Skip to content

Commit 4c90561

Browse files
committed
extmod/machine_i2c: Remove trivial function wrappers.
1 parent 37333cb commit 4c90561

1 file changed

Lines changed: 8 additions & 24 deletions

File tree

extmod/machine_i2c.c

Lines changed: 8 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,9 @@ STATIC int mp_hal_i2c_read_byte(machine_i2c_obj_t *self, uint8_t *val, int nack)
188188
// return value:
189189
// >=0 - number of acks received
190190
// <0 - error, with errno being the negative of the return value
191-
STATIC int mp_hal_i2c_write(machine_i2c_obj_t *self, uint8_t addr, const uint8_t *src, size_t len, bool stop) {
191+
STATIC int mp_machine_soft_i2c_writeto(mp_obj_base_t *self_in, uint16_t addr, const uint8_t *src, size_t len, bool stop) {
192+
machine_i2c_obj_t *self = (machine_i2c_obj_t*)self_in;
193+
192194
// start the I2C transaction
193195
int ret = mp_hal_i2c_start(self);
194196
if (ret != 0) {
@@ -232,7 +234,9 @@ STATIC int mp_hal_i2c_write(machine_i2c_obj_t *self, uint8_t addr, const uint8_t
232234
// return value:
233235
// 0 - success
234236
// <0 - error, with errno being the negative of the return value
235-
STATIC int mp_hal_i2c_read(machine_i2c_obj_t *self, uint8_t addr, uint8_t *dest, size_t len, bool stop) {
237+
STATIC int mp_machine_soft_i2c_readfrom(mp_obj_base_t *self_in, uint16_t addr, uint8_t *dest, size_t len, bool stop) {
238+
machine_i2c_obj_t *self = (machine_i2c_obj_t*)self_in;
239+
236240
// start the I2C transaction
237241
int ret = mp_hal_i2c_start(self);
238242
if (ret != 0) {
@@ -580,16 +584,6 @@ STATIC const mp_rom_map_elem_t machine_i2c_locals_dict_table[] = {
580584

581585
STATIC MP_DEFINE_CONST_DICT(machine_i2c_locals_dict, machine_i2c_locals_dict_table);
582586

583-
int mp_machine_soft_i2c_start(mp_obj_base_t *self_in) {
584-
machine_i2c_obj_t *self = (machine_i2c_obj_t*)self_in;
585-
return mp_hal_i2c_start(self);
586-
}
587-
588-
int mp_machine_soft_i2c_stop(mp_obj_base_t *self_in) {
589-
machine_i2c_obj_t *self = (machine_i2c_obj_t*)self_in;
590-
return mp_hal_i2c_stop(self);
591-
}
592-
593587
int mp_machine_soft_i2c_read(mp_obj_base_t *self_in, uint8_t *dest, size_t len, bool nack) {
594588
machine_i2c_obj_t *self = (machine_i2c_obj_t*)self_in;
595589
while (len--) {
@@ -617,19 +611,9 @@ int mp_machine_soft_i2c_write(mp_obj_base_t *self_in, const uint8_t *src, size_t
617611
return num_acks;
618612
}
619613

620-
int mp_machine_soft_i2c_readfrom(mp_obj_base_t *self_in, uint16_t addr, uint8_t *dest, size_t len, bool stop) {
621-
machine_i2c_obj_t *self = (machine_i2c_obj_t*)self_in;
622-
return mp_hal_i2c_read(self, addr, dest, len, stop);
623-
}
624-
625-
int mp_machine_soft_i2c_writeto(mp_obj_base_t *self_in, uint16_t addr, const uint8_t *src, size_t len, bool stop) {
626-
machine_i2c_obj_t *self = (machine_i2c_obj_t*)self_in;
627-
return mp_hal_i2c_write(self, addr, src, len, stop);
628-
}
629-
630614
STATIC const mp_machine_i2c_p_t mp_machine_soft_i2c_p = {
631-
.start = mp_machine_soft_i2c_start,
632-
.stop = mp_machine_soft_i2c_stop,
615+
.start = (int(*)(mp_obj_base_t*))mp_hal_i2c_start,
616+
.stop = (int(*)(mp_obj_base_t*))mp_hal_i2c_stop,
633617
.read = mp_machine_soft_i2c_read,
634618
.write = mp_machine_soft_i2c_write,
635619
.readfrom = mp_machine_soft_i2c_readfrom,

0 commit comments

Comments
 (0)