Skip to content

Commit 1e3a735

Browse files
authored
Merge pull request #9132 from mariopesch/main
Update I2C implementation for senseBox MCU-S2 ESP32S2
2 parents e35d277 + f1ced60 commit 1e3a735

File tree

4 files changed

+21
-4
lines changed

4 files changed

+21
-4
lines changed

ports/espressif/boards/sensebox_mcu_esp32s2/mpconfigboard.h

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,20 @@
3131

3232
#define MICROPY_HW_NEOPIXEL (&pin_GPIO1)
3333

34+
#define CIRCUITPY_I2C_ALLOW_INTERNAL_PULL_UP 1
3435

35-
#define DEFAULT_I2C_BUS_SCL (&pin_GPIO40)
36-
#define DEFAULT_I2C_BUS_SDA (&pin_GPIO39)
37-
36+
#define CIRCUITPY_BOARD_I2C (2)
37+
#define CIRCUITPY_BOARD_I2C_PIN {{.scl = &pin_GPIO40, .sda = &pin_GPIO39}, \
38+
{.scl = &pin_GPIO42, .sda = &pin_GPIO45}}
3839
#define DEFAULT_SPI_BUS_SCK (&pin_GPIO36)
3940
#define DEFAULT_SPI_BUS_MOSI (&pin_GPIO35)
4041
#define DEFAULT_SPI_BUS_MISO (&pin_GPIO37)
4142

4243
#define DEFAULT_UART_BUS_RX (&pin_GPIO44)
4344
#define DEFAULT_UART_BUS_TX (&pin_GPIO43)
4445

45-
#define DOUBLE_TAP_PIN (&pin_GPIO0)
46+
#define CIRCUITPY_BOARD_SPI (1)
47+
#define CIRCUITPY_BOARD_SPI_PIN {{.clock = &pin_GPIO36, .mosi = &pin_GPIO35, .miso = &pin_GPIO37}}
48+
49+
#define CIRCUITPY_BOARD_UART (1)
50+
#define CIRCUITPY_BOARD_UART_PIN {{.tx = &pin_GPIO43, .rx = &pin_GPIO44}}

ports/espressif/boards/sensebox_mcu_esp32s2/mpconfigboard.mk

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ CIRCUITPY_ESP_FLASH_FREQ = 80m
1111

1212
CIRCUITPY_ESPCAMERA = 0
1313

14+
CIRCUITPY_REQUIRE_I2C_PULLUPS = 0
15+
CIRCUITPY_I2C_ALLOW_STRAPPING_PINS = 1
1416

1517
# Include these Python libraries in firmware.
1618
FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_NeoPixel

ports/espressif/common-hal/busio/I2C.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,15 @@ void common_hal_busio_i2c_construct(busio_i2c_obj_t *self,
4040
// support I2C on these pins.
4141
//
4242
// 46 is also input-only so it'll never work.
43+
#if CIRCUITPY_I2C_ALLOW_STRAPPING_PINS
44+
if (scl->number == 46 || sda->number == 46) {
45+
raise_ValueError_invalid_pins();
46+
}
47+
#else
4348
if (scl->number == 45 || scl->number == 46 || sda->number == 45 || sda->number == 46) {
4449
raise_ValueError_invalid_pins();
4550
}
51+
#endif
4652

4753
#if CIRCUITPY_REQUIRE_I2C_PULLUPS
4854
// Test that the pins are in a high state. (Hopefully indicating they are pulled up.)

py/circuitpy_mpconfig.mk

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -428,6 +428,10 @@ CFLAGS += -DCIRCUITPY_RE=$(CIRCUITPY_RE)
428428
CIRCUITPY_REQUIRE_I2C_PULLUPS ?= 1
429429
CFLAGS += -DCIRCUITPY_REQUIRE_I2C_PULLUPS=$(CIRCUITPY_REQUIRE_I2C_PULLUPS)
430430

431+
# Allow the use of strapping pins for i2c
432+
CIRCUITPY_I2C_ALLOW_STRAPPING_PINS ?= 0
433+
CFLAGS += -DCIRCUITPY_I2C_ALLOW_STRAPPING_PINS=$(CIRCUITPY_I2C_ALLOW_STRAPPING_PINS)
434+
431435
# CIRCUITPY_RP2PIO is handled in the raspberrypi tree.
432436
# Only for rp2 chips.
433437
# Assume not a rp2 build.

0 commit comments

Comments
 (0)