欢迎来到天天文库
浏览记录
ID:51125635
大小:115.50 KB
页数:7页
时间:2020-03-19
《中断硬件驱动代码分析.doc》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库。
1、中断硬件驱动代码分析ARM-Week-1Learn-lumit-Step-15.+断按钮实验lJntO_driver.cintintO_open(void){初始化IO端口专用寄存器//setgpio'sdirection:setIOPMODregistermodebitto0=inputTable12-1.IOPMODRegisterRegisterOffsetAddressRZWDescriptionResetValueKDPMOD(X5000R/WVOportmoderegister0x00000000I
2、OPMOD=IOPMOD&(〜0x00000100);即把IOPMOD的第8位(9端31INTMSK口)清零,也就是设置为输入模式。Table13-4INTMSKRegisterRegisterOffsetAddressR/WDescriptionResetValueINTMSK04008R/WInterruptmaskregister0X003FFFFF2120191817161544131211109876543210Gx
3、xxx
4、xx
5、xxxxxxxxxxxx
6、xXX//unmasktheswitchint
7、emiptINTMSK&二〜((1vv21)I(l«0));〜((lvv21)丨(lvvO))二〜(100000000000000000000011)=0111111111111111111110也就是要把INTMSK的22位和0位清零(开启中断控制器,开启外部中断控制0)oreturn0;intintO_ioctl(unsignedintcmd,unsignedlongarg){switch(cmd)INTO_IO_ENABLE宏定义值为(1«4)INTO_IO_ACTIVE_HIGH宏定义值为(1«3)INT
8、O_IO_RISING_EDGE宏定义值为(0x01)INTO_IO_FALLING_EDGE宏定义值为(0x02)INTO」O_BOTH_EDGE宏定义值为(0x03)Table12-2.IOPCONRegisterRegisterOffsetAddressR/WDescriptionResetValueIOPCON0x5004R/WI/Oportcontrolregister0x0000000031302928272625232220191514109543210//Enableinterruptreques
9、tandUnmaskPI08interruptcaseINTO_ENABLE_INTERRUPT:IOPCON1=INTO_IO_ENABLE;INTO_IO_ENABLE为10000。把IO端口控制寄存器第4位置1,即开启XIRQOobreak;//clearint0pendingintemiptsINTPND2120191817161514131211109876543210Table13-3.INTPNDRegisterRegisterOffsetAddressR/WDescriptionResetValu
10、eINTPND0x4004R/WInterojptpendingregister0x00000000caseINT0_CLEAR_INTERRUPT:INTPNDl=INT0.MASK;INTO_MASK宏定义值为1,把INTPND第0位值1,即把外部中断0清0。break;//setrisingedgeinterruptcaseINTO_RISING_EDGE_INTERRUPT:IOPCON1=INT0_IO_RISING_EDGE;设置中断为上升沿触发;break;//setfallingedgeinter
11、ruptcaseINTO_FALLING_EDGE_INTERRUPT:IOPCON1=INTO_IO_FALLING_EDGE;设置中断为下降沿触发;break;//setbothedgeinterruptcaseINTO_BOTH_EDGE_INTERRUPT:IOPCON1=INTOIOBOTHEDGE;设置中断为下降/上升沿都触发;break;//setasactivehighcaseINT0_ACTIVE_HIGH:IOPCON1=INTO_IO_ACTIVE_HIGH;设置屮断为电平触发;break;
12、default:break;}return0;2,startup.smovrO,#0xd2;makeirqmodewithallirqsdisabledmsrcpsr_cxsf,rOMOVsp,#0x70000设置IRQ模式的栈指针。movrO,#0xd3;makesvcmodewithallirqsdisabledmsrcpsr_cxsf,rOMOVsp,#0x8000
此文档下载收益归作者所有