|
void Init_GPIO(void)
{
P1DIR = 0xFF;P1OUT = 0x00;
P2DIR = 0xFF;P2OUT = 0x00;
P3DIR = 0xFF;P3OUT = 0x00;
P2DIR &=~(S1I+S2I+DTI); //S2I,S1I,DTI 设置成输入口
//P2REN |= S2I+DTI+S1I; //上拉使能
//P2OUT |= (S2I+DTI+S1I); //上拉动作
P2IES |= (S2I+S1I+DTI); // S2I+S1I+DTI 下降沿触发
P2IE = S2I+S1I+DTI; // 使能 S2I+S1I+DTI 输入中断
P2IFG = 0; // 清除 P2 口中断标志
P1SEL0 |= RX | TX; // P1.5和P1.4分别设置成 RX 和 TX
P1DIR |=(PS1+PS2+PDT); //S2I,S1I,DTI power control outputs
P1OUT |= (PS1+PS2+PDT);
P1DIR |=DERE; //S2I,S1I,DTI 设置成输出口
P1OUT &=~DERE; //控制485IC读写功能,低位MCU接收,高为MCU发送
P1OUT |= BAT_GND;
P1OUT |= AD_BAT; //p1.0 口电压检测口
SYSCFG2 |= ADCPCTL0; // P1.0 设置成 ADC A0检测口
PM5CTL0 &= ~LOCKLPM5; // Disable the GPIO power-on default high-impedance mode
// to activate previously configured port settings
} |
|