Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| ac16f8150e | |||
| f0d2990b8d | |||
| 72ffb2644e | |||
| 2a3d5d17b3 | |||
| 151bac7a13 |
+3
-13
@@ -24,27 +24,17 @@
|
||||
|
||||
#include "main.h"
|
||||
|
||||
/* Decladerations for queues */
|
||||
extern osMessageQueueId_t xCAN1RxQueue;
|
||||
extern osMessageQueueId_t xCAN2RxQueue;
|
||||
|
||||
/* Decladerations for thread handles and attributes */
|
||||
extern osThreadId_t vCAN1_rx;
|
||||
extern osThreadId_t vCAN2_rx;
|
||||
extern osThreadId_t vLED_CAN1_Heartbeat;
|
||||
extern osThreadId_t vLED_CAN2_Heartbeat;
|
||||
|
||||
extern const osThreadAttr_t vCAN1_rx_attributes;
|
||||
extern const osThreadAttr_t vCAN2_rx_attributes;
|
||||
extern const osThreadAttr_t vLED_CAN1_Heartbeat_attributes;
|
||||
extern const osThreadAttr_t vLED_CAN2_Heartbeat_attributes;
|
||||
extern osSemaphoreId_t xLEDSemaphoreCAN1;
|
||||
extern osSemaphoreId_t xLEDSemaphoreCAN2;
|
||||
|
||||
/**
|
||||
* @brief Initializes the CAN logger modules, OS threads, queues, and hardware.
|
||||
* @param hcan1 Pointer to the CAN1 handle
|
||||
* @param hcan2 Pointer to the CAN2 handle
|
||||
*/
|
||||
void vCANLoggerInit(CAN_HandleTypeDef *hcan1, CAN_HandleTypeDef *hcan2);
|
||||
void CAN_Logger_Init(CAN_HandleTypeDef *hcan1, CAN_HandleTypeDef *hcan2);
|
||||
void HAL_CAN_RxFifo0MsgPendingCallback(CAN_HandleTypeDef *hcan);
|
||||
void vCANLoggerListen(void *argument);
|
||||
void vLEDHeartbeat(void *argument);
|
||||
|
||||
+17
-13
@@ -44,7 +44,7 @@ typedef struct {
|
||||
|
||||
typedef struct {
|
||||
LED_Config *led;
|
||||
osSemaphoreId_t sem;
|
||||
osSemaphoreId_t semaphore;
|
||||
osTimerId_t timer;
|
||||
} LEDContext;
|
||||
/* USER CODE END PTD */
|
||||
@@ -72,8 +72,8 @@ LED_Config led_can1 = {GPIOB, GPIO_PIN_2};
|
||||
LED_Config led_can2 = {GPIOB, GPIO_PIN_5};
|
||||
LED_Config led_error = {GPIOB, GPIO_PIN_3};
|
||||
|
||||
LEDContext ledCtxCAN1;
|
||||
LEDContext ledCtxCAN2;
|
||||
LEDContext ledContextCAN1;
|
||||
LEDContext ledContextCAN2;
|
||||
|
||||
osSemaphoreId_t xLEDSemaphoreCAN1;
|
||||
osSemaphoreId_t xLEDSemaphoreCAN2;
|
||||
@@ -118,13 +118,7 @@ int main(void)
|
||||
HAL_Init();
|
||||
|
||||
/* USER CODE BEGIN Init */
|
||||
ledCtxCAN1.led = &led_can1;
|
||||
ledCtxCAN1.sem = xLEDSemaphoreCAN1;
|
||||
ledCtxCAN1.timer = xHeartbeatTimerCAN1;
|
||||
|
||||
ledCtxCAN2.led = &led_can2;
|
||||
ledCtxCAN2.sem = xLEDSemaphoreCAN2;
|
||||
ledCtxCAN2.timer = xHeartbeatTimerCAN2;
|
||||
/* USER CODE END Init */
|
||||
|
||||
/* Configure the system clock */
|
||||
@@ -168,15 +162,15 @@ int main(void)
|
||||
/* USER CODE END RTOS_MUTEX */
|
||||
|
||||
/* USER CODE BEGIN RTOS_SEMAPHORES */
|
||||
xLEDSemaphoreCAN1 = osSemaphoreNew(255, 0, NULL);
|
||||
xLEDSemaphoreCAN2 = osSemaphoreNew(255, 0, NULL);
|
||||
xLEDSemaphoreCAN1 = osSemaphoreNew(10, 0, NULL);
|
||||
xLEDSemaphoreCAN2 = osSemaphoreNew(10, 0, NULL);
|
||||
|
||||
if (xLEDSemaphoreCAN1 == NULL || xLEDSemaphoreCAN2 == NULL) Error_Handler();
|
||||
/* USER CODE END RTOS_SEMAPHORES */
|
||||
|
||||
/* USER CODE BEGIN RTOS_TIMERS */
|
||||
xHeartbeatTimerCAN1 = osTimerNew(vLEDHeartbeat, osTimerOnce, &led_can1, NULL);
|
||||
xHeartbeatTimerCAN2 = osTimerNew(vLEDHeartbeat, osTimerOnce, &led_can2, NULL);
|
||||
xHeartbeatTimerCAN1 = osTimerNew(vLEDHeartbeat, osTimerOnce, &ledContextCAN1, NULL);
|
||||
xHeartbeatTimerCAN2 = osTimerNew(vLEDHeartbeat, osTimerOnce, &ledContextCAN2, NULL);
|
||||
|
||||
osTimerStart(xHeartbeatTimerCAN1, 25U);
|
||||
osTimerStart(xHeartbeatTimerCAN2, 25U);
|
||||
@@ -200,6 +194,16 @@ int main(void)
|
||||
/* add events, ... */
|
||||
/* USER CODE END RTOS_EVENTS */
|
||||
|
||||
/* USER CODE BEGIN 3 */
|
||||
ledContextCAN1.led = &led_can1;
|
||||
ledContextCAN1.semaphore = xLEDSemaphoreCAN1;
|
||||
ledContextCAN1.timer = xHeartbeatTimerCAN1;
|
||||
|
||||
ledContextCAN2.led = &led_can2;
|
||||
ledContextCAN2.semaphore = xLEDSemaphoreCAN2;
|
||||
ledContextCAN2.timer = xHeartbeatTimerCAN2;
|
||||
/* USER CODE END 3 */
|
||||
|
||||
/* Start scheduler */
|
||||
osKernelStart();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user