stm32/boards/LEGO_HUB_NO6: Make all SPI flash transfers use 32-bit addr.

Signed-off-by: Damien George <damien@micropython.org>
This commit is contained in:
Damien George 2022-06-02 13:25:25 +10:00
parent 87fbceef26
commit 36211baf0e
2 changed files with 8 additions and 17 deletions

View File

@ -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;
}

View File

@ -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);