From: Jan "Yenya" Kasprzak Date: Thu, 2 May 2013 14:58:52 +0000 (+0200) Subject: buttons.c: button on PB0, status LED on PB1 X-Git-Url: https://www.fi.muni.cz/~kas/git//home/kas/public_html/git/?p=tinyboard.git;a=commitdiff_plain;h=fa1f7d30307b72620fc766db4f4aade13bb8d1b5 buttons.c: button on PB0, status LED on PB1 --- diff --git a/projects/step-up/buttons.c b/projects/step-up/buttons.c index 4101a2f..b03a816 100644 --- a/projects/step-up/buttons.c +++ b/projects/step-up/buttons.c @@ -16,17 +16,17 @@ static unsigned char prev_state; void status_led_on_off(unsigned char mode) { if (mode) - PORTB |= _BV(PORTB0); + PORTB |= _BV(PORTB1); else - PORTB &= ~_BV(PORTB0); + PORTB &= ~_BV(PORTB1); } void init_buttons() { - DDRB &= ~_BV(DDB1); - DDRB |= _BV(DDB0); - PORTB |= _BV(PORTB1); // enable internal pull-up - PORTB &= ~_BV(PORTB0); // status led off + DDRB &= ~_BV(DDB0); + DDRB |= _BV(DDB1); + PORTB |= _BV(PORTB0); // enable internal pull-up + PORTB &= ~_BV(PORTB1); // status led off GIMSK &= ~_BV(PCIE); // disable pin-change IRQs PCMSK = 0; // disable pin-change IRQs on all pins of port B @@ -36,19 +36,19 @@ void init_buttons() void susp_buttons() { - DDRB &= ~(_BV(DDB1)); // set as input - PORTB |= _BV(PORTB1); // enable internal pull-up - PORTB &= ~_BV(PORTB0); // set to zero + DDRB &= ~(_BV(DDB0)); // set as input + PORTB |= _BV(PORTB0); // enable internal pull-up + PORTB &= ~_BV(PORTB1); // set to zero GIMSK |= _BV(PCIE); - PCMSK = _BV(PCINT1); + PCMSK = _BV(PCINT0); // disable pin-change IRQs on all pins except PB1 } void timer_check_buttons() { - unsigned char cur = !(PINB & _BV(PINB1)); + unsigned char cur = !(PINB & _BV(PINB0)); unsigned char prev = prev_state; prev_state = cur; @@ -118,8 +118,8 @@ unsigned char buttons_wait_for_release() _delay_ms(100); - pin = PINB & _BV(PINB1); - } while (!(pin & _BV(PINB1))); + pin = PINB & _BV(PINB0); + } while (!(pin & _BV(PINB0))); status_led_on_off(0);