From: Jan "Yenya" Kasprzak Date: Fri, 14 Sep 2012 20:33:02 +0000 (+0200) Subject: delete pwm_off(), use pwm_set instead X-Git-Tag: gerber-fab-20121029-1711~38 X-Git-Url: https://www.fi.muni.cz/~kas/git//home/kas/public_html/git/?a=commitdiff_plain;h=50b66ac17ddb7c5cf2105959905bdb3ca183a978;p=bike-lights.git delete pwm_off(), use pwm_set instead --- diff --git a/firmware/lights.h b/firmware/lights.h index 56345fb..bce5215 100644 --- a/firmware/lights.h +++ b/firmware/lights.h @@ -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); diff --git a/firmware/pwm.c b/firmware/pwm.c index 02992e9..4eb2f83 100644 --- a/firmware/pwm.c +++ b/firmware/pwm.c @@ -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; } diff --git a/firmware/pwmled.c b/firmware/pwmled.c index 8dcb760..7985467 100644 --- a/firmware/pwmled.c +++ b/firmware/pwmled.c @@ -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