From 95ea4f0c95a6d08215dbfd0705747c1f8480ef10 Mon Sep 17 00:00:00 2001 From: Damien George Date: Wed, 6 Aug 2014 16:04:57 +0100 Subject: [PATCH] stmhal: Enable relevant GPIO clock when Pin obj is init'd. --- stmhal/pin.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/stmhal/pin.c b/stmhal/pin.c index 2d7466d3cb..f71ca92d9c 100644 --- a/stmhal/pin.c +++ b/stmhal/pin.c @@ -285,6 +285,32 @@ STATIC mp_obj_t pin_obj_init(uint n_args, mp_obj_t *args) { } } + // enable the peripheral clock for the port of this pin + switch (self->port) { + case PORT_A: __GPIOA_CLK_ENABLE(); break; + case PORT_B: __GPIOB_CLK_ENABLE(); break; + case PORT_C: __GPIOC_CLK_ENABLE(); break; + case PORT_D: __GPIOD_CLK_ENABLE(); break; + #ifdef __GPIOE_CLK_ENABLE + case PORT_E: __GPIOE_CLK_ENABLE(); break; + #endif + #ifdef __GPIOF_CLK_ENABLE + case PORT_F: __GPIOF_CLK_ENABLE(); break; + #endif + #ifdef __GPIOG_CLK_ENABLE + case PORT_G: __GPIOG_CLK_ENABLE(); break; + #endif + #ifdef __GPIOH_CLK_ENABLE + case PORT_H: __GPIOH_CLK_ENABLE(); break; + #endif + #ifdef __GPIOI_CLK_ENABLE + case PORT_I: __GPIOI_CLK_ENABLE(); break; + #endif + #ifdef __GPIOJ_CLK_ENABLE + case PORT_J: __GPIOJ_CLK_ENABLE(); break; + #endif + } + // configure the GPIO as requested GPIO_InitTypeDef GPIO_InitStructure; GPIO_InitStructure.Pin = self->pin_mask;