IoAbstraction
Classes | Typedefs | Functions | Variables
BasicIoAbstraction.h File Reference

Provides the core IoAbstraction interface and Arduino implementation of that interface. More...

Go to the source code of this file.

Classes

class  BasicIoAbstraction
 

Typedefs

typedef BasicIoAbstractionIoAbstractionRef
 

Functions

IoAbstractionRef internalDigitalIo ()
 
void ioDevicePinMode (IoAbstractionRef ioDev, pinid_t pin, uint8_t dir)
 
uint8_t ioDeviceDigitalRead (IoAbstractionRef ioDev, pinid_t pin)
 
void ioDeviceDigitalWrite (IoAbstractionRef ioDev, pinid_t pin, uint8_t val)
 
bool ioDeviceSync (IoAbstractionRef ioDev)
 
void ioDeviceAttachInterrupt (IoAbstractionRef ioDev, pinid_t pin, RawIntHandler intHandler, uint8_t mode)
 
uint8_t ioDeviceDigitalReadS (IoAbstractionRef ioDev, pinid_t pin)
 
bool ioDeviceDigitalWriteS (IoAbstractionRef ioDev, pinid_t pin, uint8_t val)
 
bool ioDeviceDigitalWritePortS (IoAbstractionRef ioDev, pinid_t pinOnPort, uint8_t portVal)
 
uint8_t ioDeviceDigitalReadPortS (IoAbstractionRef ioDev, pinid_t pinOnPort)
 
void ioDeviceDigitalWritePort (IoAbstractionRef ioDev, pinid_t pinOnPort, uint8_t portVal)
 
uint8_t ioDeviceDigitalReadPort (IoAbstractionRef ioDev, pinid_t pinOnPort)
 

Variables

BasicIoAbstraction internalIoAbstraction
 

Detailed Description

Provides the core IoAbstraction interface and Arduino implementation of that interface.

Typedef Documentation

◆ IoAbstractionRef

A reference to any type of IoAbstraction, that can be passed to one of the ioDevice.. functions. Normally, a reference is obtained using a helper function, such as ioUsingArduino.

Function Documentation

◆ internalDigitalIo()

IoAbstractionRef internalDigitalIo ( )

Legacy to allow easy use of the original ioDevice... functions, for new code use internalDigitalDevice and the Arduino like helpers.

See also
internalDigitalDevice()
Returns
the device abstraction for digital pins, on ESP32 this abstraction does not need Arduino present.

◆ ioDevicePinMode()

void ioDevicePinMode ( IoAbstractionRef  ioDev,
pinid_t  pin,
uint8_t  dir 
)
inline

Works in the same way as regular pinMode but this works for any IoAbstractionRef that you wish to set the pin mode on. Moving forward we recommend using the abstractions directly as per documentation.

Parameters
ioDevthe previously created IoAbstraction
thepin on the device to change mode
themode such as INPUT, OUTPUT, INPUT_PULLUP

◆ ioDeviceDigitalRead()

uint8_t ioDeviceDigitalRead ( IoAbstractionRef  ioDev,
pinid_t  pin 
)
inline

Works in the same way as digitalRead, but this works for any IoAbstractionRef, on the serial versions, the port is cached, so before calling this method you need to have called ioDeviceSync first. Moving forward we recommend using the abstractions directly as per documentation.

See also
ioDeviceDigitalReadS for a shortcut version that syncs first, but is less efficient if there are many reads
Parameters
ioDevthe previously created IoAbstraction
thepin on the device to read

◆ ioDeviceDigitalWrite()

void ioDeviceDigitalWrite ( IoAbstractionRef  ioDev,
pinid_t  pin,
uint8_t  val 
)
inline

Works in the same way as digitalWrite, but this works for any IoAbstractionRef, on the serial versions, the port is cached, so before calling this method, you need to have called IoDeviceSync first. Moving forward we recommend using the abstractions directly as per documentation.

See also
ioDeviceDigitalWriteS for a shortcut version that syncs after writing, but is less efficient with many writes.
Parameters
ioDevthe previously created IoAbstraction
pinthe pin to be updated
valthe new value for the pin, HIGH/LOW

◆ ioDeviceSync()

bool ioDeviceSync ( IoAbstractionRef  ioDev)
inline

On serial versions of this abstraction, this causes synchronization to both the read and write values, so the chip and this IoAbstraction are in sync. Moving forward we recommend using the abstractions directly as per documentation.

Parameters
ioDevthe IoAbstraction to be synchronised.

