Skip to content
Snippets Groups Projects
Commit e6590357 authored by swym's avatar swym
Browse files

fatfs_schedule_attach: attach directly if we're running in thread

context
parent 37bc28e7
No related branches found
No related tags found
No related merge requests found
Pipeline #3424 passed
......@@ -25,6 +25,7 @@
#include "modules/log.h"
#include "modules/modules.h"
#include "api/common.h"
#include "core_cmFunc.h" //__get_IPSR()
#define SSLOG_DEBUG(...) LOG_DEBUG("fatfs", __VA_ARGS__)
#define SSLOG_INFO(...) LOG_INFO("fatfs", __VA_ARGS__)
......@@ -167,8 +168,14 @@ int fatfs_attach()
void fatfs_schedule_attach(void)
{
//if we're running in thread context, cont't call the *FromISR version
if (__get_IPSR() == 0) {
xTimerPendFunctionCall(
cb_attachTimer, NULL, 0, 1); //wait 1 tick
} else {
xTimerPendFunctionCallFromISR(cb_attachTimer, NULL, 0, NULL);
}
}
void fatfs_detach()
{
......
......@@ -133,23 +133,29 @@ static int mscmem_ready()
return mx25_ready();
}
static bool s_fsDetached = false;
int epic_usb_shutdown(void)
{
esb_deinit();
if (s_fsDetached) {
fatfs_attach();
}
return 0;
}
int epic_usb_storage(void)
{
esb_deinit();
s_fsDetached = true;
return esb_init(&s_cfg_msc);
}
int epic_usb_cdcacm(void)
{
esb_deinit();
if (s_fsDetached) {
fatfs_attach();
}
return esb_init(&s_cfg_cdcacm);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment