0.4.1 MCP23017_RT

This commit is contained in:
Rob Tillaart 2023-09-23 16:25:55 +02:00
parent 6fa7133f4b
commit df7b17f1d8
8 changed files with 118 additions and 39 deletions

View File

@ -6,6 +6,13 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).
## [0.4.1] 2023-09-23
- add Wire1 support for ESP32
- update readme.md
- add CMakeLists.txt - See #8 mcp23008
- fix keywords.txt
## [0.4.0] - 2023-02-04
- breaking REV D chips => new release
- no change in code compared to 0.3.3

View File

@ -0,0 +1,10 @@
# Allows for use with ESP-IDF and Arduino as component
# Tested with ESP-IDF v4.4.4
cmake_minimum_required(VERSION 3.5)
idf_component_register(SRCS "MCP23017.cpp"
INCLUDE_DIRS "."
REQUIRES arduino)
project(MCP23017)

View File

@ -1,12 +1,11 @@
//
// FILE: MCP23017.cpp
// AUTHOR: Rob Tillaart
// VERSION: 0.4.0
// VERSION: 0.4.1
// PURPOSE: Arduino library for I2C MCP23017 16 channel port expander
// DATE: 2019-10-12
// URL: https://github.com/RobTillaart/MCP23017_RT
//
// WARNING: please read REV D note in readme.md.
@ -49,7 +48,6 @@ MCP23017::MCP23017(uint8_t address, TwoWire *wire)
#if defined(ESP8266) || defined(ESP32)
bool MCP23017::begin(const uint8_t dataPin, const uint8_t clockPin)
{
_wire = &Wire;
_wire->begin(dataPin, clockPin);
// check connected
if (! isConnected()) return false;
@ -335,7 +333,7 @@ bool MCP23017::getPullup(uint8_t pin, bool &pullup)
// 8 pins interface
// whole register at once
// port = 0..1
// value = 0..0xFF bit pattern
// value = 0..0xFF bit pattern
bool MCP23017::pinMode8(uint8_t port, uint8_t value)
{
if (port > 1)
@ -589,5 +587,5 @@ uint8_t MCP23017::readReg(uint8_t reg)
}
// -- END OF FILE --
// -- END OF FILE --

View File

@ -2,12 +2,11 @@
//
// FILE: MCP23017.h
// AUTHOR: Rob Tillaart
// VERSION: 0.4.0
// VERSION: 0.4.1
// PURPOSE: Arduino library for I2C MCP23017 16 channel port expander
// DATE: 2019-10-12
// URL: https://github.com/RobTillaart/MCP23017_RT
//
// WARNING: please read REV D note in readme.md.
@ -15,7 +14,7 @@
#include "Wire.h"
#define MCP23017_LIB_VERSION (F("0.4.0"))
#define MCP23017_LIB_VERSION (F("0.4.1"))
#define MCP23017_OK 0x00
#define MCP23017_PIN_ERROR 0x81
@ -33,35 +32,35 @@ public:
MCP23017(uint8_t address, TwoWire *wire = &Wire);
#if defined(ESP8266) || defined(ESP32)
bool begin(const uint8_t dataPin, const uint8_t clockPin);
bool begin(const uint8_t dataPin, const uint8_t clockPin);
#endif
bool begin();
bool isConnected();
bool begin();
bool isConnected();
// single pin interface
// mode = INPUT, OUTPUT or INPUT_PULLUP (==INPUT)
bool pinMode(uint8_t pin, uint8_t mode);
bool digitalWrite(uint8_t pin, uint8_t value);
uint8_t digitalRead(uint8_t pin);
// single pin interface
// mode = INPUT, OUTPUT or INPUT_PULLUP (==INPUT)
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, bool reversed);
bool getPolarity(uint8_t pin, bool &reversed);
bool setPullup(uint8_t pin, bool pullup);
bool getPullup(uint8_t pin, bool &pullup);
bool setPolarity(uint8_t pin, bool reversed);
bool getPolarity(uint8_t pin, bool &reversed);
bool setPullup(uint8_t pin, bool pullup);
bool getPullup(uint8_t pin, bool &pullup);
// 8 pins interface
// port = 0..1
// value = bit pattern
bool pinMode8(uint8_t port, uint8_t value);
bool write8(uint8_t port, uint8_t value);
int read8(uint8_t port);
// 8 pins interface
// port = 0..1
// value = bit pattern
bool pinMode8(uint8_t port, uint8_t value);
bool write8(uint8_t port, uint8_t value);
int read8(uint8_t port);
bool setPolarity8(uint8_t port, uint8_t mask);
bool getPolarity8(uint8_t port, uint8_t &mask);
bool setPullup8(uint8_t port, uint8_t mask);
bool getPullup8(uint8_t port, uint8_t &mask);
bool setPolarity8(uint8_t port, uint8_t mask);
bool getPolarity8(uint8_t port, uint8_t &mask);
bool setPullup8(uint8_t port, uint8_t mask);
bool getPullup8(uint8_t port, uint8_t &mask);
// 16 pins interface
@ -78,8 +77,8 @@ public:
int lastError();
private:
bool writeReg(uint8_t reg, uint8_t value);
uint8_t readReg(uint8_t reg);
bool writeReg(uint8_t reg, uint8_t value);
uint8_t readReg(uint8_t reg);
uint8_t _address;
TwoWire* _wire;
@ -87,5 +86,5 @@ private:
};
// -- END OF FILE --
// -- END OF FILE --

