/**
    @copyright None
    @file      led.h
    @author    Comment Vivre
    @date      2025-12-19
    @brief     None
*/
#ifndef __LED_H_
#define __LED_H_


#include <FU65_72.h>
// LED指示灯控制
// ------------------------------------------------------------------------

typedef struct
{
    enum
    {
        LED_STATE_OFF = 0,                  // 熄灭
        LED_STATE_ON,                       // 常亮
        LED_STATE_FAULT_HIGH_BLINK,         // 故障码高4位闪烁
        LED_STATE_FAULT_HIGH_GAP,           // 高低位间隔 1s
        LED_STATE_FAULT_LOW_BLINK,          // 故障码低4位闪烁
        LED_STATE_FAULT_CYCLE_GAP           // 整个故障码显示完成，间隔 3s
    } ledState;
    
    uint16_t PauseDelayCnt;                 // 延时
    uint8_t BlinkCnt;                       // 当前闪烁次数
    uint8_t FaultHighBit;                   // 故障码 高位
    uint8_t FaultLowBit;                    // 故障码 低位
} LED_Control_t;
extern LED_Control_t ledCtrl;


void LED_GPIO_Init(void);
void LED_State_Display(unsigned char Xn0);

// IO选择
// ------------------------------------------------------------------------
#define LED_PXIN                            (P2_OE)                             // LED所在端口组
#define LED_PINX                            (P21)                               // LED端口号
#define LED_PIN                             (GP21)                              // LED IO PIN 
#define LED_ON                              (LED_PIN = 0)                       // LED ON    
#define LED_OFF                             (LED_PIN = 1)                       // LED OFF
#define LEDPinONOFF                         (LED_PIN ^= 1)



extern bool data isCtrlPowOn;


#endif