训练营PLSR题目
25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

2235 lines
85 KiB

  1. /**
  2. ******************************************************************************
  3. * @file stm32f4xx_ll_fmpi2c.h
  4. * @author MCD Application Team
  5. * @brief Header file of FMPI2C LL module.
  6. ******************************************************************************
  7. * @attention
  8. *
  9. * Copyright (c) 2016 STMicroelectronics.
  10. * All rights reserved.
  11. *
  12. * This software is licensed under terms that can be found in the LICENSE file
  13. * in the root directory of this software component.
  14. * If no LICENSE file comes with this software, it is provided AS-IS.
  15. *
  16. ******************************************************************************
  17. */
  18. /* Define to prevent recursive inclusion -------------------------------------*/
  19. #ifndef STM32F4xx_LL_FMPI2C_H
  20. #define STM32F4xx_LL_FMPI2C_H
  21. #ifdef __cplusplus
  22. extern "C" {
  23. #endif
  24. #if defined(FMPI2C_CR1_PE)
  25. /* Includes ------------------------------------------------------------------*/
  26. #include "stm32f4xx.h"
  27. /** @addtogroup STM32F4xx_LL_Driver
  28. * @{
  29. */
  30. #if defined (FMPI2C1)
  31. /** @defgroup FMPI2C_LL FMPI2C
  32. * @{
  33. */
  34. /* Private types -------------------------------------------------------------*/
  35. /* Private variables ---------------------------------------------------------*/
  36. /* Private constants ---------------------------------------------------------*/
  37. /** @defgroup FMPI2C_LL_Private_Constants FMPI2C Private Constants
  38. * @{
  39. */
  40. /**
  41. * @}
  42. */
  43. /* Private macros ------------------------------------------------------------*/
  44. #if defined(USE_FULL_LL_DRIVER)
  45. /** @defgroup FMPI2C_LL_Private_Macros FMPI2C Private Macros
  46. * @{
  47. */
  48. /**
  49. * @}
  50. */
  51. #endif /*USE_FULL_LL_DRIVER*/
  52. /* Exported types ------------------------------------------------------------*/
  53. #if defined(USE_FULL_LL_DRIVER)
  54. /** @defgroup FMPI2C_LL_ES_INIT FMPI2C Exported Init structure
  55. * @{
  56. */
  57. typedef struct
  58. {
  59. uint32_t PeripheralMode; /*!< Specifies the peripheral mode.
  60. This parameter can be a value of @ref FMPI2C_LL_EC_PERIPHERAL_MODE.
  61. This feature can be modified afterwards using unitary function
  62. @ref LL_FMPI2C_SetMode(). */
  63. uint32_t Timing; /*!< Specifies the SDA setup, hold time and the SCL high, low period values.
  64. This parameter must be set by referring to the STM32CubeMX Tool and
  65. the helper macro @ref __LL_FMPI2C_CONVERT_TIMINGS().
  66. This feature can be modified afterwards using unitary function
  67. @ref LL_FMPI2C_SetTiming(). */
  68. uint32_t AnalogFilter; /*!< Enables or disables analog noise filter.
  69. This parameter can be a value of @ref FMPI2C_LL_EC_ANALOGFILTER_SELECTION.
  70. This feature can be modified afterwards using unitary functions
  71. @ref LL_FMPI2C_EnableAnalogFilter() or LL_FMPI2C_DisableAnalogFilter(). */
  72. uint32_t DigitalFilter; /*!< Configures the digital noise filter.
  73. This parameter can be a number between Min_Data = 0x00 and Max_Data = 0x0F.
  74. This feature can be modified afterwards using unitary function
  75. @ref LL_FMPI2C_SetDigitalFilter(). */
  76. uint32_t OwnAddress1; /*!< Specifies the device own address 1.
  77. This parameter must be a value between Min_Data = 0x00 and Max_Data = 0x3FF.
  78. This feature can be modified afterwards using unitary function
  79. @ref LL_FMPI2C_SetOwnAddress1(). */
  80. uint32_t TypeAcknowledge; /*!< Specifies the ACKnowledge or Non ACKnowledge condition after the address receive
  81. match code or next received byte.
  82. This parameter can be a value of @ref FMPI2C_LL_EC_I2C_ACKNOWLEDGE.
  83. This feature can be modified afterwards using unitary function
  84. @ref LL_FMPI2C_AcknowledgeNextData(). */
  85. uint32_t OwnAddrSize; /*!< Specifies the device own address 1 size (7-bit or 10-bit).
  86. This parameter can be a value of @ref FMPI2C_LL_EC_OWNADDRESS1.
  87. This feature can be modified afterwards using unitary function
  88. @ref LL_FMPI2C_SetOwnAddress1(). */
  89. } LL_FMPI2C_InitTypeDef;
  90. /**
  91. * @}
  92. */
  93. #endif /*USE_FULL_LL_DRIVER*/
  94. /* Exported constants --------------------------------------------------------*/
  95. /** @defgroup FMPI2C_LL_Exported_Constants FMPI2C Exported Constants
  96. * @{
  97. */
  98. /** @defgroup FMPI2C_LL_EC_CLEAR_FLAG Clear Flags Defines
  99. * @brief Flags defines which can be used with LL_FMPI2C_WriteReg function
  100. * @{
  101. */
  102. #define LL_FMPI2C_ICR_ADDRCF FMPI2C_ICR_ADDRCF /*!< Address Matched flag */
  103. #define LL_FMPI2C_ICR_NACKCF FMPI2C_ICR_NACKCF /*!< Not Acknowledge flag */
  104. #define LL_FMPI2C_ICR_STOPCF FMPI2C_ICR_STOPCF /*!< Stop detection flag */
  105. #define LL_FMPI2C_ICR_BERRCF FMPI2C_ICR_BERRCF /*!< Bus error flag */
  106. #define LL_FMPI2C_ICR_ARLOCF FMPI2C_ICR_ARLOCF /*!< Arbitration Lost flag */
  107. #define LL_FMPI2C_ICR_OVRCF FMPI2C_ICR_OVRCF /*!< Overrun/Underrun flag */
  108. #define LL_FMPI2C_ICR_PECCF FMPI2C_ICR_PECCF /*!< PEC error flag */
  109. #define LL_FMPI2C_ICR_TIMOUTCF FMPI2C_ICR_TIMOUTCF /*!< Timeout detection flag */
  110. #define LL_FMPI2C_ICR_ALERTCF FMPI2C_ICR_ALERTCF /*!< Alert flag */
  111. /**
  112. * @}
  113. */
  114. /** @defgroup FMPI2C_LL_EC_GET_FLAG Get Flags Defines
  115. * @brief Flags defines which can be used with LL_FMPI2C_ReadReg function
  116. * @{
  117. */
  118. #define LL_FMPI2C_ISR_TXE FMPI2C_ISR_TXE /*!< Transmit data register empty */
  119. #define LL_FMPI2C_ISR_TXIS FMPI2C_ISR_TXIS /*!< Transmit interrupt status */
  120. #define LL_FMPI2C_ISR_RXNE FMPI2C_ISR_RXNE /*!< Receive data register not empty */
  121. #define LL_FMPI2C_ISR_ADDR FMPI2C_ISR_ADDR /*!< Address matched (slave mode) */
  122. #define LL_FMPI2C_ISR_NACKF FMPI2C_ISR_NACKF /*!< Not Acknowledge received flag */
  123. #define LL_FMPI2C_ISR_STOPF FMPI2C_ISR_STOPF /*!< Stop detection flag */
  124. #define LL_FMPI2C_ISR_TC FMPI2C_ISR_TC /*!< Transfer Complete (master mode) */
  125. #define LL_FMPI2C_ISR_TCR FMPI2C_ISR_TCR /*!< Transfer Complete Reload */
  126. #define LL_FMPI2C_ISR_BERR FMPI2C_ISR_BERR /*!< Bus error */
  127. #define LL_FMPI2C_ISR_ARLO FMPI2C_ISR_ARLO /*!< Arbitration lost */
  128. #define LL_FMPI2C_ISR_OVR FMPI2C_ISR_OVR /*!< Overrun/Underrun (slave mode) */
  129. #define LL_FMPI2C_ISR_PECERR FMPI2C_ISR_PECERR /*!< PEC Error in reception (SMBus mode) */
  130. #define LL_FMPI2C_ISR_TIMEOUT FMPI2C_ISR_TIMEOUT /*!< Timeout detection flag (SMBus mode) */
  131. #define LL_FMPI2C_ISR_ALERT FMPI2C_ISR_ALERT /*!< SMBus alert (SMBus mode) */
  132. #define LL_FMPI2C_ISR_BUSY FMPI2C_ISR_BUSY /*!< Bus busy */
  133. /**
  134. * @}
  135. */
  136. /** @defgroup FMPI2C_LL_EC_IT IT Defines
  137. * @brief IT defines which can be used with LL_FMPI2C_ReadReg and LL_FMPI2C_WriteReg functions
  138. * @{
  139. */
  140. #define LL_FMPI2C_CR1_TXIE FMPI2C_CR1_TXIE /*!< TX Interrupt enable */
  141. #define LL_FMPI2C_CR1_RXIE FMPI2C_CR1_RXIE /*!< RX Interrupt enable */
  142. #define LL_FMPI2C_CR1_ADDRIE FMPI2C_CR1_ADDRIE /*!< Address match Interrupt enable (slave only) */
  143. #define LL_FMPI2C_CR1_NACKIE FMPI2C_CR1_NACKIE /*!< Not acknowledge received Interrupt enable */
  144. #define LL_FMPI2C_CR1_STOPIE FMPI2C_CR1_STOPIE /*!< STOP detection Interrupt enable */
  145. #define LL_FMPI2C_CR1_TCIE FMPI2C_CR1_TCIE /*!< Transfer Complete interrupt enable */
  146. #define LL_FMPI2C_CR1_ERRIE FMPI2C_CR1_ERRIE /*!< Error interrupts enable */
  147. /**
  148. * @}
  149. */
  150. /** @defgroup FMPI2C_LL_EC_PERIPHERAL_MODE Peripheral Mode
  151. * @{
  152. */
  153. #define LL_FMPI2C_MODE_I2C 0x00000000U /*!< FMPI2C Master or Slave mode */
  154. #define LL_FMPI2C_MODE_SMBUS_HOST FMPI2C_CR1_SMBHEN /*!< SMBus Host address acknowledge */
  155. #define LL_FMPI2C_MODE_SMBUS_DEVICE 0x00000000U /*!< SMBus Device default mode
  156. (Default address not acknowledge) */
  157. #define LL_FMPI2C_MODE_SMBUS_DEVICE_ARP FMPI2C_CR1_SMBDEN /*!< SMBus Device Default address acknowledge */
  158. /**
  159. * @}
  160. */
  161. /** @defgroup FMPI2C_LL_EC_ANALOGFILTER_SELECTION Analog Filter Selection
  162. * @{
  163. */
  164. #define LL_FMPI2C_ANALOGFILTER_ENABLE 0x00000000U /*!< Analog filter is enabled. */
  165. #define LL_FMPI2C_ANALOGFILTER_DISABLE FMPI2C_CR1_ANFOFF /*!< Analog filter is disabled. */
  166. /**
  167. * @}
  168. */
  169. /** @defgroup FMPI2C_LL_EC_ADDRESSING_MODE Master Addressing Mode
  170. * @{
  171. */
  172. #define LL_FMPI2C_ADDRESSING_MODE_7BIT 0x00000000U /*!< Master operates in 7-bit addressing mode. */
  173. #define LL_FMPI2C_ADDRESSING_MODE_10BIT FMPI2C_CR2_ADD10 /*!< Master operates in 10-bit addressing mode.*/
  174. /**
  175. * @}
  176. */
  177. /** @defgroup FMPI2C_LL_EC_OWNADDRESS1 Own Address 1 Length
  178. * @{
  179. */
  180. #define LL_FMPI2C_OWNADDRESS1_7BIT 0x00000000U /*!< Own address 1 is a 7-bit address. */
  181. #define LL_FMPI2C_OWNADDRESS1_10BIT FMPI2C_OAR1_OA1MODE /*!< Own address 1 is a 10-bit address.*/
  182. /**
  183. * @}
  184. */
  185. /** @defgroup FMPI2C_LL_EC_OWNADDRESS2 Own Address 2 Masks
  186. * @{
  187. */
  188. #define LL_FMPI2C_OWNADDRESS2_NOMASK FMPI2C_OAR2_OA2NOMASK /*!< Own Address2 No mask. */
  189. #define LL_FMPI2C_OWNADDRESS2_MASK01 FMPI2C_OAR2_OA2MASK01 /*!< Only Address2 bits[7:2] are compared. */
  190. #define LL_FMPI2C_OWNADDRESS2_MASK02 FMPI2C_OAR2_OA2MASK02 /*!< Only Address2 bits[7:3] are compared. */
  191. #define LL_FMPI2C_OWNADDRESS2_MASK03 FMPI2C_OAR2_OA2MASK03 /*!< Only Address2 bits[7:4] are compared. */
  192. #define LL_FMPI2C_OWNADDRESS2_MASK04 FMPI2C_OAR2_OA2MASK04 /*!< Only Address2 bits[7:5] are compared. */
  193. #define LL_FMPI2C_OWNADDRESS2_MASK05 FMPI2C_OAR2_OA2MASK05 /*!< Only Address2 bits[7:6] are compared. */
  194. #define LL_FMPI2C_OWNADDRESS2_MASK06 FMPI2C_OAR2_OA2MASK06 /*!< Only Address2 bits[7] are compared. */
  195. #define LL_FMPI2C_OWNADDRESS2_MASK07 FMPI2C_OAR2_OA2MASK07 /*!< No comparison is done.
  196. All Address2 are acknowledged. */
  197. /**
  198. * @}
  199. */
  200. /** @defgroup FMPI2C_LL_EC_I2C_ACKNOWLEDGE Acknowledge Generation
  201. * @{
  202. */
  203. #define LL_FMPI2C_ACK 0x00000000U /*!< ACK is sent after current received byte. */
  204. #define LL_FMPI2C_NACK FMPI2C_CR2_NACK /*!< NACK is sent after current received byte.*/
  205. /**
  206. * @}
  207. */
  208. /** @defgroup FMPI2C_LL_EC_ADDRSLAVE Slave Address Length
  209. * @{
  210. */
  211. #define LL_FMPI2C_ADDRSLAVE_7BIT 0x00000000U /*!< Slave Address in 7-bit. */
  212. #define LL_FMPI2C_ADDRSLAVE_10BIT FMPI2C_CR2_ADD10 /*!< Slave Address in 10-bit.*/
  213. /**
  214. * @}
  215. */
  216. /** @defgroup FMPI2C_LL_EC_REQUEST Transfer Request Direction
  217. * @{
  218. */
  219. #define LL_FMPI2C_REQUEST_WRITE 0x00000000U /*!< Master request a write transfer. */
  220. #define LL_FMPI2C_REQUEST_READ FMPI2C_CR2_RD_WRN /*!< Master request a read transfer. */
  221. /**
  222. * @}
  223. */
  224. /** @defgroup FMPI2C_LL_EC_MODE Transfer End Mode
  225. * @{
  226. */
  227. #define LL_FMPI2C_MODE_RELOAD FMPI2C_CR2_RELOAD /*!< Enable FMPI2C Reload mode. */
  228. #define LL_FMPI2C_MODE_AUTOEND FMPI2C_CR2_AUTOEND /*!< Enable FMPI2C Automatic end mode
  229. with no HW PEC comparison. */
  230. #define LL_FMPI2C_MODE_SOFTEND 0x00000000U /*!< Enable FMPI2C Software end mode
  231. with no HW PEC comparison. */
  232. #define LL_FMPI2C_MODE_SMBUS_RELOAD LL_FMPI2C_MODE_RELOAD /*!< Enable FMPSMBUS Automatic end mode
  233. with HW PEC comparison. */
  234. #define LL_FMPI2C_MODE_SMBUS_AUTOEND_NO_PEC LL_FMPI2C_MODE_AUTOEND /*!< Enable FMPSMBUS Automatic end mode
  235. with HW PEC comparison. */
  236. #define LL_FMPI2C_MODE_SMBUS_SOFTEND_NO_PEC LL_FMPI2C_MODE_SOFTEND /*!< Enable FMPSMBUS Software end mode
  237. with HW PEC comparison. */
  238. #define LL_FMPI2C_MODE_SMBUS_AUTOEND_WITH_PEC (uint32_t)(LL_FMPI2C_MODE_AUTOEND | FMPI2C_CR2_PECBYTE)
  239. /*!< Enable FMPSMBUS Automatic end mode with HW PEC comparison. */
  240. #define LL_FMPI2C_MODE_SMBUS_SOFTEND_WITH_PEC (uint32_t)(LL_FMPI2C_MODE_SOFTEND | FMPI2C_CR2_PECBYTE)
  241. /*!< Enable FMPSMBUS Software end mode with HW PEC comparison. */
  242. /**
  243. * @}
  244. */
  245. /** @defgroup FMPI2C_LL_EC_GENERATE Start And Stop Generation
  246. * @{
  247. */
  248. #define LL_FMPI2C_GENERATE_NOSTARTSTOP 0x00000000U
  249. /*!< Don't Generate Stop and Start condition. */
  250. #define LL_FMPI2C_GENERATE_STOP (uint32_t)(0x80000000U | FMPI2C_CR2_STOP)
  251. /*!< Generate Stop condition (Size should be set to 0). */
  252. #define LL_FMPI2C_GENERATE_START_READ (uint32_t)(0x80000000U | FMPI2C_CR2_START | FMPI2C_CR2_RD_WRN)
  253. /*!< Generate Start for read request. */
  254. #define LL_FMPI2C_GENERATE_START_WRITE (uint32_t)(0x80000000U | FMPI2C_CR2_START)
  255. /*!< Generate Start for write request. */
  256. #define LL_FMPI2C_GENERATE_RESTART_7BIT_READ (uint32_t)(0x80000000U | FMPI2C_CR2_START | FMPI2C_CR2_RD_WRN)
  257. /*!< Generate Restart for read request, slave 7Bit address. */
  258. #define LL_FMPI2C_GENERATE_RESTART_7BIT_WRITE (uint32_t)(0x80000000U | FMPI2C_CR2_START)
  259. /*!< Generate Restart for write request, slave 7Bit address. */
  260. #define LL_FMPI2C_GENERATE_RESTART_10BIT_READ (uint32_t)(0x80000000U | FMPI2C_CR2_START | \
  261. FMPI2C_CR2_RD_WRN | FMPI2C_CR2_HEAD10R)
  262. /*!< Generate Restart for read request, slave 10Bit address. */
  263. #define LL_FMPI2C_GENERATE_RESTART_10BIT_WRITE (uint32_t)(0x80000000U | FMPI2C_CR2_START)
  264. /*!< Generate Restart for write request, slave 10Bit address.*/
  265. /**
  266. * @}
  267. */
  268. /** @defgroup FMPI2C_LL_EC_DIRECTION Read Write Direction
  269. * @{
  270. */
  271. #define LL_FMPI2C_DIRECTION_WRITE 0x00000000U /*!< Write transfer request by master,
  272. slave enters receiver mode. */
  273. #define LL_FMPI2C_DIRECTION_READ FMPI2C_ISR_DIR /*!< Read transfer request by master,
  274. slave enters transmitter mode.*/
  275. /**
  276. * @}
  277. */
  278. /** @defgroup FMPI2C_LL_EC_DMA_REG_DATA DMA Register Data
  279. * @{
  280. */
  281. #define LL_FMPI2C_DMA_REG_DATA_TRANSMIT 0x00000000U /*!< Get address of data register used for
  282. transmission */
  283. #define LL_FMPI2C_DMA_REG_DATA_RECEIVE 0x00000001U /*!< Get address of data register used for
  284. reception */
  285. /**
  286. * @}
  287. */
  288. /** @defgroup FMPI2C_LL_EC_SMBUS_TIMEOUTA_MODE SMBus TimeoutA Mode SCL SDA Timeout
  289. * @{
  290. */
  291. #define LL_FMPI2C_FMPSMBUS_TIMEOUTA_MODE_SCL_LOW 0x00000000U /*!< TimeoutA is used to detect
  292. SCL low level timeout. */
  293. #define LL_FMPI2C_FMPSMBUS_TIMEOUTA_MODE_SDA_SCL_HIGH FMPI2C_TIMEOUTR_TIDLE /*!< TimeoutA is used to detect
  294. both SCL and SDA high level timeout.*/
  295. /**
  296. * @}
  297. */
  298. /** @defgroup FMPI2C_LL_EC_SMBUS_TIMEOUT_SELECTION SMBus Timeout Selection
  299. * @{
  300. */
  301. #define LL_FMPI2C_FMPSMBUS_TIMEOUTA FMPI2C_TIMEOUTR_TIMOUTEN /*!< TimeoutA enable bit */
  302. #define LL_FMPI2C_FMPSMBUS_TIMEOUTB FMPI2C_TIMEOUTR_TEXTEN /*!< TimeoutB (extended clock)
  303. enable bit */
  304. #define LL_FMPI2C_FMPSMBUS_ALL_TIMEOUT (uint32_t)(FMPI2C_TIMEOUTR_TIMOUTEN | \
  305. FMPI2C_TIMEOUTR_TEXTEN) /*!< TimeoutA and TimeoutB
  306. (extended clock) enable bits */
  307. /**
  308. * @}
  309. */
  310. /**
  311. * @}
  312. */
  313. /* Exported macro ------------------------------------------------------------*/
  314. /** @defgroup FMPI2C_LL_Exported_Macros FMPI2C Exported Macros
  315. * @{
  316. */
  317. /** @defgroup FMPI2C_LL_EM_WRITE_READ Common Write and read registers Macros
  318. * @{
  319. */
  320. /**
  321. * @brief Write a value in FMPI2C register
  322. * @param __INSTANCE__ FMPI2C Instance
  323. * @param __REG__ Register to be written
  324. * @param __VALUE__ Value to be written in the register
  325. * @retval None
  326. */
  327. #define LL_FMPI2C_WriteReg(__INSTANCE__, __REG__, __VALUE__) WRITE_REG(__INSTANCE__->__REG__, (__VALUE__))
  328. /**
  329. * @brief Read a value in FMPI2C register
  330. * @param __INSTANCE__ FMPI2C Instance
  331. * @param __REG__ Register to be read
  332. * @retval Register value
  333. */
  334. #define LL_FMPI2C_ReadReg(__INSTANCE__, __REG__) READ_REG(__INSTANCE__->__REG__)
  335. /**
  336. * @}
  337. */
  338. /** @defgroup FMPI2C_LL_EM_CONVERT_TIMINGS Convert SDA SCL timings
  339. * @{
  340. */
  341. /**
  342. * @brief Configure the SDA setup, hold time and the SCL high, low period.
  343. * @param __PRESCALER__ This parameter must be a value between Min_Data=0 and Max_Data=0xF.
  344. * @param __SETUP_TIME__ This parameter must be a value between Min_Data=0 and Max_Data=0xF.
  345. (tscldel = (SCLDEL+1)xtpresc)
  346. * @param __HOLD_TIME__ This parameter must be a value between Min_Data=0 and Max_Data=0xF.
  347. (tsdadel = SDADELxtpresc)
  348. * @param __SCLH_PERIOD__ This parameter must be a value between Min_Data=0 and Max_Data=0xFF.
  349. (tsclh = (SCLH+1)xtpresc)
  350. * @param __SCLL_PERIOD__ This parameter must be a value between Min_Data=0 and Max_Data=0xFF.
  351. (tscll = (SCLL+1)xtpresc)
  352. * @retval Value between Min_Data=0 and Max_Data=0xFFFFFFFF
  353. */
  354. #define __LL_FMPI2C_CONVERT_TIMINGS(__PRESCALER__, __SETUP_TIME__, __HOLD_TIME__, __SCLH_PERIOD__, __SCLL_PERIOD__) \
  355. ((((uint32_t)(__PRESCALER__) << FMPI2C_TIMINGR_PRESC_Pos) & FMPI2C_TIMINGR_PRESC) | \
  356. (((uint32_t)(__SETUP_TIME__) << FMPI2C_TIMINGR_SCLDEL_Pos) & FMPI2C_TIMINGR_SCLDEL) | \
  357. (((uint32_t)(__HOLD_TIME__) << FMPI2C_TIMINGR_SDADEL_Pos) & FMPI2C_TIMINGR_SDADEL) | \
  358. (((uint32_t)(__SCLH_PERIOD__) << FMPI2C_TIMINGR_SCLH_Pos) & FMPI2C_TIMINGR_SCLH) | \
  359. (((uint32_t)(__SCLL_PERIOD__) << FMPI2C_TIMINGR_SCLL_Pos) & FMPI2C_TIMINGR_SCLL))
  360. /**
  361. * @}
  362. */
  363. /**
  364. * @}
  365. */
  366. /* Exported functions --------------------------------------------------------*/
  367. /** @defgroup FMPI2C_LL_Exported_Functions FMPI2C Exported Functions
  368. * @{
  369. */
  370. /** @defgroup FMPI2C_LL_EF_Configuration Configuration
  371. * @{
  372. */
  373. /**
  374. * @brief Enable FMPI2C peripheral (PE = 1).
  375. * @rmtoll CR1 PE LL_FMPI2C_Enable
  376. * @param FMPI2Cx FMPI2C Instance.
  377. * @retval None
  378. */
  379. __STATIC_INLINE void LL_FMPI2C_Enable(FMPI2C_TypeDef *FMPI2Cx)
  380. {
  381. SET_BIT(FMPI2Cx->CR1, FMPI2C_CR1_PE);
  382. }
  383. /**
  384. * @brief Disable FMPI2C peripheral (PE = 0).
  385. * @note When PE = 0, the FMPI2C SCL and SDA lines are released.
  386. * Internal state machines and status bits are put back to their reset value.
  387. * When cleared, PE must be kept low for at least 3 APB clock cycles.
  388. * @rmtoll CR1 PE LL_FMPI2C_Disable
  389. * @param FMPI2Cx FMPI2C Instance.
  390. * @retval None
  391. */
  392. __STATIC_INLINE void LL_FMPI2C_Disable(FMPI2C_TypeDef *FMPI2Cx)
  393. {
  394. CLEAR_BIT(FMPI2Cx->CR1, FMPI2C_CR1_PE);
  395. }
  396. /**
  397. * @brief Check if the FMPI2C peripheral is enabled or disabled.
  398. * @rmtoll CR1 PE LL_FMPI2C_IsEnabled
  399. * @param FMPI2Cx FMPI2C Instance.
  400. * @retval State of bit (1 or 0).
  401. */
  402. __STATIC_INLINE uint32_t LL_FMPI2C_IsEnabled(FMPI2C_TypeDef *FMPI2Cx)
  403. {
  404. return ((READ_BIT(FMPI2Cx->CR1, FMPI2C_CR1_PE) == (FMPI2C_CR1_PE)) ? 1UL : 0UL);
  405. }
  406. /**
  407. * @brief Configure Noise Filters (Analog and Digital).
  408. * @note If the analog filter is also enabled, the digital filter is added to analog filter.
  409. * The filters can only be programmed when the FMPI2C is disabled (PE = 0).
  410. * @rmtoll CR1 ANFOFF LL_FMPI2C_ConfigFilters\n
  411. * CR1 DNF LL_FMPI2C_ConfigFilters
  412. * @param FMPI2Cx FMPI2C Instance.
  413. * @param AnalogFilter This parameter can be one of the following values:
  414. * @arg @ref LL_FMPI2C_ANALOGFILTER_ENABLE
  415. * @arg @ref LL_FMPI2C_ANALOGFILTER_DISABLE
  416. * @param DigitalFilter This parameter must be a value between Min_Data=0x00 (Digital filter disabled)
  417. and Max_Data=0x0F (Digital filter enabled and filtering capability up to 15*tfmpi2cclk).
  418. * This parameter is used to configure the digital noise filter on SDA and SCL input.
  419. * The digital filter will filter spikes with a length of up to DNF[3:0]*tfmpi2cclk.
  420. * @retval None
  421. */
  422. __STATIC_INLINE void LL_FMPI2C_ConfigFilters(FMPI2C_TypeDef *FMPI2Cx, uint32_t AnalogFilter, uint32_t DigitalFilter)
  423. {
  424. MODIFY_REG(FMPI2Cx->CR1, FMPI2C_CR1_ANFOFF | FMPI2C_CR1_DNF, AnalogFilter | (DigitalFilter << FMPI2C_CR1_DNF_Pos));
  425. }
  426. /**
  427. * @brief Configure Digital Noise Filter.
  428. * @note If the analog filter is also enabled, the digital filter is added to analog filter.
  429. * This filter can only be programmed when the FMPI2C is disabled (PE = 0).
  430. * @rmtoll CR1 DNF LL_FMPI2C_SetDigitalFilter
  431. * @param FMPI2Cx FMPI2C Instance.
  432. * @param DigitalFilter This parameter must be a value between Min_Data=0x00 (Digital filter disabled)
  433. and Max_Data=0x0F (Digital filter enabled and filtering capability up to 15*tfmpi2cclk).
  434. * This parameter is used to configure the digital noise filter on SDA and SCL input.
  435. * The digital filter will filter spikes with a length of up to DNF[3:0]*tfmpi2cclk.
  436. * @retval None
  437. */
  438. __STATIC_INLINE void LL_FMPI2C_SetDigitalFilter(FMPI2C_TypeDef *FMPI2Cx, uint32_t DigitalFilter)
  439. {
  440. MODIFY_REG(FMPI2Cx->CR1, FMPI2C_CR1_DNF, DigitalFilter << FMPI2C_CR1_DNF_Pos);
  441. }
  442. /**
  443. * @brief Get the current Digital Noise Filter configuration.
  444. * @rmtoll CR1 DNF LL_FMPI2C_GetDigitalFilter
  445. * @param FMPI2Cx FMPI2C Instance.
  446. * @retval Value between Min_Data=0x0 and Max_Data=0xF
  447. */
  448. __STATIC_INLINE uint32_t LL_FMPI2C_GetDigitalFilter(FMPI2C_TypeDef *FMPI2Cx)
  449. {
  450. return (uint32_t)(READ_BIT(FMPI2Cx->CR1, FMPI2C_CR1_DNF) >> FMPI2C_CR1_DNF_Pos);
  451. }
  452. /**
  453. * @brief Enable Analog Noise Filter.
  454. * @note This filter can only be programmed when the FMPI2C is disabled (PE = 0).
  455. * @rmtoll CR1 ANFOFF LL_FMPI2C_EnableAnalogFilter
  456. * @param FMPI2Cx FMPI2C Instance.
  457. * @retval None
  458. */
  459. __STATIC_INLINE void LL_FMPI2C_EnableAnalogFilter(FMPI2C_TypeDef *FMPI2Cx)
  460. {
  461. CLEAR_BIT(FMPI2Cx->CR1, FMPI2C_CR1_ANFOFF);
  462. }
  463. /**
  464. * @brief Disable Analog Noise Filter.
  465. * @note This filter can only be programmed when the FMPI2C is disabled (PE = 0).
  466. * @rmtoll CR1 ANFOFF LL_FMPI2C_DisableAnalogFilter
  467. * @param FMPI2Cx FMPI2C Instance.
  468. * @retval None
  469. */
  470. __STATIC_INLINE void LL_FMPI2C_DisableAnalogFilter(FMPI2C_TypeDef *FMPI2Cx)
  471. {
  472. SET_BIT(FMPI2Cx->CR1, FMPI2C_CR1_ANFOFF);
  473. }
  474. /**
  475. * @brief Check if Analog Noise Filter is enabled or disabled.
  476. * @rmtoll CR1 ANFOFF LL_FMPI2C_IsEnabledAnalogFilter
  477. * @param FMPI2Cx FMPI2C Instance.
  478. * @retval State of bit (1 or 0).
  479. */
  480. __STATIC_INLINE uint32_t LL_FMPI2C_IsEnabledAnalogFilter(FMPI2C_TypeDef *FMPI2Cx)
  481. {
  482. return ((READ_BIT(FMPI2Cx->CR1, FMPI2C_CR1_ANFOFF) != (FMPI2C_CR1_ANFOFF)) ? 1UL : 0UL);
  483. }
  484. /**
  485. * @brief Enable DMA transmission requests.
  486. * @rmtoll CR1 TXDMAEN LL_FMPI2C_EnableDMAReq_TX
  487. * @param FMPI2Cx FMPI2C Instance.
  488. * @retval None
  489. */
  490. __STATIC_INLINE void LL_FMPI2C_EnableDMAReq_TX(FMPI2C_TypeDef *FMPI2Cx)
  491. {
  492. SET_BIT(FMPI2Cx->CR1, FMPI2C_CR1_TXDMAEN);
  493. }
  494. /**
  495. * @brief Disable DMA transmission requests.
  496. * @rmtoll CR1 TXDMAEN LL_FMPI2C_DisableDMAReq_TX
  497. * @param FMPI2Cx FMPI2C Instance.
  498. * @retval None
  499. */
  500. __STATIC_INLINE void LL_FMPI2C_DisableDMAReq_TX(FMPI2C_TypeDef *FMPI2Cx)
  501. {
  502. CLEAR_BIT(FMPI2Cx->CR1, FMPI2C_CR1_TXDMAEN);
  503. }
  504. /**
  505. * @brief Check if DMA transmission requests are enabled or disabled.
  506. * @rmtoll CR1 TXDMAEN LL_FMPI2C_IsEnabledDMAReq_TX
  507. * @param FMPI2Cx FMPI2C Instance.
  508. * @retval State of bit (1 or 0).
  509. */
  510. __STATIC_INLINE uint32_t LL_FMPI2C_IsEnabledDMAReq_TX(FMPI2C_TypeDef *FMPI2Cx)
  511. {
  512. return ((READ_BIT(FMPI2Cx->CR1, FMPI2C_CR1_TXDMAEN) == (FMPI2C_CR1_TXDMAEN)) ? 1UL : 0UL);
  513. }
  514. /**
  515. * @brief Enable DMA reception requests.
  516. * @rmtoll CR1 RXDMAEN LL_FMPI2C_EnableDMAReq_RX
  517. * @param FMPI2Cx FMPI2C Instance.
  518. * @retval None
  519. */
  520. __STATIC_INLINE void LL_FMPI2C_EnableDMAReq_RX(FMPI2C_TypeDef *FMPI2Cx)
  521. {
  522. SET_BIT(FMPI2Cx->CR1, FMPI2C_CR1_RXDMAEN);
  523. }
  524. /**
  525. * @brief Disable DMA reception requests.
  526. * @rmtoll CR1 RXDMAEN LL_FMPI2C_DisableDMAReq_RX
  527. * @param FMPI2Cx FMPI2C Instance.
  528. * @retval None
  529. */
  530. __STATIC_INLINE void LL_FMPI2C_DisableDMAReq_RX(FMPI2C_TypeDef *FMPI2Cx)
  531. {
  532. CLEAR_BIT(FMPI2Cx->CR1, FMPI2C_CR1_RXDMAEN);
  533. }
  534. /**
  535. * @brief Check if DMA reception requests are enabled or disabled.
  536. * @rmtoll CR1 RXDMAEN LL_FMPI2C_IsEnabledDMAReq_RX
  537. * @param FMPI2Cx FMPI2C Instance.
  538. * @retval State of bit (1 or 0).
  539. */
  540. __STATIC_INLINE uint32_t LL_FMPI2C_IsEnabledDMAReq_RX(FMPI2C_TypeDef *FMPI2Cx)
  541. {
  542. return ((READ_BIT(FMPI2Cx->CR1, FMPI2C_CR1_RXDMAEN) == (FMPI2C_CR1_RXDMAEN)) ? 1UL : 0UL);
  543. }
  544. /**
  545. * @brief Get the data register address used for DMA transfer
  546. * @rmtoll TXDR TXDATA LL_FMPI2C_DMA_GetRegAddr\n
  547. * RXDR RXDATA LL_FMPI2C_DMA_GetRegAddr
  548. * @param FMPI2Cx FMPI2C Instance
  549. * @param Direction This parameter can be one of the following values:
  550. * @arg @ref LL_FMPI2C_DMA_REG_DATA_TRANSMIT
  551. * @arg @ref LL_FMPI2C_DMA_REG_DATA_RECEIVE
  552. * @retval Address of data register
  553. */
  554. __STATIC_INLINE uint32_t LL_FMPI2C_DMA_GetRegAddr(FMPI2C_TypeDef *FMPI2Cx, uint32_t Direction)
  555. {
  556. uint32_t data_reg_addr;
  557. if (Direction == LL_FMPI2C_DMA_REG_DATA_TRANSMIT)
  558. {
  559. /* return address of TXDR register */
  560. data_reg_addr = (uint32_t) &(FMPI2Cx->TXDR);
  561. }
  562. else
  563. {
  564. /* return address of RXDR register */
  565. data_reg_addr = (uint32_t) &(FMPI2Cx->RXDR);
  566. }
  567. return data_reg_addr;
  568. }
  569. /**
  570. * @brief Enable Clock stretching.
  571. * @note This bit can only be programmed when the FMPI2C is disabled (PE = 0).
  572. * @rmtoll CR1 NOSTRETCH LL_FMPI2C_EnableClockStretching
  573. * @param FMPI2Cx FMPI2C Instance.
  574. * @retval None
  575. */
  576. __STATIC_INLINE void LL_FMPI2C_EnableClockStretching(FMPI2C_TypeDef *FMPI2Cx)
  577. {
  578. CLEAR_BIT(FMPI2Cx->CR1, FMPI2C_CR1_NOSTRETCH);
  579. }
  580. /**
  581. * @brief Disable Clock stretching.
  582. * @note This bit can only be programmed when the FMPI2C is disabled (PE = 0).
  583. * @rmtoll CR1 NOSTRETCH LL_FMPI2C_DisableClockStretching
  584. * @param FMPI2Cx FMPI2C Instance.
  585. * @retval None
  586. */
  587. __STATIC_INLINE void LL_FMPI2C_DisableClockStretching(FMPI2C_TypeDef *FMPI2Cx)
  588. {
  589. SET_BIT(FMPI2Cx->CR1, FMPI2C_CR1_NOSTRETCH);
  590. }
  591. /**
  592. * @brief Check if Clock stretching is enabled or disabled.
  593. * @rmtoll CR1 NOSTRETCH LL_FMPI2C_IsEnabledClockStretching
  594. * @param FMPI2Cx FMPI2C Instance.
  595. * @retval State of bit (1 or 0).
  596. */
  597. __STATIC_INLINE uint32_t LL_FMPI2C_IsEnabledClockStretching(FMPI2C_TypeDef *FMPI2Cx)
  598. {
  599. return ((READ_BIT(FMPI2Cx->CR1, FMPI2C_CR1_NOSTRETCH) != (FMPI2C_CR1_NOSTRETCH)) ? 1UL : 0UL);
  600. }
  601. /**
  602. * @brief Enable hardware byte control in slave mode.
  603. * @rmtoll CR1 SBC LL_FMPI2C_EnableSlaveByteControl
  604. * @param FMPI2Cx FMPI2C Instance.
  605. * @retval None
  606. */
  607. __STATIC_INLINE void LL_FMPI2C_EnableSlaveByteControl(FMPI2C_TypeDef *FMPI2Cx)
  608. {
  609. SET_BIT(FMPI2Cx->CR1, FMPI2C_CR1_SBC);
  610. }
  611. /**
  612. * @brief Disable hardware byte control in slave mode.
  613. * @rmtoll CR1 SBC LL_FMPI2C_DisableSlaveByteControl
  614. * @param FMPI2Cx FMPI2C Instance.
  615. * @retval None
  616. */
  617. __STATIC_INLINE void LL_FMPI2C_DisableSlaveByteControl(FMPI2C_TypeDef *FMPI2Cx)
  618. {
  619. CLEAR_BIT(FMPI2Cx->CR1, FMPI2C_CR1_SBC);
  620. }
  621. /**
  622. * @brief Check if hardware byte control in slave mode is enabled or disabled.
  623. * @rmtoll CR1 SBC LL_FMPI2C_IsEnabledSlaveByteControl
  624. * @param FMPI2Cx FMPI2C Instance.
  625. * @retval State of bit (1 or 0).
  626. */
  627. __STATIC_INLINE uint32_t LL_FMPI2C_IsEnabledSlaveByteControl(FMPI2C_TypeDef *FMPI2Cx)
  628. {
  629. return ((READ_BIT(FMPI2Cx->CR1, FMPI2C_CR1_SBC) == (FMPI2C_CR1_SBC)) ? 1UL : 0UL);
  630. }
  631. /**
  632. * @brief Enable General Call.
  633. * @note When enabled the Address 0x00 is ACKed.
  634. * @rmtoll CR1 GCEN LL_FMPI2C_EnableGeneralCall
  635. * @param FMPI2Cx FMPI2C Instance.
  636. * @retval None
  637. */
  638. __STATIC_INLINE void LL_FMPI2C_EnableGeneralCall(FMPI2C_TypeDef *FMPI2Cx)
  639. {
  640. SET_BIT(FMPI2Cx->CR1, FMPI2C_CR1_GCEN);
  641. }
  642. /**
  643. * @brief Disable General Call.
  644. * @note When disabled the Address 0x00 is NACKed.
  645. * @rmtoll CR1 GCEN LL_FMPI2C_DisableGeneralCall
  646. * @param FMPI2Cx FMPI2C Instance.
  647. * @retval None
  648. */
  649. __STATIC_INLINE void LL_FMPI2C_DisableGeneralCall(FMPI2C_TypeDef *FMPI2Cx)
  650. {
  651. CLEAR_BIT(FMPI2Cx->CR1, FMPI2C_CR1_GCEN);
  652. }
  653. /**
  654. * @brief Check if General Call is enabled or disabled.
  655. * @rmtoll CR1 GCEN LL_FMPI2C_IsEnabledGeneralCall
  656. * @param FMPI2Cx FMPI2C Instance.
  657. * @retval State of bit (1 or 0).
  658. */
  659. __STATIC_INLINE uint32_t LL_FMPI2C_IsEnabledGeneralCall(FMPI2C_TypeDef *FMPI2Cx)
  660. {
  661. return ((READ_BIT(FMPI2Cx->CR1, FMPI2C_CR1_GCEN) == (FMPI2C_CR1_GCEN)) ? 1UL : 0UL);
  662. }
  663. /**
  664. * @brief Configure the Master to operate in 7-bit or 10-bit addressing mode.
  665. * @note Changing this bit is not allowed, when the START bit is set.
  666. * @rmtoll CR2 ADD10 LL_FMPI2C_SetMasterAddressingMode
  667. * @param FMPI2Cx FMPI2C Instance.
  668. * @param AddressingMode This parameter can be one of the following values:
  669. * @arg @ref LL_FMPI2C_ADDRESSING_MODE_7BIT
  670. * @arg @ref LL_FMPI2C_ADDRESSING_MODE_10BIT
  671. * @retval None
  672. */
  673. __STATIC_INLINE void LL_FMPI2C_SetMasterAddressingMode(FMPI2C_TypeDef *FMPI2Cx, uint32_t AddressingMode)
  674. {
  675. MODIFY_REG(FMPI2Cx->CR2, FMPI2C_CR2_ADD10, AddressingMode);
  676. }
  677. /**
  678. * @brief Get the Master addressing mode.
  679. * @rmtoll CR2 ADD10 LL_FMPI2C_GetMasterAddressingMode
  680. * @param FMPI2Cx FMPI2C Instance.
  681. * @retval Returned value can be one of the following values:
  682. * @arg @ref LL_FMPI2C_ADDRESSING_MODE_7BIT
  683. * @arg @ref LL_FMPI2C_ADDRESSING_MODE_10BIT
  684. */
  685. __STATIC_INLINE uint32_t LL_FMPI2C_GetMasterAddressingMode(FMPI2C_TypeDef *FMPI2Cx)
  686. {
  687. return (uint32_t)(READ_BIT(FMPI2Cx->CR2, FMPI2C_CR2_ADD10));
  688. }
  689. /**
  690. * @brief Set the Own Address1.
  691. * @rmtoll OAR1 OA1 LL_FMPI2C_SetOwnAddress1\n
  692. * OAR1 OA1MODE LL_FMPI2C_SetOwnAddress1
  693. * @param FMPI2Cx FMPI2C Instance.
  694. * @param OwnAddress1 This parameter must be a value between Min_Data=0 and Max_Data=0x3FF.
  695. * @param OwnAddrSize This parameter can be one of the following values:
  696. * @arg @ref LL_FMPI2C_OWNADDRESS1_7BIT
  697. * @arg @ref LL_FMPI2C_OWNADDRESS1_10BIT
  698. * @retval None
  699. */
  700. __STATIC_INLINE void LL_FMPI2C_SetOwnAddress1(FMPI2C_TypeDef *FMPI2Cx, uint32_t OwnAddress1, uint32_t OwnAddrSize)
  701. {
  702. MODIFY_REG(FMPI2Cx->OAR1, FMPI2C_OAR1_OA1 | FMPI2C_OAR1_OA1MODE, OwnAddress1 | OwnAddrSize);
  703. }
  704. /**
  705. * @brief Enable acknowledge on Own Address1 match address.
  706. * @rmtoll OAR1 OA1EN LL_FMPI2C_EnableOwnAddress1
  707. * @param FMPI2Cx FMPI2C Instance.
  708. * @retval None
  709. */
  710. __STATIC_INLINE void LL_FMPI2C_EnableOwnAddress1(FMPI2C_TypeDef *FMPI2Cx)
  711. {
  712. SET_BIT(FMPI2Cx->OAR1, FMPI2C_OAR1_OA1EN);
  713. }
  714. /**
  715. * @brief Disable acknowledge on Own Address1 match address.
  716. * @rmtoll OAR1 OA1EN LL_FMPI2C_DisableOwnAddress1
  717. * @param FMPI2Cx FMPI2C Instance.
  718. * @retval None
  719. */
  720. __STATIC_INLINE void LL_FMPI2C_DisableOwnAddress1(FMPI2C_TypeDef *FMPI2Cx)
  721. {
  722. CLEAR_BIT(FMPI2Cx->OAR1, FMPI2C_OAR1_OA1EN);
  723. }
  724. /**
  725. * @brief Check if Own Address1 acknowledge is enabled or disabled.
  726. * @rmtoll OAR1 OA1EN LL_FMPI2C_IsEnabledOwnAddress1
  727. * @param FMPI2Cx FMPI2C Instance.
  728. * @retval State of bit (1 or 0).
  729. */
  730. __STATIC_INLINE uint32_t LL_FMPI2C_IsEnabledOwnAddress1(FMPI2C_TypeDef *FMPI2Cx)
  731. {
  732. return ((READ_BIT(FMPI2Cx->OAR1, FMPI2C_OAR1_OA1EN) == (FMPI2C_OAR1_OA1EN)) ? 1UL : 0UL);
  733. }
  734. /**
  735. * @brief Set the 7bits Own Address2.
  736. * @note This action has no effect if own address2 is enabled.
  737. * @rmtoll OAR2 OA2 LL_FMPI2C_SetOwnAddress2\n
  738. * OAR2 OA2MSK LL_FMPI2C_SetOwnAddress2
  739. * @param FMPI2Cx FMPI2C Instance.
  740. * @param OwnAddress2 Value between Min_Data=0 and Max_Data=0x7F.
  741. * @param OwnAddrMask This parameter can be one of the following values:
  742. * @arg @ref LL_FMPI2C_OWNADDRESS2_NOMASK
  743. * @arg @ref LL_FMPI2C_OWNADDRESS2_MASK01
  744. * @arg @ref LL_FMPI2C_OWNADDRESS2_MASK02
  745. * @arg @ref LL_FMPI2C_OWNADDRESS2_MASK03
  746. * @arg @ref LL_FMPI2C_OWNADDRESS2_MASK04
  747. * @arg @ref LL_FMPI2C_OWNADDRESS2_MASK05
  748. * @arg @ref LL_FMPI2C_OWNADDRESS2_MASK06
  749. * @arg @ref LL_FMPI2C_OWNADDRESS2_MASK07
  750. * @retval None
  751. */
  752. __STATIC_INLINE void LL_FMPI2C_SetOwnAddress2(FMPI2C_TypeDef *FMPI2Cx, uint32_t OwnAddress2, uint32_t OwnAddrMask)
  753. {
  754. MODIFY_REG(FMPI2Cx->OAR2, FMPI2C_OAR2_OA2 | FMPI2C_OAR2_OA2MSK, OwnAddress2 | OwnAddrMask);
  755. }
  756. /**
  757. * @brief Enable acknowledge on Own Address2 match address.
  758. * @rmtoll OAR2 OA2EN LL_FMPI2C_EnableOwnAddress2
  759. * @param FMPI2Cx FMPI2C Instance.
  760. * @retval None
  761. */
  762. __STATIC_INLINE void LL_FMPI2C_EnableOwnAddress2(FMPI2C_TypeDef *FMPI2Cx)
  763. {
  764. SET_BIT(FMPI2Cx->OAR2, FMPI2C_OAR2_OA2EN);
  765. }
  766. /**
  767. * @brief Disable acknowledge on Own Address2 match address.
  768. * @rmtoll OAR2 OA2EN LL_FMPI2C_DisableOwnAddress2
  769. * @param FMPI2Cx FMPI2C Instance.
  770. * @retval None
  771. */
  772. __STATIC_INLINE void LL_FMPI2C_DisableOwnAddress2(FMPI2C_TypeDef *FMPI2Cx)
  773. {
  774. CLEAR_BIT(FMPI2Cx->OAR2, FMPI2C_OAR2_OA2EN);
  775. }
  776. /**
  777. * @brief Check if Own Address1 acknowledge is enabled or disabled.
  778. * @rmtoll OAR2 OA2EN LL_FMPI2C_IsEnabledOwnAddress2
  779. * @param FMPI2Cx FMPI2C Instance.
  780. * @retval State of bit (1 or 0).
  781. */
  782. __STATIC_INLINE uint32_t LL_FMPI2C_IsEnabledOwnAddress2(FMPI2C_TypeDef *FMPI2Cx)
  783. {
  784. return ((READ_BIT(FMPI2Cx->OAR2, FMPI2C_OAR2_OA2EN) == (FMPI2C_OAR2_OA2EN)) ? 1UL : 0UL);
  785. }
  786. /**
  787. * @brief Configure the SDA setup, hold time and the SCL high, low period.
  788. * @note This bit can only be programmed when the FMPI2C is disabled (PE = 0).
  789. * @rmtoll TIMINGR TIMINGR LL_FMPI2C_SetTiming
  790. * @param FMPI2Cx FMPI2C Instance.
  791. * @param Timing This parameter must be a value between Min_Data=0 and Max_Data=0xFFFFFFFF.
  792. * @note This parameter is computed with the STM32CubeMX Tool.
  793. * @retval None
  794. */
  795. __STATIC_INLINE void LL_FMPI2C_SetTiming(FMPI2C_TypeDef *FMPI2Cx, uint32_t Timing)
  796. {
  797. WRITE_REG(FMPI2Cx->TIMINGR, Timing);
  798. }
  799. /**
  800. * @brief Get the Timing Prescaler setting.
  801. * @rmtoll TIMINGR PRESC LL_FMPI2C_GetTimingPrescaler
  802. * @param FMPI2Cx FMPI2C Instance.
  803. * @retval Value between Min_Data=0x0 and Max_Data=0xF
  804. */
  805. __STATIC_INLINE uint32_t LL_FMPI2C_GetTimingPrescaler(FMPI2C_TypeDef *FMPI2Cx)
  806. {
  807. return (uint32_t)(READ_BIT(FMPI2Cx->TIMINGR, FMPI2C_TIMINGR_PRESC) >> FMPI2C_TIMINGR_PRESC_Pos);
  808. }
  809. /**
  810. * @brief Get the SCL low period setting.
  811. * @rmtoll TIMINGR SCLL LL_FMPI2C_GetClockLowPeriod
  812. * @param FMPI2Cx FMPI2C Instance.
  813. * @retval Value between Min_Data=0x00 and Max_Data=0xFF
  814. */
  815. __STATIC_INLINE uint32_t LL_FMPI2C_GetClockLowPeriod(FMPI2C_TypeDef *FMPI2Cx)
  816. {
  817. return (uint32_t)(READ_BIT(FMPI2Cx->TIMINGR, FMPI2C_TIMINGR_SCLL) >> FMPI2C_TIMINGR_SCLL_Pos);
  818. }
  819. /**
  820. * @brief Get the SCL high period setting.
  821. * @rmtoll TIMINGR SCLH LL_FMPI2C_GetClockHighPeriod
  822. * @param FMPI2Cx FMPI2C Instance.
  823. * @retval Value between Min_Data=0x00 and Max_Data=0xFF
  824. */
  825. __STATIC_INLINE uint32_t LL_FMPI2C_GetClockHighPeriod(FMPI2C_TypeDef *FMPI2Cx)
  826. {
  827. return (uint32_t)(READ_BIT(FMPI2Cx->TIMINGR, FMPI2C_TIMINGR_SCLH) >> FMPI2C_TIMINGR_SCLH_Pos);
  828. }
  829. /**
  830. * @brief Get the SDA hold time.
  831. * @rmtoll TIMINGR SDADEL LL_FMPI2C_GetDataHoldTime
  832. * @param FMPI2Cx FMPI2C Instance.
  833. * @retval Value between Min_Data=0x0 and Max_Data=0xF
  834. */
  835. __STATIC_INLINE uint32_t LL_FMPI2C_GetDataHoldTime(FMPI2C_TypeDef *FMPI2Cx)
  836. {
  837. return (uint32_t)(READ_BIT(FMPI2Cx->TIMINGR, FMPI2C_TIMINGR_SDADEL) >> FMPI2C_TIMINGR_SDADEL_Pos);
  838. }
  839. /**
  840. * @brief Get the SDA setup time.
  841. * @rmtoll TIMINGR SCLDEL LL_FMPI2C_GetDataSetupTime
  842. * @param FMPI2Cx FMPI2C Instance.
  843. * @retval Value between Min_Data=0x0 and Max_Data=0xF
  844. */
  845. __STATIC_INLINE uint32_t LL_FMPI2C_GetDataSetupTime(FMPI2C_TypeDef *FMPI2Cx)
  846. {
  847. return (uint32_t)(READ_BIT(FMPI2Cx->TIMINGR, FMPI2C_TIMINGR_SCLDEL) >> FMPI2C_TIMINGR_SCLDEL_Pos);
  848. }
  849. /**
  850. * @brief Configure peripheral mode.
  851. * @note The macro IS_FMPSMBUS_ALL_INSTANCE(FMPI2Cx) can be used to check whether or not
  852. * SMBus feature is supported by the FMPI2Cx Instance.
  853. * @rmtoll CR1 SMBHEN LL_FMPI2C_SetMode\n
  854. * CR1 SMBDEN LL_FMPI2C_SetMode
  855. * @param FMPI2Cx FMPI2C Instance.
  856. * @param PeripheralMode This parameter can be one of the following values:
  857. * @arg @ref LL_FMPI2C_MODE_I2C
  858. * @arg @ref LL_FMPI2C_MODE_SMBUS_HOST
  859. * @arg @ref LL_FMPI2C_MODE_SMBUS_DEVICE
  860. * @arg @ref LL_FMPI2C_MODE_SMBUS_DEVICE_ARP
  861. * @retval None
  862. */
  863. __STATIC_INLINE void LL_FMPI2C_SetMode(FMPI2C_TypeDef *FMPI2Cx, uint32_t PeripheralMode)
  864. {
  865. MODIFY_REG(FMPI2Cx->CR1, FMPI2C_CR1_SMBHEN | FMPI2C_CR1_SMBDEN, PeripheralMode);
  866. }
  867. /**
  868. * @brief Get peripheral mode.
  869. * @note The macro IS_FMPSMBUS_ALL_INSTANCE(FMPI2Cx) can be used to check whether or not
  870. * SMBus feature is supported by the FMPI2Cx Instance.
  871. * @rmtoll CR1 SMBHEN LL_FMPI2C_GetMode\n
  872. * CR1 SMBDEN LL_FMPI2C_GetMode
  873. * @param FMPI2Cx FMPI2C Instance.
  874. * @retval Returned value can be one of the following values:
  875. * @arg @ref LL_FMPI2C_MODE_I2C
  876. * @arg @ref LL_FMPI2C_MODE_SMBUS_HOST
  877. * @arg @ref LL_FMPI2C_MODE_SMBUS_DEVICE
  878. * @arg @ref LL_FMPI2C_MODE_SMBUS_DEVICE_ARP
  879. */
  880. __STATIC_INLINE uint32_t LL_FMPI2C_GetMode(FMPI2C_TypeDef *FMPI2Cx)
  881. {
  882. return (uint32_t)(READ_BIT(FMPI2Cx->CR1, FMPI2C_CR1_SMBHEN | FMPI2C_CR1_SMBDEN));
  883. }
  884. /**
  885. * @brief Enable SMBus alert (Host or Device mode)
  886. * @note The macro IS_FMPSMBUS_ALL_INSTANCE(FMPI2Cx) can be used to check whether or not
  887. * SMBus feature is supported by the FMPI2Cx Instance.
  888. * @note SMBus Device mode:
  889. * - SMBus Alert pin is drived low and
  890. * Alert Response Address Header acknowledge is enabled.
  891. * SMBus Host mode:
  892. * - SMBus Alert pin management is supported.
  893. * @rmtoll CR1 ALERTEN LL_FMPI2C_EnableSMBusAlert
  894. * @param FMPI2Cx FMPI2C Instance.
  895. * @retval None
  896. */
  897. __STATIC_INLINE void LL_FMPI2C_EnableSMBusAlert(FMPI2C_TypeDef *FMPI2Cx)
  898. {
  899. SET_BIT(FMPI2Cx->CR1, FMPI2C_CR1_ALERTEN);
  900. }
  901. /**
  902. * @brief Disable SMBus alert (Host or Device mode)
  903. * @note The macro IS_FMPSMBUS_ALL_INSTANCE(FMPI2Cx) can be used to check whether or not
  904. * SMBus feature is supported by the FMPI2Cx Instance.
  905. * @note SMBus Device mode:
  906. * - SMBus Alert pin is not drived (can be used as a standard GPIO) and
  907. * Alert Response Address Header acknowledge is disabled.
  908. * SMBus Host mode:
  909. * - SMBus Alert pin management is not supported.
  910. * @rmtoll CR1 ALERTEN LL_FMPI2C_DisableSMBusAlert
  911. * @param FMPI2Cx FMPI2C Instance.
  912. * @retval None
  913. */
  914. __STATIC_INLINE void LL_FMPI2C_DisableSMBusAlert(FMPI2C_TypeDef *FMPI2Cx)
  915. {
  916. CLEAR_BIT(FMPI2Cx->CR1, FMPI2C_CR1_ALERTEN);
  917. }
  918. /**
  919. * @brief Check if SMBus alert (Host or Device mode) is enabled or disabled.
  920. * @note The macro IS_FMPSMBUS_ALL_INSTANCE(FMPI2Cx) can be used to check whether or not
  921. * SMBus feature is supported by the FMPI2Cx Instance.
  922. * @rmtoll CR1 ALERTEN LL_FMPI2C_IsEnabledSMBusAlert
  923. * @param FMPI2Cx FMPI2C Instance.
  924. * @retval State of bit (1 or 0).
  925. */
  926. __STATIC_INLINE uint32_t LL_FMPI2C_IsEnabledSMBusAlert(FMPI2C_TypeDef *FMPI2Cx)
  927. {
  928. return ((READ_BIT(FMPI2Cx->CR1, FMPI2C_CR1_ALERTEN) == (FMPI2C_CR1_ALERTEN)) ? 1UL : 0UL);
  929. }
  930. /**
  931. * @brief Enable SMBus Packet Error Calculation (PEC).
  932. * @note The macro IS_FMPSMBUS_ALL_INSTANCE(FMPI2Cx) can be used to check whether or not
  933. * SMBus feature is supported by the FMPI2Cx Instance.
  934. * @rmtoll CR1 PECEN LL_FMPI2C_EnableSMBusPEC
  935. * @param FMPI2Cx FMPI2C Instance.
  936. * @retval None
  937. */
  938. __STATIC_INLINE void LL_FMPI2C_EnableSMBusPEC(FMPI2C_TypeDef *FMPI2Cx)
  939. {
  940. SET_BIT(FMPI2Cx->CR1, FMPI2C_CR1_PECEN);
  941. }
  942. /**
  943. * @brief Disable SMBus Packet Error Calculation (PEC).
  944. * @note The macro IS_FMPSMBUS_ALL_INSTANCE(FMPI2Cx) can be used to check whether or not
  945. * SMBus feature is supported by the FMPI2Cx Instance.
  946. * @rmtoll CR1 PECEN LL_FMPI2C_DisableSMBusPEC
  947. * @param FMPI2Cx FMPI2C Instance.
  948. * @retval None
  949. */
  950. __STATIC_INLINE void LL_FMPI2C_DisableSMBusPEC(FMPI2C_TypeDef *FMPI2Cx)
  951. {
  952. CLEAR_BIT(FMPI2Cx->CR1, FMPI2C_CR1_PECEN);
  953. }
  954. /**
  955. * @brief Check if SMBus Packet Error Calculation (PEC) is enabled or disabled.
  956. * @note The macro IS_FMPSMBUS_ALL_INSTANCE(FMPI2Cx) can be used to check whether or not
  957. * SMBus feature is supported by the FMPI2Cx Instance.
  958. * @rmtoll CR1 PECEN LL_FMPI2C_IsEnabledSMBusPEC
  959. * @param FMPI2Cx FMPI2C Instance.
  960. * @retval State of bit (1 or 0).
  961. */
  962. __STATIC_INLINE uint32_t LL_FMPI2C_IsEnabledSMBusPEC(FMPI2C_TypeDef *FMPI2Cx)
  963. {
  964. return ((READ_BIT(FMPI2Cx->CR1, FMPI2C_CR1_PECEN) == (FMPI2C_CR1_PECEN)) ? 1UL : 0UL);
  965. }
  966. /**
  967. * @brief Configure the SMBus Clock Timeout.
  968. * @note The macro IS_FMPSMBUS_ALL_INSTANCE(FMPI2Cx) can be used to check whether or not
  969. * SMBus feature is supported by the FMPI2Cx Instance.
  970. * @note This configuration can only be programmed when associated Timeout is disabled (TimeoutA and/orTimeoutB).
  971. * @rmtoll TIMEOUTR TIMEOUTA LL_FMPI2C_ConfigSMBusTimeout\n
  972. * TIMEOUTR TIDLE LL_FMPI2C_ConfigSMBusTimeout\n
  973. * TIMEOUTR TIMEOUTB LL_FMPI2C_ConfigSMBusTimeout
  974. * @param FMPI2Cx FMPI2C Instance.
  975. * @param TimeoutA This parameter must be a value between Min_Data=0 and Max_Data=0xFFF.
  976. * @param TimeoutAMode This parameter can be one of the following values:
  977. * @arg @ref LL_FMPI2C_FMPSMBUS_TIMEOUTA_MODE_SCL_LOW
  978. * @arg @ref LL_FMPI2C_FMPSMBUS_TIMEOUTA_MODE_SDA_SCL_HIGH
  979. * @param TimeoutB
  980. * @retval None
  981. */
  982. __STATIC_INLINE void LL_FMPI2C_ConfigSMBusTimeout(FMPI2C_TypeDef *FMPI2Cx, uint32_t TimeoutA, uint32_t TimeoutAMode,
  983. uint32_t TimeoutB)
  984. {
  985. MODIFY_REG(FMPI2Cx->TIMEOUTR, FMPI2C_TIMEOUTR_TIMEOUTA | FMPI2C_TIMEOUTR_TIDLE | FMPI2C_TIMEOUTR_TIMEOUTB,
  986. TimeoutA | TimeoutAMode | (TimeoutB << FMPI2C_TIMEOUTR_TIMEOUTB_Pos));
  987. }
  988. /**
  989. * @brief Configure the SMBus Clock TimeoutA (SCL low timeout or SCL and SDA high timeout depends on TimeoutA mode).
  990. * @note The macro IS_FMPSMBUS_ALL_INSTANCE(FMPI2Cx) can be used to check whether or not
  991. * SMBus feature is supported by the FMPI2Cx Instance.
  992. * @note These bits can only be programmed when TimeoutA is disabled.
  993. * @rmtoll TIMEOUTR TIMEOUTA LL_FMPI2C_SetSMBusTimeoutA
  994. * @param FMPI2Cx FMPI2C Instance.
  995. * @param TimeoutA This parameter must be a value between Min_Data=0 and Max_Data=0xFFF.
  996. * @retval None
  997. */
  998. __STATIC_INLINE void LL_FMPI2C_SetSMBusTimeoutA(FMPI2C_TypeDef *FMPI2Cx, uint32_t TimeoutA)
  999. {
  1000. WRITE_REG(FMPI2Cx->TIMEOUTR, TimeoutA);
  1001. }
  1002. /**
  1003. * @brief Get the SMBus Clock TimeoutA setting.
  1004. * @note The macro IS_FMPSMBUS_ALL_INSTANCE(FMPI2Cx) can be used to check whether or not
  1005. * SMBus feature is supported by the FMPI2Cx Instance.
  1006. * @rmtoll TIMEOUTR TIMEOUTA LL_FMPI2C_GetSMBusTimeoutA
  1007. * @param FMPI2Cx FMPI2C Instance.
  1008. * @retval Value between Min_Data=0 and Max_Data=0xFFF
  1009. */
  1010. __STATIC_INLINE uint32_t LL_FMPI2C_GetSMBusTimeoutA(FMPI2C_TypeDef *FMPI2Cx)
  1011. {
  1012. return (uint32_t)(READ_BIT(FMPI2Cx->TIMEOUTR, FMPI2C_TIMEOUTR_TIMEOUTA));
  1013. }
  1014. /**
  1015. * @brief Set the SMBus Clock TimeoutA mode.
  1016. * @note The macro IS_FMPSMBUS_ALL_INSTANCE(FMPI2Cx) can be used to check whether or not
  1017. * SMBus feature is supported by the FMPI2Cx Instance.
  1018. * @note This bit can only be programmed when TimeoutA is disabled.
  1019. * @rmtoll TIMEOUTR TIDLE LL_FMPI2C_SetSMBusTimeoutAMode
  1020. * @param FMPI2Cx FMPI2C Instance.
  1021. * @param TimeoutAMode This parameter can be one of the following values:
  1022. * @arg @ref LL_FMPI2C_FMPSMBUS_TIMEOUTA_MODE_SCL_LOW
  1023. * @arg @ref LL_FMPI2C_FMPSMBUS_TIMEOUTA_MODE_SDA_SCL_HIGH
  1024. * @retval None
  1025. */
  1026. __STATIC_INLINE void LL_FMPI2C_SetSMBusTimeoutAMode(FMPI2C_TypeDef *FMPI2Cx, uint32_t TimeoutAMode)
  1027. {
  1028. WRITE_REG(FMPI2Cx->TIMEOUTR, TimeoutAMode);
  1029. }
  1030. /**
  1031. * @brief Get the SMBus Clock TimeoutA mode.
  1032. * @note The macro IS_FMPSMBUS_ALL_INSTANCE(FMPI2Cx) can be used to check whether or not
  1033. * SMBus feature is supported by the FMPI2Cx Instance.
  1034. * @rmtoll TIMEOUTR TIDLE LL_FMPI2C_GetSMBusTimeoutAMode
  1035. * @param FMPI2Cx FMPI2C Instance.
  1036. * @retval Returned value can be one of the following values:
  1037. * @arg @ref LL_FMPI2C_FMPSMBUS_TIMEOUTA_MODE_SCL_LOW
  1038. * @arg @ref LL_FMPI2C_FMPSMBUS_TIMEOUTA_MODE_SDA_SCL_HIGH
  1039. */
  1040. __STATIC_INLINE uint32_t LL_FMPI2C_GetSMBusTimeoutAMode(FMPI2C_TypeDef *FMPI2Cx)
  1041. {
  1042. return (uint32_t)(READ_BIT(FMPI2Cx->TIMEOUTR, FMPI2C_TIMEOUTR_TIDLE));
  1043. }
  1044. /**
  1045. * @brief Configure the SMBus Extended Cumulative Clock TimeoutB (Master or Slave mode).
  1046. * @note The macro IS_FMPSMBUS_ALL_INSTANCE(FMPI2Cx) can be used to check whether or not
  1047. * SMBus feature is supported by the FMPI2Cx Instance.
  1048. * @note These bits can only be programmed when TimeoutB is disabled.
  1049. * @rmtoll TIMEOUTR TIMEOUTB LL_FMPI2C_SetSMBusTimeoutB
  1050. * @param FMPI2Cx FMPI2C Instance.
  1051. * @param TimeoutB This parameter must be a value between Min_Data=0 and Max_Data=0xFFF.
  1052. * @retval None
  1053. */
  1054. __STATIC_INLINE void LL_FMPI2C_SetSMBusTimeoutB(FMPI2C_TypeDef *FMPI2Cx, uint32_t TimeoutB)
  1055. {
  1056. WRITE_REG(FMPI2Cx->TIMEOUTR, TimeoutB << FMPI2C_TIMEOUTR_TIMEOUTB_Pos);
  1057. }
  1058. /**
  1059. * @brief Get the SMBus Extended Cumulative Clock TimeoutB setting.
  1060. * @note The macro IS_FMPSMBUS_ALL_INSTANCE(FMPI2Cx) can be used to check whether or not
  1061. * SMBus feature is supported by the FMPI2Cx Instance.
  1062. * @rmtoll TIMEOUTR TIMEOUTB LL_FMPI2C_GetSMBusTimeoutB
  1063. * @param FMPI2Cx FMPI2C Instance.
  1064. * @retval Value between Min_Data=0 and Max_Data=0xFFF
  1065. */
  1066. __STATIC_INLINE uint32_t LL_FMPI2C_GetSMBusTimeoutB(FMPI2C_TypeDef *FMPI2Cx)
  1067. {
  1068. return (uint32_t)(READ_BIT(FMPI2Cx->TIMEOUTR, FMPI2C_TIMEOUTR_TIMEOUTB) >> FMPI2C_TIMEOUTR_TIMEOUTB_Pos);
  1069. }
  1070. /**
  1071. * @brief Enable the SMBus Clock Timeout.
  1072. * @note The macro IS_FMPSMBUS_ALL_INSTANCE(FMPI2Cx) can be used to check whether or not
  1073. * SMBus feature is supported by the FMPI2Cx Instance.
  1074. * @rmtoll TIMEOUTR TIMOUTEN LL_FMPI2C_EnableSMBusTimeout\n
  1075. * TIMEOUTR TEXTEN LL_FMPI2C_EnableSMBusTimeout
  1076. * @param FMPI2Cx FMPI2C Instance.
  1077. * @param ClockTimeout This parameter can be one of the following values:
  1078. * @arg @ref LL_FMPI2C_FMPSMBUS_TIMEOUTA
  1079. * @arg @ref LL_FMPI2C_FMPSMBUS_TIMEOUTB
  1080. * @arg @ref LL_FMPI2C_FMPSMBUS_ALL_TIMEOUT
  1081. * @retval None
  1082. */
  1083. __STATIC_INLINE void LL_FMPI2C_EnableSMBusTimeout(FMPI2C_TypeDef *FMPI2Cx, uint32_t ClockTimeout)
  1084. {
  1085. SET_BIT(FMPI2Cx->TIMEOUTR, ClockTimeout);
  1086. }
  1087. /**
  1088. * @brief Disable the SMBus Clock Timeout.
  1089. * @note The macro IS_FMPSMBUS_ALL_INSTANCE(FMPI2Cx) can be used to check whether or not
  1090. * SMBus feature is supported by the FMPI2Cx Instance.
  1091. * @rmtoll TIMEOUTR TIMOUTEN LL_FMPI2C_DisableSMBusTimeout\n
  1092. * TIMEOUTR TEXTEN LL_FMPI2C_DisableSMBusTimeout
  1093. * @param FMPI2Cx FMPI2C Instance.
  1094. * @param ClockTimeout This parameter can be one of the following values:
  1095. * @arg @ref LL_FMPI2C_FMPSMBUS_TIMEOUTA
  1096. * @arg @ref LL_FMPI2C_FMPSMBUS_TIMEOUTB
  1097. * @arg @ref LL_FMPI2C_FMPSMBUS_ALL_TIMEOUT
  1098. * @retval None
  1099. */
  1100. __STATIC_INLINE void LL_FMPI2C_DisableSMBusTimeout(FMPI2C_TypeDef *FMPI2Cx, uint32_t ClockTimeout)
  1101. {
  1102. CLEAR_BIT(FMPI2Cx->TIMEOUTR, ClockTimeout);
  1103. }
  1104. /**
  1105. * @brief Check if the SMBus Clock Timeout is enabled or disabled.
  1106. * @note The macro IS_FMPSMBUS_ALL_INSTANCE(FMPI2Cx) can be used to check whether or not
  1107. * SMBus feature is supported by the FMPI2Cx Instance.
  1108. * @rmtoll TIMEOUTR TIMOUTEN LL_FMPI2C_IsEnabledSMBusTimeout\n
  1109. * TIMEOUTR TEXTEN LL_FMPI2C_IsEnabledSMBusTimeout
  1110. * @param FMPI2Cx FMPI2C Instance.
  1111. * @param ClockTimeout This parameter can be one of the following values:
  1112. * @arg @ref LL_FMPI2C_FMPSMBUS_TIMEOUTA
  1113. * @arg @ref LL_FMPI2C_FMPSMBUS_TIMEOUTB
  1114. * @arg @ref LL_FMPI2C_FMPSMBUS_ALL_TIMEOUT
  1115. * @retval State of bit (1 or 0).
  1116. */
  1117. __STATIC_INLINE uint32_t LL_FMPI2C_IsEnabledSMBusTimeout(FMPI2C_TypeDef *FMPI2Cx, uint32_t ClockTimeout)
  1118. {
  1119. return ((READ_BIT(FMPI2Cx->TIMEOUTR, (FMPI2C_TIMEOUTR_TIMOUTEN | FMPI2C_TIMEOUTR_TEXTEN)) == \
  1120. (ClockTimeout)) ? 1UL : 0UL);
  1121. }
  1122. /**
  1123. * @}
  1124. */
  1125. /** @defgroup FMPI2C_LL_EF_IT_Management IT_Management
  1126. * @{
  1127. */
  1128. /**
  1129. * @brief Enable TXIS interrupt.
  1130. * @rmtoll CR1 TXIE LL_FMPI2C_EnableIT_TX
  1131. * @param FMPI2Cx FMPI2C Instance.
  1132. * @retval None
  1133. */
  1134. __STATIC_INLINE void LL_FMPI2C_EnableIT_TX(FMPI2C_TypeDef *FMPI2Cx)
  1135. {
  1136. SET_BIT(FMPI2Cx->CR1, FMPI2C_CR1_TXIE);
  1137. }
  1138. /**
  1139. * @brief Disable TXIS interrupt.
  1140. * @rmtoll CR1 TXIE LL_FMPI2C_DisableIT_TX
  1141. * @param FMPI2Cx FMPI2C Instance.
  1142. * @retval None
  1143. */
  1144. __STATIC_INLINE void LL_FMPI2C_DisableIT_TX(FMPI2C_TypeDef *FMPI2Cx)
  1145. {
  1146. CLEAR_BIT(FMPI2Cx->CR1, FMPI2C_CR1_TXIE);
  1147. }
  1148. /**
  1149. * @brief Check if the TXIS Interrupt is enabled or disabled.
  1150. * @rmtoll CR1 TXIE LL_FMPI2C_IsEnabledIT_TX
  1151. * @param FMPI2Cx FMPI2C Instance.
  1152. * @retval State of bit (1 or 0).
  1153. */
  1154. __STATIC_INLINE uint32_t LL_FMPI2C_IsEnabledIT_TX(FMPI2C_TypeDef *FMPI2Cx)
  1155. {
  1156. return ((READ_BIT(FMPI2Cx->CR1, FMPI2C_CR1_TXIE) == (FMPI2C_CR1_TXIE)) ? 1UL : 0UL);
  1157. }
  1158. /**
  1159. * @brief Enable RXNE interrupt.
  1160. * @rmtoll CR1 RXIE LL_FMPI2C_EnableIT_RX
  1161. * @param FMPI2Cx FMPI2C Instance.
  1162. * @retval None
  1163. */
  1164. __STATIC_INLINE void LL_FMPI2C_EnableIT_RX(FMPI2C_TypeDef *FMPI2Cx)
  1165. {
  1166. SET_BIT(FMPI2Cx->CR1, FMPI2C_CR1_RXIE);
  1167. }
  1168. /**
  1169. * @brief Disable RXNE interrupt.
  1170. * @rmtoll CR1 RXIE LL_FMPI2C_DisableIT_RX
  1171. * @param FMPI2Cx FMPI2C Instance.
  1172. * @retval None
  1173. */
  1174. __STATIC_INLINE void LL_FMPI2C_DisableIT_RX(FMPI2C_TypeDef *FMPI2Cx)
  1175. {
  1176. CLEAR_BIT(FMPI2Cx->CR1, FMPI2C_CR1_RXIE);
  1177. }
  1178. /**
  1179. * @brief Check if the RXNE Interrupt is enabled or disabled.
  1180. * @rmtoll CR1 RXIE LL_FMPI2C_IsEnabledIT_RX
  1181. * @param FMPI2Cx FMPI2C Instance.
  1182. * @retval State of bit (1 or 0).
  1183. */
  1184. __STATIC_INLINE uint32_t LL_FMPI2C_IsEnabledIT_RX(FMPI2C_TypeDef *FMPI2Cx)
  1185. {
  1186. return ((READ_BIT(FMPI2Cx->CR1, FMPI2C_CR1_RXIE) == (FMPI2C_CR1_RXIE)) ? 1UL : 0UL);
  1187. }
  1188. /**
  1189. * @brief Enable Address match interrupt (slave mode only).
  1190. * @rmtoll CR1 ADDRIE LL_FMPI2C_EnableIT_ADDR
  1191. * @param FMPI2Cx FMPI2C Instance.
  1192. * @retval None
  1193. */
  1194. __STATIC_INLINE void LL_FMPI2C_EnableIT_ADDR(FMPI2C_TypeDef *FMPI2Cx)
  1195. {
  1196. SET_BIT(FMPI2Cx->CR1, FMPI2C_CR1_ADDRIE);
  1197. }
  1198. /**
  1199. * @brief Disable Address match interrupt (slave mode only).
  1200. * @rmtoll CR1 ADDRIE LL_FMPI2C_DisableIT_ADDR
  1201. * @param FMPI2Cx FMPI2C Instance.
  1202. * @retval None
  1203. */
  1204. __STATIC_INLINE void LL_FMPI2C_DisableIT_ADDR(FMPI2C_TypeDef *FMPI2Cx)
  1205. {
  1206. CLEAR_BIT(FMPI2Cx->CR1, FMPI2C_CR1_ADDRIE);
  1207. }
  1208. /**
  1209. * @brief Check if Address match interrupt is enabled or disabled.
  1210. * @rmtoll CR1 ADDRIE LL_FMPI2C_IsEnabledIT_ADDR
  1211. * @param FMPI2Cx FMPI2C Instance.
  1212. * @retval State of bit (1 or 0).
  1213. */
  1214. __STATIC_INLINE uint32_t LL_FMPI2C_IsEnabledIT_ADDR(FMPI2C_TypeDef *FMPI2Cx)
  1215. {
  1216. return ((READ_BIT(FMPI2Cx->CR1, FMPI2C_CR1_ADDRIE) == (FMPI2C_CR1_ADDRIE)) ? 1UL : 0UL);
  1217. }
  1218. /**
  1219. * @brief Enable Not acknowledge received interrupt.
  1220. * @rmtoll CR1 NACKIE LL_FMPI2C_EnableIT_NACK
  1221. * @param FMPI2Cx FMPI2C Instance.
  1222. * @retval None
  1223. */
  1224. __STATIC_INLINE void LL_FMPI2C_EnableIT_NACK(FMPI2C_TypeDef *FMPI2Cx)
  1225. {
  1226. SET_BIT(FMPI2Cx->CR1, FMPI2C_CR1_NACKIE);
  1227. }
  1228. /**
  1229. * @brief Disable Not acknowledge received interrupt.
  1230. * @rmtoll CR1 NACKIE LL_FMPI2C_DisableIT_NACK
  1231. * @param FMPI2Cx FMPI2C Instance.
  1232. * @retval None
  1233. */
  1234. __STATIC_INLINE void LL_FMPI2C_DisableIT_NACK(FMPI2C_TypeDef *FMPI2Cx)
  1235. {
  1236. CLEAR_BIT(FMPI2Cx->CR1, FMPI2C_CR1_NACKIE);
  1237. }
  1238. /**
  1239. * @brief Check if Not acknowledge received interrupt is enabled or disabled.
  1240. * @rmtoll CR1 NACKIE LL_FMPI2C_IsEnabledIT_NACK
  1241. * @param FMPI2Cx FMPI2C Instance.
  1242. * @retval State of bit (1 or 0).
  1243. */
  1244. __STATIC_INLINE uint32_t LL_FMPI2C_IsEnabledIT_NACK(FMPI2C_TypeDef *FMPI2Cx)
  1245. {
  1246. return ((READ_BIT(FMPI2Cx->CR1, FMPI2C_CR1_NACKIE) == (FMPI2C_CR1_NACKIE)) ? 1UL : 0UL);
  1247. }
  1248. /**
  1249. * @brief Enable STOP detection interrupt.
  1250. * @rmtoll CR1 STOPIE LL_FMPI2C_EnableIT_STOP
  1251. * @param FMPI2Cx FMPI2C Instance.
  1252. * @retval None
  1253. */
  1254. __STATIC_INLINE void LL_FMPI2C_EnableIT_STOP(FMPI2C_TypeDef *FMPI2Cx)
  1255. {
  1256. SET_BIT(FMPI2Cx->CR1, FMPI2C_CR1_STOPIE);
  1257. }
  1258. /**
  1259. * @brief Disable STOP detection interrupt.
  1260. * @rmtoll CR1 STOPIE LL_FMPI2C_DisableIT_STOP
  1261. * @param FMPI2Cx FMPI2C Instance.
  1262. * @retval None
  1263. */
  1264. __STATIC_INLINE void LL_FMPI2C_DisableIT_STOP(FMPI2C_TypeDef *FMPI2Cx)
  1265. {
  1266. CLEAR_BIT(FMPI2Cx->CR1, FMPI2C_CR1_STOPIE);
  1267. }
  1268. /**
  1269. * @brief Check if STOP detection interrupt is enabled or disabled.
  1270. * @rmtoll CR1 STOPIE LL_FMPI2C_IsEnabledIT_STOP
  1271. * @param FMPI2Cx FMPI2C Instance.
  1272. * @retval State of bit (1 or 0).
  1273. */
  1274. __STATIC_INLINE uint32_t LL_FMPI2C_IsEnabledIT_STOP(FMPI2C_TypeDef *FMPI2Cx)
  1275. {
  1276. return ((READ_BIT(FMPI2Cx->CR1, FMPI2C_CR1_STOPIE) == (FMPI2C_CR1_STOPIE)) ? 1UL : 0UL);
  1277. }
  1278. /**
  1279. * @brief Enable Transfer Complete interrupt.
  1280. * @note Any of these events will generate interrupt :
  1281. * Transfer Complete (TC)
  1282. * Transfer Complete Reload (TCR)
  1283. * @rmtoll CR1 TCIE LL_FMPI2C_EnableIT_TC
  1284. * @param FMPI2Cx FMPI2C Instance.
  1285. * @retval None
  1286. */
  1287. __STATIC_INLINE void LL_FMPI2C_EnableIT_TC(FMPI2C_TypeDef *FMPI2Cx)
  1288. {
  1289. SET_BIT(FMPI2Cx->CR1, FMPI2C_CR1_TCIE);
  1290. }
  1291. /**
  1292. * @brief Disable Transfer Complete interrupt.
  1293. * @note Any of these events will generate interrupt :
  1294. * Transfer Complete (TC)
  1295. * Transfer Complete Reload (TCR)
  1296. * @rmtoll CR1 TCIE LL_FMPI2C_DisableIT_TC
  1297. * @param FMPI2Cx FMPI2C Instance.
  1298. * @retval None
  1299. */
  1300. __STATIC_INLINE void LL_FMPI2C_DisableIT_TC(FMPI2C_TypeDef *FMPI2Cx)
  1301. {
  1302. CLEAR_BIT(FMPI2Cx->CR1, FMPI2C_CR1_TCIE);
  1303. }
  1304. /**
  1305. * @brief Check if Transfer Complete interrupt is enabled or disabled.
  1306. * @rmtoll CR1 TCIE LL_FMPI2C_IsEnabledIT_TC
  1307. * @param FMPI2Cx FMPI2C Instance.
  1308. * @retval State of bit (1 or 0).
  1309. */
  1310. __STATIC_INLINE uint32_t LL_FMPI2C_IsEnabledIT_TC(FMPI2C_TypeDef *FMPI2Cx)
  1311. {
  1312. return ((READ_BIT(FMPI2Cx->CR1, FMPI2C_CR1_TCIE) == (FMPI2C_CR1_TCIE)) ? 1UL : 0UL);
  1313. }
  1314. /**
  1315. * @brief Enable Error interrupts.
  1316. * @note The macro IS_FMPSMBUS_ALL_INSTANCE(FMPI2Cx) can be used to check whether or not
  1317. * SMBus feature is supported by the FMPI2Cx Instance.
  1318. * @note Any of these errors will generate interrupt :
  1319. * Arbitration Loss (ARLO)
  1320. * Bus Error detection (BERR)
  1321. * Overrun/Underrun (OVR)
  1322. * SMBus Timeout detection (TIMEOUT)
  1323. * SMBus PEC error detection (PECERR)
  1324. * SMBus Alert pin event detection (ALERT)
  1325. * @rmtoll CR1 ERRIE LL_FMPI2C_EnableIT_ERR
  1326. * @param FMPI2Cx FMPI2C Instance.
  1327. * @retval None
  1328. */
  1329. __STATIC_INLINE void LL_FMPI2C_EnableIT_ERR(FMPI2C_TypeDef *FMPI2Cx)
  1330. {
  1331. SET_BIT(FMPI2Cx->CR1, FMPI2C_CR1_ERRIE);
  1332. }
  1333. /**
  1334. * @brief Disable Error interrupts.
  1335. * @note The macro IS_FMPSMBUS_ALL_INSTANCE(FMPI2Cx) can be used to check whether or not
  1336. * SMBus feature is supported by the FMPI2Cx Instance.
  1337. * @note Any of these errors will generate interrupt :
  1338. * Arbitration Loss (ARLO)
  1339. * Bus Error detection (BERR)
  1340. * Overrun/Underrun (OVR)
  1341. * SMBus Timeout detection (TIMEOUT)
  1342. * SMBus PEC error detection (PECERR)
  1343. * SMBus Alert pin event detection (ALERT)
  1344. * @rmtoll CR1 ERRIE LL_FMPI2C_DisableIT_ERR
  1345. * @param FMPI2Cx FMPI2C Instance.
  1346. * @retval None
  1347. */
  1348. __STATIC_INLINE void LL_FMPI2C_DisableIT_ERR(FMPI2C_TypeDef *FMPI2Cx)
  1349. {
  1350. CLEAR_BIT(FMPI2Cx->CR1, FMPI2C_CR1_ERRIE);
  1351. }
  1352. /**
  1353. * @brief Check if Error interrupts are enabled or disabled.
  1354. * @rmtoll CR1 ERRIE LL_FMPI2C_IsEnabledIT_ERR
  1355. * @param FMPI2Cx FMPI2C Instance.
  1356. * @retval State of bit (1 or 0).
  1357. */
  1358. __STATIC_INLINE uint32_t LL_FMPI2C_IsEnabledIT_ERR(FMPI2C_TypeDef *FMPI2Cx)
  1359. {
  1360. return ((READ_BIT(FMPI2Cx->CR1, FMPI2C_CR1_ERRIE) == (FMPI2C_CR1_ERRIE)) ? 1UL : 0UL);
  1361. }
  1362. /**
  1363. * @}
  1364. */
  1365. /** @defgroup FMPI2C_LL_EF_FLAG_management FLAG_management
  1366. * @{
  1367. */
  1368. /**
  1369. * @brief Indicate the status of Transmit data register empty flag.
  1370. * @note RESET: When next data is written in Transmit data register.
  1371. * SET: When Transmit data register is empty.
  1372. * @rmtoll ISR TXE LL_FMPI2C_IsActiveFlag_TXE
  1373. * @param FMPI2Cx FMPI2C Instance.
  1374. * @retval State of bit (1 or 0).
  1375. */
  1376. __STATIC_INLINE uint32_t LL_FMPI2C_IsActiveFlag_TXE(FMPI2C_TypeDef *FMPI2Cx)
  1377. {
  1378. return ((READ_BIT(FMPI2Cx->ISR, FMPI2C_ISR_TXE) == (FMPI2C_ISR_TXE)) ? 1UL : 0UL);
  1379. }
  1380. /**
  1381. * @brief Indicate the status of Transmit interrupt flag.
  1382. * @note RESET: When next data is written in Transmit data register.
  1383. * SET: When Transmit data register is empty.
  1384. * @rmtoll ISR TXIS LL_FMPI2C_IsActiveFlag_TXIS
  1385. * @param FMPI2Cx FMPI2C Instance.
  1386. * @retval State of bit (1 or 0).
  1387. */
  1388. __STATIC_INLINE uint32_t LL_FMPI2C_IsActiveFlag_TXIS(FMPI2C_TypeDef *FMPI2Cx)
  1389. {
  1390. return ((READ_BIT(FMPI2Cx->ISR, FMPI2C_ISR_TXIS) == (FMPI2C_ISR_TXIS)) ? 1UL : 0UL);
  1391. }
  1392. /**
  1393. * @brief Indicate the status of Receive data register not empty flag.
  1394. * @note RESET: When Receive data register is read.
  1395. * SET: When the received data is copied in Receive data register.
  1396. * @rmtoll ISR RXNE LL_FMPI2C_IsActiveFlag_RXNE
  1397. * @param FMPI2Cx FMPI2C Instance.
  1398. * @retval State of bit (1 or 0).
  1399. */
  1400. __STATIC_INLINE uint32_t LL_FMPI2C_IsActiveFlag_RXNE(FMPI2C_TypeDef *FMPI2Cx)
  1401. {
  1402. return ((READ_BIT(FMPI2Cx->ISR, FMPI2C_ISR_RXNE) == (FMPI2C_ISR_RXNE)) ? 1UL : 0UL);
  1403. }
  1404. /**
  1405. * @brief Indicate the status of Address matched flag (slave mode).
  1406. * @note RESET: Clear default value.
  1407. * SET: When the received slave address matched with one of the enabled slave address.
  1408. * @rmtoll ISR ADDR LL_FMPI2C_IsActiveFlag_ADDR
  1409. * @param FMPI2Cx FMPI2C Instance.
  1410. * @retval State of bit (1 or 0).
  1411. */
  1412. __STATIC_INLINE uint32_t LL_FMPI2C_IsActiveFlag_ADDR(FMPI2C_TypeDef *FMPI2Cx)
  1413. {
  1414. return ((READ_BIT(FMPI2Cx->ISR, FMPI2C_ISR_ADDR) == (FMPI2C_ISR_ADDR)) ? 1UL : 0UL);
  1415. }
  1416. /**
  1417. * @brief Indicate the status of Not Acknowledge received flag.
  1418. * @note RESET: Clear default value.
  1419. * SET: When a NACK is received after a byte transmission.
  1420. * @rmtoll ISR NACKF LL_FMPI2C_IsActiveFlag_NACK
  1421. * @param FMPI2Cx FMPI2C Instance.
  1422. * @retval State of bit (1 or 0).
  1423. */
  1424. __STATIC_INLINE uint32_t LL_FMPI2C_IsActiveFlag_NACK(FMPI2C_TypeDef *FMPI2Cx)
  1425. {
  1426. return ((READ_BIT(FMPI2Cx->ISR, FMPI2C_ISR_NACKF) == (FMPI2C_ISR_NACKF)) ? 1UL : 0UL);
  1427. }
  1428. /**
  1429. * @brief Indicate the status of Stop detection flag.
  1430. * @note RESET: Clear default value.
  1431. * SET: When a Stop condition is detected.
  1432. * @rmtoll ISR STOPF LL_FMPI2C_IsActiveFlag_STOP
  1433. * @param FMPI2Cx FMPI2C Instance.
  1434. * @retval State of bit (1 or 0).
  1435. */
  1436. __STATIC_INLINE uint32_t LL_FMPI2C_IsActiveFlag_STOP(FMPI2C_TypeDef *FMPI2Cx)
  1437. {
  1438. return ((READ_BIT(FMPI2Cx->ISR, FMPI2C_ISR_STOPF) == (FMPI2C_ISR_STOPF)) ? 1UL : 0UL);
  1439. }
  1440. /**
  1441. * @brief Indicate the status of Transfer complete flag (master mode).
  1442. * @note RESET: Clear default value.
  1443. * SET: When RELOAD=0, AUTOEND=0 and NBYTES date have been transferred.
  1444. * @rmtoll ISR TC LL_FMPI2C_IsActiveFlag_TC
  1445. * @param FMPI2Cx FMPI2C Instance.
  1446. * @retval State of bit (1 or 0).
  1447. */
  1448. __STATIC_INLINE uint32_t LL_FMPI2C_IsActiveFlag_TC(FMPI2C_TypeDef *FMPI2Cx)
  1449. {
  1450. return ((READ_BIT(FMPI2Cx->ISR, FMPI2C_ISR_TC) == (FMPI2C_ISR_TC)) ? 1UL : 0UL);
  1451. }
  1452. /**
  1453. * @brief Indicate the status of Transfer complete flag (master mode).
  1454. * @note RESET: Clear default value.
  1455. * SET: When RELOAD=1 and NBYTES date have been transferred.
  1456. * @rmtoll ISR TCR LL_FMPI2C_IsActiveFlag_TCR
  1457. * @param FMPI2Cx FMPI2C Instance.
  1458. * @retval State of bit (1 or 0).
  1459. */
  1460. __STATIC_INLINE uint32_t LL_FMPI2C_IsActiveFlag_TCR(FMPI2C_TypeDef *FMPI2Cx)
  1461. {
  1462. return ((READ_BIT(FMPI2Cx->ISR, FMPI2C_ISR_TCR) == (FMPI2C_ISR_TCR)) ? 1UL : 0UL);
  1463. }
  1464. /**
  1465. * @brief Indicate the status of Bus error flag.
  1466. * @note RESET: Clear default value.
  1467. * SET: When a misplaced Start or Stop condition is detected.
  1468. * @rmtoll ISR BERR LL_FMPI2C_IsActiveFlag_BERR
  1469. * @param FMPI2Cx FMPI2C Instance.
  1470. * @retval State of bit (1 or 0).
  1471. */
  1472. __STATIC_INLINE uint32_t LL_FMPI2C_IsActiveFlag_BERR(FMPI2C_TypeDef *FMPI2Cx)
  1473. {
  1474. return ((READ_BIT(FMPI2Cx->ISR, FMPI2C_ISR_BERR) == (FMPI2C_ISR_BERR)) ? 1UL : 0UL);
  1475. }
  1476. /**
  1477. * @brief Indicate the status of Arbitration lost flag.
  1478. * @note RESET: Clear default value.
  1479. * SET: When arbitration lost.
  1480. * @rmtoll ISR ARLO LL_FMPI2C_IsActiveFlag_ARLO
  1481. * @param FMPI2Cx FMPI2C Instance.
  1482. * @retval State of bit (1 or 0).
  1483. */
  1484. __STATIC_INLINE uint32_t LL_FMPI2C_IsActiveFlag_ARLO(FMPI2C_TypeDef *FMPI2Cx)
  1485. {
  1486. return ((READ_BIT(FMPI2Cx->ISR, FMPI2C_ISR_ARLO) == (FMPI2C_ISR_ARLO)) ? 1UL : 0UL);
  1487. }
  1488. /**
  1489. * @brief Indicate the status of Overrun/Underrun flag (slave mode).
  1490. * @note RESET: Clear default value.
  1491. * SET: When an overrun/underrun error occurs (Clock Stretching Disabled).
  1492. * @rmtoll ISR OVR LL_FMPI2C_IsActiveFlag_OVR
  1493. * @param FMPI2Cx FMPI2C Instance.
  1494. * @retval State of bit (1 or 0).
  1495. */
  1496. __STATIC_INLINE uint32_t LL_FMPI2C_IsActiveFlag_OVR(FMPI2C_TypeDef *FMPI2Cx)
  1497. {
  1498. return ((READ_BIT(FMPI2Cx->ISR, FMPI2C_ISR_OVR) == (FMPI2C_ISR_OVR)) ? 1UL : 0UL);
  1499. }
  1500. /**
  1501. * @brief Indicate the status of SMBus PEC error flag in reception.
  1502. * @note The macro IS_FMPSMBUS_ALL_INSTANCE(FMPI2Cx) can be used to check whether or not
  1503. * SMBus feature is supported by the FMPI2Cx Instance.
  1504. * @note RESET: Clear default value.
  1505. * SET: When the received PEC does not match with the PEC register content.
  1506. * @rmtoll ISR PECERR LL_FMPI2C_IsActiveSMBusFlag_PECERR
  1507. * @param FMPI2Cx FMPI2C Instance.
  1508. * @retval State of bit (1 or 0).
  1509. */
  1510. __STATIC_INLINE uint32_t LL_FMPI2C_IsActiveSMBusFlag_PECERR(FMPI2C_TypeDef *FMPI2Cx)
  1511. {
  1512. return ((READ_BIT(FMPI2Cx->ISR, FMPI2C_ISR_PECERR) == (FMPI2C_ISR_PECERR)) ? 1UL : 0UL);
  1513. }
  1514. /**
  1515. * @brief Indicate the status of SMBus Timeout detection flag.
  1516. * @note The macro IS_FMPSMBUS_ALL_INSTANCE(FMPI2Cx) can be used to check whether or not
  1517. * SMBus feature is supported by the FMPI2Cx Instance.
  1518. * @note RESET: Clear default value.
  1519. * SET: When a timeout or extended clock timeout occurs.
  1520. * @rmtoll ISR TIMEOUT LL_FMPI2C_IsActiveSMBusFlag_TIMEOUT
  1521. * @param FMPI2Cx FMPI2C Instance.
  1522. * @retval State of bit (1 or 0).
  1523. */
  1524. __STATIC_INLINE uint32_t LL_FMPI2C_IsActiveSMBusFlag_TIMEOUT(FMPI2C_TypeDef *FMPI2Cx)
  1525. {
  1526. return ((READ_BIT(FMPI2Cx->ISR, FMPI2C_ISR_TIMEOUT) == (FMPI2C_ISR_TIMEOUT)) ? 1UL : 0UL);
  1527. }
  1528. /**
  1529. * @brief Indicate the status of SMBus alert flag.
  1530. * @note The macro IS_FMPSMBUS_ALL_INSTANCE(FMPI2Cx) can be used to check whether or not
  1531. * SMBus feature is supported by the FMPI2Cx Instance.
  1532. * @note RESET: Clear default value.
  1533. * SET: When SMBus host configuration, SMBus alert enabled and
  1534. * a falling edge event occurs on SMBA pin.
  1535. * @rmtoll ISR ALERT LL_FMPI2C_IsActiveSMBusFlag_ALERT
  1536. * @param FMPI2Cx FMPI2C Instance.
  1537. * @retval State of bit (1 or 0).
  1538. */
  1539. __STATIC_INLINE uint32_t LL_FMPI2C_IsActiveSMBusFlag_ALERT(FMPI2C_TypeDef *FMPI2Cx)
  1540. {
  1541. return ((READ_BIT(FMPI2Cx->ISR, FMPI2C_ISR_ALERT) == (FMPI2C_ISR_ALERT)) ? 1UL : 0UL);
  1542. }
  1543. /**
  1544. * @brief Indicate the status of Bus Busy flag.
  1545. * @note RESET: Clear default value.
  1546. * SET: When a Start condition is detected.
  1547. * @rmtoll ISR BUSY LL_FMPI2C_IsActiveFlag_BUSY
  1548. * @param FMPI2Cx FMPI2C Instance.
  1549. * @retval State of bit (1 or 0).
  1550. */
  1551. __STATIC_INLINE uint32_t LL_FMPI2C_IsActiveFlag_BUSY(FMPI2C_TypeDef *FMPI2Cx)
  1552. {
  1553. return ((READ_BIT(FMPI2Cx->ISR, FMPI2C_ISR_BUSY) == (FMPI2C_ISR_BUSY)) ? 1UL : 0UL);
  1554. }
  1555. /**
  1556. * @brief Clear Address Matched flag.
  1557. * @rmtoll ICR ADDRCF LL_FMPI2C_ClearFlag_ADDR
  1558. * @param FMPI2Cx FMPI2C Instance.
  1559. * @retval None
  1560. */
  1561. __STATIC_INLINE void LL_FMPI2C_ClearFlag_ADDR(FMPI2C_TypeDef *FMPI2Cx)
  1562. {
  1563. SET_BIT(FMPI2Cx->ICR, FMPI2C_ICR_ADDRCF);
  1564. }
  1565. /**
  1566. * @brief Clear Not Acknowledge flag.
  1567. * @rmtoll ICR NACKCF LL_FMPI2C_ClearFlag_NACK
  1568. * @param FMPI2Cx FMPI2C Instance.
  1569. * @retval None
  1570. */
  1571. __STATIC_INLINE void LL_FMPI2C_ClearFlag_NACK(FMPI2C_TypeDef *FMPI2Cx)
  1572. {
  1573. SET_BIT(FMPI2Cx->ICR, FMPI2C_ICR_NACKCF);
  1574. }
  1575. /**
  1576. * @brief Clear Stop detection flag.
  1577. * @rmtoll ICR STOPCF LL_FMPI2C_ClearFlag_STOP
  1578. * @param FMPI2Cx FMPI2C Instance.
  1579. * @retval None
  1580. */
  1581. __STATIC_INLINE void LL_FMPI2C_ClearFlag_STOP(FMPI2C_TypeDef *FMPI2Cx)
  1582. {
  1583. SET_BIT(FMPI2Cx->ICR, FMPI2C_ICR_STOPCF);
  1584. }
  1585. /**
  1586. * @brief Clear Transmit data register empty flag (TXE).
  1587. * @note This bit can be clear by software in order to flush the transmit data register (TXDR).
  1588. * @rmtoll ISR TXE LL_FMPI2C_ClearFlag_TXE
  1589. * @param FMPI2Cx FMPI2C Instance.
  1590. * @retval None
  1591. */
  1592. __STATIC_INLINE void LL_FMPI2C_ClearFlag_TXE(FMPI2C_TypeDef *FMPI2Cx)
  1593. {
  1594. WRITE_REG(FMPI2Cx->ISR, FMPI2C_ISR_TXE);
  1595. }
  1596. /**
  1597. * @brief Clear Bus error flag.
  1598. * @rmtoll ICR BERRCF LL_FMPI2C_ClearFlag_BERR
  1599. * @param FMPI2Cx FMPI2C Instance.
  1600. * @retval None
  1601. */
  1602. __STATIC_INLINE void LL_FMPI2C_ClearFlag_BERR(FMPI2C_TypeDef *FMPI2Cx)
  1603. {
  1604. SET_BIT(FMPI2Cx->ICR, FMPI2C_ICR_BERRCF);
  1605. }
  1606. /**
  1607. * @brief Clear Arbitration lost flag.
  1608. * @rmtoll ICR ARLOCF LL_FMPI2C_ClearFlag_ARLO
  1609. * @param FMPI2Cx FMPI2C Instance.
  1610. * @retval None
  1611. */
  1612. __STATIC_INLINE void LL_FMPI2C_ClearFlag_ARLO(FMPI2C_TypeDef *FMPI2Cx)
  1613. {
  1614. SET_BIT(FMPI2Cx->ICR, FMPI2C_ICR_ARLOCF);
  1615. }
  1616. /**
  1617. * @brief Clear Overrun/Underrun flag.
  1618. * @rmtoll ICR OVRCF LL_FMPI2C_ClearFlag_OVR
  1619. * @param FMPI2Cx FMPI2C Instance.
  1620. * @retval None
  1621. */
  1622. __STATIC_INLINE void LL_FMPI2C_ClearFlag_OVR(FMPI2C_TypeDef *FMPI2Cx)
  1623. {
  1624. SET_BIT(FMPI2Cx->ICR, FMPI2C_ICR_OVRCF);
  1625. }
  1626. /**
  1627. * @brief Clear SMBus PEC error flag.
  1628. * @note The macro IS_FMPSMBUS_ALL_INSTANCE(FMPI2Cx) can be used to check whether or not
  1629. * SMBus feature is supported by the FMPI2Cx Instance.
  1630. * @rmtoll ICR PECCF LL_FMPI2C_ClearSMBusFlag_PECERR
  1631. * @param FMPI2Cx FMPI2C Instance.
  1632. * @retval None
  1633. */
  1634. __STATIC_INLINE void LL_FMPI2C_ClearSMBusFlag_PECERR(FMPI2C_TypeDef *FMPI2Cx)
  1635. {
  1636. SET_BIT(FMPI2Cx->ICR, FMPI2C_ICR_PECCF);
  1637. }
  1638. /**
  1639. * @brief Clear SMBus Timeout detection flag.
  1640. * @note The macro IS_FMPSMBUS_ALL_INSTANCE(FMPI2Cx) can be used to check whether or not
  1641. * SMBus feature is supported by the FMPI2Cx Instance.
  1642. * @rmtoll ICR TIMOUTCF LL_FMPI2C_ClearSMBusFlag_TIMEOUT
  1643. * @param FMPI2Cx FMPI2C Instance.
  1644. * @retval None
  1645. */
  1646. __STATIC_INLINE void LL_FMPI2C_ClearSMBusFlag_TIMEOUT(FMPI2C_TypeDef *FMPI2Cx)
  1647. {
  1648. SET_BIT(FMPI2Cx->ICR, FMPI2C_ICR_TIMOUTCF);
  1649. }
  1650. /**
  1651. * @brief Clear SMBus Alert flag.
  1652. * @note The macro IS_FMPSMBUS_ALL_INSTANCE(FMPI2Cx) can be used to check whether or not
  1653. * SMBus feature is supported by the FMPI2Cx Instance.
  1654. * @rmtoll ICR ALERTCF LL_FMPI2C_ClearSMBusFlag_ALERT
  1655. * @param FMPI2Cx FMPI2C Instance.
  1656. * @retval None
  1657. */
  1658. __STATIC_INLINE void LL_FMPI2C_ClearSMBusFlag_ALERT(FMPI2C_TypeDef *FMPI2Cx)
  1659. {
  1660. SET_BIT(FMPI2Cx->ICR, FMPI2C_ICR_ALERTCF);
  1661. }
  1662. /**
  1663. * @}
  1664. */
  1665. /** @defgroup FMPI2C_LL_EF_Data_Management Data_Management
  1666. * @{
  1667. */
  1668. /**
  1669. * @brief Enable automatic STOP condition generation (master mode).
  1670. * @note Automatic end mode : a STOP condition is automatically sent when NBYTES data are transferred.
  1671. * This bit has no effect in slave mode or when RELOAD bit is set.
  1672. * @rmtoll CR2 AUTOEND LL_FMPI2C_EnableAutoEndMode
  1673. * @param FMPI2Cx FMPI2C Instance.
  1674. * @retval None
  1675. */
  1676. __STATIC_INLINE void LL_FMPI2C_EnableAutoEndMode(FMPI2C_TypeDef *FMPI2Cx)
  1677. {
  1678. SET_BIT(FMPI2Cx->CR2, FMPI2C_CR2_AUTOEND);
  1679. }
  1680. /**
  1681. * @brief Disable automatic STOP condition generation (master mode).
  1682. * @note Software end mode : TC flag is set when NBYTES data are transferre, stretching SCL low.
  1683. * @rmtoll CR2 AUTOEND LL_FMPI2C_DisableAutoEndMode
  1684. * @param FMPI2Cx FMPI2C Instance.
  1685. * @retval None
  1686. */
  1687. __STATIC_INLINE void LL_FMPI2C_DisableAutoEndMode(FMPI2C_TypeDef *FMPI2Cx)
  1688. {
  1689. CLEAR_BIT(FMPI2Cx->CR2, FMPI2C_CR2_AUTOEND);
  1690. }
  1691. /**
  1692. * @brief Check if automatic STOP condition is enabled or disabled.
  1693. * @rmtoll CR2 AUTOEND LL_FMPI2C_IsEnabledAutoEndMode
  1694. * @param FMPI2Cx FMPI2C Instance.
  1695. * @retval State of bit (1 or 0).
  1696. */
  1697. __STATIC_INLINE uint32_t LL_FMPI2C_IsEnabledAutoEndMode(FMPI2C_TypeDef *FMPI2Cx)
  1698. {
  1699. return ((READ_BIT(FMPI2Cx->CR2, FMPI2C_CR2_AUTOEND) == (FMPI2C_CR2_AUTOEND)) ? 1UL : 0UL);
  1700. }
  1701. /**
  1702. * @brief Enable reload mode (master mode).
  1703. * @note The transfer is not completed after the NBYTES data transfer, NBYTES will be reloaded when TCR flag is set.
  1704. * @rmtoll CR2 RELOAD LL_FMPI2C_EnableReloadMode
  1705. * @param FMPI2Cx FMPI2C Instance.
  1706. * @retval None
  1707. */
  1708. __STATIC_INLINE void LL_FMPI2C_EnableReloadMode(FMPI2C_TypeDef *FMPI2Cx)
  1709. {
  1710. SET_BIT(FMPI2Cx->CR2, FMPI2C_CR2_RELOAD);
  1711. }
  1712. /**
  1713. * @brief Disable reload mode (master mode).
  1714. * @note The transfer is completed after the NBYTES data transfer(STOP or RESTART will follow).
  1715. * @rmtoll CR2 RELOAD LL_FMPI2C_DisableReloadMode
  1716. * @param FMPI2Cx FMPI2C Instance.
  1717. * @retval None
  1718. */
  1719. __STATIC_INLINE void LL_FMPI2C_DisableReloadMode(FMPI2C_TypeDef *FMPI2Cx)
  1720. {
  1721. CLEAR_BIT(FMPI2Cx->CR2, FMPI2C_CR2_RELOAD);
  1722. }
  1723. /**
  1724. * @brief Check if reload mode is enabled or disabled.
  1725. * @rmtoll CR2 RELOAD LL_FMPI2C_IsEnabledReloadMode
  1726. * @param FMPI2Cx FMPI2C Instance.
  1727. * @retval State of bit (1 or 0).
  1728. */
  1729. __STATIC_INLINE uint32_t LL_FMPI2C_IsEnabledReloadMode(FMPI2C_TypeDef *FMPI2Cx)
  1730. {
  1731. return ((READ_BIT(FMPI2Cx->CR2, FMPI2C_CR2_RELOAD) == (FMPI2C_CR2_RELOAD)) ? 1UL : 0UL);
  1732. }
  1733. /**
  1734. * @brief Configure the number of bytes for transfer.
  1735. * @note Changing these bits when START bit is set is not allowed.
  1736. * @rmtoll CR2 NBYTES LL_FMPI2C_SetTransferSize
  1737. * @param FMPI2Cx FMPI2C Instance.
  1738. * @param TransferSize This parameter must be a value between Min_Data=0x00 and Max_Data=0xFF.
  1739. * @retval None
  1740. */
  1741. __STATIC_INLINE void LL_FMPI2C_SetTransferSize(FMPI2C_TypeDef *FMPI2Cx, uint32_t TransferSize)
  1742. {
  1743. MODIFY_REG(FMPI2Cx->CR2, FMPI2C_CR2_NBYTES, TransferSize << FMPI2C_CR2_NBYTES_Pos);
  1744. }
  1745. /**
  1746. * @brief Get the number of bytes configured for transfer.
  1747. * @rmtoll CR2 NBYTES LL_FMPI2C_GetTransferSize
  1748. * @param FMPI2Cx FMPI2C Instance.
  1749. * @retval Value between Min_Data=0x0 and Max_Data=0xFF
  1750. */
  1751. __STATIC_INLINE uint32_t LL_FMPI2C_GetTransferSize(FMPI2C_TypeDef *FMPI2Cx)
  1752. {
  1753. return (uint32_t)(READ_BIT(FMPI2Cx->CR2, FMPI2C_CR2_NBYTES) >> FMPI2C_CR2_NBYTES_Pos);
  1754. }
  1755. /**
  1756. * @brief Prepare the generation of a ACKnowledge or Non ACKnowledge condition after the address receive match code
  1757. or next received byte.
  1758. * @note Usage in Slave mode only.
  1759. * @rmtoll CR2 NACK LL_FMPI2C_AcknowledgeNextData
  1760. * @param FMPI2Cx FMPI2C Instance.
  1761. * @param TypeAcknowledge This parameter can be one of the following values:
  1762. * @arg @ref LL_FMPI2C_ACK
  1763. * @arg @ref LL_FMPI2C_NACK
  1764. * @retval None
  1765. */
  1766. __STATIC_INLINE void LL_FMPI2C_AcknowledgeNextData(FMPI2C_TypeDef *FMPI2Cx, uint32_t TypeAcknowledge)
  1767. {
  1768. MODIFY_REG(FMPI2Cx->CR2, FMPI2C_CR2_NACK, TypeAcknowledge);
  1769. }
  1770. /**
  1771. * @brief Generate a START or RESTART condition
  1772. * @note The START bit can be set even if bus is BUSY or FMPI2C is in slave mode.
  1773. * This action has no effect when RELOAD is set.
  1774. * @rmtoll CR2 START LL_FMPI2C_GenerateStartCondition
  1775. * @param FMPI2Cx FMPI2C Instance.
  1776. * @retval None
  1777. */
  1778. __STATIC_INLINE void LL_FMPI2C_GenerateStartCondition(FMPI2C_TypeDef *FMPI2Cx)
  1779. {
  1780. SET_BIT(FMPI2Cx->CR2, FMPI2C_CR2_START);
  1781. }
  1782. /**
  1783. * @brief Generate a STOP condition after the current byte transfer (master mode).
  1784. * @rmtoll CR2 STOP LL_FMPI2C_GenerateStopCondition
  1785. * @param FMPI2Cx FMPI2C Instance.
  1786. * @retval None
  1787. */
  1788. __STATIC_INLINE void LL_FMPI2C_GenerateStopCondition(FMPI2C_TypeDef *FMPI2Cx)
  1789. {
  1790. SET_BIT(FMPI2Cx->CR2, FMPI2C_CR2_STOP);
  1791. }
  1792. /**
  1793. * @brief Enable automatic RESTART Read request condition for 10bit address header (master mode).
  1794. * @note The master sends the complete 10bit slave address read sequence :
  1795. * Start + 2 bytes 10bit address in Write direction + Restart + first 7 bits of 10bit address
  1796. in Read direction.
  1797. * @rmtoll CR2 HEAD10R LL_FMPI2C_EnableAuto10BitRead
  1798. * @param FMPI2Cx FMPI2C Instance.
  1799. * @retval None
  1800. */
  1801. __STATIC_INLINE void LL_FMPI2C_EnableAuto10BitRead(FMPI2C_TypeDef *FMPI2Cx)
  1802. {
  1803. CLEAR_BIT(FMPI2Cx->CR2, FMPI2C_CR2_HEAD10R);
  1804. }
  1805. /**
  1806. * @brief Disable automatic RESTART Read request condition for 10bit address header (master mode).
  1807. * @note The master only sends the first 7 bits of 10bit address in Read direction.
  1808. * @rmtoll CR2 HEAD10R LL_FMPI2C_DisableAuto10BitRead
  1809. * @param FMPI2Cx FMPI2C Instance.
  1810. * @retval None
  1811. */
  1812. __STATIC_INLINE void LL_FMPI2C_DisableAuto10BitRead(FMPI2C_TypeDef *FMPI2Cx)
  1813. {
  1814. SET_BIT(FMPI2Cx->CR2, FMPI2C_CR2_HEAD10R);
  1815. }
  1816. /**
  1817. * @brief Check if automatic RESTART Read request condition for 10bit address header is enabled or disabled.
  1818. * @rmtoll CR2 HEAD10R LL_FMPI2C_IsEnabledAuto10BitRead
  1819. * @param FMPI2Cx FMPI2C Instance.
  1820. * @retval State of bit (1 or 0).
  1821. */
  1822. __STATIC_INLINE uint32_t LL_FMPI2C_IsEnabledAuto10BitRead(FMPI2C_TypeDef *FMPI2Cx)
  1823. {
  1824. return ((READ_BIT(FMPI2Cx->CR2, FMPI2C_CR2_HEAD10R) != (FMPI2C_CR2_HEAD10R)) ? 1UL : 0UL);
  1825. }
  1826. /**
  1827. * @brief Configure the transfer direction (master mode).
  1828. * @note Changing these bits when START bit is set is not allowed.
  1829. * @rmtoll CR2 RD_WRN LL_FMPI2C_SetTransferRequest
  1830. * @param FMPI2Cx FMPI2C Instance.
  1831. * @param TransferRequest This parameter can be one of the following values:
  1832. * @arg @ref LL_FMPI2C_REQUEST_WRITE
  1833. * @arg @ref LL_FMPI2C_REQUEST_READ
  1834. * @retval None
  1835. */
  1836. __STATIC_INLINE void LL_FMPI2C_SetTransferRequest(FMPI2C_TypeDef *FMPI2Cx, uint32_t TransferRequest)
  1837. {
  1838. MODIFY_REG(FMPI2Cx->CR2, FMPI2C_CR2_RD_WRN, TransferRequest);
  1839. }
  1840. /**
  1841. * @brief Get the transfer direction requested (master mode).
  1842. * @rmtoll CR2 RD_WRN LL_FMPI2C_GetTransferRequest
  1843. * @param FMPI2Cx FMPI2C Instance.
  1844. * @retval Returned value can be one of the following values:
  1845. * @arg @ref LL_FMPI2C_REQUEST_WRITE
  1846. * @arg @ref LL_FMPI2C_REQUEST_READ
  1847. */
  1848. __STATIC_INLINE uint32_t LL_FMPI2C_GetTransferRequest(FMPI2C_TypeDef *FMPI2Cx)
  1849. {
  1850. return (uint32_t)(READ_BIT(FMPI2Cx->CR2, FMPI2C_CR2_RD_WRN));
  1851. }
  1852. /**
  1853. * @brief Configure the slave address for transfer (master mode).
  1854. * @note Changing these bits when START bit is set is not allowed.
  1855. * @rmtoll CR2 SADD LL_FMPI2C_SetSlaveAddr
  1856. * @param FMPI2Cx FMPI2C Instance.
  1857. * @param SlaveAddr This parameter must be a value between Min_Data=0x00 and Max_Data=0x3F.
  1858. * @retval None
  1859. */
  1860. __STATIC_INLINE void LL_FMPI2C_SetSlaveAddr(FMPI2C_TypeDef *FMPI2Cx, uint32_t SlaveAddr)
  1861. {
  1862. MODIFY_REG(FMPI2Cx->CR2, FMPI2C_CR2_SADD, SlaveAddr);
  1863. }
  1864. /**
  1865. * @brief Get the slave address programmed for transfer.
  1866. * @rmtoll CR2 SADD LL_FMPI2C_GetSlaveAddr
  1867. * @param FMPI2Cx FMPI2C Instance.
  1868. * @retval Value between Min_Data=0x0 and Max_Data=0x3F
  1869. */
  1870. __STATIC_INLINE uint32_t LL_FMPI2C_GetSlaveAddr(FMPI2C_TypeDef *FMPI2Cx)
  1871. {
  1872. return (uint32_t)(READ_BIT(FMPI2Cx->CR2, FMPI2C_CR2_SADD));
  1873. }
  1874. /**
  1875. * @brief Handles FMPI2Cx communication when starting transfer or during transfer (TC or TCR flag are set).
  1876. * @rmtoll CR2 SADD LL_FMPI2C_HandleTransfer\n
  1877. * CR2 ADD10 LL_FMPI2C_HandleTransfer\n
  1878. * CR2 RD_WRN LL_FMPI2C_HandleTransfer\n
  1879. * CR2 START LL_FMPI2C_HandleTransfer\n
  1880. * CR2 STOP LL_FMPI2C_HandleTransfer\n
  1881. * CR2 RELOAD LL_FMPI2C_HandleTransfer\n
  1882. * CR2 NBYTES LL_FMPI2C_HandleTransfer\n
  1883. * CR2 AUTOEND LL_FMPI2C_HandleTransfer\n
  1884. * CR2 HEAD10R LL_FMPI2C_HandleTransfer
  1885. * @param FMPI2Cx FMPI2C Instance.
  1886. * @param SlaveAddr Specifies the slave address to be programmed.
  1887. * @param SlaveAddrSize This parameter can be one of the following values:
  1888. * @arg @ref LL_FMPI2C_ADDRSLAVE_7BIT
  1889. * @arg @ref LL_FMPI2C_ADDRSLAVE_10BIT
  1890. * @param TransferSize Specifies the number of bytes to be programmed.
  1891. * This parameter must be a value between Min_Data=0 and Max_Data=255.
  1892. * @param EndMode This parameter can be one of the following values:
  1893. * @arg @ref LL_FMPI2C_MODE_RELOAD
  1894. * @arg @ref LL_FMPI2C_MODE_AUTOEND
  1895. * @arg @ref LL_FMPI2C_MODE_SOFTEND
  1896. * @arg @ref LL_FMPI2C_MODE_SMBUS_RELOAD
  1897. * @arg @ref LL_FMPI2C_MODE_SMBUS_AUTOEND_NO_PEC
  1898. * @arg @ref LL_FMPI2C_MODE_SMBUS_SOFTEND_NO_PEC
  1899. * @arg @ref LL_FMPI2C_MODE_SMBUS_AUTOEND_WITH_PEC
  1900. * @arg @ref LL_FMPI2C_MODE_SMBUS_SOFTEND_WITH_PEC
  1901. * @param Request This parameter can be one of the following values:
  1902. * @arg @ref LL_FMPI2C_GENERATE_NOSTARTSTOP
  1903. * @arg @ref LL_FMPI2C_GENERATE_STOP
  1904. * @arg @ref LL_FMPI2C_GENERATE_START_READ
  1905. * @arg @ref LL_FMPI2C_GENERATE_START_WRITE
  1906. * @arg @ref LL_FMPI2C_GENERATE_RESTART_7BIT_READ
  1907. * @arg @ref LL_FMPI2C_GENERATE_RESTART_7BIT_WRITE
  1908. * @arg @ref LL_FMPI2C_GENERATE_RESTART_10BIT_READ
  1909. * @arg @ref LL_FMPI2C_GENERATE_RESTART_10BIT_WRITE
  1910. * @retval None
  1911. */
  1912. __STATIC_INLINE void LL_FMPI2C_HandleTransfer(FMPI2C_TypeDef *FMPI2Cx, uint32_t SlaveAddr, uint32_t SlaveAddrSize,
  1913. uint32_t TransferSize, uint32_t EndMode, uint32_t Request)
  1914. {
  1915. MODIFY_REG(FMPI2Cx->CR2, FMPI2C_CR2_SADD | FMPI2C_CR2_ADD10 |
  1916. (FMPI2C_CR2_RD_WRN & (uint32_t)(Request >> (31U - FMPI2C_CR2_RD_WRN_Pos))) |
  1917. FMPI2C_CR2_START | FMPI2C_CR2_STOP | FMPI2C_CR2_RELOAD |
  1918. FMPI2C_CR2_NBYTES | FMPI2C_CR2_AUTOEND | FMPI2C_CR2_HEAD10R,
  1919. SlaveAddr | SlaveAddrSize | (TransferSize << FMPI2C_CR2_NBYTES_Pos) | EndMode | Request);
  1920. }
  1921. /**
  1922. * @brief Indicate the value of transfer direction (slave mode).
  1923. * @note RESET: Write transfer, Slave enters in receiver mode.
  1924. * SET: Read transfer, Slave enters in transmitter mode.
  1925. * @rmtoll ISR DIR LL_FMPI2C_GetTransferDirection
  1926. * @param FMPI2Cx FMPI2C Instance.
  1927. * @retval Returned value can be one of the following values:
  1928. * @arg @ref LL_FMPI2C_DIRECTION_WRITE
  1929. * @arg @ref LL_FMPI2C_DIRECTION_READ
  1930. */
  1931. __STATIC_INLINE uint32_t LL_FMPI2C_GetTransferDirection(FMPI2C_TypeDef *FMPI2Cx)
  1932. {
  1933. return (uint32_t)(READ_BIT(FMPI2Cx->ISR, FMPI2C_ISR_DIR));
  1934. }
  1935. /**
  1936. * @brief Return the slave matched address.
  1937. * @rmtoll ISR ADDCODE LL_FMPI2C_GetAddressMatchCode
  1938. * @param FMPI2Cx FMPI2C Instance.
  1939. * @retval Value between Min_Data=0x00 and Max_Data=0x3F
  1940. */
  1941. __STATIC_INLINE uint32_t LL_FMPI2C_GetAddressMatchCode(FMPI2C_TypeDef *FMPI2Cx)
  1942. {
  1943. return (uint32_t)(READ_BIT(FMPI2Cx->ISR, FMPI2C_ISR_ADDCODE) >> FMPI2C_ISR_ADDCODE_Pos << 1);
  1944. }
  1945. /**
  1946. * @brief Enable internal comparison of the SMBus Packet Error byte (transmission or reception mode).
  1947. * @note The macro IS_FMPSMBUS_ALL_INSTANCE(FMPI2Cx) can be used to check whether or not
  1948. * SMBus feature is supported by the FMPI2Cx Instance.
  1949. * @note This feature is cleared by hardware when the PEC byte is transferred, or when a STOP condition
  1950. or an Address Matched is received.
  1951. * This bit has no effect when RELOAD bit is set.
  1952. * This bit has no effect in device mode when SBC bit is not set.
  1953. * @rmtoll CR2 PECBYTE LL_FMPI2C_EnableSMBusPECCompare
  1954. * @param FMPI2Cx FMPI2C Instance.
  1955. * @retval None
  1956. */
  1957. __STATIC_INLINE void LL_FMPI2C_EnableSMBusPECCompare(FMPI2C_TypeDef *FMPI2Cx)
  1958. {
  1959. SET_BIT(FMPI2Cx->CR2, FMPI2C_CR2_PECBYTE);
  1960. }
  1961. /**
  1962. * @brief Check if the SMBus Packet Error byte internal comparison is requested or not.
  1963. * @note The macro IS_FMPSMBUS_ALL_INSTANCE(FMPI2Cx) can be used to check whether or not
  1964. * SMBus feature is supported by the FMPI2Cx Instance.
  1965. * @rmtoll CR2 PECBYTE LL_FMPI2C_IsEnabledSMBusPECCompare
  1966. * @param FMPI2Cx FMPI2C Instance.
  1967. * @retval State of bit (1 or 0).
  1968. */
  1969. __STATIC_INLINE uint32_t LL_FMPI2C_IsEnabledSMBusPECCompare(FMPI2C_TypeDef *FMPI2Cx)
  1970. {
  1971. return ((READ_BIT(FMPI2Cx->CR2, FMPI2C_CR2_PECBYTE) == (FMPI2C_CR2_PECBYTE)) ? 1UL : 0UL);
  1972. }
  1973. /**
  1974. * @brief Get the SMBus Packet Error byte calculated.
  1975. * @note The macro IS_FMPSMBUS_ALL_INSTANCE(FMPI2Cx) can be used to check whether or not
  1976. * SMBus feature is supported by the FMPI2Cx Instance.
  1977. * @rmtoll PECR PEC LL_FMPI2C_GetSMBusPEC
  1978. * @param FMPI2Cx FMPI2C Instance.
  1979. * @retval Value between Min_Data=0x00 and Max_Data=0xFF
  1980. */
  1981. __STATIC_INLINE uint32_t LL_FMPI2C_GetSMBusPEC(FMPI2C_TypeDef *FMPI2Cx)
  1982. {
  1983. return (uint32_t)(READ_BIT(FMPI2Cx->PECR, FMPI2C_PECR_PEC));
  1984. }
  1985. /**
  1986. * @brief Read Receive Data register.
  1987. * @rmtoll RXDR RXDATA LL_FMPI2C_ReceiveData8
  1988. * @param FMPI2Cx FMPI2C Instance.
  1989. * @retval Value between Min_Data=0x00 and Max_Data=0xFF
  1990. */
  1991. __STATIC_INLINE uint8_t LL_FMPI2C_ReceiveData8(FMPI2C_TypeDef *FMPI2Cx)
  1992. {
  1993. return (uint8_t)(READ_BIT(FMPI2Cx->RXDR, FMPI2C_RXDR_RXDATA));
  1994. }
  1995. /**
  1996. * @brief Write in Transmit Data Register .
  1997. * @rmtoll TXDR TXDATA LL_FMPI2C_TransmitData8
  1998. * @param FMPI2Cx FMPI2C Instance.
  1999. * @param Data Value between Min_Data=0x00 and Max_Data=0xFF
  2000. * @retval None
  2001. */
  2002. __STATIC_INLINE void LL_FMPI2C_TransmitData8(FMPI2C_TypeDef *FMPI2Cx, uint8_t Data)
  2003. {
  2004. WRITE_REG(FMPI2Cx->TXDR, Data);
  2005. }
  2006. /**
  2007. * @}
  2008. */
  2009. #if defined(USE_FULL_LL_DRIVER)
  2010. /** @defgroup FMPI2C_LL_EF_Init Initialization and de-initialization functions
  2011. * @{
  2012. */
  2013. ErrorStatus LL_FMPI2C_Init(FMPI2C_TypeDef *FMPI2Cx, LL_FMPI2C_InitTypeDef *FMPI2C_InitStruct);
  2014. ErrorStatus LL_FMPI2C_DeInit(FMPI2C_TypeDef *FMPI2Cx);
  2015. void LL_FMPI2C_StructInit(LL_FMPI2C_InitTypeDef *FMPI2C_InitStruct);
  2016. /**
  2017. * @}
  2018. */
  2019. #endif /* USE_FULL_LL_DRIVER */
  2020. /**
  2021. * @}
  2022. */
  2023. /**
  2024. * @}
  2025. */
  2026. #endif /* FMPI2C1 */
  2027. /**
  2028. * @}
  2029. */
  2030. #endif /* FMPI2C_CR1_PE */
  2031. #ifdef __cplusplus
  2032. }
  2033. #endif
  2034. #endif /* STM32F4xx_LL_FMPI2C_H */