

#include "Include.h"

void GPIO_Init_First(void)
{

	PIN_54_D = OUT; //CAN STB
	PIN_54_P = 1;
	//所有引脚配置成输出模式，保证引脚电平稳定
	DDRT = 0XFF;
	DDRP = 0XFF;
	DDRH = 0XFF;
	DDRR = 0XFF;
	DDRU = 0XFF;
	DDRV = 0XFF;
	DDRM = 0XFF;
	DDRA = 0XFF;
	DDRB = 0XFF;
	DDR0AD = 0XFF;
	DDR1AD = 0XFF;
	DDRS = 0XFF; //    PIN_44_D   //CAN  TX
	//所有引脚上拉关闭
	PERT = 0;
	PERP = 0;
	PERH = 0;
	PERR = 0;
	PERU = 0;
	PERV = 0;
	PERM = 0;
	PUCR_PUPAE = 0;
	PUCR_PUPBE = 0;
	PER0AD = 0;
	PER1AD = 0;
	PERS = 0;
	//////需要用作输入使用的引脚//////////////////////////////////////////////////////
	PIN_112_D = IN;
	PIN_111_D = IN; //I_MCU_空滤阻塞（-）_预留 21
	PIN_110_D = IN;
	PIN_109_D = IN;
	PIN_108_D = IN;
	PIN_1_D = IN;
	PIN_2_D = IN;
	PIN_3_D = IN;//差速锁工作
//	PIN_4_D = IN;
//	PIN_5_D = IN;
//	PIN_6_D = IN;
//	PIN_7_D = IN;			     LE21
/////////////////////////////////////////////////////////////
	PIN_61_D = IN; //EE	     LE21
	PIN_62_D = IN; //EE	      LE21

	PIN_47_D = IN; //LED_IC	         LE21
	PIN_50_D = IN; //LED_IC	          LE21

	//PIN_31_D = IN;	//制动系统阀故障
	PIN_32_D = IN;	// I_MCU_轴间差速锁工作（-）_预留
	PIN_33_D = IN;	//I_MCU_轴间差速锁工作（-）_预留
	PIN_35_D = IN;	//I_MCU_驾驶室锁止不到位信号（-）
	PIN_37_D = IN;	//车速信号输入（预留）
	PIN_38_D = IN;	//低压dcdc故障（预留）
	PIN_40_D = IN;	//I_MCU_主安全带报警（-）

	PIN_49_D = IN;	//I_MCU_驻车制动	      //LE21
	PIN_53_D = IN; //I_MCU_制动液位低（-）_预留	         LE21
	PIN_59_D = IN;	//I_MCU_摩擦片破损（悬空）    LE21
	PIN_60_D = IN;	//I_MCU_副驾安全带报警（-）_预留	    LE21
	PIN_63_D = IN;	//I_MCU_转向液位低（-）_预留
	PIN_75_D = IN;	//I_MCU_中间座位安全带报警（-）_预留
	PIN_76_D = IN;	//I_MCU_取力器工作（-）_预留

	PIN_52_D = IN; //正空预留    LE21
	PIN_57_D = IN; //P_ILLBitSW_OUT-调光开关	 LE21
	PIN_43_D = IN; //CAN_RX       LE21
	PIN_45_D = IN; //CAN2_RX 预留      LE21

	//	PIN_47_D = IN; //FL3236_SCL
	//	PIN_48_D = IN; //FL3236_SDB
	//	PIN_50_D = IN; //FL3236_SDA
	PIN_69_D = IN; //下按键	     LE21
	PIN_70_D = IN; //		    LE21
	PIN_72_D = IN; //左按键	    LE21

	PIN_69_PULL = HIGH; //下按键
	PIN_70_PULL = HIGH; //右按键
	PIN_72_PULL = HIGH; //左按键

	////部分输出引脚电平控制////////////////////////////////////////////////////////
	//关闭该关闭的IO口
//	LM2735_EN_OUT_P = 0;
	PIN_55_P = 1;		 //CAN2_STB_MCU	
	PIN_29_P = 0;		  //蜂鸣器-_MCU-PWM   LE21
	PIN_34_P = 0;		  //液晶屏背光_MCU-PWM    LE21
	PIN_36_P = 0;		  //指针背光_MCU-PWM         LE21
	GPIO_Speed_OUT_1 = 0; //车速信号输出1（PPK4992）_MCU-PWM  LE21
						  //	GPIO_Speed_OUT_2 = 0; //车速信号输出2（PPK8000)_MCU-PWM
	//打开需打开的IO口
	GPIO_5V_Control_OUT = 1; //可切5V_MCU-OUT  LE21
	PIN_101_P = 0 ;//气压输出     LE21

	/*黑电机*/   //LE21
	PIN_9_D = IN;		   
	PIN_10_D = IN;
	PIN_11_D = IN;
	PIN_12_D = IN;

	PIN_15_D = IN;
	PIN_16_D = IN;
	PIN_17_D = IN;
	PIN_18_D = IN;

	PIN_19_D = IN;
	PIN_20_D = IN;
	PIN_21_D = IN;
	PIN_22_D = IN;

	PIN_25_D = IN;
	PIN_26_D = IN;
	PIN_27_D = IN;
	PIN_28_D = IN;
}

void GPIO_Sleep_Init(void)
{
	IIC_SCL_DIR = 1;      //EE
	IIC_SDA_DIR = 1;      //EE
	IIC_SDA = 1;	   //EE
	IIC_SCL = 1;      //EE
	

	SIMULATED_IIC_2_SDA_DIR = 0;
	SIMULATED_IIC_2_SCL_DIR = 0;
	

	GPIO_Speed_OUT_1 = 0;	 //车速信号输出1（PPK4992）_MCU-PWM	   LE21
	GPIO_5V_Control_OUT = 0; //可切5V_MCU-OUT    LE21
	LED_Driver_Shutdown_Pin_Set(0);
	PIN_69_PULL = 0; //下按键	    LE21
	PIN_70_PULL = 0; //	  右按键
	PIN_72_PULL = 0; //   左按键
	//LM2735_EN_OUT_P = 0;

	SIM_8080_P_A0 = 0u;	 //LE21
	SIM_8080_P_nRD = 0u;
	SIM_8080_P_nWR = 0u;
	SIM_8080_P_nCS = 0u;
	SIM_8080_P_DATA = 0u;
	LCD_nRST = 0u;	
	PIN_101_P = 1 ;//气压输出
	

	Buzzer_Play_Sleep();
}
void GPIO_WakeUp_Init(void)
{
	GPIO_5V_Control_OUT = 1; //可切5V_MCU-OUT	  LE21
	LED_Driver_Shutdown_Pin_Set(1);	   //LE21
	PIN_69_PULL = 1; //下按键
	PIN_70_PULL = 1; //	  右按键
	PIN_72_PULL = 1; //   左按键
	 //LM2735_EN_OUT_P = 1;
	 PIN_101_P = 0 ;//
}
