复位默认是普通IO口,剩下的就是操作寄存器的事,看数据手册。如下是外设驱动的参考代码,有IO操作的demo
http://www.ti.com/general/docs/lit/getliterature.tsp?literatureNumber=swrc257&fileType=zip
copy一段,很简单,看注释都能明白
输入
P0SEL &= ~P0_PIN; // Select pin to function as General Purpose I/O.
P0DIR &= ~P0_PIN; // Select direction as input.
P0INP &= ~P0_PIN; // Pull up/pull down.
输出
P1SEL &= BIT0; // GPIO.
P1DIR |= BIT0; // Output.
P1_0 = 0; // LED1 off.
复位默认是普通IO口,剩下的就是操作寄存器的事,看数据手册。如下是外设驱动的参考代码,有IO操作的demo
http://www.ti.com/general/docs/lit/getliterature.tsp?literatureNumber=swrc257&fileType=zip
copy一段,很简单,看注释都能明白
输入
P0SEL &= ~P0_PIN; // Select pin to function as General Purpose I/O.
P0DIR &= ~P0_PIN; // Select direction as input.
P0INP &= ~P0_PIN; // Pull up/pull down.
输出
P1SEL &= BIT0; // GPIO.
P1DIR |= BIT0; // Output.
P1_0 = 0; // LED1 off.
举报