mirror of
https://github.com/hathach/tinyusb.git
synced 2025-03-25 01:43:47 +00:00
usb work when sd is init first
This commit is contained in:
parent
ae560bd825
commit
6752a71264
@ -188,8 +188,25 @@ void board_init(void)
|
||||
uint32_t usb_reg;
|
||||
|
||||
#ifdef SOFTDEVICE_PRESENT
|
||||
|
||||
// Enable to test enable SD before USB scenario
|
||||
#if 1
|
||||
extern void nrf_error_cb(uint32_t id, uint32_t pc, uint32_t info);
|
||||
nrf_clock_lf_cfg_t clock_cfg =
|
||||
{
|
||||
// LFXO
|
||||
.source = NRF_CLOCK_LF_SRC_XTAL,
|
||||
.rc_ctiv = 0,
|
||||
.rc_temp_ctiv = 0,
|
||||
.accuracy = NRF_CLOCK_LF_ACCURACY_20_PPM
|
||||
};
|
||||
|
||||
sd_softdevice_enable(&clock_cfg, nrf_error_cb);
|
||||
NVIC_EnableIRQ(SD_EVT_IRQn);
|
||||
#endif
|
||||
|
||||
uint8_t sd_en = false;
|
||||
(void) sd_softdevice_is_enabled(&sd_en);
|
||||
sd_softdevice_is_enabled(&sd_en);
|
||||
|
||||
if ( sd_en ) {
|
||||
sd_power_usbdetected_enable(true);
|
||||
@ -240,7 +257,7 @@ uint32_t board_buttons(void)
|
||||
return ret;
|
||||
}
|
||||
|
||||
uint8_t board_uart_getchar(void)
|
||||
uint8_t board_uart_getchar(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
@ -251,12 +268,46 @@ void board_uart_putchar(uint8_t c)
|
||||
}
|
||||
|
||||
#ifdef SOFTDEVICE_PRESENT
|
||||
|
||||
// process SOC event from SD
|
||||
uint32_t proc_soc(void)
|
||||
{
|
||||
uint32_t soc_evt;
|
||||
uint32_t err = sd_evt_get(&soc_evt);
|
||||
|
||||
if (NRF_SUCCESS == err)
|
||||
{
|
||||
/*------------- usb power event handler -------------*/
|
||||
int32_t usbevt = (soc_evt == NRF_EVT_POWER_USB_DETECTED ) ? NRFX_POWER_USB_EVT_DETECTED:
|
||||
(soc_evt == NRF_EVT_POWER_USB_POWER_READY) ? NRFX_POWER_USB_EVT_READY :
|
||||
(soc_evt == NRF_EVT_POWER_USB_REMOVED ) ? NRFX_POWER_USB_EVT_REMOVED : -1;
|
||||
|
||||
if ( usbevt >= 0) tusb_hal_nrf_power_event(usbevt);
|
||||
}
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
uint32_t proc_ble(void)
|
||||
{
|
||||
// do nothing with ble
|
||||
return NRF_ERROR_NOT_FOUND;
|
||||
}
|
||||
|
||||
void SD_EVT_IRQHandler(void)
|
||||
{
|
||||
// process BLE and SOC until there is no more events
|
||||
while( (NRF_ERROR_NOT_FOUND != proc_ble()) || (NRF_ERROR_NOT_FOUND != proc_soc()) )
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void SVC_Handler( void )
|
||||
void nrf_error_cb(uint32_t id, uint32_t pc, uint32_t info)
|
||||
{
|
||||
(void) id;
|
||||
(void) pc;
|
||||
(void) info;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user