C2000launchpad学习帖之点亮LED
例程如下:
#include<F2802x_Device.h>
#include<DSP28x_Project.h>
void main(void)
{
InitSysCtrl(); //系统控制初始化
//InitGpio();
DINT; //禁止全局中断
InitPieCtrl();
IER = 0x0000; //禁止CPU中断
IFR = 0x0000; //清楚CPU所有中断标志
InitPieVectTable();//位向量表中的所有中断向量配置对应的入口地址
EALLOW; //允许访问受保护的空间
GpioCtrlRegs.GPADIR.bit.GPIO0=1; //配置I/O口为输出
GpioCtrlRegs.GPADIR.bit.GPIO1=1;
GpioCtrlRegs.GPADIR.bit.GPIO2=1;
GpioCtrlRegs.GPADIR.bit.GPIO3=1;
GpioCtrlRegs.GPADIR.bit.GPIO12=0;
EDIS; //禁止访问受保护的空间
GpioDataRegs.GPASET.bit.GPIO12 == 0;
for(;;)
{
if(GpioDataRegs.GPADAT.bit.GPIO12 == 0)
{
GpioDataRegs.GPACLEAR.bit.GPIO2 = 1;
GpioDataRegs.GPACLEAR.bit.GPIO0 = 1;
GpioDataRegs.GPASET.bit.GPIO3 = 1;
GpioDataRegs.GPASET.bit.GPIO1 = 1;
}
if(GpioDataRegs.GPADAT.bit.GPIO12 == 1)
{
GpioDataRegs.GPASET.bit.GPIO0 = 1;
GpioDataRegs.GPASET.bit.GPIO2 = 1;
GpioDataRegs.GPACLEAR.bit.GPIO1 = 1;
GpioDataRegs.GPACLEAR.bit.GPIO3 = 1;
}
}
} |