Compare commits
2 Commits
5a3223af29
...
19eefc288b
| Author | SHA1 | Date | |
|---|---|---|---|
| 19eefc288b | |||
| 17febf569a |
@@ -30,11 +30,27 @@ extern osMessageQueueId_t xCAN2RxQueue;
|
||||
extern osSemaphoreId_t xLEDSemaphoreCAN1;
|
||||
extern osSemaphoreId_t xLEDSemaphoreCAN2;
|
||||
|
||||
/* USER CODE BEGIN PTD */
|
||||
typedef struct {
|
||||
GPIO_TypeDef* port;
|
||||
uint16_t pin;
|
||||
} LED_Config;
|
||||
|
||||
typedef struct {
|
||||
uint32_t id;
|
||||
uint8_t payload[8];
|
||||
uint8_t dlc;
|
||||
uint8_t isExtended;
|
||||
//uint32_t timestamp; //Enable TIM2: 42 MHz / (41+1) = 1 MHz → 1 µs tick; 32bit autoreload freerunning
|
||||
// this is for getting timestamps on can messages
|
||||
} CanMessage_t;
|
||||
|
||||
typedef struct {
|
||||
LED_Config *led;
|
||||
osSemaphoreId_t semaphore;
|
||||
osTimerId_t timer;
|
||||
} LEDContext;
|
||||
/* USER CODE END PTD */
|
||||
|
||||
/**
|
||||
* @brief Initializes the CAN logger modules, OS threads, queues, and hardware.
|
||||
|
||||
@@ -28,6 +28,7 @@ extern "C" {
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "stm32f4xx_hal.h"
|
||||
#include "canlog.h"
|
||||
|
||||
/* Private includes ----------------------------------------------------------*/
|
||||
/* USER CODE BEGIN Includes */
|
||||
|
||||
+2
-3
@@ -111,9 +111,8 @@ void vCANLoggerListen(void *argument)
|
||||
{
|
||||
if (osMessageQueueGet(queue, &message, NULL, osWaitForever) == osOK)
|
||||
{
|
||||
// TODO: parse message send message to serial/uart
|
||||
|
||||
osSemaphoreRelease( (hcan->Instance == CAN1) ? xLEDSemaphoreCAN1 : xLEDSemaphoreCAN2 );
|
||||
osSemaphoreRelease( (hcan->Instance == CAN1) ? xSemaphoreCAN1 : xLEDSemaphoreCAN2 );
|
||||
// TODO: use this semaphore
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+5
-18
@@ -27,19 +27,6 @@
|
||||
|
||||
/* Private typedef -----------------------------------------------------------*/
|
||||
/* USER CODE BEGIN PTD */
|
||||
typedef struct {
|
||||
GPIO_TypeDef* port;
|
||||
uint16_t pin;
|
||||
} LED_Config;
|
||||
|
||||
typedef struct {
|
||||
uint32_t id;
|
||||
uint8_t payload[8];
|
||||
uint8_t dlc;
|
||||
uint8_t isExtended;
|
||||
//uint32_t timestamp; //Enable TIM2: 42 MHz / (41+1) = 1 MHz → 1 µs tick; 32bit autoreload freerunning
|
||||
// this is for getting timestamps on can messages
|
||||
} CanMessage_t;
|
||||
/* USER CODE END PTD */
|
||||
|
||||
/* Private define ------------------------------------------------------------*/
|
||||
@@ -68,7 +55,7 @@ LED_Config led_error = {GPIOB, GPIO_PIN_3};
|
||||
LEDContext ledContextCAN1;
|
||||
LEDContext ledContextCAN2;
|
||||
|
||||
osSemaphoreId_t xLEDSemaphoreCAN1;
|
||||
osSemaphoreId_t xSemaphoreCAN1;
|
||||
osSemaphoreId_t xLEDSemaphoreCAN2;
|
||||
|
||||
osTimerId_t xHeartbeatTimerCAN1;
|
||||
@@ -155,13 +142,13 @@ int main(void)
|
||||
/* USER CODE END RTOS_MUTEX */
|
||||
|
||||
/* USER CODE BEGIN RTOS_SEMAPHORES */
|
||||
xLEDSemaphoreCAN1 = osSemaphoreNew(10, 0, NULL);
|
||||
xSemaphoreCAN1 = osSemaphoreNew(10, 0, NULL);
|
||||
xLEDSemaphoreCAN2 = osSemaphoreNew(10, 0, NULL);
|
||||
|
||||
if (xLEDSemaphoreCAN1 == NULL || xLEDSemaphoreCAN2 == NULL) Error_Handler();
|
||||
if (xSemaphoreCAN1 == NULL || xLEDSemaphoreCAN2 == NULL) Error_Handler();
|
||||
|
||||
ledContextCAN1.led = &led_can1;
|
||||
ledContextCAN1.semaphore = xLEDSemaphoreCAN1;
|
||||
ledContextCAN1.semaphore = xSemaphoreCAN1;
|
||||
ledContextCAN2.led = &led_can2;
|
||||
ledContextCAN2.semaphore = xLEDSemaphoreCAN2;
|
||||
/* USER CODE END RTOS_SEMAPHORES */
|
||||
@@ -197,7 +184,7 @@ int main(void)
|
||||
|
||||
/* USER CODE BEGIN 3 */
|
||||
ledContextCAN1.led = &led_can1;
|
||||
ledContextCAN1.semaphore = xLEDSemaphoreCAN1;
|
||||
ledContextCAN1.semaphore = xSemaphoreCAN1;
|
||||
ledContextCAN1.timer = xHeartbeatTimerCAN1;
|
||||
|
||||
ledContextCAN2.led = &led_can2;
|
||||
|
||||
Reference in New Issue
Block a user