实验目的:按键控制led灯
实验环境: mini2440
工具: ads1.2 h-jtag1.0
如下start.s
area init,code,readonly
start ldr
sp,=4096
import main
bl main
end
//main.c
#include "def.h"
int dely(unsigned int a)
{
while(a--);
return 0;
}
int main()
{
rGPBCON|=0x15400;
rGPGCON|=0x80A882;
while(1)
{
if((rGPGDAT&0x1)==0x0)
LED1_ON;
if((rGPGDAT&0x8)==0x0)
LED2_ON;
if((rGPGDAT&0x20)==0x0)
LED3_ON;
if((rGPGDAT&0x40)==0x0)
LED4_ON;
if((rGPGDAT&0x1)==0x1)
LED1_OFF;
if((rGPGDAT&0x8)==0x8)
LED2_OFF;
if((rGPGDAT&0x20)==0x20)
LED3_OFF;
if((rGPGDAT&0x40)==0x40)
LED4_OFF;
}
return 0;
}
//def.h
#ifndef __DEF_H
#define __DEF_H
#define rGPBCON ((*(volatile unsigned *)0x56000010))
#define rGPBDAT ((*(volatile unsigned *)0x56000014))
#define rGPGCON ((*(volatile unsigned *)0x56000060))
#define rGPGDAT ((*(volatile unsigned *)0x56000064))
#define LED1_ON rGPBDAT &=(~(1<<5))
#define LED2_ON rGPBDAT &=(~(1<<6))
#define LED3_ON rGPBDAT &=(~(1<<7))
#define LED4_ON rGPBDAT &=(~(1<<8))
#define LED1_OFF rGPBDAT |=(1<<5)
#define LED2_OFF rGPBDAT |=(1<<6)
#define LED3_OFF rGPBDAT |=(1<<7)
#define LED4_OFF rGPBDAT |=(1<<8)
#endif