Skip to content

Commit 99d7cfb

Browse files
authored
Merge pull request #220 from ayedm1/fix_compilation_issue_when_debug_log_enabled
Improvement of UX_ENABLE_DEBUG_LOG option
2 parents 130fd5b + 3632bd4 commit 99d7cfb

File tree

5 files changed

+163
-152
lines changed

5 files changed

+163
-152
lines changed

common/core/inc/ux_api.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -441,15 +441,16 @@ typedef signed char SCHAR;
441441

442442
/* Map the error log macros to internal USBX function. */
443443

444-
#define UX_DEBUG_LOG(debug_location, debug_message, debug_code, debug_parameter_1, debug_parameter_2) _ux_utility_debug_log((UCHAR *) debug_location, (UCHAR *) debug_message, (ULONG) debug_code, (ULONG) debug_parameter_1, (ULONG) debug_parameter_2);
444+
#define UX_DEBUG_LOG(debug_location, debug_message, debug_code, debug_parameter_1, debug_parameter_2) \
445+
_ux_utility_debug_log((UCHAR *) debug_location, (UCHAR *) debug_message, (ULONG) debug_code, \
446+
(ULONG) debug_parameter_1, (ULONG) debug_parameter_2);
445447

446448
VOID _ux_utility_debug_log(UCHAR *debug_location, UCHAR *debug_message, ULONG debug_code, ULONG debug_parameter_1, ULONG debug_parameter_2);
447449

448450
/* DEBUG LOG MESSAGES SHOULD BE WRITTEN LIKE THIS IN THE CODE : */
449451
/* If error log is enabled, insert this error message into the log buffer. */
450452
/* UX_DEBUG_LOG("_ux_host_stack_rh_device_insertion", "Device insertion", port_index, port_index, 0) */
451453

452-
453454
#else
454455

455456
/* If Log is not defined, map it to nothing so that debug messages can stay in the code. */

common/core/inc/ux_user_sample.h

Lines changed: 53 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
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

1111

1212
/**************************************************************************/
1313
/**************************************************************************/
14-
/** */
14+
/** */
1515
/** USBX Component */
1616
/** */
1717
/** User Specific */
@@ -20,29 +20,29 @@
2020
/**************************************************************************/
2121

2222

23-
/**************************************************************************/
24-
/* */
25-
/* PORT SPECIFIC C INFORMATION RELEASE */
26-
/* */
27-
/* ux_user.h PORTABLE C */
23+
/**************************************************************************/
24+
/* */
25+
/* PORT SPECIFIC C INFORMATION RELEASE */
26+
/* */
27+
/* ux_user.h PORTABLE C */
2828
/* 6.3.0 */
2929
/* */
3030
/* AUTHOR */
3131
/* */
3232
/* Chaoqiong Xiao, Microsoft Corporation */
3333
/* */
3434
/* DESCRIPTION */
35-
/* */
36-
/* This file contains user defines for configuring USBX in specific */
37-
/* ways. This file will have an effect only if the application and */
38-
/* USBX library are built with UX_INCLUDE_USER_DEFINE_FILE defined. */
39-
/* Note that all the defines in this file may also be made on the */
40-
/* command line when building USBX library and application objects. */
41-
/* */
42-
/* RELEASE HISTORY */
43-
/* */
44-
/* DATE NAME DESCRIPTION */
45-
/* */
35+
/* */
36+
/* This file contains user defines for configuring USBX in specific */
37+
/* ways. This file will have an effect only if the application and */
38+
/* USBX library are built with UX_INCLUDE_USER_DEFINE_FILE defined. */
39+
/* Note that all the defines in this file may also be made on the */
40+
/* command line when building USBX library and application objects. */
41+
/* */
42+
/* RELEASE HISTORY */
43+
/* */
44+
/* DATE NAME DESCRIPTION */
45+
/* */
4646
/* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */
4747
/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */
4848
/* resulting in version 6.1 */
@@ -115,15 +115,15 @@
115115

116116

117117
/* Define various build options for the USBX port. The application should either make changes
118-
here by commenting or un-commenting the conditional compilation defined OR supply the defines
118+
here by commenting or un-commenting the conditional compilation defined OR supply the defines
119119
though the compiler's equivalent of the -D option. */
120120

121121
/* Define USBX Generic Thread Stack Size. */
122122
/* #define UX_THREAD_STACK_SIZE (2 * 1024) */
123123

124124
/* Define USBX Host Enum Thread Stack Size. The default is to use UX_THREAD_STACK_SIZE */
125-
/*
126-
#define UX_HOST_ENUM_THREAD_STACK_SIZE UX_THREAD_STACK_SIZE
125+
/*
126+
#define UX_HOST_ENUM_THREAD_STACK_SIZE UX_THREAD_STACK_SIZE
127127
*/
128128

