34 lines
906 B
C
34 lines
906 B
C
#include <avr/io.h>
|
|
#include "button.h"
|
|
|
|
// BUTTON0 PD0
|
|
// BUTTON1 PD1
|
|
// BUTTON2 PD5
|
|
// BUTTON3 PD6
|
|
// BUTTON4 PD7
|
|
// BUTTON5 PC0
|
|
// BUTTON6 PC4 (VFDRESET)
|
|
// BUTTON7 PC1
|
|
|
|
void button_init() {
|
|
// PD0, PD1, PD5, PD6, PD7, PC0, PC1: input, no pullup (button0..5,7)
|
|
PORTD &= ~(_BV(PD0) | _BV(PD1) | _BV(PD5) | _BV(PD6) | _BV(PD7));
|
|
DDRD &= ~(_BV(PD0) | _BV(PD1) | _BV(PD5) | _BV(PD6) | _BV(PD7));
|
|
PORTC &= ~(_BV(PC0) | _BV(PC1));
|
|
DDRC &= ~(_BV(PC0) | _BV(PC1));
|
|
}
|
|
|
|
uint8_t button_get() {
|
|
uint8_t pinc = PINC;
|
|
uint8_t pind = PIND;
|
|
uint8_t buttons = 0;
|
|
if (pind & _BV(PD0)) buttons |= _BV(0);
|
|
if (pind & _BV(PD1)) buttons |= _BV(1);
|
|
if (pind & _BV(PD5)) buttons |= _BV(2);
|
|
if (pind & _BV(PD6)) buttons |= _BV(3);
|
|
if (pind & _BV(PD7)) buttons |= _BV(4);
|
|
if (pinc & _BV(PC0)) buttons |= _BV(5);
|
|
//if (pinc & _BV(PC4)) buttons |= _BV(6);
|
|
if (pinc & _BV(PC1)) buttons |= _BV(7);
|
|
return buttons;
|
|
}
|