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=d2a240b4e31fd4a3690ba4b69ace130b5dd83538;hp=2ee32109d754360434afc6ec0ed3d5c3a8269592;hb=HEAD;hpb=f956c1fa7f47b0e8b8afe323c2eff1b6c2607c2a diff --git a/firmware/gpio.c b/firmware/gpio.c index 2ee3210..b51d89f 100644 --- a/firmware/gpio.c +++ b/firmware/gpio.c @@ -2,26 +2,34 @@ #include "lights.h" -void gpio_init() +void init_gpio() { - DDRB |= _BV(PB2) | _BV(PB4); - PORTB &=~ (_BV(PB2) | _BV(PB4)); + PORTB &=~ (_BV(PB0) | _BV(PB2) | _BV(PB4) | _BV(PB6)); + DDRB |= _BV(PB0) | _BV(PB2) | _BV(PB4) | _BV(PB6); +} - gpio_set(GPIO_LED2, 1); +void susp_gpio() +{ + PORTB &= ~(_BV(PB0) | _BV(PB2) | _BV(PB4) | _BV(PB6)); + DDRB |= _BV(PB0) | _BV(PB2) | _BV(PB4) | _BV(PB6); } 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: PORTB |= _BV(PB4); break; + case 3: PORTB |= _BV(PB6); break; + } } else { - PORTB &= ~bits; + switch(n) { + case 0: PORTB &= ~_BV(PB0); break; + case 1: PORTB &= ~_BV(PB2); break; + case 2: PORTB &= ~_BV(PB4); break; + case 3: PORTB &= ~_BV(PB6); break; + } } }