Skip to content

Commit bbdb12f

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 bbdb12f

File tree

5 files changed

+244
-186
lines changed

5 files changed

+244
-186
lines changed

common/usbx_device_classes/inc/ux_device_class_cdc_acm.h

Lines changed: 56 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,29 @@ 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_BREAK_PARAMETER_STRUCT
313+
{
314+
USHORT ux_slave_class_cdc_acm_parameter_break_duration;
315+
316+
} UX_SLAVE_CLASS_CDC_ACM_BREAK_PARAMETER;
317+
318+
typedef struct UX_SLAVE_CLASS_CDC_ACM_CALLBACK_PARAMETER_STRUCT
309319
{
310320
UINT (*ux_device_class_cdc_acm_parameter_write_callback)(struct UX_SLAVE_CLASS_CDC_ACM_STRUCT *cdc_acm, UINT status, ULONG length);
311321
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 +326,22 @@ typedef struct UX_SLAVE_CLASS_CDC_ACM_CALLBACK_PARAMETER_STRUCT
316326

317327
/* Requests - Ethernet Networking Control Model */
318328

319-
#define UX_SLAVE_CLASS_CDC_ACM_SEND_ENCAPSULATED_COMMAND 0x00
329+
#define UX_SLAVE_CLASS_CDC_ACM_SEND_ENCAPSULATED_COMMAND 0x00
320330
/* Issues a command in the format of the supported control
321331
protocol. The intent of this mechanism is to support
322332
networking devices (e.g., host-based cable modems)
323333
that require an additional vendor-defined interface for
324334
media specific hardware configuration and
325335
management. */
326-
#define UX_SLAVE_CLASS_CDC_ACM_GET_ENCAPSULATED_RESPONSE 0x01
336+
#define UX_SLAVE_CLASS_CDC_ACM_GET_ENCAPSULATED_RESPONSE 0x01
327337
/* Requests a response in the format of the supported
328338
control protocol. */
329-
#define UX_SLAVE_CLASS_CDC_ACM_SET_ETHERNET_MULTICAST_FILTERS 0x40
339+
#define UX_SLAVE_CLASS_CDC_ACM_SET_ETHERNET_MULTICAST_FILTERS 0x40
330340
/* As applications are loaded and unloaded on the host,
331341
the networking transport will instruct the device's MAC
332342
driver to change settings of the Networking device's
333343
multicast filters. */
334-
#define UX_SLAVE_CLASS_CDC_ACM_SET_ETHERNET_POWER_MANAGEMENT_PATTERN_FILTER 0x41
344+
#define UX_SLAVE_CLASS_CDC_ACM_SET_ETHERNET_POWER_MANAGEMENT_PATTERN_FILTER 0x41
335345
/* Some hosts are able to conserve energy and stay quiet
336346
in a 'sleeping' state while not being used. USB
337347
Networking devices may provide special pattern filtering
@@ -340,13 +350,13 @@ typedef struct UX_SLAVE_CLASS_CDC_ACM_CALLBACK_PARAMETER_STRUCT
340350
host (e.g., an incoming web browser connection).
341351
Primitives are needed in management plane to negotiate
342352
the setting of these special filters */
343-
#define UX_SLAVE_CLASS_CDC_ACM_GET_ETHERNET_POWER_MANAGEMENT_PATTERN_FILTER 0x42
353+
#define UX_SLAVE_CLASS_CDC_ACM_GET_ETHERNET_POWER_MANAGEMENT_PATTERN_FILTER 0x42
344354
/* Retrieves the status of the above power management
345355
pattern filter setting */
346-
#define UX_SLAVE_CLASS_CDC_ACM_SET_ETHERNET_PACKET_FILTER 0x43
356+
#define UX_SLAVE_CLASS_CDC_ACM_SET_ETHERNET_PACKET_FILTER 0x43
347357
/* Sets device filter for running a network analyzer
348358
application on the host machine */
349-
#define UX_SLAVE_CLASS_CDC_ACM_GET_ETHERNET_STATISTIC 0x44
359+
#define UX_SLAVE_CLASS_CDC_ACM_GET_ETHERNET_STATISTIC 0x44
350360
/* Retrieves Ethernet device statistics such as frames
351361
transmitted, frames received, and bad frames received. */
352362

@@ -363,20 +373,20 @@ UINT _ux_device_class_cdc_acm_deactivate(UX_SLAVE_CLASS_COMMAND *command);
363373
UINT _ux_device_class_cdc_acm_entry(UX_SLAVE_CLASS_COMMAND *command);
364374
UINT _ux_device_class_cdc_acm_initialize(UX_SLAVE_CLASS_COMMAND *command);
365375
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,
376+
UINT _ux_device_class_cdc_acm_write(UX_SLAVE_CLASS_CDC_ACM *cdc_acm, UCHAR *buffer,
367377
ULONG requested_length, ULONG *actual_length);
368-
UINT _ux_device_class_cdc_acm_read(UX_SLAVE_CLASS_CDC_ACM *cdc_acm, UCHAR *buffer,
378+
UINT _ux_device_class_cdc_acm_read(UX_SLAVE_CLASS_CDC_ACM *cdc_acm, UCHAR *buffer,
369379
ULONG requested_length, ULONG *actual_length);
370380
UINT _ux_device_class_cdc_acm_ioctl(UX_SLAVE_CLASS_CDC_ACM *cdc_acm, ULONG ioctl_function,
371381
VOID *parameter);
372382
VOID _ux_device_class_cdc_acm_bulkin_thread(ULONG class_pointer);
373383
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,
384+
UINT _ux_device_class_cdc_acm_write_with_callback(UX_SLAVE_CLASS_CDC_ACM *cdc_acm, UCHAR *buffer,
375385
ULONG requested_length);
376386

377-
UINT _ux_device_class_cdc_acm_write_run(UX_SLAVE_CLASS_CDC_ACM *cdc_acm, UCHAR *buffer,
387+
UINT _ux_device_class_cdc_acm_write_run(UX_SLAVE_CLASS_CDC_ACM *cdc_acm, UCHAR *buffer,
378388
ULONG requested_length, ULONG *actual_length);
379-
UINT _ux_device_class_cdc_acm_read_run(UX_SLAVE_CLASS_CDC_ACM *cdc_acm, UCHAR *buffer,
389+
UINT _ux_device_class_cdc_acm_read_run(UX_SLAVE_CLASS_CDC_ACM *cdc_acm, UCHAR *buffer,
380390
ULONG requested_length, ULONG *actual_length);
381391

382392
UINT _ux_device_class_cdc_acm_tasks_run(VOID *instance);
@@ -419,10 +429,10 @@ UINT _uxe_device_class_cdc_acm_read_run(UX_SLAVE_CLASS_CDC_ACM *cdc_acm, UCHAR
419429

420430
#endif
421431

422-
/* Determine if a C++ compiler is being used. If so, complete the standard
423-
C conditional started above. */
432+
/* Determine if a C++ compiler is being used. If so, complete the standard
433+
C conditional started above. */
424434
#ifdef __cplusplus
425-
}
426-
#endif
435+
}
436+
#endif
427437

428438
#endif /* UX_DEVICE_CLASS_CDC_ACM_H */

0 commit comments

Comments
 (0)