Compare commits
4 Commits
ebbd1816fa
...
5f1695dc0d
| Author | SHA1 | Date | |
|---|---|---|---|
| 5f1695dc0d | |||
| de6dc24dd3 | |||
| 1b38c0f29a | |||
| 7ece650f72 |
+15
-3
@@ -113,9 +113,11 @@ void vCANLoggerListen(void *argument)
|
|||||||
{
|
{
|
||||||
// TODO: parse message send message to serial/uart
|
// TODO: parse message send message to serial/uart
|
||||||
|
|
||||||
HAL_GPIO_WritePin(led_can1.port, led_can1.pin, GPIO_PIN_SET);
|
|
||||||
osTimerStart(xHeartbeatTimerCAN1, 25U);
|
bus = (hcan->Instance == CAN1) ? xLEDSemaphoreCAN1 : xLEDSemaphoreCAN2
|
||||||
|
osSemaphoreRelease(bus);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
/* CODE END */
|
/* CODE END */
|
||||||
}
|
}
|
||||||
@@ -131,7 +133,17 @@ void vLEDHeartbeat(void *argument)
|
|||||||
{
|
{
|
||||||
/* CODE BEGIN */
|
/* CODE BEGIN */
|
||||||
LED_Config *led = (LED_Config*)argument;
|
LED_Config *led = (LED_Config*)argument;
|
||||||
HAL_GPIO_WritePin(led->port, led->pin, GPIO_PIN_RESET);
|
|
||||||
|
if (osSemaphoreAcquire(xCanActivitySemaphore, 0U) == osOK)
|
||||||
|
{
|
||||||
|
HAL_GPIO_WritePin(led->port, led->pin, GPIO_PIN_SET);
|
||||||
|
osTimerStart(xHeartbeatTimerCAN1, 25U);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
HAL_GPIO_WritePin(led->port, led->pin, GPIO_PIN_RESET);
|
||||||
|
}
|
||||||
|
|
||||||
/* CODE END */
|
/* CODE END */
|
||||||
}
|
}
|
||||||
/* END vLEDHeartbeat */
|
/* END vLEDHeartbeat */
|
||||||
|
|||||||
+9
-6
@@ -66,8 +66,14 @@ LED_Config led_can1 = {GPIOB, GPIO_PIN_2};
|
|||||||
LED_Config led_can2 = {GPIOB, GPIO_PIN_5};
|
LED_Config led_can2 = {GPIOB, GPIO_PIN_5};
|
||||||
LED_Config led_error = {GPIOB, GPIO_PIN_3};
|
LED_Config led_error = {GPIOB, GPIO_PIN_3};
|
||||||
|
|
||||||
|
osSemaphoreId_t xLEDSemaphoreCAN1;
|
||||||
|
osSemaphoreId_t xLEDSemaphoreCAN2;
|
||||||
|
|
||||||
osTimerId_t xHeartbeatTimerCAN1;
|
osTimerId_t xHeartbeatTimerCAN1;
|
||||||
osTimerId_t xHeartbeatTimerCAN2;
|
osTimerId_t xHeartbeatTimerCAN2;
|
||||||
|
|
||||||
|
osMessageQueueId_t xCAN1RxQueue;
|
||||||
|
osMessageQueueId_t xCAN2RxQueue;
|
||||||
/* USER CODE END PV */
|
/* USER CODE END PV */
|
||||||
|
|
||||||
/* Private function prototypes -----------------------------------------------*/
|
/* Private function prototypes -----------------------------------------------*/
|
||||||
@@ -147,10 +153,7 @@ int main(void)
|
|||||||
/* USER CODE END RTOS_MUTEX */
|
/* USER CODE END RTOS_MUTEX */
|
||||||
|
|
||||||
/* USER CODE BEGIN RTOS_SEMAPHORES */
|
/* USER CODE BEGIN RTOS_SEMAPHORES */
|
||||||
osSemaphoreId_t xLEDSemaphoreCAN1;
|
|
||||||
xLEDSemaphoreCAN1 = osSemaphoreNew(255, 0, NULL);
|
xLEDSemaphoreCAN1 = osSemaphoreNew(255, 0, NULL);
|
||||||
|
|
||||||
osSemaphoreId_t xLEDSemaphoreCAN2;
|
|
||||||
xLEDSemaphoreCAN2 = osSemaphoreNew(255, 0, NULL);
|
xLEDSemaphoreCAN2 = osSemaphoreNew(255, 0, NULL);
|
||||||
|
|
||||||
if (xLEDSemaphoreCAN1 == NULL || xLEDSemaphoreCAN2 == NULL) Error_Handler();
|
if (xLEDSemaphoreCAN1 == NULL || xLEDSemaphoreCAN2 == NULL) Error_Handler();
|
||||||
@@ -160,14 +163,14 @@ int main(void)
|
|||||||
xHeartbeatTimerCAN1 = osTimerNew(vLEDHeartbeat, osTimerOnce, &led_can1, NULL);
|
xHeartbeatTimerCAN1 = osTimerNew(vLEDHeartbeat, osTimerOnce, &led_can1, NULL);
|
||||||
xHeartbeatTimerCAN2 = osTimerNew(vLEDHeartbeat, osTimerOnce, &led_can2, NULL);
|
xHeartbeatTimerCAN2 = osTimerNew(vLEDHeartbeat, osTimerOnce, &led_can2, NULL);
|
||||||
|
|
||||||
|
osTimerStart(xHeartbeatTimerCAN1, 25U);
|
||||||
|
osTimerStart(xHeartbeatTimerCAN2, 25U);
|
||||||
|
|
||||||
if (xHeartbeatTimerCAN1 == NULL || xHeartbeatTimerCAN2 == NULL) Error_Handler();
|
if (xHeartbeatTimerCAN1 == NULL || xHeartbeatTimerCAN2 == NULL) Error_Handler();
|
||||||
/* USER CODE END RTOS_TIMERS */
|
/* USER CODE END RTOS_TIMERS */
|
||||||
|
|
||||||
/* USER CODE BEGIN RTOS_QUEUES */
|
/* USER CODE BEGIN RTOS_QUEUES */
|
||||||
osMessageQueueId_t xCAN1RxQueue;
|
|
||||||
xCAN1RxQueue = osMessageQueueNew(32, sizeof(CanMessage_t), NULL);
|
xCAN1RxQueue = osMessageQueueNew(32, sizeof(CanMessage_t), NULL);
|
||||||
|
|
||||||
osMessageQueueId_t xCAN2RxQueue;
|
|
||||||
xCAN2RxQueue = osMessageQueueNew(32, sizeof(CanMessage_t), NULL);
|
xCAN2RxQueue = osMessageQueueNew(32, sizeof(CanMessage_t), NULL);
|
||||||
|
|
||||||
if (xCAN1RxQueue == NULL || xCAN2RxQueue == NULL) Error_Handler();
|
if (xCAN1RxQueue == NULL || xCAN2RxQueue == NULL) Error_Handler();
|
||||||
|
|||||||
Reference in New Issue
Block a user