1、初始化系统,并打开系统时钟
SysCtrlRegs.PCLKCR3.bit.GPIOINENCLK = 1; // GPIO
2、设置GPIO口输入输出方向
GpioCtrlRegs.GPADIR.bit.GPIO0 = 1;
3、设置GPIO的值
GpioDataRegs.GPATOGGLE.bit.GPIO0 = 1;
注GPIO GpioDataRegs口如下:
union GPADAT_REG GPADAT; // GPIO Data Register (GPIO0 to 31)
union GPADAT_REG GPASET; // GPIO Data Set Register (GPIO0 to 31)
union GPADAT_REG GPACLEAR; // GPIO Data Clear Register (GPIO0 to 31)
union GPADAT_REG GPATOGGLE; // GPIO Data Toggle Register (GPIO0 to 31)
union GPBDAT_REG GPBDAT; // GPIO Data Register (GPIO32 to 38)
union GPBDAT_REG GPBSET; // GPIO Data Set Register (GPIO32 to 38)
union GPBDAT_REG GPBCLEAR; // GPIO Data Clear Register (GPIO32 to 38)
union GPBDAT_REG GPBTOGGLE; // GPIO Data Toggle Register (GPIO32 to 38)