diff --git a/cores/nRF5/nordic/nrfx_config.h b/cores/nRF5/nordic/nrfx_config.h index 4d44420b..1a69f708 100644 --- a/cores/nRF5/nordic/nrfx_config.h +++ b/cores/nRF5/nordic/nrfx_config.h @@ -10,7 +10,7 @@ #define NRFX_SPIM_MISO_PULL_CFG 1 // pulldown #define NRFX_SPIM_EXTENDED_ENABLED 0 -#define NRFX_SPIM0_ENABLED 1 +#define NRFX_SPIM0_ENABLED 0 // used as I2C #define NRFX_SPIM1_ENABLED 1 #define NRFX_SPIM2_ENABLED 1 diff --git a/libraries/SPI/SPI.cpp b/libraries/SPI/SPI.cpp index 4e113e66..83e2eb6c 100644 --- a/libraries/SPI/SPI.cpp +++ b/libraries/SPI/SPI.cpp @@ -31,9 +31,8 @@ SPIClass::SPIClass(NRF_SPIM_Type *p_spi, uint8_t uc_pinMISO, uint8_t uc_pinSCK, _spim.p_reg = p_spi; - if ( NRF_SPIM0 == p_spi ) { - _spim.drv_inst_idx = NRFX_SPIM0_INST_IDX; - } else if ( NRF_SPIM1 == p_spi ) { + // NRF_SPIM0 is used for I2C + if ( NRF_SPIM1 == p_spi ) { _spim.drv_inst_idx = NRFX_SPIM1_INST_IDX; } else if ( NRF_SPIM2 == p_spi ) { _spim.drv_inst_idx = NRFX_SPIM2_INST_IDX; @@ -213,15 +212,17 @@ void SPIClass::detachInterrupt() { // Should be disableInterrupt() } +// SPIM0 is used as I2C + #if SPI_INTERFACES_COUNT > 0 #ifdef NRF52840_XXAA // use SPIM3 for nrf52840 for highspeed 32Mhz SPIClass SPI(NRF_SPIM3, PIN_SPI_MISO, PIN_SPI_SCK, PIN_SPI_MOSI); #else - SPIClass SPI(NRF_SPIM0, PIN_SPI_MISO, PIN_SPI_SCK, PIN_SPI_MOSI); + SPIClass SPI(NRF_SPIM1, PIN_SPI_MISO, PIN_SPI_SCK, PIN_SPI_MOSI); #endif #endif #if SPI_INTERFACES_COUNT > 1 -SPIClass SPI1(NRF_SPIM1, PIN_SPI1_MISO, PIN_SPI1_SCK, PIN_SPI1_MOSI); +SPIClass SPI1(NRF_SPIM2, PIN_SPI1_MISO, PIN_SPI1_SCK, PIN_SPI1_MOSI); #endif diff --git a/libraries/Wire/Wire_nRF52.cpp b/libraries/Wire/Wire_nRF52.cpp index fa5666e4..e593cedc 100755 --- a/libraries/Wire/Wire_nRF52.cpp +++ b/libraries/Wire/Wire_nRF52.cpp @@ -392,12 +392,12 @@ void TwoWire::onService(void) } } -TwoWire Wire(NRF_TWIM1, NRF_TWIS1, SPIM1_SPIS1_TWIM1_TWIS1_SPI1_TWI1_IRQn, PIN_WIRE_SDA, PIN_WIRE_SCL); +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 SPIM1_SPIS1_TWIM1_TWIS1_SPI1_TWI1_IRQHandler(void) + void SPIM0_SPIS0_TWIM0_TWIS0_SPI0_TWI0_IRQHandler(void) { Wire.onService(); }