summaryrefslogtreecommitdiffstatshomepage
path: root/ports/stm32/storage.c
diff options
context:
space:
mode:
Diffstat (limited to 'ports/stm32/storage.c')
-rw-r--r--ports/stm32/storage.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/ports/stm32/storage.c b/ports/stm32/storage.c
index d810261fbc..d26ac821e5 100644
--- a/ports/stm32/storage.c
+++ b/ports/stm32/storage.c
@@ -32,6 +32,7 @@
#include "led.h"
#include "storage.h"
#include "irq.h"
+#include "xspi.h"
#if MICROPY_HW_ENABLE_STORAGE
@@ -44,13 +45,17 @@
static bool storage_is_initialised = false;
+#if !defined(STM32N6)
static void storage_systick_callback(uint32_t ticks_ms);
+#endif
void storage_init(void) {
if (!storage_is_initialised) {
storage_is_initialised = true;
+ #if !defined(STM32N6)
systick_enable_dispatch(SYSTICK_DISPATCH_STORAGE, storage_systick_callback);
+ #endif
MICROPY_HW_BDEV_IOCTL(BDEV_IOCTL_INIT, 0);
@@ -58,10 +63,12 @@ void storage_init(void) {
MICROPY_HW_BDEV2_IOCTL(BDEV_IOCTL_INIT, 0);
#endif
+ #if !defined(STM32N6)
// Enable the flash IRQ, which is used to also call our storage IRQ handler
// It must go at the same priority as USB (see comment in irq.h).
NVIC_SetPriority(FLASH_IRQn, IRQ_PRI_FLASH);
HAL_NVIC_EnableIRQ(FLASH_IRQn);
+ #endif
}
}
@@ -77,6 +84,7 @@ uint32_t storage_get_block_count(void) {
#endif
}
+#if !defined(STM32N6)
static void storage_systick_callback(uint32_t ticks_ms) {
if (STORAGE_IDLE_TICK(ticks_ms)) {
// Trigger a FLASH IRQ to execute at a lower priority
@@ -96,6 +104,7 @@ void FLASH_IRQHandler(void) {
#endif
IRQ_EXIT(FLASH_IRQn);
}
+#endif
void storage_flush(void) {
MICROPY_HW_BDEV_IOCTL(BDEV_IOCTL_SYNC, 0);
@@ -235,11 +244,11 @@ int storage_write_blocks(const uint8_t *src, uint32_t block_num, uint32_t num_bl
// Board defined an external SPI flash for use with extended block protocol
#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(MICROPY_HW_BDEV_SPIFLASH_EXTENDED, (dest), (bl), (off), (len)))
+ (spi_bdev_readblocks_raw(MICROPY_HW_BDEV_SPIFLASH_EXTENDED, (dest), MICROPY_HW_BDEV_SPIFLASH_OFFSET_BYTES / MP_SPIFLASH_ERASE_BLOCK_SIZE + (bl), (off), (len)))
#define MICROPY_HW_BDEV_WRITEBLOCKS_EXT(src, bl, off, len) \
- (spi_bdev_writeblocks_raw(MICROPY_HW_BDEV_SPIFLASH_EXTENDED, (src), (bl), (off), (len)))
+ (spi_bdev_writeblocks_raw(MICROPY_HW_BDEV_SPIFLASH_EXTENDED, (src), MICROPY_HW_BDEV_SPIFLASH_OFFSET_BYTES / MP_SPIFLASH_ERASE_BLOCK_SIZE + (bl), (off), (len)))
#define MICROPY_HW_BDEV_ERASEBLOCKS_EXT(bl, len) \
- (spi_bdev_eraseblocks_raw(MICROPY_HW_BDEV_SPIFLASH_EXTENDED, (bl), (len)))
+ (spi_bdev_eraseblocks_raw(MICROPY_HW_BDEV_SPIFLASH_EXTENDED, MICROPY_HW_BDEV_SPIFLASH_OFFSET_BYTES / MP_SPIFLASH_ERASE_BLOCK_SIZE + (bl), (len)))
#elif (MICROPY_VFS_LFS1 || MICROPY_VFS_LFS2) && MICROPY_HW_ENABLE_INTERNAL_FLASH_STORAGE
// Board uses littlefs and internal flash, so enable extended block protocol on internal flash