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=8e39bd29923359eb745946711bbb42a07bb21757;hp=d2a240b4e31fd4a3690ba4b69ace130b5dd83538;hb=5ea15612762e0ed843fd31734b4937c15892b546;hpb=740d6851a8c6110d3d37a5be59c9944f01fb92b0 diff --git a/firmware/gpio.c b/firmware/gpio.c index d2a240b..8e39bd2 100644 --- a/firmware/gpio.c +++ b/firmware/gpio.c @@ -4,28 +4,22 @@ 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)); // 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)); } void gpio_before_poweroff() { - DDRA |= _BV(PA4); - PORTA |= _BV(PA4); + DDRB |= _BV(PB2); + PORTB |= _BV(PB2); } void gpio_set(unsigned char n, unsigned char on) @@ -34,15 +28,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; } } }