stm32l4xx_ll_adc.h 420 KB

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