Skip to content

Commit

Permalink
Consolidate some EEPROM Driver configuration (qmk#22321)
Browse files Browse the repository at this point in the history
  • Loading branch information
zvecr committed Oct 22, 2023
1 parent 79094d3 commit bf6f13a
Show file tree
Hide file tree
Showing 21 changed files with 28 additions and 70 deletions.
8 changes: 8 additions & 0 deletions docs/eeprom_driver.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,14 @@ Currently QMK supports 25xx-series chips over SPI. As such, requires a working s
`#define EXTERNAL_EEPROM_PAGE_SIZE` | `32` | Page size of the EEPROM in bytes, as specified in the datasheet
`#define EXTERNAL_EEPROM_ADDRESS_SIZE` | `2` | The number of bytes to transmit for the memory location within the EEPROM

Default values and extended descriptions can be found in `drivers/eeprom/eeprom_spi.h`.

Alternatively, there are pre-defined hardware configurations for available chips/modules:

Module | Equivalent `#define` | Source
-----------------|---------------------------------|------------------------------------------
MB85RS64V FRAM | `define EEPROM_SPI_MB85RS64V` | <https://www.adafruit.com/product/1897>

!> There's no way to determine if there is an SPI EEPROM actually responding. Generally, this will result in reads of nothing but zero.

## Transient Driver configuration :id=transient-eeprom-driver-configuration
Expand Down
12 changes: 12 additions & 0 deletions drivers/eeprom/eeprom_spi.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,18 @@

#pragma once

/*
Default device configurations:
For the Adafruit SPI Non-Volatile FRAM Breakout: https://www.adafruit.com/product/1897
#define EEPROM_SPI_MB85RS64V
*/
#if defined(EEPROM_SPI_MB85RS64V)
# define EXTERNAL_EEPROM_BYTE_COUNT 8192
# define EXTERNAL_EEPROM_PAGE_SIZE 64 // it's FRAM, so it doesn't actually matter, this just sets the RAM buffer
# define EXTERNAL_EEPROM_ADDRESS_SIZE 2
#endif

/*
The slave select pin of the EEPROM.
This needs to be a normal GPIO pin_t value, such as A7.
Expand Down
1 change: 1 addition & 0 deletions keyboards/custommk/evo70_r2/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#define MATRIX_ROW_PINS { A8, A1, A2, B1, A7 }

// FRAM configuration
#define EEPROM_SPI_MB85RS64V
#define EXTERNAL_EEPROM_SPI_SLAVE_SELECT_PIN A0
#define EXTERNAL_EEPROM_SPI_CLOCK_DIVISOR 4 // 48MHz / 4 = 12MHz; max supported by MB85R64 is 20MHz

Expand Down
2 changes: 0 additions & 2 deletions keyboards/rgbkb/mun/keymaps/default/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,3 @@
// 20m timeout (20m * 60s * 1000mil)
// #define RGB_MATRIX_TIMEOUT 1200000
#define RGB_DISABLE_WHEN_USB_SUSPENDED

#define STM32_ONBOARD_EEPROM_SIZE 2048
2 changes: 0 additions & 2 deletions keyboards/rgbkb/mun/keymaps/via/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,3 @@
// 224B per layer right now
#define DYNAMIC_KEYMAP_LAYER_COUNT 8
#define DYNAMIC_KEYMAP_EEPROM_MAX_ADDR 2047

#define STM32_ONBOARD_EEPROM_SIZE 2048
3 changes: 0 additions & 3 deletions keyboards/rgbkb/sol3/keymaps/default/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,3 @@
// 20m timeout (20m * 60s * 1000mil)
// #define RGB_MATRIX_TIMEOUT 1200000
#define RGB_DISABLE_WHEN_USB_SUSPENDED

#define STM32_ONBOARD_EEPROM_SIZE 2048

3 changes: 0 additions & 3 deletions keyboards/rgbkb/sol3/keymaps/via/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,3 @@
// 224B per layer right now
#define DYNAMIC_KEYMAP_LAYER_COUNT 8
#define DYNAMIC_KEYMAP_EEPROM_MAX_ADDR 2047

#define STM32_ONBOARD_EEPROM_SIZE 2048

9 changes: 0 additions & 9 deletions keyboards/tau4/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,6 @@ along with this program. If not, see <http:https://www.gnu.org/licenses/>.

#pragma once


// Buggy, currently disabled
/* #define EXTERNAL_EEPROM_I2C_BASE_ADDRESS 0b10100000
#define EXTERNAL_EEPROM_I2C_ADDRESS(loc) (EXTERNAL_EEPROM_I2C_BASE_ADDRESS | ((((loc) >> 8) & 0x07) << 1))
#define EXTERNAL_EEPROM_BYTE_COUNT 2048
#define EXTERNAL_EEPROM_PAGE_SIZE 16
#define EXTERNAL_EEPROM_ADDRESS_SIZE 1
#define EXTERNAL_EEPROM_WRITE_TIME 5 */

#define RGBLIGHT_LAYERS_RETAIN_VAL

#define OLED_DISPLAY_WIDTH 128
Expand Down
3 changes: 1 addition & 2 deletions keyboards/tzarc/djinn/rev1/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
#define RGB_CURR_3000mA_OK_PIN C5

// EEPROM configuration
#define EEPROM_SPI_MB85RS64V
#define EXTERNAL_EEPROM_SPI_SLAVE_SELECT_PIN B5
#define EXTERNAL_EEPROM_SPI_CLOCK_DIVISOR 8 // (160MHz/8) => 20MHz
#define EXTERNAL_EEPROM_BYTE_COUNT 8192
#define EXTERNAL_EEPROM_PAGE_SIZE 64 // it's FRAM, so it doesn't actually matter, this just sets the RAM buffer size
3 changes: 1 addition & 2 deletions keyboards/tzarc/djinn/rev2/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,9 @@
#define RGB_CURR_3000mA_OK_PIN C4

// EEPROM configuration
#define EEPROM_SPI_MB85RS64V
#define EXTERNAL_EEPROM_SPI_SLAVE_SELECT_PIN B5
#define EXTERNAL_EEPROM_SPI_CLOCK_DIVISOR 8 // (160MHz/8) => 20MHz
#define EXTERNAL_EEPROM_BYTE_COUNT 8192
#define EXTERNAL_EEPROM_PAGE_SIZE 64 // it's FRAM, so it doesn't actually matter, this just sets the RAM buffer size

// External flash config
#define EXTERNAL_FLASH_SPI_MODE 3
Expand Down
3 changes: 1 addition & 2 deletions keyboards/tzarc/ghoul/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@
// #define MATRIX_COLS 8 // actually defined in info.json: 8 bits per register

// EEPROM configuration
#define EXTERNAL_EEPROM_BYTE_COUNT 8192
#define EXTERNAL_EEPROM_PAGE_SIZE 64 // it's FRAM, so it doesn't actually matter, this just sets the RAM buffer
#define EEPROM_SPI_MB85RS64V

// RGB configuration
#define RGB_MATRIX_LED_COUNT 40
6 changes: 1 addition & 5 deletions keyboards/vinhcatba/uncertainty/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,7 @@
#define I2C1_DUTY_CYCLE FAST_DUTY_CYCLE_16_9

/* eeprom i2c driver config */
#define EXTERNAL_EEPROM_I2C_BASE_ADDRESS 0b10100000
#define EXTERNAL_EEPROM_BYTE_COUNT 4096
#define EXTERNAL_EEPROM_PAGE_SIZE 32
#define EXTERNAL_EEPROM_WRITE_TIME 10
//#define EEPROM_I2C_24LC32
#define EEPROM_I2C_24LC32A

/* OLED config */
#define OLED_UPDATE_INTERVAL 100
Expand Down
3 changes: 0 additions & 3 deletions keyboards/xelus/kangaroo/rev1/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,3 @@

// I2C EEPROM
#define EEPROM_I2C_CAT24C512

// Dynamic EEPROM
#define DYNAMIC_KEYMAP_EEPROM_MAX_ADDR 65535
3 changes: 0 additions & 3 deletions keyboards/xelus/pachi/rgb/rev1/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,6 @@
// I2C EEPROM
#define EEPROM_I2C_24LC64

// More EEPROM for layers
#define DYNAMIC_KEYMAP_EEPROM_MAX_ADDR 8191

// RGB Matrix defines
#define IS31FL3741_I2C_ADDRESS_1 IS31FL3741_I2C_ADDRESS_GND

Expand Down
9 changes: 1 addition & 8 deletions keyboards/xelus/rs108/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,7 @@
#define I2C1_DUTY_CYCLE FAST_DUTY_CYCLE_2

// EEPROM config
// 24LC32
#define EXTERNAL_EEPROM_BYTE_COUNT 4096
#define EXTERNAL_EEPROM_PAGE_SIZE 32
#define EXTERNAL_EEPROM_ADDRESS_SIZE 2
#define EXTERNAL_EEPROM_WRITE_TIME 5

// More EEPROM for layers
#define DYNAMIC_KEYMAP_EEPROM_MAX_ADDR 4095
#define EEPROM_I2C_24LC32A

// Hardware Defines
#define EARLY_INIT_PERFORM_BOOTLOADER_JUMP TRUE
Expand Down
9 changes: 1 addition & 8 deletions keyboards/xelus/rs60/rev2_0/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,7 @@
#define I2C1_DUTY_CYCLE FAST_DUTY_CYCLE_2

// EEPROM config
// 24LC32
#define EXTERNAL_EEPROM_BYTE_COUNT 4096
#define EXTERNAL_EEPROM_PAGE_SIZE 32
#define EXTERNAL_EEPROM_ADDRESS_SIZE 2
#define EXTERNAL_EEPROM_WRITE_TIME 5

// More EEPROM for layers
#define DYNAMIC_KEYMAP_EEPROM_MAX_ADDR 4095
#define EEPROM_I2C_24LC32A

// Hardware Defines
#define EARLY_INIT_PERFORM_BOOTLOADER_JUMP TRUE
Expand Down
3 changes: 0 additions & 3 deletions keyboards/xelus/valor/rev2/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,6 @@
// I2C EEPROM
#define EEPROM_I2C_24LC64

// More EEPROM for layers
#define DYNAMIC_KEYMAP_EEPROM_MAX_ADDR 8191

/* RGB Matrix */
#define RGB_MATRIX_LED_COUNT 28
#define NOP_FUDGE 0.4
Expand Down
6 changes: 0 additions & 6 deletions keyboards/xelus/valor_frl_tkl/rev1/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,4 @@
#define I2C1_TIMINGR_SCLL 9U

// I2C EEPROM
// 24LC64
#define EEPROM_I2C_24LC64

// Dynamic EEPROM
// Something sensible or else VIA may crash
// Users may enable more if they wish
#define DYNAMIC_KEYMAP_EEPROM_MAX_ADDR 4095
3 changes: 0 additions & 3 deletions keyboards/xelus/xs108/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,3 @@

// I2C EEPROM
#define EEPROM_I2C_24LC64

// More EEPROM for layers
#define DYNAMIC_KEYMAP_EEPROM_MAX_ADDR 8191
3 changes: 0 additions & 3 deletions keyboards/xelus/xs60/hotswap/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,6 @@
// I2C EEPROM
#define EEPROM_I2C_24LC64

// More EEPROM for layers
#define DYNAMIC_KEYMAP_EEPROM_MAX_ADDR 8191

// RGBLIGHT
#define RGBLIGHT_LAYERS
#define WS2812_EXTERNAL_PULLUP
Expand Down
4 changes: 1 addition & 3 deletions platforms/chibios/boards/BONSAI_C4/configs/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,9 @@

// FRAM configuration
#ifndef EXTERNAL_EEPROM_SPI_SLAVE_SELECT_PIN
# define EEPROM_SPI_MB85RS64V
# define EXTERNAL_EEPROM_SPI_SLAVE_SELECT_PIN PAL_LINE(GPIOA, 0)
# define EXTERNAL_EEPROM_SPI_CLOCK_DIVISOR 8 // 96MHz / 8 = 12MHz; max supported by MB85R64 is 20MHz
# define EXTERNAL_EEPROM_BYTE_COUNT 8192
# define EXTERNAL_EEPROM_PAGE_SIZE 64 // does not matter for FRAM, just sets the RAM buffer size in STM32F chip
# define DYNAMIC_KEYMAP_EEPROM_MAX_ADDR 8191
#endif

// External flash configuration
Expand Down

0 comments on commit bf6f13a

Please sign in to comment.