summaryrefslogtreecommitdiff
path: root/src/device
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/device
parent606f932d92322a71960f51148ecc91eaf29bf507 (diff)
Add SOF callback function for feedback value determination in uac - wip!
Diffstat (limited to 'src/device')
-rw-r--r--src/device/usbd.c22
-rw-r--r--src/device/usbd_pvt.h5
2 files changed, 23 insertions, 4 deletions
diff --git a/src/device/usbd.c b/src/device/usbd.c
index 8662d5b84..170342072 100644
--- a/src/device/usbd.c
+++ b/src/device/usbd.c
@@ -139,7 +139,7 @@ static usbd_class_driver_t const _usbd_driver[] =
.open = audiod_open,
.control_xfer_cb = audiod_control_xfer_cb,
.xfer_cb = audiod_xfer_cb,
- .sof = NULL
+ .sof = audiod_sof
},
#endif
@@ -612,7 +612,7 @@ void tud_task (void)
for ( uint8_t i = 0; i < TOTAL_DRIVER_COUNT; i++ )
{
usbd_class_driver_t const * driver = get_driver(i);
- if ( driver->sof ) driver->sof(event.rhport);
+ if ( driver->sof ) driver->sof(event.rhport, event.sof.frame_count);
}
break;
@@ -1131,7 +1131,18 @@ void dcd_event_handler(dcd_event_t const * event, bool in_isr)
break;
case DCD_EVENT_SOF:
- // SOF Handler
+ // SOF driver handler in ISR context
+ for (uint8_t i = 0; i < TOTAL_DRIVER_COUNT; i++)
+ {
+ usbd_class_driver_t const * driver = get_driver(i);
+ if (driver->sof)
+ {
+ driver->sof(event->rhport, event->sof.frame_count);
+ // TU_LOG2("%s sof\r\n", driver->name); // too demanding
+ }
+ }
+
+ // SOF user handler in ISR context
if (_sof_isr) _sof_isr(event->sof.frame_count);
// Some MCUs after running dcd_remote_wakeup() does not have way to detect the end of remote wakeup
@@ -1441,4 +1452,9 @@ void usbd_edpt_close(uint8_t rhport, uint8_t ep_addr)
return;
}
+void usbd_sof_enable(uint8_t rhport, bool en)
+{
+ dcd_sof_enable(rhport, en);
+}
+
#endif
diff --git a/src/device/usbd_pvt.h b/src/device/usbd_pvt.h
index dae95cebb..f9fb543df 100644
--- a/src/device/usbd_pvt.h
+++ b/src/device/usbd_pvt.h
@@ -48,7 +48,7 @@ typedef struct
uint16_t (* open ) (uint8_t rhport, tusb_desc_interface_t const * desc_intf, uint16_t max_len);
bool (* control_xfer_cb ) (uint8_t rhport, uint8_t stage, tusb_control_request_t const * request);
bool (* xfer_cb ) (uint8_t rhport, uint8_t ep_addr, xfer_result_t result, uint32_t xferred_bytes);
- void (* sof ) (uint8_t rhport); /* optional */
+ void (* sof ) (uint8_t rhport, uint32_t frame_count); /* optional */
} usbd_class_driver_t;
// Invoked when initializing device stack to get additional class drivers.
@@ -102,6 +102,9 @@ bool usbd_edpt_ready(uint8_t rhport, uint8_t ep_addr)
return !usbd_edpt_busy(rhport, ep_addr) && !usbd_edpt_stalled(rhport, ep_addr);
}
+// Enable SOF interrupt
+void usbd_sof_enable(uint8_t rhport, bool en);
+
/*------------------------------------------------------------------*/
/* Helper
*------------------------------------------------------------------*/