|
| 1 | +/* |
| 2 | + * This file is part of the MicroPython project, http://micropython.org/ |
| 3 | + * |
| 4 | + * The MIT License (MIT) |
| 5 | + * |
| 6 | + * Copyright (c) 2025 Garatronic SAS, thanks to 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 "PymateIO CORE8ADI8DOSC V0.2.0" |
| 28 | +#define MICROPY_HW_MCU_NAME "STM32F412RE" |
| 29 | +#define MICROPY_PY_THREAD (1) |
| 30 | + |
| 31 | +#define MICROPY_PY_PYB_LEGACY (1) |
| 32 | +#define MICROPY_HW_ENABLE_INTERNAL_FLASH_STORAGE (0) |
| 33 | +#define MICROPY_HW_HAS_SWITCH (1) |
| 34 | +#define MICROPY_HW_HAS_FLASH (1) |
| 35 | +#define MICROPY_HW_ENABLE_RNG (1) |
| 36 | +#define MICROPY_HW_ENABLE_RTC (1) |
| 37 | +#define MICROPY_HW_ENABLE_USB (1) |
| 38 | +#define MICROPY_HW_ENABLE_SERVO (1) |
| 39 | +#define MICROPY_HW_ENABLE_DAC (0) |
| 40 | +#define MICROPY_HW_ENABLE_SDCARD (0) |
| 41 | +#define MICROPY_HW_ENABLE_MMCARD (0) |
| 42 | + |
| 43 | +// board HSE is 16MHz, run SYS at 96 MHz |
| 44 | +// board is 3.3V powered, 75 to 100 MHz: 3 wait states |
| 45 | +#define MICROPY_HW_CLK_PLLM (16) |
| 46 | +#define MICROPY_HW_CLK_PLLN (192) |
| 47 | +#define MICROPY_HW_CLK_PLLP (RCC_PLLP_DIV2) |
| 48 | +#define MICROPY_HW_CLK_PLLQ (4) |
| 49 | +#define MICROPY_HW_CLK_LAST_FREQ (1) |
| 50 | +#define MICROPY_HW_CLK_AHB_DIV (RCC_SYSCLK_DIV1) |
| 51 | +#define MICROPY_HW_CLK_APB1_DIV (RCC_HCLK_DIV2) |
| 52 | +#define MICROPY_HW_CLK_APB2_DIV (RCC_HCLK_DIV1) |
| 53 | +#define MICROPY_HW_FLASH_LATENCY FLASH_LATENCY_3 |
| 54 | + |
| 55 | +// board haves 32kHz crystal |
| 56 | +#define MICROPY_HW_RTC_USE_LSE (1) |
| 57 | +#define MICROPY_HW_RTC_USE_US (1) |
| 58 | +#define MICROPY_HW_RTC_USE_CALOUT (0) |
| 59 | + |
| 60 | + |
| 61 | +// 8MBit external QSPI flash |
| 62 | +#define MICROPY_HW_QSPIFLASH_SIZE_BITS_LOG2 (23) |
| 63 | +#define MICROPY_HW_QSPIFLASH_CS (pin_B6) |
| 64 | +#define MICROPY_HW_QSPIFLASH_SCK (pin_B2) |
| 65 | +#define MICROPY_HW_QSPIFLASH_IO0 (pin_C9) |
| 66 | +#define MICROPY_HW_QSPIFLASH_IO1 (pin_C10) |
| 67 | +#define MICROPY_HW_QSPIFLASH_IO2 (pin_C8) |
| 68 | +#define MICROPY_HW_QSPIFLASH_IO3 (pin_A1) |
| 69 | + |
| 70 | +// ROMFS config |
| 71 | +#define MICROPY_HW_ROMFS_ENABLE_EXTERNAL_QSPI (1) |
| 72 | +#define MICROPY_HW_ROMFS_QSPI_SPIFLASH_OBJ (&spi_bdev.spiflash) |
| 73 | +#define MICROPY_HW_ROMFS_ENABLE_PART0 (1) |
| 74 | + |
| 75 | +// SPI flash, block device config (when used as the filesystem) |
| 76 | +extern const struct _mp_spiflash_config_t spiflash_config; |
| 77 | +extern struct _spi_bdev_t spi_bdev; |
| 78 | + |
| 79 | +#if !USE_QSPI_XIP |
| 80 | +#define MICROPY_HW_SPIFLASH_ENABLE_CACHE (1) |
| 81 | +#define MICROPY_HW_BDEV_SPIFLASH (&spi_bdev) |
| 82 | +#define MICROPY_HW_BDEV_SPIFLASH_CONFIG (&spiflash_config) |
| 83 | +#define MICROPY_HW_BDEV_SPIFLASH_SIZE_BYTES ((1 << MICROPY_HW_QSPIFLASH_SIZE_BITS_LOG2) / 8) |
| 84 | +#define MICROPY_HW_BDEV_SPIFLASH_EXTENDED (&spi_bdev) // for extended block protocol |
| 85 | +#endif |
| 86 | + |
| 87 | +// UART config |
| 88 | +#define MICROPY_HW_UART1_NAME "X" |
| 89 | +#define MICROPY_HW_UART1_TX (pin_A15) |
| 90 | +#define MICROPY_HW_UART1_RX (pin_A10) |
| 91 | +#define MICROPY_HW_UART2_NAME "M" |
| 92 | +#define MICROPY_HW_UART2_TX (pin_A2) |
| 93 | +#define MICROPY_HW_UART2_RX (pin_A3) |
| 94 | + |
| 95 | + |
| 96 | +// I2C buses |
| 97 | +// putain de fmpi2c controleur, ne marche pas encore :-( |
| 98 | +//#define MICROPY_HW_I2C4_NAME "X" |
| 99 | +//#define MICROPY_HW_I2C4_SCL (pin_B15) |
| 100 | +//#define MICROPY_HW_I2C4_SDA (pin_B14) |
| 101 | +//#define MICROPY_HW_I2C4_SMB (pin_B13) |
| 102 | + |
| 103 | +// CAN buse |
| 104 | +#define MICROPY_HW_CAN1_NAME "X" |
| 105 | +#define MICROPY_HW_CAN1_TX (pin_B9) |
| 106 | +#define MICROPY_HW_CAN1_RX (pin_B8) |
| 107 | + |
| 108 | +// SPI buses |
| 109 | +#define MICROPY_HW_SPI1_NAME "X" |
| 110 | +#define MICROPY_HW_SPI1_NSS (pin_A4) |
| 111 | +#define MICROPY_HW_SPI1_SCK (pin_B3) |
| 112 | +#define MICROPY_HW_SPI1_MISO (pin_B4) |
| 113 | +#define MICROPY_HW_SPI1_MOSI (pin_B5) |
| 114 | + |
| 115 | +// USRSW has external pullup, and pressing the switch makes the input go low |
| 116 | +#define MICROPY_HW_USRSW_PIN (pin_B12) |
| 117 | +#define MICROPY_HW_USRSW_PULL (GPIO_PULLUP) |
| 118 | +#define MICROPY_HW_USRSW_EXTI_MODE (GPIO_MODE_IT_FALLING) |
| 119 | +#define MICROPY_HW_USRSW_PRESSED (0) |
| 120 | + |
| 121 | +// The board has 2 LEDs, LED1 & LED2 as fusionned |
| 122 | +#define MICROPY_HW_LED1 (pin_A13) // RED legacy |
| 123 | +#define MICROPY_HW_LED2 (pin_A13) // GREEN legacy |
| 124 | +#define MICROPY_HW_LED3 (pin_A14) // YELLOW lecacy |
| 125 | +#define MICROPY_HW_LED_ON(pin) (mp_hal_pin_high(pin)) |
| 126 | +#define MICROPY_HW_LED_OFF(pin) (mp_hal_pin_low(pin)) |
| 127 | + |
| 128 | +// USB config |
| 129 | +#define MICROPY_HW_USB_FS (1) |
| 130 | +#define MICROPY_HW_FLASH_FS_LABEL "pymate_io" |
| 131 | + |
| 132 | +/******************************************************************************/ |
| 133 | +// Mboot bootloader configuration : only for QSPI version |
| 134 | +// else STM32 rom based bootloader with BOOT0 trigger at reset need to be used |
| 135 | + |
| 136 | +//#define MBOOT_SPIFLASH_ADDR (0x90000000) |
| 137 | +//#define MBOOT_SPIFLASH_BYTE_SIZE (1024 * 1024) |
| 138 | +//#define MBOOT_SPIFLASH_LAYOUT "/0x90000000/256*4Kg" |
| 139 | +//#define MBOOT_SPIFLASH_ERASE_BLOCKS_PER_PAGE (1) |
| 140 | +//#define MBOOT_SPIFLASH_SPIFLASH (&spi_bdev.spiflash) |
| 141 | +//#define MBOOT_SPIFLASH_CONFIG (&spiflash_config) |
| 142 | + |
| 143 | +//#define MBOOT_USB_AUTODETECT_PORT (1) |
| 144 | +//#define MBOOT_FSLOAD (1) |
| 145 | +//#define MBOOT_VFS_LFS2 (1) |
| 146 | + |
| 147 | +//#define MBOOT_BOOTPIN_PIN (pin_B12) |
| 148 | +//#define MBOOT_BOOTPIN_PULL (MP_HAL_PIN_PULL_UP) |
| 149 | +//#define MBOOT_BOOTPIN_ACTIVE (0) |
| 150 | + |
| 151 | +// #define MBOOT_I2C_PERIPH_ID 1 |
| 152 | +// #define MBOOT_I2C_SCL (pin_B8) |
| 153 | +// #define MBOOT_I2C_SDA (pin_B9) |
| 154 | +// #define MBOOT_I2C_ALTFUNC (4) |
| 155 | + |
| 156 | +//#define MBOOT_BOARD_EARLY_INIT(initial_r0) mboot_board_early_init() |
| 157 | +//void mboot_board_early_init(void); |
0 commit comments