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=b51d89f6c9442366b347c07705cc357fd330ea5b;hp=d2a240b4e31fd4a3690ba4b69ace130b5dd83538;hb=65c3ad96cf307c3b77b36e6f6a2af5201c213a3c;hpb=a06ea914a745c95ca286ea41337ff5bbf3d02cbd diff --git a/firmware/gpio.c b/firmware/gpio.c index d2a240b..b51d89f 100644 --- a/firmware/gpio.c +++ b/firmware/gpio.c @@ -2,30 +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)); - - gpio_set(1, 1); + PORTB &=~ (_BV(PB0) | _BV(PB2) | _BV(PB4) | _BV(PB6)); + DDRB |= _BV(PB0) | _BV(PB2) | _BV(PB4) | _BV(PB6); } void susp_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)); -} - -void gpio_before_poweroff() -{ - DDRA |= _BV(PA4); - PORTA |= _BV(PA4); + 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) @@ -34,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; } } }