hathach 6 лет назад
Родитель
Сommit
7b2f8cc73a

+ 0 - 3
examples/device/board_test/Makefile

@@ -5,9 +5,6 @@ INC += \
   src \
   $(TOP)/hw \
 
-# stop on the first build error, which is quite a lot of porting new board
-CFLAGS += -Wfatal-errors
-
 # Example source
 EXAMPLE_SOURCE += $(wildcard src/*.c)
 SRC_C += $(addprefix $(CURRENT_PATH)/, $(EXAMPLE_SOURCE))

+ 1 - 0
examples/make.mk

@@ -58,6 +58,7 @@ CFLAGS += \
 	-Wall \
 	-Werror \
 	-Werror-implicit-function-declaration \
+	-Wfatal-errors \
 	-Wfloat-equal \
 	-Wundef \
 	-Wshadow \

+ 1 - 1
hw/bsp/stm32l0538disco/board.mk

@@ -6,9 +6,9 @@ CFLAGS += \
 	-mcpu=cortex-m0plus \
 	-mfloat-abi=soft \
 	-nostdlib -nostartfiles \
+	-DCFG_EXAMPLE_MSC_READONLY \
 	-DCFG_TUSB_MCU=OPT_MCU_STM32L0
 
-#	-DCFG_EXAMPLE_MSC_READONLY \
 
 ST_HAL_DRIVER = hw/mcu/st/st_driver/STM32L0xx_HAL_Driver
 ST_CMSIS = hw/mcu/st/st_driver/CMSIS/Device/ST/STM32L0xx

+ 20 - 18
src/portable/st/stm32_fsdev/dcd_stm32_fsdev.c

@@ -106,14 +106,17 @@
 
 #include "tusb_option.h"
 
+#define STM32F1_FSDEV   ( \
+    defined(STM32F102x6) || defined(STM32F102xB) || \
+    defined(STM32F103x6) || defined(STM32F103xB) || \
+    defined(STM32F103xE) || defined(STM32F103xG)   \
+)
+
 #if (TUSB_OPT_DEVICE_ENABLED) && ( \
-      ((CFG_TUSB_MCU) == OPT_MCU_STM32F0) || \
-      (((CFG_TUSB_MCU) == OPT_MCU_STM32F1) && ( \
-          defined(stm32f102x6) || defined(stm32f102xb) || \
-          defined(stm32f103x6) || defined(stm32f103xb) || \
-          defined(stm32f103xe) || defined(stm32f103xg) \
-      )) || \
-      ((CFG_TUSB_MCU) == OPT_MCU_STM32F3) \
+      (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                  ) \
     )
 
 // In order to reduce the dependance on HAL, we undefine this.
@@ -165,7 +168,7 @@ typedef struct
 
 static xfer_ctl_t xfer_status[MAX_EP_COUNT][2];
 
-static xfer_ctl_t* xfer_ctl_ptr(uint32_t epnum, uint32_t dir)
+static inline xfer_ctl_t* xfer_ctl_ptr(uint32_t epnum, uint32_t dir)
 {
   return &xfer_status[epnum][dir];
 }
@@ -252,9 +255,10 @@ void dcd_init (uint8_t rhport)
 void dcd_int_enable (uint8_t rhport)
 {
   (void)rhport;
-#if defined(STM32F0)
+
+#if CFG_TUSB_MCU == OPT_MCU_STM32F0 || CFG_TUSB_MCU == OPT_MCU_STM32L0
   NVIC_EnableIRQ(USB_IRQn);
-#elif defined(STM32F3)
+#elif CFG_TUSB_MCU == OPT_MCU_STM32F3
   NVIC_EnableIRQ(USB_HP_CAN_TX_IRQn);
   NVIC_EnableIRQ(USB_LP_CAN_RX0_IRQn);
   NVIC_EnableIRQ(USBWakeUp_IRQn);
@@ -265,14 +269,15 @@ void dcd_int_enable (uint8_t rhport)
 void dcd_int_disable(uint8_t rhport)
 {
   (void)rhport;
-#if defined(STM32F0)
+
+#if CFG_TUSB_MCU == OPT_MCU_STM32F0 || CFG_TUSB_MCU == OPT_MCU_STM32L0
   NVIC_DisableIRQ(USB_IRQn);
-#elif defined(STM32F3)
+#elif CFG_TUSB_MCU == OPT_MCU_STM32F3
   NVIC_DisableIRQ(USB_HP_CAN_TX_IRQn);
   NVIC_DisableIRQ(USB_LP_CAN_RX0_IRQn);
   NVIC_DisableIRQ(USBWakeUp_IRQn);
 #else
-#error Unknown arch in USB driver
+  #error Unknown arch in USB driver
 #endif
   // I'm not convinced that memory synchronization is completely necessary, but
   // it isn't a bad idea.
@@ -305,7 +310,7 @@ void dcd_remote_wakeup(uint8_t rhport)
 {
   (void) rhport;
 
-  USB->CNTR |= (uint16_t)USB_CNTR_RESUME;
+  USB->CNTR |= (uint16_t) USB_CNTR_RESUME;
   remoteWakeCountdown = 4u; // required to be 1 to 15 ms, ESOF should trigger every 1ms.
 }
 
@@ -448,14 +453,11 @@ static uint16_t dcd_ep_ctr_handler(void)
           {
             pcd_set_ep_rx_status(USB, EPindex, USB_EP_RX_VALID);// Await next SETUP
           }
-
         }
-
       }
     }
     else /* Decode and service non control endpoints interrupt  */
     {
-
       /* process related endpoint register */
       wEPVal = pcd_get_endpoint(USB, EPindex);
       if ((wEPVal & USB_EP_CTR_RX) != 0U) // OUT
@@ -809,7 +811,7 @@ static bool dcd_read_packet_memory(void *__restrict dst, uint16_t src, size_t wN
 
 
 // Interrupt handlers
-#if (CFG_TUSB_MCU) == (OPT_MCU_STM32F0)
+#if CFG_TUSB_MCU == OPT_MCU_STM32F0 || CFG_TUSB_MCU == OPT_MCU_STM32L0
 void USB_IRQHandler(void)
 {
   dcd_fs_irqHandler();

+ 42 - 37
src/portable/st/stm32_fsdev/dcd_stm32_fsdev_pvt_st.h

@@ -41,51 +41,56 @@
 #ifndef PORTABLE_ST_STM32F0_DCD_STM32F0_FSDEV_PVT_ST_H_
 #define PORTABLE_ST_STM32F0_DCD_STM32F0_FSDEV_PVT_ST_H_
 
-#if defined(STM32F042x6) | \
-    defined(STM32F070x6) | defined(STM32F070xB) | \
-    defined(STM32F072xB) | \
+#if defined(STM32F042x6) || \
+    defined(STM32F070x6) || defined(STM32F070xB) || \
+    defined(STM32F072xB) || \
     defined(STM32F078xx)
-#include "stm32f0xx.h"
-#define PMA_LENGTH (1024u)
-// F0x2 models are crystal-less
-// All have internal D+ pull-up
-// 070RB:    2 x 16 bits/word memory     LPM Support, BCD Support
-// PMA dedicated to USB (no sharing with CAN)
-#elif defined(STM32F102x6) | defined(STM32F102x6) | \
-      defined(STM32F103x6) | defined(STM32F103xB) | \
-      defined(STM32F103xE) | defined(STM32F103xB)
-#include "stm32f1xx.h"
-#define PMA_LENGTH (512u)
-// NO internal Pull-ups
-//         *B, and *C:    2 x 16 bits/word
-#error The F102/F103 driver is expected not to work, but it might? Try it?
-
-#elif defined(STM32F302xB) | defined(STM32F302xC) | \
-      defined(STM32F303xB) | defined(STM32F303xC) | \
+  #include "stm32f0xx.h"
+  #define PMA_LENGTH (1024u)
+  // F0x2 models are crystal-less
+  // All have internal D+ pull-up
+  // 070RB:    2 x 16 bits/word memory     LPM Support, BCD Support
+  // PMA dedicated to USB (no sharing with CAN)
+
+#elif STM32F1_FSDEV
+  #include "stm32f1xx.h"
+  #define PMA_LENGTH (512u)
+  // NO internal Pull-ups
+  //         *B, and *C:    2 x 16 bits/word
+  #error The F102/F103 driver is expected not to work, but it might? Try it?
+
+#elif defined(STM32F302xB) || defined(STM32F302xC) || \
+      defined(STM32F303xB) || defined(STM32F303xC) || \
       defined(STM32F373xC)
-#include "stm32f3xx.h"
-#define PMA_LENGTH (512u)
-// NO internal Pull-ups
-//         *B, and *C:    1 x 16 bits/word
-// PMA dedicated to USB (no sharing with CAN)
-#elif defined(STM32F302x6) | defined(STM32F302x8) | \
-      defined(STM32F302xD) | defined(STM32F302xE) | \
-      defined(STM32F303xD) | defined(STM32F303xE) | \
-#include "stm32f3xx.h"
-#define PMA_LENGTH (1024u)
-// NO internal Pull-ups
-// *6, *8, *D, and *E:    2 x 16 bits/word     LPM Support
-// When CAN clock is enabled, USB can use first 768 bytes ONLY.
+  #include "stm32f3xx.h"
+  #define PMA_LENGTH (512u)
+  // NO internal Pull-ups
+  //         *B, and *C:    1 x 16 bits/word
+  // PMA dedicated to USB (no sharing with CAN)
+
+#elif defined(STM32F302x6) || defined(STM32F302x8) || \
+      defined(STM32F302xD) || defined(STM32F302xE) || \
+      defined(STM32F303xD) || defined(STM32F303xE)
+  #include "stm32f3xx.h"
+  #define PMA_LENGTH (1024u)
+  // NO internal Pull-ups
+  // *6, *8, *D, and *E:    2 x 16 bits/word     LPM Support
+  // When CAN clock is enabled, USB can use first 768 bytes ONLY.
+
+#elif CFG_TUSB_MCU == OPT_MCU_STM32L0
+  #include "stm32l0xx.h"
+  #define PMA_LENGTH (1024u)
+
 #else
-#error You are using an untested or unimplemented STM32 variant. Please update the driver.
-// This includes L0x2, L0x3, L1x0, L1x1, L1x2, L4x2 and L4x3, G1x1, G1x3, and G1x4
+  #error You are using an untested or unimplemented STM32 variant. Please update the driver.
+  // This includes L1x0, L1x1, L1x2, L4x2 and L4x3, G1x1, G1x3, and G1x4
 #endif
 
 // For purposes of accessing the packet
 #if ((PMA_LENGTH) == 512u)
-#define PMA_STRIDE  (2u)
+  #define PMA_STRIDE  (2u)
 #elif ((PMA_LENGTH) == 1024u)
-#define PMA_STRIDE  (1u)
+  #define PMA_STRIDE  (1u)
 #endif
 
 // And for type-safety create a new macro for the volatile address of PMAADDR