somewhat works
This commit is contained in:
@@ -38,7 +38,7 @@ typedef struct {
|
||||
uint8_t MODIFIER; // Modifier keys (e.g., Ctrl, Shift, Alt, GUI/Win)
|
||||
uint8_t RESERVED; // Reserved for alignment, always set to 0
|
||||
uint8_t KEYPRESS[12]; // Array holding up to 12 keycodes being pressed
|
||||
} HIDReport;
|
||||
} __attribute__((packed)) HIDReport;
|
||||
|
||||
|
||||
// Switch pin mapping structure
|
||||
@@ -53,7 +53,7 @@ typedef struct {
|
||||
uint16_t DEPTH; // Custom field: could represent queue depth, layer, or message size
|
||||
uint16_t TYPE; // Message type identifier (defines what kind of message this is)
|
||||
uint8_t KEYPRESS[12]; // Keypress data (similar to HIDReport, but for UART transmission)
|
||||
} UARTMessage;
|
||||
} __attribute__((packed)) UARTMessage;
|
||||
|
||||
/* USER CODE END PTD */
|
||||
|
||||
@@ -100,7 +100,7 @@ SwitchPins COLUMN_PINS[COL] = {
|
||||
{GPIOC, GPIO_PIN_9},
|
||||
{GPIOC, GPIO_PIN_8},
|
||||
{GPIOC, GPIO_PIN_7},
|
||||
{GPIOC, GPIO_PIN_5}
|
||||
{GPIOC, GPIO_PIN_6}
|
||||
};
|
||||
|
||||
// Initialize keycodes array
|
||||
@@ -187,7 +187,6 @@ int main(void)
|
||||
HAL_UART_Receive_DMA(&huart2, (uint8_t*)&RX2Msg, sizeof(UARTMessage));
|
||||
HAL_UART_Receive_DMA(&huart4, (uint8_t*)&RX4Msg, sizeof(UARTMessage));
|
||||
HAL_UART_Receive_DMA(&huart5, (uint8_t*)&RX5Msg, sizeof(UARTMessage));
|
||||
HAL_TIM_PWM_Start(&htim2, TIM_CHANNEL_1);
|
||||
/* USER CODE END 2 */
|
||||
|
||||
/* Infinite loop */
|
||||
@@ -229,8 +228,8 @@ int main(void)
|
||||
break;
|
||||
|
||||
case MODE_MAINBOARD:
|
||||
resetReport();
|
||||
matrixScan();
|
||||
resetReport(); //Something related to this making the key stick. Likely due to race conditions
|
||||
matrixScan(); //Removing resetReport() makes the modules inputs works but makes the key stick
|
||||
USBD_HID_SendReport(&hUsbDeviceFS, (uint8_t*)&REPORT, sizeof(REPORT));
|
||||
break;
|
||||
|
||||
@@ -313,6 +312,23 @@ void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart) {
|
||||
}
|
||||
}
|
||||
|
||||
void HAL_UART_ErrorCallback(UART_HandleTypeDef *huart) {
|
||||
// Restart DMA on error
|
||||
if (huart->Instance == USART1) {
|
||||
HAL_UART_Receive_DMA(&huart1, (uint8_t*)&RX1Msg, sizeof(UARTMessage));
|
||||
}
|
||||
else if (huart->Instance == USART2) {
|
||||
HAL_UART_Receive_DMA(&huart2, (uint8_t*)&RX2Msg, sizeof(UARTMessage));
|
||||
}
|
||||
else if (huart->Instance == UART4) {
|
||||
HAL_UART_Receive_DMA(&huart4, (uint8_t*)&RX4Msg, sizeof(UARTMessage));
|
||||
}
|
||||
else if (huart->Instance == UART5) {
|
||||
HAL_UART_Receive_DMA(&huart5, (uint8_t*)&RX5Msg, sizeof(UARTMessage));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void findBestParent(){
|
||||
//Find least depth parent
|
||||
|
||||
@@ -214,7 +214,7 @@ void HAL_UART_MspInit(UART_HandleTypeDef* uartHandle)
|
||||
__HAL_LINKDMA(uartHandle,hdmatx,hdma_uart4_tx);
|
||||
|
||||
/* UART4 interrupt Init */
|
||||
HAL_NVIC_SetPriority(UART4_IRQn, 0, 0);
|
||||
HAL_NVIC_SetPriority(UART4_IRQn, 5, 0);
|
||||
HAL_NVIC_EnableIRQ(UART4_IRQn);
|
||||
/* USER CODE BEGIN UART4_MspInit 1 */
|
||||
|
||||
@@ -286,7 +286,7 @@ void HAL_UART_MspInit(UART_HandleTypeDef* uartHandle)
|
||||
__HAL_LINKDMA(uartHandle,hdmatx,hdma_uart5_tx);
|
||||
|
||||
/* UART5 interrupt Init */
|
||||
HAL_NVIC_SetPriority(UART5_IRQn, 0, 0);
|
||||
HAL_NVIC_SetPriority(UART5_IRQn, 5, 0);
|
||||
HAL_NVIC_EnableIRQ(UART5_IRQn);
|
||||
/* USER CODE BEGIN UART5_MspInit 1 */
|
||||
|
||||
@@ -350,7 +350,7 @@ void HAL_UART_MspInit(UART_HandleTypeDef* uartHandle)
|
||||
__HAL_LINKDMA(uartHandle,hdmatx,hdma_usart1_tx);
|
||||
|
||||
/* USART1 interrupt Init */
|
||||
HAL_NVIC_SetPriority(USART1_IRQn, 0, 0);
|
||||
HAL_NVIC_SetPriority(USART1_IRQn, 5, 0);
|
||||
HAL_NVIC_EnableIRQ(USART1_IRQn);
|
||||
/* USER CODE BEGIN USART1_MspInit 1 */
|
||||
|
||||
@@ -414,7 +414,7 @@ void HAL_UART_MspInit(UART_HandleTypeDef* uartHandle)
|
||||
__HAL_LINKDMA(uartHandle,hdmatx,hdma_usart2_tx);
|
||||
|
||||
/* USART2 interrupt Init */
|
||||
HAL_NVIC_SetPriority(USART2_IRQn, 0, 0);
|
||||
HAL_NVIC_SetPriority(USART2_IRQn, 5, 0);
|
||||
HAL_NVIC_EnableIRQ(USART2_IRQn);
|
||||
/* USER CODE BEGIN USART2_MspInit 1 */
|
||||
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
../Core/Src/main.c:149:5:main 6
|
||||
../Core/Src/main.c:253:6:SystemClock_Config 3
|
||||
../Core/Src/main.c:297:6:HAL_UART_RxCpltCallback 5
|
||||
../Core/Src/main.c:317:6:findBestParent 4
|
||||
../Core/Src/main.c:338:6:handleUARTMessages 12
|
||||
../Core/Src/main.c:386:6:addUSBReport 3
|
||||
../Core/Src/main.c:394:6:matrixScan 4
|
||||
../Core/Src/main.c:407:6:resetReport 1
|
||||
../Core/Src/main.c:418:6:Error_Handler 1
|
||||
../Core/Src/main.c:150:5:main 7
|
||||
../Core/Src/main.c:256:6:SystemClock_Config 3
|
||||
../Core/Src/main.c:300:6:HAL_UART_RxCpltCallback 5
|
||||
../Core/Src/main.c:319:6:HAL_UART_ErrorCallback 5
|
||||
../Core/Src/main.c:337:6:findBestParent 4
|
||||
../Core/Src/main.c:358:6:handleUARTMessages 11
|
||||
../Core/Src/main.c:403:6:addUSBReport 3
|
||||
../Core/Src/main.c:411:6:matrixScan 4
|
||||
../Core/Src/main.c:424:6:resetReport 1
|
||||
../Core/Src/main.c:435:6:Error_Handler 1
|
||||
|
||||
Binary file not shown.
@@ -1,9 +1,10 @@
|
||||
../Core/Src/main.c:149:5:main 40 static
|
||||
../Core/Src/main.c:253:6:SystemClock_Config 88 static
|
||||
../Core/Src/main.c:297:6:HAL_UART_RxCpltCallback 16 static
|
||||
../Core/Src/main.c:317:6:findBestParent 24 static
|
||||
../Core/Src/main.c:338:6:handleUARTMessages 56 static
|
||||
../Core/Src/main.c:386:6:addUSBReport 24 static
|
||||
../Core/Src/main.c:394:6:matrixScan 16 static
|
||||
../Core/Src/main.c:407:6:resetReport 8 static
|
||||
../Core/Src/main.c:418:6:Error_Handler 4 static,ignoring_inline_asm
|
||||
../Core/Src/main.c:150:5:main 48 static
|
||||
../Core/Src/main.c:256:6:SystemClock_Config 88 static
|
||||
../Core/Src/main.c:300:6:HAL_UART_RxCpltCallback 16 static
|
||||
../Core/Src/main.c:319:6:HAL_UART_ErrorCallback 16 static
|
||||
../Core/Src/main.c:337:6:findBestParent 24 static
|
||||
../Core/Src/main.c:358:6:handleUARTMessages 56 static
|
||||
../Core/Src/main.c:403:6:addUSBReport 24 static
|
||||
../Core/Src/main.c:411:6:matrixScan 16 static
|
||||
../Core/Src/main.c:424:6:resetReport 8 static
|
||||
../Core/Src/main.c:435:6:Error_Handler 4 static,ignoring_inline_asm
|
||||
|
||||
Binary file not shown.
Binary file not shown.
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user