Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extend available EEPROM driver config #22322

Draft
wants to merge 1 commit into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions data/mappings/info_config.hjson
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@
"DYNAMIC_KEYMAP_LAYER_COUNT": {"info_key": "dynamic_keymap.layer_count", "value_type": "int"},

// EEPROM
"EXTERNAL_EEPROM_WP_PIN": {"info_key": "eeprom.i2c.write_protect_pin"},
"EXTERNAL_EEPROM_I2C_BASE_ADDRESS": {"info_key": "eeprom.i2c.address", "to_json": false},
"EXTERNAL_EEPROM_SPI_SLAVE_SELECT_PIN": {"info_key": "eeprom.spi.chip_select_pin"},
"WEAR_LEVELING_BACKING_SIZE": {"info_key": "eeprom.wear_leveling.backing_size", "value_type": "int", "to_json": false},
"WEAR_LEVELING_LOGICAL_SIZE": {"info_key": "eeprom.wear_leveling.logical_size", "value_type": "int", "to_json": false},

Expand Down
17 changes: 17 additions & 0 deletions data/schemas/keyboard.jsonschema
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,23 @@
"eeprom": {
"properties": {
"driver": {"type": "string"},
"i2c": {
"type": "object",
"additionalProperties": false,
"properties": {
"device": {"type": "string"},
"address": {"$ref": "qmk.definitions.v1#/hex_number_2d"},
"write_protect_pin": {"$ref": "qmk.definitions.v1#/mcu_pin"}
}
},
"spi": {
"type": "object",
"additionalProperties": false,
"properties": {
"device": {"type": "string"},
"chip_select_pin": {"$ref": "qmk.definitions.v1#/mcu_pin"}
}
},
"wear_leveling": {
"type": "object",
"additionalProperties": false,
Expand Down
4 changes: 0 additions & 4 deletions keyboards/drop/alt/v2/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@
#define I2C1_SCL_PIN A9
#define I2C1_SDA_PIN A10

#define EXTERNAL_EEPROM_I2C_BASE_ADDRESS 0b10101000
#define EXTERNAL_EEPROM_WP_PIN B5
#define EEPROM_I2C_24LC256

#define IS31FL3733_I2C_ADDRESS_1 IS31FL3733_I2C_ADDRESS_GND_VCC
#define IS31FL3733_I2C_ADDRESS_2 IS31FL3733_I2C_ADDRESS_VCC_VCC
#define IS31FL3733_DRIVER_COUNT 2
Expand Down
7 changes: 6 additions & 1 deletion keyboards/drop/alt/v2/info.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,12 @@
"device_version": "2.0.0"
},
"eeprom": {
"driver": "i2c"
"driver": "i2c",
"i2c": {
"device": "24lc256",
"address": "0xA8",
"write_protect_pin": "B5"
}
},
"features": {
"rgb_matrix": true,
Expand Down
4 changes: 0 additions & 4 deletions keyboards/drop/cstm80/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@
#define I2C1_SCL_PIN B8
#define I2C1_SDA_PIN B9

#define EXTERNAL_EEPROM_I2C_BASE_ADDRESS 0b10101000
#define EXTERNAL_EEPROM_WP_PIN B7
#define EEPROM_I2C_24LC256

#define IS31FL3733_I2C_ADDRESS_1 IS31FL3733_I2C_ADDRESS_GND_GND
#define IS31FL3733_I2C_ADDRESS_2 IS31FL3733_I2C_ADDRESS_VCC_VCC
#define IS31FL3733_DRIVER_COUNT 2
Expand Down
7 changes: 6 additions & 1 deletion keyboards/drop/cstm80/info.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,12 @@
"device_version": "1.0.0"
},
"eeprom": {
"driver": "i2c"
"driver": "i2c",
"i2c": {
"device": "24lc256",
"address": "0xA8",
"write_protect_pin": "B5"
}
},
"features": {
"rgb_matrix": true,
Expand Down
4 changes: 0 additions & 4 deletions keyboards/drop/ctrl/v2/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@
#define I2C1_SCL_PIN A9
#define I2C1_SDA_PIN A10

#define EXTERNAL_EEPROM_I2C_BASE_ADDRESS 0b10101000
#define EXTERNAL_EEPROM_WP_PIN B5
#define EEPROM_I2C_24LC256

#define IS31FL3733_I2C_ADDRESS_1 IS31FL3733_I2C_ADDRESS_GND_VCC
#define IS31FL3733_I2C_ADDRESS_2 IS31FL3733_I2C_ADDRESS_VCC_VCC
#define IS31FL3733_DRIVER_COUNT 2
Expand Down
7 changes: 6 additions & 1 deletion keyboards/drop/ctrl/v2/info.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,12 @@
"device_version": "2.0.0"
},
"eeprom": {
"driver": "i2c"
"driver": "i2c",
"i2c": {
"device": "24lc256",
"address": "0xA8",
"write_protect_pin": "B5"
}
},
"features": {
"rgb_matrix": true,
Expand Down
4 changes: 0 additions & 4 deletions keyboards/drop/sense75/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@
#define I2C1_SCL_PIN B8
#define I2C1_SDA_PIN B9

#define EXTERNAL_EEPROM_I2C_BASE_ADDRESS 0b10101000
#define EXTERNAL_EEPROM_WP_PIN B7
#define EEPROM_I2C_24LC256

#define IS31FL3733_I2C_ADDRESS_1 IS31FL3733_I2C_ADDRESS_GND_GND
#define IS31FL3733_I2C_ADDRESS_2 IS31FL3733_I2C_ADDRESS_VCC_VCC
#define IS31FL3733_DRIVER_COUNT 2
Expand Down
7 changes: 6 additions & 1 deletion keyboards/drop/sense75/info.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,12 @@
"device_version": "1.0.0"
},
"eeprom": {
"driver": "i2c"
"driver": "i2c",
"i2c": {
"device": "24lc256",
"address": "0xA8",
"write_protect_pin": "B5"
}
},
"features": {
"rgb_matrix": true,
Expand Down
4 changes: 0 additions & 4 deletions keyboards/drop/shift/v2/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@
#define I2C1_SCL_PIN A9
#define I2C1_SDA_PIN A10

#define EXTERNAL_EEPROM_I2C_BASE_ADDRESS 0b10101000
#define EXTERNAL_EEPROM_WP_PIN B5
#define EEPROM_I2C_24LC256

#define IS31FL3733_I2C_ADDRESS_1 IS31FL3733_I2C_ADDRESS_GND_VCC
#define IS31FL3733_I2C_ADDRESS_2 IS31FL3733_I2C_ADDRESS_VCC_VCC
#define IS31FL3733_I2C_ADDRESS_3 IS31FL3733_I2C_ADDRESS_GND_GND
Expand Down
7 changes: 6 additions & 1 deletion keyboards/drop/shift/v2/info.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,12 @@
"device_version": "2.0.0"
},
"eeprom": {
"driver": "i2c"
"driver": "i2c",
"i2c": {
"device": "24lc256",
"address": "0xA8",
"write_protect_pin": "B5"
}
},
"features": {
"rgb_matrix": true,
Expand Down
14 changes: 14 additions & 0 deletions lib/python/qmk/cli/generate/config_h.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,17 @@ def generate_config_items(kb_info_json, config_h_lines):
config_h_lines.append(generate_define(config_key, config_value))


def generate_eeprom_config(eeprom_json, config_h_lines):
"""Generate the config.h lines for eeprom."""
if 'driver' in eeprom_json:
driver = eeprom_json['driver']
if driver in eeprom_json:
driver_json = eeprom_json[driver]
if 'device' in driver_json:
device = driver_json['device']
config_h_lines.append(generate_define(f'EEPROM_{driver.upper()}_{device.upper()}'))


def generate_encoder_config(encoder_json, config_h_lines, postfix=''):
"""Generate the config.h lines for encoders."""
a_pads = []
Expand Down Expand Up @@ -199,6 +210,9 @@ def generate_config_h(cli):
if 'matrix_pins' in kb_info_json:
config_h_lines.append(matrix_pins(kb_info_json['matrix_pins']))

if 'eeprom' in kb_info_json:
generate_eeprom_config(kb_info_json['eeprom'], config_h_lines)

if 'encoder' in kb_info_json:
generate_encoder_config(kb_info_json['encoder'], config_h_lines)

Expand Down