Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion common/usbx_device_classes/inc/ux_device_class_cdc_acm.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,19 @@
* SPDX-License-Identifier: MIT
**************************************************************************/


/**************************************************************************/
/**************************************************************************/
/** */
/** USBX Component */
/** */
/** CDC Class */
/** Device CDC ACM Class */
/** */
/**************************************************************************/
/**************************************************************************/


/**************************************************************************/
/**************************************************************************/
/* */
/* COMPONENT DEFINITION RELEASE */
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,13 @@
* SPDX-License-Identifier: MIT
**************************************************************************/


/**************************************************************************/
/**************************************************************************/
/** */
/** USBX Component */
/** */
/** Device CDC Class */
/** Device CDC ACM Class */
/** */
/**************************************************************************/
/**************************************************************************/
Expand Down Expand Up @@ -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. */
Expand All @@ -170,4 +185,3 @@ ULONG transmit_length;
/* It's handled. */
return(UX_SUCCESS);
}

Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,13 @@
* SPDX-License-Identifier: MIT
**************************************************************************/


/**************************************************************************/
/**************************************************************************/
/** */
/** USBX Component */
/** */
/** Device CDC Class */
/** Device CDC ACM Class */
/** */
/**************************************************************************/
/**************************************************************************/
Expand Down Expand Up @@ -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)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,13 @@
* SPDX-License-Identifier: MIT
**************************************************************************/


/**************************************************************************/
/**************************************************************************/
/** */
/** USBX Component */
/** */
/** Device CDC Class */
/** Device CDC ACM Class */
/** */
/**************************************************************************/
/**************************************************************************/
Expand Down Expand Up @@ -48,7 +50,7 @@
/* */
/* INPUT */
/* */
/* command Pointer to cdc_acm command */
/* command Pointer to cdc acm command */
/* */
/* OUTPUT */
/* */
Expand Down Expand Up @@ -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)
Expand Down
33 changes: 30 additions & 3 deletions test/regression/usbx_cdc_acm_basic_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -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");

Expand Down Expand Up @@ -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");
Expand Down