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=014b5cfa49f3697ad13d717949327e4b790e20f9;hp=d759b1883f114d2ed9fbae96a8e016ac4b689ca5;hpb=04c70055063c30c7ebda95872527919f5f48c9a2;p=bike-lights.git diff --git a/firmware/gpio.c b/firmware/gpio.c index d759b18..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 - PORTB &=~ (_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; } } }