照着韦老师的视频改写了led和led-key用minitools下载到mini2440后led程序可以运行但是led-key却无法运行 小弟刚接触这块有哪位大神知道是为什么吗?求解答不胜感激整个程序中我只是把韦老师程序中的GPIO口改成了mini2440led相应的GPIO口 代码如下
#define GPBCON (*(vola
tile unsigned long *)0x56000010)
#define GPBDAT (*(volatile unsigned long *)0x56000014)
#define GPGCON (*(volatile unsigned long *)0x56000060)
#define GPGDAT (*(volatile unsigned long *)0x56000064)
/*
* LED1,LED2,LED4对应GPF4、GPF5、GPF6
*/
#define GPB5_out (1<<(5*2))
#define GPB6_out (1<<(6*2))
#define GPB7_out (1<<(7*2))
#define GPB8_out (1<<(8*2))
#define GPB5_msk (3<<(5*2))
#define GPB6_msk (3<<(6*2))
#define GPB7_msk (3<<(7*2))
#define GPB8_msk (3<<(8*2))
/*
* S2,S3,S4对应GPF0、GPF2、GPG3
*/
#define GPG0_in (0<<(0*2))
#define GPG3_in (0<<(3*2))
#define GPG5_in (0<<(5*2))
#define GPG6_in (0<<(6*2))
#define GPG0_msk (3<<(0*2))
#define GPG3_msk (3<<(3*2))
#define GPG5_msk (3<<(5*2))
#define GPG6_msk (3<<(6*2))
int main()
{
unsigned long dwDat;
// LED1,LED2,LED4对应的3根引脚设为输出
GPBCON &= ~(GPB5_msk | GPB6_msk | GPB7_msk | GPB8_msk); //将相应位置零
GPBCON |= GPB5_out | GPB6_out | GPB7_out | GPB8_out; //将相应位置01,位输出模式
// K1 K2 K3 K4对应的引脚设为输入
GPGCON &= ~(GPG3_msk | GPG0_msk | GPG5_msk | GPG6_msk);
GPGCON |= GPG3_in | GPG0_in | GPG5_in | GPG6_in;
while(1){
//若Kn为0(表示按下),则令LEDn为0(表示点亮)
dwDat = GPGDAT; // 读取GPG管脚电平状态
if (dwDat & (1<<0)) // K1没有按下
GPBDAT |= (1<<5); // LED1熄灭
else
GPBDAT &= ~(1<<5); // LED1点亮
if (dwDat & (1<<3)) // K2没有按下
GPBDAT |= (1<<6); // LED2熄灭
else
GPBDAT &= ~(1<<6); // LED2点亮
if (dwDat & (1<<5)) // K3没有按下
GPBDAT |= (1<<7); // LED3熄灭
else
GPBDAT &= ~(1<<7); // LED3点亮
if (dwDat & (1<<6)) // K4没有按下
GPBDAT |= (1<<8); // LED4熄灭
else
GPBDAT &= ~(1<<8); // LED4点亮
}
return 0;
}