/* USER CODE BEGIN Header */ /** ****************************************************************************** * @file : hal_gpio.h * @brief : GPIO hardware abstraction layer header file ****************************************************************************** */ /* USER CODE END Header */ #ifndef HAL_GPIO_H #define HAL_GPIO_H /** * @brief GPIO pin state definitions */ typedef enum { HAL_GPIO_PIN_RESET = 0U, HAL_GPIO_PIN_SET = 1U } hal_gpio_pin_state_t; /** * @brief GPIO pin definitions */ typedef enum { HAL_GPIO_PIN_0 = 0U, HAL_GPIO_PIN_1 = 1U, HAL_GPIO_PIN_2 = 2U, HAL_GPIO_PIN_3 = 3U, HAL_GPIO_PIN_4 = 4U, HAL_GPIO_PIN_5 = 5U, HAL_GPIO_PIN_6 = 6U, HAL_GPIO_PIN_7 = 7U, HAL_GPIO_PIN_8 = 8U, HAL_GPIO_PIN_9 = 9U, HAL_GPIO_PIN_10 = 10U, HAL_GPIO_PIN_11 = 11U, HAL_GPIO_PIN_12 = 12U, HAL_GPIO_PIN_13 = 13U, HAL_GPIO_PIN_14 = 14U, HAL_GPIO_PIN_15 = 15U, HAL_GPIO_PIN_ALL = 0xFFFFU } hal_gpio_pin_t; /** * @brief GPIO port definitions */ typedef enum { HAL_GPIO_PORT_A = 0U, HAL_GPIO_PORT_B = 1U, HAL_GPIO_PORT_C = 2U, HAL_GPIO_PORT_D = 3U, HAL_GPIO_PORT_E = 4U, HAL_GPIO_PORT_F = 5U, HAL_GPIO_PORT_G = 6U, HAL_GPIO_PORT_H = 7U, HAL_GPIO_PORT_I = 8U, HAL_GPIO_PORT_J = 9U, HAL_GPIO_PORT_K = 10U } hal_gpio_port_t; /** * @brief GPIO mode definitions */ typedef enum { HAL_GPIO_MODE_INPUT = 0U, HAL_GPIO_MODE_OUTPUT_PP = 1U, HAL_GPIO_MODE_OUTPUT_OD = 2U, HAL_GPIO_MODE_AF_PP = 3U, HAL_GPIO_MODE_AF_OD = 4U, HAL_GPIO_MODE_ANALOG = 5U, HAL_GPIO_MODE_IT_RISING = 6U, HAL_GPIO_MODE_IT_FALLING = 7U, HAL_GPIO_MODE_IT_RISING_FALLING = 8U } hal_gpio_mode_t; /** * @brief GPIO speed definitions */ typedef enum { HAL_GPIO_SPEED_LOW = 0U, HAL_GPIO_SPEED_MEDIUM = 1U, HAL_GPIO_SPEED_HIGH = 2U, HAL_GPIO_SPEED_VERY_HIGH = 3U } hal_gpio_speed_t; /** * @brief GPIO pull-up/pull-down definitions */ typedef enum { HAL_GPIO_PULL_NO = 0U, HAL_GPIO_PULL_UP = 1U, HAL_GPIO_PULL_DOWN = 2U } hal_gpio_pull_t; /** * @brief GPIO configuration structure */ typedef struct { hal_gpio_port_t port; hal_gpio_pin_t pin; hal_gpio_mode_t mode; hal_gpio_speed_t speed; hal_gpio_pull_t pull; } hal_gpio_config_t; /** * @brief Initialize GPIO hardware */ void hal_gpio_init(void); /** * @brief Configure GPIO pin * @param config: GPIO configuration structure */ void hal_gpio_configure_pin(const hal_gpio_config_t *config); /** * @brief Write GPIO pin state * @param port: GPIO port * @param pin: GPIO pin * @param state: GPIO pin state */ void hal_gpio_write_pin(hal_gpio_port_t port, hal_gpio_pin_t pin, hal_gpio_pin_state_t state); /** * @brief Toggle GPIO pin state * @param port: GPIO port * @param pin: GPIO pin */ void hal_gpio_toggle_pin(hal_gpio_port_t port, hal_gpio_pin_t pin); /** * @brief Read GPIO pin state * @param port: GPIO port * @param pin: GPIO pin * @retval GPIO pin state */ hal_gpio_pin_state_t hal_gpio_read_pin(hal_gpio_port_t port, hal_gpio_pin_t pin); #endif /* HAL_GPIO_H */