Skip to content

Commit d3f9747

Browse files
committed
0.3.5 MCP23008
1 parent 178c3ed commit d3f9747

File tree

12 files changed

+76
-57
lines changed

12 files changed

+76
-57
lines changed

libraries/MCP23008/CHANGELOG.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/)
66
and this project adheres to [Semantic Versioning](http://semver.org/).
77

88

9+
## [0.3.5] 2025-04-23
10+
- update readme.md
11+
- update examples (minor)
12+
- minor edits
13+
914
## [0.3.4] 2024-07-04
1015
- Fix #21, documentation bug
1116

@@ -64,7 +69,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
6469
- minor edit readme.md
6570
- update datasheet page numbers of registers MCP23008.cpp
6671

67-
## [0.1.1] - 2022-09-28
72+
## [0.1.1] - 2022-09-28
6873
- optimize digitalWrite() - as that is the most used one
6974

7075
## [0.1.0] - 2022-01-10

libraries/MCP23008/LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2022-2024 Rob Tillaart
3+
Copyright (c) 2022-2025 Rob Tillaart
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

libraries/MCP23008/MCP23008.cpp

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//
22
// FILE: MCP23008.cpp
33
// AUTHOR: Rob Tillaart
4-
// VERSION: 0.3.4
4+
// VERSION: 0.3.5
55
// PURPOSE: Arduino library for I2C MCP23008 8 channel port expander
66
// DATE: 2019-10-12
77
// URL: https://github.com/RobTillaart/MCP23008
@@ -11,11 +11,8 @@
1111

1212

1313
MCP23008::MCP23008(uint8_t address, TwoWire *wire)
14-
{
15-
_address = address;
16-
_wire = wire;
17-
_error = MCP23008_OK;
18-
}
14+
: _address{address}, _wire{wire}
15+
{}
1916

2017

2118
bool MCP23008::begin(bool pullup)
@@ -51,12 +48,6 @@ bool MCP23008::isConnected()
5148
}
5249

5350

54-
uint8_t MCP23008::getAddress()
55-
{
56-
return _address;
57-
}
58-
59-
6051
///////////////////////////////////////////////////////////////////
6152
//
6253
// single pin interface

libraries/MCP23008/MCP23008.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//
33
// FILE: MCP23008.h
44
// AUTHOR: Rob Tillaart
5-
// VERSION: 0.3.4
5+
// VERSION: 0.3.5
66
// PURPOSE: Arduino library for I2C MCP23008 8 channel port expander
77
// DATE: 2022-01-10
88
// URL: https://github.com/RobTillaart/MCP23008
@@ -13,7 +13,7 @@
1313
#include "MCP23x08_registers.h"
1414

1515

16-
#define MCP23008_LIB_VERSION (F("0.3.4"))
16+
#define MCP23008_LIB_VERSION (F("0.3.5"))
1717

1818
#define MCP23008_OK 0x00
1919
#define MCP23008_PIN_ERROR 0x81
@@ -31,7 +31,7 @@ class MCP23008
3131

3232
bool begin(bool pullup = true);
3333
bool isConnected();
34-
uint8_t getAddress();
34+
uint8_t getAddress() const {return _address; }
3535

3636

3737
// single pin interface
@@ -48,7 +48,7 @@ class MCP23008
4848

4949

5050
// 8 pins interface
51-
// mask = 0x00..0xFF bit pattern,
51+
// mask = 0x00..0xFF bit pattern,
5252
// bit 0 = output mode, bit 1 = input mode
5353
// value = bit pattern.
5454
bool pinMode8(uint8_t mask);
@@ -93,7 +93,7 @@ class MCP23008
9393

9494
uint8_t _address;
9595
TwoWire* _wire;
96-
uint8_t _error;
96+
uint8_t _error{MCP23008_OK};
9797
};
9898

9999

libraries/MCP23008/README.md

Lines changed: 48 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ Since 0.1.1 the **digitalWrite(pin, value)** is optimized.
2525
If a pin is not changed it will not be written again to save time.
2626

2727

28-
#### 0.3.0 Breaking change
28+
### 0.3.0 Breaking change
2929

3030
The version 0.3.0 has breaking changes in the interface.
3131
The rationale is that the programming environment of the **Arduino ESP32 S3**
@@ -47,7 +47,7 @@ The following library functions have been renamed:
4747
| digitalWrite() | write1() |
4848

4949

50-
#### 0.2.0 Breaking change
50+
### 0.2.0 Breaking change
5151

5252
Version 0.2.0 introduced a breaking change.
5353
You cannot set the pins in **begin()** any more.
@@ -56,31 +56,51 @@ The user has to call **Wire.begin()** and can optionally set the Wire pins
5656
before calling **begin()**.
5757

5858

59-
#### Related
59+
### Related
6060

6161
16 bit port expanders
6262

