X-Git-Url: https://www.fi.muni.cz/~kas/git//home/kas/public_html/git/?a=blobdiff_plain;f=firmware%2Fgpio.c;h=8e39bd29923359eb745946711bbb42a07bb21757;hb=64a3d3a699cd60b7a6b4b06c5c38689975a3d460;hp=d1efaaa0333315ac1a7e5d1e1cac91d6d1b2ff13;hpb=fad7e8ad13a9c01c6740331376ded53b7e085242;p=bike-lights.git diff --git a/firmware/gpio.c b/firmware/gpio.c index d1efaaa..8e39bd2 100644 --- a/firmware/gpio.c +++ b/firmware/gpio.c @@ -4,30 +4,39 @@ void gpio_init() { - DDRB |= _BV(PB0) | _BV(PB2); // LED4, LED5 - PORTB &=~ (_BV(PB0) | _BV(PB2)); - - DDRA |= _BV(PA3) | _BV(PA4); // LED6, LED7 - PORTA &=~ (_BV(PA3) | _BV(PA4)); + DDRB |= _BV(PB0) | _BV(PB2) | _BV(PB4) | _BV(PB6); + PORTB &=~ (_BV(PB0) | _BV(PB2) | _BV(PB4) | _BV(PB6)); gpio_set(1, 1); } +void susp_gpio() +{ + DDRB &= ~(_BV(PB0) | _BV(PB2) | _BV(PB4) | _BV(PB6)); + PORTB &= ~(_BV(PB0) | _BV(PB2) | _BV(PB4) | _BV(PB6)); +} + +void gpio_before_poweroff() +{ + DDRB |= _BV(PB2); + PORTB |= _BV(PB2); +} + void gpio_set(unsigned char n, unsigned char on) { if (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; } } }