summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDamien George <damien@micropython.org>2022-06-02 13:25:25 +1000
committerDamien George <damien@micropython.org>2022-06-02 14:30:51 +1000
commit36211baf0eaa36416d262c9ed505dc0e55f1c11d (patch)
treee9ba31522b48455927c5605726d2a4fa2592edba
parent87fbceef2649b15d40cc8aaf4e5957af537ce9af (diff)
stm32/boards/LEGO_HUB_NO6: Make all SPI flash transfers use 32-bit addr.
Signed-off-by: Damien George <damien@micropython.org>
-rw-r--r--ports/stm32/boards/LEGO_HUB_NO6/bdev.c14
-rw-r--r--ports/stm32/boards/LEGO_HUB_NO6/mpconfigboard.h11
2 files changed, 8 insertions, 17 deletions
diff --git a/ports/stm32/boards/LEGO_HUB_NO6/bdev.c b/ports/stm32/boards/LEGO_HUB_NO6/bdev.c
index a68b812ed..2f450dcb0 100644
--- a/ports/stm32/boards/LEGO_HUB_NO6/bdev.c
+++ b/ports/stm32/boards/LEGO_HUB_NO6/bdev.c
@@ -28,8 +28,6 @@
#include "storage.h"
#include "spi.h"
-#define CMD_EXIT_4_BYTE_ADDRESS_MODE (0xE9)
-
STATIC const spi_proto_cfg_t spi_bus = {
.spi = &spi_obj[1], // SPI2 hardware peripheral
.baudrate = 25000000,
@@ -50,15 +48,3 @@ const mp_spiflash_config_t spiflash_config = {
};
spi_bdev_t spi_bdev;
-
-int32_t board_bdev_ioctl(void) {
- int32_t ret = spi_bdev_ioctl(&spi_bdev, BDEV_IOCTL_INIT, (uint32_t)&spiflash_config);
-
- // Exit 4-byte address mode
- uint8_t cmd = CMD_EXIT_4_BYTE_ADDRESS_MODE;
- mp_hal_pin_write(MICROPY_HW_SPIFLASH_CS, 0);
- spi_proto.transfer(MP_OBJ_FROM_PTR(&spi_bus), 1, &cmd, NULL);
- mp_hal_pin_write(MICROPY_HW_SPIFLASH_CS, 1);
-
- return ret;
-}
diff --git a/ports/stm32/boards/LEGO_HUB_NO6/mpconfigboard.h b/ports/stm32/boards/LEGO_HUB_NO6/mpconfigboard.h
index 2cfb420ef..4ee5207a6 100644
--- a/ports/stm32/boards/LEGO_HUB_NO6/mpconfigboard.h
+++ b/ports/stm32/boards/LEGO_HUB_NO6/mpconfigboard.h
@@ -78,6 +78,10 @@
#define MICROPY_HW_BLE_UART_BAUDRATE_SECONDARY (921600)
#define MICROPY_HW_BLE_BTSTACK_CHIPSET_INSTANCE btstack_chipset_cc256x_instance()
+// External SPI flash starts in 32-bit addressing mode, so make all SPI flash
+// transfers use the explicit 32-bit addressing instructions.
+#define MICROPY_HW_SPI_ADDR_IS_32BIT(addr) (1)
+
// SPI flash, for R/W storage
// The first 1MiB is skipped because it's used by the built-in bootloader
// Note: MICROPY_HW_SPIFLASH_OFFSET_BYTES must be a multiple of MP_SPIFLASH_ERASE_BLOCK_SIZE
@@ -92,11 +96,9 @@
#define MICROPY_HW_SPIFLASH_MOSI (MICROPY_HW_SPI2_MOSI)
// SPI flash, block device config
-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) : \
- (op) == BDEV_IOCTL_INIT ? board_bdev_ioctl() : \
+ (op) == BDEV_IOCTL_INIT ? spi_bdev_ioctl(&spi_bdev, (op), (uint32_t)&spiflash_config) : \
spi_bdev_ioctl(&spi_bdev, (op), (arg)) \
)
@@ -134,6 +136,9 @@ extern struct _spi_bdev_t spi_bdev;
/******************************************************************************/
// Function declarations
+extern const struct _mp_spiflash_config_t spiflash_config;
+extern struct _spi_bdev_t spi_bdev;
+
void board_init(void);
void board_mboot_cleanup(int reset_mode);
void board_mboot_led_init(void);