Skip to content

Commit 71c0b97

Browse files
author
Joy Lee
authored
Added external spi flash driver. (#15419)
1 parent 00cc646 commit 71c0b97

File tree

4 files changed

+547
-0
lines changed

4 files changed

+547
-0
lines changed

builddefs/common_features.mk

+15
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,21 @@ else
219219
endif
220220
endif
221221

222+
VALID_FLASH_DRIVER_TYPES := spi
223+
FLASH_DRIVER ?= no
224+
ifneq ($(strip $(FLASH_DRIVER)), no)
225+
ifeq ($(filter $(FLASH_DRIVER),$(VALID_FLASH_DRIVER_TYPES)),)
226+
$(error FLASH_DRIVER="$(FLASH_DRIVER)" is not a valid FLASH driver)
227+
else
228+
OPT_DEFS += -DFLASH_ENABLE
229+
ifeq ($(strip $(FLASH_DRIVER)), spi)
230+
OPT_DEFS += -DFLASH_DRIVER -DFLASH_SPI
231+
COMMON_VPATH += $(DRIVER_PATH)/flash
232+
SRC += flash_spi.c
233+
endif
234+
endif
235+
endif
236+
222237
RGBLIGHT_ENABLE ?= no
223238
VALID_RGBLIGHT_TYPES := WS2812 APA102 custom
224239

docs/flash_driver.md

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# FLASH Driver Configuration :id=flash-driver-configuration
2+
3+
The FLASH driver can be swapped out depending on the needs of the keyboard, or whether extra hardware is present.
4+
5+
Driver | Description
6+
-----------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
7+
`FLASH_DRIVER = spi` | Supports writing to almost all NOR Flash chips. See the driver section below.
8+
9+
10+
## SPI FLASH Driver Configuration :id=spi-flash-driver-configuration
11+
12+
Currently QMK supports almost all NOR Flash chips over SPI. As such, requires a working spi_master driver configuration. You can override the driver configuration via your config.h:
13+
14+
`config.h` override | Description | Default Value
15+
-----------------------------------------------|--------------------------------------------------------------------------------------|-----------------
16+
`#define EXTERNAL_FLASH_SPI_SLAVE_SELECT_PIN` | SPI Slave select pin in order to inform that the FLASH is currently being addressed | _none_
17+
`#define EXTERNAL_FLASH_SPI_CLOCK_DIVISOR` | Clock divisor used to divide the peripheral clock to derive the SPI frequency | `8`
18+
`#define EXTERNAL_FLASH_PAGE_SIZE` | The Page size of the FLASH in bytes, as specified in the datasheet | `256`
19+
`#define EXTERNAL_FLASH_SECTOR_SIZE` | The sector size of the FLASH in bytes, as specified in the datasheet | `(4 * 1024)`
20+
`#define EXTERNAL_FLASH_BLOCK_SIZE` | The block size of the FLASH in bytes, as specified in the datasheet | `(64 * 1024)`
21+
`#define EXTERNAL_FLASH_SIZE` | The total size of the FLASH in bytes, as specified in the datasheet | `(512 * 1024)`
22+
`#define EXTERNAL_FLASH_ADDRESS_SIZE` | The Flash address size in bytes, as specified in datasheet | `3`
23+
24+
!> All the above default configurations are based on MX25L4006E NOR Flash.

0 commit comments

Comments
 (0)