mirror of
https://github.com/RobTillaart/Arduino.git
synced 2024-10-03 18:09:02 -04:00
0.5.4 MCP23S17
This commit is contained in:
parent
d0056c7e5f
commit
9e38675e8a
@ -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/).
|
||||
|
||||
|
||||
## [0.5.4] - 2024-07-04
|
||||
- fix #45, documentation bug
|
||||
|
||||
## [0.5.3] - 2024-06-12
|
||||
- #43 optimize read/write16, kudos to Olkal
|
||||
- add performance test output 0.5.2, 0.5.3
|
||||
|
@ -1,7 +1,7 @@
|
||||
//
|
||||
// FILE: MCP23S17.cpp
|
||||
// AUTHOR: Rob Tillaart
|
||||
// VERSION: 0.5.3
|
||||
// VERSION: 0.5.4
|
||||
// PURPOSE: Arduino library for SPI MCP23S17 16 channel port expander
|
||||
// DATE: 2021-12-30
|
||||
// URL: https://github.com/RobTillaart/MCP23S17
|
||||
@ -107,6 +107,7 @@ uint8_t MCP23S17::getAddress()
|
||||
//
|
||||
// pin = 0..15
|
||||
// mode = INPUT, OUTPUT, INPUT_PULLUP (= same as INPUT)
|
||||
// do NOT use 0 or 1 for mode.
|
||||
bool MCP23S17::pinMode1(uint8_t pin, uint8_t mode)
|
||||
{
|
||||
if (pin > 15)
|
||||
@ -357,17 +358,18 @@ void MCP23S17::setSPIspeed(uint32_t speed)
|
||||
// 8 pins interface
|
||||
//
|
||||
// whole register at once
|
||||
// port = 0..1
|
||||
// value = 0..0xFF bit pattern
|
||||
bool MCP23S17::pinMode8(uint8_t port, uint8_t value)
|
||||
// port = 0..1
|
||||
// mask = 0x00..0xFF bit pattern
|
||||
// bit 0 = output mode, bit 1 = input mode
|
||||
bool MCP23S17::pinMode8(uint8_t port, uint8_t mask)
|
||||
{
|
||||
if (port > 1)
|
||||
{
|
||||
_error = MCP23S17_PORT_ERROR;
|
||||
return false;
|
||||
}
|
||||
if (port == 0) writeReg(MCP23x17_DDR_A, value);
|
||||
if (port == 1) writeReg(MCP23x17_DDR_B, value);
|
||||
if (port == 0) writeReg(MCP23x17_DDR_A, mask);
|
||||
if (port == 1) writeReg(MCP23x17_DDR_B, mask);
|
||||
_error = MCP23S17_OK;
|
||||
return true;
|
||||
}
|
||||
@ -477,11 +479,12 @@ bool MCP23S17::getPullup8(uint8_t port, uint8_t &mask)
|
||||
//
|
||||
// 16 pins interface
|
||||
//
|
||||
// two register at once
|
||||
// value = 0x0000..0xFFFF bit pattern
|
||||
bool MCP23S17::pinMode16(uint16_t value)
|
||||
// two registers at once
|
||||
// mask = 0x0000..0xFFFF bit pattern
|
||||
// bit 0 = output mode, bit 1 = input mode
|
||||
bool MCP23S17::pinMode16(uint16_t mask)
|
||||
{
|
||||
writeReg16(MCP23x17_DDR_A, value);
|
||||
writeReg16(MCP23x17_DDR_A, mask);
|
||||
_error = MCP23S17_OK;
|
||||
return true;
|
||||
}
|
||||
|
@ -2,7 +2,7 @@
|
||||
//
|
||||
// FILE: MCP23S17.h
|
||||
// AUTHOR: Rob Tillaart
|
||||
// VERSION: 0.5.3
|
||||
// VERSION: 0.5.4
|
||||
// PURPOSE: Arduino library for SPI MCP23S17 16 channel port expander
|
||||
// DATE: 2021-12-30
|
||||
// URL: https://github.com/RobTillaart/MCP23S17
|
||||
@ -13,7 +13,7 @@
|
||||
#include "MCP23x17_registers.h"
|
||||
|
||||
|
||||
#define MCP23S17_LIB_VERSION (F("0.5.3"))
|
||||
#define MCP23S17_LIB_VERSION (F("0.5.4"))
|
||||
|
||||
// ERROR CODES
|
||||
#define MCP23S17_OK 0x00
|
||||
@ -56,7 +56,8 @@ public:
|
||||
|
||||
|
||||
// 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 write1(uint8_t pin, uint8_t value);
|
||||
uint8_t read1(uint8_t pin);
|
||||
@ -69,8 +70,10 @@ public:
|
||||
|
||||
// 8 pins interface
|
||||
// port = 0..1
|
||||
// value = bit pattern
|
||||
bool pinMode8(uint8_t port, uint8_t value);
|
||||
// mask = 0x00..0xFF bit pattern,
|
||||
// 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);
|
||||
int read8(uint8_t port);
|
||||
|
||||
@ -81,8 +84,10 @@ public:
|
||||
|
||||
|
||||
// 16 pins interface
|
||||
// value = bit pattern
|
||||
bool pinMode16(uint16_t value);
|
||||
// mask = 0x0000..0xFFFF bit pattern
|
||||
// bit 0 = output mode, bit 1 = input mode
|
||||
// value = bit pattern.
|
||||
bool pinMode16(uint16_t mask);
|
||||
bool write16(uint16_t value);
|
||||
uint16_t read16();
|
||||
|
||||
|
@ -137,7 +137,9 @@ See also **IO Control Register** section below.
|
||||
|
||||
### Single pin interface
|
||||
|
||||
- **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.
|
||||
- **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.
|
||||
@ -148,7 +150,7 @@ See also **IO Control Register** section below.
|
||||
|
||||
### 8 pins interface
|
||||
|
||||
- **bool pinMode8(uint8_t port, uint8_t value)** port = 0..1, value = 0..255. Returns true if successful.
|
||||
- **bool pinMode8(uint8_t port, uint8_t mask)** port = 0..1, mask = 0..255. Returns true if successful.
|
||||
- **bool write8(uint8_t port, uint8_t value)** port = 0..1, value = 0..255. Returns true if successful.
|
||||
- **uint8_t read8(uint8_t port)** port = 0..1, reads 8 pins into one byte.
|
||||
- **bool setPolarity8(uint8_t port, uint8_t mask)** port = 0..1, sets polarity for 8 channels at once.
|
||||
@ -163,7 +165,7 @@ Returns true if successful.
|
||||
|
||||
### 16 pins interface
|
||||
|
||||
- **bool pinMode16(uint16_t value)** value = 0..0xFFFF, returns true if successful.
|
||||
- **bool pinMode16(uint16_t mask)** mask = 0..0xFFFF, returns true if successful.
|
||||
- **bool write16(uint16_t value)** value = 0..0xFFFF, returns true if successful.
|
||||
- **uint16_t read16()** reads 16 pins into an uint16_t.
|
||||
- **bool setPolarity16(uint16_t mask)** sets polarity for 16 channels.
|
||||
|
@ -15,7 +15,7 @@
|
||||
"type": "git",
|
||||
"url": "https://github.com/RobTillaart/MCP23S17.git"
|
||||
},
|
||||
"version": "0.5.3",
|
||||
"version": "0.5.4",
|
||||
"license": "MIT",
|
||||
"frameworks": "*",
|
||||
"platforms": "*",
|
||||
|
@ -1,5 +1,5 @@
|
||||
name=MCP23S17
|
||||
version=0.5.3
|
||||
version=0.5.4
|
||||
author=Rob Tillaart <rob.tillaart@gmail.com>
|
||||
maintainer=Rob Tillaart <rob.tillaart@gmail.com>
|
||||
sentence=Arduino library for SPI MCP23S17 16 channel port expander 16 IO-lines
|
||||
|
Loading…
Reference in New Issue
Block a user