Skip to content

Commit a98ff10

Browse files
committed
device cdc acm support break request
- Implements handling of UX_SLAVE_CLASS_CDC_ACM_SEND_BREAK in the CDC ACM control request path. - Ensures break state is cleared on class deactivation to avoid carrying state across disconnect/reset cycles. - Minor comment/whitespace cleanups in touched headers/sources. - Testing: Build-only / compilation sanity/send break request. (no new automated tests added).
1 parent 515c9a4 commit a98ff10

File tree

5 files changed

+238
-186
lines changed

5 files changed

+238
-186
lines changed

common/usbx_device_classes/inc/ux_device_class_cdc_acm.h

Lines changed: 50 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,45 @@
11
/***************************************************************************
2-
* Copyright (c) 2024 Microsoft Corporation
3-
*
2+
* Copyright (c) 2024 Microsoft Corporation
3+
*
44
* This program and the accompanying materials are made available under the
55
* terms of the MIT License which is available at
66
* https://opensource.org/licenses/MIT.
7-
*
7+
*
88
* SPDX-License-Identifier: MIT
99
**************************************************************************/
1010

11+
1112
/**************************************************************************/
1213
/**************************************************************************/
13-
/** */
14-
/** USBX Component */
1514
/** */
16-
/** CDC Class */
15+
/** USBX Component */
16+
/** */
17+
/** Device CDC ACM Class */
1718
/** */
1819
/**************************************************************************/
1920
/**************************************************************************/
2021

21-
/**************************************************************************/
22-
/* */
23-
/* COMPONENT DEFINITION RELEASE */
24-
/* */
25-
/* ux_device_class_cdc_acm.h PORTABLE C */
22+
23+
/**************************************************************************/
24+
/**************************************************************************/
25+
/* */
26+
/* COMPONENT DEFINITION RELEASE */
27+
/* */
28+
/* ux_device_class_cdc_acm.h PORTABLE C */
2629
/* 6.3.0 */
2730
/* AUTHOR */
2831
/* */
2932
/* Chaoqiong Xiao, Microsoft Corporation */
3033
/* */
3134
/* DESCRIPTION */
32-
/* */
33-
/* This file defines the equivalences for the USBX Device Class CDC */
34-
/* ACM component. */
35-
/* */
36-
/* RELEASE HISTORY */
37-
/* */
38-
/* DATE NAME DESCRIPTION */
39-
/* */
35+
/* */
36+
/* This file defines the equivalences for the USBX Device Class CDC */
37+
/* ACM component. */
38+
/* */
39+
/* RELEASE HISTORY */
40+
/* */
41+
/* DATE NAME DESCRIPTION */
42+
/* */
4043
/* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */
4144
/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */
4245
/* used UX prefix to refer to */
@@ -69,15 +72,15 @@
6972
#ifndef UX_DEVICE_CLASS_CDC_ACM_H
7073
#define UX_DEVICE_CLASS_CDC_ACM_H
7174

72-
/* Determine if a C++ compiler is being used. If so, ensure that standard
73-
C is used to process the API information. */
75+
/* Determine if a C++ compiler is being used. If so, ensure that standard
76+
C is used to process the API information. */
7477

75-
#ifdef __cplusplus
78+
#ifdef __cplusplus
7679

