From 323a11e9caf22731221155f7b6c553126b703819 Mon Sep 17 00:00:00 2001 From: Kymkim Date: Tue, 15 Jul 2025 11:41:31 -0700 Subject: [PATCH] prototype mainboard done! --- .../stmf446retx/.vscode/c_cpp_properties.json | 8 ++--- .../mainboard/stmf446retx/.vscode/launch.json | 6 ++-- firmware/mainboard/stmf446retx/Src/can.c | 9 +++--- firmware/mainboard/stmf446retx/Src/main.c | 30 ++++++++----------- .../sample_module/.pio/build/project.checksum | 2 +- .../.vscode/c_cpp_properties.json | 8 ++--- .../modules/sample_module/.vscode/launch.json | 6 ++-- firmware/modules/sample_module/Src/can.c | 6 ++-- 8 files changed, 35 insertions(+), 40 deletions(-) diff --git a/firmware/mainboard/stmf446retx/.vscode/c_cpp_properties.json b/firmware/mainboard/stmf446retx/.vscode/c_cpp_properties.json index 8faef710..4c80da0b 100644 --- a/firmware/mainboard/stmf446retx/.vscode/c_cpp_properties.json +++ b/firmware/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/CSULB/modular-kbd/firmware/components/mainboard/stmf446retx/Src", - "/home/kymkim/Projects/CSULB/modular-kbd/firmware/components/mainboard/stmf446retx/Inc", + "/home/kymkim/Projects/modular-kbd/firmware/mainboard/stmf446retx/Src", + "/home/kymkim/Projects/modular-kbd/firmware/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/CSULB/modular-kbd/firmware/components/mainboard/stmf446retx/Src", - "/home/kymkim/Projects/CSULB/modular-kbd/firmware/components/mainboard/stmf446retx/Inc", + "/home/kymkim/Projects/modular-kbd/firmware/mainboard/stmf446retx/Src", + "/home/kymkim/Projects/modular-kbd/firmware/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/mainboard/stmf446retx/.vscode/launch.json b/firmware/mainboard/stmf446retx/.vscode/launch.json index 43744156..edbc33e0 100644 --- a/firmware/mainboard/stmf446retx/.vscode/launch.json +++ b/firmware/mainboard/stmf446retx/.vscode/launch.json @@ -12,7 +12,7 @@ "type": "platformio-debug", "request": "launch", "name": "PIO Debug", - "executable": "/home/kymkim/Projects/CSULB/modular-kbd/firmware/components/mainboard/stmf446retx/.pio/build/nucleo_f446re/firmware.elf", + "executable": "/home/kymkim/Projects/modular-kbd/firmware/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/CSULB/modular-kbd/firmware/components/mainboard/stmf446retx/.pio/build/nucleo_f446re/firmware.elf", + "executable": "/home/kymkim/Projects/modular-kbd/firmware/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/CSULB/modular-kbd/firmware/components/mainboard/stmf446retx/.pio/build/nucleo_f446re/firmware.elf", + "executable": "/home/kymkim/Projects/modular-kbd/firmware/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/mainboard/stmf446retx/Src/can.c b/firmware/mainboard/stmf446retx/Src/can.c index ae42cd72..f0a7926d 100644 --- a/firmware/mainboard/stmf446retx/Src/can.c +++ b/firmware/mainboard/stmf446retx/Src/can.c @@ -57,12 +57,11 @@ void MX_CAN1_Init(void) CAN_FilterTypeDef canfilterconf; canfilterconf.FilterActivation = CAN_FILTER_ENABLE; canfilterconf.FilterBank = 0; - canfilterconf.FilterFIFOAssignment = CAN_FILTER_FIFO1; - canfilterconf.FilterIdHigh = 0x399 << 5; - canfilterconf.FilterIdLow = 0x0000; - canfilterconf.FilterMaskIdHigh = 0x7FF << 5; + canfilterconf.FilterFIFOAssignment = CAN_FILTER_FIFO0; + canfilterconf.FilterIdHigh = 0x100 << 5; + canfilterconf.FilterIdLow = 0x0000; + canfilterconf.FilterMaskIdHigh = 0x7FF << 5; // Exact match mask canfilterconf.FilterMaskIdLow = 0x0000; - canfilterconf.FilterMode = CAN_FILTERMODE_IDMASK; canfilterconf.FilterScale = CAN_FILTERSCALE_32BIT; HAL_CAN_ConfigFilter(&hcan1, &canfilterconf); /* USER CODE END CAN1_Init 2 */ diff --git a/firmware/mainboard/stmf446retx/Src/main.c b/firmware/mainboard/stmf446retx/Src/main.c index 220526d0..688b4ed2 100644 --- a/firmware/mainboard/stmf446retx/Src/main.c +++ b/firmware/mainboard/stmf446retx/Src/main.c @@ -33,7 +33,7 @@ typedef struct{ uint8_t MODIFIER; uint8_t RESERVED; - uint8_t KEYPRESS[13]; + uint8_t KEYPRESS[12]; } HIDReportNKRO; typedef struct{ @@ -134,22 +134,18 @@ int main(void) while (1) { //Keycode Scan - - // memset(REPORT.KEYPRESS, 0, 6); // Clear keypresses at the start of each scan for 6 key rollover - + // 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); - HAL_Delay(1); - for(int row = 0; row < ROWS; row++){ - if(HAL_GPIO_ReadPin(row_pins[row].PORT, row_pins[row].PIN)){ - addHIDReport(matrix[row][col], 1); - }else{ - addHIDReport(matrix[row][col], 0); - } - } - HAL_GPIO_WritePin(col_pins[col].PORT, col_pins[col].PIN, GPIO_PIN_RESET); - } + // for(int col = 0; col < COLS; col++){ + // HAL_GPIO_WritePin(col_pins[col].PORT, col_pins[col].PIN, GPIO_PIN_SET); + // HAL_Delay(1); + // for(int row = 0; row < ROWS; row++){ + // if(HAL_GPIO_ReadPin(row_pins[row].PORT, row_pins[row].PIN)){ + // addHIDReport(matrix[row][col], 1); + // } + // } + // HAL_GPIO_WritePin(col_pins[col].PORT, col_pins[col].PIN, GPIO_PIN_RESET); + // } USBD_HID_SendReport(&hUsbDeviceFS, (uint8_t*)&REPORT, sizeof(REPORT)); HAL_Delay(20); /* USER CODE BEGIN 3 */ @@ -160,7 +156,7 @@ int main(void) void HAL_CAN_RxFifo0MsgPendingCallback(CAN_HandleTypeDef *hcan) { HAL_CAN_GetRxMessage(hcan, CAN_RX_FIFO0, &RxHeader, RxData); - addHIDReport(RxData[0], (RxData[1] & (1 << 7)) ? 1 : 0); + addHIDReport(RxData[0], (RxData[1] & 0x01) ? 1 : 0); } /** * @brief System Clock Configuration diff --git a/firmware/modules/sample_module/.pio/build/project.checksum b/firmware/modules/sample_module/.pio/build/project.checksum index 4aff4c9d..e3d0c4d0 100644 --- a/firmware/modules/sample_module/.pio/build/project.checksum +++ b/firmware/modules/sample_module/.pio/build/project.checksum @@ -1 +1 @@ -2c6909f9688b4acb0de5f41f5b66ff6d9ae65699 \ No newline at end of file +0155328e36f0c1915c840fe3dc3713be2dd09ff7 \ No newline at end of file diff --git a/firmware/modules/sample_module/.vscode/c_cpp_properties.json b/firmware/modules/sample_module/.vscode/c_cpp_properties.json index ff4ccd14..290aca0c 100644 --- a/firmware/modules/sample_module/.vscode/c_cpp_properties.json +++ b/firmware/modules/sample_module/.vscode/c_cpp_properties.json @@ -8,8 +8,8 @@ { "name": "PlatformIO", "includePath": [ - "/home/kymkim/Projects/modular-kbd/firmware/components/modules/sample_module/Inc", - "/home/kymkim/Projects/modular-kbd/firmware/components/modules/sample_module/Src", + "/home/kymkim/Projects/modular-kbd/firmware/modules/sample_module/Inc", + "/home/kymkim/Projects/modular-kbd/firmware/modules/sample_module/Src", "/home/kymkim/.platformio/packages/framework-stm32cubef1/Drivers/CMSIS/Include", "/home/kymkim/.platformio/packages/framework-stm32cubef1/Drivers/CMSIS/Device/ST/STM32F1xx/Include", "/home/kymkim/.platformio/packages/framework-stm32cubef1/Drivers/STM32F1xx_HAL_Driver/Inc", @@ -61,8 +61,8 @@ "browse": { "limitSymbolsToIncludedHeaders": true, "path": [ - "/home/kymkim/Projects/modular-kbd/firmware/components/modules/sample_module/Inc", - "/home/kymkim/Projects/modular-kbd/firmware/components/modules/sample_module/Src", + "/home/kymkim/Projects/modular-kbd/firmware/modules/sample_module/Inc", + "/home/kymkim/Projects/modular-kbd/firmware/modules/sample_module/Src", "/home/kymkim/.platformio/packages/framework-stm32cubef1/Drivers/CMSIS/Include", "/home/kymkim/.platformio/packages/framework-stm32cubef1/Drivers/CMSIS/Device/ST/STM32F1xx/Include", "/home/kymkim/.platformio/packages/framework-stm32cubef1/Drivers/STM32F1xx_HAL_Driver/Inc", diff --git a/firmware/modules/sample_module/.vscode/launch.json b/firmware/modules/sample_module/.vscode/launch.json index 6d51024c..ea1b930d 100644 --- a/firmware/modules/sample_module/.vscode/launch.json +++ b/firmware/modules/sample_module/.vscode/launch.json @@ -12,7 +12,7 @@ "type": "platformio-debug", "request": "launch", "name": "PIO Debug", - "executable": "/home/kymkim/Projects/modular-kbd/firmware/components/modules/sample_module/.pio/build/bluepill_f103c8/firmware.elf", + "executable": "/home/kymkim/Projects/modular-kbd/firmware/modules/sample_module/.pio/build/bluepill_f103c8/firmware.elf", "projectEnvName": "bluepill_f103c8", "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/modules/sample_module/.pio/build/bluepill_f103c8/firmware.elf", + "executable": "/home/kymkim/Projects/modular-kbd/firmware/modules/sample_module/.pio/build/bluepill_f103c8/firmware.elf", "projectEnvName": "bluepill_f103c8", "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/modules/sample_module/.pio/build/bluepill_f103c8/firmware.elf", + "executable": "/home/kymkim/Projects/modular-kbd/firmware/modules/sample_module/.pio/build/bluepill_f103c8/firmware.elf", "projectEnvName": "bluepill_f103c8", "toolchainBinDir": "/home/kymkim/.platformio/packages/toolchain-gccarmnoneeabi/bin", "internalConsoleOptions": "openOnSessionStart", diff --git a/firmware/modules/sample_module/Src/can.c b/firmware/modules/sample_module/Src/can.c index 64bc0c84..cac16bd9 100644 --- a/firmware/modules/sample_module/Src/can.c +++ b/firmware/modules/sample_module/Src/can.c @@ -38,11 +38,11 @@ void MX_CAN_Init(void) /* USER CODE END CAN_Init 1 */ hcan.Instance = CAN1; - hcan.Init.Prescaler = 18; + hcan.Init.Prescaler = 6; hcan.Init.Mode = CAN_MODE_NORMAL; hcan.Init.SyncJumpWidth = CAN_SJW_1TQ; - hcan.Init.TimeSeg1 = CAN_BS1_13TQ; - hcan.Init.TimeSeg2 = CAN_BS2_2TQ; + hcan.Init.TimeSeg1 = CAN_BS1_16TQ; + hcan.Init.TimeSeg2 = CAN_BS2_7TQ; hcan.Init.TimeTriggeredMode = DISABLE; hcan.Init.AutoBusOff = DISABLE; hcan.Init.AutoWakeUp = DISABLE;