summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrew Leech <[email protected]>2024-05-16 16:05:36 +1000
committerAndrew Leech <[email protected]>2024-05-27 20:35:35 +1000
commit160cd79fdb9fee70894c4d9bfe908af38b88dc46 (patch)
tree93e4a15f2e2bcd8d80a24eaaecee5a7b022a36d1 /src
parente229270a1c3d542cdf9924313f585dd43c607de8 (diff)
nrf5x: Add support for dcd_sof_enable().
Diffstat (limited to 'src')
-rw-r--r--src/portable/nordic/nrf5x/dcd_nrf5x.c26
1 files changed, 18 insertions, 8 deletions
diff --git a/src/portable/nordic/nrf5x/dcd_nrf5x.c b/src/portable/nordic/nrf5x/dcd_nrf5x.c
index bb07063d2..abce35245 100644
--- a/src/portable/nordic/nrf5x/dcd_nrf5x.c
+++ b/src/portable/nordic/nrf5x/dcd_nrf5x.c
@@ -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 manually enabled
+ bool sof_enabled;
} _dcd;
/*------------------------------------------------------------------*/
@@ -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;
+ }
}
//--------------------------------------------------------------------+
@@ -607,13 +614,16 @@ 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);
+ 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) {