stm32g4xx_ll_adc.h 518 KB

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