#ifndef  __GPIO_Init_H__
#define  __GPIO_Init_H__


#define Can_Power_Enable(on) gpio_bit_write(GPIOA,GPIO_PIN_12,(bit_status)(!on))
#define FL_Enable(on) gpio_bit_write(GPIOB,GPIO_PIN_2,(bit_status)(!on))

#define Lock_Enable(on) gpio_bit_write(GPIOB,GPIO_PIN_4,(bit_status)(on))
#define QD_Enable(on) gpio_bit_write(GPIOB,GPIO_PIN_5,(bit_status)(on))
//#define ACC2_Enable(on) gpio_bit_write(GPIOC,GPIO_PIN_15,(bit_status)(on))
#define Left_Light_Enable(on) gpio_bit_write(GPIOC,GPIO_PIN_6,(bit_status)(on))
#define Right_Light_Enable(on) gpio_bit_write(GPIOC,GPIO_PIN_7,(bit_status)(on))
#define Tail_Light_Enable(on) gpio_bit_write(GPIOB,GPIO_PIN_0,(bit_status)(on))
#define Carpet_Light_Enable(on) gpio_bit_write(GPIOB,GPIO_PIN_1,(bit_status)(on))

#define Side_Stay_Dect() gpio_input_bit_get(GPIOC,GPIO_PIN_10)
#define Soak_Dect() !gpio_input_bit_get(GPIOC,GPIO_PIN_11)
#define Sitting_Dect() gpio_input_bit_get(GPIOC,GPIO_PIN_12)
#define Repair_Key_Dect() gpio_input_bit_get(GPIOC,GPIO_PIN_13)
#define QD_Dect() (!gpio_input_bit_get(GPIOB,GPIO_PIN_6))
#define XL_Dect() gpio_input_bit_get(GPIOB,GPIO_PIN_7)
#define ACC2_Dect() (!gpio_input_bit_get(GPIOD,GPIO_PIN_0))
#define ACC2_Over_Loader_Dect() gpio_input_bit_get(GPIOC,GPIO_PIN_14)

#define Lock_Dect() gpio_output_bit_get(GPIOB,GPIO_PIN_4)
#define Carpet_Dect() gpio_output_bit_get(GPIOB,GPIO_PIN_1)
#define Tail_Dect() gpio_output_bit_get(GPIOB,GPIO_PIN_0)
#define Enable_12V(on) gpio_bit_write(GPIOB,GPIO_PIN_3,(bit_status)(on))
#define V12_On_Dect() (!gpio_input_bit_get(GPIOA,GPIO_PIN_15))

#define CHARGE_DEC_TIMEOUT  (100)
#define SIDE_STAY_DEC_TIMEOUT  (100)
#define SOAK_DEC_TIMEOUT  (2000)
#define STI_DEC_TIMEOUT  (100)
#define REPAIR_DEC_TIMEOUT  (100)
#define QD_DEC_TIMEOUT  (100)
#define XL_DEC_TIMEOUT  (100)
#define ACC2_DEC_TIMEOUT  (100)
#define ACC2_ENABLE_TIMEOUT  (100)
#define CC_PULSE_MIN_COUNT   (2)
#define CC_TIME_OUT_COUNT   (3000)
#define CC_PULL_OUT_TIME_OUT_COUNT   (3000)
typedef struct
{
	uint8_t cc_set;
	uint16_t cc_time_count;
	uint8_t cc_is_charger_in;
	uint32_t cc_pulse_count;

	uint8_t cc_pull_out_set;
	uint16_t cc_pull_out_time_count;
	
}CHECK_CHARGER;

extern CHECK_CHARGER check_charger;
extern DELAY_COMMON side_stay_dec_delay;
extern CTR_DELAY_COMMON soak_dec_delay;
extern DELAY_COMMON sti_dec_delay;
extern DELAY_COMMON repair_dec_delay;
extern DELAY_COMMON qd_dec_delay;
extern DELAY_COMMON xl_dec_delay;
extern DELAY_COMMON acc2_dec_delay;
extern DELAY_COMMON acc2_delay;
extern DELAY_COMMON left_light_delay;
extern DELAY_COMMON right_light_delay;

extern DELAY_COMMON shield_xl;

extern uint32_t xl_count;
extern DELAY_COMMON charge_delay;
extern uint8_t battery_charged_full;
extern uint8_t QD_switch_from;

enum
{
	FROM_QD,
	FROM_ACC12,
	

	FROM_MAX
};


void _CB_Operate_Initial(void);

void GPIO_Initial(void);

void E_CTR_Initial(void);

void ACC2_PWM(void);

void ACC2_Enable(uint8_t on);

void Check_Charger_Timeout(void);

uint8_t IS_CHARGE_IN(void);

void Set_Charger_In(uint8_t value);

void QD_Enable_From(uint8_t on,uint8_t from);

uint8_t IS_CHARGE_IN(void);

uint8_t ACC2_Is_On(void);

void Check_S11_May_Operate(void);

#endif

