0.3.4 MCP23008

This commit is contained in:
Rob Tillaart 2024-07-06 11:16:32 +02:00
parent 86c72658c2
commit d2b5981264
6 changed files with 22 additions and 14 deletions

View File

@ -6,6 +6,9 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/). and this project adheres to [Semantic Versioning](http://semver.org/).
## [0.3.4] 2024-07-04
- Fix #21, documentation bug
## [0.3.3] 2024-05-25 ## [0.3.3] 2024-05-25
- add several interrupt functions (sync MCP23S17) - add several interrupt functions (sync MCP23S17)
- update **MCP23x08_registers.h** (reuse with MCP23008) - update **MCP23x08_registers.h** (reuse with MCP23008)

View File

@ -1,7 +1,7 @@
// //
// FILE: MCP23008.cpp // FILE: MCP23008.cpp
// AUTHOR: Rob Tillaart // AUTHOR: Rob Tillaart
// VERSION: 0.3.3 // VERSION: 0.3.4
// PURPOSE: Arduino library for I2C MCP23008 8 channel port expander // PURPOSE: Arduino library for I2C MCP23008 8 channel port expander
// DATE: 2019-10-12 // DATE: 2019-10-12
// URL: https://github.com/RobTillaart/MCP23008 // URL: https://github.com/RobTillaart/MCP23008
@ -63,6 +63,7 @@ uint8_t MCP23008::getAddress()
// //
// pin = 0..7 // pin = 0..7
// mode = INPUT, OUTPUT, INPUT_PULLUP (= same as INPUT) // mode = INPUT, OUTPUT, INPUT_PULLUP (= same as INPUT)
// do NOT use 0 or 1 for mode
bool MCP23008::pinMode1(uint8_t pin, uint8_t mode) bool MCP23008::pinMode1(uint8_t pin, uint8_t mode)
{ {
if (pin > 7) if (pin > 7)
@ -269,10 +270,11 @@ bool MCP23008::getPullup(uint8_t pin, bool &pullup)
// 8 pins interface // 8 pins interface
// //
// whole register at once // whole register at once
// value = 0..0xFF bit pattern // mask = 0x00..0xFF bit pattern
bool MCP23008::pinMode8(uint8_t value) // bit 0 = output mode, bit 1 = input mode
bool MCP23008::pinMode8(uint8_t mask)
{ {
writeReg(MCP23x08_DDR_A, value); writeReg(MCP23x08_DDR_A, mask);
_error = MCP23008_OK; _error = MCP23008_OK;
return true; return true;
} }

View File

@ -2,7 +2,7 @@
// //
// FILE: MCP23008.h // FILE: MCP23008.h
// AUTHOR: Rob Tillaart // AUTHOR: Rob Tillaart
// VERSION: 0.3.3 // VERSION: 0.3.4
// PURPOSE: Arduino library for I2C MCP23008 8 channel port expander // PURPOSE: Arduino library for I2C MCP23008 8 channel port expander
// DATE: 2022-01-10 // DATE: 2022-01-10
// URL: https://github.com/RobTillaart/MCP23008 // URL: https://github.com/RobTillaart/MCP23008
@ -13,7 +13,7 @@
#include "MCP23x08_registers.h" #include "MCP23x08_registers.h"
#define MCP23008_LIB_VERSION (F("0.3.3")) #define MCP23008_LIB_VERSION (F("0.3.4"))
#define MCP23008_OK 0x00 #define MCP23008_OK 0x00
#define MCP23008_PIN_ERROR 0x81 #define MCP23008_PIN_ERROR 0x81
@ -35,7 +35,8 @@ public:
// single pin interface // single pin interface
// mode: 0 = OUTPUT, 1 = INPUT, 1 = INPUT_PULLUP (==INPUT) // mode = INPUT, OUTPUT, INPUT_PULLUP (= same as INPUT)
// do not use 0, 1 for mode.
bool pinMode1(uint8_t pin, uint8_t mode); bool pinMode1(uint8_t pin, uint8_t mode);
bool write1(uint8_t pin, uint8_t value); bool write1(uint8_t pin, uint8_t value);
uint8_t read1(uint8_t pin); uint8_t read1(uint8_t pin);
@ -47,8 +48,10 @@ public:
// 8 pins interface // 8 pins interface
// value = bit pattern // mask = 0x00..0xFF bit pattern,
bool pinMode8(uint8_t value); // bit 0 = output mode, bit 1 = input mode
// value = bit pattern.
bool pinMode8(uint8_t mask);
bool write8(uint8_t value); bool write8(uint8_t value);
int read8(); int read8();

View File

@ -117,8 +117,8 @@ Returns false if not connected or a register could not be set.
### Single pin interface ### Single pin interface
- **bool pinMode1(uint8_t pin, uint8_t mode)** pin = 0..7, mode = INPUT, OUTPUT. - **bool pinMode1(uint8_t pin, uint8_t mode)** pin = 0..7, mode = INPUT, OUTPUT or INPUT_PULLUP.
0xFF is all pins are input, 0x1F are 5 inputs and 3 outputs. Do NOT use 0, 1 for mode as the 3 constants are (possibly) defined differently.
Returns true if successful. Returns true if successful.
- **bool write1(uint8_t pin, uint8_t value)** pin = 0..7, value = LOW(0) HIGH (!0). Returns true if successful. - **bool write1(uint8_t pin, uint8_t value)** pin = 0..7, value = LOW(0) HIGH (!0). Returns true if successful.
- **uint8_t read1(uint8_t pin)** pin = 0..7, returns LOW or HIGH, might set the lastError(); - **uint8_t read1(uint8_t pin)** pin = 0..7, returns LOW or HIGH, might set the lastError();
@ -130,7 +130,7 @@ Returns true if successful.
### 8 pins interface ### 8 pins interface
- **bool pinMode8(uint8_t value)** value = 0..255. Returns true if successful. - **bool pinMode8(uint8_t mask)** mask = 0..255. Returns true if successful.
- **bool write8(uint8_t value)** value = 0..255. Returns true if successful. - **bool write8(uint8_t value)** value = 0..255. Returns true if successful.
- **uint8_t read8()** reads 8 pins into one byte. - **uint8_t read8()** reads 8 pins into one byte.
- **bool setPolarity8(uint8_t mask)** sets polarity for 8 channels at once. Returns true if successful. - **bool setPolarity8(uint8_t mask)** sets polarity for 8 channels at once. Returns true if successful.

View File

@ -15,7 +15,7 @@
"type": "git", "type": "git",
"url": "https://github.com/RobTillaart/MCP23008.git" "url": "https://github.com/RobTillaart/MCP23008.git"
}, },
"version": "0.3.3", "version": "0.3.4",
"license": "MIT", "license": "MIT",
"frameworks": "*", "frameworks": "*",
"platforms": "*", "platforms": "*",

View File

@ -1,5 +1,5 @@
name=MCP23008 name=MCP23008
version=0.3.3 version=0.3.4
author=Rob Tillaart <rob.tillaart@gmail.com> author=Rob Tillaart <rob.tillaart@gmail.com>
maintainer=Rob Tillaart <rob.tillaart@gmail.com> maintainer=Rob Tillaart <rob.tillaart@gmail.com>
sentence=Arduino library for I2C MCP23008 8 channel port expander 8 IO-lines sentence=Arduino library for I2C MCP23008 8 channel port expander 8 IO-lines