63-
- https://github.com/RobTillaart/MCP23017_RT
64-
- https://github.com/RobTillaart/MCP23S17
65-
- https://github.com/RobTillaart/PCF8575
66-
- https://github.com/RobTillaart/TCA9555
63+
- https://github.com/RobTillaart/MCP23017_RT I2C 16 IO lines.
64+
- https://github.com/RobTillaart/MCP23S17 SPI 16 IO lines.
65+
- https://github.com/RobTillaart/PCF8575 I2C 16 IO lines.
66+
- https://github.com/RobTillaart/PCA9671 I2C 16 IO lines. - successor PCF8575
67+
- https://github.com/RobTillaart/TCA9555 I2C 16 IO lines.
6768

6869

6970
8 bit port expanders
7071

71-
- https://github.com/RobTillaart/MCP23008
72-
- https://github.com/RobTillaart/MCP23S08
73-
- https://github.com/RobTillaart/PCF8574
72+
- https://github.com/RobTillaart/MCP23008 I2C 8 IO lines.
73+
- https://github.com/RobTillaart/MCP23S08 SPI 8 IO lines.
74+
- https://github.com/RobTillaart/PCF8574 I2C 8 IO lines.
75+
- https://github.com/RobTillaart/TCA9554 I2C 8 IO lines.
7476

7577

7678
## I2C
7779

78-
Supports 100kHz, 400kHz and 1.7MHz
80+
The device has 8 possible addresses: 0x20 - 0x27.
7981

80-
TODO - add performance data
82+
See datasheet page 8.
8183

84+
### Performance
8285

83-
#### I2C multiplexing
86+
Datasheet states it supports 100kHz, 400kHz and 1.7MHz
87+
88+
TODO test to fill the table
89+
90+
| clock speed | Read | Write | Notes |
91+
|:-----------:|:------:|:-------:|:--------|
92+
| 100000 | | |
93+
| 200000 | | |
94+
| 300000 | | |
95+
| 400000 | | |
96+
| 500000 | | |
97+
| 600000 | | |
98+
| 700000 | | |
99+
| 800000 | | |
100+
101+
102+
103+
### I2C multiplexing
84104

85105
Sometimes you need to control more devices than possible with the default
86106
address range the device provides.
@@ -148,19 +168,19 @@ pin = 0..7
148168
mode = { RISING, FALLING, CHANGE }
149169
- **bool enableInterrupt(uint8_t pin, uint8_t mode)**
150170
Returns true if successful.
151-
Returns MCP23017_PIN_ERROR if pin > 7.
171+
Returns MCP23008_PIN_ERROR if pin > 7.
152172
- **bool disableInterrupt(uint8_t pin)**
153173
Returns true if successful.
154-
Returns MCP23017_PIN_ERROR if pin > 7.
174+
Returns MCP23008_PIN_ERROR if pin > 7.
155175

156176

157-
Determine which pins caused the Interrupt. (datasheet).
177+
Determine which pins caused the Interrupt. (Read datasheet).
158178
- **uint8_t getInterruptFlagRegister()** Reads all 8 pins.
159179
- **uint8_t getInterruptCaptureRegister()** Reads all 8 pins.
160180
Is used to detect if multiple pins triggered an interrupt.
161181

162182

163-
- **bool setInterruptPolarity(uint8_t ipol)** polarity: 0 = LOW, 1 = HIGH, 2 = NONE/ODR
183+
- **bool setInterruptPolarity(uint8_t polarity)** polarity: 0 = LOW, 1 = HIGH, 2 = NONE/ODR
164184
- **uint8_t getInterruptPolarity()** return set value.
165185

166186

@@ -172,23 +192,16 @@ Read the datasheet carefully!
172192
- **bool enableControlRegister(uint8_t mask)** set IOCR bit fields
173193
- **bool disableControlRegister(uint8_t mask)** clear IOCR bit fields
174194

195+
Datasheet page 15
175196

176197
| constant | mask | description |
177198
|:-----------------------|:------:|:--------------|
178-
| MCP23x17_IOCR_BANK | 0x80 | Controls how the registers are addressed.
179-
| MCP23x17_IOCR_MIRROR | 0x40 | INT Pins Mirror bit.
180-
| MCP23x17_IOCR_SEQOP | 0x20 | Sequential Operation mode bit.
181-
| MCP23x17_IOCR_DISSLW | 0x10 | Slew Rate control bit for SDA output.
182-
| MCP23x17_IOCR_HAEN | 0x08 | Hardware Address Enable bit (MCP23S17 only).
183-
| MCP23x17_IOCR_ODR | 0x04 | Configures the INT pin as an open-drain output.
184-
| MCP23x17_IOCR_INTPOL | 0x02 | This bit sets the polarity of the INT output pin.
185-
| MCP23x17_IOCR_NI | 0x01 | Not implemented.
186-
187-
188-
Two dedicated functions are added: (MCP23S17 only)
189-
190-
- **bool enableHardwareAddress()** set IOCR_HAEN bit.
191-
- **bool disableHardwareAddress()** clear IOCR_HAEN bit.
199+
| MCP23x08_IOCR_SEQOP | 0x20 | Sequential Operation mode bit.
200+
| MCP23x08_IOCR_DISSLW | 0x10 | Slew Rate control bit for SDA output.
201+
| MCP23x08_IOCR_HAEN | 0x08 | Hardware Address Enable bit (MCP23S08 only).
202+
| MCP23x08_IOCR_ODR | 0x04 | Configures the INT pin as an open-drain output.
203+
| MCP23x08_IOCR_INTPOL | 0x02 | This bit sets the polarity of the INT output pin.
204+
| MCP23x08_IOCR_NI | 0x01 | Not implemented.
192205

