|
|
@ -10,7 +10,7 @@ |
|
|
|
#define MICROPY_HW_MCU_NAME "STM32F413" |
|
|
|
|
|
|
|
#define MICROPY_HW_HAS_SWITCH (0) |
|
|
|
#define MICROPY_HW_HAS_FLASH (0) |
|
|
|
#define MICROPY_HW_HAS_FLASH (1) |
|
|
|
#define MICROPY_PY_PYB_LEGACY (0) |
|
|
|
#define MICROPY_HW_ENTER_BOOTLOADER_VIA_RESET (0) |
|
|
|
#define MICROPY_HW_ENABLE_INTERNAL_FLASH_STORAGE (0) |
|
|
@ -78,8 +78,12 @@ |
|
|
|
#define MICROPY_HW_BLE_BTSTACK_CHIPSET_INSTANCE btstack_chipset_cc256x_instance() |
|
|
|
|
|
|
|
// SPI flash, for R/W storage
|
|
|
|
// The first 1MiB is skipped because it's used by the built-in bootloader
|
|
|
|
#define MICROPY_HW_SPIFLASH_OFFSET_BYTES (1024 * 1024) |
|
|
|
#define MICROPY_HW_SPIFLASH_BLOCKMAP(bl) ((bl) + MICROPY_HW_SPIFLASH_OFFSET_BYTES / FLASH_BLOCK_SIZE) |
|
|
|
#define MICROPY_HW_SPIFLASH_BLOCKMAP_EXT(bl) ((bl) + MICROPY_HW_SPIFLASH_OFFSET_BYTES / MP_SPIFLASH_ERASE_BLOCK_SIZE) |
|
|
|
#define MICROPY_HW_SPIFLASH_ENABLE_CACHE (1) |
|
|
|
#define MICROPY_HW_SPIFLASH_SIZE_BITS (256 * 1024 * 1024) |
|
|
|
#define MICROPY_HW_SPIFLASH_SIZE_BITS (256 * 1024 * 1024 - MICROPY_HW_SPIFLASH_OFFSET_BYTES * 8) |
|
|
|
#define MICROPY_HW_SPIFLASH_CS (MICROPY_HW_SPI2_NSS) |
|
|
|
#define MICROPY_HW_SPIFLASH_SCK (MICROPY_HW_SPI2_SCK) |
|
|
|
#define MICROPY_HW_SPIFLASH_MISO (MICROPY_HW_SPI2_MISO) |
|
|
@ -89,15 +93,25 @@ |
|
|
|
extern int32_t board_bdev_ioctl(void); |
|
|
|
extern struct _spi_bdev_t spi_bdev; |
|
|
|
#define MICROPY_HW_BDEV_IOCTL(op, arg) ( \ |
|
|
|
(op) == BDEV_IOCTL_NUM_BLOCKS ? (MICROPY_HW_SPIFLASH_SIZE_BITS / 8 / FLASH_BLOCK_SIZE - 1) : \ |
|
|
|
(op) == BDEV_IOCTL_NUM_BLOCKS ? (MICROPY_HW_SPIFLASH_SIZE_BITS / 8 / FLASH_BLOCK_SIZE) : \ |
|
|
|
(op) == BDEV_IOCTL_INIT ? board_bdev_ioctl() : \ |
|
|
|
spi_bdev_ioctl(&spi_bdev, (op), (arg)) \ |
|
|
|
) |
|
|
|
|
|
|
|
// Jump over first block (bl + 1) as it is cleared by bootloader
|
|
|
|
#define MICROPY_HW_BDEV_READBLOCKS(dest, bl, n) spi_bdev_readblocks(&spi_bdev, (dest), (bl + 1), (n)) |
|
|
|
#define MICROPY_HW_BDEV_WRITEBLOCKS(src, bl, n) spi_bdev_writeblocks(&spi_bdev, (src), (bl + 1), (n)) |
|
|
|
#define MICROPY_HW_BDEV_SPIFLASH_EXTENDED (&spi_bdev) // for extended block protocol
|
|
|
|
// Configuration for stardard block protocol (block size FLASH_BLOCK_SIZE).
|
|
|
|
#define MICROPY_HW_BDEV_READBLOCKS(dest, bl, n) \ |
|
|
|
spi_bdev_readblocks(&spi_bdev, (dest), MICROPY_HW_SPIFLASH_BLOCKMAP(bl), (n)) |
|
|
|
#define MICROPY_HW_BDEV_WRITEBLOCKS(src, bl, n) \ |
|
|
|
spi_bdev_writeblocks(&spi_bdev, (src), MICROPY_HW_SPIFLASH_BLOCKMAP(bl), (n)) |
|
|
|
|
|
|
|
// Configuration for extended block protocol (block size MP_SPIFLASH_ERASE_BLOCK_SIZE).
|
|
|
|
#define MICROPY_HW_BDEV_BLOCKSIZE_EXT (MP_SPIFLASH_ERASE_BLOCK_SIZE) |
|
|
|
#define MICROPY_HW_BDEV_READBLOCKS_EXT(dest, bl, off, len) \ |
|
|
|
(spi_bdev_readblocks_raw(&spi_bdev, (dest), MICROPY_HW_SPIFLASH_BLOCKMAP_EXT(bl), (off), (len))) |
|
|
|
#define MICROPY_HW_BDEV_WRITEBLOCKS_EXT(src, bl, off, len) \ |
|
|
|
(spi_bdev_writeblocks_raw(&spi_bdev, (src), MICROPY_HW_SPIFLASH_BLOCKMAP_EXT(bl), (off), (len))) |
|
|
|
#define MICROPY_HW_BDEV_ERASEBLOCKS_EXT(bl, len) \ |
|
|
|
(spi_bdev_eraseblocks_raw(&spi_bdev, MICROPY_HW_SPIFLASH_BLOCKMAP_EXT(bl), (len))) |
|
|
|
|
|
|
|
// Board control config
|
|
|
|
#define MICROPY_BOARD_STARTUP board_init |
|
|
|