eBoard ๐
โ โงโจ
Written for SIA 2017/2018
Main Page
Pages
Tutorials
Namespaces
Classes
Files
File List
File Members
eagle_Checks.h
Go to the documentation of this file.
1
#ifndef EAGLE_EBOARD_HELPLIB_CHECKS
2
#define EAGLE_EBOARD_HELPLIB_CHECKS
3
4
using namespace
eagle_impl
;
11
inline
void
checkIdx
(
optVAL_t
idx);
13
inline
void
checkIdx
(
optVAL_t
idx){
14
#if EBOARD_DEBUG_MODE > 0x0
15
assert(idx>=0x0 && idx <
PIN_MAX
);
//changed pins? change me! (didn't want to use macros)
16
assert(idx!=
PIN_BLUETOOTH_RX
&&idx!=
PIN_BLUETOOTH_TX
);
17
#endif
18
}
20
21
#if EBOARD_COPY_AND_PASTE > 0x0
22
#if EBOARD_CHECK_PINS_PWM > 0x0
23
29
optVAL_t
countSetBits (
optVAL_t
x);
31
optVAL_t
countSetBits (
optVAL_t
x) {
32
optVAL_t
count;
//dont't want to overuse global space^^
33
for
(count = 0; x; count++)
34
x &= x - 1;
35
return
count;
36
}
38
#endif
39
40
#if EBOARD_CHECK_PINS > 0x0
41
46
#if defined(__AVR_ATmega328P__) && not defined(__AVR_ATmega2560__)
47
uint16_t pin_out = 0x0;
48
#elif defined(__AVR_ATmega2560__)
49
uint64_t pin_out = 0x0;
50
#endif
51
54
#if defined(__AVR_ATmega328P__) && not defined(__AVR_ATmega2560__)
55
uint16_t pin_in = 0x0;
56
#elif defined(__AVR_ATmega2560__)
57
uint64_t pin_in = 0x0;
58
#endif
59
69
inline
bool
checkPin(
optVAL_t
idx,
optVAL_t
mode = OUTPUT);
71
inline
bool
checkPin(
optVAL_t
idx,
optVAL_t
mode){
72
checkIdx
(idx);
73
return
(mode == OUTPUT)? ((pin_out & (1<<idx))>0x0):((pin_in & (1<<idx))>0x0);
74
}
76
#endif
77
82
void
setPin(
optVAL_t
idx,
optVAL_t
mode = OUTPUT);
84
void
setPin(
optVAL_t
idx,
optVAL_t
mode){
85
#if EBOARD_CHECK_PINS > 0x0
86
checkIdx
(idx);
87
if
(mode==OUTPUT) {
//possible to read from OUTPUT digital ... we won't do it
88
pin_out |= (1<<idx);
89
pin_in &= ~(1<<idx);
90
}
91
else
{
92
pin_in |= (1<<idx);
93
pin_out &= ~(1<<idx);
94
}
95
#endif
96
pinMode(idx, mode);
97
}
99
#endif
100
#endif
checkIdx
void checkIdx(optVAL_t idx)
[DEBUG_MODE] used to check if a pin index is in bounds
PIN_MAX
#define PIN_MAX
Definition:
eBoard.h:133
eagle_impl
this namespace contains all the Don't use manually classes ;)
PIN_BLUETOOTH_RX
#define PIN_BLUETOOTH_RX
Definition:
eBoard.h:399
PIN_BLUETOOTH_TX
#define PIN_BLUETOOTH_TX
Definition:
eBoard.h:410
optVAL_t
int optVAL_t
Definition:
eBoard.h:196
eBoard
source
eagle_Checks.h
[WIP-BUILD]
EagleoutIce
19.04.2018 16:49:12