129129

@@ -137,14 +137,14 @@
137137
#define UX_HOST_HNP_POLLING_THREAD_STACK UX_THREAD_STACK_SIZE
138138
*/
139139

140-
/* Override various options with default values already assigned in ux_api.h or ux_port.h. Please
140+
/* Override various options with default values already assigned in ux_api.h or ux_port.h. Please
141141
also refer to ux_port.h for descriptions on each of these options. */
142142

143143
/* Defined, this value represents minimal allocated memory alignment in number of bytes.
144144
The default is UX_ALIGN_8 (0x07) to align allocated memory to 8 bytes. */
145145
/* #define UX_ALIGN_MIN UX_ALIGN_8 */
146146

147-
/* Defined, this value represents how many ticks per seconds for a specific hardware platform.
147+
/* Defined, this value represents how many ticks per seconds for a specific hardware platform.
148148
The default is 1000 indicating 1 tick per millisecond. */
149149

150150
/* #define UX_PERIODIC_RATE 1000
@@ -167,7 +167,7 @@
167167
/* Defined, this value is the maximum number of classes that can be loaded by USBX. This value
168168
represents the class container and not the number of instances of a class. For instance, if a
169169
particular implementation of USBX needs the hub class, the printer class, and the storage
170-
class, then the UX_MAX_CLASSES value can be set to 3 regardless of the number of devices
170+
class, then the UX_MAX_CLASSES value can be set to 3 regardless of the number of devices
171171
that belong to these classes. */
172172

173173
/* #define UX_MAX_CLASSES 3
@@ -185,9 +185,9 @@
185185
/* #define UX_MAX_SLAVE_INTERFACES 16
186186
*/
187187

188-
/* Defined, this value represents the number of different host controllers available in the system.
189-
For USB 1.1 support, this value will usually be 1. For USB 2.0 support, this value can be more
190-
than 1. This value represents the number of concurrent host controllers running at the same time.
188+
/* Defined, this value represents the number of different host controllers available in the system.
189+
For USB 1.1 support, this value will usually be 1. For USB 2.0 support, this value can be more
190+
than 1. This value represents the number of concurrent host controllers running at the same time.
191191
If for instance there are two instances of OHCI running, or one EHCI and one OHCI controller
192192
running, the UX_MAX_HCD should be set to 2. */
193193

@@ -196,8 +196,8 @@
196196

197197

198198
/* Defined, this value represents the maximum number of devices that can be attached to the USB.
199-
Normally, the theoretical maximum number on a single USB is 127 devices. This value can be
200-
scaled down to conserve memory. Note that this value represents the total number of devices
199+
Normally, the theoretical maximum number on a single USB is 127 devices. This value can be
200+
scaled down to conserve memory. Note that this value represents the total number of devices
201201
regardless of the number of USB buses in the system. */
202202

203203
/* #define UX_MAX_DEVICES 127
@@ -213,7 +213,7 @@
213213

214214
/* Defined, this value represents the maximum number of SCSI logical units represented in the
215215
host storage class driver. */
216-
216+
217217
/* #define UX_MAX_HOST_LUN 1
218218
*/
219219

@@ -274,13 +274,13 @@
274274

275275

276276
/* Defined, this value represents the maximum number of bytes that can be received or transmitted
277-
on any endpoint. This value cannot be less than the maximum packet size of any endpoint. The default
278-
is 4096 bytes but can be reduced in memory constrained environments. For cd-rom support in the storage
277+
on any endpoint. This value cannot be less than the maximum packet size of any endpoint. The default
278+
is 4096 bytes but can be reduced in memory constrained environments. For cd-rom support in the storage
279279
class, this value cannot be less than 2048. */
280280

281281
#define UX_SLAVE_REQUEST_DATA_MAX_LENGTH (1024 * 2)
282282

283-
/* Defined, this enables processing of Get String Descriptor requests with zero Language ID.
283+
/* Defined, this enables processing of Get String Descriptor requests with zero Language ID.
284284
The first language ID in the language ID framwork will be used if the request has a zero
285285
Language ID. */
286286
/* #define UX_DEVICE_ENABLE_GET_STRING_WITH_ZERO_LANGUAGE_ID */
@@ -297,7 +297,7 @@
297297

298298
/* Define USBX Mass Storage Thread Stack Size. The default is to use UX_THREAD_STACK_SIZE. */
299299

300-
/* #define UX_HOST_CLASS_STORAGE_THREAD_STACK_SIZE UX_THREAD_STACK_SIZE
300+
/* #define UX_HOST_CLASS_STORAGE_THREAD_STACK_SIZE UX_THREAD_STACK_SIZE
301301
*/
302302

