summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorScott Shawcroft <scott@tannewt.org>2019-08-23 12:13:11 -0700
committerScott Shawcroft <scott@tannewt.org>2019-08-23 12:13:11 -0700
commit5662b5813e477a515dc3252fef29d6a92d338a4b (patch)
tree3726eb5b0084705a273bd506daae453725298883
parent82d436d05e600ab386f43652f865f59b4361f888 (diff)
Use size_t and document buffers can be the same.
-rw-r--r--shared-bindings/bitbangio/I2C.c7
-rw-r--r--shared-bindings/busio/I2C.c7
2 files changed, 8 insertions, 6 deletions
diff --git a/shared-bindings/bitbangio/I2C.c b/shared-bindings/bitbangio/I2C.c
index a6276dca0..01a128393 100644
--- a/shared-bindings/bitbangio/I2C.c
+++ b/shared-bindings/bitbangio/I2C.c
@@ -180,7 +180,7 @@ STATIC void readfrom(bitbangio_i2c_obj_t *self, mp_int_t address, mp_obj_t buffe
mp_buffer_info_t bufinfo;
mp_get_buffer_raise(buffer, &bufinfo, MP_BUFFER_WRITE);
- uint32_t length = bufinfo.len;
+ size_t length = bufinfo.len;
normalize_buffer_bounds(&start, end, &length);
if (length == 0) {
mp_raise_ValueError(translate("Buffer must be at least length 1"));
@@ -238,7 +238,7 @@ STATIC void writeto(bitbangio_i2c_obj_t *self, mp_int_t address, mp_obj_t buffer
mp_buffer_info_t bufinfo;
mp_get_buffer_raise(buffer, &bufinfo, MP_BUFFER_READ);
- uint32_t length = bufinfo.len;
+ size_t length = bufinfo.len;
normalize_buffer_bounds(&start, end, &length);
// do the transfer
@@ -275,7 +275,8 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_KW(bitbangio_i2c_writeto_obj, 1, bitbangio_i2c_wr
//| .. method:: writeto_then_readfrom(address, out_buffer, in_buffer, *, out_start=0, out_end=None, in_start=0, in_end=None)
//|
//| Write the bytes from ``out_buffer`` to the slave specified by ``address``, generate no stop
-//| bit, generate a repeated start and read into ``in_buffer``.
+//| bit, generate a repeated start and read into ``in_buffer``. ``out_buffer`` and
+//| ``in_buffer`` can be the same buffer because they are used sequentially.
//|
//| If ``start`` or ``end`` is provided, then the corresponding buffer will be sliced
//| as if ``buffer[start:end]``. This will not cause an allocation like ``buf[start:end]``
diff --git a/shared-bindings/busio/I2C.c b/shared-bindings/busio/I2C.c
index f3c1503ed..3bd89e2e2 100644
--- a/shared-bindings/busio/I2C.c
+++ b/shared-bindings/busio/I2C.c
@@ -194,7 +194,7 @@ STATIC void readfrom(busio_i2c_obj_t *self, mp_int_t address, mp_obj_t buffer, i
mp_buffer_info_t bufinfo;
mp_get_buffer_raise(buffer, &bufinfo, MP_BUFFER_WRITE);
- uint32_t length = bufinfo.len;
+ size_t length = bufinfo.len;
normalize_buffer_bounds(&start, end, &length);
if (length == 0) {
mp_raise_ValueError(translate("Buffer must be at least length 1"));
@@ -253,7 +253,7 @@ STATIC void writeto(busio_i2c_obj_t *self, mp_int_t address, mp_obj_t buffer, in
mp_buffer_info_t bufinfo;
mp_get_buffer_raise(buffer, &bufinfo, MP_BUFFER_READ);
- uint32_t length = bufinfo.len;
+ size_t length = bufinfo.len;
normalize_buffer_bounds(&start, end, &length);
// do the transfer
@@ -288,7 +288,8 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_KW(busio_i2c_writeto_obj, 1, busio_i2c_writeto);
//| .. method:: writeto_then_readfrom(address, out_buffer, in_buffer, *, out_start=0, out_end=None, in_start=0, in_end=None)
//|
//| Write the bytes from ``out_buffer`` to the slave specified by ``address``, generate no stop
-//| bit, generate a repeated start and read into ``in_buffer``.
+//| bit, generate a repeated start and read into ``in_buffer``. ``out_buffer`` and
+//| ``in_buffer`` can be the same buffer because they are used sequentially.
//|
//| If ``start`` or ``end`` is provided, then the corresponding buffer will be sliced
//| as if ``buffer[start:end]``. This will not cause an allocation like ``buf[start:end]``