diff options
| author | HiFiPhile <[email protected]> | 2026-06-24 21:15:33 +0200 |
|---|---|---|
| committer | HiFiPhile <[email protected]> | 2026-06-24 21:15:33 +0200 |
| commit | f35af01db58ba76bef1a65a56458bc815497ebbe (patch) | |
| tree | 0e890d9579690742e0a2c1e6a4f6956be5a8bbad /src/typec | |
| parent | 3a1ced7e1333de7ddf57f8592a41cbf0605512ed (diff) | |
typec: add tuc_connect/tuc_disconnect api
Signed-off-by: HiFiPhile <[email protected]>
Diffstat (limited to 'src/typec')
| -rw-r--r-- | src/typec/pd_types.h | 3 | ||||
| -rw-r--r-- | src/typec/tcd.h | 6 | ||||
| -rw-r--r-- | src/typec/usbc.c | 22 | ||||
| -rw-r--r-- | src/typec/usbc.h | 8 |
4 files changed, 38 insertions, 1 deletions
diff --git a/src/typec/pd_types.h b/src/typec/pd_types.h index 950f4d488..eebcec632 100644 --- a/src/typec/pd_types.h +++ b/src/typec/pd_types.h @@ -46,7 +46,8 @@ TU_ATTR_BIT_FIELD_ORDER_BEGIN typedef enum { TUSB_TYPEC_PORT_SRC, TUSB_TYPEC_PORT_SNK, - TUSB_TYPEC_PORT_DRP + TUSB_TYPEC_PORT_DRP, + TUSB_TYPEC_PORT_DISCONNECTED, } tusb_typec_port_type_t; enum { diff --git a/src/typec/tcd.h b/src/typec/tcd.h index da7ab4b13..6e18cd063 100644 --- a/src/typec/tcd.h +++ b/src/typec/tcd.h @@ -78,6 +78,12 @@ void tcd_int_enable (uint8_t rhport); // Disable interrupt void tcd_int_disable(uint8_t rhport); +// Enable Type-C port terminations +void tcd_connect(uint8_t rhport); + +// Disable Type-C port terminations +void tcd_disconnect(uint8_t rhport); + // Interrupt Handler void tcd_int_handler(uint8_t rhport); diff --git a/src/typec/usbc.c b/src/typec/usbc.c index 20abd1700..8071e93c3 100644 --- a/src/typec/usbc.c +++ b/src/typec/usbc.c @@ -76,6 +76,14 @@ TU_ATTR_WEAK bool tuc_pd_control_received_cb(uint8_t rhport, pd_header_t const* return false; } +TU_ATTR_WEAK void tcd_connect(uint8_t rhport) { + (void) rhport; +} + +TU_ATTR_WEAK void tcd_disconnect(uint8_t rhport) { + (void) rhport; +} + //--------------------------------------------------------------------+ // //--------------------------------------------------------------------+ @@ -83,6 +91,20 @@ bool tuc_inited(uint8_t rhport) { return _usbc_inited && _port_inited[rhport]; } +bool tuc_connect(uint8_t rhport) { + TU_VERIFY(rhport < TUP_TYPEC_RHPORTS_NUM && tuc_inited(rhport)); + + tcd_connect(rhport); + return true; +} + +bool tuc_disconnect(uint8_t rhport) { + TU_VERIFY(rhport < TUP_TYPEC_RHPORTS_NUM && tuc_inited(rhport)); + + tcd_disconnect(rhport); + return true; +} + bool tuc_init(uint8_t rhport, uint32_t port_type) { // Initialize stack if (!_usbc_inited) { diff --git a/src/typec/usbc.h b/src/typec/usbc.h index 711119596..ed8595d27 100644 --- a/src/typec/usbc.h +++ b/src/typec/usbc.h @@ -52,6 +52,14 @@ bool tuc_init(uint8_t rhport, uint32_t port_type); // Check if typec port is initialized bool tuc_inited(uint8_t rhport); +// Enable Type-C port terminations +// Return false if port is not initialized +bool tuc_connect(uint8_t rhport); + +// Disable Type-C port terminations +// Return false if port is not initialized +bool tuc_disconnect(uint8_t rhport); + // Task function should be called in main/rtos loop, extended version of tud_task() // - timeout_ms: millisecond to wait, zero = no wait, 0xFFFFFFFF = wait forever // - in_isr: if function is called in ISR |
