Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix write_then_readinto in adafruit_bus_device I2CDevice #4146

Merged
merged 1 commit into from
Feb 8, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 12 additions & 11 deletions shared-bindings/adafruit_bus_device/I2CDevice.c
Original file line number Diff line number Diff line change
Expand Up @@ -234,23 +234,24 @@ STATIC mp_obj_t adafruit_bus_device_i2cdevice_write_then_readinto(size_t n_args,

mp_obj_t dest[13];
uint8_t num_kws = 2;
uint8_t index = 2;

mp_load_method(self->i2c, MP_QSTR_writeto_then_readfrom, dest);
dest[2] = MP_OBJ_NEW_SMALL_INT(self->device_address);
dest[3] = args[ARG_out_buffer].u_obj;
dest[4] = args[ARG_in_buffer].u_obj;
dest[5] = MP_OBJ_NEW_QSTR(MP_QSTR_out_start);
dest[6] = MP_OBJ_NEW_SMALL_INT(args[ARG_out_start].u_int);
dest[index++] = MP_OBJ_NEW_SMALL_INT(self->device_address);
dest[index++] = args[ARG_out_buffer].u_obj;
dest[index++] = args[ARG_in_buffer].u_obj;
dest[index++] = MP_OBJ_NEW_QSTR(MP_QSTR_out_start);
dest[index++] = MP_OBJ_NEW_SMALL_INT(args[ARG_out_start].u_int);
if (args[ARG_out_end].u_int != INT_MAX) {
dest[7] = MP_OBJ_NEW_QSTR(MP_QSTR_out_end);
dest[8] = MP_OBJ_NEW_SMALL_INT(args[ARG_out_end].u_int);
dest[index++] = MP_OBJ_NEW_QSTR(MP_QSTR_out_end);
dest[index++] = MP_OBJ_NEW_SMALL_INT(args[ARG_out_end].u_int);
num_kws++;
}
dest[9] = MP_OBJ_NEW_QSTR(MP_QSTR_in_start);
dest[10] = MP_OBJ_NEW_SMALL_INT(args[ARG_in_start].u_int);
dest[index++] = MP_OBJ_NEW_QSTR(MP_QSTR_in_start);
dest[index++] = MP_OBJ_NEW_SMALL_INT(args[ARG_in_start].u_int);
if (args[ARG_in_end].u_int != INT_MAX) {
dest[11] = MP_OBJ_NEW_QSTR(MP_QSTR_in_end);
dest[12] = MP_OBJ_NEW_SMALL_INT(args[ARG_in_end].u_int);
dest[index++] = MP_OBJ_NEW_QSTR(MP_QSTR_in_end);
dest[index++] = MP_OBJ_NEW_SMALL_INT(args[ARG_in_end].u_int);
num_kws++;
}

Expand Down