aboutsummaryrefslogtreecommitdiff
path: root/extmod/machine_i2c.c
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2016-11-23 16:54:52 +1100
committerDamien George <damien.p.george@gmail.com>2016-11-23 17:05:38 +1100
commit4c905616f08fa29d83e2fc2c0b2a5233c998e008 (patch)
tree57335b2acfd1a8b587675bfd6c23faf314568f13 /extmod/machine_i2c.c
parent37333cb00a9e08961045b444a4b090c358e57b1c (diff)
extmod/machine_i2c: Remove trivial function wrappers.
Diffstat (limited to 'extmod/machine_i2c.c')
-rw-r--r--extmod/machine_i2c.c32
1 files changed, 8 insertions, 24 deletions
diff --git a/extmod/machine_i2c.c b/extmod/machine_i2c.c
index 530d0412e..e727f4410 100644
--- a/extmod/machine_i2c.c
+++ b/extmod/machine_i2c.c
@@ -188,7 +188,9 @@ STATIC int mp_hal_i2c_read_byte(machine_i2c_obj_t *self, uint8_t *val, int nack)
// return value:
// >=0 - number of acks received
// <0 - error, with errno being the negative of the return value
-STATIC int mp_hal_i2c_write(machine_i2c_obj_t *self, uint8_t addr, const uint8_t *src, size_t len, bool stop) {
+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) {
+ machine_i2c_obj_t *self = (machine_i2c_obj_t*)self_in;
+
// start the I2C transaction
int ret = mp_hal_i2c_start(self);
if (ret != 0) {
@@ -232,7 +234,9 @@ STATIC int mp_hal_i2c_write(machine_i2c_obj_t *self, uint8_t addr, const uint8_t
// return value:
// 0 - success
// <0 - error, with errno being the negative of the return value
-STATIC int mp_hal_i2c_read(machine_i2c_obj_t *self, uint8_t addr, uint8_t *dest, size_t len, bool stop) {
+STATIC int mp_machine_soft_i2c_readfrom(mp_obj_base_t *self_in, uint16_t addr, uint8_t *dest, size_t len, bool stop) {
+ machine_i2c_obj_t *self = (machine_i2c_obj_t*)self_in;
+
// start the I2C transaction
int ret = mp_hal_i2c_start(self);
if (ret != 0) {
@@ -580,16 +584,6 @@ STATIC const mp_rom_map_elem_t machine_i2c_locals_dict_table[] = {
STATIC MP_DEFINE_CONST_DICT(machine_i2c_locals_dict, machine_i2c_locals_dict_table);
-int mp_machine_soft_i2c_start(mp_obj_base_t *self_in) {
- machine_i2c_obj_t *self = (machine_i2c_obj_t*)self_in;
- return mp_hal_i2c_start(self);
-}
-
-int mp_machine_soft_i2c_stop(mp_obj_base_t *self_in) {
- machine_i2c_obj_t *self = (machine_i2c_obj_t*)self_in;
- return mp_hal_i2c_stop(self);
-}
-
int mp_machine_soft_i2c_read(mp_obj_base_t *self_in, uint8_t *dest, size_t len, bool nack) {
machine_i2c_obj_t *self = (machine_i2c_obj_t*)self_in;
while (len--) {
@@ -617,19 +611,9 @@ int mp_machine_soft_i2c_write(mp_obj_base_t *self_in, const uint8_t *src, size_t
return num_acks;
}
-int mp_machine_soft_i2c_readfrom(mp_obj_base_t *self_in, uint16_t addr, uint8_t *dest, size_t len, bool stop) {
- machine_i2c_obj_t *self = (machine_i2c_obj_t*)self_in;
- return mp_hal_i2c_read(self, addr, dest, len, stop);
-}
-
-int mp_machine_soft_i2c_writeto(mp_obj_base_t *self_in, uint16_t addr, const uint8_t *src, size_t len, bool stop) {
- machine_i2c_obj_t *self = (machine_i2c_obj_t*)self_in;
- return mp_hal_i2c_write(self, addr, src, len, stop);
-}
-
STATIC const mp_machine_i2c_p_t mp_machine_soft_i2c_p = {
- .start = mp_machine_soft_i2c_start,
- .stop = mp_machine_soft_i2c_stop,
+ .start = (int(*)(mp_obj_base_t*))mp_hal_i2c_start,
+ .stop = (int(*)(mp_obj_base_t*))mp_hal_i2c_stop,
.read = mp_machine_soft_i2c_read,
.write = mp_machine_soft_i2c_write,
.readfrom = mp_machine_soft_i2c_readfrom,