Skip to content

Commit 95ea4f0

Browse files
committed
stmhal: Enable relevant GPIO clock when Pin obj is init'd.
1 parent 7cc20e7 commit 95ea4f0

1 file changed

Lines changed: 26 additions & 0 deletions

File tree

stmhal/pin.c

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,32 @@ STATIC mp_obj_t pin_obj_init(uint n_args, mp_obj_t *args) {
285285
}
286286
}
287287

288+
// enable the peripheral clock for the port of this pin
289+
switch (self->port) {
290+
case PORT_A: __GPIOA_CLK_ENABLE(); break;
291+
case PORT_B: __GPIOB_CLK_ENABLE(); break;
292+
case PORT_C: __GPIOC_CLK_ENABLE(); break;
293+
case PORT_D: __GPIOD_CLK_ENABLE(); break;
294+
#ifdef __GPIOE_CLK_ENABLE
295+
case PORT_E: __GPIOE_CLK_ENABLE(); break;
296+
#endif
297+
#ifdef __GPIOF_CLK_ENABLE
298+
case PORT_F: __GPIOF_CLK_ENABLE(); break;
299+
#endif
300+
#ifdef __GPIOG_CLK_ENABLE
301+
case PORT_G: __GPIOG_CLK_ENABLE(); break;
302+
#endif
303+
#ifdef __GPIOH_CLK_ENABLE
304+
case PORT_H: __GPIOH_CLK_ENABLE(); break;
305+
#endif
306+
#ifdef __GPIOI_CLK_ENABLE
307+
case PORT_I: __GPIOI_CLK_ENABLE(); break;
308+
#endif
309+
#ifdef __GPIOJ_CLK_ENABLE
310+
case PORT_J: __GPIOJ_CLK_ENABLE(); break;
311+
#endif
312+
}
313+
288314
// configure the GPIO as requested
289315
GPIO_InitTypeDef GPIO_InitStructure;
290316
GPIO_InitStructure.Pin = self->pin_mask;

0 commit comments

Comments
 (0)