|
- /***************************************************************/
- LED.c文件
- /*
- 本实验接口说明
- GPB5 ------ LED0
- GPB6 ------ LED1
- GPB8 ------ LED2
- GPB10 ------ LED3
- */
- /*------------------------地址声明---------------------------*/
- #define GPBCON (*(volatile unsigned *)0x56000010)
- #define GPBDAT (*(volatile unsigned *)0x56000014)
- #define GPBUP (*(volatile unsigned *)0x56000018)
- #define uchar unsigned char
- #define uint unsigned int
- /*-----------------------定义全局变量------------------------*/
- /*-----------------------函数声明----------------------------*/
- void Delay(int x);
- /*------------------------------------------------------------/
- 函数名称: Delay
- 功能描述: 延时函数
- 传 参: int x
- 返 回 值: 无
- -------------------------------------------------------------*/
- void Delay(int x)
- {
- int k, j;
- while(x)
- {
- for (k=0;k<=0xff;k++)
- for(j=0;j<=0xff;j++);
-
- x--;
- }
- }
- /*-------------------------------------------------------------
- 函数名称: ledMain
- 功能描述: 入口程序
- 初始化后,进入跑马灯死循环
- 传 参: 无
- 返 回 值: int 0
- -------------------------------------------------------------*/
- int ledMain(void)
- {
- GPBCON = 0x1dd7fc; // GPB5,GPB6,GPB8,GPB10设置为输出
- GPBDAT = ((1<<5)|(1<<6)|(1<<8)|(1<<10)); //使LED全灭
- GPBDAT&=0xffe; //关闭蜂鸣器
- GPBUP = 0x00;
-
- while (1) // 死循环
- {
-
- GPBDAT = ~(1<<5); //LED0亮
- Delay(500);
- GPBDAT = ~(1<<6); //LED1亮
- Delay(500);
- GPBDAT = ~(1<<8); //LED2亮
- Delay(500);
- GPBDAT = ~(1<<10); //LED3亮
- Delay(500);
- }
- return 0;
- }
复制代码
- //Init.s 文件
- AREA |DATA|,CODE,READONLY
- ENTRY
- ldr r13, =0x1000
- IMPORT ledMain
- b ledMain
- END
复制代码
发个简单的跑马灯实验程序给你吧,按键中断LED,其实也很简单
只要加个判断语句就好了。例如
if(按键被按下)
GPBDAT = ~(1<<5); //灯亮 |
|