49 lines
1.1 KiB
C
49 lines
1.1 KiB
C
#include "bsp_Led.h"
|
|
#include "os_timer.h"
|
|
|
|
#include "bsp_Flash.h"
|
|
|
|
#include "proto_modbus_tcp_master.h"
|
|
|
|
static void bsp_Led_Init(void);
|
|
static void bsp_Led_Flash(void);
|
|
|
|
bsp_Led_t Led =
|
|
{
|
|
.Init = bsp_Led_Init,
|
|
.Flash = bsp_Led_Flash,
|
|
};
|
|
/*其他外设初始化后快速闪烁,提示初始化完成*/
|
|
static void bsp_Led_Init(void)
|
|
{
|
|
for(u8 i = 0;i < 20;i++)
|
|
{
|
|
Delay_ms(50);
|
|
HAL_GPIO_TogglePin(LED_RUN_GPIO_Port, LED_RUN_Pin);
|
|
}
|
|
}
|
|
|
|
static void bsp_Led_Flash(void)
|
|
{
|
|
if (modbus_tcp.alarm_ctx.offline)
|
|
{
|
|
HAL_GPIO_TogglePin(LED_ERROR_GPIO_Port, LED_ERROR_Pin);
|
|
HAL_GPIO_WritePin(LED_RUN_GPIO_Port,LED_RUN_Pin,GPIO_PIN_SET);
|
|
}else
|
|
{
|
|
HAL_GPIO_TogglePin(LED_RUN_GPIO_Port, LED_RUN_Pin);
|
|
HAL_GPIO_WritePin(LED_ERROR_GPIO_Port,LED_ERROR_Pin,GPIO_PIN_SET);
|
|
}
|
|
/*进入测试模式*/
|
|
if(Usr_Flash.test == 1)
|
|
{
|
|
//运行和故障灯交替运行
|
|
Delay_ms(50);
|
|
HAL_GPIO_TogglePin(LED_RUN_GPIO_Port, LED_RUN_Pin);
|
|
Delay_ms(50);
|
|
HAL_GPIO_TogglePin(LED_ERROR_GPIO_Port, LED_ERROR_Pin);
|
|
}
|
|
|
|
// HAL_GPIO_TogglePin(LED_RUN_GPIO_Port, LED_RUN_Pin);
|
|
}
|