tae32f53xx_ll_i2c.h 86 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511
  1. /**
  2. ******************************************************************************
  3. * @file tae32f53xx_ll_i2c.h
  4. * @author MCD Application Team
  5. * @brief Header file for I2C LL module.
  6. *
  7. ******************************************************************************
  8. * @attention
  9. *
  10. * <h2><center>&copy; Copyright (c) 2020 Tai-Action.
  11. * All rights reserved.</center></h2>
  12. *
  13. * This software is licensed by Tai-Action under BSD 3-Clause license,
  14. * the "License"; You may not use this file except in compliance with the
  15. * License. You may obtain a copy of the License at:
  16. * opensource.org/licenses/BSD-3-Clause
  17. *
  18. ******************************************************************************
  19. */
  20. /* Define to prevent recursive inclusion -------------------------------------*/
  21. #ifndef _TMF5XXX_LL_I2C_H_
  22. #define _TMF5XXX_LL_I2C_H_
  23. #ifdef __cplusplus
  24. extern "C" {
  25. #endif /* __cplusplus */
  26. /* Includes ------------------------------------------------------------------*/
  27. #include "tae32f53xx_ll_def.h"
  28. #ifdef LL_DMA_MODULE_ENABLED
  29. #include "tae32f53xx_ll_dma.h"
  30. #endif
  31. /** @addtogroup TAE32F53xx_LL_Driver
  32. * @{
  33. */
  34. /** @addtogroup I2C_LL
  35. * @{
  36. */
  37. /* Exported constants --------------------------------------------------------*/
  38. /** @defgroup I2C_LL_Exported_Constants I2C LL Exported Constants
  39. * @brief I2C LL Exported Constants
  40. * @{
  41. */
  42. /**
  43. * @brief I2C SS SPEED Max Macro Define
  44. */
  45. #define I2C_SS_SPEED_MAX (100000UL)
  46. /**
  47. * @brief I2C FS SPEED Max Macro Define
  48. */
  49. #define I2C_FS_SPEED_MAX (400000UL)
  50. /**
  51. * @brief I2C FS PLUS SPEED Max Macro Define
  52. */
  53. #define I2C_FS_PLUS_SPEED_MAX (1000000UL)
  54. /**
  55. * @brief I2C HS SPEED Max Macro Define
  56. */
  57. #define I2C_HS_SPEED_MAX (3400000UL)
  58. /**
  59. * @brief I2C FIFO Depth Define
  60. */
  61. #define I2C_FIFO_DEPTH (16)
  62. /**
  63. * @}
  64. */
  65. /* Exported macro ------------------------------------------------------------*/
  66. /** @defgroup I2C_LL_Exported_Macros I2C LL Exported Macros
  67. * @brief I2C LL Exported Macros
  68. * @{
  69. */
  70. /**
  71. * @brief I2C SMBUS Persistant Slave Address Enable
  72. * @param __I2C__ Specifies I2C peripheral
  73. * @return None
  74. */
  75. #define __LL_I2C_SMBUS_SlvPersistant_En(__I2C__) SET_BIT((__I2C__)->CON, I2C_SMBUS_PST_SLV_ADDR_EN_Msk)
  76. /**
  77. * @brief I2C SMBUS Persistant Slave Address Disable
  78. * @param __I2C__ Specifies I2C peripheral
  79. * @return None
  80. */
  81. #define __LL_I2C_SMBUS_SlvPersistant_Dis(__I2C__) CLEAR_BIT((__I2C__)->CON, I2C_SMBUS_PST_SLV_ADDR_EN_Msk)
  82. /**
  83. * @brief I2C SMBUS ARP Enable
  84. * @param __I2C__ Specifies I2C peripheral
  85. * @return None
  86. */
  87. #define __LL_I2C_SMBUS_ARP_En(__I2C__) SET_BIT((__I2C__)->CON, I2C_SMBUS_ARP_EN_Msk)
  88. /**
  89. * @brief I2C SMBUS ARP Disable
  90. * @param __I2C__ Specifies I2C peripheral
  91. * @return None
  92. */
  93. #define __LL_I2C_SMBUS_ARP_Dis(__I2C__) CLEAR_BIT((__I2C__)->CON, I2C_SMBUS_ARP_EN_Msk)
  94. /**
  95. * @brief I2C SMBUS Slave Quick Cmd Enable
  96. * @param __I2C__ Specifies I2C peripheral
  97. * @return None
  98. */
  99. #define __LL_I2C_SMBUS_SlvQuickCmd_En(__I2C__) SET_BIT((__I2C__)->CON, I2C_SMBUS_SLV_QUICK_CMD_EN_Msk)
  100. /**
  101. * @brief I2C SMBUS Slave Quick Cmd Disable
  102. * @param __I2C__ Specifies I2C peripheral
  103. * @return None
  104. */
  105. #define __LL_I2C_SMBUS_SlvQuickCmd_Dis(__I2C__) CLEAR_BIT((__I2C__)->CON, I2C_SMBUS_SLV_QUICK_CMD_EN_Msk)
  106. /**
  107. * @brief I2C Optional SAR Control Set
  108. * @param __I2C__ Specifies I2C peripheral
  109. * @return None
  110. */
  111. #define __LL_I2C_OptionalSarCtrl_Set(__I2C__) SET_BIT((__I2C__)->CON, I2C_OPTIONAL_SAR_CTRL_Msk)
  112. /**
  113. * @brief I2C Master Bus Clear Feature Enable
  114. * @param __I2C__ Specifies I2C peripheral
  115. * @return None
  116. */
  117. #define __LL_I2C_MST_BusClrFeature_En(__I2C__) SET_BIT((__I2C__)->CON, I2C_BUS_CLEAR_FEATURE_CTRL_Msk)
  118. /**
  119. * @brief I2C Master Bus Clear Feature Disable
  120. * @param __I2C__ Specifies I2C peripheral
  121. * @return None
  122. */
  123. #define __LL_I2C_MST_BusClrFeature_Dis(__I2C__) CLEAR_BIT((__I2C__)->CON, I2C_BUS_CLEAR_FEATURE_CTRL_Msk)
  124. /**
  125. * @brief I2C Stop Detect If Master Active Set
  126. * @param __I2C__ Specifies I2C peripheral
  127. * @return None
  128. */
  129. #define __LL_I2C_MST_StopDetIfActive_Set(__I2C__) SET_BIT((__I2C__)->CON, I2C_STOP_DET_IF_MASTER_ACT_Msk)
  130. /**
  131. * @brief I2C Stop Detect If Master Active Clear
  132. * @param __I2C__ Specifies I2C peripheral
  133. * @return None
  134. */
  135. #define __LL_I2C_MST_StopDetIfActive_Clr(__I2C__) CLEAR_BIT((__I2C__)->CON, I2C_STOP_DET_IF_MASTER_ACT_Msk)
  136. /**
  137. * @brief I2C RX FIFO Full Hold Enable
  138. * @param __I2C__ Specifies I2C peripheral
  139. * @return None
  140. */
  141. #define __LL_I2C_RxFIFOFullHold_En(__I2C__) SET_BIT((__I2C__)->CON, I2C_RX_FIFO_FULL_HLD_CTRL_Msk)
  142. /**
  143. * @brief I2C RX FIFO Full Hold Disable
  144. * @param __I2C__ Specifies I2C peripheral
  145. * @return None
  146. */
  147. #define __LL_I2C_RxFIFOFullHold_Dis(__I2C__) CLEAR_BIT((__I2C__)->CON, I2C_RX_FIFO_FULL_HLD_CTRL_Msk)
  148. /**
  149. * @brief I2C TX Empty Control Set
  150. * @param __I2C__ Specifies I2C peripheral
  151. * @return None
  152. */
  153. #define __LL_I2C_TxEmptyCtrl_Set(__I2C__) SET_BIT((__I2C__)->CON, I2C_TX_EMPTY_CTRL_Msk)
  154. /**
  155. * @brief I2C TX Empty Control Clear
  156. * @param __I2C__ Specifies I2C peripheral
  157. * @return None
  158. */
  159. #define __LL_I2C_TxEmptyCtrl_Clr(__I2C__) CLEAR_BIT((__I2C__)->CON, I2C_TX_EMPTY_CTRL_Msk)
  160. /**
  161. * @brief I2C Slave Stop Detect If Addressed Set
  162. * @param __I2C__ Specifies I2C peripheral
  163. * @return None
  164. */
  165. #define __LL_I2C_SLV_StopDetIfAddressed_Set(__I2C__) SET_BIT((__I2C__)->CON, I2C_STOP_DET_IFADDRESSED_Msk)
  166. /**
  167. * @brief I2C Slave Stop Detect If Addressed Clear
  168. * @param __I2C__ Specifies I2C peripheral
  169. * @return None
  170. */
  171. #define __LL_I2C_SLV_StopDetIfAddressed_Clr(__I2C__) CLEAR_BIT((__I2C__)->CON, I2C_STOP_DET_IFADDRESSED_Msk)
  172. /**
  173. * @brief I2C Slave Mode Enable
  174. * @param __I2C__ Specifies I2C peripheral
  175. * @return None
  176. */
  177. #define __LL_I2C_SLAVE_Mode_En(__I2C__) CLEAR_BIT((__I2C__)->CON, I2C_SLAVE_DISABLE_Msk)
  178. /**
  179. * @brief I2C Slave Mode Disable
  180. * @param __I2C__ Specifies I2C peripheral
  181. * @return None
  182. */
  183. #define __LL_I2C_SLAVE_Mode_Dis(__I2C__) SET_BIT((__I2C__)->CON, I2C_SLAVE_DISABLE_Msk)
  184. /**
  185. * @brief I2C Master Restart Enable
  186. * @param __I2C__ Specifies I2C peripheral
  187. * @return None
  188. */
  189. #define __LL_I2C_MST_Restart_En(__I2C__) SET_BIT((__I2C__)->CON, I2C_RESTART_EN_Msk)
  190. /**
  191. * @brief I2C Master Restart Disable
  192. * @param __I2C__ Specifies I2C peripheral
  193. * @return None
  194. */
  195. #define __LL_I2C_MST_Restart_Dis(__I2C__) CLEAR_BIT((__I2C__)->CON, I2C_RESTART_EN_Msk)
  196. /**
  197. * @brief I2C Master 7bit Address Mode Set
  198. * @param __I2C__ Specifies I2C peripheral
  199. * @return None
  200. */
  201. #define __LL_I2C_MST_7bAddr_Set(__I2C__) CLEAR_BIT((__I2C__)->CON, I2C_10BITADDR_MASTER_Msk)
  202. /**
  203. * @brief I2C Master 10bit Address Mode Set
  204. * @param __I2C__ Specifies I2C peripheral
  205. * @return None
  206. */
  207. #define __LL_I2C_MST_10bAddr_Set(__I2C__) SET_BIT((__I2C__)->CON, I2C_10BITADDR_MASTER_Msk)
  208. /**
  209. * @brief I2C Slave 7bit Address Mode Set
  210. * @param __I2C__ Specifies I2C peripheral
  211. * @return None
  212. */
  213. #define __LL_I2C_SLV_7bAddr_Set(__I2C__) CLEAR_BIT((__I2C__)->CON, I2C_10BITADDR_SLAVE_Msk)
  214. /**
  215. * @brief I2C Slave 10bit Address Mode Set
  216. * @param __I2C__ Specifies I2C peripheral
  217. * @return None
  218. */
  219. #define __LL_I2C_SLV_10bAddr_Set(__I2C__) SET_BIT((__I2C__)->CON, I2C_10BITADDR_SLAVE_Msk)
  220. /**
  221. * @brief I2C Speed Set
  222. * @param __I2C__ Specifies I2C peripheral
  223. * @param speed I2C Speed
  224. * @return None
  225. */
  226. #define __LL_I2C_Speed_Set(__I2C__, speed) MODIFY_REG((__I2C__)->CON, I2C_SPEED_Msk, speed)
  227. /**
  228. * @brief I2C Master Mode Enable
  229. * @param __I2C__ Specifies I2C peripheral
  230. * @return None
  231. */
  232. #define __LL_I2C_MASTER_Mode_En(__I2C__) SET_BIT((__I2C__)->CON, I2C_MASTER_MODE_Msk)
  233. /**
  234. * @brief I2C Master Mode Disable
  235. * @param __I2C__ Specifies I2C peripheral
  236. * @return None
  237. */
  238. #define __LL_I2C_MASTER_Mode_Dis(__I2C__) CLEAR_BIT((__I2C__)->CON, I2C_MASTER_MODE_Msk)
  239. /**
  240. * @brief I2C Master Mode is Enable or not
  241. * @param __I2C__ Specifies I2C peripheral
  242. * @retval 0 I2C isn't Master Mode
  243. * @retval 1 I2C is Master Mode
  244. */
  245. #define __LL_I2C_IsMasterMode(__I2C__) READ_BIT((__I2C__)->CON, I2C_MASTER_MODE_Msk)
  246. /**
  247. * @brief I2C TAR SMBUD Quick Cmd Set
  248. * @param __I2C__ Specifies I2C peripheral
  249. * @return None
  250. */
  251. #define __LL_I2C_TAR_SmbusQuickCmd_Set(__I2C__) SET_BIT((__I2C__)->TAR, I2C_SMBUS_QUICK_CMD_Msk)
  252. /**
  253. * @brief I2C TAR SMBUD Quick Cmd Clear
  254. * @param __I2C__ Specifies I2C peripheral
  255. * @return None
  256. */
  257. #define __LL_I2C_TAR_SmbusQuickCmd_Clr(__I2C__) CLEAR_BIT((__I2C__)->TAR, I2C_SMBUS_QUICK_CMD_Msk)
  258. /**
  259. * @brief I2C TAR Device ID Set
  260. * @param __I2C__ Specifies I2C peripheral
  261. * @return None
  262. */
  263. #define __LL_I2C_TAR_DevID_Set(__I2C__) SET_BIT((__I2C__)->TAR, I2C_TAR_DEV_ID_Msk)
  264. /**
  265. * @brief I2C TAR Device ID Clear
  266. * @param __I2C__ Specifies I2C peripheral
  267. * @return None
  268. */
  269. #define __LL_I2C_TAR_DevID_Clr(__I2C__) CLEAR_BIT((__I2C__)->TAR, I2C_TAR_DEV_ID_Msk)
  270. /**
  271. * @brief I2C TAR Master 7bit Address Set
  272. * @param __I2C__ Specifies I2C peripheral
  273. * @return None
  274. */
  275. #define __LL_I2C_TAR_MST_7bAddr_Set(__I2C__) CLEAR_BIT((__I2C__)->TAR, I2C_TAR_10BITADDR_MASTER_Msk)
  276. /**
  277. * @brief I2C TAR Master 10bit Address Set
  278. * @param __I2C__ Specifies I2C peripheral
  279. * @return None
  280. */
  281. #define __LL_I2C_TAR_MST_10bAddr_Set(__I2C__) SET_BIT((__I2C__)->TAR, I2C_TAR_10BITADDR_MASTER_Msk)
  282. /**
  283. * @brief I2C TAR Special Set
  284. * @param __I2C__ Specifies I2C peripheral
  285. * @return None
  286. */
  287. #define __LL_I2C_TAR_Special_Set(__I2C__) SET_BIT((__I2C__)->TAR, I2C_SPECIAL_Msk)
  288. /**
  289. * @brief I2C TAR Special Clear
  290. * @param __I2C__ Specifies I2C peripheral
  291. * @return None
  292. */
  293. #define __LL_I2C_TAR_Special_Clr(__I2C__) CLEAR_BIT((__I2C__)->TAR, I2C_SPECIAL_Msk)
  294. /**
  295. * @brief I2C TAR GC OR Start Set
  296. * @param __I2C__ Specifies I2C peripheral
  297. * @return None
  298. */
  299. #define __LL_I2C_TAR_GcOrStart_Set(__I2C__) SET_BIT((__I2C__)->TAR, I2C_GC_OR_START_Msk)
  300. /**
  301. * @brief I2C TAR GC OR Start Clear
  302. * @param __I2C__ Specifies I2C peripheral
  303. * @return None
  304. */
  305. #define __LL_I2C_TAR_GcOrStart_Clr(__I2C__) CLEAR_BIT((__I2C__)->TAR, I2C_GC_OR_START_Msk)
  306. /**
  307. * @brief I2C Master TAR Set
  308. * @param __I2C__ Specifies I2C peripheral
  309. * @param tar I2C Master TAR
  310. * @return None
  311. */
  312. #define __LL_I2C_TAR_Set(__I2C__, tar) MODIFY_REG((__I2C__)->TAR, I2C_TAR_Msk, ((tar & 0x3ffUL) << I2C_TAR_Pos))
  313. /**
  314. * @brief I2C Slave SAR Set
  315. * @param __I2C__ Specifies I2C peripheral
  316. * @param tar I2C Slave SAR
  317. * @return None
  318. */
  319. #define __LL_I2C_SAR_Set(__I2C__, sar) MODIFY_REG((__I2C__)->SAR, I2C_SAR_Msk, ((sar & 0x3ffUL) << I2C_SAR_Pos))
  320. /**
  321. * @brief Judge Is First Data Byte or not
  322. * @param __I2C__ Specifies I2C peripheral
  323. * @retval 0 Isn't first data byte
  324. * @retval 1 Is first data byte
  325. */
  326. #define __LL_I2C_IsFirstDataByte(__I2C__) (READ_BIT((__I2C__)->DCMD, I2C_FIRST_DATA_BYTE_Msk) >> I2C_FIRST_DATA_BYTE_Pos)
  327. /**
  328. * @brief I2C Restart Set
  329. * @param __I2C__ Specifies I2C peripheral
  330. * @return None
  331. */
  332. #define __LL_I2C_Restart_Set(__I2C__) SET_BIT((__I2C__)->DCMD, I2C_RESTART_Msk)
  333. /**
  334. * @brief I2C Restart Clear
  335. * @param __I2C__ Specifies I2C peripheral
  336. * @return None
  337. */
  338. #define __LL_I2C_Restart_Clr(__I2C__) CLEAR_BIT((__I2C__)->DCMD, I2C_RESTART_Msk)
  339. /**
  340. * @brief I2C Stop Set
  341. * @param __I2C__ Specifies I2C peripheral
  342. * @return None
  343. */
  344. #define __LL_I2C_Stop_Set(__I2C__) SET_BIT((__I2C__)->DCMD, I2C_STOP_Msk)
  345. /**
  346. * @brief I2C Stop Clear
  347. * @param __I2C__ Specifies I2C peripheral
  348. * @return None
  349. */
  350. #define __LL_I2C_Stop_Clr(__I2C__) CLEAR_BIT((__I2C__)->DCMD, I2C_STOP_Msk)
  351. /**
  352. * @brief I2C Master Cmd Read Set
  353. * @param __I2C__ Specifies I2C peripheral
  354. * @return None
  355. */
  356. #define __LL_I2C_MST_CmdRead_Set(__I2C__) SET_BIT((__I2C__)->DCMD, I2C_CMD_Msk)
  357. /**
  358. * @brief I2C Master Cmd Write Set
  359. * @param __I2C__ Specifies I2C peripheral
  360. * @return None
  361. */
  362. #define __LL_I2C_MST_CmdWrite_Set(__I2C__) CLEAR_BIT((__I2C__)->DCMD, I2C_CMD_Msk)
  363. /**
  364. * @brief I2C Data Write
  365. * @param __I2C__ Specifies I2C peripheral
  366. * @param dat data to write
  367. * @return None
  368. */
  369. #define __LL_I2C_DAT_Write(__I2C__, dat) MODIFY_REG((__I2C__)->DCMD, I2C_DAT_Msk, (((dat) & 0xffUL) << I2C_DAT_Pos))
  370. /**
  371. * @brief I2C Data Read
  372. * @param __I2C__ Specifies I2C peripheral
  373. * @return read data
  374. */
  375. #define __LL_I2C_DAT_Read(__I2C__) (READ_BIT((__I2C__)->DCMD, I2C_DAT_Msk) >> I2C_DAT_Pos)
  376. /**
  377. * @brief I2C timing start and send 8b address
  378. * @param __I2C__ Specifies I2C peripheral
  379. * @param addr_8b 8b address
  380. * @return None
  381. */
  382. #define __LL_I2C_Timing_RestartAddr8b(__I2C__, addr_8b) \
  383. do { \
  384. WRITE_REG((__I2C__)->DCMD, I2C_RESTART_Msk | ((addr_8b & 0xffUL) << I2C_DAT_Pos)); \
  385. } while(0)
  386. /**
  387. * @brief I2C timing restart and send 16b address
  388. * @param __I2C__ Specifies I2C peripheral
  389. * @param addr_16b 16b address
  390. * @return None
  391. */
  392. #define __LL_I2C_Timing_RestartAddr16b(__I2C__, addr_16b) \
  393. do { \
  394. WRITE_REG((__I2C__)->DCMD, I2C_RESTART_Msk | (((addr_16b >> 8) & 0xffUL) << I2C_DAT_Pos)); \
  395. WRITE_REG((__I2C__)->DCMD, ((addr_16b & 0xffUL) << I2C_DAT_Pos)); \
  396. } while(0)
  397. /**
  398. * @brief I2C timing restart and send 32b address
  399. * @param __I2C__ Specifies I2C peripheral
  400. * @param addr_32b 32b address
  401. * @return None
  402. */
  403. #define __LL_I2C_Timing_RestartAddr32b(__I2C__, addr_32b) \
  404. do { \
  405. WRITE_REG((__I2C__)->DCMD, I2C_RESTART_Msk | (((addr_32b >> 24) & 0xffUL) << I2C_DAT_Pos)); \
  406. WRITE_REG((__I2C__)->DCMD, (((addr_32b >> 16) & 0xffUL) << I2C_DAT_Pos)); \
  407. WRITE_REG((__I2C__)->DCMD, (((addr_32b >> 8) & 0xffUL) << I2C_DAT_Pos)); \
  408. WRITE_REG((__I2C__)->DCMD, ((addr_32b & 0xffUL) << I2C_DAT_Pos)); \
  409. } while(0)
  410. /**
  411. * @brief I2C timing restart read stop
  412. * @param __I2C__ Specifies I2C peripheral
  413. * @return None
  414. */
  415. #define __LL_I2C_Timing_RestartReadStop(__I2C__) \
  416. do { \
  417. WRITE_REG((__I2C__)->DCMD, I2C_RESTART_Msk | I2C_CMD_READ | I2C_STOP_Msk); \
  418. } while(0)
  419. /**
  420. * @brief I2C timing restart read
  421. * @param __I2C__ Specifies I2C peripheral
  422. * @return None
  423. */
  424. #define __LL_I2C_Timing_RestartRead(__I2C__) \
  425. do { \
  426. WRITE_REG((__I2C__)->DCMD, I2C_RESTART_Msk | I2C_CMD_READ); \
  427. } while(0)
  428. /**
  429. * @brief I2C timing read
  430. * @param __I2C__ Specifies I2C peripheral
  431. * @return None
  432. */
  433. #define __LL_I2C_Timing_Read(__I2C__) \
  434. do { \
  435. WRITE_REG((__I2C__)->DCMD, I2C_CMD_READ); \
  436. } while(0)
  437. /**
  438. * @brief I2C timing read stop
  439. * @param __I2C__ Specifies I2C peripheral
  440. * @return None
  441. */
  442. #define __LL_I2C_Timing_ReadStop(__I2C__) \
  443. do { \
  444. WRITE_REG((__I2C__)->DCMD, I2C_CMD_READ | I2C_STOP_Msk); \
  445. } while(0)
  446. /**
  447. * @brief I2C timing write
  448. * @param __I2C__ Specifies I2C peripheral
  449. * @param dat write data
  450. * @return None
  451. */
  452. #define __LL_I2C_Timing_Write(__I2C__, dat) \
  453. do { \
  454. WRITE_REG((__I2C__)->DCMD, (((dat) & 0xffUL) << I2C_DAT_Pos)); \
  455. } while(0)
  456. /**
  457. * @brief I2C timing restart write
  458. * @param __I2C__ Specifies I2C peripheral
  459. * @param dat write data
  460. * @return None
  461. */
  462. #define __LL_I2C_Timing_RestartWrite(__I2C__, dat) \
  463. do { \
  464. WRITE_REG((__I2C__)->DCMD, I2C_RESTART_Msk | (((dat) & 0xffUL) << I2C_DAT_Pos)); \
  465. } while(0)
  466. /**
  467. * @brief I2C timing write stop
  468. * @param __I2C__ Specifies I2C peripheral
  469. * @param dat write data
  470. * @return None
  471. */
  472. #define __LL_I2C_Timing_WriteStop(__I2C__, dat) \
  473. do { \
  474. WRITE_REG((__I2C__)->DCMD, I2C_STOP_Msk | (((dat) & 0xffUL) << I2C_DAT_Pos)); \
  475. } while(0)
  476. /**
  477. * @brief I2C timing restart write stop
  478. * @param __I2C__ Specifies I2C peripheral
  479. * @param dat write data
  480. * @return None
  481. */
  482. #define __LL_I2C_Timing_RestartWriteStop(__I2C__, dat) \
  483. do { \
  484. WRITE_REG((__I2C__)->DCMD, I2C_RESTART_Msk | I2C_STOP_Msk | (((dat) & 0xffUL) << I2C_DAT_Pos)); \
  485. } while(0)
  486. /**
  487. * @brief I2C SS SCL High Count Set
  488. * @param __I2C__ Specifies I2C peripheral
  489. * @param cnt I2C SS SCL High Count
  490. * @return None
  491. */
  492. #define __LL_I2C_SS_SCLHcnt_Set(__I2C__, cnt) \
  493. MODIFY_REG((__I2C__)->SSHCNT, I2C_SS_SCL_HCNT_Msk, ((cnt & 0xffffUL) << I2C_SS_SCL_HCNT_Pos))
  494. /**
  495. * @brief I2C SS SCL Low Count Set
  496. * @param __I2C__ Specifies I2C peripheral
  497. * @param cnt I2C SS SCL Low Count
  498. * @return None
  499. */
  500. #define __LL_I2C_SS_SCLLcnt_Set(__I2C__, cnt) \
  501. MODIFY_REG((__I2C__)->SSLCNT, I2C_SS_SCL_LCNT_Msk, ((cnt & 0xffffUL) << I2C_SS_SCL_LCNT_Pos))
  502. /**
  503. * @brief I2C FS SCL High Count Set
  504. * @param __I2C__ Specifies I2C peripheral
  505. * @param cnt I2C FS SCL High Count
  506. * @return None
  507. */
  508. #define __LL_I2C_FS_SCLHcnt_Set(__I2C__, cnt) \
  509. MODIFY_REG((__I2C__)->FSHCNT, I2C_FS_SCL_HCNT_Msk, ((cnt & 0xffffUL) << I2C_FS_SCL_HCNT_Pos))
  510. /**
  511. * @brief I2C FS SCL Low Count Set
  512. * @param __I2C__ Specifies I2C peripheral
  513. * @param cnt I2C FS SCL Low Count
  514. * @return None
  515. */
  516. #define __LL_I2C_FS_SCLLcnt_Set(__I2C__, cnt) \
  517. MODIFY_REG((__I2C__)->FSLCNT, I2C_FS_SCL_LCNT_Msk, ((cnt & 0xffffUL) << I2C_FS_SCL_LCNT_Pos))
  518. /**
  519. * @brief Judge SCL Stuck at Low or not
  520. * @param __I2C__ Specifies I2C peripheral
  521. * @retval 0 SCL isn't Stuck at Low
  522. * @retval 1 SCL is Stuck at Low
  523. */
  524. #define __LL_I2C_IsSCLStuckAtLow(__I2C__) \
  525. (READ_BIT((__I2C__)->INTRST, I2C_SCL_STK_AT_LOW_INT_STA_Msk) >> I2C_SCL_STK_AT_LOW_INT_STA_Pos)
  526. /**
  527. * @brief Judge Master On Hold or not
  528. * @param __I2C__ Specifies I2C peripheral
  529. * @retval 0 Master isn't On Hold
  530. * @retval 1 Master is On Hold
  531. */
  532. #define __LL_I2C_MST_IsOnHold(__I2C__) \
  533. (READ_BIT((__I2C__)->INTRST, I2C_MST_ON_HOLD_INT_STA_Msk) >> I2C_MST_ON_HOLD_INT_STA_Pos)
  534. /**
  535. * @brief Judge Slave is Restart Detect or not
  536. * @param __I2C__ Specifies I2C peripheral
  537. * @retval 0 Slave isn't Restart Detect
  538. * @retval 1 Slave is Restart Detect
  539. */
  540. #define __LL_I2C_SLV_IsRestartDet(__I2C__) \
  541. (READ_BIT((__I2C__)->INTRST, I2C_RESTART_DET_INT_STA_Msk) >> I2C_RESTART_DET_INT_STA_Pos)
  542. /**
  543. * @brief Judge Slave Genaral Call or not
  544. * @param __I2C__ Specifies I2C peripheral
  545. * @retval 0 Isn't Genaral Call
  546. * @retval 1 Is Genaral Call
  547. */
  548. #define __LL_I2C_SLV_IsGenCall(__I2C__) \
  549. (READ_BIT((__I2C__)->INTRST, I2C_GEN_CALL_INT_STA_Msk) >> I2C_GEN_CALL_INT_STA_Pos)
  550. /**
  551. * @brief Judge Start Detect or not
  552. * @param __I2C__ Specifies I2C peripheral
  553. * @retval 0 Isn't start detect
  554. * @retval 1 Is start detect
  555. */
  556. #define __LL_I2C_IsStartDet(__I2C__) \
  557. (READ_BIT((__I2C__)->INTRST, I2C_START_DET_INT_STA_Msk) >> I2C_START_DET_INT_STA_Pos)
  558. /**
  559. * @brief Judge Stop Detect or not
  560. * @param __I2C__ Specifies I2C peripheral
  561. * @retval 0 Isn't stop detect
  562. * @retval 1 Is stop detect
  563. */
  564. #define __LL_I2C_IsStopDet(__I2C__) \
  565. (READ_BIT((__I2C__)->INTRST, I2C_STOP_DET_INT_STA_Msk) >> I2C_STOP_DET_INT_STA_Pos)
  566. /**
  567. * @brief Judge I2C Activity or not
  568. * @param __I2C__ Specifies I2C peripheral
  569. * @retval 0 I2C isn't activity
  570. * @retval 1 I2C is activity
  571. */
  572. #define __LL_I2C_IsActivityInt(__I2C__) \
  573. (READ_BIT((__I2C__)->INTRST, I2C_ACTIVITY_INT_STA_Msk) >> I2C_ACTIVITY_INT_STA_Pos)
  574. /**
  575. * @brief Judge Slave RX Done or not
  576. * @param __I2C__ Specifies I2C peripheral
  577. * @retval 0 Slave isn't RX Done
  578. * @retval 1 Slave is RX Done
  579. */
  580. #define __LL_I2C_SLV_IsRxDone(__I2C__) \
  581. (READ_BIT((__I2C__)->INTRST, I2C_RX_DONE_INT_STA_Msk) >> I2C_RX_DONE_INT_STA_Pos)
  582. /**
  583. * @brief Judge TX Abort or not
  584. * @param __I2C__ Specifies I2C peripheral
  585. * @retval 0 Isn't TX Abort
  586. * @retval 1 Is TX Abort
  587. */
  588. #define __LL_I2C_IsTxAbort(__I2C__) \
  589. (READ_BIT((__I2C__)->INTRST, I2C_TX_ABRT_INT_STA_Msk) >> I2C_TX_ABRT_INT_STA_Pos)
  590. /**
  591. * @brief Judge Slave Read Request or not
  592. * @param __I2C__ Specifies I2C peripheral
  593. * @retval 0 Slave isn't Read Request
  594. * @retval 1 Slave is Read Request
  595. */
  596. #define __LL_I2C_SLV_IsReadReq(__I2C__) \
  597. (READ_BIT((__I2C__)->INTRST, I2C_RD_REQ_INT_STA_Msk) >> I2C_RD_REQ_INT_STA_Pos)
  598. /**
  599. * @brief Judge TX Empty or not
  600. * @param __I2C__ Specifies I2C peripheral
  601. * @retval 0 Isn't TX Empty
  602. * @retval 1 Is TX Empty
  603. */
  604. #define __LL_I2C_IsTxEmpty(__I2C__) \
  605. (READ_BIT((__I2C__)->INTRST, I2C_TX_EMPTY_INT_STA_Msk) >> I2C_TX_EMPTY_INT_STA_Pos)
  606. /**
  607. * @brief Judge TX Over or not
  608. * @param __I2C__ Specifies I2C peripheral
  609. * @retval 0 Isn't TX Over
  610. * @retval 1 Is TX Over
  611. */
  612. #define __LL_I2C_IsTxOver(__I2C__) \
  613. (READ_BIT((__I2C__)->INTRST, I2C_TX_OVER_INT_STA_Msk) >> I2C_TX_OVER_INT_STA_Pos)
  614. /**
  615. * @brief Judge RX Full or not
  616. * @param __I2C__ Specifies I2C peripheral
  617. * @retval 0 Isn't RX Full
  618. * @retval 1 Is RX Full
  619. */
  620. #define __LL_I2C_IsRxFull(__I2C__) \
  621. (READ_BIT((__I2C__)->INTRST, I2C_RX_FULL_INT_STA_Msk) >> I2C_RX_FULL_INT_STA_Pos)
  622. /**
  623. * @brief Judge RX Over or not
  624. * @param __I2C__ Specifies I2C peripheral
  625. * @retval 0 Isn't RX Over
  626. * @retval 1 Is RX Over
  627. */
  628. #define __LL_I2C_IsRxOver(__I2C__) \
  629. (READ_BIT((__I2C__)->INTRST, I2C_RX_OVER_INT_STA_Msk) >> I2C_RX_OVER_INT_STA_Pos)
  630. /**
  631. * @brief Judge RX Under or not
  632. * @param __I2C__ Specifies I2C peripheral
  633. * @retval 0 Isn't RX Under
  634. * @retval 1 Is RX Under
  635. */
  636. #define __LL_I2C_IsRxUnder(__I2C__) \
  637. (READ_BIT((__I2C__)->INTRST, I2C_RX_UNDER_INT_STA_Msk) >> I2C_RX_UNDER_INT_STA_Pos)
  638. /**
  639. * @brief I2C interrupt status get
  640. * @param __I2C__ Specifies I2C peripheral
  641. * @return I2C interrupt status
  642. */
  643. #define __LL_I2C_IntSta_Get(__I2C__) (READ_REG((__I2C__)->INTRST))
  644. /**
  645. * @brief I2C SCL Stuck at low Interrupt Enable
  646. * @param __I2C__ Specifies I2C peripheral
  647. * @return None
  648. */
  649. #define __LL_I2C_SCLStuckAtLow_INT_En(__I2C__) SET_BIT((__I2C__)->INTRMS, I2C_SCL_STK_AT_LOW_INT_EN_Msk)
  650. /**
  651. * @brief I2C SCL Stuck at low Interrupt Disable
  652. * @param __I2C__ Specifies I2C peripheral
  653. * @return None
  654. */
  655. #define __LL_I2C_SCLStuckAtLow_INT_Dis(__I2C__) CLEAR_BIT((__I2C__)->INTRMS, I2C_SCL_STK_AT_LOW_INT_EN_Msk)
  656. /**
  657. * @brief I2C Master on hold Interrupt Enable
  658. * @param __I2C__ Specifies I2C peripheral
  659. * @return None
  660. */
  661. #define __LL_I2C_MST_OnHold_INT_En(__I2C__) SET_BIT((__I2C__)->INTRMS, I2C_MST_ON_HOLD_INT_EN_Msk)
  662. /**
  663. * @brief I2C Master on hold Interrupt Disable
  664. * @param __I2C__ Specifies I2C peripheral
  665. * @return None
  666. */
  667. #define __LL_I2C_MST_OnHold_INT_Dis(__I2C__) CLEAR_BIT((__I2C__)->INTRMS, I2C_MST_ON_HOLD_INT_EN_Msk)
  668. /**
  669. * @brief I2C Slave Restart Detect Interrupt Enable
  670. * @param __I2C__ Specifies I2C peripheral
  671. * @return None
  672. */
  673. #define __LL_I2C_SLV_RestartDet_INT_En(__I2C__) SET_BIT((__I2C__)->INTRMS, I2C_RESTART_DET_INT_EN_Msk)
  674. /**
  675. * @brief I2C Slave Restart Detect Interrupt Disable
  676. * @param __I2C__ Specifies I2C peripheral
  677. * @return None
  678. */
  679. #define __LL_I2C_SLV_RestartDet_INT_Dis(__I2C__) CLEAR_BIT((__I2C__)->INTRMS, I2C_RESTART_DET_INT_EN_Msk)
  680. /**
  681. * @brief I2C Slave Genaral Call Interrupt Enable
  682. * @param __I2C__ Specifies I2C peripheral
  683. * @return None
  684. */
  685. #define __LL_I2C_SLV_GenCall_INT_En(__I2C__) SET_BIT((__I2C__)->INTRMS, I2C_GEN_CALL_INT_EN_Msk)
  686. /**
  687. * @brief I2C Slave Genaral Call Interrupt Disable
  688. * @param __I2C__ Specifies I2C peripheral
  689. * @return None
  690. */
  691. #define __LL_I2C_SLV_GenCall_INT_Dis(__I2C__) CLEAR_BIT((__I2C__)->INTRMS, I2C_GEN_CALL_INT_EN_Msk)
  692. /**
  693. * @brief I2C Start Detect Interrupt Enable
  694. * @param __I2C__ Specifies I2C peripheral
  695. * @return None
  696. */
  697. #define __LL_I2C_StartDet_INT_En(__I2C__) SET_BIT((__I2C__)->INTRMS, I2C_START_DET_INT_EN_Msk)
  698. /**
  699. * @brief I2C Start Detect Interrupt Disable
  700. * @param __I2C__ Specifies I2C peripheral
  701. * @return None
  702. */
  703. #define __LL_I2C_StartDet_INT_Dis(__I2C__) CLEAR_BIT((__I2C__)->INTRMS, I2C_START_DET_INT_EN_Msk)
  704. /**
  705. * @brief I2C Stop Detect Interrupt Enable
  706. * @param __I2C__ Specifies I2C peripheral
  707. * @return None
  708. */
  709. #define __LL_I2C_StopDet_INT_En(__I2C__) SET_BIT((__I2C__)->INTRMS, I2C_STOP_DET_INT_EN_Msk)
  710. /**
  711. * @brief I2C Stop Detect Interrupt Disable
  712. * @param __I2C__ Specifies I2C peripheral
  713. * @return None
  714. */
  715. #define __LL_I2C_StopDet_INT_Dis(__I2C__) CLEAR_BIT((__I2C__)->INTRMS, I2C_STOP_DET_INT_EN_Msk)
  716. /**
  717. * @brief I2C Activity Interrupt Enable
  718. * @param __I2C__ Specifies I2C peripheral
  719. * @return None
  720. */
  721. #define __LL_I2C_Activity_INT_En(__I2C__) SET_BIT((__I2C__)->INTRMS, I2C_ACTIVITY_INT_EN_Msk)
  722. /**
  723. * @brief I2C Activity Interrupt Disable
  724. * @param __I2C__ Specifies I2C peripheral
  725. * @return None
  726. */
  727. #define __LL_I2C_Activity_INT_Dis(__I2C__) CLEAR_BIT((__I2C__)->INTRMS, I2C_ACTIVITY_INT_EN_Msk)
  728. /**
  729. * @brief I2C Slave RX Done Interrupt Enable
  730. * @param __I2C__ Specifies I2C peripheral
  731. * @return None
  732. */
  733. #define __LL_I2C_SLV_RxDone_INT_En(__I2C__) SET_BIT((__I2C__)->INTRMS, I2C_RX_DONE_INT_EN_Msk)
  734. /**
  735. * @brief I2C Slave RX Done Interrupt Disable
  736. * @param __I2C__ Specifies I2C peripheral
  737. * @return None
  738. */
  739. #define __LL_I2C_SLV_RxDone_INT_Dis(__I2C__) CLEAR_BIT((__I2C__)->INTRMS, I2C_RX_DONE_INT_EN_Msk)
  740. /**
  741. * @brief I2C TX Abort Interrupt Enable
  742. * @param __I2C__ Specifies I2C peripheral
  743. * @return None
  744. */
  745. #define __LL_I2C_TxAbort_INT_En(__I2C__) SET_BIT((__I2C__)->INTRMS, I2C_TX_ABRT_INT_EN_Msk)
  746. /**
  747. * @brief I2C TX Abort Interrupt Disable
  748. * @param __I2C__ Specifies I2C peripheral
  749. * @return None
  750. */
  751. #define __LL_I2C_TxAbort_INT_Dis(__I2C__) CLEAR_BIT((__I2C__)->INTRMS, I2C_TX_ABRT_INT_EN_Msk)
  752. /**
  753. * @brief I2C Slave Read Request Interrupt Enable
  754. * @param __I2C__ Specifies I2C peripheral
  755. * @return None
  756. */
  757. #define __LL_I2C_SLV_ReadReq_INT_En(__I2C__) SET_BIT((__I2C__)->INTRMS, I2C_RD_REQ_INT_EN_Msk)
  758. /**
  759. * @brief I2C Slave Read Request Interrupt Disable
  760. * @param __I2C__ Specifies I2C peripheral
  761. * @return None
  762. */
  763. #define __LL_I2C_SLV_ReadReq_INT_Dis(__I2C__) CLEAR_BIT((__I2C__)->INTRMS, I2C_RD_REQ_INT_EN_Msk)
  764. /**
  765. * @brief I2C TX Empty Interrupt Enable
  766. * @param __I2C__ Specifies I2C peripheral
  767. * @return None
  768. */
  769. #define __LL_I2C_TxEmpty_INT_En(__I2C__) SET_BIT((__I2C__)->INTRMS, I2C_TX_EMPTY_INT_EN_Msk)
  770. /**
  771. * @brief I2C TX Empty Interrupt Disable
  772. * @param __I2C__ Specifies I2C peripheral
  773. * @return None
  774. */
  775. #define __LL_I2C_TxEmpty_INT_Dis(__I2C__) CLEAR_BIT((__I2C__)->INTRMS, I2C_TX_EMPTY_INT_EN_Msk)
  776. /**
  777. * @brief I2C TX Over Interrupt Enable
  778. * @param __I2C__ Specifies I2C peripheral
  779. * @return None
  780. */
  781. #define __LL_I2C_TxOver_INT_En(__I2C__) SET_BIT((__I2C__)->INTRMS, I2C_TX_OVER_INT_EN_Msk)
  782. /**
  783. * @brief I2C TX Over Interrupt Disable
  784. * @param __I2C__ Specifies I2C peripheral
  785. * @return None
  786. */
  787. #define __LL_I2C_TxOver_INT_Dis(__I2C__) CLEAR_BIT((__I2C__)->INTRMS, I2C_TX_OVER_INT_EN_Msk)
  788. /**
  789. * @brief I2C RX Full Interrupt Enable
  790. * @param __I2C__ Specifies I2C peripheral
  791. * @return None
  792. */
  793. #define __LL_I2C_RxFull_INT_En(__I2C__) SET_BIT((__I2C__)->INTRMS, I2C_RX_FULL_INT_EN_Msk)
  794. /**
  795. * @brief I2C RX Full Interrupt Disable
  796. * @param __I2C__ Specifies I2C peripheral
  797. * @return None
  798. */
  799. #define __LL_I2C_RxFull_INT_Dis(__I2C__) CLEAR_BIT((__I2C__)->INTRMS, I2C_RX_FULL_INT_EN_Msk)
  800. /**
  801. * @brief I2C RX Over Interrupt Enable
  802. * @param __I2C__ Specifies I2C peripheral
  803. * @return None
  804. */
  805. #define __LL_I2C_RxOver_INT_En(__I2C__) SET_BIT((__I2C__)->INTRMS, I2C_RX_OVER_INT_EN_Msk)
  806. /**
  807. * @brief I2C RX Over Interrupt Disable
  808. * @param __I2C__ Specifies I2C peripheral
  809. * @return None
  810. */
  811. #define __LL_I2C_RxOver_INT_Dis(__I2C__) CLEAR_BIT((__I2C__)->INTRMS, I2C_RX_OVER_INT_EN_Msk)
  812. /**
  813. * @brief I2C RX Under Interrupt Enable
  814. * @param __I2C__ Specifies I2C peripheral
  815. * @return None
  816. */
  817. #define __LL_I2C_RxUnder_INT_En(__I2C__) SET_BIT((__I2C__)->INTRMS, I2C_RX_UNDER_INT_EN_Msk)
  818. /**
  819. * @brief I2C RX Under Interrupt Disable
  820. * @param __I2C__ Specifies I2C peripheral
  821. * @return None
  822. */
  823. #define __LL_I2C_RxUnder_INT_Dis(__I2C__) CLEAR_BIT((__I2C__)->INTRMS, I2C_RX_UNDER_INT_EN_Msk)
  824. /**
  825. * @brief Judge SCL Stuck at Low Raw or not
  826. * @param __I2C__ Specifies I2C peripheral
  827. * @retval 0 SCL isn't Stuck at Low
  828. * @retval 1 SCL is Stuck at Low
  829. */
  830. #define __LL_I2C_IsSCLStuckAtLow_Raw(__I2C__) \
  831. (READ_BIT((__I2C__)->RINTRST, I2C_SCL_STK_AT_LOW_RAW_INT_STA_Msk) >> I2C_SCL_STK_AT_LOW_RAW_INT_STA_Pos)
  832. /**
  833. * @brief Judge Master On Hold Raw or not
  834. * @param __I2C__ Specifies I2C peripheral
  835. * @retval 0 Master isn't On Hold
  836. * @retval 1 Master is On Hold
  837. */
  838. #define __LL_I2C_MST_IsOnHold_Raw(__I2C__) \
  839. (READ_BIT((__I2C__)->RINTRST, I2C_MST_ON_HOLD_RAW_INT_STA_Msk) >> I2C_MST_ON_HOLD_RAW_INT_STA_Pos)
  840. /**
  841. * @brief Judge Slave is Restart Detect Raw or not
  842. * @param __I2C__ Specifies I2C peripheral
  843. * @retval 0 Slave isn't Restart Detect
  844. * @retval 1 Slave is Restart Detect
  845. */
  846. #define __LL_I2C_SLV_IsRestartDet_Raw(__I2C__) \
  847. (READ_BIT((__I2C__)->RINTRST, I2C_RESTART_DET_RAW_INT_STA_Msk) >> I2C_RESTART_DET_RAW_INT_STA_Pos)
  848. /**
  849. * @brief Judge Slave Genaral Call Raw or not
  850. * @param __I2C__ Specifies I2C peripheral
  851. * @retval 0 Isn't Genaral Call
  852. * @retval 1 Is Genaral Call
  853. */
  854. #define __LL_I2C_SLV_IsGenCall_Raw(__I2C__) \
  855. (READ_BIT((__I2C__)->RINTRST, I2C_GEN_CALL_RAW_INT_STA_Msk) >> I2C_GEN_CALL_RAW_INT_STA_Pos)
  856. /**
  857. * @brief Judge Start Detect Raw or not
  858. * @param __I2C__ Specifies I2C peripheral
  859. * @retval 0 Isn't start detect
  860. * @retval 1 Is start detect
  861. */
  862. #define __LL_I2C_IsStartDet_Raw(__I2C__) \
  863. (READ_BIT((__I2C__)->RINTRST, I2C_START_DET_RAW_INT_STA_Msk) >> I2C_START_DET_RAW_INT_STA_Pos)
  864. /**
  865. * @brief Judge Stop Detect Raw or not
  866. * @param __I2C__ Specifies I2C peripheral
  867. * @retval 0 Isn't stop detect
  868. * @retval 1 Is stop detect
  869. */
  870. #define __LL_I2C_IsStopDet_Raw(__I2C__) \
  871. (READ_BIT((__I2C__)->RINTRST, I2C_STOP_DET_RAW_INT_STA_Msk) >> I2C_STOP_DET_RAW_INT_STA_Pos)
  872. /**
  873. * @brief Judge I2C Activity Raw or not
  874. * @param __I2C__ Specifies I2C peripheral
  875. * @retval 0 I2C isn't activity
  876. * @retval 1 I2C is activity
  877. */
  878. #define __LL_I2C_IsActivity_Raw(__I2C__) \
  879. (READ_BIT((__I2C__)->RINTRST, I2C_ACTIVITY_RAW_INT_STA_Msk) >> I2C_ACTIVITY_RAW_INT_STA_Pos)
  880. /**
  881. * @brief Judge Slave RX Done Raw or not
  882. * @param __I2C__ Specifies I2C peripheral
  883. * @retval 0 Slave isn't RX Done
  884. * @retval 1 Slave is RX Done
  885. */
  886. #define __LL_I2C_SLV_IsRxDone_Raw(__I2C__) \
  887. (READ_BIT((__I2C__)->RINTRST, I2C_RX_DONE_RAW_INT_STA_Msk) >> I2C_RX_DONE_RAW_INT_STA_Pos)
  888. /**
  889. * @brief Judge TX Abort Raw or not
  890. * @param __I2C__ Specifies I2C peripheral
  891. * @retval 0 Isn't TX Abort
  892. * @retval 1 Is TX Abort
  893. */
  894. #define __LL_I2C_IsTxAbort_Raw(__I2C__) \
  895. (READ_BIT((__I2C__)->RINTRST, I2C_TX_ABRT_RAW_INT_STA_Msk) >> I2C_TX_ABRT_RAW_INT_STA_Pos)
  896. /**
  897. * @brief Judge Slave Read Request Raw or not
  898. * @param __I2C__ Specifies I2C peripheral
  899. * @retval 0 Slave isn't Read Request
  900. * @retval 1 Slave is Read Request
  901. */
  902. #define __LL_I2C_SLV_IsReadReq_Raw(__I2C__) \
  903. (READ_BIT((__I2C__)->RINTRST, I2C_RD_REQ_RAW_INT_STA_Msk) >> I2C_RD_REQ_RAW_INT_STA_Pos)
  904. /**
  905. * @brief Judge TX Empty Raw or not
  906. * @param __I2C__ Specifies I2C peripheral
  907. * @retval 0 Isn't TX Empty
  908. * @retval 1 Is TX Empty
  909. */
  910. #define __LL_I2C_IsTxEmpty_Raw(__I2C__) \
  911. (READ_BIT((__I2C__)->RINTRST, I2C_TX_EMPTY_RAW_INT_STA_Msk) >> I2C_TX_EMPTY_RAW_INT_STA_Pos)
  912. /**
  913. * @brief Judge TX Over Raw or not
  914. * @param __I2C__ Specifies I2C peripheral
  915. * @retval 0 Isn't TX Over
  916. * @retval 1 Is TX Over
  917. */
  918. #define __LL_I2C_IsTxOver_Raw(__I2C__) \
  919. (READ_BIT((__I2C__)->RINTRST, I2C_TX_OVER_RAW_INT_STA_Msk) >> I2C_TX_OVER_RAW_INT_STA_Pos)
  920. /**
  921. * @brief Judge RX Full Raw or not
  922. * @param __I2C__ Specifies I2C peripheral
  923. * @retval 0 Isn't RX Full
  924. * @retval 1 Is RX Full
  925. */
  926. #define __LL_I2C_IsRxFull_Raw(__I2C__) \
  927. (READ_BIT((__I2C__)->RINTRST, I2C_RX_FULL_RAW_INT_STA_Msk) >> I2C_RX_FULL_RAW_INT_STA_Pos)
  928. /**
  929. * @brief Judge RX Over Raw or not
  930. * @param __I2C__ Specifies I2C peripheral
  931. * @retval 0 Isn't RX Over
  932. * @retval 1 Is RX Over
  933. */
  934. #define __LL_I2C_IsRxOver_Raw(__I2C__) \
  935. (READ_BIT((__I2C__)->RINTRST, I2C_RX_OVER_RAW_INT_STA_Msk) >> I2C_RX_OVER_RAW_INT_STA_Pos)
  936. /**
  937. * @brief Judge RX Under Raw or not
  938. * @param __I2C__ Specifies I2C peripheral
  939. * @retval 0 Isn't RX Under
  940. * @retval 1 Is RX Under
  941. */
  942. #define __LL_I2C_IsRxUnder_Raw(__I2C__) \
  943. (READ_BIT((__I2C__)->RINTRST, I2C_RX_UNDER_RAW_INT_STA_Msk) >> I2C_RX_UNDER_RAW_INT_STA_Pos)
  944. /**
  945. * @brief I2C RX Trigger Level Set
  946. * @param __I2C__ Specifies I2C peripheral
  947. * @param tl RX Trigger Level
  948. * @return None
  949. */
  950. #define __LL_I2C_RxTL_Set(__I2C__, tl) MODIFY_REG((__I2C__)->RXTL, I2C_RX_TL_Msk, (((tl-1) & 0xffUL) << I2C_RX_TL_Pos))
  951. /**
  952. * @brief I2C TX Trigger Level Set
  953. * @param __I2C__ Specifies I2C peripheral
  954. * @param tl TX Trigger Level
  955. * @return None
  956. */
  957. #define __LL_I2C_TxTL_Set(__I2C__, tl) MODIFY_REG((__I2C__)->TXTL, I2C_TX_TL_Msk, (((tl-1) & 0xffUL) << I2C_TX_TL_Pos))
  958. /**
  959. * @brief I2C Soft Interrupt Status Clear
  960. * @param __I2C__ Specifies I2C peripheral
  961. * @return Read Value, not use
  962. */
  963. #define __LL_I2C_SoftIntSta_Clr(__I2C__) (READ_BIT((__I2C__)->INTRCR, I2C_CLR_INT_Msk) >> I2C_CLR_INT_Pos)
  964. /**
  965. * @brief I2C RX Under Interrupt Status Clear
  966. * @param __I2C__ Specifies I2C peripheral
  967. * @return Read Value, not use
  968. */
  969. #define __LL_I2C_RxUnderRawIntSta_Clr(__I2C__) (READ_BIT((__I2C__)->RXUNCR, I2C_CLR_RX_UNDER_Msk) >> I2C_CLR_RX_UNDER_Pos)
  970. /**
  971. * @brief I2C RX Over Interrupt Status Clear
  972. * @param __I2C__ Specifies I2C peripheral
  973. * @return Read Value, not use
  974. */
  975. #define __LL_I2C_RxOverRawIntSta_Clr(__I2C__) (READ_BIT((__I2C__)->RXOVCR, I2C_CLR_RX_OVER_Msk) >> I2C_CLR_RX_OVER_Pos)
  976. /**
  977. * @brief I2C TX Over Interrupt Status Clear
  978. * @param __I2C__ Specifies I2C peripheral
  979. * @return Read Value, not use
  980. */
  981. #define __LL_I2C_TxOverRawIntSta_Clr(__I2C__) (READ_BIT((__I2C__)->TXOVCR, I2C_CLR_TX_OVER_Msk) >> I2C_CLR_TX_OVER_Pos)
  982. /**
  983. * @brief I2C Slave Read Request Interrupt Status Clear
  984. * @param __I2C__ Specifies I2C peripheral
  985. * @return Read Value, not use
  986. */
  987. #define __LL_I2C_SLV_ReadReqRawIntSta_Clr(__I2C__) (READ_BIT((__I2C__)->RDREQCR, I2C_CLR_RD_REQ_Msk) >> I2C_CLR_RD_REQ_Pos)
  988. /**
  989. * @brief I2C TX Abort Interrupt Status Clear
  990. * @param __I2C__ Specifies I2C peripheral
  991. * @return Read Value, not use
  992. */
  993. #define __LL_I2C_TxAbortRawIntSta_Clr(__I2C__) (READ_BIT((__I2C__)->TXABCR, I2C_CLR_TX_ABRT_Msk) >> I2C_CLR_TX_ABRT_Pos)
  994. /**
  995. * @brief I2C Slave RX Done Interrupt Status Clear
  996. * @param __I2C__ Specifies I2C peripheral
  997. * @return Read Value, not use
  998. */
  999. #define __LL_I2C_SLV_RxDoneRawIntSta_Clr(__I2C__) (READ_BIT((__I2C__)->RXDOCR, I2C_CLR_RX_DONE_Msk) >> I2C_CLR_RX_DONE_Pos)
  1000. /**
  1001. * @brief I2C Activity Interrupt Status Clear
  1002. * @param __I2C__ Specifies I2C peripheral
  1003. * @return Read Value, not use
  1004. */
  1005. #define __LL_I2C_ActivityRawIntSta_Clr(__I2C__) (READ_BIT((__I2C__)->ACTICR, I2C_CLR_ACTIVITY_Msk) >> I2C_CLR_ACTIVITY_Pos)
  1006. /**
  1007. * @brief I2C Stop Detect Interrupt Status Clear
  1008. * @param __I2C__ Specifies I2C peripheral
  1009. * @return Read Value, not use
  1010. */
  1011. #define __LL_I2C_StopDetRawIntSta_Clr(__I2C__) (READ_BIT((__I2C__)->SPDETCR, I2C_CLR_STOP_DET_Msk) >> I2C_CLR_STOP_DET_Pos)
  1012. /**
  1013. * @brief I2C Start Detect Interrupt Status Clear
  1014. * @param __I2C__ Specifies I2C peripheral
  1015. * @return Read Value, not use
  1016. */
  1017. #define __LL_I2C_StartDetRawIntSta_Clr(__I2C__) (READ_BIT((__I2C__)->STDETCR, I2C_CLR_START_DET_Msk) >> I2C_CLR_START_DET_Pos)
  1018. /**
  1019. * @brief I2C Slave Genaral Call Interrupt Status Clear
  1020. * @param __I2C__ Specifies I2C peripheral
  1021. * @return Read Value, not use
  1022. */
  1023. #define __LL_I2C_SLV_GenCallRawIntSta_Clr(__I2C__) (READ_BIT((__I2C__)->GCCR, I2C_CLR_GEN_CALL_Msk) >> I2C_CLR_GEN_CALL_Pos)
  1024. /**
  1025. * @brief I2C SMBUS Alert Enable Set
  1026. * @param __I2C__ Specifies I2C peripheral
  1027. * @return None
  1028. */
  1029. #define __LL_I2C_SMBUS_AlertEn_Set(__I2C__) SET_BIT((__I2C__)->ENABLE, I2C_SMBUS_ALERT_EN_Msk)
  1030. /**
  1031. * @brief I2C SMBUS Alert Enable Clear
  1032. * @param __I2C__ Specifies I2C peripheral
  1033. * @return None
  1034. */
  1035. #define __LL_I2C_SMBUS_AlertEn_Clr(__I2C__) CLEAR_BIT((__I2C__)->ENABLE, I2C_SMBUS_ALERT_EN_Msk)
  1036. /**
  1037. * @brief I2C SMBUS Suspend Enable Set
  1038. * @param __I2C__ Specifies I2C peripheral
  1039. * @return None
  1040. */
  1041. #define __LL_I2C_SMBUS_SuspendEn_Set(__I2C__) SET_BIT((__I2C__)->ENABLE, I2C_SMBUS_SUSPEND_EN_Msk)
  1042. /**
  1043. * @brief I2C SMBUS Suspend Enable Clear
  1044. * @param __I2C__ Specifies I2C peripheral
  1045. * @return None
  1046. */
  1047. #define __LL_I2C_SMBUS_SuspendEn_Clr(__I2C__) CLEAR_BIT((__I2C__)->ENABLE, I2C_SMBUS_SUSPEND_EN_Msk)
  1048. /**
  1049. * @brief I2C SMBUS CLK Reset Set
  1050. * @param __I2C__ Specifies I2C peripheral
  1051. * @return None
  1052. */
  1053. #define __LL_I2C_SMBUS_ClkReset_Set(__I2C__) SET_BIT((__I2C__)->ENABLE, I2C_SMBUS_CLK_RESET_Msk)
  1054. /**
  1055. * @brief I2C SMBUS CLK Reset Clear
  1056. * @param __I2C__ Specifies I2C peripheral
  1057. * @return None
  1058. */
  1059. #define __LL_I2C_SMBUS_ClkReset_Clr(__I2C__) CLEAR_BIT((__I2C__)->ENABLE, I2C_SMBUS_CLK_RESET_Msk)
  1060. /**
  1061. * @brief I2C SDA Stuck Recovery Enable Set
  1062. * @param __I2C__ Specifies I2C peripheral
  1063. * @return None
  1064. */
  1065. #define __LL_I2C_SDAStuckRecoveryEn_Set(__I2C__) SET_BIT((__I2C__)->ENABLE, I2C_SDA_STK_RECOVERY_EN_Msk)
  1066. /**
  1067. * @brief I2C Master TX Cmd Block Set
  1068. * @param __I2C__ Specifies I2C peripheral
  1069. * @return None
  1070. */
  1071. #define __LL_I2C_MST_TxCmdBlock_Set(__I2C__) SET_BIT((__I2C__)->ENABLE, I2C_TX_CMD_BLOCK_Msk)
  1072. /**
  1073. * @brief I2C Master TX Cmd Block Clear
  1074. * @param __I2C__ Specifies I2C peripheral
  1075. * @return None
  1076. */
  1077. #define __LL_I2C_MST_TxCmdBlock_Clr(__I2C__) CLEAR_BIT((__I2C__)->ENABLE, I2C_TX_CMD_BLOCK_Msk)
  1078. /**
  1079. * @brief I2C Master Abort Set
  1080. * @param __I2C__ Specifies I2C peripheral
  1081. * @return None
  1082. */
  1083. #define __LL_I2C_MST_Abort_Set(__I2C__) SET_BIT((__I2C__)->ENABLE, I2C_ABORT_Msk)
  1084. /**
  1085. * @brief I2C Module Enable
  1086. * @param __I2C__ Specifies I2C peripheral
  1087. * @return None
  1088. */
  1089. #define __LL_I2C_Enable(__I2C__) SET_BIT((__I2C__)->ENABLE, I2C_ENABLE_Msk)
  1090. /**
  1091. * @brief I2C Module Disable
  1092. * @param __I2C__ Specifies I2C peripheral
  1093. * @return None
  1094. */
  1095. #define __LL_I2C_Disable(__I2C__) CLEAR_BIT((__I2C__)->ENABLE, I2C_ENABLE_Msk)
  1096. /**
  1097. * @brief Judge SMBUS Alert Status or not
  1098. * @param __I2C__ Specifies I2C peripheral
  1099. * @retval 0 Isn't alert status
  1100. * @retval 1 Is alert status
  1101. */
  1102. #define __LL_I2C_SMBUS_IsAlertSta(__I2C__) (READ_BIT((__I2C__)->STATUS, I2C_SMBUS_ALERT_STATUS_Msk) >> I2C_SMBUS_ALERT_STATUS_Pos)
  1103. /**
  1104. * @brief Judge SMBUS Suspend Status or not
  1105. * @param __I2C__ Specifies I2C peripheral
  1106. * @retval 0 Isn't Suspend status
  1107. * @retval 1 Is Suspend status
  1108. */
  1109. #define __LL_I2C_SMBUS_IsSuspendSta(__I2C__) (READ_BIT((__I2C__)->STATUS, I2C_SMBUS_SUSPEND_STATUS_Msk) >> I2C_SMBUS_SUSPEND_STATUS_Pos)
  1110. /**
  1111. * @brief Judge SMBUS Slave Address Resolved or not
  1112. * @param __I2C__ Specifies I2C peripheral
  1113. * @retval 0 SMBUS Slave Address Isn't Resolved
  1114. * @retval 1 SMBUS Slave Address Is Resolved
  1115. */
  1116. #define __LL_I2C_SMBUS_IsSlvAddrResolved(__I2C__) \
  1117. (READ_BIT((__I2C__)->STATUS, I2C_SMBUS_SLV_ADDR_RESOLVED_Msk) >> I2C_SMBUS_SLV_ADDR_RESOLVED_Pos)
  1118. /**
  1119. * @brief Judge SMBUS Slave Address Valid or not
  1120. * @param __I2C__ Specifies I2C peripheral
  1121. * @retval 0 SMBUS Slave Address Isn't Valid
  1122. * @retval 1 SMBUS Slave Address Is Valid
  1123. */
  1124. #define __LL_I2C_SMBUS_IsSlvAddrValid(__I2C__) \
  1125. (READ_BIT((__I2C__)->STATUS, I2C_SMBUS_SLV_ADDR_VALID_Msk) >> I2C_SMBUS_SLV_ADDR_VALID_Pos)
  1126. /**
  1127. * @brief I2C SMBUS Quick Cmd Bit
  1128. * @param __I2C__ Specifies I2C peripheral
  1129. * @return SMBUS Quick Cmd Bit(R/W)
  1130. */
  1131. #define __LL_I2C_SMBUS_QuickCmdBit(__I2C__) (READ_BIT((__I2C__)->STATUS, I2C_SMBUS_QUICK_CMD_BIT_Msk) >> I2C_SMBUS_QUICK_CMD_BIT_Pos)
  1132. /**
  1133. * @brief Judge SDA Stuck No Recovered or not
  1134. * @param __I2C__ Specifies I2C peripheral
  1135. * @retval 0 SDA Stuck has Recovered
  1136. * @retval 1 SDA Stuck hasn't Recovered
  1137. */
  1138. #define __LL_I2C_IsSDAStuckNoRecovered(__I2C__) \
  1139. (READ_BIT((__I2C__)->STATUS, I2C_SDA_STUCK_NOT_RECOVERED_Msk) >> I2C_SDA_STUCK_NOT_RECOVERED_Pos)
  1140. /**
  1141. * @brief Judge Slave Hold RX FIFO Full or not
  1142. * @param __I2C__ Specifies I2C peripheral
  1143. * @retval 0 Slave Isn't Holding RX FIFO Full
  1144. * @retval 1 Slave Is Holding RX FIFO Full
  1145. */
  1146. #define __LL_I2C_SLV_IsHoldRxFIFOFull(__I2C__) \
  1147. (READ_BIT((__I2C__)->STATUS, I2C_SLV_HOLD_RX_FIFO_FULL_Msk) >> I2C_SLV_HOLD_RX_FIFO_FULL_Pos)
  1148. /**
  1149. * @brief Judge Slave Hold Tx FIFO Empty or not
  1150. * @param __I2C__ Specifies I2C peripheral
  1151. * @retval 0 Slave Isn't Holding Tx FIFO Empty
  1152. * @retval 1 Slave Is Holding Tx FIFO Empty
  1153. */
  1154. #define __LL_I2C_SLV_IsHoldTxFIFOEmpty(__I2C__) \
  1155. (READ_BIT((__I2C__)->STATUS, I2C_SLV_HOLD_TX_FIFO_EMPTY_Msk) >> I2C_SLV_HOLD_TX_FIFO_EMPTY_Pos)
  1156. /**
  1157. * @brief Judge Master Hold RX FIFO Full or not
  1158. * @param __I2C__ Specifies I2C peripheral
  1159. * @retval 0 Master Isn't Holding RX FIFO Full
  1160. * @retval 1 Master Is Holding RX FIFO Full
  1161. */
  1162. #define __LL_I2C_MST_IsHoldRxFIFOFull(__I2C__) \
  1163. (READ_BIT((__I2C__)->STATUS, I2C_MST_HOLD_RX_FIFO_FULL_Msk) >> I2C_MST_HOLD_RX_FIFO_FULL_Pos)
  1164. /**
  1165. * @brief Judge Master Hold Tx FIFO Empty or not
  1166. * @param __I2C__ Specifies I2C peripheral
  1167. * @retval 0 Master Isn't Holding Tx FIFO Empty
  1168. * @retval 1 Master Is Holding Tx FIFO Empty
  1169. */
  1170. #define __LL_I2C_MST_IsHoldTxFIFOEmpty(__I2C__) \
  1171. (READ_BIT((__I2C__)->STATUS, I2C_MST_HOLD_TX_FIFO_EMPTY_Msk) >> I2C_MST_HOLD_TX_FIFO_EMPTY_Pos)
  1172. /**
  1173. * @brief Judge Slave Activity or not
  1174. * @param __I2C__ Specifies I2C peripheral
  1175. * @retval 0 Slave Isn't Activity
  1176. * @retval 1 Slave Is Activity
  1177. */
  1178. #define __LL_I2C_SLV_IsActivity(__I2C__) (READ_BIT((__I2C__)->STATUS, I2C_SLV_ACTIVITY_Msk) >> I2C_SLV_ACTIVITY_Pos)
  1179. /**
  1180. * @brief Judge Master Activity or not
  1181. * @param __I2C__ Specifies I2C peripheral
  1182. * @retval 0 Master Isn't Activity
  1183. * @retval 1 Master Is Activity
  1184. */
  1185. #define __LL_I2C_MST_IsActivity(__I2C__) (READ_BIT((__I2C__)->STATUS, I2C_MST_ACTIVITY_Msk) >> I2C_MST_ACTIVITY_Pos)
  1186. /**
  1187. * @brief Judge RXFIFO Full Entirely or not
  1188. * @param __I2C__ Specifies I2C peripheral
  1189. * @retval 0 RXFIFO isn't full Entirely
  1190. * @retval 1 RXFIFO is full Entirely
  1191. */
  1192. #define __LL_I2C_IsRxFIFOFull(__I2C__) (READ_BIT((__I2C__)->STATUS, I2C_RFF_Msk) >> I2C_RFF_Pos)
  1193. /**
  1194. * @brief Judge RXFIFO Not Empty or not
  1195. * @param __I2C__ Specifies I2C peripheral
  1196. * @retval 0 RXFIO is empty
  1197. * @retval 1 RXFIO isn't empty
  1198. */
  1199. #define __LL_I2C_IsRxFIFONotEmpty(__I2C__) (READ_BIT((__I2C__)->STATUS, I2C_RFNE_Msk) >> I2C_RFNE_Pos)
  1200. /**
  1201. * @brief Judge TXFIFO Empty or not
  1202. * @param __I2C__ Specifies I2C peripheral
  1203. * @retval 0 TXFIFO isn't empty
  1204. * @retval 1 TXFIFO is empty
  1205. */
  1206. #define __LL_I2C_IsTxFIFOEmpty(__I2C__) (READ_BIT((__I2C__)->STATUS, I2C_TFE_Msk) >> I2C_TFE_Pos)
  1207. /**
  1208. * @brief Judge TXFIFO Not Full or not
  1209. * @param __I2C__ Specifies I2C peripheral
  1210. * @retval 0 TXFIFO is Full
  1211. * @retval 1 TXFIFO isn't Full
  1212. */
  1213. #define __LL_I2C_IsTxFIFONotFull(__I2C__) (READ_BIT((__I2C__)->STATUS, I2C_TFNF_Msk) >> I2C_TFNF_Pos)
  1214. /**
  1215. * @brief Judge I2C Activity or not
  1216. * @param __I2C__ Specifies I2C peripheral
  1217. * @retval 0 I2C isn't activity
  1218. * @retval 1 I2C is activity
  1219. */
  1220. #define __LL_I2C_IsActivitySta(__I2C__) (READ_BIT((__I2C__)->STATUS, I2C_ACTIVITY_Msk) >> I2C_ACTIVITY_Pos)
  1221. /**
  1222. * @brief I2C TXFIFO Level Get
  1223. * @param __I2C__ Specifies I2C peripheral
  1224. * @return TXFIFO Level
  1225. */
  1226. #define __LL_I2C_TxFIFOLevel_Get(__I2C__) (READ_BIT((__I2C__)->TXFLR, I2C_TXFLR_Msk) >> I2C_TXFLR_Pos)
  1227. /**
  1228. * @brief I2C RXFIFO Level Get
  1229. * @param __I2C__ Specifies I2C peripheral
  1230. * @return RXFIFO Level
  1231. */
  1232. #define __LL_I2C_RxFIFOLevel_Get(__I2C__) (READ_BIT((__I2C__)->RXFLR, I2C_RXFLR_Msk) >> I2C_RXFLR_Pos)
  1233. /**
  1234. * @brief I2C SDA RX Hold Set
  1235. * @param __I2C__ Specifies I2C peripheral
  1236. * @param hld SDA RX Hold
  1237. * @return None
  1238. */
  1239. #define __LL_I2C_SDARxHold_Set(__I2C__, hld) \
  1240. MODIFY_REG((__I2C__)->SDA_HOLD, I2C_SDA_RX_HOLD_Msk, ((hld & 0xffUL) << I2C_SDA_RX_HOLD_Pos))
  1241. /**
  1242. * @brief I2C SDA TX Hold Set
  1243. * @param __I2C__ Specifies I2C peripheral
  1244. * @param hld SDA TX Hold
  1245. * @return None
  1246. */
  1247. #define __LL_I2C_SDATxHold_Set(__I2C__, hld) \
  1248. MODIFY_REG((__I2C__)->SDA_HOLD, I2C_SDA_TX_HOLD_Msk, ((hld & 0xffffUL) << I2C_SDA_TX_HOLD_Pos))
  1249. /**
  1250. * @brief I2C TX Flush Count Get
  1251. * @param __I2C__ Specifies I2C peripheral
  1252. * @return TX Flush Count
  1253. */
  1254. #define __LL_I2C_TxFlushCnt_Get(__I2C__) (READ_BIT((__I2C__)->TXABSR, I2C_TX_FLUSH_CNT_Msk) >> I2C_TX_FLUSH_CNT_Pos)
  1255. /**
  1256. * @brief Judge Master Abort Source Device Write or not
  1257. * @param __I2C__ Specifies I2C peripheral
  1258. * @retval 0 Abort Source Isn't Device Write
  1259. * @retval 1 Abort Source Is Device Write
  1260. */
  1261. #define __LL_I2C_MST_AbortSrc_IsDevWrite(__I2C__) \
  1262. (READ_BIT((__I2C__)->TXABSR, I2C_ABRT_DEV_WRITE_Msk) >> I2C_ABRT_DEV_WRITE_Pos)
  1263. /**
  1264. * @brief Judge Master Abort Source Device Slave Address No ACK or not
  1265. * @param __I2C__ Specifies I2C peripheral
  1266. * @retval 0 Abort Source Isn't Device Slave Address No ACK
  1267. * @retval 1 Abort Source Is Device Slave Address No ACK
  1268. */
  1269. #define __LL_I2C_MST_AbortSrc_IsDevSlvAddrNoAck(__I2C__) \
  1270. (READ_BIT((__I2C__)->TXABSR, I2C_ABRT_DEV_SLV_ADDR_NOACK_Msk) >> I2C_ABRT_DEV_SLV_ADDR_NOACK_Pos)
  1271. /**
  1272. * @brief Judge Master Abort Source Device No ACK or not
  1273. * @param __I2C__ Specifies I2C peripheral
  1274. * @retval 0 Abort Source Isn't Device No ACK
  1275. * @retval 1 Abort Source Is Device No ACK
  1276. */
  1277. #define __LL_I2C_MST_AbortSrc_IsDevNoAck(__I2C__) \
  1278. (READ_BIT((__I2C__)->TXABSR, I2C_ABRT_DEV_NOACK_Msk) >> I2C_ABRT_DEV_NOACK_Pos)
  1279. /**
  1280. * @brief Judge Master Abort Source SDA Stuck at Low or not
  1281. * @param __I2C__ Specifies I2C peripheral
  1282. * @retval 0 Abort Source Isn't SDA Stuck at Low
  1283. * @retval 1 Abort Source Is SDA Stuck at Low
  1284. */
  1285. #define __LL_I2C_MST_AbortSrc_IsSDAStuckAtLow(__I2C__) \
  1286. (READ_BIT((__I2C__)->TXABSR, I2C_ABRT_SDA_STUCK_AT_LOW_Msk) >> I2C_ABRT_SDA_STUCK_AT_LOW_Pos)
  1287. /**
  1288. * @brief Judge Master Abort Source User Abort or not
  1289. * @param __I2C__ Specifies I2C peripheral
  1290. * @retval 0 Abort Source Isn't User Abort
  1291. * @retval 1 Abort Source Is User Abort
  1292. */
  1293. #define __LL_I2C_MST_AbortSrc_IsUserAbort(__I2C__) \
  1294. (READ_BIT((__I2C__)->TXABSR, I2C_ABRT_USER_ABRT_Msk) >> I2C_ABRT_USER_ABRT_Pos)
  1295. /**
  1296. * @brief Judge Slave Abort Source Slave Read In TX or not
  1297. * @param __I2C__ Specifies I2C peripheral
  1298. * @retval 0 Abort Source Isn't Slave Read In TX
  1299. * @retval 1 Abort Source Is Slave Read In TX
  1300. */
  1301. #define __LL_I2C_SLV_AbortSrc_IsSlvReadInTx(__I2C__) \
  1302. (READ_BIT((__I2C__)->TXABSR, I2C_ABRT_SLVRD_INTX_Msk) >> I2C_ABRT_SLVRD_INTX_Pos)
  1303. /**
  1304. * @brief Judge Slave Abort Source Slave Lost Bus or not
  1305. * @param __I2C__ Specifies I2C peripheral
  1306. * @retval 0 Abort Source Isn't Slave Lost Bus
  1307. * @retval 1 Abort Source Is Slave Lost Bus
  1308. */
  1309. #define __LL_I2C_SLV_AbortSrc_IsSlvLostBus(__I2C__) \
  1310. (READ_BIT((__I2C__)->TXABSR, I2C_ABRT_SLV_ARBLOST_Msk) >> I2C_ABRT_SLV_ARBLOST_Pos)
  1311. /**
  1312. * @brief Judge Slave Abort Source Slave Flush TXFIFO or not
  1313. * @param __I2C__ Specifies I2C peripheral
  1314. * @retval 0 Abort Source Isn't Slave Flush TXFIFO
  1315. * @retval 1 Abort Source Is Slave Flush TXFIFO
  1316. */
  1317. #define __LL_I2C_SLV_AbortSrc_IsSlvFlushTxFIFO(__I2C__) \
  1318. (READ_BIT((__I2C__)->TXABSR, I2C_ABRT_SLVFLUSH_TXFIFO_Msk) >> I2C_ABRT_SLVFLUSH_TXFIFO_Pos)
  1319. /**
  1320. * @brief Judge Abort Source ARB Lost or not
  1321. * @param __I2C__ Specifies I2C peripheral
  1322. * @retval 0 Abort Source Isn't ARB Lost
  1323. * @retval 1 Abort Source Is ARB Lost
  1324. */
  1325. #define __LL_I2C_AbortSrc_IsArbLost(__I2C__) \
  1326. (READ_BIT((__I2C__)->TXABSR, I2C_ARB_LOST_Msk) >> I2C_ARB_LOST_Pos)
  1327. /**
  1328. * @brief Judge Abort Source Master Disable or not
  1329. * @param __I2C__ Specifies I2C peripheral
  1330. * @retval 0 Abort Source Isn't Master Disable
  1331. * @retval 1 Abort Source Is Master Disable
  1332. */
  1333. #define __LL_I2C_AbortSrc_IsMasterDis(__I2C__) \
  1334. (READ_BIT((__I2C__)->TXABSR, I2C_ABRT_MASTER_DIS_Msk) >> I2C_ABRT_MASTER_DIS_Pos)
  1335. /**
  1336. * @brief Judge Master Abort Source 10bit Read No Restart or not
  1337. * @param __I2C__ Specifies I2C peripheral
  1338. * @retval 0 Abort Source Isn't 10bit Read No Restart
  1339. * @retval 1 Abort Source Is 10bit Read No Restart
  1340. */
  1341. #define __LL_I2C_MST_AbortSrc_Is10bReadNoRestart(__I2C__) \
  1342. (READ_BIT((__I2C__)->TXABSR, I2C_ABRT_10B_RD_NORSTRT_Msk) >> I2C_ABRT_10B_RD_NORSTRT_Pos)
  1343. /**
  1344. * @brief Judge Master Abort Source Send Start No Restart or not
  1345. * @param __I2C__ Specifies I2C peripheral
  1346. * @retval 0 Abort Source Isn't Send Start No Restart
  1347. * @retval 1 Abort Source Is Send Start No Restart
  1348. */
  1349. #define __LL_I2C_MST_AbortSrc_IsSendStartNoRestart(__I2C__) \
  1350. (READ_BIT((__I2C__)->TXABSR, I2C_ABRT_SBYTE_NORSTRT_Msk) >> I2C_ABRT_SBYTE_NORSTRT_Pos)
  1351. /**
  1352. * @brief Judge Master Abort Source HS No Restart or not
  1353. * @param __I2C__ Specifies I2C peripheral
  1354. * @retval 0 Abort Source Isn't HS No Restart
  1355. * @retval 1 Abort Source Is HS No Restart
  1356. */
  1357. #define __LL_I2C_MST_AbortSrc_IsHsNoRestart(__I2C__) \
  1358. (READ_BIT((__I2C__)->TXABSR, I2C_ABRT_HS_NORSTRT_Msk) >> I2C_ABRT_HS_NORSTRT_Pos)
  1359. /**
  1360. * @brief Judge Master Abort Source Send Start ACK Detect or not
  1361. * @param __I2C__ Specifies I2C peripheral
  1362. * @retval 0 Abort Source Isn't Send Start ACK Detect
  1363. * @retval 1 Abort Source Is Send Start ACK Detect
  1364. */
  1365. #define __LL_I2C_MST_AbortSrc_IsSendStartAckDet(__I2C__) \
  1366. (READ_BIT((__I2C__)->TXABSR, I2C_ABRT_SBYTE_ACKDET_Msk) >> I2C_ABRT_SBYTE_ACKDET_Pos)
  1367. /**
  1368. * @brief Judge Master Abort Source HS ACK Detect or not
  1369. * @param __I2C__ Specifies I2C peripheral
  1370. * @retval 0 Abort Source Isn't HS ACK Detect
  1371. * @retval 1 Abort Source Is HS ACK Detect
  1372. */
  1373. #define __LL_I2C_MST_AbortSrc_IsHsAckDet(__I2C__) \
  1374. (READ_BIT((__I2C__)->TXABSR, I2C_ABRT_HS_ACKDET_Msk) >> I2C_ABRT_HS_ACKDET_Pos)
  1375. /**
  1376. * @brief Judge Master Abort Source Genaral Call Read or not
  1377. * @param __I2C__ Specifies I2C peripheral
  1378. * @retval 0 Abort Source Isn't Genaral Call Read
  1379. * @retval 1 Abort Source Is Genaral Call Read
  1380. */
  1381. #define __LL_I2C_MST_AbortSrc_IsGenCallRead(__I2C__) \
  1382. (READ_BIT((__I2C__)->TXABSR, I2C_ABRT_GCALL_READ_Msk) >> I2C_ABRT_GCALL_READ_Pos)
  1383. /**
  1384. * @brief Judge Master Abort Source Genaral Call No ACK or not
  1385. * @param __I2C__ Specifies I2C peripheral
  1386. * @retval 0 Abort Source Isn't Genaral Call No ACK
  1387. * @retval 1 Abort Source Is Genaral Call No ACK
  1388. */
  1389. #define __LL_I2C_MST_AbortSrc_IsGenCallNoAck(__I2C__) \
  1390. (READ_BIT((__I2C__)->TXABSR, I2C_ABRT_GCALL_NOACK_Msk) >> I2C_ABRT_GCALL_NOACK_Pos)
  1391. /**
  1392. * @brief Judge Master Abort Source TX Data No ACK or not
  1393. * @param __I2C__ Specifies I2C peripheral
  1394. * @retval 0 Abort Source Isn't TX Data No ACK
  1395. * @retval 1 Abort Source Is TX Data No ACK
  1396. */
  1397. #define __LL_I2C_MST_AbortSrc_IsTxDataNoAck(__I2C__) \
  1398. (READ_BIT((__I2C__)->TXABSR, I2C_ABRT_TXDATA_NOACK_Msk) >> I2C_ABRT_TXDATA_NOACK_Pos)
  1399. /**
  1400. * @brief Judge Master Abort Source 10b Address 2 No ACK or not
  1401. * @param __I2C__ Specifies I2C peripheral
  1402. * @retval 0 Abort Source Isn't 10b Address 2 No ACK
  1403. * @retval 1 Abort Source Is 10b Address 2 No ACK
  1404. */
  1405. #define __LL_I2C_MST_AbortSrc_Is10bAddr2NoAck(__I2C__) \
  1406. (READ_BIT((__I2C__)->TXABSR, I2C_ABRT_10ADDR2_NOACK_Msk) >> I2C_ABRT_10ADDR2_NOACK_Pos)
  1407. /**
  1408. * @brief Judge Master Abort Source 10b Address 1 No ACK or not
  1409. * @param __I2C__ Specifies I2C peripheral
  1410. * @retval 0 Abort Source Isn't 10b Address 1 No ACK
  1411. * @retval 1 Abort Source Is 10b Address 1 No ACK
  1412. */
  1413. #define __LL_I2C_MST_AbortSrc_Is10bAddr1NoAck(__I2C__) \
  1414. (READ_BIT((__I2C__)->TXABSR, I2C_ABRT_10ADDR1_NOACK_Msk) >> I2C_ABRT_10ADDR1_NOACK_Pos)
  1415. /**
  1416. * @brief Judge Master Abort Source 7b Address No ACK or not
  1417. * @param __I2C__ Specifies I2C peripheral
  1418. * @retval 0 Abort Source Isn't 7b Address No ACK
  1419. * @retval 1 Abort Source Is 7b Address No ACK
  1420. */
  1421. #define __LL_I2C_MST_AbortSrc_Is7bAddrNoAck(__I2C__) \
  1422. (READ_BIT((__I2C__)->TXABSR, I2C_ABRT_7B_ADDR_NOACK_Msk) >> I2C_ABRT_7B_ADDR_NOACK_Pos)
  1423. /**
  1424. * @brief I2C Slave Force Data No ACK Set
  1425. * @param __I2C__ Specifies I2C peripheral
  1426. * @return None
  1427. */
  1428. #define __LL_I2C_SLV_ForceDataNoAck_Set(__I2C__) SET_BIT((__I2C__)->NACKEN, I2C_SLV_DATA_NACK_Msk)
  1429. /**
  1430. * @brief I2C Slave Force Data No ACK Clear
  1431. * @param __I2C__ Specifies I2C peripheral
  1432. * @return None
  1433. */
  1434. #define __LL_I2C_SLV_ForceDataNoAck_Clr(__I2C__) CLEAR_BIT((__I2C__)->NACKEN, I2C_SLV_DATA_NACK_Msk)
  1435. /**
  1436. * @brief I2C TX DMA Enable
  1437. * @param __I2C__ Specifies I2C peripheral
  1438. * @return None
  1439. */
  1440. #define __LL_I2C_TxDMA_En(__I2C__) SET_BIT((__I2C__)->DMACT, I2C_DMA_TDMAE_Msk)
  1441. /**
  1442. * @brief I2C TX DMA Disable
  1443. * @param __I2C__ Specifies I2C peripheral
  1444. * @return None
  1445. */
  1446. #define __LL_I2C_TxDMA_Dis(__I2C__) CLEAR_BIT((__I2C__)->DMACT, I2C_DMA_TDMAE_Msk)
  1447. /**
  1448. * @brief I2C RX DMA Enable
  1449. * @param __I2C__ Specifies I2C peripheral
  1450. * @return None
  1451. */
  1452. #define __LL_I2C_RxDMA_En(__I2C__) SET_BIT((__I2C__)->DMACT, I2C_DMA_RDMAE_Msk)
  1453. /**
  1454. * @brief I2C RX DMA Disable
  1455. * @param __I2C__ Specifies I2C peripheral
  1456. * @return None
  1457. */
  1458. #define __LL_I2C_RxDMA_Dis(__I2C__) CLEAR_BIT((__I2C__)->DMACT, I2C_DMA_RDMAE_Msk)
  1459. /**
  1460. * @brief I2C TX DMA Trigger Level Set
  1461. * @param __I2C__ Specifies I2C peripheral
  1462. * @param tl TX DMA Trigger Level
  1463. * @return None
  1464. */
  1465. #define __LL_I2C_TxDMATriggerLevel_Set(__I2C__, tl) \
  1466. MODIFY_REG((__I2C__)->DMATDLR, I2C_DMA_DMATDL_Msk, ((tl & 0xfUL) << I2C_DMA_DMATDL_Pos))
  1467. /**
  1468. * @brief I2C RX DMA Trigger Level Set
  1469. * @param __I2C__ Specifies I2C peripheral
  1470. * @param tl RX DMA Trigger Level
  1471. * @return None
  1472. */
  1473. #define __LL_I2C_RxDMATriggerLevel_Set(__I2C__, tl) \
  1474. MODIFY_REG((__I2C__)->DMARDLR, I2C_DMA_DMARDL_Msk, (((tl-1) & 0xfUL) << I2C_DMA_DMARDL_Pos))
  1475. #define __LL_I2C_SDA_Setup_Set(__I2C__, val) \
  1476. MODIFY_REG((__I2C__)->SDA_SETUP, I2C_SDA_SETUP_Msk, ((val & 0xffUL) << I2C_SDA_SETUP_Pos))
  1477. /**
  1478. * @brief I2C ACK Genaral Call Enable
  1479. * @param __I2C__ Specifies I2C peripheral
  1480. * @return None
  1481. */
  1482. #define __LL_I2C_AckGenCall_En(__I2C__) SET_BIT((__I2C__)->GCACK, I2C_ACK_GEN_CALL_Msk)
  1483. /**
  1484. * @brief I2C ACK Genaral Call Disable
  1485. * @param __I2C__ Specifies I2C peripheral
  1486. * @return None
  1487. */
  1488. #define __LL_I2C_AckGenCall_Dis(__I2C__) CLEAR_BIT((__I2C__)->GCACK, I2C_ACK_GEN_CALL_Msk)
  1489. /**
  1490. * @brief Judge Slave RX Data Lost or not
  1491. * @param __I2C__ Specifies I2C peripheral
  1492. * @retval 0 Slave Isn't RX Data Lost
  1493. * @retval 1 Slave Is RX Data Lost
  1494. */
  1495. #define __LL_I2C_SLV_IsRxDataLost(__I2C__) \
  1496. (READ_BIT((__I2C__)->ENST, I2C_SLV_RX_DATA_LOST_Msk) >> I2C_SLV_RX_DATA_LOST_Pos)
  1497. /**
  1498. * @brief Judge Slave Disable While Busy or not
  1499. * @param __I2C__ Specifies I2C peripheral
  1500. * @retval 0 Isn't Slave Disable While Busy
  1501. * @retval 1 Is Slave Disable While Busy
  1502. */
  1503. #define __LL_I2C_SLV_IsSlvDisWhileBusy(__I2C__) \
  1504. (READ_BIT((__I2C__)->ENST, I2C_SLVDIS_WHILEBUSY_Msk) >> I2C_SLVDIS_WHILEBUSY_Pos)
  1505. /**
  1506. * @brief Judge I2C Enable or not
  1507. * @param __I2C__ Specifies I2C peripheral
  1508. * @retval 0 I2C Isn't Enable
  1509. * @retval 1 I2C Is Enable
  1510. */
  1511. #define __LL_I2C_IsEnable(__I2C__) (READ_BIT((__I2C__)->ENST, I2C_EN_Msk) >> I2C_EN_Pos)
  1512. /**
  1513. * @brief I2C FS Spike Lengh Set
  1514. * @param __I2C__ Specifies I2C peripheral
  1515. * @param len FS Spike Lengh
  1516. * @return None
  1517. */
  1518. #define __LL_I2C_FsSpkLen_Set(__I2C__, len) \
  1519. MODIFY_REG((__I2C__)->FS_SPKLEN, I2C_FS_SPKLEN_Msk, ((len & 0xffUL) << I2C_FS_SPKLEN_Pos))
  1520. /**
  1521. * @brief I2C Restart Detect RAW Interrupt Status Clear
  1522. * @param __I2C__ Specifies I2C peripheral
  1523. * @return Read Value, not use
  1524. */
  1525. #define __LL_I2C_RestartDetRawIntSta_Clr(__I2C__) \
  1526. (READ_BIT((__I2C__)->RSDETCR, I2C_CLR_RESTART_DET_Msk) >> I2C_CLR_RESTART_DET_Pos)
  1527. /**
  1528. * @brief I2C SCL Stuck at Low Timeout Set
  1529. * @param __I2C__ Specifies I2C peripheral
  1530. * @param val Timeout Value
  1531. * @return None
  1532. */
  1533. #define __LL_I2C_SCLStuckAtLowTimeout_Set(__I2C__, val) MODIFY_REG((__I2C__)->SCLLTO,\
  1534. I2C_SCL_STK_LOW_TIMEOUT_Msk, ((val & 0xffffffffUL) << I2C_SCL_STK_LOW_TIMEOUT_Pos))
  1535. /**
  1536. * @brief I2C SDA Stuck at Low Timeout Set
  1537. * @param __I2C__ Specifies I2C peripheral
  1538. * @param val Timeout Value
  1539. * @return None
  1540. */
  1541. #define __LL_I2C_SDAStuckAtLowTimeout_Set(__I2C__, val) MODIFY_REG((__I2C__)->SDALTO,\
  1542. I2C_SDA_STK_LOW_TIMEOUT_Msk, ((val & 0xffffffffUL) << I2C_SDA_STK_LOW_TIMEOUT_Pos))
  1543. /**
  1544. * @brief I2C SCL Stuck Detect RAW Interrupt Status Clear
  1545. * @param __I2C__ Specifies I2C peripheral
  1546. * @return Read Value, not use
  1547. */
  1548. #define __LL_I2C_SCLStuckDetRawIntSta_Clr(__I2C__) \
  1549. (READ_BIT((__I2C__)->SSTDETCR, I2C_CLR_SCL_STK_Msk) >> I2C_CLR_SCL_STK_Pos)
  1550. /**
  1551. * @brief I2C Device ID Set
  1552. * @param __I2C__ Specifies I2C peripheral
  1553. * @param id Device ID
  1554. * @return None
  1555. */
  1556. #define __LL_I2C_DeviceID_Set(__I2C__, id) MODIFY_REG((__I2C__)->DEVICE_ID, I2C_DEV_ID_Msk, ((id & 0xffffffUL) << I2C_DEV_ID_Pos))
  1557. /**
  1558. * @brief I2C SMBUS Clock Low Sext Timeout Set
  1559. * @param __I2C__ Specifies I2C peripheral
  1560. * @param val Timeout Value
  1561. * @return None
  1562. */
  1563. #define __LL_I2C_SMBUS_ClkLowSextTimeout_Set(__I2C__, val) MODIFY_REG((__I2C__)->TSEXT,\
  1564. I2C_SMBUS_CLK_LOW_SEXT_TIMEOUT_Msk, ((val & 0xffffffffUL) << I2C_SMBUS_CLK_LOW_SEXT_TIMEOUT_Pos))
  1565. /**
  1566. * @brief I2C SMBUS Clock Low Mext Timeout Set
  1567. * @param __I2C__ Specifies I2C peripheral
  1568. * @param val Timeout Value
  1569. * @return None
  1570. */
  1571. #define __LL_I2C_SMBUS_ClkLowMextTimeout_Set(__I2C__, val) MODIFY_REG((__I2C__)->TMEXT,\
  1572. I2C_SMBUS_CLK_LOW_MEXT_TIMEOUT_Msk, ((val & 0xffffffffUL) << I2C_SMBUS_CLK_LOW_MEXT_TIMEOUT_Pos))
  1573. /**
  1574. * @brief I2C SMBUS Thigh Max Bus Idle Count Set
  1575. * @param __I2C__ Specifies I2C peripheral
  1576. * @param cnt Count
  1577. * @return None
  1578. */
  1579. #define __LL_I2C_SMBUS_ThighMaxBusIdleCnt_Set(__I2C__, cnt) MODIFY_REG((__I2C__)->IDCNT,\
  1580. I2C_SMBUS_THIGH_MAX_BUS_IDLE_CNT_Msk, ((cnt & 0xffffUL) << I2C_SMBUS_THIGH_MAX_BUS_IDLE_CNT_Pos))
  1581. /**
  1582. * @brief Judge SMBUS is alert detect or not
  1583. * @param __I2C__ Specifies I2C peripheral
  1584. * @retval 0 SMBUS isn't alert detect
  1585. * @retval 1 SMBUS is alert detect
  1586. */
  1587. #define __LL_I2C_SMBUS_IsAlertDet(__I2C__) \
  1588. (READ_BIT((__I2C__)->SMINTRST, I2C_SMBUS_ALERT_DET_INT_STA_Msk) << I2C_SMBUS_ALERT_DET_INT_STA_Pos)
  1589. /**
  1590. * @brief Judge SMBUS is suspend detect or not
  1591. * @param __I2C__ Specifies I2C peripheral
  1592. * @retval 0 SMBUS isn't suspend detect
  1593. * @retval 1 SMBUS is suspend detect
  1594. */
  1595. #define __LL_I2C_SMBUS_IsSuspendDet(__I2C__) \
  1596. (READ_BIT((__I2C__)->SMINTRST, I2C_SMBUS_SUSPEND_DET_INT_STA_Msk) << I2C_SMBUS_SUSPEND_DET_INT_STA_Pos)
  1597. /**
  1598. * @brief Judge SMBUS is slave RX PEC NACK or not
  1599. * @param __I2C__ Specifies I2C peripheral
  1600. * @retval 0 SMBUS isn't slave RX PEC NACK
  1601. * @retval 1 SMBUS is slave RX PEC NACK
  1602. */
  1603. #define __LL_I2C_SMBUS_IsSlvRxPecNack(__I2C__) \
  1604. (READ_BIT((__I2C__)->SMINTRST, I2C_SLV_RX_PEC_NACK_INT_STA_Msk) << I2C_SLV_RX_PEC_NACK_INT_STA_Pos)
  1605. /**
  1606. * @brief Judge SMBUS is ARP assgn address cmd detect or not
  1607. * @param __I2C__ Specifies I2C peripheral
  1608. * @retval 0 SMBUS isn't ARP assgn address cmd detect
  1609. * @retval 1 SMBUS is ARP assgn address cmd detect
  1610. */
  1611. #define __LL_I2C_SMBUS_IsARPAssgnAddrCmdDet(__I2C__) \
  1612. (READ_BIT((__I2C__)->SMINTRST, I2C_ARP_ASSGN_ADDR_CMD_DET_INT_STA_Msk) << I2C_ARP_ASSGN_ADDR_CMD_DET_INT_STA_Pos)
  1613. /**
  1614. * @brief Judge SMBUS is ARP get UDID cmd detect or not
  1615. * @param __I2C__ Specifies I2C peripheral
  1616. * @retval 0 SMBUS isn't ARP get UDID cmd detect
  1617. * @retval 1 SMBUS is ARP get UDID cmd detect
  1618. */
  1619. #define __LL_I2C_SMBUS_IsARPGetUdidCmdDet(__I2C__) \
  1620. (READ_BIT((__I2C__)->SMINTRST, I2C_ARP_GET_UDID_CMD_DET_INT_STA_Msk) << I2C_ARP_GET_UDID_CMD_DET_INT_STA_Pos)
  1621. /**
  1622. * @brief Judge SMBUS is ARP reset cmd detect or not
  1623. * @param __I2C__ Specifies I2C peripheral
  1624. * @retval 0 SMBUS isn't ARP reset cmd detect
  1625. * @retval 1 SMBUS is ARP reset cmd detect
  1626. */
  1627. #define __LL_I2C_SMBUS_IsARPRstCmdDet(__I2C__) \
  1628. (READ_BIT((__I2C__)->SMINTRST, I2C_ARP_RST_CMD_DET_INT_STA_Msk) << I2C_ARP_RST_CMD_DET_INT_STA_Pos)
  1629. /**
  1630. * @brief Judge SMBUS is ARP prepare cmd detect or not
  1631. * @param __I2C__ Specifies I2C peripheral
  1632. * @retval 0 SMBUS isn't ARP prepare cmd detect
  1633. * @retval 1 SMBUS is ARP prepare cmd detect
  1634. */
  1635. #define __LL_I2C_SMBUS_IsARPPrepareCmdDet(__I2C__) \
  1636. (READ_BIT((__I2C__)->SMINTRST, I2C_ARP_PREPARE_CMD_DET_INT_STA_Msk) << I2C_ARP_PREPARE_CMD_DET_INT_STA_Pos)
  1637. /**
  1638. * @brief Judge SMBUS is host nofity mst detect or not
  1639. * @param __I2C__ Specifies I2C peripheral
  1640. * @retval 0 SMBUS isn't host nofity mst detect
  1641. * @retval 1 SMBUS is host nofity mst detect
  1642. */
  1643. #define __LL_I2C_SMBUS_IsHostNotifyMstDet(__I2C__) \
  1644. (READ_BIT((__I2C__)->SMINTRST, I2C_HOST_NOTIFY_MST_DET_INT_STA_Msk) << I2C_HOST_NOTIFY_MST_DET_INT_STA_Pos)
  1645. /**
  1646. * @brief Judge SMBUS is quick cmd detect or not
  1647. * @param __I2C__ Specifies I2C peripheral
  1648. * @retval 0 SMBUS isn't quick cmd detect
  1649. * @retval 1 SMBUS is quick cmd detect
  1650. */
  1651. #define __LL_I2C_SMBUS_IsQuickCmdDet(__I2C__) \
  1652. (READ_BIT((__I2C__)->SMINTRST, I2C_QUICK_CMD_DET_INT_STA_Msk) << I2C_QUICK_CMD_DET_INT_STA_Pos)
  1653. /**
  1654. * @brief Judge SMBUS is mst clock extend timeout or not
  1655. * @param __I2C__ Specifies I2C peripheral
  1656. * @retval 0 SMBUS isn't mst clock extend timeout
  1657. * @retval 1 SMBUS is mst clock extend timeout
  1658. */
  1659. #define __LL_I2C_SMBUS_IsMstClkExtendTimeout(__I2C__) \
  1660. (READ_BIT((__I2C__)->SMINTRST, I2C_MST_CLK_EXTND_TIMEOUT_INT_STA_Msk) << I2C_MST_CLK_EXTND_TIMEOUT_INT_STA_Pos)
  1661. /**
  1662. * @brief Judge SMBUS is slave clock extend timeout or not
  1663. * @param __I2C__ Specifies I2C peripheral
  1664. * @retval 0 SMBUS isn't slave clock extend timeout
  1665. * @retval 1 SMBUS is slave clock extend timeout
  1666. */
  1667. #define __LL_I2C_SMBUS_IsSlvClkExtendTimeout(__I2C__) \
  1668. (READ_BIT((__I2C__)->SMINTRST, I2C_SLV_CLK_EXTND_TIMEOUT_INT_STA_Msk) << I2C_SLV_CLK_EXTND_TIMEOUT_INT_STA_Pos)
  1669. /**
  1670. * @brief SMBUS alert detect interrupt enable
  1671. * @param __I2C__ Specifies I2C peripheral
  1672. * @return None
  1673. */
  1674. #define __LL_I2C_SMBUS_AlertDet_INT_En(__I2C__) SET_BIT((__I2C__)->SMINTRMS, I2C_SMBUS_ALERT_DET_INT_EN_Msk)
  1675. /**
  1676. * @brief SMBUS alert detect interrupt Disable
  1677. * @param __I2C__ Specifies I2C peripheral
  1678. * @return None
  1679. */
  1680. #define __LL_I2C_SMBUS_AlertDet_INT_Dis(__I2C__) CLEAR_BIT((__I2C__)->SMINTRMS, I2C_SMBUS_ALERT_DET_INT_EN_Msk)
  1681. /**
  1682. * @brief SMBUS Suspend detect interrupt enable
  1683. * @param __I2C__ Specifies I2C peripheral
  1684. * @return None
  1685. */
  1686. #define __LL_I2C_SMBUS_SuspendDet_INT_En(__I2C__) SET_BIT((__I2C__)->SMINTRMS, I2C_SMBUS_SUSPEND_DET_INT_EN_Msk)
  1687. /**
  1688. * @brief SMBUS Suspend detect interrupt disable
  1689. * @param __I2C__ Specifies I2C peripheral
  1690. * @return None
  1691. */
  1692. #define __LL_I2C_SMBUS_SuspendDet_INT_Dis(__I2C__) CLEAR_BIT((__I2C__)->SMINTRMS, I2C_SMBUS_SUSPEND_DET_INT_EN_Msk)
  1693. /**
  1694. * @brief SMBUS slave RX PEC NACK interrupt enable
  1695. * @param __I2C__ Specifies I2C peripheral
  1696. * @return None
  1697. */
  1698. #define __LL_I2C_SMBUS_SlvRxPecNack_INT_En(__I2C__) SET_BIT((__I2C__)->SMINTRMS, I2C_SLV_RX_PEC_NACK_INT_EN_Msk)
  1699. /**
  1700. * @brief SMBUS slave RX PEC NACK interrupt disable
  1701. * @param __I2C__ Specifies I2C peripheral
  1702. * @return None
  1703. */
  1704. #define __LL_I2C_SMBUS_SlvRxPecNack_INT_Dis(__I2C__) CLEAR_BIT((__I2C__)->SMINTRMS, I2C_SLV_RX_PEC_NACK_INT_EN_Msk)
  1705. /**
  1706. * @brief SBMUS ARP assgn addr cmd detect interrupt enable
  1707. * @param __I2C__ Specifies I2C peripheral
  1708. * @return None
  1709. */
  1710. #define __LL_I2C_SMBUS_ARPAssgnAddrCmdDet_INT_En(__I2C__) SET_BIT((__I2C__)->SMINTRMS, I2C_ARP_ASSGN_ADDR_CMD_DET_INT_EN_Msk)
  1711. /**
  1712. * @brief SBMUS ARP assgn addr cmd detect interrupt disable
  1713. * @param __I2C__ Specifies I2C peripheral
  1714. * @return None
  1715. */
  1716. #define __LL_I2C_SMBUS_ARPAssgnAddrCmdDet_INT_Dis(__I2C__) CLEAR_BIT((__I2C__)->SMINTRMS, I2C_ARP_ASSGN_ADDR_CMD_DET_INT_EN_Msk)
  1717. /**
  1718. * @brief SMBUS ARP get UDID cmd detect interrupt enable
  1719. * @param __I2C__ Specifies I2C peripheral
  1720. * @return None
  1721. */
  1722. #define __LL_I2C_SMBUS_ARPGetUdidCmdDet_INT_En(__I2C__) SET_BIT((__I2C__)->SMINTRMS, I2C_ARP_GET_UDID_CMD_DET_INT_EN_Msk)
  1723. /**
  1724. * @brief SMBUS ARP get UDID cmd detect interrupt disable
  1725. * @param __I2C__ Specifies I2C peripheral
  1726. * @return None
  1727. */
  1728. #define __LL_I2C_SMBUS_ARPGetUdidCmdDet_INT_Dis(__I2C__) CLEAR_BIT((__I2C__)->SMINTRMS, I2C_ARP_GET_UDID_CMD_DET_INT_EN_Msk)
  1729. /**
  1730. * @brief SMBUS ARP reset cmd detect interrupt enable
  1731. * @param __I2C__ Specifies I2C peripheral
  1732. * @return None
  1733. */
  1734. #define __LL_I2C_SMBUS_ARPRstCmdDet_INT_En(__I2C__) SET_BIT((__I2C__)->SMINTRMS, I2C_ARP_RST_CMD_DET_INT_EN_Msk)
  1735. /**
  1736. * @brief SMBUS ARP reset cmd detect interrupt disable
  1737. * @param __I2C__ Specifies I2C peripheral
  1738. * @return None
  1739. */
  1740. #define __LL_I2C_SMBUS_ARPRstCmdDet_INT_Dis(__I2C__) CLEAR_BIT((__I2C__)->SMINTRMS, I2C_ARP_RST_CMD_DET_INT_EN_Msk)
  1741. /**
  1742. * @brief SMBUS ARP prepare cmd detect interrupt enable
  1743. * @param __I2C__ Specifies I2C peripheral
  1744. * @return None
  1745. */
  1746. #define __LL_I2C_SMBUS_ARPPrepareCmdDet_INT_En(__I2C__) SET_BIT((__I2C__)->SMINTRMS, I2C_ARP_PREPARE_CMD_DET_INT_EN_Msk)
  1747. /**
  1748. * @brief SMBUS ARP prepare cmd detect interrupt disable
  1749. * @param __I2C__ Specifies I2C peripheral
  1750. * @return None
  1751. */
  1752. #define __LL_I2C_SMBUS_ARPPrepareCmdDet_INT_Dis(__I2C__) CLEAR_BIT((__I2C__)->SMINTRMS, I2C_ARP_PREPARE_CMD_DET_INT_EN_Msk)
  1753. /**
  1754. * @brief SMBUS host notify master detect interrupt enable
  1755. * @param __I2C__ Specifies I2C peripheral
  1756. * @return None
  1757. */
  1758. #define __LL_I2C_SMBUS_HostNotifyMstDet_INT_En(__I2C__) SET_BIT((__I2C__)->SMINTRMS, I2C_HOST_NOTIFY_MST_DET_INT_EN_Msk)
  1759. /**
  1760. * @brief SMBUS host notify master detect interrupt disable
  1761. * @param __I2C__ Specifies I2C peripheral
  1762. * @return None
  1763. */
  1764. #define __LL_I2C_SMBUS_HostNotifyMstDet_INT_Dis(__I2C__) CLEAR_BIT((__I2C__)->SMINTRMS, I2C_HOST_NOTIFY_MST_DET_INT_EN_Msk)
  1765. /**
  1766. * @brief SMBUS quick cmd detect interrupt enable
  1767. * @param __I2C__ Specifies I2C peripheral
  1768. * @return None
  1769. */
  1770. #define __LL_I2C_SMBUS_QuickCmdDet_INT_En(__I2C__) SET_BIT((__I2C__)->SMINTRMS, I2C_QUICK_CMD_DET_INT_EN_Msk)
  1771. /**
  1772. * @brief SMBUS quick cmd detect interrupt disable
  1773. * @param __I2C__ Specifies I2C peripheral
  1774. * @return None
  1775. */
  1776. #define __LL_I2C_SMBUS_QuickCmdDet_INT_Dis(__I2C__) CLEAR_BIT((__I2C__)->SMINTRMS, I2C_QUICK_CMD_DET_INT_EN_Msk)
  1777. /**
  1778. * @brief SMBUS master clock extend timeout interrupt enable
  1779. * @param __I2C__ Specifies I2C peripheral
  1780. * @return None
  1781. */
  1782. #define __LL_I2C_SMBUS_MstClkExtendTimeout_INT_En(__I2C__) SET_BIT((__I2C__)->SMINTRMS, I2C_MST_CLK_EXTND_TIMEOUT_INT_EN_Msk)
  1783. /**
  1784. * @brief SMBUS master clock extend timeout interrupt disable
  1785. * @param __I2C__ Specifies I2C peripheral
  1786. * @return None
  1787. */
  1788. #define __LL_I2C_SMBUS_MstClkExtendTimeout_INT_Dis(__I2C__) CLEAR_BIT((__I2C__)->SMINTRMS, I2C_MST_CLK_EXTND_TIMEOUT_INT_EN_Msk)
  1789. /**
  1790. * @brief SMBUS slave clock extend timeout interrupt enable
  1791. * @param __I2C__ Specifies I2C peripheral
  1792. * @return None
  1793. */
  1794. #define __LL_I2C_SMBUS_SlvClkExtendTimeout_INT_En(__I2C__) SET_BIT((__I2C__)->SMINTRMS, I2C_SLV_CLK_EXTND_TIMEOUT_INT_EN_Msk)
  1795. /**
  1796. * @brief SMBUS slave clock extend timeout interrupt disable
  1797. * @param __I2C__ Specifies I2C peripheral
  1798. * @return None
  1799. */
  1800. #define __LL_I2C_SMBUS_SlvClkExtendTimeout_INT_Dis(__I2C__) CLEAR_BIT((__I2C__)->SMINTRMS, I2C_SLV_CLK_EXTND_TIMEOUT_INT_EN_Msk)
  1801. /**
  1802. * @brief Judge SMBUS is alert detect raw or not
  1803. * @param __I2C__ Specifies I2C peripheral
  1804. * @retval 0 SMBUS isn't alert detect raw
  1805. * @retval 1 SMBUS is alert detect raw
  1806. */
  1807. #define __LL_I2C_SMBUS_IsAlertDetRaw(__I2C__) \
  1808. (READ_BIT((__I2C__)->SMINTRRST, I2C_SMBUS_ALERT_DET_RAW_INT_STA_Msk) << I2C_SMBUS_ALERT_DET_RAW_INT_STA_Pos)
  1809. /**
  1810. * @brief Judge SMBUS is suspend detect raw or not
  1811. * @param __I2C__ Specifies I2C peripheral
  1812. * @retval 0 SMBUS isn't suspend detect raw
  1813. * @retval 1 SMBUS is suspend detect raw
  1814. */
  1815. #define __LL_I2C_SMBUS_IsSuspendDetRaw(__I2C__) \
  1816. (READ_BIT((__I2C__)->SMINTRRST, I2C_SMBUS_SUSPEND_DET_RAW_INT_STA_Msk) << I2C_SMBUS_SUSPEND_DET_RAW_INT_STA_Pos)
  1817. /**
  1818. * @brief Judge SMBUS is slave RX PEC NACK or not
  1819. * @param __I2C__ Specifies I2C peripheral
  1820. * @retval 0 SMBUS isn't slave RX PEC NACK
  1821. * @retval 1 SMBUS is slave RX PEC NACK
  1822. */
  1823. #define __LL_I2C_SMBUS_IsSlvRxPecNackRaw(__I2C__) \
  1824. (READ_BIT((__I2C__)->SMINTRRST, I2C_SLV_RX_PEC_NACK_RAW_INT_STA_Msk) << I2C_SLV_RX_PEC_NACK_RAW_INT_STA_Pos)
  1825. /**
  1826. * @brief Judge SMBUS is ARP assgn address cmd detect raw or not
  1827. * @param __I2C__ Specifies I2C peripheral
  1828. * @retval 0 SMBUS isn't ARP assgn address cmd detect raw
  1829. * @retval 1 SMBUS is ARP assgn address cmd detect raw
  1830. */
  1831. #define __LL_I2C_SMBUS_IsARPAssgnAddrCmdDetRaw(__I2C__) \
  1832. (READ_BIT((__I2C__)->SMINTRRST, I2C_ARP_ASSGN_ADDR_CMD_DET_RAW_INT_STA_Msk) << I2C_ARP_ASSGN_ADDR_CMD_DET_RAW_INT_STA_Pos)
  1833. /**
  1834. * @brief Judge SMBUS is ARP get UDID cmd detect raw or not
  1835. * @param __I2C__ Specifies I2C peripheral
  1836. * @retval 0 SMBUS isn't ARP get UDID cmd detect raw
  1837. * @retval 1 SMBUS is ARP get UDID cmd detect raw
  1838. */
  1839. #define __LL_I2C_SMBUS_IsARPGetUdidCmdDetRaw(__I2C__) \
  1840. (READ_BIT((__I2C__)->SMINTRRST, I2C_ARP_GET_UDID_CMD_DET_RAW_INT_STA_Msk) << I2C_ARP_GET_UDID_CMD_DET_RAW_INT_STA_Pos)
  1841. /**
  1842. * @brief Judge SMBUS is ARP reset cmd detect raw or not
  1843. * @param __I2C__ Specifies I2C peripheral
  1844. * @retval 0 SMBUS isn't ARP reset cmd detect raw
  1845. * @retval 1 SMBUS is ARP reset cmd detect raw
  1846. */
  1847. #define __LL_I2C_SMBUS_IsARPRstCmdDetRaw(__I2C__) \
  1848. (READ_BIT((__I2C__)->SMINTRRST, I2C_ARP_RST_CMD_DET_RAW_INT_STA_Msk) << I2C_ARP_RST_CMD_DET_RAW_INT_STA_Pos)
  1849. /**
  1850. * @brief Judge SMBUS is ARP prepare cmd detect raw or not
  1851. * @param __I2C__ Specifies I2C peripheral
  1852. * @retval 0 SMBUS isn't ARP prepare cmd detect raw
  1853. * @retval 1 SMBUS is ARP prepare cmd detect raw
  1854. */
  1855. #define __LL_I2C_SMBUS_IsARPPrepareCmdDetRaw(__I2C__) \
  1856. (READ_BIT((__I2C__)->SMINTRRST, I2C_ARP_PREPARE_CMD_DET_RAW_INT_STA_Msk) << I2C_ARP_PREPARE_CMD_DET_RAW_INT_STA_Pos)
  1857. /**
  1858. * @brief Judge SMBUS is host nofity mst detect raw or not
  1859. * @param __I2C__ Specifies I2C peripheral
  1860. * @retval 0 SMBUS isn't host nofity mst detect raw
  1861. * @retval 1 SMBUS is host nofity mst detect raw
  1862. */
  1863. #define __LL_I2C_SMBUS_IsHostNotifyMstDetRaw(__I2C__) \
  1864. (READ_BIT((__I2C__)->SMINTRRST, I2C_HOST_NOTIFY_MST_DET_RAW_INT_STA_Msk) << I2C_HOST_NOTIFY_MST_DET_RAW_INT_STA_Pos)
  1865. /**
  1866. * @brief Judge SMBUS is quick cmd detect raw or not
  1867. * @param __I2C__ Specifies I2C peripheral
  1868. * @retval 0 SMBUS isn't quick cmd detect raw
  1869. * @retval 1 SMBUS is quick cmd detect raw
  1870. */
  1871. #define __LL_I2C_SMBUS_IsQuickCmdDetRaw(__I2C__) \
  1872. (READ_BIT((__I2C__)->SMINTRRST, I2C_QUICK_CMD_DET_RAW_INT_STA_Msk) << I2C_QUICK_CMD_DET_RAW_INT_STA_Pos)
  1873. /**
  1874. * @brief Judge SMBUS is mst clock extend timeout or not
  1875. * @param __I2C__ Specifies I2C peripheral
  1876. * @retval 0 SMBUS isn't mst clock extend timeout
  1877. * @retval 1 SMBUS is mst clock extend timeout
  1878. */
  1879. #define __LL_I2C_SMBUS_IsMstClkExtendTimeoutRaw(__I2C__) \
  1880. (READ_BIT((__I2C__)->SMINTRRST, I2C_MST_CLK_EXTND_TIMEOUT_RAW_INT_STA_Msk) << I2C_MST_CLK_EXTND_TIMEOUT_RAW_INT_STA_Pos)
  1881. /**
  1882. * @brief Judge SMBUS is slave clock extend timeout or not
  1883. * @param __I2C__ Specifies I2C peripheral
  1884. * @retval 0 SMBUS isn't slave clock extend timeout
  1885. * @retval 1 SMBUS is slave clock extend timeout
  1886. */
  1887. #define __LL_I2C_SMBUS_IsSlvClkExtendTimeoutRaw(__I2C__) \
  1888. (READ_BIT((__I2C__)->SMINTRRST, I2C_SLV_CLK_EXTND_TIMEOUT_RAW_INT_STA_Msk) << I2C_SLV_CLK_EXTND_TIMEOUT_RAW_INT_STA_Pos)
  1889. /**
  1890. * @brief SMBUS alert detect raw interrupt status clear
  1891. * @param __I2C__ Specifies I2C peripheral
  1892. * @return None
  1893. */
  1894. #define __LL_I2C_SMBUS_AlertDetRawIntSta_Clr(__I2C__) SET_BIT((__I2C__)->SMINTRCR, I2C_CLR_SMBUS_ALERT_DET_Msk)
  1895. /**
  1896. * @brief SMBUS suspend detect raw interrupt status clear
  1897. * @param __I2C__ Specifies I2C peripheral
  1898. * @return None
  1899. */
  1900. #define __LL_I2C_SMBUS_SuspendDetRawIntSta_Clr(__I2C__) SET_BIT((__I2C__)->SMINTRCR, I2C_CLR_SMBUS_SUSPEND_DET_Msk)
  1901. /**
  1902. * @brief SMBUS slave RX PEC NACK raw interrupt status clear
  1903. * @param __I2C__ Specifies I2C peripheral
  1904. * @return None
  1905. */
  1906. #define __LL_I2C_SMBUS_SlvRxPecNackRawIntSta_Clr(__I2C__) SET_BIT((__I2C__)->SMINTRCR, I2C_CLR_SLV_RX_PEC_NACK_Msk)
  1907. /**
  1908. * @brief SMBUS ARP assgn addredd cmd detect raw interrupt status clear
  1909. * @param __I2C__ Specifies I2C peripheral
  1910. * @return None
  1911. */
  1912. #define __LL_I2C_SMBUS_ARPAssgnAddrCmdDetRawIntSta_Clr(__I2C__) SET_BIT((__I2C__)->SMINTRCR, I2C_CLR_ARP_ASSGN_ADDR_CMD_DET_Msk)
  1913. /**
  1914. * @brief SMBUS ARP get UDID cmd detect raw interrupt status clear
  1915. * @param __I2C__ Specifies I2C peripheral
  1916. * @return None
  1917. */
  1918. #define __LL_I2C_SMBUS_ARPUdidCmdDetRawIntSta_Clr(__I2C__) SET_BIT((__I2C__)->SMINTRCR, I2C_CLR_ARP_GET_UDID_CMD_DET_Msk)
  1919. /**
  1920. * @brief SMBUS ARP reset cmd detect raw interrupt status clear
  1921. * @param __I2C__ Specifies I2C peripheral
  1922. * @return None
  1923. */
  1924. #define __LL_I2C_SMBUS_ARPRstCmdDetRawIntSta_Clr(__I2C__) SET_BIT((__I2C__)->SMINTRCR, I2C_CLR_ARP_RST_CMD_DET_Msk)
  1925. /**
  1926. * @brief SMBUS ARP prepare cmd detect raw interrupt status clear
  1927. * @param __I2C__ Specifies I2C peripheral
  1928. * @return None
  1929. */
  1930. #define __LL_I2C_SMBUS_ARPPrepareCmdDetRawIntSta_Clr(__I2C__) SET_BIT((__I2C__)->SMINTRCR, I2C_CLR_ARP_PREPARE_CMD_DET_Msk)
  1931. /**
  1932. * @brief SMBUS host notify master detect raw interrupt status clear
  1933. * @param __I2C__ Specifies I2C peripheral
  1934. * @return None
  1935. */
  1936. #define __LL_I2C_SMBUS_HostNotifyMstDetRawIntSta_Clr(__I2C__) SET_BIT((__I2C__)->SMINTRCR, I2C_CLR_HOST_NOTIFY_MST_DET_Msk)
  1937. /**
  1938. * @brief SMBUS quick cmd detect raw interrupt status clear
  1939. * @param __I2C__ Specifies I2C peripheral
  1940. * @return None
  1941. */
  1942. #define __LL_I2C_SMBUS_QuickCmdDetRawIntSta_Clr(__I2C__) SET_BIT((__I2C__)->SMINTRCR, I2C_CLR_QUICK_CMD_DET_Msk)
  1943. /**
  1944. * @brief SMBUS master clock extend timeout raw interrupt status clear
  1945. * @param __I2C__ Specifies I2C peripheral
  1946. * @return None
  1947. */
  1948. #define __LL_I2C_SMBUS_MstClkExtendTimeoutRawIntSta_Clr(__I2C__) SET_BIT((__I2C__)->SMINTRCR, I2C_CLR_MST_CLOCK_EXTND_TIMEOUT_Msk)
  1949. /**
  1950. * @brief SMBUS Slave clock extend timeout raw interrupt status clear
  1951. * @param __I2C__ Specifies I2C peripheral
  1952. * @return None
  1953. */
  1954. #define __LL_I2C_SMBUS_SlvClkExtendTimeoutRawIntSta_Clr(__I2C__) SET_BIT((__I2C__)->SMINTRCR, I2C_CLR_SLV_CLOCK_EXTND_TIMEOUT_Msk)
  1955. /**
  1956. * @brief SMBUS optional SAR set
  1957. * @param __I2C__ Specifies I2C peripheral
  1958. * @param sar optional SAR
  1959. * @return None
  1960. */
  1961. #define __LL_I2C_SMBUS_OptionalSAR_Set(__I2C__, sar) \
  1962. MODIFY_REG((__I2C__)->SAROP, I2C_OPTIONAL_SAR_Msk, ((sar & 0x7fUL) << I2C_OPTIONAL_SAR_Pos))
  1963. /**
  1964. * @brief SMBUS ARP UDID LSB set
  1965. * @param __I2C__ Specifies I2C peripheral
  1966. * @param lsb SMBUS ARP UDID LSB
  1967. * @return None
  1968. */
  1969. #define __LL_I2C_SMBUS_ARPUdidLsb_Set(__I2C__, lsb) \
  1970. MODIFY_REG((__I2C__)->UDIDLSB, I2C_SMBUS_ARP_UDID_LSB_Msk, ((lsb & 0xffffffffUL) << I2C_SMBUS_ARP_UDID_LSB_Pos))
  1971. /**
  1972. * @}
  1973. */
  1974. /* Exported types ------------------------------------------------------------*/
  1975. /** @defgroup I2C_LL_Exported_Types I2C LL Exported Types
  1976. * @brief I2C LL Exported Types
  1977. * @{
  1978. */
  1979. /**
  1980. * @brief I2C role definition
  1981. */
  1982. typedef enum {
  1983. I2C_ROLE_MASTER, /*!< I2C role master */
  1984. I2C_ROLE_SLAVE, /*!< I2C role slave */
  1985. } I2C_RoleETypeDef;
  1986. /**
  1987. * @brief I2C address bit definition
  1988. */
  1989. typedef enum {
  1990. I2C_ADDR_7BIT, /*!< I2C address mode 7b */
  1991. I2C_ADDR_10BIT, /*!< I2C address mode 10b */
  1992. } I2C_AddrModeETypeDef;
  1993. /**
  1994. * @brief I2C memmory address size definition
  1995. */
  1996. typedef enum {
  1997. I2C_MEMADDR_SIZE_INVALID = 0, /*!< memmory address size invalid */
  1998. I2C_MEMADDR_SIZE_8BIT = 1, /*!< memmory address size 8bit */
  1999. I2C_MEMADDR_SIZE_16BIT = 2, /*!< memmory address size 16bit */
  2000. I2C_MEMADDR_SIZE_32BIT = 4, /*!< memmory address size 32bit */
  2001. } I2C_MemAddrSizeETypeDef;
  2002. /**
  2003. * @brief I2C user config
  2004. */
  2005. typedef struct __I2C_UserCfgTypeDef {
  2006. I2C_RoleETypeDef role; /*!< role */
  2007. I2C_AddrModeETypeDef addr_mode; /*!< address mode */
  2008. uint32_t baudrate; /*!< baudrate */
  2009. uint16_t slave_addr; /*!< slave address */
  2010. LL_FuncStatusETypeDef smbus_enable; /*!< smbus enable */
  2011. uint32_t smbus_master_extend_clk; /*!< smbus master extend clk */
  2012. uint32_t smbus_slaver_extend_clk; /*!< smbus slaver extend clk */
  2013. } I2C_UserCfgTypeDef;
  2014. /**
  2015. * @brief I2C DMA Status
  2016. */
  2017. typedef enum {
  2018. IIC_DMA_STATE_RESET = 0, /*!< DMA State Reset: not yet initialized or disabled */
  2019. IIC_DMA_STATE_READY, /*!< DMA State Ready: initialized and ready for use */
  2020. IIC_DMA_STATE_BUSY, /*!< DMA State Busy: process is ongoing */
  2021. IIC_DMA_STATE_ERROR, /*!< DMA State Error: process is Error */
  2022. IIC_DMA_STATE_FINISH, /*!< DMA State Finish: process has been finished */
  2023. } I2C_DMAStatusTypeDef;
  2024. /**
  2025. * @brief I2C frame definition
  2026. */
  2027. typedef struct __I2C_FrameTypeDef {
  2028. I2C_TypeDef *Instance; /*!< I2C Reg base address */
  2029. uint16_t target_addr; /*!< target address */
  2030. uint32_t mem_addr; /*!< memory address */
  2031. I2C_MemAddrSizeETypeDef mem_addr_size; /*!< memory address size */
  2032. uint8_t *buf; /*!< buffer pointer */
  2033. uint32_t buf_len; /*!< buffer length */
  2034. uint32_t command; /*!< smbus_command */
  2035. uint16_t XferCount; /*!< I2C transfer counter */
  2036. uint32_t clk_cnt; /*!< I2C sent clk to read */
  2037. #ifdef LL_DMA_MODULE_ENABLED
  2038. DMA_ChannelETypeDef dma_tx_ch; /*!< I2C Tx DMA Channel */
  2039. DMA_ChannelETypeDef dma_rx_ch; /*!< I2C Rx DMA Channel */
  2040. I2C_DMAStatusTypeDef TXdma_status; /*!< I2C DMA status */
  2041. I2C_DMAStatusTypeDef RXdma_status; /*!< I2C DMA status */
  2042. #endif
  2043. } I2C_FrameTypeDef;
  2044. /**
  2045. * @}
  2046. */
  2047. /* Exported functions --------------------------------------------------------*/
  2048. /** @addtogroup I2C_LL_Exported_Functions
  2049. * @{
  2050. */
  2051. /** @addtogroup I2C_LL_Exported_Functions_Group1
  2052. * @{
  2053. */
  2054. LL_StatusETypeDef LL_I2C_Init(I2C_TypeDef *Instance, I2C_UserCfgTypeDef *user_cfg);
  2055. LL_StatusETypeDef LL_I2C_DeInit(I2C_TypeDef *Instance);
  2056. void LL_I2C_MspInit(I2C_TypeDef *Instance);
  2057. void LL_I2C_MspDeInit(I2C_TypeDef *Instance);
  2058. /**
  2059. * @}
  2060. */
  2061. /** @addtogroup I2C_LL_Exported_Functions_Group2
  2062. * @{
  2063. */
  2064. uint32_t LL_I2C_MasterWrite_CPU(I2C_TypeDef *Instance, I2C_FrameTypeDef *frame);
  2065. uint32_t LL_I2C_MasterRead_CPU(I2C_TypeDef *Instance, I2C_FrameTypeDef *frame);
  2066. LL_StatusETypeDef LL_I2C_SlaveWrite_CPU(I2C_TypeDef *Instance, I2C_FrameTypeDef *frame, uint32_t Timeout);
  2067. LL_StatusETypeDef LL_I2C_SlaveRead_CPU(I2C_TypeDef *Instance, I2C_FrameTypeDef *frame, uint32_t Timeout);
  2068. uint32_t LL_SMBUS_MasterWrite_CPU(I2C_TypeDef *Instance, I2C_FrameTypeDef *frame);
  2069. uint32_t LL_SMBUS_MasterRead_CPU(I2C_TypeDef *Instance, I2C_FrameTypeDef *frame);
  2070. LL_StatusETypeDef LL_SMBUS_SlaveRead_CPU(I2C_TypeDef *Instance, I2C_FrameTypeDef *frame, uint32_t Timeout);
  2071. LL_StatusETypeDef LL_SMBUS_SlaveWrite_CPU(I2C_TypeDef *Instance, I2C_FrameTypeDef *frame, uint32_t Timeout);
  2072. LL_StatusETypeDef LL_I2C_MasterWrite_IT(I2C_TypeDef *Instance, I2C_FrameTypeDef *frame);
  2073. LL_StatusETypeDef LL_I2C_SlaveWrite_IT(I2C_TypeDef *Instance, I2C_FrameTypeDef *frame);
  2074. LL_StatusETypeDef LL_I2C_MasterRead_IT(I2C_TypeDef *Instance, I2C_FrameTypeDef *frame);
  2075. LL_StatusETypeDef LL_I2C_SlaveRead_IT(I2C_TypeDef *Instance, I2C_FrameTypeDef *frame);
  2076. LL_StatusETypeDef LL_SMBUS_MasterWrite_IT(I2C_TypeDef *Instance, I2C_FrameTypeDef *frame);
  2077. LL_StatusETypeDef LL_SMBUS_MasterRead_IT(I2C_TypeDef *Instance, I2C_FrameTypeDef *frame);
  2078. LL_StatusETypeDef LL_SMBUS_SlaveRead_IT(I2C_TypeDef *Instance, I2C_FrameTypeDef *frame);
  2079. LL_StatusETypeDef LL_SMBUS_SlaveWrite_IT(I2C_TypeDef *Instance, I2C_FrameTypeDef *frame);
  2080. #ifdef LL_DMA_MODULE_ENABLED
  2081. LL_StatusETypeDef LL_I2C_MasterWrite_DMA(I2C_TypeDef *Instance, DMA_UserCfgTypeDef *dma_user_cfg,
  2082. I2C_FrameTypeDef *frame, uint32_t Timeout);
  2083. LL_StatusETypeDef LL_I2C_MasterRead_DMA(I2C_TypeDef *Instance, DMA_UserCfgTypeDef *dma_user_cfg,
  2084. I2C_FrameTypeDef *frame, uint32_t Timeout);
  2085. LL_StatusETypeDef LL_I2C_SlaveRead_DMA(I2C_TypeDef *Instance, DMA_UserCfgTypeDef *dma_user_cfg,
  2086. I2C_FrameTypeDef *frame, uint32_t Timeout);
  2087. LL_StatusETypeDef LL_I2C_SlaveWrite_DMA(I2C_TypeDef *Instance, DMA_UserCfgTypeDef *dma_user_cfg,
  2088. I2C_FrameTypeDef *frame, uint32_t Timeout);
  2089. LL_StatusETypeDef LL_SMBUS_MasterWrite_DMA(I2C_TypeDef *Instance, DMA_UserCfgTypeDef *dma_user_cfg,
  2090. I2C_FrameTypeDef *frame, uint32_t Timeout);
  2091. LL_StatusETypeDef LL_SMBUS_MasterRead_DMA(I2C_TypeDef *Instance, DMA_UserCfgTypeDef *dma_user_cfg,
  2092. I2C_FrameTypeDef *frame, uint32_t Timeout);
  2093. LL_StatusETypeDef LL_SMBUS_SlaveWrite_DMA(I2C_TypeDef *Instance, DMA_UserCfgTypeDef *dma_user_cfg,
  2094. I2C_FrameTypeDef *frame, uint32_t Timeout);
  2095. LL_StatusETypeDef LL_SMBUS_SlaveRead_DMA(I2C_TypeDef *Instance, DMA_UserCfgTypeDef *dma_user_cfg,
  2096. I2C_FrameTypeDef *frame, uint32_t Timeout);
  2097. #endif
  2098. /**
  2099. * @}
  2100. */
  2101. /** @addtogroup I2C_LL_Exported_Functions_Group3
  2102. * @{
  2103. */
  2104. void LL_I2C_IRQHandler(I2C_TypeDef *Instance, I2C_FrameTypeDef *hi2c);
  2105. void LL_I2C_SCLStuckAtLowCallback(I2C_TypeDef *Instance);
  2106. void LL_I2C_MstOnHoldCallback(I2C_TypeDef *Instance);
  2107. void LL_I2C_SlvRestartDetCallback(I2C_TypeDef *Instance);
  2108. void LL_I2C_SlvGenCallCallback(I2C_TypeDef *Instance);
  2109. void LL_I2C_StartDetCallback(I2C_TypeDef *Instance);
  2110. void LL_I2C_StopDetCallback(I2C_TypeDef *Instance);
  2111. void LL_I2C_ActivityCallback(I2C_TypeDef *Instance);
  2112. void LL_I2C_SlvRxDoneCallback(I2C_TypeDef *Instance);
  2113. void LL_I2C_TxAbortCallback(I2C_TypeDef *Instance);
  2114. void LL_I2C_SlvReadReqCallback(I2C_TypeDef *Instance);
  2115. void LL_I2C_TxEmptyCallback(I2C_TypeDef *Instance);
  2116. void LL_I2C_TxOverCallback(I2C_TypeDef *Instance);
  2117. void LL_I2C_RxFullCallback(I2C_TypeDef *Instance);
  2118. void LL_I2C_RxOverCallback(I2C_TypeDef *Instance);
  2119. void LL_I2C_RxUnderCallback(I2C_TypeDef *Instance);
  2120. void LL_SMBUS_SlvClkExtTimeoutCallback(I2C_TypeDef *Instance);
  2121. void LL_SMBUS_MstClkExtTimeoutCallback(I2C_TypeDef *Instance);
  2122. /**
  2123. * @}
  2124. */
  2125. /**
  2126. * @}
  2127. */
  2128. /* Private types -------------------------------------------------------------*/
  2129. /* Private variables ---------------------------------------------------------*/
  2130. /* Private constants ---------------------------------------------------------*/
  2131. /* Private macros ------------------------------------------------------------*/
  2132. /* Private functions ---------------------------------------------------------*/
  2133. #ifdef __cplusplus
  2134. }
  2135. #endif /* __cplusplus */
  2136. #endif /* _TMF5XXX_LL_I2C_H_ */
  2137. /**
  2138. * @}
  2139. */
  2140. /**
  2141. * @}
  2142. */
  2143. /************************* (C) COPYRIGHT Tai-Action *****END OF FILE***********/