0.1.3 TCA9555

This commit is contained in:
rob tillaart 2022-11-26 13:08:45 +01:00
parent d0045e9601
commit 5151d1c712
6 changed files with 65 additions and 40 deletions

View File

@ -0,0 +1,27 @@
# Change Log TCA9555
All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).
## [0.1.3] - 2022-11-25
- Add RP2040 support to build-CI.
- Add CHANGELOG.md
- update readme.md
## [0.1.2] - 2021-12-28
- update Arduino-CI
- update readme.md
- update license
- minor edits
## [0.1.1] - 2021-06-10
- add 16 bit interface
## [0.1.0] - 2021-06-09
- initial version

View File

@ -107,14 +107,17 @@ See examples
#### Must
- buy TCA9555 / TCA9535
- test all functionality (initial version is written with no hardware around)
- add TCA9535 error codes
#### Should
- INPUT_PULLUP mappen op INPUT (pinMode ?)
- investigate internal pull up etc.
- add TCA9535 error codes
- investigate TCA9535 differences
- elaborate derived class
#### Could
- rethink class hierarchy
- buy TCA9555 / TCA9535
- rethink class hierarchy?
- investigate internal pull up etc.

View File

@ -1,28 +1,23 @@
//
// FILE: TCA9555.cpp
// AUTHOR: Rob Tillaart
// VERSION: 0.1.2
// VERSION: 0.1.3
// PURPOSE: Arduino library for I2C TCA9555 16 channel port expander
// DATE: 2021-06-09
// URL: https://github.com/RobTillaart/TCA9555
//
// HISTORY:
// 0.1.0 2021-06-09 initial version
// 0.1.1 2021-06-10 add 16 bit interface
// 0.1.2 2021-12-28 update Arduino-CI, readme, license, minor edits
#include "TCA9555.h"
// REGISTERS
#define TCA9555_INPUT_PORT_REGISTER_0 0x00 // read()
// REGISTERS
#define TCA9555_INPUT_PORT_REGISTER_0 0x00 // read()
#define TCA9555_INPUT_PORT_REGISTER_1 0x01
#define TCA9555_OUTPUT_PORT_REGISTER_0 0x02 // write()
#define TCA9555_OUTPUT_PORT_REGISTER_0 0x02 // write()
#define TCA9555_OUTPUT_PORT_REGISTER_1 0x03
#define TCA9555_POLARITY_REGISTER_0 0x04 // get/setPolarity
#define TCA9555_POLARITY_REGISTER_0 0x04 // get/setPolarity
#define TCA9555_POLARITY_REGISTER_1 0x05
#define TCA9555_CONFIGURATION_PORT_0 0x06 // pinMode
#define TCA9555_CONFIGURATION_PORT_0 0x06 // pinMode
#define TCA9555_CONFIGURATION_PORT_1 0x07
@ -62,9 +57,9 @@ bool TCA9555::isConnected()
//////////////////////////////////////////////////////////
//
// 1 PIN INTERFACE
// 1 PIN INTERFACE
//
bool TCA9555::pinMode(uint8_t pin, uint8_t mode)
bool TCA9555::pinMode(uint8_t pin, uint8_t mode) // pin = 0..15
{
if (pin > 15)
{
@ -92,7 +87,7 @@ bool TCA9555::pinMode(uint8_t pin, uint8_t mode)
}
bool TCA9555::digitalWrite(uint8_t pin, uint8_t value) // pin = 0..15
bool TCA9555::digitalWrite(uint8_t pin, uint8_t value) // pin = 0..15
{
if (pin > 15)
{
@ -115,7 +110,7 @@ bool TCA9555::digitalWrite(uint8_t pin, uint8_t value) // pin = 0..15
}
uint8_t TCA9555::digitalRead(uint8_t pin)
uint8_t TCA9555::digitalRead(uint8_t pin) // pin = 0..15
{
if (pin > 15)
{
@ -136,7 +131,7 @@ uint8_t TCA9555::digitalRead(uint8_t pin)
}
bool TCA9555::setPolarity(uint8_t pin, uint8_t value) // pin = 0..15
bool TCA9555::setPolarity(uint8_t pin, uint8_t value) // pin = 0..15
{
if (pin > 15)
{
@ -177,7 +172,7 @@ uint8_t TCA9555::getPolarity(uint8_t pin)
//////////////////////////////////////////////////////////
//
// 8 PIN INTERFACE
// 8 PIN INTERFACE
//
bool TCA9555::pinMode8(uint8_t port, uint8_t mask)
{
@ -193,7 +188,7 @@ bool TCA9555::pinMode8(uint8_t port, uint8_t mask)
}
bool TCA9555::write8(uint8_t port, uint8_t mask) // port = 0..1
bool TCA9555::write8(uint8_t port, uint8_t mask) // port = 0..1
{
if (port > 1)
{
@ -240,12 +235,12 @@ uint8_t TCA9555::getPolarity8(uint8_t port)
if (port > 1)
{
_error = TCA9555_PORT_ERROR;
return false;
return 0;
}
_error = TCA9555_OK;
if (port == 0) return readRegister(TCA9555_POLARITY_REGISTER_0);
if (port == 1) return readRegister(TCA9555_POLARITY_REGISTER_1);
return 0; // keeps compiler happy
return 0; // keeps compiler happy
}
@ -291,7 +286,7 @@ bool TCA9555::setPolarity16(uint16_t mask)
uint8_t TCA9555::getPolarity16()
{
uint16_t rv = 0;
uint16_t rv = 0;
rv |= (getPolarity8(1) << 8);
rv |= getPolarity8(0);
return rv;
@ -300,15 +295,15 @@ uint8_t TCA9555::getPolarity16()
int TCA9555::lastError()
{
int e = _error;
_error = TCA9555_OK; // reset error after read.
return e;
int error = _error;
_error = TCA9555_OK; // reset error after read.
return error;
}
////////////////////////////////////////////////////
//
// PRIVATE
// PRIVATE
//
bool TCA9555::writeRegister(uint8_t reg, uint8_t value)
{
@ -346,7 +341,7 @@ uint8_t TCA9555::readRegister(uint8_t reg)
/////////////////////////////////////////////////////////////////////////////
//
// TCA9535
// TCA9535
//
TCA9535::TCA9535(uint8_t address, TwoWire *wire)
:TCA9555(address, wire)

View File

@ -2,7 +2,7 @@
//
// FILE: TCA9555.h
// AUTHOR: Rob Tillaart
// VERSION: 0.1.2
// VERSION: 0.1.3
// PURPOSE: Arduino library for I2C TCA9555 16 channel port expander
// DATE: 2021-06-09
// URL: https://github.com/RobTillaart/TCA9555
@ -12,7 +12,7 @@
#include "Wire.h"
#define TCA9555_LIB_VERSION (F("0.1.2"))
#define TCA9555_LIB_VERSION (F("0.1.3"))
#define TCA9555_OK 0x00
#define TCA9555_PIN_ERROR 0x81
@ -43,7 +43,7 @@ public:
bool pinMode(uint8_t pin, uint8_t mode);
bool digitalWrite(uint8_t pin, uint8_t value);
uint8_t digitalRead(uint8_t pin);
bool setPolarity(uint8_t pin, uint8_t value); // input pins only.
bool setPolarity(uint8_t pin, uint8_t value); // input pins only.
uint8_t getPolarity(uint8_t pin);
@ -75,15 +75,15 @@ protected:
bool writeRegister(uint8_t reg, uint8_t value);
uint8_t readRegister(uint8_t reg);
uint8_t _address;
TwoWire* _wire;
uint8_t _error;
uint8_t _address;
TwoWire* _wire;
uint8_t _error;
};
/////////////////////////////////////////////////////////////////////////////
//
// TCA9535 class which is just a wrapper (for now)
// TCA9535 class which is just a wrapper (for now)
//
class TCA9535 : public TCA9555
{

View File

@ -15,7 +15,7 @@
"type": "git",
"url": "https://github.com/RobTillaart/TCA9555.git"
},
"version": "0.1.2",
"version": "0.1.3",
"license": "MIT",
"frameworks": "arduino",
"platforms": "*",

View File

@ -1,5 +1,5 @@
name=TCA9555
version=0.1.2
version=0.1.3
author=Rob Tillaart <rob.tillaart@gmail.com>
maintainer=Rob Tillaart <rob.tillaart@gmail.com>
sentence=Arduino library for I2C TCA9555 16 channel port expander - 16 IO-lines