change I2C to use NRF_TWIM0/SPIM0 instead of NRF_TWIM1/SPIM1 for simplicity

This commit is contained in:
hathach committed 2019-10-16 22:47:00 +07:00
1 parent 3d2bd10671
commit f1e9877408
3 files changed
+9 -8

No files matched your search

+1 -1
View File
@@ -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
+6 -5
View File
@@ -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
+2 -2
View File
@@ -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();
}