Skip to content

Commit

Permalink
nrf5x: Add support for dcd_sof_enable().
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewleech committed May 16, 2024
1 parent 8642081 commit 99c2d26
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions src/portable/nordic/nrf5x/dcd_nrf5x.c
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,9 @@ static struct {

// nRF can only carry one DMA at a time, this is used to guard the access to EasyDMA
atomic_flag dma_running;

// Track whether sof has been manully enabled
bool sof_enabled;
} _dcd;

/*------------------------------------------------------------------*/
Expand Down Expand Up @@ -283,9 +286,13 @@ void dcd_connect(uint8_t rhport) {

void dcd_sof_enable(uint8_t rhport, bool en) {
(void) rhport;
(void) en;

// TODO implement later
if (en) {
_dcd.sof_enabled = true;
NRF_USBD->INTENSET = USBD_INTENSET_SOF_Msk;
} else {
_dcd.sof_enabled = false;
NRF_USBD->INTENCLR = USBD_INTENCLR_SOF_Msk;
}
}

//--------------------------------------------------------------------+
Expand Down Expand Up @@ -607,10 +614,11 @@ void dcd_int_handler(uint8_t rhport) {
}
}

if (!iso_enabled) {
// ISO endpoint is not used, SOF is only enabled one-time for remote wakeup
// so we disable it now
NRF_USBD->INTENCLR = USBD_INTENSET_SOF_Msk;
if (!iso_enabled && !_dcd.sof_enabled) {
// SOF interrupt not manually enabled and ISO endpoint is not used,
// SOF is only enabled one-time for remote wakeup so we disable it now

NRF_USBD->INTENCLR = USBD_INTENCLR_SOF_Msk;
}

dcd_event_bus_signal(0, DCD_EVENT_SOF, true);
Expand Down

0 comments on commit 99c2d26

Please sign in to comment.