From ce728bb6000def033bae3c3d3066345c4e83eb1b Mon Sep 17 00:00:00 2001 From: Nolan Nguyen Date: Wed, 2 Jul 2025 17:42:06 -0700 Subject: [PATCH 1/2] 6 Key Rollover Code Comments check the addHIDReport function and the main function, memset line, verify --- .../mainboard/stmf446retx/Src/main.c | 30 ++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/firmware/components/mainboard/stmf446retx/Src/main.c b/firmware/components/mainboard/stmf446retx/Src/main.c index 5b40c90a..01cb552c 100644 --- a/firmware/components/mainboard/stmf446retx/Src/main.c +++ b/firmware/components/mainboard/stmf446retx/Src/main.c @@ -33,7 +33,7 @@ typedef struct{ uint8_t MODIFIER; uint8_t RESERVED; - uint8_t KEYPRESS[13]; + uint8_t KEYPRESS[6]; // for 6 Key Rollover, changed index to 6. } HIDReport; typedef struct{ @@ -128,6 +128,9 @@ int main(void) while (1) { //Keycode Scan + + // memset(REPORT.KEYPRESS, 0, 6); // Clear keypresses at the start of each scan for 6 key rollover + /* USER CODE END WHILE */ for(int col = 0; col < COLS; col++){ HAL_GPIO_WritePin(col_pins[col].PORT, col_pins[col].PIN, GPIO_PIN_SET); @@ -213,6 +216,31 @@ void addHIDReport(uint8_t usageID, uint8_t isPressed){ REPORT.KEYPRESS[byte_index] &= ~(1 << bit_offset); } } + +// 6 KEY ROLLOVER CODE STRUCTURE +/* +if (usageID < 0x04 || usageID > 0x73) return; + + int i, empty = -1; + if (isPressed) { + for (i = 0; i < 6; i++) { + if (REPORT.KEYPRESS[i] == usageID) return; // Already present + if (REPORT.KEYPRESS[i] == 0 && empty == -1) empty = i; + } + if (empty != -1) { + REPORT.KEYPRESS[empty] = usageID; + } + // If no empty slot, ignore (6KRO: only 6 keys allowed) + } else { + // Remove from the array when released + for (i = 0; i < 6; i++) { + if (REPORT.KEYPRESS[i] == usageID) { + REPORT.KEYPRESS[i] = 0; + } + } + } +*/ + /* USER CODE END 4 */ /** From d519070ef8d0d4625e390c171e951b1f7e9da074 Mon Sep 17 00:00:00 2001 From: Kymkim Date: Wed, 2 Jul 2025 23:45:59 -0700 Subject: [PATCH 2/2] separated HID struct for both nkro and 6kro --- .../stmf446retx/.vscode/c_cpp_properties.json | 8 ++++---- .../mainboard/stmf446retx/.vscode/launch.json | 6 +++--- firmware/components/mainboard/stmf446retx/Src/main.c | 10 ++++++++-- 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/firmware/components/mainboard/stmf446retx/.vscode/c_cpp_properties.json b/firmware/components/mainboard/stmf446retx/.vscode/c_cpp_properties.json index 69836baa..b67677ed 100644 --- a/firmware/components/mainboard/stmf446retx/.vscode/c_cpp_properties.json +++ b/firmware/components/mainboard/stmf446retx/.vscode/c_cpp_properties.json @@ -36,8 +36,8 @@ "/home/kymkim/.platformio/packages/framework-stm32cubef4/Middlewares/ST/STM32_USB_Device_Library/Class/AUDIO/Src", "/home/kymkim/.platformio/packages/framework-stm32cubef4/Middlewares/ST/STM32_USB_Device_Library/Core/Inc", "/home/kymkim/.platformio/packages/framework-stm32cubef4/Middlewares/ST/STM32_USB_Device_Library/Core/Src", - "/home/kymkim/Projects/modular-kbd/firmware/components/mainboard/stmf446retx/Src", - "/home/kymkim/Projects/modular-kbd/firmware/components/mainboard/stmf446retx/Inc", + "/home/kymkim/Projects/module-dev-mskbd/modular-kbd/firmware/components/mainboard/stmf446retx/Src", + "/home/kymkim/Projects/module-dev-mskbd/modular-kbd/firmware/components/mainboard/stmf446retx/Inc", "/home/kymkim/.platformio/packages/framework-stm32cubef4/Drivers/CMSIS/Include", "/home/kymkim/.platformio/packages/framework-stm32cubef4/Drivers/CMSIS/Device/ST/STM32F4xx/Include", "/home/kymkim/.platformio/packages/framework-stm32cubef4/Drivers/STM32F4xx_HAL_Driver/Inc", @@ -128,8 +128,8 @@ "/home/kymkim/.platformio/packages/framework-stm32cubef4/Middlewares/ST/STM32_USB_Device_Library/Class/AUDIO/Src", "/home/kymkim/.platformio/packages/framework-stm32cubef4/Middlewares/ST/STM32_USB_Device_Library/Core/Inc", "/home/kymkim/.platformio/packages/framework-stm32cubef4/Middlewares/ST/STM32_USB_Device_Library/Core/Src", - "/home/kymkim/Projects/modular-kbd/firmware/components/mainboard/stmf446retx/Src", - "/home/kymkim/Projects/modular-kbd/firmware/components/mainboard/stmf446retx/Inc", + "/home/kymkim/Projects/module-dev-mskbd/modular-kbd/firmware/components/mainboard/stmf446retx/Src", + "/home/kymkim/Projects/module-dev-mskbd/modular-kbd/firmware/components/mainboard/stmf446retx/Inc", "/home/kymkim/.platformio/packages/framework-stm32cubef4/Drivers/CMSIS/Include", "/home/kymkim/.platformio/packages/framework-stm32cubef4/Drivers/CMSIS/Device/ST/STM32F4xx/Include", "/home/kymkim/.platformio/packages/framework-stm32cubef4/Drivers/STM32F4xx_HAL_Driver/Inc", diff --git a/firmware/components/mainboard/stmf446retx/.vscode/launch.json b/firmware/components/mainboard/stmf446retx/.vscode/launch.json index 5e2348d7..413ac318 100644 --- a/firmware/components/mainboard/stmf446retx/.vscode/launch.json +++ b/firmware/components/mainboard/stmf446retx/.vscode/launch.json @@ -12,7 +12,7 @@ "type": "platformio-debug", "request": "launch", "name": "PIO Debug", - "executable": "/home/kymkim/Projects/modular-kbd/firmware/components/mainboard/stmf446retx/.pio/build/nucleo_f446re/firmware.elf", + "executable": "/home/kymkim/Projects/module-dev-mskbd/modular-kbd/firmware/components/mainboard/stmf446retx/.pio/build/nucleo_f446re/firmware.elf", "projectEnvName": "nucleo_f446re", "toolchainBinDir": "/home/kymkim/.platformio/packages/toolchain-gccarmnoneeabi/bin", "internalConsoleOptions": "openOnSessionStart", @@ -26,7 +26,7 @@ "type": "platformio-debug", "request": "launch", "name": "PIO Debug (skip Pre-Debug)", - "executable": "/home/kymkim/Projects/modular-kbd/firmware/components/mainboard/stmf446retx/.pio/build/nucleo_f446re/firmware.elf", + "executable": "/home/kymkim/Projects/module-dev-mskbd/modular-kbd/firmware/components/mainboard/stmf446retx/.pio/build/nucleo_f446re/firmware.elf", "projectEnvName": "nucleo_f446re", "toolchainBinDir": "/home/kymkim/.platformio/packages/toolchain-gccarmnoneeabi/bin", "internalConsoleOptions": "openOnSessionStart", @@ -36,7 +36,7 @@ "type": "platformio-debug", "request": "launch", "name": "PIO Debug (without uploading)", - "executable": "/home/kymkim/Projects/modular-kbd/firmware/components/mainboard/stmf446retx/.pio/build/nucleo_f446re/firmware.elf", + "executable": "/home/kymkim/Projects/module-dev-mskbd/modular-kbd/firmware/components/mainboard/stmf446retx/.pio/build/nucleo_f446re/firmware.elf", "projectEnvName": "nucleo_f446re", "toolchainBinDir": "/home/kymkim/.platformio/packages/toolchain-gccarmnoneeabi/bin", "internalConsoleOptions": "openOnSessionStart", diff --git a/firmware/components/mainboard/stmf446retx/Src/main.c b/firmware/components/mainboard/stmf446retx/Src/main.c index 01cb552c..220526d0 100644 --- a/firmware/components/mainboard/stmf446retx/Src/main.c +++ b/firmware/components/mainboard/stmf446retx/Src/main.c @@ -30,11 +30,17 @@ /* Private typedef -----------------------------------------------------------*/ /* USER CODE BEGIN PTD */ +typedef struct{ + uint8_t MODIFIER; + uint8_t RESERVED; + uint8_t KEYPRESS[13]; +} HIDReportNKRO; + typedef struct{ uint8_t MODIFIER; uint8_t RESERVED; uint8_t KEYPRESS[6]; // for 6 Key Rollover, changed index to 6. -} HIDReport; +} HIDReport6KRO; typedef struct{ GPIO_TypeDef* PORT; @@ -70,7 +76,7 @@ KbdPins col_pins[COLS] = { {GPIOB, GPIO_PIN_14}, {GPIOB, GPIO_PIN_13} }; -HIDReport REPORT = {0,0,0,0,0,0,0,0}; +HIDReportNKRO REPORT = {0,0,0,0,0,0,0,0}; CAN_RxHeaderTypeDef RxHeader; uint8_t RxData[8]; /* USER CODE END PV */