X-Git-Url: https://www.fi.muni.cz/~kas/git//home/kas/public_html/git/?p=bike-lights.git;a=blobdiff_plain;f=firmware%2Fgpio.c;h=d759b1883f114d2ed9fbae96a8e016ac4b689ca5;hp=2ee32109d754360434afc6ec0ed3d5c3a8269592;hb=04c70055063c30c7ebda95872527919f5f48c9a2;hpb=2a206315ac194c21e3a14ca0b3a9e29cd0cec0b2 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; + } } }