STM32G474xx HAL 用户手册
stm32g4xx_ll_i2c.h
转到此文件的文档。
00001 /**
00002   ******************************************************************************
00003   * @file    stm32g4xx_ll_i2c.h
00004   * @author  MCD Application Team
00005   * @brief   I2C 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_I2C_H
00021 #define STM32G4xx_LL_I2C_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 (I2C1) || defined (I2C2) || defined (I2C3) || defined (I2C4)
00035 
00036 /** @defgroup I2C_LL I2C
00037   * @{
00038   */
00039 
00040 /* Private types -------------------------------------------------------------*/
00041 /* Private variables ---------------------------------------------------------*/
00042 
00043 /* Private constants ---------------------------------------------------------*/
00044 /** @defgroup I2C_LL_Private_Constants I2C 私有常量
00045   * @{
00046   */
00047 /**
00048   * @}
00049   */
00050 
00051 /* Private macros ------------------------------------------------------------*/
00052 #if defined(USE_FULL_LL_DRIVER)
00053 /** @defgroup I2C_LL_Private_Macros I2C 私有宏
00054   * @{
00055   */
00056 /**
00057   * @}
00058   */
00059 #endif /*USE_FULL_LL_DRIVER*/
00060 
00061 /* Exported types ------------------------------------------------------------*/
00062 #if defined(USE_FULL_LL_DRIVER)
00063 /** @defgroup I2C_LL_ES_INIT I2C 导出的初始化结构体
00064   * @{
00065   */
00066 typedef struct
00067 {
00068   uint32_t PeripheralMode;      /*!< 指定外设模式。
00069                                      此参数可以是 @ref I2C_LL_EC_PERIPHERAL_MODE 的值。
00070 
00071                                      此功能可以使用单元函数
00072                                      @ref LL_I2C_SetMode() 进行修改。 */
00073 
00074   uint32_t Timing;              /*!< 指定 SDA 建立时间、保持时间以及 SCL 高电平、低电平周期值。
00075                                      此参数必须参考 STM32CubeMX 工具和
00076                                      辅助宏 @ref __LL_I2C_CONVERT_TIMINGS() 进行设置。
00077 
00078                                      此功能可以使用单元函数
00079                                      @ref LL_I2C_SetTiming() 进行修改。 */
00080 
00081   uint32_t AnalogFilter;        /*!< 使能或禁用模拟噪声滤波器。
00082                                      此参数可以是 @ref I2C_LL_EC_ANALOGFILTER_SELECTION 的值。
00083 
00084                                      此功能可以使用单元函数
00085                                      @ref LL_I2C_EnableAnalogFilter() 或 LL_I2C_DisableAnalogFilter() 进行修改。 */
00086 
00087   uint32_t DigitalFilter;       /*!< 配置数字噪声滤波器。
00088                                      此参数可以是 Min_Data = 0x00 和 Max_Data = 0x0F 之间的数字。
00089 
00090                                      此功能可以使用单元函数
00091                                      @ref LL_I2C_SetDigitalFilter() 进行修改。 */
00092 
00093   uint32_t OwnAddress1;         /*!< 指定设备自身地址 1。
00094                                      此参数必须是 Min_Data = 0x00 和 Max_Data = 0x3FF 之间的值。
00095 
00096                                      此功能可以使用单元函数
00097                                      @ref LL_I2C_SetOwnAddress1() 进行修改。 */
00098 
00099   uint32_t TypeAcknowledge;     /*!< 指定地址接收匹配码或下一个接收字节之后的应答或非应答条件。
00100                                      此参数可以是 @ref I2C_LL_EC_I2C_ACKNOWLEDGE 的值。
00101 
00102                                      此功能可以使用单元函数
00103                                      @ref LL_I2C_AcknowledgeNextData() 进行修改。 */
00104 
00105 
00106   uint32_t OwnAddrSize;         /*!< 指定设备自身地址 1 的大小(7 位或 10 位)。
00107                                      此参数可以是 @ref I2C_LL_EC_OWNADDRESS1 的值。
00108 
00109                                      此功能可以使用单元函数
00110                                      @ref LL_I2C_SetOwnAddress1() 进行修改。 */
00111 } LL_I2C_InitTypeDef;
00112 /**
00113   * @}
00114   */
00115 #endif /*USE_FULL_LL_DRIVER*/
00116 
00117 /* Exported constants --------------------------------------------------------*/
00118 /** @defgroup I2C_LL_Exported_Constants I2C 导出的常量
00119   * @{
00120   */
00121 
00122 /** @defgroup I2C_LL_EC_CLEAR_FLAG 清除标志定义
00123   * @brief    可与 LL_I2C_WriteReg 函数一起使用的标志定义
00124   * @{
00125   */
00126 #define LL_I2C_ICR_ADDRCF                   I2C_ICR_ADDRCF          /*!< 地址匹配标志   */
00127 #define LL_I2C_ICR_NACKCF                   I2C_ICR_NACKCF          /*!< 非应答标志   */
00128 #define LL_I2C_ICR_STOPCF                   I2C_ICR_STOPCF          /*!< 停止检测标志    */
00129 #define LL_I2C_ICR_BERRCF                   I2C_ICR_BERRCF          /*!< 总线错误标志         */
00130 #define LL_I2C_ICR_ARLOCF                   I2C_ICR_ARLOCF          /*!< 仲裁丢失标志  */
00131 #define LL_I2C_ICR_OVRCF                    I2C_ICR_OVRCF           /*!< 溢出/欠载标志  */
00132 #define LL_I2C_ICR_PECCF                    I2C_ICR_PECCF           /*!< PEC 错误标志         */
00133 #define LL_I2C_ICR_TIMOUTCF                 I2C_ICR_TIMOUTCF        /*!< 超时检测标志 */
00134 #define LL_I2C_ICR_ALERTCF                  I2C_ICR_ALERTCF         /*!< 警报标志             */
00135 /**
00136   * @}
00137   */
00138 
00139 /** @defgroup I2C_LL_EC_GET_FLAG 获取标志定义
00140   * @brief    可与 LL_I2C_ReadReg 函数一起使用的标志定义
00141   * @{
00142   */
00143 #define LL_I2C_ISR_TXE                      I2C_ISR_TXE             /*!< 发送数据寄存器为空        */
00144 #define LL_I2C_ISR_TXIS                     I2C_ISR_TXIS            /*!< 发送中断状态           */
00145 #define LL_I2C_ISR_RXNE                     I2C_ISR_RXNE            /*!< 接收数据寄存器非空     */
00146 #define LL_I2C_ISR_ADDR                     I2C_ISR_ADDR            /*!< 地址匹配(从机模式)        */
00147 #define LL_I2C_ISR_NACKF                    I2C_ISR_NACKF           /*!< 接收到非应答标志       */
00148 #define LL_I2C_ISR_STOPF                    I2C_ISR_STOPF           /*!< 停止检测标志                 */