77-
/* Yes, C++ compiler is present. Use standard C. */
78-
extern "C" {
80+
/* Yes, C++ compiler is present. Use standard C. */
81+
extern "C" {
7982

80-
#endif
83+
#endif
8184

8285
/* Internal option: enable the basic USBX error checking. This define is typically used
8386
while debugging application. */
@@ -251,6 +254,7 @@ typedef struct UX_SLAVE_CLASS_CDC_ACM_STRUCT
251254
UCHAR ux_slave_class_cdc_acm_data_bit;
252255
UCHAR ux_slave_class_cdc_acm_data_dtr_state;
253256
UCHAR ux_slave_class_cdc_acm_data_rts_state;
257+
USHORT ux_slave_class_cdc_acm_break_duration;
254258
UCHAR reserved[3];
255259

256260
#ifndef UX_DEVICE_CLASS_CDC_ACM_TRANSMISSION_DISABLE
@@ -289,23 +293,23 @@ typedef struct UX_SLAVE_CLASS_CDC_ACM_STRUCT
289293

290294
/* Define some CDC Class structures */
291295

292-
typedef struct UX_SLAVE_CLASS_CDC_ACM_LINE_CODING_PARAMETER_STRUCT
296+
typedef struct UX_SLAVE_CLASS_CDC_ACM_LINE_CODING_PARAMETER_STRUCT
293297
{
294298
ULONG ux_slave_class_cdc_acm_parameter_baudrate;
295299
UCHAR ux_slave_class_cdc_acm_parameter_stop_bit;
296300
UCHAR ux_slave_class_cdc_acm_parameter_parity;
297301
UCHAR ux_slave_class_cdc_acm_parameter_data_bit;
298-
302+
299303
} UX_SLAVE_CLASS_CDC_ACM_LINE_CODING_PARAMETER;
300304

301-
typedef struct UX_SLAVE_CLASS_CDC_ACM_LINE_STATE_PARAMETER_STRUCT
305+
typedef struct UX_SLAVE_CLASS_CDC_ACM_LINE_STATE_PARAMETER_STRUCT
302306
{
303307
UCHAR ux_slave_class_cdc_acm_parameter_rts;
304308
UCHAR ux_slave_class_cdc_acm_parameter_dtr;
305-
309+
306310
} UX_SLAVE_CLASS_CDC_ACM_LINE_STATE_PARAMETER;
307311

308-
typedef struct UX_SLAVE_CLASS_CDC_ACM_CALLBACK_PARAMETER_STRUCT
312+
typedef struct UX_SLAVE_CLASS_CDC_ACM_CALLBACK_PARAMETER_STRUCT
309313
{
310314
UINT (*ux_device_class_cdc_acm_parameter_write_callback)(struct UX_SLAVE_CLASS_CDC_ACM_STRUCT *cdc_acm, UINT status, ULONG length);
311315
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
316320

317321
/* Requests - Ethernet Networking Control Model */
318322

319-
#define UX_SLAVE_CLASS_CDC_ACM_SEND_ENCAPSULATED_COMMAND 0x00
323+
#define UX_SLAVE_CLASS_CDC_ACM_SEND_ENCAPSULATED_COMMAND 0x00
320324
/* Issues a command in the format of the supported control
321325
protocol. The intent of this mechanism is to support
322326
networking devices (e.g., host-based cable modems)
323327
that require an additional vendor-defined interface for
324328
media specific hardware configuration and
325329
management. */
326-
#define UX_SLAVE_CLASS_CDC_ACM_GET_ENCAPSULATED_RESPONSE 0x01
330+
#define UX_SLAVE_CLASS_CDC_ACM_GET_ENCAPSULATED_RESPONSE 0x01
327331
/* Requests a response in the format of the supported
328332
control protocol. */
329-
#define UX_SLAVE_CLASS_CDC_ACM_SET_ETHERNET_MULTICAST_FILTERS 0x40
333+
#define UX_SLAVE_CLASS_CDC_ACM_SET_ETHERNET_MULTICAST_FILTERS 0x40
330334
/* As applications are loaded and unloaded on the host,
331335
the networking transport will instruct the device's MAC
332336
driver to change settings of the Networking device's
333337
multicast filters. */
334-
#define UX_SLAVE_CLASS_CDC_ACM_SET_ETHERNET_POWER_MANAGEMENT_PATTERN_FILTER 0x41
338+
#define UX_SLAVE_CLASS_CDC_ACM_SET_ETHERNET_POWER_MANAGEMENT_PATTERN_FILTER 0x41
335339
/* Some hosts are able to conserve energy and stay quiet
336340
in a 'sleeping' state while not being used. USB
337341
Networking devices may provide special pattern filtering
@@ -340,13 +344,13 @@ typedef struct UX_SLAVE_CLASS_CDC_ACM_CALLBACK_PARAMETER_STRUCT
340344
host (e.g., an incoming web browser connection).
341345
Primitives are needed in management plane to negotiate
342346
the setting of these special filters */
343-
#define UX_SLAVE_CLASS_CDC_ACM_GET_ETHERNET_POWER_MANAGEMENT_PATTERN_FILTER 0x42
347+
#define UX_SLAVE_CLASS_CDC_ACM_GET_ETHERNET_POWER_MANAGEMENT_PATTERN_FILTER 0x42
344348
/* Retrieves the status of the above power management
345349
pattern filter setting */
346-
#define UX_SLAVE_CLASS_CDC_ACM_SET_ETHERNET_PACKET_FILTER 0x43
350+
#define UX_SLAVE_CLASS_CDC_ACM_SET_ETHERNET_PACKET_FILTER 0x43
347351
/* Sets device filter for running a network analyzer
348352
application on the host machine */
349-
#define UX_SLAVE_CLASS_CDC_ACM_GET_ETHERNET_STATISTIC 0x44
353+
#define UX_SLAVE_CLASS_CDC_ACM_GET_ETHERNET_STATISTIC 0x44
350354
/* Retrieves Ethernet device statistics such as frames
351355
transmitted, frames received, and bad frames received. */
352356

@@ -363,20 +367,20 @@ UINT _ux_device_class_cdc_acm_deactivate(UX_SLAVE_CLASS_COMMAND *command);
363367
UINT _ux_device_class_cdc_acm_entry(UX_SLAVE_CLASS_COMMAND *command);
364368
UINT _ux_device_class_cdc_acm_initialize(UX_SLAVE_CLASS_COMMAND *command);
365369
UINT _ux_device_class_cdc_acm_uninitialize(UX_SLAVE_CLASS_COMMAND *command);
366-
UINT _ux_device_class_cdc_acm_write(UX_SLAVE_CLASS_CDC_ACM *cdc_acm, UCHAR *buffer,
370+
UINT _ux_device_class_cdc_acm_write(UX_SLAVE_CLASS_CDC_ACM *cdc_acm, UCHAR *buffer,
367371
ULONG requested_length, ULONG *actual_length);
368-
UINT _ux_device_class_cdc_acm_read(UX_SLAVE_CLASS_CDC_ACM *cdc_acm, UCHAR *buffer,
372+
UINT _ux_device_class_cdc_acm_read(UX_SLAVE_CLASS_CDC_ACM *cdc_acm, UCHAR *buffer,
369373
ULONG requested_length, ULONG *actual_length);
370374
UINT _ux_device_class_cdc_acm_ioctl(UX_SLAVE_CLASS_CDC_ACM *cdc_acm, ULONG ioctl_function,
371375
VOID *parameter);
372376
VOID _ux_device_class_cdc_acm_bulkin_thread(ULONG class_pointer);
373377
VOID _ux_device_class_cdc_acm_bulkout_thread(ULONG class_pointer);
374-
UINT _ux_device_class_cdc_acm_write_with_callback(UX_SLAVE_CLASS_CDC_ACM *cdc_acm, UCHAR *buffer,
378+
UINT _ux_device_class_cdc_acm_write_with_callback(UX_SLAVE_CLASS_CDC_ACM *cdc_acm, UCHAR *buffer,
375379
ULONG requested_length);
376380

377-
UINT _ux_device_class_cdc_acm_write_run(UX_SLAVE_CLASS_CDC_ACM *cdc_acm, UCHAR *buffer,
381+
UINT _ux_device_class_cdc_acm_write_run(UX_SLAVE_CLASS_CDC_ACM *cdc_acm, UCHAR *buffer,
378382
ULONG requested_length, ULONG *actual_length);
379-
UINT _ux_device_class_cdc_acm_read_run(UX_SLAVE_CLASS_CDC_ACM *cdc_acm, UCHAR *buffer,
383+
UINT _ux_device_class_cdc_acm_read_run(UX_SLAVE_CLASS_CDC_ACM *cdc_acm, UCHAR *buffer,
380384
ULONG requested_length, ULONG *actual_length);
381385

382386
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
419423

420424
#endif
421425

422-
/* Determine if a C++ compiler is being used. If so, complete the standard
423-
C conditional started above. */
426+
/* Determine if a C++ compiler is being used. If so, complete the standard
427+
C conditional started above. */
424428
#ifdef __cplusplus
425-
}
426-
#endif
429+
}
430+
#endif
427431

428432
#endif /* UX_DEVICE_CLASS_CDC_ACM_H */

0 commit comments

Comments
 (0)