29
29
#if CFG_TUC_ENABLED
30
30
31
31
#include "tcd.h"
32
- #include "utcd .h"
32
+ #include "usbc .h"
33
33
34
34
//--------------------------------------------------------------------+
35
35
//
36
36
//--------------------------------------------------------------------+
37
37
38
38
// Debug level of USBD
39
- #define UTCD_DEBUG 2
40
- #define TU_LOG_UTCD (...) TU_LOG(UTCD_DEBUG , __VA_ARGS__)
39
+ #define USBC_DEBUG 2
40
+ #define TU_LOG_USBC (...) TU_LOG(USBC_DEBUG , __VA_ARGS__)
41
41
42
42
// Event queue
43
- // utcd_int_set () is used as mutex in OS NONE config
44
- void utcd_int_set (bool enabled );
45
- OSAL_QUEUE_DEF (utcd_int_set , _utcd_qdef , CFG_TUC_TASK_QUEUE_SZ , tcd_event_t );
46
- tu_static osal_queue_t _utcd_q ;
43
+ // usbc_int_set () is used as mutex in OS NONE config
44
+ void usbc_int_set (bool enabled );
45
+ OSAL_QUEUE_DEF (usbc_int_set , _usbc_qdef , CFG_TUC_TASK_QUEUE_SZ , tcd_event_t );
46
+ tu_static osal_queue_t _usbc_q ;
47
47
48
48
// if stack is initialized
49
- static bool _utcd_inited = false;
49
+ static bool _usbc_inited = false;
50
50
51
51
// if port is initialized
52
52
static bool _port_inited [TUP_TYPEC_RHPORTS_NUM ];
@@ -55,35 +55,35 @@ static bool _port_inited[TUP_TYPEC_RHPORTS_NUM];
55
55
static uint8_t _rx_buf [64 ] TU_ATTR_ALIGNED (4 );
56
56
static uint8_t _tx_buf [64 ] TU_ATTR_ALIGNED (4 );
57
57
58
- bool utcd_msg_send (uint8_t rhport , pd_header_t const * header , void const * data );
58
+ bool usbc_msg_send (uint8_t rhport , pd_header_t const * header , void const * data );
59
59
bool parse_msg_data (uint8_t rhport , pd_header_t const * header , uint8_t const * dobj , uint8_t const * p_end );
60
60
bool parse_msg_control (uint8_t rhport , pd_header_t const * header );
61
61
62
62
//--------------------------------------------------------------------+
63
63
//
64
64
//--------------------------------------------------------------------+
65
65
bool tuc_inited (uint8_t rhport ) {
66
- return _utcd_inited && _port_inited [rhport ];
66
+ return _usbc_inited && _port_inited [rhport ];
67
67
}
68
68
69
69
bool tuc_init (uint8_t rhport , uint32_t port_type ) {
70
70
// Initialize stack
71
- if (!_utcd_inited ) {
71
+ if (!_usbc_inited ) {
72
72
tu_memclr (_port_inited , sizeof (_port_inited ));
73
73
74
- _utcd_q = osal_queue_create (& _utcd_qdef );
75
- TU_ASSERT (_utcd_q != NULL );
74
+ _usbc_q = osal_queue_create (& _usbc_qdef );
75
+ TU_ASSERT (_usbc_q != NULL );
76
76
77
- _utcd_inited = true;
77
+ _usbc_inited = true;
78
78
}
79
79
80
80
// skip if port already initialized
81
81
if ( _port_inited [rhport ] ) {
82
82
return true;
83
83
}
84
84
85
- TU_LOG_UTCD ( "UTCD init on port %u\r\n" , rhport );
86
- TU_LOG_INT (UTCD_DEBUG , sizeof (tcd_event_t ));
85
+ TU_LOG_USBC ( "USBC init on port %u\r\n" , rhport );
86
+ TU_LOG_INT (USBC_DEBUG , sizeof (tcd_event_t ));
87
87
88
88
TU_ASSERT (tcd_init (rhport , port_type ));
89
89
tcd_int_enable (rhport );
@@ -96,12 +96,12 @@ void tuc_task_ext(uint32_t timeout_ms, bool in_isr) {
96
96
(void ) in_isr ; // not implemented yet
97
97
98
98
// Skip if stack is not initialized
99
- if (!_utcd_inited ) return ;
99
+ if (!_usbc_inited ) return ;
100
100
101
101
// Loop until there is no more events in the queue
102
102
while (1 ) {
103
103
tcd_event_t event ;
104
- if (!osal_queue_receive (_utcd_q , & event , timeout_ms )) return ;
104
+ if (!osal_queue_receive (_usbc_q , & event , timeout_ms )) return ;
105
105
106
106
switch (event .event_id ) {
107
107
case TCD_EVENT_CC_CHANGED :
@@ -155,7 +155,7 @@ bool parse_msg_control(uint8_t rhport, pd_header_t const* header) {
155
155
//
156
156
//--------------------------------------------------------------------+
157
157
158
- bool utcd_msg_send (uint8_t rhport , pd_header_t const * header , void const * data ) {
158
+ bool usbc_msg_send (uint8_t rhport , pd_header_t const * header , void const * data ) {
159
159
// copy header
160
160
memcpy (_tx_buf , header , sizeof (pd_header_t ));
161
161
@@ -179,7 +179,7 @@ bool tuc_msg_request(uint8_t rhport, void const* rdo) {
179
179
.extended = 0 ,
180
180
};
181
181
182
- return utcd_msg_send (rhport , & header , rdo );
182
+ return usbc_msg_send (rhport , & header , rdo );
183
183
}
184
184
185
185
void tcd_event_handler (tcd_event_t const * event , bool in_isr ) {
@@ -197,13 +197,13 @@ void tcd_event_handler(tcd_event_t const * event, bool in_isr) {
197
197
default : break ;
198
198
}
199
199
200
- osal_queue_send (_utcd_q , event , in_isr );
200
+ osal_queue_send (_usbc_q , event , in_isr );
201
201
}
202
202
203
203
//--------------------------------------------------------------------+
204
204
//
205
205
//--------------------------------------------------------------------+
206
- void utcd_int_set (bool enabled ) {
206
+ void usbc_int_set (bool enabled ) {
207
207
// Disable all controllers since they shared the same event queue
208
208
for (uint8_t p = 0 ; p < TUP_TYPEC_RHPORTS_NUM ; p ++ ) {
209
209
if ( _port_inited [p ] ) {
0 commit comments