@@ -59,11 +59,11 @@ void common_hal_busio_i2c_construct(busio_i2c_obj_t *self,
5959 sda -> sercom [i ].pad != 0 ) {
6060 continue ;
6161 }
62- sda_pinmux = PINMUX (sda -> pin , (i == 0 ) ? MUX_C : MUX_D );
62+ sda_pinmux = PINMUX (sda -> number , (i == 0 ) ? MUX_C : MUX_D );
6363 for (int j = 0 ; j < NUM_SERCOMS_PER_PIN ; j ++ ) {
6464 if (sercom_index == scl -> sercom [j ].index &&
6565 scl -> sercom [j ].pad == 1 ) {
66- scl_pinmux = PINMUX (scl -> pin , (j == 0 ) ? MUX_C : MUX_D );
66+ scl_pinmux = PINMUX (scl -> number , (j == 0 ) ? MUX_C : MUX_D );
6767 sercom = potential_sercom ;
6868 break ;
6969 }
@@ -77,50 +77,50 @@ void common_hal_busio_i2c_construct(busio_i2c_obj_t *self,
7777 }
7878
7979 // Test that the pins are in a high state. (Hopefully indicating they are pulled up.)
80- gpio_set_pin_function (sda -> pin , GPIO_PIN_FUNCTION_OFF );
81- gpio_set_pin_function (scl -> pin , GPIO_PIN_FUNCTION_OFF );
82- gpio_set_pin_direction (sda -> pin , GPIO_DIRECTION_IN );
83- gpio_set_pin_direction (scl -> pin , GPIO_DIRECTION_IN );
80+ gpio_set_pin_function (sda -> number , GPIO_PIN_FUNCTION_OFF );
81+ gpio_set_pin_function (scl -> number , GPIO_PIN_FUNCTION_OFF );
82+ gpio_set_pin_direction (sda -> number , GPIO_DIRECTION_IN );
83+ gpio_set_pin_direction (scl -> number , GPIO_DIRECTION_IN );
8484
85- gpio_set_pin_pull_mode (sda -> pin , GPIO_PULL_DOWN );
86- gpio_set_pin_pull_mode (scl -> pin , GPIO_PULL_DOWN );
85+ gpio_set_pin_pull_mode (sda -> number , GPIO_PULL_DOWN );
86+ gpio_set_pin_pull_mode (scl -> number , GPIO_PULL_DOWN );
8787
8888 common_hal_mcu_delay_us (10 );
8989
90- gpio_set_pin_pull_mode (sda -> pin , GPIO_PULL_OFF );
91- gpio_set_pin_pull_mode (scl -> pin , GPIO_PULL_OFF );
90+ gpio_set_pin_pull_mode (sda -> number , GPIO_PULL_OFF );
91+ gpio_set_pin_pull_mode (scl -> number , GPIO_PULL_OFF );
9292
9393 // We must pull up within 3us to achieve 400khz.
9494 common_hal_mcu_delay_us (3 );
9595
96- if (!gpio_get_pin_level (sda -> pin ) || !gpio_get_pin_level (scl -> pin )) {
97- reset_pin (sda -> pin );
98- reset_pin (scl -> pin );
96+ if (!gpio_get_pin_level (sda -> number ) || !gpio_get_pin_level (scl -> number )) {
97+ reset_pin (sda -> number );
98+ reset_pin (scl -> number );
9999 mp_raise_RuntimeError ("SDA or SCL needs a pull up" );
100100 }
101- gpio_set_pin_function (sda -> pin , sda_pinmux );
102- gpio_set_pin_function (scl -> pin , scl_pinmux );
101+ gpio_set_pin_function (sda -> number , sda_pinmux );
102+ gpio_set_pin_function (scl -> number , scl_pinmux );
103103
104104 // Set up I2C clocks on sercom.
105105 samd_peripherals_sercom_clock_init (sercom , sercom_index );
106106
107107 if (i2c_m_sync_init (& self -> i2c_desc , sercom ) != ERR_NONE ) {
108- reset_pin (sda -> pin );
109- reset_pin (scl -> pin );
108+ reset_pin (sda -> number );
109+ reset_pin (scl -> number );
110110 mp_raise_OSError (MP_EIO );
111111 }
112112
113113 // clkrate is always 0. baud_rate is in kHz.
114114
115115 // Frequency must be set before the I2C device is enabled.
116116 if (i2c_m_sync_set_baudrate (& self -> i2c_desc , 0 , frequency / 1000 ) != ERR_NONE ) {
117- reset_pin (sda -> pin );
118- reset_pin (scl -> pin );
117+ reset_pin (sda -> number );
118+ reset_pin (scl -> number );
119119 mp_raise_ValueError ("Unsupported baudrate" );
120120 }
121121
122- self -> sda_pin = sda -> pin ;
123- self -> scl_pin = scl -> pin ;
122+ self -> sda_pin = sda -> number ;
123+ self -> scl_pin = scl -> number ;
124124 claim_pin (sda );
125125 claim_pin (scl );
126126
0 commit comments