stm32l1xx_ll_adc.h 320 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175
  1. /**
  2. ******************************************************************************
  3. * @file stm32l1xx_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 __STM32L1xx_LL_ADC_H
  37. #define __STM32L1xx_LL_ADC_H
  38. #ifdef __cplusplus
  39. extern "C" {
  40. #endif
  41. /* Includes ------------------------------------------------------------------*/
  42. #include "stm32l1xx.h"
  43. /** @addtogroup STM32L1xx_LL_Driver
  44. * @{
  45. */
  46. #if defined (ADC1)
  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_SQR5_REGOFFSET 0x00000400U
  67. #define ADC_REG_SQRX_REGOFFSET_MASK (ADC_SQR1_REGOFFSET | ADC_SQR2_REGOFFSET | ADC_SQR3_REGOFFSET | ADC_SQR4_REGOFFSET | ADC_SQR5_REGOFFSET)
  68. #define ADC_REG_RANK_ID_SQRX_MASK (ADC_CHANNEL_ID_NUMBER_MASK_POSBIT0)
  69. /* Definition of ADC group regular sequencer bits information to be inserted */
  70. /* into ADC group regular sequencer ranks literals definition. */
  71. #define ADC_REG_RANK_1_SQRX_BITOFFSET_POS ( 0U) /* Value equivalent to POSITION_VAL(ADC_SQR5_SQ1) */
  72. #define ADC_REG_RANK_2_SQRX_BITOFFSET_POS ( 5U) /* Value equivalent to POSITION_VAL(ADC_SQR5_SQ2) */
  73. #define ADC_REG_RANK_3_SQRX_BITOFFSET_POS (10U) /* Value equivalent to POSITION_VAL(ADC_SQR5_SQ3) */
  74. #define ADC_REG_RANK_4_SQRX_BITOFFSET_POS (15U) /* Value equivalent to POSITION_VAL(ADC_SQR5_SQ4) */
  75. #define ADC_REG_RANK_5_SQRX_BITOFFSET_POS (20U) /* Value equivalent to POSITION_VAL(ADC_SQR5_SQ5) */
  76. #define ADC_REG_RANK_6_SQRX_BITOFFSET_POS (25U) /* Value equivalent to POSITION_VAL(ADC_SQR5_SQ6) */
  77. #define ADC_REG_RANK_7_SQRX_BITOFFSET_POS ( 0U) /* Value equivalent to POSITION_VAL(ADC_SQR4_SQ7) */
  78. #define ADC_REG_RANK_8_SQRX_BITOFFSET_POS ( 5U) /* Value equivalent to POSITION_VAL(ADC_SQR4_SQ8) */
  79. #define ADC_REG_RANK_9_SQRX_BITOFFSET_POS (10U) /* Value equivalent to POSITION_VAL(ADC_SQR4_SQ9) */
  80. #define ADC_REG_RANK_10_SQRX_BITOFFSET_POS (15U) /* Value equivalent to POSITION_VAL(ADC_SQR4_SQ10) */
  81. #define ADC_REG_RANK_11_SQRX_BITOFFSET_POS (20U) /* Value equivalent to POSITION_VAL(ADC_SQR4_SQ11) */
  82. #define ADC_REG_RANK_12_SQRX_BITOFFSET_POS (25U) /* Value equivalent to POSITION_VAL(ADC_SQR4_SQ12) */
  83. #define ADC_REG_RANK_13_SQRX_BITOFFSET_POS ( 0U) /* Value equivalent to POSITION_VAL(ADC_SQR3_SQ13) */
  84. #define ADC_REG_RANK_14_SQRX_BITOFFSET_POS ( 5U) /* Value equivalent to POSITION_VAL(ADC_SQR3_SQ14) */
  85. #define ADC_REG_RANK_15_SQRX_BITOFFSET_POS (10U) /* Value equivalent to POSITION_VAL(ADC_SQR3_SQ15) */
  86. #define ADC_REG_RANK_16_SQRX_BITOFFSET_POS (15U) /* Value equivalent to POSITION_VAL(ADC_SQR3_SQ16) */
  87. #define ADC_REG_RANK_17_SQRX_BITOFFSET_POS (20U) /* Value equivalent to POSITION_VAL(ADC_SQR3_SQ17) */
  88. #define ADC_REG_RANK_18_SQRX_BITOFFSET_POS (25U) /* Value equivalent to POSITION_VAL(ADC_SQR3_SQ18) */
  89. #define ADC_REG_RANK_19_SQRX_BITOFFSET_POS ( 0U) /* Value equivalent to POSITION_VAL(ADC_SQR2_SQ29) */
  90. #define ADC_REG_RANK_20_SQRX_BITOFFSET_POS ( 5U) /* Value equivalent to POSITION_VAL(ADC_SQR2_SQ20) */
  91. #define ADC_REG_RANK_21_SQRX_BITOFFSET_POS (10U) /* Value equivalent to POSITION_VAL(ADC_SQR2_SQ21) */
  92. #define ADC_REG_RANK_22_SQRX_BITOFFSET_POS (15U) /* Value equivalent to POSITION_VAL(ADC_SQR2_SQ22) */
  93. #define ADC_REG_RANK_23_SQRX_BITOFFSET_POS (20U) /* Value equivalent to POSITION_VAL(ADC_SQR2_SQ23) */
  94. #define ADC_REG_RANK_24_SQRX_BITOFFSET_POS (25U) /* Value equivalent to POSITION_VAL(ADC_SQR2_SQ24) */
  95. #define ADC_REG_RANK_25_SQRX_BITOFFSET_POS ( 0U) /* Value equivalent to POSITION_VAL(ADC_SQR1_SQ25) */
  96. #define ADC_REG_RANK_26_SQRX_BITOFFSET_POS ( 5U) /* Value equivalent to POSITION_VAL(ADC_SQR1_SQ26) */
  97. #define ADC_REG_RANK_27_SQRX_BITOFFSET_POS (10U) /* Value equivalent to POSITION_VAL(ADC_SQR1_SQ27) */
  98. #if defined(ADC_SQR1_SQ28)
  99. #define ADC_REG_RANK_28_SQRX_BITOFFSET_POS (15U) /* Value equivalent to POSITION_VAL(ADC_SQR1_SQ28) */
  100. #endif
  101. /* Internal mask for ADC group injected sequencer: */
  102. /* To select into literal LL_ADC_INJ_RANK_x the relevant bits for: */
  103. /* - data register offset */
  104. /* - offset register offset */
  105. /* - sequencer rank bits position into the selected register */
  106. /* Internal register offset for ADC group injected data register */
  107. /* (offset placed into a spare area of literal definition) */
  108. #define ADC_JDR1_REGOFFSET 0x00000000U
  109. #define ADC_JDR2_REGOFFSET 0x00000100U
  110. #define ADC_JDR3_REGOFFSET 0x00000200U
  111. #define ADC_JDR4_REGOFFSET 0x00000300U
  112. /* Internal register offset for ADC group injected offset configuration */
  113. /* (offset placed into a spare area of literal definition) */
  114. #define ADC_JOFR1_REGOFFSET 0x00000000U
  115. #define ADC_JOFR2_REGOFFSET 0x00001000U
  116. #define ADC_JOFR3_REGOFFSET 0x00002000U
  117. #define ADC_JOFR4_REGOFFSET 0x00003000U
  118. #define ADC_INJ_JDRX_REGOFFSET_MASK (ADC_JDR1_REGOFFSET | ADC_JDR2_REGOFFSET | ADC_JDR3_REGOFFSET | ADC_JDR4_REGOFFSET)
  119. #define ADC_INJ_JOFRX_REGOFFSET_MASK (ADC_JOFR1_REGOFFSET | ADC_JOFR2_REGOFFSET | ADC_JOFR3_REGOFFSET | ADC_JOFR4_REGOFFSET)
  120. #define ADC_INJ_RANK_ID_JSQR_MASK (ADC_CHANNEL_ID_NUMBER_MASK_POSBIT0)
  121. /* Definition of ADC group injected sequencer bits information to be inserted */
  122. /* into ADC group injected sequencer ranks literals definition. */
  123. #define ADC_INJ_RANK_1_JSQR_BITOFFSET_POS ( 0U) /* Value equivalent to POSITION_VAL(ADC_JSQR_JSQ1) */
  124. #define ADC_INJ_RANK_2_JSQR_BITOFFSET_POS ( 5U) /* Value equivalent to POSITION_VAL(ADC_JSQR_JSQ2) */
  125. #define ADC_INJ_RANK_3_JSQR_BITOFFSET_POS (10U) /* Value equivalent to POSITION_VAL(ADC_JSQR_JSQ3) */
  126. #define ADC_INJ_RANK_4_JSQR_BITOFFSET_POS (15U) /* Value equivalent to POSITION_VAL(ADC_JSQR_JSQ4) */
  127. /* Internal mask for ADC group regular trigger: */
  128. /* To select into literal LL_ADC_REG_TRIG_x the relevant bits for: */
  129. /* - regular trigger source */
  130. /* - regular trigger edge */
  131. #define ADC_REG_TRIG_EXT_EDGE_DEFAULT (ADC_CR2_EXTEN_0) /* Trigger edge set to rising edge (default setting for compatibility with some ADC on other STM32 families having this setting set by HW default value) */
  132. /* Mask containing trigger source masks for each of possible */
  133. /* trigger edge selection duplicated with shifts [0; 4; 8; 12] */
  134. /* corresponding to {SW start; ext trigger; ext trigger; ext trigger}. */
  135. #define ADC_REG_TRIG_SOURCE_MASK (((LL_ADC_REG_TRIG_SOFTWARE & ADC_CR2_EXTSEL) >> (4U * 0U)) | \
  136. ((ADC_CR2_EXTSEL) >> (4U * 1U)) | \
  137. ((ADC_CR2_EXTSEL) >> (4U * 2U)) | \
  138. ((ADC_CR2_EXTSEL) >> (4U * 3U)))
  139. /* Mask containing trigger edge masks for each of possible */
  140. /* trigger edge selection duplicated with shifts [0; 4; 8; 12] */
  141. /* corresponding to {SW start; ext trigger; ext trigger; ext trigger}. */
  142. #define ADC_REG_TRIG_EDGE_MASK (((LL_ADC_REG_TRIG_SOFTWARE & ADC_CR2_EXTEN) >> (4U * 0U)) | \
  143. ((ADC_REG_TRIG_EXT_EDGE_DEFAULT) >> (4U * 1U)) | \
  144. ((ADC_REG_TRIG_EXT_EDGE_DEFAULT) >> (4U * 2U)) | \
  145. ((ADC_REG_TRIG_EXT_EDGE_DEFAULT) >> (4U * 3U)))
  146. /* Definition of ADC group regular trigger bits information. */
  147. #define ADC_REG_TRIG_EXTSEL_BITOFFSET_POS (24U) /* Value equivalent to POSITION_VAL(ADC_CR2_EXTSEL) */
  148. #define ADC_REG_TRIG_EXTEN_BITOFFSET_POS (28U) /* Value equivalent to POSITION_VAL(ADC_CR2_EXTEN) */
  149. /* Internal mask for ADC group injected trigger: */
  150. /* To select into literal LL_ADC_INJ_TRIG_x the relevant bits for: */
  151. /* - injected trigger source */
  152. /* - injected trigger edge */
  153. #define ADC_INJ_TRIG_EXT_EDGE_DEFAULT (ADC_CR2_JEXTEN_0) /* Trigger edge set to rising edge (default setting for compatibility with some ADC on other STM32 families having this setting set by HW default value) */
  154. /* Mask containing trigger source masks for each of possible */
  155. /* trigger edge selection duplicated with shifts [0; 4; 8; 12] */
  156. /* corresponding to {SW start; ext trigger; ext trigger; ext trigger}. */
  157. #define ADC_INJ_TRIG_SOURCE_MASK (((LL_ADC_REG_TRIG_SOFTWARE & ADC_CR2_JEXTSEL) >> (4U * 0U)) | \
  158. ((ADC_CR2_JEXTSEL) >> (4U * 1U)) | \
  159. ((ADC_CR2_JEXTSEL) >> (4U * 2U)) | \
  160. ((ADC_CR2_JEXTSEL) >> (4U * 3U)))
  161. /* Mask containing trigger edge masks for each of possible */
  162. /* trigger edge selection duplicated with shifts [0; 4; 8; 12] */
  163. /* corresponding to {SW start; ext trigger; ext trigger; ext trigger}. */
  164. #define ADC_INJ_TRIG_EDGE_MASK (((LL_ADC_INJ_TRIG_SOFTWARE & ADC_CR2_JEXTEN) >> (4U * 0U)) | \
  165. ((ADC_INJ_TRIG_EXT_EDGE_DEFAULT) >> (4U * 1U)) | \
  166. ((ADC_INJ_TRIG_EXT_EDGE_DEFAULT) >> (4U * 2U)) | \
  167. ((ADC_INJ_TRIG_EXT_EDGE_DEFAULT) >> (4U * 3U)))
  168. /* Definition of ADC group injected trigger bits information. */
  169. #define ADC_INJ_TRIG_EXTSEL_BITOFFSET_POS (16U) /* Value equivalent to POSITION_VAL(ADC_CR2_JEXTSEL) */
  170. #define ADC_INJ_TRIG_EXTEN_BITOFFSET_POS (20U) /* Value equivalent to POSITION_VAL(ADC_CR2_JEXTEN) */
  171. /* Internal mask for ADC channel: */
  172. /* To select into literal LL_ADC_CHANNEL_x the relevant bits for: */
  173. /* - channel identifier defined by number */
  174. /* - channel differentiation between external channels (connected to */
  175. /* GPIO pins) and internal channels (connected to internal paths) */
  176. /* - channel sampling time defined by SMPRx register offset */
  177. /* and SMPx bits positions into SMPRx register */
  178. #define ADC_CHANNEL_ID_NUMBER_MASK (ADC_CR1_AWDCH)
  179. #define ADC_CHANNEL_ID_NUMBER_BITOFFSET_POS ( 0U)/* Value equivalent to POSITION_VAL(ADC_CHANNEL_ID_NUMBER_MASK) */
  180. #define ADC_CHANNEL_ID_MASK (ADC_CHANNEL_ID_NUMBER_MASK | ADC_CHANNEL_ID_INTERNAL_CH_MASK)
  181. /* Equivalent mask of ADC_CHANNEL_NUMBER_MASK aligned on register LSB (bit 0) */
  182. #define ADC_CHANNEL_ID_NUMBER_MASK_POSBIT0 0x0000001FU /* Equivalent to shift: (ADC_CHANNEL_NUMBER_MASK >> POSITION_VAL(ADC_CHANNEL_NUMBER_MASK)) */
  183. /* Channel differentiation between external and internal channels */
  184. #define ADC_CHANNEL_ID_INTERNAL_CH 0x80000000U /* Marker of internal channel */
  185. #define ADC_CHANNEL_ID_INTERNAL_CH_MASK (ADC_CHANNEL_ID_INTERNAL_CH)
  186. /* Internal register offset for ADC channel sampling time configuration */
  187. /* (offset placed into a spare area of literal definition) */
  188. #define ADC_SMPR1_REGOFFSET 0x00000000U
  189. #define ADC_SMPR2_REGOFFSET 0x02000000U
  190. #define ADC_SMPR3_REGOFFSET 0x04000000U
  191. #if defined(ADC_SMPR0_SMP31)
  192. #define ADC_SMPR0_REGOFFSET 0x28000000U /* SMPR0 register offset from SMPR1 is 20 registers. On STM32L1, parameter not available on all devices: only on STM32L1 Cat.4 and Cat.5. */
  193. #define ADC_CHANNEL_SMPRX_REGOFFSET_MASK (ADC_SMPR1_REGOFFSET | ADC_SMPR2_REGOFFSET | ADC_SMPR3_REGOFFSET | ADC_SMPR0_REGOFFSET)
  194. #else
  195. #define ADC_CHANNEL_SMPRX_REGOFFSET_MASK (ADC_SMPR1_REGOFFSET | ADC_SMPR2_REGOFFSET | ADC_SMPR3_REGOFFSET)
  196. #endif /* ADC_SMPR0_SMP31 */
  197. #define ADC_CHANNEL_SMPx_BITOFFSET_MASK 0x01F00000U
  198. #define ADC_CHANNEL_SMPx_BITOFFSET_POS (20U) /* Value equivalent to POSITION_VAL(ADC_CHANNEL_SMPx_BITOFFSET_MASK) */
  199. /* Definition of channels ID number information to be inserted into */
  200. /* channels literals definition. */
  201. #define ADC_CHANNEL_0_NUMBER 0x00000000U
  202. #define ADC_CHANNEL_1_NUMBER ( ADC_CR1_AWDCH_0)
  203. #define ADC_CHANNEL_2_NUMBER ( ADC_CR1_AWDCH_1 )
  204. #define ADC_CHANNEL_3_NUMBER ( ADC_CR1_AWDCH_1 | ADC_CR1_AWDCH_0)
  205. #define ADC_CHANNEL_4_NUMBER ( ADC_CR1_AWDCH_2 )
  206. #define ADC_CHANNEL_5_NUMBER ( ADC_CR1_AWDCH_2 | ADC_CR1_AWDCH_0)
  207. #define ADC_CHANNEL_6_NUMBER ( ADC_CR1_AWDCH_2 | ADC_CR1_AWDCH_1 )
  208. #define ADC_CHANNEL_7_NUMBER ( ADC_CR1_AWDCH_2 | ADC_CR1_AWDCH_1 | ADC_CR1_AWDCH_0)
  209. #define ADC_CHANNEL_8_NUMBER ( ADC_CR1_AWDCH_3 )
  210. #define ADC_CHANNEL_9_NUMBER ( ADC_CR1_AWDCH_3 | ADC_CR1_AWDCH_0)
  211. #define ADC_CHANNEL_10_NUMBER ( ADC_CR1_AWDCH_3 | ADC_CR1_AWDCH_1 )
  212. #define ADC_CHANNEL_11_NUMBER ( ADC_CR1_AWDCH_3 | ADC_CR1_AWDCH_1 | ADC_CR1_AWDCH_0)
  213. #define ADC_CHANNEL_12_NUMBER ( ADC_CR1_AWDCH_3 | ADC_CR1_AWDCH_2 )
  214. #define ADC_CHANNEL_13_NUMBER ( ADC_CR1_AWDCH_3 | ADC_CR1_AWDCH_2 | ADC_CR1_AWDCH_0)
  215. #define ADC_CHANNEL_14_NUMBER ( ADC_CR1_AWDCH_3 | ADC_CR1_AWDCH_2 | ADC_CR1_AWDCH_1 )
  216. #define ADC_CHANNEL_15_NUMBER ( ADC_CR1_AWDCH_3 | ADC_CR1_AWDCH_2 | ADC_CR1_AWDCH_1 | ADC_CR1_AWDCH_0)
  217. #define ADC_CHANNEL_16_NUMBER (ADC_CR1_AWDCH_4 )
  218. #define ADC_CHANNEL_17_NUMBER (ADC_CR1_AWDCH_4 | ADC_CR1_AWDCH_0)
  219. #define ADC_CHANNEL_18_NUMBER (ADC_CR1_AWDCH_4 | ADC_CR1_AWDCH_1 )
  220. #define ADC_CHANNEL_19_NUMBER (ADC_CR1_AWDCH_4 | ADC_CR1_AWDCH_1 | ADC_CR1_AWDCH_0)
  221. #define ADC_CHANNEL_20_NUMBER (ADC_CR1_AWDCH_4 | ADC_CR1_AWDCH_2 )
  222. #define ADC_CHANNEL_21_NUMBER (ADC_CR1_AWDCH_4 | ADC_CR1_AWDCH_2 | ADC_CR1_AWDCH_0)
  223. #define ADC_CHANNEL_22_NUMBER (ADC_CR1_AWDCH_4 | ADC_CR1_AWDCH_2 | ADC_CR1_AWDCH_1 )
  224. #define ADC_CHANNEL_23_NUMBER (ADC_CR1_AWDCH_4 | ADC_CR1_AWDCH_2 | ADC_CR1_AWDCH_1 | ADC_CR1_AWDCH_0)
  225. #define ADC_CHANNEL_24_NUMBER (ADC_CR1_AWDCH_4 | ADC_CR1_AWDCH_3 )
  226. #define ADC_CHANNEL_25_NUMBER (ADC_CR1_AWDCH_4 | ADC_CR1_AWDCH_3 | ADC_CR1_AWDCH_0)
  227. #define ADC_CHANNEL_26_NUMBER (ADC_CR1_AWDCH_4 | ADC_CR1_AWDCH_3 | ADC_CR1_AWDCH_1 )
  228. #if defined(ADC_SMPR0_SMP31)
  229. #define ADC_CHANNEL_27_NUMBER (ADC_CR1_AWDCH_4 | ADC_CR1_AWDCH_3 | ADC_CR1_AWDCH_1 | ADC_CR1_AWDCH_0)
  230. #define ADC_CHANNEL_28_NUMBER (ADC_CR1_AWDCH_4 | ADC_CR1_AWDCH_3 | ADC_CR1_AWDCH_2 )
  231. #define ADC_CHANNEL_29_NUMBER (ADC_CR1_AWDCH_4 | ADC_CR1_AWDCH_3 | ADC_CR1_AWDCH_2 | ADC_CR1_AWDCH_0)
  232. #define ADC_CHANNEL_30_NUMBER (ADC_CR1_AWDCH_4 | ADC_CR1_AWDCH_3 | ADC_CR1_AWDCH_2 | ADC_CR1_AWDCH_1 )
  233. #define ADC_CHANNEL_31_NUMBER (ADC_CR1_AWDCH_4 | ADC_CR1_AWDCH_3 | ADC_CR1_AWDCH_2 | ADC_CR1_AWDCH_1 | ADC_CR1_AWDCH_0)
  234. #endif /* ADC_SMPR0_SMP31 */
  235. /* Definition of channels sampling time information to be inserted into */
  236. /* channels literals definition. */
  237. #define ADC_CHANNEL_0_SMP (ADC_SMPR3_REGOFFSET | (( 0U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR3_SMP0) */
  238. #define ADC_CHANNEL_1_SMP (ADC_SMPR3_REGOFFSET | (( 3U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR3_SMP1) */
  239. #define ADC_CHANNEL_2_SMP (ADC_SMPR3_REGOFFSET | (( 6U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR3_SMP2) */
  240. #define ADC_CHANNEL_3_SMP (ADC_SMPR3_REGOFFSET | (( 9U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR3_SMP3) */
  241. #define ADC_CHANNEL_4_SMP (ADC_SMPR3_REGOFFSET | ((12U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR3_SMP4) */
  242. #define ADC_CHANNEL_5_SMP (ADC_SMPR3_REGOFFSET | ((15U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR3_SMP5) */
  243. #define ADC_CHANNEL_6_SMP (ADC_SMPR3_REGOFFSET | ((18U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR3_SMP6) */
  244. #define ADC_CHANNEL_7_SMP (ADC_SMPR3_REGOFFSET | ((21U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR3_SMP7) */
  245. #define ADC_CHANNEL_8_SMP (ADC_SMPR3_REGOFFSET | ((24U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR3_SMP8) */
  246. #define ADC_CHANNEL_9_SMP (ADC_SMPR3_REGOFFSET | ((27U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR3_SMP9) */
  247. #define ADC_CHANNEL_10_SMP (ADC_SMPR2_REGOFFSET | (( 0U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR2_SMP10) */
  248. #define ADC_CHANNEL_11_SMP (ADC_SMPR2_REGOFFSET | (( 3U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR2_SMP11) */
  249. #define ADC_CHANNEL_12_SMP (ADC_SMPR2_REGOFFSET | (( 6U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR2_SMP12) */
  250. #define ADC_CHANNEL_13_SMP (ADC_SMPR2_REGOFFSET | (( 9U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR2_SMP13) */
  251. #define ADC_CHANNEL_14_SMP (ADC_SMPR2_REGOFFSET | ((12U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR2_SMP14) */
  252. #define ADC_CHANNEL_15_SMP (ADC_SMPR2_REGOFFSET | ((15U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR2_SMP15) */
  253. #define ADC_CHANNEL_16_SMP (ADC_SMPR2_REGOFFSET | ((18U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR2_SMP16) */
  254. #define ADC_CHANNEL_17_SMP (ADC_SMPR2_REGOFFSET | ((21U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR2_SMP17) */
  255. #define ADC_CHANNEL_18_SMP (ADC_SMPR2_REGOFFSET | ((24U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR2_SMP18) */
  256. #define ADC_CHANNEL_19_SMP (ADC_SMPR2_REGOFFSET | ((27U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR2_SMP19) */
  257. #define ADC_CHANNEL_20_SMP (ADC_SMPR1_REGOFFSET | (( 0U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR1_SMP20) */
  258. #define ADC_CHANNEL_21_SMP (ADC_SMPR1_REGOFFSET | (( 3U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR1_SMP21) */
  259. #define ADC_CHANNEL_22_SMP (ADC_SMPR1_REGOFFSET | (( 6U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR1_SMP22) */
  260. #define ADC_CHANNEL_23_SMP (ADC_SMPR1_REGOFFSET | (( 9U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR1_SMP23) */
  261. #define ADC_CHANNEL_24_SMP (ADC_SMPR1_REGOFFSET | ((12U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR1_SMP24) */
  262. #define ADC_CHANNEL_25_SMP (ADC_SMPR1_REGOFFSET | ((15U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR1_SMP25) */
  263. #define ADC_CHANNEL_26_SMP (ADC_SMPR1_REGOFFSET | ((18U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR1_SMP26) */
  264. #if defined(ADC_SMPR0_SMP31)
  265. #define ADC_CHANNEL_27_SMP (ADC_SMPR1_REGOFFSET | ((21U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR1_SMP27) */
  266. #define ADC_CHANNEL_28_SMP (ADC_SMPR1_REGOFFSET | ((24U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR1_SMP28) */
  267. #define ADC_CHANNEL_29_SMP (ADC_SMPR1_REGOFFSET | ((27U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR1_SMP19) */
  268. #define ADC_CHANNEL_30_SMP (ADC_SMPR0_REGOFFSET | (( 0U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR0_SMP30) */
  269. #define ADC_CHANNEL_31_SMP (ADC_SMPR0_REGOFFSET | (( 3U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR0_SMP31) */
  270. #endif /* ADC_SMPR0_SMP31 */
  271. /* Internal mask for ADC analog watchdog: */
  272. /* To select into literals LL_ADC_AWD_CHANNELx_xxx the relevant bits for: */
  273. /* (concatenation of multiple bits used in different analog watchdogs, */
  274. /* (feature of several watchdogs not available on all STM32 families)). */
  275. /* - analog watchdog 1: monitored channel defined by number, */
  276. /* selection of ADC group (ADC groups regular and-or injected). */
  277. /* Internal register offset for ADC analog watchdog channel configuration */
  278. #define ADC_AWD_CR1_REGOFFSET 0x00000000U
  279. #define ADC_AWD_CRX_REGOFFSET_MASK (ADC_AWD_CR1_REGOFFSET)
  280. #define ADC_AWD_CR1_CHANNEL_MASK (ADC_CR1_AWDCH | ADC_CR1_JAWDEN | ADC_CR1_AWDEN | ADC_CR1_AWDSGL)
  281. #define ADC_AWD_CR_ALL_CHANNEL_MASK (ADC_AWD_CR1_CHANNEL_MASK)
  282. /* Internal register offset for ADC analog watchdog threshold configuration */
  283. #define ADC_AWD_TR1_HIGH_REGOFFSET 0x00000000U
  284. #define ADC_AWD_TR1_LOW_REGOFFSET 0x00000001U
  285. #define ADC_AWD_TRX_REGOFFSET_MASK (ADC_AWD_TR1_HIGH_REGOFFSET | ADC_AWD_TR1_LOW_REGOFFSET)
  286. /* ADC registers bits positions */
  287. #define ADC_CR1_RES_BITOFFSET_POS (24U) /* Value equivalent to POSITION_VAL(ADC_CR1_RES) */
  288. #define ADC_TR_HT_BITOFFSET_POS (16U) /* Value equivalent to POSITION_VAL(ADC_TR_HT) */
  289. /* ADC internal channels related definitions */
  290. /* Internal voltage reference VrefInt */
  291. #define VREFINT_CAL_ADDR ((uint16_t*) (0x1FF800F8U)) /* Internal voltage reference, address of parameter VREFINT_CAL: VrefInt ADC raw data acquired at temperature 30 DegC (tolerance: +-5 DegC), Vref+ = 3.0 V (tolerance: +-10 mV). */
  292. #define VREFINT_CAL_VREF ( 3000U) /* Analog voltage reference (Vref+) value with which temperature sensor has been calibrated in production (tolerance: +-10 mV) (unit: mV). */
  293. /* Temperature sensor */
  294. #define TEMPSENSOR_CAL1_ADDR ((uint16_t*) (0x1FF800FAU)) /* Internal temperature sensor, address of parameter TS_CAL1: On STM32L1, temperature sensor ADC raw data acquired at temperature 30 DegC (tolerance: +-5 DegC), Vref+ = 3.0 V (tolerance: +-10 mV). */
  295. #define TEMPSENSOR_CAL2_ADDR ((uint16_t*) (0x1FF800FEU)) /* Internal temperature sensor, address of parameter TS_CAL2: On STM32L1, temperature sensor ADC raw data acquired at temperature 110 DegC (tolerance: +-5 DegC), Vref+ = 3.0 V (tolerance: +-10 mV). */
  296. #define TEMPSENSOR_CAL1_TEMP (( int32_t) 30) /* Internal temperature sensor, temperature at which temperature sensor has been calibrated in production for data into TEMPSENSOR_CAL1_ADDR (tolerance: +-5 DegC) (unit: DegC). */
  297. #define TEMPSENSOR_CAL2_TEMP (( int32_t) 110) /* Internal temperature sensor, temperature at which temperature sensor has been calibrated in production for data into TEMPSENSOR_CAL2_ADDR (tolerance: +-5 DegC) (unit: DegC). */
  298. #define TEMPSENSOR_CAL_VREFANALOG ( 3000U) /* Analog voltage reference (Vref+) voltage with which temperature sensor has been calibrated in production (+-10 mV) (unit: mV). */
  299. /**
  300. * @}
  301. */
  302. /* Private macros ------------------------------------------------------------*/
  303. /** @defgroup ADC_LL_Private_Macros ADC Private Macros
  304. * @{
  305. */
  306. /**
  307. * @brief Driver macro reserved for internal use: isolate bits with the
  308. * selected mask and shift them to the register LSB
  309. * (shift mask on register position bit 0).
  310. * @param __BITS__ Bits in register 32 bits
  311. * @param __MASK__ Mask in register 32 bits
  312. * @retval Bits in register 32 bits
  313. */
  314. #define __ADC_MASK_SHIFT(__BITS__, __MASK__) \
  315. (((__BITS__) & (__MASK__)) >> POSITION_VAL((__MASK__)))
  316. /**
  317. * @brief Driver macro reserved for internal use: set a pointer to
  318. * a register from a register basis from which an offset
  319. * is applied.
  320. * @param __REG__ Register basis from which the offset is applied.
  321. * @param __REG_OFFFSET__ Offset to be applied (unit: number of registers).
  322. * @retval Pointer to register address
  323. */
  324. #define __ADC_PTR_REG_OFFSET(__REG__, __REG_OFFFSET__) \
  325. ((uint32_t *)((uint32_t) ((uint32_t)(&(__REG__)) + ((__REG_OFFFSET__) << 2U))))
  326. /**
  327. * @}
  328. */
  329. /* Exported types ------------------------------------------------------------*/
  330. #if defined(USE_FULL_LL_DRIVER)
  331. /** @defgroup ADC_LL_ES_INIT ADC Exported Init structure
  332. * @{
  333. */
  334. /**
  335. * @brief Structure definition of some features of ADC common parameters
  336. * and multimode
  337. * (all ADC instances belonging to the same ADC common instance).
  338. * @note The setting of these parameters by function @ref LL_ADC_CommonInit()
  339. * is conditioned to ADC instances state (all ADC instances
  340. * sharing the same ADC common instance):
  341. * All ADC instances sharing the same ADC common instance must be
  342. * disabled.
  343. */
  344. typedef struct
  345. {
  346. uint32_t CommonClock; /*!< Set parameter common to several ADC: Clock source and prescaler.
  347. This parameter can be a value of @ref ADC_LL_EC_COMMON_CLOCK_SOURCE
  348. @note On this STM32 serie, HSI RC oscillator is the only clock source for ADC.
  349. Therefore, HSI RC oscillator must be preliminarily enabled at RCC top level.
  350. @note On this STM32 serie, some clock ratio constraints between ADC clock and APB clock
  351. must be respected:
  352. - In all cases: if APB clock frequency is too low compared ADC clock frequency, a delay between conversions must be inserted.
  353. - If ADC group injected is used: ADC clock frequency should be lower than APB clock frequency /4 for resolution 12 or 10 bits, APB clock frequency /3 for resolution 8 bits, APB clock frequency /2 for resolution 6 bits.
  354. Refer to reference manual.
  355. This feature can be modified afterwards using unitary function @ref LL_ADC_SetCommonClock(). */
  356. } LL_ADC_CommonInitTypeDef;
  357. /**
  358. * @brief Structure definition of some features of ADC instance.
  359. * @note These parameters have an impact on ADC scope: ADC instance.
  360. * Affects both group regular and group injected (availability
  361. * of ADC group injected depends on STM32 families).
  362. * Refer to corresponding unitary functions into
  363. * @ref ADC_LL_EF_Configuration_ADC_Instance .
  364. * @note The setting of these parameters by function @ref LL_ADC_Init()
  365. * is conditioned to ADC state:
  366. * ADC instance must be disabled.
  367. * This condition is applied to all ADC features, for efficiency
  368. * and compatibility over all STM32 families. However, the different
  369. * features can be set under different ADC state conditions
  370. * (setting possible with ADC enabled without conversion on going,
  371. * ADC enabled with conversion on going, ...)
  372. * Each feature can be updated afterwards with a unitary function
  373. * and potentially with ADC in a different state than disabled,
  374. * refer to description of each function for setting
  375. * conditioned to ADC state.
  376. */
  377. typedef struct
  378. {
  379. uint32_t Resolution; /*!< Set ADC resolution.
  380. This parameter can be a value of @ref ADC_LL_EC_RESOLUTION
  381. This feature can be modified afterwards using unitary function @ref LL_ADC_SetResolution(). */
  382. uint32_t DataAlignment; /*!< Set ADC conversion data alignment.
  383. This parameter can be a value of @ref ADC_LL_EC_DATA_ALIGN
  384. This feature can be modified afterwards using unitary function @ref LL_ADC_SetDataAlignment(). */
  385. uint32_t LowPowerMode; /*!< Set ADC low power mode.
  386. This parameter can be a concatenation of a value of @ref ADC_LL_EC_LP_MODE_AUTOWAIT and a value of @ref ADC_LL_EC_LP_MODE_AUTOPOWEROFF
  387. This feature can be modified afterwards using unitary function @ref LL_ADC_SetLowPowerModeAutoWait() and @ref LL_ADC_SetLowPowerModeAutoPowerOff(). */
  388. uint32_t SequencersScanMode; /*!< Set ADC scan selection.
  389. This parameter can be a value of @ref ADC_LL_EC_SCAN_SELECTION
  390. This feature can be modified afterwards using unitary function @ref LL_ADC_SetSequencersScanMode(). */
  391. } LL_ADC_InitTypeDef;
  392. /**
  393. * @brief Structure definition of some features of ADC group regular.
  394. * @note These parameters have an impact on ADC scope: ADC group regular.
  395. * Refer to corresponding unitary functions into
  396. * @ref ADC_LL_EF_Configuration_ADC_Group_Regular
  397. * (functions with prefix "REG").
  398. * @note The setting of these parameters by function @ref LL_ADC_REG_Init()
  399. * is conditioned to ADC state:
  400. * ADC instance must be disabled.
  401. * This condition is applied to all ADC features, for efficiency
  402. * and compatibility over all STM32 families. However, the different
  403. * features can be set under different ADC state conditions
  404. * (setting possible with ADC enabled without conversion on going,
  405. * ADC enabled with conversion on going, ...)
  406. * Each feature can be updated afterwards with a unitary function
  407. * and potentially with ADC in a different state than disabled,
  408. * refer to description of each function for setting
  409. * conditioned to ADC state.
  410. */
  411. typedef struct
  412. {
  413. uint32_t TriggerSource; /*!< Set ADC group regular conversion trigger source: internal (SW start) or from external IP (timer event, external interrupt line).
  414. This parameter can be a value of @ref ADC_LL_EC_REG_TRIGGER_SOURCE
  415. @note On this STM32 serie, setting of external trigger edge is performed
  416. using function @ref LL_ADC_REG_StartConversionExtTrig().
  417. This feature can be modified afterwards using unitary function @ref LL_ADC_REG_SetTriggerSource(). */
  418. uint32_t SequencerLength; /*!< Set ADC group regular sequencer length.
  419. This parameter can be a value of @ref ADC_LL_EC_REG_SEQ_SCAN_LENGTH
  420. @note This parameter is discarded if scan mode is disabled (refer to parameter 'ADC_SequencersScanMode').
  421. This feature can be modified afterwards using unitary function @ref LL_ADC_REG_SetSequencerLength(). */
  422. uint32_t SequencerDiscont; /*!< Set ADC group regular sequencer discontinuous mode: sequence subdivided and scan conversions interrupted every selected number of ranks.
  423. This parameter can be a value of @ref ADC_LL_EC_REG_SEQ_DISCONT_MODE
  424. @note This parameter has an effect only if group regular sequencer is enabled
  425. (scan length of 2 ranks or more).
  426. This feature can be modified afterwards using unitary function @ref LL_ADC_REG_SetSequencerDiscont(). */
  427. 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).
  428. This parameter can be a value of @ref ADC_LL_EC_REG_CONTINUOUS_MODE
  429. Note: It is not possible to enable both ADC group regular continuous mode and discontinuous mode.
  430. This feature can be modified afterwards using unitary function @ref LL_ADC_REG_SetContinuousMode(). */
  431. uint32_t DMATransfer; /*!< Set ADC group regular conversion data transfer: no transfer or transfer by DMA, and DMA requests mode.
  432. This parameter can be a value of @ref ADC_LL_EC_REG_DMA_TRANSFER
  433. This feature can be modified afterwards using unitary function @ref LL_ADC_REG_SetDMATransfer(). */
  434. } LL_ADC_REG_InitTypeDef;
  435. /**
  436. * @brief Structure definition of some features of ADC group injected.
  437. * @note These parameters have an impact on ADC scope: ADC group injected.
  438. * Refer to corresponding unitary functions into
  439. * @ref ADC_LL_EF_Configuration_ADC_Group_Regular
  440. * (functions with prefix "INJ").
  441. * @note The setting of these parameters by function @ref LL_ADC_INJ_Init()
  442. * is conditioned to ADC state:
  443. * ADC instance must be disabled.
  444. * This condition is applied to all ADC features, for efficiency
  445. * and compatibility over all STM32 families. However, the different
  446. * features can be set under different ADC state conditions
  447. * (setting possible with ADC enabled without conversion on going,
  448. * ADC enabled with conversion on going, ...)
  449. * Each feature can be updated afterwards with a unitary function
  450. * and potentially with ADC in a different state than disabled,
  451. * refer to description of each function for setting
  452. * conditioned to ADC state.
  453. */
  454. typedef struct
  455. {
  456. uint32_t TriggerSource; /*!< Set ADC group injected conversion trigger source: internal (SW start) or from external IP (timer event, external interrupt line).
  457. This parameter can be a value of @ref ADC_LL_EC_INJ_TRIGGER_SOURCE
  458. @note On this STM32 serie, setting of external trigger edge is performed
  459. using function @ref LL_ADC_INJ_StartConversionExtTrig().
  460. This feature can be modified afterwards using unitary function @ref LL_ADC_INJ_SetTriggerSource(). */
  461. uint32_t SequencerLength; /*!< Set ADC group injected sequencer length.
  462. This parameter can be a value of @ref ADC_LL_EC_INJ_SEQ_SCAN_LENGTH
  463. @note This parameter is discarded if scan mode is disabled (refer to parameter 'ADC_SequencersScanMode').
  464. This feature can be modified afterwards using unitary function @ref LL_ADC_INJ_SetSequencerLength(). */
  465. uint32_t SequencerDiscont; /*!< Set ADC group injected sequencer discontinuous mode: sequence subdivided and scan conversions interrupted every selected number of ranks.
  466. This parameter can be a value of @ref ADC_LL_EC_INJ_SEQ_DISCONT_MODE
  467. @note This parameter has an effect only if group injected sequencer is enabled
  468. (scan length of 2 ranks or more).
  469. This feature can be modified afterwards using unitary function @ref LL_ADC_INJ_SetSequencerDiscont(). */
  470. uint32_t TrigAuto; /*!< Set ADC group injected conversion trigger: independent or from ADC group regular.
  471. This parameter can be a value of @ref ADC_LL_EC_INJ_TRIG_AUTO
  472. Note: This parameter must be set to set to independent trigger if injected trigger source is set to an external trigger.
  473. This feature can be modified afterwards using unitary function @ref LL_ADC_INJ_SetTrigAuto(). */
  474. } LL_ADC_INJ_InitTypeDef;
  475. /**
  476. * @}
  477. */
  478. #endif /* USE_FULL_LL_DRIVER */
  479. /* Exported constants --------------------------------------------------------*/
  480. /** @defgroup ADC_LL_Exported_Constants ADC Exported Constants
  481. * @{
  482. */
  483. /** @defgroup ADC_LL_EC_FLAG ADC flags
  484. * @brief Flags defines which can be used with LL_ADC_ReadReg function
  485. * @{
  486. */
  487. #define LL_ADC_FLAG_ADRDY ADC_SR_ADONS /*!< ADC flag ADC instance ready */
  488. #define LL_ADC_FLAG_STRT ADC_SR_STRT /*!< ADC flag ADC group regular conversion start */
  489. #define LL_ADC_FLAG_EOCS ADC_SR_EOC /*!< ADC flag ADC group regular end of unitary conversion or sequence conversions (to configure flag of end of conversion, use function @ref LL_ADC_REG_SetFlagEndOfConversion() ) */
  490. #define LL_ADC_FLAG_OVR ADC_SR_OVR /*!< ADC flag ADC group regular overrun */
  491. #define LL_ADC_FLAG_JSTRT ADC_SR_JSTRT /*!< ADC flag ADC group injected conversion start */
  492. #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) */
  493. #define LL_ADC_FLAG_AWD1 ADC_SR_AWD /*!< ADC flag ADC analog watchdog 1 */
  494. /**
  495. * @}
  496. */
  497. /** @defgroup ADC_LL_EC_IT ADC interruptions for configuration (interruption enable or disable)
  498. * @brief IT defines which can be used with LL_ADC_ReadReg and LL_ADC_WriteReg functions
  499. * @{
  500. */
  501. #define LL_ADC_IT_EOCS ADC_CR1_EOCIE /*!< ADC interruption ADC group regular end of unitary conversion or sequence conversions (to configure flag of end of conversion, use function @ref LL_ADC_REG_SetFlagEndOfConversion() ) */
  502. #define LL_ADC_IT_OVR ADC_CR1_OVRIE /*!< ADC interruption ADC group regular overrun */
  503. #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) */
  504. #define LL_ADC_IT_AWD1 ADC_CR1_AWDIE /*!< ADC interruption ADC analog watchdog 1 */
  505. /**
  506. * @}
  507. */
  508. /** @defgroup ADC_LL_EC_REGISTERS ADC registers compliant with specific purpose
  509. * @{
  510. */
  511. /* List of ADC registers intended to be used (most commonly) with */
  512. /* DMA transfer. */
  513. /* Refer to function @ref LL_ADC_DMA_GetRegAddr(). */
  514. #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() */
  515. /**
  516. * @}
  517. */
  518. /** @defgroup ADC_LL_EC_COMMON_CLOCK_SOURCE ADC common - Clock source
  519. * @{
  520. */
  521. #define LL_ADC_CLOCK_ASYNC_DIV1 0x00000000U /*!< ADC asynchronous clock without prescaler */
  522. #define LL_ADC_CLOCK_ASYNC_DIV2 (ADC_CCR_ADCPRE_0) /*!< ADC asynchronous clock with prescaler division by 2 */
  523. #define LL_ADC_CLOCK_ASYNC_DIV4 (ADC_CCR_ADCPRE_1) /*!< ADC asynchronous clock with prescaler division by 4 */
  524. /**
  525. * @}
  526. */
  527. /** @defgroup ADC_LL_EC_COMMON_PATH_INTERNAL ADC common - Measurement path to internal channels
  528. * @{
  529. */
  530. /* Note: Other measurement paths to internal channels may be available */
  531. /* (connections to other peripherals). */
  532. /* If they are not listed below, they do not require any specific */
  533. /* path enable. In this case, Access to measurement path is done */
  534. /* only by selecting the corresponding ADC internal channel. */
  535. #define LL_ADC_PATH_INTERNAL_NONE 0x00000000U /*!< ADC measurement pathes all disabled */
  536. #define LL_ADC_PATH_INTERNAL_VREFINT (ADC_CCR_TSVREFE) /*!< ADC measurement path to internal channel VrefInt */
  537. #define LL_ADC_PATH_INTERNAL_TEMPSENSOR (ADC_CCR_TSVREFE) /*!< ADC measurement path to internal channel temperature sensor */
  538. /**
  539. * @}
  540. */
  541. /** @defgroup ADC_LL_EC_RESOLUTION ADC instance - Resolution
  542. * @{
  543. */
  544. #define LL_ADC_RESOLUTION_12B 0x00000000U /*!< ADC resolution 12 bits */
  545. #define LL_ADC_RESOLUTION_10B ( ADC_CR1_RES_0) /*!< ADC resolution 10 bits */
  546. #define LL_ADC_RESOLUTION_8B (ADC_CR1_RES_1 ) /*!< ADC resolution 8 bits */
  547. #define LL_ADC_RESOLUTION_6B (ADC_CR1_RES_1 | ADC_CR1_RES_0) /*!< ADC resolution 6 bits */
  548. /**
  549. * @}
  550. */
  551. /** @defgroup ADC_LL_EC_DATA_ALIGN ADC instance - Data alignment
  552. * @{
  553. */
  554. #define LL_ADC_DATA_ALIGN_RIGHT 0x00000000U /*!< ADC conversion data alignment: right aligned (alignment on data register LSB bit 0)*/
  555. #define LL_ADC_DATA_ALIGN_LEFT (ADC_CR2_ALIGN) /*!< ADC conversion data alignment: left aligned (aligment on data register MSB bit 15)*/
  556. /**
  557. * @}
  558. */
  559. /** @defgroup ADC_LL_EC_LP_MODE_AUTOWAIT ADC instance - Low power mode auto wait (auto delay)
  560. * @{
  561. */
  562. #define LL_ADC_LP_AUTOWAIT_NONE 0x00000000U /*!< ADC low power mode auto wait not activated */
  563. #define LL_ADC_LP_AUTOWAIT ( ADC_CR2_DELS_0) /*!< ADC low power mode auto wait: Dynamic low power mode, ADC conversions are performed only when necessary (when previous ADC conversion data is read). See description with function @ref LL_ADC_SetLowPowerModeAutoWait(). */
  564. #define LL_ADC_LP_AUTOWAIT_7_APBCLOCKCYCLES ( ADC_CR2_DELS_1 ) /*!< ADC low power mode auto wait: Insert a delay between ADC conversions: 7 APB clock cycles */
  565. #define LL_ADC_LP_AUTOWAIT_15_APBCLOCKCYCLES ( ADC_CR2_DELS_1 | ADC_CR2_DELS_0) /*!< ADC low power mode auto wait: Insert a delay between ADC conversions: 15 APB clock cycles */
  566. #define LL_ADC_LP_AUTOWAIT_31_APBCLOCKCYCLES (ADC_CR2_DELS_2 ) /*!< ADC low power mode auto wait: Insert a delay between ADC conversions: 31 APB clock cycles */
  567. #define LL_ADC_LP_AUTOWAIT_63_APBCLOCKCYCLES (ADC_CR2_DELS_2 | ADC_CR2_DELS_0) /*!< ADC low power mode auto wait: Insert a delay between ADC conversions: 63 APB clock cycles */
  568. #define LL_ADC_LP_AUTOWAIT_127_APBCLOCKCYCLES (ADC_CR2_DELS_2 | ADC_CR2_DELS_1 ) /*!< ADC low power mode auto wait: Insert a delay between ADC conversions: 127 APB clock cycles */
  569. #define LL_ADC_LP_AUTOWAIT_255_APBCLOCKCYCLES (ADC_CR2_DELS_2 | ADC_CR2_DELS_1 | ADC_CR2_DELS_0) /*!< ADC low power mode auto wait: Insert a delay between ADC conversions: 255 APB clock cycles */
  570. /**
  571. * @}
  572. */
  573. /** @defgroup ADC_LL_EC_LP_MODE_AUTOPOWEROFF ADC instance - Low power mode auto power-off
  574. * @{
  575. */
  576. #define LL_ADC_LP_AUTOPOWEROFF_NONE 0x00000000U /*!< ADC low power mode auto power-off not activated */
  577. #define LL_ADC_LP_AUTOPOWEROFF_IDLE_PHASE (ADC_CR1_PDI) /*!< ADC low power mode auto power-off: ADC power off when ADC is not converting (idle phase) */
  578. #define LL_ADC_LP_AUTOPOWEROFF_AUTOWAIT_PHASE (ADC_CR1_PDD) /*!< ADC low power mode auto power-off: ADC power off when a delay is inserted between conversions (refer to function @ref LL_ADC_SetLowPowerModeAutoWait() ) */
  579. #define LL_ADC_LP_AUTOPOWEROFF_IDLE_AUTOWAIT_PHASES (ADC_CR1_PDI | ADC_CR1_PDD) /*!< ADC low power mode auto power-off: ADC power off when ADC is not converting (idle phase) and when a delay is inserted between conversions (refer to function @ref LL_ADC_SetLowPowerModeAutoWait() ) */
  580. /**
  581. * @}
  582. */
  583. /** @defgroup ADC_LL_EC_SCAN_SELECTION ADC instance - Scan selection
  584. * @{
  585. */
  586. #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.*/
  587. #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, ...). */
  588. /**
  589. * @}
  590. */
  591. #if defined(ADC_CR2_CFG)
  592. /** @defgroup ADC_LL_EC_CHANNELS_BANK ADC instance - Channels bank
  593. * @{
  594. */
  595. #define LL_ADC_CHANNELS_BANK_A 0x00000000U /*!< ADC channels bank A */
  596. #define LL_ADC_CHANNELS_BANK_B (ADC_CR2_CFG) /*!< ADC channels bank B, available in devices categories 3, 4, 5. */
  597. /**
  598. * @}
  599. */
  600. #endif
  601. /** @defgroup ADC_LL_EC_GROUPS ADC instance - Groups
  602. * @{
  603. */
  604. #define LL_ADC_GROUP_REGULAR 0x00000001U /*!< ADC group regular (available on all STM32 devices) */
  605. #define LL_ADC_GROUP_INJECTED 0x00000002U /*!< ADC group injected (not available on all STM32 devices)*/
  606. #define LL_ADC_GROUP_REGULAR_INJECTED 0x00000003U /*!< ADC both groups regular and injected */
  607. /**
  608. * @}
  609. */
  610. /** @defgroup ADC_LL_EC_CHANNEL ADC instance - Channel number
  611. * @{
  612. */
  613. #define LL_ADC_CHANNEL_0 (ADC_CHANNEL_0_NUMBER | ADC_CHANNEL_0_SMP) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN0 . Channel different in bank A and bank B. */
  614. #define LL_ADC_CHANNEL_1 (ADC_CHANNEL_1_NUMBER | ADC_CHANNEL_1_SMP) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN1 . Channel different in bank A and bank B. */
  615. #define LL_ADC_CHANNEL_2 (ADC_CHANNEL_2_NUMBER | ADC_CHANNEL_2_SMP) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN2 . Channel different in bank A and bank B. */
  616. #define LL_ADC_CHANNEL_3 (ADC_CHANNEL_3_NUMBER | ADC_CHANNEL_3_SMP) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN3 . Channel different in bank A and bank B. */
  617. #define LL_ADC_CHANNEL_4 (ADC_CHANNEL_4_NUMBER | ADC_CHANNEL_4_SMP) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN4 . Direct (fast) channel. */
  618. #define LL_ADC_CHANNEL_5 (ADC_CHANNEL_5_NUMBER | ADC_CHANNEL_5_SMP) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN5 . Direct (fast) channel. */
  619. #define LL_ADC_CHANNEL_6 (ADC_CHANNEL_6_NUMBER | ADC_CHANNEL_6_SMP) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN6 . Channel different in bank A and bank B. */
  620. #define LL_ADC_CHANNEL_7 (ADC_CHANNEL_7_NUMBER | ADC_CHANNEL_7_SMP) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN7 . Channel different in bank A and bank B. */
  621. #define LL_ADC_CHANNEL_8 (ADC_CHANNEL_8_NUMBER | ADC_CHANNEL_8_SMP) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN8 . Channel different in bank A and bank B. */
  622. #define LL_ADC_CHANNEL_9 (ADC_CHANNEL_9_NUMBER | ADC_CHANNEL_9_SMP) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN9 . Channel different in bank A and bank B. */
  623. #define LL_ADC_CHANNEL_10 (ADC_CHANNEL_10_NUMBER | ADC_CHANNEL_10_SMP) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN10. Channel different in bank A and bank B. */
  624. #define LL_ADC_CHANNEL_11 (ADC_CHANNEL_11_NUMBER | ADC_CHANNEL_11_SMP) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN11. Channel different in bank A and bank B. */
  625. #define LL_ADC_CHANNEL_12 (ADC_CHANNEL_12_NUMBER | ADC_CHANNEL_12_SMP) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN12. Channel different in bank A and bank B. */
  626. #define LL_ADC_CHANNEL_13 (ADC_CHANNEL_13_NUMBER | ADC_CHANNEL_13_SMP) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN13. Channel common to both bank A and bank B. */
  627. #define LL_ADC_CHANNEL_14 (ADC_CHANNEL_14_NUMBER | ADC_CHANNEL_14_SMP) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN14. Channel common to both bank A and bank B. */
  628. #define LL_ADC_CHANNEL_15 (ADC_CHANNEL_15_NUMBER | ADC_CHANNEL_15_SMP) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN15. Channel common to both bank A and bank B. */
  629. #define LL_ADC_CHANNEL_16 (ADC_CHANNEL_16_NUMBER | ADC_CHANNEL_16_SMP) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN16. Channel common to both bank A and bank B. */
  630. #define LL_ADC_CHANNEL_17 (ADC_CHANNEL_17_NUMBER | ADC_CHANNEL_17_SMP) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN17. Channel common to both bank A and bank B. */
  631. #define LL_ADC_CHANNEL_18 (ADC_CHANNEL_18_NUMBER | ADC_CHANNEL_18_SMP) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN18. Channel common to both bank A and bank B. */
  632. #define LL_ADC_CHANNEL_19 (ADC_CHANNEL_19_NUMBER | ADC_CHANNEL_19_SMP) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN19. Channel common to both bank A and bank B. */
  633. #define LL_ADC_CHANNEL_20 (ADC_CHANNEL_20_NUMBER | ADC_CHANNEL_20_SMP) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN20. Channel common to both bank A and bank B. */
  634. #define LL_ADC_CHANNEL_21 (ADC_CHANNEL_21_NUMBER | ADC_CHANNEL_21_SMP) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN21. Channel common to both bank A and bank B. */
  635. #define LL_ADC_CHANNEL_22 (ADC_CHANNEL_22_NUMBER | ADC_CHANNEL_22_SMP) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN22. Direct (fast) channel. */
  636. #define LL_ADC_CHANNEL_23 (ADC_CHANNEL_23_NUMBER | ADC_CHANNEL_23_SMP) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN23. Direct (fast) channel. */
  637. #define LL_ADC_CHANNEL_24 (ADC_CHANNEL_24_NUMBER | ADC_CHANNEL_24_SMP) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN24. Direct (fast) channel. */
  638. #define LL_ADC_CHANNEL_25 (ADC_CHANNEL_25_NUMBER | ADC_CHANNEL_25_SMP) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN25. Direct (fast) channel. */
  639. #define LL_ADC_CHANNEL_26 (ADC_CHANNEL_26_NUMBER | ADC_CHANNEL_26_SMP) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN26. Direct (fast) channel. */
  640. #if defined(ADC_SMPR0_SMP31)
  641. #define LL_ADC_CHANNEL_27 (ADC_CHANNEL_27_NUMBER | ADC_CHANNEL_27_SMP) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN27. Channel common to both bank A and bank B. On STM32L1, parameter not available on all devices: only on STM32L1 Cat.4 and Cat.5. */
  642. #define LL_ADC_CHANNEL_28 (ADC_CHANNEL_28_NUMBER | ADC_CHANNEL_28_SMP) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN28. Channel common to both bank A and bank B. On STM32L1, parameter not available on all devices: only on STM32L1 Cat.4 and Cat.5. */
  643. #define LL_ADC_CHANNEL_29 (ADC_CHANNEL_29_NUMBER | ADC_CHANNEL_29_SMP) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN29. Channel common to both bank A and bank B. On STM32L1, parameter not available on all devices: only on STM32L1 Cat.4 and Cat.5. */
  644. #define LL_ADC_CHANNEL_30 (ADC_CHANNEL_30_NUMBER | ADC_CHANNEL_30_SMP) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN30. Channel common to both bank A and bank B. On STM32L1, parameter not available on all devices: only on STM32L1 Cat.4 and Cat.5. */
  645. #define LL_ADC_CHANNEL_31 (ADC_CHANNEL_31_NUMBER | ADC_CHANNEL_31_SMP) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN31. Channel common to both bank A and bank B. On STM32L1, parameter not available on all devices: only on STM32L1 Cat.4 and Cat.5. */
  646. #endif /* ADC_SMPR0_SMP31 */
  647. #define LL_ADC_CHANNEL_VREFINT (LL_ADC_CHANNEL_17 | ADC_CHANNEL_ID_INTERNAL_CH) /*!< ADC internal channel connected to VrefInt: Internal voltage reference. Channel common to both bank A and bank B. */
  648. #define LL_ADC_CHANNEL_TEMPSENSOR (LL_ADC_CHANNEL_16 | ADC_CHANNEL_ID_INTERNAL_CH) /*!< ADC internal channel connected to Temperature sensor. Channel common to both bank A and bank B. */
  649. #define LL_ADC_CHANNEL_VCOMP (LL_ADC_CHANNEL_26 | ADC_CHANNEL_ID_INTERNAL_CH) /*!< ADC internal channel connected to comparator COMP1 positive input via ADC switch matrix. Channel common to both bank A and bank B. */
  650. #if defined(OPAMP_CSR_OPA1PD) || defined (OPAMP_CSR_OPA2PD) || defined (OPAMP_CSR_OPA3PD)
  651. #define LL_ADC_CHANNEL_VOPAMP1 (LL_ADC_CHANNEL_3 | ADC_CHANNEL_ID_INTERNAL_CH) /*!< ADC internal channel connected to OPAMP1 output via ADC switch matrix. Channel common to both bank A and bank B. */
  652. #define LL_ADC_CHANNEL_VOPAMP2 (LL_ADC_CHANNEL_8 | ADC_CHANNEL_ID_INTERNAL_CH) /*!< ADC internal channel connected to OPAMP2 output via ADC switch matrix. Channel common to both bank A and bank B. */
  653. #if defined(OPAMP_CSR_OPA3PD)
  654. #define LL_ADC_CHANNEL_VOPAMP3 (LL_ADC_CHANNEL_13 | ADC_CHANNEL_ID_INTERNAL_CH) /*!< ADC internal channel connected to OPAMP3 output via ADC switch matrix. Channel common to both bank A and bank B. */
  655. #endif /* OPAMP_CSR_OPA3PD */
  656. #endif /* OPAMP_CSR_OPA1PD || OPAMP_CSR_OPA2PD || OPAMP_CSR_OPA3PD */
  657. /**
  658. * @}
  659. */
  660. /** @defgroup ADC_LL_EC_REG_TRIGGER_SOURCE ADC group regular - Trigger source
  661. * @{
  662. */
  663. #define LL_ADC_REG_TRIG_SOFTWARE 0x00000000U /*!< ADC group regular conversion trigger internal: SW start. */
  664. #define LL_ADC_REG_TRIG_EXT_TIM2_TRGO (ADC_CR2_EXTSEL_2 | ADC_CR2_EXTSEL_1 | ADC_REG_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group regular conversion trigger from external IP: TIM2 TRGO. Trigger edge set to rising edge (default setting). */
  665. #define LL_ADC_REG_TRIG_EXT_TIM2_CH3 (ADC_CR2_EXTSEL_1 | ADC_REG_TRIG_EXT_EDGE_DEFAULT) /*!< 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). */
  666. #define LL_ADC_REG_TRIG_EXT_TIM3_TRGO (ADC_CR2_EXTSEL_2 | ADC_REG_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group regular conversion trigger from external IP: TIM3 TRGO. Trigger edge set to rising edge (default setting). */
  667. #define LL_ADC_REG_TRIG_EXT_TIM2_CH2 (ADC_CR2_EXTSEL_1 | ADC_CR2_EXTSEL_0 | ADC_REG_TRIG_EXT_EDGE_DEFAULT) /*!< 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). */
  668. #define LL_ADC_REG_TRIG_EXT_TIM3_CH1 (ADC_CR2_EXTSEL_2 | ADC_CR2_EXTSEL_1 | ADC_CR2_EXTSEL_0 | ADC_REG_TRIG_EXT_EDGE_DEFAULT) /*!< 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). */
  669. #define LL_ADC_REG_TRIG_EXT_TIM3_CH3 (ADC_CR2_EXTSEL_3 | ADC_REG_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group regular conversion trigger from external IP: TIM3 channel 3 event (capture compare: input capture or output capture). Trigger edge set to rising edge (default setting). */
  670. #define LL_ADC_REG_TRIG_EXT_TIM4_TRGO (ADC_CR2_EXTSEL_3 | ADC_CR2_EXTSEL_0 | ADC_REG_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group regular conversion trigger from external IP: TIM4 TRGO. Trigger edge set to rising edge (default setting). */
  671. #define LL_ADC_REG_TRIG_EXT_TIM4_CH4 (ADC_CR2_EXTSEL_2 | ADC_CR2_EXTSEL_0 | ADC_REG_TRIG_EXT_EDGE_DEFAULT) /*!< 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). */
  672. #define LL_ADC_REG_TRIG_EXT_TIM6_TRGO (ADC_CR2_EXTSEL_3 | ADC_CR2_EXTSEL_1 | ADC_REG_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group regular conversion trigger from external IP: TIM6 TRGO. Trigger edge set to rising edge (default setting). */
  673. #define LL_ADC_REG_TRIG_EXT_TIM9_CH2 (ADC_REG_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group regular conversion trigger from external IP: TIM9 channel 2 event (capture compare: input capture or output capture). Trigger edge set to rising edge (default setting). */
  674. #define LL_ADC_REG_TRIG_EXT_TIM9_TRGO (ADC_CR2_EXTSEL_0 | ADC_REG_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group regular conversion trigger from external IP: TIM9 TRGO. Trigger edge set to rising edge (default setting). */
  675. #define LL_ADC_REG_TRIG_EXT_EXTI_LINE11 (ADC_CR2_EXTSEL_3 | ADC_CR2_EXTSEL_2 | ADC_CR2_EXTSEL_1 | ADC_CR2_EXTSEL_0 | ADC_REG_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group regular conversion trigger from external IP: external interrupt line 11. Trigger edge set to rising edge (default setting). */
  676. /**
  677. * @}
  678. */
  679. /** @defgroup ADC_LL_EC_REG_TRIGGER_EDGE ADC group regular - Trigger edge
  680. * @{
  681. */
  682. #define LL_ADC_REG_TRIG_EXT_RISING ( ADC_CR2_EXTEN_0) /*!< ADC group regular conversion trigger polarity set to rising edge */
  683. #define LL_ADC_REG_TRIG_EXT_FALLING (ADC_CR2_EXTEN_1 ) /*!< ADC group regular conversion trigger polarity set to falling edge */
  684. #define LL_ADC_REG_TRIG_EXT_RISINGFALLING (ADC_CR2_EXTEN_1 | ADC_CR2_EXTEN_0) /*!< ADC group regular conversion trigger polarity set to both rising and falling edges */
  685. /**
  686. * @}
  687. */
  688. /** @defgroup ADC_LL_EC_REG_CONTINUOUS_MODE ADC group regular - Continuous mode
  689. * @{
  690. */
  691. #define LL_ADC_REG_CONV_SINGLE 0x00000000U /*!< ADC conversions are performed in single mode: one conversion per trigger */
  692. #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 */
  693. /**
  694. * @}
  695. */
  696. /** @defgroup ADC_LL_EC_REG_DMA_TRANSFER ADC group regular - DMA transfer of ADC conversion data
  697. * @{
  698. */
  699. #define LL_ADC_REG_DMA_TRANSFER_NONE 0x00000000U /*!< ADC conversions are not transferred by DMA */
  700. #define LL_ADC_REG_DMA_TRANSFER_LIMITED ( ADC_CR2_DMA) /*!< ADC conversion data are transferred by DMA, in limited mode (one shot mode): DMA transfer requests are stopped when number of DMA data transfers (number of ADC conversions) is reached. This ADC mode is intended to be used with DMA mode non-circular. */
  701. #define LL_ADC_REG_DMA_TRANSFER_UNLIMITED (ADC_CR2_DDS | 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. */
  702. /**
  703. * @}
  704. */
  705. /** @defgroup ADC_LL_EC_REG_FLAG_EOC_SELECTION ADC group regular - Flag EOC selection (unitary or sequence conversions)
  706. * @{
  707. */
  708. #define LL_ADC_REG_FLAG_EOC_SEQUENCE_CONV 0x00000000U /*!< ADC flag EOC (end of unitary conversion) selected */
  709. #define LL_ADC_REG_FLAG_EOC_UNITARY_CONV (ADC_CR2_EOCS) /*!< ADC flag EOS (end of sequence conversions) selected */
  710. /**
  711. * @}
  712. */
  713. /** @defgroup ADC_LL_EC_REG_SEQ_SCAN_LENGTH ADC group regular - Sequencer scan length
  714. * @{
  715. */
  716. #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) */
  717. #define LL_ADC_REG_SEQ_SCAN_ENABLE_2RANKS ( ADC_SQR1_L_0) /*!< ADC group regular sequencer enable with 2 ranks in the sequence */
  718. #define LL_ADC_REG_SEQ_SCAN_ENABLE_3RANKS ( ADC_SQR1_L_1 ) /*!< ADC group regular sequencer enable with 3 ranks in the sequence */
  719. #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 */
  720. #define LL_ADC_REG_SEQ_SCAN_ENABLE_5RANKS ( ADC_SQR1_L_2 ) /*!< ADC group regular sequencer enable with 5 ranks in the sequence */
  721. #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 */
  722. #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 */
  723. #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 */
  724. #define LL_ADC_REG_SEQ_SCAN_ENABLE_9RANKS (ADC_SQR1_L_3 ) /*!< ADC group regular sequencer enable with 9 ranks in the sequence */
  725. #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 */
  726. #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 */
  727. #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 */
  728. #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 */
  729. #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 */
  730. #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 */
  731. #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 */
  732. /**
  733. * @}
  734. */
  735. /** @defgroup ADC_LL_EC_REG_SEQ_DISCONT_MODE ADC group regular - Sequencer discontinuous mode
  736. * @{
  737. */
  738. #define LL_ADC_REG_SEQ_DISCONT_DISABLE 0x00000000U /*!< ADC group regular sequencer discontinuous mode disable */
  739. #define LL_ADC_REG_SEQ_DISCONT_1RANK ( ADC_CR1_DISCEN) /*!< ADC group regular sequencer discontinuous mode enable with sequence interruption every rank */
  740. #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 */
  741. #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 */
  742. #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 */
  743. #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 */
  744. #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 */
  745. #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 */
  746. #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 */
  747. /**
  748. * @}
  749. */
  750. /** @defgroup ADC_LL_EC_REG_SEQ_RANKS ADC group regular - Sequencer ranks
  751. * @{
  752. */
  753. #define LL_ADC_REG_RANK_1 (ADC_SQR5_REGOFFSET | ADC_REG_RANK_1_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 1 */
  754. #define LL_ADC_REG_RANK_2 (ADC_SQR5_REGOFFSET | ADC_REG_RANK_2_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 2 */
  755. #define LL_ADC_REG_RANK_3 (ADC_SQR5_REGOFFSET | ADC_REG_RANK_3_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 3 */
  756. #define LL_ADC_REG_RANK_4 (ADC_SQR5_REGOFFSET | ADC_REG_RANK_4_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 4 */
  757. #define LL_ADC_REG_RANK_5 (ADC_SQR5_REGOFFSET | ADC_REG_RANK_5_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 5 */
  758. #define LL_ADC_REG_RANK_6 (ADC_SQR5_REGOFFSET | ADC_REG_RANK_6_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 6 */
  759. #define LL_ADC_REG_RANK_7 (ADC_SQR4_REGOFFSET | ADC_REG_RANK_7_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 7 */
  760. #define LL_ADC_REG_RANK_8 (ADC_SQR4_REGOFFSET | ADC_REG_RANK_8_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 8 */
  761. #define LL_ADC_REG_RANK_9 (ADC_SQR4_REGOFFSET | ADC_REG_RANK_9_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 9 */
  762. #define LL_ADC_REG_RANK_10 (ADC_SQR4_REGOFFSET | ADC_REG_RANK_10_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 10 */
  763. #define LL_ADC_REG_RANK_11 (ADC_SQR4_REGOFFSET | ADC_REG_RANK_11_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 11 */
  764. #define LL_ADC_REG_RANK_12 (ADC_SQR4_REGOFFSET | ADC_REG_RANK_12_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 12 */
  765. #define LL_ADC_REG_RANK_13 (ADC_SQR3_REGOFFSET | ADC_REG_RANK_13_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 13 */
  766. #define LL_ADC_REG_RANK_14 (ADC_SQR3_REGOFFSET | ADC_REG_RANK_14_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 14 */
  767. #define LL_ADC_REG_RANK_15 (ADC_SQR3_REGOFFSET | ADC_REG_RANK_15_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 15 */
  768. #define LL_ADC_REG_RANK_16 (ADC_SQR3_REGOFFSET | ADC_REG_RANK_16_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 16 */
  769. #define LL_ADC_REG_RANK_17 (ADC_SQR3_REGOFFSET | ADC_REG_RANK_17_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 17 */
  770. #define LL_ADC_REG_RANK_18 (ADC_SQR3_REGOFFSET | ADC_REG_RANK_18_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 18 */
  771. #define LL_ADC_REG_RANK_19 (ADC_SQR2_REGOFFSET | ADC_REG_RANK_19_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 19 */
  772. #define LL_ADC_REG_RANK_20 (ADC_SQR2_REGOFFSET | ADC_REG_RANK_20_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 20 */
  773. #define LL_ADC_REG_RANK_21 (ADC_SQR2_REGOFFSET | ADC_REG_RANK_21_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 21 */
  774. #define LL_ADC_REG_RANK_22 (ADC_SQR2_REGOFFSET | ADC_REG_RANK_22_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 22 */
  775. #define LL_ADC_REG_RANK_23 (ADC_SQR2_REGOFFSET | ADC_REG_RANK_23_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 23 */
  776. #define LL_ADC_REG_RANK_24 (ADC_SQR2_REGOFFSET | ADC_REG_RANK_24_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 24 */
  777. #define LL_ADC_REG_RANK_25 (ADC_SQR1_REGOFFSET | ADC_REG_RANK_25_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 25 */
  778. #define LL_ADC_REG_RANK_26 (ADC_SQR1_REGOFFSET | ADC_REG_RANK_26_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 26 */
  779. #define LL_ADC_REG_RANK_27 (ADC_SQR1_REGOFFSET | ADC_REG_RANK_27_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 27 */
  780. #if defined(ADC_SQR1_SQ28)
  781. #define LL_ADC_REG_RANK_28 (ADC_SQR1_REGOFFSET | ADC_REG_RANK_28_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 28 */
  782. #endif
  783. /**
  784. * @}
  785. */
  786. /** @defgroup ADC_LL_EC_INJ_TRIGGER_SOURCE ADC group injected - Trigger source
  787. * @{
  788. */
  789. #define LL_ADC_INJ_TRIG_SOFTWARE 0x00000000U /*!< ADC group injected conversion trigger internal: SW start. */
  790. #define LL_ADC_INJ_TRIG_EXT_TIM9_CH1 (ADC_INJ_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group injected conversion trigger from external IP: TIM9 channel 1 event (capture compare: input capture or output capture). Trigger edge set to rising edge (default setting). */
  791. #define LL_ADC_INJ_TRIG_EXT_TIM9_TRGO (ADC_CR2_JEXTSEL_0 | ADC_INJ_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group injected conversion trigger from external IP: TIM9 TRGO. Trigger edge set to rising edge (default setting). */
  792. #define LL_ADC_INJ_TRIG_EXT_TIM2_TRGO (ADC_CR2_JEXTSEL_1 | ADC_INJ_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group injected conversion trigger from external IP: TIM2 TRGO. Trigger edge set to rising edge (default setting). */
  793. #define LL_ADC_INJ_TRIG_EXT_TIM2_CH1 (ADC_CR2_JEXTSEL_1 | ADC_CR2_JEXTSEL_0 | ADC_INJ_TRIG_EXT_EDGE_DEFAULT) /*!< 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). */
  794. #define LL_ADC_INJ_TRIG_EXT_TIM3_CH4 (ADC_CR2_JEXTSEL_2 | ADC_INJ_TRIG_EXT_EDGE_DEFAULT) /*!< 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). */
  795. #define LL_ADC_INJ_TRIG_EXT_TIM4_TRGO (ADC_CR2_JEXTSEL_2 | ADC_CR2_JEXTSEL_0 | ADC_INJ_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group injected conversion trigger from external IP: TIM4 TRGO. Trigger edge set to rising edge (default setting). */
  796. #define LL_ADC_INJ_TRIG_EXT_TIM4_CH1 (ADC_CR2_JEXTSEL_2 | ADC_CR2_JEXTSEL_1 | ADC_INJ_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group injected conversion trigger from external IP: TIM4 channel 1 event (capture compare: input capture or output capture). Trigger edge set to rising edge (default setting). */
  797. #define LL_ADC_INJ_TRIG_EXT_TIM4_CH2 (ADC_CR2_JEXTSEL_2 | ADC_CR2_JEXTSEL_1 | ADC_CR2_JEXTSEL_0 | ADC_INJ_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group injected conversion trigger from external IP: TIM4 channel 2 event (capture compare: input capture or output capture). Trigger edge set to rising edge (default setting). */
  798. #define LL_ADC_INJ_TRIG_EXT_TIM4_CH3 (ADC_CR2_JEXTSEL_3 | ADC_INJ_TRIG_EXT_EDGE_DEFAULT) /*!< 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). */
  799. #define LL_ADC_INJ_TRIG_EXT_TIM10_CH1 (ADC_CR2_JEXTSEL_3 | ADC_CR2_JEXTSEL_0 | ADC_INJ_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group injected conversion trigger from external IP: TIM10 channel 1 event (capture compare: input capture or output capture). Trigger edge set to rising edge (default setting). */
  800. #define LL_ADC_INJ_TRIG_EXT_TIM7_TRGO (ADC_CR2_JEXTSEL_3 | ADC_CR2_JEXTSEL_1 | ADC_INJ_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group injected conversion trigger from external IP: TIM7 TRGO. Trigger edge set to rising edge (default setting). */
  801. #define LL_ADC_INJ_TRIG_EXT_EXTI_LINE15 (ADC_CR2_JEXTSEL_3 | ADC_CR2_JEXTSEL_2 | ADC_CR2_JEXTSEL_1 | ADC_CR2_JEXTSEL_0 | ADC_INJ_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group injected conversion trigger from external IP: external interrupt line 15. Trigger edge set to rising edge (default setting). */
  802. /**
  803. * @}
  804. */
  805. /** @defgroup ADC_LL_EC_INJ_TRIGGER_EDGE ADC group injected - Trigger edge
  806. * @{
  807. */
  808. #define LL_ADC_INJ_TRIG_EXT_RISING ( ADC_CR2_JEXTEN_0) /*!< ADC group injected conversion trigger polarity set to rising edge */
  809. #define LL_ADC_INJ_TRIG_EXT_FALLING (ADC_CR2_JEXTEN_1 ) /*!< ADC group injected conversion trigger polarity set to falling edge */
  810. #define LL_ADC_INJ_TRIG_EXT_RISINGFALLING (ADC_CR2_JEXTEN_1 | ADC_CR2_JEXTEN_0) /*!< ADC group injected conversion trigger polarity set to both rising and falling edges */
  811. /**
  812. * @}
  813. */
  814. /** @defgroup ADC_LL_EC_INJ_TRIG_AUTO ADC group injected - Automatic trigger mode
  815. * @{
  816. */
  817. #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. */
  818. #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. */
  819. /**
  820. * @}
  821. */
  822. /** @defgroup ADC_LL_EC_INJ_SEQ_SCAN_LENGTH ADC group injected - Sequencer scan length
  823. * @{
  824. */
  825. #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) */
  826. #define LL_ADC_INJ_SEQ_SCAN_ENABLE_2RANKS ( ADC_JSQR_JL_0) /*!< ADC group injected sequencer enable with 2 ranks in the sequence */
  827. #define LL_ADC_INJ_SEQ_SCAN_ENABLE_3RANKS (ADC_JSQR_JL_1 ) /*!< ADC group injected sequencer enable with 3 ranks in the sequence */
  828. #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 */
  829. /**
  830. * @}
  831. */
  832. /** @defgroup ADC_LL_EC_INJ_SEQ_DISCONT_MODE ADC group injected - Sequencer discontinuous mode
  833. * @{
  834. */
  835. #define LL_ADC_INJ_SEQ_DISCONT_DISABLE 0x00000000U /*!< ADC group injected sequencer discontinuous mode disable */
  836. #define LL_ADC_INJ_SEQ_DISCONT_1RANK (ADC_CR1_JDISCEN) /*!< ADC group injected sequencer discontinuous mode enable with sequence interruption every rank */
  837. /**
  838. * @}
  839. */
  840. /** @defgroup ADC_LL_EC_INJ_SEQ_RANKS ADC group injected - Sequencer ranks
  841. * @{
  842. */
  843. #define LL_ADC_INJ_RANK_1 (ADC_JDR1_REGOFFSET | ADC_JOFR1_REGOFFSET | ADC_INJ_RANK_1_JSQR_BITOFFSET_POS) /*!< ADC group injected sequencer rank 1 */
  844. #define LL_ADC_INJ_RANK_2 (ADC_JDR2_REGOFFSET | ADC_JOFR2_REGOFFSET | ADC_INJ_RANK_2_JSQR_BITOFFSET_POS) /*!< ADC group injected sequencer rank 2 */
  845. #define LL_ADC_INJ_RANK_3 (ADC_JDR3_REGOFFSET | ADC_JOFR3_REGOFFSET | ADC_INJ_RANK_3_JSQR_BITOFFSET_POS) /*!< ADC group injected sequencer rank 3 */
  846. #define LL_ADC_INJ_RANK_4 (ADC_JDR4_REGOFFSET | ADC_JOFR4_REGOFFSET | ADC_INJ_RANK_4_JSQR_BITOFFSET_POS) /*!< ADC group injected sequencer rank 4 */
  847. /**
  848. * @}
  849. */
  850. /** @defgroup ADC_LL_EC_CHANNEL_SAMPLINGTIME Channel - Sampling time
  851. * @{
  852. */
  853. #define LL_ADC_SAMPLINGTIME_4CYCLES 0x00000000U /*!< Sampling time 4 ADC clock cycles */
  854. #define LL_ADC_SAMPLINGTIME_9CYCLES (ADC_SMPR3_SMP0_0) /*!< Sampling time 9 ADC clock cycles */
  855. #define LL_ADC_SAMPLINGTIME_16CYCLES (ADC_SMPR3_SMP0_1) /*!< Sampling time 16 ADC clock cycles */
  856. #define LL_ADC_SAMPLINGTIME_24CYCLES (ADC_SMPR3_SMP0_1 | ADC_SMPR3_SMP0_0) /*!< Sampling time 24 ADC clock cycles */
  857. #define LL_ADC_SAMPLINGTIME_48CYCLES (ADC_SMPR3_SMP0_2) /*!< Sampling time 48 ADC clock cycles */
  858. #define LL_ADC_SAMPLINGTIME_96CYCLES (ADC_SMPR3_SMP0_2 | ADC_SMPR3_SMP0_0) /*!< Sampling time 96 ADC clock cycles */
  859. #define LL_ADC_SAMPLINGTIME_192CYCLES (ADC_SMPR3_SMP0_2 | ADC_SMPR3_SMP0_1) /*!< Sampling time 192 ADC clock cycles */
  860. #define LL_ADC_SAMPLINGTIME_384CYCLES (ADC_SMPR3_SMP0_2 | ADC_SMPR3_SMP0_1 | ADC_SMPR3_SMP0_0) /*!< Sampling time 384 ADC clock cycles */
  861. /**
  862. * @}
  863. */
  864. #if defined(COMP_CSR_FCH3)
  865. /** @defgroup ADC_LL_EC_CHANNEL_ROUTING_LIST Channel - Routing channels list
  866. * @{
  867. */
  868. #define LL_ADC_CHANNEL_3_ROUTING (COMP_CSR_FCH3) /*!< ADC channel 3 routing. Used as ADC direct channel (fast channel) if OPAMP1 is in power down mode. */
  869. #define LL_ADC_CHANNEL_8_ROUTING (COMP_CSR_FCH8) /*!< ADC channel 8 routing. Used as ADC direct channel (fast channel) if OPAMP2 is in power down mode. */
  870. #define LL_ADC_CHANNEL_13_ROUTING (COMP_CSR_RCH13) /*!< ADC channel 13 routing. Used as ADC re-routed channel if OPAMP3 is in power down mode. Otherwise, channel 13 is connected to OPAMP3 output and routed through switches COMP1_SW1 and VCOMP to ADC switch matrix. (Note: OPAMP3 is available on STM32L1 Cat.4 only). */
  871. /**
  872. * @}
  873. */
  874. /** @defgroup ADC_LL_EC_CHANNEL_ROUTING_SELECTION Channel - Routing selection
  875. * @{
  876. */
  877. #define LL_ADC_CHANNEL_ROUTING_DEFAULT 0x00000000U /*!< ADC channel routing default: slow channel */
  878. #define LL_ADC_CHANNEL_ROUTING_DIRECT 0x00000001U /*!< ADC channel routing direct: fast channel. */
  879. /**
  880. * @}
  881. */
  882. #endif
  883. /** @defgroup ADC_LL_EC_AWD_NUMBER Analog watchdog - Analog watchdog number
  884. * @{
  885. */
  886. #define LL_ADC_AWD1 (ADC_AWD_CR1_CHANNEL_MASK | ADC_AWD_CR1_REGOFFSET) /*!< ADC analog watchdog number 1 */
  887. /**
  888. * @}
  889. */
  890. /** @defgroup ADC_LL_EC_AWD_CHANNELS Analog watchdog - Monitored channels
  891. * @{
  892. */
  893. #define LL_ADC_AWD_DISABLE 0x00000000U /*!< ADC analog watchdog monitoring disabled */
  894. #define LL_ADC_AWD_ALL_CHANNELS_REG ( ADC_CR1_AWDEN ) /*!< ADC analog watchdog monitoring of all channels, converted by group regular only */
  895. #define LL_ADC_AWD_ALL_CHANNELS_INJ ( ADC_CR1_JAWDEN ) /*!< ADC analog watchdog monitoring of all channels, converted by group injected only */
  896. #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 */
  897. #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 */
  898. #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 */
  899. #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 */
  900. #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 */
  901. #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 */
  902. #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 */
  903. #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 */
  904. #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 */
  905. #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 */
  906. #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 */
  907. #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 */
  908. #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 */
  909. #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 */
  910. #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 */
  911. #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 */
  912. #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 */
  913. #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 */
  914. #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 */
  915. #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 */
  916. #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 */
  917. #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 */
  918. #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 */
  919. #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 */
  920. #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 */
  921. #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 */
  922. #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 */
  923. #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 */
  924. #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 */
  925. #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 */
  926. #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 */
  927. #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 */
  928. #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 */
  929. #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 */
  930. #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 */
  931. #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 */
  932. #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 */
  933. #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 */
  934. #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 */
  935. #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 */
  936. #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 */
  937. #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 */
  938. #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 */
  939. #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 */
  940. #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 */
  941. #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 */
  942. #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 */
  943. #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 */
  944. #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 */
  945. #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 */
  946. #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 */
  947. #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 */
  948. #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 */
  949. #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 */
  950. #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 */
  951. #define LL_ADC_AWD_CHANNEL_18_REG ((LL_ADC_CHANNEL_18 & ADC_CHANNEL_ID_MASK) | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN18, converted by group regular only */
  952. #define LL_ADC_AWD_CHANNEL_18_INJ ((LL_ADC_CHANNEL_18 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN18, converted by group injected only */
  953. #define LL_ADC_AWD_CHANNEL_18_REG_INJ ((LL_ADC_CHANNEL_18 & 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_IN18, converted by either group regular or injected */
  954. #define LL_ADC_AWD_CHANNEL_19_REG ((LL_ADC_CHANNEL_19 & ADC_CHANNEL_ID_MASK) | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN19, converted by group regular only */
  955. #define LL_ADC_AWD_CHANNEL_19_INJ ((LL_ADC_CHANNEL_19 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN19, converted by group injected only */
  956. #define LL_ADC_AWD_CHANNEL_19_REG_INJ ((LL_ADC_CHANNEL_19 & 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_IN19, converted by either group regular or injected */
  957. #define LL_ADC_AWD_CHANNEL_20_REG ((LL_ADC_CHANNEL_20 & ADC_CHANNEL_ID_MASK) | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN20, converted by group regular only */
  958. #define LL_ADC_AWD_CHANNEL_20_INJ ((LL_ADC_CHANNEL_20 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN20, converted by group injected only */
  959. #define LL_ADC_AWD_CHANNEL_20_REG_INJ ((LL_ADC_CHANNEL_20 & 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_IN20, converted by either group regular or injected */
  960. #define LL_ADC_AWD_CHANNEL_21_REG ((LL_ADC_CHANNEL_21 & ADC_CHANNEL_ID_MASK) | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN21, converted by group regular only */
  961. #define LL_ADC_AWD_CHANNEL_21_INJ ((LL_ADC_CHANNEL_21 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN21, converted by group injected only */
  962. #define LL_ADC_AWD_CHANNEL_21_REG_INJ ((LL_ADC_CHANNEL_21 & 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_IN21, converted by either group regular or injected */
  963. #define LL_ADC_AWD_CHANNEL_22_REG ((LL_ADC_CHANNEL_22 & ADC_CHANNEL_ID_MASK) | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN22, converted by group regular only */
  964. #define LL_ADC_AWD_CHANNEL_22_INJ ((LL_ADC_CHANNEL_22 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN22, converted by group injected only */
  965. #define LL_ADC_AWD_CHANNEL_22_REG_INJ ((LL_ADC_CHANNEL_22 & 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_IN22, converted by either group regular or injected */
  966. #define LL_ADC_AWD_CHANNEL_23_REG ((LL_ADC_CHANNEL_23 & ADC_CHANNEL_ID_MASK) | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN23, converted by group regular only */
  967. #define LL_ADC_AWD_CHANNEL_23_INJ ((LL_ADC_CHANNEL_23 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN23, converted by group injected only */
  968. #define LL_ADC_AWD_CHANNEL_23_REG_INJ ((LL_ADC_CHANNEL_23 & 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_IN23, converted by either group regular or injected */
  969. #define LL_ADC_AWD_CHANNEL_24_REG ((LL_ADC_CHANNEL_24 & ADC_CHANNEL_ID_MASK) | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN24, converted by group regular only */
  970. #define LL_ADC_AWD_CHANNEL_24_INJ ((LL_ADC_CHANNEL_24 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN24, converted by group injected only */
  971. #define LL_ADC_AWD_CHANNEL_24_REG_INJ ((LL_ADC_CHANNEL_24 & 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_IN24, converted by either group regular or injected */
  972. #define LL_ADC_AWD_CHANNEL_25_REG ((LL_ADC_CHANNEL_25 & ADC_CHANNEL_ID_MASK) | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN25, converted by group regular only */
  973. #define LL_ADC_AWD_CHANNEL_25_INJ ((LL_ADC_CHANNEL_25 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN25, converted by group injected only */
  974. #define LL_ADC_AWD_CHANNEL_25_REG_INJ ((LL_ADC_CHANNEL_25 & 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_IN25, converted by either group regular or injected */
  975. #define LL_ADC_AWD_CHANNEL_26_REG ((LL_ADC_CHANNEL_26 & ADC_CHANNEL_ID_MASK) | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN26, converted by group regular only */
  976. #define LL_ADC_AWD_CHANNEL_26_INJ ((LL_ADC_CHANNEL_26 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN26, converted by group injected only */
  977. #define LL_ADC_AWD_CHANNEL_26_REG_INJ ((LL_ADC_CHANNEL_26 & 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_IN26, converted by either group regular or injected */
  978. #if defined(ADC_SMPR0_SMP31)
  979. #define LL_ADC_AWD_CHANNEL_27_REG ((LL_ADC_CHANNEL_27 & ADC_CHANNEL_ID_MASK) | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN27, converted by group regular only. On STM32L1, parameter not available on all devices: only on STM32L1 Cat.4 and Cat.5. */
  980. #define LL_ADC_AWD_CHANNEL_27_INJ ((LL_ADC_CHANNEL_27 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN27, converted by group injected only. On STM32L1, parameter not available on all devices: only on STM32L1 Cat.4 and Cat.5. */
  981. #define LL_ADC_AWD_CHANNEL_27_REG_INJ ((LL_ADC_CHANNEL_27 & 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_IN27, converted by either group regular or injected. On STM32L1, parameter not available on all devices: only on STM32L1 Cat.4 and Cat.5. */
  982. #define LL_ADC_AWD_CHANNEL_28_REG ((LL_ADC_CHANNEL_28 & ADC_CHANNEL_ID_MASK) | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN28, converted by group regular only. On STM32L1, parameter not available on all devices: only on STM32L1 Cat.4 and Cat.5. */
  983. #define LL_ADC_AWD_CHANNEL_28_INJ ((LL_ADC_CHANNEL_28 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN28, converted by group injected only. On STM32L1, parameter not available on all devices: only on STM32L1 Cat.4 and Cat.5. */
  984. #define LL_ADC_AWD_CHANNEL_28_REG_INJ ((LL_ADC_CHANNEL_28 & 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_IN28, converted by either group regular or injected. On STM32L1, parameter not available on all devices: only on STM32L1 Cat.4 and Cat.5. */
  985. #define LL_ADC_AWD_CHANNEL_29_REG ((LL_ADC_CHANNEL_29 & ADC_CHANNEL_ID_MASK) | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN29, converted by group regular only. On STM32L1, parameter not available on all devices: only on STM32L1 Cat.4 and Cat.5. */
  986. #define LL_ADC_AWD_CHANNEL_29_INJ ((LL_ADC_CHANNEL_29 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN29, converted by group injected only. On STM32L1, parameter not available on all devices: only on STM32L1 Cat.4 and Cat.5. */
  987. #define LL_ADC_AWD_CHANNEL_29_REG_INJ ((LL_ADC_CHANNEL_29 & 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_IN29, converted by either group regular or injected. On STM32L1, parameter not available on all devices: only on STM32L1 Cat.4 and Cat.5. */
  988. #define LL_ADC_AWD_CHANNEL_30_REG ((LL_ADC_CHANNEL_30 & ADC_CHANNEL_ID_MASK) | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN30, converted by group regular only. On STM32L1, parameter not available on all devices: only on STM32L1 Cat.4 and Cat.5. */
  989. #define LL_ADC_AWD_CHANNEL_30_INJ ((LL_ADC_CHANNEL_30 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN30, converted by group injected only. On STM32L1, parameter not available on all devices: only on STM32L1 Cat.4 and Cat.5. */
  990. #define LL_ADC_AWD_CHANNEL_30_REG_INJ ((LL_ADC_CHANNEL_30 & 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_IN30, converted by either group regular or injected. On STM32L1, parameter not available on all devices: only on STM32L1 Cat.4 and Cat.5. */
  991. #define LL_ADC_AWD_CHANNEL_31_REG ((LL_ADC_CHANNEL_31 & ADC_CHANNEL_ID_MASK) | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN31, converted by group regular only. On STM32L1, parameter not available on all devices: only on STM32L1 Cat.4 and Cat.5. */
  992. #define LL_ADC_AWD_CHANNEL_31_INJ ((LL_ADC_CHANNEL_31 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN31, converted by group injected only. On STM32L1, parameter not available on all devices: only on STM32L1 Cat.4 and Cat.5. */
  993. #define LL_ADC_AWD_CHANNEL_31_REG_INJ ((LL_ADC_CHANNEL_31 & 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_IN31, converted by either group regular or injected. On STM32L1, parameter not available on all devices: only on STM32L1 Cat.4 and Cat.5. */
  994. #endif /* ADC_SMPR0_SMP31 */
  995. #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. Channel common to both bank A and bank B. */
  996. #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. Channel common to both bank A and bank B. */
  997. #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. Channel common to both bank A and bank B. */
  998. #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. Channel common to both bank A and bank B. */
  999. #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. Channel common to both bank A and bank B. */
  1000. #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. Channel common to both bank A and bank B. */
  1001. #define LL_ADC_AWD_CH_VCOMP_REG ((LL_ADC_CHANNEL_VCOMP & ADC_CHANNEL_ID_MASK) | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC internal channel connected to comparator COMP1 positive input via ADC switch matrix. Channel common to both bank A and bank B. */
  1002. #define LL_ADC_AWD_CH_VCOMP_INJ ((LL_ADC_CHANNEL_VCOMP & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC internal channel connected to comparator COMP1 positive input via ADC switch matrix. Channel common to both bank A and bank B. */
  1003. #define LL_ADC_AWD_CH_VCOMP_REG_INJ ((LL_ADC_CHANNEL_VCOMP & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC internal channel connected to comparator COMP1 positive input via ADC switch matrix. Channel common to both bank A and bank B. */
  1004. #if defined(OPAMP_CSR_OPA1PD) || defined (OPAMP_CSR_OPA2PD) || defined (OPAMP_CSR_OPA3PD)
  1005. #define LL_ADC_AWD_CH_VOPAMP1_REG ((LL_ADC_CHANNEL_VOPAMP1 & ADC_CHANNEL_ID_MASK) | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC internal channel connected to OPAMP1 output via ADC switch matrix. Channel common to both bank A and bank B. */
  1006. #define LL_ADC_AWD_CH_VOPAMP1_INJ ((LL_ADC_CHANNEL_VOPAMP1 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC internal channel connected to OPAMP1 output via ADC switch matrix. Channel common to both bank A and bank B. */
  1007. #define LL_ADC_AWD_CH_VOPAMP1_REG_INJ ((LL_ADC_CHANNEL_VOPAMP1 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC internal channel connected to OPAMP1 output via ADC switch matrix. Channel common to both bank A and bank B. */
  1008. #define LL_ADC_AWD_CH_VOPAMP2_REG ((LL_ADC_CHANNEL_VOPAMP2 & ADC_CHANNEL_ID_MASK) | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC internal channel connected to OPAMP2 output via ADC switch matrix. Channel common to both bank A and bank B. */
  1009. #define LL_ADC_AWD_CH_VOPAMP2_INJ ((LL_ADC_CHANNEL_VOPAMP2 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC internal channel connected to OPAMP2 output via ADC switch matrix. Channel common to both bank A and bank B. */
  1010. #define LL_ADC_AWD_CH_VOPAMP2_REG_INJ ((LL_ADC_CHANNEL_VOPAMP2 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC internal channel connected to OPAMP2 output via ADC switch matrix. Channel common to both bank A and bank B. */
  1011. #if defined(OPAMP_CSR_OPA3PD)
  1012. #define LL_ADC_AWD_CH_VOPAMP3_REG ((LL_ADC_CHANNEL_VOPAMP3 & ADC_CHANNEL_ID_MASK) | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC internal channel connected to OPAMP3 output via ADC switch matrix. Channel common to both bank A and bank B. */
  1013. #define LL_ADC_AWD_CH_VOPAMP3_INJ ((LL_ADC_CHANNEL_VOPAMP3 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC internal channel connected to OPAMP3 output via ADC switch matrix. Channel common to both bank A and bank B. */
  1014. #define LL_ADC_AWD_CH_VOPAMP3_REG_INJ ((LL_ADC_CHANNEL_VOPAMP3 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC internal channel connected to OPAMP3 output via ADC switch matrix. Channel common to both bank A and bank B. */
  1015. #endif /* OPAMP_CSR_OPA3PD */
  1016. #endif /* OPAMP_CSR_OPA1PD || OPAMP_CSR_OPA2PD || OPAMP_CSR_OPA3PD */
  1017. /**
  1018. * @}
  1019. */
  1020. /** @defgroup ADC_LL_EC_AWD_THRESHOLDS Analog watchdog - Thresholds
  1021. * @{
  1022. */
  1023. #define LL_ADC_AWD_THRESHOLD_HIGH (ADC_AWD_TR1_HIGH_REGOFFSET) /*!< ADC analog watchdog threshold high */
  1024. #define LL_ADC_AWD_THRESHOLD_LOW (ADC_AWD_TR1_LOW_REGOFFSET) /*!< ADC analog watchdog threshold low */
  1025. /**
  1026. * @}
  1027. */
  1028. /** @defgroup ADC_LL_EC_HW_DELAYS Definitions of ADC hardware constraints delays
  1029. * @note Only ADC IP HW delays are defined in ADC LL driver driver,
  1030. * not timeout values.
  1031. * For details on delays values, refer to descriptions in source code
  1032. * above each literal definition.
  1033. * @{
  1034. */
  1035. /* Note: Only ADC IP HW delays are defined in ADC LL driver driver, */
  1036. /* not timeout values. */
  1037. /* Timeout values for ADC operations are dependent to device clock */
  1038. /* configuration (system clock versus ADC clock), */
  1039. /* and therefore must be defined in user application. */
  1040. /* Indications for estimation of ADC timeout delays, for this */
  1041. /* STM32 serie: */
  1042. /* - ADC enable time: maximum delay is 3.5us */
  1043. /* (refer to device datasheet, parameter "tSTAB") */
  1044. /* - ADC conversion time: duration depending on ADC clock and ADC */
  1045. /* configuration. */
  1046. /* (refer to device reference manual, section "Timing") */
  1047. /* Delay for internal voltage reference stabilization time. */
  1048. /* Delay set to maximum value (refer to device datasheet, */
  1049. /* parameter "TADC_BUF"). */
  1050. /* Unit: us */
  1051. #define LL_ADC_DELAY_VREFINT_STAB_US ( 10U) /*!< Delay for internal voltage reference stabilization time */
  1052. /* Delay for temperature sensor stabilization time. */
  1053. /* Literal set to maximum value (refer to device datasheet, */
  1054. /* parameter "tSTART"). */
  1055. /* Unit: us */
  1056. #define LL_ADC_DELAY_TEMPSENSOR_STAB_US ( 10U) /*!< Delay for internal voltage reference stabilization time */
  1057. /**
  1058. * @}
  1059. */
  1060. /**
  1061. * @}
  1062. */
  1063. /* Exported macro ------------------------------------------------------------*/
  1064. /** @defgroup ADC_LL_Exported_Macros ADC Exported Macros
  1065. * @{
  1066. */
  1067. /** @defgroup ADC_LL_EM_WRITE_READ Common write and read registers Macros
  1068. * @{
  1069. */
  1070. /**
  1071. * @brief Write a value in ADC register
  1072. * @param __INSTANCE__ ADC Instance
  1073. * @param __REG__ Register to be written
  1074. * @param __VALUE__ Value to be written in the register
  1075. * @retval None
  1076. */
  1077. #define LL_ADC_WriteReg(__INSTANCE__, __REG__, __VALUE__) WRITE_REG(__INSTANCE__->__REG__, (__VALUE__))
  1078. /**
  1079. * @brief Read a value in ADC register
  1080. * @param __INSTANCE__ ADC Instance
  1081. * @param __REG__ Register to be read
  1082. * @retval Register value
  1083. */
  1084. #define LL_ADC_ReadReg(__INSTANCE__, __REG__) READ_REG(__INSTANCE__->__REG__)
  1085. /**
  1086. * @}
  1087. */
  1088. /** @defgroup ADC_LL_EM_HELPER_MACRO ADC helper macro
  1089. * @{
  1090. */
  1091. /**
  1092. * @brief Helper macro to get ADC channel number in decimal format
  1093. * from literals LL_ADC_CHANNEL_x.
  1094. * @note Example:
  1095. * __LL_ADC_CHANNEL_TO_DECIMAL_NB(LL_ADC_CHANNEL_4)
  1096. * will return decimal number "4".
  1097. * @note The input can be a value from functions where a channel
  1098. * number is returned, either defined with number
  1099. * or with bitfield (only one bit must be set).
  1100. * @param __CHANNEL__ This parameter can be one of the following values:
  1101. * @arg @ref LL_ADC_CHANNEL_0 (2)
  1102. * @arg @ref LL_ADC_CHANNEL_1 (2)
  1103. * @arg @ref LL_ADC_CHANNEL_2 (2)
  1104. * @arg @ref LL_ADC_CHANNEL_3 (2)
  1105. * @arg @ref LL_ADC_CHANNEL_4 (1)
  1106. * @arg @ref LL_ADC_CHANNEL_5 (1)
  1107. * @arg @ref LL_ADC_CHANNEL_6 (2)
  1108. * @arg @ref LL_ADC_CHANNEL_7 (2)
  1109. * @arg @ref LL_ADC_CHANNEL_8 (2)
  1110. * @arg @ref LL_ADC_CHANNEL_9 (2)
  1111. * @arg @ref LL_ADC_CHANNEL_10 (2)
  1112. * @arg @ref LL_ADC_CHANNEL_11 (2)
  1113. * @arg @ref LL_ADC_CHANNEL_12 (2)
  1114. * @arg @ref LL_ADC_CHANNEL_13 (3)
  1115. * @arg @ref LL_ADC_CHANNEL_14 (3)
  1116. * @arg @ref LL_ADC_CHANNEL_15 (3)
  1117. * @arg @ref LL_ADC_CHANNEL_16 (3)
  1118. * @arg @ref LL_ADC_CHANNEL_17 (3)
  1119. * @arg @ref LL_ADC_CHANNEL_18 (3)
  1120. * @arg @ref LL_ADC_CHANNEL_19 (3)
  1121. * @arg @ref LL_ADC_CHANNEL_20 (3)
  1122. * @arg @ref LL_ADC_CHANNEL_21 (3)
  1123. * @arg @ref LL_ADC_CHANNEL_22 (1)
  1124. * @arg @ref LL_ADC_CHANNEL_23 (1)
  1125. * @arg @ref LL_ADC_CHANNEL_24 (1)
  1126. * @arg @ref LL_ADC_CHANNEL_25 (1)
  1127. * @arg @ref LL_ADC_CHANNEL_26 (3)
  1128. * @arg @ref LL_ADC_CHANNEL_27 (3)(4)
  1129. * @arg @ref LL_ADC_CHANNEL_28 (3)(4)
  1130. * @arg @ref LL_ADC_CHANNEL_29 (3)(4)
  1131. * @arg @ref LL_ADC_CHANNEL_30 (3)(4)
  1132. * @arg @ref LL_ADC_CHANNEL_31 (3)(4)
  1133. * @arg @ref LL_ADC_CHANNEL_VREFINT (3)
  1134. * @arg @ref LL_ADC_CHANNEL_TEMPSENSOR (3)
  1135. * @arg @ref LL_ADC_CHANNEL_VCOMP (3)
  1136. * @arg @ref LL_ADC_CHANNEL_VOPAMP1 (3)(5)
  1137. * @arg @ref LL_ADC_CHANNEL_VOPAMP2 (3)(5)
  1138. * @arg @ref LL_ADC_CHANNEL_VOPAMP3 (3)(5)
  1139. *
  1140. * (1) On STM32L1, connection via routing interface (RI) specificity: fast channel (channel routed directly to ADC switch matrix).\n
  1141. * (2) On STM32L1, for devices with feature 'channels banks' available: Channel different in bank A and bank B.\n
  1142. * (3) On STM32L1, for devices with feature 'channels banks' available: Channel common to both bank A and bank B.\n
  1143. * (4) On STM32L1, parameter not available on all devices: only on STM32L1 Cat.4 and Cat.5.\n
  1144. * (5) On STM32L1, parameter not available on all devices: OPAMP1 and OPAMP2 available only on STM32L1 Cat.3, Cat.4 and Cat.5, OPAMP3 available only on STM32L1 Cat.4 and Cat.5
  1145. * @retval Value between Min_Data=0 and Max_Data=18
  1146. */
  1147. #define __LL_ADC_CHANNEL_TO_DECIMAL_NB(__CHANNEL__) \
  1148. (((__CHANNEL__) & ADC_CHANNEL_ID_NUMBER_MASK) >> ADC_CHANNEL_ID_NUMBER_BITOFFSET_POS)
  1149. /**
  1150. * @brief Helper macro to get ADC channel in literal format LL_ADC_CHANNEL_x
  1151. * from number in decimal format.
  1152. * @note Example:
  1153. * __LL_ADC_DECIMAL_NB_TO_CHANNEL(4)
  1154. * will return a data equivalent to "LL_ADC_CHANNEL_4".
  1155. * @param __DECIMAL_NB__: Value between Min_Data=0 and Max_Data=18
  1156. * @retval Returned value can be one of the following values:
  1157. * @arg @ref LL_ADC_CHANNEL_0 (2)
  1158. * @arg @ref LL_ADC_CHANNEL_1 (2)
  1159. * @arg @ref LL_ADC_CHANNEL_2 (2)
  1160. * @arg @ref LL_ADC_CHANNEL_3 (2)
  1161. * @arg @ref LL_ADC_CHANNEL_4 (1)
  1162. * @arg @ref LL_ADC_CHANNEL_5 (1)
  1163. * @arg @ref LL_ADC_CHANNEL_6 (2)
  1164. * @arg @ref LL_ADC_CHANNEL_7 (2)
  1165. * @arg @ref LL_ADC_CHANNEL_8 (2)
  1166. * @arg @ref LL_ADC_CHANNEL_9 (2)
  1167. * @arg @ref LL_ADC_CHANNEL_10 (2)
  1168. * @arg @ref LL_ADC_CHANNEL_11 (2)
  1169. * @arg @ref LL_ADC_CHANNEL_12 (2)
  1170. * @arg @ref LL_ADC_CHANNEL_13 (3)
  1171. * @arg @ref LL_ADC_CHANNEL_14 (3)
  1172. * @arg @ref LL_ADC_CHANNEL_15 (3)
  1173. * @arg @ref LL_ADC_CHANNEL_16 (3)
  1174. * @arg @ref LL_ADC_CHANNEL_17 (3)
  1175. * @arg @ref LL_ADC_CHANNEL_18 (3)
  1176. * @arg @ref LL_ADC_CHANNEL_19 (3)
  1177. * @arg @ref LL_ADC_CHANNEL_20 (3)
  1178. * @arg @ref LL_ADC_CHANNEL_21 (3)
  1179. * @arg @ref LL_ADC_CHANNEL_22 (1)
  1180. * @arg @ref LL_ADC_CHANNEL_23 (1)
  1181. * @arg @ref LL_ADC_CHANNEL_24 (1)
  1182. * @arg @ref LL_ADC_CHANNEL_25 (1)
  1183. * @arg @ref LL_ADC_CHANNEL_26 (3)
  1184. * @arg @ref LL_ADC_CHANNEL_27 (3)(4)
  1185. * @arg @ref LL_ADC_CHANNEL_28 (3)(4)
  1186. * @arg @ref LL_ADC_CHANNEL_29 (3)(4)
  1187. * @arg @ref LL_ADC_CHANNEL_30 (3)(4)
  1188. * @arg @ref LL_ADC_CHANNEL_31 (3)(4)
  1189. * @arg @ref LL_ADC_CHANNEL_VREFINT (3)(6)
  1190. * @arg @ref LL_ADC_CHANNEL_TEMPSENSOR (3)(6)
  1191. * @arg @ref LL_ADC_CHANNEL_VCOMP (3)(6)
  1192. * @arg @ref LL_ADC_CHANNEL_VOPAMP1 (3)(5)
  1193. * @arg @ref LL_ADC_CHANNEL_VOPAMP2 (3)(5)
  1194. * @arg @ref LL_ADC_CHANNEL_VOPAMP3 (3)(5)
  1195. *
  1196. * (1) On STM32L1, connection via routing interface (RI) specificity: fast channel (channel routed directly to ADC switch matrix).\n
  1197. * (2) On STM32L1, for devices with feature 'channels banks' available: Channel different in bank A and bank B.\n
  1198. * (3) On STM32L1, for devices with feature 'channels banks' available: Channel common to both bank A and bank B.\n
  1199. * (4) On STM32L1, parameter not available on all devices: only on STM32L1 Cat.4 and Cat.5.\n
  1200. * (5) On STM32L1, parameter not available on all devices: OPAMP1 and OPAMP2 available only on STM32L1 Cat.3, Cat.4 and Cat.5, OPAMP3 available only on STM32L1 Cat.4 and Cat.5.\n
  1201. * (6) For ADC channel read back from ADC register,
  1202. * comparison with internal channel parameter to be done
  1203. * using helper macro @ref __LL_ADC_CHANNEL_INTERNAL_TO_EXTERNAL().
  1204. */
  1205. #if defined(ADC_SMPR0_SMP31)
  1206. #define __LL_ADC_DECIMAL_NB_TO_CHANNEL(__DECIMAL_NB__) \
  1207. (((__DECIMAL_NB__) <= 9U) \
  1208. ? ( \
  1209. ((__DECIMAL_NB__) << ADC_CHANNEL_ID_NUMBER_BITOFFSET_POS) | \
  1210. (ADC_SMPR3_REGOFFSET | (((uint32_t) (3U * (__DECIMAL_NB__))) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) \
  1211. ) \
  1212. : \
  1213. (((__DECIMAL_NB__) <= 19U) \
  1214. ? ( \
  1215. ((__DECIMAL_NB__) << ADC_CHANNEL_ID_NUMBER_BITOFFSET_POS) | \
  1216. (ADC_SMPR2_REGOFFSET | (((uint32_t) (3U * ((__DECIMAL_NB__) -10U))) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) \
  1217. ) \
  1218. : \
  1219. (((__DECIMAL_NB__) <= 28U) \
  1220. ? ( \
  1221. ((__DECIMAL_NB__) << ADC_CHANNEL_ID_NUMBER_BITOFFSET_POS) | \
  1222. (ADC_SMPR1_REGOFFSET | (((uint32_t) (3U * ((__DECIMAL_NB__) -20U))) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) \
  1223. ) \
  1224. : \
  1225. ( \
  1226. ((__DECIMAL_NB__) << ADC_CHANNEL_ID_NUMBER_BITOFFSET_POS) | \
  1227. (ADC_SMPR0_REGOFFSET | (((uint32_t) (3U * ((__DECIMAL_NB__) - 30U))) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) \
  1228. ) \
  1229. ) \
  1230. ) \
  1231. )
  1232. #else
  1233. #define __LL_ADC_DECIMAL_NB_TO_CHANNEL(__DECIMAL_NB__) \
  1234. (((__DECIMAL_NB__) <= 9U) \
  1235. ? ( \
  1236. ((__DECIMAL_NB__) << ADC_CHANNEL_ID_NUMBER_BITOFFSET_POS) | \
  1237. (ADC_SMPR3_REGOFFSET | (((uint32_t) (3U * (__DECIMAL_NB__))) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) \
  1238. ) \
  1239. : \
  1240. (((__DECIMAL_NB__) <= 19U) \
  1241. ? ( \
  1242. ((__DECIMAL_NB__) << ADC_CHANNEL_ID_NUMBER_BITOFFSET_POS) | \
  1243. (ADC_SMPR2_REGOFFSET | (((uint32_t) (3U * ((__DECIMAL_NB__) -10U))) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) \
  1244. ) \
  1245. : \
  1246. ( \
  1247. ((__DECIMAL_NB__) << ADC_CHANNEL_ID_NUMBER_BITOFFSET_POS) | \
  1248. (ADC_SMPR1_REGOFFSET | (((uint32_t) (3U * ((__DECIMAL_NB__) -20U))) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) \
  1249. ) \
  1250. ) \
  1251. )
  1252. #endif /* ADC_SMPR0_SMP31 */
  1253. /**
  1254. * @brief Helper macro to determine whether the selected channel
  1255. * corresponds to literal definitions of driver.
  1256. * @note The different literal definitions of ADC channels are:
  1257. * - ADC internal channel:
  1258. * LL_ADC_CHANNEL_VREFINT, LL_ADC_CHANNEL_TEMPSENSOR, ...
  1259. * - ADC external channel (channel connected to a GPIO pin):
  1260. * LL_ADC_CHANNEL_1, LL_ADC_CHANNEL_2, ...
  1261. * @note The channel parameter must be a value defined from literal
  1262. * definition of a ADC internal channel (LL_ADC_CHANNEL_VREFINT,
  1263. * LL_ADC_CHANNEL_TEMPSENSOR, ...),
  1264. * ADC external channel (LL_ADC_CHANNEL_1, LL_ADC_CHANNEL_2, ...),
  1265. * must not be a value from functions where a channel number is
  1266. * returned from ADC registers,
  1267. * because internal and external channels share the same channel
  1268. * number in ADC registers. The differentiation is made only with
  1269. * parameters definitions of driver.
  1270. * @param __CHANNEL__ This parameter can be one of the following values:
  1271. * @arg @ref LL_ADC_CHANNEL_0 (2)
  1272. * @arg @ref LL_ADC_CHANNEL_1 (2)
  1273. * @arg @ref LL_ADC_CHANNEL_2 (2)
  1274. * @arg @ref LL_ADC_CHANNEL_3 (2)
  1275. * @arg @ref LL_ADC_CHANNEL_4 (1)
  1276. * @arg @ref LL_ADC_CHANNEL_5 (1)
  1277. * @arg @ref LL_ADC_CHANNEL_6 (2)
  1278. * @arg @ref LL_ADC_CHANNEL_7 (2)
  1279. * @arg @ref LL_ADC_CHANNEL_8 (2)
  1280. * @arg @ref LL_ADC_CHANNEL_9 (2)
  1281. * @arg @ref LL_ADC_CHANNEL_10 (2)
  1282. * @arg @ref LL_ADC_CHANNEL_11 (2)
  1283. * @arg @ref LL_ADC_CHANNEL_12 (2)
  1284. * @arg @ref LL_ADC_CHANNEL_13 (3)
  1285. * @arg @ref LL_ADC_CHANNEL_14 (3)
  1286. * @arg @ref LL_ADC_CHANNEL_15 (3)
  1287. * @arg @ref LL_ADC_CHANNEL_16 (3)
  1288. * @arg @ref LL_ADC_CHANNEL_17 (3)
  1289. * @arg @ref LL_ADC_CHANNEL_18 (3)
  1290. * @arg @ref LL_ADC_CHANNEL_19 (3)
  1291. * @arg @ref LL_ADC_CHANNEL_20 (3)
  1292. * @arg @ref LL_ADC_CHANNEL_21 (3)
  1293. * @arg @ref LL_ADC_CHANNEL_22 (1)
  1294. * @arg @ref LL_ADC_CHANNEL_23 (1)
  1295. * @arg @ref LL_ADC_CHANNEL_24 (1)
  1296. * @arg @ref LL_ADC_CHANNEL_25 (1)
  1297. * @arg @ref LL_ADC_CHANNEL_26 (3)
  1298. * @arg @ref LL_ADC_CHANNEL_27 (3)(4)
  1299. * @arg @ref LL_ADC_CHANNEL_28 (3)(4)
  1300. * @arg @ref LL_ADC_CHANNEL_29 (3)(4)
  1301. * @arg @ref LL_ADC_CHANNEL_30 (3)(4)
  1302. * @arg @ref LL_ADC_CHANNEL_31 (3)(4)
  1303. * @arg @ref LL_ADC_CHANNEL_VREFINT (3)
  1304. * @arg @ref LL_ADC_CHANNEL_TEMPSENSOR (3)
  1305. * @arg @ref LL_ADC_CHANNEL_VCOMP (3)
  1306. * @arg @ref LL_ADC_CHANNEL_VOPAMP1 (3)(5)
  1307. * @arg @ref LL_ADC_CHANNEL_VOPAMP2 (3)(5)
  1308. * @arg @ref LL_ADC_CHANNEL_VOPAMP3 (3)(5)
  1309. *
  1310. * (1) On STM32L1, connection via routing interface (RI) specificity: fast channel (channel routed directly to ADC switch matrix).\n
  1311. * (2) On STM32L1, for devices with feature 'channels banks' available: Channel different in bank A and bank B.\n
  1312. * (3) On STM32L1, for devices with feature 'channels banks' available: Channel common to both bank A and bank B.\n
  1313. * (4) On STM32L1, parameter not available on all devices: only on STM32L1 Cat.4 and Cat.5.\n
  1314. * (5) On STM32L1, parameter not available on all devices: OPAMP1 and OPAMP2 available only on STM32L1 Cat.3, Cat.4 and Cat.5, OPAMP3 available only on STM32L1 Cat.4 and Cat.5
  1315. * @retval Value "0" if the channel corresponds to a parameter definition of a ADC external channel (channel connected to a GPIO pin).
  1316. * Value "1" if the channel corresponds to a parameter definition of a ADC internal channel.
  1317. */
  1318. #define __LL_ADC_IS_CHANNEL_INTERNAL(__CHANNEL__) \
  1319. (((__CHANNEL__) & ADC_CHANNEL_ID_INTERNAL_CH_MASK) != 0U)
  1320. /**
  1321. * @brief Helper macro to convert a channel defined from parameter
  1322. * definition of a ADC internal channel (LL_ADC_CHANNEL_VREFINT,
  1323. * LL_ADC_CHANNEL_TEMPSENSOR, ...),
  1324. * to its equivalent parameter definition of a ADC external channel
  1325. * (LL_ADC_CHANNEL_1, LL_ADC_CHANNEL_2, ...).
  1326. * @note The channel parameter can be, additionally to a value
  1327. * defined from parameter definition of a ADC internal channel
  1328. * (LL_ADC_CHANNEL_VREFINT, LL_ADC_CHANNEL_TEMPSENSOR, ...),
  1329. * a value defined from parameter definition of
  1330. * ADC external channel (LL_ADC_CHANNEL_1, LL_ADC_CHANNEL_2, ...)
  1331. * or a value from functions where a channel number is returned
  1332. * from ADC registers.
  1333. * @param __CHANNEL__ This parameter can be one of the following values:
  1334. * @arg @ref LL_ADC_CHANNEL_0 (2)
  1335. * @arg @ref LL_ADC_CHANNEL_1 (2)
  1336. * @arg @ref LL_ADC_CHANNEL_2 (2)
  1337. * @arg @ref LL_ADC_CHANNEL_3 (2)
  1338. * @arg @ref LL_ADC_CHANNEL_4 (1)
  1339. * @arg @ref LL_ADC_CHANNEL_5 (1)
  1340. * @arg @ref LL_ADC_CHANNEL_6 (2)
  1341. * @arg @ref LL_ADC_CHANNEL_7 (2)
  1342. * @arg @ref LL_ADC_CHANNEL_8 (2)
  1343. * @arg @ref LL_ADC_CHANNEL_9 (2)
  1344. * @arg @ref LL_ADC_CHANNEL_10 (2)
  1345. * @arg @ref LL_ADC_CHANNEL_11 (2)
  1346. * @arg @ref LL_ADC_CHANNEL_12 (2)
  1347. * @arg @ref LL_ADC_CHANNEL_13 (3)
  1348. * @arg @ref LL_ADC_CHANNEL_14 (3)
  1349. * @arg @ref LL_ADC_CHANNEL_15 (3)
  1350. * @arg @ref LL_ADC_CHANNEL_16 (3)
  1351. * @arg @ref LL_ADC_CHANNEL_17 (3)
  1352. * @arg @ref LL_ADC_CHANNEL_18 (3)
  1353. * @arg @ref LL_ADC_CHANNEL_19 (3)
  1354. * @arg @ref LL_ADC_CHANNEL_20 (3)
  1355. * @arg @ref LL_ADC_CHANNEL_21 (3)
  1356. * @arg @ref LL_ADC_CHANNEL_22 (1)
  1357. * @arg @ref LL_ADC_CHANNEL_23 (1)
  1358. * @arg @ref LL_ADC_CHANNEL_24 (1)
  1359. * @arg @ref LL_ADC_CHANNEL_25 (1)
  1360. * @arg @ref LL_ADC_CHANNEL_26 (3)
  1361. * @arg @ref LL_ADC_CHANNEL_27 (3)(4)
  1362. * @arg @ref LL_ADC_CHANNEL_28 (3)(4)
  1363. * @arg @ref LL_ADC_CHANNEL_29 (3)(4)
  1364. * @arg @ref LL_ADC_CHANNEL_30 (3)(4)
  1365. * @arg @ref LL_ADC_CHANNEL_31 (3)(4)
  1366. * @arg @ref LL_ADC_CHANNEL_VREFINT (3)
  1367. * @arg @ref LL_ADC_CHANNEL_TEMPSENSOR (3)
  1368. * @arg @ref LL_ADC_CHANNEL_VCOMP (3)
  1369. * @arg @ref LL_ADC_CHANNEL_VOPAMP1 (3)(5)
  1370. * @arg @ref LL_ADC_CHANNEL_VOPAMP2 (3)(5)
  1371. * @arg @ref LL_ADC_CHANNEL_VOPAMP3 (3)(5)
  1372. *
  1373. * (1) On STM32L1, connection via routing interface (RI) specificity: fast channel (channel routed directly to ADC switch matrix).\n
  1374. * (2) On STM32L1, for devices with feature 'channels banks' available: Channel different in bank A and bank B.\n
  1375. * (3) On STM32L1, for devices with feature 'channels banks' available: Channel common to both bank A and bank B.\n
  1376. * (4) On STM32L1, parameter not available on all devices: only on STM32L1 Cat.4 and Cat.5.\n
  1377. * (5) On STM32L1, parameter not available on all devices: OPAMP1 and OPAMP2 available only on STM32L1 Cat.3, Cat.4 and Cat.5, OPAMP3 available only on STM32L1 Cat.4 and Cat.5
  1378. * @retval Returned value can be one of the following values:
  1379. * @arg @ref LL_ADC_CHANNEL_0
  1380. * @arg @ref LL_ADC_CHANNEL_1
  1381. * @arg @ref LL_ADC_CHANNEL_2
  1382. * @arg @ref LL_ADC_CHANNEL_3
  1383. * @arg @ref LL_ADC_CHANNEL_4
  1384. * @arg @ref LL_ADC_CHANNEL_5
  1385. * @arg @ref LL_ADC_CHANNEL_6
  1386. * @arg @ref LL_ADC_CHANNEL_7
  1387. * @arg @ref LL_ADC_CHANNEL_8
  1388. * @arg @ref LL_ADC_CHANNEL_9
  1389. * @arg @ref LL_ADC_CHANNEL_10
  1390. * @arg @ref LL_ADC_CHANNEL_11
  1391. * @arg @ref LL_ADC_CHANNEL_12
  1392. * @arg @ref LL_ADC_CHANNEL_13
  1393. * @arg @ref LL_ADC_CHANNEL_14
  1394. * @arg @ref LL_ADC_CHANNEL_15
  1395. * @arg @ref LL_ADC_CHANNEL_16
  1396. * @arg @ref LL_ADC_CHANNEL_17
  1397. * @arg @ref LL_ADC_CHANNEL_18
  1398. */
  1399. #define __LL_ADC_CHANNEL_INTERNAL_TO_EXTERNAL(__CHANNEL__) \
  1400. ((__CHANNEL__) & ~ADC_CHANNEL_ID_INTERNAL_CH_MASK)
  1401. /**
  1402. * @brief Helper macro to determine whether the internal channel
  1403. * selected is available on the ADC instance selected.
  1404. * @note The channel parameter must be a value defined from parameter
  1405. * definition of a ADC internal channel (LL_ADC_CHANNEL_VREFINT,
  1406. * LL_ADC_CHANNEL_TEMPSENSOR, ...),
  1407. * must not be a value defined from parameter definition of
  1408. * ADC external channel (LL_ADC_CHANNEL_1, LL_ADC_CHANNEL_2, ...)
  1409. * or a value from functions where a channel number is
  1410. * returned from ADC registers,
  1411. * because internal and external channels share the same channel
  1412. * number in ADC registers. The differentiation is made only with
  1413. * parameters definitions of driver.
  1414. * @param __ADC_INSTANCE__ ADC instance
  1415. * @param __CHANNEL__ This parameter can be one of the following values:
  1416. * @arg @ref LL_ADC_CHANNEL_VREFINT (3)
  1417. * @arg @ref LL_ADC_CHANNEL_TEMPSENSOR (3)
  1418. * @arg @ref LL_ADC_CHANNEL_VCOMP (3)
  1419. * @arg @ref LL_ADC_CHANNEL_VOPAMP1 (3)(5)
  1420. * @arg @ref LL_ADC_CHANNEL_VOPAMP2 (3)(5)
  1421. * @arg @ref LL_ADC_CHANNEL_VOPAMP3 (3)(5)
  1422. *
  1423. * (1) On STM32L1, connection via routing interface (RI) specificity: fast channel (channel routed directly to ADC switch matrix).\n
  1424. * (2) On STM32L1, for devices with feature 'channels banks' available: Channel different in bank A and bank B.\n
  1425. * (3) On STM32L1, for devices with feature 'channels banks' available: Channel common to both bank A and bank B.\n
  1426. * (4) On STM32L1, parameter not available on all devices: only on STM32L1 Cat.4 and Cat.5.\n
  1427. * (5) On STM32L1, parameter not available on all devices: OPAMP1 and OPAMP2 available only on STM32L1 Cat.3, Cat.4 and Cat.5, OPAMP3 available only on STM32L1 Cat.4 and Cat.5
  1428. * @retval Value "0" if the internal channel selected is not available on the ADC instance selected.
  1429. * Value "1" if the internal channel selected is available on the ADC instance selected.
  1430. */
  1431. #if defined (OPAMP_CSR_OPA3PD)
  1432. #define __LL_ADC_IS_CHANNEL_INTERNAL_AVAILABLE(__ADC_INSTANCE__, __CHANNEL__) \
  1433. ( \
  1434. ((__CHANNEL__) == LL_ADC_CHANNEL_VREFINT) || \
  1435. ((__CHANNEL__) == LL_ADC_CHANNEL_TEMPSENSOR) || \
  1436. ((__CHANNEL__) == LL_ADC_CHANNEL_VCOMP) || \
  1437. ((__CHANNEL__) == LL_ADC_CHANNEL_VOPAMP1) || \
  1438. ((__CHANNEL__) == LL_ADC_CHANNEL_VOPAMP2) || \
  1439. ((__CHANNEL__) == LL_ADC_CHANNEL_VOPAMP3) \
  1440. )
  1441. #elif defined(OPAMP_CSR_OPA1PD) || defined (OPAMP_CSR_OPA2PD)
  1442. #define __LL_ADC_IS_CHANNEL_INTERNAL_AVAILABLE(__ADC_INSTANCE__, __CHANNEL__) \
  1443. ( \
  1444. ((__CHANNEL__) == LL_ADC_CHANNEL_VREFINT) || \
  1445. ((__CHANNEL__) == LL_ADC_CHANNEL_TEMPSENSOR) || \
  1446. ((__CHANNEL__) == LL_ADC_CHANNEL_VCOMP) || \
  1447. ((__CHANNEL__) == LL_ADC_CHANNEL_VOPAMP1) || \
  1448. ((__CHANNEL__) == LL_ADC_CHANNEL_VOPAMP2) \
  1449. )
  1450. #else
  1451. #define __LL_ADC_IS_CHANNEL_INTERNAL_AVAILABLE(__ADC_INSTANCE__, __CHANNEL__) \
  1452. ( \
  1453. ((__CHANNEL__) == LL_ADC_CHANNEL_VREFINT) || \
  1454. ((__CHANNEL__) == LL_ADC_CHANNEL_TEMPSENSOR) || \
  1455. ((__CHANNEL__) == LL_ADC_CHANNEL_VCOMP) \
  1456. )
  1457. #endif
  1458. /**
  1459. * @brief Helper macro to define ADC analog watchdog parameter:
  1460. * define a single channel to monitor with analog watchdog
  1461. * from sequencer channel and groups definition.
  1462. * @note To be used with function @ref LL_ADC_SetAnalogWDMonitChannels().
  1463. * Example:
  1464. * LL_ADC_SetAnalogWDMonitChannels(
  1465. * ADC1, LL_ADC_AWD1,
  1466. * __LL_ADC_ANALOGWD_CHANNEL_GROUP(LL_ADC_CHANNEL4, LL_ADC_GROUP_REGULAR))
  1467. * @param __CHANNEL__ This parameter can be one of the following values:
  1468. * @arg @ref LL_ADC_CHANNEL_0 (2)
  1469. * @arg @ref LL_ADC_CHANNEL_1 (2)
  1470. * @arg @ref LL_ADC_CHANNEL_2 (2)
  1471. * @arg @ref LL_ADC_CHANNEL_3 (2)
  1472. * @arg @ref LL_ADC_CHANNEL_4 (1)
  1473. * @arg @ref LL_ADC_CHANNEL_5 (1)
  1474. * @arg @ref LL_ADC_CHANNEL_6 (2)
  1475. * @arg @ref LL_ADC_CHANNEL_7 (2)
  1476. * @arg @ref LL_ADC_CHANNEL_8 (2)
  1477. * @arg @ref LL_ADC_CHANNEL_9 (2)
  1478. * @arg @ref LL_ADC_CHANNEL_10 (2)
  1479. * @arg @ref LL_ADC_CHANNEL_11 (2)
  1480. * @arg @ref LL_ADC_CHANNEL_12 (2)
  1481. * @arg @ref LL_ADC_CHANNEL_13 (3)
  1482. * @arg @ref LL_ADC_CHANNEL_14 (3)
  1483. * @arg @ref LL_ADC_CHANNEL_15 (3)
  1484. * @arg @ref LL_ADC_CHANNEL_16 (3)
  1485. * @arg @ref LL_ADC_CHANNEL_17 (3)
  1486. * @arg @ref LL_ADC_CHANNEL_18 (3)
  1487. * @arg @ref LL_ADC_CHANNEL_19 (3)
  1488. * @arg @ref LL_ADC_CHANNEL_20 (3)
  1489. * @arg @ref LL_ADC_CHANNEL_21 (3)
  1490. * @arg @ref LL_ADC_CHANNEL_22 (1)
  1491. * @arg @ref LL_ADC_CHANNEL_23 (1)
  1492. * @arg @ref LL_ADC_CHANNEL_24 (1)
  1493. * @arg @ref LL_ADC_CHANNEL_25 (1)
  1494. * @arg @ref LL_ADC_CHANNEL_26 (3)
  1495. * @arg @ref LL_ADC_CHANNEL_27 (3)(4)
  1496. * @arg @ref LL_ADC_CHANNEL_28 (3)(4)
  1497. * @arg @ref LL_ADC_CHANNEL_29 (3)(4)
  1498. * @arg @ref LL_ADC_CHANNEL_30 (3)(4)
  1499. * @arg @ref LL_ADC_CHANNEL_31 (3)(4)
  1500. * @arg @ref LL_ADC_CHANNEL_VREFINT (3)(6)
  1501. * @arg @ref LL_ADC_CHANNEL_TEMPSENSOR (3)(6)
  1502. * @arg @ref LL_ADC_CHANNEL_VCOMP (3)(6)
  1503. * @arg @ref LL_ADC_CHANNEL_VOPAMP1 (3)(5)
  1504. * @arg @ref LL_ADC_CHANNEL_VOPAMP2 (3)(5)
  1505. * @arg @ref LL_ADC_CHANNEL_VOPAMP3 (3)(5)
  1506. *
  1507. * (1) On STM32L1, connection via routing interface (RI) specificity: fast channel (channel routed directly to ADC switch matrix).\n
  1508. * (2) On STM32L1, for devices with feature 'channels banks' available: Channel different in bank A and bank B.\n
  1509. * (3) On STM32L1, for devices with feature 'channels banks' available: Channel common to both bank A and bank B.\n
  1510. * (4) On STM32L1, parameter not available on all devices: only on STM32L1 Cat.4 and Cat.5.\n
  1511. * (5) On STM32L1, parameter not available on all devices: OPAMP1 and OPAMP2 available only on STM32L1 Cat.3, Cat.4 and Cat.5, OPAMP3 available only on STM32L1 Cat.4 and Cat.5.\n
  1512. * (6) For ADC channel read back from ADC register,
  1513. * comparison with internal channel parameter to be done
  1514. * using helper macro @ref __LL_ADC_CHANNEL_INTERNAL_TO_EXTERNAL().
  1515. * @param __GROUP__ This parameter can be one of the following values:
  1516. * @arg @ref LL_ADC_GROUP_REGULAR
  1517. * @arg @ref LL_ADC_GROUP_INJECTED
  1518. * @arg @ref LL_ADC_GROUP_REGULAR_INJECTED
  1519. * @retval Returned value can be one of the following values:
  1520. * @arg @ref LL_ADC_AWD_DISABLE
  1521. * @arg @ref LL_ADC_AWD_ALL_CHANNELS_REG
  1522. * @arg @ref LL_ADC_AWD_ALL_CHANNELS_INJ
  1523. * @arg @ref LL_ADC_AWD_ALL_CHANNELS_REG_INJ
  1524. * @arg @ref LL_ADC_AWD_CHANNEL_0_REG (2)
  1525. * @arg @ref LL_ADC_AWD_CHANNEL_0_INJ (2)
  1526. * @arg @ref LL_ADC_AWD_CHANNEL_0_REG_INJ (2)
  1527. * @arg @ref LL_ADC_AWD_CHANNEL_1_REG (2)
  1528. * @arg @ref LL_ADC_AWD_CHANNEL_1_INJ (2)
  1529. * @arg @ref LL_ADC_AWD_CHANNEL_1_REG_INJ (2)
  1530. * @arg @ref LL_ADC_AWD_CHANNEL_2_REG (2)
  1531. * @arg @ref LL_ADC_AWD_CHANNEL_2_INJ (2)
  1532. * @arg @ref LL_ADC_AWD_CHANNEL_2_REG_INJ (2)
  1533. * @arg @ref LL_ADC_AWD_CHANNEL_3_REG (2)
  1534. * @arg @ref LL_ADC_AWD_CHANNEL_3_INJ (2)
  1535. * @arg @ref LL_ADC_AWD_CHANNEL_3_REG_INJ (2)
  1536. * @arg @ref LL_ADC_AWD_CHANNEL_4_REG (1)
  1537. * @arg @ref LL_ADC_AWD_CHANNEL_4_INJ (1)
  1538. * @arg @ref LL_ADC_AWD_CHANNEL_4_REG_INJ (1)
  1539. * @arg @ref LL_ADC_AWD_CHANNEL_5_REG (1)
  1540. * @arg @ref LL_ADC_AWD_CHANNEL_5_INJ (1)
  1541. * @arg @ref LL_ADC_AWD_CHANNEL_5_REG_INJ (1)
  1542. * @arg @ref LL_ADC_AWD_CHANNEL_6_REG (2)
  1543. * @arg @ref LL_ADC_AWD_CHANNEL_6_INJ (2)
  1544. * @arg @ref LL_ADC_AWD_CHANNEL_6_REG_INJ (2)
  1545. * @arg @ref LL_ADC_AWD_CHANNEL_7_REG (2)
  1546. * @arg @ref LL_ADC_AWD_CHANNEL_7_INJ (2)
  1547. * @arg @ref LL_ADC_AWD_CHANNEL_7_REG_INJ (2)
  1548. * @arg @ref LL_ADC_AWD_CHANNEL_8_REG (2)
  1549. * @arg @ref LL_ADC_AWD_CHANNEL_8_INJ (2)
  1550. * @arg @ref LL_ADC_AWD_CHANNEL_8_REG_INJ (2)
  1551. * @arg @ref LL_ADC_AWD_CHANNEL_9_REG (2)
  1552. * @arg @ref LL_ADC_AWD_CHANNEL_9_INJ (2)
  1553. * @arg @ref LL_ADC_AWD_CHANNEL_9_REG_INJ (2)
  1554. * @arg @ref LL_ADC_AWD_CHANNEL_10_REG (2)
  1555. * @arg @ref LL_ADC_AWD_CHANNEL_10_INJ (2)
  1556. * @arg @ref LL_ADC_AWD_CHANNEL_10_REG_INJ (2)
  1557. * @arg @ref LL_ADC_AWD_CHANNEL_11_REG (2)
  1558. * @arg @ref LL_ADC_AWD_CHANNEL_11_INJ (2)
  1559. * @arg @ref LL_ADC_AWD_CHANNEL_11_REG_INJ (2)
  1560. * @arg @ref LL_ADC_AWD_CHANNEL_12_REG (2)
  1561. * @arg @ref LL_ADC_AWD_CHANNEL_12_INJ (2)
  1562. * @arg @ref LL_ADC_AWD_CHANNEL_12_REG_INJ (2)
  1563. * @arg @ref LL_ADC_AWD_CHANNEL_13_REG (3)
  1564. * @arg @ref LL_ADC_AWD_CHANNEL_13_INJ (3)
  1565. * @arg @ref LL_ADC_AWD_CHANNEL_13_REG_INJ (3)
  1566. * @arg @ref LL_ADC_AWD_CHANNEL_14_REG (3)
  1567. * @arg @ref LL_ADC_AWD_CHANNEL_14_INJ (3)
  1568. * @arg @ref LL_ADC_AWD_CHANNEL_14_REG_INJ (3)
  1569. * @arg @ref LL_ADC_AWD_CHANNEL_15_REG (3)
  1570. * @arg @ref LL_ADC_AWD_CHANNEL_15_INJ (3)
  1571. * @arg @ref LL_ADC_AWD_CHANNEL_15_REG_INJ (3)
  1572. * @arg @ref LL_ADC_AWD_CHANNEL_16_REG (3)
  1573. * @arg @ref LL_ADC_AWD_CHANNEL_16_INJ (3)
  1574. * @arg @ref LL_ADC_AWD_CHANNEL_16_REG_INJ (3)
  1575. * @arg @ref LL_ADC_AWD_CHANNEL_17_REG (3)
  1576. * @arg @ref LL_ADC_AWD_CHANNEL_17_INJ (3)
  1577. * @arg @ref LL_ADC_AWD_CHANNEL_17_REG_INJ (3)
  1578. * @arg @ref LL_ADC_AWD_CHANNEL_18_REG (3)
  1579. * @arg @ref LL_ADC_AWD_CHANNEL_18_INJ (3)
  1580. * @arg @ref LL_ADC_AWD_CHANNEL_18_REG_INJ (3)
  1581. * @arg @ref LL_ADC_AWD_CHANNEL_19_REG (3)
  1582. * @arg @ref LL_ADC_AWD_CHANNEL_19_INJ (3)
  1583. * @arg @ref LL_ADC_AWD_CHANNEL_19_REG_INJ (3)
  1584. * @arg @ref LL_ADC_AWD_CHANNEL_20_REG (3)
  1585. * @arg @ref LL_ADC_AWD_CHANNEL_20_INJ (3)
  1586. * @arg @ref LL_ADC_AWD_CHANNEL_20_REG_INJ (3)
  1587. * @arg @ref LL_ADC_AWD_CHANNEL_21_REG (3)
  1588. * @arg @ref LL_ADC_AWD_CHANNEL_21_INJ (3)
  1589. * @arg @ref LL_ADC_AWD_CHANNEL_21_REG_INJ (3)
  1590. * @arg @ref LL_ADC_AWD_CHANNEL_22_REG (1)
  1591. * @arg @ref LL_ADC_AWD_CHANNEL_22_INJ (1)
  1592. * @arg @ref LL_ADC_AWD_CHANNEL_22_REG_INJ (1)
  1593. * @arg @ref LL_ADC_AWD_CHANNEL_23_REG (1)
  1594. * @arg @ref LL_ADC_AWD_CHANNEL_23_INJ (1)
  1595. * @arg @ref LL_ADC_AWD_CHANNEL_23_REG_INJ (1)
  1596. * @arg @ref LL_ADC_AWD_CHANNEL_24_REG (1)
  1597. * @arg @ref LL_ADC_AWD_CHANNEL_24_INJ (1)
  1598. * @arg @ref LL_ADC_AWD_CHANNEL_24_REG_INJ (1)
  1599. * @arg @ref LL_ADC_AWD_CHANNEL_25_REG (1)
  1600. * @arg @ref LL_ADC_AWD_CHANNEL_25_INJ (1)
  1601. * @arg @ref LL_ADC_AWD_CHANNEL_25_REG_INJ (1)
  1602. * @arg @ref LL_ADC_AWD_CHANNEL_26_REG (3)
  1603. * @arg @ref LL_ADC_AWD_CHANNEL_26_INJ (3)
  1604. * @arg @ref LL_ADC_AWD_CHANNEL_26_REG_INJ (3)
  1605. * @arg @ref LL_ADC_AWD_CHANNEL_27_REG (3)(4)
  1606. * @arg @ref LL_ADC_AWD_CHANNEL_27_INJ (3)(4)
  1607. * @arg @ref LL_ADC_AWD_CHANNEL_27_REG_INJ (3)(4)
  1608. * @arg @ref LL_ADC_AWD_CHANNEL_28_REG (3)(4)
  1609. * @arg @ref LL_ADC_AWD_CHANNEL_28_INJ (3)(4)
  1610. * @arg @ref LL_ADC_AWD_CHANNEL_28_REG_INJ (3)(4)
  1611. * @arg @ref LL_ADC_AWD_CHANNEL_29_REG (3)(4)
  1612. * @arg @ref LL_ADC_AWD_CHANNEL_29_INJ (3)(4)
  1613. * @arg @ref LL_ADC_AWD_CHANNEL_29_REG_INJ (3)(4)
  1614. * @arg @ref LL_ADC_AWD_CHANNEL_30_REG (3)(4)
  1615. * @arg @ref LL_ADC_AWD_CHANNEL_30_INJ (3)(4)
  1616. * @arg @ref LL_ADC_AWD_CHANNEL_30_REG_INJ (3)(4)
  1617. * @arg @ref LL_ADC_AWD_CHANNEL_31_REG (3)(4)
  1618. * @arg @ref LL_ADC_AWD_CHANNEL_31_INJ (3)(4)
  1619. * @arg @ref LL_ADC_AWD_CHANNEL_31_REG_INJ (3)(4)
  1620. * @arg @ref LL_ADC_AWD_CH_VREFINT_REG (3)
  1621. * @arg @ref LL_ADC_AWD_CH_VREFINT_INJ (3)
  1622. * @arg @ref LL_ADC_AWD_CH_VREFINT_REG_INJ (3)
  1623. * @arg @ref LL_ADC_AWD_CH_TEMPSENSOR_REG (3)
  1624. * @arg @ref LL_ADC_AWD_CH_TEMPSENSOR_INJ (3)
  1625. * @arg @ref LL_ADC_AWD_CH_TEMPSENSOR_REG_INJ (3)
  1626. * @arg @ref LL_ADC_AWD_CH_VCOMP_REG (3)
  1627. * @arg @ref LL_ADC_AWD_CH_VCOMP_INJ (3)
  1628. * @arg @ref LL_ADC_AWD_CH_VCOMP_REG_INJ (3)
  1629. * @arg @ref LL_ADC_AWD_CH_VOPAMP1_REG (3)(5)
  1630. * @arg @ref LL_ADC_AWD_CH_VOPAMP1_INJ (3)(5)
  1631. * @arg @ref LL_ADC_AWD_CH_VOPAMP1_REG_INJ (3)(5)
  1632. * @arg @ref LL_ADC_AWD_CH_VOPAMP2_REG (3)(5)
  1633. * @arg @ref LL_ADC_AWD_CH_VOPAMP2_INJ (3)(5)
  1634. * @arg @ref LL_ADC_AWD_CH_VOPAMP2_REG_INJ (3)(5)
  1635. * @arg @ref LL_ADC_AWD_CH_VOPAMP3_REG (3)(5)
  1636. * @arg @ref LL_ADC_AWD_CH_VOPAMP3_INJ (3)(5)
  1637. * @arg @ref LL_ADC_AWD_CH_VOPAMP3_REG_INJ (3)(5)
  1638. *
  1639. * (1) On STM32L1, connection via routing interface (RI) specificity: fast channel (channel routed directly to ADC switch matrix).\n
  1640. * (2) On STM32L1, for devices with feature 'channels banks' available: Channel different in bank A and bank B.\n
  1641. * (3) On STM32L1, for devices with feature 'channels banks' available: Channel common to both bank A and bank B.\n
  1642. * (4) On STM32L1, parameter not available on all devices: only on STM32L1 Cat.4 and Cat.5.\n
  1643. * (5) On STM32L1, parameter not available on all devices: OPAMP1 and OPAMP2 available only on STM32L1 Cat.3, Cat.4 and Cat.5, OPAMP3 available only on STM32L1 Cat.4 and Cat.5
  1644. */
  1645. #define __LL_ADC_ANALOGWD_CHANNEL_GROUP(__CHANNEL__, __GROUP__) \
  1646. (((__GROUP__) == LL_ADC_GROUP_REGULAR) \
  1647. ? (((__CHANNEL__) & ADC_CHANNEL_ID_MASK) | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) \
  1648. : \
  1649. ((__GROUP__) == LL_ADC_GROUP_INJECTED) \
  1650. ? (((__CHANNEL__) & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDSGL) \
  1651. : \
  1652. (((__CHANNEL__) & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) \
  1653. )
  1654. /**
  1655. * @brief Helper macro to set the value of ADC analog watchdog threshold high
  1656. * or low in function of ADC resolution, when ADC resolution is
  1657. * different of 12 bits.
  1658. * @note To be used with function @ref LL_ADC_SetAnalogWDThresholds().
  1659. * Example, with a ADC resolution of 8 bits, to set the value of
  1660. * analog watchdog threshold high (on 8 bits):
  1661. * LL_ADC_SetAnalogWDThresholds
  1662. * (< ADCx param >,
  1663. * __LL_ADC_ANALOGWD_SET_THRESHOLD_RESOLUTION(LL_ADC_RESOLUTION_8B, <threshold_value_8_bits>)
  1664. * );
  1665. * @param __ADC_RESOLUTION__ This parameter can be one of the following values:
  1666. * @arg @ref LL_ADC_RESOLUTION_12B
  1667. * @arg @ref LL_ADC_RESOLUTION_10B
  1668. * @arg @ref LL_ADC_RESOLUTION_8B
  1669. * @arg @ref LL_ADC_RESOLUTION_6B
  1670. * @param __AWD_THRESHOLD__ Value between Min_Data=0x000 and Max_Data=0xFFF
  1671. * @retval Value between Min_Data=0x000 and Max_Data=0xFFF
  1672. */
  1673. #define __LL_ADC_ANALOGWD_SET_THRESHOLD_RESOLUTION(__ADC_RESOLUTION__, __AWD_THRESHOLD__) \
  1674. ((__AWD_THRESHOLD__) << ((__ADC_RESOLUTION__) >> (ADC_CR1_RES_BITOFFSET_POS - 1U )))
  1675. /**
  1676. * @brief Helper macro to get the value of ADC analog watchdog threshold high
  1677. * or low in function of ADC resolution, when ADC resolution is
  1678. * different of 12 bits.
  1679. * @note To be used with function @ref LL_ADC_GetAnalogWDThresholds().
  1680. * Example, with a ADC resolution of 8 bits, to get the value of
  1681. * analog watchdog threshold high (on 8 bits):
  1682. * < threshold_value_6_bits > = __LL_ADC_ANALOGWD_GET_THRESHOLD_RESOLUTION
  1683. * (LL_ADC_RESOLUTION_8B,
  1684. * LL_ADC_GetAnalogWDThresholds(<ADCx param>, LL_ADC_AWD_THRESHOLD_HIGH)
  1685. * );
  1686. * @param __ADC_RESOLUTION__ This parameter can be one of the following values:
  1687. * @arg @ref LL_ADC_RESOLUTION_12B
  1688. * @arg @ref LL_ADC_RESOLUTION_10B
  1689. * @arg @ref LL_ADC_RESOLUTION_8B
  1690. * @arg @ref LL_ADC_RESOLUTION_6B
  1691. * @param __AWD_THRESHOLD_12_BITS__ Value between Min_Data=0x000 and Max_Data=0xFFF
  1692. * @retval Value between Min_Data=0x000 and Max_Data=0xFFF
  1693. */
  1694. #define __LL_ADC_ANALOGWD_GET_THRESHOLD_RESOLUTION(__ADC_RESOLUTION__, __AWD_THRESHOLD_12_BITS__) \
  1695. ((__AWD_THRESHOLD_12_BITS__) >> ((__ADC_RESOLUTION__) >> (ADC_CR1_RES_BITOFFSET_POS - 1U )))
  1696. /**
  1697. * @brief Helper macro to select the ADC common instance
  1698. * to which is belonging the selected ADC instance.
  1699. * @note ADC common register instance can be used for:
  1700. * - Set parameters common to several ADC instances
  1701. * - Multimode (for devices with several ADC instances)
  1702. * Refer to functions having argument "ADCxy_COMMON" as parameter.
  1703. * @param __ADCx__ ADC instance
  1704. * @retval ADC common register instance
  1705. */
  1706. #define __LL_ADC_COMMON_INSTANCE(__ADCx__) \
  1707. (ADC1_COMMON)
  1708. /**
  1709. * @brief Helper macro to check if all ADC instances sharing the same
  1710. * ADC common instance are disabled.
  1711. * @note This check is required by functions with setting conditioned to
  1712. * ADC state:
  1713. * All ADC instances of the ADC common group must be disabled.
  1714. * Refer to functions having argument "ADCxy_COMMON" as parameter.
  1715. * @note On devices with only 1 ADC common instance, parameter of this macro
  1716. * is useless and can be ignored (parameter kept for compatibility
  1717. * with devices featuring several ADC common instances).
  1718. * @param __ADCXY_COMMON__ ADC common instance
  1719. * (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() )
  1720. * @retval Value "0" if all ADC instances sharing the same ADC common instance
  1721. * are disabled.
  1722. * Value "1" if at least one ADC instance sharing the same ADC common instance
  1723. * is enabled.
  1724. */
  1725. #define __LL_ADC_IS_ENABLED_ALL_COMMON_INSTANCE(__ADCXY_COMMON__) \
  1726. LL_ADC_IsEnabled(ADC1)
  1727. /**
  1728. * @brief Helper macro to define the ADC conversion data full-scale digital
  1729. * value corresponding to the selected ADC resolution.
  1730. * @note ADC conversion data full-scale corresponds to voltage range
  1731. * determined by analog voltage references Vref+ and Vref-
  1732. * (refer to reference manual).
  1733. * @param __ADC_RESOLUTION__ This parameter can be one of the following values:
  1734. * @arg @ref LL_ADC_RESOLUTION_12B
  1735. * @arg @ref LL_ADC_RESOLUTION_10B
  1736. * @arg @ref LL_ADC_RESOLUTION_8B
  1737. * @arg @ref LL_ADC_RESOLUTION_6B
  1738. * @retval ADC conversion data equivalent voltage value (unit: mVolt)
  1739. */
  1740. #define __LL_ADC_DIGITAL_SCALE(__ADC_RESOLUTION__) \
  1741. (0xFFFU >> ((__ADC_RESOLUTION__) >> (ADC_CR1_RES_BITOFFSET_POS - 1U)))
  1742. /**
  1743. * @brief Helper macro to convert the ADC conversion data from
  1744. * a resolution to another resolution.
  1745. * @param __DATA__ ADC conversion data to be converted
  1746. * @param __ADC_RESOLUTION_CURRENT__ Resolution of to the data to be converted
  1747. * This parameter can be one of the following values:
  1748. * @arg @ref LL_ADC_RESOLUTION_12B
  1749. * @arg @ref LL_ADC_RESOLUTION_10B
  1750. * @arg @ref LL_ADC_RESOLUTION_8B
  1751. * @arg @ref LL_ADC_RESOLUTION_6B
  1752. * @param __ADC_RESOLUTION_TARGET__ Resolution of the data after conversion
  1753. * This parameter can be one of the following values:
  1754. * @arg @ref LL_ADC_RESOLUTION_12B
  1755. * @arg @ref LL_ADC_RESOLUTION_10B
  1756. * @arg @ref LL_ADC_RESOLUTION_8B
  1757. * @arg @ref LL_ADC_RESOLUTION_6B
  1758. * @retval ADC conversion data to the requested resolution
  1759. */
  1760. #define __LL_ADC_CONVERT_DATA_RESOLUTION(__DATA__, __ADC_RESOLUTION_CURRENT__, __ADC_RESOLUTION_TARGET__) \
  1761. (((__DATA__) \
  1762. << ((__ADC_RESOLUTION_CURRENT__) >> (ADC_CR1_RES_BITOFFSET_POS - 1U))) \
  1763. >> ((__ADC_RESOLUTION_TARGET__) >> (ADC_CR1_RES_BITOFFSET_POS - 1U)) \
  1764. )
  1765. /**
  1766. * @brief Helper macro to calculate the voltage (unit: mVolt)
  1767. * corresponding to a ADC conversion data (unit: digital value).
  1768. * @note Analog reference voltage (Vref+) must be either known from
  1769. * user board environment or can be calculated using ADC measurement
  1770. * and ADC helper macro @ref __LL_ADC_CALC_VREFANALOG_VOLTAGE().
  1771. * @param __VREFANALOG_VOLTAGE__ Analog reference voltage (unit: mV)
  1772. * @param __ADC_DATA__ ADC conversion data (resolution 12 bits)
  1773. * (unit: digital value).
  1774. * @param __ADC_RESOLUTION__ This parameter can be one of the following values:
  1775. * @arg @ref LL_ADC_RESOLUTION_12B
  1776. * @arg @ref LL_ADC_RESOLUTION_10B
  1777. * @arg @ref LL_ADC_RESOLUTION_8B
  1778. * @arg @ref LL_ADC_RESOLUTION_6B
  1779. * @retval ADC conversion data equivalent voltage value (unit: mVolt)
  1780. */
  1781. #define __LL_ADC_CALC_DATA_TO_VOLTAGE(__VREFANALOG_VOLTAGE__,\
  1782. __ADC_DATA__,\
  1783. __ADC_RESOLUTION__) \
  1784. ((__ADC_DATA__) * (__VREFANALOG_VOLTAGE__) \
  1785. / __LL_ADC_DIGITAL_SCALE(__ADC_RESOLUTION__) \
  1786. )
  1787. /**
  1788. * @brief Helper macro to calculate analog reference voltage (Vref+)
  1789. * (unit: mVolt) from ADC conversion data of internal voltage
  1790. * reference VrefInt.
  1791. * @note Computation is using VrefInt calibration value
  1792. * stored in system memory for each device during production.
  1793. * @note This voltage depends on user board environment: voltage level
  1794. * connected to pin Vref+.
  1795. * On devices with small package, the pin Vref+ is not present
  1796. * and internally bonded to pin Vdda.
  1797. * @note On this STM32 serie, calibration data of internal voltage reference
  1798. * VrefInt corresponds to a resolution of 12 bits,
  1799. * this is the recommended ADC resolution to convert voltage of
  1800. * internal voltage reference VrefInt.
  1801. * Otherwise, this macro performs the processing to scale
  1802. * ADC conversion data to 12 bits.
  1803. * @param __VREFINT_ADC_DATA__: ADC conversion data (resolution 12 bits)
  1804. * of internal voltage reference VrefInt (unit: digital value).
  1805. * @param __ADC_RESOLUTION__ This parameter can be one of the following values:
  1806. * @arg @ref LL_ADC_RESOLUTION_12B
  1807. * @arg @ref LL_ADC_RESOLUTION_10B
  1808. * @arg @ref LL_ADC_RESOLUTION_8B
  1809. * @arg @ref LL_ADC_RESOLUTION_6B
  1810. * @retval Analog reference voltage (unit: mV)
  1811. */
  1812. #define __LL_ADC_CALC_VREFANALOG_VOLTAGE(__VREFINT_ADC_DATA__,\
  1813. __ADC_RESOLUTION__) \
  1814. (((uint32_t)(*VREFINT_CAL_ADDR) * VREFINT_CAL_VREF) \
  1815. / __LL_ADC_CONVERT_DATA_RESOLUTION((__VREFINT_ADC_DATA__), \
  1816. (__ADC_RESOLUTION__), \
  1817. LL_ADC_RESOLUTION_12B) \
  1818. )
  1819. /**
  1820. * @brief Helper macro to calculate the temperature (unit: degree Celsius)
  1821. * from ADC conversion data of internal temperature sensor.
  1822. * @note Computation is using temperature sensor calibration values
  1823. * stored in system memory for each device during production.
  1824. * @note Calculation formula:
  1825. * Temperature = ((TS_ADC_DATA - TS_CAL1)
  1826. * * (TS_CAL2_TEMP - TS_CAL1_TEMP))
  1827. * / (TS_CAL2 - TS_CAL1) + TS_CAL1_TEMP
  1828. * with TS_ADC_DATA = temperature sensor raw data measured by ADC
  1829. * Avg_Slope = (TS_CAL2 - TS_CAL1)
  1830. * / (TS_CAL2_TEMP - TS_CAL1_TEMP)
  1831. * TS_CAL1 = equivalent TS_ADC_DATA at temperature
  1832. * TEMP_DEGC_CAL1 (calibrated in factory)
  1833. * TS_CAL2 = equivalent TS_ADC_DATA at temperature
  1834. * TEMP_DEGC_CAL2 (calibrated in factory)
  1835. * Caution: Calculation relevancy under reserve that calibration
  1836. * parameters are correct (address and data).
  1837. * To calculate temperature using temperature sensor
  1838. * datasheet typical values (generic values less, therefore
  1839. * less accurate than calibrated values),
  1840. * use helper macro @ref __LL_ADC_CALC_TEMPERATURE_TYP_PARAMS().
  1841. * @note As calculation input, the analog reference voltage (Vref+) must be
  1842. * defined as it impacts the ADC LSB equivalent voltage.
  1843. * @note Analog reference voltage (Vref+) must be either known from
  1844. * user board environment or can be calculated using ADC measurement
  1845. * and ADC helper macro @ref __LL_ADC_CALC_VREFANALOG_VOLTAGE().
  1846. * @note On this STM32 serie, calibration data of temperature sensor
  1847. * corresponds to a resolution of 12 bits,
  1848. * this is the recommended ADC resolution to convert voltage of
  1849. * temperature sensor.
  1850. * Otherwise, this macro performs the processing to scale
  1851. * ADC conversion data to 12 bits.
  1852. * @param __VREFANALOG_VOLTAGE__ Analog reference voltage (unit: mV)
  1853. * @param __TEMPSENSOR_ADC_DATA__ ADC conversion data of internal
  1854. * temperature sensor (unit: digital value).
  1855. * @param __ADC_RESOLUTION__ ADC resolution at which internal temperature
  1856. * sensor voltage has been measured.
  1857. * This parameter can be one of the following values:
  1858. * @arg @ref LL_ADC_RESOLUTION_12B
  1859. * @arg @ref LL_ADC_RESOLUTION_10B
  1860. * @arg @ref LL_ADC_RESOLUTION_8B
  1861. * @arg @ref LL_ADC_RESOLUTION_6B
  1862. * @retval Temperature (unit: degree Celsius)
  1863. */
  1864. #define __LL_ADC_CALC_TEMPERATURE(__VREFANALOG_VOLTAGE__,\
  1865. __TEMPSENSOR_ADC_DATA__,\
  1866. __ADC_RESOLUTION__) \
  1867. (((( ((int32_t)((__LL_ADC_CONVERT_DATA_RESOLUTION((__TEMPSENSOR_ADC_DATA__), \
  1868. (__ADC_RESOLUTION__), \
  1869. LL_ADC_RESOLUTION_12B) \
  1870. * (__VREFANALOG_VOLTAGE__)) \
  1871. / TEMPSENSOR_CAL_VREFANALOG) \
  1872. - (int32_t) *TEMPSENSOR_CAL1_ADDR) \
  1873. ) * (int32_t)(TEMPSENSOR_CAL2_TEMP - TEMPSENSOR_CAL1_TEMP) \
  1874. ) / (int32_t)((int32_t)*TEMPSENSOR_CAL2_ADDR - (int32_t)*TEMPSENSOR_CAL1_ADDR) \
  1875. ) + TEMPSENSOR_CAL1_TEMP \
  1876. )
  1877. /**
  1878. * @brief Helper macro to calculate the temperature (unit: degree Celsius)
  1879. * from ADC conversion data of internal temperature sensor.
  1880. * @note Computation is using temperature sensor typical values
  1881. * (refer to device datasheet).
  1882. * @note Calculation formula:
  1883. * Temperature = (TS_TYP_CALx_VOLT(uV) - TS_ADC_DATA * Conversion_uV)
  1884. * / Avg_Slope + CALx_TEMP
  1885. * with TS_ADC_DATA = temperature sensor raw data measured by ADC
  1886. * (unit: digital value)
  1887. * Avg_Slope = temperature sensor slope
  1888. * (unit: uV/Degree Celsius)
  1889. * TS_TYP_CALx_VOLT = temperature sensor digital value at
  1890. * temperature CALx_TEMP (unit: mV)
  1891. * Caution: Calculation relevancy under reserve the temperature sensor
  1892. * of the current device has characteristics in line with
  1893. * datasheet typical values.
  1894. * If temperature sensor calibration values are available on
  1895. * on this device (presence of macro __LL_ADC_CALC_TEMPERATURE()),
  1896. * temperature calculation will be more accurate using
  1897. * helper macro @ref __LL_ADC_CALC_TEMPERATURE().
  1898. * @note As calculation input, the analog reference voltage (Vref+) must be
  1899. * defined as it impacts the ADC LSB equivalent voltage.
  1900. * @note Analog reference voltage (Vref+) must be either known from
  1901. * user board environment or can be calculated using ADC measurement
  1902. * and ADC helper macro @ref __LL_ADC_CALC_VREFANALOG_VOLTAGE().
  1903. * @note ADC measurement data must correspond to a resolution of 12bits
  1904. * (full scale digital value 4095). If not the case, the data must be
  1905. * preliminarily rescaled to an equivalent resolution of 12 bits.
  1906. * @param __TEMPSENSOR_TYP_AVGSLOPE__ Device datasheet data: Temperature sensor slope typical value (unit: uV/DegCelsius).
  1907. * On STM32L1, refer to device datasheet parameter "Avg_Slope".
  1908. * @param __TEMPSENSOR_TYP_CALX_V__ Device datasheet data: Temperature sensor voltage typical value (at temperature and Vref+ defined in parameters below) (unit: mV).
  1909. * On STM32L1, refer to device datasheet parameter "V110" (corresponding to TS_CAL2).
  1910. * @param __TEMPSENSOR_CALX_TEMP__ Device datasheet data: Temperature at which temperature sensor voltage (see parameter above) is corresponding (unit: mV)
  1911. * @param __VREFANALOG_VOLTAGE__ Analog voltage reference (Vref+) voltage (unit: mV)
  1912. * @param __TEMPSENSOR_ADC_DATA__ ADC conversion data of internal temperature sensor (unit: digital value).
  1913. * @param __ADC_RESOLUTION__ ADC resolution at which internal temperature sensor voltage has been measured.
  1914. * This parameter can be one of the following values:
  1915. * @arg @ref LL_ADC_RESOLUTION_12B
  1916. * @arg @ref LL_ADC_RESOLUTION_10B
  1917. * @arg @ref LL_ADC_RESOLUTION_8B
  1918. * @arg @ref LL_ADC_RESOLUTION_6B
  1919. * @retval Temperature (unit: degree Celsius)
  1920. */
  1921. #define __LL_ADC_CALC_TEMPERATURE_TYP_PARAMS(__TEMPSENSOR_TYP_AVGSLOPE__,\
  1922. __TEMPSENSOR_TYP_CALX_V__,\
  1923. __TEMPSENSOR_CALX_TEMP__,\
  1924. __VREFANALOG_VOLTAGE__,\
  1925. __TEMPSENSOR_ADC_DATA__,\
  1926. __ADC_RESOLUTION__) \
  1927. ((( ( \
  1928. (int32_t)((((__TEMPSENSOR_ADC_DATA__) * (__VREFANALOG_VOLTAGE__)) \
  1929. / __LL_ADC_DIGITAL_SCALE(__ADC_RESOLUTION__)) \
  1930. * 1000) \
  1931. - \
  1932. (int32_t)(((__TEMPSENSOR_TYP_CALX_V__)) \
  1933. * 1000) \
  1934. ) \
  1935. ) / (__TEMPSENSOR_TYP_AVGSLOPE__) \
  1936. ) + (__TEMPSENSOR_CALX_TEMP__) \
  1937. )
  1938. /**
  1939. * @}
  1940. */
  1941. /**
  1942. * @}
  1943. */
  1944. /* Exported functions --------------------------------------------------------*/
  1945. /** @defgroup ADC_LL_Exported_Functions ADC Exported Functions
  1946. * @{
  1947. */
  1948. /** @defgroup ADC_LL_EF_DMA_Management ADC DMA management
  1949. * @{
  1950. */
  1951. /* Note: LL ADC functions to set DMA transfer are located into sections of */
  1952. /* configuration of ADC instance, groups and multimode (if available): */
  1953. /* @ref LL_ADC_REG_SetDMATransfer(), ... */
  1954. /**
  1955. * @brief Function to help to configure DMA transfer from ADC: retrieve the
  1956. * ADC register address from ADC instance and a list of ADC registers
  1957. * intended to be used (most commonly) with DMA transfer.
  1958. * @note These ADC registers are data registers:
  1959. * when ADC conversion data is available in ADC data registers,
  1960. * ADC generates a DMA transfer request.
  1961. * @note This macro is intended to be used with LL DMA driver, refer to
  1962. * function "LL_DMA_ConfigAddresses()".
  1963. * Example:
  1964. * LL_DMA_ConfigAddresses(DMA1,
  1965. * LL_DMA_CHANNEL_1,
  1966. * LL_ADC_DMA_GetRegAddr(ADC1, LL_ADC_DMA_REG_REGULAR_DATA),
  1967. * (uint32_t)&< array or variable >,
  1968. * LL_DMA_DIRECTION_PERIPH_TO_MEMORY);
  1969. * @note For devices with several ADC: in multimode, some devices
  1970. * use a different data register outside of ADC instance scope
  1971. * (common data register). This macro manages this register difference,
  1972. * only ADC instance has to be set as parameter.
  1973. * @rmtoll DR DATA LL_ADC_DMA_GetRegAddr
  1974. * @param ADCx ADC instance
  1975. * @param Register This parameter can be one of the following values:
  1976. * @arg @ref LL_ADC_DMA_REG_REGULAR_DATA
  1977. * @retval ADC register address
  1978. */
  1979. __STATIC_INLINE uint32_t LL_ADC_DMA_GetRegAddr(ADC_TypeDef *ADCx, uint32_t Register)
  1980. {
  1981. /* Retrieve address of register DR */
  1982. return (uint32_t)&(ADCx->DR);
  1983. }
  1984. /**
  1985. * @}
  1986. */
  1987. /** @defgroup ADC_LL_EF_Configuration_ADC_Common Configuration of ADC hierarchical scope: common to several ADC instances
  1988. * @{
  1989. */
  1990. /**
  1991. * @brief Set parameter common to several ADC: Clock source and prescaler.
  1992. * @note On this STM32 serie, HSI RC oscillator is the only clock source for ADC.
  1993. * Therefore, HSI RC oscillator must be preliminarily enabled at RCC top level.
  1994. * @note On this STM32 serie, some clock ratio constraints between ADC clock and APB clock
  1995. * must be respected:
  1996. * - In all cases: if APB clock frequency is too low compared ADC clock frequency, a delay between conversions must be inserted.
  1997. * - If ADC group injected is used: ADC clock frequency should be lower than APB clock frequency /4 for resolution 12 or 10 bits, APB clock frequency /3 for resolution 8 bits, APB clock frequency /2 for resolution 6 bits.
  1998. * Refer to reference manual.
  1999. * @rmtoll CCR ADCPRE LL_ADC_SetCommonClock
  2000. * @param ADCxy_COMMON ADC common instance
  2001. * (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() )
  2002. * @param CommonClock This parameter can be one of the following values:
  2003. * @arg @ref LL_ADC_CLOCK_ASYNC_DIV1
  2004. * @arg @ref LL_ADC_CLOCK_ASYNC_DIV2
  2005. * @arg @ref LL_ADC_CLOCK_ASYNC_DIV4
  2006. * @retval None
  2007. */
  2008. __STATIC_INLINE void LL_ADC_SetCommonClock(ADC_Common_TypeDef *ADCxy_COMMON, uint32_t CommonClock)
  2009. {
  2010. MODIFY_REG(ADCxy_COMMON->CCR, ADC_CCR_ADCPRE, CommonClock);
  2011. }
  2012. /**
  2013. * @brief Get parameter common to several ADC: Clock source and prescaler.
  2014. * @rmtoll CCR ADCPRE LL_ADC_GetCommonClock
  2015. * @param ADCxy_COMMON ADC common instance
  2016. * (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() )
  2017. * @retval Returned value can be one of the following values:
  2018. * @arg @ref LL_ADC_CLOCK_ASYNC_DIV1
  2019. * @arg @ref LL_ADC_CLOCK_ASYNC_DIV2
  2020. * @arg @ref LL_ADC_CLOCK_ASYNC_DIV4
  2021. */
  2022. __STATIC_INLINE uint32_t LL_ADC_GetCommonClock(ADC_Common_TypeDef *ADCxy_COMMON)
  2023. {
  2024. return (uint32_t)(READ_BIT(ADCxy_COMMON->CCR, ADC_CCR_ADCPRE));
  2025. }
  2026. /**
  2027. * @brief Set parameter common to several ADC: measurement path to internal
  2028. * channels (VrefInt, temperature sensor, ...).
  2029. * @note One or several values can be selected.
  2030. * Example: (LL_ADC_PATH_INTERNAL_VREFINT |
  2031. * LL_ADC_PATH_INTERNAL_TEMPSENSOR)
  2032. * @note Stabilization time of measurement path to internal channel:
  2033. * After enabling internal paths, before starting ADC conversion,
  2034. * a delay is required for internal voltage reference and
  2035. * temperature sensor stabilization time.
  2036. * Refer to device datasheet.
  2037. * Refer to literal @ref LL_ADC_DELAY_VREFINT_STAB_US.
  2038. * Refer to literal @ref LL_ADC_DELAY_TEMPSENSOR_STAB_US.
  2039. * @note ADC internal channel sampling time constraint:
  2040. * For ADC conversion of internal channels,
  2041. * a sampling time minimum value is required.
  2042. * Refer to device datasheet.
  2043. * @rmtoll CCR TSVREFE LL_ADC_SetCommonPathInternalCh
  2044. * @param ADCxy_COMMON ADC common instance
  2045. * (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() )
  2046. * @param PathInternal This parameter can be a combination of the following values:
  2047. * @arg @ref LL_ADC_PATH_INTERNAL_NONE
  2048. * @arg @ref LL_ADC_PATH_INTERNAL_VREFINT
  2049. * @arg @ref LL_ADC_PATH_INTERNAL_TEMPSENSOR
  2050. * @retval None
  2051. */
  2052. __STATIC_INLINE void LL_ADC_SetCommonPathInternalCh(ADC_Common_TypeDef *ADCxy_COMMON, uint32_t PathInternal)
  2053. {
  2054. MODIFY_REG(ADCxy_COMMON->CCR, ADC_CCR_TSVREFE, PathInternal);
  2055. }
  2056. /**
  2057. * @brief Get parameter common to several ADC: measurement path to internal
  2058. * channels (VrefInt, temperature sensor, ...).
  2059. * @note One or several values can be selected.
  2060. * Example: (LL_ADC_PATH_INTERNAL_VREFINT |
  2061. * LL_ADC_PATH_INTERNAL_TEMPSENSOR)
  2062. * @rmtoll CCR TSVREFE LL_ADC_GetCommonPathInternalCh
  2063. * @param ADCxy_COMMON ADC common instance
  2064. * (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() )
  2065. * @retval Returned value can be a combination of the following values:
  2066. * @arg @ref LL_ADC_PATH_INTERNAL_NONE
  2067. * @arg @ref LL_ADC_PATH_INTERNAL_VREFINT
  2068. * @arg @ref LL_ADC_PATH_INTERNAL_TEMPSENSOR
  2069. */
  2070. __STATIC_INLINE uint32_t LL_ADC_GetCommonPathInternalCh(ADC_Common_TypeDef *ADCxy_COMMON)
  2071. {
  2072. return (uint32_t)(READ_BIT(ADCxy_COMMON->CCR, ADC_CCR_TSVREFE));
  2073. }
  2074. /**
  2075. * @}
  2076. */
  2077. /** @defgroup ADC_LL_EF_Configuration_ADC_Instance Configuration of ADC hierarchical scope: ADC instance
  2078. * @{
  2079. */
  2080. /**
  2081. * @brief Set ADC resolution.
  2082. * Refer to reference manual for alignments formats
  2083. * dependencies to ADC resolutions.
  2084. * @rmtoll CR1 RES LL_ADC_SetResolution
  2085. * @param ADCx ADC instance
  2086. * @param Resolution This parameter can be one of the following values:
  2087. * @arg @ref LL_ADC_RESOLUTION_12B
  2088. * @arg @ref LL_ADC_RESOLUTION_10B
  2089. * @arg @ref LL_ADC_RESOLUTION_8B
  2090. * @arg @ref LL_ADC_RESOLUTION_6B
  2091. * @retval None
  2092. */
  2093. __STATIC_INLINE void LL_ADC_SetResolution(ADC_TypeDef *ADCx, uint32_t Resolution)
  2094. {
  2095. MODIFY_REG(ADCx->CR1, ADC_CR1_RES, Resolution);
  2096. }
  2097. /**
  2098. * @brief Get ADC resolution.
  2099. * Refer to reference manual for alignments formats
  2100. * dependencies to ADC resolutions.
  2101. * @rmtoll CR1 RES LL_ADC_GetResolution
  2102. * @param ADCx ADC instance
  2103. * @retval Returned value can be one of the following values:
  2104. * @arg @ref LL_ADC_RESOLUTION_12B
  2105. * @arg @ref LL_ADC_RESOLUTION_10B
  2106. * @arg @ref LL_ADC_RESOLUTION_8B
  2107. * @arg @ref LL_ADC_RESOLUTION_6B
  2108. */
  2109. __STATIC_INLINE uint32_t LL_ADC_GetResolution(ADC_TypeDef *ADCx)
  2110. {
  2111. return (uint32_t)(READ_BIT(ADCx->CR1, ADC_CR1_RES));
  2112. }
  2113. /**
  2114. * @brief Set ADC conversion data alignment.
  2115. * @note Refer to reference manual for alignments formats
  2116. * dependencies to ADC resolutions.
  2117. * @rmtoll CR2 ALIGN LL_ADC_SetDataAlignment
  2118. * @param ADCx ADC instance
  2119. * @param DataAlignment This parameter can be one of the following values:
  2120. * @arg @ref LL_ADC_DATA_ALIGN_RIGHT
  2121. * @arg @ref LL_ADC_DATA_ALIGN_LEFT
  2122. * @retval None
  2123. */
  2124. __STATIC_INLINE void LL_ADC_SetDataAlignment(ADC_TypeDef *ADCx, uint32_t DataAlignment)
  2125. {
  2126. MODIFY_REG(ADCx->CR2, ADC_CR2_ALIGN, DataAlignment);
  2127. }
  2128. /**
  2129. * @brief Get ADC conversion data alignment.
  2130. * @note Refer to reference manual for alignments formats
  2131. * dependencies to ADC resolutions.
  2132. * @rmtoll CR2 ALIGN LL_ADC_SetDataAlignment
  2133. * @param ADCx ADC instance
  2134. * @retval Returned value can be one of the following values:
  2135. * @arg @ref LL_ADC_DATA_ALIGN_RIGHT
  2136. * @arg @ref LL_ADC_DATA_ALIGN_LEFT
  2137. */
  2138. __STATIC_INLINE uint32_t LL_ADC_GetDataAlignment(ADC_TypeDef *ADCx)
  2139. {
  2140. return (uint32_t)(READ_BIT(ADCx->CR2, ADC_CR2_ALIGN));
  2141. }
  2142. /**
  2143. * @brief Set ADC low power mode auto wait.
  2144. * @note Description of ADC low power modes:
  2145. * - ADC low power mode "auto wait": Dynamic low power mode,
  2146. * ADC conversions occurrences are limited to the minimum necessary
  2147. * in order to reduce power consumption.
  2148. * New ADC conversion starts only when the previous
  2149. * unitary conversion data (for ADC group regular)
  2150. * or previous sequence conversions data (for ADC group injected)
  2151. * has been retrieved by user software.
  2152. * In the meantime, ADC remains idle: does not performs any
  2153. * other conversion.
  2154. * This mode allows to automatically adapt the ADC conversions
  2155. * triggers to the speed of the software that reads the data.
  2156. * Moreover, this avoids risk of overrun for low frequency
  2157. * applications.
  2158. * How to use this low power mode:
  2159. * - Do not use with interruption or DMA since these modes
  2160. * have to clear immediately the EOC flag to free the
  2161. * IRQ vector sequencer.
  2162. * - Do use with polling: 1. Start conversion,
  2163. * 2. Later on, when conversion data is needed: poll for end of
  2164. * conversion to ensure that conversion is completed and
  2165. * retrieve ADC conversion data. This will trig another
  2166. * ADC conversion start.
  2167. * - ADC low power mode "auto power-off":
  2168. * refer to function @ref LL_ADC_SetLowPowerModeAutoPowerOff().
  2169. * @note With ADC low power mode "auto wait", the ADC conversion data read
  2170. * is corresponding to previous ADC conversion start, independently
  2171. * of delay during which ADC was idle.
  2172. * Therefore, the ADC conversion data may be outdated: does not
  2173. * correspond to the current voltage level on the selected
  2174. * ADC channel.
  2175. * @rmtoll CR2 DELS LL_ADC_SetLowPowerModeAutoWait
  2176. * @param ADCx ADC instance
  2177. * @param LowPowerModeAutoWait This parameter can be one of the following values:
  2178. * @arg @ref LL_ADC_LP_AUTOWAIT_NONE
  2179. * @arg @ref LL_ADC_LP_AUTOWAIT
  2180. * @arg @ref LL_ADC_LP_AUTOWAIT_7_APBCLOCKCYCLES
  2181. * @arg @ref LL_ADC_LP_AUTOWAIT_15_APBCLOCKCYCLES
  2182. * @arg @ref LL_ADC_LP_AUTOWAIT_31_APBCLOCKCYCLES
  2183. * @arg @ref LL_ADC_LP_AUTOWAIT_63_APBCLOCKCYCLES
  2184. * @arg @ref LL_ADC_LP_AUTOWAIT_127_APBCLOCKCYCLES
  2185. * @arg @ref LL_ADC_LP_AUTOWAIT_255_APBCLOCKCYCLES
  2186. * @retval None
  2187. */
  2188. __STATIC_INLINE void LL_ADC_SetLowPowerModeAutoWait(ADC_TypeDef *ADCx, uint32_t LowPowerModeAutoWait)
  2189. {
  2190. MODIFY_REG(ADCx->CR2, ADC_CR2_DELS, LowPowerModeAutoWait);
  2191. }
  2192. /**
  2193. * @brief Get ADC low power mode auto wait.
  2194. * @note Description of ADC low power modes:
  2195. * - ADC low power mode "auto wait": Dynamic low power mode,
  2196. * ADC conversions occurrences are limited to the minimum necessary
  2197. * in order to reduce power consumption.
  2198. * New ADC conversion starts only when the previous
  2199. * unitary conversion data (for ADC group regular)
  2200. * or previous sequence conversions data (for ADC group injected)
  2201. * has been retrieved by user software.
  2202. * In the meantime, ADC remains idle: does not performs any
  2203. * other conversion.
  2204. * This mode allows to automatically adapt the ADC conversions
  2205. * triggers to the speed of the software that reads the data.
  2206. * Moreover, this avoids risk of overrun for low frequency
  2207. * applications.
  2208. * How to use this low power mode:
  2209. * - Do not use with interruption or DMA since these modes
  2210. * have to clear immediately the EOC flag to free the
  2211. * IRQ vector sequencer.
  2212. * - Do use with polling: 1. Start conversion,
  2213. * 2. Later on, when conversion data is needed: poll for end of
  2214. * conversion to ensure that conversion is completed and
  2215. * retrieve ADC conversion data. This will trig another
  2216. * ADC conversion start.
  2217. * - ADC low power mode "auto power-off":
  2218. * refer to function @ref LL_ADC_SetLowPowerModeAutoPowerOff().
  2219. * @note With ADC low power mode "auto wait", the ADC conversion data read
  2220. * is corresponding to previous ADC conversion start, independently
  2221. * of delay during which ADC was idle.
  2222. * Therefore, the ADC conversion data may be outdated: does not
  2223. * correspond to the current voltage level on the selected
  2224. * ADC channel.
  2225. * @rmtoll CR2 DELS LL_ADC_GetLowPowerModeAutoWait
  2226. * @param ADCx ADC instance
  2227. * @retval Returned value can be one of the following values:
  2228. * @arg @ref LL_ADC_LP_AUTOWAIT_NONE
  2229. * @arg @ref LL_ADC_LP_AUTOWAIT
  2230. * @arg @ref LL_ADC_LP_AUTOWAIT_7_APBCLOCKCYCLES
  2231. * @arg @ref LL_ADC_LP_AUTOWAIT_15_APBCLOCKCYCLES
  2232. * @arg @ref LL_ADC_LP_AUTOWAIT_31_APBCLOCKCYCLES
  2233. * @arg @ref LL_ADC_LP_AUTOWAIT_63_APBCLOCKCYCLES
  2234. * @arg @ref LL_ADC_LP_AUTOWAIT_127_APBCLOCKCYCLES
  2235. * @arg @ref LL_ADC_LP_AUTOWAIT_255_APBCLOCKCYCLES
  2236. */
  2237. __STATIC_INLINE uint32_t LL_ADC_GetLowPowerModeAutoWait(ADC_TypeDef *ADCx)
  2238. {
  2239. return (uint32_t)(READ_BIT(ADCx->CR2, ADC_CR2_DELS));
  2240. }
  2241. /**
  2242. * @brief Set ADC low power mode auto power-off.
  2243. * @note Description of ADC low power modes:
  2244. * - ADC low power mode "auto wait":
  2245. * refer to function @ref LL_ADC_SetLowPowerModeAutoWait().
  2246. * - ADC low power mode "auto power-off":
  2247. * the ADC automatically powers-off after a conversion and
  2248. * automatically wakes up when a new conversion is triggered
  2249. * (with startup time between trigger and start of sampling).
  2250. * This feature can be combined with low power mode "auto wait".
  2251. * @rmtoll CR1 PDI LL_ADC_GetLowPowerModeAutoPowerOff\n
  2252. * CR1 PDD LL_ADC_GetLowPowerModeAutoPowerOff
  2253. * @param ADCx ADC instance
  2254. * @param LowPowerModeAutoPowerOff This parameter can be one of the following values:
  2255. * @arg @ref LL_ADC_LP_AUTOPOWEROFF_NONE
  2256. * @arg @ref LL_ADC_LP_AUTOPOWEROFF_IDLE_PHASE
  2257. * @arg @ref LL_ADC_LP_AUTOPOWEROFF_AUTOWAIT_PHASE
  2258. * @arg @ref LL_ADC_LP_AUTOPOWEROFF_IDLE_AUTOWAIT_PHASES
  2259. * @retval None
  2260. */
  2261. __STATIC_INLINE void LL_ADC_SetLowPowerModeAutoPowerOff(ADC_TypeDef *ADCx, uint32_t LowPowerModeAutoPowerOff)
  2262. {
  2263. MODIFY_REG(ADCx->CR1, (ADC_CR1_PDI | ADC_CR1_PDD), LowPowerModeAutoPowerOff);
  2264. }
  2265. /**
  2266. * @brief Get ADC low power mode auto power-off.
  2267. * @note Description of ADC low power modes:
  2268. * - ADC low power mode "auto wait":
  2269. * refer to function @ref LL_ADC_SetLowPowerModeAutoWait().
  2270. * - ADC low power mode "auto power-off":
  2271. * the ADC automatically powers-off after a conversion and
  2272. * automatically wakes up when a new conversion is triggered
  2273. * (with startup time between trigger and start of sampling).
  2274. * This feature can be combined with low power mode "auto wait".
  2275. * @rmtoll CR1 PDI LL_ADC_GetLowPowerModeAutoPowerOff\n
  2276. * CR1 PDD LL_ADC_GetLowPowerModeAutoPowerOff
  2277. * @param ADCx ADC instance
  2278. * @retval Returned value can be one of the following values:
  2279. * @arg @ref LL_ADC_LP_AUTOPOWEROFF_NONE
  2280. * @arg @ref LL_ADC_LP_AUTOPOWEROFF_IDLE_PHASE
  2281. * @arg @ref LL_ADC_LP_AUTOPOWEROFF_AUTOWAIT_PHASE
  2282. * @arg @ref LL_ADC_LP_AUTOPOWEROFF_IDLE_AUTOWAIT_PHASES
  2283. */
  2284. __STATIC_INLINE uint32_t LL_ADC_GetLowPowerModeAutoPowerOff(ADC_TypeDef *ADCx)
  2285. {
  2286. return (uint32_t)(READ_BIT(ADCx->CR1, (ADC_CR1_PDI | ADC_CR1_PDD)));
  2287. }
  2288. /**
  2289. * @brief Set ADC sequencers scan mode, for all ADC groups
  2290. * (group regular, group injected).
  2291. * @note According to sequencers scan mode :
  2292. * - If disabled: ADC conversion is performed in unitary conversion
  2293. * mode (one channel converted, that defined in rank 1).
  2294. * Configuration of sequencers of all ADC groups
  2295. * (sequencer scan length, ...) is discarded: equivalent to
  2296. * scan length of 1 rank.
  2297. * - If enabled: ADC conversions are performed in sequence conversions
  2298. * mode, according to configuration of sequencers of
  2299. * each ADC group (sequencer scan length, ...).
  2300. * Refer to function @ref LL_ADC_REG_SetSequencerLength()
  2301. * and to function @ref LL_ADC_INJ_SetSequencerLength().
  2302. * @note On this STM32 serie, setting of this feature is conditioned to
  2303. * ADC state:
  2304. * ADC must be disabled or enabled without conversion on going
  2305. * on either groups regular or injected.
  2306. * @rmtoll CR1 SCAN LL_ADC_SetSequencersScanMode
  2307. * @param ADCx ADC instance
  2308. * @param ScanMode This parameter can be one of the following values:
  2309. * @arg @ref LL_ADC_SEQ_SCAN_DISABLE
  2310. * @arg @ref LL_ADC_SEQ_SCAN_ENABLE
  2311. * @retval None
  2312. */
  2313. __STATIC_INLINE void LL_ADC_SetSequencersScanMode(ADC_TypeDef *ADCx, uint32_t ScanMode)
  2314. {
  2315. MODIFY_REG(ADCx->CR1, ADC_CR1_SCAN, ScanMode);
  2316. }
  2317. /**
  2318. * @brief Get ADC sequencers scan mode, for all ADC groups
  2319. * (group regular, group injected).
  2320. * @note According to sequencers scan mode :
  2321. * - If disabled: ADC conversion is performed in unitary conversion
  2322. * mode (one channel converted, that defined in rank 1).
  2323. * Configuration of sequencers of all ADC groups
  2324. * (sequencer scan length, ...) is discarded: equivalent to
  2325. * scan length of 1 rank.
  2326. * - If enabled: ADC conversions are performed in sequence conversions
  2327. * mode, according to configuration of sequencers of
  2328. * each ADC group (sequencer scan length, ...).
  2329. * Refer to function @ref LL_ADC_REG_SetSequencerLength()
  2330. * and to function @ref LL_ADC_INJ_SetSequencerLength().
  2331. * @rmtoll CR1 SCAN LL_ADC_GetSequencersScanMode
  2332. * @param ADCx ADC instance
  2333. * @retval Returned value can be one of the following values:
  2334. * @arg @ref LL_ADC_SEQ_SCAN_DISABLE
  2335. * @arg @ref LL_ADC_SEQ_SCAN_ENABLE
  2336. */
  2337. __STATIC_INLINE uint32_t LL_ADC_GetSequencersScanMode(ADC_TypeDef *ADCx)
  2338. {
  2339. return (uint32_t)(READ_BIT(ADCx->CR1, ADC_CR1_SCAN));
  2340. }
  2341. #if defined(ADC_CR2_CFG)
  2342. /**
  2343. * @brief Set ADC channels bank.
  2344. * @note Bank selected applies to ADC scope, on all channels
  2345. * (independently of channel mapped on ADC group regular
  2346. * or group injected).
  2347. * @note Banks availability depends on devices categories.
  2348. * @note On this STM32 serie, setting of this feature is conditioned to
  2349. * ADC state:
  2350. * ADC must be disabled or enabled without conversion on going
  2351. * on either groups regular or injected.
  2352. * @rmtoll CR2 ADC_CFG LL_ADC_SetChannelsBank
  2353. * @param ADCx ADC instance
  2354. * @param ChannelsBank This parameter can be one of the following values:
  2355. * @arg @ref LL_ADC_CHANNELS_BANK_A
  2356. * @arg @ref LL_ADC_CHANNELS_BANK_B
  2357. * @retval None
  2358. */
  2359. __STATIC_INLINE void LL_ADC_SetChannelsBank(ADC_TypeDef *ADCx, uint32_t ChannelsBank)
  2360. {
  2361. MODIFY_REG(ADCx->CR2, ADC_CR2_CFG, ChannelsBank);
  2362. }
  2363. /**
  2364. * @brief Get ADC channels bank.
  2365. * @note Bank selected applies to ADC scope, on all channels
  2366. * (independently of channel mapped on ADC group regular
  2367. * or group injected).
  2368. * @note Banks availability depends on devices categories.
  2369. * @rmtoll CR2 ADC_CFG LL_ADC_GetChannelsBank
  2370. * @param ADCx ADC instance
  2371. * @retval Returned value can be one of the following values:
  2372. * @arg @ref LL_ADC_CHANNELS_BANK_A
  2373. * @arg @ref LL_ADC_CHANNELS_BANK_B
  2374. */
  2375. __STATIC_INLINE uint32_t LL_ADC_GetChannelsBank(ADC_TypeDef *ADCx)
  2376. {
  2377. return (uint32_t)(READ_BIT(ADCx->CR2, ADC_CR2_CFG));
  2378. }
  2379. #endif
  2380. /**
  2381. * @}
  2382. */
  2383. /** @defgroup ADC_LL_EF_Configuration_ADC_Group_Regular Configuration of ADC hierarchical scope: group regular
  2384. * @{
  2385. */
  2386. /**
  2387. * @brief Set ADC group regular conversion trigger source:
  2388. * internal (SW start) or from external IP (timer event,
  2389. * external interrupt line).
  2390. * @note On this STM32 serie, setting of external trigger edge is performed
  2391. * using function @ref LL_ADC_REG_StartConversionExtTrig().
  2392. * @note Availability of parameters of trigger sources from timer
  2393. * depends on timers availability on the selected device.
  2394. * @rmtoll CR2 EXTSEL LL_ADC_REG_SetTriggerSource\n
  2395. * CR2 EXTEN LL_ADC_REG_SetTriggerSource
  2396. * @param ADCx ADC instance
  2397. * @param TriggerSource This parameter can be one of the following values:
  2398. * @arg @ref LL_ADC_REG_TRIG_SOFTWARE
  2399. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM2_TRGO
  2400. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM2_CH3
  2401. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM3_TRGO
  2402. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM2_CH2
  2403. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM3_CH1
  2404. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM3_CH3
  2405. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM4_TRGO
  2406. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM4_CH4
  2407. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM6_TRGO
  2408. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM9_CH2
  2409. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM9_TRGO
  2410. * @arg @ref LL_ADC_REG_TRIG_EXT_EXTI_LINE11
  2411. * @retval None
  2412. */
  2413. __STATIC_INLINE void LL_ADC_REG_SetTriggerSource(ADC_TypeDef *ADCx, uint32_t TriggerSource)
  2414. {
  2415. /* Note: On this STM32 serie, ADC group regular external trigger edge */
  2416. /* is used to perform a ADC conversion start. */
  2417. /* This function does not set external trigger edge. */
  2418. /* This feature is set using function */
  2419. /* @ref LL_ADC_REG_StartConversionExtTrig(). */
  2420. MODIFY_REG(ADCx->CR2, ADC_CR2_EXTSEL, (TriggerSource & ADC_CR2_EXTSEL));
  2421. }
  2422. /**
  2423. * @brief Get ADC group regular conversion trigger source:
  2424. * internal (SW start) or from external IP (timer event,
  2425. * external interrupt line).
  2426. * @note To determine whether group regular trigger source is
  2427. * internal (SW start) or external, without detail
  2428. * of which peripheral is selected as external trigger,
  2429. * (equivalent to
  2430. * "if(LL_ADC_REG_GetTriggerSource(ADC1) == LL_ADC_REG_TRIG_SOFTWARE)")
  2431. * use function @ref LL_ADC_REG_IsTriggerSourceSWStart.
  2432. * @note Availability of parameters of trigger sources from timer
  2433. * depends on timers availability on the selected device.
  2434. * @rmtoll CR2 EXTSEL LL_ADC_REG_GetTriggerSource\n
  2435. * CR2 EXTEN LL_ADC_REG_GetTriggerSource
  2436. * @param ADCx ADC instance
  2437. * @retval Returned value can be one of the following values:
  2438. * @arg @ref LL_ADC_REG_TRIG_SOFTWARE
  2439. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM2_TRGO
  2440. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM2_CH3
  2441. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM3_TRGO
  2442. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM2_CH2
  2443. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM3_CH1
  2444. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM3_CH3
  2445. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM4_TRGO
  2446. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM4_CH4
  2447. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM6_TRGO
  2448. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM9_CH2
  2449. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM9_TRGO
  2450. * @arg @ref LL_ADC_REG_TRIG_EXT_EXTI_LINE11
  2451. */
  2452. __STATIC_INLINE uint32_t LL_ADC_REG_GetTriggerSource(ADC_TypeDef *ADCx)
  2453. {
  2454. register uint32_t TriggerSource = READ_BIT(ADCx->CR2, ADC_CR2_EXTSEL | ADC_CR2_EXTEN);
  2455. /* Value for shift of {0; 4; 8; 12} depending on value of bitfield */
  2456. /* corresponding to ADC_CR2_EXTEN {0; 1; 2; 3}. */
  2457. register uint32_t ShiftExten = ((TriggerSource & ADC_CR2_EXTEN) >> (ADC_REG_TRIG_EXTEN_BITOFFSET_POS - 2U));
  2458. /* Set bitfield corresponding to ADC_CR2_EXTEN and ADC_CR2_EXTSEL */
  2459. /* to match with triggers literals definition. */
  2460. return ((TriggerSource
  2461. & (ADC_REG_TRIG_SOURCE_MASK << ShiftExten) & ADC_CR2_EXTSEL)
  2462. | ((ADC_REG_TRIG_EDGE_MASK << ShiftExten) & ADC_CR2_EXTEN)
  2463. );
  2464. }
  2465. /**
  2466. * @brief Get ADC group regular conversion trigger source internal (SW start)
  2467. or external.
  2468. * @note In case of group regular trigger source set to external trigger,
  2469. * to determine which peripheral is selected as external trigger,
  2470. * use function @ref LL_ADC_REG_GetTriggerSource().
  2471. * @rmtoll CR2 EXTEN LL_ADC_REG_IsTriggerSourceSWStart
  2472. * @param ADCx ADC instance
  2473. * @retval Value "0" if trigger source external trigger
  2474. * Value "1" if trigger source SW start.
  2475. */
  2476. __STATIC_INLINE uint32_t LL_ADC_REG_IsTriggerSourceSWStart(ADC_TypeDef *ADCx)
  2477. {
  2478. return (READ_BIT(ADCx->CR2, ADC_CR2_EXTEN) == (LL_ADC_REG_TRIG_SOFTWARE & ADC_CR2_EXTEN));
  2479. }
  2480. /**
  2481. * @brief Get ADC group regular conversion trigger polarity.
  2482. * @note Applicable only for trigger source set to external trigger.
  2483. * @note On this STM32 serie, setting of external trigger edge is performed
  2484. * using function @ref LL_ADC_REG_StartConversionExtTrig().
  2485. * @rmtoll CR2 EXTEN LL_ADC_REG_GetTriggerEdge
  2486. * @param ADCx ADC instance
  2487. * @retval Returned value can be one of the following values:
  2488. * @arg @ref LL_ADC_REG_TRIG_EXT_RISING
  2489. * @arg @ref LL_ADC_REG_TRIG_EXT_FALLING
  2490. * @arg @ref LL_ADC_REG_TRIG_EXT_RISINGFALLING
  2491. */
  2492. __STATIC_INLINE uint32_t LL_ADC_REG_GetTriggerEdge(ADC_TypeDef *ADCx)
  2493. {
  2494. return (uint32_t)(READ_BIT(ADCx->CR2, ADC_CR2_EXTEN));
  2495. }
  2496. /**
  2497. * @brief Set ADC group regular sequencer length and scan direction.
  2498. * @note Description of ADC group regular sequencer features:
  2499. * - For devices with sequencer fully configurable
  2500. * (function "LL_ADC_REG_SetSequencerRanks()" available):
  2501. * sequencer length and each rank affectation to a channel
  2502. * are configurable.
  2503. * This function performs configuration of:
  2504. * - Sequence length: Number of ranks in the scan sequence.
  2505. * - Sequence direction: Unless specified in parameters, sequencer
  2506. * scan direction is forward (from rank 1 to rank n).
  2507. * Sequencer ranks are selected using
  2508. * function "LL_ADC_REG_SetSequencerRanks()".
  2509. * - For devices with sequencer not fully configurable
  2510. * (function "LL_ADC_REG_SetSequencerChannels()" available):
  2511. * sequencer length and each rank affectation to a channel
  2512. * are defined by channel number.
  2513. * This function performs configuration of:
  2514. * - Sequence length: Number of ranks in the scan sequence is
  2515. * defined by number of channels set in the sequence,
  2516. * rank of each channel is fixed by channel HW number.
  2517. * (channel 0 fixed on rank 0, channel 1 fixed on rank1, ...).
  2518. * - Sequence direction: Unless specified in parameters, sequencer
  2519. * scan direction is forward (from lowest channel number to
  2520. * highest channel number).
  2521. * Sequencer ranks are selected using
  2522. * function "LL_ADC_REG_SetSequencerChannels()".
  2523. * @note On this STM32 serie, group regular sequencer configuration
  2524. * is conditioned to ADC instance sequencer mode.
  2525. * If ADC instance sequencer mode is disabled, sequencers of
  2526. * all groups (group regular, group injected) can be configured
  2527. * but their execution is disabled (limited to rank 1).
  2528. * Refer to function @ref LL_ADC_SetSequencersScanMode().
  2529. * @note Sequencer disabled is equivalent to sequencer of 1 rank:
  2530. * ADC conversion on only 1 channel.
  2531. * @rmtoll SQR1 L LL_ADC_REG_SetSequencerLength
  2532. * @param ADCx ADC instance
  2533. * @param SequencerNbRanks This parameter can be one of the following values:
  2534. * @arg @ref LL_ADC_REG_SEQ_SCAN_DISABLE
  2535. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_2RANKS
  2536. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_3RANKS
  2537. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_4RANKS
  2538. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_5RANKS
  2539. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_6RANKS
  2540. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_7RANKS
  2541. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_8RANKS
  2542. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_9RANKS
  2543. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_10RANKS
  2544. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_11RANKS
  2545. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_12RANKS
  2546. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_13RANKS
  2547. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_14RANKS
  2548. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_15RANKS
  2549. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_16RANKS
  2550. * @retval None
  2551. */
  2552. __STATIC_INLINE void LL_ADC_REG_SetSequencerLength(ADC_TypeDef *ADCx, uint32_t SequencerNbRanks)
  2553. {
  2554. MODIFY_REG(ADCx->SQR1, ADC_SQR1_L, SequencerNbRanks);
  2555. }
  2556. /**
  2557. * @brief Get ADC group regular sequencer length and scan direction.
  2558. * @note Description of ADC group regular sequencer features:
  2559. * - For devices with sequencer fully configurable
  2560. * (function "LL_ADC_REG_SetSequencerRanks()" available):
  2561. * sequencer length and each rank affectation to a channel
  2562. * are configurable.
  2563. * This function retrieves:
  2564. * - Sequence length: Number of ranks in the scan sequence.
  2565. * - Sequence direction: Unless specified in parameters, sequencer
  2566. * scan direction is forward (from rank 1 to rank n).
  2567. * Sequencer ranks are selected using
  2568. * function "LL_ADC_REG_SetSequencerRanks()".
  2569. * - For devices with sequencer not fully configurable
  2570. * (function "LL_ADC_REG_SetSequencerChannels()" available):
  2571. * sequencer length and each rank affectation to a channel
  2572. * are defined by channel number.
  2573. * This function retrieves:
  2574. * - Sequence length: Number of ranks in the scan sequence is
  2575. * defined by number of channels set in the sequence,
  2576. * rank of each channel is fixed by channel HW number.
  2577. * (channel 0 fixed on rank 0, channel 1 fixed on rank1, ...).
  2578. * - Sequence direction: Unless specified in parameters, sequencer
  2579. * scan direction is forward (from lowest channel number to
  2580. * highest channel number).
  2581. * Sequencer ranks are selected using
  2582. * function "LL_ADC_REG_SetSequencerChannels()".
  2583. * @note On this STM32 serie, group regular sequencer configuration
  2584. * is conditioned to ADC instance sequencer mode.
  2585. * If ADC instance sequencer mode is disabled, sequencers of
  2586. * all groups (group regular, group injected) can be configured
  2587. * but their execution is disabled (limited to rank 1).
  2588. * Refer to function @ref LL_ADC_SetSequencersScanMode().
  2589. * @note Sequencer disabled is equivalent to sequencer of 1 rank:
  2590. * ADC conversion on only 1 channel.
  2591. * @rmtoll SQR1 L LL_ADC_REG_SetSequencerLength
  2592. * @param ADCx ADC instance
  2593. * @retval Returned value can be one of the following values:
  2594. * @arg @ref LL_ADC_REG_SEQ_SCAN_DISABLE
  2595. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_2RANKS
  2596. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_3RANKS
  2597. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_4RANKS
  2598. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_5RANKS
  2599. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_6RANKS
  2600. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_7RANKS
  2601. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_8RANKS
  2602. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_9RANKS
  2603. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_10RANKS
  2604. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_11RANKS
  2605. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_12RANKS
  2606. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_13RANKS
  2607. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_14RANKS
  2608. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_15RANKS
  2609. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_16RANKS
  2610. */
  2611. __STATIC_INLINE uint32_t LL_ADC_REG_GetSequencerLength(ADC_TypeDef *ADCx)
  2612. {
  2613. return (uint32_t)(READ_BIT(ADCx->SQR1, ADC_SQR1_L));
  2614. }
  2615. /**
  2616. * @brief Set ADC group regular sequencer discontinuous mode:
  2617. * sequence subdivided and scan conversions interrupted every selected
  2618. * number of ranks.
  2619. * @note It is not possible to enable both ADC group regular
  2620. * continuous mode and sequencer discontinuous mode.
  2621. * @note It is not possible to enable both ADC auto-injected mode
  2622. * and ADC group regular sequencer discontinuous mode.
  2623. * @rmtoll CR1 DISCEN LL_ADC_REG_SetSequencerDiscont\n
  2624. * CR1 DISCNUM LL_ADC_REG_SetSequencerDiscont
  2625. * @param ADCx ADC instance
  2626. * @param SeqDiscont This parameter can be one of the following values:
  2627. * @arg @ref LL_ADC_REG_SEQ_DISCONT_DISABLE
  2628. * @arg @ref LL_ADC_REG_SEQ_DISCONT_1RANK
  2629. * @arg @ref LL_ADC_REG_SEQ_DISCONT_2RANKS
  2630. * @arg @ref LL_ADC_REG_SEQ_DISCONT_3RANKS
  2631. * @arg @ref LL_ADC_REG_SEQ_DISCONT_4RANKS
  2632. * @arg @ref LL_ADC_REG_SEQ_DISCONT_5RANKS
  2633. * @arg @ref LL_ADC_REG_SEQ_DISCONT_6RANKS
  2634. * @arg @ref LL_ADC_REG_SEQ_DISCONT_7RANKS
  2635. * @arg @ref LL_ADC_REG_SEQ_DISCONT_8RANKS
  2636. * @retval None
  2637. */
  2638. __STATIC_INLINE void LL_ADC_REG_SetSequencerDiscont(ADC_TypeDef *ADCx, uint32_t SeqDiscont)
  2639. {
  2640. MODIFY_REG(ADCx->CR1, ADC_CR1_DISCEN | ADC_CR1_DISCNUM, SeqDiscont);
  2641. }
  2642. /**
  2643. * @brief Get ADC group regular sequencer discontinuous mode:
  2644. * sequence subdivided and scan conversions interrupted every selected
  2645. * number of ranks.
  2646. * @rmtoll CR1 DISCEN LL_ADC_REG_GetSequencerDiscont\n
  2647. * CR1 DISCNUM LL_ADC_REG_GetSequencerDiscont
  2648. * @param ADCx ADC instance
  2649. * @retval Returned value can be one of the following values:
  2650. * @arg @ref LL_ADC_REG_SEQ_DISCONT_DISABLE
  2651. * @arg @ref LL_ADC_REG_SEQ_DISCONT_1RANK
  2652. * @arg @ref LL_ADC_REG_SEQ_DISCONT_2RANKS
  2653. * @arg @ref LL_ADC_REG_SEQ_DISCONT_3RANKS
  2654. * @arg @ref LL_ADC_REG_SEQ_DISCONT_4RANKS
  2655. * @arg @ref LL_ADC_REG_SEQ_DISCONT_5RANKS
  2656. * @arg @ref LL_ADC_REG_SEQ_DISCONT_6RANKS
  2657. * @arg @ref LL_ADC_REG_SEQ_DISCONT_7RANKS
  2658. * @arg @ref LL_ADC_REG_SEQ_DISCONT_8RANKS
  2659. */
  2660. __STATIC_INLINE uint32_t LL_ADC_REG_GetSequencerDiscont(ADC_TypeDef *ADCx)
  2661. {
  2662. return (uint32_t)(READ_BIT(ADCx->CR1, ADC_CR1_DISCEN | ADC_CR1_DISCNUM));
  2663. }
  2664. /**
  2665. * @brief Set ADC group regular sequence: channel on the selected
  2666. * scan sequence rank.
  2667. * @note This function performs configuration of:
  2668. * - Channels ordering into each rank of scan sequence:
  2669. * whatever channel can be placed into whatever rank.
  2670. * @note On this STM32 serie, ADC group regular sequencer is
  2671. * fully configurable: sequencer length and each rank
  2672. * affectation to a channel are configurable.
  2673. * Refer to description of function @ref LL_ADC_REG_SetSequencerLength().
  2674. * @note Depending on devices and packages, some channels may not be available.
  2675. * Refer to device datasheet for channels availability.
  2676. * @note On this STM32 serie, to measure internal channels (VrefInt,
  2677. * TempSensor, ...), measurement paths to internal channels must be
  2678. * enabled separately.
  2679. * This can be done using function @ref LL_ADC_SetCommonPathInternalCh().
  2680. * @rmtoll SQR5 SQ1 LL_ADC_REG_SetSequencerRanks\n
  2681. * SQR5 SQ2 LL_ADC_REG_SetSequencerRanks\n
  2682. * SQR5 SQ3 LL_ADC_REG_SetSequencerRanks\n
  2683. * SQR5 SQ4 LL_ADC_REG_SetSequencerRanks\n
  2684. * SQR5 SQ5 LL_ADC_REG_SetSequencerRanks\n
  2685. * SQR5 SQ6 LL_ADC_REG_SetSequencerRanks\n
  2686. * SQR4 SQ7 LL_ADC_REG_SetSequencerRanks\n
  2687. * SQR4 SQ8 LL_ADC_REG_SetSequencerRanks\n
  2688. * SQR4 SQ9 LL_ADC_REG_SetSequencerRanks\n
  2689. * SQR4 SQ10 LL_ADC_REG_SetSequencerRanks\n
  2690. * SQR4 SQ11 LL_ADC_REG_SetSequencerRanks\n
  2691. * SQR4 SQ12 LL_ADC_REG_SetSequencerRanks\n
  2692. * SQR3 SQ13 LL_ADC_REG_SetSequencerRanks\n
  2693. * SQR3 SQ14 LL_ADC_REG_SetSequencerRanks\n
  2694. * SQR3 SQ15 LL_ADC_REG_SetSequencerRanks\n
  2695. * SQR3 SQ16 LL_ADC_REG_SetSequencerRanks\n
  2696. * SQR3 SQ17 LL_ADC_REG_SetSequencerRanks\n
  2697. * SQR3 SQ18 LL_ADC_REG_SetSequencerRanks\n
  2698. * SQR2 SQ19 LL_ADC_REG_SetSequencerRanks\n
  2699. * SQR2 SQ20 LL_ADC_REG_SetSequencerRanks\n
  2700. * SQR2 SQ21 LL_ADC_REG_SetSequencerRanks\n
  2701. * SQR2 SQ22 LL_ADC_REG_SetSequencerRanks\n
  2702. * SQR2 SQ23 LL_ADC_REG_SetSequencerRanks\n
  2703. * SQR2 SQ24 LL_ADC_REG_SetSequencerRanks\n
  2704. * SQR1 SQ25 LL_ADC_REG_SetSequencerRanks\n
  2705. * SQR1 SQ26 LL_ADC_REG_SetSequencerRanks\n
  2706. * SQR1 SQ27 LL_ADC_REG_SetSequencerRanks\n
  2707. * SQR1 SQ28 LL_ADC_REG_SetSequencerRanks
  2708. * @param ADCx ADC instance
  2709. * @param Rank This parameter can be one of the following values:
  2710. * @arg @ref LL_ADC_REG_RANK_1
  2711. * @arg @ref LL_ADC_REG_RANK_2
  2712. * @arg @ref LL_ADC_REG_RANK_3
  2713. * @arg @ref LL_ADC_REG_RANK_4
  2714. * @arg @ref LL_ADC_REG_RANK_5
  2715. * @arg @ref LL_ADC_REG_RANK_6
  2716. * @arg @ref LL_ADC_REG_RANK_7
  2717. * @arg @ref LL_ADC_REG_RANK_8
  2718. * @arg @ref LL_ADC_REG_RANK_9
  2719. * @arg @ref LL_ADC_REG_RANK_10
  2720. * @arg @ref LL_ADC_REG_RANK_11
  2721. * @arg @ref LL_ADC_REG_RANK_12
  2722. * @arg @ref LL_ADC_REG_RANK_13
  2723. * @arg @ref LL_ADC_REG_RANK_14
  2724. * @arg @ref LL_ADC_REG_RANK_15
  2725. * @arg @ref LL_ADC_REG_RANK_16
  2726. * @arg @ref LL_ADC_REG_RANK_17
  2727. * @arg @ref LL_ADC_REG_RANK_18
  2728. * @arg @ref LL_ADC_REG_RANK_19
  2729. * @arg @ref LL_ADC_REG_RANK_20
  2730. * @arg @ref LL_ADC_REG_RANK_21
  2731. * @arg @ref LL_ADC_REG_RANK_22
  2732. * @arg @ref LL_ADC_REG_RANK_23
  2733. * @arg @ref LL_ADC_REG_RANK_24
  2734. * @arg @ref LL_ADC_REG_RANK_25
  2735. * @arg @ref LL_ADC_REG_RANK_26
  2736. * @arg @ref LL_ADC_REG_RANK_27
  2737. * @arg @ref LL_ADC_REG_RANK_28 (1)
  2738. *
  2739. * (1) On STM32L1, parameter not available on all devices: only on STM32L1 Cat.3, Cat.4 and Cat.5.
  2740. * @param Channel This parameter can be one of the following values:
  2741. * @arg @ref LL_ADC_CHANNEL_0 (2)
  2742. * @arg @ref LL_ADC_CHANNEL_1 (2)
  2743. * @arg @ref LL_ADC_CHANNEL_2 (2)
  2744. * @arg @ref LL_ADC_CHANNEL_3 (2)
  2745. * @arg @ref LL_ADC_CHANNEL_4 (1)
  2746. * @arg @ref LL_ADC_CHANNEL_5 (1)
  2747. * @arg @ref LL_ADC_CHANNEL_6 (2)
  2748. * @arg @ref LL_ADC_CHANNEL_7 (2)
  2749. * @arg @ref LL_ADC_CHANNEL_8 (2)
  2750. * @arg @ref LL_ADC_CHANNEL_9 (2)
  2751. * @arg @ref LL_ADC_CHANNEL_10 (2)
  2752. * @arg @ref LL_ADC_CHANNEL_11 (2)
  2753. * @arg @ref LL_ADC_CHANNEL_12 (2)
  2754. * @arg @ref LL_ADC_CHANNEL_13 (3)
  2755. * @arg @ref LL_ADC_CHANNEL_14 (3)
  2756. * @arg @ref LL_ADC_CHANNEL_15 (3)
  2757. * @arg @ref LL_ADC_CHANNEL_16 (3)
  2758. * @arg @ref LL_ADC_CHANNEL_17 (3)
  2759. * @arg @ref LL_ADC_CHANNEL_18 (3)
  2760. * @arg @ref LL_ADC_CHANNEL_19 (3)
  2761. * @arg @ref LL_ADC_CHANNEL_20 (3)
  2762. * @arg @ref LL_ADC_CHANNEL_21 (3)
  2763. * @arg @ref LL_ADC_CHANNEL_22 (1)
  2764. * @arg @ref LL_ADC_CHANNEL_23 (1)
  2765. * @arg @ref LL_ADC_CHANNEL_24 (1)
  2766. * @arg @ref LL_ADC_CHANNEL_25 (1)
  2767. * @arg @ref LL_ADC_CHANNEL_26 (3)
  2768. * @arg @ref LL_ADC_CHANNEL_27 (3)(4)
  2769. * @arg @ref LL_ADC_CHANNEL_28 (3)(4)
  2770. * @arg @ref LL_ADC_CHANNEL_29 (3)(4)
  2771. * @arg @ref LL_ADC_CHANNEL_30 (3)(4)
  2772. * @arg @ref LL_ADC_CHANNEL_31 (3)(4)
  2773. * @arg @ref LL_ADC_CHANNEL_VREFINT (3)
  2774. * @arg @ref LL_ADC_CHANNEL_TEMPSENSOR (3)
  2775. * @arg @ref LL_ADC_CHANNEL_VCOMP (3)
  2776. * @arg @ref LL_ADC_CHANNEL_VOPAMP1 (3)(5)
  2777. * @arg @ref LL_ADC_CHANNEL_VOPAMP2 (3)(5)
  2778. * @arg @ref LL_ADC_CHANNEL_VOPAMP3 (3)(5)
  2779. *
  2780. * (1) On STM32L1, connection via routing interface (RI) specificity: fast channel (channel routed directly to ADC switch matrix).\n
  2781. * (2) On STM32L1, for devices with feature 'channels banks' available: Channel different in bank A and bank B.\n
  2782. * (3) On STM32L1, for devices with feature 'channels banks' available: Channel common to both bank A and bank B.\n
  2783. * (4) On STM32L1, parameter not available on all devices: only on STM32L1 Cat.4 and Cat.5.\n
  2784. * (5) On STM32L1, parameter not available on all devices: OPAMP1 and OPAMP2 available only on STM32L1 Cat.3, Cat.4 and Cat.5, OPAMP3 available only on STM32L1 Cat.4 and Cat.5
  2785. * @retval None
  2786. */
  2787. __STATIC_INLINE void LL_ADC_REG_SetSequencerRanks(ADC_TypeDef *ADCx, uint32_t Rank, uint32_t Channel)
  2788. {
  2789. /* Set bits with content of parameter "Channel" with bits position */
  2790. /* in register and register position depending on parameter "Rank". */
  2791. /* Parameters "Rank" and "Channel" are used with masks because containing */
  2792. /* other bits reserved for other purpose. */
  2793. register uint32_t *preg = __ADC_PTR_REG_OFFSET(ADCx->SQR1, __ADC_MASK_SHIFT(Rank, ADC_REG_SQRX_REGOFFSET_MASK));
  2794. MODIFY_REG(*preg,
  2795. ADC_CHANNEL_ID_NUMBER_MASK << (Rank & ADC_REG_RANK_ID_SQRX_MASK),
  2796. (Channel & ADC_CHANNEL_ID_NUMBER_MASK) << (Rank & ADC_REG_RANK_ID_SQRX_MASK));
  2797. }
  2798. /**
  2799. * @brief Get ADC group regular sequence: channel on the selected
  2800. * scan sequence rank.
  2801. * @note On this STM32 serie, ADC group regular sequencer is
  2802. * fully configurable: sequencer length and each rank
  2803. * affectation to a channel are configurable.
  2804. * Refer to description of function @ref LL_ADC_REG_SetSequencerLength().
  2805. * @note Depending on devices and packages, some channels may not be available.
  2806. * Refer to device datasheet for channels availability.
  2807. * @note Usage of the returned channel number:
  2808. * - To reinject this channel into another function LL_ADC_xxx:
  2809. * the returned channel number is only partly formatted on definition
  2810. * of literals LL_ADC_CHANNEL_x. Therefore, it has to be compared
  2811. * with parts of literals LL_ADC_CHANNEL_x or using
  2812. * helper macro @ref __LL_ADC_CHANNEL_TO_DECIMAL_NB().
  2813. * Then the selected literal LL_ADC_CHANNEL_x can be used
  2814. * as parameter for another function.
  2815. * - To get the channel number in decimal format:
  2816. * process the returned value with the helper macro
  2817. * @ref __LL_ADC_CHANNEL_TO_DECIMAL_NB().
  2818. * @rmtoll SQR5 SQ1 LL_ADC_REG_GetSequencerRanks\n
  2819. * SQR5 SQ2 LL_ADC_REG_GetSequencerRanks\n
  2820. * SQR5 SQ3 LL_ADC_REG_GetSequencerRanks\n
  2821. * SQR5 SQ4 LL_ADC_REG_GetSequencerRanks\n
  2822. * SQR5 SQ5 LL_ADC_REG_GetSequencerRanks\n
  2823. * SQR5 SQ6 LL_ADC_REG_GetSequencerRanks\n
  2824. * SQR4 SQ7 LL_ADC_REG_GetSequencerRanks\n
  2825. * SQR4 SQ8 LL_ADC_REG_GetSequencerRanks\n
  2826. * SQR4 SQ9 LL_ADC_REG_GetSequencerRanks\n
  2827. * SQR4 SQ10 LL_ADC_REG_GetSequencerRanks\n
  2828. * SQR4 SQ11 LL_ADC_REG_GetSequencerRanks\n
  2829. * SQR4 SQ12 LL_ADC_REG_GetSequencerRanks\n
  2830. * SQR3 SQ13 LL_ADC_REG_GetSequencerRanks\n
  2831. * SQR3 SQ14 LL_ADC_REG_GetSequencerRanks\n
  2832. * SQR3 SQ15 LL_ADC_REG_GetSequencerRanks\n
  2833. * SQR3 SQ16 LL_ADC_REG_GetSequencerRanks\n
  2834. * SQR3 SQ17 LL_ADC_REG_GetSequencerRanks\n
  2835. * SQR3 SQ18 LL_ADC_REG_GetSequencerRanks\n
  2836. * SQR2 SQ19 LL_ADC_REG_GetSequencerRanks\n
  2837. * SQR2 SQ20 LL_ADC_REG_GetSequencerRanks\n
  2838. * SQR2 SQ21 LL_ADC_REG_GetSequencerRanks\n
  2839. * SQR2 SQ22 LL_ADC_REG_GetSequencerRanks\n
  2840. * SQR2 SQ23 LL_ADC_REG_GetSequencerRanks\n
  2841. * SQR2 SQ24 LL_ADC_REG_GetSequencerRanks\n
  2842. * SQR1 SQ25 LL_ADC_REG_GetSequencerRanks\n
  2843. * SQR1 SQ26 LL_ADC_REG_GetSequencerRanks\n
  2844. * SQR1 SQ27 LL_ADC_REG_GetSequencerRanks\n
  2845. * SQR1 SQ28 LL_ADC_REG_GetSequencerRanks
  2846. * @param ADCx ADC instance
  2847. * @param Rank This parameter can be one of the following values:
  2848. * @arg @ref LL_ADC_REG_RANK_1
  2849. * @arg @ref LL_ADC_REG_RANK_2
  2850. * @arg @ref LL_ADC_REG_RANK_3
  2851. * @arg @ref LL_ADC_REG_RANK_4
  2852. * @arg @ref LL_ADC_REG_RANK_5
  2853. * @arg @ref LL_ADC_REG_RANK_6
  2854. * @arg @ref LL_ADC_REG_RANK_7
  2855. * @arg @ref LL_ADC_REG_RANK_8
  2856. * @arg @ref LL_ADC_REG_RANK_9
  2857. * @arg @ref LL_ADC_REG_RANK_10
  2858. * @arg @ref LL_ADC_REG_RANK_11
  2859. * @arg @ref LL_ADC_REG_RANK_12
  2860. * @arg @ref LL_ADC_REG_RANK_13
  2861. * @arg @ref LL_ADC_REG_RANK_14
  2862. * @arg @ref LL_ADC_REG_RANK_15
  2863. * @arg @ref LL_ADC_REG_RANK_16
  2864. * @arg @ref LL_ADC_REG_RANK_17
  2865. * @arg @ref LL_ADC_REG_RANK_18
  2866. * @arg @ref LL_ADC_REG_RANK_19
  2867. * @arg @ref LL_ADC_REG_RANK_20
  2868. * @arg @ref LL_ADC_REG_RANK_21
  2869. * @arg @ref LL_ADC_REG_RANK_22
  2870. * @arg @ref LL_ADC_REG_RANK_23
  2871. * @arg @ref LL_ADC_REG_RANK_24
  2872. * @arg @ref LL_ADC_REG_RANK_25
  2873. * @arg @ref LL_ADC_REG_RANK_26
  2874. * @arg @ref LL_ADC_REG_RANK_27
  2875. * @arg @ref LL_ADC_REG_RANK_28 (1)
  2876. *
  2877. * (1) On STM32L1, parameter not available on all devices: only on STM32L1 Cat.3, Cat.4 and Cat.5.
  2878. * @retval Returned value can be one of the following values:
  2879. * @arg @ref LL_ADC_CHANNEL_0 (2)
  2880. * @arg @ref LL_ADC_CHANNEL_1 (2)
  2881. * @arg @ref LL_ADC_CHANNEL_2 (2)
  2882. * @arg @ref LL_ADC_CHANNEL_3 (2)
  2883. * @arg @ref LL_ADC_CHANNEL_4 (1)
  2884. * @arg @ref LL_ADC_CHANNEL_5 (1)
  2885. * @arg @ref LL_ADC_CHANNEL_6 (2)
  2886. * @arg @ref LL_ADC_CHANNEL_7 (2)
  2887. * @arg @ref LL_ADC_CHANNEL_8 (2)
  2888. * @arg @ref LL_ADC_CHANNEL_9 (2)
  2889. * @arg @ref LL_ADC_CHANNEL_10 (2)
  2890. * @arg @ref LL_ADC_CHANNEL_11 (2)
  2891. * @arg @ref LL_ADC_CHANNEL_12 (2)
  2892. * @arg @ref LL_ADC_CHANNEL_13 (3)
  2893. * @arg @ref LL_ADC_CHANNEL_14 (3)
  2894. * @arg @ref LL_ADC_CHANNEL_15 (3)
  2895. * @arg @ref LL_ADC_CHANNEL_16 (3)
  2896. * @arg @ref LL_ADC_CHANNEL_17 (3)
  2897. * @arg @ref LL_ADC_CHANNEL_18 (3)
  2898. * @arg @ref LL_ADC_CHANNEL_19 (3)
  2899. * @arg @ref LL_ADC_CHANNEL_20 (3)
  2900. * @arg @ref LL_ADC_CHANNEL_21 (3)
  2901. * @arg @ref LL_ADC_CHANNEL_22 (1)
  2902. * @arg @ref LL_ADC_CHANNEL_23 (1)
  2903. * @arg @ref LL_ADC_CHANNEL_24 (1)
  2904. * @arg @ref LL_ADC_CHANNEL_25 (1)
  2905. * @arg @ref LL_ADC_CHANNEL_26 (3)
  2906. * @arg @ref LL_ADC_CHANNEL_27 (3)(4)
  2907. * @arg @ref LL_ADC_CHANNEL_28 (3)(4)
  2908. * @arg @ref LL_ADC_CHANNEL_29 (3)(4)
  2909. * @arg @ref LL_ADC_CHANNEL_30 (3)(4)
  2910. * @arg @ref LL_ADC_CHANNEL_31 (3)(4)
  2911. * @arg @ref LL_ADC_CHANNEL_VREFINT (3)(6)
  2912. * @arg @ref LL_ADC_CHANNEL_TEMPSENSOR (3)(6)
  2913. * @arg @ref LL_ADC_CHANNEL_VCOMP (3)(6)
  2914. * @arg @ref LL_ADC_CHANNEL_VOPAMP1 (3)(5)
  2915. * @arg @ref LL_ADC_CHANNEL_VOPAMP2 (3)(5)
  2916. * @arg @ref LL_ADC_CHANNEL_VOPAMP3 (3)(5)
  2917. *
  2918. * (1) On STM32L1, connection via routing interface (RI) specificity: fast channel (channel routed directly to ADC switch matrix).\n
  2919. * (2) On STM32L1, for devices with feature 'channels banks' available: Channel different in bank A and bank B.\n
  2920. * (3) On STM32L1, for devices with feature 'channels banks' available: Channel common to both bank A and bank B.\n
  2921. * (4) On STM32L1, parameter not available on all devices: only on STM32L1 Cat.4 and Cat.5.\n
  2922. * (5) On STM32L1, parameter not available on all devices: OPAMP1 and OPAMP2 available only on STM32L1 Cat.3, Cat.4 and Cat.5, OPAMP3 available only on STM32L1 Cat.4 and Cat.5.\n
  2923. * (6) For ADC channel read back from ADC register,
  2924. * comparison with internal channel parameter to be done
  2925. * using helper macro @ref __LL_ADC_CHANNEL_INTERNAL_TO_EXTERNAL().
  2926. */
  2927. __STATIC_INLINE uint32_t LL_ADC_REG_GetSequencerRanks(ADC_TypeDef *ADCx, uint32_t Rank)
  2928. {
  2929. register uint32_t *preg = __ADC_PTR_REG_OFFSET(ADCx->SQR1, __ADC_MASK_SHIFT(Rank, ADC_REG_SQRX_REGOFFSET_MASK));
  2930. return (uint32_t) (READ_BIT(*preg,
  2931. ADC_CHANNEL_ID_NUMBER_MASK << (Rank & ADC_REG_RANK_ID_SQRX_MASK))
  2932. >> (Rank & ADC_REG_RANK_ID_SQRX_MASK)
  2933. );
  2934. }
  2935. /**
  2936. * @brief Set ADC continuous conversion mode on ADC group regular.
  2937. * @note Description of ADC continuous conversion mode:
  2938. * - single mode: one conversion per trigger
  2939. * - continuous mode: after the first trigger, following
  2940. * conversions launched successively automatically.
  2941. * @note It is not possible to enable both ADC group regular
  2942. * continuous mode and sequencer discontinuous mode.
  2943. * @rmtoll CR2 CONT LL_ADC_REG_SetContinuousMode
  2944. * @param ADCx ADC instance
  2945. * @param Continuous This parameter can be one of the following values:
  2946. * @arg @ref LL_ADC_REG_CONV_SINGLE
  2947. * @arg @ref LL_ADC_REG_CONV_CONTINUOUS
  2948. * @retval None
  2949. */
  2950. __STATIC_INLINE void LL_ADC_REG_SetContinuousMode(ADC_TypeDef *ADCx, uint32_t Continuous)
  2951. {
  2952. MODIFY_REG(ADCx->CR2, ADC_CR2_CONT, Continuous);
  2953. }
  2954. /**
  2955. * @brief Get ADC continuous conversion mode on ADC group regular.
  2956. * @note Description of ADC continuous conversion mode:
  2957. * - single mode: one conversion per trigger
  2958. * - continuous mode: after the first trigger, following
  2959. * conversions launched successively automatically.
  2960. * @rmtoll CR2 CONT LL_ADC_REG_GetContinuousMode
  2961. * @param ADCx ADC instance
  2962. * @retval Returned value can be one of the following values:
  2963. * @arg @ref LL_ADC_REG_CONV_SINGLE
  2964. * @arg @ref LL_ADC_REG_CONV_CONTINUOUS
  2965. */
  2966. __STATIC_INLINE uint32_t LL_ADC_REG_GetContinuousMode(ADC_TypeDef *ADCx)
  2967. {
  2968. return (uint32_t)(READ_BIT(ADCx->CR2, ADC_CR2_CONT));
  2969. }
  2970. /**
  2971. * @brief Set ADC group regular conversion data transfer: no transfer or
  2972. * transfer by DMA, and DMA requests mode.
  2973. * @note If transfer by DMA selected, specifies the DMA requests
  2974. * mode:
  2975. * - Limited mode (One shot mode): DMA transfer requests are stopped
  2976. * when number of DMA data transfers (number of
  2977. * ADC conversions) is reached.
  2978. * This ADC mode is intended to be used with DMA mode non-circular.
  2979. * - Unlimited mode: DMA transfer requests are unlimited,
  2980. * whatever number of DMA data transfers (number of
  2981. * ADC conversions).
  2982. * This ADC mode is intended to be used with DMA mode circular.
  2983. * @note If ADC DMA requests mode is set to unlimited and DMA is set to
  2984. * mode non-circular:
  2985. * when DMA transfers size will be reached, DMA will stop transfers of
  2986. * ADC conversions data ADC will raise an overrun error
  2987. * (overrun flag and interruption if enabled).
  2988. * @note To configure DMA source address (peripheral address),
  2989. * use function @ref LL_ADC_DMA_GetRegAddr().
  2990. * @rmtoll CR2 DMA LL_ADC_REG_SetDMATransfer\n
  2991. * CR2 DDS LL_ADC_REG_SetDMATransfer
  2992. * @param ADCx ADC instance
  2993. * @param DMATransfer This parameter can be one of the following values:
  2994. * @arg @ref LL_ADC_REG_DMA_TRANSFER_NONE
  2995. * @arg @ref LL_ADC_REG_DMA_TRANSFER_LIMITED
  2996. * @arg @ref LL_ADC_REG_DMA_TRANSFER_UNLIMITED
  2997. * @retval None
  2998. */
  2999. __STATIC_INLINE void LL_ADC_REG_SetDMATransfer(ADC_TypeDef *ADCx, uint32_t DMATransfer)
  3000. {
  3001. MODIFY_REG(ADCx->CR2, ADC_CR2_DMA | ADC_CR2_DDS, DMATransfer);
  3002. }
  3003. /**
  3004. * @brief Get ADC group regular conversion data transfer: no transfer or
  3005. * transfer by DMA, and DMA requests mode.
  3006. * @note If transfer by DMA selected, specifies the DMA requests
  3007. * mode:
  3008. * - Limited mode (One shot mode): DMA transfer requests are stopped
  3009. * when number of DMA data transfers (number of
  3010. * ADC conversions) is reached.
  3011. * This ADC mode is intended to be used with DMA mode non-circular.
  3012. * - Unlimited mode: DMA transfer requests are unlimited,
  3013. * whatever number of DMA data transfers (number of
  3014. * ADC conversions).
  3015. * This ADC mode is intended to be used with DMA mode circular.
  3016. * @note If ADC DMA requests mode is set to unlimited and DMA is set to
  3017. * mode non-circular:
  3018. * when DMA transfers size will be reached, DMA will stop transfers of
  3019. * ADC conversions data ADC will raise an overrun error
  3020. * (overrun flag and interruption if enabled).
  3021. * @note To configure DMA source address (peripheral address),
  3022. * use function @ref LL_ADC_DMA_GetRegAddr().
  3023. * @rmtoll CR2 DMA LL_ADC_REG_GetDMATransfer\n
  3024. * CR2 DDS LL_ADC_REG_GetDMATransfer
  3025. * @param ADCx ADC instance
  3026. * @retval Returned value can be one of the following values:
  3027. * @arg @ref LL_ADC_REG_DMA_TRANSFER_NONE
  3028. * @arg @ref LL_ADC_REG_DMA_TRANSFER_LIMITED
  3029. * @arg @ref LL_ADC_REG_DMA_TRANSFER_UNLIMITED
  3030. */
  3031. __STATIC_INLINE uint32_t LL_ADC_REG_GetDMATransfer(ADC_TypeDef *ADCx)
  3032. {
  3033. return (uint32_t)(READ_BIT(ADCx->CR2, ADC_CR2_DMA | ADC_CR2_DDS));
  3034. }
  3035. /**
  3036. * @brief Specify which ADC flag between EOC (end of unitary conversion)
  3037. * or EOS (end of sequence conversions) is used to indicate
  3038. * the end of conversion.
  3039. * @note This feature is aimed to be set when using ADC with
  3040. * programming model by polling or interruption
  3041. * (programming model by DMA usually uses DMA interruptions
  3042. * to indicate end of conversion and data transfer).
  3043. * @note For ADC group injected, end of conversion (flag&IT) is raised
  3044. * only at the end of the sequence.
  3045. * @rmtoll CR2 EOCS LL_ADC_REG_SetFlagEndOfConversion
  3046. * @param ADCx ADC instance
  3047. * @param EocSelection This parameter can be one of the following values:
  3048. * @arg @ref LL_ADC_REG_FLAG_EOC_SEQUENCE_CONV
  3049. * @arg @ref LL_ADC_REG_FLAG_EOC_UNITARY_CONV
  3050. * @retval None
  3051. */
  3052. __STATIC_INLINE void LL_ADC_REG_SetFlagEndOfConversion(ADC_TypeDef *ADCx, uint32_t EocSelection)
  3053. {
  3054. MODIFY_REG(ADCx->CR2, ADC_CR2_EOCS, EocSelection);
  3055. }
  3056. /**
  3057. * @brief Get which ADC flag between EOC (end of unitary conversion)
  3058. * or EOS (end of sequence conversions) is used to indicate
  3059. * the end of conversion.
  3060. * @rmtoll CR2 EOCS LL_ADC_REG_GetFlagEndOfConversion
  3061. * @param ADCx ADC instance
  3062. * @retval Returned value can be one of the following values:
  3063. * @arg @ref LL_ADC_REG_FLAG_EOC_SEQUENCE_CONV
  3064. * @arg @ref LL_ADC_REG_FLAG_EOC_UNITARY_CONV
  3065. */
  3066. __STATIC_INLINE uint32_t LL_ADC_REG_GetFlagEndOfConversion(ADC_TypeDef *ADCx)
  3067. {
  3068. return (uint32_t)(READ_BIT(ADCx->CR2, ADC_CR2_EOCS));
  3069. }
  3070. /**
  3071. * @}
  3072. */
  3073. /** @defgroup ADC_LL_EF_Configuration_ADC_Group_Injected Configuration of ADC hierarchical scope: group injected
  3074. * @{
  3075. */
  3076. /**
  3077. * @brief Set ADC group injected conversion trigger source:
  3078. * internal (SW start) or from external IP (timer event,
  3079. * external interrupt line).
  3080. * @note On this STM32 serie, setting of external trigger edge is performed
  3081. * using function @ref LL_ADC_INJ_StartConversionExtTrig().
  3082. * @note Availability of parameters of trigger sources from timer
  3083. * depends on timers availability on the selected device.
  3084. * @rmtoll CR2 JEXTSEL LL_ADC_INJ_SetTriggerSource\n
  3085. * CR2 JEXTEN LL_ADC_INJ_SetTriggerSource
  3086. * @param ADCx ADC instance
  3087. * @param TriggerSource This parameter can be one of the following values:
  3088. * @arg @ref LL_ADC_INJ_TRIG_SOFTWARE
  3089. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM9_CH1
  3090. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM9_TRGO
  3091. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM2_TRGO
  3092. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM2_CH1
  3093. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM3_CH4
  3094. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM4_TRGO
  3095. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM4_CH1
  3096. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM4_CH2
  3097. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM4_CH3
  3098. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM10_CH1
  3099. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM7_TRGO
  3100. * @arg @ref LL_ADC_INJ_TRIG_EXT_EXTI_LINE15
  3101. * @retval None
  3102. */
  3103. __STATIC_INLINE void LL_ADC_INJ_SetTriggerSource(ADC_TypeDef *ADCx, uint32_t TriggerSource)
  3104. {
  3105. /* Note: On this STM32 serie, ADC group injected external trigger edge */
  3106. /* is used to perform a ADC conversion start. */
  3107. /* This function does not set external trigger edge. */
  3108. /* This feature is set using function */
  3109. /* @ref LL_ADC_INJ_StartConversionExtTrig(). */
  3110. MODIFY_REG(ADCx->CR2, ADC_CR2_JEXTSEL, (TriggerSource & ADC_CR2_JEXTSEL));
  3111. }
  3112. /**
  3113. * @brief Get ADC group injected conversion trigger source:
  3114. * internal (SW start) or from external IP (timer event,
  3115. * external interrupt line).
  3116. * @note To determine whether group injected trigger source is
  3117. * internal (SW start) or external, without detail
  3118. * of which peripheral is selected as external trigger,
  3119. * (equivalent to
  3120. * "if(LL_ADC_INJ_GetTriggerSource(ADC1) == LL_ADC_INJ_TRIG_SOFTWARE)")
  3121. * use function @ref LL_ADC_INJ_IsTriggerSourceSWStart.
  3122. * @note Availability of parameters of trigger sources from timer
  3123. * depends on timers availability on the selected device.
  3124. * @rmtoll CR2 JEXTSEL LL_ADC_INJ_GetTriggerSource\n
  3125. * CR2 JEXTEN LL_ADC_INJ_GetTriggerSource
  3126. * @param ADCx ADC instance
  3127. * @retval Returned value can be one of the following values:
  3128. * @arg @ref LL_ADC_INJ_TRIG_SOFTWARE
  3129. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM9_CH1
  3130. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM9_TRGO
  3131. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM2_TRGO
  3132. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM2_CH1
  3133. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM3_CH4
  3134. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM4_TRGO
  3135. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM4_CH1
  3136. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM4_CH2
  3137. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM4_CH3
  3138. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM10_CH1
  3139. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM7_TRGO
  3140. * @arg @ref LL_ADC_INJ_TRIG_EXT_EXTI_LINE15
  3141. */
  3142. __STATIC_INLINE uint32_t LL_ADC_INJ_GetTriggerSource(ADC_TypeDef *ADCx)
  3143. {
  3144. register uint32_t TriggerSource = READ_BIT(ADCx->CR2, ADC_CR2_JEXTSEL | ADC_CR2_JEXTEN);
  3145. /* Value for shift of {0; 4; 8; 12} depending on value of bitfield */
  3146. /* corresponding to ADC_CR2_JEXTEN {0; 1; 2; 3}. */
  3147. register uint32_t ShiftExten = ((TriggerSource & ADC_CR2_JEXTEN) >> (ADC_INJ_TRIG_EXTEN_BITOFFSET_POS - 2U));
  3148. /* Set bitfield corresponding to ADC_CR2_JEXTEN and ADC_CR2_JEXTSEL */
  3149. /* to match with triggers literals definition. */
  3150. return ((TriggerSource
  3151. & (ADC_INJ_TRIG_SOURCE_MASK << ShiftExten) & ADC_CR2_JEXTSEL)
  3152. | ((ADC_INJ_TRIG_EDGE_MASK << ShiftExten) & ADC_CR2_JEXTEN)
  3153. );
  3154. }
  3155. /**
  3156. * @brief Get ADC group injected conversion trigger source internal (SW start)
  3157. or external
  3158. * @note In case of group injected trigger source set to external trigger,
  3159. * to determine which peripheral is selected as external trigger,
  3160. * use function @ref LL_ADC_INJ_GetTriggerSource.
  3161. * @rmtoll CR2 JEXTEN LL_ADC_INJ_IsTriggerSourceSWStart
  3162. * @param ADCx ADC instance
  3163. * @retval Value "0" if trigger source external trigger
  3164. * Value "1" if trigger source SW start.
  3165. */
  3166. __STATIC_INLINE uint32_t LL_ADC_INJ_IsTriggerSourceSWStart(ADC_TypeDef *ADCx)
  3167. {
  3168. return (READ_BIT(ADCx->CR2, ADC_CR2_JEXTEN) == (LL_ADC_INJ_TRIG_SOFTWARE & ADC_CR2_JEXTEN));
  3169. }
  3170. /**
  3171. * @brief Get ADC group injected conversion trigger polarity.
  3172. * Applicable only for trigger source set to external trigger.
  3173. * @rmtoll CR2 JEXTEN LL_ADC_INJ_GetTriggerEdge
  3174. * @param ADCx ADC instance
  3175. * @retval Returned value can be one of the following values:
  3176. * @arg @ref LL_ADC_INJ_TRIG_EXT_RISING
  3177. * @arg @ref LL_ADC_INJ_TRIG_EXT_FALLING
  3178. * @arg @ref LL_ADC_INJ_TRIG_EXT_RISINGFALLING
  3179. */
  3180. __STATIC_INLINE uint32_t LL_ADC_INJ_GetTriggerEdge(ADC_TypeDef *ADCx)
  3181. {
  3182. return (uint32_t)(READ_BIT(ADCx->CR2, ADC_CR2_JEXTEN));
  3183. }
  3184. /**
  3185. * @brief Set ADC group injected sequencer length and scan direction.
  3186. * @note This function performs configuration of:
  3187. * - Sequence length: Number of ranks in the scan sequence.
  3188. * - Sequence direction: Unless specified in parameters, sequencer
  3189. * scan direction is forward (from rank 1 to rank n).
  3190. * @note On this STM32 serie, group injected sequencer configuration
  3191. * is conditioned to ADC instance sequencer mode.
  3192. * If ADC instance sequencer mode is disabled, sequencers of
  3193. * all groups (group regular, group injected) can be configured
  3194. * but their execution is disabled (limited to rank 1).
  3195. * Refer to function @ref LL_ADC_SetSequencersScanMode().
  3196. * @note Sequencer disabled is equivalent to sequencer of 1 rank:
  3197. * ADC conversion on only 1 channel.
  3198. * @rmtoll JSQR JL LL_ADC_INJ_SetSequencerLength
  3199. * @param ADCx ADC instance
  3200. * @param SequencerNbRanks This parameter can be one of the following values:
  3201. * @arg @ref LL_ADC_INJ_SEQ_SCAN_DISABLE
  3202. * @arg @ref LL_ADC_INJ_SEQ_SCAN_ENABLE_2RANKS
  3203. * @arg @ref LL_ADC_INJ_SEQ_SCAN_ENABLE_3RANKS
  3204. * @arg @ref LL_ADC_INJ_SEQ_SCAN_ENABLE_4RANKS
  3205. * @retval None
  3206. */
  3207. __STATIC_INLINE void LL_ADC_INJ_SetSequencerLength(ADC_TypeDef *ADCx, uint32_t SequencerNbRanks)
  3208. {
  3209. MODIFY_REG(ADCx->JSQR, ADC_JSQR_JL, SequencerNbRanks);
  3210. }
  3211. /**
  3212. * @brief Get ADC group injected sequencer length and scan direction.
  3213. * @note This function retrieves:
  3214. * - Sequence length: Number of ranks in the scan sequence.
  3215. * - Sequence direction: Unless specified in parameters, sequencer
  3216. * scan direction is forward (from rank 1 to rank n).
  3217. * @note On this STM32 serie, group injected sequencer configuration
  3218. * is conditioned to ADC instance sequencer mode.
  3219. * If ADC instance sequencer mode is disabled, sequencers of
  3220. * all groups (group regular, group injected) can be configured
  3221. * but their execution is disabled (limited to rank 1).
  3222. * Refer to function @ref LL_ADC_SetSequencersScanMode().
  3223. * @note Sequencer disabled is equivalent to sequencer of 1 rank:
  3224. * ADC conversion on only 1 channel.
  3225. * @rmtoll JSQR JL LL_ADC_INJ_GetSequencerLength
  3226. * @param ADCx ADC instance
  3227. * @retval Returned value can be one of the following values:
  3228. * @arg @ref LL_ADC_INJ_SEQ_SCAN_DISABLE
  3229. * @arg @ref LL_ADC_INJ_SEQ_SCAN_ENABLE_2RANKS
  3230. * @arg @ref LL_ADC_INJ_SEQ_SCAN_ENABLE_3RANKS
  3231. * @arg @ref LL_ADC_INJ_SEQ_SCAN_ENABLE_4RANKS
  3232. */
  3233. __STATIC_INLINE uint32_t LL_ADC_INJ_GetSequencerLength(ADC_TypeDef *ADCx)
  3234. {
  3235. return (uint32_t)(READ_BIT(ADCx->JSQR, ADC_JSQR_JL));
  3236. }
  3237. /**
  3238. * @brief Set ADC group injected sequencer discontinuous mode:
  3239. * sequence subdivided and scan conversions interrupted every selected
  3240. * number of ranks.
  3241. * @note It is not possible to enable both ADC group injected
  3242. * auto-injected mode and sequencer discontinuous mode.
  3243. * @rmtoll CR1 DISCEN LL_ADC_INJ_SetSequencerDiscont
  3244. * @param ADCx ADC instance
  3245. * @param SeqDiscont This parameter can be one of the following values:
  3246. * @arg @ref LL_ADC_INJ_SEQ_DISCONT_DISABLE
  3247. * @arg @ref LL_ADC_INJ_SEQ_DISCONT_1RANK
  3248. * @retval None
  3249. */
  3250. __STATIC_INLINE void LL_ADC_INJ_SetSequencerDiscont(ADC_TypeDef *ADCx, uint32_t SeqDiscont)
  3251. {
  3252. MODIFY_REG(ADCx->CR1, ADC_CR1_JDISCEN, SeqDiscont);
  3253. }
  3254. /**
  3255. * @brief Get ADC group injected sequencer discontinuous mode:
  3256. * sequence subdivided and scan conversions interrupted every selected
  3257. * number of ranks.
  3258. * @rmtoll CR1 DISCEN LL_ADC_REG_GetSequencerDiscont
  3259. * @param ADCx ADC instance
  3260. * @retval Returned value can be one of the following values:
  3261. * @arg @ref LL_ADC_INJ_SEQ_DISCONT_DISABLE
  3262. * @arg @ref LL_ADC_INJ_SEQ_DISCONT_1RANK
  3263. */
  3264. __STATIC_INLINE uint32_t LL_ADC_INJ_GetSequencerDiscont(ADC_TypeDef *ADCx)
  3265. {
  3266. return (uint32_t)(READ_BIT(ADCx->CR1, ADC_CR1_JDISCEN));
  3267. }
  3268. /**
  3269. * @brief Set ADC group injected sequence: channel on the selected
  3270. * sequence rank.
  3271. * @note Depending on devices and packages, some channels may not be available.
  3272. * Refer to device datasheet for channels availability.
  3273. * @note On this STM32 serie, to measure internal channels (VrefInt,
  3274. * TempSensor, ...), measurement paths to internal channels must be
  3275. * enabled separately.
  3276. * This can be done using function @ref LL_ADC_SetCommonPathInternalCh().
  3277. * @rmtoll JSQR JSQ1 LL_ADC_INJ_SetSequencerRanks\n
  3278. * JSQR JSQ2 LL_ADC_INJ_SetSequencerRanks\n
  3279. * JSQR JSQ3 LL_ADC_INJ_SetSequencerRanks\n
  3280. * JSQR JSQ4 LL_ADC_INJ_SetSequencerRanks
  3281. * @param ADCx ADC instance
  3282. * @param Rank This parameter can be one of the following values:
  3283. * @arg @ref LL_ADC_INJ_RANK_1
  3284. * @arg @ref LL_ADC_INJ_RANK_2
  3285. * @arg @ref LL_ADC_INJ_RANK_3
  3286. * @arg @ref LL_ADC_INJ_RANK_4
  3287. * @param Channel This parameter can be one of the following values:
  3288. * @arg @ref LL_ADC_CHANNEL_0 (2)
  3289. * @arg @ref LL_ADC_CHANNEL_1 (2)
  3290. * @arg @ref LL_ADC_CHANNEL_2 (2)
  3291. * @arg @ref LL_ADC_CHANNEL_3 (2)
  3292. * @arg @ref LL_ADC_CHANNEL_4 (1)
  3293. * @arg @ref LL_ADC_CHANNEL_5 (1)
  3294. * @arg @ref LL_ADC_CHANNEL_6 (2)
  3295. * @arg @ref LL_ADC_CHANNEL_7 (2)
  3296. * @arg @ref LL_ADC_CHANNEL_8 (2)
  3297. * @arg @ref LL_ADC_CHANNEL_9 (2)
  3298. * @arg @ref LL_ADC_CHANNEL_10 (2)
  3299. * @arg @ref LL_ADC_CHANNEL_11 (2)
  3300. * @arg @ref LL_ADC_CHANNEL_12 (2)
  3301. * @arg @ref LL_ADC_CHANNEL_13 (3)
  3302. * @arg @ref LL_ADC_CHANNEL_14 (3)
  3303. * @arg @ref LL_ADC_CHANNEL_15 (3)
  3304. * @arg @ref LL_ADC_CHANNEL_16 (3)
  3305. * @arg @ref LL_ADC_CHANNEL_17 (3)
  3306. * @arg @ref LL_ADC_CHANNEL_18 (3)
  3307. * @arg @ref LL_ADC_CHANNEL_19 (3)
  3308. * @arg @ref LL_ADC_CHANNEL_20 (3)
  3309. * @arg @ref LL_ADC_CHANNEL_21 (3)
  3310. * @arg @ref LL_ADC_CHANNEL_22 (1)
  3311. * @arg @ref LL_ADC_CHANNEL_23 (1)
  3312. * @arg @ref LL_ADC_CHANNEL_24 (1)
  3313. * @arg @ref LL_ADC_CHANNEL_25 (1)
  3314. * @arg @ref LL_ADC_CHANNEL_26 (3)
  3315. * @arg @ref LL_ADC_CHANNEL_27 (3)(4)
  3316. * @arg @ref LL_ADC_CHANNEL_28 (3)(4)
  3317. * @arg @ref LL_ADC_CHANNEL_29 (3)(4)
  3318. * @arg @ref LL_ADC_CHANNEL_30 (3)(4)
  3319. * @arg @ref LL_ADC_CHANNEL_31 (3)(4)
  3320. * @arg @ref LL_ADC_CHANNEL_VREFINT (3)
  3321. * @arg @ref LL_ADC_CHANNEL_TEMPSENSOR (3)
  3322. * @arg @ref LL_ADC_CHANNEL_VCOMP (3)
  3323. * @arg @ref LL_ADC_CHANNEL_VOPAMP1 (3)(5)
  3324. * @arg @ref LL_ADC_CHANNEL_VOPAMP2 (3)(5)
  3325. * @arg @ref LL_ADC_CHANNEL_VOPAMP3 (3)(5)
  3326. *
  3327. * (1) On STM32L1, connection via routing interface (RI) specificity: fast channel (channel routed directly to ADC switch matrix).\n
  3328. * (2) On STM32L1, for devices with feature 'channels banks' available: Channel different in bank A and bank B.\n
  3329. * (3) On STM32L1, for devices with feature 'channels banks' available: Channel common to both bank A and bank B.\n
  3330. * (4) On STM32L1, parameter not available on all devices: only on STM32L1 Cat.4 and Cat.5.\n
  3331. * (5) On STM32L1, parameter not available on all devices: OPAMP1 and OPAMP2 available only on STM32L1 Cat.3, Cat.4 and Cat.5, OPAMP3 available only on STM32L1 Cat.4 and Cat.5
  3332. * @retval None
  3333. */
  3334. __STATIC_INLINE void LL_ADC_INJ_SetSequencerRanks(ADC_TypeDef *ADCx, uint32_t Rank, uint32_t Channel)
  3335. {
  3336. /* Set bits with content of parameter "Channel" with bits position */
  3337. /* in register depending on parameter "Rank". */
  3338. /* Parameters "Rank" and "Channel" are used with masks because containing */
  3339. /* other bits reserved for other purpose. */
  3340. MODIFY_REG(ADCx->JSQR,
  3341. ADC_CHANNEL_ID_NUMBER_MASK << (Rank & ADC_INJ_RANK_ID_JSQR_MASK),
  3342. (Channel & ADC_CHANNEL_ID_NUMBER_MASK) << (Rank & ADC_INJ_RANK_ID_JSQR_MASK));
  3343. }
  3344. /**
  3345. * @brief Get ADC group injected sequence: channel on the selected
  3346. * sequence rank.
  3347. * @note Depending on devices and packages, some channels may not be available.
  3348. * Refer to device datasheet for channels availability.
  3349. * @note Usage of the returned channel number:
  3350. * - To reinject this channel into another function LL_ADC_xxx:
  3351. * the returned channel number is only partly formatted on definition
  3352. * of literals LL_ADC_CHANNEL_x. Therefore, it has to be compared
  3353. * with parts of literals LL_ADC_CHANNEL_x or using
  3354. * helper macro @ref __LL_ADC_CHANNEL_TO_DECIMAL_NB().
  3355. * Then the selected literal LL_ADC_CHANNEL_x can be used
  3356. * as parameter for another function.
  3357. * - To get the channel number in decimal format:
  3358. * process the returned value with the helper macro
  3359. * @ref __LL_ADC_CHANNEL_TO_DECIMAL_NB().
  3360. * @rmtoll JSQR JSQ1 LL_ADC_INJ_SetSequencerRanks\n
  3361. * JSQR JSQ2 LL_ADC_INJ_SetSequencerRanks\n
  3362. * JSQR JSQ3 LL_ADC_INJ_SetSequencerRanks\n
  3363. * JSQR JSQ4 LL_ADC_INJ_SetSequencerRanks
  3364. * @param ADCx ADC instance
  3365. * @param Rank This parameter can be one of the following values:
  3366. * @arg @ref LL_ADC_INJ_RANK_1
  3367. * @arg @ref LL_ADC_INJ_RANK_2
  3368. * @arg @ref LL_ADC_INJ_RANK_3
  3369. * @arg @ref LL_ADC_INJ_RANK_4
  3370. * @retval Returned value can be one of the following values:
  3371. * @arg @ref LL_ADC_CHANNEL_0 (2)
  3372. * @arg @ref LL_ADC_CHANNEL_1 (2)
  3373. * @arg @ref LL_ADC_CHANNEL_2 (2)
  3374. * @arg @ref LL_ADC_CHANNEL_3 (2)
  3375. * @arg @ref LL_ADC_CHANNEL_4 (1)
  3376. * @arg @ref LL_ADC_CHANNEL_5 (1)
  3377. * @arg @ref LL_ADC_CHANNEL_6 (2)
  3378. * @arg @ref LL_ADC_CHANNEL_7 (2)
  3379. * @arg @ref LL_ADC_CHANNEL_8 (2)
  3380. * @arg @ref LL_ADC_CHANNEL_9 (2)
  3381. * @arg @ref LL_ADC_CHANNEL_10 (2)
  3382. * @arg @ref LL_ADC_CHANNEL_11 (2)
  3383. * @arg @ref LL_ADC_CHANNEL_12 (2)
  3384. * @arg @ref LL_ADC_CHANNEL_13 (3)
  3385. * @arg @ref LL_ADC_CHANNEL_14 (3)
  3386. * @arg @ref LL_ADC_CHANNEL_15 (3)
  3387. * @arg @ref LL_ADC_CHANNEL_16 (3)
  3388. * @arg @ref LL_ADC_CHANNEL_17 (3)
  3389. * @arg @ref LL_ADC_CHANNEL_18 (3)
  3390. * @arg @ref LL_ADC_CHANNEL_19 (3)
  3391. * @arg @ref LL_ADC_CHANNEL_20 (3)
  3392. * @arg @ref LL_ADC_CHANNEL_21 (3)
  3393. * @arg @ref LL_ADC_CHANNEL_22 (1)
  3394. * @arg @ref LL_ADC_CHANNEL_23 (1)
  3395. * @arg @ref LL_ADC_CHANNEL_24 (1)
  3396. * @arg @ref LL_ADC_CHANNEL_25 (1)
  3397. * @arg @ref LL_ADC_CHANNEL_26 (3)
  3398. * @arg @ref LL_ADC_CHANNEL_27 (3)(4)
  3399. * @arg @ref LL_ADC_CHANNEL_28 (3)(4)
  3400. * @arg @ref LL_ADC_CHANNEL_29 (3)(4)
  3401. * @arg @ref LL_ADC_CHANNEL_30 (3)(4)
  3402. * @arg @ref LL_ADC_CHANNEL_31 (3)(4)
  3403. * @arg @ref LL_ADC_CHANNEL_VREFINT (3)(6)
  3404. * @arg @ref LL_ADC_CHANNEL_TEMPSENSOR (3)(6)
  3405. * @arg @ref LL_ADC_CHANNEL_VCOMP (3)(6)
  3406. * @arg @ref LL_ADC_CHANNEL_VOPAMP1 (3)(5)
  3407. * @arg @ref LL_ADC_CHANNEL_VOPAMP2 (3)(5)
  3408. * @arg @ref LL_ADC_CHANNEL_VOPAMP3 (3)(5)
  3409. *
  3410. * (1) On STM32L1, connection via routing interface (RI) specificity: fast channel (channel routed directly to ADC switch matrix).\n
  3411. * (2) On STM32L1, for devices with feature 'channels banks' available: Channel different in bank A and bank B.\n
  3412. * (3) On STM32L1, for devices with feature 'channels banks' available: Channel common to both bank A and bank B.\n
  3413. * (4) On STM32L1, parameter not available on all devices: only on STM32L1 Cat.4 and Cat.5.\n
  3414. * (5) On STM32L1, parameter not available on all devices: OPAMP1 and OPAMP2 available only on STM32L1 Cat.3, Cat.4 and Cat.5, OPAMP3 available only on STM32L1 Cat.4 and Cat.5.\n
  3415. * (6) For ADC channel read back from ADC register,
  3416. * comparison with internal channel parameter to be done
  3417. * using helper macro @ref __LL_ADC_CHANNEL_INTERNAL_TO_EXTERNAL().
  3418. */
  3419. __STATIC_INLINE uint32_t LL_ADC_INJ_GetSequencerRanks(ADC_TypeDef *ADCx, uint32_t Rank)
  3420. {
  3421. return (uint32_t)(READ_BIT(ADCx->JSQR,
  3422. ADC_CHANNEL_ID_NUMBER_MASK << (Rank & ADC_INJ_RANK_ID_JSQR_MASK))
  3423. >> (Rank & ADC_INJ_RANK_ID_JSQR_MASK)
  3424. );
  3425. }
  3426. /**
  3427. * @brief Set ADC group injected conversion trigger:
  3428. * independent or from ADC group regular.
  3429. * @note This mode can be used to extend number of data registers
  3430. * updated after one ADC conversion trigger and with data
  3431. * permanently kept (not erased by successive conversions of scan of
  3432. * ADC sequencer ranks), up to 5 data registers:
  3433. * 1 data register on ADC group regular, 4 data registers
  3434. * on ADC group injected.
  3435. * @note If ADC group injected injected trigger source is set to an
  3436. * external trigger, this feature must be must be set to
  3437. * independent trigger.
  3438. * ADC group injected automatic trigger is compliant only with
  3439. * group injected trigger source set to SW start, without any
  3440. * further action on ADC group injected conversion start or stop:
  3441. * in this case, ADC group injected is controlled only
  3442. * from ADC group regular.
  3443. * @note It is not possible to enable both ADC group injected
  3444. * auto-injected mode and sequencer discontinuous mode.
  3445. * @rmtoll CR1 JAUTO LL_ADC_INJ_SetTrigAuto
  3446. * @param ADCx ADC instance
  3447. * @param TrigAuto This parameter can be one of the following values:
  3448. * @arg @ref LL_ADC_INJ_TRIG_INDEPENDENT
  3449. * @arg @ref LL_ADC_INJ_TRIG_FROM_GRP_REGULAR
  3450. * @retval None
  3451. */
  3452. __STATIC_INLINE void LL_ADC_INJ_SetTrigAuto(ADC_TypeDef *ADCx, uint32_t TrigAuto)
  3453. {
  3454. MODIFY_REG(ADCx->CR1, ADC_CR1_JAUTO, TrigAuto);
  3455. }
  3456. /**
  3457. * @brief Get ADC group injected conversion trigger:
  3458. * independent or from ADC group regular.
  3459. * @rmtoll CR1 JAUTO LL_ADC_INJ_GetTrigAuto
  3460. * @param ADCx ADC instance
  3461. * @retval Returned value can be one of the following values:
  3462. * @arg @ref LL_ADC_INJ_TRIG_INDEPENDENT
  3463. * @arg @ref LL_ADC_INJ_TRIG_FROM_GRP_REGULAR
  3464. */
  3465. __STATIC_INLINE uint32_t LL_ADC_INJ_GetTrigAuto(ADC_TypeDef *ADCx)
  3466. {
  3467. return (uint32_t)(READ_BIT(ADCx->CR1, ADC_CR1_JAUTO));
  3468. }
  3469. /**
  3470. * @brief Set ADC group injected offset.
  3471. * @note It sets:
  3472. * - ADC group injected rank to which the offset programmed
  3473. * will be applied
  3474. * - Offset level (offset to be subtracted from the raw
  3475. * converted data).
  3476. * Caution: Offset format is dependent to ADC resolution:
  3477. * offset has to be left-aligned on bit 11, the LSB (right bits)
  3478. * are set to 0.
  3479. * @note Offset cannot be enabled or disabled.
  3480. * To emulate offset disabled, set an offset value equal to 0.
  3481. * @rmtoll JOFR1 JOFFSET1 LL_ADC_INJ_SetOffset\n
  3482. * JOFR2 JOFFSET2 LL_ADC_INJ_SetOffset\n
  3483. * JOFR3 JOFFSET3 LL_ADC_INJ_SetOffset\n
  3484. * JOFR4 JOFFSET4 LL_ADC_INJ_SetOffset
  3485. * @param ADCx ADC instance
  3486. * @param Rank This parameter can be one of the following values:
  3487. * @arg @ref LL_ADC_INJ_RANK_1
  3488. * @arg @ref LL_ADC_INJ_RANK_2
  3489. * @arg @ref LL_ADC_INJ_RANK_3
  3490. * @arg @ref LL_ADC_INJ_RANK_4
  3491. * @param OffsetLevel Value between Min_Data=0x000 and Max_Data=0xFFF
  3492. * @retval None
  3493. */
  3494. __STATIC_INLINE void LL_ADC_INJ_SetOffset(ADC_TypeDef *ADCx, uint32_t Rank, uint32_t OffsetLevel)
  3495. {
  3496. register uint32_t *preg = __ADC_PTR_REG_OFFSET(ADCx->JOFR1, __ADC_MASK_SHIFT(Rank, ADC_INJ_JOFRX_REGOFFSET_MASK));
  3497. MODIFY_REG(*preg,
  3498. ADC_JOFR1_JOFFSET1,
  3499. OffsetLevel);
  3500. }
  3501. /**
  3502. * @brief Get ADC group injected offset.
  3503. * @note It gives offset level (offset to be subtracted from the raw converted data).
  3504. * Caution: Offset format is dependent to ADC resolution:
  3505. * offset has to be left-aligned on bit 11, the LSB (right bits)
  3506. * are set to 0.
  3507. * @rmtoll JOFR1 JOFFSET1 LL_ADC_INJ_GetOffset\n
  3508. * JOFR2 JOFFSET2 LL_ADC_INJ_GetOffset\n
  3509. * JOFR3 JOFFSET3 LL_ADC_INJ_GetOffset\n
  3510. * JOFR4 JOFFSET4 LL_ADC_INJ_GetOffset
  3511. * @param ADCx ADC instance
  3512. * @param Rank This parameter can be one of the following values:
  3513. * @arg @ref LL_ADC_INJ_RANK_1
  3514. * @arg @ref LL_ADC_INJ_RANK_2
  3515. * @arg @ref LL_ADC_INJ_RANK_3
  3516. * @arg @ref LL_ADC_INJ_RANK_4
  3517. * @retval Value between Min_Data=0x000 and Max_Data=0xFFF
  3518. */
  3519. __STATIC_INLINE uint32_t LL_ADC_INJ_GetOffset(ADC_TypeDef *ADCx, uint32_t Rank)
  3520. {
  3521. register uint32_t *preg = __ADC_PTR_REG_OFFSET(ADCx->JOFR1, __ADC_MASK_SHIFT(Rank, ADC_INJ_JOFRX_REGOFFSET_MASK));
  3522. return (uint32_t)(READ_BIT(*preg,
  3523. ADC_JOFR1_JOFFSET1)
  3524. );
  3525. }
  3526. /**
  3527. * @}
  3528. */
  3529. /** @defgroup ADC_LL_EF_Configuration_Channels Configuration of ADC hierarchical scope: channels
  3530. * @{
  3531. */
  3532. /**
  3533. * @brief Set sampling time of the selected ADC channel
  3534. * Unit: ADC clock cycles.
  3535. * @note On this device, sampling time is on channel scope: independently
  3536. * of channel mapped on ADC group regular or injected.
  3537. * @note In case of internal channel (VrefInt, TempSensor, ...) to be
  3538. * converted:
  3539. * sampling time constraints must be respected (sampling time can be
  3540. * adjusted in function of ADC clock frequency and sampling time
  3541. * setting).
  3542. * Refer to device datasheet for timings values (parameters TS_vrefint,
  3543. * TS_temp, ...).
  3544. * @note Conversion time is the addition of sampling time and processing time.
  3545. * Refer to reference manual for ADC processing time of
  3546. * this STM32 serie.
  3547. * @note In case of ADC conversion of internal channel (VrefInt,
  3548. * temperature sensor, ...), a sampling time minimum value
  3549. * is required.
  3550. * Refer to device datasheet.
  3551. * @rmtoll SMPR0 SMP31 LL_ADC_SetChannelSamplingTime\n
  3552. * SMPR0 SMP30 LL_ADC_SetChannelSamplingTime\n
  3553. * SMPR1 SMP29 LL_ADC_SetChannelSamplingTime\n
  3554. * SMPR1 SMP28 LL_ADC_SetChannelSamplingTime\n
  3555. * SMPR1 SMP27 LL_ADC_SetChannelSamplingTime\n
  3556. * SMPR1 SMP26 LL_ADC_SetChannelSamplingTime\n
  3557. * SMPR1 SMP25 LL_ADC_SetChannelSamplingTime\n
  3558. * SMPR1 SMP24 LL_ADC_SetChannelSamplingTime\n
  3559. * SMPR1 SMP23 LL_ADC_SetChannelSamplingTime\n
  3560. * SMPR1 SMP22 LL_ADC_SetChannelSamplingTime\n
  3561. * SMPR1 SMP21 LL_ADC_SetChannelSamplingTime\n
  3562. * SMPR1 SMP20 LL_ADC_SetChannelSamplingTime\n
  3563. * SMPR2 SMP19 LL_ADC_SetChannelSamplingTime\n
  3564. * SMPR2 SMP18 LL_ADC_SetChannelSamplingTime\n
  3565. * SMPR2 SMP17 LL_ADC_SetChannelSamplingTime\n
  3566. * SMPR2 SMP16 LL_ADC_SetChannelSamplingTime\n
  3567. * SMPR2 SMP15 LL_ADC_SetChannelSamplingTime\n
  3568. * SMPR2 SMP14 LL_ADC_SetChannelSamplingTime\n
  3569. * SMPR2 SMP13 LL_ADC_SetChannelSamplingTime\n
  3570. * SMPR2 SMP12 LL_ADC_SetChannelSamplingTime\n
  3571. * SMPR2 SMP11 LL_ADC_SetChannelSamplingTime\n
  3572. * SMPR2 SMP10 LL_ADC_SetChannelSamplingTime\n
  3573. * SMPR3 SMP9 LL_ADC_SetChannelSamplingTime\n
  3574. * SMPR3 SMP8 LL_ADC_SetChannelSamplingTime\n
  3575. * SMPR3 SMP7 LL_ADC_SetChannelSamplingTime\n
  3576. * SMPR3 SMP6 LL_ADC_SetChannelSamplingTime\n
  3577. * SMPR3 SMP5 LL_ADC_SetChannelSamplingTime\n
  3578. * SMPR3 SMP4 LL_ADC_SetChannelSamplingTime\n
  3579. * SMPR3 SMP3 LL_ADC_SetChannelSamplingTime\n
  3580. * SMPR3 SMP2 LL_ADC_SetChannelSamplingTime\n
  3581. * SMPR3 SMP1 LL_ADC_SetChannelSamplingTime\n
  3582. * SMPR3 SMP0 LL_ADC_SetChannelSamplingTime
  3583. * @param ADCx ADC instance
  3584. * @param Channel This parameter can be one of the following values:
  3585. * @arg @ref LL_ADC_CHANNEL_0 (2)
  3586. * @arg @ref LL_ADC_CHANNEL_1 (2)
  3587. * @arg @ref LL_ADC_CHANNEL_2 (2)
  3588. * @arg @ref LL_ADC_CHANNEL_3 (2)
  3589. * @arg @ref LL_ADC_CHANNEL_4 (1)
  3590. * @arg @ref LL_ADC_CHANNEL_5 (1)
  3591. * @arg @ref LL_ADC_CHANNEL_6 (2)
  3592. * @arg @ref LL_ADC_CHANNEL_7 (2)
  3593. * @arg @ref LL_ADC_CHANNEL_8 (2)
  3594. * @arg @ref LL_ADC_CHANNEL_9 (2)
  3595. * @arg @ref LL_ADC_CHANNEL_10 (2)
  3596. * @arg @ref LL_ADC_CHANNEL_11 (2)
  3597. * @arg @ref LL_ADC_CHANNEL_12 (2)
  3598. * @arg @ref LL_ADC_CHANNEL_13 (3)
  3599. * @arg @ref LL_ADC_CHANNEL_14 (3)
  3600. * @arg @ref LL_ADC_CHANNEL_15 (3)
  3601. * @arg @ref LL_ADC_CHANNEL_16 (3)
  3602. * @arg @ref LL_ADC_CHANNEL_17 (3)
  3603. * @arg @ref LL_ADC_CHANNEL_18 (3)
  3604. * @arg @ref LL_ADC_CHANNEL_19 (3)
  3605. * @arg @ref LL_ADC_CHANNEL_20 (3)
  3606. * @arg @ref LL_ADC_CHANNEL_21 (3)
  3607. * @arg @ref LL_ADC_CHANNEL_22 (1)
  3608. * @arg @ref LL_ADC_CHANNEL_23 (1)
  3609. * @arg @ref LL_ADC_CHANNEL_24 (1)
  3610. * @arg @ref LL_ADC_CHANNEL_25 (1)
  3611. * @arg @ref LL_ADC_CHANNEL_26 (3)
  3612. * @arg @ref LL_ADC_CHANNEL_27 (3)(4)
  3613. * @arg @ref LL_ADC_CHANNEL_28 (3)(4)
  3614. * @arg @ref LL_ADC_CHANNEL_29 (3)(4)
  3615. * @arg @ref LL_ADC_CHANNEL_30 (3)(4)
  3616. * @arg @ref LL_ADC_CHANNEL_31 (3)(4)
  3617. * @arg @ref LL_ADC_CHANNEL_VREFINT (3)
  3618. * @arg @ref LL_ADC_CHANNEL_TEMPSENSOR (3)
  3619. * @arg @ref LL_ADC_CHANNEL_VCOMP (3)
  3620. * @arg @ref LL_ADC_CHANNEL_VOPAMP1 (3)(5)
  3621. * @arg @ref LL_ADC_CHANNEL_VOPAMP2 (3)(5)
  3622. * @arg @ref LL_ADC_CHANNEL_VOPAMP3 (3)(5)
  3623. *
  3624. * (1) On STM32L1, connection via routing interface (RI) specificity: fast channel (channel routed directly to ADC switch matrix).\n
  3625. * (2) On STM32L1, for devices with feature 'channels banks' available: Channel different in bank A and bank B.\n
  3626. * (3) On STM32L1, for devices with feature 'channels banks' available: Channel common to both bank A and bank B.\n
  3627. * (4) On STM32L1, parameter not available on all devices: only on STM32L1 Cat.4 and Cat.5.\n
  3628. * (5) On STM32L1, parameter not available on all devices: OPAMP1 and OPAMP2 available only on STM32L1 Cat.3, Cat.4 and Cat.5, OPAMP3 available only on STM32L1 Cat.4 and Cat.5
  3629. * @param SamplingTime This parameter can be one of the following values:
  3630. * @arg @ref LL_ADC_SAMPLINGTIME_4CYCLES
  3631. * @arg @ref LL_ADC_SAMPLINGTIME_9CYCLES
  3632. * @arg @ref LL_ADC_SAMPLINGTIME_16CYCLES
  3633. * @arg @ref LL_ADC_SAMPLINGTIME_24CYCLES
  3634. * @arg @ref LL_ADC_SAMPLINGTIME_48CYCLES
  3635. * @arg @ref LL_ADC_SAMPLINGTIME_96CYCLES
  3636. * @arg @ref LL_ADC_SAMPLINGTIME_192CYCLES
  3637. * @arg @ref LL_ADC_SAMPLINGTIME_384CYCLES
  3638. * @retval None
  3639. */
  3640. __STATIC_INLINE void LL_ADC_SetChannelSamplingTime(ADC_TypeDef *ADCx, uint32_t Channel, uint32_t SamplingTime)
  3641. {
  3642. /* Set bits with content of parameter "SamplingTime" with bits position */
  3643. /* in register and register position depending on parameter "Channel". */
  3644. /* Parameter "Channel" is used with masks because containing */
  3645. /* other bits reserved for other purpose. */
  3646. register uint32_t *preg = __ADC_PTR_REG_OFFSET(ADCx->SMPR1, __ADC_MASK_SHIFT(Channel, ADC_CHANNEL_SMPRX_REGOFFSET_MASK));
  3647. MODIFY_REG(*preg,
  3648. ADC_SMPR3_SMP0 << __ADC_MASK_SHIFT(Channel, ADC_CHANNEL_SMPx_BITOFFSET_MASK),
  3649. SamplingTime << __ADC_MASK_SHIFT(Channel, ADC_CHANNEL_SMPx_BITOFFSET_MASK));
  3650. }
  3651. /**
  3652. * @brief Get sampling time of the selected ADC channel
  3653. * Unit: ADC clock cycles.
  3654. * @note On this device, sampling time is on channel scope: independently
  3655. * of channel mapped on ADC group regular or injected.
  3656. * @note Conversion time is the addition of sampling time and processing time.
  3657. * Refer to reference manual for ADC processing time of
  3658. * this STM32 serie.
  3659. * @rmtoll SMPR0 SMP31 LL_ADC_GetChannelSamplingTime\n
  3660. * SMPR0 SMP30 LL_ADC_GetChannelSamplingTime\n
  3661. * SMPR1 SMP29 LL_ADC_GetChannelSamplingTime\n
  3662. * SMPR1 SMP28 LL_ADC_GetChannelSamplingTime\n
  3663. * SMPR1 SMP27 LL_ADC_GetChannelSamplingTime\n
  3664. * SMPR1 SMP26 LL_ADC_GetChannelSamplingTime\n
  3665. * SMPR1 SMP25 LL_ADC_GetChannelSamplingTime\n
  3666. * SMPR1 SMP24 LL_ADC_GetChannelSamplingTime\n
  3667. * SMPR1 SMP23 LL_ADC_GetChannelSamplingTime\n
  3668. * SMPR1 SMP22 LL_ADC_GetChannelSamplingTime\n
  3669. * SMPR1 SMP21 LL_ADC_GetChannelSamplingTime\n
  3670. * SMPR1 SMP20 LL_ADC_GetChannelSamplingTime\n
  3671. * SMPR2 SMP19 LL_ADC_GetChannelSamplingTime\n
  3672. * SMPR2 SMP18 LL_ADC_GetChannelSamplingTime\n
  3673. * SMPR2 SMP17 LL_ADC_GetChannelSamplingTime\n
  3674. * SMPR2 SMP16 LL_ADC_GetChannelSamplingTime\n
  3675. * SMPR2 SMP15 LL_ADC_GetChannelSamplingTime\n
  3676. * SMPR2 SMP14 LL_ADC_GetChannelSamplingTime\n
  3677. * SMPR2 SMP13 LL_ADC_GetChannelSamplingTime\n
  3678. * SMPR2 SMP12 LL_ADC_GetChannelSamplingTime\n
  3679. * SMPR2 SMP11 LL_ADC_GetChannelSamplingTime\n
  3680. * SMPR2 SMP10 LL_ADC_GetChannelSamplingTime\n
  3681. * SMPR3 SMP9 LL_ADC_GetChannelSamplingTime\n
  3682. * SMPR3 SMP8 LL_ADC_GetChannelSamplingTime\n
  3683. * SMPR3 SMP7 LL_ADC_GetChannelSamplingTime\n
  3684. * SMPR3 SMP6 LL_ADC_GetChannelSamplingTime\n
  3685. * SMPR3 SMP5 LL_ADC_GetChannelSamplingTime\n
  3686. * SMPR3 SMP4 LL_ADC_GetChannelSamplingTime\n
  3687. * SMPR3 SMP3 LL_ADC_GetChannelSamplingTime\n
  3688. * SMPR3 SMP2 LL_ADC_GetChannelSamplingTime\n
  3689. * SMPR3 SMP1 LL_ADC_GetChannelSamplingTime\n
  3690. * SMPR3 SMP0 LL_ADC_GetChannelSamplingTime
  3691. * @param ADCx ADC instance
  3692. * @param Channel This parameter can be one of the following values:
  3693. * @arg @ref LL_ADC_CHANNEL_0 (2)
  3694. * @arg @ref LL_ADC_CHANNEL_1 (2)
  3695. * @arg @ref LL_ADC_CHANNEL_2 (2)
  3696. * @arg @ref LL_ADC_CHANNEL_3 (2)
  3697. * @arg @ref LL_ADC_CHANNEL_4 (1)
  3698. * @arg @ref LL_ADC_CHANNEL_5 (1)
  3699. * @arg @ref LL_ADC_CHANNEL_6 (2)
  3700. * @arg @ref LL_ADC_CHANNEL_7 (2)
  3701. * @arg @ref LL_ADC_CHANNEL_8 (2)
  3702. * @arg @ref LL_ADC_CHANNEL_9 (2)
  3703. * @arg @ref LL_ADC_CHANNEL_10 (2)
  3704. * @arg @ref LL_ADC_CHANNEL_11 (2)
  3705. * @arg @ref LL_ADC_CHANNEL_12 (2)
  3706. * @arg @ref LL_ADC_CHANNEL_13 (3)
  3707. * @arg @ref LL_ADC_CHANNEL_14 (3)
  3708. * @arg @ref LL_ADC_CHANNEL_15 (3)
  3709. * @arg @ref LL_ADC_CHANNEL_16 (3)
  3710. * @arg @ref LL_ADC_CHANNEL_17 (3)
  3711. * @arg @ref LL_ADC_CHANNEL_18 (3)
  3712. * @arg @ref LL_ADC_CHANNEL_19 (3)
  3713. * @arg @ref LL_ADC_CHANNEL_20 (3)
  3714. * @arg @ref LL_ADC_CHANNEL_21 (3)
  3715. * @arg @ref LL_ADC_CHANNEL_22 (1)
  3716. * @arg @ref LL_ADC_CHANNEL_23 (1)
  3717. * @arg @ref LL_ADC_CHANNEL_24 (1)
  3718. * @arg @ref LL_ADC_CHANNEL_25 (1)
  3719. * @arg @ref LL_ADC_CHANNEL_26 (3)
  3720. * @arg @ref LL_ADC_CHANNEL_27 (3)(4)
  3721. * @arg @ref LL_ADC_CHANNEL_28 (3)(4)
  3722. * @arg @ref LL_ADC_CHANNEL_29 (3)(4)
  3723. * @arg @ref LL_ADC_CHANNEL_30 (3)(4)
  3724. * @arg @ref LL_ADC_CHANNEL_31 (3)(4)
  3725. * @arg @ref LL_ADC_CHANNEL_VREFINT (3)
  3726. * @arg @ref LL_ADC_CHANNEL_TEMPSENSOR (3)
  3727. * @arg @ref LL_ADC_CHANNEL_VCOMP (3)
  3728. * @arg @ref LL_ADC_CHANNEL_VOPAMP1 (3)(5)
  3729. * @arg @ref LL_ADC_CHANNEL_VOPAMP2 (3)(5)
  3730. * @arg @ref LL_ADC_CHANNEL_VOPAMP3 (3)(5)
  3731. *
  3732. * (1) On STM32L1, connection via routing interface (RI) specificity: fast channel (channel routed directly to ADC switch matrix).\n
  3733. * (2) On STM32L1, for devices with feature 'channels banks' available: Channel different in bank A and bank B.\n
  3734. * (3) On STM32L1, for devices with feature 'channels banks' available: Channel common to both bank A and bank B.\n
  3735. * (4) On STM32L1, parameter not available on all devices: only on STM32L1 Cat.4 and Cat.5.\n
  3736. * (5) On STM32L1, parameter not available on all devices: OPAMP1 and OPAMP2 available only on STM32L1 Cat.3, Cat.4 and Cat.5, OPAMP3 available only on STM32L1 Cat.4 and Cat.5
  3737. * @retval Returned value can be one of the following values:
  3738. * @arg @ref LL_ADC_SAMPLINGTIME_4CYCLES
  3739. * @arg @ref LL_ADC_SAMPLINGTIME_9CYCLES
  3740. * @arg @ref LL_ADC_SAMPLINGTIME_16CYCLES
  3741. * @arg @ref LL_ADC_SAMPLINGTIME_24CYCLES
  3742. * @arg @ref LL_ADC_SAMPLINGTIME_48CYCLES
  3743. * @arg @ref LL_ADC_SAMPLINGTIME_96CYCLES
  3744. * @arg @ref LL_ADC_SAMPLINGTIME_192CYCLES
  3745. * @arg @ref LL_ADC_SAMPLINGTIME_384CYCLES
  3746. */
  3747. __STATIC_INLINE uint32_t LL_ADC_GetChannelSamplingTime(ADC_TypeDef *ADCx, uint32_t Channel)
  3748. {
  3749. register uint32_t *preg = __ADC_PTR_REG_OFFSET(ADCx->SMPR1, __ADC_MASK_SHIFT(Channel, ADC_CHANNEL_SMPRX_REGOFFSET_MASK));
  3750. return (uint32_t)(READ_BIT(*preg,
  3751. ADC_SMPR3_SMP0 << __ADC_MASK_SHIFT(Channel, ADC_CHANNEL_SMPx_BITOFFSET_MASK))
  3752. >> __ADC_MASK_SHIFT(Channel, ADC_CHANNEL_SMPx_BITOFFSET_MASK)
  3753. );
  3754. }
  3755. #if defined(COMP_CSR_FCH3)
  3756. /**
  3757. * @brief Set ADC channels routing.
  3758. * @note Channel routing set configuration between ADC IP and GPIO pads,
  3759. * it is used to increase ADC channels speed (setting of
  3760. * direct channel).
  3761. * @note This feature is specific to STM32L1, on devices
  3762. * category Cat.3, Cat.4, Cat.5.
  3763. * To use this function, COMP RCC clock domain must be enabled.
  3764. * Refer to @ref LL_APB1_GRP1_PERIPH_COMP.
  3765. * @rmtoll CSR FCH3 LL_ADC_SetChannelRouting
  3766. * @rmtoll CSR FCH8 LL_ADC_SetChannelRouting
  3767. * @rmtoll CSR RCH13 LL_ADC_SetChannelRouting
  3768. * @param ADCx ADC instance
  3769. * @param Channel This parameter can be one of the following values:
  3770. * @arg @ref LL_ADC_CHANNEL_3_ROUTING (1)
  3771. * @arg @ref LL_ADC_CHANNEL_8_ROUTING (2)
  3772. * @arg @ref LL_ADC_CHANNEL_13_ROUTING (3)
  3773. *
  3774. * (1) Used as ADC direct channel (fast channel) if OPAMP1 is
  3775. * in power down mode.\n
  3776. * (2) Used as ADC direct channel (fast channel) if OPAMP2 is
  3777. * in power down mode.\n
  3778. * (3) Used as ADC re-routed channel if OPAMP3 is
  3779. * in power down mode.
  3780. * Otherwise, channel 13 is connected to OPAMP3 output and routed
  3781. * through switches COMP1_SW1 and VCOMP to ADC switch matrix.
  3782. * (Note: OPAMP3 is available on STM32L1 Cat.4 only).
  3783. * @param Routing This parameter can be one of the following values:
  3784. * @arg @ref LL_ADC_CHANNEL_ROUTING_DEFAULT
  3785. * @arg @ref LL_ADC_CHANNEL_ROUTING_DIRECT
  3786. */
  3787. __STATIC_INLINE void LL_ADC_SetChannelRouting(ADC_TypeDef *ADCx, uint32_t Channel, uint32_t Routing)
  3788. {
  3789. /* Note: Bit is located in comparator IP, but dedicated to ADC */
  3790. MODIFY_REG(COMP->CSR, Channel, (Routing << POSITION_VAL(Channel)));
  3791. }
  3792. /**
  3793. * @brief Get ADC channels speed.
  3794. * @note Channel routing set configuration between ADC IP and GPIO pads,
  3795. * it is used to increase ADC channels speed (setting of
  3796. * direct channel).
  3797. * @note This feature is specific to STM32L1, on devices
  3798. * category Cat.3, Cat.4, Cat.5.
  3799. * To use this function, COMP RCC clock domain must be enabled.
  3800. * Refer to @ref LL_APB1_GRP1_PERIPH_COMP.
  3801. * @rmtoll CSR FCH3 LL_ADC_GetChannelRouting
  3802. * @rmtoll CSR FCH8 LL_ADC_GetChannelRouting
  3803. * @rmtoll CSR RCH13 LL_ADC_GetChannelRouting
  3804. * @param ADCx ADC instance
  3805. * @param Channel This parameter can be one of the following values:
  3806. * @arg @ref LL_ADC_CHANNEL_3_ROUTING (1)
  3807. * @arg @ref LL_ADC_CHANNEL_8_ROUTING (2)
  3808. * @arg @ref LL_ADC_CHANNEL_13_ROUTING (3)
  3809. *
  3810. * (1) Used as ADC direct channel (fast channel) if OPAMP1 is
  3811. * in power down mode.\n
  3812. * (2) Used as ADC direct channel (fast channel) if OPAMP2 is
  3813. * in power down mode.\n
  3814. * (3) Used as ADC re-routed channel if OPAMP3 is
  3815. * in power down mode.
  3816. * Otherwise, channel 13 is connected to OPAMP3 output and routed
  3817. * through switches COMP1_SW1 and VCOMP to ADC switch matrix.
  3818. * (Note: OPAMP3 is available on STM32L1 Cat.4 only).
  3819. * @retval Returned value can be one of the following values:
  3820. * @arg @ref LL_ADC_CHANNEL_ROUTING_DEFAULT
  3821. * @arg @ref LL_ADC_CHANNEL_ROUTING_DIRECT
  3822. */
  3823. __STATIC_INLINE uint32_t LL_ADC_GetChannelRouting(ADC_TypeDef *ADCx, uint32_t Channel)
  3824. {
  3825. /* Note: Bit is located in comparator IP, but dedicated to ADC */
  3826. return (uint32_t)(READ_BIT(COMP->CSR, Channel) >> POSITION_VAL(Channel));
  3827. }
  3828. #endif
  3829. /**
  3830. * @}
  3831. */
  3832. /** @defgroup ADC_LL_EF_Configuration_ADC_AnalogWatchdog Configuration of ADC transversal scope: analog watchdog
  3833. * @{
  3834. */
  3835. /**
  3836. * @brief Set ADC analog watchdog monitored channels:
  3837. * a single channel or all channels,
  3838. * on ADC groups regular and-or injected.
  3839. * @note Once monitored channels are selected, analog watchdog
  3840. * is enabled.
  3841. * @note In case of need to define a single channel to monitor
  3842. * with analog watchdog from sequencer channel definition,
  3843. * use helper macro @ref __LL_ADC_ANALOGWD_CHANNEL_GROUP().
  3844. * @note On this STM32 serie, there is only 1 kind of analog watchdog
  3845. * instance:
  3846. * - AWD standard (instance AWD1):
  3847. * - channels monitored: can monitor 1 channel or all channels.
  3848. * - groups monitored: ADC groups regular and-or injected.
  3849. * - resolution: resolution is not limited (corresponds to
  3850. * ADC resolution configured).
  3851. * @rmtoll CR1 AWD1CH LL_ADC_SetAnalogWDMonitChannels\n
  3852. * CR1 AWD1SGL LL_ADC_SetAnalogWDMonitChannels\n
  3853. * CR1 AWD1EN LL_ADC_SetAnalogWDMonitChannels
  3854. * @param ADCx ADC instance
  3855. * @param AWDChannelGroup This parameter can be one of the following values:
  3856. * @arg @ref LL_ADC_AWD_DISABLE
  3857. * @arg @ref LL_ADC_AWD_ALL_CHANNELS_REG
  3858. * @arg @ref LL_ADC_AWD_ALL_CHANNELS_INJ
  3859. * @arg @ref LL_ADC_AWD_ALL_CHANNELS_REG_INJ
  3860. * @arg @ref LL_ADC_AWD_CHANNEL_0_REG (2)
  3861. * @arg @ref LL_ADC_AWD_CHANNEL_0_INJ (2)
  3862. * @arg @ref LL_ADC_AWD_CHANNEL_0_REG_INJ (2)
  3863. * @arg @ref LL_ADC_AWD_CHANNEL_1_REG (2)
  3864. * @arg @ref LL_ADC_AWD_CHANNEL_1_INJ (2)
  3865. * @arg @ref LL_ADC_AWD_CHANNEL_1_REG_INJ (2)
  3866. * @arg @ref LL_ADC_AWD_CHANNEL_2_REG (2)
  3867. * @arg @ref LL_ADC_AWD_CHANNEL_2_INJ (2)
  3868. * @arg @ref LL_ADC_AWD_CHANNEL_2_REG_INJ (2)
  3869. * @arg @ref LL_ADC_AWD_CHANNEL_3_REG (2)
  3870. * @arg @ref LL_ADC_AWD_CHANNEL_3_INJ (2)
  3871. * @arg @ref LL_ADC_AWD_CHANNEL_3_REG_INJ (2)
  3872. * @arg @ref LL_ADC_AWD_CHANNEL_4_REG (1)
  3873. * @arg @ref LL_ADC_AWD_CHANNEL_4_INJ (1)
  3874. * @arg @ref LL_ADC_AWD_CHANNEL_4_REG_INJ (1)
  3875. * @arg @ref LL_ADC_AWD_CHANNEL_5_REG (1)
  3876. * @arg @ref LL_ADC_AWD_CHANNEL_5_INJ (1)
  3877. * @arg @ref LL_ADC_AWD_CHANNEL_5_REG_INJ (1)
  3878. * @arg @ref LL_ADC_AWD_CHANNEL_6_REG (2)
  3879. * @arg @ref LL_ADC_AWD_CHANNEL_6_INJ (2)
  3880. * @arg @ref LL_ADC_AWD_CHANNEL_6_REG_INJ (2)
  3881. * @arg @ref LL_ADC_AWD_CHANNEL_7_REG (2)
  3882. * @arg @ref LL_ADC_AWD_CHANNEL_7_INJ (2)
  3883. * @arg @ref LL_ADC_AWD_CHANNEL_7_REG_INJ (2)
  3884. * @arg @ref LL_ADC_AWD_CHANNEL_8_REG (2)
  3885. * @arg @ref LL_ADC_AWD_CHANNEL_8_INJ (2)
  3886. * @arg @ref LL_ADC_AWD_CHANNEL_8_REG_INJ (2)
  3887. * @arg @ref LL_ADC_AWD_CHANNEL_9_REG (2)
  3888. * @arg @ref LL_ADC_AWD_CHANNEL_9_INJ (2)
  3889. * @arg @ref LL_ADC_AWD_CHANNEL_9_REG_INJ (2)
  3890. * @arg @ref LL_ADC_AWD_CHANNEL_10_REG (2)
  3891. * @arg @ref LL_ADC_AWD_CHANNEL_10_INJ (2)
  3892. * @arg @ref LL_ADC_AWD_CHANNEL_10_REG_INJ (2)
  3893. * @arg @ref LL_ADC_AWD_CHANNEL_11_REG (2)
  3894. * @arg @ref LL_ADC_AWD_CHANNEL_11_INJ (2)
  3895. * @arg @ref LL_ADC_AWD_CHANNEL_11_REG_INJ (2)
  3896. * @arg @ref LL_ADC_AWD_CHANNEL_12_REG (2)
  3897. * @arg @ref LL_ADC_AWD_CHANNEL_12_INJ (2)
  3898. * @arg @ref LL_ADC_AWD_CHANNEL_12_REG_INJ (2)
  3899. * @arg @ref LL_ADC_AWD_CHANNEL_13_REG (3)
  3900. * @arg @ref LL_ADC_AWD_CHANNEL_13_INJ (3)
  3901. * @arg @ref LL_ADC_AWD_CHANNEL_13_REG_INJ (3)
  3902. * @arg @ref LL_ADC_AWD_CHANNEL_14_REG (3)
  3903. * @arg @ref LL_ADC_AWD_CHANNEL_14_INJ (3)
  3904. * @arg @ref LL_ADC_AWD_CHANNEL_14_REG_INJ (3)
  3905. * @arg @ref LL_ADC_AWD_CHANNEL_15_REG (3)
  3906. * @arg @ref LL_ADC_AWD_CHANNEL_15_INJ (3)
  3907. * @arg @ref LL_ADC_AWD_CHANNEL_15_REG_INJ (3)
  3908. * @arg @ref LL_ADC_AWD_CHANNEL_16_REG (3)
  3909. * @arg @ref LL_ADC_AWD_CHANNEL_16_INJ (3)
  3910. * @arg @ref LL_ADC_AWD_CHANNEL_16_REG_INJ (3)
  3911. * @arg @ref LL_ADC_AWD_CHANNEL_17_REG (3)
  3912. * @arg @ref LL_ADC_AWD_CHANNEL_17_INJ (3)
  3913. * @arg @ref LL_ADC_AWD_CHANNEL_17_REG_INJ (3)
  3914. * @arg @ref LL_ADC_AWD_CHANNEL_18_REG (3)
  3915. * @arg @ref LL_ADC_AWD_CHANNEL_18_INJ (3)
  3916. * @arg @ref LL_ADC_AWD_CHANNEL_18_REG_INJ (3)
  3917. * @arg @ref LL_ADC_AWD_CHANNEL_19_REG (3)
  3918. * @arg @ref LL_ADC_AWD_CHANNEL_19_INJ (3)
  3919. * @arg @ref LL_ADC_AWD_CHANNEL_19_REG_INJ (3)
  3920. * @arg @ref LL_ADC_AWD_CHANNEL_20_REG (3)
  3921. * @arg @ref LL_ADC_AWD_CHANNEL_20_INJ (3)
  3922. * @arg @ref LL_ADC_AWD_CHANNEL_20_REG_INJ (3)
  3923. * @arg @ref LL_ADC_AWD_CHANNEL_21_REG (3)
  3924. * @arg @ref LL_ADC_AWD_CHANNEL_21_INJ (3)
  3925. * @arg @ref LL_ADC_AWD_CHANNEL_21_REG_INJ (3)
  3926. * @arg @ref LL_ADC_AWD_CHANNEL_22_REG (1)
  3927. * @arg @ref LL_ADC_AWD_CHANNEL_22_INJ (1)
  3928. * @arg @ref LL_ADC_AWD_CHANNEL_22_REG_INJ (1)
  3929. * @arg @ref LL_ADC_AWD_CHANNEL_23_REG (1)
  3930. * @arg @ref LL_ADC_AWD_CHANNEL_23_INJ (1)
  3931. * @arg @ref LL_ADC_AWD_CHANNEL_23_REG_INJ (1)
  3932. * @arg @ref LL_ADC_AWD_CHANNEL_24_REG (1)
  3933. * @arg @ref LL_ADC_AWD_CHANNEL_24_INJ (1)
  3934. * @arg @ref LL_ADC_AWD_CHANNEL_24_REG_INJ (1)
  3935. * @arg @ref LL_ADC_AWD_CHANNEL_25_REG (1)
  3936. * @arg @ref LL_ADC_AWD_CHANNEL_25_INJ (1)
  3937. * @arg @ref LL_ADC_AWD_CHANNEL_25_REG_INJ (1)
  3938. * @arg @ref LL_ADC_AWD_CHANNEL_26_REG (3)
  3939. * @arg @ref LL_ADC_AWD_CHANNEL_26_INJ (3)
  3940. * @arg @ref LL_ADC_AWD_CHANNEL_26_REG_INJ (3)
  3941. * @arg @ref LL_ADC_AWD_CHANNEL_27_REG (3)(4)
  3942. * @arg @ref LL_ADC_AWD_CHANNEL_27_INJ (3)(4)
  3943. * @arg @ref LL_ADC_AWD_CHANNEL_27_REG_INJ (3)(4)
  3944. * @arg @ref LL_ADC_AWD_CHANNEL_28_REG (3)(4)
  3945. * @arg @ref LL_ADC_AWD_CHANNEL_28_INJ (3)(4)
  3946. * @arg @ref LL_ADC_AWD_CHANNEL_28_REG_INJ (3)(4)
  3947. * @arg @ref LL_ADC_AWD_CHANNEL_29_REG (3)(4)
  3948. * @arg @ref LL_ADC_AWD_CHANNEL_29_INJ (3)(4)
  3949. * @arg @ref LL_ADC_AWD_CHANNEL_29_REG_INJ (3)(4)
  3950. * @arg @ref LL_ADC_AWD_CHANNEL_30_REG (3)(4)
  3951. * @arg @ref LL_ADC_AWD_CHANNEL_30_INJ (3)(4)
  3952. * @arg @ref LL_ADC_AWD_CHANNEL_30_REG_INJ (3)(4)
  3953. * @arg @ref LL_ADC_AWD_CHANNEL_31_REG (3)(4)
  3954. * @arg @ref LL_ADC_AWD_CHANNEL_31_INJ (3)(4)
  3955. * @arg @ref LL_ADC_AWD_CHANNEL_31_REG_INJ (3)(4)
  3956. * @arg @ref LL_ADC_AWD_CH_VREFINT_REG (3)
  3957. * @arg @ref LL_ADC_AWD_CH_VREFINT_INJ (3)
  3958. * @arg @ref LL_ADC_AWD_CH_VREFINT_REG_INJ (3)
  3959. * @arg @ref LL_ADC_AWD_CH_TEMPSENSOR_REG (3)
  3960. * @arg @ref LL_ADC_AWD_CH_TEMPSENSOR_INJ (3)
  3961. * @arg @ref LL_ADC_AWD_CH_TEMPSENSOR_REG_INJ (3)
  3962. * @arg @ref LL_ADC_AWD_CH_VCOMP_REG (3)
  3963. * @arg @ref LL_ADC_AWD_CH_VCOMP_INJ (3)
  3964. * @arg @ref LL_ADC_AWD_CH_VCOMP_REG_INJ (3)
  3965. * @arg @ref LL_ADC_AWD_CH_VOPAMP1_REG (3)(5)
  3966. * @arg @ref LL_ADC_AWD_CH_VOPAMP1_INJ (3)(5)
  3967. * @arg @ref LL_ADC_AWD_CH_VOPAMP1_REG_INJ (3)(5)
  3968. * @arg @ref LL_ADC_AWD_CH_VOPAMP2_REG (3)(5)
  3969. * @arg @ref LL_ADC_AWD_CH_VOPAMP2_INJ (3)(5)
  3970. * @arg @ref LL_ADC_AWD_CH_VOPAMP2_REG_INJ (3)(5)
  3971. * @arg @ref LL_ADC_AWD_CH_VOPAMP3_REG (3)(5)
  3972. * @arg @ref LL_ADC_AWD_CH_VOPAMP3_INJ (3)(5)
  3973. * @arg @ref LL_ADC_AWD_CH_VOPAMP3_REG_INJ (3)(5)
  3974. *
  3975. * (1) On STM32L1, connection via routing interface (RI) specificity: fast channel (channel routed directly to ADC switch matrix).\n
  3976. * (2) On STM32L1, for devices with feature 'channels banks' available: Channel different in bank A and bank B.\n
  3977. * (3) On STM32L1, for devices with feature 'channels banks' available: Channel common to both bank A and bank B.\n
  3978. * (4) On STM32L1, parameter not available on all devices: only on STM32L1 Cat.4 and Cat.5.\n
  3979. * (5) On STM32L1, parameter not available on all devices: OPAMP1 and OPAMP2 available only on STM32L1 Cat.3, Cat.4 and Cat.5, OPAMP3 available only on STM32L1 Cat.4 and Cat.5
  3980. * @retval None
  3981. */
  3982. __STATIC_INLINE void LL_ADC_SetAnalogWDMonitChannels(ADC_TypeDef *ADCx, uint32_t AWDChannelGroup)
  3983. {
  3984. MODIFY_REG(ADCx->CR1,
  3985. (ADC_CR1_AWDEN | ADC_CR1_JAWDEN | ADC_CR1_AWDSGL | ADC_CR1_AWDCH),
  3986. AWDChannelGroup);
  3987. }
  3988. /**
  3989. * @brief Get ADC analog watchdog monitored channel.
  3990. * @note Usage of the returned channel number:
  3991. * - To reinject this channel into another function LL_ADC_xxx:
  3992. * the returned channel number is only partly formatted on definition
  3993. * of literals LL_ADC_CHANNEL_x. Therefore, it has to be compared
  3994. * with parts of literals LL_ADC_CHANNEL_x or using
  3995. * helper macro @ref __LL_ADC_CHANNEL_TO_DECIMAL_NB().
  3996. * Then the selected literal LL_ADC_CHANNEL_x can be used
  3997. * as parameter for another function.
  3998. * - To get the channel number in decimal format:
  3999. * process the returned value with the helper macro
  4000. * @ref __LL_ADC_CHANNEL_TO_DECIMAL_NB().
  4001. * Applicable only when the analog watchdog is set to monitor
  4002. * one channel.
  4003. * @note On this STM32 serie, there is only 1 kind of analog watchdog
  4004. * instance:
  4005. * - AWD standard (instance AWD1):
  4006. * - channels monitored: can monitor 1 channel or all channels.
  4007. * - groups monitored: ADC groups regular and-or injected.
  4008. * - resolution: resolution is not limited (corresponds to
  4009. * ADC resolution configured).
  4010. * @rmtoll CR1 AWD1CH LL_ADC_GetAnalogWDMonitChannels\n
  4011. * CR1 AWD1SGL LL_ADC_GetAnalogWDMonitChannels\n
  4012. * CR1 AWD1EN LL_ADC_GetAnalogWDMonitChannels
  4013. * @param ADCx ADC instance
  4014. * @retval Returned value can be one of the following values:
  4015. * @arg @ref LL_ADC_AWD_DISABLE
  4016. * @arg @ref LL_ADC_AWD_ALL_CHANNELS_REG
  4017. * @arg @ref LL_ADC_AWD_ALL_CHANNELS_INJ
  4018. * @arg @ref LL_ADC_AWD_ALL_CHANNELS_REG_INJ
  4019. * @arg @ref LL_ADC_AWD_CHANNEL_0_REG (2)
  4020. * @arg @ref LL_ADC_AWD_CHANNEL_0_INJ (2)
  4021. * @arg @ref LL_ADC_AWD_CHANNEL_0_REG_INJ (2)
  4022. * @arg @ref LL_ADC_AWD_CHANNEL_1_REG (2)
  4023. * @arg @ref LL_ADC_AWD_CHANNEL_1_INJ (2)
  4024. * @arg @ref LL_ADC_AWD_CHANNEL_1_REG_INJ (2)
  4025. * @arg @ref LL_ADC_AWD_CHANNEL_2_REG (2)
  4026. * @arg @ref LL_ADC_AWD_CHANNEL_2_INJ (2)
  4027. * @arg @ref LL_ADC_AWD_CHANNEL_2_REG_INJ (2)
  4028. * @arg @ref LL_ADC_AWD_CHANNEL_3_REG (2)
  4029. * @arg @ref LL_ADC_AWD_CHANNEL_3_INJ (2)
  4030. * @arg @ref LL_ADC_AWD_CHANNEL_3_REG_INJ (2)
  4031. * @arg @ref LL_ADC_AWD_CHANNEL_4_REG (1)
  4032. * @arg @ref LL_ADC_AWD_CHANNEL_4_INJ (1)
  4033. * @arg @ref LL_ADC_AWD_CHANNEL_4_REG_INJ (1)
  4034. * @arg @ref LL_ADC_AWD_CHANNEL_5_REG (1)
  4035. * @arg @ref LL_ADC_AWD_CHANNEL_5_INJ (1)
  4036. * @arg @ref LL_ADC_AWD_CHANNEL_5_REG_INJ (1)
  4037. * @arg @ref LL_ADC_AWD_CHANNEL_6_REG (2)
  4038. * @arg @ref LL_ADC_AWD_CHANNEL_6_INJ (2)
  4039. * @arg @ref LL_ADC_AWD_CHANNEL_6_REG_INJ (2)
  4040. * @arg @ref LL_ADC_AWD_CHANNEL_7_REG (2)
  4041. * @arg @ref LL_ADC_AWD_CHANNEL_7_INJ (2)
  4042. * @arg @ref LL_ADC_AWD_CHANNEL_7_REG_INJ (2)
  4043. * @arg @ref LL_ADC_AWD_CHANNEL_8_REG (2)
  4044. * @arg @ref LL_ADC_AWD_CHANNEL_8_INJ (2)
  4045. * @arg @ref LL_ADC_AWD_CHANNEL_8_REG_INJ (2)
  4046. * @arg @ref LL_ADC_AWD_CHANNEL_9_REG (2)
  4047. * @arg @ref LL_ADC_AWD_CHANNEL_9_INJ (2)
  4048. * @arg @ref LL_ADC_AWD_CHANNEL_9_REG_INJ (2)
  4049. * @arg @ref LL_ADC_AWD_CHANNEL_10_REG (2)
  4050. * @arg @ref LL_ADC_AWD_CHANNEL_10_INJ (2)
  4051. * @arg @ref LL_ADC_AWD_CHANNEL_10_REG_INJ (2)
  4052. * @arg @ref LL_ADC_AWD_CHANNEL_11_REG (2)
  4053. * @arg @ref LL_ADC_AWD_CHANNEL_11_INJ (2)
  4054. * @arg @ref LL_ADC_AWD_CHANNEL_11_REG_INJ (2)
  4055. * @arg @ref LL_ADC_AWD_CHANNEL_12_REG (2)
  4056. * @arg @ref LL_ADC_AWD_CHANNEL_12_INJ (2)
  4057. * @arg @ref LL_ADC_AWD_CHANNEL_12_REG_INJ (2)
  4058. * @arg @ref LL_ADC_AWD_CHANNEL_13_REG (3)
  4059. * @arg @ref LL_ADC_AWD_CHANNEL_13_INJ (3)
  4060. * @arg @ref LL_ADC_AWD_CHANNEL_13_REG_INJ (3)
  4061. * @arg @ref LL_ADC_AWD_CHANNEL_14_REG (3)
  4062. * @arg @ref LL_ADC_AWD_CHANNEL_14_INJ (3)
  4063. * @arg @ref LL_ADC_AWD_CHANNEL_14_REG_INJ (3)
  4064. * @arg @ref LL_ADC_AWD_CHANNEL_15_REG (3)
  4065. * @arg @ref LL_ADC_AWD_CHANNEL_15_INJ (3)
  4066. * @arg @ref LL_ADC_AWD_CHANNEL_15_REG_INJ (3)
  4067. * @arg @ref LL_ADC_AWD_CHANNEL_16_REG (3)
  4068. * @arg @ref LL_ADC_AWD_CHANNEL_16_INJ (3)
  4069. * @arg @ref LL_ADC_AWD_CHANNEL_16_REG_INJ (3)
  4070. * @arg @ref LL_ADC_AWD_CHANNEL_17_REG (3)
  4071. * @arg @ref LL_ADC_AWD_CHANNEL_17_INJ (3)
  4072. * @arg @ref LL_ADC_AWD_CHANNEL_17_REG_INJ (3)
  4073. * @arg @ref LL_ADC_AWD_CHANNEL_18_REG (3)
  4074. * @arg @ref LL_ADC_AWD_CHANNEL_18_INJ (3)
  4075. * @arg @ref LL_ADC_AWD_CHANNEL_18_REG_INJ (3)
  4076. * @arg @ref LL_ADC_AWD_CHANNEL_19_REG (3)
  4077. * @arg @ref LL_ADC_AWD_CHANNEL_19_INJ (3)
  4078. * @arg @ref LL_ADC_AWD_CHANNEL_19_REG_INJ (3)
  4079. * @arg @ref LL_ADC_AWD_CHANNEL_20_REG (3)
  4080. * @arg @ref LL_ADC_AWD_CHANNEL_20_INJ (3)
  4081. * @arg @ref LL_ADC_AWD_CHANNEL_20_REG_INJ (3)
  4082. * @arg @ref LL_ADC_AWD_CHANNEL_21_REG (3)
  4083. * @arg @ref LL_ADC_AWD_CHANNEL_21_INJ (3)
  4084. * @arg @ref LL_ADC_AWD_CHANNEL_21_REG_INJ (3)
  4085. * @arg @ref LL_ADC_AWD_CHANNEL_22_REG (1)
  4086. * @arg @ref LL_ADC_AWD_CHANNEL_22_INJ (1)
  4087. * @arg @ref LL_ADC_AWD_CHANNEL_22_REG_INJ (1)
  4088. * @arg @ref LL_ADC_AWD_CHANNEL_23_REG (1)
  4089. * @arg @ref LL_ADC_AWD_CHANNEL_23_INJ (1)
  4090. * @arg @ref LL_ADC_AWD_CHANNEL_23_REG_INJ (1)
  4091. * @arg @ref LL_ADC_AWD_CHANNEL_24_REG (1)
  4092. * @arg @ref LL_ADC_AWD_CHANNEL_24_INJ (1)
  4093. * @arg @ref LL_ADC_AWD_CHANNEL_24_REG_INJ (1)
  4094. * @arg @ref LL_ADC_AWD_CHANNEL_25_REG (1)
  4095. * @arg @ref LL_ADC_AWD_CHANNEL_25_INJ (1)
  4096. * @arg @ref LL_ADC_AWD_CHANNEL_25_REG_INJ (1)
  4097. * @arg @ref LL_ADC_AWD_CHANNEL_26_REG (3)
  4098. * @arg @ref LL_ADC_AWD_CHANNEL_26_INJ (3)
  4099. * @arg @ref LL_ADC_AWD_CHANNEL_26_REG_INJ (3)
  4100. * @arg @ref LL_ADC_AWD_CHANNEL_27_REG (3)(4)
  4101. * @arg @ref LL_ADC_AWD_CHANNEL_27_INJ (3)(4)
  4102. * @arg @ref LL_ADC_AWD_CHANNEL_27_REG_INJ (3)(4)
  4103. * @arg @ref LL_ADC_AWD_CHANNEL_28_REG (3)(4)
  4104. * @arg @ref LL_ADC_AWD_CHANNEL_28_INJ (3)(4)
  4105. * @arg @ref LL_ADC_AWD_CHANNEL_28_REG_INJ (3)(4)
  4106. * @arg @ref LL_ADC_AWD_CHANNEL_29_REG (3)(4)
  4107. * @arg @ref LL_ADC_AWD_CHANNEL_29_INJ (3)(4)
  4108. * @arg @ref LL_ADC_AWD_CHANNEL_29_REG_INJ (3)(4)
  4109. * @arg @ref LL_ADC_AWD_CHANNEL_30_REG (3)(4)
  4110. * @arg @ref LL_ADC_AWD_CHANNEL_30_INJ (3)(4)
  4111. * @arg @ref LL_ADC_AWD_CHANNEL_30_REG_INJ (3)(4)
  4112. * @arg @ref LL_ADC_AWD_CHANNEL_31_REG (3)(4)
  4113. * @arg @ref LL_ADC_AWD_CHANNEL_31_INJ (3)(4)
  4114. * @arg @ref LL_ADC_AWD_CHANNEL_31_REG_INJ (3)(4)
  4115. *
  4116. * (1) On STM32L1, connection via routing interface (RI) specificity: fast channel (channel routed directly to ADC switch matrix).\n
  4117. * (2) On STM32L1, for devices with feature 'channels banks' available: Channel different in bank A and bank B.\n
  4118. * (3) On STM32L1, for devices with feature 'channels banks' available: Channel common to both bank A and bank B.\n
  4119. * (4) On STM32L1, parameter not available on all devices: only on STM32L1 Cat.4 and Cat.5.
  4120. */
  4121. __STATIC_INLINE uint32_t LL_ADC_GetAnalogWDMonitChannels(ADC_TypeDef *ADCx)
  4122. {
  4123. return (uint32_t)(READ_BIT(ADCx->CR1, (ADC_CR1_AWDEN | ADC_CR1_JAWDEN | ADC_CR1_AWDSGL | ADC_CR1_AWDCH)));
  4124. }
  4125. /**
  4126. * @brief Set ADC analog watchdog threshold value of threshold
  4127. * high or low.
  4128. * @note In case of ADC resolution different of 12 bits,
  4129. * analog watchdog thresholds data require a specific shift.
  4130. * Use helper macro @ref __LL_ADC_ANALOGWD_SET_THRESHOLD_RESOLUTION().
  4131. * @note On this STM32 serie, there is only 1 kind of analog watchdog
  4132. * instance:
  4133. * - AWD standard (instance AWD1):
  4134. * - channels monitored: can monitor 1 channel or all channels.
  4135. * - groups monitored: ADC groups regular and-or injected.
  4136. * - resolution: resolution is not limited (corresponds to
  4137. * ADC resolution configured).
  4138. * @rmtoll HTR HT LL_ADC_SetAnalogWDThresholds\n
  4139. * LTR LT LL_ADC_SetAnalogWDThresholds
  4140. * @param ADCx ADC instance
  4141. * @param AWDThresholdsHighLow This parameter can be one of the following values:
  4142. * @arg @ref LL_ADC_AWD_THRESHOLD_HIGH
  4143. * @arg @ref LL_ADC_AWD_THRESHOLD_LOW
  4144. * @param AWDThresholdValue: Value between Min_Data=0x000 and Max_Data=0xFFF
  4145. * @retval None
  4146. */
  4147. __STATIC_INLINE void LL_ADC_SetAnalogWDThresholds(ADC_TypeDef *ADCx, uint32_t AWDThresholdsHighLow, uint32_t AWDThresholdValue)
  4148. {
  4149. register uint32_t *preg = __ADC_PTR_REG_OFFSET(ADCx->HTR, AWDThresholdsHighLow);
  4150. MODIFY_REG(*preg,
  4151. ADC_HTR_HT,
  4152. AWDThresholdValue);
  4153. }
  4154. /**
  4155. * @brief Get ADC analog watchdog threshold value of threshold high or
  4156. * threshold low.
  4157. * @note In case of ADC resolution different of 12 bits,
  4158. * analog watchdog thresholds data require a specific shift.
  4159. * Use helper macro @ref __LL_ADC_ANALOGWD_GET_THRESHOLD_RESOLUTION().
  4160. * @rmtoll HTR HT LL_ADC_GetAnalogWDThresholds\n
  4161. * LTR LT LL_ADC_GetAnalogWDThresholds
  4162. * @param ADCx ADC instance
  4163. * @param AWDThresholdsHighLow This parameter can be one of the following values:
  4164. * @arg @ref LL_ADC_AWD_THRESHOLD_HIGH
  4165. * @arg @ref LL_ADC_AWD_THRESHOLD_LOW
  4166. * @retval Value between Min_Data=0x000 and Max_Data=0xFFF
  4167. */
  4168. __STATIC_INLINE uint32_t LL_ADC_GetAnalogWDThresholds(ADC_TypeDef *ADCx, uint32_t AWDThresholdsHighLow)
  4169. {
  4170. register uint32_t *preg = __ADC_PTR_REG_OFFSET(ADCx->HTR, AWDThresholdsHighLow);
  4171. return (uint32_t)(READ_BIT(*preg, ADC_HTR_HT));
  4172. }
  4173. /**
  4174. * @}
  4175. */
  4176. /** @defgroup ADC_LL_EF_Operation_ADC_Instance Operation on ADC hierarchical scope: ADC instance
  4177. * @{
  4178. */
  4179. /**
  4180. * @brief Enable the selected ADC instance.
  4181. * @note On this STM32 serie, after ADC enable, a delay for
  4182. * ADC internal analog stabilization is required before performing a
  4183. * ADC conversion start.
  4184. * Refer to device datasheet, parameter tSTAB.
  4185. * @note Due to the latency introduced by the synchronization between
  4186. * two clock domains (ADC clock source asynchronous),
  4187. * some hardware constraints must be respected:
  4188. * - ADC must be enabled (@ref LL_ADC_Enable() ) only
  4189. * when ADC is not ready to convert.
  4190. * - ADC must be disabled (@ref LL_ADC_Disable() ) only
  4191. * when ADC is ready to convert.
  4192. * Status of ADC ready to convert can be checked using function
  4193. * @ref LL_ADC_IsActiveFlag_ADRDY().
  4194. * @rmtoll CR2 ADON LL_ADC_Enable
  4195. * @param ADCx ADC instance
  4196. * @retval None
  4197. */
  4198. __STATIC_INLINE void LL_ADC_Enable(ADC_TypeDef *ADCx)
  4199. {
  4200. SET_BIT(ADCx->CR2, ADC_CR2_ADON);
  4201. }
  4202. /**
  4203. * @brief Disable the selected ADC instance.
  4204. * @note Due to the latency introduced by the synchronization between
  4205. * two clock domains (ADC clock source asynchronous),
  4206. * some hardware constraints must be respected:
  4207. * - ADC must be enabled (@ref LL_ADC_Enable() ) only
  4208. * when ADC is not ready to convert.
  4209. * - ADC must be disabled (@ref LL_ADC_Disable() ) only
  4210. * when ADC is ready to convert.
  4211. * Status of ADC ready to convert can be checked using function
  4212. * @ref LL_ADC_IsActiveFlag_ADRDY().
  4213. * @rmtoll CR2 ADON LL_ADC_Disable
  4214. * @param ADCx ADC instance
  4215. * @retval None
  4216. */
  4217. __STATIC_INLINE void LL_ADC_Disable(ADC_TypeDef *ADCx)
  4218. {
  4219. CLEAR_BIT(ADCx->CR2, ADC_CR2_ADON);
  4220. }
  4221. /**
  4222. * @brief Get the selected ADC instance enable state.
  4223. * @rmtoll CR2 ADON LL_ADC_IsEnabled
  4224. * @param ADCx ADC instance
  4225. * @retval 0: ADC is disabled, 1: ADC is enabled.
  4226. */
  4227. __STATIC_INLINE uint32_t LL_ADC_IsEnabled(ADC_TypeDef *ADCx)
  4228. {
  4229. return (READ_BIT(ADCx->CR2, ADC_CR2_ADON) == (ADC_CR2_ADON));
  4230. }
  4231. /**
  4232. * @}
  4233. */
  4234. /** @defgroup ADC_LL_EF_Operation_ADC_Group_Regular Operation on ADC hierarchical scope: group regular
  4235. * @{
  4236. */
  4237. /**
  4238. * @brief Start ADC group regular conversion.
  4239. * @note On this STM32 serie, this function is relevant only for
  4240. * internal trigger (SW start), not for external trigger:
  4241. * - If ADC trigger has been set to software start, ADC conversion
  4242. * starts immediately.
  4243. * - If ADC trigger has been set to external trigger, ADC conversion
  4244. * start must be performed using function
  4245. * @ref LL_ADC_REG_StartConversionExtTrig().
  4246. * (if external trigger edge would have been set during ADC other
  4247. * settings, ADC conversion would start at trigger event
  4248. * as soon as ADC is enabled).
  4249. * @rmtoll CR2 SWSTART LL_ADC_REG_StartConversionSWStart
  4250. * @param ADCx ADC instance
  4251. * @retval None
  4252. */
  4253. __STATIC_INLINE void LL_ADC_REG_StartConversionSWStart(ADC_TypeDef *ADCx)
  4254. {
  4255. SET_BIT(ADCx->CR2, ADC_CR2_SWSTART);
  4256. }
  4257. /**
  4258. * @brief Start ADC group regular conversion from external trigger.
  4259. * @note ADC conversion will start at next trigger event (on the selected
  4260. * trigger edge) following the ADC start conversion command.
  4261. * @note On this STM32 serie, this function is relevant for
  4262. * ADC conversion start from external trigger.
  4263. * If internal trigger (SW start) is needed, perform ADC conversion
  4264. * start using function @ref LL_ADC_REG_StartConversionSWStart().
  4265. * @rmtoll CR2 EXTEN LL_ADC_REG_StartConversionExtTrig
  4266. * @param ExternalTriggerEdge This parameter can be one of the following values:
  4267. * @arg @ref LL_ADC_REG_TRIG_EXT_RISING
  4268. * @arg @ref LL_ADC_REG_TRIG_EXT_FALLING
  4269. * @arg @ref LL_ADC_REG_TRIG_EXT_RISINGFALLING
  4270. * @param ADCx ADC instance
  4271. * @retval None
  4272. */
  4273. __STATIC_INLINE void LL_ADC_REG_StartConversionExtTrig(ADC_TypeDef *ADCx, uint32_t ExternalTriggerEdge)
  4274. {
  4275. SET_BIT(ADCx->CR2, ExternalTriggerEdge);
  4276. }
  4277. /**
  4278. * @brief Stop ADC group regular conversion from external trigger.
  4279. * @note No more ADC conversion will start at next trigger event
  4280. * following the ADC stop conversion command.
  4281. * If a conversion is on-going, it will be completed.
  4282. * @note On this STM32 serie, there is no specific command
  4283. * to stop a conversion on-going or to stop ADC converting
  4284. * in continuous mode. These actions can be performed
  4285. * using function @ref LL_ADC_Disable().
  4286. * @rmtoll CR2 EXTEN LL_ADC_REG_StopConversionExtTrig
  4287. * @param ADCx ADC instance
  4288. * @retval None
  4289. */
  4290. __STATIC_INLINE void LL_ADC_REG_StopConversionExtTrig(ADC_TypeDef *ADCx)
  4291. {
  4292. CLEAR_BIT(ADCx->CR2, ADC_CR2_EXTEN);
  4293. }
  4294. /**
  4295. * @brief Get ADC group regular conversion data, range fit for
  4296. * all ADC configurations: all ADC resolutions and
  4297. * all oversampling increased data width (for devices
  4298. * with feature oversampling).
  4299. * @rmtoll DR RDATA LL_ADC_REG_ReadConversionData32
  4300. * @param ADCx ADC instance
  4301. * @retval Value between Min_Data=0x00000000 and Max_Data=0xFFFFFFFF
  4302. */
  4303. __STATIC_INLINE uint32_t LL_ADC_REG_ReadConversionData32(ADC_TypeDef *ADCx)
  4304. {
  4305. return (uint16_t)(READ_BIT(ADCx->DR, ADC_DR_DATA));
  4306. }
  4307. /**
  4308. * @brief Get ADC group regular conversion data, range fit for
  4309. * ADC resolution 12 bits.
  4310. * @note For devices with feature oversampling: Oversampling
  4311. * can increase data width, function for extended range
  4312. * may be needed: @ref LL_ADC_REG_ReadConversionData32.
  4313. * @rmtoll DR RDATA LL_ADC_REG_ReadConversionData12
  4314. * @param ADCx ADC instance
  4315. * @retval Value between Min_Data=0x000 and Max_Data=0xFFF
  4316. */
  4317. __STATIC_INLINE uint16_t LL_ADC_REG_ReadConversionData12(ADC_TypeDef *ADCx)
  4318. {
  4319. return (uint16_t)(READ_BIT(ADCx->DR, ADC_DR_DATA));
  4320. }
  4321. /**
  4322. * @brief Get ADC group regular conversion data, range fit for
  4323. * ADC resolution 10 bits.
  4324. * @note For devices with feature oversampling: Oversampling
  4325. * can increase data width, function for extended range
  4326. * may be needed: @ref LL_ADC_REG_ReadConversionData32.
  4327. * @rmtoll DR RDATA LL_ADC_REG_ReadConversionData10
  4328. * @param ADCx ADC instance
  4329. * @retval Value between Min_Data=0x000 and Max_Data=0x3FF
  4330. */
  4331. __STATIC_INLINE uint16_t LL_ADC_REG_ReadConversionData10(ADC_TypeDef *ADCx)
  4332. {
  4333. return (uint16_t)(READ_BIT(ADCx->DR, ADC_DR_DATA));
  4334. }
  4335. /**
  4336. * @brief Get ADC group regular conversion data, range fit for
  4337. * ADC resolution 8 bits.
  4338. * @note For devices with feature oversampling: Oversampling
  4339. * can increase data width, function for extended range
  4340. * may be needed: @ref LL_ADC_REG_ReadConversionData32.
  4341. * @rmtoll DR RDATA LL_ADC_REG_ReadConversionData8
  4342. * @param ADCx ADC instance
  4343. * @retval Value between Min_Data=0x00 and Max_Data=0xFF
  4344. */
  4345. __STATIC_INLINE uint8_t LL_ADC_REG_ReadConversionData8(ADC_TypeDef *ADCx)
  4346. {
  4347. return (uint16_t)(READ_BIT(ADCx->DR, ADC_DR_DATA));
  4348. }
  4349. /**
  4350. * @brief Get ADC group regular conversion data, range fit for
  4351. * ADC resolution 6 bits.
  4352. * @note For devices with feature oversampling: Oversampling
  4353. * can increase data width, function for extended range
  4354. * may be needed: @ref LL_ADC_REG_ReadConversionData32.
  4355. * @rmtoll DR RDATA LL_ADC_REG_ReadConversionData6
  4356. * @param ADCx ADC instance
  4357. * @retval Value between Min_Data=0x00 and Max_Data=0x3F
  4358. */
  4359. __STATIC_INLINE uint8_t LL_ADC_REG_ReadConversionData6(ADC_TypeDef *ADCx)
  4360. {
  4361. return (uint16_t)(READ_BIT(ADCx->DR, ADC_DR_DATA));
  4362. }
  4363. /**
  4364. * @}
  4365. */
  4366. /** @defgroup ADC_LL_EF_Operation_ADC_Group_Injected Operation on ADC hierarchical scope: group injected
  4367. * @{
  4368. */
  4369. /**
  4370. * @brief Start ADC group injected conversion.
  4371. * @note On this STM32 serie, this function is relevant only for
  4372. * internal trigger (SW start), not for external trigger:
  4373. * - If ADC trigger has been set to software start, ADC conversion
  4374. * starts immediately.
  4375. * - If ADC trigger has been set to external trigger, ADC conversion
  4376. * start must be performed using function
  4377. * @ref LL_ADC_INJ_StartConversionExtTrig().
  4378. * (if external trigger edge would have been set during ADC other
  4379. * settings, ADC conversion would start at trigger event
  4380. * as soon as ADC is enabled).
  4381. * @rmtoll CR2 JSWSTART LL_ADC_INJ_StartConversionSWStart
  4382. * @param ADCx ADC instance
  4383. * @retval None
  4384. */
  4385. __STATIC_INLINE void LL_ADC_INJ_StartConversionSWStart(ADC_TypeDef *ADCx)
  4386. {
  4387. SET_BIT(ADCx->CR2, ADC_CR2_JSWSTART);
  4388. }
  4389. /**
  4390. * @brief Start ADC group injected conversion from external trigger.
  4391. * @note ADC conversion will start at next trigger event (on the selected
  4392. * trigger edge) following the ADC start conversion command.
  4393. * @note On this STM32 serie, this function is relevant for
  4394. * ADC conversion start from external trigger.
  4395. * If internal trigger (SW start) is needed, perform ADC conversion
  4396. * start using function @ref LL_ADC_INJ_StartConversionSWStart().
  4397. * @rmtoll CR2 JEXTEN LL_ADC_INJ_StartConversionExtTrig
  4398. * @param ExternalTriggerEdge This parameter can be one of the following values:
  4399. * @arg @ref LL_ADC_INJ_TRIG_EXT_RISING
  4400. * @arg @ref LL_ADC_INJ_TRIG_EXT_FALLING
  4401. * @arg @ref LL_ADC_INJ_TRIG_EXT_RISINGFALLING
  4402. * @param ADCx ADC instance
  4403. * @retval None
  4404. */
  4405. __STATIC_INLINE void LL_ADC_INJ_StartConversionExtTrig(ADC_TypeDef *ADCx, uint32_t ExternalTriggerEdge)
  4406. {
  4407. SET_BIT(ADCx->CR2, ExternalTriggerEdge);
  4408. }
  4409. /**
  4410. * @brief Stop ADC group injected conversion from external trigger.
  4411. * @note No more ADC conversion will start at next trigger event
  4412. * following the ADC stop conversion command.
  4413. * If a conversion is on-going, it will be completed.
  4414. * @note On this STM32 serie, there is no specific command
  4415. * to stop a conversion on-going or to stop ADC converting
  4416. * in continuous mode. These actions can be performed
  4417. * using function @ref LL_ADC_Disable().
  4418. * @rmtoll CR2 JEXTEN LL_ADC_INJ_StopConversionExtTrig
  4419. * @param ADCx ADC instance
  4420. * @retval None
  4421. */
  4422. __STATIC_INLINE void LL_ADC_INJ_StopConversionExtTrig(ADC_TypeDef *ADCx)
  4423. {
  4424. CLEAR_BIT(ADCx->CR2, ADC_CR2_JEXTEN);
  4425. }
  4426. /**
  4427. * @brief Get ADC group regular conversion data, range fit for
  4428. * all ADC configurations: all ADC resolutions and
  4429. * all oversampling increased data width (for devices
  4430. * with feature oversampling).
  4431. * @rmtoll JDR1 JDATA LL_ADC_INJ_ReadConversionData32\n
  4432. * JDR2 JDATA LL_ADC_INJ_ReadConversionData32\n
  4433. * JDR3 JDATA LL_ADC_INJ_ReadConversionData32\n
  4434. * JDR4 JDATA LL_ADC_INJ_ReadConversionData32
  4435. * @param ADCx ADC instance
  4436. * @param Rank This parameter can be one of the following values:
  4437. * @arg @ref LL_ADC_INJ_RANK_1
  4438. * @arg @ref LL_ADC_INJ_RANK_2
  4439. * @arg @ref LL_ADC_INJ_RANK_3
  4440. * @arg @ref LL_ADC_INJ_RANK_4
  4441. * @retval Value between Min_Data=0x00000000 and Max_Data=0xFFFFFFFF
  4442. */
  4443. __STATIC_INLINE uint32_t LL_ADC_INJ_ReadConversionData32(ADC_TypeDef *ADCx, uint32_t Rank)
  4444. {
  4445. register uint32_t *preg = __ADC_PTR_REG_OFFSET(ADCx->JDR1, __ADC_MASK_SHIFT(Rank, ADC_INJ_JDRX_REGOFFSET_MASK));
  4446. return (uint32_t)(READ_BIT(*preg,
  4447. ADC_JDR1_JDATA)
  4448. );
  4449. }
  4450. /**
  4451. * @brief Get ADC group injected conversion data, range fit for
  4452. * ADC resolution 12 bits.
  4453. * @note For devices with feature oversampling: Oversampling
  4454. * can increase data width, function for extended range
  4455. * may be needed: @ref LL_ADC_INJ_ReadConversionData32.
  4456. * @rmtoll JDR1 JDATA LL_ADC_INJ_ReadConversionData12\n
  4457. * JDR2 JDATA LL_ADC_INJ_ReadConversionData12\n
  4458. * JDR3 JDATA LL_ADC_INJ_ReadConversionData12\n
  4459. * JDR4 JDATA LL_ADC_INJ_ReadConversionData12
  4460. * @param ADCx ADC instance
  4461. * @param Rank This parameter can be one of the following values:
  4462. * @arg @ref LL_ADC_INJ_RANK_1
  4463. * @arg @ref LL_ADC_INJ_RANK_2
  4464. * @arg @ref LL_ADC_INJ_RANK_3
  4465. * @arg @ref LL_ADC_INJ_RANK_4
  4466. * @retval Value between Min_Data=0x000 and Max_Data=0xFFF
  4467. */
  4468. __STATIC_INLINE uint16_t LL_ADC_INJ_ReadConversionData12(ADC_TypeDef *ADCx, uint32_t Rank)
  4469. {
  4470. register uint32_t *preg = __ADC_PTR_REG_OFFSET(ADCx->JDR1, __ADC_MASK_SHIFT(Rank, ADC_INJ_JDRX_REGOFFSET_MASK));
  4471. return (uint16_t)(READ_BIT(*preg,
  4472. ADC_JDR1_JDATA)
  4473. );
  4474. }
  4475. /**
  4476. * @brief Get ADC group injected conversion data, range fit for
  4477. * ADC resolution 10 bits.
  4478. * @note For devices with feature oversampling: Oversampling
  4479. * can increase data width, function for extended range
  4480. * may be needed: @ref LL_ADC_INJ_ReadConversionData32.
  4481. * @rmtoll JDR1 JDATA LL_ADC_INJ_ReadConversionData10\n
  4482. * JDR2 JDATA LL_ADC_INJ_ReadConversionData10\n
  4483. * JDR3 JDATA LL_ADC_INJ_ReadConversionData10\n
  4484. * JDR4 JDATA LL_ADC_INJ_ReadConversionData10
  4485. * @param ADCx ADC instance
  4486. * @param Rank This parameter can be one of the following values:
  4487. * @arg @ref LL_ADC_INJ_RANK_1
  4488. * @arg @ref LL_ADC_INJ_RANK_2
  4489. * @arg @ref LL_ADC_INJ_RANK_3
  4490. * @arg @ref LL_ADC_INJ_RANK_4
  4491. * @retval Value between Min_Data=0x000 and Max_Data=0x3FF
  4492. */
  4493. __STATIC_INLINE uint16_t LL_ADC_INJ_ReadConversionData10(ADC_TypeDef *ADCx, uint32_t Rank)
  4494. {
  4495. register uint32_t *preg = __ADC_PTR_REG_OFFSET(ADCx->JDR1, __ADC_MASK_SHIFT(Rank, ADC_INJ_JDRX_REGOFFSET_MASK));
  4496. return (uint16_t)(READ_BIT(*preg,
  4497. ADC_JDR1_JDATA)
  4498. );
  4499. }
  4500. /**
  4501. * @brief Get ADC group injected conversion data, range fit for
  4502. * ADC resolution 8 bits.
  4503. * @note For devices with feature oversampling: Oversampling
  4504. * can increase data width, function for extended range
  4505. * may be needed: @ref LL_ADC_INJ_ReadConversionData32.
  4506. * @rmtoll JDR1 JDATA LL_ADC_INJ_ReadConversionData8\n
  4507. * JDR2 JDATA LL_ADC_INJ_ReadConversionData8\n
  4508. * JDR3 JDATA LL_ADC_INJ_ReadConversionData8\n
  4509. * JDR4 JDATA LL_ADC_INJ_ReadConversionData8
  4510. * @param ADCx ADC instance
  4511. * @param Rank This parameter can be one of the following values:
  4512. * @arg @ref LL_ADC_INJ_RANK_1
  4513. * @arg @ref LL_ADC_INJ_RANK_2
  4514. * @arg @ref LL_ADC_INJ_RANK_3
  4515. * @arg @ref LL_ADC_INJ_RANK_4
  4516. * @retval Value between Min_Data=0x00 and Max_Data=0xFF
  4517. */
  4518. __STATIC_INLINE uint8_t LL_ADC_INJ_ReadConversionData8(ADC_TypeDef *ADCx, uint32_t Rank)
  4519. {
  4520. register uint32_t *preg = __ADC_PTR_REG_OFFSET(ADCx->JDR1, __ADC_MASK_SHIFT(Rank, ADC_INJ_JDRX_REGOFFSET_MASK));
  4521. return (uint8_t)(READ_BIT(*preg,
  4522. ADC_JDR1_JDATA)
  4523. );
  4524. }
  4525. /**
  4526. * @brief Get ADC group injected conversion data, range fit for
  4527. * ADC resolution 6 bits.
  4528. * @note For devices with feature oversampling: Oversampling
  4529. * can increase data width, function for extended range
  4530. * may be needed: @ref LL_ADC_INJ_ReadConversionData32.
  4531. * @rmtoll JDR1 JDATA LL_ADC_INJ_ReadConversionData6\n
  4532. * JDR2 JDATA LL_ADC_INJ_ReadConversionData6\n
  4533. * JDR3 JDATA LL_ADC_INJ_ReadConversionData6\n
  4534. * JDR4 JDATA LL_ADC_INJ_ReadConversionData6
  4535. * @param ADCx ADC instance
  4536. * @param Rank This parameter can be one of the following values:
  4537. * @arg @ref LL_ADC_INJ_RANK_1
  4538. * @arg @ref LL_ADC_INJ_RANK_2
  4539. * @arg @ref LL_ADC_INJ_RANK_3
  4540. * @arg @ref LL_ADC_INJ_RANK_4
  4541. * @retval Value between Min_Data=0x00 and Max_Data=0x3F
  4542. */
  4543. __STATIC_INLINE uint8_t LL_ADC_INJ_ReadConversionData6(ADC_TypeDef *ADCx, uint32_t Rank)
  4544. {
  4545. register uint32_t *preg = __ADC_PTR_REG_OFFSET(ADCx->JDR1, __ADC_MASK_SHIFT(Rank, ADC_INJ_JDRX_REGOFFSET_MASK));
  4546. return (uint8_t)(READ_BIT(*preg,
  4547. ADC_JDR1_JDATA)
  4548. );
  4549. }
  4550. /**
  4551. * @}
  4552. */
  4553. /** @defgroup ADC_LL_EF_FLAG_Management ADC flag management
  4554. * @{
  4555. */
  4556. /**
  4557. * @brief Get flag ADC ready.
  4558. * @rmtoll SR ADONS LL_ADC_IsActiveFlag_ADRDY
  4559. * @param ADCx ADC instance
  4560. * @retval State of bit (1 or 0).
  4561. */
  4562. __STATIC_INLINE uint32_t LL_ADC_IsActiveFlag_ADRDY(ADC_TypeDef *ADCx)
  4563. {
  4564. return (READ_BIT(ADCx->SR, LL_ADC_FLAG_ADRDY) == (LL_ADC_FLAG_ADRDY));
  4565. }
  4566. /**
  4567. * @brief Get flag ADC group regular end of unitary conversion
  4568. * or end of sequence conversions, depending on
  4569. * ADC configuration.
  4570. * @note To configure flag of end of conversion,
  4571. * use function @ref LL_ADC_REG_SetFlagEndOfConversion().
  4572. * @rmtoll SR EOC LL_ADC_IsActiveFlag_EOCS
  4573. * @param ADCx ADC instance
  4574. * @retval State of bit (1 or 0).
  4575. */
  4576. __STATIC_INLINE uint32_t LL_ADC_IsActiveFlag_EOCS(ADC_TypeDef *ADCx)
  4577. {
  4578. return (READ_BIT(ADCx->SR, LL_ADC_FLAG_EOCS) == (LL_ADC_FLAG_EOCS));
  4579. }
  4580. /**
  4581. * @brief Get flag ADC group regular overrun.
  4582. * @rmtoll SR OVR LL_ADC_IsActiveFlag_OVR
  4583. * @param ADCx ADC instance
  4584. * @retval State of bit (1 or 0).
  4585. */
  4586. __STATIC_INLINE uint32_t LL_ADC_IsActiveFlag_OVR(ADC_TypeDef *ADCx)
  4587. {
  4588. return (READ_BIT(ADCx->SR, LL_ADC_FLAG_OVR) == (LL_ADC_FLAG_OVR));
  4589. }
  4590. /**
  4591. * @brief Get flag ADC group injected end of sequence conversions.
  4592. * @rmtoll SR JEOC LL_ADC_IsActiveFlag_JEOS
  4593. * @param ADCx ADC instance
  4594. * @retval State of bit (1 or 0).
  4595. */
  4596. __STATIC_INLINE uint32_t LL_ADC_IsActiveFlag_JEOS(ADC_TypeDef *ADCx)
  4597. {
  4598. /* Note: on this STM32 serie, there is no flag ADC group injected */
  4599. /* end of unitary conversion. */
  4600. /* Flag noted as "JEOC" is corresponding to flag "JEOS" */
  4601. /* in other STM32 families). */
  4602. return (READ_BIT(ADCx->SR, LL_ADC_FLAG_JEOS) == (LL_ADC_FLAG_JEOS));
  4603. }
  4604. /**
  4605. * @brief Get flag ADC analog watchdog 1 flag
  4606. * @rmtoll SR AWD LL_ADC_IsActiveFlag_AWD1
  4607. * @param ADCx ADC instance
  4608. * @retval State of bit (1 or 0).
  4609. */
  4610. __STATIC_INLINE uint32_t LL_ADC_IsActiveFlag_AWD1(ADC_TypeDef *ADCx)
  4611. {
  4612. return (READ_BIT(ADCx->SR, LL_ADC_FLAG_AWD1) == (LL_ADC_FLAG_AWD1));
  4613. }
  4614. /**
  4615. * @brief Clear flag ADC group regular end of unitary conversion
  4616. * or end of sequence conversions, depending on
  4617. * ADC configuration.
  4618. * @note To configure flag of end of conversion,
  4619. * use function @ref LL_ADC_REG_SetFlagEndOfConversion().
  4620. * @rmtoll SR EOC LL_ADC_ClearFlag_EOCS
  4621. * @param ADCx ADC instance
  4622. * @retval None
  4623. */
  4624. __STATIC_INLINE void LL_ADC_ClearFlag_EOCS(ADC_TypeDef *ADCx)
  4625. {
  4626. WRITE_REG(ADCx->SR, ~LL_ADC_FLAG_EOCS);
  4627. }
  4628. /**
  4629. * @brief Clear flag ADC group regular overrun.
  4630. * @rmtoll SR OVR LL_ADC_ClearFlag_OVR
  4631. * @param ADCx ADC instance
  4632. * @retval None
  4633. */
  4634. __STATIC_INLINE void LL_ADC_ClearFlag_OVR(ADC_TypeDef *ADCx)
  4635. {
  4636. WRITE_REG(ADCx->SR, ~LL_ADC_FLAG_OVR);
  4637. }
  4638. /**
  4639. * @brief Clear flag ADC group injected end of sequence conversions.
  4640. * @rmtoll SR JEOC LL_ADC_ClearFlag_JEOS
  4641. * @param ADCx ADC instance
  4642. * @retval None
  4643. */
  4644. __STATIC_INLINE void LL_ADC_ClearFlag_JEOS(ADC_TypeDef *ADCx)
  4645. {
  4646. /* Note: on this STM32 serie, there is no flag ADC group injected */
  4647. /* end of unitary conversion. */
  4648. /* Flag noted as "JEOC" is corresponding to flag "JEOS" */
  4649. /* in other STM32 families). */
  4650. WRITE_REG(ADCx->SR, ~LL_ADC_FLAG_JEOS);
  4651. }
  4652. /**
  4653. * @brief Clear flag ADC analog watchdog 1.
  4654. * @rmtoll SR AWD LL_ADC_ClearFlag_AWD1
  4655. * @param ADCx ADC instance
  4656. * @retval None
  4657. */
  4658. __STATIC_INLINE void LL_ADC_ClearFlag_AWD1(ADC_TypeDef *ADCx)
  4659. {
  4660. WRITE_REG(ADCx->SR, ~LL_ADC_FLAG_AWD1);
  4661. }
  4662. /**
  4663. * @}
  4664. */
  4665. /** @defgroup ADC_LL_EF_IT_Management ADC IT management
  4666. * @{
  4667. */
  4668. /**
  4669. * @brief Enable interruption ADC group regular end of unitary conversion
  4670. * or end of sequence conversions, depending on
  4671. * ADC configuration.
  4672. * @note To configure flag of end of conversion,
  4673. * use function @ref LL_ADC_REG_SetFlagEndOfConversion().
  4674. * @rmtoll CR1 EOCIE LL_ADC_EnableIT_EOCS
  4675. * @param ADCx ADC instance
  4676. * @retval None
  4677. */
  4678. __STATIC_INLINE void LL_ADC_EnableIT_EOCS(ADC_TypeDef *ADCx)
  4679. {
  4680. SET_BIT(ADCx->CR1, LL_ADC_IT_EOCS);
  4681. }
  4682. /**
  4683. * @brief Enable ADC group regular interruption overrun.
  4684. * @rmtoll CR1 OVRIE LL_ADC_EnableIT_OVR
  4685. * @param ADCx ADC instance
  4686. * @retval None
  4687. */
  4688. __STATIC_INLINE void LL_ADC_EnableIT_OVR(ADC_TypeDef *ADCx)
  4689. {
  4690. SET_BIT(ADCx->CR1, LL_ADC_IT_OVR);
  4691. }
  4692. /**
  4693. * @brief Enable interruption ADC group injected end of sequence conversions.
  4694. * @rmtoll CR1 JEOCIE LL_ADC_EnableIT_JEOS
  4695. * @param ADCx ADC instance
  4696. * @retval None
  4697. */
  4698. __STATIC_INLINE void LL_ADC_EnableIT_JEOS(ADC_TypeDef *ADCx)
  4699. {
  4700. /* Note: on this STM32 serie, there is no flag ADC group injected */
  4701. /* end of unitary conversion. */
  4702. /* Flag noted as "JEOC" is corresponding to flag "JEOS" */
  4703. /* in other STM32 families). */
  4704. SET_BIT(ADCx->CR1, LL_ADC_IT_JEOS);
  4705. }
  4706. /**
  4707. * @brief Enable interruption ADC analog watchdog 1.
  4708. * @rmtoll CR1 AWDIE LL_ADC_EnableIT_AWD1
  4709. * @param ADCx ADC instance
  4710. * @retval None
  4711. */
  4712. __STATIC_INLINE void LL_ADC_EnableIT_AWD1(ADC_TypeDef *ADCx)
  4713. {
  4714. SET_BIT(ADCx->CR1, LL_ADC_IT_AWD1);
  4715. }
  4716. /**
  4717. * @brief Disable interruption ADC group regular end of unitary conversion
  4718. * or end of sequence conversions, depending on
  4719. * ADC configuration.
  4720. * @note To configure flag of end of conversion,
  4721. * use function @ref LL_ADC_REG_SetFlagEndOfConversion().
  4722. * @rmtoll CR1 EOCIE LL_ADC_DisableIT_EOCS
  4723. * @param ADCx ADC instance
  4724. * @retval None
  4725. */
  4726. __STATIC_INLINE void LL_ADC_DisableIT_EOCS(ADC_TypeDef *ADCx)
  4727. {
  4728. CLEAR_BIT(ADCx->CR1, LL_ADC_IT_EOCS);
  4729. }
  4730. /**
  4731. * @brief Disable interruption ADC group regular overrun.
  4732. * @rmtoll CR1 OVRIE LL_ADC_DisableIT_OVR
  4733. * @param ADCx ADC instance
  4734. * @retval None
  4735. */
  4736. __STATIC_INLINE void LL_ADC_DisableIT_OVR(ADC_TypeDef *ADCx)
  4737. {
  4738. CLEAR_BIT(ADCx->CR1, LL_ADC_IT_OVR);
  4739. }
  4740. /**
  4741. * @brief Disable interruption ADC group injected end of sequence conversions.
  4742. * @rmtoll CR1 JEOCIE LL_ADC_EnableIT_JEOS
  4743. * @param ADCx ADC instance
  4744. * @retval None
  4745. */
  4746. __STATIC_INLINE void LL_ADC_DisableIT_JEOS(ADC_TypeDef *ADCx)
  4747. {
  4748. /* Note: on this STM32 serie, there is no flag ADC group injected */
  4749. /* end of unitary conversion. */
  4750. /* Flag noted as "JEOC" is corresponding to flag "JEOS" */
  4751. /* in other STM32 families). */
  4752. CLEAR_BIT(ADCx->CR1, LL_ADC_IT_JEOS);
  4753. }
  4754. /**
  4755. * @brief Disable interruption ADC analog watchdog 1.
  4756. * @rmtoll CR1 AWDIE LL_ADC_EnableIT_AWD1
  4757. * @param ADCx ADC instance
  4758. * @retval None
  4759. */
  4760. __STATIC_INLINE void LL_ADC_DisableIT_AWD1(ADC_TypeDef *ADCx)
  4761. {
  4762. CLEAR_BIT(ADCx->CR1, LL_ADC_IT_AWD1);
  4763. }
  4764. /**
  4765. * @brief Get state of interruption ADC group regular end of unitary conversion
  4766. * or end of sequence conversions, depending on
  4767. * ADC configuration.
  4768. * @note To configure flag of end of conversion,
  4769. * use function @ref LL_ADC_REG_SetFlagEndOfConversion().
  4770. * (0: interrupt disabled, 1: interrupt enabled)
  4771. * @rmtoll CR1 EOCIE LL_ADC_IsEnabledIT_EOCS
  4772. * @param ADCx ADC instance
  4773. * @retval State of bit (1 or 0).
  4774. */
  4775. __STATIC_INLINE uint32_t LL_ADC_IsEnabledIT_EOCS(ADC_TypeDef *ADCx)
  4776. {
  4777. return (READ_BIT(ADCx->CR1, LL_ADC_IT_EOCS) == (LL_ADC_IT_EOCS));
  4778. }
  4779. /**
  4780. * @brief Get state of interruption ADC group regular overrun
  4781. * (0: interrupt disabled, 1: interrupt enabled).
  4782. * @rmtoll CR1 OVRIE LL_ADC_IsEnabledIT_OVR
  4783. * @param ADCx ADC instance
  4784. * @retval State of bit (1 or 0).
  4785. */
  4786. __STATIC_INLINE uint32_t LL_ADC_IsEnabledIT_OVR(ADC_TypeDef *ADCx)
  4787. {
  4788. return (READ_BIT(ADCx->CR1, LL_ADC_IT_OVR) == (LL_ADC_IT_OVR));
  4789. }
  4790. /**
  4791. * @brief Get state of interruption ADC group injected end of sequence conversions
  4792. * (0: interrupt disabled, 1: interrupt enabled).
  4793. * @rmtoll CR1 JEOCIE LL_ADC_EnableIT_JEOS
  4794. * @param ADCx ADC instance
  4795. * @retval State of bit (1 or 0).
  4796. */
  4797. __STATIC_INLINE uint32_t LL_ADC_IsEnabledIT_JEOS(ADC_TypeDef *ADCx)
  4798. {
  4799. /* Note: on this STM32 serie, there is no flag ADC group injected */
  4800. /* end of unitary conversion. */
  4801. /* Flag noted as "JEOC" is corresponding to flag "JEOS" */
  4802. /* in other STM32 families). */
  4803. return (READ_BIT(ADCx->CR1, LL_ADC_IT_JEOS) == (LL_ADC_IT_JEOS));
  4804. }
  4805. /**
  4806. * @brief Get state of interruption ADC analog watchdog 1
  4807. * (0: interrupt disabled, 1: interrupt enabled).
  4808. * @rmtoll CR1 AWDIE LL_ADC_EnableIT_AWD1
  4809. * @param ADCx ADC instance
  4810. * @retval State of bit (1 or 0).
  4811. */
  4812. __STATIC_INLINE uint32_t LL_ADC_IsEnabledIT_AWD1(ADC_TypeDef *ADCx)
  4813. {
  4814. return (READ_BIT(ADCx->CR1, LL_ADC_IT_AWD1) == (LL_ADC_IT_AWD1));
  4815. }
  4816. /**
  4817. * @}
  4818. */
  4819. #if defined(USE_FULL_LL_DRIVER)
  4820. /** @defgroup ADC_LL_EF_Init Initialization and de-initialization functions
  4821. * @{
  4822. */
  4823. /* Initialization of some features of ADC common parameters and multimode */
  4824. ErrorStatus LL_ADC_CommonDeInit(ADC_Common_TypeDef *ADCxy_COMMON);
  4825. ErrorStatus LL_ADC_CommonInit(ADC_Common_TypeDef *ADCxy_COMMON, LL_ADC_CommonInitTypeDef *ADC_CommonInitStruct);
  4826. void LL_ADC_CommonStructInit(LL_ADC_CommonInitTypeDef *ADC_CommonInitStruct);
  4827. /* De-initialization of ADC instance, ADC group regular and ADC group injected */
  4828. /* (availability of ADC group injected depends on STM32 families) */
  4829. ErrorStatus LL_ADC_DeInit(ADC_TypeDef *ADCx);
  4830. /* Initialization of some features of ADC instance */
  4831. ErrorStatus LL_ADC_Init(ADC_TypeDef *ADCx, LL_ADC_InitTypeDef *ADC_InitStruct);
  4832. void LL_ADC_StructInit(LL_ADC_InitTypeDef *ADC_InitStruct);
  4833. /* Initialization of some features of ADC instance and ADC group regular */
  4834. ErrorStatus LL_ADC_REG_Init(ADC_TypeDef *ADCx, LL_ADC_REG_InitTypeDef *ADC_REG_InitStruct);
  4835. void LL_ADC_REG_StructInit(LL_ADC_REG_InitTypeDef *ADC_REG_InitStruct);
  4836. /* Initialization of some features of ADC instance and ADC group injected */
  4837. ErrorStatus LL_ADC_INJ_Init(ADC_TypeDef *ADCx, LL_ADC_INJ_InitTypeDef *ADC_INJ_InitStruct);
  4838. void LL_ADC_INJ_StructInit(LL_ADC_INJ_InitTypeDef *ADC_INJ_InitStruct);
  4839. /**
  4840. * @}
  4841. */
  4842. #endif /* USE_FULL_LL_DRIVER */
  4843. /**
  4844. * @}
  4845. */
  4846. /**
  4847. * @}
  4848. */
  4849. #endif /* ADC1 */
  4850. /**
  4851. * @}
  4852. */
  4853. #ifdef __cplusplus
  4854. }
  4855. #endif
  4856. #endif /* __STM32L1xx_LL_ADC_H */
  4857. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/