Implement LED heartbeat with RTOS timers instead of threads

- Less memory overhead (no stack allocation)
- Better timing accuracy (less jitter)
- CAN bus still has higher priority than timers
This commit is contained in:
2026-06-10 13:56:52 +02:00
parent 0c3c93040b
commit 59a58d1f1f
2 changed files with 13 additions and 34 deletions
+1 -28
View File
@@ -43,22 +43,6 @@ const osThreadAttr_t vCAN2_rx_attributes = {
.stack_size = 128 * 4,
.priority = (osPriority_t) osPriorityRealtime,
};
/* Definitions for CAN1 LED heartbeat */
osThreadId_t vLED_CAN1_Heartbeat;
const osThreadAttr_t vLED_CAN1_Heartbeat_attributes = {
.name = "vLED_CAN1_HeartbeatTask",
.stack_size = 128 * 4,
.priority = (osPriority_t) osPriorityVeryLow1,
};
/* Definitions for CAN2 LED heartbeat */
osThreadId_t vLED_CAN2_Heartbeat;
const osThreadAttr_t vLED_CAN2_Heartbeat_attributes = {
.name = "vLED_CAN2_HeartbeatTask",
.stack_size = 128 * 4,
.priority = (osPriority_t) osPriorityVeryLow,
};
/* USER END RTOS_TASKS */
@@ -121,18 +105,7 @@ void vLED_Heartbeat(void *argument)
{
/* CODE BEGIN */
LED_Config *led = (LED_Config*)argument;
for(;;)
{
//HAL_GPIO_WritePin(led->port, led->pin, GPIO_PIN_RESET);
// if semaphore for canrx, do the rest
HAL_GPIO_WritePin(led->port, led->pin, GPIO_PIN_SET);
osDelay(100);
HAL_GPIO_WritePin(led->port, led->pin, GPIO_PIN_RESET);
osDelay(100);
}
HAL_GPIO_TogglePin(led->port, led->pin);
/* CODE END */
}
/* END vLED_HeartbeatOnCanRx */