stm32f1xx_ll_adc.h 224 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948
  1. /**
  2. ******************************************************************************
  3. * @file stm32f1xx_ll_adc.h
  4. * @author MCD Application Team
  5. * @brief Header file of ADC LL module.
  6. ******************************************************************************
  7. * @attention
  8. *
  9. * <h2><center>&copy; COPYRIGHT(c) 2017 STMicroelectronics</center></h2>
  10. *
  11. * Redistribution and use in source and binary forms, with or without modification,
  12. * are permitted provided that the following conditions are met:
  13. * 1. Redistributions of source code must retain the above copyright notice,
  14. * this list of conditions and the following disclaimer.
  15. * 2. Redistributions in binary form must reproduce the above copyright notice,
  16. * this list of conditions and the following disclaimer in the documentation
  17. * and/or other materials provided with the distribution.
  18. * 3. Neither the name of STMicroelectronics nor the names of its contributors
  19. * may be used to endorse or promote products derived from this software
  20. * without specific prior written permission.
  21. *
  22. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  23. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  24. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  25. * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
  26. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  27. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  28. * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  29. * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  30. * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  31. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  32. *
  33. ******************************************************************************
  34. */
  35. /* Define to prevent recursive inclusion -------------------------------------*/
  36. #ifndef __STM32F1xx_LL_ADC_H
  37. #define __STM32F1xx_LL_ADC_H
  38. #ifdef __cplusplus
  39. extern "C" {
  40. #endif
  41. /* Includes ------------------------------------------------------------------*/
  42. #include "stm32f1xx.h"
  43. /** @addtogroup STM32F1xx_LL_Driver
  44. * @{
  45. */
  46. #if defined (ADC1) || defined (ADC2) || defined (ADC3)
  47. /** @defgroup ADC_LL ADC
  48. * @{
  49. */
  50. /* Private types -------------------------------------------------------------*/
  51. /* Private variables ---------------------------------------------------------*/
  52. /* Private constants ---------------------------------------------------------*/
  53. /** @defgroup ADC_LL_Private_Constants ADC Private Constants
  54. * @{
  55. */
  56. /* Internal mask for ADC group regular sequencer: */
  57. /* To select into literal LL_ADC_REG_RANK_x the relevant bits for: */
  58. /* - sequencer register offset */
  59. /* - sequencer rank bits position into the selected register */
  60. /* Internal register offset for ADC group regular sequencer configuration */
  61. /* (offset placed into a spare area of literal definition) */
  62. #define ADC_SQR1_REGOFFSET 0x00000000U
  63. #define ADC_SQR2_REGOFFSET 0x00000100U
  64. #define ADC_SQR3_REGOFFSET 0x00000200U
  65. #define ADC_SQR4_REGOFFSET 0x00000300U
  66. #define ADC_REG_SQRX_REGOFFSET_MASK (ADC_SQR1_REGOFFSET | ADC_SQR2_REGOFFSET | ADC_SQR3_REGOFFSET | ADC_SQR4_REGOFFSET)
  67. #define ADC_REG_RANK_ID_SQRX_MASK (ADC_CHANNEL_ID_NUMBER_MASK_POSBIT0)
  68. /* Definition of ADC group regular sequencer bits information to be inserted */
  69. /* into ADC group regular sequencer ranks literals definition. */
  70. #define ADC_REG_RANK_1_SQRX_BITOFFSET_POS ( 0U) /* Value equivalent to POSITION_VAL(ADC_SQR3_SQ1) */
  71. #define ADC_REG_RANK_2_SQRX_BITOFFSET_POS ( 5U) /* Value equivalent to POSITION_VAL(ADC_SQR3_SQ2) */
  72. #define ADC_REG_RANK_3_SQRX_BITOFFSET_POS (10U) /* Value equivalent to POSITION_VAL(ADC_SQR3_SQ3) */
  73. #define ADC_REG_RANK_4_SQRX_BITOFFSET_POS (15U) /* Value equivalent to POSITION_VAL(ADC_SQR3_SQ4) */
  74. #define ADC_REG_RANK_5_SQRX_BITOFFSET_POS (20U) /* Value equivalent to POSITION_VAL(ADC_SQR3_SQ5) */
  75. #define ADC_REG_RANK_6_SQRX_BITOFFSET_POS (25U) /* Value equivalent to POSITION_VAL(ADC_SQR3_SQ6) */
  76. #define ADC_REG_RANK_7_SQRX_BITOFFSET_POS ( 0U) /* Value equivalent to POSITION_VAL(ADC_SQR2_SQ7) */
  77. #define ADC_REG_RANK_8_SQRX_BITOFFSET_POS ( 5U) /* Value equivalent to POSITION_VAL(ADC_SQR2_SQ8) */
  78. #define ADC_REG_RANK_9_SQRX_BITOFFSET_POS (10U) /* Value equivalent to POSITION_VAL(ADC_SQR2_SQ9) */
  79. #define ADC_REG_RANK_10_SQRX_BITOFFSET_POS (15U) /* Value equivalent to POSITION_VAL(ADC_SQR2_SQ10) */
  80. #define ADC_REG_RANK_11_SQRX_BITOFFSET_POS (20U) /* Value equivalent to POSITION_VAL(ADC_SQR2_SQ11) */
  81. #define ADC_REG_RANK_12_SQRX_BITOFFSET_POS (25U) /* Value equivalent to POSITION_VAL(ADC_SQR2_SQ12) */
  82. #define ADC_REG_RANK_13_SQRX_BITOFFSET_POS ( 0U) /* Value equivalent to POSITION_VAL(ADC_SQR1_SQ13) */
  83. #define ADC_REG_RANK_14_SQRX_BITOFFSET_POS ( 5U) /* Value equivalent to POSITION_VAL(ADC_SQR1_SQ14) */
  84. #define ADC_REG_RANK_15_SQRX_BITOFFSET_POS (10U) /* Value equivalent to POSITION_VAL(ADC_SQR1_SQ15) */
  85. #define ADC_REG_RANK_16_SQRX_BITOFFSET_POS (15U) /* Value equivalent to POSITION_VAL(ADC_SQR1_SQ16) */
  86. /* Internal mask for ADC group injected sequencer: */
  87. /* To select into literal LL_ADC_INJ_RANK_x the relevant bits for: */
  88. /* - data register offset */
  89. /* - offset register offset */
  90. /* - sequencer rank bits position into the selected register */
  91. /* Internal register offset for ADC group injected data register */
  92. /* (offset placed into a spare area of literal definition) */
  93. #define ADC_JDR1_REGOFFSET 0x00000000U
  94. #define ADC_JDR2_REGOFFSET 0x00000100U
  95. #define ADC_JDR3_REGOFFSET 0x00000200U
  96. #define ADC_JDR4_REGOFFSET 0x00000300U
  97. /* Internal register offset for ADC group injected offset configuration */
  98. /* (offset placed into a spare area of literal definition) */
  99. #define ADC_JOFR1_REGOFFSET 0x00000000U
  100. #define ADC_JOFR2_REGOFFSET 0x00001000U
  101. #define ADC_JOFR3_REGOFFSET 0x00002000U
  102. #define ADC_JOFR4_REGOFFSET 0x00003000U
  103. #define ADC_INJ_JDRX_REGOFFSET_MASK (ADC_JDR1_REGOFFSET | ADC_JDR2_REGOFFSET | ADC_JDR3_REGOFFSET | ADC_JDR4_REGOFFSET)
  104. #define ADC_INJ_JOFRX_REGOFFSET_MASK (ADC_JOFR1_REGOFFSET | ADC_JOFR2_REGOFFSET | ADC_JOFR3_REGOFFSET | ADC_JOFR4_REGOFFSET)
  105. #define ADC_INJ_RANK_ID_JSQR_MASK (ADC_CHANNEL_ID_NUMBER_MASK_POSBIT0)
  106. /* Internal mask for ADC channel: */
  107. /* To select into literal LL_ADC_CHANNEL_x the relevant bits for: */
  108. /* - channel identifier defined by number */
  109. /* - channel differentiation between external channels (connected to */
  110. /* GPIO pins) and internal channels (connected to internal paths) */
  111. /* - channel sampling time defined by SMPRx register offset */
  112. /* and SMPx bits positions into SMPRx register */
  113. #define ADC_CHANNEL_ID_NUMBER_MASK (ADC_CR1_AWDCH)
  114. #define ADC_CHANNEL_ID_NUMBER_BITOFFSET_POS ( 0U)/* Value equivalent to POSITION_VAL(ADC_CHANNEL_ID_NUMBER_MASK) */
  115. #define ADC_CHANNEL_ID_MASK (ADC_CHANNEL_ID_NUMBER_MASK | ADC_CHANNEL_ID_INTERNAL_CH_MASK)
  116. /* Equivalent mask of ADC_CHANNEL_NUMBER_MASK aligned on register LSB (bit 0) */
  117. #define ADC_CHANNEL_ID_NUMBER_MASK_POSBIT0 0x0000001FU /* Equivalent to shift: (ADC_CHANNEL_NUMBER_MASK >> POSITION_VAL(ADC_CHANNEL_NUMBER_MASK)) */
  118. /* Channel differentiation between external and internal channels */
  119. #define ADC_CHANNEL_ID_INTERNAL_CH 0x80000000U /* Marker of internal channel */
  120. #define ADC_CHANNEL_ID_INTERNAL_CH_2 0x40000000U /* Marker of internal channel for other ADC instances, in case of different ADC internal channels mapped on same channel number on different ADC instances */
  121. #define ADC_CHANNEL_ID_INTERNAL_CH_MASK (ADC_CHANNEL_ID_INTERNAL_CH | ADC_CHANNEL_ID_INTERNAL_CH_2)
  122. /* Internal register offset for ADC channel sampling time configuration */
  123. /* (offset placed into a spare area of literal definition) */
  124. #define ADC_SMPR1_REGOFFSET 0x00000000U
  125. #define ADC_SMPR2_REGOFFSET 0x02000000U
  126. #define ADC_CHANNEL_SMPRX_REGOFFSET_MASK (ADC_SMPR1_REGOFFSET | ADC_SMPR2_REGOFFSET)
  127. #define ADC_CHANNEL_SMPx_BITOFFSET_MASK 0x01F00000U
  128. #define ADC_CHANNEL_SMPx_BITOFFSET_POS (20U) /* Value equivalent to POSITION_VAL(ADC_CHANNEL_SMPx_BITOFFSET_MASK) */
  129. /* Definition of channels ID number information to be inserted into */
  130. /* channels literals definition. */
  131. #define ADC_CHANNEL_0_NUMBER 0x00000000U
  132. #define ADC_CHANNEL_1_NUMBER ( ADC_CR1_AWDCH_0)
  133. #define ADC_CHANNEL_2_NUMBER ( ADC_CR1_AWDCH_1 )
  134. #define ADC_CHANNEL_3_NUMBER ( ADC_CR1_AWDCH_1 | ADC_CR1_AWDCH_0)
  135. #define ADC_CHANNEL_4_NUMBER ( ADC_CR1_AWDCH_2 )
  136. #define ADC_CHANNEL_5_NUMBER ( ADC_CR1_AWDCH_2 | ADC_CR1_AWDCH_0)
  137. #define ADC_CHANNEL_6_NUMBER ( ADC_CR1_AWDCH_2 | ADC_CR1_AWDCH_1 )
  138. #define ADC_CHANNEL_7_NUMBER ( ADC_CR1_AWDCH_2 | ADC_CR1_AWDCH_1 | ADC_CR1_AWDCH_0)
  139. #define ADC_CHANNEL_8_NUMBER ( ADC_CR1_AWDCH_3 )
  140. #define ADC_CHANNEL_9_NUMBER ( ADC_CR1_AWDCH_3 | ADC_CR1_AWDCH_0)
  141. #define ADC_CHANNEL_10_NUMBER ( ADC_CR1_AWDCH_3 | ADC_CR1_AWDCH_1 )
  142. #define ADC_CHANNEL_11_NUMBER ( ADC_CR1_AWDCH_3 | ADC_CR1_AWDCH_1 | ADC_CR1_AWDCH_0)
  143. #define ADC_CHANNEL_12_NUMBER ( ADC_CR1_AWDCH_3 | ADC_CR1_AWDCH_2 )
  144. #define ADC_CHANNEL_13_NUMBER ( ADC_CR1_AWDCH_3 | ADC_CR1_AWDCH_2 | ADC_CR1_AWDCH_0)
  145. #define ADC_CHANNEL_14_NUMBER ( ADC_CR1_AWDCH_3 | ADC_CR1_AWDCH_2 | ADC_CR1_AWDCH_1 )
  146. #define ADC_CHANNEL_15_NUMBER ( ADC_CR1_AWDCH_3 | ADC_CR1_AWDCH_2 | ADC_CR1_AWDCH_1 | ADC_CR1_AWDCH_0)
  147. #define ADC_CHANNEL_16_NUMBER (ADC_CR1_AWDCH_4 )
  148. #define ADC_CHANNEL_17_NUMBER (ADC_CR1_AWDCH_4 | ADC_CR1_AWDCH_0)
  149. /* Definition of channels sampling time information to be inserted into */
  150. /* channels literals definition. */
  151. #define ADC_CHANNEL_0_SMP (ADC_SMPR2_REGOFFSET | (( 0U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR2_SMP0) */
  152. #define ADC_CHANNEL_1_SMP (ADC_SMPR2_REGOFFSET | (( 3U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR2_SMP1) */
  153. #define ADC_CHANNEL_2_SMP (ADC_SMPR2_REGOFFSET | (( 6U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR2_SMP2) */
  154. #define ADC_CHANNEL_3_SMP (ADC_SMPR2_REGOFFSET | (( 9U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR2_SMP3) */
  155. #define ADC_CHANNEL_4_SMP (ADC_SMPR2_REGOFFSET | ((12U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR2_SMP4) */
  156. #define ADC_CHANNEL_5_SMP (ADC_SMPR2_REGOFFSET | ((15U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR2_SMP5) */
  157. #define ADC_CHANNEL_6_SMP (ADC_SMPR2_REGOFFSET | ((18U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR2_SMP6) */
  158. #define ADC_CHANNEL_7_SMP (ADC_SMPR2_REGOFFSET | ((21U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR2_SMP7) */
  159. #define ADC_CHANNEL_8_SMP (ADC_SMPR2_REGOFFSET | ((24U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR2_SMP8) */
  160. #define ADC_CHANNEL_9_SMP (ADC_SMPR2_REGOFFSET | ((27U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR2_SMP9) */
  161. #define ADC_CHANNEL_10_SMP (ADC_SMPR1_REGOFFSET | (( 0U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR1_SMP10) */
  162. #define ADC_CHANNEL_11_SMP (ADC_SMPR1_REGOFFSET | (( 3U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR1_SMP11) */
  163. #define ADC_CHANNEL_12_SMP (ADC_SMPR1_REGOFFSET | (( 6U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR1_SMP12) */
  164. #define ADC_CHANNEL_13_SMP (ADC_SMPR1_REGOFFSET | (( 9U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR1_SMP13) */
  165. #define ADC_CHANNEL_14_SMP (ADC_SMPR1_REGOFFSET | ((12U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR1_SMP14) */
  166. #define ADC_CHANNEL_15_SMP (ADC_SMPR1_REGOFFSET | ((15U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR1_SMP15) */
  167. #define ADC_CHANNEL_16_SMP (ADC_SMPR1_REGOFFSET | ((18U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR1_SMP16) */
  168. #define ADC_CHANNEL_17_SMP (ADC_SMPR1_REGOFFSET | ((21U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR1_SMP17) */
  169. /* Internal mask for ADC analog watchdog: */
  170. /* To select into literals LL_ADC_AWD_CHANNELx_xxx the relevant bits for: */
  171. /* (concatenation of multiple bits used in different analog watchdogs, */
  172. /* (feature of several watchdogs not available on all STM32 families)). */
  173. /* - analog watchdog 1: monitored channel defined by number, */
  174. /* selection of ADC group (ADC groups regular and-or injected). */
  175. /* Internal register offset for ADC analog watchdog channel configuration */
  176. #define ADC_AWD_CR1_REGOFFSET 0x00000000U
  177. #define ADC_AWD_CRX_REGOFFSET_MASK (ADC_AWD_CR1_REGOFFSET)
  178. #define ADC_AWD_CR1_CHANNEL_MASK (ADC_CR1_AWDCH | ADC_CR1_JAWDEN | ADC_CR1_AWDEN | ADC_CR1_AWDSGL)
  179. #define ADC_AWD_CR_ALL_CHANNEL_MASK (ADC_AWD_CR1_CHANNEL_MASK)
  180. /* Internal register offset for ADC analog watchdog threshold configuration */
  181. #define ADC_AWD_TR1_HIGH_REGOFFSET 0x00000000U
  182. #define ADC_AWD_TR1_LOW_REGOFFSET 0x00000001U
  183. #define ADC_AWD_TRX_REGOFFSET_MASK (ADC_AWD_TR1_HIGH_REGOFFSET | ADC_AWD_TR1_LOW_REGOFFSET)
  184. /* ADC registers bits positions */
  185. #define ADC_CR1_DUALMOD_BITOFFSET_POS (16U) /* Value equivalent to POSITION_VAL(ADC_CR1_DUALMOD) */
  186. /**
  187. * @}
  188. */
  189. /* Private macros ------------------------------------------------------------*/
  190. /** @defgroup ADC_LL_Private_Macros ADC Private Macros
  191. * @{
  192. */
  193. /**
  194. * @brief Driver macro reserved for internal use: isolate bits with the
  195. * selected mask and shift them to the register LSB
  196. * (shift mask on register position bit 0).
  197. * @param __BITS__ Bits in register 32 bits
  198. * @param __MASK__ Mask in register 32 bits
  199. * @retval Bits in register 32 bits
  200. */
  201. #define __ADC_MASK_SHIFT(__BITS__, __MASK__) \
  202. (((__BITS__) & (__MASK__)) >> POSITION_VAL((__MASK__)))
  203. /**
  204. * @brief Driver macro reserved for internal use: set a pointer to
  205. * a register from a register basis from which an offset
  206. * is applied.
  207. * @param __REG__ Register basis from which the offset is applied.
  208. * @param __REG_OFFFSET__ Offset to be applied (unit: number of registers).
  209. * @retval Pointer to register address
  210. */
  211. #define __ADC_PTR_REG_OFFSET(__REG__, __REG_OFFFSET__) \
  212. ((uint32_t *)((uint32_t) ((uint32_t)(&(__REG__)) + ((__REG_OFFFSET__) << 2U))))
  213. /**
  214. * @}
  215. */
  216. /* Exported types ------------------------------------------------------------*/
  217. #if defined(USE_FULL_LL_DRIVER)
  218. /** @defgroup ADC_LL_ES_INIT ADC Exported Init structure
  219. * @{
  220. */
  221. /**
  222. * @brief Structure definition of some features of ADC common parameters
  223. * and multimode
  224. * (all ADC instances belonging to the same ADC common instance).
  225. * @note The setting of these parameters by function @ref LL_ADC_CommonInit()
  226. * is conditioned to ADC instances state (all ADC instances
  227. * sharing the same ADC common instance):
  228. * All ADC instances sharing the same ADC common instance must be
  229. * disabled.
  230. */
  231. typedef struct
  232. {
  233. uint32_t Multimode; /*!< Set ADC multimode configuration to operate in independent mode or multimode (for devices with several ADC instances).
  234. This parameter can be a value of @ref ADC_LL_EC_MULTI_MODE
  235. This feature can be modified afterwards using unitary function @ref LL_ADC_SetMultimode(). */
  236. } LL_ADC_CommonInitTypeDef;
  237. /**
  238. * @brief Structure definition of some features of ADC instance.
  239. * @note These parameters have an impact on ADC scope: ADC instance.
  240. * Affects both group regular and group injected (availability
  241. * of ADC group injected depends on STM32 families).
  242. * Refer to corresponding unitary functions into
  243. * @ref ADC_LL_EF_Configuration_ADC_Instance .
  244. * @note The setting of these parameters by function @ref LL_ADC_Init()
  245. * is conditioned to ADC state:
  246. * ADC instance must be disabled.
  247. * This condition is applied to all ADC features, for efficiency
  248. * and compatibility over all STM32 families. However, the different
  249. * features can be set under different ADC state conditions
  250. * (setting possible with ADC enabled without conversion on going,
  251. * ADC enabled with conversion on going, ...)
  252. * Each feature can be updated afterwards with a unitary function
  253. * and potentially with ADC in a different state than disabled,
  254. * refer to description of each function for setting
  255. * conditioned to ADC state.
  256. */
  257. typedef struct
  258. {
  259. uint32_t DataAlignment; /*!< Set ADC conversion data alignment.
  260. This parameter can be a value of @ref ADC_LL_EC_DATA_ALIGN
  261. This feature can be modified afterwards using unitary function @ref LL_ADC_SetDataAlignment(). */
  262. uint32_t SequencersScanMode; /*!< Set ADC scan selection.
  263. This parameter can be a value of @ref ADC_LL_EC_SCAN_SELECTION
  264. This feature can be modified afterwards using unitary function @ref LL_ADC_SetSequencersScanMode(). */
  265. } LL_ADC_InitTypeDef;
  266. /**
  267. * @brief Structure definition of some features of ADC group regular.
  268. * @note These parameters have an impact on ADC scope: ADC group regular.
  269. * Refer to corresponding unitary functions into
  270. * @ref ADC_LL_EF_Configuration_ADC_Group_Regular
  271. * (functions with prefix "REG").
  272. * @note The setting of these parameters by function @ref LL_ADC_REG_Init()
  273. * is conditioned to ADC state:
  274. * ADC instance must be disabled.
  275. * This condition is applied to all ADC features, for efficiency
  276. * and compatibility over all STM32 families. However, the different
  277. * features can be set under different ADC state conditions
  278. * (setting possible with ADC enabled without conversion on going,
  279. * ADC enabled with conversion on going, ...)
  280. * Each feature can be updated afterwards with a unitary function
  281. * and potentially with ADC in a different state than disabled,
  282. * refer to description of each function for setting
  283. * conditioned to ADC state.
  284. */
  285. typedef struct
  286. {
  287. uint32_t TriggerSource; /*!< Set ADC group regular conversion trigger source: internal (SW start) or from external IP (timer event, external interrupt line).
  288. This parameter can be a value of @ref ADC_LL_EC_REG_TRIGGER_SOURCE
  289. @note On this STM32 serie, external trigger is set with trigger polarity: rising edge
  290. (only trigger polarity available on this STM32 serie).
  291. This feature can be modified afterwards using unitary function @ref LL_ADC_REG_SetTriggerSource(). */
  292. uint32_t SequencerLength; /*!< Set ADC group regular sequencer length.
  293. This parameter can be a value of @ref ADC_LL_EC_REG_SEQ_SCAN_LENGTH
  294. @note This parameter is discarded if scan mode is disabled (refer to parameter 'ADC_SequencersScanMode').
  295. This feature can be modified afterwards using unitary function @ref LL_ADC_REG_SetSequencerLength(). */
  296. uint32_t SequencerDiscont; /*!< Set ADC group regular sequencer discontinuous mode: sequence subdivided and scan conversions interrupted every selected number of ranks.
  297. This parameter can be a value of @ref ADC_LL_EC_REG_SEQ_DISCONT_MODE
  298. @note This parameter has an effect only if group regular sequencer is enabled
  299. (scan length of 2 ranks or more).
  300. This feature can be modified afterwards using unitary function @ref LL_ADC_REG_SetSequencerDiscont(). */
  301. uint32_t ContinuousMode; /*!< Set ADC continuous conversion mode on ADC group regular, whether ADC conversions are performed in single mode (one conversion per trigger) or in continuous mode (after the first trigger, following conversions launched successively automatically).
  302. This parameter can be a value of @ref ADC_LL_EC_REG_CONTINUOUS_MODE
  303. Note: It is not possible to enable both ADC group regular continuous mode and discontinuous mode.
  304. This feature can be modified afterwards using unitary function @ref LL_ADC_REG_SetContinuousMode(). */
  305. uint32_t DMATransfer; /*!< Set ADC group regular conversion data transfer: no transfer or transfer by DMA, and DMA requests mode.
  306. This parameter can be a value of @ref ADC_LL_EC_REG_DMA_TRANSFER
  307. This feature can be modified afterwards using unitary function @ref LL_ADC_REG_SetDMATransfer(). */
  308. } LL_ADC_REG_InitTypeDef;
  309. /**
  310. * @brief Structure definition of some features of ADC group injected.
  311. * @note These parameters have an impact on ADC scope: ADC group injected.
  312. * Refer to corresponding unitary functions into
  313. * @ref ADC_LL_EF_Configuration_ADC_Group_Regular
  314. * (functions with prefix "INJ").
  315. * @note The setting of these parameters by function @ref LL_ADC_INJ_Init()
  316. * is conditioned to ADC state:
  317. * ADC instance must be disabled.
  318. * This condition is applied to all ADC features, for efficiency
  319. * and compatibility over all STM32 families. However, the different
  320. * features can be set under different ADC state conditions
  321. * (setting possible with ADC enabled without conversion on going,
  322. * ADC enabled with conversion on going, ...)
  323. * Each feature can be updated afterwards with a unitary function
  324. * and potentially with ADC in a different state than disabled,
  325. * refer to description of each function for setting
  326. * conditioned to ADC state.
  327. */
  328. typedef struct
  329. {
  330. uint32_t TriggerSource; /*!< Set ADC group injected conversion trigger source: internal (SW start) or from external IP (timer event, external interrupt line).
  331. This parameter can be a value of @ref ADC_LL_EC_INJ_TRIGGER_SOURCE
  332. @note On this STM32 serie, external trigger is set with trigger polarity: rising edge
  333. (only trigger polarity available on this STM32 serie).
  334. This feature can be modified afterwards using unitary function @ref LL_ADC_INJ_SetTriggerSource(). */
  335. uint32_t SequencerLength; /*!< Set ADC group injected sequencer length.
  336. This parameter can be a value of @ref ADC_LL_EC_INJ_SEQ_SCAN_LENGTH
  337. @note This parameter is discarded if scan mode is disabled (refer to parameter 'ADC_SequencersScanMode').
  338. This feature can be modified afterwards using unitary function @ref LL_ADC_INJ_SetSequencerLength(). */
  339. uint32_t SequencerDiscont; /*!< Set ADC group injected sequencer discontinuous mode: sequence subdivided and scan conversions interrupted every selected number of ranks.
  340. This parameter can be a value of @ref ADC_LL_EC_INJ_SEQ_DISCONT_MODE
  341. @note This parameter has an effect only if group injected sequencer is enabled
  342. (scan length of 2 ranks or more).
  343. This feature can be modified afterwards using unitary function @ref LL_ADC_INJ_SetSequencerDiscont(). */
  344. uint32_t TrigAuto; /*!< Set ADC group injected conversion trigger: independent or from ADC group regular.
  345. This parameter can be a value of @ref ADC_LL_EC_INJ_TRIG_AUTO
  346. Note: This parameter must be set to set to independent trigger if injected trigger source is set to an external trigger.
  347. This feature can be modified afterwards using unitary function @ref LL_ADC_INJ_SetTrigAuto(). */
  348. } LL_ADC_INJ_InitTypeDef;
  349. /**
  350. * @}
  351. */
  352. #endif /* USE_FULL_LL_DRIVER */
  353. /* Exported constants --------------------------------------------------------*/
  354. /** @defgroup ADC_LL_Exported_Constants ADC Exported Constants
  355. * @{
  356. */
  357. /** @defgroup ADC_LL_EC_FLAG ADC flags
  358. * @brief Flags defines which can be used with LL_ADC_ReadReg function
  359. * @{
  360. */
  361. #define LL_ADC_FLAG_STRT ADC_SR_STRT /*!< ADC flag ADC group regular conversion start */
  362. #define LL_ADC_FLAG_EOS ADC_SR_EOC /*!< ADC flag ADC group regular end of sequence conversions (Note: on this STM32 serie, there is no flag ADC group regular end of unitary conversion. Flag noted as "EOC" is corresponding to flag "EOS" in other STM32 families) */
  363. #define LL_ADC_FLAG_JSTRT ADC_SR_JSTRT /*!< ADC flag ADC group injected conversion start */
  364. #define LL_ADC_FLAG_JEOS ADC_SR_JEOC /*!< ADC flag ADC group injected end of sequence conversions (Note: on this STM32 serie, there is no flag ADC group injected end of unitary conversion. Flag noted as "JEOC" is corresponding to flag "JEOS" in other STM32 families) */
  365. #define LL_ADC_FLAG_AWD1 ADC_SR_AWD /*!< ADC flag ADC analog watchdog 1 */
  366. #if defined(ADC_MULTIMODE_SUPPORT)
  367. #define LL_ADC_FLAG_EOS_MST ADC_SR_EOC /*!< ADC flag ADC multimode master group regular end of sequence conversions (Note: on this STM32 serie, there is no flag ADC group regular end of unitary conversion. Flag noted as "EOC" is corresponding to flag "EOS" in other STM32 families) */
  368. #define LL_ADC_FLAG_EOS_SLV ADC_SR_EOC /*!< ADC flag ADC multimode slave group regular end of sequence conversions (Note: on this STM32 serie, there is no flag ADC group regular end of unitary conversion. Flag noted as "EOC" is corresponding to flag "EOS" in other STM32 families) (on STM32F1, this flag must be read from ADC instance slave: ADC2) */
  369. #define LL_ADC_FLAG_JEOS_MST ADC_SR_JEOC /*!< ADC flag ADC multimode master group injected end of sequence conversions (Note: on this STM32 serie, there is no flag ADC group injected end of unitary conversion. Flag noted as "JEOC" is corresponding to flag "JEOS" in other STM32 families) */
  370. #define LL_ADC_FLAG_JEOS_SLV ADC_SR_JEOC /*!< ADC flag ADC multimode slave group injected end of sequence conversions (Note: on this STM32 serie, there is no flag ADC group injected end of unitary conversion. Flag noted as "JEOC" is corresponding to flag "JEOS" in other STM32 families) (on STM32F1, this flag must be read from ADC instance slave: ADC2) */
  371. #define LL_ADC_FLAG_AWD1_MST ADC_SR_AWD /*!< ADC flag ADC multimode master analog watchdog 1 of the ADC master */
  372. #define LL_ADC_FLAG_AWD1_SLV ADC_SR_AWD /*!< ADC flag ADC multimode slave analog watchdog 1 of the ADC slave (on STM32F1, this flag must be read from ADC instance slave: ADC2) */
  373. #endif
  374. /**
  375. * @}
  376. */
  377. /** @defgroup ADC_LL_EC_IT ADC interruptions for configuration (interruption enable or disable)
  378. * @brief IT defines which can be used with LL_ADC_ReadReg and LL_ADC_WriteReg functions
  379. * @{
  380. */
  381. #define LL_ADC_IT_EOS ADC_CR1_EOCIE /*!< ADC interruption ADC group regular end of sequence conversions (Note: on this STM32 serie, there is no flag ADC group regular end of unitary conversion. Flag noted as "EOC" is corresponding to flag "EOS" in other STM32 families) */
  382. #define LL_ADC_IT_JEOS ADC_CR1_JEOCIE /*!< ADC interruption ADC group injected end of sequence conversions (Note: on this STM32 serie, there is no flag ADC group injected end of unitary conversion. Flag noted as "JEOC" is corresponding to flag "JEOS" in other STM32 families) */
  383. #define LL_ADC_IT_AWD1 ADC_CR1_AWDIE /*!< ADC interruption ADC analog watchdog 1 */
  384. /**
  385. * @}
  386. */
  387. /** @defgroup ADC_LL_EC_REGISTERS ADC registers compliant with specific purpose
  388. * @{
  389. */
  390. /* List of ADC registers intended to be used (most commonly) with */
  391. /* DMA transfer. */
  392. /* Refer to function @ref LL_ADC_DMA_GetRegAddr(). */
  393. #define LL_ADC_DMA_REG_REGULAR_DATA 0x00000000U /* ADC group regular conversion data register (corresponding to register DR) to be used with ADC configured in independent mode. Without DMA transfer, register accessed by LL function @ref LL_ADC_REG_ReadConversionData32() and other functions @ref LL_ADC_REG_ReadConversionDatax() */
  394. #if defined(ADC_MULTIMODE_SUPPORT)
  395. #define LL_ADC_DMA_REG_REGULAR_DATA_MULTI 0x00000001U /* ADC group regular conversion data register (corresponding to register CDR) to be used with ADC configured in multimode (available on STM32 devices with several ADC instances). Without DMA transfer, register accessed by LL function @ref LL_ADC_REG_ReadMultiConversionData32() */
  396. #endif
  397. /**
  398. * @}
  399. */
  400. /** @defgroup ADC_LL_EC_COMMON_PATH_INTERNAL ADC common - Measurement path to internal channels
  401. * @{
  402. */
  403. /* Note: Other measurement paths to internal channels may be available */
  404. /* (connections to other peripherals). */
  405. /* If they are not listed below, they do not require any specific */
  406. /* path enable. In this case, Access to measurement path is done */
  407. /* only by selecting the corresponding ADC internal channel. */
  408. #define LL_ADC_PATH_INTERNAL_NONE 0x00000000U /*!< ADC measurement pathes all disabled */
  409. #define LL_ADC_PATH_INTERNAL_VREFINT (ADC_CR2_TSVREFE) /*!< ADC measurement path to internal channel VrefInt */
  410. #define LL_ADC_PATH_INTERNAL_TEMPSENSOR (ADC_CR2_TSVREFE) /*!< ADC measurement path to internal channel temperature sensor */
  411. /**
  412. * @}
  413. */
  414. /** @defgroup ADC_LL_EC_RESOLUTION ADC instance - Resolution
  415. * @{
  416. */
  417. #define LL_ADC_RESOLUTION_12B 0x00000000U /*!< ADC resolution 12 bits */
  418. /**
  419. * @}
  420. */
  421. /** @defgroup ADC_LL_EC_DATA_ALIGN ADC instance - Data alignment
  422. * @{
  423. */
  424. #define LL_ADC_DATA_ALIGN_RIGHT 0x00000000U /*!< ADC conversion data alignment: right aligned (alignment on data register LSB bit 0)*/
  425. #define LL_ADC_DATA_ALIGN_LEFT (ADC_CR2_ALIGN) /*!< ADC conversion data alignment: left aligned (aligment on data register MSB bit 15)*/
  426. /**
  427. * @}
  428. */
  429. /** @defgroup ADC_LL_EC_SCAN_SELECTION ADC instance - Scan selection
  430. * @{
  431. */
  432. #define LL_ADC_SEQ_SCAN_DISABLE 0x00000000U /*!< ADC conversion is performed in unitary conversion mode (one channel converted, that defined in rank 1). Configuration of both groups regular and injected sequencers (sequence length, ...) is discarded: equivalent to length of 1 rank.*/
  433. #define LL_ADC_SEQ_SCAN_ENABLE (ADC_CR1_SCAN) /*!< ADC conversions are performed in sequence conversions mode, according to configuration of both groups regular and injected sequencers (sequence length, ...). */
  434. /**
  435. * @}
  436. */
  437. /** @defgroup ADC_LL_EC_GROUPS ADC instance - Groups
  438. * @{
  439. */
  440. #define LL_ADC_GROUP_REGULAR 0x00000001U /*!< ADC group regular (available on all STM32 devices) */
  441. #define LL_ADC_GROUP_INJECTED 0x00000002U /*!< ADC group injected (not available on all STM32 devices)*/
  442. #define LL_ADC_GROUP_REGULAR_INJECTED 0x00000003U /*!< ADC both groups regular and injected */
  443. /**
  444. * @}
  445. */
  446. /** @defgroup ADC_LL_EC_CHANNEL ADC instance - Channel number
  447. * @{
  448. */
  449. #define LL_ADC_CHANNEL_0 (ADC_CHANNEL_0_NUMBER | ADC_CHANNEL_0_SMP) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN0 */
  450. #define LL_ADC_CHANNEL_1 (ADC_CHANNEL_1_NUMBER | ADC_CHANNEL_1_SMP) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN1 */
  451. #define LL_ADC_CHANNEL_2 (ADC_CHANNEL_2_NUMBER | ADC_CHANNEL_2_SMP) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN2 */
  452. #define LL_ADC_CHANNEL_3 (ADC_CHANNEL_3_NUMBER | ADC_CHANNEL_3_SMP) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN3 */
  453. #define LL_ADC_CHANNEL_4 (ADC_CHANNEL_4_NUMBER | ADC_CHANNEL_4_SMP) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN4 */
  454. #define LL_ADC_CHANNEL_5 (ADC_CHANNEL_5_NUMBER | ADC_CHANNEL_5_SMP) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN5 */
  455. #define LL_ADC_CHANNEL_6 (ADC_CHANNEL_6_NUMBER | ADC_CHANNEL_6_SMP) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN6 */
  456. #define LL_ADC_CHANNEL_7 (ADC_CHANNEL_7_NUMBER | ADC_CHANNEL_7_SMP) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN7 */
  457. #define LL_ADC_CHANNEL_8 (ADC_CHANNEL_8_NUMBER | ADC_CHANNEL_8_SMP) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN8 */
  458. #define LL_ADC_CHANNEL_9 (ADC_CHANNEL_9_NUMBER | ADC_CHANNEL_9_SMP) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN9 */
  459. #define LL_ADC_CHANNEL_10 (ADC_CHANNEL_10_NUMBER | ADC_CHANNEL_10_SMP) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN10 */
  460. #define LL_ADC_CHANNEL_11 (ADC_CHANNEL_11_NUMBER | ADC_CHANNEL_11_SMP) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN11 */
  461. #define LL_ADC_CHANNEL_12 (ADC_CHANNEL_12_NUMBER | ADC_CHANNEL_12_SMP) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN12 */
  462. #define LL_ADC_CHANNEL_13 (ADC_CHANNEL_13_NUMBER | ADC_CHANNEL_13_SMP) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN13 */
  463. #define LL_ADC_CHANNEL_14 (ADC_CHANNEL_14_NUMBER | ADC_CHANNEL_14_SMP) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN14 */
  464. #define LL_ADC_CHANNEL_15 (ADC_CHANNEL_15_NUMBER | ADC_CHANNEL_15_SMP) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN15 */
  465. #define LL_ADC_CHANNEL_16 (ADC_CHANNEL_16_NUMBER | ADC_CHANNEL_16_SMP) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN16 */
  466. #define LL_ADC_CHANNEL_17 (ADC_CHANNEL_17_NUMBER | ADC_CHANNEL_17_SMP) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN17 */
  467. #define LL_ADC_CHANNEL_VREFINT (LL_ADC_CHANNEL_17 | ADC_CHANNEL_ID_INTERNAL_CH) /*!< ADC internal channel connected to VrefInt: Internal voltage reference. On STM32F1, ADC channel available only on ADC instance: ADC1. */
  468. #define LL_ADC_CHANNEL_TEMPSENSOR (LL_ADC_CHANNEL_16 | ADC_CHANNEL_ID_INTERNAL_CH) /*!< ADC internal channel connected to Temperature sensor. */
  469. /**
  470. * @}
  471. */
  472. /** @defgroup ADC_LL_EC_REG_TRIGGER_SOURCE ADC group regular - Trigger source
  473. * @{
  474. */
  475. /* ADC group regular external triggers for ADC instances: ADC1, ADC2, ADC3 (for ADC instances ADCx available on the selected device) */
  476. #define LL_ADC_REG_TRIG_SOFTWARE (ADC_CR2_EXTSEL_2 | ADC_CR2_EXTSEL_1 | ADC_CR2_EXTSEL_0) /*!< ADC group regular conversion trigger internal: SW start. */
  477. #define LL_ADC_REG_TRIG_EXT_TIM1_CH3 (ADC_CR2_EXTSEL_1) /*!< ADC group regular conversion trigger from external IP: TIM1 channel 3 event (capture compare: input capture or output capture). Trigger edge set to rising edge (default setting). */
  478. /* ADC group regular external triggers for ADC instances: ADC1, ADC2 (for ADC instances ADCx available on the selected device) */
  479. #define LL_ADC_REG_TRIG_EXT_TIM1_CH1 0x00000000U /*!< ADC group regular conversion trigger from external IP: TIM1 channel 1 event (capture compare: input capture or output capture). Trigger edge set to rising edge (default setting). */
  480. #define LL_ADC_REG_TRIG_EXT_TIM1_CH2 (ADC_CR2_EXTSEL_0) /*!< ADC group regular conversion trigger from external IP: TIM1 channel 2 event (capture compare: input capture or output capture). Trigger edge set to rising edge (default setting). */
  481. #define LL_ADC_REG_TRIG_EXT_TIM2_CH2 (ADC_CR2_EXTSEL_1 | ADC_CR2_EXTSEL_0) /*!< ADC group regular conversion trigger from external IP: TIM2 channel 2 event (capture compare: input capture or output capture). Trigger edge set to rising edge (default setting). */
  482. #define LL_ADC_REG_TRIG_EXT_TIM3_TRGO (ADC_CR2_EXTSEL_2) /*!< ADC group regular conversion trigger from external IP: TIM3 TRGO. Trigger edge set to rising edge (default setting). */
  483. #define LL_ADC_REG_TRIG_EXT_TIM4_CH4 (ADC_CR2_EXTSEL_2 | ADC_CR2_EXTSEL_0) /*!< ADC group regular conversion trigger from external IP: TIM4 channel 4 event (capture compare: input capture or output capture). Trigger edge set to rising edge (default setting). */
  484. #define LL_ADC_REG_TRIG_EXT_EXTI_LINE11 (ADC_CR2_EXTSEL_2 | ADC_CR2_EXTSEL_1) /*!< ADC group regular conversion trigger from external IP: external interrupt line 11. Trigger edge set to rising edge (default setting). */
  485. #if defined (STM32F101xE) || defined (STM32F103xE) || defined (STM32F103xG) || defined (STM32F105xC) || defined (STM32F107xC)
  486. /* Note: TIM8_TRGO is available on ADC1 and ADC2 only in high-density and */
  487. /* XL-density devices. */
  488. /* Note: To use TIM8_TRGO on ADC1 or ADC2, a remap of trigger must be done */
  489. /* A remap of trigger must be done at top level (refer to */
  490. /* AFIO peripheral). */
  491. #define LL_ADC_REG_TRIG_EXT_TIM8_TRGO (LL_ADC_REG_TRIG_EXT_EXTI_LINE11) /*!< ADC group regular conversion trigger from external IP: TIM8 TRGO. Trigger edge set to rising edge (default setting). Available only on high-density and XL-density devices. A remap of trigger must be done at top level (refer to AFIO peripheral).*/
  492. #endif /* STM32F101xE || STM32F103xE || STM32F103xG || STM32F105xC || STM32F107xC */
  493. #if defined (STM32F103xE) || defined (STM32F103xG)
  494. /* ADC group regular external triggers for ADC instances: ADC3 (for ADC instances ADCx available on the selected device) */
  495. #define LL_ADC_REG_TRIG_EXT_TIM3_CH1 (LL_ADC_REG_TRIG_EXT_TIM1_CH1) /*!< ADC group regular conversion trigger from external IP: TIM3 channel 1 event (capture compare: input capture or output capture). Trigger edge set to rising edge (default setting). */
  496. #define LL_ADC_REG_TRIG_EXT_TIM2_CH3 (LL_ADC_REG_TRIG_EXT_TIM1_CH2) /*!< ADC group regular conversion trigger from external IP: TIM2 channel 3 event (capture compare: input capture or output capture). Trigger edge set to rising edge (default setting). */
  497. #define LL_ADC_REG_TRIG_EXT_TIM8_CH1 (LL_ADC_REG_TRIG_EXT_TIM2_CH2) /*!< ADC group regular conversion trigger from external IP: TIM8 channel 1 event (capture compare: input capture or output capture). Trigger edge set to rising edge (default setting). */
  498. #define LL_ADC_REG_TRIG_EXT_TIM8_TRGO_ADC3 (LL_ADC_REG_TRIG_EXT_TIM3_TRGO) /*!< ADC group regular conversion trigger from external IP: TIM8 TRGO. Trigger edge set to rising edge (default setting). */
  499. #define LL_ADC_REG_TRIG_EXT_TIM5_CH1 (LL_ADC_REG_TRIG_EXT_TIM4_CH4) /*!< ADC group regular conversion trigger from external IP: TIM5 channel 1 event (capture compare: input capture or output capture). Trigger edge set to rising edge (default setting). */
  500. #define LL_ADC_REG_TRIG_EXT_TIM5_CH3 (LL_ADC_REG_TRIG_EXT_EXTI_LINE11) /*!< ADC group regular conversion trigger from external IP: TIM5 channel 3 event (capture compare: input capture or output capture). Trigger edge set to rising edge (default setting). */
  501. #endif
  502. /**
  503. * @}
  504. */
  505. /** @defgroup ADC_LL_EC_REG_TRIGGER_EDGE ADC group regular - Trigger edge
  506. * @{
  507. */
  508. #define LL_ADC_REG_TRIG_EXT_RISING ADC_CR2_EXTTRIG /*!< ADC group regular conversion trigger polarity set to rising edge */
  509. /**
  510. * @}
  511. */
  512. /** @defgroup ADC_LL_EC_REG_CONTINUOUS_MODE ADC group regular - Continuous mode
  513. * @{
  514. */
  515. #define LL_ADC_REG_CONV_SINGLE 0x00000000U /*!< ADC conversions are performed in single mode: one conversion per trigger */
  516. #define LL_ADC_REG_CONV_CONTINUOUS (ADC_CR2_CONT) /*!< ADC conversions are performed in continuous mode: after the first trigger, following conversions launched successively automatically */
  517. /**
  518. * @}
  519. */
  520. /** @defgroup ADC_LL_EC_REG_DMA_TRANSFER ADC group regular - DMA transfer of ADC conversion data
  521. * @{
  522. */
  523. #define LL_ADC_REG_DMA_TRANSFER_NONE 0x00000000U /*!< ADC conversions are not transferred by DMA */
  524. #define LL_ADC_REG_DMA_TRANSFER_UNLIMITED (ADC_CR2_DMA) /*!< ADC conversion data are transferred by DMA, in unlimited mode: DMA transfer requests are unlimited, whatever number of DMA data transferred (number of ADC conversions). This ADC mode is intended to be used with DMA mode circular. */
  525. /**
  526. * @}
  527. */
  528. /** @defgroup ADC_LL_EC_REG_SEQ_SCAN_LENGTH ADC group regular - Sequencer scan length
  529. * @{
  530. */
  531. #define LL_ADC_REG_SEQ_SCAN_DISABLE 0x00000000U /*!< ADC group regular sequencer disable (equivalent to sequencer of 1 rank: ADC conversion on only 1 channel) */
  532. #define LL_ADC_REG_SEQ_SCAN_ENABLE_2RANKS ( ADC_SQR1_L_0) /*!< ADC group regular sequencer enable with 2 ranks in the sequence */
  533. #define LL_ADC_REG_SEQ_SCAN_ENABLE_3RANKS ( ADC_SQR1_L_1 ) /*!< ADC group regular sequencer enable with 3 ranks in the sequence */
  534. #define LL_ADC_REG_SEQ_SCAN_ENABLE_4RANKS ( ADC_SQR1_L_1 | ADC_SQR1_L_0) /*!< ADC group regular sequencer enable with 4 ranks in the sequence */
  535. #define LL_ADC_REG_SEQ_SCAN_ENABLE_5RANKS ( ADC_SQR1_L_2 ) /*!< ADC group regular sequencer enable with 5 ranks in the sequence */
  536. #define LL_ADC_REG_SEQ_SCAN_ENABLE_6RANKS ( ADC_SQR1_L_2 | ADC_SQR1_L_0) /*!< ADC group regular sequencer enable with 6 ranks in the sequence */
  537. #define LL_ADC_REG_SEQ_SCAN_ENABLE_7RANKS ( ADC_SQR1_L_2 | ADC_SQR1_L_1 ) /*!< ADC group regular sequencer enable with 7 ranks in the sequence */
  538. #define LL_ADC_REG_SEQ_SCAN_ENABLE_8RANKS ( ADC_SQR1_L_2 | ADC_SQR1_L_1 | ADC_SQR1_L_0) /*!< ADC group regular sequencer enable with 8 ranks in the sequence */
  539. #define LL_ADC_REG_SEQ_SCAN_ENABLE_9RANKS (ADC_SQR1_L_3 ) /*!< ADC group regular sequencer enable with 9 ranks in the sequence */
  540. #define LL_ADC_REG_SEQ_SCAN_ENABLE_10RANKS (ADC_SQR1_L_3 | ADC_SQR1_L_0) /*!< ADC group regular sequencer enable with 10 ranks in the sequence */
  541. #define LL_ADC_REG_SEQ_SCAN_ENABLE_11RANKS (ADC_SQR1_L_3 | ADC_SQR1_L_1 ) /*!< ADC group regular sequencer enable with 11 ranks in the sequence */
  542. #define LL_ADC_REG_SEQ_SCAN_ENABLE_12RANKS (ADC_SQR1_L_3 | ADC_SQR1_L_1 | ADC_SQR1_L_0) /*!< ADC group regular sequencer enable with 12 ranks in the sequence */
  543. #define LL_ADC_REG_SEQ_SCAN_ENABLE_13RANKS (ADC_SQR1_L_3 | ADC_SQR1_L_2 ) /*!< ADC group regular sequencer enable with 13 ranks in the sequence */
  544. #define LL_ADC_REG_SEQ_SCAN_ENABLE_14RANKS (ADC_SQR1_L_3 | ADC_SQR1_L_2 | ADC_SQR1_L_0) /*!< ADC group regular sequencer enable with 14 ranks in the sequence */
  545. #define LL_ADC_REG_SEQ_SCAN_ENABLE_15RANKS (ADC_SQR1_L_3 | ADC_SQR1_L_2 | ADC_SQR1_L_1 ) /*!< ADC group regular sequencer enable with 15 ranks in the sequence */
  546. #define LL_ADC_REG_SEQ_SCAN_ENABLE_16RANKS (ADC_SQR1_L_3 | ADC_SQR1_L_2 | ADC_SQR1_L_1 | ADC_SQR1_L_0) /*!< ADC group regular sequencer enable with 16 ranks in the sequence */
  547. /**
  548. * @}
  549. */
  550. /** @defgroup ADC_LL_EC_REG_SEQ_DISCONT_MODE ADC group regular - Sequencer discontinuous mode
  551. * @{
  552. */
  553. #define LL_ADC_REG_SEQ_DISCONT_DISABLE 0x00000000U /*!< ADC group regular sequencer discontinuous mode disable */
  554. #define LL_ADC_REG_SEQ_DISCONT_1RANK ( ADC_CR1_DISCEN) /*!< ADC group regular sequencer discontinuous mode enable with sequence interruption every rank */
  555. #define LL_ADC_REG_SEQ_DISCONT_2RANKS ( ADC_CR1_DISCNUM_0 | ADC_CR1_DISCEN) /*!< ADC group regular sequencer discontinuous mode enabled with sequence interruption every 2 ranks */
  556. #define LL_ADC_REG_SEQ_DISCONT_3RANKS ( ADC_CR1_DISCNUM_1 | ADC_CR1_DISCEN) /*!< ADC group regular sequencer discontinuous mode enable with sequence interruption every 3 ranks */
  557. #define LL_ADC_REG_SEQ_DISCONT_4RANKS ( ADC_CR1_DISCNUM_1 | ADC_CR1_DISCNUM_0 | ADC_CR1_DISCEN) /*!< ADC group regular sequencer discontinuous mode enable with sequence interruption every 4 ranks */
  558. #define LL_ADC_REG_SEQ_DISCONT_5RANKS (ADC_CR1_DISCNUM_2 | ADC_CR1_DISCEN) /*!< ADC group regular sequencer discontinuous mode enable with sequence interruption every 5 ranks */
  559. #define LL_ADC_REG_SEQ_DISCONT_6RANKS (ADC_CR1_DISCNUM_2 | ADC_CR1_DISCNUM_0 | ADC_CR1_DISCEN) /*!< ADC group regular sequencer discontinuous mode enable with sequence interruption every 6 ranks */
  560. #define LL_ADC_REG_SEQ_DISCONT_7RANKS (ADC_CR1_DISCNUM_2 | ADC_CR1_DISCNUM_1 | ADC_CR1_DISCEN) /*!< ADC group regular sequencer discontinuous mode enable with sequence interruption every 7 ranks */
  561. #define LL_ADC_REG_SEQ_DISCONT_8RANKS (ADC_CR1_DISCNUM_2 | ADC_CR1_DISCNUM_1 | ADC_CR1_DISCNUM_0 | ADC_CR1_DISCEN) /*!< ADC group regular sequencer discontinuous mode enable with sequence interruption every 8 ranks */
  562. /**
  563. * @}
  564. */
  565. /** @defgroup ADC_LL_EC_REG_SEQ_RANKS ADC group regular - Sequencer ranks
  566. * @{
  567. */
  568. #define LL_ADC_REG_RANK_1 (ADC_SQR3_REGOFFSET | ADC_REG_RANK_1_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 1 */
  569. #define LL_ADC_REG_RANK_2 (ADC_SQR3_REGOFFSET | ADC_REG_RANK_2_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 2 */
  570. #define LL_ADC_REG_RANK_3 (ADC_SQR3_REGOFFSET | ADC_REG_RANK_3_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 3 */
  571. #define LL_ADC_REG_RANK_4 (ADC_SQR3_REGOFFSET | ADC_REG_RANK_4_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 4 */
  572. #define LL_ADC_REG_RANK_5 (ADC_SQR3_REGOFFSET | ADC_REG_RANK_5_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 5 */
  573. #define LL_ADC_REG_RANK_6 (ADC_SQR3_REGOFFSET | ADC_REG_RANK_6_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 6 */
  574. #define LL_ADC_REG_RANK_7 (ADC_SQR2_REGOFFSET | ADC_REG_RANK_7_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 7 */
  575. #define LL_ADC_REG_RANK_8 (ADC_SQR2_REGOFFSET | ADC_REG_RANK_8_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 8 */
  576. #define LL_ADC_REG_RANK_9 (ADC_SQR2_REGOFFSET | ADC_REG_RANK_9_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 9 */
  577. #define LL_ADC_REG_RANK_10 (ADC_SQR2_REGOFFSET | ADC_REG_RANK_10_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 10 */
  578. #define LL_ADC_REG_RANK_11 (ADC_SQR2_REGOFFSET | ADC_REG_RANK_11_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 11 */
  579. #define LL_ADC_REG_RANK_12 (ADC_SQR2_REGOFFSET | ADC_REG_RANK_12_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 12 */
  580. #define LL_ADC_REG_RANK_13 (ADC_SQR1_REGOFFSET | ADC_REG_RANK_13_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 13 */
  581. #define LL_ADC_REG_RANK_14 (ADC_SQR1_REGOFFSET | ADC_REG_RANK_14_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 14 */
  582. #define LL_ADC_REG_RANK_15 (ADC_SQR1_REGOFFSET | ADC_REG_RANK_15_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 15 */
  583. #define LL_ADC_REG_RANK_16 (ADC_SQR1_REGOFFSET | ADC_REG_RANK_16_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 16 */
  584. /**
  585. * @}
  586. */
  587. /** @defgroup ADC_LL_EC_INJ_TRIGGER_SOURCE ADC group injected - Trigger source
  588. * @{
  589. */
  590. /* ADC group injected external triggers for ADC instances: ADC1, ADC2, ADC3 (for ADC instances ADCx available on the selected device) */
  591. #define LL_ADC_INJ_TRIG_SOFTWARE (ADC_CR2_JEXTSEL_2 | ADC_CR2_JEXTSEL_1 | ADC_CR2_JEXTSEL_0) /*!< ADC group injected conversion trigger internal: SW start. */
  592. #define LL_ADC_INJ_TRIG_EXT_TIM1_TRGO 0x00000000U /*!< ADC group injected conversion trigger from external IP: TIM1 TRGO. Trigger edge set to rising edge (default setting). */
  593. #define LL_ADC_INJ_TRIG_EXT_TIM1_CH4 (ADC_CR2_JEXTSEL_0) /*!< ADC group injected conversion trigger from external IP: TIM1 channel 4 event (capture compare: input capture or output capture). Trigger edge set to rising edge (default setting). */
  594. /* ADC group injected external triggers for ADC instances: ADC1, ADC2 (for ADC instances ADCx available on the selected device) */
  595. #define LL_ADC_INJ_TRIG_EXT_TIM2_TRGO (ADC_CR2_JEXTSEL_1) /*!< ADC group injected conversion trigger from external IP: TIM2 TRGO. Trigger edge set to rising edge (default setting). */
  596. #define LL_ADC_INJ_TRIG_EXT_TIM2_CH1 (ADC_CR2_JEXTSEL_1 | ADC_CR2_JEXTSEL_0) /*!< ADC group injected conversion trigger from external IP: TIM2 channel 1 event (capture compare: input capture or output capture). Trigger edge set to rising edge (default setting). */
  597. #define LL_ADC_INJ_TRIG_EXT_TIM3_CH4 (ADC_CR2_JEXTSEL_2) /*!< ADC group injected conversion trigger from external IP: TIM3 channel 4 event (capture compare: input capture or output capture). Trigger edge set to rising edge (default setting). */
  598. #define LL_ADC_INJ_TRIG_EXT_TIM4_TRGO (ADC_CR2_JEXTSEL_2 | ADC_CR2_JEXTSEL_0) /*!< ADC group injected conversion trigger from external IP: TIM4 TRGO. Trigger edge set to rising edge (default setting). */
  599. #define LL_ADC_INJ_TRIG_EXT_EXTI_LINE15 (ADC_CR2_JEXTSEL_2 | ADC_CR2_JEXTSEL_1) /*!< ADC group injected conversion trigger from external IP: external interrupt line 15. Trigger edge set to rising edge (default setting). */
  600. #if defined (STM32F101xE) || defined (STM32F103xE) || defined (STM32F103xG) || defined (STM32F105xC) || defined (STM32F107xC)
  601. /* Note: TIM8_CH4 is available on ADC1 and ADC2 only in high-density and */
  602. /* XL-density devices. */
  603. /* Note: To use TIM8_TRGO on ADC1 or ADC2, a remap of trigger must be done */
  604. /* A remap of trigger must be done at top level (refer to */
  605. /* AFIO peripheral). */
  606. #define LL_ADC_INJ_TRIG_EXT_TIM8_CH4 (LL_ADC_INJ_TRIG_EXT_EXTI_LINE15) /*!< ADC group injected conversion trigger from external IP: TIM8 channel 4 event (capture compare: input capture or output capture). Trigger edge set to rising edge (default setting). Available only on high-density and XL-density devices. A remap of trigger must be done at top level (refer to AFIO peripheral). */
  607. #endif /* STM32F101xE || STM32F103xE || STM32F103xG || STM32F105xC || STM32F107xC */
  608. #if defined (STM32F103xE) || defined (STM32F103xG)
  609. /* ADC group injected external triggers for ADC instances: ADC3 (for ADC instances ADCx available on the selected device) */
  610. #define LL_ADC_INJ_TRIG_EXT_TIM4_CH3 (LL_ADC_INJ_TRIG_EXT_TIM2_TRGO) /*!< ADC group injected conversion trigger from external IP: TIM4 channel 3 event (capture compare: input capture or output capture). Trigger edge set to rising edge (default setting). */
  611. #define LL_ADC_INJ_TRIG_EXT_TIM8_CH2 (LL_ADC_INJ_TRIG_EXT_TIM2_CH1) /*!< ADC group injected conversion trigger from external IP: TIM8 channel 2 event (capture compare: input capture or output capture). Trigger edge set to rising edge (default setting). */
  612. #define LL_ADC_INJ_TRIG_EXT_TIM8_CH4_ADC3 (LL_ADC_INJ_TRIG_EXT_TIM3_CH4) /*!< ADC group injected conversion trigger from external IP: TIM8 channel 4 event (capture compare: input capture or output capture). Trigger edge set to rising edge (default setting). */
  613. #define LL_ADC_INJ_TRIG_EXT_TIM5_TRGO (LL_ADC_INJ_TRIG_EXT_TIM4_TRGO) /*!< ADC group injected conversion trigger from external IP: TIM5 TRGO. Trigger edge set to rising edge (default setting). */
  614. #define LL_ADC_INJ_TRIG_EXT_TIM5_CH4 (LL_ADC_INJ_TRIG_EXT_EXTI_LINE15) /*!< ADC group injected conversion trigger from external IP: TIM5 channel 4 event (capture compare: input capture or output capture). Trigger edge set to rising edge (default setting). */
  615. #endif
  616. /**
  617. * @}
  618. */
  619. /** @defgroup ADC_LL_EC_INJ_TRIGGER_EDGE ADC group injected - Trigger edge
  620. * @{
  621. */
  622. #define LL_ADC_INJ_TRIG_EXT_RISING ADC_CR2_JEXTTRIG /*!< ADC group injected conversion trigger polarity set to rising edge */
  623. /**
  624. * @}
  625. */
  626. /** @defgroup ADC_LL_EC_INJ_TRIG_AUTO ADC group injected - Automatic trigger mode
  627. * @{
  628. */
  629. #define LL_ADC_INJ_TRIG_INDEPENDENT 0x00000000U /*!< ADC group injected conversion trigger independent. Setting mandatory if ADC group injected injected trigger source is set to an external trigger. */
  630. #define LL_ADC_INJ_TRIG_FROM_GRP_REGULAR (ADC_CR1_JAUTO) /*!< ADC group injected conversion trigger from ADC group regular. Setting compliant only with group injected trigger source set to SW start, 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. */
  631. /**
  632. * @}
  633. */
  634. /** @defgroup ADC_LL_EC_INJ_SEQ_SCAN_LENGTH ADC group injected - Sequencer scan length
  635. * @{
  636. */
  637. #define LL_ADC_INJ_SEQ_SCAN_DISABLE 0x00000000U /*!< ADC group injected sequencer disable (equivalent to sequencer of 1 rank: ADC conversion on only 1 channel) */
  638. #define LL_ADC_INJ_SEQ_SCAN_ENABLE_2RANKS ( ADC_JSQR_JL_0) /*!< ADC group injected sequencer enable with 2 ranks in the sequence */
  639. #define LL_ADC_INJ_SEQ_SCAN_ENABLE_3RANKS (ADC_JSQR_JL_1 ) /*!< ADC group injected sequencer enable with 3 ranks in the sequence */
  640. #define LL_ADC_INJ_SEQ_SCAN_ENABLE_4RANKS (ADC_JSQR_JL_1 | ADC_JSQR_JL_0) /*!< ADC group injected sequencer enable with 4 ranks in the sequence */
  641. /**
  642. * @}
  643. */
  644. /** @defgroup ADC_LL_EC_INJ_SEQ_DISCONT_MODE ADC group injected - Sequencer discontinuous mode
  645. * @{
  646. */
  647. #define LL_ADC_INJ_SEQ_DISCONT_DISABLE 0x00000000U /*!< ADC group injected sequencer discontinuous mode disable */
  648. #define LL_ADC_INJ_SEQ_DISCONT_1RANK (ADC_CR1_JDISCEN) /*!< ADC group injected sequencer discontinuous mode enable with sequence interruption every rank */
  649. /**
  650. * @}
  651. */
  652. /** @defgroup ADC_LL_EC_INJ_SEQ_RANKS ADC group injected - Sequencer ranks
  653. * @{
  654. */
  655. #define LL_ADC_INJ_RANK_1 (ADC_JDR1_REGOFFSET | ADC_JOFR1_REGOFFSET | 0x00000001U) /*!< ADC group injected sequencer rank 1 */
  656. #define LL_ADC_INJ_RANK_2 (ADC_JDR2_REGOFFSET | ADC_JOFR2_REGOFFSET | 0x00000002U) /*!< ADC group injected sequencer rank 2 */
  657. #define LL_ADC_INJ_RANK_3 (ADC_JDR3_REGOFFSET | ADC_JOFR3_REGOFFSET | 0x00000003U) /*!< ADC group injected sequencer rank 3 */
  658. #define LL_ADC_INJ_RANK_4 (ADC_JDR4_REGOFFSET | ADC_JOFR4_REGOFFSET | 0x00000004U) /*!< ADC group injected sequencer rank 4 */
  659. /**
  660. * @}
  661. */
  662. /** @defgroup ADC_LL_EC_CHANNEL_SAMPLINGTIME Channel - Sampling time
  663. * @{
  664. */
  665. #define LL_ADC_SAMPLINGTIME_1CYCLE_5 0x00000000U /*!< Sampling time 1.5 ADC clock cycle */
  666. #define LL_ADC_SAMPLINGTIME_7CYCLES_5 (ADC_SMPR2_SMP0_0) /*!< Sampling time 7.5 ADC clock cycles */
  667. #define LL_ADC_SAMPLINGTIME_13CYCLES_5 (ADC_SMPR2_SMP0_1) /*!< Sampling time 13.5 ADC clock cycles */
  668. #define LL_ADC_SAMPLINGTIME_28CYCLES_5 (ADC_SMPR2_SMP0_1 | ADC_SMPR2_SMP0_0) /*!< Sampling time 28.5 ADC clock cycles */
  669. #define LL_ADC_SAMPLINGTIME_41CYCLES_5 (ADC_SMPR2_SMP0_2) /*!< Sampling time 41.5 ADC clock cycles */
  670. #define LL_ADC_SAMPLINGTIME_55CYCLES_5 (ADC_SMPR2_SMP0_2 | ADC_SMPR2_SMP0_0) /*!< Sampling time 55.5 ADC clock cycles */
  671. #define LL_ADC_SAMPLINGTIME_71CYCLES_5 (ADC_SMPR2_SMP0_2 | ADC_SMPR2_SMP0_1) /*!< Sampling time 71.5 ADC clock cycles */
  672. #define LL_ADC_SAMPLINGTIME_239CYCLES_5 (ADC_SMPR2_SMP0_2 | ADC_SMPR2_SMP0_1 | ADC_SMPR2_SMP0_0) /*!< Sampling time 239.5 ADC clock cycles */
  673. /**
  674. * @}
  675. */
  676. /** @defgroup ADC_LL_EC_AWD_NUMBER Analog watchdog - Analog watchdog number
  677. * @{
  678. */
  679. #define LL_ADC_AWD1 (ADC_AWD_CR1_CHANNEL_MASK | ADC_AWD_CR1_REGOFFSET) /*!< ADC analog watchdog number 1 */
  680. /**
  681. * @}
  682. */
  683. /** @defgroup ADC_LL_EC_AWD_CHANNELS Analog watchdog - Monitored channels
  684. * @{
  685. */
  686. #define LL_ADC_AWD_DISABLE 0x00000000U /*!< ADC analog watchdog monitoring disabled */
  687. #define LL_ADC_AWD_ALL_CHANNELS_REG ( ADC_CR1_AWDEN ) /*!< ADC analog watchdog monitoring of all channels, converted by group regular only */
  688. #define LL_ADC_AWD_ALL_CHANNELS_INJ ( ADC_CR1_JAWDEN ) /*!< ADC analog watchdog monitoring of all channels, converted by group injected only */
  689. #define LL_ADC_AWD_ALL_CHANNELS_REG_INJ ( ADC_CR1_JAWDEN | ADC_CR1_AWDEN ) /*!< ADC analog watchdog monitoring of all channels, converted by either group regular or injected */
  690. #define LL_ADC_AWD_CHANNEL_0_REG ((LL_ADC_CHANNEL_0 & ADC_CHANNEL_ID_MASK) | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN0, converted by group regular only */
  691. #define LL_ADC_AWD_CHANNEL_0_INJ ((LL_ADC_CHANNEL_0 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN0, converted by group injected only */
  692. #define LL_ADC_AWD_CHANNEL_0_REG_INJ ((LL_ADC_CHANNEL_0 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN0, converted by either group regular or injected */
  693. #define LL_ADC_AWD_CHANNEL_1_REG ((LL_ADC_CHANNEL_1 & ADC_CHANNEL_ID_MASK) | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN1, converted by group regular only */
  694. #define LL_ADC_AWD_CHANNEL_1_INJ ((LL_ADC_CHANNEL_1 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN1, converted by group injected only */
  695. #define LL_ADC_AWD_CHANNEL_1_REG_INJ ((LL_ADC_CHANNEL_1 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN1, converted by either group regular or injected */
  696. #define LL_ADC_AWD_CHANNEL_2_REG ((LL_ADC_CHANNEL_2 & ADC_CHANNEL_ID_MASK) | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN2, converted by group regular only */
  697. #define LL_ADC_AWD_CHANNEL_2_INJ ((LL_ADC_CHANNEL_2 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN2, converted by group injected only */
  698. #define LL_ADC_AWD_CHANNEL_2_REG_INJ ((LL_ADC_CHANNEL_2 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN2, converted by either group regular or injected */
  699. #define LL_ADC_AWD_CHANNEL_3_REG ((LL_ADC_CHANNEL_3 & ADC_CHANNEL_ID_MASK) | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN3, converted by group regular only */
  700. #define LL_ADC_AWD_CHANNEL_3_INJ ((LL_ADC_CHANNEL_3 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN3, converted by group injected only */
  701. #define LL_ADC_AWD_CHANNEL_3_REG_INJ ((LL_ADC_CHANNEL_3 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN3, converted by either group regular or injected */
  702. #define LL_ADC_AWD_CHANNEL_4_REG ((LL_ADC_CHANNEL_4 & ADC_CHANNEL_ID_MASK) | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN4, converted by group regular only */
  703. #define LL_ADC_AWD_CHANNEL_4_INJ ((LL_ADC_CHANNEL_4 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN4, converted by group injected only */
  704. #define LL_ADC_AWD_CHANNEL_4_REG_INJ ((LL_ADC_CHANNEL_4 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN4, converted by either group regular or injected */
  705. #define LL_ADC_AWD_CHANNEL_5_REG ((LL_ADC_CHANNEL_5 & ADC_CHANNEL_ID_MASK) | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN5, converted by group regular only */
  706. #define LL_ADC_AWD_CHANNEL_5_INJ ((LL_ADC_CHANNEL_5 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN5, converted by group injected only */
  707. #define LL_ADC_AWD_CHANNEL_5_REG_INJ ((LL_ADC_CHANNEL_5 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN5, converted by either group regular or injected */
  708. #define LL_ADC_AWD_CHANNEL_6_REG ((LL_ADC_CHANNEL_6 & ADC_CHANNEL_ID_MASK) | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN6, converted by group regular only */
  709. #define LL_ADC_AWD_CHANNEL_6_INJ ((LL_ADC_CHANNEL_6 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN6, converted by group injected only */
  710. #define LL_ADC_AWD_CHANNEL_6_REG_INJ ((LL_ADC_CHANNEL_6 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN6, converted by either group regular or injected */
  711. #define LL_ADC_AWD_CHANNEL_7_REG ((LL_ADC_CHANNEL_7 & ADC_CHANNEL_ID_MASK) | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN7, converted by group regular only */
  712. #define LL_ADC_AWD_CHANNEL_7_INJ ((LL_ADC_CHANNEL_7 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN7, converted by group injected only */
  713. #define LL_ADC_AWD_CHANNEL_7_REG_INJ ((LL_ADC_CHANNEL_7 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN7, converted by either group regular or injected */
  714. #define LL_ADC_AWD_CHANNEL_8_REG ((LL_ADC_CHANNEL_8 & ADC_CHANNEL_ID_MASK) | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN8, converted by group regular only */
  715. #define LL_ADC_AWD_CHANNEL_8_INJ ((LL_ADC_CHANNEL_8 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN8, converted by group injected only */
  716. #define LL_ADC_AWD_CHANNEL_8_REG_INJ ((LL_ADC_CHANNEL_8 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN8, converted by either group regular or injected */
  717. #define LL_ADC_AWD_CHANNEL_9_REG ((LL_ADC_CHANNEL_9 & ADC_CHANNEL_ID_MASK) | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN9, converted by group regular only */
  718. #define LL_ADC_AWD_CHANNEL_9_INJ ((LL_ADC_CHANNEL_9 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN9, converted by group injected only */
  719. #define LL_ADC_AWD_CHANNEL_9_REG_INJ ((LL_ADC_CHANNEL_9 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN9, converted by either group regular or injected */
  720. #define LL_ADC_AWD_CHANNEL_10_REG ((LL_ADC_CHANNEL_10 & ADC_CHANNEL_ID_MASK) | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN10, converted by group regular only */
  721. #define LL_ADC_AWD_CHANNEL_10_INJ ((LL_ADC_CHANNEL_10 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN10, converted by group injected only */
  722. #define LL_ADC_AWD_CHANNEL_10_REG_INJ ((LL_ADC_CHANNEL_10 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN10, converted by either group regular or injected */
  723. #define LL_ADC_AWD_CHANNEL_11_REG ((LL_ADC_CHANNEL_11 & ADC_CHANNEL_ID_MASK) | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN11, converted by group regular only */
  724. #define LL_ADC_AWD_CHANNEL_11_INJ ((LL_ADC_CHANNEL_11 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN11, converted by group injected only */
  725. #define LL_ADC_AWD_CHANNEL_11_REG_INJ ((LL_ADC_CHANNEL_11 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN11, converted by either group regular or injected */
  726. #define LL_ADC_AWD_CHANNEL_12_REG ((LL_ADC_CHANNEL_12 & ADC_CHANNEL_ID_MASK) | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN12, converted by group regular only */
  727. #define LL_ADC_AWD_CHANNEL_12_INJ ((LL_ADC_CHANNEL_12 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN12, converted by group injected only */
  728. #define LL_ADC_AWD_CHANNEL_12_REG_INJ ((LL_ADC_CHANNEL_12 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN12, converted by either group regular or injected */
  729. #define LL_ADC_AWD_CHANNEL_13_REG ((LL_ADC_CHANNEL_13 & ADC_CHANNEL_ID_MASK) | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN13, converted by group regular only */
  730. #define LL_ADC_AWD_CHANNEL_13_INJ ((LL_ADC_CHANNEL_13 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN13, converted by group injected only */
  731. #define LL_ADC_AWD_CHANNEL_13_REG_INJ ((LL_ADC_CHANNEL_13 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN13, converted by either group regular or injected */
  732. #define LL_ADC_AWD_CHANNEL_14_REG ((LL_ADC_CHANNEL_14 & ADC_CHANNEL_ID_MASK) | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN14, converted by group regular only */
  733. #define LL_ADC_AWD_CHANNEL_14_INJ ((LL_ADC_CHANNEL_14 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN14, converted by group injected only */
  734. #define LL_ADC_AWD_CHANNEL_14_REG_INJ ((LL_ADC_CHANNEL_14 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN14, converted by either group regular or injected */
  735. #define LL_ADC_AWD_CHANNEL_15_REG ((LL_ADC_CHANNEL_15 & ADC_CHANNEL_ID_MASK) | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN15, converted by group regular only */
  736. #define LL_ADC_AWD_CHANNEL_15_INJ ((LL_ADC_CHANNEL_15 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN15, converted by group injected only */
  737. #define LL_ADC_AWD_CHANNEL_15_REG_INJ ((LL_ADC_CHANNEL_15 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN15, converted by either group regular or injected */
  738. #define LL_ADC_AWD_CHANNEL_16_REG ((LL_ADC_CHANNEL_16 & ADC_CHANNEL_ID_MASK) | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN16, converted by group regular only */
  739. #define LL_ADC_AWD_CHANNEL_16_INJ ((LL_ADC_CHANNEL_16 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN16, converted by group injected only */
  740. #define LL_ADC_AWD_CHANNEL_16_REG_INJ ((LL_ADC_CHANNEL_16 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN16, converted by either group regular or injected */
  741. #define LL_ADC_AWD_CHANNEL_17_REG ((LL_ADC_CHANNEL_17 & ADC_CHANNEL_ID_MASK) | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN17, converted by group regular only */
  742. #define LL_ADC_AWD_CHANNEL_17_INJ ((LL_ADC_CHANNEL_17 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN17, converted by group injected only */
  743. #define LL_ADC_AWD_CHANNEL_17_REG_INJ ((LL_ADC_CHANNEL_17 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN17, converted by either group regular or injected */
  744. #define LL_ADC_AWD_CH_VREFINT_REG ((LL_ADC_CHANNEL_VREFINT & ADC_CHANNEL_ID_MASK) | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC internal channel connected to VrefInt: Internal voltage reference, converted by group regular only */
  745. #define LL_ADC_AWD_CH_VREFINT_INJ ((LL_ADC_CHANNEL_VREFINT & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC internal channel connected to VrefInt: Internal voltage reference, converted by group injected only */
  746. #define LL_ADC_AWD_CH_VREFINT_REG_INJ ((LL_ADC_CHANNEL_VREFINT & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC internal channel connected to VrefInt: Internal voltage reference, converted by either group regular or injected */
  747. #define LL_ADC_AWD_CH_TEMPSENSOR_REG ((LL_ADC_CHANNEL_TEMPSENSOR & ADC_CHANNEL_ID_MASK) | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC internal channel connected to Temperature sensor, converted by group regular only */
  748. #define LL_ADC_AWD_CH_TEMPSENSOR_INJ ((LL_ADC_CHANNEL_TEMPSENSOR & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC internal channel connected to Temperature sensor, converted by group injected only */
  749. #define LL_ADC_AWD_CH_TEMPSENSOR_REG_INJ ((LL_ADC_CHANNEL_TEMPSENSOR & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC internal channel connected to Temperature sensor, converted by either group regular or injected */
  750. /**
  751. * @}
  752. */
  753. /** @defgroup ADC_LL_EC_AWD_THRESHOLDS Analog watchdog - Thresholds
  754. * @{
  755. */
  756. #define LL_ADC_AWD_THRESHOLD_HIGH (ADC_AWD_TR1_HIGH_REGOFFSET) /*!< ADC analog watchdog threshold high */
  757. #define LL_ADC_AWD_THRESHOLD_LOW (ADC_AWD_TR1_LOW_REGOFFSET) /*!< ADC analog watchdog threshold low */
  758. /**
  759. * @}
  760. */
  761. #if !defined(ADC_MULTIMODE_SUPPORT)
  762. /** @defgroup ADC_LL_EC_MULTI_MODE Multimode - Mode
  763. * @{
  764. */
  765. #define LL_ADC_MULTI_INDEPENDENT 0x00000000U /*!< ADC dual mode disabled (ADC independent mode) */
  766. /**
  767. * @}
  768. */
  769. #endif
  770. #if defined(ADC_MULTIMODE_SUPPORT)
  771. /** @defgroup ADC_LL_EC_MULTI_MODE Multimode - Mode
  772. * @{
  773. */
  774. #define LL_ADC_MULTI_INDEPENDENT 0x00000000U /*!< ADC dual mode disabled (ADC independent mode) */
  775. #define LL_ADC_MULTI_DUAL_REG_SIMULT ( ADC_CR1_DUALMOD_2 | ADC_CR1_DUALMOD_1 ) /*!< ADC dual mode enabled: group regular simultaneous */
  776. #define LL_ADC_MULTI_DUAL_REG_INTERL_FAST ( ADC_CR1_DUALMOD_2 | ADC_CR1_DUALMOD_1 | ADC_CR1_DUALMOD_0) /*!< ADC dual mode enabled: Combined group regular interleaved fast (delay between ADC sampling phases: 7 ADC clock cycles) (equivalent to multimode sampling delay set to "LL_ADC_MULTI_TWOSMP_DELAY_7CYCLES" on other STM32 devices)) */
  777. #define LL_ADC_MULTI_DUAL_REG_INTERL_SLOW (ADC_CR1_DUALMOD_3 ) /*!< ADC dual mode enabled: Combined group regular interleaved slow (delay between ADC sampling phases: 14 ADC clock cycles) (equivalent to multimode sampling delay set to "LL_ADC_MULTI_TWOSMP_DELAY_14CYCLES" on other STM32 devices)) */
  778. #define LL_ADC_MULTI_DUAL_INJ_SIMULT ( ADC_CR1_DUALMOD_2 | ADC_CR1_DUALMOD_0) /*!< ADC dual mode enabled: group injected simultaneous slow (delay between ADC sampling phases: 14 ADC clock cycles) (equivalent to multimode sampling delay set to "LL_ADC_MULTI_TWOSMP_DELAY_14CYCLES" on other STM32 devices)) */
  779. #define LL_ADC_MULTI_DUAL_INJ_ALTERN (ADC_CR1_DUALMOD_3 | ADC_CR1_DUALMOD_0) /*!< ADC dual mode enabled: group injected alternate trigger. Works only with external triggers (not internal SW start) */
  780. #define LL_ADC_MULTI_DUAL_REG_SIM_INJ_SIM ( ADC_CR1_DUALMOD_0) /*!< ADC dual mode enabled: Combined group regular simultaneous + group injected simultaneous */
  781. #define LL_ADC_MULTI_DUAL_REG_SIM_INJ_ALT ( ADC_CR1_DUALMOD_1 ) /*!< ADC dual mode enabled: Combined group regular simultaneous + group injected alternate trigger */
  782. #define LL_ADC_MULTI_DUAL_REG_INTFAST_INJ_SIM ( ADC_CR1_DUALMOD_1 | ADC_CR1_DUALMOD_0) /*!< ADC dual mode enabled: Combined group regular interleaved fast (delay between ADC sampling phases: 7 ADC clock cycles) + group injected simultaneous */
  783. #define LL_ADC_MULTI_DUAL_REG_INTSLOW_INJ_SIM ( ADC_CR1_DUALMOD_2 ) /*!< ADC dual mode enabled: Combined group regular interleaved slow (delay between ADC sampling phases: 14 ADC clock cycles) + group injected simultaneous */
  784. /**
  785. * @}
  786. */
  787. /** @defgroup ADC_LL_EC_MULTI_MASTER_SLAVE Multimode - ADC master or slave
  788. * @{
  789. */
  790. #define LL_ADC_MULTI_MASTER ( ADC_DR_DATA) /*!< In multimode, selection among several ADC instances: ADC master */
  791. #define LL_ADC_MULTI_SLAVE (ADC_DR_ADC2DATA ) /*!< In multimode, selection among several ADC instances: ADC slave */
  792. #define LL_ADC_MULTI_MASTER_SLAVE (ADC_DR_ADC2DATA | ADC_DR_DATA) /*!< In multimode, selection among several ADC instances: both ADC master and ADC slave */
  793. /**
  794. * @}
  795. */
  796. #endif /* ADC_MULTIMODE_SUPPORT */
  797. /** @defgroup ADC_LL_EC_HW_DELAYS Definitions of ADC hardware constraints delays
  798. * @note Only ADC IP HW delays are defined in ADC LL driver driver,
  799. * not timeout values.
  800. * For details on delays values, refer to descriptions in source code
  801. * above each literal definition.
  802. * @{
  803. */
  804. /* Note: Only ADC IP HW delays are defined in ADC LL driver driver, */
  805. /* not timeout values. */
  806. /* Timeout values for ADC operations are dependent to device clock */
  807. /* configuration (system clock versus ADC clock), */
  808. /* and therefore must be defined in user application. */
  809. /* Indications for estimation of ADC timeout delays, for this */
  810. /* STM32 serie: */
  811. /* - ADC enable time: maximum delay is 1us */
  812. /* (refer to device datasheet, parameter "tSTAB") */
  813. /* - ADC conversion time: duration depending on ADC clock and ADC */
  814. /* configuration. */
  815. /* (refer to device reference manual, section "Timing") */
  816. /* Delay for temperature sensor stabilization time. */
  817. /* Literal set to maximum value (refer to device datasheet, */
  818. /* parameter "tSTART"). */
  819. /* Unit: us */
  820. #define LL_ADC_DELAY_TEMPSENSOR_STAB_US (10U) /*!< Delay for internal voltage reference stabilization time */
  821. /* Delay required between ADC disable and ADC calibration start. */
  822. /* Note: On this STM32 serie, before starting a calibration, */
  823. /* ADC must be disabled. */
  824. /* A minimum number of ADC clock cycles are required */
  825. /* between ADC disable state and calibration start. */
  826. /* Refer to literal @ref LL_ADC_DELAY_ENABLE_CALIB_ADC_CYCLES. */
  827. /* Wait time can be computed in user application by waiting for the */
  828. /* equivalent number of CPU cycles, by taking into account */
  829. /* ratio of CPU clock versus ADC clock prescalers. */
  830. /* Unit: ADC clock cycles. */
  831. #define LL_ADC_DELAY_DISABLE_CALIB_ADC_CYCLES (2U) /*!< Delay required between ADC disable and ADC calibration start */
  832. /* Delay required between end of ADC Enable and the start of ADC calibration. */
  833. /* Note: On this STM32 serie, a minimum number of ADC clock cycles */
  834. /* are required between the end of ADC enable and the start of ADC */
  835. /* calibration. */
  836. /* Wait time can be computed in user application by waiting for the */
  837. /* equivalent number of CPU cycles, by taking into account */
  838. /* ratio of CPU clock versus ADC clock prescalers. */
  839. /* Unit: ADC clock cycles. */
  840. #define LL_ADC_DELAY_ENABLE_CALIB_ADC_CYCLES (2U) /*!< Delay required between end of ADC enable and the start of ADC calibration */
  841. /**
  842. * @}
  843. */
  844. /**
  845. * @}
  846. */
  847. /* Exported macro ------------------------------------------------------------*/
  848. /** @defgroup ADC_LL_Exported_Macros ADC Exported Macros
  849. * @{
  850. */
  851. /** @defgroup ADC_LL_EM_WRITE_READ Common write and read registers Macros
  852. * @{
  853. */
  854. /**
  855. * @brief Write a value in ADC register
  856. * @param __INSTANCE__ ADC Instance
  857. * @param __REG__ Register to be written
  858. * @param __VALUE__ Value to be written in the register
  859. * @retval None
  860. */
  861. #define LL_ADC_WriteReg(__INSTANCE__, __REG__, __VALUE__) WRITE_REG(__INSTANCE__->__REG__, (__VALUE__))
  862. /**
  863. * @brief Read a value in ADC register
  864. * @param __INSTANCE__ ADC Instance
  865. * @param __REG__ Register to be read
  866. * @retval Register value
  867. */
  868. #define LL_ADC_ReadReg(__INSTANCE__, __REG__) READ_REG(__INSTANCE__->__REG__)
  869. /**
  870. * @}
  871. */
  872. /** @defgroup ADC_LL_EM_HELPER_MACRO ADC helper macro
  873. * @{
  874. */
  875. /**
  876. * @brief Helper macro to get ADC channel number in decimal format
  877. * from literals LL_ADC_CHANNEL_x.
  878. * @note Example:
  879. * __LL_ADC_CHANNEL_TO_DECIMAL_NB(LL_ADC_CHANNEL_4)
  880. * will return decimal number "4".
  881. * @note The input can be a value from functions where a channel
  882. * number is returned, either defined with number
  883. * or with bitfield (only one bit must be set).
  884. * @param __CHANNEL__ This parameter can be one of the following values:
  885. * @arg @ref LL_ADC_CHANNEL_0
  886. * @arg @ref LL_ADC_CHANNEL_1
  887. * @arg @ref LL_ADC_CHANNEL_2
  888. * @arg @ref LL_ADC_CHANNEL_3
  889. * @arg @ref LL_ADC_CHANNEL_4
  890. * @arg @ref LL_ADC_CHANNEL_5
  891. * @arg @ref LL_ADC_CHANNEL_6
  892. * @arg @ref LL_ADC_CHANNEL_7
  893. * @arg @ref LL_ADC_CHANNEL_8
  894. * @arg @ref LL_ADC_CHANNEL_9
  895. * @arg @ref LL_ADC_CHANNEL_10
  896. * @arg @ref LL_ADC_CHANNEL_11
  897. * @arg @ref LL_ADC_CHANNEL_12
  898. * @arg @ref LL_ADC_CHANNEL_13
  899. * @arg @ref LL_ADC_CHANNEL_14
  900. * @arg @ref LL_ADC_CHANNEL_15
  901. * @arg @ref LL_ADC_CHANNEL_16
  902. * @arg @ref LL_ADC_CHANNEL_17
  903. * @arg @ref LL_ADC_CHANNEL_VREFINT (1)
  904. * @arg @ref LL_ADC_CHANNEL_TEMPSENSOR (1)
  905. *
  906. * (1) On STM32F1, parameter available only on ADC instance: ADC1.
  907. * @retval Value between Min_Data=0 and Max_Data=18
  908. */
  909. #define __LL_ADC_CHANNEL_TO_DECIMAL_NB(__CHANNEL__) \
  910. (((__CHANNEL__) & ADC_CHANNEL_ID_NUMBER_MASK) >> ADC_CHANNEL_ID_NUMBER_BITOFFSET_POS)
  911. /**
  912. * @brief Helper macro to get ADC channel in literal format LL_ADC_CHANNEL_x
  913. * from number in decimal format.
  914. * @note Example:
  915. * __LL_ADC_DECIMAL_NB_TO_CHANNEL(4)
  916. * will return a data equivalent to "LL_ADC_CHANNEL_4".
  917. * @param __DECIMAL_NB__: Value between Min_Data=0 and Max_Data=18
  918. * @retval Returned value can be one of the following values:
  919. * @arg @ref LL_ADC_CHANNEL_0
  920. * @arg @ref LL_ADC_CHANNEL_1
  921. * @arg @ref LL_ADC_CHANNEL_2
  922. * @arg @ref LL_ADC_CHANNEL_3
  923. * @arg @ref LL_ADC_CHANNEL_4
  924. * @arg @ref LL_ADC_CHANNEL_5
  925. * @arg @ref LL_ADC_CHANNEL_6
  926. * @arg @ref LL_ADC_CHANNEL_7
  927. * @arg @ref LL_ADC_CHANNEL_8
  928. * @arg @ref LL_ADC_CHANNEL_9
  929. * @arg @ref LL_ADC_CHANNEL_10
  930. * @arg @ref LL_ADC_CHANNEL_11
  931. * @arg @ref LL_ADC_CHANNEL_12
  932. * @arg @ref LL_ADC_CHANNEL_13
  933. * @arg @ref LL_ADC_CHANNEL_14
  934. * @arg @ref LL_ADC_CHANNEL_15
  935. * @arg @ref LL_ADC_CHANNEL_16
  936. * @arg @ref LL_ADC_CHANNEL_17
  937. * @arg @ref LL_ADC_CHANNEL_VREFINT (1)
  938. * @arg @ref LL_ADC_CHANNEL_TEMPSENSOR (1)
  939. *
  940. * (1) On STM32F1, parameter available only on ADC instance: ADC1.\n
  941. * (1) For ADC channel read back from ADC register,
  942. * comparison with internal channel parameter to be done
  943. * using helper macro @ref __LL_ADC_CHANNEL_INTERNAL_TO_EXTERNAL().
  944. */
  945. #define __LL_ADC_DECIMAL_NB_TO_CHANNEL(__DECIMAL_NB__) \
  946. (((__DECIMAL_NB__) <= 9U) \
  947. ? ( \
  948. ((__DECIMAL_NB__) << ADC_CHANNEL_ID_NUMBER_BITOFFSET_POS) | \
  949. (ADC_SMPR2_REGOFFSET | (((uint32_t) (3U * (__DECIMAL_NB__))) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) \
  950. ) \
  951. : \
  952. ( \
  953. ((__DECIMAL_NB__) << ADC_CHANNEL_ID_NUMBER_BITOFFSET_POS) | \
  954. (ADC_SMPR1_REGOFFSET | (((uint32_t) (3U * ((__DECIMAL_NB__) - 10U))) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) \
  955. ) \
  956. )
  957. /**
  958. * @brief Helper macro to determine whether the selected channel
  959. * corresponds to literal definitions of driver.
  960. * @note The different literal definitions of ADC channels are:
  961. * - ADC internal channel:
  962. * LL_ADC_CHANNEL_VREFINT, LL_ADC_CHANNEL_TEMPSENSOR, ...
  963. * - ADC external channel (channel connected to a GPIO pin):
  964. * LL_ADC_CHANNEL_1, LL_ADC_CHANNEL_2, ...
  965. * @note The channel parameter must be a value defined from literal
  966. * definition of a ADC internal channel (LL_ADC_CHANNEL_VREFINT,
  967. * LL_ADC_CHANNEL_TEMPSENSOR, ...),
  968. * ADC external channel (LL_ADC_CHANNEL_1, LL_ADC_CHANNEL_2, ...),
  969. * must not be a value from functions where a channel number is
  970. * returned from ADC registers,
  971. * because internal and external channels share the same channel
  972. * number in ADC registers. The differentiation is made only with
  973. * parameters definitions of driver.
  974. * @param __CHANNEL__ This parameter can be one of the following values:
  975. * @arg @ref LL_ADC_CHANNEL_0
  976. * @arg @ref LL_ADC_CHANNEL_1
  977. * @arg @ref LL_ADC_CHANNEL_2
  978. * @arg @ref LL_ADC_CHANNEL_3
  979. * @arg @ref LL_ADC_CHANNEL_4
  980. * @arg @ref LL_ADC_CHANNEL_5
  981. * @arg @ref LL_ADC_CHANNEL_6
  982. * @arg @ref LL_ADC_CHANNEL_7
  983. * @arg @ref LL_ADC_CHANNEL_8
  984. * @arg @ref LL_ADC_CHANNEL_9
  985. * @arg @ref LL_ADC_CHANNEL_10
  986. * @arg @ref LL_ADC_CHANNEL_11
  987. * @arg @ref LL_ADC_CHANNEL_12
  988. * @arg @ref LL_ADC_CHANNEL_13
  989. * @arg @ref LL_ADC_CHANNEL_14
  990. * @arg @ref LL_ADC_CHANNEL_15
  991. * @arg @ref LL_ADC_CHANNEL_16
  992. * @arg @ref LL_ADC_CHANNEL_17
  993. * @arg @ref LL_ADC_CHANNEL_VREFINT (1)
  994. * @arg @ref LL_ADC_CHANNEL_TEMPSENSOR (1)
  995. *
  996. * (1) On STM32F1, parameter available only on ADC instance: ADC1.
  997. * @retval Value "0" if the channel corresponds to a parameter definition of a ADC external channel (channel connected to a GPIO pin).
  998. * Value "1" if the channel corresponds to a parameter definition of a ADC internal channel.
  999. */
  1000. #define __LL_ADC_IS_CHANNEL_INTERNAL(__CHANNEL__) \
  1001. (((__CHANNEL__) & ADC_CHANNEL_ID_INTERNAL_CH_MASK) != 0U)
  1002. /**
  1003. * @brief Helper macro to convert a channel defined from parameter
  1004. * definition of a ADC internal channel (LL_ADC_CHANNEL_VREFINT,
  1005. * LL_ADC_CHANNEL_TEMPSENSOR, ...),
  1006. * to its equivalent parameter definition of a ADC external channel
  1007. * (LL_ADC_CHANNEL_1, LL_ADC_CHANNEL_2, ...).
  1008. * @note The channel parameter can be, additionally to a value
  1009. * defined from parameter definition of a ADC internal channel
  1010. * (LL_ADC_CHANNEL_VREFINT, LL_ADC_CHANNEL_TEMPSENSOR, ...),
  1011. * a value defined from parameter definition of
  1012. * ADC external channel (LL_ADC_CHANNEL_1, LL_ADC_CHANNEL_2, ...)
  1013. * or a value from functions where a channel number is returned
  1014. * from ADC registers.
  1015. * @param __CHANNEL__ This parameter can be one of the following values:
  1016. * @arg @ref LL_ADC_CHANNEL_0
  1017. * @arg @ref LL_ADC_CHANNEL_1
  1018. * @arg @ref LL_ADC_CHANNEL_2
  1019. * @arg @ref LL_ADC_CHANNEL_3
  1020. * @arg @ref LL_ADC_CHANNEL_4
  1021. * @arg @ref LL_ADC_CHANNEL_5
  1022. * @arg @ref LL_ADC_CHANNEL_6
  1023. * @arg @ref LL_ADC_CHANNEL_7
  1024. * @arg @ref LL_ADC_CHANNEL_8
  1025. * @arg @ref LL_ADC_CHANNEL_9
  1026. * @arg @ref LL_ADC_CHANNEL_10
  1027. * @arg @ref LL_ADC_CHANNEL_11
  1028. * @arg @ref LL_ADC_CHANNEL_12
  1029. * @arg @ref LL_ADC_CHANNEL_13
  1030. * @arg @ref LL_ADC_CHANNEL_14
  1031. * @arg @ref LL_ADC_CHANNEL_15
  1032. * @arg @ref LL_ADC_CHANNEL_16
  1033. * @arg @ref LL_ADC_CHANNEL_17
  1034. * @arg @ref LL_ADC_CHANNEL_VREFINT (1)
  1035. * @arg @ref LL_ADC_CHANNEL_TEMPSENSOR (1)
  1036. *
  1037. * (1) On STM32F1, parameter available only on ADC instance: ADC1.
  1038. * @retval Returned value can be one of the following values:
  1039. * @arg @ref LL_ADC_CHANNEL_0
  1040. * @arg @ref LL_ADC_CHANNEL_1
  1041. * @arg @ref LL_ADC_CHANNEL_2
  1042. * @arg @ref LL_ADC_CHANNEL_3
  1043. * @arg @ref LL_ADC_CHANNEL_4
  1044. * @arg @ref LL_ADC_CHANNEL_5
  1045. * @arg @ref LL_ADC_CHANNEL_6
  1046. * @arg @ref LL_ADC_CHANNEL_7
  1047. * @arg @ref LL_ADC_CHANNEL_8
  1048. * @arg @ref LL_ADC_CHANNEL_9
  1049. * @arg @ref LL_ADC_CHANNEL_10
  1050. * @arg @ref LL_ADC_CHANNEL_11
  1051. * @arg @ref LL_ADC_CHANNEL_12
  1052. * @arg @ref LL_ADC_CHANNEL_13
  1053. * @arg @ref LL_ADC_CHANNEL_14
  1054. * @arg @ref LL_ADC_CHANNEL_15
  1055. * @arg @ref LL_ADC_CHANNEL_16
  1056. * @arg @ref LL_ADC_CHANNEL_17
  1057. */
  1058. #define __LL_ADC_CHANNEL_INTERNAL_TO_EXTERNAL(__CHANNEL__) \
  1059. ((__CHANNEL__) & ~ADC_CHANNEL_ID_INTERNAL_CH_MASK)
  1060. /**
  1061. * @brief Helper macro to determine whether the internal channel
  1062. * selected is available on the ADC instance selected.
  1063. * @note The channel parameter must be a value defined from parameter
  1064. * definition of a ADC internal channel (LL_ADC_CHANNEL_VREFINT,
  1065. * LL_ADC_CHANNEL_TEMPSENSOR, ...),
  1066. * must not be a value defined from parameter definition of
  1067. * ADC external channel (LL_ADC_CHANNEL_1, LL_ADC_CHANNEL_2, ...)
  1068. * or a value from functions where a channel number is
  1069. * returned from ADC registers,
  1070. * because internal and external channels share the same channel
  1071. * number in ADC registers. The differentiation is made only with
  1072. * parameters definitions of driver.
  1073. * @param __ADC_INSTANCE__ ADC instance
  1074. * @param __CHANNEL__ This parameter can be one of the following values:
  1075. * @arg @ref LL_ADC_CHANNEL_VREFINT (1)
  1076. * @arg @ref LL_ADC_CHANNEL_TEMPSENSOR (1)
  1077. *
  1078. * (1) On STM32F1, parameter available only on ADC instance: ADC1.
  1079. * @retval Value "0" if the internal channel selected is not available on the ADC instance selected.
  1080. * Value "1" if the internal channel selected is available on the ADC instance selected.
  1081. */
  1082. #define __LL_ADC_IS_CHANNEL_INTERNAL_AVAILABLE(__ADC_INSTANCE__, __CHANNEL__) \
  1083. (((__ADC_INSTANCE__) == ADC1) \
  1084. ? ( \
  1085. ((__CHANNEL__) == LL_ADC_CHANNEL_VREFINT) || \
  1086. ((__CHANNEL__) == LL_ADC_CHANNEL_TEMPSENSOR) \
  1087. ) \
  1088. : \
  1089. (0U) \
  1090. )
  1091. /**
  1092. * @brief Helper macro to define ADC analog watchdog parameter:
  1093. * define a single channel to monitor with analog watchdog
  1094. * from sequencer channel and groups definition.
  1095. * @note To be used with function @ref LL_ADC_SetAnalogWDMonitChannels().
  1096. * Example:
  1097. * LL_ADC_SetAnalogWDMonitChannels(
  1098. * ADC1, LL_ADC_AWD1,
  1099. * __LL_ADC_ANALOGWD_CHANNEL_GROUP(LL_ADC_CHANNEL4, LL_ADC_GROUP_REGULAR))
  1100. * @param __CHANNEL__ This parameter can be one of the following values:
  1101. * @arg @ref LL_ADC_CHANNEL_0
  1102. * @arg @ref LL_ADC_CHANNEL_1
  1103. * @arg @ref LL_ADC_CHANNEL_2
  1104. * @arg @ref LL_ADC_CHANNEL_3
  1105. * @arg @ref LL_ADC_CHANNEL_4
  1106. * @arg @ref LL_ADC_CHANNEL_5
  1107. * @arg @ref LL_ADC_CHANNEL_6
  1108. * @arg @ref LL_ADC_CHANNEL_7
  1109. * @arg @ref LL_ADC_CHANNEL_8
  1110. * @arg @ref LL_ADC_CHANNEL_9
  1111. * @arg @ref LL_ADC_CHANNEL_10
  1112. * @arg @ref LL_ADC_CHANNEL_11
  1113. * @arg @ref LL_ADC_CHANNEL_12
  1114. * @arg @ref LL_ADC_CHANNEL_13
  1115. * @arg @ref LL_ADC_CHANNEL_14
  1116. * @arg @ref LL_ADC_CHANNEL_15
  1117. * @arg @ref LL_ADC_CHANNEL_16
  1118. * @arg @ref LL_ADC_CHANNEL_17
  1119. * @arg @ref LL_ADC_CHANNEL_VREFINT (1)
  1120. * @arg @ref LL_ADC_CHANNEL_TEMPSENSOR (1)
  1121. *
  1122. * (1) On STM32F1, parameter available only on ADC instance: ADC1.\n
  1123. * (1) For ADC channel read back from ADC register,
  1124. * comparison with internal channel parameter to be done
  1125. * using helper macro @ref __LL_ADC_CHANNEL_INTERNAL_TO_EXTERNAL().
  1126. * @param __GROUP__ This parameter can be one of the following values:
  1127. * @arg @ref LL_ADC_GROUP_REGULAR
  1128. * @arg @ref LL_ADC_GROUP_INJECTED
  1129. * @arg @ref LL_ADC_GROUP_REGULAR_INJECTED
  1130. * @retval Returned value can be one of the following values:
  1131. * @arg @ref LL_ADC_AWD_DISABLE
  1132. * @arg @ref LL_ADC_AWD_ALL_CHANNELS_REG
  1133. * @arg @ref LL_ADC_AWD_ALL_CHANNELS_INJ
  1134. * @arg @ref LL_ADC_AWD_ALL_CHANNELS_REG_INJ
  1135. * @arg @ref LL_ADC_AWD_CHANNEL_0_REG
  1136. * @arg @ref LL_ADC_AWD_CHANNEL_0_INJ
  1137. * @arg @ref LL_ADC_AWD_CHANNEL_0_REG_INJ
  1138. * @arg @ref LL_ADC_AWD_CHANNEL_1_REG
  1139. * @arg @ref LL_ADC_AWD_CHANNEL_1_INJ
  1140. * @arg @ref LL_ADC_AWD_CHANNEL_1_REG_INJ
  1141. * @arg @ref LL_ADC_AWD_CHANNEL_2_REG
  1142. * @arg @ref LL_ADC_AWD_CHANNEL_2_INJ
  1143. * @arg @ref LL_ADC_AWD_CHANNEL_2_REG_INJ
  1144. * @arg @ref LL_ADC_AWD_CHANNEL_3_REG
  1145. * @arg @ref LL_ADC_AWD_CHANNEL_3_INJ
  1146. * @arg @ref LL_ADC_AWD_CHANNEL_3_REG_INJ
  1147. * @arg @ref LL_ADC_AWD_CHANNEL_4_REG
  1148. * @arg @ref LL_ADC_AWD_CHANNEL_4_INJ
  1149. * @arg @ref LL_ADC_AWD_CHANNEL_4_REG_INJ
  1150. * @arg @ref LL_ADC_AWD_CHANNEL_5_REG
  1151. * @arg @ref LL_ADC_AWD_CHANNEL_5_INJ
  1152. * @arg @ref LL_ADC_AWD_CHANNEL_5_REG_INJ
  1153. * @arg @ref LL_ADC_AWD_CHANNEL_6_REG
  1154. * @arg @ref LL_ADC_AWD_CHANNEL_6_INJ
  1155. * @arg @ref LL_ADC_AWD_CHANNEL_6_REG_INJ
  1156. * @arg @ref LL_ADC_AWD_CHANNEL_7_REG
  1157. * @arg @ref LL_ADC_AWD_CHANNEL_7_INJ
  1158. * @arg @ref LL_ADC_AWD_CHANNEL_7_REG_INJ
  1159. * @arg @ref LL_ADC_AWD_CHANNEL_8_REG
  1160. * @arg @ref LL_ADC_AWD_CHANNEL_8_INJ
  1161. * @arg @ref LL_ADC_AWD_CHANNEL_8_REG_INJ
  1162. * @arg @ref LL_ADC_AWD_CHANNEL_9_REG
  1163. * @arg @ref LL_ADC_AWD_CHANNEL_9_INJ
  1164. * @arg @ref LL_ADC_AWD_CHANNEL_9_REG_INJ
  1165. * @arg @ref LL_ADC_AWD_CHANNEL_10_REG
  1166. * @arg @ref LL_ADC_AWD_CHANNEL_10_INJ
  1167. * @arg @ref LL_ADC_AWD_CHANNEL_10_REG_INJ
  1168. * @arg @ref LL_ADC_AWD_CHANNEL_11_REG
  1169. * @arg @ref LL_ADC_AWD_CHANNEL_11_INJ
  1170. * @arg @ref LL_ADC_AWD_CHANNEL_11_REG_INJ
  1171. * @arg @ref LL_ADC_AWD_CHANNEL_12_REG
  1172. * @arg @ref LL_ADC_AWD_CHANNEL_12_INJ
  1173. * @arg @ref LL_ADC_AWD_CHANNEL_12_REG_INJ
  1174. * @arg @ref LL_ADC_AWD_CHANNEL_13_REG
  1175. * @arg @ref LL_ADC_AWD_CHANNEL_13_INJ
  1176. * @arg @ref LL_ADC_AWD_CHANNEL_13_REG_INJ
  1177. * @arg @ref LL_ADC_AWD_CHANNEL_14_REG
  1178. * @arg @ref LL_ADC_AWD_CHANNEL_14_INJ
  1179. * @arg @ref LL_ADC_AWD_CHANNEL_14_REG_INJ
  1180. * @arg @ref LL_ADC_AWD_CHANNEL_15_REG
  1181. * @arg @ref LL_ADC_AWD_CHANNEL_15_INJ
  1182. * @arg @ref LL_ADC_AWD_CHANNEL_15_REG_INJ
  1183. * @arg @ref LL_ADC_AWD_CHANNEL_16_REG
  1184. * @arg @ref LL_ADC_AWD_CHANNEL_16_INJ
  1185. * @arg @ref LL_ADC_AWD_CHANNEL_16_REG_INJ
  1186. * @arg @ref LL_ADC_AWD_CHANNEL_17_REG
  1187. * @arg @ref LL_ADC_AWD_CHANNEL_17_INJ
  1188. * @arg @ref LL_ADC_AWD_CHANNEL_17_REG_INJ
  1189. * @arg @ref LL_ADC_AWD_CH_VREFINT_REG (1)
  1190. * @arg @ref LL_ADC_AWD_CH_VREFINT_INJ (1)
  1191. * @arg @ref LL_ADC_AWD_CH_VREFINT_REG_INJ (1)
  1192. * @arg @ref LL_ADC_AWD_CH_TEMPSENSOR_REG (1)
  1193. * @arg @ref LL_ADC_AWD_CH_TEMPSENSOR_INJ (1)
  1194. * @arg @ref LL_ADC_AWD_CH_TEMPSENSOR_REG_INJ (1)
  1195. *
  1196. * (1) On STM32F1, parameter available only on ADC instance: ADC1.
  1197. */
  1198. #define __LL_ADC_ANALOGWD_CHANNEL_GROUP(__CHANNEL__, __GROUP__) \
  1199. (((__GROUP__) == LL_ADC_GROUP_REGULAR) \
  1200. ? (((__CHANNEL__) & ADC_CHANNEL_ID_MASK) | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) \
  1201. : \
  1202. ((__GROUP__) == LL_ADC_GROUP_INJECTED) \
  1203. ? (((__CHANNEL__) & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDSGL) \
  1204. : \
  1205. (((__CHANNEL__) & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) \
  1206. )
  1207. /**
  1208. * @brief Helper macro to set the value of ADC analog watchdog threshold high
  1209. * or low in function of ADC resolution, when ADC resolution is
  1210. * different of 12 bits.
  1211. * @note To be used with function @ref LL_ADC_SetAnalogWDThresholds().
  1212. * Example, with a ADC resolution of 8 bits, to set the value of
  1213. * analog watchdog threshold high (on 8 bits):
  1214. * LL_ADC_SetAnalogWDThresholds
  1215. * (< ADCx param >,
  1216. * __LL_ADC_ANALOGWD_SET_THRESHOLD_RESOLUTION(LL_ADC_RESOLUTION_8B, <threshold_value_8_bits>)
  1217. * );
  1218. * @param __ADC_RESOLUTION__ This parameter can be one of the following values:
  1219. * @arg @ref LL_ADC_RESOLUTION_12B
  1220. * @param __AWD_THRESHOLD__ Value between Min_Data=0x000 and Max_Data=0xFFF
  1221. * @retval Value between Min_Data=0x000 and Max_Data=0xFFF
  1222. */
  1223. /* Note: On this STM32 serie, ADC is fixed to resolution 12 bits. */
  1224. /* This macro has been kept anyway for compatibility with other */
  1225. /* STM32 families featuring different ADC resolutions. */
  1226. #define __LL_ADC_ANALOGWD_SET_THRESHOLD_RESOLUTION(__ADC_RESOLUTION__, __AWD_THRESHOLD__) \
  1227. ((__AWD_THRESHOLD__) << (0U))
  1228. /**
  1229. * @brief Helper macro to get the value of ADC analog watchdog threshold high
  1230. * or low in function of ADC resolution, when ADC resolution is
  1231. * different of 12 bits.
  1232. * @note To be used with function @ref LL_ADC_GetAnalogWDThresholds().
  1233. * Example, with a ADC resolution of 8 bits, to get the value of
  1234. * analog watchdog threshold high (on 8 bits):
  1235. * < threshold_value_6_bits > = __LL_ADC_ANALOGWD_GET_THRESHOLD_RESOLUTION
  1236. * (LL_ADC_RESOLUTION_8B,
  1237. * LL_ADC_GetAnalogWDThresholds(<ADCx param>, LL_ADC_AWD_THRESHOLD_HIGH)
  1238. * );
  1239. * @param __ADC_RESOLUTION__ This parameter can be one of the following values:
  1240. * @arg @ref LL_ADC_RESOLUTION_12B
  1241. * @param __AWD_THRESHOLD_12_BITS__ Value between Min_Data=0x000 and Max_Data=0xFFF
  1242. * @retval Value between Min_Data=0x000 and Max_Data=0xFFF
  1243. */
  1244. /* Note: On this STM32 serie, ADC is fixed to resolution 12 bits. */
  1245. /* This macro has been kept anyway for compatibility with other */
  1246. /* STM32 families featuring different ADC resolutions. */
  1247. #define __LL_ADC_ANALOGWD_GET_THRESHOLD_RESOLUTION(__ADC_RESOLUTION__, __AWD_THRESHOLD_12_BITS__) \
  1248. (__AWD_THRESHOLD_12_BITS__)
  1249. #if defined(ADC_MULTIMODE_SUPPORT)
  1250. /**
  1251. * @brief Helper macro to get the ADC multimode conversion data of ADC master
  1252. * or ADC slave from raw value with both ADC conversion data concatenated.
  1253. * @note This macro is intended to be used when multimode transfer by DMA
  1254. * is enabled.
  1255. * In this case the transferred data need to processed with this macro
  1256. * to separate the conversion data of ADC master and ADC slave.
  1257. * @param __ADC_MULTI_MASTER_SLAVE__ This parameter can be one of the following values:
  1258. * @arg @ref LL_ADC_MULTI_MASTER
  1259. * @arg @ref LL_ADC_MULTI_SLAVE
  1260. * @param __ADC_MULTI_CONV_DATA__ Value between Min_Data=0x000 and Max_Data=0xFFF
  1261. * @retval Value between Min_Data=0x000 and Max_Data=0xFFF
  1262. */
  1263. #define __LL_ADC_MULTI_CONV_DATA_MASTER_SLAVE(__ADC_MULTI_MASTER_SLAVE__, __ADC_MULTI_CONV_DATA__) \
  1264. (((__ADC_MULTI_CONV_DATA__) >> POSITION_VAL((__ADC_MULTI_MASTER_SLAVE__))) & ADC_DR_DATA)
  1265. #endif
  1266. /**
  1267. * @brief Helper macro to select the ADC common instance
  1268. * to which is belonging the selected ADC instance.
  1269. * @note ADC common register instance can be used for:
  1270. * - Set parameters common to several ADC instances
  1271. * - Multimode (for devices with several ADC instances)
  1272. * Refer to functions having argument "ADCxy_COMMON" as parameter.
  1273. * @note On STM32F1, there is no common ADC instance.
  1274. * However, ADC instance ADC1 has a role of common ADC instance
  1275. * for ADC1 and ADC2:
  1276. * this instance is used to manage internal channels
  1277. * and multimode (these features are managed in ADC common
  1278. * instances on some other STM32 devices).
  1279. * ADC instance ADC3 (if available on the selected device)
  1280. * has no ADC common instance.
  1281. * @param __ADCx__ ADC instance
  1282. * @retval ADC common register instance
  1283. */
  1284. #if defined(ADC1) && defined(ADC2) && defined(ADC3)
  1285. #define __LL_ADC_COMMON_INSTANCE(__ADCx__) \
  1286. ((((__ADCx__) == ADC1) || ((__ADCx__) == ADC2)) \
  1287. ? ( \
  1288. (ADC12_COMMON) \
  1289. ) \
  1290. : \
  1291. ( \
  1292. (0U) \
  1293. ) \
  1294. )
  1295. #elif defined(ADC1) && defined(ADC2)
  1296. #define __LL_ADC_COMMON_INSTANCE(__ADCx__) \
  1297. (ADC12_COMMON)
  1298. #else
  1299. #define __LL_ADC_COMMON_INSTANCE(__ADCx__) \
  1300. (ADC1_COMMON)
  1301. #endif
  1302. /**
  1303. * @brief Helper macro to check if all ADC instances sharing the same
  1304. * ADC common instance are disabled.
  1305. * @note This check is required by functions with setting conditioned to
  1306. * ADC state:
  1307. * All ADC instances of the ADC common group must be disabled.
  1308. * Refer to functions having argument "ADCxy_COMMON" as parameter.
  1309. * @note On devices with only 1 ADC common instance, parameter of this macro
  1310. * is useless and can be ignored (parameter kept for compatibility
  1311. * with devices featuring several ADC common instances).
  1312. * @note On STM32F1, there is no common ADC instance.
  1313. * However, ADC instance ADC1 has a role of common ADC instance
  1314. * for ADC1 and ADC2:
  1315. * this instance is used to manage internal channels
  1316. * and multimode (these features are managed in ADC common
  1317. * instances on some other STM32 devices).
  1318. * ADC instance ADC3 (if available on the selected device)
  1319. * has no ADC common instance.
  1320. * @param __ADCXY_COMMON__ ADC common instance
  1321. * (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() )
  1322. * @retval Value "0" if all ADC instances sharing the same ADC common instance
  1323. * are disabled.
  1324. * Value "1" if at least one ADC instance sharing the same ADC common instance
  1325. * is enabled.
  1326. */
  1327. #if defined(ADC1) && defined(ADC2) && defined(ADC3)
  1328. #define __LL_ADC_IS_ENABLED_ALL_COMMON_INSTANCE(__ADCXY_COMMON__) \
  1329. (((__ADCXY_COMMON__) == ADC12_COMMON) \
  1330. ? ( \
  1331. (LL_ADC_IsEnabled(ADC1) | \
  1332. LL_ADC_IsEnabled(ADC2) ) \
  1333. ) \
  1334. : \
  1335. ( \
  1336. LL_ADC_IsEnabled(ADC3) \
  1337. ) \
  1338. )
  1339. #elif defined(ADC1) && defined(ADC2)
  1340. #define __LL_ADC_IS_ENABLED_ALL_COMMON_INSTANCE(__ADCXY_COMMON__) \
  1341. (LL_ADC_IsEnabled(ADC1) | \
  1342. LL_ADC_IsEnabled(ADC2) )
  1343. #else
  1344. #define __LL_ADC_IS_ENABLED_ALL_COMMON_INSTANCE(__ADCXY_COMMON__) \
  1345. LL_ADC_IsEnabled(ADC1)
  1346. #endif
  1347. /**
  1348. * @brief Helper macro to define the ADC conversion data full-scale digital
  1349. * value corresponding to the selected ADC resolution.
  1350. * @note ADC conversion data full-scale corresponds to voltage range
  1351. * determined by analog voltage references Vref+ and Vref-
  1352. * (refer to reference manual).
  1353. * @param __ADC_RESOLUTION__ This parameter can be one of the following values:
  1354. * @arg @ref LL_ADC_RESOLUTION_12B
  1355. * @retval ADC conversion data equivalent voltage value (unit: mVolt)
  1356. */
  1357. #define __LL_ADC_DIGITAL_SCALE(__ADC_RESOLUTION__) \
  1358. (0xFFFU)
  1359. /**
  1360. * @brief Helper macro to calculate the voltage (unit: mVolt)
  1361. * corresponding to a ADC conversion data (unit: digital value).
  1362. * @note Analog reference voltage (Vref+) must be known from
  1363. * user board environment or can be calculated using ADC measurement.
  1364. * @param __VREFANALOG_VOLTAGE__ Analog reference voltage (unit: mV)
  1365. * @param __ADC_DATA__ ADC conversion data (resolution 12 bits)
  1366. * (unit: digital value).
  1367. * @param __ADC_RESOLUTION__ This parameter can be one of the following values:
  1368. * @arg @ref LL_ADC_RESOLUTION_12B
  1369. * @retval ADC conversion data equivalent voltage value (unit: mVolt)
  1370. */
  1371. #define __LL_ADC_CALC_DATA_TO_VOLTAGE(__VREFANALOG_VOLTAGE__,\
  1372. __ADC_DATA__,\
  1373. __ADC_RESOLUTION__) \
  1374. ((__ADC_DATA__) * (__VREFANALOG_VOLTAGE__) \
  1375. / __LL_ADC_DIGITAL_SCALE(__ADC_RESOLUTION__) \
  1376. )
  1377. /**
  1378. * @brief Helper macro to calculate the temperature (unit: degree Celsius)
  1379. * from ADC conversion data of internal temperature sensor.
  1380. * @note Computation is using temperature sensor typical values
  1381. * (refer to device datasheet).
  1382. * @note Calculation formula:
  1383. * Temperature = (TS_TYP_CALx_VOLT(uV) - TS_ADC_DATA * Conversion_uV)
  1384. * / Avg_Slope + CALx_TEMP
  1385. * with TS_ADC_DATA = temperature sensor raw data measured by ADC
  1386. * (unit: digital value)
  1387. * Avg_Slope = temperature sensor slope
  1388. * (unit: uV/Degree Celsius)
  1389. * TS_TYP_CALx_VOLT = temperature sensor digital value at
  1390. * temperature CALx_TEMP (unit: mV)
  1391. * Caution: Calculation relevancy under reserve the temperature sensor
  1392. * of the current device has characteristics in line with
  1393. * datasheet typical values.
  1394. * If temperature sensor calibration values are available on
  1395. * on this device (presence of macro __LL_ADC_CALC_TEMPERATURE()),
  1396. * temperature calculation will be more accurate using
  1397. * helper macro @ref __LL_ADC_CALC_TEMPERATURE().
  1398. * @note As calculation input, the analog reference voltage (Vref+) must be
  1399. * defined as it impacts the ADC LSB equivalent voltage.
  1400. * @note Analog reference voltage (Vref+) must be known from
  1401. * user board environment or can be calculated using ADC measurement.
  1402. * @note ADC measurement data must correspond to a resolution of 12bits
  1403. * (full scale digital value 4095). If not the case, the data must be
  1404. * preliminarily rescaled to an equivalent resolution of 12 bits.
  1405. * @param __TEMPSENSOR_TYP_AVGSLOPE__ Device datasheet data: Temperature sensor slope typical value (unit: uV/DegCelsius).
  1406. * On STM32F1, refer to device datasheet parameter "Avg_Slope".
  1407. * @param __TEMPSENSOR_TYP_CALX_V__ Device datasheet data: Temperature sensor voltage typical value (at temperature and Vref+ defined in parameters below) (unit: mV).
  1408. * On STM32F1, refer to device datasheet parameter "V25".
  1409. * @param __TEMPSENSOR_CALX_TEMP__ Device datasheet data: Temperature at which temperature sensor voltage (see parameter above) is corresponding (unit: mV)
  1410. * @param __VREFANALOG_VOLTAGE__ Analog voltage reference (Vref+) voltage (unit: mV)
  1411. * @param __TEMPSENSOR_ADC_DATA__ ADC conversion data of internal temperature sensor (unit: digital value).
  1412. * @param __ADC_RESOLUTION__ ADC resolution at which internal temperature sensor voltage has been measured.
  1413. * This parameter can be one of the following values:
  1414. * @arg @ref LL_ADC_RESOLUTION_12B
  1415. * @retval Temperature (unit: degree Celsius)
  1416. */
  1417. #define __LL_ADC_CALC_TEMPERATURE_TYP_PARAMS(__TEMPSENSOR_TYP_AVGSLOPE__,\
  1418. __TEMPSENSOR_TYP_CALX_V__,\
  1419. __TEMPSENSOR_CALX_TEMP__,\
  1420. __VREFANALOG_VOLTAGE__,\
  1421. __TEMPSENSOR_ADC_DATA__,\
  1422. __ADC_RESOLUTION__) \
  1423. ((( ( \
  1424. (int32_t)(((__TEMPSENSOR_TYP_CALX_V__)) \
  1425. * 1000) \
  1426. - \
  1427. (int32_t)((((__TEMPSENSOR_ADC_DATA__) * (__VREFANALOG_VOLTAGE__)) \
  1428. / __LL_ADC_DIGITAL_SCALE(__ADC_RESOLUTION__)) \
  1429. * 1000) \
  1430. ) \
  1431. ) / (__TEMPSENSOR_TYP_AVGSLOPE__) \
  1432. ) + (__TEMPSENSOR_CALX_TEMP__) \
  1433. )
  1434. /**
  1435. * @}
  1436. */
  1437. /**
  1438. * @}
  1439. */
  1440. /* Exported functions --------------------------------------------------------*/
  1441. /** @defgroup ADC_LL_Exported_Functions ADC Exported Functions
  1442. * @{
  1443. */
  1444. /** @defgroup ADC_LL_EF_DMA_Management ADC DMA management
  1445. * @{
  1446. */
  1447. /* Note: LL ADC functions to set DMA transfer are located into sections of */
  1448. /* configuration of ADC instance, groups and multimode (if available): */
  1449. /* @ref LL_ADC_REG_SetDMATransfer(), ... */
  1450. /**
  1451. * @brief Function to help to configure DMA transfer from ADC: retrieve the
  1452. * ADC register address from ADC instance and a list of ADC registers
  1453. * intended to be used (most commonly) with DMA transfer.
  1454. * @note These ADC registers are data registers:
  1455. * when ADC conversion data is available in ADC data registers,
  1456. * ADC generates a DMA transfer request.
  1457. * @note This macro is intended to be used with LL DMA driver, refer to
  1458. * function "LL_DMA_ConfigAddresses()".
  1459. * Example:
  1460. * LL_DMA_ConfigAddresses(DMA1,
  1461. * LL_DMA_CHANNEL_1,
  1462. * LL_ADC_DMA_GetRegAddr(ADC1, LL_ADC_DMA_REG_REGULAR_DATA),
  1463. * (uint32_t)&< array or variable >,
  1464. * LL_DMA_DIRECTION_PERIPH_TO_MEMORY);
  1465. * @note For devices with several ADC: in multimode, some devices
  1466. * use a different data register outside of ADC instance scope
  1467. * (common data register). This macro manages this register difference,
  1468. * only ADC instance has to be set as parameter.
  1469. * @note On STM32F1, only ADC instances ADC1 and ADC3 have DMA transfer
  1470. * capability, not ADC2 (ADC2 and ADC3 instances not available on
  1471. * all devices).
  1472. * @note On STM32F1, multimode can be used only with ADC1 and ADC2, not ADC3.
  1473. * Therefore, the corresponding parameter of data transfer
  1474. * for multimode can be used only with ADC1 and ADC2.
  1475. * (ADC2 and ADC3 instances not available on all devices).
  1476. * @rmtoll DR DATA LL_ADC_DMA_GetRegAddr
  1477. * @param ADCx ADC instance
  1478. * @param Register This parameter can be one of the following values:
  1479. * @arg @ref LL_ADC_DMA_REG_REGULAR_DATA
  1480. * @arg @ref LL_ADC_DMA_REG_REGULAR_DATA_MULTI (1)
  1481. *
  1482. * (1) Available on devices with several ADC instances.
  1483. * @retval ADC register address
  1484. */
  1485. #if defined(ADC_MULTIMODE_SUPPORT)
  1486. __STATIC_INLINE uint32_t LL_ADC_DMA_GetRegAddr(ADC_TypeDef *ADCx, uint32_t Register)
  1487. {
  1488. register uint32_t data_reg_addr = 0U;
  1489. if (Register == LL_ADC_DMA_REG_REGULAR_DATA)
  1490. {
  1491. /* Retrieve address of register DR */
  1492. data_reg_addr = (uint32_t)&(ADCx->DR);
  1493. }
  1494. else /* (Register == LL_ADC_DMA_REG_REGULAR_DATA_MULTI) */
  1495. {
  1496. /* Retrieve address of register of multimode data */
  1497. data_reg_addr = (uint32_t)&(ADC12_COMMON->DR);
  1498. }
  1499. return data_reg_addr;
  1500. }
  1501. #else
  1502. __STATIC_INLINE uint32_t LL_ADC_DMA_GetRegAddr(ADC_TypeDef *ADCx, uint32_t Register)
  1503. {
  1504. /* Retrieve address of register DR */
  1505. return (uint32_t)&(ADCx->DR);
  1506. }
  1507. #endif
  1508. /**
  1509. * @}
  1510. */
  1511. /** @defgroup ADC_LL_EF_Configuration_ADC_Common Configuration of ADC hierarchical scope: common to several ADC instances
  1512. * @{
  1513. */
  1514. /**
  1515. * @brief Set parameter common to several ADC: measurement path to internal
  1516. * channels (VrefInt, temperature sensor, ...).
  1517. * @note One or several values can be selected.
  1518. * Example: (LL_ADC_PATH_INTERNAL_VREFINT |
  1519. * LL_ADC_PATH_INTERNAL_TEMPSENSOR)
  1520. * @note Stabilization time of measurement path to internal channel:
  1521. * After enabling internal paths, before starting ADC conversion,
  1522. * a delay is required for internal voltage reference and
  1523. * temperature sensor stabilization time.
  1524. * Refer to device datasheet.
  1525. * Refer to literal @ref LL_ADC_DELAY_TEMPSENSOR_STAB_US.
  1526. * @note ADC internal channel sampling time constraint:
  1527. * For ADC conversion of internal channels,
  1528. * a sampling time minimum value is required.
  1529. * Refer to device datasheet.
  1530. * @rmtoll CR2 TSVREFE LL_ADC_SetCommonPathInternalCh
  1531. * @param ADCxy_COMMON ADC common instance
  1532. * (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() )
  1533. * @param PathInternal This parameter can be a combination of the following values:
  1534. * @arg @ref LL_ADC_PATH_INTERNAL_NONE
  1535. * @arg @ref LL_ADC_PATH_INTERNAL_VREFINT
  1536. * @arg @ref LL_ADC_PATH_INTERNAL_TEMPSENSOR
  1537. * @retval None
  1538. */
  1539. __STATIC_INLINE void LL_ADC_SetCommonPathInternalCh(ADC_Common_TypeDef *ADCxy_COMMON, uint32_t PathInternal)
  1540. {
  1541. MODIFY_REG(ADCxy_COMMON->CR2, (ADC_CR2_TSVREFE), PathInternal);
  1542. }
  1543. /**
  1544. * @brief Get parameter common to several ADC: measurement path to internal
  1545. * channels (VrefInt, temperature sensor, ...).
  1546. * @note One or several values can be selected.
  1547. * Example: (LL_ADC_PATH_INTERNAL_VREFINT |
  1548. * LL_ADC_PATH_INTERNAL_TEMPSENSOR)
  1549. * @rmtoll CR2 TSVREFE LL_ADC_GetCommonPathInternalCh
  1550. * @param ADCxy_COMMON ADC common instance
  1551. * (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() )
  1552. * @retval Returned value can be a combination of the following values:
  1553. * @arg @ref LL_ADC_PATH_INTERNAL_NONE
  1554. * @arg @ref LL_ADC_PATH_INTERNAL_VREFINT
  1555. * @arg @ref LL_ADC_PATH_INTERNAL_TEMPSENSOR
  1556. */
  1557. __STATIC_INLINE uint32_t LL_ADC_GetCommonPathInternalCh(ADC_Common_TypeDef *ADCxy_COMMON)
  1558. {
  1559. return (uint32_t)(READ_BIT(ADCxy_COMMON->CR2, ADC_CR2_TSVREFE));
  1560. }
  1561. /**
  1562. * @}
  1563. */
  1564. /** @defgroup ADC_LL_EF_Configuration_ADC_Instance Configuration of ADC hierarchical scope: ADC instance
  1565. * @{
  1566. */
  1567. /**
  1568. * @brief Set ADC conversion data alignment.
  1569. * @note Refer to reference manual for alignments formats
  1570. * dependencies to ADC resolutions.
  1571. * @rmtoll CR2 ALIGN LL_ADC_SetDataAlignment
  1572. * @param ADCx ADC instance
  1573. * @param DataAlignment This parameter can be one of the following values:
  1574. * @arg @ref LL_ADC_DATA_ALIGN_RIGHT
  1575. * @arg @ref LL_ADC_DATA_ALIGN_LEFT
  1576. * @retval None
  1577. */
  1578. __STATIC_INLINE void LL_ADC_SetDataAlignment(ADC_TypeDef *ADCx, uint32_t DataAlignment)
  1579. {
  1580. MODIFY_REG(ADCx->CR2, ADC_CR2_ALIGN, DataAlignment);
  1581. }
  1582. /**
  1583. * @brief Get ADC conversion data alignment.
  1584. * @note Refer to reference manual for alignments formats
  1585. * dependencies to ADC resolutions.
  1586. * @rmtoll CR2 ALIGN LL_ADC_SetDataAlignment
  1587. * @param ADCx ADC instance
  1588. * @retval Returned value can be one of the following values:
  1589. * @arg @ref LL_ADC_DATA_ALIGN_RIGHT
  1590. * @arg @ref LL_ADC_DATA_ALIGN_LEFT
  1591. */
  1592. __STATIC_INLINE uint32_t LL_ADC_GetDataAlignment(ADC_TypeDef *ADCx)
  1593. {
  1594. return (uint32_t)(READ_BIT(ADCx->CR2, ADC_CR2_ALIGN));
  1595. }
  1596. /**
  1597. * @brief Set ADC sequencers scan mode, for all ADC groups
  1598. * (group regular, group injected).
  1599. * @note According to sequencers scan mode :
  1600. * - If disabled: ADC conversion is performed in unitary conversion
  1601. * mode (one channel converted, that defined in rank 1).
  1602. * Configuration of sequencers of all ADC groups
  1603. * (sequencer scan length, ...) is discarded: equivalent to
  1604. * scan length of 1 rank.
  1605. * - If enabled: ADC conversions are performed in sequence conversions
  1606. * mode, according to configuration of sequencers of
  1607. * each ADC group (sequencer scan length, ...).
  1608. * Refer to function @ref LL_ADC_REG_SetSequencerLength()
  1609. * and to function @ref LL_ADC_INJ_SetSequencerLength().
  1610. * @rmtoll CR1 SCAN LL_ADC_SetSequencersScanMode
  1611. * @param ADCx ADC instance
  1612. * @param ScanMode This parameter can be one of the following values:
  1613. * @arg @ref LL_ADC_SEQ_SCAN_DISABLE
  1614. * @arg @ref LL_ADC_SEQ_SCAN_ENABLE
  1615. * @retval None
  1616. */
  1617. __STATIC_INLINE void LL_ADC_SetSequencersScanMode(ADC_TypeDef *ADCx, uint32_t ScanMode)
  1618. {
  1619. MODIFY_REG(ADCx->CR1, ADC_CR1_SCAN, ScanMode);
  1620. }
  1621. /**
  1622. * @brief Get ADC sequencers scan mode, for all ADC groups
  1623. * (group regular, group injected).
  1624. * @note According to sequencers scan mode :
  1625. * - If disabled: ADC conversion is performed in unitary conversion
  1626. * mode (one channel converted, that defined in rank 1).
  1627. * Configuration of sequencers of all ADC groups
  1628. * (sequencer scan length, ...) is discarded: equivalent to
  1629. * scan length of 1 rank.
  1630. * - If enabled: ADC conversions are performed in sequence conversions
  1631. * mode, according to configuration of sequencers of
  1632. * each ADC group (sequencer scan length, ...).
  1633. * Refer to function @ref LL_ADC_REG_SetSequencerLength()
  1634. * and to function @ref LL_ADC_INJ_SetSequencerLength().
  1635. * @rmtoll CR1 SCAN LL_ADC_GetSequencersScanMode
  1636. * @param ADCx ADC instance
  1637. * @retval Returned value can be one of the following values:
  1638. * @arg @ref LL_ADC_SEQ_SCAN_DISABLE
  1639. * @arg @ref LL_ADC_SEQ_SCAN_ENABLE
  1640. */
  1641. __STATIC_INLINE uint32_t LL_ADC_GetSequencersScanMode(ADC_TypeDef *ADCx)
  1642. {
  1643. return (uint32_t)(READ_BIT(ADCx->CR1, ADC_CR1_SCAN));
  1644. }
  1645. /**
  1646. * @}
  1647. */
  1648. /** @defgroup ADC_LL_EF_Configuration_ADC_Group_Regular Configuration of ADC hierarchical scope: group regular
  1649. * @{
  1650. */
  1651. /**
  1652. * @brief Set ADC group regular conversion trigger source:
  1653. * internal (SW start) or from external IP (timer event,
  1654. * external interrupt line).
  1655. * @note On this STM32 serie, external trigger is set with trigger polarity:
  1656. * rising edge (only trigger polarity available on this STM32 serie).
  1657. * @note Availability of parameters of trigger sources from timer
  1658. * depends on timers availability on the selected device.
  1659. * @rmtoll CR2 EXTSEL LL_ADC_REG_SetTriggerSource
  1660. * @param ADCx ADC instance
  1661. * @param TriggerSource This parameter can be one of the following values:
  1662. * @arg @ref LL_ADC_REG_TRIG_SOFTWARE
  1663. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM1_CH3 (1)
  1664. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM1_CH1 (2)
  1665. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM1_CH2 (2)
  1666. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM2_CH2 (2)
  1667. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM3_TRGO (2)
  1668. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM4_CH4 (2)
  1669. * @arg @ref LL_ADC_REG_TRIG_EXT_EXTI_LINE11 (2)
  1670. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM8_TRGO (2)(4)
  1671. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM8_TRGO_ADC3 (3)
  1672. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM3_CH1 (3)
  1673. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM2_CH3 (3)
  1674. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM8_CH1 (3)
  1675. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM8_TRGO (3)
  1676. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM5_CH1 (3)
  1677. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM5_CH3 (3)
  1678. *
  1679. * (1) On STM32F1, parameter available on all ADC instances: ADC1, ADC2, ADC3 (for ADC instances ADCx available on the selected device).\n
  1680. * (2) On STM32F1, parameter available only on ADC instances: ADC1, ADC2 (for ADC instances ADCx available on the selected device).\n
  1681. * (3) On STM32F1, parameter available only on ADC instances: ADC3 (for ADC instances ADCx available on the selected device).\n
  1682. * (4) On STM32F1, parameter available only on high-density and XL-density devices. A remap of trigger must be done at top level (refer to AFIO peripheral).
  1683. * @retval None
  1684. */
  1685. __STATIC_INLINE void LL_ADC_REG_SetTriggerSource(ADC_TypeDef *ADCx, uint32_t TriggerSource)
  1686. {
  1687. /* Note: On this STM32 serie, ADC group regular external trigger edge */
  1688. /* is used to perform a ADC conversion start. */
  1689. /* This function does not set external trigger edge. */
  1690. /* This feature is set using function */
  1691. /* @ref LL_ADC_REG_StartConversionExtTrig(). */
  1692. MODIFY_REG(ADCx->CR2, ADC_CR2_EXTSEL, (TriggerSource & ADC_CR2_EXTSEL));
  1693. }
  1694. /**
  1695. * @brief Get ADC group regular conversion trigger source:
  1696. * internal (SW start) or from external IP (timer event,
  1697. * external interrupt line).
  1698. * @note To determine whether group regular trigger source is
  1699. * internal (SW start) or external, without detail
  1700. * of which peripheral is selected as external trigger,
  1701. * (equivalent to
  1702. * "if(LL_ADC_REG_GetTriggerSource(ADC1) == LL_ADC_REG_TRIG_SOFTWARE)")
  1703. * use function @ref LL_ADC_REG_IsTriggerSourceSWStart.
  1704. * @note Availability of parameters of trigger sources from timer
  1705. * depends on timers availability on the selected device.
  1706. * @rmtoll CR2 EXTSEL LL_ADC_REG_GetTriggerSource
  1707. * @param ADCx ADC instance
  1708. * @retval Returned value can be one of the following values:
  1709. * @arg @ref LL_ADC_REG_TRIG_SOFTWARE
  1710. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM1_CH3 (1)
  1711. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM1_CH1 (2)
  1712. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM1_CH2 (2)
  1713. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM2_CH2 (2)
  1714. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM3_TRGO (2)
  1715. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM4_CH4 (2)
  1716. * @arg @ref LL_ADC_REG_TRIG_EXT_EXTI_LINE11 (2)
  1717. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM8_TRGO (2)(4)
  1718. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM8_TRGO_ADC3 (3)
  1719. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM3_CH1 (3)
  1720. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM2_CH3 (3)
  1721. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM8_CH1 (3)
  1722. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM8_TRGO (3)
  1723. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM5_CH1 (3)
  1724. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM5_CH3 (3)
  1725. *
  1726. * (1) On STM32F1, parameter available on all ADC instances: ADC1, ADC2, ADC3 (for ADC instances ADCx available on the selected device).\n
  1727. * (2) On STM32F1, parameter available only on ADC instances: ADC1, ADC2 (for ADC instances ADCx available on the selected device).\n
  1728. * (3) On STM32F1, parameter available only on ADC instances: ADC3 (for ADC instances ADCx available on the selected device).\n
  1729. * (4) On STM32F1, parameter available only on high-density and XL-density devices. A remap of trigger must be done at top level (refer to AFIO peripheral).
  1730. */
  1731. __STATIC_INLINE uint32_t LL_ADC_REG_GetTriggerSource(ADC_TypeDef *ADCx)
  1732. {
  1733. return (uint32_t)(READ_BIT(ADCx->CR2, ADC_CR2_EXTSEL));
  1734. }
  1735. /**
  1736. * @brief Get ADC group regular conversion trigger source internal (SW start)
  1737. or external.
  1738. * @note In case of group regular trigger source set to external trigger,
  1739. * to determine which peripheral is selected as external trigger,
  1740. * use function @ref LL_ADC_REG_GetTriggerSource().
  1741. * @rmtoll CR2 EXTSEL LL_ADC_REG_IsTriggerSourceSWStart
  1742. * @param ADCx ADC instance
  1743. * @retval Value "0" if trigger source external trigger
  1744. * Value "1" if trigger source SW start.
  1745. */
  1746. __STATIC_INLINE uint32_t LL_ADC_REG_IsTriggerSourceSWStart(ADC_TypeDef *ADCx)
  1747. {
  1748. return (READ_BIT(ADCx->CR2, ADC_CR2_EXTSEL) == (LL_ADC_REG_TRIG_SOFTWARE));
  1749. }
  1750. /**
  1751. * @brief Set ADC group regular sequencer length and scan direction.
  1752. * @note Description of ADC group regular sequencer features:
  1753. * - For devices with sequencer fully configurable
  1754. * (function "LL_ADC_REG_SetSequencerRanks()" available):
  1755. * sequencer length and each rank affectation to a channel
  1756. * are configurable.
  1757. * This function performs configuration of:
  1758. * - Sequence length: Number of ranks in the scan sequence.
  1759. * - Sequence direction: Unless specified in parameters, sequencer
  1760. * scan direction is forward (from rank 1 to rank n).
  1761. * Sequencer ranks are selected using
  1762. * function "LL_ADC_REG_SetSequencerRanks()".
  1763. * - For devices with sequencer not fully configurable
  1764. * (function "LL_ADC_REG_SetSequencerChannels()" available):
  1765. * sequencer length and each rank affectation to a channel
  1766. * are defined by channel number.
  1767. * This function performs configuration of:
  1768. * - Sequence length: Number of ranks in the scan sequence is
  1769. * defined by number of channels set in the sequence,
  1770. * rank of each channel is fixed by channel HW number.
  1771. * (channel 0 fixed on rank 0, channel 1 fixed on rank1, ...).
  1772. * - Sequence direction: Unless specified in parameters, sequencer
  1773. * scan direction is forward (from lowest channel number to
  1774. * highest channel number).
  1775. * Sequencer ranks are selected using
  1776. * function "LL_ADC_REG_SetSequencerChannels()".
  1777. * @note On this STM32 serie, group regular sequencer configuration
  1778. * is conditioned to ADC instance sequencer mode.
  1779. * If ADC instance sequencer mode is disabled, sequencers of
  1780. * all groups (group regular, group injected) can be configured
  1781. * but their execution is disabled (limited to rank 1).
  1782. * Refer to function @ref LL_ADC_SetSequencersScanMode().
  1783. * @note Sequencer disabled is equivalent to sequencer of 1 rank:
  1784. * ADC conversion on only 1 channel.
  1785. * @rmtoll SQR1 L LL_ADC_REG_SetSequencerLength
  1786. * @param ADCx ADC instance
  1787. * @param SequencerNbRanks This parameter can be one of the following values:
  1788. * @arg @ref LL_ADC_REG_SEQ_SCAN_DISABLE
  1789. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_2RANKS
  1790. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_3RANKS
  1791. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_4RANKS
  1792. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_5RANKS
  1793. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_6RANKS
  1794. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_7RANKS
  1795. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_8RANKS
  1796. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_9RANKS
  1797. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_10RANKS
  1798. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_11RANKS
  1799. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_12RANKS
  1800. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_13RANKS
  1801. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_14RANKS
  1802. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_15RANKS
  1803. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_16RANKS
  1804. * @retval None
  1805. */
  1806. __STATIC_INLINE void LL_ADC_REG_SetSequencerLength(ADC_TypeDef *ADCx, uint32_t SequencerNbRanks)
  1807. {
  1808. MODIFY_REG(ADCx->SQR1, ADC_SQR1_L, SequencerNbRanks);
  1809. }
  1810. /**
  1811. * @brief Get ADC group regular sequencer length and scan direction.
  1812. * @note Description of ADC group regular sequencer features:
  1813. * - For devices with sequencer fully configurable
  1814. * (function "LL_ADC_REG_SetSequencerRanks()" available):
  1815. * sequencer length and each rank affectation to a channel
  1816. * are configurable.
  1817. * This function retrieves:
  1818. * - Sequence length: Number of ranks in the scan sequence.
  1819. * - Sequence direction: Unless specified in parameters, sequencer
  1820. * scan direction is forward (from rank 1 to rank n).
  1821. * Sequencer ranks are selected using
  1822. * function "LL_ADC_REG_SetSequencerRanks()".
  1823. * - For devices with sequencer not fully configurable
  1824. * (function "LL_ADC_REG_SetSequencerChannels()" available):
  1825. * sequencer length and each rank affectation to a channel
  1826. * are defined by channel number.
  1827. * This function retrieves:
  1828. * - Sequence length: Number of ranks in the scan sequence is
  1829. * defined by number of channels set in the sequence,
  1830. * rank of each channel is fixed by channel HW number.
  1831. * (channel 0 fixed on rank 0, channel 1 fixed on rank1, ...).
  1832. * - Sequence direction: Unless specified in parameters, sequencer
  1833. * scan direction is forward (from lowest channel number to
  1834. * highest channel number).
  1835. * Sequencer ranks are selected using
  1836. * function "LL_ADC_REG_SetSequencerChannels()".
  1837. * @note On this STM32 serie, group regular sequencer configuration
  1838. * is conditioned to ADC instance sequencer mode.
  1839. * If ADC instance sequencer mode is disabled, sequencers of
  1840. * all groups (group regular, group injected) can be configured
  1841. * but their execution is disabled (limited to rank 1).
  1842. * Refer to function @ref LL_ADC_SetSequencersScanMode().
  1843. * @note Sequencer disabled is equivalent to sequencer of 1 rank:
  1844. * ADC conversion on only 1 channel.
  1845. * @rmtoll SQR1 L LL_ADC_REG_SetSequencerLength
  1846. * @param ADCx ADC instance
  1847. * @retval Returned value can be one of the following values:
  1848. * @arg @ref LL_ADC_REG_SEQ_SCAN_DISABLE
  1849. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_2RANKS
  1850. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_3RANKS
  1851. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_4RANKS
  1852. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_5RANKS
  1853. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_6RANKS
  1854. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_7RANKS
  1855. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_8RANKS
  1856. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_9RANKS
  1857. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_10RANKS
  1858. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_11RANKS
  1859. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_12RANKS
  1860. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_13RANKS
  1861. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_14RANKS
  1862. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_15RANKS
  1863. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_16RANKS
  1864. */
  1865. __STATIC_INLINE uint32_t LL_ADC_REG_GetSequencerLength(ADC_TypeDef *ADCx)
  1866. {
  1867. return (uint32_t)(READ_BIT(ADCx->SQR1, ADC_SQR1_L));
  1868. }
  1869. /**
  1870. * @brief Set ADC group regular sequencer discontinuous mode:
  1871. * sequence subdivided and scan conversions interrupted every selected
  1872. * number of ranks.
  1873. * @note It is not possible to enable both ADC group regular
  1874. * continuous mode and sequencer discontinuous mode.
  1875. * @note It is not possible to enable both ADC auto-injected mode
  1876. * and ADC group regular sequencer discontinuous mode.
  1877. * @rmtoll CR1 DISCEN LL_ADC_REG_SetSequencerDiscont\n
  1878. * CR1 DISCNUM LL_ADC_REG_SetSequencerDiscont
  1879. * @param ADCx ADC instance
  1880. * @param SeqDiscont This parameter can be one of the following values:
  1881. * @arg @ref LL_ADC_REG_SEQ_DISCONT_DISABLE
  1882. * @arg @ref LL_ADC_REG_SEQ_DISCONT_1RANK
  1883. * @arg @ref LL_ADC_REG_SEQ_DISCONT_2RANKS
  1884. * @arg @ref LL_ADC_REG_SEQ_DISCONT_3RANKS
  1885. * @arg @ref LL_ADC_REG_SEQ_DISCONT_4RANKS
  1886. * @arg @ref LL_ADC_REG_SEQ_DISCONT_5RANKS
  1887. * @arg @ref LL_ADC_REG_SEQ_DISCONT_6RANKS
  1888. * @arg @ref LL_ADC_REG_SEQ_DISCONT_7RANKS
  1889. * @arg @ref LL_ADC_REG_SEQ_DISCONT_8RANKS
  1890. * @retval None
  1891. */
  1892. __STATIC_INLINE void LL_ADC_REG_SetSequencerDiscont(ADC_TypeDef *ADCx, uint32_t SeqDiscont)
  1893. {
  1894. MODIFY_REG(ADCx->CR1, ADC_CR1_DISCEN | ADC_CR1_DISCNUM, SeqDiscont);
  1895. }
  1896. /**
  1897. * @brief Get ADC group regular sequencer discontinuous mode:
  1898. * sequence subdivided and scan conversions interrupted every selected
  1899. * number of ranks.
  1900. * @rmtoll CR1 DISCEN LL_ADC_REG_GetSequencerDiscont\n
  1901. * CR1 DISCNUM LL_ADC_REG_GetSequencerDiscont
  1902. * @param ADCx ADC instance
  1903. * @retval Returned value can be one of the following values:
  1904. * @arg @ref LL_ADC_REG_SEQ_DISCONT_DISABLE
  1905. * @arg @ref LL_ADC_REG_SEQ_DISCONT_1RANK
  1906. * @arg @ref LL_ADC_REG_SEQ_DISCONT_2RANKS
  1907. * @arg @ref LL_ADC_REG_SEQ_DISCONT_3RANKS
  1908. * @arg @ref LL_ADC_REG_SEQ_DISCONT_4RANKS
  1909. * @arg @ref LL_ADC_REG_SEQ_DISCONT_5RANKS
  1910. * @arg @ref LL_ADC_REG_SEQ_DISCONT_6RANKS
  1911. * @arg @ref LL_ADC_REG_SEQ_DISCONT_7RANKS
  1912. * @arg @ref LL_ADC_REG_SEQ_DISCONT_8RANKS
  1913. */
  1914. __STATIC_INLINE uint32_t LL_ADC_REG_GetSequencerDiscont(ADC_TypeDef *ADCx)
  1915. {
  1916. return (uint32_t)(READ_BIT(ADCx->CR1, ADC_CR1_DISCEN | ADC_CR1_DISCNUM));
  1917. }
  1918. /**
  1919. * @brief Set ADC group regular sequence: channel on the selected
  1920. * scan sequence rank.
  1921. * @note This function performs configuration of:
  1922. * - Channels ordering into each rank of scan sequence:
  1923. * whatever channel can be placed into whatever rank.
  1924. * @note On this STM32 serie, ADC group regular sequencer is
  1925. * fully configurable: sequencer length and each rank
  1926. * affectation to a channel are configurable.
  1927. * Refer to description of function @ref LL_ADC_REG_SetSequencerLength().
  1928. * @note Depending on devices and packages, some channels may not be available.
  1929. * Refer to device datasheet for channels availability.
  1930. * @note On this STM32 serie, to measure internal channels (VrefInt,
  1931. * TempSensor, ...), measurement paths to internal channels must be
  1932. * enabled separately.
  1933. * This can be done using function @ref LL_ADC_SetCommonPathInternalCh().
  1934. * @rmtoll SQR3 SQ1 LL_ADC_REG_SetSequencerRanks\n
  1935. * SQR3 SQ2 LL_ADC_REG_SetSequencerRanks\n
  1936. * SQR3 SQ3 LL_ADC_REG_SetSequencerRanks\n
  1937. * SQR3 SQ4 LL_ADC_REG_SetSequencerRanks\n
  1938. * SQR3 SQ5 LL_ADC_REG_SetSequencerRanks\n
  1939. * SQR3 SQ6 LL_ADC_REG_SetSequencerRanks\n
  1940. * SQR2 SQ7 LL_ADC_REG_SetSequencerRanks\n
  1941. * SQR2 SQ8 LL_ADC_REG_SetSequencerRanks\n
  1942. * SQR2 SQ9 LL_ADC_REG_SetSequencerRanks\n
  1943. * SQR2 SQ10 LL_ADC_REG_SetSequencerRanks\n
  1944. * SQR2 SQ11 LL_ADC_REG_SetSequencerRanks\n
  1945. * SQR2 SQ12 LL_ADC_REG_SetSequencerRanks\n
  1946. * SQR1 SQ13 LL_ADC_REG_SetSequencerRanks\n
  1947. * SQR1 SQ14 LL_ADC_REG_SetSequencerRanks\n
  1948. * SQR1 SQ15 LL_ADC_REG_SetSequencerRanks\n
  1949. * SQR1 SQ16 LL_ADC_REG_SetSequencerRanks
  1950. * @param ADCx ADC instance
  1951. * @param Rank This parameter can be one of the following values:
  1952. * @arg @ref LL_ADC_REG_RANK_1
  1953. * @arg @ref LL_ADC_REG_RANK_2
  1954. * @arg @ref LL_ADC_REG_RANK_3
  1955. * @arg @ref LL_ADC_REG_RANK_4
  1956. * @arg @ref LL_ADC_REG_RANK_5
  1957. * @arg @ref LL_ADC_REG_RANK_6
  1958. * @arg @ref LL_ADC_REG_RANK_7
  1959. * @arg @ref LL_ADC_REG_RANK_8
  1960. * @arg @ref LL_ADC_REG_RANK_9
  1961. * @arg @ref LL_ADC_REG_RANK_10
  1962. * @arg @ref LL_ADC_REG_RANK_11
  1963. * @arg @ref LL_ADC_REG_RANK_12
  1964. * @arg @ref LL_ADC_REG_RANK_13
  1965. * @arg @ref LL_ADC_REG_RANK_14
  1966. * @arg @ref LL_ADC_REG_RANK_15
  1967. * @arg @ref LL_ADC_REG_RANK_16
  1968. * @param Channel This parameter can be one of the following values:
  1969. * @arg @ref LL_ADC_CHANNEL_0
  1970. * @arg @ref LL_ADC_CHANNEL_1
  1971. * @arg @ref LL_ADC_CHANNEL_2
  1972. * @arg @ref LL_ADC_CHANNEL_3
  1973. * @arg @ref LL_ADC_CHANNEL_4
  1974. * @arg @ref LL_ADC_CHANNEL_5
  1975. * @arg @ref LL_ADC_CHANNEL_6
  1976. * @arg @ref LL_ADC_CHANNEL_7
  1977. * @arg @ref LL_ADC_CHANNEL_8
  1978. * @arg @ref LL_ADC_CHANNEL_9
  1979. * @arg @ref LL_ADC_CHANNEL_10
  1980. * @arg @ref LL_ADC_CHANNEL_11
  1981. * @arg @ref LL_ADC_CHANNEL_12
  1982. * @arg @ref LL_ADC_CHANNEL_13
  1983. * @arg @ref LL_ADC_CHANNEL_14
  1984. * @arg @ref LL_ADC_CHANNEL_15
  1985. * @arg @ref LL_ADC_CHANNEL_16
  1986. * @arg @ref LL_ADC_CHANNEL_17
  1987. * @arg @ref LL_ADC_CHANNEL_VREFINT (1)
  1988. * @arg @ref LL_ADC_CHANNEL_TEMPSENSOR (1)
  1989. *
  1990. * (1) On STM32F1, parameter available only on ADC instance: ADC1.
  1991. * @retval None
  1992. */
  1993. __STATIC_INLINE void LL_ADC_REG_SetSequencerRanks(ADC_TypeDef *ADCx, uint32_t Rank, uint32_t Channel)
  1994. {
  1995. /* Set bits with content of parameter "Channel" with bits position */
  1996. /* in register and register position depending on parameter "Rank". */
  1997. /* Parameters "Rank" and "Channel" are used with masks because containing */
  1998. /* other bits reserved for other purpose. */
  1999. register uint32_t *preg = __ADC_PTR_REG_OFFSET(ADCx->SQR1, __ADC_MASK_SHIFT(Rank, ADC_REG_SQRX_REGOFFSET_MASK));
  2000. MODIFY_REG(*preg,
  2001. ADC_CHANNEL_ID_NUMBER_MASK << (Rank & ADC_REG_RANK_ID_SQRX_MASK),
  2002. (Channel & ADC_CHANNEL_ID_NUMBER_MASK) << (Rank & ADC_REG_RANK_ID_SQRX_MASK));
  2003. }
  2004. /**
  2005. * @brief Get ADC group regular sequence: channel on the selected
  2006. * scan sequence rank.
  2007. * @note On this STM32 serie, ADC group regular sequencer is
  2008. * fully configurable: sequencer length and each rank
  2009. * affectation to a channel are configurable.
  2010. * Refer to description of function @ref LL_ADC_REG_SetSequencerLength().
  2011. * @note Depending on devices and packages, some channels may not be available.
  2012. * Refer to device datasheet for channels availability.
  2013. * @note Usage of the returned channel number:
  2014. * - To reinject this channel into another function LL_ADC_xxx:
  2015. * the returned channel number is only partly formatted on definition
  2016. * of literals LL_ADC_CHANNEL_x. Therefore, it has to be compared
  2017. * with parts of literals LL_ADC_CHANNEL_x or using
  2018. * helper macro @ref __LL_ADC_CHANNEL_TO_DECIMAL_NB().
  2019. * Then the selected literal LL_ADC_CHANNEL_x can be used
  2020. * as parameter for another function.
  2021. * - To get the channel number in decimal format:
  2022. * process the returned value with the helper macro
  2023. * @ref __LL_ADC_CHANNEL_TO_DECIMAL_NB().
  2024. * @rmtoll SQR3 SQ1 LL_ADC_REG_GetSequencerRanks\n
  2025. * SQR3 SQ2 LL_ADC_REG_GetSequencerRanks\n
  2026. * SQR3 SQ3 LL_ADC_REG_GetSequencerRanks\n
  2027. * SQR3 SQ4 LL_ADC_REG_GetSequencerRanks\n
  2028. * SQR3 SQ5 LL_ADC_REG_GetSequencerRanks\n
  2029. * SQR3 SQ6 LL_ADC_REG_GetSequencerRanks\n
  2030. * SQR2 SQ7 LL_ADC_REG_GetSequencerRanks\n
  2031. * SQR2 SQ8 LL_ADC_REG_GetSequencerRanks\n
  2032. * SQR2 SQ9 LL_ADC_REG_GetSequencerRanks\n
  2033. * SQR2 SQ10 LL_ADC_REG_GetSequencerRanks\n
  2034. * SQR2 SQ11 LL_ADC_REG_GetSequencerRanks\n
  2035. * SQR2 SQ12 LL_ADC_REG_GetSequencerRanks\n
  2036. * SQR1 SQ13 LL_ADC_REG_GetSequencerRanks\n
  2037. * SQR1 SQ14 LL_ADC_REG_GetSequencerRanks\n
  2038. * SQR1 SQ15 LL_ADC_REG_GetSequencerRanks\n
  2039. * SQR1 SQ16 LL_ADC_REG_GetSequencerRanks
  2040. * @param ADCx ADC instance
  2041. * @param Rank This parameter can be one of the following values:
  2042. * @arg @ref LL_ADC_REG_RANK_1
  2043. * @arg @ref LL_ADC_REG_RANK_2
  2044. * @arg @ref LL_ADC_REG_RANK_3
  2045. * @arg @ref LL_ADC_REG_RANK_4
  2046. * @arg @ref LL_ADC_REG_RANK_5
  2047. * @arg @ref LL_ADC_REG_RANK_6
  2048. * @arg @ref LL_ADC_REG_RANK_7
  2049. * @arg @ref LL_ADC_REG_RANK_8
  2050. * @arg @ref LL_ADC_REG_RANK_9
  2051. * @arg @ref LL_ADC_REG_RANK_10
  2052. * @arg @ref LL_ADC_REG_RANK_11
  2053. * @arg @ref LL_ADC_REG_RANK_12
  2054. * @arg @ref LL_ADC_REG_RANK_13
  2055. * @arg @ref LL_ADC_REG_RANK_14
  2056. * @arg @ref LL_ADC_REG_RANK_15
  2057. * @arg @ref LL_ADC_REG_RANK_16
  2058. * @retval Returned value can be one of the following values:
  2059. * @arg @ref LL_ADC_CHANNEL_0
  2060. * @arg @ref LL_ADC_CHANNEL_1
  2061. * @arg @ref LL_ADC_CHANNEL_2
  2062. * @arg @ref LL_ADC_CHANNEL_3
  2063. * @arg @ref LL_ADC_CHANNEL_4
  2064. * @arg @ref LL_ADC_CHANNEL_5
  2065. * @arg @ref LL_ADC_CHANNEL_6
  2066. * @arg @ref LL_ADC_CHANNEL_7
  2067. * @arg @ref LL_ADC_CHANNEL_8
  2068. * @arg @ref LL_ADC_CHANNEL_9
  2069. * @arg @ref LL_ADC_CHANNEL_10
  2070. * @arg @ref LL_ADC_CHANNEL_11
  2071. * @arg @ref LL_ADC_CHANNEL_12
  2072. * @arg @ref LL_ADC_CHANNEL_13
  2073. * @arg @ref LL_ADC_CHANNEL_14
  2074. * @arg @ref LL_ADC_CHANNEL_15
  2075. * @arg @ref LL_ADC_CHANNEL_16
  2076. * @arg @ref LL_ADC_CHANNEL_17
  2077. * @arg @ref LL_ADC_CHANNEL_VREFINT (1)
  2078. * @arg @ref LL_ADC_CHANNEL_TEMPSENSOR (1)
  2079. *
  2080. * (1) On STM32F1, parameter available only on ADC instance: ADC1.\n
  2081. * (1) For ADC channel read back from ADC register,
  2082. * comparison with internal channel parameter to be done
  2083. * using helper macro @ref __LL_ADC_CHANNEL_INTERNAL_TO_EXTERNAL().
  2084. */
  2085. __STATIC_INLINE uint32_t LL_ADC_REG_GetSequencerRanks(ADC_TypeDef *ADCx, uint32_t Rank)
  2086. {
  2087. register uint32_t *preg = __ADC_PTR_REG_OFFSET(ADCx->SQR1, __ADC_MASK_SHIFT(Rank, ADC_REG_SQRX_REGOFFSET_MASK));
  2088. return (uint32_t) (READ_BIT(*preg,
  2089. ADC_CHANNEL_ID_NUMBER_MASK << (Rank & ADC_REG_RANK_ID_SQRX_MASK))
  2090. >> (Rank & ADC_REG_RANK_ID_SQRX_MASK)
  2091. );
  2092. }
  2093. /**
  2094. * @brief Set ADC continuous conversion mode on ADC group regular.
  2095. * @note Description of ADC continuous conversion mode:
  2096. * - single mode: one conversion per trigger
  2097. * - continuous mode: after the first trigger, following
  2098. * conversions launched successively automatically.
  2099. * @note It is not possible to enable both ADC group regular
  2100. * continuous mode and sequencer discontinuous mode.
  2101. * @rmtoll CR2 CONT LL_ADC_REG_SetContinuousMode
  2102. * @param ADCx ADC instance
  2103. * @param Continuous This parameter can be one of the following values:
  2104. * @arg @ref LL_ADC_REG_CONV_SINGLE
  2105. * @arg @ref LL_ADC_REG_CONV_CONTINUOUS
  2106. * @retval None
  2107. */
  2108. __STATIC_INLINE void LL_ADC_REG_SetContinuousMode(ADC_TypeDef *ADCx, uint32_t Continuous)
  2109. {
  2110. MODIFY_REG(ADCx->CR2, ADC_CR2_CONT, Continuous);
  2111. }
  2112. /**
  2113. * @brief Get ADC continuous conversion mode on ADC group regular.
  2114. * @note Description of ADC continuous conversion mode:
  2115. * - single mode: one conversion per trigger
  2116. * - continuous mode: after the first trigger, following
  2117. * conversions launched successively automatically.
  2118. * @rmtoll CR2 CONT LL_ADC_REG_GetContinuousMode
  2119. * @param ADCx ADC instance
  2120. * @retval Returned value can be one of the following values:
  2121. * @arg @ref LL_ADC_REG_CONV_SINGLE
  2122. * @arg @ref LL_ADC_REG_CONV_CONTINUOUS
  2123. */
  2124. __STATIC_INLINE uint32_t LL_ADC_REG_GetContinuousMode(ADC_TypeDef *ADCx)
  2125. {
  2126. return (uint32_t)(READ_BIT(ADCx->CR2, ADC_CR2_CONT));
  2127. }
  2128. /**
  2129. * @brief Set ADC group regular conversion data transfer: no transfer or
  2130. * transfer by DMA, and DMA requests mode.
  2131. * @note If transfer by DMA selected, specifies the DMA requests
  2132. * mode:
  2133. * - Limited mode (One shot mode): DMA transfer requests are stopped
  2134. * when number of DMA data transfers (number of
  2135. * ADC conversions) is reached.
  2136. * This ADC mode is intended to be used with DMA mode non-circular.
  2137. * - Unlimited mode: DMA transfer requests are unlimited,
  2138. * whatever number of DMA data transfers (number of
  2139. * ADC conversions).
  2140. * This ADC mode is intended to be used with DMA mode circular.
  2141. * @note If ADC DMA requests mode is set to unlimited and DMA is set to
  2142. * mode non-circular:
  2143. * when DMA transfers size will be reached, DMA will stop transfers of
  2144. * ADC conversions data ADC will raise an overrun error
  2145. * (overrun flag and interruption if enabled).
  2146. * @note To configure DMA source address (peripheral address),
  2147. * use function @ref LL_ADC_DMA_GetRegAddr().
  2148. * @rmtoll CR2 DMA LL_ADC_REG_SetDMATransfer
  2149. * @param ADCx ADC instance
  2150. * @param DMATransfer This parameter can be one of the following values:
  2151. * @arg @ref LL_ADC_REG_DMA_TRANSFER_NONE
  2152. * @arg @ref LL_ADC_REG_DMA_TRANSFER_UNLIMITED
  2153. * @retval None
  2154. */
  2155. __STATIC_INLINE void LL_ADC_REG_SetDMATransfer(ADC_TypeDef *ADCx, uint32_t DMATransfer)
  2156. {
  2157. MODIFY_REG(ADCx->CR2, ADC_CR2_DMA, DMATransfer);
  2158. }
  2159. /**
  2160. * @brief Get ADC group regular conversion data transfer: no transfer or
  2161. * transfer by DMA, and DMA requests mode.
  2162. * @note If transfer by DMA selected, specifies the DMA requests
  2163. * mode:
  2164. * - Limited mode (One shot mode): DMA transfer requests are stopped
  2165. * when number of DMA data transfers (number of
  2166. * ADC conversions) is reached.
  2167. * This ADC mode is intended to be used with DMA mode non-circular.
  2168. * - Unlimited mode: DMA transfer requests are unlimited,
  2169. * whatever number of DMA data transfers (number of
  2170. * ADC conversions).
  2171. * This ADC mode is intended to be used with DMA mode circular.
  2172. * @note If ADC DMA requests mode is set to unlimited and DMA is set to
  2173. * mode non-circular:
  2174. * when DMA transfers size will be reached, DMA will stop transfers of
  2175. * ADC conversions data ADC will raise an overrun error
  2176. * (overrun flag and interruption if enabled).
  2177. * @note To configure DMA source address (peripheral address),
  2178. * use function @ref LL_ADC_DMA_GetRegAddr().
  2179. * @rmtoll CR2 DMA LL_ADC_REG_GetDMATransfer
  2180. * @param ADCx ADC instance
  2181. * @retval Returned value can be one of the following values:
  2182. * @arg @ref LL_ADC_REG_DMA_TRANSFER_NONE
  2183. * @arg @ref LL_ADC_REG_DMA_TRANSFER_UNLIMITED
  2184. */
  2185. __STATIC_INLINE uint32_t LL_ADC_REG_GetDMATransfer(ADC_TypeDef *ADCx)
  2186. {
  2187. return (uint32_t)(READ_BIT(ADCx->CR2, ADC_CR2_DMA));
  2188. }
  2189. /**
  2190. * @}
  2191. */
  2192. /** @defgroup ADC_LL_EF_Configuration_ADC_Group_Injected Configuration of ADC hierarchical scope: group injected
  2193. * @{
  2194. */
  2195. /**
  2196. * @brief Set ADC group injected conversion trigger source:
  2197. * internal (SW start) or from external IP (timer event,
  2198. * external interrupt line).
  2199. * @note On this STM32 serie, external trigger is set with trigger polarity:
  2200. * rising edge (only trigger polarity available on this STM32 serie).
  2201. * @note Availability of parameters of trigger sources from timer
  2202. * depends on timers availability on the selected device.
  2203. * @rmtoll CR2 JEXTSEL LL_ADC_INJ_SetTriggerSource
  2204. * @param ADCx ADC instance
  2205. * @param TriggerSource This parameter can be one of the following values:
  2206. * @arg @ref LL_ADC_INJ_TRIG_SOFTWARE
  2207. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM1_TRGO (1)
  2208. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM1_CH4 (1)
  2209. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM2_TRGO (2)
  2210. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM2_CH1 (2)
  2211. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM3_CH4 (2)
  2212. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM4_TRGO (2)
  2213. * @arg @ref LL_ADC_INJ_TRIG_EXT_EXTI_LINE15 (2)
  2214. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM8_CH4 (2)(4)
  2215. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM8_CH4_ADC3 (3)
  2216. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM4_CH3 (3)
  2217. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM8_CH2 (3)
  2218. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM8_CH4 (3)
  2219. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM5_TRGO (3)
  2220. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM5_CH4 (3)
  2221. *
  2222. * (1) On STM32F1, parameter available on all ADC instances: ADC1, ADC2, ADC3 (for ADC instances ADCx available on the selected device).\n
  2223. * (2) On STM32F1, parameter available only on ADC instances: ADC1, ADC2 (for ADC instances ADCx available on the selected device).\n
  2224. * (3) On STM32F1, parameter available only on ADC instances: ADC3 (for ADC instances ADCx available on the selected device).\n
  2225. * (4) On STM32F1, parameter available only on high-density and XL-density devices. A remap of trigger must be done at top level (refer to AFIO peripheral).
  2226. * @retval None
  2227. */
  2228. __STATIC_INLINE void LL_ADC_INJ_SetTriggerSource(ADC_TypeDef *ADCx, uint32_t TriggerSource)
  2229. {
  2230. /* Note: On this STM32 serie, ADC group injected external trigger edge */
  2231. /* is used to perform a ADC conversion start. */
  2232. /* This function does not set external trigger edge. */
  2233. /* This feature is set using function */
  2234. /* @ref LL_ADC_INJ_StartConversionExtTrig(). */
  2235. MODIFY_REG(ADCx->CR2, ADC_CR2_JEXTSEL, (TriggerSource & ADC_CR2_JEXTSEL));
  2236. }
  2237. /**
  2238. * @brief Get ADC group injected conversion trigger source:
  2239. * internal (SW start) or from external IP (timer event,
  2240. * external interrupt line).
  2241. * @note To determine whether group injected trigger source is
  2242. * internal (SW start) or external, without detail
  2243. * of which peripheral is selected as external trigger,
  2244. * (equivalent to
  2245. * "if(LL_ADC_INJ_GetTriggerSource(ADC1) == LL_ADC_INJ_TRIG_SOFTWARE)")
  2246. * use function @ref LL_ADC_INJ_IsTriggerSourceSWStart.
  2247. * @note Availability of parameters of trigger sources from timer
  2248. * depends on timers availability on the selected device.
  2249. * @rmtoll CR2 JEXTSEL LL_ADC_INJ_GetTriggerSource
  2250. * @param ADCx ADC instance
  2251. * @retval Returned value can be one of the following values:
  2252. * @arg @ref LL_ADC_INJ_TRIG_SOFTWARE
  2253. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM1_TRGO (1)
  2254. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM1_CH4 (1)
  2255. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM2_TRGO (2)
  2256. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM2_CH1 (2)
  2257. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM3_CH4 (2)
  2258. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM4_TRGO (2)
  2259. * @arg @ref LL_ADC_INJ_TRIG_EXT_EXTI_LINE15 (2)
  2260. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM8_CH4 (2)(4)
  2261. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM8_CH4_ADC3 (3)
  2262. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM4_CH3 (3)
  2263. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM8_CH2 (3)
  2264. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM8_CH4 (3)
  2265. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM5_TRGO (3)
  2266. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM5_CH4 (3)
  2267. *
  2268. * (1) On STM32F1, parameter available on all ADC instances: ADC1, ADC2, ADC3 (for ADC instances ADCx available on the selected device).\n
  2269. * (2) On STM32F1, parameter available only on ADC instances: ADC1, ADC2 (for ADC instances ADCx available on the selected device).\n
  2270. * (3) On STM32F1, parameter available only on ADC instances: ADC3 (for ADC instances ADCx available on the selected device).\n
  2271. * (4) On STM32F1, parameter available only on high-density and XL-density devices. A remap of trigger must be done at top level (refer to AFIO peripheral).
  2272. */
  2273. __STATIC_INLINE uint32_t LL_ADC_INJ_GetTriggerSource(ADC_TypeDef *ADCx)
  2274. {
  2275. return (uint32_t)(READ_BIT(ADCx->CR2, ADC_CR2_JEXTSEL));
  2276. }
  2277. /**
  2278. * @brief Get ADC group injected conversion trigger source internal (SW start)
  2279. or external
  2280. * @note In case of group injected trigger source set to external trigger,
  2281. * to determine which peripheral is selected as external trigger,
  2282. * use function @ref LL_ADC_INJ_GetTriggerSource.
  2283. * @rmtoll CR2 JEXTSEL LL_ADC_INJ_IsTriggerSourceSWStart
  2284. * @param ADCx ADC instance
  2285. * @retval Value "0" if trigger source external trigger
  2286. * Value "1" if trigger source SW start.
  2287. */
  2288. __STATIC_INLINE uint32_t LL_ADC_INJ_IsTriggerSourceSWStart(ADC_TypeDef *ADCx)
  2289. {
  2290. return (READ_BIT(ADCx->CR2, ADC_CR2_JEXTSEL) == LL_ADC_INJ_TRIG_SOFTWARE);
  2291. }
  2292. /**
  2293. * @brief Set ADC group injected sequencer length and scan direction.
  2294. * @note This function performs configuration of:
  2295. * - Sequence length: Number of ranks in the scan sequence.
  2296. * - Sequence direction: Unless specified in parameters, sequencer
  2297. * scan direction is forward (from rank 1 to rank n).
  2298. * @note On this STM32 serie, group injected sequencer configuration
  2299. * is conditioned to ADC instance sequencer mode.
  2300. * If ADC instance sequencer mode is disabled, sequencers of
  2301. * all groups (group regular, group injected) can be configured
  2302. * but their execution is disabled (limited to rank 1).
  2303. * Refer to function @ref LL_ADC_SetSequencersScanMode().
  2304. * @note Sequencer disabled is equivalent to sequencer of 1 rank:
  2305. * ADC conversion on only 1 channel.
  2306. * @rmtoll JSQR JL LL_ADC_INJ_SetSequencerLength
  2307. * @param ADCx ADC instance
  2308. * @param SequencerNbRanks This parameter can be one of the following values:
  2309. * @arg @ref LL_ADC_INJ_SEQ_SCAN_DISABLE
  2310. * @arg @ref LL_ADC_INJ_SEQ_SCAN_ENABLE_2RANKS
  2311. * @arg @ref LL_ADC_INJ_SEQ_SCAN_ENABLE_3RANKS
  2312. * @arg @ref LL_ADC_INJ_SEQ_SCAN_ENABLE_4RANKS
  2313. * @retval None
  2314. */
  2315. __STATIC_INLINE void LL_ADC_INJ_SetSequencerLength(ADC_TypeDef *ADCx, uint32_t SequencerNbRanks)
  2316. {
  2317. MODIFY_REG(ADCx->JSQR, ADC_JSQR_JL, SequencerNbRanks);
  2318. }
  2319. /**
  2320. * @brief Get ADC group injected sequencer length and scan direction.
  2321. * @note This function retrieves:
  2322. * - Sequence length: Number of ranks in the scan sequence.
  2323. * - Sequence direction: Unless specified in parameters, sequencer
  2324. * scan direction is forward (from rank 1 to rank n).
  2325. * @note On this STM32 serie, group injected sequencer configuration
  2326. * is conditioned to ADC instance sequencer mode.
  2327. * If ADC instance sequencer mode is disabled, sequencers of
  2328. * all groups (group regular, group injected) can be configured
  2329. * but their execution is disabled (limited to rank 1).
  2330. * Refer to function @ref LL_ADC_SetSequencersScanMode().
  2331. * @note Sequencer disabled is equivalent to sequencer of 1 rank:
  2332. * ADC conversion on only 1 channel.
  2333. * @rmtoll JSQR JL LL_ADC_INJ_GetSequencerLength
  2334. * @param ADCx ADC instance
  2335. * @retval Returned value can be one of the following values:
  2336. * @arg @ref LL_ADC_INJ_SEQ_SCAN_DISABLE
  2337. * @arg @ref LL_ADC_INJ_SEQ_SCAN_ENABLE_2RANKS
  2338. * @arg @ref LL_ADC_INJ_SEQ_SCAN_ENABLE_3RANKS
  2339. * @arg @ref LL_ADC_INJ_SEQ_SCAN_ENABLE_4RANKS
  2340. */
  2341. __STATIC_INLINE uint32_t LL_ADC_INJ_GetSequencerLength(ADC_TypeDef *ADCx)
  2342. {
  2343. return (uint32_t)(READ_BIT(ADCx->JSQR, ADC_JSQR_JL));
  2344. }
  2345. /**
  2346. * @brief Set ADC group injected sequencer discontinuous mode:
  2347. * sequence subdivided and scan conversions interrupted every selected
  2348. * number of ranks.
  2349. * @note It is not possible to enable both ADC group injected
  2350. * auto-injected mode and sequencer discontinuous mode.
  2351. * @rmtoll CR1 DISCEN LL_ADC_INJ_SetSequencerDiscont
  2352. * @param ADCx ADC instance
  2353. * @param SeqDiscont This parameter can be one of the following values:
  2354. * @arg @ref LL_ADC_INJ_SEQ_DISCONT_DISABLE
  2355. * @arg @ref LL_ADC_INJ_SEQ_DISCONT_1RANK
  2356. * @retval None
  2357. */
  2358. __STATIC_INLINE void LL_ADC_INJ_SetSequencerDiscont(ADC_TypeDef *ADCx, uint32_t SeqDiscont)
  2359. {
  2360. MODIFY_REG(ADCx->CR1, ADC_CR1_JDISCEN, SeqDiscont);
  2361. }
  2362. /**
  2363. * @brief Get ADC group injected sequencer discontinuous mode:
  2364. * sequence subdivided and scan conversions interrupted every selected
  2365. * number of ranks.
  2366. * @rmtoll CR1 DISCEN LL_ADC_REG_GetSequencerDiscont
  2367. * @param ADCx ADC instance
  2368. * @retval Returned value can be one of the following values:
  2369. * @arg @ref LL_ADC_INJ_SEQ_DISCONT_DISABLE
  2370. * @arg @ref LL_ADC_INJ_SEQ_DISCONT_1RANK
  2371. */
  2372. __STATIC_INLINE uint32_t LL_ADC_INJ_GetSequencerDiscont(ADC_TypeDef *ADCx)
  2373. {
  2374. return (uint32_t)(READ_BIT(ADCx->CR1, ADC_CR1_JDISCEN));
  2375. }
  2376. /**
  2377. * @brief Set ADC group injected sequence: channel on the selected
  2378. * sequence rank.
  2379. * @note Depending on devices and packages, some channels may not be available.
  2380. * Refer to device datasheet for channels availability.
  2381. * @note On this STM32 serie, to measure internal channels (VrefInt,
  2382. * TempSensor, ...), measurement paths to internal channels must be
  2383. * enabled separately.
  2384. * This can be done using function @ref LL_ADC_SetCommonPathInternalCh().
  2385. * @rmtoll JSQR JSQ1 LL_ADC_INJ_SetSequencerRanks\n
  2386. * JSQR JSQ2 LL_ADC_INJ_SetSequencerRanks\n
  2387. * JSQR JSQ3 LL_ADC_INJ_SetSequencerRanks\n
  2388. * JSQR JSQ4 LL_ADC_INJ_SetSequencerRanks
  2389. * @param ADCx ADC instance
  2390. * @param Rank This parameter can be one of the following values:
  2391. * @arg @ref LL_ADC_INJ_RANK_1
  2392. * @arg @ref LL_ADC_INJ_RANK_2
  2393. * @arg @ref LL_ADC_INJ_RANK_3
  2394. * @arg @ref LL_ADC_INJ_RANK_4
  2395. * @param Channel This parameter can be one of the following values:
  2396. * @arg @ref LL_ADC_CHANNEL_0
  2397. * @arg @ref LL_ADC_CHANNEL_1
  2398. * @arg @ref LL_ADC_CHANNEL_2
  2399. * @arg @ref LL_ADC_CHANNEL_3
  2400. * @arg @ref LL_ADC_CHANNEL_4
  2401. * @arg @ref LL_ADC_CHANNEL_5
  2402. * @arg @ref LL_ADC_CHANNEL_6
  2403. * @arg @ref LL_ADC_CHANNEL_7
  2404. * @arg @ref LL_ADC_CHANNEL_8
  2405. * @arg @ref LL_ADC_CHANNEL_9
  2406. * @arg @ref LL_ADC_CHANNEL_10
  2407. * @arg @ref LL_ADC_CHANNEL_11
  2408. * @arg @ref LL_ADC_CHANNEL_12
  2409. * @arg @ref LL_ADC_CHANNEL_13
  2410. * @arg @ref LL_ADC_CHANNEL_14
  2411. * @arg @ref LL_ADC_CHANNEL_15
  2412. * @arg @ref LL_ADC_CHANNEL_16
  2413. * @arg @ref LL_ADC_CHANNEL_17
  2414. * @arg @ref LL_ADC_CHANNEL_VREFINT (1)
  2415. * @arg @ref LL_ADC_CHANNEL_TEMPSENSOR (1)
  2416. *
  2417. * (1) On STM32F1, parameter available only on ADC instance: ADC1.
  2418. * @retval None
  2419. */
  2420. __STATIC_INLINE void LL_ADC_INJ_SetSequencerRanks(ADC_TypeDef *ADCx, uint32_t Rank, uint32_t Channel)
  2421. {
  2422. /* Set bits with content of parameter "Channel" with bits position */
  2423. /* in register depending on parameter "Rank". */
  2424. /* Parameters "Rank" and "Channel" are used with masks because containing */
  2425. /* other bits reserved for other purpose. */
  2426. register uint32_t tmpreg1 = (READ_BIT(ADCx->JSQR, ADC_JSQR_JL) >> ADC_JSQR_JL_Pos) + 1U;
  2427. MODIFY_REG(ADCx->JSQR,
  2428. ADC_CHANNEL_ID_NUMBER_MASK << (5U * (uint8_t)(((Rank) + 3U) - (tmpreg1))),
  2429. (Channel & ADC_CHANNEL_ID_NUMBER_MASK) << (5U * (uint8_t)(((Rank) + 3U) - (tmpreg1))));
  2430. }
  2431. /**
  2432. * @brief Get ADC group injected sequence: channel on the selected
  2433. * sequence rank.
  2434. * @note Depending on devices and packages, some channels may not be available.
  2435. * Refer to device datasheet for channels availability.
  2436. * @note Usage of the returned channel number:
  2437. * - To reinject this channel into another function LL_ADC_xxx:
  2438. * the returned channel number is only partly formatted on definition
  2439. * of literals LL_ADC_CHANNEL_x. Therefore, it has to be compared
  2440. * with parts of literals LL_ADC_CHANNEL_x or using
  2441. * helper macro @ref __LL_ADC_CHANNEL_TO_DECIMAL_NB().
  2442. * Then the selected literal LL_ADC_CHANNEL_x can be used
  2443. * as parameter for another function.
  2444. * - To get the channel number in decimal format:
  2445. * process the returned value with the helper macro
  2446. * @ref __LL_ADC_CHANNEL_TO_DECIMAL_NB().
  2447. * @rmtoll JSQR JSQ1 LL_ADC_INJ_SetSequencerRanks\n
  2448. * JSQR JSQ2 LL_ADC_INJ_SetSequencerRanks\n
  2449. * JSQR JSQ3 LL_ADC_INJ_SetSequencerRanks\n
  2450. * JSQR JSQ4 LL_ADC_INJ_SetSequencerRanks
  2451. * @param ADCx ADC instance
  2452. * @param Rank This parameter can be one of the following values:
  2453. * @arg @ref LL_ADC_INJ_RANK_1
  2454. * @arg @ref LL_ADC_INJ_RANK_2
  2455. * @arg @ref LL_ADC_INJ_RANK_3
  2456. * @arg @ref LL_ADC_INJ_RANK_4
  2457. * @retval Returned value can be one of the following values:
  2458. * @arg @ref LL_ADC_CHANNEL_0
  2459. * @arg @ref LL_ADC_CHANNEL_1
  2460. * @arg @ref LL_ADC_CHANNEL_2
  2461. * @arg @ref LL_ADC_CHANNEL_3
  2462. * @arg @ref LL_ADC_CHANNEL_4
  2463. * @arg @ref LL_ADC_CHANNEL_5
  2464. * @arg @ref LL_ADC_CHANNEL_6
  2465. * @arg @ref LL_ADC_CHANNEL_7
  2466. * @arg @ref LL_ADC_CHANNEL_8
  2467. * @arg @ref LL_ADC_CHANNEL_9
  2468. * @arg @ref LL_ADC_CHANNEL_10
  2469. * @arg @ref LL_ADC_CHANNEL_11
  2470. * @arg @ref LL_ADC_CHANNEL_12
  2471. * @arg @ref LL_ADC_CHANNEL_13
  2472. * @arg @ref LL_ADC_CHANNEL_14
  2473. * @arg @ref LL_ADC_CHANNEL_15
  2474. * @arg @ref LL_ADC_CHANNEL_16
  2475. * @arg @ref LL_ADC_CHANNEL_17
  2476. * @arg @ref LL_ADC_CHANNEL_VREFINT (1)
  2477. * @arg @ref LL_ADC_CHANNEL_TEMPSENSOR (1)
  2478. *
  2479. * (1) On STM32F1, parameter available only on ADC instance: ADC1.\n
  2480. * (1) For ADC channel read back from ADC register,
  2481. * comparison with internal channel parameter to be done
  2482. * using helper macro @ref __LL_ADC_CHANNEL_INTERNAL_TO_EXTERNAL().
  2483. */
  2484. __STATIC_INLINE uint32_t LL_ADC_INJ_GetSequencerRanks(ADC_TypeDef *ADCx, uint32_t Rank)
  2485. {
  2486. register uint32_t tmpreg1 = (READ_BIT(ADCx->JSQR, ADC_JSQR_JL) >> ADC_JSQR_JL_Pos) + 1U;
  2487. return (uint32_t)(READ_BIT(ADCx->JSQR,
  2488. ADC_CHANNEL_ID_NUMBER_MASK << (5U * (uint8_t)(((Rank) + 3U) - (tmpreg1))))
  2489. >> (5U * (uint8_t)(((Rank) + 3U) - (tmpreg1)))
  2490. );
  2491. }
  2492. /**
  2493. * @brief Set ADC group injected conversion trigger:
  2494. * independent or from ADC group regular.
  2495. * @note This mode can be used to extend number of data registers
  2496. * updated after one ADC conversion trigger and with data
  2497. * permanently kept (not erased by successive conversions of scan of
  2498. * ADC sequencer ranks), up to 5 data registers:
  2499. * 1 data register on ADC group regular, 4 data registers
  2500. * on ADC group injected.
  2501. * @note If ADC group injected injected trigger source is set to an
  2502. * external trigger, this feature must be must be set to
  2503. * independent trigger.
  2504. * ADC group injected automatic trigger is compliant only with
  2505. * group injected trigger source set to SW start, without any
  2506. * further action on ADC group injected conversion start or stop:
  2507. * in this case, ADC group injected is controlled only
  2508. * from ADC group regular.
  2509. * @note It is not possible to enable both ADC group injected
  2510. * auto-injected mode and sequencer discontinuous mode.
  2511. * @rmtoll CR1 JAUTO LL_ADC_INJ_SetTrigAuto
  2512. * @param ADCx ADC instance
  2513. * @param TrigAuto This parameter can be one of the following values:
  2514. * @arg @ref LL_ADC_INJ_TRIG_INDEPENDENT
  2515. * @arg @ref LL_ADC_INJ_TRIG_FROM_GRP_REGULAR
  2516. * @retval None
  2517. */
  2518. __STATIC_INLINE void LL_ADC_INJ_SetTrigAuto(ADC_TypeDef *ADCx, uint32_t TrigAuto)
  2519. {
  2520. MODIFY_REG(ADCx->CR1, ADC_CR1_JAUTO, TrigAuto);
  2521. }
  2522. /**
  2523. * @brief Get ADC group injected conversion trigger:
  2524. * independent or from ADC group regular.
  2525. * @rmtoll CR1 JAUTO LL_ADC_INJ_GetTrigAuto
  2526. * @param ADCx ADC instance
  2527. * @retval Returned value can be one of the following values:
  2528. * @arg @ref LL_ADC_INJ_TRIG_INDEPENDENT
  2529. * @arg @ref LL_ADC_INJ_TRIG_FROM_GRP_REGULAR
  2530. */
  2531. __STATIC_INLINE uint32_t LL_ADC_INJ_GetTrigAuto(ADC_TypeDef *ADCx)
  2532. {
  2533. return (uint32_t)(READ_BIT(ADCx->CR1, ADC_CR1_JAUTO));
  2534. }
  2535. /**
  2536. * @brief Set ADC group injected offset.
  2537. * @note It sets:
  2538. * - ADC group injected rank to which the offset programmed
  2539. * will be applied
  2540. * - Offset level (offset to be subtracted from the raw
  2541. * converted data).
  2542. * Caution: Offset format is dependent to ADC resolution:
  2543. * offset has to be left-aligned on bit 11, the LSB (right bits)
  2544. * are set to 0.
  2545. * @note Offset cannot be enabled or disabled.
  2546. * To emulate offset disabled, set an offset value equal to 0.
  2547. * @rmtoll JOFR1 JOFFSET1 LL_ADC_INJ_SetOffset\n
  2548. * JOFR2 JOFFSET2 LL_ADC_INJ_SetOffset\n
  2549. * JOFR3 JOFFSET3 LL_ADC_INJ_SetOffset\n
  2550. * JOFR4 JOFFSET4 LL_ADC_INJ_SetOffset
  2551. * @param ADCx ADC instance
  2552. * @param Rank This parameter can be one of the following values:
  2553. * @arg @ref LL_ADC_INJ_RANK_1
  2554. * @arg @ref LL_ADC_INJ_RANK_2
  2555. * @arg @ref LL_ADC_INJ_RANK_3
  2556. * @arg @ref LL_ADC_INJ_RANK_4
  2557. * @param OffsetLevel Value between Min_Data=0x000 and Max_Data=0xFFF
  2558. * @retval None
  2559. */
  2560. __STATIC_INLINE void LL_ADC_INJ_SetOffset(ADC_TypeDef *ADCx, uint32_t Rank, uint32_t OffsetLevel)
  2561. {
  2562. register uint32_t *preg = __ADC_PTR_REG_OFFSET(ADCx->JOFR1, __ADC_MASK_SHIFT(Rank, ADC_INJ_JOFRX_REGOFFSET_MASK));
  2563. MODIFY_REG(*preg,
  2564. ADC_JOFR1_JOFFSET1,
  2565. OffsetLevel);
  2566. }
  2567. /**
  2568. * @brief Get ADC group injected offset.
  2569. * @note It gives offset level (offset to be subtracted from the raw converted data).
  2570. * Caution: Offset format is dependent to ADC resolution:
  2571. * offset has to be left-aligned on bit 11, the LSB (right bits)
  2572. * are set to 0.
  2573. * @rmtoll JOFR1 JOFFSET1 LL_ADC_INJ_GetOffset\n
  2574. * JOFR2 JOFFSET2 LL_ADC_INJ_GetOffset\n
  2575. * JOFR3 JOFFSET3 LL_ADC_INJ_GetOffset\n
  2576. * JOFR4 JOFFSET4 LL_ADC_INJ_GetOffset
  2577. * @param ADCx ADC instance
  2578. * @param Rank This parameter can be one of the following values:
  2579. * @arg @ref LL_ADC_INJ_RANK_1
  2580. * @arg @ref LL_ADC_INJ_RANK_2
  2581. * @arg @ref LL_ADC_INJ_RANK_3
  2582. * @arg @ref LL_ADC_INJ_RANK_4
  2583. * @retval Value between Min_Data=0x000 and Max_Data=0xFFF
  2584. */
  2585. __STATIC_INLINE uint32_t LL_ADC_INJ_GetOffset(ADC_TypeDef *ADCx, uint32_t Rank)
  2586. {
  2587. register uint32_t *preg = __ADC_PTR_REG_OFFSET(ADCx->JOFR1, __ADC_MASK_SHIFT(Rank, ADC_INJ_JOFRX_REGOFFSET_MASK));
  2588. return (uint32_t)(READ_BIT(*preg,
  2589. ADC_JOFR1_JOFFSET1)
  2590. );
  2591. }
  2592. /**
  2593. * @}
  2594. */
  2595. /** @defgroup ADC_LL_EF_Configuration_Channels Configuration of ADC hierarchical scope: channels
  2596. * @{
  2597. */
  2598. /**
  2599. * @brief Set sampling time of the selected ADC channel
  2600. * Unit: ADC clock cycles.
  2601. * @note On this device, sampling time is on channel scope: independently
  2602. * of channel mapped on ADC group regular or injected.
  2603. * @note In case of internal channel (VrefInt, TempSensor, ...) to be
  2604. * converted:
  2605. * sampling time constraints must be respected (sampling time can be
  2606. * adjusted in function of ADC clock frequency and sampling time
  2607. * setting).
  2608. * Refer to device datasheet for timings values (parameters TS_vrefint,
  2609. * TS_temp, ...).
  2610. * @note Conversion time is the addition of sampling time and processing time.
  2611. * Refer to reference manual for ADC processing time of
  2612. * this STM32 serie.
  2613. * @note In case of ADC conversion of internal channel (VrefInt,
  2614. * temperature sensor, ...), a sampling time minimum value
  2615. * is required.
  2616. * Refer to device datasheet.
  2617. * @rmtoll SMPR1 SMP17 LL_ADC_SetChannelSamplingTime\n
  2618. * SMPR1 SMP16 LL_ADC_SetChannelSamplingTime\n
  2619. * SMPR1 SMP15 LL_ADC_SetChannelSamplingTime\n
  2620. * SMPR1 SMP14 LL_ADC_SetChannelSamplingTime\n
  2621. * SMPR1 SMP13 LL_ADC_SetChannelSamplingTime\n
  2622. * SMPR1 SMP12 LL_ADC_SetChannelSamplingTime\n
  2623. * SMPR1 SMP11 LL_ADC_SetChannelSamplingTime\n
  2624. * SMPR1 SMP10 LL_ADC_SetChannelSamplingTime\n
  2625. * SMPR2 SMP9 LL_ADC_SetChannelSamplingTime\n
  2626. * SMPR2 SMP8 LL_ADC_SetChannelSamplingTime\n
  2627. * SMPR2 SMP7 LL_ADC_SetChannelSamplingTime\n
  2628. * SMPR2 SMP6 LL_ADC_SetChannelSamplingTime\n
  2629. * SMPR2 SMP5 LL_ADC_SetChannelSamplingTime\n
  2630. * SMPR2 SMP4 LL_ADC_SetChannelSamplingTime\n
  2631. * SMPR2 SMP3 LL_ADC_SetChannelSamplingTime\n
  2632. * SMPR2 SMP2 LL_ADC_SetChannelSamplingTime\n
  2633. * SMPR2 SMP1 LL_ADC_SetChannelSamplingTime\n
  2634. * SMPR2 SMP0 LL_ADC_SetChannelSamplingTime
  2635. * @param ADCx ADC instance
  2636. * @param Channel This parameter can be one of the following values:
  2637. * @arg @ref LL_ADC_CHANNEL_0
  2638. * @arg @ref LL_ADC_CHANNEL_1
  2639. * @arg @ref LL_ADC_CHANNEL_2
  2640. * @arg @ref LL_ADC_CHANNEL_3
  2641. * @arg @ref LL_ADC_CHANNEL_4
  2642. * @arg @ref LL_ADC_CHANNEL_5
  2643. * @arg @ref LL_ADC_CHANNEL_6
  2644. * @arg @ref LL_ADC_CHANNEL_7
  2645. * @arg @ref LL_ADC_CHANNEL_8
  2646. * @arg @ref LL_ADC_CHANNEL_9
  2647. * @arg @ref LL_ADC_CHANNEL_10
  2648. * @arg @ref LL_ADC_CHANNEL_11
  2649. * @arg @ref LL_ADC_CHANNEL_12
  2650. * @arg @ref LL_ADC_CHANNEL_13
  2651. * @arg @ref LL_ADC_CHANNEL_14
  2652. * @arg @ref LL_ADC_CHANNEL_15
  2653. * @arg @ref LL_ADC_CHANNEL_16
  2654. * @arg @ref LL_ADC_CHANNEL_17
  2655. * @arg @ref LL_ADC_CHANNEL_VREFINT (1)
  2656. * @arg @ref LL_ADC_CHANNEL_TEMPSENSOR (1)
  2657. *
  2658. * (1) On STM32F1, parameter available only on ADC instance: ADC1.
  2659. * @param SamplingTime This parameter can be one of the following values:
  2660. * @arg @ref LL_ADC_SAMPLINGTIME_1CYCLE_5
  2661. * @arg @ref LL_ADC_SAMPLINGTIME_7CYCLES_5
  2662. * @arg @ref LL_ADC_SAMPLINGTIME_13CYCLES_5
  2663. * @arg @ref LL_ADC_SAMPLINGTIME_28CYCLES_5
  2664. * @arg @ref LL_ADC_SAMPLINGTIME_41CYCLES_5
  2665. * @arg @ref LL_ADC_SAMPLINGTIME_55CYCLES_5
  2666. * @arg @ref LL_ADC_SAMPLINGTIME_71CYCLES_5
  2667. * @arg @ref LL_ADC_SAMPLINGTIME_239CYCLES_5
  2668. * @retval None
  2669. */
  2670. __STATIC_INLINE void LL_ADC_SetChannelSamplingTime(ADC_TypeDef *ADCx, uint32_t Channel, uint32_t SamplingTime)
  2671. {
  2672. /* Set bits with content of parameter "SamplingTime" with bits position */
  2673. /* in register and register position depending on parameter "Channel". */
  2674. /* Parameter "Channel" is used with masks because containing */
  2675. /* other bits reserved for other purpose. */
  2676. register uint32_t *preg = __ADC_PTR_REG_OFFSET(ADCx->SMPR1, __ADC_MASK_SHIFT(Channel, ADC_CHANNEL_SMPRX_REGOFFSET_MASK));
  2677. MODIFY_REG(*preg,
  2678. ADC_SMPR2_SMP0 << __ADC_MASK_SHIFT(Channel, ADC_CHANNEL_SMPx_BITOFFSET_MASK),
  2679. SamplingTime << __ADC_MASK_SHIFT(Channel, ADC_CHANNEL_SMPx_BITOFFSET_MASK));
  2680. }
  2681. /**
  2682. * @brief Get sampling time of the selected ADC channel
  2683. * Unit: ADC clock cycles.
  2684. * @note On this device, sampling time is on channel scope: independently
  2685. * of channel mapped on ADC group regular or injected.
  2686. * @note Conversion time is the addition of sampling time and processing time.
  2687. * Refer to reference manual for ADC processing time of
  2688. * this STM32 serie.
  2689. * @rmtoll SMPR1 SMP17 LL_ADC_GetChannelSamplingTime\n
  2690. * SMPR1 SMP16 LL_ADC_GetChannelSamplingTime\n
  2691. * SMPR1 SMP15 LL_ADC_GetChannelSamplingTime\n
  2692. * SMPR1 SMP14 LL_ADC_GetChannelSamplingTime\n
  2693. * SMPR1 SMP13 LL_ADC_GetChannelSamplingTime\n
  2694. * SMPR1 SMP12 LL_ADC_GetChannelSamplingTime\n
  2695. * SMPR1 SMP11 LL_ADC_GetChannelSamplingTime\n
  2696. * SMPR1 SMP10 LL_ADC_GetChannelSamplingTime\n
  2697. * SMPR2 SMP9 LL_ADC_GetChannelSamplingTime\n
  2698. * SMPR2 SMP8 LL_ADC_GetChannelSamplingTime\n
  2699. * SMPR2 SMP7 LL_ADC_GetChannelSamplingTime\n
  2700. * SMPR2 SMP6 LL_ADC_GetChannelSamplingTime\n
  2701. * SMPR2 SMP5 LL_ADC_GetChannelSamplingTime\n
  2702. * SMPR2 SMP4 LL_ADC_GetChannelSamplingTime\n
  2703. * SMPR2 SMP3 LL_ADC_GetChannelSamplingTime\n
  2704. * SMPR2 SMP2 LL_ADC_GetChannelSamplingTime\n
  2705. * SMPR2 SMP1 LL_ADC_GetChannelSamplingTime\n
  2706. * SMPR2 SMP0 LL_ADC_GetChannelSamplingTime
  2707. * @param ADCx ADC instance
  2708. * @param Channel This parameter can be one of the following values:
  2709. * @arg @ref LL_ADC_CHANNEL_0
  2710. * @arg @ref LL_ADC_CHANNEL_1
  2711. * @arg @ref LL_ADC_CHANNEL_2
  2712. * @arg @ref LL_ADC_CHANNEL_3
  2713. * @arg @ref LL_ADC_CHANNEL_4
  2714. * @arg @ref LL_ADC_CHANNEL_5
  2715. * @arg @ref LL_ADC_CHANNEL_6
  2716. * @arg @ref LL_ADC_CHANNEL_7
  2717. * @arg @ref LL_ADC_CHANNEL_8
  2718. * @arg @ref LL_ADC_CHANNEL_9
  2719. * @arg @ref LL_ADC_CHANNEL_10
  2720. * @arg @ref LL_ADC_CHANNEL_11
  2721. * @arg @ref LL_ADC_CHANNEL_12
  2722. * @arg @ref LL_ADC_CHANNEL_13
  2723. * @arg @ref LL_ADC_CHANNEL_14
  2724. * @arg @ref LL_ADC_CHANNEL_15
  2725. * @arg @ref LL_ADC_CHANNEL_16
  2726. * @arg @ref LL_ADC_CHANNEL_17
  2727. * @arg @ref LL_ADC_CHANNEL_VREFINT (1)
  2728. * @arg @ref LL_ADC_CHANNEL_TEMPSENSOR (1)
  2729. *
  2730. * (1) On STM32F1, parameter available only on ADC instance: ADC1.
  2731. * @retval Returned value can be one of the following values:
  2732. * @arg @ref LL_ADC_SAMPLINGTIME_1CYCLE_5
  2733. * @arg @ref LL_ADC_SAMPLINGTIME_7CYCLES_5
  2734. * @arg @ref LL_ADC_SAMPLINGTIME_13CYCLES_5
  2735. * @arg @ref LL_ADC_SAMPLINGTIME_28CYCLES_5
  2736. * @arg @ref LL_ADC_SAMPLINGTIME_41CYCLES_5
  2737. * @arg @ref LL_ADC_SAMPLINGTIME_55CYCLES_5
  2738. * @arg @ref LL_ADC_SAMPLINGTIME_71CYCLES_5
  2739. * @arg @ref LL_ADC_SAMPLINGTIME_239CYCLES_5
  2740. */
  2741. __STATIC_INLINE uint32_t LL_ADC_GetChannelSamplingTime(ADC_TypeDef *ADCx, uint32_t Channel)
  2742. {
  2743. register uint32_t *preg = __ADC_PTR_REG_OFFSET(ADCx->SMPR1, __ADC_MASK_SHIFT(Channel, ADC_CHANNEL_SMPRX_REGOFFSET_MASK));
  2744. return (uint32_t)(READ_BIT(*preg,
  2745. ADC_SMPR2_SMP0 << __ADC_MASK_SHIFT(Channel, ADC_CHANNEL_SMPx_BITOFFSET_MASK))
  2746. >> __ADC_MASK_SHIFT(Channel, ADC_CHANNEL_SMPx_BITOFFSET_MASK)
  2747. );
  2748. }
  2749. /**
  2750. * @}
  2751. */
  2752. /** @defgroup ADC_LL_EF_Configuration_ADC_AnalogWatchdog Configuration of ADC transversal scope: analog watchdog
  2753. * @{
  2754. */
  2755. /**
  2756. * @brief Set ADC analog watchdog monitored channels:
  2757. * a single channel or all channels,
  2758. * on ADC groups regular and-or injected.
  2759. * @note Once monitored channels are selected, analog watchdog
  2760. * is enabled.
  2761. * @note In case of need to define a single channel to monitor
  2762. * with analog watchdog from sequencer channel definition,
  2763. * use helper macro @ref __LL_ADC_ANALOGWD_CHANNEL_GROUP().
  2764. * @note On this STM32 serie, there is only 1 kind of analog watchdog
  2765. * instance:
  2766. * - AWD standard (instance AWD1):
  2767. * - channels monitored: can monitor 1 channel or all channels.
  2768. * - groups monitored: ADC groups regular and-or injected.
  2769. * - resolution: resolution is not limited (corresponds to
  2770. * ADC resolution configured).
  2771. * @rmtoll CR1 AWD1CH LL_ADC_SetAnalogWDMonitChannels\n
  2772. * CR1 AWD1SGL LL_ADC_SetAnalogWDMonitChannels\n
  2773. * CR1 AWD1EN LL_ADC_SetAnalogWDMonitChannels
  2774. * @param ADCx ADC instance
  2775. * @param AWDChannelGroup This parameter can be one of the following values:
  2776. * @arg @ref LL_ADC_AWD_DISABLE
  2777. * @arg @ref LL_ADC_AWD_ALL_CHANNELS_REG
  2778. * @arg @ref LL_ADC_AWD_ALL_CHANNELS_INJ
  2779. * @arg @ref LL_ADC_AWD_ALL_CHANNELS_REG_INJ
  2780. * @arg @ref LL_ADC_AWD_CHANNEL_0_REG
  2781. * @arg @ref LL_ADC_AWD_CHANNEL_0_INJ
  2782. * @arg @ref LL_ADC_AWD_CHANNEL_0_REG_INJ
  2783. * @arg @ref LL_ADC_AWD_CHANNEL_1_REG
  2784. * @arg @ref LL_ADC_AWD_CHANNEL_1_INJ
  2785. * @arg @ref LL_ADC_AWD_CHANNEL_1_REG_INJ
  2786. * @arg @ref LL_ADC_AWD_CHANNEL_2_REG
  2787. * @arg @ref LL_ADC_AWD_CHANNEL_2_INJ
  2788. * @arg @ref LL_ADC_AWD_CHANNEL_2_REG_INJ
  2789. * @arg @ref LL_ADC_AWD_CHANNEL_3_REG
  2790. * @arg @ref LL_ADC_AWD_CHANNEL_3_INJ
  2791. * @arg @ref LL_ADC_AWD_CHANNEL_3_REG_INJ
  2792. * @arg @ref LL_ADC_AWD_CHANNEL_4_REG
  2793. * @arg @ref LL_ADC_AWD_CHANNEL_4_INJ
  2794. * @arg @ref LL_ADC_AWD_CHANNEL_4_REG_INJ
  2795. * @arg @ref LL_ADC_AWD_CHANNEL_5_REG
  2796. * @arg @ref LL_ADC_AWD_CHANNEL_5_INJ
  2797. * @arg @ref LL_ADC_AWD_CHANNEL_5_REG_INJ
  2798. * @arg @ref LL_ADC_AWD_CHANNEL_6_REG
  2799. * @arg @ref LL_ADC_AWD_CHANNEL_6_INJ
  2800. * @arg @ref LL_ADC_AWD_CHANNEL_6_REG_INJ
  2801. * @arg @ref LL_ADC_AWD_CHANNEL_7_REG
  2802. * @arg @ref LL_ADC_AWD_CHANNEL_7_INJ
  2803. * @arg @ref LL_ADC_AWD_CHANNEL_7_REG_INJ
  2804. * @arg @ref LL_ADC_AWD_CHANNEL_8_REG
  2805. * @arg @ref LL_ADC_AWD_CHANNEL_8_INJ
  2806. * @arg @ref LL_ADC_AWD_CHANNEL_8_REG_INJ
  2807. * @arg @ref LL_ADC_AWD_CHANNEL_9_REG
  2808. * @arg @ref LL_ADC_AWD_CHANNEL_9_INJ
  2809. * @arg @ref LL_ADC_AWD_CHANNEL_9_REG_INJ
  2810. * @arg @ref LL_ADC_AWD_CHANNEL_10_REG
  2811. * @arg @ref LL_ADC_AWD_CHANNEL_10_INJ
  2812. * @arg @ref LL_ADC_AWD_CHANNEL_10_REG_INJ
  2813. * @arg @ref LL_ADC_AWD_CHANNEL_11_REG
  2814. * @arg @ref LL_ADC_AWD_CHANNEL_11_INJ
  2815. * @arg @ref LL_ADC_AWD_CHANNEL_11_REG_INJ
  2816. * @arg @ref LL_ADC_AWD_CHANNEL_12_REG
  2817. * @arg @ref LL_ADC_AWD_CHANNEL_12_INJ
  2818. * @arg @ref LL_ADC_AWD_CHANNEL_12_REG_INJ
  2819. * @arg @ref LL_ADC_AWD_CHANNEL_13_REG
  2820. * @arg @ref LL_ADC_AWD_CHANNEL_13_INJ
  2821. * @arg @ref LL_ADC_AWD_CHANNEL_13_REG_INJ
  2822. * @arg @ref LL_ADC_AWD_CHANNEL_14_REG
  2823. * @arg @ref LL_ADC_AWD_CHANNEL_14_INJ
  2824. * @arg @ref LL_ADC_AWD_CHANNEL_14_REG_INJ
  2825. * @arg @ref LL_ADC_AWD_CHANNEL_15_REG
  2826. * @arg @ref LL_ADC_AWD_CHANNEL_15_INJ
  2827. * @arg @ref LL_ADC_AWD_CHANNEL_15_REG_INJ
  2828. * @arg @ref LL_ADC_AWD_CHANNEL_16_REG
  2829. * @arg @ref LL_ADC_AWD_CHANNEL_16_INJ
  2830. * @arg @ref LL_ADC_AWD_CHANNEL_16_REG_INJ
  2831. * @arg @ref LL_ADC_AWD_CHANNEL_17_REG
  2832. * @arg @ref LL_ADC_AWD_CHANNEL_17_INJ
  2833. * @arg @ref LL_ADC_AWD_CHANNEL_17_REG_INJ
  2834. * @arg @ref LL_ADC_AWD_CH_VREFINT_REG (1)
  2835. * @arg @ref LL_ADC_AWD_CH_VREFINT_INJ (1)
  2836. * @arg @ref LL_ADC_AWD_CH_VREFINT_REG_INJ (1)
  2837. * @arg @ref LL_ADC_AWD_CH_TEMPSENSOR_REG (1)
  2838. * @arg @ref LL_ADC_AWD_CH_TEMPSENSOR_INJ (1)
  2839. * @arg @ref LL_ADC_AWD_CH_TEMPSENSOR_REG_INJ (1)
  2840. *
  2841. * (1) On STM32F1, parameter available only on ADC instance: ADC1.
  2842. * @retval None
  2843. */
  2844. __STATIC_INLINE void LL_ADC_SetAnalogWDMonitChannels(ADC_TypeDef *ADCx, uint32_t AWDChannelGroup)
  2845. {
  2846. MODIFY_REG(ADCx->CR1,
  2847. (ADC_CR1_AWDEN | ADC_CR1_JAWDEN | ADC_CR1_AWDSGL | ADC_CR1_AWDCH),
  2848. AWDChannelGroup);
  2849. }
  2850. /**
  2851. * @brief Get ADC analog watchdog monitored channel.
  2852. * @note Usage of the returned channel number:
  2853. * - To reinject this channel into another function LL_ADC_xxx:
  2854. * the returned channel number is only partly formatted on definition
  2855. * of literals LL_ADC_CHANNEL_x. Therefore, it has to be compared
  2856. * with parts of literals LL_ADC_CHANNEL_x or using
  2857. * helper macro @ref __LL_ADC_CHANNEL_TO_DECIMAL_NB().
  2858. * Then the selected literal LL_ADC_CHANNEL_x can be used
  2859. * as parameter for another function.
  2860. * - To get the channel number in decimal format:
  2861. * process the returned value with the helper macro
  2862. * @ref __LL_ADC_CHANNEL_TO_DECIMAL_NB().
  2863. * Applicable only when the analog watchdog is set to monitor
  2864. * one channel.
  2865. * @note On this STM32 serie, there is only 1 kind of analog watchdog
  2866. * instance:
  2867. * - AWD standard (instance AWD1):
  2868. * - channels monitored: can monitor 1 channel or all channels.
  2869. * - groups monitored: ADC groups regular and-or injected.
  2870. * - resolution: resolution is not limited (corresponds to
  2871. * ADC resolution configured).
  2872. * @rmtoll CR1 AWD1CH LL_ADC_GetAnalogWDMonitChannels\n
  2873. * CR1 AWD1SGL LL_ADC_GetAnalogWDMonitChannels\n
  2874. * CR1 AWD1EN LL_ADC_GetAnalogWDMonitChannels
  2875. * @param ADCx ADC instance
  2876. * @retval Returned value can be one of the following values:
  2877. * @arg @ref LL_ADC_AWD_DISABLE
  2878. * @arg @ref LL_ADC_AWD_ALL_CHANNELS_REG
  2879. * @arg @ref LL_ADC_AWD_ALL_CHANNELS_INJ
  2880. * @arg @ref LL_ADC_AWD_ALL_CHANNELS_REG_INJ
  2881. * @arg @ref LL_ADC_AWD_CHANNEL_0_REG
  2882. * @arg @ref LL_ADC_AWD_CHANNEL_0_INJ
  2883. * @arg @ref LL_ADC_AWD_CHANNEL_0_REG_INJ
  2884. * @arg @ref LL_ADC_AWD_CHANNEL_1_REG
  2885. * @arg @ref LL_ADC_AWD_CHANNEL_1_INJ
  2886. * @arg @ref LL_ADC_AWD_CHANNEL_1_REG_INJ
  2887. * @arg @ref LL_ADC_AWD_CHANNEL_2_REG
  2888. * @arg @ref LL_ADC_AWD_CHANNEL_2_INJ
  2889. * @arg @ref LL_ADC_AWD_CHANNEL_2_REG_INJ
  2890. * @arg @ref LL_ADC_AWD_CHANNEL_3_REG
  2891. * @arg @ref LL_ADC_AWD_CHANNEL_3_INJ
  2892. * @arg @ref LL_ADC_AWD_CHANNEL_3_REG_INJ
  2893. * @arg @ref LL_ADC_AWD_CHANNEL_4_REG
  2894. * @arg @ref LL_ADC_AWD_CHANNEL_4_INJ
  2895. * @arg @ref LL_ADC_AWD_CHANNEL_4_REG_INJ
  2896. * @arg @ref LL_ADC_AWD_CHANNEL_5_REG
  2897. * @arg @ref LL_ADC_AWD_CHANNEL_5_INJ
  2898. * @arg @ref LL_ADC_AWD_CHANNEL_5_REG_INJ
  2899. * @arg @ref LL_ADC_AWD_CHANNEL_6_REG
  2900. * @arg @ref LL_ADC_AWD_CHANNEL_6_INJ
  2901. * @arg @ref LL_ADC_AWD_CHANNEL_6_REG_INJ
  2902. * @arg @ref LL_ADC_AWD_CHANNEL_7_REG
  2903. * @arg @ref LL_ADC_AWD_CHANNEL_7_INJ
  2904. * @arg @ref LL_ADC_AWD_CHANNEL_7_REG_INJ
  2905. * @arg @ref LL_ADC_AWD_CHANNEL_8_REG
  2906. * @arg @ref LL_ADC_AWD_CHANNEL_8_INJ
  2907. * @arg @ref LL_ADC_AWD_CHANNEL_8_REG_INJ
  2908. * @arg @ref LL_ADC_AWD_CHANNEL_9_REG
  2909. * @arg @ref LL_ADC_AWD_CHANNEL_9_INJ
  2910. * @arg @ref LL_ADC_AWD_CHANNEL_9_REG_INJ
  2911. * @arg @ref LL_ADC_AWD_CHANNEL_10_REG
  2912. * @arg @ref LL_ADC_AWD_CHANNEL_10_INJ
  2913. * @arg @ref LL_ADC_AWD_CHANNEL_10_REG_INJ
  2914. * @arg @ref LL_ADC_AWD_CHANNEL_11_REG
  2915. * @arg @ref LL_ADC_AWD_CHANNEL_11_INJ
  2916. * @arg @ref LL_ADC_AWD_CHANNEL_11_REG_INJ
  2917. * @arg @ref LL_ADC_AWD_CHANNEL_12_REG
  2918. * @arg @ref LL_ADC_AWD_CHANNEL_12_INJ
  2919. * @arg @ref LL_ADC_AWD_CHANNEL_12_REG_INJ
  2920. * @arg @ref LL_ADC_AWD_CHANNEL_13_REG
  2921. * @arg @ref LL_ADC_AWD_CHANNEL_13_INJ
  2922. * @arg @ref LL_ADC_AWD_CHANNEL_13_REG_INJ
  2923. * @arg @ref LL_ADC_AWD_CHANNEL_14_REG
  2924. * @arg @ref LL_ADC_AWD_CHANNEL_14_INJ
  2925. * @arg @ref LL_ADC_AWD_CHANNEL_14_REG_INJ
  2926. * @arg @ref LL_ADC_AWD_CHANNEL_15_REG
  2927. * @arg @ref LL_ADC_AWD_CHANNEL_15_INJ
  2928. * @arg @ref LL_ADC_AWD_CHANNEL_15_REG_INJ
  2929. * @arg @ref LL_ADC_AWD_CHANNEL_16_REG
  2930. * @arg @ref LL_ADC_AWD_CHANNEL_16_INJ
  2931. * @arg @ref LL_ADC_AWD_CHANNEL_16_REG_INJ
  2932. * @arg @ref LL_ADC_AWD_CHANNEL_17_REG
  2933. * @arg @ref LL_ADC_AWD_CHANNEL_17_INJ
  2934. * @arg @ref LL_ADC_AWD_CHANNEL_17_REG_INJ
  2935. */
  2936. __STATIC_INLINE uint32_t LL_ADC_GetAnalogWDMonitChannels(ADC_TypeDef *ADCx)
  2937. {
  2938. return (uint32_t)(READ_BIT(ADCx->CR1, (ADC_CR1_AWDEN | ADC_CR1_JAWDEN | ADC_CR1_AWDSGL | ADC_CR1_AWDCH)));
  2939. }
  2940. /**
  2941. * @brief Set ADC analog watchdog threshold value of threshold
  2942. * high or low.
  2943. * @note On this STM32 serie, there is only 1 kind of analog watchdog
  2944. * instance:
  2945. * - AWD standard (instance AWD1):
  2946. * - channels monitored: can monitor 1 channel or all channels.
  2947. * - groups monitored: ADC groups regular and-or injected.
  2948. * - resolution: resolution is not limited (corresponds to
  2949. * ADC resolution configured).
  2950. * @rmtoll HTR HT LL_ADC_SetAnalogWDThresholds\n
  2951. * LTR LT LL_ADC_SetAnalogWDThresholds
  2952. * @param ADCx ADC instance
  2953. * @param AWDThresholdsHighLow This parameter can be one of the following values:
  2954. * @arg @ref LL_ADC_AWD_THRESHOLD_HIGH
  2955. * @arg @ref LL_ADC_AWD_THRESHOLD_LOW
  2956. * @param AWDThresholdValue: Value between Min_Data=0x000 and Max_Data=0xFFF
  2957. * @retval None
  2958. */
  2959. __STATIC_INLINE void LL_ADC_SetAnalogWDThresholds(ADC_TypeDef *ADCx, uint32_t AWDThresholdsHighLow, uint32_t AWDThresholdValue)
  2960. {
  2961. register uint32_t *preg = __ADC_PTR_REG_OFFSET(ADCx->HTR, AWDThresholdsHighLow);
  2962. MODIFY_REG(*preg,
  2963. ADC_HTR_HT,
  2964. AWDThresholdValue);
  2965. }
  2966. /**
  2967. * @brief Get ADC analog watchdog threshold value of threshold high or
  2968. * threshold low.
  2969. * @note In case of ADC resolution different of 12 bits,
  2970. * analog watchdog thresholds data require a specific shift.
  2971. * Use helper macro @ref __LL_ADC_ANALOGWD_GET_THRESHOLD_RESOLUTION().
  2972. * @rmtoll HTR HT LL_ADC_GetAnalogWDThresholds\n
  2973. * LTR LT LL_ADC_GetAnalogWDThresholds
  2974. * @param ADCx ADC instance
  2975. * @param AWDThresholdsHighLow This parameter can be one of the following values:
  2976. * @arg @ref LL_ADC_AWD_THRESHOLD_HIGH
  2977. * @arg @ref LL_ADC_AWD_THRESHOLD_LOW
  2978. * @retval Value between Min_Data=0x000 and Max_Data=0xFFF
  2979. */
  2980. __STATIC_INLINE uint32_t LL_ADC_GetAnalogWDThresholds(ADC_TypeDef *ADCx, uint32_t AWDThresholdsHighLow)
  2981. {
  2982. register uint32_t *preg = __ADC_PTR_REG_OFFSET(ADCx->HTR, AWDThresholdsHighLow);
  2983. return (uint32_t)(READ_BIT(*preg, ADC_HTR_HT));
  2984. }
  2985. /**
  2986. * @}
  2987. */
  2988. /** @defgroup ADC_LL_EF_Configuration_ADC_Multimode Configuration of ADC hierarchical scope: multimode
  2989. * @{
  2990. */
  2991. #if defined(ADC_MULTIMODE_SUPPORT)
  2992. /**
  2993. * @brief Set ADC multimode configuration to operate in independent mode
  2994. * or multimode (for devices with several ADC instances).
  2995. * @note If multimode configuration: the selected ADC instance is
  2996. * either master or slave depending on hardware.
  2997. * Refer to reference manual.
  2998. * @rmtoll CR1 DUALMOD LL_ADC_SetMultimode
  2999. * @param ADCxy_COMMON ADC common instance
  3000. * (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() )
  3001. * @param Multimode This parameter can be one of the following values:
  3002. * @arg @ref LL_ADC_MULTI_INDEPENDENT
  3003. * @arg @ref LL_ADC_MULTI_DUAL_REG_SIMULT
  3004. * @arg @ref LL_ADC_MULTI_DUAL_REG_INTERL_FAST
  3005. * @arg @ref LL_ADC_MULTI_DUAL_REG_INTERL_SLOW
  3006. * @arg @ref LL_ADC_MULTI_DUAL_INJ_SIMULT
  3007. * @arg @ref LL_ADC_MULTI_DUAL_INJ_ALTERN
  3008. * @arg @ref LL_ADC_MULTI_DUAL_REG_SIM_INJ_SIM
  3009. * @arg @ref LL_ADC_MULTI_DUAL_REG_SIM_INJ_ALT
  3010. * @arg @ref LL_ADC_MULTI_DUAL_REG_INTFAST_INJ_SIM
  3011. * @arg @ref LL_ADC_MULTI_DUAL_REG_INTSLOW_INJ_SIM
  3012. * @retval None
  3013. */
  3014. __STATIC_INLINE void LL_ADC_SetMultimode(ADC_Common_TypeDef *ADCxy_COMMON, uint32_t Multimode)
  3015. {
  3016. MODIFY_REG(ADCxy_COMMON->CR1, ADC_CR1_DUALMOD, Multimode);
  3017. }
  3018. /**
  3019. * @brief Get ADC multimode configuration to operate in independent mode
  3020. * or multimode (for devices with several ADC instances).
  3021. * @note If multimode configuration: the selected ADC instance is
  3022. * either master or slave depending on hardware.
  3023. * Refer to reference manual.
  3024. * @rmtoll CR1 DUALMOD LL_ADC_GetMultimode
  3025. * @param ADCxy_COMMON ADC common instance
  3026. * (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() )
  3027. * @retval Returned value can be one of the following values:
  3028. * @arg @ref LL_ADC_MULTI_INDEPENDENT
  3029. * @arg @ref LL_ADC_MULTI_DUAL_REG_SIMULT
  3030. * @arg @ref LL_ADC_MULTI_DUAL_REG_INTERL_FAST
  3031. * @arg @ref LL_ADC_MULTI_DUAL_REG_INTERL_SLOW
  3032. * @arg @ref LL_ADC_MULTI_DUAL_INJ_SIMULT
  3033. * @arg @ref LL_ADC_MULTI_DUAL_INJ_ALTERN
  3034. * @arg @ref LL_ADC_MULTI_DUAL_REG_SIM_INJ_SIM
  3035. * @arg @ref LL_ADC_MULTI_DUAL_REG_SIM_INJ_ALT
  3036. * @arg @ref LL_ADC_MULTI_DUAL_REG_INTFAST_INJ_SIM
  3037. * @arg @ref LL_ADC_MULTI_DUAL_REG_INTSLOW_INJ_SIM
  3038. */
  3039. __STATIC_INLINE uint32_t LL_ADC_GetMultimode(ADC_Common_TypeDef *ADCxy_COMMON)
  3040. {
  3041. return (uint32_t)(READ_BIT(ADCxy_COMMON->CR1, ADC_CR1_DUALMOD));
  3042. }
  3043. #endif /* ADC_MULTIMODE_SUPPORT */
  3044. /**
  3045. * @}
  3046. */
  3047. /** @defgroup ADC_LL_EF_Operation_ADC_Instance Operation on ADC hierarchical scope: ADC instance
  3048. * @{
  3049. */
  3050. /**
  3051. * @brief Enable the selected ADC instance.
  3052. * @note On this STM32 serie, after ADC enable, a delay for
  3053. * ADC internal analog stabilization is required before performing a
  3054. * ADC conversion start.
  3055. * Refer to device datasheet, parameter tSTAB.
  3056. * @rmtoll CR2 ADON LL_ADC_Enable
  3057. * @param ADCx ADC instance
  3058. * @retval None
  3059. */
  3060. __STATIC_INLINE void LL_ADC_Enable(ADC_TypeDef *ADCx)
  3061. {
  3062. SET_BIT(ADCx->CR2, ADC_CR2_ADON);
  3063. }
  3064. /**
  3065. * @brief Disable the selected ADC instance.
  3066. * @rmtoll CR2 ADON LL_ADC_Disable
  3067. * @param ADCx ADC instance
  3068. * @retval None
  3069. */
  3070. __STATIC_INLINE void LL_ADC_Disable(ADC_TypeDef *ADCx)
  3071. {
  3072. CLEAR_BIT(ADCx->CR2, ADC_CR2_ADON);
  3073. }
  3074. /**
  3075. * @brief Get the selected ADC instance enable state.
  3076. * @rmtoll CR2 ADON LL_ADC_IsEnabled
  3077. * @param ADCx ADC instance
  3078. * @retval 0: ADC is disabled, 1: ADC is enabled.
  3079. */
  3080. __STATIC_INLINE uint32_t LL_ADC_IsEnabled(ADC_TypeDef *ADCx)
  3081. {
  3082. return (READ_BIT(ADCx->CR2, ADC_CR2_ADON) == (ADC_CR2_ADON));
  3083. }
  3084. /**
  3085. * @brief Start ADC calibration in the mode single-ended
  3086. * or differential (for devices with differential mode available).
  3087. * @note On this STM32 serie, before starting a calibration,
  3088. * ADC must be disabled.
  3089. * A minimum number of ADC clock cycles are required
  3090. * between ADC disable state and calibration start.
  3091. * Refer to literal @ref LL_ADC_DELAY_DISABLE_CALIB_ADC_CYCLES.
  3092. * @note On this STM32 serie, hardware prerequisite before starting a calibration:
  3093. the ADC must have been in power-on state for at least
  3094. two ADC clock cycles.
  3095. * @rmtoll CR2 CAL LL_ADC_StartCalibration
  3096. * @param ADCx ADC instance
  3097. * @retval None
  3098. */
  3099. __STATIC_INLINE void LL_ADC_StartCalibration(ADC_TypeDef *ADCx)
  3100. {
  3101. SET_BIT(ADCx->CR2, ADC_CR2_CAL);
  3102. }
  3103. /**
  3104. * @brief Get ADC calibration state.
  3105. * @rmtoll CR2 CAL LL_ADC_IsCalibrationOnGoing
  3106. * @param ADCx ADC instance
  3107. * @retval 0: calibration complete, 1: calibration in progress.
  3108. */
  3109. __STATIC_INLINE uint32_t LL_ADC_IsCalibrationOnGoing(ADC_TypeDef *ADCx)
  3110. {
  3111. return (READ_BIT(ADCx->CR2, ADC_CR2_CAL) == (ADC_CR2_CAL));
  3112. }
  3113. /**
  3114. * @}
  3115. */
  3116. /** @defgroup ADC_LL_EF_Operation_ADC_Group_Regular Operation on ADC hierarchical scope: group regular
  3117. * @{
  3118. */
  3119. /**
  3120. * @brief Start ADC group regular conversion.
  3121. * @note On this STM32 serie, this function is relevant only for
  3122. * internal trigger (SW start), not for external trigger:
  3123. * - If ADC trigger has been set to software start, ADC conversion
  3124. * starts immediately.
  3125. * - If ADC trigger has been set to external trigger, ADC conversion
  3126. * start must be performed using function
  3127. * @ref LL_ADC_REG_StartConversionExtTrig().
  3128. * (if external trigger edge would have been set during ADC other
  3129. * settings, ADC conversion would start at trigger event
  3130. * as soon as ADC is enabled).
  3131. * @rmtoll CR2 SWSTART LL_ADC_REG_StartConversionSWStart
  3132. * @param ADCx ADC instance
  3133. * @retval None
  3134. */
  3135. __STATIC_INLINE void LL_ADC_REG_StartConversionSWStart(ADC_TypeDef *ADCx)
  3136. {
  3137. SET_BIT(ADCx->CR2, (ADC_CR2_SWSTART | ADC_CR2_EXTTRIG));
  3138. }
  3139. /**
  3140. * @brief Start ADC group regular conversion from external trigger.
  3141. * @note ADC conversion will start at next trigger event (on the selected
  3142. * trigger edge) following the ADC start conversion command.
  3143. * @note On this STM32 serie, this function is relevant for
  3144. * ADC conversion start from external trigger.
  3145. * If internal trigger (SW start) is needed, perform ADC conversion
  3146. * start using function @ref LL_ADC_REG_StartConversionSWStart().
  3147. * @rmtoll CR2 EXTEN LL_ADC_REG_StartConversionExtTrig
  3148. * @param ExternalTriggerEdge This parameter can be one of the following values:
  3149. * @arg @ref LL_ADC_REG_TRIG_EXT_RISING
  3150. * @param ADCx ADC instance
  3151. * @retval None
  3152. */
  3153. __STATIC_INLINE void LL_ADC_REG_StartConversionExtTrig(ADC_TypeDef *ADCx, uint32_t ExternalTriggerEdge)
  3154. {
  3155. SET_BIT(ADCx->CR2, ExternalTriggerEdge);
  3156. }
  3157. /**
  3158. * @brief Stop ADC group regular conversion from external trigger.
  3159. * @note No more ADC conversion will start at next trigger event
  3160. * following the ADC stop conversion command.
  3161. * If a conversion is on-going, it will be completed.
  3162. * @note On this STM32 serie, there is no specific command
  3163. * to stop a conversion on-going or to stop ADC converting
  3164. * in continuous mode. These actions can be performed
  3165. * using function @ref LL_ADC_Disable().
  3166. * @rmtoll CR2 EXTSEL LL_ADC_REG_StopConversionExtTrig
  3167. * @param ADCx ADC instance
  3168. * @retval None
  3169. */
  3170. __STATIC_INLINE void LL_ADC_REG_StopConversionExtTrig(ADC_TypeDef *ADCx)
  3171. {
  3172. CLEAR_BIT(ADCx->CR2, ADC_CR2_EXTSEL);
  3173. }
  3174. /**
  3175. * @brief Get ADC group regular conversion data, range fit for
  3176. * all ADC configurations: all ADC resolutions and
  3177. * all oversampling increased data width (for devices
  3178. * with feature oversampling).
  3179. * @rmtoll DR RDATA LL_ADC_REG_ReadConversionData32
  3180. * @param ADCx ADC instance
  3181. * @retval Value between Min_Data=0x00000000 and Max_Data=0xFFFFFFFF
  3182. */
  3183. __STATIC_INLINE uint32_t LL_ADC_REG_ReadConversionData32(ADC_TypeDef *ADCx)
  3184. {
  3185. return (uint16_t)(READ_BIT(ADCx->DR, ADC_DR_DATA));
  3186. }
  3187. /**
  3188. * @brief Get ADC group regular conversion data, range fit for
  3189. * ADC resolution 12 bits.
  3190. * @note For devices with feature oversampling: Oversampling
  3191. * can increase data width, function for extended range
  3192. * may be needed: @ref LL_ADC_REG_ReadConversionData32.
  3193. * @rmtoll DR RDATA LL_ADC_REG_ReadConversionData12
  3194. * @param ADCx ADC instance
  3195. * @retval Value between Min_Data=0x000 and Max_Data=0xFFF
  3196. */
  3197. __STATIC_INLINE uint16_t LL_ADC_REG_ReadConversionData12(ADC_TypeDef *ADCx)
  3198. {
  3199. return (uint16_t)(READ_BIT(ADCx->DR, ADC_DR_DATA));
  3200. }
  3201. #if defined(ADC_MULTIMODE_SUPPORT)
  3202. /**
  3203. * @brief Get ADC multimode conversion data of ADC master, ADC slave
  3204. * or raw data with ADC master and slave concatenated.
  3205. * @note If raw data with ADC master and slave concatenated is retrieved,
  3206. * a macro is available to get the conversion data of
  3207. * ADC master or ADC slave: see helper macro
  3208. * @ref __LL_ADC_MULTI_CONV_DATA_MASTER_SLAVE().
  3209. * (however this macro is mainly intended for multimode
  3210. * transfer by DMA, because this function can do the same
  3211. * by getting multimode conversion data of ADC master or ADC slave
  3212. * separately).
  3213. * @rmtoll DR DATA LL_ADC_REG_ReadMultiConversionData32\n
  3214. * DR ADC2DATA LL_ADC_REG_ReadMultiConversionData32
  3215. * @param ADCx ADC instance
  3216. * (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() )
  3217. * @param ConversionData This parameter can be one of the following values:
  3218. * @arg @ref LL_ADC_MULTI_MASTER
  3219. * @arg @ref LL_ADC_MULTI_SLAVE
  3220. * @arg @ref LL_ADC_MULTI_MASTER_SLAVE
  3221. * @retval Value between Min_Data=0x00000000 and Max_Data=0xFFFFFFFF
  3222. */
  3223. __STATIC_INLINE uint32_t LL_ADC_REG_ReadMultiConversionData32(ADC_TypeDef *ADCx, uint32_t ConversionData)
  3224. {
  3225. return (uint32_t)(READ_BIT(ADCx->DR,
  3226. ADC_DR_ADC2DATA)
  3227. >> POSITION_VAL(ConversionData)
  3228. );
  3229. }
  3230. #endif /* ADC_MULTIMODE_SUPPORT */
  3231. /**
  3232. * @}
  3233. */
  3234. /** @defgroup ADC_LL_EF_Operation_ADC_Group_Injected Operation on ADC hierarchical scope: group injected
  3235. * @{
  3236. */
  3237. /**
  3238. * @brief Start ADC group injected conversion.
  3239. * @note On this STM32 serie, this function is relevant only for
  3240. * internal trigger (SW start), not for external trigger:
  3241. * - If ADC trigger has been set to software start, ADC conversion
  3242. * starts immediately.
  3243. * - If ADC trigger has been set to external trigger, ADC conversion
  3244. * start must be performed using function
  3245. * @ref LL_ADC_INJ_StartConversionExtTrig().
  3246. * (if external trigger edge would have been set during ADC other
  3247. * settings, ADC conversion would start at trigger event
  3248. * as soon as ADC is enabled).
  3249. * @rmtoll CR2 JSWSTART LL_ADC_INJ_StartConversionSWStart
  3250. * @param ADCx ADC instance
  3251. * @retval None
  3252. */
  3253. __STATIC_INLINE void LL_ADC_INJ_StartConversionSWStart(ADC_TypeDef *ADCx)
  3254. {
  3255. SET_BIT(ADCx->CR2, (ADC_CR2_JSWSTART | ADC_CR2_JEXTTRIG));
  3256. }
  3257. /**
  3258. * @brief Start ADC group injected conversion from external trigger.
  3259. * @note ADC conversion will start at next trigger event (on the selected
  3260. * trigger edge) following the ADC start conversion command.
  3261. * @note On this STM32 serie, this function is relevant for
  3262. * ADC conversion start from external trigger.
  3263. * If internal trigger (SW start) is needed, perform ADC conversion
  3264. * start using function @ref LL_ADC_INJ_StartConversionSWStart().
  3265. * @rmtoll CR2 JEXTEN LL_ADC_INJ_StartConversionExtTrig
  3266. * @param ExternalTriggerEdge This parameter can be one of the following values:
  3267. * @arg @ref LL_ADC_INJ_TRIG_EXT_RISING
  3268. * @param ADCx ADC instance
  3269. * @retval None
  3270. */
  3271. __STATIC_INLINE void LL_ADC_INJ_StartConversionExtTrig(ADC_TypeDef *ADCx, uint32_t ExternalTriggerEdge)
  3272. {
  3273. SET_BIT(ADCx->CR2, ExternalTriggerEdge);
  3274. }
  3275. /**
  3276. * @brief Stop ADC group injected conversion from external trigger.
  3277. * @note No more ADC conversion will start at next trigger event
  3278. * following the ADC stop conversion command.
  3279. * If a conversion is on-going, it will be completed.
  3280. * @note On this STM32 serie, there is no specific command
  3281. * to stop a conversion on-going or to stop ADC converting
  3282. * in continuous mode. These actions can be performed
  3283. * using function @ref LL_ADC_Disable().
  3284. * @rmtoll CR2 JEXTSEL LL_ADC_INJ_StopConversionExtTrig
  3285. * @param ADCx ADC instance
  3286. * @retval None
  3287. */
  3288. __STATIC_INLINE void LL_ADC_INJ_StopConversionExtTrig(ADC_TypeDef *ADCx)
  3289. {
  3290. CLEAR_BIT(ADCx->CR2, ADC_CR2_JEXTSEL);
  3291. }
  3292. /**
  3293. * @brief Get ADC group regular conversion data, range fit for
  3294. * all ADC configurations: all ADC resolutions and
  3295. * all oversampling increased data width (for devices
  3296. * with feature oversampling).
  3297. * @rmtoll JDR1 JDATA LL_ADC_INJ_ReadConversionData32\n
  3298. * JDR2 JDATA LL_ADC_INJ_ReadConversionData32\n
  3299. * JDR3 JDATA LL_ADC_INJ_ReadConversionData32\n
  3300. * JDR4 JDATA LL_ADC_INJ_ReadConversionData32
  3301. * @param ADCx ADC instance
  3302. * @param Rank This parameter can be one of the following values:
  3303. * @arg @ref LL_ADC_INJ_RANK_1
  3304. * @arg @ref LL_ADC_INJ_RANK_2
  3305. * @arg @ref LL_ADC_INJ_RANK_3
  3306. * @arg @ref LL_ADC_INJ_RANK_4
  3307. * @retval Value between Min_Data=0x00000000 and Max_Data=0xFFFFFFFF
  3308. */
  3309. __STATIC_INLINE uint32_t LL_ADC_INJ_ReadConversionData32(ADC_TypeDef *ADCx, uint32_t Rank)
  3310. {
  3311. register uint32_t *preg = __ADC_PTR_REG_OFFSET(ADCx->JDR1, __ADC_MASK_SHIFT(Rank, ADC_INJ_JDRX_REGOFFSET_MASK));
  3312. return (uint32_t)(READ_BIT(*preg,
  3313. ADC_JDR1_JDATA)
  3314. );
  3315. }
  3316. /**
  3317. * @brief Get ADC group injected conversion data, range fit for
  3318. * ADC resolution 12 bits.
  3319. * @note For devices with feature oversampling: Oversampling
  3320. * can increase data width, function for extended range
  3321. * may be needed: @ref LL_ADC_INJ_ReadConversionData32.
  3322. * @rmtoll JDR1 JDATA LL_ADC_INJ_ReadConversionData12\n
  3323. * JDR2 JDATA LL_ADC_INJ_ReadConversionData12\n
  3324. * JDR3 JDATA LL_ADC_INJ_ReadConversionData12\n
  3325. * JDR4 JDATA LL_ADC_INJ_ReadConversionData12
  3326. * @param ADCx ADC instance
  3327. * @param Rank This parameter can be one of the following values:
  3328. * @arg @ref LL_ADC_INJ_RANK_1
  3329. * @arg @ref LL_ADC_INJ_RANK_2
  3330. * @arg @ref LL_ADC_INJ_RANK_3
  3331. * @arg @ref LL_ADC_INJ_RANK_4
  3332. * @retval Value between Min_Data=0x000 and Max_Data=0xFFF
  3333. */
  3334. __STATIC_INLINE uint16_t LL_ADC_INJ_ReadConversionData12(ADC_TypeDef *ADCx, uint32_t Rank)
  3335. {
  3336. register uint32_t *preg = __ADC_PTR_REG_OFFSET(ADCx->JDR1, __ADC_MASK_SHIFT(Rank, ADC_INJ_JDRX_REGOFFSET_MASK));
  3337. return (uint16_t)(READ_BIT(*preg,
  3338. ADC_JDR1_JDATA)
  3339. );
  3340. }
  3341. /**
  3342. * @}
  3343. */
  3344. /** @defgroup ADC_LL_EF_FLAG_Management ADC flag management
  3345. * @{
  3346. */
  3347. /**
  3348. * @brief Get flag ADC group regular end of sequence conversions.
  3349. * @rmtoll SR EOC LL_ADC_IsActiveFlag_EOS
  3350. * @param ADCx ADC instance
  3351. * @retval State of bit (1 or 0).
  3352. */
  3353. __STATIC_INLINE uint32_t LL_ADC_IsActiveFlag_EOS(ADC_TypeDef *ADCx)
  3354. {
  3355. /* Note: on this STM32 serie, there is no flag ADC group regular */
  3356. /* end of unitary conversion. */
  3357. /* Flag noted as "EOC" is corresponding to flag "EOS" */
  3358. /* in other STM32 families). */
  3359. return (READ_BIT(ADCx->SR, LL_ADC_FLAG_EOS) == (LL_ADC_FLAG_EOS));
  3360. }
  3361. /**
  3362. * @brief Get flag ADC group injected end of sequence conversions.
  3363. * @rmtoll SR JEOC LL_ADC_IsActiveFlag_JEOS
  3364. * @param ADCx ADC instance
  3365. * @retval State of bit (1 or 0).
  3366. */
  3367. __STATIC_INLINE uint32_t LL_ADC_IsActiveFlag_JEOS(ADC_TypeDef *ADCx)
  3368. {
  3369. /* Note: on this STM32 serie, there is no flag ADC group injected */
  3370. /* end of unitary conversion. */
  3371. /* Flag noted as "JEOC" is corresponding to flag "JEOS" */
  3372. /* in other STM32 families). */
  3373. return (READ_BIT(ADCx->SR, LL_ADC_FLAG_JEOS) == (LL_ADC_FLAG_JEOS));
  3374. }
  3375. /**
  3376. * @brief Get flag ADC analog watchdog 1 flag
  3377. * @rmtoll SR AWD LL_ADC_IsActiveFlag_AWD1
  3378. * @param ADCx ADC instance
  3379. * @retval State of bit (1 or 0).
  3380. */
  3381. __STATIC_INLINE uint32_t LL_ADC_IsActiveFlag_AWD1(ADC_TypeDef *ADCx)
  3382. {
  3383. return (READ_BIT(ADCx->SR, LL_ADC_FLAG_AWD1) == (LL_ADC_FLAG_AWD1));
  3384. }
  3385. /**
  3386. * @brief Clear flag ADC group regular end of sequence conversions.
  3387. * @rmtoll SR EOC LL_ADC_ClearFlag_EOS
  3388. * @param ADCx ADC instance
  3389. * @retval None
  3390. */
  3391. __STATIC_INLINE void LL_ADC_ClearFlag_EOS(ADC_TypeDef *ADCx)
  3392. {
  3393. /* Note: on this STM32 serie, there is no flag ADC group regular */
  3394. /* end of unitary conversion. */
  3395. /* Flag noted as "EOC" is corresponding to flag "EOS" */
  3396. /* in other STM32 families). */
  3397. WRITE_REG(ADCx->SR, ~LL_ADC_FLAG_EOS);
  3398. }
  3399. /**
  3400. * @brief Clear flag ADC group injected end of sequence conversions.
  3401. * @rmtoll SR JEOC LL_ADC_ClearFlag_JEOS
  3402. * @param ADCx ADC instance
  3403. * @retval None
  3404. */
  3405. __STATIC_INLINE void LL_ADC_ClearFlag_JEOS(ADC_TypeDef *ADCx)
  3406. {
  3407. /* Note: on this STM32 serie, there is no flag ADC group injected */
  3408. /* end of unitary conversion. */
  3409. /* Flag noted as "JEOC" is corresponding to flag "JEOS" */
  3410. /* in other STM32 families). */
  3411. WRITE_REG(ADCx->SR, ~LL_ADC_FLAG_JEOS);
  3412. }
  3413. /**
  3414. * @brief Clear flag ADC analog watchdog 1.
  3415. * @rmtoll SR AWD LL_ADC_ClearFlag_AWD1
  3416. * @param ADCx ADC instance
  3417. * @retval None
  3418. */
  3419. __STATIC_INLINE void LL_ADC_ClearFlag_AWD1(ADC_TypeDef *ADCx)
  3420. {
  3421. WRITE_REG(ADCx->SR, ~LL_ADC_FLAG_AWD1);
  3422. }
  3423. #if defined(ADC_MULTIMODE_SUPPORT)
  3424. /**
  3425. * @brief Get flag multimode ADC group regular end of sequence conversions of the ADC master.
  3426. * @rmtoll SR EOC LL_ADC_IsActiveFlag_MST_EOS
  3427. * @param ADCxy_COMMON ADC common instance
  3428. * (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() )
  3429. * @retval State of bit (1 or 0).
  3430. */
  3431. __STATIC_INLINE uint32_t LL_ADC_IsActiveFlag_MST_EOS(ADC_Common_TypeDef *ADCxy_COMMON)
  3432. {
  3433. /* Note: on this STM32 serie, there is no flag ADC group regular */
  3434. /* end of unitary conversion. */
  3435. /* Flag noted as "EOC" is corresponding to flag "EOS" */
  3436. /* in other STM32 families). */
  3437. return (READ_BIT(ADCxy_COMMON->SR, ADC_SR_EOC) == (ADC_SR_EOC));
  3438. }
  3439. /**
  3440. * @brief Get flag multimode ADC group regular end of sequence conversions of the ADC slave.
  3441. * @rmtoll SR EOC LL_ADC_IsActiveFlag_SLV_EOS
  3442. * @param ADCxy_COMMON ADC common instance
  3443. * (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() )
  3444. * @retval State of bit (1 or 0).
  3445. */
  3446. __STATIC_INLINE uint32_t LL_ADC_IsActiveFlag_SLV_EOS(ADC_Common_TypeDef *ADCxy_COMMON)
  3447. {
  3448. /* Note: on this STM32 serie, there is no flag ADC group regular */
  3449. /* end of unitary conversion. */
  3450. /* Flag noted as "EOC" is corresponding to flag "EOS" */
  3451. /* in other STM32 families). */
  3452. register uint32_t *preg = __ADC_PTR_REG_OFFSET(ADCxy_COMMON->SR, 1U);
  3453. return (READ_BIT(*preg, LL_ADC_FLAG_EOS_SLV) == (LL_ADC_FLAG_EOS_SLV));
  3454. }
  3455. /**
  3456. * @brief Get flag multimode ADC group injected end of sequence conversions of the ADC master.
  3457. * @rmtoll SR JEOC LL_ADC_IsActiveFlag_MST_JEOS
  3458. * @param ADCxy_COMMON ADC common instance
  3459. * (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() )
  3460. * @retval State of bit (1 or 0).
  3461. */
  3462. __STATIC_INLINE uint32_t LL_ADC_IsActiveFlag_MST_JEOS(ADC_Common_TypeDef *ADCxy_COMMON)
  3463. {
  3464. /* Note: on this STM32 serie, there is no flag ADC group injected */
  3465. /* end of unitary conversion. */
  3466. /* Flag noted as "JEOC" is corresponding to flag "JEOS" */
  3467. /* in other STM32 families). */
  3468. return (READ_BIT(ADC1->SR, ADC_SR_JEOC) == (ADC_SR_JEOC));
  3469. }
  3470. /**
  3471. * @brief Get flag multimode ADC group injected end of sequence conversions of the ADC slave.
  3472. * @rmtoll SR JEOC LL_ADC_IsActiveFlag_SLV_JEOS
  3473. * @param ADCxy_COMMON ADC common instance
  3474. * (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() )
  3475. * @retval State of bit (1 or 0).
  3476. */
  3477. __STATIC_INLINE uint32_t LL_ADC_IsActiveFlag_SLV_JEOS(ADC_Common_TypeDef *ADCxy_COMMON)
  3478. {
  3479. /* Note: on this STM32 serie, there is no flag ADC group injected */
  3480. /* end of unitary conversion. */
  3481. /* Flag noted as "JEOC" is corresponding to flag "JEOS" */
  3482. /* in other STM32 families). */
  3483. register uint32_t *preg = __ADC_PTR_REG_OFFSET(ADCxy_COMMON->SR, 1U);
  3484. return (READ_BIT(*preg, LL_ADC_FLAG_JEOS_SLV) == (LL_ADC_FLAG_JEOS_SLV));
  3485. }
  3486. /**
  3487. * @brief Get flag multimode ADC analog watchdog 1 of the ADC master.
  3488. * @rmtoll SR AWD LL_ADC_IsActiveFlag_MST_AWD1
  3489. * @param ADCxy_COMMON ADC common instance
  3490. * (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() )
  3491. * @retval State of bit (1 or 0).
  3492. */
  3493. __STATIC_INLINE uint32_t LL_ADC_IsActiveFlag_MST_AWD1(ADC_Common_TypeDef *ADCxy_COMMON)
  3494. {
  3495. return (READ_BIT(ADC1->SR, LL_ADC_FLAG_AWD1) == (LL_ADC_FLAG_AWD1));
  3496. }
  3497. /**
  3498. * @brief Get flag multimode analog watchdog 1 of the ADC slave.
  3499. * @rmtoll SR AWD LL_ADC_IsActiveFlag_SLV_AWD1
  3500. * @param ADCxy_COMMON ADC common instance
  3501. * (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() )
  3502. * @retval State of bit (1 or 0).
  3503. */
  3504. __STATIC_INLINE uint32_t LL_ADC_IsActiveFlag_SLV_AWD1(ADC_Common_TypeDef *ADCxy_COMMON)
  3505. {
  3506. register uint32_t *preg = __ADC_PTR_REG_OFFSET(ADCxy_COMMON->SR, 1U);
  3507. return (READ_BIT(*preg, LL_ADC_FLAG_AWD1) == (LL_ADC_FLAG_AWD1));
  3508. }
  3509. #endif /* ADC_MULTIMODE_SUPPORT */
  3510. /**
  3511. * @}
  3512. */
  3513. /** @defgroup ADC_LL_EF_IT_Management ADC IT management
  3514. * @{
  3515. */
  3516. /**
  3517. * @brief Enable interruption ADC group regular end of sequence conversions.
  3518. * @rmtoll CR1 EOCIE LL_ADC_EnableIT_EOS
  3519. * @param ADCx ADC instance
  3520. * @retval None
  3521. */
  3522. __STATIC_INLINE void LL_ADC_EnableIT_EOS(ADC_TypeDef *ADCx)
  3523. {
  3524. /* Note: on this STM32 serie, there is no flag ADC group regular */
  3525. /* end of unitary conversion. */
  3526. /* Flag noted as "EOC" is corresponding to flag "EOS" */
  3527. /* in other STM32 families). */
  3528. SET_BIT(ADCx->CR1, ADC_CR1_EOCIE);
  3529. }
  3530. /**
  3531. * @brief Enable interruption ADC group injected end of sequence conversions.
  3532. * @rmtoll CR1 JEOCIE LL_ADC_EnableIT_JEOS
  3533. * @param ADCx ADC instance
  3534. * @retval None
  3535. */
  3536. __STATIC_INLINE void LL_ADC_EnableIT_JEOS(ADC_TypeDef *ADCx)
  3537. {
  3538. /* Note: on this STM32 serie, there is no flag ADC group injected */
  3539. /* end of unitary conversion. */
  3540. /* Flag noted as "JEOC" is corresponding to flag "JEOS" */
  3541. /* in other STM32 families). */
  3542. SET_BIT(ADCx->CR1, LL_ADC_IT_JEOS);
  3543. }
  3544. /**
  3545. * @brief Enable interruption ADC analog watchdog 1.
  3546. * @rmtoll CR1 AWDIE LL_ADC_EnableIT_AWD1
  3547. * @param ADCx ADC instance
  3548. * @retval None
  3549. */
  3550. __STATIC_INLINE void LL_ADC_EnableIT_AWD1(ADC_TypeDef *ADCx)
  3551. {
  3552. SET_BIT(ADCx->CR1, LL_ADC_IT_AWD1);
  3553. }
  3554. /**
  3555. * @brief Disable interruption ADC group regular end of sequence conversions.
  3556. * @rmtoll CR1 EOCIE LL_ADC_DisableIT_EOS
  3557. * @param ADCx ADC instance
  3558. * @retval None
  3559. */
  3560. __STATIC_INLINE void LL_ADC_DisableIT_EOS(ADC_TypeDef *ADCx)
  3561. {
  3562. /* Note: on this STM32 serie, there is no flag ADC group regular */
  3563. /* end of unitary conversion. */
  3564. /* Flag noted as "EOC" is corresponding to flag "EOS" */
  3565. /* in other STM32 families). */
  3566. CLEAR_BIT(ADCx->CR1, ADC_CR1_EOCIE);
  3567. }
  3568. /**
  3569. * @brief Disable interruption ADC group injected end of sequence conversions.
  3570. * @rmtoll CR1 JEOCIE LL_ADC_EnableIT_JEOS
  3571. * @param ADCx ADC instance
  3572. * @retval None
  3573. */
  3574. __STATIC_INLINE void LL_ADC_DisableIT_JEOS(ADC_TypeDef *ADCx)
  3575. {
  3576. /* Note: on this STM32 serie, there is no flag ADC group injected */
  3577. /* end of unitary conversion. */
  3578. /* Flag noted as "JEOC" is corresponding to flag "JEOS" */
  3579. /* in other STM32 families). */
  3580. CLEAR_BIT(ADCx->CR1, LL_ADC_IT_JEOS);
  3581. }
  3582. /**
  3583. * @brief Disable interruption ADC analog watchdog 1.
  3584. * @rmtoll CR1 AWDIE LL_ADC_EnableIT_AWD1
  3585. * @param ADCx ADC instance
  3586. * @retval None
  3587. */
  3588. __STATIC_INLINE void LL_ADC_DisableIT_AWD1(ADC_TypeDef *ADCx)
  3589. {
  3590. CLEAR_BIT(ADCx->CR1, LL_ADC_IT_AWD1);
  3591. }
  3592. /**
  3593. * @brief Get state of interruption ADC group regular end of sequence conversions
  3594. * (0: interrupt disabled, 1: interrupt enabled).
  3595. * @rmtoll CR1 EOCIE LL_ADC_IsEnabledIT_EOS
  3596. * @param ADCx ADC instance
  3597. * @retval State of bit (1 or 0).
  3598. */
  3599. __STATIC_INLINE uint32_t LL_ADC_IsEnabledIT_EOS(ADC_TypeDef *ADCx)
  3600. {
  3601. /* Note: on this STM32 serie, there is no flag ADC group regular */
  3602. /* end of unitary conversion. */
  3603. /* Flag noted as "EOC" is corresponding to flag "EOS" */
  3604. /* in other STM32 families). */
  3605. return (READ_BIT(ADCx->CR1, LL_ADC_IT_EOS) == (LL_ADC_IT_EOS));
  3606. }
  3607. /**
  3608. * @brief Get state of interruption ADC group injected end of sequence conversions
  3609. * (0: interrupt disabled, 1: interrupt enabled).
  3610. * @rmtoll CR1 JEOCIE LL_ADC_EnableIT_JEOS
  3611. * @param ADCx ADC instance
  3612. * @retval State of bit (1 or 0).
  3613. */
  3614. __STATIC_INLINE uint32_t LL_ADC_IsEnabledIT_JEOS(ADC_TypeDef *ADCx)
  3615. {
  3616. /* Note: on this STM32 serie, there is no flag ADC group injected */
  3617. /* end of unitary conversion. */
  3618. /* Flag noted as "JEOC" is corresponding to flag "JEOS" */
  3619. /* in other STM32 families). */
  3620. return (READ_BIT(ADCx->CR1, LL_ADC_IT_JEOS) == (LL_ADC_IT_JEOS));
  3621. }
  3622. /**
  3623. * @brief Get state of interruption ADC analog watchdog 1
  3624. * (0: interrupt disabled, 1: interrupt enabled).
  3625. * @rmtoll CR1 AWDIE LL_ADC_EnableIT_AWD1
  3626. * @param ADCx ADC instance
  3627. * @retval State of bit (1 or 0).
  3628. */
  3629. __STATIC_INLINE uint32_t LL_ADC_IsEnabledIT_AWD1(ADC_TypeDef *ADCx)
  3630. {
  3631. return (READ_BIT(ADCx->CR1, LL_ADC_IT_AWD1) == (LL_ADC_IT_AWD1));
  3632. }
  3633. /**
  3634. * @}
  3635. */
  3636. #if defined(USE_FULL_LL_DRIVER)
  3637. /** @defgroup ADC_LL_EF_Init Initialization and de-initialization functions
  3638. * @{
  3639. */
  3640. /* Initialization of some features of ADC common parameters and multimode */
  3641. ErrorStatus LL_ADC_CommonDeInit(ADC_Common_TypeDef *ADCxy_COMMON);
  3642. ErrorStatus LL_ADC_CommonInit(ADC_Common_TypeDef *ADCxy_COMMON, LL_ADC_CommonInitTypeDef *ADC_CommonInitStruct);
  3643. void LL_ADC_CommonStructInit(LL_ADC_CommonInitTypeDef *ADC_CommonInitStruct);
  3644. /* De-initialization of ADC instance, ADC group regular and ADC group injected */
  3645. /* (availability of ADC group injected depends on STM32 families) */
  3646. ErrorStatus LL_ADC_DeInit(ADC_TypeDef *ADCx);
  3647. /* Initialization of some features of ADC instance */
  3648. ErrorStatus LL_ADC_Init(ADC_TypeDef *ADCx, LL_ADC_InitTypeDef *ADC_InitStruct);
  3649. void LL_ADC_StructInit(LL_ADC_InitTypeDef *ADC_InitStruct);
  3650. /* Initialization of some features of ADC instance and ADC group regular */
  3651. ErrorStatus LL_ADC_REG_Init(ADC_TypeDef *ADCx, LL_ADC_REG_InitTypeDef *ADC_REG_InitStruct);
  3652. void LL_ADC_REG_StructInit(LL_ADC_REG_InitTypeDef *ADC_REG_InitStruct);
  3653. /* Initialization of some features of ADC instance and ADC group injected */
  3654. ErrorStatus LL_ADC_INJ_Init(ADC_TypeDef *ADCx, LL_ADC_INJ_InitTypeDef *ADC_INJ_InitStruct);
  3655. void LL_ADC_INJ_StructInit(LL_ADC_INJ_InitTypeDef *ADC_INJ_InitStruct);
  3656. /**
  3657. * @}
  3658. */
  3659. #endif /* USE_FULL_LL_DRIVER */
  3660. /**
  3661. * @}
  3662. */
  3663. /**
  3664. * @}
  3665. */
  3666. #endif /* ADC1 || ADC2 || ADC3 */
  3667. /**
  3668. * @}
  3669. */
  3670. #ifdef __cplusplus
  3671. }
  3672. #endif
  3673. #endif /* __STM32F1xx_LL_ADC_H */
  3674. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/