summaryrefslogtreecommitdiff
path: root/stmhal/adc.c
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2015-03-13 22:11:50 +0000
committerDamien George <damien.p.george@gmail.com>2015-03-13 22:11:50 +0000
commitac4f6b804fc7fd298aef420195f773f830ace422 (patch)
tree817155701295fe15e0da5a79bc1234d19acb4eb4 /stmhal/adc.c
parent1129de5ac09ac5b41a952021cbc7a9752c8c253f (diff)
stmhal: Fix adc.read_timed so buffer store respects element size.
Addresses issue #1154.
Diffstat (limited to 'stmhal/adc.c')
-rw-r--r--stmhal/adc.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/stmhal/adc.c b/stmhal/adc.c
index a59543710..867edc648 100644
--- a/stmhal/adc.c
+++ b/stmhal/adc.c
@@ -228,7 +228,8 @@ STATIC mp_obj_t adc_read_timed(mp_obj_t self_in, mp_obj_t buf_in, mp_obj_t freq_
// This uses the timer in polling mode to do the sampling
// We could use DMA, but then we can't convert the values correctly for the buffer
adc_config_channel(self);
- for (uint index = 0; index < bufinfo.len; index++) {
+ uint nelems = bufinfo.len / typesize;
+ for (uint index = 0; index < nelems; index++) {
// Wait for the timer to trigger
while (__HAL_TIM_GET_FLAG(&TIM6_Handle, TIM_FLAG_UPDATE) == RESET) {
}