rp2/machine_i2c: Use pico-sdk's default pins for I2C.

Inherits the default values for whichever instance is PICO_DEFAULT_I2C.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
This commit is contained in:
Jim Mussared 2022-09-06 23:28:50 +10:00 committed by Damien George
parent 29437205f2
commit 315e74236f

View File

@ -35,14 +35,24 @@
#define DEFAULT_I2C_FREQ (400000) #define DEFAULT_I2C_FREQ (400000)
#ifndef MICROPY_HW_I2C0_SCL #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_SCL (9)
#define MICROPY_HW_I2C0_SDA (8) #define MICROPY_HW_I2C0_SDA (8)
#endif #endif
#endif
#ifndef MICROPY_HW_I2C1_SCL #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_SCL (7)
#define MICROPY_HW_I2C1_SDA (6) #define MICROPY_HW_I2C1_SDA (6)
#endif #endif
#endif
// SDA/SCL on even/odd pins, I2C0/I2C1 on even/odd pairs of pins. // 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)) #define IS_VALID_SCL(i2c, pin) (((pin) & 1) == 1 && (((pin) & 2) >> 1) == (i2c))