◆ ioDeviceAttachInterrupt()

void ioDeviceAttachInterrupt ( IoAbstractionRef  ioDev,
pinid_t  pin,
RawIntHandler  intHandler,
uint8_t  mode 
)
inline

Attach an interrupt to any IoAbstraction, 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, check the device datasheet and the particular abstraction you are using carefully, to ensure you get the expected result. Moving forward we recommend using the abstractions directly as per documentation.

Parameters
ioDevthe IoAbstraction to use
pinthe pin on this device to be used
intHandlera void function with no parameters, used to handle interrupts. THIS IS A RAW INTERRUPT AND NOT MARSHALLED
modestandard Arduino interrupt modes: CHANGE, RISING, FALLING

◆ ioDeviceDigitalReadS()

uint8_t ioDeviceDigitalReadS ( IoAbstractionRef  ioDev,
pinid_t  pin 
)
inline

Works in the same way as digitalRead, but this works for any IoAbstractionRef, unlike the non 'S' version this automatically calls ioDeviceSync first. Moving forward we recommend using the abstractions directly as per documentation.

See also
ioDeviceDigitalRead where you have more than one read / write to do at once, performs better in those cases.
Parameters
ioDevthe previously created IoAbstraction
thepin on the device to read

◆ ioDeviceDigitalWriteS()

bool ioDeviceDigitalWriteS ( IoAbstractionRef  ioDev,
pinid_t  pin,
uint8_t  val 
)
inline

Works in the same way as digitalWrite, but this works for any IoAbstractionRef, unlike the non 'S' version this automatically calls ioDeviceSync first. Moving forward we recommend using the abstractions directly as per documentation.

See also
ioDeviceDigitalWrite where you have more than one read / write to do at once, performs better in those cases.
Parameters
ioDevthe previously created IoAbstraction
pinthe pin to be updated
valthe new value for the pin, HIGH/LOW

◆ ioDeviceDigitalWritePortS()

bool ioDeviceDigitalWritePortS ( IoAbstractionRef  ioDev,
pinid_t  pinOnPort,
uint8_t  portVal 
)
inline

Write a whole 8 bit byte onto the port that the pin belongs to. For example if pin 42 where on PORTH then this would write to PORTH. For i2c and shift registers, it works the same, but the results are more predictable.

This version calls ioDeviceSync automatically after doing the write

Moving forward we recommend using the abstractions directly as per documentation.

Parameters
ioDevthe previously created IoAbstraction
pinOnPortany pin belonging to the port
valthe new value for the port

◆ ioDeviceDigitalReadPortS()

uint8_t ioDeviceDigitalReadPortS ( IoAbstractionRef  ioDev,
pinid_t  pinOnPort 
)
inline

Reads a whole 8 bit value back from the port with automatic sync before the operation. Specify the pin on the port that you wish to read. For example if pin 42 where on PORTH then this would write to PORTH. For i2c and shift registers, it works the same, but the results are more predictable.

This version calls ioDeviceSync automatically before doing the read. Moving forward we recommend using the abstractions directly as per documentation.

Parameters
ioDevthe previously created IoAbstraction
pinany pin belonging to the port to be read
Returns
the value of the port.

◆ ioDeviceDigitalWritePort()

void ioDeviceDigitalWritePort ( IoAbstractionRef  ioDev,
pinid_t  pinOnPort,
uint8_t  portVal 
)
inline

Write a whole 8 bit byte onto the port that the pin belongs to. For example if pin 42 where on PORTH then this would write to PORTH. For i2c and shift registers, it works the same, but the results are more predictable.

This version does not automatically sync, call the 'S' variant for that. Moving forward we recommend using the abstractions directly as per documentation.

Parameters
ioDevthe previously created IoAbstraction
pinOnPortany pin belonging to the port
valthe new value for the port

◆ ioDeviceDigitalReadPort()

uint8_t ioDeviceDigitalReadPort ( IoAbstractionRef  ioDev,
pinid_t  pinOnPort 
)
inline

Reads a whole 8 bit value back from the port with automatic sync before the operation. Specify the pin on the port that you wish to read. For example if pin 42 where on PORTH then this would write to PORTH. For i2c and shift registers, it works the same, but the results are more predictable.

This version does not automatically sync, call the 'S' variant for that. Moving forward we recommend using the abstractions directly as per documentation.

Parameters
ioDevthe previously created IoAbstraction
pinany pin belonging to the port to be read
Returns
the value of the port.