summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Ajax <[email protected]>2026-08-30 09:44:23 -0700
committerMike Ajax <[email protected]>2026-08-30 09:44:23 -0700
commit1e3c2faed4db782f093aa4c88fc98fa81cccc77a (patch)
tree0ce666304c49aaa9bef025496a28b485716104c8
parent84dcec43c709643f8a1b1ebbab6d08fbbc605a6d (diff)
Add "attached" state callback for UCPD
-rw-r--r--src/typec/usbc.c10
-rw-r--r--src/typec/usbc.h1
2 files changed, 10 insertions, 1 deletions
diff --git a/src/typec/usbc.c b/src/typec/usbc.c
index dc59b35be..ab7dd0b92 100644
--- a/src/typec/usbc.c
+++ b/src/typec/usbc.c
@@ -57,6 +57,11 @@ TU_ATTR_WEAK bool tuc_pd_control_received_cb(uint8_t rhport, pd_header_t const*
return false;
}
+TU_ATTR_WEAK void tuc_attach_changed_cb(uint8_t rhport, bool attached) {
+ (void) rhport;
+ (void) attached;
+}
+
TU_ATTR_WEAK void tcd_connect(uint8_t rhport) {
(void) rhport;
}
@@ -124,8 +129,11 @@ void tuc_task_ext(uint32_t timeout_ms, bool in_isr) {
if (!osal_queue_receive(_usbc_q, &event, timeout_ms)) return;
switch (event.event_id) {
- case TCD_EVENT_CC_CHANGED:
+ case TCD_EVENT_CC_CHANGED: {
+ bool const attached = event.cc_changed.cc_state[0] != 0 || event.cc_changed.cc_state[1] != 0;
+ tuc_attach_changed_cb(event.rhport, attached);
break;
+ }
case TCD_EVENT_RX_COMPLETE:
// TODO process message here in ISR, move to thread later
diff --git a/src/typec/usbc.h b/src/typec/usbc.h
index 9fca7da0d..fc4773b07 100644
--- a/src/typec/usbc.h
+++ b/src/typec/usbc.h
@@ -65,6 +65,7 @@ extern void tcd_int_handler(uint8_t rhport);
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);
+void tuc_attach_changed_cb(uint8_t rhport, bool attached);
//--------------------------------------------------------------------+
//