Create context structure for timer callback

Strucure is made of
-  LED (port, pin)
- Semaphore
- Timer handle
This commit is contained in:
2026-06-14 15:12:54 +02:00
parent 5b500d72ff
commit 643cac8ea6
2 changed files with 19 additions and 5 deletions
+4 -5
View File
@@ -132,16 +132,15 @@ void vLEDHeartbeat(void *argument)
/* CODE BEGIN */
LED_Config *led = (LED_Config*)argument;
if (osSemaphoreAcquire(xCanActivitySemaphore, 0U) == osOK)
if (osSemaphoreAcquire(ctx->sem, 0U) == osOK)
{
HAL_GPIO_WritePin(led->port, led->pin, GPIO_PIN_SET);
osTimerStart(xHeartbeatTimerCAN1, 25U);
HAL_GPIO_WritePin(ctx->led->port, ctx->led->pin, GPIO_PIN_SET);
osTimerStart(ctx->timer, 25U);
}
else
{
HAL_GPIO_WritePin(led->port, led->pin, GPIO_PIN_RESET);
HAL_GPIO_WritePin(ctx->led->port, ctx->led->pin, GPIO_PIN_RESET);
}
/* CODE END */
}
/* END vLEDHeartbeat */