1 ;/*********************基本功能实现跑马灯的效果**********************/
2 ;/*********************GPA2,3,4,5为输出模式,低电平亮*****************/
3 #include "NUC1xx.h"
4 #include "DRVGPIO.h"
5 #include "DRVSYS.h"
6
7 static uint8_t EGPADATA=0xfb;
8 static int8_t Led_Count;
9
10
11 void InitSYS()
12 {
13 UNLOCKREG(x); //????12M
14 DrvSYS_SetOscCtrl(E_SYS_XTL12M, 1); //使能外部12M
15 DrvSYS_Delay(5000);
16 LOCKREG(x);
17 }
18 void InitGpio()
19 {
20 DrvGPIO_SetPortBits(E_GPA,EGPADATA); //给端口写数据,这是整个端口操作;
21 }
22 void Delay_ms()
23 {
24 uint32_t x, y;
25 for(x=1000;x>=5;x--)
26 for(y=5;y<1000;y++);
27 }
28 int main()
29 {
30 InitSYS();
31 InitGpio();
32
33 while(1)
34 {
35 for(Led_Count=0;Led_Count<=3;++Led_Count)
36 {
37 InitGpio();
38 Delay_ms();
39 EGPADATA=((EGPADATA<<1)|0x04);
40
41 if(EGPADATA==0xBC) //由于助学板只有4个LED灯,所以计数达到这个值再重新赋值;
42 {
43 EGPADATA=0xFb;
44 Led_Count=-1;
45 }
46 }
47
48 }
49 }