mini6410中断控制器-VIC中断控制器
时间:11-20
来源:互联网
点击:
- sf,#0xd2;切换到中断模式下
- ldrsp,=0x51000000;设置中断模式栈指针
- msrcpsr_cxsf,#0x13;返回管理模式
- IMPORTxmain
- blxmain
- loop
- bloop
- ;***********************************************************************
- ;中断处理
- ;***********************************************************************
- ;K1pressirq
- EXPORTasm_handle_k1_irq
- asm_handle_k1_irq
- sublr,lr,#4;修正返回地址
- stmdbsp!,{r0-r12,lr};保存程序执行现场
- ldrlr,=isr_return;设置中断处理程序返回地址
- IMPORT__do_k1_irq
- ldrpc,=__do_k1_irq;跳入中断处理程序
- ;timer0pressirq
- EXPORTasm_handle_tmr0_irq
- asm_handle_tmr0_irq
- sublr,lr,#4;修正返回地址
- stmdbsp!,{r0-r12,lr};保存程序执行现场
- ldrlr,=isr_return;设置中断处理程序返回地址
- IMPORT__do_tmr0_irq
- ldrpc,=__do_tmr0_irq;跳入中断处理程序
- isr_return;中断处理返回标签
- ldmiasp!,{r0-r12,pc}^;恢复程序执行现场,返回继续执行
- END;程序结束符
init.c
//////////////////////////////////////////////////////////////////////////////////
- #defineGPNCON(*(volatileunsignedlong*)0x7F008830)
- #defineGPNPUD(*(volatileunsignedlong*)0x7F008838)
- #defineEINT0CON0(*(volatileunsignedlong*)0x7F008900)
- #defineEINT0MASK(*(volatileunsignedlong*)0x7F008920)
- #defineVIC0IRQSTATUS(*(volatileunsignedlong*)0x71200004)
- #defineVIC0INTSELECT(*(volatileunsignedlong*)0x7120000C)
- #defineVIC1INTSELECT(*(volatileunsignedlong*)0x7130000C)
- #defineVIC0INTENABLE(*(volatileunsignedlong*)0x71200010)
- #defineVIC1INTENABLE(*(volatileunsignedlong*)0x71300010)
- #defineVIC0INTENCLEAR(*(volatileunsignedlong*)0x71200014)
- #defineVIC1INTENCLEAR(*(volatileunsignedlong*)0x71300014)
- #defineVIC0VECTADDR(*(volatileunsignedlong*)0x71200100)
- #defineINT_EINT0_BIT0
- #defineINT_TIMER0_BIT23
- //////////////////////////////////////////////////////////////////////////////////
- externvoidasm_handle_k1_irq(void);
- externvoidasm_handle_tmr0_irq(void);
- typedefvoid(fnc_t)(void);
- fnc_t**isr_array=(fnc_t**)0x71200100;
- voidirq_init()
- {
- __asm{
- mrcp15,0,r0,c1,c0,0;
- orrr0,r0,#(0x1000000);
- mcrp15,0,r0,c1,c0,0;
- }
- //configureGPN0asEINT0
- GPNCON&=(~0x2);
- GPNCON|=0x2;
- GPNPUD&=~(0x3);
- //K1,K2fallingedgetrigged
- EINT0CON0&=(~0x3);
- EINT0CON0|=0x3;
- //EnableEINT0irq
- EINT0MASK&=(~0x1);
- //SelectINT_EINT0modeasirq
- VIC0INTSELECT&=(~(1
- //inittheisraddr
- isr_array[INT_EINT0_BIT]=(fnc_t*)asm_handle_k1_irq;
- isr_array[INT_TIMER0_BIT]=(fnc_t*)asm_handle_tmr0_irq;
- //enableINT_EINT0
- VIC0INTENABLE|=(1
- printk("irqinitOK\r\n");
- }
handle_irq.c
- //====================================================
- #defineVIC0ADDRESS(*(volatileunsignedlong*)0x71200F00)
- #defineVIC1ADDRESS(*(volatileunsignedlong*)0x71300F00)
- #defineEINT0PEND(*(volatileunsignedlong*)0x7F008924)
- #defineTINT_CSTAT(*(volatileunsignedlong*)0x7F006044)
- externintprintk(char*);
- /*系统中断处理函数*/
- #defineclear_irq()\
- do{\
- VIC0ADDRESS=0;\
- VIC1ADDRESS=0;\
- }while(0)
- void__do_k1_irq(void)
- {
- printk("do_irq\r\n");
- //clearK1irq
- EINT0PEND=1;
- //clearVICADDRESS
- clear_irq();
- }
- void__do_tmr0_irq(void)
- {
- printk("Timer0irqoccur\r\n");
- //cleartimer0irq
- TINT_CSTAT|=1<5;
- //clearVICADDRESS
- clear_irq();
- return;
- }
main.c
- //===================================================
- #defineGPKCON(*(volatileunsignedlong*)0x7F008800)
- #defineGPKDAT(*(volatileunsignedlong*)0x7F008808)
- #defineLED_BIT(1<5|1<6|1<7|1<8)
- externvoiduart_init(void);
- externvoidirq_init(void);
- externvoidtimer0_init(void);
- externintprintk(constchar*str);
- externvoidled_run(void);
- intled_on()
- {
- GPKCON&=0xFFFF0000;//设置GPB5~8为输出口
- GPKCON|=0x11110000;
- GPKDAT=0;//令LED亮灯
- printk("led_on\n\r");
- return0;
- }
- intxmain(){
- uart_init();
- printk("uart_initOK\n\r");
- led_on();
- irq_init();
- timer0_init();
- led_run();
- return0;
- }
mini6410中断控制器VI 相关文章:
- Windows CE 进程、线程和内存管理(11-09)
- RedHatLinux新手入门教程(5)(11-12)
- uClinux介绍(11-09)
- openwebmailV1.60安装教学(11-12)
- Linux嵌入式系统开发平台选型探讨(11-09)
- Windows CE 进程、线程和内存管理(二)(11-09)