链接:https://pan.baidu.com/s/1E4x2TX_9SYhxM9sWfnehMg?pwd=1688
提取码:1688
1、键盘1*3的中断程序
//************************************************
#include "2440addr.h"
#include "2440lib.h"
#include "uart.h"
void __irq Eint2Handler(void);
void __irq Eint3Handler(void);
void __irq Eint4_7Handler(void);
void EXIT_IRQ_init(int num ,void __irq (* Exit_Handler)(void),int type);
int Main()
{
memcpy(0x0,(unsigned char *)0x30000000,0x1000); //将SDRAM中前4K代码拷贝程序到0地址
//拷贝中断向量表
ChangeMPllValue(0x5c,1,1); //固定格式 设置时钟频率 FCLK = 400M
ChangeClockDivider(14,12); //HCLK = 100M,PCLK = 50M
Uart_Select(0);
myUart_Init(50000000,115200); //固定格式 设置终端
Uart_Printf("EXIT INT test\n");
Uart_Printf("1*3键盘测试程序\n"); //串口打印
rGPFCON &= ~((0x03<<2*2)|(0x03<<3*2)|(0x03<<4*2)); //寄存器清零
rGPFCON |= ((0x02<<2*2)|(0x02<<3*2)|(0x02<<4*2)); //将GPF2,3,4配置成中断模式
rGPFUP &= ~((0x01<<2)|(0x01<<3)|(0x01<<4)); //GPF2,3,4上拉使能
EXIT_IRQ_init(2,Eint2Handler,2); //外部中断监听函数启动
EXIT_IRQ_init(3,Eint3Handler,2);
EXIT_IRQ_init(4,Eint4_7Handler,2);
while(1); //等待中断到来
}文章来源:https://www.toymoban.com/news/detail-834135.html
void EXIT_IRQ_init(int num , void __irq(* Exit_Handler)(void),int type) //__irq中断入口的关键字
{
switch(num)
{
case 0:
pISR_EINT0 = (unsigned)Exit_Handler; //中断函数的入口地址
rEXTINT0 &= ~(0x07);
rEXTINT0 |= (type); //设置中断触发类型
ClearPending(BIT_EINT0); //清除中断标志,防止勿中断
EnableIrq(BIT_EINT0); //使能中断
break;
case 1:
pISR_EINT1 = (unsigned)Exit_Handler; //中断函数的入口地址
rEXTINT0 &= ~(0x07<<4);
rEXTINT0 |= type<<4; //设置中断触发类型
ClearPending(BIT_EINT1); //清除中断标志,防止勿中断
EnableIrq(BIT_EINT1);
break;
case 2:
pISR_EINT2 = (unsigned)Exit_Handler; //中断函数的入口地址
rEXTINT0 &= ~(0x07<<8);
rEXTINT0 |= (type<<8); //设置中断触发类型
ClearPending(BIT_EINT2); //清除中断标志,防止勿中断
EnableIrq(BIT_EINT2);
break;
case 3:
pISR_EINT3 = (unsigned)Exit_Handler; //中断函数的入口地址
rEXTINT0 &= ~(0x07<<12);
rEXTINT0 |= (type<<12); //设置中断触发类型
ClearPending(BIT_EINT3); //清除中断标志,防止勿中断
EnableIrq(BIT_EINT3);
break;
case 4:
pISR_EINT4_7 = (unsigned)Exit_Handler; //中断函数的入口地址
rEXTINT0 &= ~(0x07<<16);
rEXTINT0 |= (type<<16); //设置中断触发类型
ClearPending(BIT_EINT4_7); //清除中断标志,防止勿中断
EnableIrq(BIT_EINT4_7);
rEINTPEND |= (0x01<<4);//子中断
rEINTMASK &= ~(0x01<<4);
break;
default:
break;
}
}
void __irq Eint2Handler(void)
{
Uart_Printf("the irq2 test\n");
ClearPending(BIT_EINT2); //清除中断标志
}
void __irq Eint3Handler(void)
{
Uart_Printf("the irq3 test\n");
ClearPending(BIT_EINT3); //清除中断标志
}
void __irq Eint4_7Handler(void)
{
if(rEINTPEND & 0x0010)
{
Uart_Printf("the irq4 test\n");
rEINTPEND |= (0x01<<4); //不清除就会再次不断进入中断服务
}
ClearPending(BIT_EINT4_7); //清除中断标志
}
//*****************************************************文章来源地址https://www.toymoban.com/news/detail-834135.html
到了这里,关于嵌入式培训机构四个月实训课程笔记(完整版)-Linux ARM驱动编程第二天-ARM按键1*3矩阵键盘编程 (物联技术666)的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!