timer: Added (non functional) C interrupt block
authorMichel Pollet <buserror@gmail.com>
Sun, 4 Apr 2010 11:21:45 +0000 (12:21 +0100)
committerMichel Pollet <buserror@gmail.com>
Sun, 4 Apr 2010 11:21:45 +0000 (12:21 +0100)
Needs some code

Signed-off-by: Michel Pollet <buserror@gmail.com>
simavr/sim/avr_timer.c
simavr/sim/avr_timer.h

index 22e9f45..b853868 100644 (file)
@@ -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);
index 3d0b575..8ef1d95 100644 (file)
@@ -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