]> www.fi.muni.cz Git - tinyboard.git/blobdiff - projects/step-up/pwm.c
Deeper sleep when idle
[tinyboard.git] / projects / step-up / pwm.c
index 42ed777357eba68b6d8853e28c92891bd5298e06..b93a4fab8502039d73d811c69b96592725c5bad5 100644 (file)
@@ -11,7 +11,7 @@
  * Counts from 0 to 0xFF, without OCR1C compare.
  */
 
-static unsigned char pwm_enabled;
+volatile unsigned char pwm_enabled;
 
 static void inline enable_pll()
 {
@@ -57,6 +57,7 @@ void pwm_off()
        DDRB &= ~_BV(PB4);
 
        PLLCSR &= ~(_BV(PLLE) | _BV(PCKE));
+       power_timer1_disable();
        pwm_enabled = 0;
 }
 
@@ -65,6 +66,7 @@ void pwm_set(uint8_t stride)
        OCR1B = stride;
 
        if (!pwm_enabled) {
+               power_timer1_enable();
                enable_pll();
                DDRB |= _BV(PB4);
                pwm_enabled = 1;