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=d1efaaa0333315ac1a7e5d1e1cac91d6d1b2ff13;hb=HEAD;hpb=fad7e8ad13a9c01c6740331376ded53b7e085242 diff --git a/firmware/gpio.c b/firmware/gpio.c index d1efaaa..b51d89f 100644 --- a/firmware/gpio.c +++ b/firmware/gpio.c @@ -2,15 +2,16 @@ #include "lights.h" -void gpio_init() +void init_gpio() { - DDRB |= _BV(PB0) | _BV(PB2); // LED4, LED5 - PORTB &=~ (_BV(PB0) | _BV(PB2)); - - DDRA |= _BV(PA3) | _BV(PA4); // LED6, LED7 - PORTA &=~ (_BV(PA3) | _BV(PA4)); + PORTB &=~ (_BV(PB0) | _BV(PB2) | _BV(PB4) | _BV(PB6)); + DDRB |= _BV(PB0) | _BV(PB2) | _BV(PB4) | _BV(PB6); +} - gpio_set(1, 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) @@ -19,15 +20,15 @@ void gpio_set(unsigned char n, unsigned char on) 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; + case 2: PORTB |= _BV(PB4); break; + case 3: PORTB |= _BV(PB6); break; } } else { 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; + case 2: PORTB &= ~_BV(PB4); break; + case 3: PORTB &= ~_BV(PB6); break; } } }