Skip to content

Commit 5f758e0

Browse files
committed
Update on 31 Mar 2023. Expand to see details.
35e477cd Fixed error checking issues on device printer class. 7bc1a9b5 USBX device video error checking support. fb766837 Moved build option check to runtime (device HID, storage). 3af71cf8 Add optional error checking to host HIDs e6d938ad generate usbx cmsis-pack 62c0c282 Add error checking to host serial classes (CDC ACM, GSER, PROLIFIC and SWAR) 89b8890b USBX device DFU error checking support. 4c3c3922 USBX device CCID error checking support. 1411aab4 Add error checks for device HID and RNDIS. 2f83bd01 Added host audio error checking. 18973298 USBX device CDC ACM error checking support.
1 parent 0acda9e commit 5f758e0

128 files changed

Lines changed: 5685 additions & 176 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

common/usbx_device_classes/inc/ux_device_class_ccid.h

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
/* COMPONENT DEFINITION RELEASE */
2525
/* */
2626
/* ux_device_class_ccid.h PORTABLE C */
27-
/* 6.2.1 */
27+
/* 6.x */
2828
/* AUTHOR */
2929
/* */
3030
/* Chaoqiong Xiao, Microsoft Corporation */
@@ -42,6 +42,9 @@
4242
/* 03-08-2023 Chaoqiong Xiao Modified comment(s), */
4343
/* added standalone support, */
4444
/* resulting in version 6.2.1 */
45+
/* xx-xx-xxxx Yajun xia Modified comment(s), */
46+
/* added error checks support, */
47+
/* resulting in version 6.x */
4548
/* */
4649
/**************************************************************************/
4750

