summaryrefslogtreecommitdiffstatshomepage
path: root/extmod/machine_i2c.h
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2016-11-22 22:49:54 +1100
committerDamien George <damien.p.george@gmail.com>2016-11-23 17:05:37 +1100
commitb983cfaf41b94aeb0cb1404d654c26d3a6893a4e (patch)
tree80864d53046d33f9a1ef15fd28fe62fcfcdb142b /extmod/machine_i2c.h
parent63a5df3cb4c5dec1cb84b86750bb87ace4c1629e (diff)
downloadmicropython-b983cfaf41b94aeb0cb1404d654c26d3a6893a4e.tar.gz
micropython-b983cfaf41b94aeb0cb1404d654c26d3a6893a4e.zip
extmod/machine_i2c: Add a C-level I2C-protocol, refactoring soft I2C.
Diffstat (limited to 'extmod/machine_i2c.h')
-rw-r--r--extmod/machine_i2c.h11
1 files changed, 11 insertions, 0 deletions
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__