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/typec/usbc.c | 25 +++++++++++++++++++------ src/typec/usbc.h | 4 ++-- 2 files changed, 21 insertions(+), 8 deletions(-) (limited to 'src/typec') diff --git a/src/typec/usbc.c b/src/typec/usbc.c index fdf2a0cd6..20abd1700 100644 --- a/src/typec/usbc.c +++ b/src/typec/usbc.c @@ -59,6 +59,23 @@ bool usbc_msg_send(uint8_t rhport, pd_header_t const* header, void const* data); bool parse_msg_data(uint8_t rhport, pd_header_t const* header, uint8_t const* dobj, uint8_t const* p_end); bool parse_msg_control(uint8_t rhport, pd_header_t const* header); +//--------------------------------------------------------------------+ +// Weak stubs: invoked if no strong implementation is available +//--------------------------------------------------------------------+ +TU_ATTR_WEAK bool tuc_pd_data_received_cb(uint8_t rhport, pd_header_t const* header, uint8_t const* dobj, uint8_t const* p_end) { + (void) rhport; + (void) header; + (void) dobj; + (void) p_end; + return false; +} + +TU_ATTR_WEAK bool tuc_pd_control_received_cb(uint8_t rhport, pd_header_t const* header) { + (void) rhport; + (void) header; + return false; +} + //--------------------------------------------------------------------+ // //--------------------------------------------------------------------+ @@ -136,17 +153,13 @@ void tuc_task_ext(uint32_t timeout_ms, bool in_isr) { } bool parse_msg_data(uint8_t rhport, pd_header_t const* header, uint8_t const* dobj, uint8_t const* p_end) { - if (tuc_pd_data_received_cb) { - tuc_pd_data_received_cb(rhport, header, dobj, p_end); - } + tuc_pd_data_received_cb(rhport, header, dobj, p_end); return true; } bool parse_msg_control(uint8_t rhport, pd_header_t const* header) { - if (tuc_pd_control_received_cb) { - tuc_pd_control_received_cb(rhport, header); - } + tuc_pd_control_received_cb(rhport, header); return true; } diff --git a/src/typec/usbc.h b/src/typec/usbc.h index 9fbff9bc6..448542aab 100644 --- a/src/typec/usbc.h +++ b/src/typec/usbc.h @@ -74,8 +74,8 @@ extern void tcd_int_handler(uint8_t rhport); // Callbacks //--------------------------------------------------------------------+ -TU_ATTR_WEAK bool tuc_pd_data_received_cb(uint8_t rhport, pd_header_t const* header, uint8_t const* dobj, uint8_t const* p_end); -TU_ATTR_WEAK bool tuc_pd_control_received_cb(uint8_t rhport, pd_header_t const* header); +bool tuc_pd_data_received_cb(uint8_t rhport, pd_header_t const* header, uint8_t const* dobj, uint8_t const* p_end); +bool tuc_pd_control_received_cb(uint8_t rhport, pd_header_t const* header); //--------------------------------------------------------------------+ // -- cgit v1.3.1