@@ -57,6 +60,12 @@
5760
extern "C" {
5861
#endif
5962

63+
/* Internal option: enable the basic USBX error checking. This define is typically used
64+
while debugging application. */
65+
#if defined(UX_ENABLE_ERROR_CHECKING) && !defined(UX_DEVICE_CLASS_CCID_ENABLE_ERROR_CHECKING)
66+
#define UX_DEVICE_CLASS_CCID_ENABLE_ERROR_CHECKING
67+
#endif
68+
6069
#if !defined(UX_DEVICE_STANDALONE)
6170

6271
/* Define CCID max number of slots, 32 for 32 bit data width. */
@@ -1161,16 +1170,33 @@ UINT _ux_device_class_ccid_auto_seq_done(UX_DEVICE_CLASS_CCID *ccid, ULONG slot
11611170
UINT _ux_device_class_ccid_time_extension(UX_DEVICE_CLASS_CCID *ccid, ULONG slot, ULONG wt);
11621171
UINT _ux_device_class_ccid_hardware_error(UX_DEVICE_CLASS_CCID *ccid, ULONG slot, ULONG error);
11631172

1173+
UINT _uxe_device_class_ccid_icc_insert(UX_DEVICE_CLASS_CCID *ccid, ULONG slot, ULONG seq_start);
1174+
UINT _uxe_device_class_ccid_icc_remove(UX_DEVICE_CLASS_CCID *ccid, ULONG slot);
1175+
UINT _uxe_device_class_ccid_auto_seq_done(UX_DEVICE_CLASS_CCID *ccid, ULONG slot, ULONG icc_status);
1176+
UINT _uxe_device_class_ccid_time_extension(UX_DEVICE_CLASS_CCID *ccid, ULONG slot, ULONG wt);
1177+
UINT _uxe_device_class_ccid_hardware_error(UX_DEVICE_CLASS_CCID *ccid, ULONG slot, ULONG error);
1178+
11641179
/* Define Device CCID Class API prototypes. */
11651180

11661181
#define ux_device_class_ccid_entry _ux_device_class_ccid_entry
11671182

1183+
#if defined(UX_DEVICE_CLASS_CCID_ENABLE_ERROR_CHECKING)
1184+
1185+
#define ux_device_class_ccid_icc_insert _uxe_device_class_ccid_icc_insert
1186+
#define ux_device_class_ccid_icc_remove _uxe_device_class_ccid_icc_remove
1187+
#define ux_device_class_ccid_auto_seq_done _uxe_device_class_ccid_auto_seq_done
1188+
#define ux_device_class_ccid_time_extension _uxe_device_class_ccid_time_extension
1189+
#define ux_device_class_ccid_hardware_error _uxe_device_class_ccid_hardware_error
1190+
1191+
#else
1192+
11681193
#define ux_device_class_ccid_icc_insert _ux_device_class_ccid_icc_insert
11691194
#define ux_device_class_ccid_icc_remove _ux_device_class_ccid_icc_remove
11701195
#define ux_device_class_ccid_auto_seq_done _ux_device_class_ccid_auto_seq_done
11711196
#define ux_device_class_ccid_time_extension _ux_device_class_ccid_time_extension
11721197
#define ux_device_class_ccid_hardware_error _ux_device_class_ccid_hardware_error
11731198

1199+
#endif
11741200

11751201
/* Determine if a C++ compiler is being used. If so, complete the standard
11761202
C conditional started above. */

common/usbx_device_classes/inc/ux_device_class_cdc_acm.h

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
/* COMPONENT DEFINITION RELEASE */
2525
/* */
2626
/* ux_device_class_cdc_acm.h PORTABLE C */
27-
/* 6.1.12 */
27+
/* 6.x */
2828
/* AUTHOR */
2929
/* */
3030
/* Chaoqiong Xiao, Microsoft Corporation */
@@ -58,6 +58,9 @@
5858
/* 07-29-2022 Chaoqiong Xiao Modified comment(s), */
5959
/* added write auto ZLP, */
6060
/* resulting in version 6.1.12 */
61+
/* xx-xx-xxxx Yajun xia Modified comment(s), */
62+
/* added error checks support, */
63+
/* resulting in version 6.x */
6164
/* */
6265
/**************************************************************************/
6366

@@ -74,6 +77,12 @@ extern "C" {
7477

7578
#endif
7679

80+
/* Internal option: enable the basic USBX error checking. This define is typically used
81+
while debugging application. */
82+
#if defined(UX_ENABLE_ERROR_CHECKING) && !defined(UX_DEVICE_CLASS_CDC_ACM_ENABLE_ERROR_CHECKING)
83+
#define UX_DEVICE_CLASS_CDC_ACM_ENABLE_ERROR_CHECKING
84+
#endif
85+
7786
/* Defined, _write is pending ZLP automatically (complete transfer) after buffer is sent. */
7887

7988
/* #define UX_DEVICE_CLASS_CDC_ACM_WRITE_AUTO_ZLP */
@@ -322,9 +331,34 @@ UINT _ux_device_class_cdc_acm_read_run(UX_SLAVE_CLASS_CDC_ACM *cdc_acm, UCHAR *
322331

323332
UINT _ux_device_class_cdc_acm_tasks_run(VOID *instance);
324333

325-
/* Define Device CDC Class API prototypes. */
334+
UINT _uxe_device_class_cdc_acm_read(UX_SLAVE_CLASS_CDC_ACM *cdc_acm, UCHAR *buffer,
335+
ULONG requested_length, ULONG *actual_length);
336+
UINT _uxe_device_class_cdc_acm_write(UX_SLAVE_CLASS_CDC_ACM *cdc_acm, UCHAR *buffer,
337+
ULONG requested_length, ULONG *actual_length);
338+
UINT _uxe_device_class_cdc_acm_ioctl(UX_SLAVE_CLASS_CDC_ACM *cdc_acm, ULONG ioctl_function,
339+
VOID *parameter);
340+
UINT _uxe_device_class_cdc_acm_write_with_callback(UX_SLAVE_CLASS_CDC_ACM *cdc_acm, UCHAR *buffer,
341+
ULONG requested_length);
342+
UINT _uxe_device_class_cdc_acm_write_run(UX_SLAVE_CLASS_CDC_ACM *cdc_acm, UCHAR *buffer,
343+
ULONG requested_length, ULONG *actual_length);
344+
UINT _uxe_device_class_cdc_acm_read_run(UX_SLAVE_CLASS_CDC_ACM *cdc_acm, UCHAR *buffer,
345+
ULONG requested_length, ULONG *actual_length);
326346

347+
/* Define Device CDC Class API prototypes. */
327348
#define ux_device_class_cdc_acm_entry _ux_device_class_cdc_acm_entry
349+
350+
#if defined(UX_DEVICE_CLASS_CDC_ACM_ENABLE_ERROR_CHECKING)
351+
352+
#define ux_device_class_cdc_acm_read _uxe_device_class_cdc_acm_read
353+
#define ux_device_class_cdc_acm_write _uxe_device_class_cdc_acm_write
354+
#define ux_device_class_cdc_acm_ioctl _uxe_device_class_cdc_acm_ioctl
355+
#define ux_device_class_cdc_acm_write_with_callback _uxe_device_class_cdc_acm_write_with_callback
356+
357+
#define ux_device_class_cdc_acm_read_run _uxe_device_class_cdc_acm_read_run
358+
#define ux_device_class_cdc_acm_write_run _uxe_device_class_cdc_acm_write_run
359+
360+
#else
361+
328362
#define ux_device_class_cdc_acm_read _ux_device_class_cdc_acm_read
329363
#define ux_device_class_cdc_acm_write _ux_device_class_cdc_acm_write
330364
#define ux_device_class_cdc_acm_ioctl _ux_device_class_cdc_acm_ioctl
@@ -333,6 +367,8 @@ UINT _ux_device_class_cdc_acm_tasks_run(VOID *instance);
333367
#define ux_device_class_cdc_acm_read_run _ux_device_class_cdc_acm_read_run
334368
#define ux_device_class_cdc_acm_write_run _ux_device_class_cdc_acm_write_run
335369

370+
#endif
371+
336372
/* Determine if a C++ compiler is being used. If so, complete the standard
337373
C conditional started above. */
338374
#ifdef __cplusplus

common/usbx_device_classes/inc/ux_device_class_dfu.h

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
/* COMPONENT DEFINITION RELEASE */
2525
/* */
2626
/* ux_device_class_dfu.h PORTABLE C */
27-
/* 6.1.12 */
27+
/* 6.x */
2828
/* AUTHOR */
2929
/* */
3030
/* Chaoqiong Xiao, Microsoft Corporation */
@@ -60,6 +60,9 @@
6060
/* 07-29-2022 Chaoqiong Xiao Modified comment(s), */
6161
/* added macros for req types, */
6262
/* resulting in version 6.1.12 */
63+
/* xx-xx-xxxx Yajun xia Modified comment(s), */
64+
/* added error checks support, */
65+
/* resulting in version 6.x */
6366
/* */
6467
/**************************************************************************/
6568

@@ -76,6 +79,12 @@ extern "C" {
7679

7780
#endif
7881

82+
/* Internal option: enable the basic USBX error checking. This define is typically used
83+
while debugging application. */
84+
#if defined(UX_ENABLE_ERROR_CHECKING) && !defined(UX_DEVICE_CLASS_DFU_ENABLE_ERROR_CHECKING)
85+
#define UX_DEVICE_CLASS_DFU_ENABLE_ERROR_CHECKING
86+
#endif
87+
7988
/* Define DFU class descriptor capabilities. */
8089
#define UX_SLAVE_CLASS_DFU_CAPABILITY_WILL_DETACH 0x08
8190
#define UX_SLAVE_CLASS_DFU_CAPABILITY_MANIFESTATION_TOLERANT 0x04
@@ -255,9 +264,10 @@ VOID _ux_device_class_dfu_state_sync(UX_SLAVE_CLASS_DFU *dfu);
255264

256265
UINT _ux_device_class_dfu_tasks_run(VOID *class_instance);
257266

258-
/* Define Device DFU Class API prototypes. */
267+
UINT _uxe_device_class_dfu_initialize(UX_SLAVE_CLASS_COMMAND *command);
259268

260-
#define ux_device_class_dfu_entry _ux_device_class_dfu_entry
269+
/* Define Device DFU Class API prototypes. */
270+
#define ux_device_class_dfu_entry _ux_device_class_dfu_entry
261271
#define ux_device_class_dfu_state_get _ux_device_class_dfu_state_get
262272
#define ux_device_class_dfu_state_sync _ux_device_class_dfu_state_sync
263273

common/usbx_device_classes/inc/ux_device_class_hid.h

Lines changed: 58 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
/* COMPONENT DEFINITION RELEASE */
2727
/* */
2828
/* ux_device_class_hid.h PORTABLE C */
29-
/* 6.1.12 */
29+
/* 6.X */
3030
/* AUTHOR */
3131
/* */
3232
/* Chaoqiong Xiao, Microsoft Corporation */
@@ -64,6 +64,9 @@
6464
/* 07-29-2022 Chaoqiong Xiao Modified comment(s), */
6565
/* added standalone int out, */
6666
/* resulting in version 6.1.12 */
67+
/* XX-XX-XXXX Chaoqiong Xiao Modified comment(s), */
68+
/* moved build option check, */
69+
/* resulting in version 6.x */
6770
/* */
6871
/**************************************************************************/
6972

@@ -85,6 +88,14 @@ extern "C" {
8588
/* If defined, interrupt OUT transfer is supported. */
8689
/* #define UX_DEVICE_CLASS_HID_INTERRUPT_OUT_SUPPORT */
8790

91+
92+
/* Internal option: enable the basic USBX error checking. This define is typically used
93+
while debugging application. */
94+
#if defined(UX_ENABLE_ERROR_CHECKING) && !defined(UX_DEVICE_CLASS_HID_ENABLE_ERROR_CHECKING)
95+
#define UX_DEVICE_CLASS_HID_ENABLE_ERROR_CHECKING
96+
#endif
97+
98+
8899
/* Use UX general thread stack size for receiver thread. */
89100
#define UX_DEVICE_CLASS_HID_RECEIVER_THREAD_STACK_SIZE UX_THREAD_STACK_SIZE
90101

@@ -142,12 +153,14 @@ extern "C" {
142153

143154
/* Ensure the event buffer can fit inside the control endpoint's data buffer. */
144155
#if UX_DEVICE_CLASS_HID_EVENT_BUFFER_LENGTH > UX_SLAVE_REQUEST_CONTROL_MAX_LENGTH
145-
#error "Error: the event buffer cannot fit inside the control endpoint's data buffer. Reduce UX_DEVICE_CLASS_HID_EVENT_BUFFER_LENGTH such that it is less than or equal to UX_SLAVE_REQUEST_CONTROL_MAX_LENGTH."
156+
/* #error "Error: the event buffer cannot fit inside the control endpoint's data buffer. Reduce UX_DEVICE_CLASS_HID_EVENT_BUFFER_LENGTH such that it is less than or equal to UX_SLAVE_REQUEST_CONTROL_MAX_LENGTH." */
157+
/* Build option checked runtime by UX_ASSERT */
146158
#endif
147159

148160
/* Ensure the event buffer can fit inside the interrupt endpoint's data buffer. */
149161
#if UX_DEVICE_CLASS_HID_EVENT_BUFFER_LENGTH > UX_SLAVE_REQUEST_DATA_MAX_LENGTH
150-
#error "Error: the event buffer cannot fit inside the interrupt endpoint's data buffer. Reduce UX_DEVICE_CLASS_HID_EVENT_BUFFER_LENGTH such that it is less than or equal to UX_SLAVE_REQUEST_DATA_MAX_LENGTH."
162+
/* #error "Error: the event buffer cannot fit inside the interrupt endpoint's data buffer. Reduce UX_DEVICE_CLASS_HID_EVENT_BUFFER_LENGTH such that it is less than or equal to UX_SLAVE_REQUEST_DATA_MAX_LENGTH." */
163+
/* Build option checked runtime by UX_ASSERT */
151164
#endif
152165

153166
#ifndef UX_DEVICE_CLASS_HID_MAX_EVENTS_QUEUE
@@ -313,15 +326,54 @@ UINT _ux_device_class_hid_read_run(UX_SLAVE_CLASS_HID *hid,
313326
ULONG *actual_length);
314327
UINT _ux_device_class_hid_receiver_tasks_run(UX_SLAVE_CLASS_HID *hid);
315328

329+
330+
UINT _uxe_device_class_hid_initialize(UX_SLAVE_CLASS_COMMAND *command);
331+
UINT _uxe_device_class_hid_event_set(UX_SLAVE_CLASS_HID *hid,
332+
UX_SLAVE_CLASS_HID_EVENT *hid_event);
333+
UINT _uxe_device_class_hid_event_get(UX_SLAVE_CLASS_HID *hid,
334+
UX_SLAVE_CLASS_HID_EVENT *hid_event);
335+
UINT _uxe_device_class_hid_read(UX_SLAVE_CLASS_HID *hid,
336+
UCHAR *buffer, ULONG requested_length,
337+
ULONG *actual_length);
338+
UINT _uxe_device_class_hid_read_run(UX_SLAVE_CLASS_HID *hid,
339+
UCHAR *buffer, ULONG requested_length,
340+
ULONG *actual_length);
341+
UINT _uxe_device_class_hid_receiver_initialize(UX_SLAVE_CLASS_HID *hid,
342+
UX_SLAVE_CLASS_HID_PARAMETER *parameter,
343+
UX_DEVICE_CLASS_HID_RECEIVER **receiver);
344+
UINT _uxe_device_class_hid_receiver_event_get(UX_SLAVE_CLASS_HID *hid,
345+
UX_DEVICE_CLASS_HID_RECEIVED_EVENT *event);
346+
UINT _uxe_device_class_hid_receiver_event_free(UX_SLAVE_CLASS_HID *hid);
347+
348+
316349
/* Define Device HID Class API prototypes. */
317350

351+
#if defined(UX_DEVICE_CLASS_HID_ENABLE_ERROR_CHECKING)
352+
353+
#define ux_device_class_hid_entry _ux_device_class_hid_entry
354+
#define ux_device_class_hid_event_set _uxe_device_class_hid_event_set
355+
#define ux_device_class_hid_event_get _uxe_device_class_hid_event_get
356+
#define ux_device_class_hid_report_set _ux_device_class_hid_report_set
357+
#define ux_device_class_hid_report_get _ux_device_class_hid_report_get
358+
359+
#define ux_device_class_hid_protocol_get(hid) (((hid) == UX_NULL) ? UX_ERROR : (hid) -> ux_device_class_hid_protocol)
360+
361+
#define ux_device_class_hid_read _uxe_device_class_hid_read
362+
#define ux_device_class_hid_read_run _uxe_device_class_hid_read_run
363+
364+
#define ux_device_class_hid_receiver_initialize _ux_device_class_hid_receiver_initialize
365+
#define ux_device_class_hid_receiver_event_get _uxe_device_class_hid_receiver_event_get
366+
#define ux_device_class_hid_receiver_event_free _uxe_device_class_hid_receiver_event_free
367+
368+
#else
369+
318370
#define ux_device_class_hid_entry _ux_device_class_hid_entry
319371
#define ux_device_class_hid_event_set _ux_device_class_hid_event_set
320372
#define ux_device_class_hid_event_get _ux_device_class_hid_event_get
321373
#define ux_device_class_hid_report_set _ux_device_class_hid_report_set
322374
#define ux_device_class_hid_report_get _ux_device_class_hid_report_get
323375

324-
#define ux_device_class_hid_protocol_get(hid) (hid -> ux_device_class_hid_protocol)
376+
#define ux_device_class_hid_protocol_get(hid) ((hid) -> ux_device_class_hid_protocol)
325377

326378
#define ux_device_class_hid_read _ux_device_class_hid_read
327379
#define ux_device_class_hid_read_run _ux_device_class_hid_read_run
@@ -330,6 +382,8 @@ UINT _ux_device_class_hid_receiver_tasks_run(UX_SLAVE_CLASS_HID *hid);
330382
#define ux_device_class_hid_receiver_event_get _ux_device_class_hid_receiver_event_get
331383
#define ux_device_class_hid_receiver_event_free _ux_device_class_hid_receiver_event_free
332384

385+
#endif
386+
333387
/* Determine if a C++ compiler is being used. If so, complete the standard
334388
C conditional started above. */
335389
#ifdef __cplusplus

0 commit comments

Comments
 (0)