From 06ae818f9360e83284c64614144f1ad00998a739 Mon Sep 17 00:00:00 2001 From: ladyada Date: Thu, 3 Oct 2019 02:54:47 -0400 Subject: [PATCH] stm32/boards: Add new board ADAFRUIT_F405_EXPRESS. --- .../ADAFRUIT_F405_EXPRESS/mpconfigboard.h | 86 +++++++++++++++++++ .../ADAFRUIT_F405_EXPRESS/mpconfigboard.mk | 13 +++ .../boards/ADAFRUIT_F405_EXPRESS/pins.csv | 48 +++++++++++ .../stm32f4xx_hal_conf.h | 19 ++++ 4 files changed, 166 insertions(+) create mode 100644 ports/stm32/boards/ADAFRUIT_F405_EXPRESS/mpconfigboard.h create mode 100644 ports/stm32/boards/ADAFRUIT_F405_EXPRESS/mpconfigboard.mk create mode 100644 ports/stm32/boards/ADAFRUIT_F405_EXPRESS/pins.csv create mode 100644 ports/stm32/boards/ADAFRUIT_F405_EXPRESS/stm32f4xx_hal_conf.h diff --git a/ports/stm32/boards/ADAFRUIT_F405_EXPRESS/mpconfigboard.h b/ports/stm32/boards/ADAFRUIT_F405_EXPRESS/mpconfigboard.h new file mode 100644 index 0000000000..36d1d31315 --- /dev/null +++ b/ports/stm32/boards/ADAFRUIT_F405_EXPRESS/mpconfigboard.h @@ -0,0 +1,86 @@ +#define MICROPY_HW_BOARD_NAME "Adafruit Feather STM32F405" +#define MICROPY_HW_MCU_NAME "STM32F405RG" + +#define MICROPY_HW_HAS_SWITCH (0) +#define MICROPY_HW_HAS_FLASH (1) +#define MICROPY_HW_HAS_MMA7660 (0) +#define MICROPY_HW_HAS_LCD (0) +#define MICROPY_HW_ENABLE_RNG (1) +#define MICROPY_HW_ENABLE_RTC (1) +#define MICROPY_HW_ENABLE_SERVO (1) +#define MICROPY_HW_ENABLE_DAC (1) +#define MICROPY_HW_ENABLE_USB (1) +#define MICROPY_HW_ENABLE_SDCARD (1) + +// HSE is 12MHz +#define MICROPY_HW_CLK_PLLM (12) +#define MICROPY_HW_CLK_PLLN (336) +#define MICROPY_HW_CLK_PLLP (RCC_PLLP_DIV2) +#define MICROPY_HW_CLK_PLLQ (7) +#define MICROPY_HW_CLK_LAST_FREQ (1) + +// The Feather has a 32kHz crystal for the RTC +#define MICROPY_HW_RTC_USE_LSE (1) +#define MICROPY_HW_RTC_USE_US (0) +#define MICROPY_HW_RTC_USE_CALOUT (1) + +// UART config +#define MICROPY_HW_UART3_NAME "UART3" // on RX / TX +#define MICROPY_HW_UART3_TX (pin_B10) // TX +#define MICROPY_HW_UART3_RX (pin_B11) // RX +#define MICROPY_HW_UART3_RTS (pin_B14) // MISO +#define MICROPY_HW_UART3_CTS (pin_B13) // SCK + +#define MICROPY_HW_UART2_NAME "UART2" // on SDA/SCL +#define MICROPY_HW_UART2_TX (pin_B6) // SCL +#define MICROPY_HW_UART2_RX (pin_B7) // SDA + +#define MICROPY_HW_UART6_NAME "UART6" // on D5/D6 +#define MICROPY_HW_UART6_TX (pin_C6) // D6 +#define MICROPY_HW_UART6_RX (pin_C7) // D5 + +// I2C busses +#define MICROPY_HW_I2C1_NAME "I2C1" +#define MICROPY_HW_I2C1_SCL (pin_B6) // SCL +#define MICROPY_HW_I2C1_SDA (pin_B7) // SDA +#define MICROPY_HW_I2C2_NAME "I2C2" +#define MICROPY_HW_I2C2_SCL (pin_B10) // TX +#define MICROPY_HW_I2C2_SDA (pin_B11) // RX + +// SPI busses +#define MICROPY_HW_SPI1_NAME "SPIFLASH" +#define MICROPY_HW_SPI1_NSS (pin_A15) // FLASH CS +#define MICROPY_HW_SPI1_SCK (pin_B3) // FLASH CLK +#define MICROPY_HW_SPI1_MISO (pin_B4) // FLASH MISO +#define MICROPY_HW_SPI1_MOSI (pin_B5) // FLASH MOSI +#define MICROPY_HW_SPI2_NAME "SPI1" +#define MICROPY_HW_SPI2_NSS (pin_B12) // SD DETECT +#define MICROPY_HW_SPI2_SCK (pin_B13) // SCK +#define MICROPY_HW_SPI2_MISO (pin_B14) // MISO +#define MICROPY_HW_SPI2_MOSI (pin_B15) // MOSI + +// CAN busses +#define MICROPY_HW_CAN1_NAME "CAN1" +#define MICROPY_HW_CAN1_TX (pin_B9) // D10 +#define MICROPY_HW_CAN1_RX (pin_B8) // D9 + +// The Feather has 1 LED +#define MICROPY_HW_LED1 (pin_C1) // red +#define MICROPY_HW_LED_ON(pin) (mp_hal_pin_high(pin)) +#define MICROPY_HW_LED_OFF(pin) (mp_hal_pin_low(pin)) + +// SD card detect switch +#define MICROPY_HW_SDCARD_DETECT_PIN (pin_B12) +#define MICROPY_HW_SDCARD_DETECT_PULL (GPIO_PULLUP) +#define MICROPY_HW_SDCARD_DETECT_PRESENT (GPIO_PIN_RESET) + +// USB config +#define MICROPY_HW_USB_FS (1) +#define MICROPY_HW_USB_VBUS_DETECT_PIN (pin_A9) +#define MICROPY_HW_USB_OTG_ID_PIN (pin_A10) + +// Bootloader configuration (only needed if Mboot is used) +#define MBOOT_I2C_PERIPH_ID 1 +#define MBOOT_I2C_SCL (pin_B8) +#define MBOOT_I2C_SDA (pin_B9) +#define MBOOT_I2C_ALTFUNC (4) diff --git a/ports/stm32/boards/ADAFRUIT_F405_EXPRESS/mpconfigboard.mk b/ports/stm32/boards/ADAFRUIT_F405_EXPRESS/mpconfigboard.mk new file mode 100644 index 0000000000..a4430cc1df --- /dev/null +++ b/ports/stm32/boards/ADAFRUIT_F405_EXPRESS/mpconfigboard.mk @@ -0,0 +1,13 @@ +MCU_SERIES = f4 +CMSIS_MCU = STM32F405xx +AF_FILE = boards/stm32f405_af.csv +ifeq ($(USE_MBOOT),1) +# When using Mboot all the text goes together after the filesystem +LD_FILES = boards/stm32f405.ld boards/common_blifs.ld +TEXT0_ADDR = 0x08020000 +else +# When not using Mboot the ISR text goes first, then the rest after the filesystem +LD_FILES = boards/stm32f405.ld boards/common_ifs.ld +TEXT0_ADDR = 0x08000000 +TEXT1_ADDR = 0x08020000 +endif diff --git a/ports/stm32/boards/ADAFRUIT_F405_EXPRESS/pins.csv b/ports/stm32/boards/ADAFRUIT_F405_EXPRESS/pins.csv new file mode 100644 index 0000000000..15e810e1ae --- /dev/null +++ b/ports/stm32/boards/ADAFRUIT_F405_EXPRESS/pins.csv @@ -0,0 +1,48 @@ +POWER,3.3V +GND,GND +USB_ID,PA10 +USB_DM,PA11 +USB_DP,PA12 +SWDIO,PA13 +SWCLK,PA14 +FLASH_CS,PA15 +BATTERY_MONITOR,PA3 +A0,PA4 +A1,PA5 +A2,PA6 +A3,PA7 +USB_VBUS,PA9 +TX,PB10 +D1,PB10 +RX,PB11 +D0,PB11 +SD_DETECT,PB12 +SCK,PB13 +MISO,PB14 +MOSI,PB15 +BOOT1,PB2 +FLASH_SCK,PB3 +FLASH_MISO,PB4 +FLASH_MOSI,PB5 +SCL,PB6 +SDA,PB7 +D9,PB8 +D10,PB9 +D8,PC0 +NEOPIXEL,PC0 +D13,PC1 +SD_D2,PC10 +SD_D3,PC11 +SD_CK,PC12 +D12,PC2 +D11,PC3 +A4,PC4 +A5,PC5 +D6,PC6 +D5,PC7 +SD_D0,PC8 +SD_D1,PC9 +SD_CMD,PD2 +NC_A0,PA0 +NC_A1,PA1 +NC_A2,PA2 diff --git a/ports/stm32/boards/ADAFRUIT_F405_EXPRESS/stm32f4xx_hal_conf.h b/ports/stm32/boards/ADAFRUIT_F405_EXPRESS/stm32f4xx_hal_conf.h new file mode 100644 index 0000000000..9719157e55 --- /dev/null +++ b/ports/stm32/boards/ADAFRUIT_F405_EXPRESS/stm32f4xx_hal_conf.h @@ -0,0 +1,19 @@ +/* This file is part of the MicroPython project, http://micropython.org/ + * The MIT License (MIT) + * Copyright (c) 2019 Damien P. George + */ +#ifndef MICROPY_INCLUDED_STM32F4XX_HAL_CONF_H +#define MICROPY_INCLUDED_STM32F4XX_HAL_CONF_H + +#include "boards/stm32f4xx_hal_conf_base.h" + +// Oscillator values in Hz +#define HSE_VALUE (12000000) +#define LSE_VALUE (32768) +#define EXTERNAL_CLOCK_VALUE (12288000) + +// Oscillator timeouts in ms +#define HSE_STARTUP_TIMEOUT (100) +#define LSE_STARTUP_TIMEOUT (5000) + +#endif // MICROPY_INCLUDED_STM32F4XX_HAL_CONF_H