summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrédéric Desbiens <[email protected]>2026-03-05 18:17:08 +0100
committerGitHub <[email protected]>2026-03-05 18:17:08 +0100
commit35ba5436a9c2f0fd694749198d196f9c2f504615 (patch)
tree1d9e50f2ed2c8be8c0113f643de6b2cc2042d378
parent7e76808d0f7c8278b23bc329185ca2a9c4923811 (diff)
parent7f5c6b2f9620449a0ab757e8ef86d85a91f6816d (diff)
Merge pull request #248 from ayedm1/cdc_acm_device_break_req
Added break request support to Device CDC ACM
-rw-r--r--common/usbx_device_classes/inc/ux_device_class_cdc_acm.h6
-rw-r--r--common/usbx_device_classes/src/ux_device_class_cdc_acm_control_request.c18
-rw-r--r--common/usbx_device_classes/src/ux_device_class_cdc_acm_deactivate.c5
-rw-r--r--common/usbx_device_classes/src/ux_device_class_cdc_acm_initialize.c9
-rw-r--r--test/regression/usbx_cdc_acm_basic_test.c33
5 files changed, 62 insertions, 9 deletions
diff --git a/common/usbx_device_classes/inc/ux_device_class_cdc_acm.h b/common/usbx_device_classes/inc/ux_device_class_cdc_acm.h
index 6eebb20..e52f591 100644
--- a/common/usbx_device_classes/inc/ux_device_class_cdc_acm.h
+++ b/common/usbx_device_classes/inc/ux_device_class_cdc_acm.h
@@ -9,16 +9,19 @@
* SPDX-License-Identifier: MIT
**************************************************************************/
+
/**************************************************************************/
/**************************************************************************/
/** */
/** USBX Component */
/** */
-/** CDC Class */
+/** Device CDC ACM Class */
/** */
/**************************************************************************/
/**************************************************************************/
+
+/**************************************************************************/
/**************************************************************************/
/* */
/* COMPONENT DEFINITION RELEASE */
@@ -221,6 +224,7 @@ typedef struct UX_SLAVE_CLASS_CDC_ACM_STRUCT
UCHAR ux_slave_class_cdc_acm_data_bit;
UCHAR ux_slave_class_cdc_acm_data_dtr_state;
UCHAR ux_slave_class_cdc_acm_data_rts_state;
+ ULONG ux_slave_class_cdc_acm_break_duration;
UCHAR reserved[3];
#ifndef UX_DEVICE_CLASS_CDC_ACM_TRANSMISSION_DISABLE
diff --git a/common/usbx_device_classes/src/ux_device_class_cdc_acm_control_request.c b/common/usbx_device_classes/src/ux_device_class_cdc_acm_control_request.c
index 12b4030..fa43630 100644
--- a/common/usbx_device_classes/src/ux_device_class_cdc_acm_control_request.c
+++ b/common/usbx_device_classes/src/ux_device_class_cdc_acm_control_request.c
@@ -9,12 +9,13 @@
* SPDX-License-Identifier: MIT
**************************************************************************/
+
/**************************************************************************/
/**************************************************************************/
/** */
/** USBX Component */
/** */
-/** Device CDC Class */
+/** Device CDC ACM Class */
/** */
/**************************************************************************/
/**************************************************************************/
@@ -161,6 +162,20 @@ ULONG transmit_length;
break ;
+ case UX_SLAVE_CLASS_CDC_ACM_SEND_BREAK:
+
+ /* SEND_BREAK has no data stage, wValue contains break duration in ms.
+ 0x0000 means stop break.
+ 0x0001-0xFFFE means break signal duration in ms.
+ 0xFFFF means indefinite break. */
+ cdc_acm -> ux_slave_class_cdc_acm_break_duration = (ULONG) value;
+
+ /* If there is a parameter change function call it. */
+ if (cdc_acm -> ux_slave_class_cdc_acm_parameter.ux_slave_class_cdc_acm_parameter_change != UX_NULL)
+ cdc_acm -> ux_slave_class_cdc_acm_parameter.ux_slave_class_cdc_acm_parameter_change(cdc_acm);
+
+ break;
+
default:
/* Unknown function. It's not handled. */
@@ -170,4 +185,3 @@ ULONG transmit_length;
/* It's handled. */
return(UX_SUCCESS);
}
-
diff --git a/common/usbx_device_classes/src/ux_device_class_cdc_acm_deactivate.c b/common/usbx_device_classes/src/ux_device_class_cdc_acm_deactivate.c
index f05e035..6061356 100644
--- a/common/usbx_device_classes/src/ux_device_class_cdc_acm_deactivate.c
+++ b/common/usbx_device_classes/src/ux_device_class_cdc_acm_deactivate.c
@@ -9,12 +9,13 @@
* SPDX-License-Identifier: MIT
**************************************************************************/
+
/**************************************************************************/
/**************************************************************************/
/** */
/** USBX Component */
/** */
-/** Device CDC Class */
+/** Device CDC ACM Class */
/** */
/**************************************************************************/
/**************************************************************************/
@@ -119,6 +120,8 @@ UX_SLAVE_ENDPOINT *endpoint_out;
cdc_acm -> ux_slave_class_cdc_acm_data_dtr_state = 0;
cdc_acm -> ux_slave_class_cdc_acm_data_rts_state = 0;
+ cdc_acm -> ux_slave_class_cdc_acm_break_duration = 0;
+
/* If trace is enabled, insert this event into the trace buffer. */
UX_TRACE_IN_LINE_INSERT(UX_TRACE_DEVICE_CLASS_CDC_ACM_DEACTIVATE, cdc_acm, 0, 0, 0, UX_TRACE_DEVICE_CLASS_EVENTS, 0, 0)
diff --git a/common/usbx_device_classes/src/ux_device_class_cdc_acm_initialize.c b/common/usbx_device_classes/src/ux_device_class_cdc_acm_initialize.c
index 6330aa6..a78969b 100644
--- a/common/usbx_device_classes/src/ux_device_class_cdc_acm_initialize.c
+++ b/common/usbx_device_classes/src/ux_device_class_cdc_acm_initialize.c
@@ -9,11 +9,13 @@
* SPDX-License-Identifier: MIT
**************************************************************************/
+
+/**************************************************************************/
/**************************************************************************/
/** */
/** USBX Component */
/** */
-/** Device CDC Class */
+/** Device CDC ACM Class */
/** */
/**************************************************************************/
/**************************************************************************/
@@ -48,7 +50,7 @@
/* */
/* INPUT */
/* */
-/* command Pointer to cdc_acm command */
+/* command Pointer to cdc acm command */
/* */
/* OUTPUT */
/* */
@@ -161,6 +163,9 @@ UINT status;
cdc_acm -> ux_slave_class_cdc_acm_parity = UX_SLAVE_CLASS_CDC_ACM_LINE_CODING_PARITY;
cdc_acm -> ux_slave_class_cdc_acm_data_bit = UX_SLAVE_CLASS_CDC_ACM_LINE_CODING_DATA_BIT;
+ /* Initialize break duration. */
+ cdc_acm -> ux_slave_class_cdc_acm_break_duration = 0;
+
#ifndef UX_DEVICE_CLASS_CDC_ACM_TRANSMISSION_DISABLE
#if defined(UX_DEVICE_STANDALONE)
diff --git a/test/regression/usbx_cdc_acm_basic_test.c b/test/regression/usbx_cdc_acm_basic_test.c
index 9997c4c..0b7cd2a 100644
--- a/test/regression/usbx_cdc_acm_basic_test.c
+++ b/test/regression/usbx_cdc_acm_basic_test.c
@@ -1177,6 +1177,7 @@ ULONG test_n;
UX_HOST_CLASS_COMMAND command;
UX_HOST_CLASS_COMMAND command1;
ULONG mem_free;
+USHORT break_ms;
stepinfo("\n");
@@ -2100,10 +2101,36 @@ ULONG mem_free;
}
/* Try IOCTRL UX_HOST_CLASS_CDC_ACM_IOCTL_SEND_BREAK */
+
stepinfo(">>>>>>>>>>>> IOCTRL UX_HOST_CLASS_CDC_ACM_IOCTL_SEND_BREAK\n");
- status = ux_host_class_cdc_acm_ioctl(cdc_acm_host_control, UX_HOST_CLASS_CDC_ACM_IOCTL_SEND_BREAK, &test_n);
- /* Not supported by simulator */
- if (status == UX_SUCCESS)
+
+ break_ms = 0xFFFF;
+
+ status = ux_host_class_cdc_acm_ioctl(cdc_acm_host_control, UX_HOST_CLASS_CDC_ACM_IOCTL_SEND_BREAK, &break_ms);
+
+ if ((status != UX_SUCCESS) || (cdc_acm_slave -> ux_slave_class_cdc_acm_break_duration != break_ms))
+ {
+
+ printf("ERROR #78: IOCTRL UX_HOST_CLASS_CDC_ACM_IOCTL_SEND_BREAK should fail\n");
+ test_control_return(1);
+ }
+
+ break_ms = 1000;
+
+ status = ux_host_class_cdc_acm_ioctl(cdc_acm_host_control, UX_HOST_CLASS_CDC_ACM_IOCTL_SEND_BREAK, &break_ms);
+
+ if ((status != UX_SUCCESS) || (cdc_acm_slave -> ux_slave_class_cdc_acm_break_duration != break_ms))
+ {
+
+ printf("ERROR #78: IOCTRL UX_HOST_CLASS_CDC_ACM_IOCTL_SEND_BREAK should fail\n");
+ test_control_return(1);
+ }
+
+ break_ms = 0x0000;
+
+ status = ux_host_class_cdc_acm_ioctl(cdc_acm_host_control, UX_HOST_CLASS_CDC_ACM_IOCTL_SEND_BREAK, &break_ms);
+
+ if ((status != UX_SUCCESS) || (cdc_acm_slave -> ux_slave_class_cdc_acm_break_duration != break_ms))
{
printf("ERROR #78: IOCTRL UX_HOST_CLASS_CDC_ACM_IOCTL_SEND_BREAK should fail\n");