1 /*
2 * Copyright (c) 2024 DNDG srl
3 * SPDX-License-Identifier: Apache-2.0
4 */
5
6 #include <zephyr/kernel.h>
7 #include <zephyr/init.h>
8 #include <stm32h7xx_ll_bus.h>
9 #include <stm32h7xx_ll_gpio.h>
10
board_gpio_hse(void)11 static int board_gpio_hse(void)
12 {
13 /* The external oscillator that drives the HSE clock should be enabled
14 * by setting the GPIOH1 pin. This function is registered at priority
15 * RE_KERNEL_1 to be executed before the standard STM clock
16 * setup code.
17 */
18
19 LL_AHB4_GRP1_EnableClock(LL_AHB4_GRP1_PERIPH_GPIOH);
20
21 LL_GPIO_SetPinMode(GPIOH, LL_GPIO_PIN_1, LL_GPIO_MODE_OUTPUT);
22 LL_GPIO_SetPinSpeed(GPIOH, LL_GPIO_PIN_1, LL_GPIO_SPEED_FREQ_LOW);
23 LL_GPIO_SetPinOutputType(GPIOH, LL_GPIO_PIN_1, LL_GPIO_OUTPUT_PUSHPULL);
24 LL_GPIO_SetPinPull(GPIOH, LL_GPIO_PIN_1, LL_GPIO_PULL_UP);
25 LL_GPIO_SetOutputPin(GPIOH, LL_GPIO_PIN_1);
26
27 return 0;
28 }
29
30 SYS_INIT(board_gpio_hse, PRE_KERNEL_1, 0);
31