diff options
| author | Damien George <damien@micropython.org> | 2023-05-24 16:17:58 +1000 |
|---|---|---|
| committer | Damien George <damien@micropython.org> | 2023-06-08 23:01:03 +1000 |
| commit | 3b370157d007649d5d5ed1747514ea242f597215 (patch) | |
| tree | f14d796bab286c92211ac1d63e855fb80096175a | |
| parent | 0832fc53cec2d3fd5ed8c9108d185f00b83c3a8f (diff) | |
stm32/mpconfigboard_common: Provide default spidev config.
Signed-off-by: Damien George <damien@micropython.org>
| -rw-r--r-- | ports/stm32/mpconfigboard_common.h | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/ports/stm32/mpconfigboard_common.h b/ports/stm32/mpconfigboard_common.h index 0bb80f215..300ca55d5 100644 --- a/ports/stm32/mpconfigboard_common.h +++ b/ports/stm32/mpconfigboard_common.h @@ -499,6 +499,21 @@ #define MICROPY_HW_BDEV_WRITEBLOCK flash_bdev_writeblock #endif +#if defined(MICROPY_HW_BDEV_SPIFLASH) +// Provide block device macros using spi_bdev. +// The board must provide settings for: +// - MICROPY_HW_BDEV_SPIFLASH - pointer to a spi_bdev_t +// - MICROPY_HW_BDEV_SPIFLASH_CONFIG - pointer to an mp_spiflash_config_t +// - MICROPY_HW_BDEV_SPIFLASH_SIZE_BYTES - size in bytes of the SPI flash +#define MICROPY_HW_BDEV_IOCTL(op, arg) ( \ + (op) == BDEV_IOCTL_NUM_BLOCKS ? (MICROPY_HW_BDEV_SPIFLASH_SIZE_BYTES / FLASH_BLOCK_SIZE) : \ + (op) == BDEV_IOCTL_INIT ? spi_bdev_ioctl(MICROPY_HW_BDEV_SPIFLASH, (op), (uint32_t)MICROPY_HW_BDEV_SPIFLASH_CONFIG) : \ + spi_bdev_ioctl(MICROPY_HW_BDEV_SPIFLASH, (op), (arg)) \ + ) +#define MICROPY_HW_BDEV_READBLOCKS(dest, bl, n) spi_bdev_readblocks(MICROPY_HW_BDEV_SPIFLASH, (dest), (bl), (n)) +#define MICROPY_HW_BDEV_WRITEBLOCKS(src, bl, n) spi_bdev_writeblocks(MICROPY_HW_BDEV_SPIFLASH, (src), (bl), (n)) +#endif + // Whether to enable caching for external SPI flash, to allow block writes that are // smaller than the native page-erase size of the SPI flash, eg when FAT FS is used. // Enabling this enables spi_bdev_readblocks() and spi_bdev_writeblocks() functions, |
