Compare commits
4 Commits
87e8ffc6fa
...
6c4a1368be
| Author | SHA1 | Date | |
|---|---|---|---|
| 6c4a1368be | |||
| e2b6d13364 | |||
| b14cdfaccb | |||
| 7bb401762a |
@@ -1,3 +1,24 @@
|
|||||||
|
/* USER CODE BEGIN Header */
|
||||||
|
/**
|
||||||
|
******************************************************************************
|
||||||
|
* @file : canlog.h
|
||||||
|
* @brief : Header for canlog.c file.
|
||||||
|
* This file contains the defines related to SAE J1939 CAN.
|
||||||
|
******************************************************************************
|
||||||
|
* @attention
|
||||||
|
*
|
||||||
|
* Copyright (c) 2026 STMicroelectronics.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* This software is licensed under terms that can be found in the LICENSE file
|
||||||
|
* in the root directory of this software component.
|
||||||
|
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||||
|
*
|
||||||
|
******************************************************************************
|
||||||
|
*/
|
||||||
|
/* USER CODE END Header */
|
||||||
|
|
||||||
|
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||||
#ifndef CANLOG_H
|
#ifndef CANLOG_H
|
||||||
#define CANLOG_H
|
#define CANLOG_H
|
||||||
|
|
||||||
|
|||||||
+40
-20
@@ -1,7 +1,28 @@
|
|||||||
|
/* USER CODE BEGIN Header */
|
||||||
|
/**
|
||||||
|
******************************************************************************
|
||||||
|
* @file : canlog.c
|
||||||
|
* @brief : SAE J1939 CAN Real Time listening and decoding
|
||||||
|
******************************************************************************
|
||||||
|
* @attention
|
||||||
|
*
|
||||||
|
* Copyright (c) 2026 STMicroelectronics.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* This software is licensed under terms that can be found in the LICENSE file
|
||||||
|
* in the root directory of this software component.
|
||||||
|
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||||
|
*
|
||||||
|
******************************************************************************
|
||||||
|
*/
|
||||||
|
/* USER CODE END Header */
|
||||||
|
/* Includes ------------------------------------------------------------------*/
|
||||||
#include "canlog.h"
|
#include "canlog.h"
|
||||||
|
/* Private includes ----------------------------------------------------------*/
|
||||||
|
/* USER CODE BEGIN Includes */
|
||||||
#include "cmsis_os.h"
|
#include "cmsis_os.h"
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
/* USER CODE END Includes */
|
||||||
|
|
||||||
extern CAN_HandleTypeDef hcan1;
|
extern CAN_HandleTypeDef hcan1;
|
||||||
extern CAN_HandleTypeDef hcan2;
|
extern CAN_HandleTypeDef hcan2;
|
||||||
@@ -28,7 +49,7 @@ osThreadId_t vLED_CAN1_Heartbeat;
|
|||||||
const osThreadAttr_t vLED_CAN1_Heartbeat_attributes = {
|
const osThreadAttr_t vLED_CAN1_Heartbeat_attributes = {
|
||||||
.name = "vLED_CAN1_HeartbeatTask",
|
.name = "vLED_CAN1_HeartbeatTask",
|
||||||
.stack_size = 128 * 4,
|
.stack_size = 128 * 4,
|
||||||
.priority = (osPriority_t) osPriorityLow1,
|
.priority = (osPriority_t) osPriorityVeryLow1,
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Definitions for CAN2 LED heartbeat */
|
/* Definitions for CAN2 LED heartbeat */
|
||||||
@@ -36,15 +57,16 @@ osThreadId_t vLED_CAN2_Heartbeat;
|
|||||||
const osThreadAttr_t vLED_CAN2_Heartbeat_attributes = {
|
const osThreadAttr_t vLED_CAN2_Heartbeat_attributes = {
|
||||||
.name = "vLED_CAN2_HeartbeatTask",
|
.name = "vLED_CAN2_HeartbeatTask",
|
||||||
.stack_size = 128 * 4,
|
.stack_size = 128 * 4,
|
||||||
.priority = (osPriority_t) osPriorityLow,
|
.priority = (osPriority_t) osPriorityVeryLow,
|
||||||
};
|
};
|
||||||
/* USER END RTOS_TASKS */
|
/* USER END RTOS_TASKS */
|
||||||
|
|
||||||
|
|
||||||
/* Private function prototypes -----------------------------------------------*/
|
/* Private function prototypes -----------------------------------------------*/
|
||||||
|
/* USER CODE BEGIN FunctionPrototypes */
|
||||||
/* BEGIN CAN_Logger_Init */
|
/* BEGIN CAN_Logger_Init */
|
||||||
/**
|
/**
|
||||||
* @brief Initialize CAN
|
* @brief Initialize CAN bus logger.
|
||||||
* @param argument: hcan1, hcan2
|
* @param argument: hcan1, hcan2
|
||||||
* @retval None
|
* @retval None
|
||||||
*/
|
*/
|
||||||
@@ -71,34 +93,31 @@ void CAN_Logger_Init(CAN_HandleTypeDef *hcan1, CAN_HandleTypeDef *hcan2)
|
|||||||
}
|
}
|
||||||
/* END CAN_Logger_Init */
|
/* END CAN_Logger_Init */
|
||||||
|
|
||||||
static void CAN_Listen(void *argument){}
|
/* BEGIN vCAN_Logger_Listen */
|
||||||
|
|
||||||
/* BEGIN vCAN_Get */
|
|
||||||
/**
|
/**
|
||||||
* @brief Log incoming CAN bus traffic in FIFO buffer
|
* @brief Log incoming CAN bus traffic in FIFO buffer
|
||||||
* @param argument: Not used
|
* @param argument: Not used
|
||||||
* @retval None
|
* @retval None
|
||||||
*/
|
*/
|
||||||
void vCAN_Get(void *argument)
|
static void vCAN_Logger_Listen(void *argument)
|
||||||
{
|
{
|
||||||
/* CODE BEGIN */
|
/* CODE BEGIN */
|
||||||
/* Infinite loop */
|
/* Infinite loop */
|
||||||
for(;;)
|
for(;;)
|
||||||
{
|
{
|
||||||
osDelay(1);
|
osDelay(1);
|
||||||
}
|
}
|
||||||
/* CODE END */
|
/* CODE END */
|
||||||
}
|
}
|
||||||
/* END vCAN_Get */
|
/* END vCAN_Logger_Listen */
|
||||||
|
|
||||||
|
/* BEGIN vLED_Heartbeat */
|
||||||
/* BEGIN vLED_HeartbeatOnCanRx */
|
|
||||||
/**
|
/**
|
||||||
* @brief Blink a LED in heartbeat mode when there is CAN traffic detected
|
* @brief Blink a LED in heartbeat mode when CAN traffic is detected
|
||||||
* @param argument: LED GPIO (port and pin)
|
* @param argument: LED GPIO (port and pin)
|
||||||
* @retval None
|
* @retval None
|
||||||
*/
|
*/
|
||||||
void vLED_HeartbeatOnCanRx(void *argument)
|
void vLED_Heartbeat(void *argument)
|
||||||
{
|
{
|
||||||
/* CODE BEGIN */
|
/* CODE BEGIN */
|
||||||
LED_Config *led = (LED_Config*)argument;
|
LED_Config *led = (LED_Config*)argument;
|
||||||
@@ -117,3 +136,4 @@ void vLED_HeartbeatOnCanRx(void *argument)
|
|||||||
/* CODE END */
|
/* CODE END */
|
||||||
}
|
}
|
||||||
/* END vLED_HeartbeatOnCanRx */
|
/* END vLED_HeartbeatOnCanRx */
|
||||||
|
/* USER CODE END FunctionPrototypes */
|
||||||
|
|||||||
+6
-6
@@ -66,8 +66,8 @@ static void MX_CAN2_Init(void);
|
|||||||
static void MX_SDIO_SD_Init(void);
|
static void MX_SDIO_SD_Init(void);
|
||||||
|
|
||||||
/* USER CODE BEGIN PFP */
|
/* USER CODE BEGIN PFP */
|
||||||
void vCAN_Get(void *argument);
|
void vCAN_Logger_Listen(void *argument);
|
||||||
void vLED_HeartbeatOnCanRx(void *argument);
|
void vLED_Heartbeat(void *argument);
|
||||||
/* USER CODE END PFP */
|
/* USER CODE END PFP */
|
||||||
|
|
||||||
/* Private user code ---------------------------------------------------------*/
|
/* Private user code ---------------------------------------------------------*/
|
||||||
@@ -134,10 +134,10 @@ int main(void)
|
|||||||
/* USER CODE END RTOS_QUEUES */
|
/* USER CODE END RTOS_QUEUES */
|
||||||
|
|
||||||
/* USER CODE BEGIN RTOS_THREADS */
|
/* USER CODE BEGIN RTOS_THREADS */
|
||||||
vCAN1_rx = osThreadNew(vCAN_Get, &hcan1, &vCAN1_rx_attributes);
|
vCAN1_rx = osThreadNew(vCAN_Logger_Listen, &hcan1, &vCAN1_rx_attributes);
|
||||||
vCAN2_rx = osThreadNew(vCAN_Get, &hcan2, &vCAN2_rx_attributes);
|
vCAN2_rx = osThreadNew(vCAN_Logger_Listen, &hcan2, &vCAN2_rx_attributes);
|
||||||
vLED_CAN1_Heartbeat = osThreadNew(vLED_HeartbeatOnCanRx, &led_can1, &vLED_CAN1_Heartbeat_attributes);
|
vLED_CAN1_Heartbeat = osThreadNew(vLED_Heartbeat, &led_can1, &vLED_CAN1_Heartbeat_attributes);
|
||||||
vLED_CAN2_Heartbeat = osThreadNew(vLED_HeartbeatOnCanRx, &led_can2, &vLED_CAN2_Heartbeat_attributes);
|
vLED_CAN2_Heartbeat = osThreadNew(vLED_Heartbeat, &led_can2, &vLED_CAN2_Heartbeat_attributes);
|
||||||
/* USER CODE END RTOS_THREADS */
|
/* USER CODE END RTOS_THREADS */
|
||||||
|
|
||||||
/* USER CODE BEGIN RTOS_EVENTS */
|
/* USER CODE BEGIN RTOS_EVENTS */
|
||||||
|
|||||||
Reference in New Issue
Block a user