summaryrefslogtreecommitdiff
path: root/src/typec
diff options
context:
space:
mode:
authorHa Thach <[email protected]>2025-09-27 20:38:03 +0700
committerGitHub <[email protected]>2025-09-27 20:38:03 +0700
commit152d25ed621393a991561b7de61c2f01bbadeb71 (patch)
tree7a75a0a3da032421907e26616f67f7f1d55b2d09 /src/typec
parent1f9c41566165b23ff573bf1b9bfd077cfbe9067f (diff)
parent0655f98359de7e9299d8047d94a1087bdd3618ac (diff)
Merge pull request #3256 from hathach/weak_cb
Migrate weak function override to new syntax, update delay api usage
Diffstat (limited to 'src/typec')
-rw-r--r--src/typec/usbc.c25
-rw-r--r--src/typec/usbc.h4
2 files changed, 21 insertions, 8 deletions
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
@@ -60,6 +60,23 @@ bool parse_msg_data(uint8_t rhport, pd_header_t const* header, uint8_t const* do
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;
+}
+
+//--------------------------------------------------------------------+
//
//--------------------------------------------------------------------+
bool tuc_inited(uint8_t rhport) {
@@ -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);
//--------------------------------------------------------------------+
//