-
Notifications
You must be signed in to change notification settings - Fork 0
/
EABase_Chip.h
77 lines (65 loc) · 1.87 KB
/
EABase_Chip.h
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
65
66
67
68
69
70
71
72
73
74
75
76
77
#ifndef __EABase_Chip_H
#define __EABase_Chip_H
#include "EABase.h"
#include "EABase_Object.h"
#if ARDUINO >= 100
#include "Arduino.h"
#else
#include "WProgram.h"
#endif
class EABase_Chip : EABase_Object
{
public:
EABase_Chip(EABase *eabase) : EABase_Object(eabase) {
baseClass = eabase;
}
EABase *baseClass;
};
class EABase_ChipIO : public EABase_Chip
{
public:
EABase_ChipIO(EABase *eabase) : EABase_Chip(eabase) {}
virtual uint8_t getPinNo(uint8_t pin) { return pin; }
void setIgnore(EABase_PINNO pin) { Ignore = setPin(Ignore, pin, true); }
void setIgnores(EABase_PINNO *pins)
{
for (EABase_PINNO i = 0; i < pins[0]; i++)
setIgnore(pins[i + 1]);
}
virtual void setMode(EABase_PINNO pin, int value, bool invert) = 0;
virtual void setMode(EABase_PINNO *pins, int value, bool invert) = 0;
virtual void pinWrite(EABase_PINNO pin, bool value) = 0;
virtual void pinWrite(EABase_PINNO *pins, EABase_PINDATA values) = 0;
virtual bool pinRead(EABase_PINNO pin) = 0;
virtual EABase_PINDATA pinRead(uint8_t *pins) = 0;
virtual uint8_t maxPins() = 0;
EABase_PINDATA setPin(EABase_PINDATA input, uint8_t pin, bool value)
{
EABase_PINDATA work = input;
if (pin >= 0 && pin < maxPins())
{
if (value == true)
return (input | ((EABase_PINDATA)1 << pin));
else
return (input & ~((EABase_PINDATA)1 << pin));
}
return input;
}
bool getPin(EABase_PINDATA input, int pin)
{
if (pin >= 0 && pin < maxPins())
{
if ((input & ((EABase_PINDATA)1 << pin)) > 0)
return true;
else
return false;
}
return false;
}
EABase_PINDATA Ignore = 0;
EABase_PINDATA Direction = 0;
EABase_PINDATA PullUp = 0;
EABase_PINDATA Output = 0;
EABase_PINDATA Invert = 0;
};
#endif