From 4b41d2dd0e009962abc2169fbb38f005c7b6a9b2 Mon Sep 17 00:00:00 2001 From: Ritvi Mishra Date: Tue, 31 Aug 2021 16:08:33 +0530 Subject: [PATCH 1/3] adding support for MCP23017 --- RF24.cpp | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/RF24.cpp b/RF24.cpp index 1cefa162f..37df60edc 100644 --- a/RF24.cpp +++ b/RF24.cpp @@ -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() @@ -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()) { @@ -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); @@ -869,6 +882,7 @@ bool RF24::_init_pins() return true; // assuming pins are connected properly } + /****************************************************************************/ bool RF24::_init_radio() From 6d64386a3b5eda36bcb565a0ace95aaa9ab30fac Mon Sep 17 00:00:00 2001 From: Ritvi Mishra Date: Tue, 31 Aug 2021 16:10:15 +0530 Subject: [PATCH 2/3] Update RF24_config.h --- RF24_config.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/RF24_config.h b/RF24_config.h index 60d03d1f0..33cf667d2 100644 --- a/RF24_config.h +++ b/RF24_config.h @@ -68,6 +68,8 @@ #else //Everything else #include + // 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 From e57774296205d5024ae909135eb717365f4257b1 Mon Sep 17 00:00:00 2001 From: Ritvi Mishra Date: Tue, 31 Aug 2021 16:12:56 +0530 Subject: [PATCH 3/3] Update RF24_config.h --- RF24_config.h | 1 + 1 file changed, 1 insertion(+) diff --git a/RF24_config.h b/RF24_config.h index 33cf667d2..88720d45f 100644 --- a/RF24_config.h +++ b/RF24_config.h @@ -67,6 +67,7 @@ #else //Everything else #include + #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