diff options
| author | iabdalkader <i.abdalkader@gmail.com> | 2025-11-21 09:18:20 +0100 |
|---|---|---|
| committer | Damien George <damien@micropython.org> | 2025-11-24 12:19:12 +1100 |
| commit | db8273def84510d71cd4d3017b345d83fe8b90bc (patch) | |
| tree | 7422f7f74f061512eb97e0afd3d322087d535acd /shared/tinyusb/mp_usbd_cdc.c | |
| parent | a6864109db645045790d97b2e2b471d24a9a0560 (diff) | |
shared/tinyusb: Add macro to override TinyUSB callbacks.
Add wrapper macros that by default expand to the callback name.
Users can define this macro to add a prefix (e.g., mp_) to
callback implementations, to redirect or completely override
MicroPython's TinyUSB callbacks.
Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
Diffstat (limited to 'shared/tinyusb/mp_usbd_cdc.c')
| -rw-r--r-- | shared/tinyusb/mp_usbd_cdc.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/shared/tinyusb/mp_usbd_cdc.c b/shared/tinyusb/mp_usbd_cdc.c index 9b380acef..961bdf898 100644 --- a/shared/tinyusb/mp_usbd_cdc.c +++ b/shared/tinyusb/mp_usbd_cdc.c @@ -68,7 +68,7 @@ uintptr_t mp_usbd_cdc_poll_interfaces(uintptr_t poll_flags) { return ret; } -void tud_cdc_rx_cb(uint8_t itf) { +void MICROPY_WRAP_TUD_CDC_RX_CB(tud_cdc_rx_cb)(uint8_t itf) { // consume pending USB data immediately to free usb buffer and keep the endpoint from stalling. // in case the ringbuffer is full, mark the CDC interface that need attention later on for polling cdc_itf_pending &= ~(1 << itf); @@ -141,7 +141,7 @@ mp_uint_t mp_usbd_cdc_tx_strn(const char *str, mp_uint_t len) { return i; } -void tud_sof_cb(uint32_t frame_count) { +void MICROPY_WRAP_TUD_SOF_CB(tud_sof_cb)(uint32_t frame_count) { if (--cdc_connected_flush_delay < 0) { // Finished on-connection delay, disable SOF interrupt again. tud_sof_cb_enable(false); @@ -172,7 +172,7 @@ static struct { } prev_line_state = {0}; #endif -void tud_cdc_line_state_cb(uint8_t itf, bool dtr, bool rts) { +void MICROPY_WRAP_TUD_CDC_LINE_STATE_CB(tud_cdc_line_state_cb)(uint8_t itf, bool dtr, bool rts) { #if MICROPY_HW_USB_CDC && !MICROPY_EXCLUDE_SHARED_TINYUSB_USBD_CDC if (dtr) { // A host application has started to open the cdc serial port. |
