stm32l4xx_ll_adc.h 448 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244
  1. /**
  2. ******************************************************************************
  3. * @file stm32l4xx_ll_adc.h
  4. * @author MCD Application Team
  5. * @brief Header file of ADC LL module.
  6. ******************************************************************************
  7. * @attention
  8. *
  9. * Copyright (c) 2017 STMicroelectronics.
  10. * All rights reserved.
  11. *
  12. * This software is licensed under terms that can be found in the LICENSE file
  13. * in the root directory of this software component.
  14. * If no LICENSE file comes with this software, it is provided AS-IS.
  15. *
  16. ******************************************************************************
  17. */
  18. /* Define to prevent recursive inclusion -------------------------------------*/
  19. #ifndef STM32L4xx_LL_ADC_H
  20. #define STM32L4xx_LL_ADC_H
  21. #ifdef __cplusplus
  22. extern "C" {
  23. #endif
  24. /* Includes ------------------------------------------------------------------*/
  25. #include "stm32l4xx.h"
  26. /** @addtogroup STM32L4xx_LL_Driver
  27. * @{
  28. */
  29. #if defined (ADC1) || defined (ADC2) || defined (ADC3)
  30. /** @defgroup ADC_LL ADC
  31. * @{
  32. */
  33. /* Private types -------------------------------------------------------------*/
  34. /* Private variables ---------------------------------------------------------*/
  35. /* Private constants ---------------------------------------------------------*/
  36. /** @defgroup ADC_LL_Private_Constants ADC Private Constants
  37. * @{
  38. */
  39. /* Internal mask for ADC group regular sequencer: */
  40. /* To select into literal LL_ADC_REG_RANK_x the relevant bits for: */
  41. /* - sequencer register offset */
  42. /* - sequencer rank bits position into the selected register */
  43. /* Internal register offset for ADC group regular sequencer configuration */
  44. /* (offset placed into a spare area of literal definition) */
  45. #define ADC_SQR1_REGOFFSET (0x00000000UL)
  46. #define ADC_SQR2_REGOFFSET (0x00000100UL)
  47. #define ADC_SQR3_REGOFFSET (0x00000200UL)
  48. #define ADC_SQR4_REGOFFSET (0x00000300UL)
  49. #define ADC_REG_SQRX_REGOFFSET_MASK (ADC_SQR1_REGOFFSET | ADC_SQR2_REGOFFSET \
  50. | ADC_SQR3_REGOFFSET | ADC_SQR4_REGOFFSET)
  51. #define ADC_SQRX_REGOFFSET_POS (8UL) /* Position of bits ADC_SQRx_REGOFFSET in ADC_REG_SQRX_REGOFFSET_MASK*/
  52. #define ADC_REG_RANK_ID_SQRX_MASK (ADC_CHANNEL_ID_NUMBER_MASK_POSBIT0)
  53. /* Definition of ADC group regular sequencer bits information to be inserted */
  54. /* into ADC group regular sequencer ranks literals definition. */
  55. #define ADC_REG_RANK_1_SQRX_BITOFFSET_POS ( 6UL) /* Equivalent to bitfield "ADC_SQR1_SQ1" position in register */
  56. #define ADC_REG_RANK_2_SQRX_BITOFFSET_POS (12UL) /* Equivalent to bitfield "ADC_SQR1_SQ2" position in register */
  57. #define ADC_REG_RANK_3_SQRX_BITOFFSET_POS (18UL) /* Equivalent to bitfield "ADC_SQR1_SQ3" position in register */
  58. #define ADC_REG_RANK_4_SQRX_BITOFFSET_POS (24UL) /* Equivalent to bitfield "ADC_SQR1_SQ4" position in register */
  59. #define ADC_REG_RANK_5_SQRX_BITOFFSET_POS ( 0UL) /* Equivalent to bitfield "ADC_SQR2_SQ5" position in register */
  60. #define ADC_REG_RANK_6_SQRX_BITOFFSET_POS ( 6UL) /* Equivalent to bitfield "ADC_SQR2_SQ6" position in register */
  61. #define ADC_REG_RANK_7_SQRX_BITOFFSET_POS (12UL) /* Equivalent to bitfield "ADC_SQR2_SQ7" position in register */
  62. #define ADC_REG_RANK_8_SQRX_BITOFFSET_POS (18UL) /* Equivalent to bitfield "ADC_SQR2_SQ8" position in register */
  63. #define ADC_REG_RANK_9_SQRX_BITOFFSET_POS (24UL) /* Equivalent to bitfield "ADC_SQR2_SQ9" position in register */
  64. #define ADC_REG_RANK_10_SQRX_BITOFFSET_POS ( 0UL) /* Equivalent to bitfield "ADC_SQR3_SQ10" position in register */
  65. #define ADC_REG_RANK_11_SQRX_BITOFFSET_POS ( 6UL) /* Equivalent to bitfield "ADC_SQR3_SQ11" position in register */
  66. #define ADC_REG_RANK_12_SQRX_BITOFFSET_POS (12UL) /* Equivalent to bitfield "ADC_SQR3_SQ12" position in register */
  67. #define ADC_REG_RANK_13_SQRX_BITOFFSET_POS (18UL) /* Equivalent to bitfield "ADC_SQR3_SQ13" position in register */
  68. #define ADC_REG_RANK_14_SQRX_BITOFFSET_POS (24UL) /* Equivalent to bitfield "ADC_SQR3_SQ14" position in register */
  69. #define ADC_REG_RANK_15_SQRX_BITOFFSET_POS ( 0UL) /* Equivalent to bitfield "ADC_SQR4_SQ15" position in register */
  70. #define ADC_REG_RANK_16_SQRX_BITOFFSET_POS ( 6UL) /* Equivalent to bitfield "ADC_SQR4_SQ16" position in register */
  71. /* Internal mask for ADC group injected sequencer: */
  72. /* To select into literal LL_ADC_INJ_RANK_x the relevant bits for: */
  73. /* - data register offset */
  74. /* - sequencer rank bits position into the selected register */
  75. /* Internal register offset for ADC group injected data register */
  76. /* (offset placed into a spare area of literal definition) */
  77. #define ADC_JDR1_REGOFFSET (0x00000000UL)
  78. #define ADC_JDR2_REGOFFSET (0x00000100UL)
  79. #define ADC_JDR3_REGOFFSET (0x00000200UL)
  80. #define ADC_JDR4_REGOFFSET (0x00000300UL)
  81. #define ADC_INJ_JDRX_REGOFFSET_MASK (ADC_JDR1_REGOFFSET | ADC_JDR2_REGOFFSET \
  82. | ADC_JDR3_REGOFFSET | ADC_JDR4_REGOFFSET)
  83. #define ADC_INJ_RANK_ID_JSQR_MASK (ADC_CHANNEL_ID_NUMBER_MASK_POSBIT0)
  84. #define ADC_JDRX_REGOFFSET_POS (8UL) /* Position of bits ADC_JDRx_REGOFFSET in ADC_INJ_JDRX_REGOFFSET_MASK*/
  85. /* Definition of ADC group injected sequencer bits information to be inserted */
  86. /* into ADC group injected sequencer ranks literals definition. */
  87. #define ADC_INJ_RANK_1_JSQR_BITOFFSET_POS ( 8UL) /* Equivalent to bitfield "ADC_JSQR_JSQ1" position in register */
  88. #define ADC_INJ_RANK_2_JSQR_BITOFFSET_POS (14UL) /* Equivalent to bitfield "ADC_JSQR_JSQ2" position in register */
  89. #define ADC_INJ_RANK_3_JSQR_BITOFFSET_POS (20UL) /* Equivalent to bitfield "ADC_JSQR_JSQ3" position in register */
  90. #define ADC_INJ_RANK_4_JSQR_BITOFFSET_POS (26UL) /* Equivalent to bitfield "ADC_JSQR_JSQ4" position in register */
  91. /* Internal mask for ADC group regular trigger: */
  92. /* To select into literal LL_ADC_REG_TRIG_x the relevant bits for: */
  93. /* - regular trigger source */
  94. /* - regular trigger edge */
  95. #define ADC_REG_TRIG_EXT_EDGE_DEFAULT (ADC_CFGR_EXTEN_0) /* Trigger edge set to rising edge (default setting for
  96. compatibility with some ADC on other STM32 series
  97. having this setting set by HW default value) */
  98. /* Mask containing trigger source masks for each of possible */
  99. /* trigger edge selection duplicated with shifts [0; 4; 8; 12] */
  100. /* corresponding to {SW start; ext trigger; ext trigger; ext trigger}. */
  101. #define ADC_REG_TRIG_SOURCE_MASK (((LL_ADC_REG_TRIG_SOFTWARE & ADC_CFGR_EXTSEL) << (4U * 0UL)) | \
  102. ((ADC_CFGR_EXTSEL) << (4U * 1UL)) | \
  103. ((ADC_CFGR_EXTSEL) << (4U * 2UL)) | \
  104. ((ADC_CFGR_EXTSEL) << (4U * 3UL)) )
  105. /* Mask containing trigger edge masks for each of possible */
  106. /* trigger edge selection duplicated with shifts [0; 4; 8; 12] */
  107. /* corresponding to {SW start; ext trigger; ext trigger; ext trigger}. */
  108. #define ADC_REG_TRIG_EDGE_MASK (((LL_ADC_REG_TRIG_SOFTWARE & ADC_CFGR_EXTEN) << (4U * 0UL)) | \
  109. ((ADC_REG_TRIG_EXT_EDGE_DEFAULT) << (4U * 1UL)) | \
  110. ((ADC_REG_TRIG_EXT_EDGE_DEFAULT) << (4U * 2UL)) | \
  111. ((ADC_REG_TRIG_EXT_EDGE_DEFAULT) << (4U * 3UL)) )
  112. /* Definition of ADC group regular trigger bits information. */
  113. #define ADC_REG_TRIG_EXTSEL_BITOFFSET_POS ( 6UL) /* Equivalent to bitfield "ADC_CFGR_EXTSEL" position in register */
  114. #define ADC_REG_TRIG_EXTEN_BITOFFSET_POS (10UL) /* Equivalent to bitfield "ADC_CFGR_EXTEN" position in register */
  115. /* Internal mask for ADC group injected trigger: */
  116. /* To select into literal LL_ADC_INJ_TRIG_x the relevant bits for: */
  117. /* - injected trigger source */
  118. /* - injected trigger edge */
  119. #define ADC_INJ_TRIG_EXT_EDGE_DEFAULT (ADC_JSQR_JEXTEN_0) /* Trigger edge set to rising edge (default setting for
  120. compatibility with some ADC on other STM32 series
  121. having this setting set by HW default value) */
  122. /* Mask containing trigger source masks for each of possible */
  123. /* trigger edge selection duplicated with shifts [0; 4; 8; 12] */
  124. /* corresponding to {SW start; ext trigger; ext trigger; ext trigger}. */
  125. #define ADC_INJ_TRIG_SOURCE_MASK (((LL_ADC_INJ_TRIG_SOFTWARE & ADC_JSQR_JEXTSEL) << (4U * 0UL)) | \
  126. ((ADC_JSQR_JEXTSEL) << (4U * 1UL)) | \
  127. ((ADC_JSQR_JEXTSEL) << (4U * 2UL)) | \
  128. ((ADC_JSQR_JEXTSEL) << (4U * 3UL)) )
  129. /* Mask containing trigger edge masks for each of possible */
  130. /* trigger edge selection duplicated with shifts [0; 4; 8; 12] */
  131. /* corresponding to {SW start; ext trigger; ext trigger; ext trigger}. */
  132. #define ADC_INJ_TRIG_EDGE_MASK (((LL_ADC_INJ_TRIG_SOFTWARE & ADC_JSQR_JEXTEN) << (4U * 0UL)) | \
  133. ((ADC_INJ_TRIG_EXT_EDGE_DEFAULT) << (4U * 1UL)) | \
  134. ((ADC_INJ_TRIG_EXT_EDGE_DEFAULT) << (4U * 2UL)) | \
  135. ((ADC_INJ_TRIG_EXT_EDGE_DEFAULT) << (4U * 3UL)) )
  136. /* Definition of ADC group injected trigger bits information. */
  137. #define ADC_INJ_TRIG_EXTSEL_BITOFFSET_POS ( 2UL) /* Equivalent to bitfield "ADC_JSQR_JEXTSEL" position in register */
  138. #define ADC_INJ_TRIG_EXTEN_BITOFFSET_POS ( 6UL) /* Equivalent to bitfield "ADC_JSQR_JEXTEN" position in register */
  139. /* Internal mask for ADC channel: */
  140. /* To select into literal LL_ADC_CHANNEL_x the relevant bits for: */
  141. /* - channel identifier defined by number */
  142. /* - channel identifier defined by bitfield */
  143. /* - channel differentiation between external channels (connected to */
  144. /* GPIO pins) and internal channels (connected to internal paths) */
  145. /* - channel sampling time defined by SMPRx register offset */
  146. /* and SMPx bits positions into SMPRx register */
  147. #define ADC_CHANNEL_ID_NUMBER_MASK (ADC_CFGR_AWD1CH)
  148. #define ADC_CHANNEL_ID_BITFIELD_MASK (ADC_AWD2CR_AWD2CH)
  149. #define ADC_CHANNEL_ID_NUMBER_BITOFFSET_POS (26UL) /* Equivalent to bitfield "ADC_CHANNEL_ID_NUMBER_MASK"
  150. position in register */
  151. #define ADC_CHANNEL_ID_MASK (ADC_CHANNEL_ID_NUMBER_MASK | ADC_CHANNEL_ID_BITFIELD_MASK \
  152. | ADC_CHANNEL_ID_INTERNAL_CH_MASK)
  153. /* Equivalent mask of ADC_CHANNEL_NUMBER_MASK aligned on register LSB (bit 0) */
  154. #define ADC_CHANNEL_ID_NUMBER_MASK_POSBIT0 (ADC_SQR2_SQ5) /* Equivalent to shift: (ADC_CHANNEL_NUMBER_MASK
  155. >> [Position of bitfield "ADC_CHANNEL_NUMBER_MASK" in register]) */
  156. /* Channel differentiation between external and internal channels */
  157. #define ADC_CHANNEL_ID_INTERNAL_CH (0x80000000UL) /* Marker of internal channel */
  158. #define ADC_CHANNEL_ID_INTERNAL_CH_2 (0x00080000UL) /* Marker of internal channel for other ADC instances, in case
  159. of different ADC internal channels mapped on same channel
  160. number on different ADC instances */
  161. #define ADC_CHANNEL_ID_INTERNAL_CH_MASK (ADC_CHANNEL_ID_INTERNAL_CH | ADC_CHANNEL_ID_INTERNAL_CH_2)
  162. /* Internal register offset for ADC channel sampling time configuration */
  163. /* (offset placed into a spare area of literal definition) */
  164. #define ADC_SMPR1_REGOFFSET (0x00000000UL)
  165. #define ADC_SMPR2_REGOFFSET (0x02000000UL)
  166. #define ADC_CHANNEL_SMPRX_REGOFFSET_MASK (ADC_SMPR1_REGOFFSET | ADC_SMPR2_REGOFFSET)
  167. #define ADC_SMPRX_REGOFFSET_POS (25UL) /* Position of bits ADC_SMPRx_REGOFFSET
  168. in ADC_CHANNEL_SMPRX_REGOFFSET_MASK */
  169. #define ADC_CHANNEL_SMPx_BITOFFSET_MASK (0x01F00000UL)
  170. #define ADC_CHANNEL_SMPx_BITOFFSET_POS (20UL) /* Equivalent to bitfield "ADC_CHANNEL_SMPx_BITOFFSET_MASK"
  171. position in register */
  172. /* Definition of channels ID number information to be inserted into */
  173. /* channels literals definition. */
  174. #define ADC_CHANNEL_0_NUMBER (0x00000000UL)
  175. #define ADC_CHANNEL_1_NUMBER (ADC_CFGR_AWD1CH_0)
  176. #define ADC_CHANNEL_2_NUMBER (ADC_CFGR_AWD1CH_1)
  177. #define ADC_CHANNEL_3_NUMBER (ADC_CFGR_AWD1CH_1 | ADC_CFGR_AWD1CH_0)
  178. #define ADC_CHANNEL_4_NUMBER (ADC_CFGR_AWD1CH_2)
  179. #define ADC_CHANNEL_5_NUMBER (ADC_CFGR_AWD1CH_2 | ADC_CFGR_AWD1CH_0)
  180. #define ADC_CHANNEL_6_NUMBER (ADC_CFGR_AWD1CH_2 | ADC_CFGR_AWD1CH_1)
  181. #define ADC_CHANNEL_7_NUMBER (ADC_CFGR_AWD1CH_2 | ADC_CFGR_AWD1CH_1 | ADC_CFGR_AWD1CH_0)
  182. #define ADC_CHANNEL_8_NUMBER (ADC_CFGR_AWD1CH_3)
  183. #define ADC_CHANNEL_9_NUMBER (ADC_CFGR_AWD1CH_3 | ADC_CFGR_AWD1CH_0)
  184. #define ADC_CHANNEL_10_NUMBER (ADC_CFGR_AWD1CH_3 | ADC_CFGR_AWD1CH_1)
  185. #define ADC_CHANNEL_11_NUMBER (ADC_CFGR_AWD1CH_3 | ADC_CFGR_AWD1CH_1 | ADC_CFGR_AWD1CH_0)
  186. #define ADC_CHANNEL_12_NUMBER (ADC_CFGR_AWD1CH_3 | ADC_CFGR_AWD1CH_2)
  187. #define ADC_CHANNEL_13_NUMBER (ADC_CFGR_AWD1CH_3 | ADC_CFGR_AWD1CH_2 | ADC_CFGR_AWD1CH_0)
  188. #define ADC_CHANNEL_14_NUMBER (ADC_CFGR_AWD1CH_3 | ADC_CFGR_AWD1CH_2 | ADC_CFGR_AWD1CH_1)
  189. #define ADC_CHANNEL_15_NUMBER (ADC_CFGR_AWD1CH_3 | ADC_CFGR_AWD1CH_2 | \
  190. ADC_CFGR_AWD1CH_1 | ADC_CFGR_AWD1CH_0)
  191. #define ADC_CHANNEL_16_NUMBER (ADC_CFGR_AWD1CH_4)
  192. #define ADC_CHANNEL_17_NUMBER (ADC_CFGR_AWD1CH_4 | ADC_CFGR_AWD1CH_0)
  193. #define ADC_CHANNEL_18_NUMBER (ADC_CFGR_AWD1CH_4 | ADC_CFGR_AWD1CH_1)
  194. /* Definition of channels ID bitfield information to be inserted into */
  195. /* channels literals definition. */
  196. #define ADC_CHANNEL_0_BITFIELD (ADC_AWD2CR_AWD2CH_0)
  197. #define ADC_CHANNEL_1_BITFIELD (ADC_AWD2CR_AWD2CH_1)
  198. #define ADC_CHANNEL_2_BITFIELD (ADC_AWD2CR_AWD2CH_2)
  199. #define ADC_CHANNEL_3_BITFIELD (ADC_AWD2CR_AWD2CH_3)
  200. #define ADC_CHANNEL_4_BITFIELD (ADC_AWD2CR_AWD2CH_4)
  201. #define ADC_CHANNEL_5_BITFIELD (ADC_AWD2CR_AWD2CH_5)
  202. #define ADC_CHANNEL_6_BITFIELD (ADC_AWD2CR_AWD2CH_6)
  203. #define ADC_CHANNEL_7_BITFIELD (ADC_AWD2CR_AWD2CH_7)
  204. #define ADC_CHANNEL_8_BITFIELD (ADC_AWD2CR_AWD2CH_8)
  205. #define ADC_CHANNEL_9_BITFIELD (ADC_AWD2CR_AWD2CH_9)
  206. #define ADC_CHANNEL_10_BITFIELD (ADC_AWD2CR_AWD2CH_10)
  207. #define ADC_CHANNEL_11_BITFIELD (ADC_AWD2CR_AWD2CH_11)
  208. #define ADC_CHANNEL_12_BITFIELD (ADC_AWD2CR_AWD2CH_12)
  209. #define ADC_CHANNEL_13_BITFIELD (ADC_AWD2CR_AWD2CH_13)
  210. #define ADC_CHANNEL_14_BITFIELD (ADC_AWD2CR_AWD2CH_14)
  211. #define ADC_CHANNEL_15_BITFIELD (ADC_AWD2CR_AWD2CH_15)
  212. #define ADC_CHANNEL_16_BITFIELD (ADC_AWD2CR_AWD2CH_16)
  213. #define ADC_CHANNEL_17_BITFIELD (ADC_AWD2CR_AWD2CH_17)
  214. #define ADC_CHANNEL_18_BITFIELD (ADC_AWD2CR_AWD2CH_18)
  215. /* Definition of channels sampling time information to be inserted into */
  216. /* channels literals definition. */
  217. /* Value shifted are equivalent to bitfield "ADC_SMPRx_SMPy" position */
  218. /* in register. */
  219. #define ADC_CHANNEL_0_SMP (ADC_SMPR1_REGOFFSET | (( 0UL) << ADC_CHANNEL_SMPx_BITOFFSET_POS))
  220. #define ADC_CHANNEL_1_SMP (ADC_SMPR1_REGOFFSET | (( 3UL) << ADC_CHANNEL_SMPx_BITOFFSET_POS))
  221. #define ADC_CHANNEL_2_SMP (ADC_SMPR1_REGOFFSET | (( 6UL) << ADC_CHANNEL_SMPx_BITOFFSET_POS))
  222. #define ADC_CHANNEL_3_SMP (ADC_SMPR1_REGOFFSET | (( 9UL) << ADC_CHANNEL_SMPx_BITOFFSET_POS))
  223. #define ADC_CHANNEL_4_SMP (ADC_SMPR1_REGOFFSET | ((12UL) << ADC_CHANNEL_SMPx_BITOFFSET_POS))
  224. #define ADC_CHANNEL_5_SMP (ADC_SMPR1_REGOFFSET | ((15UL) << ADC_CHANNEL_SMPx_BITOFFSET_POS))
  225. #define ADC_CHANNEL_6_SMP (ADC_SMPR1_REGOFFSET | ((18UL) << ADC_CHANNEL_SMPx_BITOFFSET_POS))
  226. #define ADC_CHANNEL_7_SMP (ADC_SMPR1_REGOFFSET | ((21UL) << ADC_CHANNEL_SMPx_BITOFFSET_POS))
  227. #define ADC_CHANNEL_8_SMP (ADC_SMPR1_REGOFFSET | ((24UL) << ADC_CHANNEL_SMPx_BITOFFSET_POS))
  228. #define ADC_CHANNEL_9_SMP (ADC_SMPR1_REGOFFSET | ((27UL) << ADC_CHANNEL_SMPx_BITOFFSET_POS))
  229. #define ADC_CHANNEL_10_SMP (ADC_SMPR2_REGOFFSET | (( 0UL) << ADC_CHANNEL_SMPx_BITOFFSET_POS))
  230. #define ADC_CHANNEL_11_SMP (ADC_SMPR2_REGOFFSET | (( 3UL) << ADC_CHANNEL_SMPx_BITOFFSET_POS))
  231. #define ADC_CHANNEL_12_SMP (ADC_SMPR2_REGOFFSET | (( 6UL) << ADC_CHANNEL_SMPx_BITOFFSET_POS))
  232. #define ADC_CHANNEL_13_SMP (ADC_SMPR2_REGOFFSET | (( 9UL) << ADC_CHANNEL_SMPx_BITOFFSET_POS))
  233. #define ADC_CHANNEL_14_SMP (ADC_SMPR2_REGOFFSET | ((12UL) << ADC_CHANNEL_SMPx_BITOFFSET_POS))
  234. #define ADC_CHANNEL_15_SMP (ADC_SMPR2_REGOFFSET | ((15UL) << ADC_CHANNEL_SMPx_BITOFFSET_POS))
  235. #define ADC_CHANNEL_16_SMP (ADC_SMPR2_REGOFFSET | ((18UL) << ADC_CHANNEL_SMPx_BITOFFSET_POS))
  236. #define ADC_CHANNEL_17_SMP (ADC_SMPR2_REGOFFSET | ((21UL) << ADC_CHANNEL_SMPx_BITOFFSET_POS))
  237. #define ADC_CHANNEL_18_SMP (ADC_SMPR2_REGOFFSET | ((24UL) << ADC_CHANNEL_SMPx_BITOFFSET_POS))
  238. /* Internal mask for ADC mode single or differential ended: */
  239. /* To select into literals LL_ADC_SINGLE_ENDED or LL_ADC_SINGLE_DIFFERENTIAL */
  240. /* the relevant bits for: */
  241. /* (concatenation of multiple bits used in different registers) */
  242. /* - ADC calibration: calibration start, calibration factor get or set */
  243. /* - ADC channels: set each ADC channel ending mode */
  244. #define ADC_SINGLEDIFF_CALIB_START_MASK (ADC_CR_ADCALDIF)
  245. #define ADC_SINGLEDIFF_CALIB_FACTOR_MASK (ADC_CALFACT_CALFACT_D | ADC_CALFACT_CALFACT_S)
  246. #define ADC_SINGLEDIFF_CHANNEL_MASK (ADC_CHANNEL_ID_BITFIELD_MASK) /* Equivalent to ADC_DIFSEL_DIFSEL */
  247. #define ADC_SINGLEDIFF_CHANNEL_SHIFT_MASK (ADC_CALFACT_CALFACT_S_4 | ADC_CALFACT_CALFACT_S_3) /* Bits chosen
  248. to perform of shift when single mode is selected, shift value out of
  249. channels bits range. */
  250. #define ADC_SINGLEDIFF_CALIB_F_BIT_D_MASK (0x00010000UL) /* Selection of 1 bit to discriminate differential mode:
  251. mask of bit */
  252. #define ADC_SINGLEDIFF_CALIB_F_BIT_D_POS (16UL) /* Selection of 1 bit to discriminate differential mode:
  253. position of bit */
  254. #define ADC_SINGLEDIFF_CALIB_F_BIT_D_SHIFT4 (ADC_SINGLEDIFF_CALIB_F_BIT_D_POS - 4UL) /* Shift of bit
  255. ADC_SINGLEDIFF_CALIB_F_BIT_D to perform a shift of 4 ranks */
  256. /* Internal mask for ADC analog watchdog: */
  257. /* To select into literals LL_ADC_AWD_CHANNELx_xxx the relevant bits for: */
  258. /* (concatenation of multiple bits used in different analog watchdogs, */
  259. /* (feature of several watchdogs not available on all STM32 series)). */
  260. /* - analog watchdog 1: monitored channel defined by number, */
  261. /* selection of ADC group (ADC groups regular and-or injected). */
  262. /* - analog watchdog 2 and 3: monitored channel defined by bitfield, no */
  263. /* selection on groups. */
  264. /* Internal register offset for ADC analog watchdog channel configuration */
  265. #define ADC_AWD_CR1_REGOFFSET (0x00000000UL)
  266. #define ADC_AWD_CR2_REGOFFSET (0x00100000UL)
  267. #define ADC_AWD_CR3_REGOFFSET (0x00200000UL)
  268. /* Register offset gap between AWD1 and AWD2-AWD3 configuration registers */
  269. /* (Set separately as ADC_AWD_CRX_REGOFFSET to spare 32 bits space */
  270. #define ADC_AWD_CR12_REGOFFSETGAP_MASK (ADC_AWD2CR_AWD2CH_0)
  271. #define ADC_AWD_CR12_REGOFFSETGAP_VAL (0x00000024UL)
  272. #define ADC_AWD_CRX_REGOFFSET_MASK (ADC_AWD_CR1_REGOFFSET | ADC_AWD_CR2_REGOFFSET | ADC_AWD_CR3_REGOFFSET)
  273. #define ADC_AWD_CR1_CHANNEL_MASK (ADC_CFGR_AWD1CH | ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1EN | ADC_CFGR_AWD1SGL)
  274. #define ADC_AWD_CR23_CHANNEL_MASK (ADC_AWD2CR_AWD2CH)
  275. #define ADC_AWD_CR_ALL_CHANNEL_MASK (ADC_AWD_CR1_CHANNEL_MASK | ADC_AWD_CR23_CHANNEL_MASK)
  276. #define ADC_AWD_CRX_REGOFFSET_POS (20UL) /* Position of bits ADC_AWD_CRx_REGOFFSET
  277. in ADC_AWD_CRX_REGOFFSET_MASK */
  278. /* Internal register offset for ADC analog watchdog threshold configuration */
  279. #define ADC_AWD_TR1_REGOFFSET (ADC_AWD_CR1_REGOFFSET)
  280. #define ADC_AWD_TR2_REGOFFSET (ADC_AWD_CR2_REGOFFSET)
  281. #define ADC_AWD_TR3_REGOFFSET (ADC_AWD_CR3_REGOFFSET)
  282. #define ADC_AWD_TRX_REGOFFSET_MASK (ADC_AWD_TR1_REGOFFSET | ADC_AWD_TR2_REGOFFSET | ADC_AWD_TR3_REGOFFSET)
  283. #define ADC_AWD_TRX_REGOFFSET_POS (ADC_AWD_CRX_REGOFFSET_POS) /* Position of bits ADC_SQRx_REGOFFSET
  284. in ADC_AWD_TRX_REGOFFSET_MASK */
  285. #define ADC_AWD_TRX_BIT_HIGH_MASK (0x00010000UL) /* Selection of 1 bit to discriminate
  286. threshold high: mask of bit */
  287. #define ADC_AWD_TRX_BIT_HIGH_POS (16UL) /* Selection of 1 bit to discriminate
  288. threshold high: position of bit */
  289. #define ADC_AWD_TRX_BIT_HIGH_SHIFT4 (ADC_AWD_TRX_BIT_HIGH_POS - 4UL) /* Shift of bit ADC_AWD_TRX_BIT_HIGH to
  290. position to perform a shift of 4 ranks */
  291. /* Internal mask for ADC offset: */
  292. /* Internal register offset for ADC offset instance configuration */
  293. #define ADC_OFR1_REGOFFSET (0x00000000UL)
  294. #define ADC_OFR2_REGOFFSET (0x00000001UL)
  295. #define ADC_OFR3_REGOFFSET (0x00000002UL)
  296. #define ADC_OFR4_REGOFFSET (0x00000003UL)
  297. #define ADC_OFRx_REGOFFSET_MASK (ADC_OFR1_REGOFFSET | ADC_OFR2_REGOFFSET \
  298. | ADC_OFR3_REGOFFSET | ADC_OFR4_REGOFFSET)
  299. /* ADC registers bits positions */
  300. #define ADC_CFGR_RES_BITOFFSET_POS ( 3UL) /* Equivalent to bitfield "ADC_CFGR_RES" position in register */
  301. #define ADC_CFGR_AWD1SGL_BITOFFSET_POS (22UL) /* Equivalent to bitfield "ADC_CFGR_AWD1SGL" position in register */
  302. #define ADC_CFGR_AWD1EN_BITOFFSET_POS (23UL) /* Equivalent to bitfield "ADC_CFGR_AWD1EN" position in register */
  303. #define ADC_CFGR_JAWD1EN_BITOFFSET_POS (24UL) /* Equivalent to bitfield "ADC_CFGR_JAWD1EN" position in register */
  304. #define ADC_TR1_HT1_BITOFFSET_POS (16UL) /* Equivalent to bitfield "ADC_TR1_HT1" position in register */
  305. /* ADC registers bits groups */
  306. #define ADC_CR_BITS_PROPERTY_RS (ADC_CR_ADCAL | ADC_CR_ADEN | ADC_CR_ADDIS \
  307. | ADC_CR_JADSTART | ADC_CR_JADSTP \
  308. | ADC_CR_ADSTART | ADC_CR_ADSTP) /* ADC register CR bits with
  309. HW property "rs": Software can read as well as set this bit.
  310. Writing '0' has no effect on the bit value. */
  311. /* ADC internal channels related definitions */
  312. /* Internal voltage reference VrefInt */
  313. #define VREFINT_CAL_ADDR ((uint16_t*) (0x1FFF75AAUL)) /* Internal voltage reference, address of
  314. parameter VREFINT_CAL: VrefInt ADC raw data acquired at temperature 30 DegC
  315. (tolerance: +-5 DegC), Vref+ = 3.0 V (tolerance: +-10 mV). */
  316. #define VREFINT_CAL_VREF ( 3000UL) /* Analog voltage reference (Vref+) value
  317. with which VrefInt has been calibrated in production
  318. (tolerance: +-10 mV) (unit: mV). */
  319. /* Temperature sensor */
  320. #define TEMPSENSOR_CAL1_ADDR ((uint16_t*) (0x1FFF75A8UL)) /* Address of parameter TS_CAL1: On STM32L4,
  321. temperature sensor ADC raw data acquired at temperature 30 DegC
  322. (tolerance: +-5 DegC), Vref+ = 3.0 V (tolerance: +-10 mV). */
  323. #define TEMPSENSOR_CAL2_ADDR ((uint16_t*) (0x1FFF75CAUL)) /* Address of parameter TS_CAL2: On STM32L4,
  324. temperature sensor ADC raw data acquired at temperature defined by
  325. TEMPSENSOR_CAL2_TEMP (tolerance: +-5 DegC), Vref+ = 3.0 V (tolerance: +-10 mV). */
  326. #define TEMPSENSOR_CAL1_TEMP (( int32_t) 30L) /* Temperature at which temperature sensor
  327. has been calibrated in production for data into TEMPSENSOR_CAL1_ADDR
  328. (tolerance: +-5 DegC) (unit: DegC). */
  329. #if defined (STM32L471xx) || defined (STM32L475xx) || defined (STM32L476xx) || defined (STM32L485xx) || defined (STM32L486xx)
  330. #define TEMPSENSOR_CAL2_TEMP (110L) /* Temperature at which temperature sensor
  331. has been calibrated in production for data into TEMPSENSOR_CAL2_ADDR
  332. (tolerance: +-5 DegC) (unit: DegC). */
  333. #else
  334. #define TEMPSENSOR_CAL2_TEMP (130L) /* Temperature at which temperature sensor
  335. has been calibrated in production for data into TEMPSENSOR_CAL2_ADDR
  336. (tolerance: +-5 DegC) (unit: DegC). */
  337. #endif /* defined (STM32L471xx) || defined (STM32L475xx) || defined (STM32L476xx) || defined (STM32L485xx) || defined (STM32L486xx) */
  338. #define TEMPSENSOR_CAL_VREFANALOG (3000UL) /* Analog voltage reference (Vref+) value
  339. with which temperature sensor has been calibrated in production
  340. (tolerance +-10 mV) (unit: mV). */
  341. /**
  342. * @}
  343. */
  344. /* Private macros ------------------------------------------------------------*/
  345. /** @defgroup ADC_LL_Private_Macros ADC Private Macros
  346. * @{
  347. */
  348. /**
  349. * @brief Driver macro reserved for internal use: set a pointer to
  350. * a register from a register basis from which an offset
  351. * is applied.
  352. * @param __REG__ Register basis from which the offset is applied.
  353. * @param __REG_OFFFSET__ Offset to be applied (unit: number of registers).
  354. * @retval Pointer to register address
  355. */
  356. #define __ADC_PTR_REG_OFFSET(__REG__, __REG_OFFFSET__) \
  357. ((__IO uint32_t *)((uint32_t) ((uint32_t)(&(__REG__)) + ((__REG_OFFFSET__) << 2UL))))
  358. /**
  359. * @}
  360. */
  361. /* Exported types ------------------------------------------------------------*/
  362. #if defined(USE_FULL_LL_DRIVER)
  363. /** @defgroup ADC_LL_ES_INIT ADC Exported Init structure
  364. * @{
  365. */
  366. /**
  367. * @brief Structure definition of some features of ADC common parameters
  368. * and multimode
  369. * (all ADC instances belonging to the same ADC common instance).
  370. * @note The setting of these parameters by function @ref LL_ADC_CommonInit()
  371. * is conditioned to ADC instances state (all ADC instances
  372. * sharing the same ADC common instance):
  373. * All ADC instances sharing the same ADC common instance must be
  374. * disabled.
  375. */
  376. typedef struct
  377. {
  378. uint32_t CommonClock; /*!< Set parameter common to several ADC: Clock source and prescaler.
  379. This parameter can be a value of @ref ADC_LL_EC_COMMON_CLOCK_SOURCE
  380. @note On this STM32 series, if ADC group injected is used, some clock ratio
  381. constraints between ADC clock and AHB clock must be respected.
  382. Refer to reference manual.
  383. This feature can be modified afterwards using unitary function
  384. @ref LL_ADC_SetCommonClock(). */
  385. #if defined(ADC_MULTIMODE_SUPPORT)
  386. uint32_t Multimode; /*!< Set ADC multimode configuration to operate in independent mode or multimode
  387. (for devices with several ADC instances).
  388. This parameter can be a value of @ref ADC_LL_EC_MULTI_MODE
  389. This feature can be modified afterwards using unitary function
  390. @ref LL_ADC_SetMultimode(). */
  391. uint32_t MultiDMATransfer; /*!< Set ADC multimode conversion data transfer: no transfer or transfer by DMA.
  392. This parameter can be a value of @ref ADC_LL_EC_MULTI_DMA_TRANSFER
  393. This feature can be modified afterwards using unitary function
  394. @ref LL_ADC_SetMultiDMATransfer(). */
  395. uint32_t MultiTwoSamplingDelay; /*!< Set ADC multimode delay between 2 sampling phases.
  396. This parameter can be a value of @ref ADC_LL_EC_MULTI_TWOSMP_DELAY
  397. This feature can be modified afterwards using unitary function
  398. @ref LL_ADC_SetMultiTwoSamplingDelay(). */
  399. #endif /* ADC_MULTIMODE_SUPPORT */
  400. } LL_ADC_CommonInitTypeDef;
  401. /**
  402. * @brief Structure definition of some features of ADC instance.
  403. * @note These parameters have an impact on ADC scope: ADC instance.
  404. * Affects both group regular and group injected (availability
  405. * of ADC group injected depends on STM32 series).
  406. * Refer to corresponding unitary functions into
  407. * @ref ADC_LL_EF_Configuration_ADC_Instance .
  408. * @note The setting of these parameters by function @ref LL_ADC_Init()
  409. * is conditioned to ADC state:
  410. * ADC instance must be disabled.
  411. * This condition is applied to all ADC features, for efficiency
  412. * and compatibility over all STM32 series. However, the different
  413. * features can be set under different ADC state conditions
  414. * (setting possible with ADC enabled without conversion on going,
  415. * ADC enabled with conversion on going, ...)
  416. * Each feature can be updated afterwards with a unitary function
  417. * and potentially with ADC in a different state than disabled,
  418. * refer to description of each function for setting
  419. * conditioned to ADC state.
  420. */
  421. typedef struct
  422. {
  423. uint32_t Resolution; /*!< Set ADC resolution.
  424. This parameter can be a value of @ref ADC_LL_EC_RESOLUTION
  425. This feature can be modified afterwards using unitary function
  426. @ref LL_ADC_SetResolution(). */
  427. uint32_t DataAlignment; /*!< Set ADC conversion data alignment.
  428. This parameter can be a value of @ref ADC_LL_EC_DATA_ALIGN
  429. This feature can be modified afterwards using unitary function
  430. @ref LL_ADC_SetDataAlignment(). */
  431. uint32_t LowPowerMode; /*!< Set ADC low power mode.
  432. This parameter can be a value of @ref ADC_LL_EC_LP_MODE
  433. This feature can be modified afterwards using unitary function
  434. @ref LL_ADC_SetLowPowerMode(). */
  435. } LL_ADC_InitTypeDef;
  436. /**
  437. * @brief Structure definition of some features of ADC group regular.
  438. * @note These parameters have an impact on ADC scope: ADC group regular.
  439. * Refer to corresponding unitary functions into
  440. * @ref ADC_LL_EF_Configuration_ADC_Group_Regular
  441. * (functions with prefix "REG").
  442. * @note The setting of these parameters by function @ref LL_ADC_REG_Init()
  443. * is conditioned to ADC state:
  444. * ADC instance must be disabled.
  445. * This condition is applied to all ADC features, for efficiency
  446. * and compatibility over all STM32 series. However, the different
  447. * features can be set under different ADC state conditions
  448. * (setting possible with ADC enabled without conversion on going,
  449. * ADC enabled with conversion on going, ...)
  450. * Each feature can be updated afterwards with a unitary function
  451. * and potentially with ADC in a different state than disabled,
  452. * refer to description of each function for setting
  453. * conditioned to ADC state.
  454. */
  455. typedef struct
  456. {
  457. uint32_t TriggerSource; /*!< Set ADC group regular conversion trigger source: internal (SW start) or
  458. from external peripheral (timer event, external interrupt line).
  459. This parameter can be a value of @ref ADC_LL_EC_REG_TRIGGER_SOURCE
  460. @note On this STM32 series, setting trigger source to external trigger also
  461. set trigger polarity to rising edge(default setting for compatibility
  462. with some ADC on other STM32 series having this setting set by HW
  463. default value).
  464. In case of need to modify trigger edge, use function
  465. @ref LL_ADC_REG_SetTriggerEdge().
  466. This feature can be modified afterwards using unitary function
  467. @ref LL_ADC_REG_SetTriggerSource(). */
  468. uint32_t SequencerLength; /*!< Set ADC group regular sequencer length.
  469. This parameter can be a value of @ref ADC_LL_EC_REG_SEQ_SCAN_LENGTH
  470. This feature can be modified afterwards using unitary function
  471. @ref LL_ADC_REG_SetSequencerLength(). */
  472. uint32_t SequencerDiscont; /*!< Set ADC group regular sequencer discontinuous mode: sequence subdivided
  473. and scan conversions interrupted every selected number of ranks.
  474. This parameter can be a value of @ref ADC_LL_EC_REG_SEQ_DISCONT_MODE
  475. @note This parameter has an effect only if group regular sequencer is
  476. enabled (scan length of 2 ranks or more).
  477. This feature can be modified afterwards using unitary function
  478. @ref LL_ADC_REG_SetSequencerDiscont(). */
  479. uint32_t ContinuousMode; /*!< Set ADC continuous conversion mode on ADC group regular, whether ADC
  480. conversions are performed in single mode (one conversion per trigger) or in
  481. continuous mode (after the first trigger, following conversions launched
  482. successively automatically).
  483. This parameter can be a value of @ref ADC_LL_EC_REG_CONTINUOUS_MODE
  484. Note: It is not possible to enable both ADC group regular continuous mode
  485. and discontinuous mode.
  486. This feature can be modified afterwards using unitary function
  487. @ref LL_ADC_REG_SetContinuousMode(). */
  488. uint32_t DMATransfer; /*!< Set ADC group regular conversion data transfer: no transfer or transfer
  489. by DMA, and DMA requests mode.
  490. This parameter can be a value of @ref ADC_LL_EC_REG_DMA_TRANSFER
  491. This feature can be modified afterwards using unitary function
  492. @ref LL_ADC_REG_SetDMATransfer(). */
  493. uint32_t Overrun; /*!< Set ADC group regular behavior in case of overrun:
  494. data preserved or overwritten.
  495. This parameter can be a value of @ref ADC_LL_EC_REG_OVR_DATA_BEHAVIOR
  496. This feature can be modified afterwards using unitary function
  497. @ref LL_ADC_REG_SetOverrun(). */
  498. } LL_ADC_REG_InitTypeDef;
  499. /**
  500. * @brief Structure definition of some features of ADC group injected.
  501. * @note These parameters have an impact on ADC scope: ADC group injected.
  502. * Refer to corresponding unitary functions into
  503. * @ref ADC_LL_EF_Configuration_ADC_Group_Regular
  504. * (functions with prefix "INJ").
  505. * @note The setting of these parameters by function @ref LL_ADC_INJ_Init()
  506. * is conditioned to ADC state:
  507. * ADC instance must be disabled.
  508. * This condition is applied to all ADC features, for efficiency
  509. * and compatibility over all STM32 series. However, the different
  510. * features can be set under different ADC state conditions
  511. * (setting possible with ADC enabled without conversion on going,
  512. * ADC enabled with conversion on going, ...)
  513. * Each feature can be updated afterwards with a unitary function
  514. * and potentially with ADC in a different state than disabled,
  515. * refer to description of each function for setting
  516. * conditioned to ADC state.
  517. */
  518. typedef struct
  519. {
  520. uint32_t TriggerSource; /*!< Set ADC group injected conversion trigger source: internal (SW start)
  521. or from external peripheral (timer event, external interrupt line).
  522. This parameter can be a value of @ref ADC_LL_EC_INJ_TRIGGER_SOURCE
  523. @note On this STM32 series, setting trigger source to external trigger also
  524. set trigger polarity to rising edge (default setting for
  525. compatibility with some ADC on other STM32 series having this
  526. setting set by HW default value).
  527. In case of need to modify trigger edge, use function
  528. @ref LL_ADC_INJ_SetTriggerEdge().
  529. This feature can be modified afterwards using unitary function
  530. @ref LL_ADC_INJ_SetTriggerSource(). */
  531. uint32_t SequencerLength; /*!< Set ADC group injected sequencer length.
  532. This parameter can be a value of @ref ADC_LL_EC_INJ_SEQ_SCAN_LENGTH
  533. This feature can be modified afterwards using unitary function
  534. @ref LL_ADC_INJ_SetSequencerLength(). */
  535. uint32_t SequencerDiscont; /*!< Set ADC group injected sequencer discontinuous mode: sequence subdivided
  536. and scan conversions interrupted every selected number of ranks.
  537. This parameter can be a value of @ref ADC_LL_EC_INJ_SEQ_DISCONT_MODE
  538. @note This parameter has an effect only if group injected sequencer is
  539. enabled (scan length of 2 ranks or more).
  540. This feature can be modified afterwards using unitary function
  541. @ref LL_ADC_INJ_SetSequencerDiscont(). */
  542. uint32_t TrigAuto; /*!< Set ADC group injected conversion trigger: independent or from ADC group
  543. regular.
  544. This parameter can be a value of @ref ADC_LL_EC_INJ_TRIG_AUTO
  545. Note: This parameter must be set to set to independent trigger if injected
  546. trigger source is set to an external trigger.
  547. This feature can be modified afterwards using unitary function
  548. @ref LL_ADC_INJ_SetTrigAuto(). */
  549. } LL_ADC_INJ_InitTypeDef;
  550. /**
  551. * @}
  552. */
  553. #endif /* USE_FULL_LL_DRIVER */
  554. /* Exported constants --------------------------------------------------------*/
  555. /** @defgroup ADC_LL_Exported_Constants ADC Exported Constants
  556. * @{
  557. */
  558. /** @defgroup ADC_LL_EC_FLAG ADC flags
  559. * @brief Flags defines which can be used with LL_ADC_ReadReg function
  560. * @{
  561. */
  562. #define LL_ADC_FLAG_ADRDY ADC_ISR_ADRDY /*!< ADC flag ADC instance ready */
  563. #define LL_ADC_FLAG_EOC ADC_ISR_EOC /*!< ADC flag ADC group regular end of unitary
  564. conversion */
  565. #define LL_ADC_FLAG_EOS ADC_ISR_EOS /*!< ADC flag ADC group regular end of sequence
  566. conversions */
  567. #define LL_ADC_FLAG_OVR ADC_ISR_OVR /*!< ADC flag ADC group regular overrun */
  568. #define LL_ADC_FLAG_EOSMP ADC_ISR_EOSMP /*!< ADC flag ADC group regular end of sampling phase */
  569. #define LL_ADC_FLAG_JEOC ADC_ISR_JEOC /*!< ADC flag ADC group injected end of unitary
  570. conversion */
  571. #define LL_ADC_FLAG_JEOS ADC_ISR_JEOS /*!< ADC flag ADC group injected end of sequence
  572. conversions */
  573. #define LL_ADC_FLAG_JQOVF ADC_ISR_JQOVF /*!< ADC flag ADC group injected contexts queue
  574. overflow */
  575. #define LL_ADC_FLAG_AWD1 ADC_ISR_AWD1 /*!< ADC flag ADC analog watchdog 1 */
  576. #define LL_ADC_FLAG_AWD2 ADC_ISR_AWD2 /*!< ADC flag ADC analog watchdog 2 */
  577. #define LL_ADC_FLAG_AWD3 ADC_ISR_AWD3 /*!< ADC flag ADC analog watchdog 3 */
  578. #if defined(ADC_MULTIMODE_SUPPORT)
  579. #define LL_ADC_FLAG_ADRDY_MST ADC_CSR_ADRDY_MST /*!< ADC flag ADC multimode master instance ready */
  580. #define LL_ADC_FLAG_ADRDY_SLV ADC_CSR_ADRDY_SLV /*!< ADC flag ADC multimode slave instance ready */
  581. #define LL_ADC_FLAG_EOC_MST ADC_CSR_EOC_MST /*!< ADC flag ADC multimode master group regular end of
  582. unitary conversion */
  583. #define LL_ADC_FLAG_EOC_SLV ADC_CSR_EOC_SLV /*!< ADC flag ADC multimode slave group regular end of
  584. unitary conversion */
  585. #define LL_ADC_FLAG_EOS_MST ADC_CSR_EOS_MST /*!< ADC flag ADC multimode master group regular end of
  586. sequence conversions */
  587. #define LL_ADC_FLAG_EOS_SLV ADC_CSR_EOS_SLV /*!< ADC flag ADC multimode slave group regular end of
  588. sequence conversions */
  589. #define LL_ADC_FLAG_OVR_MST ADC_CSR_OVR_MST /*!< ADC flag ADC multimode master group regular
  590. overrun */
  591. #define LL_ADC_FLAG_OVR_SLV ADC_CSR_OVR_SLV /*!< ADC flag ADC multimode slave group regular
  592. overrun */
  593. #define LL_ADC_FLAG_EOSMP_MST ADC_CSR_EOSMP_MST /*!< ADC flag ADC multimode master group regular end of
  594. sampling phase */
  595. #define LL_ADC_FLAG_EOSMP_SLV ADC_CSR_EOSMP_SLV /*!< ADC flag ADC multimode slave group regular end of
  596. sampling phase */
  597. #define LL_ADC_FLAG_JEOC_MST ADC_CSR_JEOC_MST /*!< ADC flag ADC multimode master group injected end of
  598. unitary conversion */
  599. #define LL_ADC_FLAG_JEOC_SLV ADC_CSR_JEOC_SLV /*!< ADC flag ADC multimode slave group injected end of
  600. unitary conversion */
  601. #define LL_ADC_FLAG_JEOS_MST ADC_CSR_JEOS_MST /*!< ADC flag ADC multimode master group injected end of
  602. sequence conversions */
  603. #define LL_ADC_FLAG_JEOS_SLV ADC_CSR_JEOS_SLV /*!< ADC flag ADC multimode slave group injected end of
  604. sequence conversions */
  605. #define LL_ADC_FLAG_JQOVF_MST ADC_CSR_JQOVF_MST /*!< ADC flag ADC multimode master group injected
  606. contexts queue overflow */
  607. #define LL_ADC_FLAG_JQOVF_SLV ADC_CSR_JQOVF_SLV /*!< ADC flag ADC multimode slave group injected
  608. contexts queue overflow */
  609. #define LL_ADC_FLAG_AWD1_MST ADC_CSR_AWD1_MST /*!< ADC flag ADC multimode master analog watchdog 1
  610. of the ADC master */
  611. #define LL_ADC_FLAG_AWD1_SLV ADC_CSR_AWD1_SLV /*!< ADC flag ADC multimode slave analog watchdog 1
  612. of the ADC slave */
  613. #define LL_ADC_FLAG_AWD2_MST ADC_CSR_AWD2_MST /*!< ADC flag ADC multimode master analog watchdog 2
  614. of the ADC master */
  615. #define LL_ADC_FLAG_AWD2_SLV ADC_CSR_AWD2_SLV /*!< ADC flag ADC multimode slave analog watchdog 2
  616. of the ADC slave */
  617. #define LL_ADC_FLAG_AWD3_MST ADC_CSR_AWD3_MST /*!< ADC flag ADC multimode master analog watchdog 3
  618. of the ADC master */
  619. #define LL_ADC_FLAG_AWD3_SLV ADC_CSR_AWD3_SLV /*!< ADC flag ADC multimode slave analog watchdog 3
  620. of the ADC slave */
  621. #endif /* ADC_MULTIMODE_SUPPORT */
  622. /**
  623. * @}
  624. */
  625. /** @defgroup ADC_LL_EC_IT ADC interruptions for configuration (interruption enable or disable)
  626. * @brief IT defines which can be used with LL_ADC_ReadReg and LL_ADC_WriteReg functions
  627. * @{
  628. */
  629. #define LL_ADC_IT_ADRDY ADC_IER_ADRDYIE /*!< ADC interruption ADC instance ready */
  630. #define LL_ADC_IT_EOC ADC_IER_EOCIE /*!< ADC interruption ADC group regular end of unitary
  631. conversion */
  632. #define LL_ADC_IT_EOS ADC_IER_EOSIE /*!< ADC interruption ADC group regular end of sequence
  633. conversions */
  634. #define LL_ADC_IT_OVR ADC_IER_OVRIE /*!< ADC interruption ADC group regular overrun */
  635. #define LL_ADC_IT_EOSMP ADC_IER_EOSMPIE /*!< ADC interruption ADC group regular end of sampling
  636. phase */
  637. #define LL_ADC_IT_JEOC ADC_IER_JEOCIE /*!< ADC interruption ADC group injected end of unitary
  638. conversion */
  639. #define LL_ADC_IT_JEOS ADC_IER_JEOSIE /*!< ADC interruption ADC group injected end of sequence
  640. conversions */
  641. #define LL_ADC_IT_JQOVF ADC_IER_JQOVFIE /*!< ADC interruption ADC group injected contexts queue
  642. overflow */
  643. #define LL_ADC_IT_AWD1 ADC_IER_AWD1IE /*!< ADC interruption ADC analog watchdog 1 */
  644. #define LL_ADC_IT_AWD2 ADC_IER_AWD2IE /*!< ADC interruption ADC analog watchdog 2 */
  645. #define LL_ADC_IT_AWD3 ADC_IER_AWD3IE /*!< ADC interruption ADC analog watchdog 3 */
  646. /**
  647. * @}
  648. */
  649. /** @defgroup ADC_LL_EC_REGISTERS ADC registers compliant with specific purpose
  650. * @{
  651. */
  652. /* List of ADC registers intended to be used (most commonly) with */
  653. /* DMA transfer. */
  654. /* Refer to function @ref LL_ADC_DMA_GetRegAddr(). */
  655. #define LL_ADC_DMA_REG_REGULAR_DATA (0x00000000UL) /* ADC group regular conversion data register
  656. (corresponding to register DR) to be used with ADC configured in independent
  657. mode. Without DMA transfer, register accessed by LL function
  658. @ref LL_ADC_REG_ReadConversionData32() and other
  659. functions @ref LL_ADC_REG_ReadConversionDatax() */
  660. #if defined(ADC_MULTIMODE_SUPPORT)
  661. #define LL_ADC_DMA_REG_REGULAR_DATA_MULTI (0x00000001UL) /* ADC group regular conversion data register
  662. (corresponding to register CDR) to be used with ADC configured in multimode
  663. (available on STM32 devices with several ADC instances).
  664. Without DMA transfer, register accessed by LL function
  665. @ref LL_ADC_REG_ReadMultiConversionData32() */
  666. #endif /* ADC_MULTIMODE_SUPPORT */
  667. /**
  668. * @}
  669. */
  670. /** @defgroup ADC_LL_EC_COMMON_CLOCK_SOURCE ADC common - Clock source
  671. * @{
  672. */
  673. #define LL_ADC_CLOCK_SYNC_PCLK_DIV1 (ADC_CCR_CKMODE_0) /*!< ADC synchronous clock derived from
  674. AHB clock without prescaler */
  675. #define LL_ADC_CLOCK_SYNC_PCLK_DIV2 (ADC_CCR_CKMODE_1) /*!< ADC synchronous clock derived from
  676. AHB clock with prescaler division by 2 */
  677. #define LL_ADC_CLOCK_SYNC_PCLK_DIV4 (ADC_CCR_CKMODE_1 | ADC_CCR_CKMODE_0) /*!< ADC synchronous clock derived from
  678. AHB clock with prescaler division by 4 */
  679. #define LL_ADC_CLOCK_ASYNC_DIV1 (0x00000000UL) /*!< ADC asynchronous clock without
  680. prescaler */
  681. #define LL_ADC_CLOCK_ASYNC_DIV2 (ADC_CCR_PRESC_0) /*!< ADC asynchronous clock with
  682. prescaler division by 2 */
  683. #define LL_ADC_CLOCK_ASYNC_DIV4 (ADC_CCR_PRESC_1) /*!< ADC asynchronous clock with
  684. prescaler division by 4 */
  685. #define LL_ADC_CLOCK_ASYNC_DIV6 (ADC_CCR_PRESC_1 | ADC_CCR_PRESC_0) /*!< ADC asynchronous clock with
  686. prescaler division by 6 */
  687. #define LL_ADC_CLOCK_ASYNC_DIV8 (ADC_CCR_PRESC_2) /*!< ADC asynchronous clock with
  688. prescaler division by 8 */
  689. #define LL_ADC_CLOCK_ASYNC_DIV10 (ADC_CCR_PRESC_2 | ADC_CCR_PRESC_0) /*!< ADC asynchronous clock with
  690. prescaler division by 10 */
  691. #define LL_ADC_CLOCK_ASYNC_DIV12 (ADC_CCR_PRESC_2 | ADC_CCR_PRESC_1) /*!< ADC asynchronous clock with
  692. prescaler division by 12 */
  693. #define LL_ADC_CLOCK_ASYNC_DIV16 (ADC_CCR_PRESC_2 | ADC_CCR_PRESC_1 \
  694. | ADC_CCR_PRESC_0) /*!< ADC asynchronous clock with
  695. prescaler division by 16 */
  696. #define LL_ADC_CLOCK_ASYNC_DIV32 (ADC_CCR_PRESC_3) /*!< ADC asynchronous clock with
  697. prescaler division by 32 */
  698. #define LL_ADC_CLOCK_ASYNC_DIV64 (ADC_CCR_PRESC_3 | ADC_CCR_PRESC_0) /*!< ADC asynchronous clock with
  699. prescaler division by 64 */
  700. #define LL_ADC_CLOCK_ASYNC_DIV128 (ADC_CCR_PRESC_3 | ADC_CCR_PRESC_1) /*!< ADC asynchronous clock with
  701. prescaler division by 128 */
  702. #define LL_ADC_CLOCK_ASYNC_DIV256 (ADC_CCR_PRESC_3 | ADC_CCR_PRESC_1 \
  703. | ADC_CCR_PRESC_0) /*!< ADC asynchronous clock with
  704. prescaler division by 256 */
  705. /**
  706. * @}
  707. */
  708. /** @defgroup ADC_LL_EC_COMMON_PATH_INTERNAL ADC common - Measurement path to internal channels
  709. * @{
  710. */
  711. /* Note: Other measurement paths to internal channels may be available */
  712. /* (connections to other peripherals). */
  713. /* If they are not listed below, they do not require any specific */
  714. /* path enable. In this case, Access to measurement path is done */
  715. /* only by selecting the corresponding ADC internal channel. */
  716. #define LL_ADC_PATH_INTERNAL_NONE (0x00000000UL) /*!< ADC measurement paths all disabled */
  717. #define LL_ADC_PATH_INTERNAL_VREFINT (ADC_CCR_VREFEN) /*!< ADC measurement path to internal channel VrefInt */
  718. #define LL_ADC_PATH_INTERNAL_TEMPSENSOR (ADC_CCR_TSEN) /*!< ADC measurement path to internal channel
  719. temperature sensor */
  720. #define LL_ADC_PATH_INTERNAL_VBAT (ADC_CCR_VBATEN) /*!< ADC measurement path to internal channel Vbat */
  721. /**
  722. * @}
  723. */
  724. /** @defgroup ADC_LL_EC_RESOLUTION ADC instance - Resolution
  725. * @{
  726. */
  727. #define LL_ADC_RESOLUTION_12B (0x00000000UL) /*!< ADC resolution 12 bits */
  728. #define LL_ADC_RESOLUTION_10B ( ADC_CFGR_RES_0) /*!< ADC resolution 10 bits */
  729. #define LL_ADC_RESOLUTION_8B (ADC_CFGR_RES_1 ) /*!< ADC resolution 8 bits */
  730. #define LL_ADC_RESOLUTION_6B (ADC_CFGR_RES_1 | ADC_CFGR_RES_0) /*!< ADC resolution 6 bits */
  731. /**
  732. * @}
  733. */
  734. /** @defgroup ADC_LL_EC_DATA_ALIGN ADC instance - Data alignment
  735. * @{
  736. */
  737. #define LL_ADC_DATA_ALIGN_RIGHT (0x00000000UL) /*!< ADC conversion data alignment: right aligned
  738. (alignment on data register LSB bit 0)*/
  739. #define LL_ADC_DATA_ALIGN_LEFT (ADC_CFGR_ALIGN) /*!< ADC conversion data alignment: left aligned
  740. (alignment on data register MSB bit 15)*/
  741. /**
  742. * @}
  743. */
  744. /** @defgroup ADC_LL_EC_LP_MODE ADC instance - Low power mode
  745. * @{
  746. */
  747. #define LL_ADC_LP_MODE_NONE (0x00000000UL) /*!< No ADC low power mode activated */
  748. #define LL_ADC_LP_AUTOWAIT (ADC_CFGR_AUTDLY) /*!< ADC low power mode auto delay: Dynamic low power
  749. mode, ADC conversions are performed only when necessary
  750. (when previous ADC conversion data is read).
  751. See description with function @ref LL_ADC_SetLowPowerMode(). */
  752. /**
  753. * @}
  754. */
  755. /** @defgroup ADC_LL_EC_OFFSET_NB ADC instance - Offset instance
  756. * @{
  757. */
  758. #define LL_ADC_OFFSET_1 ADC_OFR1_REGOFFSET /*!< ADC offset instance 1: ADC channel and offset level
  759. to which the offset programmed will be applied (independently of channel
  760. mapped on ADC group regular or injected) */
  761. #define LL_ADC_OFFSET_2 ADC_OFR2_REGOFFSET /*!< ADC offset instance 2: ADC channel and offset level
  762. to which the offset programmed will be applied (independently of channel
  763. mapped on ADC group regular or injected) */
  764. #define LL_ADC_OFFSET_3 ADC_OFR3_REGOFFSET /*!< ADC offset instance 3: ADC channel and offset level
  765. to which the offset programmed will be applied (independently of channel
  766. mapped on ADC group regular or injected) */
  767. #define LL_ADC_OFFSET_4 ADC_OFR4_REGOFFSET /*!< ADC offset instance 4: ADC channel and offset level
  768. to which the offset programmed will be applied (independently of channel
  769. mapped on ADC group regular or injected) */
  770. /**
  771. * @}
  772. */
  773. /** @defgroup ADC_LL_EC_OFFSET_STATE ADC instance - Offset state
  774. * @{
  775. */
  776. #define LL_ADC_OFFSET_DISABLE (0x00000000UL) /*!< ADC offset disabled
  777. (setting offset instance wise) */
  778. #define LL_ADC_OFFSET_ENABLE (ADC_OFR1_OFFSET1_EN) /*!< ADC offset enabled
  779. (setting offset instance wise) */
  780. /**
  781. * @}
  782. */
  783. /** @defgroup ADC_LL_EC_GROUPS ADC instance - Groups
  784. * @{
  785. */
  786. #define LL_ADC_GROUP_REGULAR (0x00000001UL) /*!< ADC group regular (available on all STM32 devices) */
  787. #define LL_ADC_GROUP_INJECTED (0x00000002UL) /*!< ADC group injected (not available on all STM32
  788. devices)*/
  789. #define LL_ADC_GROUP_REGULAR_INJECTED (0x00000003UL) /*!< ADC both groups regular and injected */
  790. /**
  791. * @}
  792. */
  793. /** @defgroup ADC_LL_EC_CHANNEL ADC instance - Channel number
  794. * @{
  795. */
  796. #define LL_ADC_CHANNEL_0 (ADC_CHANNEL_0_NUMBER | ADC_CHANNEL_0_SMP \
  797. | ADC_CHANNEL_0_BITFIELD) /*!< ADC channel ADCx_IN0 */
  798. #define LL_ADC_CHANNEL_1 (ADC_CHANNEL_1_NUMBER | ADC_CHANNEL_1_SMP \
  799. | ADC_CHANNEL_1_BITFIELD) /*!< ADC channel ADCx_IN1 */
  800. #define LL_ADC_CHANNEL_2 (ADC_CHANNEL_2_NUMBER | ADC_CHANNEL_2_SMP \
  801. | ADC_CHANNEL_2_BITFIELD) /*!< ADC channel ADCx_IN2 */
  802. #define LL_ADC_CHANNEL_3 (ADC_CHANNEL_3_NUMBER | ADC_CHANNEL_3_SMP \
  803. | ADC_CHANNEL_3_BITFIELD) /*!< ADC channel ADCx_IN3 */
  804. #define LL_ADC_CHANNEL_4 (ADC_CHANNEL_4_NUMBER | ADC_CHANNEL_4_SMP \
  805. | ADC_CHANNEL_4_BITFIELD) /*!< ADC channel ADCx_IN4 */
  806. #define LL_ADC_CHANNEL_5 (ADC_CHANNEL_5_NUMBER | ADC_CHANNEL_5_SMP \
  807. | ADC_CHANNEL_5_BITFIELD) /*!< ADC channel ADCx_IN5 */
  808. #define LL_ADC_CHANNEL_6 (ADC_CHANNEL_6_NUMBER | ADC_CHANNEL_6_SMP \
  809. | ADC_CHANNEL_6_BITFIELD) /*!< ADC channel ADCx_IN6 */
  810. #define LL_ADC_CHANNEL_7 (ADC_CHANNEL_7_NUMBER | ADC_CHANNEL_7_SMP \
  811. | ADC_CHANNEL_7_BITFIELD) /*!< ADC channel ADCx_IN7 */
  812. #define LL_ADC_CHANNEL_8 (ADC_CHANNEL_8_NUMBER | ADC_CHANNEL_8_SMP \
  813. | ADC_CHANNEL_8_BITFIELD) /*!< ADC channel ADCx_IN8 */
  814. #define LL_ADC_CHANNEL_9 (ADC_CHANNEL_9_NUMBER | ADC_CHANNEL_9_SMP \
  815. | ADC_CHANNEL_9_BITFIELD) /*!< ADC channel ADCx_IN9 */
  816. #define LL_ADC_CHANNEL_10 (ADC_CHANNEL_10_NUMBER | ADC_CHANNEL_10_SMP \
  817. | ADC_CHANNEL_10_BITFIELD) /*!< ADC channel ADCx_IN10 */
  818. #define LL_ADC_CHANNEL_11 (ADC_CHANNEL_11_NUMBER | ADC_CHANNEL_11_SMP \
  819. | ADC_CHANNEL_11_BITFIELD) /*!< ADC channel ADCx_IN11 */
  820. #define LL_ADC_CHANNEL_12 (ADC_CHANNEL_12_NUMBER | ADC_CHANNEL_12_SMP \
  821. | ADC_CHANNEL_12_BITFIELD) /*!< ADC channel ADCx_IN12 */
  822. #define LL_ADC_CHANNEL_13 (ADC_CHANNEL_13_NUMBER | ADC_CHANNEL_13_SMP \
  823. | ADC_CHANNEL_13_BITFIELD) /*!< ADC channel ADCx_IN13 */
  824. #define LL_ADC_CHANNEL_14 (ADC_CHANNEL_14_NUMBER | ADC_CHANNEL_14_SMP \
  825. | ADC_CHANNEL_14_BITFIELD) /*!< ADC channel ADCx_IN14 */
  826. #define LL_ADC_CHANNEL_15 (ADC_CHANNEL_15_NUMBER | ADC_CHANNEL_15_SMP \
  827. | ADC_CHANNEL_15_BITFIELD) /*!< ADC channel ADCx_IN15 */
  828. #define LL_ADC_CHANNEL_16 (ADC_CHANNEL_16_NUMBER | ADC_CHANNEL_16_SMP | \
  829. ADC_CHANNEL_16_BITFIELD) /*!< ADC channel ADCx_IN16 */
  830. #define LL_ADC_CHANNEL_17 (ADC_CHANNEL_17_NUMBER | ADC_CHANNEL_17_SMP | \
  831. ADC_CHANNEL_17_BITFIELD) /*!< ADC channel ADCx_IN17 */
  832. #define LL_ADC_CHANNEL_18 (ADC_CHANNEL_18_NUMBER | ADC_CHANNEL_18_SMP | \
  833. ADC_CHANNEL_18_BITFIELD) /*!< ADC channel ADCx_IN18 */
  834. #define LL_ADC_CHANNEL_VREFINT (LL_ADC_CHANNEL_0 | ADC_CHANNEL_ID_INTERNAL_CH) /*!< ADC internal channel
  835. connected to VrefInt: Internal voltage reference.
  836. On STM32L4, ADC channel available only on ADC instance: ADC1. */
  837. #define LL_ADC_CHANNEL_TEMPSENSOR (LL_ADC_CHANNEL_17 | ADC_CHANNEL_ID_INTERNAL_CH) /*!< ADC internal channel
  838. connected to internal temperature sensor.
  839. On STM32L4, ADC channel available only on ADC instances: ADC1, ADC3. */
  840. #define LL_ADC_CHANNEL_VBAT (LL_ADC_CHANNEL_18 | ADC_CHANNEL_ID_INTERNAL_CH) /*!< ADC internal channel
  841. connected to Vbat/3: Vbat voltage through a divider ladder of factor 1/3
  842. to have channel voltage always below Vdda.
  843. On STM32L4, ADC channel available only on ADC instances: ADC1, ADC3. */
  844. #if defined(ADC1) && !defined(ADC2)
  845. #define LL_ADC_CHANNEL_DAC1CH1 (LL_ADC_CHANNEL_17 | ADC_CHANNEL_ID_INTERNAL_CH | \
  846. ADC_CHANNEL_ID_INTERNAL_CH_2) /*!< ADC internal channel
  847. connected to DAC1 channel 1, channel specific to ADC1. This channel is
  848. shared with ADC internal channel connected to internal temperature sensor,
  849. selection is done using function @ref LL_ADC_SetCommonPathInternalCh(). */
  850. #define LL_ADC_CHANNEL_DAC1CH2 (LL_ADC_CHANNEL_18 | ADC_CHANNEL_ID_INTERNAL_CH | \
  851. ADC_CHANNEL_ID_INTERNAL_CH_2) /*!< ADC internal channel
  852. connected to DAC1 channel 2, channel specific to ADC1. This channel is
  853. shared with ADC internal channel connected to Vbat,
  854. selection is done using function @ref LL_ADC_SetCommonPathInternalCh(). */
  855. #elif defined(ADC2)
  856. #define LL_ADC_CHANNEL_DAC1CH1_ADC2 (LL_ADC_CHANNEL_17 | ADC_CHANNEL_ID_INTERNAL_CH | \
  857. ADC_CHANNEL_ID_INTERNAL_CH_2) /*!< ADC internal channel
  858. connected to DAC1 channel 1, channel specific to ADC2 */
  859. #define LL_ADC_CHANNEL_DAC1CH2_ADC2 (LL_ADC_CHANNEL_18 | ADC_CHANNEL_ID_INTERNAL_CH | \
  860. ADC_CHANNEL_ID_INTERNAL_CH_2) /*!< ADC internal channel
  861. connected to DAC1 channel 2, channel specific to ADC2 */
  862. #if defined(ADC3)
  863. #define LL_ADC_CHANNEL_DAC1CH1_ADC3 (LL_ADC_CHANNEL_14 | ADC_CHANNEL_ID_INTERNAL_CH) /*!< ADC internal channel
  864. connected to DAC1 channel 1, channel specific to ADC3 */
  865. #define LL_ADC_CHANNEL_DAC1CH2_ADC3 (LL_ADC_CHANNEL_15 | ADC_CHANNEL_ID_INTERNAL_CH) /*!< ADC internal channel
  866. connected to DAC1 channel 2, channel specific to ADC3 */
  867. #endif /* ADC3 */
  868. #endif /* ADC1 && !ADC2 */
  869. /**
  870. * @}
  871. */
  872. /** @defgroup ADC_LL_EC_REG_TRIGGER_SOURCE ADC group regular - Trigger source
  873. * @{
  874. */
  875. #define LL_ADC_REG_TRIG_SOFTWARE (0x00000000UL) /*!< ADC group regular
  876. conversion trigger internal: SW start. */
  877. #define LL_ADC_REG_TRIG_EXT_TIM1_TRGO (ADC_CFGR_EXTSEL_3 | ADC_CFGR_EXTSEL_0 | \
  878. ADC_REG_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group regular
  879. conversion trigger from external peripheral: TIM1 TRGO. Trigger edge set to
  880. rising edge (default setting). */
  881. #define LL_ADC_REG_TRIG_EXT_TIM1_TRGO2 (ADC_CFGR_EXTSEL_3 | ADC_CFGR_EXTSEL_1 | \
  882. ADC_REG_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group regular
  883. conversion trigger from external peripheral: TIM1 TRGO2. Trigger edge set to
  884. rising edge (default setting). */
  885. #define LL_ADC_REG_TRIG_EXT_TIM1_CH1 (ADC_REG_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group regular
  886. conversion trigger from external peripheral: TIM1 channel 1 event (capture
  887. compare: input capture or output capture). Trigger edge set to rising edge
  888. (default setting). */
  889. #define LL_ADC_REG_TRIG_EXT_TIM1_CH2 (ADC_CFGR_EXTSEL_0 | ADC_REG_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group regular
  890. conversion trigger from external peripheral: TIM1 channel 2 event (capture
  891. compare: input capture or output capture). Trigger edge set to rising edge
  892. (default setting). */
  893. #define LL_ADC_REG_TRIG_EXT_TIM1_CH3 (ADC_CFGR_EXTSEL_1 | ADC_REG_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group regular
  894. conversion trigger from external peripheral: TIM1 channel 3 event (capture
  895. compare: input capture or output capture). Trigger edge set to rising edge
  896. (default setting). */
  897. #define LL_ADC_REG_TRIG_EXT_TIM2_TRGO (ADC_CFGR_EXTSEL_3 | ADC_CFGR_EXTSEL_1 | \
  898. ADC_CFGR_EXTSEL_0 | ADC_REG_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group regular
  899. conversion trigger from external peripheral: TIM2 TRGO. Trigger edge set to
  900. rising edge (default setting). */
  901. #define LL_ADC_REG_TRIG_EXT_TIM2_CH2 (ADC_CFGR_EXTSEL_1 | ADC_CFGR_EXTSEL_0 | \
  902. ADC_REG_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group regular
  903. conversion trigger from external peripheral: TIM2 channel 2 event (capture
  904. compare: input capture or output capture). Trigger edge set to rising edge
  905. (default setting). */
  906. #define LL_ADC_REG_TRIG_EXT_TIM3_TRGO (ADC_CFGR_EXTSEL_2 | ADC_REG_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group regular
  907. conversion trigger from external peripheral: TIM3 TRGO. Trigger edge set to
  908. rising edge (default setting). */
  909. #define LL_ADC_REG_TRIG_EXT_TIM3_CH4 (ADC_CFGR_EXTSEL_3 | ADC_CFGR_EXTSEL_2 | \
  910. ADC_CFGR_EXTSEL_1 | ADC_CFGR_EXTSEL_0 | \
  911. ADC_REG_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group regular
  912. conversion trigger from external peripheral: TIM3 channel 4 event (capture
  913. compare: input capture or output capture). Trigger edge set to rising edge
  914. (default setting). */
  915. #define LL_ADC_REG_TRIG_EXT_TIM4_TRGO (ADC_CFGR_EXTSEL_3 | ADC_CFGR_EXTSEL_2 | \
  916. ADC_REG_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group regular
  917. conversion trigger from external peripheral: TIM4 TRGO. Trigger edge set to
  918. rising edge (default setting). */
  919. #define LL_ADC_REG_TRIG_EXT_TIM4_CH4 (ADC_CFGR_EXTSEL_2 | ADC_CFGR_EXTSEL_0 | \
  920. ADC_REG_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group regular
  921. conversion trigger from external peripheral: TIM4 channel 4 event (capture
  922. compare: input capture or output capture). Trigger edge set to
  923. rising edge (default setting). */
  924. #define LL_ADC_REG_TRIG_EXT_TIM6_TRGO (ADC_CFGR_EXTSEL_3 | ADC_CFGR_EXTSEL_2 | \
  925. ADC_CFGR_EXTSEL_0 | ADC_REG_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group regular
  926. conversion trigger from external peripheral: TIM6 TRGO. Trigger edge set to
  927. rising edge (default setting). */
  928. #define LL_ADC_REG_TRIG_EXT_TIM8_TRGO (ADC_CFGR_EXTSEL_2 | ADC_CFGR_EXTSEL_1 | \
  929. ADC_CFGR_EXTSEL_0 | ADC_REG_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group regular
  930. conversion trigger from external peripheral: TIM8 TRGO. Trigger edge set to
  931. rising edge (default setting). */
  932. #define LL_ADC_REG_TRIG_EXT_TIM8_TRGO2 (ADC_CFGR_EXTSEL_3 | ADC_REG_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group regular
  933. conversion trigger from external peripheral: TIM8 TRGO2. Trigger edge set to
  934. rising edge (default setting). */
  935. #define LL_ADC_REG_TRIG_EXT_TIM15_TRGO (ADC_CFGR_EXTSEL_3 | ADC_CFGR_EXTSEL_2 | \
  936. ADC_CFGR_EXTSEL_1 | ADC_REG_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group regular
  937. conversion trigger from external peripheral: TIM15 TRGO. Trigger edge set to
  938. rising edge (default setting). */
  939. #define LL_ADC_REG_TRIG_EXT_EXTI_LINE11 (ADC_CFGR_EXTSEL_2 | ADC_CFGR_EXTSEL_1 | \
  940. ADC_REG_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group regular
  941. conversion trigger from external peripheral: external interrupt line 11.
  942. Trigger edge set to rising edge (default setting). */
  943. /**
  944. * @}
  945. */
  946. /** @defgroup ADC_LL_EC_REG_TRIGGER_EDGE ADC group regular - Trigger edge
  947. * @{
  948. */
  949. #define LL_ADC_REG_TRIG_EXT_RISING (ADC_CFGR_EXTEN_0) /*!< ADC group regular conversion
  950. trigger polarity set to rising edge */
  951. #define LL_ADC_REG_TRIG_EXT_FALLING (ADC_CFGR_EXTEN_1) /*!< ADC group regular conversion
  952. trigger polarity set to falling edge */
  953. #define LL_ADC_REG_TRIG_EXT_RISINGFALLING (ADC_CFGR_EXTEN_1 | ADC_CFGR_EXTEN_0) /*!< ADC group regular conversion
  954. trigger polarity set to both rising and falling edges */
  955. /**
  956. * @}
  957. */
  958. /** @defgroup ADC_LL_EC_REG_CONTINUOUS_MODE ADC group regular - Continuous mode
  959. * @{
  960. */
  961. #define LL_ADC_REG_CONV_SINGLE (0x00000000UL) /*!< ADC conversions performed in single mode:
  962. one conversion per trigger */
  963. #define LL_ADC_REG_CONV_CONTINUOUS (ADC_CFGR_CONT) /*!< ADC conversions performed in continuous mode:
  964. after the first trigger, following conversions launched successively
  965. automatically */
  966. /**
  967. * @}
  968. */
  969. /** @defgroup ADC_LL_EC_REG_DMA_TRANSFER ADC group regular - DMA transfer of ADC conversion data
  970. * @{
  971. */
  972. #define LL_ADC_REG_DMA_TRANSFER_NONE (0x00000000UL) /*!< ADC conversions are not transferred by DMA */
  973. #define LL_ADC_REG_DMA_TRANSFER_LIMITED (ADC_CFGR_DMAEN) /*!< ADC conversion data are transferred by DMA
  974. in limited mode (one shot mode): DMA transfer requests are stopped when
  975. number of DMA data transfers (number of ADC conversions) is reached.
  976. This ADC mode is intended to be used with DMA mode non-circular. */
  977. #define LL_ADC_REG_DMA_TRANSFER_UNLIMITED (ADC_CFGR_DMACFG | ADC_CFGR_DMAEN) /*!< ADC conversion data are
  978. transferred by DMA, in unlimited mode: DMA transfer requests are unlimited,
  979. whatever number of DMA data transferred (number of ADC conversions).
  980. This ADC mode is intended to be used with DMA mode circular. */
  981. /**
  982. * @}
  983. */
  984. #if defined(ADC_CFGR_DFSDMCFG) &&defined(DFSDM1_Channel0)
  985. /** @defgroup ADC_LL_EC_REG_DFSDM_TRANSFER ADC group regular - DFSDM transfer of ADC conversion data
  986. * @{
  987. */
  988. #define LL_ADC_REG_DFSDM_TRANSFER_NONE (0x00000000UL) /*!< ADC conversions are not transferred by DFSDM. */
  989. #define LL_ADC_REG_DFSDM_TRANSFER_ENABLE (ADC_CFGR_DFSDMCFG) /*!< ADC conversion data are transferred to DFSDM for
  990. post processing. The ADC conversion data format must be 16-bit signed and
  991. right aligned, refer to reference manual.
  992. DFSDM transfer cannot be used if DMA transfer is enabled. */
  993. /**
  994. * @}
  995. */
  996. #endif /* ADC_CFGR_DFSDMCFG */
  997. #if defined(ADC_SMPR1_SMPPLUS)
  998. /** @defgroup ADC_LL_EC_SAMPLINGTIME_COMMON_CONFIG ADC instance - ADC sampling time common configuration
  999. * @{
  1000. */
  1001. #define LL_ADC_SAMPLINGTIME_COMMON_DEFAULT (0x00000000UL) /*!< ADC sampling time let to default settings. */
  1002. #define LL_ADC_SAMPLINGTIME_COMMON_3C5_REPL_2C5 (ADC_SMPR1_SMPPLUS) /*!< ADC additional sampling time 3.5 ADC clock
  1003. cycles replacing 2.5 ADC clock cycles (this applies to all channels mapped
  1004. with selection sampling time 2.5 ADC clock cycles, whatever channels mapped
  1005. on ADC groups regular or injected). */
  1006. /**
  1007. * @}
  1008. */
  1009. #endif /* ADC_SMPR1_SMPPLUS */
  1010. /** @defgroup ADC_LL_EC_REG_OVR_DATA_BEHAVIOR ADC group regular - Overrun behavior on conversion data
  1011. * @{
  1012. */
  1013. #define LL_ADC_REG_OVR_DATA_PRESERVED (0x00000000UL) /*!< ADC group regular behavior in case of overrun:
  1014. data preserved */
  1015. #define LL_ADC_REG_OVR_DATA_OVERWRITTEN (ADC_CFGR_OVRMOD) /*!< ADC group regular behavior in case of overrun:
  1016. data overwritten */
  1017. /**
  1018. * @}
  1019. */
  1020. /** @defgroup ADC_LL_EC_REG_SEQ_SCAN_LENGTH ADC group regular - Sequencer scan length
  1021. * @{
  1022. */
  1023. #define LL_ADC_REG_SEQ_SCAN_DISABLE (0x00000000UL) /*!< ADC group regular sequencer disable
  1024. (equivalent to sequencer of 1 rank: ADC conversion on only 1 channel) */
  1025. #define LL_ADC_REG_SEQ_SCAN_ENABLE_2RANKS (ADC_SQR1_L_0) /*!< ADC group regular sequencer enable
  1026. with 2 ranks in the sequence */
  1027. #define LL_ADC_REG_SEQ_SCAN_ENABLE_3RANKS (ADC_SQR1_L_1) /*!< ADC group regular sequencer enable
  1028. with 3 ranks in the sequence */
  1029. #define LL_ADC_REG_SEQ_SCAN_ENABLE_4RANKS (ADC_SQR1_L_1 | ADC_SQR1_L_0) /*!< ADC group regular sequencer enable
  1030. with 4 ranks in the sequence */
  1031. #define LL_ADC_REG_SEQ_SCAN_ENABLE_5RANKS (ADC_SQR1_L_2) /*!< ADC group regular sequencer enable
  1032. with 5 ranks in the sequence */
  1033. #define LL_ADC_REG_SEQ_SCAN_ENABLE_6RANKS (ADC_SQR1_L_2 | ADC_SQR1_L_0) /*!< ADC group regular sequencer enable
  1034. with 6 ranks in the sequence */
  1035. #define LL_ADC_REG_SEQ_SCAN_ENABLE_7RANKS (ADC_SQR1_L_2 | ADC_SQR1_L_1) /*!< ADC group regular sequencer enable
  1036. with 7 ranks in the sequence */
  1037. #define LL_ADC_REG_SEQ_SCAN_ENABLE_8RANKS (ADC_SQR1_L_2 | ADC_SQR1_L_1 \
  1038. | ADC_SQR1_L_0) /*!< ADC group regular sequencer enable
  1039. with 8 ranks in the sequence */
  1040. #define LL_ADC_REG_SEQ_SCAN_ENABLE_9RANKS (ADC_SQR1_L_3) /*!< ADC group regular sequencer enable
  1041. with 9 ranks in the sequence */
  1042. #define LL_ADC_REG_SEQ_SCAN_ENABLE_10RANKS (ADC_SQR1_L_3 | ADC_SQR1_L_0) /*!< ADC group regular sequencer enable
  1043. with 10 ranks in the sequence */
  1044. #define LL_ADC_REG_SEQ_SCAN_ENABLE_11RANKS (ADC_SQR1_L_3 | ADC_SQR1_L_1) /*!< ADC group regular sequencer enable
  1045. with 11 ranks in the sequence */
  1046. #define LL_ADC_REG_SEQ_SCAN_ENABLE_12RANKS (ADC_SQR1_L_3 | ADC_SQR1_L_1 \
  1047. | ADC_SQR1_L_0) /*!< ADC group regular sequencer enable
  1048. with 12 ranks in the sequence */
  1049. #define LL_ADC_REG_SEQ_SCAN_ENABLE_13RANKS (ADC_SQR1_L_3 | ADC_SQR1_L_2) /*!< ADC group regular sequencer enable
  1050. with 13 ranks in the sequence */
  1051. #define LL_ADC_REG_SEQ_SCAN_ENABLE_14RANKS (ADC_SQR1_L_3 | ADC_SQR1_L_2 \
  1052. | ADC_SQR1_L_0) /*!< ADC group regular sequencer enable
  1053. with 14 ranks in the sequence */
  1054. #define LL_ADC_REG_SEQ_SCAN_ENABLE_15RANKS (ADC_SQR1_L_3 | ADC_SQR1_L_2 \
  1055. | ADC_SQR1_L_1) /*!< ADC group regular sequencerenable
  1056. with 15 ranks in the sequence */
  1057. #define LL_ADC_REG_SEQ_SCAN_ENABLE_16RANKS (ADC_SQR1_L_3 | ADC_SQR1_L_2 \
  1058. | ADC_SQR1_L_1 | ADC_SQR1_L_0) /*!< ADC group regular sequencer enable
  1059. with 16 ranks in the sequence */
  1060. /**
  1061. * @}
  1062. */
  1063. /** @defgroup ADC_LL_EC_REG_SEQ_DISCONT_MODE ADC group regular - Sequencer discontinuous mode
  1064. * @{
  1065. */
  1066. #define LL_ADC_REG_SEQ_DISCONT_DISABLE (0x00000000UL) /*!< ADC group regular sequencer
  1067. discontinuous mode disable */
  1068. #define LL_ADC_REG_SEQ_DISCONT_1RANK (ADC_CFGR_DISCEN) /*!< ADC group regular sequencer
  1069. discontinuous mode enable with sequence interruption every rank */
  1070. #define LL_ADC_REG_SEQ_DISCONT_2RANKS (ADC_CFGR_DISCNUM_0 | ADC_CFGR_DISCEN) /*!< ADC group regular sequencer
  1071. discontinuous mode enabled with sequence interruption every 2 ranks */
  1072. #define LL_ADC_REG_SEQ_DISCONT_3RANKS (ADC_CFGR_DISCNUM_1 | ADC_CFGR_DISCEN) /*!< ADC group regular sequencer
  1073. discontinuous mode enable with sequence interruption every 3 ranks */
  1074. #define LL_ADC_REG_SEQ_DISCONT_4RANKS (ADC_CFGR_DISCNUM_1 | ADC_CFGR_DISCNUM_0 \
  1075. | ADC_CFGR_DISCEN) /*!< ADC group regular sequencer
  1076. discontinuous mode enable with sequence interruption every 4 ranks */
  1077. #define LL_ADC_REG_SEQ_DISCONT_5RANKS (ADC_CFGR_DISCNUM_2 | ADC_CFGR_DISCEN) /*!< ADC group regular sequencer
  1078. discontinuous mode enable with sequence interruption every 5 ranks */
  1079. #define LL_ADC_REG_SEQ_DISCONT_6RANKS (ADC_CFGR_DISCNUM_2 | ADC_CFGR_DISCNUM_0 \
  1080. | ADC_CFGR_DISCEN) /*!< ADC group regular sequencer
  1081. discontinuous mode enable with sequence interruption every 6 ranks */
  1082. #define LL_ADC_REG_SEQ_DISCONT_7RANKS (ADC_CFGR_DISCNUM_2 | ADC_CFGR_DISCNUM_1 \
  1083. | ADC_CFGR_DISCEN) /*!< ADC group regular sequencer
  1084. discontinuous mode enable with sequence interruption every 7 ranks */
  1085. #define LL_ADC_REG_SEQ_DISCONT_8RANKS (ADC_CFGR_DISCNUM_2 | ADC_CFGR_DISCNUM_1 \
  1086. | ADC_CFGR_DISCNUM_0 | ADC_CFGR_DISCEN) /*!< ADC group regular sequencer
  1087. discontinuous mode enable with sequence interruption every 8 ranks */
  1088. /**
  1089. * @}
  1090. */
  1091. /** @defgroup ADC_LL_EC_REG_SEQ_RANKS ADC group regular - Sequencer ranks
  1092. * @{
  1093. */
  1094. #define LL_ADC_REG_RANK_1 (ADC_SQR1_REGOFFSET | ADC_REG_RANK_1_SQRX_BITOFFSET_POS) /*!< ADC group
  1095. regular sequencer rank 1 */
  1096. #define LL_ADC_REG_RANK_2 (ADC_SQR1_REGOFFSET | ADC_REG_RANK_2_SQRX_BITOFFSET_POS) /*!< ADC group
  1097. regular sequencer rank 2 */
  1098. #define LL_ADC_REG_RANK_3 (ADC_SQR1_REGOFFSET | ADC_REG_RANK_3_SQRX_BITOFFSET_POS) /*!< ADC group
  1099. regular sequencer rank 3 */
  1100. #define LL_ADC_REG_RANK_4 (ADC_SQR1_REGOFFSET | ADC_REG_RANK_4_SQRX_BITOFFSET_POS) /*!< ADC group
  1101. regular sequencer rank 4 */
  1102. #define LL_ADC_REG_RANK_5 (ADC_SQR2_REGOFFSET | ADC_REG_RANK_5_SQRX_BITOFFSET_POS) /*!< ADC group
  1103. regular sequencer rank 5 */
  1104. #define LL_ADC_REG_RANK_6 (ADC_SQR2_REGOFFSET | ADC_REG_RANK_6_SQRX_BITOFFSET_POS) /*!< ADC group
  1105. regular sequencer rank 6 */
  1106. #define LL_ADC_REG_RANK_7 (ADC_SQR2_REGOFFSET | ADC_REG_RANK_7_SQRX_BITOFFSET_POS) /*!< ADC group
  1107. regular sequencer rank 7 */
  1108. #define LL_ADC_REG_RANK_8 (ADC_SQR2_REGOFFSET | ADC_REG_RANK_8_SQRX_BITOFFSET_POS) /*!< ADC group
  1109. regular sequencer rank 8 */
  1110. #define LL_ADC_REG_RANK_9 (ADC_SQR2_REGOFFSET | ADC_REG_RANK_9_SQRX_BITOFFSET_POS) /*!< ADC group
  1111. regular sequencer rank 9 */
  1112. #define LL_ADC_REG_RANK_10 (ADC_SQR3_REGOFFSET | ADC_REG_RANK_10_SQRX_BITOFFSET_POS) /*!< ADC group
  1113. regular sequencer rank 10 */
  1114. #define LL_ADC_REG_RANK_11 (ADC_SQR3_REGOFFSET | ADC_REG_RANK_11_SQRX_BITOFFSET_POS) /*!< ADC group
  1115. regular sequencer rank 11 */
  1116. #define LL_ADC_REG_RANK_12 (ADC_SQR3_REGOFFSET | ADC_REG_RANK_12_SQRX_BITOFFSET_POS) /*!< ADC group
  1117. regular sequencer rank 12 */
  1118. #define LL_ADC_REG_RANK_13 (ADC_SQR3_REGOFFSET | ADC_REG_RANK_13_SQRX_BITOFFSET_POS) /*!< ADC group
  1119. regular sequencer rank 13 */
  1120. #define LL_ADC_REG_RANK_14 (ADC_SQR3_REGOFFSET | ADC_REG_RANK_14_SQRX_BITOFFSET_POS) /*!< ADC group
  1121. regular sequencer rank 14 */
  1122. #define LL_ADC_REG_RANK_15 (ADC_SQR4_REGOFFSET | ADC_REG_RANK_15_SQRX_BITOFFSET_POS) /*!< ADC group
  1123. regular sequencer rank 15 */
  1124. #define LL_ADC_REG_RANK_16 (ADC_SQR4_REGOFFSET | ADC_REG_RANK_16_SQRX_BITOFFSET_POS) /*!< ADC group
  1125. regular sequencer rank 16 */
  1126. /**
  1127. * @}
  1128. */
  1129. /** @defgroup ADC_LL_EC_INJ_TRIGGER_SOURCE ADC group injected - Trigger source
  1130. * @{
  1131. */
  1132. #define LL_ADC_INJ_TRIG_SOFTWARE (0x00000000UL) /*!< ADC group injected
  1133. conversion trigger internal: SW start. */
  1134. #define LL_ADC_INJ_TRIG_EXT_TIM1_TRGO (ADC_INJ_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group injected
  1135. conversion trigger from external peripheral: TIM1 TRGO. Trigger edge set to
  1136. rising edge (default setting). */
  1137. #define LL_ADC_INJ_TRIG_EXT_TIM1_TRGO2 (ADC_JSQR_JEXTSEL_3 | ADC_INJ_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group injected
  1138. conversion trigger from external peripheral: TIM1 TRGO2. Trigger edge set to
  1139. rising edge (default setting). */
  1140. #define LL_ADC_INJ_TRIG_EXT_TIM1_CH4 (ADC_JSQR_JEXTSEL_0 | ADC_INJ_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group injected
  1141. conversion trigger from external peripheral: TIM1 channel 4 event (capture
  1142. compare: input capture or output capture). Trigger edge set to rising edge
  1143. (default setting). */
  1144. #define LL_ADC_INJ_TRIG_EXT_TIM2_TRGO (ADC_JSQR_JEXTSEL_1 | ADC_INJ_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group injected
  1145. conversion trigger from external peripheral: TIM2 TRGO. Trigger edge set to
  1146. rising edge (default setting). */
  1147. #define LL_ADC_INJ_TRIG_EXT_TIM2_CH1 (ADC_JSQR_JEXTSEL_1 | ADC_JSQR_JEXTSEL_0 | \
  1148. ADC_INJ_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group injected
  1149. conversion trigger from external peripheral: TIM2 channel 1 event (capture
  1150. compare: input capture or output capture). Trigger edge set to rising edge
  1151. (default setting). */
  1152. #define LL_ADC_INJ_TRIG_EXT_TIM3_TRGO (ADC_JSQR_JEXTSEL_3 | ADC_JSQR_JEXTSEL_2 | \
  1153. ADC_INJ_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group injected
  1154. conversion trigger from external peripheral: TIM3 TRGO. Trigger edge set to
  1155. rising edge (default setting). */
  1156. #define LL_ADC_INJ_TRIG_EXT_TIM3_CH1 (ADC_JSQR_JEXTSEL_3 | ADC_JSQR_JEXTSEL_2 | \
  1157. ADC_JSQR_JEXTSEL_0 | ADC_INJ_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group injected
  1158. conversion trigger from external peripheral: TIM3 channel 1 event (capture
  1159. compare: input capture or output capture). Trigger edge set to rising edge
  1160. (default setting). */
  1161. #define LL_ADC_INJ_TRIG_EXT_TIM3_CH3 (ADC_JSQR_JEXTSEL_3 | ADC_JSQR_JEXTSEL_1 | \
  1162. ADC_JSQR_JEXTSEL_0 | ADC_INJ_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group injected
  1163. conversion trigger from external peripheral: TIM3 channel 3 event (capture
  1164. compare: input capture or output capture). Trigger edge set to rising edge
  1165. (default setting). */
  1166. #define LL_ADC_INJ_TRIG_EXT_TIM3_CH4 (ADC_JSQR_JEXTSEL_2 | ADC_INJ_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group injected
  1167. conversion trigger from external peripheral: TIM3 channel 4 event (capture
  1168. compare: input capture or output capture). Trigger edge set to rising edge
  1169. (default setting). */
  1170. #define LL_ADC_INJ_TRIG_EXT_TIM4_TRGO (ADC_JSQR_JEXTSEL_2 | ADC_JSQR_JEXTSEL_0 | \
  1171. ADC_INJ_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group injected
  1172. conversion trigger from external peripheral: TIM4 TRGO. Trigger edge set to
  1173. rising edge (default setting). */
  1174. #define LL_ADC_INJ_TRIG_EXT_TIM6_TRGO (ADC_JSQR_JEXTSEL_3 | ADC_JSQR_JEXTSEL_2 | \
  1175. ADC_JSQR_JEXTSEL_1 | ADC_INJ_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group injected
  1176. conversion trigger from external peripheral: TIM6 TRGO. Trigger edge set to
  1177. rising edge (default setting). */
  1178. #define LL_ADC_INJ_TRIG_EXT_TIM8_CH4 (ADC_JSQR_JEXTSEL_2 | ADC_JSQR_JEXTSEL_1 | \
  1179. ADC_JSQR_JEXTSEL_0 | ADC_INJ_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group injected
  1180. conversion trigger from external peripheral: TIM8 channel 4 event (capture
  1181. compare: input capture or output capture). Trigger edge set to rising edge
  1182. (default setting). */
  1183. #define LL_ADC_INJ_TRIG_EXT_TIM8_TRGO (ADC_JSQR_JEXTSEL_3 | ADC_JSQR_JEXTSEL_0 | \
  1184. ADC_INJ_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group injected
  1185. conversion trigger from external peripheral: TIM8 TRGO. Trigger edge set to
  1186. rising edge (default setting). */
  1187. #define LL_ADC_INJ_TRIG_EXT_TIM8_TRGO2 (ADC_JSQR_JEXTSEL_3 | ADC_JSQR_JEXTSEL_1 | \
  1188. ADC_INJ_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group injected
  1189. conversion trigger from external peripheral: TIM8 TRGO2. Trigger edge set to
  1190. rising edge (default setting). */
  1191. #define LL_ADC_INJ_TRIG_EXT_TIM15_TRGO (ADC_JSQR_JEXTSEL_3 | ADC_JSQR_JEXTSEL_2 | \
  1192. ADC_JSQR_JEXTSEL_1 | ADC_JSQR_JEXTSEL_0 | \
  1193. ADC_INJ_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group injected
  1194. conversion trigger from external peripheral: TIM15 TRGO. Trigger edge set to
  1195. rising edge (default setting). */
  1196. #define LL_ADC_INJ_TRIG_EXT_EXTI_LINE15 (ADC_JSQR_JEXTSEL_2 | ADC_JSQR_JEXTSEL_1 | \
  1197. ADC_INJ_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group injected
  1198. conversion trigger from external peripheral: external interrupt line 15.
  1199. Trigger edge set to rising edge (default setting). */
  1200. /**
  1201. * @}
  1202. */
  1203. /** @defgroup ADC_LL_EC_INJ_TRIGGER_EDGE ADC group injected - Trigger edge
  1204. * @{
  1205. */
  1206. #define LL_ADC_INJ_TRIG_EXT_RISING ( ADC_JSQR_JEXTEN_0) /*!< ADC group injected conversion
  1207. trigger polarity set to rising edge */
  1208. #define LL_ADC_INJ_TRIG_EXT_FALLING (ADC_JSQR_JEXTEN_1 ) /*!< ADC group injected conversion
  1209. trigger polarity set to falling edge */
  1210. #define LL_ADC_INJ_TRIG_EXT_RISINGFALLING (ADC_JSQR_JEXTEN_1 | ADC_JSQR_JEXTEN_0) /*!< ADC group injected conversion
  1211. trigger polarity set to both rising and falling edges */
  1212. /**
  1213. * @}
  1214. */
  1215. /** @defgroup ADC_LL_EC_INJ_TRIG_AUTO ADC group injected - Automatic trigger mode
  1216. * @{
  1217. */
  1218. #define LL_ADC_INJ_TRIG_INDEPENDENT (0x00000000UL) /*!< ADC group injected conversion trigger independent.
  1219. Setting mandatory if ADC group injected injected trigger source is set to
  1220. an external trigger. */
  1221. #define LL_ADC_INJ_TRIG_FROM_GRP_REGULAR (ADC_CFGR_JAUTO) /*!< ADC group injected conversion trigger from ADC group
  1222. regular. Setting compliant only with group injected trigger source set to
  1223. SW start, without any further action on ADC group injected conversion start
  1224. or stop: in this case, ADC group injected is controlled only from ADC group
  1225. regular. */
  1226. /**
  1227. * @}
  1228. */
  1229. /** @defgroup ADC_LL_EC_INJ_CONTEXT_QUEUE ADC group injected - Context queue mode
  1230. * @{
  1231. */
  1232. #define LL_ADC_INJ_QUEUE_2CONTEXTS_LAST_ACTIVE (0x00000000UL) /* Group injected sequence context queue is enabled
  1233. and can contain up to 2 contexts. When all contexts have been processed,
  1234. the queue maintains the last context active perpetually. */
  1235. #define LL_ADC_INJ_QUEUE_2CONTEXTS_END_EMPTY (ADC_CFGR_JQM) /* Group injected sequence context queue is enabled
  1236. and can contain up to 2 contexts. When all contexts have been processed,
  1237. the queue is empty and injected group triggers are disabled. */
  1238. #define LL_ADC_INJ_QUEUE_DISABLE (ADC_CFGR_JQDIS) /* Group injected sequence context queue is disabled:
  1239. only 1 sequence can be configured and is active perpetually. */
  1240. /**
  1241. * @}
  1242. */
  1243. /** @defgroup ADC_LL_EC_INJ_SEQ_SCAN_LENGTH ADC group injected - Sequencer scan length
  1244. * @{
  1245. */
  1246. #define LL_ADC_INJ_SEQ_SCAN_DISABLE (0x00000000UL) /*!< ADC group injected sequencer disable
  1247. (equivalent to sequencer of 1 rank: ADC conversion on only 1 channel) */
  1248. #define LL_ADC_INJ_SEQ_SCAN_ENABLE_2RANKS ( ADC_JSQR_JL_0) /*!< ADC group injected sequencer enable
  1249. with 2 ranks in the sequence */
  1250. #define LL_ADC_INJ_SEQ_SCAN_ENABLE_3RANKS (ADC_JSQR_JL_1 ) /*!< ADC group injected sequencer enable
  1251. with 3 ranks in the sequence */
  1252. #define LL_ADC_INJ_SEQ_SCAN_ENABLE_4RANKS (ADC_JSQR_JL_1 | ADC_JSQR_JL_0) /*!< ADC group injected sequencer enable
  1253. with 4 ranks in the sequence */
  1254. /**
  1255. * @}
  1256. */
  1257. /** @defgroup ADC_LL_EC_INJ_SEQ_DISCONT_MODE ADC group injected - Sequencer discontinuous mode
  1258. * @{
  1259. */
  1260. #define LL_ADC_INJ_SEQ_DISCONT_DISABLE (0x00000000UL) /*!< ADC group injected sequencer discontinuous mode
  1261. disable */
  1262. #define LL_ADC_INJ_SEQ_DISCONT_1RANK (ADC_CFGR_JDISCEN) /*!< ADC group injected sequencer discontinuous mode
  1263. enable with sequence interruption every rank */
  1264. /**
  1265. * @}
  1266. */
  1267. /** @defgroup ADC_LL_EC_INJ_SEQ_RANKS ADC group injected - Sequencer ranks
  1268. * @{
  1269. */
  1270. #define LL_ADC_INJ_RANK_1 (ADC_JDR1_REGOFFSET \
  1271. | ADC_INJ_RANK_1_JSQR_BITOFFSET_POS) /*!< ADC group inj. sequencer rank 1 */
  1272. #define LL_ADC_INJ_RANK_2 (ADC_JDR2_REGOFFSET \
  1273. | ADC_INJ_RANK_2_JSQR_BITOFFSET_POS) /*!< ADC group inj. sequencer rank 2 */
  1274. #define LL_ADC_INJ_RANK_3 (ADC_JDR3_REGOFFSET \
  1275. | ADC_INJ_RANK_3_JSQR_BITOFFSET_POS) /*!< ADC group inj. sequencer rank 3 */
  1276. #define LL_ADC_INJ_RANK_4 (ADC_JDR4_REGOFFSET \
  1277. | ADC_INJ_RANK_4_JSQR_BITOFFSET_POS) /*!< ADC group inj. sequencer rank 4 */
  1278. /**
  1279. * @}
  1280. */
  1281. /** @defgroup ADC_LL_EC_CHANNEL_SAMPLINGTIME Channel - Sampling time
  1282. * @{
  1283. */
  1284. #define LL_ADC_SAMPLINGTIME_2CYCLES_5 (0x00000000UL) /*!< Sampling time 2.5 ADC clock cycles */
  1285. #define LL_ADC_SAMPLINGTIME_6CYCLES_5 (ADC_SMPR2_SMP10_0) /*!< Sampling time 6.5 ADC clock cycles */
  1286. #define LL_ADC_SAMPLINGTIME_12CYCLES_5 (ADC_SMPR2_SMP10_1) /*!< Sampling time 12.5 ADC clock cycles */
  1287. #define LL_ADC_SAMPLINGTIME_24CYCLES_5 (ADC_SMPR2_SMP10_1 \
  1288. | ADC_SMPR2_SMP10_0) /*!< Sampling time 24.5 ADC clock cycles */
  1289. #define LL_ADC_SAMPLINGTIME_47CYCLES_5 (ADC_SMPR2_SMP10_2) /*!< Sampling time 47.5 ADC clock cycles */
  1290. #define LL_ADC_SAMPLINGTIME_92CYCLES_5 (ADC_SMPR2_SMP10_2 \
  1291. | ADC_SMPR2_SMP10_0) /*!< Sampling time 92.5 ADC clock cycles */
  1292. #define LL_ADC_SAMPLINGTIME_247CYCLES_5 (ADC_SMPR2_SMP10_2 \
  1293. | ADC_SMPR2_SMP10_1) /*!< Sampling time 247.5 ADC clock cycles */
  1294. #define LL_ADC_SAMPLINGTIME_640CYCLES_5 (ADC_SMPR2_SMP10_2 \
  1295. | ADC_SMPR2_SMP10_1 \
  1296. | ADC_SMPR2_SMP10_0) /*!< Sampling time 640.5 ADC clock cycles */
  1297. /**
  1298. * @}
  1299. */
  1300. /** @defgroup ADC_LL_EC_CHANNEL_SINGLE_DIFF_ENDING Channel - Single or differential ending
  1301. * @{
  1302. */
  1303. #define LL_ADC_SINGLE_ENDED ( ADC_CALFACT_CALFACT_S) /*!< ADC channel ending
  1304. set to single ended (literal also used to set calibration mode) */
  1305. #define LL_ADC_DIFFERENTIAL_ENDED (ADC_CR_ADCALDIF | ADC_CALFACT_CALFACT_D) /*!< ADC channel ending
  1306. set to differential (literal also used to set calibration mode) */
  1307. #define LL_ADC_BOTH_SINGLE_DIFF_ENDED (LL_ADC_SINGLE_ENDED | LL_ADC_DIFFERENTIAL_ENDED) /*!< ADC channel ending
  1308. set to both single ended and differential (literal used only to set
  1309. calibration factors) */
  1310. /**
  1311. * @}
  1312. */
  1313. /** @defgroup ADC_LL_EC_AWD_NUMBER Analog watchdog - Analog watchdog number
  1314. * @{
  1315. */
  1316. #define LL_ADC_AWD1 (ADC_AWD_CR1_CHANNEL_MASK \
  1317. | ADC_AWD_CR1_REGOFFSET) /*!< ADC analog watchdog number 1 */
  1318. #define LL_ADC_AWD2 (ADC_AWD_CR23_CHANNEL_MASK \
  1319. | ADC_AWD_CR2_REGOFFSET) /*!< ADC analog watchdog number 2 */
  1320. #define LL_ADC_AWD3 (ADC_AWD_CR23_CHANNEL_MASK \
  1321. | ADC_AWD_CR3_REGOFFSET) /*!< ADC analog watchdog number 3 */
  1322. /**
  1323. * @}
  1324. */
  1325. /** @defgroup ADC_LL_EC_AWD_CHANNELS Analog watchdog - Monitored channels
  1326. * @{
  1327. */
  1328. #define LL_ADC_AWD_DISABLE (0x00000000UL) /*!< ADC analog watchdog monitoring
  1329. disabled */
  1330. #define LL_ADC_AWD_ALL_CHANNELS_REG (ADC_AWD_CR23_CHANNEL_MASK \
  1331. | ADC_CFGR_AWD1EN) /*!< ADC analog watchdog monitoring
  1332. of all channels, converted by group regular only */
  1333. #define LL_ADC_AWD_ALL_CHANNELS_INJ (ADC_AWD_CR23_CHANNEL_MASK \
  1334. | ADC_CFGR_JAWD1EN) /*!< ADC analog watchdog monitoring
  1335. of all channels, converted by group injected only */
  1336. #define LL_ADC_AWD_ALL_CHANNELS_REG_INJ (ADC_AWD_CR23_CHANNEL_MASK \
  1337. | ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1EN) /*!< ADC analog watchdog monitoring
  1338. of all channels, converted by either group regular or injected */
  1339. #define LL_ADC_AWD_CHANNEL_0_REG ((LL_ADC_CHANNEL_0 & ADC_CHANNEL_ID_MASK) \
  1340. | ADC_CFGR_AWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring
  1341. of ADC channel ADCx_IN0, converted by group regular only */
  1342. #define LL_ADC_AWD_CHANNEL_0_INJ ((LL_ADC_CHANNEL_0 & ADC_CHANNEL_ID_MASK) \
  1343. | ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring
  1344. of ADC channel ADCx_IN0, converted by group injected only */
  1345. #define LL_ADC_AWD_CHANNEL_0_REG_INJ ((LL_ADC_CHANNEL_0 & ADC_CHANNEL_ID_MASK) \
  1346. | ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1EN \
  1347. | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring
  1348. of ADC channel ADCx_IN0, converted by either group regular or injected */
  1349. #define LL_ADC_AWD_CHANNEL_1_REG ((LL_ADC_CHANNEL_1 & ADC_CHANNEL_ID_MASK) \
  1350. | ADC_CFGR_AWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring
  1351. of ADC channel ADCx_IN1, converted by group regular only */
  1352. #define LL_ADC_AWD_CHANNEL_1_INJ ((LL_ADC_CHANNEL_1 & ADC_CHANNEL_ID_MASK) \
  1353. | ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring
  1354. of ADC channel ADCx_IN1, converted by group injected only */
  1355. #define LL_ADC_AWD_CHANNEL_1_REG_INJ ((LL_ADC_CHANNEL_1 & ADC_CHANNEL_ID_MASK) \
  1356. | ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1EN \
  1357. | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring
  1358. of ADC channel ADCx_IN1, converted by either group regular or injected */
  1359. #define LL_ADC_AWD_CHANNEL_2_REG ((LL_ADC_CHANNEL_2 & ADC_CHANNEL_ID_MASK) \
  1360. | ADC_CFGR_AWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring
  1361. of ADC channel ADCx_IN2, converted by group regular only */
  1362. #define LL_ADC_AWD_CHANNEL_2_INJ ((LL_ADC_CHANNEL_2 & ADC_CHANNEL_ID_MASK) \
  1363. | ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring
  1364. of ADC channel ADCx_IN2, converted by group injected only */
  1365. #define LL_ADC_AWD_CHANNEL_2_REG_INJ ((LL_ADC_CHANNEL_2 & ADC_CHANNEL_ID_MASK) \
  1366. | ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1EN \
  1367. | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring
  1368. of ADC channel ADCx_IN2, converted by either group regular or injected */
  1369. #define LL_ADC_AWD_CHANNEL_3_REG ((LL_ADC_CHANNEL_3 & ADC_CHANNEL_ID_MASK) \
  1370. | ADC_CFGR_AWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring
  1371. of ADC channel ADCx_IN3, converted by group regular only */
  1372. #define LL_ADC_AWD_CHANNEL_3_INJ ((LL_ADC_CHANNEL_3 & ADC_CHANNEL_ID_MASK) \
  1373. | ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring
  1374. of ADC channel ADCx_IN3, converted by group injected only */
  1375. #define LL_ADC_AWD_CHANNEL_3_REG_INJ ((LL_ADC_CHANNEL_3 & ADC_CHANNEL_ID_MASK) \
  1376. | ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1EN \
  1377. | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring
  1378. of ADC channel ADCx_IN3, converted by either group regular or injected */
  1379. #define LL_ADC_AWD_CHANNEL_4_REG ((LL_ADC_CHANNEL_4 & ADC_CHANNEL_ID_MASK) \
  1380. | ADC_CFGR_AWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring
  1381. of ADC channel ADCx_IN4, converted by group regular only */
  1382. #define LL_ADC_AWD_CHANNEL_4_INJ ((LL_ADC_CHANNEL_4 & ADC_CHANNEL_ID_MASK) \
  1383. | ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring
  1384. of ADC channel ADCx_IN4, converted by group injected only */
  1385. #define LL_ADC_AWD_CHANNEL_4_REG_INJ ((LL_ADC_CHANNEL_4 & ADC_CHANNEL_ID_MASK) \
  1386. | ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1EN \
  1387. | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring
  1388. of ADC channel ADCx_IN4, converted by either group regular or injected */
  1389. #define LL_ADC_AWD_CHANNEL_5_REG ((LL_ADC_CHANNEL_5 & ADC_CHANNEL_ID_MASK) \
  1390. | ADC_CFGR_AWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring
  1391. of ADC channel ADCx_IN5, converted by group regular only */
  1392. #define LL_ADC_AWD_CHANNEL_5_INJ ((LL_ADC_CHANNEL_5 & ADC_CHANNEL_ID_MASK) \
  1393. | ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring
  1394. of ADC channel ADCx_IN5, converted by group injected only */
  1395. #define LL_ADC_AWD_CHANNEL_5_REG_INJ ((LL_ADC_CHANNEL_5 & ADC_CHANNEL_ID_MASK) \
  1396. | ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1EN \
  1397. | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring
  1398. of ADC channel ADCx_IN5, converted by either group regular or injected */
  1399. #define LL_ADC_AWD_CHANNEL_6_REG ((LL_ADC_CHANNEL_6 & ADC_CHANNEL_ID_MASK) \
  1400. | ADC_CFGR_AWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring
  1401. of ADC channel ADCx_IN6, converted by group regular only */
  1402. #define LL_ADC_AWD_CHANNEL_6_INJ ((LL_ADC_CHANNEL_6 & ADC_CHANNEL_ID_MASK) \
  1403. | ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring
  1404. of ADC channel ADCx_IN6, converted by group injected only */
  1405. #define LL_ADC_AWD_CHANNEL_6_REG_INJ ((LL_ADC_CHANNEL_6 & ADC_CHANNEL_ID_MASK) \
  1406. | ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1EN \
  1407. | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring
  1408. of ADC channel ADCx_IN6, converted by either group regular or injected */
  1409. #define LL_ADC_AWD_CHANNEL_7_REG ((LL_ADC_CHANNEL_7 & ADC_CHANNEL_ID_MASK) \
  1410. | ADC_CFGR_AWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring
  1411. of ADC channel ADCx_IN7, converted by group regular only */
  1412. #define LL_ADC_AWD_CHANNEL_7_INJ ((LL_ADC_CHANNEL_7 & ADC_CHANNEL_ID_MASK) \
  1413. | ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring
  1414. of ADC channel ADCx_IN7, converted by group injected only */
  1415. #define LL_ADC_AWD_CHANNEL_7_REG_INJ ((LL_ADC_CHANNEL_7 & ADC_CHANNEL_ID_MASK) \
  1416. | ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1EN \
  1417. | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring
  1418. of ADC channel ADCx_IN7, converted by either group regular or injected */
  1419. #define LL_ADC_AWD_CHANNEL_8_REG ((LL_ADC_CHANNEL_8 & ADC_CHANNEL_ID_MASK) \
  1420. | ADC_CFGR_AWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring
  1421. of ADC channel ADCx_IN8, converted by group regular only */
  1422. #define LL_ADC_AWD_CHANNEL_8_INJ ((LL_ADC_CHANNEL_8 & ADC_CHANNEL_ID_MASK) \
  1423. | ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring
  1424. of ADC channel ADCx_IN8, converted by group injected only */
  1425. #define LL_ADC_AWD_CHANNEL_8_REG_INJ ((LL_ADC_CHANNEL_8 & ADC_CHANNEL_ID_MASK) \
  1426. | ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1EN \
  1427. | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring
  1428. of ADC channel ADCx_IN8, converted by either group regular or injected */
  1429. #define LL_ADC_AWD_CHANNEL_9_REG ((LL_ADC_CHANNEL_9 & ADC_CHANNEL_ID_MASK) \
  1430. | ADC_CFGR_AWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring
  1431. of ADC channel ADCx_IN9, converted by group regular only */
  1432. #define LL_ADC_AWD_CHANNEL_9_INJ ((LL_ADC_CHANNEL_9 & ADC_CHANNEL_ID_MASK) \
  1433. | ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring
  1434. of ADC channel ADCx_IN9, converted by group injected only */
  1435. #define LL_ADC_AWD_CHANNEL_9_REG_INJ ((LL_ADC_CHANNEL_9 & ADC_CHANNEL_ID_MASK) \
  1436. | ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1EN \
  1437. | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring
  1438. of ADC channel ADCx_IN9, converted by either group regular or injected */
  1439. #define LL_ADC_AWD_CHANNEL_10_REG ((LL_ADC_CHANNEL_10 & ADC_CHANNEL_ID_MASK) \
  1440. | ADC_CFGR_AWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring
  1441. of ADC channel ADCx_IN10, converted by group regular only */
  1442. #define LL_ADC_AWD_CHANNEL_10_INJ ((LL_ADC_CHANNEL_10 & ADC_CHANNEL_ID_MASK) \
  1443. | ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring
  1444. of ADC channel ADCx_IN10, converted by group injected only */
  1445. #define LL_ADC_AWD_CHANNEL_10_REG_INJ ((LL_ADC_CHANNEL_10 & ADC_CHANNEL_ID_MASK)\
  1446. | ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1EN \
  1447. | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring
  1448. of ADC channel ADCx_IN10, converted by either group regular or injected */
  1449. #define LL_ADC_AWD_CHANNEL_11_REG ((LL_ADC_CHANNEL_11 & ADC_CHANNEL_ID_MASK) \
  1450. | ADC_CFGR_AWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring
  1451. of ADC channel ADCx_IN11, converted by group regular only */
  1452. #define LL_ADC_AWD_CHANNEL_11_INJ ((LL_ADC_CHANNEL_11 & ADC_CHANNEL_ID_MASK) \
  1453. | ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring
  1454. of ADC channel ADCx_IN11, converted by group injected only */
  1455. #define LL_ADC_AWD_CHANNEL_11_REG_INJ ((LL_ADC_CHANNEL_11 & ADC_CHANNEL_ID_MASK) \
  1456. | ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1EN \
  1457. | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring
  1458. of ADC channel ADCx_IN11, converted by either group regular or injected */
  1459. #define LL_ADC_AWD_CHANNEL_12_REG ((LL_ADC_CHANNEL_12 & ADC_CHANNEL_ID_MASK) \
  1460. | ADC_CFGR_AWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring
  1461. of ADC channel ADCx_IN12, converted by group regular only */
  1462. #define LL_ADC_AWD_CHANNEL_12_INJ ((LL_ADC_CHANNEL_12 & ADC_CHANNEL_ID_MASK) \
  1463. | ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring
  1464. of ADC channel ADCx_IN12, converted by group injected only */
  1465. #define LL_ADC_AWD_CHANNEL_12_REG_INJ ((LL_ADC_CHANNEL_12 & ADC_CHANNEL_ID_MASK) \
  1466. | ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1EN \
  1467. | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring
  1468. of ADC channel ADCx_IN12, converted by either group regular or injected */
  1469. #define LL_ADC_AWD_CHANNEL_13_REG ((LL_ADC_CHANNEL_13 & ADC_CHANNEL_ID_MASK) \
  1470. | ADC_CFGR_AWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring
  1471. of ADC channel ADCx_IN13, converted by group regular only */
  1472. #define LL_ADC_AWD_CHANNEL_13_INJ ((LL_ADC_CHANNEL_13 & ADC_CHANNEL_ID_MASK) \
  1473. | ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring
  1474. of ADC channel ADCx_IN13, converted by group injected only */
  1475. #define LL_ADC_AWD_CHANNEL_13_REG_INJ ((LL_ADC_CHANNEL_13 & ADC_CHANNEL_ID_MASK) \
  1476. | ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1EN \
  1477. | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring
  1478. of ADC channel ADCx_IN13, converted by either group regular or injected */
  1479. #define LL_ADC_AWD_CHANNEL_14_REG ((LL_ADC_CHANNEL_14 & ADC_CHANNEL_ID_MASK) \
  1480. | ADC_CFGR_AWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring
  1481. of ADC channel ADCx_IN14, converted by group regular only */
  1482. #define LL_ADC_AWD_CHANNEL_14_INJ ((LL_ADC_CHANNEL_14 & ADC_CHANNEL_ID_MASK) \
  1483. | ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring
  1484. of ADC channel ADCx_IN14, converted by group only */
  1485. #define LL_ADC_AWD_CHANNEL_14_REG_INJ ((LL_ADC_CHANNEL_14 & ADC_CHANNEL_ID_MASK) \
  1486. | ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1EN \
  1487. | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring
  1488. of ADC channel ADCx_IN14, converted by either group regular or injected */
  1489. #define LL_ADC_AWD_CHANNEL_15_REG ((LL_ADC_CHANNEL_15 & ADC_CHANNEL_ID_MASK) \
  1490. | ADC_CFGR_AWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring
  1491. monitoring of ADC channel ADCx_IN15, converted by group regular only */
  1492. #define LL_ADC_AWD_CHANNEL_15_INJ ((LL_ADC_CHANNEL_15 & ADC_CHANNEL_ID_MASK) \
  1493. | ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring
  1494. of ADC channel ADCx_IN15, converted by group injected only */
  1495. #define LL_ADC_AWD_CHANNEL_15_REG_INJ ((LL_ADC_CHANNEL_15 & ADC_CHANNEL_ID_MASK) \
  1496. | ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1EN \
  1497. | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring
  1498. of ADC channel ADCx_IN15, converted by either group
  1499. regular or injected */
  1500. #define LL_ADC_AWD_CHANNEL_16_REG ((LL_ADC_CHANNEL_16 & ADC_CHANNEL_ID_MASK) \
  1501. | ADC_CFGR_AWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring
  1502. of ADC channel ADCx_IN16, converted by group regular only */
  1503. #define LL_ADC_AWD_CHANNEL_16_INJ ((LL_ADC_CHANNEL_16 & ADC_CHANNEL_ID_MASK) \
  1504. | ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring
  1505. of ADC channel ADCx_IN16, converted by group injected only */
  1506. #define LL_ADC_AWD_CHANNEL_16_REG_INJ ((LL_ADC_CHANNEL_16 & ADC_CHANNEL_ID_MASK) \
  1507. | ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1EN \
  1508. | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring
  1509. of ADC channel ADCx_IN16, converted by either group regular or injected */
  1510. #define LL_ADC_AWD_CHANNEL_17_REG ((LL_ADC_CHANNEL_17 & ADC_CHANNEL_ID_MASK) \
  1511. | ADC_CFGR_AWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring
  1512. of ADC channel ADCx_IN17, converted by group regular only */
  1513. #define LL_ADC_AWD_CHANNEL_17_INJ ((LL_ADC_CHANNEL_17 & ADC_CHANNEL_ID_MASK) \
  1514. | ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring
  1515. of ADC channel ADCx_IN17, converted by group injected only */
  1516. #define LL_ADC_AWD_CHANNEL_17_REG_INJ ((LL_ADC_CHANNEL_17 & ADC_CHANNEL_ID_MASK) \
  1517. | ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1EN \
  1518. | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring
  1519. of ADC channel ADCx_IN17, converted by either group regular or injected */
  1520. #define LL_ADC_AWD_CHANNEL_18_REG ((LL_ADC_CHANNEL_18 & ADC_CHANNEL_ID_MASK) \
  1521. | ADC_CFGR_AWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring
  1522. of ADC channel ADCx_IN18, converted by group regular only */
  1523. #define LL_ADC_AWD_CHANNEL_18_INJ ((LL_ADC_CHANNEL_18 & ADC_CHANNEL_ID_MASK) \
  1524. | ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring
  1525. of ADC channel ADCx_IN18, converted by group injected only */
  1526. #define LL_ADC_AWD_CHANNEL_18_REG_INJ ((LL_ADC_CHANNEL_18 & ADC_CHANNEL_ID_MASK) \
  1527. | ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1EN \
  1528. | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring
  1529. of ADC channel ADCx_IN18, converted by either group
  1530. regular or injected */
  1531. #define LL_ADC_AWD_CH_VREFINT_REG ((LL_ADC_CHANNEL_VREFINT & ADC_CHANNEL_ID_MASK) \
  1532. | ADC_CFGR_AWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring
  1533. of ADC internal channel connected to VrefInt: Internal
  1534. voltage reference, converted by group regular only */
  1535. #define LL_ADC_AWD_CH_VREFINT_INJ ((LL_ADC_CHANNEL_VREFINT & ADC_CHANNEL_ID_MASK) \
  1536. | ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring
  1537. of ADC internal channel connected to VrefInt: Internal
  1538. voltage reference, converted by group injected only */
  1539. #define LL_ADC_AWD_CH_VREFINT_REG_INJ ((LL_ADC_CHANNEL_VREFINT & ADC_CHANNEL_ID_MASK) \
  1540. | ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1EN \
  1541. | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring
  1542. of ADC internal channel connected to VrefInt: Internal
  1543. voltage reference, converted by either group regular or injected */
  1544. #define LL_ADC_AWD_CH_TEMPSENSOR_REG ((LL_ADC_CHANNEL_TEMPSENSOR & ADC_CHANNEL_ID_MASK) \
  1545. | ADC_CFGR_AWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring
  1546. of ADC internal channel connected to internal temperature sensor,
  1547. converted by group regular only */
  1548. #define LL_ADC_AWD_CH_TEMPSENSOR_INJ ((LL_ADC_CHANNEL_TEMPSENSOR & ADC_CHANNEL_ID_MASK) \
  1549. | ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring
  1550. of ADC internal channel connected to internal temperature sensor,
  1551. converted by group injected only */
  1552. #define LL_ADC_AWD_CH_TEMPSENSOR_REG_INJ ((LL_ADC_CHANNEL_TEMPSENSOR & ADC_CHANNEL_ID_MASK) \
  1553. | ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1EN \
  1554. | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring
  1555. of ADC internal channel connected to internal temperature sensor,
  1556. converted by either group regular or injected */
  1557. #define LL_ADC_AWD_CH_VBAT_REG ((LL_ADC_CHANNEL_VBAT & ADC_CHANNEL_ID_MASK) \
  1558. | ADC_CFGR_AWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring
  1559. of ADC internal channel connected to Vbat/3: Vbat
  1560. voltage through a divider ladder of factor 1/3 to have channel voltage
  1561. always below Vdda, converted by group regular only */
  1562. #define LL_ADC_AWD_CH_VBAT_INJ ((LL_ADC_CHANNEL_VBAT & ADC_CHANNEL_ID_MASK) \
  1563. | ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring
  1564. of ADC internal channel connected to Vbat/3: Vbat
  1565. voltage through a divider ladder of factor 1/3 to have channel voltage
  1566. always below Vdda, converted by group injected only */
  1567. #define LL_ADC_AWD_CH_VBAT_REG_INJ ((LL_ADC_CHANNEL_VBAT & ADC_CHANNEL_ID_MASK) \
  1568. | ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog
  1569. of ADC internal channel connected to Vbat/3: Vbat
  1570. voltage through a divider ladder of factor 1/3 to have channel voltage
  1571. always below Vdda */
  1572. #if defined(ADC1) && !defined(ADC2)
  1573. #define LL_ADC_AWD_CH_DAC1CH1_REG ((LL_ADC_CHANNEL_DAC1CH1 & ADC_CHANNEL_ID_MASK) \
  1574. | ADC_CFGR_AWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring
  1575. of ADC internal channel connected to DAC1 channel 1,
  1576. channel specific to ADC1, converted by group regular only */
  1577. #define LL_ADC_AWD_CH_DAC1CH1_INJ ((LL_ADC_CHANNEL_DAC1CH1 & ADC_CHANNEL_ID_MASK) \
  1578. | ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring
  1579. of ADC internal channel connected to DAC1 channel 1,
  1580. channel specific to ADC1, converted by group injected only */
  1581. #define LL_ADC_AWD_CH_DAC1CH1_REG_INJ ((LL_ADC_CHANNEL_DAC1CH1 & ADC_CHANNEL_ID_MASK) \
  1582. | ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1EN \
  1583. | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring
  1584. of ADC internal channel connected to DAC1 channel 1,
  1585. channel specific to ADC1, converted by either group regular or injected */
  1586. #define LL_ADC_AWD_CH_DAC1CH2_REG ((LL_ADC_CHANNEL_DAC1CH2 & ADC_CHANNEL_ID_MASK) \
  1587. | ADC_CFGR_AWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring
  1588. of ADC internal channel connected to DAC1 channel 2,
  1589. channel specific to ADC1, converted by group regular only */
  1590. #define LL_ADC_AWD_CH_DAC1CH2_INJ ((LL_ADC_CHANNEL_DAC1CH2 & ADC_CHANNEL_ID_MASK) \
  1591. | ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring
  1592. of ADC internal channel connected to DAC1 channel 2,
  1593. channel specific to ADC1, converted by group injected only */
  1594. #define LL_ADC_AWD_CH_DAC1CH2_REG_INJ ((LL_ADC_CHANNEL_DAC1CH2 & ADC_CHANNEL_ID_MASK) \
  1595. | ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1EN \
  1596. | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring
  1597. of ADC internal channel connected to DAC1 channel 2,
  1598. channel specific to ADC1, converted by either group regular or injected */
  1599. #elif defined(ADC2)
  1600. #define LL_ADC_AWD_CH_DAC1CH1_ADC2_REG ((LL_ADC_CHANNEL_DAC1CH1_ADC2 & ADC_CHANNEL_ID_MASK) \
  1601. | ADC_CFGR_AWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring
  1602. of ADC internal channel connected to DAC1 channel 1,
  1603. channel specific to ADC2, converted by group regular only */
  1604. #define LL_ADC_AWD_CH_DAC1CH1_ADC2_INJ ((LL_ADC_CHANNEL_DAC1CH1_ADC2 & ADC_CHANNEL_ID_MASK) \
  1605. | ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring
  1606. of ADC internal channel connected to DAC1 channel 1,
  1607. channel specific to ADC2, converted by group injected only */
  1608. #define LL_ADC_AWD_CH_DAC1CH1_ADC2_REG_INJ ((LL_ADC_CHANNEL_DAC1CH1_ADC2 & ADC_CHANNEL_ID_MASK) \
  1609. | ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1EN \
  1610. | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring
  1611. of ADC internal channel connected to DAC1 channel 1,
  1612. channel specific to ADC2, converted by either group regular or injected */
  1613. #define LL_ADC_AWD_CH_DAC1CH2_ADC2_REG ((LL_ADC_CHANNEL_DAC1CH2_ADC2 & ADC_CHANNEL_ID_MASK) \
  1614. | ADC_CFGR_AWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring
  1615. of ADC internal channel connected to DAC1 channel 2,
  1616. channel specific to ADC2, converted by group regular only */
  1617. #define LL_ADC_AWD_CH_DAC1CH2_ADC2_INJ ((LL_ADC_CHANNEL_DAC1CH2_ADC2 & ADC_CHANNEL_ID_MASK) \
  1618. | ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring
  1619. of ADC internal channel connected to DAC1 channel 2,
  1620. channel specific to ADC2, converted by group injected only */
  1621. #define LL_ADC_AWD_CH_DAC1CH2_ADC2_REG_INJ ((LL_ADC_CHANNEL_DAC1CH2_ADC2 & ADC_CHANNEL_ID_MASK) \
  1622. | ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1EN \
  1623. | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring
  1624. of ADC internal channel connected to DAC1 channel 2,
  1625. channel specific to ADC2, converted by either group regular or injected */
  1626. #if defined(ADC3)
  1627. #define LL_ADC_AWD_CH_DAC1CH1_ADC3_REG ((LL_ADC_CHANNEL_DAC1CH1_ADC3 & ADC_CHANNEL_ID_MASK) \
  1628. | ADC_CFGR_AWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring
  1629. of ADC internal channel connected to DAC1 channel 1,
  1630. channel specific to ADC3, converted by group regular only */
  1631. #define LL_ADC_AWD_CH_DAC1CH1_ADC3_INJ ((LL_ADC_CHANNEL_DAC1CH1_ADC3 & ADC_CHANNEL_ID_MASK) \
  1632. | ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring
  1633. of ADC internal channel connected to DAC1 channel 1,
  1634. channel specific to ADC3, converted by group injected only */
  1635. #define LL_ADC_AWD_CH_DAC1CH1_ADC3_REG_INJ ((LL_ADC_CHANNEL_DAC1CH1_ADC3 & ADC_CHANNEL_ID_MASK) \
  1636. | ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1EN \
  1637. | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring
  1638. of ADC internal channel connected to DAC1 channel 1,
  1639. channel specific to ADC3, converted by either group regular or injected */
  1640. #define LL_ADC_AWD_CH_DAC1CH2_ADC3_REG ((LL_ADC_CHANNEL_DAC1CH2_ADC3 & ADC_CHANNEL_ID_MASK) \
  1641. | ADC_CFGR_AWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring
  1642. of ADC internal channel connected to DAC1 channel 2,
  1643. channel specific to ADC3, converted by group regular only */
  1644. #define LL_ADC_AWD_CH_DAC1CH2_ADC3_INJ ((LL_ADC_CHANNEL_DAC1CH2_ADC3 & ADC_CHANNEL_ID_MASK) \
  1645. | ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring
  1646. of ADC internal channel connected to DAC1 channel 2,
  1647. channel specific to ADC3, converted by group injected only */
  1648. #define LL_ADC_AWD_CH_DAC1CH2_ADC3_REG_INJ ((LL_ADC_CHANNEL_DAC1CH2_ADC3 & ADC_CHANNEL_ID_MASK) \
  1649. | ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1EN \
  1650. | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring
  1651. of ADC internal channel connected to DAC1 channel 2,
  1652. channel specific to ADC3, converted by either group regular or injected */
  1653. #endif /* ADC3 */
  1654. #endif /* ADC1 && !ADC2 */
  1655. /**
  1656. * @}
  1657. */
  1658. /** @defgroup ADC_LL_EC_AWD_THRESHOLDS Analog watchdog - Thresholds
  1659. * @{
  1660. */
  1661. #define LL_ADC_AWD_THRESHOLD_HIGH (ADC_TR1_HT1) /*!< ADC analog watchdog threshold high */
  1662. #define LL_ADC_AWD_THRESHOLD_LOW (ADC_TR1_LT1) /*!< ADC analog watchdog threshold low */
  1663. #define LL_ADC_AWD_THRESHOLDS_HIGH_LOW (ADC_TR1_HT1 \
  1664. | ADC_TR1_LT1) /*!< ADC analog watchdog both thresholds high and low
  1665. concatenated into the same data */
  1666. /**
  1667. * @}
  1668. */
  1669. /** @defgroup ADC_LL_EC_OVS_SCOPE Oversampling - Oversampling scope
  1670. * @{
  1671. */
  1672. #define LL_ADC_OVS_DISABLE (0x00000000UL) /*!< ADC oversampling disabled. */
  1673. #define LL_ADC_OVS_GRP_REGULAR_CONTINUED (ADC_CFGR2_ROVSE) /*!< ADC oversampling on conversions of
  1674. ADC group regular. If group injected interrupts group regular:
  1675. when ADC group injected is triggered, the oversampling on ADC group regular
  1676. is temporary stopped and continued afterwards. */
  1677. #define LL_ADC_OVS_GRP_REGULAR_RESUMED (ADC_CFGR2_ROVSM | ADC_CFGR2_ROVSE) /*!< ADC oversampling on conversions of
  1678. ADC group regular. If group injected interrupts group regular:
  1679. when ADC group injected is triggered, the oversampling on ADC group regular
  1680. is resumed from start (oversampler buffer reset). */
  1681. #define LL_ADC_OVS_GRP_INJECTED (ADC_CFGR2_JOVSE) /*!< ADC oversampling on conversions of
  1682. ADC group injected. */
  1683. #define LL_ADC_OVS_GRP_INJ_REG_RESUMED (ADC_CFGR2_JOVSE | ADC_CFGR2_ROVSE) /*!< ADC oversampling on conversions of
  1684. both ADC groups regular and injected. If group injected interrupting group
  1685. regular: when ADC group injected is triggered, the oversampling on ADC group
  1686. regular is resumed from start (oversampler buffer reset). */
  1687. /**
  1688. * @}
  1689. */
  1690. /** @defgroup ADC_LL_EC_OVS_DISCONT_MODE Oversampling - Discontinuous mode
  1691. * @{
  1692. */
  1693. #define LL_ADC_OVS_REG_CONT (0x00000000UL) /*!< ADC oversampling discontinuous mode: continuous mode
  1694. (all conversions of oversampling ratio are done from 1 trigger) */
  1695. #define LL_ADC_OVS_REG_DISCONT (ADC_CFGR2_TROVS) /*!< ADC oversampling discontinuous mode: discontinuous
  1696. mode (each conversion of oversampling ratio needs a trigger) */
  1697. /**
  1698. * @}
  1699. */
  1700. /** @defgroup ADC_LL_EC_OVS_RATIO Oversampling - Ratio
  1701. * @{
  1702. */
  1703. #define LL_ADC_OVS_RATIO_2 (0x00000000UL) /*!< ADC oversampling ratio of 2
  1704. (sum of conversions data computed to result as oversampling conversion data
  1705. (before potential shift) */
  1706. #define LL_ADC_OVS_RATIO_4 (ADC_CFGR2_OVSR_0) /*!< ADC oversampling ratio of 4
  1707. (sum of conversions data computed to result as oversampling conversion data
  1708. (before potential shift) */
  1709. #define LL_ADC_OVS_RATIO_8 (ADC_CFGR2_OVSR_1) /*!< ADC oversampling ratio of 8
  1710. (sum of conversions data computed to result as oversampling conversion data
  1711. (before potential shift) */
  1712. #define LL_ADC_OVS_RATIO_16 (ADC_CFGR2_OVSR_1 | ADC_CFGR2_OVSR_0) /*!< ADC oversampling ratio of 16
  1713. (sum of conversions data computed to result as oversampling conversion data
  1714. (before potential shift) */
  1715. #define LL_ADC_OVS_RATIO_32 (ADC_CFGR2_OVSR_2) /*!< ADC oversampling ratio of 32
  1716. (sum of conversions data computed to result as oversampling conversion data
  1717. (before potential shift) */
  1718. #define LL_ADC_OVS_RATIO_64 (ADC_CFGR2_OVSR_2 | ADC_CFGR2_OVSR_0) /*!< ADC oversampling ratio of 64
  1719. (sum of conversions data computed to result as oversampling conversion data
  1720. (before potential shift) */
  1721. #define LL_ADC_OVS_RATIO_128 (ADC_CFGR2_OVSR_2 | ADC_CFGR2_OVSR_1) /*!< ADC oversampling ratio of 128
  1722. (sum of conversions data computed to result as oversampling conversion data
  1723. (before potential shift) */
  1724. #define LL_ADC_OVS_RATIO_256 (ADC_CFGR2_OVSR_2 | ADC_CFGR2_OVSR_1 \
  1725. | ADC_CFGR2_OVSR_0) /*!< ADC oversampling ratio of 256
  1726. (sum of conversions data computed to result as oversampling conversion data
  1727. (before potential shift) */
  1728. /**
  1729. * @}
  1730. */
  1731. /** @defgroup ADC_LL_EC_OVS_SHIFT Oversampling - Data right shift
  1732. * @{
  1733. */
  1734. #define LL_ADC_OVS_SHIFT_NONE (0x00000000UL) /*!< ADC oversampling no shift
  1735. (sum of the ADC conversions data is not divided to result as oversampling
  1736. conversion data) */
  1737. #define LL_ADC_OVS_SHIFT_RIGHT_1 (ADC_CFGR2_OVSS_0) /*!< ADC oversampling right shift of 1
  1738. (sum of the ADC conversions data (after OVS ratio) is divided by 2
  1739. to result as oversampling conversion data) */
  1740. #define LL_ADC_OVS_SHIFT_RIGHT_2 (ADC_CFGR2_OVSS_1) /*!< ADC oversampling right shift of 2
  1741. (sum of the ADC conversions data (after OVS ratio) is divided by 4
  1742. to result as oversampling conversion data) */
  1743. #define LL_ADC_OVS_SHIFT_RIGHT_3 (ADC_CFGR2_OVSS_1 | ADC_CFGR2_OVSS_0) /*!< ADC oversampling right shift of 3
  1744. (sum of the ADC conversions data (after OVS ratio) is divided by 8
  1745. to result as oversampling conversion data) */
  1746. #define LL_ADC_OVS_SHIFT_RIGHT_4 (ADC_CFGR2_OVSS_2) /*!< ADC oversampling right shift of 4
  1747. (sum of the ADC conversions data (after OVS ratio) is divided by 16
  1748. to result as oversampling conversion data) */
  1749. #define LL_ADC_OVS_SHIFT_RIGHT_5 (ADC_CFGR2_OVSS_2 | ADC_CFGR2_OVSS_0) /*!< ADC oversampling right shift of 5
  1750. (sum of the ADC conversions data (after OVS ratio) is divided by 32
  1751. to result as oversampling conversion data) */
  1752. #define LL_ADC_OVS_SHIFT_RIGHT_6 (ADC_CFGR2_OVSS_2 | ADC_CFGR2_OVSS_1) /*!< ADC oversampling right shift of 6
  1753. (sum of the ADC conversions data (after OVS ratio) is divided by 64
  1754. to result as oversampling conversion data) */
  1755. #define LL_ADC_OVS_SHIFT_RIGHT_7 (ADC_CFGR2_OVSS_2 | ADC_CFGR2_OVSS_1 \
  1756. | ADC_CFGR2_OVSS_0) /*!< ADC oversampling right shift of 7
  1757. (sum of the ADC conversions data (after OVS ratio) is divided by 128
  1758. to result as oversampling conversion data) */
  1759. #define LL_ADC_OVS_SHIFT_RIGHT_8 (ADC_CFGR2_OVSS_3) /*!< ADC oversampling right shift of 8
  1760. (sum of the ADC conversions data (after OVS ratio) is divided by 256
  1761. to result as oversampling conversion data) */
  1762. /**
  1763. * @}
  1764. */
  1765. #if defined(ADC_MULTIMODE_SUPPORT)
  1766. /** @defgroup ADC_LL_EC_MULTI_MODE Multimode - Mode
  1767. * @{
  1768. */
  1769. #define LL_ADC_MULTI_INDEPENDENT (0x00000000UL) /*!< ADC dual mode disabled (ADC
  1770. independent mode) */
  1771. #define LL_ADC_MULTI_DUAL_REG_SIMULT (ADC_CCR_DUAL_2 | ADC_CCR_DUAL_1) /*!< ADC dual mode enabled: group regular
  1772. simultaneous */
  1773. #define LL_ADC_MULTI_DUAL_REG_INTERL (ADC_CCR_DUAL_2 | ADC_CCR_DUAL_1 \
  1774. | ADC_CCR_DUAL_0) /*!< ADC dual mode enabled: Combined group
  1775. regular interleaved */
  1776. #define LL_ADC_MULTI_DUAL_INJ_SIMULT (ADC_CCR_DUAL_2 | ADC_CCR_DUAL_0) /*!< ADC dual mode enabled: group injected
  1777. simultaneous */
  1778. #define LL_ADC_MULTI_DUAL_INJ_ALTERN (ADC_CCR_DUAL_3 | ADC_CCR_DUAL_0) /*!< ADC dual mode enabled: group injected
  1779. alternate trigger. Works only with external triggers (not SW start) */
  1780. #define LL_ADC_MULTI_DUAL_REG_SIM_INJ_SIM (ADC_CCR_DUAL_0) /*!< ADC dual mode enabled: Combined group
  1781. regular simultaneous + group injected simultaneous */
  1782. #define LL_ADC_MULTI_DUAL_REG_SIM_INJ_ALT (ADC_CCR_DUAL_1) /*!< ADC dual mode enabled: Combined group
  1783. regular simultaneous + group injected alternate trigger */
  1784. #define LL_ADC_MULTI_DUAL_REG_INT_INJ_SIM (ADC_CCR_DUAL_1 | ADC_CCR_DUAL_0) /*!< ADC dual mode enabled: Combined group
  1785. regular interleaved + group injected simultaneous */
  1786. /**
  1787. * @}
  1788. */
  1789. /** @defgroup ADC_LL_EC_MULTI_DMA_TRANSFER Multimode - DMA transfer
  1790. * @{
  1791. */
  1792. #define LL_ADC_MULTI_REG_DMA_EACH_ADC (0x00000000UL) /*!< ADC multimode group regular
  1793. conversions are transferred by DMA: each ADC uses its own DMA channel,
  1794. with its individual DMA transfer settings */
  1795. #define LL_ADC_MULTI_REG_DMA_LIMIT_RES12_10B (ADC_CCR_MDMA_1) /*!< ADC multimode group regular
  1796. conversions are transferred by DMA, one DMA channel for both ADC(DMA of
  1797. ADC master), in limited mode (one shot mode): DMA transfer requests
  1798. are stopped when number of DMA data transfers (number of ADC conversions)
  1799. is reached. This ADC mode is intended to be used with DMA mode
  1800. non-circular. Setting for ADC resolution of 12 and 10 bits */
  1801. #define LL_ADC_MULTI_REG_DMA_LIMIT_RES8_6B (ADC_CCR_MDMA_1 | ADC_CCR_MDMA_0) /*!< ADC multimode group regular
  1802. conversions are transferred by DMA, one DMA channel for both ADC(DMA of
  1803. ADC master), in limited mode (one shot mode): DMA transfer requests
  1804. are stopped when number of DMA data transfers (number of ADC conversions)
  1805. is reached. This ADC mode is intended to be used with DMA mode
  1806. non-circular. Setting for ADC resolution of 8 and 6 bits */
  1807. #define LL_ADC_MULTI_REG_DMA_UNLMT_RES12_10B (ADC_CCR_DMACFG | ADC_CCR_MDMA_1) /*!< ADC multimode group regular
  1808. conversions are transferred by DMA, one DMA channel for both ADC(DMA of
  1809. ADC master), in unlimited mode: DMA transfer requests are unlimited,
  1810. whatever number of DMA data transferred (number of ADC conversions).
  1811. This ADC mode is intended to be used with DMA mode circular.
  1812. Setting for ADC resolution of 12 and 10 bits */
  1813. #define LL_ADC_MULTI_REG_DMA_UNLMT_RES8_6B (ADC_CCR_DMACFG | ADC_CCR_MDMA_1 \
  1814. | ADC_CCR_MDMA_0) /*!< ADC multimode group regular
  1815. conversions are transferred by DMA, one DMA channel for both ADC (DMA of
  1816. ADC master), in unlimited mode: DMA transfer requests are unlimited,
  1817. whatever number of DMA data transferred (number of ADC conversions).
  1818. This ADC mode is intended to be used with DMA mode circular.
  1819. Setting for ADC resolution of 8 and 6 bits */
  1820. /**
  1821. * @}
  1822. */
  1823. /** @defgroup ADC_LL_EC_MULTI_TWOSMP_DELAY Multimode - Delay between two sampling phases
  1824. * @{
  1825. */
  1826. #define LL_ADC_MULTI_TWOSMP_DELAY_1CYCLE (0x00000000UL) /*!< ADC multimode delay between two
  1827. sampling phases: 1 ADC clock cycle */
  1828. #define LL_ADC_MULTI_TWOSMP_DELAY_2CYCLES (ADC_CCR_DELAY_0) /*!< ADC multimode delay between two
  1829. sampling phases: 2 ADC clock cycles */
  1830. #define LL_ADC_MULTI_TWOSMP_DELAY_3CYCLES (ADC_CCR_DELAY_1) /*!< ADC multimode delay between two
  1831. sampling phases: 3 ADC clock cycles */
  1832. #define LL_ADC_MULTI_TWOSMP_DELAY_4CYCLES (ADC_CCR_DELAY_1 | ADC_CCR_DELAY_0) /*!< ADC multimode delay between two
  1833. sampling phases: 4 ADC clock cycles */
  1834. #define LL_ADC_MULTI_TWOSMP_DELAY_5CYCLES (ADC_CCR_DELAY_2) /*!< ADC multimode delay between two
  1835. sampling phases: 5 ADC clock cycles */
  1836. #define LL_ADC_MULTI_TWOSMP_DELAY_6CYCLES (ADC_CCR_DELAY_2 | ADC_CCR_DELAY_0) /*!< ADC multimode delay between two
  1837. sampling phases: 6 ADC clock cycles */
  1838. #define LL_ADC_MULTI_TWOSMP_DELAY_7CYCLES (ADC_CCR_DELAY_2 | ADC_CCR_DELAY_1) /*!< ADC multimode delay between two
  1839. sampling phases: 7 ADC clock cycles */
  1840. #define LL_ADC_MULTI_TWOSMP_DELAY_8CYCLES (ADC_CCR_DELAY_2 | ADC_CCR_DELAY_1 \
  1841. | ADC_CCR_DELAY_0) /*!< ADC multimode delay between two
  1842. sampling phases: 8 ADC clock cycles */
  1843. #define LL_ADC_MULTI_TWOSMP_DELAY_9CYCLES (ADC_CCR_DELAY_3) /*!< ADC multimode delay between two
  1844. sampling phases: 9 ADC clock cycles */
  1845. #define LL_ADC_MULTI_TWOSMP_DELAY_10CYCLES (ADC_CCR_DELAY_3 | ADC_CCR_DELAY_0) /*!< ADC multimode delay between two
  1846. sampling phases: 10 ADC clock cycles */
  1847. #define LL_ADC_MULTI_TWOSMP_DELAY_11CYCLES (ADC_CCR_DELAY_3 | ADC_CCR_DELAY_1) /*!< ADC multimode delay between two
  1848. sampling phases: 11 ADC clock cycles */
  1849. #define LL_ADC_MULTI_TWOSMP_DELAY_12CYCLES (ADC_CCR_DELAY_3 | ADC_CCR_DELAY_1 \
  1850. | ADC_CCR_DELAY_0) /*!< ADC multimode delay between two
  1851. sampling phases: 12 ADC clock cycles */
  1852. /**
  1853. * @}
  1854. */
  1855. /** @defgroup ADC_LL_EC_MULTI_MASTER_SLAVE Multimode - ADC master or slave
  1856. * @{
  1857. */
  1858. #define LL_ADC_MULTI_MASTER (ADC_CDR_RDATA_MST) /*!< In multimode, selection among several ADC
  1859. instances: ADC master */
  1860. #define LL_ADC_MULTI_SLAVE (ADC_CDR_RDATA_SLV) /*!< In multimode, selection among several ADC
  1861. instances: ADC slave */
  1862. #define LL_ADC_MULTI_MASTER_SLAVE (ADC_CDR_RDATA_SLV \
  1863. | ADC_CDR_RDATA_MST) /*!< In multimode, selection among several ADC
  1864. instances: both ADC master and ADC slave */
  1865. /**
  1866. * @}
  1867. */
  1868. #endif /* ADC_MULTIMODE_SUPPORT */
  1869. /** @defgroup ADC_LL_EC_LEGACY ADC literals legacy naming
  1870. * @{
  1871. */
  1872. #define LL_ADC_REG_TRIG_SW_START (LL_ADC_REG_TRIG_SOFTWARE)
  1873. #define LL_ADC_REG_TRIG_EXT_TIM1_CC1 (LL_ADC_REG_TRIG_EXT_TIM1_CH1)
  1874. #define LL_ADC_REG_TRIG_EXT_TIM1_CC2 (LL_ADC_REG_TRIG_EXT_TIM1_CH2)
  1875. #define LL_ADC_REG_TRIG_EXT_TIM1_CC3 (LL_ADC_REG_TRIG_EXT_TIM1_CH3)
  1876. #define LL_ADC_REG_TRIG_EXT_TIM2_CC2 (LL_ADC_REG_TRIG_EXT_TIM2_CH2)
  1877. #define LL_ADC_REG_TRIG_EXT_TIM3_CC4 (LL_ADC_REG_TRIG_EXT_TIM3_CH4)
  1878. #define LL_ADC_REG_TRIG_EXT_TIM4_CC4 (LL_ADC_REG_TRIG_EXT_TIM4_CH4)
  1879. #define LL_ADC_INJ_TRIG_SW_START (LL_ADC_INJ_TRIG_SOFTWARE)
  1880. #define LL_ADC_INJ_TRIG_EXT_TIM1_CC4 (LL_ADC_INJ_TRIG_EXT_TIM1_CH4)
  1881. #define LL_ADC_INJ_TRIG_EXT_TIM2_CC1 (LL_ADC_INJ_TRIG_EXT_TIM2_CH1)
  1882. #define LL_ADC_INJ_TRIG_EXT_TIM3_CC1 (LL_ADC_INJ_TRIG_EXT_TIM3_CH1)
  1883. #define LL_ADC_INJ_TRIG_EXT_TIM3_CC3 (LL_ADC_INJ_TRIG_EXT_TIM3_CH3)
  1884. #define LL_ADC_INJ_TRIG_EXT_TIM3_CC4 (LL_ADC_INJ_TRIG_EXT_TIM3_CH4)
  1885. #define LL_ADC_INJ_TRIG_EXT_TIM8_CC4 (LL_ADC_INJ_TRIG_EXT_TIM8_CH4)
  1886. #define LL_ADC_OVS_DATA_SHIFT_NONE (LL_ADC_OVS_SHIFT_NONE)
  1887. #define LL_ADC_OVS_DATA_SHIFT_1 (LL_ADC_OVS_SHIFT_RIGHT_1)
  1888. #define LL_ADC_OVS_DATA_SHIFT_2 (LL_ADC_OVS_SHIFT_RIGHT_2)
  1889. #define LL_ADC_OVS_DATA_SHIFT_3 (LL_ADC_OVS_SHIFT_RIGHT_3)
  1890. #define LL_ADC_OVS_DATA_SHIFT_4 (LL_ADC_OVS_SHIFT_RIGHT_4)
  1891. #define LL_ADC_OVS_DATA_SHIFT_5 (LL_ADC_OVS_SHIFT_RIGHT_5)
  1892. #define LL_ADC_OVS_DATA_SHIFT_6 (LL_ADC_OVS_SHIFT_RIGHT_6)
  1893. #define LL_ADC_OVS_DATA_SHIFT_7 (LL_ADC_OVS_SHIFT_RIGHT_7)
  1894. #define LL_ADC_OVS_DATA_SHIFT_8 (LL_ADC_OVS_SHIFT_RIGHT_8)
  1895. /**
  1896. * @}
  1897. */
  1898. /** @defgroup ADC_LL_EC_HELPER_MACRO Definitions of constants used by helper macro
  1899. * @{
  1900. */
  1901. #define LL_ADC_TEMPERATURE_CALC_ERROR ((int16_t)0x7FFF) /* Temperature calculation error using helper macro
  1902. @ref __LL_ADC_CALC_TEMPERATURE(), due to issue on
  1903. calibration parameters. This value is coded on 16 bits
  1904. (to fit on signed word or double word) and corresponds
  1905. to an inconsistent temperature value. */
  1906. /**
  1907. * @}
  1908. */
  1909. /** @defgroup ADC_LL_EC_HW_DELAYS Definitions of ADC hardware constraints delays
  1910. * @note Only ADC peripheral HW delays are defined in ADC LL driver driver,
  1911. * not timeout values.
  1912. * For details on delays values, refer to descriptions in source code
  1913. * above each literal definition.
  1914. * @{
  1915. */
  1916. /* Note: Only ADC peripheral HW delays are defined in ADC LL driver driver, */
  1917. /* not timeout values. */
  1918. /* Timeout values for ADC operations are dependent to device clock */
  1919. /* configuration (system clock versus ADC clock), */
  1920. /* and therefore must be defined in user application. */
  1921. /* Indications for estimation of ADC timeout delays, for this */
  1922. /* STM32 series: */
  1923. /* - ADC calibration time: maximum delay is 112/fADC. */
  1924. /* (refer to device datasheet, parameter "tCAL") */
  1925. /* - ADC enable time: maximum delay is 1 conversion cycle. */
  1926. /* (refer to device datasheet, parameter "tSTAB") */
  1927. /* - ADC disable time: maximum delay should be a few ADC clock cycles */
  1928. /* - ADC stop conversion time: maximum delay should be a few ADC clock */
  1929. /* cycles */
  1930. /* - ADC conversion time: duration depending on ADC clock and ADC */
  1931. /* configuration. */
  1932. /* (refer to device reference manual, section "Timing") */
  1933. /* Delay for ADC stabilization time (ADC voltage regulator start-up time) */
  1934. /* Delay set to maximum value (refer to device datasheet, */
  1935. /* parameter "tADCVREG_STUP"). */
  1936. /* Unit: us */
  1937. #define LL_ADC_DELAY_INTERNAL_REGUL_STAB_US ( 20UL) /*!< Delay for ADC stabilization time (ADC voltage
  1938. regulator start-up time) */
  1939. /* Delay for internal voltage reference stabilization time. */
  1940. /* Delay set to maximum value (refer to device datasheet, */
  1941. /* parameter "tstart_vrefint"). */
  1942. /* Unit: us */
  1943. #define LL_ADC_DELAY_VREFINT_STAB_US ( 12UL) /*!< Delay for internal voltage reference stabilization
  1944. time */
  1945. /* Delay for temperature sensor stabilization time. */
  1946. /* Literal set to maximum value (refer to device datasheet, */
  1947. /* parameter "tSTART"). */
  1948. /* Unit: us */
  1949. #define LL_ADC_DELAY_TEMPSENSOR_STAB_US (120UL) /*!< Delay for temperature sensor stabilization time */
  1950. #define LL_ADC_DELAY_TEMPSENSOR_BUFFER_STAB_US ( 15UL) /*!< Delay for temperature sensor buffer stabilization
  1951. time (starting from ADC enable, refer to
  1952. @ref LL_ADC_Enable()) */
  1953. /* Delay required between ADC end of calibration and ADC enable. */
  1954. /* Note: On this STM32 series, a minimum number of ADC clock cycles */
  1955. /* are required between ADC end of calibration and ADC enable. */
  1956. /* Wait time can be computed in user application by waiting for the */
  1957. /* equivalent number of CPU cycles, by taking into account */
  1958. /* ratio of CPU clock versus ADC clock prescalers. */
  1959. /* Unit: ADC clock cycles. */
  1960. #define LL_ADC_DELAY_CALIB_ENABLE_ADC_CYCLES ( 4UL) /*!< Delay required between ADC end of calibration
  1961. and ADC enable */
  1962. /**
  1963. * @}
  1964. */
  1965. /**
  1966. * @}
  1967. */
  1968. /* Exported macro ------------------------------------------------------------*/
  1969. /** @defgroup ADC_LL_Exported_Macros ADC Exported Macros
  1970. * @{
  1971. */
  1972. /** @defgroup ADC_LL_EM_WRITE_READ Common write and read registers Macros
  1973. * @{
  1974. */
  1975. /**
  1976. * @brief Write a value in ADC register
  1977. * @param __INSTANCE__ ADC Instance
  1978. * @param __REG__ Register to be written
  1979. * @param __VALUE__ Value to be written in the register
  1980. * @retval None
  1981. */
  1982. #define LL_ADC_WriteReg(__INSTANCE__, __REG__, __VALUE__) WRITE_REG(__INSTANCE__->__REG__, (__VALUE__))
  1983. /**
  1984. * @brief Read a value in ADC register
  1985. * @param __INSTANCE__ ADC Instance
  1986. * @param __REG__ Register to be read
  1987. * @retval Register value
  1988. */
  1989. #define LL_ADC_ReadReg(__INSTANCE__, __REG__) READ_REG(__INSTANCE__->__REG__)
  1990. /**
  1991. * @}
  1992. */
  1993. /** @defgroup ADC_LL_EM_HELPER_MACRO ADC helper macro
  1994. * @{
  1995. */
  1996. /**
  1997. * @brief Helper macro to get ADC channel number in decimal format
  1998. * from literals LL_ADC_CHANNEL_x.
  1999. * @note Example:
  2000. * __LL_ADC_CHANNEL_TO_DECIMAL_NB(LL_ADC_CHANNEL_4)
  2001. * will return decimal number "4".
  2002. * @note The input can be a value from functions where a channel
  2003. * number is returned, either defined with number
  2004. * or with bitfield (only one bit must be set).
  2005. * @param __CHANNEL__ This parameter can be one of the following values:
  2006. * @arg @ref LL_ADC_CHANNEL_0
  2007. * @arg @ref LL_ADC_CHANNEL_1 (7)
  2008. * @arg @ref LL_ADC_CHANNEL_2 (7)
  2009. * @arg @ref LL_ADC_CHANNEL_3 (7)
  2010. * @arg @ref LL_ADC_CHANNEL_4 (7)
  2011. * @arg @ref LL_ADC_CHANNEL_5 (7)
  2012. * @arg @ref LL_ADC_CHANNEL_6
  2013. * @arg @ref LL_ADC_CHANNEL_7
  2014. * @arg @ref LL_ADC_CHANNEL_8
  2015. * @arg @ref LL_ADC_CHANNEL_9
  2016. * @arg @ref LL_ADC_CHANNEL_10
  2017. * @arg @ref LL_ADC_CHANNEL_11
  2018. * @arg @ref LL_ADC_CHANNEL_12
  2019. * @arg @ref LL_ADC_CHANNEL_13
  2020. * @arg @ref LL_ADC_CHANNEL_14
  2021. * @arg @ref LL_ADC_CHANNEL_15
  2022. * @arg @ref LL_ADC_CHANNEL_16
  2023. * @arg @ref LL_ADC_CHANNEL_17
  2024. * @arg @ref LL_ADC_CHANNEL_18
  2025. * @arg @ref LL_ADC_CHANNEL_VREFINT (1)
  2026. * @arg @ref LL_ADC_CHANNEL_TEMPSENSOR (4)
  2027. * @arg @ref LL_ADC_CHANNEL_VBAT (4)
  2028. * @arg @ref LL_ADC_CHANNEL_DAC1CH1 (5)
  2029. * @arg @ref LL_ADC_CHANNEL_DAC1CH2 (5)
  2030. * @arg @ref LL_ADC_CHANNEL_DAC1CH1_ADC2 (2)(6)
  2031. * @arg @ref LL_ADC_CHANNEL_DAC1CH2_ADC2 (2)(6)
  2032. * @arg @ref LL_ADC_CHANNEL_DAC1CH1_ADC3 (3)(6)
  2033. * @arg @ref LL_ADC_CHANNEL_DAC1CH2_ADC3 (3)(6)
  2034. *
  2035. * (1) On STM32L4, parameter available only on ADC instance: ADC1.\n
  2036. * (2) On STM32L4, parameter available only on ADC instance: ADC2.\n
  2037. * (3) On STM32L4, parameter available only on ADC instance: ADC3.\n
  2038. * (4) On STM32L4, parameter available only on ADC instances: ADC1, ADC3.\n
  2039. * (5) On STM32L4, parameter available on devices with only 1 ADC instance.\n
  2040. * (6) On STM32L4, parameter available on devices with several ADC instances.\n
  2041. * (7) On STM32L4, fast channel (0.188 us for 12-bit resolution (ADC conversion rate up to 5.33 Ms/s)).
  2042. * Other channels are slow channels (0.238 us for 12-bit resolution (ADC conversion rate up to 4.21 Ms/s)).
  2043. * @retval Value between Min_Data=0 and Max_Data=18
  2044. */
  2045. #define __LL_ADC_CHANNEL_TO_DECIMAL_NB(__CHANNEL__) \
  2046. ((((__CHANNEL__) & ADC_CHANNEL_ID_BITFIELD_MASK) == 0UL) ? \
  2047. ( \
  2048. ((__CHANNEL__) & ADC_CHANNEL_ID_NUMBER_MASK) >> ADC_CHANNEL_ID_NUMBER_BITOFFSET_POS \
  2049. ) \
  2050. : \
  2051. ( \
  2052. (uint32_t)POSITION_VAL((__CHANNEL__)) \
  2053. ) \
  2054. )
  2055. /**
  2056. * @brief Helper macro to get ADC channel in literal format LL_ADC_CHANNEL_x
  2057. * from number in decimal format.
  2058. * @note Example:
  2059. * __LL_ADC_DECIMAL_NB_TO_CHANNEL(4)
  2060. * will return a data equivalent to "LL_ADC_CHANNEL_4".
  2061. * @param __DECIMAL_NB__ Value between Min_Data=0 and Max_Data=18
  2062. * @retval Returned value can be one of the following values:
  2063. * @arg @ref LL_ADC_CHANNEL_0
  2064. * @arg @ref LL_ADC_CHANNEL_1 (7)
  2065. * @arg @ref LL_ADC_CHANNEL_2 (7)
  2066. * @arg @ref LL_ADC_CHANNEL_3 (7)
  2067. * @arg @ref LL_ADC_CHANNEL_4 (7)
  2068. * @arg @ref LL_ADC_CHANNEL_5 (7)
  2069. * @arg @ref LL_ADC_CHANNEL_6
  2070. * @arg @ref LL_ADC_CHANNEL_7
  2071. * @arg @ref LL_ADC_CHANNEL_8
  2072. * @arg @ref LL_ADC_CHANNEL_9
  2073. * @arg @ref LL_ADC_CHANNEL_10
  2074. * @arg @ref LL_ADC_CHANNEL_11
  2075. * @arg @ref LL_ADC_CHANNEL_12
  2076. * @arg @ref LL_ADC_CHANNEL_13
  2077. * @arg @ref LL_ADC_CHANNEL_14
  2078. * @arg @ref LL_ADC_CHANNEL_15
  2079. * @arg @ref LL_ADC_CHANNEL_16
  2080. * @arg @ref LL_ADC_CHANNEL_17
  2081. * @arg @ref LL_ADC_CHANNEL_18
  2082. * @arg @ref LL_ADC_CHANNEL_VREFINT (1)
  2083. * @arg @ref LL_ADC_CHANNEL_TEMPSENSOR (4)
  2084. * @arg @ref LL_ADC_CHANNEL_VBAT (4)
  2085. * @arg @ref LL_ADC_CHANNEL_DAC1CH1 (5)
  2086. * @arg @ref LL_ADC_CHANNEL_DAC1CH2 (5)
  2087. * @arg @ref LL_ADC_CHANNEL_DAC1CH1_ADC2 (2)(6)
  2088. * @arg @ref LL_ADC_CHANNEL_DAC1CH2_ADC2 (2)(6)
  2089. * @arg @ref LL_ADC_CHANNEL_DAC1CH1_ADC3 (3)(6)
  2090. * @arg @ref LL_ADC_CHANNEL_DAC1CH2_ADC3 (3)(6)
  2091. *
  2092. * (1) On STM32L4, parameter available only on ADC instance: ADC1.\n
  2093. * (2) On STM32L4, parameter available only on ADC instance: ADC2.\n
  2094. * (3) On STM32L4, parameter available only on ADC instance: ADC3.\n
  2095. * (4) On STM32L4, parameter available only on ADC instances: ADC1, ADC3.\n
  2096. * (5) On STM32L4, parameter available on devices with only 1 ADC instance.\n
  2097. * (6) On STM32L4, parameter available on devices with several ADC instances.\n
  2098. * (7) On STM32L4, fast channel (0.188 us for 12-bit resolution (ADC conversion rate up to 5.33 Ms/s)).
  2099. * Other channels are slow channels (0.238 us for 12-bit resolution (ADC conversion rate up to
  2100. * 4.21 Ms/s)).\n
  2101. * (1, 2, 3, 4) For ADC channel read back from ADC register,
  2102. * comparison with internal channel parameter to be done
  2103. * using helper macro @ref __LL_ADC_CHANNEL_INTERNAL_TO_EXTERNAL().
  2104. */
  2105. #define __LL_ADC_DECIMAL_NB_TO_CHANNEL(__DECIMAL_NB__) \
  2106. (((__DECIMAL_NB__) <= 9UL) ? \
  2107. ( \
  2108. ((__DECIMAL_NB__) << ADC_CHANNEL_ID_NUMBER_BITOFFSET_POS) | \
  2109. (ADC_AWD2CR_AWD2CH_0 << (__DECIMAL_NB__)) | \
  2110. (ADC_SMPR1_REGOFFSET | (((3UL * (__DECIMAL_NB__))) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) \
  2111. ) \
  2112. : \
  2113. ( \
  2114. ((__DECIMAL_NB__) << ADC_CHANNEL_ID_NUMBER_BITOFFSET_POS) | \
  2115. (ADC_AWD2CR_AWD2CH_0 << (__DECIMAL_NB__)) | \
  2116. (ADC_SMPR2_REGOFFSET | (((3UL * ((__DECIMAL_NB__) - 10UL))) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) \
  2117. ) \
  2118. )
  2119. /**
  2120. * @brief Helper macro to determine whether the selected channel
  2121. * corresponds to literal definitions of driver.
  2122. * @note The different literal definitions of ADC channels are:
  2123. * - ADC internal channel:
  2124. * LL_ADC_CHANNEL_VREFINT, LL_ADC_CHANNEL_TEMPSENSOR, ...
  2125. * - ADC external channel (channel connected to a GPIO pin):
  2126. * LL_ADC_CHANNEL_1, LL_ADC_CHANNEL_2, ...
  2127. * @note The channel parameter must be a value defined from literal
  2128. * definition of a ADC internal channel (LL_ADC_CHANNEL_VREFINT,
  2129. * LL_ADC_CHANNEL_TEMPSENSOR, ...),
  2130. * ADC external channel (LL_ADC_CHANNEL_1, LL_ADC_CHANNEL_2, ...),
  2131. * must not be a value from functions where a channel number is
  2132. * returned from ADC registers,
  2133. * because internal and external channels share the same channel
  2134. * number in ADC registers. The differentiation is made only with
  2135. * parameters definitions of driver.
  2136. * @param __CHANNEL__ This parameter can be one of the following values:
  2137. * @arg @ref LL_ADC_CHANNEL_0
  2138. * @arg @ref LL_ADC_CHANNEL_1 (7)
  2139. * @arg @ref LL_ADC_CHANNEL_2 (7)
  2140. * @arg @ref LL_ADC_CHANNEL_3 (7)
  2141. * @arg @ref LL_ADC_CHANNEL_4 (7)
  2142. * @arg @ref LL_ADC_CHANNEL_5 (7)
  2143. * @arg @ref LL_ADC_CHANNEL_6
  2144. * @arg @ref LL_ADC_CHANNEL_7
  2145. * @arg @ref LL_ADC_CHANNEL_8
  2146. * @arg @ref LL_ADC_CHANNEL_9
  2147. * @arg @ref LL_ADC_CHANNEL_10
  2148. * @arg @ref LL_ADC_CHANNEL_11
  2149. * @arg @ref LL_ADC_CHANNEL_12
  2150. * @arg @ref LL_ADC_CHANNEL_13
  2151. * @arg @ref LL_ADC_CHANNEL_14
  2152. * @arg @ref LL_ADC_CHANNEL_15
  2153. * @arg @ref LL_ADC_CHANNEL_16
  2154. * @arg @ref LL_ADC_CHANNEL_17
  2155. * @arg @ref LL_ADC_CHANNEL_18
  2156. * @arg @ref LL_ADC_CHANNEL_VREFINT (1)
  2157. * @arg @ref LL_ADC_CHANNEL_TEMPSENSOR (4)
  2158. * @arg @ref LL_ADC_CHANNEL_VBAT (4)
  2159. * @arg @ref LL_ADC_CHANNEL_DAC1CH1 (5)
  2160. * @arg @ref LL_ADC_CHANNEL_DAC1CH2 (5)
  2161. * @arg @ref LL_ADC_CHANNEL_DAC1CH1_ADC2 (2)(6)
  2162. * @arg @ref LL_ADC_CHANNEL_DAC1CH2_ADC2 (2)(6)
  2163. * @arg @ref LL_ADC_CHANNEL_DAC1CH1_ADC3 (3)(6)
  2164. * @arg @ref LL_ADC_CHANNEL_DAC1CH2_ADC3 (3)(6)
  2165. *
  2166. * (1) On STM32L4, parameter available only on ADC instance: ADC1.\n
  2167. * (2) On STM32L4, parameter available only on ADC instance: ADC2.\n
  2168. * (3) On STM32L4, parameter available only on ADC instance: ADC3.\n
  2169. * (4) On STM32L4, parameter available only on ADC instances: ADC1, ADC3.\n
  2170. * (5) On STM32L4, parameter available on devices with only 1 ADC instance.\n
  2171. * (6) On STM32L4, parameter available on devices with several ADC instances.\n
  2172. * (7) On STM32L4, fast channel (0.188 us for 12-bit resolution (ADC conversion rate up to 5.33 Ms/s)).
  2173. * Other channels are slow channels (0.238 us for 12-bit resolution (ADC conversion rate up to 4.21 Ms/s)).
  2174. * @retval Value "0" if the channel corresponds to a parameter definition of a ADC external channel (channel
  2175. connected to a GPIO pin).
  2176. * Value "1" if the channel corresponds to a parameter definition of a ADC internal channel.
  2177. */
  2178. #define __LL_ADC_IS_CHANNEL_INTERNAL(__CHANNEL__) \
  2179. (((__CHANNEL__) & ADC_CHANNEL_ID_INTERNAL_CH_MASK) != 0UL)
  2180. /**
  2181. * @brief Helper macro to convert a channel defined from parameter
  2182. * definition of a ADC internal channel (LL_ADC_CHANNEL_VREFINT,
  2183. * LL_ADC_CHANNEL_TEMPSENSOR, ...),
  2184. * to its equivalent parameter definition of a ADC external channel
  2185. * (LL_ADC_CHANNEL_1, LL_ADC_CHANNEL_2, ...).
  2186. * @note The channel parameter can be, additionally to a value
  2187. * defined from parameter definition of a ADC internal channel
  2188. * (LL_ADC_CHANNEL_VREFINT, LL_ADC_CHANNEL_TEMPSENSOR, ...),
  2189. * a value defined from parameter definition of
  2190. * ADC external channel (LL_ADC_CHANNEL_1, LL_ADC_CHANNEL_2, ...)
  2191. * or a value from functions where a channel number is returned
  2192. * from ADC registers.
  2193. * @param __CHANNEL__ This parameter can be one of the following values:
  2194. * @arg @ref LL_ADC_CHANNEL_0
  2195. * @arg @ref LL_ADC_CHANNEL_1 (7)
  2196. * @arg @ref LL_ADC_CHANNEL_2 (7)
  2197. * @arg @ref LL_ADC_CHANNEL_3 (7)
  2198. * @arg @ref LL_ADC_CHANNEL_4 (7)
  2199. * @arg @ref LL_ADC_CHANNEL_5 (7)
  2200. * @arg @ref LL_ADC_CHANNEL_6
  2201. * @arg @ref LL_ADC_CHANNEL_7
  2202. * @arg @ref LL_ADC_CHANNEL_8
  2203. * @arg @ref LL_ADC_CHANNEL_9
  2204. * @arg @ref LL_ADC_CHANNEL_10
  2205. * @arg @ref LL_ADC_CHANNEL_11
  2206. * @arg @ref LL_ADC_CHANNEL_12
  2207. * @arg @ref LL_ADC_CHANNEL_13
  2208. * @arg @ref LL_ADC_CHANNEL_14
  2209. * @arg @ref LL_ADC_CHANNEL_15
  2210. * @arg @ref LL_ADC_CHANNEL_16
  2211. * @arg @ref LL_ADC_CHANNEL_17
  2212. * @arg @ref LL_ADC_CHANNEL_18
  2213. * @arg @ref LL_ADC_CHANNEL_VREFINT (1)
  2214. * @arg @ref LL_ADC_CHANNEL_TEMPSENSOR (4)
  2215. * @arg @ref LL_ADC_CHANNEL_VBAT (4)
  2216. * @arg @ref LL_ADC_CHANNEL_DAC1CH1 (5)
  2217. * @arg @ref LL_ADC_CHANNEL_DAC1CH2 (5)
  2218. * @arg @ref LL_ADC_CHANNEL_DAC1CH1_ADC2 (2)(6)
  2219. * @arg @ref LL_ADC_CHANNEL_DAC1CH2_ADC2 (2)(6)
  2220. * @arg @ref LL_ADC_CHANNEL_DAC1CH1_ADC3 (3)(6)
  2221. * @arg @ref LL_ADC_CHANNEL_DAC1CH2_ADC3 (3)(6)
  2222. *
  2223. * (1) On STM32L4, parameter available only on ADC instance: ADC1.\n
  2224. * (2) On STM32L4, parameter available only on ADC instance: ADC2.\n
  2225. * (3) On STM32L4, parameter available only on ADC instance: ADC3.\n
  2226. * (4) On STM32L4, parameter available only on ADC instances: ADC1, ADC3.\n
  2227. * (5) On STM32L4, parameter available on devices with only 1 ADC instance.\n
  2228. * (6) On STM32L4, parameter available on devices with several ADC instances.\n
  2229. * (7) On STM32L4, fast channel (0.188 us for 12-bit resolution (ADC conversion rate up to 5.33 Ms/s)).
  2230. * Other channels are slow channels (0.238 us for 12-bit resolution (ADC conversion rate up to 4.21 Ms/s)).
  2231. * @retval Returned value can be one of the following values:
  2232. * @arg @ref LL_ADC_CHANNEL_0
  2233. * @arg @ref LL_ADC_CHANNEL_1
  2234. * @arg @ref LL_ADC_CHANNEL_2
  2235. * @arg @ref LL_ADC_CHANNEL_3
  2236. * @arg @ref LL_ADC_CHANNEL_4
  2237. * @arg @ref LL_ADC_CHANNEL_5
  2238. * @arg @ref LL_ADC_CHANNEL_6
  2239. * @arg @ref LL_ADC_CHANNEL_7
  2240. * @arg @ref LL_ADC_CHANNEL_8
  2241. * @arg @ref LL_ADC_CHANNEL_9
  2242. * @arg @ref LL_ADC_CHANNEL_10
  2243. * @arg @ref LL_ADC_CHANNEL_11
  2244. * @arg @ref LL_ADC_CHANNEL_12
  2245. * @arg @ref LL_ADC_CHANNEL_13
  2246. * @arg @ref LL_ADC_CHANNEL_14
  2247. * @arg @ref LL_ADC_CHANNEL_15
  2248. * @arg @ref LL_ADC_CHANNEL_16
  2249. * @arg @ref LL_ADC_CHANNEL_17
  2250. * @arg @ref LL_ADC_CHANNEL_18
  2251. */
  2252. #define __LL_ADC_CHANNEL_INTERNAL_TO_EXTERNAL(__CHANNEL__) \
  2253. ((__CHANNEL__) & ~ADC_CHANNEL_ID_INTERNAL_CH_MASK)
  2254. /**
  2255. * @brief Helper macro to determine whether the internal channel
  2256. * selected is available on the ADC instance selected.
  2257. * @note The channel parameter must be a value defined from parameter
  2258. * definition of a ADC internal channel (LL_ADC_CHANNEL_VREFINT,
  2259. * LL_ADC_CHANNEL_TEMPSENSOR, ...),
  2260. * must not be a value defined from parameter definition of
  2261. * ADC external channel (LL_ADC_CHANNEL_1, LL_ADC_CHANNEL_2, ...)
  2262. * or a value from functions where a channel number is
  2263. * returned from ADC registers,
  2264. * because internal and external channels share the same channel
  2265. * number in ADC registers. The differentiation is made only with
  2266. * parameters definitions of driver.
  2267. * @param __ADC_INSTANCE__ ADC instance
  2268. * @param __CHANNEL__ This parameter can be one of the following values:
  2269. * @arg @ref LL_ADC_CHANNEL_VREFINT (1)
  2270. * @arg @ref LL_ADC_CHANNEL_TEMPSENSOR (4)
  2271. * @arg @ref LL_ADC_CHANNEL_VBAT (4)
  2272. * @arg @ref LL_ADC_CHANNEL_DAC1CH1 (5)
  2273. * @arg @ref LL_ADC_CHANNEL_DAC1CH2 (5)
  2274. * @arg @ref LL_ADC_CHANNEL_DAC1CH1_ADC2 (2)(6)
  2275. * @arg @ref LL_ADC_CHANNEL_DAC1CH2_ADC2 (2)(6)
  2276. * @arg @ref LL_ADC_CHANNEL_DAC1CH1_ADC3 (3)(6)
  2277. * @arg @ref LL_ADC_CHANNEL_DAC1CH2_ADC3 (3)(6)
  2278. *
  2279. * (1) On STM32L4, parameter available only on ADC instance: ADC1.\n
  2280. * (2) On STM32L4, parameter available only on ADC instance: ADC2.\n
  2281. * (3) On STM32L4, parameter available only on ADC instance: ADC3.\n
  2282. * (4) On STM32L4, parameter available only on ADC instances: ADC1, ADC3.\n
  2283. * (5) On STM32L4, parameter available on devices with only 1 ADC instance.\n
  2284. * (6) On STM32L4, parameter available on devices with several ADC instances.
  2285. * @retval Value "0" if the internal channel selected is not available on the ADC instance selected.
  2286. * Value "1" if the internal channel selected is available on the ADC instance selected.
  2287. */
  2288. #if defined (ADC1) && defined (ADC2) && defined (ADC3)
  2289. #define __LL_ADC_IS_CHANNEL_INTERNAL_AVAILABLE(__ADC_INSTANCE__, __CHANNEL__) \
  2290. (((__ADC_INSTANCE__) == ADC1) ? \
  2291. ( \
  2292. ((__CHANNEL__) == LL_ADC_CHANNEL_VREFINT) || \
  2293. ((__CHANNEL__) == LL_ADC_CHANNEL_TEMPSENSOR) || \
  2294. ((__CHANNEL__) == LL_ADC_CHANNEL_VBAT) \
  2295. ) \
  2296. : \
  2297. ((__ADC_INSTANCE__) == ADC2) ? \
  2298. ( \
  2299. ((__CHANNEL__) == LL_ADC_CHANNEL_VREFINT) || \
  2300. ((__CHANNEL__) == LL_ADC_CHANNEL_DAC1CH1_ADC2) || \
  2301. ((__CHANNEL__) == LL_ADC_CHANNEL_DAC1CH2_ADC2) \
  2302. ) \
  2303. : \
  2304. ((__ADC_INSTANCE__) == ADC3) ? \
  2305. ( \
  2306. ((__CHANNEL__) == LL_ADC_CHANNEL_VREFINT) || \
  2307. ((__CHANNEL__) == LL_ADC_CHANNEL_TEMPSENSOR) || \
  2308. ((__CHANNEL__) == LL_ADC_CHANNEL_VBAT) || \
  2309. ((__CHANNEL__) == LL_ADC_CHANNEL_DAC1CH1_ADC3) || \
  2310. ((__CHANNEL__) == LL_ADC_CHANNEL_DAC1CH2_ADC3) \
  2311. ) \
  2312. : \
  2313. (0UL) \
  2314. )
  2315. #elif defined (ADC1) && defined (ADC2)
  2316. #define __LL_ADC_IS_CHANNEL_INTERNAL_AVAILABLE(__ADC_INSTANCE__, __CHANNEL__) \
  2317. (((__ADC_INSTANCE__) == ADC1) ? \
  2318. ( \
  2319. ((__CHANNEL__) == LL_ADC_CHANNEL_VREFINT) || \
  2320. ((__CHANNEL__) == LL_ADC_CHANNEL_TEMPSENSOR) || \
  2321. ((__CHANNEL__) == LL_ADC_CHANNEL_VBAT) \
  2322. ) \
  2323. : \
  2324. ((__ADC_INSTANCE__) == ADC2) ? \
  2325. ( \
  2326. ((__CHANNEL__) == LL_ADC_CHANNEL_VREFINT) || \
  2327. ((__CHANNEL__) == LL_ADC_CHANNEL_DAC1CH1_ADC2) || \
  2328. ((__CHANNEL__) == LL_ADC_CHANNEL_DAC1CH2_ADC2) \
  2329. ) \
  2330. : \
  2331. (0UL) \
  2332. )
  2333. #elif defined (ADC1)
  2334. #define __LL_ADC_IS_CHANNEL_INTERNAL_AVAILABLE(__ADC_INSTANCE__, __CHANNEL__) \
  2335. ( \
  2336. ((__CHANNEL__) == LL_ADC_CHANNEL_VREFINT) || \
  2337. ((__CHANNEL__) == LL_ADC_CHANNEL_TEMPSENSOR) || \
  2338. ((__CHANNEL__) == LL_ADC_CHANNEL_VBAT) || \
  2339. ((__CHANNEL__) == LL_ADC_CHANNEL_DAC1CH1) || \
  2340. ((__CHANNEL__) == LL_ADC_CHANNEL_DAC1CH2) \
  2341. )
  2342. #endif /* defined (ADC1) && defined (ADC2) && defined (ADC3) */
  2343. /**
  2344. * @brief Helper macro to define ADC analog watchdog parameter:
  2345. * define a single channel to monitor with analog watchdog
  2346. * from sequencer channel and groups definition.
  2347. * @note To be used with function @ref LL_ADC_SetAnalogWDMonitChannels().
  2348. * Example:
  2349. * LL_ADC_SetAnalogWDMonitChannels(
  2350. * ADC1, LL_ADC_AWD1,
  2351. * __LL_ADC_ANALOGWD_CHANNEL_GROUP(LL_ADC_CHANNEL4, LL_ADC_GROUP_REGULAR))
  2352. * @param __CHANNEL__ This parameter can be one of the following values:
  2353. * @arg @ref LL_ADC_CHANNEL_0
  2354. * @arg @ref LL_ADC_CHANNEL_1 (7)
  2355. * @arg @ref LL_ADC_CHANNEL_2 (7)
  2356. * @arg @ref LL_ADC_CHANNEL_3 (7)
  2357. * @arg @ref LL_ADC_CHANNEL_4 (7)
  2358. * @arg @ref LL_ADC_CHANNEL_5 (7)
  2359. * @arg @ref LL_ADC_CHANNEL_6
  2360. * @arg @ref LL_ADC_CHANNEL_7
  2361. * @arg @ref LL_ADC_CHANNEL_8
  2362. * @arg @ref LL_ADC_CHANNEL_9
  2363. * @arg @ref LL_ADC_CHANNEL_10
  2364. * @arg @ref LL_ADC_CHANNEL_11
  2365. * @arg @ref LL_ADC_CHANNEL_12
  2366. * @arg @ref LL_ADC_CHANNEL_13
  2367. * @arg @ref LL_ADC_CHANNEL_14
  2368. * @arg @ref LL_ADC_CHANNEL_15
  2369. * @arg @ref LL_ADC_CHANNEL_16
  2370. * @arg @ref LL_ADC_CHANNEL_17
  2371. * @arg @ref LL_ADC_CHANNEL_18
  2372. * @arg @ref LL_ADC_CHANNEL_VREFINT (1)
  2373. * @arg @ref LL_ADC_CHANNEL_TEMPSENSOR (4)
  2374. * @arg @ref LL_ADC_CHANNEL_VBAT (4)
  2375. * @arg @ref LL_ADC_CHANNEL_DAC1CH1 (5)
  2376. * @arg @ref LL_ADC_CHANNEL_DAC1CH2 (5)
  2377. * @arg @ref LL_ADC_CHANNEL_DAC1CH1_ADC2 (2)(6)
  2378. * @arg @ref LL_ADC_CHANNEL_DAC1CH2_ADC2 (2)(6)
  2379. * @arg @ref LL_ADC_CHANNEL_DAC1CH1_ADC3 (3)(6)
  2380. * @arg @ref LL_ADC_CHANNEL_DAC1CH2_ADC3 (3)(6)
  2381. *
  2382. * (1) On STM32L4, parameter available only on ADC instance: ADC1.\n
  2383. * (2) On STM32L4, parameter available only on ADC instance: ADC2.\n
  2384. * (3) On STM32L4, parameter available only on ADC instance: ADC3.\n
  2385. * (4) On STM32L4, parameter available only on ADC instances: ADC1, ADC3.\n
  2386. * (5) On STM32L4, parameter available on devices with only 1 ADC instance.\n
  2387. * (6) On STM32L4, parameter available on devices with several ADC instances.\n
  2388. * (7) On STM32L4, fast channel (0.188 us for 12-bit resolution (ADC conversion rate up to 5.33 Ms/s)).
  2389. * Other channels are slow channels (0.238 us for 12-bit resolution (ADC conversion rate up to
  2390. * 4.21 Ms/s)).\n
  2391. * (1, 2, 3, 4) For ADC channel read back from ADC register,
  2392. * comparison with internal channel parameter to be done
  2393. * using helper macro @ref __LL_ADC_CHANNEL_INTERNAL_TO_EXTERNAL().
  2394. * @param __GROUP__ This parameter can be one of the following values:
  2395. * @arg @ref LL_ADC_GROUP_REGULAR
  2396. * @arg @ref LL_ADC_GROUP_INJECTED
  2397. * @arg @ref LL_ADC_GROUP_REGULAR_INJECTED
  2398. * @retval Returned value can be one of the following values:
  2399. * @arg @ref LL_ADC_AWD_DISABLE
  2400. * @arg @ref LL_ADC_AWD_ALL_CHANNELS_REG (0)
  2401. * @arg @ref LL_ADC_AWD_ALL_CHANNELS_INJ (0)
  2402. * @arg @ref LL_ADC_AWD_ALL_CHANNELS_REG_INJ
  2403. * @arg @ref LL_ADC_AWD_CHANNEL_0_REG (0)
  2404. * @arg @ref LL_ADC_AWD_CHANNEL_0_INJ (0)
  2405. * @arg @ref LL_ADC_AWD_CHANNEL_0_REG_INJ
  2406. * @arg @ref LL_ADC_AWD_CHANNEL_1_REG (0)
  2407. * @arg @ref LL_ADC_AWD_CHANNEL_1_INJ (0)
  2408. * @arg @ref LL_ADC_AWD_CHANNEL_1_REG_INJ
  2409. * @arg @ref LL_ADC_AWD_CHANNEL_2_REG (0)
  2410. * @arg @ref LL_ADC_AWD_CHANNEL_2_INJ (0)
  2411. * @arg @ref LL_ADC_AWD_CHANNEL_2_REG_INJ
  2412. * @arg @ref LL_ADC_AWD_CHANNEL_3_REG (0)
  2413. * @arg @ref LL_ADC_AWD_CHANNEL_3_INJ (0)
  2414. * @arg @ref LL_ADC_AWD_CHANNEL_3_REG_INJ
  2415. * @arg @ref LL_ADC_AWD_CHANNEL_4_REG (0)
  2416. * @arg @ref LL_ADC_AWD_CHANNEL_4_INJ (0)
  2417. * @arg @ref LL_ADC_AWD_CHANNEL_4_REG_INJ
  2418. * @arg @ref LL_ADC_AWD_CHANNEL_5_REG (0)
  2419. * @arg @ref LL_ADC_AWD_CHANNEL_5_INJ (0)
  2420. * @arg @ref LL_ADC_AWD_CHANNEL_5_REG_INJ
  2421. * @arg @ref LL_ADC_AWD_CHANNEL_6_REG (0)
  2422. * @arg @ref LL_ADC_AWD_CHANNEL_6_INJ (0)
  2423. * @arg @ref LL_ADC_AWD_CHANNEL_6_REG_INJ
  2424. * @arg @ref LL_ADC_AWD_CHANNEL_7_REG (0)
  2425. * @arg @ref LL_ADC_AWD_CHANNEL_7_INJ (0)
  2426. * @arg @ref LL_ADC_AWD_CHANNEL_7_REG_INJ
  2427. * @arg @ref LL_ADC_AWD_CHANNEL_8_REG (0)
  2428. * @arg @ref LL_ADC_AWD_CHANNEL_8_INJ (0)
  2429. * @arg @ref LL_ADC_AWD_CHANNEL_8_REG_INJ
  2430. * @arg @ref LL_ADC_AWD_CHANNEL_9_REG (0)
  2431. * @arg @ref LL_ADC_AWD_CHANNEL_9_INJ (0)
  2432. * @arg @ref LL_ADC_AWD_CHANNEL_9_REG_INJ
  2433. * @arg @ref LL_ADC_AWD_CHANNEL_10_REG (0)
  2434. * @arg @ref LL_ADC_AWD_CHANNEL_10_INJ (0)
  2435. * @arg @ref LL_ADC_AWD_CHANNEL_10_REG_INJ
  2436. * @arg @ref LL_ADC_AWD_CHANNEL_11_REG (0)
  2437. * @arg @ref LL_ADC_AWD_CHANNEL_11_INJ (0)
  2438. * @arg @ref LL_ADC_AWD_CHANNEL_11_REG_INJ
  2439. * @arg @ref LL_ADC_AWD_CHANNEL_12_REG (0)
  2440. * @arg @ref LL_ADC_AWD_CHANNEL_12_INJ (0)
  2441. * @arg @ref LL_ADC_AWD_CHANNEL_12_REG_INJ
  2442. * @arg @ref LL_ADC_AWD_CHANNEL_13_REG (0)
  2443. * @arg @ref LL_ADC_AWD_CHANNEL_13_INJ (0)
  2444. * @arg @ref LL_ADC_AWD_CHANNEL_13_REG_INJ
  2445. * @arg @ref LL_ADC_AWD_CHANNEL_14_REG (0)
  2446. * @arg @ref LL_ADC_AWD_CHANNEL_14_INJ (0)
  2447. * @arg @ref LL_ADC_AWD_CHANNEL_14_REG_INJ
  2448. * @arg @ref LL_ADC_AWD_CHANNEL_15_REG (0)
  2449. * @arg @ref LL_ADC_AWD_CHANNEL_15_INJ (0)
  2450. * @arg @ref LL_ADC_AWD_CHANNEL_15_REG_INJ
  2451. * @arg @ref LL_ADC_AWD_CHANNEL_16_REG (0)
  2452. * @arg @ref LL_ADC_AWD_CHANNEL_16_INJ (0)
  2453. * @arg @ref LL_ADC_AWD_CHANNEL_16_REG_INJ
  2454. * @arg @ref LL_ADC_AWD_CHANNEL_17_REG (0)
  2455. * @arg @ref LL_ADC_AWD_CHANNEL_17_INJ (0)
  2456. * @arg @ref LL_ADC_AWD_CHANNEL_17_REG_INJ
  2457. * @arg @ref LL_ADC_AWD_CHANNEL_18_REG (0)
  2458. * @arg @ref LL_ADC_AWD_CHANNEL_18_INJ (0)
  2459. * @arg @ref LL_ADC_AWD_CHANNEL_18_REG_INJ
  2460. * @arg @ref LL_ADC_AWD_CH_VREFINT_REG (0)(1)
  2461. * @arg @ref LL_ADC_AWD_CH_VREFINT_INJ (0)(1)
  2462. * @arg @ref LL_ADC_AWD_CH_VREFINT_REG_INJ (1)
  2463. * @arg @ref LL_ADC_AWD_CH_TEMPSENSOR_REG (0)(4)
  2464. * @arg @ref LL_ADC_AWD_CH_TEMPSENSOR_INJ (0)(4)
  2465. * @arg @ref LL_ADC_AWD_CH_TEMPSENSOR_REG_INJ (4)
  2466. * @arg @ref LL_ADC_AWD_CH_VBAT_REG (0)(4)
  2467. * @arg @ref LL_ADC_AWD_CH_VBAT_INJ (0)(4)
  2468. * @arg @ref LL_ADC_AWD_CH_VBAT_REG_INJ (4)
  2469. * @arg @ref LL_ADC_AWD_CH_DAC1CH1_REG (0)(2)(5)
  2470. * @arg @ref LL_ADC_AWD_CH_DAC1CH1_INJ (0)(2)(5)
  2471. * @arg @ref LL_ADC_AWD_CH_DAC1CH1_REG_INJ (2)(5)
  2472. * @arg @ref LL_ADC_AWD_CH_DAC1CH2_REG (0)(2)(5)
  2473. * @arg @ref LL_ADC_AWD_CH_DAC1CH2_INJ (0)(2)(5)
  2474. * @arg @ref LL_ADC_AWD_CH_DAC1CH2_REG_INJ (2)(5)
  2475. * @arg @ref LL_ADC_AWD_CH_DAC1CH1_ADC2_REG (0)(2)(6)
  2476. * @arg @ref LL_ADC_AWD_CH_DAC1CH1_ADC2_INJ (0)(2)(6)
  2477. * @arg @ref LL_ADC_AWD_CH_DAC1CH1_ADC2_REG_INJ (2)(6)
  2478. * @arg @ref LL_ADC_AWD_CH_DAC1CH2_ADC2_REG (0)(2)(6)
  2479. * @arg @ref LL_ADC_AWD_CH_DAC1CH2_ADC2_INJ (0)(2)(6)
  2480. * @arg @ref LL_ADC_AWD_CH_DAC1CH2_ADC2_REG_INJ (2)(6)
  2481. * @arg @ref LL_ADC_AWD_CH_DAC1CH1_ADC3_REG (0)(3)(6)
  2482. * @arg @ref LL_ADC_AWD_CH_DAC1CH1_ADC3_INJ (0)(3)(6)
  2483. * @arg @ref LL_ADC_AWD_CH_DAC1CH1_ADC3_REG_INJ (3)(6)
  2484. * @arg @ref LL_ADC_AWD_CH_DAC1CH2_ADC3_REG (0)(3)(6)
  2485. * @arg @ref LL_ADC_AWD_CH_DAC1CH2_ADC3_INJ (0)(3)(6)
  2486. * @arg @ref LL_ADC_AWD_CH_DAC1CH2_ADC3_REG_INJ (3)(6)
  2487. *
  2488. * (0) On STM32L4, parameter available only on analog watchdog number: AWD1.\n
  2489. * (1) On STM32L4, parameter available only on ADC instance: ADC1.\n
  2490. * (2) On STM32L4, parameter available only on ADC instance: ADC2.\n
  2491. * (3) On STM32L4, parameter available only on ADC instance: ADC3.\n
  2492. * (4) On STM32L4, parameter available only on ADC instances: ADC1, ADC3.
  2493. * (5) On STM32L4, parameter available on devices with only 1 ADC instance.\n
  2494. * (6) On STM32L4, parameter available on devices with several ADC instances.
  2495. */
  2496. #define __LL_ADC_ANALOGWD_CHANNEL_GROUP(__CHANNEL__, __GROUP__) \
  2497. (((__GROUP__) == LL_ADC_GROUP_REGULAR) \
  2498. ? (((__CHANNEL__) & ADC_CHANNEL_ID_MASK) | ADC_CFGR_AWD1EN | ADC_CFGR_AWD1SGL) \
  2499. : \
  2500. ((__GROUP__) == LL_ADC_GROUP_INJECTED) \
  2501. ? (((__CHANNEL__) & ADC_CHANNEL_ID_MASK) | ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1SGL) \
  2502. : \
  2503. (((__CHANNEL__) & ADC_CHANNEL_ID_MASK) | ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1EN | ADC_CFGR_AWD1SGL) \
  2504. )
  2505. /**
  2506. * @brief Helper macro to set the value of ADC analog watchdog threshold high
  2507. * or low in function of ADC resolution, when ADC resolution is
  2508. * different of 12 bits.
  2509. * @note To be used with function @ref LL_ADC_ConfigAnalogWDThresholds()
  2510. * or @ref LL_ADC_SetAnalogWDThresholds().
  2511. * Example, with a ADC resolution of 8 bits, to set the value of
  2512. * analog watchdog threshold high (on 8 bits):
  2513. * LL_ADC_SetAnalogWDThresholds
  2514. * (< ADCx param >,
  2515. * __LL_ADC_ANALOGWD_SET_THRESHOLD_RESOLUTION(LL_ADC_RESOLUTION_8B, <threshold_value_8_bits>)
  2516. * );
  2517. * @param __ADC_RESOLUTION__ This parameter can be one of the following values:
  2518. * @arg @ref LL_ADC_RESOLUTION_12B
  2519. * @arg @ref LL_ADC_RESOLUTION_10B
  2520. * @arg @ref LL_ADC_RESOLUTION_8B
  2521. * @arg @ref LL_ADC_RESOLUTION_6B
  2522. * @param __AWD_THRESHOLD__ Value between Min_Data=0x000 and Max_Data=0xFFF
  2523. * @retval Value between Min_Data=0x000 and Max_Data=0xFFF
  2524. */
  2525. #define __LL_ADC_ANALOGWD_SET_THRESHOLD_RESOLUTION(__ADC_RESOLUTION__, __AWD_THRESHOLD__) \
  2526. ((__AWD_THRESHOLD__) << ((__ADC_RESOLUTION__) >> (ADC_CFGR_RES_BITOFFSET_POS - 1U )))
  2527. /**
  2528. * @brief Helper macro to get the value of ADC analog watchdog threshold high
  2529. * or low in function of ADC resolution, when ADC resolution is
  2530. * different of 12 bits.
  2531. * @note To be used with function @ref LL_ADC_GetAnalogWDThresholds().
  2532. * Example, with a ADC resolution of 8 bits, to get the value of
  2533. * analog watchdog threshold high (on 8 bits):
  2534. * < threshold_value_6_bits > = __LL_ADC_ANALOGWD_GET_THRESHOLD_RESOLUTION
  2535. * (LL_ADC_RESOLUTION_8B,
  2536. * LL_ADC_GetAnalogWDThresholds(<ADCx param>, LL_ADC_AWD_THRESHOLD_HIGH)
  2537. * );
  2538. * @param __ADC_RESOLUTION__ This parameter can be one of the following values:
  2539. * @arg @ref LL_ADC_RESOLUTION_12B
  2540. * @arg @ref LL_ADC_RESOLUTION_10B
  2541. * @arg @ref LL_ADC_RESOLUTION_8B
  2542. * @arg @ref LL_ADC_RESOLUTION_6B
  2543. * @param __AWD_THRESHOLD_12_BITS__ Value between Min_Data=0x000 and Max_Data=0xFFF
  2544. * @retval Value between Min_Data=0x000 and Max_Data=0xFFF
  2545. */
  2546. #define __LL_ADC_ANALOGWD_GET_THRESHOLD_RESOLUTION(__ADC_RESOLUTION__, __AWD_THRESHOLD_12_BITS__) \
  2547. ((__AWD_THRESHOLD_12_BITS__) >> ((__ADC_RESOLUTION__) >> (ADC_CFGR_RES_BITOFFSET_POS - 1U )))
  2548. /**
  2549. * @brief Helper macro to get the ADC analog watchdog threshold high
  2550. * or low from raw value containing both thresholds concatenated.
  2551. * @note To be used with function @ref LL_ADC_GetAnalogWDThresholds().
  2552. * Example, to get analog watchdog threshold high from the register raw value:
  2553. * __LL_ADC_ANALOGWD_THRESHOLDS_HIGH_LOW(LL_ADC_AWD_THRESHOLD_HIGH, <raw_value_with_both_thresholds>);
  2554. * @param __AWD_THRESHOLD_TYPE__ This parameter can be one of the following values:
  2555. * @arg @ref LL_ADC_AWD_THRESHOLD_HIGH
  2556. * @arg @ref LL_ADC_AWD_THRESHOLD_LOW
  2557. * @param __AWD_THRESHOLDS__ Value between Min_Data=0x00000000 and Max_Data=0xFFFFFFFF
  2558. * @retval Value between Min_Data=0x000 and Max_Data=0xFFF
  2559. */
  2560. #define __LL_ADC_ANALOGWD_THRESHOLDS_HIGH_LOW(__AWD_THRESHOLD_TYPE__, __AWD_THRESHOLDS__) \
  2561. (((__AWD_THRESHOLDS__) >> (((__AWD_THRESHOLD_TYPE__) & ADC_AWD_TRX_BIT_HIGH_MASK) >> ADC_AWD_TRX_BIT_HIGH_SHIFT4)) \
  2562. & LL_ADC_AWD_THRESHOLD_LOW)
  2563. /**
  2564. * @brief Helper macro to set the ADC calibration value with both single ended
  2565. * and differential modes calibration factors concatenated.
  2566. * @note To be used with function @ref LL_ADC_SetCalibrationFactor().
  2567. * Example, to set calibration factors single ended to 0x55
  2568. * and differential ended to 0x2A:
  2569. * LL_ADC_SetCalibrationFactor(
  2570. * ADC1,
  2571. * __LL_ADC_CALIB_FACTOR_SINGLE_DIFF(0x55, 0x2A))
  2572. * @param __CALIB_FACTOR_SINGLE_ENDED__ Value between Min_Data=0x00 and Max_Data=0x7F
  2573. * @param __CALIB_FACTOR_DIFFERENTIAL__ Value between Min_Data=0x00 and Max_Data=0x7F
  2574. * @retval Value between Min_Data=0x00000000 and Max_Data=0xFFFFFFFF
  2575. */
  2576. #define __LL_ADC_CALIB_FACTOR_SINGLE_DIFF(__CALIB_FACTOR_SINGLE_ENDED__, __CALIB_FACTOR_DIFFERENTIAL__) \
  2577. (((__CALIB_FACTOR_DIFFERENTIAL__) << ADC_CALFACT_CALFACT_D_Pos) | (__CALIB_FACTOR_SINGLE_ENDED__))
  2578. #if defined(ADC_MULTIMODE_SUPPORT)
  2579. /**
  2580. * @brief Helper macro to get the ADC multimode conversion data of ADC master
  2581. * or ADC slave from raw value with both ADC conversion data concatenated.
  2582. * @note This macro is intended to be used when multimode transfer by DMA
  2583. * is enabled: refer to function @ref LL_ADC_SetMultiDMATransfer().
  2584. * In this case the transferred data need to processed with this macro
  2585. * to separate the conversion data of ADC master and ADC slave.
  2586. * @param __ADC_MULTI_MASTER_SLAVE__ This parameter can be one of the following values:
  2587. * @arg @ref LL_ADC_MULTI_MASTER
  2588. * @arg @ref LL_ADC_MULTI_SLAVE
  2589. * @param __ADC_MULTI_CONV_DATA__ Value between Min_Data=0x000 and Max_Data=0xFFF
  2590. * @retval Value between Min_Data=0x000 and Max_Data=0xFFF
  2591. */
  2592. #define __LL_ADC_MULTI_CONV_DATA_MASTER_SLAVE(__ADC_MULTI_MASTER_SLAVE__, __ADC_MULTI_CONV_DATA__) \
  2593. (((__ADC_MULTI_CONV_DATA__) >> ((ADC_CDR_RDATA_SLV_Pos) & ~(__ADC_MULTI_MASTER_SLAVE__))) & ADC_CDR_RDATA_MST)
  2594. #endif /* ADC_MULTIMODE_SUPPORT */
  2595. #if defined(ADC_MULTIMODE_SUPPORT)
  2596. /**
  2597. * @brief Helper macro to select, from a ADC instance, to which ADC instance
  2598. * it has a dependence in multimode (ADC master of the corresponding
  2599. * ADC common instance).
  2600. * @note In case of device with multimode available and a mix of
  2601. * ADC instances compliant and not compliant with multimode feature,
  2602. * ADC instances not compliant with multimode feature are
  2603. * considered as master instances (do not depend to
  2604. * any other ADC instance).
  2605. * @param __ADCx__ ADC instance
  2606. * @retval __ADCx__ ADC instance master of the corresponding ADC common instance
  2607. */
  2608. #if defined(ADC2)
  2609. #define __LL_ADC_MULTI_INSTANCE_MASTER(__ADCx__) \
  2610. ((((__ADCx__) == ADC2))? \
  2611. (ADC1) \
  2612. : \
  2613. (__ADCx__) \
  2614. )
  2615. #else
  2616. #define __LL_ADC_MULTI_INSTANCE_MASTER(__ADCx__) \
  2617. (__ADCx__)
  2618. #endif /* ADC2 */
  2619. #endif /* ADC_MULTIMODE_SUPPORT */
  2620. /**
  2621. * @brief Helper macro to select the ADC common instance
  2622. * to which is belonging the selected ADC instance.
  2623. * @note ADC common register instance can be used for:
  2624. * - Set parameters common to several ADC instances
  2625. * - Multimode (for devices with several ADC instances)
  2626. * Refer to functions having argument "ADCxy_COMMON" as parameter.
  2627. * @param __ADCx__ ADC instance
  2628. * @retval ADC common register instance
  2629. */
  2630. #if defined(ADC1) && defined(ADC2) && defined(ADC3)
  2631. #define __LL_ADC_COMMON_INSTANCE(__ADCx__) \
  2632. (ADC123_COMMON)
  2633. #elif defined(ADC1) && defined(ADC2)
  2634. #define __LL_ADC_COMMON_INSTANCE(__ADCx__) \
  2635. (ADC12_COMMON)
  2636. #else
  2637. #define __LL_ADC_COMMON_INSTANCE(__ADCx__) \
  2638. (ADC1_COMMON)
  2639. #endif /* defined(ADC1) && defined(ADC2) && defined(ADC3) */
  2640. /**
  2641. * @brief Helper macro to check if all ADC instances sharing the same
  2642. * ADC common instance are disabled.
  2643. * @note This check is required by functions with setting conditioned to
  2644. * ADC state:
  2645. * All ADC instances of the ADC common group must be disabled.
  2646. * Refer to functions having argument "ADCxy_COMMON" as parameter.
  2647. * @note On devices with only 1 ADC common instance, parameter of this macro
  2648. * is useless and can be ignored (parameter kept for compatibility
  2649. * with devices featuring several ADC common instances).
  2650. * @param __ADCXY_COMMON__ ADC common instance
  2651. * (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() )
  2652. * @retval Value "0" if all ADC instances sharing the same ADC common instance
  2653. * are disabled.
  2654. * Value "1" if at least one ADC instance sharing the same ADC common instance
  2655. * is enabled.
  2656. */
  2657. #if defined(ADC1) && defined(ADC2) && defined(ADC3)
  2658. #define __LL_ADC_IS_ENABLED_ALL_COMMON_INSTANCE(__ADCXY_COMMON__) \
  2659. (LL_ADC_IsEnabled(ADC1) | \
  2660. LL_ADC_IsEnabled(ADC2) | \
  2661. LL_ADC_IsEnabled(ADC3) )
  2662. #elif defined(ADC1) && defined(ADC2)
  2663. #define __LL_ADC_IS_ENABLED_ALL_COMMON_INSTANCE(__ADCXY_COMMON__) \
  2664. (LL_ADC_IsEnabled(ADC1) | \
  2665. LL_ADC_IsEnabled(ADC2) )
  2666. #else
  2667. #define __LL_ADC_IS_ENABLED_ALL_COMMON_INSTANCE(__ADCXY_COMMON__) \
  2668. (LL_ADC_IsEnabled(ADC1))
  2669. #endif /* defined(ADC1) && defined(ADC2) && defined(ADC3) */
  2670. /**
  2671. * @brief Helper macro to define the ADC conversion data full-scale digital
  2672. * value corresponding to the selected ADC resolution.
  2673. * @note ADC conversion data full-scale corresponds to voltage range
  2674. * determined by analog voltage references Vref+ and Vref-
  2675. * (refer to reference manual).
  2676. * @param __ADC_RESOLUTION__ This parameter can be one of the following values:
  2677. * @arg @ref LL_ADC_RESOLUTION_12B
  2678. * @arg @ref LL_ADC_RESOLUTION_10B
  2679. * @arg @ref LL_ADC_RESOLUTION_8B
  2680. * @arg @ref LL_ADC_RESOLUTION_6B
  2681. * @retval ADC conversion data full-scale digital value (unit: digital value of ADC conversion data)
  2682. */
  2683. #define __LL_ADC_DIGITAL_SCALE(__ADC_RESOLUTION__) \
  2684. (0xFFFUL >> ((__ADC_RESOLUTION__) >> (ADC_CFGR_RES_BITOFFSET_POS - 1UL)))
  2685. /**
  2686. * @brief Helper macro to convert the ADC conversion data from
  2687. * a resolution to another resolution.
  2688. * @param __DATA__ ADC conversion data to be converted
  2689. * @param __ADC_RESOLUTION_CURRENT__ Resolution of the data to be converted
  2690. * This parameter can be one of the following values:
  2691. * @arg @ref LL_ADC_RESOLUTION_12B
  2692. * @arg @ref LL_ADC_RESOLUTION_10B
  2693. * @arg @ref LL_ADC_RESOLUTION_8B
  2694. * @arg @ref LL_ADC_RESOLUTION_6B
  2695. * @param __ADC_RESOLUTION_TARGET__ Resolution of the data after conversion
  2696. * This parameter can be one of the following values:
  2697. * @arg @ref LL_ADC_RESOLUTION_12B
  2698. * @arg @ref LL_ADC_RESOLUTION_10B
  2699. * @arg @ref LL_ADC_RESOLUTION_8B
  2700. * @arg @ref LL_ADC_RESOLUTION_6B
  2701. * @retval ADC conversion data to the requested resolution
  2702. */
  2703. #define __LL_ADC_CONVERT_DATA_RESOLUTION(__DATA__,\
  2704. __ADC_RESOLUTION_CURRENT__,\
  2705. __ADC_RESOLUTION_TARGET__) \
  2706. (((__DATA__) \
  2707. << ((__ADC_RESOLUTION_CURRENT__) >> (ADC_CFGR_RES_BITOFFSET_POS - 1UL))) \
  2708. >> ((__ADC_RESOLUTION_TARGET__) >> (ADC_CFGR_RES_BITOFFSET_POS - 1UL)) \
  2709. )
  2710. /**
  2711. * @brief Helper macro to calculate the voltage (unit: mVolt)
  2712. * corresponding to a ADC conversion data (unit: digital value).
  2713. * @note Analog reference voltage (Vref+) must be either known from
  2714. * user board environment or can be calculated using ADC measurement
  2715. * and ADC helper macro @ref __LL_ADC_CALC_VREFANALOG_VOLTAGE().
  2716. * @param __VREFANALOG_VOLTAGE__ Analog reference voltage (unit: mV)
  2717. * @param __ADC_DATA__ ADC conversion data (resolution 12 bits)
  2718. * (unit: digital value).
  2719. * @param __ADC_RESOLUTION__ This parameter can be one of the following values:
  2720. * @arg @ref LL_ADC_RESOLUTION_12B
  2721. * @arg @ref LL_ADC_RESOLUTION_10B
  2722. * @arg @ref LL_ADC_RESOLUTION_8B
  2723. * @arg @ref LL_ADC_RESOLUTION_6B
  2724. * @retval ADC conversion data equivalent voltage value (unit: mVolt)
  2725. */
  2726. #define __LL_ADC_CALC_DATA_TO_VOLTAGE(__VREFANALOG_VOLTAGE__,\
  2727. __ADC_DATA__,\
  2728. __ADC_RESOLUTION__) \
  2729. ((__ADC_DATA__) * (__VREFANALOG_VOLTAGE__) \
  2730. / __LL_ADC_DIGITAL_SCALE(__ADC_RESOLUTION__) \
  2731. )
  2732. /* Legacy define */
  2733. #define __LL_ADC_CALC_DATA_VOLTAGE() __LL_ADC_CALC_DATA_TO_VOLTAGE()
  2734. /**
  2735. * @brief Helper macro to calculate analog reference voltage (Vref+)
  2736. * (unit: mVolt) from ADC conversion data of internal voltage
  2737. * reference VrefInt.
  2738. * @note Computation is using VrefInt calibration value
  2739. * stored in system memory for each device during production.
  2740. * @note This voltage depends on user board environment: voltage level
  2741. * connected to pin Vref+.
  2742. * On devices with small package, the pin Vref+ is not present
  2743. * and internally bonded to pin Vdda.
  2744. * @note On this STM32 series, calibration data of internal voltage reference
  2745. * VrefInt corresponds to a resolution of 12 bits,
  2746. * this is the recommended ADC resolution to convert voltage of
  2747. * internal voltage reference VrefInt.
  2748. * Otherwise, this macro performs the processing to scale
  2749. * ADC conversion data to 12 bits.
  2750. * @param __VREFINT_ADC_DATA__ ADC conversion data (resolution 12 bits)
  2751. * of internal voltage reference VrefInt (unit: digital value).
  2752. * @param __ADC_RESOLUTION__ This parameter can be one of the following values:
  2753. * @arg @ref LL_ADC_RESOLUTION_12B
  2754. * @arg @ref LL_ADC_RESOLUTION_10B
  2755. * @arg @ref LL_ADC_RESOLUTION_8B
  2756. * @arg @ref LL_ADC_RESOLUTION_6B
  2757. * @retval Analog reference voltage (unit: mV)
  2758. */
  2759. #define __LL_ADC_CALC_VREFANALOG_VOLTAGE(__VREFINT_ADC_DATA__,\
  2760. __ADC_RESOLUTION__) \
  2761. (((uint32_t)(*VREFINT_CAL_ADDR) * VREFINT_CAL_VREF) \
  2762. / __LL_ADC_CONVERT_DATA_RESOLUTION((__VREFINT_ADC_DATA__), \
  2763. (__ADC_RESOLUTION__), \
  2764. LL_ADC_RESOLUTION_12B) \
  2765. )
  2766. /**
  2767. * @brief Helper macro to calculate the temperature (unit: degree Celsius)
  2768. * from ADC conversion data of internal temperature sensor.
  2769. * @note Computation is using temperature sensor calibration values
  2770. * stored in system memory for each device during production.
  2771. * @note Calculation formula:
  2772. * Temperature = ((TS_ADC_DATA - TS_CAL1)
  2773. * * (TS_CAL2_TEMP - TS_CAL1_TEMP))
  2774. * / (TS_CAL2 - TS_CAL1) + TS_CAL1_TEMP
  2775. * with TS_ADC_DATA = temperature sensor raw data measured by ADC
  2776. * Avg_Slope = (TS_CAL2 - TS_CAL1)
  2777. * / (TS_CAL2_TEMP - TS_CAL1_TEMP)
  2778. * TS_CAL1 = equivalent TS_ADC_DATA at temperature
  2779. * TEMP_DEGC_CAL1 (calibrated in factory)
  2780. * TS_CAL2 = equivalent TS_ADC_DATA at temperature
  2781. * TEMP_DEGC_CAL2 (calibrated in factory)
  2782. * Caution: Calculation relevancy under reserve that calibration
  2783. * parameters are correct (address and data).
  2784. * To calculate temperature using temperature sensor
  2785. * datasheet typical values (generic values less, therefore
  2786. * less accurate than calibrated values),
  2787. * use helper macro @ref __LL_ADC_CALC_TEMPERATURE_TYP_PARAMS().
  2788. * @note As calculation input, the analog reference voltage (Vref+) must be
  2789. * defined as it impacts the ADC LSB equivalent voltage.
  2790. * @note Analog reference voltage (Vref+) must be either known from
  2791. * user board environment or can be calculated using ADC measurement
  2792. * and ADC helper macro @ref __LL_ADC_CALC_VREFANALOG_VOLTAGE().
  2793. * @note On this STM32 series, calibration data of temperature sensor
  2794. * corresponds to a resolution of 12 bits,
  2795. * this is the recommended ADC resolution to convert voltage of
  2796. * temperature sensor.
  2797. * Otherwise, this macro performs the processing to scale
  2798. * ADC conversion data to 12 bits.
  2799. * @param __VREFANALOG_VOLTAGE__ Analog reference voltage (unit: mV)
  2800. * @param __TEMPSENSOR_ADC_DATA__ ADC conversion data of internal
  2801. * temperature sensor (unit: digital value).
  2802. * @param __ADC_RESOLUTION__ ADC resolution at which internal temperature
  2803. * sensor voltage has been measured.
  2804. * This parameter can be one of the following values:
  2805. * @arg @ref LL_ADC_RESOLUTION_12B
  2806. * @arg @ref LL_ADC_RESOLUTION_10B
  2807. * @arg @ref LL_ADC_RESOLUTION_8B
  2808. * @arg @ref LL_ADC_RESOLUTION_6B
  2809. * @retval Temperature (unit: degree Celsius)
  2810. * In case or error, value LL_ADC_TEMPERATURE_CALC_ERROR is returned (inconsistent temperature value)
  2811. */
  2812. #define __LL_ADC_CALC_TEMPERATURE(__VREFANALOG_VOLTAGE__,\
  2813. __TEMPSENSOR_ADC_DATA__,\
  2814. __ADC_RESOLUTION__)\
  2815. ((((int32_t)*TEMPSENSOR_CAL2_ADDR - (int32_t)*TEMPSENSOR_CAL1_ADDR) != 0) ? \
  2816. (((( ((int32_t)((__LL_ADC_CONVERT_DATA_RESOLUTION((__TEMPSENSOR_ADC_DATA__), \
  2817. (__ADC_RESOLUTION__), \
  2818. LL_ADC_RESOLUTION_12B) \
  2819. * (__VREFANALOG_VOLTAGE__)) \
  2820. / TEMPSENSOR_CAL_VREFANALOG) \
  2821. - (int32_t) *TEMPSENSOR_CAL1_ADDR) \
  2822. ) * (int32_t)(TEMPSENSOR_CAL2_TEMP - TEMPSENSOR_CAL1_TEMP) \
  2823. ) / (int32_t)((int32_t)*TEMPSENSOR_CAL2_ADDR - (int32_t)*TEMPSENSOR_CAL1_ADDR) \
  2824. ) + TEMPSENSOR_CAL1_TEMP \
  2825. ) \
  2826. : \
  2827. ((int32_t)LL_ADC_TEMPERATURE_CALC_ERROR) \
  2828. )
  2829. /**
  2830. * @brief Helper macro to calculate the temperature (unit: degree Celsius)
  2831. * from ADC conversion data of internal temperature sensor.
  2832. * @note Computation is using temperature sensor typical values
  2833. * (refer to device datasheet).
  2834. * @note Calculation formula:
  2835. * Temperature = (TS_TYP_CALx_VOLT(uV) - TS_ADC_DATA * Conversion_uV)
  2836. * / Avg_Slope + CALx_TEMP
  2837. * with TS_ADC_DATA = temperature sensor raw data measured by ADC
  2838. * (unit: digital value)
  2839. * Avg_Slope = temperature sensor slope
  2840. * (unit: uV/Degree Celsius)
  2841. * TS_TYP_CALx_VOLT = temperature sensor digital value at
  2842. * temperature CALx_TEMP (unit: mV)
  2843. * Caution: Calculation relevancy under reserve the temperature sensor
  2844. * of the current device has characteristics in line with
  2845. * datasheet typical values.
  2846. * If temperature sensor calibration values are available on
  2847. * on this device (presence of macro __LL_ADC_CALC_TEMPERATURE()),
  2848. * temperature calculation will be more accurate using
  2849. * helper macro @ref __LL_ADC_CALC_TEMPERATURE().
  2850. * @note As calculation input, the analog reference voltage (Vref+) must be
  2851. * defined as it impacts the ADC LSB equivalent voltage.
  2852. * @note Analog reference voltage (Vref+) must be either known from
  2853. * user board environment or can be calculated using ADC measurement
  2854. * and ADC helper macro @ref __LL_ADC_CALC_VREFANALOG_VOLTAGE().
  2855. * @note ADC measurement data must correspond to a resolution of 12 bits
  2856. * (full scale digital value 4095). If not the case, the data must be
  2857. * preliminarily rescaled to an equivalent resolution of 12 bits.
  2858. * @param __TEMPSENSOR_TYP_AVGSLOPE__ Device datasheet data: Temperature sensor slope typical value
  2859. * (unit: uV/DegCelsius).
  2860. * On STM32L4, refer to device datasheet parameter "Avg_Slope".
  2861. * @param __TEMPSENSOR_TYP_CALX_V__ Device datasheet data: Temperature sensor voltage typical value
  2862. * (at temperature and Vref+ defined in parameters below) (unit: mV).
  2863. * On STM32L4, refer to datasheet parameter "V30" (corresponding to TS_CAL1).
  2864. * @param __TEMPSENSOR_CALX_TEMP__ Device datasheet data: Temperature at which temperature sensor voltage
  2865. * (see parameter above) is corresponding (unit: mV)
  2866. * @param __VREFANALOG_VOLTAGE__ Analog voltage reference (Vref+) value (unit: mV)
  2867. * @param __TEMPSENSOR_ADC_DATA__ ADC conversion data of internal temperature sensor (unit: digital value).
  2868. * @param __ADC_RESOLUTION__ ADC resolution at which internal temperature sensor voltage has been measured.
  2869. * This parameter can be one of the following values:
  2870. * @arg @ref LL_ADC_RESOLUTION_12B
  2871. * @arg @ref LL_ADC_RESOLUTION_10B
  2872. * @arg @ref LL_ADC_RESOLUTION_8B
  2873. * @arg @ref LL_ADC_RESOLUTION_6B
  2874. * @retval Temperature (unit: degree Celsius)
  2875. */
  2876. #define __LL_ADC_CALC_TEMPERATURE_TYP_PARAMS(__TEMPSENSOR_TYP_AVGSLOPE__,\
  2877. __TEMPSENSOR_TYP_CALX_V__,\
  2878. __TEMPSENSOR_CALX_TEMP__,\
  2879. __VREFANALOG_VOLTAGE__,\
  2880. __TEMPSENSOR_ADC_DATA__,\
  2881. __ADC_RESOLUTION__) \
  2882. (((((int32_t)((((__TEMPSENSOR_ADC_DATA__) * (__VREFANALOG_VOLTAGE__)) \
  2883. / __LL_ADC_DIGITAL_SCALE(__ADC_RESOLUTION__)) \
  2884. * 1000UL) \
  2885. - \
  2886. (int32_t)(((__TEMPSENSOR_TYP_CALX_V__)) \
  2887. * 1000UL) \
  2888. ) \
  2889. ) / (int32_t)(__TEMPSENSOR_TYP_AVGSLOPE__) \
  2890. ) + (int32_t)(__TEMPSENSOR_CALX_TEMP__) \
  2891. )
  2892. /**
  2893. * @}
  2894. */
  2895. /**
  2896. * @}
  2897. */
  2898. /* Exported functions --------------------------------------------------------*/
  2899. /** @defgroup ADC_LL_Exported_Functions ADC Exported Functions
  2900. * @{
  2901. */
  2902. /** @defgroup ADC_LL_EF_DMA_Management ADC DMA management
  2903. * @{
  2904. */
  2905. /* Note: LL ADC functions to set DMA transfer are located into sections of */
  2906. /* configuration of ADC instance, groups and multimode (if available): */
  2907. /* @ref LL_ADC_REG_SetDMATransfer(), ... */
  2908. /**
  2909. * @brief Function to help to configure DMA transfer from ADC: retrieve the
  2910. * ADC register address from ADC instance and a list of ADC registers
  2911. * intended to be used (most commonly) with DMA transfer.
  2912. * @note These ADC registers are data registers:
  2913. * when ADC conversion data is available in ADC data registers,
  2914. * ADC generates a DMA transfer request.
  2915. * @note This macro is intended to be used with LL DMA driver, refer to
  2916. * function "LL_DMA_ConfigAddresses()".
  2917. * Example:
  2918. * LL_DMA_ConfigAddresses(DMA1,
  2919. * LL_DMA_CHANNEL_1,
  2920. * LL_ADC_DMA_GetRegAddr(ADC1, LL_ADC_DMA_REG_REGULAR_DATA),
  2921. * (uint32_t)&< array or variable >,
  2922. * LL_DMA_DIRECTION_PERIPH_TO_MEMORY);
  2923. * @note For devices with several ADC: in multimode, some devices
  2924. * use a different data register outside of ADC instance scope
  2925. * (common data register). This macro manages this register difference,
  2926. * only ADC instance has to be set as parameter.
  2927. * @rmtoll DR RDATA LL_ADC_DMA_GetRegAddr\n
  2928. * CDR RDATA_MST LL_ADC_DMA_GetRegAddr\n
  2929. * CDR RDATA_SLV LL_ADC_DMA_GetRegAddr
  2930. * @param ADCx ADC instance
  2931. * @param Register This parameter can be one of the following values:
  2932. * @arg @ref LL_ADC_DMA_REG_REGULAR_DATA
  2933. * @arg @ref LL_ADC_DMA_REG_REGULAR_DATA_MULTI (1)
  2934. *
  2935. * (1) Available on devices with several ADC instances.
  2936. * @retval ADC register address
  2937. */
  2938. #if defined(ADC_MULTIMODE_SUPPORT)
  2939. __STATIC_INLINE uint32_t LL_ADC_DMA_GetRegAddr(const ADC_TypeDef *ADCx, uint32_t Register)
  2940. {
  2941. uint32_t data_reg_addr;
  2942. if (Register == LL_ADC_DMA_REG_REGULAR_DATA)
  2943. {
  2944. /* Retrieve address of register DR */
  2945. data_reg_addr = (uint32_t) &(ADCx->DR);
  2946. }
  2947. else /* (Register == LL_ADC_DMA_REG_REGULAR_DATA_MULTI) */
  2948. {
  2949. /* Retrieve address of register CDR */
  2950. data_reg_addr = (uint32_t) &((__LL_ADC_COMMON_INSTANCE(ADCx))->CDR);
  2951. }
  2952. return data_reg_addr;
  2953. }
  2954. #else
  2955. __STATIC_INLINE uint32_t LL_ADC_DMA_GetRegAddr(const ADC_TypeDef *ADCx, uint32_t Register)
  2956. {
  2957. /* Prevent unused argument(s) compilation warning */
  2958. (void)(Register);
  2959. /* Retrieve address of register DR */
  2960. return (uint32_t) &(ADCx->DR);
  2961. }
  2962. #endif /* ADC_MULTIMODE_SUPPORT */
  2963. /**
  2964. * @}
  2965. */
  2966. /** @defgroup ADC_LL_EF_Configuration_ADC_Common Configuration of ADC hierarchical scope: common to several
  2967. * ADC instances
  2968. * @{
  2969. */
  2970. /**
  2971. * @brief Set parameter common to several ADC: Clock source and prescaler.
  2972. * @note On this STM32 series, if ADC group injected is used, some
  2973. * clock ratio constraints between ADC clock and AHB clock
  2974. * must be respected.
  2975. * Refer to reference manual.
  2976. * @note On this STM32 series, setting of this feature is conditioned to
  2977. * ADC state:
  2978. * All ADC instances of the ADC common group must be disabled.
  2979. * This check can be done with function @ref LL_ADC_IsEnabled() for each
  2980. * ADC instance or by using helper macro helper macro
  2981. * @ref __LL_ADC_IS_ENABLED_ALL_COMMON_INSTANCE().
  2982. * @rmtoll CCR CKMODE LL_ADC_SetCommonClock\n
  2983. * CCR PRESC LL_ADC_SetCommonClock
  2984. * @param ADCxy_COMMON ADC common instance
  2985. * (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() )
  2986. * @param CommonClock This parameter can be one of the following values:
  2987. * @arg @ref LL_ADC_CLOCK_SYNC_PCLK_DIV1
  2988. * @arg @ref LL_ADC_CLOCK_SYNC_PCLK_DIV2
  2989. * @arg @ref LL_ADC_CLOCK_SYNC_PCLK_DIV4
  2990. * @arg @ref LL_ADC_CLOCK_ASYNC_DIV1
  2991. * @arg @ref LL_ADC_CLOCK_ASYNC_DIV2
  2992. * @arg @ref LL_ADC_CLOCK_ASYNC_DIV4
  2993. * @arg @ref LL_ADC_CLOCK_ASYNC_DIV6
  2994. * @arg @ref LL_ADC_CLOCK_ASYNC_DIV8
  2995. * @arg @ref LL_ADC_CLOCK_ASYNC_DIV10
  2996. * @arg @ref LL_ADC_CLOCK_ASYNC_DIV12
  2997. * @arg @ref LL_ADC_CLOCK_ASYNC_DIV16
  2998. * @arg @ref LL_ADC_CLOCK_ASYNC_DIV32
  2999. * @arg @ref LL_ADC_CLOCK_ASYNC_DIV64
  3000. * @arg @ref LL_ADC_CLOCK_ASYNC_DIV128
  3001. * @arg @ref LL_ADC_CLOCK_ASYNC_DIV256
  3002. * @retval None
  3003. */
  3004. __STATIC_INLINE void LL_ADC_SetCommonClock(ADC_Common_TypeDef *ADCxy_COMMON, uint32_t CommonClock)
  3005. {
  3006. MODIFY_REG(ADCxy_COMMON->CCR, ADC_CCR_CKMODE | ADC_CCR_PRESC, CommonClock);
  3007. }
  3008. /**
  3009. * @brief Get parameter common to several ADC: Clock source and prescaler.
  3010. * @rmtoll CCR CKMODE LL_ADC_GetCommonClock\n
  3011. * CCR PRESC LL_ADC_GetCommonClock
  3012. * @param ADCxy_COMMON ADC common instance
  3013. * (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() )
  3014. * @retval Returned value can be one of the following values:
  3015. * @arg @ref LL_ADC_CLOCK_SYNC_PCLK_DIV1
  3016. * @arg @ref LL_ADC_CLOCK_SYNC_PCLK_DIV2
  3017. * @arg @ref LL_ADC_CLOCK_SYNC_PCLK_DIV4
  3018. * @arg @ref LL_ADC_CLOCK_ASYNC_DIV1
  3019. * @arg @ref LL_ADC_CLOCK_ASYNC_DIV2
  3020. * @arg @ref LL_ADC_CLOCK_ASYNC_DIV4
  3021. * @arg @ref LL_ADC_CLOCK_ASYNC_DIV6
  3022. * @arg @ref LL_ADC_CLOCK_ASYNC_DIV8
  3023. * @arg @ref LL_ADC_CLOCK_ASYNC_DIV10
  3024. * @arg @ref LL_ADC_CLOCK_ASYNC_DIV12
  3025. * @arg @ref LL_ADC_CLOCK_ASYNC_DIV16
  3026. * @arg @ref LL_ADC_CLOCK_ASYNC_DIV32
  3027. * @arg @ref LL_ADC_CLOCK_ASYNC_DIV64
  3028. * @arg @ref LL_ADC_CLOCK_ASYNC_DIV128
  3029. * @arg @ref LL_ADC_CLOCK_ASYNC_DIV256
  3030. */
  3031. __STATIC_INLINE uint32_t LL_ADC_GetCommonClock(const ADC_Common_TypeDef *ADCxy_COMMON)
  3032. {
  3033. return (uint32_t)(READ_BIT(ADCxy_COMMON->CCR, ADC_CCR_CKMODE | ADC_CCR_PRESC));
  3034. }
  3035. /**
  3036. * @brief Set parameter common to several ADC: measurement path to
  3037. * internal channels (VrefInt, temperature sensor, ...).
  3038. * Configure all paths (overwrite current configuration).
  3039. * @note One or several values can be selected.
  3040. * Example: (LL_ADC_PATH_INTERNAL_VREFINT |
  3041. * LL_ADC_PATH_INTERNAL_TEMPSENSOR)
  3042. * The values not selected are removed from configuration.
  3043. * @note Stabilization time of measurement path to internal channel:
  3044. * After enabling internal paths, before starting ADC conversion,
  3045. * a delay is required for internal voltage reference and
  3046. * temperature sensor stabilization time.
  3047. * Refer to device datasheet.
  3048. * Refer to literal @ref LL_ADC_DELAY_VREFINT_STAB_US.
  3049. * Refer to literals @ref LL_ADC_DELAY_TEMPSENSOR_STAB_US,
  3050. * @ref LL_ADC_DELAY_TEMPSENSOR_BUFFER_STAB_US.
  3051. * @note ADC internal channel sampling time constraint:
  3052. * For ADC conversion of internal channels,
  3053. * a sampling time minimum value is required.
  3054. * Refer to device datasheet.
  3055. * @rmtoll CCR VREFEN LL_ADC_SetCommonPathInternalCh\n
  3056. * CCR TSEN LL_ADC_SetCommonPathInternalCh\n
  3057. * CCR VBATEN LL_ADC_SetCommonPathInternalCh
  3058. * @param ADCxy_COMMON ADC common instance
  3059. * (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() )
  3060. * @param PathInternal This parameter can be a combination of the following values:
  3061. * @arg @ref LL_ADC_PATH_INTERNAL_NONE
  3062. * @arg @ref LL_ADC_PATH_INTERNAL_VREFINT
  3063. * @arg @ref LL_ADC_PATH_INTERNAL_TEMPSENSOR
  3064. * @arg @ref LL_ADC_PATH_INTERNAL_VBAT
  3065. * @retval None
  3066. */
  3067. __STATIC_INLINE void LL_ADC_SetCommonPathInternalCh(ADC_Common_TypeDef *ADCxy_COMMON, uint32_t PathInternal)
  3068. {
  3069. MODIFY_REG(ADCxy_COMMON->CCR, ADC_CCR_VREFEN | ADC_CCR_TSEN | ADC_CCR_VBATEN, PathInternal);
  3070. }
  3071. /**
  3072. * @brief Set parameter common to several ADC: measurement path to
  3073. * internal channels (VrefInt, temperature sensor, ...).
  3074. * Add paths to the current configuration.
  3075. * @note One or several values can be selected.
  3076. * Example: (LL_ADC_PATH_INTERNAL_VREFINT |
  3077. * LL_ADC_PATH_INTERNAL_TEMPSENSOR)
  3078. * @note Stabilization time of measurement path to internal channel:
  3079. * After enabling internal paths, before starting ADC conversion,
  3080. * a delay is required for internal voltage reference and
  3081. * temperature sensor stabilization time.
  3082. * Refer to device datasheet.
  3083. * Refer to literal @ref LL_ADC_DELAY_VREFINT_STAB_US.
  3084. * Refer to literals @ref LL_ADC_DELAY_TEMPSENSOR_STAB_US,
  3085. * @ref LL_ADC_DELAY_TEMPSENSOR_BUFFER_STAB_US.
  3086. * @note ADC internal channel sampling time constraint:
  3087. * For ADC conversion of internal channels,
  3088. * a sampling time minimum value is required.
  3089. * Refer to device datasheet.
  3090. * @rmtoll CCR VREFEN LL_ADC_SetCommonPathInternalChAdd\n
  3091. * CCR TSEN LL_ADC_SetCommonPathInternalChAdd\n
  3092. * CCR VBATEN LL_ADC_SetCommonPathInternalChAdd
  3093. * @param ADCxy_COMMON ADC common instance
  3094. * (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() )
  3095. * @param PathInternal This parameter can be a combination of the following values:
  3096. * @arg @ref LL_ADC_PATH_INTERNAL_NONE
  3097. * @arg @ref LL_ADC_PATH_INTERNAL_VREFINT
  3098. * @arg @ref LL_ADC_PATH_INTERNAL_TEMPSENSOR
  3099. * @arg @ref LL_ADC_PATH_INTERNAL_VBAT
  3100. * @retval None
  3101. */
  3102. __STATIC_INLINE void LL_ADC_SetCommonPathInternalChAdd(ADC_Common_TypeDef *ADCxy_COMMON, uint32_t PathInternal)
  3103. {
  3104. SET_BIT(ADCxy_COMMON->CCR, PathInternal);
  3105. }
  3106. /**
  3107. * @brief Set parameter common to several ADC: measurement path to
  3108. * internal channels (VrefInt, temperature sensor, ...).
  3109. * Remove paths to the current configuration.
  3110. * @note One or several values can be selected.
  3111. * Example: (LL_ADC_PATH_INTERNAL_VREFINT |
  3112. * LL_ADC_PATH_INTERNAL_TEMPSENSOR)
  3113. * @rmtoll CCR VREFEN LL_ADC_SetCommonPathInternalChRem\n
  3114. * CCR TSEN LL_ADC_SetCommonPathInternalChRem\n
  3115. * CCR VBATEN LL_ADC_SetCommonPathInternalChRem
  3116. * @param ADCxy_COMMON ADC common instance
  3117. * (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() )
  3118. * @param PathInternal This parameter can be a combination of the following values:
  3119. * @arg @ref LL_ADC_PATH_INTERNAL_NONE
  3120. * @arg @ref LL_ADC_PATH_INTERNAL_VREFINT
  3121. * @arg @ref LL_ADC_PATH_INTERNAL_TEMPSENSOR
  3122. * @arg @ref LL_ADC_PATH_INTERNAL_VBAT
  3123. * @retval None
  3124. */
  3125. __STATIC_INLINE void LL_ADC_SetCommonPathInternalChRem(ADC_Common_TypeDef *ADCxy_COMMON, uint32_t PathInternal)
  3126. {
  3127. CLEAR_BIT(ADCxy_COMMON->CCR, PathInternal);
  3128. }
  3129. /**
  3130. * @brief Get parameter common to several ADC: measurement path to internal
  3131. * channels (VrefInt, temperature sensor, ...).
  3132. * @note One or several values can be selected.
  3133. * Example: (LL_ADC_PATH_INTERNAL_VREFINT |
  3134. * LL_ADC_PATH_INTERNAL_TEMPSENSOR)
  3135. * @rmtoll CCR VREFEN LL_ADC_GetCommonPathInternalCh\n
  3136. * CCR TSEN LL_ADC_GetCommonPathInternalCh\n
  3137. * CCR VBATEN LL_ADC_GetCommonPathInternalCh
  3138. * @param ADCxy_COMMON ADC common instance
  3139. * (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() )
  3140. * @retval Returned value can be a combination of the following values:
  3141. * @arg @ref LL_ADC_PATH_INTERNAL_NONE
  3142. * @arg @ref LL_ADC_PATH_INTERNAL_VREFINT
  3143. * @arg @ref LL_ADC_PATH_INTERNAL_TEMPSENSOR
  3144. * @arg @ref LL_ADC_PATH_INTERNAL_VBAT
  3145. */
  3146. __STATIC_INLINE uint32_t LL_ADC_GetCommonPathInternalCh(const ADC_Common_TypeDef *ADCxy_COMMON)
  3147. {
  3148. return (uint32_t)(READ_BIT(ADCxy_COMMON->CCR, ADC_CCR_VREFEN | ADC_CCR_TSEN | ADC_CCR_VBATEN));
  3149. }
  3150. /**
  3151. * @}
  3152. */
  3153. /** @defgroup ADC_LL_EF_Configuration_ADC_Instance Configuration of ADC hierarchical scope: ADC instance
  3154. * @{
  3155. */
  3156. /**
  3157. * @brief Set ADC calibration factor in the mode single-ended
  3158. * or differential (for devices with differential mode available).
  3159. * @note This function is intended to set calibration parameters
  3160. * without having to perform a new calibration using
  3161. * @ref LL_ADC_StartCalibration().
  3162. * @note For devices with differential mode available:
  3163. * Calibration of offset is specific to each of
  3164. * single-ended and differential modes
  3165. * (calibration factor must be specified for each of these
  3166. * differential modes, if used afterwards and if the application
  3167. * requires their calibration).
  3168. * @note In case of setting calibration factors of both modes single ended
  3169. * and differential (parameter LL_ADC_BOTH_SINGLE_DIFF_ENDED):
  3170. * both calibration factors must be concatenated.
  3171. * To perform this processing, use helper macro
  3172. * @ref __LL_ADC_CALIB_FACTOR_SINGLE_DIFF().
  3173. * @note On this STM32 series, setting of this feature is conditioned to
  3174. * ADC state:
  3175. * ADC must be enabled, without calibration on going, without conversion
  3176. * on going on group regular.
  3177. * @rmtoll CALFACT CALFACT_S LL_ADC_SetCalibrationFactor\n
  3178. * CALFACT CALFACT_D LL_ADC_SetCalibrationFactor
  3179. * @param ADCx ADC instance
  3180. * @param SingleDiff This parameter can be one of the following values:
  3181. * @arg @ref LL_ADC_SINGLE_ENDED
  3182. * @arg @ref LL_ADC_DIFFERENTIAL_ENDED
  3183. * @arg @ref LL_ADC_BOTH_SINGLE_DIFF_ENDED
  3184. * @param CalibrationFactor Value between Min_Data=0x00 and Max_Data=0x7F
  3185. * @retval None
  3186. */
  3187. __STATIC_INLINE void LL_ADC_SetCalibrationFactor(ADC_TypeDef *ADCx, uint32_t SingleDiff, uint32_t CalibrationFactor)
  3188. {
  3189. MODIFY_REG(ADCx->CALFACT,
  3190. SingleDiff & ADC_SINGLEDIFF_CALIB_FACTOR_MASK,
  3191. CalibrationFactor << (((SingleDiff & ADC_SINGLEDIFF_CALIB_F_BIT_D_MASK)
  3192. >> ADC_SINGLEDIFF_CALIB_F_BIT_D_SHIFT4)
  3193. & ~(SingleDiff & ADC_CALFACT_CALFACT_S)));
  3194. }
  3195. /**
  3196. * @brief Get ADC calibration factor in the mode single-ended
  3197. * or differential (for devices with differential mode available).
  3198. * @note Calibration factors are set by hardware after performing
  3199. * a calibration run using function @ref LL_ADC_StartCalibration().
  3200. * @note For devices with differential mode available:
  3201. * Calibration of offset is specific to each of
  3202. * single-ended and differential modes
  3203. * @rmtoll CALFACT CALFACT_S LL_ADC_GetCalibrationFactor\n
  3204. * CALFACT CALFACT_D LL_ADC_GetCalibrationFactor
  3205. * @param ADCx ADC instance
  3206. * @param SingleDiff This parameter can be one of the following values:
  3207. * @arg @ref LL_ADC_SINGLE_ENDED
  3208. * @arg @ref LL_ADC_DIFFERENTIAL_ENDED
  3209. * @retval Value between Min_Data=0x00 and Max_Data=0x7F
  3210. */
  3211. __STATIC_INLINE uint32_t LL_ADC_GetCalibrationFactor(const ADC_TypeDef *ADCx, uint32_t SingleDiff)
  3212. {
  3213. /* Retrieve bits with position in register depending on parameter */
  3214. /* "SingleDiff". */
  3215. /* Parameter used with mask "ADC_SINGLEDIFF_CALIB_FACTOR_MASK" because */
  3216. /* containing other bits reserved for other purpose. */
  3217. return (uint32_t)(READ_BIT(ADCx->CALFACT,
  3218. (SingleDiff & ADC_SINGLEDIFF_CALIB_FACTOR_MASK))
  3219. >> ((SingleDiff & ADC_SINGLEDIFF_CALIB_F_BIT_D_MASK) >>
  3220. ADC_SINGLEDIFF_CALIB_F_BIT_D_SHIFT4));
  3221. }
  3222. /**
  3223. * @brief Set ADC resolution.
  3224. * Refer to reference manual for alignments formats
  3225. * dependencies to ADC resolutions.
  3226. * @note On this STM32 series, setting of this feature is conditioned to
  3227. * ADC state:
  3228. * ADC must be disabled or enabled without conversion on going
  3229. * on either groups regular or injected.
  3230. * @rmtoll CFGR RES LL_ADC_SetResolution
  3231. * @param ADCx ADC instance
  3232. * @param Resolution This parameter can be one of the following values:
  3233. * @arg @ref LL_ADC_RESOLUTION_12B
  3234. * @arg @ref LL_ADC_RESOLUTION_10B
  3235. * @arg @ref LL_ADC_RESOLUTION_8B
  3236. * @arg @ref LL_ADC_RESOLUTION_6B
  3237. * @retval None
  3238. */
  3239. __STATIC_INLINE void LL_ADC_SetResolution(ADC_TypeDef *ADCx, uint32_t Resolution)
  3240. {
  3241. MODIFY_REG(ADCx->CFGR, ADC_CFGR_RES, Resolution);
  3242. }
  3243. /**
  3244. * @brief Get ADC resolution.
  3245. * Refer to reference manual for alignments formats
  3246. * dependencies to ADC resolutions.
  3247. * @rmtoll CFGR RES LL_ADC_GetResolution
  3248. * @param ADCx ADC instance
  3249. * @retval Returned value can be one of the following values:
  3250. * @arg @ref LL_ADC_RESOLUTION_12B
  3251. * @arg @ref LL_ADC_RESOLUTION_10B
  3252. * @arg @ref LL_ADC_RESOLUTION_8B
  3253. * @arg @ref LL_ADC_RESOLUTION_6B
  3254. */
  3255. __STATIC_INLINE uint32_t LL_ADC_GetResolution(const ADC_TypeDef *ADCx)
  3256. {
  3257. return (uint32_t)(READ_BIT(ADCx->CFGR, ADC_CFGR_RES));
  3258. }
  3259. /**
  3260. * @brief Set ADC conversion data alignment.
  3261. * @note Refer to reference manual for alignments formats
  3262. * dependencies to ADC resolutions.
  3263. * @note On this STM32 series, setting of this feature is conditioned to
  3264. * ADC state:
  3265. * ADC must be disabled or enabled without conversion on going
  3266. * on either groups regular or injected.
  3267. * @rmtoll CFGR ALIGN LL_ADC_SetDataAlignment
  3268. * @param ADCx ADC instance
  3269. * @param DataAlignment This parameter can be one of the following values:
  3270. * @arg @ref LL_ADC_DATA_ALIGN_RIGHT
  3271. * @arg @ref LL_ADC_DATA_ALIGN_LEFT
  3272. * @retval None
  3273. */
  3274. __STATIC_INLINE void LL_ADC_SetDataAlignment(ADC_TypeDef *ADCx, uint32_t DataAlignment)
  3275. {
  3276. MODIFY_REG(ADCx->CFGR, ADC_CFGR_ALIGN, DataAlignment);
  3277. }
  3278. /**
  3279. * @brief Get ADC conversion data alignment.
  3280. * @note Refer to reference manual for alignments formats
  3281. * dependencies to ADC resolutions.
  3282. * @rmtoll CFGR ALIGN LL_ADC_GetDataAlignment
  3283. * @param ADCx ADC instance
  3284. * @retval Returned value can be one of the following values:
  3285. * @arg @ref LL_ADC_DATA_ALIGN_RIGHT
  3286. * @arg @ref LL_ADC_DATA_ALIGN_LEFT
  3287. */
  3288. __STATIC_INLINE uint32_t LL_ADC_GetDataAlignment(const ADC_TypeDef *ADCx)
  3289. {
  3290. return (uint32_t)(READ_BIT(ADCx->CFGR, ADC_CFGR_ALIGN));
  3291. }
  3292. /**
  3293. * @brief Set ADC low power mode.
  3294. * @note Description of ADC low power modes:
  3295. * - ADC low power mode "auto wait": Dynamic low power mode,
  3296. * ADC conversions occurrences are limited to the minimum necessary
  3297. * in order to reduce power consumption.
  3298. * New ADC conversion starts only when the previous
  3299. * unitary conversion data (for ADC group regular)
  3300. * or previous sequence conversions data (for ADC group injected)
  3301. * has been retrieved by user software.
  3302. * In the meantime, ADC remains idle: does not performs any
  3303. * other conversion.
  3304. * This mode allows to automatically adapt the ADC conversions
  3305. * triggers to the speed of the software that reads the data.
  3306. * Moreover, this avoids risk of overrun for low frequency
  3307. * applications.
  3308. * How to use this low power mode:
  3309. * - It is not recommended to use with interruption or DMA
  3310. * since these modes have to clear immediately the EOC flag
  3311. * (by CPU to free the IRQ pending event or by DMA).
  3312. * Auto wait will work but fort a very short time, discarding
  3313. * its intended benefit (except specific case of high load of CPU
  3314. * or DMA transfers which can justify usage of auto wait).
  3315. * - Do use with polling: 1. Start conversion,
  3316. * 2. Later on, when conversion data is needed: poll for end of
  3317. * conversion to ensure that conversion is completed and
  3318. * retrieve ADC conversion data. This will trig another
  3319. * ADC conversion start.
  3320. * @note With ADC low power mode "auto wait", the ADC conversion data read
  3321. * is corresponding to previous ADC conversion start, independently
  3322. * of delay during which ADC was idle.
  3323. * Therefore, the ADC conversion data may be outdated: does not
  3324. * correspond to the current voltage level on the selected
  3325. * ADC channel.
  3326. * @note On this STM32 series, setting of this feature is conditioned to
  3327. * ADC state:
  3328. * ADC must be disabled or enabled without conversion on going
  3329. * on either groups regular or injected.
  3330. * @rmtoll CFGR AUTDLY LL_ADC_SetLowPowerMode
  3331. * @param ADCx ADC instance
  3332. * @param LowPowerMode This parameter can be one of the following values:
  3333. * @arg @ref LL_ADC_LP_MODE_NONE
  3334. * @arg @ref LL_ADC_LP_AUTOWAIT
  3335. * @retval None
  3336. */
  3337. __STATIC_INLINE void LL_ADC_SetLowPowerMode(ADC_TypeDef *ADCx, uint32_t LowPowerMode)
  3338. {
  3339. MODIFY_REG(ADCx->CFGR, ADC_CFGR_AUTDLY, LowPowerMode);
  3340. }
  3341. /**
  3342. * @brief Get ADC low power mode:
  3343. * @note Description of ADC low power modes:
  3344. * - ADC low power mode "auto wait": Dynamic low power mode,
  3345. * ADC conversions occurrences are limited to the minimum necessary
  3346. * in order to reduce power consumption.
  3347. * New ADC conversion starts only when the previous
  3348. * unitary conversion data (for ADC group regular)
  3349. * or previous sequence conversions data (for ADC group injected)
  3350. * has been retrieved by user software.
  3351. * In the meantime, ADC remains idle: does not performs any
  3352. * other conversion.
  3353. * This mode allows to automatically adapt the ADC conversions
  3354. * triggers to the speed of the software that reads the data.
  3355. * Moreover, this avoids risk of overrun for low frequency
  3356. * applications.
  3357. * How to use this low power mode:
  3358. * - It is not recommended to use with interruption or DMA
  3359. * since these modes have to clear immediately the EOC flag
  3360. * (by CPU to free the IRQ pending event or by DMA).
  3361. * Auto wait will work but fort a very short time, discarding
  3362. * its intended benefit (except specific case of high load of CPU
  3363. * or DMA transfers which can justify usage of auto wait).
  3364. * - Do use with polling: 1. Start conversion,
  3365. * 2. Later on, when conversion data is needed: poll for end of
  3366. * conversion to ensure that conversion is completed and
  3367. * retrieve ADC conversion data. This will trig another
  3368. * ADC conversion start.
  3369. * @note With ADC low power mode "auto wait", the ADC conversion data read
  3370. * is corresponding to previous ADC conversion start, independently
  3371. * of delay during which ADC was idle.
  3372. * Therefore, the ADC conversion data may be outdated: does not
  3373. * correspond to the current voltage level on the selected
  3374. * ADC channel.
  3375. * @rmtoll CFGR AUTDLY LL_ADC_GetLowPowerMode
  3376. * @param ADCx ADC instance
  3377. * @retval Returned value can be one of the following values:
  3378. * @arg @ref LL_ADC_LP_MODE_NONE
  3379. * @arg @ref LL_ADC_LP_AUTOWAIT
  3380. */
  3381. __STATIC_INLINE uint32_t LL_ADC_GetLowPowerMode(const ADC_TypeDef *ADCx)
  3382. {
  3383. return (uint32_t)(READ_BIT(ADCx->CFGR, ADC_CFGR_AUTDLY));
  3384. }
  3385. /**
  3386. * @brief Set ADC selected offset instance 1, 2, 3 or 4.
  3387. * @note This function set the 2 items of offset configuration:
  3388. * - ADC channel to which the offset programmed will be applied
  3389. * (independently of channel mapped on ADC group regular
  3390. * or group injected)
  3391. * - Offset level (offset to be subtracted from the raw
  3392. * converted data).
  3393. * @note Caution: Offset format is dependent to ADC resolution:
  3394. * offset has to be left-aligned on bit 11, the LSB (right bits)
  3395. * are set to 0.
  3396. * @note This function enables the offset, by default. It can be forced
  3397. * to disable state using function LL_ADC_SetOffsetState().
  3398. * @note If a channel is mapped on several offsets numbers, only the offset
  3399. * with the lowest value is considered for the subtraction.
  3400. * @note On this STM32 series, setting of this feature is conditioned to
  3401. * ADC state:
  3402. * ADC must be disabled or enabled without conversion on going
  3403. * on either groups regular or injected.
  3404. * @note On STM32L4, some fast channels are available: fast analog inputs
  3405. * coming from GPIO pads (ADC_IN1..5).
  3406. * @rmtoll OFR1 OFFSET1_CH LL_ADC_SetOffset\n
  3407. * OFR1 OFFSET1 LL_ADC_SetOffset\n
  3408. * OFR1 OFFSET1_EN LL_ADC_SetOffset\n
  3409. * OFR2 OFFSET2_CH LL_ADC_SetOffset\n
  3410. * OFR2 OFFSET2 LL_ADC_SetOffset\n
  3411. * OFR2 OFFSET2_EN LL_ADC_SetOffset\n
  3412. * OFR3 OFFSET3_CH LL_ADC_SetOffset\n
  3413. * OFR3 OFFSET3 LL_ADC_SetOffset\n
  3414. * OFR3 OFFSET3_EN LL_ADC_SetOffset\n
  3415. * OFR4 OFFSET4_CH LL_ADC_SetOffset\n
  3416. * OFR4 OFFSET4 LL_ADC_SetOffset\n
  3417. * OFR4 OFFSET4_EN LL_ADC_SetOffset
  3418. * @param ADCx ADC instance
  3419. * @param Offsety This parameter can be one of the following values:
  3420. * @arg @ref LL_ADC_OFFSET_1
  3421. * @arg @ref LL_ADC_OFFSET_2
  3422. * @arg @ref LL_ADC_OFFSET_3
  3423. * @arg @ref LL_ADC_OFFSET_4
  3424. * @param Channel This parameter can be one of the following values:
  3425. * @arg @ref LL_ADC_CHANNEL_0
  3426. * @arg @ref LL_ADC_CHANNEL_1 (7)
  3427. * @arg @ref LL_ADC_CHANNEL_2 (7)
  3428. * @arg @ref LL_ADC_CHANNEL_3 (7)
  3429. * @arg @ref LL_ADC_CHANNEL_4 (7)
  3430. * @arg @ref LL_ADC_CHANNEL_5 (7)
  3431. * @arg @ref LL_ADC_CHANNEL_6
  3432. * @arg @ref LL_ADC_CHANNEL_7
  3433. * @arg @ref LL_ADC_CHANNEL_8
  3434. * @arg @ref LL_ADC_CHANNEL_9
  3435. * @arg @ref LL_ADC_CHANNEL_10
  3436. * @arg @ref LL_ADC_CHANNEL_11
  3437. * @arg @ref LL_ADC_CHANNEL_12
  3438. * @arg @ref LL_ADC_CHANNEL_13
  3439. * @arg @ref LL_ADC_CHANNEL_14
  3440. * @arg @ref LL_ADC_CHANNEL_15
  3441. * @arg @ref LL_ADC_CHANNEL_16
  3442. * @arg @ref LL_ADC_CHANNEL_17
  3443. * @arg @ref LL_ADC_CHANNEL_18
  3444. * @arg @ref LL_ADC_CHANNEL_VREFINT (1)
  3445. * @arg @ref LL_ADC_CHANNEL_TEMPSENSOR (4)
  3446. * @arg @ref LL_ADC_CHANNEL_VBAT (4)
  3447. * @arg @ref LL_ADC_CHANNEL_DAC1CH1 (5)
  3448. * @arg @ref LL_ADC_CHANNEL_DAC1CH2 (5)
  3449. * @arg @ref LL_ADC_CHANNEL_DAC1CH1_ADC2 (2)(6)
  3450. * @arg @ref LL_ADC_CHANNEL_DAC1CH2_ADC2 (2)(6)
  3451. * @arg @ref LL_ADC_CHANNEL_DAC1CH1_ADC3 (3)(6)
  3452. * @arg @ref LL_ADC_CHANNEL_DAC1CH2_ADC3 (3)(6)
  3453. *
  3454. * (1) On STM32L4, parameter available only on ADC instance: ADC1.\n
  3455. * (2) On STM32L4, parameter available only on ADC instance: ADC2.\n
  3456. * (3) On STM32L4, parameter available only on ADC instance: ADC3.\n
  3457. * (4) On STM32L4, parameter available only on ADC instances: ADC1, ADC3.\n
  3458. * (5) On STM32L4, parameter available on devices with only 1 ADC instance.\n
  3459. * (6) On STM32L4, parameter available on devices with several ADC instances.\n
  3460. * (7) On STM32L4, fast channel (0.188 us for 12-bit resolution (ADC conversion rate up to 5.33 Ms/s)).
  3461. * Other channels are slow channels (0.238 us for 12-bit resolution (ADC conversion rate up to 4.21 Ms/s)).
  3462. * @param OffsetLevel Value between Min_Data=0x000 and Max_Data=0xFFF
  3463. * @retval None
  3464. */
  3465. __STATIC_INLINE void LL_ADC_SetOffset(ADC_TypeDef *ADCx, uint32_t Offsety, uint32_t Channel, uint32_t OffsetLevel)
  3466. {
  3467. __IO uint32_t *preg = __ADC_PTR_REG_OFFSET(ADCx->OFR1, Offsety);
  3468. MODIFY_REG(*preg,
  3469. ADC_OFR1_OFFSET1_EN | ADC_OFR1_OFFSET1_CH | ADC_OFR1_OFFSET1,
  3470. ADC_OFR1_OFFSET1_EN | (Channel & ADC_CHANNEL_ID_NUMBER_MASK) | OffsetLevel);
  3471. }
  3472. /**
  3473. * @brief Get for the ADC selected offset instance 1, 2, 3 or 4:
  3474. * Channel to which the offset programmed will be applied
  3475. * (independently of channel mapped on ADC group regular
  3476. * or group injected)
  3477. * @note Usage of the returned channel number:
  3478. * - To reinject this channel into another function LL_ADC_xxx:
  3479. * the returned channel number is only partly formatted on definition
  3480. * of literals LL_ADC_CHANNEL_x. Therefore, it has to be compared
  3481. * with parts of literals LL_ADC_CHANNEL_x or using
  3482. * helper macro @ref __LL_ADC_CHANNEL_TO_DECIMAL_NB().
  3483. * Then the selected literal LL_ADC_CHANNEL_x can be used
  3484. * as parameter for another function.
  3485. * - To get the channel number in decimal format:
  3486. * process the returned value with the helper macro
  3487. * @ref __LL_ADC_CHANNEL_TO_DECIMAL_NB().
  3488. * @note On STM32L4, some fast channels are available: fast analog inputs
  3489. * coming from GPIO pads (ADC_IN1..5).
  3490. * @rmtoll OFR1 OFFSET1_CH LL_ADC_GetOffsetChannel\n
  3491. * OFR2 OFFSET2_CH LL_ADC_GetOffsetChannel\n
  3492. * OFR3 OFFSET3_CH LL_ADC_GetOffsetChannel\n
  3493. * OFR4 OFFSET4_CH LL_ADC_GetOffsetChannel
  3494. * @param ADCx ADC instance
  3495. * @param Offsety This parameter can be one of the following values:
  3496. * @arg @ref LL_ADC_OFFSET_1
  3497. * @arg @ref LL_ADC_OFFSET_2
  3498. * @arg @ref LL_ADC_OFFSET_3
  3499. * @arg @ref LL_ADC_OFFSET_4
  3500. * @retval Returned value can be one of the following values:
  3501. * @arg @ref LL_ADC_CHANNEL_0
  3502. * @arg @ref LL_ADC_CHANNEL_1 (7)
  3503. * @arg @ref LL_ADC_CHANNEL_2 (7)
  3504. * @arg @ref LL_ADC_CHANNEL_3 (7)
  3505. * @arg @ref LL_ADC_CHANNEL_4 (7)
  3506. * @arg @ref LL_ADC_CHANNEL_5 (7)
  3507. * @arg @ref LL_ADC_CHANNEL_6
  3508. * @arg @ref LL_ADC_CHANNEL_7
  3509. * @arg @ref LL_ADC_CHANNEL_8
  3510. * @arg @ref LL_ADC_CHANNEL_9
  3511. * @arg @ref LL_ADC_CHANNEL_10
  3512. * @arg @ref LL_ADC_CHANNEL_11
  3513. * @arg @ref LL_ADC_CHANNEL_12
  3514. * @arg @ref LL_ADC_CHANNEL_13
  3515. * @arg @ref LL_ADC_CHANNEL_14
  3516. * @arg @ref LL_ADC_CHANNEL_15
  3517. * @arg @ref LL_ADC_CHANNEL_16
  3518. * @arg @ref LL_ADC_CHANNEL_17
  3519. * @arg @ref LL_ADC_CHANNEL_18
  3520. * @arg @ref LL_ADC_CHANNEL_VREFINT (1)
  3521. * @arg @ref LL_ADC_CHANNEL_TEMPSENSOR (4)
  3522. * @arg @ref LL_ADC_CHANNEL_VBAT (4)
  3523. * @arg @ref LL_ADC_CHANNEL_DAC1CH1 (5)
  3524. * @arg @ref LL_ADC_CHANNEL_DAC1CH2 (5)
  3525. * @arg @ref LL_ADC_CHANNEL_DAC1CH1_ADC2 (2)(6)
  3526. * @arg @ref LL_ADC_CHANNEL_DAC1CH2_ADC2 (2)(6)
  3527. * @arg @ref LL_ADC_CHANNEL_DAC1CH1_ADC3 (3)(6)
  3528. * @arg @ref LL_ADC_CHANNEL_DAC1CH2_ADC3 (3)(6)
  3529. *
  3530. * (1) On STM32L4, parameter available only on ADC instance: ADC1.\n
  3531. * (2) On STM32L4, parameter available only on ADC instance: ADC2.\n
  3532. * (3) On STM32L4, parameter available only on ADC instance: ADC3.\n
  3533. * (4) On STM32L4, parameter available only on ADC instances: ADC1, ADC3.\n
  3534. * (5) On STM32L4, parameter available on devices with only 1 ADC instance.\n
  3535. * (6) On STM32L4, parameter available on devices with several ADC instances.\n
  3536. * (7) On STM32L4, fast channel (0.188 us for 12-bit resolution (ADC conversion rate up to 5.33 Ms/s)).
  3537. * Other channels are slow channels (0.238 us for 12-bit resolution (ADC conversion rate up to
  3538. * 4.21 Ms/s)).\n
  3539. * (1, 2, 3, 4) For ADC channel read back from ADC register,
  3540. * comparison with internal channel parameter to be done
  3541. * using helper macro @ref __LL_ADC_CHANNEL_INTERNAL_TO_EXTERNAL().
  3542. */
  3543. __STATIC_INLINE uint32_t LL_ADC_GetOffsetChannel(const ADC_TypeDef *ADCx, uint32_t Offsety)
  3544. {
  3545. const __IO uint32_t *preg = __ADC_PTR_REG_OFFSET(ADCx->OFR1, Offsety);
  3546. return (uint32_t) READ_BIT(*preg, ADC_OFR1_OFFSET1_CH);
  3547. }
  3548. /**
  3549. * @brief Get for the ADC selected offset instance 1, 2, 3 or 4:
  3550. * Offset level (offset to be subtracted from the raw
  3551. * converted data).
  3552. * @note Caution: Offset format is dependent to ADC resolution:
  3553. * offset has to be left-aligned on bit 11, the LSB (right bits)
  3554. * are set to 0.
  3555. * @rmtoll OFR1 OFFSET1 LL_ADC_GetOffsetLevel\n
  3556. * OFR2 OFFSET2 LL_ADC_GetOffsetLevel\n
  3557. * OFR3 OFFSET3 LL_ADC_GetOffsetLevel\n
  3558. * OFR4 OFFSET4 LL_ADC_GetOffsetLevel
  3559. * @param ADCx ADC instance
  3560. * @param Offsety This parameter can be one of the following values:
  3561. * @arg @ref LL_ADC_OFFSET_1
  3562. * @arg @ref LL_ADC_OFFSET_2
  3563. * @arg @ref LL_ADC_OFFSET_3
  3564. * @arg @ref LL_ADC_OFFSET_4
  3565. * @retval Value between Min_Data=0x000 and Max_Data=0xFFF
  3566. */
  3567. __STATIC_INLINE uint32_t LL_ADC_GetOffsetLevel(const ADC_TypeDef *ADCx, uint32_t Offsety)
  3568. {
  3569. const __IO uint32_t *preg = __ADC_PTR_REG_OFFSET(ADCx->OFR1, Offsety);
  3570. return (uint32_t) READ_BIT(*preg, ADC_OFR1_OFFSET1);
  3571. }
  3572. /**
  3573. * @brief Set for the ADC selected offset instance 1, 2, 3 or 4:
  3574. * force offset state disable or enable
  3575. * without modifying offset channel or offset value.
  3576. * @note This function should be needed only in case of offset to be
  3577. * enabled-disabled dynamically, and should not be needed in other cases:
  3578. * function LL_ADC_SetOffset() automatically enables the offset.
  3579. * @note On this STM32 series, setting of this feature is conditioned to
  3580. * ADC state:
  3581. * ADC must be disabled or enabled without conversion on going
  3582. * on either groups regular or injected.
  3583. * @rmtoll OFR1 OFFSET1_EN LL_ADC_SetOffsetState\n
  3584. * OFR2 OFFSET2_EN LL_ADC_SetOffsetState\n
  3585. * OFR3 OFFSET3_EN LL_ADC_SetOffsetState\n
  3586. * OFR4 OFFSET4_EN LL_ADC_SetOffsetState
  3587. * @param ADCx ADC instance
  3588. * @param Offsety This parameter can be one of the following values:
  3589. * @arg @ref LL_ADC_OFFSET_1
  3590. * @arg @ref LL_ADC_OFFSET_2
  3591. * @arg @ref LL_ADC_OFFSET_3
  3592. * @arg @ref LL_ADC_OFFSET_4
  3593. * @param OffsetState This parameter can be one of the following values:
  3594. * @arg @ref LL_ADC_OFFSET_DISABLE
  3595. * @arg @ref LL_ADC_OFFSET_ENABLE
  3596. * @retval None
  3597. */
  3598. __STATIC_INLINE void LL_ADC_SetOffsetState(ADC_TypeDef *ADCx, uint32_t Offsety, uint32_t OffsetState)
  3599. {
  3600. __IO uint32_t *preg = __ADC_PTR_REG_OFFSET(ADCx->OFR1, Offsety);
  3601. MODIFY_REG(*preg,
  3602. ADC_OFR1_OFFSET1_EN,
  3603. OffsetState);
  3604. }
  3605. /**
  3606. * @brief Get for the ADC selected offset instance 1, 2, 3 or 4:
  3607. * offset state disabled or enabled.
  3608. * @rmtoll OFR1 OFFSET1_EN LL_ADC_GetOffsetState\n
  3609. * OFR2 OFFSET2_EN LL_ADC_GetOffsetState\n
  3610. * OFR3 OFFSET3_EN LL_ADC_GetOffsetState\n
  3611. * OFR4 OFFSET4_EN LL_ADC_GetOffsetState
  3612. * @param ADCx ADC instance
  3613. * @param Offsety This parameter can be one of the following values:
  3614. * @arg @ref LL_ADC_OFFSET_1
  3615. * @arg @ref LL_ADC_OFFSET_2
  3616. * @arg @ref LL_ADC_OFFSET_3
  3617. * @arg @ref LL_ADC_OFFSET_4
  3618. * @retval Returned value can be one of the following values:
  3619. * @arg @ref LL_ADC_OFFSET_DISABLE
  3620. * @arg @ref LL_ADC_OFFSET_ENABLE
  3621. */
  3622. __STATIC_INLINE uint32_t LL_ADC_GetOffsetState(const ADC_TypeDef *ADCx, uint32_t Offsety)
  3623. {
  3624. const __IO uint32_t *preg = __ADC_PTR_REG_OFFSET(ADCx->OFR1, Offsety);
  3625. return (uint32_t) READ_BIT(*preg, ADC_OFR1_OFFSET1_EN);
  3626. }
  3627. #if defined(ADC_SMPR1_SMPPLUS)
  3628. /**
  3629. * @brief Set ADC sampling time common configuration impacting
  3630. * settings of sampling time channel wise.
  3631. * @note On this STM32 series, setting of this feature is conditioned to
  3632. * ADC state:
  3633. * ADC must be disabled or enabled without conversion on going
  3634. * on either groups regular or injected.
  3635. * @rmtoll SMPR1 SMPPLUS LL_ADC_SetSamplingTimeCommonConfig
  3636. * @param ADCx ADC instance
  3637. * @param SamplingTimeCommonConfig This parameter can be one of the following values:
  3638. * @arg @ref LL_ADC_SAMPLINGTIME_COMMON_DEFAULT
  3639. * @arg @ref LL_ADC_SAMPLINGTIME_COMMON_3C5_REPL_2C5
  3640. * @retval None
  3641. */
  3642. __STATIC_INLINE void LL_ADC_SetSamplingTimeCommonConfig(ADC_TypeDef *ADCx, uint32_t SamplingTimeCommonConfig)
  3643. {
  3644. MODIFY_REG(ADCx->SMPR1, ADC_SMPR1_SMPPLUS, SamplingTimeCommonConfig);
  3645. }
  3646. /**
  3647. * @brief Get ADC sampling time common configuration impacting
  3648. * settings of sampling time channel wise.
  3649. * @rmtoll SMPR1 SMPPLUS LL_ADC_GetSamplingTimeCommonConfig
  3650. * @param ADCx ADC instance
  3651. * @retval Returned value can be one of the following values:
  3652. * @arg @ref LL_ADC_SAMPLINGTIME_COMMON_DEFAULT
  3653. * @arg @ref LL_ADC_SAMPLINGTIME_COMMON_3C5_REPL_2C5
  3654. */
  3655. __STATIC_INLINE uint32_t LL_ADC_GetSamplingTimeCommonConfig(const ADC_TypeDef *ADCx)
  3656. {
  3657. return (uint32_t)(READ_BIT(ADCx->SMPR1, ADC_SMPR1_SMPPLUS));
  3658. }
  3659. #endif /* ADC_SMPR1_SMPPLUS */
  3660. /**
  3661. * @}
  3662. */
  3663. /** @defgroup ADC_LL_EF_Configuration_ADC_Group_Regular Configuration of ADC hierarchical scope: group regular
  3664. * @{
  3665. */
  3666. /**
  3667. * @brief Set ADC group regular conversion trigger source:
  3668. * internal (SW start) or from external peripheral (timer event,
  3669. * external interrupt line).
  3670. * @note On this STM32 series, setting trigger source to external trigger
  3671. * also set trigger polarity to rising edge
  3672. * (default setting for compatibility with some ADC on other
  3673. * STM32 series having this setting set by HW default value).
  3674. * In case of need to modify trigger edge, use
  3675. * function @ref LL_ADC_REG_SetTriggerEdge().
  3676. * @note Availability of parameters of trigger sources from timer
  3677. * depends on timers availability on the selected device.
  3678. * @note On this STM32 series, setting of this feature is conditioned to
  3679. * ADC state:
  3680. * ADC must be disabled or enabled without conversion on going
  3681. * on group regular.
  3682. * @rmtoll CFGR EXTSEL LL_ADC_REG_SetTriggerSource\n
  3683. * CFGR EXTEN LL_ADC_REG_SetTriggerSource
  3684. * @param ADCx ADC instance
  3685. * @param TriggerSource This parameter can be one of the following values:
  3686. * @arg @ref LL_ADC_REG_TRIG_SOFTWARE
  3687. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM1_TRGO
  3688. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM1_TRGO2
  3689. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM1_CH1
  3690. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM1_CH2
  3691. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM1_CH3
  3692. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM2_TRGO
  3693. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM2_CH2
  3694. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM3_TRGO
  3695. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM3_CH4
  3696. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM4_TRGO
  3697. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM4_CH4
  3698. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM6_TRGO
  3699. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM8_TRGO
  3700. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM8_TRGO2
  3701. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM15_TRGO
  3702. * @arg @ref LL_ADC_REG_TRIG_EXT_EXTI_LINE11
  3703. * @retval None
  3704. */
  3705. __STATIC_INLINE void LL_ADC_REG_SetTriggerSource(ADC_TypeDef *ADCx, uint32_t TriggerSource)
  3706. {
  3707. MODIFY_REG(ADCx->CFGR, ADC_CFGR_EXTEN | ADC_CFGR_EXTSEL, TriggerSource);
  3708. }
  3709. /**
  3710. * @brief Get ADC group regular conversion trigger source:
  3711. * internal (SW start) or from external peripheral (timer event,
  3712. * external interrupt line).
  3713. * @note To determine whether group regular trigger source is
  3714. * internal (SW start) or external, without detail
  3715. * of which peripheral is selected as external trigger,
  3716. * (equivalent to
  3717. * "if(LL_ADC_REG_GetTriggerSource(ADC1) == LL_ADC_REG_TRIG_SOFTWARE)")
  3718. * use function @ref LL_ADC_REG_IsTriggerSourceSWStart.
  3719. * @note Availability of parameters of trigger sources from timer
  3720. * depends on timers availability on the selected device.
  3721. * @rmtoll CFGR EXTSEL LL_ADC_REG_GetTriggerSource\n
  3722. * CFGR EXTEN LL_ADC_REG_GetTriggerSource
  3723. * @param ADCx ADC instance
  3724. * @retval Returned value can be one of the following values:
  3725. * @arg @ref LL_ADC_REG_TRIG_SOFTWARE
  3726. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM1_TRGO
  3727. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM1_TRGO2
  3728. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM1_CH1
  3729. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM1_CH2
  3730. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM1_CH3
  3731. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM2_TRGO
  3732. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM2_CH2
  3733. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM3_TRGO
  3734. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM3_CH4
  3735. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM4_TRGO
  3736. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM4_CH4
  3737. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM6_TRGO
  3738. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM8_TRGO
  3739. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM8_TRGO2
  3740. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM15_TRGO
  3741. * @arg @ref LL_ADC_REG_TRIG_EXT_EXTI_LINE11
  3742. */
  3743. __STATIC_INLINE uint32_t LL_ADC_REG_GetTriggerSource(const ADC_TypeDef *ADCx)
  3744. {
  3745. __IO uint32_t trigger_source = READ_BIT(ADCx->CFGR, ADC_CFGR_EXTSEL | ADC_CFGR_EXTEN);
  3746. /* Value for shift of {0; 4; 8; 12} depending on value of bitfield */
  3747. /* corresponding to ADC_CFGR_EXTEN {0; 1; 2; 3}. */
  3748. uint32_t shift_exten = ((trigger_source & ADC_CFGR_EXTEN) >> (ADC_REG_TRIG_EXTEN_BITOFFSET_POS - 2UL));
  3749. /* Set bitfield corresponding to ADC_CFGR_EXTEN and ADC_CFGR_EXTSEL */
  3750. /* to match with triggers literals definition. */
  3751. return ((trigger_source
  3752. & (ADC_REG_TRIG_SOURCE_MASK >> shift_exten) & ADC_CFGR_EXTSEL)
  3753. | ((ADC_REG_TRIG_EDGE_MASK >> shift_exten) & ADC_CFGR_EXTEN)
  3754. );
  3755. }
  3756. /**
  3757. * @brief Get ADC group regular conversion trigger source internal (SW start)
  3758. * or external.
  3759. * @note In case of group regular trigger source set to external trigger,
  3760. * to determine which peripheral is selected as external trigger,
  3761. * use function @ref LL_ADC_REG_GetTriggerSource().
  3762. * @rmtoll CFGR EXTEN LL_ADC_REG_IsTriggerSourceSWStart
  3763. * @param ADCx ADC instance
  3764. * @retval Value "0" if trigger source external trigger
  3765. * Value "1" if trigger source SW start.
  3766. */
  3767. __STATIC_INLINE uint32_t LL_ADC_REG_IsTriggerSourceSWStart(const ADC_TypeDef *ADCx)
  3768. {
  3769. return ((READ_BIT(ADCx->CFGR, ADC_CFGR_EXTEN) == (LL_ADC_REG_TRIG_SOFTWARE & ADC_CFGR_EXTEN)) ? 1UL : 0UL);
  3770. }
  3771. /**
  3772. * @brief Set ADC group regular conversion trigger polarity.
  3773. * @note Applicable only for trigger source set to external trigger.
  3774. * @note On this STM32 series, setting of this feature is conditioned to
  3775. * ADC state:
  3776. * ADC must be disabled or enabled without conversion on going
  3777. * on group regular.
  3778. * @rmtoll CFGR EXTEN LL_ADC_REG_SetTriggerEdge
  3779. * @param ADCx ADC instance
  3780. * @param ExternalTriggerEdge This parameter can be one of the following values:
  3781. * @arg @ref LL_ADC_REG_TRIG_EXT_RISING
  3782. * @arg @ref LL_ADC_REG_TRIG_EXT_FALLING
  3783. * @arg @ref LL_ADC_REG_TRIG_EXT_RISINGFALLING
  3784. * @retval None
  3785. */
  3786. __STATIC_INLINE void LL_ADC_REG_SetTriggerEdge(ADC_TypeDef *ADCx, uint32_t ExternalTriggerEdge)
  3787. {
  3788. MODIFY_REG(ADCx->CFGR, ADC_CFGR_EXTEN, ExternalTriggerEdge);
  3789. }
  3790. /**
  3791. * @brief Get ADC group regular conversion trigger polarity.
  3792. * @note Applicable only for trigger source set to external trigger.
  3793. * @rmtoll CFGR EXTEN LL_ADC_REG_GetTriggerEdge
  3794. * @param ADCx ADC instance
  3795. * @retval Returned value can be one of the following values:
  3796. * @arg @ref LL_ADC_REG_TRIG_EXT_RISING
  3797. * @arg @ref LL_ADC_REG_TRIG_EXT_FALLING
  3798. * @arg @ref LL_ADC_REG_TRIG_EXT_RISINGFALLING
  3799. */
  3800. __STATIC_INLINE uint32_t LL_ADC_REG_GetTriggerEdge(const ADC_TypeDef *ADCx)
  3801. {
  3802. return (uint32_t)(READ_BIT(ADCx->CFGR, ADC_CFGR_EXTEN));
  3803. }
  3804. /**
  3805. * @brief Set ADC group regular sequencer length and scan direction.
  3806. * @note Description of ADC group regular sequencer features:
  3807. * - For devices with sequencer fully configurable
  3808. * (function "LL_ADC_REG_SetSequencerRanks()" available):
  3809. * sequencer length and each rank affectation to a channel
  3810. * are configurable.
  3811. * This function performs configuration of:
  3812. * - Sequence length: Number of ranks in the scan sequence.
  3813. * - Sequence direction: Unless specified in parameters, sequencer
  3814. * scan direction is forward (from rank 1 to rank n).
  3815. * Sequencer ranks are selected using
  3816. * function "LL_ADC_REG_SetSequencerRanks()".
  3817. * - For devices with sequencer not fully configurable
  3818. * (function "LL_ADC_REG_SetSequencerChannels()" available):
  3819. * sequencer length and each rank affectation to a channel
  3820. * are defined by channel number.
  3821. * This function performs configuration of:
  3822. * - Sequence length: Number of ranks in the scan sequence is
  3823. * defined by number of channels set in the sequence,
  3824. * rank of each channel is fixed by channel HW number.
  3825. * (channel 0 fixed on rank 0, channel 1 fixed on rank1, ...).
  3826. * - Sequence direction: Unless specified in parameters, sequencer
  3827. * scan direction is forward (from lowest channel number to
  3828. * highest channel number).
  3829. * Sequencer ranks are selected using
  3830. * function "LL_ADC_REG_SetSequencerChannels()".
  3831. * @note Sequencer disabled is equivalent to sequencer of 1 rank:
  3832. * ADC conversion on only 1 channel.
  3833. * @note On this STM32 series, setting of this feature is conditioned to
  3834. * ADC state:
  3835. * ADC must be disabled or enabled without conversion on going
  3836. * on group regular.
  3837. * @rmtoll SQR1 L LL_ADC_REG_SetSequencerLength
  3838. * @param ADCx ADC instance
  3839. * @param SequencerNbRanks This parameter can be one of the following values:
  3840. * @arg @ref LL_ADC_REG_SEQ_SCAN_DISABLE
  3841. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_2RANKS
  3842. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_3RANKS
  3843. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_4RANKS
  3844. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_5RANKS
  3845. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_6RANKS
  3846. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_7RANKS
  3847. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_8RANKS
  3848. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_9RANKS
  3849. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_10RANKS
  3850. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_11RANKS
  3851. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_12RANKS
  3852. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_13RANKS
  3853. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_14RANKS
  3854. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_15RANKS
  3855. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_16RANKS
  3856. * @retval None
  3857. */
  3858. __STATIC_INLINE void LL_ADC_REG_SetSequencerLength(ADC_TypeDef *ADCx, uint32_t SequencerNbRanks)
  3859. {
  3860. MODIFY_REG(ADCx->SQR1, ADC_SQR1_L, SequencerNbRanks);
  3861. }
  3862. /**
  3863. * @brief Get ADC group regular sequencer length and scan direction.
  3864. * @note Description of ADC group regular sequencer features:
  3865. * - For devices with sequencer fully configurable
  3866. * (function "LL_ADC_REG_SetSequencerRanks()" available):
  3867. * sequencer length and each rank affectation to a channel
  3868. * are configurable.
  3869. * This function retrieves:
  3870. * - Sequence length: Number of ranks in the scan sequence.
  3871. * - Sequence direction: Unless specified in parameters, sequencer
  3872. * scan direction is forward (from rank 1 to rank n).
  3873. * Sequencer ranks are selected using
  3874. * function "LL_ADC_REG_SetSequencerRanks()".
  3875. * - For devices with sequencer not fully configurable
  3876. * (function "LL_ADC_REG_SetSequencerChannels()" available):
  3877. * sequencer length and each rank affectation to a channel
  3878. * are defined by channel number.
  3879. * This function retrieves:
  3880. * - Sequence length: Number of ranks in the scan sequence is
  3881. * defined by number of channels set in the sequence,
  3882. * rank of each channel is fixed by channel HW number.
  3883. * (channel 0 fixed on rank 0, channel 1 fixed on rank1, ...).
  3884. * - Sequence direction: Unless specified in parameters, sequencer
  3885. * scan direction is forward (from lowest channel number to
  3886. * highest channel number).
  3887. * Sequencer ranks are selected using
  3888. * function "LL_ADC_REG_SetSequencerChannels()".
  3889. * @note Sequencer disabled is equivalent to sequencer of 1 rank:
  3890. * ADC conversion on only 1 channel.
  3891. * @rmtoll SQR1 L LL_ADC_REG_GetSequencerLength
  3892. * @param ADCx ADC instance
  3893. * @retval Returned value can be one of the following values:
  3894. * @arg @ref LL_ADC_REG_SEQ_SCAN_DISABLE
  3895. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_2RANKS
  3896. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_3RANKS
  3897. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_4RANKS
  3898. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_5RANKS
  3899. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_6RANKS
  3900. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_7RANKS
  3901. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_8RANKS
  3902. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_9RANKS
  3903. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_10RANKS
  3904. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_11RANKS
  3905. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_12RANKS
  3906. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_13RANKS
  3907. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_14RANKS
  3908. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_15RANKS
  3909. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_16RANKS
  3910. */
  3911. __STATIC_INLINE uint32_t LL_ADC_REG_GetSequencerLength(const ADC_TypeDef *ADCx)
  3912. {
  3913. return (uint32_t)(READ_BIT(ADCx->SQR1, ADC_SQR1_L));
  3914. }
  3915. /**
  3916. * @brief Set ADC group regular sequencer discontinuous mode:
  3917. * sequence subdivided and scan conversions interrupted every selected
  3918. * number of ranks.
  3919. * @note It is not possible to enable both ADC group regular
  3920. * continuous mode and sequencer discontinuous mode.
  3921. * @note It is not possible to enable both ADC auto-injected mode
  3922. * and ADC group regular sequencer discontinuous mode.
  3923. * @note On this STM32 series, setting of this feature is conditioned to
  3924. * ADC state:
  3925. * ADC must be disabled or enabled without conversion on going
  3926. * on group regular.
  3927. * @rmtoll CFGR DISCEN LL_ADC_REG_SetSequencerDiscont\n
  3928. * CFGR DISCNUM LL_ADC_REG_SetSequencerDiscont
  3929. * @param ADCx ADC instance
  3930. * @param SeqDiscont This parameter can be one of the following values:
  3931. * @arg @ref LL_ADC_REG_SEQ_DISCONT_DISABLE
  3932. * @arg @ref LL_ADC_REG_SEQ_DISCONT_1RANK
  3933. * @arg @ref LL_ADC_REG_SEQ_DISCONT_2RANKS
  3934. * @arg @ref LL_ADC_REG_SEQ_DISCONT_3RANKS
  3935. * @arg @ref LL_ADC_REG_SEQ_DISCONT_4RANKS
  3936. * @arg @ref LL_ADC_REG_SEQ_DISCONT_5RANKS
  3937. * @arg @ref LL_ADC_REG_SEQ_DISCONT_6RANKS
  3938. * @arg @ref LL_ADC_REG_SEQ_DISCONT_7RANKS
  3939. * @arg @ref LL_ADC_REG_SEQ_DISCONT_8RANKS
  3940. * @retval None
  3941. */
  3942. __STATIC_INLINE void LL_ADC_REG_SetSequencerDiscont(ADC_TypeDef *ADCx, uint32_t SeqDiscont)
  3943. {
  3944. MODIFY_REG(ADCx->CFGR, ADC_CFGR_DISCEN | ADC_CFGR_DISCNUM, SeqDiscont);
  3945. }
  3946. /**
  3947. * @brief Get ADC group regular sequencer discontinuous mode:
  3948. * sequence subdivided and scan conversions interrupted every selected
  3949. * number of ranks.
  3950. * @rmtoll CFGR DISCEN LL_ADC_REG_GetSequencerDiscont\n
  3951. * CFGR DISCNUM LL_ADC_REG_GetSequencerDiscont
  3952. * @param ADCx ADC instance
  3953. * @retval Returned value can be one of the following values:
  3954. * @arg @ref LL_ADC_REG_SEQ_DISCONT_DISABLE
  3955. * @arg @ref LL_ADC_REG_SEQ_DISCONT_1RANK
  3956. * @arg @ref LL_ADC_REG_SEQ_DISCONT_2RANKS
  3957. * @arg @ref LL_ADC_REG_SEQ_DISCONT_3RANKS
  3958. * @arg @ref LL_ADC_REG_SEQ_DISCONT_4RANKS
  3959. * @arg @ref LL_ADC_REG_SEQ_DISCONT_5RANKS
  3960. * @arg @ref LL_ADC_REG_SEQ_DISCONT_6RANKS
  3961. * @arg @ref LL_ADC_REG_SEQ_DISCONT_7RANKS
  3962. * @arg @ref LL_ADC_REG_SEQ_DISCONT_8RANKS
  3963. */
  3964. __STATIC_INLINE uint32_t LL_ADC_REG_GetSequencerDiscont(const ADC_TypeDef *ADCx)
  3965. {
  3966. return (uint32_t)(READ_BIT(ADCx->CFGR, ADC_CFGR_DISCEN | ADC_CFGR_DISCNUM));
  3967. }
  3968. /**
  3969. * @brief Set ADC group regular sequence: channel on the selected
  3970. * scan sequence rank.
  3971. * @note This function performs configuration of:
  3972. * - Channels ordering into each rank of scan sequence:
  3973. * whatever channel can be placed into whatever rank.
  3974. * @note On this STM32 series, ADC group regular sequencer is
  3975. * fully configurable: sequencer length and each rank
  3976. * affectation to a channel are configurable.
  3977. * Refer to description of function @ref LL_ADC_REG_SetSequencerLength().
  3978. * @note Depending on devices and packages, some channels may not be available.
  3979. * Refer to device datasheet for channels availability.
  3980. * @note On this STM32 series, to measure internal channels (VrefInt,
  3981. * TempSensor, ...), measurement paths to internal channels must be
  3982. * enabled separately.
  3983. * This can be done using function @ref LL_ADC_SetCommonPathInternalCh().
  3984. * @note On this STM32 series, setting of this feature is conditioned to
  3985. * ADC state:
  3986. * ADC must be disabled or enabled without conversion on going
  3987. * on group regular.
  3988. * @rmtoll SQR1 SQ1 LL_ADC_REG_SetSequencerRanks\n
  3989. * SQR1 SQ2 LL_ADC_REG_SetSequencerRanks\n
  3990. * SQR1 SQ3 LL_ADC_REG_SetSequencerRanks\n
  3991. * SQR1 SQ4 LL_ADC_REG_SetSequencerRanks\n
  3992. * SQR2 SQ5 LL_ADC_REG_SetSequencerRanks\n
  3993. * SQR2 SQ6 LL_ADC_REG_SetSequencerRanks\n
  3994. * SQR2 SQ7 LL_ADC_REG_SetSequencerRanks\n
  3995. * SQR2 SQ8 LL_ADC_REG_SetSequencerRanks\n
  3996. * SQR2 SQ9 LL_ADC_REG_SetSequencerRanks\n
  3997. * SQR3 SQ10 LL_ADC_REG_SetSequencerRanks\n
  3998. * SQR3 SQ11 LL_ADC_REG_SetSequencerRanks\n
  3999. * SQR3 SQ12 LL_ADC_REG_SetSequencerRanks\n
  4000. * SQR3 SQ13 LL_ADC_REG_SetSequencerRanks\n
  4001. * SQR3 SQ14 LL_ADC_REG_SetSequencerRanks\n
  4002. * SQR4 SQ15 LL_ADC_REG_SetSequencerRanks\n
  4003. * SQR4 SQ16 LL_ADC_REG_SetSequencerRanks
  4004. * @param ADCx ADC instance
  4005. * @param Rank This parameter can be one of the following values:
  4006. * @arg @ref LL_ADC_REG_RANK_1
  4007. * @arg @ref LL_ADC_REG_RANK_2
  4008. * @arg @ref LL_ADC_REG_RANK_3
  4009. * @arg @ref LL_ADC_REG_RANK_4
  4010. * @arg @ref LL_ADC_REG_RANK_5
  4011. * @arg @ref LL_ADC_REG_RANK_6
  4012. * @arg @ref LL_ADC_REG_RANK_7
  4013. * @arg @ref LL_ADC_REG_RANK_8
  4014. * @arg @ref LL_ADC_REG_RANK_9
  4015. * @arg @ref LL_ADC_REG_RANK_10
  4016. * @arg @ref LL_ADC_REG_RANK_11
  4017. * @arg @ref LL_ADC_REG_RANK_12
  4018. * @arg @ref LL_ADC_REG_RANK_13
  4019. * @arg @ref LL_ADC_REG_RANK_14
  4020. * @arg @ref LL_ADC_REG_RANK_15
  4021. * @arg @ref LL_ADC_REG_RANK_16
  4022. * @param Channel This parameter can be one of the following values:
  4023. * @arg @ref LL_ADC_CHANNEL_0
  4024. * @arg @ref LL_ADC_CHANNEL_1 (7)
  4025. * @arg @ref LL_ADC_CHANNEL_2 (7)
  4026. * @arg @ref LL_ADC_CHANNEL_3 (7)
  4027. * @arg @ref LL_ADC_CHANNEL_4 (7)
  4028. * @arg @ref LL_ADC_CHANNEL_5 (7)
  4029. * @arg @ref LL_ADC_CHANNEL_6
  4030. * @arg @ref LL_ADC_CHANNEL_7
  4031. * @arg @ref LL_ADC_CHANNEL_8
  4032. * @arg @ref LL_ADC_CHANNEL_9
  4033. * @arg @ref LL_ADC_CHANNEL_10
  4034. * @arg @ref LL_ADC_CHANNEL_11
  4035. * @arg @ref LL_ADC_CHANNEL_12
  4036. * @arg @ref LL_ADC_CHANNEL_13
  4037. * @arg @ref LL_ADC_CHANNEL_14
  4038. * @arg @ref LL_ADC_CHANNEL_15
  4039. * @arg @ref LL_ADC_CHANNEL_16
  4040. * @arg @ref LL_ADC_CHANNEL_17
  4041. * @arg @ref LL_ADC_CHANNEL_18
  4042. * @arg @ref LL_ADC_CHANNEL_VREFINT (1)
  4043. * @arg @ref LL_ADC_CHANNEL_TEMPSENSOR (4)
  4044. * @arg @ref LL_ADC_CHANNEL_VBAT (4)
  4045. * @arg @ref LL_ADC_CHANNEL_DAC1CH1 (5)
  4046. * @arg @ref LL_ADC_CHANNEL_DAC1CH2 (5)
  4047. * @arg @ref LL_ADC_CHANNEL_DAC1CH1_ADC2 (2)(6)
  4048. * @arg @ref LL_ADC_CHANNEL_DAC1CH2_ADC2 (2)(6)
  4049. * @arg @ref LL_ADC_CHANNEL_DAC1CH1_ADC3 (3)(6)
  4050. * @arg @ref LL_ADC_CHANNEL_DAC1CH2_ADC3 (3)(6)
  4051. *
  4052. * (1) On STM32L4, parameter available only on ADC instance: ADC1.\n
  4053. * (2) On STM32L4, parameter available only on ADC instance: ADC2.\n
  4054. * (3) On STM32L4, parameter available only on ADC instance: ADC3.\n
  4055. * (4) On STM32L4, parameter available only on ADC instances: ADC1, ADC3.\n
  4056. * (5) On STM32L4, parameter available on devices with only 1 ADC instance.\n
  4057. * (6) On STM32L4, parameter available on devices with several ADC instances.\n
  4058. * (7) On STM32L4, fast channel (0.188 us for 12-bit resolution (ADC conversion rate up to 5.33 Ms/s)).
  4059. * Other channels are slow channels (0.238 us for 12-bit resolution (ADC conversion rate up to 4.21 Ms/s)).
  4060. * @retval None
  4061. */
  4062. __STATIC_INLINE void LL_ADC_REG_SetSequencerRanks(ADC_TypeDef *ADCx, uint32_t Rank, uint32_t Channel)
  4063. {
  4064. /* Set bits with content of parameter "Channel" with bits position */
  4065. /* in register and register position depending on parameter "Rank". */
  4066. /* Parameters "Rank" and "Channel" are used with masks because containing */
  4067. /* other bits reserved for other purpose. */
  4068. __IO uint32_t *preg = __ADC_PTR_REG_OFFSET(ADCx->SQR1,
  4069. ((Rank & ADC_REG_SQRX_REGOFFSET_MASK) >> ADC_SQRX_REGOFFSET_POS));
  4070. MODIFY_REG(*preg,
  4071. ADC_CHANNEL_ID_NUMBER_MASK_POSBIT0 << (Rank & ADC_REG_RANK_ID_SQRX_MASK),
  4072. ((Channel & ADC_CHANNEL_ID_NUMBER_MASK) >> ADC_CHANNEL_ID_NUMBER_BITOFFSET_POS)
  4073. << (Rank & ADC_REG_RANK_ID_SQRX_MASK));
  4074. }
  4075. /**
  4076. * @brief Get ADC group regular sequence: channel on the selected
  4077. * scan sequence rank.
  4078. * @note On this STM32 series, ADC group regular sequencer is
  4079. * fully configurable: sequencer length and each rank
  4080. * affectation to a channel are configurable.
  4081. * Refer to description of function @ref LL_ADC_REG_SetSequencerLength().
  4082. * @note Depending on devices and packages, some channels may not be available.
  4083. * Refer to device datasheet for channels availability.
  4084. * @note Usage of the returned channel number:
  4085. * - To reinject this channel into another function LL_ADC_xxx:
  4086. * the returned channel number is only partly formatted on definition
  4087. * of literals LL_ADC_CHANNEL_x. Therefore, it has to be compared
  4088. * with parts of literals LL_ADC_CHANNEL_x or using
  4089. * helper macro @ref __LL_ADC_CHANNEL_TO_DECIMAL_NB().
  4090. * Then the selected literal LL_ADC_CHANNEL_x can be used
  4091. * as parameter for another function.
  4092. * - To get the channel number in decimal format:
  4093. * process the returned value with the helper macro
  4094. * @ref __LL_ADC_CHANNEL_TO_DECIMAL_NB().
  4095. * @rmtoll SQR1 SQ1 LL_ADC_REG_GetSequencerRanks\n
  4096. * SQR1 SQ2 LL_ADC_REG_GetSequencerRanks\n
  4097. * SQR1 SQ3 LL_ADC_REG_GetSequencerRanks\n
  4098. * SQR1 SQ4 LL_ADC_REG_GetSequencerRanks\n
  4099. * SQR2 SQ5 LL_ADC_REG_GetSequencerRanks\n
  4100. * SQR2 SQ6 LL_ADC_REG_GetSequencerRanks\n
  4101. * SQR2 SQ7 LL_ADC_REG_GetSequencerRanks\n
  4102. * SQR2 SQ8 LL_ADC_REG_GetSequencerRanks\n
  4103. * SQR2 SQ9 LL_ADC_REG_GetSequencerRanks\n
  4104. * SQR3 SQ10 LL_ADC_REG_GetSequencerRanks\n
  4105. * SQR3 SQ11 LL_ADC_REG_GetSequencerRanks\n
  4106. * SQR3 SQ12 LL_ADC_REG_GetSequencerRanks\n
  4107. * SQR3 SQ13 LL_ADC_REG_GetSequencerRanks\n
  4108. * SQR3 SQ14 LL_ADC_REG_GetSequencerRanks\n
  4109. * SQR4 SQ15 LL_ADC_REG_GetSequencerRanks\n
  4110. * SQR4 SQ16 LL_ADC_REG_GetSequencerRanks
  4111. * @param ADCx ADC instance
  4112. * @param Rank This parameter can be one of the following values:
  4113. * @arg @ref LL_ADC_REG_RANK_1
  4114. * @arg @ref LL_ADC_REG_RANK_2
  4115. * @arg @ref LL_ADC_REG_RANK_3
  4116. * @arg @ref LL_ADC_REG_RANK_4
  4117. * @arg @ref LL_ADC_REG_RANK_5
  4118. * @arg @ref LL_ADC_REG_RANK_6
  4119. * @arg @ref LL_ADC_REG_RANK_7
  4120. * @arg @ref LL_ADC_REG_RANK_8
  4121. * @arg @ref LL_ADC_REG_RANK_9
  4122. * @arg @ref LL_ADC_REG_RANK_10
  4123. * @arg @ref LL_ADC_REG_RANK_11
  4124. * @arg @ref LL_ADC_REG_RANK_12
  4125. * @arg @ref LL_ADC_REG_RANK_13
  4126. * @arg @ref LL_ADC_REG_RANK_14
  4127. * @arg @ref LL_ADC_REG_RANK_15
  4128. * @arg @ref LL_ADC_REG_RANK_16
  4129. * @retval Returned value can be one of the following values:
  4130. * @arg @ref LL_ADC_CHANNEL_0
  4131. * @arg @ref LL_ADC_CHANNEL_1 (7)
  4132. * @arg @ref LL_ADC_CHANNEL_2 (7)
  4133. * @arg @ref LL_ADC_CHANNEL_3 (7)
  4134. * @arg @ref LL_ADC_CHANNEL_4 (7)
  4135. * @arg @ref LL_ADC_CHANNEL_5 (7)
  4136. * @arg @ref LL_ADC_CHANNEL_6
  4137. * @arg @ref LL_ADC_CHANNEL_7
  4138. * @arg @ref LL_ADC_CHANNEL_8
  4139. * @arg @ref LL_ADC_CHANNEL_9
  4140. * @arg @ref LL_ADC_CHANNEL_10
  4141. * @arg @ref LL_ADC_CHANNEL_11
  4142. * @arg @ref LL_ADC_CHANNEL_12
  4143. * @arg @ref LL_ADC_CHANNEL_13
  4144. * @arg @ref LL_ADC_CHANNEL_14
  4145. * @arg @ref LL_ADC_CHANNEL_15
  4146. * @arg @ref LL_ADC_CHANNEL_16
  4147. * @arg @ref LL_ADC_CHANNEL_17
  4148. * @arg @ref LL_ADC_CHANNEL_18
  4149. * @arg @ref LL_ADC_CHANNEL_VREFINT (1)
  4150. * @arg @ref LL_ADC_CHANNEL_TEMPSENSOR (4)
  4151. * @arg @ref LL_ADC_CHANNEL_VBAT (4)
  4152. * @arg @ref LL_ADC_CHANNEL_DAC1CH1 (5)
  4153. * @arg @ref LL_ADC_CHANNEL_DAC1CH2 (5)
  4154. * @arg @ref LL_ADC_CHANNEL_DAC1CH1_ADC2 (2)(6)
  4155. * @arg @ref LL_ADC_CHANNEL_DAC1CH2_ADC2 (2)(6)
  4156. * @arg @ref LL_ADC_CHANNEL_DAC1CH1_ADC3 (3)(6)
  4157. * @arg @ref LL_ADC_CHANNEL_DAC1CH2_ADC3 (3)(6)
  4158. *
  4159. * (1) On STM32L4, parameter available only on ADC instance: ADC1.\n
  4160. * (2) On STM32L4, parameter available only on ADC instance: ADC2.\n
  4161. * (3) On STM32L4, parameter available only on ADC instance: ADC3.\n
  4162. * (4) On STM32L4, parameter available only on ADC instances: ADC1, ADC3.\n
  4163. * (5) On STM32L4, parameter available on devices with only 1 ADC instance.\n
  4164. * (6) On STM32L4, parameter available on devices with several ADC instances.\n
  4165. * (7) On STM32L4, fast channel (0.188 us for 12-bit resolution (ADC conversion rate up to 5.33 Ms/s)).
  4166. * Other channels are slow channels (0.238 us for 12-bit resolution (ADC conversion rate up to
  4167. * 4.21 Ms/s)).\n
  4168. * (1, 2, 3, 4) For ADC channel read back from ADC register,
  4169. * comparison with internal channel parameter to be done
  4170. * using helper macro @ref __LL_ADC_CHANNEL_INTERNAL_TO_EXTERNAL().
  4171. */
  4172. __STATIC_INLINE uint32_t LL_ADC_REG_GetSequencerRanks(const ADC_TypeDef *ADCx, uint32_t Rank)
  4173. {
  4174. const __IO uint32_t *preg = __ADC_PTR_REG_OFFSET(ADCx->SQR1,
  4175. ((Rank & ADC_REG_SQRX_REGOFFSET_MASK) >> ADC_SQRX_REGOFFSET_POS));
  4176. return (uint32_t)((READ_BIT(*preg,
  4177. ADC_CHANNEL_ID_NUMBER_MASK_POSBIT0 << (Rank & ADC_REG_RANK_ID_SQRX_MASK))
  4178. >> (Rank & ADC_REG_RANK_ID_SQRX_MASK)) << ADC_CHANNEL_ID_NUMBER_BITOFFSET_POS
  4179. );
  4180. }
  4181. /**
  4182. * @brief Set ADC continuous conversion mode on ADC group regular.
  4183. * @note Description of ADC continuous conversion mode:
  4184. * - single mode: one conversion per trigger
  4185. * - continuous mode: after the first trigger, following
  4186. * conversions launched successively automatically.
  4187. * @note It is not possible to enable both ADC group regular
  4188. * continuous mode and sequencer discontinuous mode.
  4189. * @note On this STM32 series, setting of this feature is conditioned to
  4190. * ADC state:
  4191. * ADC must be disabled or enabled without conversion on going
  4192. * on group regular.
  4193. * @rmtoll CFGR CONT LL_ADC_REG_SetContinuousMode
  4194. * @param ADCx ADC instance
  4195. * @param Continuous This parameter can be one of the following values:
  4196. * @arg @ref LL_ADC_REG_CONV_SINGLE
  4197. * @arg @ref LL_ADC_REG_CONV_CONTINUOUS
  4198. * @retval None
  4199. */
  4200. __STATIC_INLINE void LL_ADC_REG_SetContinuousMode(ADC_TypeDef *ADCx, uint32_t Continuous)
  4201. {
  4202. MODIFY_REG(ADCx->CFGR, ADC_CFGR_CONT, Continuous);
  4203. }
  4204. /**
  4205. * @brief Get ADC continuous conversion mode on ADC group regular.
  4206. * @note Description of ADC continuous conversion mode:
  4207. * - single mode: one conversion per trigger
  4208. * - continuous mode: after the first trigger, following
  4209. * conversions launched successively automatically.
  4210. * @rmtoll CFGR CONT LL_ADC_REG_GetContinuousMode
  4211. * @param ADCx ADC instance
  4212. * @retval Returned value can be one of the following values:
  4213. * @arg @ref LL_ADC_REG_CONV_SINGLE
  4214. * @arg @ref LL_ADC_REG_CONV_CONTINUOUS
  4215. */
  4216. __STATIC_INLINE uint32_t LL_ADC_REG_GetContinuousMode(const ADC_TypeDef *ADCx)
  4217. {
  4218. return (uint32_t)(READ_BIT(ADCx->CFGR, ADC_CFGR_CONT));
  4219. }
  4220. /**
  4221. * @brief Set ADC group regular conversion data transfer: no transfer or
  4222. * transfer by DMA, and DMA requests mode.
  4223. * @note If transfer by DMA selected, specifies the DMA requests
  4224. * mode:
  4225. * - Limited mode (One shot mode): DMA transfer requests are stopped
  4226. * when number of DMA data transfers (number of
  4227. * ADC conversions) is reached.
  4228. * This ADC mode is intended to be used with DMA mode non-circular.
  4229. * - Unlimited mode: DMA transfer requests are unlimited,
  4230. * whatever number of DMA data transfers (number of
  4231. * ADC conversions).
  4232. * This ADC mode is intended to be used with DMA mode circular.
  4233. * @note If ADC DMA requests mode is set to unlimited and DMA is set to
  4234. * mode non-circular:
  4235. * when DMA transfers size will be reached, DMA will stop transfers of
  4236. * ADC conversions data ADC will raise an overrun error
  4237. * (overrun flag and interruption if enabled).
  4238. * @note For devices with several ADC instances: ADC multimode DMA
  4239. * settings are available using function @ref LL_ADC_SetMultiDMATransfer().
  4240. * @note To configure DMA source address (peripheral address),
  4241. * use function @ref LL_ADC_DMA_GetRegAddr().
  4242. * @note On this STM32 series, setting of this feature is conditioned to
  4243. * ADC state:
  4244. * ADC must be disabled or enabled without conversion on going
  4245. * on either groups regular or injected.
  4246. * @rmtoll CFGR DMAEN LL_ADC_REG_SetDMATransfer\n
  4247. * CFGR DMACFG LL_ADC_REG_SetDMATransfer
  4248. * @param ADCx ADC instance
  4249. * @param DMATransfer This parameter can be one of the following values:
  4250. * @arg @ref LL_ADC_REG_DMA_TRANSFER_NONE
  4251. * @arg @ref LL_ADC_REG_DMA_TRANSFER_LIMITED
  4252. * @arg @ref LL_ADC_REG_DMA_TRANSFER_UNLIMITED
  4253. * @retval None
  4254. */
  4255. __STATIC_INLINE void LL_ADC_REG_SetDMATransfer(ADC_TypeDef *ADCx, uint32_t DMATransfer)
  4256. {
  4257. MODIFY_REG(ADCx->CFGR, ADC_CFGR_DMAEN | ADC_CFGR_DMACFG, DMATransfer);
  4258. }
  4259. /**
  4260. * @brief Get ADC group regular conversion data transfer: no transfer or
  4261. * transfer by DMA, and DMA requests mode.
  4262. * @note If transfer by DMA selected, specifies the DMA requests
  4263. * mode:
  4264. * - Limited mode (One shot mode): DMA transfer requests are stopped
  4265. * when number of DMA data transfers (number of
  4266. * ADC conversions) is reached.
  4267. * This ADC mode is intended to be used with DMA mode non-circular.
  4268. * - Unlimited mode: DMA transfer requests are unlimited,
  4269. * whatever number of DMA data transfers (number of
  4270. * ADC conversions).
  4271. * This ADC mode is intended to be used with DMA mode circular.
  4272. * @note If ADC DMA requests mode is set to unlimited and DMA is set to
  4273. * mode non-circular:
  4274. * when DMA transfers size will be reached, DMA will stop transfers of
  4275. * ADC conversions data ADC will raise an overrun error
  4276. * (overrun flag and interruption if enabled).
  4277. * @note For devices with several ADC instances: ADC multimode DMA
  4278. * settings are available using function @ref LL_ADC_GetMultiDMATransfer().
  4279. * @note To configure DMA source address (peripheral address),
  4280. * use function @ref LL_ADC_DMA_GetRegAddr().
  4281. * @rmtoll CFGR DMAEN LL_ADC_REG_GetDMATransfer\n
  4282. * CFGR DMACFG LL_ADC_REG_GetDMATransfer
  4283. * @param ADCx ADC instance
  4284. * @retval Returned value can be one of the following values:
  4285. * @arg @ref LL_ADC_REG_DMA_TRANSFER_NONE
  4286. * @arg @ref LL_ADC_REG_DMA_TRANSFER_LIMITED
  4287. * @arg @ref LL_ADC_REG_DMA_TRANSFER_UNLIMITED
  4288. */
  4289. __STATIC_INLINE uint32_t LL_ADC_REG_GetDMATransfer(const ADC_TypeDef *ADCx)
  4290. {
  4291. return (uint32_t)(READ_BIT(ADCx->CFGR, ADC_CFGR_DMAEN | ADC_CFGR_DMACFG));
  4292. }
  4293. #if defined(ADC_CFGR_DFSDMCFG) &&defined(DFSDM1_Channel0)
  4294. /**
  4295. * @brief Set ADC group regular conversion data transfer to DFSDM.
  4296. * @note DFSDM transfer cannot be used if DMA transfer is enabled.
  4297. * @note To configure DFSDM source address (peripheral address),
  4298. * use the same function as for DMA transfer:
  4299. * function @ref LL_ADC_DMA_GetRegAddr().
  4300. * @note On this STM32 series, setting of this feature is conditioned to
  4301. * ADC state:
  4302. * ADC must be disabled or enabled without conversion on going
  4303. * on either groups regular or injected.
  4304. * @rmtoll CFGR DFSDMCFG LL_ADC_REG_GetDFSDMTransfer
  4305. * @param ADCx ADC instance
  4306. * @param DFSDMTransfer This parameter can be one of the following values:
  4307. * @arg @ref LL_ADC_REG_DFSDM_TRANSFER_NONE
  4308. * @arg @ref LL_ADC_REG_DFSDM_TRANSFER_ENABLE
  4309. * @retval None
  4310. */
  4311. __STATIC_INLINE void LL_ADC_REG_SetDFSDMTransfer(ADC_TypeDef *ADCx, uint32_t DFSDMTransfer)
  4312. {
  4313. MODIFY_REG(ADCx->CFGR, ADC_CFGR_DFSDMCFG, DFSDMTransfer);
  4314. }
  4315. /**
  4316. * @brief Get ADC group regular conversion data transfer to DFSDM.
  4317. * @rmtoll CFGR DFSDMCFG LL_ADC_REG_GetDFSDMTransfer
  4318. * @param ADCx ADC instance
  4319. * @retval Returned value can be one of the following values:
  4320. * @arg @ref LL_ADC_REG_DFSDM_TRANSFER_NONE
  4321. * @arg @ref LL_ADC_REG_DFSDM_TRANSFER_ENABLE
  4322. */
  4323. __STATIC_INLINE uint32_t LL_ADC_REG_GetDFSDMTransfer(const ADC_TypeDef *ADCx)
  4324. {
  4325. return (uint32_t)(READ_BIT(ADCx->CFGR, ADC_CFGR_DFSDMCFG));
  4326. }
  4327. #endif /* ADC_CFGR_DFSDMCFG */
  4328. /**
  4329. * @brief Set ADC group regular behavior in case of overrun:
  4330. * data preserved or overwritten.
  4331. * @note Compatibility with devices without feature overrun:
  4332. * other devices without this feature have a behavior
  4333. * equivalent to data overwritten.
  4334. * The default setting of overrun is data preserved.
  4335. * Therefore, for compatibility with all devices, parameter
  4336. * overrun should be set to data overwritten.
  4337. * @note On this STM32 series, setting of this feature is conditioned to
  4338. * ADC state:
  4339. * ADC must be disabled or enabled without conversion on going
  4340. * on group regular.
  4341. * @rmtoll CFGR OVRMOD LL_ADC_REG_SetOverrun
  4342. * @param ADCx ADC instance
  4343. * @param Overrun This parameter can be one of the following values:
  4344. * @arg @ref LL_ADC_REG_OVR_DATA_PRESERVED
  4345. * @arg @ref LL_ADC_REG_OVR_DATA_OVERWRITTEN
  4346. * @retval None
  4347. */
  4348. __STATIC_INLINE void LL_ADC_REG_SetOverrun(ADC_TypeDef *ADCx, uint32_t Overrun)
  4349. {
  4350. MODIFY_REG(ADCx->CFGR, ADC_CFGR_OVRMOD, Overrun);
  4351. }
  4352. /**
  4353. * @brief Get ADC group regular behavior in case of overrun:
  4354. * data preserved or overwritten.
  4355. * @rmtoll CFGR OVRMOD LL_ADC_REG_GetOverrun
  4356. * @param ADCx ADC instance
  4357. * @retval Returned value can be one of the following values:
  4358. * @arg @ref LL_ADC_REG_OVR_DATA_PRESERVED
  4359. * @arg @ref LL_ADC_REG_OVR_DATA_OVERWRITTEN
  4360. */
  4361. __STATIC_INLINE uint32_t LL_ADC_REG_GetOverrun(const ADC_TypeDef *ADCx)
  4362. {
  4363. return (uint32_t)(READ_BIT(ADCx->CFGR, ADC_CFGR_OVRMOD));
  4364. }
  4365. /**
  4366. * @}
  4367. */
  4368. /** @defgroup ADC_LL_EF_Configuration_ADC_Group_Injected Configuration of ADC hierarchical scope: group injected
  4369. * @{
  4370. */
  4371. /**
  4372. * @brief Set ADC group injected conversion trigger source:
  4373. * internal (SW start) or from external peripheral (timer event,
  4374. * external interrupt line).
  4375. * @note On this STM32 series, setting trigger source to external trigger
  4376. * also set trigger polarity to rising edge
  4377. * (default setting for compatibility with some ADC on other
  4378. * STM32 series having this setting set by HW default value).
  4379. * In case of need to modify trigger edge, use
  4380. * function @ref LL_ADC_INJ_SetTriggerEdge().
  4381. * @note Availability of parameters of trigger sources from timer
  4382. * depends on timers availability on the selected device.
  4383. * @note On this STM32 series, setting of this feature is conditioned to
  4384. * ADC state:
  4385. * ADC must not be disabled. Can be enabled with or without conversion
  4386. * on going on either groups regular or injected.
  4387. * @rmtoll JSQR JEXTSEL LL_ADC_INJ_SetTriggerSource\n
  4388. * JSQR JEXTEN LL_ADC_INJ_SetTriggerSource
  4389. * @param ADCx ADC instance
  4390. * @param TriggerSource This parameter can be one of the following values:
  4391. * @arg @ref LL_ADC_INJ_TRIG_SOFTWARE
  4392. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM1_TRGO
  4393. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM1_TRGO2
  4394. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM1_CH4
  4395. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM2_TRGO
  4396. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM2_CH1
  4397. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM3_TRGO
  4398. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM3_CH1
  4399. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM3_CH3
  4400. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM3_CH4
  4401. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM4_TRGO
  4402. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM6_TRGO
  4403. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM8_CH4
  4404. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM8_TRGO
  4405. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM8_TRGO2
  4406. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM15_TRGO
  4407. * @arg @ref LL_ADC_INJ_TRIG_EXT_EXTI_LINE15
  4408. * @retval None
  4409. */
  4410. __STATIC_INLINE void LL_ADC_INJ_SetTriggerSource(ADC_TypeDef *ADCx, uint32_t TriggerSource)
  4411. {
  4412. MODIFY_REG(ADCx->JSQR, ADC_JSQR_JEXTSEL | ADC_JSQR_JEXTEN, TriggerSource);
  4413. }
  4414. /**
  4415. * @brief Get ADC group injected conversion trigger source:
  4416. * internal (SW start) or from external peripheral (timer event,
  4417. * external interrupt line).
  4418. * @note To determine whether group injected trigger source is
  4419. * internal (SW start) or external, without detail
  4420. * of which peripheral is selected as external trigger,
  4421. * (equivalent to
  4422. * "if(LL_ADC_INJ_GetTriggerSource(ADC1) == LL_ADC_INJ_TRIG_SOFTWARE)")
  4423. * use function @ref LL_ADC_INJ_IsTriggerSourceSWStart.
  4424. * @note Availability of parameters of trigger sources from timer
  4425. * depends on timers availability on the selected device.
  4426. * @rmtoll JSQR JEXTSEL LL_ADC_INJ_GetTriggerSource\n
  4427. * JSQR JEXTEN LL_ADC_INJ_GetTriggerSource
  4428. * @param ADCx ADC instance
  4429. * @retval Returned value can be one of the following values:
  4430. * @arg @ref LL_ADC_INJ_TRIG_SOFTWARE
  4431. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM1_TRGO
  4432. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM1_TRGO2
  4433. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM1_CH4
  4434. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM2_TRGO
  4435. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM2_CH1
  4436. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM3_TRGO
  4437. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM3_CH1
  4438. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM3_CH3
  4439. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM3_CH4
  4440. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM4_TRGO
  4441. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM6_TRGO
  4442. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM8_CH4
  4443. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM8_TRGO
  4444. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM8_TRGO2
  4445. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM15_TRGO
  4446. * @arg @ref LL_ADC_INJ_TRIG_EXT_EXTI_LINE15
  4447. */
  4448. __STATIC_INLINE uint32_t LL_ADC_INJ_GetTriggerSource(const ADC_TypeDef *ADCx)
  4449. {
  4450. __IO uint32_t trigger_source = READ_BIT(ADCx->JSQR, ADC_JSQR_JEXTSEL | ADC_JSQR_JEXTEN);
  4451. /* Value for shift of {0; 4; 8; 12} depending on value of bitfield */
  4452. /* corresponding to ADC_JSQR_JEXTEN {0; 1; 2; 3}. */
  4453. uint32_t shift_jexten = ((trigger_source & ADC_JSQR_JEXTEN) >> (ADC_INJ_TRIG_EXTEN_BITOFFSET_POS - 2UL));
  4454. /* Set bitfield corresponding to ADC_JSQR_JEXTEN and ADC_JSQR_JEXTSEL */
  4455. /* to match with triggers literals definition. */
  4456. return ((trigger_source
  4457. & (ADC_INJ_TRIG_SOURCE_MASK >> shift_jexten) & ADC_JSQR_JEXTSEL)
  4458. | ((ADC_INJ_TRIG_EDGE_MASK >> shift_jexten) & ADC_JSQR_JEXTEN)
  4459. );
  4460. }
  4461. /**
  4462. * @brief Get ADC group injected conversion trigger source internal (SW start)
  4463. or external
  4464. * @note In case of group injected trigger source set to external trigger,
  4465. * to determine which peripheral is selected as external trigger,
  4466. * use function @ref LL_ADC_INJ_GetTriggerSource.
  4467. * @rmtoll JSQR JEXTEN LL_ADC_INJ_IsTriggerSourceSWStart
  4468. * @param ADCx ADC instance
  4469. * @retval Value "0" if trigger source external trigger
  4470. * Value "1" if trigger source SW start.
  4471. */
  4472. __STATIC_INLINE uint32_t LL_ADC_INJ_IsTriggerSourceSWStart(const ADC_TypeDef *ADCx)
  4473. {
  4474. return ((READ_BIT(ADCx->JSQR, ADC_JSQR_JEXTEN) == (LL_ADC_INJ_TRIG_SOFTWARE & ADC_JSQR_JEXTEN)) ? 1UL : 0UL);
  4475. }
  4476. /**
  4477. * @brief Set ADC group injected conversion trigger polarity.
  4478. * Applicable only for trigger source set to external trigger.
  4479. * @note On this STM32 series, setting of this feature is conditioned to
  4480. * ADC state:
  4481. * ADC must not be disabled. Can be enabled with or without conversion
  4482. * on going on either groups regular or injected.
  4483. * @rmtoll JSQR JEXTEN LL_ADC_INJ_SetTriggerEdge
  4484. * @param ADCx ADC instance
  4485. * @param ExternalTriggerEdge This parameter can be one of the following values:
  4486. * @arg @ref LL_ADC_INJ_TRIG_EXT_RISING
  4487. * @arg @ref LL_ADC_INJ_TRIG_EXT_FALLING
  4488. * @arg @ref LL_ADC_INJ_TRIG_EXT_RISINGFALLING
  4489. * @retval None
  4490. */
  4491. __STATIC_INLINE void LL_ADC_INJ_SetTriggerEdge(ADC_TypeDef *ADCx, uint32_t ExternalTriggerEdge)
  4492. {
  4493. MODIFY_REG(ADCx->JSQR, ADC_JSQR_JEXTEN, ExternalTriggerEdge);
  4494. }
  4495. /**
  4496. * @brief Get ADC group injected conversion trigger polarity.
  4497. * Applicable only for trigger source set to external trigger.
  4498. * @rmtoll JSQR JEXTEN LL_ADC_INJ_GetTriggerEdge
  4499. * @param ADCx ADC instance
  4500. * @retval Returned value can be one of the following values:
  4501. * @arg @ref LL_ADC_INJ_TRIG_EXT_RISING
  4502. * @arg @ref LL_ADC_INJ_TRIG_EXT_FALLING
  4503. * @arg @ref LL_ADC_INJ_TRIG_EXT_RISINGFALLING
  4504. */
  4505. __STATIC_INLINE uint32_t LL_ADC_INJ_GetTriggerEdge(const ADC_TypeDef *ADCx)
  4506. {
  4507. return (uint32_t)(READ_BIT(ADCx->JSQR, ADC_JSQR_JEXTEN));
  4508. }
  4509. /**
  4510. * @brief Set ADC group injected sequencer length and scan direction.
  4511. * @note This function performs configuration of:
  4512. * - Sequence length: Number of ranks in the scan sequence.
  4513. * - Sequence direction: Unless specified in parameters, sequencer
  4514. * scan direction is forward (from rank 1 to rank n).
  4515. * @note Sequencer disabled is equivalent to sequencer of 1 rank:
  4516. * ADC conversion on only 1 channel.
  4517. * @note On this STM32 series, setting of this feature is conditioned to
  4518. * ADC state:
  4519. * ADC must not be disabled. Can be enabled with or without conversion
  4520. * on going on either groups regular or injected.
  4521. * @rmtoll JSQR JL LL_ADC_INJ_SetSequencerLength
  4522. * @param ADCx ADC instance
  4523. * @param SequencerNbRanks This parameter can be one of the following values:
  4524. * @arg @ref LL_ADC_INJ_SEQ_SCAN_DISABLE
  4525. * @arg @ref LL_ADC_INJ_SEQ_SCAN_ENABLE_2RANKS
  4526. * @arg @ref LL_ADC_INJ_SEQ_SCAN_ENABLE_3RANKS
  4527. * @arg @ref LL_ADC_INJ_SEQ_SCAN_ENABLE_4RANKS
  4528. * @retval None
  4529. */
  4530. __STATIC_INLINE void LL_ADC_INJ_SetSequencerLength(ADC_TypeDef *ADCx, uint32_t SequencerNbRanks)
  4531. {
  4532. MODIFY_REG(ADCx->JSQR, ADC_JSQR_JL, SequencerNbRanks);
  4533. }
  4534. /**
  4535. * @brief Get ADC group injected sequencer length and scan direction.
  4536. * @note This function retrieves:
  4537. * - Sequence length: Number of ranks in the scan sequence.
  4538. * - Sequence direction: Unless specified in parameters, sequencer
  4539. * scan direction is forward (from rank 1 to rank n).
  4540. * @note Sequencer disabled is equivalent to sequencer of 1 rank:
  4541. * ADC conversion on only 1 channel.
  4542. * @rmtoll JSQR JL LL_ADC_INJ_GetSequencerLength
  4543. * @param ADCx ADC instance
  4544. * @retval Returned value can be one of the following values:
  4545. * @arg @ref LL_ADC_INJ_SEQ_SCAN_DISABLE
  4546. * @arg @ref LL_ADC_INJ_SEQ_SCAN_ENABLE_2RANKS
  4547. * @arg @ref LL_ADC_INJ_SEQ_SCAN_ENABLE_3RANKS
  4548. * @arg @ref LL_ADC_INJ_SEQ_SCAN_ENABLE_4RANKS
  4549. */
  4550. __STATIC_INLINE uint32_t LL_ADC_INJ_GetSequencerLength(const ADC_TypeDef *ADCx)
  4551. {
  4552. return (uint32_t)(READ_BIT(ADCx->JSQR, ADC_JSQR_JL));
  4553. }
  4554. /**
  4555. * @brief Set ADC group injected sequencer discontinuous mode:
  4556. * sequence subdivided and scan conversions interrupted every selected
  4557. * number of ranks.
  4558. * @note It is not possible to enable both ADC group injected
  4559. * auto-injected mode and sequencer discontinuous mode.
  4560. * @rmtoll CFGR JDISCEN LL_ADC_INJ_SetSequencerDiscont
  4561. * @param ADCx ADC instance
  4562. * @param SeqDiscont This parameter can be one of the following values:
  4563. * @arg @ref LL_ADC_INJ_SEQ_DISCONT_DISABLE
  4564. * @arg @ref LL_ADC_INJ_SEQ_DISCONT_1RANK
  4565. * @retval None
  4566. */
  4567. __STATIC_INLINE void LL_ADC_INJ_SetSequencerDiscont(ADC_TypeDef *ADCx, uint32_t SeqDiscont)
  4568. {
  4569. MODIFY_REG(ADCx->CFGR, ADC_CFGR_JDISCEN, SeqDiscont);
  4570. }
  4571. /**
  4572. * @brief Get ADC group injected sequencer discontinuous mode:
  4573. * sequence subdivided and scan conversions interrupted every selected
  4574. * number of ranks.
  4575. * @rmtoll CFGR JDISCEN LL_ADC_INJ_GetSequencerDiscont
  4576. * @param ADCx ADC instance
  4577. * @retval Returned value can be one of the following values:
  4578. * @arg @ref LL_ADC_INJ_SEQ_DISCONT_DISABLE
  4579. * @arg @ref LL_ADC_INJ_SEQ_DISCONT_1RANK
  4580. */
  4581. __STATIC_INLINE uint32_t LL_ADC_INJ_GetSequencerDiscont(const ADC_TypeDef *ADCx)
  4582. {
  4583. return (uint32_t)(READ_BIT(ADCx->CFGR, ADC_CFGR_JDISCEN));
  4584. }
  4585. /**
  4586. * @brief Set ADC group injected sequence: channel on the selected
  4587. * sequence rank.
  4588. * @note Depending on devices and packages, some channels may not be available.
  4589. * Refer to device datasheet for channels availability.
  4590. * @note On this STM32 series, to measure internal channels (VrefInt,
  4591. * TempSensor, ...), measurement paths to internal channels must be
  4592. * enabled separately.
  4593. * This can be done using function @ref LL_ADC_SetCommonPathInternalCh().
  4594. * @note On STM32L4, some fast channels are available: fast analog inputs
  4595. * coming from GPIO pads (ADC_IN1..5).
  4596. * @note On this STM32 series, setting of this feature is conditioned to
  4597. * ADC state:
  4598. * ADC must not be disabled. Can be enabled with or without conversion
  4599. * on going on either groups regular or injected.
  4600. * @rmtoll JSQR JSQ1 LL_ADC_INJ_SetSequencerRanks\n
  4601. * JSQR JSQ2 LL_ADC_INJ_SetSequencerRanks\n
  4602. * JSQR JSQ3 LL_ADC_INJ_SetSequencerRanks\n
  4603. * JSQR JSQ4 LL_ADC_INJ_SetSequencerRanks
  4604. * @param ADCx ADC instance
  4605. * @param Rank This parameter can be one of the following values:
  4606. * @arg @ref LL_ADC_INJ_RANK_1
  4607. * @arg @ref LL_ADC_INJ_RANK_2
  4608. * @arg @ref LL_ADC_INJ_RANK_3
  4609. * @arg @ref LL_ADC_INJ_RANK_4
  4610. * @param Channel This parameter can be one of the following values:
  4611. * @arg @ref LL_ADC_CHANNEL_0
  4612. * @arg @ref LL_ADC_CHANNEL_1 (7)
  4613. * @arg @ref LL_ADC_CHANNEL_2 (7)
  4614. * @arg @ref LL_ADC_CHANNEL_3 (7)
  4615. * @arg @ref LL_ADC_CHANNEL_4 (7)
  4616. * @arg @ref LL_ADC_CHANNEL_5 (7)
  4617. * @arg @ref LL_ADC_CHANNEL_6
  4618. * @arg @ref LL_ADC_CHANNEL_7
  4619. * @arg @ref LL_ADC_CHANNEL_8
  4620. * @arg @ref LL_ADC_CHANNEL_9
  4621. * @arg @ref LL_ADC_CHANNEL_10
  4622. * @arg @ref LL_ADC_CHANNEL_11
  4623. * @arg @ref LL_ADC_CHANNEL_12
  4624. * @arg @ref LL_ADC_CHANNEL_13
  4625. * @arg @ref LL_ADC_CHANNEL_14
  4626. * @arg @ref LL_ADC_CHANNEL_15
  4627. * @arg @ref LL_ADC_CHANNEL_16
  4628. * @arg @ref LL_ADC_CHANNEL_17
  4629. * @arg @ref LL_ADC_CHANNEL_18
  4630. * @arg @ref LL_ADC_CHANNEL_VREFINT (1)
  4631. * @arg @ref LL_ADC_CHANNEL_TEMPSENSOR (4)
  4632. * @arg @ref LL_ADC_CHANNEL_VBAT (4)
  4633. * @arg @ref LL_ADC_CHANNEL_DAC1CH1 (5)
  4634. * @arg @ref LL_ADC_CHANNEL_DAC1CH2 (5)
  4635. * @arg @ref LL_ADC_CHANNEL_DAC1CH1_ADC2 (2)(6)
  4636. * @arg @ref LL_ADC_CHANNEL_DAC1CH2_ADC2 (2)(6)
  4637. * @arg @ref LL_ADC_CHANNEL_DAC1CH1_ADC3 (3)(6)
  4638. * @arg @ref LL_ADC_CHANNEL_DAC1CH2_ADC3 (3)(6)
  4639. *
  4640. * (1) On STM32L4, parameter available only on ADC instance: ADC1.\n
  4641. * (2) On STM32L4, parameter available only on ADC instance: ADC2.\n
  4642. * (3) On STM32L4, parameter available only on ADC instance: ADC3.\n
  4643. * (4) On STM32L4, parameter available only on ADC instances: ADC1, ADC3.\n
  4644. * (5) On STM32L4, parameter available on devices with only 1 ADC instance.\n
  4645. * (6) On STM32L4, parameter available on devices with several ADC instances.\n
  4646. * (7) On STM32L4, fast channel (0.188 us for 12-bit resolution (ADC conversion rate up to 5.33 Ms/s)).
  4647. * Other channels are slow channels (0.238 us for 12-bit resolution (ADC conversion rate up to 4.21 Ms/s)).
  4648. * @retval None
  4649. */
  4650. __STATIC_INLINE void LL_ADC_INJ_SetSequencerRanks(ADC_TypeDef *ADCx, uint32_t Rank, uint32_t Channel)
  4651. {
  4652. /* Set bits with content of parameter "Channel" with bits position */
  4653. /* in register depending on parameter "Rank". */
  4654. /* Parameters "Rank" and "Channel" are used with masks because containing */
  4655. /* other bits reserved for other purpose. */
  4656. MODIFY_REG(ADCx->JSQR,
  4657. (ADC_CHANNEL_ID_NUMBER_MASK >> ADC_CHANNEL_ID_NUMBER_BITOFFSET_POS)
  4658. << (Rank & ADC_INJ_RANK_ID_JSQR_MASK),
  4659. ((Channel & ADC_CHANNEL_ID_NUMBER_MASK) >> ADC_CHANNEL_ID_NUMBER_BITOFFSET_POS)
  4660. << (Rank & ADC_INJ_RANK_ID_JSQR_MASK));
  4661. }
  4662. /**
  4663. * @brief Get ADC group injected sequence: channel on the selected
  4664. * sequence rank.
  4665. * @note Depending on devices and packages, some channels may not be available.
  4666. * Refer to device datasheet for channels availability.
  4667. * @note Usage of the returned channel number:
  4668. * - To reinject this channel into another function LL_ADC_xxx:
  4669. * the returned channel number is only partly formatted on definition
  4670. * of literals LL_ADC_CHANNEL_x. Therefore, it has to be compared
  4671. * with parts of literals LL_ADC_CHANNEL_x or using
  4672. * helper macro @ref __LL_ADC_CHANNEL_TO_DECIMAL_NB().
  4673. * Then the selected literal LL_ADC_CHANNEL_x can be used
  4674. * as parameter for another function.
  4675. * - To get the channel number in decimal format:
  4676. * process the returned value with the helper macro
  4677. * @ref __LL_ADC_CHANNEL_TO_DECIMAL_NB().
  4678. * @rmtoll JSQR JSQ1 LL_ADC_INJ_GetSequencerRanks\n
  4679. * JSQR JSQ2 LL_ADC_INJ_GetSequencerRanks\n
  4680. * JSQR JSQ3 LL_ADC_INJ_GetSequencerRanks\n
  4681. * JSQR JSQ4 LL_ADC_INJ_GetSequencerRanks
  4682. * @param ADCx ADC instance
  4683. * @param Rank This parameter can be one of the following values:
  4684. * @arg @ref LL_ADC_INJ_RANK_1
  4685. * @arg @ref LL_ADC_INJ_RANK_2
  4686. * @arg @ref LL_ADC_INJ_RANK_3
  4687. * @arg @ref LL_ADC_INJ_RANK_4
  4688. * @retval Returned value can be one of the following values:
  4689. * @arg @ref LL_ADC_CHANNEL_0
  4690. * @arg @ref LL_ADC_CHANNEL_1 (7)
  4691. * @arg @ref LL_ADC_CHANNEL_2 (7)
  4692. * @arg @ref LL_ADC_CHANNEL_3 (7)
  4693. * @arg @ref LL_ADC_CHANNEL_4 (7)
  4694. * @arg @ref LL_ADC_CHANNEL_5 (7)
  4695. * @arg @ref LL_ADC_CHANNEL_6
  4696. * @arg @ref LL_ADC_CHANNEL_7
  4697. * @arg @ref LL_ADC_CHANNEL_8
  4698. * @arg @ref LL_ADC_CHANNEL_9
  4699. * @arg @ref LL_ADC_CHANNEL_10
  4700. * @arg @ref LL_ADC_CHANNEL_11
  4701. * @arg @ref LL_ADC_CHANNEL_12
  4702. * @arg @ref LL_ADC_CHANNEL_13
  4703. * @arg @ref LL_ADC_CHANNEL_14
  4704. * @arg @ref LL_ADC_CHANNEL_15
  4705. * @arg @ref LL_ADC_CHANNEL_16
  4706. * @arg @ref LL_ADC_CHANNEL_17
  4707. * @arg @ref LL_ADC_CHANNEL_18
  4708. * @arg @ref LL_ADC_CHANNEL_VREFINT (1)
  4709. * @arg @ref LL_ADC_CHANNEL_TEMPSENSOR (4)
  4710. * @arg @ref LL_ADC_CHANNEL_VBAT (4)
  4711. * @arg @ref LL_ADC_CHANNEL_DAC1CH1 (5)
  4712. * @arg @ref LL_ADC_CHANNEL_DAC1CH2 (5)
  4713. * @arg @ref LL_ADC_CHANNEL_DAC1CH1_ADC2 (2)(6)
  4714. * @arg @ref LL_ADC_CHANNEL_DAC1CH2_ADC2 (2)(6)
  4715. * @arg @ref LL_ADC_CHANNEL_DAC1CH1_ADC3 (3)(6)
  4716. * @arg @ref LL_ADC_CHANNEL_DAC1CH2_ADC3 (3)(6)
  4717. *
  4718. * (1) On STM32L4, parameter available only on ADC instance: ADC1.\n
  4719. * (2) On STM32L4, parameter available only on ADC instance: ADC2.\n
  4720. * (3) On STM32L4, parameter available only on ADC instance: ADC3.\n
  4721. * (4) On STM32L4, parameter available only on ADC instances: ADC1, ADC3.\n
  4722. * (5) On STM32L4, parameter available on devices with only 1 ADC instance.\n
  4723. * (6) On STM32L4, parameter available on devices with several ADC instances.\n
  4724. * (7) On STM32L4, fast channel (0.188 us for 12-bit resolution (ADC conversion rate up to 5.33 Ms/s)).
  4725. * Other channels are slow channels (0.238 us for 12-bit resolution (ADC conversion rate up to
  4726. * 4.21 Ms/s)).\n
  4727. * (1, 2, 3, 4) For ADC channel read back from ADC register,
  4728. * comparison with internal channel parameter to be done
  4729. * using helper macro @ref __LL_ADC_CHANNEL_INTERNAL_TO_EXTERNAL().
  4730. */
  4731. __STATIC_INLINE uint32_t LL_ADC_INJ_GetSequencerRanks(const ADC_TypeDef *ADCx, uint32_t Rank)
  4732. {
  4733. return (uint32_t)((READ_BIT(ADCx->JSQR,
  4734. (ADC_CHANNEL_ID_NUMBER_MASK >> ADC_CHANNEL_ID_NUMBER_BITOFFSET_POS)
  4735. << (Rank & ADC_INJ_RANK_ID_JSQR_MASK))
  4736. >> (Rank & ADC_INJ_RANK_ID_JSQR_MASK)) << ADC_CHANNEL_ID_NUMBER_BITOFFSET_POS
  4737. );
  4738. }
  4739. /**
  4740. * @brief Set ADC group injected conversion trigger:
  4741. * independent or from ADC group regular.
  4742. * @note This mode can be used to extend number of data registers
  4743. * updated after one ADC conversion trigger and with data
  4744. * permanently kept (not erased by successive conversions of scan of
  4745. * ADC sequencer ranks), up to 5 data registers:
  4746. * 1 data register on ADC group regular, 4 data registers
  4747. * on ADC group injected.
  4748. * @note If ADC group injected injected trigger source is set to an
  4749. * external trigger, this feature must be must be set to
  4750. * independent trigger.
  4751. * ADC group injected automatic trigger is compliant only with
  4752. * group injected trigger source set to SW start, without any
  4753. * further action on ADC group injected conversion start or stop:
  4754. * in this case, ADC group injected is controlled only
  4755. * from ADC group regular.
  4756. * @note It is not possible to enable both ADC group injected
  4757. * auto-injected mode and sequencer discontinuous mode.
  4758. * @note On this STM32 series, setting of this feature is conditioned to
  4759. * ADC state:
  4760. * ADC must be disabled or enabled without conversion on going
  4761. * on either groups regular or injected.
  4762. * @rmtoll CFGR JAUTO LL_ADC_INJ_SetTrigAuto
  4763. * @param ADCx ADC instance
  4764. * @param TrigAuto This parameter can be one of the following values:
  4765. * @arg @ref LL_ADC_INJ_TRIG_INDEPENDENT
  4766. * @arg @ref LL_ADC_INJ_TRIG_FROM_GRP_REGULAR
  4767. * @retval None
  4768. */
  4769. __STATIC_INLINE void LL_ADC_INJ_SetTrigAuto(ADC_TypeDef *ADCx, uint32_t TrigAuto)
  4770. {
  4771. MODIFY_REG(ADCx->CFGR, ADC_CFGR_JAUTO, TrigAuto);
  4772. }
  4773. /**
  4774. * @brief Get ADC group injected conversion trigger:
  4775. * independent or from ADC group regular.
  4776. * @rmtoll CFGR JAUTO LL_ADC_INJ_GetTrigAuto
  4777. * @param ADCx ADC instance
  4778. * @retval Returned value can be one of the following values:
  4779. * @arg @ref LL_ADC_INJ_TRIG_INDEPENDENT
  4780. * @arg @ref LL_ADC_INJ_TRIG_FROM_GRP_REGULAR
  4781. */
  4782. __STATIC_INLINE uint32_t LL_ADC_INJ_GetTrigAuto(const ADC_TypeDef *ADCx)
  4783. {
  4784. return (uint32_t)(READ_BIT(ADCx->CFGR, ADC_CFGR_JAUTO));
  4785. }
  4786. /**
  4787. * @brief Set ADC group injected contexts queue mode.
  4788. * @note A context is a setting of group injected sequencer:
  4789. * - group injected trigger
  4790. * - sequencer length
  4791. * - sequencer ranks
  4792. * If contexts queue is disabled:
  4793. * - only 1 sequence can be configured
  4794. * and is active perpetually.
  4795. * If contexts queue is enabled:
  4796. * - up to 2 contexts can be queued
  4797. * and are checked in and out as a FIFO stack (first-in, first-out).
  4798. * - If a new context is set when queues is full, error is triggered
  4799. * by interruption "Injected Queue Overflow".
  4800. * - Two behaviors are possible when all contexts have been processed:
  4801. * the contexts queue can maintain the last context active perpetually
  4802. * or can be empty and injected group triggers are disabled.
  4803. * - Triggers can be only external (not internal SW start)
  4804. * - Caution: The sequence must be fully configured in one time
  4805. * (one write of register JSQR makes a check-in of a new context
  4806. * into the queue).
  4807. * Therefore functions to set separately injected trigger and
  4808. * sequencer channels cannot be used, register JSQR must be set
  4809. * using function @ref LL_ADC_INJ_ConfigQueueContext().
  4810. * @note This parameter can be modified only when no conversion is on going
  4811. * on either groups regular or injected.
  4812. * @note A modification of the context mode (bit JQDIS) causes the contexts
  4813. * queue to be flushed and the register JSQR is cleared.
  4814. * @note On this STM32 series, setting of this feature is conditioned to
  4815. * ADC state:
  4816. * ADC must be disabled or enabled without conversion on going
  4817. * on either groups regular or injected.
  4818. * @rmtoll CFGR JQM LL_ADC_INJ_SetQueueMode\n
  4819. * CFGR JQDIS LL_ADC_INJ_SetQueueMode
  4820. * @param ADCx ADC instance
  4821. * @param QueueMode This parameter can be one of the following values:
  4822. * @arg @ref LL_ADC_INJ_QUEUE_DISABLE
  4823. * @arg @ref LL_ADC_INJ_QUEUE_2CONTEXTS_LAST_ACTIVE
  4824. * @arg @ref LL_ADC_INJ_QUEUE_2CONTEXTS_END_EMPTY
  4825. * @retval None
  4826. */
  4827. __STATIC_INLINE void LL_ADC_INJ_SetQueueMode(ADC_TypeDef *ADCx, uint32_t QueueMode)
  4828. {
  4829. MODIFY_REG(ADCx->CFGR, ADC_CFGR_JQM | ADC_CFGR_JQDIS, QueueMode);
  4830. }
  4831. /**
  4832. * @brief Get ADC group injected context queue mode.
  4833. * @rmtoll CFGR JQM LL_ADC_INJ_GetQueueMode\n
  4834. * CFGR JQDIS LL_ADC_INJ_GetQueueMode
  4835. * @param ADCx ADC instance
  4836. * @retval Returned value can be one of the following values:
  4837. * @arg @ref LL_ADC_INJ_QUEUE_DISABLE
  4838. * @arg @ref LL_ADC_INJ_QUEUE_2CONTEXTS_LAST_ACTIVE
  4839. * @arg @ref LL_ADC_INJ_QUEUE_2CONTEXTS_END_EMPTY
  4840. */
  4841. __STATIC_INLINE uint32_t LL_ADC_INJ_GetQueueMode(const ADC_TypeDef *ADCx)
  4842. {
  4843. return (uint32_t)(READ_BIT(ADCx->CFGR, ADC_CFGR_JQM | ADC_CFGR_JQDIS));
  4844. }
  4845. /**
  4846. * @brief Set one context on ADC group injected that will be checked in
  4847. * contexts queue.
  4848. * @note A context is a setting of group injected sequencer:
  4849. * - group injected trigger
  4850. * - sequencer length
  4851. * - sequencer ranks
  4852. * This function is intended to be used when contexts queue is enabled,
  4853. * because the sequence must be fully configured in one time
  4854. * (functions to set separately injected trigger and sequencer channels
  4855. * cannot be used):
  4856. * Refer to function @ref LL_ADC_INJ_SetQueueMode().
  4857. * @note In the contexts queue, only the active context can be read.
  4858. * The parameters of this function can be read using functions:
  4859. * @arg @ref LL_ADC_INJ_GetTriggerSource()
  4860. * @arg @ref LL_ADC_INJ_GetTriggerEdge()
  4861. * @arg @ref LL_ADC_INJ_GetSequencerRanks()
  4862. * @note On this STM32 series, to measure internal channels (VrefInt,
  4863. * TempSensor, ...), measurement paths to internal channels must be
  4864. * enabled separately.
  4865. * This can be done using function @ref LL_ADC_SetCommonPathInternalCh().
  4866. * @note On STM32L4, some fast channels are available: fast analog inputs
  4867. * coming from GPIO pads (ADC_IN1..5).
  4868. * @note On this STM32 series, setting of this feature is conditioned to
  4869. * ADC state:
  4870. * ADC must not be disabled. Can be enabled with or without conversion
  4871. * on going on either groups regular or injected.
  4872. * @rmtoll JSQR JEXTSEL LL_ADC_INJ_ConfigQueueContext\n
  4873. * JSQR JEXTEN LL_ADC_INJ_ConfigQueueContext\n
  4874. * JSQR JL LL_ADC_INJ_ConfigQueueContext\n
  4875. * JSQR JSQ1 LL_ADC_INJ_ConfigQueueContext\n
  4876. * JSQR JSQ2 LL_ADC_INJ_ConfigQueueContext\n
  4877. * JSQR JSQ3 LL_ADC_INJ_ConfigQueueContext\n
  4878. * JSQR JSQ4 LL_ADC_INJ_ConfigQueueContext
  4879. * @param ADCx ADC instance
  4880. * @param TriggerSource This parameter can be one of the following values:
  4881. * @arg @ref LL_ADC_INJ_TRIG_SOFTWARE
  4882. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM1_TRGO
  4883. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM1_TRGO2
  4884. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM1_CH4
  4885. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM2_TRGO
  4886. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM2_CH1
  4887. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM3_TRGO
  4888. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM3_CH1
  4889. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM3_CH3
  4890. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM3_CH4
  4891. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM4_TRGO
  4892. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM6_TRGO
  4893. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM8_CH4
  4894. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM8_TRGO
  4895. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM8_TRGO2
  4896. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM15_TRGO
  4897. * @arg @ref LL_ADC_INJ_TRIG_EXT_EXTI_LINE15
  4898. * @param ExternalTriggerEdge This parameter can be one of the following values:
  4899. * @arg @ref LL_ADC_INJ_TRIG_EXT_RISING
  4900. * @arg @ref LL_ADC_INJ_TRIG_EXT_FALLING
  4901. * @arg @ref LL_ADC_INJ_TRIG_EXT_RISINGFALLING
  4902. *
  4903. * Note: This parameter is discarded in case of SW start:
  4904. * parameter "TriggerSource" set to "LL_ADC_INJ_TRIG_SOFTWARE".
  4905. * @param SequencerNbRanks This parameter can be one of the following values:
  4906. * @arg @ref LL_ADC_INJ_SEQ_SCAN_DISABLE
  4907. * @arg @ref LL_ADC_INJ_SEQ_SCAN_ENABLE_2RANKS
  4908. * @arg @ref LL_ADC_INJ_SEQ_SCAN_ENABLE_3RANKS
  4909. * @arg @ref LL_ADC_INJ_SEQ_SCAN_ENABLE_4RANKS
  4910. * @param Rank1_Channel This parameter can be one of the following values:
  4911. * @arg @ref LL_ADC_CHANNEL_0
  4912. * @arg @ref LL_ADC_CHANNEL_1 (7)
  4913. * @arg @ref LL_ADC_CHANNEL_2 (7)
  4914. * @arg @ref LL_ADC_CHANNEL_3 (7)
  4915. * @arg @ref LL_ADC_CHANNEL_4 (7)
  4916. * @arg @ref LL_ADC_CHANNEL_5 (7)
  4917. * @arg @ref LL_ADC_CHANNEL_6
  4918. * @arg @ref LL_ADC_CHANNEL_7
  4919. * @arg @ref LL_ADC_CHANNEL_8
  4920. * @arg @ref LL_ADC_CHANNEL_9
  4921. * @arg @ref LL_ADC_CHANNEL_10
  4922. * @arg @ref LL_ADC_CHANNEL_11
  4923. * @arg @ref LL_ADC_CHANNEL_12
  4924. * @arg @ref LL_ADC_CHANNEL_13
  4925. * @arg @ref LL_ADC_CHANNEL_14
  4926. * @arg @ref LL_ADC_CHANNEL_15
  4927. * @arg @ref LL_ADC_CHANNEL_16
  4928. * @arg @ref LL_ADC_CHANNEL_17
  4929. * @arg @ref LL_ADC_CHANNEL_18
  4930. * @arg @ref LL_ADC_CHANNEL_VREFINT (1)
  4931. * @arg @ref LL_ADC_CHANNEL_TEMPSENSOR (4)
  4932. * @arg @ref LL_ADC_CHANNEL_VBAT (4)
  4933. * @arg @ref LL_ADC_CHANNEL_DAC1CH1 (5)
  4934. * @arg @ref LL_ADC_CHANNEL_DAC1CH2 (5)
  4935. * @arg @ref LL_ADC_CHANNEL_DAC1CH1_ADC2 (2)(6)
  4936. * @arg @ref LL_ADC_CHANNEL_DAC1CH2_ADC2 (2)(6)
  4937. * @arg @ref LL_ADC_CHANNEL_DAC1CH1_ADC3 (3)(6)
  4938. * @arg @ref LL_ADC_CHANNEL_DAC1CH2_ADC3 (3)(6)
  4939. *
  4940. * (1) On STM32L4, parameter available only on ADC instance: ADC1.\n
  4941. * (2) On STM32L4, parameter available only on ADC instance: ADC2.\n
  4942. * (3) On STM32L4, parameter available only on ADC instance: ADC3.\n
  4943. * (4) On STM32L4, parameter available only on ADC instances: ADC1, ADC3.\n
  4944. * (5) On STM32L4, parameter available on devices with only 1 ADC instance.\n
  4945. * (6) On STM32L4, parameter available on devices with several ADC instances.\n
  4946. * (7) On STM32L4, fast channel (0.188 us for 12-bit resolution (ADC conversion rate up to 5.33 Ms/s)).
  4947. * Other channels are slow channels (0.238 us for 12-bit resolution (ADC conversion rate up to 4.21 Ms/s)).
  4948. * @param Rank2_Channel This parameter can be one of the following values:
  4949. * @arg @ref LL_ADC_CHANNEL_0
  4950. * @arg @ref LL_ADC_CHANNEL_1 (7)
  4951. * @arg @ref LL_ADC_CHANNEL_2 (7)
  4952. * @arg @ref LL_ADC_CHANNEL_3 (7)
  4953. * @arg @ref LL_ADC_CHANNEL_4 (7)
  4954. * @arg @ref LL_ADC_CHANNEL_5 (7)
  4955. * @arg @ref LL_ADC_CHANNEL_6
  4956. * @arg @ref LL_ADC_CHANNEL_7
  4957. * @arg @ref LL_ADC_CHANNEL_8
  4958. * @arg @ref LL_ADC_CHANNEL_9
  4959. * @arg @ref LL_ADC_CHANNEL_10
  4960. * @arg @ref LL_ADC_CHANNEL_11
  4961. * @arg @ref LL_ADC_CHANNEL_12
  4962. * @arg @ref LL_ADC_CHANNEL_13
  4963. * @arg @ref LL_ADC_CHANNEL_14
  4964. * @arg @ref LL_ADC_CHANNEL_15
  4965. * @arg @ref LL_ADC_CHANNEL_16
  4966. * @arg @ref LL_ADC_CHANNEL_17
  4967. * @arg @ref LL_ADC_CHANNEL_18
  4968. * @arg @ref LL_ADC_CHANNEL_VREFINT (1)
  4969. * @arg @ref LL_ADC_CHANNEL_TEMPSENSOR (4)
  4970. * @arg @ref LL_ADC_CHANNEL_VBAT (4)
  4971. * @arg @ref LL_ADC_CHANNEL_DAC1CH1 (5)
  4972. * @arg @ref LL_ADC_CHANNEL_DAC1CH2 (5)
  4973. * @arg @ref LL_ADC_CHANNEL_DAC1CH1_ADC2 (2)(6)
  4974. * @arg @ref LL_ADC_CHANNEL_DAC1CH2_ADC2 (2)(6)
  4975. * @arg @ref LL_ADC_CHANNEL_DAC1CH1_ADC3 (3)(6)
  4976. * @arg @ref LL_ADC_CHANNEL_DAC1CH2_ADC3 (3)(6)
  4977. *
  4978. * (1) On STM32L4, parameter available only on ADC instance: ADC1.\n
  4979. * (2) On STM32L4, parameter available only on ADC instance: ADC2.\n
  4980. * (3) On STM32L4, parameter available only on ADC instance: ADC3.\n
  4981. * (4) On STM32L4, parameter available only on ADC instances: ADC1, ADC3.\n
  4982. * (5) On STM32L4, parameter available on devices with only 1 ADC instance.\n
  4983. * (6) On STM32L4, parameter available on devices with several ADC instances.\n
  4984. * (7) On STM32L4, fast channel (0.188 us for 12-bit resolution (ADC conversion rate up to 5.33 Ms/s)).
  4985. * Other channels are slow channels (0.238 us for 12-bit resolution (ADC conversion rate up to 4.21 Ms/s)).
  4986. * @param Rank3_Channel This parameter can be one of the following values:
  4987. * @arg @ref LL_ADC_CHANNEL_0
  4988. * @arg @ref LL_ADC_CHANNEL_1 (7)
  4989. * @arg @ref LL_ADC_CHANNEL_2 (7)
  4990. * @arg @ref LL_ADC_CHANNEL_3 (7)
  4991. * @arg @ref LL_ADC_CHANNEL_4 (7)
  4992. * @arg @ref LL_ADC_CHANNEL_5 (7)
  4993. * @arg @ref LL_ADC_CHANNEL_6
  4994. * @arg @ref LL_ADC_CHANNEL_7
  4995. * @arg @ref LL_ADC_CHANNEL_8
  4996. * @arg @ref LL_ADC_CHANNEL_9
  4997. * @arg @ref LL_ADC_CHANNEL_10
  4998. * @arg @ref LL_ADC_CHANNEL_11
  4999. * @arg @ref LL_ADC_CHANNEL_12
  5000. * @arg @ref LL_ADC_CHANNEL_13
  5001. * @arg @ref LL_ADC_CHANNEL_14
  5002. * @arg @ref LL_ADC_CHANNEL_15
  5003. * @arg @ref LL_ADC_CHANNEL_16
  5004. * @arg @ref LL_ADC_CHANNEL_17
  5005. * @arg @ref LL_ADC_CHANNEL_18
  5006. * @arg @ref LL_ADC_CHANNEL_VREFINT (1)
  5007. * @arg @ref LL_ADC_CHANNEL_TEMPSENSOR (4)
  5008. * @arg @ref LL_ADC_CHANNEL_VBAT (4)
  5009. * @arg @ref LL_ADC_CHANNEL_DAC1CH1 (5)
  5010. * @arg @ref LL_ADC_CHANNEL_DAC1CH2 (5)
  5011. * @arg @ref LL_ADC_CHANNEL_DAC1CH1_ADC2 (2)(6)
  5012. * @arg @ref LL_ADC_CHANNEL_DAC1CH2_ADC2 (2)(6)
  5013. * @arg @ref LL_ADC_CHANNEL_DAC1CH1_ADC3 (3)(6)
  5014. * @arg @ref LL_ADC_CHANNEL_DAC1CH2_ADC3 (3)(6)
  5015. *
  5016. * (1) On STM32L4, parameter available only on ADC instance: ADC1.\n
  5017. * (2) On STM32L4, parameter available only on ADC instance: ADC2.\n
  5018. * (3) On STM32L4, parameter available only on ADC instance: ADC3.\n
  5019. * (4) On STM32L4, parameter available only on ADC instances: ADC1, ADC3.\n
  5020. * (5) On STM32L4, parameter available on devices with only 1 ADC instance.\n
  5021. * (6) On STM32L4, parameter available on devices with several ADC instances.\n
  5022. * (7) On STM32L4, fast channel (0.188 us for 12-bit resolution (ADC conversion rate up to 5.33 Ms/s)).
  5023. * Other channels are slow channels (0.238 us for 12-bit resolution (ADC conversion rate up to 4.21 Ms/s)).
  5024. * @param Rank4_Channel This parameter can be one of the following values:
  5025. * @arg @ref LL_ADC_CHANNEL_0
  5026. * @arg @ref LL_ADC_CHANNEL_1 (7)
  5027. * @arg @ref LL_ADC_CHANNEL_2 (7)
  5028. * @arg @ref LL_ADC_CHANNEL_3 (7)
  5029. * @arg @ref LL_ADC_CHANNEL_4 (7)
  5030. * @arg @ref LL_ADC_CHANNEL_5 (7)
  5031. * @arg @ref LL_ADC_CHANNEL_6
  5032. * @arg @ref LL_ADC_CHANNEL_7
  5033. * @arg @ref LL_ADC_CHANNEL_8
  5034. * @arg @ref LL_ADC_CHANNEL_9
  5035. * @arg @ref LL_ADC_CHANNEL_10
  5036. * @arg @ref LL_ADC_CHANNEL_11
  5037. * @arg @ref LL_ADC_CHANNEL_12
  5038. * @arg @ref LL_ADC_CHANNEL_13
  5039. * @arg @ref LL_ADC_CHANNEL_14
  5040. * @arg @ref LL_ADC_CHANNEL_15
  5041. * @arg @ref LL_ADC_CHANNEL_16
  5042. * @arg @ref LL_ADC_CHANNEL_17
  5043. * @arg @ref LL_ADC_CHANNEL_18
  5044. * @arg @ref LL_ADC_CHANNEL_VREFINT (1)
  5045. * @arg @ref LL_ADC_CHANNEL_TEMPSENSOR (4)
  5046. * @arg @ref LL_ADC_CHANNEL_VBAT (4)
  5047. * @arg @ref LL_ADC_CHANNEL_DAC1CH1 (5)
  5048. * @arg @ref LL_ADC_CHANNEL_DAC1CH2 (5)
  5049. * @arg @ref LL_ADC_CHANNEL_DAC1CH1_ADC2 (2)(6)
  5050. * @arg @ref LL_ADC_CHANNEL_DAC1CH2_ADC2 (2)(6)
  5051. * @arg @ref LL_ADC_CHANNEL_DAC1CH1_ADC3 (3)(6)
  5052. * @arg @ref LL_ADC_CHANNEL_DAC1CH2_ADC3 (3)(6)
  5053. *
  5054. * (1) On STM32L4, parameter available only on ADC instance: ADC1.\n
  5055. * (2) On STM32L4, parameter available only on ADC instance: ADC2.\n
  5056. * (3) On STM32L4, parameter available only on ADC instance: ADC3.\n
  5057. * (4) On STM32L4, parameter available only on ADC instances: ADC1, ADC3.\n
  5058. * (5) On STM32L4, parameter available on devices with only 1 ADC instance.\n
  5059. * (6) On STM32L4, parameter available on devices with several ADC instances.\n
  5060. * (7) On STM32L4, fast channel (0.188 us for 12-bit resolution (ADC conversion rate up to 5.33 Ms/s)).
  5061. * Other channels are slow channels (0.238 us for 12-bit resolution (ADC conversion rate up to 4.21 Ms/s)).
  5062. * @retval None
  5063. */
  5064. __STATIC_INLINE void LL_ADC_INJ_ConfigQueueContext(ADC_TypeDef *ADCx,
  5065. uint32_t TriggerSource,
  5066. uint32_t ExternalTriggerEdge,
  5067. uint32_t SequencerNbRanks,
  5068. uint32_t Rank1_Channel,
  5069. uint32_t Rank2_Channel,
  5070. uint32_t Rank3_Channel,
  5071. uint32_t Rank4_Channel)
  5072. {
  5073. /* Set bits with content of parameter "Rankx_Channel" with bits position */
  5074. /* in register depending on literal "LL_ADC_INJ_RANK_x". */
  5075. /* Parameters "Rankx_Channel" and "LL_ADC_INJ_RANK_x" are used with masks */
  5076. /* because containing other bits reserved for other purpose. */
  5077. /* If parameter "TriggerSource" is set to SW start, then parameter */
  5078. /* "ExternalTriggerEdge" is discarded. */
  5079. uint32_t is_trigger_not_sw = (uint32_t)((TriggerSource != LL_ADC_INJ_TRIG_SOFTWARE) ? 1UL : 0UL);
  5080. MODIFY_REG(ADCx->JSQR,
  5081. ADC_JSQR_JEXTSEL |
  5082. ADC_JSQR_JEXTEN |
  5083. ADC_JSQR_JSQ4 |
  5084. ADC_JSQR_JSQ3 |
  5085. ADC_JSQR_JSQ2 |
  5086. ADC_JSQR_JSQ1 |
  5087. ADC_JSQR_JL,
  5088. (TriggerSource & ADC_JSQR_JEXTSEL) |
  5089. (ExternalTriggerEdge * (is_trigger_not_sw)) |
  5090. (((Rank4_Channel & ADC_CHANNEL_ID_NUMBER_MASK) >> ADC_CHANNEL_ID_NUMBER_BITOFFSET_POS)
  5091. << (LL_ADC_INJ_RANK_4 & ADC_INJ_RANK_ID_JSQR_MASK)) |
  5092. (((Rank3_Channel & ADC_CHANNEL_ID_NUMBER_MASK) >> ADC_CHANNEL_ID_NUMBER_BITOFFSET_POS)
  5093. << (LL_ADC_INJ_RANK_3 & ADC_INJ_RANK_ID_JSQR_MASK)) |
  5094. (((Rank2_Channel & ADC_CHANNEL_ID_NUMBER_MASK) >> ADC_CHANNEL_ID_NUMBER_BITOFFSET_POS)
  5095. << (LL_ADC_INJ_RANK_2 & ADC_INJ_RANK_ID_JSQR_MASK)) |
  5096. (((Rank1_Channel & ADC_CHANNEL_ID_NUMBER_MASK) >> ADC_CHANNEL_ID_NUMBER_BITOFFSET_POS)
  5097. << (LL_ADC_INJ_RANK_1 & ADC_INJ_RANK_ID_JSQR_MASK)) |
  5098. SequencerNbRanks
  5099. );
  5100. }
  5101. /**
  5102. * @}
  5103. */
  5104. /** @defgroup ADC_LL_EF_Configuration_Channels Configuration of ADC hierarchical scope: channels
  5105. * @{
  5106. */
  5107. /**
  5108. * @brief Set sampling time of the selected ADC channel
  5109. * Unit: ADC clock cycles.
  5110. * @note On this device, sampling time is on channel scope: independently
  5111. * of channel mapped on ADC group regular or injected.
  5112. * @note In case of internal channel (VrefInt, TempSensor, ...) to be
  5113. * converted:
  5114. * sampling time constraints must be respected (sampling time can be
  5115. * adjusted in function of ADC clock frequency and sampling time
  5116. * setting).
  5117. * Refer to device datasheet for timings values (parameters TS_vrefint,
  5118. * TS_temp, ...).
  5119. * @note Conversion time is the addition of sampling time and processing time.
  5120. * On this STM32 series, ADC processing time is:
  5121. * - 12.5 ADC clock cycles at ADC resolution 12 bits
  5122. * - 10.5 ADC clock cycles at ADC resolution 10 bits
  5123. * - 8.5 ADC clock cycles at ADC resolution 8 bits
  5124. * - 6.5 ADC clock cycles at ADC resolution 6 bits
  5125. * @note In case of ADC conversion of internal channel (VrefInt,
  5126. * temperature sensor, ...), a sampling time minimum value
  5127. * is required.
  5128. * Refer to device datasheet.
  5129. * @note On this STM32 series, setting of this feature is conditioned to
  5130. * ADC state:
  5131. * ADC must be disabled or enabled without conversion on going
  5132. * on either groups regular or injected.
  5133. * @rmtoll SMPR1 SMP0 LL_ADC_SetChannelSamplingTime\n
  5134. * SMPR1 SMP1 LL_ADC_SetChannelSamplingTime\n
  5135. * SMPR1 SMP2 LL_ADC_SetChannelSamplingTime\n
  5136. * SMPR1 SMP3 LL_ADC_SetChannelSamplingTime\n
  5137. * SMPR1 SMP4 LL_ADC_SetChannelSamplingTime\n
  5138. * SMPR1 SMP5 LL_ADC_SetChannelSamplingTime\n
  5139. * SMPR1 SMP6 LL_ADC_SetChannelSamplingTime\n
  5140. * SMPR1 SMP7 LL_ADC_SetChannelSamplingTime\n
  5141. * SMPR1 SMP8 LL_ADC_SetChannelSamplingTime\n
  5142. * SMPR1 SMP9 LL_ADC_SetChannelSamplingTime\n
  5143. * SMPR2 SMP10 LL_ADC_SetChannelSamplingTime\n
  5144. * SMPR2 SMP11 LL_ADC_SetChannelSamplingTime\n
  5145. * SMPR2 SMP12 LL_ADC_SetChannelSamplingTime\n
  5146. * SMPR2 SMP13 LL_ADC_SetChannelSamplingTime\n
  5147. * SMPR2 SMP14 LL_ADC_SetChannelSamplingTime\n
  5148. * SMPR2 SMP15 LL_ADC_SetChannelSamplingTime\n
  5149. * SMPR2 SMP16 LL_ADC_SetChannelSamplingTime\n
  5150. * SMPR2 SMP17 LL_ADC_SetChannelSamplingTime\n
  5151. * SMPR2 SMP18 LL_ADC_SetChannelSamplingTime
  5152. * @param ADCx ADC instance
  5153. * @param Channel This parameter can be one of the following values:
  5154. * @arg @ref LL_ADC_CHANNEL_0
  5155. * @arg @ref LL_ADC_CHANNEL_1 (7)
  5156. * @arg @ref LL_ADC_CHANNEL_2 (7)
  5157. * @arg @ref LL_ADC_CHANNEL_3 (7)
  5158. * @arg @ref LL_ADC_CHANNEL_4 (7)
  5159. * @arg @ref LL_ADC_CHANNEL_5 (7)
  5160. * @arg @ref LL_ADC_CHANNEL_6
  5161. * @arg @ref LL_ADC_CHANNEL_7
  5162. * @arg @ref LL_ADC_CHANNEL_8
  5163. * @arg @ref LL_ADC_CHANNEL_9
  5164. * @arg @ref LL_ADC_CHANNEL_10
  5165. * @arg @ref LL_ADC_CHANNEL_11
  5166. * @arg @ref LL_ADC_CHANNEL_12
  5167. * @arg @ref LL_ADC_CHANNEL_13
  5168. * @arg @ref LL_ADC_CHANNEL_14
  5169. * @arg @ref LL_ADC_CHANNEL_15
  5170. * @arg @ref LL_ADC_CHANNEL_16
  5171. * @arg @ref LL_ADC_CHANNEL_17
  5172. * @arg @ref LL_ADC_CHANNEL_18
  5173. * @arg @ref LL_ADC_CHANNEL_VREFINT (1)
  5174. * @arg @ref LL_ADC_CHANNEL_TEMPSENSOR (4)
  5175. * @arg @ref LL_ADC_CHANNEL_VBAT (4)
  5176. * @arg @ref LL_ADC_CHANNEL_DAC1CH1 (5)
  5177. * @arg @ref LL_ADC_CHANNEL_DAC1CH2 (5)
  5178. * @arg @ref LL_ADC_CHANNEL_DAC1CH1_ADC2 (2)(6)
  5179. * @arg @ref LL_ADC_CHANNEL_DAC1CH2_ADC2 (2)(6)
  5180. * @arg @ref LL_ADC_CHANNEL_DAC1CH1_ADC3 (3)(6)
  5181. * @arg @ref LL_ADC_CHANNEL_DAC1CH2_ADC3 (3)(6)
  5182. *
  5183. * (1) On STM32L4, parameter available only on ADC instance: ADC1.\n
  5184. * (2) On STM32L4, parameter available only on ADC instance: ADC2.\n
  5185. * (3) On STM32L4, parameter available only on ADC instance: ADC3.\n
  5186. * (4) On STM32L4, parameter available only on ADC instances: ADC1, ADC3.\n
  5187. * (5) On STM32L4, parameter available on devices with only 1 ADC instance.\n
  5188. * (6) On STM32L4, parameter available on devices with several ADC instances.\n
  5189. * (7) On STM32L4, fast channel (0.188 us for 12-bit resolution (ADC conversion rate up to 5.33 Ms/s)).
  5190. * Other channels are slow channels (0.238 us for 12-bit resolution (ADC conversion rate up to 4.21 Ms/s)).
  5191. * @param SamplingTime This parameter can be one of the following values:
  5192. * @arg @ref LL_ADC_SAMPLINGTIME_2CYCLES_5 (1)
  5193. * @arg @ref LL_ADC_SAMPLINGTIME_6CYCLES_5
  5194. * @arg @ref LL_ADC_SAMPLINGTIME_12CYCLES_5
  5195. * @arg @ref LL_ADC_SAMPLINGTIME_24CYCLES_5
  5196. * @arg @ref LL_ADC_SAMPLINGTIME_47CYCLES_5
  5197. * @arg @ref LL_ADC_SAMPLINGTIME_92CYCLES_5
  5198. * @arg @ref LL_ADC_SAMPLINGTIME_247CYCLES_5
  5199. * @arg @ref LL_ADC_SAMPLINGTIME_640CYCLES_5
  5200. *
  5201. * (1) On some devices, ADC sampling time 2.5 ADC clock cycles
  5202. * can be replaced by 3.5 ADC clock cycles.
  5203. * Refer to function @ref LL_ADC_SetSamplingTimeCommonConfig().
  5204. * @retval None
  5205. */
  5206. __STATIC_INLINE void LL_ADC_SetChannelSamplingTime(ADC_TypeDef *ADCx, uint32_t Channel, uint32_t SamplingTime)
  5207. {
  5208. /* Set bits with content of parameter "SamplingTime" with bits position */
  5209. /* in register and register position depending on parameter "Channel". */
  5210. /* Parameter "Channel" is used with masks because containing */
  5211. /* other bits reserved for other purpose. */
  5212. __IO uint32_t *preg = __ADC_PTR_REG_OFFSET(ADCx->SMPR1,
  5213. ((Channel & ADC_CHANNEL_SMPRX_REGOFFSET_MASK) >> ADC_SMPRX_REGOFFSET_POS));
  5214. MODIFY_REG(*preg,
  5215. ADC_SMPR1_SMP0 << ((Channel & ADC_CHANNEL_SMPx_BITOFFSET_MASK) >> ADC_CHANNEL_SMPx_BITOFFSET_POS),
  5216. SamplingTime << ((Channel & ADC_CHANNEL_SMPx_BITOFFSET_MASK) >> ADC_CHANNEL_SMPx_BITOFFSET_POS));
  5217. }
  5218. /**
  5219. * @brief Get sampling time of the selected ADC channel
  5220. * Unit: ADC clock cycles.
  5221. * @note On this device, sampling time is on channel scope: independently
  5222. * of channel mapped on ADC group regular or injected.
  5223. * @note Conversion time is the addition of sampling time and processing time.
  5224. * On this STM32 series, ADC processing time is:
  5225. * - 12.5 ADC clock cycles at ADC resolution 12 bits
  5226. * - 10.5 ADC clock cycles at ADC resolution 10 bits
  5227. * - 8.5 ADC clock cycles at ADC resolution 8 bits
  5228. * - 6.5 ADC clock cycles at ADC resolution 6 bits
  5229. * @rmtoll SMPR1 SMP0 LL_ADC_GetChannelSamplingTime\n
  5230. * SMPR1 SMP1 LL_ADC_GetChannelSamplingTime\n
  5231. * SMPR1 SMP2 LL_ADC_GetChannelSamplingTime\n
  5232. * SMPR1 SMP3 LL_ADC_GetChannelSamplingTime\n
  5233. * SMPR1 SMP4 LL_ADC_GetChannelSamplingTime\n
  5234. * SMPR1 SMP5 LL_ADC_GetChannelSamplingTime\n
  5235. * SMPR1 SMP6 LL_ADC_GetChannelSamplingTime\n
  5236. * SMPR1 SMP7 LL_ADC_GetChannelSamplingTime\n
  5237. * SMPR1 SMP8 LL_ADC_GetChannelSamplingTime\n
  5238. * SMPR1 SMP9 LL_ADC_GetChannelSamplingTime\n
  5239. * SMPR2 SMP10 LL_ADC_GetChannelSamplingTime\n
  5240. * SMPR2 SMP11 LL_ADC_GetChannelSamplingTime\n
  5241. * SMPR2 SMP12 LL_ADC_GetChannelSamplingTime\n
  5242. * SMPR2 SMP13 LL_ADC_GetChannelSamplingTime\n
  5243. * SMPR2 SMP14 LL_ADC_GetChannelSamplingTime\n
  5244. * SMPR2 SMP15 LL_ADC_GetChannelSamplingTime\n
  5245. * SMPR2 SMP16 LL_ADC_GetChannelSamplingTime\n
  5246. * SMPR2 SMP17 LL_ADC_GetChannelSamplingTime\n
  5247. * SMPR2 SMP18 LL_ADC_GetChannelSamplingTime
  5248. * @param ADCx ADC instance
  5249. * @param Channel This parameter can be one of the following values:
  5250. * @arg @ref LL_ADC_CHANNEL_0
  5251. * @arg @ref LL_ADC_CHANNEL_1 (7)
  5252. * @arg @ref LL_ADC_CHANNEL_2 (7)
  5253. * @arg @ref LL_ADC_CHANNEL_3 (7)
  5254. * @arg @ref LL_ADC_CHANNEL_4 (7)
  5255. * @arg @ref LL_ADC_CHANNEL_5 (7)
  5256. * @arg @ref LL_ADC_CHANNEL_6
  5257. * @arg @ref LL_ADC_CHANNEL_7
  5258. * @arg @ref LL_ADC_CHANNEL_8
  5259. * @arg @ref LL_ADC_CHANNEL_9
  5260. * @arg @ref LL_ADC_CHANNEL_10
  5261. * @arg @ref LL_ADC_CHANNEL_11
  5262. * @arg @ref LL_ADC_CHANNEL_12
  5263. * @arg @ref LL_ADC_CHANNEL_13
  5264. * @arg @ref LL_ADC_CHANNEL_14
  5265. * @arg @ref LL_ADC_CHANNEL_15
  5266. * @arg @ref LL_ADC_CHANNEL_16
  5267. * @arg @ref LL_ADC_CHANNEL_17
  5268. * @arg @ref LL_ADC_CHANNEL_18
  5269. * @arg @ref LL_ADC_CHANNEL_VREFINT (1)
  5270. * @arg @ref LL_ADC_CHANNEL_TEMPSENSOR (4)
  5271. * @arg @ref LL_ADC_CHANNEL_VBAT (4)
  5272. * @arg @ref LL_ADC_CHANNEL_DAC1CH1 (5)
  5273. * @arg @ref LL_ADC_CHANNEL_DAC1CH2 (5)
  5274. * @arg @ref LL_ADC_CHANNEL_DAC1CH1_ADC2 (2)(6)
  5275. * @arg @ref LL_ADC_CHANNEL_DAC1CH2_ADC2 (2)(6)
  5276. * @arg @ref LL_ADC_CHANNEL_DAC1CH1_ADC3 (3)(6)
  5277. * @arg @ref LL_ADC_CHANNEL_DAC1CH2_ADC3 (3)(6)
  5278. *
  5279. * (1) On STM32L4, parameter available only on ADC instance: ADC1.\n
  5280. * (2) On STM32L4, parameter available only on ADC instance: ADC2.\n
  5281. * (3) On STM32L4, parameter available only on ADC instance: ADC3.\n
  5282. * (4) On STM32L4, parameter available only on ADC instances: ADC1, ADC3.\n
  5283. * (5) On STM32L4, parameter available on devices with only 1 ADC instance.\n
  5284. * (6) On STM32L4, parameter available on devices with several ADC instances.\n
  5285. * (7) On STM32L4, fast channel (0.188 us for 12-bit resolution (ADC conversion rate up to 5.33 Ms/s)).
  5286. * Other channels are slow channels (0.238 us for 12-bit resolution (ADC conversion rate up to 4.21 Ms/s)).
  5287. * @retval Returned value can be one of the following values:
  5288. * @arg @ref LL_ADC_SAMPLINGTIME_2CYCLES_5 (1)
  5289. * @arg @ref LL_ADC_SAMPLINGTIME_6CYCLES_5
  5290. * @arg @ref LL_ADC_SAMPLINGTIME_12CYCLES_5
  5291. * @arg @ref LL_ADC_SAMPLINGTIME_24CYCLES_5
  5292. * @arg @ref LL_ADC_SAMPLINGTIME_47CYCLES_5
  5293. * @arg @ref LL_ADC_SAMPLINGTIME_92CYCLES_5
  5294. * @arg @ref LL_ADC_SAMPLINGTIME_247CYCLES_5
  5295. * @arg @ref LL_ADC_SAMPLINGTIME_640CYCLES_5
  5296. *
  5297. * (1) On some devices, ADC sampling time 2.5 ADC clock cycles
  5298. * can be replaced by 3.5 ADC clock cycles.
  5299. * Refer to function @ref LL_ADC_SetSamplingTimeCommonConfig().
  5300. */
  5301. __STATIC_INLINE uint32_t LL_ADC_GetChannelSamplingTime(const ADC_TypeDef *ADCx, uint32_t Channel)
  5302. {
  5303. const __IO uint32_t *preg = __ADC_PTR_REG_OFFSET(ADCx->SMPR1, ((Channel & ADC_CHANNEL_SMPRX_REGOFFSET_MASK)
  5304. >> ADC_SMPRX_REGOFFSET_POS));
  5305. return (uint32_t)(READ_BIT(*preg,
  5306. ADC_SMPR1_SMP0
  5307. << ((Channel & ADC_CHANNEL_SMPx_BITOFFSET_MASK) >> ADC_CHANNEL_SMPx_BITOFFSET_POS))
  5308. >> ((Channel & ADC_CHANNEL_SMPx_BITOFFSET_MASK) >> ADC_CHANNEL_SMPx_BITOFFSET_POS)
  5309. );
  5310. }
  5311. /**
  5312. * @brief Set mode single-ended or differential input of the selected
  5313. * ADC channel.
  5314. * @note Channel ending is on channel scope: independently of channel mapped
  5315. * on ADC group regular or injected.
  5316. * In differential mode: Differential measurement is carried out
  5317. * between the selected channel 'i' (positive input) and
  5318. * channel 'i+1' (negative input). Only channel 'i' has to be
  5319. * configured, channel 'i+1' is configured automatically.
  5320. * @note Refer to Reference Manual to ensure the selected channel is
  5321. * available in differential mode.
  5322. * For example, internal channels (VrefInt, TempSensor, ...) are
  5323. * not available in differential mode.
  5324. * @note When configuring a channel 'i' in differential mode,
  5325. * the channel 'i+1' is not usable separately.
  5326. * @note On STM32L4, channels 16, 17, 18 of ADC1, ADC2, ADC3 (if available)
  5327. * are internally fixed to single-ended inputs configuration.
  5328. * @note For ADC channels configured in differential mode, both inputs
  5329. * should be biased at (Vref+)/2 +/-200mV.
  5330. * (Vref+ is the analog voltage reference)
  5331. * @note On this STM32 series, setting of this feature is conditioned to
  5332. * ADC state:
  5333. * ADC must be ADC disabled.
  5334. * @note One or several values can be selected.
  5335. * Example: (LL_ADC_CHANNEL_4 | LL_ADC_CHANNEL_12 | ...)
  5336. * @rmtoll DIFSEL DIFSEL LL_ADC_SetChannelSingleDiff
  5337. * @param ADCx ADC instance
  5338. * @param Channel This parameter can be one of the following values:
  5339. * @arg @ref LL_ADC_CHANNEL_1
  5340. * @arg @ref LL_ADC_CHANNEL_2
  5341. * @arg @ref LL_ADC_CHANNEL_3
  5342. * @arg @ref LL_ADC_CHANNEL_4
  5343. * @arg @ref LL_ADC_CHANNEL_5
  5344. * @arg @ref LL_ADC_CHANNEL_6
  5345. * @arg @ref LL_ADC_CHANNEL_7
  5346. * @arg @ref LL_ADC_CHANNEL_8
  5347. * @arg @ref LL_ADC_CHANNEL_9
  5348. * @arg @ref LL_ADC_CHANNEL_10
  5349. * @arg @ref LL_ADC_CHANNEL_11
  5350. * @arg @ref LL_ADC_CHANNEL_12
  5351. * @arg @ref LL_ADC_CHANNEL_13
  5352. * @arg @ref LL_ADC_CHANNEL_14
  5353. * @arg @ref LL_ADC_CHANNEL_15
  5354. * @param SingleDiff This parameter can be a combination of the following values:
  5355. * @arg @ref LL_ADC_SINGLE_ENDED
  5356. * @arg @ref LL_ADC_DIFFERENTIAL_ENDED
  5357. * @retval None
  5358. */
  5359. __STATIC_INLINE void LL_ADC_SetChannelSingleDiff(ADC_TypeDef *ADCx, uint32_t Channel, uint32_t SingleDiff)
  5360. {
  5361. /* Bits of channels in single or differential mode are set only for */
  5362. /* differential mode (for single mode, mask of bits allowed to be set is */
  5363. /* shifted out of range of bits of channels in single or differential mode. */
  5364. MODIFY_REG(ADCx->DIFSEL,
  5365. Channel & ADC_SINGLEDIFF_CHANNEL_MASK,
  5366. (Channel & ADC_SINGLEDIFF_CHANNEL_MASK)
  5367. & (ADC_DIFSEL_DIFSEL >> (SingleDiff & ADC_SINGLEDIFF_CHANNEL_SHIFT_MASK)));
  5368. }
  5369. /**
  5370. * @brief Get mode single-ended or differential input of the selected
  5371. * ADC channel.
  5372. * @note When configuring a channel 'i' in differential mode,
  5373. * the channel 'i+1' is not usable separately.
  5374. * Therefore, to ensure a channel is configured in single-ended mode,
  5375. * the configuration of channel itself and the channel 'i-1' must be
  5376. * read back (to ensure that the selected channel channel has not been
  5377. * configured in differential mode by the previous channel).
  5378. * @note Refer to Reference Manual to ensure the selected channel is
  5379. * available in differential mode.
  5380. * For example, internal channels (VrefInt, TempSensor, ...) are
  5381. * not available in differential mode.
  5382. * @note When configuring a channel 'i' in differential mode,
  5383. * the channel 'i+1' is not usable separately.
  5384. * @note On STM32L4, channels 16, 17, 18 of ADC1, ADC2, ADC3 (if available)
  5385. * are internally fixed to single-ended inputs configuration.
  5386. * @note One or several values can be selected. In this case, the value
  5387. * returned is null if all channels are in single ended-mode.
  5388. * Example: (LL_ADC_CHANNEL_4 | LL_ADC_CHANNEL_12 | ...)
  5389. * @rmtoll DIFSEL DIFSEL LL_ADC_GetChannelSingleDiff
  5390. * @param ADCx ADC instance
  5391. * @param Channel This parameter can be a combination of the following values:
  5392. * @arg @ref LL_ADC_CHANNEL_1
  5393. * @arg @ref LL_ADC_CHANNEL_2
  5394. * @arg @ref LL_ADC_CHANNEL_3
  5395. * @arg @ref LL_ADC_CHANNEL_4
  5396. * @arg @ref LL_ADC_CHANNEL_5
  5397. * @arg @ref LL_ADC_CHANNEL_6
  5398. * @arg @ref LL_ADC_CHANNEL_7
  5399. * @arg @ref LL_ADC_CHANNEL_8
  5400. * @arg @ref LL_ADC_CHANNEL_9
  5401. * @arg @ref LL_ADC_CHANNEL_10
  5402. * @arg @ref LL_ADC_CHANNEL_11
  5403. * @arg @ref LL_ADC_CHANNEL_12
  5404. * @arg @ref LL_ADC_CHANNEL_13
  5405. * @arg @ref LL_ADC_CHANNEL_14
  5406. * @arg @ref LL_ADC_CHANNEL_15
  5407. * @retval 0: channel in single-ended mode, else: channel in differential mode
  5408. */
  5409. __STATIC_INLINE uint32_t LL_ADC_GetChannelSingleDiff(const ADC_TypeDef *ADCx, uint32_t Channel)
  5410. {
  5411. return (uint32_t)(READ_BIT(ADCx->DIFSEL, (Channel & ADC_SINGLEDIFF_CHANNEL_MASK)));
  5412. }
  5413. /**
  5414. * @}
  5415. */
  5416. /** @defgroup ADC_LL_EF_Configuration_ADC_AnalogWatchdog Configuration of ADC transversal scope: analog watchdog
  5417. * @{
  5418. */
  5419. /**
  5420. * @brief Set ADC analog watchdog monitored channels:
  5421. * a single channel, multiple channels or all channels,
  5422. * on ADC groups regular and-or injected.
  5423. * @note Once monitored channels are selected, analog watchdog
  5424. * is enabled.
  5425. * @note In case of need to define a single channel to monitor
  5426. * with analog watchdog from sequencer channel definition,
  5427. * use helper macro @ref __LL_ADC_ANALOGWD_CHANNEL_GROUP().
  5428. * @note On this STM32 series, there are 2 kinds of analog watchdog
  5429. * instance:
  5430. * - AWD standard (instance AWD1):
  5431. * - channels monitored: can monitor 1 channel or all channels.
  5432. * - groups monitored: ADC groups regular and-or injected.
  5433. * - resolution: resolution is not limited (corresponds to
  5434. * ADC resolution configured).
  5435. * - AWD flexible (instances AWD2, AWD3):
  5436. * - channels monitored: flexible on channels monitored, selection is
  5437. * channel wise, from from 1 to all channels.
  5438. * Specificity of this analog watchdog: Multiple channels can
  5439. * be selected. For example:
  5440. * (LL_ADC_AWD_CHANNEL4_REG_INJ | LL_ADC_AWD_CHANNEL5_REG_INJ | ...)
  5441. * - groups monitored: not selection possible (monitoring on both
  5442. * groups regular and injected).
  5443. * Channels selected are monitored on groups regular and injected:
  5444. * LL_ADC_AWD_CHANNELxx_REG_INJ (do not use parameters
  5445. * LL_ADC_AWD_CHANNELxx_REG and LL_ADC_AWD_CHANNELxx_INJ)
  5446. * - resolution: resolution is limited to 8 bits: if ADC resolution is
  5447. * 12 bits the 4 LSB are ignored, if ADC resolution is 10 bits
  5448. * the 2 LSB are ignored.
  5449. * @note On this STM32 series, setting of this feature is conditioned to
  5450. * ADC state:
  5451. * ADC must be disabled or enabled without conversion on going
  5452. * on either groups regular or injected.
  5453. * @rmtoll CFGR AWD1CH LL_ADC_SetAnalogWDMonitChannels\n
  5454. * CFGR AWD1SGL LL_ADC_SetAnalogWDMonitChannels\n
  5455. * CFGR AWD1EN LL_ADC_SetAnalogWDMonitChannels\n
  5456. * CFGR JAWD1EN LL_ADC_SetAnalogWDMonitChannels\n
  5457. * AWD2CR AWD2CH LL_ADC_SetAnalogWDMonitChannels\n
  5458. * AWD3CR AWD3CH LL_ADC_SetAnalogWDMonitChannels
  5459. * @param ADCx ADC instance
  5460. * @param AWDy This parameter can be one of the following values:
  5461. * @arg @ref LL_ADC_AWD1
  5462. * @arg @ref LL_ADC_AWD2
  5463. * @arg @ref LL_ADC_AWD3
  5464. * @param AWDChannelGroup This parameter can be one of the following values:
  5465. * @arg @ref LL_ADC_AWD_DISABLE
  5466. * @arg @ref LL_ADC_AWD_ALL_CHANNELS_REG (0)
  5467. * @arg @ref LL_ADC_AWD_ALL_CHANNELS_INJ (0)
  5468. * @arg @ref LL_ADC_AWD_ALL_CHANNELS_REG_INJ
  5469. * @arg @ref LL_ADC_AWD_CHANNEL_0_REG (0)
  5470. * @arg @ref LL_ADC_AWD_CHANNEL_0_INJ (0)
  5471. * @arg @ref LL_ADC_AWD_CHANNEL_0_REG_INJ
  5472. * @arg @ref LL_ADC_AWD_CHANNEL_1_REG (0)
  5473. * @arg @ref LL_ADC_AWD_CHANNEL_1_INJ (0)
  5474. * @arg @ref LL_ADC_AWD_CHANNEL_1_REG_INJ
  5475. * @arg @ref LL_ADC_AWD_CHANNEL_2_REG (0)
  5476. * @arg @ref LL_ADC_AWD_CHANNEL_2_INJ (0)
  5477. * @arg @ref LL_ADC_AWD_CHANNEL_2_REG_INJ
  5478. * @arg @ref LL_ADC_AWD_CHANNEL_3_REG (0)
  5479. * @arg @ref LL_ADC_AWD_CHANNEL_3_INJ (0)
  5480. * @arg @ref LL_ADC_AWD_CHANNEL_3_REG_INJ
  5481. * @arg @ref LL_ADC_AWD_CHANNEL_4_REG (0)
  5482. * @arg @ref LL_ADC_AWD_CHANNEL_4_INJ (0)
  5483. * @arg @ref LL_ADC_AWD_CHANNEL_4_REG_INJ
  5484. * @arg @ref LL_ADC_AWD_CHANNEL_5_REG (0)
  5485. * @arg @ref LL_ADC_AWD_CHANNEL_5_INJ (0)
  5486. * @arg @ref LL_ADC_AWD_CHANNEL_5_REG_INJ
  5487. * @arg @ref LL_ADC_AWD_CHANNEL_6_REG (0)
  5488. * @arg @ref LL_ADC_AWD_CHANNEL_6_INJ (0)
  5489. * @arg @ref LL_ADC_AWD_CHANNEL_6_REG_INJ
  5490. * @arg @ref LL_ADC_AWD_CHANNEL_7_REG (0)
  5491. * @arg @ref LL_ADC_AWD_CHANNEL_7_INJ (0)
  5492. * @arg @ref LL_ADC_AWD_CHANNEL_7_REG_INJ
  5493. * @arg @ref LL_ADC_AWD_CHANNEL_8_REG (0)
  5494. * @arg @ref LL_ADC_AWD_CHANNEL_8_INJ (0)
  5495. * @arg @ref LL_ADC_AWD_CHANNEL_8_REG_INJ
  5496. * @arg @ref LL_ADC_AWD_CHANNEL_9_REG (0)
  5497. * @arg @ref LL_ADC_AWD_CHANNEL_9_INJ (0)
  5498. * @arg @ref LL_ADC_AWD_CHANNEL_9_REG_INJ
  5499. * @arg @ref LL_ADC_AWD_CHANNEL_10_REG (0)
  5500. * @arg @ref LL_ADC_AWD_CHANNEL_10_INJ (0)
  5501. * @arg @ref LL_ADC_AWD_CHANNEL_10_REG_INJ
  5502. * @arg @ref LL_ADC_AWD_CHANNEL_11_REG (0)
  5503. * @arg @ref LL_ADC_AWD_CHANNEL_11_INJ (0)
  5504. * @arg @ref LL_ADC_AWD_CHANNEL_11_REG_INJ
  5505. * @arg @ref LL_ADC_AWD_CHANNEL_12_REG (0)
  5506. * @arg @ref LL_ADC_AWD_CHANNEL_12_INJ (0)
  5507. * @arg @ref LL_ADC_AWD_CHANNEL_12_REG_INJ
  5508. * @arg @ref LL_ADC_AWD_CHANNEL_13_REG (0)
  5509. * @arg @ref LL_ADC_AWD_CHANNEL_13_INJ (0)
  5510. * @arg @ref LL_ADC_AWD_CHANNEL_13_REG_INJ
  5511. * @arg @ref LL_ADC_AWD_CHANNEL_14_REG (0)
  5512. * @arg @ref LL_ADC_AWD_CHANNEL_14_INJ (0)
  5513. * @arg @ref LL_ADC_AWD_CHANNEL_14_REG_INJ
  5514. * @arg @ref LL_ADC_AWD_CHANNEL_15_REG (0)
  5515. * @arg @ref LL_ADC_AWD_CHANNEL_15_INJ (0)
  5516. * @arg @ref LL_ADC_AWD_CHANNEL_15_REG_INJ
  5517. * @arg @ref LL_ADC_AWD_CHANNEL_16_REG (0)
  5518. * @arg @ref LL_ADC_AWD_CHANNEL_16_INJ (0)
  5519. * @arg @ref LL_ADC_AWD_CHANNEL_16_REG_INJ
  5520. * @arg @ref LL_ADC_AWD_CHANNEL_17_REG (0)
  5521. * @arg @ref LL_ADC_AWD_CHANNEL_17_INJ (0)
  5522. * @arg @ref LL_ADC_AWD_CHANNEL_17_REG_INJ
  5523. * @arg @ref LL_ADC_AWD_CHANNEL_18_REG (0)
  5524. * @arg @ref LL_ADC_AWD_CHANNEL_18_INJ (0)
  5525. * @arg @ref LL_ADC_AWD_CHANNEL_18_REG_INJ
  5526. * @arg @ref LL_ADC_AWD_CH_VREFINT_REG (0)(1)
  5527. * @arg @ref LL_ADC_AWD_CH_VREFINT_INJ (0)(1)
  5528. * @arg @ref LL_ADC_AWD_CH_VREFINT_REG_INJ (1)
  5529. * @arg @ref LL_ADC_AWD_CH_TEMPSENSOR_REG (0)(4)
  5530. * @arg @ref LL_ADC_AWD_CH_TEMPSENSOR_INJ (0)(4)
  5531. * @arg @ref LL_ADC_AWD_CH_TEMPSENSOR_REG_INJ (4)
  5532. * @arg @ref LL_ADC_AWD_CH_VBAT_REG (0)(4)
  5533. * @arg @ref LL_ADC_AWD_CH_VBAT_INJ (0)(4)
  5534. * @arg @ref LL_ADC_AWD_CH_VBAT_REG_INJ (4)
  5535. * @arg @ref LL_ADC_AWD_CH_DAC1CH1_REG (0)(2)(5)
  5536. * @arg @ref LL_ADC_AWD_CH_DAC1CH1_INJ (0)(2)(5)
  5537. * @arg @ref LL_ADC_AWD_CH_DAC1CH1_REG_INJ (2)(5)
  5538. * @arg @ref LL_ADC_AWD_CH_DAC1CH2_REG (0)(2)(5)
  5539. * @arg @ref LL_ADC_AWD_CH_DAC1CH2_INJ (0)(2)(5)
  5540. * @arg @ref LL_ADC_AWD_CH_DAC1CH2_REG_INJ (2)(5)
  5541. * @arg @ref LL_ADC_AWD_CH_DAC1CH1_ADC2_REG (0)(2)(6)
  5542. * @arg @ref LL_ADC_AWD_CH_DAC1CH1_ADC2_INJ (0)(2)(6)
  5543. * @arg @ref LL_ADC_AWD_CH_DAC1CH1_ADC2_REG_INJ (2)(6)
  5544. * @arg @ref LL_ADC_AWD_CH_DAC1CH2_ADC2_REG (0)(2)(6)
  5545. * @arg @ref LL_ADC_AWD_CH_DAC1CH2_ADC2_INJ (0)(2)(6)
  5546. * @arg @ref LL_ADC_AWD_CH_DAC1CH2_ADC2_REG_INJ (2)(6)
  5547. * @arg @ref LL_ADC_AWD_CH_DAC1CH1_ADC3_REG (0)(3)(6)
  5548. * @arg @ref LL_ADC_AWD_CH_DAC1CH1_ADC3_INJ (0)(3)(6)
  5549. * @arg @ref LL_ADC_AWD_CH_DAC1CH1_ADC3_REG_INJ (3)(6)
  5550. * @arg @ref LL_ADC_AWD_CH_DAC1CH2_ADC3_REG (0)(3)(6)
  5551. * @arg @ref LL_ADC_AWD_CH_DAC1CH2_ADC3_INJ (0)(3)(6)
  5552. * @arg @ref LL_ADC_AWD_CH_DAC1CH2_ADC3_REG_INJ (3)(6)
  5553. *
  5554. * (0) On STM32L4, parameter available only on analog watchdog number: AWD1.\n
  5555. * (1) On STM32L4, parameter available only on ADC instance: ADC1.\n
  5556. * (2) On STM32L4, parameter available only on ADC instance: ADC2.\n
  5557. * (3) On STM32L4, parameter available only on ADC instance: ADC3.\n
  5558. * (4) On STM32L4, parameter available only on ADC instances: ADC1, ADC3.
  5559. * (5) On STM32L4, parameter available on devices with only 1 ADC instance.\n
  5560. * (6) On STM32L4, parameter available on devices with several ADC instances.
  5561. * @retval None
  5562. */
  5563. __STATIC_INLINE void LL_ADC_SetAnalogWDMonitChannels(ADC_TypeDef *ADCx, uint32_t AWDy, uint32_t AWDChannelGroup)
  5564. {
  5565. /* Set bits with content of parameter "AWDChannelGroup" with bits position */
  5566. /* in register and register position depending on parameter "AWDy". */
  5567. /* Parameters "AWDChannelGroup" and "AWDy" are used with masks because */
  5568. /* containing other bits reserved for other purpose. */
  5569. __IO uint32_t *preg = __ADC_PTR_REG_OFFSET(ADCx->CFGR,
  5570. ((AWDy & ADC_AWD_CRX_REGOFFSET_MASK) >> ADC_AWD_CRX_REGOFFSET_POS)
  5571. + ((AWDy & ADC_AWD_CR12_REGOFFSETGAP_MASK)
  5572. * ADC_AWD_CR12_REGOFFSETGAP_VAL));
  5573. MODIFY_REG(*preg,
  5574. (AWDy & ADC_AWD_CR_ALL_CHANNEL_MASK),
  5575. AWDChannelGroup & AWDy);
  5576. }
  5577. /**
  5578. * @brief Get ADC analog watchdog monitored channel.
  5579. * @note Usage of the returned channel number:
  5580. * - To reinject this channel into another function LL_ADC_xxx:
  5581. * the returned channel number is only partly formatted on definition
  5582. * of literals LL_ADC_CHANNEL_x. Therefore, it has to be compared
  5583. * with parts of literals LL_ADC_CHANNEL_x or using
  5584. * helper macro @ref __LL_ADC_CHANNEL_TO_DECIMAL_NB().
  5585. * Then the selected literal LL_ADC_CHANNEL_x can be used
  5586. * as parameter for another function.
  5587. * - To get the channel number in decimal format:
  5588. * process the returned value with the helper macro
  5589. * @ref __LL_ADC_CHANNEL_TO_DECIMAL_NB().
  5590. * Applicable only when the analog watchdog is set to monitor
  5591. * one channel.
  5592. * @note On this STM32 series, there are 2 kinds of analog watchdog
  5593. * instance:
  5594. * - AWD standard (instance AWD1):
  5595. * - channels monitored: can monitor 1 channel or all channels.
  5596. * - groups monitored: ADC groups regular and-or injected.
  5597. * - resolution: resolution is not limited (corresponds to
  5598. * ADC resolution configured).
  5599. * - AWD flexible (instances AWD2, AWD3):
  5600. * - channels monitored: flexible on channels monitored, selection is
  5601. * channel wise, from from 1 to all channels.
  5602. * Specificity of this analog watchdog: Multiple channels can
  5603. * be selected. For example:
  5604. * (LL_ADC_AWD_CHANNEL4_REG_INJ | LL_ADC_AWD_CHANNEL5_REG_INJ | ...)
  5605. * - groups monitored: not selection possible (monitoring on both
  5606. * groups regular and injected).
  5607. * Channels selected are monitored on groups regular and injected:
  5608. * LL_ADC_AWD_CHANNELxx_REG_INJ (do not use parameters
  5609. * LL_ADC_AWD_CHANNELxx_REG and LL_ADC_AWD_CHANNELxx_INJ)
  5610. * - resolution: resolution is limited to 8 bits: if ADC resolution is
  5611. * 12 bits the 4 LSB are ignored, if ADC resolution is 10 bits
  5612. * the 2 LSB are ignored.
  5613. * @note On this STM32 series, setting of this feature is conditioned to
  5614. * ADC state:
  5615. * ADC must be disabled or enabled without conversion on going
  5616. * on either groups regular or injected.
  5617. * @rmtoll CFGR AWD1CH LL_ADC_GetAnalogWDMonitChannels\n
  5618. * CFGR AWD1SGL LL_ADC_GetAnalogWDMonitChannels\n
  5619. * CFGR AWD1EN LL_ADC_GetAnalogWDMonitChannels\n
  5620. * CFGR JAWD1EN LL_ADC_GetAnalogWDMonitChannels\n
  5621. * AWD2CR AWD2CH LL_ADC_GetAnalogWDMonitChannels\n
  5622. * AWD3CR AWD3CH LL_ADC_GetAnalogWDMonitChannels
  5623. * @param ADCx ADC instance
  5624. * @param AWDy This parameter can be one of the following values:
  5625. * @arg @ref LL_ADC_AWD1
  5626. * @arg @ref LL_ADC_AWD2 (1)
  5627. * @arg @ref LL_ADC_AWD3 (1)
  5628. *
  5629. * (1) On this AWD number, monitored channel can be retrieved
  5630. * if only 1 channel is programmed (or none or all channels).
  5631. * This function cannot retrieve monitored channel if
  5632. * multiple channels are programmed simultaneously
  5633. * by bitfield.
  5634. * @retval Returned value can be one of the following values:
  5635. * @arg @ref LL_ADC_AWD_DISABLE
  5636. * @arg @ref LL_ADC_AWD_ALL_CHANNELS_REG (0)
  5637. * @arg @ref LL_ADC_AWD_ALL_CHANNELS_INJ (0)
  5638. * @arg @ref LL_ADC_AWD_ALL_CHANNELS_REG_INJ
  5639. * @arg @ref LL_ADC_AWD_CHANNEL_0_REG (0)
  5640. * @arg @ref LL_ADC_AWD_CHANNEL_0_INJ (0)
  5641. * @arg @ref LL_ADC_AWD_CHANNEL_0_REG_INJ
  5642. * @arg @ref LL_ADC_AWD_CHANNEL_1_REG (0)
  5643. * @arg @ref LL_ADC_AWD_CHANNEL_1_INJ (0)
  5644. * @arg @ref LL_ADC_AWD_CHANNEL_1_REG_INJ
  5645. * @arg @ref LL_ADC_AWD_CHANNEL_2_REG (0)
  5646. * @arg @ref LL_ADC_AWD_CHANNEL_2_INJ (0)
  5647. * @arg @ref LL_ADC_AWD_CHANNEL_2_REG_INJ
  5648. * @arg @ref LL_ADC_AWD_CHANNEL_3_REG (0)
  5649. * @arg @ref LL_ADC_AWD_CHANNEL_3_INJ (0)
  5650. * @arg @ref LL_ADC_AWD_CHANNEL_3_REG_INJ
  5651. * @arg @ref LL_ADC_AWD_CHANNEL_4_REG (0)
  5652. * @arg @ref LL_ADC_AWD_CHANNEL_4_INJ (0)
  5653. * @arg @ref LL_ADC_AWD_CHANNEL_4_REG_INJ
  5654. * @arg @ref LL_ADC_AWD_CHANNEL_5_REG (0)
  5655. * @arg @ref LL_ADC_AWD_CHANNEL_5_INJ (0)
  5656. * @arg @ref LL_ADC_AWD_CHANNEL_5_REG_INJ
  5657. * @arg @ref LL_ADC_AWD_CHANNEL_6_REG (0)
  5658. * @arg @ref LL_ADC_AWD_CHANNEL_6_INJ (0)
  5659. * @arg @ref LL_ADC_AWD_CHANNEL_6_REG_INJ
  5660. * @arg @ref LL_ADC_AWD_CHANNEL_7_REG (0)
  5661. * @arg @ref LL_ADC_AWD_CHANNEL_7_INJ (0)
  5662. * @arg @ref LL_ADC_AWD_CHANNEL_7_REG_INJ
  5663. * @arg @ref LL_ADC_AWD_CHANNEL_8_REG (0)
  5664. * @arg @ref LL_ADC_AWD_CHANNEL_8_INJ (0)
  5665. * @arg @ref LL_ADC_AWD_CHANNEL_8_REG_INJ
  5666. * @arg @ref LL_ADC_AWD_CHANNEL_9_REG (0)
  5667. * @arg @ref LL_ADC_AWD_CHANNEL_9_INJ (0)
  5668. * @arg @ref LL_ADC_AWD_CHANNEL_9_REG_INJ
  5669. * @arg @ref LL_ADC_AWD_CHANNEL_10_REG (0)
  5670. * @arg @ref LL_ADC_AWD_CHANNEL_10_INJ (0)
  5671. * @arg @ref LL_ADC_AWD_CHANNEL_10_REG_INJ
  5672. * @arg @ref LL_ADC_AWD_CHANNEL_11_REG (0)
  5673. * @arg @ref LL_ADC_AWD_CHANNEL_11_INJ (0)
  5674. * @arg @ref LL_ADC_AWD_CHANNEL_11_REG_INJ
  5675. * @arg @ref LL_ADC_AWD_CHANNEL_12_REG (0)
  5676. * @arg @ref LL_ADC_AWD_CHANNEL_12_INJ (0)
  5677. * @arg @ref LL_ADC_AWD_CHANNEL_12_REG_INJ
  5678. * @arg @ref LL_ADC_AWD_CHANNEL_13_REG (0)
  5679. * @arg @ref LL_ADC_AWD_CHANNEL_13_INJ (0)
  5680. * @arg @ref LL_ADC_AWD_CHANNEL_13_REG_INJ
  5681. * @arg @ref LL_ADC_AWD_CHANNEL_14_REG (0)
  5682. * @arg @ref LL_ADC_AWD_CHANNEL_14_INJ (0)
  5683. * @arg @ref LL_ADC_AWD_CHANNEL_14_REG_INJ
  5684. * @arg @ref LL_ADC_AWD_CHANNEL_15_REG (0)
  5685. * @arg @ref LL_ADC_AWD_CHANNEL_15_INJ (0)
  5686. * @arg @ref LL_ADC_AWD_CHANNEL_15_REG_INJ
  5687. * @arg @ref LL_ADC_AWD_CHANNEL_16_REG (0)
  5688. * @arg @ref LL_ADC_AWD_CHANNEL_16_INJ (0)
  5689. * @arg @ref LL_ADC_AWD_CHANNEL_16_REG_INJ
  5690. * @arg @ref LL_ADC_AWD_CHANNEL_17_REG (0)
  5691. * @arg @ref LL_ADC_AWD_CHANNEL_17_INJ (0)
  5692. * @arg @ref LL_ADC_AWD_CHANNEL_17_REG_INJ
  5693. * @arg @ref LL_ADC_AWD_CHANNEL_18_REG (0)
  5694. * @arg @ref LL_ADC_AWD_CHANNEL_18_INJ (0)
  5695. * @arg @ref LL_ADC_AWD_CHANNEL_18_REG_INJ
  5696. *
  5697. * (0) On STM32L4, parameter available only on analog watchdog number: AWD1.
  5698. */
  5699. __STATIC_INLINE uint32_t LL_ADC_GetAnalogWDMonitChannels(const ADC_TypeDef *ADCx, uint32_t AWDy)
  5700. {
  5701. const __IO uint32_t *preg = __ADC_PTR_REG_OFFSET(ADCx->CFGR,
  5702. ((AWDy & ADC_AWD_CRX_REGOFFSET_MASK) >> ADC_AWD_CRX_REGOFFSET_POS)
  5703. + ((AWDy & ADC_AWD_CR12_REGOFFSETGAP_MASK)
  5704. * ADC_AWD_CR12_REGOFFSETGAP_VAL));
  5705. uint32_t analog_wd_monit_channels = (READ_BIT(*preg, AWDy) & AWDy & ADC_AWD_CR_ALL_CHANNEL_MASK);
  5706. /* If "analog_wd_monit_channels" == 0, then the selected AWD is disabled */
  5707. /* (parameter value LL_ADC_AWD_DISABLE). */
  5708. /* Else, the selected AWD is enabled and is monitoring a group of channels */
  5709. /* or a single channel. */
  5710. if (analog_wd_monit_channels != 0UL)
  5711. {
  5712. if (AWDy == LL_ADC_AWD1)
  5713. {
  5714. if ((analog_wd_monit_channels & ADC_CFGR_AWD1SGL) == 0UL)
  5715. {
  5716. /* AWD monitoring a group of channels */
  5717. analog_wd_monit_channels = ((analog_wd_monit_channels
  5718. | (ADC_AWD_CR23_CHANNEL_MASK)
  5719. )
  5720. & (~(ADC_CFGR_AWD1CH))
  5721. );
  5722. }
  5723. else
  5724. {
  5725. /* AWD monitoring a single channel */
  5726. analog_wd_monit_channels = (analog_wd_monit_channels
  5727. | (ADC_AWD2CR_AWD2CH_0 << (analog_wd_monit_channels >> ADC_CFGR_AWD1CH_Pos))
  5728. );
  5729. }
  5730. }
  5731. else
  5732. {
  5733. if ((analog_wd_monit_channels & ADC_AWD_CR23_CHANNEL_MASK) == ADC_AWD_CR23_CHANNEL_MASK)
  5734. {
  5735. /* AWD monitoring a group of channels */
  5736. analog_wd_monit_channels = (ADC_AWD_CR23_CHANNEL_MASK
  5737. | ((ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1EN))
  5738. );
  5739. }
  5740. else
  5741. {
  5742. /* AWD monitoring a single channel */
  5743. /* AWD monitoring a group of channels */
  5744. analog_wd_monit_channels = (analog_wd_monit_channels
  5745. | (ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1EN | ADC_CFGR_AWD1SGL)
  5746. | (__LL_ADC_CHANNEL_TO_DECIMAL_NB(analog_wd_monit_channels) << ADC_CFGR_AWD1CH_Pos)
  5747. );
  5748. }
  5749. }
  5750. }
  5751. return analog_wd_monit_channels;
  5752. }
  5753. /**
  5754. * @brief Set ADC analog watchdog thresholds value of both thresholds
  5755. * high and low.
  5756. * @note If value of only one threshold high or low must be set,
  5757. * use function @ref LL_ADC_SetAnalogWDThresholds().
  5758. * @note In case of ADC resolution different of 12 bits,
  5759. * analog watchdog thresholds data require a specific shift.
  5760. * Use helper macro @ref __LL_ADC_ANALOGWD_SET_THRESHOLD_RESOLUTION().
  5761. * @note On this STM32 series, there are 2 kinds of analog watchdog
  5762. * instance:
  5763. * - AWD standard (instance AWD1):
  5764. * - channels monitored: can monitor 1 channel or all channels.
  5765. * - groups monitored: ADC groups regular and-or injected.
  5766. * - resolution: resolution is not limited (corresponds to
  5767. * ADC resolution configured).
  5768. * - AWD flexible (instances AWD2, AWD3):
  5769. * - channels monitored: flexible on channels monitored, selection is
  5770. * channel wise, from from 1 to all channels.
  5771. * Specificity of this analog watchdog: Multiple channels can
  5772. * be selected. For example:
  5773. * (LL_ADC_AWD_CHANNEL4_REG_INJ | LL_ADC_AWD_CHANNEL5_REG_INJ | ...)
  5774. * - groups monitored: not selection possible (monitoring on both
  5775. * groups regular and injected).
  5776. * Channels selected are monitored on groups regular and injected:
  5777. * LL_ADC_AWD_CHANNELxx_REG_INJ (do not use parameters
  5778. * LL_ADC_AWD_CHANNELxx_REG and LL_ADC_AWD_CHANNELxx_INJ)
  5779. * - resolution: resolution is limited to 8 bits: if ADC resolution is
  5780. * 12 bits the 4 LSB are ignored, if ADC resolution is 10 bits
  5781. * the 2 LSB are ignored.
  5782. * @note If ADC oversampling is enabled, ADC analog watchdog thresholds are
  5783. * impacted: the comparison of analog watchdog thresholds is done on
  5784. * oversampling final computation (after ratio and shift application):
  5785. * ADC data register bitfield [15:4] (12 most significant bits).
  5786. * Examples:
  5787. * - Oversampling ratio and shift selected to have ADC conversion data
  5788. * on 12 bits (ratio 16 and shift 4, or ratio 32 and shift 5, ...):
  5789. * ADC analog watchdog thresholds must be divided by 16.
  5790. * - Oversampling ratio and shift selected to have ADC conversion data
  5791. * on 14 bits (ratio 16 and shift 2, or ratio 32 and shift 3, ...):
  5792. * ADC analog watchdog thresholds must be divided by 4.
  5793. * - Oversampling ratio and shift selected to have ADC conversion data
  5794. * on 16 bits (ratio 16 and shift none, or ratio 32 and shift 1, ...):
  5795. * ADC analog watchdog thresholds match directly to ADC data register.
  5796. * @note On this STM32 series, setting of this feature is conditioned to
  5797. * ADC state:
  5798. * ADC must be disabled or enabled without conversion on going
  5799. * on either groups regular or injected.
  5800. * @rmtoll TR1 HT1 LL_ADC_ConfigAnalogWDThresholds\n
  5801. * TR2 HT2 LL_ADC_ConfigAnalogWDThresholds\n
  5802. * TR3 HT3 LL_ADC_ConfigAnalogWDThresholds\n
  5803. * TR1 LT1 LL_ADC_ConfigAnalogWDThresholds\n
  5804. * TR2 LT2 LL_ADC_ConfigAnalogWDThresholds\n
  5805. * TR3 LT3 LL_ADC_ConfigAnalogWDThresholds
  5806. * @param ADCx ADC instance
  5807. * @param AWDy This parameter can be one of the following values:
  5808. * @arg @ref LL_ADC_AWD1
  5809. * @arg @ref LL_ADC_AWD2
  5810. * @arg @ref LL_ADC_AWD3
  5811. * @param AWDThresholdHighValue Value between Min_Data=0x000 and Max_Data=0xFFF
  5812. * @param AWDThresholdLowValue Value between Min_Data=0x000 and Max_Data=0xFFF
  5813. * @retval None
  5814. */
  5815. __STATIC_INLINE void LL_ADC_ConfigAnalogWDThresholds(ADC_TypeDef *ADCx, uint32_t AWDy, uint32_t AWDThresholdHighValue,
  5816. uint32_t AWDThresholdLowValue)
  5817. {
  5818. /* Set bits with content of parameter "AWDThresholdxxxValue" with bits */
  5819. /* position in register and register position depending on parameter */
  5820. /* "AWDy". */
  5821. /* Parameters "AWDy" and "AWDThresholdxxxValue" are used with masks because */
  5822. /* containing other bits reserved for other purpose. */
  5823. __IO uint32_t *preg = __ADC_PTR_REG_OFFSET(ADCx->TR1,
  5824. ((AWDy & ADC_AWD_TRX_REGOFFSET_MASK) >> ADC_AWD_TRX_REGOFFSET_POS));
  5825. MODIFY_REG(*preg,
  5826. ADC_TR1_HT1 | ADC_TR1_LT1,
  5827. (AWDThresholdHighValue << ADC_TR1_HT1_BITOFFSET_POS) | AWDThresholdLowValue);
  5828. }
  5829. /**
  5830. * @brief Set ADC analog watchdog threshold value of threshold
  5831. * high or low.
  5832. * @note If values of both thresholds high or low must be set,
  5833. * use function @ref LL_ADC_ConfigAnalogWDThresholds().
  5834. * @note In case of ADC resolution different of 12 bits,
  5835. * analog watchdog thresholds data require a specific shift.
  5836. * Use helper macro @ref __LL_ADC_ANALOGWD_SET_THRESHOLD_RESOLUTION().
  5837. * @note On this STM32 series, there are 2 kinds of analog watchdog
  5838. * instance:
  5839. * - AWD standard (instance AWD1):
  5840. * - channels monitored: can monitor 1 channel or all channels.
  5841. * - groups monitored: ADC groups regular and-or injected.
  5842. * - resolution: resolution is not limited (corresponds to
  5843. * ADC resolution configured).
  5844. * - AWD flexible (instances AWD2, AWD3):
  5845. * - channels monitored: flexible on channels monitored, selection is
  5846. * channel wise, from from 1 to all channels.
  5847. * Specificity of this analog watchdog: Multiple channels can
  5848. * be selected. For example:
  5849. * (LL_ADC_AWD_CHANNEL4_REG_INJ | LL_ADC_AWD_CHANNEL5_REG_INJ | ...)
  5850. * - groups monitored: not selection possible (monitoring on both
  5851. * groups regular and injected).
  5852. * Channels selected are monitored on groups regular and injected:
  5853. * LL_ADC_AWD_CHANNELxx_REG_INJ (do not use parameters
  5854. * LL_ADC_AWD_CHANNELxx_REG and LL_ADC_AWD_CHANNELxx_INJ)
  5855. * - resolution: resolution is limited to 8 bits: if ADC resolution is
  5856. * 12 bits the 4 LSB are ignored, if ADC resolution is 10 bits
  5857. * the 2 LSB are ignored.
  5858. * @note If ADC oversampling is enabled, ADC analog watchdog thresholds are
  5859. * impacted: the comparison of analog watchdog thresholds is done on
  5860. * oversampling final computation (after ratio and shift application):
  5861. * ADC data register bitfield [15:4] (12 most significant bits).
  5862. * Examples:
  5863. * - Oversampling ratio and shift selected to have ADC conversion data
  5864. * on 12 bits (ratio 16 and shift 4, or ratio 32 and shift 5, ...):
  5865. * ADC analog watchdog thresholds must be divided by 16.
  5866. * - Oversampling ratio and shift selected to have ADC conversion data
  5867. * on 14 bits (ratio 16 and shift 2, or ratio 32 and shift 3, ...):
  5868. * ADC analog watchdog thresholds must be divided by 4.
  5869. * - Oversampling ratio and shift selected to have ADC conversion data
  5870. * on 16 bits (ratio 16 and shift none, or ratio 32 and shift 1, ...):
  5871. * ADC analog watchdog thresholds match directly to ADC data register.
  5872. * @note On this STM32 series, setting of this feature is conditioned to
  5873. * ADC state:
  5874. * ADC must be disabled or enabled without conversion on going
  5875. * on either ADC groups regular or injected.
  5876. * @rmtoll TR1 HT1 LL_ADC_SetAnalogWDThresholds\n
  5877. * TR2 HT2 LL_ADC_SetAnalogWDThresholds\n
  5878. * TR3 HT3 LL_ADC_SetAnalogWDThresholds\n
  5879. * TR1 LT1 LL_ADC_SetAnalogWDThresholds\n
  5880. * TR2 LT2 LL_ADC_SetAnalogWDThresholds\n
  5881. * TR3 LT3 LL_ADC_SetAnalogWDThresholds
  5882. * @param ADCx ADC instance
  5883. * @param AWDy This parameter can be one of the following values:
  5884. * @arg @ref LL_ADC_AWD1
  5885. * @arg @ref LL_ADC_AWD2
  5886. * @arg @ref LL_ADC_AWD3
  5887. * @param AWDThresholdsHighLow This parameter can be one of the following values:
  5888. * @arg @ref LL_ADC_AWD_THRESHOLD_HIGH
  5889. * @arg @ref LL_ADC_AWD_THRESHOLD_LOW
  5890. * @param AWDThresholdValue Value between Min_Data=0x000 and Max_Data=0xFFF
  5891. * @retval None
  5892. */
  5893. __STATIC_INLINE void LL_ADC_SetAnalogWDThresholds(ADC_TypeDef *ADCx, uint32_t AWDy, uint32_t AWDThresholdsHighLow,
  5894. uint32_t AWDThresholdValue)
  5895. {
  5896. /* Set bits with content of parameter "AWDThresholdValue" with bits */
  5897. /* position in register and register position depending on parameters */
  5898. /* "AWDThresholdsHighLow" and "AWDy". */
  5899. /* Parameters "AWDy" and "AWDThresholdValue" are used with masks because */
  5900. /* containing other bits reserved for other purpose. */
  5901. __IO uint32_t *preg = __ADC_PTR_REG_OFFSET(ADCx->TR1,
  5902. ((AWDy & ADC_AWD_TRX_REGOFFSET_MASK) >> ADC_AWD_TRX_REGOFFSET_POS));
  5903. MODIFY_REG(*preg,
  5904. AWDThresholdsHighLow,
  5905. AWDThresholdValue << ((AWDThresholdsHighLow & ADC_AWD_TRX_BIT_HIGH_MASK) >> ADC_AWD_TRX_BIT_HIGH_SHIFT4));
  5906. }
  5907. /**
  5908. * @brief Get ADC analog watchdog threshold value of threshold high,
  5909. * threshold low or raw data with ADC thresholds high and low
  5910. * concatenated.
  5911. * @note If raw data with ADC thresholds high and low is retrieved,
  5912. * the data of each threshold high or low can be isolated
  5913. * using helper macro:
  5914. * @ref __LL_ADC_ANALOGWD_THRESHOLDS_HIGH_LOW().
  5915. * @note In case of ADC resolution different of 12 bits,
  5916. * analog watchdog thresholds data require a specific shift.
  5917. * Use helper macro @ref __LL_ADC_ANALOGWD_GET_THRESHOLD_RESOLUTION().
  5918. * @rmtoll TR1 HT1 LL_ADC_GetAnalogWDThresholds\n
  5919. * TR2 HT2 LL_ADC_GetAnalogWDThresholds\n
  5920. * TR3 HT3 LL_ADC_GetAnalogWDThresholds\n
  5921. * TR1 LT1 LL_ADC_GetAnalogWDThresholds\n
  5922. * TR2 LT2 LL_ADC_GetAnalogWDThresholds\n
  5923. * TR3 LT3 LL_ADC_GetAnalogWDThresholds
  5924. * @param ADCx ADC instance
  5925. * @param AWDy This parameter can be one of the following values:
  5926. * @arg @ref LL_ADC_AWD1
  5927. * @arg @ref LL_ADC_AWD2
  5928. * @arg @ref LL_ADC_AWD3
  5929. * @param AWDThresholdsHighLow This parameter can be one of the following values:
  5930. * @arg @ref LL_ADC_AWD_THRESHOLD_HIGH
  5931. * @arg @ref LL_ADC_AWD_THRESHOLD_LOW
  5932. * @arg @ref LL_ADC_AWD_THRESHOLDS_HIGH_LOW
  5933. * @retval Value between Min_Data=0x000 and Max_Data=0xFFF
  5934. */
  5935. __STATIC_INLINE uint32_t LL_ADC_GetAnalogWDThresholds(const ADC_TypeDef *ADCx,
  5936. uint32_t AWDy, uint32_t AWDThresholdsHighLow)
  5937. {
  5938. const __IO uint32_t *preg = __ADC_PTR_REG_OFFSET(ADCx->TR1,
  5939. ((AWDy & ADC_AWD_TRX_REGOFFSET_MASK) >> ADC_AWD_TRX_REGOFFSET_POS));
  5940. return (uint32_t)(READ_BIT(*preg,
  5941. (AWDThresholdsHighLow | ADC_TR1_LT1))
  5942. >> (((AWDThresholdsHighLow & ADC_AWD_TRX_BIT_HIGH_MASK) >> ADC_AWD_TRX_BIT_HIGH_SHIFT4)
  5943. & ~(AWDThresholdsHighLow & ADC_TR1_LT1)));
  5944. }
  5945. /**
  5946. * @}
  5947. */
  5948. /** @defgroup ADC_LL_EF_Configuration_ADC_oversampling Configuration of ADC transversal scope: oversampling
  5949. * @{
  5950. */
  5951. /**
  5952. * @brief Set ADC oversampling scope: ADC groups regular and-or injected
  5953. * (availability of ADC group injected depends on STM32 series).
  5954. * @note If both groups regular and injected are selected,
  5955. * specify behavior of ADC group injected interrupting
  5956. * group regular: when ADC group injected is triggered,
  5957. * the oversampling on ADC group regular is either
  5958. * temporary stopped and continued, or resumed from start
  5959. * (oversampler buffer reset).
  5960. * @note On this STM32 series, setting of this feature is conditioned to
  5961. * ADC state:
  5962. * ADC must be disabled or enabled without conversion on going
  5963. * on either groups regular or injected.
  5964. * @rmtoll CFGR2 ROVSE LL_ADC_SetOverSamplingScope\n
  5965. * CFGR2 JOVSE LL_ADC_SetOverSamplingScope\n
  5966. * CFGR2 ROVSM LL_ADC_SetOverSamplingScope
  5967. * @param ADCx ADC instance
  5968. * @param OvsScope This parameter can be one of the following values:
  5969. * @arg @ref LL_ADC_OVS_DISABLE
  5970. * @arg @ref LL_ADC_OVS_GRP_REGULAR_CONTINUED
  5971. * @arg @ref LL_ADC_OVS_GRP_REGULAR_RESUMED
  5972. * @arg @ref LL_ADC_OVS_GRP_INJECTED
  5973. * @arg @ref LL_ADC_OVS_GRP_INJ_REG_RESUMED
  5974. * @retval None
  5975. */
  5976. __STATIC_INLINE void LL_ADC_SetOverSamplingScope(ADC_TypeDef *ADCx, uint32_t OvsScope)
  5977. {
  5978. MODIFY_REG(ADCx->CFGR2, ADC_CFGR2_ROVSE | ADC_CFGR2_JOVSE | ADC_CFGR2_ROVSM, OvsScope);
  5979. }
  5980. /**
  5981. * @brief Get ADC oversampling scope: ADC groups regular and-or injected
  5982. * (availability of ADC group injected depends on STM32 series).
  5983. * @note If both groups regular and injected are selected,
  5984. * specify behavior of ADC group injected interrupting
  5985. * group regular: when ADC group injected is triggered,
  5986. * the oversampling on ADC group regular is either
  5987. * temporary stopped and continued, or resumed from start
  5988. * (oversampler buffer reset).
  5989. * @rmtoll CFGR2 ROVSE LL_ADC_GetOverSamplingScope\n
  5990. * CFGR2 JOVSE LL_ADC_GetOverSamplingScope\n
  5991. * CFGR2 ROVSM LL_ADC_GetOverSamplingScope
  5992. * @param ADCx ADC instance
  5993. * @retval Returned value can be one of the following values:
  5994. * @arg @ref LL_ADC_OVS_DISABLE
  5995. * @arg @ref LL_ADC_OVS_GRP_REGULAR_CONTINUED
  5996. * @arg @ref LL_ADC_OVS_GRP_REGULAR_RESUMED
  5997. * @arg @ref LL_ADC_OVS_GRP_INJECTED
  5998. * @arg @ref LL_ADC_OVS_GRP_INJ_REG_RESUMED
  5999. */
  6000. __STATIC_INLINE uint32_t LL_ADC_GetOverSamplingScope(const ADC_TypeDef *ADCx)
  6001. {
  6002. return (uint32_t)(READ_BIT(ADCx->CFGR2, ADC_CFGR2_ROVSE | ADC_CFGR2_JOVSE | ADC_CFGR2_ROVSM));
  6003. }
  6004. /**
  6005. * @brief Set ADC oversampling discontinuous mode (triggered mode)
  6006. * on the selected ADC group.
  6007. * @note Number of oversampled conversions are done either in:
  6008. * - continuous mode (all conversions of oversampling ratio
  6009. * are done from 1 trigger)
  6010. * - discontinuous mode (each conversion of oversampling ratio
  6011. * needs a trigger)
  6012. * @note On this STM32 series, setting of this feature is conditioned to
  6013. * ADC state:
  6014. * ADC must be disabled or enabled without conversion on going
  6015. * on group regular.
  6016. * @note On this STM32 series, oversampling discontinuous mode
  6017. * (triggered mode) can be used only when oversampling is
  6018. * set on group regular only and in resumed mode.
  6019. * @rmtoll CFGR2 TROVS LL_ADC_SetOverSamplingDiscont
  6020. * @param ADCx ADC instance
  6021. * @param OverSamplingDiscont This parameter can be one of the following values:
  6022. * @arg @ref LL_ADC_OVS_REG_CONT
  6023. * @arg @ref LL_ADC_OVS_REG_DISCONT
  6024. * @retval None
  6025. */
  6026. __STATIC_INLINE void LL_ADC_SetOverSamplingDiscont(ADC_TypeDef *ADCx, uint32_t OverSamplingDiscont)
  6027. {
  6028. MODIFY_REG(ADCx->CFGR2, ADC_CFGR2_TROVS, OverSamplingDiscont);
  6029. }
  6030. /**
  6031. * @brief Get ADC oversampling discontinuous mode (triggered mode)
  6032. * on the selected ADC group.
  6033. * @note Number of oversampled conversions are done either in:
  6034. * - continuous mode (all conversions of oversampling ratio
  6035. * are done from 1 trigger)
  6036. * - discontinuous mode (each conversion of oversampling ratio
  6037. * needs a trigger)
  6038. * @rmtoll CFGR2 TROVS LL_ADC_GetOverSamplingDiscont
  6039. * @param ADCx ADC instance
  6040. * @retval Returned value can be one of the following values:
  6041. * @arg @ref LL_ADC_OVS_REG_CONT
  6042. * @arg @ref LL_ADC_OVS_REG_DISCONT
  6043. */
  6044. __STATIC_INLINE uint32_t LL_ADC_GetOverSamplingDiscont(const ADC_TypeDef *ADCx)
  6045. {
  6046. return (uint32_t)(READ_BIT(ADCx->CFGR2, ADC_CFGR2_TROVS));
  6047. }
  6048. /**
  6049. * @brief Set ADC oversampling
  6050. * (impacting both ADC groups regular and injected)
  6051. * @note This function set the 2 items of oversampling configuration:
  6052. * - ratio
  6053. * - shift
  6054. * @note On this STM32 series, setting of this feature is conditioned to
  6055. * ADC state:
  6056. * ADC must be disabled or enabled without conversion on going
  6057. * on either groups regular or injected.
  6058. * @rmtoll CFGR2 OVSS LL_ADC_ConfigOverSamplingRatioShift\n
  6059. * CFGR2 OVSR LL_ADC_ConfigOverSamplingRatioShift
  6060. * @param ADCx ADC instance
  6061. * @param Ratio This parameter can be one of the following values:
  6062. * @arg @ref LL_ADC_OVS_RATIO_2
  6063. * @arg @ref LL_ADC_OVS_RATIO_4
  6064. * @arg @ref LL_ADC_OVS_RATIO_8
  6065. * @arg @ref LL_ADC_OVS_RATIO_16
  6066. * @arg @ref LL_ADC_OVS_RATIO_32
  6067. * @arg @ref LL_ADC_OVS_RATIO_64
  6068. * @arg @ref LL_ADC_OVS_RATIO_128
  6069. * @arg @ref LL_ADC_OVS_RATIO_256
  6070. * @param Shift This parameter can be one of the following values:
  6071. * @arg @ref LL_ADC_OVS_SHIFT_NONE
  6072. * @arg @ref LL_ADC_OVS_SHIFT_RIGHT_1
  6073. * @arg @ref LL_ADC_OVS_SHIFT_RIGHT_2
  6074. * @arg @ref LL_ADC_OVS_SHIFT_RIGHT_3
  6075. * @arg @ref LL_ADC_OVS_SHIFT_RIGHT_4
  6076. * @arg @ref LL_ADC_OVS_SHIFT_RIGHT_5
  6077. * @arg @ref LL_ADC_OVS_SHIFT_RIGHT_6
  6078. * @arg @ref LL_ADC_OVS_SHIFT_RIGHT_7
  6079. * @arg @ref LL_ADC_OVS_SHIFT_RIGHT_8
  6080. * @retval None
  6081. */
  6082. __STATIC_INLINE void LL_ADC_ConfigOverSamplingRatioShift(ADC_TypeDef *ADCx, uint32_t Ratio, uint32_t Shift)
  6083. {
  6084. MODIFY_REG(ADCx->CFGR2, (ADC_CFGR2_OVSS | ADC_CFGR2_OVSR), (Shift | Ratio));
  6085. }
  6086. /**
  6087. * @brief Get ADC oversampling ratio
  6088. * (impacting both ADC groups regular and injected)
  6089. * @rmtoll CFGR2 OVSR LL_ADC_GetOverSamplingRatio
  6090. * @param ADCx ADC instance
  6091. * @retval Ratio This parameter can be one of the following values:
  6092. * @arg @ref LL_ADC_OVS_RATIO_2
  6093. * @arg @ref LL_ADC_OVS_RATIO_4
  6094. * @arg @ref LL_ADC_OVS_RATIO_8
  6095. * @arg @ref LL_ADC_OVS_RATIO_16
  6096. * @arg @ref LL_ADC_OVS_RATIO_32
  6097. * @arg @ref LL_ADC_OVS_RATIO_64
  6098. * @arg @ref LL_ADC_OVS_RATIO_128
  6099. * @arg @ref LL_ADC_OVS_RATIO_256
  6100. */
  6101. __STATIC_INLINE uint32_t LL_ADC_GetOverSamplingRatio(const ADC_TypeDef *ADCx)
  6102. {
  6103. return (uint32_t)(READ_BIT(ADCx->CFGR2, ADC_CFGR2_OVSR));
  6104. }
  6105. /**
  6106. * @brief Get ADC oversampling shift
  6107. * (impacting both ADC groups regular and injected)
  6108. * @rmtoll CFGR2 OVSS LL_ADC_GetOverSamplingShift
  6109. * @param ADCx ADC instance
  6110. * @retval Shift This parameter can be one of the following values:
  6111. * @arg @ref LL_ADC_OVS_SHIFT_NONE
  6112. * @arg @ref LL_ADC_OVS_SHIFT_RIGHT_1
  6113. * @arg @ref LL_ADC_OVS_SHIFT_RIGHT_2
  6114. * @arg @ref LL_ADC_OVS_SHIFT_RIGHT_3
  6115. * @arg @ref LL_ADC_OVS_SHIFT_RIGHT_4
  6116. * @arg @ref LL_ADC_OVS_SHIFT_RIGHT_5
  6117. * @arg @ref LL_ADC_OVS_SHIFT_RIGHT_6
  6118. * @arg @ref LL_ADC_OVS_SHIFT_RIGHT_7
  6119. * @arg @ref LL_ADC_OVS_SHIFT_RIGHT_8
  6120. */
  6121. __STATIC_INLINE uint32_t LL_ADC_GetOverSamplingShift(const ADC_TypeDef *ADCx)
  6122. {
  6123. return (uint32_t)(READ_BIT(ADCx->CFGR2, ADC_CFGR2_OVSS));
  6124. }
  6125. /**
  6126. * @}
  6127. */
  6128. /** @defgroup ADC_LL_EF_Configuration_ADC_Multimode Configuration of ADC hierarchical scope: multimode
  6129. * @{
  6130. */
  6131. #if defined(ADC_MULTIMODE_SUPPORT)
  6132. /**
  6133. * @brief Set ADC multimode configuration to operate in independent mode
  6134. * or multimode (for devices with several ADC instances).
  6135. * @note If multimode configuration: the selected ADC instance is
  6136. * either master or slave depending on hardware.
  6137. * Refer to reference manual.
  6138. * @note On this STM32 series, setting of this feature is conditioned to
  6139. * ADC state:
  6140. * All ADC instances of the ADC common group must be disabled.
  6141. * This check can be done with function @ref LL_ADC_IsEnabled() for each
  6142. * ADC instance or by using helper macro
  6143. * @ref __LL_ADC_IS_ENABLED_ALL_COMMON_INSTANCE().
  6144. * @rmtoll CCR DUAL LL_ADC_SetMultimode
  6145. * @param ADCxy_COMMON ADC common instance
  6146. * (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() )
  6147. * @param Multimode This parameter can be one of the following values:
  6148. * @arg @ref LL_ADC_MULTI_INDEPENDENT
  6149. * @arg @ref LL_ADC_MULTI_DUAL_REG_SIMULT
  6150. * @arg @ref LL_ADC_MULTI_DUAL_REG_INTERL
  6151. * @arg @ref LL_ADC_MULTI_DUAL_INJ_SIMULT
  6152. * @arg @ref LL_ADC_MULTI_DUAL_INJ_ALTERN
  6153. * @arg @ref LL_ADC_MULTI_DUAL_REG_SIM_INJ_SIM
  6154. * @arg @ref LL_ADC_MULTI_DUAL_REG_SIM_INJ_ALT
  6155. * @arg @ref LL_ADC_MULTI_DUAL_REG_INT_INJ_SIM
  6156. * @retval None
  6157. */
  6158. __STATIC_INLINE void LL_ADC_SetMultimode(ADC_Common_TypeDef *ADCxy_COMMON, uint32_t Multimode)
  6159. {
  6160. MODIFY_REG(ADCxy_COMMON->CCR, ADC_CCR_DUAL, Multimode);
  6161. }
  6162. /**
  6163. * @brief Get ADC multimode configuration to operate in independent mode
  6164. * or multimode (for devices with several ADC instances).
  6165. * @note If multimode configuration: the selected ADC instance is
  6166. * either master or slave depending on hardware.
  6167. * Refer to reference manual.
  6168. * @rmtoll CCR DUAL LL_ADC_GetMultimode
  6169. * @param ADCxy_COMMON ADC common instance
  6170. * (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() )
  6171. * @retval Returned value can be one of the following values:
  6172. * @arg @ref LL_ADC_MULTI_INDEPENDENT
  6173. * @arg @ref LL_ADC_MULTI_DUAL_REG_SIMULT
  6174. * @arg @ref LL_ADC_MULTI_DUAL_REG_INTERL
  6175. * @arg @ref LL_ADC_MULTI_DUAL_INJ_SIMULT
  6176. * @arg @ref LL_ADC_MULTI_DUAL_INJ_ALTERN
  6177. * @arg @ref LL_ADC_MULTI_DUAL_REG_SIM_INJ_SIM
  6178. * @arg @ref LL_ADC_MULTI_DUAL_REG_SIM_INJ_ALT
  6179. * @arg @ref LL_ADC_MULTI_DUAL_REG_INT_INJ_SIM
  6180. */
  6181. __STATIC_INLINE uint32_t LL_ADC_GetMultimode(const ADC_Common_TypeDef *ADCxy_COMMON)
  6182. {
  6183. return (uint32_t)(READ_BIT(ADCxy_COMMON->CCR, ADC_CCR_DUAL));
  6184. }
  6185. /**
  6186. * @brief Set ADC multimode conversion data transfer: no transfer
  6187. * or transfer by DMA.
  6188. * @note If ADC multimode transfer by DMA is not selected:
  6189. * each ADC uses its own DMA channel, with its individual
  6190. * DMA transfer settings.
  6191. * If ADC multimode transfer by DMA is selected:
  6192. * One DMA channel is used for both ADC (DMA of ADC master)
  6193. * Specifies the DMA requests mode:
  6194. * - Limited mode (One shot mode): DMA transfer requests are stopped
  6195. * when number of DMA data transfers (number of
  6196. * ADC conversions) is reached.
  6197. * This ADC mode is intended to be used with DMA mode non-circular.
  6198. * - Unlimited mode: DMA transfer requests are unlimited,
  6199. * whatever number of DMA data transfers (number of
  6200. * ADC conversions).
  6201. * This ADC mode is intended to be used with DMA mode circular.
  6202. * @note If ADC DMA requests mode is set to unlimited and DMA is set to
  6203. * mode non-circular:
  6204. * when DMA transfers size will be reached, DMA will stop transfers of
  6205. * ADC conversions data ADC will raise an overrun error
  6206. * (overrun flag and interruption if enabled).
  6207. * @note How to retrieve multimode conversion data:
  6208. * Whatever multimode transfer by DMA setting: using function
  6209. * @ref LL_ADC_REG_ReadMultiConversionData32().
  6210. * If ADC multimode transfer by DMA is selected: conversion data
  6211. * is a raw data with ADC master and slave concatenated.
  6212. * A macro is available to get the conversion data of
  6213. * ADC master or ADC slave: see helper macro
  6214. * @ref __LL_ADC_MULTI_CONV_DATA_MASTER_SLAVE().
  6215. * @note On this STM32 series, setting of this feature is conditioned to
  6216. * ADC state:
  6217. * All ADC instances of the ADC common group must be disabled
  6218. * or enabled without conversion on going on group regular.
  6219. * @rmtoll CCR MDMA LL_ADC_SetMultiDMATransfer\n
  6220. * CCR DMACFG LL_ADC_SetMultiDMATransfer
  6221. * @param ADCxy_COMMON ADC common instance
  6222. * (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() )
  6223. * @param MultiDMATransfer This parameter can be one of the following values:
  6224. * @arg @ref LL_ADC_MULTI_REG_DMA_EACH_ADC
  6225. * @arg @ref LL_ADC_MULTI_REG_DMA_LIMIT_RES12_10B
  6226. * @arg @ref LL_ADC_MULTI_REG_DMA_LIMIT_RES8_6B
  6227. * @arg @ref LL_ADC_MULTI_REG_DMA_UNLMT_RES12_10B
  6228. * @arg @ref LL_ADC_MULTI_REG_DMA_UNLMT_RES8_6B
  6229. * @retval None
  6230. */
  6231. __STATIC_INLINE void LL_ADC_SetMultiDMATransfer(ADC_Common_TypeDef *ADCxy_COMMON, uint32_t MultiDMATransfer)
  6232. {
  6233. MODIFY_REG(ADCxy_COMMON->CCR, ADC_CCR_MDMA | ADC_CCR_DMACFG, MultiDMATransfer);
  6234. }
  6235. /**
  6236. * @brief Get ADC multimode conversion data transfer: no transfer
  6237. * or transfer by DMA.
  6238. * @note If ADC multimode transfer by DMA is not selected:
  6239. * each ADC uses its own DMA channel, with its individual
  6240. * DMA transfer settings.
  6241. * If ADC multimode transfer by DMA is selected:
  6242. * One DMA channel is used for both ADC (DMA of ADC master)
  6243. * Specifies the DMA requests mode:
  6244. * - Limited mode (One shot mode): DMA transfer requests are stopped
  6245. * when number of DMA data transfers (number of
  6246. * ADC conversions) is reached.
  6247. * This ADC mode is intended to be used with DMA mode non-circular.
  6248. * - Unlimited mode: DMA transfer requests are unlimited,
  6249. * whatever number of DMA data transfers (number of
  6250. * ADC conversions).
  6251. * This ADC mode is intended to be used with DMA mode circular.
  6252. * @note If ADC DMA requests mode is set to unlimited and DMA is set to
  6253. * mode non-circular:
  6254. * when DMA transfers size will be reached, DMA will stop transfers of
  6255. * ADC conversions data ADC will raise an overrun error
  6256. * (overrun flag and interruption if enabled).
  6257. * @note How to retrieve multimode conversion data:
  6258. * Whatever multimode transfer by DMA setting: using function
  6259. * @ref LL_ADC_REG_ReadMultiConversionData32().
  6260. * If ADC multimode transfer by DMA is selected: conversion data
  6261. * is a raw data with ADC master and slave concatenated.
  6262. * A macro is available to get the conversion data of
  6263. * ADC master or ADC slave: see helper macro
  6264. * @ref __LL_ADC_MULTI_CONV_DATA_MASTER_SLAVE().
  6265. * @rmtoll CCR MDMA LL_ADC_GetMultiDMATransfer\n
  6266. * CCR DMACFG LL_ADC_GetMultiDMATransfer
  6267. * @param ADCxy_COMMON ADC common instance
  6268. * (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() )
  6269. * @retval Returned value can be one of the following values:
  6270. * @arg @ref LL_ADC_MULTI_REG_DMA_EACH_ADC
  6271. * @arg @ref LL_ADC_MULTI_REG_DMA_LIMIT_RES12_10B
  6272. * @arg @ref LL_ADC_MULTI_REG_DMA_LIMIT_RES8_6B
  6273. * @arg @ref LL_ADC_MULTI_REG_DMA_UNLMT_RES12_10B
  6274. * @arg @ref LL_ADC_MULTI_REG_DMA_UNLMT_RES8_6B
  6275. */
  6276. __STATIC_INLINE uint32_t LL_ADC_GetMultiDMATransfer(const ADC_Common_TypeDef *ADCxy_COMMON)
  6277. {
  6278. return (uint32_t)(READ_BIT(ADCxy_COMMON->CCR, ADC_CCR_MDMA | ADC_CCR_DMACFG));
  6279. }
  6280. /**
  6281. * @brief Set ADC multimode delay between 2 sampling phases.
  6282. * @note The sampling delay range depends on ADC resolution:
  6283. * - ADC resolution 12 bits can have maximum delay of 12 cycles.
  6284. * - ADC resolution 10 bits can have maximum delay of 10 cycles.
  6285. * - ADC resolution 8 bits can have maximum delay of 8 cycles.
  6286. * - ADC resolution 6 bits can have maximum delay of 6 cycles.
  6287. * @note On this STM32 series, setting of this feature is conditioned to
  6288. * ADC state:
  6289. * All ADC instances of the ADC common group must be disabled.
  6290. * This check can be done with function @ref LL_ADC_IsEnabled() for each
  6291. * ADC instance or by using helper macro helper macro
  6292. * @ref __LL_ADC_IS_ENABLED_ALL_COMMON_INSTANCE().
  6293. * @rmtoll CCR DELAY LL_ADC_SetMultiTwoSamplingDelay
  6294. * @param ADCxy_COMMON ADC common instance
  6295. * (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() )
  6296. * @param MultiTwoSamplingDelay This parameter can be one of the following values:
  6297. * @arg @ref LL_ADC_MULTI_TWOSMP_DELAY_1CYCLE
  6298. * @arg @ref LL_ADC_MULTI_TWOSMP_DELAY_2CYCLES
  6299. * @arg @ref LL_ADC_MULTI_TWOSMP_DELAY_3CYCLES
  6300. * @arg @ref LL_ADC_MULTI_TWOSMP_DELAY_4CYCLES
  6301. * @arg @ref LL_ADC_MULTI_TWOSMP_DELAY_5CYCLES
  6302. * @arg @ref LL_ADC_MULTI_TWOSMP_DELAY_6CYCLES (1)
  6303. * @arg @ref LL_ADC_MULTI_TWOSMP_DELAY_7CYCLES (1)
  6304. * @arg @ref LL_ADC_MULTI_TWOSMP_DELAY_8CYCLES (2)
  6305. * @arg @ref LL_ADC_MULTI_TWOSMP_DELAY_9CYCLES (2)
  6306. * @arg @ref LL_ADC_MULTI_TWOSMP_DELAY_10CYCLES (2)
  6307. * @arg @ref LL_ADC_MULTI_TWOSMP_DELAY_11CYCLES (3)
  6308. * @arg @ref LL_ADC_MULTI_TWOSMP_DELAY_12CYCLES (3)
  6309. *
  6310. * (1) Parameter available only if ADC resolution is 12, 10 or 8 bits.\n
  6311. * (2) Parameter available only if ADC resolution is 12 or 10 bits.\n
  6312. * (3) Parameter available only if ADC resolution is 12 bits.
  6313. * @retval None
  6314. */
  6315. __STATIC_INLINE void LL_ADC_SetMultiTwoSamplingDelay(ADC_Common_TypeDef *ADCxy_COMMON, uint32_t MultiTwoSamplingDelay)
  6316. {
  6317. MODIFY_REG(ADCxy_COMMON->CCR, ADC_CCR_DELAY, MultiTwoSamplingDelay);
  6318. }
  6319. /**
  6320. * @brief Get ADC multimode delay between 2 sampling phases.
  6321. * @rmtoll CCR DELAY LL_ADC_GetMultiTwoSamplingDelay
  6322. * @param ADCxy_COMMON ADC common instance
  6323. * (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() )
  6324. * @retval Returned value can be one of the following values:
  6325. * @arg @ref LL_ADC_MULTI_TWOSMP_DELAY_1CYCLE
  6326. * @arg @ref LL_ADC_MULTI_TWOSMP_DELAY_2CYCLES
  6327. * @arg @ref LL_ADC_MULTI_TWOSMP_DELAY_3CYCLES
  6328. * @arg @ref LL_ADC_MULTI_TWOSMP_DELAY_4CYCLES
  6329. * @arg @ref LL_ADC_MULTI_TWOSMP_DELAY_5CYCLES
  6330. * @arg @ref LL_ADC_MULTI_TWOSMP_DELAY_6CYCLES (1)
  6331. * @arg @ref LL_ADC_MULTI_TWOSMP_DELAY_7CYCLES (1)
  6332. * @arg @ref LL_ADC_MULTI_TWOSMP_DELAY_8CYCLES (2)
  6333. * @arg @ref LL_ADC_MULTI_TWOSMP_DELAY_9CYCLES (2)
  6334. * @arg @ref LL_ADC_MULTI_TWOSMP_DELAY_10CYCLES (2)
  6335. * @arg @ref LL_ADC_MULTI_TWOSMP_DELAY_11CYCLES (3)
  6336. * @arg @ref LL_ADC_MULTI_TWOSMP_DELAY_12CYCLES (3)
  6337. *
  6338. * (1) Parameter available only if ADC resolution is 12, 10 or 8 bits.\n
  6339. * (2) Parameter available only if ADC resolution is 12 or 10 bits.\n
  6340. * (3) Parameter available only if ADC resolution is 12 bits.
  6341. */
  6342. __STATIC_INLINE uint32_t LL_ADC_GetMultiTwoSamplingDelay(const ADC_Common_TypeDef *ADCxy_COMMON)
  6343. {
  6344. return (uint32_t)(READ_BIT(ADCxy_COMMON->CCR, ADC_CCR_DELAY));
  6345. }
  6346. #endif /* ADC_MULTIMODE_SUPPORT */
  6347. /**
  6348. * @}
  6349. */
  6350. /** @defgroup ADC_LL_EF_Configuration_Leg_Functions Configuration of ADC alternate functions name
  6351. * @{
  6352. */
  6353. /* Old functions name kept for legacy purpose, to be replaced by the */
  6354. /* current functions name. */
  6355. __STATIC_INLINE void LL_ADC_REG_SetTrigSource(ADC_TypeDef *ADCx, uint32_t TriggerSource)
  6356. {
  6357. LL_ADC_REG_SetTriggerSource(ADCx, TriggerSource);
  6358. }
  6359. __STATIC_INLINE void LL_ADC_INJ_SetTrigSource(ADC_TypeDef *ADCx, uint32_t TriggerSource)
  6360. {
  6361. LL_ADC_INJ_SetTriggerSource(ADCx, TriggerSource);
  6362. }
  6363. /**
  6364. * @}
  6365. */
  6366. /** @defgroup ADC_LL_EF_Operation_ADC_Instance Operation on ADC hierarchical scope: ADC instance
  6367. * @{
  6368. */
  6369. /**
  6370. * @brief Put ADC instance in deep power down state.
  6371. * @note In case of ADC calibration necessary: When ADC is in deep-power-down
  6372. * state, the internal analog calibration is lost. After exiting from
  6373. * deep power down, calibration must be relaunched or calibration factor
  6374. * (preliminarily saved) must be set back into calibration register.
  6375. * @note On this STM32 series, setting of this feature is conditioned to
  6376. * ADC state:
  6377. * ADC must be ADC disabled.
  6378. * @rmtoll CR DEEPPWD LL_ADC_EnableDeepPowerDown
  6379. * @param ADCx ADC instance
  6380. * @retval None
  6381. */
  6382. __STATIC_INLINE void LL_ADC_EnableDeepPowerDown(ADC_TypeDef *ADCx)
  6383. {
  6384. /* Note: Write register with some additional bits forced to state reset */
  6385. /* instead of modifying only the selected bit for this function, */
  6386. /* to not interfere with bits with HW property "rs". */
  6387. MODIFY_REG(ADCx->CR,
  6388. ADC_CR_BITS_PROPERTY_RS,
  6389. ADC_CR_DEEPPWD);
  6390. }
  6391. /**
  6392. * @brief Disable ADC deep power down mode.
  6393. * @note In case of ADC calibration necessary: When ADC is in deep-power-down
  6394. * state, the internal analog calibration is lost. After exiting from
  6395. * deep power down, calibration must be relaunched or calibration factor
  6396. * (preliminarily saved) must be set back into calibration register.
  6397. * @note On this STM32 series, setting of this feature is conditioned to
  6398. * ADC state:
  6399. * ADC must be ADC disabled.
  6400. * @rmtoll CR DEEPPWD LL_ADC_DisableDeepPowerDown
  6401. * @param ADCx ADC instance
  6402. * @retval None
  6403. */
  6404. __STATIC_INLINE void LL_ADC_DisableDeepPowerDown(ADC_TypeDef *ADCx)
  6405. {
  6406. /* Note: Write register with some additional bits forced to state reset */
  6407. /* instead of modifying only the selected bit for this function, */
  6408. /* to not interfere with bits with HW property "rs". */
  6409. CLEAR_BIT(ADCx->CR, (ADC_CR_DEEPPWD | ADC_CR_BITS_PROPERTY_RS));
  6410. }
  6411. /**
  6412. * @brief Get the selected ADC instance deep power down state.
  6413. * @rmtoll CR DEEPPWD LL_ADC_IsDeepPowerDownEnabled
  6414. * @param ADCx ADC instance
  6415. * @retval 0: deep power down is disabled, 1: deep power down is enabled.
  6416. */
  6417. __STATIC_INLINE uint32_t LL_ADC_IsDeepPowerDownEnabled(const ADC_TypeDef *ADCx)
  6418. {
  6419. return ((READ_BIT(ADCx->CR, ADC_CR_DEEPPWD) == (ADC_CR_DEEPPWD)) ? 1UL : 0UL);
  6420. }
  6421. /**
  6422. * @brief Enable ADC instance internal voltage regulator.
  6423. * @note On this STM32 series, after ADC internal voltage regulator enable,
  6424. * a delay for ADC internal voltage regulator stabilization
  6425. * is required before performing a ADC calibration or ADC enable.
  6426. * Refer to device datasheet, parameter tADCVREG_STUP.
  6427. * Refer to literal @ref LL_ADC_DELAY_INTERNAL_REGUL_STAB_US.
  6428. * @note On this STM32 series, setting of this feature is conditioned to
  6429. * ADC state:
  6430. * ADC must be ADC disabled.
  6431. * @rmtoll CR ADVREGEN LL_ADC_EnableInternalRegulator
  6432. * @param ADCx ADC instance
  6433. * @retval None
  6434. */
  6435. __STATIC_INLINE void LL_ADC_EnableInternalRegulator(ADC_TypeDef *ADCx)
  6436. {
  6437. /* Note: Write register with some additional bits forced to state reset */
  6438. /* instead of modifying only the selected bit for this function, */
  6439. /* to not interfere with bits with HW property "rs". */
  6440. MODIFY_REG(ADCx->CR,
  6441. ADC_CR_BITS_PROPERTY_RS,
  6442. ADC_CR_ADVREGEN);
  6443. }
  6444. /**
  6445. * @brief Disable ADC internal voltage regulator.
  6446. * @note On this STM32 series, setting of this feature is conditioned to
  6447. * ADC state:
  6448. * ADC must be ADC disabled.
  6449. * @rmtoll CR ADVREGEN LL_ADC_DisableInternalRegulator
  6450. * @param ADCx ADC instance
  6451. * @retval None
  6452. */
  6453. __STATIC_INLINE void LL_ADC_DisableInternalRegulator(ADC_TypeDef *ADCx)
  6454. {
  6455. CLEAR_BIT(ADCx->CR, (ADC_CR_ADVREGEN | ADC_CR_BITS_PROPERTY_RS));
  6456. }
  6457. /**
  6458. * @brief Get the selected ADC instance internal voltage regulator state.
  6459. * @rmtoll CR ADVREGEN LL_ADC_IsInternalRegulatorEnabled
  6460. * @param ADCx ADC instance
  6461. * @retval 0: internal regulator is disabled, 1: internal regulator is enabled.
  6462. */
  6463. __STATIC_INLINE uint32_t LL_ADC_IsInternalRegulatorEnabled(const ADC_TypeDef *ADCx)
  6464. {
  6465. return ((READ_BIT(ADCx->CR, ADC_CR_ADVREGEN) == (ADC_CR_ADVREGEN)) ? 1UL : 0UL);
  6466. }
  6467. /**
  6468. * @brief Enable the selected ADC instance.
  6469. * @note On this STM32 series, after ADC enable, a delay for
  6470. * ADC internal analog stabilization is required before performing a
  6471. * ADC conversion start.
  6472. * Refer to device datasheet, parameter tSTAB.
  6473. * @note On this STM32 series, flag LL_ADC_FLAG_ADRDY is raised when the ADC
  6474. * is enabled and when conversion clock is active.
  6475. * (not only core clock: this ADC has a dual clock domain)
  6476. * @note On this STM32 series, setting of this feature is conditioned to
  6477. * ADC state:
  6478. * ADC must be ADC disabled and ADC internal voltage regulator enabled.
  6479. * @rmtoll CR ADEN LL_ADC_Enable
  6480. * @param ADCx ADC instance
  6481. * @retval None
  6482. */
  6483. __STATIC_INLINE void LL_ADC_Enable(ADC_TypeDef *ADCx)
  6484. {
  6485. /* Note: Write register with some additional bits forced to state reset */
  6486. /* instead of modifying only the selected bit for this function, */
  6487. /* to not interfere with bits with HW property "rs". */
  6488. MODIFY_REG(ADCx->CR,
  6489. ADC_CR_BITS_PROPERTY_RS,
  6490. ADC_CR_ADEN);
  6491. }
  6492. /**
  6493. * @brief Disable the selected ADC instance.
  6494. * @note On this STM32 series, setting of this feature is conditioned to
  6495. * ADC state:
  6496. * ADC must be not disabled. Must be enabled without conversion on going
  6497. * on either groups regular or injected.
  6498. * @rmtoll CR ADDIS LL_ADC_Disable
  6499. * @param ADCx ADC instance
  6500. * @retval None
  6501. */
  6502. __STATIC_INLINE void LL_ADC_Disable(ADC_TypeDef *ADCx)
  6503. {
  6504. /* Note: Write register with some additional bits forced to state reset */
  6505. /* instead of modifying only the selected bit for this function, */
  6506. /* to not interfere with bits with HW property "rs". */
  6507. MODIFY_REG(ADCx->CR,
  6508. ADC_CR_BITS_PROPERTY_RS,
  6509. ADC_CR_ADDIS);
  6510. }
  6511. /**
  6512. * @brief Get the selected ADC instance enable state.
  6513. * @note On this STM32 series, flag LL_ADC_FLAG_ADRDY is raised when the ADC
  6514. * is enabled and when conversion clock is active.
  6515. * (not only core clock: this ADC has a dual clock domain)
  6516. * @rmtoll CR ADEN LL_ADC_IsEnabled
  6517. * @param ADCx ADC instance
  6518. * @retval 0: ADC is disabled, 1: ADC is enabled.
  6519. */
  6520. __STATIC_INLINE uint32_t LL_ADC_IsEnabled(const ADC_TypeDef *ADCx)
  6521. {
  6522. return ((READ_BIT(ADCx->CR, ADC_CR_ADEN) == (ADC_CR_ADEN)) ? 1UL : 0UL);
  6523. }
  6524. /**
  6525. * @brief Get the selected ADC instance disable state.
  6526. * @rmtoll CR ADDIS LL_ADC_IsDisableOngoing
  6527. * @param ADCx ADC instance
  6528. * @retval 0: no ADC disable command on going.
  6529. */
  6530. __STATIC_INLINE uint32_t LL_ADC_IsDisableOngoing(const ADC_TypeDef *ADCx)
  6531. {
  6532. return ((READ_BIT(ADCx->CR, ADC_CR_ADDIS) == (ADC_CR_ADDIS)) ? 1UL : 0UL);
  6533. }
  6534. /**
  6535. * @brief Start ADC calibration in the mode single-ended
  6536. * or differential (for devices with differential mode available).
  6537. * @note On this STM32 series, a minimum number of ADC clock cycles
  6538. * are required between ADC end of calibration and ADC enable.
  6539. * Refer to literal @ref LL_ADC_DELAY_CALIB_ENABLE_ADC_CYCLES.
  6540. * @note For devices with differential mode available:
  6541. * Calibration of offset is specific to each of
  6542. * single-ended and differential modes
  6543. * (calibration run must be performed for each of these
  6544. * differential modes, if used afterwards and if the application
  6545. * requires their calibration).
  6546. * @note On this STM32 series, setting of this feature is conditioned to
  6547. * ADC state:
  6548. * ADC must be ADC disabled.
  6549. * @rmtoll CR ADCAL LL_ADC_StartCalibration\n
  6550. * CR ADCALDIF LL_ADC_StartCalibration
  6551. * @param ADCx ADC instance
  6552. * @param SingleDiff This parameter can be one of the following values:
  6553. * @arg @ref LL_ADC_SINGLE_ENDED
  6554. * @arg @ref LL_ADC_DIFFERENTIAL_ENDED
  6555. * @retval None
  6556. */
  6557. __STATIC_INLINE void LL_ADC_StartCalibration(ADC_TypeDef *ADCx, uint32_t SingleDiff)
  6558. {
  6559. /* Note: Write register with some additional bits forced to state reset */
  6560. /* instead of modifying only the selected bit for this function, */
  6561. /* to not interfere with bits with HW property "rs". */
  6562. MODIFY_REG(ADCx->CR,
  6563. ADC_CR_ADCALDIF | ADC_CR_BITS_PROPERTY_RS,
  6564. ADC_CR_ADCAL | (SingleDiff & ADC_SINGLEDIFF_CALIB_START_MASK));
  6565. }
  6566. /**
  6567. * @brief Get ADC calibration state.
  6568. * @rmtoll CR ADCAL LL_ADC_IsCalibrationOnGoing
  6569. * @param ADCx ADC instance
  6570. * @retval 0: calibration complete, 1: calibration in progress.
  6571. */
  6572. __STATIC_INLINE uint32_t LL_ADC_IsCalibrationOnGoing(const ADC_TypeDef *ADCx)
  6573. {
  6574. return ((READ_BIT(ADCx->CR, ADC_CR_ADCAL) == (ADC_CR_ADCAL)) ? 1UL : 0UL);
  6575. }
  6576. /**
  6577. * @}
  6578. */
  6579. /** @defgroup ADC_LL_EF_Operation_ADC_Group_Regular Operation on ADC hierarchical scope: group regular
  6580. * @{
  6581. */
  6582. /**
  6583. * @brief Start ADC group regular conversion.
  6584. * @note On this STM32 series, this function is relevant for both
  6585. * internal trigger (SW start) and external trigger:
  6586. * - If ADC trigger has been set to software start, ADC conversion
  6587. * starts immediately.
  6588. * - If ADC trigger has been set to external trigger, ADC conversion
  6589. * will start at next trigger event (on the selected trigger edge)
  6590. * following the ADC start conversion command.
  6591. * @note On this STM32 series, setting of this feature is conditioned to
  6592. * ADC state:
  6593. * ADC must be enabled without conversion on going on group regular,
  6594. * without conversion stop command on going on group regular,
  6595. * without ADC disable command on going.
  6596. * @rmtoll CR ADSTART LL_ADC_REG_StartConversion
  6597. * @param ADCx ADC instance
  6598. * @retval None
  6599. */
  6600. __STATIC_INLINE void LL_ADC_REG_StartConversion(ADC_TypeDef *ADCx)
  6601. {
  6602. /* Note: Write register with some additional bits forced to state reset */
  6603. /* instead of modifying only the selected bit for this function, */
  6604. /* to not interfere with bits with HW property "rs". */
  6605. MODIFY_REG(ADCx->CR,
  6606. ADC_CR_BITS_PROPERTY_RS,
  6607. ADC_CR_ADSTART);
  6608. }
  6609. /**
  6610. * @brief Stop ADC group regular conversion.
  6611. * @note On this STM32 series, setting of this feature is conditioned to
  6612. * ADC state:
  6613. * ADC must be enabled with conversion on going on group regular,
  6614. * without ADC disable command on going.
  6615. * @rmtoll CR ADSTP LL_ADC_REG_StopConversion
  6616. * @param ADCx ADC instance
  6617. * @retval None
  6618. */
  6619. __STATIC_INLINE void LL_ADC_REG_StopConversion(ADC_TypeDef *ADCx)
  6620. {
  6621. /* Note: Write register with some additional bits forced to state reset */
  6622. /* instead of modifying only the selected bit for this function, */
  6623. /* to not interfere with bits with HW property "rs". */
  6624. MODIFY_REG(ADCx->CR,
  6625. ADC_CR_BITS_PROPERTY_RS,
  6626. ADC_CR_ADSTP);
  6627. }
  6628. /**
  6629. * @brief Get ADC group regular conversion state.
  6630. * @rmtoll CR ADSTART LL_ADC_REG_IsConversionOngoing
  6631. * @param ADCx ADC instance
  6632. * @retval 0: no conversion is on going on ADC group regular.
  6633. */
  6634. __STATIC_INLINE uint32_t LL_ADC_REG_IsConversionOngoing(const ADC_TypeDef *ADCx)
  6635. {
  6636. return ((READ_BIT(ADCx->CR, ADC_CR_ADSTART) == (ADC_CR_ADSTART)) ? 1UL : 0UL);
  6637. }
  6638. /**
  6639. * @brief Get ADC group regular command of conversion stop state
  6640. * @rmtoll CR ADSTP LL_ADC_REG_IsStopConversionOngoing
  6641. * @param ADCx ADC instance
  6642. * @retval 0: no command of conversion stop is on going on ADC group regular.
  6643. */
  6644. __STATIC_INLINE uint32_t LL_ADC_REG_IsStopConversionOngoing(const ADC_TypeDef *ADCx)
  6645. {
  6646. return ((READ_BIT(ADCx->CR, ADC_CR_ADSTP) == (ADC_CR_ADSTP)) ? 1UL : 0UL);
  6647. }
  6648. /**
  6649. * @brief Get ADC group regular conversion data, range fit for
  6650. * all ADC configurations: all ADC resolutions and
  6651. * all oversampling increased data width (for devices
  6652. * with feature oversampling).
  6653. * @rmtoll DR RDATA LL_ADC_REG_ReadConversionData32
  6654. * @param ADCx ADC instance
  6655. * @retval Value between Min_Data=0x00000000 and Max_Data=0xFFFFFFFF
  6656. */
  6657. __STATIC_INLINE uint32_t LL_ADC_REG_ReadConversionData32(const ADC_TypeDef *ADCx)
  6658. {
  6659. return (uint32_t)(READ_BIT(ADCx->DR, ADC_DR_RDATA));
  6660. }
  6661. /**
  6662. * @brief Get ADC group regular conversion data, range fit for
  6663. * ADC resolution 12 bits.
  6664. * @note For devices with feature oversampling: Oversampling
  6665. * can increase data width, function for extended range
  6666. * may be needed: @ref LL_ADC_REG_ReadConversionData32.
  6667. * @rmtoll DR RDATA LL_ADC_REG_ReadConversionData12
  6668. * @param ADCx ADC instance
  6669. * @retval Value between Min_Data=0x000 and Max_Data=0xFFF
  6670. */
  6671. __STATIC_INLINE uint16_t LL_ADC_REG_ReadConversionData12(const ADC_TypeDef *ADCx)
  6672. {
  6673. return (uint16_t)(READ_BIT(ADCx->DR, ADC_DR_RDATA));
  6674. }
  6675. /**
  6676. * @brief Get ADC group regular conversion data, range fit for
  6677. * ADC resolution 10 bits.
  6678. * @note For devices with feature oversampling: Oversampling
  6679. * can increase data width, function for extended range
  6680. * may be needed: @ref LL_ADC_REG_ReadConversionData32.
  6681. * @rmtoll DR RDATA LL_ADC_REG_ReadConversionData10
  6682. * @param ADCx ADC instance
  6683. * @retval Value between Min_Data=0x000 and Max_Data=0x3FF
  6684. */
  6685. __STATIC_INLINE uint16_t LL_ADC_REG_ReadConversionData10(const ADC_TypeDef *ADCx)
  6686. {
  6687. return (uint16_t)(READ_BIT(ADCx->DR, ADC_DR_RDATA));
  6688. }
  6689. /**
  6690. * @brief Get ADC group regular conversion data, range fit for
  6691. * ADC resolution 8 bits.
  6692. * @note For devices with feature oversampling: Oversampling
  6693. * can increase data width, function for extended range
  6694. * may be needed: @ref LL_ADC_REG_ReadConversionData32.
  6695. * @rmtoll DR RDATA LL_ADC_REG_ReadConversionData8
  6696. * @param ADCx ADC instance
  6697. * @retval Value between Min_Data=0x00 and Max_Data=0xFF
  6698. */
  6699. __STATIC_INLINE uint8_t LL_ADC_REG_ReadConversionData8(const ADC_TypeDef *ADCx)
  6700. {
  6701. return (uint8_t)(READ_BIT(ADCx->DR, ADC_DR_RDATA));
  6702. }
  6703. /**
  6704. * @brief Get ADC group regular conversion data, range fit for
  6705. * ADC resolution 6 bits.
  6706. * @note For devices with feature oversampling: Oversampling
  6707. * can increase data width, function for extended range
  6708. * may be needed: @ref LL_ADC_REG_ReadConversionData32.
  6709. * @rmtoll DR RDATA LL_ADC_REG_ReadConversionData6
  6710. * @param ADCx ADC instance
  6711. * @retval Value between Min_Data=0x00 and Max_Data=0x3F
  6712. */
  6713. __STATIC_INLINE uint8_t LL_ADC_REG_ReadConversionData6(const ADC_TypeDef *ADCx)
  6714. {
  6715. return (uint8_t)(READ_BIT(ADCx->DR, ADC_DR_RDATA));
  6716. }
  6717. #if defined(ADC_MULTIMODE_SUPPORT)
  6718. /**
  6719. * @brief Get ADC multimode conversion data of ADC master, ADC slave
  6720. * or raw data with ADC master and slave concatenated.
  6721. * @note If raw data with ADC master and slave concatenated is retrieved,
  6722. * a macro is available to get the conversion data of
  6723. * ADC master or ADC slave: see helper macro
  6724. * @ref __LL_ADC_MULTI_CONV_DATA_MASTER_SLAVE().
  6725. * (however this macro is mainly intended for multimode
  6726. * transfer by DMA, because this function can do the same
  6727. * by getting multimode conversion data of ADC master or ADC slave
  6728. * separately).
  6729. * @rmtoll CDR RDATA_MST LL_ADC_REG_ReadMultiConversionData32\n
  6730. * CDR RDATA_SLV LL_ADC_REG_ReadMultiConversionData32
  6731. * @param ADCxy_COMMON ADC common instance
  6732. * (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() )
  6733. * @param ConversionData This parameter can be one of the following values:
  6734. * @arg @ref LL_ADC_MULTI_MASTER
  6735. * @arg @ref LL_ADC_MULTI_SLAVE
  6736. * @arg @ref LL_ADC_MULTI_MASTER_SLAVE
  6737. * @retval Value between Min_Data=0x00000000 and Max_Data=0xFFFFFFFF
  6738. */
  6739. __STATIC_INLINE uint32_t LL_ADC_REG_ReadMultiConversionData32(const ADC_Common_TypeDef *ADCxy_COMMON,
  6740. uint32_t ConversionData)
  6741. {
  6742. return (uint32_t)(READ_BIT(ADCxy_COMMON->CDR,
  6743. ConversionData)
  6744. >> (POSITION_VAL(ConversionData) & 0x1FUL)
  6745. );
  6746. }
  6747. #endif /* ADC_MULTIMODE_SUPPORT */
  6748. /**
  6749. * @}
  6750. */
  6751. /** @defgroup ADC_LL_EF_Operation_ADC_Group_Injected Operation on ADC hierarchical scope: group injected
  6752. * @{
  6753. */
  6754. /**
  6755. * @brief Start ADC group injected conversion.
  6756. * @note On this STM32 series, this function is relevant for both
  6757. * internal trigger (SW start) and external trigger:
  6758. * - If ADC trigger has been set to software start, ADC conversion
  6759. * starts immediately.
  6760. * - If ADC trigger has been set to external trigger, ADC conversion
  6761. * will start at next trigger event (on the selected trigger edge)
  6762. * following the ADC start conversion command.
  6763. * @note On this STM32 series, setting of this feature is conditioned to
  6764. * ADC state:
  6765. * ADC must be enabled without conversion on going on group injected,
  6766. * without conversion stop command on going on group injected,
  6767. * without ADC disable command on going.
  6768. * @rmtoll CR JADSTART LL_ADC_INJ_StartConversion
  6769. * @param ADCx ADC instance
  6770. * @retval None
  6771. */
  6772. __STATIC_INLINE void LL_ADC_INJ_StartConversion(ADC_TypeDef *ADCx)
  6773. {
  6774. /* Note: Write register with some additional bits forced to state reset */
  6775. /* instead of modifying only the selected bit for this function, */
  6776. /* to not interfere with bits with HW property "rs". */
  6777. MODIFY_REG(ADCx->CR,
  6778. ADC_CR_BITS_PROPERTY_RS,
  6779. ADC_CR_JADSTART);
  6780. }
  6781. /**
  6782. * @brief Stop ADC group injected conversion.
  6783. * @note On this STM32 series, setting of this feature is conditioned to
  6784. * ADC state:
  6785. * ADC must be enabled with conversion on going on group injected,
  6786. * without ADC disable command on going.
  6787. * @rmtoll CR JADSTP LL_ADC_INJ_StopConversion
  6788. * @param ADCx ADC instance
  6789. * @retval None
  6790. */
  6791. __STATIC_INLINE void LL_ADC_INJ_StopConversion(ADC_TypeDef *ADCx)
  6792. {
  6793. /* Note: Write register with some additional bits forced to state reset */
  6794. /* instead of modifying only the selected bit for this function, */
  6795. /* to not interfere with bits with HW property "rs". */
  6796. MODIFY_REG(ADCx->CR,
  6797. ADC_CR_BITS_PROPERTY_RS,
  6798. ADC_CR_JADSTP);
  6799. }
  6800. /**
  6801. * @brief Get ADC group injected conversion state.
  6802. * @rmtoll CR JADSTART LL_ADC_INJ_IsConversionOngoing
  6803. * @param ADCx ADC instance
  6804. * @retval 0: no conversion is on going on ADC group injected.
  6805. */
  6806. __STATIC_INLINE uint32_t LL_ADC_INJ_IsConversionOngoing(const ADC_TypeDef *ADCx)
  6807. {
  6808. return ((READ_BIT(ADCx->CR, ADC_CR_JADSTART) == (ADC_CR_JADSTART)) ? 1UL : 0UL);
  6809. }
  6810. /**
  6811. * @brief Get ADC group injected command of conversion stop state
  6812. * @rmtoll CR JADSTP LL_ADC_INJ_IsStopConversionOngoing
  6813. * @param ADCx ADC instance
  6814. * @retval 0: no command of conversion stop is on going on ADC group injected.
  6815. */
  6816. __STATIC_INLINE uint32_t LL_ADC_INJ_IsStopConversionOngoing(const ADC_TypeDef *ADCx)
  6817. {
  6818. return ((READ_BIT(ADCx->CR, ADC_CR_JADSTP) == (ADC_CR_JADSTP)) ? 1UL : 0UL);
  6819. }
  6820. /**
  6821. * @brief Get ADC group injected conversion data, range fit for
  6822. * all ADC configurations: all ADC resolutions and
  6823. * all oversampling increased data width (for devices
  6824. * with feature oversampling).
  6825. * @rmtoll JDR1 JDATA LL_ADC_INJ_ReadConversionData32\n
  6826. * JDR2 JDATA LL_ADC_INJ_ReadConversionData32\n
  6827. * JDR3 JDATA LL_ADC_INJ_ReadConversionData32\n
  6828. * JDR4 JDATA LL_ADC_INJ_ReadConversionData32
  6829. * @param ADCx ADC instance
  6830. * @param Rank This parameter can be one of the following values:
  6831. * @arg @ref LL_ADC_INJ_RANK_1
  6832. * @arg @ref LL_ADC_INJ_RANK_2
  6833. * @arg @ref LL_ADC_INJ_RANK_3
  6834. * @arg @ref LL_ADC_INJ_RANK_4
  6835. * @retval Value between Min_Data=0x00000000 and Max_Data=0xFFFFFFFF
  6836. */
  6837. __STATIC_INLINE uint32_t LL_ADC_INJ_ReadConversionData32(const ADC_TypeDef *ADCx, uint32_t Rank)
  6838. {
  6839. const __IO uint32_t *preg = __ADC_PTR_REG_OFFSET(ADCx->JDR1,
  6840. ((Rank & ADC_INJ_JDRX_REGOFFSET_MASK) >> ADC_JDRX_REGOFFSET_POS));
  6841. return (uint32_t)(READ_BIT(*preg,
  6842. ADC_JDR1_JDATA)
  6843. );
  6844. }
  6845. /**
  6846. * @brief Get ADC group injected conversion data, range fit for
  6847. * ADC resolution 12 bits.
  6848. * @note For devices with feature oversampling: Oversampling
  6849. * can increase data width, function for extended range
  6850. * may be needed: @ref LL_ADC_INJ_ReadConversionData32.
  6851. * @rmtoll JDR1 JDATA LL_ADC_INJ_ReadConversionData12\n
  6852. * JDR2 JDATA LL_ADC_INJ_ReadConversionData12\n
  6853. * JDR3 JDATA LL_ADC_INJ_ReadConversionData12\n
  6854. * JDR4 JDATA LL_ADC_INJ_ReadConversionData12
  6855. * @param ADCx ADC instance
  6856. * @param Rank This parameter can be one of the following values:
  6857. * @arg @ref LL_ADC_INJ_RANK_1
  6858. * @arg @ref LL_ADC_INJ_RANK_2
  6859. * @arg @ref LL_ADC_INJ_RANK_3
  6860. * @arg @ref LL_ADC_INJ_RANK_4
  6861. * @retval Value between Min_Data=0x000 and Max_Data=0xFFF
  6862. */
  6863. __STATIC_INLINE uint16_t LL_ADC_INJ_ReadConversionData12(const ADC_TypeDef *ADCx, uint32_t Rank)
  6864. {
  6865. const __IO uint32_t *preg = __ADC_PTR_REG_OFFSET(ADCx->JDR1,
  6866. ((Rank & ADC_INJ_JDRX_REGOFFSET_MASK) >> ADC_JDRX_REGOFFSET_POS));
  6867. return (uint16_t)(READ_BIT(*preg,
  6868. ADC_JDR1_JDATA)
  6869. );
  6870. }
  6871. /**
  6872. * @brief Get ADC group injected conversion data, range fit for
  6873. * ADC resolution 10 bits.
  6874. * @note For devices with feature oversampling: Oversampling
  6875. * can increase data width, function for extended range
  6876. * may be needed: @ref LL_ADC_INJ_ReadConversionData32.
  6877. * @rmtoll JDR1 JDATA LL_ADC_INJ_ReadConversionData10\n
  6878. * JDR2 JDATA LL_ADC_INJ_ReadConversionData10\n
  6879. * JDR3 JDATA LL_ADC_INJ_ReadConversionData10\n
  6880. * JDR4 JDATA LL_ADC_INJ_ReadConversionData10
  6881. * @param ADCx ADC instance
  6882. * @param Rank This parameter can be one of the following values:
  6883. * @arg @ref LL_ADC_INJ_RANK_1
  6884. * @arg @ref LL_ADC_INJ_RANK_2
  6885. * @arg @ref LL_ADC_INJ_RANK_3
  6886. * @arg @ref LL_ADC_INJ_RANK_4
  6887. * @retval Value between Min_Data=0x000 and Max_Data=0x3FF
  6888. */
  6889. __STATIC_INLINE uint16_t LL_ADC_INJ_ReadConversionData10(const ADC_TypeDef *ADCx, uint32_t Rank)
  6890. {
  6891. const __IO uint32_t *preg = __ADC_PTR_REG_OFFSET(ADCx->JDR1,
  6892. ((Rank & ADC_INJ_JDRX_REGOFFSET_MASK) >> ADC_JDRX_REGOFFSET_POS));
  6893. return (uint16_t)(READ_BIT(*preg,
  6894. ADC_JDR1_JDATA)
  6895. );
  6896. }
  6897. /**
  6898. * @brief Get ADC group injected conversion data, range fit for
  6899. * ADC resolution 8 bits.
  6900. * @note For devices with feature oversampling: Oversampling
  6901. * can increase data width, function for extended range
  6902. * may be needed: @ref LL_ADC_INJ_ReadConversionData32.
  6903. * @rmtoll JDR1 JDATA LL_ADC_INJ_ReadConversionData8\n
  6904. * JDR2 JDATA LL_ADC_INJ_ReadConversionData8\n
  6905. * JDR3 JDATA LL_ADC_INJ_ReadConversionData8\n
  6906. * JDR4 JDATA LL_ADC_INJ_ReadConversionData8
  6907. * @param ADCx ADC instance
  6908. * @param Rank This parameter can be one of the following values:
  6909. * @arg @ref LL_ADC_INJ_RANK_1
  6910. * @arg @ref LL_ADC_INJ_RANK_2
  6911. * @arg @ref LL_ADC_INJ_RANK_3
  6912. * @arg @ref LL_ADC_INJ_RANK_4
  6913. * @retval Value between Min_Data=0x00 and Max_Data=0xFF
  6914. */
  6915. __STATIC_INLINE uint8_t LL_ADC_INJ_ReadConversionData8(const ADC_TypeDef *ADCx, uint32_t Rank)
  6916. {
  6917. const __IO uint32_t *preg = __ADC_PTR_REG_OFFSET(ADCx->JDR1,
  6918. ((Rank & ADC_INJ_JDRX_REGOFFSET_MASK) >> ADC_JDRX_REGOFFSET_POS));
  6919. return (uint8_t)(READ_BIT(*preg,
  6920. ADC_JDR1_JDATA)
  6921. );
  6922. }
  6923. /**
  6924. * @brief Get ADC group injected conversion data, range fit for
  6925. * ADC resolution 6 bits.
  6926. * @note For devices with feature oversampling: Oversampling
  6927. * can increase data width, function for extended range
  6928. * may be needed: @ref LL_ADC_INJ_ReadConversionData32.
  6929. * @rmtoll JDR1 JDATA LL_ADC_INJ_ReadConversionData6\n
  6930. * JDR2 JDATA LL_ADC_INJ_ReadConversionData6\n
  6931. * JDR3 JDATA LL_ADC_INJ_ReadConversionData6\n
  6932. * JDR4 JDATA LL_ADC_INJ_ReadConversionData6
  6933. * @param ADCx ADC instance
  6934. * @param Rank This parameter can be one of the following values:
  6935. * @arg @ref LL_ADC_INJ_RANK_1
  6936. * @arg @ref LL_ADC_INJ_RANK_2
  6937. * @arg @ref LL_ADC_INJ_RANK_3
  6938. * @arg @ref LL_ADC_INJ_RANK_4
  6939. * @retval Value between Min_Data=0x00 and Max_Data=0x3F
  6940. */
  6941. __STATIC_INLINE uint8_t LL_ADC_INJ_ReadConversionData6(const ADC_TypeDef *ADCx, uint32_t Rank)
  6942. {
  6943. const __IO uint32_t *preg = __ADC_PTR_REG_OFFSET(ADCx->JDR1,
  6944. ((Rank & ADC_INJ_JDRX_REGOFFSET_MASK) >> ADC_JDRX_REGOFFSET_POS));
  6945. return (uint8_t)(READ_BIT(*preg,
  6946. ADC_JDR1_JDATA)
  6947. );
  6948. }
  6949. /**
  6950. * @}
  6951. */
  6952. /** @defgroup ADC_LL_EF_FLAG_Management ADC flag management
  6953. * @{
  6954. */
  6955. /**
  6956. * @brief Get flag ADC ready.
  6957. * @note On this STM32 series, flag LL_ADC_FLAG_ADRDY is raised when the ADC
  6958. * is enabled and when conversion clock is active.
  6959. * (not only core clock: this ADC has a dual clock domain)
  6960. * @rmtoll ISR ADRDY LL_ADC_IsActiveFlag_ADRDY
  6961. * @param ADCx ADC instance
  6962. * @retval State of bit (1 or 0).
  6963. */
  6964. __STATIC_INLINE uint32_t LL_ADC_IsActiveFlag_ADRDY(const ADC_TypeDef *ADCx)
  6965. {
  6966. return ((READ_BIT(ADCx->ISR, LL_ADC_FLAG_ADRDY) == (LL_ADC_FLAG_ADRDY)) ? 1UL : 0UL);
  6967. }
  6968. /**
  6969. * @brief Get flag ADC group regular end of unitary conversion.
  6970. * @rmtoll ISR EOC LL_ADC_IsActiveFlag_EOC
  6971. * @param ADCx ADC instance
  6972. * @retval State of bit (1 or 0).
  6973. */
  6974. __STATIC_INLINE uint32_t LL_ADC_IsActiveFlag_EOC(const ADC_TypeDef *ADCx)
  6975. {
  6976. return ((READ_BIT(ADCx->ISR, ADC_ISR_EOC) == (ADC_ISR_EOC)) ? 1UL : 0UL);
  6977. }
  6978. /**
  6979. * @brief Get flag ADC group regular end of sequence conversions.
  6980. * @rmtoll ISR EOS LL_ADC_IsActiveFlag_EOS
  6981. * @param ADCx ADC instance
  6982. * @retval State of bit (1 or 0).
  6983. */
  6984. __STATIC_INLINE uint32_t LL_ADC_IsActiveFlag_EOS(const ADC_TypeDef *ADCx)
  6985. {
  6986. return ((READ_BIT(ADCx->ISR, LL_ADC_FLAG_EOS) == (LL_ADC_FLAG_EOS)) ? 1UL : 0UL);
  6987. }
  6988. /**
  6989. * @brief Get flag ADC group regular overrun.
  6990. * @rmtoll ISR OVR LL_ADC_IsActiveFlag_OVR
  6991. * @param ADCx ADC instance
  6992. * @retval State of bit (1 or 0).
  6993. */
  6994. __STATIC_INLINE uint32_t LL_ADC_IsActiveFlag_OVR(const ADC_TypeDef *ADCx)
  6995. {
  6996. return ((READ_BIT(ADCx->ISR, LL_ADC_FLAG_OVR) == (LL_ADC_FLAG_OVR)) ? 1UL : 0UL);
  6997. }
  6998. /**
  6999. * @brief Get flag ADC group regular end of sampling phase.
  7000. * @rmtoll ISR EOSMP LL_ADC_IsActiveFlag_EOSMP
  7001. * @param ADCx ADC instance
  7002. * @retval State of bit (1 or 0).
  7003. */
  7004. __STATIC_INLINE uint32_t LL_ADC_IsActiveFlag_EOSMP(const ADC_TypeDef *ADCx)
  7005. {
  7006. return ((READ_BIT(ADCx->ISR, LL_ADC_FLAG_EOSMP) == (LL_ADC_FLAG_EOSMP)) ? 1UL : 0UL);
  7007. }
  7008. /**
  7009. * @brief Get flag ADC group injected end of unitary conversion.
  7010. * @rmtoll ISR JEOC LL_ADC_IsActiveFlag_JEOC
  7011. * @param ADCx ADC instance
  7012. * @retval State of bit (1 or 0).
  7013. */
  7014. __STATIC_INLINE uint32_t LL_ADC_IsActiveFlag_JEOC(const ADC_TypeDef *ADCx)
  7015. {
  7016. return ((READ_BIT(ADCx->ISR, LL_ADC_FLAG_JEOC) == (LL_ADC_FLAG_JEOC)) ? 1UL : 0UL);
  7017. }
  7018. /**
  7019. * @brief Get flag ADC group injected end of sequence conversions.
  7020. * @rmtoll ISR JEOS LL_ADC_IsActiveFlag_JEOS
  7021. * @param ADCx ADC instance
  7022. * @retval State of bit (1 or 0).
  7023. */
  7024. __STATIC_INLINE uint32_t LL_ADC_IsActiveFlag_JEOS(const ADC_TypeDef *ADCx)
  7025. {
  7026. return ((READ_BIT(ADCx->ISR, LL_ADC_FLAG_JEOS) == (LL_ADC_FLAG_JEOS)) ? 1UL : 0UL);
  7027. }
  7028. /**
  7029. * @brief Get flag ADC group injected contexts queue overflow.
  7030. * @rmtoll ISR JQOVF LL_ADC_IsActiveFlag_JQOVF
  7031. * @param ADCx ADC instance
  7032. * @retval State of bit (1 or 0).
  7033. */
  7034. __STATIC_INLINE uint32_t LL_ADC_IsActiveFlag_JQOVF(const ADC_TypeDef *ADCx)
  7035. {
  7036. return ((READ_BIT(ADCx->ISR, LL_ADC_FLAG_JQOVF) == (LL_ADC_FLAG_JQOVF)) ? 1UL : 0UL);
  7037. }
  7038. /**
  7039. * @brief Get flag ADC analog watchdog 1 flag
  7040. * @rmtoll ISR AWD1 LL_ADC_IsActiveFlag_AWD1
  7041. * @param ADCx ADC instance
  7042. * @retval State of bit (1 or 0).
  7043. */
  7044. __STATIC_INLINE uint32_t LL_ADC_IsActiveFlag_AWD1(const ADC_TypeDef *ADCx)
  7045. {
  7046. return ((READ_BIT(ADCx->ISR, LL_ADC_FLAG_AWD1) == (LL_ADC_FLAG_AWD1)) ? 1UL : 0UL);
  7047. }
  7048. /**
  7049. * @brief Get flag ADC analog watchdog 2.
  7050. * @rmtoll ISR AWD2 LL_ADC_IsActiveFlag_AWD2
  7051. * @param ADCx ADC instance
  7052. * @retval State of bit (1 or 0).
  7053. */
  7054. __STATIC_INLINE uint32_t LL_ADC_IsActiveFlag_AWD2(const ADC_TypeDef *ADCx)
  7055. {
  7056. return ((READ_BIT(ADCx->ISR, LL_ADC_FLAG_AWD2) == (LL_ADC_FLAG_AWD2)) ? 1UL : 0UL);
  7057. }
  7058. /**
  7059. * @brief Get flag ADC analog watchdog 3.
  7060. * @rmtoll ISR AWD3 LL_ADC_IsActiveFlag_AWD3
  7061. * @param ADCx ADC instance
  7062. * @retval State of bit (1 or 0).
  7063. */
  7064. __STATIC_INLINE uint32_t LL_ADC_IsActiveFlag_AWD3(const ADC_TypeDef *ADCx)
  7065. {
  7066. return ((READ_BIT(ADCx->ISR, LL_ADC_FLAG_AWD3) == (LL_ADC_FLAG_AWD3)) ? 1UL : 0UL);
  7067. }
  7068. /**
  7069. * @brief Clear flag ADC ready.
  7070. * @note On this STM32 series, flag LL_ADC_FLAG_ADRDY is raised when the ADC
  7071. * is enabled and when conversion clock is active.
  7072. * (not only core clock: this ADC has a dual clock domain)
  7073. * @rmtoll ISR ADRDY LL_ADC_ClearFlag_ADRDY
  7074. * @param ADCx ADC instance
  7075. * @retval None
  7076. */
  7077. __STATIC_INLINE void LL_ADC_ClearFlag_ADRDY(ADC_TypeDef *ADCx)
  7078. {
  7079. WRITE_REG(ADCx->ISR, LL_ADC_FLAG_ADRDY);
  7080. }
  7081. /**
  7082. * @brief Clear flag ADC group regular end of unitary conversion.
  7083. * @rmtoll ISR EOC LL_ADC_ClearFlag_EOC
  7084. * @param ADCx ADC instance
  7085. * @retval None
  7086. */
  7087. __STATIC_INLINE void LL_ADC_ClearFlag_EOC(ADC_TypeDef *ADCx)
  7088. {
  7089. WRITE_REG(ADCx->ISR, LL_ADC_FLAG_EOC);
  7090. }
  7091. /**
  7092. * @brief Clear flag ADC group regular end of sequence conversions.
  7093. * @rmtoll ISR EOS LL_ADC_ClearFlag_EOS
  7094. * @param ADCx ADC instance
  7095. * @retval None
  7096. */
  7097. __STATIC_INLINE void LL_ADC_ClearFlag_EOS(ADC_TypeDef *ADCx)
  7098. {
  7099. WRITE_REG(ADCx->ISR, LL_ADC_FLAG_EOS);
  7100. }
  7101. /**
  7102. * @brief Clear flag ADC group regular overrun.
  7103. * @rmtoll ISR OVR LL_ADC_ClearFlag_OVR
  7104. * @param ADCx ADC instance
  7105. * @retval None
  7106. */
  7107. __STATIC_INLINE void LL_ADC_ClearFlag_OVR(ADC_TypeDef *ADCx)
  7108. {
  7109. WRITE_REG(ADCx->ISR, LL_ADC_FLAG_OVR);
  7110. }
  7111. /**
  7112. * @brief Clear flag ADC group regular end of sampling phase.
  7113. * @rmtoll ISR EOSMP LL_ADC_ClearFlag_EOSMP
  7114. * @param ADCx ADC instance
  7115. * @retval None
  7116. */
  7117. __STATIC_INLINE void LL_ADC_ClearFlag_EOSMP(ADC_TypeDef *ADCx)
  7118. {
  7119. WRITE_REG(ADCx->ISR, LL_ADC_FLAG_EOSMP);
  7120. }
  7121. /**
  7122. * @brief Clear flag ADC group injected end of unitary conversion.
  7123. * @rmtoll ISR JEOC LL_ADC_ClearFlag_JEOC
  7124. * @param ADCx ADC instance
  7125. * @retval None
  7126. */
  7127. __STATIC_INLINE void LL_ADC_ClearFlag_JEOC(ADC_TypeDef *ADCx)
  7128. {
  7129. WRITE_REG(ADCx->ISR, LL_ADC_FLAG_JEOC);
  7130. }
  7131. /**
  7132. * @brief Clear flag ADC group injected end of sequence conversions.
  7133. * @rmtoll ISR JEOS LL_ADC_ClearFlag_JEOS
  7134. * @param ADCx ADC instance
  7135. * @retval None
  7136. */
  7137. __STATIC_INLINE void LL_ADC_ClearFlag_JEOS(ADC_TypeDef *ADCx)
  7138. {
  7139. WRITE_REG(ADCx->ISR, LL_ADC_FLAG_JEOS);
  7140. }
  7141. /**
  7142. * @brief Clear flag ADC group injected contexts queue overflow.
  7143. * @rmtoll ISR JQOVF LL_ADC_ClearFlag_JQOVF
  7144. * @param ADCx ADC instance
  7145. * @retval None
  7146. */
  7147. __STATIC_INLINE void LL_ADC_ClearFlag_JQOVF(ADC_TypeDef *ADCx)
  7148. {
  7149. WRITE_REG(ADCx->ISR, LL_ADC_FLAG_JQOVF);
  7150. }
  7151. /**
  7152. * @brief Clear flag ADC analog watchdog 1.
  7153. * @rmtoll ISR AWD1 LL_ADC_ClearFlag_AWD1
  7154. * @param ADCx ADC instance
  7155. * @retval None
  7156. */
  7157. __STATIC_INLINE void LL_ADC_ClearFlag_AWD1(ADC_TypeDef *ADCx)
  7158. {
  7159. WRITE_REG(ADCx->ISR, LL_ADC_FLAG_AWD1);
  7160. }
  7161. /**
  7162. * @brief Clear flag ADC analog watchdog 2.
  7163. * @rmtoll ISR AWD2 LL_ADC_ClearFlag_AWD2
  7164. * @param ADCx ADC instance
  7165. * @retval None
  7166. */
  7167. __STATIC_INLINE void LL_ADC_ClearFlag_AWD2(ADC_TypeDef *ADCx)
  7168. {
  7169. WRITE_REG(ADCx->ISR, LL_ADC_FLAG_AWD2);
  7170. }
  7171. /**
  7172. * @brief Clear flag ADC analog watchdog 3.
  7173. * @rmtoll ISR AWD3 LL_ADC_ClearFlag_AWD3
  7174. * @param ADCx ADC instance
  7175. * @retval None
  7176. */
  7177. __STATIC_INLINE void LL_ADC_ClearFlag_AWD3(ADC_TypeDef *ADCx)
  7178. {
  7179. WRITE_REG(ADCx->ISR, LL_ADC_FLAG_AWD3);
  7180. }
  7181. #if defined(ADC_MULTIMODE_SUPPORT)
  7182. /**
  7183. * @brief Get flag multimode ADC ready of the ADC master.
  7184. * @rmtoll CSR ADRDY_MST LL_ADC_IsActiveFlag_MST_ADRDY
  7185. * @param ADCxy_COMMON ADC common instance
  7186. * (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() )
  7187. * @retval State of bit (1 or 0).
  7188. */
  7189. __STATIC_INLINE uint32_t LL_ADC_IsActiveFlag_MST_ADRDY(const ADC_Common_TypeDef *ADCxy_COMMON)
  7190. {
  7191. return ((READ_BIT(ADCxy_COMMON->CSR, LL_ADC_FLAG_ADRDY_MST) == (LL_ADC_FLAG_ADRDY_MST)) ? 1UL : 0UL);
  7192. }
  7193. /**
  7194. * @brief Get flag multimode ADC ready of the ADC slave.
  7195. * @rmtoll CSR ADRDY_SLV LL_ADC_IsActiveFlag_SLV_ADRDY
  7196. * @param ADCxy_COMMON ADC common instance
  7197. * (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() )
  7198. * @retval State of bit (1 or 0).
  7199. */
  7200. __STATIC_INLINE uint32_t LL_ADC_IsActiveFlag_SLV_ADRDY(const ADC_Common_TypeDef *ADCxy_COMMON)
  7201. {
  7202. return ((READ_BIT(ADCxy_COMMON->CSR, LL_ADC_FLAG_ADRDY_SLV) == (LL_ADC_FLAG_ADRDY_SLV)) ? 1UL : 0UL);
  7203. }
  7204. /**
  7205. * @brief Get flag multimode ADC group regular end of unitary conversion of the ADC master.
  7206. * @rmtoll CSR EOC_MST LL_ADC_IsActiveFlag_MST_EOC
  7207. * @param ADCxy_COMMON ADC common instance
  7208. * (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() )
  7209. * @retval State of bit (1 or 0).
  7210. */
  7211. __STATIC_INLINE uint32_t LL_ADC_IsActiveFlag_MST_EOC(const ADC_Common_TypeDef *ADCxy_COMMON)
  7212. {
  7213. return ((READ_BIT(ADCxy_COMMON->CSR, LL_ADC_FLAG_EOC_SLV) == (LL_ADC_FLAG_EOC_SLV)) ? 1UL : 0UL);
  7214. }
  7215. /**
  7216. * @brief Get flag multimode ADC group regular end of unitary conversion of the ADC slave.
  7217. * @rmtoll CSR EOC_SLV LL_ADC_IsActiveFlag_SLV_EOC
  7218. * @param ADCxy_COMMON ADC common instance
  7219. * (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() )
  7220. * @retval State of bit (1 or 0).
  7221. */
  7222. __STATIC_INLINE uint32_t LL_ADC_IsActiveFlag_SLV_EOC(const ADC_Common_TypeDef *ADCxy_COMMON)
  7223. {
  7224. return ((READ_BIT(ADCxy_COMMON->CSR, LL_ADC_FLAG_EOC_SLV) == (LL_ADC_FLAG_EOC_SLV)) ? 1UL : 0UL);
  7225. }
  7226. /**
  7227. * @brief Get flag multimode ADC group regular end of sequence conversions of the ADC master.
  7228. * @rmtoll CSR EOS_MST LL_ADC_IsActiveFlag_MST_EOS
  7229. * @param ADCxy_COMMON ADC common instance
  7230. * (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() )
  7231. * @retval State of bit (1 or 0).
  7232. */
  7233. __STATIC_INLINE uint32_t LL_ADC_IsActiveFlag_MST_EOS(const ADC_Common_TypeDef *ADCxy_COMMON)
  7234. {
  7235. return ((READ_BIT(ADCxy_COMMON->CSR, LL_ADC_FLAG_EOS_MST) == (LL_ADC_FLAG_EOS_MST)) ? 1UL : 0UL);
  7236. }
  7237. /**
  7238. * @brief Get flag multimode ADC group regular end of sequence conversions of the ADC slave.
  7239. * @rmtoll CSR EOS_SLV LL_ADC_IsActiveFlag_SLV_EOS
  7240. * @param ADCxy_COMMON ADC common instance
  7241. * (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() )
  7242. * @retval State of bit (1 or 0).
  7243. */
  7244. __STATIC_INLINE uint32_t LL_ADC_IsActiveFlag_SLV_EOS(const ADC_Common_TypeDef *ADCxy_COMMON)
  7245. {
  7246. return ((READ_BIT(ADCxy_COMMON->CSR, LL_ADC_FLAG_EOS_SLV) == (LL_ADC_FLAG_EOS_SLV)) ? 1UL : 0UL);
  7247. }
  7248. /**
  7249. * @brief Get flag multimode ADC group regular overrun of the ADC master.
  7250. * @rmtoll CSR OVR_MST LL_ADC_IsActiveFlag_MST_OVR
  7251. * @param ADCxy_COMMON ADC common instance
  7252. * (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() )
  7253. * @retval State of bit (1 or 0).
  7254. */
  7255. __STATIC_INLINE uint32_t LL_ADC_IsActiveFlag_MST_OVR(const ADC_Common_TypeDef *ADCxy_COMMON)
  7256. {
  7257. return ((READ_BIT(ADCxy_COMMON->CSR, LL_ADC_FLAG_OVR_MST) == (LL_ADC_FLAG_OVR_MST)) ? 1UL : 0UL);
  7258. }
  7259. /**
  7260. * @brief Get flag multimode ADC group regular overrun of the ADC slave.
  7261. * @rmtoll CSR OVR_SLV LL_ADC_IsActiveFlag_SLV_OVR
  7262. * @param ADCxy_COMMON ADC common instance
  7263. * (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() )
  7264. * @retval State of bit (1 or 0).
  7265. */
  7266. __STATIC_INLINE uint32_t LL_ADC_IsActiveFlag_SLV_OVR(const ADC_Common_TypeDef *ADCxy_COMMON)
  7267. {
  7268. return ((READ_BIT(ADCxy_COMMON->CSR, LL_ADC_FLAG_OVR_SLV) == (LL_ADC_FLAG_OVR_SLV)) ? 1UL : 0UL);
  7269. }
  7270. /**
  7271. * @brief Get flag multimode ADC group regular end of sampling of the ADC master.
  7272. * @rmtoll CSR EOSMP_MST LL_ADC_IsActiveFlag_MST_EOSMP
  7273. * @param ADCxy_COMMON ADC common instance
  7274. * (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() )
  7275. * @retval State of bit (1 or 0).
  7276. */
  7277. __STATIC_INLINE uint32_t LL_ADC_IsActiveFlag_MST_EOSMP(const ADC_Common_TypeDef *ADCxy_COMMON)
  7278. {
  7279. return ((READ_BIT(ADCxy_COMMON->CSR, LL_ADC_FLAG_EOSMP_MST) == (LL_ADC_FLAG_EOSMP_MST)) ? 1UL : 0UL);
  7280. }
  7281. /**
  7282. * @brief Get flag multimode ADC group regular end of sampling of the ADC slave.
  7283. * @rmtoll CSR EOSMP_SLV LL_ADC_IsActiveFlag_SLV_EOSMP
  7284. * @param ADCxy_COMMON ADC common instance
  7285. * (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() )
  7286. * @retval State of bit (1 or 0).
  7287. */
  7288. __STATIC_INLINE uint32_t LL_ADC_IsActiveFlag_SLV_EOSMP(const ADC_Common_TypeDef *ADCxy_COMMON)
  7289. {
  7290. return ((READ_BIT(ADCxy_COMMON->CSR, LL_ADC_FLAG_EOSMP_SLV) == (LL_ADC_FLAG_EOSMP_SLV)) ? 1UL : 0UL);
  7291. }
  7292. /**
  7293. * @brief Get flag multimode ADC group injected end of unitary conversion of the ADC master.
  7294. * @rmtoll CSR JEOC_MST LL_ADC_IsActiveFlag_MST_JEOC
  7295. * @param ADCxy_COMMON ADC common instance
  7296. * (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() )
  7297. * @retval State of bit (1 or 0).
  7298. */
  7299. __STATIC_INLINE uint32_t LL_ADC_IsActiveFlag_MST_JEOC(const ADC_Common_TypeDef *ADCxy_COMMON)
  7300. {
  7301. return ((READ_BIT(ADCxy_COMMON->CSR, LL_ADC_FLAG_JEOC_MST) == (LL_ADC_FLAG_JEOC_MST)) ? 1UL : 0UL);
  7302. }
  7303. /**
  7304. * @brief Get flag multimode ADC group injected end of unitary conversion of the ADC slave.
  7305. * @rmtoll CSR JEOC_SLV LL_ADC_IsActiveFlag_SLV_JEOC
  7306. * @param ADCxy_COMMON ADC common instance
  7307. * (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() )
  7308. * @retval State of bit (1 or 0).
  7309. */
  7310. __STATIC_INLINE uint32_t LL_ADC_IsActiveFlag_SLV_JEOC(const ADC_Common_TypeDef *ADCxy_COMMON)
  7311. {
  7312. return ((READ_BIT(ADCxy_COMMON->CSR, LL_ADC_FLAG_JEOC_SLV) == (LL_ADC_FLAG_JEOC_SLV)) ? 1UL : 0UL);
  7313. }
  7314. /**
  7315. * @brief Get flag multimode ADC group injected end of sequence conversions of the ADC master.
  7316. * @rmtoll CSR JEOS_MST LL_ADC_IsActiveFlag_MST_JEOS
  7317. * @param ADCxy_COMMON ADC common instance
  7318. * (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() )
  7319. * @retval State of bit (1 or 0).
  7320. */
  7321. __STATIC_INLINE uint32_t LL_ADC_IsActiveFlag_MST_JEOS(const ADC_Common_TypeDef *ADCxy_COMMON)
  7322. {
  7323. return ((READ_BIT(ADCxy_COMMON->CSR, LL_ADC_FLAG_JEOS_MST) == (LL_ADC_FLAG_JEOS_MST)) ? 1UL : 0UL);
  7324. }
  7325. /**
  7326. * @brief Get flag multimode ADC group injected end of sequence conversions of the ADC slave.
  7327. * @rmtoll CSR JEOS_SLV LL_ADC_IsActiveFlag_SLV_JEOS
  7328. * @param ADCxy_COMMON ADC common instance
  7329. * (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() )
  7330. * @retval State of bit (1 or 0).
  7331. */
  7332. __STATIC_INLINE uint32_t LL_ADC_IsActiveFlag_SLV_JEOS(const ADC_Common_TypeDef *ADCxy_COMMON)
  7333. {
  7334. return ((READ_BIT(ADCxy_COMMON->CSR, LL_ADC_FLAG_JEOS_SLV) == (LL_ADC_FLAG_JEOS_SLV)) ? 1UL : 0UL);
  7335. }
  7336. /**
  7337. * @brief Get flag multimode ADC group injected context queue overflow of the ADC master.
  7338. * @rmtoll CSR JQOVF_MST LL_ADC_IsActiveFlag_MST_JQOVF
  7339. * @param ADCxy_COMMON ADC common instance
  7340. * (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() )
  7341. * @retval State of bit (1 or 0).
  7342. */
  7343. __STATIC_INLINE uint32_t LL_ADC_IsActiveFlag_MST_JQOVF(const ADC_Common_TypeDef *ADCxy_COMMON)
  7344. {
  7345. return ((READ_BIT(ADCxy_COMMON->CSR, LL_ADC_FLAG_JQOVF_MST) == (LL_ADC_FLAG_JQOVF_MST)) ? 1UL : 0UL);
  7346. }
  7347. /**
  7348. * @brief Get flag multimode ADC group injected context queue overflow of the ADC slave.
  7349. * @rmtoll CSR JQOVF_SLV LL_ADC_IsActiveFlag_SLV_JQOVF
  7350. * @param ADCxy_COMMON ADC common instance
  7351. * (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() )
  7352. * @retval State of bit (1 or 0).
  7353. */
  7354. __STATIC_INLINE uint32_t LL_ADC_IsActiveFlag_SLV_JQOVF(const ADC_Common_TypeDef *ADCxy_COMMON)
  7355. {
  7356. return ((READ_BIT(ADCxy_COMMON->CSR, LL_ADC_FLAG_JQOVF_SLV) == (LL_ADC_FLAG_JQOVF_SLV)) ? 1UL : 0UL);
  7357. }
  7358. /**
  7359. * @brief Get flag multimode ADC analog watchdog 1 of the ADC master.
  7360. * @rmtoll CSR AWD1_MST LL_ADC_IsActiveFlag_MST_AWD1
  7361. * @param ADCxy_COMMON ADC common instance
  7362. * (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() )
  7363. * @retval State of bit (1 or 0).
  7364. */
  7365. __STATIC_INLINE uint32_t LL_ADC_IsActiveFlag_MST_AWD1(const ADC_Common_TypeDef *ADCxy_COMMON)
  7366. {
  7367. return ((READ_BIT(ADCxy_COMMON->CSR, LL_ADC_FLAG_AWD1_MST) == (LL_ADC_FLAG_AWD1_MST)) ? 1UL : 0UL);
  7368. }
  7369. /**
  7370. * @brief Get flag multimode analog watchdog 1 of the ADC slave.
  7371. * @rmtoll CSR AWD1_SLV LL_ADC_IsActiveFlag_SLV_AWD1
  7372. * @param ADCxy_COMMON ADC common instance
  7373. * (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() )
  7374. * @retval State of bit (1 or 0).
  7375. */
  7376. __STATIC_INLINE uint32_t LL_ADC_IsActiveFlag_SLV_AWD1(const ADC_Common_TypeDef *ADCxy_COMMON)
  7377. {
  7378. return ((READ_BIT(ADCxy_COMMON->CSR, LL_ADC_FLAG_AWD1_SLV) == (LL_ADC_FLAG_AWD1_SLV)) ? 1UL : 0UL);
  7379. }
  7380. /**
  7381. * @brief Get flag multimode ADC analog watchdog 2 of the ADC master.
  7382. * @rmtoll CSR AWD2_MST LL_ADC_IsActiveFlag_MST_AWD2
  7383. * @param ADCxy_COMMON ADC common instance
  7384. * (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() )
  7385. * @retval State of bit (1 or 0).
  7386. */
  7387. __STATIC_INLINE uint32_t LL_ADC_IsActiveFlag_MST_AWD2(const ADC_Common_TypeDef *ADCxy_COMMON)
  7388. {
  7389. return ((READ_BIT(ADCxy_COMMON->CSR, LL_ADC_FLAG_AWD2_MST) == (LL_ADC_FLAG_AWD2_MST)) ? 1UL : 0UL);
  7390. }
  7391. /**
  7392. * @brief Get flag multimode ADC analog watchdog 2 of the ADC slave.
  7393. * @rmtoll CSR AWD2_SLV LL_ADC_IsActiveFlag_SLV_AWD2
  7394. * @param ADCxy_COMMON ADC common instance
  7395. * (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() )
  7396. * @retval State of bit (1 or 0).
  7397. */
  7398. __STATIC_INLINE uint32_t LL_ADC_IsActiveFlag_SLV_AWD2(const ADC_Common_TypeDef *ADCxy_COMMON)
  7399. {
  7400. return ((READ_BIT(ADCxy_COMMON->CSR, LL_ADC_FLAG_AWD2_SLV) == (LL_ADC_FLAG_AWD2_SLV)) ? 1UL : 0UL);
  7401. }
  7402. /**
  7403. * @brief Get flag multimode ADC analog watchdog 3 of the ADC master.
  7404. * @rmtoll CSR AWD3_MST LL_ADC_IsActiveFlag_MST_AWD3
  7405. * @param ADCxy_COMMON ADC common instance
  7406. * (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() )
  7407. * @retval State of bit (1 or 0).
  7408. */
  7409. __STATIC_INLINE uint32_t LL_ADC_IsActiveFlag_MST_AWD3(const ADC_Common_TypeDef *ADCxy_COMMON)
  7410. {
  7411. return ((READ_BIT(ADCxy_COMMON->CSR, LL_ADC_FLAG_AWD3_MST) == (LL_ADC_FLAG_AWD3_MST)) ? 1UL : 0UL);
  7412. }
  7413. /**
  7414. * @brief Get flag multimode ADC analog watchdog 3 of the ADC slave.
  7415. * @rmtoll CSR AWD3_SLV LL_ADC_IsActiveFlag_SLV_AWD3
  7416. * @param ADCxy_COMMON ADC common instance
  7417. * (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() )
  7418. * @retval State of bit (1 or 0).
  7419. */
  7420. __STATIC_INLINE uint32_t LL_ADC_IsActiveFlag_SLV_AWD3(const ADC_Common_TypeDef *ADCxy_COMMON)
  7421. {
  7422. return ((READ_BIT(ADCxy_COMMON->CSR, LL_ADC_FLAG_AWD3_SLV) == (LL_ADC_FLAG_AWD3_SLV)) ? 1UL : 0UL);
  7423. }
  7424. #endif /* ADC_MULTIMODE_SUPPORT */
  7425. /**
  7426. * @}
  7427. */
  7428. /** @defgroup ADC_LL_EF_IT_Management ADC IT management
  7429. * @{
  7430. */
  7431. /**
  7432. * @brief Enable ADC ready.
  7433. * @rmtoll IER ADRDYIE LL_ADC_EnableIT_ADRDY
  7434. * @param ADCx ADC instance
  7435. * @retval None
  7436. */
  7437. __STATIC_INLINE void LL_ADC_EnableIT_ADRDY(ADC_TypeDef *ADCx)
  7438. {
  7439. SET_BIT(ADCx->IER, LL_ADC_IT_ADRDY);
  7440. }
  7441. /**
  7442. * @brief Enable interruption ADC group regular end of unitary conversion.
  7443. * @rmtoll IER EOCIE LL_ADC_EnableIT_EOC
  7444. * @param ADCx ADC instance
  7445. * @retval None
  7446. */
  7447. __STATIC_INLINE void LL_ADC_EnableIT_EOC(ADC_TypeDef *ADCx)
  7448. {
  7449. SET_BIT(ADCx->IER, LL_ADC_IT_EOC);
  7450. }
  7451. /**
  7452. * @brief Enable interruption ADC group regular end of sequence conversions.
  7453. * @rmtoll IER EOSIE LL_ADC_EnableIT_EOS
  7454. * @param ADCx ADC instance
  7455. * @retval None
  7456. */
  7457. __STATIC_INLINE void LL_ADC_EnableIT_EOS(ADC_TypeDef *ADCx)
  7458. {
  7459. SET_BIT(ADCx->IER, LL_ADC_IT_EOS);
  7460. }
  7461. /**
  7462. * @brief Enable ADC group regular interruption overrun.
  7463. * @rmtoll IER OVRIE LL_ADC_EnableIT_OVR
  7464. * @param ADCx ADC instance
  7465. * @retval None
  7466. */
  7467. __STATIC_INLINE void LL_ADC_EnableIT_OVR(ADC_TypeDef *ADCx)
  7468. {
  7469. SET_BIT(ADCx->IER, LL_ADC_IT_OVR);
  7470. }
  7471. /**
  7472. * @brief Enable interruption ADC group regular end of sampling.
  7473. * @rmtoll IER EOSMPIE LL_ADC_EnableIT_EOSMP
  7474. * @param ADCx ADC instance
  7475. * @retval None
  7476. */
  7477. __STATIC_INLINE void LL_ADC_EnableIT_EOSMP(ADC_TypeDef *ADCx)
  7478. {
  7479. SET_BIT(ADCx->IER, LL_ADC_IT_EOSMP);
  7480. }
  7481. /**
  7482. * @brief Enable interruption ADC group injected end of unitary conversion.
  7483. * @rmtoll IER JEOCIE LL_ADC_EnableIT_JEOC
  7484. * @param ADCx ADC instance
  7485. * @retval None
  7486. */
  7487. __STATIC_INLINE void LL_ADC_EnableIT_JEOC(ADC_TypeDef *ADCx)
  7488. {
  7489. SET_BIT(ADCx->IER, LL_ADC_IT_JEOC);
  7490. }
  7491. /**
  7492. * @brief Enable interruption ADC group injected end of sequence conversions.
  7493. * @rmtoll IER JEOSIE LL_ADC_EnableIT_JEOS
  7494. * @param ADCx ADC instance
  7495. * @retval None
  7496. */
  7497. __STATIC_INLINE void LL_ADC_EnableIT_JEOS(ADC_TypeDef *ADCx)
  7498. {
  7499. SET_BIT(ADCx->IER, LL_ADC_IT_JEOS);
  7500. }
  7501. /**
  7502. * @brief Enable interruption ADC group injected context queue overflow.
  7503. * @rmtoll IER JQOVFIE LL_ADC_EnableIT_JQOVF
  7504. * @param ADCx ADC instance
  7505. * @retval None
  7506. */
  7507. __STATIC_INLINE void LL_ADC_EnableIT_JQOVF(ADC_TypeDef *ADCx)
  7508. {
  7509. SET_BIT(ADCx->IER, LL_ADC_IT_JQOVF);
  7510. }
  7511. /**
  7512. * @brief Enable interruption ADC analog watchdog 1.
  7513. * @rmtoll IER AWD1IE LL_ADC_EnableIT_AWD1
  7514. * @param ADCx ADC instance
  7515. * @retval None
  7516. */
  7517. __STATIC_INLINE void LL_ADC_EnableIT_AWD1(ADC_TypeDef *ADCx)
  7518. {
  7519. SET_BIT(ADCx->IER, LL_ADC_IT_AWD1);
  7520. }
  7521. /**
  7522. * @brief Enable interruption ADC analog watchdog 2.
  7523. * @rmtoll IER AWD2IE LL_ADC_EnableIT_AWD2
  7524. * @param ADCx ADC instance
  7525. * @retval None
  7526. */
  7527. __STATIC_INLINE void LL_ADC_EnableIT_AWD2(ADC_TypeDef *ADCx)
  7528. {
  7529. SET_BIT(ADCx->IER, LL_ADC_IT_AWD2);
  7530. }
  7531. /**
  7532. * @brief Enable interruption ADC analog watchdog 3.
  7533. * @rmtoll IER AWD3IE LL_ADC_EnableIT_AWD3
  7534. * @param ADCx ADC instance
  7535. * @retval None
  7536. */
  7537. __STATIC_INLINE void LL_ADC_EnableIT_AWD3(ADC_TypeDef *ADCx)
  7538. {
  7539. SET_BIT(ADCx->IER, LL_ADC_IT_AWD3);
  7540. }
  7541. /**
  7542. * @brief Disable interruption ADC ready.
  7543. * @rmtoll IER ADRDYIE LL_ADC_DisableIT_ADRDY
  7544. * @param ADCx ADC instance
  7545. * @retval None
  7546. */
  7547. __STATIC_INLINE void LL_ADC_DisableIT_ADRDY(ADC_TypeDef *ADCx)
  7548. {
  7549. CLEAR_BIT(ADCx->IER, LL_ADC_IT_ADRDY);
  7550. }
  7551. /**
  7552. * @brief Disable interruption ADC group regular end of unitary conversion.
  7553. * @rmtoll IER EOCIE LL_ADC_DisableIT_EOC
  7554. * @param ADCx ADC instance
  7555. * @retval None
  7556. */
  7557. __STATIC_INLINE void LL_ADC_DisableIT_EOC(ADC_TypeDef *ADCx)
  7558. {
  7559. CLEAR_BIT(ADCx->IER, LL_ADC_IT_EOC);
  7560. }
  7561. /**
  7562. * @brief Disable interruption ADC group regular end of sequence conversions.
  7563. * @rmtoll IER EOSIE LL_ADC_DisableIT_EOS
  7564. * @param ADCx ADC instance
  7565. * @retval None
  7566. */
  7567. __STATIC_INLINE void LL_ADC_DisableIT_EOS(ADC_TypeDef *ADCx)
  7568. {
  7569. CLEAR_BIT(ADCx->IER, LL_ADC_IT_EOS);
  7570. }
  7571. /**
  7572. * @brief Disable interruption ADC group regular overrun.
  7573. * @rmtoll IER OVRIE LL_ADC_DisableIT_OVR
  7574. * @param ADCx ADC instance
  7575. * @retval None
  7576. */
  7577. __STATIC_INLINE void LL_ADC_DisableIT_OVR(ADC_TypeDef *ADCx)
  7578. {
  7579. CLEAR_BIT(ADCx->IER, LL_ADC_IT_OVR);
  7580. }
  7581. /**
  7582. * @brief Disable interruption ADC group regular end of sampling.
  7583. * @rmtoll IER EOSMPIE LL_ADC_DisableIT_EOSMP
  7584. * @param ADCx ADC instance
  7585. * @retval None
  7586. */
  7587. __STATIC_INLINE void LL_ADC_DisableIT_EOSMP(ADC_TypeDef *ADCx)
  7588. {
  7589. CLEAR_BIT(ADCx->IER, LL_ADC_IT_EOSMP);
  7590. }
  7591. /**
  7592. * @brief Disable interruption ADC group regular end of unitary conversion.
  7593. * @rmtoll IER JEOCIE LL_ADC_DisableIT_JEOC
  7594. * @param ADCx ADC instance
  7595. * @retval None
  7596. */
  7597. __STATIC_INLINE void LL_ADC_DisableIT_JEOC(ADC_TypeDef *ADCx)
  7598. {
  7599. CLEAR_BIT(ADCx->IER, LL_ADC_IT_JEOC);
  7600. }
  7601. /**
  7602. * @brief Disable interruption ADC group injected end of sequence conversions.
  7603. * @rmtoll IER JEOSIE LL_ADC_DisableIT_JEOS
  7604. * @param ADCx ADC instance
  7605. * @retval None
  7606. */
  7607. __STATIC_INLINE void LL_ADC_DisableIT_JEOS(ADC_TypeDef *ADCx)
  7608. {
  7609. CLEAR_BIT(ADCx->IER, LL_ADC_IT_JEOS);
  7610. }
  7611. /**
  7612. * @brief Disable interruption ADC group injected context queue overflow.
  7613. * @rmtoll IER JQOVFIE LL_ADC_DisableIT_JQOVF
  7614. * @param ADCx ADC instance
  7615. * @retval None
  7616. */
  7617. __STATIC_INLINE void LL_ADC_DisableIT_JQOVF(ADC_TypeDef *ADCx)
  7618. {
  7619. CLEAR_BIT(ADCx->IER, LL_ADC_IT_JQOVF);
  7620. }
  7621. /**
  7622. * @brief Disable interruption ADC analog watchdog 1.
  7623. * @rmtoll IER AWD1IE LL_ADC_DisableIT_AWD1
  7624. * @param ADCx ADC instance
  7625. * @retval None
  7626. */
  7627. __STATIC_INLINE void LL_ADC_DisableIT_AWD1(ADC_TypeDef *ADCx)
  7628. {
  7629. CLEAR_BIT(ADCx->IER, LL_ADC_IT_AWD1);
  7630. }
  7631. /**
  7632. * @brief Disable interruption ADC analog watchdog 2.
  7633. * @rmtoll IER AWD2IE LL_ADC_DisableIT_AWD2
  7634. * @param ADCx ADC instance
  7635. * @retval None
  7636. */
  7637. __STATIC_INLINE void LL_ADC_DisableIT_AWD2(ADC_TypeDef *ADCx)
  7638. {
  7639. CLEAR_BIT(ADCx->IER, LL_ADC_IT_AWD2);
  7640. }
  7641. /**
  7642. * @brief Disable interruption ADC analog watchdog 3.
  7643. * @rmtoll IER AWD3IE LL_ADC_DisableIT_AWD3
  7644. * @param ADCx ADC instance
  7645. * @retval None
  7646. */
  7647. __STATIC_INLINE void LL_ADC_DisableIT_AWD3(ADC_TypeDef *ADCx)
  7648. {
  7649. CLEAR_BIT(ADCx->IER, LL_ADC_IT_AWD3);
  7650. }
  7651. /**
  7652. * @brief Get state of interruption ADC ready
  7653. * (0: interrupt disabled, 1: interrupt enabled).
  7654. * @rmtoll IER ADRDYIE LL_ADC_IsEnabledIT_ADRDY
  7655. * @param ADCx ADC instance
  7656. * @retval State of bit (1 or 0).
  7657. */
  7658. __STATIC_INLINE uint32_t LL_ADC_IsEnabledIT_ADRDY(const ADC_TypeDef *ADCx)
  7659. {
  7660. return ((READ_BIT(ADCx->IER, LL_ADC_IT_ADRDY) == (LL_ADC_IT_ADRDY)) ? 1UL : 0UL);
  7661. }
  7662. /**
  7663. * @brief Get state of interruption ADC group regular end of unitary conversion
  7664. * (0: interrupt disabled, 1: interrupt enabled).
  7665. * @rmtoll IER EOCIE LL_ADC_IsEnabledIT_EOC
  7666. * @param ADCx ADC instance
  7667. * @retval State of bit (1 or 0).
  7668. */
  7669. __STATIC_INLINE uint32_t LL_ADC_IsEnabledIT_EOC(const ADC_TypeDef *ADCx)
  7670. {
  7671. return ((READ_BIT(ADCx->IER, LL_ADC_IT_EOC) == (LL_ADC_IT_EOC)) ? 1UL : 0UL);
  7672. }
  7673. /**
  7674. * @brief Get state of interruption ADC group regular end of sequence conversions
  7675. * (0: interrupt disabled, 1: interrupt enabled).
  7676. * @rmtoll IER EOSIE LL_ADC_IsEnabledIT_EOS
  7677. * @param ADCx ADC instance
  7678. * @retval State of bit (1 or 0).
  7679. */
  7680. __STATIC_INLINE uint32_t LL_ADC_IsEnabledIT_EOS(const ADC_TypeDef *ADCx)
  7681. {
  7682. return ((READ_BIT(ADCx->IER, LL_ADC_IT_EOS) == (LL_ADC_IT_EOS)) ? 1UL : 0UL);
  7683. }
  7684. /**
  7685. * @brief Get state of interruption ADC group regular overrun
  7686. * (0: interrupt disabled, 1: interrupt enabled).
  7687. * @rmtoll IER OVRIE LL_ADC_IsEnabledIT_OVR
  7688. * @param ADCx ADC instance
  7689. * @retval State of bit (1 or 0).
  7690. */
  7691. __STATIC_INLINE uint32_t LL_ADC_IsEnabledIT_OVR(const ADC_TypeDef *ADCx)
  7692. {
  7693. return ((READ_BIT(ADCx->IER, LL_ADC_IT_OVR) == (LL_ADC_IT_OVR)) ? 1UL : 0UL);
  7694. }
  7695. /**
  7696. * @brief Get state of interruption ADC group regular end of sampling
  7697. * (0: interrupt disabled, 1: interrupt enabled).
  7698. * @rmtoll IER EOSMPIE LL_ADC_IsEnabledIT_EOSMP
  7699. * @param ADCx ADC instance
  7700. * @retval State of bit (1 or 0).
  7701. */
  7702. __STATIC_INLINE uint32_t LL_ADC_IsEnabledIT_EOSMP(const ADC_TypeDef *ADCx)
  7703. {
  7704. return ((READ_BIT(ADCx->IER, LL_ADC_IT_EOSMP) == (LL_ADC_IT_EOSMP)) ? 1UL : 0UL);
  7705. }
  7706. /**
  7707. * @brief Get state of interruption ADC group injected end of unitary conversion
  7708. * (0: interrupt disabled, 1: interrupt enabled).
  7709. * @rmtoll IER JEOCIE LL_ADC_IsEnabledIT_JEOC
  7710. * @param ADCx ADC instance
  7711. * @retval State of bit (1 or 0).
  7712. */
  7713. __STATIC_INLINE uint32_t LL_ADC_IsEnabledIT_JEOC(const ADC_TypeDef *ADCx)
  7714. {
  7715. return ((READ_BIT(ADCx->IER, LL_ADC_IT_JEOC) == (LL_ADC_IT_JEOC)) ? 1UL : 0UL);
  7716. }
  7717. /**
  7718. * @brief Get state of interruption ADC group injected end of sequence conversions
  7719. * (0: interrupt disabled, 1: interrupt enabled).
  7720. * @rmtoll IER JEOSIE LL_ADC_IsEnabledIT_JEOS
  7721. * @param ADCx ADC instance
  7722. * @retval State of bit (1 or 0).
  7723. */
  7724. __STATIC_INLINE uint32_t LL_ADC_IsEnabledIT_JEOS(const ADC_TypeDef *ADCx)
  7725. {
  7726. return ((READ_BIT(ADCx->IER, LL_ADC_IT_JEOS) == (LL_ADC_IT_JEOS)) ? 1UL : 0UL);
  7727. }
  7728. /**
  7729. * @brief Get state of interruption ADC group injected context queue overflow interrupt state
  7730. * (0: interrupt disabled, 1: interrupt enabled).
  7731. * @rmtoll IER JQOVFIE LL_ADC_IsEnabledIT_JQOVF
  7732. * @param ADCx ADC instance
  7733. * @retval State of bit (1 or 0).
  7734. */
  7735. __STATIC_INLINE uint32_t LL_ADC_IsEnabledIT_JQOVF(const ADC_TypeDef *ADCx)
  7736. {
  7737. return ((READ_BIT(ADCx->IER, LL_ADC_IT_JQOVF) == (LL_ADC_IT_JQOVF)) ? 1UL : 0UL);
  7738. }
  7739. /**
  7740. * @brief Get state of interruption ADC analog watchdog 1
  7741. * (0: interrupt disabled, 1: interrupt enabled).
  7742. * @rmtoll IER AWD1IE LL_ADC_IsEnabledIT_AWD1
  7743. * @param ADCx ADC instance
  7744. * @retval State of bit (1 or 0).
  7745. */
  7746. __STATIC_INLINE uint32_t LL_ADC_IsEnabledIT_AWD1(const ADC_TypeDef *ADCx)
  7747. {
  7748. return ((READ_BIT(ADCx->IER, LL_ADC_IT_AWD1) == (LL_ADC_IT_AWD1)) ? 1UL : 0UL);
  7749. }
  7750. /**
  7751. * @brief Get state of interruption Get ADC analog watchdog 2
  7752. * (0: interrupt disabled, 1: interrupt enabled).
  7753. * @rmtoll IER AWD2IE LL_ADC_IsEnabledIT_AWD2
  7754. * @param ADCx ADC instance
  7755. * @retval State of bit (1 or 0).
  7756. */
  7757. __STATIC_INLINE uint32_t LL_ADC_IsEnabledIT_AWD2(const ADC_TypeDef *ADCx)
  7758. {
  7759. return ((READ_BIT(ADCx->IER, LL_ADC_IT_AWD2) == (LL_ADC_IT_AWD2)) ? 1UL : 0UL);
  7760. }
  7761. /**
  7762. * @brief Get state of interruption Get ADC analog watchdog 3
  7763. * (0: interrupt disabled, 1: interrupt enabled).
  7764. * @rmtoll IER AWD3IE LL_ADC_IsEnabledIT_AWD3
  7765. * @param ADCx ADC instance
  7766. * @retval State of bit (1 or 0).
  7767. */
  7768. __STATIC_INLINE uint32_t LL_ADC_IsEnabledIT_AWD3(const ADC_TypeDef *ADCx)
  7769. {
  7770. return ((READ_BIT(ADCx->IER, LL_ADC_IT_AWD3) == (LL_ADC_IT_AWD3)) ? 1UL : 0UL);
  7771. }
  7772. /**
  7773. * @}
  7774. */
  7775. #if defined(USE_FULL_LL_DRIVER)
  7776. /** @defgroup ADC_LL_EF_Init Initialization and de-initialization functions
  7777. * @{
  7778. */
  7779. /* Initialization of some features of ADC common parameters and multimode */
  7780. ErrorStatus LL_ADC_CommonDeInit(const ADC_Common_TypeDef *ADCxy_COMMON);
  7781. ErrorStatus LL_ADC_CommonInit(ADC_Common_TypeDef *ADCxy_COMMON, const LL_ADC_CommonInitTypeDef *pADC_CommonInitStruct);
  7782. void LL_ADC_CommonStructInit(LL_ADC_CommonInitTypeDef *pADC_CommonInitStruct);
  7783. /* De-initialization of ADC instance, ADC group regular and ADC group injected */
  7784. /* (availability of ADC group injected depends on STM32 series) */
  7785. ErrorStatus LL_ADC_DeInit(ADC_TypeDef *ADCx);
  7786. /* Initialization of some features of ADC instance */
  7787. ErrorStatus LL_ADC_Init(ADC_TypeDef *ADCx, const LL_ADC_InitTypeDef *pADC_InitStruct);
  7788. void LL_ADC_StructInit(LL_ADC_InitTypeDef *pADC_InitStruct);
  7789. /* Initialization of some features of ADC instance and ADC group regular */
  7790. ErrorStatus LL_ADC_REG_Init(ADC_TypeDef *ADCx, const LL_ADC_REG_InitTypeDef *pADC_RegInitStruct);
  7791. void LL_ADC_REG_StructInit(LL_ADC_REG_InitTypeDef *pADC_RegInitStruct);
  7792. /* Initialization of some features of ADC instance and ADC group injected */
  7793. ErrorStatus LL_ADC_INJ_Init(ADC_TypeDef *ADCx, const LL_ADC_INJ_InitTypeDef *pADC_InjInitStruct);
  7794. void LL_ADC_INJ_StructInit(LL_ADC_INJ_InitTypeDef *pADC_InjInitStruct);
  7795. /**
  7796. * @}
  7797. */
  7798. #endif /* USE_FULL_LL_DRIVER */
  7799. /**
  7800. * @}
  7801. */
  7802. /**
  7803. * @}
  7804. */
  7805. #endif /* ADC1 || ADC2 || ADC3 */
  7806. /**
  7807. * @}
  7808. */
  7809. #ifdef __cplusplus
  7810. }
  7811. #endif
  7812. #endif /* STM32L4xx_LL_ADC_H */