added Suspend and Resume event for nrf5x port

also rename DCD_EVENT_SUSPENDED to DCD_EVENT_SUSPEND
This commit is contained in:
hathach
2019-03-29 01:34:53 +07:00
parent 8fb9fbb0b1
commit 0bdd4bd550
8 changed files with 44 additions and 15 deletions
+29 -7
View File
@@ -207,6 +207,13 @@ void dcd_set_config (uint8_t rhport, uint8_t config_num)
(void) rhport;
(void) config_num;
// Nothing to do
// Clear current pending
NRF_USBD->EVENTCAUSE |= NRF_USBD->EVENTCAUSE;
NRF_USBD->EVENTS_USBEVENT = 0;
// Enable usb event for suspend and resume
NRF_USBD->INTENSET = USBD_INTEN_USBEVENT_Msk;
}
//--------------------------------------------------------------------+
@@ -358,13 +365,34 @@ void USBD_IRQHandler(void)
}
}
/*------------- Interrupt Processing -------------*/
if ( int_status & USBD_INTEN_USBRESET_Msk )
{
bus_reset();
dcd_event_bus_signal(0, DCD_EVENT_BUS_RESET, true);
}
if ( int_status & USBD_INTEN_SOF_Msk )
{
dcd_event_bus_signal(0, DCD_EVENT_SOF, true);
}
if ( int_status & USBD_INTEN_USBEVENT_Msk )
{
uint32_t const evt_cause = NRF_USBD->EVENTCAUSE;
if ( evt_cause & USBD_EVENTCAUSE_SUSPEND_Msk )
{
dcd_event_bus_signal(0, DCD_EVENT_SUSPEND, true);
}
if ( evt_cause & USBD_EVENTCAUSE_RESUME_Msk )
{
dcd_event_bus_signal(0, DCD_EVENT_RESUME , true);
}
NRF_USBD->EVENTCAUSE = evt_cause; // clear interrupt
}
if ( int_status & EDPT_END_ALL_MASK )
{
// DMA complete move data from SRAM -> Endpoint
@@ -502,12 +530,6 @@ void USBD_IRQHandler(void)
}
}
}
// SOF interrupt
if ( int_status & USBD_INTEN_SOF_Msk )
{
dcd_event_bus_signal(0, DCD_EVENT_SOF, true);
}
}
#endif
+2 -2
View File
@@ -212,8 +212,8 @@ void tusb_hal_nrf_power_event (uint32_t event)
nrf_usbd_isosplit_set(USBD_ISOSPLIT_SPLIT_HalfIN);
// Enable interrupt. SOF is used as CDC auto flush
NRF_USBD->INTENSET = USBD_INTEN_USBRESET_Msk | USBD_INTEN_USBEVENT_Msk | USBD_INTEN_EPDATA_Msk |
// Enable interrupt
NRF_USBD->INTENSET = USBD_INTEN_USBRESET_Msk | USBD_INTEN_EPDATA_Msk |
USBD_INTEN_EP0SETUP_Msk | USBD_INTEN_EP0DATADONE_Msk | USBD_INTEN_ENDEPIN0_Msk | USBD_INTEN_ENDEPOUT0_Msk;
// Enable interrupt, priorities should be set by application