From 6820e4dcdc11df4419f82e25435406bbb5f1f6df Mon Sep 17 00:00:00 2001 From: Drashna Jael're Date: Tue, 12 Nov 2024 19:21:20 -0800 Subject: [PATCH] Enable wear leveling spi flash eeprom for feather f405 --- .../handwired/feather_stm32f405_express/config.h | 13 +++++++++++++ .../handwired/feather_stm32f405_express/halconf.h | 5 +++++ .../feather_stm32f405_express/keyboard.json | 7 +++++++ .../handwired/feather_stm32f405_express/mcuconf.h | 12 ++++++++++++ 4 files changed, 37 insertions(+) diff --git a/keyboards/handwired/feather_stm32f405_express/config.h b/keyboards/handwired/feather_stm32f405_express/config.h index bdfb32ff60ea..3d3aed759319 100644 --- a/keyboards/handwired/feather_stm32f405_express/config.h +++ b/keyboards/handwired/feather_stm32f405_express/config.h @@ -12,3 +12,16 @@ #define DRV2605L_FB_ERM_LRA 0 #define DRV2605L_GREETING DRV2605L_EFFECT_750_MS_ALERT_100 #define DRV2605L_DEFAULT_MODE DRV2605L_EFFECT_BUZZ_1_100 + +/* spi config for eeprom and pmw3360 sensor */ +#define SPI_DRIVER SPID1 +#define SPI_SCK_PIN B3 +#define SPI_SCK_PAL_MODE 5 +#define SPI_MOSI_PIN B5 +#define SPI_MOSI_PAL_MODE 5 +#define SPI_MISO_PIN B4 +#define SPI_MISO_PAL_MODE 5 + +#define EXTERNAL_FLASH_SPI_SLAVE_SELECT_PIN A15 +#define EXTERNAL_FLASH_SPI_CLOCK_DIVISOR 32 // 16 or less doesn't work right +#define EXTERNAL_FLASH_SIZE (2 * 1024 * 1024) diff --git a/keyboards/handwired/feather_stm32f405_express/halconf.h b/keyboards/handwired/feather_stm32f405_express/halconf.h index 6c46c850f704..c0e8e5e4b689 100644 --- a/keyboards/handwired/feather_stm32f405_express/halconf.h +++ b/keyboards/handwired/feather_stm32f405_express/halconf.h @@ -19,4 +19,9 @@ #define HAL_USE_I2C TRUE +#if HAL_USE_SPI == TRUE +# define SPI_USE_WAIT TRUE +# define SPI_SELECT_MODE SPI_SELECT_MODE_PAD +#endif + #include_next diff --git a/keyboards/handwired/feather_stm32f405_express/keyboard.json b/keyboards/handwired/feather_stm32f405_express/keyboard.json index 952395e26c49..adfaf96b6cd4 100644 --- a/keyboards/handwired/feather_stm32f405_express/keyboard.json +++ b/keyboards/handwired/feather_stm32f405_express/keyboard.json @@ -17,6 +17,13 @@ "haptic": { "driver": "drv2605l" }, + "eeprom": { + "wear_leveling": { + "driver": "spi_flash", + "logical_size": 16384, + "backing_size": 65536 + } + }, "matrix_pins": { "cols": [null, null, null, null], "rows": [null, null, null, null] diff --git a/keyboards/handwired/feather_stm32f405_express/mcuconf.h b/keyboards/handwired/feather_stm32f405_express/mcuconf.h index 87291c61a5ef..1db61cdc4d07 100644 --- a/keyboards/handwired/feather_stm32f405_express/mcuconf.h +++ b/keyboards/handwired/feather_stm32f405_express/mcuconf.h @@ -20,3 +20,15 @@ #undef STM32_I2C_USE_I2C1 #define STM32_I2C_USE_I2C1 TRUE + + +#if HAL_USE_SPI == TRUE +# undef STM32_SPI_USE_SPI1 +# define STM32_SPI_USE_SPI1 TRUE + +# undef STM32_SPI_SPI1_TX_DMA_STREAM +# define STM32_SPI_SPI1_TX_DMA_STREAM STM32_DMA_STREAM_ID(2, 5) +# undef STM32_SPI_SPI1_RX_DMA_STREAM +# define STM32_SPI_SPI1_RX_DMA_STREAM STM32_DMA_STREAM_ID(2, 0) + +#endif