Browse Source

Extend available EEPROM driver config

zvecr 2 years ago
parent
commit
668c29ca52

+ 3 - 0
data/mappings/info_config.hjson

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

+ 17 - 0
data/schemas/keyboard.jsonschema

@@ -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,

+ 0 - 4
keyboards/drop/alt/v2/config.h

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

+ 6 - 1
keyboards/drop/alt/v2/info.json

@@ -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,

+ 0 - 4
keyboards/drop/cstm80/config.h

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

+ 6 - 1
keyboards/drop/cstm80/info.json

@@ -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,

+ 0 - 4
keyboards/drop/ctrl/v2/config.h

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

+ 6 - 1
keyboards/drop/ctrl/v2/info.json

@@ -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,

+ 0 - 4
keyboards/drop/sense75/config.h

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

+ 6 - 1
keyboards/drop/sense75/info.json

@@ -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,

+ 0 - 4
keyboards/drop/shift/v2/config.h

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

+ 6 - 1
keyboards/drop/shift/v2/info.json

@@ -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,

+ 14 - 0
lib/python/qmk/cli/generate/config_h.py

@@ -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 = []
@@ -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)