From 909054c35772ae62d6d2de0cefd1bef18762e754 Mon Sep 17 00:00:00 2001 From: Joel Challis Date: Tue, 12 Sep 2023 06:47:12 +0100 Subject: Migrate spi_flash WEAR_LEVELING_DRIVER to info.json (#21978) --- keyboards/annepro2/c15/info.json | 6 ++++++ keyboards/annepro2/c15/rules.mk | 4 ---- keyboards/annepro2/c18/info.json | 6 ++++++ keyboards/annepro2/c18/rules.mk | 4 ---- 4 files changed, 12 insertions(+), 8 deletions(-) (limited to 'keyboards/annepro2') diff --git a/keyboards/annepro2/c15/info.json b/keyboards/annepro2/c15/info.json index 15c3ca8ba1..7138294987 100644 --- a/keyboards/annepro2/c15/info.json +++ b/keyboards/annepro2/c15/info.json @@ -3,6 +3,12 @@ "usb": { "pid": "0xAC15" }, + "eeprom": { + "driver": "wear_leveling", + "wear_leveling": { + "driver": "spi_flash" + } + }, "rgb_matrix": { "driver": "custom" }, diff --git a/keyboards/annepro2/c15/rules.mk b/keyboards/annepro2/c15/rules.mk index 05b715e034..8694893ac2 100644 --- a/keyboards/annepro2/c15/rules.mk +++ b/keyboards/annepro2/c15/rules.mk @@ -26,10 +26,6 @@ BACKLIGHT_ENABLE = no # Enable keyboard backlight functionality RGBLIGHT_ENABLE = no # Enable keyboard RGB underglow AUDIO_ENABLE = no # Audio output -# Wear-levelling driver -EEPROM_DRIVER = wear_leveling -WEAR_LEVELING_DRIVER = spi_flash - # Custom RGB matrix handling RGB_MATRIX_ENABLE = yes diff --git a/keyboards/annepro2/c18/info.json b/keyboards/annepro2/c18/info.json index f7acff808c..439188b2f7 100644 --- a/keyboards/annepro2/c18/info.json +++ b/keyboards/annepro2/c18/info.json @@ -3,6 +3,12 @@ "usb": { "pid": "0xAC18" }, + "eeprom": { + "driver": "wear_leveling", + "wear_leveling": { + "driver": "spi_flash" + } + }, "rgb_matrix": { "driver": "custom" }, diff --git a/keyboards/annepro2/c18/rules.mk b/keyboards/annepro2/c18/rules.mk index 1d53851df6..dab7269570 100644 --- a/keyboards/annepro2/c18/rules.mk +++ b/keyboards/annepro2/c18/rules.mk @@ -26,10 +26,6 @@ BACKLIGHT_ENABLE = no # Enable keyboard backlight functionality RGBLIGHT_ENABLE = no # Enable keyboard RGB underglow AUDIO_ENABLE = no # Audio output -# Wear-levelling driver -EEPROM_DRIVER = wear_leveling -WEAR_LEVELING_DRIVER = spi_flash - # Custom RGB matrix handling RGB_MATRIX_ENABLE = yes -- cgit v1.2.3 From 00feff656f80d9c9bf57cb1c6ad94ef2f69f1440 Mon Sep 17 00:00:00 2001 From: Joel Challis Date: Thu, 14 Sep 2023 00:13:19 +0100 Subject: Migrate WEAR_LEVELING_*_SIZE to info.json (#22010) --- keyboards/akko/5108/config.h | 1 - keyboards/akko/5108/info.json | 3 ++- keyboards/akko/acr87/config.h | 1 - keyboards/akko/acr87/info.json | 3 ++- keyboards/akko/top40/config.h | 1 - keyboards/akko/top40/info.json | 3 ++- keyboards/annepro2/c15/config.h | 4 ---- keyboards/annepro2/c15/info.json | 3 ++- keyboards/annepro2/c18/config.h | 4 ---- keyboards/annepro2/c18/info.json | 3 ++- keyboards/binepad/bn006/config.h | 8 -------- keyboards/binepad/bn006/info.json | 5 +++++ keyboards/binepad/bn006/rules.mk | 6 +----- keyboards/binepad/bn009/r2/config.h | 12 ------------ keyboards/binepad/bn009/r2/info.json | 5 +++++ keyboards/binepad/bnr1/v2/config.h | 7 ------- keyboards/chosfox/cf81/config.h | 1 - keyboards/chosfox/cf81/info.json | 3 ++- keyboards/gmmk/gmmk2/p96/ansi/info.json | 3 ++- keyboards/gmmk/gmmk2/p96/config.h | 1 - keyboards/gmmk/gmmk2/p96/iso/info.json | 3 ++- keyboards/gmmk/numpad/config.h | 1 - keyboards/gmmk/numpad/info.json | 3 ++- keyboards/gmmk/pro/rev2/ansi/info.json | 3 ++- keyboards/gmmk/pro/rev2/config.h | 1 - keyboards/gmmk/pro/rev2/iso/info.json | 3 ++- keyboards/hfdkb/ac001/config.h | 1 - keyboards/hfdkb/ac001/info.json | 3 ++- keyboards/horrortroll/handwired_k552/config.h | 4 ---- keyboards/horrortroll/handwired_k552/info.json | 3 ++- keyboards/ibm/model_m/yugo_m/config.h | 4 ---- keyboards/ibm/model_m/yugo_m/info.json | 5 +++++ keyboards/inland/kb83/config.h | 1 - keyboards/inland/kb83/info.json | 3 ++- keyboards/inland/mk47/config.h | 1 - keyboards/inland/mk47/info.json | 3 ++- keyboards/mechlovin/hex6c/config.h | 3 --- keyboards/mechlovin/hex6c/info.json | 5 +++++ keyboards/mode/m75h/config.h | 21 --------------------- keyboards/mode/m75h/info.json | 5 +++++ keyboards/mode/m75s/config.h | 3 --- keyboards/mode/m75s/info.json | 5 +++++ keyboards/monsgeek/m1/config.h | 1 - keyboards/monsgeek/m1/info.json | 3 ++- keyboards/monsgeek/m5/config.h | 1 - keyboards/monsgeek/m5/info.json | 3 ++- keyboards/monsgeek/m6/config.h | 1 - keyboards/monsgeek/m6/info.json | 3 ++- keyboards/projectd/65/projectd_65_ansi/config.h | 1 - keyboards/projectd/65/projectd_65_ansi/info.json | 3 ++- keyboards/rgbkb/mun/config.h | 3 --- keyboards/rgbkb/mun/rev1/info.json | 5 +++++ keyboards/rgbkb/sol3/config.h | 3 --- keyboards/rgbkb/sol3/rev1/info.json | 5 +++++ keyboards/xelus/kangaroo/rev2/config.h | 3 --- keyboards/xelus/kangaroo/rev2/info.json | 5 +++++ keyboards/xelus/rs60/rev2_1/config.h | 3 --- keyboards/xelus/rs60/rev2_1/info.json | 5 +++++ 58 files changed, 89 insertions(+), 120 deletions(-) delete mode 100644 keyboards/binepad/bn009/r2/config.h delete mode 100644 keyboards/binepad/bnr1/v2/config.h delete mode 100644 keyboards/mode/m75h/config.h (limited to 'keyboards/annepro2') diff --git a/keyboards/akko/5108/config.h b/keyboards/akko/5108/config.h index 4c04933bcf..790830c88b 100644 --- a/keyboards/akko/5108/config.h +++ b/keyboards/akko/5108/config.h @@ -35,7 +35,6 @@ #define SPI_MOSI_PAL_MODE 5 #define EXTERNAL_FLASH_SPI_SLAVE_SELECT_PIN C12 -#define WEAR_LEVELING_BACKING_SIZE (8 * 1024) /* I2C Config for LED Driver */ #define IS31FL3733_DRIVER_COUNT 2 diff --git a/keyboards/akko/5108/info.json b/keyboards/akko/5108/info.json index 74379db27b..ef3f85a1ec 100644 --- a/keyboards/akko/5108/info.json +++ b/keyboards/akko/5108/info.json @@ -29,7 +29,8 @@ "eeprom": { "driver": "wear_leveling", "wear_leveling": { - "driver": "spi_flash" + "driver": "spi_flash", + "backing_size": 8192 } }, "indicators": { diff --git a/keyboards/akko/acr87/config.h b/keyboards/akko/acr87/config.h index 6e4d8dd574..3f61359074 100644 --- a/keyboards/akko/acr87/config.h +++ b/keyboards/akko/acr87/config.h @@ -32,7 +32,6 @@ #define SPI_MOSI_PAL_MODE 5 #define EXTERNAL_FLASH_SPI_SLAVE_SELECT_PIN C12 -#define WEAR_LEVELING_BACKING_SIZE (8 * 1024) /* I2C Config for LED Driver */ #define IS31FL3733_DRIVER_COUNT 3 diff --git a/keyboards/akko/acr87/info.json b/keyboards/akko/acr87/info.json index 5ce22462d9..f9d360282d 100644 --- a/keyboards/akko/acr87/info.json +++ b/keyboards/akko/acr87/info.json @@ -29,7 +29,8 @@ "eeprom": { "driver": "wear_leveling", "wear_leveling": { - "driver": "spi_flash" + "driver": "spi_flash", + "backing_size": 8192 } }, "rgb_matrix": { diff --git a/keyboards/akko/top40/config.h b/keyboards/akko/top40/config.h index e8672856ef..cc72977c4d 100644 --- a/keyboards/akko/top40/config.h +++ b/keyboards/akko/top40/config.h @@ -32,7 +32,6 @@ #define SPI_MOSI_PAL_MODE 5 #define EXTERNAL_FLASH_SPI_SLAVE_SELECT_PIN C12 -#define WEAR_LEVELING_BACKING_SIZE (8 * 1024) /* I2C Config for LED Driver */ #define IS31FL3733_DRIVER_COUNT 2 diff --git a/keyboards/akko/top40/info.json b/keyboards/akko/top40/info.json index e66f79e6c0..3624ee0411 100644 --- a/keyboards/akko/top40/info.json +++ b/keyboards/akko/top40/info.json @@ -29,7 +29,8 @@ "eeprom": { "driver": "wear_leveling", "wear_leveling": { - "driver": "spi_flash" + "driver": "spi_flash", + "backing_size": 8192 } }, "rgb_matrix": { diff --git a/keyboards/annepro2/c15/config.h b/keyboards/annepro2/c15/config.h index ea38f4dce3..f488b9d8f3 100644 --- a/keyboards/annepro2/c15/config.h +++ b/keyboards/annepro2/c15/config.h @@ -57,7 +57,3 @@ #define EXTERNAL_FLASH_SECTOR_SIZE 4096 #define EXTERNAL_FLASH_BLOCK_SIZE 4096 #define EXTERNAL_FLASH_SIZE (256 * 1024) // 2M-bit flash size - -// Wear-leveling driver configuration -#define WEAR_LEVELING_LOGICAL_SIZE 1024 -#define WEAR_LEVELING_BACKING_SIZE (WEAR_LEVELING_LOGICAL_SIZE * 2) diff --git a/keyboards/annepro2/c15/info.json b/keyboards/annepro2/c15/info.json index 7138294987..b7624dd6c5 100644 --- a/keyboards/annepro2/c15/info.json +++ b/keyboards/annepro2/c15/info.json @@ -6,7 +6,8 @@ "eeprom": { "driver": "wear_leveling", "wear_leveling": { - "driver": "spi_flash" + "driver": "spi_flash", + "backing_size": 2048 } }, "rgb_matrix": { diff --git a/keyboards/annepro2/c18/config.h b/keyboards/annepro2/c18/config.h index 6b6307c3d0..36f4a25c8d 100644 --- a/keyboards/annepro2/c18/config.h +++ b/keyboards/annepro2/c18/config.h @@ -55,7 +55,3 @@ #define EXTERNAL_FLASH_SECTOR_SIZE 4096 #define EXTERNAL_FLASH_BLOCK_SIZE 4096 #define EXTERNAL_FLASH_SIZE (256 * 1024) // 2M-bit flash size - -// Wear-leveling driver configuration -#define WEAR_LEVELING_LOGICAL_SIZE 1024 -#define WEAR_LEVELING_BACKING_SIZE (WEAR_LEVELING_LOGICAL_SIZE * 2) diff --git a/keyboards/annepro2/c18/info.json b/keyboards/annepro2/c18/info.json index 439188b2f7..c8f524e3cf 100644 --- a/keyboards/annepro2/c18/info.json +++ b/keyboards/annepro2/c18/info.json @@ -6,7 +6,8 @@ "eeprom": { "driver": "wear_leveling", "wear_leveling": { - "driver": "spi_flash" + "driver": "spi_flash", + "backing_size": 2048 } }, "rgb_matrix": { diff --git a/keyboards/binepad/bn006/config.h b/keyboards/binepad/bn006/config.h index 41c3822655..0569ccff03 100755 --- a/keyboards/binepad/bn006/config.h +++ b/keyboards/binepad/bn006/config.h @@ -3,14 +3,6 @@ #pragma once -/* - * Wear Leveling EEPROM Emulation - */ - -#define WEAR_LEVELING_LOGICAL_SIZE 2048 // Number of bytes "exposed" to the rest of QMK and denotes the size of the usable EEPROM. -#define WEAR_LEVELING_BACKING_SIZE (WEAR_LEVELING_LOGICAL_SIZE * 2) // Number of bytes used by the wear-leveling algorithm for its underlying storage, and needs to be a multiple of the logical size. - - /* * RGB Matrix */ diff --git a/keyboards/binepad/bn006/info.json b/keyboards/binepad/bn006/info.json index 756b82e330..81e68d2e0c 100755 --- a/keyboards/binepad/bn006/info.json +++ b/keyboards/binepad/bn006/info.json @@ -24,6 +24,11 @@ "pid": "0x426E", "device_version": "1.0.0" }, + "eeprom": { + "wear_leveling": { + "backing_size": 4096 + } + }, "ws2812": { "pin": "B15" }, diff --git a/keyboards/binepad/bn006/rules.mk b/keyboards/binepad/bn006/rules.mk index 58561c984b..7ff128fa69 100755 --- a/keyboards/binepad/bn006/rules.mk +++ b/keyboards/binepad/bn006/rules.mk @@ -1,5 +1 @@ -# Copyright 2022 Binepad (@binpad) -# SPDX-License-Identifier: GPL-2.0-or-later - -EPROM_DRIVER = wear_leveling -WEAR_LEVELING_DRIVER = embedded_flash +# This file intentionally left blank \ No newline at end of file diff --git a/keyboards/binepad/bn009/r2/config.h b/keyboards/binepad/bn009/r2/config.h deleted file mode 100644 index 45b63ec105..0000000000 --- a/keyboards/binepad/bn009/r2/config.h +++ /dev/null @@ -1,12 +0,0 @@ -// Copyright 2023 Binepad (@binepad) -// SPDX-License-Identifier: GPL-2.0-or-later - -#pragma once - - -/* - * Wear Leveling EEPROM Emulation - */ - -#define WEAR_LEVELING_LOGICAL_SIZE 2048 // Number of bytes "exposed" to the rest of QMK and denotes the size of the usable EEPROM. -#define WEAR_LEVELING_BACKING_SIZE (WEAR_LEVELING_LOGICAL_SIZE * 2) // Number of bytes used by the wear-leveling algorithm for its underlying storage, and needs to be a multiple of the logical size. diff --git a/keyboards/binepad/bn009/r2/info.json b/keyboards/binepad/bn009/r2/info.json index c011fe0e32..870608b5c8 100644 --- a/keyboards/binepad/bn009/r2/info.json +++ b/keyboards/binepad/bn009/r2/info.json @@ -6,6 +6,11 @@ "cols": ["A1", "A2", "A6"], "rows": ["B6", "B7", "B2"] }, + "eeprom": { + "wear_leveling": { + "backing_size": 4096 + } + }, "processor": "STM32F103", "usb": { "device_version": "2.0.0" diff --git a/keyboards/binepad/bnr1/v2/config.h b/keyboards/binepad/bnr1/v2/config.h deleted file mode 100644 index c408f95d38..0000000000 --- a/keyboards/binepad/bnr1/v2/config.h +++ /dev/null @@ -1,7 +0,0 @@ -// Copyright 2022 BINEPAD (@binepad) -// SPDX-License-Identifier: GPL-2.0-or-later - -#pragma once - -#define WEAR_LEVELING_LOGICAL_SIZE 1024 -#define WEAR_LEVELING_BACKING_SIZE (WEAR_LEVELING_LOGICAL_SIZE * 2) diff --git a/keyboards/chosfox/cf81/config.h b/keyboards/chosfox/cf81/config.h index 95b2aca688..e837c9745b 100644 --- a/keyboards/chosfox/cf81/config.h +++ b/keyboards/chosfox/cf81/config.h @@ -32,7 +32,6 @@ #define SPI_MOSI_PAL_MODE 5 #define EXTERNAL_FLASH_SPI_SLAVE_SELECT_PIN C12 -#define WEAR_LEVELING_BACKING_SIZE (8 * 1024) /* I2C Config for LED Driver */ #define IS31FL3733_DRIVER_COUNT 2 diff --git a/keyboards/chosfox/cf81/info.json b/keyboards/chosfox/cf81/info.json index 65134dfedf..bbfc2deb31 100644 --- a/keyboards/chosfox/cf81/info.json +++ b/keyboards/chosfox/cf81/info.json @@ -12,7 +12,8 @@ "eeprom": { "driver": "wear_leveling", "wear_leveling": { - "driver": "spi_flash" + "driver": "spi_flash", + "backing_size": 8192 } }, "processor": "WB32FQ95", diff --git a/keyboards/gmmk/gmmk2/p96/ansi/info.json b/keyboards/gmmk/gmmk2/p96/ansi/info.json index b80e334e0a..e4eaddbfe8 100644 --- a/keyboards/gmmk/gmmk2/p96/ansi/info.json +++ b/keyboards/gmmk/gmmk2/p96/ansi/info.json @@ -22,7 +22,8 @@ "eeprom": { "driver": "wear_leveling", "wear_leveling": { - "driver": "spi_flash" + "driver": "spi_flash", + "backing_size": 2048 } }, "processor": "WB32F3G71", diff --git a/keyboards/gmmk/gmmk2/p96/config.h b/keyboards/gmmk/gmmk2/p96/config.h index 4200bae922..9a5a2bf8a4 100644 --- a/keyboards/gmmk/gmmk2/p96/config.h +++ b/keyboards/gmmk/gmmk2/p96/config.h @@ -25,7 +25,6 @@ /* External spi flash */ #define EXTERNAL_FLASH_SPI_SLAVE_SELECT_PIN B14 -#define WEAR_LEVELING_BACKING_SIZE 2048 /* SPI Config for LED Driver */ #define SPI_DRIVER SPIDQ diff --git a/keyboards/gmmk/gmmk2/p96/iso/info.json b/keyboards/gmmk/gmmk2/p96/iso/info.json index ee59bfd4ff..42b40231b6 100644 --- a/keyboards/gmmk/gmmk2/p96/iso/info.json +++ b/keyboards/gmmk/gmmk2/p96/iso/info.json @@ -22,7 +22,8 @@ "eeprom": { "driver": "wear_leveling", "wear_leveling": { - "driver": "spi_flash" + "driver": "spi_flash", + "backing_size": 2048 } }, "processor": "WB32F3G71", diff --git a/keyboards/gmmk/numpad/config.h b/keyboards/gmmk/numpad/config.h index 9096ce1d56..24a7a24a3f 100644 --- a/keyboards/gmmk/numpad/config.h +++ b/keyboards/gmmk/numpad/config.h @@ -37,7 +37,6 @@ #define RGB_MATRIX_LED_COUNT 31 #define EXTERNAL_FLASH_SPI_SLAVE_SELECT_PIN B6 -#define WEAR_LEVELING_BACKING_SIZE 2048 #define ENABLE_RGB_MATRIX_ALPHAS_MODS #define ENABLE_RGB_MATRIX_GRADIENT_UP_DOWN diff --git a/keyboards/gmmk/numpad/info.json b/keyboards/gmmk/numpad/info.json index 406f22603a..83f7d840dc 100644 --- a/keyboards/gmmk/numpad/info.json +++ b/keyboards/gmmk/numpad/info.json @@ -11,7 +11,8 @@ "eeprom": { "driver": "wear_leveling", "wear_leveling": { - "driver": "spi_flash" + "driver": "spi_flash", + "backing_size": 2048 } }, "encoder": { diff --git a/keyboards/gmmk/pro/rev2/ansi/info.json b/keyboards/gmmk/pro/rev2/ansi/info.json index 968a1952ee..cd1fd31bf0 100644 --- a/keyboards/gmmk/pro/rev2/ansi/info.json +++ b/keyboards/gmmk/pro/rev2/ansi/info.json @@ -19,7 +19,8 @@ "eeprom": { "driver": "wear_leveling", "wear_leveling": { - "driver": "spi_flash" + "driver": "spi_flash", + "backing_size": 2048 } }, "encoder": { diff --git a/keyboards/gmmk/pro/rev2/config.h b/keyboards/gmmk/pro/rev2/config.h index fa409ba026..c393e04e45 100644 --- a/keyboards/gmmk/pro/rev2/config.h +++ b/keyboards/gmmk/pro/rev2/config.h @@ -19,7 +19,6 @@ /* External spi flash */ #define EXTERNAL_FLASH_SPI_SLAVE_SELECT_PIN B12 -#define WEAR_LEVELING_BACKING_SIZE 2048 /* SPI Config for LED Driver */ #define SPI_DRIVER SPIDQ diff --git a/keyboards/gmmk/pro/rev2/iso/info.json b/keyboards/gmmk/pro/rev2/iso/info.json index 54ebc2d2f7..6233356616 100644 --- a/keyboards/gmmk/pro/rev2/iso/info.json +++ b/keyboards/gmmk/pro/rev2/iso/info.json @@ -19,7 +19,8 @@ "eeprom": { "driver": "wear_leveling", "wear_leveling": { - "driver": "spi_flash" + "driver": "spi_flash", + "backing_size": 2048 } }, "encoder": { diff --git a/keyboards/hfdkb/ac001/config.h b/keyboards/hfdkb/ac001/config.h index 6c0c2a2cf6..7d38c7392c 100644 --- a/keyboards/hfdkb/ac001/config.h +++ b/keyboards/hfdkb/ac001/config.h @@ -32,7 +32,6 @@ #define SPI_MOSI_PAL_MODE 5 #define EXTERNAL_FLASH_SPI_SLAVE_SELECT_PIN C12 -#define WEAR_LEVELING_BACKING_SIZE (8 * 1024) #define RGB_DISABLE_WHEN_USB_SUSPENDED // turn off effects when suspended diff --git a/keyboards/hfdkb/ac001/info.json b/keyboards/hfdkb/ac001/info.json index 36583e2e58..3f896d5988 100644 --- a/keyboards/hfdkb/ac001/info.json +++ b/keyboards/hfdkb/ac001/info.json @@ -20,7 +20,8 @@ "eeprom": { "driver": "wear_leveling", "wear_leveling": { - "driver": "spi_flash" + "driver": "spi_flash", + "backing_size": 8192 } }, "ws2812": { diff --git a/keyboards/horrortroll/handwired_k552/config.h b/keyboards/horrortroll/handwired_k552/config.h index bec0ac055b..11461a9418 100644 --- a/keyboards/horrortroll/handwired_k552/config.h +++ b/keyboards/horrortroll/handwired_k552/config.h @@ -30,10 +30,6 @@ #define EXTERNAL_FLASH_BLOCK_SIZE 4096 #define EXTERNAL_FLASH_SIZE (256 * 1024) // 2M-bit flash size -// Wear-leveling driver configuration -#define WEAR_LEVELING_LOGICAL_SIZE 1024 -#define WEAR_LEVELING_BACKING_SIZE (WEAR_LEVELING_LOGICAL_SIZE * 2) - #ifdef OLED_ENABLE /* Mapping I2C2 for OLED */ #define I2C1_SCL_PIN B10 diff --git a/keyboards/horrortroll/handwired_k552/info.json b/keyboards/horrortroll/handwired_k552/info.json index 2c97ce1306..b064df38c2 100644 --- a/keyboards/horrortroll/handwired_k552/info.json +++ b/keyboards/horrortroll/handwired_k552/info.json @@ -23,7 +23,8 @@ "eeprom": { "driver": "wear_leveling", "wear_leveling": { - "driver": "spi_flash" + "driver": "spi_flash", + "backing_size": 2048 } }, "community_layouts": ["tkl_ansi"], diff --git a/keyboards/ibm/model_m/yugo_m/config.h b/keyboards/ibm/model_m/yugo_m/config.h index 2b7fc4d157..0e6881ded3 100644 --- a/keyboards/ibm/model_m/yugo_m/config.h +++ b/keyboards/ibm/model_m/yugo_m/config.h @@ -36,7 +36,3 @@ along with this program. If not, see . //#define NO_ACTION_LAYER //#define NO_ACTION_TAPPING //#define NO_ACTION_ONESHOT - -/* redefine available (emulated) EEPROM as 4 kB rather than the default 2 kB to let VIA use more of the on-chip Flash of the STM32F303 to store 4 layers (since 4 layers * 8 rows * 16 columns * 2 = 1024 bytes but the default max available is 1023 bytes due to ATMEGA32U4 etc. only having 1 kB of EEPROM) */ -#define WEAR_LEVELING_BACKING_SIZE 4096 -#define WEAR_LEVELING_LOGICAL_SIZE 2048 diff --git a/keyboards/ibm/model_m/yugo_m/info.json b/keyboards/ibm/model_m/yugo_m/info.json index 6e3a0b39c6..f4d9cc1d94 100644 --- a/keyboards/ibm/model_m/yugo_m/info.json +++ b/keyboards/ibm/model_m/yugo_m/info.json @@ -13,6 +13,11 @@ "rows": ["B8", "B7", "B6", "B5", "B4", "B3", "A15", "A14"] }, "diode_direction": "ROW2COL", + "eeprom": { + "wear_leveling": { + "backing_size": 4096 + } + }, "processor": "STM32F303", "bootloader": "stm32-dfu", "board": "QMK_PROTON_C", diff --git a/keyboards/inland/kb83/config.h b/keyboards/inland/kb83/config.h index e1b6702bd8..ed1f3cf160 100644 --- a/keyboards/inland/kb83/config.h +++ b/keyboards/inland/kb83/config.h @@ -36,7 +36,6 @@ #define SPI_MOSI_PAL_MODE 5 #define EXTERNAL_FLASH_SPI_SLAVE_SELECT_PIN C12 -#define WEAR_LEVELING_BACKING_SIZE (8 * 1024) /* I2C Config for LED Driver */ #define IS31FL3733_DRIVER_COUNT 2 diff --git a/keyboards/inland/kb83/info.json b/keyboards/inland/kb83/info.json index 33545515ad..cd538ef4ee 100644 --- a/keyboards/inland/kb83/info.json +++ b/keyboards/inland/kb83/info.json @@ -21,7 +21,8 @@ "eeprom": { "driver": "wear_leveling", "wear_leveling": { - "driver": "spi_flash" + "driver": "spi_flash", + "backing_size": 8192 } }, "encoder": { diff --git a/keyboards/inland/mk47/config.h b/keyboards/inland/mk47/config.h index 7004b38e63..db9aea328f 100644 --- a/keyboards/inland/mk47/config.h +++ b/keyboards/inland/mk47/config.h @@ -23,7 +23,6 @@ #define SPI_MISO_PIN B4 #define EXTERNAL_FLASH_SPI_SLAVE_SELECT_PIN C12 -#define WEAR_LEVELING_BACKING_SIZE (4 * 1024) /* I2C Config for LED Driver */ #define IS31FL3733_DRIVER_COUNT 1 diff --git a/keyboards/inland/mk47/info.json b/keyboards/inland/mk47/info.json index 2ed18eac3b..7d94365724 100644 --- a/keyboards/inland/mk47/info.json +++ b/keyboards/inland/mk47/info.json @@ -29,7 +29,8 @@ "eeprom": { "driver": "wear_leveling", "wear_leveling": { - "driver": "spi_flash" + "driver": "spi_flash", + "backing_size": 4096 } }, "rgb_matrix": { diff --git a/keyboards/mechlovin/hex6c/config.h b/keyboards/mechlovin/hex6c/config.h index 4cfcaebcde..e74e7939c4 100644 --- a/keyboards/mechlovin/hex6c/config.h +++ b/keyboards/mechlovin/hex6c/config.h @@ -18,6 +18,3 @@ along with this program. If not, see . #pragma once #define BACKLIGHT_PWM_DRIVER PWMD3 - -#define WEAR_LEVELING_BACKING_SIZE 4096 -#define WEAR_LEVELING_LOGICAL_SIZE 2048 diff --git a/keyboards/mechlovin/hex6c/info.json b/keyboards/mechlovin/hex6c/info.json index dfeb91e0ba..483566e7f4 100644 --- a/keyboards/mechlovin/hex6c/info.json +++ b/keyboards/mechlovin/hex6c/info.json @@ -13,6 +13,11 @@ "rows": ["A10", "B13", "B12", "B11", "C14", "C15"] }, "diode_direction": "COL2ROW", + "eeprom": { + "wear_leveling": { + "backing_size": 4096 + } + }, "encoder": { "rotary": [ {"pin_a": "A15", "pin_b": "A2"} diff --git a/keyboards/mode/m75h/config.h b/keyboards/mode/m75h/config.h deleted file mode 100644 index c6d7d037ec..0000000000 --- a/keyboards/mode/m75h/config.h +++ /dev/null @@ -1,21 +0,0 @@ -/* - Copyright 2020 Álvaro "Gondolindrim" Volpato - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 2 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see . -*/ - -#pragma once - -#define WEAR_LEVELING_LOGICAL_SIZE 2048 -#define WEAR_LEVELING_BACKING_SIZE 4096 diff --git a/keyboards/mode/m75h/info.json b/keyboards/mode/m75h/info.json index f57aac383e..8314dbf99d 100644 --- a/keyboards/mode/m75h/info.json +++ b/keyboards/mode/m75h/info.json @@ -13,6 +13,11 @@ "rows": ["C5", "B0", "B14", "B15", "A8", "C9", "A15"] }, "diode_direction": "COL2ROW", + "eeprom": { + "wear_leveling": { + "backing_size": 4096 + } + }, "processor": "STM32F401", "bootloader": "stm32-dfu", "layout_aliases": { diff --git a/keyboards/mode/m75s/config.h b/keyboards/mode/m75s/config.h index 7fdb18d26a..4d3a7d5ca4 100644 --- a/keyboards/mode/m75s/config.h +++ b/keyboards/mode/m75s/config.h @@ -20,6 +20,3 @@ along with this program. If not, see . #define BACKLIGHT_DEFAULT_LEVEL 20 #define BACKLIGHT_PWM_DRIVER PWMD3 #define BACKLIGHT_PWM_CHANNEL 1 - -#define WEAR_LEVELING_LOGICAL_SIZE 2048 -#define WEAR_LEVELING_BACKING_SIZE 4096 diff --git a/keyboards/mode/m75s/info.json b/keyboards/mode/m75s/info.json index bf60aebd56..df4d1ab451 100644 --- a/keyboards/mode/m75s/info.json +++ b/keyboards/mode/m75s/info.json @@ -13,6 +13,11 @@ "rows": ["C5", "B0", "B14", "B15", "C7", "C9", "A15"] }, "diode_direction": "COL2ROW", + "eeprom": { + "wear_leveling": { + "backing_size": 4096 + } + }, "backlight": { "pin": "C6", "levels": 20, diff --git a/keyboards/monsgeek/m1/config.h b/keyboards/monsgeek/m1/config.h index f5466ab09b..162001fca6 100644 --- a/keyboards/monsgeek/m1/config.h +++ b/keyboards/monsgeek/m1/config.h @@ -34,7 +34,6 @@ #define SPI_MOSI_PAL_MODE 5 #define EXTERNAL_FLASH_SPI_SLAVE_SELECT_PIN C12 -#define WEAR_LEVELING_BACKING_SIZE (8 * 1024) /* I2C Config for LED Driver */ #define IS31FL3733_DRIVER_COUNT 2 diff --git a/keyboards/monsgeek/m1/info.json b/keyboards/monsgeek/m1/info.json index fe979b7c31..a008b22195 100644 --- a/keyboards/monsgeek/m1/info.json +++ b/keyboards/monsgeek/m1/info.json @@ -29,7 +29,8 @@ "eeprom": { "driver": "wear_leveling", "wear_leveling": { - "driver": "spi_flash" + "driver": "spi_flash", + "backing_size": 8192 } }, "encoder": { diff --git a/keyboards/monsgeek/m5/config.h b/keyboards/monsgeek/m5/config.h index db65cef760..a92c4975eb 100644 --- a/keyboards/monsgeek/m5/config.h +++ b/keyboards/monsgeek/m5/config.h @@ -35,7 +35,6 @@ #define SPI_MOSI_PAL_MODE 5 #define EXTERNAL_FLASH_SPI_SLAVE_SELECT_PIN C12 -#define WEAR_LEVELING_BACKING_SIZE (8 * 1024) /* I2C Config for LED Driver */ #define IS31FL3733_DRIVER_COUNT 2 diff --git a/keyboards/monsgeek/m5/info.json b/keyboards/monsgeek/m5/info.json index ecc6b309ae..1e9ec8618a 100644 --- a/keyboards/monsgeek/m5/info.json +++ b/keyboards/monsgeek/m5/info.json @@ -28,7 +28,8 @@ "eeprom": { "driver": "wear_leveling", "wear_leveling": { - "driver": "spi_flash" + "driver": "spi_flash", + "backing_size": 8192 } }, "indicators": { diff --git a/keyboards/monsgeek/m6/config.h b/keyboards/monsgeek/m6/config.h index abed72f54e..c6f7d55e9d 100644 --- a/keyboards/monsgeek/m6/config.h +++ b/keyboards/monsgeek/m6/config.h @@ -32,7 +32,6 @@ #define SPI_MOSI_PAL_MODE 5 #define EXTERNAL_FLASH_SPI_SLAVE_SELECT_PIN C12 -#define WEAR_LEVELING_BACKING_SIZE (8 * 1024) /* I2C Config for LED Driver */ #define IS31FL3733_DRIVER_COUNT 2 diff --git a/keyboards/monsgeek/m6/info.json b/keyboards/monsgeek/m6/info.json index 2aa297570c..7751ef13d6 100644 --- a/keyboards/monsgeek/m6/info.json +++ b/keyboards/monsgeek/m6/info.json @@ -28,7 +28,8 @@ "eeprom": { "driver": "wear_leveling", "wear_leveling": { - "driver": "spi_flash" + "driver": "spi_flash", + "backing_size": 8192 } }, "rgb_matrix": { diff --git a/keyboards/projectd/65/projectd_65_ansi/config.h b/keyboards/projectd/65/projectd_65_ansi/config.h index 64e4595e1b..4d1dc100d8 100644 --- a/keyboards/projectd/65/projectd_65_ansi/config.h +++ b/keyboards/projectd/65/projectd_65_ansi/config.h @@ -25,7 +25,6 @@ /* External spi flash */ #define EXTERNAL_FLASH_SPI_SLAVE_SELECT_PIN B14 -#define WEAR_LEVELING_BACKING_SIZE (4 * 1024) /* SPI Config for LED Driver */ #define SPI_DRIVER SPIDQ diff --git a/keyboards/projectd/65/projectd_65_ansi/info.json b/keyboards/projectd/65/projectd_65_ansi/info.json index c385f00ed1..861e3792db 100644 --- a/keyboards/projectd/65/projectd_65_ansi/info.json +++ b/keyboards/projectd/65/projectd_65_ansi/info.json @@ -13,7 +13,8 @@ "eeprom": { "driver": "wear_leveling", "wear_leveling": { - "driver": "spi_flash" + "driver": "spi_flash", + "backing_size": 4096 } }, "features": { diff --git a/keyboards/rgbkb/mun/config.h b/keyboards/rgbkb/mun/config.h index fd2e366614..baf495b534 100644 --- a/keyboards/rgbkb/mun/config.h +++ b/keyboards/rgbkb/mun/config.h @@ -119,6 +119,3 @@ #define TOUCH_UPDATE_INTERVAL 33 #define OLED_UPDATE_INTERVAL 33 - -#define WEAR_LEVELING_BACKING_SIZE 4096 -#define WEAR_LEVELING_LOGICAL_SIZE 2048 diff --git a/keyboards/rgbkb/mun/rev1/info.json b/keyboards/rgbkb/mun/rev1/info.json index 5d380de5c7..91b60e76c3 100644 --- a/keyboards/rgbkb/mun/rev1/info.json +++ b/keyboards/rgbkb/mun/rev1/info.json @@ -37,6 +37,11 @@ "io_delay": 5 }, "diode_direction": "COL2ROW", + "eeprom": { + "wear_leveling": { + "backing_size": 4096 + } + }, "encoder": { "rotary": [ {"pin_a": "B8", "pin_b": "A14"}, diff --git a/keyboards/rgbkb/sol3/config.h b/keyboards/rgbkb/sol3/config.h index 3a0b61bfd5..575e5bcd95 100644 --- a/keyboards/rgbkb/sol3/config.h +++ b/keyboards/rgbkb/sol3/config.h @@ -125,6 +125,3 @@ #define AUDIO_CLICKY #define AUDIO_DAC_SAMPLE_WAVEFORM_SQUARE #define AUDIO_DAC_OFF_VALUE 0 - -#define WEAR_LEVELING_BACKING_SIZE 4096 -#define WEAR_LEVELING_LOGICAL_SIZE 2048 diff --git a/keyboards/rgbkb/sol3/rev1/info.json b/keyboards/rgbkb/sol3/rev1/info.json index b80161995f..7d3db933a8 100644 --- a/keyboards/rgbkb/sol3/rev1/info.json +++ b/keyboards/rgbkb/sol3/rev1/info.json @@ -37,6 +37,11 @@ "io_delay": 5 }, "diode_direction": "COL2ROW", + "eeprom": { + "wear_leveling": { + "backing_size": 4096 + } + }, "encoder": { "rotary": [ {"pin_a": "A1", "pin_b": "A2"}, diff --git a/keyboards/xelus/kangaroo/rev2/config.h b/keyboards/xelus/kangaroo/rev2/config.h index 790db9b30a..dfe8035b10 100644 --- a/keyboards/xelus/kangaroo/rev2/config.h +++ b/keyboards/xelus/kangaroo/rev2/config.h @@ -20,6 +20,3 @@ #define LOCKING_SUPPORT_ENABLE /* Locking resynchronize hack */ #define LOCKING_RESYNC_ENABLE - -#define WEAR_LEVELING_LOGICAL_SIZE 2048 -#define WEAR_LEVELING_BACKING_SIZE WEAR_LEVELING_LOGICAL_SIZE*2 diff --git a/keyboards/xelus/kangaroo/rev2/info.json b/keyboards/xelus/kangaroo/rev2/info.json index 196f11860b..9e639df034 100644 --- a/keyboards/xelus/kangaroo/rev2/info.json +++ b/keyboards/xelus/kangaroo/rev2/info.json @@ -8,6 +8,11 @@ "rows": ["A9", "A8", "B15", "B14", "B13", "B12", "A4", "A5", "A6", "A7", "B0", "B1"] }, "diode_direction": "COL2ROW", + "eeprom": { + "wear_leveling": { + "backing_size": 4096 + } + }, "processor": "STM32L412", "bootloader": "stm32-dfu" } diff --git a/keyboards/xelus/rs60/rev2_1/config.h b/keyboards/xelus/rs60/rev2_1/config.h index 1c5fe4a336..430a5a47f7 100644 --- a/keyboards/xelus/rs60/rev2_1/config.h +++ b/keyboards/xelus/rs60/rev2_1/config.h @@ -21,6 +21,3 @@ // Locking resynchronize hack #define LOCKING_RESYNC_ENABLE -// Emulated EEPROM -#define WEAR_LEVELING_LOGICAL_SIZE 2048 -#define WEAR_LEVELING_BACKING_SIZE WEAR_LEVELING_LOGICAL_SIZE*2 diff --git a/keyboards/xelus/rs60/rev2_1/info.json b/keyboards/xelus/rs60/rev2_1/info.json index 118a671547..fe87561e61 100644 --- a/keyboards/xelus/rs60/rev2_1/info.json +++ b/keyboards/xelus/rs60/rev2_1/info.json @@ -8,6 +8,11 @@ "rows": ["B15", "B14", "B12", "B1", "B0"] }, "diode_direction": "COL2ROW", + "eeprom": { + "wear_leveling": { + "backing_size": 4096 + } + }, "indicators": { "caps_lock": "A1", "on_state": 0 -- cgit v1.2.3 From 1bff37781bda1d0c285aa5aa7102d6941ad64e7d Mon Sep 17 00:00:00 2001 From: Ryan Date: Sat, 14 Oct 2023 22:21:20 +1100 Subject: Prep work for NKRO report separation (#22268) * Clean up some keyboard/userspace code * Rename `KEYBOARD_REPORT_BITS` -> `NKRO_REPORT_BITS` * Add some missing includes * Use `PACKED` define for report types * Fix incorrect function signatures for FlexRAM EEPROM driver --- keyboards/annepro2/annepro2_ble.c | 2 +- keyboards/bioi/bluetooth_custom.c | 13 ++++++------- keyboards/sawnsprojects/okayu/stm32f072/config.h | 2 +- keyboards/sawnsprojects/okayu/stm32f103/config.h | 2 +- keyboards/sawnsprojects/okayu/stm32f303/config.h | 2 +- .../chibios/drivers/eeprom/eeprom_kinetis_flexram.c | 8 ++++---- quantum/eeconfig.h | 1 + quantum/quantum.h | 2 ++ tmk_core/protocol/report.c | 8 ++++---- tmk_core/protocol/report.h | 19 ++++++++++--------- tmk_core/protocol/usb_descriptor.c | 4 ++-- users/brandonschlack/brandonschlack.c | 8 ++------ 12 files changed, 35 insertions(+), 36 deletions(-) (limited to 'keyboards/annepro2') diff --git a/keyboards/annepro2/annepro2_ble.c b/keyboards/annepro2/annepro2_ble.c index 375f551cc2..b04929e958 100644 --- a/keyboards/annepro2/annepro2_ble.c +++ b/keyboards/annepro2/annepro2_ble.c @@ -167,5 +167,5 @@ static void ap2_ble_extra(report_extra_t *report) { static void ap2_ble_keyboard(report_keyboard_t *report) { sdPut(&SD1, 0x0); sdWrite(&SD1, ble_mcu_send_report, sizeof(ble_mcu_send_report)); - sdWrite(&SD1, &report->raw[0], KEYBOARD_REPORT_SIZE); + sdWrite(&SD1, (uint8_t *)report, KEYBOARD_REPORT_SIZE); } diff --git a/keyboards/bioi/bluetooth_custom.c b/keyboards/bioi/bluetooth_custom.c index 7d88a837d1..4ea277f731 100644 --- a/keyboards/bioi/bluetooth_custom.c +++ b/keyboards/bioi/bluetooth_custom.c @@ -86,13 +86,12 @@ void bluetooth_send_keyboard(report_keyboard_t *report) send_str(PSTR("AT+BLEKEYBOARDCODE=")); - for (uint8_t i = 0; i < KEYBOARD_EPSIZE; i++) - { - send_bytes(report->raw[i]); - if (i < (KEYBOARD_EPSIZE - 1)) - { - send_str(PSTR("-")); - } + send_bytes(report->mods); + send_str(PSTR("-")); + send_bytes(0); + for (uint8_t i = 0; i < KEYBOARD_REPORT_KEYS; i++) { + send_str(PSTR("-")); + send_bytes(report->keys[i]); } send_str(PSTR("\r\n")); diff --git a/keyboards/sawnsprojects/okayu/stm32f072/config.h b/keyboards/sawnsprojects/okayu/stm32f072/config.h index c47f1928c8..41bb0d1fdb 100644 --- a/keyboards/sawnsprojects/okayu/stm32f072/config.h +++ b/keyboards/sawnsprojects/okayu/stm32f072/config.h @@ -2,7 +2,7 @@ // SPDX-License-Identifier: GPL-2.0-or-later #pragma once -#define WS2812_SPI SPID1 +#define WS2812_SPI_DRIVER SPID1 #define WS2812_SPI_MOSI_PAL_MODE 5 #define WS2812_SPI_SCK_PIN B13 #define WS2812_SPI_SCK_PAL_MODE 5 \ No newline at end of file diff --git a/keyboards/sawnsprojects/okayu/stm32f103/config.h b/keyboards/sawnsprojects/okayu/stm32f103/config.h index eff3605470..9024616477 100644 --- a/keyboards/sawnsprojects/okayu/stm32f103/config.h +++ b/keyboards/sawnsprojects/okayu/stm32f103/config.h @@ -2,7 +2,7 @@ // SPDX-License-Identifier: GPL-2.0-or-later #pragma once -#define WS2812_SPI SPID2 +#define WS2812_SPI_DRIVER SPID2 #define WS2812_SPI_MOSI_PAL_MODE 5 #define WS2812_SPI_SCK_PIN B13 #define WS2812_SPI_SCK_PAL_MODE 5 \ No newline at end of file diff --git a/keyboards/sawnsprojects/okayu/stm32f303/config.h b/keyboards/sawnsprojects/okayu/stm32f303/config.h index c47f1928c8..41bb0d1fdb 100644 --- a/keyboards/sawnsprojects/okayu/stm32f303/config.h +++ b/keyboards/sawnsprojects/okayu/stm32f303/config.h @@ -2,7 +2,7 @@ // SPDX-License-Identifier: GPL-2.0-or-later #pragma once -#define WS2812_SPI SPID1 +#define WS2812_SPI_DRIVER SPID1 #define WS2812_SPI_MOSI_PAL_MODE 5 #define WS2812_SPI_SCK_PIN B13 #define WS2812_SPI_SCK_PAL_MODE 5 \ No newline at end of file diff --git a/platforms/chibios/drivers/eeprom/eeprom_kinetis_flexram.c b/platforms/chibios/drivers/eeprom/eeprom_kinetis_flexram.c index 6468cbf3fa..9cf956b2f7 100644 --- a/platforms/chibios/drivers/eeprom/eeprom_kinetis_flexram.c +++ b/platforms/chibios/drivers/eeprom/eeprom_kinetis_flexram.c @@ -146,7 +146,7 @@ uint32_t eeprom_read_dword(const uint32_t *addr) { * * FIXME: needs doc */ -void eeprom_read_block(void *buf, const void *addr, uint32_t len) { +void eeprom_read_block(void *buf, const void *addr, size_t len) { uint32_t offset = (uint32_t)addr; uint8_t *dest = (uint8_t *)buf; uint32_t end = offset + len; @@ -271,7 +271,7 @@ void eeprom_write_dword(uint32_t *addr, uint32_t value) { * * FIXME: needs doc */ -void eeprom_write_block(const void *buf, void *addr, uint32_t len) { +void eeprom_write_block(const void *buf, void *addr, size_t len) { uint32_t offset = (uint32_t)addr; const uint8_t *src = (const uint8_t *)buf; @@ -480,7 +480,7 @@ uint32_t eeprom_read_dword(const uint32_t *addr) { return eeprom_read_byte(p) | (eeprom_read_byte(p + 1) << 8) | (eeprom_read_byte(p + 2) << 16) | (eeprom_read_byte(p + 3) << 24); } -void eeprom_read_block(void *buf, const void *addr, uint32_t len) { +void eeprom_read_block(void *buf, const void *addr, size_t len) { const uint8_t *p = (const uint8_t *)addr; uint8_t * dest = (uint8_t *)buf; while (len--) { @@ -506,7 +506,7 @@ void eeprom_write_dword(uint32_t *addr, uint32_t value) { eeprom_write_byte(p, value >> 24); } -void eeprom_write_block(const void *buf, void *addr, uint32_t len) { +void eeprom_write_block(const void *buf, void *addr, size_t len) { uint8_t * p = (uint8_t *)addr; const uint8_t *src = (const uint8_t *)buf; while (len--) { diff --git a/quantum/eeconfig.h b/quantum/eeconfig.h index 34d85cb91e..d7cce166bd 100644 --- a/quantum/eeconfig.h +++ b/quantum/eeconfig.h @@ -19,6 +19,7 @@ along with this program. If not, see . #include #include +#include "eeprom.h" #ifndef EECONFIG_MAGIC_NUMBER # define EECONFIG_MAGIC_NUMBER (uint16_t)0xFEE6 // When changing, decrement this value to avoid future re-init issues diff --git a/quantum/quantum.h b/quantum/quantum.h index 66e4569991..e41542e4af 100644 --- a/quantum/quantum.h +++ b/quantum/quantum.h @@ -56,6 +56,8 @@ #include "suspend.h" #include #include +#include +#include #ifdef DEFERRED_EXEC_ENABLE # include "deferred_exec.h" diff --git a/tmk_core/protocol/report.c b/tmk_core/protocol/report.c index 1ba3be4604..27d267abae 100644 --- a/tmk_core/protocol/report.c +++ b/tmk_core/protocol/report.c @@ -59,7 +59,7 @@ uint8_t get_first_key(report_keyboard_t* keyboard_report) { #ifdef NKRO_ENABLE if (keyboard_protocol && keymap_config.nkro) { uint8_t i = 0; - for (; i < KEYBOARD_REPORT_BITS && !keyboard_report->nkro.bits[i]; i++) + for (; i < NKRO_REPORT_BITS && !keyboard_report->nkro.bits[i]; i++) ; return i << 3 | biton(keyboard_report->nkro.bits[i]); } @@ -89,7 +89,7 @@ bool is_key_pressed(report_keyboard_t* keyboard_report, uint8_t key) { } #ifdef NKRO_ENABLE if (keyboard_protocol && keymap_config.nkro) { - if ((key >> 3) < KEYBOARD_REPORT_BITS) { + if ((key >> 3) < NKRO_REPORT_BITS) { return keyboard_report->nkro.bits[key >> 3] & 1 << (key & 7); } else { return false; @@ -216,7 +216,7 @@ void del_key_byte(report_keyboard_t* keyboard_report, uint8_t code) { * FIXME: Needs doc */ void add_key_bit(report_keyboard_t* keyboard_report, uint8_t code) { - if ((code >> 3) < KEYBOARD_REPORT_BITS) { + if ((code >> 3) < NKRO_REPORT_BITS) { keyboard_report->nkro.bits[code >> 3] |= 1 << (code & 7); } else { dprintf("add_key_bit: can't add: %02X\n", code); @@ -228,7 +228,7 @@ void add_key_bit(report_keyboard_t* keyboard_report, uint8_t code) { * FIXME: Needs doc */ void del_key_bit(report_keyboard_t* keyboard_report, uint8_t code) { - if ((code >> 3) < KEYBOARD_REPORT_BITS) { + if ((code >> 3) < NKRO_REPORT_BITS) { keyboard_report->nkro.bits[code >> 3] &= ~(1 << (code & 7)); } else { dprintf("del_key_bit: can't del: %02X\n", code); diff --git a/tmk_core/protocol/report.h b/tmk_core/protocol/report.h index 9d415a3bfd..dd3cee3df0 100644 --- a/tmk_core/protocol/report.h +++ b/tmk_core/protocol/report.h @@ -20,6 +20,7 @@ along with this program. If not, see . #include #include #include "keycode.h" +#include "util.h" // clang-format off @@ -129,10 +130,10 @@ enum desktop_usages { #if defined(NKRO_ENABLE) # if defined(PROTOCOL_LUFA) || defined(PROTOCOL_CHIBIOS) # include "protocol/usb_descriptor.h" -# define KEYBOARD_REPORT_BITS (SHARED_EPSIZE - 2) +# define NKRO_REPORT_BITS (SHARED_EPSIZE - 2) # elif defined(PROTOCOL_ARM_ATSAM) # include "protocol/arm_atsam/usb/udi_device_epsize.h" -# define KEYBOARD_REPORT_BITS (NKRO_EPSIZE - 1) +# define NKRO_REPORT_BITS (NKRO_EPSIZE - 1) # undef NKRO_SHARED_EP # undef MOUSE_SHARED_EP # else @@ -188,20 +189,20 @@ typedef union { uint8_t report_id; # endif uint8_t mods; - uint8_t bits[KEYBOARD_REPORT_BITS]; + uint8_t bits[NKRO_REPORT_BITS]; } nkro; #endif -} __attribute__((packed)) report_keyboard_t; +} PACKED report_keyboard_t; typedef struct { uint8_t report_id; uint16_t usage; -} __attribute__((packed)) report_extra_t; +} PACKED report_extra_t; typedef struct { uint8_t report_id; uint32_t usage; -} __attribute__((packed)) report_programmable_button_t; +} PACKED report_programmable_button_t; #ifdef MOUSE_EXTENDED_REPORT typedef int16_t mouse_xy_report_t; @@ -222,7 +223,7 @@ typedef struct { mouse_xy_report_t y; int8_t v; int8_t h; -} __attribute__((packed)) report_mouse_t; +} PACKED report_mouse_t; typedef struct { #ifdef DIGITIZER_SHARED_EP @@ -234,7 +235,7 @@ typedef struct { uint8_t reserved : 5; uint16_t x; uint16_t y; -} __attribute__((packed)) report_digitizer_t; +} PACKED report_digitizer_t; typedef struct { #ifdef JOYSTICK_SHARED_EP @@ -251,7 +252,7 @@ typedef struct { #if JOYSTICK_BUTTON_COUNT > 0 uint8_t buttons[(JOYSTICK_BUTTON_COUNT - 1) / 8 + 1]; #endif -} __attribute__((packed)) report_joystick_t; +} PACKED report_joystick_t; /* keycode to system usage */ static inline uint16_t KEYCODE2SYSTEM(uint8_t key) { diff --git a/tmk_core/protocol/usb_descriptor.c b/tmk_core/protocol/usb_descriptor.c index e215c90900..eb214c0492 100644 --- a/tmk_core/protocol/usb_descriptor.c +++ b/tmk_core/protocol/usb_descriptor.c @@ -359,10 +359,10 @@ const USB_Descriptor_HIDReport_Datatype_t PROGMEM SharedReport[] = { // Keycodes HID_RI_USAGE_PAGE(8, 0x07), // Keyboard/Keypad HID_RI_USAGE_MINIMUM(8, 0x00), - HID_RI_USAGE_MAXIMUM(8, KEYBOARD_REPORT_BITS * 8 - 1), + HID_RI_USAGE_MAXIMUM(8, NKRO_REPORT_BITS * 8 - 1), HID_RI_LOGICAL_MINIMUM(8, 0x00), HID_RI_LOGICAL_MAXIMUM(8, 0x01), - HID_RI_REPORT_COUNT(8, KEYBOARD_REPORT_BITS * 8), + HID_RI_REPORT_COUNT(8, NKRO_REPORT_BITS * 8), HID_RI_REPORT_SIZE(8, 0x01), HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE), diff --git a/users/brandonschlack/brandonschlack.c b/users/brandonschlack/brandonschlack.c index 1e52bd6452..6a9c04a73d 100644 --- a/users/brandonschlack/brandonschlack.c +++ b/users/brandonschlack/brandonschlack.c @@ -88,9 +88,7 @@ void suspend_power_down_keymap(void) {} */ void suspend_power_down_user(void) { #ifdef RGB_MATRIX_ENABLE - if (!g_suspend_state) { - rgb_matrix_set_suspend_state(true); - } + rgb_matrix_set_suspend_state(true); #endif //RGB_MATRIX_ENABLE suspend_power_down_keymap(); } @@ -103,9 +101,7 @@ void suspend_wakeup_init_keymap(void) {} */ void suspend_wakeup_init_user(void) { #ifdef RGB_MATRIX_ENABLE - if (g_suspend_state) { - rgb_matrix_set_suspend_state(false); - } + rgb_matrix_set_suspend_state(false); #endif //RGB_MATRIX_ENABLE suspend_wakeup_init_keymap(); } -- cgit v1.2.3 From 0c160e1fbafbf477c74e64fd8ab9a9121eb0f42a Mon Sep 17 00:00:00 2001 From: Ryan Date: Mon, 23 Oct 2023 14:43:46 +1000 Subject: Separate 6KRO and NKRO report structs (#22267) --- keyboards/annepro2/annepro2_ble.c | 2 +- keyboards/horrortroll/lemon40/info.json | 3 +- keyboards/kbdfans/kbd67/rev1/info.json | 1 - quantum/action.c | 2 +- quantum/action_util.c | 57 ++++++++++++++++++++------ quantum/action_util.h | 9 +++-- tests/test_common/keyboard_report_util.cpp | 4 +- tests/test_common/test_driver.cpp | 6 ++- tests/test_common/test_driver.hpp | 2 + tmk_core/protocol.mk | 4 +- tmk_core/protocol/arm_atsam/main_arm_atsam.c | 59 +++++++++++++-------------- tmk_core/protocol/chibios/chibios.c | 3 +- tmk_core/protocol/chibios/usb_main.c | 22 +++++----- tmk_core/protocol/host.c | 33 ++++++++------- tmk_core/protocol/host.h | 1 + tmk_core/protocol/host_driver.h | 1 + tmk_core/protocol/lufa/lufa.c | 34 +++++++--------- tmk_core/protocol/report.c | 37 ++++++++--------- tmk_core/protocol/report.h | 60 ++++++++++------------------ tmk_core/protocol/vusb/vusb.c | 8 +++- 20 files changed, 185 insertions(+), 163 deletions(-) (limited to 'keyboards/annepro2') diff --git a/keyboards/annepro2/annepro2_ble.c b/keyboards/annepro2/annepro2_ble.c index b04929e958..a382c61638 100644 --- a/keyboards/annepro2/annepro2_ble.c +++ b/keyboards/annepro2/annepro2_ble.c @@ -31,7 +31,7 @@ static void ap2_ble_swtich_ble_driver(void); /* -------------------- Static Local Variables ------------------------------ */ static host_driver_t ap2_ble_driver = { - ap2_ble_leds, ap2_ble_keyboard, ap2_ble_mouse, ap2_ble_extra + ap2_ble_leds, ap2_ble_keyboard, NULL, ap2_ble_mouse, ap2_ble_extra }; static uint8_t ble_mcu_wakeup[11] = {0x7b, 0x12, 0x53, 0x00, 0x03, 0x00, 0x01, 0x7d, 0x02, 0x01, 0x02}; diff --git a/keyboards/horrortroll/lemon40/info.json b/keyboards/horrortroll/lemon40/info.json index 7162e2c2c7..7b0b1c394b 100644 --- a/keyboards/horrortroll/lemon40/info.json +++ b/keyboards/horrortroll/lemon40/info.json @@ -19,8 +19,7 @@ "knight": true, "christmas": true, "static_gradient": true, - "alternating": true, - "twinkle": true + "alternating": true } }, "ws2812": { diff --git a/keyboards/kbdfans/kbd67/rev1/info.json b/keyboards/kbdfans/kbd67/rev1/info.json index 9119477584..f279c5a2c9 100644 --- a/keyboards/kbdfans/kbd67/rev1/info.json +++ b/keyboards/kbdfans/kbd67/rev1/info.json @@ -38,7 +38,6 @@ "knight": true, "christmas": true, "static_gradient": true, - "rgb_test": true, "alternating": true, "twinkle": true } diff --git a/quantum/action.c b/quantum/action.c index 349250472b..29822c39e9 100644 --- a/quantum/action.c +++ b/quantum/action.c @@ -925,7 +925,7 @@ __attribute__((weak)) void register_code(uint8_t code) { // Force a new key press if the key is already pressed // without this, keys with the same keycode, but different // modifiers will be reported incorrectly, see issue #1708 - if (is_key_pressed(keyboard_report, code)) { + if (is_key_pressed(code)) { del_key(code); send_keyboard_report(); } diff --git a/quantum/action_util.c b/quantum/action_util.c index 909dea0595..52171b5050 100644 --- a/quantum/action_util.c +++ b/quantum/action_util.c @@ -35,6 +35,9 @@ static uint8_t suppressed_mods = 0; // TODO: pointer variable is not needed // report_keyboard_t keyboard_report = {}; report_keyboard_t *keyboard_report = &(report_keyboard_t){}; +#ifdef NKRO_ENABLE +report_nkro_t *nkro_report = &(report_nkro_t){}; +#endif extern inline void add_key(uint8_t key); extern inline void del_key(uint8_t key); @@ -252,13 +255,8 @@ bool is_oneshot_enabled(void) { #endif -/** \brief Send keyboard report - * - * FIXME: needs doc - */ -void send_keyboard_report(void) { - keyboard_report->mods = real_mods; - keyboard_report->mods |= weak_mods; +static uint8_t get_mods_for_report(void) { + uint8_t mods = real_mods | weak_mods; #ifndef NO_ACTION_ONESHOT if (oneshot_mods) { @@ -268,20 +266,25 @@ void send_keyboard_report(void) { clear_oneshot_mods(); } # endif - keyboard_report->mods |= oneshot_mods; - if (has_anykey(keyboard_report)) { + mods |= oneshot_mods; + if (has_anykey()) { clear_oneshot_mods(); } } - #endif #ifdef KEY_OVERRIDE_ENABLE // These need to be last to be able to properly control key overrides - keyboard_report->mods &= ~suppressed_mods; - keyboard_report->mods |= weak_override_mods; + mods &= ~suppressed_mods; + mods |= weak_override_mods; #endif + return mods; +} + +void send_6kro_report(void) { + keyboard_report->mods = get_mods_for_report(); + #ifdef PROTOCOL_VUSB host_keyboard_send(keyboard_report); #else @@ -295,6 +298,36 @@ void send_keyboard_report(void) { #endif } +#ifdef NKRO_ENABLE +void send_nkro_report(void) { + nkro_report->mods = get_mods_for_report(); + + static report_nkro_t last_report; + + /* Only send the report if there are changes to propagate to the host. */ + if (memcmp(nkro_report, &last_report, sizeof(report_nkro_t)) != 0) { + memcpy(&last_report, nkro_report, sizeof(report_nkro_t)); + host_nkro_send(nkro_report); + } +} +#endif + +/** \brief Send keyboard report + * + * FIXME: needs doc + */ +void send_keyboard_report(void) { +#ifdef NKRO_ENABLE + if (keyboard_protocol && keymap_config.nkro) { + send_nkro_report(); + } else { + send_6kro_report(); + } +#else + send_6kro_report(); +#endif +} + /** \brief Get mods * * FIXME: needs doc diff --git a/quantum/action_util.h b/quantum/action_util.h index 831caf3c0a..d2ecb145be 100644 --- a/quantum/action_util.h +++ b/quantum/action_util.h @@ -26,20 +26,23 @@ extern "C" { #endif extern report_keyboard_t *keyboard_report; +#ifdef NKRO_ENABLE +extern report_nkro_t *nkro_report; +#endif void send_keyboard_report(void); /* key */ inline void add_key(uint8_t key) { - add_key_to_report(keyboard_report, key); + add_key_to_report(key); } inline void del_key(uint8_t key) { - del_key_from_report(keyboard_report, key); + del_key_from_report(key); } inline void clear_keys(void) { - clear_keys_from_report(keyboard_report); + clear_keys_from_report(); } /* modifier */ diff --git a/tests/test_common/keyboard_report_util.cpp b/tests/test_common/keyboard_report_util.cpp index cb7f7ae735..5676483539 100644 --- a/tests/test_common/keyboard_report_util.cpp +++ b/tests/test_common/keyboard_report_util.cpp @@ -95,12 +95,12 @@ std::ostream& operator<<(std::ostream& os, const report_keyboard_t& report) { } KeyboardReportMatcher::KeyboardReportMatcher(const std::vector& keys) { - memset(m_report.raw, 0, sizeof(m_report.raw)); + memset(&m_report, 0, sizeof(report_keyboard_t)); for (auto k : keys) { if (IS_MODIFIER_KEYCODE(k)) { m_report.mods |= MOD_BIT(k); } else { - add_key_to_report(&m_report, k); + add_key_byte(&m_report, k); } } } diff --git a/tests/test_common/test_driver.cpp b/tests/test_common/test_driver.cpp index 0495da8205..d410b225f9 100644 --- a/tests/test_common/test_driver.cpp +++ b/tests/test_common/test_driver.cpp @@ -31,7 +31,7 @@ uint8_t hex_digit_to_keycode(uint8_t digit) { } } // namespace -TestDriver::TestDriver() : m_driver{&TestDriver::keyboard_leds, &TestDriver::send_keyboard, &TestDriver::send_mouse, &TestDriver::send_extra} { +TestDriver::TestDriver() : m_driver{&TestDriver::keyboard_leds, &TestDriver::send_keyboard, &TestDriver::send_nkro, &TestDriver::send_mouse, &TestDriver::send_extra} { host_set_driver(&m_driver); m_this = this; } @@ -49,6 +49,10 @@ void TestDriver::send_keyboard(report_keyboard_t* report) { m_this->send_keyboard_mock(*report); } +void TestDriver::send_nkro(report_nkro_t* report) { + m_this->send_nkro_mock(*report); +} + void TestDriver::send_mouse(report_mouse_t* report) { m_this->send_mouse_mock(*report); } diff --git a/tests/test_common/test_driver.hpp b/tests/test_common/test_driver.hpp index d8a6885d0f..ec75d3fff2 100644 --- a/tests/test_common/test_driver.hpp +++ b/tests/test_common/test_driver.hpp @@ -32,12 +32,14 @@ class TestDriver { } MOCK_METHOD1(send_keyboard_mock, void(report_keyboard_t&)); + MOCK_METHOD1(send_nkro_mock, void(report_nkro_t&)); MOCK_METHOD1(send_mouse_mock, void(report_mouse_t&)); MOCK_METHOD1(send_extra_mock, void(report_extra_t&)); private: static uint8_t keyboard_leds(void); static void send_keyboard(report_keyboard_t* report); + static void send_nkro(report_nkro_t* report); static void send_mouse(report_mouse_t* report); static void send_extra(report_extra_t* report); host_driver_t m_driver; diff --git a/tmk_core/protocol.mk b/tmk_core/protocol.mk index d159dacc55..fd5342d637 100644 --- a/tmk_core/protocol.mk +++ b/tmk_core/protocol.mk @@ -46,9 +46,7 @@ else endif ifeq ($(strip $(NKRO_ENABLE)), yes) - ifeq ($(PROTOCOL), VUSB) - $(info NKRO is not currently supported on V-USB, and has been disabled.) - else ifeq ($(strip $(BLUETOOTH_ENABLE)), yes) + ifeq ($(strip $(BLUETOOTH_ENABLE)), yes) $(info NKRO is not currently supported with Bluetooth, and has been disabled.) else OPT_DEFS += -DNKRO_ENABLE diff --git a/tmk_core/protocol/arm_atsam/main_arm_atsam.c b/tmk_core/protocol/arm_atsam/main_arm_atsam.c index 30817c17b6..8abcfd6090 100644 --- a/tmk_core/protocol/arm_atsam/main_arm_atsam.c +++ b/tmk_core/protocol/arm_atsam/main_arm_atsam.c @@ -36,6 +36,7 @@ uint8_t g_usb_state = USB_FSMSTATUS_FSMSTATE_OFF_Val; // Saved USB state from ha void main_subtasks(void); uint8_t keyboard_leds(void); void send_keyboard(report_keyboard_t *report); +void send_nkro(report_nkro_t *report); void send_mouse(report_mouse_t *report); void send_extra(report_extra_t *report); @@ -43,7 +44,7 @@ void send_extra(report_extra_t *report); void deferred_exec_task(void); #endif // DEFERRED_EXEC_ENABLE -host_driver_t arm_atsam_driver = {keyboard_leds, send_keyboard, send_mouse, send_extra}; +host_driver_t arm_atsam_driver = {keyboard_leds, send_keyboard, send_nkro, send_mouse, send_extra}; uint8_t led_states; @@ -59,41 +60,41 @@ uint8_t keyboard_leds(void) { void send_keyboard(report_keyboard_t *report) { uint32_t irqflags; -#ifdef NKRO_ENABLE - if (!keymap_config.nkro) { -#endif // NKRO_ENABLE - while (udi_hid_kbd_b_report_trans_ongoing) { - main_subtasks(); - } // Run other tasks while waiting for USB to be free + while (udi_hid_kbd_b_report_trans_ongoing) { + main_subtasks(); + } // Run other tasks while waiting for USB to be free - irqflags = __get_PRIMASK(); - __disable_irq(); - __DMB(); + irqflags = __get_PRIMASK(); + __disable_irq(); + __DMB(); - memcpy(udi_hid_kbd_report, report->raw, UDI_HID_KBD_REPORT_SIZE); - udi_hid_kbd_b_report_valid = 1; - udi_hid_kbd_send_report(); + memcpy(udi_hid_kbd_report, report, UDI_HID_KBD_REPORT_SIZE); + udi_hid_kbd_b_report_valid = 1; + udi_hid_kbd_send_report(); - __DMB(); - __set_PRIMASK(irqflags); + __DMB(); + __set_PRIMASK(irqflags); +} + +void send_nkro(report_nkro_t *report) { #ifdef NKRO_ENABLE - } else { - while (udi_hid_nkro_b_report_trans_ongoing) { - main_subtasks(); - } // Run other tasks while waiting for USB to be free + uint32_t irqflags; - irqflags = __get_PRIMASK(); - __disable_irq(); - __DMB(); + while (udi_hid_nkro_b_report_trans_ongoing) { + main_subtasks(); + } // Run other tasks while waiting for USB to be free - memcpy(udi_hid_nkro_report, report->raw, UDI_HID_NKRO_REPORT_SIZE); - udi_hid_nkro_b_report_valid = 1; - udi_hid_nkro_send_report(); + irqflags = __get_PRIMASK(); + __disable_irq(); + __DMB(); - __DMB(); - __set_PRIMASK(irqflags); - } -#endif // NKRO_ENABLE + memcpy(udi_hid_nkro_report, report, UDI_HID_NKRO_REPORT_SIZE); + udi_hid_nkro_b_report_valid = 1; + udi_hid_nkro_send_report(); + + __DMB(); + __set_PRIMASK(irqflags); +#endif } void send_mouse(report_mouse_t *report) { diff --git a/tmk_core/protocol/chibios/chibios.c b/tmk_core/protocol/chibios/chibios.c index 4d97f1cd82..91bb252c7c 100644 --- a/tmk_core/protocol/chibios/chibios.c +++ b/tmk_core/protocol/chibios/chibios.c @@ -59,11 +59,12 @@ /* declarations */ uint8_t keyboard_leds(void); void send_keyboard(report_keyboard_t *report); +void send_nkro(report_nkro_t *report); void send_mouse(report_mouse_t *report); void send_extra(report_extra_t *report); /* host struct */ -host_driver_t chibios_driver = {keyboard_leds, send_keyboard, send_mouse, send_extra}; +host_driver_t chibios_driver = {keyboard_leds, send_keyboard, send_nkro, send_mouse, send_extra}; #ifdef VIRTSER_ENABLE void virtser_task(void); diff --git a/tmk_core/protocol/chibios/usb_main.c b/tmk_core/protocol/chibios/usb_main.c index b14ca30c1a..f2158fd009 100644 --- a/tmk_core/protocol/chibios/usb_main.c +++ b/tmk_core/protocol/chibios/usb_main.c @@ -71,7 +71,7 @@ static virtual_timer_t keyboard_idle_timer; static void keyboard_idle_timer_cb(struct ch_virtual_timer *, void *arg); -report_keyboard_t keyboard_report_sent = {{0}}; +report_keyboard_t keyboard_report_sent = {0}; report_mouse_t mouse_report_sent = {0}; union { @@ -883,26 +883,22 @@ void send_report(uint8_t endpoint, void *report, size_t size) { /* prepare and start sending a report IN * not callable from ISR or locked state */ void send_keyboard(report_keyboard_t *report) { - uint8_t ep = KEYBOARD_IN_EPNUM; - size_t size = KEYBOARD_REPORT_SIZE; - /* If we're in Boot Protocol, don't send any report ID or other funky fields */ if (!keyboard_protocol) { - send_report(ep, &report->mods, 8); + send_report(KEYBOARD_IN_EPNUM, &report->mods, 8); } else { -#ifdef NKRO_ENABLE - if (keymap_config.nkro) { - ep = SHARED_IN_EPNUM; - size = sizeof(struct nkro_report); - } -#endif - - send_report(ep, report, size); + send_report(KEYBOARD_IN_EPNUM, report, KEYBOARD_REPORT_SIZE); } keyboard_report_sent = *report; } +void send_nkro(report_nkro_t *report) { +#ifdef NKRO_ENABLE + send_report(SHARED_IN_EPNUM, report, sizeof(report_nkro_t)); +#endif +} + /* --------------------------------------------------------- * Mouse functions * --------------------------------------------------------- diff --git a/tmk_core/protocol/host.c b/tmk_core/protocol/host.c index 2c6654e9a6..732fbdc37d 100644 --- a/tmk_core/protocol/host.c +++ b/tmk_core/protocol/host.c @@ -81,26 +81,29 @@ void host_keyboard_send(report_keyboard_t *report) { #endif if (!driver) return; -#if defined(NKRO_ENABLE) && defined(NKRO_SHARED_EP) - if (keyboard_protocol && keymap_config.nkro) { - /* The callers of this function assume that report->mods is where mods go in. - * But report->nkro.mods can be at a different offset if core keyboard does not have a report ID. - */ - report->nkro.mods = report->mods; - report->nkro.report_id = REPORT_ID_NKRO; - } else -#endif - { #ifdef KEYBOARD_SHARED_EP - report->report_id = REPORT_ID_KEYBOARD; + report->report_id = REPORT_ID_KEYBOARD; #endif - } (*driver->send_keyboard)(report); if (debug_keyboard) { - dprint("keyboard_report: "); - for (uint8_t i = 0; i < KEYBOARD_REPORT_SIZE; i++) { - dprintf("%02X ", report->raw[i]); + dprintf("keyboard_report: %02X | ", report->mods); + for (uint8_t i = 0; i < KEYBOARD_REPORT_KEYS; i++) { + dprintf("%02X ", report->keys[i]); + } + dprint("\n"); + } +} + +void host_nkro_send(report_nkro_t *report) { + if (!driver) return; + report->report_id = REPORT_ID_NKRO; + (*driver->send_nkro)(report); + + if (debug_keyboard) { + dprintf("nkro_report: %02X | ", report->mods); + for (uint8_t i = 0; i < NKRO_REPORT_BITS; i++) { + dprintf("%02X ", report->bits[i]); } dprint("\n"); } diff --git a/tmk_core/protocol/host.h b/tmk_core/protocol/host.h index e4fb3a74f2..959753ae02 100644 --- a/tmk_core/protocol/host.h +++ b/tmk_core/protocol/host.h @@ -38,6 +38,7 @@ host_driver_t *host_get_driver(void); uint8_t host_keyboard_leds(void); led_t host_keyboard_led_state(void); void host_keyboard_send(report_keyboard_t *report); +void host_nkro_send(report_nkro_t *report); void host_mouse_send(report_mouse_t *report); void host_system_send(uint16_t usage); void host_consumer_send(uint16_t usage); diff --git a/tmk_core/protocol/host_driver.h b/tmk_core/protocol/host_driver.h index 7dc6c3d810..8aa38b6dee 100644 --- a/tmk_core/protocol/host_driver.h +++ b/tmk_core/protocol/host_driver.h @@ -26,6 +26,7 @@ along with this program. If not, see . typedef struct { uint8_t (*keyboard_leds)(void); void (*send_keyboard)(report_keyboard_t *); + void (*send_nkro)(report_nkro_t *); void (*send_mouse)(report_mouse_t *); void (*send_extra)(report_extra_t *); } host_driver_t; diff --git a/tmk_core/protocol/lufa/lufa.c b/tmk_core/protocol/lufa/lufa.c index f04ca79a0c..553f69b1e4 100644 --- a/tmk_core/protocol/lufa/lufa.c +++ b/tmk_core/protocol/lufa/lufa.c @@ -55,12 +55,6 @@ #include "usb_device_state.h" #include -#ifdef NKRO_ENABLE -# include "keycode_config.h" - -extern keymap_config_t keymap_config; -#endif - #ifdef VIRTSER_ENABLE # include "virtser.h" #endif @@ -83,9 +77,10 @@ static report_keyboard_t keyboard_report_sent; /* Host driver */ static uint8_t keyboard_leds(void); static void send_keyboard(report_keyboard_t *report); +static void send_nkro(report_nkro_t *report); static void send_mouse(report_mouse_t *report); static void send_extra(report_extra_t *report); -host_driver_t lufa_driver = {keyboard_leds, send_keyboard, send_mouse, send_extra}; +host_driver_t lufa_driver = {keyboard_leds, send_keyboard, send_nkro, send_mouse, send_extra}; void send_report(uint8_t endpoint, void *report, size_t size) { uint8_t timeout = 255; @@ -559,27 +554,26 @@ static uint8_t keyboard_leds(void) { * FIXME: Needs doc */ static void send_keyboard(report_keyboard_t *report) { - /* Select the Keyboard Report Endpoint */ - uint8_t ep = KEYBOARD_IN_EPNUM; - uint8_t size = KEYBOARD_REPORT_SIZE; - /* If we're in Boot Protocol, don't send any report ID or other funky fields */ if (!keyboard_protocol) { - send_report(ep, &report->mods, 8); + send_report(KEYBOARD_IN_EPNUM, &report->mods, 8); } else { -#ifdef NKRO_ENABLE - if (keymap_config.nkro) { - ep = SHARED_IN_EPNUM; - size = sizeof(struct nkro_report); - } -#endif - - send_report(ep, report, size); + send_report(KEYBOARD_IN_EPNUM, report, KEYBOARD_REPORT_SIZE); } keyboard_report_sent = *report; } +/** \brief Send NKRO + * + * FIXME: Needs doc + */ +static void send_nkro(report_nkro_t *report) { +#ifdef NKRO_ENABLE + send_report(SHARED_IN_EPNUM, report, sizeof(report_nkro_t)); +#endif +} + /** \brief Send Mouse * * FIXME: Needs doc diff --git a/tmk_core/protocol/report.c b/tmk_core/protocol/report.c index 27d267abae..0166bf654f 100644 --- a/tmk_core/protocol/report.c +++ b/tmk_core/protocol/report.c @@ -15,6 +15,7 @@ */ #include "report.h" +#include "action_util.h" #include "host.h" #include "keycode_config.h" #include "debug.h" @@ -35,14 +36,14 @@ static int8_t cb_count = 0; * * FIXME: Needs doc */ -uint8_t has_anykey(report_keyboard_t* keyboard_report) { +uint8_t has_anykey(void) { uint8_t cnt = 0; uint8_t* p = keyboard_report->keys; uint8_t lp = sizeof(keyboard_report->keys); #ifdef NKRO_ENABLE if (keyboard_protocol && keymap_config.nkro) { - p = keyboard_report->nkro.bits; - lp = sizeof(keyboard_report->nkro.bits); + p = nkro_report->bits; + lp = sizeof(nkro_report->bits); } #endif while (lp--) { @@ -55,13 +56,13 @@ uint8_t has_anykey(report_keyboard_t* keyboard_report) { * * FIXME: Needs doc */ -uint8_t get_first_key(report_keyboard_t* keyboard_report) { +uint8_t get_first_key(void) { #ifdef NKRO_ENABLE if (keyboard_protocol && keymap_config.nkro) { uint8_t i = 0; - for (; i < NKRO_REPORT_BITS && !keyboard_report->nkro.bits[i]; i++) + for (; i < NKRO_REPORT_BITS && !nkro_report->bits[i]; i++) ; - return i << 3 | biton(keyboard_report->nkro.bits[i]); + return i << 3 | biton(nkro_report->bits[i]); } #endif #ifdef RING_BUFFERED_6KRO_REPORT_ENABLE @@ -83,14 +84,14 @@ uint8_t get_first_key(report_keyboard_t* keyboard_report) { * Returns true if the keyboard_report reports that the key is pressed, otherwise false * Note: The function doesn't support modifers currently, and it returns false for KC_NO */ -bool is_key_pressed(report_keyboard_t* keyboard_report, uint8_t key) { +bool is_key_pressed(uint8_t key) { if (key == KC_NO) { return false; } #ifdef NKRO_ENABLE if (keyboard_protocol && keymap_config.nkro) { if ((key >> 3) < NKRO_REPORT_BITS) { - return keyboard_report->nkro.bits[key >> 3] & 1 << (key & 7); + return nkro_report->bits[key >> 3] & 1 << (key & 7); } else { return false; } @@ -215,9 +216,9 @@ void del_key_byte(report_keyboard_t* keyboard_report, uint8_t code) { * * FIXME: Needs doc */ -void add_key_bit(report_keyboard_t* keyboard_report, uint8_t code) { +void add_key_bit(report_nkro_t* nkro_report, uint8_t code) { if ((code >> 3) < NKRO_REPORT_BITS) { - keyboard_report->nkro.bits[code >> 3] |= 1 << (code & 7); + nkro_report->bits[code >> 3] |= 1 << (code & 7); } else { dprintf("add_key_bit: can't add: %02X\n", code); } @@ -227,9 +228,9 @@ void add_key_bit(report_keyboard_t* keyboard_report, uint8_t code) { * * FIXME: Needs doc */ -void del_key_bit(report_keyboard_t* keyboard_report, uint8_t code) { +void del_key_bit(report_nkro_t* nkro_report, uint8_t code) { if ((code >> 3) < NKRO_REPORT_BITS) { - keyboard_report->nkro.bits[code >> 3] &= ~(1 << (code & 7)); + nkro_report->bits[code >> 3] &= ~(1 << (code & 7)); } else { dprintf("del_key_bit: can't del: %02X\n", code); } @@ -240,10 +241,10 @@ void del_key_bit(report_keyboard_t* keyboard_report, uint8_t code) { * * FIXME: Needs doc */ -void add_key_to_report(report_keyboard_t* keyboard_report, uint8_t key) { +void add_key_to_report(uint8_t key) { #ifdef NKRO_ENABLE if (keyboard_protocol && keymap_config.nkro) { - add_key_bit(keyboard_report, key); + add_key_bit(nkro_report, key); return; } #endif @@ -254,10 +255,10 @@ void add_key_to_report(report_keyboard_t* keyboard_report, uint8_t key) { * * FIXME: Needs doc */ -void del_key_from_report(report_keyboard_t* keyboard_report, uint8_t key) { +void del_key_from_report(uint8_t key) { #ifdef NKRO_ENABLE if (keyboard_protocol && keymap_config.nkro) { - del_key_bit(keyboard_report, key); + del_key_bit(nkro_report, key); return; } #endif @@ -268,11 +269,11 @@ void del_key_from_report(report_keyboard_t* keyboard_report, uint8_t key) { * * FIXME: Needs doc */ -void clear_keys_from_report(report_keyboard_t* keyboard_report) { +void clear_keys_from_report(void) { // not clear mods #ifdef NKRO_ENABLE if (keyboard_protocol && keymap_config.nkro) { - memset(keyboard_report->nkro.bits, 0, sizeof(keyboard_report->nkro.bits)); + memset(nkro_report->bits, 0, sizeof(nkro_report->bits)); return; } #endif diff --git a/tmk_core/protocol/report.h b/tmk_core/protocol/report.h index dd3cee3df0..9b612dd182 100644 --- a/tmk_core/protocol/report.h +++ b/tmk_core/protocol/report.h @@ -125,21 +125,7 @@ enum desktop_usages { // clang-format on -#define NKRO_SHARED_EP -/* key report size(NKRO or boot mode) */ -#if defined(NKRO_ENABLE) -# if defined(PROTOCOL_LUFA) || defined(PROTOCOL_CHIBIOS) -# include "protocol/usb_descriptor.h" -# define NKRO_REPORT_BITS (SHARED_EPSIZE - 2) -# elif defined(PROTOCOL_ARM_ATSAM) -# include "protocol/arm_atsam/usb/udi_device_epsize.h" -# define NKRO_REPORT_BITS (NKRO_EPSIZE - 1) -# undef NKRO_SHARED_EP -# undef MOUSE_SHARED_EP -# else -# error "NKRO not supported with this protocol" -# endif -#endif +#define NKRO_REPORT_BITS 30 #ifdef KEYBOARD_SHARED_EP # define KEYBOARD_REPORT_SIZE 9 @@ -173,27 +159,21 @@ extern "C" { * desc |Lcontrol|Lshift |Lalt |Lgui |Rcontrol|Rshift |Ralt |Rgui * */ -typedef union { - uint8_t raw[KEYBOARD_REPORT_SIZE]; - struct { +typedef struct { #ifdef KEYBOARD_SHARED_EP - uint8_t report_id; -#endif - uint8_t mods; - uint8_t reserved; - uint8_t keys[KEYBOARD_REPORT_KEYS]; - }; -#ifdef NKRO_ENABLE - struct nkro_report { -# ifdef NKRO_SHARED_EP - uint8_t report_id; -# endif - uint8_t mods; - uint8_t bits[NKRO_REPORT_BITS]; - } nkro; + uint8_t report_id; #endif + uint8_t mods; + uint8_t reserved; + uint8_t keys[KEYBOARD_REPORT_KEYS]; } PACKED report_keyboard_t; +typedef struct { + uint8_t report_id; + uint8_t mods; + uint8_t bits[NKRO_REPORT_BITS]; +} PACKED report_nkro_t; + typedef struct { uint8_t report_id; uint16_t usage; @@ -330,20 +310,20 @@ static inline uint16_t KEYCODE2CONSUMER(uint8_t key) { } } -uint8_t has_anykey(report_keyboard_t* keyboard_report); -uint8_t get_first_key(report_keyboard_t* keyboard_report); -bool is_key_pressed(report_keyboard_t* keyboard_report, uint8_t key); +uint8_t has_anykey(void); +uint8_t get_first_key(void); +bool is_key_pressed(uint8_t key); void add_key_byte(report_keyboard_t* keyboard_report, uint8_t code); void del_key_byte(report_keyboard_t* keyboard_report, uint8_t code); #ifdef NKRO_ENABLE -void add_key_bit(report_keyboard_t* keyboard_report, uint8_t code); -void del_key_bit(report_keyboard_t* keyboard_report, uint8_t code); +void add_key_bit(report_nkro_t* nkro_report, uint8_t code); +void del_key_bit(report_nkro_t* nkro_report, uint8_t code); #endif -void add_key_to_report(report_keyboard_t* keyboard_report, uint8_t key); -void del_key_from_report(report_keyboard_t* keyboard_report, uint8_t key); -void clear_keys_from_report(report_keyboard_t* keyboard_report); +void add_key_to_report(uint8_t key); +void del_key_from_report(uint8_t key); +void clear_keys_from_report(void); #ifdef MOUSE_ENABLE bool has_mouse_report_changed(report_mouse_t* new_report, report_mouse_t* old_report); diff --git a/tmk_core/protocol/vusb/vusb.c b/tmk_core/protocol/vusb/vusb.c index d74f375f66..d2c7749937 100644 --- a/tmk_core/protocol/vusb/vusb.c +++ b/tmk_core/protocol/vusb/vusb.c @@ -91,6 +91,7 @@ enum usb_interfaces { static uint8_t keyboard_led_state = 0; static uint8_t vusb_idle_rate = 0; +uint8_t keyboard_protocol = 1; /* Keyboard report send buffer */ #define KBUF_SIZE 16 @@ -231,10 +232,11 @@ void console_task(void) { *------------------------------------------------------------------*/ static uint8_t keyboard_leds(void); static void send_keyboard(report_keyboard_t *report); +static void send_nkro(report_nkro_t *report); static void send_mouse(report_mouse_t *report); static void send_extra(report_extra_t *report); -static host_driver_t driver = {keyboard_leds, send_keyboard, send_mouse, send_extra}; +static host_driver_t driver = {keyboard_leds, send_keyboard, send_nkro, send_mouse, send_extra}; host_driver_t *vusb_driver(void) { return &driver; @@ -259,6 +261,10 @@ static void send_keyboard(report_keyboard_t *report) { keyboard_report_sent = *report; } +static void send_nkro(report_nkro_t *report) { + // TODO: Implement NKRO +} + #ifndef KEYBOARD_SHARED_EP # define usbInterruptIsReadyShared usbInterruptIsReady3 # define usbSetInterruptShared usbSetInterrupt3 -- cgit v1.2.3