From d7399679ded88a2f8b64f69f487bc52d648ca6fd Mon Sep 17 00:00:00 2001 From: Thomas Roberts Date: Thu, 14 May 2020 14:56:26 +0100 Subject: [PATCH] stm32: Add support for F412 MCUs. --- ports/stm32/adc.c | 8 +- ports/stm32/boards/stm32f412_af.csv | 116 ++++++++++++++++++++++++++++ ports/stm32/boards/stm32f412zx.ld | 28 +++++++ ports/stm32/flashbdev.c | 2 +- ports/stm32/modmachine.c | 2 +- ports/stm32/timer.c | 4 + 6 files changed, 154 insertions(+), 6 deletions(-) create mode 100644 ports/stm32/boards/stm32f412_af.csv create mode 100644 ports/stm32/boards/stm32f412zx.ld diff --git a/ports/stm32/adc.c b/ports/stm32/adc.c index 937b6470bc..bdd4ec1aeb 100644 --- a/ports/stm32/adc.c +++ b/ports/stm32/adc.c @@ -132,10 +132,10 @@ defined(STM32F407xx) || defined(STM32F417xx) || \ defined(STM32F401xC) || defined(STM32F401xE) #define VBAT_DIV (2) -#elif defined(STM32F411xE) || defined(STM32F413xx) || \ - defined(STM32F427xx) || defined(STM32F429xx) || \ - defined(STM32F437xx) || defined(STM32F439xx) || \ - defined(STM32F446xx) +#elif defined(STM32F411xE) || defined(STM32F412Zx) || \ + defined(STM32F413xx) || defined(STM32F427xx) || \ + defined(STM32F429xx) || defined(STM32F437xx) || \ + defined(STM32F439xx) || defined(STM32F446xx) #define VBAT_DIV (4) #elif defined(STM32F722xx) || defined(STM32F723xx) || \ defined(STM32F732xx) || defined(STM32F733xx) || \ diff --git a/ports/stm32/boards/stm32f412_af.csv b/ports/stm32/boards/stm32f412_af.csv new file mode 100644 index 0000000000..90eb3d1df6 --- /dev/null +++ b/ports/stm32/boards/stm32f412_af.csv @@ -0,0 +1,116 @@ +Port,,AF0,AF1,AF2,AF3,AF4,AF5,AF6,AF7,AF8,AF9,AF10,AF11,AF12,AF13,AF14,AF15, +,,SYS_AF,TIM1/TIM2,TIM3/TIM4/TIM5,TIM8/9/10/11,I2C1/2/3/I2CFMP1,SPI1/2/3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SDIO_CK,,,EVENTOUT, +PortC,PC13,,,,,,,,,,,,,,,,EVENTOUT, +PortC,PC14,,,,,,,,,,,,,,,,EVENTOUT, +PortC,PC15,,,,,,,,,,,,,,,,EVENTOUT, +PortD,PD0,,,,,,,,,,CAN1_RX,,,FSMC_D2/FSMC_DA2,,,EVENTOUT, +PortD,PD1,,,,,,,,,,CAN1_TX,,,FSMC_D3/FSMC_DA3,,,EVENTOUT, +PortD,PD2,,,TIM3_ETR,,,,,,,,FSMC_NWE,,SDIO_CMD,,,EVENTOUT, +PortD,PD3,TRACED1,,,,,SPI2_SCK/I2S2_CK,DFSDM1_DATIN0,USART2_CTS,,QUADSPI_CLK,,,FSMC_CLK,,,EVENTOUT, +PortD,PD4,,,,,,,DFSDM1_CKIN0,USART2_RTS,,,,,FSMC_NOE,,,EVENTOUT, +PortD,PD5,,,,,,,,USART2_TX,,,,,FSMC_NWE,,,EVENTOUT, +PortD,PD6,,,,,,SPI3_MOSI/I2S3_SD,DFSDM1_DATIN1,USART2_RX,,,,,FSMC_NWAIT,,,EVENTOUT, +PortD,PD7,,,,,,,DFSDM1_CKIN1,USART2_CK,,,,,FSMC_NE1,,,EVENTOUT, +PortD,PD8,,,,,,,,USART3_TX,,,,,FSMC_D13/FSMC_DA13,,,EVENTOUT, +PortD,PD9,,,,,,,,USART3_RX,,,,,FSMC_D14/FSMC_DA14,,,EVENTOUT, +PortD,PD10,,,,,,,,USART3_CK,,,,,FSMC_D15/FSMC_DA15,,,EVENTOUT, +PortD,PD11,,,,,I2CFMP1_SMBA,,,USART3_CTS,,QUADSPI_BK1_IO0,,,FSMC_A16,,,EVENTOUT, +PortD,PD12,,,TIM4_CH1,,I2CFMP1_SCL,,,USART3_RTS,,QUADSPI_BK1_IO1,,,FSMC_A17,,,EVENTOUT, +PortD,PD13,,,TIM4_CH2,,I2CFMP1_SDA,,,,,QUADSPI_BK1_IO3,,,FSMC_A18,,,EVENTOUT, +PortD,PD14,,,TIM4_CH3,,I2CFMP1_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P1_SMBA,,,,,,,,FSMC_A7,,,EVENTOUT, +PortF,PF14,,,,,I2CFMP1_SCL,,,,,,,,FSMC_A8,,,EVENTOUT, +PortF,PF15,,,,,I2CFMP1_SDA,,,,,,,,FSMC_A9,,,EVENTOUT, +PortG,PG0,,,,,,,,,,CAN1_RX,,,FSMC_A10,,,EVENTOUT, +PortG,PG1,,,,,,,,,,CAN1_TX,,,FSMC_A11,,,EVENTOUT, +PortG,PG2,,,,,,,,,,,,,FSMC_A12,,,EVENTOUT, +PortG,PG3,,,,,,,,,,,,,FSMC_A13,,,EVENTOUT, +PortG,PG4,,,,,,,,,,,,,FSMC_A14,,,EVENTOUT, +PortG,PG5,,,,,,,,,,,,,FSMC_A15,,,EVENTOUT, +PortG,PG6,,,,,,,,,,,QUADSPI_BK1_NCS,,,,,EVENTOUT, +PortG,PG7,,,,,,,,,USART6_CK,,,,,,,EVENTOUT, +PortG,PG8,,,,,,,,,USART6_RTS,,,,,,,EVENTOUT, +PortG,PG9,,,,,,,,,USART6_RX,QUADSPI_BK2_IO2,,,FSMC_NE2,,,EVENTOUT, +PortG,PG10,,,,,,,,,,,,,FSMC_NE3,,,EVENTOUT, +PortG,PG11,,,,,,,,,,CAN2_RX,,,,,,EVENTOUT, +PortG,PG12,,,,,,,,,USART6_RTS,CAN2_TX,,,FSMC_NE4,,,EVENTOUT, +PortG,PG13,TRACED2,,,,,,,,USART6_CTS,,,,FSMC_A24,,,EVENTOUT, +PortG,PG14,TRACED3,,,,,,,,USART6_TX,QUADSPI_BK2_IO3,,,FSMC_A25,,,EVENTOUT, +PortG,PG15,,,,,,,,,USART6_CTS,,,,,,,EVENTOUT, +PortH,PH0,,,,,,,,,,,,,,,,EVENTOUT, +PortH,PH1,,,,,,,,,,,,,,,,EVENTOUT, diff --git a/ports/stm32/boards/stm32f412zx.ld b/ports/stm32/boards/stm32f412zx.ld new file mode 100644 index 0000000000..55aa608657 --- /dev/null +++ b/ports/stm32/boards/stm32f412zx.ld @@ -0,0 +1,28 @@ +/* + GNU linker script for STM32F412zx (1MB flash, 256kB RAM) +*/ + +/* Specify the memory areas */ +MEMORY +{ + FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 1024K /* entire flash */ + FLASH_ISR (rx) : ORIGIN = 0x08000000, LENGTH = 16K /* sector 0 */ + FLASH_FS (rx) : ORIGIN = 0x08004000, LENGTH = 112K /* sectors 1,2,3 are 16K, 4 is 64K */ + FLASH_TEXT (rx) : ORIGIN = 0x08020000, LENGTH = 896K /* sectors 5,6,7,8,9,10,11 are 128K */ + RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 256K +} + +/* produce a link error if there is not this amount of RAM for these sections */ +_minimum_stack_size = 2K; +_minimum_heap_size = 16K; + +/* Define the stack. The stack is full descending so begins just above last byte + of RAM. Note that EABI requires the stack to be 8-byte aligned for a call. */ +_estack = ORIGIN(RAM) + LENGTH(RAM) - _estack_reserve; +_sstack = _estack - 16K; /* tunable */ + +/* RAM extents for the garbage collector */ +_ram_start = ORIGIN(RAM); +_ram_end = ORIGIN(RAM) + LENGTH(RAM); +_heap_start = _ebss; /* heap starts just after statically allocated memory */ +_heap_end = _sstack; diff --git a/ports/stm32/flashbdev.c b/ports/stm32/flashbdev.c index bc3f6b07a5..e105bd3538 100644 --- a/ports/stm32/flashbdev.c +++ b/ports/stm32/flashbdev.c @@ -53,7 +53,7 @@ #define FLASH_MEM_SEG2_NUM_BLOCKS (128) // sector 11: 128k #endif -#elif defined(STM32F401xE) || defined(STM32F411xE) || defined(STM32F446xx) +#elif defined(STM32F401xE) || defined(STM32F411xE) || defined(STM32F412Zx) || defined(STM32F446xx) STATIC byte flash_cache_mem[0x4000] __attribute__((aligned(4))); // 16k #define CACHE_MEM_START_ADDR (&flash_cache_mem[0]) diff --git a/ports/stm32/modmachine.c b/ports/stm32/modmachine.c index 6ea6c9afa3..0795d2ccf0 100644 --- a/ports/stm32/modmachine.c +++ b/ports/stm32/modmachine.c @@ -124,7 +124,7 @@ void machine_init(void) { if (state & RCC_SR_IWDGRSTF || state & RCC_SR_WWDGRSTF) { reset_cause = PYB_RESET_WDT; } else if (state & RCC_SR_PORRSTF - #if !defined(STM32F0) + #if !defined(STM32F0) && !defined(STM32F412Zx) || state & RCC_SR_BORRSTF #endif ) { diff --git a/ports/stm32/timer.c b/ports/stm32/timer.c index 6006a3f666..491221ec2a 100644 --- a/ports/stm32/timer.c +++ b/ports/stm32/timer.c @@ -820,8 +820,12 @@ STATIC const uint32_t tim_instance_table[MICROPY_HW_MAX_TIMER] = { TIM_ENTRY(5, TIM5_IRQn), #endif #if defined(TIM6) + #if defined(STM32F412Zx) + TIM_ENTRY(6, TIM6_IRQn), + #else TIM_ENTRY(6, TIM6_DAC_IRQn), #endif + #endif #if defined(TIM7) TIM_ENTRY(7, TIM7_IRQn), #endif