STM32G474xx HAL用户手册
stm32g4xx_ll_gpio.h
跳转到此文件的文档。
00001 /**
00002   ******************************************************************************
00003   * @file    stm32g4xx_ll_gpio.h
00004   * @author  MCD Application Team
00005   * @brief   GPIO LL模块头文件。
00006   ******************************************************************************
00007   * @attention
00008   *
00009   * Copyright (c) 2019 STMicroelectronics.
00010   * All rights reserved.
00011   *
00012   * This software is licensed under terms that can be found in the LICENSE file
00013   * in the root directory of this software component.
00014   * If no LICENSE file comes with this software, it is provided AS-IS.
00015   *
00016   ******************************************************************************
00017   */
00018 
00019 /* Define to prevent recursive inclusion -------------------------------------*/
00020 #ifndef STM32G4xx_LL_GPIO_H
00021 #define STM32G4xx_LL_GPIO_H
00022 
00023 #ifdef __cplusplus
00024 extern "C" {
00025 #endif
00026 
00027 /* Includes ------------------------------------------------------------------*/
00028 #include "stm32g4xx.h"
00029 
00030 /** @addtogroup STM32G4xx_LL_Driver
00031   * @{
00032   */
00033 
00034 #if defined (GPIOA) || defined (GPIOB) || defined (GPIOC) || defined (GPIOD) || defined (GPIOE) || defined (GPIOF) || defined (GPIOG)
00035 
00036 /** @defgroup GPIO_LL GPIO
00037   * @{
00038   */
00039 /** MISRA C:2012 deviation rule has been granted for following rules:
00040   * Rule-18.1_d - Medium: Array pointer `GPIOx' is accessed with index [..,..]
00041   * which may be out of array bounds [..,UNKNOWN] in following APIs:
00042   * LL_GPIO_GetAFPin_0_7
00043   * LL_GPIO_SetAFPin_0_7
00044   * LL_GPIO_SetAFPin_8_15
00045   * LL_GPIO_GetAFPin_8_15
00046   */
00047 
00048 /* Private types -------------------------------------------------------------*/
00049 /* Private variables ---------------------------------------------------------*/
00050 /* Private constants ---------------------------------------------------------*/
00051 /* Private macros ------------------------------------------------------------*/
00052 #if defined(USE_FULL_LL_DRIVER)
00053 /** @defgroup GPIO_LL_Private_Macros GPIO Private Macros
00054   * @{
00055   */
00056 
00057 /**
00058   * @}
00059   */
00060 #endif /*USE_FULL_LL_DRIVER*/
00061 
00062 /* Exported types ------------------------------------------------------------*/
00063 #if defined(USE_FULL_LL_DRIVER)
00064 /** @defgroup GPIO_LL_ES_INIT GPIO Exported Init structures
00065   * @{
00066   */
00067 
00068 /**
00069   * @brief LL GPIO初始化结构体定义
00070   */
00071 typedef struct
00072 {
00073   uint32_t Pin;          /*!< 指定要配置的GPIO引脚。
00074                               此参数可以是@ref GPIO_LL_EC_PIN的任意值 */
00075 
00076   uint32_t Mode;         /*!< 指定所选引脚的工作模式。
00077                               此参数可以是@ref GPIO_LL_EC_MODE的值。
00078 
00079                               GPIO硬件配置可使用单元函数@ref LL_GPIO_SetPinMode()进行修改。*/
00080 
00081   uint32_t Speed;        /*!< 指定所选引脚的速度。
00082                               此参数可以是@ref GPIO_LL_EC_SPEED的值。

00084                               GPIO硬件配置可使用单元函数@ref LL_GPIO_SetPinSpeed()进行修改。*/
00085 
00086   uint32_t OutputType;   /*!< 指定所选引脚的工作输出类型。
00087                               此参数可以是@ref GPIO_LL_EC_OUTPUT的值。

00089                               GPIO硬件配置可使用单元函数@ref LL_GPIO_SetPinOutputType()进行修改。*/
00090 
00091   uint32_t Pull;         /*!< 指定所选引脚的工作上下拉配置。
00092                               此参数可以是@ref GPIO_LL_EC_PULL的值。

00094                               GPIO硬件配置可使用单元函数@ref LL_GPIO_SetPinPull()进行修改。*/
00095 
00096   uint32_t Alternate;    /*!< 指定要连接到所选引脚的外设。
00098                               此参数可以是@ref GPIO_LL_EC_AF的值。
00100 
00100                               GPIO硬件配置可使用单元函数@ref LL_GPIO_SetAFPin_0_7()和LL_GPIO_SetAFPin_8_15()进行修改。*/
00101 } LL_GPIO_InitTypeDef;
00102 
00103 /**
00104   * @}
00105   */
00106 #endif /* USE_FULL_LL_DRIVER */
00107 
00108 /* Exported constants --------------------------------------------------------*/
00109 /** @defgroup GPIO_LL_Exported_Constants GPIO Exported Constants
00110   * @{
00111   */
00112 
00113 /** @defgroup GPIO_LL_EC_PIN 引脚
00114   * @{
00115   */
00116 #define LL_GPIO_PIN_0                      GPIO_BSRR_BS0 /*!< 选择引脚0 */
00117 #define LL_GPIO_PIN_1                      GPIO_BSRR_BS1 /*!< 选择引脚1 */
00118 #define LL_GPIO_PIN_2                      GPIO_BSRR_BS2 /*!< 选择引脚2 */
00119 #define LL_GPIO_PIN_3                      GPIO_BSRR_BS3 /*!< 选择引脚3 */
00120 #define LL_GPIO_PIN_4                      GPIO_BSRR_BS4 /*!< 选择引脚4 */
00121 #define LL_GPIO_PIN_5                      GPIO_BSRR_BS5 /*!< 选择引脚5 */
00122 #define LL_GPIO_PIN_6                      GPIO_BSRR_BS6 /*!< 选择引脚6 */
00123 #define LL_GPIO_PIN_7                      GPIO_BSRR_BS7 /*!< 选择引脚7 */
00124 #define LL_GPIO_PIN_8                      GPIO_BSRR_BS8 /*!< 选择引脚8 */
00125 #define LL_GPIO_PIN_9                      GPIO_BSRR_BS9 /*!< 选择引脚9 */
00126 #define LL_GPIO_PIN_10                     GPIO_BSRR_BS10 /*!< 选择引脚10 */
00127 #define LL_GPIO_PIN_11                     GPIO_BSRR_BS11 /*!< 选择引脚11 */
00128 #define LL_GPIO_PIN_12                     GPIO_BSRR_BS12 /*!< 选择引脚12 */
00129 #define LL_GPIO_PIN_13                     GPIO_BSRR_BS13 /*!< 选择引脚13 */
00130 #define LL_GPIO_PIN_14                     GPIO_BSRR_BS14 /*!< 选择引脚14 */
00131 #define LL_GPIO_PIN_15                     GPIO_BSRR_BS15 /*!< 选择引脚15 */
00132 #define LL_GPIO_PIN_ALL                    (GPIO_BSRR_BS0 | GPIO_BSRR_BS1  | GPIO_BSRR_BS2  | \
00133                                            GPIO_BSRR_BS3  | GPIO_BSRR_BS4  | GPIO_BSRR_BS5  | \
00134                                            GPIO_BSRR_BS6  | GPIO_BSRR_BS7  | GPIO_BSRR_BS8  | \
00135                                            GPIO_BSRR_BS9  | GPIO_BSRR_BS10 | GPIO_BSRR_BS11 | \
00136                                            GPIO_BSRR_BS12 | GPIO_BSRR_BS13 | GPIO_BSRR_BS14 | \
00137                                            GPIO_BSRR_BS15) /*!< 选择所有引脚 */
00138 /**
00139   * @}
00140   */
00141 
00142 /** @defgroup GPIO_LL_EC_MODE 模式
00143   * @{
00144   */
00145 #define LL_GPIO_MODE_INPUT                 (0x00000000U) /*!< 选择输入模式 */
00146 #define LL_GPIO_MODE_OUTPUT                GPIO_MODER_MODE0_0  /*!< 选择输出模式 */
00147 #define LL_GPIO_MODE_ALTERNATE             GPIO_MODER_MODE0_1  /*!< 选择复用功能模式 */
00148 #define LL_GPIO_MODE_ANALOG                GPIO_MODER_MODE0    /*!< 选择模拟模式 */
00149 /**
00150   * @}
00151   */
00152 
00153 /** @defgroup GPIO_LL_EC_OUTPUT 输出类型
00154   * @{
00155   */
00156 #define LL_GPIO_OUTPUT_PUSHPULL            (0x00000000U) /*!< 选择推挽作为输出类型 */
00157 #define LL_GPIO_OUTPUT_OPENDRAIN           GPIO_OTYPER_OT0 /*!< 选择开漏作为输出类型 */
00158 /**
00159   * @}
00160   */
00161 
00162 /** @defgroup GPIO_LL_EC_SPEED 输出速度
00163   * @{
00164   */
00165 #define LL_GPIO_SPEED_FREQ_LOW             (0x00000000U) /*!< 选择I/O低速输出    */
00166 #define LL_GPIO_SPEED_FREQ_MEDIUM          GPIO_OSPEEDR_OSPEED0_0 /*!< 选择I/O中速输出 */
00167 #define LL_GPIO_SPEED_FREQ_HIGH            GPIO_OSPEEDR_OSPEED0_1 /*!< 选择I/O高速输出   */
00168 #define LL_GPIO_SPEED_FREQ_VERY_HIGH       GPIO_OSPEEDR_OSPEED0   /*!< 选择I/O最高速输出   */
00169 /**
00170   * @}
00171   */
00172 #define LL_GPIO_SPEED_LOW                  LL_GPIO_SPEED_FREQ_LOW
00173 #define LL_GPIO_SPEED_MEDIUM               LL_GPIO_SPEED_FREQ_MEDIUM
00174 #define LL_GPIO_SPEED_FAST                 LL_GPIO_SPEED_FREQ_HIGH