From 6183dbd0ceefdbff42d30e6691fa9948a695e9af Mon Sep 17 00:00:00 2001 From: hathach Date: Fri, 27 Sep 2019 00:15:43 +0700 Subject: [PATCH 1/5] add -Wextra for more warnings to example non-stack warning (probably mcu driver) should be suppressed in the board.mk --- examples/make.mk | 1 + hw/bsp/circuitplayground_bluefruit/board.mk | 5 ++++- hw/bsp/ea4088qs/board.mk | 4 ++-- hw/bsp/ea4357/board.mk | 4 ++-- hw/bsp/feather_nrf52840_express/board.mk | 5 ++++- hw/bsp/lpcxpresso11u37/board.mk | 4 ++-- hw/bsp/lpcxpresso51u68/board.mk | 4 ++-- hw/bsp/lpcxpresso54114/board.mk | 3 +++ hw/bsp/lpcxpresso55s69/board.mk | 6 +++--- hw/bsp/mcb1800/board.mk | 4 ++-- hw/bsp/ngx4330/board.mk | 4 ++-- hw/bsp/pca10056/board.mk | 5 ++++- hw/bsp/pca10056/pca10056.c | 3 ++- hw/bsp/pca10059/board.mk | 5 ++++- hw/bsp/stm32f070rbnucleo/board.mk | 3 +++ hw/bsp/stm32f072disco/board.mk | 3 +++ hw/bsp/stm32f207nucleo/board.mk | 2 +- hw/bsp/stm32f303disco/board.mk | 3 +++ hw/bsp/stm32f412disco/board.mk | 3 +++ hw/bsp/stm32f767nucleo/board.mk | 4 ++-- hw/bsp/stm32f767nucleo/stm32f767nucleo.c | 3 ++- hw/bsp/stm32h743nucleo/board.mk | 3 +++ hw/bsp/stm32h743nucleo/stm32h743nucleo.c | 2 ++ hw/bsp/stm32l0538disco/board.mk | 2 ++ src/class/midi/midi_device.c | 13 ++++++++++++- src/osal/osal_none.h | 4 ++++ src/portable/st/stm32_fsdev/dcd_stm32_fsdev.c | 16 ++++++++-------- .../st/stm32_fsdev/dcd_stm32_fsdev_pvt_st.h | 2 +- src/portable/st/synopsys/dcd_synopsys.c | 10 +++++----- tools/build_all.py | 8 ++++---- 30 files changed, 95 insertions(+), 43 deletions(-) diff --git a/examples/make.mk b/examples/make.mk index f35195fde..22d8f7455 100644 --- a/examples/make.mk +++ b/examples/make.mk @@ -56,6 +56,7 @@ CFLAGS += \ -Wno-endif-labels \ -Wstrict-prototypes \ -Wall \ + -Wextra \ -Werror \ -Werror-implicit-function-declaration \ -Wfatal-errors \ diff --git a/hw/bsp/circuitplayground_bluefruit/board.mk b/hw/bsp/circuitplayground_bluefruit/board.mk index 26b15564d..c1513fe7c 100644 --- a/hw/bsp/circuitplayground_bluefruit/board.mk +++ b/hw/bsp/circuitplayground_bluefruit/board.mk @@ -9,7 +9,10 @@ CFLAGS += \ -DCONFIG_GPIO_AS_PINRESET # nrfx issue undef _ARMCC_VERSION usage https://github.com/NordicSemiconductor/nrfx/issues/49 -CFLAGS += -Wno-error=undef +CFLAGS += -Wno-error=undef -Wno-error=unused-parameter + +# due to tusb_hal_nrf_power_event +CFLAGS += -Wno-error=cast-function-type # All source paths should be relative to the top level. LD_FILE = hw/bsp/circuitplayground_bluefruit/nrf52840_s140_v6.ld diff --git a/hw/bsp/ea4088qs/board.mk b/hw/bsp/ea4088qs/board.mk index 510e2912b..46625ca84 100644 --- a/hw/bsp/ea4088qs/board.mk +++ b/hw/bsp/ea4088qs/board.mk @@ -8,8 +8,8 @@ CFLAGS += \ -DCFG_TUSB_MEM_SECTION='__attribute__((section(".data.$$RAM2")))' \ -D__USE_LPCOPEN -# lpc_types.h cause following errors -CFLAGS += -Wno-error=strict-prototypes +# mcu driver cause following warnings +CFLAGS += -Wno-error=strict-prototypes -Wno-error=unused-parameter MCU_DIR = hw/mcu/nxp/lpc_driver/lpc40xx/lpc_chip_40xx diff --git a/hw/bsp/ea4357/board.mk b/hw/bsp/ea4357/board.mk index 265d9b38b..823481baf 100644 --- a/hw/bsp/ea4357/board.mk +++ b/hw/bsp/ea4357/board.mk @@ -7,8 +7,8 @@ CFLAGS += \ -DCFG_TUSB_MCU=OPT_MCU_LPC43XX \ -D__USE_LPCOPEN -# lpc_types.h cause following errors -CFLAGS += -Wno-error=strict-prototypes +# mcu driver cause following warnings +CFLAGS += -Wno-error=unused-parameter -Wno-error=strict-prototypes MCU_DIR = hw/mcu/nxp/lpc_driver/lpc43xx/lpc_chip_43xx diff --git a/hw/bsp/feather_nrf52840_express/board.mk b/hw/bsp/feather_nrf52840_express/board.mk index 11b5e7bdc..1900bedbb 100644 --- a/hw/bsp/feather_nrf52840_express/board.mk +++ b/hw/bsp/feather_nrf52840_express/board.mk @@ -9,7 +9,10 @@ CFLAGS += \ -DCONFIG_GPIO_AS_PINRESET # nrfx issue undef _ARMCC_VERSION usage https://github.com/NordicSemiconductor/nrfx/issues/49 -CFLAGS += -Wno-error=undef +CFLAGS += -Wno-error=undef -Wno-error=unused-parameter + +# due to tusb_hal_nrf_power_event +CFLAGS += -Wno-error=cast-function-type # All source paths should be relative to the top level. LD_FILE = hw/bsp/feather_nrf52840_express/nrf52840_s140_v6.ld diff --git a/hw/bsp/lpcxpresso11u37/board.mk b/hw/bsp/lpcxpresso11u37/board.mk index 228765550..ced7ceefd 100644 --- a/hw/bsp/lpcxpresso11u37/board.mk +++ b/hw/bsp/lpcxpresso11u37/board.mk @@ -10,8 +10,8 @@ CFLAGS += \ -DCFG_TUSB_MEM_SECTION='__attribute__((section(".data.$$RAM2")))' \ -DCFG_TUSB_MEM_ALIGN='__attribute__((aligned(64)))' -# startup.c and lpc_types.h cause following errors -CFLAGS += -Wno-error=nested-externs -Wno-error=strict-prototypes +# mcu driver cause following warnings +CFLAGS += -Wno-error=nested-externs -Wno-error=strict-prototypes -Wno-error=unused-parameter MCU_DIR = hw/mcu/nxp/lpc_driver/lpc11uxx/lpc_chip_11uxx diff --git a/hw/bsp/lpcxpresso51u68/board.mk b/hw/bsp/lpcxpresso51u68/board.mk index 5ebda6c39..e5576c3c0 100644 --- a/hw/bsp/lpcxpresso51u68/board.mk +++ b/hw/bsp/lpcxpresso51u68/board.mk @@ -7,8 +7,8 @@ CFLAGS += \ -DCFG_TUSB_MEM_SECTION='__attribute__((section(".data")))' \ -DCFG_TUSB_MEM_ALIGN='__attribute__((aligned(64)))' -# system_LPC51U68.c cause following errors -CFLAGS += -Wno-error=nested-externs +# mcu driver cause following warnings +CFLAGS += -Wno-error=nested-externs -Wno-error=unused-parameter MCU_DIR = hw/mcu/nxp/lpc_driver/lpc51u6x/devices/LPC51U68 diff --git a/hw/bsp/lpcxpresso54114/board.mk b/hw/bsp/lpcxpresso54114/board.mk index 90e864e99..21c8dfd32 100644 --- a/hw/bsp/lpcxpresso54114/board.mk +++ b/hw/bsp/lpcxpresso54114/board.mk @@ -9,6 +9,9 @@ CFLAGS += \ -DCFG_TUSB_MEM_SECTION='__attribute__((section(".data")))' \ -DCFG_TUSB_MEM_ALIGN='__attribute__((aligned(64)))' +# mcu driver cause following warnings +CFLAGS += -Wno-error=unused-parameter + MCU_DIR = hw/mcu/nxp/lpc_driver/lpc54xxx/devices/LPC54114 # All source paths should be relative to the top level. diff --git a/hw/bsp/lpcxpresso55s69/board.mk b/hw/bsp/lpcxpresso55s69/board.mk index 2ab7ec51e..6f1afaac1 100644 --- a/hw/bsp/lpcxpresso55s69/board.mk +++ b/hw/bsp/lpcxpresso55s69/board.mk @@ -7,10 +7,10 @@ CFLAGS += \ -DCPU_LPC55S69JBD100_cm33_core0 \ -DCFG_TUSB_MCU=OPT_MCU_LPC55XX \ -DCFG_TUSB_MEM_SECTION='__attribute__((section(".data")))' \ - -DCFG_TUSB_MEM_ALIGN='__attribute__((aligned(64)))' + -DCFG_TUSB_MEM_ALIGN='__attribute__((aligned(64)))' -# system_LPC55S69_cm33_core0.c cause following errors -CFLAGS += -Wno-error=float-equal -Wno-error=nested-externs +# mcu driver cause following warnings +CFLAGS += -Wno-error=unused-parameter -Wno-error=float-equal -Wno-error=nested-externs MCU_DIR = hw/mcu/nxp/lpc_driver/lpc55xx/devices/LPC55S69 diff --git a/hw/bsp/mcb1800/board.mk b/hw/bsp/mcb1800/board.mk index 4a59c043a..3b8ee2968 100644 --- a/hw/bsp/mcb1800/board.mk +++ b/hw/bsp/mcb1800/board.mk @@ -7,8 +7,8 @@ CFLAGS += \ -DCFG_TUSB_MCU=OPT_MCU_LPC18XX \ -D__USE_LPCOPEN -# lpc_types.h cause following errors -CFLAGS += -Wno-error=strict-prototypes +# mcu driver cause following warnings +CFLAGS += -Wno-error=unused-parameter -Wno-error=strict-prototypes MCU_DIR = hw/mcu/nxp/lpc_driver/lpc18xx/lpc_chip_18xx diff --git a/hw/bsp/ngx4330/board.mk b/hw/bsp/ngx4330/board.mk index 852c883b0..b82ae9d5c 100644 --- a/hw/bsp/ngx4330/board.mk +++ b/hw/bsp/ngx4330/board.mk @@ -7,8 +7,8 @@ CFLAGS += \ -DCFG_TUSB_MCU=OPT_MCU_LPC43XX \ -D__USE_LPCOPEN -# lpc_types.h cause following errors -CFLAGS += -Wno-error=strict-prototypes +# mcu driver cause following warnings +CFLAGS += -Wno-error=strict-prototypes -Wno-error=unused-parameter MCU_DIR = hw/mcu/nxp/lpc_driver/lpc43xx/lpc_chip_43xx diff --git a/hw/bsp/pca10056/board.mk b/hw/bsp/pca10056/board.mk index 9dbaea426..dc2c434f4 100644 --- a/hw/bsp/pca10056/board.mk +++ b/hw/bsp/pca10056/board.mk @@ -9,7 +9,10 @@ CFLAGS += \ -DCFG_TUSB_MCU=OPT_MCU_NRF5X # nrfx issue undef _ARMCC_VERSION usage https://github.com/NordicSemiconductor/nrfx/issues/49 -CFLAGS += -Wno-error=undef +CFLAGS += -Wno-error=undef -Wno-error=unused-parameter + +# due to tusb_hal_nrf_power_event +CFLAGS += -Wno-error=cast-function-type # All source paths should be relative to the top level. LD_FILE = hw/mcu/nordic/nrfx/mdk/nrf52840_xxaa.ld diff --git a/hw/bsp/pca10056/pca10056.c b/hw/bsp/pca10056/pca10056.c index f575895ec..57426732c 100644 --- a/hw/bsp/pca10056/pca10056.c +++ b/hw/bsp/pca10056/pca10056.c @@ -96,7 +96,8 @@ void board_init(void) nrfx_power_init(&pwr_cfg); // Register tusb function as USB power handler - const nrfx_power_usbevt_config_t config = { .handler = (nrfx_power_usb_event_handler_t) tusb_hal_nrf_power_event }; + // cause cast-function-type warning + const nrfx_power_usbevt_config_t config = { .handler = ((nrfx_power_usb_event_handler_t) tusb_hal_nrf_power_event) }; nrfx_power_usbevt_init(&config); nrfx_power_usbevt_enable(); diff --git a/hw/bsp/pca10059/board.mk b/hw/bsp/pca10059/board.mk index a92592dd1..0ef56ed50 100644 --- a/hw/bsp/pca10059/board.mk +++ b/hw/bsp/pca10059/board.mk @@ -9,7 +9,10 @@ CFLAGS += \ -DCFG_TUSB_MCU=OPT_MCU_NRF5X # nrfx issue undef _ARMCC_VERSION usage https://github.com/NordicSemiconductor/nrfx/issues/49 -CFLAGS += -Wno-error=undef +CFLAGS += -Wno-error=undef -Wno-error=unused-parameter + +# due to tusb_hal_nrf_power_event +CFLAGS += -Wno-error=cast-function-type # All source paths should be relative to the top level. LD_FILE = hw/bsp/$(BOARD)/$(BOARD).ld diff --git a/hw/bsp/stm32f070rbnucleo/board.mk b/hw/bsp/stm32f070rbnucleo/board.mk index 6c5fbe022..42394d1ad 100644 --- a/hw/bsp/stm32f070rbnucleo/board.mk +++ b/hw/bsp/stm32f070rbnucleo/board.mk @@ -9,6 +9,9 @@ CFLAGS += \ -DCFG_EXAMPLE_MSC_READONLY \ -DCFG_TUSB_MCU=OPT_MCU_STM32F0 +# mcu driver cause following warnings +CFLAGS += -Wno-error=unused-parameter + ST_HAL_DRIVER = hw/mcu/st/st_driver/STM32F0xx_HAL_Driver ST_CMSIS = hw/mcu/st/st_driver/CMSIS/Device/ST/STM32F0xx diff --git a/hw/bsp/stm32f072disco/board.mk b/hw/bsp/stm32f072disco/board.mk index 0a58a5654..6529763ee 100644 --- a/hw/bsp/stm32f072disco/board.mk +++ b/hw/bsp/stm32f072disco/board.mk @@ -9,6 +9,9 @@ CFLAGS += \ -DCFG_EXAMPLE_MSC_READONLY \ -DCFG_TUSB_MCU=OPT_MCU_STM32F0 +# mcu driver cause following warnings +CFLAGS += -Wno-error=unused-parameter + ST_HAL_DRIVER = hw/mcu/st/st_driver/STM32F0xx_HAL_Driver ST_CMSIS = hw/mcu/st/st_driver/CMSIS/Device/ST/STM32F0xx diff --git a/hw/bsp/stm32f207nucleo/board.mk b/hw/bsp/stm32f207nucleo/board.mk index fa7855439..cd2b26204 100644 --- a/hw/bsp/stm32f207nucleo/board.mk +++ b/hw/bsp/stm32f207nucleo/board.mk @@ -8,7 +8,7 @@ CFLAGS += \ -nostdlib -nostartfiles \ -DCFG_TUSB_MCU=OPT_MCU_STM32F2 -# Suppress following warnings/error is required due to STM32F2xx_HAL_Driver. +# mcu driver cause following warnings CFLAGS += -Wno-error=sign-compare ST_HAL_DRIVER = hw/mcu/st/st_driver/STM32F2xx_HAL_Driver diff --git a/hw/bsp/stm32f303disco/board.mk b/hw/bsp/stm32f303disco/board.mk index 9efee9092..ab77c55c4 100644 --- a/hw/bsp/stm32f303disco/board.mk +++ b/hw/bsp/stm32f303disco/board.mk @@ -9,6 +9,9 @@ CFLAGS += \ -nostdlib -nostartfiles \ -DCFG_TUSB_MCU=OPT_MCU_STM32F3 +# mcu driver cause following warnings +CFLAGS += -Wno-error=unused-parameter + ST_HAL_DRIVER = hw/mcu/st/st_driver/STM32F3xx_HAL_Driver ST_CMSIS = hw/mcu/st/st_driver/CMSIS/Device/ST/STM32F3xx diff --git a/hw/bsp/stm32f412disco/board.mk b/hw/bsp/stm32f412disco/board.mk index 62f1d4c1e..e059c81d1 100644 --- a/hw/bsp/stm32f412disco/board.mk +++ b/hw/bsp/stm32f412disco/board.mk @@ -9,6 +9,9 @@ CFLAGS += \ -nostdlib -nostartfiles \ -DCFG_TUSB_MCU=OPT_MCU_STM32F4 +# mcu driver cause following warnings +CFLAGS += -Wno-error=maybe-uninitialized + ST_HAL_DRIVER = hw/mcu/st/st_driver/STM32F4xx_HAL_Driver ST_CMSIS = hw/mcu/st/st_driver/CMSIS/Device/ST/STM32F4xx diff --git a/hw/bsp/stm32f767nucleo/board.mk b/hw/bsp/stm32f767nucleo/board.mk index 3a15e67c7..65690cb2f 100644 --- a/hw/bsp/stm32f767nucleo/board.mk +++ b/hw/bsp/stm32f767nucleo/board.mk @@ -9,8 +9,8 @@ CFLAGS += \ -nostdlib -nostartfiles \ -DCFG_TUSB_MCU=OPT_MCU_STM32F7 -# Suppress following warnings/error is required due to STM32F7xx_HAL_Driver. -CFLAGS += -Wno-error=shadow +# mcu driver cause following warnings +CFLAGS += -Wno-error=shadow ST_HAL_DRIVER = hw/mcu/st/st_driver/STM32F7xx_HAL_Driver ST_CMSIS = hw/mcu/st/st_driver/CMSIS/Device/ST/STM32F7xx diff --git a/hw/bsp/stm32f767nucleo/stm32f767nucleo.c b/hw/bsp/stm32f767nucleo/stm32f767nucleo.c index 5ac2ddb72..07412fd8e 100644 --- a/hw/bsp/stm32f767nucleo/stm32f767nucleo.c +++ b/hw/bsp/stm32f767nucleo/stm32f767nucleo.c @@ -174,15 +174,16 @@ uint32_t board_button_read(void) int board_uart_read(uint8_t* buf, int len) { + (void) buf; (void) len; return 0; } int board_uart_write(void const * buf, int len) { + (void) buf; (void) len; return 0; } - #if CFG_TUSB_OS == OPT_OS_NONE volatile uint32_t system_ticks = 0; void SysTick_Handler (void) diff --git a/hw/bsp/stm32h743nucleo/board.mk b/hw/bsp/stm32h743nucleo/board.mk index 3d6aae4c4..40b36413f 100644 --- a/hw/bsp/stm32h743nucleo/board.mk +++ b/hw/bsp/stm32h743nucleo/board.mk @@ -9,6 +9,9 @@ CFLAGS += \ -nostdlib -nostartfiles \ -DCFG_TUSB_MCU=OPT_MCU_STM32H7 +# mcu driver cause following warnings +CFLAGS += -Wno-error=maybe-uninitialized + ST_HAL_DRIVER = hw/mcu/st/st_driver/STM32H7xx_HAL_Driver ST_CMSIS = hw/mcu/st/st_driver/CMSIS/Device/ST/STM32H7xx diff --git a/hw/bsp/stm32h743nucleo/stm32h743nucleo.c b/hw/bsp/stm32h743nucleo/stm32h743nucleo.c index 2e02786ee..f7e46a158 100644 --- a/hw/bsp/stm32h743nucleo/stm32h743nucleo.c +++ b/hw/bsp/stm32h743nucleo/stm32h743nucleo.c @@ -197,11 +197,13 @@ uint32_t board_button_read(void) int board_uart_read(uint8_t* buf, int len) { + (void) buf; (void) len; return 0; } int board_uart_write(void const * buf, int len) { + (void) buf; (void) len; return 0; } diff --git a/hw/bsp/stm32l0538disco/board.mk b/hw/bsp/stm32l0538disco/board.mk index 3b84159d1..7e11fa6cd 100644 --- a/hw/bsp/stm32l0538disco/board.mk +++ b/hw/bsp/stm32l0538disco/board.mk @@ -9,6 +9,8 @@ CFLAGS += \ -DCFG_EXAMPLE_MSC_READONLY \ -DCFG_TUSB_MCU=OPT_MCU_STM32L0 +# mcu driver cause following warnings +CFLAGS += -Wno-error=unused-parameter -Wno-error=maybe-uninitialized ST_HAL_DRIVER = hw/mcu/st/st_driver/STM32L0xx_HAL_Driver ST_CMSIS = hw/mcu/st/st_driver/CMSIS/Device/ST/STM32L0xx diff --git a/src/class/midi/midi_device.c b/src/class/midi/midi_device.c index 50826a1f4..11fe06e38 100644 --- a/src/class/midi/midi_device.c +++ b/src/class/midi/midi_device.c @@ -86,16 +86,19 @@ bool tud_midi_n_mounted (uint8_t itf) //--------------------------------------------------------------------+ uint32_t tud_midi_n_available(uint8_t itf, uint8_t jack_id) { + (void) jack_id; return tu_fifo_count(&_midid_itf[itf].rx_ff); } uint32_t tud_midi_n_read(uint8_t itf, uint8_t jack_id, void* buffer, uint32_t bufsize) { + (void) jack_id; return tu_fifo_read_n(&_midid_itf[itf].rx_ff, buffer, bufsize); } void tud_midi_n_read_flush (uint8_t itf, uint8_t jack_id) { + (void) jack_id; tu_fifo_clear(&_midid_itf[itf].rx_ff); } @@ -128,6 +131,8 @@ void midi_rx_done_cb(midid_interface_t* midi, uint8_t const* buffer, uint32_t bu static bool maybe_transmit(midid_interface_t* midi, uint8_t itf_index) { + (void) itf_index; + // skip if previous transfer not complete TU_VERIFY( !usbd_edpt_busy(TUD_OPT_RHPORT, midi->ep_in) ); @@ -309,11 +314,15 @@ bool midid_open(uint8_t rhport, tusb_desc_interface_t const * p_interface_desc, bool midid_control_complete(uint8_t rhport, tusb_control_request_t const * p_request) { - return false; + (void) rhport; + (void) p_request; + return true; } bool midid_control_request(uint8_t rhport, tusb_control_request_t const * p_request) { + (void) rhport; + //------------- Class Specific Request -------------// if (p_request->bmRequestType_bit.type != TUSB_REQ_TYPE_CLASS) return false; @@ -322,6 +331,8 @@ bool midid_control_request(uint8_t rhport, tusb_control_request_t const * p_requ bool midid_xfer_cb(uint8_t rhport, uint8_t ep_addr, xfer_result_t result, uint32_t xferred_bytes) { + (void) result; + // TODO Support multiple interfaces uint8_t const itf = 0; midid_interface_t* p_midi = &_midid_itf[itf]; diff --git a/src/osal/osal_none.h b/src/osal/osal_none.h index 7780345df..fa581215d 100644 --- a/src/osal/osal_none.h +++ b/src/osal/osal_none.h @@ -145,6 +145,8 @@ typedef osal_queue_def_t* osal_queue_t; // lock queue by disable usb isr static inline void _osal_q_lock(osal_queue_t qhdl) { + (void) qhdl; + #if TUSB_OPT_DEVICE_ENABLED if (qhdl->role == OPT_MODE_DEVICE) dcd_int_disable(TUD_OPT_RHPORT); #endif @@ -157,6 +159,8 @@ static inline void _osal_q_lock(osal_queue_t qhdl) // unlock queue static inline void _osal_q_unlock(osal_queue_t qhdl) { + (void) qhdl; + #if TUSB_OPT_DEVICE_ENABLED if (qhdl->role == OPT_MODE_DEVICE) dcd_int_enable(TUD_OPT_RHPORT); #endif diff --git a/src/portable/st/stm32_fsdev/dcd_stm32_fsdev.c b/src/portable/st/stm32_fsdev/dcd_stm32_fsdev.c index 00f5b1239..9debef2ae 100644 --- a/src/portable/st/stm32_fsdev/dcd_stm32_fsdev.c +++ b/src/portable/st/stm32_fsdev/dcd_stm32_fsdev.c @@ -103,17 +103,17 @@ #include "tusb_option.h" -#define STM32F1_FSDEV ( \ - defined(STM32F102x6) || defined(STM32F102xB) || \ +#if defined(STM32F102x6) || defined(STM32F102xB) || \ defined(STM32F103x6) || defined(STM32F103xB) || \ - defined(STM32F103xE) || defined(STM32F103xG) \ -) + defined(STM32F103xE) || defined(STM32F103xG) +#define STM32F1_FSDEV +#endif #if (TUSB_OPT_DEVICE_ENABLED) && ( \ - (CFG_TUSB_MCU == OPT_MCU_STM32F0 ) || \ - (CFG_TUSB_MCU == OPT_MCU_STM32F1 && STM32F1_FSDEV ) || \ - (CFG_TUSB_MCU == OPT_MCU_STM32F3 ) || \ - (CFG_TUSB_MCU == OPT_MCU_STM32L0 ) \ + (CFG_TUSB_MCU == OPT_MCU_STM32F0 ) || \ + (CFG_TUSB_MCU == OPT_MCU_STM32F1 && defined(STM32F1_FSDEV)) || \ + (CFG_TUSB_MCU == OPT_MCU_STM32F3 ) || \ + (CFG_TUSB_MCU == OPT_MCU_STM32L0 ) \ ) // In order to reduce the dependance on HAL, we undefine this. diff --git a/src/portable/st/stm32_fsdev/dcd_stm32_fsdev_pvt_st.h b/src/portable/st/stm32_fsdev/dcd_stm32_fsdev_pvt_st.h index 30538541a..bbaa52eae 100644 --- a/src/portable/st/stm32_fsdev/dcd_stm32_fsdev_pvt_st.h +++ b/src/portable/st/stm32_fsdev/dcd_stm32_fsdev_pvt_st.h @@ -52,7 +52,7 @@ // 070RB: 2 x 16 bits/word memory LPM Support, BCD Support // PMA dedicated to USB (no sharing with CAN) -#elif STM32F1_FSDEV +#elif defined(STM32F1_FSDEV) #include "stm32f1xx.h" #define PMA_LENGTH (512u) // NO internal Pull-ups diff --git a/src/portable/st/synopsys/dcd_synopsys.c b/src/portable/st/synopsys/dcd_synopsys.c index 1a7f86219..7929b6916 100644 --- a/src/portable/st/synopsys/dcd_synopsys.c +++ b/src/portable/st/synopsys/dcd_synopsys.c @@ -27,19 +27,19 @@ #include "tusb_option.h" -#define STM32L4_SYNOPSYS ( \ - defined (STM32L475xx) || defined (STM32L476xx) || \ +#if defined (STM32L475xx) || defined (STM32L476xx) || \ defined (STM32L485xx) || defined (STM32L486xx) || defined (STM32L496xx) || \ defined (STM32L4R5xx) || defined (STM32L4R7xx) || defined (STM32L4R9xx) || \ - defined (STM32L4S5xx) || defined (STM32L4S7xx) || defined (STM32L4S9xx) \ -) + defined (STM32L4S5xx) || defined (STM32L4S7xx) || defined (STM32L4S9xx) +#define STM32L4_SYNOPSYS +#endif #if TUSB_OPT_DEVICE_ENABLED && \ ( CFG_TUSB_MCU == OPT_MCU_STM32F2 || \ CFG_TUSB_MCU == OPT_MCU_STM32F4 || \ CFG_TUSB_MCU == OPT_MCU_STM32F7 || \ CFG_TUSB_MCU == OPT_MCU_STM32H7 || \ - (CFG_TUSB_MCU == OPT_MCU_STM32L4 && STM32L4_SYNOPSYS) \ + (CFG_TUSB_MCU == OPT_MCU_STM32L4 && defined(STM32L4_SYNOPSYS)) \ ) // TODO Support OTG_HS diff --git a/tools/build_all.py b/tools/build_all.py index e327da221..b20785049 100644 --- a/tools/build_all.py +++ b/tools/build_all.py @@ -46,13 +46,13 @@ for example in all_examples: build_result = build_example(example, board) build_duration = time.monotonic() - start_time - if build_result.returncode != 0: + if build_result.returncode == 0: + success = "\033[32msucceeded\033[0m" + success_count += 1 + else: exit_status = build_result.returncode success = "\033[31mfailed\033[0m " fail_count += 1 - else: - success = "\033[32msucceeded\033[0m" - success_count += 1 if travis: print('travis_fold:start:build-{}-{}\\r'.format(example, board)) From 4ccdc5522d202daec98e2bb6536a4ed0ccd98b9a Mon Sep 17 00:00:00 2001 From: Nathan Conrad Date: Fri, 27 Sep 2019 12:41:46 -0400 Subject: [PATCH 2/5] Fix typo of CFG_TUD_ENDOINT0_SIZE. --- examples/device/board_test/src/tusb_config.h | 2 +- examples/device/cdc_msc/src/tusb_config.h | 4 ++-- examples/device/cdc_msc/src/usb_descriptors.c | 2 +- examples/device/cdc_msc_hid_freertos/src/tusb_config.h | 4 ++-- examples/device/cdc_msc_hid_freertos/src/usb_descriptors.c | 2 +- examples/device/hid_composite/src/tusb_config.h | 4 ++-- examples/device/hid_composite/src/usb_descriptors.c | 2 +- examples/device/hid_generic_inout/src/tusb_config.h | 4 ++-- examples/device/hid_generic_inout/src/usb_descriptors.c | 2 +- examples/device/midi_test/src/tusb_config.h | 4 ++-- examples/device/midi_test/src/usb_descriptors.c | 2 +- examples/device/msc_dual_lun/src/tusb_config.h | 4 ++-- examples/device/msc_dual_lun/src/usb_descriptors.c | 2 +- examples/device/usbtmc/src/tusb_config.h | 2 +- examples/device/usbtmc/src/usb_descriptors.c | 2 +- examples/device/webusb_serial/src/tusb_config.h | 4 ++-- examples/device/webusb_serial/src/usb_descriptors.c | 2 +- src/device/usbd_control.c | 2 +- src/portable/nxp/lpc17_40/dcd_lpc17_40.c | 4 ++-- src/portable/nxp/lpc18_43/dcd_lpc18_43.c | 2 +- 20 files changed, 28 insertions(+), 28 deletions(-) diff --git a/examples/device/board_test/src/tusb_config.h b/examples/device/board_test/src/tusb_config.h index 5c3cac83a..2f2a4deeb 100644 --- a/examples/device/board_test/src/tusb_config.h +++ b/examples/device/board_test/src/tusb_config.h @@ -64,7 +64,7 @@ // DEVICE CONFIGURATION //-------------------------------------------------------------------- -#define CFG_TUD_ENDOINT0_SIZE 64 +#define CFG_TUD_ENDPOINT0_SIZE 64 //------------- CLASS -------------// #define CFG_TUD_CDC 0 diff --git a/examples/device/cdc_msc/src/tusb_config.h b/examples/device/cdc_msc/src/tusb_config.h index e307870ed..4455f665e 100644 --- a/examples/device/cdc_msc/src/tusb_config.h +++ b/examples/device/cdc_msc/src/tusb_config.h @@ -68,8 +68,8 @@ //-------------------------------------------------------------------- // DEVICE CONFIGURATION //-------------------------------------------------------------------- -#ifndef CFG_TUD_ENDOINT0_SIZE -#define CFG_TUD_ENDOINT0_SIZE 64 +#ifndef CFG_TUD_ENDPOINT0_SIZE +#define CFG_TUD_ENDPOINT0_SIZE 64 #endif //------------- CLASS -------------// diff --git a/examples/device/cdc_msc/src/usb_descriptors.c b/examples/device/cdc_msc/src/usb_descriptors.c index ac8214e37..11d07e9ba 100644 --- a/examples/device/cdc_msc/src/usb_descriptors.c +++ b/examples/device/cdc_msc/src/usb_descriptors.c @@ -50,7 +50,7 @@ tusb_desc_device_t const desc_device = .bDeviceSubClass = MISC_SUBCLASS_COMMON, .bDeviceProtocol = MISC_PROTOCOL_IAD, - .bMaxPacketSize0 = CFG_TUD_ENDOINT0_SIZE, + .bMaxPacketSize0 = CFG_TUD_ENDPOINT0_SIZE, .idVendor = 0xCafe, .idProduct = USB_PID, diff --git a/examples/device/cdc_msc_hid_freertos/src/tusb_config.h b/examples/device/cdc_msc_hid_freertos/src/tusb_config.h index 7869e24cc..f84874ab1 100644 --- a/examples/device/cdc_msc_hid_freertos/src/tusb_config.h +++ b/examples/device/cdc_msc_hid_freertos/src/tusb_config.h @@ -69,8 +69,8 @@ // DEVICE CONFIGURATION //-------------------------------------------------------------------- -#ifndef CFG_TUD_ENDOINT0_SIZE -#define CFG_TUD_ENDOINT0_SIZE 64 +#ifndef CFG_TUD_ENDPOINT0_SIZE +#define CFG_TUD_ENDPOINT0_SIZE 64 #endif //------------- CLASS -------------// diff --git a/examples/device/cdc_msc_hid_freertos/src/usb_descriptors.c b/examples/device/cdc_msc_hid_freertos/src/usb_descriptors.c index 5d93cc2f6..d60c9a585 100644 --- a/examples/device/cdc_msc_hid_freertos/src/usb_descriptors.c +++ b/examples/device/cdc_msc_hid_freertos/src/usb_descriptors.c @@ -57,7 +57,7 @@ tusb_desc_device_t const desc_device = .bDeviceProtocol = 0x00, #endif - .bMaxPacketSize0 = CFG_TUD_ENDOINT0_SIZE, + .bMaxPacketSize0 = CFG_TUD_ENDPOINT0_SIZE, .idVendor = 0xCafe, .idProduct = USB_PID, diff --git a/examples/device/hid_composite/src/tusb_config.h b/examples/device/hid_composite/src/tusb_config.h index 13ecfa415..8d29f10be 100644 --- a/examples/device/hid_composite/src/tusb_config.h +++ b/examples/device/hid_composite/src/tusb_config.h @@ -69,8 +69,8 @@ // DEVICE CONFIGURATION //-------------------------------------------------------------------- -#ifndef CFG_TUD_ENDOINT0_SIZE -#define CFG_TUD_ENDOINT0_SIZE 64 +#ifndef CFG_TUD_ENDPOINT0_SIZE +#define CFG_TUD_ENDPOINT0_SIZE 64 #endif //------------- CLASS -------------// diff --git a/examples/device/hid_composite/src/usb_descriptors.c b/examples/device/hid_composite/src/usb_descriptors.c index 678b7528b..01f2cb59b 100644 --- a/examples/device/hid_composite/src/usb_descriptors.c +++ b/examples/device/hid_composite/src/usb_descriptors.c @@ -47,7 +47,7 @@ tusb_desc_device_t const desc_device = .bDeviceClass = 0x00, .bDeviceSubClass = 0x00, .bDeviceProtocol = 0x00, - .bMaxPacketSize0 = CFG_TUD_ENDOINT0_SIZE, + .bMaxPacketSize0 = CFG_TUD_ENDPOINT0_SIZE, .idVendor = 0xCafe, .idProduct = USB_PID, diff --git a/examples/device/hid_generic_inout/src/tusb_config.h b/examples/device/hid_generic_inout/src/tusb_config.h index c82588c2f..a7ce7acf8 100644 --- a/examples/device/hid_generic_inout/src/tusb_config.h +++ b/examples/device/hid_generic_inout/src/tusb_config.h @@ -69,8 +69,8 @@ // DEVICE CONFIGURATION //-------------------------------------------------------------------- -#ifndef CFG_TUD_ENDOINT0_SIZE -#define CFG_TUD_ENDOINT0_SIZE 64 +#ifndef CFG_TUD_ENDPOINT0_SIZE +#define CFG_TUD_ENDPOINT0_SIZE 64 #endif //------------- CLASS -------------// diff --git a/examples/device/hid_generic_inout/src/usb_descriptors.c b/examples/device/hid_generic_inout/src/usb_descriptors.c index d0fc6b1bc..07989c5fd 100644 --- a/examples/device/hid_generic_inout/src/usb_descriptors.c +++ b/examples/device/hid_generic_inout/src/usb_descriptors.c @@ -46,7 +46,7 @@ tusb_desc_device_t const desc_device = .bDeviceClass = 0x00, .bDeviceSubClass = 0x00, .bDeviceProtocol = 0x00, - .bMaxPacketSize0 = CFG_TUD_ENDOINT0_SIZE, + .bMaxPacketSize0 = CFG_TUD_ENDPOINT0_SIZE, .idVendor = 0xCafe, .idProduct = USB_PID, diff --git a/examples/device/midi_test/src/tusb_config.h b/examples/device/midi_test/src/tusb_config.h index 4a84812c5..fcd6b97c2 100644 --- a/examples/device/midi_test/src/tusb_config.h +++ b/examples/device/midi_test/src/tusb_config.h @@ -69,8 +69,8 @@ // DEVICE CONFIGURATION //-------------------------------------------------------------------- -#ifndef CFG_TUD_ENDOINT0_SIZE -#define CFG_TUD_ENDOINT0_SIZE 64 +#ifndef CFG_TUD_ENDPOINT0_SIZE +#define CFG_TUD_ENDPOINT0_SIZE 64 #endif //------------- CLASS -------------// diff --git a/examples/device/midi_test/src/usb_descriptors.c b/examples/device/midi_test/src/usb_descriptors.c index 7cebc6a15..2305c9f68 100644 --- a/examples/device/midi_test/src/usb_descriptors.c +++ b/examples/device/midi_test/src/usb_descriptors.c @@ -46,7 +46,7 @@ tusb_desc_device_t const desc_device = .bDeviceClass = 0x00, .bDeviceSubClass = 0x00, .bDeviceProtocol = 0x00, - .bMaxPacketSize0 = CFG_TUD_ENDOINT0_SIZE, + .bMaxPacketSize0 = CFG_TUD_ENDPOINT0_SIZE, .idVendor = 0xCafe, .idProduct = USB_PID, diff --git a/examples/device/msc_dual_lun/src/tusb_config.h b/examples/device/msc_dual_lun/src/tusb_config.h index 073e2379f..b45e9c4dc 100644 --- a/examples/device/msc_dual_lun/src/tusb_config.h +++ b/examples/device/msc_dual_lun/src/tusb_config.h @@ -69,8 +69,8 @@ // DEVICE CONFIGURATION //-------------------------------------------------------------------- -#ifndef CFG_TUD_ENDOINT0_SIZE -#define CFG_TUD_ENDOINT0_SIZE 64 +#ifndef CFG_TUD_ENDPOINT0_SIZE +#define CFG_TUD_ENDPOINT0_SIZE 64 #endif //------------- CLASS -------------// diff --git a/examples/device/msc_dual_lun/src/usb_descriptors.c b/examples/device/msc_dual_lun/src/usb_descriptors.c index cab37cf1f..e0a5904a4 100644 --- a/examples/device/msc_dual_lun/src/usb_descriptors.c +++ b/examples/device/msc_dual_lun/src/usb_descriptors.c @@ -46,7 +46,7 @@ tusb_desc_device_t const desc_device = .bDeviceClass = 0x00, .bDeviceSubClass = 0x00, .bDeviceProtocol = 0x00, - .bMaxPacketSize0 = CFG_TUD_ENDOINT0_SIZE, + .bMaxPacketSize0 = CFG_TUD_ENDPOINT0_SIZE, .idVendor = 0xCafe, .idProduct = USB_PID, diff --git a/examples/device/usbtmc/src/tusb_config.h b/examples/device/usbtmc/src/tusb_config.h index c20b05fbb..9141e6a5a 100644 --- a/examples/device/usbtmc/src/tusb_config.h +++ b/examples/device/usbtmc/src/tusb_config.h @@ -51,7 +51,7 @@ // DEVICE CONFIGURATION //-------------------------------------------------------------------- -#define CFG_TUD_ENDOINT0_SIZE 64 +#define CFG_TUD_ENDPOINT0_SIZE 64 //------------- CLASS -------------// diff --git a/examples/device/usbtmc/src/usb_descriptors.c b/examples/device/usbtmc/src/usb_descriptors.c index 1175ebb99..27e1bdaa9 100644 --- a/examples/device/usbtmc/src/usb_descriptors.c +++ b/examples/device/usbtmc/src/usb_descriptors.c @@ -58,7 +58,7 @@ tusb_desc_device_t const desc_device = .bDeviceProtocol = 0x00, #endif - .bMaxPacketSize0 = CFG_TUD_ENDOINT0_SIZE, + .bMaxPacketSize0 = CFG_TUD_ENDPOINT0_SIZE, .idVendor = 0xCafe, .idProduct = USB_PID, diff --git a/examples/device/webusb_serial/src/tusb_config.h b/examples/device/webusb_serial/src/tusb_config.h index b2f09cac0..8a73e8353 100644 --- a/examples/device/webusb_serial/src/tusb_config.h +++ b/examples/device/webusb_serial/src/tusb_config.h @@ -69,8 +69,8 @@ // DEVICE CONFIGURATION //-------------------------------------------------------------------- -#ifndef CFG_TUD_ENDOINT0_SIZE -#define CFG_TUD_ENDOINT0_SIZE 64 +#ifndef CFG_TUD_ENDPOINT0_SIZE +#define CFG_TUD_ENDPOINT0_SIZE 64 #endif //------------- CLASS -------------// diff --git a/examples/device/webusb_serial/src/usb_descriptors.c b/examples/device/webusb_serial/src/usb_descriptors.c index a1d5cd9b9..740defe4e 100644 --- a/examples/device/webusb_serial/src/usb_descriptors.c +++ b/examples/device/webusb_serial/src/usb_descriptors.c @@ -50,7 +50,7 @@ tusb_desc_device_t const desc_device = .bDeviceClass = TUSB_CLASS_MISC, .bDeviceSubClass = MISC_SUBCLASS_COMMON, .bDeviceProtocol = MISC_PROTOCOL_IAD, - .bMaxPacketSize0 = CFG_TUD_ENDOINT0_SIZE, + .bMaxPacketSize0 = CFG_TUD_ENDPOINT0_SIZE, .idVendor = 0xCafe, .idProduct = USB_PID, diff --git a/src/device/usbd_control.c b/src/device/usbd_control.c index eecc95edb..f5c442b74 100644 --- a/src/device/usbd_control.c +++ b/src/device/usbd_control.c @@ -124,7 +124,7 @@ bool usbd_control_xfer_cb (uint8_t rhport, uint8_t ep_addr, xfer_result_t result _control_state.total_transferred += xferred_bytes; _control_state.buffer = ((uint8_t*)_control_state.buffer) + xferred_bytes; - if ( _control_state.total_len == _control_state.total_transferred || xferred_bytes < CFG_TUD_ENDOINT0_SIZE ) + if ( _control_state.total_len == _control_state.total_transferred || xferred_bytes < CFG_TUD_ENDPOINT0_SIZE ) { // DATA stage is complete bool is_ok = true; diff --git a/src/portable/nxp/lpc17_40/dcd_lpc17_40.c b/src/portable/nxp/lpc17_40/dcd_lpc17_40.c index d5f90d2a7..8c439616a 100644 --- a/src/portable/nxp/lpc17_40/dcd_lpc17_40.c +++ b/src/portable/nxp/lpc17_40/dcd_lpc17_40.c @@ -172,8 +172,8 @@ void dcd_init(uint8_t rhport) //------------- user manual 11.13 usb device controller initialization -------------// // step 6 : set up control endpoint - set_ep_size(0, CFG_TUD_ENDOINT0_SIZE); - set_ep_size(1, CFG_TUD_ENDOINT0_SIZE); + set_ep_size(0, CFG_TUD_ENDPOINT0_SIZE); + set_ep_size(1, CFG_TUD_ENDPOINT0_SIZE); bus_reset(); diff --git a/src/portable/nxp/lpc18_43/dcd_lpc18_43.c b/src/portable/nxp/lpc18_43/dcd_lpc18_43.c index 519e0dcc6..3619a7c2b 100644 --- a/src/portable/nxp/lpc18_43/dcd_lpc18_43.c +++ b/src/portable/nxp/lpc18_43/dcd_lpc18_43.c @@ -115,7 +115,7 @@ static void bus_reset(uint8_t rhport) //------------- Set up Control Endpoints (0 OUT, 1 IN) -------------// p_dcd->qhd[0].zero_length_termination = p_dcd->qhd[1].zero_length_termination = 1; - p_dcd->qhd[0].max_package_size = p_dcd->qhd[1].max_package_size = CFG_TUD_ENDOINT0_SIZE; + p_dcd->qhd[0].max_package_size = p_dcd->qhd[1].max_package_size = CFG_TUD_ENDPOINT0_SIZE; p_dcd->qhd[0].qtd_overlay.next = p_dcd->qhd[1].qtd_overlay.next = QTD_NEXT_INVALID; p_dcd->qhd[0].int_on_setup = 1; // OUT only From 12609f818b59756f70c0059275a0de391c85ee3a Mon Sep 17 00:00:00 2001 From: hathach Date: Tue, 1 Oct 2019 14:43:34 +0700 Subject: [PATCH 3/5] fix #161 added volatile for ep_busy_map/ep_stall_map --- src/device/usbd.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/device/usbd.c b/src/device/usbd.c index 3700fb988..7f819d8f9 100644 --- a/src/device/usbd.c +++ b/src/device/usbd.c @@ -52,14 +52,14 @@ typedef struct { uint8_t self_powered : 1; // configuration descriptor's attribute }; - uint8_t ep_busy_map[2]; // bit mask for busy endpoint - uint8_t ep_stall_map[2]; // bit map for stalled endpoint + volatile uint8_t ep_busy_map[2]; // bit mask for busy endpoint + volatile uint8_t ep_stall_map[2]; // bit map for stalled endpoint uint8_t itf2drv[16]; // map interface number to driver (0xff is invalid) uint8_t ep2drv[8][2]; // map endpoint to driver ( 0xff is invalid ) }usbd_device_t; -static usbd_device_t _usbd_dev = { 0 }; +static usbd_device_t _usbd_dev; // Invalid driver ID in itf2drv[] ep2drv[][] mapping enum { DRVID_INVALID = 0xFFu }; From 6479ee53d5ecaf2b47b59979239ac31868779c05 Mon Sep 17 00:00:00 2001 From: hathach Date: Tue, 1 Oct 2019 15:43:28 +0700 Subject: [PATCH 4/5] -Wno-error=cast-function-type is only available for gcc 8+, change travis dist to bionic --- .travis.yml | 2 +- hw/bsp/circuitplayground_bluefruit/board.mk | 3 +++ hw/bsp/feather_nrf52840_express/board.mk | 3 +++ hw/bsp/pca10056/board.mk | 3 +++ hw/bsp/pca10059/board.mk | 3 +++ 5 files changed, 13 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index f2f2ba51d..6dfc507fc 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,5 @@ language: c -dist: xenial +dist: bionic compiler: - gcc diff --git a/hw/bsp/circuitplayground_bluefruit/board.mk b/hw/bsp/circuitplayground_bluefruit/board.mk index c1513fe7c..72b9ddfbe 100644 --- a/hw/bsp/circuitplayground_bluefruit/board.mk +++ b/hw/bsp/circuitplayground_bluefruit/board.mk @@ -12,7 +12,10 @@ CFLAGS += \ CFLAGS += -Wno-error=undef -Wno-error=unused-parameter # due to tusb_hal_nrf_power_event +GCCVERSION = $(firstword $(subst ., ,$(shell arm-none-eabi-gcc -dumpversion))) +ifeq ($(shell expr $(GCCVERSION) \>= 8), 1) CFLAGS += -Wno-error=cast-function-type +endif # All source paths should be relative to the top level. LD_FILE = hw/bsp/circuitplayground_bluefruit/nrf52840_s140_v6.ld diff --git a/hw/bsp/feather_nrf52840_express/board.mk b/hw/bsp/feather_nrf52840_express/board.mk index 1900bedbb..1e077bac7 100644 --- a/hw/bsp/feather_nrf52840_express/board.mk +++ b/hw/bsp/feather_nrf52840_express/board.mk @@ -12,7 +12,10 @@ CFLAGS += \ CFLAGS += -Wno-error=undef -Wno-error=unused-parameter # due to tusb_hal_nrf_power_event +GCCVERSION = $(firstword $(subst ., ,$(shell arm-none-eabi-gcc -dumpversion))) +ifeq ($(shell expr $(GCCVERSION) \>= 8), 1) CFLAGS += -Wno-error=cast-function-type +endif # All source paths should be relative to the top level. LD_FILE = hw/bsp/feather_nrf52840_express/nrf52840_s140_v6.ld diff --git a/hw/bsp/pca10056/board.mk b/hw/bsp/pca10056/board.mk index dc2c434f4..c0616abee 100644 --- a/hw/bsp/pca10056/board.mk +++ b/hw/bsp/pca10056/board.mk @@ -12,7 +12,10 @@ CFLAGS += \ CFLAGS += -Wno-error=undef -Wno-error=unused-parameter # due to tusb_hal_nrf_power_event +GCCVERSION = $(firstword $(subst ., ,$(shell arm-none-eabi-gcc -dumpversion))) +ifeq ($(shell expr $(GCCVERSION) \>= 8), 1) CFLAGS += -Wno-error=cast-function-type +endif # All source paths should be relative to the top level. LD_FILE = hw/mcu/nordic/nrfx/mdk/nrf52840_xxaa.ld diff --git a/hw/bsp/pca10059/board.mk b/hw/bsp/pca10059/board.mk index 0ef56ed50..15801054c 100644 --- a/hw/bsp/pca10059/board.mk +++ b/hw/bsp/pca10059/board.mk @@ -12,7 +12,10 @@ CFLAGS += \ CFLAGS += -Wno-error=undef -Wno-error=unused-parameter # due to tusb_hal_nrf_power_event +GCCVERSION = $(firstword $(subst ., ,$(shell arm-none-eabi-gcc -dumpversion))) +ifeq ($(shell expr $(GCCVERSION) \>= 8), 1) CFLAGS += -Wno-error=cast-function-type +endif # All source paths should be relative to the top level. LD_FILE = hw/bsp/$(BOARD)/$(BOARD).ld From 204791b3e787ed75b0f9d722392a601458417ceb Mon Sep 17 00:00:00 2001 From: hathach Date: Tue, 1 Oct 2019 22:19:04 +0700 Subject: [PATCH 5/5] 2nd attempt to fix #161 --- src/class/hid/hid_device.c | 2 +- src/device/usbd.c | 29 ++++++++++++++++------------- src/device/usbd_pvt.h | 11 +++++++++++ 3 files changed, 28 insertions(+), 14 deletions(-) diff --git a/src/class/hid/hid_device.c b/src/class/hid/hid_device.c index b57d6219f..40ec52886 100644 --- a/src/class/hid/hid_device.c +++ b/src/class/hid/hid_device.c @@ -74,7 +74,7 @@ bool tud_hid_ready(void) { uint8_t itf = 0; uint8_t const ep_in = _hidd_itf[itf].ep_in; - return tud_ready() && (ep_in != 0) && !usbd_edpt_busy(TUD_OPT_RHPORT, ep_in); + return tud_ready() && (ep_in != 0) && usbd_edpt_ready(TUD_OPT_RHPORT, ep_in); } bool tud_hid_report(uint8_t report_id, void const* report, uint8_t len) diff --git a/src/device/usbd.c b/src/device/usbd.c index 7f819d8f9..14e56a9b7 100644 --- a/src/device/usbd.c +++ b/src/device/usbd.c @@ -52,11 +52,16 @@ typedef struct { uint8_t self_powered : 1; // configuration descriptor's attribute }; - volatile uint8_t ep_busy_map[2]; // bit mask for busy endpoint - volatile uint8_t ep_stall_map[2]; // bit map for stalled endpoint - uint8_t itf2drv[16]; // map interface number to driver (0xff is invalid) uint8_t ep2drv[8][2]; // map endpoint to driver ( 0xff is invalid ) + + struct TU_ATTR_PACKED + { + volatile bool busy : 1; + volatile bool stalled : 1; + + // TODO merge ep2drv here, 4-bit should be sufficient + }ep_status[8][2]; }usbd_device_t; static usbd_device_t _usbd_dev; @@ -310,7 +315,7 @@ void tud_task (void) uint8_t const epnum = tu_edpt_number(ep_addr); uint8_t const ep_dir = tu_edpt_dir(ep_addr); - _usbd_dev.ep_busy_map[ep_dir] = (uint8_t) tu_bit_clear(_usbd_dev.ep_busy_map[ep_dir], epnum); + _usbd_dev.ep_status[epnum][ep_dir].busy = false; if ( 0 == epnum ) { @@ -864,8 +869,7 @@ bool usbd_edpt_xfer(uint8_t rhport, uint8_t ep_addr, uint8_t * buffer, uint16_t uint8_t const dir = tu_edpt_dir(ep_addr); TU_VERIFY( dcd_edpt_xfer(rhport, ep_addr, buffer, total_bytes) ); - - _usbd_dev.ep_busy_map[dir] = (uint8_t) tu_bit_set(_usbd_dev.ep_busy_map[dir], epnum); + _usbd_dev.ep_status[epnum][dir].busy = true; return true; } @@ -877,18 +881,17 @@ bool usbd_edpt_busy(uint8_t rhport, uint8_t ep_addr) uint8_t const epnum = tu_edpt_number(ep_addr); uint8_t const dir = tu_edpt_dir(ep_addr); - return tu_bit_test(_usbd_dev.ep_busy_map[dir], epnum); + return _usbd_dev.ep_status[epnum][dir].busy; } - void usbd_edpt_stall(uint8_t rhport, uint8_t ep_addr) { uint8_t const epnum = tu_edpt_number(ep_addr); uint8_t const dir = tu_edpt_dir(ep_addr); dcd_edpt_stall(rhport, ep_addr); - _usbd_dev.ep_stall_map[dir] = (uint8_t) tu_bit_set(_usbd_dev.ep_stall_map[dir], epnum); - _usbd_dev.ep_busy_map[dir] = (uint8_t) tu_bit_set(_usbd_dev.ep_busy_map[dir], epnum); + _usbd_dev.ep_status[epnum][dir].stalled = true; + _usbd_dev.ep_status[epnum][dir].busy = true; } void usbd_edpt_clear_stall(uint8_t rhport, uint8_t ep_addr) @@ -897,8 +900,8 @@ void usbd_edpt_clear_stall(uint8_t rhport, uint8_t ep_addr) uint8_t const dir = tu_edpt_dir(ep_addr); dcd_edpt_clear_stall(rhport, ep_addr); - _usbd_dev.ep_busy_map[dir] = (uint8_t) tu_bit_clear(_usbd_dev.ep_busy_map[dir], epnum); - _usbd_dev.ep_stall_map[dir] = (uint8_t) tu_bit_clear(_usbd_dev.ep_stall_map[dir], epnum); + _usbd_dev.ep_status[epnum][dir].stalled = false; + _usbd_dev.ep_status[epnum][dir].busy = false; } bool usbd_edpt_stalled(uint8_t rhport, uint8_t ep_addr) @@ -908,7 +911,7 @@ bool usbd_edpt_stalled(uint8_t rhport, uint8_t ep_addr) uint8_t const epnum = tu_edpt_number(ep_addr); uint8_t const dir = tu_edpt_dir(ep_addr); - return tu_bit_test(_usbd_dev.ep_stall_map[dir], epnum); + return _usbd_dev.ep_status[epnum][dir].stalled; } #endif diff --git a/src/device/usbd_pvt.h b/src/device/usbd_pvt.h index fbf030ce3..892680142 100644 --- a/src/device/usbd_pvt.h +++ b/src/device/usbd_pvt.h @@ -47,10 +47,21 @@ bool usbd_edpt_xfer(uint8_t rhport, uint8_t ep_addr, uint8_t * buffer, uint16_t // Check if endpoint transferring is complete bool usbd_edpt_busy(uint8_t rhport, uint8_t ep_addr); +// Stall endpoint void usbd_edpt_stall(uint8_t rhport, uint8_t ep_addr); + +// Clear stalled endpoint void usbd_edpt_clear_stall(uint8_t rhport, uint8_t ep_addr); + +// Check if endpoint is stalled bool usbd_edpt_stalled(uint8_t rhport, uint8_t ep_addr); +static inline +bool usbd_edpt_ready(uint8_t rhport, uint8_t ep_addr) +{ + return !usbd_edpt_busy(rhport, ep_addr) && !usbd_edpt_stalled(rhport, ep_addr); +} + /*------------------------------------------------------------------*/ /* Helper *------------------------------------------------------------------*/