#include <BasicIoAbstraction.h>
Public Member Functions | |
uint8_t | digitalRead (pinid_t p) |
void | digitalWrite (pinid_t p, uint8_t v) |
uint8_t | digitalReadS (pinid_t p) |
void | digitalWriteS (pinid_t p, uint8_t v) |
void | writePortS (pinid_t p, uint8_t v) |
uint8_t | readPortS (pinid_t p) |
void | pinMode (pinid_t pin, uint8_t mode) |
bool | sync () |
virtual void | pinDirection (pinid_t pin, uint8_t mode) |
virtual void | writeValue (pinid_t pin, uint8_t value) |
virtual uint8_t | readValue (pinid_t pin) |
virtual void | attachInterrupt (pinid_t pin, RawIntHandler interruptHandler, uint8_t mode) |
virtual bool | runLoop () |
virtual void | writePort (pinid_t pin, uint8_t portVal) |
virtual uint8_t | readPort (pinid_t pin) |
This class provides the interface by which all IoAbstractionRef
types work. It makes it possible to treat many types of IO in the same way, by providing a standard way of dealing with Arduino pins, shift registers and IO expanders.
As well as providing the standard interface, it also provides the Arduino pin implementation.
Normally, to use an IoAbstraction one would use the helper functions available, for this IoAbstraction the helper function is ioUsingArduino
|
inline |
Reads the current digital state of a pin, HIGH or LOW. Note that for I2C/off-chip devices you need to sync() the device first. This means you can read many pins with one sync!
p | the pin to read |
|
inline |
Writes a new digital value for a given pin on the device. For I2C and other offboard devices you'll need to sync() afterwards, or use digitalWriteS if you only need a single write.
p | the pin to write |
v | the value to write |
|
inline |
Reads the current digital state of a pin, HIGH or LOW. Does a sync() before reading ensuring latest values.
p | the pin to read |
|
inline |
Writes a new digital value for a given pin on the device. For I2C and other off-chip devices this does sync() after writing. It is useful when only one pin needs to be set. To write more than one pin at once, use the non sync() version and sync() at the end.
p | the pin to write |
v | the value to write |
|
inline |
Write a whole port at once if support by the device. Supported on most Arduino, I2C, Shift registers. It does sync with the device for I2C/off-chip. Use the non 'S' version to optimize writes to off-board chips.
p | any pin on the port |
v | the value for the whole port. |
|
inline |
Reads a whole port at once, and does a sync() with the chip before hand. Use the non 'S' version to optimize writes to off-board chips.
p | any pin on the port |
|
inline |
Set the direction of a pin on the device, be careful that the device can support the pin mode you're requesting. It roughly follows the Arduino method.
pin | the pin to set the mode for |
mode | the mode you are requesting, EG OUTPUT, INPUT, INPUT_PULLUP |
|
inline |
This method is not needed on Arduino pins, but for most serial implementations it causes the device and abstraction to be synced. Returns true if the write call worked, normally true, false indicates error
|
virtual |
sets the pin direction for a pin controlled by this abstraction - as per pinMode
pin | the pin to be changed |
mode | the new mode, as per pinMode (or on Mbed you can use PinMode enum values) |
Reimplemented in NegatingIoAbstraction, LoggingIoAbstraction, MockedIoAbstraction, AnalogJoystickToButtons, MPR121IoAbstraction, AW9523IoAbstraction, MCP23017IoAbstraction, PCF8574IoAbstraction, MultiIoAbstraction, ShiftRegisterIoAbstraction165In, ShiftRegisterIoAbstraction, and DfRobotInputAbstraction.
|
virtual |
Writes a value to a pin on this abstraction, as per digitalWrite
. For serial devices, may need a sync first.
pin | the pin to be written to |
value | the new value such as HIGH / LOW |
Reimplemented in NegatingIoAbstraction, LoggingIoAbstraction, MockedIoAbstraction, AnalogJoystickToButtons, Standard16BitDevice, PCF8574IoAbstraction, MultiIoAbstraction, ShiftRegisterIoAbstraction165In, ShiftRegisterIoAbstraction, and DfRobotInputAbstraction.
|
virtual |
Reads a value from a pin for this abstraction as per digitalRead
. For serial devices may need a sync first.
pin | the pin to be read |
Reimplemented in NegatingIoAbstraction, LoggingIoAbstraction, MockedIoAbstraction, AnalogJoystickToButtons, Standard16BitDevice, PCF8574IoAbstraction, MultiIoAbstraction, ShiftRegisterIoAbstraction165In, ShiftRegisterIoAbstraction, and DfRobotInputAbstraction.
|
virtual |
Attach an interrupt to this abstraction, regardless of the device location this will perform the required tasks to register the interrupt in the requested mode. Note that not all devices can support all modes, for arduino pins all modes are supported.
pin | the pin on this device to be used |
intHandler | a void function with no parameters, used to handle interrupts. THIS IS A RAW INTERRUPT AND NOT MARSHALLED |
mode | standard Arduino interrupt modes: CHANGE, RISING, FALLING |
Reimplemented in ShiftRegisterIoAbstraction165In, ShiftRegisterIoAbstraction, MPR121IoAbstraction, AW9523IoAbstraction, MCP23017IoAbstraction, PCF8574IoAbstraction, MultiIoAbstraction, NegatingIoAbstraction, LoggingIoAbstraction, and MockedIoAbstraction.
|
inlinevirtual |
This method is not needed on Arduino pins, but for most serial implementations it causes the device and abstraction to be synced. Returns true if the write call worked, normally true, false indicates error
Reimplemented in NegatingIoAbstraction, LoggingIoAbstraction, MockedIoAbstraction, AnalogJoystickToButtons, MPR121IoAbstraction, AW9523IoAbstraction, MCP23017IoAbstraction, PCF8574IoAbstraction, MultiIoAbstraction, ShiftRegisterIoAbstraction165In, ShiftRegisterIoAbstraction, and DfRobotInputAbstraction.
|
virtual |
Writes out a whole port at once, on Arduino pins this is achieved by providing any pin within that port. On Arduino pins you should take care not to use ports that are providing core functions.
pin | the pin determines the hardware port to use. |
portVal | the 8 bit value to write to the port. Use with care. |
Reimplemented in MultiIoAbstraction, ShiftRegisterIoAbstraction165In, ShiftRegisterIoAbstraction, NegatingIoAbstraction, LoggingIoAbstraction, MockedIoAbstraction, AnalogJoystickToButtons, DfRobotInputAbstraction, Standard16BitDevice, and PCF8574IoAbstraction.
|
virtual |
Reads a whole port at once, on Arduino pins this is achieved by providing any pin within that port. On Arduino pins you should take care not to use ports that are providing core functions.
pin | the pin determines the hardware port to use. |
Reimplemented in MultiIoAbstraction, ShiftRegisterIoAbstraction165In, ShiftRegisterIoAbstraction, DfRobotInputAbstraction, NegatingIoAbstraction, LoggingIoAbstraction, AnalogJoystickToButtons, Standard16BitDevice, PCF8574IoAbstraction, and MockedIoAbstraction.