summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2016-11-23 12:26:37 +1100
committerDamien George <damien.p.george@gmail.com>2016-11-23 17:05:38 +1100
commit946f8dd46f5421a6f4c750748891f225846ec3d2 (patch)
treedf30f8e6aa035a32191afa8f28178b28b81c81f7
parent96c3911a0a661a3819d6fffe9886b4f799248279 (diff)
downloadmicropython-946f8dd46f5421a6f4c750748891f225846ec3d2.tar.gz
micropython-946f8dd46f5421a6f4c750748891f225846ec3d2.zip
extmod/machine_i2c: Remove unneeded i2c_write_mem/i2c_read_mem funcs.
-rw-r--r--extmod/machine_i2c.c44
1 files changed, 4 insertions, 40 deletions
diff --git a/extmod/machine_i2c.c b/extmod/machine_i2c.c
index 39c1b962be..3153e0f5a9 100644
--- a/extmod/machine_i2c.c
+++ b/extmod/machine_i2c.c
@@ -168,29 +168,14 @@ STATIC int mp_hal_i2c_read_byte(machine_i2c_obj_t *self, uint8_t *val, int nack)
return 1; // success
}
-// addr is the device address, memaddr is a memory address sent big-endian
-STATIC int mp_hal_i2c_write_addresses(machine_i2c_obj_t *self, uint8_t addr,
- uint32_t memaddr, uint8_t addrsize) {
- if (!mp_hal_i2c_write_byte(self, addr << 1)) {
- return 0; // error
- }
- for (int16_t i = addrsize - 8; i >= 0; i -= 8) {
- if (!mp_hal_i2c_write_byte(self, memaddr >> i)) {
- return 0; // error
- }
- }
- return 1; // success
-}
-
-STATIC void mp_hal_i2c_write_mem(machine_i2c_obj_t *self, uint8_t addr,
- uint32_t memaddr, uint8_t addrsize, const uint8_t *src, size_t len, bool stop) {
+STATIC void mp_hal_i2c_write(machine_i2c_obj_t *self, uint8_t addr, const uint8_t *src, size_t len, bool stop) {
// start the I2C transaction
if (!mp_hal_i2c_start(self)) {
goto er;
}
- // write the slave address and the memory address within the slave
- if (!mp_hal_i2c_write_addresses(self, addr, memaddr, addrsize)) {
+ // write the slave address
+ if (!mp_hal_i2c_write_byte(self, addr << 1)) {
goto er;
}
@@ -212,25 +197,12 @@ er:
nlr_raise(mp_obj_new_exception_msg(&mp_type_OSError, "I2C bus error"));
}
-STATIC void mp_hal_i2c_read_mem(machine_i2c_obj_t *self, uint8_t addr,
- uint32_t memaddr, uint8_t addrsize, uint8_t *dest, size_t len, bool stop) {
+STATIC void mp_hal_i2c_read(machine_i2c_obj_t *self, uint8_t addr, uint8_t *dest, size_t len, bool stop) {
// start the I2C transaction
if (!mp_hal_i2c_start(self)) {
goto er;
}
- if (addrsize) {
- // write the slave address and the memory address within the slave
- if (!mp_hal_i2c_write_addresses(self, addr, memaddr, addrsize)) {
- goto er;
- }
-
- // i2c_read will do a repeated start, and then read the I2C memory
- if (!mp_hal_i2c_start(self)) {
- goto er;
- }
- }
-
if (!mp_hal_i2c_write_byte(self, (addr << 1) | 1)) {
goto er;
}
@@ -249,14 +221,6 @@ er:
nlr_raise(mp_obj_new_exception_msg(&mp_type_OSError, "I2C bus error"));
}
-STATIC void mp_hal_i2c_write(machine_i2c_obj_t *self, uint8_t addr, const uint8_t *src, size_t len, bool stop) {
- mp_hal_i2c_write_mem(self, addr, 0, 0, src, len, stop);
-}
-
-STATIC void mp_hal_i2c_read(machine_i2c_obj_t *self, uint8_t addr, uint8_t *dest, size_t len, bool stop) {
- mp_hal_i2c_read_mem(self, addr, 0, 0, dest, len, stop);
-}
-
/******************************************************************************/
// MicroPython bindings for I2C