Files

79 lines
1.7 KiB
C
Raw Permalink Normal View History

2026-03-31 15:46:04 +08:00
/**
******************************************************************************
2026-05-21 12:19:01 +08:00
* @file User\App\task_sys.c
* @author
2026-03-31 15:46:04 +08:00
* @version v0.1
2026-05-21 12:19:01 +08:00
* @date 2026-05-21
* @brief
2026-03-31 15:46:04 +08:00
******************************************************************************
*/
/* Includes ------------------------------------------------------------------*/
2026-05-21 10:01:28 +08:00
#include "task_sys.h"
2026-03-31 15:46:04 +08:00
void HeartBeat_Sign(void);
/**
2026-05-21 12:19:01 +08:00
* @brief sys_task_function
* @note none
* @param none
* @retval none
2026-03-31 15:46:04 +08:00
*/
2026-05-21 10:01:28 +08:00
void sys_task_function(void const *argument)
2026-03-31 15:46:04 +08:00
{
while (1)
{
HeartBeat_Sign(); // 指示灯、蜂鸣器
// HAL_IWDG_Refresh(&hiwdg); //喂狗
osDelay(50);
}
}
/**
* @funNm : HeartBeat_Sign
* @brief :
* @param : none
* @retval: void
*/
2026-04-30 17:16:01 +08:00
static uint32_t last_heartbeat_tick[MAX_CHARGER_COUNT] = {0};
2026-03-31 15:46:04 +08:00
void HeartBeat_Sign(void)
{
2026-04-30 17:16:01 +08:00
int i;
uint32_t now = HAL_GetTick();
bool any_online = false;
/* 6路桩独立心跳互不影响 */
for (i = 0; i < MAX_CHARGER_COUNT; i++)
{
if (g_charger_manager.charger_piles[i].is_online)
{
any_online = true;
if ((now - last_heartbeat_tick[i]) >= 8000)
{
last_heartbeat_tick[i] = now;
2026-05-21 10:01:28 +08:00
charger_to_server_0X03(i + 1, 1);
2026-04-30 17:16:01 +08:00
}
}
}
if (any_online)
2026-03-31 15:46:04 +08:00
{
2026-05-21 10:01:28 +08:00
RUN_EVERY(50, tick_B, {
2026-03-31 15:46:04 +08:00
System_Mode_Led_Toggle();
});
}
else
{
RUN_EVERY(500, tick_C, {
System_Mode_Led_Toggle();
});
}
RUN_EVERY(1000, tick_D, {
System_Run_Led_Toggle();
});
}