Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 263b699662 | |||
| da0211ebd5 | |||
| d5fd649325 | |||
| 79ef4c5fdb |
+19
-13
@@ -196,6 +196,9 @@ int main(void)
|
||||
xUartTask = osThreadNew(vUARTLogger, NULL, &UartLoggerAttributes);
|
||||
xCAN1LedTask = osThreadNew(vLEDHeartbeat, &led_can1, &LEDHeartbeatCAN1Attributes);
|
||||
xCAN2LedTask = osThreadNew(vLEDHeartbeat, &led_can2, &LEDHeartbeatCAN2Attributes);
|
||||
|
||||
if (xCAN1rxTask == NULL || xCAN2rxTask == NULL || xUartTask == NULL ||
|
||||
xCAN1LedTask == NULL || xCAN2LedTask == NULL) Error_Handler();
|
||||
/* USER CODE END RTOS_THREADS */
|
||||
|
||||
/* USER CODE BEGIN RTOS_EVENTS */
|
||||
@@ -282,7 +285,7 @@ static void MX_CAN1_Init(void)
|
||||
/* USER CODE END CAN1_Init 1 */
|
||||
hcan1.Instance = CAN1;
|
||||
hcan1.Init.Prescaler = 4;
|
||||
hcan1.Init.Mode = CAN_MODE_SILENT;
|
||||
hcan1.Init.Mode = CAN_MODE_NORMAL;
|
||||
hcan1.Init.SyncJumpWidth = CAN_SJW_1TQ;
|
||||
hcan1.Init.TimeSeg1 = CAN_BS1_16TQ;
|
||||
hcan1.Init.TimeSeg2 = CAN_BS2_4TQ;
|
||||
@@ -319,7 +322,7 @@ static void MX_CAN2_Init(void)
|
||||
/* USER CODE END CAN2_Init 1 */
|
||||
hcan2.Instance = CAN2;
|
||||
hcan2.Init.Prescaler = 8;
|
||||
hcan2.Init.Mode = CAN_MODE_SILENT;
|
||||
hcan2.Init.Mode = CAN_MODE_NORMAL;
|
||||
hcan2.Init.SyncJumpWidth = CAN_SJW_1TQ;
|
||||
hcan2.Init.TimeSeg1 = CAN_BS1_16TQ;
|
||||
hcan2.Init.TimeSeg2 = CAN_BS2_4TQ;
|
||||
@@ -391,7 +394,7 @@ static void MX_USART1_UART_Init(void)
|
||||
|
||||
/* USER CODE END USART1_Init 1 */
|
||||
huart1.Instance = USART1;
|
||||
huart1.Init.BaudRate = 1152000;
|
||||
huart1.Init.BaudRate = 1000000;
|
||||
huart1.Init.WordLength = UART_WORDLENGTH_8B;
|
||||
huart1.Init.StopBits = UART_STOPBITS_1;
|
||||
huart1.Init.Parity = UART_PARITY_NONE;
|
||||
@@ -554,18 +557,21 @@ void Error_Handler(void)
|
||||
|
||||
/* USER CODE BEGIN Error_Handler_Debug */
|
||||
/* User can add his own implementation to report the HAL error return state */
|
||||
if (HAL_CAN_GetState(&hcan1) != HAL_CAN_STATE_READY)
|
||||
{
|
||||
DEBUG_PRINT("[E] CAN1 error code: 0x%08lX\r\n", (unsigned long)HAL_CAN_GetError(&hcan1));
|
||||
}
|
||||
if (HAL_CAN_GetState(&hcan2) != HAL_CAN_STATE_READY)
|
||||
{
|
||||
DEBUG_PRINT("[E] CAN2 error code: 0x%08lX\r\n", (unsigned long)HAL_CAN_GetError(&hcan2));
|
||||
}
|
||||
|
||||
// TODO: write error to SD
|
||||
|
||||
/* Disabling interrupts here (after reporting above) freezes the FreeRTOS
|
||||
scheduler for good, since it relies on SysTick/PendSV. */
|
||||
__disable_irq();
|
||||
|
||||
//TODO: check if it is necessary to stop FreeRTOS
|
||||
|
||||
uint32_t error_code_can1;
|
||||
uint32_t error_code_can2;
|
||||
|
||||
if (HAL_CAN_GetState(&hcan1) != HAL_CAN_STATE_READY) error_code_can1 = HAL_CAN_GetError(&hcan1);
|
||||
if (HAL_CAN_GetState(&hcan2) != HAL_CAN_STATE_READY) error_code_can2 = HAL_CAN_GetError(&hcan2);
|
||||
|
||||
// TODO: write error to SD and/or serial
|
||||
|
||||
HAL_GPIO_WritePin(led_can1.port, led_can1.pin, GPIO_PIN_RESET);
|
||||
HAL_GPIO_WritePin(led_can2.port, led_can2.pin, GPIO_PIN_RESET);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user