-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathRDButton.h
More file actions
64 lines (56 loc) · 1.39 KB
/
RDButton.h
File metadata and controls
64 lines (56 loc) · 1.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
/*
* libRobotDev
* RDButton.h
* Purpose: Abstracts all micro button interface functions
* Created: 25/07/2014 11:52:35 AM
* Author(s): Jerry Luck, Jeremy Pearson, Darryl Lee
* Status: TESTED <Blake>
*/
#include <avr/io.h>
#include "RDPinDefs.h"
#include "RDUtil.h"
#ifndef RDBUTTON_H_
/**
* Robot Development Button Header.
*/
#define RDBUTTON_H_
/**
* Sets up specified pin of Port F as an input.
* @param pin
* The specific pin of Port F to be set as an input.
*/
void RDSetupButton(unsigned char pin){
clr_bit(DDRF, pin);
}
/**
* Checks if button is pressed.
* @param pin
* The specific pin of Port F that the button is attached to.
*
* @return
* 1 if specified pin of Port F is high (button is pressed),
* 0 if specified pin of Port F is low (button is not pressed).
*/
unsigned char RDButtonIsPressed(unsigned char pin){
if(get_bit(PORTF, pin))
return 1;
else
return 0;
}
/**
* Waits until button is pressed, before it returns.
* @param pin
* The specific pin of Port F that the button is attached to.
*/
void RDButtonWaitForPress(unsigned char pin){
while(!get_bit(PORTF, pin));
}
/**
* Waits until button is not pressed, before it returns.
* @param pin
* The specific pin of Port F that the button is attached to.
*/
void RDButtonWaitForRelease(unsigned char pin){
while(get_bit(PORTF, pin));
}
#endif // RDBUTTON_H_