diff --git a/Source/system/gpio.c b/Source/system/gpio.c new file mode 100644 --- /dev/null +++ b/Source/system/gpio.c @@ -0,0 +1,36 @@ +// +// GPIO: Configure and initialize GPIOs +// + +#include "config.h" +#include "system/gpio.h" +#include "stm32f0xx_hal.h" + + +// Private variables +static uint8_t shutdown_triggered = 0; +static uint32_t shutdown_triggered_time = 0; + + +// Initialize GPIOs +void gpio_init(void) +{ + GPIO_InitTypeDef GPIO_InitStruct; + + // Enable clocks + __GPIOC_CLK_ENABLE(); + __GPIOF_CLK_ENABLE(); + __GPIOA_CLK_ENABLE(); + __GPIOB_CLK_ENABLE(); + + // LEDs 1/2 + GPIO_InitStruct.Pin = PIN_LED_POWER; + GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_LOW; + HAL_GPIO_Init(PORT_LED_POWER, &GPIO_InitStruct); + + + // Toggle the power LED + HAL_GPIO_TogglePin(LED_POWER); +}