Skip to content

Commit 0bed256

Browse files
committed
Fix I2C pullups on Nano33BLE sensors
1 parent d2cca06 commit 0bed256

File tree

7 files changed

+19
-5
lines changed

7 files changed

+19
-5
lines changed

libraries/SPI/SPI.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ void arduino::MbedSPI::end() {
5959

6060
#if DEVICE_SPI > 0
6161
arduino::MbedSPI SPI(SPI_MISO, SPI_MOSI, SPI_SCK);
62-
#elif DEVICE_SPI > 1
62+
#endif
63+
#if DEVICE_SPI > 1
6364
arduino::MbedSPI SPI1(SPI_MISO1, SPI_MOSI1, SPI_SCK1);
6465
#endif

libraries/SPI/SPI.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ class MbedSPI : public SPIClass
3838

3939
#if DEVICE_SPI > 0
4040
extern arduino::MbedSPI SPI;
41-
#elif DEVICE_SPI > 1
41+
#endif
42+
#if DEVICE_SPI > 1
4243
extern arduino::MbedSPI SPI1;
4344
#endif

libraries/Wire/Wire.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ void arduino::MbedI2C::onRequest(void(*)(void)) {}
104104

105105
#if DEVICE_I2C > 0
106106
arduino::MbedI2C Wire(I2C_SDA, I2C_SCL);
107-
#elif DEVICE_I2C > 1
107+
#endif
108+
#if DEVICE_I2C > 1
108109
arduino::MbedI2C Wire1(I2C_SDA1, I2C_SCL1);;
109110
#endif

libraries/Wire/Wire.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,9 @@ class MbedI2C : public HardwareI2C
6868

6969
#if DEVICE_I2C > 0
7070
extern arduino::MbedI2C Wire;
71+
#endif
7172
#if DEVICE_I2C > 1
7273
extern arduino::MbedI2C Wire1;
7374
#endif
74-
#endif
7575

7676
typedef arduino::MbedI2C TwoWire;

variants/ARDUINO_NANO33BLE/defines.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
-D__CORTEX_M4
1212
-DDEVICE_ANALOGIN=1
1313
-DDEVICE_FLASH=1
14-
-DDEVICE_I2C=1
14+
-DDEVICE_I2C=2
1515
-DDEVICE_I2C_ASYNCH=1
1616
-DDEVICE_INTERRUPTIN=1
1717
-DDEVICE_ITM=1

variants/ARDUINO_NANO33BLE/pins_arduino.h

+3
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,9 @@ static const uint8_t SCK = PIN_SPI_SCK;
7878
#define PIN_WIRE_SDA1 (30u)
7979
#define PIN_WIRE_SCL1 (31u)
8080

81+
#define PIN_ENABLE_SENSORS_3V3 (32u)
82+
#define PIN_ENABLE_I2C_PULLUP (33u)
83+
8184
#define PIN_INT_APDS (26u)
8285

8386
// PDM Interfaces

variants/ARDUINO_NANO33BLE/variant.cpp

+8
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,14 @@ void initVariant() {
6666
// was being enabled by nrfx_clock_anomaly_132
6767
CoreDebug->DEMCR = 0;
6868
NRF_CLOCK->TRACECONFIG = 0;
69+
70+
// FIXME: always enable I2C pullup and power @startup
71+
// Change for maximum powersave
72+
pinMode(PIN_ENABLE_SENSORS_3V3, OUTPUT);
73+
pinMode(PIN_ENABLE_I2C_PULLUP, OUTPUT);
74+
75+
digitalWrite(PIN_ENABLE_SENSORS_3V3, HIGH);
76+
digitalWrite(PIN_ENABLE_I2C_PULLUP, HIGH);
6977
}
7078

7179
#ifdef SERIAL_CDC

0 commit comments

Comments
 (0)