IoAbstraction
Classes | Typedefs | Enumerations | Functions
IoAbstraction.h File Reference

Using basic IoFacilities allows one to abstract away the use of IoExpanders, such that the switching from BasicIoFacilities to IoExpanderFacilities allows the same code to use an IoExpander instead of direct pins. More...

Go to the source code of this file.

Classes

struct  ShiftRegConfig
 
class  ShiftRegisterIoAbstraction
 
class  ShiftRegisterIoAbstraction165In
 
class  MultiIoAbstraction
 

Typedefs

typedef uint8_t(* ExpanderOpFn) (IoAbstractionRef ref, uint8_t pin, uint8_t val)
 
typedef MultiIoAbstractionMultiIoAbstractionRef
 

Enumerations

enum  ShiftBitOrder { MSBFIRST , LSBFIRST }
 

Functions

uint8_t shiftIn (pinid_t dataPin, pinid_t clockPin, ShiftBitOrder bitOrder)
 
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)
 
IoAbstractionRef inputOutputFromShiftRegister (uint8_t readClockPin, uint8_t readDataPin, uint8_t readLatchPin, uint8_t writeClockPin, uint8_t writeDataPin, uint8_t writeLatchPin)
 
IoAbstractionRef inputOnlyFromShiftRegister (uint8_t readClockPin, uint8_t dataPin, uint8_t latchPin, uint8_t numOfDevicesRead=1)
 
IoAbstractionRef outputOnlyFromShiftRegister (uint8_t writeClockPin, uint8_t writeDataPin, uint8_t writeLatchPin, uint8_t numOfDevicesWrite=1)
 
IoAbstractionRef inputFrom74HC165ShiftRegister (pinid_t readClkPin, pinid_t dataPin, pinid_t latchPin, pinid_t numOfDevices=1)
 
MultiIoAbstractionRef multiIoExpander (pinid_t arduinoPinRange)
 
void multiIoAddExpander (MultiIoAbstractionRef multiIo, IoAbstractionRef expander, pinid_t pinRange)
 

Detailed Description

Using basic IoFacilities allows one to abstract away the use of IoExpanders, such that the switching from BasicIoFacilities to IoExpanderFacilities allows the same code to use an IoExpander instead of direct pins.

Typedef Documentation

◆ MultiIoAbstractionRef

A reference specifically to a MultiIoAbstraction that can be passed to any of the ioDevice calls, but can also have more IO expanders added to it.

Function Documentation

◆ inputOutputFromShiftRegister() [1/2]

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 
)

performs both input and output functions using two or more shift registers, for both reading and writing. As shift registers have a fixed direction input and output are handled by different devices, and therefore fixed at the time of building the circuit. This function supports chaining of up to 4 devices for both directions.

This abstraction works as follows:

  • Input pins of the input shift register start at 0
  • Output pins of the output shift register start at 32.
Parameters
readClockPinthe clock pin on the INPUT shift register
readDataPinthe data pin on the INPUT shift register
readLatchPinthe latch pin on the INPUT shift register
numOfDevicesReadthe number of shift registers that have been chained for reading
writeClockPinthe clock pin on the OUTPUT shift register
writeDataPinthe data pin on the OUTPUT shift register
writeLatchPinthe latch pin on the OUTPUT shift register
numOfDevicesWritethe number of shift registers that have been chained for writing

◆ inputOutputFromShiftRegister() [2/2]

IoAbstractionRef inputOutputFromShiftRegister ( uint8_t  readClockPin,
uint8_t  readDataPin,
uint8_t  readLatchPin,
uint8_t  writeClockPin,
uint8_t  writeDataPin,
uint8_t  writeLatchPin 
)

performs both input and output functions using two shift registers, one for reading and one for writing. As shift registers have a fixed direction input and output are handled by different devices, and therefore fixed at the time of building the circuit. This function is for when you have a single input and single output device. See the other version of the function if you need to chain devices.

This abstraction works as follows:

  • Input pins of the input shift register start at 0
  • Output pins of the output shift register start at 32.
Parameters
readClockPinthe clock pin on the INPUT shift register
readDataPinthe data pin on the INPUT shift register
readLatchPinthe latch pin on the INPUT shift register
writeClockPinthe clock pin on the OUTPUT shift register
writeDataPinthe data pin on the OUTPUT shift register
writeLatchPinthe latch pin on the OUTPUT shift register

◆ inputOnlyFromShiftRegister()

IoAbstractionRef inputOnlyFromShiftRegister ( uint8_t  readClockPin,
uint8_t  dataPin,
uint8_t  latchPin,
uint8_t  numOfDevicesRead = 1 
)

performs input only functions using a shift register, the input pins of the shift register start at pin 0.

Parameters
readClockPinthe clock pin on the INPUT shift register
dataPinthe data pin on the INPUT shift register
latchPinthe latch pin on the INPUT shift register

◆ outputOnlyFromShiftRegister()

IoAbstractionRef outputOnlyFromShiftRegister ( uint8_t  writeClockPin,
uint8_t  writeDataPin,
uint8_t  writeLatchPin,
uint8_t  numOfDevicesWrite = 1 
)

performs output only functions using a shift register, the output pins of the shift register start at 32.

Parameters
writeClockPinthe clock pin on the OUTPUT shift register
writeDataPinthe data pin on the OUTPUT shift register
writeLatchPinthe latch pin on the OUTPUT shift register

◆ inputFrom74HC165ShiftRegister()

IoAbstractionRef inputFrom74HC165ShiftRegister ( pinid_t  readClkPin,
pinid_t  dataPin,
pinid_t  latchPin,
pinid_t  numOfDevices = 1 
)

Performs input only functions using a 74x165 plugin, the input pins start at 0 up to a maximum of 31, each device adds another 8 pins.

Parameters
readClkPinthe clock pin of the shift register, used as OUTPUT
dataPinthe data pin of the shift register, used as INPUT
latchPinthe latch pin of the shift register, used as OUTPUT
numOfDevicesthe number of devices that are chained together in the usual fashion, range is 1..4
Returns
a shift register abstraction as an IoAbstraction ref.

◆ multiIoExpander()

MultiIoAbstractionRef multiIoExpander ( pinid_t  arduinoPinRange)
inline

Create a multiIoExpander by adding together more than one IoAbstraction, for example Arduino pins plus a few 8574 devices.

Parameters
arduinoPinRangethe number of pins to assign to Arduino.

◆ multiIoAddExpander()

void multiIoAddExpander ( MultiIoAbstractionRef  multiIo,
IoAbstractionRef  expander,
pinid_t  pinRange 
)
inline

Add an additional expander to an existing multiIoExpander.

Parameters
expanderthe expander to be added
pinRangethe number of pins needed by the expander.