]> www.fi.muni.cz Git - bike-lights.git/blobdiff - firmware/gpio.c
gpio leds according to new pins.txt
[bike-lights.git] / firmware / gpio.c
index 2ee32109d754360434afc6ec0ed3d5c3a8269592..d759b1883f114d2ed9fbae96a8e016ac4b689ca5 100644 (file)
@@ -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;
+               }
        }
 }