void handleUsbConnection() { #if defined(PCBTARANIS) && !defined(SIMU) static bool usbStarted = false; if (!usbStarted && usbPlugged()) { usbStarted = true; /* We used to initialize USB peripheral and driver here. According to my tests this is way too late. The USB peripheral therefore does not have enough information to start responding to USB host request, which causes very slow USB device recognition, multiple USB device resets, etc... If we want to change the USB profile, the procedure is simple: * USB cable must be disconnected * call usbDeInit(); * call usbUnit(); which initializes USB with the new profile. Obviously the usbInit() should be modified to have a runtime selection of the USB profile. */ #if defined(USB_MASS_STORAGE) opentxClose(); usbPluggedIn(); #endif } if (usbStarted && !usbPlugged()) { usbStarted = false; } #if defined(USB_JOYSTICK) if (usbStarted ) { usbJoystickUpdate(); } #endif #endif //#if defined(PCBTARANIS) && !defined(SIMU) }
void menusTask(void * pdata) { opentxInit(); #if defined(PCBTARANIS) && defined(REV9E) while (1) { uint32_t pwr_check = pwrCheck(); if (pwr_check == e_power_off) { break; } else if (pwr_check == e_power_press) { continue; } #else while (pwrCheck() != e_power_off) { #endif U64 start = CoGetOSTime(); perMain(); // TODO remove completely massstorage from sky9x firmware U32 runtime = (U32)(CoGetOSTime() - start); // deduct the thread run-time from the wait, if run-time was more than // desired period, then skip the wait all together if (runtime < MENU_TASK_PERIOD_TICKS) { CoTickDelay(MENU_TASK_PERIOD_TICKS - runtime); } } #if defined(REV9E) topLcdOff(); #endif BACKLIGHT_OFF(); #if defined(PCBTARANIS) displaySleepBitmap(); #else lcd_clear(); displayPopup(STR_SHUTDOWN); #endif opentxClose(); boardOff(); // Only turn power off if necessary } extern void audioTask(void* pdata); void tasksStart() { CoInitOS(); #if defined(CLI) cliStart(); #endif #if defined(BLUETOOTH) btTaskId = CoCreateTask(btTask, NULL, 15, &btStack[BT_STACK_SIZE-1], BT_STACK_SIZE); #endif mixerTaskId = CoCreateTask(mixerTask, NULL, 5, &mixerStack[MIXER_STACK_SIZE-1], MIXER_STACK_SIZE); menusTaskId = CoCreateTask(menusTask, NULL, 10, &menusStack[MENUS_STACK_SIZE-1], MENUS_STACK_SIZE); audioTaskId = CoCreateTask(audioTask, NULL, 7, &audioStack[AUDIO_STACK_SIZE-1], AUDIO_STACK_SIZE); #if !defined(SIMU) audioMutex = CoCreateMutex(); mixerMutex = CoCreateMutex(); #endif CoStartOS(); }