aboutsummaryrefslogtreecommitdiff
path: root/stmhal/dac.c
diff options
context:
space:
mode:
authorDamien George2014-04-13 12:08:52 +0100
committerDamien George2014-04-13 12:08:52 +0100
commit8a1cab952f08f46182f6f86caf8edf37e477be33 (patch)
tree0d032ab1e5390a3d68414f2305a42a8172ee16bf /stmhal/dac.c
parent4b01de44ba110394cac66f83a44a037fc58ae4e8 (diff)
py: Fix mp_get_buffer, and use it in more places.
Must use mp_obj_get_type to get the type of an object. Can't assume mp_obj_t is castable to mp_obj_base_t.
Diffstat (limited to 'stmhal/dac.c')
-rw-r--r--stmhal/dac.c6
1 files changed, 1 insertions, 5 deletions
diff --git a/stmhal/dac.c b/stmhal/dac.c
index 22622d474..5e809412e 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();