summaryrefslogtreecommitdiff
path: root/src/class/cdc/cdc_device.h
diff options
context:
space:
mode:
authorhathach <[email protected]>2025-07-03 13:42:05 +0700
committerhathach <[email protected]>2025-07-03 13:42:05 +0700
commit41606a533dbe4bb7e031267d2869401243d2a0aa (patch)
tree956bedfa8a4dc3bc6676b4b8df15f1b66a8f664f /src/class/cdc/cdc_device.h
parentcf3966efd9fc552d641ea1e76e5aaad3ace3afd2 (diff)
make notify API and memory configurable with CFG_TUD_CDC_NOTIFY
add tud_cdc_n_notify_conn_speed_change() add tud_cdc_notify_complete_cb()
Diffstat (limited to 'src/class/cdc/cdc_device.h')
-rw-r--r--src/class/cdc/cdc_device.h34
1 files changed, 25 insertions, 9 deletions
diff --git a/src/class/cdc/cdc_device.h b/src/class/cdc/cdc_device.h
index f6fa5abf8..a34e07e1d 100644
--- a/src/class/cdc/cdc_device.h
+++ b/src/class/cdc/cdc_device.h
@@ -32,6 +32,10 @@
//--------------------------------------------------------------------+
// Class Driver Configuration
//--------------------------------------------------------------------+
+#ifndef CFG_TUD_CDC_NOTIFY
+ #define CFG_TUD_CDC_NOTIFY 0
+#endif
+
#if !defined(CFG_TUD_CDC_EP_BUFSIZE) && defined(CFG_TUD_CDC_EPSIZE)
#warning CFG_TUD_CDC_EPSIZE is renamed to CFG_TUD_CDC_EP_BUFSIZE, please update to use the new name
#define CFG_TUD_CDC_EP_BUFSIZE CFG_TUD_CDC_EPSIZE
@@ -83,9 +87,6 @@ uint8_t tud_cdc_n_get_line_state(uint8_t itf);
// Get current line encoding: bit rate, stop bits parity etc ..
void tud_cdc_n_get_line_coding(uint8_t itf, cdc_line_coding_t* coding);
-// Send UART status notification: DCD, DSR etc ..
-bool tud_cdc_n_send_uart_state(uint8_t itf, cdc_uart_state_t state);
-
// Set special character that will trigger tud_cdc_rx_wanted_cb() callback on receiving
void tud_cdc_n_set_wanted_char(uint8_t itf, char wanted);
@@ -129,6 +130,23 @@ uint32_t tud_cdc_n_write_available(uint8_t itf);
// Clear the transmit FIFO
bool tud_cdc_n_write_clear(uint8_t itf);
+
+#if CFG_TUD_CDC_NOTIFY
+// Send UART status notification: DCD, DSR etc ..
+bool tud_cdc_n_notify_uart_state(uint8_t itf, const cdc_notify_uart_state_t *state);
+
+// Send connection speed change notification
+bool tud_cdc_n_notify_conn_speed_change(uint8_t itf, const cdc_notify_conn_speed_change_t* conn_speed_change);
+
+TU_ATTR_ALWAYS_INLINE static inline bool tud_cdc_notify_uart_state(const cdc_notify_uart_state_t* state) {
+ return tud_cdc_n_notify_uart_state(0, state);
+}
+
+TU_ATTR_ALWAYS_INLINE static inline bool tud_cdc_notify_conn_speed_change(const cdc_notify_conn_speed_change_t* conn_speed_change) {
+ return tud_cdc_n_notify_conn_speed_change(0, conn_speed_change);
+}
+#endif
+
//--------------------------------------------------------------------+
// Application API (Single Port)
//--------------------------------------------------------------------+
@@ -149,11 +167,6 @@ TU_ATTR_ALWAYS_INLINE static inline void tud_cdc_get_line_coding(cdc_line_coding
tud_cdc_n_get_line_coding(0, coding);
}
-TU_ATTR_ALWAYS_INLINE static inline bool tud_cdc_send_uart_state(cdc_uart_state_t state) {
- return tud_cdc_n_send_uart_state(0, state);
-}
-
-
TU_ATTR_ALWAYS_INLINE static inline void tud_cdc_set_wanted_char(char wanted) {
tud_cdc_n_set_wanted_char(0, wanted);
}
@@ -203,7 +216,7 @@ TU_ATTR_ALWAYS_INLINE static inline bool tud_cdc_write_clear(void) {
}
//--------------------------------------------------------------------+
-// Application Callback API (weak is optional)
+// Application Callback API
//--------------------------------------------------------------------+
// Invoked when received new data
@@ -215,6 +228,9 @@ TU_ATTR_WEAK void tud_cdc_rx_wanted_cb(uint8_t itf, char wanted_char);
// Invoked when a TX is complete and therefore space becomes available in TX buffer
TU_ATTR_WEAK void tud_cdc_tx_complete_cb(uint8_t itf);
+// Invoked when a notification is sent to host
+TU_ATTR_WEAK void tud_cdc_notify_complete_cb(uint8_t itf);
+
// Invoked when line state DTR & RTS are changed via SET_CONTROL_LINE_STATE
TU_ATTR_WEAK void tud_cdc_line_state_cb(uint8_t itf, bool dtr, bool rts);