0.5.3 MCP23S08

This commit is contained in:
Rob Tillaart 2024-07-06 11:18:29 +02:00
parent d2b5981264
commit 609ca019c0
6 changed files with 27 additions and 15 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.5.3] - 2024-07-04
- Fix #20, documentation bug
## [0.5.2] - 2024-05-25 ## [0.5.2] - 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: MCP23S08.cpp // FILE: MCP23S08.cpp
// AUTHOR: Rob Tillaart // AUTHOR: Rob Tillaart
// VERSION: 0.5.2 // VERSION: 0.5.3
// PURPOSE: Arduino library for SPI MCP23S08 8 channel port expander // PURPOSE: Arduino library for SPI MCP23S08 8 channel port expander
// DATE: 2022-01-10 // DATE: 2022-01-10
// URL: https://github.com/RobTillaart/MCP23S08 // URL: https://github.com/RobTillaart/MCP23S08
@ -100,6 +100,7 @@ uint8_t MCP23S08::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 MCP23S08::pinMode1(uint8_t pin, uint8_t mode) bool MCP23S08::pinMode1(uint8_t pin, uint8_t mode)
{ {
if (pin > 7) if (pin > 7)
@ -313,10 +314,11 @@ void MCP23S08::setSPIspeed(uint32_t speed)
// 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 MCP23S08::pinMode8(uint8_t value) // bit 0 = output mode, bit 1 = input mode
bool MCP23S08::pinMode8(uint8_t mask)
{ {
writeReg(MCP23x08_DDR_A, value); writeReg(MCP23x08_DDR_A, mask);
_error = MCP23S08_OK; _error = MCP23S08_OK;
return true; return true;
} }

View File

@ -2,7 +2,7 @@
// //
// FILE: MCP23S08.h // FILE: MCP23S08.h
// AUTHOR: Rob Tillaart // AUTHOR: Rob Tillaart
// VERSION: 0.5.2 // VERSION: 0.5.3
// PURPOSE: Arduino library for SPI MCP23S08 8 channel port expander // PURPOSE: Arduino library for SPI MCP23S08 8 channel port expander
// DATE: 2022-01-10 // DATE: 2022-01-10
// URL: https://github.com/RobTillaart/MCP23S08 // URL: https://github.com/RobTillaart/MCP23S08
@ -13,7 +13,7 @@
#include "MCP23x08_registers.h" #include "MCP23x08_registers.h"
#define MCP23S08_LIB_VERSION (F("0.5.2")) #define MCP23S08_LIB_VERSION (F("0.5.3"))
// ERROR CODES // ERROR CODES
#define MCP23S08_OK 0x00 #define MCP23S08_OK 0x00
@ -54,8 +54,10 @@ public:
bool isConnected(); bool isConnected();
uint8_t getAddress(); uint8_t getAddress();
// 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);
@ -67,8 +69,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

@ -137,9 +137,10 @@ See also **IO Control Register** section below.
### Single pin interface ### Single pin interface
mode: 0 = OUTPUT, 1 = INPUT, 1 = INPUT_PULLUP (==INPUT) - **bool pinMode1(uint8_t pin, uint8_t mode)** pin = 0..7.
mode = INPUT, OUTPUT or INPUT_PULLUP.
- **bool pinMode1(uint8_t pin, uint8_t mode)** pin = 0..7. Returns true if successful. 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..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();
- **bool setPolarity(uint8_t pin, bool reversed)** pin = 0..7, set reversed flag. Returns true if successful. - **bool setPolarity(uint8_t pin, bool reversed)** pin = 0..7, set reversed flag. Returns true if successful.
@ -150,8 +151,10 @@ mode: 0 = OUTPUT, 1 = INPUT, 1 = INPUT_PULLUP (==INPUT)
### 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.
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.
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. - **bool setPolarity8(uint8_t mask)** sets polarity for 8 channels at once.
Returns true if successful. Returns true if successful.

View File

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

View File

@ -1,5 +1,5 @@
name=MCP23S08 name=MCP23S08
version=0.5.2 version=0.5.3
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 SPI MCP23S08 8 channel port expander 8 IO-lines sentence=Arduino library for SPI MCP23S08 8 channel port expander 8 IO-lines