tae32f53xx_ll_adc.h 169 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582
  1. /**
  2. ******************************************************************************
  3. * @file tae32f53xx_ll_adc.h
  4. * @author MCD Application Team
  5. * @brief Header file of ADC 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 _TAE32F53XX_LL_ADC_H_
  22. #define _TAE32F53XX_LL_ADC_H_
  23. #ifdef __cplusplus
  24. extern "C" {
  25. #endif /* __cplusplus */
  26. /* Includes ------------------------------------------------------------------*/
  27. #include "tae32f53xx_ll_def.h"
  28. /** @addtogroup TAE32F53xx_LL_Driver
  29. * @{
  30. */
  31. /** @addtogroup ADC_LL
  32. * @{
  33. */
  34. /* Exported constants --------------------------------------------------------*/
  35. /** @defgroup ADC_LL_Exported_Constants ADC LL Exported Constants
  36. * @brief ADC LL Exported Constants
  37. * @{
  38. */
  39. /**
  40. * @brief regular trigger edge
  41. * Internal mask for ADC group regular trigger:
  42. * To select into literal LL_ADC_REG_TRIG_x the relevant bits for:
  43. */
  44. #define ADC_REG_TRIG_EXT_EDGE_DEFAULT (ADC_LR_EXTEN_0)
  45. /**
  46. * @brief Mask containing trigger source masks for each of possible
  47. * trigger edge selection duplicated with shifts [0; 4; 8; 12]
  48. * corresponding to {SW start; ext trigger; ext trigger; ext trigger}
  49. */
  50. #define ADC_REG_TRIG_SOURCE_MASK (((ADC_REG_TRIG_SOFTWARE & ADC_LR_EXTSEL) << (4U * 0UL)) | \
  51. ((ADC_LR_EXTSEL) << (4U * 1UL)) | \
  52. ((ADC_LR_EXTSEL) << (4U * 2UL)) | \
  53. ((ADC_LR_EXTSEL) << (4U * 3UL)) )
  54. /**
  55. * @brief Mask containing trigger edge masks for each of possible
  56. * trigger edge selection duplicated with shifts [0; 4; 8; 12]
  57. * corresponding to {SW start; ext trigger; ext trigger; ext trigger}
  58. */
  59. #define ADC_REG_TRIG_EDGE_MASK (((ADC_REG_TRIG_SOFTWARE & ADC_LR_EXTEN) << (4U * 0UL)) | \
  60. ((ADC_REG_TRIG_EXT_EDGE_DEFAULT) << (4U * 1UL)) | \
  61. ((ADC_REG_TRIG_EXT_EDGE_DEFAULT) << (4U * 2UL)) | \
  62. ((ADC_REG_TRIG_EXT_EDGE_DEFAULT) << (4U * 3UL)) )
  63. /**
  64. * @brief Definition of ADC group regular trigger bits information
  65. */
  66. #define ADC_REG_TRIG_EXTSEL_BITOFFSET_POS (ADC_LR_EXTSEL_Pos)
  67. /**
  68. * @brief Definition of ADC group regular trigger bits information
  69. */
  70. #define ADC_REG_TRIG_EXTEN_BITOFFSET_POS (ADC_LR_EXTEN_Pos)
  71. /**
  72. * @brief Internal mask for ADC group injected trigger:
  73. * To select into literal LL_ADC_INJ_TRIG_x the relevant bits for:
  74. */
  75. #define ADC_INJ_TRIG_EXT_EDGE_DEFAULT (ADC_JLR_JEXTEN_0)
  76. /**
  77. * @brief Mask containing trigger source masks for each of possible
  78. * trigger edge selection duplicated with shifts [0; 4; 8; 12]
  79. * corresponding to {SW start; ext trigger; ext trigger; ext trigger}
  80. */
  81. #define ADC_INJ_TRIG_SOURCE_MASK (((ADC_INJ_TRIG_SOFTWARE & ADC_JLR_JEXTSEL) << (4U * 0UL)) | \
  82. ((ADC_JLR_JEXTSEL) << (4U * 1UL)) | \
  83. ((ADC_JLR_JEXTSEL) << (4U * 2UL)) | \
  84. ((ADC_JLR_JEXTSEL) << (4U * 3UL)) )
  85. /**
  86. * @brief Mask containing trigger edge masks for each of possible
  87. * trigger edge selection duplicated with shifts [0; 4; 8; 12]
  88. * corresponding to {SW start; ext trigger; ext trigger; ext trigger}
  89. */
  90. #define ADC_INJ_TRIG_EDGE_MASK (((ADC_INJ_TRIG_SOFTWARE & ADC_JLR_JEXTEN) << (4U * 0UL)) | \
  91. ((ADC_INJ_TRIG_EXT_EDGE_DEFAULT) << (4U * 1UL)) | \
  92. ((ADC_INJ_TRIG_EXT_EDGE_DEFAULT) << (4U * 2UL)) | \
  93. ((ADC_INJ_TRIG_EXT_EDGE_DEFAULT) << (4U * 3UL)) )
  94. /**
  95. * @brief Definition of ADC group injected trigger bits information
  96. */
  97. #define ADC_INJ_TRIG_EXTSEL_BITOFFSET_POS (ADC_JLR_JEXTSEL_Pos)
  98. /**
  99. * @brief Definition of ADC group injected trigger bits information
  100. */
  101. #define ADC_INJ_TRIG_EXTEN_BITOFFSET_POS (ADC_JLR_JEXTEN_Pos)
  102. /**
  103. * @brief Definition of ADC group injected trigger bits information
  104. */
  105. #define ADC_SINGLEDIFF_CHANNEL_SHIFT (0x00000001UL)
  106. /**
  107. * @brief Definition of ADC group injected trigger bits information
  108. */
  109. #define ADC_JSQX_REGOFFSET (0x00000002UL)
  110. /**
  111. * @brief Definition of ADC group injected trigger bits information
  112. */
  113. #define ADC_SMPRX_REGOFFSET (0x00000002UL)
  114. /**
  115. * @brief Definition of ADC group injected trigger bits information
  116. */
  117. #define ADC_SMPRX_REGOFFSET_POS (25UL) /* Position of bits ADC_SMPRx_REGOFFSET in ADC_CHANNEL_SMPRX_REGOFFSET_MASK */
  118. /**
  119. * @brief ADC register CR bits: Software can read as well as set this bit. Writing '0' has no effect on the bit value.
  120. */
  121. #define ADC_CR0_BITS_PROPERTY_RS (ADC_CR0_JADSTP | ADC_CR0_ADSTP | ADC_CR0_JADSTART | ADC_CR0_ADSTART)
  122. /** @defgroup ADC_LL_AWD_CHANNELS ADC LL AWD CHANNELS
  123. * @brief Analog watchdog Monitored channels
  124. * @{
  125. */
  126. /** @brief ADC analog watchdog monitoring disabled */
  127. #define ADC_AWD_DISABLE (0x00000000UL)
  128. /** @brief ADC analog watchdog monitoring enable */
  129. #define ADC_AWD_ALL_CHANNELS (0x00000FFFUL)
  130. /** @brief ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN0 */
  131. #define ADC_AWD_CHANNEL_0 (ADC_AWD0CR_AWD0CH_0 )
  132. /** @brief ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN1 */
  133. #define ADC_AWD_CHANNEL_1 (ADC_AWD0CR_AWD0CH_1 )
  134. /** @brief ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN2 */
  135. #define ADC_AWD_CHANNEL_2 (ADC_AWD0CR_AWD0CH_2 )
  136. /** @brief ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN3 */
  137. #define ADC_AWD_CHANNEL_3 (ADC_AWD0CR_AWD0CH_3 )
  138. /** @brief ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN4 */
  139. #define ADC_AWD_CHANNEL_4 (ADC_AWD0CR_AWD0CH_4 )
  140. /** @brief ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN5 */
  141. #define ADC_AWD_CHANNEL_5 (ADC_AWD0CR_AWD0CH_5 )
  142. /** @brief ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN6 */
  143. #define ADC_AWD_CHANNEL_6 (ADC_AWD0CR_AWD0CH_6 )
  144. /** @brief ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN7 */
  145. #define ADC_AWD_CHANNEL_7 (ADC_AWD0CR_AWD0CH_7 )
  146. /** @brief ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN8 */
  147. #define ADC_AWD_CHANNEL_8 (ADC_AWD0CR_AWD0CH_8 )
  148. /** @brief ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN9 */
  149. #define ADC_AWD_CHANNEL_9 (ADC_AWD0CR_AWD0CH_9 )
  150. /** @brief ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN10 */
  151. #define ADC_AWD_CHANNEL_10 (ADC_AWD0CR_AWD0CH_10)
  152. /** @brief ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN11 */
  153. #define ADC_AWD_CHANNEL_TEMPSENSOR (ADC_AWD0CR_AWD0CH_11)
  154. /**
  155. * @}
  156. */
  157. /** @defgroup ADC_LL_IT ADC LL IT
  158. * @brief ADC interruptions for configuration (interruption enable or disable)
  159. * @note IT defines which can be used with LL_ADC_ReadReg and LL_ADC_WriteReg functions
  160. * @{
  161. */
  162. #define ADC_IT_ADRDY ADC_IER_ADRDYIE /*!< ADC interruption ADC instance ready */
  163. #define ADC_IT_EOC ADC_IER_EOCIE /*!< ADC interruption ADC group regular end of unitary conversion */
  164. #define ADC_IT_EOS ADC_IER_EOSIE /*!< ADC interruption ADC group regular end of sequence conversions */
  165. #define ADC_IT_OVR ADC_IER_OVRIE /*!< ADC interruption ADC group regular overrun */
  166. #define ADC_IT_EOSMP ADC_IER_EOSMPIE /*!< ADC interruption ADC group regular end of sampling phase */
  167. #define ADC_IT_JEOC ADC_IER_JEOCIE /*!< ADC interruption ADC group injected end of unitary conversion */
  168. #define ADC_IT_JEOS ADC_IER_JEOSIE /*!< ADC interruption ADC group injected end of sequence conversions */
  169. #define ADC_IT_AWD0 ADC_IER_AWD0IE /*!< ADC interruption ADC analog watchdog 0 */
  170. #define ADC_IT_AWD1 ADC_IER_AWD1IE /*!< ADC interruption ADC analog watchdog 1 */
  171. #define ADC_IT_AWD2 ADC_IER_AWD2IE /*!< ADC interruption ADC analog watchdog 2 */
  172. /**
  173. * @}
  174. */
  175. /** @defgroup ADC_FLAG ADC FLAG
  176. * @brief Flags defines which can be used with LL_ADC_ReadReg function
  177. * @{
  178. */
  179. #define ADC_FLAG_ADRDY ADC_ISR_ADRDY /*!< ADC flag ADC instance ready */
  180. #define ADC_FLAG_EOC ADC_ISR_EOC /*!< ADC flag ADC group regular end of unitary conversion */
  181. #define ADC_FLAG_EOS ADC_ISR_EOS /*!< ADC flag ADC group regular end of sequence conversions */
  182. #define ADC_FLAG_OVR ADC_ISR_OVR /*!< ADC flag ADC group regular overrun */
  183. #define ADC_FLAG_EOSMP ADC_ISR_EOSMP /*!< ADC flag ADC group regular end of sampling phase */
  184. #define ADC_FLAG_JEOC ADC_ISR_JEOC /*!< ADC flag ADC group injected end of unitary conversion */
  185. #define ADC_FLAG_JEOS ADC_ISR_JEOS /*!< ADC flag ADC group injected end of sequence conversions */
  186. #define ADC_FLAG_AWD0 ADC_ISR_AWD0 /*!< ADC flag ADC analog watchdog 1 */
  187. #define ADC_FLAG_AWD1 ADC_ISR_AWD1 /*!< ADC flag ADC analog watchdog 2 */
  188. #define ADC_FLAG_AWD2 ADC_ISR_AWD2 /*!< ADC flag ADC analog watchdog 3 */
  189. #define ADC_AWD_THRESHOLDS_HIGH_POS (16U) /*!< ADC AWD Thresholds high pos */
  190. /**
  191. * @}
  192. */
  193. /**
  194. * @}
  195. */
  196. /* Exported types ------------------------------------------------------------*/
  197. /** @defgroup ADC_LL_Exported_Types ADC LL Exported Types
  198. * @brief ADC LL Exported Types
  199. * @{
  200. */
  201. /**
  202. * @brief Oversampling - Data shift
  203. */
  204. typedef enum {
  205. ADC_OVSS_SHIFT_NONE = 0x0,
  206. /*!< ADC oversampling no shift (sum of the ADC conversions data is not divided to result as the ADC oversampling conversion data) */
  207. ADC_OVSS_SHIFT_RIGHT_1 = ADC_CR1_OVSS_0,
  208. /*!< ADC oversampling shift of 1 (sum of the ADC conversions data is divided by 2 to result as the ADC oversampling conversion data) */
  209. ADC_OVSS_SHIFT_RIGHT_2 = ADC_CR1_OVSS_1,
  210. /*!< ADC oversampling shift of 2 (sum of the ADC conversions data is divided by 4 to result as the ADC oversampling conversion data) */
  211. ADC_OVSS_SHIFT_RIGHT_3 = ADC_CR1_OVSS_1 | ADC_CR1_OVSS_0,
  212. /*!< ADC oversampling shift of 3 (sum of the ADC conversions data is divided by 8 to result as the ADC oversampling conversion data) */
  213. ADC_OVSS_SHIFT_RIGHT_4 = ADC_CR1_OVSS_2,
  214. /*!< ADC oversampling shift of 4 (sum of the ADC conversions data is divided by 16 to result as the ADC oversampling conversion data) */
  215. ADC_OVSS_SHIFT_RIGHT_5 = ADC_CR1_OVSS_2 | ADC_CR1_OVSS_0,
  216. /*!< ADC oversampling shift of 5 (sum of the ADC conversions data is divided by 32 to result as the ADC oversampling conversion data) */
  217. ADC_OVSS_SHIFT_RIGHT_6 = ADC_CR1_OVSS_2 | ADC_CR1_OVSS_1,
  218. /*!< ADC oversampling shift of 6 (sum of the ADC conversions data is divided by 64 to result as the ADC oversampling conversion data) */
  219. ADC_OVSS_SHIFT_RIGHT_7 = ADC_CR1_OVSS_2 | ADC_CR1_OVSS_1 | ADC_CR1_OVSS_0,
  220. /*!< ADC oversampling shift of 7 (sum of the ADC conversions data is divided by 128 to result as the ADC oversampling conversion data) */
  221. ADC_OVSS_SHIFT_RIGHT_8 = ADC_CR1_OVSS_3,
  222. /*!< ADC oversampling shift of 8 (sum of the ADC conversions data is divided by 256 to result as the ADC oversampling conversion data) */
  223. } ADC_OverSampShiftETypeDef;
  224. /**
  225. * @brief Oversampling - Ratio
  226. */
  227. typedef enum {
  228. ADC_OVSR_RATIO_2 = 0x0,
  229. /*!< ADC oversampling ratio of 2 (before potential shift) */
  230. ADC_OVSR_RATIO_4 = ADC_CR1_OVSR_0,
  231. /*!< ADC oversampling ratio of 4 (before potential shift) */
  232. ADC_OVSR_RATIO_8 = ADC_CR1_OVSR_1,
  233. /*!< ADC oversampling ratio of 8 (before potential shift) */
  234. ADC_OVSR_RATIO_16 = ADC_CR1_OVSR_1 | ADC_CR1_OVSR_0,
  235. /*!< ADC oversampling ratio of 16 (before potential shift) */
  236. ADC_OVSR_RATIO_32 = ADC_CR1_OVSR_2,
  237. /*!< ADC oversampling ratio of 32 (before potential shift) */
  238. ADC_OVSR_RATIO_64 = ADC_CR1_OVSR_2 | ADC_CR1_OVSR_0,
  239. /*!< ADC oversampling ratio of 64 (before potential shift) */
  240. ADC_OVSR_RATIO_128 = ADC_CR1_OVSR_2 | ADC_CR1_OVSR_1,
  241. /*!< ADC oversampling ratio of 128 (before potential shift) */
  242. ADC_OVSR_RATIO_256 = ADC_CR1_OVSR_2 | ADC_CR1_OVSR_1 | ADC_CR1_OVSR_0,
  243. /*!< ADC oversampling ratio of 256 (before potential shift) */
  244. } ADC_OverSampRatioETypeDef;
  245. /**
  246. * @brief Oversampling scope
  247. */
  248. typedef enum {
  249. ADC_OVS_DISABLE = 0x0,
  250. /*!< ADC oversampling disabled. */
  251. ADC_OVS_GRP_REGULAR_CONTINUED = ADC_CR1_ROVSE,
  252. /*!< ADC oversampling on conversions of ADC group regular. If group injected interrupts group regular:
  253. when ADC group injected is triggered, the oversampling on ADC group regular is temporary stopped and continued afterwards. */
  254. ADC_OVS_GRP_REGULAR_RESUMED = ADC_CR1_ROVSM | ADC_CR1_ROVSE,
  255. /*!< ADC oversampling on conversions of ADC group regular. If group injected interrupts group regular:
  256. when ADC group injected is triggered, the oversampling on ADC group regular is resumed from start (oversampler buffer reset). */
  257. ADC_OVS_GRP_INJECTED = ADC_CR1_JOVSE,
  258. /*!< ADC oversampling on conversions of ADC group injected. */
  259. ADC_OVS_GRP_INJ_REG_RESUMED = ADC_CR1_JOVSE | ADC_CR1_ROVSE,
  260. /*!< ADC oversampling on conversions of both ADC groups regular and injected. If group injected interrupting group regular:
  261. when ADC group injected is triggered, the oversampling on ADC group regular is resumed from start (oversampler buffer reset). */
  262. } ADC_OverSampModeETypeDef;
  263. /**
  264. * @brief Oversampling scope for ADC group regular valid
  265. */
  266. typedef enum {
  267. ADC_OVS_CONTINUED_MODE = 0x0,
  268. /*!< Oversampling buffer maintained during injection sequence */
  269. ADC_OVS_RESUMED_MODE = ADC_CR1_ROVSM,
  270. /*!< Oversampling buffer zeroed during injection sequence */
  271. } ADC_OverSampROVSMETypeDef;
  272. /**
  273. * @brief Discontinuous mode Trigger over sample
  274. */
  275. typedef enum {
  276. ADC_OVS_TRIG_CONT = 0x0,
  277. /*!< ADC oversampling discontinuous mode: continuous mode (all conversions of oversampling ratio are done from 1 trigger) */
  278. ADC_OVS_TRIG_DISCONT = ADC_CR1_TROVS,
  279. /*!< ADC oversampling discontinuous mode: discontinuous mode (each conversion of oversampling ratio needs a trigger) */
  280. } ADC_OverSampTROVSETypeDef;
  281. /**
  282. * @brief Synchronization
  283. */
  284. typedef enum {
  285. ADC_SYNCEN_DIS = 0x0,
  286. /*!< ADC synchronization is disable */
  287. ADC_SYNCEN_EN = ADC_CR1_SYNCEN,
  288. /*!< ADC synchronization is enabled */
  289. } ADC_SyncEnETypeDef;
  290. /**
  291. * @brief ADC TBIMOD SEL
  292. */
  293. typedef enum {
  294. ADC_TBIMOD_MUX_CLOSE = 0x0,
  295. ADC_TBIMOD_A_SH = ADC_CR1_OVSR_2,
  296. ADC_TBIMOD_A_ADC = ADC_CR1_OVSR_2 | ADC_CR1_OVSR_0,
  297. ADC_TBIMOD_B_SH = ADC_CR1_OVSR_2 | ADC_CR1_OVSR_1,
  298. ADC_TBIMOD_B_ADC = ADC_CR1_OVSR_2 | ADC_CR1_OVSR_1 | ADC_CR1_OVSR_0,
  299. } ADC_TestBuffModeETypeDef;
  300. /**
  301. * @brief ADC ANOLOG CTL
  302. */
  303. typedef enum {
  304. ADC_ANOLOG_CTL_DEFAULT = ADC_CR2_ISEL_1 | ADC_CR2_CH_EN | ADC_CR2_FADC_EN | ADC_CR2_REF_EN | ADC_CR2_BIAS_EN,
  305. ADC_ANOLOG_CTL_A_SH = ADC_ANOLOG_CTL_DEFAULT | ADC_TBIMOD_A_SH,
  306. ADC_ANOLOG_CTL_A_ADC = ADC_ANOLOG_CTL_DEFAULT | ADC_TBIMOD_A_ADC,
  307. ADC_ANOLOG_CTL_B_SH = ADC_ANOLOG_CTL_DEFAULT | ADC_TBIMOD_B_SH,
  308. ADC_ANOLOG_CTL_B_ADC = ADC_ANOLOG_CTL_DEFAULT | ADC_TBIMOD_B_ADC,
  309. } ADC_AnologCtlETypeDef;
  310. /**
  311. * @brief Channel Sampling time
  312. */
  313. typedef enum {
  314. ADC_SAMPLINGTIME_6CYCLES = 0x0,
  315. /*!< Sampling time 6 ADC clock cycles */
  316. ADC_SAMPLINGTIME_18CYCLES = ADC_SMPR0_SMP0_0,
  317. /*!< Sampling time 18 ADC clock cycles */
  318. ADC_SAMPLINGTIME_42CYCLES = ADC_SMPR0_SMP0_1,
  319. /*!< Sampling time 42 ADC clock cycles */
  320. ADC_SAMPLINGTIME_90CYCLES = ADC_SMPR0_SMP0_1 | ADC_SMPR0_SMP0_0,
  321. /*!< Sampling time 90 ADC clock cycles */
  322. ADC_SAMPLINGTIME_186CYCLES = ADC_SMPR0_SMP0_2,
  323. /*!< Sampling time 186 ADC clock cycles */
  324. ADC_SAMPLINGTIME_378CYCLES = ADC_SMPR0_SMP0_2 | ADC_SMPR0_SMP0_0,
  325. /*!< Sampling time 378 ADC clock cycles */
  326. ADC_SAMPLINGTIME_762CYCLES = ADC_SMPR0_SMP0_2 | ADC_SMPR0_SMP0_1,
  327. /*!< Sampling time 762 ADC clock cycles */
  328. ADC_SAMPLINGTIME_1530CYCLES = ADC_SMPR0_SMP0_2 | ADC_SMPR0_SMP0_1 | ADC_SMPR0_SMP0_0,
  329. /*!< Sampling time 1530 ADC clock cycles */
  330. } ADC_SampTimeETypeDef;
  331. /**
  332. * @brief ADC CALCULATE OFFST GROUP SELECT
  333. */
  334. typedef enum {
  335. ADC_CAL_OFFSET_GROUP0 = 0x0,
  336. /*ADC calibration offset/gain register gruop 0 -- OFR0*/
  337. ADC_CAL_OFFSET_GROUP1 = ADC_CALR0_CAL0_0,
  338. /*ADC calibration offset/gain register gruop 1 -- OFR1*/
  339. ADC_CAL_OFFSET_GROUP2 = ADC_CALR0_CAL0_1,
  340. /*ADC calibration offset/gain register gruop 2 -- OFR2*/
  341. ADC_CAL_OFFSET_GROUP3 = ADC_CALR0_CAL0_1 | ADC_CALR0_CAL0_0,
  342. /*ADC calibration offset/gain register gruop 3 -- OFR3*/
  343. } ADC_CalrGroupETypeDef;
  344. /**
  345. * @brief Trigger edge
  346. */
  347. typedef enum {
  348. LL_ADC_REG_TRIG_SOFT = 0x0,
  349. /*!< ADC group regular conversion software trigger */
  350. ADC_REG_TRIG_EXT_RISING = ADC_LR_EXTEN_0,
  351. /*!< ADC group regular conversion trigger polarity set to rising edge */
  352. ADC_REG_TRIG_EXT_FALLING = ADC_LR_EXTEN_1,
  353. /*!< ADC group regular conversion trigger polarity set to falling edge */
  354. ADC_REG_TRIG_EXT_RISINGFALLING = ADC_LR_EXTEN_1 | ADC_LR_EXTEN_0,
  355. /*!< ADC group regular conversion trigger polarity set to both rising and falling edges */
  356. } ADC_RegTrigEdgeETypeDef;
  357. /**
  358. * @brief Continuous mode
  359. */
  360. typedef enum {
  361. ADC_REG_CONV_SINGLE = 0x0,
  362. /*!< ADC conversions are performed in single mode: one conversion per trigger */
  363. ADC_REG_CONV_CONTINUOUS = ADC_CR1_CONT,
  364. /*!< ADC conversions are performed in continuous mode: after the first trigger,
  365. following conversions launched successively automatically */
  366. } ADC_RegConvModeETypeDef;
  367. /**
  368. * @brief Overrun behavior on conversion data
  369. */
  370. typedef enum {
  371. ADC_OVR_DATA_PRESERVED = 0x0,
  372. /*!< ADC group regular behavior in case of overrun: data preserved */
  373. ADC_OVR_DATA_OVERWRITTEN = ADC_CR1_OVRMOD,
  374. /*!< ADC group regular behavior in case of overrun: data overwritten */
  375. } ADC_OverRunModeETypeDef;
  376. /**
  377. * @brief Sequencer discontinuous mode
  378. */
  379. typedef enum {
  380. ADC_REG_SEQ_DISCON_DISABLE = 0x0,
  381. /*!< ADC group regular sequencer discontinuous mode disable */
  382. ADC_REG_SEQ_DISNUM_1RANK = ADC_CR1_DISCEN,
  383. /*!< ADC group regular sequencer discontinuous mode enable with sequence interruption every rank */
  384. ADC_REG_SEQ_DISNUM_2RANKS = ADC_CR1_DISCNUM_0 | ADC_CR1_DISCEN,
  385. /*!< ADC group regular sequencer discontinuous mode enable with sequence interruption every 2 ranks */
  386. ADC_REG_SEQ_DISNUM_3RANKS = ADC_CR1_DISCNUM_1 | ADC_CR1_DISCEN,
  387. /*!< ADC group regular sequencer discontinuous mode enable with sequence interruption every 3 ranks */
  388. ADC_REG_SEQ_DISNUM_4RANKS = ADC_CR1_DISCNUM_1 | ADC_CR1_DISCNUM_0 | ADC_CR1_DISCEN,
  389. /*!< ADC group regular sequencer discontinuous mode enable with sequence interruption every 4 ranks */
  390. ADC_REG_SEQ_DISNUM_5RANKS = ADC_CR1_DISCNUM_2 | ADC_CR1_DISCEN,
  391. /*!< ADC group regular sequencer discontinuous mode enable with sequence interruption every 5 ranks */
  392. ADC_REG_SEQ_DISNUM_6RANKS = ADC_CR1_DISCNUM_2 | ADC_CR1_DISCNUM_0 | ADC_CR1_DISCEN,
  393. /*!< ADC group regular sequencer discontinuous mode enable with sequence interruption every 6 ranks */
  394. ADC_REG_SEQ_DISNUM_7RANKS = ADC_CR1_DISCNUM_2 | ADC_CR1_DISCNUM_1 | ADC_CR1_DISCEN,
  395. /*!< ADC group regular sequencer discontinuous mode enable with sequence interruption every 7 ranks */
  396. ADC_REG_SEQ_DISNUM_8RANKS = ADC_CR1_DISCNUM_2 | ADC_CR1_DISCNUM_1 | ADC_CR1_DISCNUM_0 | ADC_CR1_DISCEN,
  397. /*!< ADC group regular sequencer discontinuous mode enable with sequence interruption every 8 ranks */
  398. } ADC_RegDiscontETypeDef;
  399. /**
  400. * @brief Sequencer length
  401. */
  402. typedef enum {
  403. ADC_REG_SEQ_LENGTH_1 = 0x0,
  404. /*!< ADC group regular sequencer disable (equivalent to sequencer of 1 rank: ADC conversion on only 1 channel) */
  405. ADC_REG_SEQ_LENGTH_2 = ADC_LR_LEN_0,
  406. /*!< ADC group regular sequencer enable with 2 ranks in the sequence */
  407. ADC_REG_SEQ_LENGTH_3 = ADC_LR_LEN_1,
  408. /*!< ADC group regular sequencer enable with 3 ranks in the sequence */
  409. ADC_REG_SEQ_LENGTH_4 = ADC_LR_LEN_1 | ADC_LR_LEN_0,
  410. /*!< ADC group regular sequencer enable with 4 ranks in the sequence */
  411. ADC_REG_SEQ_LENGTH_5 = ADC_LR_LEN_2,
  412. /*!< ADC group regular sequencer enable with 5 ranks in the sequence */
  413. ADC_REG_SEQ_LENGTH_6 = ADC_LR_LEN_2 | ADC_LR_LEN_0,
  414. /*!< ADC group regular sequencer enable with 6 ranks in the sequence */
  415. ADC_REG_SEQ_LENGTH_7 = ADC_LR_LEN_2 | ADC_LR_LEN_1,
  416. /*!< ADC group regular sequencer enable with 7 ranks in the sequence */
  417. ADC_REG_SEQ_LENGTH_8 = ADC_LR_LEN_2 | ADC_LR_LEN_1 | ADC_LR_LEN_0,
  418. /*!< ADC group regular sequencer enable with 8 ranks in the sequence */
  419. ADC_REG_SEQ_LENGTH_9 = ADC_LR_LEN_3,
  420. /*!< ADC group regular sequencer enable with 9 ranks in the sequence */
  421. ADC_REG_SEQ_LENGTH_10 = ADC_LR_LEN_3 | ADC_LR_LEN_0,
  422. /*!< ADC group regular sequencer enable with 10 ranks in the sequence */
  423. ADC_REG_SEQ_LENGTH_11 = ADC_LR_LEN_3 | ADC_LR_LEN_1,
  424. /*!< ADC group regular sequencer enable with 11 ranks in the sequence */
  425. ADC_REG_SEQ_LENGTH_12 = ADC_LR_LEN_3 | ADC_LR_LEN_1 | ADC_LR_LEN_0,
  426. /*!< ADC group regular sequencer enable with 12 ranks in the sequence */
  427. ADC_REG_SEQ_LENGTH_13 = ADC_LR_LEN_3 | ADC_LR_LEN_2,
  428. /*!< ADC group regular sequencer enable with 13 ranks in the sequence */
  429. ADC_REG_SEQ_LENGTH_14 = ADC_LR_LEN_3 | ADC_LR_LEN_2 | ADC_LR_LEN_0,
  430. /*!< ADC group regular sequencer enable with 14 ranks in the sequence */
  431. ADC_REG_SEQ_LENGTH_15 = ADC_LR_LEN_3 | ADC_LR_LEN_2 | ADC_LR_LEN_1,
  432. /*!< ADC group regular sequencer enable with 15 ranks in the sequence */
  433. ADC_REG_SEQ_LENGTH_16 = ADC_LR_LEN_3 | ADC_LR_LEN_2 | ADC_LR_LEN_1 | ADC_LR_LEN_0,
  434. /*!< ADC group regular sequencer enable with 16 ranks in the sequence */
  435. } ADC_RegSeqLengthETypeDef;
  436. /**
  437. * @brief Sequencer ranks
  438. */
  439. typedef enum {
  440. ADC_REG_RANK_1 = 0x0UL,
  441. /*!< ADC group regular sequencer rank 1 */
  442. ADC_REG_RANK_2 = 0x1UL,
  443. /*!< ADC group regular sequencer rank 2 */
  444. ADC_REG_RANK_3 = 0x2UL,
  445. /*!< ADC group regular sequencer rank 3 */
  446. ADC_REG_RANK_4 = 0x3UL,
  447. /*!< ADC group regular sequencer rank 4 */
  448. ADC_REG_RANK_5 = 0x4UL,
  449. /*!< ADC group regular sequencer rank 5 */
  450. ADC_REG_RANK_6 = 0x5UL,
  451. /*!< ADC group regular sequencer rank 6 */
  452. ADC_REG_RANK_7 = 0x6UL,
  453. /*!< ADC group regular sequencer rank 7 */
  454. ADC_REG_RANK_8 = 0x7UL,
  455. /*!< ADC group regular sequencer rank 8 */
  456. ADC_REG_RANK_9 = 0x8UL,
  457. /*!< ADC group regular sequencer rank 9 */
  458. ADC_REG_RANK_10 = 0x9UL,
  459. /*!< ADC group regular sequencer rank 10 */
  460. ADC_REG_RANK_11 = 0xAUL,
  461. /*!< ADC group regular sequencer rank 11 */
  462. ADC_REG_RANK_12 = 0xBUL,
  463. /*!< ADC group regular sequencer rank 12 */
  464. ADC_REG_RANK_13 = 0xCUL,
  465. /*!< ADC group regular sequencer rank 13 */
  466. ADC_REG_RANK_14 = 0xDUL,
  467. /*!< ADC group regular sequencer rank 14 */
  468. ADC_REG_RANK_15 = 0xEUL,
  469. /*!< ADC group regular sequencer rank 15 */
  470. ADC_REG_RANK_16 = 0xFUL,
  471. /*!< ADC group regular sequencer rank 16 */
  472. } ADC_RegSeqRankETypeDef;
  473. /**
  474. * @brief Trigger source
  475. */
  476. typedef enum {
  477. ADC_REG_TRIG_SOFTWARE = 0x0,
  478. /*!<ADC group regular conversion trigger internal: SW start. */
  479. ADC_REG_TRIG_EXT_TIM0_CC = ADC_REG_TRIG_EXT_EDGE_DEFAULT,
  480. /*!<ADC group regular conversion trigger from external peripheral: TIM0 CC(capture compare: input capture or output capture). Trigger edge set to rising edge*/
  481. ADC_REG_TRIG_EXT_TIM1_CC = ADC_LR_EXTSEL_0 | ADC_REG_TRIG_EXT_EDGE_DEFAULT,
  482. /*!<ADC group regular conversion trigger from external peripheral: TIM1 CC(capture compare: input capture or output capture). Trigger edge set to rising edge*/
  483. ADC_REG_TRIG_EXT_TIM2_CC = ADC_LR_EXTSEL_1 | ADC_REG_TRIG_EXT_EDGE_DEFAULT,
  484. /*!<ADC group regular conversion trigger from external peripheral: TIM2 CC(capture compare: input capture or output capture). Trigger edge set to rising edge*/
  485. ADC_REG_TRIG_EXT_TIM3_CC = ADC_LR_EXTSEL_1 | ADC_LR_EXTSEL_0 | ADC_REG_TRIG_EXT_EDGE_DEFAULT,
  486. /*!<ADC group regular conversion trigger from external peripheral: TIM3 CC(capture compare: input capture or output capture). Trigger edge set to rising edge*/
  487. ADC_REG_TRIG_EXT_TIM4_CC = ADC_LR_EXTSEL_2 | ADC_REG_TRIG_EXT_EDGE_DEFAULT,
  488. /*!<ADC group regular conversion trigger from external peripheral: TIM4 CC(capture compare: input capture or output capture). Trigger edge set to rising edge*/
  489. ADC_REG_TRIG_EXT_TIM5_CC = ADC_LR_EXTSEL_2 | ADC_LR_EXTSEL_0 | ADC_REG_TRIG_EXT_EDGE_DEFAULT,
  490. /*!<ADC group regular conversion trigger from external peripheral: TIM5 CC(capture compare: input capture or output capture). Trigger edge set to rising edge*/
  491. ADC_REG_TRIG_EXT_TIM6_CC = ADC_LR_EXTSEL_2 | ADC_LR_EXTSEL_1 | ADC_REG_TRIG_EXT_EDGE_DEFAULT,
  492. /*!<ADC group regular conversion trigger from external peripheral: TIM6 CC(capture compare: input capture or output capture). Trigger edge set to rising edge*/
  493. ADC_REG_TRIG_EXT_TIM7_CC = ADC_LR_EXTSEL_2 | ADC_LR_EXTSEL_1 | ADC_LR_EXTSEL_0 | ADC_REG_TRIG_EXT_EDGE_DEFAULT,
  494. /*!<ADC group regular conversion trigger from external peripheral: TIM7 CC(capture compare: input capture or output capture). Trigger edge set to rising edge*/
  495. ADC_REG_TRIG_EXT_TIM0_TRGO = ADC_LR_EXTSEL_3 | ADC_REG_TRIG_EXT_EDGE_DEFAULT,
  496. /*!<ADC group regular conversion trigger from external peripheral: TIM0 TRGO. Trigger edge set to rising edge (default setting). */
  497. ADC_REG_TRIG_EXT_TIM1_TRGO = ADC_LR_EXTSEL_3 | ADC_LR_EXTSEL_0 | ADC_REG_TRIG_EXT_EDGE_DEFAULT,
  498. /*!<ADC group regular conversion trigger from external peripheral: TIM1 TRGO. Trigger edge set to rising edge (default setting). */
  499. ADC_REG_TRIG_EXT_TIM2_TRGO = ADC_LR_EXTSEL_3 | ADC_LR_EXTSEL_1 | ADC_REG_TRIG_EXT_EDGE_DEFAULT,
  500. /*!<ADC group regular conversion trigger from external peripheral: TIM2 TRGO. Trigger edge set to rising edge (default setting). */
  501. ADC_REG_TRIG_EXT_TIM3_TRGO = ADC_LR_EXTSEL_3 | ADC_LR_EXTSEL_1 | ADC_LR_EXTSEL_0 | ADC_REG_TRIG_EXT_EDGE_DEFAULT,
  502. /*!<ADC group regular conversion trigger from external peripheral: TIM3 TRGO. Trigger edge set to rising edge (default setting). */
  503. ADC_REG_TRIG_EXT_TIM4_TRGO = ADC_LR_EXTSEL_3 | ADC_LR_EXTSEL_2 | ADC_REG_TRIG_EXT_EDGE_DEFAULT,
  504. /*!<ADC group regular conversion trigger from external peripheral: TIM4 TRGO. Trigger edge set to rising edge (default setting). */
  505. ADC_REG_TRIG_EXT_TIM5_TRGO = ADC_LR_EXTSEL_3 | ADC_LR_EXTSEL_2 | ADC_LR_EXTSEL_0 | ADC_REG_TRIG_EXT_EDGE_DEFAULT,
  506. /*!<ADC group regular conversion trigger from external peripheral: TIM5 TRGO. Trigger edge set to rising edge (default setting). */
  507. ADC_REG_TRIG_EXT_TIM6_TRGO = ADC_LR_EXTSEL_3 | ADC_LR_EXTSEL_2 | ADC_LR_EXTSEL_1 | ADC_REG_TRIG_EXT_EDGE_DEFAULT,
  508. /*!<ADC group regular conversion trigger from external peripheral: TIM6 TRGO. Trigger edge set to rising edge (default setting). */
  509. ADC_REG_TRIG_EXT_TIM7_TRGO = ADC_LR_EXTSEL_3 | ADC_LR_EXTSEL_2 | ADC_LR_EXTSEL_1 | ADC_LR_EXTSEL_0 | ADC_REG_TRIG_EXT_EDGE_DEFAULT,
  510. /*!<ADC group regular conversion trigger from external peripheral: TIM7 TRGO. Trigger edge set to rising edge (default setting). */
  511. ADC_REG_TRIG_EXT_HRPWM_ADC_TRG0 = ADC_LR_EXTSEL_4 | ADC_REG_TRIG_EXT_EDGE_DEFAULT,
  512. /*!<ADC group regular conversion trigger from external peripheral: HRPWM_ADC_TRG0. Trigger edge set to rising edge (default setting). */
  513. ADC_REG_TRIG_EXT_HRPWM_ADC_TRG1 = ADC_LR_EXTSEL_4 | ADC_LR_EXTSEL_0 | ADC_REG_TRIG_EXT_EDGE_DEFAULT,
  514. /*!<ADC group regular conversion trigger from external peripheral: HRPWM_ADC_TRG1. Trigger edge set to rising edge (default setting). */
  515. ADC_REG_TRIG_EXT_HRPWM_ADC_TRG2 = ADC_LR_EXTSEL_4 | ADC_LR_EXTSEL_1 | ADC_REG_TRIG_EXT_EDGE_DEFAULT,
  516. /*!<ADC group regular conversion trigger from external peripheral: HRPWM_ADC_TRG2. Trigger edge set to rising edge (default setting). */
  517. ADC_REG_TRIG_EXT_HRPWM_ADC_TRG3 = ADC_LR_EXTSEL_4 | ADC_LR_EXTSEL_1 | ADC_LR_EXTSEL_0 | ADC_REG_TRIG_EXT_EDGE_DEFAULT,
  518. /*!<ADC group regular conversion trigger from external peripheral: HRPWM_ADC_TRG3. Trigger edge set to rising edge (default setting). */
  519. ADC_REG_TRIG_EXT_HRPWM_ADC_TRG4 = ADC_LR_EXTSEL_4 | ADC_LR_EXTSEL_2 | ADC_REG_TRIG_EXT_EDGE_DEFAULT,
  520. /*!<ADC group regular conversion trigger from external peripheral: HRPWM_ADC_TRG4. Trigger edge set to rising edge (default setting). */
  521. ADC_REG_TRIG_EXT_HRPWM_ADC_TRG5 = ADC_LR_EXTSEL_4 | ADC_LR_EXTSEL_2 | ADC_LR_EXTSEL_0 | ADC_REG_TRIG_EXT_EDGE_DEFAULT,
  522. /*!<ADC group regular conversion trigger from external peripheral: HRPWM_ADC_TRG5. Trigger edge set to rising edge (default setting). */
  523. ADC_REG_TRIG_EXT_HRPWM_ADC_TRG6 = ADC_LR_EXTSEL_4 | ADC_LR_EXTSEL_2 | ADC_LR_EXTSEL_1 | ADC_REG_TRIG_EXT_EDGE_DEFAULT,
  524. /*!<ADC group regular conversion trigger from external peripheral: HRPWM_ADC_TRG6. Trigger edge set to rising edge (default setting). */
  525. ADC_REG_TRIG_EXT_HRPWM_ADC_TRG7 = ADC_LR_EXTSEL_4 | ADC_LR_EXTSEL_2 | ADC_LR_EXTSEL_1 | ADC_LR_EXTSEL_0 | ADC_REG_TRIG_EXT_EDGE_DEFAULT,
  526. /*!<ADC group regular conversion trigger from external peripheral: HRPWM_ADC_TRG7. Trigger edge set to rising edge (default setting). */
  527. ADC_REG_TRIG_EXT_PIN = ADC_LR_EXTSEL_4 | ADC_LR_EXTSEL_3 | ADC_REG_TRIG_EXT_EDGE_DEFAULT,
  528. /*!<ADC group regular conversion trigger from external peripheral: external GPIO PIN: PA8. Trigger edge set to rising edge (default setting). */
  529. } ADC_RegExtTrigSrcETypeDef;
  530. /**
  531. * @brief Trigger edge
  532. */
  533. typedef enum {
  534. ADC_INJ_TRIG_EXT_RISING = ADC_JLR_JEXTEN_0,
  535. /*!< ADC group injected conversion trigger polarity set to rising edge */
  536. ADC_INJ_TRIG_EXT_FALLING = ADC_JLR_JEXTEN_1,
  537. /*!< ADC group injected conversion trigger polarity set to falling edge */
  538. ADC_INJ_TRIG_EXT_RISINGFALLING = ADC_JLR_JEXTEN_1 | ADC_JLR_JEXTEN_0,
  539. /*!< ADC group injected conversion trigger polarity set to both rising and falling edges */
  540. } ADC_InjExtTrigEdgeETypeDef;
  541. /**
  542. * @brief Automatic trigger mode
  543. */
  544. typedef enum {
  545. ADC_INJ_TRIG_INDEPENDENT = 0x0,
  546. /*!< ADC group injected conversion trigger independent. Setting mandatory if ADC group injected injected trigger source is set to an external trigger. */
  547. ADC_INJ_TRIG_FROM_GRP_REGULAR = ADC_CR1_JAUTO,
  548. /*!< ADC group injected conversion trigger from ADC group regular. Setting compliant only with group injected trigger source set to SW start,
  549. without any further action on ADC group injected conversion start or stop: in this case, ADC group injected is controlled only from ADC group regular. */
  550. } ADC_InjAutoTrigETypeDef;
  551. /**
  552. * @brief Sequencer scan length
  553. */
  554. typedef enum {
  555. ADC_INJ_SEQ_LENGTH_1 = 0x0,
  556. /*!< ADC group injected sequencer disable (equivalent to sequencer of 1 rank: ADC conversion on only 1 channel) */
  557. ADC_INJ_SEQ_LENGTH_2 = ADC_JLR_JLEN_0,
  558. /*!< ADC group injected sequencer enable with 2 ranks in the sequence */
  559. ADC_INJ_SEQ_LENGTH_3 = ADC_JLR_JLEN_1,
  560. /*!< ADC group injected sequencer enable with 3 ranks in the sequence */
  561. ADC_INJ_SEQ_LENGTH_4 = ADC_JLR_JLEN_1 | ADC_JLR_JLEN_0,
  562. /*!< ADC group injected sequencer enable with 4 ranks in the sequence */
  563. } ADC_InjSeqLengthETypeDef;
  564. /**
  565. * @brief Sequencer ranks
  566. */
  567. typedef enum {
  568. ADC_INJ_RANK_1 = ADC_JSQR_JSQ1_Pos,
  569. /*!< ADC group injected sequencer position 1 */
  570. ADC_INJ_RANK_2 = ADC_JSQR_JSQ2_Pos,
  571. /*!< ADC group injected sequencer position 2 */
  572. ADC_INJ_RANK_3 = ADC_JSQR_JSQ3_Pos,
  573. /*!< ADC group injected sequencer position 3 */
  574. ADC_INJ_RANK_4 = ADC_JSQR_JSQ4_Pos,
  575. /*!< ADC group injected sequencer position 4 */
  576. } ADC_InjSeqRankETypeDef;
  577. /**
  578. * @brief Sequencer discontinuous mode
  579. */
  580. typedef enum {
  581. ADC_INJ_SEQ_DISCONT_DISABLE = 0x0,
  582. /*!< ADC group injected sequencer discontinuous mode disable */
  583. ADC_INJ_SEQ_DISCONT_ENABLE = ADC_CR1_JDISCEN,
  584. /*!< ADC group injected sequencer discontinuous mode enable with sequence interruption every rank */
  585. } ADC_InjDiscontEnETypeDef;
  586. /**
  587. * @brief Trigger source
  588. */
  589. typedef enum {
  590. ADC_INJ_TRIG_SOFTWARE = 0x0,
  591. /*!<ADC group injected conversion trigger internal: SW start. */
  592. ADC_INJ_TRIG_EXT_TIM0_CC = ADC_INJ_TRIG_EXT_EDGE_DEFAULT,
  593. /*!<ADC group injected conversion trigger from external peripheral: TIM0 CC(capture compare: input capture or output capture). Trigger edge set to rising edge*/
  594. ADC_INJ_TRIG_EXT_TIM1_CC = ADC_JLR_JEXTSEL_0 | ADC_INJ_TRIG_EXT_EDGE_DEFAULT,
  595. /*!<ADC group injected conversion trigger from external peripheral: TIM1 CC(capture compare: input capture or output capture). Trigger edge set to rising edge*/
  596. ADC_INJ_TRIG_EXT_TIM2_CC = ADC_JLR_JEXTSEL_1 | ADC_INJ_TRIG_EXT_EDGE_DEFAULT,
  597. /*!<ADC group injected conversion trigger from external peripheral: TIM2 CC(capture compare: input capture or output capture). Trigger edge set to rising edge*/
  598. ADC_INJ_TRIG_EXT_TIM3_CC = ADC_JLR_JEXTSEL_1 | ADC_JLR_JEXTSEL_0 | ADC_INJ_TRIG_EXT_EDGE_DEFAULT,
  599. /*!<ADC group injected conversion trigger from external peripheral: TIM3 CC(capture compare: input capture or output capture). Trigger edge set to rising edge*/
  600. ADC_INJ_TRIG_EXT_TIM4_CC = ADC_JLR_JEXTSEL_2 | ADC_INJ_TRIG_EXT_EDGE_DEFAULT,
  601. /*!<ADC group injected conversion trigger from external peripheral: TIM4 CC(capture compare: input capture or output capture). Trigger edge set to rising edge*/
  602. ADC_INJ_TRIG_EXT_TIM5_CC = ADC_JLR_JEXTSEL_2 | ADC_JLR_JEXTSEL_0 | ADC_INJ_TRIG_EXT_EDGE_DEFAULT,
  603. /*!<ADC group injected conversion trigger from external peripheral: TIM5 CC(capture compare: input capture or output capture). Trigger edge set to rising edge*/
  604. ADC_INJ_TRIG_EXT_TIM6_CC = ADC_JLR_JEXTSEL_2 | ADC_JLR_JEXTSEL_1 | ADC_INJ_TRIG_EXT_EDGE_DEFAULT,
  605. /*!<ADC group injected conversion trigger from external peripheral: TIM6 CC(capture compare: input capture or output capture). Trigger edge set to rising edge*/
  606. ADC_INJ_TRIG_EXT_TIM7_CC = ADC_JLR_JEXTSEL_2 | ADC_JLR_JEXTSEL_1 | ADC_JLR_JEXTSEL_0 | ADC_INJ_TRIG_EXT_EDGE_DEFAULT,
  607. /*!<ADC group injected conversion trigger from external peripheral: TIM7 CC(capture compare: input capture or output capture). Trigger edge set to rising edge*/
  608. ADC_INJ_TRIG_EXT_TIM0_TRGO = ADC_JLR_JEXTSEL_3 | ADC_INJ_TRIG_EXT_EDGE_DEFAULT,
  609. /*!<ADC group injected conversion trigger from external peripheral: TIM0 TRGO. Trigger edge set to rising edge (default setting). */
  610. ADC_INJ_TRIG_EXT_TIM1_TRGO = ADC_JLR_JEXTSEL_3 | ADC_JLR_JEXTSEL_0 | ADC_INJ_TRIG_EXT_EDGE_DEFAULT,
  611. /*!<ADC group injected conversion trigger from external peripheral: TIM1 TRGO. Trigger edge set to rising edge (default setting). */
  612. ADC_INJ_TRIG_EXT_TIM2_TRGO = ADC_JLR_JEXTSEL_3 | ADC_JLR_JEXTSEL_1 | ADC_INJ_TRIG_EXT_EDGE_DEFAULT,
  613. /*!<ADC group injected conversion trigger from external peripheral: TIM2 TRGO. Trigger edge set to rising edge (default setting). */
  614. ADC_INJ_TRIG_EXT_TIM3_TRGO = ADC_JLR_JEXTSEL_3 | ADC_JLR_JEXTSEL_1 | ADC_JLR_JEXTSEL_0 | ADC_INJ_TRIG_EXT_EDGE_DEFAULT,
  615. /*!<ADC group injected conversion trigger from external peripheral: TIM3 TRGO. Trigger edge set to rising edge (default setting). */
  616. ADC_INJ_TRIG_EXT_TIM4_TRGO = ADC_JLR_JEXTSEL_3 | ADC_JLR_JEXTSEL_2 | ADC_INJ_TRIG_EXT_EDGE_DEFAULT,
  617. /*!<ADC group injected conversion trigger from external peripheral: TIM4 TRGO. Trigger edge set to rising edge (default setting). */
  618. ADC_INJ_TRIG_EXT_TIM5_TRGO = ADC_JLR_JEXTSEL_3 | ADC_JLR_JEXTSEL_2 | ADC_JLR_JEXTSEL_0 | ADC_INJ_TRIG_EXT_EDGE_DEFAULT,
  619. /*!<ADC group injected conversion trigger from external peripheral: TIM5 TRGO. Trigger edge set to rising edge (default setting). */
  620. ADC_INJ_TRIG_EXT_TIM6_TRGO = ADC_JLR_JEXTSEL_3 | ADC_JLR_JEXTSEL_2 | ADC_JLR_JEXTSEL_1 | ADC_INJ_TRIG_EXT_EDGE_DEFAULT,
  621. /*!<ADC group injected conversion trigger from external peripheral: TIM6 TRGO. Trigger edge set to rising edge (default setting). */
  622. ADC_INJ_TRIG_EXT_TIM7_TRGO = ADC_JLR_JEXTSEL_3 | ADC_JLR_JEXTSEL_2 | ADC_JLR_JEXTSEL_1 | ADC_JLR_JEXTSEL_0 | ADC_INJ_TRIG_EXT_EDGE_DEFAULT,
  623. /*!<ADC group injected conversion trigger from external peripheral: TIM7 TRGO. Trigger edge set to rising edge (default setting). */
  624. ADC_INJ_TRIG_EXT_HRPWM_ADC_TRG0 = ADC_JLR_JEXTSEL_4 | ADC_INJ_TRIG_EXT_EDGE_DEFAULT,
  625. /*!<ADC group injected conversion trigger from external peripheral: HRPWM_ADC_TRG0. Trigger edge set to rising edge (default setting). */
  626. ADC_INJ_TRIG_EXT_HRPWM_ADC_TRG1 = ADC_JLR_JEXTSEL_4 | ADC_JLR_JEXTSEL_0 | ADC_INJ_TRIG_EXT_EDGE_DEFAULT,
  627. /*!<ADC group injected conversion trigger from external peripheral: HRPWM_ADC_TRG1. Trigger edge set to rising edge (default setting). */
  628. ADC_INJ_TRIG_EXT_HRPWM_ADC_TRG2 = ADC_JLR_JEXTSEL_4 | ADC_JLR_JEXTSEL_1 | ADC_INJ_TRIG_EXT_EDGE_DEFAULT,
  629. /*!<ADC group injected conversion trigger from external peripheral: HRPWM_ADC_TRG2. Trigger edge set to rising edge (default setting). */
  630. ADC_INJ_TRIG_EXT_HRPWM_ADC_TRG3 = ADC_JLR_JEXTSEL_4 | ADC_JLR_JEXTSEL_1 | ADC_JLR_JEXTSEL_0 | ADC_INJ_TRIG_EXT_EDGE_DEFAULT,
  631. /*!<ADC group injected conversion trigger from external peripheral: HRPWM_ADC_TRG3. Trigger edge set to rising edge (default setting). */
  632. ADC_INJ_TRIG_EXT_HRPWM_ADC_TRG4 = ADC_JLR_JEXTSEL_4 | ADC_JLR_JEXTSEL_2 | ADC_INJ_TRIG_EXT_EDGE_DEFAULT,
  633. /*!<ADC group injected conversion trigger from external peripheral: HRPWM_ADC_TRG4. Trigger edge set to rising edge (default setting). */
  634. ADC_INJ_TRIG_EXT_HRPWM_ADC_TRG5 = ADC_JLR_JEXTSEL_4 | ADC_JLR_JEXTSEL_2 | ADC_JLR_JEXTSEL_0 | ADC_INJ_TRIG_EXT_EDGE_DEFAULT,
  635. /*!<ADC group injected conversion trigger from external peripheral: HRPWM_ADC_TRG5. Trigger edge set to rising edge (default setting). */
  636. ADC_INJ_TRIG_EXT_HRPWM_ADC_TRG6 = ADC_JLR_JEXTSEL_4 | ADC_JLR_JEXTSEL_2 | ADC_JLR_JEXTSEL_1 | ADC_INJ_TRIG_EXT_EDGE_DEFAULT,
  637. /*!<ADC group injected conversion trigger from external peripheral: HRPWM_ADC_TRG6. Trigger edge set to rising edge (default setting). */
  638. ADC_INJ_TRIG_EXT_HRPWM_ADC_TRG7 = ADC_JLR_JEXTSEL_4 | ADC_JLR_JEXTSEL_2 | ADC_JLR_JEXTSEL_1 | ADC_JLR_JEXTSEL_0 | ADC_INJ_TRIG_EXT_EDGE_DEFAULT,
  639. /*!<ADC group injected conversion trigger from external peripheral: HRPWM_ADC_TRG7. Trigger edge set to rising edge (default setting). */
  640. ADC_INJ_TRIG_EXT_PIN = ADC_JLR_JEXTSEL_4 | ADC_JLR_JEXTSEL_3 | ADC_INJ_TRIG_EXT_EDGE_DEFAULT,
  641. /*!<ADC group injected conversion trigger from external peripheral: external GPIO PIN: PA9. Trigger edge set to rising edge (default setting). */
  642. } ADC_InjExtTrigSrcETypeDef;
  643. /**
  644. * @brief Single or differential ending
  645. */
  646. typedef enum {
  647. ADC_DIFSEL_DIFFER = 0x1UL,
  648. /*!< ADC the channel works in differential input mode*/
  649. ADC_DIFSEL_SINGLE = 0x0UL,
  650. /*!< ADC the channel works in single input mode*/
  651. } ADC_DiffSelETypeDef;
  652. /**
  653. * @brief select ecu group
  654. */
  655. typedef enum {
  656. ADC_ECR_GROUP0 = 0x0UL,
  657. /*!< Select the first set of registers associated with the ECU -- ECR0*/
  658. ADC_ECR_GROUP1 = 0x1UL,
  659. /*!< Select the second set of registers associated with the ECU -- ECR1*/
  660. ADC_ECR_GROUP2 = 0x2UL,
  661. /*!< Select the third set of registers associated with the ECU -- ECR2*/
  662. ADC_ECR_GROUP3 = 0x3UL,
  663. /*!< Select the forth set of registers associated with the ECU -- ECR3*/
  664. } ADC_EcuGroupETypeDef;
  665. /**
  666. * @brief ADC CALIB GROUP
  667. */
  668. typedef enum {
  669. ADC_CALIB_GROUP0 = 0x0UL,
  670. ADC_CALIB_GROUP1 = 0x1UL,
  671. ADC_CALIB_GROUP2 = 0x2UL,
  672. ADC_CALIB_GROUP3 = 0x3UL,
  673. } ADC_CalibGroupETypeDef;
  674. /**
  675. * @brief Analog watchdog number
  676. */
  677. typedef enum {
  678. ADC_AWD0 = 0x0UL,
  679. ADC_AWD1 = 0x1UL,
  680. ADC_AWD2 = 0x2UL,
  681. } ADC_AnologWDETypeDef;
  682. /**
  683. * @brief Analog watchdog Thresholds
  684. */
  685. typedef enum {
  686. ADC_AWD_THRESHOLD_HIGH = (int32_t)ADC_TR1_HT1,
  687. /*!< ADC analog watchdog threshold high */
  688. ADC_AWD_THRESHOLD_LOW = ADC_TR1_LT1,
  689. /*!< ADC analog watchdog threshold low */
  690. ADC_AWD_THRESHOLDS_HIGH_LOW = (int32_t)(ADC_TR1_HT1 | ADC_TR1_LT1),
  691. /*!< ADC analog watchdog both thresholds high and low concatenated into the same data */
  692. } ADC_AnologThresholdETypeDef;
  693. /**
  694. * @brief Analog watchdog filtering config
  695. */
  696. typedef enum {
  697. ADC_AWD_FILTERING_NONE = 0x0,
  698. /*!< ADC analog wathdog no filtering, one out-of-window sample is needed to raise flag */
  699. ADC_AWD_FILTERING_1 = ADC_AWD0CR_AWD0FILT_0,
  700. /*!< ADC analog wathdog 2 consecutives out-of-window samples are needed to raise flag */
  701. ADC_AWD_FILTERING_2 = ADC_AWD0CR_AWD0FILT_1,
  702. /*!< ADC analog wathdog 3 consecutives out-of-window samples are needed to raise flag */
  703. ADC_AWD_FILTERING_3 = ADC_AWD0CR_AWD0FILT_1 | ADC_AWD0CR_AWD0FILT_0,
  704. /*!< ADC analog wathdog 4 consecutives out-of-window samples are needed to raise flag */
  705. ADC_AWD_FILTERING_4 = ADC_AWD0CR_AWD0FILT_2,
  706. /*!< ADC analog wathdog 5 consecutives out-of-window samples are needed to raise flag */
  707. ADC_AWD_FILTERING_5 = ADC_AWD0CR_AWD0FILT_2 | ADC_AWD0CR_AWD0FILT_0,
  708. /*!< ADC analog wathdog 6 consecutives out-of-window samples are needed to raise flag */
  709. ADC_AWD_FILTERING_6 = ADC_AWD0CR_AWD0FILT_2 | ADC_AWD0CR_AWD0FILT_1,
  710. /*!< ADC analog wathdog 7 consecutives out-of-window samples are needed to raise flag */
  711. ADC_AWD_FILTERING_7 = ADC_AWD0CR_AWD0FILT_2 | ADC_AWD0CR_AWD0FILT_1 | ADC_AWD0CR_AWD0FILT_0,
  712. /*!< ADC analog wathdog 8 consecutives out-of-window samples are needed to raise flag */
  713. ADC_AWD_FILTERING_8 = ADC_AWD0CR_AWD0FILT_3,
  714. /*!< ADC analog wathdog 9 consecutives out-of-window samples are needed to raise flag */
  715. ADC_AWD_FILTERING_9 = ADC_AWD0CR_AWD0FILT_3 | ADC_AWD0CR_AWD0FILT_0,
  716. /*!< ADC analog wathdog 10 consecutives out-of-window samples are needed to raise flag */
  717. ADC_AWD_FILTERING_10 = ADC_AWD0CR_AWD0FILT_3 | ADC_AWD0CR_AWD0FILT_1,
  718. /*!< ADC analog wathdog 11 consecutives out-of-window samples are needed to raise flag */
  719. ADC_AWD_FILTERING_11 = ADC_AWD0CR_AWD0FILT_3 | ADC_AWD0CR_AWD0FILT_1 | ADC_AWD0CR_AWD0FILT_0,
  720. /*!< ADC analog wathdog 12 consecutives out-of-window samples are needed to raise flag */
  721. ADC_AWD_FILTERING_12 = ADC_AWD0CR_AWD0FILT_3 | ADC_AWD0CR_AWD0FILT_2,
  722. /*!< ADC analog wathdog 13 consecutives out-of-window samples are needed to raise flag */
  723. ADC_AWD_FILTERING_13 = ADC_AWD0CR_AWD0FILT_3 | ADC_AWD0CR_AWD0FILT_2 | ADC_AWD0CR_AWD0FILT_0,
  724. /*!< ADC analog wathdog 14 consecutives out-of-window samples are needed to raise flag */
  725. ADC_AWD_FILTERING_14 = ADC_AWD0CR_AWD0FILT_3 | ADC_AWD0CR_AWD0FILT_2 | ADC_AWD0CR_AWD0FILT_1,
  726. /*!< ADC analog wathdog 15 consecutives out-of-window samples are needed to raise flag */
  727. ADC_AWD_FILTERING_15 = ADC_AWD0CR_AWD0FILT_3 | ADC_AWD0CR_AWD0FILT_2 | ADC_AWD0CR_AWD0FILT_1 | ADC_AWD0CR_AWD0FILT_0,
  728. /*!< ADC analog wathdog 16 consecutives out-of-window samples are needed to raise flag */
  729. } ADC_AnologWDFliterETypeDef;
  730. /**
  731. * @brief ADC Transfer data mode set ADC_DMA_CR->TCR
  732. */
  733. typedef enum {
  734. ADC_REG_DMA_TRANSFER_DISABLE = 0x0,
  735. ADC_REG_DMA_TRANSFER_SINGLE = ADC_DMA_TCR_START,
  736. ADC_REG_DMA_TRANSFER_CIRCLE = ADC_DMA_TCR_CIRC | ADC_DMA_TCR_START,
  737. } ADC_DMATransferModeETypeDef;
  738. /**
  739. * @brief ADC instance Channel number
  740. */
  741. typedef enum {
  742. ADC_CHANNEL_0 = 0UL,
  743. /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN0 */
  744. ADC_CHANNEL_1 = 1UL,
  745. /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN1 */
  746. ADC_CHANNEL_2 = 2UL,
  747. /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN2 */
  748. ADC_CHANNEL_3 = 3UL,
  749. /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN3 */
  750. ADC_CHANNEL_4 = 4UL,
  751. /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN4 */
  752. ADC_CHANNEL_5 = 5UL,
  753. /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN5 */
  754. ADC_CHANNEL_6 = 6UL,
  755. /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN6 */
  756. ADC_CHANNEL_7 = 7UL,
  757. /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN7 */
  758. ADC_CHANNEL_8 = 8UL,
  759. /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN8 */
  760. ADC_CHANNEL_9 = 9UL,
  761. /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN9 */
  762. ADC_CHANNEL_10 = 10UL,
  763. /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN10 */
  764. ADC_CHANNEL_TEMPSENSOR = 11UL,
  765. /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN11 */
  766. } ADC_ChannelSelETypeDef;
  767. /**
  768. * @brief ADC group regular oversampling structure definition
  769. */
  770. typedef struct __ADC_OversamplingTypeDef {
  771. ADC_OverSampROVSMETypeDef OverSampResetMode; /*!< Set ADC over sample reset mode,only regular group is valid */
  772. ADC_OverSampTROVSETypeDef TrigOverSamp; /*!< Set ADC trigger over sample */
  773. ADC_OverSampShiftETypeDef OverSampShiftBit; /*!< Set ADC over sample shift bit */
  774. ADC_OverSampRatioETypeDef OverSampRatio; /*!< Set ADC over sample ratio */
  775. } ADC_OversamplingTypeDef;
  776. /** @defgroup LL_ADC_INIT ADC Exported Init structure
  777. * @brief Structure definition of some features of ADC instance.
  778. * @note These parameters have an impact on ADC scope: ADC instance.
  779. * Affects both group regular and group injected.
  780. * Refer to corresponding unitary functions into
  781. * @note The setting of these parameters by function reference LL_ADC_Init()
  782. * is conditioned to ADC state:
  783. * ADC instance must be disabled.
  784. */
  785. typedef struct __ADC_InitTypeDef {
  786. uint32_t NormInterrupt; /*!< Set ADC Normal interrupt paramter cconfig.
  787. This parameter can be combination value of reference LL_ADC_IT */
  788. ADC_SyncEnETypeDef Synchronization; /*!< Set ADC synchronization */
  789. ADC_AnologCtlETypeDef AnologCfg; /*!< Set ADC anolog paramter cconfig */
  790. ADC_OverRunModeETypeDef Overrun; /*!< Set ADC group regular behavior in case of overrun: data preserved or overwritten */
  791. LL_FuncStatusETypeDef RegOversampMode; /*!< Specify whether the regular group oversampling feature is enabled or disabled */
  792. LL_FuncStatusETypeDef InjOversampMode; /*!< Specify whether the injected group oversampling feature is enabled or disabled */
  793. ADC_OversamplingTypeDef OverSampling; /*!< Specify the Oversampling parameters.Caution: this setting overwrites the
  794. previous oversampling configuration if oversampling is already enabled. */
  795. } ADC_InitTypeDef;
  796. /**
  797. * @brief Structure definition of some features of ADC group regular.
  798. * @note These parameters have an impact on ADC scope: ADC group regular.
  799. * Refer to corresponding unitary functions into
  800. * (functions with prefix "REG").
  801. */
  802. typedef struct __ADC_REG_InitTypeDef {
  803. ADC_ChannelSelETypeDef Channel; /*!< Set ADC group regular conversion Channel. */
  804. LL_FuncStatusETypeDef SampInterrupt; /*!< Configures the ADC conversion Channel Sample interrupt. */
  805. ADC_RegSeqRankETypeDef SequencerPos; /*!< Set SQR is configured in combination with length for the number of conversions */
  806. ADC_RegExtTrigSrcETypeDef TriggerSource; /*!< Set ADC group regular conversion trigger source: internal (SW start)
  807. or from external peripheral(timer event,hrpwm trigger , up edge). */
  808. ADC_RegSeqLengthETypeDef SequencerLength; /*!< Set ADC group regular sequencer length. */
  809. ADC_RegDiscontETypeDef SequencerDiscont; /*!< Set ADC group regular sequencer discontinuous mode: sequence subdivided
  810. and scan conversions interrupted every selected number of ranks. */
  811. ADC_RegConvModeETypeDef ContinuousMode; /*!< Set ADC continuous conversion mode on ADC group regular, whether ADC
  812. conversions are performedin single mode (one conversion per trigger). or in
  813. continuous mode (after the first trigger,following conversions launched
  814. successively automatically). */
  815. ADC_DiffSelETypeDef DifferSel; /*!< Set ADC group regular channel is differential or single mode */
  816. ADC_SampTimeETypeDef SampTimClk; /*!< Set ADC group regular channel sample clk length */
  817. } ADC_REG_InitTypeDef;
  818. /**
  819. * @brief Structure definition of some features of ADC group injected.
  820. * @note These parameters have an impact on ADC scope: ADC group injected.
  821. * (functions with prefix "INJ").
  822. */
  823. typedef struct __ADC_INJ_InitTypeDef {
  824. ADC_ChannelSelETypeDef Channel; /*!< Set ADC group injected conversion Channel. */
  825. ADC_InjSeqRankETypeDef SequencerPos; /*!< Set JSQR is configured in combination with length for the number of
  826. conversions the channel is placed on. */
  827. ADC_InjExtTrigSrcETypeDef TriggerSource; /*!< Set ADC group injected conversion trigger source: internal (SW start)
  828. or from external peripheral (timer event, external interrupt line). */
  829. ADC_InjSeqLengthETypeDef SequencerLength; /*!< Set ADC group injected sequencer length. */
  830. ADC_InjDiscontEnETypeDef SequencerDiscont; /*!< Set ADC group injected sequencer discontinuous mode: sequence
  831. subdivided and scan conversions interrupted every selected number of ranks. */
  832. ADC_InjAutoTrigETypeDef TrigAuto; /*!< Set ADC group injected conversion trigger: independent or from ADC group regular. */
  833. } ADC_INJ_InitTypeDef;
  834. /**
  835. * @brief Structure definition of some features of ADC to ECU.
  836. * @note These parameters have an impact on ADC scope: ADC to ECU.
  837. * Electric quantity parameter calculation configuration.
  838. */
  839. typedef struct __ADC_ECUConfTypeDef {
  840. ADC_EcuGroupETypeDef GroupSel; /*!< Each ADC has four sets of ECU configurations, and the ECU is divided into four events. */
  841. ADC_ChannelSelETypeDef AddrDataSel; /*!< Set ADC to ECU: The ECU fetches data from the channel address of the ADC . */
  842. ADC_AnologWDETypeDef PingPongUpZero; /*!< Set Sinusoidal wave above zero detection of the selected watchdog. */
  843. ADC_AnologWDETypeDef PingPongDownZero; /*!< SetSinusoidal wave down through zero detection of the selected watchdog. */
  844. ADC_ChannelSelETypeDef AWD2SourceSel; /*!< Set Watchdog 2 monitors channel sources. */
  845. ADC_ChannelSelETypeDef AWD1SourceSel; /*!< Set Watchdog 1 monitors channel sources. */
  846. ADC_ChannelSelETypeDef AWD0SourceSel; /*!< Set Watchdog 0 monitors channel sources. */
  847. } ADC_ECUConfTypeDef;
  848. /**
  849. * @brief Structure definition of ADC analog watchdog
  850. * @note The setting of these parameters by function HAL_ADC_AnalogWDGConfig() is conditioned to ADC state.
  851. * ADC state can be either:
  852. * - For all parameters except 'HighThreshold', 'LowThreshold': ADC disabled or ADC enabled without conversion on going
  853. * on ADC groups regular and injected.
  854. * - For parameters 'HighThreshold', 'LowThreshold': ADC enabled with conversion on going on regular and injected groups.
  855. */
  856. typedef struct __ADC_AnalogWDGCfgTypeDef {
  857. uint32_t Channel; /*!< Select which ADC channel to monitor by analog watchdog.
  858. This parameter can be combination value of reference LL_ADC_AWD_CHANNELS. */
  859. int16_t HighThreshold; /*!< Configure the ADC analog watchdog High threshold value.
  860. This parameter must be a number between Min_Data = 0x0000 and Max_Data = 0xFFFF. */
  861. int16_t LowThreshold; /*!< Configures the ADC analog watchdog Low threshold value.
  862. This parameter must be a number between Min_Data = 0x0000 and Max_Data = 0xFFFF. */
  863. ADC_AnologWDETypeDef WatchdogNumber; /*!< Select which ADC analog watchdog is monitoring the selected channel. */
  864. ADC_AnologWDFliterETypeDef Filtering; /*!< Specify whether filtering should be use and the number of samples to consider.
  865. Before setting flag or raising interrupt, analog watchdog can wait to have several
  866. consecutive out-of-window samples. This parameter allows to configure this number. */
  867. } ADC_AnalogWDGCfgTypeDef;
  868. /**
  869. * @brief Structure definition of ADC DMA Transfer
  870. * @note The setting of these parameters by function LL_ADC_DMATransferConfig() is conditioned to ADC state.
  871. * Each channel corresponds to a set of DMA, and only regular channels can use DMA.
  872. */
  873. typedef struct __ADC_DMATransferCfgTypeDef {
  874. ADC_ChannelSelETypeDef Channel; /*!< Select which ADC direct memory access the selected channel. */
  875. LL_FuncStatusETypeDef HalfInterrupt; /*!< Configures the ADC direct memory access Half interrupt. */
  876. LL_FuncStatusETypeDef FullInterrupt; /*!< Configures the ADC direct memory access Full interrupt. */
  877. ADC_DMATransferModeETypeDef TransferMode; /*!< Configure the DMA transfer mode to be single or cyclic. */
  878. uint32_t Address; /*!< Configure the address of the DMA transfer Buffer ,Only SECTION_RAMB,
  879. SECTION_RAMB can be configured . */
  880. uint32_t Length; /*!< Configure the length of data (byte units) for a single DMA transfer.
  881. This parameter must be a number between Min_Data = 0x0000 and Max_Data = 0xFFFF. */
  882. } ADC_DMATransferCfgTypeDef;
  883. /**
  884. * @brief Calibration parameter definitions for ADC groups regular and injected
  885. */
  886. typedef struct __ADC_CalibrationTypeDef {
  887. ADC_ChannelSelETypeDef Channel; /*!< Select which ADC channel congfigure Calibration parameters. */
  888. ADC_CalibGroupETypeDef CalibrationGroup; /*!< Set ADC calibration group parameter selection. */
  889. int16_t Offset; /*!< Configure ADC calibration offset,default value is 0x0.
  890. This parameter must be a number between Min_Data = 0x0000 and Max_Data = 0xFFFF */
  891. uint16_t Gain; /*!< Configure ADC calibration gain defaulr value is 0x2000.
  892. This parameter must be a number between Min_Data = 0x0000 and Max_Data = 0xFFFF */
  893. } ADC_CalibrationTypeDef;
  894. /**
  895. * @brief Read ADC self-calibration data
  896. */
  897. typedef struct {
  898. int16_t SingleOffset; /*!< Read ADC single-ended self-calibration data*/
  899. uint16_t SingleGain; /*!< Read ADC single-ended self-calibration data*/
  900. int16_t DiffOffset; /*!< Read ADC differential self-calibration data*/
  901. uint16_t DiffGain; /*!< Read ADC differential self-calibration data*/
  902. int16_t SingleBuffOffset; /*!< Read ADC single-ended plus BUFF self-calibration data*/
  903. uint16_t SingleBuffGain; /*!< Read ADC single-ended plus BUFF self-calibration data*/
  904. } ADC_CalibrationDataTypeDef;
  905. /**
  906. * @}
  907. */
  908. /* Exported macro ------------------------------------------------------------*/
  909. /** @defgroup ADC_LL_Exported_Macros ADC LL Exported Macros
  910. * @brief ADC LL Exported Macros
  911. * @{
  912. */
  913. /**
  914. * @brief Driver macro reserved for internal use: set a pointer to
  915. * a register from a register basis from which an offset
  916. * is applied.
  917. * @param __REG__ Register basis from which the offset is applied.
  918. * @param __REG_OFFFSET__ Offset to be applied (unit: number of registers).
  919. * @retval Pointer to register address
  920. */
  921. #define __ADC_PTR_REG_OFFSET(__REG__, __REG_OFFFSET__) \
  922. ((__IO uint32_t *)((uint32_t) ((uint32_t)(&(__REG__)) + ((__REG_OFFFSET__) << 2UL))))
  923. /** @addtogroup ADC_LL_Operation_ADC_Group_Regular Operation on ADC hierarchical scope: group regular
  924. * @{
  925. */
  926. /**
  927. * @brief Start ADC group regular conversion.
  928. * @note This function is relevant for both
  929. * internal trigger (SW start) and external trigger:
  930. * - If ADC trigger has been set to software start, ADC conversion
  931. * starts immediately.
  932. * - If ADC trigger has been set to external trigger, ADC conversion
  933. * will start at next trigger event (on the selected trigger edge)
  934. * following the ADC start conversion command.
  935. * @note Setting of this feature is conditioned to
  936. * ADC state:
  937. * ADC must be enabled without conversion on going on group regular,
  938. * without conversion stop command on going on group regular,
  939. * without ADC disable command on going.
  940. * @param Instance ADC instance
  941. * @retval None
  942. */
  943. #define __LL_ADC_REG_StartConversion(__INSTANCE__) MODIFY_REG((__INSTANCE__)->CR0, ADC_CR0_BITS_PROPERTY_RS, ADC_CR0_ADSTART)
  944. /**
  945. * @brief Stop ADC group regular conversion.
  946. * @note Setting of this feature is conditioned to ADC state:
  947. * ADC must be enabled with conversion on going on group regular,
  948. * without ADC disable command on going.
  949. * @param Instance ADC instance
  950. * @retval None
  951. */
  952. #define __LL_ADC_REG_StopConversion(__INSTANCE__) MODIFY_REG((__INSTANCE__)->CR0, ADC_CR0_BITS_PROPERTY_RS, ADC_CR0_ADSTP)
  953. /**
  954. * @brief Get ADC group regular conversion state.
  955. * @param Instance ADC instance
  956. * @retval 0: no conversion is on going on ADC group regular.
  957. */
  958. #define __LL_ADC_REG_IsConversionOngoing(__INSTANCE__) \
  959. ((READ_BIT((__INSTANCE__)->CR0, ADC_CR0_ADSTART) == (ADC_CR0_ADSTART)) ? 1UL : 0UL)
  960. /**
  961. * @brief Get ADC group regular command of conversion stop state
  962. * @param Instance ADC instance
  963. * @retval 0: no command of conversion stop is on going on ADC group regular.
  964. */
  965. #define __LL_ADC_REG_IsStopConversionOngoing(__INSTANCE__) \
  966. ((READ_BIT((__INSTANCE__)->CR0, ADC_CR0_ADSTP) == (ADC_CR0_ADSTP)) ? 1UL : 0UL)
  967. /**
  968. * @brief Get ADC group regular conversion data, range fit for
  969. * all ADC configurations.
  970. * @param Instance ADC instance
  971. * @retval Value between Min_Data=0x0000 and Max_Data=0xFFFF
  972. */
  973. #define __LL_ADC_REG_ReadConversionData(__INSTANCE__) (READ_BIT((__INSTANCE__)->DR, ADC_DR_RDATA))
  974. /**
  975. * @brief Get ADC group regular every channel conversion data, range fit for
  976. * all ADC configurations.
  977. * @param Instance ADC instance
  978. * @param Channel This parameter can be one of the following values:
  979. * @arg @ref ADC_CHANNEL_1
  980. * @arg @ref ADC_CHANNEL_2
  981. * @arg @ref ADC_CHANNEL_3
  982. * @arg @ref ADC_CHANNEL_4
  983. * @arg @ref ADC_CHANNEL_5
  984. * @arg @ref ADC_CHANNEL_6
  985. * @arg @ref ADC_CHANNEL_7
  986. * @arg @ref ADC_CHANNEL_8
  987. * @arg @ref ADC_CHANNEL_9
  988. * @arg @ref ADC_CHANNEL_10
  989. * @arg @ref ADC_CHANNEL_TEMPSENSOR
  990. * @retval Value between Min_Data=0x0000 and Max_Data=0xFFFF
  991. */
  992. #define __LL_ADC_REG_ReadChannelConversionData(__INSTANCE__, __CHANNEL__) \
  993. (READ_BIT((__INSTANCE__)->CDR[__CHANNEL__], ADC_CDR_RDATA))
  994. /**
  995. * @}
  996. */
  997. /** @addtogroup ADC_LL_Configuration_ADC_Group_Regular Configuration of ADC hierarchical scope: group regular
  998. * @{
  999. */
  1000. /**
  1001. * @brief Set for the ADC selected offset number 1, 2, 3 or 4:
  1002. * Channel to which the offset programmed will be applied
  1003. * @param Instance ADC instance
  1004. * @param Channel This parameter can be one of the following values:
  1005. * @arg @ref ADC_CHANNEL_0
  1006. * @arg @ref ADC_CHANNEL_1
  1007. * @arg @ref ADC_CHANNEL_2
  1008. * @arg @ref ADC_CHANNEL_3
  1009. * @arg @ref ADC_CHANNEL_4
  1010. * @arg @ref ADC_CHANNEL_5
  1011. * @arg @ref ADC_CHANNEL_6
  1012. * @arg @ref ADC_CHANNEL_7
  1013. * @arg @ref ADC_CHANNEL_8
  1014. * @arg @ref ADC_CHANNEL_9
  1015. * @arg @ref ADC_CHANNEL_10
  1016. * @arg @ref ADC_CHANNEL_TEMPSENSOR
  1017. * @param GroupSel value can be one of the following values:
  1018. * @arg @ref ADC_OFFSET_1
  1019. * @arg @ref ADC_OFFSET_2
  1020. * @arg @ref ADC_OFFSET_3
  1021. * @arg @ref ADC_OFFSET_4
  1022. */
  1023. #define __LL_ADC_SetCalGroup(__INSTANCE__, __CHANNEL__, __GROUPSEL__) \
  1024. (__CHANNEL__ > 7) ? \
  1025. MODIFY_REG((__INSTANCE__)->CALR1, ADC_CALR1_CAL8 << ((__CHANNEL__ - 8) << ADC_SMPRX_REGOFFSET), \
  1026. ((__GROUPSEL__) << ((__CHANNEL__ - 8) << ADC_SMPRX_REGOFFSET))) : \
  1027. MODIFY_REG((__INSTANCE__)->CALR0, ADC_CALR0_CAL0 << ((__CHANNEL__) << ADC_SMPRX_REGOFFSET), \
  1028. ((__GROUPSEL__) << ((__CHANNEL__) << ADC_SMPRX_REGOFFSET)))
  1029. /**
  1030. * @brief Set ADC selected offset number 1, 2, 3 or 4.
  1031. * @note This function set the 2 items of offset configuration:
  1032. * - ADC channel to which the offset programmed will be applied
  1033. * (Single mode)
  1034. * - Offset level (offset to be subtracted from the raw
  1035. * converted data).
  1036. * @note Caution: Offset format is dependent to ADC resolution:
  1037. * offset has to be left-aligned on bit 11, the LSB (right bits)
  1038. * are set to 0.
  1039. * @note This function enables the offset, by default. It can be forced
  1040. * to disable state using function LL_ADC_SetOffsetState().
  1041. * @param Instance ADC instance
  1042. * @param Offsety This parameter can be one of the following values:
  1043. * @arg @ref ADC_OFFSET_1
  1044. * @arg @ref ADC_OFFSET_2
  1045. * @arg @ref ADC_OFFSET_3
  1046. * @arg @ref ADC_OFFSET_4
  1047. * @param OffsetValue Value between Min_Data=0x0000 and Max_Data=0xFFFF
  1048. * @retval None
  1049. */
  1050. #define __LL_ADC_SetOffset(__INSTANCE__, __OFFSETY__, __VALUE__) \
  1051. MODIFY_REG((__INSTANCE__)->OFR[__OFFSETY__], ADC_OFR0_OFFSET, (__VALUE__))
  1052. /**
  1053. * @brief Get for the ADC selected offset number 1, 2, 3 or 4:
  1054. * Offset level (offset to be subtracted from the raw
  1055. * converted data). Single mode.
  1056. * @param Instance ADC instance
  1057. * @param Offsety This parameter can be one of the following values:
  1058. * @arg @ref ADC_OFFSET_1
  1059. * @arg @ref ADC_OFFSET_2
  1060. * @arg @ref ADC_OFFSET_3
  1061. * @arg @ref ADC_OFFSET_4
  1062. * @retval Value between Min_Data=0x0000 and Max_Data=0xFFFF
  1063. */
  1064. #define __LL_ADC_GetOffset(__INSTANCE__, __OFFSETY__) READ_BIT((__INSTANCE__)->OFR[__OFFSETY__], ADC_OFR0_OFFSET)
  1065. /**
  1066. * @brief Set ADC selected gain compensation number 1, 2, 3 or 4.Single mode.
  1067. * @note This function set the gain compensation coefficient
  1068. * that is applied to raw converted data using the formula:
  1069. * DATA = DATA(raw) * (gain compensation coef) >> 12
  1070. * @param Instance ADC instance
  1071. * @param Gainy This parameter can be one of the following values:
  1072. * @arg @ref ADC_GAIN_1
  1073. * @arg @ref ADC_GAIN_2
  1074. * @arg @ref ADC_GAIN_3
  1075. * @arg @ref ADC_GAIN_4
  1076. * @param GainCompensation This parameter can be:
  1077. * 0 Gain compensation will be disabled and value set to 0
  1078. * 1 -> 8192 Gain compensation will be enabled with specified value(default)
  1079. * @retval None
  1080. */
  1081. #define __LL_ADC_SetGainCompensation(__INSTANCE__,__GAINY__, __VALUE__) \
  1082. MODIFY_REG((__INSTANCE__)->GCR[(__GAINY__)], ADC_GCR0_GAIN, (__VALUE__))
  1083. /**
  1084. * @brief Get the ADC gain compensation value
  1085. * @param Instance ADC instance
  1086. * @param Gainy This parameter can be one of the following values:
  1087. * @arg @ref ADC_GAIN_1
  1088. * @arg @ref ADC_GAIN_2
  1089. * @arg @ref ADC_GAIN_3
  1090. * @arg @ref ADC_GAIN_4
  1091. * @retval Returned value can be:
  1092. * 0 Gain compensation is disabled
  1093. * 1 -> 8192 Gain compensation is enabled with returned value
  1094. */
  1095. #define __LL_ADC_GetGainCompensation(__INSTANCE__,__GAINY__) READ_BIT((__INSTANCE__)->GCR[(__GAINY__)], ADC_GCR0_GAIN)
  1096. /**
  1097. * @brief Set ADC selected offset number 1, 2, 3 or 4.
  1098. * @note This function set the 2 items of offset configuration:
  1099. * - ADC channel to which the offset programmed will be applied
  1100. * (Single mode)
  1101. * - Offset level (offset to be subtracted from the raw
  1102. * converted data).
  1103. * @note Caution: Offset format is dependent to ADC resolution:
  1104. * offset has to be left-aligned on bit 11, the LSB (right bits)
  1105. * are set to 0.
  1106. * @note This function enables the offset, by default. It can be forced
  1107. * to disable state using function LL_ADC_SetOffsetState().
  1108. * @param Instance ADC instance
  1109. * @param Doffsety This parameter can be one of the following values:
  1110. * @arg @ref ADC_OFFSET_1
  1111. * @arg @ref ADC_OFFSET_2
  1112. * @arg @ref ADC_OFFSET_3
  1113. * @arg @ref ADC_OFFSET_4
  1114. * @param OffsetValue Value between Min_Data=0x0000 and Max_Data=0xFFFF
  1115. * @retval None
  1116. */
  1117. #define __LL_ADC_SetDiffOffset(__INSTANCE__, __DOFFSETY__, __VALUE__) \
  1118. MODIFY_REG((__INSTANCE__)->DOFR[(__DOFFSETY__)], ADC_DOFR0_OFFSET, (__VALUE__))
  1119. /**
  1120. * @brief Get for the ADC selected offset number 1, 2, 3 or 4:
  1121. * Offset level (offset to be subtracted from the raw
  1122. * converted data). Single mode.
  1123. * @param Instance ADC instance
  1124. * @param Doffsety This parameter can be one of the following values:
  1125. * @arg @ref ADC_OFFSET_1
  1126. * @arg @ref ADC_OFFSET_2
  1127. * @arg @ref ADC_OFFSET_3
  1128. * @arg @ref ADC_OFFSET_4
  1129. * @retval Value between Min_Data=0x0000 and Max_Data=0xFFFF
  1130. */
  1131. #define __LL_ADC_GetDiffOffset(__INSTANCE__, __DOFFSETY__) READ_BIT((__INSTANCE__)->DOFR[(__DOFFSETY__)], ADC_DOFR0_OFFSET)
  1132. /**
  1133. * @brief Set ADC selected gain compensation number 1, 2, 3 or 4.Single mode.
  1134. * @note This function set the gain compensation coefficient
  1135. * that is applied to raw converted data using the formula:
  1136. * DATA = DATA(raw) * (gain compensation coef) >> 12
  1137. * @param Instance ADC instance
  1138. * @param Dgainy This parameter can be one of the following values:
  1139. * @arg @ref ADC_GAIN_1
  1140. * @arg @ref ADC_GAIN_2
  1141. * @arg @ref ADC_GAIN_3
  1142. * @arg @ref ADC_GAIN_4
  1143. * @param GainCompensation This parameter can be:
  1144. * 0 Gain compensation will be disabled and value set to 0
  1145. * 1 -> 8192 Gain compensation will be enabled with specified value(default)
  1146. * @retval None
  1147. */
  1148. #define __LL_ADC_SetDiffGainCompensation(__INSTANCE__,__DGAINY__, __VALUE__) \
  1149. MODIFY_REG((__INSTANCE__)->DGCR[(__DGAINY__)], ADC_DGCR0_GAIN, (__VALUE__))
  1150. /**
  1151. * @brief Get the ADC gain compensation value ,Differential.
  1152. * @param Instance ADC instance
  1153. * @param Dgainy This parameter can be one of the following values:
  1154. * @arg @ref ADC_GAIN_1
  1155. * @arg @ref ADC_GAIN_2
  1156. * @arg @ref ADC_GAIN_3
  1157. * @arg @ref ADC_GAIN_4
  1158. * @retval Returned value can be:
  1159. * 0 Gain compensation is disabled
  1160. * 1 -> 8192 Gain compensation is enabled with returned value
  1161. */
  1162. #define __LL_ADC_GetDiffGainCompensation(__INSTANCE__,__DGAINY__) READ_BIT((__INSTANCE__)->DGCR[(__DGAINY__)], ADC_DGCR0_GAIN)
  1163. /**
  1164. * @brief Set ADC group regular conversion trigger source:
  1165. * internal (SW start) or from external peripheral (timer event,
  1166. * external interrupt line).
  1167. * @note setting trigger source to external trigger
  1168. * also set trigger polarity to rising edge.
  1169. * ADC must be without conversion on going on group regular.
  1170. * @param Instance ADC instance
  1171. * @param TriggerSource This parameter can be one of the following values:
  1172. * @arg @ref ADC_REG_TRIG_SOFTWARE)
  1173. * @arg @ref ADC_REG_TRIG_EXT_TIM0_CC
  1174. * @arg @ref ADC_REG_TRIG_EXT_TIM1_CC
  1175. * @arg @ref ADC_REG_TRIG_EXT_TIM2_CC
  1176. * @arg @ref ADC_REG_TRIG_EXT_TIM3_CC
  1177. * @arg @ref ADC_REG_TRIG_EXT_TIM4_CC
  1178. * @arg @ref ADC_REG_TRIG_EXT_TIM5_CC
  1179. * @arg @ref ADC_REG_TRIG_EXT_TIM6_CC
  1180. * @arg @ref ADC_REG_TRIG_EXT_TIM7_CC
  1181. * @arg @ref ADC_REG_TRIG_EXT_TIM0_TRGO
  1182. * @arg @ref ADC_REG_TRIG_EXT_TIM1_TRGO
  1183. * @arg @ref ADC_REG_TRIG_EXT_TIM2_TRGO
  1184. * @arg @ref ADC_REG_TRIG_EXT_TIM3_TRGO
  1185. * @arg @ref ADC_REG_TRIG_EXT_TIM4_TRGO
  1186. * @arg @ref ADC_REG_TRIG_EXT_TIM5_TRGO
  1187. * @arg @ref ADC_REG_TRIG_EXT_TIM6_TRGO
  1188. * @arg @ref ADC_REG_TRIG_EXT_TIM7_TRGO
  1189. * @arg @ref ADC_REG_TRIG_EXT_HRPWM_ADC_TRG0
  1190. * @arg @ref ADC_REG_TRIG_EXT_HRPWM_ADC_TRG1
  1191. * @arg @ref ADC_REG_TRIG_EXT_HRPWM_ADC_TRG2
  1192. * @arg @ref ADC_REG_TRIG_EXT_HRPWM_ADC_TRG3
  1193. * @arg @ref ADC_REG_TRIG_EXT_HRPWM_ADC_TRG4
  1194. * @arg @ref ADC_REG_TRIG_EXT_HRPWM_ADC_TRG5
  1195. * @arg @ref ADC_REG_TRIG_EXT_HRPWM_ADC_TRG6
  1196. * @arg @ref ADC_REG_TRIG_EXT_HRPWM_ADC_TRG7
  1197. * @arg @ref ADC_REG_TRIG_EXT_PIN
  1198. * @retval None
  1199. */
  1200. #define __LL_ADC_REG_SetTriggerSource(__INSTANCE__, __TRIGSRC__) \
  1201. MODIFY_REG((__INSTANCE__)->LR, ADC_LR_EXTEN | ADC_LR_EXTSEL, (__TRIGSRC__))
  1202. /**
  1203. * @brief Get ADC group regular conversion trigger source:
  1204. * internal (SW start) or from external peripheral (timer event,
  1205. * external interrupt line).
  1206. * @note To determine whether group regular trigger source is
  1207. * internal (SW start) or external, without detail
  1208. * of which peripheral is selected as external trigger,
  1209. * use function @ref LL_ADC_REG_IsTriggerSourceSWStart.
  1210. * @param Instance ADC instance
  1211. * @retval Returned value can be one of the following values:
  1212. * @arg @ref ADC_REG_TRIG_SOFTWARE)
  1213. * @arg @ref ADC_REG_TRIG_EXT_TIM0_CC
  1214. * @arg @ref ADC_REG_TRIG_EXT_TIM1_CC
  1215. * @arg @ref ADC_REG_TRIG_EXT_TIM2_CC
  1216. * @arg @ref ADC_REG_TRIG_EXT_TIM3_CC
  1217. * @arg @ref ADC_REG_TRIG_EXT_TIM4_CC
  1218. * @arg @ref ADC_REG_TRIG_EXT_TIM5_CC
  1219. * @arg @ref ADC_REG_TRIG_EXT_TIM6_CC
  1220. * @arg @ref ADC_REG_TRIG_EXT_TIM7_CC
  1221. * @arg @ref ADC_REG_TRIG_EXT_TIM0_TRGO
  1222. * @arg @ref ADC_REG_TRIG_EXT_TIM1_TRGO
  1223. * @arg @ref ADC_REG_TRIG_EXT_TIM2_TRGO
  1224. * @arg @ref ADC_REG_TRIG_EXT_TIM3_TRGO
  1225. * @arg @ref ADC_REG_TRIG_EXT_TIM4_TRGO
  1226. * @arg @ref ADC_REG_TRIG_EXT_TIM5_TRGO
  1227. * @arg @ref ADC_REG_TRIG_EXT_TIM6_TRGO
  1228. * @arg @ref ADC_REG_TRIG_EXT_TIM7_TRGO
  1229. * @arg @ref ADC_REG_TRIG_EXT_HRPWM_ADC_TRG0
  1230. * @arg @ref ADC_REG_TRIG_EXT_HRPWM_ADC_TRG1
  1231. * @arg @ref ADC_REG_TRIG_EXT_HRPWM_ADC_TRG2
  1232. * @arg @ref ADC_REG_TRIG_EXT_HRPWM_ADC_TRG3
  1233. * @arg @ref ADC_REG_TRIG_EXT_HRPWM_ADC_TRG4
  1234. * @arg @ref ADC_REG_TRIG_EXT_HRPWM_ADC_TRG5
  1235. * @arg @ref ADC_REG_TRIG_EXT_HRPWM_ADC_TRG6
  1236. * @arg @ref ADC_REG_TRIG_EXT_HRPWM_ADC_TRG7
  1237. * @arg @ref ADC_REG_TRIG_EXT_PIN)
  1238. */
  1239. #define __LL_ADC_REG_GetTriggerSource(__INSTANCE__) (READ_BIT((__INSTANCE__)->LR, ADC_LR_EXTSEL)
  1240. /**
  1241. * @brief Get ADC group regular conversion trigger source internal (SW start)
  1242. * or external.
  1243. * @note In case of group regular trigger source set to external trigger,
  1244. * to determine which peripheral is selected as external trigger,
  1245. * use function @ref LL_ADC_REG_GetTriggerSource().
  1246. * @param Instance ADC instance
  1247. * @retval Value "0" if trigger source external trigger
  1248. * Value "1" if trigger source SW start.
  1249. */
  1250. #define __LL_ADC_REG_IsTriggerSourceSWStart(__INSTANCE__) \
  1251. ((READ_BIT((__INSTANCE__)->LR, ADC_LR_EXTEN) == (ADC_REG_TRIG_SOFTWARE)) ? 1UL : 0UL)
  1252. /**
  1253. * @brief Set ADC group regular conversion trigger polarity.
  1254. * @note Applicable only for trigger source set to external trigger.
  1255. * ADC must be disabled or enabled without conversion on going
  1256. * on group regular.
  1257. * @param Instance ADC instance
  1258. * @param ExternalTriggerEdge This parameter can be one of the following values:
  1259. * @arg @ref ADC_REG_TRIG_EXT_RISING
  1260. * @arg @ref ADC_REG_TRIG_EXT_FALLING
  1261. * @arg @ref ADC_REG_TRIG_EXT_RISINGFALLING
  1262. * @retval None
  1263. */
  1264. #define __LL_ADC_REG_SetTriggerEdge(__INSTANCE__, __EXIT_EDGE__) MODIFY_REG((__INSTANCE__)->LR, ADC_LR_EXTEN, (__EXIT_EDGE__))
  1265. /**
  1266. * @brief Get ADC group regular conversion trigger polarity.
  1267. * @note Applicable only for trigger source set to external trigger.
  1268. * @param Instance ADC instance
  1269. * @retval Returned value can be one of the following values:
  1270. * @arg @ref ADC_REG_TRIG_EXT_RISING
  1271. * @arg @ref ADC_REG_TRIG_EXT_FALLING
  1272. * @arg @ref ADC_REG_TRIG_EXT_RISINGFALLING
  1273. */
  1274. #define __LL_ADC_REG_GetTriggerEdge(__INSTANCE__) READ_BIT((__INSTANCE__)->LR, ADC_LR_EXTEN)
  1275. /**
  1276. * @brief Set ADC group regular sequencer length.
  1277. * @note Description of ADC group regular sequencer features:
  1278. * - For devices with sequencer fully configurable
  1279. * sequencer length and each rank affectation to a channel
  1280. * are configurable.
  1281. * This function performs configuration of:
  1282. * - Sequence length: Number of ranks in the scan sequence.
  1283. * @note Sequencer length value 0 is equivalent to sequencer of 1 rank:
  1284. * ADC conversion on only 1 channel.
  1285. * @param Instance ADC instance
  1286. * @param SequencerNbRanks This parameter can be one of the following values:
  1287. * @arg @ref ADC_REG_SEQ_ENABLE_1
  1288. * @arg @ref ADC_REG_SEQ_ENABLE_2
  1289. * @arg @ref ADC_REG_SEQ_ENABLE_3
  1290. * @arg @ref ADC_REG_SEQ_ENABLE_4
  1291. * @arg @ref ADC_REG_SEQ_ENABLE_5
  1292. * @arg @ref ADC_REG_SEQ_ENABLE_6
  1293. * @arg @ref ADC_REG_SEQ_ENABLE_7
  1294. * @arg @ref ADC_REG_SEQ_ENABLE_8
  1295. * @arg @ref ADC_REG_SEQ_ENABLE_9
  1296. * @arg @ref ADC_REG_SEQ_ENABLE_10
  1297. * @arg @ref ADC_REG_SEQ_ENABLE_11
  1298. * @arg @ref ADC_REG_SEQ_ENABLE_12
  1299. * @arg @ref ADC_REG_SEQ_ENABLE_13
  1300. * @arg @ref ADC_REG_SEQ_ENABLE_14
  1301. * @arg @ref ADC_REG_SEQ_ENABLE_15
  1302. * @arg @ref ADC_REG_SEQ_ENABLE_16
  1303. * @retval None
  1304. */
  1305. #define __LL_ADC_REG_SetSequencerLength(__INSTANCE__, __SEQUENCERANKS__) \
  1306. MODIFY_REG((__INSTANCE__)->LR, ADC_LR_LEN, (__SEQUENCERANKS__))
  1307. /**
  1308. * @brief Get ADC group regular sequencer length.
  1309. * @note Description of ADC group regular sequencer features:
  1310. * - For devices with sequencer fully configurable
  1311. * sequencer length and each rank affectation to a channel
  1312. * are configurable.
  1313. * This function retrieves:
  1314. * - Sequence length: Number of ranks in the scan sequence.
  1315. * @note Sequencer length value 0 is equivalent to sequencer of 1 rank:
  1316. * ADC conversion on only 1 channel.
  1317. * @param Instance ADC instance
  1318. * @retval Returned value can be one of the following values:
  1319. * @arg @ref ADC_REG_SEQ_ENABLE_1
  1320. * @arg @ref ADC_REG_SEQ_ENABLE_2
  1321. * @arg @ref ADC_REG_SEQ_ENABLE_3
  1322. * @arg @ref ADC_REG_SEQ_ENABLE_4
  1323. * @arg @ref ADC_REG_SEQ_ENABLE_5
  1324. * @arg @ref ADC_REG_SEQ_ENABLE_6
  1325. * @arg @ref ADC_REG_SEQ_ENABLE_7
  1326. * @arg @ref ADC_REG_SEQ_ENABLE_8
  1327. * @arg @ref ADC_REG_SEQ_ENABLE_9
  1328. * @arg @ref ADC_REG_SEQ_ENABLE_10
  1329. * @arg @ref ADC_REG_SEQ_ENABLE_11
  1330. * @arg @ref ADC_REG_SEQ_ENABLE_12
  1331. * @arg @ref ADC_REG_SEQ_ENABLE_13
  1332. * @arg @ref ADC_REG_SEQ_ENABLE_14
  1333. * @arg @ref ADC_REG_SEQ_ENABLE_15
  1334. * @arg @ref ADC_REG_SEQ_ENABLE_16
  1335. */
  1336. #define __LL_ADC_REG_GetSequencerLength(__INSTANCE__) READ_BIT((__INSTANCE__)->LR, ADC_LR_LEN)
  1337. /**
  1338. * @brief Set ADC group regular sequencer discontinuous mode:
  1339. * sequence subdivided and conversions interrupted every selected
  1340. * number of ranks.
  1341. * @note It is not possible to enable both ADC group regular
  1342. * continuous mode and sequencer discontinuous mode.
  1343. * @note It is not possible to enable both ADC auto-injected mode
  1344. * and ADC group regular sequencer discontinuous mode.
  1345. * ADC must be disabled or enabled without conversion on going
  1346. * on group regular.
  1347. * @param Instance ADC instance
  1348. * @param SeqDiscont This parameter can be one of the following values:
  1349. * @arg @ref ADC_REG_SEQ_DISCON_DISABLE
  1350. * @arg @ref ADC_REG_SEQ_DISNUM_1
  1351. * @arg @ref ADC_REG_SEQ_DISNUM_2
  1352. * @arg @ref ADC_REG_SEQ_DISNUM_3
  1353. * @arg @ref ADC_REG_SEQ_DISNUM_4
  1354. * @arg @ref ADC_REG_SEQ_DISNUM_5
  1355. * @arg @ref ADC_REG_SEQ_DISNUM_6
  1356. * @arg @ref ADC_REG_SEQ_DISNUM_7
  1357. * @arg @ref ADC_REG_SEQ_DISNUM_8
  1358. * @retval None
  1359. */
  1360. #define __LL_ADC_REG_SetSequencerDiscont(__INSTANCE__, __SEQDISCONT__) \
  1361. MODIFY_REG((__INSTANCE__)->CR1, ADC_CR1_DISCEN | ADC_CR1_DISCNUM, (__SEQDISCONT__))
  1362. /**
  1363. * @brief Get ADC group regular sequencer discontinuous mode:
  1364. * sequence subdivided and scan conversions interrupted every selected
  1365. * number of ranks.
  1366. * @param Instance ADC instance
  1367. * @retval Returned value can be one of the following values:
  1368. * @arg @ref ADC_REG_SEQ_DISCONT_DISABLE
  1369. * @arg @ref ADC_REG_SEQ_DISCONT_1
  1370. * @arg @ref ADC_REG_SEQ_DISCONT_2
  1371. * @arg @ref ADC_REG_SEQ_DISCONT_3
  1372. * @arg @ref ADC_REG_SEQ_DISCONT_4
  1373. * @arg @ref ADC_REG_SEQ_DISCONT_5
  1374. * @arg @ref ADC_REG_SEQ_DISCONT_6
  1375. * @arg @ref ADC_REG_SEQ_DISCONT_7
  1376. * @arg @ref ADC_REG_SEQ_DISCONT_8
  1377. */
  1378. #define __LL_ADC_REG_GetSequencerDiscont(__INSTANCE__) READ_BIT((__INSTANCE__)->CR1, ADC_CR1_DISCEN | ADC_CR1_DISCNUM)
  1379. /**
  1380. * @brief Set ADC group regular sequence: channel on the selected
  1381. * scan sequence rank.
  1382. * @note This function performs configuration of:
  1383. * - Channels ordering into each rank of scan sequence:
  1384. * whatever channel can be placed into whatever rank.
  1385. * @note ADC group regular sequencer is fully configurable: sequencer length and each rank
  1386. * affectation to a channel are configurable.
  1387. * Refer to description of function @ref LL_ADC_REG_SetSequencerLength().
  1388. * @param Instance ADC instance
  1389. * @param Rank This parameter can be one of the following values:
  1390. * @arg @ref ADC_REG_RANK_1
  1391. * @arg @ref ADC_REG_RANK_2
  1392. * @arg @ref ADC_REG_RANK_3
  1393. * @arg @ref ADC_REG_RANK_4
  1394. * @arg @ref ADC_REG_RANK_5
  1395. * @arg @ref ADC_REG_RANK_6
  1396. * @arg @ref ADC_REG_RANK_7
  1397. * @arg @ref ADC_REG_RANK_8
  1398. * @arg @ref ADC_REG_RANK_9
  1399. * @arg @ref ADC_REG_RANK_10
  1400. * @arg @ref ADC_REG_RANK_11
  1401. * @arg @ref ADC_REG_RANK_12
  1402. * @arg @ref ADC_REG_RANK_13
  1403. * @arg @ref ADC_REG_RANK_14
  1404. * @arg @ref ADC_REG_RANK_15
  1405. * @arg @ref ADC_REG_RANK_16
  1406. * @param Channel This parameter can be one of the following values:
  1407. * @arg @ref ADC_CHANNEL_0
  1408. * @arg @ref ADC_CHANNEL_1
  1409. * @arg @ref ADC_CHANNEL_2
  1410. * @arg @ref ADC_CHANNEL_3
  1411. * @arg @ref ADC_CHANNEL_4
  1412. * @arg @ref ADC_CHANNEL_5
  1413. * @arg @ref ADC_CHANNEL_6
  1414. * @arg @ref ADC_CHANNEL_7
  1415. * @arg @ref ADC_CHANNEL_8
  1416. * @arg @ref ADC_CHANNEL_9
  1417. * @arg @ref ADC_CHANNEL_10
  1418. * @arg @ref ADC_CHANNEL_TEMPSENSOR
  1419. * @retval None
  1420. */
  1421. #define __LL_ADC_REG_SetSequencerRanks(__INSTANCE__, __RANK__, __CHANNEL__) \
  1422. (__RANK__) > 7 ? \
  1423. MODIFY_REG((__INSTANCE__)->SQR1, ADC_SQR1_SQ9 << ((__RANK__ - 8) << ADC_SMPRX_REGOFFSET), \
  1424. ((__CHANNEL__) << ((__RANK__ - 8) << ADC_SMPRX_REGOFFSET))) : \
  1425. MODIFY_REG((__INSTANCE__)->SQR0, ADC_SQR0_SQ1 << ((__RANK__) << ADC_SMPRX_REGOFFSET), \
  1426. ((__CHANNEL__) << ((__RANK__) << ADC_SMPRX_REGOFFSET)))
  1427. /**
  1428. * @brief Get ADC group regular sequence: channel on the selected
  1429. * scan sequence rank.
  1430. * @note ADC group regular sequencer is fully configurable: sequencer length and each rank
  1431. * affectation to a channel are configurable.
  1432. * Refer to description of function @ref LL_ADC_REG_SetSequencerLength().
  1433. * @param Instance ADC instance
  1434. * @param Rank This parameter can be one of the following values:
  1435. * @arg @ref ADC_REG_RANK_1
  1436. * @arg @ref ADC_REG_RANK_2
  1437. * @arg @ref ADC_REG_RANK_3
  1438. * @arg @ref ADC_REG_RANK_4
  1439. * @arg @ref ADC_REG_RANK_5
  1440. * @arg @ref ADC_REG_RANK_6
  1441. * @arg @ref ADC_REG_RANK_7
  1442. * @arg @ref ADC_REG_RANK_8
  1443. * @arg @ref ADC_REG_RANK_9
  1444. * @arg @ref ADC_REG_RANK_10
  1445. * @arg @ref ADC_REG_RANK_11
  1446. * @arg @ref ADC_REG_RANK_12
  1447. * @arg @ref ADC_REG_RANK_13
  1448. * @arg @ref ADC_REG_RANK_14
  1449. * @arg @ref ADC_REG_RANK_15
  1450. * @arg @ref ADC_REG_RANK_16
  1451. * @retval Returned value can be one of the following values:
  1452. * @arg @ref ADC_CHANNEL_0
  1453. * @arg @ref ADC_CHANNEL_1
  1454. * @arg @ref ADC_CHANNEL_2
  1455. * @arg @ref ADC_CHANNEL_3
  1456. * @arg @ref ADC_CHANNEL_4
  1457. * @arg @ref ADC_CHANNEL_5
  1458. * @arg @ref ADC_CHANNEL_6
  1459. * @arg @ref ADC_CHANNEL_7
  1460. * @arg @ref ADC_CHANNEL_8
  1461. * @arg @ref ADC_CHANNEL_9
  1462. * @arg @ref ADC_CHANNEL_10
  1463. * @arg @ref ADC_CHANNEL_TEMPSENSOR
  1464. */
  1465. #define __LL_ADC_REG_GetSequencerRanks(__INSTANCE__, __RANK__) \
  1466. (__RANK__) > 7 ? \
  1467. (READ_BIT((__INSTANCE__)->SQR1, ADC_SQR1_SQ9 << ((__RANK__ - 8) << ADC_SMPRX_REGOFFSET))) : \
  1468. (READ_BIT((__INSTANCE__)->SQR0, ADC_SQR0_SQ1 << ((__RANK__) << ADC_SMPRX_REGOFFSET)))
  1469. /**
  1470. * @brief Set ADC continuous conversion mode on ADC group regular.
  1471. * @note Description of ADC continuous conversion mode:
  1472. * - single mode: one conversion per trigger
  1473. * - continuous mode: after the first trigger, following
  1474. * conversions launched successively automatically.
  1475. * @note It is not possible to enable both ADC group regular
  1476. * continuous mode and sequencer discontinuous mode.
  1477. * @param Instance ADC instance
  1478. * @param Continuous This parameter can be one of the following values:
  1479. * @arg @ref ADC_REG_CONV_SINGLE
  1480. * @arg @ref ADC_REG_CONV_CONTINUOUS
  1481. * @retval None
  1482. */
  1483. #define __LL_ADC_REG_SetContinuousMode(__INSTANCE__, __COUNT__) MODIFY_REG((__INSTANCE__)->CR1, ADC_CR1_CONT, (__COUNT__))
  1484. /**
  1485. * @brief Get ADC continuous conversion mode on ADC group regular.
  1486. * @note Description of ADC continuous conversion mode:
  1487. * - single mode: one conversion per trigger
  1488. * - continuous mode: after the first trigger, following
  1489. * conversions launched successively automatically.
  1490. * @param Instance ADC instance
  1491. * @retval Returned value can be one of the following values:
  1492. * @arg @ref ADC_REG_CONV_SINGLE
  1493. * @arg @ref ADC_REG_CONV_CONTINUOUS
  1494. */
  1495. #define __LL_ADC_REG_GetContinuousMode(__INSTANCE__) READ_BIT((__INSTANCE__)->CR1, ADC_CR1_CONT)
  1496. /**
  1497. * @brief Set ADC group regular conversion data transfer: no transfer or
  1498. * transfer by DMA.
  1499. * @note If transfer by DMA selected, This ADC mode is intended to be used with DMA mode circular.
  1500. * @note If ADC DMA is set to single and DMA is set to mode non-circular:
  1501. * when DMA transfers size will be reached, DMA will stop transfers of
  1502. * ADC conversions data ADC will raise an overrun error
  1503. * (overrun flag and interruption if enabled).
  1504. * ADC must be disabled or enabled without conversion on going
  1505. * on either groups regular.
  1506. * @param Instance ADC instance
  1507. * @param Channel This parameter can be one of the following values:
  1508. * @arg @ref ADC_CHANNEL_0
  1509. * @arg @ref ADC_CHANNEL_1
  1510. * @arg @ref ADC_CHANNEL_2
  1511. * @arg @ref ADC_CHANNEL_3
  1512. * @arg @ref ADC_CHANNEL_4
  1513. * @arg @ref ADC_CHANNEL_5
  1514. * @arg @ref ADC_CHANNEL_6
  1515. * @arg @ref ADC_CHANNEL_7
  1516. * @arg @ref ADC_CHANNEL_8
  1517. * @arg @ref ADC_CHANNEL_9
  1518. * @arg @ref ADC_CHANNEL_10
  1519. * @arg @ref ADC_CHANNEL_TEMPSENSOR
  1520. * @param DMATransfer This parameter can be one of the following values:
  1521. * @arg @ref ADC_REG_DMA_TRANSFER_SINGLE
  1522. * @arg @ref ADC_REG_DMA_TRANSFER_CIRCLE
  1523. * @retval None
  1524. */
  1525. #define __LL_ADC_REG_SetDMATransfer(__INSTANCE__, __CHANNLE__, __DMAMODE__) \
  1526. MODIFY_REG((__INSTANCE__)->DMA_CR[__CHANNLE__].TCR, ADC_DMA_TCR_CIRC | ADC_DMA_TCR_START, (__DMAMODE__))
  1527. /**
  1528. * @brief Get ADC group regular conversion data transfer: no transfer or
  1529. * transfer by DMA.
  1530. * @note If transfer by DMA selected:
  1531. * This ADC mode is intended to be used with DMA mode circular.
  1532. * @note If ADC DMA is set to single and DMA is set to mode non-circular:
  1533. * when DMA transfers size will be reached, DMA will stop transfers of
  1534. * ADC conversions data ADC will raise an overrun error
  1535. * (overrun flag and interruption if enabled).
  1536. * @param Instance ADC instance
  1537. * @param Channel This parameter can be one of the following values:
  1538. * @arg @ref ADC_CHANNEL_0
  1539. * @arg @ref ADC_CHANNEL_1
  1540. * @arg @ref ADC_CHANNEL_2
  1541. * @arg @ref ADC_CHANNEL_3
  1542. * @arg @ref ADC_CHANNEL_4
  1543. * @arg @ref ADC_CHANNEL_5
  1544. * @arg @ref ADC_CHANNEL_6
  1545. * @arg @ref ADC_CHANNEL_7
  1546. * @arg @ref ADC_CHANNEL_8
  1547. * @arg @ref ADC_CHANNEL_9
  1548. * @arg @ref ADC_CHANNEL_10
  1549. * @arg @ref ADC_CHANNEL_TEMPSENSOR
  1550. * @retval Returned value can be one of the following values:
  1551. * @arg @ref ADC_REG_DMA_TRANSFER_SINGLE
  1552. * @arg @ref ADC_REG_DMA_TRANSFER_CIRCLE
  1553. */
  1554. #define __LL_ADC_REG_GetDMATransfer(__INSTANCE__, __CHANNLE__) \
  1555. READ_BIT((__INSTANCE__)->DMA_CR[__CHANNLE__].TCR, ADC_DMA_TCR_CIRC | ADC_DMA_TCR_START)
  1556. /**
  1557. * @brief Set the DMA transfer address.
  1558. * @note If transfer by DMA selected:
  1559. * This ADC mode is intended to be used with DMA mode circular.
  1560. * @note If ADC DMA is set to single and DMA is set to mode non-circular:
  1561. * when DMA transfers size will be reached, DMA will stop transfers of
  1562. * ADC conversions data ADC will raise an overrun error
  1563. * (overrun flag and interruption if enabled).
  1564. * @param Instance ADC instance
  1565. * @param Channel This parameter can be one of the following values:
  1566. * @arg @ref ADC_CHANNEL_0
  1567. * @arg @ref ADC_CHANNEL_1
  1568. * @arg @ref ADC_CHANNEL_2
  1569. * @arg @ref ADC_CHANNEL_3
  1570. * @arg @ref ADC_CHANNEL_4
  1571. * @arg @ref ADC_CHANNEL_5
  1572. * @arg @ref ADC_CHANNEL_6
  1573. * @arg @ref ADC_CHANNEL_7
  1574. * @arg @ref ADC_CHANNEL_8
  1575. * @arg @ref ADC_CHANNEL_9
  1576. * @arg @ref ADC_CHANNEL_10
  1577. * @arg @ref ADC_CHANNEL_TEMPSENSOR
  1578. * @param Address dma transfer buffer addresss
  1579. * @retval None
  1580. */
  1581. #define __LL_ADC_REG_SetDMAAddr(__INSTANCE__, __CHANNLE__, __ADDR__) \
  1582. MODIFY_REG((__INSTANCE__)->DMA_CR[__CHANNLE__].TAR, ADC_DMA_TAR_ADDR, (__ADDR__))
  1583. /**
  1584. * @brief Set the DMA transfer length
  1585. * @param __INSTANCE__ Special ADC Peripheral
  1586. * @param __CHANNLE__ ADC Channel
  1587. * @param __LENGTH__ dma transfer length
  1588. * @return None
  1589. */
  1590. #define __LL_ADC_REG_SetDMALength(__INSTANCE__, __CHANNLE__, __LENGTH__) \
  1591. MODIFY_REG((__INSTANCE__)->DMA_CR[__CHANNLE__].TLR, ADC_DMA_TLR_LENG, (__LENGTH__))
  1592. /**
  1593. * @brief Set ADC group regular behavior in case of overrun:
  1594. * data preserved or overwritten.
  1595. * @note Compatibility with devices without feature overrun:
  1596. * other devices without this feature have a behavior
  1597. * equivalent to data overwritten.
  1598. * The default setting of overrun is data preserved.
  1599. * ADC must be disabled or enabled without conversion on going
  1600. * on group regular.
  1601. * @param Instance ADC instance
  1602. * @param Overrun This parameter can be one of the following values:
  1603. * @arg @ref ADC_REG_OVR_DATA_PRESERVED
  1604. * @arg @ref ADC_REG_OVR_DATA_OVERWRITTEN
  1605. * @retval None
  1606. */
  1607. #define __LL_ADC_REG_SetOverrun(__INSTANCE__, __OVRRUN__) MODIFY_REG((__INSTANCE__)->CR1, ADC_CR1_OVRMOD, (__OVRRUN__))
  1608. /**
  1609. * @brief Get ADC group regular behavior in case of overrun:
  1610. * data preserved or overwritten.
  1611. * @param Instance ADC instance
  1612. * @retval Returned value can be one of the following values:
  1613. * @arg @ref ADC_REG_OVR_DATA_PRESERVED
  1614. * @arg @ref ADC_REG_OVR_DATA_OVERWRITTEN
  1615. */
  1616. #define __LL_ADC_REG_GetOverrun(__INSTANCE__) READ_BIT((__INSTANCE__)->CR1, ADC_CR1_OVRMOD)
  1617. /**
  1618. * @}
  1619. */
  1620. /** @addtogroup ADC_LL_Configuration_ADC_Group_Injected Configuration of ADC hierarchical scope: group injected
  1621. * @{
  1622. */
  1623. /**
  1624. * @brief Set ADC group injected conversion trigger source:
  1625. * internal (SW start) or from external peripheral (timer event,
  1626. * external interrupt line).
  1627. * @note setting trigger source to external trigger also set trigger polarity to rising edge
  1628. * ADC must not be disabled. Can be enabled with or without conversion
  1629. * on going on either groups regular or injected.
  1630. * @param Instance ADC instance
  1631. * @param TriggerSource This parameter can be one of the following values:
  1632. * @arg @ref ADC_INJ_TRIG_SOFTWARE
  1633. * @arg @ref ADC_INJ_TRIG_EXT_TIM0_CC
  1634. * @arg @ref ADC_INJ_TRIG_EXT_TIM1_CC
  1635. * @arg @ref ADC_INJ_TRIG_EXT_TIM2_CC
  1636. * @arg @ref ADC_INJ_TRIG_EXT_TIM3_CC
  1637. * @arg @ref ADC_INJ_TRIG_EXT_TIM4_CC
  1638. * @arg @ref ADC_INJ_TRIG_EXT_TIM5_CC
  1639. * @arg @ref ADC_INJ_TRIG_EXT_TIM6_CC
  1640. * @arg @ref ADC_INJ_TRIG_EXT_TIM7_CC
  1641. * @arg @ref ADC_INJ_TRIG_EXT_TIM0_TRGO
  1642. * @arg @ref ADC_INJ_TRIG_EXT_TIM1_TRGO
  1643. * @arg @ref ADC_INJ_TRIG_EXT_TIM2_TRGO
  1644. * @arg @ref ADC_INJ_TRIG_EXT_TIM3_TRGO
  1645. * @arg @ref ADC_INJ_TRIG_EXT_TIM4_TRGO
  1646. * @arg @ref ADC_INJ_TRIG_EXT_TIM5_TRGO
  1647. * @arg @ref ADC_INJ_TRIG_EXT_TIM6_TRGO
  1648. * @arg @ref ADC_INJ_TRIG_EXT_TIM7_TRGO
  1649. * @arg @ref ADC_INJ_TRIG_EXT_HRPWM_ADC_TRG0
  1650. * @arg @ref ADC_INJ_TRIG_EXT_HRPWM_ADC_TRG1
  1651. * @arg @ref ADC_INJ_TRIG_EXT_HRPWM_ADC_TRG2
  1652. * @arg @ref ADC_INJ_TRIG_EXT_HRPWM_ADC_TRG3
  1653. * @arg @ref ADC_INJ_TRIG_EXT_HRPWM_ADC_TRG4
  1654. * @arg @ref ADC_INJ_TRIG_EXT_HRPWM_ADC_TRG5
  1655. * @arg @ref ADC_INJ_TRIG_EXT_HRPWM_ADC_TRG6
  1656. * @arg @ref ADC_INJ_TRIG_EXT_HRPWM_ADC_TRG7
  1657. * @arg @ref ADC_INJ_TRIG_EXT_PIN
  1658. * @retval None
  1659. */
  1660. #define __LL_ADC_INJ_SetTriggerSource(__INSTANCE__, __TRIGSRC__) \
  1661. MODIFY_REG((__INSTANCE__)->JLR, ADC_JLR_JEXTSEL | ADC_JLR_JEXTEN, (__TRIGSRC__))
  1662. /**
  1663. * @brief Get ADC group injected conversion trigger source:
  1664. * internal (SW start) or from external peripheral (timer event,
  1665. * external interrupt line).
  1666. * @note To determine whether group injected trigger source is
  1667. * internal (SW start) or external, without detail
  1668. * of which peripheral is selected as external trigger,
  1669. * @note setting trigger source to external trigger also set trigger polarity to rising edge
  1670. * ADC must not be disabled. Can be enabled with or without conversion
  1671. * on going on either groups regular or injected.
  1672. * @param Instance ADC instance
  1673. * @param TriggerSource This parameter can be one of the following values:
  1674. * @arg @ref ADC_INJ_TRIG_SOFTWARE
  1675. * @arg @ref ADC_INJ_TRIG_EXT_TIM0_CC
  1676. * @arg @ref ADC_INJ_TRIG_EXT_TIM1_CC
  1677. * @arg @ref ADC_INJ_TRIG_EXT_TIM2_CC
  1678. * @arg @ref ADC_INJ_TRIG_EXT_TIM3_CC
  1679. * @arg @ref ADC_INJ_TRIG_EXT_TIM4_CC
  1680. * @arg @ref ADC_INJ_TRIG_EXT_TIM5_CC
  1681. * @arg @ref ADC_INJ_TRIG_EXT_TIM6_CC
  1682. * @arg @ref ADC_INJ_TRIG_EXT_TIM7_CC
  1683. * @arg @ref ADC_INJ_TRIG_EXT_TIM0_TRGO
  1684. * @arg @ref ADC_INJ_TRIG_EXT_TIM1_TRGO
  1685. * @arg @ref ADC_INJ_TRIG_EXT_TIM2_TRGO
  1686. * @arg @ref ADC_INJ_TRIG_EXT_TIM3_TRGO
  1687. * @arg @ref ADC_INJ_TRIG_EXT_TIM4_TRGO
  1688. * @arg @ref ADC_INJ_TRIG_EXT_TIM5_TRGO
  1689. * @arg @ref ADC_INJ_TRIG_EXT_TIM6_TRGO
  1690. * @arg @ref ADC_INJ_TRIG_EXT_TIM7_TRGO
  1691. * @arg @ref ADC_INJ_TRIG_EXT_HRPWM_ADC_TRG0
  1692. * @arg @ref ADC_INJ_TRIG_EXT_HRPWM_ADC_TRG1
  1693. * @arg @ref ADC_INJ_TRIG_EXT_HRPWM_ADC_TRG2
  1694. * @arg @ref ADC_INJ_TRIG_EXT_HRPWM_ADC_TRG3
  1695. * @arg @ref ADC_INJ_TRIG_EXT_HRPWM_ADC_TRG4
  1696. * @arg @ref ADC_INJ_TRIG_EXT_HRPWM_ADC_TRG5
  1697. * @arg @ref ADC_INJ_TRIG_EXT_HRPWM_ADC_TRG6
  1698. * @arg @ref ADC_INJ_TRIG_EXT_HRPWM_ADC_TRG7
  1699. * @arg @ref ADC_INJ_TRIG_EXT_PIN
  1700. * @retval None
  1701. */
  1702. #define __LL_ADC_INJ_GetTriggerSource(__INSTANCE__) READ_BIT((__INSTANCE__)->JLR, ADC_JLR_JEXTSEL)
  1703. /**
  1704. * @brief Get ADC group injected conversion trigger source internal (SW start)
  1705. or external
  1706. * @note In case of group injected trigger source set to external trigger,
  1707. * to determine which peripheral is selected as external trigger,
  1708. * use function @ref LL_ADC_INJ_GetTriggerSource.
  1709. * @param Instance ADC instance
  1710. * @retval Value "0" if trigger source external trigger
  1711. * Value "1" if trigger source SW start.
  1712. */
  1713. #define __LL_ADC_INJ_IsTriggerSourceSWStart(__INSTANCE__) \
  1714. ((READ_BIT((__INSTANCE__)->JLR, ADC_JLR_JEXTEN) == (ADC_INJ_TRIG_SOFTWARE & ADC_JLR_JEXTEN)) ? 1UL : 0UL)
  1715. /**
  1716. * @brief Set ADC group injected conversion trigger polarity.
  1717. * Applicable only for trigger source set to external trigger.
  1718. * ADC must not be disabled. Can be enabled with or without conversion
  1719. * on going on either groups regular or injected.
  1720. * @param Instance ADC instance
  1721. * @param ExternalTriggerEdge This parameter can be one of the following values:
  1722. * @arg @ref ADC_INJ_TRIG_EXT_RISING
  1723. * @arg @ref ADC_INJ_TRIG_EXT_FALLING
  1724. * @arg @ref ADC_INJ_TRIG_EXT_RISINGFALLING
  1725. * @retval None
  1726. */
  1727. #define __LL_ADC_INJ_SetTriggerEdge(__INSTANCE__, __TRIG_EDGE__) \
  1728. MODIFY_REG((__INSTANCE__)->JLR, ADC_JLR_JEXTEN, (__TRIG_EDGE__))
  1729. /**
  1730. * @brief Get ADC group injected conversion trigger polarity.
  1731. * Applicable only for trigger source set to external trigger.
  1732. * @param Instance ADC instance
  1733. * @retval Returned value can be one of the following values:
  1734. * @arg @ref ADC_INJ_TRIG_EXT_RISING
  1735. * @arg @ref ADC_INJ_TRIG_EXT_FALLING
  1736. * @arg @ref ADC_INJ_TRIG_EXT_RISINGFALLING
  1737. */
  1738. #define __LL_ADC_INJ_GetTriggerEdge(__INSTANCE__) READ_BIT((__INSTANCE__)->JLR, ADC_JLR_JEXTEN)
  1739. /**
  1740. * @brief Set ADC group injected sequencer length.
  1741. * @note This function performs configuration of:
  1742. * - Sequence length: Number of ranks in the scan sequence.
  1743. * ADC must not be disabled. Can be enabled with or without conversion
  1744. * on going on either groups regular or injected.
  1745. * @param Instance ADC instance
  1746. * @param SequencerNbRanks This parameter can be one of the following values:
  1747. * @arg @ref ADC_INJ_SEQ_LENGTH_1
  1748. * @arg @ref ADC_INJ_SEQ_LENGTH_2
  1749. * @arg @ref ADC_INJ_SEQ_LENGTH_3
  1750. * @arg @ref ADC_INJ_SEQ_LENGTH_4
  1751. * @retval None
  1752. */
  1753. #define __LL_ADC_INJ_SetSequencerLength(__INSTANCE__, __SEQUENCERANK__) \
  1754. MODIFY_REG((__INSTANCE__)->JLR, ADC_JLR_JLEN, (__SEQUENCERANK__))
  1755. /**
  1756. * @brief Get ADC group injected sequencer length and scan direction.
  1757. * @note This function retrieves:
  1758. * - Sequence length: Number of ranks in the scan sequence.
  1759. * @param Instance ADC instance
  1760. * @retval Returned value can be one of the following values:
  1761. * @arg @ref ADC_INJ_SEQ_LENGTH_1
  1762. * @arg @ref ADC_INJ_SEQ_LENGTH_2
  1763. * @arg @ref ADC_INJ_SEQ_LENGTH_3
  1764. * @arg @ref ADC_INJ_SEQ_LENGTH_4
  1765. */
  1766. #define __LL_ADC_INJ_GetSequencerLength(__INSTANCE__) READ_BIT((__INSTANCE__)->JLR, ADC_JLR_JLEN)
  1767. /**
  1768. * @brief Set ADC group injected sequencer discontinuous mode:
  1769. * sequence subdivided and scan conversions interrupted every selected
  1770. * number of ranks.
  1771. * @note It is not possible to enable both ADC group injected
  1772. * auto-injected mode and sequencer discontinuous mode.
  1773. * @param Instance ADC instance
  1774. * @param SeqDiscont This parameter can be one of the following values:
  1775. * @arg @ref ADC_INJ_SEQ_DISCONT_DISABLE
  1776. * @arg @ref ADC_INJ_SEQ_DISCONT_ENABLE
  1777. * @retval None
  1778. */
  1779. #define __LL_ADC_INJ_SetSequencerDiscont(__INSTANCE__, __SEQDISCONT__) \
  1780. MODIFY_REG((__INSTANCE__)->CR1, ADC_CR1_JDISCEN, (__SEQDISCONT__))
  1781. /**
  1782. * @brief Get ADC group injected sequencer discontinuous mode:
  1783. * sequence subdivided and scan conversions interrupted every selected
  1784. * number of ranks.
  1785. * @param Instance ADC instance
  1786. * @retval Returned value can be one of the following values:
  1787. * @arg @ref ADC_INJ_SEQ_DISCONT_DISABLE
  1788. * @arg @ref ADC_INJ_SEQ_DISCONT_ENABLE
  1789. */
  1790. #define __LL_ADC_INJ_GetSequencerDiscont(__INSTANCE__) READ_BIT((__INSTANCE__)->CR1, ADC_CR1_JDISCEN)
  1791. /**
  1792. * @brief Set ADC group injected sequence: channel on the selected
  1793. * sequence rank.
  1794. * @note Depending on devices and packages, some channels may not be available.
  1795. * @note setting of this feature is conditioned to ADC state:
  1796. * ADC must not be disabled. Can be enabled with or without conversion
  1797. * on going on either groups injected.
  1798. * @param Instance ADC instance
  1799. * @param Rank Position This parameter can be one of the following values:
  1800. * @arg @ref ADC_INJ_RANK_1
  1801. * @arg @ref ADC_INJ_RANK_2
  1802. * @arg @ref ADC_INJ_RANK_3
  1803. * @arg @ref ADC_INJ_RANK_4
  1804. * @param Channel This parameter can be one of the following values:
  1805. * @arg @ref ADC_CHANNEL_0
  1806. * @arg @ref ADC_CHANNEL_1
  1807. * @arg @ref ADC_CHANNEL_2
  1808. * @arg @ref ADC_CHANNEL_3
  1809. * @arg @ref ADC_CHANNEL_4
  1810. * @arg @ref ADC_CHANNEL_5
  1811. * @arg @ref ADC_CHANNEL_6
  1812. * @arg @ref ADC_CHANNEL_7
  1813. * @arg @ref ADC_CHANNEL_8
  1814. * @arg @ref ADC_CHANNEL_9
  1815. * @arg @ref ADC_CHANNEL_10
  1816. * @arg @ref ADC_CHANNEL_TEMPSENSOR
  1817. * @retval None
  1818. */
  1819. #define __LL_ADC_INJ_SetSequencerRanks(__INSTANCE__, __RANK__, __CHANNEL__) \
  1820. MODIFY_REG((__INSTANCE__)->JSQR, (ADC_JSQR_JSQ1 << (__RANK__)), (__CHANNEL__) << (__RANK__))
  1821. /**
  1822. * @brief Get ADC group injected sequence: channel on the selected
  1823. * sequence rank.
  1824. * @note Depending on devices and packages, some channels may not be available.
  1825. * Refer to device datasheet for channels availability.
  1826. * @note setting of this feature is conditioned to ADC state:
  1827. * ADC must not be disabled. Can be enabled with or without conversion
  1828. * on going on either groups regular or injected.
  1829. * @param Instance ADC instance
  1830. * @param Rank This parameter can be one of the following values:
  1831. * @arg @ref ADC_INJ_RANK_1
  1832. * @arg @ref ADC_INJ_RANK_2
  1833. * @arg @ref ADC_INJ_RANK_3
  1834. * @arg @ref ADC_INJ_RANK_4
  1835. * @param Channel This parameter can be one of the following values:
  1836. * @arg @ref ADC_CHANNEL_0
  1837. * @arg @ref ADC_CHANNEL_1
  1838. * @arg @ref ADC_CHANNEL_2
  1839. * @arg @ref ADC_CHANNEL_3
  1840. * @arg @ref ADC_CHANNEL_4
  1841. * @arg @ref ADC_CHANNEL_5
  1842. * @arg @ref ADC_CHANNEL_6
  1843. * @arg @ref ADC_CHANNEL_7
  1844. * @arg @ref ADC_CHANNEL_8
  1845. * @arg @ref ADC_CHANNEL_9
  1846. * @arg @ref ADC_CHANNEL_10
  1847. * @arg @ref ADC_CHANNEL_TEMPSENSOR
  1848. * @retval None
  1849. */
  1850. #define __LL_ADC_INJ_GetSequencerRanks(__INSTANCE__, __RANK__) READ_BIT((__INSTANCE__)->JSQR, (ADC_JSQR_JSQ1 << (__RANK__)))
  1851. /**
  1852. * @brief Set ADC group injected conversion trigger:
  1853. * independent or from ADC group regular.
  1854. * @note This mode can be used to extend number of data registers
  1855. * updated after one ADC conversion trigger and with data
  1856. * permanently kept , up to 5 data registers:
  1857. * 1 data register on ADC group regular, 4 data registers
  1858. * on ADC group injected.
  1859. * @note If ADC group injected injected trigger source is set to an
  1860. * external trigger, this feature must be must be set to
  1861. * independent trigger.
  1862. * ADC group injected automatic trigger is compliant only with
  1863. * group injected trigger source set to SW start, without any
  1864. * further action on ADC group injected conversion start or stop:
  1865. * @note It is not possible to enable both ADC group injected
  1866. * auto-injected mode and sequencer discontinuous mode.
  1867. * ADC must be disabled or enabled without conversion on going
  1868. * on either groups regular or injected.
  1869. * @param Instance ADC instance
  1870. * @param TrigAuto This parameter can be one of the following values:
  1871. * @arg @ref ADC_INJ_TRIG_INDEPENDENT
  1872. * @arg @ref ADC_INJ_TRIG_FROM_GRP_REGULAR
  1873. * @retval None
  1874. */
  1875. #define __LL_ADC_INJ_SetTrigAuto(__INSTANCE__, __TRIGAUTO__) MODIFY_REG((__INSTANCE__)->CR1, ADC_CR1_JAUTO, (__TRIGAUTO__))
  1876. /**
  1877. * @brief Get ADC group injected conversion trigger:
  1878. * independent or from ADC group regular.
  1879. * @param Instance ADC instance
  1880. * @retval Returned value can be one of the following values:
  1881. * @arg @ref ADC_INJ_TRIG_INDEPENDENT
  1882. * @arg @ref ADC_INJ_TRIG_FROM_GRP_REGULAR
  1883. */
  1884. #define __LL_ADC_INJ_GetTrigAuto(__INSTANCE__) READ_BIT((__INSTANCE__)->CR1, ADC_CR1_JAUTO)
  1885. /**
  1886. * @}
  1887. */
  1888. /** @addtogroup ADC_LL_Configuration_Channels Configuration of ADC hierarchical scope: channels
  1889. * @{
  1890. */
  1891. /**
  1892. * @brief Set sampling time of the selected ADC channel Unit: ADC clock cycles.
  1893. * @note On this device, sampling time is on channel scope: independently
  1894. * of channel mapped on ADC group regular or injected.
  1895. * @note sampling time constraints must be respected (sampling time can be
  1896. * adjusted in function of ADC clock frequency and sampling time
  1897. * setting).
  1898. * @note Conversion time is the addition of sampling time and processing time.
  1899. * ADC processing time is: 12.5 ADC clock cycles at ADC resolution 12 bits
  1900. * @param Instance ADC instance
  1901. * @param Channel This parameter can be one of the following values:
  1902. * @arg @ref ADC_CHANNEL_0
  1903. * @arg @ref ADC_CHANNEL_1
  1904. * @arg @ref ADC_CHANNEL_2
  1905. * @arg @ref ADC_CHANNEL_3
  1906. * @arg @ref ADC_CHANNEL_4
  1907. * @arg @ref ADC_CHANNEL_5
  1908. * @arg @ref ADC_CHANNEL_6
  1909. * @arg @ref ADC_CHANNEL_7
  1910. * @arg @ref ADC_CHANNEL_8
  1911. * @arg @ref ADC_CHANNEL_9
  1912. * @arg @ref ADC_CHANNEL_10
  1913. * @arg @ref ADC_CHANNEL_TEMPSENSOR
  1914. * @param SamplingTime This parameter can be one of the following values:
  1915. * @arg @ref ADC_SAMPLINGTIME_6CYCLES
  1916. * @arg @ref ADC_SAMPLINGTIME_18CYCLES
  1917. * @arg @ref ADC_SAMPLINGTIME_42CYCLES
  1918. * @arg @ref ADC_SAMPLINGTIME_90CYCLES
  1919. * @arg @ref ADC_SAMPLINGTIME_186CYCLES
  1920. * @arg @ref ADC_SAMPLINGTIME_378CYCLES
  1921. * @arg @ref ADC_SAMPLINGTIME_762CYCLES
  1922. * @arg @ref ADC_SAMPLINGTIME_1530CYCLES
  1923. * @retval None
  1924. */
  1925. #define __LL_ADC_SetChannelSamplingTime(__INSTANCE__, __CHANNEL__, __SAMPTIME__) \
  1926. (__CHANNEL__ > 7) ? \
  1927. MODIFY_REG((__INSTANCE__)->SMPR1, ADC_SMPR1_SMP8 << ((__CHANNEL__ - 8) << ADC_SMPRX_REGOFFSET), \
  1928. ((__SAMPTIME__) << ((__CHANNEL__ - 8) << ADC_SMPRX_REGOFFSET))) : \
  1929. MODIFY_REG((__INSTANCE__)->SMPR0, ADC_SMPR0_SMP0 << ((__CHANNEL__) << ADC_SMPRX_REGOFFSET), \
  1930. ((__SAMPTIME__) << ((__CHANNEL__) << ADC_SMPRX_REGOFFSET)))
  1931. /**
  1932. * @brief Get sampling time of the selected ADC channel Unit: ADC clock cycles.
  1933. * @note sampling time is on channel scope: independently
  1934. * of channel mapped on ADC group regular or injected.
  1935. * @note Conversion time is the addition of sampling time and processing time.
  1936. * @param Instance ADC instance
  1937. * @param Channel This parameter can be one of the following values:
  1938. * @arg @ref ADC_CHANNEL_0
  1939. * @arg @ref ADC_CHANNEL_1
  1940. * @arg @ref ADC_CHANNEL_2
  1941. * @arg @ref ADC_CHANNEL_3
  1942. * @arg @ref ADC_CHANNEL_4
  1943. * @arg @ref ADC_CHANNEL_5
  1944. * @arg @ref ADC_CHANNEL_6
  1945. * @arg @ref ADC_CHANNEL_7
  1946. * @arg @ref ADC_CHANNEL_8
  1947. * @arg @ref ADC_CHANNEL_9
  1948. * @arg @ref ADC_CHANNEL_10
  1949. * @arg @ref ADC_CHANNEL_TEMPSENSOR
  1950. * @param SamplingTime This parameter can be one of the following values:
  1951. * @arg @ref ADC_SAMPLINGTIME_6CYCLES
  1952. * @arg @ref ADC_SAMPLINGTIME_18CYCLES
  1953. * @arg @ref ADC_SAMPLINGTIME_42CYCLES
  1954. * @arg @ref ADC_SAMPLINGTIME_90CYCLES
  1955. * @arg @ref ADC_SAMPLINGTIME_186CYCLES
  1956. * @arg @ref ADC_SAMPLINGTIME_378CYCLES
  1957. * @arg @ref ADC_SAMPLINGTIME_762CYCLES
  1958. * @arg @ref ADC_SAMPLINGTIME_1530CYCLES
  1959. */
  1960. #define __LL_ADC_GetChannelSamplingTime(__INSTANCE__, __CHANNEL__) (__CHANNEL__ > 7) ? \
  1961. (READ_BIT((__INSTANCE__)->SMPR1, ADC_SMPR1_SMP8 << (((__CHANNEL__ - 8) << ADC_SMPRX_REGOFFSET)))) : \
  1962. (READ_BIT((__INSTANCE__)->SMPR0, ADC_SMPR0_SMP0 << (((__INSTANCE__) << ADC_SMPRX_REGOFFSET))))
  1963. /**
  1964. * @brief Set mode single-ended or differential input of the selected
  1965. * ADC channel.
  1966. * In differential mode: Differential measurement is carried out
  1967. * between the selected channel 'i' (positive input) and
  1968. * channel 'i+1' (negative input). Only channel 'i' has to be
  1969. * configured, channel 'i+1' is configured automatically.
  1970. * @note For example, internal channels (VrefInt, TempSensor, ...) are
  1971. * not available in differential mode.
  1972. * @note When configuring a channel 'i' in differential mode,
  1973. * the channel 'i+1' is not usable separately.refer to device datasheet
  1974. * for more details.
  1975. * @note For ADC channels configured in differential mode, both inputs
  1976. * should be biased at (Vref+)/2 +/-200mV.
  1977. * (Vref+ is the analog voltage reference)
  1978. * @param Instance ADC instance
  1979. * @param Channel This parameter can be one of the following values:
  1980. * @arg @ref ADC_CHANNEL_0
  1981. * @arg @ref ADC_CHANNEL_1
  1982. * @arg @ref ADC_CHANNEL_2
  1983. * @arg @ref ADC_CHANNEL_3
  1984. * @arg @ref ADC_CHANNEL_4
  1985. * @arg @ref ADC_CHANNEL_5
  1986. * @arg @ref ADC_CHANNEL_6
  1987. * @arg @ref ADC_CHANNEL_7
  1988. * @arg @ref ADC_CHANNEL_8
  1989. * @arg @ref ADC_CHANNEL_9
  1990. * @arg @ref ADC_CHANNEL_10
  1991. * @arg @ref ADC_CHANNEL_TEMPSENSOR
  1992. * @param SingleDiff This parameter can be a combination of the following values:
  1993. * @arg @ref LL_ADC_SINGLE_ENDED
  1994. * @arg @ref LL_ADC_DIFFERENTIAL_ENDED
  1995. * @retval None
  1996. */
  1997. #define __LL_ADC_SetChannelSingleDiff(__INSTANCE__, __CHANNEL__, __SINGLEDIFF__) \
  1998. MODIFY_REG((__INSTANCE__)->DIFSEL, \
  1999. ADC_SINGLEDIFF_CHANNEL_SHIFT << (__CHANNEL__), \
  2000. (((__SINGLEDIFF__) & ADC_SINGLEDIFF_CHANNEL_SHIFT) << (__CHANNEL__)))
  2001. /**
  2002. * @brief Get mode single-ended or differential input of the selected
  2003. * ADC channel.
  2004. * In differential mode: Differential measurement is carried out
  2005. * between the selected channel 'i' (positive input) and
  2006. * channel 'i+1' (negative input). Only channel 'i' has to be
  2007. * configured, channel 'i+1' is configured automatically.
  2008. * @note For example, internal channels (VrefInt, TempSensor, ...) are
  2009. * not available in differential mode.
  2010. * @note When configuring a channel 'i' in differential mode,
  2011. * the channel 'i+1' is not usable separately.refer to device datasheet
  2012. * for more details.
  2013. * @note For ADC channels configured in differential mode, both inputs
  2014. * should be biased at (Vref+)/2 +/-200mV.
  2015. * (Vref+ is the analog voltage reference)
  2016. * @param Instance ADC instance
  2017. * @param Channel This parameter can be one of the following values:
  2018. * @arg @ref ADC_CHANNEL_0
  2019. * @arg @ref ADC_CHANNEL_1
  2020. * @arg @ref ADC_CHANNEL_2
  2021. * @arg @ref ADC_CHANNEL_3
  2022. * @arg @ref ADC_CHANNEL_4
  2023. * @arg @ref ADC_CHANNEL_5
  2024. * @arg @ref ADC_CHANNEL_6
  2025. * @arg @ref ADC_CHANNEL_7
  2026. * @arg @ref ADC_CHANNEL_8
  2027. * @arg @ref ADC_CHANNEL_9
  2028. * @arg @ref ADC_CHANNEL_10
  2029. * @arg @ref ADC_CHANNEL_TEMPSENSOR
  2030. * @retval SingleDiff This parameter can be a combination of the following values:
  2031. * @arg @ref LL_ADC_SINGLE_ENDED
  2032. * @arg @ref LL_ADC_DIFFERENTIAL_ENDED
  2033. */
  2034. #define __LL_ADC_GetChannelSingleDiff(__INSTANCE__, __CHANNEL__) \
  2035. ((READ_BIT((__INSTANCE__)->DIFSEL, ADC_SINGLEDIFF_CHANNEL_SHIFT << (__CHANNEL__)) == \
  2036. (ADC_SINGLEDIFF_CHANNEL_SHIFT << (__CHANNEL__))) ? 0x1U : 0x0U)
  2037. /**
  2038. * @}
  2039. */
  2040. /** @addtogroup ADC_LL_Configuration_ADC_AnalogWatchdog Configuration of ADC transversal scope: analog watchdog
  2041. * @{
  2042. */
  2043. /**
  2044. * @brief Set ADC analog watchdog monitored channels:
  2045. * a single channel, multiple channels or all channels,
  2046. * @note Once monitored channels are selected, analog watchdog
  2047. * is enabled.
  2048. * @note In case of need to define a single channel to monitor
  2049. * with analog watchdog from sequencer channel definition,
  2050. * @note Analog watchdog instance:
  2051. * - AWD standard (instance AWD0\1\2):
  2052. * - channels monitored: can monitor 1 channel or all channels.
  2053. * ADC must be disabled or enabled without conversion on going
  2054. * on either groups regular or injected.
  2055. * @param Instance ADC instance
  2056. * @param AWDy This parameter can be one of the following values:
  2057. * @arg @ref ADC_AWD0
  2058. * @arg @ref ADC_AWD1
  2059. * @arg @ref ADC_AWD2
  2060. * @param AWDChannelGroup This parameter can combination of the following values:
  2061. * @arg @ref ADC_AWD_DISABLE
  2062. * @arg @ref ADC_AWD_ALL_CHANNELS
  2063. * @arg @ref ADC_AWD_CHANNEL_0
  2064. * @arg @ref ADC_AWD_CHANNEL_1
  2065. * @arg @ref ADC_AWD_CHANNEL_2
  2066. * @arg @ref ADC_AWD_CHANNEL_3
  2067. * @arg @ref ADC_AWD_CHANNEL_4
  2068. * @arg @ref ADC_AWD_CHANNEL_5
  2069. * @arg @ref ADC_AWD_CHANNEL_6
  2070. * @arg @ref ADC_AWD_CHANNEL_7
  2071. * @arg @ref ADC_AWD_CHANNEL_8
  2072. * @arg @ref ADC_AWD_CHANNEL_9
  2073. * @arg @ref ADC_AWD_CHANNEL_10
  2074. * @arg @ref ADC_AWD_CHANNEL_11
  2075. * @retval None
  2076. */
  2077. #define __LL_ADC_SetAnalogWDMonitChannels(__INSTANCE__, __AWDY__, __AWDCHANNEL__) \
  2078. MODIFY_REG((__INSTANCE__)->AWDCR[__AWDY__], ADC_AWD0CR_AWD0CH, __AWDCHANNEL__)
  2079. /**
  2080. * @brief Get ADC analog watchdog monitored channel.
  2081. * @note Usage of the returned channel number:
  2082. * @note Once monitored channels are selected, analog watchdog is enabled.
  2083. * @note In case of need to define a single channel to monitor
  2084. * with analog watchdog from sequencer channel definition,
  2085. * @param Instance ADC instance
  2086. * @param AWDy This parameter can be one of the following values:
  2087. * @arg @ref ADC_AWD0
  2088. * @arg @ref ADC_AWD1
  2089. * @arg @ref ADC_AWD2
  2090. * @retval Returned value can be one of the following values:
  2091. * @arg @ref ADC_AWD_DISABLE
  2092. * @arg @ref ADC_AWD_ALL_CHANNELS
  2093. * @arg @ref ADC_AWD_CHANNEL_0
  2094. * @arg @ref ADC_AWD_CHANNEL_1
  2095. * @arg @ref ADC_AWD_CHANNEL_2
  2096. * @arg @ref ADC_AWD_CHANNEL_3
  2097. * @arg @ref ADC_AWD_CHANNEL_4
  2098. * @arg @ref ADC_AWD_CHANNEL_5
  2099. * @arg @ref ADC_AWD_CHANNEL_6
  2100. * @arg @ref ADC_AWD_CHANNEL_7
  2101. * @arg @ref ADC_AWD_CHANNEL_8
  2102. * @arg @ref ADC_AWD_CHANNEL_9
  2103. * @arg @ref ADC_AWD_CHANNEL_10
  2104. * @arg @ref ADC_AWD_CHANNEL_11
  2105. */
  2106. #define __LL_ADC_GetAnalogWDMonitChannels(__INSTANCE__, __AWDY__) \
  2107. READ_BIT((Instance->AWDCR[AWDy]), ADC_AWD0CR_AWD0CH & ADC_AWD_ALL_CHANNELS)
  2108. /**
  2109. * @brief Set ADC analog watchdog thresholds value of both thresholds
  2110. * high and low.
  2111. * @note If value of only one threshold high or low must be set,
  2112. * use function @ref LL_ADC_SetAnalogWDThresholds().
  2113. * @note In case of ADC resolution different of 16 bits.
  2114. * @note Analog watchdog instance:
  2115. * - AWD standard (instance AWD0\1\2):
  2116. * - channels monitored: can monitor 1 channel or all channels.
  2117. * - groups monitored: ADC groups regular and-or injected.
  2118. * @note ADC data register bitfield [15:0] (16 most significant bits).
  2119. * @param Instance ADC instance
  2120. * @param AWDy This parameter can be one of the following values:
  2121. * @arg @ref ADC_AWD0
  2122. * @arg @ref ADC_AWD1
  2123. * @arg @ref ADC_AWD2
  2124. * @param AWDThresholdHighValue Value between Min_Data=0x0000 and Max_Data=0xFFFF
  2125. * @param AWDThresholdLowValue Value between Min_Data=0x0000 and Max_Data=0xFFFF
  2126. * @retval None
  2127. */
  2128. #define __LL_ADC_ConfigAnalogWDThresholds(__INSTANCE__, __AWDY__, __HIGHVALUE__, __LOWVALUE__) \
  2129. WRITE_REG((__INSTANCE__)->TR[__AWDY__], ((__HIGHVALUE__) << ADC_AWD_THRESHOLDS_HIGH_POS) | (__LOWVALUE__))
  2130. /**
  2131. * @brief Set ADC analog watchdog threshold value of threshold
  2132. * high or low.
  2133. * @note If value of only one threshold high or low must be set,
  2134. * use function @ref LL_ADC_SetAnalogWDThresholds().
  2135. * @note In case of ADC resolution different of 16 bits.
  2136. * @note Analog watchdog instance:
  2137. * - AWD standard (instance AWD0\1\2):
  2138. * - channels monitored: can monitor 1 channel or all channels.
  2139. * - groups monitored: ADC groups regular and-or injected.
  2140. * @note ADC data register bitfield [15:0] (16 most significant bits).
  2141. * @param Instance ADC instance
  2142. * @param AWDy This parameter can be one of the following values:
  2143. * @arg @ref ADC_AWD0
  2144. * @arg @ref ADC_AWD1
  2145. * @arg @ref ADC_AWD2
  2146. * @param AWDThresholdsHighLow This parameter can be one of the following values:
  2147. * @arg @ref ADC_AWD_THRESHOLD_HIGH
  2148. * @arg @ref ADC_AWD_THRESHOLD_LOW
  2149. * @param AWDThresholdValue Value between Min_Data=0x0000 and Max_Data=0xFFFF
  2150. * @retval None
  2151. */
  2152. #define __LL_ADC_SetAnalogWDThresholds(__INSTANCE__, __AWDY__, __SIGN__, __VALUE__) \
  2153. MODIFY_REG((__INSTANCE__)->TR[__AWDY__], (__SIGN__), \
  2154. ((((__VALUE__) << ADC_AWD_THRESHOLDS_HIGH_POS) | (__VALUE__)) & __SIGN__))
  2155. /**
  2156. * @brief Set ADC analog watchdog filtering configuration
  2157. * ADC must be disabled or enabled without conversion on going
  2158. * on either groups regular or injected.
  2159. * @param Instance ADC instance
  2160. * @param AWDy This parameter can be one of the following values:
  2161. * @arg @ref ADC_AWD0\1\2
  2162. * @param FilteringConfig This parameter can be one of the following values:
  2163. * @arg @ref ADC_AWD_FILTERING_NONE
  2164. * @arg @ref ADC_AWD_FILTERING_2
  2165. * @arg @ref ADC_AWD_FILTERING_3
  2166. * @arg @ref ADC_AWD_FILTERING_4
  2167. * @arg @ref ADC_AWD_FILTERING_5
  2168. * @arg @ref ADC_AWD_FILTERING_6
  2169. * @arg @ref ADC_AWD_FILTERING_7
  2170. * @arg @ref ADC_AWD_FILTERING_8
  2171. * @arg @ref ADC_AWD_FILTERING_9
  2172. * @arg @ref ADC_AWD_FILTERING_10
  2173. * @arg @ref ADC_AWD_FILTERING_11
  2174. * @arg @ref ADC_AWD_FILTERING_12
  2175. * @arg @ref ADC_AWD_FILTERING_13
  2176. * @arg @ref ADC_AWD_FILTERING_14
  2177. * @arg @ref ADC_AWD_FILTERING_15
  2178. * @arg @ref ADC_AWD_FILTERING_16
  2179. * @retval None
  2180. */
  2181. #define __LL_ADC_SetAWDFilteringConfiguration(__INSTANCE__, __AWDY__, __AWDFILTER__) \
  2182. MODIFY_REG((__INSTANCE__)->AWDCR[__AWDY__], ADC_AWD0CR_AWD0FILT, (__AWDFILTER__))
  2183. /**
  2184. * @brief Get ADC analog watchdog filtering configuration
  2185. * @note On this TMF5 serie, this feature is only available on first
  2186. * analog watchdog (AWD0\1\2)
  2187. * @param Instance ADC instance
  2188. * @param AWDy This parameter can be one of the following values:
  2189. * @arg @ref ADC_AWD0\1\2
  2190. * @param FilteringConfig This parameter can be one of the following values:
  2191. * @arg @ref ADC_AWD_FILTERING_NONE
  2192. * @arg @ref ADC_AWD_FILTERING_2
  2193. * @arg @ref ADC_AWD_FILTERING_3
  2194. * @arg @ref ADC_AWD_FILTERING_4
  2195. * @arg @ref ADC_AWD_FILTERING_5
  2196. * @arg @ref ADC_AWD_FILTERING_6
  2197. * @arg @ref ADC_AWD_FILTERING_7
  2198. * @arg @ref ADC_AWD_FILTERING_8
  2199. * @arg @ref ADC_AWD_FILTERING_9
  2200. * @arg @ref ADC_AWD_FILTERING_10
  2201. * @arg @ref ADC_AWD_FILTERING_11
  2202. * @arg @ref ADC_AWD_FILTERING_12
  2203. * @arg @ref ADC_AWD_FILTERING_13
  2204. * @arg @ref ADC_AWD_FILTERING_14
  2205. * @arg @ref ADC_AWD_FILTERING_15
  2206. * @arg @ref ADC_AWD_FILTERING_16
  2207. */
  2208. #define __LL_ADC_GetAWDFilteringConfiguration(__INSTANCE__, __AWDY__) \
  2209. READ_BIT((__INSTANCE__)->AWDCR[__AWDY__], ADC_AWD0CR_AWD0FILT)
  2210. /**
  2211. * @}
  2212. */
  2213. /** @addtogroup ADC_LL_Configuration_ADC_oversampling Configuration of ADC transversal scope: oversampling
  2214. * @{
  2215. */
  2216. /**
  2217. * @brief Set ADC oversampling scope: ADC groups regular and-or injected.
  2218. * @note If both groups regular and injected are selected,
  2219. * specify behavior of ADC group injected interrupting
  2220. * group regular: when ADC group injected is triggered,
  2221. * the oversampling on ADC group regular is either
  2222. * temporary stopped and continued, or resumed from start
  2223. * (oversampler buffer reset).
  2224. * ADC must be disabled or enabled without conversion on going
  2225. * on either groups regular or injected.
  2226. * @param Instance ADC instance
  2227. * @param This parameter can be one of the following values:
  2228. * @arg @ref ADC_OVS_DISABLE
  2229. * @arg @ref ADC_OVS_GRP_REGULAR_CONTINUED
  2230. * @arg @ref ADC_OVS_GRP_REGULAR_RESUMED
  2231. * @arg @ref ADC_OVS_GRP_INJECTED
  2232. * @arg @ref ADC_OVS_GRP_INJ_REG_RESUMED
  2233. * @retval None
  2234. */
  2235. #define __LL_ADC_SetOverSamplingScope(__INSTANCE__, __OVRSCOPE__) \
  2236. MODIFY_REG((__INSTANCE__)->CR1, ADC_CR1_ROVSE | ADC_CR1_JOVSE | ADC_CR1_ROVSM, __OVRSCOPE__)
  2237. /**
  2238. * @brief Get ADC oversampling scope: ADC groups regular and-or injected.
  2239. * @note If both groups regular and injected are selected,
  2240. * specify behavior of ADC group injected interrupting
  2241. * group regular: when ADC group injected is triggered,
  2242. * the oversampling on ADC group regular is either
  2243. * temporary stopped and continued, or resumed from start
  2244. * (oversampler buffer reset).
  2245. * @param Instance ADC instance
  2246. * @retval Returned value can be one of the following values:
  2247. * @arg @ref ADC_OVS_DISABLE
  2248. * @arg @ref ADC_OVS_GRP_REGULAR_CONTINUED
  2249. * @arg @ref ADC_OVS_GRP_REGULAR_RESUMED
  2250. * @arg @ref ADC_OVS_GRP_INJECTED
  2251. * @arg @ref ADC_OVS_GRP_INJ_REG_RESUMED
  2252. */
  2253. #define __LL_ADC_GetOverSamplingScope(__INSTANCE__) \
  2254. READ_BIT((__INSTANCE__)->CR1, ADC_CR1_ROVSE | ADC_CR1_JOVSE | ADC_CR1_ROVSM)
  2255. /**
  2256. * @brief Set ADC oversampling discontinuous mode (triggered mode)
  2257. * on the selected ADC group.
  2258. * @note Number of oversampled conversions are done either in:
  2259. * - continuous mode (all conversions of oversampling ratio
  2260. * are done from 1 trigger)
  2261. * - discontinuous mode (each conversion of oversampling ratio
  2262. * needs a trigger)
  2263. * @note oversampling discontinuous mode (triggered mode) can be used only
  2264. * when oversampling is set on group regular only and in resumed mode.
  2265. * @param Instance ADC instance
  2266. * @param OverSamplingDiscont This parameter can be one of the following values:
  2267. * @arg @ref ADC_OVS_REG_CONT
  2268. * @arg @ref ADC_OVS_REG_DISCONT
  2269. * @retval None
  2270. */
  2271. #define __LL_ADC_SetOverSamplingDiscont(__INSTANCE__, __TROVS__) MODIFY_REG((__INSTANCE__)->CR1, ADC_CR1_TROVS, (__TROVS__))
  2272. /**
  2273. * @brief Get ADC oversampling discontinuous mode (triggered mode)
  2274. * on the selected ADC group.
  2275. * @note Number of oversampled conversions are done either in:
  2276. * - continuous mode (all conversions of oversampling ratio
  2277. * are done from 1 trigger)
  2278. * - discontinuous mode (each conversion of oversampling ratio
  2279. * needs a trigger)
  2280. * @param Instance ADC instance
  2281. * @retval Returned value can be one of the following values:
  2282. * @arg @ref ADC_OVS_REG_CONT
  2283. * @arg @ref ADC_OVS_REG_DISCONT
  2284. */
  2285. #define __LL_ADC_GetOverSamplingDiscont(__INSTANCE__) READ_BIT((__INSTANCE__)->CR1, ADC_CR1_TROVS)
  2286. /**
  2287. * @brief Set ADC oversampling
  2288. * (impacting both ADC groups regular and injected)
  2289. * @note This function set the 2 items of oversampling configuration:
  2290. * - ratio
  2291. * - shift
  2292. * @param Instance ADC instance
  2293. * @param Ratio This parameter can be one of the following values:
  2294. * @arg @ref ADC_OVSR_RATIO_2
  2295. * @arg @ref ADC_OVSR_RATIO_4
  2296. * @arg @ref ADC_OVSR_RATIO_8
  2297. * @arg @ref ADC_OVSR_RATIO_16
  2298. * @arg @ref ADC_OVSR_RATIO_32
  2299. * @arg @ref ADC_OVSR_RATIO_64
  2300. * @arg @ref ADC_OVSR_RATIO_128
  2301. * @arg @ref ADC_OVSR_RATIO_256
  2302. * @param Shift This parameter can be one of the following values:
  2303. * @arg @ref ADC_OVSS_SHIFT_NONE
  2304. * @arg @ref ADC_OVSS_SHIFT_RIGHT_1
  2305. * @arg @ref ADC_OVSS_SHIFT_RIGHT_2
  2306. * @arg @ref ADC_OVSS_SHIFT_RIGHT_3
  2307. * @arg @ref ADC_OVSS_SHIFT_RIGHT_4
  2308. * @arg @ref ADC_OVSS_SHIFT_RIGHT_5
  2309. * @arg @ref ADC_OVSS_SHIFT_RIGHT_6
  2310. * @arg @ref ADC_OVSS_SHIFT_RIGHT_7
  2311. * @arg @ref ADC_OVSS_SHIFT_RIGHT_8
  2312. * @retval None
  2313. */
  2314. #define __LL_ADC_ConfigOverSamplingRatioShift(__INSTANCE__, __RATIO__, __SHIFT__) \
  2315. MODIFY_REG((__INSTANCE__)->CR1, (ADC_CR1_OVSS | ADC_CR1_OVSR), (__SHIFT__ | __RATIO__))
  2316. /**
  2317. * @brief Get ADC oversampling ratio
  2318. * (impacting both ADC groups regular and injected)
  2319. * @param Instance ADC instance
  2320. * @retval Ratio This parameter can be one of the following values:
  2321. * @arg @ref ADC_OVSR_RATIO_2
  2322. * @arg @ref ADC_OVSR_RATIO_4
  2323. * @arg @ref ADC_OVSR_RATIO_8
  2324. * @arg @ref ADC_OVSR_RATIO_16
  2325. * @arg @ref ADC_OVSR_RATIO_32
  2326. * @arg @ref ADC_OVSR_RATIO_64
  2327. * @arg @ref ADC_OVSR_RATIO_128
  2328. * @arg @ref ADC_OVSR_RATIO_256
  2329. */
  2330. #define __LL_ADC_GetOverSamplingRatio(__INSTANCE__) READ_BIT((__INSTANCE__)->CR1, ADC_CR1_OVSR)
  2331. /**
  2332. * @brief Get ADC oversampling shift
  2333. * (impacting both ADC groups regular and injected)
  2334. * @param Instance ADC instance
  2335. * @retval Shift This parameter can be one of the following values:
  2336. * @arg @ref ADC_OVS_SHIFT_NONE
  2337. * @arg @ref ADC_OVS_SHIFT_RIGHT_1
  2338. * @arg @ref ADC_OVS_SHIFT_RIGHT_2
  2339. * @arg @ref ADC_OVS_SHIFT_RIGHT_3
  2340. * @arg @ref ADC_OVS_SHIFT_RIGHT_4
  2341. * @arg @ref ADC_OVS_SHIFT_RIGHT_5
  2342. * @arg @ref ADC_OVS_SHIFT_RIGHT_6
  2343. * @arg @ref ADC_OVS_SHIFT_RIGHT_7
  2344. * @arg @ref ADC_OVS_SHIFT_RIGHT_8
  2345. */
  2346. #define __LL_ADC_GetOverSamplingShift(__INSTANCE__) READ_BIT((__INSTANCE__)->CR1, ADC_CR1_OVSS)
  2347. /**
  2348. * @}
  2349. */
  2350. /** @addtogroup ADC_LL_Operation_ADC_Group_Injected Operation on ADC hierarchical scope: group injected
  2351. * @{
  2352. */
  2353. /**
  2354. * @brief Start ADC group injected conversion.
  2355. * @note This function is relevant for both internal trigger (SW start) and external trigger:
  2356. * - If ADC trigger has been set to software start, ADC conversion
  2357. * starts immediately.
  2358. * - If ADC trigger has been set to external trigger, ADC conversion
  2359. * will start at next trigger event (on the selected trigger edge)
  2360. * following the ADC start conversion command.
  2361. * @note Setting of this feature is conditioned to ADC state:
  2362. * ADC must be enabled without conversion on going on group injected,
  2363. * without conversion stop command on going on group injected.
  2364. * @param Instance ADC instance
  2365. * @retval None
  2366. */
  2367. #define __LL_ADC_INJ_StartConversion(__INSTANCE__) MODIFY_REG((__INSTANCE__)->CR0, ADC_CR0_BITS_PROPERTY_RS, ADC_CR0_JADSTART)
  2368. /**
  2369. * @brief Stop ADC group injected conversion.
  2370. * @note Setting of this feature is conditioned to ADC state:
  2371. * ADC must be enabled with conversion on going on group injected,
  2372. * without ADC disable command on going.
  2373. * @param Instance ADC instance
  2374. * @retval None
  2375. */
  2376. #define __LL_ADC_INJ_StopConversion(__INSTANCE__) MODIFY_REG((__INSTANCE__)->CR0, ADC_CR0_BITS_PROPERTY_RS, ADC_CR0_JADSTP)
  2377. /**
  2378. * @brief Get ADC group injected conversion state.
  2379. * @param Instance ADC instance
  2380. * @retval 0: no conversion is on going on ADC group injected.
  2381. */
  2382. #define __LL_ADC_INJ_IsConversionOngoing(__INSTANCE__) \
  2383. ((READ_BIT((__INSTANCE__)->CR0, ADC_CR0_JADSTART) == (ADC_CR0_JADSTART)) ? 1UL : 0UL)
  2384. /**
  2385. * @brief Get ADC group injected command of conversion stop state
  2386. * @param Instance ADC instance
  2387. * @retval 0: no command of conversion stop is on going on ADC group injected.
  2388. */
  2389. #define __LL_ADC_INJ_IsStopConversionOngoing(__INSTANCE__) \
  2390. ((READ_BIT((__INSTANCE__)->CR0, ADC_CR0_JADSTP) == (ADC_CR0_JADSTP)) ? 1UL : 0UL)
  2391. /**
  2392. * @brief Get ADC group injected conversion data, range fit for
  2393. * all ADC configurations.
  2394. * @param Instance ADC instance
  2395. * @param Rank This parameter can be one of the following values:
  2396. * @arg @ref ADC_INJ_RANK_1
  2397. * @arg @ref ADC_INJ_RANK_2
  2398. * @arg @ref ADC_INJ_RANK_3
  2399. * @arg @ref ADC_INJ_RANK_4
  2400. * @retval Value between Min_Data=0x0000 and Max_Data=0xFFFF
  2401. */
  2402. #define __LL_ADC_INJ_ReadConversionData(__INSTANCE__, __RANK__) \
  2403. READ_BIT((__INSTANCE__)->JDR[(__RANK__) >> ADC_JSQX_REGOFFSET], ADC_JDR0_JDATA)
  2404. /**
  2405. * @}
  2406. */
  2407. /** @addtogroup ADC_LL_ECU related register interface functions are configured in the ADC
  2408. * @{
  2409. */
  2410. /**
  2411. * @brief Sets the source channel for the data Address flag bit.
  2412. * @note The linkage with the ECU must work in DMA cycle mode.
  2413. * @param Instance ADC instance
  2414. * @param GroupSel ADC_ECR_GROUP_SEL
  2415. * @param Channel ADC_CHANNEL
  2416. * @retval None
  2417. */
  2418. #define __LL_ADC_ECU_SetAddrDataFlag(__INSTANCE__, __GROUP__, __CHANNLE__) \
  2419. MODIFY_REG((__INSTANCE__)->ECR[__GROUP__], ADC_ECR0_ADSRC, ((__CHANNLE__) << ADC_ECR0_ADSRC_Pos))
  2420. /**
  2421. * @brief Set PINGPONG to rise and fall over zero and choose which watchdog to monitor.
  2422. * @note Try to use different watchdogs for ascending and
  2423. * descending zero - crossing monitoring.
  2424. * @param Instance ADC instance
  2425. * @param GroupSel ADC_ECR_GROUP_SEL
  2426. * @param UpZeroAWD the range of value AWD0\1\2
  2427. * @param DownZeroAWD the range of value AWD0\1\2
  2428. * @retval None
  2429. */
  2430. #define __LL_ADC_ECU_SetUpDownPPFlag(__INSTANCE__, __GROUP__, __UPAWD__, __DOWNAWD__) \
  2431. MODIFY_REG((__INSTANCE__)->ECR[__GROUP__], \
  2432. ADC_ECR0_PSRCU | ADC_ECR0_PSRCD, \
  2433. (((__UPAWD__) << ADC_ECR0_PSRCU_Pos) | ((__DOWNAWD__) << ADC_ECR0_PSRCD_Pos)))
  2434. /**
  2435. * @brief Set up a watch-dog 2 monitoring channel.
  2436. * @note The selected channel for ascending and descending zero crossing
  2437. * monitoring watchdog must be configured to be the same.
  2438. * @param Instance ADC instance
  2439. * @param GroupSel ADC_ECR_GROUP_SEL
  2440. * @param Channel ADC_CHANNEL
  2441. * @retval None
  2442. */
  2443. #define __LL_ADC_ECU_SetAWD2Channel(__INSTANCE__, __GROUP__, __CHANNLE__) \
  2444. MODIFY_REG((__INSTANCE__)->ECR[__GROUP__], ADC_ECR0_AWD2SEL, ((__CHANNLE__) << ADC_ECR0_AWD2SEL_Pos))
  2445. /**
  2446. * @brief Set up a watch-dog 1 monitoring channel.
  2447. * @note The selected channel for ascending and descending zero crossing
  2448. * monitoring watchdog must be configured to be the same.
  2449. * @param Instance ADC instance
  2450. * @param GroupSel ADC_ECR_GROUP_SEL
  2451. * @param Channel ADC_CHANNEL
  2452. * @retval None
  2453. */
  2454. #define __LL_ADC_ECU_SetAWD1Channel(__INSTANCE__, __GROUP__, __CHANNLE__) \
  2455. MODIFY_REG((__INSTANCE__)->ECR[__GROUP__], ADC_ECR0_AWD1SEL, ((__CHANNLE__) << ADC_ECR0_AWD1SEL_Pos))
  2456. /**
  2457. * @brief Set up a watch-dog 0 monitoring channel.
  2458. * @note The selected channel for ascending and descending zero crossing
  2459. * monitoring watchdog must be configured to be the same.
  2460. * @param Instance ADC instance
  2461. * @param GroupSel ADC_ECR_GROUP_SEL
  2462. * @param Channel ADC_CHANNEL
  2463. * @retval None
  2464. */
  2465. #define __LL_ADC_ECU_SetAWD0Channel(__INSTANCE__, __GROUP__, __CHANNLE__) \
  2466. MODIFY_REG((__INSTANCE__)->ECR[__GROUP__], ADC_ECR0_AWD0SEL, ((__CHANNLE__) << ADC_ECR0_AWD0SEL_Pos))
  2467. /**
  2468. * @}
  2469. */
  2470. /** @addtogroup ADC_LL_FLAG_Management ADC normal flag management
  2471. * @{
  2472. */
  2473. /**
  2474. * @brief Get flag ADC ready.
  2475. * @note Flag ADC_FLAG_ADRDY is raised when the ADC
  2476. * is enabled and when conversion clock is active.
  2477. * @param __INSTANCE__ ADC instance
  2478. * @retval State of bit (1 or 0).
  2479. */
  2480. #define __LL_ADC_GET_FLAG_ADRDY(__INSTANCE__) ((READ_BIT((__INSTANCE__)->ISR, ADC_FLAG_ADRDY) == (ADC_FLAG_ADRDY)) ? 1UL : 0UL)
  2481. /**
  2482. * @brief Get flag ADC group regular end of unitary conversion.
  2483. * @param __INSTANCE__ ADC instance
  2484. * @retval State of bit (1 or 0).
  2485. */
  2486. #define __LL_ADC_GET_FLAG_EOC(__INSTANCE__) ((READ_BIT((__INSTANCE__)->ISR, ADC_FLAG_EOC) == (ADC_FLAG_EOC)) ? 1UL : 0UL)
  2487. /**
  2488. * @brief Get flag ADC group regular end of sequence conversions.
  2489. * @param __INSTANCE__ ADC instance
  2490. * @retval State of bit (1 or 0).
  2491. */
  2492. #define __LL_ADC_GET_FLAG_EOS(__INSTANCE__) ((READ_BIT((__INSTANCE__)->ISR, ADC_FLAG_EOS) == (ADC_FLAG_EOS)) ? 1UL : 0UL)
  2493. /**
  2494. * @brief Get flag ADC group regular overrun.
  2495. * @param __INSTANCE__ ADC instance
  2496. * @retval State of bit (1 or 0).
  2497. */
  2498. #define __LL_ADC_GET_FLAG_OVR(__INSTANCE__) ((READ_BIT((__INSTANCE__)->ISR, ADC_FLAG_OVR) == (ADC_FLAG_OVR)) ? 1UL : 0UL)
  2499. /**
  2500. * @brief Get flag ADC group regular end of sampling phase.
  2501. * @param __INSTANCE__ ADC instance
  2502. * @retval State of bit (1 or 0).
  2503. */
  2504. #define __LL_ADC_GET_FLAG_EOSMP(__INSTANCE__) ((READ_BIT((__INSTANCE__)->ISR, ADC_FLAG_EOSMP) == (ADC_FLAG_EOSMP)) ? 1UL : 0UL)
  2505. /**
  2506. * @brief Get flag ADC group injected end of unitary conversion.
  2507. * @param __INSTANCE__ ADC instance
  2508. * @retval State of bit (1 or 0).
  2509. */
  2510. #define __LL_ADC_GET_FLAG_JEOC(__INSTANCE__) ((READ_BIT((__INSTANCE__)->ISR, ADC_FLAG_JEOC) == (ADC_FLAG_JEOC)) ? 1UL : 0UL)
  2511. /**
  2512. * @brief Get flag ADC group injected end of sequence conversions.
  2513. * @param __INSTANCE__ ADC instance
  2514. * @retval State of bit (1 or 0).
  2515. */
  2516. #define __LL_ADC_GET_FLAG_JEOS(__INSTANCE__) ((READ_BIT((__INSTANCE__)->ISR, ADC_FLAG_JEOS) == (ADC_FLAG_JEOS)) ? 1UL : 0UL)
  2517. /**
  2518. * @brief Get flag ADC analog watchdog 0 flag
  2519. * @param __INSTANCE__ ADC instance
  2520. * @retval State of bit (1 or 0).
  2521. */
  2522. #define __LL_ADC_GET_FLAG_AWD0(__INSTANCE__) ((READ_BIT((__INSTANCE__)->ISR, ADC_FLAG_AWD0) == (ADC_FLAG_AWD0)) ? 1UL : 0UL)
  2523. /**
  2524. * @brief Get flag ADC analog watchdog 1.
  2525. * @param __INSTANCE__ ADC instance
  2526. * @retval State of bit (1 or 0).
  2527. */
  2528. #define __LL_ADC_GET_FLAG_AWD1(__INSTANCE__) ((READ_BIT((__INSTANCE__)->ISR, ADC_FLAG_AWD1) == (ADC_FLAG_AWD1)) ? 1UL : 0UL)
  2529. /**
  2530. * @brief Get flag ADC analog watchdog 2.
  2531. * @param __INSTANCE__ ADC instance
  2532. * @retval State of bit (1 or 0).
  2533. */
  2534. #define __LL_ADC_GET_FLAG_AWD2(__INSTANCE__) ((READ_BIT((__INSTANCE__)->ISR, ADC_FLAG_AWD2) == (ADC_FLAG_AWD2)) ? 1UL : 0UL)
  2535. /**
  2536. * @brief Clear flag ADC ready.
  2537. * @note Flag ADC_FLAG_ADRDY is raised when the ADC
  2538. * is enabled and when conversion clock is active.
  2539. * @param __INSTANCE__ ADC instance
  2540. * @retval None
  2541. */
  2542. #define __LL_ADC_CLEAR_FLAG_ADRDY(__INSTANCE__) WRITE_REG((__INSTANCE__)->ISR, ADC_FLAG_ADRDY)
  2543. /**
  2544. * @brief Clear flag ADC group regular end of unitary conversion.
  2545. * @param __INSTANCE__ ADC instance
  2546. * @retval None
  2547. */
  2548. #define __LL_ADC_CLEAR_FLAG_EOC(__INSTANCE__) WRITE_REG((__INSTANCE__)->ISR, ADC_FLAG_EOC)
  2549. /**
  2550. * @brief Clear flag ADC group regular end of sequence conversions.
  2551. * @param __INSTANCE__ ADC instance
  2552. * @retval None
  2553. */
  2554. #define __LL_ADC_CLEAR_FLAG_EOS(__INSTANCE__) WRITE_REG((__INSTANCE__)->ISR, ADC_FLAG_EOS)
  2555. /**
  2556. * @brief Clear flag ADC group regular overrun.
  2557. * @param __INSTANCE__ ADC instance
  2558. * @retval None
  2559. */
  2560. #define __LL_ADC_CLEAR_FLAG_OVR(__INSTANCE__) WRITE_REG((__INSTANCE__)->ISR, ADC_FLAG_OVR)
  2561. /**
  2562. * @brief Clear flag ADC group regular end of sampling phase.
  2563. * @param __INSTANCE__ ADC instance
  2564. * @retval None
  2565. */
  2566. #define __LL_ADC_CLEAR_FLAG_EOSMP(__INSTANCE__) WRITE_REG((__INSTANCE__)->ISR, ADC_FLAG_EOSMP)
  2567. /**
  2568. * @brief Clear flag ADC group injected end of unitary conversion.
  2569. * @param __INSTANCE__ ADC instance
  2570. * @retval None
  2571. */
  2572. #define __LL_ADC_CLEAR_FLAG_JEOC(__INSTANCE__) WRITE_REG((__INSTANCE__)->ISR, ADC_FLAG_JEOC)
  2573. /**
  2574. * @brief Clear flag ADC group injected end of sequence conversions.
  2575. * @param __INSTANCE__ ADC instance
  2576. * @retval None
  2577. */
  2578. #define __LL_ADC_CLEAR_FLAG_JEOS(__INSTANCE__) WRITE_REG((__INSTANCE__)->ISR, ADC_FLAG_JEOS)
  2579. /**
  2580. * @brief Clear flag ADC analog watchdog 0.
  2581. * @param __INSTANCE__ ADC instance
  2582. * @retval None
  2583. */
  2584. #define __LL_ADC_CLEAR_FLAG_AWD0(__INSTANCE__) WRITE_REG((__INSTANCE__)->ISR, ADC_FLAG_AWD0)
  2585. /**
  2586. * @brief Clear flag ADC analog watchdog 1.
  2587. * @param __INSTANCE__ ADC instance
  2588. * @retval None
  2589. */
  2590. #define __LL_ADC_CLEAR_FLAG_AWD1(__INSTANCE__) WRITE_REG((__INSTANCE__)->ISR, ADC_FLAG_AWD1)
  2591. /**
  2592. * @brief Clear flag ADC analog watchdog 2.
  2593. * @param __INSTANCE__ ADC instance
  2594. * @retval None
  2595. */
  2596. #define __LL_ADC_CLEAR_FLAG_AWD2(__INSTANCE__) WRITE_REG((__INSTANCE__)->ISR, ADC_FLAG_AWD2)
  2597. /**
  2598. * @}
  2599. */
  2600. /** @addtogroup ADC_LL_IT_Management ADC IT management
  2601. * @{
  2602. */
  2603. /**
  2604. * @brief Enable the specified ADC interrupt.
  2605. * @param __INSTANCE__ ADC instance
  2606. * @param __INTERRUPT__ specifies the ADC flags to clear.
  2607. * This parameter can be any combination of @ref ADC_Flag_definition:
  2608. * @arg ADC_IT_ADRDY ADC flag ADC instance ready
  2609. * @arg ADC_IT_EOC ADC flag ADC group regular end of unitary conversion
  2610. * @arg ADC_IT_EOS ADC flag ADC group regular end of sequence conversions
  2611. * @arg ADC_IT_OVR ADC flag ADC group regular overrun
  2612. * @arg ADC_IT_EOSMP ADC flag ADC group regular end of sampling phase
  2613. * @arg ADC_IT_JEOC ADC flag ADC group injected end of unitary conversion
  2614. * @arg ADC_IT_JEOS ADC flag ADC group injected end of sequence conversions
  2615. * @arg ADC_IT_AWD0 ADC flag ADC analog watchdog 1
  2616. * @arg ADC_IT_AWD1 ADC flag ADC analog watchdog 2
  2617. * @arg ADC_IT_AWD2 ADC flag ADC analog watchdog 3
  2618. * @retval None
  2619. */
  2620. #define __LL_ADC_ENABLE_IT(__INSTANCE__, __INTERRUPT__) SET_BIT((__INSTANCE__)->IER, __INTERRUPT__)
  2621. /**
  2622. * @brief Disable the specified ADC interrupt.
  2623. * @param __INSTANCE__ ADC instance
  2624. * @param __INTERRUPT__ specifies the TMR flags to clear.
  2625. * This parameter can be any combination of @ref TMR_Flag_definition:
  2626. * @arg ADC_IT_ADRDY ADC flag ADC instance ready
  2627. * @arg ADC_IT_EOC ADC flag ADC group regular end of unitary conversion
  2628. * @arg ADC_IT_EOS ADC flag ADC group regular end of sequence conversions
  2629. * @arg ADC_IT_OVR ADC flag ADC group regular overrun
  2630. * @arg ADC_IT_EOSMP ADC flag ADC group regular end of sampling phase
  2631. * @arg ADC_IT_JEOC ADC flag ADC group injected end of unitary conversion
  2632. * @arg ADC_IT_JEOS ADC flag ADC group injected end of sequence conversions
  2633. * @arg ADC_IT_AWD0 ADC flag ADC analog watchdog 1
  2634. * @arg ADC_IT_AWD1 ADC flag ADC analog watchdog 2
  2635. * @arg ADC_IT_AWD2 ADC flag ADC analog watchdog 3
  2636. * @retval None
  2637. */
  2638. #define __LL_ADC_DISABLE_IT(__INSTANCE__, __INTERRUPT__) CLEAR_BIT((__INSTANCE__)->IER, __INTERRUPT__)
  2639. /**
  2640. * @brief Get state of interruption ADC ready
  2641. * (0: interrupt disabled, 1: interrupt enabled).
  2642. * @param __INSTANCE__ ADC instance
  2643. * @retval State of bit (1 or 0).
  2644. */
  2645. #define __LL_ADC_GET_IT_ADRDY(__INSTANCE__) ((READ_BIT((__INSTANCE__)->IER, ADC_IT_ADRDY) == (ADC_IT_ADRDY)) ? 1UL : 0UL)
  2646. /**
  2647. * @brief Get state of interruption ADC group regular end of unitary conversion
  2648. * (0: interrupt disabled, 1: interrupt enabled).
  2649. * @param __INSTANCE__ ADC instance
  2650. * @retval State of bit (1 or 0).
  2651. */
  2652. #define __LL_ADC_GET_IT_EOC(__INSTANCE__) ((READ_BIT((__INSTANCE__)->IER, ADC_IT_EOC) == (ADC_IT_EOC)) ? 1UL : 0UL)
  2653. /**
  2654. * @brief Get state of interruption ADC group regular end of sequence conversions
  2655. * (0: interrupt disabled, 1: interrupt enabled).
  2656. * @param __INSTANCE__ ADC instance
  2657. * @retval State of bit (1 or 0).
  2658. */
  2659. #define __LL_ADC_GET_IT_EOS(__INSTANCE__) ((READ_BIT((__INSTANCE__)->IER, ADC_IT_EOS) == (ADC_IT_EOS)) ? 1UL : 0UL)
  2660. /**
  2661. * @brief Get state of interruption ADC group regular overrun
  2662. * (0: interrupt disabled, 1: interrupt enabled).
  2663. * @param __INSTANCE__ ADC instance
  2664. * @retval State of bit (1 or 0).
  2665. */
  2666. #define __LL_ADC_GET_IT_OVR(__INSTANCE__) ((READ_BIT((__INSTANCE__)->IER, ADC_IT_OVR) == (ADC_IT_OVR)) ? 1UL : 0UL)
  2667. /**
  2668. * @brief Get state of interruption ADC group regular end of sampling
  2669. * (0: interrupt disabled, 1: interrupt enabled).
  2670. * @param __INSTANCE__ ADC instance
  2671. * @retval State of bit (1 or 0).
  2672. */
  2673. #define __LL_ADC_GET_IT_EOSMP(__INSTANCE__) ((READ_BIT((__INSTANCE__)->IER, ADC_IT_EOSMP) == (ADC_IT_EOSMP)) ? 1UL : 0UL)
  2674. /**
  2675. * @brief Get state of interruption ADC group injected end of unitary conversion
  2676. * (0: interrupt disabled, 1: interrupt enabled).
  2677. * @param __INSTANCE__ ADC instance
  2678. * @retval State of bit (1 or 0).
  2679. */
  2680. #define __LL_ADC_GET_IT_JEOC(__INSTANCE__) ((READ_BIT((__INSTANCE__)->IER, ADC_IT_JEOC) == (ADC_IT_JEOC)) ? 1UL : 0UL)
  2681. /**
  2682. * @brief Get state of interruption ADC group injected end of sequence conversions
  2683. * (0: interrupt disabled, 1: interrupt enabled).
  2684. * @param __INSTANCE__ ADC instance
  2685. * @retval State of bit (1 or 0).
  2686. */
  2687. #define __LL_ADC_GET_IT_JEOS(__INSTANCE__) ((READ_BIT((__INSTANCE__)->IER, ADC_IT_JEOS) == (ADC_IT_JEOS)) ? 1UL : 0UL)
  2688. /**
  2689. * @brief Get state of interruption Get ADC analog watchdog 0
  2690. * (0: interrupt disabled, 1: interrupt enabled).
  2691. * @param __INSTANCE__ ADC instance
  2692. * @retval State of bit (1 or 0).
  2693. */
  2694. #define __LL_ADC_GET_IT_AWD0(__INSTANCE__) ((READ_BIT((__INSTANCE__)->IER, ADC_IT_AWD0) == (ADC_IT_AWD0)) ? 1UL : 0UL)
  2695. /**
  2696. * @brief Get state of interruption ADC analog watchdog 1
  2697. * (0: interrupt disabled, 1: interrupt enabled).
  2698. * @param __INSTANCE__ ADC instance
  2699. * @retval State of bit (1 or 0).
  2700. */
  2701. #define __LL_ADC_GET_IT_AWD1(__INSTANCE__) ((READ_BIT((__INSTANCE__)->IER, ADC_IT_AWD1) == (ADC_IT_AWD1)) ? 1UL : 0UL)
  2702. /**
  2703. * @brief Get state of interruption Get ADC analog watchdog 2
  2704. * (0: interrupt disabled, 1: interrupt enabled).
  2705. * @param __INSTANCE__ ADC instance
  2706. * @retval State of bit (1 or 0).
  2707. */
  2708. #define __LL_ADC_GET_IT_AWD2(__INSTANCE__) ((READ_BIT((__INSTANCE__)->IER, ADC_IT_AWD2) == (ADC_IT_AWD2)) ? 1UL : 0UL)
  2709. /**
  2710. * @}
  2711. */
  2712. /** @addtogroup ADC_LL_SAMP_INT_FLAG ADC Sample interrupt management
  2713. * @{
  2714. */
  2715. /**
  2716. * @brief Enable interruption ADC every channel Sample done.
  2717. * @param __INSTANCE__ ADC instance
  2718. * @param Channel 0~11
  2719. * @retval None
  2720. */
  2721. #define __LL_ADC_ENABLE_IT_DONE(__INSTANCE__, __CHANNEL__) \
  2722. SET_BIT((__INSTANCE__)->SIER, (ADC_SIER_CHANNEL_0 << (__CHANNEL__)))
  2723. /**
  2724. * @brief Disable interruption ADC every channel Sample done.
  2725. * @param __INSTANCE__ ADC instance
  2726. * @param Channel 0~11
  2727. * @retval None
  2728. */
  2729. #define __LL_ADC_DISABLE_IT_DONE(__INSTANCE__, __CHANNEL__) \
  2730. CLEAR_BIT((__INSTANCE__)->SIER, (ADC_SIER_CHANNEL_0 << (__CHANNEL__)))
  2731. /**
  2732. * @brief Get state of interruption Get ADC every channel Sample done.
  2733. * (0: interrupt disabled, 1: interrupt enabled).
  2734. * @param __INSTANCE__ ADC instance
  2735. * @param Channel 0~11
  2736. * @retval State of bit (1 or 0).
  2737. */
  2738. #define __LL_ADC_GET_IT_DONE(__INSTANCE__, __CHANNEL__) \
  2739. ((READ_BIT((__INSTANCE__)->SIER, (ADC_SIER_CHANNEL_0 << (__CHANNEL__))) == \
  2740. ((ADC_SIER_CHANNEL_0 << (__CHANNEL__)))) ? 1UL : 0UL)
  2741. /**
  2742. * @brief Clear flag ADC every channel Sample done.
  2743. * @param __INSTANCE__ ADC instance
  2744. * @param Channel 0~11
  2745. * @retval None
  2746. */
  2747. #define __LL_ADC_CLEAR_FLAG_DONE(__INSTANCE__, __CHANNEL__) \
  2748. WRITE_REG((__INSTANCE__)->SISR, (ADC_SISR_CHANNEL_0 << (__CHANNEL__)))
  2749. /**
  2750. * @brief Get flagADC every channel Sample done.
  2751. * @param __INSTANCE__ ADC instance
  2752. * @param Channel 0~11
  2753. * @retval State of bit (1 or 0).
  2754. */
  2755. #define __LL_ADC_GET_FLAG_DONE(__INSTANCE__, __CHANNEL__) \
  2756. ((READ_BIT((__INSTANCE__)->SISR, (ADC_SISR_CHANNEL_0 << (__CHANNEL__))) == \
  2757. (ADC_SISR_CHANNEL_0 << (__CHANNEL__))) ? 1UL : 0UL)
  2758. /**
  2759. * @}
  2760. */
  2761. /** @addtogroup ADC_LL_HALF_INT_FLAG ADC Half interrupt management
  2762. * @{
  2763. */
  2764. /**
  2765. * @brief Enable interruption ADC every channel Sample done.
  2766. * @param __INSTANCE__ ADC instance
  2767. * @param Channel 0~11
  2768. * @retval None
  2769. */
  2770. #define __LL_ADC_ENABLE_IT_HALF(__INSTANCE__, __CHANNEL__) \
  2771. SET_BIT((__INSTANCE__)->HIER, (ADC_HIER_CHANNEL_0 << (__CHANNEL__)))
  2772. /**
  2773. * @brief Disable interruption ADC every channel Sample done.
  2774. * @param __INSTANCE__ ADC instance
  2775. * @param Channel 0~11
  2776. * @retval None
  2777. */
  2778. #define __LL_ADC_DISABLE_IT_HALF(__INSTANCE__, __CHANNEL__) \
  2779. CLEAR_BIT((__INSTANCE__)->HIER, (ADC_HIER_CHANNEL_0 << (__CHANNEL__)))
  2780. /**
  2781. * @brief Get state of interruption Get ADC every channel Sample done.
  2782. * (0: interrupt disabled, 1: interrupt enabled).
  2783. * @param __INSTANCE__ ADC instance
  2784. * @param Channel 0~11
  2785. * @retval State of bit (1 or 0).
  2786. */
  2787. #define __LL_ADC_GET_IT_HALF(__INSTANCE__, __CHANNEL__) \
  2788. ((READ_BIT((__INSTANCE__)->HIER, (ADC_HIER_CHANNEL_0 << (__CHANNEL__))) == \
  2789. ((ADC_HIER_CHANNEL_0 << (__CHANNEL__)))) ? 1UL : 0UL)
  2790. /**
  2791. * @brief Clear flag ADC every channel Sample done.
  2792. * @param __INSTANCE__ ADC instance
  2793. * @param Channel 0~11
  2794. * @retval None
  2795. */
  2796. #define __LL_ADC_CLEAR_FLAG_HALF(__INSTANCE__, __CHANNEL__) \
  2797. WRITE_REG((__INSTANCE__)->HISR, (ADC_HISR_CHANNEL_0 << (__CHANNEL__)))
  2798. /**
  2799. * @brief Get flagADC every channel Sample done.
  2800. * @param __INSTANCE__ ADC instance
  2801. * @param Channel 0~11
  2802. * @retval State of bit (1 or 0).
  2803. */
  2804. #define __LL_ADC_GET_FLAG_HALF(__INSTANCE__, __CHANNEL__) \
  2805. ((READ_BIT((__INSTANCE__)->HISR, (ADC_HISR_CHANNEL_0 << (__CHANNEL__))) == \
  2806. (ADC_HISR_CHANNEL_0 << (__CHANNEL__))) ? 1UL : 0UL)
  2807. /**
  2808. * @}
  2809. */
  2810. /** @addtogroup ADC_LL_FULL_INT_FLAG ADC Full interrupt management
  2811. * @{
  2812. */
  2813. /**
  2814. * @brief Enable interruption ADC every channel Sample done.
  2815. * @param __INSTANCE__ ADC instance
  2816. * @param Channel 0~11
  2817. * @retval None
  2818. */
  2819. #define __LL_ADC_ENABLE_IT_FULL(__INSTANCE__, __CHANNEL__) \
  2820. SET_BIT((__INSTANCE__)->FIER, (ADC_FIER_CHANNEL_0 << (__CHANNEL__)))
  2821. /**
  2822. * @brief Disable interruption ADC every channel Sample done.
  2823. * @param __INSTANCE__ ADC instance
  2824. * @param Channel 0~11
  2825. * @retval None
  2826. */
  2827. #define __LL_ADC_DISABLE_IT_FULL(__INSTANCE__, __CHANNEL__) \
  2828. CLEAR_BIT((__INSTANCE__)->FIER, (ADC_FIER_CHANNEL_0 << (__CHANNEL__)))
  2829. /**
  2830. * @brief Get state of interruption Get ADC every channel Sample done.
  2831. * (0: interrupt disabled, 1: interrupt enabled).
  2832. * @param __INSTANCE__ ADC instance
  2833. * @param Channel 0~11
  2834. * @retval State of bit (1 or 0).
  2835. */
  2836. #define __LL_ADC_GET_IT_FULL(__INSTANCE__, __CHANNEL__) \
  2837. ((READ_BIT((__INSTANCE__)->FIER, (ADC_FIER_CHANNEL_0 << (__CHANNEL__))) == \
  2838. ((ADC_FIER_CHANNEL_0 << (__CHANNEL__)))) ? 1UL : 0UL)
  2839. /**
  2840. * @brief Clear flag ADC every channel Sample done.
  2841. * @param __INSTANCE__ ADC instance
  2842. * @param Channel 0~11
  2843. * @retval None
  2844. */
  2845. #define __LL_ADC_CLEAR_FLAG_FULL(__INSTANCE__, __CHANNEL__) \
  2846. WRITE_REG((__INSTANCE__)->FISR, (ADC_FISR_CHANNEL_0 << (__CHANNEL__)))
  2847. /**
  2848. * @brief Get flagADC every channel Sample done.
  2849. * @param __INSTANCE__ ADC instance
  2850. * @param Channel 0~11
  2851. * @retval State of bit (1 or 0).
  2852. */
  2853. #define __LL_ADC_GET_FLAG_FULL(__INSTANCE__, __CHANNEL__) \
  2854. ((READ_BIT((__INSTANCE__)->FISR, (ADC_FISR_CHANNEL_0 << (__CHANNEL__))) == \
  2855. (ADC_FISR_CHANNEL_0 << (__CHANNEL__))) ? 1UL : 0UL)
  2856. /**
  2857. * @}
  2858. */
  2859. /**
  2860. * @}
  2861. */
  2862. /* Exported functions --------------------------------------------------------*/
  2863. /** @addtogroup ADC_LL_Exported_Functions
  2864. * @{
  2865. */
  2866. /** @addtogroup ADC_LL_Exported_Functions_Group1
  2867. * @{
  2868. */
  2869. LL_StatusETypeDef LL_ADC_Init(ADC_TypeDef *Instance, ADC_InitTypeDef *ADC_InitStruct);
  2870. LL_StatusETypeDef LL_ADC_DeInit(ADC_TypeDef *Instance);
  2871. LL_StatusETypeDef LL_ADC_REG_Init(ADC_TypeDef *Instance, ADC_REG_InitTypeDef *ADC_REG_InitStruct);
  2872. LL_StatusETypeDef LL_ADC_INJ_Init(ADC_TypeDef *Instance, ADC_INJ_InitTypeDef *ADC_INJ_InitStruct);
  2873. void LL_ADC_MspInit(ADC_TypeDef *Instance);
  2874. void LL_ADC_MspDeInit(ADC_TypeDef *Instance);
  2875. /**
  2876. * @}
  2877. */
  2878. /** @addtogroup ADC_LL_Exported_Functions_Group2
  2879. * @{
  2880. */
  2881. LL_StatusETypeDef LL_ADC_ECU_Config(ADC_TypeDef *Instance, ADC_ECUConfTypeDef *ADC_ECU_Config);
  2882. LL_StatusETypeDef LL_ADC_AnalogWDGConfig(ADC_TypeDef *Instance, ADC_AnalogWDGCfgTypeDef *AnalogWDGConfig);
  2883. LL_StatusETypeDef LL_ADC_DMATransferConfig(ADC_TypeDef *Instance, ADC_DMATransferCfgTypeDef *DMATransferConfig);
  2884. LL_StatusETypeDef LL_ADC_CalibrationConfig(ADC_TypeDef *Instance, ADC_CalibrationTypeDef *CalibrationConfig);
  2885. float LL_ADC_TemperatureCovert(uint16_t voltage_data);
  2886. /**
  2887. * @}
  2888. */
  2889. /** @addtogroup ADC_LL_Exported_Functions_Interrupt
  2890. * @{
  2891. */
  2892. void LL_ADC_AdRdyCallback(ADC_TypeDef *Instance);
  2893. void LL_ADC_EosmpCallback(ADC_TypeDef *Instance);
  2894. void LL_ADC_AnologWD2Callback(ADC_TypeDef *Instance);
  2895. void LL_ADC_AnologWD1Callback(ADC_TypeDef *Instance);
  2896. void LL_ADC_AnologWD0Callback(ADC_TypeDef *Instance);
  2897. void LL_ADC_OverRunCallback(ADC_TypeDef *Instance);
  2898. void LL_ADC_JeosCallback(ADC_TypeDef *Instance);
  2899. void LL_ADC_EosCallback(ADC_TypeDef *Instance);
  2900. void LL_ADC_JeocCallback(ADC_TypeDef *Instance);
  2901. void LL_ADC_EocCallback(ADC_TypeDef *Instance);
  2902. void LL_ADC_SampCallback(ADC_TypeDef *Instance, uint8_t Channel);
  2903. void LL_ADC_HalfCallback(ADC_TypeDef *Instance, uint8_t Channel);
  2904. void LL_ADC_FullCallback(ADC_TypeDef *Instance, uint8_t Channel);
  2905. void LL_ADC_NORM_IRQHandler(ADC_TypeDef *Instance);
  2906. void LL_ADC_SAMP_IRQHandler(ADC_TypeDef *Instance, uint8_t Channel);
  2907. void LL_ADC_HALF_IRQHandler(ADC_TypeDef *Instance, uint8_t Channel);
  2908. void LL_ADC_FULL_IRQHandler(ADC_TypeDef *Instance, uint8_t Channel);
  2909. /**
  2910. * @}
  2911. */
  2912. /**
  2913. * @}
  2914. */
  2915. /* Private constants ---------------------------------------------------------*/
  2916. /* Private variables ---------------------------------------------------------*/
  2917. /* Private types -------------------------------------------------------------*/
  2918. /* Private macros ------------------------------------------------------------*/
  2919. /** @defgroup ADC_LL_Private_Macros ADC LL Private Macros
  2920. * @brief ADC LL Private Macros
  2921. * @{
  2922. */
  2923. /**
  2924. * @brief Judge is ADC synchronization or not
  2925. * @param __SYNCHRONZATION__ synchronization to judge
  2926. * @retval 0 isn't ADC synchronization
  2927. * @retval 1 is ADC synchronization
  2928. */
  2929. #define IS_ADC_SYNCHRONIZATION(__SYNCHRONZATION__) \
  2930. ( ((__SYNCHRONZATION__) == ADC_SYNCEN_DIS) \
  2931. || ((__SYNCHRONZATION__) == ADC_SYNCEN_EN) \
  2932. )
  2933. /**
  2934. * @brief Judge is ADC over samp mode set or not
  2935. * @param __OVER_SAMP_MODE__ over samp mode to judge
  2936. * @retval 0 isn't ADC over samp mode set
  2937. * @retval 1 is ADC over samp mode set
  2938. */
  2939. #define IS_ADC_OVERSAMPMODE_SET(__OVER_SAMP_MODE__) \
  2940. ( ((__OVER_SAMP_MODE__) == ADC_OVS_CONTINUED_MODE) \
  2941. || ((__OVER_SAMP_MODE__) == ADC_OVS_RESUMED_MODE) \
  2942. )
  2943. /**
  2944. * @brief Judge is ADC trig over samp or not
  2945. * @param __TRIG_OVER_SAMP__ trig over samp to judge
  2946. * @retval 0 isn't ADC trig over samp
  2947. * @retval 1 is ADC trig over samp
  2948. */
  2949. #define IS_ADC_TRIGOVERSAMP(__TRIG_OVER_SAMP__) \
  2950. ( ((__TRIG_OVER_SAMP__) == ADC_OVS_TRIG_CONT) \
  2951. || ((__TRIG_OVER_SAMP__) == ADC_OVS_TRIG_DISCONT) \
  2952. )
  2953. /**
  2954. * @brief Judge is ADC over samp shift or not
  2955. * @param __OVER_SAMP_SHIFT__ over samp shift to judge
  2956. * @retval 0 isn't ADC over samp shift
  2957. * @retval 1 is ADC over samp shift
  2958. */
  2959. #define IS_ADC_OVERSAMPSHIFT(__OVER_SAMP_SHIFT__) \
  2960. ( ((__OVER_SAMP_SHIFT__) == ADC_OVSS_SHIFT_NONE) \
  2961. || ((__OVER_SAMP_SHIFT__) == ADC_OVSS_SHIFT_RIGHT_1) \
  2962. || ((__OVER_SAMP_SHIFT__) == ADC_OVSS_SHIFT_RIGHT_2) \
  2963. || ((__OVER_SAMP_SHIFT__) == ADC_OVSS_SHIFT_RIGHT_3) \
  2964. || ((__OVER_SAMP_SHIFT__) == ADC_OVSS_SHIFT_RIGHT_4) \
  2965. || ((__OVER_SAMP_SHIFT__) == ADC_OVSS_SHIFT_RIGHT_5) \
  2966. || ((__OVER_SAMP_SHIFT__) == ADC_OVSS_SHIFT_RIGHT_6) \
  2967. || ((__OVER_SAMP_SHIFT__) == ADC_OVSS_SHIFT_RIGHT_7) \
  2968. || ((__OVER_SAMP_SHIFT__) == ADC_OVSS_SHIFT_RIGHT_8) \
  2969. )
  2970. /**
  2971. * @brief Judge is ADC over samp ratio or not
  2972. * @param __OVER_SAMP_RATIO__ over samp ratio to judge
  2973. * @retval 0 isn't ADC over samp ratio
  2974. * @retval 1 is ADC over samp ratio
  2975. */
  2976. #define IS_ADC_OVERSAMPRATIO(__OVER_SAMP_RATIO__) \
  2977. ( ((__OVER_SAMP_RATIO__) == ADC_OVSR_RATIO_2) \
  2978. || ((__OVER_SAMP_RATIO__) == ADC_OVSR_RATIO_4) \
  2979. || ((__OVER_SAMP_RATIO__) == ADC_OVSR_RATIO_8) \
  2980. || ((__OVER_SAMP_RATIO__) == ADC_OVSR_RATIO_16) \
  2981. || ((__OVER_SAMP_RATIO__) == ADC_OVSR_RATIO_32) \
  2982. || ((__OVER_SAMP_RATIO__) == ADC_OVSR_RATIO_64) \
  2983. || ((__OVER_SAMP_RATIO__) == ADC_OVSR_RATIO_128) \
  2984. || ((__OVER_SAMP_RATIO__) == ADC_OVSR_RATIO_256) \
  2985. )
  2986. /**
  2987. * @brief Judge is ADC anolog set or not
  2988. * @param __ANOLOG_SET__ anolog set to judge
  2989. * @retval 0 isn't ADC anolog set
  2990. * @retval 1 is ADC anolog set
  2991. */
  2992. #define IS_ADC_ANOLOGSET(__ANOLOG_SET__) \
  2993. ( ((__ANOLOG_SET__) == ADC_ANOLOG_CTL_DEFAULT) \
  2994. || ((__ANOLOG_SET__) == ADC_ANOLOG_CTL_A_SH) \
  2995. || ((__ANOLOG_SET__) == ADC_ANOLOG_CTL_A_ADC) \
  2996. || ((__ANOLOG_SET__) == ADC_ANOLOG_CTL_B_SH) \
  2997. || ((__ANOLOG_SET__) == ADC_ANOLOG_CTL_B_ADC) \
  2998. )
  2999. /**
  3000. * @brief Judge is ADC channel or not
  3001. * @param __ADC_CHANNEL__ ADC channel to judge
  3002. * @retval 0 isn't ADC channel
  3003. * @retval 1 is ADC channel
  3004. */
  3005. #define IS_ADC_CHANNEL(__ADC_CHANNEL__) \
  3006. ( ((__ADC_CHANNEL__) == ADC_CHANNEL_0) \
  3007. || ((__ADC_CHANNEL__) == ADC_CHANNEL_1) \
  3008. || ((__ADC_CHANNEL__) == ADC_CHANNEL_2) \
  3009. || ((__ADC_CHANNEL__) == ADC_CHANNEL_3) \
  3010. || ((__ADC_CHANNEL__) == ADC_CHANNEL_4) \
  3011. || ((__ADC_CHANNEL__) == ADC_CHANNEL_5) \
  3012. || ((__ADC_CHANNEL__) == ADC_CHANNEL_6) \
  3013. || ((__ADC_CHANNEL__) == ADC_CHANNEL_7) \
  3014. || ((__ADC_CHANNEL__) == ADC_CHANNEL_8) \
  3015. || ((__ADC_CHANNEL__) == ADC_CHANNEL_9) \
  3016. || ((__ADC_CHANNEL__) == ADC_CHANNEL_10) \
  3017. || ((__ADC_CHANNEL__) == ADC_CHANNEL_TEMPSENSOR) \
  3018. )
  3019. /**
  3020. * @brief Judge is ADC reg trig source or not
  3021. * @param __REG_TRIG_SOURCE__ reg trig source to judge
  3022. * @retval 0 isn't ADC reg trig source
  3023. * @retval 1 is ADC reg trig source
  3024. */
  3025. #define IS_ADC_REG_TRIG_SOURCE( __REG_TRIG_SOURCE__) \
  3026. ( ((__REG_TRIG_SOURCE__) == ADC_REG_TRIG_SOFTWARE) \
  3027. || (((__REG_TRIG_SOURCE__) & (ADC_LR_EXTSEL_Msk | ADC_LR_EXTEN_Msk)) != 0x00U) \
  3028. )
  3029. /**
  3030. * @brief Judge is ADC reg continuous mode or not
  3031. * @param __REG_CONTINUOUS_MODE__ reg continuous mode to judge
  3032. * @retval 0 isn't ADC reg continuous mode
  3033. * @retval 1 is ADC reg continuous mode
  3034. */
  3035. #define IS_ADC_REG_CONTINUOUS_MODE(__REG_CONTINUOUS_MODE__) \
  3036. ( ((__REG_CONTINUOUS_MODE__) == ADC_REG_CONV_SINGLE) \
  3037. || ((__REG_CONTINUOUS_MODE__) == ADC_REG_CONV_CONTINUOUS) \
  3038. )
  3039. /**
  3040. * @brief Judge is ADC reg seq discont or not
  3041. * @param __REG_DISCONT_MODE__ reg seq discont to judge
  3042. * @retval 0 isn't ADC reg seq discont
  3043. * @retval 1 is ADC reg seq discont
  3044. */
  3045. #define IS_ADC_REG_SEQ_DISCONT(__REG_DISCONT_MODE__) \
  3046. ( ((__REG_DISCONT_MODE__) == ADC_REG_SEQ_DISCON_DISABLE) \
  3047. || ((__REG_DISCONT_MODE__) == ADC_REG_SEQ_DISNUM_1RANK) \
  3048. || ((__REG_DISCONT_MODE__) == ADC_REG_SEQ_DISNUM_2RANKS) \
  3049. || ((__REG_DISCONT_MODE__) == ADC_REG_SEQ_DISNUM_3RANKS) \
  3050. || ((__REG_DISCONT_MODE__) == ADC_REG_SEQ_DISNUM_4RANKS) \
  3051. || ((__REG_DISCONT_MODE__) == ADC_REG_SEQ_DISNUM_5RANKS) \
  3052. || ((__REG_DISCONT_MODE__) == ADC_REG_SEQ_DISNUM_6RANKS) \
  3053. || ((__REG_DISCONT_MODE__) == ADC_REG_SEQ_DISNUM_7RANKS) \
  3054. || ((__REG_DISCONT_MODE__) == ADC_REG_SEQ_DISNUM_8RANKS) \
  3055. )
  3056. /**
  3057. * @brief Judge is ADC reg differ sel or not
  3058. * @param __DIFSEL_MODE__ differ sel mode to judge
  3059. * @retval 0 isn't ADC reg differ sel
  3060. * @retval 1 is ADC reg differ sel
  3061. */
  3062. #define IS_ADC_REG_DIFFERSEL(__DIFSEL_MODE__) \
  3063. ( ((__DIFSEL_MODE__) == ADC_DIFSEL_DIFFER) \
  3064. || ((__DIFSEL_MODE__) == ADC_DIFSEL_SINGLE) \
  3065. )
  3066. /**
  3067. * @brief Judge is ADC reg samp time clock or not
  3068. * @param __REG_SAMPTIMCLK__ reg samp time clock to judge
  3069. * @retval 0 isn't ADC reg samp time clock
  3070. * @retval 1 is ADC reg samp time clock
  3071. */
  3072. #define IS_ADC_REG_SAMPTIMCLK(__REG_SAMPTIMCLK__) \
  3073. ( ((__REG_SAMPTIMCLK__) == ADC_SAMPLINGTIME_6CYCLES) \
  3074. || (((__REG_SAMPTIMCLK__) & ADC_SMPR0_SMP0_Msk) != 0x00U) \
  3075. )
  3076. /**
  3077. * @brief Judge is ADC LL cal coef sel or not
  3078. * @param __CALCOEFSEL__ cal coef sel to judge
  3079. * @retval 0 isn't ADC LL cal coef sel
  3080. * @retval 1 is ADC LL cal coef sel
  3081. */
  3082. #define IS_LL_ADC_CALCOEFSEL(__CALCOEFSEL__) \
  3083. ( ((__CALCOEFSEL__) == ADC_CALIB_GROUP0) \
  3084. || ((__CALCOEFSEL__) == ADC_CALIB_GROUP1) \
  3085. || ((__CALCOEFSEL__) == ADC_CALIB_GROUP2) \
  3086. || ((__CALCOEFSEL__) == ADC_CALIB_GROUP3) \
  3087. )
  3088. /**
  3089. * @brief Judge is ADC over data behavior or not
  3090. * @param __REG_OVR_DATA_BEHAVIOR__ over data behavior to judge
  3091. * @retval 0 isn't ADC over data behavior
  3092. * @retval 1 is ADC over data behavior
  3093. */
  3094. #define IS_ADC_OVR_DATA_BEHAVIOR(__REG_OVR_DATA_BEHAVIOR__) \
  3095. ( ((__REG_OVR_DATA_BEHAVIOR__) == ADC_OVR_DATA_PRESERVED) \
  3096. || ((__REG_OVR_DATA_BEHAVIOR__) == ADC_OVR_DATA_OVERWRITTEN) \
  3097. )
  3098. /**
  3099. * @brief Judge is ADC reg dma transfer or not
  3100. * @param __REG_DMA_TRANSFER__ reg dma transfer to judge
  3101. * @retval 0 isn't ADC reg dma transfer
  3102. * @retval 1 is ADC reg dma transfer
  3103. */
  3104. #define IS_ADC_REG_DMA_TRANSFER(__REG_DMA_TRANSFER__) \
  3105. ( ((__REG_DMA_TRANSFER__) == ADC_REG_DMA_TRANSFER_SINGLE) \
  3106. || ((__REG_DMA_TRANSFER__) == ADC_REG_DMA_TRANSFER_CIRCLE) \
  3107. || ((__REG_DMA_TRANSFER__) == ADC_REG_DMA_TRANSFER_DISABLE) \
  3108. )
  3109. /**
  3110. * @brief Judge is ADC reg awd filter or not
  3111. * @param __REG_AWD_FILTER__ reg awd filter to judge
  3112. * @retval 0 isn't ADC reg awd filter
  3113. * @retval 1 is ADC reg awd filter
  3114. */
  3115. #define IS_ADC_REG_AWD_FILTER(__REG_AWD_FILTER__) \
  3116. ( (((__REG_AWD_FILTER__) & ADC_AWD0CR_AWD0FILT_Msk) != 0x00U) \
  3117. || ((__REG_AWD_FILTER__) == ADC_AWD_FILTERING_NONE) \
  3118. )
  3119. /**
  3120. * @brief Judge is ADC reg awd sel or not
  3121. * @param __REG_AWD_SEL__ reg awd sel to judge
  3122. * @retval 0 isn't ADC reg awd sel
  3123. * @retval 1 is ADC reg awd sel
  3124. */
  3125. #define IS_ADC_REG_AWD_SEL(__REG_AWD_SEL__) \
  3126. ( ((__REG_AWD_SEL__) == ADC_AWD2) \
  3127. || ((__REG_AWD_SEL__) == ADC_AWD0) \
  3128. || ((__REG_AWD_SEL__) == ADC_AWD1) \
  3129. )
  3130. /**
  3131. * @brief Judge is ADC awd channel or not
  3132. * @param __AWD_CHANNEL__ awd channel to judge
  3133. * @retval 0 isn't ADC awd channel
  3134. * @retval 1 is ADC awd channel
  3135. */
  3136. #define IS_ADC_AWD_CHANNEL(__AWD_CHANNEL__) \
  3137. ( (((__AWD_CHANNEL__) & ADC_AWD0CR_AWD0CH_Msk) != 0x00U) \
  3138. || (((__AWD_CHANNEL__) & (ADC_AWD0CR_AWD0CH_Msk)) == 0x00U) \
  3139. )
  3140. /**
  3141. * @brief Judge is ADC reg seq length or not
  3142. * @param __REG_SEQ_LENGTH__ reg seq length to judge
  3143. * @retval 0 isn't ADC reg seq length
  3144. * @retval 1 is ADC reg seq length
  3145. */
  3146. #define IS_ADC_REG_SEQ_LENGTH(__REG_SEQ_LENGTH__) \
  3147. ( ((__REG_SEQ_LENGTH__) == ADC_REG_SEQ_LENGTH_1) \
  3148. || (((__REG_SEQ_LENGTH__) & ADC_LR_LEN_Msk) != 0x00U) \
  3149. )
  3150. /**
  3151. * @brief Judge is ADC reg seq pos or not
  3152. * @param __REG_SEQ_POS_ reg seq pos to judge
  3153. * @retval 0 isn't ADC reg seq pos
  3154. * @retval 1 is ADC reg seq pos
  3155. */
  3156. #define IS_ADC_REG_SEQ_POS(__REG_SEQ_POS_) \
  3157. ( ((__REG_SEQ_POS_) == ADC_REG_RANK_1) \
  3158. || ((__REG_SEQ_POS_) == ADC_REG_RANK_2) \
  3159. || ((__REG_SEQ_POS_) == ADC_REG_RANK_3) \
  3160. || ((__REG_SEQ_POS_) == ADC_REG_RANK_4) \
  3161. || ((__REG_SEQ_POS_) == ADC_REG_RANK_5) \
  3162. || ((__REG_SEQ_POS_) == ADC_REG_RANK_6) \
  3163. || ((__REG_SEQ_POS_) == ADC_REG_RANK_7) \
  3164. || ((__REG_SEQ_POS_) == ADC_REG_RANK_8) \
  3165. || ((__REG_SEQ_POS_) == ADC_REG_RANK_9) \
  3166. || ((__REG_SEQ_POS_) == ADC_REG_RANK_10) \
  3167. || ((__REG_SEQ_POS_) == ADC_REG_RANK_11) \
  3168. || ((__REG_SEQ_POS_) == ADC_REG_RANK_12) \
  3169. || ((__REG_SEQ_POS_) == ADC_REG_RANK_13) \
  3170. || ((__REG_SEQ_POS_) == ADC_REG_RANK_14) \
  3171. || ((__REG_SEQ_POS_) == ADC_REG_RANK_15) \
  3172. || ((__REG_SEQ_POS_) == ADC_REG_RANK_16) \
  3173. )
  3174. /**
  3175. * @brief Judge is ADC reg seq discont mode or not
  3176. * @param __REG_SEQ_DISCONT_MODE__ reg seq discont mode to judge
  3177. * @retval 0 isn't ADC reg seq discont mode
  3178. * @retval 1 is ADC reg seq discont mode
  3179. */
  3180. #define IS_ADC_REG_SEQ_DISCONT_MODE(__REG_SEQ_DISCONT_MODE__) \
  3181. ( ((__REG_SEQ_DISCONT_MODE__) == ADC_REG_SEQ_DISCON_DISABLE) \
  3182. || ((__REG_SEQ_DISCONT_MODE__) == ADC_REG_SEQ_DISNUM_1RANK) \
  3183. || ((__REG_SEQ_DISCONT_MODE__) == ADC_REG_SEQ_DISNUM_2RANKS) \
  3184. || ((__REG_SEQ_DISCONT_MODE__) == ADC_REG_SEQ_DISNUM_3RANKS) \
  3185. || ((__REG_SEQ_DISCONT_MODE__) == ADC_REG_SEQ_DISNUM_4RANKS) \
  3186. || ((__REG_SEQ_DISCONT_MODE__) == ADC_REG_SEQ_DISNUM_5RANKS) \
  3187. || ((__REG_SEQ_DISCONT_MODE__) == ADC_REG_SEQ_DISNUM_6RANKS) \
  3188. || ((__REG_SEQ_DISCONT_MODE__) == ADC_REG_SEQ_DISNUM_7RANKS) \
  3189. || ((__REG_SEQ_DISCONT_MODE__) == ADC_REG_SEQ_DISNUM_8RANKS) \
  3190. )
  3191. /**
  3192. * @brief Judge is ADC inj trig source or not
  3193. * @param __INJ_TRIG_SOURCE__ inj trig source to judge
  3194. * @retval 0 isn't ADC inj trig source
  3195. * @retval 1 is ADC inj trig source
  3196. */
  3197. #define IS_ADC_INJ_TRIG_SOURCE( __INJ_TRIG_SOURCE__) \
  3198. ( ((__INJ_TRIG_SOURCE__) == ADC_INJ_TRIG_SOFTWARE) \
  3199. || (((__INJ_TRIG_SOURCE__) & (ADC_JLR_JEXTSEL_Msk | ADC_JLR_JEXTEN_Msk)) != 0x00U) \
  3200. )
  3201. /**
  3202. * @brief Judge is ADC inj trig ext edge or not
  3203. * @param __INJ_TRIG_EXT_EDGE__ inj trig ext edge to judge
  3204. * @retval 0 isn't ADC inj trig ext edge
  3205. * @retval 1 is ADC inj trig ext edge
  3206. */
  3207. #define IS_ADC_INJ_TRIG_EXT_EDGE(__INJ_TRIG_EXT_EDGE__) \
  3208. ( ((__INJ_TRIG_EXT_EDGE__) == ADC_INJ_TRIG_EXT_RISING) \
  3209. || ((__INJ_TRIG_EXT_EDGE__) == ADC_INJ_TRIG_EXT_FALLING) \
  3210. || ((__INJ_TRIG_EXT_EDGE__) == ADC_INJ_TRIG_EXT_RISINGFALLING) \
  3211. )
  3212. /**
  3213. * @brief Judge is ADC inj trig auto or not
  3214. * @param __INJ_TRIG_AUTO__ inj trig auto to judge
  3215. * @retval 0 isn't ADC inj trig auto
  3216. * @retval 1 is ADC inj trig auto
  3217. */
  3218. #define IS_ADC_INJ_TRIG_AUTO(__INJ_TRIG_AUTO__) \
  3219. ( ((__INJ_TRIG_AUTO__) == ADC_INJ_TRIG_INDEPENDENT) \
  3220. || ((__INJ_TRIG_AUTO__) == ADC_INJ_TRIG_FROM_GRP_REGULAR) \
  3221. )
  3222. /**
  3223. * @brief Judge is ADC inj seq scan length or not
  3224. * @param __INJ_SEQ_LENGTH__ inj seq scan length to judge
  3225. * @retval 0 isn't ADC inj seq scan length
  3226. * @retval 1 is ADC inj seq scan length
  3227. */
  3228. #define IS_ADC_INJ_SEQ_SCAN_LENGTH(__INJ_SEQ_LENGTH__) \
  3229. ( ((__INJ_SEQ_LENGTH__) == ADC_INJ_SEQ_LENGTH_1) \
  3230. || ((__INJ_SEQ_LENGTH__) == ADC_INJ_SEQ_LENGTH_2) \
  3231. || ((__INJ_SEQ_LENGTH__) == ADC_INJ_SEQ_LENGTH_3) \
  3232. || ((__INJ_SEQ_LENGTH__) == ADC_INJ_SEQ_LENGTH_4) \
  3233. )
  3234. /**
  3235. * @brief Judge is ADC inj jseq pos or not
  3236. * @param __INJ_SEQ_LENGTH__ inj jseq pos to judge
  3237. * @retval 0 isn't ADC inj jseq pos
  3238. * @retval 1 is ADC inj jseq pos
  3239. */
  3240. #define IS_ADC_INJ_JSEQ_POS(__INJ_SEQ_LENGTH__) \
  3241. ( ((__INJ_SEQ_LENGTH__) == ADC_INJ_RANK_1) \
  3242. || ((__INJ_SEQ_LENGTH__) == ADC_INJ_RANK_2) \
  3243. || ((__INJ_SEQ_LENGTH__) == ADC_INJ_RANK_3) \
  3244. || ((__INJ_SEQ_LENGTH__) == ADC_INJ_RANK_4) \
  3245. )
  3246. /**
  3247. * @brief Judge is ADC inj seq scan discont mode or not
  3248. * @param __INJ_SEQ_DISCONT_MODE__ inj seq scan discont mode to judge
  3249. * @retval 0 isn't ADC inj seq scan discont mode
  3250. * @retval 1 is ADC inj seq scan discont mode
  3251. */
  3252. #define IS_ADC_INJ_SEQ_SCAN_DISCONT_MODE(__INJ_SEQ_DISCONT_MODE__) \
  3253. ( ((__INJ_SEQ_DISCONT_MODE__) == ADC_INJ_SEQ_DISCONT_DISABLE) \
  3254. || ((__INJ_SEQ_DISCONT_MODE__) == ADC_INJ_SEQ_DISCONT_ENABLE) \
  3255. )
  3256. /**
  3257. * @brief Judge is ADC ECU group sel or not
  3258. * @param __ECU_GROUP_SEL__ ECU group sel to judge
  3259. * @retval 0 isn't ADC ECU group sel
  3260. * @retval 1 is ADC ECU group sel
  3261. */
  3262. #define IS_ADC_ECU_GROUPSEL(__ECU_GROUP_SEL__) \
  3263. ( ((__ECU_GROUP_SEL__) == ADC_CALIB_GROUP0) \
  3264. || ((__ECU_GROUP_SEL__) == ADC_CALIB_GROUP1) \
  3265. || ((__ECU_GROUP_SEL__) == ADC_CALIB_GROUP2) \
  3266. || ((__ECU_GROUP_SEL__) == ADC_CALIB_GROUP3) \
  3267. )
  3268. /**
  3269. * @}
  3270. */
  3271. /* Private functions ---------------------------------------------------------*/
  3272. /**
  3273. * @}
  3274. */
  3275. /**
  3276. * @}
  3277. */
  3278. #ifdef __cplusplus
  3279. }
  3280. #endif /* __cplusplus */
  3281. #endif /* _TAE32F53XX_LL_ADC_H_ */
  3282. /************************* (C) COPYRIGHT Tai-Action *****END OF FILE***********/