]> www.fi.muni.cz Git - bike-lights.git/commitdiff
delete pwm_off(), use pwm_set instead
authorJan "Yenya" Kasprzak <kas@fi.muni.cz>
Fri, 14 Sep 2012 20:33:02 +0000 (22:33 +0200)
committerJan "Yenya" Kasprzak <kas@fi.muni.cz>
Fri, 14 Sep 2012 20:35:01 +0000 (22:35 +0200)
firmware/lights.h
firmware/pwm.c
firmware/pwmled.c

index 56345fb9f7819354299f419804d19653f2bdbd5b..bce52154de1edc3298e2ea93478808470c7c678c 100644 (file)
@@ -28,7 +28,6 @@ void timer_start_adcs();
 
 /* pwm.c */
 void init_pwm();
-void pwm_on(unsigned char n);
 void pwm_off(unsigned char n);
 void pwm_set(unsigned char n, unsigned char stride);
 
index 02992e9a012dcdd6a4451aaf0dbe3e58c1186571..4eb2f83183a1ee411176b58815180afe12d786d0 100644 (file)
@@ -36,15 +36,6 @@ void init_pwm()
        PORTB &= ~(_BV( PB1 ) | _BV( PB3 ) | _BV( PB5 )); // set to zero
 }
 
-void pwm_on(unsigned char n)
-{
-       switch (n) {
-       case 0: DDRB |= _BV(PB1); break;
-       case 1: DDRB |= _BV(PB3); break;
-       case 2: DDRB |= _BV(PB5); break;
-       }
-}
-
 void pwm_off(unsigned char n)
 {
        switch (n) {
@@ -58,8 +49,13 @@ void pwm_set(unsigned char n, unsigned char stride)
 {
        TC1H = 0x00;
        switch (n) {
-       case 0: OCR1A = stride; break;
-       case 1: OCR1B = stride; break;
+       case 0:
+               OCR1A = stride;
+               DDRB |= _BV(PB1);
+               break;
+       case 1: OCR1B = stride;
+               DDRB |= _BV(PB3);
+               break;
        case 2: {
                        uint16_t s16 = PWM_MAX - (uint16_t)stride;
                        volatile unsigned char hi, lo;
@@ -67,6 +63,7 @@ void pwm_set(unsigned char n, unsigned char stride)
                        lo = s16 & 0xFF;
                        TC1H = hi;
                        OCR1D = lo;
+                       DDRB |= _BV(PB5);
                }
                break;
        }
index 8dcb7603ab4006434ef833ec7767e81dbd2a22c5..798546737d358f303889fd7490f97644f2ff91b1 100644 (file)
@@ -28,7 +28,6 @@ static void start_probing(unsigned char n)
 {
        pwmled_state[n] = ST_PROBING;
        pwm_set(n, 0);
-       pwm_on(n);
        pwm_probes[n] = 0;
 }
 
@@ -87,7 +86,6 @@ void pwmled_set_mode(unsigned char n, unsigned char mode)
                mode--;
                pwmval = pwm_vals[n*N_PWMLED_MODES+mode];
                pwm_set(n, pwmval);
-               pwm_on(n);
 #if 0
                log_byte(pwmval);
 #endif