summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--common/usbx_device_classes/inc/ux_device_class_cdc_acm.h96
-rw-r--r--common/usbx_device_classes/src/ux_device_class_cdc_acm_control_request.c112
-rw-r--r--common/usbx_device_classes/src/ux_device_class_cdc_acm_deactivate.c83
-rw-r--r--common/usbx_device_classes/src/ux_device_class_cdc_acm_initialize.c100
-rw-r--r--test/regression/usbx_cdc_acm_basic_test.c33
5 files changed, 238 insertions, 186 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 e973676..a6fea42 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
@@ -1,42 +1,45 @@
/***************************************************************************
- * Copyright (c) 2024 Microsoft Corporation
- *
+ * Copyright (c) 2024 Microsoft Corporation
+ *
* This program and the accompanying materials are made available under the
* terms of the MIT License which is available at
* https://opensource.org/licenses/MIT.
- *
+ *
* SPDX-License-Identifier: MIT
**************************************************************************/
+
/**************************************************************************/
/**************************************************************************/
-/** */
-/** USBX Component */
/** */
-/** CDC Class */
+/** USBX Component */
+/** */
+/** Device CDC ACM Class */
/** */
/**************************************************************************/
/**************************************************************************/
-/**************************************************************************/
-/* */
-/* COMPONENT DEFINITION RELEASE */
-/* */
-/* ux_device_class_cdc_acm.h PORTABLE C */
+
+/**************************************************************************/
+/**************************************************************************/
+/* */
+/* COMPONENT DEFINITION RELEASE */
+/* */
+/* ux_device_class_cdc_acm.h PORTABLE C */
/* 6.3.0 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
/* */
/* DESCRIPTION */
-/* */
-/* This file defines the equivalences for the USBX Device Class CDC */
-/* ACM component. */
-/* */
-/* RELEASE HISTORY */
-/* */
-/* DATE NAME DESCRIPTION */
-/* */
+/* */
+/* This file defines the equivalences for the USBX Device Class CDC */
+/* ACM component. */
+/* */
+/* RELEASE HISTORY */
+/* */
+/* DATE NAME DESCRIPTION */
+/* */
/* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */
/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */
/* used UX prefix to refer to */
@@ -69,15 +72,15 @@
#ifndef UX_DEVICE_CLASS_CDC_ACM_H
#define UX_DEVICE_CLASS_CDC_ACM_H
-/* Determine if a C++ compiler is being used. If so, ensure that standard
- C is used to process the API information. */
+/* Determine if a C++ compiler is being used. If so, ensure that standard
+ C is used to process the API information. */
-#ifdef __cplusplus
+#ifdef __cplusplus
-/* Yes, C++ compiler is present. Use standard C. */
-extern "C" {
+/* Yes, C++ compiler is present. Use standard C. */
+extern "C" {
-#endif
+#endif
/* Internal option: enable the basic USBX error checking. This define is typically used
while debugging application. */
@@ -251,6 +254,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
@@ -289,23 +293,23 @@ typedef struct UX_SLAVE_CLASS_CDC_ACM_STRUCT
/* Define some CDC Class structures */
-typedef struct UX_SLAVE_CLASS_CDC_ACM_LINE_CODING_PARAMETER_STRUCT
+typedef struct UX_SLAVE_CLASS_CDC_ACM_LINE_CODING_PARAMETER_STRUCT
{
ULONG ux_slave_class_cdc_acm_parameter_baudrate;
UCHAR ux_slave_class_cdc_acm_parameter_stop_bit;
UCHAR ux_slave_class_cdc_acm_parameter_parity;
UCHAR ux_slave_class_cdc_acm_parameter_data_bit;
-
+
} UX_SLAVE_CLASS_CDC_ACM_LINE_CODING_PARAMETER;
-typedef struct UX_SLAVE_CLASS_CDC_ACM_LINE_STATE_PARAMETER_STRUCT
+typedef struct UX_SLAVE_CLASS_CDC_ACM_LINE_STATE_PARAMETER_STRUCT
{
UCHAR ux_slave_class_cdc_acm_parameter_rts;
UCHAR ux_slave_class_cdc_acm_parameter_dtr;
-
+
} UX_SLAVE_CLASS_CDC_ACM_LINE_STATE_PARAMETER;
-typedef struct UX_SLAVE_CLASS_CDC_ACM_CALLBACK_PARAMETER_STRUCT
+typedef struct UX_SLAVE_CLASS_CDC_ACM_CALLBACK_PARAMETER_STRUCT
{
UINT (*ux_device_class_cdc_acm_parameter_write_callback)(struct UX_SLAVE_CLASS_CDC_ACM_STRUCT *cdc_acm, UINT status, ULONG length);
UINT (*ux_device_class_cdc_acm_parameter_read_callback)(struct UX_SLAVE_CLASS_CDC_ACM_STRUCT *cdc_acm, UINT status, UCHAR *data_pointer, ULONG length);
@@ -316,22 +320,22 @@ typedef struct UX_SLAVE_CLASS_CDC_ACM_CALLBACK_PARAMETER_STRUCT
/* Requests - Ethernet Networking Control Model */
-#define UX_SLAVE_CLASS_CDC_ACM_SEND_ENCAPSULATED_COMMAND 0x00
+#define UX_SLAVE_CLASS_CDC_ACM_SEND_ENCAPSULATED_COMMAND 0x00
/* Issues a command in the format of the supported control
protocol. The intent of this mechanism is to support
networking devices (e.g., host-based cable modems)
that require an additional vendor-defined interface for
media specific hardware configuration and
management. */
-#define UX_SLAVE_CLASS_CDC_ACM_GET_ENCAPSULATED_RESPONSE 0x01
+#define UX_SLAVE_CLASS_CDC_ACM_GET_ENCAPSULATED_RESPONSE 0x01
/* Requests a response in the format of the supported
control protocol. */
-#define UX_SLAVE_CLASS_CDC_ACM_SET_ETHERNET_MULTICAST_FILTERS 0x40
+#define UX_SLAVE_CLASS_CDC_ACM_SET_ETHERNET_MULTICAST_FILTERS 0x40
/* As applications are loaded and unloaded on the host,
the networking transport will instruct the device's MAC
driver to change settings of the Networking device's
multicast filters. */
-#define UX_SLAVE_CLASS_CDC_ACM_SET_ETHERNET_POWER_MANAGEMENT_PATTERN_FILTER 0x41
+#define UX_SLAVE_CLASS_CDC_ACM_SET_ETHERNET_POWER_MANAGEMENT_PATTERN_FILTER 0x41
/* Some hosts are able to conserve energy and stay quiet
in a 'sleeping' state while not being used. USB
Networking devices may provide special pattern filtering
@@ -340,13 +344,13 @@ typedef struct UX_SLAVE_CLASS_CDC_ACM_CALLBACK_PARAMETER_STRUCT
host (e.g., an incoming web browser connection).
Primitives are needed in management plane to negotiate
the setting of these special filters */
-#define UX_SLAVE_CLASS_CDC_ACM_GET_ETHERNET_POWER_MANAGEMENT_PATTERN_FILTER 0x42
+#define UX_SLAVE_CLASS_CDC_ACM_GET_ETHERNET_POWER_MANAGEMENT_PATTERN_FILTER 0x42
/* Retrieves the status of the above power management
pattern filter setting */
-#define UX_SLAVE_CLASS_CDC_ACM_SET_ETHERNET_PACKET_FILTER 0x43
+#define UX_SLAVE_CLASS_CDC_ACM_SET_ETHERNET_PACKET_FILTER 0x43
/* Sets device filter for running a network analyzer
application on the host machine */
-#define UX_SLAVE_CLASS_CDC_ACM_GET_ETHERNET_STATISTIC 0x44
+#define UX_SLAVE_CLASS_CDC_ACM_GET_ETHERNET_STATISTIC 0x44
/* Retrieves Ethernet device statistics such as frames
transmitted, frames received, and bad frames received. */
@@ -363,20 +367,20 @@ UINT _ux_device_class_cdc_acm_deactivate(UX_SLAVE_CLASS_COMMAND *command);
UINT _ux_device_class_cdc_acm_entry(UX_SLAVE_CLASS_COMMAND *command);
UINT _ux_device_class_cdc_acm_initialize(UX_SLAVE_CLASS_COMMAND *command);
UINT _ux_device_class_cdc_acm_uninitialize(UX_SLAVE_CLASS_COMMAND *command);
-UINT _ux_device_class_cdc_acm_write(UX_SLAVE_CLASS_CDC_ACM *cdc_acm, UCHAR *buffer,
+UINT _ux_device_class_cdc_acm_write(UX_SLAVE_CLASS_CDC_ACM *cdc_acm, UCHAR *buffer,
ULONG requested_length, ULONG *actual_length);
-UINT _ux_device_class_cdc_acm_read(UX_SLAVE_CLASS_CDC_ACM *cdc_acm, UCHAR *buffer,
+UINT _ux_device_class_cdc_acm_read(UX_SLAVE_CLASS_CDC_ACM *cdc_acm, UCHAR *buffer,
ULONG requested_length, ULONG *actual_length);
UINT _ux_device_class_cdc_acm_ioctl(UX_SLAVE_CLASS_CDC_ACM *cdc_acm, ULONG ioctl_function,
VOID *parameter);
VOID _ux_device_class_cdc_acm_bulkin_thread(ULONG class_pointer);
VOID _ux_device_class_cdc_acm_bulkout_thread(ULONG class_pointer);
-UINT _ux_device_class_cdc_acm_write_with_callback(UX_SLAVE_CLASS_CDC_ACM *cdc_acm, UCHAR *buffer,
+UINT _ux_device_class_cdc_acm_write_with_callback(UX_SLAVE_CLASS_CDC_ACM *cdc_acm, UCHAR *buffer,
ULONG requested_length);
-UINT _ux_device_class_cdc_acm_write_run(UX_SLAVE_CLASS_CDC_ACM *cdc_acm, UCHAR *buffer,
+UINT _ux_device_class_cdc_acm_write_run(UX_SLAVE_CLASS_CDC_ACM *cdc_acm, UCHAR *buffer,
ULONG requested_length, ULONG *actual_length);
-UINT _ux_device_class_cdc_acm_read_run(UX_SLAVE_CLASS_CDC_ACM *cdc_acm, UCHAR *buffer,
+UINT _ux_device_class_cdc_acm_read_run(UX_SLAVE_CLASS_CDC_ACM *cdc_acm, UCHAR *buffer,
ULONG requested_length, ULONG *actual_length);
UINT _ux_device_class_cdc_acm_tasks_run(VOID *instance);
@@ -419,10 +423,10 @@ UINT _uxe_device_class_cdc_acm_read_run(UX_SLAVE_CLASS_CDC_ACM *cdc_acm, UCHAR
#endif
-/* Determine if a C++ compiler is being used. If so, complete the standard
- C conditional started above. */
+/* Determine if a C++ compiler is being used. If so, complete the standard
+ C conditional started above. */
#ifdef __cplusplus
-}
-#endif
+}
+#endif
#endif /* UX_DEVICE_CLASS_CDC_ACM_H */
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 0660bf2..f7cd7a2 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
@@ -1,19 +1,20 @@
/***************************************************************************
- * Copyright (c) 2024 Microsoft Corporation
- *
+ * Copyright (c) 2024 Microsoft Corporation
+ *
* This program and the accompanying materials are made available under the
* terms of the MIT License which is available at
* https://opensource.org/licenses/MIT.
- *
+ *
* SPDX-License-Identifier: MIT
**************************************************************************/
+
/**************************************************************************/
/**************************************************************************/
-/** */
-/** USBX Component */
/** */
-/** Device CDC Class */
+/** USBX Component */
+/** */
+/** Device CDC ACM Class */
/** */
/**************************************************************************/
/**************************************************************************/
@@ -28,41 +29,41 @@
#include "ux_device_stack.h"
-/**************************************************************************/
-/* */
-/* FUNCTION RELEASE */
-/* */
-/* _ux_device_class_cdc_acm_control_request PORTABLE C */
+/**************************************************************************/
+/* */
+/* FUNCTION RELEASE */
+/* */
+/* _ux_device_class_cdc_acm_control_request PORTABLE C */
/* 6.1.12 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
/* */
/* DESCRIPTION */
-/* */
-/* This function manages the based sent by the host on the control */
-/* endpoints with a CLASS or VENDOR SPECIFIC type. */
-/* */
-/* INPUT */
-/* */
-/* cdc_acm Pointer to cdc_acm class */
-/* */
-/* OUTPUT */
-/* */
-/* None */
-/* */
-/* CALLS */
-/* */
-/* _ux_device_stack_transfer_request Transfer request */
-/* */
-/* CALLED BY */
-/* */
+/* */
+/* This function manages the based sent by the host on the control */
+/* endpoints with a CLASS or VENDOR SPECIFIC type. */
+/* */
+/* INPUT */
+/* */
+/* cdc_acm Pointer to cdc_acm class */
+/* */
+/* OUTPUT */
+/* */
+/* None */
+/* */
+/* CALLS */
+/* */
+/* _ux_device_stack_transfer_request Transfer request */
+/* */
+/* CALLED BY */
+/* */
/* CDC Class */
-/* */
-/* RELEASE HISTORY */
-/* */
-/* DATE NAME DESCRIPTION */
-/* */
+/* */
+/* RELEASE HISTORY */
+/* */
+/* DATE NAME DESCRIPTION */
+/* */
/* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */
/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */
/* resulting in version 6.1 */
@@ -105,7 +106,7 @@ ULONG transmit_length;
request_length = _ux_utility_short_get(transfer_request -> ux_slave_transfer_request_setup + UX_SETUP_LENGTH);
transmit_length = request_length ;
-
+
/* Here we proceed only the standard request we know of at the device level. */
switch (request)
{
@@ -118,16 +119,16 @@ ULONG transmit_length;
/* Get the line state parameters from the host. DTR signal. */
if (value & UX_SLAVE_CLASS_CDC_ACM_LINE_STATE_DTR)
- cdc_acm -> ux_slave_class_cdc_acm_data_dtr_state = UX_TRUE;
+ cdc_acm -> ux_slave_class_cdc_acm_data_dtr_state = UX_TRUE;
/* Get the line state parameters from the host. RTS signal. */
if (value & UX_SLAVE_CLASS_CDC_ACM_LINE_STATE_RTS)
- cdc_acm -> ux_slave_class_cdc_acm_data_rts_state = UX_TRUE;
-
+ cdc_acm -> ux_slave_class_cdc_acm_data_rts_state = UX_TRUE;
+
/* 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)
- {
-
+ {
+
/* Invoke the application. */
cdc_acm -> ux_slave_class_cdc_acm_parameter.ux_slave_class_cdc_acm_parameter_change(cdc_acm);
}
@@ -137,11 +138,11 @@ ULONG transmit_length;
case UX_SLAVE_CLASS_CDC_ACM_GET_LINE_CODING:
/* Setup the length appropriately. */
- if (request_length > UX_SLAVE_CLASS_CDC_ACM_LINE_CODING_RESPONSE_SIZE)
+ if (request_length > UX_SLAVE_CLASS_CDC_ACM_LINE_CODING_RESPONSE_SIZE)
transmit_length = UX_SLAVE_CLASS_CDC_ACM_LINE_CODING_RESPONSE_SIZE;
-
+
/* Send the line coding default parameters back to the host. */
- _ux_utility_long_put(transfer_request -> ux_slave_transfer_request_data_pointer + UX_SLAVE_CLASS_CDC_ACM_LINE_CODING_BAUDRATE_STRUCT,
+ _ux_utility_long_put(transfer_request -> ux_slave_transfer_request_data_pointer + UX_SLAVE_CLASS_CDC_ACM_LINE_CODING_BAUDRATE_STRUCT,
cdc_acm -> ux_slave_class_cdc_acm_baudrate);
*(transfer_request -> ux_slave_transfer_request_data_pointer + UX_SLAVE_CLASS_CDC_ACM_LINE_CODING_STOP_BIT_STRUCT) = cdc_acm -> ux_slave_class_cdc_acm_stop_bit;
*(transfer_request -> ux_slave_transfer_request_data_pointer + UX_SLAVE_CLASS_CDC_ACM_LINE_CODING_PARITY_STRUCT) = cdc_acm -> ux_slave_class_cdc_acm_parity;
@@ -149,11 +150,11 @@ ULONG transmit_length;
/* Set the phase of the transfer to data out. */
transfer_request -> ux_slave_transfer_request_phase = UX_TRANSFER_PHASE_DATA_OUT;
-
+
/* Perform the data transfer. */
_ux_device_stack_transfer_request(transfer_request, transmit_length, request_length);
- break;
-
+ break;
+
case UX_SLAVE_CLASS_CDC_ACM_SET_LINE_CODING:
/* Get the line coding parameters from the host. */
@@ -164,14 +165,28 @@ ULONG transmit_length;
/* 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)
- {
-
+ {
+
/* Invoke the application. */
cdc_acm -> ux_slave_class_cdc_acm_parameter.ux_slave_class_cdc_acm_parameter_change(cdc_acm);
}
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. */
@@ -181,4 +196,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 fe3f510..252aa87 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
@@ -1,19 +1,20 @@
/***************************************************************************
- * Copyright (c) 2024 Microsoft Corporation
- *
+ * Copyright (c) 2024 Microsoft Corporation
+ *
* This program and the accompanying materials are made available under the
* terms of the MIT License which is available at
* https://opensource.org/licenses/MIT.
- *
+ *
* SPDX-License-Identifier: MIT
**************************************************************************/
+
/**************************************************************************/
/**************************************************************************/
-/** */
-/** USBX Component */
/** */
-/** Device CDC Class */
+/** USBX Component */
+/** */
+/** Device CDC ACM Class */
/** */
/**************************************************************************/
/**************************************************************************/
@@ -28,41 +29,41 @@
#include "ux_device_stack.h"
-/**************************************************************************/
-/* */
-/* FUNCTION RELEASE */
-/* */
-/* _ux_device_class_cdc_acm_deactivate PORTABLE C */
+/**************************************************************************/
+/* */
+/* FUNCTION RELEASE */
+/* */
+/* _ux_device_class_cdc_acm_deactivate PORTABLE C */
/* 6.1.12 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
/* */
/* DESCRIPTION */
-/* */
-/* This function deactivate an instance of the cdc_acm class. */
-/* */
-/* INPUT */
-/* */
-/* command Pointer to a class command */
-/* */
-/* OUTPUT */
-/* */
-/* Completion Status */
-/* */
-/* CALLS */
-/* */
-/* _ux_device_stack_transfer_all_request_abort Abort all transfers */
-/* _ux_device_class_cdc_acm_ioctl IO control */
-/* */
-/* CALLED BY */
-/* */
+/* */
+/* This function deactivate an instance of the cdc_acm class. */
+/* */
+/* INPUT */
+/* */
+/* command Pointer to a class command */
+/* */
+/* OUTPUT */
+/* */
+/* Completion Status */
+/* */
+/* CALLS */
+/* */
+/* _ux_device_stack_transfer_all_request_abort Abort all transfers */
+/* _ux_device_class_cdc_acm_ioctl IO control */
+/* */
+/* CALLED BY */
+/* */
/* CDC Class */
-/* */
-/* RELEASE HISTORY */
-/* */
-/* DATE NAME DESCRIPTION */
-/* */
+/* */
+/* RELEASE HISTORY */
+/* */
+/* DATE NAME DESCRIPTION */
+/* */
/* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */
/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */
/* resulting in version 6.1 */
@@ -74,7 +75,7 @@
/**************************************************************************/
UINT _ux_device_class_cdc_acm_deactivate(UX_SLAVE_CLASS_COMMAND *command)
{
-
+
UX_SLAVE_INTERFACE *interface_ptr;
UX_SLAVE_CLASS *class_ptr;
UX_SLAVE_CLASS_CDC_ACM *cdc_acm;
@@ -89,17 +90,17 @@ UX_SLAVE_ENDPOINT *endpoint_out;
/* We need the interface to the class. */
interface_ptr = cdc_acm -> ux_slave_class_cdc_acm_interface;
-
+
/* Locate the endpoints. */
endpoint_in = interface_ptr -> ux_slave_interface_first_endpoint;
-
+
/* Check the endpoint direction, if IN we have the correct endpoint. */
if ((endpoint_in -> ux_slave_endpoint_descriptor.bEndpointAddress & UX_ENDPOINT_DIRECTION) != UX_ENDPOINT_IN)
{
/* Wrong direction, we found the OUT endpoint first. */
endpoint_out = endpoint_in;
-
+
/* So the next endpoint has to be the IN endpoint. */
endpoint_in = endpoint_out -> ux_slave_endpoint_next_endpoint;
}
@@ -109,7 +110,7 @@ UX_SLAVE_ENDPOINT *endpoint_out;
/* We found the endpoint IN first, so next endpoint is OUT. */
endpoint_out = endpoint_in -> ux_slave_endpoint_next_endpoint;
}
-
+
/* Terminate the transactions pending on the endpoints. */
_ux_device_stack_transfer_all_request_abort(endpoint_in, UX_TRANSFER_BUS_RESET);
_ux_device_stack_transfer_all_request_abort(endpoint_out, UX_TRANSFER_BUS_RESET);
@@ -125,11 +126,13 @@ UX_SLAVE_ENDPOINT *endpoint_out;
cdc_acm -> ux_slave_class_cdc_acm_parameter.ux_slave_class_cdc_acm_instance_deactivate(cdc_acm);
}
- /* We need to reset the DTR and RTS values so they do not carry over to the
+ /* We need to reset the DTR and RTS values so they do not carry over to the
next connection. */
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 20066a7..573566e 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
@@ -1,18 +1,20 @@
/***************************************************************************
- * Copyright (c) 2024 Microsoft Corporation
- *
+ * Copyright (c) 2024 Microsoft Corporation
+ *
* This program and the accompanying materials are made available under the
* terms of the MIT License which is available at
* https://opensource.org/licenses/MIT.
- *
+ *
* SPDX-License-Identifier: MIT
**************************************************************************/
+
+/**************************************************************************/
/**************************************************************************/
-/** */
-/** USBX Component */
/** */
-/** Device CDC Class */
+/** USBX Component */
+/** */
+/** Device CDC ACM Class */
/** */
/**************************************************************************/
/**************************************************************************/
@@ -31,43 +33,43 @@
#error UX_THREAD_STACK_SIZE too large
#endif
-/**************************************************************************/
-/* */
-/* FUNCTION RELEASE */
-/* */
-/* _ux_device_class_cdc_acm_initialize PORTABLE C */
+/**************************************************************************/
+/* */
+/* FUNCTION RELEASE */
+/* */
+/* _ux_device_class_cdc_acm_initialize PORTABLE C */
/* 6.3.0 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
/* */
/* DESCRIPTION */
-/* */
-/* This function initializes the USB CDC device. */
-/* */
-/* INPUT */
-/* */
-/* command Pointer to cdc_acm command */
-/* */
-/* OUTPUT */
-/* */
-/* Completion Status */
-/* */
-/* CALLS */
-/* */
-/* _ux_utility_memory_allocate Allocate memory */
-/* _ux_utility_memory_free Free memory */
-/* _ux_utility_mutex_create Create mutex */
-/* _ux_device_mutex_delete Delete mutex */
-/* */
-/* CALLED BY */
-/* */
-/* USBX Source Code */
-/* */
-/* RELEASE HISTORY */
-/* */
-/* DATE NAME DESCRIPTION */
-/* */
+/* */
+/* This function initializes the USB CDC device. */
+/* */
+/* INPUT */
+/* */
+/* command Pointer to cdc acm command */
+/* */
+/* OUTPUT */
+/* */
+/* Completion Status */
+/* */
+/* CALLS */
+/* */
+/* _ux_utility_memory_allocate Allocate memory */
+/* _ux_utility_memory_free Free memory */
+/* _ux_utility_mutex_create Create mutex */
+/* _ux_device_mutex_delete Delete mutex */
+/* */
+/* CALLED BY */
+/* */
+/* USBX Source Code */
+/* */
+/* RELEASE HISTORY */
+/* */
+/* DATE NAME DESCRIPTION */
+/* */
/* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */
/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */
/* resulting in version 6.1 */
@@ -95,7 +97,7 @@
/**************************************************************************/
UINT _ux_device_class_cdc_acm_initialize(UX_SLAVE_CLASS_COMMAND *command)
{
-
+
UX_SLAVE_CLASS_CDC_ACM *cdc_acm;
UX_SLAVE_CLASS_CDC_ACM_PARAMETER *cdc_acm_parameter;
UX_SLAVE_CLASS *class_ptr;
@@ -132,10 +134,10 @@ UINT status;
UX_DEVICE_CLASS_CDC_ACM_ENDPOINT_BUFFER_SIZE);
if (cdc_acm -> ux_device_class_cdc_acm_endpoint_buffer == UX_NULL)
{
-
+
/* Free the resources. */
_ux_utility_memory_free(cdc_acm);
-
+
/* Return fatal error. */
return(UX_MEMORY_INSUFFICIENT);
}
@@ -155,10 +157,10 @@ UINT status;
_ux_utility_memory_free(cdc_acm -> ux_device_class_cdc_acm_endpoint_buffer);
#endif
_ux_utility_memory_free(cdc_acm);
-
+
/* Return fatal error. */
return(UX_MUTEX_ERROR);
- }
+ }
/* Out Mutex. */
status = _ux_utility_mutex_create(&cdc_acm -> ux_slave_class_cdc_acm_endpoint_out_mutex, "ux_slave_class_cdc_acm_out_mutex");
@@ -175,10 +177,10 @@ UINT status;
_ux_utility_memory_free(cdc_acm -> ux_device_class_cdc_acm_endpoint_buffer);
#endif
_ux_utility_memory_free(cdc_acm);
-
+
/* Return fatal error. */
return(UX_MUTEX_ERROR);
- }
+ }
#endif
@@ -188,6 +190,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)
@@ -198,7 +203,7 @@ UINT status;
/* We need to prepare the 2 threads for sending and receiving. */
/* Allocate some memory for the bulk out and in thread stack. */
- cdc_acm -> ux_slave_class_cdc_acm_bulkout_thread_stack =
+ cdc_acm -> ux_slave_class_cdc_acm_bulkout_thread_stack =
_ux_utility_memory_allocate(UX_NO_ALIGN, UX_REGULAR_MEMORY, UX_THREAD_STACK_SIZE * 2);
/* Check for successful allocation. */
@@ -236,7 +241,7 @@ UINT status;
does not start until we have a instance of the class. */
status = _ux_utility_thread_create(
&cdc_acm -> ux_slave_class_cdc_acm_bulkin_thread,
- "ux_slave_class_cdc_acm_bulkin_thread",
+ "ux_slave_class_cdc_acm_bulkin_thread",
_ux_device_class_cdc_acm_bulkin_thread,
(ULONG) (ALIGN_TYPE) cdc_acm,
(VOID *) cdc_acm -> ux_slave_class_cdc_acm_bulkin_thread_stack,
@@ -264,7 +269,7 @@ UINT status;
does not start until we have a instance of the class. */
status = _ux_utility_thread_create(
&cdc_acm -> ux_slave_class_cdc_acm_bulkout_thread,
- "ux_slave_class_cdc_acm_bulkout_thread",
+ "ux_slave_class_cdc_acm_bulkout_thread",
_ux_device_class_cdc_acm_bulkout_thread,
(ULONG) (ALIGN_TYPE) cdc_acm,
(VOID *) cdc_acm -> ux_slave_class_cdc_acm_bulkout_thread_stack,
@@ -309,4 +314,3 @@ UINT status;
/* Return completion status. */
return(UX_SUCCESS);
}
-
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");