1 /* This file is part of the MicroPython project, http://micropython.org/ 2 * MIT License; Copyright (c) 2021 Damien P. George 3 */ 4 5 // STM32F407VET6 Mini by VCC-GND Studio 6 // http://vcc-gnd.com/ 7 // https://item.taobao.com/item.htm?ft=t&id=523361737493 8 // https://www.aliexpress.com/wholesale?SearchText=STM32F407VET6+Mini 9 10 // DFU mode can be accessed by switching BOOT0 DIP ON (towards USB) 11 12 #define MICROPY_HW_BOARD_NAME "VCC-GND STM32F407VE" 13 #define MICROPY_HW_MCU_NAME "STM32F407VE" 14 #define MICROPY_HW_FLASH_FS_LABEL "VCCGNDF407VE" 15 16 // 1 = use internal flash (512 KByte) 17 // 0 = use external SPI flash 18 #define MICROPY_HW_ENABLE_INTERNAL_FLASH_STORAGE (1) 19 20 #define MICROPY_HW_HAS_FLASH (1) 21 #define MICROPY_HW_ENABLE_RNG (1) 22 #define MICROPY_HW_ENABLE_RTC (1) 23 #define MICROPY_HW_ENABLE_DAC (1) 24 #define MICROPY_HW_ENABLE_USB (1) 25 #define MICROPY_HW_ENABLE_SDCARD (1) 26 27 // HSE is 25MHz 28 #define MICROPY_HW_CLK_PLLM (25) // divide external clock by this to get 1MHz 29 #define MICROPY_HW_CLK_PLLN (336) // PLL clock in MHz 30 #define MICROPY_HW_CLK_PLLP (RCC_PLLP_DIV2) // divide PLL clock by this to get core clock 31 #define MICROPY_HW_CLK_PLLQ (7) // divide core clock by this to get 48MHz 32 33 // The board has a 32kHz crystal for the RTC 34 #define MICROPY_HW_RTC_USE_LSE (1) 35 #define MICROPY_HW_RTC_USE_US (0) 36 // #define MICROPY_HW_RTC_USE_CALOUT (1) // turn on/off PC13 512Hz output 37 38 // USART1 39 #define MICROPY_HW_UART1_TX (pin_A9) // PA9,PB6 40 #define MICROPY_HW_UART1_RX (pin_A10) // PA10,PB7 41 42 // USART2 43 #define MICROPY_HW_UART2_TX (pin_A2) // PA2,PD5 44 #define MICROPY_HW_UART2_RX (pin_A3) // PA3,PD6 45 #define MICROPY_HW_UART2_RTS (pin_A1) // PA1,PD4 46 #define MICROPY_HW_UART2_CTS (pin_A0) // PA0,PD3 47 48 // USART3 49 #define MICROPY_HW_UART3_TX (pin_D8) // PB10,PC10,PD8 50 #define MICROPY_HW_UART3_RX (pin_D9) // PB11,PC11,PD9 51 #define MICROPY_HW_UART3_RTS (pin_D12) // PB14,PD12 52 #define MICROPY_HW_UART3_CTS (pin_D11) // PB13,PD11 53 54 // UART4 55 #define MICROPY_HW_UART4_TX (pin_A0) // PA0,PC10 56 #define MICROPY_HW_UART4_RX (pin_A1) // PA1,PC11 57 58 // UART5 59 #define MICROPY_HW_UART5_TX (pin_C12) // PC12 60 #define MICROPY_HW_UART5_RX (pin_D2) // PD2 61 62 // USART6 63 #define MICROPY_HW_UART6_TX (pin_C6) // PC6,PG14 64 #define MICROPY_HW_UART6_RX (pin_C7) // PC7,PG9 65 66 // I2C buses 67 #define MICROPY_HW_I2C1_SCL (pin_B6) // PB8,PB6 68 #define MICROPY_HW_I2C1_SDA (pin_B7) // PB9,PB7 69 #define MICROPY_HW_I2C2_SCL (pin_B10) // PB10 70 #define MICROPY_HW_I2C2_SDA (pin_B11) // PB11 71 #define MICROPY_HW_I2C3_SCL (pin_A8) // PA8 72 #define MICROPY_HW_I2C3_SDA (pin_C9) // PC9 73 // AT24C08 EEPROM on I2C1 0x50-0x53 74 75 // I2S buses 76 // I2S2_CK PB13 77 // I2S2_MCK PC6 78 // I2S2_SD PB15 79 // I2S2_WS PB12 80 // I2S3_CK PB3 81 // I2S3_MCK PC7 82 // I2S3_SD PB5 83 // I2S3_WS PA15 84 85 // SPI buses 86 #define MICROPY_HW_SPI1_NSS (pin_A4) // PA4 87 #define MICROPY_HW_SPI1_SCK (pin_A5) // PA5,PB3 88 #define MICROPY_HW_SPI1_MISO (pin_A6) // PA6,PB4 89 #define MICROPY_HW_SPI1_MOSI (pin_A7) // PA7,PB5 90 91 #define MICROPY_HW_SPI2_NSS (pin_B12) // PB12 92 #define MICROPY_HW_SPI2_SCK (pin_B13) // PB13 93 #define MICROPY_HW_SPI2_MISO (pin_B14) // PB14 94 #define MICROPY_HW_SPI2_MOSI (pin_B15) // PB15 95 96 #define MICROPY_HW_SPI3_NSS (pin_A15) // PA15 97 #define MICROPY_HW_SPI3_SCK (pin_B3) // PB3 98 #define MICROPY_HW_SPI3_MISO (pin_B4) // PB4 99 #define MICROPY_HW_SPI3_MOSI (pin_B5) // PB5 100 101 // CAN buses 102 #define MICROPY_HW_CAN1_TX (pin_B9) // PB9,PD1,PA12 103 #define MICROPY_HW_CAN1_RX (pin_B8) // PB8,PD0,PA11 104 #define MICROPY_HW_CAN2_TX (pin_B13) // PB13 105 #define MICROPY_HW_CAN2_RX (pin_B12) // PB12 106 107 // DAC 108 // DAC_OUT1 PA4 109 // DAC_OUT2 PA5 110 111 // LEDs 112 #define MICROPY_HW_LED1 (pin_B9) // blue 113 #define MICROPY_HW_LED_ON(pin) (mp_hal_pin_low(pin)) 114 #define MICROPY_HW_LED_OFF(pin) (mp_hal_pin_high(pin)) 115 116 // If using external SPI flash 117 #if !MICROPY_HW_ENABLE_INTERNAL_FLASH_STORAGE 118 119 // The board does not have onboard SPI flash. You need to add an external one. 120 #define MICROPY_HW_SPIFLASH_SIZE_BITS (4 * 1024 * 1024) // W25X40 - 4 Mbit (512 KByte) 121 // #define MICROPY_HW_SPIFLASH_SIZE_BITS (32 * 1024 * 1024) // W25Q32 - 32 Mbit (4 MByte) 122 // #define MICROPY_HW_SPIFLASH_SIZE_BITS (64 * 1024 * 1024) // W25Q64 - 64 Mbit (8 MByte) 123 // #define MICROPY_HW_SPIFLASH_SIZE_BITS (128 * 1024 * 1024) // W25Q128 - 128 Mbit (16 MByte) 124 125 #define MICROPY_HW_SPIFLASH_CS (pin_A4) // also in board_init.c 126 #define MICROPY_HW_SPIFLASH_SCK (pin_A5) 127 #define MICROPY_HW_SPIFLASH_MISO (pin_A6) 128 #define MICROPY_HW_SPIFLASH_MOSI (pin_A7) 129 130 #define MICROPY_BOARD_EARLY_INIT VCC_GND_F407VE_board_early_init 131 void VCC_GND_F407VE_board_early_init(void); 132 133 extern const struct _mp_spiflash_config_t spiflash_config; 134 extern struct _spi_bdev_t spi_bdev; 135 #define MICROPY_HW_SPIFLASH_ENABLE_CACHE (1) 136 #define MICROPY_HW_BDEV_IOCTL(op, arg) ( \ 137 (op) == BDEV_IOCTL_NUM_BLOCKS ? (MICROPY_HW_SPIFLASH_SIZE_BITS / 8 / FLASH_BLOCK_SIZE) : \ 138 (op) == BDEV_IOCTL_INIT ? spi_bdev_ioctl(&spi_bdev, (op), (uint32_t)&spiflash_config) : \ 139 spi_bdev_ioctl(&spi_bdev, (op), (arg)) \ 140 ) 141 #define MICROPY_HW_BDEV_READBLOCKS(dest, bl, n) spi_bdev_readblocks(&spi_bdev, (dest), (bl), (n)) 142 #define MICROPY_HW_BDEV_WRITEBLOCKS(src, bl, n) spi_bdev_writeblocks(&spi_bdev, (src), (bl), (n)) 143 144 #endif 145 146 // SD card detect switch 147 #define MICROPY_HW_SDCARD_DETECT_PIN (pin_A8) 148 #define MICROPY_HW_SDCARD_DETECT_PULL (GPIO_PULLUP) 149 #define MICROPY_HW_SDCARD_DETECT_PRESENT (GPIO_PIN_RESET) 150 // 1 - PC10 - DAT2/RES 151 // 2 - PC11 - CD/DAT3/CS 152 // 3 - PD2 - CMD/DI 153 // 4 - VCC - VDD 154 // 5 - PC12 - CLK/SCLK 155 // 6 - GND - VSS 156 // 7 - PC8 - DAT0/D0 157 // 8 - PC9 - DAT1/RES 158 // 9 SW2 - GND 159 // 10 SW1 - PA8 160 161 // USB config 162 #define MICROPY_HW_USB_FS (1) 163 // #define MICROPY_HW_USB_VBUS_DETECT_PIN (pin_A9) 164 // #define MICROPY_HW_USB_OTG_ID_PIN (pin_A10) 165