summaryrefslogtreecommitdiff
path: root/src/portable
diff options
context:
space:
mode:
authorReinhard Panhuber <[email protected]>2022-03-14 20:40:33 +0100
committerReinhard Panhuber <[email protected]>2022-03-14 20:40:33 +0100
commitf212899b54740479eff225d89432d88f0a14f17e (patch)
treeb0897d02339446e1a2ef23b1ae5928d6f46875f1 /src/portable
parent606f932d92322a71960f51148ecc91eaf29bf507 (diff)
Add SOF callback function for feedback value determination in uac - wip!
Diffstat (limited to 'src/portable')
-rw-r--r--src/portable/synopsys/dwc2/dcd_dwc2.c32
1 files changed, 28 insertions, 4 deletions
diff --git a/src/portable/synopsys/dwc2/dcd_dwc2.c b/src/portable/synopsys/dwc2/dcd_dwc2.c
index 37712d2d9..d92b17703 100644
--- a/src/portable/synopsys/dwc2/dcd_dwc2.c
+++ b/src/portable/synopsys/dwc2/dcd_dwc2.c
@@ -93,6 +93,9 @@ static uint16_t ep0_pending[2]; // Index determines direction
static uint16_t _allocated_fifo_words_tx; // TX FIFO size in words (IN EPs)
static bool _out_ep_closed; // Flag to check if RX FIFO size needs an update (reduce its size)
+// SOF enabling flag - required for SOF to not get disabled in ISR when SOF was enabled by
+static bool _sof_en;
+
// Calculate the RX FIFO size according to recommendations from reference manual
static inline uint16_t calc_rx_ff_size(uint16_t ep_size)
{
@@ -126,6 +129,8 @@ static void bus_reset(uint8_t rhport)
tu_memclr(xfer_status, sizeof(xfer_status));
_out_ep_closed = false;
+ _sof_en = false;
+
// clear device address
dwc2->dcfg &= ~DCFG_DAD_Msk;
@@ -588,12 +593,23 @@ void dcd_disconnect(uint8_t rhport)
dwc2->dctl |= DCTL_SDIS;
}
+// Be advised: audio, video and possibly other iso-ep classes use dcd_sof_enable() to enable/disable its corresponding ISR on purpose!
void dcd_sof_enable(uint8_t rhport, bool en)
{
(void) rhport;
- (void) en;
+ dwc2_regs_t * dwc2 = DWC2_REG(rhport);
+
+ _sof_en = en;
- // TODO implement later
+ if (en)
+ {
+ dwc2->gintsts = GINTSTS_SOF;
+ dwc2->gintmsk |= GINTMSK_SOFM;
+ }
+ else
+ {
+ dwc2->gintmsk &= ~GINTMSK_SOFM;
+ }
}
/*------------------------------------------------------------------*/
@@ -1258,8 +1274,16 @@ void dcd_int_handler(uint8_t rhport)
{
dwc2->gotgint = GINTSTS_SOF;
- // Disable SOF interrupt since currently only used for remote wakeup detection
- dwc2->gintmsk &= ~GINTMSK_SOFM;
+ if (_sof_en)
+ {
+ uint32_t frame = (dwc2->dsts & (USB_OTG_DSTS_FNSOF)) >> 8;
+ dcd_event_sof(rhport, frame, true);
+ }
+ else
+ {
+ // Disable SOF interrupt if SOF was not explicitly enabled. SOF was used for remote wakeup detection
+ dwc2->gintmsk &= ~GINTMSK_SOFM;
+ }
dcd_event_bus_signal(rhport, DCD_EVENT_SOF, true);
}