Debian Codegraph @

ports/stm32/boards/PYBD_SF2/mpconfigboard.h

raw
1 /*
2 * This file is part of the MicroPython project, http://micropython.org/
3 *
4 * The MIT License (MIT)
5 *
6 * Copyright (c) 2018-2019 Damien P. George
7 *
8 * Permission is hereby granted, free of charge, to any person obtaining a copy
9 * of this software and associated documentation files (the "Software"), to deal
10 * in the Software without restriction, including without limitation the rights
11 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 * copies of the Software, and to permit persons to whom the Software is
13 * furnished to do so, subject to the following conditions:
14 *
15 * The above copyright notice and this permission notice shall be included in
16 * all copies or substantial portions of the Software.
17 *
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24 * THE SOFTWARE.
25 */
26
27 #define MICROPY_HW_BOARD_NAME "PYBD-SF2W"
28 #define MICROPY_HW_MCU_NAME "STM32F722IEK"
29
30 #define MICROPY_PY_NETWORK_HOSTNAME_DEFAULT "PYBD"
31
32 #define MICROPY_PY_PYB_LEGACY (1)
33 #define MICROPY_HW_ENABLE_INTERNAL_FLASH_STORAGE (0)
34 #define MICROPY_HW_HAS_SWITCH (1)
35 #define MICROPY_HW_HAS_FLASH (1)
36 #define MICROPY_HW_ENABLE_RNG (1)
37 #define MICROPY_HW_ENABLE_RTC (1)
38 #define MICROPY_HW_ENABLE_SERVO (1)
39 #define MICROPY_HW_ENABLE_DAC (1)
40 #define MICROPY_HW_ENABLE_USB (1)
41 #define MICROPY_HW_ENABLE_SDCARD (1)
42 #define MICROPY_HW_ENABLE_MMCARD (1)
43 #define MICROPY_HW_ENABLE_RF_SWITCH (1)
44
45 #define MICROPY_BOARD_EARLY_INIT board_early_init
46 #define MICROPY_BOARD_RUN_BOOT_PY board_run_boot_py
47 #define MICROPY_BOARD_ENTER_STOP board_sleep(1);
48 #define MICROPY_BOARD_LEAVE_STOP board_sleep(0);
49 #define MICROPY_BOARD_ENTER_STANDBY board_sleep(1);
50 #define MICROPY_BOARD_SDCARD_POWER mp_hal_pin_high(pyb_pin_EN_3V3);
51 struct _boardctrl_state_t;
52 void board_early_init(void);
53 int board_run_boot_py(struct _boardctrl_state_t *state);
54 void board_sleep(int value);
55
56 // HSE is 25MHz, run SYS at 120MHz
57 #define MICROPY_HW_CLK_PLLM (20)
58 #define MICROPY_HW_CLK_PLLN (192)
59 #define MICROPY_HW_CLK_PLLP (RCC_PLLP_DIV2)
60 #define MICROPY_HW_CLK_PLLQ (5)
61 #define MICROPY_HW_FLASH_LATENCY (FLASH_LATENCY_3)
62
63 // There is an external 32kHz oscillator
64 #define RTC_ASYNCH_PREDIV (3)
65 #define RTC_SYNCH_PREDIV (0x1fff)
66 #define MICROPY_HW_RTC_USE_BYPASS (1)
67 #define MICROPY_HW_RTC_USE_US (1)
68 #define MICROPY_HW_RTC_USE_CALOUT (1)
69
70 // ROMFS config
71 #define MICROPY_HW_ROMFS_ENABLE_EXTERNAL_QSPI (1)
72 #define MICROPY_HW_ROMFS_QSPI_SPIFLASH_OBJ (&spi_bdev2.spiflash)
73 #define MICROPY_HW_ROMFS_ENABLE_PART0 (1)
74
75 // SPI flash #1, for R/W storage
76 #define MICROPY_HW_SOFTQSPI_SCK_LOW(self) (GPIOE->BSRR = (0x10000 << 11))
77 #define MICROPY_HW_SOFTQSPI_SCK_HIGH(self) (GPIOE->BSRR = (1 << 11))
78 #define MICROPY_HW_SOFTQSPI_NIBBLE_READ(self) ((GPIOE->IDR >> 7) & 0xf)
79 #define MICROPY_HW_SPIFLASH_SIZE_BITS (16 * 1024 * 1024)
80 #define MICROPY_HW_SPIFLASH_CS (pyb_pin_QSPI1_CS)
81 #define MICROPY_HW_SPIFLASH_SCK (pyb_pin_QSPI1_CLK)
82 #define MICROPY_HW_SPIFLASH_IO0 (pyb_pin_QSPI1_D0)
83 #define MICROPY_HW_SPIFLASH_IO1 (pyb_pin_QSPI1_D1)
84 #define MICROPY_HW_SPIFLASH_IO2 (pyb_pin_QSPI1_D2)
85 #define MICROPY_HW_SPIFLASH_IO3 (pyb_pin_QSPI1_D3)
86
87 // SPI flash #1, block device config
88 extern const struct _mp_spiflash_config_t spiflash_config;
89 extern struct _spi_bdev_t spi_bdev;
90 #if !BUILDING_MBOOT
91 #define MICROPY_HW_SPIFLASH_ENABLE_CACHE (1)
92 #endif
93 #define MICROPY_HW_BDEV_SPIFLASH (&spi_bdev)
94 #define MICROPY_HW_BDEV_SPIFLASH_CONFIG (&spiflash_config)
95 #define MICROPY_HW_BDEV_SPIFLASH_SIZE_BYTES (MICROPY_HW_SPIFLASH_SIZE_BITS / 8)
96 #define MICROPY_HW_BDEV_SPIFLASH_EXTENDED (&spi_bdev) // for extended block protocol
97
98 // SPI flash #2, to be memory mapped
99 #define MICROPY_HW_QSPIFLASH_SIZE_BITS_LOG2 (24)
100 #define MICROPY_HW_QSPIFLASH_CS (pyb_pin_QSPI2_CS)
101 #define MICROPY_HW_QSPIFLASH_SCK (pyb_pin_QSPI2_CLK)
102 #define MICROPY_HW_QSPIFLASH_IO0 (pyb_pin_QSPI2_D0)
103 #define MICROPY_HW_QSPIFLASH_IO1 (pyb_pin_QSPI2_D1)
104 #define MICROPY_HW_QSPIFLASH_IO2 (pyb_pin_QSPI2_D2)
105 #define MICROPY_HW_QSPIFLASH_IO3 (pyb_pin_QSPI2_D3)
106
107 // SPI flash #2, block device config
108 extern const struct _mp_spiflash_config_t spiflash2_config;
109 extern struct _spi_bdev_t spi_bdev2;
110
111 // UART config
112 #define MICROPY_HW_UART1_NAME "YA"
113 #define MICROPY_HW_UART1_TX (pyb_pin_Y1)
114 #define MICROPY_HW_UART1_RX (pyb_pin_Y2)
115 #define MICROPY_HW_UART2_TX (pyb_pin_X3)
116 #define MICROPY_HW_UART2_RX (pyb_pin_X4)
117 #define MICROPY_HW_UART2_RTS (pyb_pin_X2)
118 #define MICROPY_HW_UART2_CTS (pyb_pin_X1)
119 #define MICROPY_HW_UART3_NAME "YB"
120 #define MICROPY_HW_UART3_TX (pyb_pin_Y9)
121 #define MICROPY_HW_UART3_RX (pyb_pin_Y10)
122 #define MICROPY_HW_UART4_NAME "XA"
123 #define MICROPY_HW_UART4_TX (pyb_pin_X1)
124 #define MICROPY_HW_UART4_RX (pyb_pin_X2)
125 #define MICROPY_HW_UART6_TX (pyb_pin_BT_TXD)
126 #define MICROPY_HW_UART6_RX (pyb_pin_BT_RXD)
127 #define MICROPY_HW_UART6_RTS (pyb_pin_BT_RTS)
128 #define MICROPY_HW_UART6_CTS (pyb_pin_BT_CTS)
129
130 // I2C buses
131 #define MICROPY_HW_I2C1_NAME "X"
132 #define MICROPY_HW_I2C1_SCL (pyb_pin_X9)
133 #define MICROPY_HW_I2C1_SDA (pyb_pin_X10)
134 #define MICROPY_HW_I2C2_NAME "Y"
135 #define MICROPY_HW_I2C2_SCL (pyb_pin_Y9)
136 #define MICROPY_HW_I2C2_SDA (pyb_pin_Y10)
137
138 // SPI buses
139 #define MICROPY_HW_SPI1_NAME "X"
140 #define MICROPY_HW_SPI1_NSS (pyb_pin_X5)
141 #define MICROPY_HW_SPI1_SCK (pyb_pin_X6)
142 #define MICROPY_HW_SPI1_MISO (pyb_pin_X7)
143 #define MICROPY_HW_SPI1_MOSI (pyb_pin_X8)
144 #define MICROPY_HW_SPI2_NAME "Y"
145 #define MICROPY_HW_SPI2_NSS (pyb_pin_Y5)
146 #define MICROPY_HW_SPI2_SCK (pyb_pin_Y6)
147 #define MICROPY_HW_SPI2_MISO (pyb_pin_Y7)
148 #define MICROPY_HW_SPI2_MOSI (pyb_pin_Y8)
149 #define MICROPY_HW_SPI3_NSS (pyb_pin_W16)
150 #define MICROPY_HW_SPI3_SCK (pyb_pin_W29)
151 #define MICROPY_HW_SPI3_MISO (pyb_pin_W50)
152 #define MICROPY_HW_SPI3_MOSI (pyb_pin_W46)
153
154 // I2S buses
155 #define MICROPY_HW_I2S1 (1)
156 #define MICROPY_HW_I2S2 (1)
157
158 // CAN buses
159 #define MICROPY_HW_CAN1_NAME "X"
160 #define MICROPY_HW_CAN1_TX (pyb_pin_X10)
161 #define MICROPY_HW_CAN1_RX (pyb_pin_X9)
162
163 // USRSW is not pulled, and pressing the button makes the input go low.
164 #define MICROPY_HW_USRSW_PIN (pyb_pin_USR)
165 #define MICROPY_HW_USRSW_PULL (GPIO_PULLUP)
166 #define MICROPY_HW_USRSW_EXTI_MODE (GPIO_MODE_IT_FALLING)
167 #define MICROPY_HW_USRSW_PRESSED (0)
168
169 // LEDs
170 #define MICROPY_HW_LED_INVERTED (1) // LEDs are on when pin is driven low
171 #define MICROPY_HW_LED1 (pyb_pin_LED_RED)
172 #define MICROPY_HW_LED2 (pyb_pin_LED_GREEN)
173 #define MICROPY_HW_LED3 (pyb_pin_LED_BLUE)
174 #define MICROPY_HW_LED_ON(pin) (mp_hal_pin_low(pin))
175 #define MICROPY_HW_LED_OFF(pin) (mp_hal_pin_high(pin))
176
177 // SD card
178 #define MICROPY_HW_SDCARD_SDMMC (2)
179 #define MICROPY_HW_SDCARD_CK (pyb_pin_SD_CK)
180 #define MICROPY_HW_SDCARD_CMD (pyb_pin_SD_CMD)
181 #define MICROPY_HW_SDCARD_D0 (pyb_pin_SD_D0)
182 #define MICROPY_HW_SDCARD_D1 (pyb_pin_SD_D1)
183 #define MICROPY_HW_SDCARD_D2 (pyb_pin_SD_D2)
184 #define MICROPY_HW_SDCARD_D3 (pyb_pin_SD_D3)
185 #define MICROPY_HW_SDCARD_DETECT_PIN (pyb_pin_SD_SW)
186 #define MICROPY_HW_SDCARD_DETECT_PULL (GPIO_PULLUP)
187 #define MICROPY_HW_SDCARD_DETECT_PRESENT (GPIO_PIN_RESET)
188 #define MICROPY_HW_SDCARD_MOUNT_AT_BOOT (0)
189
190 // MM card: the size is hard-coded to support the WBUS-EMMC add-on
191 #define MICROPY_HW_MMCARD_LOG_BLOCK_NBR (7469056 + 2048)
192
193 // USB config
194 #define MICROPY_HW_USB_FS (1)
195 #define MICROPY_HW_USB_HS (1)
196 #define MICROPY_HW_USB_HS_IN_FS (1)
197 #define MICROPY_HW_USB_MAIN_DEV (USB_PHY_HS_ID)
198
199 // Bluetooth config
200 #define MICROPY_HW_BLE_UART_ID (PYB_UART_6)
201 #define MICROPY_HW_BLE_UART_BAUDRATE (115200)
202 #define MICROPY_HW_BLE_UART_BAUDRATE_SECONDARY (3000000)
203 #define MICROPY_HW_BLE_UART_BAUDRATE_DOWNLOAD_FIRMWARE (3000000)
204
205 /******************************************************************************/
206 // Bootloader configuration
207
208 #define MBOOT_USB_AUTODETECT_PORT (1)
209 #define MBOOT_FSLOAD (1)
210 #define MBOOT_VFS_FAT (1)
211
212 #define MBOOT_I2C_PERIPH_ID 1
213 #define MBOOT_I2C_SCL (pin_B8)
214 #define MBOOT_I2C_SDA (pin_B9)
215 #define MBOOT_I2C_ALTFUNC (4)
216
217 #define MBOOT_SPIFLASH_ADDR (0x80000000)
218 #define MBOOT_SPIFLASH_BYTE_SIZE (64 * 32 * 1024)
219 #define MBOOT_SPIFLASH_LAYOUT "/0x80000000/64*32Kg"
220 #define MBOOT_SPIFLASH_ERASE_BLOCKS_PER_PAGE (32 / 4)
221 #define MBOOT_SPIFLASH_SPIFLASH (&spi_bdev.spiflash)
222 #define MBOOT_SPIFLASH_CONFIG (&spiflash_config)
223
224 #define MBOOT_SPIFLASH2_ADDR (0x90000000)
225 #define MBOOT_SPIFLASH2_BYTE_SIZE (64 * 32 * 1024)
226 #define MBOOT_SPIFLASH2_LAYOUT "/0x90000000/64*32Kg"
227 #define MBOOT_SPIFLASH2_ERASE_BLOCKS_PER_PAGE (32 / 4)
228 #define MBOOT_SPIFLASH2_SPIFLASH (&spi_bdev2.spiflash)
229 #define MBOOT_SPIFLASH2_CONFIG (&spiflash2_config)
230
231 #define MBOOT_BOARD_EARLY_INIT(initial_r0) mboot_board_early_init()
232 void mboot_board_early_init(void);