diff options
Diffstat (limited to 'ports/stm32/mpconfigboard_common.h')
| -rw-r--r-- | ports/stm32/mpconfigboard_common.h | 95 | 
1 files changed, 84 insertions, 11 deletions
| diff --git a/ports/stm32/mpconfigboard_common.h b/ports/stm32/mpconfigboard_common.h index d5cef1fec..eefd5c05c 100644 --- a/ports/stm32/mpconfigboard_common.h +++ b/ports/stm32/mpconfigboard_common.h @@ -250,12 +250,50 @@  #error "Old USBD_xxx configuration option used, renamed to MICROPY_HW_USB_xxx"  #endif +// Select whether TinyUSB or legacy STM stack is used to provide USB. +#ifndef MICROPY_HW_TINYUSB_STACK +#define MICROPY_HW_TINYUSB_STACK (0) +#endif + +// Central definition for STM USB stack (when not using TinyUSB) +#define MICROPY_HW_STM_USB_STACK (MICROPY_HW_ENABLE_USB && !MICROPY_HW_TINYUSB_STACK) + +#if MICROPY_HW_TINYUSB_STACK +#ifndef MICROPY_HW_ENABLE_USBDEV +#define MICROPY_HW_ENABLE_USBDEV (1) +#endif + +#ifndef MICROPY_HW_USB_CDC +#define MICROPY_HW_USB_CDC (1) +#endif + +#ifndef MICROPY_HW_ENABLE_USB_RUNTIME_DEVICE +#define MICROPY_HW_ENABLE_USB_RUNTIME_DEVICE    (1) // Support machine.USBDevice +#endif +#endif + +// Configure maximum number of CDC VCP interfaces, and whether MSC/HID are supported +#ifndef MICROPY_HW_USB_CDC_NUM +#define MICROPY_HW_USB_CDC_NUM (1) +#endif +#ifndef MICROPY_HW_USB_MSC +#define MICROPY_HW_USB_MSC (MICROPY_HW_ENABLE_USB) +#endif +#ifndef MICROPY_HW_USB_HID +#define MICROPY_HW_USB_HID (MICROPY_HW_STM_USB_STACK) +#endif +  // Default VID and PID values to use for the USB device.  If MICROPY_HW_USB_VID  // is defined by a board then all needed PID options must also be defined.  The  // VID and PID can also be set dynamically in pyb.usb_mode().  // Windows needs a different PID to distinguish different device configurations.  #ifndef MICROPY_HW_USB_VID  #define MICROPY_HW_USB_VID              (0xf055) + +// USB PID for TinyUSB Stack. +#define MICROPY_HW_USB_PID              (0x9802) + +// USB PID table for STM USB stack.  #define MICROPY_HW_USB_PID_CDC_MSC      (0x9800)  #define MICROPY_HW_USB_PID_CDC_HID      (0x9801)  #define MICROPY_HW_USB_PID_CDC          (0x9802) @@ -369,6 +407,8 @@  #endif  #define MICROPY_HW_MAX_LPUART (0) +#define CFG_TUSB_MCU OPT_MCU_STM32F4 +  // Configuration for STM32F7 series  #elif defined(STM32F7) @@ -384,6 +424,8 @@  #define MICROPY_HW_MAX_UART (8)  #define MICROPY_HW_MAX_LPUART (0) +#define CFG_TUSB_MCU OPT_MCU_STM32F7 +  // Configuration for STM32G0 series  #elif defined(STM32G0) @@ -394,6 +436,8 @@  #define MICROPY_HW_MAX_UART (6)  #define MICROPY_HW_MAX_LPUART (2) +#define CFG_TUSB_MCU OPT_MCU_STM32G0 +  // Configuration for STM32G4 series  #elif defined(STM32G4) @@ -404,6 +448,8 @@  #define MICROPY_HW_MAX_UART (5) // UART1-5 + LPUART1  #define MICROPY_HW_MAX_LPUART (1) +#define CFG_TUSB_MCU OPT_MCU_STM32G4 +  // Configuration for STM32H5 series  #elif defined(STM32H5) @@ -414,6 +460,8 @@  #define MICROPY_HW_MAX_UART (12)  #define MICROPY_HW_MAX_LPUART (1) +#define CFG_TUSB_MCU OPT_MCU_STM32H5 +  // Configuration for STM32H7A3/B3 series  #elif defined(STM32H7A3xx) || defined(STM32H7A3xxQ) || \      defined(STM32H7B3xx) || defined(STM32H7B3xxQ) @@ -425,6 +473,8 @@  #define MICROPY_HW_MAX_UART (10)  #define MICROPY_HW_MAX_LPUART (1) +#define CFG_TUSB_MCU OPT_MCU_STM32H7 +  // Configuration for STM32H7 series  #elif defined(STM32H7) @@ -435,6 +485,8 @@  #define MICROPY_HW_MAX_UART (8)  #define MICROPY_HW_MAX_LPUART (1) +#define CFG_TUSB_MCU OPT_MCU_STM32H7 +  #if defined(MICROPY_HW_ANALOG_SWITCH_PA0) \      || defined(MICROPY_HW_ANALOG_SWITCH_PA1) \      || defined(MICROPY_HW_ANALOG_SWITCH_PC2) \ @@ -454,6 +506,8 @@  #define MICROPY_HW_MAX_UART (5)  #define MICROPY_HW_MAX_LPUART (1) +#define CFG_TUSB_MCU OPT_MCU_STM32L0 +  // Configuration for STM32L1 series  #elif defined(STM32L1)  #define MP_HAL_UNIQUE_ID_ADDRESS (UID_BASE) @@ -464,6 +518,8 @@  #define MICROPY_HW_MAX_UART (5)  #define MICROPY_HW_MAX_LPUART (0) +#define CFG_TUSB_MCU OPT_MCU_STM32L1 +  // Configuration for STM32L4 series  #elif defined(STM32L4) @@ -474,6 +530,8 @@  #define MICROPY_HW_MAX_UART (5)  #define MICROPY_HW_MAX_LPUART (1) +#define CFG_TUSB_MCU OPT_MCU_STM32L4 +  // Configuration for STM32N6 series  #elif defined(STM32N6) @@ -484,6 +542,20 @@  #define MICROPY_HW_MAX_UART (10)  #define MICROPY_HW_MAX_LPUART (1) +// Configuration for STM32U5 series +#elif defined(STM32U5) + +#define MP_HAL_UNIQUE_ID_ADDRESS (UID_BASE) +// STM32U5 has 26 EXTI vectors but does not have line for RTC/USB. +// To treat these interrupts as same as exti, add virtual vectors for +// EXTI_RTC_TIMESTAMP (26), EXTI_RTC_WAKEUP (27), +// EXTI_RTC_ALARM (28), and EXTI_USB_OTG_FS_WAKEUP  (29) +#define PYB_EXTI_NUM_VECTORS (30) +#define MICROPY_HW_MAX_I2C (6) +#define MICROPY_HW_MAX_TIMER (17) +#define MICROPY_HW_MAX_UART (6) +#define MICROPY_HW_MAX_LPUART (1) +  // Configuration for STM32WB series  #elif defined(STM32WB) @@ -494,6 +566,8 @@  #define MICROPY_HW_MAX_UART (1)  #define MICROPY_HW_MAX_LPUART (1) +#define CFG_TUSB_MCU OPT_MCU_STM32WB +  #ifndef MICROPY_HW_STM32WB_FLASH_SYNCRONISATION  #define MICROPY_HW_STM32WB_FLASH_SYNCRONISATION (1)  #endif @@ -577,6 +651,11 @@  #define MICROPY_HW_CLK_AHB_DIV (RCC_SYSCLK_DIV1)  #define MICROPY_HW_CLK_APB1_DIV (RCC_HCLK_DIV1)  #define MICROPY_HW_CLK_APB2_DIV (RCC_HCLK_DIV1) +#elif defined(STM32U5) +#define MICROPY_HW_CLK_AHB_DIV (RCC_SYSCLK_DIV1) +#define MICROPY_HW_CLK_APB1_DIV (RCC_HCLK_DIV1) +#define MICROPY_HW_CLK_APB2_DIV (RCC_HCLK_DIV1) +#define MICROPY_HW_CLK_APB3_DIV (RCC_HCLK_DIV1)  #else  #define MICROPY_HW_CLK_AHB_DIV (RCC_SYSCLK_DIV1)  #define MICROPY_HW_CLK_APB1_DIV (RCC_HCLK_DIV4) @@ -616,8 +695,13 @@  #define MICROPY_HW_BDEV_WRITEBLOCKS(src, bl, n) spi_bdev_writeblocks(MICROPY_HW_BDEV_SPIFLASH, (src), MICROPY_HW_BDEV_SPIFLASH_OFFSET_BLOCKS + (bl), (n))  #endif +// Define the FATFS maximum sector size. +#ifndef MICROPY_FATFS_MAX_SS  #if defined(STM32N6)  #define MICROPY_FATFS_MAX_SS                    (4096) +#else +#define MICROPY_FATFS_MAX_SS                    (512) +#endif  #endif  // Whether to enable caching for external SPI flash, to allow block writes that are @@ -696,17 +780,6 @@  #define MICROPY_HW_USB_IS_MULTI_OTG (1)  #endif -// Configure maximum number of CDC VCP interfaces, and whether MSC/HID are supported -#ifndef MICROPY_HW_USB_CDC_NUM -#define MICROPY_HW_USB_CDC_NUM (1) -#endif -#ifndef MICROPY_HW_USB_MSC -#define MICROPY_HW_USB_MSC (MICROPY_HW_ENABLE_USB) -#endif -#ifndef MICROPY_HW_USB_HID -#define MICROPY_HW_USB_HID (MICROPY_HW_ENABLE_USB) -#endif -  // Pin definition header file  #define MICROPY_PIN_DEFS_PORT_H "pin_defs_stm32.h" | 
