X-Git-Url: https://hackdaworld.org/gitweb/?p=my-code%2Farm.git;a=blobdiff_plain;f=betty%2Finterrupts.c;h=0e0baa32bbbb04866fc9985b3f00095a98402b5e;hp=e344f054149066fd6724e3ea061056ecb147ce73;hb=1473a4be06e0cc16875bf6c49719a2c92826f908;hpb=b75b1bf631a3bb68f50f65c65736b1bf743f51b7 diff --git a/betty/interrupts.c b/betty/interrupts.c index e344f05..0e0baa3 100644 --- a/betty/interrupts.c +++ b/betty/interrupts.c @@ -15,6 +15,8 @@ static t_interrupt interrupt; * functions */ +// generaal interrupt handling + void interrupt_init(void) { interrupt.default_soft_callback=0; @@ -33,6 +35,11 @@ void interrupt_set_soft_callback(void (*callback)(void)) { interrupt.default_soft_callback=callback; } +void interrupt_set_fiq_callback(void (*callback)(void)) { + + interrupt.fiq_callback=callback; +} + void interrupt_soft_clear(u8 src_number) { VICSoftIntClr=(1<3) @@ -135,9 +150,69 @@ void interrupt_ext_ir_set(u8 eint) { EXTINT=(1<1) + return; + + if(tcnum==0) { + T0TCR=0x03; + T0CTCR=mode|(cap<<2); + T0PR=psc; + } + else { + T1TCR=0x03; + T1CTCR=mode|(cap<<2); + T1PR=psc; + } +} + +void interrupt_tc_match_config(u8 tcnum,u8 mnum,u32 val,u8 mode) { + + u32 *mraddr; + + if(tcnum>1) + return; + + if(mnum>3) + return; + + if(tcnum==0) { + T0MCR=mode<<(3*mnum); + mrddr=&T0MR0 + } + else { + T1MCR=mode<<(3*mnum); + mrddr=&T1MR0 + } + + mraddr[mnum]=val; +} + +void interrupt_tc_capt_config(u8 tcnum,u8 cnum,u8 mode) { + + if(tcnum>1) + return; + + if(cnum>3) + return; + + if(tcnum==0) + T0CCR=mode<<(3*cnum); + else + T1CCR=mode<<(3*cnum); +} + +void interrupt_tc_ir_set(u8 tcnum,u8 tcmc) { + + if(tcnum>1) + return; + + if(tcnum==0) + T0IR=tcmc; + else + T1IR=tcmc; } /* @@ -169,5 +244,8 @@ void interrupt_handler_data_abort(void) { // fiq void interrupt_handler_fiq(void) { + + if(interrupt.fiq_callback) + interrupt.fiq_callback(); }