// 定时反转PB0管脚,如果接有LED则会不断闪烁发光
#include "hw_types.h" #include "hw_memmap.h" #include "hw_sysctl.h" #include "hw_gpio.h" #include "src/sysctl.h" #include "src/gpio.h"
// 将较长的标识符定义为较短的形式 #define SysCtlPeriphEn SysCtlPeripheralEnable #define GPIOPinTypeIn GPIOPinTypeGPIOInput #define GPIOPinTypeOut GPIOPinTypeGPIOOutput
#define PB0 GPIO_PORTB_BASE, GPIO_PIN_0
void timeDelay (unsigned long ulVal) { do { } while ( --ulVal != 0 ); }
int main (void) { unsigned char ucPins = 0x00; // 定义临时变量
timeDelay(1500000L); // 开机延迟
SysCtlPeriphEn(SYSCTL_PERIPH_GPIOB); // 使能GPIOB端口 GPIOPinTypeOut(PB0); // 设置PB0为输出
for (;;) { GPIOPinWrite(PB0, ucPins); // ucPins最低位写入PB0 ucPins ^= 0x01; // 反转ucPins最低位 timeDelay(200000L); } }
相关链接:http://www.zlgmcu.com/LUMINARY/Stellaris.asp |