From: Michel Pollet Date: Sun, 4 Apr 2010 11:21:45 +0000 (+0100) Subject: timer: Added (non functional) C interrupt block X-Git-Tag: v1.0a2~17 X-Git-Url: https://git.htl-mechatronik.at/public/?a=commitdiff_plain;h=6356c90c173e9d1672001048b15468cbbe2cfd08;p=sx%2Fsimavr.git timer: Added (non functional) C interrupt block Needs some code Signed-off-by: Michel Pollet --- diff --git a/simavr/sim/avr_timer.c b/simavr/sim/avr_timer.c index 22e9f45..b853868 100644 --- a/simavr/sim/avr_timer.c +++ b/simavr/sim/avr_timer.c @@ -304,7 +304,10 @@ void avr_timer_init(avr_t * avr, avr_timer_t * p) * the trigger. */ avr_register_io_write(avr, p->r_ocra, avr_timer_write_ocr, p); - avr_register_io_write(avr, p->r_ocrb, avr_timer_write, p); + if (p->r_ocrb) // not all timers have B register + avr_register_io_write(avr, p->r_ocrb, avr_timer_write, p); + if(p->r_ocrc) // but some have a C one + avr_register_io_write(avr, p->r_ocrc, avr_timer_write, p); avr_register_io_write(avr, p->r_tcnt, avr_timer_tcnt_write, p); avr_register_io_read(avr, p->r_tcnt, avr_timer_tcnt_read, p); diff --git a/simavr/sim/avr_timer.h b/simavr/sim/avr_timer.h index 3d0b575..8ef1d95 100644 --- a/simavr/sim/avr_timer.h +++ b/simavr/sim/avr_timer.h @@ -65,7 +65,7 @@ typedef struct avr_timer_t { avr_regbit_t disabled; // bit in the PRR avr_io_addr_t r_ocra, r_ocrb, r_ocrc, r_tcnt, r_icr; - avr_io_addr_t r_ocrah, r_ocrbh, r_tcnth, r_icrh; + avr_io_addr_t r_ocrah, r_ocrbh, r_ocrch, r_tcnth, r_icrh; avr_regbit_t wgm[4]; avr_timer_wgm_t wgm_op[16]; @@ -75,13 +75,15 @@ typedef struct avr_timer_t { avr_regbit_t as2; // asynchronous clock 32khz avr_int_vector_t compa; // comparator A - avr_int_vector_t compb; // comparator A + avr_int_vector_t compb; // comparator B + avr_int_vector_t compc; // comparator C TODO: code avr_int_vector_t overflow; // overflow avr_int_vector_t icr; // input capture avr_timer_wgm_t mode; uint64_t compa_cycles; uint64_t compb_cycles; + uint64_t compc_cycles; uint64_t tov_cycles; uint64_t tov_base; // we we last were called uint16_t tov_top; // current top value to calculate tnct