Skip to content

Commit 74b2463

Browse files
committed
add second hardware i2c as Wire1 for cplayground bluefruit
1 parent d61c88a commit 74b2463

File tree

3 files changed

+24
-12
lines changed

3 files changed

+24
-12
lines changed

libraries/Wire/Wire.h

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,9 @@
3434
class TwoWire : public Stream
3535
{
3636
public:
37-
#if defined(NRF52) || defined(NRF52_SERIES)
3837
TwoWire(NRF_TWIM_Type * p_twim, NRF_TWIS_Type * p_twis, IRQn_Type IRQn, uint8_t pinSDA, uint8_t pinSCL);
39-
#else
40-
TwoWire(NRF_TWI_Type * p_twi, uint8_t pinSDA, uint8_t pinSCL);
41-
#endif
4238
void begin();
43-
#if defined(NRF52) || defined(NRF52_SERIES)
4439
void begin(uint8_t);
45-
#endif
4640
void end();
4741
void setClock(uint32_t);
4842

@@ -60,11 +54,10 @@ class TwoWire : public Stream
6054
virtual int read(void);
6155
virtual int peek(void);
6256
virtual void flush(void);
63-
#if defined(NRF52) || defined(NRF52_SERIES)
57+
6458
void onReceive(void(*)(int));
6559
void onRequest(void(*)(void));
6660
void onService(void);
67-
#endif
6861

6962
using Print::write;
7063

@@ -105,4 +98,8 @@ class TwoWire : public Stream
10598
extern TwoWire Wire;
10699
#endif
107100

101+
#if WIRE_INTERFACES_COUNT > 1
102+
extern TwoWire Wire1;
103+
#endif
104+
108105
#endif

libraries/Wire/Wire_nRF52.cpp

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -392,9 +392,9 @@ void TwoWire::onService(void)
392392
}
393393
}
394394

395+
#if WIRE_INTERFACES_COUNT > 0
395396
TwoWire Wire(NRF_TWIM0, NRF_TWIS0, SPIM0_SPIS0_TWIM0_TWIS0_SPI0_TWI0_IRQn, PIN_WIRE_SDA, PIN_WIRE_SCL);
396397

397-
#if WIRE_INTERFACES_COUNT > 0
398398
extern "C"
399399
{
400400
void SPIM0_SPIS0_TWIM0_TWIS0_SPI0_TWI0_IRQHandler(void)
@@ -404,4 +404,16 @@ extern "C"
404404
}
405405
#endif
406406

407+
#if WIRE_INTERFACES_COUNT > 1
408+
TwoWire Wire1(NRF_TWIM1, NRF_TWIS1, SPIM1_SPIS1_TWIM1_TWIS1_SPI1_TWI1_IRQn, PIN_WIRE1_SDA, PIN_WIRE1_SCL);
409+
410+
extern "C"
411+
{
412+
void SPIM1_SPIS1_TWIM1_TWIS1_SPI1_TWI1_IRQHandler(void)
413+
{
414+
Wire1.onService();
415+
}
416+
}
407417
#endif
418+
419+
#endif // NRF52_SERIES

variants/circuitplayground_nrf52840/variant.h

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,10 +112,13 @@ static const uint8_t SCK = PIN_SPI_SCK ;
112112
/*
113113
* Wire Interfaces
114114
*/
115-
#define WIRE_INTERFACES_COUNT 1
115+
#define WIRE_INTERFACES_COUNT 2
116116

117-
#define PIN_WIRE_SDA (28)
118-
#define PIN_WIRE_SCL (26)
117+
#define PIN_WIRE_SDA (2)
118+
#define PIN_WIRE_SCL (3)
119+
120+
#define PIN_WIRE1_SDA (28)
121+
#define PIN_WIRE1_SCL (26)
119122

120123
// QSPI Pins
121124
#define PIN_QSPI_SCK 29

0 commit comments

Comments
 (0)