From 3980b361730a4d3313f6456fca1697db96b73870 Mon Sep 17 00:00:00 2001 From: robert-hh Date: Wed, 20 Mar 2024 20:23:49 +0100 Subject: [PATCH] samd/samd_spiflash: Allow configuring the flash SPI baudrate. Using a define for MICROPY_HW_SPIFLASH_BAUDRATE in mpconfigboard.h. If not defined the default is 24MHz. Signed-off-by: robert-hh --- ports/samd/samd_spiflash.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ports/samd/samd_spiflash.c b/ports/samd/samd_spiflash.c index 1313a6fd9d..cd4f10640d 100644 --- a/ports/samd/samd_spiflash.c +++ b/ports/samd/samd_spiflash.c @@ -49,6 +49,9 @@ const uint8_t _COMMANDS_32BIT[] = {0x13, 0x12, 0x21}; // READ, PROGRAM_PAGE, ER #define COMMAND_READ_SFDP (0x5A) #define PAGE_SIZE (256) #define SECTOR_SIZE (4096) +#ifndef MICROPY_HW_SPIFLASH_BAUDRATE +#define MICROPY_HW_SPIFLASH_BAUDRATE (24000000) +#endif typedef struct _spiflash_obj_t { mp_obj_base_t base; @@ -136,7 +139,7 @@ static mp_obj_t spiflash_make_new(const mp_obj_type_t *type, size_t n_args, size mp_obj_t spi_args[] = { MP_OBJ_NEW_SMALL_INT(MICROPY_HW_SPIFLASH_ID), - MP_OBJ_NEW_SMALL_INT(24000000), // baudrate + MP_OBJ_NEW_SMALL_INT(MICROPY_HW_SPIFLASH_BAUDRATE), MP_OBJ_NEW_QSTR(MP_QSTR_mosi), MP_OBJ_NEW_QSTR(MP_QSTR_FLASH_MOSI), MP_OBJ_NEW_QSTR(MP_QSTR_miso), MP_OBJ_NEW_QSTR(MP_QSTR_FLASH_MISO), MP_OBJ_NEW_QSTR(MP_QSTR_sck), MP_OBJ_NEW_QSTR(MP_QSTR_FLASH_SCK),