Skip to content

Commit

Permalink
Add 'USE_ZEPHYR_USB_STACK' flag
Browse files Browse the repository at this point in the history
This commit adds 'USE_ZEPHYR_USB_STACK' flag to handle differences
between MSDK USB and Zephyr USB.

Disabled given line in 'usb.c' file with using 'USE_ZEPHYR_USB_STACK'
flag for Zephyr USB stack because this line causes a race condition for
Zephyr USB. I added this line to 'udc_max32.c' file of Zephyr repo
to handle race condition problem.

Disabled given line in 'usb_protocol.h' file because this line causes a
'redefined' warning for Zephyr USB stack.

Signed-off-by: Furkan Akkiz <[email protected]>
  • Loading branch information
hfakkiz committed Dec 16, 2024
1 parent 6f68827 commit 4f8d65e
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
3 changes: 3 additions & 0 deletions Libraries/MAXUSB/include/core/usb_protocol.h
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,10 @@ typedef __packed struct {
} MXC_USB_interface_descriptor_t;

#define USB_EP_NUM_MASK 0x0F

#ifndef USE_ZEPHYR_USB_STACK
#define USB_EP_DIR_MASK 0x80
#endif

#if defined(__GNUC__)
typedef struct __attribute__((packed)) {
Expand Down
2 changes: 2 additions & 0 deletions Libraries/MAXUSB/src/core/musbhsfc/usb.c
Original file line number Diff line number Diff line change
Expand Up @@ -941,7 +941,9 @@ int MXC_USB_GetSetup(MXC_USB_SetupPkt *sud)

/* Check for follow-on data and advance state machine */
if (sud->wLength > 0) {
#ifndef USE_ZEPHYR_USB_STACK
MXC_USBHS->csr0 |= MXC_F_USBHS_CSR0_SERV_OUTPKTRDY;
#endif
/* Determine if IN or OUT data follows */
if (sud->bmRequestType & RT_DEV_TO_HOST) {
setup_phase = SETUP_DATA_IN;
Expand Down
4 changes: 4 additions & 0 deletions Libraries/zephyr/MAX/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ zephyr_include_directories(
)

if (CONFIG_UDC_MAX32)
zephyr_compile_definitions(
-DUSE_ZEPHYR_USB_STACK=1
)

set(MSDK_MAXUSB_DIR ${MSDK_LIBRARY_DIR}/MAXUSB)

zephyr_include_directories(
Expand Down

0 comments on commit 4f8d65e

Please sign in to comment.