7 #ifndef _BASIC_IO_ABSTRACTION_H_
8 #define _BASIC_IO_ABSTRACTION_H_
16 #include "PlatformDetermination.h"
19 #define SHIFT_REGISTER_OUTPUT_CUTOVER 32
21 #if defined(IOA_USE_MBED) || defined(BUILD_FOR_PICO_CMAKE)
22 #if defined(IOA_USE_MBED)
25 enum ShiftBitOrder { MSBFIRST, LSBFIRST };
26 uint8_t shiftIn(pinid_t dataPin, pinid_t clockPin, ShiftBitOrder bitOrder);
37 ShiftRegConfig(pinid_t clock, pinid_t data, pinid_t latch, uint8_t numDevices) : clock(clock), data(data), latch(latch), numDevices(numDevices) {}
38 ShiftRegConfig() : clock(IO_PIN_NOT_DEFINED), data(IO_PIN_NOT_DEFINED), latch(IO_PIN_NOT_DEFINED), numDevices(0) {}
55 uint8_t numOfDevicesRead;
60 uint8_t numOfDevicesWrite;
62 pinid_t writeLatchPin;
63 pinid_t writeClockPin;
73 pinid_t writeClockPin, pinid_t writeDataPin, pinid_t writeLatchPin, uint8_t numRead, uint8_t numWrite);
79 void writeValue(pinid_t pin, uint8_t value)
override;
90 void writePort(pinid_t port, uint8_t portVal)
override;
95 uint8_t
readPort(pinid_t port)
override;
101 uint8_t numOfDevicesRead;
103 pinid_t readLatchPin;
104 pinid_t readClockPin;
124 uint8_t
readPort(pinid_t port)
override;
129 void writePort(pinid_t port, uint8_t portVal)
override { }
133 uint8_t shiftInFor165()
const;
156 uint8_t writeClockPin, uint8_t writeDataPin, uint8_t writeLatchPin, uint8_t numOfWriteDevices);
176 uint8_t writeClockPin, uint8_t writeDataPin, uint8_t writeLatchPin);
206 #ifndef MAX_ALLOWABLE_DELEGATES
207 #define MAX_ALLOWABLE_DELEGATES 8
210 typedef uint8_t (*ExpanderOpFn)(
IoAbstractionRef ref, uint8_t pin, uint8_t val);
226 pinid_t limits[MAX_ALLOWABLE_DELEGATES];
227 uint8_t numDelegates;
232 void addIoDevice(
BasicIoAbstraction& expander, pinid_t pinsNeeded) { addIoExpander(&expander, pinsNeeded);}
248 void writeValue(pinid_t pin, uint8_t value)
override;
262 void writePort(pinid_t port, uint8_t portVal)
override;
269 uint8_t
readPort(pinid_t port)
override;
278 void attachInterrupt(pinid_t pin, RawIntHandler intHandler, uint8_t mode)
override;
285 uint8_t doExpanderOp(pinid_t pin, uint8_t aVal, ExpanderOpFn fn);
307 #include "TaskManagerIO.h"
309 #include "IoLogging.h"
Provides the core IoAbstraction interface and Arduino implementation of that interface.
IoAbstractionRef inputOutputFromShiftRegister(uint8_t readClockPin, uint8_t readDataPin, uint8_t readLatchPin, uint8_t numOfReadDevices, uint8_t writeClockPin, uint8_t writeDataPin, uint8_t writeLatchPin, uint8_t numOfWriteDevices)
Definition: IoAbstraction.cpp:194
IoAbstractionRef inputOnlyFromShiftRegister(uint8_t readClockPin, uint8_t dataPin, uint8_t latchPin, uint8_t numOfDevicesRead=1)
Definition: IoAbstraction.cpp:190
IoAbstractionRef inputFrom74HC165ShiftRegister(pinid_t readClkPin, pinid_t dataPin, pinid_t latchPin, pinid_t numOfDevices=1)
Definition: IoAbstraction.cpp:286
IoAbstractionRef outputOnlyFromShiftRegister(uint8_t writeClockPin, uint8_t writeDataPin, uint8_t writeLatchPin, uint8_t numOfDevicesWrite=1)
Definition: IoAbstraction.cpp:186
void multiIoAddExpander(MultiIoAbstractionRef multiIo, IoAbstractionRef expander, pinid_t pinRange)
Definition: IoAbstraction.h:305
MultiIoAbstraction * MultiIoAbstractionRef
Definition: IoAbstraction.h:292
MultiIoAbstractionRef multiIoExpander(pinid_t arduinoPinRange)
Definition: IoAbstraction.h:298
Definition: BasicIoAbstraction.h:38
Definition: IoAbstraction.h:223
void writeValue(pinid_t pin, uint8_t value) override
Definition: IoAbstraction.cpp:335
void writePort(pinid_t port, uint8_t portVal) override
Definition: IoAbstraction.cpp:349
uint8_t readPort(pinid_t port) override
Definition: IoAbstraction.cpp:356
bool runLoop() override
Definition: IoAbstraction.cpp:378
void pinDirection(pinid_t pin, uint8_t mode) override
Definition: IoAbstraction.cpp:328
uint8_t readValue(pinid_t pin) override
Definition: IoAbstraction.cpp:342
void attachInterrupt(pinid_t pin, RawIntHandler intHandler, uint8_t mode) override
Definition: IoAbstraction.cpp:362
Definition: IoAbstraction.h:98
void pinDirection(pinid_t pin, uint8_t mode) override
Definition: IoAbstraction.h:120
uint8_t readValue(pinid_t pin) override
Definition: IoAbstraction.cpp:252
void attachInterrupt(pinid_t, RawIntHandler, uint8_t) override
Definition: IoAbstraction.h:131
void writeValue(pinid_t pin, uint8_t value) override
Definition: IoAbstraction.h:130
ShiftRegisterIoAbstraction165In(pinid_t readClockPin, pinid_t readDataPin, pinid_t readLatchPin, pinid_t numRead)
Definition: IoAbstraction.cpp:214
bool runLoop() override
Definition: IoAbstraction.cpp:258
uint8_t readPort(pinid_t port) override
Definition: IoAbstraction.cpp:235
void writePort(pinid_t port, uint8_t portVal) override
Definition: IoAbstraction.h:129
Definition: IoAbstraction.h:49
ShiftRegisterIoAbstraction(pinid_t readClockPin, pinid_t readDataPin, pinid_t readLatchPin, pinid_t writeClockPin, pinid_t writeDataPin, pinid_t writeLatchPin, uint8_t numRead, uint8_t numWrite)
Definition: IoAbstraction.cpp:64
void writeValue(pinid_t pin, uint8_t value) override
Definition: IoAbstraction.cpp:102
void writePort(pinid_t port, uint8_t portVal) override
Definition: IoAbstraction.cpp:110
uint8_t readValue(pinid_t pin) override
Definition: IoAbstraction.cpp:148
void attachInterrupt(pinid_t, RawIntHandler, uint8_t) override
Definition: IoAbstraction.h:84
uint8_t readPort(pinid_t port) override
Definition: IoAbstraction.cpp:133
bool runLoop() override
Definition: IoAbstraction.cpp:152
void pinDirection(pinid_t pin, uint8_t mode) override
Definition: IoAbstraction.cpp:98
Definition: IoAbstraction.h:31