From: Jan "Yenya" Kasprzak Date: Fri, 14 Sep 2012 21:34:31 +0000 (+0200) Subject: gpio leds according to new pins.txt X-Git-Tag: gerber-fab-20121029-1711~35 X-Git-Url: https://www.fi.muni.cz/~kas/git//home/kas/public_html/git/?a=commitdiff_plain;h=04c70055063c30c7ebda95872527919f5f48c9a2;p=bike-lights.git gpio leds according to new pins.txt --- diff --git a/firmware/gpio.c b/firmware/gpio.c index 2ee3210..d759b18 100644 --- a/firmware/gpio.c +++ b/firmware/gpio.c @@ -4,24 +4,31 @@ void gpio_init() { - DDRB |= _BV(PB2) | _BV(PB4); - PORTB &=~ (_BV(PB2) | _BV(PB4)); + DDRB |= _BV(PB0) | _BV(PB2); // LED4, LED5 + PORTB &=~ (_BV(PB0) | _BV(PB2)); - gpio_set(GPIO_LED2, 1); + DDRA |= _BV(PA3) | _BV(PA4); // LED6, LED7 + PORTB &=~ (_BV(PA3) | _BV(PA4)); + + gpio_set(1, 1); } void gpio_set(unsigned char n, unsigned char on) { - unsigned char bits = 0; - switch(n) { - case GPIO_LED1: bits = _BV(PB4); break; - case GPIO_LED2: bits = _BV(PB2); break; - } - if (on) { - PORTB |= bits; + switch(n) { + case 0: PORTB |= _BV(PB0); break; + case 1: PORTB |= _BV(PB2); break; + case 2: PORTA |= _BV(PA3); break; + case 3: PORTA |= _BV(PA4); break; + } } else { - PORTB &= ~bits; + switch(n) { + case 0: PORTB &= ~_BV(PB0); break; + case 1: PORTB &= ~_BV(PB2); break; + case 2: PORTA &= ~_BV(PA3); break; + case 3: PORTA &= ~_BV(PA4); break; + } } } diff --git a/firmware/lights.h b/firmware/lights.h index c0daaef..d7f0065 100644 --- a/firmware/lights.h +++ b/firmware/lights.h @@ -1,7 +1,7 @@ #ifndef LIGHTS_H__ #define LIGHTS_H__ 1 -#define N_LEDS 5 +#define N_LEDS 7 #define N_PWMLEDS 3 #define N_PWMLED_MODES 4 @@ -43,9 +43,6 @@ unsigned char pwmled_needs_adc(unsigned char n); unsigned char pwmled_enabled(unsigned char n); /* gpio.c */ -#define GPIO_LED1 0 -#define GPIO_LED2 1 - void gpio_init(); void gpio_set(unsigned char n, unsigned char on);