193206

194207
### Error codes
@@ -201,10 +214,10 @@ Reading it will reset the flag to **MCP23008_OK**.
201214
| name | value | description |
202215
|:--------------------------|:-------:|:--------------|
203216
| MCP23008_OK | 0x00 | No error |
204-
| MCP23008_PIN_ERROR | 0x81 |
205-
| MCP23008_I2C_ERROR | 0x82 | (compatibility)
206-
| MCP23008_VALUE_ERROR | 0x83 |
207-
| MCP23008_PORT_ERROR | 0x84 |
217+
| MCP23008_PIN_ERROR | 0x81 | pin out of range
218+
| MCP23008_I2C_ERROR | 0x82 | low level
219+
| MCP23008_VALUE_ERROR | 0x83 | pin mode error only for now.
220+
| MCP23008_PORT_ERROR | 0x84 | (compatibility)
208221
| MCP23008_REGISTER_ERROR | 0xFF | low level.
209222
| MCP23008_INVALID_READ | 0xFF | low level.
210223

libraries/MCP23008/examples/MCP23008_I2C_Keypad_4x4_read/MCP23008_I2C_Keypad_4x4_read.ino

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@ byte keys_of_keypad[ROWS_OF_KEYPAD][COLS_OF_KEYPAD] = {
2828

2929
void setup()
3030
{
31+
// while (!Serial); // uncomment if needed
3132
Serial.begin(115200);
33+
Serial.println();
3234
Serial.println(__FILE__);
3335
Serial.print("MCP23008_LIB_VERSION: ");
3436
Serial.println(MCP23008_LIB_VERSION);
@@ -92,5 +94,5 @@ void loop()
9294
}
9395

9496

95-
// -- END OF FILE --
97+
// -- END OF FILE --
9698

libraries/MCP23008/examples/MCP23008_digitalRead/MCP23008_digitalRead.ino

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@ MCP23008 MCP(0x27);
1313

1414
void setup()
1515
{
16+
// while (!Serial); // uncomment if needed
1617
Serial.begin(115200);
18+
Serial.println();
1719
Serial.println(__FILE__);
1820
Serial.print("MCP23008_LIB_VERSION: ");
1921
Serial.println(MCP23008_LIB_VERSION);

libraries/MCP23008/examples/MCP23008_digitalWrite/MCP23008_digitalWrite.ino

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@ MCP23008 MCP(0x27);
1313

1414
void setup()
1515
{
16+
// while (!Serial); // uncomment if needed
1617
Serial.begin(115200);
18+
Serial.println();
1719
Serial.println(__FILE__);
1820
Serial.print("MCP23008_LIB_VERSION: ");
1921
Serial.println(MCP23008_LIB_VERSION);

libraries/MCP23008/examples/MCP23008_performance/MCP23008_performance.ino

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@ uint32_t start, stop;
1515

1616
void setup()
1717
{
18+
// while (!Serial); // uncomment if needed
1819
Serial.begin(115200);
20+
Serial.println();
1921
Serial.println(__FILE__);
2022
Serial.print("MCP23008_LIB_VERSION: ");
2123
Serial.println(MCP23008_LIB_VERSION);

libraries/MCP23008/examples/MCP23008_test/MCP23008_test.ino

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@ MCP23008 MCP(0x22);
1313

1414
void setup()
1515
{
16+
// while (!Serial); // uncomment if needed
1617
Serial.begin(115200);
18+
Serial.println();
1719
Serial.println(__FILE__);
1820
Serial.print("MCP23008_LIB_VERSION: ");
1921
Serial.println(MCP23008_LIB_VERSION);

libraries/MCP23008/library.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"type": "git",
1616
"url": "https://github.com/RobTillaart/MCP23008.git"
1717
},
18-
"version": "0.3.4",
18+
"version": "0.3.5",
1919
"license": "MIT",
2020
"frameworks": "*",
2121
"platforms": "*",

libraries/MCP23008/library.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name=MCP23008
2-
version=0.3.4
2+
version=0.3.5
33
author=Rob Tillaart <rob.tillaart@gmail.com>
44
maintainer=Rob Tillaart <rob.tillaart@gmail.com>
55
sentence=Arduino library for I2C MCP23008 8 channel port expander 8 IO-lines

0 commit comments

Comments
 (0)