stm32l4xx_ll_adc.h 427 KB

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