Merge branch 'master' into devlocal

This commit is contained in:
hathach 2018-12-21 12:17:48 +07:00
commit 89be1cf9f8
2 changed files with 15 additions and 2 deletions

View File

@ -128,8 +128,9 @@ static void wait_for_events(void)
app_sched_execute(); app_sched_execute();
#ifdef NRF52840_XXAA #ifdef NRF52840_XXAA
// usb is not enabled in OTA // skip if usb is not inited ( e.g OTA / finializing sd/bootloader )
if ( !is_ota() ) extern bool usb_inited(void);
if ( usb_inited() )
{ {
tusb_task(); tusb_task();
tud_cdc_write_flush(); tud_cdc_write_flush();

View File

@ -65,8 +65,20 @@ extern void tusb_hal_nrf_power_event(uint32_t event);
//------------- IMPLEMENTATION -------------// //------------- IMPLEMENTATION -------------//
static bool _inited = false;
bool usb_inited(void)
{
return _inited;
}
void usb_init(bool cdc_only) void usb_init(bool cdc_only)
{ {
// skipped if already inited
if ( _inited ) return;
_inited = true;
// USB power may already be ready at this time -> no event generated // USB power may already be ready at this time -> no event generated
// We need to invoke the handler based on the status initially // We need to invoke the handler based on the status initially
uint32_t usb_reg; uint32_t usb_reg;