LOGGER  Logger
Data Logging using ESP8266
Classes | Macros | Functions
tca9539.cpp File Reference
#include <arduino.h>
#include <ESP8266WiFi.h>
#include "tca9539.h"
#include "huzzahpins.h"
#include "i2cservices.h"
#include "pincounter.h"
#include "sensorlibrary.h"

Classes

union  IoExpanderStatus_t
 
struct  IOpinsDevice_t
 

Macros

#define tca9539Edit   1
 version of this module
 
#define TCA_BASE_ADDRESS   0
 Address to read the pair of input bytes from. More...
 
#define TCA_INPUT_ADDRESS   (TCA_BASE_ADDRESS)
 Input byte pair.
 
#define TCA_DESIRED_OUTPUT_ADDRESS   (TCA_BASE_ADDRESS+2)
 output byte pair
 
#define TCA_INVERSION_ADDRESS   (TCA_BASE_ADDRESS+4)
 inversion byte pair
 
#define TCA_CONFIGURATION_ADDRESS   (TCA_BASE_ADDRESS+6)
 on when input byte pair
 

Functions

EXTERNDEF void tca9539init ()
 < version of this include file More...
 
EXTERNDEF uint32_t tca9539readPin (uint8_t *pUniqueID, uint8_t pinNumber)
 
EXTERNDEF int32_t tca9539getDesiredOutputs (uint8_t address)
 
EXTERNDEF bool tca9539setDesiredOutputs (uint8_t address, uint16_t value)
 
EXTERNDEF int32_t tca9539getConfiguration (uint8_t address)
 
EXTERNDEF bool tca9539setConfiguration (uint8_t address, uint16_t value)
 
EXTERNDEF bool tca9539dumpState (Print *pPrinter, uint8_t address)
 
EXTERNDEF void tca9539emitConfiguror (Print *pPrint, uint8_t pinIndex, bool setIOconfig, bool ioIsOutput, bool ioIsOn)
 
EXTERNDEF void tca9539checkPinChanges ()
 

Detailed Description

Support for the TCA9539 I/O expander part. The I/O registers for this part are the same as the PCA9535.

Macro Definition Documentation

#define TCA_BASE_ADDRESS   0

Address to read the pair of input bytes from.

Base address of all part registers

Function Documentation

EXTERNDEF void tca9539checkPinChanges ( )

Check pin changes. Call this when changes in sensors have been detected. This may be called when no changes in pin state have occured.

NOTE: knowlege that address 0x77 pins 16 and 17 are pulse counting pins is buried inside this module.

EXTERNDEF bool tca9539dumpState ( Print *  pPrinter,
uint8_t  address 
)

print the current state of a device

Parameters
pPrinterwhere to send the output
addressI2C address of the device to print
Returns
true if the device is found false otherwise
EXTERNDEF void tca9539emitConfiguror ( Print *  pPrint,
uint8_t  pinIndex,
bool  setIOconfig,
bool  ioIsOutput,
bool  ioIsOn 
)

Emit the display and configuration for a TCA pin.

Parameters
pPrintwhere to print the selector
pinIndexcurrent selected data type as an integer
setIOconfigtrue to set the IO configuration or pin state
ioIsOutputtrue if pin is an output
ioIsOntrue if intended value is on
EXTERNDEF int32_t tca9539getConfiguration ( uint8_t  address)

Get the current device pin configuration. The data is read from a data structure and reported. A one in any bit position indicates that the bit is configured as an input.

Parameters
addressI2C address of the device to read
Returns
-1 if the device is not found otherwise the pin configuration for the device
EXTERNDEF int32_t tca9539getDesiredOutputs ( uint8_t  address)

Get the current device desired output state. The data is read from a data structure and reported.

Parameters
addressI2C address of the device to read
Returns
-1 if the device is not found otherwise the desired output state
EXTERNDEF void tca9539init ( )

< version of this include file

Initialize I/O expander devices. Find the devices and put them into the list of devices.

EXTERNDEF uint32_t tca9539readPin ( uint8_t *  pUniqueID,
uint8_t  pinNumber 
)

Read a pin of the tca9539 part.

The uniqueID is an 8 byte array. The first bytes are the MAC address of this processor. The last byte is the I2C address for the specific part to read.

Pin number 0 is the lowest order bit. Pin number 15 is the highest order bit.

Parameters
pUniqueIDID of the part to read
pinNumberpin number to read
EXTERNDEF bool tca9539setConfiguration ( uint8_t  address,
uint16_t  value 
)

Set the configuration of all pins. The configuration is logged in a data structure and is also sent to the device. A one in any bit position indicated that the pin is an input.

Parameters
addressI2C address of the device to update
valueNew value for the pin configuration
Returns
true if the device is found and updated false otherwise
EXTERNDEF bool tca9539setDesiredOutputs ( uint8_t  address,
uint16_t  value 
)

Set the desired state of all output pins. The state is logged in a data structure and is also sent to the device.

Parameters
addressI2C address of the device to update
valuenew value for the desired outputs state
Returns
true if the device is found and updated false otherwise