Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GPIO Expander Support #787

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions RF24.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,12 +101,17 @@ void RF24::csn(bool mode)

void RF24::ce(bool level)
{
//Allow for 3-pin use on ATTiny
if (ce_pin != csn_pin) {
#if defined USE_MCP23XXX_AS_CE
USE_MCP23XXX_AS_CE.digitalWrite(ce_pin, level);
#else // !defined(USE_MCP23XXX_AS_CE)
if (ce_pin != csn_pin)
{
digitalWrite(ce_pin, level);
}
#endif // !defined(USE_MCP23XXX_AS_CE)
}


/****************************************************************************/

inline void RF24::beginTransaction()
Expand Down Expand Up @@ -820,6 +825,8 @@ bool RF24::begin(void)

/****************************************************************************/

// This modification assumes you passed the MCP23017 pin number to the RF24 constructor's _ce_pin parameter

bool RF24::_init_pins()
{
if (!isValid()) {
Expand Down Expand Up @@ -854,9 +861,15 @@ bool RF24::_init_pins()

// Initialize pins
if (ce_pin != csn_pin) {
#if !defined (USE_MCP23XXX_AS_CE)
pinMode(ce_pin, OUTPUT);
#endif // !defined (USE_MCP23XXX_AS_CE)
pinMode(csn_pin, OUTPUT);
}

#if defined (USE_MCP23XXX_AS_CE)
USE_MCP23XXX_AS_CE.pinMode(ce_pin, OUTPUT);
#endif // defined(USE_MCP23XXX_AS_CE)

ce(LOW);
csn(HIGH);
Expand All @@ -869,6 +882,7 @@ bool RF24::_init_pins()
return true; // assuming pins are connected properly
}


/****************************************************************************/

bool RF24::_init_radio()
Expand Down
3 changes: 3 additions & 0 deletions RF24_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,10 @@

#else //Everything else
#include <Arduino.h>
#include "Adafruit_MCP23X17.h"

// This macro assumes that MCP23017::begin() was called by the application prior to RF24::begin().
#define USE_MCP23XXX_AS_CE mcp // the global MCP23017 object declared in main application's code space

#if defined (ARDUINO) && !defined (__arm__) && !defined (__ARDUINO_X86__)
#if defined SPI_UART
Expand Down