summaryrefslogtreecommitdiff
path: root/src/class/cdc/cdc_device.h
diff options
context:
space:
mode:
authorHa Thach <[email protected]>2025-11-27 11:42:31 +0700
committerGitHub <[email protected]>2025-11-27 11:42:31 +0700
commit5ef55bfa30d6f8cf175b3d327f621c76aae7b138 (patch)
tree26fd4779ccaa8b7b2d6cb5aa3badc02fa1cd6a67 /src/class/cdc/cdc_device.h
parent38842491bb55260c0cc7d7709abe5b0e73a0de61 (diff)
parent8cf2c3b00b2f8188571e4bd9f0e66ffc5ae188a3 (diff)
Merge pull request #3359 from hathach/xfer-fifo
remove ep buffer for port with dedicated hw fifo
Diffstat (limited to 'src/class/cdc/cdc_device.h')
-rw-r--r--src/class/cdc/cdc_device.h38
1 files changed, 36 insertions, 2 deletions
diff --git a/src/class/cdc/cdc_device.h b/src/class/cdc/cdc_device.h
index 6f21af4f3..0809b578f 100644
--- a/src/class/cdc/cdc_device.h
+++ b/src/class/cdc/cdc_device.h
@@ -36,6 +36,14 @@
#define CFG_TUD_CDC_NOTIFY 0
#endif
+#ifndef CFG_TUD_CDC_TX_BUFSIZE
+ #define CFG_TUD_CDC_TX_BUFSIZE (TUD_OPT_HIGH_SPEED ? 512 : 64)
+#endif
+
+#ifndef CFG_TUD_CDC_RX_BUFSIZE
+ #define CFG_TUD_CDC_RX_BUFSIZE (TUD_OPT_HIGH_SPEED ? 512 : 64)
+#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
@@ -133,11 +141,37 @@ bool tud_cdc_n_write_clear(uint8_t itf);
#if CFG_TUD_CDC_NOTIFY
+bool tud_cdc_n_notify_msg(uint8_t itf, cdc_notify_msg_t *msg);
+
// Send UART status notification: DCD, DSR etc ..
-bool tud_cdc_n_notify_uart_state(uint8_t itf, const cdc_notify_uart_state_t *state);
+TU_ATTR_ALWAYS_INLINE static inline bool tud_cdc_n_notify_uart_state(uint8_t itf,
+ const cdc_notify_uart_state_t *state) {
+ cdc_notify_msg_t notify_msg;
+ notify_msg.request.bmRequestType = CDC_REQ_TYPE_NOTIF;
+ notify_msg.request.bRequest = CDC_NOTIF_SERIAL_STATE;
+ notify_msg.request.wValue = 0;
+ notify_msg.request.wIndex = 0; // filled later
+ notify_msg.request.wLength = sizeof(cdc_notify_uart_state_t);
+ notify_msg.serial_state = *state;
+ return tud_cdc_n_notify_msg(itf, &notify_msg);
+}
// 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_n_notify_conn_speed_change(uint8_t itf, const cdc_notify_conn_speed_change_t *conn_speed_change) {
+ cdc_notify_msg_t notify_msg;
+ notify_msg.request.bmRequestType = CDC_REQ_TYPE_NOTIF;
+ notify_msg.request.bRequest = CDC_NOTIF_CONNECTION_SPEED_CHANGE;
+ notify_msg.request.wValue = 0;
+ notify_msg.request.wIndex = 0; // filled later
+ notify_msg.request.wLength = sizeof(cdc_notify_conn_speed_change_t);
+ notify_msg.conn_speed_change = *conn_speed_change;
+ return tud_cdc_n_notify_msg(itf, &notify_msg);
+}
+
+TU_ATTR_ALWAYS_INLINE static inline bool tud_cdc_notify_msg(cdc_notify_msg_t *msg) {
+ return tud_cdc_n_notify_msg(0, msg);
+}
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);