From 369a1ff5153a472327d2847c7bc7386309486b34 Mon Sep 17 00:00:00 2001 From: HiFiPhile Date: Wed, 17 Sep 2025 22:37:45 +0200 Subject: Update weak callbacks to new syntax Signed-off-by: HiFiPhile --- src/device/dcd.h | 2 +- src/device/usbd.c | 13 +++++++++---- src/device/usbd_pvt.h | 2 +- 3 files changed, 11 insertions(+), 6 deletions(-) (limited to 'src/device') 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); -- cgit v1.3.1 From e621f2f77b19dce0a9f288ebd608ebf98d2f817b Mon Sep 17 00:00:00 2001 From: HiFiPhile Date: Thu, 18 Sep 2025 19:09:10 +0200 Subject: set driver count to 0 Signed-off-by: HiFiPhile --- src/device/usbd.c | 2 +- src/host/usbh.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'src/device') diff --git a/src/device/usbd.c b/src/device/usbd.c index 6b5c3d846..5792359f6 100644 --- a/src/device/usbd.c +++ b/src/device/usbd.c @@ -397,7 +397,7 @@ bool usbd_control_xfer_cb (uint8_t rhport, uint8_t ep_addr, xfer_result_t event, // 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; + *driver_count = 0; return NULL; } diff --git a/src/host/usbh.c b/src/host/usbh.c index fafcc0fef..6bafde368 100644 --- a/src/host/usbh.c +++ b/src/host/usbh.c @@ -89,7 +89,7 @@ TU_ATTR_WEAK bool hcd_dcache_clean_invalidate(const void* addr, uint32_t data_si } TU_ATTR_WEAK usbh_class_driver_t const* usbh_app_driver_get_cb(uint8_t* driver_count) { - (void) driver_count; + *driver_count = 0; return NULL; } -- cgit v1.3.1 From 0961e06845591792031b69515bc56f2e5b3fa60d Mon Sep 17 00:00:00 2001 From: HiFiPhile Date: Thu, 18 Sep 2025 19:14:27 +0200 Subject: Add usbd_edpt_xfer_fifo stub Signed-off-by: HiFiPhile --- src/device/usbd.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/device') diff --git a/src/device/usbd.c b/src/device/usbd.c index 5792359f6..b1aef0b38 100644 --- a/src/device/usbd.c +++ b/src/device/usbd.c @@ -401,6 +401,11 @@ TU_ATTR_WEAK usbd_class_driver_t const* usbd_app_driver_get_cb(uint8_t* driver_c return NULL; } +TU_ATTR_WEAK bool dcd_edpt_xfer_fifo(uint8_t rhport, uint8_t ep_addr, tu_fifo_t * ff, uint16_t total_bytes) { + (void) rhport; (void) ep_addr; (void) ff; (void) total_bytes; + return false; +} + //--------------------------------------------------------------------+ // Debug //--------------------------------------------------------------------+ -- cgit v1.3.1