From e0784750aab4bd71896d6683de00b15324b8cb0f Mon Sep 17 00:00:00 2001 From: Luca Burelli Date: Tue, 4 Jul 2023 12:24:35 +0200 Subject: [PATCH] shared/tinyusb: Avoid symbol clash on targets with external TinyUSB. On targets that provide a reference TinyUSB implementation, like ESP32, the SDK already defines and implements standard callback functions such as tud_cdc_line_state_cb(). This causes a symbol clash when enabling shared implementations like the MicroPython 1200 touch functionality. To avoid this symbol clash, add an optional macro to allow ports to use a different function name in the shared implementation. Signed-off-by: Luca Burelli --- shared/tinyusb/mp_cdc_common.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/shared/tinyusb/mp_cdc_common.c b/shared/tinyusb/mp_cdc_common.c index cd4f5d1013..4ccae4bac1 100644 --- a/shared/tinyusb/mp_cdc_common.c +++ b/shared/tinyusb/mp_cdc_common.c @@ -39,7 +39,13 @@ STATIC void usbd_cdc_run_bootloader_task(mp_sched_node_t *node) { machine_bootloader(0, NULL); } -void tud_cdc_line_state_cb(uint8_t itf, bool dtr, bool rts) { +void +#if MICROPY_HW_USB_EXTERNAL_TINYUSB +mp_usbd_line_state_cb +#else +tud_cdc_line_state_cb +#endif + (uint8_t itf, bool dtr, bool rts) { if (dtr == false && rts == false) { // Device is disconnected. cdc_line_coding_t line_coding;