stm32f4xx_ll_fmpi2c.h 84 KB

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