实现串口驱动,移植方便
This commit is contained in:
97
HAL/Inc/hal_gpio.h
Normal file
97
HAL/Inc/hal_gpio.h
Normal file
@ -0,0 +1,97 @@
|
||||
/* 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 configuration structure
|
||||
*/
|
||||
typedef struct {
|
||||
hal_gpio_port_t port;
|
||||
hal_gpio_pin_t pin;
|
||||
} hal_gpio_config_t;
|
||||
|
||||
/**
|
||||
* @brief Initialize GPIO hardware
|
||||
*/
|
||||
void hal_gpio_init(void);
|
||||
|
||||
/**
|
||||
* @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 */
|
||||
Reference in New Issue
Block a user