added Suspend and Resume event for nrf5x port
also rename DCD_EVENT_SUSPENDED to DCD_EVENT_SUSPEND
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -339,7 +339,7 @@ void USB_IRQHandler(void)
|
||||
// Note: Host may delay more than 3 ms before and/or after bus reset before doing enumeration.
|
||||
if (dev_cmd_stat & CMDSTAT_DEVICE_ADDR_MASK)
|
||||
{
|
||||
dcd_event_bus_signal(0, DCD_EVENT_SUSPENDED, true);
|
||||
dcd_event_bus_signal(0, DCD_EVENT_SUSPEND, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -481,7 +481,7 @@ static void bus_event_isr(uint8_t rhport)
|
||||
{
|
||||
if (dev_status & SIE_DEV_STATUS_SUSPEND_MASK)
|
||||
{
|
||||
dcd_event_bus_signal(rhport, DCD_EVENT_SUSPENDED, true);
|
||||
dcd_event_bus_signal(rhport, DCD_EVENT_SUSPEND, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -303,7 +303,7 @@ void hal_dcd_isr(uint8_t rhport)
|
||||
// Note: Host may delay more than 3 ms before and/or after bus reset before doing enumeration.
|
||||
if ((lpc_usb->DEVICEADDR >> 25) & 0x0f)
|
||||
{
|
||||
dcd_event_bus_signal(rhport, DCD_EVENT_SUSPENDED, true);
|
||||
dcd_event_bus_signal(rhport, DCD_EVENT_SUSPEND, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user