Skip to content

Commit f1e9877

Browse files
committed
change I2C to use NRF_TWIM0/SPIM0 instead of NRF_TWIM1/SPIM1 for simplicity
1 parent 3d2bd10 commit f1e9877

File tree

3 files changed

+9
-8
lines changed

3 files changed

+9
-8
lines changed

cores/nRF5/nordic/nrfx_config.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
#define NRFX_SPIM_MISO_PULL_CFG 1 // pulldown
1111
#define NRFX_SPIM_EXTENDED_ENABLED 0
1212

13-
#define NRFX_SPIM0_ENABLED 1
13+
#define NRFX_SPIM0_ENABLED 0 // used as I2C
1414
#define NRFX_SPIM1_ENABLED 1
1515
#define NRFX_SPIM2_ENABLED 1
1616

libraries/SPI/SPI.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,8 @@ SPIClass::SPIClass(NRF_SPIM_Type *p_spi, uint8_t uc_pinMISO, uint8_t uc_pinSCK,
3131

3232
_spim.p_reg = p_spi;
3333

34-
if ( NRF_SPIM0 == p_spi ) {
35-
_spim.drv_inst_idx = NRFX_SPIM0_INST_IDX;
36-
} else if ( NRF_SPIM1 == p_spi ) {
34+
// NRF_SPIM0 is used for I2C
35+
if ( NRF_SPIM1 == p_spi ) {
3736
_spim.drv_inst_idx = NRFX_SPIM1_INST_IDX;
3837
} else if ( NRF_SPIM2 == p_spi ) {
3938
_spim.drv_inst_idx = NRFX_SPIM2_INST_IDX;
@@ -213,15 +212,17 @@ void SPIClass::detachInterrupt() {
213212
// Should be disableInterrupt()
214213
}
215214

215+
// SPIM0 is used as I2C
216+
216217
#if SPI_INTERFACES_COUNT > 0
217218
#ifdef NRF52840_XXAA
218219
// use SPIM3 for nrf52840 for highspeed 32Mhz
219220
SPIClass SPI(NRF_SPIM3, PIN_SPI_MISO, PIN_SPI_SCK, PIN_SPI_MOSI);
220221
#else
221-
SPIClass SPI(NRF_SPIM0, PIN_SPI_MISO, PIN_SPI_SCK, PIN_SPI_MOSI);
222+
SPIClass SPI(NRF_SPIM1, PIN_SPI_MISO, PIN_SPI_SCK, PIN_SPI_MOSI);
222223
#endif
223224
#endif
224225

225226
#if SPI_INTERFACES_COUNT > 1
226-
SPIClass SPI1(NRF_SPIM1, PIN_SPI1_MISO, PIN_SPI1_SCK, PIN_SPI1_MOSI);
227+
SPIClass SPI1(NRF_SPIM2, PIN_SPI1_MISO, PIN_SPI1_SCK, PIN_SPI1_MOSI);
227228
#endif

libraries/Wire/Wire_nRF52.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -392,12 +392,12 @@ void TwoWire::onService(void)
392392
}
393393
}
394394

395-
TwoWire Wire(NRF_TWIM1, NRF_TWIS1, SPIM1_SPIS1_TWIM1_TWIS1_SPI1_TWI1_IRQn, PIN_WIRE_SDA, PIN_WIRE_SCL);
395+
TwoWire Wire(NRF_TWIM0, NRF_TWIS0, SPIM0_SPIS0_TWIM0_TWIS0_SPI0_TWI0_IRQn, PIN_WIRE_SDA, PIN_WIRE_SCL);
396396

397397
#if WIRE_INTERFACES_COUNT > 0
398398
extern "C"
399399
{
400-
void SPIM1_SPIS1_TWIM1_TWIS1_SPI1_TWI1_IRQHandler(void)
400+
void SPIM0_SPIS0_TWIM0_TWIS0_SPI0_TWI0_IRQHandler(void)
401401
{
402402
Wire.onService();
403403
}

0 commit comments

Comments
 (0)