mirror of
https://github.com/esphome/esphome.git
synced 2026-07-11 01:15:33 +00:00
Add datasheet references for RP2040/RP2350 I2C pin mapping
This commit is contained in:
@@ -94,7 +94,13 @@ def _bus_declare_type(value):
|
||||
|
||||
|
||||
def _rp2040_i2c_controller(pin):
|
||||
"""Return the I2C controller number (0 or 1) for a given RP2040/RP2350 GPIO pin."""
|
||||
"""Return the I2C controller number (0 or 1) for a given RP2040/RP2350 GPIO pin.
|
||||
|
||||
See RP2040 datasheet Table 2 (section 1.4.3, "GPIO Functions"):
|
||||
https://datasheets.raspberrypi.com/rp2040/rp2040-datasheet.pdf
|
||||
See RP2350 datasheet Table 7 (section 9.4, "Function Select"):
|
||||
https://datasheets.raspberrypi.com/rp2350/rp2350-datasheet.pdf
|
||||
"""
|
||||
return (pin // 2) % 2
|
||||
|
||||
|
||||
|
||||
@@ -22,7 +22,8 @@ void ArduinoI2CBus::setup() {
|
||||
#elif defined(USE_RP2040)
|
||||
// Select Wire instance based on pin assignment, not definition order.
|
||||
// RP2040 I2C controller is determined by GPIO: (pin / 2) % 2
|
||||
// I2C0 SDA: GPIO 0,4,8,12,16,20,24,28 I2C1 SDA: GPIO 2,6,10,14,18,22,26
|
||||
// See RP2040 datasheet Table 2 (section 1.4.3): https://datasheets.raspberrypi.com/rp2040/rp2040-datasheet.pdf
|
||||
// See RP2350 datasheet Table 7 (section 9.4): https://datasheets.raspberrypi.com/rp2350/rp2350-datasheet.pdf
|
||||
if ((this->sda_pin_ / 2) % 2 == 0) {
|
||||
wire_ = &Wire;
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user