|
| 1 | +/* |
| 2 | + * This file is part of the MicroPython project, http://micropython.org/ |
| 3 | + * |
| 4 | + * The MIT License (MIT) |
| 5 | + * |
| 6 | + * Copyright (c) 2025 Mike Tolkachev <contact@miketolkachev.dev> |
| 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 | +// This board is configured to communicate over USB port, not ST-Link |
| 28 | + |
| 29 | +#define MICROPY_HW_BOARD_NAME "F469DISC" |
| 30 | +#define MICROPY_HW_MCU_NAME "STM32F469" |
| 31 | + |
| 32 | +// Use external QSPI flash for storage by default |
| 33 | +#define MICROPY_HW_ENABLE_INTERNAL_FLASH_STORAGE (0) |
| 34 | + |
| 35 | +#define MICROPY_HW_HAS_SWITCH (1) |
| 36 | +#define MICROPY_HW_HAS_FLASH (1) |
| 37 | +#define MICROPY_HW_ENABLE_RNG (1) |
| 38 | +#define MICROPY_HW_ENABLE_RTC (1) |
| 39 | +#define MICROPY_HW_ENABLE_DAC (1) |
| 40 | +#define MICROPY_HW_ENABLE_USB (1) |
| 41 | +#define MICROPY_HW_ENABLE_SDCARD (1) |
| 42 | + |
| 43 | +#define MICROPY_BOARD_EARLY_INIT STM32F469DISC_board_early_init |
| 44 | +void STM32F469DISC_board_early_init(void); |
| 45 | + |
| 46 | +// QSPI flash storage configuration |
| 47 | +#if !BUILDING_MBOOT |
| 48 | +#define MICROPY_HW_SPIFLASH_ENABLE_CACHE (1) |
| 49 | +#endif |
| 50 | +#define MICROPY_HW_SPIFLASH_SOFT_RESET (1) |
| 51 | +#define MICROPY_HW_SPIFLASH_SIZE_BITS (128 * 1024 * 1024) |
| 52 | +#define MICROPY_HW_SPIFLASH_CHIP_PARAMS (1) // enable extended parameters |
| 53 | +#define MICROPY_HW_QSPI_PRESCALER (3) |
| 54 | +#define MICROPY_HW_QSPIFLASH_DUMMY_CYCLES (4) |
| 55 | +#define MICROPY_HW_QSPIFLASH_SIZE_BITS_LOG2 (27) |
| 56 | +#define MICROPY_HW_QSPIFLASH_CS (pyb_pin_QSPI_CS) |
| 57 | +#define MICROPY_HW_QSPIFLASH_SCK (pyb_pin_QSPI_CLK) |
| 58 | +#define MICROPY_HW_QSPIFLASH_IO0 (pyb_pin_QSPI_D0) |
| 59 | +#define MICROPY_HW_QSPIFLASH_IO1 (pyb_pin_QSPI_D1) |
| 60 | +#define MICROPY_HW_QSPIFLASH_IO2 (pyb_pin_QSPI_D2) |
| 61 | +#define MICROPY_HW_QSPIFLASH_IO3 (pyb_pin_QSPI_D3) |
| 62 | + |
| 63 | +// QSPI flash block device configuration |
| 64 | +extern const struct _mp_spiflash_config_t spiflash_config; |
| 65 | +extern struct _spi_bdev_t spi_bdev; |
| 66 | +#define MICROPY_HW_BDEV_SPIFLASH (&spi_bdev) |
| 67 | +#define MICROPY_HW_BDEV_SPIFLASH_CONFIG (&spiflash_config) |
| 68 | +#define MICROPY_HW_BDEV_SPIFLASH_SIZE_BYTES (MICROPY_HW_SPIFLASH_SIZE_BITS / 8) |
| 69 | +#define MICROPY_HW_BDEV_SPIFLASH_EXTENDED (&spi_bdev) // for extended block protocol |
| 70 | + |
| 71 | +// HSE is 8MHz |
| 72 | +#define MICROPY_HW_CLK_PLLM (8) |
| 73 | +#define MICROPY_HW_CLK_PLLN (336) |
| 74 | +#define MICROPY_HW_CLK_PLLP (RCC_PLLP_DIV2) |
| 75 | +#define MICROPY_HW_CLK_PLLQ (7) |
| 76 | + |
| 77 | +#define MICROPY_HW_FLASH_LATENCY FLASH_LATENCY_6 |
| 78 | + |
| 79 | +// UART config |
| 80 | +#define MICROPY_HW_UART3_NAME "YB" |
| 81 | +#define MICROPY_HW_UART3_TX (pin_B10) |
| 82 | +#define MICROPY_HW_UART3_RX (pin_B11) |
| 83 | +#define MICROPY_HW_UART6_NAME "YA" |
| 84 | +#define MICROPY_HW_UART6_TX (pin_G14) |
| 85 | +#define MICROPY_HW_UART6_RX (pin_G9) |
| 86 | +#define MICROPY_HW_UART2_NAME "UART2" |
| 87 | +#define MICROPY_HW_UART2_TX (pin_A2) // Needed to enable AF |
| 88 | +#define MICROPY_HW_UART2_RX (pin_A3) // Dummy, not routed on PCB |
| 89 | +#define MICROPY_HW_UART2_CK (pin_A4) |
| 90 | + |
| 91 | +// I2C buses |
| 92 | +#define MICROPY_HW_I2C1_SCL (pin_B8) |
| 93 | +#define MICROPY_HW_I2C1_SDA (pin_B9) |
| 94 | + |
| 95 | +// SPI |
| 96 | +#define MICROPY_HW_SPI2_NSS (pin_B9) |
| 97 | +#define MICROPY_HW_SPI2_SCK (pin_D3) |
| 98 | +#define MICROPY_HW_SPI2_MISO (pin_B14) |
| 99 | +#define MICROPY_HW_SPI2_MOSI (pin_B15) |
| 100 | + |
| 101 | +// CAN buses |
| 102 | +#define MICROPY_HW_CAN1_TX (pin_B9) |
| 103 | +#define MICROPY_HW_CAN1_RX (pin_B8) |
| 104 | + |
| 105 | +// USRSW is pulled low. Pressing the button makes the input go high. |
| 106 | +#define MICROPY_HW_USRSW_PIN (pin_A0) |
| 107 | +#define MICROPY_HW_USRSW_PULL (GPIO_NOPULL) |
| 108 | +#define MICROPY_HW_USRSW_EXTI_MODE (GPIO_MODE_IT_RISING) |
| 109 | +#define MICROPY_HW_USRSW_PRESSED (1) |
| 110 | + |
| 111 | +// LEDs |
| 112 | +#define MICROPY_HW_LED1 (pin_G6) // green |
| 113 | +#define MICROPY_HW_LED2 (pin_D4) // orange |
| 114 | +#define MICROPY_HW_LED3 (pin_D5) // red |
| 115 | +#define MICROPY_HW_LED4 (pin_K3) // blue |
| 116 | +#define MICROPY_HW_LED_ON(pin) (mp_hal_pin_low(pin)) |
| 117 | +#define MICROPY_HW_LED_OFF(pin) (mp_hal_pin_high(pin)) |
| 118 | + |
| 119 | +// SD Card SDMMC |
| 120 | +#define MICROPY_HW_SDCARD_CK (pin_C12) |
| 121 | +#define MICROPY_HW_SDCARD_CMD (pin_D2) |
| 122 | +#define MICROPY_HW_SDCARD_D0 (pin_C8) |
| 123 | +#define MICROPY_HW_SDCARD_D1 (pin_C9) |
| 124 | +#define MICROPY_HW_SDCARD_D2 (pin_C10) |
| 125 | +#define MICROPY_HW_SDCARD_D3 (pin_C11) |
| 126 | +#define MICROPY_HW_SDCARD_DETECT_PIN (pin_G2) |
| 127 | +#define MICROPY_HW_SDCARD_DETECT_PULL (GPIO_PULLUP) |
| 128 | +#define MICROPY_HW_SDCARD_DETECT_PRESENT (GPIO_PIN_RESET) |
| 129 | + |
| 130 | +// USB config |
| 131 | +#define MICROPY_HW_USB_FS (1) |
| 132 | +#define MICROPY_HW_USB_VBUS_DETECT_PIN (pin_A9) |
| 133 | +#define MICROPY_HW_USB_OTG_ID_PIN (pin_A10) |
0 commit comments