Commit 72048849474c59a70f1148dd41c6f4be9a36a02d
authorKyrylo Yatsenko <kyrylo.yatsenko@hedrok.org>
Tue, 14 Oct 2014 13:35:38 +0000 (16:35 +0300)
committerKyrylo Yatsenko <kyrylo.yatsenko@hedrok.org>
Tue, 14 Oct 2014 13:47:25 +0000 (16:47 +0300)
Several fixes after fcce7868a2fe2ef028b7f6c1741a12380b82a9cc:
- Remove zeroing of mode in which erased mode
  seleced in avr_timer_write
- Fix wrong brackets in ?: in avr_timer_wgm_pwm mode

simavr/sim/avr_timer.c

index 5ed574523f346ad67d5a2cf15ba17576b7dfed33..7d4d715da30dfb715558ee970cdd22cfafb3ba6b 100644 (file)
@@ -237,8 +237,6 @@ static void avr_timer_reconfigure(avr_timer_t * p)
 {
        avr_t * avr = p->io.avr;
 
-       avr_timer_wgm_t zero={0};
-       p->mode = zero;
        // cancel everything
        p->comp[AVR_TIMER_COMPA].comp_cycles = 0;
        p->comp[AVR_TIMER_COMPB].comp_cycles = 0;
@@ -258,8 +256,8 @@ static void avr_timer_reconfigure(avr_timer_t * p)
                        avr_timer_configure(p, p->cs_div_clock, _timer_get_ocr(p, AVR_TIMER_COMPA));
                }       break;
                case avr_timer_wgm_pwm: {
-                       uint16_t top = p->mode.top == (avr_timer_wgm_reg_ocra ?
-                               _timer_get_ocr(p, AVR_TIMER_COMPA) : _timer_get_icr(p));
+                       uint16_t top = (p->mode.top == avr_timer_wgm_reg_ocra) ?
+                               _timer_get_ocr(p, AVR_TIMER_COMPA) : _timer_get_icr(p);
                        avr_timer_configure(p, p->cs_div_clock, top);
                }       break;
                case avr_timer_wgm_fast_pwm: