summaryrefslogtreecommitdiffstatshomepage
path: root/stmhal
diff options
context:
space:
mode:
Diffstat (limited to 'stmhal')
-rw-r--r--stmhal/dac.c6
-rw-r--r--stmhal/i2c.c11
-rw-r--r--stmhal/modpyb.c9
3 files changed, 12 insertions, 14 deletions
diff --git a/stmhal/dac.c b/stmhal/dac.c
index 22622d4747..5e809412e9 100644
--- a/stmhal/dac.c
+++ b/stmhal/dac.c
@@ -180,12 +180,8 @@ mp_obj_t pyb_dac_dma(uint n_args, const mp_obj_t *args, mp_map_t *kw_args) {
// set TIM6 to trigger the DAC at the given frequency
TIM6_Config(mp_obj_get_int(args[2]));
- mp_obj_type_t *type = mp_obj_get_type(args[1]);
- if (type->buffer_p.get_buffer == NULL) {
- nlr_raise(mp_obj_new_exception_msg(&mp_type_TypeError, "buffer argument must support buffer protocol"));
- }
buffer_info_t bufinfo;
- type->buffer_p.get_buffer(args[1], &bufinfo, BUFFER_READ);
+ mp_get_buffer_raise(args[1], &bufinfo);
__DMA1_CLK_ENABLE();
diff --git a/stmhal/i2c.c b/stmhal/i2c.c
index 9528a3c3ce..65bc3600ef 100644
--- a/stmhal/i2c.c
+++ b/stmhal/i2c.c
@@ -143,16 +143,13 @@ STATIC mp_obj_t pyb_i2c_mem_write(uint n_args, const mp_obj_t *args) {
machine_uint_t i2c_addr = mp_obj_get_int(args[1]) << 1;
machine_uint_t mem_addr = mp_obj_get_int(args[2]);
HAL_StatusTypeDef status;
- mp_obj_type_t *type = mp_obj_get_type(args[3]);
- if (type->buffer_p.get_buffer != NULL) {
- buffer_info_t bufinfo;
- type->buffer_p.get_buffer(args[3], &bufinfo, BUFFER_READ);
- status = HAL_I2C_Mem_Write(self->i2c_handle, i2c_addr, mem_addr, I2C_MEMADD_SIZE_8BIT, bufinfo.buf, bufinfo.len, 200);
- } else if (MP_OBJ_IS_INT(args[3])) {
+ if (MP_OBJ_IS_INT(args[3])) {
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 {
- nlr_raise(mp_obj_new_exception_msg(&mp_type_TypeError, "data argument must be an integer or support the buffer protocol"));
+ buffer_info_t bufinfo;
+ mp_get_buffer_raise(args[3], &bufinfo);
+ status = HAL_I2C_Mem_Write(self->i2c_handle, i2c_addr, mem_addr, I2C_MEMADD_SIZE_8BIT, bufinfo.buf, bufinfo.len, 200);
}
//printf("Write got %d\n", status);
diff --git a/stmhal/modpyb.c b/stmhal/modpyb.c
index a6cb5adb6d..c564a0f195 100644
--- a/stmhal/modpyb.c
+++ b/stmhal/modpyb.c
@@ -32,7 +32,7 @@
#include "ff.h"
// get lots of info about the board
-STATIC mp_obj_t pyb_info(void) {
+STATIC mp_obj_t pyb_info(uint n_args, const mp_obj_t *args) {
// get and print unique id; 96 bits
{
byte *id = (byte*)0x1fff7a10;
@@ -89,10 +89,15 @@ STATIC mp_obj_t pyb_info(void) {
printf("LFS free: %u bytes\n", (uint)(nclst * fatfs->csize * 512));
}
+ if (n_args == 1) {
+ // arg given means dump gc allocation table
+ gc_dump_alloc_table();
+ }
+
return mp_const_none;
}
-STATIC MP_DEFINE_CONST_FUN_OBJ_0(pyb_info_obj, pyb_info);
+STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(pyb_info_obj, 0, 1, pyb_info);
// sync all file systems
STATIC mp_obj_t pyb_sync(void) {