-
Notifications
You must be signed in to change notification settings - Fork 0
/
avrinputoutput.hpp
53 lines (42 loc) · 1.19 KB
/
avrinputoutput.hpp
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
#ifndef TMP_AVR_INPUT_OUTPUT_HPP
#define TMP_AVR_INPUT_OUTPUT_HPP
// This namespace holds the enums for convenient HW I/O access
namespace AvrInputOutput
{
enum PinType
{
OutputHigh,
OutputLow,
Input,
InputPullup
};
// don't change these PinState-values, as they are the ones hardcoded in the
// chip and currently not transformed in the reading methods.
enum PinState
{
Low=0,
High=1
};
// convenience methods for access to respectively input or output only
template<bool PullupEnabled_>
AvrInputOutput::PinType getInputType()
{
return AvrInputOutput::PinType::Input;
}
template<PinState DesiredPinState_>
AvrInputOutput::PinType getOutputType()
{
return AvrInputOutput::PinType::OutputLow;
}
} // namespace AvrInputOutput
template<>
AvrInputOutput::PinType AvrInputOutput::getInputType</*PullupEnabled*/ true>()
{
return AvrInputOutput::PinType::InputPullup;
}
template<>
AvrInputOutput::PinType AvrInputOutput::getOutputType</*DesiredPinState*/ AvrInputOutput::PinState::High>()
{
return AvrInputOutput::PinType::OutputHigh;
}
#endif // TMP_AVR_INPUT_OUTPUT_HPP