Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| dca7707d28 | |||
| 4b2cd53f3b |
+15
-2
@@ -121,8 +121,21 @@ void vLEDHeartbeat(void *argument)
|
|||||||
|
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
if (osSemaphoreAcquire(context->semaphore, 25U) == osOK) HAL_GPIO_WritePin(context->led->port, context->led->pin, GPIO_PIN_SET);
|
// BLOCK for UP TO 25ms.
|
||||||
else HAL_GPIO_WritePin(context->led->port, context->led->pin, GPIO_PIN_RESET);
|
// - Returns osOK instantly if CAN traffic arrives.
|
||||||
|
// - Returns osTimeout if 25ms pass with NO traffic.
|
||||||
|
if (osSemaphoreAcquire(context->semaphore, 25U) == osOK)
|
||||||
|
{
|
||||||
|
// Traffic detected! Turn ON LED.
|
||||||
|
// Loop immediately to wait for the next message.
|
||||||
|
HAL_GPIO_WritePin(context->led->port, context->led->pin, GPIO_PIN_SET);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Timeout! No CAN traffic for 25ms. Turn OFF LED.
|
||||||
|
// Loop and block again.
|
||||||
|
HAL_GPIO_WritePin(context->led->port, context->led->pin, GPIO_PIN_RESET);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
/* CODE END */
|
/* CODE END */
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user