View File

@ -2,8 +2,11 @@
[![Arduino CI](https://github.com/RobTillaart/MCP23017_RT/workflows/Arduino%20CI/badge.svg)](https://github.com/marketplace/actions/arduino_ci)
[![Arduino-lint](https://github.com/RobTillaart/MCP23017_RT/actions/workflows/arduino-lint.yml/badge.svg)](https://github.com/RobTillaart/MCP23017_RT/actions/workflows/arduino-lint.yml)
[![JSON check](https://github.com/RobTillaart/MCP23017_RT/actions/workflows/jsoncheck.yml/badge.svg)](https://github.com/RobTillaart/MCP23017_RT/actions/workflows/jsoncheck.yml)
[![GitHub issues](https://img.shields.io/github/issues/RobTillaart/MCP23017_RT.svg)](https://github.com/RobTillaart/MCP23017_RT/issues)
[![License: MIT](https://img.shields.io/badge/license-MIT-green.svg)](https://github.com/RobTillaart/MCP23017_RT/blob/master/LICENSE)
[![GitHub release](https://img.shields.io/github/release/RobTillaart/MCP23017_RT.svg?maxAge=3600)](https://github.com/RobTillaart/MCP23017_RT/releases)
[![PlatformIO Registry](https://badges.registry.platformio.org/packages/robtillaart/library/MCP23017_RT.svg)](https://registry.platformio.org/libraries/robtillaart/MCP23017_RT)
# MCP23017_RT
@ -21,7 +24,7 @@ Programming Interface is kept the same as much as possible.
Since 0.3.1 the **digitalWrite(pin, value)** is optimized.
If a pin is not changed it will not be written again to save time.
#### REV D - june 2022
#### REV D - June 2022
The I2C IO expander MCP23017 has changed according to the new data sheet. It is now a 14/16-bit IO expander.
The pins GPA7 and GPB7 have lost their input mode, output mode still works.
@ -141,6 +144,7 @@ Reading it will reset the flag to **MCP23017_OK**.
- extend error codes
- optimize code - squeeze footprint
- investigate if REV D chips can be detected.
- add keywords.txt
#### Could
@ -151,3 +155,12 @@ Reading it will reset the flag to **MCP23017_OK**.
#### Wont
## Support
If you appreciate my libraries, you can support the development and maintenance.
Improve the quality of the libraries by providing issues and Pull Requests, or
donate through PayPal or GitHub sponsors.
Thank you,

View File

@ -0,0 +1,52 @@
# Syntax Colouring Map For MCP23017
# Data types (KEYWORD1)
MCP23017 KEYWORD1
# Methods and Functions (KEYWORD2)
begin KEYWORD2
isConnected KEYWORD2
pinMode KEYWORD2
digitalWrite KEYWORD2
digitalRead KEYWORD2
setPolarity KEYWORD2
getPolarity KEYWORD2
setPullup KEYWORD2
getPullup KEYWORD2
pinMode8 KEYWORD2
write8 KEYWORD2
read8 KEYWORD2
setPolarity8 KEYWORD2
getPolarity8 KEYWORD2
setPullup8 KEYWORD2
getPullup8 KEYWORD2
pinMode16 KEYWORD2
write16 KEYWORD2
read16 KEYWORD2
setPolarity16 KEYWORD2
getPolarity16 KEYWORD2
setPullup16 KEYWORD2
getPullup16 KEYWORD2
lastError KEYWORD2
# Instances (KEYWORD2)
# Constants (LITERAL1)
MCP23017_LIB_VERSION LITERAL1
MCP23017_OK LITERAL1
MCP23017_PIN_ERROR LITERAL1
MCP23017_I2C_ERROR LITERAL1
MCP23017_VALUE_ERROR LITERAL1
MCP23017_PORT_ERROR LITERAL1

View File

@ -15,9 +15,9 @@
"type": "git",
"url": "https://github.com/RobTillaart/MCP23017_RT.git"
},
"version": "0.4.0",
"version": "0.4.1",
"license": "MIT",
"frameworks": "arduino",
"frameworks": "*",
"platforms": "*",
"headers": "MCP23017.h"
}

View File

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