nrf5x: Add support for dcd_sof_enable().

This commit is contained in:
Andrew Leech 2024-05-16 16:05:36 +10:00
parent e229270a1c
commit 160cd79fdb

View File

@ -120,6 +120,9 @@ static struct {
// nRF can only carry one DMA at a time, this is used to guard the access to EasyDMA // nRF can only carry one DMA at a time, this is used to guard the access to EasyDMA
atomic_flag dma_running; atomic_flag dma_running;
// Track whether sof has been manually enabled
bool sof_enabled;
} _dcd; } _dcd;
/*------------------------------------------------------------------*/ /*------------------------------------------------------------------*/
@ -283,9 +286,13 @@ void dcd_connect(uint8_t rhport) {
void dcd_sof_enable(uint8_t rhport, bool en) { void dcd_sof_enable(uint8_t rhport, bool en) {
(void) rhport; (void) rhport;
(void) en; if (en) {
_dcd.sof_enabled = true;
// TODO implement later NRF_USBD->INTENSET = USBD_INTENSET_SOF_Msk;
} else {
_dcd.sof_enabled = false;
NRF_USBD->INTENCLR = USBD_INTENCLR_SOF_Msk;
}
} }
//--------------------------------------------------------------------+ //--------------------------------------------------------------------+
@ -607,13 +614,16 @@ void dcd_int_handler(uint8_t rhport) {
} }
} }
if (!iso_enabled) { if (!iso_enabled && !_dcd.sof_enabled) {
// ISO endpoint is not used, SOF is only enabled one-time for remote wakeup // SOF interrupt not manually enabled and ISO endpoint is not used,
// so we disable it now // SOF is only enabled one-time for remote wakeup so we disable it now
NRF_USBD->INTENCLR = USBD_INTENSET_SOF_Msk;
NRF_USBD->INTENCLR = USBD_INTENCLR_SOF_Msk;
} }
dcd_event_bus_signal(0, DCD_EVENT_SOF, true); const uint32_t frame = NRF_USBD->FRAMECNTR;
dcd_event_sof(0, frame, true);
//dcd_event_bus_signal(0, DCD_EVENT_SOF, true);
} }
if (int_status & USBD_INTEN_USBEVENT_Msk) { if (int_status & USBD_INTEN_USBEVENT_Msk) {