Skip to content

Commit

Permalink
Fix #32, improve SPI dependency (#33)
Browse files Browse the repository at this point in the history
- Fix #32, improve handling SPI dependency.
- update examples
  • Loading branch information
RobTillaart authored Jan 20, 2024
1 parent 65e8190 commit 8b942cb
Show file tree
Hide file tree
Showing 16 changed files with 32 additions and 17 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).


## [0.5.0] - 2024-01-20
- Fix #32, improve handling SPI dependency.
- update examples

----

## [0.4.0] - 2023-12-24
- Fix #30, support for Arduino ESP32 S3 - breaking change
- update readme.md
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2021-2023 Rob Tillaart
Copyright (c) 2021-2024 Rob Tillaart

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
6 changes: 3 additions & 3 deletions MCP23S17.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//
// FILE: MCP23S17.cpp
// AUTHOR: Rob Tillaart
// VERSION: 0.4.0
// VERSION: 0.5.0
// PURPOSE: Arduino library for SPI MCP23S17 16 channel port expander
// DATE: 2021-12-30
// URL: https://github.com/RobTillaart/MCP23S17
Expand Down Expand Up @@ -50,8 +50,8 @@ bool MCP23S17::begin()

if (_hwSPI)
{
_mySPI->end();
_mySPI->begin();
// _mySPI->end();
// _mySPI->begin();
}
else
{
Expand Down
4 changes: 2 additions & 2 deletions MCP23S17.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
//
// FILE: MCP23S17.h
// AUTHOR: Rob Tillaart
// VERSION: 0.4.0
// VERSION: 0.5.0
// PURPOSE: Arduino library for SPI MCP23S17 16 channel port expander
// DATE: 2021-12-30
// URL: https://github.com/RobTillaart/MCP23S17
Expand All @@ -13,7 +13,7 @@
#include "MCP23S17_registers.h"


#define MCP23S17_LIB_VERSION (F("0.4.0"))
#define MCP23S17_LIB_VERSION (F("0.5.0"))

// ERROR CODES
#define MCP23S17_OK 0x00
Expand Down
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,13 @@ This IC is strongly related to the MCP23017 I2C port expander - https://github.c
Programming Interface is kept the same as much as possible.


#### 0.5.0 Breaking change

Version 0.5.0 introduced a breaking change to improve handling the SPI dependency.
The user has to call **SPI.begin()** or equivalent before calling **MCP.begin()**.
Optionally the user can provide parameters to the **SPI.begin(...)**


#### 0.4.0 Breaking change

The version 0.4.0 has breaking changes in the interface.
Expand Down
2 changes: 1 addition & 1 deletion examples/MCP23S17_digitalRead/MCP23S17_digitalRead.ino
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@


#include "MCP23S17.h"
#include "SPI.h"


MCP23S17 MCP(10);
Expand All @@ -22,6 +21,7 @@ void setup()
delay(100);

SPI.begin();

rv = MCP.begin();
Serial.println(rv ? "true" : "false");

Expand Down
3 changes: 2 additions & 1 deletion examples/MCP23S17_digitalWrite/MCP23S17_digitalWrite.ino
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@


#include "MCP23S17.h"
#include "SPI.h"


MCP23S17 MCP(10, 5, 6, 7); // SW SPI address 0x00

Expand All @@ -20,6 +20,7 @@ void setup()
delay(100);

SPI.begin();

bool b = MCP.begin();
Serial.println(b ? "true" : "false");
delay(100);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@


#include "MCP23S17.h"
#include "SPI.h"


MCP23S17 MCP_A(10, 12, 11, 13, 0); // SW SPI, address 0
Expand All @@ -34,6 +33,7 @@ void setup()
delay(100);

SPI.begin();

for (int addr = 0; addr < 4; addr++)
{
MCP[addr].begin();
Expand Down
3 changes: 2 additions & 1 deletion examples/MCP23S17_performance/MCP23S17_performance.ino
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@


#include "MCP23S17.h"
#include "SPI.h"


// MCP23S17 MCP(10, 12, 11, 13); // SW SPI address 0x00
MCP23S17 MCP(10); // HW SPI address 0x00
Expand All @@ -28,6 +28,7 @@ void setup()
delay(100);

SPI.begin();

bool b = MCP.begin();
Serial.println(b ? "true" : "false");

Expand Down
2 changes: 1 addition & 1 deletion examples/MCP23S17_test/MCP23S17_test.ino
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@


#include "MCP23S17.h"
#include "SPI.h"


// MCP23S17 MCP(10, 12, 11, 13); // SW SPI address 0x00
Expand All @@ -23,6 +22,7 @@ void setup()
delay(100);

SPI.begin();

bool b = MCP.begin();
Serial.println(b ? "true" : "false");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@


#include "MCP23S17.h"
#include "SPI.h"


// MCP23S17 MCP(10, 12, 11, 13); // SW SPI address 0x00
Expand All @@ -25,6 +24,7 @@ void setup()
delay(100);

SPI.begin();

MCP.begin();

int c = testConnection(MCP);
Expand Down
2 changes: 1 addition & 1 deletion examples/MCP23S17_test_led_bar/MCP23S17_test_led_bar.ino
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@


#include "MCP23S17.h"
#include "SPI.h"


// MCP23S17 MCP(10, 12, 11, 13); // SW SPI address 0x00
Expand All @@ -28,6 +27,7 @@ void setup()
delay(100);

SPI.begin();

bool b = MCP.begin();
Serial.println(b ? "true" : "false");

Expand Down
2 changes: 1 addition & 1 deletion examples/MCP23S17_two_ADDRESS/MCP23S17_two_ADDRESS.ino
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@


#include "MCP23S17.h"
#include "SPI.h"


MCP23S17 MCP_A(10, 12, 11, 13, 0); // SW SPI, address 0
Expand All @@ -28,6 +27,7 @@ void setup()
delay(100);

SPI.begin();

MCP_A.begin();
MCP_B.begin();
MCP_A.enableHardwareAddress();
Expand Down
2 changes: 1 addition & 1 deletion examples/MCP23S17_two_SELECT/MCP23S17_two_SELECT.ino
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@


#include "MCP23S17.h"
#include "SPI.h"


MCP23S17 MCP_A(10, 12, 11, 13); // SW SPI
Expand All @@ -28,6 +27,7 @@ void setup()
delay(100);

SPI.begin();

MCP_A.begin();
MCP_B.begin();

Expand Down
2 changes: 1 addition & 1 deletion library.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"type": "git",
"url": "https://github.com/RobTillaart/MCP23S17.git"
},
"version": "0.4.0",
"version": "0.5.0",
"license": "MIT",
"frameworks": "*",
"platforms": "*",
Expand Down
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name=MCP23S17
version=0.4.0
version=0.5.0
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
Expand Down

0 comments on commit 8b942cb

Please sign in to comment.