You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

1911 lines
67 KiB

  1. /**
  2. ******************************************************************************
  3. * @file stm32f4xx_ll_i2c.h
  4. * @author MCD Application Team
  5. * @version V1.7.1
  6. * @date 14-April-2017
  7. * @brief Header file of I2C LL module.
  8. ******************************************************************************
  9. * @attention
  10. *
  11. * <h2><center>&copy; COPYRIGHT(c) 2017 STMicroelectronics</center></h2>
  12. *
  13. * Redistribution and use in source and binary forms, with or without modification,
  14. * are permitted provided that the following conditions are met:
  15. * 1. Redistributions of source code must retain the above copyright notice,
  16. * this list of conditions and the following disclaimer.
  17. * 2. Redistributions in binary form must reproduce the above copyright notice,
  18. * this list of conditions and the following disclaimer in the documentation
  19. * and/or other materials provided with the distribution.
  20. * 3. Neither the name of STMicroelectronics nor the names of its contributors
  21. * may be used to endorse or promote products derived from this software
  22. * without specific prior written permission.
  23. *
  24. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  25. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  26. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  27. * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
  28. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  29. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  30. * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  31. * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  32. * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  33. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  34. *
  35. ******************************************************************************
  36. */
  37. /* Define to prevent recursive inclusion -------------------------------------*/
  38. #ifndef __STM32F4xx_LL_I2C_H
  39. #define __STM32F4xx_LL_I2C_H
  40. #ifdef __cplusplus
  41. extern "C" {
  42. #endif
  43. /* Includes ------------------------------------------------------------------*/
  44. #include "stm32f4xx.h"
  45. /** @addtogroup STM32F4xx_LL_Driver
  46. * @{
  47. */
  48. #if defined (I2C1) || defined (I2C2) || defined (I2C3)
  49. /** @defgroup I2C_LL I2C
  50. * @{
  51. */
  52. /* Private types -------------------------------------------------------------*/
  53. /* Private variables ---------------------------------------------------------*/
  54. /* Private constants ---------------------------------------------------------*/
  55. /** @defgroup I2C_LL_Private_Constants I2C Private Constants
  56. * @{
  57. */
  58. /* Defines used to perform compute and check in the macros */
  59. #define LL_I2C_MAX_SPEED_STANDARD 100000U
  60. #define LL_I2C_MAX_SPEED_FAST 400000U
  61. /**
  62. * @}
  63. */
  64. /* Private macros ------------------------------------------------------------*/
  65. #if defined(USE_FULL_LL_DRIVER)
  66. /** @defgroup I2C_LL_Private_Macros I2C Private Macros
  67. * @{
  68. */
  69. /**
  70. * @}
  71. */
  72. #endif /*USE_FULL_LL_DRIVER*/
  73. /* Exported types ------------------------------------------------------------*/
  74. #if defined(USE_FULL_LL_DRIVER)
  75. /** @defgroup I2C_LL_ES_INIT I2C Exported Init structure
  76. * @{
  77. */
  78. typedef struct
  79. {
  80. uint32_t PeripheralMode; /*!< Specifies the peripheral mode.
  81. This parameter can be a value of @ref I2C_LL_EC_PERIPHERAL_MODE
  82. This feature can be modified afterwards using unitary function @ref LL_I2C_SetMode(). */
  83. uint32_t ClockSpeed; /*!< Specifies the clock frequency.
  84. This parameter must be set to a value lower than 400kHz (in Hz)
  85. This feature can be modified afterwards using unitary function @ref LL_I2C_SetClockPeriod()
  86. or @ref LL_I2C_SetDutyCycle() or @ref LL_I2C_SetClockSpeedMode() or @ref LL_I2C_ConfigSpeed(). */
  87. uint32_t DutyCycle; /*!< Specifies the I2C fast mode duty cycle.
  88. This parameter can be a value of @ref I2C_LL_EC_DUTYCYCLE
  89. This feature can be modified afterwards using unitary function @ref LL_I2C_SetDutyCycle(). */
  90. #if defined(I2C_FLTR_ANOFF)&&defined(I2C_FLTR_DNF)
  91. uint32_t AnalogFilter; /*!< Enables or disables analog noise filter.
  92. This parameter can be a value of @ref I2C_LL_EC_ANALOGFILTER_SELECTION
  93. This feature can be modified afterwards using unitary functions @ref LL_I2C_EnableAnalogFilter() or LL_I2C_DisableAnalogFilter(). */
  94. uint32_t DigitalFilter; /*!< Configures the digital noise filter.
  95. This parameter can be a number between Min_Data = 0x00 and Max_Data = 0x0F
  96. This feature can be modified afterwards using unitary function @ref LL_I2C_SetDigitalFilter(). */
  97. #endif
  98. uint32_t OwnAddress1; /*!< Specifies the device own address 1.
  99. This parameter must be a value between Min_Data = 0x00 and Max_Data = 0x3FF
  100. This feature can be modified afterwards using unitary function @ref LL_I2C_SetOwnAddress1(). */
  101. uint32_t TypeAcknowledge; /*!< Specifies the ACKnowledge or Non ACKnowledge condition after the address receive match code or next received byte.
  102. This parameter can be a value of @ref I2C_LL_EC_I2C_ACKNOWLEDGE
  103. This feature can be modified afterwards using unitary function @ref LL_I2C_AcknowledgeNextData(). */
  104. uint32_t OwnAddrSize; /*!< Specifies the device own address 1 size (7-bit or 10-bit).
  105. This parameter can be a value of @ref I2C_LL_EC_OWNADDRESS1
  106. This feature can be modified afterwards using unitary function @ref LL_I2C_SetOwnAddress1(). */
  107. } LL_I2C_InitTypeDef;
  108. /**
  109. * @}
  110. */
  111. #endif /*USE_FULL_LL_DRIVER*/
  112. /* Exported constants --------------------------------------------------------*/
  113. /** @defgroup I2C_LL_Exported_Constants I2C Exported Constants
  114. * @{
  115. */
  116. /** @defgroup I2C_LL_EC_GET_FLAG Get Flags Defines
  117. * @brief Flags defines which can be used with LL_I2C_ReadReg function
  118. * @{
  119. */
  120. #define LL_I2C_SR1_SB I2C_SR1_SB /*!< Start Bit (master mode) */
  121. #define LL_I2C_SR1_ADDR I2C_SR1_ADDR /*!< Address sent (master mode) or
  122. Address matched flag (slave mode) */
  123. #define LL_I2C_SR1_BTF I2C_SR1_BTF /*!< Byte Transfer Finished flag */
  124. #define LL_I2C_SR1_ADD10 I2C_SR1_ADD10 /*!< 10-bit header sent (master mode) */
  125. #define LL_I2C_SR1_STOPF I2C_SR1_STOPF /*!< Stop detection flag (slave mode) */
  126. #define LL_I2C_SR1_RXNE I2C_SR1_RXNE /*!< Data register not empty (receivers) */
  127. #define LL_I2C_SR1_TXE I2C_SR1_TXE /*!< Data register empty (transmitters) */
  128. #define LL_I2C_SR1_BERR I2C_SR1_BERR /*!< Bus error */
  129. #define LL_I2C_SR1_ARLO I2C_SR1_ARLO /*!< Arbitration lost */
  130. #define LL_I2C_SR1_AF I2C_SR1_AF /*!< Acknowledge failure flag */
  131. #define LL_I2C_SR1_OVR I2C_SR1_OVR /*!< Overrun/Underrun */
  132. #define LL_I2C_SR1_PECERR I2C_ISR_PECERR /*!< PEC Error in reception (SMBus mode) */
  133. #define LL_I2C_SR1_TIMEOUT I2C_ISR_TIMEOUT /*!< Timeout detection flag (SMBus mode) */
  134. #define LL_I2C_SR1_SMALERT I2C_ISR_SMALERT /*!< SMBus alert (SMBus mode) */
  135. #define LL_I2C_SR2_MSL I2C_SR2_MSL /*!< Master/Slave flag */
  136. #define LL_I2C_SR2_BUSY I2C_SR2_BUSY /*!< Bus busy flag */
  137. #define LL_I2C_SR2_TRA I2C_SR2_TRA /*!< Transmitter/receiver direction */
  138. #define LL_I2C_SR2_GENCALL I2C_SR2_GENCALL /*!< General call address (Slave mode) */
  139. #define LL_I2C_SR2_SMBDEFAULT I2C_SR2_SMBDEFAULT /*!< SMBus Device default address (Slave mode) */
  140. #define LL_I2C_SR2_SMBHOST I2C_SR2_SMBHOST /*!< SMBus Host address (Slave mode) */
  141. #define LL_I2C_SR2_DUALF I2C_SR2_DUALF /*!< Dual flag (Slave mode) */
  142. /**
  143. * @}
  144. */
  145. /** @defgroup I2C_LL_EC_IT IT Defines
  146. * @brief IT defines which can be used with LL_I2C_ReadReg and LL_I2C_WriteReg functions
  147. * @{
  148. */
  149. #define LL_I2C_CR2_ITEVTEN I2C_CR2_ITEVTEN /*!< Events interrupts enable */
  150. #define LL_I2C_CR2_ITBUFEN I2C_CR2_ITBUFEN /*!< Buffer interrupts enable */
  151. #define LL_I2C_CR2_ITERREN I2C_CR2_ITERREN /*!< Error interrupts enable */
  152. /**
  153. * @}
  154. */
  155. #if defined(I2C_FLTR_ANOFF)
  156. /** @defgroup I2C_LL_EC_ANALOGFILTER_SELECTION Analog Filter Selection
  157. * @{
  158. */
  159. #define LL_I2C_ANALOGFILTER_ENABLE 0x00000000U /*!< Analog filter is enabled. */
  160. #define LL_I2C_ANALOGFILTER_DISABLE I2C_FLTR_ANOFF /*!< Analog filter is disabled.*/
  161. /**
  162. * @}
  163. */
  164. #endif
  165. /** @defgroup I2C_LL_EC_OWNADDRESS1 Own Address 1 Length
  166. * @{
  167. */
  168. #define LL_I2C_OWNADDRESS1_7BIT 0x00004000U /*!< Own address 1 is a 7-bit address. */
  169. #define LL_I2C_OWNADDRESS1_10BIT (uint32_t)(I2C_OAR1_ADDMODE | 0x00004000U) /*!< Own address 1 is a 10-bit address. */
  170. /**
  171. * @}
  172. */
  173. /** @defgroup I2C_LL_EC_DUTYCYCLE Fast Mode Duty Cycle
  174. * @{
  175. */
  176. #define LL_I2C_DUTYCYCLE_2 0x00000000U /*!< I2C fast mode Tlow/Thigh = 2 */
  177. #define LL_I2C_DUTYCYCLE_16_9 I2C_CCR_DUTY /*!< I2C fast mode Tlow/Thigh = 16/9 */
  178. /**
  179. * @}
  180. */
  181. /** @defgroup I2C_LL_EC_CLOCK_SPEED_MODE Master Clock Speed Mode
  182. * @{
  183. */
  184. #define LL_I2C_CLOCK_SPEED_STANDARD_MODE 0x00000000U /*!< Master clock speed range is standard mode */
  185. #define LL_I2C_CLOCK_SPEED_FAST_MODE I2C_CCR_FS /*!< Master clock speed range is fast mode */
  186. /**
  187. * @}
  188. */
  189. /** @defgroup I2C_LL_EC_PERIPHERAL_MODE Peripheral Mode
  190. * @{
  191. */
  192. #define LL_I2C_MODE_I2C 0x00000000U /*!< I2C Master or Slave mode */
  193. #define LL_I2C_MODE_SMBUS_HOST (uint32_t)(I2C_CR1_SMBUS | I2C_CR1_SMBTYPE | I2C_CR1_ENARP) /*!< SMBus Host address acknowledge */
  194. #define LL_I2C_MODE_SMBUS_DEVICE I2C_CR1_SMBUS /*!< SMBus Device default mode (Default address not acknowledge) */
  195. #define LL_I2C_MODE_SMBUS_DEVICE_ARP (uint32_t)(I2C_CR1_SMBUS | I2C_CR1_ENARP) /*!< SMBus Device Default address acknowledge */
  196. /**
  197. * @}
  198. */
  199. /** @defgroup I2C_LL_EC_I2C_ACKNOWLEDGE Acknowledge Generation
  200. * @{
  201. */
  202. #define LL_I2C_ACK I2C_CR1_ACK /*!< ACK is sent after current received byte. */
  203. #define LL_I2C_NACK 0x00000000U /*!< NACK is sent after current received byte.*/
  204. /**
  205. * @}
  206. */
  207. /** @defgroup I2C_LL_EC_DIRECTION Read Write Direction
  208. * @{
  209. */
  210. #define LL_I2C_DIRECTION_WRITE I2C_SR2_TRA /*!< Bus is in write transfer */
  211. #define LL_I2C_DIRECTION_READ 0x00000000U /*!< Bus is in read transfer */
  212. /**
  213. * @}
  214. */
  215. /**
  216. * @}
  217. */
  218. /* Exported macro ------------------------------------------------------------*/
  219. /** @defgroup I2C_LL_Exported_Macros I2C Exported Macros
  220. * @{
  221. */
  222. /** @defgroup I2C_LL_EM_WRITE_READ Common Write and read registers Macros
  223. * @{
  224. */
  225. /**
  226. * @brief Write a value in I2C register
  227. * @param __INSTANCE__ I2C Instance
  228. * @param __REG__ Register to be written
  229. * @param __VALUE__ Value to be written in the register
  230. * @retval None
  231. */
  232. #define LL_I2C_WriteReg(__INSTANCE__, __REG__, __VALUE__) WRITE_REG(__INSTANCE__->__REG__, (__VALUE__))
  233. /**
  234. * @brief Read a value in I2C register
  235. * @param __INSTANCE__ I2C Instance
  236. * @param __REG__ Register to be read
  237. * @retval Register value
  238. */
  239. #define LL_I2C_ReadReg(__INSTANCE__, __REG__) READ_REG(__INSTANCE__->__REG__)
  240. /**
  241. * @}
  242. */
  243. /** @defgroup I2C_LL_EM_Exported_Macros_Helper Exported_Macros_Helper
  244. * @{
  245. */
  246. /**
  247. * @brief Convert Peripheral Clock Frequency in Mhz.
  248. * @param __PCLK__ This parameter must be a value of peripheral clock (in Hz).
  249. * @retval Value of peripheral clock (in Mhz)
  250. */
  251. #define __LL_I2C_FREQ_HZ_TO_MHZ(__PCLK__) (uint32_t)((__PCLK__)/1000000U)
  252. /**
  253. * @brief Convert Peripheral Clock Frequency in Hz.
  254. * @param __PCLK__ This parameter must be a value of peripheral clock (in Mhz).
  255. * @retval Value of peripheral clock (in Hz)
  256. */
  257. #define __LL_I2C_FREQ_MHZ_TO_HZ(__PCLK__) (uint32_t)((__PCLK__)*1000000U)
  258. /**
  259. * @brief Compute I2C Clock rising time.
  260. * @param __FREQRANGE__ This parameter must be a value of peripheral clock (in Mhz).
  261. * @param __SPEED__ This parameter must be a value lower than 400kHz (in Hz).
  262. * @retval Value between Min_Data=0x02 and Max_Data=0x3F
  263. */
  264. #define __LL_I2C_RISE_TIME(__FREQRANGE__, __SPEED__) (uint32_t)(((__SPEED__) <= LL_I2C_MAX_SPEED_STANDARD) ? ((__FREQRANGE__) + 1U) : ((((__FREQRANGE__) * 300U) / 1000U) + 1U))
  265. /**
  266. * @brief Compute Speed clock range to a Clock Control Register (I2C_CCR_CCR) value.
  267. * @param __PCLK__ This parameter must be a value of peripheral clock (in Hz).
  268. * @param __SPEED__ This parameter must be a value lower than 400kHz (in Hz).
  269. * @param __DUTYCYCLE__ This parameter can be one of the following values:
  270. * @arg @ref LL_I2C_DUTYCYCLE_2
  271. * @arg @ref LL_I2C_DUTYCYCLE_16_9
  272. * @retval Value between Min_Data=0x004 and Max_Data=0xFFF, except in FAST DUTY mode where Min_Data=0x001.
  273. */
  274. #define __LL_I2C_SPEED_TO_CCR(__PCLK__, __SPEED__, __DUTYCYCLE__) (uint32_t)(((__SPEED__) <= LL_I2C_MAX_SPEED_STANDARD)? \
  275. (__LL_I2C_SPEED_STANDARD_TO_CCR((__PCLK__), (__SPEED__))) : \
  276. (__LL_I2C_SPEED_FAST_TO_CCR((__PCLK__), (__SPEED__), (__DUTYCYCLE__))))
  277. /**
  278. * @brief Compute Speed Standard clock range to a Clock Control Register (I2C_CCR_CCR) value.
  279. * @param __PCLK__ This parameter must be a value of peripheral clock (in Hz).
  280. * @param __SPEED__ This parameter must be a value lower than 100kHz (in Hz).
  281. * @retval Value between Min_Data=0x004 and Max_Data=0xFFF.
  282. */
  283. #define __LL_I2C_SPEED_STANDARD_TO_CCR(__PCLK__, __SPEED__) (uint32_t)(((((__PCLK__)/((__SPEED__) << 1U)) & I2C_CCR_CCR) < 4U)? 4U:((__PCLK__) / ((__SPEED__) << 1U)))
  284. /**
  285. * @brief Compute Speed Fast clock range to a Clock Control Register (I2C_CCR_CCR) value.
  286. * @param __PCLK__ This parameter must be a value of peripheral clock (in Hz).
  287. * @param __SPEED__ This parameter must be a value between Min_Data=100Khz and Max_Data=400Khz (in Hz).
  288. * @param __DUTYCYCLE__ This parameter can be one of the following values:
  289. * @arg @ref LL_I2C_DUTYCYCLE_2
  290. * @arg @ref LL_I2C_DUTYCYCLE_16_9
  291. * @retval Value between Min_Data=0x001 and Max_Data=0xFFF
  292. */
  293. #define __LL_I2C_SPEED_FAST_TO_CCR(__PCLK__, __SPEED__, __DUTYCYCLE__) (uint32_t)(((__DUTYCYCLE__) == LL_I2C_DUTYCYCLE_2)? \
  294. (((((__PCLK__) / ((__SPEED__) * 3U)) & I2C_CCR_CCR) == 0U)? 1U:((__PCLK__) / ((__SPEED__) * 3U))) : \
  295. (((((__PCLK__) / ((__SPEED__) * 25U)) & I2C_CCR_CCR) == 0U)? 1U:((__PCLK__) / ((__SPEED__) * 25U))))
  296. /**
  297. * @brief Get the Least significant bits of a 10-Bits address.
  298. * @param __ADDRESS__ This parameter must be a value of a 10-Bits slave address.
  299. * @retval Value between Min_Data=0x00 and Max_Data=0xFF
  300. */
  301. #define __LL_I2C_10BIT_ADDRESS(__ADDRESS__) ((uint8_t)((uint16_t)((__ADDRESS__) & (uint16_t)(0x00FF))))
  302. /**
  303. * @brief Convert a 10-Bits address to a 10-Bits header with Write direction.
  304. * @param __ADDRESS__ This parameter must be a value of a 10-Bits slave address.
  305. * @retval Value between Min_Data=0xF0 and Max_Data=0xF6
  306. */
  307. #define __LL_I2C_10BIT_HEADER_WRITE(__ADDRESS__) ((uint8_t)((uint16_t)((uint16_t)(((uint16_t)((__ADDRESS__) & (uint16_t)(0x0300))) >> 7) | (uint16_t)(0xF0))))
  308. /**
  309. * @brief Convert a 10-Bits address to a 10-Bits header with Read direction.
  310. * @param __ADDRESS__ This parameter must be a value of a 10-Bits slave address.
  311. * @retval Value between Min_Data=0xF1 and Max_Data=0xF7
  312. */
  313. #define __LL_I2C_10BIT_HEADER_READ(__ADDRESS__) ((uint8_t)((uint16_t)((uint16_t)(((uint16_t)((__ADDRESS__) & (uint16_t)(0x0300))) >> 7) | (uint16_t)(0xF1))))
  314. /**
  315. * @}
  316. */
  317. /**
  318. * @}
  319. */
  320. /* Exported functions --------------------------------------------------------*/
  321. /** @defgroup I2C_LL_Exported_Functions I2C Exported Functions
  322. * @{
  323. */
  324. /** @defgroup I2C_LL_EF_Configuration Configuration
  325. * @{
  326. */
  327. /**
  328. * @brief Enable I2C peripheral (PE = 1).
  329. * @rmtoll CR1 PE LL_I2C_Enable
  330. * @param I2Cx I2C Instance.
  331. * @retval None
  332. */
  333. __STATIC_INLINE void LL_I2C_Enable(I2C_TypeDef *I2Cx)
  334. {
  335. SET_BIT(I2Cx->CR1, I2C_CR1_PE);
  336. }
  337. /**
  338. * @brief Disable I2C peripheral (PE = 0).
  339. * @rmtoll CR1 PE LL_I2C_Disable
  340. * @param I2Cx I2C Instance.
  341. * @retval None
  342. */
  343. __STATIC_INLINE void LL_I2C_Disable(I2C_TypeDef *I2Cx)
  344. {
  345. CLEAR_BIT(I2Cx->CR1, I2C_CR1_PE);
  346. }
  347. /**
  348. * @brief Check if the I2C peripheral is enabled or disabled.
  349. * @rmtoll CR1 PE LL_I2C_IsEnabled
  350. * @param I2Cx I2C Instance.
  351. * @retval State of bit (1 or 0).
  352. */
  353. __STATIC_INLINE uint32_t LL_I2C_IsEnabled(I2C_TypeDef *I2Cx)
  354. {
  355. return (READ_BIT(I2Cx->CR1, I2C_CR1_PE) == (I2C_CR1_PE));
  356. }
  357. #if defined(I2C_FLTR_ANOFF)&&defined(I2C_FLTR_DNF)
  358. /**
  359. * @brief Configure Noise Filters (Analog and Digital).
  360. * @note If the analog filter is also enabled, the digital filter is added to analog filter.
  361. * The filters can only be programmed when the I2C is disabled (PE = 0).
  362. * @rmtoll FLTR ANOFF LL_I2C_ConfigFilters\n
  363. * FLTR DNF LL_I2C_ConfigFilters
  364. * @param I2Cx I2C Instance.
  365. * @param AnalogFilter This parameter can be one of the following values:
  366. * @arg @ref LL_I2C_ANALOGFILTER_ENABLE
  367. * @arg @ref LL_I2C_ANALOGFILTER_DISABLE
  368. * @param DigitalFilter This parameter must be a value between Min_Data=0x00 (Digital filter disabled) and Max_Data=0x0F (Digital filter enabled and filtering capability up to 15*TPCLK1)
  369. * This parameter is used to configure the digital noise filter on SDA and SCL input. The digital filter will suppress the spikes with a length of up to DNF[3:0]*TPCLK1.
  370. * @retval None
  371. */
  372. __STATIC_INLINE void LL_I2C_ConfigFilters(I2C_TypeDef *I2Cx, uint32_t AnalogFilter, uint32_t DigitalFilter)
  373. {
  374. MODIFY_REG(I2Cx->FLTR, I2C_FLTR_ANOFF | I2C_FLTR_DNF, AnalogFilter | DigitalFilter);
  375. }
  376. #endif
  377. #if defined(I2C_FLTR_DNF)
  378. /**
  379. * @brief Configure Digital Noise Filter.
  380. * @note If the analog filter is also enabled, the digital filter is added to analog filter.
  381. * This filter can only be programmed when the I2C is disabled (PE = 0).
  382. * @rmtoll FLTR DNF LL_I2C_SetDigitalFilter
  383. * @param I2Cx I2C Instance.
  384. * @param DigitalFilter This parameter must be a value between Min_Data=0x00 (Digital filter disabled) and Max_Data=0x0F (Digital filter enabled and filtering capability up to 15*TPCLK1)
  385. * This parameter is used to configure the digital noise filter on SDA and SCL input. The digital filter will suppress the spikes with a length of up to DNF[3:0]*TPCLK1.
  386. * @retval None
  387. */
  388. __STATIC_INLINE void LL_I2C_SetDigitalFilter(I2C_TypeDef *I2Cx, uint32_t DigitalFilter)
  389. {
  390. MODIFY_REG(I2Cx->FLTR, I2C_FLTR_DNF, DigitalFilter);
  391. }
  392. /**
  393. * @brief Get the current Digital Noise Filter configuration.
  394. * @rmtoll FLTR DNF LL_I2C_GetDigitalFilter
  395. * @param I2Cx I2C Instance.
  396. * @retval Value between Min_Data=0x0 and Max_Data=0xF
  397. */
  398. __STATIC_INLINE uint32_t LL_I2C_GetDigitalFilter(I2C_TypeDef *I2Cx)
  399. {
  400. return (uint32_t)(READ_BIT(I2Cx->FLTR, I2C_FLTR_DNF));
  401. }
  402. #endif
  403. #if defined(I2C_FLTR_ANOFF)
  404. /**
  405. * @brief Enable Analog Noise Filter.
  406. * @note This filter can only be programmed when the I2C is disabled (PE = 0).
  407. * @rmtoll FLTR ANOFF LL_I2C_EnableAnalogFilter
  408. * @param I2Cx I2C Instance.
  409. * @retval None
  410. */
  411. __STATIC_INLINE void LL_I2C_EnableAnalogFilter(I2C_TypeDef *I2Cx)
  412. {
  413. CLEAR_BIT(I2Cx->FLTR, I2C_FLTR_ANOFF);
  414. }
  415. /**
  416. * @brief Disable Analog Noise Filter.
  417. * @note This filter can only be programmed when the I2C is disabled (PE = 0).
  418. * @rmtoll FLTR ANOFF LL_I2C_DisableAnalogFilter
  419. * @param I2Cx I2C Instance.
  420. * @retval None
  421. */
  422. __STATIC_INLINE void LL_I2C_DisableAnalogFilter(I2C_TypeDef *I2Cx)
  423. {
  424. SET_BIT(I2Cx->FLTR, I2C_FLTR_ANOFF);
  425. }
  426. /**
  427. * @brief Check if Analog Noise Filter is enabled or disabled.
  428. * @rmtoll FLTR ANOFF LL_I2C_IsEnabledAnalogFilter
  429. * @param I2Cx I2C Instance.
  430. * @retval State of bit (1 or 0).
  431. */
  432. __STATIC_INLINE uint32_t LL_I2C_IsEnabledAnalogFilter(I2C_TypeDef *I2Cx)
  433. {
  434. return (READ_BIT(I2Cx->FLTR, I2C_FLTR_ANOFF) == (I2C_FLTR_ANOFF));
  435. }
  436. #endif
  437. /**
  438. * @brief Enable DMA transmission requests.
  439. * @rmtoll CR2 DMAEN LL_I2C_EnableDMAReq_TX
  440. * @param I2Cx I2C Instance.
  441. * @retval None
  442. */
  443. __STATIC_INLINE void LL_I2C_EnableDMAReq_TX(I2C_TypeDef *I2Cx)
  444. {
  445. SET_BIT(I2Cx->CR2, I2C_CR2_DMAEN);
  446. }
  447. /**
  448. * @brief Disable DMA transmission requests.
  449. * @rmtoll CR2 DMAEN LL_I2C_DisableDMAReq_TX
  450. * @param I2Cx I2C Instance.
  451. * @retval None
  452. */
  453. __STATIC_INLINE void LL_I2C_DisableDMAReq_TX(I2C_TypeDef *I2Cx)
  454. {
  455. CLEAR_BIT(I2Cx->CR2, I2C_CR2_DMAEN);
  456. }
  457. /**
  458. * @brief Check if DMA transmission requests are enabled or disabled.
  459. * @rmtoll CR2 DMAEN LL_I2C_IsEnabledDMAReq_TX
  460. * @param I2Cx I2C Instance.
  461. * @retval State of bit (1 or 0).
  462. */
  463. __STATIC_INLINE uint32_t LL_I2C_IsEnabledDMAReq_TX(I2C_TypeDef *I2Cx)
  464. {
  465. return (READ_BIT(I2Cx->CR2, I2C_CR2_DMAEN) == (I2C_CR2_DMAEN));
  466. }
  467. /**
  468. * @brief Enable DMA reception requests.
  469. * @rmtoll CR2 DMAEN LL_I2C_EnableDMAReq_RX
  470. * @param I2Cx I2C Instance.
  471. * @retval None
  472. */
  473. __STATIC_INLINE void LL_I2C_EnableDMAReq_RX(I2C_TypeDef *I2Cx)
  474. {
  475. SET_BIT(I2Cx->CR2, I2C_CR2_DMAEN);
  476. }
  477. /**
  478. * @brief Disable DMA reception requests.
  479. * @rmtoll CR2 DMAEN LL_I2C_DisableDMAReq_RX
  480. * @param I2Cx I2C Instance.
  481. * @retval None
  482. */
  483. __STATIC_INLINE void LL_I2C_DisableDMAReq_RX(I2C_TypeDef *I2Cx)
  484. {
  485. CLEAR_BIT(I2Cx->CR2, I2C_CR2_DMAEN);
  486. }
  487. /**
  488. * @brief Check if DMA reception requests are enabled or disabled.
  489. * @rmtoll CR2 DMAEN LL_I2C_IsEnabledDMAReq_RX
  490. * @param I2Cx I2C Instance.
  491. * @retval State of bit (1 or 0).
  492. */
  493. __STATIC_INLINE uint32_t LL_I2C_IsEnabledDMAReq_RX(I2C_TypeDef *I2Cx)
  494. {
  495. return (READ_BIT(I2Cx->CR2, I2C_CR2_DMAEN) == (I2C_CR2_DMAEN));
  496. }
  497. /**
  498. * @brief Get the data register address used for DMA transfer.
  499. * @rmtoll DR DR LL_I2C_DMA_GetRegAddr
  500. * @param I2Cx I2C Instance.
  501. * @retval Address of data register
  502. */
  503. __STATIC_INLINE uint32_t LL_I2C_DMA_GetRegAddr(I2C_TypeDef *I2Cx)
  504. {
  505. return (uint32_t) & (I2Cx->DR);
  506. }
  507. /**
  508. * @brief Enable Clock stretching.
  509. * @note This bit can only be programmed when the I2C is disabled (PE = 0).
  510. * @rmtoll CR1 NOSTRETCH LL_I2C_EnableClockStretching
  511. * @param I2Cx I2C Instance.
  512. * @retval None
  513. */
  514. __STATIC_INLINE void LL_I2C_EnableClockStretching(I2C_TypeDef *I2Cx)
  515. {
  516. CLEAR_BIT(I2Cx->CR1, I2C_CR1_NOSTRETCH);
  517. }
  518. /**
  519. * @brief Disable Clock stretching.
  520. * @note This bit can only be programmed when the I2C is disabled (PE = 0).
  521. * @rmtoll CR1 NOSTRETCH LL_I2C_DisableClockStretching
  522. * @param I2Cx I2C Instance.
  523. * @retval None
  524. */
  525. __STATIC_INLINE void LL_I2C_DisableClockStretching(I2C_TypeDef *I2Cx)
  526. {
  527. SET_BIT(I2Cx->CR1, I2C_CR1_NOSTRETCH);
  528. }
  529. /**
  530. * @brief Check if Clock stretching is enabled or disabled.
  531. * @rmtoll CR1 NOSTRETCH LL_I2C_IsEnabledClockStretching
  532. * @param I2Cx I2C Instance.
  533. * @retval State of bit (1 or 0).
  534. */
  535. __STATIC_INLINE uint32_t LL_I2C_IsEnabledClockStretching(I2C_TypeDef *I2Cx)
  536. {
  537. return (READ_BIT(I2Cx->CR1, I2C_CR1_NOSTRETCH) != (I2C_CR1_NOSTRETCH));
  538. }
  539. /**
  540. * @brief Enable General Call.
  541. * @note When enabled the Address 0x00 is ACKed.
  542. * @rmtoll CR1 ENGC LL_I2C_EnableGeneralCall
  543. * @param I2Cx I2C Instance.
  544. * @retval None
  545. */
  546. __STATIC_INLINE void LL_I2C_EnableGeneralCall(I2C_TypeDef *I2Cx)
  547. {
  548. SET_BIT(I2Cx->CR1, I2C_CR1_ENGC);
  549. }
  550. /**
  551. * @brief Disable General Call.
  552. * @note When disabled the Address 0x00 is NACKed.
  553. * @rmtoll CR1 ENGC LL_I2C_DisableGeneralCall
  554. * @param I2Cx I2C Instance.
  555. * @retval None
  556. */
  557. __STATIC_INLINE void LL_I2C_DisableGeneralCall(I2C_TypeDef *I2Cx)
  558. {
  559. CLEAR_BIT(I2Cx->CR1, I2C_CR1_ENGC);
  560. }
  561. /**
  562. * @brief Check if General Call is enabled or disabled.
  563. * @rmtoll CR1 ENGC LL_I2C_IsEnabledGeneralCall
  564. * @param I2Cx I2C Instance.
  565. * @retval State of bit (1 or 0).
  566. */
  567. __STATIC_INLINE uint32_t LL_I2C_IsEnabledGeneralCall(I2C_TypeDef *I2Cx)
  568. {
  569. return (READ_BIT(I2Cx->CR1, I2C_CR1_ENGC) == (I2C_CR1_ENGC));
  570. }
  571. /**
  572. * @brief Set the Own Address1.
  573. * @rmtoll OAR1 ADD0 LL_I2C_SetOwnAddress1\n
  574. * OAR1 ADD1_7 LL_I2C_SetOwnAddress1\n
  575. * OAR1 ADD8_9 LL_I2C_SetOwnAddress1\n
  576. * OAR1 ADDMODE LL_I2C_SetOwnAddress1
  577. * @param I2Cx I2C Instance.
  578. * @param OwnAddress1 This parameter must be a value between Min_Data=0 and Max_Data=0x3FF.
  579. * @param OwnAddrSize This parameter can be one of the following values:
  580. * @arg @ref LL_I2C_OWNADDRESS1_7BIT
  581. * @arg @ref LL_I2C_OWNADDRESS1_10BIT
  582. * @retval None
  583. */
  584. __STATIC_INLINE void LL_I2C_SetOwnAddress1(I2C_TypeDef *I2Cx, uint32_t OwnAddress1, uint32_t OwnAddrSize)
  585. {
  586. MODIFY_REG(I2Cx->OAR1, I2C_OAR1_ADD0 | I2C_OAR1_ADD1_7 | I2C_OAR1_ADD8_9 | I2C_OAR1_ADDMODE, OwnAddress1 | OwnAddrSize);
  587. }
  588. /**
  589. * @brief Set the 7bits Own Address2.
  590. * @note This action has no effect if own address2 is enabled.
  591. * @rmtoll OAR2 ADD2 LL_I2C_SetOwnAddress2
  592. * @param I2Cx I2C Instance.
  593. * @param OwnAddress2 This parameter must be a value between Min_Data=0 and Max_Data=0x7F.
  594. * @retval None
  595. */
  596. __STATIC_INLINE void LL_I2C_SetOwnAddress2(I2C_TypeDef *I2Cx, uint32_t OwnAddress2)
  597. {
  598. MODIFY_REG(I2Cx->OAR2, I2C_OAR2_ADD2, OwnAddress2);
  599. }
  600. /**
  601. * @brief Enable acknowledge on Own Address2 match address.
  602. * @rmtoll OAR2 ENDUAL LL_I2C_EnableOwnAddress2
  603. * @param I2Cx I2C Instance.
  604. * @retval None
  605. */
  606. __STATIC_INLINE void LL_I2C_EnableOwnAddress2(I2C_TypeDef *I2Cx)
  607. {
  608. SET_BIT(I2Cx->OAR2, I2C_OAR2_ENDUAL);
  609. }
  610. /**
  611. * @brief Disable acknowledge on Own Address2 match address.
  612. * @rmtoll OAR2 ENDUAL LL_I2C_DisableOwnAddress2
  613. * @param I2Cx I2C Instance.
  614. * @retval None
  615. */
  616. __STATIC_INLINE void LL_I2C_DisableOwnAddress2(I2C_TypeDef *I2Cx)
  617. {
  618. CLEAR_BIT(I2Cx->OAR2, I2C_OAR2_ENDUAL);
  619. }
  620. /**
  621. * @brief Check if Own Address1 acknowledge is enabled or disabled.
  622. * @rmtoll OAR2 ENDUAL LL_I2C_IsEnabledOwnAddress2
  623. * @param I2Cx I2C Instance.
  624. * @retval State of bit (1 or 0).
  625. */
  626. __STATIC_INLINE uint32_t LL_I2C_IsEnabledOwnAddress2(I2C_TypeDef *I2Cx)
  627. {
  628. return (READ_BIT(I2Cx->OAR2, I2C_OAR2_ENDUAL) == (I2C_OAR2_ENDUAL));
  629. }
  630. /**
  631. * @brief Configure the Peripheral clock frequency.
  632. * @rmtoll CR2 FREQ LL_I2C_SetPeriphClock
  633. * @param I2Cx I2C Instance.
  634. * @param PeriphClock Peripheral Clock (in Hz)
  635. * @retval None
  636. */
  637. __STATIC_INLINE void LL_I2C_SetPeriphClock(I2C_TypeDef *I2Cx, uint32_t PeriphClock)
  638. {
  639. MODIFY_REG(I2Cx->CR2, I2C_CR2_FREQ, __LL_I2C_FREQ_HZ_TO_MHZ(PeriphClock));
  640. }
  641. /**
  642. * @brief Get the Peripheral clock frequency.
  643. * @rmtoll CR2 FREQ LL_I2C_GetPeriphClock
  644. * @param I2Cx I2C Instance.
  645. * @retval Value of Peripheral Clock (in Hz)
  646. */
  647. __STATIC_INLINE uint32_t LL_I2C_GetPeriphClock(I2C_TypeDef *I2Cx)
  648. {
  649. return (uint32_t)(__LL_I2C_FREQ_MHZ_TO_HZ(READ_BIT(I2Cx->CR2, I2C_CR2_FREQ)));
  650. }
  651. /**
  652. * @brief Configure the Duty cycle (Fast mode only).
  653. * @rmtoll CCR DUTY LL_I2C_SetDutyCycle
  654. * @param I2Cx I2C Instance.
  655. * @param DutyCycle This parameter can be one of the following values:
  656. * @arg @ref LL_I2C_DUTYCYCLE_2
  657. * @arg @ref LL_I2C_DUTYCYCLE_16_9
  658. * @retval None
  659. */
  660. __STATIC_INLINE void LL_I2C_SetDutyCycle(I2C_TypeDef *I2Cx, uint32_t DutyCycle)
  661. {
  662. MODIFY_REG(I2Cx->CCR, I2C_CCR_DUTY, DutyCycle);
  663. }
  664. /**
  665. * @brief Get the Duty cycle (Fast mode only).
  666. * @rmtoll CCR DUTY LL_I2C_GetDutyCycle
  667. * @param I2Cx I2C Instance.
  668. * @retval Returned value can be one of the following values:
  669. * @arg @ref LL_I2C_DUTYCYCLE_2
  670. * @arg @ref LL_I2C_DUTYCYCLE_16_9
  671. */
  672. __STATIC_INLINE uint32_t LL_I2C_GetDutyCycle(I2C_TypeDef *I2Cx)
  673. {
  674. return (uint32_t)(READ_BIT(I2Cx->CCR, I2C_CCR_DUTY));
  675. }
  676. /**
  677. * @brief Configure the I2C master clock speed mode.
  678. * @rmtoll CCR FS LL_I2C_SetClockSpeedMode
  679. * @param I2Cx I2C Instance.
  680. * @param ClockSpeedMode This parameter can be one of the following values:
  681. * @arg @ref LL_I2C_CLOCK_SPEED_STANDARD_MODE
  682. * @arg @ref LL_I2C_CLOCK_SPEED_FAST_MODE
  683. * @retval None
  684. */
  685. __STATIC_INLINE void LL_I2C_SetClockSpeedMode(I2C_TypeDef *I2Cx, uint32_t ClockSpeedMode)
  686. {
  687. MODIFY_REG(I2Cx->CCR, I2C_CCR_FS, ClockSpeedMode);
  688. }
  689. /**
  690. * @brief Get the the I2C master speed mode.
  691. * @rmtoll CCR FS LL_I2C_GetClockSpeedMode
  692. * @param I2Cx I2C Instance.
  693. * @retval Returned value can be one of the following values:
  694. * @arg @ref LL_I2C_CLOCK_SPEED_STANDARD_MODE
  695. * @arg @ref LL_I2C_CLOCK_SPEED_FAST_MODE
  696. */
  697. __STATIC_INLINE uint32_t LL_I2C_GetClockSpeedMode(I2C_TypeDef *I2Cx)
  698. {
  699. return (uint32_t)(READ_BIT(I2Cx->CCR, I2C_CCR_FS));
  700. }
  701. /**
  702. * @brief Configure the SCL, SDA rising time.
  703. * @note This bit can only be programmed when the I2C is disabled (PE = 0).
  704. * @rmtoll TRISE TRISE LL_I2C_SetRiseTime
  705. * @param I2Cx I2C Instance.
  706. * @param RiseTime This parameter must be a value between Min_Data=0x02 and Max_Data=0x3F.
  707. * @retval None
  708. */
  709. __STATIC_INLINE void LL_I2C_SetRiseTime(I2C_TypeDef *I2Cx, uint32_t RiseTime)
  710. {
  711. MODIFY_REG(I2Cx->TRISE, I2C_TRISE_TRISE, RiseTime);
  712. }
  713. /**
  714. * @brief Get the SCL, SDA rising time.
  715. * @rmtoll TRISE TRISE LL_I2C_GetRiseTime
  716. * @param I2Cx I2C Instance.
  717. * @retval Value between Min_Data=0x02 and Max_Data=0x3F
  718. */
  719. __STATIC_INLINE uint32_t LL_I2C_GetRiseTime(I2C_TypeDef *I2Cx)
  720. {
  721. return (uint32_t)(READ_BIT(I2Cx->TRISE, I2C_TRISE_TRISE));
  722. }
  723. /**
  724. * @brief Configure the SCL high and low period.
  725. * @note This bit can only be programmed when the I2C is disabled (PE = 0).
  726. * @rmtoll CCR CCR LL_I2C_SetClockPeriod
  727. * @param I2Cx I2C Instance.
  728. * @param ClockPeriod This parameter must be a value between Min_Data=0x004 and Max_Data=0xFFF, except in FAST DUTY mode where Min_Data=0x001.
  729. * @retval None
  730. */
  731. __STATIC_INLINE void LL_I2C_SetClockPeriod(I2C_TypeDef *I2Cx, uint32_t ClockPeriod)
  732. {
  733. MODIFY_REG(I2Cx->CCR, I2C_CCR_CCR, ClockPeriod);
  734. }
  735. /**
  736. * @brief Get the SCL high and low period.
  737. * @rmtoll CCR CCR LL_I2C_GetClockPeriod
  738. * @param I2Cx I2C Instance.
  739. * @retval Value between Min_Data=0x004 and Max_Data=0xFFF, except in FAST DUTY mode where Min_Data=0x001.
  740. */
  741. __STATIC_INLINE uint32_t LL_I2C_GetClockPeriod(I2C_TypeDef *I2Cx)
  742. {
  743. return (uint32_t)(READ_BIT(I2Cx->CCR, I2C_CCR_CCR));
  744. }
  745. /**
  746. * @brief Configure the SCL speed.
  747. * @note This bit can only be programmed when the I2C is disabled (PE = 0).
  748. * @rmtoll CR2 FREQ LL_I2C_ConfigSpeed\n
  749. * TRISE TRISE LL_I2C_ConfigSpeed\n
  750. * CCR FS LL_I2C_ConfigSpeed\n
  751. * CCR DUTY LL_I2C_ConfigSpeed\n
  752. * CCR CCR LL_I2C_ConfigSpeed
  753. * @param I2Cx I2C Instance.
  754. * @param PeriphClock Peripheral Clock (in Hz)
  755. * @param ClockSpeed This parameter must be a value lower than 400kHz (in Hz).
  756. * @param DutyCycle This parameter can be one of the following values:
  757. * @arg @ref LL_I2C_DUTYCYCLE_2
  758. * @arg @ref LL_I2C_DUTYCYCLE_16_9
  759. * @retval None
  760. */
  761. __STATIC_INLINE void LL_I2C_ConfigSpeed(I2C_TypeDef *I2Cx, uint32_t PeriphClock, uint32_t ClockSpeed,
  762. uint32_t DutyCycle)
  763. {
  764. register uint32_t freqrange = 0x0U;
  765. register uint32_t clockconfig = 0x0U;
  766. /* Compute frequency range */
  767. freqrange = __LL_I2C_FREQ_HZ_TO_MHZ(PeriphClock);
  768. /* Configure I2Cx: Frequency range register */
  769. MODIFY_REG(I2Cx->CR2, I2C_CR2_FREQ, freqrange);
  770. /* Configure I2Cx: Rise Time register */
  771. MODIFY_REG(I2Cx->TRISE, I2C_TRISE_TRISE, __LL_I2C_RISE_TIME(freqrange, ClockSpeed));
  772. /* Configure Speed mode, Duty Cycle and Clock control register value */
  773. if (ClockSpeed > LL_I2C_MAX_SPEED_STANDARD)
  774. {
  775. /* Set Speed mode at fast and duty cycle for Clock Speed request in fast clock range */
  776. clockconfig = LL_I2C_CLOCK_SPEED_FAST_MODE | \
  777. __LL_I2C_SPEED_FAST_TO_CCR(PeriphClock, ClockSpeed, DutyCycle) | \
  778. DutyCycle;
  779. }
  780. else
  781. {
  782. /* Set Speed mode at standard for Clock Speed request in standard clock range */
  783. clockconfig = LL_I2C_CLOCK_SPEED_STANDARD_MODE | \
  784. __LL_I2C_SPEED_STANDARD_TO_CCR(PeriphClock, ClockSpeed);
  785. }
  786. /* Configure I2Cx: Clock control register */
  787. MODIFY_REG(I2Cx->CCR, (I2C_CCR_FS | I2C_CCR_DUTY | I2C_CCR_CCR), clockconfig);
  788. }
  789. /**
  790. * @brief Configure peripheral mode.
  791. * @note Macro @ref IS_SMBUS_ALL_INSTANCE(I2Cx) can be used to check whether or not
  792. * SMBus feature is supported by the I2Cx Instance.
  793. * @rmtoll CR1 SMBUS LL_I2C_SetMode\n
  794. * CR1 SMBTYPE LL_I2C_SetMode\n
  795. * CR1 ENARP LL_I2C_SetMode
  796. * @param I2Cx I2C Instance.
  797. * @param PeripheralMode This parameter can be one of the following values:
  798. * @arg @ref LL_I2C_MODE_I2C
  799. * @arg @ref LL_I2C_MODE_SMBUS_HOST
  800. * @arg @ref LL_I2C_MODE_SMBUS_DEVICE
  801. * @arg @ref LL_I2C_MODE_SMBUS_DEVICE_ARP
  802. * @retval None
  803. */
  804. __STATIC_INLINE void LL_I2C_SetMode(I2C_TypeDef *I2Cx, uint32_t PeripheralMode)
  805. {
  806. MODIFY_REG(I2Cx->CR1, I2C_CR1_SMBUS | I2C_CR1_SMBTYPE | I2C_CR1_ENARP, PeripheralMode);
  807. }
  808. /**
  809. * @brief Get peripheral mode.
  810. * @note Macro @ref IS_SMBUS_ALL_INSTANCE(I2Cx) can be used to check whether or not
  811. * SMBus feature is supported by the I2Cx Instance.
  812. * @rmtoll CR1 SMBUS LL_I2C_GetMode\n
  813. * CR1 SMBTYPE LL_I2C_GetMode\n
  814. * CR1 ENARP LL_I2C_GetMode
  815. * @param I2Cx I2C Instance.
  816. * @retval Returned value can be one of the following values:
  817. * @arg @ref LL_I2C_MODE_I2C
  818. * @arg @ref LL_I2C_MODE_SMBUS_HOST
  819. * @arg @ref LL_I2C_MODE_SMBUS_DEVICE
  820. * @arg @ref LL_I2C_MODE_SMBUS_DEVICE_ARP
  821. */
  822. __STATIC_INLINE uint32_t LL_I2C_GetMode(I2C_TypeDef *I2Cx)
  823. {
  824. return (uint32_t)(READ_BIT(I2Cx->CR1, I2C_CR1_SMBUS | I2C_CR1_SMBTYPE | I2C_CR1_ENARP));
  825. }
  826. /**
  827. * @brief Enable SMBus alert (Host or Device mode)
  828. * @note Macro @ref IS_SMBUS_ALL_INSTANCE(I2Cx) can be used to check whether or not
  829. * SMBus feature is supported by the I2Cx Instance.
  830. * @note SMBus Device mode:
  831. * - SMBus Alert pin is drived low and
  832. * Alert Response Address Header acknowledge is enabled.
  833. * SMBus Host mode:
  834. * - SMBus Alert pin management is supported.
  835. * @rmtoll CR1 ALERT LL_I2C_EnableSMBusAlert
  836. * @param I2Cx I2C Instance.
  837. * @retval None
  838. */
  839. __STATIC_INLINE void LL_I2C_EnableSMBusAlert(I2C_TypeDef *I2Cx)
  840. {
  841. SET_BIT(I2Cx->CR1, I2C_CR1_ALERT);
  842. }
  843. /**
  844. * @brief Disable SMBus alert (Host or Device mode)
  845. * @note Macro @ref IS_SMBUS_ALL_INSTANCE(I2Cx) can be used to check whether or not
  846. * SMBus feature is supported by the I2Cx Instance.
  847. * @note SMBus Device mode:
  848. * - SMBus Alert pin is not drived (can be used as a standard GPIO) and
  849. * Alert Response Address Header acknowledge is disabled.
  850. * SMBus Host mode:
  851. * - SMBus Alert pin management is not supported.
  852. * @rmtoll CR1 ALERT LL_I2C_DisableSMBusAlert
  853. * @param I2Cx I2C Instance.
  854. * @retval None
  855. */
  856. __STATIC_INLINE void LL_I2C_DisableSMBusAlert(I2C_TypeDef *I2Cx)
  857. {
  858. CLEAR_BIT(I2Cx->CR1, I2C_CR1_ALERT);
  859. }
  860. /**
  861. * @brief Check if SMBus alert (Host or Device mode) is enabled or disabled.
  862. * @note Macro @ref IS_SMBUS_ALL_INSTANCE(I2Cx) can be used to check whether or not
  863. * SMBus feature is supported by the I2Cx Instance.
  864. * @rmtoll CR1 ALERT LL_I2C_IsEnabledSMBusAlert
  865. * @param I2Cx I2C Instance.
  866. * @retval State of bit (1 or 0).
  867. */
  868. __STATIC_INLINE uint32_t LL_I2C_IsEnabledSMBusAlert(I2C_TypeDef *I2Cx)
  869. {
  870. return (READ_BIT(I2Cx->CR1, I2C_CR1_ALERT) == (I2C_CR1_ALERT));
  871. }
  872. /**
  873. * @brief Enable SMBus Packet Error Calculation (PEC).
  874. * @note Macro @ref IS_SMBUS_ALL_INSTANCE(I2Cx) can be used to check whether or not
  875. * SMBus feature is supported by the I2Cx Instance.
  876. * @rmtoll CR1 ENPEC LL_I2C_EnableSMBusPEC
  877. * @param I2Cx I2C Instance.
  878. * @retval None
  879. */
  880. __STATIC_INLINE void LL_I2C_EnableSMBusPEC(I2C_TypeDef *I2Cx)
  881. {
  882. SET_BIT(I2Cx->CR1, I2C_CR1_ENPEC);
  883. }
  884. /**
  885. * @brief Disable SMBus Packet Error Calculation (PEC).
  886. * @note Macro @ref IS_SMBUS_ALL_INSTANCE(I2Cx) can be used to check whether or not
  887. * SMBus feature is supported by the I2Cx Instance.
  888. * @rmtoll CR1 ENPEC LL_I2C_DisableSMBusPEC
  889. * @param I2Cx I2C Instance.
  890. * @retval None
  891. */
  892. __STATIC_INLINE void LL_I2C_DisableSMBusPEC(I2C_TypeDef *I2Cx)
  893. {
  894. CLEAR_BIT(I2Cx->CR1, I2C_CR1_ENPEC);
  895. }
  896. /**
  897. * @brief Check if SMBus Packet Error Calculation (PEC) is enabled or disabled.
  898. * @note Macro @ref IS_SMBUS_ALL_INSTANCE(I2Cx) can be used to check whether or not
  899. * SMBus feature is supported by the I2Cx Instance.
  900. * @rmtoll CR1 ENPEC LL_I2C_IsEnabledSMBusPEC
  901. * @param I2Cx I2C Instance.
  902. * @retval State of bit (1 or 0).
  903. */
  904. __STATIC_INLINE uint32_t LL_I2C_IsEnabledSMBusPEC(I2C_TypeDef *I2Cx)
  905. {
  906. return (READ_BIT(I2Cx->CR1, I2C_CR1_ENPEC) == (I2C_CR1_ENPEC));
  907. }
  908. /**
  909. * @}
  910. */
  911. /** @defgroup I2C_LL_EF_IT_Management IT_Management
  912. * @{
  913. */
  914. /**
  915. * @brief Enable TXE interrupt.
  916. * @rmtoll CR2 ITEVTEN LL_I2C_EnableIT_TX\n
  917. * CR2 ITBUFEN LL_I2C_EnableIT_TX
  918. * @param I2Cx I2C Instance.
  919. * @retval None
  920. */
  921. __STATIC_INLINE void LL_I2C_EnableIT_TX(I2C_TypeDef *I2Cx)
  922. {
  923. SET_BIT(I2Cx->CR2, I2C_CR2_ITEVTEN | I2C_CR2_ITBUFEN);
  924. }
  925. /**
  926. * @brief Disable TXE interrupt.
  927. * @rmtoll CR2 ITEVTEN LL_I2C_DisableIT_TX\n
  928. * CR2 ITBUFEN LL_I2C_DisableIT_TX
  929. * @param I2Cx I2C Instance.
  930. * @retval None
  931. */
  932. __STATIC_INLINE void LL_I2C_DisableIT_TX(I2C_TypeDef *I2Cx)
  933. {
  934. CLEAR_BIT(I2Cx->CR2, I2C_CR2_ITEVTEN | I2C_CR2_ITBUFEN);
  935. }
  936. /**
  937. * @brief Check if the TXE Interrupt is enabled or disabled.
  938. * @rmtoll CR2 ITEVTEN LL_I2C_IsEnabledIT_TX\n
  939. * CR2 ITBUFEN LL_I2C_IsEnabledIT_TX
  940. * @param I2Cx I2C Instance.
  941. * @retval State of bit (1 or 0).
  942. */
  943. __STATIC_INLINE uint32_t LL_I2C_IsEnabledIT_TX(I2C_TypeDef *I2Cx)
  944. {
  945. return (READ_BIT(I2Cx->CR2, I2C_CR2_ITEVTEN | I2C_CR2_ITBUFEN) == (I2C_CR2_ITEVTEN | I2C_CR2_ITBUFEN));
  946. }
  947. /**
  948. * @brief Enable RXNE interrupt.
  949. * @rmtoll CR2 ITEVTEN LL_I2C_EnableIT_RX\n
  950. * CR2 ITBUFEN LL_I2C_EnableIT_RX
  951. * @param I2Cx I2C Instance.
  952. * @retval None
  953. */
  954. __STATIC_INLINE void LL_I2C_EnableIT_RX(I2C_TypeDef *I2Cx)
  955. {
  956. SET_BIT(I2Cx->CR2, I2C_CR2_ITEVTEN | I2C_CR2_ITBUFEN);
  957. }
  958. /**
  959. * @brief Disable RXNE interrupt.
  960. * @rmtoll CR2 ITEVTEN LL_I2C_DisableIT_RX\n
  961. * CR2 ITBUFEN LL_I2C_DisableIT_RX
  962. * @param I2Cx I2C Instance.
  963. * @retval None
  964. */
  965. __STATIC_INLINE void LL_I2C_DisableIT_RX(I2C_TypeDef *I2Cx)
  966. {
  967. CLEAR_BIT(I2Cx->CR2, I2C_CR2_ITEVTEN | I2C_CR2_ITBUFEN);
  968. }
  969. /**
  970. * @brief Check if the RXNE Interrupt is enabled or disabled.
  971. * @rmtoll CR2 ITEVTEN LL_I2C_IsEnabledIT_RX\n
  972. * CR2 ITBUFEN LL_I2C_IsEnabledIT_RX
  973. * @param I2Cx I2C Instance.
  974. * @retval State of bit (1 or 0).
  975. */
  976. __STATIC_INLINE uint32_t LL_I2C_IsEnabledIT_RX(I2C_TypeDef *I2Cx)
  977. {
  978. return (READ_BIT(I2Cx->CR2, I2C_CR2_ITEVTEN | I2C_CR2_ITBUFEN) == (I2C_CR2_ITEVTEN | I2C_CR2_ITBUFEN));
  979. }
  980. /**
  981. * @brief Enable Events interrupts.
  982. * @note Any of these events will generate interrupt :
  983. * Start Bit (SB)
  984. * Address sent, Address matched (ADDR)
  985. * 10-bit header sent (ADD10)
  986. * Stop detection (STOPF)
  987. * Byte transfer finished (BTF)
  988. *
  989. * @note Any of these events will generate interrupt if Buffer interrupts are enabled too(using unitary function @ref LL_I2C_EnableIT_BUF()) :
  990. * Receive buffer not empty (RXNE)
  991. * Transmit buffer empty (TXE)
  992. * @rmtoll CR2 ITEVTEN LL_I2C_EnableIT_EVT
  993. * @param I2Cx I2C Instance.
  994. * @retval None
  995. */
  996. __STATIC_INLINE void LL_I2C_EnableIT_EVT(I2C_TypeDef *I2Cx)
  997. {
  998. SET_BIT(I2Cx->CR2, I2C_CR2_ITEVTEN);
  999. }
  1000. /**
  1001. * @brief Disable Events interrupts.
  1002. * @note Any of these events will generate interrupt :
  1003. * Start Bit (SB)
  1004. * Address sent, Address matched (ADDR)
  1005. * 10-bit header sent (ADD10)
  1006. * Stop detection (STOPF)
  1007. * Byte transfer finished (BTF)
  1008. * Receive buffer not empty (RXNE)
  1009. * Transmit buffer empty (TXE)
  1010. * @rmtoll CR2 ITEVTEN LL_I2C_DisableIT_EVT
  1011. * @param I2Cx I2C Instance.
  1012. * @retval None
  1013. */
  1014. __STATIC_INLINE void LL_I2C_DisableIT_EVT(I2C_TypeDef *I2Cx)
  1015. {
  1016. CLEAR_BIT(I2Cx->CR2, I2C_CR2_ITEVTEN);
  1017. }
  1018. /**
  1019. * @brief Check if Events interrupts are enabled or disabled.
  1020. * @rmtoll CR2 ITEVTEN LL_I2C_IsEnabledIT_EVT
  1021. * @param I2Cx I2C Instance.
  1022. * @retval State of bit (1 or 0).
  1023. */
  1024. __STATIC_INLINE uint32_t LL_I2C_IsEnabledIT_EVT(I2C_TypeDef *I2Cx)
  1025. {
  1026. return (READ_BIT(I2Cx->CR2, I2C_CR2_ITEVTEN) == (I2C_CR2_ITEVTEN));
  1027. }
  1028. /**
  1029. * @brief Enable Buffer interrupts.
  1030. * @note Any of these Buffer events will generate interrupt if Events interrupts are enabled too(using unitary function @ref LL_I2C_EnableIT_EVT()) :
  1031. * Receive buffer not empty (RXNE)
  1032. * Transmit buffer empty (TXE)
  1033. * @rmtoll CR2 ITBUFEN LL_I2C_EnableIT_BUF
  1034. * @param I2Cx I2C Instance.
  1035. * @retval None
  1036. */
  1037. __STATIC_INLINE void LL_I2C_EnableIT_BUF(I2C_TypeDef *I2Cx)
  1038. {
  1039. SET_BIT(I2Cx->CR2, I2C_CR2_ITBUFEN);
  1040. }
  1041. /**
  1042. * @brief Disable Buffer interrupts.
  1043. * @note Any of these Buffer events will generate interrupt :
  1044. * Receive buffer not empty (RXNE)
  1045. * Transmit buffer empty (TXE)
  1046. * @rmtoll CR2 ITBUFEN LL_I2C_DisableIT_BUF
  1047. * @param I2Cx I2C Instance.
  1048. * @retval None
  1049. */
  1050. __STATIC_INLINE void LL_I2C_DisableIT_BUF(I2C_TypeDef *I2Cx)
  1051. {
  1052. CLEAR_BIT(I2Cx->CR2, I2C_CR2_ITBUFEN);
  1053. }
  1054. /**
  1055. * @brief Check if Buffer interrupts are enabled or disabled.
  1056. * @rmtoll CR2 ITBUFEN LL_I2C_IsEnabledIT_BUF
  1057. * @param I2Cx I2C Instance.
  1058. * @retval State of bit (1 or 0).
  1059. */
  1060. __STATIC_INLINE uint32_t LL_I2C_IsEnabledIT_BUF(I2C_TypeDef *I2Cx)
  1061. {
  1062. return (READ_BIT(I2Cx->CR2, I2C_CR2_ITBUFEN) == (I2C_CR2_ITBUFEN));
  1063. }
  1064. /**
  1065. * @brief Enable Error interrupts.
  1066. * @note Macro @ref IS_SMBUS_ALL_INSTANCE(I2Cx) can be used to check whether or not
  1067. * SMBus feature is supported by the I2Cx Instance.
  1068. * @note Any of these errors will generate interrupt :
  1069. * Bus Error detection (BERR)
  1070. * Arbitration Loss (ARLO)
  1071. * Acknowledge Failure(AF)
  1072. * Overrun/Underrun (OVR)
  1073. * SMBus Timeout detection (TIMEOUT)
  1074. * SMBus PEC error detection (PECERR)
  1075. * SMBus Alert pin event detection (SMBALERT)
  1076. * @rmtoll CR2 ITERREN LL_I2C_EnableIT_ERR
  1077. * @param I2Cx I2C Instance.
  1078. * @retval None
  1079. */
  1080. __STATIC_INLINE void LL_I2C_EnableIT_ERR(I2C_TypeDef *I2Cx)
  1081. {
  1082. SET_BIT(I2Cx->CR2, I2C_CR2_ITERREN);
  1083. }
  1084. /**
  1085. * @brief Disable Error interrupts.
  1086. * @note Macro @ref IS_SMBUS_ALL_INSTANCE(I2Cx) can be used to check whether or not
  1087. * SMBus feature is supported by the I2Cx Instance.
  1088. * @note Any of these errors will generate interrupt :
  1089. * Bus Error detection (BERR)
  1090. * Arbitration Loss (ARLO)
  1091. * Acknowledge Failure(AF)
  1092. * Overrun/Underrun (OVR)
  1093. * SMBus Timeout detection (TIMEOUT)
  1094. * SMBus PEC error detection (PECERR)
  1095. * SMBus Alert pin event detection (SMBALERT)
  1096. * @rmtoll CR2 ITERREN LL_I2C_DisableIT_ERR
  1097. * @param I2Cx I2C Instance.
  1098. * @retval None
  1099. */
  1100. __STATIC_INLINE void LL_I2C_DisableIT_ERR(I2C_TypeDef *I2Cx)
  1101. {
  1102. CLEAR_BIT(I2Cx->CR2, I2C_CR2_ITERREN);
  1103. }
  1104. /**
  1105. * @brief Check if Error interrupts are enabled or disabled.
  1106. * @rmtoll CR2 ITERREN LL_I2C_IsEnabledIT_ERR
  1107. * @param I2Cx I2C Instance.
  1108. * @retval State of bit (1 or 0).
  1109. */
  1110. __STATIC_INLINE uint32_t LL_I2C_IsEnabledIT_ERR(I2C_TypeDef *I2Cx)
  1111. {
  1112. return (READ_BIT(I2Cx->CR2, I2C_CR2_ITERREN) == (I2C_CR2_ITERREN));
  1113. }
  1114. /**
  1115. * @}
  1116. */
  1117. /** @defgroup I2C_LL_EF_FLAG_management FLAG_management
  1118. * @{
  1119. */
  1120. /**
  1121. * @brief Indicate the status of Transmit data register empty flag.
  1122. * @note RESET: When next data is written in Transmit data register.
  1123. * SET: When Transmit data register is empty.
  1124. * @rmtoll SR1 TXE LL_I2C_IsActiveFlag_TXE
  1125. * @param I2Cx I2C Instance.
  1126. * @retval State of bit (1 or 0).
  1127. */
  1128. __STATIC_INLINE uint32_t LL_I2C_IsActiveFlag_TXE(I2C_TypeDef *I2Cx)
  1129. {
  1130. return (READ_BIT(I2Cx->SR1, I2C_SR1_TXE) == (I2C_SR1_TXE));
  1131. }
  1132. /**
  1133. * @brief Indicate the status of Byte Transfer Finished flag.
  1134. * RESET: When Data byte transfer not done.
  1135. * SET: When Data byte transfer succeeded.
  1136. * @rmtoll SR1 BTF LL_I2C_IsActiveFlag_BTF
  1137. * @param I2Cx I2C Instance.
  1138. * @retval State of bit (1 or 0).
  1139. */
  1140. __STATIC_INLINE uint32_t LL_I2C_IsActiveFlag_BTF(I2C_TypeDef *I2Cx)
  1141. {
  1142. return (READ_BIT(I2Cx->SR1, I2C_SR1_BTF) == (I2C_SR1_BTF));
  1143. }
  1144. /**
  1145. * @brief Indicate the status of Receive data register not empty flag.
  1146. * @note RESET: When Receive data register is read.
  1147. * SET: When the received data is copied in Receive data register.
  1148. * @rmtoll SR1 RXNE LL_I2C_IsActiveFlag_RXNE
  1149. * @param I2Cx I2C Instance.
  1150. * @retval State of bit (1 or 0).
  1151. */
  1152. __STATIC_INLINE uint32_t LL_I2C_IsActiveFlag_RXNE(I2C_TypeDef *I2Cx)
  1153. {
  1154. return (READ_BIT(I2Cx->SR1, I2C_SR1_RXNE) == (I2C_SR1_RXNE));
  1155. }
  1156. /**
  1157. * @brief Indicate the status of Start Bit (master mode).
  1158. * @note RESET: When No Start condition.
  1159. * SET: When Start condition is generated.
  1160. * @rmtoll SR1 SB LL_I2C_IsActiveFlag_SB
  1161. * @param I2Cx I2C Instance.
  1162. * @retval State of bit (1 or 0).
  1163. */
  1164. __STATIC_INLINE uint32_t LL_I2C_IsActiveFlag_SB(I2C_TypeDef *I2Cx)
  1165. {
  1166. return (READ_BIT(I2Cx->SR1, I2C_SR1_SB) == (I2C_SR1_SB));
  1167. }
  1168. /**
  1169. * @brief Indicate the status of Address sent (master mode) or Address matched flag (slave mode).
  1170. * @note RESET: Clear default value.
  1171. * SET: When the address is fully sent (master mode) or when the received slave address matched with one of the enabled slave address (slave mode).
  1172. * @rmtoll SR1 ADDR LL_I2C_IsActiveFlag_ADDR
  1173. * @param I2Cx I2C Instance.
  1174. * @retval State of bit (1 or 0).
  1175. */
  1176. __STATIC_INLINE uint32_t LL_I2C_IsActiveFlag_ADDR(I2C_TypeDef *I2Cx)
  1177. {
  1178. return (READ_BIT(I2Cx->SR1, I2C_SR1_ADDR) == (I2C_SR1_ADDR));
  1179. }
  1180. /**
  1181. * @brief Indicate the status of 10-bit header sent (master mode).
  1182. * @note RESET: When no ADD10 event occured.
  1183. * SET: When the master has sent the first address byte (header).
  1184. * @rmtoll SR1 ADD10 LL_I2C_IsActiveFlag_ADD10
  1185. * @param I2Cx I2C Instance.
  1186. * @retval State of bit (1 or 0).
  1187. */
  1188. __STATIC_INLINE uint32_t LL_I2C_IsActiveFlag_ADD10(I2C_TypeDef *I2Cx)
  1189. {
  1190. return (READ_BIT(I2Cx->SR1, I2C_SR1_ADD10) == (I2C_SR1_ADD10));
  1191. }
  1192. /**
  1193. * @brief Indicate the status of Acknowledge failure flag.
  1194. * @note RESET: No acknowledge failure.
  1195. * SET: When an acknowledge failure is received after a byte transmission.
  1196. * @rmtoll SR1 AF LL_I2C_IsActiveFlag_AF
  1197. * @param I2Cx I2C Instance.
  1198. * @retval State of bit (1 or 0).
  1199. */
  1200. __STATIC_INLINE uint32_t LL_I2C_IsActiveFlag_AF(I2C_TypeDef *I2Cx)
  1201. {
  1202. return (READ_BIT(I2Cx->SR1, I2C_SR1_AF) == (I2C_SR1_AF));
  1203. }
  1204. /**
  1205. * @brief Indicate the status of Stop detection flag (slave mode).
  1206. * @note RESET: Clear default value.
  1207. * SET: When a Stop condition is detected.
  1208. * @rmtoll SR1 STOPF LL_I2C_IsActiveFlag_STOP
  1209. * @param I2Cx I2C Instance.
  1210. * @retval State of bit (1 or 0).
  1211. */
  1212. __STATIC_INLINE uint32_t LL_I2C_IsActiveFlag_STOP(I2C_TypeDef *I2Cx)
  1213. {
  1214. return (READ_BIT(I2Cx->SR1, I2C_SR1_STOPF) == (I2C_SR1_STOPF));
  1215. }
  1216. /**
  1217. * @brief Indicate the status of Bus error flag.
  1218. * @note RESET: Clear default value.
  1219. * SET: When a misplaced Start or Stop condition is detected.
  1220. * @rmtoll SR1 BERR LL_I2C_IsActiveFlag_BERR
  1221. * @param I2Cx I2C Instance.
  1222. * @retval State of bit (1 or 0).
  1223. */
  1224. __STATIC_INLINE uint32_t LL_I2C_IsActiveFlag_BERR(I2C_TypeDef *I2Cx)
  1225. {
  1226. return (READ_BIT(I2Cx->SR1, I2C_SR1_BERR) == (I2C_SR1_BERR));
  1227. }
  1228. /**
  1229. * @brief Indicate the status of Arbitration lost flag.
  1230. * @note RESET: Clear default value.
  1231. * SET: When arbitration lost.
  1232. * @rmtoll SR1 ARLO LL_I2C_IsActiveFlag_ARLO
  1233. * @param I2Cx I2C Instance.
  1234. * @retval State of bit (1 or 0).
  1235. */
  1236. __STATIC_INLINE uint32_t LL_I2C_IsActiveFlag_ARLO(I2C_TypeDef *I2Cx)
  1237. {
  1238. return (READ_BIT(I2Cx->SR1, I2C_SR1_ARLO) == (I2C_SR1_ARLO));
  1239. }
  1240. /**
  1241. * @brief Indicate the status of Overrun/Underrun flag.
  1242. * @note RESET: Clear default value.
  1243. * SET: When an overrun/underrun error occurs (Clock Stretching Disabled).
  1244. * @rmtoll SR1 OVR LL_I2C_IsActiveFlag_OVR
  1245. * @param I2Cx I2C Instance.
  1246. * @retval State of bit (1 or 0).
  1247. */
  1248. __STATIC_INLINE uint32_t LL_I2C_IsActiveFlag_OVR(I2C_TypeDef *I2Cx)
  1249. {
  1250. return (READ_BIT(I2Cx->SR1, I2C_SR1_OVR) == (I2C_SR1_OVR));
  1251. }
  1252. /**
  1253. * @brief Indicate the status of SMBus PEC error flag in reception.
  1254. * @note Macro @ref IS_SMBUS_ALL_INSTANCE(I2Cx) can be used to check whether or not
  1255. * SMBus feature is supported by the I2Cx Instance.
  1256. * @rmtoll SR1 PECERR LL_I2C_IsActiveSMBusFlag_PECERR
  1257. * @param I2Cx I2C Instance.
  1258. * @retval State of bit (1 or 0).
  1259. */
  1260. __STATIC_INLINE uint32_t LL_I2C_IsActiveSMBusFlag_PECERR(I2C_TypeDef *I2Cx)
  1261. {
  1262. return (READ_BIT(I2Cx->SR1, I2C_SR1_PECERR) == (I2C_SR1_PECERR));
  1263. }
  1264. /**
  1265. * @brief Indicate the status of SMBus Timeout detection flag.
  1266. * @note Macro @ref IS_SMBUS_ALL_INSTANCE(I2Cx) can be used to check whether or not
  1267. * SMBus feature is supported by the I2Cx Instance.
  1268. * @rmtoll SR1 TIMEOUT LL_I2C_IsActiveSMBusFlag_TIMEOUT
  1269. * @param I2Cx I2C Instance.
  1270. * @retval State of bit (1 or 0).
  1271. */
  1272. __STATIC_INLINE uint32_t LL_I2C_IsActiveSMBusFlag_TIMEOUT(I2C_TypeDef *I2Cx)
  1273. {
  1274. return (READ_BIT(I2Cx->SR1, I2C_SR1_TIMEOUT) == (I2C_SR1_TIMEOUT));
  1275. }
  1276. /**
  1277. * @brief Indicate the status of SMBus alert flag.
  1278. * @note Macro @ref IS_SMBUS_ALL_INSTANCE(I2Cx) can be used to check whether or not
  1279. * SMBus feature is supported by the I2Cx Instance.
  1280. * @rmtoll SR1 SMBALERT LL_I2C_IsActiveSMBusFlag_ALERT
  1281. * @param I2Cx I2C Instance.
  1282. * @retval State of bit (1 or 0).
  1283. */
  1284. __STATIC_INLINE uint32_t LL_I2C_IsActiveSMBusFlag_ALERT(I2C_TypeDef *I2Cx)
  1285. {
  1286. return (READ_BIT(I2Cx->SR1, I2C_SR1_SMBALERT) == (I2C_SR1_SMBALERT));
  1287. }
  1288. /**
  1289. * @brief Indicate the status of Bus Busy flag.
  1290. * @note RESET: Clear default value.
  1291. * SET: When a Start condition is detected.
  1292. * @rmtoll SR2 BUSY LL_I2C_IsActiveFlag_BUSY
  1293. * @param I2Cx I2C Instance.
  1294. * @retval State of bit (1 or 0).
  1295. */
  1296. __STATIC_INLINE uint32_t LL_I2C_IsActiveFlag_BUSY(I2C_TypeDef *I2Cx)
  1297. {
  1298. return (READ_BIT(I2Cx->SR2, I2C_SR2_BUSY) == (I2C_SR2_BUSY));
  1299. }
  1300. /**
  1301. * @brief Indicate the status of Dual flag.
  1302. * @note RESET: Received address matched with OAR1.
  1303. * SET: Received address matched with OAR2.
  1304. * @rmtoll SR2 DUALF LL_I2C_IsActiveFlag_DUAL
  1305. * @param I2Cx I2C Instance.
  1306. * @retval State of bit (1 or 0).
  1307. */
  1308. __STATIC_INLINE uint32_t LL_I2C_IsActiveFlag_DUAL(I2C_TypeDef *I2Cx)
  1309. {
  1310. return (READ_BIT(I2Cx->SR2, I2C_SR2_DUALF) == (I2C_SR2_DUALF));
  1311. }
  1312. /**
  1313. * @brief Indicate the status of SMBus Host address reception (Slave mode).
  1314. * @note Macro @ref IS_SMBUS_ALL_INSTANCE(I2Cx) can be used to check whether or not
  1315. * SMBus feature is supported by the I2Cx Instance.
  1316. * @note RESET: No SMBus Host address
  1317. * SET: SMBus Host address received.
  1318. * @note This status is cleared by hardware after a STOP condition or repeated START condition.
  1319. * @rmtoll SR2 SMBHOST LL_I2C_IsActiveSMBusFlag_SMBHOST
  1320. * @param I2Cx I2C Instance.
  1321. * @retval State of bit (1 or 0).
  1322. */
  1323. __STATIC_INLINE uint32_t LL_I2C_IsActiveSMBusFlag_SMBHOST(I2C_TypeDef *I2Cx)
  1324. {
  1325. return (READ_BIT(I2Cx->SR2, I2C_SR2_SMBHOST) == (I2C_SR2_SMBHOST));
  1326. }
  1327. /**
  1328. * @brief Indicate the status of SMBus Device default address reception (Slave mode).
  1329. * @note Macro @ref IS_SMBUS_ALL_INSTANCE(I2Cx) can be used to check whether or not
  1330. * SMBus feature is supported by the I2Cx Instance.
  1331. * @note RESET: No SMBus Device default address
  1332. * SET: SMBus Device default address received.
  1333. * @note This status is cleared by hardware after a STOP condition or repeated START condition.
  1334. * @rmtoll SR2 SMBDEFAULT LL_I2C_IsActiveSMBusFlag_SMBDEFAULT
  1335. * @param I2Cx I2C Instance.
  1336. * @retval State of bit (1 or 0).
  1337. */
  1338. __STATIC_INLINE uint32_t LL_I2C_IsActiveSMBusFlag_SMBDEFAULT(I2C_TypeDef *I2Cx)
  1339. {
  1340. return (READ_BIT(I2Cx->SR2, I2C_SR2_SMBDEFAULT) == (I2C_SR2_SMBDEFAULT));
  1341. }
  1342. /**
  1343. * @brief Indicate the status of General call address reception (Slave mode).
  1344. * @note RESET: No Generall call address
  1345. * SET: General call address received.
  1346. * @note This status is cleared by hardware after a STOP condition or repeated START condition.
  1347. * @rmtoll SR2 GENCALL LL_I2C_IsActiveFlag_GENCALL
  1348. * @param I2Cx I2C Instance.
  1349. * @retval State of bit (1 or 0).
  1350. */
  1351. __STATIC_INLINE uint32_t LL_I2C_IsActiveFlag_GENCALL(I2C_TypeDef *I2Cx)
  1352. {
  1353. return (READ_BIT(I2Cx->SR2, I2C_SR2_GENCALL) == (I2C_SR2_GENCALL));
  1354. }
  1355. /**
  1356. * @brief Indicate the status of Master/Slave flag.
  1357. * @note RESET: Slave Mode.
  1358. * SET: Master Mode.
  1359. * @rmtoll SR2 MSL LL_I2C_IsActiveFlag_MSL
  1360. * @param I2Cx I2C Instance.
  1361. * @retval State of bit (1 or 0).
  1362. */
  1363. __STATIC_INLINE uint32_t LL_I2C_IsActiveFlag_MSL(I2C_TypeDef *I2Cx)
  1364. {
  1365. return (READ_BIT(I2Cx->SR2, I2C_SR2_MSL) == (I2C_SR2_MSL));
  1366. }
  1367. /**
  1368. * @brief Clear Address Matched flag.
  1369. * @note Clearing this flag is done by a read access to the I2Cx_SR1
  1370. * register followed by a read access to the I2Cx_SR2 register.
  1371. * @rmtoll SR1 ADDR LL_I2C_ClearFlag_ADDR
  1372. * @param I2Cx I2C Instance.
  1373. * @retval None
  1374. */
  1375. __STATIC_INLINE void LL_I2C_ClearFlag_ADDR(I2C_TypeDef *I2Cx)
  1376. {
  1377. __IO uint32_t tmpreg;
  1378. tmpreg = I2Cx->SR1;
  1379. (void) tmpreg;
  1380. tmpreg = I2Cx->SR2;
  1381. (void) tmpreg;
  1382. }
  1383. /**
  1384. * @brief Clear Acknowledge failure flag.
  1385. * @rmtoll SR1 AF LL_I2C_ClearFlag_AF
  1386. * @param I2Cx I2C Instance.
  1387. * @retval None
  1388. */
  1389. __STATIC_INLINE void LL_I2C_ClearFlag_AF(I2C_TypeDef *I2Cx)
  1390. {
  1391. CLEAR_BIT(I2Cx->SR1, I2C_SR1_AF);
  1392. }
  1393. /**
  1394. * @brief Clear Stop detection flag.
  1395. * @note Clearing this flag is done by a read access to the I2Cx_SR1
  1396. * register followed by a write access to I2Cx_CR1 register.
  1397. * @rmtoll SR1 STOPF LL_I2C_ClearFlag_STOP\n
  1398. * CR1 PE LL_I2C_ClearFlag_STOP
  1399. * @param I2Cx I2C Instance.
  1400. * @retval None
  1401. */
  1402. __STATIC_INLINE void LL_I2C_ClearFlag_STOP(I2C_TypeDef *I2Cx)
  1403. {
  1404. __IO uint32_t tmpreg;
  1405. tmpreg = I2Cx->SR1;
  1406. (void) tmpreg;
  1407. SET_BIT(I2Cx->CR1, I2C_CR1_PE);
  1408. }
  1409. /**
  1410. * @brief Clear Bus error flag.
  1411. * @rmtoll SR1 BERR LL_I2C_ClearFlag_BERR
  1412. * @param I2Cx I2C Instance.
  1413. * @retval None
  1414. */
  1415. __STATIC_INLINE void LL_I2C_ClearFlag_BERR(I2C_TypeDef *I2Cx)
  1416. {
  1417. CLEAR_BIT(I2Cx->SR1, I2C_SR1_BERR);
  1418. }
  1419. /**
  1420. * @brief Clear Arbitration lost flag.
  1421. * @rmtoll SR1 ARLO LL_I2C_ClearFlag_ARLO
  1422. * @param I2Cx I2C Instance.
  1423. * @retval None
  1424. */
  1425. __STATIC_INLINE void LL_I2C_ClearFlag_ARLO(I2C_TypeDef *I2Cx)
  1426. {
  1427. CLEAR_BIT(I2Cx->SR1, I2C_SR1_ARLO);
  1428. }
  1429. /**
  1430. * @brief Clear Overrun/Underrun flag.
  1431. * @rmtoll SR1 OVR LL_I2C_ClearFlag_OVR
  1432. * @param I2Cx I2C Instance.
  1433. * @retval None
  1434. */
  1435. __STATIC_INLINE void LL_I2C_ClearFlag_OVR(I2C_TypeDef *I2Cx)
  1436. {
  1437. CLEAR_BIT(I2Cx->SR1, I2C_SR1_OVR);
  1438. }
  1439. /**
  1440. * @brief Clear SMBus PEC error flag.
  1441. * @rmtoll SR1 PECERR LL_I2C_ClearSMBusFlag_PECERR
  1442. * @param I2Cx I2C Instance.
  1443. * @retval None
  1444. */
  1445. __STATIC_INLINE void LL_I2C_ClearSMBusFlag_PECERR(I2C_TypeDef *I2Cx)
  1446. {
  1447. CLEAR_BIT(I2Cx->SR1, I2C_SR1_PECERR);
  1448. }
  1449. /**
  1450. * @brief Clear SMBus Timeout detection flag.
  1451. * @note Macro @ref IS_SMBUS_ALL_INSTANCE(I2Cx) can be used to check whether or not
  1452. * SMBus feature is supported by the I2Cx Instance.
  1453. * @rmtoll SR1 TIMEOUT LL_I2C_ClearSMBusFlag_TIMEOUT
  1454. * @param I2Cx I2C Instance.
  1455. * @retval None
  1456. */
  1457. __STATIC_INLINE void LL_I2C_ClearSMBusFlag_TIMEOUT(I2C_TypeDef *I2Cx)
  1458. {
  1459. CLEAR_BIT(I2Cx->SR1, I2C_SR1_TIMEOUT);
  1460. }
  1461. /**
  1462. * @brief Clear SMBus Alert flag.
  1463. * @note Macro @ref IS_SMBUS_ALL_INSTANCE(I2Cx) can be used to check whether or not
  1464. * SMBus feature is supported by the I2Cx Instance.
  1465. * @rmtoll SR1 SMBALERT LL_I2C_ClearSMBusFlag_ALERT
  1466. * @param I2Cx I2C Instance.
  1467. * @retval None
  1468. */
  1469. __STATIC_INLINE void LL_I2C_ClearSMBusFlag_ALERT(I2C_TypeDef *I2Cx)
  1470. {
  1471. CLEAR_BIT(I2Cx->SR1, I2C_SR1_SMBALERT);
  1472. }
  1473. /**
  1474. * @}
  1475. */
  1476. /** @defgroup I2C_LL_EF_Data_Management Data_Management
  1477. * @{
  1478. */
  1479. /**
  1480. * @brief Enable Reset of I2C peripheral.
  1481. * @rmtoll CR1 SWRST LL_I2C_EnableReset
  1482. * @param I2Cx I2C Instance.
  1483. * @retval None
  1484. */
  1485. __STATIC_INLINE void LL_I2C_EnableReset(I2C_TypeDef *I2Cx)
  1486. {
  1487. SET_BIT(I2Cx->CR1, I2C_CR1_SWRST);
  1488. }
  1489. /**
  1490. * @brief Disable Reset of I2C peripheral.
  1491. * @rmtoll CR1 SWRST LL_I2C_DisableReset
  1492. * @param I2Cx I2C Instance.
  1493. * @retval None
  1494. */
  1495. __STATIC_INLINE void LL_I2C_DisableReset(I2C_TypeDef *I2Cx)
  1496. {
  1497. CLEAR_BIT(I2Cx->CR1, I2C_CR1_SWRST);
  1498. }
  1499. /**
  1500. * @brief Check if the I2C peripheral is under reset state or not.
  1501. * @rmtoll CR1 SWRST LL_I2C_IsResetEnabled
  1502. * @param I2Cx I2C Instance.
  1503. * @retval State of bit (1 or 0).
  1504. */
  1505. __STATIC_INLINE uint32_t LL_I2C_IsResetEnabled(I2C_TypeDef *I2Cx)
  1506. {
  1507. return (READ_BIT(I2Cx->CR1, I2C_CR1_SWRST) == (I2C_CR1_SWRST));
  1508. }
  1509. /**
  1510. * @brief Prepare the generation of a ACKnowledge or Non ACKnowledge condition after the address receive match code or next received byte.
  1511. * @note Usage in Slave or Master mode.
  1512. * @rmtoll CR1 ACK LL_I2C_AcknowledgeNextData
  1513. * @param I2Cx I2C Instance.
  1514. * @param TypeAcknowledge This parameter can be one of the following values:
  1515. * @arg @ref LL_I2C_ACK
  1516. * @arg @ref LL_I2C_NACK
  1517. * @retval None
  1518. */
  1519. __STATIC_INLINE void LL_I2C_AcknowledgeNextData(I2C_TypeDef *I2Cx, uint32_t TypeAcknowledge)
  1520. {
  1521. MODIFY_REG(I2Cx->CR1, I2C_CR1_ACK, TypeAcknowledge);
  1522. }
  1523. /**
  1524. * @brief Generate a START or RESTART condition
  1525. * @note The START bit can be set even if bus is BUSY or I2C is in slave mode.
  1526. * This action has no effect when RELOAD is set.
  1527. * @rmtoll CR1 START LL_I2C_GenerateStartCondition
  1528. * @param I2Cx I2C Instance.
  1529. * @retval None
  1530. */
  1531. __STATIC_INLINE void LL_I2C_GenerateStartCondition(I2C_TypeDef *I2Cx)
  1532. {
  1533. SET_BIT(I2Cx->CR1, I2C_CR1_START);
  1534. }
  1535. /**
  1536. * @brief Generate a STOP condition after the current byte transfer (master mode).
  1537. * @rmtoll CR1 STOP LL_I2C_GenerateStopCondition
  1538. * @param I2Cx I2C Instance.
  1539. * @retval None
  1540. */
  1541. __STATIC_INLINE void LL_I2C_GenerateStopCondition(I2C_TypeDef *I2Cx)
  1542. {
  1543. SET_BIT(I2Cx->CR1, I2C_CR1_STOP);
  1544. }
  1545. /**
  1546. * @brief Enable bit POS (master/host mode).
  1547. * @note In that case, the ACK bit controls the (N)ACK of the next byte received or the PEC bit indicates that the next byte in shift register is a PEC.
  1548. * @rmtoll CR1 POS LL_I2C_EnableBitPOS
  1549. * @param I2Cx I2C Instance.
  1550. * @retval None
  1551. */
  1552. __STATIC_INLINE void LL_I2C_EnableBitPOS(I2C_TypeDef *I2Cx)
  1553. {
  1554. SET_BIT(I2Cx->CR1, I2C_CR1_POS);
  1555. }
  1556. /**
  1557. * @brief Disable bit POS (master/host mode).
  1558. * @note In that case, the ACK bit controls the (N)ACK of the current byte received or the PEC bit indicates that the current byte in shift register is a PEC.
  1559. * @rmtoll CR1 POS LL_I2C_DisableBitPOS
  1560. * @param I2Cx I2C Instance.
  1561. * @retval None
  1562. */
  1563. __STATIC_INLINE void LL_I2C_DisableBitPOS(I2C_TypeDef *I2Cx)
  1564. {
  1565. CLEAR_BIT(I2Cx->CR1, I2C_CR1_POS);
  1566. }
  1567. /**
  1568. * @brief Check if bit POS is enabled or disabled.
  1569. * @rmtoll CR1 POS LL_I2C_IsEnabledBitPOS
  1570. * @param I2Cx I2C Instance.
  1571. * @retval State of bit (1 or 0).
  1572. */
  1573. __STATIC_INLINE uint32_t LL_I2C_IsEnabledBitPOS(I2C_TypeDef *I2Cx)
  1574. {
  1575. return (READ_BIT(I2Cx->CR1, I2C_CR1_POS) == (I2C_CR1_POS));
  1576. }
  1577. /**
  1578. * @brief Indicate the value of transfer direction.
  1579. * @note RESET: Bus is in read transfer (peripheral point of view).
  1580. * SET: Bus is in write transfer (peripheral point of view).
  1581. * @rmtoll SR2 TRA LL_I2C_GetTransferDirection
  1582. * @param I2Cx I2C Instance.
  1583. * @retval Returned value can be one of the following values:
  1584. * @arg @ref LL_I2C_DIRECTION_WRITE
  1585. * @arg @ref LL_I2C_DIRECTION_READ
  1586. */
  1587. __STATIC_INLINE uint32_t LL_I2C_GetTransferDirection(I2C_TypeDef *I2Cx)
  1588. {
  1589. return (uint32_t)(READ_BIT(I2Cx->SR2, I2C_SR2_TRA));
  1590. }
  1591. /**
  1592. * @brief Enable DMA last transfer.
  1593. * @note This action mean that next DMA EOT is the last transfer.
  1594. * @rmtoll CR2 LAST LL_I2C_EnableLastDMA
  1595. * @param I2Cx I2C Instance.
  1596. * @retval None
  1597. */
  1598. __STATIC_INLINE void LL_I2C_EnableLastDMA(I2C_TypeDef *I2Cx)
  1599. {
  1600. SET_BIT(I2Cx->CR2, I2C_CR2_LAST);
  1601. }
  1602. /**
  1603. * @brief Disable DMA last transfer.
  1604. * @note This action mean that next DMA EOT is not the last transfer.
  1605. * @rmtoll CR2 LAST LL_I2C_DisableLastDMA
  1606. * @param I2Cx I2C Instance.
  1607. * @retval None
  1608. */
  1609. __STATIC_INLINE void LL_I2C_DisableLastDMA(I2C_TypeDef *I2Cx)
  1610. {
  1611. CLEAR_BIT(I2Cx->CR2, I2C_CR2_LAST);
  1612. }
  1613. /**
  1614. * @brief Check if DMA last transfer is enabled or disabled.
  1615. * @rmtoll CR2 LAST LL_I2C_IsEnabledLastDMA
  1616. * @param I2Cx I2C Instance.
  1617. * @retval State of bit (1 or 0).
  1618. */
  1619. __STATIC_INLINE uint32_t LL_I2C_IsEnabledLastDMA(I2C_TypeDef *I2Cx)
  1620. {
  1621. return (READ_BIT(I2Cx->CR2, I2C_CR2_LAST) == (I2C_CR2_LAST));
  1622. }
  1623. /**
  1624. * @brief Enable transfer or internal comparison of the SMBus Packet Error byte (transmission or reception mode).
  1625. * @note Macro @ref IS_SMBUS_ALL_INSTANCE(I2Cx) can be used to check whether or not
  1626. * SMBus feature is supported by the I2Cx Instance.
  1627. * @note This feature is cleared by hardware when the PEC byte is transferred or compared,
  1628. * or by a START or STOP condition, it is also cleared by software.
  1629. * @rmtoll CR1 PEC LL_I2C_EnableSMBusPECCompare
  1630. * @param I2Cx I2C Instance.
  1631. * @retval None
  1632. */
  1633. __STATIC_INLINE void LL_I2C_EnableSMBusPECCompare(I2C_TypeDef *I2Cx)
  1634. {
  1635. SET_BIT(I2Cx->CR1, I2C_CR1_PEC);
  1636. }
  1637. /**
  1638. * @brief Disable transfer or internal comparison of the SMBus Packet Error byte (transmission or reception mode).
  1639. * @note Macro @ref IS_SMBUS_ALL_INSTANCE(I2Cx) can be used to check whether or not
  1640. * SMBus feature is supported by the I2Cx Instance.
  1641. * @rmtoll CR1 PEC LL_I2C_DisableSMBusPECCompare
  1642. * @param I2Cx I2C Instance.
  1643. * @retval None
  1644. */
  1645. __STATIC_INLINE void LL_I2C_DisableSMBusPECCompare(I2C_TypeDef *I2Cx)
  1646. {
  1647. CLEAR_BIT(I2Cx->CR1, I2C_CR1_PEC);
  1648. }
  1649. /**
  1650. * @brief Check if the SMBus Packet Error byte transfer or internal comparison is requested or not.
  1651. * @note Macro @ref IS_SMBUS_ALL_INSTANCE(I2Cx) can be used to check whether or not
  1652. * SMBus feature is supported by the I2Cx Instance.
  1653. * @rmtoll CR1 PEC LL_I2C_IsEnabledSMBusPECCompare
  1654. * @param I2Cx I2C Instance.
  1655. * @retval State of bit (1 or 0).
  1656. */
  1657. __STATIC_INLINE uint32_t LL_I2C_IsEnabledSMBusPECCompare(I2C_TypeDef *I2Cx)
  1658. {
  1659. return (READ_BIT(I2Cx->CR1, I2C_CR1_PEC) == (I2C_CR1_PEC));
  1660. }
  1661. /**
  1662. * @brief Get the SMBus Packet Error byte calculated.
  1663. * @note Macro @ref IS_SMBUS_ALL_INSTANCE(I2Cx) can be used to check whether or not
  1664. * SMBus feature is supported by the I2Cx Instance.
  1665. * @rmtoll SR2 PEC LL_I2C_GetSMBusPEC
  1666. * @param I2Cx I2C Instance.
  1667. * @retval Value between Min_Data=0x00 and Max_Data=0xFF
  1668. */
  1669. __STATIC_INLINE uint32_t LL_I2C_GetSMBusPEC(I2C_TypeDef *I2Cx)
  1670. {
  1671. return (uint32_t)(READ_BIT(I2Cx->SR2, I2C_SR2_PEC) >> I2C_SR2_PEC_Pos);
  1672. }
  1673. /**
  1674. * @brief Read Receive Data register.
  1675. * @rmtoll DR DR LL_I2C_ReceiveData8
  1676. * @param I2Cx I2C Instance.
  1677. * @retval Value between Min_Data=0x0 and Max_Data=0xFF
  1678. */
  1679. __STATIC_INLINE uint8_t LL_I2C_ReceiveData8(I2C_TypeDef *I2Cx)
  1680. {
  1681. return (uint8_t)(READ_BIT(I2Cx->DR, I2C_DR_DR));
  1682. }
  1683. /**
  1684. * @brief Write in Transmit Data Register .
  1685. * @rmtoll DR DR LL_I2C_TransmitData8
  1686. * @param I2Cx I2C Instance.
  1687. * @param Data Value between Min_Data=0x0 and Max_Data=0xFF
  1688. * @retval None
  1689. */
  1690. __STATIC_INLINE void LL_I2C_TransmitData8(I2C_TypeDef *I2Cx, uint8_t Data)
  1691. {
  1692. MODIFY_REG(I2Cx->DR, I2C_DR_DR, Data);
  1693. }
  1694. /**
  1695. * @}
  1696. */
  1697. #if defined(USE_FULL_LL_DRIVER)
  1698. /** @defgroup I2C_LL_EF_Init Initialization and de-initialization functions
  1699. * @{
  1700. */
  1701. uint32_t LL_I2C_Init(I2C_TypeDef *I2Cx, LL_I2C_InitTypeDef *I2C_InitStruct);
  1702. uint32_t LL_I2C_DeInit(I2C_TypeDef *I2Cx);
  1703. void LL_I2C_StructInit(LL_I2C_InitTypeDef *I2C_InitStruct);
  1704. /**
  1705. * @}
  1706. */
  1707. #endif /* USE_FULL_LL_DRIVER */
  1708. /**
  1709. * @}
  1710. */
  1711. /**
  1712. * @}
  1713. */
  1714. #endif /* I2C1 || I2C2 || I2C3 */
  1715. /**
  1716. * @}
  1717. */
  1718. #ifdef __cplusplus
  1719. }
  1720. #endif
  1721. #endif /* __STM32F4xx_LL_I2C_H */
  1722. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/