Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 4da8f59330 | |||
| c9f735acd9 | |||
| 30410f9b9e | |||
| e14a98eba4 |
+1
-4
@@ -93,10 +93,7 @@ void HAL_CAN_RxFifo0MsgPendingCallback(CAN_HandleTypeDef *hcan)
|
|||||||
led_task = xCAN2LedTask;
|
led_task = xCAN2LedTask;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (osMessageQueuePut(queue, &message, 0U, 0U) == osOK)
|
if (osMessageQueuePut(queue, &message, 0U, 0U) == osOK) osThreadFlagsSet(led_task, 0x01);
|
||||||
{
|
|
||||||
osThreadFlagsSet(led_task, 0x01);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
/* END HAL_CAN_RxFifo0MsgPendingCallback */
|
/* END HAL_CAN_RxFifo0MsgPendingCallback */
|
||||||
|
|
||||||
|
|||||||
+29
-6
@@ -56,7 +56,10 @@ void uart_printf(const char *fmt, ...)
|
|||||||
osSemaphoreRelease(xUARTDMASemaphore);
|
osSemaphoreRelease(xUARTDMASemaphore);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else HAL_UART_Transmit(&huart1, (uint8_t*)buf, len, HAL_MAX_DELAY);
|
else
|
||||||
|
{
|
||||||
|
HAL_UART_Transmit(&huart1, (uint8_t*)buf, len, HAL_MAX_DELAY);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* END uart_printf */
|
/* END uart_printf */
|
||||||
@@ -151,13 +154,31 @@ void vUARTLogger(void *argument)
|
|||||||
CanMessage_t message;
|
CanMessage_t message;
|
||||||
char tx_buffer[45];
|
char tx_buffer[45];
|
||||||
|
|
||||||
|
#ifdef DEBUG_DUMMY_FRAME
|
||||||
|
CanMessage_t dummy_frame = {
|
||||||
|
.id = 0x0CF00400, // J1939 EEC1 ID
|
||||||
|
.dlc = 8, // 8 bytes of data
|
||||||
|
.isExtended = 1, // 29-bit Extended ID
|
||||||
|
.source = 1, // CAN1
|
||||||
|
.payload = {0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF, 0x11, 0x22}
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
DEBUG_PRINT("[D] Waiting for CAN traffic...\r\n");
|
uint32_t queue_timeout = 2500U;
|
||||||
|
|
||||||
if (osMessageQueueGet(xUARTQueue, &message, NULL, osWaitForever) == osOK)
|
//#ifdef DEBUG_DUMMY_FRAME
|
||||||
{
|
//uint32_t queue_timeout = 100U;
|
||||||
if (osSemaphoreAcquire(xUARTDMASemaphore, osWaitForever) == osOK)
|
//osMessageQueuePut(xUARTQueue, &dummy_frame, 0U, 0U);
|
||||||
|
//osDelay(500);
|
||||||
|
//#else
|
||||||
|
//uint32_t queue_timeout = osWaitForever;
|
||||||
|
// #endif
|
||||||
|
|
||||||
|
if (osMessageQueueGet(xUARTQueue, &message, NULL, queue_timeout) == osOK)
|
||||||
|
{
|
||||||
|
if (osSemaphoreAcquire(xUARTDMASemaphore, queue_timeout) == osOK)
|
||||||
{
|
{
|
||||||
int len = format_can_message(tx_buffer, message.source, &message);
|
int len = format_can_message(tx_buffer, message.source, &message);
|
||||||
|
|
||||||
@@ -167,7 +188,9 @@ void vUARTLogger(void *argument)
|
|||||||
DEBUG_PRINT("[E] HAL error, CAN frame NOT sent!\r\n");
|
DEBUG_PRINT("[E] HAL error, CAN frame NOT sent!\r\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
else DEBUG_PRINT("[E] Semaphore timeout! UART might be stuck in BUSY state.\r\n");
|
||||||
|
}
|
||||||
|
else DEBUG_PRINT("[D] Waiting for CAN traffic...\r\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* END vUARTLogger */
|
/* END vUARTLogger */
|
||||||
|
|||||||
+1
-1
@@ -127,12 +127,12 @@ int main(void)
|
|||||||
/* USER CODE END SysInit */
|
/* USER CODE END SysInit */
|
||||||
|
|
||||||
/* Initialize all configured peripherals */
|
/* Initialize all configured peripherals */
|
||||||
|
MX_USART1_UART_Init();
|
||||||
MX_GPIO_Init();
|
MX_GPIO_Init();
|
||||||
MX_DMA_Init();
|
MX_DMA_Init();
|
||||||
MX_CAN1_Init();
|
MX_CAN1_Init();
|
||||||
MX_CAN2_Init();
|
MX_CAN2_Init();
|
||||||
MX_SDIO_SD_Init();
|
MX_SDIO_SD_Init();
|
||||||
MX_USART1_UART_Init();
|
|
||||||
/* USER CODE BEGIN 2 */
|
/* USER CODE BEGIN 2 */
|
||||||
DEBUG_PRINT("[L] Initializing CAN bus logger\r\n");
|
DEBUG_PRINT("[L] Initializing CAN bus logger\r\n");
|
||||||
CAN_Logger_Init(&hcan1, &hcan2);
|
CAN_Logger_Init(&hcan1, &hcan2);
|
||||||
|
|||||||
Reference in New Issue
Block a user