summaryrefslogtreecommitdiff
path: root/src/device
diff options
context:
space:
mode:
authorHiFiPhile <[email protected]>2025-09-17 22:37:45 +0200
committerHiFiPhile <[email protected]>2025-09-17 22:48:59 +0200
commit369a1ff5153a472327d2847c7bc7386309486b34 (patch)
tree7b8e6403bb1017e14fa224865eb73f4e10a3ba18 /src/device
parentd9ad09a8dce9e54cbd23062f8dec6c4fd49dc906 (diff)
Update weak callbacks to new syntax
Signed-off-by: HiFiPhile <[email protected]>
Diffstat (limited to 'src/device')
-rw-r--r--src/device/dcd.h2
-rw-r--r--src/device/usbd.c13
-rw-r--r--src/device/usbd_pvt.h2
3 files changed, 11 insertions, 6 deletions
diff --git a/src/device/dcd.h b/src/device/dcd.h
index 789552d47..400f62bff 100644
--- a/src/device/dcd.h
+++ b/src/device/dcd.h
@@ -162,7 +162,7 @@ bool dcd_edpt_xfer (uint8_t rhport, uint8_t ep_addr, uint8_t * buffer
// Submit an transfer using fifo, When complete dcd_event_xfer_complete() is invoked to notify the stack
// This API is optional, may be useful for register-based for transferring data.
-bool dcd_edpt_xfer_fifo (uint8_t rhport, uint8_t ep_addr, tu_fifo_t * ff, uint16_t total_bytes) TU_ATTR_WEAK;
+bool dcd_edpt_xfer_fifo (uint8_t rhport, uint8_t ep_addr, tu_fifo_t * ff, uint16_t total_bytes);
// Stall endpoint, any queuing transfer should be removed from endpoint
void dcd_edpt_stall (uint8_t rhport, uint8_t ep_addr);
diff --git a/src/device/usbd.c b/src/device/usbd.c
index b09d02fbd..6b5c3d846 100644
--- a/src/device/usbd.c
+++ b/src/device/usbd.c
@@ -393,6 +393,13 @@ void usbd_control_set_request(tusb_control_request_t const *request);
void usbd_control_set_complete_callback( usbd_control_xfer_cb_t fp );
bool usbd_control_xfer_cb (uint8_t rhport, uint8_t ep_addr, xfer_result_t event, uint32_t xferred_bytes);
+//--------------------------------------------------------------------+
+// Weak stubs: invoked if no strong implementation is available
+//--------------------------------------------------------------------+
+TU_ATTR_WEAK usbd_class_driver_t const* usbd_app_driver_get_cb(uint8_t* driver_count) {
+ (void) driver_count;
+ return NULL;
+}
//--------------------------------------------------------------------+
// Debug
@@ -516,10 +523,8 @@ bool tud_rhport_init(uint8_t rhport, const tusb_rhport_init_t* rh_init) {
TU_ASSERT(_usbd_q);
// Get application driver if available
- if (usbd_app_driver_get_cb) {
- _app_driver = usbd_app_driver_get_cb(&_app_driver_count);
- TU_ASSERT(_app_driver_count + BUILTIN_DRIVER_COUNT <= UINT8_MAX);
- }
+ _app_driver = usbd_app_driver_get_cb(&_app_driver_count);
+ TU_ASSERT(_app_driver_count + BUILTIN_DRIVER_COUNT <= UINT8_MAX);
// Init class drivers
for (uint8_t i = 0; i < TOTAL_DRIVER_COUNT; i++) {
diff --git a/src/device/usbd_pvt.h b/src/device/usbd_pvt.h
index f1797bf0d..a688cf497 100644
--- a/src/device/usbd_pvt.h
+++ b/src/device/usbd_pvt.h
@@ -64,7 +64,7 @@ typedef struct {
// Invoked when initializing device stack to get additional class drivers.
// Can be implemented by application to extend/overwrite class driver support.
// Note: The drivers array must be accessible at all time when stack is active
-usbd_class_driver_t const* usbd_app_driver_get_cb(uint8_t* driver_count) TU_ATTR_WEAK;
+usbd_class_driver_t const* usbd_app_driver_get_cb(uint8_t* driver_count);
typedef bool (*usbd_control_xfer_cb_t)(uint8_t rhport, uint8_t stage, tusb_control_request_t const * request);