diff --git a/ports/stm32/spibdev.c b/ports/stm32/spibdev.c index 4481a7a709..3eadb995d6 100644 --- a/ports/stm32/spibdev.c +++ b/ports/stm32/spibdev.c @@ -105,26 +105,26 @@ void spi_bdev_flush(void) { } } -bool spi_bdev_readblock(uint8_t *dest, uint32_t block) { +int spi_bdev_readblocks(uint8_t *dest, uint32_t block_num, uint32_t num_blocks) { // we must disable USB irqs to prevent MSC contention with SPI flash uint32_t basepri = raise_irq_pri(IRQ_PRI_OTG_FS); - mp_spiflash_read(&spiflash, block * FLASH_BLOCK_SIZE, FLASH_BLOCK_SIZE, dest); + mp_spiflash_read(&spiflash, block_num * FLASH_BLOCK_SIZE, num_blocks * FLASH_BLOCK_SIZE, dest); restore_irq_pri(basepri); - return true; + return 0; } -bool spi_bdev_writeblock(const uint8_t *src, uint32_t block) { +int spi_bdev_writeblocks(const uint8_t *src, uint32_t block_num, uint32_t num_blocks) { // we must disable USB irqs to prevent MSC contention with SPI flash uint32_t basepri = raise_irq_pri(IRQ_PRI_OTG_FS); - int ret = mp_spiflash_write(&spiflash, block * FLASH_BLOCK_SIZE, FLASH_BLOCK_SIZE, src); + int ret = mp_spiflash_write(&spiflash, block_num * FLASH_BLOCK_SIZE, num_blocks * FLASH_BLOCK_SIZE, src); if (spiflash.flags & 1) { led_state(PYB_LED_RED, 1); // indicate a dirty cache with LED on flash_tick_counter_last_write = HAL_GetTick(); } restore_irq_pri(basepri); - return ret == 0; + return ret; } #endif // defined(MICROPY_HW_SPIFLASH_SIZE_BITS) diff --git a/ports/stm32/storage.c b/ports/stm32/storage.c index 0b6f2db621..46bd4fdc76 100644 --- a/ports/stm32/storage.c +++ b/ports/stm32/storage.c @@ -41,8 +41,8 @@ #define BDEV_INIT spi_bdev_init #define BDEV_IRQ_HANDLER spi_bdev_irq_handler #define BDEV_FLUSH spi_bdev_flush -#define BDEV_READBLOCK spi_bdev_readblock -#define BDEV_WRITEBLOCK spi_bdev_writeblock +#define BDEV_READBLOCKS spi_bdev_readblocks +#define BDEV_WRITEBLOCKS spi_bdev_writeblocks #else diff --git a/ports/stm32/storage.h b/ports/stm32/storage.h index 2497633896..8b3cedb127 100644 --- a/ports/stm32/storage.h +++ b/ports/stm32/storage.h @@ -53,8 +53,8 @@ bool flash_bdev_writeblock(const uint8_t *src, uint32_t block); void spi_bdev_init(void); void spi_bdev_irq_handler(void); void spi_bdev_flush(void); -bool spi_bdev_readblock(uint8_t *dest, uint32_t block); -bool spi_bdev_writeblock(const uint8_t *src, uint32_t block); +int spi_bdev_readblocks(uint8_t *dest, uint32_t block_num, uint32_t num_blocks); +int spi_bdev_writeblocks(const uint8_t *src, uint32_t block_num, uint32_t num_blocks); extern const struct _mp_obj_type_t pyb_flash_type;