diff --git a/libraries/Wire/Wire.h b/libraries/Wire/Wire.h index f2af3a41..39a353ec 100755 --- a/libraries/Wire/Wire.h +++ b/libraries/Wire/Wire.h @@ -34,15 +34,9 @@ class TwoWire : public Stream { public: -#if defined(NRF52) || defined(NRF52_SERIES) TwoWire(NRF_TWIM_Type * p_twim, NRF_TWIS_Type * p_twis, IRQn_Type IRQn, uint8_t pinSDA, uint8_t pinSCL); -#else - TwoWire(NRF_TWI_Type * p_twi, uint8_t pinSDA, uint8_t pinSCL); -#endif void begin(); -#if defined(NRF52) || defined(NRF52_SERIES) void begin(uint8_t); -#endif void end(); void setClock(uint32_t); @@ -60,11 +54,10 @@ class TwoWire : public Stream virtual int read(void); virtual int peek(void); virtual void flush(void); -#if defined(NRF52) || defined(NRF52_SERIES) + void onReceive(void(*)(int)); void onRequest(void(*)(void)); void onService(void); -#endif using Print::write; @@ -105,4 +98,8 @@ class TwoWire : public Stream extern TwoWire Wire; #endif +#if WIRE_INTERFACES_COUNT > 1 +extern TwoWire Wire1; +#endif + #endif diff --git a/libraries/Wire/Wire_nRF52.cpp b/libraries/Wire/Wire_nRF52.cpp index e593cedc..b128d393 100755 --- a/libraries/Wire/Wire_nRF52.cpp +++ b/libraries/Wire/Wire_nRF52.cpp @@ -392,9 +392,9 @@ void TwoWire::onService(void) } } +#if WIRE_INTERFACES_COUNT > 0 TwoWire Wire(NRF_TWIM0, NRF_TWIS0, SPIM0_SPIS0_TWIM0_TWIS0_SPI0_TWI0_IRQn, PIN_WIRE_SDA, PIN_WIRE_SCL); -#if WIRE_INTERFACES_COUNT > 0 extern "C" { void SPIM0_SPIS0_TWIM0_TWIS0_SPI0_TWI0_IRQHandler(void) @@ -404,4 +404,16 @@ extern "C" } #endif +#if WIRE_INTERFACES_COUNT > 1 +TwoWire Wire1(NRF_TWIM1, NRF_TWIS1, SPIM1_SPIS1_TWIM1_TWIS1_SPI1_TWI1_IRQn, PIN_WIRE1_SDA, PIN_WIRE1_SCL); + +extern "C" +{ + void SPIM1_SPIS1_TWIM1_TWIS1_SPI1_TWI1_IRQHandler(void) + { + Wire1.onService(); + } +} #endif + +#endif // NRF52_SERIES diff --git a/variants/circuitplayground_nrf52840/variant.h b/variants/circuitplayground_nrf52840/variant.h index 5f3dd2ff..c7fdd8cc 100644 --- a/variants/circuitplayground_nrf52840/variant.h +++ b/variants/circuitplayground_nrf52840/variant.h @@ -112,10 +112,13 @@ static const uint8_t SCK = PIN_SPI_SCK ; /* * Wire Interfaces */ -#define WIRE_INTERFACES_COUNT 1 +#define WIRE_INTERFACES_COUNT 2 -#define PIN_WIRE_SDA (28) -#define PIN_WIRE_SCL (26) +#define PIN_WIRE_SDA (2) +#define PIN_WIRE_SCL (3) + +#define PIN_WIRE1_SDA (28) +#define PIN_WIRE1_SCL (26) // QSPI Pins #define PIN_QSPI_SCK 29