Commit 6356c90c173e9d1672001048b15468cbbe2cfd08
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>
2 files changed:
simavr/sim/avr_timer.c
simavr/sim/avr_timer.h

index 22e9f455e7e2d5cde848ce66f6136cbe8aafed97..b853868a49a75620177316ef829b35615c0693ee 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 3d0b57561c0003a7e7d6897e54cb63d0bafe019f..8ef1d95229551f39fa30e96b2018244c4b735fa3 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