303303
/* Defined, this value represents the maximum number of Ed, regular TDs and Isochronous TDs. These values
@@ -313,13 +313,13 @@
313313

314314
#define UX_HOST_CLASS_HID_DECOMPRESSION_BUFFER 4096
315315

316-
/* Defined, this value represents the maximum number of HID usages for a HID device.
316+
/* Defined, this value represents the maximum number of HID usages for a HID device.
317317
Default is 2048 but for simple HID devices like keyboard and mouse it can be reduced a lot. */
318318

319319
#define UX_HOST_CLASS_HID_USAGES 2048
320320

321321

322-
/* By default, each key in each HID report from the device is reported by ux_host_class_hid_keyboard_key_get
322+
/* By default, each key in each HID report from the device is reported by ux_host_class_hid_keyboard_key_get
323323
(a HID report from the device is received whenever there is a change in a key state i.e. when a key is pressed
324324
or released. The report contains every key that is down). There are limitations to this method such as not being
325325
able to determine when a key has been released.
@@ -352,13 +352,13 @@
352352
/* #define UX_HOST_CLASS_HID_KEYBOARD_EVENTS_KEY_CHANGES_MODE_REPORT_MODIFIER_KEYS */
353353

354354

355-
/* Defined, this value represents the maximum number of media for the host storage class.
355+
/* Defined, this value represents the maximum number of media for the host storage class.
356356
Default is 8 but for memory constrained resource systems this can ne reduced to 1. */
357357

358358
#define UX_HOST_CLASS_STORAGE_MAX_MEDIA 2
359359

360360
/* Defined, this value includes code to handle storage devices that use the CB
361-
or CBI protocol (such as floppy disks). It is off by default because these
361+
or CBI protocol (such as floppy disks). It is off by default because these
362362
protocols are obsolete, being superseded by the Bulk Only Transport (BOT) protocol
363363
which virtually all modern storage devices use.
364364
*/
@@ -415,8 +415,8 @@
415415

416416
/* #define UX_DEVICE_CLASS_HID_EVENT_BUFFER_LENGTH 64 */
417417

418-
/* Defined, this value represents the the maximum number of HID events/reports
419-
that can be queued at once.
418+
/* Defined, this value represents the the maximum number of HID events/reports
419+
that can be queued at once.
420420
*/
421421

422422
/* #define UX_DEVICE_CLASS_HID_MAX_EVENTS_QUEUE 8 */
@@ -485,7 +485,7 @@
485485
/* #define UX_DEVICE_BIDIRECTIONAL_ENDPOINT_SUPPORT */
486486

487487
/* Defined, this macro disables interface alternate setting support.
488-
Device stalls
488+
Device stalls
489489
*/
490490
/* UX_DEVICE_ALTERNATE_SETTING_SUPPORT_DISABLE */
491491

@@ -563,13 +563,13 @@
563563
/* Defined, this value will include the OTG polling thread. OTG can only be active if both host/device are present.
564564
*/
565565

566-
#ifndef UX_HOST_SIDE_ONLY
567-
#ifndef UX_DEVICE_SIDE_ONLY
566+
#ifndef UX_HOST_SIDE_ONLY
567+
#ifndef UX_DEVICE_SIDE_ONLY
568568

569569
/* #define UX_OTG_SUPPORT */
570570

571-
#endif
572-
#endif
571+
#endif
572+
#endif
573573

574574
/* Defined, this macro will enable the standalone mode of usbx. */
575575
/* #define UX_STANDALONE */
@@ -592,6 +592,10 @@
592592

593593
#define UX_HOST_CLASS_STORAGE_MAX_TRANSFER_SIZE (1024 * 1)
594594

595+
/* Defined, this option enables error log. */
596+
597+
/* #define UX_ENABLE_DEBUG_LOG */
598+
595599
/* Defined, this value represents the size of the log pool.
596600
*/
597601
#define UX_DEBUG_LOG_SIZE (1024 * 16)
@@ -641,7 +645,7 @@
641645
#include "usbh_hcs.h"
642646
#include "usbh_stdreq.h"
643647
#include "usbh_core.h"
644-
#endif
648+
#endif
645649

646-
#endif
650+
#endif
647651

common/core/inc/ux_utility.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -451,6 +451,7 @@ VOID* _ux_utility_memory_allocate_add_safe(ULONG align,ULONG cache,UL
451451
#define ux_utility_event_flags_set _ux_utility_event_flags_set
452452
#define ux_utility_unicode_to_string _ux_utility_unicode_to_string
453453
#define ux_utility_string_to_unicode _ux_utility_string_to_unicode
454+
#define ux_utility_debug_callback_register _ux_utility_debug_callback_register
454455
#define ux_utility_delay_ms _ux_utility_delay_ms
455456
#define ux_utility_error_callback_register _ux_utility_error_callback_register
456457
#define ux_system_error_handler _ux_system_error_handler

0 commit comments

Comments
 (0)