专题2-通过按键玩中断2440按键中断编程lesson2

1、程序优化

修改Makefile

把main.c里面的mmu代码复制到mmu.c并修改如下

main.c的修改

由于在bootloader当中一般不会使用MMU,所以

main.c

加入led.c文件

makefile

2440中断源初始化

打开开发板底板与核心板原理图

底板

比如K1对应EINT1,然后到核心板去搜EINT1

然后去2440芯片手册去找到GPF这一组IO口

创建一个button.c,加入到makefile里面去button.o

按键初始化

编写button.c文件

#define GPFCON  (volatile unsigned long *)0x56000050

#define GPF0_msk   (3<<(0*2))

#define GPF1_msk   (3<<(1*2))

#define GPF2_msk   (3<<(2*2))

#define GPF4_msk   (3<<(4*2))

#define GPF0_int   (2<<(0*2))

#define GPF1_int   (2<<(1*2))

#define GPF2_int   (2<<(2*2))

#define GPF4_int   (2<<(4*2))

void button_init()

{

    *(GPFCON )&=~(GPF0_msk|GPF1_msk|GPF2_msk|GPF4_msk);

  *(GPFCON )|=GPF0_int|GPF1_int|GPF2_int|GPF4_int;

}

加入到main.c中,

初始化中断控制器

创建interrupt.c文件,修改makefile,加入interrupt.o

原文地址:https://www.cnblogs.com/gary-guo/p/5808547.html