stm32f7xx_ll_i2c.h 80 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206
  1. /**
  2. ******************************************************************************
  3. * @file stm32f7xx_ll_i2c.h
  4. * @author MCD Application Team
  5. * @brief Header file of I2C LL module.
  6. ******************************************************************************
  7. * @attention
  8. *
  9. * <h2><center>&copy; COPYRIGHT(c) 2017 STMicroelectronics</center></h2>
  10. *
  11. * Redistribution and use in source and binary forms, with or without modification,
  12. * are permitted provided that the following conditions are met:
  13. * 1. Redistributions of source code must retain the above copyright notice,
  14. * this list of conditions and the following disclaimer.
  15. * 2. Redistributions in binary form must reproduce the above copyright notice,
  16. * this list of conditions and the following disclaimer in the documentation
  17. * and/or other materials provided with the distribution.
  18. * 3. Neither the name of STMicroelectronics nor the names of its contributors
  19. * may be used to endorse or promote products derived from this software
  20. * without specific prior written permission.
  21. *
  22. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  23. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  24. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  25. * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
  26. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  27. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  28. * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  29. * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  30. * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  31. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  32. *
  33. ******************************************************************************
  34. */
  35. /* Define to prevent recursive inclusion -------------------------------------*/
  36. #ifndef __STM32F7xx_LL_I2C_H
  37. #define __STM32F7xx_LL_I2C_H
  38. #ifdef __cplusplus
  39. extern "C" {
  40. #endif
  41. /* Includes ------------------------------------------------------------------*/
  42. #include "stm32f7xx.h"
  43. /** @addtogroup STM32F7xx_LL_Driver
  44. * @{
  45. */
  46. #if defined (I2C1) || defined (I2C2) || defined (I2C3) || defined (I2C4)
  47. /** @defgroup I2C_LL I2C
  48. * @{
  49. */
  50. /* Private types -------------------------------------------------------------*/
  51. /* Private variables ---------------------------------------------------------*/
  52. /* Private constants ---------------------------------------------------------*/
  53. /** @defgroup I2C_LL_Private_Constants I2C Private Constants
  54. * @{
  55. */
  56. /**
  57. * @}
  58. */
  59. /* Private macros ------------------------------------------------------------*/
  60. #if defined(USE_FULL_LL_DRIVER)
  61. /** @defgroup I2C_LL_Private_Macros I2C Private Macros
  62. * @{
  63. */
  64. /**
  65. * @}
  66. */
  67. #endif /*USE_FULL_LL_DRIVER*/
  68. /* Exported types ------------------------------------------------------------*/
  69. #if defined(USE_FULL_LL_DRIVER)
  70. /** @defgroup I2C_LL_ES_INIT I2C Exported Init structure
  71. * @{
  72. */
  73. typedef struct
  74. {
  75. uint32_t PeripheralMode; /*!< Specifies the peripheral mode.
  76. This parameter can be a value of @ref I2C_LL_EC_PERIPHERAL_MODE
  77. This feature can be modified afterwards using unitary function @ref LL_I2C_SetMode(). */
  78. uint32_t Timing; /*!< Specifies the SDA setup, hold time and the SCL high, low period values.
  79. This parameter must be set by referring to the STM32CubeMX Tool and
  80. the helper macro @ref __LL_I2C_CONVERT_TIMINGS()
  81. This feature can be modified afterwards using unitary function @ref LL_I2C_SetTiming(). */
  82. uint32_t AnalogFilter; /*!< Enables or disables analog noise filter.
  83. This parameter can be a value of @ref I2C_LL_EC_ANALOGFILTER_SELECTION
  84. This feature can be modified afterwards using unitary functions @ref LL_I2C_EnableAnalogFilter() or LL_I2C_DisableAnalogFilter(). */
  85. uint32_t DigitalFilter; /*!< Configures the digital noise filter.
  86. This parameter can be a number between Min_Data = 0x00 and Max_Data = 0x0F
  87. This feature can be modified afterwards using unitary function @ref LL_I2C_SetDigitalFilter(). */
  88. uint32_t OwnAddress1; /*!< Specifies the device own address 1.
  89. This parameter must be a value between Min_Data = 0x00 and Max_Data = 0x3FF
  90. This feature can be modified afterwards using unitary function @ref LL_I2C_SetOwnAddress1(). */
  91. uint32_t TypeAcknowledge; /*!< Specifies the ACKnowledge or Non ACKnowledge condition after the address receive match code or next received byte.
  92. This parameter can be a value of @ref I2C_LL_EC_I2C_ACKNOWLEDGE
  93. This feature can be modified afterwards using unitary function @ref LL_I2C_AcknowledgeNextData(). */
  94. uint32_t OwnAddrSize; /*!< Specifies the device own address 1 size (7-bit or 10-bit).
  95. This parameter can be a value of @ref I2C_LL_EC_OWNADDRESS1
  96. This feature can be modified afterwards using unitary function @ref LL_I2C_SetOwnAddress1(). */
  97. } LL_I2C_InitTypeDef;
  98. /**
  99. * @}
  100. */
  101. #endif /*USE_FULL_LL_DRIVER*/
  102. /* Exported constants --------------------------------------------------------*/
  103. /** @defgroup I2C_LL_Exported_Constants I2C Exported Constants
  104. * @{
  105. */
  106. /** @defgroup I2C_LL_EC_CLEAR_FLAG Clear Flags Defines
  107. * @brief Flags defines which can be used with LL_I2C_WriteReg function
  108. * @{
  109. */
  110. #define LL_I2C_ICR_ADDRCF I2C_ICR_ADDRCF /*!< Address Matched flag */
  111. #define LL_I2C_ICR_NACKCF I2C_ICR_NACKCF /*!< Not Acknowledge flag */
  112. #define LL_I2C_ICR_STOPCF I2C_ICR_STOPCF /*!< Stop detection flag */
  113. #define LL_I2C_ICR_BERRCF I2C_ICR_BERRCF /*!< Bus error flag */
  114. #define LL_I2C_ICR_ARLOCF I2C_ICR_ARLOCF /*!< Arbitration Lost flag */
  115. #define LL_I2C_ICR_OVRCF I2C_ICR_OVRCF /*!< Overrun/Underrun flag */
  116. #define LL_I2C_ICR_PECCF I2C_ICR_PECCF /*!< PEC error flag */
  117. #define LL_I2C_ICR_TIMOUTCF I2C_ICR_TIMOUTCF /*!< Timeout detection flag */
  118. #define LL_I2C_ICR_ALERTCF I2C_ICR_ALERTCF /*!< Alert flag */
  119. /**
  120. * @}
  121. */
  122. /** @defgroup I2C_LL_EC_GET_FLAG Get Flags Defines
  123. * @brief Flags defines which can be used with LL_I2C_ReadReg function
  124. * @{
  125. */
  126. #define LL_I2C_ISR_TXE I2C_ISR_TXE /*!< Transmit data register empty */
  127. #define LL_I2C_ISR_TXIS I2C_ISR_TXIS /*!< Transmit interrupt status */
  128. #define LL_I2C_ISR_RXNE I2C_ISR_RXNE /*!< Receive data register not empty */
  129. #define LL_I2C_ISR_ADDR I2C_ISR_ADDR /*!< Address matched (slave mode) */
  130. #define LL_I2C_ISR_NACKF I2C_ISR_NACKF /*!< Not Acknowledge received flag */
  131. #define LL_I2C_ISR_STOPF I2C_ISR_STOPF /*!< Stop detection flag */
  132. #define LL_I2C_ISR_TC I2C_ISR_TC /*!< Transfer Complete (master mode) */
  133. #define LL_I2C_ISR_TCR I2C_ISR_TCR /*!< Transfer Complete Reload */
  134. #define LL_I2C_ISR_BERR I2C_ISR_BERR /*!< Bus error */
  135. #define LL_I2C_ISR_ARLO I2C_ISR_ARLO /*!< Arbitration lost */
  136. #define LL_I2C_ISR_OVR I2C_ISR_OVR /*!< Overrun/Underrun (slave mode) */
  137. #define LL_I2C_ISR_PECERR I2C_ISR_PECERR /*!< PEC Error in reception (SMBus mode) */
  138. #define LL_I2C_ISR_TIMEOUT I2C_ISR_TIMEOUT /*!< Timeout detection flag (SMBus mode) */
  139. #define LL_I2C_ISR_ALERT I2C_ISR_ALERT /*!< SMBus alert (SMBus mode) */
  140. #define LL_I2C_ISR_BUSY I2C_ISR_BUSY /*!< Bus busy */
  141. /**
  142. * @}
  143. */
  144. /** @defgroup I2C_LL_EC_IT IT Defines
  145. * @brief IT defines which can be used with LL_I2C_ReadReg and LL_I2C_WriteReg functions
  146. * @{
  147. */
  148. #define LL_I2C_CR1_TXIE I2C_CR1_TXIE /*!< TX Interrupt enable */
  149. #define LL_I2C_CR1_RXIE I2C_CR1_RXIE /*!< RX Interrupt enable */
  150. #define LL_I2C_CR1_ADDRIE I2C_CR1_ADDRIE /*!< Address match Interrupt enable (slave only) */
  151. #define LL_I2C_CR1_NACKIE I2C_CR1_NACKIE /*!< Not acknowledge received Interrupt enable */
  152. #define LL_I2C_CR1_STOPIE I2C_CR1_STOPIE /*!< STOP detection Interrupt enable */
  153. #define LL_I2C_CR1_TCIE I2C_CR1_TCIE /*!< Transfer Complete interrupt enable */
  154. #define LL_I2C_CR1_ERRIE I2C_CR1_ERRIE /*!< Error interrupts enable */
  155. /**
  156. * @}
  157. */
  158. /** @defgroup I2C_LL_EC_PERIPHERAL_MODE Peripheral Mode
  159. * @{
  160. */
  161. #define LL_I2C_MODE_I2C 0x00000000U /*!< I2C Master or Slave mode */
  162. #define LL_I2C_MODE_SMBUS_HOST I2C_CR1_SMBHEN /*!< SMBus Host address acknowledge */
  163. #define LL_I2C_MODE_SMBUS_DEVICE 0x00000000U /*!< SMBus Device default mode (Default address not acknowledge) */
  164. #define LL_I2C_MODE_SMBUS_DEVICE_ARP I2C_CR1_SMBDEN /*!< SMBus Device Default address acknowledge */
  165. /**
  166. * @}
  167. */
  168. /** @defgroup I2C_LL_EC_ANALOGFILTER_SELECTION Analog Filter Selection
  169. * @{
  170. */
  171. #define LL_I2C_ANALOGFILTER_ENABLE 0x00000000U /*!< Analog filter is enabled. */
  172. #define LL_I2C_ANALOGFILTER_DISABLE I2C_CR1_ANFOFF /*!< Analog filter is disabled. */
  173. /**
  174. * @}
  175. */
  176. /** @defgroup I2C_LL_EC_ADDRESSING_MODE Master Addressing Mode
  177. * @{
  178. */
  179. #define LL_I2C_ADDRESSING_MODE_7BIT 0x00000000U /*!< Master operates in 7-bit addressing mode. */
  180. #define LL_I2C_ADDRESSING_MODE_10BIT I2C_CR2_ADD10 /*!< Master operates in 10-bit addressing mode.*/
  181. /**
  182. * @}
  183. */
  184. /** @defgroup I2C_LL_EC_OWNADDRESS1 Own Address 1 Length
  185. * @{
  186. */
  187. #define LL_I2C_OWNADDRESS1_7BIT 0x00000000U /*!< Own address 1 is a 7-bit address. */
  188. #define LL_I2C_OWNADDRESS1_10BIT I2C_OAR1_OA1MODE /*!< Own address 1 is a 10-bit address.*/
  189. /**
  190. * @}
  191. */
  192. /** @defgroup I2C_LL_EC_OWNADDRESS2 Own Address 2 Masks
  193. * @{
  194. */
  195. #define LL_I2C_OWNADDRESS2_NOMASK I2C_OAR2_OA2NOMASK /*!< Own Address2 No mask. */
  196. #define LL_I2C_OWNADDRESS2_MASK01 I2C_OAR2_OA2MASK01 /*!< Only Address2 bits[7:2] are compared. */
  197. #define LL_I2C_OWNADDRESS2_MASK02 I2C_OAR2_OA2MASK02 /*!< Only Address2 bits[7:3] are compared. */
  198. #define LL_I2C_OWNADDRESS2_MASK03 I2C_OAR2_OA2MASK03 /*!< Only Address2 bits[7:4] are compared. */
  199. #define LL_I2C_OWNADDRESS2_MASK04 I2C_OAR2_OA2MASK04 /*!< Only Address2 bits[7:5] are compared. */
  200. #define LL_I2C_OWNADDRESS2_MASK05 I2C_OAR2_OA2MASK05 /*!< Only Address2 bits[7:6] are compared. */
  201. #define LL_I2C_OWNADDRESS2_MASK06 I2C_OAR2_OA2MASK06 /*!< Only Address2 bits[7] are compared. */
  202. #define LL_I2C_OWNADDRESS2_MASK07 I2C_OAR2_OA2MASK07 /*!< No comparison is done. All Address2 are acknowledged.*/
  203. /**
  204. * @}
  205. */
  206. /** @defgroup I2C_LL_EC_I2C_ACKNOWLEDGE Acknowledge Generation
  207. * @{
  208. */
  209. #define LL_I2C_ACK 0x00000000U /*!< ACK is sent after current received byte. */
  210. #define LL_I2C_NACK I2C_CR2_NACK /*!< NACK is sent after current received byte.*/
  211. /**
  212. * @}
  213. */
  214. /** @defgroup I2C_LL_EC_ADDRSLAVE Slave Address Length
  215. * @{
  216. */
  217. #define LL_I2C_ADDRSLAVE_7BIT 0x00000000U /*!< Slave Address in 7-bit. */
  218. #define LL_I2C_ADDRSLAVE_10BIT I2C_CR2_ADD10 /*!< Slave Address in 10-bit.*/
  219. /**
  220. * @}
  221. */
  222. /** @defgroup I2C_LL_EC_REQUEST Transfer Request Direction
  223. * @{
  224. */
  225. #define LL_I2C_REQUEST_WRITE 0x00000000U /*!< Master request a write transfer. */
  226. #define LL_I2C_REQUEST_READ I2C_CR2_RD_WRN /*!< Master request a read transfer. */
  227. /**
  228. * @}
  229. */
  230. /** @defgroup I2C_LL_EC_MODE Transfer End Mode
  231. * @{
  232. */
  233. #define LL_I2C_MODE_RELOAD I2C_CR2_RELOAD /*!< Enable I2C Reload mode. */
  234. #define LL_I2C_MODE_AUTOEND I2C_CR2_AUTOEND /*!< Enable I2C Automatic end mode with no HW PEC comparison. */
  235. #define LL_I2C_MODE_SOFTEND 0x00000000U /*!< Enable I2C Software end mode with no HW PEC comparison. */
  236. #define LL_I2C_MODE_SMBUS_RELOAD LL_I2C_MODE_RELOAD /*!< Enable SMBUS Automatic end mode with HW PEC comparison. */
  237. #define LL_I2C_MODE_SMBUS_AUTOEND_NO_PEC LL_I2C_MODE_AUTOEND /*!< Enable SMBUS Automatic end mode with HW PEC comparison. */
  238. #define LL_I2C_MODE_SMBUS_SOFTEND_NO_PEC LL_I2C_MODE_SOFTEND /*!< Enable SMBUS Software end mode with HW PEC comparison. */
  239. #define LL_I2C_MODE_SMBUS_AUTOEND_WITH_PEC (uint32_t)(LL_I2C_MODE_AUTOEND | I2C_CR2_PECBYTE) /*!< Enable SMBUS Automatic end mode with HW PEC comparison. */
  240. #define LL_I2C_MODE_SMBUS_SOFTEND_WITH_PEC (uint32_t)(LL_I2C_MODE_SOFTEND | I2C_CR2_PECBYTE) /*!< Enable SMBUS Software end mode with HW PEC comparison. */
  241. /**
  242. * @}
  243. */
  244. /** @defgroup I2C_LL_EC_GENERATE Start And Stop Generation
  245. * @{
  246. */
  247. #define LL_I2C_GENERATE_NOSTARTSTOP 0x00000000U /*!< Don't Generate Stop and Start condition. */
  248. #define LL_I2C_GENERATE_STOP (uint32_t)(0x80000000U | I2C_CR2_STOP) /*!< Generate Stop condition (Size should be set to 0). */
  249. #define LL_I2C_GENERATE_START_READ (uint32_t)(0x80000000U | I2C_CR2_START | I2C_CR2_RD_WRN) /*!< Generate Start for read request. */
  250. #define LL_I2C_GENERATE_START_WRITE (uint32_t)(0x80000000U | I2C_CR2_START) /*!< Generate Start for write request. */
  251. #define LL_I2C_GENERATE_RESTART_7BIT_READ (uint32_t)(0x80000000U | I2C_CR2_START | I2C_CR2_RD_WRN) /*!< Generate Restart for read request, slave 7Bit address. */
  252. #define LL_I2C_GENERATE_RESTART_7BIT_WRITE (uint32_t)(0x80000000U | I2C_CR2_START) /*!< Generate Restart for write request, slave 7Bit address. */
  253. #define LL_I2C_GENERATE_RESTART_10BIT_READ (uint32_t)(0x80000000U | I2C_CR2_START | I2C_CR2_RD_WRN | I2C_CR2_HEAD10R) /*!< Generate Restart for read request, slave 10Bit address. */
  254. #define LL_I2C_GENERATE_RESTART_10BIT_WRITE (uint32_t)(0x80000000U | I2C_CR2_START) /*!< Generate Restart for write request, slave 10Bit address.*/
  255. /**
  256. * @}
  257. */
  258. /** @defgroup I2C_LL_EC_DIRECTION Read Write Direction
  259. * @{
  260. */
  261. #define LL_I2C_DIRECTION_WRITE 0x00000000U /*!< Write transfer request by master, slave enters receiver mode. */
  262. #define LL_I2C_DIRECTION_READ I2C_ISR_DIR /*!< Read transfer request by master, slave enters transmitter mode.*/
  263. /**
  264. * @}
  265. */
  266. /** @defgroup I2C_LL_EC_DMA_REG_DATA DMA Register Data
  267. * @{
  268. */
  269. #define LL_I2C_DMA_REG_DATA_TRANSMIT 0x00000000U /*!< Get address of data register used for transmission */
  270. #define LL_I2C_DMA_REG_DATA_RECEIVE 0x00000001U /*!< Get address of data register used for reception */
  271. /**
  272. * @}
  273. */
  274. /** @defgroup I2C_LL_EC_SMBUS_TIMEOUTA_MODE SMBus TimeoutA Mode SCL SDA Timeout
  275. * @{
  276. */
  277. #define LL_I2C_SMBUS_TIMEOUTA_MODE_SCL_LOW 0x00000000U /*!< TimeoutA is used to detect SCL low level timeout. */
  278. #define LL_I2C_SMBUS_TIMEOUTA_MODE_SDA_SCL_HIGH I2C_TIMEOUTR_TIDLE /*!< TimeoutA is used to detect both SCL and SDA high level timeout.*/
  279. /**
  280. * @}
  281. */
  282. /** @defgroup I2C_LL_EC_SMBUS_TIMEOUT_SELECTION SMBus Timeout Selection
  283. * @{
  284. */
  285. #define LL_I2C_SMBUS_TIMEOUTA I2C_TIMEOUTR_TIMOUTEN /*!< TimeoutA enable bit */
  286. #define LL_I2C_SMBUS_TIMEOUTB I2C_TIMEOUTR_TEXTEN /*!< TimeoutB (extended clock) enable bit */
  287. #define LL_I2C_SMBUS_ALL_TIMEOUT (uint32_t)(I2C_TIMEOUTR_TIMOUTEN | I2C_TIMEOUTR_TEXTEN) /*!< TimeoutA and TimeoutB (extended clock) enable bits */
  288. /**
  289. * @}
  290. */
  291. /**
  292. * @}
  293. */
  294. /* Exported macro ------------------------------------------------------------*/
  295. /** @defgroup I2C_LL_Exported_Macros I2C Exported Macros
  296. * @{
  297. */
  298. /** @defgroup I2C_LL_EM_WRITE_READ Common Write and read registers Macros
  299. * @{
  300. */
  301. /**
  302. * @brief Write a value in I2C register
  303. * @param __INSTANCE__ I2C Instance
  304. * @param __REG__ Register to be written
  305. * @param __VALUE__ Value to be written in the register
  306. * @retval None
  307. */
  308. #define LL_I2C_WriteReg(__INSTANCE__, __REG__, __VALUE__) WRITE_REG(__INSTANCE__->__REG__, (__VALUE__))
  309. /**
  310. * @brief Read a value in I2C register
  311. * @param __INSTANCE__ I2C Instance
  312. * @param __REG__ Register to be read
  313. * @retval Register value
  314. */
  315. #define LL_I2C_ReadReg(__INSTANCE__, __REG__) READ_REG(__INSTANCE__->__REG__)
  316. /**
  317. * @}
  318. */
  319. /** @defgroup I2C_LL_EM_CONVERT_TIMINGS Convert SDA SCL timings
  320. * @{
  321. */
  322. /**
  323. * @brief Configure the SDA setup, hold time and the SCL high, low period.
  324. * @param __PRESCALER__ This parameter must be a value between Min_Data=0 and Max_Data=0xF.
  325. * @param __DATA_SETUP_TIME__ This parameter must be a value between Min_Data=0 and Max_Data=0xF. (tscldel = (SCLDEL+1)xtpresc)
  326. * @param __DATA_HOLD_TIME__ This parameter must be a value between Min_Data=0 and Max_Data=0xF. (tsdadel = SDADELxtpresc)
  327. * @param __CLOCK_HIGH_PERIOD__ This parameter must be a value between Min_Data=0 and Max_Data=0xFF. (tsclh = (SCLH+1)xtpresc)
  328. * @param __CLOCK_LOW_PERIOD__ This parameter must be a value between Min_Data=0 and Max_Data=0xFF. (tscll = (SCLL+1)xtpresc)
  329. * @retval Value between Min_Data=0 and Max_Data=0xFFFFFFFF
  330. */
  331. #define __LL_I2C_CONVERT_TIMINGS(__PRESCALER__, __DATA_SETUP_TIME__, __DATA_HOLD_TIME__, __CLOCK_HIGH_PERIOD__, __CLOCK_LOW_PERIOD__) \
  332. ((((uint32_t)(__PRESCALER__) << I2C_TIMINGR_PRESC_Pos) & I2C_TIMINGR_PRESC) | \
  333. (((uint32_t)(__DATA_SETUP_TIME__) << I2C_TIMINGR_SCLDEL_Pos) & I2C_TIMINGR_SCLDEL) | \
  334. (((uint32_t)(__DATA_HOLD_TIME__) << I2C_TIMINGR_SDADEL_Pos) & I2C_TIMINGR_SDADEL) | \
  335. (((uint32_t)(__CLOCK_HIGH_PERIOD__) << I2C_TIMINGR_SCLH_Pos) & I2C_TIMINGR_SCLH) | \
  336. (((uint32_t)(__CLOCK_LOW_PERIOD__) << I2C_TIMINGR_SCLL_Pos) & I2C_TIMINGR_SCLL))
  337. /**
  338. * @}
  339. */
  340. /**
  341. * @}
  342. */
  343. /* Exported functions --------------------------------------------------------*/
  344. /** @defgroup I2C_LL_Exported_Functions I2C Exported Functions
  345. * @{
  346. */
  347. /** @defgroup I2C_LL_EF_Configuration Configuration
  348. * @{
  349. */
  350. /**
  351. * @brief Enable I2C peripheral (PE = 1).
  352. * @rmtoll CR1 PE LL_I2C_Enable
  353. * @param I2Cx I2C Instance.
  354. * @retval None
  355. */
  356. __STATIC_INLINE void LL_I2C_Enable(I2C_TypeDef *I2Cx)
  357. {
  358. SET_BIT(I2Cx->CR1, I2C_CR1_PE);
  359. }
  360. /**
  361. * @brief Disable I2C peripheral (PE = 0).
  362. * @note When PE = 0, the I2C SCL and SDA lines are released.
  363. * Internal state machines and status bits are put back to their reset value.
  364. * When cleared, PE must be kept low for at least 3 APB clock cycles.
  365. * @rmtoll CR1 PE LL_I2C_Disable
  366. * @param I2Cx I2C Instance.
  367. * @retval None
  368. */
  369. __STATIC_INLINE void LL_I2C_Disable(I2C_TypeDef *I2Cx)
  370. {
  371. CLEAR_BIT(I2Cx->CR1, I2C_CR1_PE);
  372. }
  373. /**
  374. * @brief Check if the I2C peripheral is enabled or disabled.
  375. * @rmtoll CR1 PE LL_I2C_IsEnabled
  376. * @param I2Cx I2C Instance.
  377. * @retval State of bit (1 or 0).
  378. */
  379. __STATIC_INLINE uint32_t LL_I2C_IsEnabled(I2C_TypeDef *I2Cx)
  380. {
  381. return (READ_BIT(I2Cx->CR1, I2C_CR1_PE) == (I2C_CR1_PE));
  382. }
  383. /**
  384. * @brief Configure Noise Filters (Analog and Digital).
  385. * @note If the analog filter is also enabled, the digital filter is added to analog filter.
  386. * The filters can only be programmed when the I2C is disabled (PE = 0).
  387. * @rmtoll CR1 ANFOFF LL_I2C_ConfigFilters\n
  388. * CR1 DNF LL_I2C_ConfigFilters
  389. * @param I2Cx I2C Instance.
  390. * @param AnalogFilter This parameter can be one of the following values:
  391. * @arg @ref LL_I2C_ANALOGFILTER_ENABLE
  392. * @arg @ref LL_I2C_ANALOGFILTER_DISABLE
  393. * @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*ti2cclk).
  394. * This parameter is used to configure the digital noise filter on SDA and SCL input.
  395. * The digital filter will filter spikes with a length of up to DNF[3:0]*ti2cclk.
  396. * @retval None
  397. */
  398. __STATIC_INLINE void LL_I2C_ConfigFilters(I2C_TypeDef *I2Cx, uint32_t AnalogFilter, uint32_t DigitalFilter)
  399. {
  400. MODIFY_REG(I2Cx->CR1, I2C_CR1_ANFOFF | I2C_CR1_DNF, AnalogFilter | (DigitalFilter << I2C_CR1_DNF_Pos));
  401. }
  402. /**
  403. * @brief Configure Digital Noise Filter.
  404. * @note If the analog filter is also enabled, the digital filter is added to analog filter.
  405. * This filter can only be programmed when the I2C is disabled (PE = 0).
  406. * @rmtoll CR1 DNF LL_I2C_SetDigitalFilter
  407. * @param I2Cx I2C Instance.
  408. * @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*ti2cclk).
  409. * This parameter is used to configure the digital noise filter on SDA and SCL input.
  410. * The digital filter will filter spikes with a length of up to DNF[3:0]*ti2cclk.
  411. * @retval None
  412. */
  413. __STATIC_INLINE void LL_I2C_SetDigitalFilter(I2C_TypeDef *I2Cx, uint32_t DigitalFilter)
  414. {
  415. MODIFY_REG(I2Cx->CR1, I2C_CR1_DNF, DigitalFilter << I2C_CR1_DNF_Pos);
  416. }
  417. /**
  418. * @brief Get the current Digital Noise Filter configuration.
  419. * @rmtoll CR1 DNF LL_I2C_GetDigitalFilter
  420. * @param I2Cx I2C Instance.
  421. * @retval Value between Min_Data=0x0 and Max_Data=0xF
  422. */
  423. __STATIC_INLINE uint32_t LL_I2C_GetDigitalFilter(I2C_TypeDef *I2Cx)
  424. {
  425. return (uint32_t)(READ_BIT(I2Cx->CR1, I2C_CR1_DNF) >> I2C_CR1_DNF_Pos);
  426. }
  427. /**
  428. * @brief Enable Analog Noise Filter.
  429. * @note This filter can only be programmed when the I2C is disabled (PE = 0).
  430. * @rmtoll CR1 ANFOFF LL_I2C_EnableAnalogFilter
  431. * @param I2Cx I2C Instance.
  432. * @retval None
  433. */
  434. __STATIC_INLINE void LL_I2C_EnableAnalogFilter(I2C_TypeDef *I2Cx)
  435. {
  436. CLEAR_BIT(I2Cx->CR1, I2C_CR1_ANFOFF);
  437. }
  438. /**
  439. * @brief Disable Analog Noise Filter.
  440. * @note This filter can only be programmed when the I2C is disabled (PE = 0).
  441. * @rmtoll CR1 ANFOFF LL_I2C_DisableAnalogFilter
  442. * @param I2Cx I2C Instance.
  443. * @retval None
  444. */
  445. __STATIC_INLINE void LL_I2C_DisableAnalogFilter(I2C_TypeDef *I2Cx)
  446. {
  447. SET_BIT(I2Cx->CR1, I2C_CR1_ANFOFF);
  448. }
  449. /**
  450. * @brief Check if Analog Noise Filter is enabled or disabled.
  451. * @rmtoll CR1 ANFOFF LL_I2C_IsEnabledAnalogFilter
  452. * @param I2Cx I2C Instance.
  453. * @retval State of bit (1 or 0).
  454. */
  455. __STATIC_INLINE uint32_t LL_I2C_IsEnabledAnalogFilter(I2C_TypeDef *I2Cx)
  456. {
  457. return (READ_BIT(I2Cx->CR1, I2C_CR1_ANFOFF) != (I2C_CR1_ANFOFF));
  458. }
  459. /**
  460. * @brief Enable DMA transmission requests.
  461. * @rmtoll CR1 TXDMAEN LL_I2C_EnableDMAReq_TX
  462. * @param I2Cx I2C Instance.
  463. * @retval None
  464. */
  465. __STATIC_INLINE void LL_I2C_EnableDMAReq_TX(I2C_TypeDef *I2Cx)
  466. {
  467. SET_BIT(I2Cx->CR1, I2C_CR1_TXDMAEN);
  468. }
  469. /**
  470. * @brief Disable DMA transmission requests.
  471. * @rmtoll CR1 TXDMAEN LL_I2C_DisableDMAReq_TX
  472. * @param I2Cx I2C Instance.
  473. * @retval None
  474. */
  475. __STATIC_INLINE void LL_I2C_DisableDMAReq_TX(I2C_TypeDef *I2Cx)
  476. {
  477. CLEAR_BIT(I2Cx->CR1, I2C_CR1_TXDMAEN);
  478. }
  479. /**
  480. * @brief Check if DMA transmission requests are enabled or disabled.
  481. * @rmtoll CR1 TXDMAEN LL_I2C_IsEnabledDMAReq_TX
  482. * @param I2Cx I2C Instance.
  483. * @retval State of bit (1 or 0).
  484. */
  485. __STATIC_INLINE uint32_t LL_I2C_IsEnabledDMAReq_TX(I2C_TypeDef *I2Cx)
  486. {
  487. return (READ_BIT(I2Cx->CR1, I2C_CR1_TXDMAEN) == (I2C_CR1_TXDMAEN));
  488. }
  489. /**
  490. * @brief Enable DMA reception requests.
  491. * @rmtoll CR1 RXDMAEN LL_I2C_EnableDMAReq_RX
  492. * @param I2Cx I2C Instance.
  493. * @retval None
  494. */
  495. __STATIC_INLINE void LL_I2C_EnableDMAReq_RX(I2C_TypeDef *I2Cx)
  496. {
  497. SET_BIT(I2Cx->CR1, I2C_CR1_RXDMAEN);
  498. }
  499. /**
  500. * @brief Disable DMA reception requests.
  501. * @rmtoll CR1 RXDMAEN LL_I2C_DisableDMAReq_RX
  502. * @param I2Cx I2C Instance.
  503. * @retval None
  504. */
  505. __STATIC_INLINE void LL_I2C_DisableDMAReq_RX(I2C_TypeDef *I2Cx)
  506. {
  507. CLEAR_BIT(I2Cx->CR1, I2C_CR1_RXDMAEN);
  508. }
  509. /**
  510. * @brief Check if DMA reception requests are enabled or disabled.
  511. * @rmtoll CR1 RXDMAEN LL_I2C_IsEnabledDMAReq_RX
  512. * @param I2Cx I2C Instance.
  513. * @retval State of bit (1 or 0).
  514. */
  515. __STATIC_INLINE uint32_t LL_I2C_IsEnabledDMAReq_RX(I2C_TypeDef *I2Cx)
  516. {
  517. return (READ_BIT(I2Cx->CR1, I2C_CR1_RXDMAEN) == (I2C_CR1_RXDMAEN));
  518. }
  519. /**
  520. * @brief Get the data register address used for DMA transfer
  521. * @rmtoll TXDR TXDATA LL_I2C_DMA_GetRegAddr\n
  522. * RXDR RXDATA LL_I2C_DMA_GetRegAddr
  523. * @param I2Cx I2C Instance
  524. * @param Direction This parameter can be one of the following values:
  525. * @arg @ref LL_I2C_DMA_REG_DATA_TRANSMIT
  526. * @arg @ref LL_I2C_DMA_REG_DATA_RECEIVE
  527. * @retval Address of data register
  528. */
  529. __STATIC_INLINE uint32_t LL_I2C_DMA_GetRegAddr(I2C_TypeDef *I2Cx, uint32_t Direction)
  530. {
  531. register uint32_t data_reg_addr = 0U;
  532. if (Direction == LL_I2C_DMA_REG_DATA_TRANSMIT)
  533. {
  534. /* return address of TXDR register */
  535. data_reg_addr = (uint32_t) & (I2Cx->TXDR);
  536. }
  537. else
  538. {
  539. /* return address of RXDR register */
  540. data_reg_addr = (uint32_t) & (I2Cx->RXDR);
  541. }
  542. return data_reg_addr;
  543. }
  544. /**
  545. * @brief Enable Clock stretching.
  546. * @note This bit can only be programmed when the I2C is disabled (PE = 0).
  547. * @rmtoll CR1 NOSTRETCH LL_I2C_EnableClockStretching
  548. * @param I2Cx I2C Instance.
  549. * @retval None
  550. */
  551. __STATIC_INLINE void LL_I2C_EnableClockStretching(I2C_TypeDef *I2Cx)
  552. {
  553. CLEAR_BIT(I2Cx->CR1, I2C_CR1_NOSTRETCH);
  554. }
  555. /**
  556. * @brief Disable Clock stretching.
  557. * @note This bit can only be programmed when the I2C is disabled (PE = 0).
  558. * @rmtoll CR1 NOSTRETCH LL_I2C_DisableClockStretching
  559. * @param I2Cx I2C Instance.
  560. * @retval None
  561. */
  562. __STATIC_INLINE void LL_I2C_DisableClockStretching(I2C_TypeDef *I2Cx)
  563. {
  564. SET_BIT(I2Cx->CR1, I2C_CR1_NOSTRETCH);
  565. }
  566. /**
  567. * @brief Check if Clock stretching is enabled or disabled.
  568. * @rmtoll CR1 NOSTRETCH LL_I2C_IsEnabledClockStretching
  569. * @param I2Cx I2C Instance.
  570. * @retval State of bit (1 or 0).
  571. */
  572. __STATIC_INLINE uint32_t LL_I2C_IsEnabledClockStretching(I2C_TypeDef *I2Cx)
  573. {
  574. return (READ_BIT(I2Cx->CR1, I2C_CR1_NOSTRETCH) != (I2C_CR1_NOSTRETCH));
  575. }
  576. /**
  577. * @brief Enable hardware byte control in slave mode.
  578. * @rmtoll CR1 SBC LL_I2C_EnableSlaveByteControl
  579. * @param I2Cx I2C Instance.
  580. * @retval None
  581. */
  582. __STATIC_INLINE void LL_I2C_EnableSlaveByteControl(I2C_TypeDef *I2Cx)
  583. {
  584. SET_BIT(I2Cx->CR1, I2C_CR1_SBC);
  585. }
  586. /**
  587. * @brief Disable hardware byte control in slave mode.
  588. * @rmtoll CR1 SBC LL_I2C_DisableSlaveByteControl
  589. * @param I2Cx I2C Instance.
  590. * @retval None
  591. */
  592. __STATIC_INLINE void LL_I2C_DisableSlaveByteControl(I2C_TypeDef *I2Cx)
  593. {
  594. CLEAR_BIT(I2Cx->CR1, I2C_CR1_SBC);
  595. }
  596. /**
  597. * @brief Check if hardware byte control in slave mode is enabled or disabled.
  598. * @rmtoll CR1 SBC LL_I2C_IsEnabledSlaveByteControl
  599. * @param I2Cx I2C Instance.
  600. * @retval State of bit (1 or 0).
  601. */
  602. __STATIC_INLINE uint32_t LL_I2C_IsEnabledSlaveByteControl(I2C_TypeDef *I2Cx)
  603. {
  604. return (READ_BIT(I2Cx->CR1, I2C_CR1_SBC) == (I2C_CR1_SBC));
  605. }
  606. /**
  607. * @brief Enable General Call.
  608. * @note When enabled the Address 0x00 is ACKed.
  609. * @rmtoll CR1 GCEN LL_I2C_EnableGeneralCall
  610. * @param I2Cx I2C Instance.
  611. * @retval None
  612. */
  613. __STATIC_INLINE void LL_I2C_EnableGeneralCall(I2C_TypeDef *I2Cx)
  614. {
  615. SET_BIT(I2Cx->CR1, I2C_CR1_GCEN);
  616. }
  617. /**
  618. * @brief Disable General Call.
  619. * @note When disabled the Address 0x00 is NACKed.
  620. * @rmtoll CR1 GCEN LL_I2C_DisableGeneralCall
  621. * @param I2Cx I2C Instance.
  622. * @retval None
  623. */
  624. __STATIC_INLINE void LL_I2C_DisableGeneralCall(I2C_TypeDef *I2Cx)
  625. {
  626. CLEAR_BIT(I2Cx->CR1, I2C_CR1_GCEN);
  627. }
  628. /**
  629. * @brief Check if General Call is enabled or disabled.
  630. * @rmtoll CR1 GCEN LL_I2C_IsEnabledGeneralCall
  631. * @param I2Cx I2C Instance.
  632. * @retval State of bit (1 or 0).
  633. */
  634. __STATIC_INLINE uint32_t LL_I2C_IsEnabledGeneralCall(I2C_TypeDef *I2Cx)
  635. {
  636. return (READ_BIT(I2Cx->CR1, I2C_CR1_GCEN) == (I2C_CR1_GCEN));
  637. }
  638. /**
  639. * @brief Configure the Master to operate in 7-bit or 10-bit addressing mode.
  640. * @note Changing this bit is not allowed, when the START bit is set.
  641. * @rmtoll CR2 ADD10 LL_I2C_SetMasterAddressingMode
  642. * @param I2Cx I2C Instance.
  643. * @param AddressingMode This parameter can be one of the following values:
  644. * @arg @ref LL_I2C_ADDRESSING_MODE_7BIT
  645. * @arg @ref LL_I2C_ADDRESSING_MODE_10BIT
  646. * @retval None
  647. */
  648. __STATIC_INLINE void LL_I2C_SetMasterAddressingMode(I2C_TypeDef *I2Cx, uint32_t AddressingMode)
  649. {
  650. MODIFY_REG(I2Cx->CR2, I2C_CR2_ADD10, AddressingMode);
  651. }
  652. /**
  653. * @brief Get the Master addressing mode.
  654. * @rmtoll CR2 ADD10 LL_I2C_GetMasterAddressingMode
  655. * @param I2Cx I2C Instance.
  656. * @retval Returned value can be one of the following values:
  657. * @arg @ref LL_I2C_ADDRESSING_MODE_7BIT
  658. * @arg @ref LL_I2C_ADDRESSING_MODE_10BIT
  659. */
  660. __STATIC_INLINE uint32_t LL_I2C_GetMasterAddressingMode(I2C_TypeDef *I2Cx)
  661. {
  662. return (uint32_t)(READ_BIT(I2Cx->CR2, I2C_CR2_ADD10));
  663. }
  664. /**
  665. * @brief Set the Own Address1.
  666. * @rmtoll OAR1 OA1 LL_I2C_SetOwnAddress1\n
  667. * OAR1 OA1MODE LL_I2C_SetOwnAddress1
  668. * @param I2Cx I2C Instance.
  669. * @param OwnAddress1 This parameter must be a value between Min_Data=0 and Max_Data=0x3FF.
  670. * @param OwnAddrSize This parameter can be one of the following values:
  671. * @arg @ref LL_I2C_OWNADDRESS1_7BIT
  672. * @arg @ref LL_I2C_OWNADDRESS1_10BIT
  673. * @retval None
  674. */
  675. __STATIC_INLINE void LL_I2C_SetOwnAddress1(I2C_TypeDef *I2Cx, uint32_t OwnAddress1, uint32_t OwnAddrSize)
  676. {
  677. MODIFY_REG(I2Cx->OAR1, I2C_OAR1_OA1 | I2C_OAR1_OA1MODE, OwnAddress1 | OwnAddrSize);
  678. }
  679. /**
  680. * @brief Enable acknowledge on Own Address1 match address.
  681. * @rmtoll OAR1 OA1EN LL_I2C_EnableOwnAddress1
  682. * @param I2Cx I2C Instance.
  683. * @retval None
  684. */
  685. __STATIC_INLINE void LL_I2C_EnableOwnAddress1(I2C_TypeDef *I2Cx)
  686. {
  687. SET_BIT(I2Cx->OAR1, I2C_OAR1_OA1EN);
  688. }
  689. /**
  690. * @brief Disable acknowledge on Own Address1 match address.
  691. * @rmtoll OAR1 OA1EN LL_I2C_DisableOwnAddress1
  692. * @param I2Cx I2C Instance.
  693. * @retval None
  694. */
  695. __STATIC_INLINE void LL_I2C_DisableOwnAddress1(I2C_TypeDef *I2Cx)
  696. {
  697. CLEAR_BIT(I2Cx->OAR1, I2C_OAR1_OA1EN);
  698. }
  699. /**
  700. * @brief Check if Own Address1 acknowledge is enabled or disabled.
  701. * @rmtoll OAR1 OA1EN LL_I2C_IsEnabledOwnAddress1
  702. * @param I2Cx I2C Instance.
  703. * @retval State of bit (1 or 0).
  704. */
  705. __STATIC_INLINE uint32_t LL_I2C_IsEnabledOwnAddress1(I2C_TypeDef *I2Cx)
  706. {
  707. return (READ_BIT(I2Cx->OAR1, I2C_OAR1_OA1EN) == (I2C_OAR1_OA1EN));
  708. }
  709. /**
  710. * @brief Set the 7bits Own Address2.
  711. * @note This action has no effect if own address2 is enabled.
  712. * @rmtoll OAR2 OA2 LL_I2C_SetOwnAddress2\n
  713. * OAR2 OA2MSK LL_I2C_SetOwnAddress2
  714. * @param I2Cx I2C Instance.
  715. * @param OwnAddress2 Value between Min_Data=0 and Max_Data=0x7F.
  716. * @param OwnAddrMask This parameter can be one of the following values:
  717. * @arg @ref LL_I2C_OWNADDRESS2_NOMASK
  718. * @arg @ref LL_I2C_OWNADDRESS2_MASK01
  719. * @arg @ref LL_I2C_OWNADDRESS2_MASK02
  720. * @arg @ref LL_I2C_OWNADDRESS2_MASK03
  721. * @arg @ref LL_I2C_OWNADDRESS2_MASK04
  722. * @arg @ref LL_I2C_OWNADDRESS2_MASK05
  723. * @arg @ref LL_I2C_OWNADDRESS2_MASK06
  724. * @arg @ref LL_I2C_OWNADDRESS2_MASK07
  725. * @retval None
  726. */
  727. __STATIC_INLINE void LL_I2C_SetOwnAddress2(I2C_TypeDef *I2Cx, uint32_t OwnAddress2, uint32_t OwnAddrMask)
  728. {
  729. MODIFY_REG(I2Cx->OAR2, I2C_OAR2_OA2 | I2C_OAR2_OA2MSK, OwnAddress2 | OwnAddrMask);
  730. }
  731. /**
  732. * @brief Enable acknowledge on Own Address2 match address.
  733. * @rmtoll OAR2 OA2EN LL_I2C_EnableOwnAddress2
  734. * @param I2Cx I2C Instance.
  735. * @retval None
  736. */
  737. __STATIC_INLINE void LL_I2C_EnableOwnAddress2(I2C_TypeDef *I2Cx)
  738. {
  739. SET_BIT(I2Cx->OAR2, I2C_OAR2_OA2EN);
  740. }
  741. /**
  742. * @brief Disable acknowledge on Own Address2 match address.
  743. * @rmtoll OAR2 OA2EN LL_I2C_DisableOwnAddress2
  744. * @param I2Cx I2C Instance.
  745. * @retval None
  746. */
  747. __STATIC_INLINE void LL_I2C_DisableOwnAddress2(I2C_TypeDef *I2Cx)
  748. {
  749. CLEAR_BIT(I2Cx->OAR2, I2C_OAR2_OA2EN);
  750. }
  751. /**
  752. * @brief Check if Own Address1 acknowledge is enabled or disabled.
  753. * @rmtoll OAR2 OA2EN LL_I2C_IsEnabledOwnAddress2
  754. * @param I2Cx I2C Instance.
  755. * @retval State of bit (1 or 0).
  756. */
  757. __STATIC_INLINE uint32_t LL_I2C_IsEnabledOwnAddress2(I2C_TypeDef *I2Cx)
  758. {
  759. return (READ_BIT(I2Cx->OAR2, I2C_OAR2_OA2EN) == (I2C_OAR2_OA2EN));
  760. }
  761. /**
  762. * @brief Configure the SDA setup, hold time and the SCL high, low period.
  763. * @note This bit can only be programmed when the I2C is disabled (PE = 0).
  764. * @rmtoll TIMINGR TIMINGR LL_I2C_SetTiming
  765. * @param I2Cx I2C Instance.
  766. * @param Timing This parameter must be a value between Min_Data=0 and Max_Data=0xFFFFFFFF.
  767. * @note This parameter is computed with the STM32CubeMX Tool.
  768. * @retval None
  769. */
  770. __STATIC_INLINE void LL_I2C_SetTiming(I2C_TypeDef *I2Cx, uint32_t Timing)
  771. {
  772. WRITE_REG(I2Cx->TIMINGR, Timing);
  773. }
  774. /**
  775. * @brief Get the Timing Prescaler setting.
  776. * @rmtoll TIMINGR PRESC LL_I2C_GetTimingPrescaler
  777. * @param I2Cx I2C Instance.
  778. * @retval Value between Min_Data=0x0 and Max_Data=0xF
  779. */
  780. __STATIC_INLINE uint32_t LL_I2C_GetTimingPrescaler(I2C_TypeDef *I2Cx)
  781. {
  782. return (uint32_t)(READ_BIT(I2Cx->TIMINGR, I2C_TIMINGR_PRESC) >> I2C_TIMINGR_PRESC_Pos);
  783. }
  784. /**
  785. * @brief Get the SCL low period setting.
  786. * @rmtoll TIMINGR SCLL LL_I2C_GetClockLowPeriod
  787. * @param I2Cx I2C Instance.
  788. * @retval Value between Min_Data=0x00 and Max_Data=0xFF
  789. */
  790. __STATIC_INLINE uint32_t LL_I2C_GetClockLowPeriod(I2C_TypeDef *I2Cx)
  791. {
  792. return (uint32_t)(READ_BIT(I2Cx->TIMINGR, I2C_TIMINGR_SCLL) >> I2C_TIMINGR_SCLL_Pos);
  793. }
  794. /**
  795. * @brief Get the SCL high period setting.
  796. * @rmtoll TIMINGR SCLH LL_I2C_GetClockHighPeriod
  797. * @param I2Cx I2C Instance.
  798. * @retval Value between Min_Data=0x00 and Max_Data=0xFF
  799. */
  800. __STATIC_INLINE uint32_t LL_I2C_GetClockHighPeriod(I2C_TypeDef *I2Cx)
  801. {
  802. return (uint32_t)(READ_BIT(I2Cx->TIMINGR, I2C_TIMINGR_SCLH) >> I2C_TIMINGR_SCLH_Pos);
  803. }
  804. /**
  805. * @brief Get the SDA hold time.
  806. * @rmtoll TIMINGR SDADEL LL_I2C_GetDataHoldTime
  807. * @param I2Cx I2C Instance.
  808. * @retval Value between Min_Data=0x0 and Max_Data=0xF
  809. */
  810. __STATIC_INLINE uint32_t LL_I2C_GetDataHoldTime(I2C_TypeDef *I2Cx)
  811. {
  812. return (uint32_t)(READ_BIT(I2Cx->TIMINGR, I2C_TIMINGR_SDADEL) >> I2C_TIMINGR_SDADEL_Pos);
  813. }
  814. /**
  815. * @brief Get the SDA setup time.
  816. * @rmtoll TIMINGR SCLDEL LL_I2C_GetDataSetupTime
  817. * @param I2Cx I2C Instance.
  818. * @retval Value between Min_Data=0x0 and Max_Data=0xF
  819. */
  820. __STATIC_INLINE uint32_t LL_I2C_GetDataSetupTime(I2C_TypeDef *I2Cx)
  821. {
  822. return (uint32_t)(READ_BIT(I2Cx->TIMINGR, I2C_TIMINGR_SCLDEL) >> I2C_TIMINGR_SCLDEL_Pos);
  823. }
  824. /**
  825. * @brief Configure peripheral mode.
  826. * @note Macro @ref IS_SMBUS_ALL_INSTANCE(I2Cx) can be used to check whether or not
  827. * SMBus feature is supported by the I2Cx Instance.
  828. * @rmtoll CR1 SMBHEN LL_I2C_SetMode\n
  829. * CR1 SMBDEN LL_I2C_SetMode
  830. * @param I2Cx I2C Instance.
  831. * @param PeripheralMode This parameter can be one of the following values:
  832. * @arg @ref LL_I2C_MODE_I2C
  833. * @arg @ref LL_I2C_MODE_SMBUS_HOST
  834. * @arg @ref LL_I2C_MODE_SMBUS_DEVICE
  835. * @arg @ref LL_I2C_MODE_SMBUS_DEVICE_ARP
  836. * @retval None
  837. */
  838. __STATIC_INLINE void LL_I2C_SetMode(I2C_TypeDef *I2Cx, uint32_t PeripheralMode)
  839. {
  840. MODIFY_REG(I2Cx->CR1, I2C_CR1_SMBHEN | I2C_CR1_SMBDEN, PeripheralMode);
  841. }
  842. /**
  843. * @brief Get peripheral mode.
  844. * @note Macro @ref IS_SMBUS_ALL_INSTANCE(I2Cx) can be used to check whether or not
  845. * SMBus feature is supported by the I2Cx Instance.
  846. * @rmtoll CR1 SMBHEN LL_I2C_GetMode\n
  847. * CR1 SMBDEN LL_I2C_GetMode
  848. * @param I2Cx I2C Instance.
  849. * @retval Returned value can be one of the following values:
  850. * @arg @ref LL_I2C_MODE_I2C
  851. * @arg @ref LL_I2C_MODE_SMBUS_HOST
  852. * @arg @ref LL_I2C_MODE_SMBUS_DEVICE
  853. * @arg @ref LL_I2C_MODE_SMBUS_DEVICE_ARP
  854. */
  855. __STATIC_INLINE uint32_t LL_I2C_GetMode(I2C_TypeDef *I2Cx)
  856. {
  857. return (uint32_t)(READ_BIT(I2Cx->CR1, I2C_CR1_SMBHEN | I2C_CR1_SMBDEN));
  858. }
  859. /**
  860. * @brief Enable SMBus alert (Host or Device mode)
  861. * @note Macro @ref IS_SMBUS_ALL_INSTANCE(I2Cx) can be used to check whether or not
  862. * SMBus feature is supported by the I2Cx Instance.
  863. * @note SMBus Device mode:
  864. * - SMBus Alert pin is drived low and
  865. * Alert Response Address Header acknowledge is enabled.
  866. * SMBus Host mode:
  867. * - SMBus Alert pin management is supported.
  868. * @rmtoll CR1 ALERTEN LL_I2C_EnableSMBusAlert
  869. * @param I2Cx I2C Instance.
  870. * @retval None
  871. */
  872. __STATIC_INLINE void LL_I2C_EnableSMBusAlert(I2C_TypeDef *I2Cx)
  873. {
  874. SET_BIT(I2Cx->CR1, I2C_CR1_ALERTEN);
  875. }
  876. /**
  877. * @brief Disable SMBus alert (Host or Device mode)
  878. * @note Macro @ref IS_SMBUS_ALL_INSTANCE(I2Cx) can be used to check whether or not
  879. * SMBus feature is supported by the I2Cx Instance.
  880. * @note SMBus Device mode:
  881. * - SMBus Alert pin is not drived (can be used as a standard GPIO) and
  882. * Alert Response Address Header acknowledge is disabled.
  883. * SMBus Host mode:
  884. * - SMBus Alert pin management is not supported.
  885. * @rmtoll CR1 ALERTEN LL_I2C_DisableSMBusAlert
  886. * @param I2Cx I2C Instance.
  887. * @retval None
  888. */
  889. __STATIC_INLINE void LL_I2C_DisableSMBusAlert(I2C_TypeDef *I2Cx)
  890. {
  891. CLEAR_BIT(I2Cx->CR1, I2C_CR1_ALERTEN);
  892. }
  893. /**
  894. * @brief Check if SMBus alert (Host or Device mode) is enabled or disabled.
  895. * @note Macro @ref IS_SMBUS_ALL_INSTANCE(I2Cx) can be used to check whether or not
  896. * SMBus feature is supported by the I2Cx Instance.
  897. * @rmtoll CR1 ALERTEN LL_I2C_IsEnabledSMBusAlert
  898. * @param I2Cx I2C Instance.
  899. * @retval State of bit (1 or 0).
  900. */
  901. __STATIC_INLINE uint32_t LL_I2C_IsEnabledSMBusAlert(I2C_TypeDef *I2Cx)
  902. {
  903. return (READ_BIT(I2Cx->CR1, I2C_CR1_ALERTEN) == (I2C_CR1_ALERTEN));
  904. }
  905. /**
  906. * @brief Enable SMBus Packet Error Calculation (PEC).
  907. * @note Macro @ref IS_SMBUS_ALL_INSTANCE(I2Cx) can be used to check whether or not
  908. * SMBus feature is supported by the I2Cx Instance.
  909. * @rmtoll CR1 PECEN LL_I2C_EnableSMBusPEC
  910. * @param I2Cx I2C Instance.
  911. * @retval None
  912. */
  913. __STATIC_INLINE void LL_I2C_EnableSMBusPEC(I2C_TypeDef *I2Cx)
  914. {
  915. SET_BIT(I2Cx->CR1, I2C_CR1_PECEN);
  916. }
  917. /**
  918. * @brief Disable SMBus Packet Error Calculation (PEC).
  919. * @note Macro @ref IS_SMBUS_ALL_INSTANCE(I2Cx) can be used to check whether or not
  920. * SMBus feature is supported by the I2Cx Instance.
  921. * @rmtoll CR1 PECEN LL_I2C_DisableSMBusPEC
  922. * @param I2Cx I2C Instance.
  923. * @retval None
  924. */
  925. __STATIC_INLINE void LL_I2C_DisableSMBusPEC(I2C_TypeDef *I2Cx)
  926. {
  927. CLEAR_BIT(I2Cx->CR1, I2C_CR1_PECEN);
  928. }
  929. /**
  930. * @brief Check if SMBus Packet Error Calculation (PEC) is enabled or disabled.
  931. * @note Macro @ref IS_SMBUS_ALL_INSTANCE(I2Cx) can be used to check whether or not
  932. * SMBus feature is supported by the I2Cx Instance.
  933. * @rmtoll CR1 PECEN LL_I2C_IsEnabledSMBusPEC
  934. * @param I2Cx I2C Instance.
  935. * @retval State of bit (1 or 0).
  936. */
  937. __STATIC_INLINE uint32_t LL_I2C_IsEnabledSMBusPEC(I2C_TypeDef *I2Cx)
  938. {
  939. return (READ_BIT(I2Cx->CR1, I2C_CR1_PECEN) == (I2C_CR1_PECEN));
  940. }
  941. /**
  942. * @brief Configure the SMBus Clock Timeout.
  943. * @note Macro @ref IS_SMBUS_ALL_INSTANCE(I2Cx) can be used to check whether or not
  944. * SMBus feature is supported by the I2Cx Instance.
  945. * @note This configuration can only be programmed when associated Timeout is disabled (TimeoutA and/orTimeoutB).
  946. * @rmtoll TIMEOUTR TIMEOUTA LL_I2C_ConfigSMBusTimeout\n
  947. * TIMEOUTR TIDLE LL_I2C_ConfigSMBusTimeout\n
  948. * TIMEOUTR TIMEOUTB LL_I2C_ConfigSMBusTimeout
  949. * @param I2Cx I2C Instance.
  950. * @param TimeoutA This parameter must be a value between Min_Data=0 and Max_Data=0xFFF.
  951. * @param TimeoutAMode This parameter can be one of the following values:
  952. * @arg @ref LL_I2C_SMBUS_TIMEOUTA_MODE_SCL_LOW
  953. * @arg @ref LL_I2C_SMBUS_TIMEOUTA_MODE_SDA_SCL_HIGH
  954. * @param TimeoutB
  955. * @retval None
  956. */
  957. __STATIC_INLINE void LL_I2C_ConfigSMBusTimeout(I2C_TypeDef *I2Cx, uint32_t TimeoutA, uint32_t TimeoutAMode,
  958. uint32_t TimeoutB)
  959. {
  960. MODIFY_REG(I2Cx->TIMEOUTR, I2C_TIMEOUTR_TIMEOUTA | I2C_TIMEOUTR_TIDLE | I2C_TIMEOUTR_TIMEOUTB,
  961. TimeoutA | TimeoutAMode | (TimeoutB << I2C_TIMEOUTR_TIMEOUTB_Pos));
  962. }
  963. /**
  964. * @brief Configure the SMBus Clock TimeoutA (SCL low timeout or SCL and SDA high timeout depends on TimeoutA mode).
  965. * @note Macro @ref IS_SMBUS_ALL_INSTANCE(I2Cx) can be used to check whether or not
  966. * SMBus feature is supported by the I2Cx Instance.
  967. * @note These bits can only be programmed when TimeoutA is disabled.
  968. * @rmtoll TIMEOUTR TIMEOUTA LL_I2C_SetSMBusTimeoutA
  969. * @param I2Cx I2C Instance.
  970. * @param TimeoutA This parameter must be a value between Min_Data=0 and Max_Data=0xFFF.
  971. * @retval None
  972. */
  973. __STATIC_INLINE void LL_I2C_SetSMBusTimeoutA(I2C_TypeDef *I2Cx, uint32_t TimeoutA)
  974. {
  975. WRITE_REG(I2Cx->TIMEOUTR, TimeoutA);
  976. }
  977. /**
  978. * @brief Get the SMBus Clock TimeoutA setting.
  979. * @note Macro @ref IS_SMBUS_ALL_INSTANCE(I2Cx) can be used to check whether or not
  980. * SMBus feature is supported by the I2Cx Instance.
  981. * @rmtoll TIMEOUTR TIMEOUTA LL_I2C_GetSMBusTimeoutA
  982. * @param I2Cx I2C Instance.
  983. * @retval Value between Min_Data=0 and Max_Data=0xFFF
  984. */
  985. __STATIC_INLINE uint32_t LL_I2C_GetSMBusTimeoutA(I2C_TypeDef *I2Cx)
  986. {
  987. return (uint32_t)(READ_BIT(I2Cx->TIMEOUTR, I2C_TIMEOUTR_TIMEOUTA));
  988. }
  989. /**
  990. * @brief Set the SMBus Clock TimeoutA mode.
  991. * @note Macro @ref IS_SMBUS_ALL_INSTANCE(I2Cx) can be used to check whether or not
  992. * SMBus feature is supported by the I2Cx Instance.
  993. * @note This bit can only be programmed when TimeoutA is disabled.
  994. * @rmtoll TIMEOUTR TIDLE LL_I2C_SetSMBusTimeoutAMode
  995. * @param I2Cx I2C Instance.
  996. * @param TimeoutAMode This parameter can be one of the following values:
  997. * @arg @ref LL_I2C_SMBUS_TIMEOUTA_MODE_SCL_LOW
  998. * @arg @ref LL_I2C_SMBUS_TIMEOUTA_MODE_SDA_SCL_HIGH
  999. * @retval None
  1000. */
  1001. __STATIC_INLINE void LL_I2C_SetSMBusTimeoutAMode(I2C_TypeDef *I2Cx, uint32_t TimeoutAMode)
  1002. {
  1003. WRITE_REG(I2Cx->TIMEOUTR, TimeoutAMode);
  1004. }
  1005. /**
  1006. * @brief Get the SMBus Clock TimeoutA mode.
  1007. * @note Macro @ref IS_SMBUS_ALL_INSTANCE(I2Cx) can be used to check whether or not
  1008. * SMBus feature is supported by the I2Cx Instance.
  1009. * @rmtoll TIMEOUTR TIDLE LL_I2C_GetSMBusTimeoutAMode
  1010. * @param I2Cx I2C Instance.
  1011. * @retval Returned value can be one of the following values:
  1012. * @arg @ref LL_I2C_SMBUS_TIMEOUTA_MODE_SCL_LOW
  1013. * @arg @ref LL_I2C_SMBUS_TIMEOUTA_MODE_SDA_SCL_HIGH
  1014. */
  1015. __STATIC_INLINE uint32_t LL_I2C_GetSMBusTimeoutAMode(I2C_TypeDef *I2Cx)
  1016. {
  1017. return (uint32_t)(READ_BIT(I2Cx->TIMEOUTR, I2C_TIMEOUTR_TIDLE));
  1018. }
  1019. /**
  1020. * @brief Configure the SMBus Extended Cumulative Clock TimeoutB (Master or Slave mode).
  1021. * @note Macro @ref IS_SMBUS_ALL_INSTANCE(I2Cx) can be used to check whether or not
  1022. * SMBus feature is supported by the I2Cx Instance.
  1023. * @note These bits can only be programmed when TimeoutB is disabled.
  1024. * @rmtoll TIMEOUTR TIMEOUTB LL_I2C_SetSMBusTimeoutB
  1025. * @param I2Cx I2C Instance.
  1026. * @param TimeoutB This parameter must be a value between Min_Data=0 and Max_Data=0xFFF.
  1027. * @retval None
  1028. */
  1029. __STATIC_INLINE void LL_I2C_SetSMBusTimeoutB(I2C_TypeDef *I2Cx, uint32_t TimeoutB)
  1030. {
  1031. WRITE_REG(I2Cx->TIMEOUTR, TimeoutB << I2C_TIMEOUTR_TIMEOUTB_Pos);
  1032. }
  1033. /**
  1034. * @brief Get the SMBus Extented Cumulative Clock TimeoutB setting.
  1035. * @note Macro @ref IS_SMBUS_ALL_INSTANCE(I2Cx) can be used to check whether or not
  1036. * SMBus feature is supported by the I2Cx Instance.
  1037. * @rmtoll TIMEOUTR TIMEOUTB LL_I2C_GetSMBusTimeoutB
  1038. * @param I2Cx I2C Instance.
  1039. * @retval Value between Min_Data=0 and Max_Data=0xFFF
  1040. */
  1041. __STATIC_INLINE uint32_t LL_I2C_GetSMBusTimeoutB(I2C_TypeDef *I2Cx)
  1042. {
  1043. return (uint32_t)(READ_BIT(I2Cx->TIMEOUTR, I2C_TIMEOUTR_TIMEOUTB) >> I2C_TIMEOUTR_TIMEOUTB_Pos);
  1044. }
  1045. /**
  1046. * @brief Enable the SMBus Clock Timeout.
  1047. * @note Macro @ref IS_SMBUS_ALL_INSTANCE(I2Cx) can be used to check whether or not
  1048. * SMBus feature is supported by the I2Cx Instance.
  1049. * @rmtoll TIMEOUTR TIMOUTEN LL_I2C_EnableSMBusTimeout\n
  1050. * TIMEOUTR TEXTEN LL_I2C_EnableSMBusTimeout
  1051. * @param I2Cx I2C Instance.
  1052. * @param ClockTimeout This parameter can be one of the following values:
  1053. * @arg @ref LL_I2C_SMBUS_TIMEOUTA
  1054. * @arg @ref LL_I2C_SMBUS_TIMEOUTB
  1055. * @arg @ref LL_I2C_SMBUS_ALL_TIMEOUT
  1056. * @retval None
  1057. */
  1058. __STATIC_INLINE void LL_I2C_EnableSMBusTimeout(I2C_TypeDef *I2Cx, uint32_t ClockTimeout)
  1059. {
  1060. SET_BIT(I2Cx->TIMEOUTR, ClockTimeout);
  1061. }
  1062. /**
  1063. * @brief Disable the SMBus Clock Timeout.
  1064. * @note Macro @ref IS_SMBUS_ALL_INSTANCE(I2Cx) can be used to check whether or not
  1065. * SMBus feature is supported by the I2Cx Instance.
  1066. * @rmtoll TIMEOUTR TIMOUTEN LL_I2C_DisableSMBusTimeout\n
  1067. * TIMEOUTR TEXTEN LL_I2C_DisableSMBusTimeout
  1068. * @param I2Cx I2C Instance.
  1069. * @param ClockTimeout This parameter can be one of the following values:
  1070. * @arg @ref LL_I2C_SMBUS_TIMEOUTA
  1071. * @arg @ref LL_I2C_SMBUS_TIMEOUTB
  1072. * @arg @ref LL_I2C_SMBUS_ALL_TIMEOUT
  1073. * @retval None
  1074. */
  1075. __STATIC_INLINE void LL_I2C_DisableSMBusTimeout(I2C_TypeDef *I2Cx, uint32_t ClockTimeout)
  1076. {
  1077. CLEAR_BIT(I2Cx->TIMEOUTR, ClockTimeout);
  1078. }
  1079. /**
  1080. * @brief Check if the SMBus Clock Timeout is enabled or disabled.
  1081. * @note Macro @ref IS_SMBUS_ALL_INSTANCE(I2Cx) can be used to check whether or not
  1082. * SMBus feature is supported by the I2Cx Instance.
  1083. * @rmtoll TIMEOUTR TIMOUTEN LL_I2C_IsEnabledSMBusTimeout\n
  1084. * TIMEOUTR TEXTEN LL_I2C_IsEnabledSMBusTimeout
  1085. * @param I2Cx I2C Instance.
  1086. * @param ClockTimeout This parameter can be one of the following values:
  1087. * @arg @ref LL_I2C_SMBUS_TIMEOUTA
  1088. * @arg @ref LL_I2C_SMBUS_TIMEOUTB
  1089. * @arg @ref LL_I2C_SMBUS_ALL_TIMEOUT
  1090. * @retval State of bit (1 or 0).
  1091. */
  1092. __STATIC_INLINE uint32_t LL_I2C_IsEnabledSMBusTimeout(I2C_TypeDef *I2Cx, uint32_t ClockTimeout)
  1093. {
  1094. return (READ_BIT(I2Cx->TIMEOUTR, (I2C_TIMEOUTR_TIMOUTEN | I2C_TIMEOUTR_TEXTEN)) == (ClockTimeout));
  1095. }
  1096. /**
  1097. * @}
  1098. */
  1099. /** @defgroup I2C_LL_EF_IT_Management IT_Management
  1100. * @{
  1101. */
  1102. /**
  1103. * @brief Enable TXIS interrupt.
  1104. * @rmtoll CR1 TXIE LL_I2C_EnableIT_TX
  1105. * @param I2Cx I2C Instance.
  1106. * @retval None
  1107. */
  1108. __STATIC_INLINE void LL_I2C_EnableIT_TX(I2C_TypeDef *I2Cx)
  1109. {
  1110. SET_BIT(I2Cx->CR1, I2C_CR1_TXIE);
  1111. }
  1112. /**
  1113. * @brief Disable TXIS interrupt.
  1114. * @rmtoll CR1 TXIE LL_I2C_DisableIT_TX
  1115. * @param I2Cx I2C Instance.
  1116. * @retval None
  1117. */
  1118. __STATIC_INLINE void LL_I2C_DisableIT_TX(I2C_TypeDef *I2Cx)
  1119. {
  1120. CLEAR_BIT(I2Cx->CR1, I2C_CR1_TXIE);
  1121. }
  1122. /**
  1123. * @brief Check if the TXIS Interrupt is enabled or disabled.
  1124. * @rmtoll CR1 TXIE LL_I2C_IsEnabledIT_TX
  1125. * @param I2Cx I2C Instance.
  1126. * @retval State of bit (1 or 0).
  1127. */
  1128. __STATIC_INLINE uint32_t LL_I2C_IsEnabledIT_TX(I2C_TypeDef *I2Cx)
  1129. {
  1130. return (READ_BIT(I2Cx->CR1, I2C_CR1_TXIE) == (I2C_CR1_TXIE));
  1131. }
  1132. /**
  1133. * @brief Enable RXNE interrupt.
  1134. * @rmtoll CR1 RXIE LL_I2C_EnableIT_RX
  1135. * @param I2Cx I2C Instance.
  1136. * @retval None
  1137. */
  1138. __STATIC_INLINE void LL_I2C_EnableIT_RX(I2C_TypeDef *I2Cx)
  1139. {
  1140. SET_BIT(I2Cx->CR1, I2C_CR1_RXIE);
  1141. }
  1142. /**
  1143. * @brief Disable RXNE interrupt.
  1144. * @rmtoll CR1 RXIE LL_I2C_DisableIT_RX
  1145. * @param I2Cx I2C Instance.
  1146. * @retval None
  1147. */
  1148. __STATIC_INLINE void LL_I2C_DisableIT_RX(I2C_TypeDef *I2Cx)
  1149. {
  1150. CLEAR_BIT(I2Cx->CR1, I2C_CR1_RXIE);
  1151. }
  1152. /**
  1153. * @brief Check if the RXNE Interrupt is enabled or disabled.
  1154. * @rmtoll CR1 RXIE LL_I2C_IsEnabledIT_RX
  1155. * @param I2Cx I2C Instance.
  1156. * @retval State of bit (1 or 0).
  1157. */
  1158. __STATIC_INLINE uint32_t LL_I2C_IsEnabledIT_RX(I2C_TypeDef *I2Cx)
  1159. {
  1160. return (READ_BIT(I2Cx->CR1, I2C_CR1_RXIE) == (I2C_CR1_RXIE));
  1161. }
  1162. /**
  1163. * @brief Enable Address match interrupt (slave mode only).
  1164. * @rmtoll CR1 ADDRIE LL_I2C_EnableIT_ADDR
  1165. * @param I2Cx I2C Instance.
  1166. * @retval None
  1167. */
  1168. __STATIC_INLINE void LL_I2C_EnableIT_ADDR(I2C_TypeDef *I2Cx)
  1169. {
  1170. SET_BIT(I2Cx->CR1, I2C_CR1_ADDRIE);
  1171. }
  1172. /**
  1173. * @brief Disable Address match interrupt (slave mode only).
  1174. * @rmtoll CR1 ADDRIE LL_I2C_DisableIT_ADDR
  1175. * @param I2Cx I2C Instance.
  1176. * @retval None
  1177. */
  1178. __STATIC_INLINE void LL_I2C_DisableIT_ADDR(I2C_TypeDef *I2Cx)
  1179. {
  1180. CLEAR_BIT(I2Cx->CR1, I2C_CR1_ADDRIE);
  1181. }
  1182. /**
  1183. * @brief Check if Address match interrupt is enabled or disabled.
  1184. * @rmtoll CR1 ADDRIE LL_I2C_IsEnabledIT_ADDR
  1185. * @param I2Cx I2C Instance.
  1186. * @retval State of bit (1 or 0).
  1187. */
  1188. __STATIC_INLINE uint32_t LL_I2C_IsEnabledIT_ADDR(I2C_TypeDef *I2Cx)
  1189. {
  1190. return (READ_BIT(I2Cx->CR1, I2C_CR1_ADDRIE) == (I2C_CR1_ADDRIE));
  1191. }
  1192. /**
  1193. * @brief Enable Not acknowledge received interrupt.
  1194. * @rmtoll CR1 NACKIE LL_I2C_EnableIT_NACK
  1195. * @param I2Cx I2C Instance.
  1196. * @retval None
  1197. */
  1198. __STATIC_INLINE void LL_I2C_EnableIT_NACK(I2C_TypeDef *I2Cx)
  1199. {
  1200. SET_BIT(I2Cx->CR1, I2C_CR1_NACKIE);
  1201. }
  1202. /**
  1203. * @brief Disable Not acknowledge received interrupt.
  1204. * @rmtoll CR1 NACKIE LL_I2C_DisableIT_NACK
  1205. * @param I2Cx I2C Instance.
  1206. * @retval None
  1207. */
  1208. __STATIC_INLINE void LL_I2C_DisableIT_NACK(I2C_TypeDef *I2Cx)
  1209. {
  1210. CLEAR_BIT(I2Cx->CR1, I2C_CR1_NACKIE);
  1211. }
  1212. /**
  1213. * @brief Check if Not acknowledge received interrupt is enabled or disabled.
  1214. * @rmtoll CR1 NACKIE LL_I2C_IsEnabledIT_NACK
  1215. * @param I2Cx I2C Instance.
  1216. * @retval State of bit (1 or 0).
  1217. */
  1218. __STATIC_INLINE uint32_t LL_I2C_IsEnabledIT_NACK(I2C_TypeDef *I2Cx)
  1219. {
  1220. return (READ_BIT(I2Cx->CR1, I2C_CR1_NACKIE) == (I2C_CR1_NACKIE));
  1221. }
  1222. /**
  1223. * @brief Enable STOP detection interrupt.
  1224. * @rmtoll CR1 STOPIE LL_I2C_EnableIT_STOP
  1225. * @param I2Cx I2C Instance.
  1226. * @retval None
  1227. */
  1228. __STATIC_INLINE void LL_I2C_EnableIT_STOP(I2C_TypeDef *I2Cx)
  1229. {
  1230. SET_BIT(I2Cx->CR1, I2C_CR1_STOPIE);
  1231. }
  1232. /**
  1233. * @brief Disable STOP detection interrupt.
  1234. * @rmtoll CR1 STOPIE LL_I2C_DisableIT_STOP
  1235. * @param I2Cx I2C Instance.
  1236. * @retval None
  1237. */
  1238. __STATIC_INLINE void LL_I2C_DisableIT_STOP(I2C_TypeDef *I2Cx)
  1239. {
  1240. CLEAR_BIT(I2Cx->CR1, I2C_CR1_STOPIE);
  1241. }
  1242. /**
  1243. * @brief Check if STOP detection interrupt is enabled or disabled.
  1244. * @rmtoll CR1 STOPIE LL_I2C_IsEnabledIT_STOP
  1245. * @param I2Cx I2C Instance.
  1246. * @retval State of bit (1 or 0).
  1247. */
  1248. __STATIC_INLINE uint32_t LL_I2C_IsEnabledIT_STOP(I2C_TypeDef *I2Cx)
  1249. {
  1250. return (READ_BIT(I2Cx->CR1, I2C_CR1_STOPIE) == (I2C_CR1_STOPIE));
  1251. }
  1252. /**
  1253. * @brief Enable Transfer Complete interrupt.
  1254. * @note Any of these events will generate interrupt :
  1255. * Transfer Complete (TC)
  1256. * Transfer Complete Reload (TCR)
  1257. * @rmtoll CR1 TCIE LL_I2C_EnableIT_TC
  1258. * @param I2Cx I2C Instance.
  1259. * @retval None
  1260. */
  1261. __STATIC_INLINE void LL_I2C_EnableIT_TC(I2C_TypeDef *I2Cx)
  1262. {
  1263. SET_BIT(I2Cx->CR1, I2C_CR1_TCIE);
  1264. }
  1265. /**
  1266. * @brief Disable Transfer Complete interrupt.
  1267. * @note Any of these events will generate interrupt :
  1268. * Transfer Complete (TC)
  1269. * Transfer Complete Reload (TCR)
  1270. * @rmtoll CR1 TCIE LL_I2C_DisableIT_TC
  1271. * @param I2Cx I2C Instance.
  1272. * @retval None
  1273. */
  1274. __STATIC_INLINE void LL_I2C_DisableIT_TC(I2C_TypeDef *I2Cx)
  1275. {
  1276. CLEAR_BIT(I2Cx->CR1, I2C_CR1_TCIE);
  1277. }
  1278. /**
  1279. * @brief Check if Transfer Complete interrupt is enabled or disabled.
  1280. * @rmtoll CR1 TCIE LL_I2C_IsEnabledIT_TC
  1281. * @param I2Cx I2C Instance.
  1282. * @retval State of bit (1 or 0).
  1283. */
  1284. __STATIC_INLINE uint32_t LL_I2C_IsEnabledIT_TC(I2C_TypeDef *I2Cx)
  1285. {
  1286. return (READ_BIT(I2Cx->CR1, I2C_CR1_TCIE) == (I2C_CR1_TCIE));
  1287. }
  1288. /**
  1289. * @brief Enable Error interrupts.
  1290. * @note Macro @ref IS_SMBUS_ALL_INSTANCE(I2Cx) can be used to check whether or not
  1291. * SMBus feature is supported by the I2Cx Instance.
  1292. * @note Any of these errors will generate interrupt :
  1293. * Arbitration Loss (ARLO)
  1294. * Bus Error detection (BERR)
  1295. * Overrun/Underrun (OVR)
  1296. * SMBus Timeout detection (TIMEOUT)
  1297. * SMBus PEC error detection (PECERR)
  1298. * SMBus Alert pin event detection (ALERT)
  1299. * @rmtoll CR1 ERRIE LL_I2C_EnableIT_ERR
  1300. * @param I2Cx I2C Instance.
  1301. * @retval None
  1302. */
  1303. __STATIC_INLINE void LL_I2C_EnableIT_ERR(I2C_TypeDef *I2Cx)
  1304. {
  1305. SET_BIT(I2Cx->CR1, I2C_CR1_ERRIE);
  1306. }
  1307. /**
  1308. * @brief Disable Error interrupts.
  1309. * @note Macro @ref IS_SMBUS_ALL_INSTANCE(I2Cx) can be used to check whether or not
  1310. * SMBus feature is supported by the I2Cx Instance.
  1311. * @note Any of these errors will generate interrupt :
  1312. * Arbitration Loss (ARLO)
  1313. * Bus Error detection (BERR)
  1314. * Overrun/Underrun (OVR)
  1315. * SMBus Timeout detection (TIMEOUT)
  1316. * SMBus PEC error detection (PECERR)
  1317. * SMBus Alert pin event detection (ALERT)
  1318. * @rmtoll CR1 ERRIE LL_I2C_DisableIT_ERR
  1319. * @param I2Cx I2C Instance.
  1320. * @retval None
  1321. */
  1322. __STATIC_INLINE void LL_I2C_DisableIT_ERR(I2C_TypeDef *I2Cx)
  1323. {
  1324. CLEAR_BIT(I2Cx->CR1, I2C_CR1_ERRIE);
  1325. }
  1326. /**
  1327. * @brief Check if Error interrupts are enabled or disabled.
  1328. * @rmtoll CR1 ERRIE LL_I2C_IsEnabledIT_ERR
  1329. * @param I2Cx I2C Instance.
  1330. * @retval State of bit (1 or 0).
  1331. */
  1332. __STATIC_INLINE uint32_t LL_I2C_IsEnabledIT_ERR(I2C_TypeDef *I2Cx)
  1333. {
  1334. return (READ_BIT(I2Cx->CR1, I2C_CR1_ERRIE) == (I2C_CR1_ERRIE));
  1335. }
  1336. /**
  1337. * @}
  1338. */
  1339. /** @defgroup I2C_LL_EF_FLAG_management FLAG_management
  1340. * @{
  1341. */
  1342. /**
  1343. * @brief Indicate the status of Transmit data register empty flag.
  1344. * @note RESET: When next data is written in Transmit data register.
  1345. * SET: When Transmit data register is empty.
  1346. * @rmtoll ISR TXE LL_I2C_IsActiveFlag_TXE
  1347. * @param I2Cx I2C Instance.
  1348. * @retval State of bit (1 or 0).
  1349. */
  1350. __STATIC_INLINE uint32_t LL_I2C_IsActiveFlag_TXE(I2C_TypeDef *I2Cx)
  1351. {
  1352. return (READ_BIT(I2Cx->ISR, I2C_ISR_TXE) == (I2C_ISR_TXE));
  1353. }
  1354. /**
  1355. * @brief Indicate the status of Transmit interrupt flag.
  1356. * @note RESET: When next data is written in Transmit data register.
  1357. * SET: When Transmit data register is empty.
  1358. * @rmtoll ISR TXIS LL_I2C_IsActiveFlag_TXIS
  1359. * @param I2Cx I2C Instance.
  1360. * @retval State of bit (1 or 0).
  1361. */
  1362. __STATIC_INLINE uint32_t LL_I2C_IsActiveFlag_TXIS(I2C_TypeDef *I2Cx)
  1363. {
  1364. return (READ_BIT(I2Cx->ISR, I2C_ISR_TXIS) == (I2C_ISR_TXIS));
  1365. }
  1366. /**
  1367. * @brief Indicate the status of Receive data register not empty flag.
  1368. * @note RESET: When Receive data register is read.
  1369. * SET: When the received data is copied in Receive data register.
  1370. * @rmtoll ISR RXNE LL_I2C_IsActiveFlag_RXNE
  1371. * @param I2Cx I2C Instance.
  1372. * @retval State of bit (1 or 0).
  1373. */
  1374. __STATIC_INLINE uint32_t LL_I2C_IsActiveFlag_RXNE(I2C_TypeDef *I2Cx)
  1375. {
  1376. return (READ_BIT(I2Cx->ISR, I2C_ISR_RXNE) == (I2C_ISR_RXNE));
  1377. }
  1378. /**
  1379. * @brief Indicate the status of Address matched flag (slave mode).
  1380. * @note RESET: Clear default value.
  1381. * SET: When the received slave address matched with one of the enabled slave address.
  1382. * @rmtoll ISR ADDR LL_I2C_IsActiveFlag_ADDR
  1383. * @param I2Cx I2C Instance.
  1384. * @retval State of bit (1 or 0).
  1385. */
  1386. __STATIC_INLINE uint32_t LL_I2C_IsActiveFlag_ADDR(I2C_TypeDef *I2Cx)
  1387. {
  1388. return (READ_BIT(I2Cx->ISR, I2C_ISR_ADDR) == (I2C_ISR_ADDR));
  1389. }
  1390. /**
  1391. * @brief Indicate the status of Not Acknowledge received flag.
  1392. * @note RESET: Clear default value.
  1393. * SET: When a NACK is received after a byte transmission.
  1394. * @rmtoll ISR NACKF LL_I2C_IsActiveFlag_NACK
  1395. * @param I2Cx I2C Instance.
  1396. * @retval State of bit (1 or 0).
  1397. */
  1398. __STATIC_INLINE uint32_t LL_I2C_IsActiveFlag_NACK(I2C_TypeDef *I2Cx)
  1399. {
  1400. return (READ_BIT(I2Cx->ISR, I2C_ISR_NACKF) == (I2C_ISR_NACKF));
  1401. }
  1402. /**
  1403. * @brief Indicate the status of Stop detection flag.
  1404. * @note RESET: Clear default value.
  1405. * SET: When a Stop condition is detected.
  1406. * @rmtoll ISR STOPF LL_I2C_IsActiveFlag_STOP
  1407. * @param I2Cx I2C Instance.
  1408. * @retval State of bit (1 or 0).
  1409. */
  1410. __STATIC_INLINE uint32_t LL_I2C_IsActiveFlag_STOP(I2C_TypeDef *I2Cx)
  1411. {
  1412. return (READ_BIT(I2Cx->ISR, I2C_ISR_STOPF) == (I2C_ISR_STOPF));
  1413. }
  1414. /**
  1415. * @brief Indicate the status of Transfer complete flag (master mode).
  1416. * @note RESET: Clear default value.
  1417. * SET: When RELOAD=0, AUTOEND=0 and NBYTES date have been transferred.
  1418. * @rmtoll ISR TC LL_I2C_IsActiveFlag_TC
  1419. * @param I2Cx I2C Instance.
  1420. * @retval State of bit (1 or 0).
  1421. */
  1422. __STATIC_INLINE uint32_t LL_I2C_IsActiveFlag_TC(I2C_TypeDef *I2Cx)
  1423. {
  1424. return (READ_BIT(I2Cx->ISR, I2C_ISR_TC) == (I2C_ISR_TC));
  1425. }
  1426. /**
  1427. * @brief Indicate the status of Transfer complete flag (master mode).
  1428. * @note RESET: Clear default value.
  1429. * SET: When RELOAD=1 and NBYTES date have been transferred.
  1430. * @rmtoll ISR TCR LL_I2C_IsActiveFlag_TCR
  1431. * @param I2Cx I2C Instance.
  1432. * @retval State of bit (1 or 0).
  1433. */
  1434. __STATIC_INLINE uint32_t LL_I2C_IsActiveFlag_TCR(I2C_TypeDef *I2Cx)
  1435. {
  1436. return (READ_BIT(I2Cx->ISR, I2C_ISR_TCR) == (I2C_ISR_TCR));
  1437. }
  1438. /**
  1439. * @brief Indicate the status of Bus error flag.
  1440. * @note RESET: Clear default value.
  1441. * SET: When a misplaced Start or Stop condition is detected.
  1442. * @rmtoll ISR BERR LL_I2C_IsActiveFlag_BERR
  1443. * @param I2Cx I2C Instance.
  1444. * @retval State of bit (1 or 0).
  1445. */
  1446. __STATIC_INLINE uint32_t LL_I2C_IsActiveFlag_BERR(I2C_TypeDef *I2Cx)
  1447. {
  1448. return (READ_BIT(I2Cx->ISR, I2C_ISR_BERR) == (I2C_ISR_BERR));
  1449. }
  1450. /**
  1451. * @brief Indicate the status of Arbitration lost flag.
  1452. * @note RESET: Clear default value.
  1453. * SET: When arbitration lost.
  1454. * @rmtoll ISR ARLO LL_I2C_IsActiveFlag_ARLO
  1455. * @param I2Cx I2C Instance.
  1456. * @retval State of bit (1 or 0).
  1457. */
  1458. __STATIC_INLINE uint32_t LL_I2C_IsActiveFlag_ARLO(I2C_TypeDef *I2Cx)
  1459. {
  1460. return (READ_BIT(I2Cx->ISR, I2C_ISR_ARLO) == (I2C_ISR_ARLO));
  1461. }
  1462. /**
  1463. * @brief Indicate the status of Overrun/Underrun flag (slave mode).
  1464. * @note RESET: Clear default value.
  1465. * SET: When an overrun/underrun error occurs (Clock Stretching Disabled).
  1466. * @rmtoll ISR OVR LL_I2C_IsActiveFlag_OVR
  1467. * @param I2Cx I2C Instance.
  1468. * @retval State of bit (1 or 0).
  1469. */
  1470. __STATIC_INLINE uint32_t LL_I2C_IsActiveFlag_OVR(I2C_TypeDef *I2Cx)
  1471. {
  1472. return (READ_BIT(I2Cx->ISR, I2C_ISR_OVR) == (I2C_ISR_OVR));
  1473. }
  1474. /**
  1475. * @brief Indicate the status of SMBus PEC error flag in reception.
  1476. * @note Macro @ref IS_SMBUS_ALL_INSTANCE(I2Cx) can be used to check whether or not
  1477. * SMBus feature is supported by the I2Cx Instance.
  1478. * @note RESET: Clear default value.
  1479. * SET: When the received PEC does not match with the PEC register content.
  1480. * @rmtoll ISR PECERR LL_I2C_IsActiveSMBusFlag_PECERR
  1481. * @param I2Cx I2C Instance.
  1482. * @retval State of bit (1 or 0).
  1483. */
  1484. __STATIC_INLINE uint32_t LL_I2C_IsActiveSMBusFlag_PECERR(I2C_TypeDef *I2Cx)
  1485. {
  1486. return (READ_BIT(I2Cx->ISR, I2C_ISR_PECERR) == (I2C_ISR_PECERR));
  1487. }
  1488. /**
  1489. * @brief Indicate the status of SMBus Timeout detection flag.
  1490. * @note Macro @ref IS_SMBUS_ALL_INSTANCE(I2Cx) can be used to check whether or not
  1491. * SMBus feature is supported by the I2Cx Instance.
  1492. * @note RESET: Clear default value.
  1493. * SET: When a timeout or extended clock timeout occurs.
  1494. * @rmtoll ISR TIMEOUT LL_I2C_IsActiveSMBusFlag_TIMEOUT
  1495. * @param I2Cx I2C Instance.
  1496. * @retval State of bit (1 or 0).
  1497. */
  1498. __STATIC_INLINE uint32_t LL_I2C_IsActiveSMBusFlag_TIMEOUT(I2C_TypeDef *I2Cx)
  1499. {
  1500. return (READ_BIT(I2Cx->ISR, I2C_ISR_TIMEOUT) == (I2C_ISR_TIMEOUT));
  1501. }
  1502. /**
  1503. * @brief Indicate the status of SMBus alert flag.
  1504. * @note Macro @ref IS_SMBUS_ALL_INSTANCE(I2Cx) can be used to check whether or not
  1505. * SMBus feature is supported by the I2Cx Instance.
  1506. * @note RESET: Clear default value.
  1507. * SET: When SMBus host configuration, SMBus alert enabled and
  1508. * a falling edge event occurs on SMBA pin.
  1509. * @rmtoll ISR ALERT LL_I2C_IsActiveSMBusFlag_ALERT
  1510. * @param I2Cx I2C Instance.
  1511. * @retval State of bit (1 or 0).
  1512. */
  1513. __STATIC_INLINE uint32_t LL_I2C_IsActiveSMBusFlag_ALERT(I2C_TypeDef *I2Cx)
  1514. {
  1515. return (READ_BIT(I2Cx->ISR, I2C_ISR_ALERT) == (I2C_ISR_ALERT));
  1516. }
  1517. /**
  1518. * @brief Indicate the status of Bus Busy flag.
  1519. * @note RESET: Clear default value.
  1520. * SET: When a Start condition is detected.
  1521. * @rmtoll ISR BUSY LL_I2C_IsActiveFlag_BUSY
  1522. * @param I2Cx I2C Instance.
  1523. * @retval State of bit (1 or 0).
  1524. */
  1525. __STATIC_INLINE uint32_t LL_I2C_IsActiveFlag_BUSY(I2C_TypeDef *I2Cx)
  1526. {
  1527. return (READ_BIT(I2Cx->ISR, I2C_ISR_BUSY) == (I2C_ISR_BUSY));
  1528. }
  1529. /**
  1530. * @brief Clear Address Matched flag.
  1531. * @rmtoll ICR ADDRCF LL_I2C_ClearFlag_ADDR
  1532. * @param I2Cx I2C Instance.
  1533. * @retval None
  1534. */
  1535. __STATIC_INLINE void LL_I2C_ClearFlag_ADDR(I2C_TypeDef *I2Cx)
  1536. {
  1537. SET_BIT(I2Cx->ICR, I2C_ICR_ADDRCF);
  1538. }
  1539. /**
  1540. * @brief Clear Not Acknowledge flag.
  1541. * @rmtoll ICR NACKCF LL_I2C_ClearFlag_NACK
  1542. * @param I2Cx I2C Instance.
  1543. * @retval None
  1544. */
  1545. __STATIC_INLINE void LL_I2C_ClearFlag_NACK(I2C_TypeDef *I2Cx)
  1546. {
  1547. SET_BIT(I2Cx->ICR, I2C_ICR_NACKCF);
  1548. }
  1549. /**
  1550. * @brief Clear Stop detection flag.
  1551. * @rmtoll ICR STOPCF LL_I2C_ClearFlag_STOP
  1552. * @param I2Cx I2C Instance.
  1553. * @retval None
  1554. */
  1555. __STATIC_INLINE void LL_I2C_ClearFlag_STOP(I2C_TypeDef *I2Cx)
  1556. {
  1557. SET_BIT(I2Cx->ICR, I2C_ICR_STOPCF);
  1558. }
  1559. /**
  1560. * @brief Clear Transmit data register empty flag (TXE).
  1561. * @note This bit can be clear by software in order to flush the transmit data register (TXDR).
  1562. * @rmtoll ISR TXE LL_I2C_ClearFlag_TXE
  1563. * @param I2Cx I2C Instance.
  1564. * @retval None
  1565. */
  1566. __STATIC_INLINE void LL_I2C_ClearFlag_TXE(I2C_TypeDef *I2Cx)
  1567. {
  1568. WRITE_REG(I2Cx->ISR, I2C_ISR_TXE);
  1569. }
  1570. /**
  1571. * @brief Clear Bus error flag.
  1572. * @rmtoll ICR BERRCF LL_I2C_ClearFlag_BERR
  1573. * @param I2Cx I2C Instance.
  1574. * @retval None
  1575. */
  1576. __STATIC_INLINE void LL_I2C_ClearFlag_BERR(I2C_TypeDef *I2Cx)
  1577. {
  1578. SET_BIT(I2Cx->ICR, I2C_ICR_BERRCF);
  1579. }
  1580. /**
  1581. * @brief Clear Arbitration lost flag.
  1582. * @rmtoll ICR ARLOCF LL_I2C_ClearFlag_ARLO
  1583. * @param I2Cx I2C Instance.
  1584. * @retval None
  1585. */
  1586. __STATIC_INLINE void LL_I2C_ClearFlag_ARLO(I2C_TypeDef *I2Cx)
  1587. {
  1588. SET_BIT(I2Cx->ICR, I2C_ICR_ARLOCF);
  1589. }
  1590. /**
  1591. * @brief Clear Overrun/Underrun flag.
  1592. * @rmtoll ICR OVRCF LL_I2C_ClearFlag_OVR
  1593. * @param I2Cx I2C Instance.
  1594. * @retval None
  1595. */
  1596. __STATIC_INLINE void LL_I2C_ClearFlag_OVR(I2C_TypeDef *I2Cx)
  1597. {
  1598. SET_BIT(I2Cx->ICR, I2C_ICR_OVRCF);
  1599. }
  1600. /**
  1601. * @brief Clear SMBus PEC error flag.
  1602. * @note Macro @ref IS_SMBUS_ALL_INSTANCE(I2Cx) can be used to check whether or not
  1603. * SMBus feature is supported by the I2Cx Instance.
  1604. * @rmtoll ICR PECCF LL_I2C_ClearSMBusFlag_PECERR
  1605. * @param I2Cx I2C Instance.
  1606. * @retval None
  1607. */
  1608. __STATIC_INLINE void LL_I2C_ClearSMBusFlag_PECERR(I2C_TypeDef *I2Cx)
  1609. {
  1610. SET_BIT(I2Cx->ICR, I2C_ICR_PECCF);
  1611. }
  1612. /**
  1613. * @brief Clear SMBus Timeout detection flag.
  1614. * @note Macro @ref IS_SMBUS_ALL_INSTANCE(I2Cx) can be used to check whether or not
  1615. * SMBus feature is supported by the I2Cx Instance.
  1616. * @rmtoll ICR TIMOUTCF LL_I2C_ClearSMBusFlag_TIMEOUT
  1617. * @param I2Cx I2C Instance.
  1618. * @retval None
  1619. */
  1620. __STATIC_INLINE void LL_I2C_ClearSMBusFlag_TIMEOUT(I2C_TypeDef *I2Cx)
  1621. {
  1622. SET_BIT(I2Cx->ICR, I2C_ICR_TIMOUTCF);
  1623. }
  1624. /**
  1625. * @brief Clear SMBus Alert flag.
  1626. * @note Macro @ref IS_SMBUS_ALL_INSTANCE(I2Cx) can be used to check whether or not
  1627. * SMBus feature is supported by the I2Cx Instance.
  1628. * @rmtoll ICR ALERTCF LL_I2C_ClearSMBusFlag_ALERT
  1629. * @param I2Cx I2C Instance.
  1630. * @retval None
  1631. */
  1632. __STATIC_INLINE void LL_I2C_ClearSMBusFlag_ALERT(I2C_TypeDef *I2Cx)
  1633. {
  1634. SET_BIT(I2Cx->ICR, I2C_ICR_ALERTCF);
  1635. }
  1636. /**
  1637. * @}
  1638. */
  1639. /** @defgroup I2C_LL_EF_Data_Management Data_Management
  1640. * @{
  1641. */
  1642. /**
  1643. * @brief Enable automatic STOP condition generation (master mode).
  1644. * @note Automatic end mode : a STOP condition is automatically sent when NBYTES data are transferred.
  1645. * This bit has no effect in slave mode or when RELOAD bit is set.
  1646. * @rmtoll CR2 AUTOEND LL_I2C_EnableAutoEndMode
  1647. * @param I2Cx I2C Instance.
  1648. * @retval None
  1649. */
  1650. __STATIC_INLINE void LL_I2C_EnableAutoEndMode(I2C_TypeDef *I2Cx)
  1651. {
  1652. SET_BIT(I2Cx->CR2, I2C_CR2_AUTOEND);
  1653. }
  1654. /**
  1655. * @brief Disable automatic STOP condition generation (master mode).
  1656. * @note Software end mode : TC flag is set when NBYTES data are transferre, stretching SCL low.
  1657. * @rmtoll CR2 AUTOEND LL_I2C_DisableAutoEndMode
  1658. * @param I2Cx I2C Instance.
  1659. * @retval None
  1660. */
  1661. __STATIC_INLINE void LL_I2C_DisableAutoEndMode(I2C_TypeDef *I2Cx)
  1662. {
  1663. CLEAR_BIT(I2Cx->CR2, I2C_CR2_AUTOEND);
  1664. }
  1665. /**
  1666. * @brief Check if automatic STOP condition is enabled or disabled.
  1667. * @rmtoll CR2 AUTOEND LL_I2C_IsEnabledAutoEndMode
  1668. * @param I2Cx I2C Instance.
  1669. * @retval State of bit (1 or 0).
  1670. */
  1671. __STATIC_INLINE uint32_t LL_I2C_IsEnabledAutoEndMode(I2C_TypeDef *I2Cx)
  1672. {
  1673. return (READ_BIT(I2Cx->CR2, I2C_CR2_AUTOEND) == (I2C_CR2_AUTOEND));
  1674. }
  1675. /**
  1676. * @brief Enable reload mode (master mode).
  1677. * @note The transfer is not completed after the NBYTES data transfer, NBYTES will be reloaded when TCR flag is set.
  1678. * @rmtoll CR2 RELOAD LL_I2C_EnableReloadMode
  1679. * @param I2Cx I2C Instance.
  1680. * @retval None
  1681. */
  1682. __STATIC_INLINE void LL_I2C_EnableReloadMode(I2C_TypeDef *I2Cx)
  1683. {
  1684. SET_BIT(I2Cx->CR2, I2C_CR2_RELOAD);
  1685. }
  1686. /**
  1687. * @brief Disable reload mode (master mode).
  1688. * @note The transfer is completed after the NBYTES data transfer(STOP or RESTART will follow).
  1689. * @rmtoll CR2 RELOAD LL_I2C_DisableReloadMode
  1690. * @param I2Cx I2C Instance.
  1691. * @retval None
  1692. */
  1693. __STATIC_INLINE void LL_I2C_DisableReloadMode(I2C_TypeDef *I2Cx)
  1694. {
  1695. CLEAR_BIT(I2Cx->CR2, I2C_CR2_RELOAD);
  1696. }
  1697. /**
  1698. * @brief Check if reload mode is enabled or disabled.
  1699. * @rmtoll CR2 RELOAD LL_I2C_IsEnabledReloadMode
  1700. * @param I2Cx I2C Instance.
  1701. * @retval State of bit (1 or 0).
  1702. */
  1703. __STATIC_INLINE uint32_t LL_I2C_IsEnabledReloadMode(I2C_TypeDef *I2Cx)
  1704. {
  1705. return (READ_BIT(I2Cx->CR2, I2C_CR2_RELOAD) == (I2C_CR2_RELOAD));
  1706. }
  1707. /**
  1708. * @brief Configure the number of bytes for transfer.
  1709. * @note Changing these bits when START bit is set is not allowed.
  1710. * @rmtoll CR2 NBYTES LL_I2C_SetTransferSize
  1711. * @param I2Cx I2C Instance.
  1712. * @param TransferSize This parameter must be a value between Min_Data=0x00 and Max_Data=0xFF.
  1713. * @retval None
  1714. */
  1715. __STATIC_INLINE void LL_I2C_SetTransferSize(I2C_TypeDef *I2Cx, uint32_t TransferSize)
  1716. {
  1717. MODIFY_REG(I2Cx->CR2, I2C_CR2_NBYTES, TransferSize << I2C_CR2_NBYTES_Pos);
  1718. }
  1719. /**
  1720. * @brief Get the number of bytes configured for transfer.
  1721. * @rmtoll CR2 NBYTES LL_I2C_GetTransferSize
  1722. * @param I2Cx I2C Instance.
  1723. * @retval Value between Min_Data=0x0 and Max_Data=0xFF
  1724. */
  1725. __STATIC_INLINE uint32_t LL_I2C_GetTransferSize(I2C_TypeDef *I2Cx)
  1726. {
  1727. return (uint32_t)(READ_BIT(I2Cx->CR2, I2C_CR2_NBYTES) >> I2C_CR2_NBYTES_Pos);
  1728. }
  1729. /**
  1730. * @brief Prepare the generation of a ACKnowledge or Non ACKnowledge condition after the address receive match code or next received byte.
  1731. * @note Usage in Slave mode only.
  1732. * @rmtoll CR2 NACK LL_I2C_AcknowledgeNextData
  1733. * @param I2Cx I2C Instance.
  1734. * @param TypeAcknowledge This parameter can be one of the following values:
  1735. * @arg @ref LL_I2C_ACK
  1736. * @arg @ref LL_I2C_NACK
  1737. * @retval None
  1738. */
  1739. __STATIC_INLINE void LL_I2C_AcknowledgeNextData(I2C_TypeDef *I2Cx, uint32_t TypeAcknowledge)
  1740. {
  1741. MODIFY_REG(I2Cx->CR2, I2C_CR2_NACK, TypeAcknowledge);
  1742. }
  1743. /**
  1744. * @brief Generate a START or RESTART condition
  1745. * @note The START bit can be set even if bus is BUSY or I2C is in slave mode.
  1746. * This action has no effect when RELOAD is set.
  1747. * @rmtoll CR2 START LL_I2C_GenerateStartCondition
  1748. * @param I2Cx I2C Instance.
  1749. * @retval None
  1750. */
  1751. __STATIC_INLINE void LL_I2C_GenerateStartCondition(I2C_TypeDef *I2Cx)
  1752. {
  1753. SET_BIT(I2Cx->CR2, I2C_CR2_START);
  1754. }
  1755. /**
  1756. * @brief Generate a STOP condition after the current byte transfer (master mode).
  1757. * @rmtoll CR2 STOP LL_I2C_GenerateStopCondition
  1758. * @param I2Cx I2C Instance.
  1759. * @retval None
  1760. */
  1761. __STATIC_INLINE void LL_I2C_GenerateStopCondition(I2C_TypeDef *I2Cx)
  1762. {
  1763. SET_BIT(I2Cx->CR2, I2C_CR2_STOP);
  1764. }
  1765. /**
  1766. * @brief Enable automatic RESTART Read request condition for 10bit address header (master mode).
  1767. * @note The master sends the complete 10bit slave address read sequence :
  1768. * Start + 2 bytes 10bit address in Write direction + Restart + first 7 bits of 10bit address in Read direction.
  1769. * @rmtoll CR2 HEAD10R LL_I2C_EnableAuto10BitRead
  1770. * @param I2Cx I2C Instance.
  1771. * @retval None
  1772. */
  1773. __STATIC_INLINE void LL_I2C_EnableAuto10BitRead(I2C_TypeDef *I2Cx)
  1774. {
  1775. CLEAR_BIT(I2Cx->CR2, I2C_CR2_HEAD10R);
  1776. }
  1777. /**
  1778. * @brief Disable automatic RESTART Read request condition for 10bit address header (master mode).
  1779. * @note The master only sends the first 7 bits of 10bit address in Read direction.
  1780. * @rmtoll CR2 HEAD10R LL_I2C_DisableAuto10BitRead
  1781. * @param I2Cx I2C Instance.
  1782. * @retval None
  1783. */
  1784. __STATIC_INLINE void LL_I2C_DisableAuto10BitRead(I2C_TypeDef *I2Cx)
  1785. {
  1786. SET_BIT(I2Cx->CR2, I2C_CR2_HEAD10R);
  1787. }
  1788. /**
  1789. * @brief Check if automatic RESTART Read request condition for 10bit address header is enabled or disabled.
  1790. * @rmtoll CR2 HEAD10R LL_I2C_IsEnabledAuto10BitRead
  1791. * @param I2Cx I2C Instance.
  1792. * @retval State of bit (1 or 0).
  1793. */
  1794. __STATIC_INLINE uint32_t LL_I2C_IsEnabledAuto10BitRead(I2C_TypeDef *I2Cx)
  1795. {
  1796. return (READ_BIT(I2Cx->CR2, I2C_CR2_HEAD10R) != (I2C_CR2_HEAD10R));
  1797. }
  1798. /**
  1799. * @brief Configure the transfer direction (master mode).
  1800. * @note Changing these bits when START bit is set is not allowed.
  1801. * @rmtoll CR2 RD_WRN LL_I2C_SetTransferRequest
  1802. * @param I2Cx I2C Instance.
  1803. * @param TransferRequest This parameter can be one of the following values:
  1804. * @arg @ref LL_I2C_REQUEST_WRITE
  1805. * @arg @ref LL_I2C_REQUEST_READ
  1806. * @retval None
  1807. */
  1808. __STATIC_INLINE void LL_I2C_SetTransferRequest(I2C_TypeDef *I2Cx, uint32_t TransferRequest)
  1809. {
  1810. MODIFY_REG(I2Cx->CR2, I2C_CR2_RD_WRN, TransferRequest);
  1811. }
  1812. /**
  1813. * @brief Get the transfer direction requested (master mode).
  1814. * @rmtoll CR2 RD_WRN LL_I2C_GetTransferRequest
  1815. * @param I2Cx I2C Instance.
  1816. * @retval Returned value can be one of the following values:
  1817. * @arg @ref LL_I2C_REQUEST_WRITE
  1818. * @arg @ref LL_I2C_REQUEST_READ
  1819. */
  1820. __STATIC_INLINE uint32_t LL_I2C_GetTransferRequest(I2C_TypeDef *I2Cx)
  1821. {
  1822. return (uint32_t)(READ_BIT(I2Cx->CR2, I2C_CR2_RD_WRN));
  1823. }
  1824. /**
  1825. * @brief Configure the slave address for transfer (master mode).
  1826. * @note Changing these bits when START bit is set is not allowed.
  1827. * @rmtoll CR2 SADD LL_I2C_SetSlaveAddr
  1828. * @param I2Cx I2C Instance.
  1829. * @param SlaveAddr This parameter must be a value between Min_Data=0x00 and Max_Data=0x3F.
  1830. * @retval None
  1831. */
  1832. __STATIC_INLINE void LL_I2C_SetSlaveAddr(I2C_TypeDef *I2Cx, uint32_t SlaveAddr)
  1833. {
  1834. MODIFY_REG(I2Cx->CR2, I2C_CR2_SADD, SlaveAddr);
  1835. }
  1836. /**
  1837. * @brief Get the slave address programmed for transfer.
  1838. * @rmtoll CR2 SADD LL_I2C_GetSlaveAddr
  1839. * @param I2Cx I2C Instance.
  1840. * @retval Value between Min_Data=0x0 and Max_Data=0x3F
  1841. */
  1842. __STATIC_INLINE uint32_t LL_I2C_GetSlaveAddr(I2C_TypeDef *I2Cx)
  1843. {
  1844. return (uint32_t)(READ_BIT(I2Cx->CR2, I2C_CR2_SADD));
  1845. }
  1846. /**
  1847. * @brief Handles I2Cx communication when starting transfer or during transfer (TC or TCR flag are set).
  1848. * @rmtoll CR2 SADD LL_I2C_HandleTransfer\n
  1849. * CR2 ADD10 LL_I2C_HandleTransfer\n
  1850. * CR2 RD_WRN LL_I2C_HandleTransfer\n
  1851. * CR2 START LL_I2C_HandleTransfer\n
  1852. * CR2 STOP LL_I2C_HandleTransfer\n
  1853. * CR2 RELOAD LL_I2C_HandleTransfer\n
  1854. * CR2 NBYTES LL_I2C_HandleTransfer\n
  1855. * CR2 AUTOEND LL_I2C_HandleTransfer\n
  1856. * CR2 HEAD10R LL_I2C_HandleTransfer
  1857. * @param I2Cx I2C Instance.
  1858. * @param SlaveAddr Specifies the slave address to be programmed.
  1859. * @param SlaveAddrSize This parameter can be one of the following values:
  1860. * @arg @ref LL_I2C_ADDRSLAVE_7BIT
  1861. * @arg @ref LL_I2C_ADDRSLAVE_10BIT
  1862. * @param TransferSize Specifies the number of bytes to be programmed.
  1863. * This parameter must be a value between Min_Data=0 and Max_Data=255.
  1864. * @param EndMode This parameter can be one of the following values:
  1865. * @arg @ref LL_I2C_MODE_RELOAD
  1866. * @arg @ref LL_I2C_MODE_AUTOEND
  1867. * @arg @ref LL_I2C_MODE_SOFTEND
  1868. * @arg @ref LL_I2C_MODE_SMBUS_RELOAD
  1869. * @arg @ref LL_I2C_MODE_SMBUS_AUTOEND_NO_PEC
  1870. * @arg @ref LL_I2C_MODE_SMBUS_SOFTEND_NO_PEC
  1871. * @arg @ref LL_I2C_MODE_SMBUS_AUTOEND_WITH_PEC
  1872. * @arg @ref LL_I2C_MODE_SMBUS_SOFTEND_WITH_PEC
  1873. * @param Request This parameter can be one of the following values:
  1874. * @arg @ref LL_I2C_GENERATE_NOSTARTSTOP
  1875. * @arg @ref LL_I2C_GENERATE_STOP
  1876. * @arg @ref LL_I2C_GENERATE_START_READ
  1877. * @arg @ref LL_I2C_GENERATE_START_WRITE
  1878. * @arg @ref LL_I2C_GENERATE_RESTART_7BIT_READ
  1879. * @arg @ref LL_I2C_GENERATE_RESTART_7BIT_WRITE
  1880. * @arg @ref LL_I2C_GENERATE_RESTART_10BIT_READ
  1881. * @arg @ref LL_I2C_GENERATE_RESTART_10BIT_WRITE
  1882. * @retval None
  1883. */
  1884. __STATIC_INLINE void LL_I2C_HandleTransfer(I2C_TypeDef *I2Cx, uint32_t SlaveAddr, uint32_t SlaveAddrSize,
  1885. uint32_t TransferSize, uint32_t EndMode, uint32_t Request)
  1886. {
  1887. MODIFY_REG(I2Cx->CR2, I2C_CR2_SADD | I2C_CR2_ADD10 | (I2C_CR2_RD_WRN & (uint32_t)(Request >> (31U - I2C_CR2_RD_WRN_Pos))) | I2C_CR2_START | I2C_CR2_STOP | I2C_CR2_RELOAD |
  1888. I2C_CR2_NBYTES | I2C_CR2_AUTOEND | I2C_CR2_HEAD10R,
  1889. SlaveAddr | SlaveAddrSize | TransferSize << I2C_CR2_NBYTES_Pos | EndMode | Request);
  1890. }
  1891. /**
  1892. * @brief Indicate the value of transfer direction (slave mode).
  1893. * @note RESET: Write transfer, Slave enters in receiver mode.
  1894. * SET: Read transfer, Slave enters in transmitter mode.
  1895. * @rmtoll ISR DIR LL_I2C_GetTransferDirection
  1896. * @param I2Cx I2C Instance.
  1897. * @retval Returned value can be one of the following values:
  1898. * @arg @ref LL_I2C_DIRECTION_WRITE
  1899. * @arg @ref LL_I2C_DIRECTION_READ
  1900. */
  1901. __STATIC_INLINE uint32_t LL_I2C_GetTransferDirection(I2C_TypeDef *I2Cx)
  1902. {
  1903. return (uint32_t)(READ_BIT(I2Cx->ISR, I2C_ISR_DIR));
  1904. }
  1905. /**
  1906. * @brief Return the slave matched address.
  1907. * @rmtoll ISR ADDCODE LL_I2C_GetAddressMatchCode
  1908. * @param I2Cx I2C Instance.
  1909. * @retval Value between Min_Data=0x00 and Max_Data=0x3F
  1910. */
  1911. __STATIC_INLINE uint32_t LL_I2C_GetAddressMatchCode(I2C_TypeDef *I2Cx)
  1912. {
  1913. return (uint32_t)(READ_BIT(I2Cx->ISR, I2C_ISR_ADDCODE) >> I2C_ISR_ADDCODE_Pos << 1);
  1914. }
  1915. /**
  1916. * @brief Enable internal comparison of the SMBus Packet Error byte (transmission or reception mode).
  1917. * @note Macro @ref IS_SMBUS_ALL_INSTANCE(I2Cx) can be used to check whether or not
  1918. * SMBus feature is supported by the I2Cx Instance.
  1919. * @note This feature is cleared by hardware when the PEC byte is transferred, or when a STOP condition or an Address Matched is received.
  1920. * This bit has no effect when RELOAD bit is set.
  1921. * This bit has no effect in device mode when SBC bit is not set.
  1922. * @rmtoll CR2 PECBYTE LL_I2C_EnableSMBusPECCompare
  1923. * @param I2Cx I2C Instance.
  1924. * @retval None
  1925. */
  1926. __STATIC_INLINE void LL_I2C_EnableSMBusPECCompare(I2C_TypeDef *I2Cx)
  1927. {
  1928. SET_BIT(I2Cx->CR2, I2C_CR2_PECBYTE);
  1929. }
  1930. /**
  1931. * @brief Check if the SMBus Packet Error byte internal comparison is requested or not.
  1932. * @note Macro @ref IS_SMBUS_ALL_INSTANCE(I2Cx) can be used to check whether or not
  1933. * SMBus feature is supported by the I2Cx Instance.
  1934. * @rmtoll CR2 PECBYTE LL_I2C_IsEnabledSMBusPECCompare
  1935. * @param I2Cx I2C Instance.
  1936. * @retval State of bit (1 or 0).
  1937. */
  1938. __STATIC_INLINE uint32_t LL_I2C_IsEnabledSMBusPECCompare(I2C_TypeDef *I2Cx)
  1939. {
  1940. return (READ_BIT(I2Cx->CR2, I2C_CR2_PECBYTE) == (I2C_CR2_PECBYTE));
  1941. }
  1942. /**
  1943. * @brief Get the SMBus Packet Error byte calculated.
  1944. * @note Macro @ref IS_SMBUS_ALL_INSTANCE(I2Cx) can be used to check whether or not
  1945. * SMBus feature is supported by the I2Cx Instance.
  1946. * @rmtoll PECR PEC LL_I2C_GetSMBusPEC
  1947. * @param I2Cx I2C Instance.
  1948. * @retval Value between Min_Data=0x00 and Max_Data=0xFF
  1949. */
  1950. __STATIC_INLINE uint32_t LL_I2C_GetSMBusPEC(I2C_TypeDef *I2Cx)
  1951. {
  1952. return (uint32_t)(READ_BIT(I2Cx->PECR, I2C_PECR_PEC));
  1953. }
  1954. /**
  1955. * @brief Read Receive Data register.
  1956. * @rmtoll RXDR RXDATA LL_I2C_ReceiveData8
  1957. * @param I2Cx I2C Instance.
  1958. * @retval Value between Min_Data=0x00 and Max_Data=0xFF
  1959. */
  1960. __STATIC_INLINE uint8_t LL_I2C_ReceiveData8(I2C_TypeDef *I2Cx)
  1961. {
  1962. return (uint8_t)(READ_BIT(I2Cx->RXDR, I2C_RXDR_RXDATA));
  1963. }
  1964. /**
  1965. * @brief Write in Transmit Data Register .
  1966. * @rmtoll TXDR TXDATA LL_I2C_TransmitData8
  1967. * @param I2Cx I2C Instance.
  1968. * @param Data Value between Min_Data=0x00 and Max_Data=0xFF
  1969. * @retval None
  1970. */
  1971. __STATIC_INLINE void LL_I2C_TransmitData8(I2C_TypeDef *I2Cx, uint8_t Data)
  1972. {
  1973. WRITE_REG(I2Cx->TXDR, Data);
  1974. }
  1975. /**
  1976. * @}
  1977. */
  1978. #if defined(USE_FULL_LL_DRIVER)
  1979. /** @defgroup I2C_LL_EF_Init Initialization and de-initialization functions
  1980. * @{
  1981. */
  1982. uint32_t LL_I2C_Init(I2C_TypeDef *I2Cx, LL_I2C_InitTypeDef *I2C_InitStruct);
  1983. uint32_t LL_I2C_DeInit(I2C_TypeDef *I2Cx);
  1984. void LL_I2C_StructInit(LL_I2C_InitTypeDef *I2C_InitStruct);
  1985. /**
  1986. * @}
  1987. */
  1988. #endif /* USE_FULL_LL_DRIVER */
  1989. /**
  1990. * @}
  1991. */
  1992. /**
  1993. * @}
  1994. */
  1995. #endif /* I2C1 || I2C2 || I2C3 || I2C4 */
  1996. /**
  1997. * @}
  1998. */
  1999. #ifdef __cplusplus
  2000. }
  2001. #endif
  2002. #endif /* __STM32F7xx_LL_I2C_H */
  2003. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/