summaryrefslogtreecommitdiffstatshomepage
path: root/stmhal/i2c.c
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2014-04-18 23:28:56 +0100
committerDamien George <damien.p.george@gmail.com>2014-04-18 23:28:56 +0100
commit38ae014e4258811d1612f9e140a35f8f9aa0ddb8 (patch)
tree2894967f48f3744515ad134f362337a3e2f64d82 /stmhal/i2c.c
parent71e9bfa20dd02457e73c2bec85102b6faf527a33 (diff)
downloadmicropython-38ae014e4258811d1612f9e140a35f8f9aa0ddb8.tar.gz
micropython-38ae014e4258811d1612f9e140a35f8f9aa0ddb8.zip
stmhal: Update ADC, DAC and I2C objects to use new buffer protocol.
Main reason for expanding buffer protocol API was to support writes to a buffer in ADC module (see read_timed). With this change you can now create an array of arbitrary type and ADC.read_timed will store into that array in the correct format (byte, int, float). I wonder though if all these changes were really worth it to support just this function. Hopefully this enhanced buffer protocol API (with typecode specified) will be used elsewhere.
Diffstat (limited to 'stmhal/i2c.c')
-rw-r--r--stmhal/i2c.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/stmhal/i2c.c b/stmhal/i2c.c
index 780d4fb498..4bbfec3ea8 100644
--- a/stmhal/i2c.c
+++ b/stmhal/i2c.c
@@ -163,8 +163,8 @@ STATIC mp_obj_t pyb_i2c_write(mp_obj_t self_in, mp_obj_t i2c_addr_in, mp_obj_t d
uint8_t data[1] = {mp_obj_get_int(data_in)};
status = HAL_I2C_Master_Transmit(self->i2c_handle, i2c_addr, data, 1, 500);
} else {
- buffer_info_t bufinfo;
- mp_get_buffer_raise(data_in, &bufinfo);
+ mp_buffer_info_t bufinfo;
+ mp_get_buffer_raise(data_in, &bufinfo, MP_BUFFER_READ);
status = HAL_I2C_Master_Transmit(self->i2c_handle, i2c_addr, bufinfo.buf, bufinfo.len, 500);
}
@@ -209,8 +209,8 @@ STATIC mp_obj_t pyb_i2c_mem_write(uint n_args, const mp_obj_t *args) {
uint8_t data[1] = {mp_obj_get_int(args[3])};
status = HAL_I2C_Mem_Write(self->i2c_handle, i2c_addr, mem_addr, I2C_MEMADD_SIZE_8BIT, data, 1, 200);
} else {
- buffer_info_t bufinfo;
- mp_get_buffer_raise(args[3], &bufinfo);
+ mp_buffer_info_t bufinfo;
+ mp_get_buffer_raise(args[3], &bufinfo, MP_BUFFER_READ);
status = HAL_I2C_Mem_Write(self->i2c_handle, i2c_addr, mem_addr, I2C_MEMADD_SIZE_8BIT, bufinfo.buf, bufinfo.len, 200);
}