mirror of
https://github.com/RobTillaart/Arduino.git
synced 2024-09-19 16:46:11 -04:00
0.7.1 MCP23017_RT
This commit is contained in:
parent
9e38675e8a
commit
86c72658c2
@ -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.7.1] 2024-06-06
|
||||||
|
- Fix #36, documentation bug.
|
||||||
|
|
||||||
## [0.7.0] 2024-06-06
|
## [0.7.0] 2024-06-06
|
||||||
- fix #33 bug, kudos to JelleWilbrink
|
- fix #33 bug, kudos to JelleWilbrink
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
//
|
//
|
||||||
// FILE: MCP23017.cpp
|
// FILE: MCP23017.cpp
|
||||||
// AUTHOR: Rob Tillaart
|
// AUTHOR: Rob Tillaart
|
||||||
// VERSION: 0.7.0
|
// VERSION: 0.7.1
|
||||||
// PURPOSE: Arduino library for I2C MCP23017 16 channel port expander
|
// PURPOSE: Arduino library for I2C MCP23017 16 channel port expander
|
||||||
// DATE: 2019-10-12
|
// DATE: 2019-10-12
|
||||||
// URL: https://github.com/RobTillaart/MCP23017_RT
|
// URL: https://github.com/RobTillaart/MCP23017_RT
|
||||||
@ -66,6 +66,7 @@ uint8_t MCP23017::getAddress()
|
|||||||
//
|
//
|
||||||
// pin = 0..15
|
// pin = 0..15
|
||||||
// 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 MCP23017::pinMode1(uint8_t pin, uint8_t mode)
|
bool MCP23017::pinMode1(uint8_t pin, uint8_t mode)
|
||||||
{
|
{
|
||||||
if (pin > 15)
|
if (pin > 15)
|
||||||
@ -310,16 +311,17 @@ bool MCP23017::getPullup(uint8_t pin, bool &pullup)
|
|||||||
//
|
//
|
||||||
// whole register at once
|
// whole register at once
|
||||||
// port = 0..1
|
// port = 0..1
|
||||||
// value = 0..0xFF bit pattern
|
// mask = 0x00..0xFF bit pattern
|
||||||
bool MCP23017::pinMode8(uint8_t port, uint8_t value)
|
// bit 0 = output mode, bit 1 = input mode
|
||||||
|
bool MCP23017::pinMode8(uint8_t port, uint8_t mask)
|
||||||
{
|
{
|
||||||
if (port > 1)
|
if (port > 1)
|
||||||
{
|
{
|
||||||
_error = MCP23017_PORT_ERROR;
|
_error = MCP23017_PORT_ERROR;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (port == 0) writeReg(MCP23x17_DDR_A, value);
|
if (port == 0) writeReg(MCP23x17_DDR_A, mask);
|
||||||
if (port == 1) writeReg(MCP23x17_DDR_B, value);
|
if (port == 1) writeReg(MCP23x17_DDR_B, mask);
|
||||||
_error = MCP23017_OK;
|
_error = MCP23017_OK;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -429,11 +431,12 @@ bool MCP23017::getPullup8(uint8_t port, uint8_t &mask)
|
|||||||
//
|
//
|
||||||
// 16 pins interface
|
// 16 pins interface
|
||||||
//
|
//
|
||||||
// two register at once
|
// two registers at once
|
||||||
// value = 0x0000..0xFFFF bit pattern
|
// mask = 0x0000..0xFFFF bit pattern
|
||||||
bool MCP23017::pinMode16(uint16_t value)
|
// bit 0 = output mode, bit 1 = input mode
|
||||||
|
bool MCP23017::pinMode16(uint16_t mask)
|
||||||
{
|
{
|
||||||
writeReg16(MCP23x17_DDR_A, value);
|
writeReg16(MCP23x17_DDR_A, mask);
|
||||||
_error = MCP23017_OK;
|
_error = MCP23017_OK;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
//
|
//
|
||||||
// FILE: MCP23017.h
|
// FILE: MCP23017.h
|
||||||
// AUTHOR: Rob Tillaart
|
// AUTHOR: Rob Tillaart
|
||||||
// VERSION: 0.7.0
|
// VERSION: 0.7.1
|
||||||
// PURPOSE: Arduino library for I2C MCP23017 16 channel port expander
|
// PURPOSE: Arduino library for I2C MCP23017 16 channel port expander
|
||||||
// DATE: 2019-10-12
|
// DATE: 2019-10-12
|
||||||
// URL: https://github.com/RobTillaart/MCP23017_RT
|
// URL: https://github.com/RobTillaart/MCP23017_RT
|
||||||
@ -15,7 +15,7 @@
|
|||||||
#include "MCP23x17_registers.h"
|
#include "MCP23x17_registers.h"
|
||||||
|
|
||||||
|
|
||||||
#define MCP23017_LIB_VERSION (F("0.7.0"))
|
#define MCP23017_LIB_VERSION (F("0.7.1"))
|
||||||
|
|
||||||
#define MCP23017_OK 0x00
|
#define MCP23017_OK 0x00
|
||||||
#define MCP23017_PIN_ERROR 0x81
|
#define MCP23017_PIN_ERROR 0x81
|
||||||
@ -37,7 +37,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);
|
||||||
@ -50,8 +51,10 @@ public:
|
|||||||
|
|
||||||
// 8 pins interface
|
// 8 pins interface
|
||||||
// port = 0..1
|
// port = 0..1
|
||||||
// value = bit pattern
|
// mask = 0x00..0xFF bit pattern,
|
||||||
bool pinMode8(uint8_t port, uint8_t value);
|
// bit 0 = output mode, bit 1 = input mode
|
||||||
|
// value = bit pattern.
|
||||||
|
bool pinMode8(uint8_t port, uint8_t mask);
|
||||||
bool write8(uint8_t port, uint8_t value);
|
bool write8(uint8_t port, uint8_t value);
|
||||||
int read8(uint8_t port);
|
int read8(uint8_t port);
|
||||||
|
|
||||||
@ -62,8 +65,10 @@ public:
|
|||||||
|
|
||||||
|
|
||||||
// 16 pins interface
|
// 16 pins interface
|
||||||
// value = bit pattern
|
// mask = 0x0000..0xFFFF bit pattern
|
||||||
bool pinMode16(uint16_t value);
|
// bit 0 = output mode, bit 1 = input mode
|
||||||
|
// value = bit pattern.
|
||||||
|
bool pinMode16(uint16_t mask);
|
||||||
bool write16(uint16_t value);
|
bool write16(uint16_t value);
|
||||||
uint16_t read16();
|
uint16_t read16();
|
||||||
|
|
||||||
|
@ -144,7 +144,9 @@ Returns false if not connected or a register could not be set.
|
|||||||
|
|
||||||
Please note REVD remarks at top.
|
Please note REVD remarks at top.
|
||||||
|
|
||||||
- **bool pinMode1(uint8_t pin, uint8_t mode)** pin = 0..15, mode = INPUT, OUTPUT. Returns true if successful.
|
- **bool pinMode1(uint8_t pin, uint8_t mode)** pin = 0..15, mode = INPUT, OUTPUT or INPUT_PULLUP.
|
||||||
|
Do NOT use 0, 1 for mode as the 3 constants are (possibly) defined differently.
|
||||||
|
Returns true if successful.
|
||||||
- **bool write1(uint8_t pin, uint8_t value)** pin = 0..15, value = LOW(0) HIGH (!0). Returns true if successful.
|
- **bool write1(uint8_t pin, uint8_t value)** pin = 0..15, value = LOW(0) HIGH (!0). Returns true if successful.
|
||||||
- **uint8_t read1(uint8_t pin)** pin = 0..15, returns LOW or HIGH, might set the lastError();
|
- **uint8_t read1(uint8_t pin)** pin = 0..15, returns LOW or HIGH, might set the lastError();
|
||||||
- **bool setPolarity(uint8_t pin, bool reversed)** pin = 0..15, set reversed flag. Returns true if successful.
|
- **bool setPolarity(uint8_t pin, bool reversed)** pin = 0..15, set reversed flag. Returns true if successful.
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/RobTillaart/MCP23017_RT.git"
|
"url": "https://github.com/RobTillaart/MCP23017_RT.git"
|
||||||
},
|
},
|
||||||
"version": "0.7.0",
|
"version": "0.7.1",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"frameworks": "*",
|
"frameworks": "*",
|
||||||
"platforms": "*",
|
"platforms": "*",
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
name=MCP23017_RT
|
name=MCP23017_RT
|
||||||
version=0.7.0
|
version=0.7.1
|
||||||
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 MCP23017 16 channel port expander 16 IO-lines
|
sentence=Arduino library for I2C MCP23017 16 channel port expander 16 IO-lines
|
||||||
|
Loading…
Reference in New Issue
Block a user