|
35 | 35 |
|
36 | 36 | #if MICROPY_PY_MACHINE_I2C |
37 | 37 |
|
38 | | -typedef struct _machine_i2c_obj_t { |
39 | | - mp_obj_base_t base; |
40 | | - uint32_t us_delay; |
41 | | - uint32_t us_timeout; |
42 | | - mp_hal_pin_obj_t scl; |
43 | | - mp_hal_pin_obj_t sda; |
44 | | -} machine_i2c_obj_t; |
| 38 | +typedef mp_machine_soft_i2c_obj_t machine_i2c_obj_t; |
45 | 39 |
|
46 | 40 | STATIC void mp_hal_i2c_delay(machine_i2c_obj_t *self) { |
47 | 41 | // We need to use an accurate delay to get acceptable I2C |
@@ -188,7 +182,7 @@ STATIC int mp_hal_i2c_read_byte(machine_i2c_obj_t *self, uint8_t *val, int nack) |
188 | 182 | // return value: |
189 | 183 | // >=0 - number of acks received |
190 | 184 | // <0 - error, with errno being the negative of the return value |
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) { |
| 185 | +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 | 186 | machine_i2c_obj_t *self = (machine_i2c_obj_t*)self_in; |
193 | 187 |
|
194 | 188 | // start the I2C transaction |
@@ -234,7 +228,7 @@ STATIC int mp_machine_soft_i2c_writeto(mp_obj_base_t *self_in, uint16_t addr, co |
234 | 228 | // return value: |
235 | 229 | // 0 - success |
236 | 230 | // <0 - error, with errno being the negative of the return value |
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) { |
| 231 | +int mp_machine_soft_i2c_readfrom(mp_obj_base_t *self_in, uint16_t addr, uint8_t *dest, size_t len, bool stop) { |
238 | 232 | machine_i2c_obj_t *self = (machine_i2c_obj_t*)self_in; |
239 | 233 |
|
240 | 234 | // start the I2C transaction |
@@ -582,7 +576,7 @@ STATIC const mp_rom_map_elem_t machine_i2c_locals_dict_table[] = { |
582 | 576 | { MP_ROM_QSTR(MP_QSTR_writeto_mem), MP_ROM_PTR(&machine_i2c_writeto_mem_obj) }, |
583 | 577 | }; |
584 | 578 |
|
585 | | -STATIC MP_DEFINE_CONST_DICT(machine_i2c_locals_dict, machine_i2c_locals_dict_table); |
| 579 | +MP_DEFINE_CONST_DICT(mp_machine_soft_i2c_locals_dict, machine_i2c_locals_dict_table); |
586 | 580 |
|
587 | 581 | int mp_machine_soft_i2c_read(mp_obj_base_t *self_in, uint8_t *dest, size_t len, bool nack) { |
588 | 582 | machine_i2c_obj_t *self = (machine_i2c_obj_t*)self_in; |
@@ -625,7 +619,7 @@ const mp_obj_type_t machine_i2c_type = { |
625 | 619 | .name = MP_QSTR_I2C, |
626 | 620 | .make_new = machine_i2c_make_new, |
627 | 621 | .protocol = &mp_machine_soft_i2c_p, |
628 | | - .locals_dict = (mp_obj_dict_t*)&machine_i2c_locals_dict, |
| 622 | + .locals_dict = (mp_obj_dict_t*)&mp_machine_soft_i2c_locals_dict, |
629 | 623 | }; |
630 | 624 |
|
631 | 625 | #endif // MICROPY_PY_MACHINE_I2C |
0 commit comments