2 Commits

Author SHA1 Message Date
eeeck ce85e473b3 Move before starting scheduler to avoid race condition
- If a CAN message arrives during boot time ISR will fire and try to put
  data into xCAN1RxQueue. At that time queue is NULL: calling RTOS APIs
  on NULL handles will cause a HardFault
2026-06-15 14:11:11 +02:00
eeeck 8c8fe93d5b Release CANrx semaphore in ISR 2026-06-15 14:09:51 +02:00
2 changed files with 4 additions and 1 deletions
+3
View File
@@ -85,6 +85,9 @@ void HAL_CAN_RxFifo0MsgPendingCallback(CAN_HandleTypeDef *hcan)
// send errors like queue full via UART
}
osSemaphoreId_t semaphore = (hcan->Instance == CAN1) ? xSemaphoreCAN1 : xSemaphoreCAN2;
osSemaphoreRelease(semaphore);
/* CODE END */
}
/* END HAL_CAN_RxFifo0MsgPendingCallback */
+1 -1
View File
@@ -110,7 +110,6 @@ int main(void)
MX_SDIO_SD_Init();
/* USER CODE BEGIN 2 */
CAN_Logger_Init(&hcan1, &hcan2);
/* USER CODE END 2 */
/* Init scheduler */
@@ -185,6 +184,7 @@ int main(void)
/* USER CODE END RTOS_EVENTS */
/* USER CODE BEGIN 3 */
CAN_Logger_Init(&hcan1, &hcan2);
/* USER CODE END 3 */
/* Start scheduler */