@@ -97,18 +97,32 @@ TU_ATTR_ALWAYS_INLINE static inline bool tuh_cdc_connected(uint8_t idx)
97
97
return tuh_cdc_get_dtr (idx );
98
98
}
99
99
100
+ //--------------------------------------------------------------------+
101
+ // Write API
102
+ //--------------------------------------------------------------------+
103
+
104
+ // Get the number of bytes available for writing
105
+ uint32_t tuh_cdc_write_available (uint8_t idx );
106
+
100
107
// Write to cdc interface
101
108
uint32_t tuh_cdc_write (uint8_t idx , void const * buffer , uint32_t bufsize );
102
109
103
110
// Force sending data if possible, return number of forced bytes
104
111
uint32_t tuh_cdc_write_flush (uint8_t idx );
105
112
106
- // Read from cdc interface
107
- uint32_t tuh_cdc_read (uint8_t idx , void * buffer , uint32_t bufsize );
113
+ //--------------------------------------------------------------------+
114
+ // Read API
115
+ //--------------------------------------------------------------------+
108
116
109
117
// Get the number of bytes available for reading
110
118
uint32_t tuh_cdc_read_available (uint8_t idx );
111
119
120
+ // Read from cdc interface
121
+ uint32_t tuh_cdc_read (uint8_t idx , void * buffer , uint32_t bufsize );
122
+
123
+ // Clear the received FIFO
124
+ void tuh_cdc_read_flush (uint8_t idx );
125
+
112
126
//--------------------------------------------------------------------+
113
127
// Control Endpoint (Request) API
114
128
//--------------------------------------------------------------------+
@@ -132,47 +146,13 @@ static inline bool tuh_cdc_disconnect(uint8_t idx, tuh_xfer_cb_t complete_cb, ui
132
146
133
147
// Invoked when a device with CDC interface is mounted
134
148
// idx is index of cdc interface in the internal pool.
135
- TU_ATTR_WEAK void tuh_cdc_mount_cb (uint8_t idx );
149
+ TU_ATTR_WEAK extern void tuh_cdc_mount_cb (uint8_t idx );
136
150
137
151
// Invoked when a device with CDC interface is unmounted
138
- TU_ATTR_WEAK void tuh_cdc_umount_cb (uint8_t idx );
139
-
140
- /** \brief Check if the interface is currently busy or not
141
- * \param[in] dev_addr device address
142
- * \param[in] pipeid value from \ref cdc_pipeid_t to indicate target pipe.
143
- * \retval true if the interface is busy, meaning the stack is still transferring/waiting data from/to device
144
- * \retval false if the interface is not busy, meaning the stack successfully transferred data from/to device
145
- * \note This function is used to check if previous transfer is complete (success or error), so that the next transfer
146
- * can be scheduled. User needs to make sure the corresponding interface is mounted
147
- * (by \ref tuh_cdc_serial_is_mounted) before calling this function.
148
- */
149
- // bool tuh_cdc_is_busy(uint8_t dev_addr, cdc_pipeid_t pipeid);
150
-
151
- /** \brief Perform USB OUT transfer to device
152
- * \param[in] dev_addr device address
153
- * \param[in] p_data Buffer containing data. Must be accessible by USB controller (see \ref CFG_TUSB_MEM_SECTION)
154
- * \param[in] length Number of bytes to be transferred via USB bus
155
- * \retval TUSB_ERROR_NONE on success
156
- * \retval TUSB_ERROR_INTERFACE_IS_BUSY if the interface is already transferring data with device
157
- * \retval TUSB_ERROR_DEVICE_NOT_READY if device is not yet configured (by SET CONFIGURED request)
158
- * \retval TUSB_ERROR_INVALID_PARA if input parameters are not correct
159
- * \note This function is non-blocking and returns immediately. The result of USB transfer will be reported by the
160
- * interface's callback function. \a p_data must be declared with \ref CFG_TUSB_MEM_SECTION.
161
- */
162
- // bool tuh_cdc_send(uint8_t dev_addr, void const * p_data, uint32_t length, bool is_notify);
163
-
164
- /** \brief Perform USB IN transfer to get data from device
165
- * \param[in] dev_addr device address
166
- * \param[in] p_buffer Buffer containing received data. Must be accessible by USB controller (see \ref CFG_TUSB_MEM_SECTION)
167
- * \param[in] length Number of bytes to be transferred via USB bus
168
- * \retval TUSB_ERROR_NONE on success
169
- * \retval TUSB_ERROR_INTERFACE_IS_BUSY if the interface is already transferring data with device
170
- * \retval TUSB_ERROR_DEVICE_NOT_READY if device is not yet configured (by SET CONFIGURED request)
171
- * \retval TUSB_ERROR_INVALID_PARA if input parameters are not correct
172
- * \note This function is non-blocking and returns immediately. The result of USB transfer will be reported by the
173
- * interface's callback function. \a p_data must be declared with \ref CFG_TUSB_MEM_SECTION.
174
- */
175
- // bool tuh_cdc_receive(uint8_t dev_addr, void * p_buffer, uint32_t length, bool is_notify);
152
+ TU_ATTR_WEAK extern void tuh_cdc_umount_cb (uint8_t idx );
153
+
154
+ // Invoked when received new data
155
+ TU_ATTR_WEAK extern void tuh_cdc_rx_cb (uint8_t idx );
176
156
177
157
//--------------------------------------------------------------------+
178
158
// CDC APPLICATION CALLBACKS
0 commit comments