From b983cfaf41b94aeb0cb1404d654c26d3a6893a4e Mon Sep 17 00:00:00 2001 From: Damien George Date: Tue, 22 Nov 2016 22:49:54 +1100 Subject: extmod/machine_i2c: Add a C-level I2C-protocol, refactoring soft I2C. --- extmod/machine_i2c.h | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'extmod/machine_i2c.h') diff --git a/extmod/machine_i2c.h b/extmod/machine_i2c.h index 03fa6422ad..c971f4b195 100644 --- a/extmod/machine_i2c.h +++ b/extmod/machine_i2c.h @@ -29,6 +29,17 @@ #include "py/obj.h" +// I2C protocol +// the first 4 methods can be NULL, meaning operation is not supported +typedef struct _mp_machine_i2c_p_t { + int (*start)(mp_obj_base_t *obj); + int (*stop)(mp_obj_base_t *obj); + int (*read)(mp_obj_base_t *obj, uint8_t *dest, size_t len); + int (*write)(mp_obj_base_t *obj, const uint8_t *src, size_t len); + int (*readfrom)(mp_obj_base_t *obj, uint16_t addr, uint8_t *dest, size_t len, bool stop); + int (*writeto)(mp_obj_base_t *obj, uint16_t addr, const uint8_t *src, size_t len, bool stop); +} mp_machine_i2c_p_t; + extern const mp_obj_type_t machine_i2c_type; #endif // __MICROPY_INCLUDED_EXTMOD_MACHINE_I2C_H__ -- cgit v1.2.3