Skip to content

Commit

Permalink
rp2/machine_i2c: Use pico-sdk's default pins for I2C.
Browse files Browse the repository at this point in the history
Inherits the default values for whichever instance is PICO_DEFAULT_I2C.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
  • Loading branch information
jimmo authored and dpgeorge committed Sep 8, 2022
1 parent 2943720 commit 315e742
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions ports/rp2/machine_i2c.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,24 @@
#define DEFAULT_I2C_FREQ (400000)

#ifndef MICROPY_HW_I2C0_SCL
#if PICO_DEFAULT_I2C == 0
#define MICROPY_HW_I2C0_SCL (PICO_DEFAULT_I2C_SCL_PIN)
#define MICROPY_HW_I2C0_SDA (PICO_DEFAULT_I2C_SDA_PIN)
#else
#define MICROPY_HW_I2C0_SCL (9)
#define MICROPY_HW_I2C0_SDA (8)
#endif
#endif

#ifndef MICROPY_HW_I2C1_SCL
#if PICO_DEFAULT_I2C == 1
#define MICROPY_HW_I2C1_SCL (PICO_DEFAULT_I2C_SCL_PIN)
#define MICROPY_HW_I2C1_SDA (PICO_DEFAULT_I2C_SDA_PIN)
#else
#define MICROPY_HW_I2C1_SCL (7)
#define MICROPY_HW_I2C1_SDA (6)
#endif
#endif

// SDA/SCL on even/odd pins, I2C0/I2C1 on even/odd pairs of pins.
#define IS_VALID_SCL(i2c, pin) (((pin) & 1) == 1 && (((pin) & 2) >> 1) == (i2c))
Expand Down

0 comments on commit 315e742

Please sign in to comment.