@@ -73,9 +73,6 @@ void common_hal_busio_i2c_construct(busio_i2c_obj_t *self,
7373 mp_raise_ValueError (MP_ERROR_TEXT ("All I2C peripherals are in use" ));
7474 }
7575
76- // Delete any previous driver.
77- i2c_driver_delete (self -> i2c_num );
78-
7976 const i2c_config_t i2c_conf = {
8077 .mode = I2C_MODE_MASTER ,
8178 .sda_io_num = self -> sda_pin -> number ,
@@ -136,7 +133,7 @@ static esp_err_t i2c_zero_length_write(busio_i2c_obj_t *self, uint8_t addr, Tick
136133}
137134
138135bool common_hal_busio_i2c_probe (busio_i2c_obj_t * self , uint8_t addr ) {
139- esp_err_t result = i2c_zero_length_write (self , addr , 1 );
136+ esp_err_t result = i2c_zero_length_write (self , addr , pdMS_TO_TICKS ( 10 ) );
140137 return result == ESP_OK ;
141138}
142139
@@ -175,21 +172,21 @@ static uint8_t convert_esp_err(esp_err_t result) {
175172
176173uint8_t common_hal_busio_i2c_write (busio_i2c_obj_t * self , uint16_t addr , const uint8_t * data , size_t len ) {
177174 return convert_esp_err (len == 0
178- ? i2c_zero_length_write (self , addr , 100 )
179- : i2c_master_write_to_device (self -> i2c_num , (uint8_t )addr , data , len , 100 /* wait in ticks */ )
175+ ? i2c_zero_length_write (self , addr , pdMS_TO_TICKS ( 1000 ) )
176+ : i2c_master_write_to_device (self -> i2c_num , (uint8_t )addr , data , len , pdMS_TO_TICKS ( 1000 ) )
180177 );
181178}
182179
183180uint8_t common_hal_busio_i2c_read (busio_i2c_obj_t * self , uint16_t addr , uint8_t * data , size_t len ) {
184181 return convert_esp_err (
185- i2c_master_read_from_device (self -> i2c_num , (uint8_t )addr , data , len , 100 /* wait in ticks */ ));
182+ i2c_master_read_from_device (self -> i2c_num , (uint8_t )addr , data , len , pdMS_TO_TICKS ( 1000 ) ));
186183}
187184
188185uint8_t common_hal_busio_i2c_write_read (busio_i2c_obj_t * self , uint16_t addr ,
189186 uint8_t * out_data , size_t out_len , uint8_t * in_data , size_t in_len ) {
190187 return convert_esp_err (
191188 i2c_master_write_read_device (self -> i2c_num , (uint8_t )addr ,
192- out_data , out_len , in_data , in_len , 100 /* wait in ticks */ ));
189+ out_data , out_len , in_data , in_len , pdMS_TO_TICKS ( 1000 ) ));
193190}
194191
195192void common_hal_busio_i2c_never_reset (busio_i2c_obj_t * self ) {
0 commit comments