rp2/machine_i2c: Provide more specific error codes from I2C transfer.
Signed-off-by: Damien George <damien@micropython.org>
This commit is contained in:
parent
ce4f8b49ce
commit
7b0a42374e
|
@ -145,11 +145,20 @@ STATIC int machine_i2c_transfer_single(mp_obj_base_t *self_in, uint16_t addr, si
|
|||
ret = mp_machine_soft_i2c_transfer(&soft_i2c.base, addr, 1, &bufs, flags);
|
||||
gpio_set_function(self->scl, GPIO_FUNC_I2C);
|
||||
gpio_set_function(self->sda, GPIO_FUNC_I2C);
|
||||
return ret;
|
||||
} else {
|
||||
ret = i2c_write_blocking(self->i2c_inst, addr, buf, len, nostop);
|
||||
}
|
||||
}
|
||||
return (ret < 0) ? -MP_EIO : ret;
|
||||
if (ret < 0) {
|
||||
if (ret == PICO_ERROR_TIMEOUT) {
|
||||
return -MP_ETIMEDOUT;
|
||||
} else {
|
||||
return -MP_EIO;
|
||||
}
|
||||
} else {
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
STATIC const mp_machine_i2c_p_t machine_i2c_p = {
|
||||
|
|
Loading…
Reference in New Issue