diff options
author | Damien George <damien.p.george@gmail.com> | 2015-08-03 00:05:16 +0100 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2015-08-03 00:14:48 +0100 |
commit | 0851751615580d02bd6f841e13651923f05fde59 (patch) | |
tree | 28b788def0d7a128b57512a923a84657d65d11be /stmhal/pin.c | |
parent | 6f1c00869c761ff84b21939a057d7752e0c01be9 (diff) | |
download | micropython-0851751615580d02bd6f841e13651923f05fde59.tar.gz micropython-0851751615580d02bd6f841e13651923f05fde59.zip |
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/pin.c')
-rw-r--r-- | stmhal/pin.c | 36 |
1 files changed, 1 insertions, 35 deletions
diff --git a/stmhal/pin.c b/stmhal/pin.c index 4be889eaf9..8ba6cce8ea 100644 --- a/stmhal/pin.c +++ b/stmhal/pin.c @@ -359,41 +359,7 @@ STATIC mp_obj_t pin_obj_init_helper(const pin_obj_t *self, mp_uint_t n_args, con } // enable the peripheral clock for the port of this pin - switch (self->port) { - #ifdef __GPIOA_CLK_ENABLE - case PORT_A: __GPIOA_CLK_ENABLE(); break; - #endif - #ifdef __GPIOB_CLK_ENABLE - case PORT_B: __GPIOB_CLK_ENABLE(); break; - #endif - #ifdef __GPIOC_CLK_ENABLE - case PORT_C: __GPIOC_CLK_ENABLE(); break; - #endif - #ifdef __GPIOD_CLK_ENABLE - case PORT_D: __GPIOD_CLK_ENABLE(); break; - #endif - #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 - #ifdef __GPIOK_CLK_ENABLE - case PORT_K: __GPIOK_CLK_ENABLE(); break; - #endif - } + mp_hal_gpio_clock_enable(self->gpio); // configure the GPIO as requested GPIO_InitTypeDef GPIO_InitStructure; |