Debian Codegraph @

ports/stm32/boards/VCC_GND_F407ZG/mpconfigboard.h

raw
1 /* This file is part of the MicroPython project, http://micropython.org/
2 * MIT License; Copyright (c) 2021 Damien P. George
3 */
4
5 // STM32F407ZGT6 Mini by VCC-GND Studio
6 // http://vcc-gnd.com/
7 // https://item.taobao.com/item.htm?ft=t&id=523383164199
8 // https://www.aliexpress.com/wholesale?SearchText=STM32F407ZGT6+Mini
9
10 // DFU mode can be accessed by switching BOOT0 DIP ON (towards USB)
11
12 #define MICROPY_HW_BOARD_NAME "VCC-GND STM32F407ZG"
13 #define MICROPY_HW_MCU_NAME "STM32F407ZG"
14 #define MICROPY_HW_FLASH_FS_LABEL "VCCGNDF407ZG"
15
16 // 1 = use internal flash (1 MByte)
17 // 0 = use onboard SPI flash (512 KByte) Winbond W25X40
18 #define MICROPY_HW_ENABLE_INTERNAL_FLASH_STORAGE (0)
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 #define MICROPY_HW_UART1_RTS (pin_A12)
42 #define MICROPY_HW_UART1_CTS (pin_A11)
43 // USART1_CK PA8
44
45 // USART2
46 #define MICROPY_HW_UART2_TX (pin_A2) // PA2,PD5
47 #define MICROPY_HW_UART2_RX (pin_A3) // PA3,PD6
48 #define MICROPY_HW_UART2_RTS (pin_A1) // PA1,PD4
49 #define MICROPY_HW_UART2_CTS (pin_A0) // PA0,PD3
50 // USART2_CK PA4,PD7
51
52 // USART3
53 #define MICROPY_HW_UART3_TX (pin_D8) // PB10,PC10,PD8
54 #define MICROPY_HW_UART3_RX (pin_D9) // PB11,PC11,PD9
55 #define MICROPY_HW_UART3_RTS (pin_D12) // PB14,PD12
56 #define MICROPY_HW_UART3_CTS (pin_D11) // PB13,PD11
57 // USART3_CK PB12,PC12,PD10
58
59 // UART4
60 #define MICROPY_HW_UART4_TX (pin_A0) // PA0,PC10
61 #define MICROPY_HW_UART4_RX (pin_A1) // PA1,PC11
62
63 // UART5
64 #define MICROPY_HW_UART5_TX (pin_C12) // PC12
65 #define MICROPY_HW_UART5_RX (pin_D2) // PD2
66
67 // USART6
68 #define MICROPY_HW_UART6_TX (pin_C6) // PC6,PG14
69 #define MICROPY_HW_UART6_RX (pin_C7) // PC7,PG9
70 #define MICROPY_HW_UART6_RTS (pin_G8) // PG8,PG12
71 #define MICROPY_HW_UART6_CTS (pin_G13) // PG13,PG15
72 // USART6_CK PC8,PG7
73
74 // I2C buses
75 #define MICROPY_HW_I2C1_SCL (pin_B6) // PB8,PB6
76 #define MICROPY_HW_I2C1_SDA (pin_B7) // PB9,PB7
77 // I2C1_SMBA PB5
78 #define MICROPY_HW_I2C2_SCL (pin_B10) // PB10,PF1
79 #define MICROPY_HW_I2C2_SDA (pin_B11) // PB11,PF0
80 // I2C2_SMBA PB12,PF2
81 #define MICROPY_HW_I2C3_SCL (pin_A8) // PA8
82 #define MICROPY_HW_I2C3_SDA (pin_C9) // PC9
83 // I2C3_SMBA PA9
84
85 // AT24C08 EEPROM on I2C1 0x50-0x53
86
87 // I2S buses - multiplexed with SPI2 and SPI3
88 // I2S2_CK PB10,PB13
89 // I2S2_MCK PC6
90 // I2S2_SD PB15,PC3
91 // I2S2_WS PB9,PB12
92 // I2S3_CK PB3,PC10
93 // I2S3_MCK PC7
94 // I2S3_SD PB5,PC12
95 // I2S3_WS PA4,PA15
96
97 // SPI buses
98 #define MICROPY_HW_SPI1_NSS (pin_A4) // PA4,PA15
99 #define MICROPY_HW_SPI1_SCK (pin_A5) // PA5,PB3
100 #define MICROPY_HW_SPI1_MISO (pin_A6) // PA6,PB4
101 #define MICROPY_HW_SPI1_MOSI (pin_A7) // PA7,PB5
102
103 #define MICROPY_HW_SPI2_NSS (pin_B12) // PB12,PB9
104 #define MICROPY_HW_SPI2_SCK (pin_B13) // PB13,PB10
105 #define MICROPY_HW_SPI2_MISO (pin_B14) // PB14,PC2
106 #define MICROPY_HW_SPI2_MOSI (pin_B15) // PB15,PC3
107
108 #define MICROPY_HW_SPI3_NSS (pin_A15) // PA15,PA4
109 #define MICROPY_HW_SPI3_SCK (pin_B3) // PB3,PC10
110 #define MICROPY_HW_SPI3_MISO (pin_B4) // PB4,PC11
111 #define MICROPY_HW_SPI3_MOSI (pin_B5) // PB5,PC12
112
113 // CAN buses
114 #define MICROPY_HW_CAN1_TX (pin_B9) // PB9,PD1,PA12
115 #define MICROPY_HW_CAN1_RX (pin_B8) // PB8,PD0,PA11
116 #define MICROPY_HW_CAN2_TX (pin_B13) // PB13,PB6
117 #define MICROPY_HW_CAN2_RX (pin_B12) // PB12,PB5
118
119 // DAC
120 // DAC_OUT1 PA4
121 // DAC_OUT2 PA5
122
123 // LEDs
124 #define MICROPY_HW_LED1 (pin_G15) // blue
125 #define MICROPY_HW_LED_ON(pin) (mp_hal_pin_low(pin))
126 #define MICROPY_HW_LED_OFF(pin) (mp_hal_pin_high(pin))
127
128 // If using onboard SPI flash
129 #if !MICROPY_HW_ENABLE_INTERNAL_FLASH_STORAGE
130
131 // W25X40 SPI Flash = 4 Mbit (512 KByte)
132 #define MICROPY_HW_SPIFLASH_SIZE_BITS (4 * 1024 * 1024)
133 #define MICROPY_HW_SPIFLASH_CS (pin_C4)
134 #define MICROPY_HW_SPIFLASH_SCK (pin_A5)
135 #define MICROPY_HW_SPIFLASH_MISO (pin_A6)
136 #define MICROPY_HW_SPIFLASH_MOSI (pin_A7)
137
138 #define MICROPY_BOARD_EARLY_INIT VCC_GND_F407ZG_board_early_init
139 void VCC_GND_F407ZG_board_early_init(void);
140
141 extern const struct _mp_spiflash_config_t spiflash_config;
142 extern struct _spi_bdev_t spi_bdev;
143 #define MICROPY_HW_SPIFLASH_ENABLE_CACHE (1)
144 #define MICROPY_HW_BDEV_SPIFLASH (&spi_bdev)
145 #define MICROPY_HW_BDEV_SPIFLASH_CONFIG (&spiflash_config)
146 #define MICROPY_HW_BDEV_SPIFLASH_SIZE_BYTES (MICROPY_HW_SPIFLASH_SIZE_BITS / 8)
147
148 #endif
149
150 // SD card detect switch
151 #define MICROPY_HW_SDCARD_DETECT_PIN (pin_F10)
152 #define MICROPY_HW_SDCARD_DETECT_PULL (GPIO_PULLUP)
153 #define MICROPY_HW_SDCARD_DETECT_PRESENT (GPIO_PIN_RESET)
154 // 1 - PC10 - DAT2/RES
155 // 2 - PC11 - CD/DAT3/CS
156 // 3 - PD2 - CMD/DI
157 // 4 - VCC - VDD
158 // 5 - PC12 - CLK/SCLK
159 // 6 - GND - VSS
160 // 7 - PC8 - DAT0/D0
161 // 8 - PC9 - DAT1/RES
162 // 9 SW2 - GND
163 // 10 SW1 - PF10
164
165 // USB config
166 #define MICROPY_HW_USB_FS (1)
167 // #define MICROPY_HW_USB_VBUS_DETECT_PIN (pin_A9)
168 // #define MICROPY_HW_USB_OTG_ID_PIN (pin_A10)
169
170 // Ethernet via RMII
171 #define MICROPY_HW_ETH_MDC (pin_C1)
172 #define MICROPY_HW_ETH_MDIO (pin_A2)
173 #define MICROPY_HW_ETH_RMII_REF_CLK (pin_A1)
174 #define MICROPY_HW_ETH_RMII_CRS_DV (pin_A7)
175 #define MICROPY_HW_ETH_RMII_RXD0 (pin_C4)
176 #define MICROPY_HW_ETH_RMII_RXD1 (pin_C5)
177 #define MICROPY_HW_ETH_RMII_TX_EN (pin_B11)
178 #define MICROPY_HW_ETH_RMII_TXD0 (pin_B12)
179 #define MICROPY_HW_ETH_RMII_TXD1 (pin_B13)