ReflexBall Rally
Main Page
Data Structures
Files
File List
Globals
All
Data Structures
Files
Functions
Variables
Macros
buttons.c
Go to the documentation of this file.
1
#include <eZ8.h>
// special encore constants, macros and flash routines
2
#include <sio.h>
// special encore serial i/o routines
3
#include "
buttons.h
"
4
#include "
time.h
"
5
6
void
initButtons
() {
// Initialize the buttons on the evaluation board
7
PDDD = (1 << 3);
8
PFDD = (1 << 6) | (1 << 7);
9
}
10
11
unsigned
char
readButtons
() {
// Read the buttons buttons in the following order: bit2: PD3, bit1: PF6 and bit0: PF7
12
unsigned
char
inD, inF;
13
inD = (~PDIN >> 3) & 0
x1
;
14
inF = (~PFIN >> 6) & 0x3;
15
return
((inF >> 1) | ((inF & 0x1) << 1) | (inD << 2));
16
}
17
18
unsigned
char
readkey
() {
// Read button with debounce
19
unsigned
char
output =
readButtons
();
20
delay_ms
(50);
// Wait 50ms
21
output &=
readButtons
();
// Check if it is still high
22
return
output;
23
}
Generated by
1.8.4