aboutsummaryrefslogtreecommitdiff
path: root/stmhal/adc.c
diff options
context:
space:
mode:
authorDamien George2015-08-03 00:05:16 +0100
committerDamien George2015-08-03 00:14:48 +0100
commit0851751615580d02bd6f841e13651923f05fde59 (patch)
tree28b788def0d7a128b57512a923a84657d65d11be /stmhal/adc.c
parent6f1c00869c761ff84b21939a057d7752e0c01be9 (diff)
stmhal: Factor GPIO clock enable logic into mp_hal_gpio_clock_enable.
Extracted GPIO clock enable logic into mp_hal_gpio_clock_enable and called from anyplace which might need to use GPIO functions on ports other than A-D. Thanks to Dave Hylands for the patch.
Diffstat (limited to 'stmhal/adc.c')
-rw-r--r--stmhal/adc.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/stmhal/adc.c b/stmhal/adc.c
index 57dc212d6..c70d88eaf 100644
--- a/stmhal/adc.c
+++ b/stmhal/adc.c
@@ -34,6 +34,7 @@
#include "adc.h"
#include "pin.h"
#include "genhdr/pins.h"
+#include "mphal.h"
#include "timer.h"
/// \moduleref pyb
@@ -89,6 +90,7 @@ STATIC void adc_init_single(pyb_obj_adc_t *adc_obj) {
// Channels 0-16 correspond to real pins. Configure the GPIO pin in
// ADC mode.
const pin_obj_t *pin = pin_adc1[adc_obj->channel];
+ mp_hal_gpio_clock_enable(pin->gpio);
GPIO_InitTypeDef GPIO_InitStructure;
GPIO_InitStructure.Pin = pin->pin_mask;
GPIO_InitStructure.Mode = GPIO_MODE_ANALOG;
@@ -348,6 +350,7 @@ void adc_init_all(pyb_adc_all_obj_t *adc_all, uint32_t resolution) {
// Channels 0-16 correspond to real pins. Configure the GPIO pin in
// ADC mode.
const pin_obj_t *pin = pin_adc1[channel];
+ mp_hal_gpio_clock_enable(pin->gpio);
GPIO_InitTypeDef GPIO_InitStructure;
GPIO_InitStructure.Pin = pin->pin_mask;
GPIO_InitStructure.Mode = GPIO_MODE_ANALOG;