stm32f3xx_ll_adc.h 657 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833
  1. /**
  2. ******************************************************************************
  3. * @file stm32f3xx_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) 2016 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 __STM32F3xx_LL_ADC_H
  37. #define __STM32F3xx_LL_ADC_H
  38. #ifdef __cplusplus
  39. extern "C" {
  40. #endif
  41. /* Includes ------------------------------------------------------------------*/
  42. #include "stm32f3xx.h"
  43. /** @addtogroup STM32F3xx_LL_Driver
  44. * @{
  45. */
  46. /* Note: Devices of STM32F3 serie embed 1 out of 2 different ADC IP. */
  47. /* - STM32F30x, STM32F31x, STM32F32x, STM32F33x, STM32F35x, STM32F39x: */
  48. /* ADC IP 5Msamples/sec, from 1 to 4 ADC instances and other specific */
  49. /* features (refer to reference manual). */
  50. /* - STM32F37x: */
  51. /* ADC IP 1Msamples/sec, 1 ADC instance */
  52. /* This file contains the drivers of these ADC IP, located in 2 area */
  53. /* delimited by compilation switches. */
  54. #if defined(ADC5_V1_1)
  55. #if defined (ADC1) || defined (ADC2) || defined (ADC3) || defined (ADC4)
  56. /** @defgroup ADC_LL ADC
  57. * @{
  58. */
  59. /* Private types -------------------------------------------------------------*/
  60. /* Private variables ---------------------------------------------------------*/
  61. /* Private constants ---------------------------------------------------------*/
  62. /** @defgroup ADC_LL_Private_Constants ADC Private Constants
  63. * @{
  64. */
  65. /* Internal mask for ADC group regular sequencer: */
  66. /* To select into literal LL_ADC_REG_RANK_x the relevant bits for: */
  67. /* - sequencer register offset */
  68. /* - sequencer rank bits position into the selected register */
  69. /* Internal register offset for ADC group regular sequencer configuration */
  70. /* (offset placed into a spare area of literal definition) */
  71. #define ADC_SQR1_REGOFFSET ((uint32_t)0x00000000U)
  72. #define ADC_SQR2_REGOFFSET ((uint32_t)0x00000100U)
  73. #define ADC_SQR3_REGOFFSET ((uint32_t)0x00000200U)
  74. #define ADC_SQR4_REGOFFSET ((uint32_t)0x00000300U)
  75. #define ADC_REG_SQRX_REGOFFSET_MASK (ADC_SQR1_REGOFFSET | ADC_SQR2_REGOFFSET | ADC_SQR3_REGOFFSET | ADC_SQR4_REGOFFSET)
  76. #define ADC_REG_RANK_ID_SQRX_MASK (ADC_CHANNEL_ID_NUMBER_MASK_POSBIT0)
  77. /* Definition of ADC group regular sequencer bits information to be inserted */
  78. /* into ADC group regular sequencer ranks literals definition. */
  79. #define ADC_REG_RANK_1_SQRX_BITOFFSET_POS ((uint32_t) 6U) /* Value equivalent to POSITION_VAL(ADC_SQR1_SQ1) */
  80. #define ADC_REG_RANK_2_SQRX_BITOFFSET_POS ((uint32_t)12U) /* Value equivalent to POSITION_VAL(ADC_SQR1_SQ2) */
  81. #define ADC_REG_RANK_3_SQRX_BITOFFSET_POS ((uint32_t)18U) /* Value equivalent to POSITION_VAL(ADC_SQR1_SQ3) */
  82. #define ADC_REG_RANK_4_SQRX_BITOFFSET_POS ((uint32_t)24U) /* Value equivalent to POSITION_VAL(ADC_SQR1_SQ4) */
  83. #define ADC_REG_RANK_5_SQRX_BITOFFSET_POS ((uint32_t) 0U) /* Value equivalent to POSITION_VAL(ADC_SQR2_SQ5) */
  84. #define ADC_REG_RANK_6_SQRX_BITOFFSET_POS ((uint32_t) 6U) /* Value equivalent to POSITION_VAL(ADC_SQR2_SQ6) */
  85. #define ADC_REG_RANK_7_SQRX_BITOFFSET_POS ((uint32_t)12U) /* Value equivalent to POSITION_VAL(ADC_SQR2_SQ7) */
  86. #define ADC_REG_RANK_8_SQRX_BITOFFSET_POS ((uint32_t)18U) /* Value equivalent to POSITION_VAL(ADC_SQR2_SQ8) */
  87. #define ADC_REG_RANK_9_SQRX_BITOFFSET_POS ((uint32_t)24U) /* Value equivalent to POSITION_VAL(ADC_SQR2_SQ9) */
  88. #define ADC_REG_RANK_10_SQRX_BITOFFSET_POS ((uint32_t) 0U) /* Value equivalent to POSITION_VAL(ADC_SQR3_SQ10) */
  89. #define ADC_REG_RANK_11_SQRX_BITOFFSET_POS ((uint32_t) 6U) /* Value equivalent to POSITION_VAL(ADC_SQR3_SQ11) */
  90. #define ADC_REG_RANK_12_SQRX_BITOFFSET_POS ((uint32_t)12U) /* Value equivalent to POSITION_VAL(ADC_SQR3_SQ12) */
  91. #define ADC_REG_RANK_13_SQRX_BITOFFSET_POS ((uint32_t)18U) /* Value equivalent to POSITION_VAL(ADC_SQR3_SQ13) */
  92. #define ADC_REG_RANK_14_SQRX_BITOFFSET_POS ((uint32_t)24U) /* Value equivalent to POSITION_VAL(ADC_SQR3_SQ14) */
  93. #define ADC_REG_RANK_15_SQRX_BITOFFSET_POS ((uint32_t) 0U) /* Value equivalent to POSITION_VAL(ADC_SQR4_SQ15) */
  94. #define ADC_REG_RANK_16_SQRX_BITOFFSET_POS ((uint32_t) 6U) /* Value equivalent to POSITION_VAL(ADC_SQR4_SQ16) */
  95. /* Internal mask for ADC group injected sequencer: */
  96. /* To select into literal LL_ADC_INJ_RANK_x the relevant bits for: */
  97. /* - data register offset */
  98. /* - sequencer rank bits position into the selected register */
  99. /* Internal register offset for ADC group injected data register */
  100. /* (offset placed into a spare area of literal definition) */
  101. #define ADC_JDR1_REGOFFSET ((uint32_t)0x00000000U)
  102. #define ADC_JDR2_REGOFFSET ((uint32_t)0x00000100U)
  103. #define ADC_JDR3_REGOFFSET ((uint32_t)0x00000200U)
  104. #define ADC_JDR4_REGOFFSET ((uint32_t)0x00000300U)
  105. #define ADC_INJ_JDRX_REGOFFSET_MASK (ADC_JDR1_REGOFFSET | ADC_JDR2_REGOFFSET | ADC_JDR3_REGOFFSET | ADC_JDR4_REGOFFSET)
  106. #define ADC_INJ_RANK_ID_JSQR_MASK (ADC_CHANNEL_ID_NUMBER_MASK_POSBIT0)
  107. /* Definition of ADC group injected sequencer bits information to be inserted */
  108. /* into ADC group injected sequencer ranks literals definition. */
  109. #define ADC_INJ_RANK_1_JSQR_BITOFFSET_POS ((uint32_t) 8U) /* Value equivalent to POSITION_VAL(ADC_JSQR_JSQ1) */
  110. #define ADC_INJ_RANK_2_JSQR_BITOFFSET_POS ((uint32_t)14U) /* Value equivalent to POSITION_VAL(ADC_JSQR_JSQ2) */
  111. #define ADC_INJ_RANK_3_JSQR_BITOFFSET_POS ((uint32_t)20U) /* Value equivalent to POSITION_VAL(ADC_JSQR_JSQ3) */
  112. #define ADC_INJ_RANK_4_JSQR_BITOFFSET_POS ((uint32_t)26U) /* Value equivalent to POSITION_VAL(ADC_JSQR_JSQ4) */
  113. /* Internal mask for ADC group regular trigger: */
  114. /* To select into literal LL_ADC_REG_TRIG_x the relevant bits for: */
  115. /* - regular trigger source */
  116. /* - regular trigger edge */
  117. #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) */
  118. /* Mask containing trigger source masks for each of possible */
  119. /* trigger edge selection duplicated with shifts [0; 4; 8; 12] */
  120. /* corresponding to {SW start; ext trigger; ext trigger; ext trigger}. */
  121. #define ADC_REG_TRIG_SOURCE_MASK (((LL_ADC_REG_TRIG_SOFTWARE & ADC_CFGR_EXTSEL) << (4U * 0U)) | \
  122. ((ADC_CFGR_EXTSEL) << (4U * 1U)) | \
  123. ((ADC_CFGR_EXTSEL) << (4U * 2U)) | \
  124. ((ADC_CFGR_EXTSEL) << (4U * 3U)) )
  125. /* Mask containing trigger edge masks for each of possible */
  126. /* trigger edge selection duplicated with shifts [0; 4; 8; 12] */
  127. /* corresponding to {SW start; ext trigger; ext trigger; ext trigger}. */
  128. #define ADC_REG_TRIG_EDGE_MASK (((LL_ADC_REG_TRIG_SOFTWARE & ADC_CFGR_EXTEN) << (4U * 0U)) | \
  129. ((ADC_REG_TRIG_EXT_EDGE_DEFAULT) << (4U * 1U)) | \
  130. ((ADC_REG_TRIG_EXT_EDGE_DEFAULT) << (4U * 2U)) | \
  131. ((ADC_REG_TRIG_EXT_EDGE_DEFAULT) << (4U * 3U)) )
  132. /* Definition of ADC group regular trigger bits information. */
  133. #define ADC_REG_TRIG_EXTSEL_BITOFFSET_POS ((uint32_t) 6U) /* Value equivalent to POSITION_VAL(ADC_CFGR_EXTSEL) */
  134. #define ADC_REG_TRIG_EXTEN_BITOFFSET_POS ((uint32_t)10U) /* Value equivalent to POSITION_VAL(ADC_CFGR_EXTEN) */
  135. /* Internal definitions for ADC group regular trigger sources: */
  136. /* To differentiate into literal LL_ADC_REG_TRIG_x the trigger sources */
  137. /* depending on ADC instances ADC1, ADC2, ADC3, ADC4 (if ADC instance is */
  138. /* available on the selected device). */
  139. #if defined(STM32F303xC) || defined(STM32F358xx) || defined(STM32F303xE) || defined(STM32F398xx)
  140. /* Internal mask offset for ADC group injected trigger sources */
  141. /* available only on specific ADC instances. */
  142. /* (offset placed into a spare area of literal definition) */
  143. #define ADC_REG_TRIG_EXT_INST_ADC12 ((uint32_t)0x00000001U) /* Marker for differentiation of ADC group regular external trigger available only on ADC instance: ADC1, ADC2 */
  144. #define ADC_REG_TRIG_EXT_INST_ADC34 ((uint32_t)0x00000002U) /* Marker for differentiation of ADC group regular external trigger available only on ADC instance: ADC3, ADC4 */
  145. #endif
  146. /* Internal mask for ADC group injected trigger: */
  147. /* To select into literal LL_ADC_INJ_TRIG_x the relevant bits for: */
  148. /* - injected trigger source */
  149. /* - injected trigger edge */
  150. #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) */
  151. /* Mask containing trigger source masks for each of possible */
  152. /* trigger edge selection duplicated with shifts [0; 4; 8; 12] */
  153. /* corresponding to {SW start; ext trigger; ext trigger; ext trigger}. */
  154. #define ADC_INJ_TRIG_SOURCE_MASK (((LL_ADC_INJ_TRIG_SOFTWARE & ADC_JSQR_JEXTSEL) << (4U * 0U)) | \
  155. ((ADC_JSQR_JEXTSEL) << (4U * 1U)) | \
  156. ((ADC_JSQR_JEXTSEL) << (4U * 2U)) | \
  157. ((ADC_JSQR_JEXTSEL) << (4U * 3U)) )
  158. /* Mask containing trigger edge masks for each of possible */
  159. /* trigger edge selection duplicated with shifts [0; 4; 8; 12] */
  160. /* corresponding to {SW start; ext trigger; ext trigger; ext trigger}. */
  161. #define ADC_INJ_TRIG_EDGE_MASK (((LL_ADC_INJ_TRIG_SOFTWARE & ADC_JSQR_JEXTEN) << (4U * 0U)) | \
  162. ((ADC_INJ_TRIG_EXT_EDGE_DEFAULT) << (4U * 1U)) | \
  163. ((ADC_INJ_TRIG_EXT_EDGE_DEFAULT) << (4U * 2U)) | \
  164. ((ADC_INJ_TRIG_EXT_EDGE_DEFAULT) << (4U * 3U)) )
  165. /* Definition of ADC group injected trigger bits information. */
  166. #define ADC_INJ_TRIG_EXTSEL_BITOFFSET_POS ((uint32_t) 2U) /* Value equivalent to POSITION_VAL(ADC_JSQR_JEXTSEL) */
  167. #define ADC_INJ_TRIG_EXTEN_BITOFFSET_POS ((uint32_t) 6U) /* Value equivalent to POSITION_VAL(ADC_JSQR_JEXTEN) */
  168. /* Internal definitions for ADC group injected trigger sources: */
  169. /* To differentiate into literal LL_ADC_INJ_TRIG_x the trigger sources */
  170. /* depending on ADC instances ADC1, ADC2, ADC3, ADC4 (if ADC instance is */
  171. /* available on the selected device). */
  172. #if defined(STM32F303xC) || defined(STM32F358xx) || defined(STM32F303xE) || defined(STM32F398xx)
  173. /* Internal mask offset for ADC group injected trigger sources */
  174. /* available only on specific ADC instances. */
  175. /* (offset placed into a spare area of literal definition) */
  176. #define ADC_INJ_TRIG_EXT_INST_ADC12 ((uint32_t)0x00000001U) /* Marker for differentiation of ADC group injected external trigger available only on ADC instance: ADC1, ADC2 */
  177. #define ADC_INJ_TRIG_EXT_INST_ADC34 ((uint32_t)0x00000002U) /* Marker for differentiation of ADC group injected external trigger available only on ADC instance: ADC3, ADC4 */
  178. #endif
  179. /* Internal mask for ADC channel: */
  180. /* To select into literal LL_ADC_CHANNEL_x the relevant bits for: */
  181. /* - channel identifier defined by number */
  182. /* - channel identifier defined by bitfield */
  183. /* - channel differentiation between external channels (connected to */
  184. /* GPIO pins) and internal channels (connected to internal paths) */
  185. /* - channel sampling time defined by SMPRx register offset */
  186. /* and SMPx bits positions into SMPRx register */
  187. #define ADC_CHANNEL_ID_NUMBER_MASK (ADC_CFGR_AWD1CH)
  188. #define ADC_CHANNEL_ID_BITFIELD_MASK (ADC_AWD2CR_AWD2CH)
  189. #define ADC_CHANNEL_ID_NUMBER_BITOFFSET_POS ((uint32_t)26U)/* Value equivalent to POSITION_VAL(ADC_CHANNEL_ID_NUMBER_MASK) */
  190. #define ADC_CHANNEL_ID_MASK (ADC_CHANNEL_ID_NUMBER_MASK | ADC_CHANNEL_ID_BITFIELD_MASK | ADC_CHANNEL_ID_INTERNAL_CH_MASK)
  191. /* Equivalent mask of ADC_CHANNEL_NUMBER_MASK aligned on register LSB (bit 0) */
  192. #define ADC_CHANNEL_ID_NUMBER_MASK_POSBIT0 (ADC_SQR2_SQ5) /* Equivalent to shift: (ADC_CHANNEL_NUMBER_MASK >> POSITION_VAL(ADC_CHANNEL_NUMBER_MASK)) */
  193. /* Channel differentiation between external and internal channels */
  194. #define ADC_CHANNEL_ID_INTERNAL_CH ((uint32_t)0x80000000U) /* Marker of internal channel */
  195. #define ADC_CHANNEL_ID_INTERNAL_CH_2 ((uint32_t)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 */
  196. #define ADC_CHANNEL_ID_INTERNAL_CH_MASK (ADC_CHANNEL_ID_INTERNAL_CH | ADC_CHANNEL_ID_INTERNAL_CH_2)
  197. /* Internal register offset for ADC channel sampling time configuration */
  198. /* (offset placed into a spare area of literal definition) */
  199. #define ADC_SMPR1_REGOFFSET ((uint32_t)0x00000000U)
  200. #define ADC_SMPR2_REGOFFSET ((uint32_t)0x02000000U)
  201. #define ADC_CHANNEL_SMPRX_REGOFFSET_MASK (ADC_SMPR1_REGOFFSET | ADC_SMPR2_REGOFFSET)
  202. #define ADC_CHANNEL_SMPx_BITOFFSET_MASK ((uint32_t)0x01F00000U)
  203. #define ADC_CHANNEL_SMPx_BITOFFSET_POS ((uint32_t)20U) /* Value equivalent to POSITION_VAL(ADC_CHANNEL_SMPx_BITOFFSET_MASK) */
  204. /* Definition of channels ID number information to be inserted into */
  205. /* channels literals definition. */
  206. #define ADC_CHANNEL_0_NUMBER ((uint32_t)0x00000000U)
  207. #define ADC_CHANNEL_1_NUMBER ( ADC_CFGR_AWD1CH_0)
  208. #define ADC_CHANNEL_2_NUMBER ( ADC_CFGR_AWD1CH_1 )
  209. #define ADC_CHANNEL_3_NUMBER ( ADC_CFGR_AWD1CH_1 | ADC_CFGR_AWD1CH_0)
  210. #define ADC_CHANNEL_4_NUMBER ( ADC_CFGR_AWD1CH_2 )
  211. #define ADC_CHANNEL_5_NUMBER ( ADC_CFGR_AWD1CH_2 | ADC_CFGR_AWD1CH_0)
  212. #define ADC_CHANNEL_6_NUMBER ( ADC_CFGR_AWD1CH_2 | ADC_CFGR_AWD1CH_1 )
  213. #define ADC_CHANNEL_7_NUMBER ( ADC_CFGR_AWD1CH_2 | ADC_CFGR_AWD1CH_1 | ADC_CFGR_AWD1CH_0)
  214. #define ADC_CHANNEL_8_NUMBER ( ADC_CFGR_AWD1CH_3 )
  215. #define ADC_CHANNEL_9_NUMBER ( ADC_CFGR_AWD1CH_3 | ADC_CFGR_AWD1CH_0)
  216. #define ADC_CHANNEL_10_NUMBER ( ADC_CFGR_AWD1CH_3 | ADC_CFGR_AWD1CH_1 )
  217. #define ADC_CHANNEL_11_NUMBER ( ADC_CFGR_AWD1CH_3 | ADC_CFGR_AWD1CH_1 | ADC_CFGR_AWD1CH_0)
  218. #define ADC_CHANNEL_12_NUMBER ( ADC_CFGR_AWD1CH_3 | ADC_CFGR_AWD1CH_2 )
  219. #define ADC_CHANNEL_13_NUMBER ( ADC_CFGR_AWD1CH_3 | ADC_CFGR_AWD1CH_2 | ADC_CFGR_AWD1CH_0)
  220. #define ADC_CHANNEL_14_NUMBER ( ADC_CFGR_AWD1CH_3 | ADC_CFGR_AWD1CH_2 | ADC_CFGR_AWD1CH_1 )
  221. #define ADC_CHANNEL_15_NUMBER ( ADC_CFGR_AWD1CH_3 | ADC_CFGR_AWD1CH_2 | ADC_CFGR_AWD1CH_1 | ADC_CFGR_AWD1CH_0)
  222. #define ADC_CHANNEL_16_NUMBER (ADC_CFGR_AWD1CH_4 )
  223. #define ADC_CHANNEL_17_NUMBER (ADC_CFGR_AWD1CH_4 | ADC_CFGR_AWD1CH_0)
  224. #define ADC_CHANNEL_18_NUMBER (ADC_CFGR_AWD1CH_4 | ADC_CFGR_AWD1CH_1 )
  225. /* Definition of channels ID bitfield information to be inserted into */
  226. /* channels literals definition. */
  227. #define ADC_CHANNEL_0_BITFIELD (ADC_AWD2CR_AWD2CH_0)
  228. #define ADC_CHANNEL_1_BITFIELD (ADC_AWD2CR_AWD2CH_1)
  229. #define ADC_CHANNEL_2_BITFIELD (ADC_AWD2CR_AWD2CH_2)
  230. #define ADC_CHANNEL_3_BITFIELD (ADC_AWD2CR_AWD2CH_3)
  231. #define ADC_CHANNEL_4_BITFIELD (ADC_AWD2CR_AWD2CH_4)
  232. #define ADC_CHANNEL_5_BITFIELD (ADC_AWD2CR_AWD2CH_5)
  233. #define ADC_CHANNEL_6_BITFIELD (ADC_AWD2CR_AWD2CH_6)
  234. #define ADC_CHANNEL_7_BITFIELD (ADC_AWD2CR_AWD2CH_7)
  235. #define ADC_CHANNEL_8_BITFIELD (ADC_AWD2CR_AWD2CH_8)
  236. #define ADC_CHANNEL_9_BITFIELD (ADC_AWD2CR_AWD2CH_9)
  237. #define ADC_CHANNEL_10_BITFIELD (ADC_AWD2CR_AWD2CH_10)
  238. #define ADC_CHANNEL_11_BITFIELD (ADC_AWD2CR_AWD2CH_11)
  239. #define ADC_CHANNEL_12_BITFIELD (ADC_AWD2CR_AWD2CH_12)
  240. #define ADC_CHANNEL_13_BITFIELD (ADC_AWD2CR_AWD2CH_13)
  241. #define ADC_CHANNEL_14_BITFIELD (ADC_AWD2CR_AWD2CH_14)
  242. #define ADC_CHANNEL_15_BITFIELD (ADC_AWD2CR_AWD2CH_15)
  243. #define ADC_CHANNEL_16_BITFIELD (ADC_AWD2CR_AWD2CH_16)
  244. #define ADC_CHANNEL_17_BITFIELD (ADC_AWD2CR_AWD2CH_17)
  245. #define ADC_CHANNEL_18_BITFIELD (ADC_AWD2CR_AWD2CH_18)
  246. /* Definition of channels sampling time information to be inserted into */
  247. /* channels literals definition. */
  248. #define ADC_CHANNEL_0_SMP (ADC_SMPR1_REGOFFSET | (((uint32_t) 0U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR1_SMP0) */
  249. #define ADC_CHANNEL_1_SMP (ADC_SMPR1_REGOFFSET | (((uint32_t) 3U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR1_SMP1) */
  250. #define ADC_CHANNEL_2_SMP (ADC_SMPR1_REGOFFSET | (((uint32_t) 6U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR1_SMP2) */
  251. #define ADC_CHANNEL_3_SMP (ADC_SMPR1_REGOFFSET | (((uint32_t) 9U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR1_SMP3) */
  252. #define ADC_CHANNEL_4_SMP (ADC_SMPR1_REGOFFSET | (((uint32_t)12U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR1_SMP4) */
  253. #define ADC_CHANNEL_5_SMP (ADC_SMPR1_REGOFFSET | (((uint32_t)15U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR1_SMP5) */
  254. #define ADC_CHANNEL_6_SMP (ADC_SMPR1_REGOFFSET | (((uint32_t)18U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR1_SMP6) */
  255. #define ADC_CHANNEL_7_SMP (ADC_SMPR1_REGOFFSET | (((uint32_t)21U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR1_SMP7) */
  256. #define ADC_CHANNEL_8_SMP (ADC_SMPR1_REGOFFSET | (((uint32_t)24U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR1_SMP8) */
  257. #define ADC_CHANNEL_9_SMP (ADC_SMPR1_REGOFFSET | (((uint32_t)27U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR1_SMP9) */
  258. #define ADC_CHANNEL_10_SMP (ADC_SMPR2_REGOFFSET | (((uint32_t) 0U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR2_SMP10) */
  259. #define ADC_CHANNEL_11_SMP (ADC_SMPR2_REGOFFSET | (((uint32_t) 3U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR2_SMP11) */
  260. #define ADC_CHANNEL_12_SMP (ADC_SMPR2_REGOFFSET | (((uint32_t) 6U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR2_SMP12) */
  261. #define ADC_CHANNEL_13_SMP (ADC_SMPR2_REGOFFSET | (((uint32_t) 9U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR2_SMP13) */
  262. #define ADC_CHANNEL_14_SMP (ADC_SMPR2_REGOFFSET | (((uint32_t)12U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR2_SMP14) */
  263. #define ADC_CHANNEL_15_SMP (ADC_SMPR2_REGOFFSET | (((uint32_t)15U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR2_SMP15) */
  264. #define ADC_CHANNEL_16_SMP (ADC_SMPR2_REGOFFSET | (((uint32_t)18U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR2_SMP16) */
  265. #define ADC_CHANNEL_17_SMP (ADC_SMPR2_REGOFFSET | (((uint32_t)21U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR2_SMP17) */
  266. #define ADC_CHANNEL_18_SMP (ADC_SMPR2_REGOFFSET | (((uint32_t)24U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR2_SMP18) */
  267. /* Internal mask for ADC mode single or differential ended: */
  268. /* To select into literals LL_ADC_SINGLE_ENDED or LL_ADC_SINGLE_DIFFERENTIAL */
  269. /* the relevant bits for: */
  270. /* (concatenation of multiple bits used in different registers) */
  271. /* - ADC calibration: calibration start, calibration factor get or set */
  272. /* - ADC channels: set each ADC channel ending mode */
  273. #define ADC_SINGLEDIFF_CALIB_START_MASK (ADC_CR_ADCALDIF)
  274. #define ADC_SINGLEDIFF_CALIB_FACTOR_MASK (ADC_CALFACT_CALFACT_D | ADC_CALFACT_CALFACT_S)
  275. #define ADC_SINGLEDIFF_CHANNEL_MASK (ADC_CHANNEL_ID_BITFIELD_MASK) /* Equivalent to ADC_DIFSEL_DIFSEL */
  276. #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. */
  277. /* Internal mask for ADC analog watchdog: */
  278. /* To select into literals LL_ADC_AWD_CHANNELx_xxx the relevant bits for: */
  279. /* (concatenation of multiple bits used in different analog watchdogs, */
  280. /* (feature of several watchdogs not available on all STM32 families)). */
  281. /* - analog watchdog 1: monitored channel defined by number, */
  282. /* selection of ADC group (ADC groups regular and-or injected). */
  283. /* - analog watchdog 2 and 3: monitored channel defined by bitfield, no */
  284. /* selection on groups. */
  285. /* Internal register offset for ADC analog watchdog channel configuration */
  286. #define ADC_AWD_CR1_REGOFFSET ((uint32_t)0x00000000U)
  287. #define ADC_AWD_CR2_REGOFFSET ((uint32_t)0x00100000U)
  288. #define ADC_AWD_CR3_REGOFFSET ((uint32_t)0x00200000U)
  289. /* Register offset gap between AWD1 and AWD2-AWD3 configuration registers */
  290. /* (Set separately as ADC_AWD_CRX_REGOFFSET to spare 32 bits space */
  291. #define ADC_AWD_CR12_REGOFFSETGAP_MASK (ADC_AWD2CR_AWD2CH_0)
  292. #define ADC_AWD_CR12_REGOFFSETGAP_VAL ((uint32_t)0x00000024U)
  293. #define ADC_AWD_CRX_REGOFFSET_MASK (ADC_AWD_CR1_REGOFFSET | ADC_AWD_CR2_REGOFFSET | ADC_AWD_CR3_REGOFFSET)
  294. #define ADC_AWD_CR1_CHANNEL_MASK (ADC_CFGR_AWD1CH | ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1EN | ADC_CFGR_AWD1SGL)
  295. #define ADC_AWD_CR23_CHANNEL_MASK (ADC_AWD2CR_AWD2CH)
  296. #define ADC_AWD_CR_ALL_CHANNEL_MASK (ADC_AWD_CR1_CHANNEL_MASK | ADC_AWD_CR23_CHANNEL_MASK)
  297. /* Internal register offset for ADC analog watchdog threshold configuration */
  298. #define ADC_AWD_TR1_REGOFFSET (ADC_AWD_CR1_REGOFFSET)
  299. #define ADC_AWD_TR2_REGOFFSET (ADC_AWD_CR2_REGOFFSET)
  300. #define ADC_AWD_TR3_REGOFFSET (ADC_AWD_CR3_REGOFFSET)
  301. #define ADC_AWD_TRX_REGOFFSET_MASK (ADC_AWD_TR1_REGOFFSET | ADC_AWD_TR2_REGOFFSET | ADC_AWD_TR3_REGOFFSET)
  302. /* Internal mask for ADC offset: */
  303. /* Internal register offset for ADC offset number configuration */
  304. #define ADC_OFR1_REGOFFSET ((uint32_t)0x00000000U)
  305. #define ADC_OFR2_REGOFFSET ((uint32_t)0x00000001U)
  306. #define ADC_OFR3_REGOFFSET ((uint32_t)0x00000002U)
  307. #define ADC_OFR4_REGOFFSET ((uint32_t)0x00000003U)
  308. #define ADC_OFRx_REGOFFSET_MASK (ADC_OFR1_REGOFFSET | ADC_OFR2_REGOFFSET | ADC_OFR3_REGOFFSET | ADC_OFR4_REGOFFSET)
  309. /* ADC registers bits positions */
  310. #define ADC_CFGR_RES_BITOFFSET_POS ((uint32_t) 3U) /* Value equivalent to POSITION_VAL(ADC_CFGR_RES) */
  311. #define ADC_CFGR_AWD1SGL_BITOFFSET_POS ((uint32_t)22U) /* Value equivalent to POSITION_VAL(ADC_CFGR_AWD1SGL) */
  312. #define ADC_CFGR_AWD1EN_BITOFFSET_POS ((uint32_t)23U) /* Value equivalent to POSITION_VAL(ADC_CFGR_AWD1EN) */
  313. #define ADC_CFGR_JAWD1EN_BITOFFSET_POS ((uint32_t)24U) /* Value equivalent to POSITION_VAL(ADC_CFGR_JAWD1EN) */
  314. #define ADC_TR1_HT1_BITOFFSET_POS ((uint32_t)16U) /* Value equivalent to POSITION_VAL(ADC_TR1_HT1) */
  315. /* ADC registers bits groups */
  316. #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. */
  317. /* ADC internal channels related definitions */
  318. /* Internal voltage reference VrefInt */
  319. #define VREFINT_CAL_ADDR ((uint16_t*) ((uint32_t)0x1FFFF7BAU)) /* Internal voltage reference, address of parameter VREFINT_CAL: VrefInt ADC raw data acquired at temperature 30 DegC (tolerance: +-5 DegC), Vref+ = 3.3 V (tolerance: +-10 mV). */
  320. #define VREFINT_CAL_VREF ((uint32_t) 3300U) /* Analog voltage reference (Vref+) value with which temperature sensor has been calibrated in production (tolerance: +-10 mV) (unit: mV). */
  321. /* Temperature sensor */
  322. #define TEMPSENSOR_CAL1_ADDR ((uint16_t*) ((uint32_t)0x1FFFF7B8U)) /* Internal temperature sensor, address of parameter TS_CAL1: On STM32F3, temperature sensor ADC raw data acquired at temperature 25 DegC (tolerance: +-5 DegC), Vref+ = 3.3 V (tolerance: +-10 mV). */
  323. #define TEMPSENSOR_CAL2_ADDR ((uint16_t*) ((uint32_t)0x1FFFF7C2U)) /* Internal temperature sensor, address of parameter TS_CAL2: On STM32F3, temperature sensor ADC raw data acquired at temperature 110 DegC (tolerance: +-5 DegC), Vref+ = 3.3 V (tolerance: +-10 mV). */
  324. #define TEMPSENSOR_CAL1_TEMP (( int32_t) 25) /* Internal temperature sensor, temperature at which temperature sensor has been calibrated in production for data into TEMPSENSOR_CAL1_ADDR (tolerance: +-5 DegC) (unit: DegC). */
  325. #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). */
  326. #define TEMPSENSOR_CAL_VREFANALOG ((uint32_t) 3300U) /* Analog voltage reference (Vref+) voltage with which temperature sensor has been calibrated in production (+-10 mV) (unit: mV). */
  327. /**
  328. * @}
  329. */
  330. /* Private macros ------------------------------------------------------------*/
  331. /** @defgroup ADC_LL_Private_Macros ADC Private Macros
  332. * @{
  333. */
  334. /**
  335. * @brief Driver macro reserved for internal use: isolate bits with the
  336. * selected mask and shift them to the register LSB
  337. * (shift mask on register position bit 0).
  338. * @param __BITS__ Bits in register 32 bits
  339. * @param __MASK__ Mask in register 32 bits
  340. * @retval Bits in register 32 bits
  341. */
  342. #define __ADC_MASK_SHIFT(__BITS__, __MASK__) \
  343. (((__BITS__) & (__MASK__)) >> POSITION_VAL((__MASK__)))
  344. /**
  345. * @brief Driver macro reserved for internal use: set a pointer to
  346. * a register from a register basis from which an offset
  347. * is applied.
  348. * @param __REG__ Register basis from which the offset is applied.
  349. * @param __REG_OFFFSET__ Offset to be applied (unit: number of registers).
  350. * @retval Pointer to register address
  351. */
  352. #define __ADC_PTR_REG_OFFSET(__REG__, __REG_OFFFSET__) \
  353. ((uint32_t *)((uint32_t) ((uint32_t)(&(__REG__)) + ((__REG_OFFFSET__) << 2U))))
  354. /**
  355. * @}
  356. */
  357. /* Exported types ------------------------------------------------------------*/
  358. #if defined(USE_FULL_LL_DRIVER)
  359. /** @defgroup ADC_LL_ES_INIT ADC Exported Init structure
  360. * @{
  361. */
  362. /**
  363. * @brief Structure definition of some features of ADC common parameters
  364. * and multimode
  365. * (all ADC instances belonging to the same ADC common instance).
  366. * @note The setting of these parameters by function @ref LL_ADC_CommonInit()
  367. * is conditioned to ADC instances state (all ADC instances
  368. * sharing the same ADC common instance):
  369. * All ADC instances sharing the same ADC common instance must be
  370. * disabled.
  371. */
  372. typedef struct
  373. {
  374. uint32_t CommonClock; /*!< Set parameter common to several ADC: Clock source and prescaler.
  375. This parameter can be a value of @ref ADC_LL_EC_COMMON_CLOCK_SOURCE
  376. @note On this STM32 serie, if ADC group injected is used, some
  377. clock ratio constraints between ADC clock and AHB clock
  378. must be respected. Refer to reference manual.
  379. This feature can be modified afterwards using unitary function @ref LL_ADC_SetCommonClock(). */
  380. #if defined(ADC_MULTIMODE_SUPPORT)
  381. uint32_t Multimode; /*!< Set ADC multimode configuration to operate in independent mode or multimode (for devices with several ADC instances).
  382. This parameter can be a value of @ref ADC_LL_EC_MULTI_MODE
  383. This feature can be modified afterwards using unitary function @ref LL_ADC_SetMultimode(). */
  384. uint32_t MultiDMATransfer; /*!< Set ADC multimode conversion data transfer: no transfer or transfer by DMA.
  385. This parameter can be a value of @ref ADC_LL_EC_MULTI_DMA_TRANSFER
  386. This feature can be modified afterwards using unitary function @ref LL_ADC_SetMultiDMATransfer(). */
  387. uint32_t MultiTwoSamplingDelay; /*!< Set ADC multimode delay between 2 sampling phases.
  388. This parameter can be a value of @ref ADC_LL_EC_MULTI_TWOSMP_DELAY
  389. This feature can be modified afterwards using unitary function @ref LL_ADC_SetMultiTwoSamplingDelay(). */
  390. #endif /* ADC_MULTIMODE_SUPPORT */
  391. } LL_ADC_CommonInitTypeDef;
  392. /**
  393. * @brief Structure definition of some features of ADC instance.
  394. * @note These parameters have an impact on ADC scope: ADC instance.
  395. * Affects both group regular and group injected (availability
  396. * of ADC group injected depends on STM32 families).
  397. * Refer to corresponding unitary functions into
  398. * @ref ADC_LL_EF_Configuration_ADC_Instance .
  399. * @note The setting of these parameters by function @ref LL_ADC_Init()
  400. * is conditioned to ADC state:
  401. * ADC instance must be disabled.
  402. * This condition is applied to all ADC features, for efficiency
  403. * and compatibility over all STM32 families. However, the different
  404. * features can be set under different ADC state conditions
  405. * (setting possible with ADC enabled without conversion on going,
  406. * ADC enabled with conversion on going, ...)
  407. * Each feature can be updated afterwards with a unitary function
  408. * and potentially with ADC in a different state than disabled,
  409. * refer to description of each function for setting
  410. * conditioned to ADC state.
  411. */
  412. typedef struct
  413. {
  414. uint32_t Resolution; /*!< Set ADC resolution.
  415. This parameter can be a value of @ref ADC_LL_EC_RESOLUTION
  416. This feature can be modified afterwards using unitary function @ref LL_ADC_SetResolution(). */
  417. uint32_t DataAlignment; /*!< Set ADC conversion data alignment.
  418. This parameter can be a value of @ref ADC_LL_EC_DATA_ALIGN
  419. This feature can be modified afterwards using unitary function @ref LL_ADC_SetDataAlignment(). */
  420. uint32_t LowPowerMode; /*!< Set ADC low power mode.
  421. This parameter can be a value of @ref ADC_LL_EC_LP_MODE
  422. This feature can be modified afterwards using unitary function @ref LL_ADC_SetLowPowerMode(). */
  423. } LL_ADC_InitTypeDef;
  424. /**
  425. * @brief Structure definition of some features of ADC group regular.
  426. * @note These parameters have an impact on ADC scope: ADC group regular.
  427. * Refer to corresponding unitary functions into
  428. * @ref ADC_LL_EF_Configuration_ADC_Group_Regular
  429. * (functions with prefix "REG").
  430. * @note The setting of these parameters by function @ref LL_ADC_REG_Init()
  431. * is conditioned to ADC state:
  432. * ADC instance must be disabled.
  433. * This condition is applied to all ADC features, for efficiency
  434. * and compatibility over all STM32 families. However, the different
  435. * features can be set under different ADC state conditions
  436. * (setting possible with ADC enabled without conversion on going,
  437. * ADC enabled with conversion on going, ...)
  438. * Each feature can be updated afterwards with a unitary function
  439. * and potentially with ADC in a different state than disabled,
  440. * refer to description of each function for setting
  441. * conditioned to ADC state.
  442. */
  443. typedef struct
  444. {
  445. uint32_t TriggerSource; /*!< Set ADC group regular conversion trigger source: internal (SW start) or from external IP (timer event, external interrupt line).
  446. This parameter can be a value of @ref ADC_LL_EC_REG_TRIGGER_SOURCE
  447. @note On this STM32 serie, setting trigger source to external trigger also set trigger polarity to rising edge
  448. (default setting for compatibility with some ADC on other STM32 families having this setting set by HW default value).
  449. In case of need to modify trigger edge, use function @ref LL_ADC_REG_SetTriggerEdge().
  450. This feature can be modified afterwards using unitary function @ref LL_ADC_REG_SetTriggerSource(). */
  451. uint32_t SequencerLength; /*!< Set ADC group regular sequencer length.
  452. This parameter can be a value of @ref ADC_LL_EC_REG_SEQ_SCAN_LENGTH
  453. This feature can be modified afterwards using unitary function @ref LL_ADC_REG_SetSequencerLength(). */
  454. uint32_t SequencerDiscont; /*!< Set ADC group regular sequencer discontinuous mode: sequence subdivided and scan conversions interrupted every selected number of ranks.
  455. This parameter can be a value of @ref ADC_LL_EC_REG_SEQ_DISCONT_MODE
  456. @note This parameter has an effect only if group regular sequencer is enabled
  457. (scan length of 2 ranks or more).
  458. This feature can be modified afterwards using unitary function @ref LL_ADC_REG_SetSequencerDiscont(). */
  459. 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).
  460. This parameter can be a value of @ref ADC_LL_EC_REG_CONTINUOUS_MODE
  461. Note: It is not possible to enable both ADC group regular continuous mode and discontinuous mode.
  462. This feature can be modified afterwards using unitary function @ref LL_ADC_REG_SetContinuousMode(). */
  463. uint32_t DMATransfer; /*!< Set ADC group regular conversion data transfer: no transfer or transfer by DMA, and DMA requests mode.
  464. This parameter can be a value of @ref ADC_LL_EC_REG_DMA_TRANSFER
  465. This feature can be modified afterwards using unitary function @ref LL_ADC_REG_SetDMATransfer(). */
  466. uint32_t Overrun; /*!< Set ADC group regular behavior in case of overrun:
  467. data preserved or overwritten.
  468. This parameter can be a value of @ref ADC_LL_EC_REG_OVR_DATA_BEHAVIOR
  469. This feature can be modified afterwards using unitary function @ref LL_ADC_REG_SetOverrun(). */
  470. } LL_ADC_REG_InitTypeDef;
  471. /**
  472. * @brief Structure definition of some features of ADC group injected.
  473. * @note These parameters have an impact on ADC scope: ADC group injected.
  474. * Refer to corresponding unitary functions into
  475. * @ref ADC_LL_EF_Configuration_ADC_Group_Regular
  476. * (functions with prefix "INJ").
  477. * @note The setting of these parameters by function @ref LL_ADC_INJ_Init()
  478. * is conditioned to ADC state:
  479. * ADC instance must be disabled.
  480. * This condition is applied to all ADC features, for efficiency
  481. * and compatibility over all STM32 families. However, the different
  482. * features can be set under different ADC state conditions
  483. * (setting possible with ADC enabled without conversion on going,
  484. * ADC enabled with conversion on going, ...)
  485. * Each feature can be updated afterwards with a unitary function
  486. * and potentially with ADC in a different state than disabled,
  487. * refer to description of each function for setting
  488. * conditioned to ADC state.
  489. */
  490. typedef struct
  491. {
  492. uint32_t TriggerSource; /*!< Set ADC group injected conversion trigger source: internal (SW start) or from external IP (timer event, external interrupt line).
  493. This parameter can be a value of @ref ADC_LL_EC_INJ_TRIGGER_SOURCE
  494. @note On this STM32 serie, setting trigger source to external trigger also set trigger polarity to rising edge
  495. (default setting for compatibility with some ADC on other STM32 families having this setting set by HW default value).
  496. In case of need to modify trigger edge, use function @ref LL_ADC_INJ_SetTriggerEdge().
  497. This feature can be modified afterwards using unitary function @ref LL_ADC_INJ_SetTriggerSource(). */
  498. uint32_t SequencerLength; /*!< Set ADC group injected sequencer length.
  499. This parameter can be a value of @ref ADC_LL_EC_INJ_SEQ_SCAN_LENGTH
  500. This feature can be modified afterwards using unitary function @ref LL_ADC_INJ_SetSequencerLength(). */
  501. uint32_t SequencerDiscont; /*!< Set ADC group injected sequencer discontinuous mode: sequence subdivided and scan conversions interrupted every selected number of ranks.
  502. This parameter can be a value of @ref ADC_LL_EC_INJ_SEQ_DISCONT_MODE
  503. @note This parameter has an effect only if group injected sequencer is enabled
  504. (scan length of 2 ranks or more).
  505. This feature can be modified afterwards using unitary function @ref LL_ADC_INJ_SetSequencerDiscont(). */
  506. uint32_t TrigAuto; /*!< Set ADC group injected conversion trigger: independent or from ADC group regular.
  507. This parameter can be a value of @ref ADC_LL_EC_INJ_TRIG_AUTO
  508. Note: This parameter must be set to set to independent trigger if injected trigger source is set to an external trigger.
  509. This feature can be modified afterwards using unitary function @ref LL_ADC_INJ_SetTrigAuto(). */
  510. } LL_ADC_INJ_InitTypeDef;
  511. /**
  512. * @}
  513. */
  514. #endif /* USE_FULL_LL_DRIVER */
  515. /* Exported constants --------------------------------------------------------*/
  516. /** @defgroup ADC_LL_Exported_Constants ADC Exported Constants
  517. * @{
  518. */
  519. /** @defgroup ADC_LL_EC_FLAG ADC flags
  520. * @brief Flags defines which can be used with LL_ADC_ReadReg function
  521. * @{
  522. */
  523. #define LL_ADC_FLAG_ADRDY ADC_ISR_ADRDY /*!< ADC flag ADC instance ready */
  524. #define LL_ADC_FLAG_EOC ADC_ISR_EOC /*!< ADC flag ADC group regular end of unitary conversion */
  525. #define LL_ADC_FLAG_EOS ADC_ISR_EOS /*!< ADC flag ADC group regular end of sequence conversions */
  526. #define LL_ADC_FLAG_OVR ADC_ISR_OVR /*!< ADC flag ADC group regular overrun */
  527. #define LL_ADC_FLAG_EOSMP ADC_ISR_EOSMP /*!< ADC flag ADC group regular end of sampling phase */
  528. #define LL_ADC_FLAG_JEOC ADC_ISR_JEOC /*!< ADC flag ADC group injected end of unitary conversion */
  529. #define LL_ADC_FLAG_JEOS ADC_ISR_JEOS /*!< ADC flag ADC group injected end of sequence conversions */
  530. #define LL_ADC_FLAG_JQOVF ADC_ISR_JQOVF /*!< ADC flag ADC group injected contexts queue overflow */
  531. #define LL_ADC_FLAG_AWD1 ADC_ISR_AWD1 /*!< ADC flag ADC analog watchdog 1 */
  532. #define LL_ADC_FLAG_AWD2 ADC_ISR_AWD2 /*!< ADC flag ADC analog watchdog 2 */
  533. #define LL_ADC_FLAG_AWD3 ADC_ISR_AWD3 /*!< ADC flag ADC analog watchdog 3 */
  534. #if defined(ADC_MULTIMODE_SUPPORT)
  535. #define LL_ADC_FLAG_ADRDY_MST ADC_CSR_ADRDY_MST /*!< ADC flag ADC multimode master instance ready */
  536. #define LL_ADC_FLAG_ADRDY_SLV ADC_CSR_ADRDY_SLV /*!< ADC flag ADC multimode slave instance ready */
  537. #define LL_ADC_FLAG_EOC_MST ADC_CSR_EOC_MST /*!< ADC flag ADC multimode master group regular end of unitary conversion */
  538. #define LL_ADC_FLAG_EOC_SLV ADC_CSR_EOC_SLV /*!< ADC flag ADC multimode slave group regular end of unitary conversion */
  539. #define LL_ADC_FLAG_EOS_MST ADC_CSR_EOS_MST /*!< ADC flag ADC multimode master group regular end of sequence conversions */
  540. #define LL_ADC_FLAG_EOS_SLV ADC_CSR_EOS_SLV /*!< ADC flag ADC multimode slave group regular end of sequence conversions */
  541. #define LL_ADC_FLAG_OVR_MST ADC_CSR_OVR_MST /*!< ADC flag ADC multimode master group regular overrun */
  542. #define LL_ADC_FLAG_OVR_SLV ADC_CSR_OVR_SLV /*!< ADC flag ADC multimode slave group regular overrun */
  543. #define LL_ADC_FLAG_EOSMP_MST ADC_CSR_EOSMP_MST /*!< ADC flag ADC multimode master group regular end of sampling phase */
  544. #define LL_ADC_FLAG_EOSMP_SLV ADC_CSR_EOSMP_SLV /*!< ADC flag ADC multimode slave group regular end of sampling phase */
  545. #define LL_ADC_FLAG_JEOC_MST ADC_CSR_JEOC_MST /*!< ADC flag ADC multimode master group injected end of unitary conversion */
  546. #define LL_ADC_FLAG_JEOC_SLV ADC_CSR_JEOC_SLV /*!< ADC flag ADC multimode slave group injected end of unitary conversion */
  547. #define LL_ADC_FLAG_JEOS_MST ADC_CSR_JEOS_MST /*!< ADC flag ADC multimode master group injected end of sequence conversions */
  548. #define LL_ADC_FLAG_JEOS_SLV ADC_CSR_JEOS_SLV /*!< ADC flag ADC multimode slave group injected end of sequence conversions */
  549. #define LL_ADC_FLAG_JQOVF_MST ADC_CSR_JQOVF_MST /*!< ADC flag ADC multimode master group injected contexts queue overflow */
  550. #define LL_ADC_FLAG_JQOVF_SLV ADC_CSR_JQOVF_SLV /*!< ADC flag ADC multimode slave group injected contexts queue overflow */
  551. #define LL_ADC_FLAG_AWD1_MST ADC_CSR_AWD1_MST /*!< ADC flag ADC multimode master analog watchdog 1 of the ADC master */
  552. #define LL_ADC_FLAG_AWD1_SLV ADC_CSR_AWD1_SLV /*!< ADC flag ADC multimode slave analog watchdog 1 of the ADC slave */
  553. #define LL_ADC_FLAG_AWD2_MST ADC_CSR_AWD2_MST /*!< ADC flag ADC multimode master analog watchdog 2 of the ADC master */
  554. #define LL_ADC_FLAG_AWD2_SLV ADC_CSR_AWD2_SLV /*!< ADC flag ADC multimode slave analog watchdog 2 of the ADC slave */
  555. #define LL_ADC_FLAG_AWD3_MST ADC_CSR_AWD3_MST /*!< ADC flag ADC multimode master analog watchdog 3 of the ADC master */
  556. #define LL_ADC_FLAG_AWD3_SLV ADC_CSR_AWD3_SLV /*!< ADC flag ADC multimode slave analog watchdog 3 of the ADC slave */
  557. #endif
  558. /**
  559. * @}
  560. */
  561. /** @defgroup ADC_LL_EC_IT ADC interruptions for configuration (interruption enable or disable)
  562. * @brief IT defines which can be used with LL_ADC_ReadReg and LL_ADC_WriteReg functions
  563. * @{
  564. */
  565. #define LL_ADC_IT_ADRDY ADC_IER_ADRDYIE /*!< ADC interruption ADC instance ready */
  566. #define LL_ADC_IT_EOC ADC_IER_EOCIE /*!< ADC interruption ADC group regular end of unitary conversion */
  567. #define LL_ADC_IT_EOS ADC_IER_EOSIE /*!< ADC interruption ADC group regular end of sequence conversions */
  568. #define LL_ADC_IT_OVR ADC_IER_OVRIE /*!< ADC interruption ADC group regular overrun */
  569. #define LL_ADC_IT_EOSMP ADC_IER_EOSMPIE /*!< ADC interruption ADC group regular end of sampling phase */
  570. #define LL_ADC_IT_JEOC ADC_IER_JEOCIE /*!< ADC interruption ADC group injected end of unitary conversion */
  571. #define LL_ADC_IT_JEOS ADC_IER_JEOSIE /*!< ADC interruption ADC group injected end of sequence conversions */
  572. #define LL_ADC_IT_JQOVF ADC_IER_JQOVFIE /*!< ADC interruption ADC group injected contexts queue overflow */
  573. #define LL_ADC_IT_AWD1 ADC_IER_AWD1IE /*!< ADC interruption ADC analog watchdog 1 */
  574. #define LL_ADC_IT_AWD2 ADC_IER_AWD2IE /*!< ADC interruption ADC analog watchdog 2 */
  575. #define LL_ADC_IT_AWD3 ADC_IER_AWD3IE /*!< ADC interruption ADC analog watchdog 3 */
  576. /**
  577. * @}
  578. */
  579. /** @defgroup ADC_LL_EC_REGISTERS ADC registers compliant with specific purpose
  580. * @{
  581. */
  582. /* List of ADC registers intended to be used (most commonly) with */
  583. /* DMA transfer. */
  584. /* Refer to function @ref LL_ADC_DMA_GetRegAddr(). */
  585. #define LL_ADC_DMA_REG_REGULAR_DATA ((uint32_t)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() */
  586. #if defined(ADC_MULTIMODE_SUPPORT)
  587. #define LL_ADC_DMA_REG_REGULAR_DATA_MULTI ((uint32_t)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() */
  588. #endif
  589. /**
  590. * @}
  591. */
  592. /** @defgroup ADC_LL_EC_COMMON_CLOCK_SOURCE ADC common - Clock source
  593. * @{
  594. */
  595. #define LL_ADC_CLOCK_SYNC_PCLK_DIV1 (ADC_CCR_CKMODE_0) /*!< ADC synchronous clock derived from AHB clock without prescaler */
  596. #define LL_ADC_CLOCK_SYNC_PCLK_DIV2 (ADC_CCR_CKMODE_1 ) /*!< ADC synchronous clock derived from AHB clock with prescaler division by 2 */
  597. #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 */
  598. #define LL_ADC_CLOCK_ASYNC_DIV1 ((uint32_t)0x00000000U) /*!< ADC asynchronous clock without prescaler */
  599. /**
  600. * @}
  601. */
  602. /** @defgroup ADC_LL_EC_COMMON_PATH_INTERNAL ADC common - Measurement path to internal channels
  603. * @{
  604. */
  605. /* Note: Other measurement paths to internal channels may be available */
  606. /* (connections to other peripherals). */
  607. /* If they are not listed below, they do not require any specific */
  608. /* path enable. In this case, Access to measurement path is done */
  609. /* only by selecting the corresponding ADC internal channel. */
  610. #define LL_ADC_PATH_INTERNAL_NONE ((uint32_t)0x00000000U)/*!< ADC measurement pathes all disabled */
  611. #define LL_ADC_PATH_INTERNAL_VREFINT (ADC_CCR_VREFEN) /*!< ADC measurement path to internal channel VrefInt */
  612. #define LL_ADC_PATH_INTERNAL_TEMPSENSOR (ADC_CCR_TSEN) /*!< ADC measurement path to internal channel temperature sensor */
  613. #define LL_ADC_PATH_INTERNAL_VBAT (ADC_CCR_VBATEN) /*!< ADC measurement path to internal channel Vbat */
  614. /**
  615. * @}
  616. */
  617. /** @defgroup ADC_LL_EC_RESOLUTION ADC instance - Resolution
  618. * @{
  619. */
  620. #define LL_ADC_RESOLUTION_12B ((uint32_t)0x00000000U) /*!< ADC resolution 12 bits */
  621. #define LL_ADC_RESOLUTION_10B ( ADC_CFGR_RES_0) /*!< ADC resolution 10 bits */
  622. #define LL_ADC_RESOLUTION_8B (ADC_CFGR_RES_1 ) /*!< ADC resolution 8 bits */
  623. #define LL_ADC_RESOLUTION_6B (ADC_CFGR_RES_1 | ADC_CFGR_RES_0) /*!< ADC resolution 6 bits */
  624. /**
  625. * @}
  626. */
  627. /** @defgroup ADC_LL_EC_DATA_ALIGN ADC instance - Data alignment
  628. * @{
  629. */
  630. #define LL_ADC_DATA_ALIGN_RIGHT ((uint32_t)0x00000000U)/*!< ADC conversion data alignment: right aligned (alignment on data register LSB bit 0)*/
  631. #define LL_ADC_DATA_ALIGN_LEFT (ADC_CFGR_ALIGN) /*!< ADC conversion data alignment: left aligned (aligment on data register MSB bit 15)*/
  632. /**
  633. * @}
  634. */
  635. /** @defgroup ADC_LL_EC_LP_MODE ADC instance - Low power mode
  636. * @{
  637. */
  638. #define LL_ADC_LP_MODE_NONE ((uint32_t)0x00000000U) /*!< No ADC low power mode activated */
  639. #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(). */
  640. /**
  641. * @}
  642. */
  643. /** @defgroup ADC_LL_EC_OFFSET_NB ADC instance - Offset number
  644. * @{
  645. */
  646. #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) */
  647. #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) */
  648. #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) */
  649. #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) */
  650. /**
  651. * @}
  652. */
  653. /** @defgroup ADC_LL_EC_OFFSET_STATE ADC instance - Offset state
  654. * @{
  655. */
  656. #define LL_ADC_OFFSET_DISABLE ((uint32_t)0x00000000U)/*!< ADC offset disabled (among ADC selected offset number 1, 2, 3 or 4) */
  657. #define LL_ADC_OFFSET_ENABLE (ADC_OFR1_OFFSET1_EN) /*!< ADC offset enabled (among ADC selected offset number 1, 2, 3 or 4) */
  658. /**
  659. * @}
  660. */
  661. /** @defgroup ADC_LL_EC_GROUPS ADC instance - Groups
  662. * @{
  663. */
  664. #define LL_ADC_GROUP_REGULAR ((uint32_t)0x00000001U) /*!< ADC group regular (available on all STM32 devices) */
  665. #define LL_ADC_GROUP_INJECTED ((uint32_t)0x00000002U) /*!< ADC group injected (not available on all STM32 devices)*/
  666. #define LL_ADC_GROUP_REGULAR_INJECTED ((uint32_t)0x00000003U) /*!< ADC both groups regular and injected */
  667. /**
  668. * @}
  669. */
  670. /** @defgroup ADC_LL_EC_CHANNEL ADC instance - Channel number
  671. * @{
  672. */
  673. #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 */
  674. #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 */
  675. #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 */
  676. #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 */
  677. #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 */
  678. #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 */
  679. #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 */
  680. #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 */
  681. #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 */
  682. #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 */
  683. #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 */
  684. #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 */
  685. #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 */
  686. #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 */
  687. #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 */
  688. #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 */
  689. #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 */
  690. #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 */
  691. #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 */
  692. #define LL_ADC_CHANNEL_VREFINT (LL_ADC_CHANNEL_18 | ADC_CHANNEL_ID_INTERNAL_CH) /*!< ADC internal channel connected to VrefInt: Internal voltage reference. On STM32F3, ADC channel available only on all ADC instances, but only one ADC instance is allowed to be connected to VrefInt at the same time. */
  693. #define LL_ADC_CHANNEL_TEMPSENSOR (LL_ADC_CHANNEL_16 | ADC_CHANNEL_ID_INTERNAL_CH) /*!< ADC internal channel connected to Temperature sensor. On STM32F3, ADC channel available only on ADC instance: ADC1. */
  694. #define LL_ADC_CHANNEL_VBAT (LL_ADC_CHANNEL_17 | 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 STM32F3, ADC channel available only on ADC instance: ADC1. */
  695. #if defined(OPAMP1_CSR_OPAMP1EN)
  696. #define LL_ADC_CHANNEL_VOPAMP1 (LL_ADC_CHANNEL_15 | ADC_CHANNEL_ID_INTERNAL_CH) /*!< ADC internal channel connected to OPAMP1 output. On STM32F3, ADC channel available only on ADC instance: ADC1. */
  697. #endif
  698. #if defined(OPAMP2_CSR_OPAMP2EN)
  699. #define LL_ADC_CHANNEL_VOPAMP2 (LL_ADC_CHANNEL_17 | ADC_CHANNEL_ID_INTERNAL_CH | ADC_CHANNEL_ID_INTERNAL_CH_2) /*!< ADC internal channel connected to OPAMP2 output. On STM32F3, ADC channel available only on ADC instance: ADC2. */
  700. #endif
  701. #if defined(OPAMP3_CSR_OPAMP3EN)
  702. #define LL_ADC_CHANNEL_VOPAMP3 (LL_ADC_CHANNEL_17 | ADC_CHANNEL_ID_INTERNAL_CH | ADC_CHANNEL_ID_INTERNAL_CH_2) /*!< ADC internal channel connected to OPAMP3 output. On STM32F3, ADC channel available only on ADC instance: ADC3. */
  703. #endif
  704. #if defined(OPAMP4_CSR_OPAMP4EN)
  705. #define LL_ADC_CHANNEL_VOPAMP4 (LL_ADC_CHANNEL_17 | ADC_CHANNEL_ID_INTERNAL_CH | ADC_CHANNEL_ID_INTERNAL_CH_2) /*!< ADC internal channel connected to OPAMP4 output. On STM32F3, ADC channel available only on ADC instance: ADC4. */
  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 ((uint32_t)0x00000000U) /*!< ADC group regular conversion trigger internal: SW start. */
  714. #if defined(STM32F303xC) || defined(STM32F358xx) || defined(STM32F303xE) || defined(STM32F398xx)
  715. /* ADC group regular external triggers for ADC instances: ADC1, ADC2 (for */
  716. /* ADC instances ADCx available on the selected device) */
  717. /* Note: Literal without suffix "ADCxy" means that external trigger */
  718. /* is available on all ADC instances. */
  719. /* Note: For devices STM32F303xE, STM32F398xx: some triggers require to set */
  720. /* register SYSCFG_CFGR4. Refer to reference manual. */
  721. #define LL_ADC_REG_TRIG_EXT_TIM1_CH1_ADC12 (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). */
  722. #define LL_ADC_REG_TRIG_EXT_TIM1_CH2_ADC12 (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). */
  723. #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). */
  724. #define LL_ADC_REG_TRIG_EXT_TIM2_CH2_ADC12 (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). */
  725. #define LL_ADC_REG_TRIG_EXT_TIM3_TRGO_ADC12 (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). */
  726. #define LL_ADC_REG_TRIG_EXT_TIM4_CH4_ADC12 (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). */
  727. #define LL_ADC_REG_TRIG_EXT_EXTI_LINE11_ADC12 (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). */
  728. #define LL_ADC_REG_TRIG_EXT_TIM8_TRGO_ADC12 (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). */
  729. #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). */
  730. #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). */
  731. #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). */
  732. #define LL_ADC_REG_TRIG_EXT_TIM2_TRGO_ADC12 (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). */
  733. #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). */
  734. #define LL_ADC_REG_TRIG_EXT_TIM6_TRGO_ADC12 (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). */
  735. #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). */
  736. #define LL_ADC_REG_TRIG_EXT_TIM3_CH4_ADC12 (ADC_CFGR_EXTSEL | 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). */
  737. #if defined(STM32F303xE) || defined(STM32F398xx)
  738. #define LL_ADC_REG_TRIG_EXT_TIM20_TRG0_ADC12 (LL_ADC_REG_TRIG_EXT_TIM1_CH3) /*!< ADC group regular conversion trigger from external IP: TIM20 TRGO. Trigger edge set to rising edge (default setting). */
  739. #define LL_ADC_REG_TRIG_EXT_TIM20_TRG02_ADC12 (LL_ADC_REG_TRIG_EXT_TIM2_CH2_ADC12) /*!< ADC group regular conversion trigger from external IP: TIM20 TRGO2. Trigger edge set to rising edge (default setting). */
  740. #define LL_ADC_REG_TRIG_EXT_TIM20_CH1_ADC12 (LL_ADC_REG_TRIG_EXT_TIM4_CH4_ADC12) /*!< ADC group regular conversion trigger from external IP: TIM20 channel 1 event (capture compare: input capture or output capture). Trigger edge set to rising edge (default setting). */
  741. #define LL_ADC_REG_TRIG_EXT_TIM20_CH2_ADC12 (LL_ADC_REG_TRIG_EXT_TIM6_TRGO_ADC12) /*!< ADC group regular conversion trigger from external IP: TIM20 channel 2 event (capture compare: input capture or output capture). Trigger edge set to rising edge (default setting). */
  742. #define LL_ADC_REG_TRIG_EXT_TIM20_CH3_ADC12 (LL_ADC_REG_TRIG_EXT_TIM3_CH4_ADC12) /*!< ADC group regular conversion trigger from external IP: TIM20 channel 3 event (capture compare: input capture or output capture). Trigger edge set to rising edge (default setting). */
  743. #endif /* STM32F303xE || STM32F398xx */
  744. /* ADC group regular external triggers for ADC instances: ADC3, ADC4 (for */
  745. /* ADC instances ADCx available on the selected device) */
  746. /* Note: Literal without suffix "ADCxy" means that external trigger */
  747. /* is available on all ADC instances. */
  748. /* Note: For devices STM32F303xE, STM32F398xx: some triggers require to set */
  749. /* register SYSCFG_CFGR4. Refer to reference manual. */
  750. #define LL_ADC_REG_TRIG_EXT_TIM3_CH1_ADC34 (ADC_REG_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group regular conversion trigger from external IP: TIM3 channel 1 event (capture compare: input capture or output capture). Trigger edge set to rising edge (default setting). */
  751. #define LL_ADC_REG_TRIG_EXT_TIM2_CH3_ADC34 (ADC_CFGR_EXTSEL_0 | ADC_REG_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group regular conversion trigger from external IP: TIM2 channel 3 event (capture compare: input capture or output capture). Trigger edge set to rising edge (default setting). */
  752. #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). */
  753. #define LL_ADC_REG_TRIG_EXT_TIM8_CH1_ADC34 (ADC_CFGR_EXTSEL_1 | ADC_CFGR_EXTSEL_0 | ADC_REG_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group regular conversion trigger from external IP: TIM8 channel 1 event (capture compare: input capture or output capture). Trigger edge set to rising edge (default setting). */
  754. #define LL_ADC_REG_TRIG_EXT_TIM8_TRGO__ADC34 (ADC_CFGR_EXTSEL_2 | ADC_REG_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group regular conversion trigger from external IP: TIM8 TRGO. Trigger edge set to rising edge (default setting). */
  755. #define LL_ADC_REG_TRIG_EXT_EXTI_LINE2_ADC34 (ADC_CFGR_EXTSEL_2 | ADC_CFGR_EXTSEL_0 | ADC_REG_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group regular conversion trigger from external IP: external interrupt line 2. Trigger edge set to rising edge (default setting). */
  756. #define LL_ADC_REG_TRIG_EXT_TIM4_CH1_ADC34 (ADC_CFGR_EXTSEL_2 | ADC_CFGR_EXTSEL_1 | ADC_REG_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group regular conversion trigger from external IP: TIM4 channel 1 event (capture compare: input capture or output capture). Trigger edge set to rising edge (default setting). */
  757. #define LL_ADC_REG_TRIG_EXT_TIM2_TRGO__ADC34 (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: TIM2 TRGO. Trigger edge set to rising edge (default setting). */
  758. #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). */
  759. #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). */
  760. #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). */
  761. #define LL_ADC_REG_TRIG_EXT_TIM3_TRGO__ADC34 (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: TIM3 TRGO. Trigger edge set to rising edge (default setting). */
  762. #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). */
  763. #define LL_ADC_REG_TRIG_EXT_TIM7_TRGO_ADC34 (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: TIM7 TRGO. Trigger edge set to rising edge (default setting). */
  764. #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). */
  765. #define LL_ADC_REG_TRIG_EXT_TIM2_CH1_ADC34 (ADC_CFGR_EXTSEL | ADC_REG_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group regular conversion trigger from external IP: TIM2 CCx. Trigger edge set to rising edge (default setting). */
  766. #if defined(STM32F303xE) || defined(STM32F398xx)
  767. #define LL_ADC_REG_TRIG_EXT_TIM20_TRG0_ADC34 (LL_ADC_REG_TRIG_EXT_EXTI_LINE2_ADC34) /*!< ADC group regular conversion trigger from external IP: TIM20 TRGO. Trigger edge set to rising edge (default setting). */
  768. #define LL_ADC_REG_TRIG_EXT_TIM20_TRG02_ADC34 (LL_ADC_REG_TRIG_EXT_TIM4_CH1_ADC34) /*!< ADC group regular conversion trigger from external IP: TIM20 TRGO2. Trigger edge set to rising edge (default setting). */
  769. #define LL_ADC_REG_TRIG_EXT_TIM20_CH1_ADC34 (LL_ADC_REG_TRIG_EXT_TIM2_CH1_ADC34) /*!< ADC group regular conversion trigger from external IP: TIM20 channel 1 event (capture compare: input capture or output capture). Trigger edge set to rising edge (default setting). */
  770. #endif /* STM32F303xE || STM32F398xx */
  771. #elif defined(STM32F303x8) || defined(STM32F328xx)
  772. #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). */
  773. #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). */
  774. #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). */
  775. #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). */
  776. #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). */
  777. #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). */
  778. #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). */
  779. #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). */
  780. #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). */
  781. #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). */
  782. #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). */
  783. #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). */
  784. #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). */
  785. #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). */
  786. #define LL_ADC_REG_TRIG_EXT_TIM3_CH4 (ADC_CFGR_EXTSEL | 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). */
  787. #elif defined(STM32F334x8)
  788. #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). */
  789. #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). */
  790. #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). */
  791. #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). */
  792. #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). */
  793. #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). */
  794. #define LL_ADC_REG_TRIG_EXT_HRTIM_TRG1 (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: HRTIM TRG1. Trigger edge set to rising edge (default setting). */
  795. #define LL_ADC_REG_TRIG_EXT_HRTIM_TRG3 (ADC_CFGR_EXTSEL_3 | ADC_REG_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group regular conversion trigger from external IP: HRTIM TRG3. Trigger edge set to rising edge (default setting). */
  796. #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). */
  797. #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). */
  798. #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). */
  799. #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). */
  800. #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). */
  801. #define LL_ADC_REG_TRIG_EXT_TIM3_CH4 (ADC_CFGR_EXTSEL | 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). */
  802. #elif defined(STM32F302xC) || defined(STM32F302xE)
  803. #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). */
  804. #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). */
  805. #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). */
  806. #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). */
  807. #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). */
  808. #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). */
  809. #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). */
  810. #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). */
  811. #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). */
  812. #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). */
  813. #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). */
  814. #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). */
  815. #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). */
  816. #define LL_ADC_REG_TRIG_EXT_TIM3_CH4 (ADC_CFGR_EXTSEL | 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). */
  817. #elif defined(STM32F301x8) || defined(STM32F302x8) || defined(STM32F318xx)
  818. #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). */
  819. #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). */
  820. #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). */
  821. #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). */
  822. #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). */
  823. #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). */
  824. #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). */
  825. #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). */
  826. #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). */
  827. #endif
  828. /**
  829. * @}
  830. */
  831. /** @defgroup ADC_LL_EC_REG_TRIGGER_EDGE ADC group regular - Trigger edge
  832. * @{
  833. */
  834. #define LL_ADC_REG_TRIG_EXT_RISING ( ADC_CFGR_EXTEN_0) /*!< ADC group regular conversion trigger polarity set to rising edge */
  835. #define LL_ADC_REG_TRIG_EXT_FALLING (ADC_CFGR_EXTEN_1 ) /*!< ADC group regular conversion trigger polarity set to falling edge */
  836. #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 */
  837. /**
  838. * @}
  839. */
  840. /** @defgroup ADC_LL_EC_REG_CONTINUOUS_MODE ADC group regular - Continuous mode
  841. * @{
  842. */
  843. #define LL_ADC_REG_CONV_SINGLE ((uint32_t)0x00000000U) /*!< ADC conversions are performed in single mode: one conversion per trigger */
  844. #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 */
  845. /**
  846. * @}
  847. */
  848. /** @defgroup ADC_LL_EC_REG_DMA_TRANSFER ADC group regular - DMA transfer of ADC conversion data
  849. * @{
  850. */
  851. #define LL_ADC_REG_DMA_TRANSFER_NONE ((uint32_t)0x00000000U) /*!< ADC conversions are not transferred by DMA */
  852. #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. */
  853. #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. */
  854. /**
  855. * @}
  856. */
  857. /** @defgroup ADC_LL_EC_REG_OVR_DATA_BEHAVIOR ADC group regular - Overrun behavior on conversion data
  858. * @{
  859. */
  860. #define LL_ADC_REG_OVR_DATA_PRESERVED ((uint32_t)0x00000000U)/*!< ADC group regular behavior in case of overrun: data preserved */
  861. #define LL_ADC_REG_OVR_DATA_OVERWRITTEN (ADC_CFGR_OVRMOD) /*!< ADC group regular behavior in case of overrun: data overwritten */
  862. /**
  863. * @}
  864. */
  865. /** @defgroup ADC_LL_EC_REG_SEQ_SCAN_LENGTH ADC group regular - Sequencer scan length
  866. * @{
  867. */
  868. #define LL_ADC_REG_SEQ_SCAN_DISABLE ((uint32_t)0x00000000U) /*!< ADC group regular sequencer disable (equivalent to sequencer of 1 rank: ADC conversion on only 1 channel) */
  869. #define LL_ADC_REG_SEQ_SCAN_ENABLE_2RANKS ( ADC_SQR1_L_0) /*!< ADC group regular sequencer enable with 2 ranks in the sequence */
  870. #define LL_ADC_REG_SEQ_SCAN_ENABLE_3RANKS ( ADC_SQR1_L_1 ) /*!< ADC group regular sequencer enable with 3 ranks in the sequence */
  871. #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 */
  872. #define LL_ADC_REG_SEQ_SCAN_ENABLE_5RANKS ( ADC_SQR1_L_2 ) /*!< ADC group regular sequencer enable with 5 ranks in the sequence */
  873. #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 */
  874. #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 */
  875. #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 */
  876. #define LL_ADC_REG_SEQ_SCAN_ENABLE_9RANKS (ADC_SQR1_L_3 ) /*!< ADC group regular sequencer enable with 9 ranks in the sequence */
  877. #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 */
  878. #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 */
  879. #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 */
  880. #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 */
  881. #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 */
  882. #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 */
  883. #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 */
  884. /**
  885. * @}
  886. */
  887. /** @defgroup ADC_LL_EC_REG_SEQ_DISCONT_MODE ADC group regular - Sequencer discontinuous mode
  888. * @{
  889. */
  890. #define LL_ADC_REG_SEQ_DISCONT_DISABLE ((uint32_t)0x00000000U) /*!< ADC group regular sequencer discontinuous mode disable */
  891. #define LL_ADC_REG_SEQ_DISCONT_1RANK ( ADC_CFGR_DISCEN) /*!< ADC group regular sequencer discontinuous mode enable with sequence interruption every rank */
  892. #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 */
  893. #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 */
  894. #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 */
  895. #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 */
  896. #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 */
  897. #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 */
  898. #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 */
  899. /**
  900. * @}
  901. */
  902. /** @defgroup ADC_LL_EC_REG_SEQ_RANKS ADC group regular - Sequencer ranks
  903. * @{
  904. */
  905. #define LL_ADC_REG_RANK_1 (ADC_SQR1_REGOFFSET | ADC_REG_RANK_1_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 1 */
  906. #define LL_ADC_REG_RANK_2 (ADC_SQR1_REGOFFSET | ADC_REG_RANK_2_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 2 */
  907. #define LL_ADC_REG_RANK_3 (ADC_SQR1_REGOFFSET | ADC_REG_RANK_3_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 3 */
  908. #define LL_ADC_REG_RANK_4 (ADC_SQR1_REGOFFSET | ADC_REG_RANK_4_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 4 */
  909. #define LL_ADC_REG_RANK_5 (ADC_SQR2_REGOFFSET | ADC_REG_RANK_5_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 5 */
  910. #define LL_ADC_REG_RANK_6 (ADC_SQR2_REGOFFSET | ADC_REG_RANK_6_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 6 */
  911. #define LL_ADC_REG_RANK_7 (ADC_SQR2_REGOFFSET | ADC_REG_RANK_7_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 7 */
  912. #define LL_ADC_REG_RANK_8 (ADC_SQR2_REGOFFSET | ADC_REG_RANK_8_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 8 */
  913. #define LL_ADC_REG_RANK_9 (ADC_SQR2_REGOFFSET | ADC_REG_RANK_9_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 9 */
  914. #define LL_ADC_REG_RANK_10 (ADC_SQR3_REGOFFSET | ADC_REG_RANK_10_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 10 */
  915. #define LL_ADC_REG_RANK_11 (ADC_SQR3_REGOFFSET | ADC_REG_RANK_11_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 11 */
  916. #define LL_ADC_REG_RANK_12 (ADC_SQR3_REGOFFSET | ADC_REG_RANK_12_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 12 */
  917. #define LL_ADC_REG_RANK_13 (ADC_SQR3_REGOFFSET | ADC_REG_RANK_13_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 13 */
  918. #define LL_ADC_REG_RANK_14 (ADC_SQR3_REGOFFSET | ADC_REG_RANK_14_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 14 */
  919. #define LL_ADC_REG_RANK_15 (ADC_SQR4_REGOFFSET | ADC_REG_RANK_15_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 15 */
  920. #define LL_ADC_REG_RANK_16 (ADC_SQR4_REGOFFSET | ADC_REG_RANK_16_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 16 */
  921. /**
  922. * @}
  923. */
  924. /** @defgroup ADC_LL_EC_INJ_TRIGGER_SOURCE ADC group injected - Trigger source
  925. * @{
  926. */
  927. #define LL_ADC_INJ_TRIG_SOFTWARE ((uint32_t)0x00000000U) /*!< ADC group injected conversion trigger internal: SW start.. Trigger edge set to rising edge (default setting). */
  928. #if defined(STM32F303xC) || defined(STM32F358xx) || defined(STM32F303xE) || defined(STM32F398xx)
  929. /* ADC group injected external triggers for ADC instances: ADC1, ADC2 (for */
  930. /* ADC instances ADCx available on the selected device) */
  931. /* Note: Literal without suffix "ADCxy" means that external trigger */
  932. /* is available on all ADC instances. */
  933. /* Note: For devices STM32F303xE, STM32F398xx: some triggers require to set */
  934. /* register SYSCFG_CFGR4. Refer to reference manual. */
  935. #define LL_ADC_INJ_TRIG_EXT_TIM1_TRGO (ADC_INJ_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group injected conversion trigger from external IP: TIM1 TRG0. Trigger edge set to rising edge (default setting). */
  936. #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). */
  937. #define LL_ADC_INJ_TRIG_EXT_TIM2_TRGO_ADC12 (ADC_JSQR_JEXTSEL_1 | ADC_INJ_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group injected conversion trigger from external IP: TIM2 TRG0. Trigger edge set to rising edge (default setting). */
  938. #define LL_ADC_INJ_TRIG_EXT_TIM2_CH1_ADC12 (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). */
  939. #define LL_ADC_INJ_TRIG_EXT_TIM3_CH4_ADC12 (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). */
  940. #define LL_ADC_INJ_TRIG_EXT_TIM4_TRGO_ADC12 (ADC_JSQR_JEXTSEL_2 | ADC_JSQR_JEXTSEL_0 | ADC_INJ_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group injected conversion trigger from external IP: TIM4 TRG0. Trigger edge set to rising edge (default setting). */
  941. #define LL_ADC_INJ_TRIG_EXT_EXTI_LINE15_ADC12 (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). */
  942. #define LL_ADC_INJ_TRIG_EXT_TIM8_CH4_ADC12 (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). */
  943. #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 TRG02. Trigger edge set to rising edge (default setting). */
  944. #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 TRG0. Trigger edge set to rising edge (default setting). */
  945. #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 TRG02. Trigger edge set to rising edge (default setting). */
  946. #define LL_ADC_INJ_TRIG_EXT_TIM3_CH3_ADC12 (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). */
  947. #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 TRG0. Trigger edge set to rising edge (default setting). */
  948. #define LL_ADC_INJ_TRIG_EXT_TIM3_CH1_ADC12 (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). */
  949. #define LL_ADC_INJ_TRIG_EXT_TIM6_TRGO_ADC12 (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 TRG0. Trigger edge set to rising edge (default setting). */
  950. #define LL_ADC_INJ_TRIG_EXT_TIM15_TRGO (ADC_JSQR_JEXTSEL | ADC_INJ_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group injected conversion trigger from external IP: TIM15 TRG0. Trigger edge set to rising edge (default setting). */
  951. #if defined(STM32F303xE) || defined(STM32F398xx)
  952. #define LL_ADC_INJ_TRIG_EXT_TIM20_TRGO_ADC12 (LL_ADC_INJ_TRIG_EXT_TIM2_CH1_ADC12) /*!< ADC group injected conversion trigger from external IP: TIM20 TRG0. Trigger edge set to rising edge (default setting). */
  953. #define LL_ADC_INJ_TRIG_EXT_TIM20_TRGO2_ADC12 (LL_ADC_INJ_TRIG_EXT_EXTI_LINE15_ADC12) /*!< ADC group injected conversion trigger from external IP: TIM20 TRG02. Trigger edge set to rising edge (default setting). */
  954. #define LL_ADC_INJ_TRIG_EXT_TIM20_CH4_ADC12 (LL_ADC_INJ_TRIG_EXT_TIM2_CH1_ADC12) /*!< ADC group injected conversion trigger from external IP: TIM20 channel 4 event (capture compare: input capture or output capture). Trigger edge set to rising edge (default setting). */
  955. #endif /* STM32F303xE || STM32F398xx */
  956. /* ADC group injected external triggers for ADC instances: ADC3, ADC4 (for */
  957. /* ADC instances ADCx available on the selected device) */
  958. /* Note: Literal without suffix "ADCxy" means that external trigger */
  959. /* is available on all ADC instances. */
  960. /* Note: External triggers JEXT2 and JEXT5 are the same (TIM4_CH3 event). */
  961. /* JEXT2 is the main trigger, JEXT5 is kept as spare trigger for */
  962. /* future devices. */
  963. /* Note: For devices STM32F303xE, STM32F398xx: some triggers require to set */
  964. /* register SYSCFG_CFGR4. Refer to reference manual. */
  965. #define LL_ADC_INJ_TRIG_EXT_TIM1_TRGO (ADC_INJ_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group injected conversion trigger from external IP: TIM1 TRG0. Trigger edge set to rising edge (default setting). */
  966. #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). */
  967. #define LL_ADC_INJ_TRIG_EXT_TIM4_CH3_ADC34 (ADC_JSQR_JEXTSEL_1 | ADC_INJ_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group injected conversion trigger from external IP: TIM4 channel 3 event (capture compare: input capture or output capture). Trigger edge set to rising edge (default setting). */
  968. #define LL_ADC_INJ_TRIG_EXT_TIM8_CH2_ADC34 (ADC_JSQR_JEXTSEL_1 | ADC_JSQR_JEXTSEL_0 | ADC_INJ_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group injected conversion trigger from external IP: TIM8 channel 2 event (capture compare: input capture or output capture). Trigger edge set to rising edge (default setting). */
  969. #define LL_ADC_INJ_TRIG_EXT_TIM8_CH4__ADC34 (ADC_JSQR_JEXTSEL_2 | 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). */
  970. #define LL_ADC_INJ_TRIG_EXT_TIM4_CH4_ADC34 (ADC_JSQR_JEXTSEL_2 | ADC_JSQR_JEXTSEL_1 | ADC_INJ_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group injected conversion trigger from external IP: TIM4 channel 4 event (capture compare: input capture or output capture). Trigger edge set to rising edge (default setting). */
  971. #define LL_ADC_INJ_TRIG_EXT_TIM4_TRGO__ADC34 (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: TIM4 TRG0. Trigger edge set to rising edge (default setting). */
  972. #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 TRG02. Trigger edge set to rising edge (default setting). */
  973. #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 TRG0. Trigger edge set to rising edge (default setting). */
  974. #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 TRG02. Trigger edge set to rising edge (default setting). */
  975. #define LL_ADC_INJ_TRIG_EXT_TIM1_CH3_ADC34 (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: TIM1 channel 3 event (capture compare: input capture or output capture). Trigger edge set to rising edge (default setting). */
  976. #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 TRG0. Trigger edge set to rising edge (default setting). */
  977. #define LL_ADC_INJ_TRIG_EXT_TIM2_TRGO__ADC34 (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: TIM2 TRG0. Trigger edge set to rising edge (default setting). */
  978. #define LL_ADC_INJ_TRIG_EXT_TIM7_TRGO_ADC34 (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: TIM7 TRG0. Trigger edge set to rising edge (default setting). */
  979. #define LL_ADC_INJ_TRIG_EXT_TIM15_TRGO (ADC_JSQR_JEXTSEL | ADC_INJ_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group injected conversion trigger from external IP: TIM15 TRG0. Trigger edge set to rising edge (default setting). */
  980. #if defined(STM32F303xE) || defined(STM32F398xx)
  981. #define LL_ADC_INJ_TRIG_EXT_TIM20_TRG_ADC34 (ADC_JSQR_JEXTSEL_2 | ADC_JSQR_JEXTSEL_0 | ADC_INJ_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group injected conversion trigger from external IP: TIM20 TRG0. Trigger edge set to rising edge (default setting). */
  982. #define LL_ADC_INJ_TRIG_EXT_TIM20_TRG2_ADC34 (LL_ADC_INJ_TRIG_EXT_TIM1_CH3_ADC34) /*!< ADC group injected conversion trigger from external IP: TIM20 TRG02. Trigger edge set to rising edge (default setting). */
  983. #define LL_ADC_INJ_TRIG_EXT_TIM20_CH2 (LL_ADC_INJ_TRIG_EXT_TIM15_TRGO) /*!< ADC group injected conversion trigger from external IP: TIM20 channel 2 event (capture compare: input capture or output capture). Trigger edge set to rising edge (default setting). */
  984. #endif /* STM32F303xE || STM32F398xx */
  985. #elif defined(STM32F303x8) || defined(STM32F328xx)
  986. #define LL_ADC_INJ_TRIG_EXT_TIM1_TRGO (ADC_INJ_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group injected conversion trigger from external IP: TIM1 TRG0. Trigger edge set to rising edge (default setting). */
  987. #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). */
  988. #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 TRG0. Trigger edge set to rising edge (default setting). */
  989. #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). */
  990. #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). */
  991. #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 TRG0. Trigger edge set to rising edge (default setting). */
  992. #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). */
  993. #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). */
  994. #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 TRG02. Trigger edge set to rising edge (default setting). */
  995. #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 TRG0. Trigger edge set to rising edge (default setting). */
  996. #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 TRG02. Trigger edge set to rising edge (default setting). */
  997. #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). */
  998. #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 TRG0. Trigger edge set to rising edge (default setting). */
  999. #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). */
  1000. #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 TRG0. Trigger edge set to rising edge (default setting). */
  1001. #define LL_ADC_INJ_TRIG_EXT_TIM15_TRGO (ADC_JSQR_JEXTSEL | ADC_INJ_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group injected conversion trigger from external IP: TIM15 TRG0. Trigger edge set to rising edge (default setting). */
  1002. #elif defined(STM32F334x8)
  1003. #define LL_ADC_INJ_TRIG_EXT_TIM1_TRGO (ADC_INJ_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group injected conversion trigger from external IP: TIM1 TRG0. Trigger edge set to rising edge (default setting). */
  1004. #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). */
  1005. #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 TRG0. Trigger edge set to rising edge (default setting). */
  1006. #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). */
  1007. #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). */
  1008. #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). */
  1009. #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 TRG02. Trigger edge set to rising edge (default setting). */
  1010. #define LL_ADC_INJ_TRIG_EXT_HRTIM_TRG2 (ADC_JSQR_JEXTSEL_3 | ADC_JSQR_JEXTSEL_0 | ADC_INJ_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group injected conversion trigger from external IP: HRTIM TRG2. Trigger edge set to rising edge (default setting). */
  1011. #define LL_ADC_INJ_TRIG_EXT_HRTIM_TRG4 (ADC_JSQR_JEXTSEL_3 | ADC_JSQR_JEXTSEL_1 | ADC_INJ_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group injected conversion trigger from external IP: HRTIM TRG4. Trigger edge set to rising edge (default setting). */
  1012. #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). */
  1013. #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 TRG0. Trigger edge set to rising edge (default setting). */
  1014. #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). */
  1015. #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 TRG0. Trigger edge set to rising edge (default setting). */
  1016. #define LL_ADC_INJ_TRIG_EXT_TIM15_TRGO (ADC_JSQR_JEXTSEL | ADC_INJ_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group injected conversion trigger from external IP: TIM15 TRG0. Trigger edge set to rising edge (default setting). */
  1017. #elif defined(STM32F302xC) || defined(STM32F302xE)
  1018. #define LL_ADC_INJ_TRIG_EXT_TIM1_TRGO (ADC_INJ_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group injected conversion trigger from external IP: TIM1 TRG0. Trigger edge set to rising edge (default setting). */
  1019. #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). */
  1020. #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 TRG0. Trigger edge set to rising edge (default setting). */
  1021. #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). */
  1022. #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). */
  1023. #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 TRG0. Trigger edge set to rising edge (default setting). */
  1024. #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). */
  1025. #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 TRG02. Trigger edge set to rising edge (default setting). */
  1026. #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). */
  1027. #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 TRG0. Trigger edge set to rising edge (default setting). */
  1028. #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). */
  1029. #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 TRG0. Trigger edge set to rising edge (default setting). */
  1030. #define LL_ADC_INJ_TRIG_EXT_TIM15_TRGO (ADC_JSQR_JEXTSEL | ADC_INJ_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group injected conversion trigger from external IP: TIM15 TRG0. Trigger edge set to rising edge (default setting). */
  1031. #elif defined(STM32F301x8) || defined(STM32F302x8) || defined(STM32F318xx)
  1032. #define LL_ADC_INJ_TRIG_EXT_TIM1_TRGO (ADC_INJ_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group injected conversion trigger from external IP: TIM1 TRG0. Trigger edge set to rising edge (default setting). */
  1033. #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). */
  1034. #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). */
  1035. #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 TRG02. Trigger edge set to rising edge (default setting). */
  1036. #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 TRG0. Trigger edge set to rising edge (default setting). */
  1037. #define LL_ADC_INJ_TRIG_EXT_TIM15_TRGO (ADC_JSQR_JEXTSEL | ADC_INJ_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group injected conversion trigger from external IP: TIM15 TRG0. Trigger edge set to rising edge (default setting). */
  1038. #endif
  1039. /**
  1040. * @}
  1041. */
  1042. /** @defgroup ADC_LL_EC_INJ_TRIGGER_EDGE ADC group injected - Trigger edge
  1043. * @{
  1044. */
  1045. #define LL_ADC_INJ_TRIG_EXT_RISING ( ADC_JSQR_JEXTEN_0) /*!< ADC group injected conversion trigger polarity set to rising edge */
  1046. #define LL_ADC_INJ_TRIG_EXT_FALLING (ADC_JSQR_JEXTEN_1 ) /*!< ADC group injected conversion trigger polarity set to falling edge */
  1047. #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 */
  1048. /**
  1049. * @}
  1050. */
  1051. /** @defgroup ADC_LL_EC_INJ_TRIG_AUTO ADC group injected - Automatic trigger mode
  1052. * @{
  1053. */
  1054. #define LL_ADC_INJ_TRIG_INDEPENDENT ((uint32_t)0x00000000U)/*!< ADC group injected conversion trigger independent. Setting mandatory if ADC group injected injected trigger source is set to an external trigger. */
  1055. #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. */
  1056. /**
  1057. * @}
  1058. */
  1059. /** @defgroup ADC_LL_EC_INJ_CONTEXT_QUEUE ADC group injected - Context queue mode
  1060. * @{
  1061. */
  1062. #define LL_ADC_INJ_QUEUE_2CONTEXTS_LAST_ACTIVE ((uint32_t)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. */
  1063. #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. */
  1064. /**
  1065. * @}
  1066. */
  1067. /** @defgroup ADC_LL_EC_INJ_SEQ_SCAN_LENGTH ADC group injected - Sequencer scan length
  1068. * @{
  1069. */
  1070. #define LL_ADC_INJ_SEQ_SCAN_DISABLE ((uint32_t)0x00000000U) /*!< ADC group injected sequencer disable (equivalent to sequencer of 1 rank: ADC conversion on only 1 channel) */
  1071. #define LL_ADC_INJ_SEQ_SCAN_ENABLE_2RANKS ( ADC_JSQR_JL_0) /*!< ADC group injected sequencer enable with 2 ranks in the sequence */
  1072. #define LL_ADC_INJ_SEQ_SCAN_ENABLE_3RANKS (ADC_JSQR_JL_1 ) /*!< ADC group injected sequencer enable with 3 ranks in the sequence */
  1073. #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 */
  1074. /**
  1075. * @}
  1076. */
  1077. /** @defgroup ADC_LL_EC_INJ_SEQ_DISCONT_MODE ADC group injected - Sequencer discontinuous mode
  1078. * @{
  1079. */
  1080. #define LL_ADC_INJ_SEQ_DISCONT_DISABLE ((uint32_t)0x00000000U)/*!< ADC group injected sequencer discontinuous mode disable */
  1081. #define LL_ADC_INJ_SEQ_DISCONT_1RANK (ADC_CFGR_JDISCEN) /*!< ADC group injected sequencer discontinuous mode enable with sequence interruption every rank */
  1082. /**
  1083. * @}
  1084. */
  1085. /** @defgroup ADC_LL_EC_INJ_SEQ_RANKS ADC group injected - Sequencer ranks
  1086. * @{
  1087. */
  1088. #define LL_ADC_INJ_RANK_1 (ADC_JDR1_REGOFFSET | ADC_INJ_RANK_1_JSQR_BITOFFSET_POS) /*!< ADC group injected sequencer rank 1 */
  1089. #define LL_ADC_INJ_RANK_2 (ADC_JDR2_REGOFFSET | ADC_INJ_RANK_2_JSQR_BITOFFSET_POS) /*!< ADC group injected sequencer rank 2 */
  1090. #define LL_ADC_INJ_RANK_3 (ADC_JDR3_REGOFFSET | ADC_INJ_RANK_3_JSQR_BITOFFSET_POS) /*!< ADC group injected sequencer rank 3 */
  1091. #define LL_ADC_INJ_RANK_4 (ADC_JDR4_REGOFFSET | ADC_INJ_RANK_4_JSQR_BITOFFSET_POS) /*!< ADC group injected sequencer rank 4 */
  1092. /**
  1093. * @}
  1094. */
  1095. /** @defgroup ADC_LL_EC_CHANNEL_SAMPLINGTIME Channel - Sampling time
  1096. * @{
  1097. */
  1098. #define LL_ADC_SAMPLINGTIME_1CYCLE_5 (0x00000000U) /*!< Sampling time 1.5 ADC clock cycle */
  1099. #define LL_ADC_SAMPLINGTIME_2CYCLES_5 ( ADC_SMPR2_SMP10_0) /*!< Sampling time 2.5 ADC clock cycles */
  1100. #define LL_ADC_SAMPLINGTIME_4CYCLES_5 ( ADC_SMPR2_SMP10_1 ) /*!< Sampling time 4.5 ADC clock cycles */
  1101. #define LL_ADC_SAMPLINGTIME_7CYCLES_5 ( ADC_SMPR2_SMP10_1 | ADC_SMPR2_SMP10_0) /*!< Sampling time 7.5 ADC clock cycles */
  1102. #define LL_ADC_SAMPLINGTIME_19CYCLES_5 (ADC_SMPR2_SMP10_2 ) /*!< Sampling time 19.5 ADC clock cycles */
  1103. #define LL_ADC_SAMPLINGTIME_61CYCLES_5 (ADC_SMPR2_SMP10_2 | ADC_SMPR2_SMP10_0) /*!< Sampling time 61.5 ADC clock cycles */
  1104. #define LL_ADC_SAMPLINGTIME_181CYCLES_5 (ADC_SMPR2_SMP10_2 | ADC_SMPR2_SMP10_1 ) /*!< Sampling time 181.5 ADC clock cycles */
  1105. #define LL_ADC_SAMPLINGTIME_601CYCLES_5 (ADC_SMPR2_SMP10_2 | ADC_SMPR2_SMP10_1 | ADC_SMPR2_SMP10_0) /*!< Sampling time 601.5 ADC clock cycles */
  1106. /**
  1107. * @}
  1108. */
  1109. /** @defgroup ADC_LL_EC_CHANNEL_SINGLE_DIFF_ENDING Channel - Single or differential ending
  1110. * @{
  1111. */
  1112. #define LL_ADC_SINGLE_ENDED ( ADC_CALFACT_CALFACT_S) /*!< ADC channel ending set to single ended (literal also used to set calibration mode) */
  1113. #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) */
  1114. #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) */
  1115. /**
  1116. * @}
  1117. */
  1118. /** @defgroup ADC_LL_EC_AWD_NUMBER Analog watchdog - Analog watchdog number
  1119. * @{
  1120. */
  1121. #define LL_ADC_AWD1 (ADC_AWD_CR1_CHANNEL_MASK | ADC_AWD_CR1_REGOFFSET) /*!< ADC analog watchdog number 1 */
  1122. #define LL_ADC_AWD2 (ADC_AWD_CR23_CHANNEL_MASK | ADC_AWD_CR2_REGOFFSET) /*!< ADC analog watchdog number 2 */
  1123. #define LL_ADC_AWD3 (ADC_AWD_CR23_CHANNEL_MASK | ADC_AWD_CR3_REGOFFSET) /*!< ADC analog watchdog number 3 */
  1124. /**
  1125. * @}
  1126. */
  1127. /** @defgroup ADC_LL_EC_AWD_CHANNELS Analog watchdog - Monitored channels
  1128. * @{
  1129. */
  1130. #define LL_ADC_AWD_DISABLE ((uint32_t)0x00000000U) /*!< ADC analog watchdog monitoring disabled */
  1131. #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 */
  1132. #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 */
  1133. #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 */
  1134. #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 */
  1135. #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 */
  1136. #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 */
  1137. #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 */
  1138. #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 */
  1139. #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 */
  1140. #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 */
  1141. #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 */
  1142. #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 */
  1143. #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 */
  1144. #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 */
  1145. #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 */
  1146. #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 */
  1147. #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 */
  1148. #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 */
  1149. #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 */
  1150. #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 */
  1151. #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 */
  1152. #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 */
  1153. #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 */
  1154. #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 */
  1155. #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 */
  1156. #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 */
  1157. #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 */
  1158. #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 */
  1159. #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 */
  1160. #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 */
  1161. #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 */
  1162. #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 */
  1163. #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 */
  1164. #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 */
  1165. #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 */
  1166. #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 */
  1167. #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 */
  1168. #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 */
  1169. #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 */
  1170. #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 */
  1171. #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 */
  1172. #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 */
  1173. #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 */
  1174. #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 */
  1175. #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 */
  1176. #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 */
  1177. #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 */
  1178. #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 */
  1179. #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 */
  1180. #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 */
  1181. #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 */
  1182. #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 */
  1183. #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 */
  1184. #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 */
  1185. #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 */
  1186. #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 */
  1187. #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 */
  1188. #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 */
  1189. #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 */
  1190. #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 */
  1191. #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 */
  1192. #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 */
  1193. #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 */
  1194. #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 */
  1195. #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 */
  1196. #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 */
  1197. #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 */
  1198. #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 */
  1199. #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 */
  1200. #if defined(OPAMP1_CSR_OPAMP1EN)
  1201. #define LL_ADC_AWD_CH_VOPAMP1_REG ((LL_ADC_CHANNEL_VOPAMP1 & 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 */
  1202. #define LL_ADC_AWD_CH_VOPAMP1_INJ ((LL_ADC_CHANNEL_VOPAMP1 & 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 */
  1203. #define LL_ADC_AWD_CH_VOPAMP1_REG_INJ ((LL_ADC_CHANNEL_VOPAMP1 & 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 */
  1204. #endif
  1205. #if defined(OPAMP2_CSR_OPAMP2EN)
  1206. #define LL_ADC_AWD_CH_VOPAMP2_REG ((LL_ADC_CHANNEL_VOPAMP2 & 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 */
  1207. #define LL_ADC_AWD_CH_VOPAMP2_INJ ((LL_ADC_CHANNEL_VOPAMP2 & 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 */
  1208. #define LL_ADC_AWD_CH_VOPAMP2_REG_INJ ((LL_ADC_CHANNEL_VOPAMP2 & 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 */
  1209. #endif
  1210. #if defined(OPAMP3_CSR_OPAMP3EN)
  1211. #define LL_ADC_AWD_CH_VOPAMP3_REG ((LL_ADC_CHANNEL_VOPAMP3 & 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 */
  1212. #define LL_ADC_AWD_CH_VOPAMP3_INJ ((LL_ADC_CHANNEL_VOPAMP3 & 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 */
  1213. #define LL_ADC_AWD_CH_VOPAMP3_REG_INJ ((LL_ADC_CHANNEL_VOPAMP3 & 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 */
  1214. #endif
  1215. #if defined(OPAMP4_CSR_OPAMP4EN)
  1216. #define LL_ADC_AWD_CH_VOPAMP4_REG ((LL_ADC_CHANNEL_VOPAMP4 & 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 */
  1217. #define LL_ADC_AWD_CH_VOPAMP4_INJ ((LL_ADC_CHANNEL_VOPAMP4 & 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 */
  1218. #define LL_ADC_AWD_CH_VOPAMP4_REG_INJ ((LL_ADC_CHANNEL_VOPAMP4 & 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 */
  1219. #endif
  1220. /**
  1221. * @}
  1222. */
  1223. /** @defgroup ADC_LL_EC_AWD_THRESHOLDS Analog watchdog - Thresholds
  1224. * @{
  1225. */
  1226. #define LL_ADC_AWD_THRESHOLD_HIGH (ADC_TR1_HT1 ) /*!< ADC analog watchdog threshold high */
  1227. #define LL_ADC_AWD_THRESHOLD_LOW ( ADC_TR1_LT1) /*!< ADC analog watchdog threshold low */
  1228. #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 */
  1229. /**
  1230. * @}
  1231. */
  1232. #if defined(ADC_MULTIMODE_SUPPORT)
  1233. /** @defgroup ADC_LL_EC_MULTI_MODE Multimode - Mode
  1234. * @{
  1235. */
  1236. #define LL_ADC_MULTI_INDEPENDENT ((uint32_t)0x00000000U) /*!< ADC dual mode disabled (ADC independent mode) */
  1237. #define LL_ADC_MULTI_DUAL_REG_SIMULT ( ADC_CCR_DUAL_2 | ADC_CCR_DUAL_1 ) /*!< ADC dual mode enabled: group regular simultaneous */
  1238. #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 */
  1239. #define LL_ADC_MULTI_DUAL_INJ_SIMULT ( ADC_CCR_DUAL_2 | ADC_CCR_DUAL_0) /*!< ADC dual mode enabled: group injected simultaneous */
  1240. #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) */
  1241. #define LL_ADC_MULTI_DUAL_REG_SIM_INJ_SIM ( ADC_CCR_DUAL_0) /*!< ADC dual mode enabled: Combined group regular simultaneous + group injected simultaneous */
  1242. #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 */
  1243. #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 */
  1244. /**
  1245. * @}
  1246. */
  1247. /** @defgroup ADC_LL_EC_MULTI_DMA_TRANSFER Multimode - DMA transfer
  1248. * @{
  1249. */
  1250. #define LL_ADC_MULTI_REG_DMA_EACH_ADC ((uint32_t)0x00000000U) /*!< ADC multimode group regular conversions are transferred by DMA: each ADC uses its own DMA channel, with its individual DMA transfer settings */
  1251. #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 */
  1252. #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 */
  1253. #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 */
  1254. #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 */
  1255. /**
  1256. * @}
  1257. */
  1258. /** @defgroup ADC_LL_EC_MULTI_TWOSMP_DELAY Multimode - Delay between two sampling phases
  1259. * @{
  1260. */
  1261. #define LL_ADC_MULTI_TWOSMP_DELAY_1CYCLE ((uint32_t)0x00000000U) /*!< ADC multimode delay between two sampling phases: 1 ADC clock cycle */
  1262. #define LL_ADC_MULTI_TWOSMP_DELAY_2CYCLES ( ADC_CCR_DELAY_0) /*!< ADC multimode delay between two sampling phases: 2 ADC clock cycles */
  1263. #define LL_ADC_MULTI_TWOSMP_DELAY_3CYCLES ( ADC_CCR_DELAY_1 ) /*!< ADC multimode delay between two sampling phases: 3 ADC clock cycles */
  1264. #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 */
  1265. #define LL_ADC_MULTI_TWOSMP_DELAY_5CYCLES ( ADC_CCR_DELAY_2 ) /*!< ADC multimode delay between two sampling phases: 5 ADC clock cycles */
  1266. #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 */
  1267. #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 */
  1268. #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 */
  1269. #define LL_ADC_MULTI_TWOSMP_DELAY_9CYCLES (ADC_CCR_DELAY_3 ) /*!< ADC multimode delay between two sampling phases: 9 ADC clock cycles */
  1270. #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 */
  1271. #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 */
  1272. #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 */
  1273. /**
  1274. * @}
  1275. */
  1276. /** @defgroup ADC_LL_EC_MULTI_MASTER_SLAVE Multimode - ADC master or slave
  1277. * @{
  1278. */
  1279. #define LL_ADC_MULTI_MASTER ( ADC_CDR_RDATA_MST) /*!< In multimode, selection among several ADC instances: ADC master */
  1280. #define LL_ADC_MULTI_SLAVE (ADC_CDR_RDATA_SLV ) /*!< In multimode, selection among several ADC instances: ADC slave */
  1281. #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 */
  1282. /**
  1283. * @}
  1284. */
  1285. #endif /* ADC_MULTIMODE_SUPPORT */
  1286. /** @defgroup ADC_LL_EC_HW_DELAYS Definitions of ADC hardware constraints delays
  1287. * @note Only ADC IP HW delays are defined in ADC LL driver driver,
  1288. * not timeout values.
  1289. * For details on delays values, refer to descriptions in source code
  1290. * above each literal definition.
  1291. * @{
  1292. */
  1293. /* Note: Only ADC IP HW delays are defined in ADC LL driver driver, */
  1294. /* not timeout values. */
  1295. /* Timeout values for ADC operations are dependent to device clock */
  1296. /* configuration (system clock versus ADC clock), */
  1297. /* and therefore must be defined in user application. */
  1298. /* Indications for estimation of ADC timeout delays, for this */
  1299. /* STM32 serie: */
  1300. /* - ADC calibration time: maximum delay is 112/fADC. */
  1301. /* (refer to device datasheet, parameter "tCAL") */
  1302. /* - ADC enable time: maximum delay is 1 conversion cycle. */
  1303. /* (refer to device datasheet, parameter "tSTAB") */
  1304. /* - ADC disable time: maximum delay should be a few ADC clock cycles */
  1305. /* - ADC stop conversion time: maximum delay should be a few ADC clock */
  1306. /* cycles */
  1307. /* - ADC conversion time: duration depending on ADC clock and ADC */
  1308. /* configuration. */
  1309. /* (refer to device reference manual, section "Timing") */
  1310. /* Delay for ADC stabilization time (ADC voltage regulator start-up time) */
  1311. /* Delay set to maximum value (refer to device datasheet, */
  1312. /* parameter "tADCVREG_STUP"). */
  1313. /* Unit: us */
  1314. #define LL_ADC_DELAY_INTERNAL_REGUL_STAB_US ((uint32_t) 10U) /*!< Delay for ADC stabilization time (ADC voltage regulator start-up time) */
  1315. /* Delay for internal voltage reference stabilization time. */
  1316. /* Delay set to maximum value (refer to device datasheet, */
  1317. /* parameter "tstart_vrefint"). */
  1318. /* Unit: us */
  1319. #define LL_ADC_DELAY_VREFINT_STAB_US ((uint32_t) 12U) /*!< Delay for internal voltage reference stabilization time */
  1320. /* Delay for temperature sensor stabilization time. */
  1321. /* Literal set to maximum value (refer to device datasheet, */
  1322. /* parameter "tSTART"). */
  1323. /* Unit: us */
  1324. #define LL_ADC_DELAY_TEMPSENSOR_STAB_US ((uint32_t) 120U) /*!< Delay for temperature sensor stabilization time */
  1325. /* Delay required between ADC end of calibration and ADC enable. */
  1326. /* Note: On this STM32 serie, a minimum number of ADC clock cycles */
  1327. /* are required between ADC end of calibration and ADC enable. */
  1328. /* Wait time can be computed in user application by waiting for the */
  1329. /* equivalent number of CPU cycles, by taking into account */
  1330. /* ratio of CPU clock versus ADC clock prescalers. */
  1331. /* Unit: ADC clock cycles. */
  1332. #define LL_ADC_DELAY_CALIB_ENABLE_ADC_CYCLES ((uint32_t) 4U) /*!< Delay required between ADC end of calibration and ADC enable */
  1333. /**
  1334. * @}
  1335. */
  1336. /**
  1337. * @}
  1338. */
  1339. /* Exported macro ------------------------------------------------------------*/
  1340. /** @defgroup ADC_LL_Exported_Macros ADC Exported Macros
  1341. * @{
  1342. */
  1343. /** @defgroup ADC_LL_EM_WRITE_READ Common write and read registers Macros
  1344. * @{
  1345. */
  1346. /**
  1347. * @brief Write a value in ADC register
  1348. * @param __INSTANCE__ ADC Instance
  1349. * @param __REG__ Register to be written
  1350. * @param __VALUE__ Value to be written in the register
  1351. * @retval None
  1352. */
  1353. #define LL_ADC_WriteReg(__INSTANCE__, __REG__, __VALUE__) WRITE_REG(__INSTANCE__->__REG__, (__VALUE__))
  1354. /**
  1355. * @brief Read a value in ADC register
  1356. * @param __INSTANCE__ ADC Instance
  1357. * @param __REG__ Register to be read
  1358. * @retval Register value
  1359. */
  1360. #define LL_ADC_ReadReg(__INSTANCE__, __REG__) READ_REG(__INSTANCE__->__REG__)
  1361. /**
  1362. * @}
  1363. */
  1364. /** @defgroup ADC_LL_EM_HELPER_MACRO ADC helper macro
  1365. * @{
  1366. */
  1367. /**
  1368. * @brief Helper macro to get ADC channel number in decimal format
  1369. * from literals LL_ADC_CHANNEL_x.
  1370. * @note Example:
  1371. * __LL_ADC_CHANNEL_TO_DECIMAL_NB(LL_ADC_CHANNEL_4)
  1372. * will return decimal number "4".
  1373. * @note The input can be a value from functions where a channel
  1374. * number is returned, either defined with number
  1375. * or with bitfield (only one bit must be set).
  1376. * @param __CHANNEL__ This parameter can be one of the following values:
  1377. * @arg @ref LL_ADC_CHANNEL_0
  1378. * @arg @ref LL_ADC_CHANNEL_1
  1379. * @arg @ref LL_ADC_CHANNEL_2
  1380. * @arg @ref LL_ADC_CHANNEL_3
  1381. * @arg @ref LL_ADC_CHANNEL_4
  1382. * @arg @ref LL_ADC_CHANNEL_5
  1383. * @arg @ref LL_ADC_CHANNEL_6
  1384. * @arg @ref LL_ADC_CHANNEL_7
  1385. * @arg @ref LL_ADC_CHANNEL_8
  1386. * @arg @ref LL_ADC_CHANNEL_9
  1387. * @arg @ref LL_ADC_CHANNEL_10
  1388. * @arg @ref LL_ADC_CHANNEL_11
  1389. * @arg @ref LL_ADC_CHANNEL_12
  1390. * @arg @ref LL_ADC_CHANNEL_13
  1391. * @arg @ref LL_ADC_CHANNEL_14
  1392. * @arg @ref LL_ADC_CHANNEL_15
  1393. * @arg @ref LL_ADC_CHANNEL_16
  1394. * @arg @ref LL_ADC_CHANNEL_17
  1395. * @arg @ref LL_ADC_CHANNEL_18
  1396. * @arg @ref LL_ADC_CHANNEL_VREFINT (5)
  1397. * @arg @ref LL_ADC_CHANNEL_TEMPSENSOR (1)
  1398. * @arg @ref LL_ADC_CHANNEL_VBAT (1)
  1399. * @arg @ref LL_ADC_CHANNEL_VOPAMP1 (1)
  1400. * @arg @ref LL_ADC_CHANNEL_VOPAMP2 (2)
  1401. * @arg @ref LL_ADC_CHANNEL_VOPAMP3 (3)
  1402. * @arg @ref LL_ADC_CHANNEL_VOPAMP4 (4)
  1403. *
  1404. * (1) On STM32F3, parameter available only on ADC instance: ADC1.\n
  1405. * (2) On STM32F3, parameter available only on ADC instance: ADC2.\n
  1406. * (3) On STM32F3, parameter available only on ADC instance: ADC3.\n
  1407. * (4) On STM32F3, parameter available only on ADC instances: ADC4.\n
  1408. * (5) On STM32F3, ADC channel available only on all ADC instances, but
  1409. * only one ADC instance is allowed to be connected to VrefInt at the same time.
  1410. * @retval Value between Min_Data=0 and Max_Data=18
  1411. */
  1412. #define __LL_ADC_CHANNEL_TO_DECIMAL_NB(__CHANNEL__) \
  1413. ((((__CHANNEL__) & ADC_CHANNEL_ID_BITFIELD_MASK) == 0U) \
  1414. ? ( \
  1415. ((__CHANNEL__) & ADC_CHANNEL_ID_NUMBER_MASK) >> ADC_CHANNEL_ID_NUMBER_BITOFFSET_POS \
  1416. ) \
  1417. : \
  1418. ( \
  1419. POSITION_VAL((__CHANNEL__)) \
  1420. ) \
  1421. )
  1422. /**
  1423. * @brief Helper macro to get ADC channel in literal format LL_ADC_CHANNEL_x
  1424. * from number in decimal format.
  1425. * @note Example:
  1426. * __LL_ADC_DECIMAL_NB_TO_CHANNEL(4)
  1427. * will return a data equivalent to "LL_ADC_CHANNEL_4".
  1428. * @param __DECIMAL_NB__ Value between Min_Data=0 and Max_Data=18
  1429. * @retval Returned value can be one of the following values:
  1430. * @arg @ref LL_ADC_CHANNEL_0
  1431. * @arg @ref LL_ADC_CHANNEL_1
  1432. * @arg @ref LL_ADC_CHANNEL_2
  1433. * @arg @ref LL_ADC_CHANNEL_3
  1434. * @arg @ref LL_ADC_CHANNEL_4
  1435. * @arg @ref LL_ADC_CHANNEL_5
  1436. * @arg @ref LL_ADC_CHANNEL_6
  1437. * @arg @ref LL_ADC_CHANNEL_7
  1438. * @arg @ref LL_ADC_CHANNEL_8
  1439. * @arg @ref LL_ADC_CHANNEL_9
  1440. * @arg @ref LL_ADC_CHANNEL_10
  1441. * @arg @ref LL_ADC_CHANNEL_11
  1442. * @arg @ref LL_ADC_CHANNEL_12
  1443. * @arg @ref LL_ADC_CHANNEL_13
  1444. * @arg @ref LL_ADC_CHANNEL_14
  1445. * @arg @ref LL_ADC_CHANNEL_15
  1446. * @arg @ref LL_ADC_CHANNEL_16
  1447. * @arg @ref LL_ADC_CHANNEL_17
  1448. * @arg @ref LL_ADC_CHANNEL_18
  1449. * @arg @ref LL_ADC_CHANNEL_VREFINT (5)
  1450. * @arg @ref LL_ADC_CHANNEL_TEMPSENSOR (1)
  1451. * @arg @ref LL_ADC_CHANNEL_VBAT (1)
  1452. * @arg @ref LL_ADC_CHANNEL_VOPAMP1 (1)
  1453. * @arg @ref LL_ADC_CHANNEL_VOPAMP2 (2)
  1454. * @arg @ref LL_ADC_CHANNEL_VOPAMP3 (3)
  1455. * @arg @ref LL_ADC_CHANNEL_VOPAMP4 (4)
  1456. *
  1457. * (1) On STM32F3, parameter available only on ADC instance: ADC1.\n
  1458. * (2) On STM32F3, parameter available only on ADC instance: ADC2.\n
  1459. * (3) On STM32F3, parameter available only on ADC instance: ADC3.\n
  1460. * (4) On STM32F3, parameter available only on ADC instances: ADC4.\n
  1461. * (5) On STM32F3, ADC channel available only on all ADC instances, but
  1462. * only one ADC instance is allowed to be connected to VrefInt at the same time.\n
  1463. * (1, 2, 3, 4, 5) For ADC channel read back from ADC register,
  1464. * comparison with internal channel parameter to be done
  1465. * using helper macro @ref __LL_ADC_CHANNEL_INTERNAL_TO_EXTERNAL().
  1466. */
  1467. #define __LL_ADC_DECIMAL_NB_TO_CHANNEL(__DECIMAL_NB__) \
  1468. (((__DECIMAL_NB__) <= 9U) \
  1469. ? ( \
  1470. ((__DECIMAL_NB__) << ADC_CHANNEL_ID_NUMBER_BITOFFSET_POS) | \
  1471. (ADC_AWD2CR_AWD2CH_0 << (__DECIMAL_NB__)) | \
  1472. (ADC_SMPR1_REGOFFSET | (((uint32_t) (3U * (__DECIMAL_NB__))) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) \
  1473. ) \
  1474. : \
  1475. ( \
  1476. ((__DECIMAL_NB__) << ADC_CHANNEL_ID_NUMBER_BITOFFSET_POS) | \
  1477. (ADC_AWD2CR_AWD2CH_0 << (__DECIMAL_NB__)) | \
  1478. (ADC_SMPR2_REGOFFSET | (((uint32_t) (3U * ((__DECIMAL_NB__) - 10U))) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) \
  1479. ) \
  1480. )
  1481. /**
  1482. * @brief Helper macro to determine whether the selected channel
  1483. * corresponds to literal definitions of driver.
  1484. * @note The different literal definitions of ADC channels are:
  1485. * - ADC internal channel:
  1486. * LL_ADC_CHANNEL_VREFINT, LL_ADC_CHANNEL_TEMPSENSOR, ...
  1487. * - ADC external channel (channel connected to a GPIO pin):
  1488. * LL_ADC_CHANNEL_1, LL_ADC_CHANNEL_2, ...
  1489. * @note The channel parameter must be a value defined from literal
  1490. * definition of a ADC internal channel (LL_ADC_CHANNEL_VREFINT,
  1491. * LL_ADC_CHANNEL_TEMPSENSOR, ...),
  1492. * ADC external channel (LL_ADC_CHANNEL_1, LL_ADC_CHANNEL_2, ...),
  1493. * must not be a value from functions where a channel number is
  1494. * returned from ADC registers,
  1495. * because internal and external channels share the same channel
  1496. * number in ADC registers. The differentiation is made only with
  1497. * parameters definitions of driver.
  1498. * @param __CHANNEL__ This parameter can be one of the following values:
  1499. * @arg @ref LL_ADC_CHANNEL_0
  1500. * @arg @ref LL_ADC_CHANNEL_1
  1501. * @arg @ref LL_ADC_CHANNEL_2
  1502. * @arg @ref LL_ADC_CHANNEL_3
  1503. * @arg @ref LL_ADC_CHANNEL_4
  1504. * @arg @ref LL_ADC_CHANNEL_5
  1505. * @arg @ref LL_ADC_CHANNEL_6
  1506. * @arg @ref LL_ADC_CHANNEL_7
  1507. * @arg @ref LL_ADC_CHANNEL_8
  1508. * @arg @ref LL_ADC_CHANNEL_9
  1509. * @arg @ref LL_ADC_CHANNEL_10
  1510. * @arg @ref LL_ADC_CHANNEL_11
  1511. * @arg @ref LL_ADC_CHANNEL_12
  1512. * @arg @ref LL_ADC_CHANNEL_13
  1513. * @arg @ref LL_ADC_CHANNEL_14
  1514. * @arg @ref LL_ADC_CHANNEL_15
  1515. * @arg @ref LL_ADC_CHANNEL_16
  1516. * @arg @ref LL_ADC_CHANNEL_17
  1517. * @arg @ref LL_ADC_CHANNEL_18
  1518. * @arg @ref LL_ADC_CHANNEL_VREFINT (5)
  1519. * @arg @ref LL_ADC_CHANNEL_TEMPSENSOR (1)
  1520. * @arg @ref LL_ADC_CHANNEL_VBAT (1)
  1521. * @arg @ref LL_ADC_CHANNEL_VOPAMP1 (1)
  1522. * @arg @ref LL_ADC_CHANNEL_VOPAMP2 (2)
  1523. * @arg @ref LL_ADC_CHANNEL_VOPAMP3 (3)
  1524. * @arg @ref LL_ADC_CHANNEL_VOPAMP4 (4)
  1525. *
  1526. * (1) On STM32F3, parameter available only on ADC instance: ADC1.\n
  1527. * (2) On STM32F3, parameter available only on ADC instance: ADC2.\n
  1528. * (3) On STM32F3, parameter available only on ADC instance: ADC3.\n
  1529. * (4) On STM32F3, parameter available only on ADC instances: ADC4.\n
  1530. * (5) On STM32F3, ADC channel available only on all ADC instances, but
  1531. * only one ADC instance is allowed to be connected to VrefInt at the same time.
  1532. * @retval Value "0" if the channel corresponds to a parameter definition of a ADC external channel (channel connected to a GPIO pin).
  1533. * Value "1" if the channel corresponds to a parameter definition of a ADC internal channel.
  1534. */
  1535. #define __LL_ADC_IS_CHANNEL_INTERNAL(__CHANNEL__) \
  1536. (((__CHANNEL__) & ADC_CHANNEL_ID_INTERNAL_CH_MASK) != 0U)
  1537. /**
  1538. * @brief Helper macro to convert a channel defined from parameter
  1539. * definition of a ADC internal channel (LL_ADC_CHANNEL_VREFINT,
  1540. * LL_ADC_CHANNEL_TEMPSENSOR, ...),
  1541. * to its equivalent parameter definition of a ADC external channel
  1542. * (LL_ADC_CHANNEL_1, LL_ADC_CHANNEL_2, ...).
  1543. * @note The channel parameter can be, additionally to a value
  1544. * defined from parameter definition of a ADC internal channel
  1545. * (LL_ADC_CHANNEL_VREFINT, LL_ADC_CHANNEL_TEMPSENSOR, ...),
  1546. * a value defined from parameter definition of
  1547. * ADC external channel (LL_ADC_CHANNEL_1, LL_ADC_CHANNEL_2, ...)
  1548. * or a value from functions where a channel number is returned
  1549. * from ADC registers.
  1550. * @param __CHANNEL__ This parameter can be one of the following values:
  1551. * @arg @ref LL_ADC_CHANNEL_0
  1552. * @arg @ref LL_ADC_CHANNEL_1
  1553. * @arg @ref LL_ADC_CHANNEL_2
  1554. * @arg @ref LL_ADC_CHANNEL_3
  1555. * @arg @ref LL_ADC_CHANNEL_4
  1556. * @arg @ref LL_ADC_CHANNEL_5
  1557. * @arg @ref LL_ADC_CHANNEL_6
  1558. * @arg @ref LL_ADC_CHANNEL_7
  1559. * @arg @ref LL_ADC_CHANNEL_8
  1560. * @arg @ref LL_ADC_CHANNEL_9
  1561. * @arg @ref LL_ADC_CHANNEL_10
  1562. * @arg @ref LL_ADC_CHANNEL_11
  1563. * @arg @ref LL_ADC_CHANNEL_12
  1564. * @arg @ref LL_ADC_CHANNEL_13
  1565. * @arg @ref LL_ADC_CHANNEL_14
  1566. * @arg @ref LL_ADC_CHANNEL_15
  1567. * @arg @ref LL_ADC_CHANNEL_16
  1568. * @arg @ref LL_ADC_CHANNEL_17
  1569. * @arg @ref LL_ADC_CHANNEL_18
  1570. * @arg @ref LL_ADC_CHANNEL_VREFINT (5)
  1571. * @arg @ref LL_ADC_CHANNEL_TEMPSENSOR (1)
  1572. * @arg @ref LL_ADC_CHANNEL_VBAT (1)
  1573. * @arg @ref LL_ADC_CHANNEL_VOPAMP1 (1)
  1574. * @arg @ref LL_ADC_CHANNEL_VOPAMP2 (2)
  1575. * @arg @ref LL_ADC_CHANNEL_VOPAMP3 (3)
  1576. * @arg @ref LL_ADC_CHANNEL_VOPAMP4 (4)
  1577. *
  1578. * (1) On STM32F3, parameter available only on ADC instance: ADC1.\n
  1579. * (2) On STM32F3, parameter available only on ADC instance: ADC2.\n
  1580. * (3) On STM32F3, parameter available only on ADC instance: ADC3.\n
  1581. * (4) On STM32F3, parameter available only on ADC instances: ADC4.\n
  1582. * (5) On STM32F3, ADC channel available only on all ADC instances, but
  1583. * only one ADC instance is allowed to be connected to VrefInt at the same time.
  1584. * @retval Returned value can be one of the following values:
  1585. * @arg @ref LL_ADC_CHANNEL_0
  1586. * @arg @ref LL_ADC_CHANNEL_1
  1587. * @arg @ref LL_ADC_CHANNEL_2
  1588. * @arg @ref LL_ADC_CHANNEL_3
  1589. * @arg @ref LL_ADC_CHANNEL_4
  1590. * @arg @ref LL_ADC_CHANNEL_5
  1591. * @arg @ref LL_ADC_CHANNEL_6
  1592. * @arg @ref LL_ADC_CHANNEL_7
  1593. * @arg @ref LL_ADC_CHANNEL_8
  1594. * @arg @ref LL_ADC_CHANNEL_9
  1595. * @arg @ref LL_ADC_CHANNEL_10
  1596. * @arg @ref LL_ADC_CHANNEL_11
  1597. * @arg @ref LL_ADC_CHANNEL_12
  1598. * @arg @ref LL_ADC_CHANNEL_13
  1599. * @arg @ref LL_ADC_CHANNEL_14
  1600. * @arg @ref LL_ADC_CHANNEL_15
  1601. * @arg @ref LL_ADC_CHANNEL_16
  1602. * @arg @ref LL_ADC_CHANNEL_17
  1603. * @arg @ref LL_ADC_CHANNEL_18
  1604. */
  1605. #define __LL_ADC_CHANNEL_INTERNAL_TO_EXTERNAL(__CHANNEL__) \
  1606. ((__CHANNEL__) & ~ADC_CHANNEL_ID_INTERNAL_CH_MASK)
  1607. /**
  1608. * @brief Helper macro to determine whether the internal channel
  1609. * selected is available on the ADC instance selected.
  1610. * @note The channel parameter must be a value defined from parameter
  1611. * definition of a ADC internal channel (LL_ADC_CHANNEL_VREFINT,
  1612. * LL_ADC_CHANNEL_TEMPSENSOR, ...),
  1613. * must not be a value defined from parameter definition of
  1614. * ADC external channel (LL_ADC_CHANNEL_1, LL_ADC_CHANNEL_2, ...)
  1615. * or a value from functions where a channel number is
  1616. * returned from ADC registers,
  1617. * because internal and external channels share the same channel
  1618. * number in ADC registers. The differentiation is made only with
  1619. * parameters definitions of driver.
  1620. * @param __ADC_INSTANCE__ ADC instance
  1621. * @param __CHANNEL__ This parameter can be one of the following values:
  1622. * @arg @ref LL_ADC_CHANNEL_VREFINT (5)
  1623. * @arg @ref LL_ADC_CHANNEL_TEMPSENSOR (1)
  1624. * @arg @ref LL_ADC_CHANNEL_VBAT (1)
  1625. * @arg @ref LL_ADC_CHANNEL_VOPAMP1 (1)
  1626. * @arg @ref LL_ADC_CHANNEL_VOPAMP2 (2)
  1627. * @arg @ref LL_ADC_CHANNEL_VOPAMP3 (3)
  1628. * @arg @ref LL_ADC_CHANNEL_VOPAMP4 (4)
  1629. *
  1630. * (1) On STM32F3, parameter available only on ADC instance: ADC1.\n
  1631. * (2) On STM32F3, parameter available only on ADC instance: ADC2.\n
  1632. * (3) On STM32F3, parameter available only on ADC instance: ADC3.\n
  1633. * (4) On STM32F3, parameter available only on ADC instances: ADC4.\n
  1634. * (5) On STM32F3, ADC channel available only on all ADC instances, but
  1635. * only one ADC instance is allowed to be connected to VrefInt at the same time.
  1636. * @retval Value "0" if the internal channel selected is not available on the ADC instance selected.
  1637. * Value "1" if the internal channel selected is available on the ADC instance selected.
  1638. */
  1639. #if defined (ADC1) && defined (ADC2) && defined (ADC3) && defined (ADC4)
  1640. #define __LL_ADC_IS_CHANNEL_INTERNAL_AVAILABLE(__ADC_INSTANCE__, __CHANNEL__) \
  1641. (((__ADC_INSTANCE__) == ADC1) \
  1642. ? ( \
  1643. ((__CHANNEL__) == LL_ADC_CHANNEL_VREFINT) || \
  1644. ((__CHANNEL__) == LL_ADC_CHANNEL_TEMPSENSOR) || \
  1645. ((__CHANNEL__) == LL_ADC_CHANNEL_VBAT) || \
  1646. ((__CHANNEL__) == LL_ADC_CHANNEL_VOPAMP1) \
  1647. ) \
  1648. : \
  1649. ((__ADC_INSTANCE__) == ADC2) \
  1650. ? ( \
  1651. ((__CHANNEL__) == LL_ADC_CHANNEL_VREFINT) || \
  1652. ((__CHANNEL__) == LL_ADC_CHANNEL_VOPAMP2) \
  1653. ) \
  1654. : \
  1655. ((__ADC_INSTANCE__) == ADC3) \
  1656. ? ( \
  1657. ((__CHANNEL__) == LL_ADC_CHANNEL_VREFINT) || \
  1658. ((__CHANNEL__) == LL_ADC_CHANNEL_VOPAMP3) \
  1659. ) \
  1660. : \
  1661. ((__ADC_INSTANCE__) == ADC4) \
  1662. ? ( \
  1663. ((__CHANNEL__) == LL_ADC_CHANNEL_VREFINT) || \
  1664. ((__CHANNEL__) == LL_ADC_CHANNEL_VOPAMP4) \
  1665. ) \
  1666. : \
  1667. (0U) \
  1668. )
  1669. #elif defined (ADC1) && defined (ADC2)
  1670. #if defined(OPAMP1_CSR_OPAMP1EN) && defined(OPAMP2_CSR_OPAMP2EN)
  1671. #define __LL_ADC_IS_CHANNEL_INTERNAL_AVAILABLE(__ADC_INSTANCE__, __CHANNEL__) \
  1672. (((__ADC_INSTANCE__) == ADC1) \
  1673. ? ( \
  1674. ((__CHANNEL__) == LL_ADC_CHANNEL_VREFINT) || \
  1675. ((__CHANNEL__) == LL_ADC_CHANNEL_TEMPSENSOR) || \
  1676. ((__CHANNEL__) == LL_ADC_CHANNEL_VBAT) || \
  1677. ((__CHANNEL__) == LL_ADC_CHANNEL_VOPAMP1) \
  1678. ) \
  1679. : \
  1680. ((__ADC_INSTANCE__) == ADC2) \
  1681. ? ( \
  1682. ((__CHANNEL__) == LL_ADC_CHANNEL_VREFINT) || \
  1683. ((__CHANNEL__) == LL_ADC_CHANNEL_VOPAMP2) \
  1684. ) \
  1685. : \
  1686. (0U) \
  1687. )
  1688. #elif defined(OPAMP2_CSR_OPAMP2EN)
  1689. #define __LL_ADC_IS_CHANNEL_INTERNAL_AVAILABLE(__ADC_INSTANCE__, __CHANNEL__) \
  1690. (((__ADC_INSTANCE__) == ADC1) \
  1691. ? ( \
  1692. ((__CHANNEL__) == LL_ADC_CHANNEL_VREFINT) || \
  1693. ((__CHANNEL__) == LL_ADC_CHANNEL_TEMPSENSOR) || \
  1694. ((__CHANNEL__) == LL_ADC_CHANNEL_VBAT) \
  1695. ) \
  1696. : \
  1697. ((__ADC_INSTANCE__) == ADC2) \
  1698. ? ( \
  1699. ((__CHANNEL__) == LL_ADC_CHANNEL_VREFINT) || \
  1700. ((__CHANNEL__) == LL_ADC_CHANNEL_VOPAMP2) \
  1701. ) \
  1702. : \
  1703. (0U) \
  1704. )
  1705. #else
  1706. #define __LL_ADC_IS_CHANNEL_INTERNAL_AVAILABLE(__ADC_INSTANCE__, __CHANNEL__) \
  1707. (((__ADC_INSTANCE__) == ADC1) \
  1708. ? ( \
  1709. ((__CHANNEL__) == LL_ADC_CHANNEL_VREFINT) || \
  1710. ((__CHANNEL__) == LL_ADC_CHANNEL_TEMPSENSOR) || \
  1711. ((__CHANNEL__) == LL_ADC_CHANNEL_VBAT) || \
  1712. ((__CHANNEL__) == LL_ADC_CHANNEL_VOPAMP1) \
  1713. ) \
  1714. : \
  1715. ((__ADC_INSTANCE__) == ADC2) \
  1716. ? ( \
  1717. ((__CHANNEL__) == LL_ADC_CHANNEL_VREFINT) \
  1718. ) \
  1719. : \
  1720. (0U) \
  1721. )
  1722. #endif
  1723. #elif defined (ADC1)
  1724. #if defined(OPAMP1_CSR_OPAMP1EN)
  1725. #define __LL_ADC_IS_CHANNEL_INTERNAL_AVAILABLE(__ADC_INSTANCE__, __CHANNEL__) \
  1726. ( \
  1727. ((__CHANNEL__) == LL_ADC_CHANNEL_VREFINT) || \
  1728. ((__CHANNEL__) == LL_ADC_CHANNEL_TEMPSENSOR) || \
  1729. ((__CHANNEL__) == LL_ADC_CHANNEL_VBAT) || \
  1730. ((__CHANNEL__) == LL_ADC_CHANNEL_VOPAMP1) \
  1731. )
  1732. #else
  1733. #define __LL_ADC_IS_CHANNEL_INTERNAL_AVAILABLE(__ADC_INSTANCE__, __CHANNEL__) \
  1734. ( \
  1735. ((__CHANNEL__) == LL_ADC_CHANNEL_VREFINT) || \
  1736. ((__CHANNEL__) == LL_ADC_CHANNEL_TEMPSENSOR) || \
  1737. ((__CHANNEL__) == LL_ADC_CHANNEL_VBAT) \
  1738. )
  1739. #endif
  1740. #endif
  1741. /**
  1742. * @brief Helper macro to define ADC analog watchdog parameter:
  1743. * define a single channel to monitor with analog watchdog
  1744. * from sequencer channel and groups definition.
  1745. * @note To be used with function @ref LL_ADC_SetAnalogWDMonitChannels().
  1746. * Example:
  1747. * LL_ADC_SetAnalogWDMonitChannels(
  1748. * ADC1, LL_ADC_AWD1,
  1749. * __LL_ADC_ANALOGWD_CHANNEL_GROUP(LL_ADC_CHANNEL4, LL_ADC_GROUP_REGULAR))
  1750. * @param __CHANNEL__ This parameter can be one of the following values:
  1751. * @arg @ref LL_ADC_CHANNEL_0
  1752. * @arg @ref LL_ADC_CHANNEL_1
  1753. * @arg @ref LL_ADC_CHANNEL_2
  1754. * @arg @ref LL_ADC_CHANNEL_3
  1755. * @arg @ref LL_ADC_CHANNEL_4
  1756. * @arg @ref LL_ADC_CHANNEL_5
  1757. * @arg @ref LL_ADC_CHANNEL_6
  1758. * @arg @ref LL_ADC_CHANNEL_7
  1759. * @arg @ref LL_ADC_CHANNEL_8
  1760. * @arg @ref LL_ADC_CHANNEL_9
  1761. * @arg @ref LL_ADC_CHANNEL_10
  1762. * @arg @ref LL_ADC_CHANNEL_11
  1763. * @arg @ref LL_ADC_CHANNEL_12
  1764. * @arg @ref LL_ADC_CHANNEL_13
  1765. * @arg @ref LL_ADC_CHANNEL_14
  1766. * @arg @ref LL_ADC_CHANNEL_15
  1767. * @arg @ref LL_ADC_CHANNEL_16
  1768. * @arg @ref LL_ADC_CHANNEL_17
  1769. * @arg @ref LL_ADC_CHANNEL_18
  1770. * @arg @ref LL_ADC_CHANNEL_VREFINT (5)
  1771. * @arg @ref LL_ADC_CHANNEL_TEMPSENSOR (1)
  1772. * @arg @ref LL_ADC_CHANNEL_VBAT (1)
  1773. * @arg @ref LL_ADC_CHANNEL_VOPAMP1 (1)
  1774. * @arg @ref LL_ADC_CHANNEL_VOPAMP2 (2)
  1775. * @arg @ref LL_ADC_CHANNEL_VOPAMP3 (3)
  1776. * @arg @ref LL_ADC_CHANNEL_VOPAMP4 (4)
  1777. *
  1778. * (1) On STM32F3, parameter available only on ADC instance: ADC1.\n
  1779. * (2) On STM32F3, parameter available only on ADC instance: ADC2.\n
  1780. * (3) On STM32F3, parameter available only on ADC instance: ADC3.\n
  1781. * (4) On STM32F3, parameter available only on ADC instances: ADC4.\n
  1782. * (5) On STM32F3, ADC channel available only on all ADC instances, but
  1783. * only one ADC instance is allowed to be connected to VrefInt at the same time.\n
  1784. * (1, 2, 3, 4, 5) For ADC channel read back from ADC register,
  1785. * comparison with internal channel parameter to be done
  1786. * using helper macro @ref __LL_ADC_CHANNEL_INTERNAL_TO_EXTERNAL().
  1787. * @param __GROUP__ This parameter can be one of the following values:
  1788. * @arg @ref LL_ADC_GROUP_REGULAR
  1789. * @arg @ref LL_ADC_GROUP_INJECTED
  1790. * @arg @ref LL_ADC_GROUP_REGULAR_INJECTED
  1791. * @retval Returned value can be one of the following values:
  1792. * @arg @ref LL_ADC_AWD_DISABLE
  1793. * @arg @ref LL_ADC_AWD_ALL_CHANNELS_REG (0)
  1794. * @arg @ref LL_ADC_AWD_ALL_CHANNELS_INJ (0)
  1795. * @arg @ref LL_ADC_AWD_ALL_CHANNELS_REG_INJ
  1796. * @arg @ref LL_ADC_AWD_CHANNEL_0_REG (0)
  1797. * @arg @ref LL_ADC_AWD_CHANNEL_0_INJ (0)
  1798. * @arg @ref LL_ADC_AWD_CHANNEL_0_REG_INJ
  1799. * @arg @ref LL_ADC_AWD_CHANNEL_1_REG (0)
  1800. * @arg @ref LL_ADC_AWD_CHANNEL_1_INJ (0)
  1801. * @arg @ref LL_ADC_AWD_CHANNEL_1_REG_INJ
  1802. * @arg @ref LL_ADC_AWD_CHANNEL_2_REG (0)
  1803. * @arg @ref LL_ADC_AWD_CHANNEL_2_INJ (0)
  1804. * @arg @ref LL_ADC_AWD_CHANNEL_2_REG_INJ
  1805. * @arg @ref LL_ADC_AWD_CHANNEL_3_REG (0)
  1806. * @arg @ref LL_ADC_AWD_CHANNEL_3_INJ (0)
  1807. * @arg @ref LL_ADC_AWD_CHANNEL_3_REG_INJ
  1808. * @arg @ref LL_ADC_AWD_CHANNEL_4_REG (0)
  1809. * @arg @ref LL_ADC_AWD_CHANNEL_4_INJ (0)
  1810. * @arg @ref LL_ADC_AWD_CHANNEL_4_REG_INJ
  1811. * @arg @ref LL_ADC_AWD_CHANNEL_5_REG (0)
  1812. * @arg @ref LL_ADC_AWD_CHANNEL_5_INJ (0)
  1813. * @arg @ref LL_ADC_AWD_CHANNEL_5_REG_INJ
  1814. * @arg @ref LL_ADC_AWD_CHANNEL_6_REG (0)
  1815. * @arg @ref LL_ADC_AWD_CHANNEL_6_INJ (0)
  1816. * @arg @ref LL_ADC_AWD_CHANNEL_6_REG_INJ
  1817. * @arg @ref LL_ADC_AWD_CHANNEL_7_REG (0)
  1818. * @arg @ref LL_ADC_AWD_CHANNEL_7_INJ (0)
  1819. * @arg @ref LL_ADC_AWD_CHANNEL_7_REG_INJ
  1820. * @arg @ref LL_ADC_AWD_CHANNEL_8_REG (0)
  1821. * @arg @ref LL_ADC_AWD_CHANNEL_8_INJ (0)
  1822. * @arg @ref LL_ADC_AWD_CHANNEL_8_REG_INJ
  1823. * @arg @ref LL_ADC_AWD_CHANNEL_9_REG (0)
  1824. * @arg @ref LL_ADC_AWD_CHANNEL_9_INJ (0)
  1825. * @arg @ref LL_ADC_AWD_CHANNEL_9_REG_INJ
  1826. * @arg @ref LL_ADC_AWD_CHANNEL_10_REG (0)
  1827. * @arg @ref LL_ADC_AWD_CHANNEL_10_INJ (0)
  1828. * @arg @ref LL_ADC_AWD_CHANNEL_10_REG_INJ
  1829. * @arg @ref LL_ADC_AWD_CHANNEL_11_REG (0)
  1830. * @arg @ref LL_ADC_AWD_CHANNEL_11_INJ (0)
  1831. * @arg @ref LL_ADC_AWD_CHANNEL_11_REG_INJ
  1832. * @arg @ref LL_ADC_AWD_CHANNEL_12_REG (0)
  1833. * @arg @ref LL_ADC_AWD_CHANNEL_12_INJ (0)
  1834. * @arg @ref LL_ADC_AWD_CHANNEL_12_REG_INJ
  1835. * @arg @ref LL_ADC_AWD_CHANNEL_13_REG (0)
  1836. * @arg @ref LL_ADC_AWD_CHANNEL_13_INJ (0)
  1837. * @arg @ref LL_ADC_AWD_CHANNEL_13_REG_INJ
  1838. * @arg @ref LL_ADC_AWD_CHANNEL_14_REG (0)
  1839. * @arg @ref LL_ADC_AWD_CHANNEL_14_INJ (0)
  1840. * @arg @ref LL_ADC_AWD_CHANNEL_14_REG_INJ
  1841. * @arg @ref LL_ADC_AWD_CHANNEL_15_REG (0)
  1842. * @arg @ref LL_ADC_AWD_CHANNEL_15_INJ (0)
  1843. * @arg @ref LL_ADC_AWD_CHANNEL_15_REG_INJ
  1844. * @arg @ref LL_ADC_AWD_CHANNEL_16_REG (0)
  1845. * @arg @ref LL_ADC_AWD_CHANNEL_16_INJ (0)
  1846. * @arg @ref LL_ADC_AWD_CHANNEL_16_REG_INJ
  1847. * @arg @ref LL_ADC_AWD_CHANNEL_17_REG (0)
  1848. * @arg @ref LL_ADC_AWD_CHANNEL_17_INJ (0)
  1849. * @arg @ref LL_ADC_AWD_CHANNEL_17_REG_INJ
  1850. * @arg @ref LL_ADC_AWD_CHANNEL_18_REG (0)
  1851. * @arg @ref LL_ADC_AWD_CHANNEL_18_INJ (0)
  1852. * @arg @ref LL_ADC_AWD_CHANNEL_18_REG_INJ
  1853. * @arg @ref LL_ADC_AWD_CH_VREFINT_REG (0)(5)
  1854. * @arg @ref LL_ADC_AWD_CH_VREFINT_INJ (0)(5)
  1855. * @arg @ref LL_ADC_AWD_CH_VREFINT_REG_INJ (5)
  1856. * @arg @ref LL_ADC_AWD_CH_TEMPSENSOR_REG (0)(1)
  1857. * @arg @ref LL_ADC_AWD_CH_TEMPSENSOR_INJ (0)(1)
  1858. * @arg @ref LL_ADC_AWD_CH_TEMPSENSOR_REG_INJ (1)
  1859. * @arg @ref LL_ADC_AWD_CH_VBAT_REG (0)(1)
  1860. * @arg @ref LL_ADC_AWD_CH_VBAT_INJ (0)(1)
  1861. * @arg @ref LL_ADC_AWD_CH_VBAT_REG_INJ (1)
  1862. * @arg @ref LL_ADC_AWD_CH_VOPAMP1_REG (0)(1)
  1863. * @arg @ref LL_ADC_AWD_CH_VOPAMP1_INJ (0)(1)
  1864. * @arg @ref LL_ADC_AWD_CH_VOPAMP1_REG_INJ (1)
  1865. * @arg @ref LL_ADC_AWD_CH_VOPAMP2_REG (0)(2)
  1866. * @arg @ref LL_ADC_AWD_CH_VOPAMP2_INJ (0)(2)
  1867. * @arg @ref LL_ADC_AWD_CH_VOPAMP2_REG_INJ (2)
  1868. * @arg @ref LL_ADC_AWD_CH_VOPAMP3_REG (0)(3)
  1869. * @arg @ref LL_ADC_AWD_CH_VOPAMP3_INJ (0)(3)
  1870. * @arg @ref LL_ADC_AWD_CH_VOPAMP3_REG_INJ (3)
  1871. * @arg @ref LL_ADC_AWD_CH_VOPAMP4_REG (0)(4)
  1872. * @arg @ref LL_ADC_AWD_CH_VOPAMP4_INJ (0)(4)
  1873. * @arg @ref LL_ADC_AWD_CH_VOPAMP4_REG_INJ (4)
  1874. *
  1875. * (0) On STM32F3, parameter available only on analog watchdog number: AWD1.\n
  1876. * (1) On STM32F3, parameter available only on ADC instance: ADC1.\n
  1877. * (2) On STM32F3, parameter available only on ADC instance: ADC2.\n
  1878. * (3) On STM32F3, parameter available only on ADC instance: ADC3.\n
  1879. * (4) On STM32F3, parameter available only on ADC instances: ADC4.\n
  1880. * (5) On STM32F3, ADC channel available only on all ADC instances, but
  1881. * only one ADC instance is allowed to be connected to VrefInt at the same time.
  1882. */
  1883. #define __LL_ADC_ANALOGWD_CHANNEL_GROUP(__CHANNEL__, __GROUP__) \
  1884. (((__GROUP__) == LL_ADC_GROUP_REGULAR) \
  1885. ? (((__CHANNEL__) & ADC_CHANNEL_ID_MASK) | ADC_CFGR_AWD1EN | ADC_CFGR_AWD1SGL) \
  1886. : \
  1887. ((__GROUP__) == LL_ADC_GROUP_INJECTED) \
  1888. ? (((__CHANNEL__) & ADC_CHANNEL_ID_MASK) | ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1SGL) \
  1889. : \
  1890. (((__CHANNEL__) & ADC_CHANNEL_ID_MASK) | ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1EN | ADC_CFGR_AWD1SGL) \
  1891. )
  1892. /**
  1893. * @brief Helper macro to set the value of ADC analog watchdog threshold high
  1894. * or low in function of ADC resolution, when ADC resolution is
  1895. * different of 12 bits.
  1896. * @note To be used with function @ref LL_ADC_ConfigAnalogWDThresholds()
  1897. * or @ref LL_ADC_SetAnalogWDThresholds().
  1898. * Example, with a ADC resolution of 8 bits, to set the value of
  1899. * analog watchdog threshold high (on 8 bits):
  1900. * LL_ADC_SetAnalogWDThresholds
  1901. * (< ADCx param >,
  1902. * __LL_ADC_ANALOGWD_SET_THRESHOLD_RESOLUTION(LL_ADC_RESOLUTION_8B, <threshold_value_8_bits>)
  1903. * );
  1904. * @param __ADC_RESOLUTION__ This parameter can be one of the following values:
  1905. * @arg @ref LL_ADC_RESOLUTION_12B
  1906. * @arg @ref LL_ADC_RESOLUTION_10B
  1907. * @arg @ref LL_ADC_RESOLUTION_8B
  1908. * @arg @ref LL_ADC_RESOLUTION_6B
  1909. * @param __AWD_THRESHOLD__ Value between Min_Data=0x000 and Max_Data=0xFFF
  1910. * @retval Value between Min_Data=0x000 and Max_Data=0xFFF
  1911. */
  1912. #define __LL_ADC_ANALOGWD_SET_THRESHOLD_RESOLUTION(__ADC_RESOLUTION__, __AWD_THRESHOLD__) \
  1913. ((__AWD_THRESHOLD__) << ((__ADC_RESOLUTION__) >> (ADC_CFGR_RES_BITOFFSET_POS - 1U )))
  1914. /**
  1915. * @brief Helper macro to get the value of ADC analog watchdog threshold high
  1916. * or low in function of ADC resolution, when ADC resolution is
  1917. * different of 12 bits.
  1918. * @note To be used with function @ref LL_ADC_GetAnalogWDThresholds().
  1919. * Example, with a ADC resolution of 8 bits, to get the value of
  1920. * analog watchdog threshold high (on 8 bits):
  1921. * < threshold_value_6_bits > = __LL_ADC_ANALOGWD_GET_THRESHOLD_RESOLUTION
  1922. * (LL_ADC_RESOLUTION_8B,
  1923. * LL_ADC_GetAnalogWDThresholds(<ADCx param>, LL_ADC_AWD_THRESHOLD_HIGH)
  1924. * );
  1925. * @param __ADC_RESOLUTION__ This parameter can be one of the following values:
  1926. * @arg @ref LL_ADC_RESOLUTION_12B
  1927. * @arg @ref LL_ADC_RESOLUTION_10B
  1928. * @arg @ref LL_ADC_RESOLUTION_8B
  1929. * @arg @ref LL_ADC_RESOLUTION_6B
  1930. * @param __AWD_THRESHOLD_12_BITS__ Value between Min_Data=0x000 and Max_Data=0xFFF
  1931. * @retval Value between Min_Data=0x000 and Max_Data=0xFFF
  1932. */
  1933. #define __LL_ADC_ANALOGWD_GET_THRESHOLD_RESOLUTION(__ADC_RESOLUTION__, __AWD_THRESHOLD_12_BITS__) \
  1934. ((__AWD_THRESHOLD_12_BITS__) >> ((__ADC_RESOLUTION__) >> (ADC_CFGR_RES_BITOFFSET_POS - 1U )))
  1935. /**
  1936. * @brief Helper macro to get the ADC analog watchdog threshold high
  1937. * or low from raw value containing both thresholds concatenated.
  1938. * @note To be used with function @ref LL_ADC_GetAnalogWDThresholds().
  1939. * Example, to get analog watchdog threshold high from the register raw value:
  1940. * __LL_ADC_ANALOGWD_THRESHOLDS_HIGH_LOW(LL_ADC_AWD_THRESHOLD_HIGH, <raw_value_with_both_thresholds>);
  1941. * @param __AWD_THRESHOLD_TYPE__ This parameter can be one of the following values:
  1942. * @arg @ref LL_ADC_AWD_THRESHOLD_HIGH
  1943. * @arg @ref LL_ADC_AWD_THRESHOLD_LOW
  1944. * @param __AWD_THRESHOLDS__ Value between Min_Data=0x00000000 and Max_Data=0xFFFFFFFF
  1945. * @retval Value between Min_Data=0x000 and Max_Data=0xFFF
  1946. */
  1947. #define __LL_ADC_ANALOGWD_THRESHOLDS_HIGH_LOW(__AWD_THRESHOLD_TYPE__, __AWD_THRESHOLDS__) \
  1948. (((__AWD_THRESHOLDS__) >> POSITION_VAL((__AWD_THRESHOLD_TYPE__))) & LL_ADC_AWD_THRESHOLD_LOW)
  1949. /**
  1950. * @brief Helper macro to set the ADC calibration value with both single ended
  1951. * and differential modes calibration factors concatenated.
  1952. * @note To be used with function @ref LL_ADC_SetCalibrationFactor().
  1953. * Example, to set calibration factors single ended to 0x55
  1954. * and differential ended to 0x2A:
  1955. * LL_ADC_SetCalibrationFactor(
  1956. * ADC1,
  1957. * __LL_ADC_CALIB_FACTOR_SINGLE_DIFF(0x55, 0x2A))
  1958. * @param __CALIB_FACTOR_SINGLE_ENDED__ Value between Min_Data=0x00 and Max_Data=0x7F
  1959. * @param __CALIB_FACTOR_DIFFERENTIAL__ Value between Min_Data=0x00 and Max_Data=0x7F
  1960. * @retval Value between Min_Data=0x00000000 and Max_Data=0xFFFFFFFF
  1961. */
  1962. #define __LL_ADC_CALIB_FACTOR_SINGLE_DIFF(__CALIB_FACTOR_SINGLE_ENDED__, __CALIB_FACTOR_DIFFERENTIAL__) \
  1963. (((__CALIB_FACTOR_DIFFERENTIAL__) << POSITION_VAL(ADC_CALFACT_CALFACT_D)) | (__CALIB_FACTOR_SINGLE_ENDED__))
  1964. #if defined(ADC_MULTIMODE_SUPPORT)
  1965. /**
  1966. * @brief Helper macro to get the ADC multimode conversion data of ADC master
  1967. * or ADC slave from raw value with both ADC conversion data concatenated.
  1968. * @note This macro is intended to be used when multimode transfer by DMA
  1969. * is enabled: refer to function @ref LL_ADC_SetMultiDMATransfer().
  1970. * In this case the transferred data need to processed with this macro
  1971. * to separate the conversion data of ADC master and ADC slave.
  1972. * @param __ADC_MULTI_MASTER_SLAVE__ This parameter can be one of the following values:
  1973. * @arg @ref LL_ADC_MULTI_MASTER
  1974. * @arg @ref LL_ADC_MULTI_SLAVE
  1975. * @param __ADC_MULTI_CONV_DATA__ Value between Min_Data=0x000 and Max_Data=0xFFF
  1976. * @retval Value between Min_Data=0x000 and Max_Data=0xFFF
  1977. */
  1978. #define __LL_ADC_MULTI_CONV_DATA_MASTER_SLAVE(__ADC_MULTI_MASTER_SLAVE__, __ADC_MULTI_CONV_DATA__) \
  1979. (((__ADC_MULTI_CONV_DATA__) >> POSITION_VAL((__ADC_MULTI_MASTER_SLAVE__))) & ADC_CDR_RDATA_MST)
  1980. #endif
  1981. /**
  1982. * @brief Helper macro to select the ADC common instance
  1983. * to which is belonging the selected ADC instance.
  1984. * @note ADC common register instance can be used for:
  1985. * - Set parameters common to several ADC instances
  1986. * - Multimode (for devices with several ADC instances)
  1987. * Refer to functions having argument "ADCxy_COMMON" as parameter.
  1988. * @param __ADCx__ ADC instance
  1989. * @retval ADC common register instance
  1990. */
  1991. #if defined(ADC3) && defined(ADC4)
  1992. #define __LL_ADC_COMMON_INSTANCE(__ADCx__) \
  1993. ((((__ADCx__) == ADC1) || ((__ADCx__) == ADC2)) \
  1994. ? ( \
  1995. (ADC12_COMMON) \
  1996. ) \
  1997. : \
  1998. ( \
  1999. (ADC34_COMMON) \
  2000. ) \
  2001. )
  2002. #elif defined(ADC1) && defined(ADC2)
  2003. #define __LL_ADC_COMMON_INSTANCE(__ADCx__) \
  2004. (ADC12_COMMON)
  2005. #else
  2006. #define __LL_ADC_COMMON_INSTANCE(__ADCx__) \
  2007. (ADC1_COMMON)
  2008. #endif
  2009. /**
  2010. * @brief Helper macro to check if all ADC instances sharing the same
  2011. * ADC common instance are disabled.
  2012. * @note This check is required by functions with setting conditioned to
  2013. * ADC state:
  2014. * All ADC instances of the ADC common group must be disabled.
  2015. * Refer to functions having argument "ADCxy_COMMON" as parameter.
  2016. * @note On devices with only 1 ADC common instance, parameter of this macro
  2017. * is useless and can be ignored (parameter kept for compatibility
  2018. * with devices featuring several ADC common instances).
  2019. * @param __ADCXY_COMMON__ ADC common instance
  2020. * (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() )
  2021. * @retval Value "0" if all ADC instances sharing the same ADC common instance
  2022. * are disabled.
  2023. * Value "1" if at least one ADC instance sharing the same ADC common instance
  2024. * is enabled.
  2025. */
  2026. #if defined(ADC3) && defined(ADC4)
  2027. #define __LL_ADC_IS_ENABLED_ALL_COMMON_INSTANCE(__ADCXY_COMMON__) \
  2028. (((__ADCXY_COMMON__) == ADC12_COMMON) \
  2029. ? ( \
  2030. (LL_ADC_IsEnabled(ADC1) | \
  2031. LL_ADC_IsEnabled(ADC2) ) \
  2032. ) \
  2033. : \
  2034. ( \
  2035. (LL_ADC_IsEnabled(ADC3) | \
  2036. LL_ADC_IsEnabled(ADC4) ) \
  2037. ) \
  2038. )
  2039. #elif defined(ADC1) && defined(ADC2)
  2040. #define __LL_ADC_IS_ENABLED_ALL_COMMON_INSTANCE(__ADCXY_COMMON__) \
  2041. (LL_ADC_IsEnabled(ADC1) | \
  2042. LL_ADC_IsEnabled(ADC2) )
  2043. #else
  2044. #define __LL_ADC_IS_ENABLED_ALL_COMMON_INSTANCE(__ADCXY_COMMON__) \
  2045. LL_ADC_IsEnabled(ADC1)
  2046. #endif
  2047. /**
  2048. * @brief Helper macro to define the ADC conversion data full-scale digital
  2049. * value corresponding to the selected ADC resolution.
  2050. * @note ADC conversion data full-scale corresponds to voltage range
  2051. * determined by analog voltage references Vref+ and Vref-
  2052. * (refer to reference manual).
  2053. * @param __ADC_RESOLUTION__ This parameter can be one of the following values:
  2054. * @arg @ref LL_ADC_RESOLUTION_12B
  2055. * @arg @ref LL_ADC_RESOLUTION_10B
  2056. * @arg @ref LL_ADC_RESOLUTION_8B
  2057. * @arg @ref LL_ADC_RESOLUTION_6B
  2058. * @retval ADC conversion data equivalent voltage value (unit: mVolt)
  2059. */
  2060. #define __LL_ADC_DIGITAL_SCALE(__ADC_RESOLUTION__) \
  2061. (((uint32_t)0xFFFU) >> ((__ADC_RESOLUTION__) >> (ADC_CFGR_RES_BITOFFSET_POS - 1U)))
  2062. /**
  2063. * @brief Helper macro to convert the ADC conversion data from
  2064. * a resolution to another resolution.
  2065. * @param __DATA__ ADC conversion data to be converted
  2066. * @param __ADC_RESOLUTION_CURRENT__ Resolution of to the data to be converted
  2067. * This parameter can be one of the following values:
  2068. * @arg @ref LL_ADC_RESOLUTION_12B
  2069. * @arg @ref LL_ADC_RESOLUTION_10B
  2070. * @arg @ref LL_ADC_RESOLUTION_8B
  2071. * @arg @ref LL_ADC_RESOLUTION_6B
  2072. * @param __ADC_RESOLUTION_TARGET__ Resolution of the data after conversion
  2073. * This parameter can be one of the following values:
  2074. * @arg @ref LL_ADC_RESOLUTION_12B
  2075. * @arg @ref LL_ADC_RESOLUTION_10B
  2076. * @arg @ref LL_ADC_RESOLUTION_8B
  2077. * @arg @ref LL_ADC_RESOLUTION_6B
  2078. * @retval ADC conversion data to the requested resolution
  2079. */
  2080. #define __LL_ADC_CONVERT_DATA_RESOLUTION(__DATA__,\
  2081. __ADC_RESOLUTION_CURRENT__,\
  2082. __ADC_RESOLUTION_TARGET__) \
  2083. (((__DATA__) \
  2084. << ((__ADC_RESOLUTION_CURRENT__) >> (ADC_CFGR_RES_BITOFFSET_POS - 1U))) \
  2085. >> ((__ADC_RESOLUTION_TARGET__) >> (ADC_CFGR_RES_BITOFFSET_POS - 1U)) \
  2086. )
  2087. /**
  2088. * @brief Helper macro to calculate the voltage (unit: mVolt)
  2089. * corresponding to a ADC conversion data (unit: digital value).
  2090. * @note Analog reference voltage (Vref+) must be either known from
  2091. * user board environment or can be calculated using ADC measurement
  2092. * and ADC helper macro @ref __LL_ADC_CALC_VREFANALOG_VOLTAGE().
  2093. * @param __VREFANALOG_VOLTAGE__ Analog reference voltage (unit: mV)
  2094. * @param __ADC_DATA__ ADC conversion data (resolution 12 bits)
  2095. * (unit: digital value).
  2096. * @param __ADC_RESOLUTION__ This parameter can be one of the following values:
  2097. * @arg @ref LL_ADC_RESOLUTION_12B
  2098. * @arg @ref LL_ADC_RESOLUTION_10B
  2099. * @arg @ref LL_ADC_RESOLUTION_8B
  2100. * @arg @ref LL_ADC_RESOLUTION_6B
  2101. * @retval ADC conversion data equivalent voltage value (unit: mVolt)
  2102. */
  2103. #define __LL_ADC_CALC_DATA_TO_VOLTAGE(__VREFANALOG_VOLTAGE__,\
  2104. __ADC_DATA__,\
  2105. __ADC_RESOLUTION__) \
  2106. ((__ADC_DATA__) * (__VREFANALOG_VOLTAGE__) \
  2107. / __LL_ADC_DIGITAL_SCALE(__ADC_RESOLUTION__) \
  2108. )
  2109. /**
  2110. * @brief Helper macro to calculate analog reference voltage (Vref+)
  2111. * (unit: mVolt) from ADC conversion data of internal voltage
  2112. * reference VrefInt.
  2113. * @note Computation is using VrefInt calibration value
  2114. * stored in system memory for each device during production.
  2115. * @note This voltage depends on user board environment: voltage level
  2116. * connected to pin Vref+.
  2117. * On devices with small package, the pin Vref+ is not present
  2118. * and internally bonded to pin Vdda.
  2119. * @note On this STM32 serie, calibration data of internal voltage reference
  2120. * VrefInt corresponds to a resolution of 12 bits,
  2121. * this is the recommended ADC resolution to convert voltage of
  2122. * internal voltage reference VrefInt.
  2123. * Otherwise, this macro performs the processing to scale
  2124. * ADC conversion data to 12 bits.
  2125. * @param __VREFINT_ADC_DATA__ ADC conversion data (resolution 12 bits)
  2126. * of internal voltage reference VrefInt (unit: digital value).
  2127. * @param __ADC_RESOLUTION__ This parameter can be one of the following values:
  2128. * @arg @ref LL_ADC_RESOLUTION_12B
  2129. * @arg @ref LL_ADC_RESOLUTION_10B
  2130. * @arg @ref LL_ADC_RESOLUTION_8B
  2131. * @arg @ref LL_ADC_RESOLUTION_6B
  2132. * @retval Analog reference voltage (unit: mV)
  2133. */
  2134. #define __LL_ADC_CALC_VREFANALOG_VOLTAGE(__VREFINT_ADC_DATA__,\
  2135. __ADC_RESOLUTION__) \
  2136. (((uint32_t)(*VREFINT_CAL_ADDR) * VREFINT_CAL_VREF) \
  2137. / __LL_ADC_CONVERT_DATA_RESOLUTION((__VREFINT_ADC_DATA__), \
  2138. (__ADC_RESOLUTION__), \
  2139. LL_ADC_RESOLUTION_12B) \
  2140. )
  2141. /**
  2142. * @brief Helper macro to calculate the temperature (unit: degree Celsius)
  2143. * from ADC conversion data of internal temperature sensor.
  2144. * @note Computation is using temperature sensor calibration values
  2145. * stored in system memory for each device during production.
  2146. * @note Calculation formula:
  2147. * Temperature = ((TS_ADC_DATA - TS_CAL1)
  2148. * * (TS_CAL2_TEMP - TS_CAL1_TEMP))
  2149. * / (TS_CAL2 - TS_CAL1) + TS_CAL1_TEMP
  2150. * with TS_ADC_DATA = temperature sensor raw data measured by ADC
  2151. * Avg_Slope = (TS_CAL2 - TS_CAL1)
  2152. * / (TS_CAL2_TEMP - TS_CAL1_TEMP)
  2153. * TS_CAL1 = equivalent TS_ADC_DATA at temperature
  2154. * TEMP_DEGC_CAL1 (calibrated in factory)
  2155. * TS_CAL2 = equivalent TS_ADC_DATA at temperature
  2156. * TEMP_DEGC_CAL2 (calibrated in factory)
  2157. * Caution: Calculation relevancy under reserve that calibration
  2158. * parameters are correct (address and data).
  2159. * To calculate temperature using temperature sensor
  2160. * datasheet typical values (generic values less, therefore
  2161. * less accurate than calibrated values),
  2162. * use helper macro @ref __LL_ADC_CALC_TEMPERATURE_TYP_PARAMS().
  2163. * @note As calculation input, the analog reference voltage (Vref+) must be
  2164. * defined as it impacts the ADC LSB equivalent voltage.
  2165. * @note Analog reference voltage (Vref+) must be either known from
  2166. * user board environment or can be calculated using ADC measurement
  2167. * and ADC helper macro @ref __LL_ADC_CALC_VREFANALOG_VOLTAGE().
  2168. * @note On this STM32 serie, calibration data of temperature sensor
  2169. * corresponds to a resolution of 12 bits,
  2170. * this is the recommended ADC resolution to convert voltage of
  2171. * temperature sensor.
  2172. * Otherwise, this macro performs the processing to scale
  2173. * ADC conversion data to 12 bits.
  2174. * @param __VREFANALOG_VOLTAGE__ Analog reference voltage (unit: mV)
  2175. * @param __TEMPSENSOR_ADC_DATA__ ADC conversion data of internal
  2176. * temperature sensor (unit: digital value).
  2177. * @param __ADC_RESOLUTION__ ADC resolution at which internal temperature
  2178. * sensor voltage has been measured.
  2179. * This parameter can be one of the following values:
  2180. * @arg @ref LL_ADC_RESOLUTION_12B
  2181. * @arg @ref LL_ADC_RESOLUTION_10B
  2182. * @arg @ref LL_ADC_RESOLUTION_8B
  2183. * @arg @ref LL_ADC_RESOLUTION_6B
  2184. * @retval Temperature (unit: degree Celsius)
  2185. */
  2186. #define __LL_ADC_CALC_TEMPERATURE(__VREFANALOG_VOLTAGE__,\
  2187. __TEMPSENSOR_ADC_DATA__,\
  2188. __ADC_RESOLUTION__) \
  2189. (((( ((int32_t)((__LL_ADC_CONVERT_DATA_RESOLUTION((__TEMPSENSOR_ADC_DATA__), \
  2190. (__ADC_RESOLUTION__), \
  2191. LL_ADC_RESOLUTION_12B) \
  2192. * (__VREFANALOG_VOLTAGE__)) \
  2193. / TEMPSENSOR_CAL_VREFANALOG) \
  2194. - (int32_t) *TEMPSENSOR_CAL1_ADDR) \
  2195. ) * (int32_t)(TEMPSENSOR_CAL2_TEMP - TEMPSENSOR_CAL1_TEMP) \
  2196. ) / (int32_t)((int32_t)*TEMPSENSOR_CAL2_ADDR - (int32_t)*TEMPSENSOR_CAL1_ADDR) \
  2197. ) + TEMPSENSOR_CAL1_TEMP \
  2198. )
  2199. /**
  2200. * @brief Helper macro to calculate the temperature (unit: degree Celsius)
  2201. * from ADC conversion data of internal temperature sensor.
  2202. * @note Computation is using temperature sensor typical values
  2203. * (refer to device datasheet).
  2204. * @note Calculation formula:
  2205. * Temperature = (TS_TYP_CALx_VOLT(uV) - TS_ADC_DATA * Conversion_uV)
  2206. * / Avg_Slope + CALx_TEMP
  2207. * with TS_ADC_DATA = temperature sensor raw data measured by ADC
  2208. * (unit: digital value)
  2209. * Avg_Slope = temperature sensor slope
  2210. * (unit: uV/Degree Celsius)
  2211. * TS_TYP_CALx_VOLT = temperature sensor digital value at
  2212. * temperature CALx_TEMP (unit: mV)
  2213. * Caution: Calculation relevancy under reserve the temperature sensor
  2214. * of the current device has characteristics in line with
  2215. * datasheet typical values.
  2216. * If temperature sensor calibration values are available on
  2217. * on this device (presence of macro __LL_ADC_CALC_TEMPERATURE()),
  2218. * temperature calculation will be more accurate using
  2219. * helper macro @ref __LL_ADC_CALC_TEMPERATURE().
  2220. * @note As calculation input, the analog reference voltage (Vref+) must be
  2221. * defined as it impacts the ADC LSB equivalent voltage.
  2222. * @note Analog reference voltage (Vref+) must be either known from
  2223. * user board environment or can be calculated using ADC measurement
  2224. * and ADC helper macro @ref __LL_ADC_CALC_VREFANALOG_VOLTAGE().
  2225. * @note ADC measurement data must correspond to a resolution of 12bits
  2226. * (full scale digital value 4095). If not the case, the data must be
  2227. * preliminarily rescaled to an equivalent resolution of 12 bits.
  2228. * @param __TEMPSENSOR_TYP_AVGSLOPE__ Device datasheet data: Temperature sensor slope typical value (unit: uV/DegCelsius).
  2229. * On STM32F3, refer to device datasheet parameter "Avg_Slope".
  2230. * @param __TEMPSENSOR_TYP_CALX_V__ Device datasheet data: Temperature sensor voltage typical value (at temperature and Vref+ defined in parameters below) (unit: mV).
  2231. * On STM32F3, refer to device datasheet parameter "V25" (corresponding to TS_CAL1).
  2232. * @param __TEMPSENSOR_CALX_TEMP__ Device datasheet data: Temperature at which temperature sensor voltage (see parameter above) is corresponding (unit: mV)
  2233. * @param __VREFANALOG_VOLTAGE__ Analog voltage reference (Vref+) voltage (unit: mV)
  2234. * @param __TEMPSENSOR_ADC_DATA__ ADC conversion data of internal temperature sensor (unit: digital value).
  2235. * @param __ADC_RESOLUTION__ ADC resolution at which internal temperature sensor voltage has been measured.
  2236. * This parameter can be one of the following values:
  2237. * @arg @ref LL_ADC_RESOLUTION_12B
  2238. * @arg @ref LL_ADC_RESOLUTION_10B
  2239. * @arg @ref LL_ADC_RESOLUTION_8B
  2240. * @arg @ref LL_ADC_RESOLUTION_6B
  2241. * @retval Temperature (unit: degree Celsius)
  2242. */
  2243. #define __LL_ADC_CALC_TEMPERATURE_TYP_PARAMS(__TEMPSENSOR_TYP_AVGSLOPE__,\
  2244. __TEMPSENSOR_TYP_CALX_V__,\
  2245. __TEMPSENSOR_CALX_TEMP__,\
  2246. __VREFANALOG_VOLTAGE__,\
  2247. __TEMPSENSOR_ADC_DATA__,\
  2248. __ADC_RESOLUTION__) \
  2249. ((( ( \
  2250. (int32_t)(((__TEMPSENSOR_TYP_CALX_V__)) \
  2251. * 1000) \
  2252. - \
  2253. (int32_t)((((__TEMPSENSOR_ADC_DATA__) * (__VREFANALOG_VOLTAGE__)) \
  2254. / __LL_ADC_DIGITAL_SCALE(__ADC_RESOLUTION__)) \
  2255. * 1000) \
  2256. ) \
  2257. ) / (__TEMPSENSOR_TYP_AVGSLOPE__) \
  2258. ) + (__TEMPSENSOR_CALX_TEMP__) \
  2259. )
  2260. /**
  2261. * @}
  2262. */
  2263. /**
  2264. * @}
  2265. */
  2266. /* Exported functions --------------------------------------------------------*/
  2267. /** @defgroup ADC_LL_Exported_Functions ADC Exported Functions
  2268. * @{
  2269. */
  2270. /** @defgroup ADC_LL_EF_DMA_Management ADC DMA management
  2271. * @{
  2272. */
  2273. /* Note: LL ADC functions to set DMA transfer are located into sections of */
  2274. /* configuration of ADC instance, groups and multimode (if available): */
  2275. /* @ref LL_ADC_REG_SetDMATransfer(), ... */
  2276. /**
  2277. * @brief Function to help to configure DMA transfer from ADC: retrieve the
  2278. * ADC register address from ADC instance and a list of ADC registers
  2279. * intended to be used (most commonly) with DMA transfer.
  2280. * @note These ADC registers are data registers:
  2281. * when ADC conversion data is available in ADC data registers,
  2282. * ADC generates a DMA transfer request.
  2283. * @note This macro is intended to be used with LL DMA driver, refer to
  2284. * function "LL_DMA_ConfigAddresses()".
  2285. * Example:
  2286. * LL_DMA_ConfigAddresses(DMA1,
  2287. * LL_DMA_CHANNEL_1,
  2288. * LL_ADC_DMA_GetRegAddr(ADC1, LL_ADC_DMA_REG_REGULAR_DATA),
  2289. * (uint32_t)&< array or variable >,
  2290. * LL_DMA_DIRECTION_PERIPH_TO_MEMORY);
  2291. * @note For devices with several ADC: in multimode, some devices
  2292. * use a different data register outside of ADC instance scope
  2293. * (common data register). This macro manages this register difference,
  2294. * only ADC instance has to be set as parameter.
  2295. * @rmtoll DR RDATA LL_ADC_DMA_GetRegAddr\n
  2296. * CDR RDATA_MST LL_ADC_DMA_GetRegAddr\n
  2297. * CDR RDATA_SLV LL_ADC_DMA_GetRegAddr
  2298. * @param ADCx ADC instance
  2299. * @param Register This parameter can be one of the following values:
  2300. * @arg @ref LL_ADC_DMA_REG_REGULAR_DATA
  2301. * @arg @ref LL_ADC_DMA_REG_REGULAR_DATA_MULTI (1)
  2302. *
  2303. * (1) Available on devices with several ADC instances.
  2304. * @retval ADC register address
  2305. */
  2306. #if defined(ADC_MULTIMODE_SUPPORT)
  2307. __STATIC_INLINE uint32_t LL_ADC_DMA_GetRegAddr(ADC_TypeDef *ADCx, uint32_t Register)
  2308. {
  2309. register uint32_t data_reg_addr = 0U;
  2310. if (Register == LL_ADC_DMA_REG_REGULAR_DATA)
  2311. {
  2312. /* Retrieve address of register DR */
  2313. data_reg_addr = (uint32_t)&(ADCx->DR);
  2314. }
  2315. else /* (Register == LL_ADC_DMA_REG_REGULAR_DATA_MULTI) */
  2316. {
  2317. /* Retrieve address of register CDR */
  2318. data_reg_addr = (uint32_t)&((__LL_ADC_COMMON_INSTANCE(ADCx))->CDR);
  2319. }
  2320. return data_reg_addr;
  2321. }
  2322. #else
  2323. __STATIC_INLINE uint32_t LL_ADC_DMA_GetRegAddr(ADC_TypeDef *ADCx, uint32_t Register)
  2324. {
  2325. /* Retrieve address of register DR */
  2326. return (uint32_t)&(ADCx->DR);
  2327. }
  2328. #endif
  2329. /**
  2330. * @}
  2331. */
  2332. /** @defgroup ADC_LL_EF_Configuration_ADC_Common Configuration of ADC hierarchical scope: common to several ADC instances
  2333. * @{
  2334. */
  2335. /**
  2336. * @brief Set parameter common to several ADC: Clock source and prescaler.
  2337. * @note On this STM32 serie, if ADC group injected is used, some
  2338. * clock ratio constraints between ADC clock and AHB clock
  2339. * must be respected.
  2340. * Refer to reference manual.
  2341. * @note On this STM32 serie, setting of this feature is conditioned to
  2342. * ADC state:
  2343. * All ADC instances of the ADC common group must be disabled.
  2344. * This check can be done with function @ref LL_ADC_IsEnabled() for each
  2345. * ADC instance or by using helper macro helper macro
  2346. * @ref __LL_ADC_IS_ENABLED_ALL_COMMON_INSTANCE().
  2347. * @rmtoll CCR CKMODE LL_ADC_SetCommonClock\n
  2348. * CCR PRESC LL_ADC_SetCommonClock
  2349. * @param ADCxy_COMMON ADC common instance
  2350. * (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() )
  2351. * @param CommonClock This parameter can be one of the following values:
  2352. * @arg @ref LL_ADC_CLOCK_SYNC_PCLK_DIV1
  2353. * @arg @ref LL_ADC_CLOCK_SYNC_PCLK_DIV2
  2354. * @arg @ref LL_ADC_CLOCK_SYNC_PCLK_DIV4
  2355. * @arg @ref LL_ADC_CLOCK_ASYNC_DIV1
  2356. * @retval None
  2357. */
  2358. __STATIC_INLINE void LL_ADC_SetCommonClock(ADC_Common_TypeDef *ADCxy_COMMON, uint32_t CommonClock)
  2359. {
  2360. MODIFY_REG(ADCxy_COMMON->CCR, ADC_CCR_CKMODE, CommonClock);
  2361. }
  2362. /**
  2363. * @brief Get parameter common to several ADC: Clock source and prescaler.
  2364. * @rmtoll CCR CKMODE LL_ADC_GetCommonClock\n
  2365. * CCR PRESC LL_ADC_GetCommonClock
  2366. * @param ADCxy_COMMON ADC common instance
  2367. * (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() )
  2368. * @retval Returned value can be one of the following values:
  2369. * @arg @ref LL_ADC_CLOCK_SYNC_PCLK_DIV1
  2370. * @arg @ref LL_ADC_CLOCK_SYNC_PCLK_DIV2
  2371. * @arg @ref LL_ADC_CLOCK_SYNC_PCLK_DIV4
  2372. * @arg @ref LL_ADC_CLOCK_ASYNC_DIV1
  2373. */
  2374. __STATIC_INLINE uint32_t LL_ADC_GetCommonClock(ADC_Common_TypeDef *ADCxy_COMMON)
  2375. {
  2376. return (uint32_t)(READ_BIT(ADCxy_COMMON->CCR, ADC_CCR_CKMODE));
  2377. }
  2378. /**
  2379. * @brief Set parameter common to several ADC: measurement path to internal
  2380. * channels (VrefInt, temperature sensor, ...).
  2381. * @note One or several values can be selected.
  2382. * Example: (LL_ADC_PATH_INTERNAL_VREFINT |
  2383. * LL_ADC_PATH_INTERNAL_TEMPSENSOR)
  2384. * @note Stabilization time of measurement path to internal channel:
  2385. * After enabling internal paths, before starting ADC conversion,
  2386. * a delay is required for internal voltage reference and
  2387. * temperature sensor stabilization time.
  2388. * Refer to device datasheet.
  2389. * Refer to literal @ref LL_ADC_DELAY_VREFINT_STAB_US.
  2390. * Refer to literal @ref LL_ADC_DELAY_TEMPSENSOR_STAB_US.
  2391. * @note ADC internal channel sampling time constraint:
  2392. * For ADC conversion of internal channels,
  2393. * a sampling time minimum value is required.
  2394. * Refer to device datasheet.
  2395. * @note On this STM32 serie, setting of this feature is conditioned to
  2396. * ADC state:
  2397. * All ADC instances of the ADC common group must be disabled.
  2398. * This check can be done with function @ref LL_ADC_IsEnabled() for each
  2399. * ADC instance or by using helper macro helper macro
  2400. * @ref __LL_ADC_IS_ENABLED_ALL_COMMON_INSTANCE().
  2401. * @rmtoll CCR VREFEN LL_ADC_SetCommonPathInternalCh\n
  2402. * CCR TSEN LL_ADC_SetCommonPathInternalCh\n
  2403. * CCR VBATEN LL_ADC_SetCommonPathInternalCh
  2404. * @param ADCxy_COMMON ADC common instance
  2405. * (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() )
  2406. * @param PathInternal This parameter can be a combination of the following values:
  2407. * @arg @ref LL_ADC_PATH_INTERNAL_NONE
  2408. * @arg @ref LL_ADC_PATH_INTERNAL_VREFINT
  2409. * @arg @ref LL_ADC_PATH_INTERNAL_TEMPSENSOR
  2410. * @arg @ref LL_ADC_PATH_INTERNAL_VBAT
  2411. * @retval None
  2412. */
  2413. __STATIC_INLINE void LL_ADC_SetCommonPathInternalCh(ADC_Common_TypeDef *ADCxy_COMMON, uint32_t PathInternal)
  2414. {
  2415. MODIFY_REG(ADCxy_COMMON->CCR, ADC_CCR_VREFEN | ADC_CCR_TSEN | ADC_CCR_VBATEN, PathInternal);
  2416. }
  2417. /**
  2418. * @brief Get parameter common to several ADC: measurement path to internal
  2419. * channels (VrefInt, temperature sensor, ...).
  2420. * @note One or several values can be selected.
  2421. * Example: (LL_ADC_PATH_INTERNAL_VREFINT |
  2422. * LL_ADC_PATH_INTERNAL_TEMPSENSOR)
  2423. * @rmtoll CCR VREFEN LL_ADC_GetCommonPathInternalCh\n
  2424. * CCR TSEN LL_ADC_GetCommonPathInternalCh\n
  2425. * CCR VBATEN LL_ADC_GetCommonPathInternalCh
  2426. * @param ADCxy_COMMON ADC common instance
  2427. * (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() )
  2428. * @retval Returned value can be a combination of the following values:
  2429. * @arg @ref LL_ADC_PATH_INTERNAL_NONE
  2430. * @arg @ref LL_ADC_PATH_INTERNAL_VREFINT
  2431. * @arg @ref LL_ADC_PATH_INTERNAL_TEMPSENSOR
  2432. * @arg @ref LL_ADC_PATH_INTERNAL_VBAT
  2433. */
  2434. __STATIC_INLINE uint32_t LL_ADC_GetCommonPathInternalCh(ADC_Common_TypeDef *ADCxy_COMMON)
  2435. {
  2436. return (uint32_t)(READ_BIT(ADCxy_COMMON->CCR, ADC_CCR_VREFEN | ADC_CCR_TSEN | ADC_CCR_VBATEN));
  2437. }
  2438. /**
  2439. * @}
  2440. */
  2441. /** @defgroup ADC_LL_EF_Configuration_ADC_Instance Configuration of ADC hierarchical scope: ADC instance
  2442. * @{
  2443. */
  2444. /**
  2445. * @brief Set ADC calibration factor in the mode single-ended
  2446. * or differential (for devices with differential mode available).
  2447. * @note This function is intended to set calibration parameters
  2448. * without having to perform a new calibration using
  2449. * @ref LL_ADC_StartCalibration().
  2450. * @note For devices with differential mode available:
  2451. * Calibration of offset is specific to each of
  2452. * single-ended and differential modes
  2453. * (calibration factor must be specified for each of these
  2454. * differential modes, if used afterwards and if the application
  2455. * requires their calibration).
  2456. * @note In case of setting calibration factors of both modes single ended
  2457. * and differential (parameter LL_ADC_BOTH_SINGLE_DIFF_ENDED):
  2458. * both calibration factors must be concatenated.
  2459. * To perform this processing, use helper macro
  2460. * @ref __LL_ADC_CALIB_FACTOR_SINGLE_DIFF().
  2461. * @note On this STM32 serie, setting of this feature is conditioned to
  2462. * ADC state:
  2463. * ADC must be enabled, without calibration on going, without conversion
  2464. * on going on group regular.
  2465. * @rmtoll CALFACT CALFACT_S LL_ADC_SetCalibrationFactor\n
  2466. * CALFACT CALFACT_D LL_ADC_SetCalibrationFactor
  2467. * @param ADCx ADC instance
  2468. * @param SingleDiff This parameter can be one of the following values:
  2469. * @arg @ref LL_ADC_SINGLE_ENDED
  2470. * @arg @ref LL_ADC_DIFFERENTIAL_ENDED
  2471. * @arg @ref LL_ADC_BOTH_SINGLE_DIFF_ENDED
  2472. * @param CalibrationFactor Value between Min_Data=0x00 and Max_Data=0x7F
  2473. * @retval None
  2474. */
  2475. __STATIC_INLINE void LL_ADC_SetCalibrationFactor(ADC_TypeDef *ADCx, uint32_t SingleDiff, uint32_t CalibrationFactor)
  2476. {
  2477. MODIFY_REG(ADCx->CALFACT,
  2478. SingleDiff & ADC_SINGLEDIFF_CALIB_FACTOR_MASK,
  2479. CalibrationFactor << POSITION_VAL(SingleDiff & ADC_SINGLEDIFF_CALIB_FACTOR_MASK));
  2480. }
  2481. /**
  2482. * @brief Get ADC calibration factor in the mode single-ended
  2483. * or differential (for devices with differential mode available).
  2484. * @note Calibration factors are set by hardware after performing
  2485. * a calibration run using function @ref LL_ADC_StartCalibration().
  2486. * @note For devices with differential mode available:
  2487. * Calibration of offset is specific to each of
  2488. * single-ended and differential modes
  2489. * @rmtoll CALFACT CALFACT_S LL_ADC_GetCalibrationFactor\n
  2490. * CALFACT CALFACT_D LL_ADC_GetCalibrationFactor
  2491. * @param ADCx ADC instance
  2492. * @param SingleDiff This parameter can be one of the following values:
  2493. * @arg @ref LL_ADC_SINGLE_ENDED
  2494. * @arg @ref LL_ADC_DIFFERENTIAL_ENDED
  2495. * @retval Value between Min_Data=0x00 and Max_Data=0x7F
  2496. */
  2497. __STATIC_INLINE uint32_t LL_ADC_GetCalibrationFactor(ADC_TypeDef *ADCx, uint32_t SingleDiff)
  2498. {
  2499. /* Retrieve bits with position in register depending on parameter */
  2500. /* "SingleDiff". */
  2501. /* Parameter used with mask "ADC_SINGLEDIFF_CALIB_FACTOR_MASK" because */
  2502. /* containing other bits reserved for other purpose. */
  2503. return (uint32_t)(READ_BIT(ADCx->CALFACT, (SingleDiff & ADC_SINGLEDIFF_CALIB_FACTOR_MASK)) >> POSITION_VAL(SingleDiff & ADC_SINGLEDIFF_CALIB_FACTOR_MASK));
  2504. }
  2505. /**
  2506. * @brief Set ADC resolution.
  2507. * Refer to reference manual for alignments formats
  2508. * dependencies to ADC resolutions.
  2509. * @note On this STM32 serie, setting of this feature is conditioned to
  2510. * ADC state:
  2511. * ADC must be disabled or enabled without conversion on going
  2512. * on either groups regular or injected.
  2513. * @rmtoll CFGR RES LL_ADC_SetResolution
  2514. * @param ADCx ADC instance
  2515. * @param Resolution This parameter can be one of the following values:
  2516. * @arg @ref LL_ADC_RESOLUTION_12B
  2517. * @arg @ref LL_ADC_RESOLUTION_10B
  2518. * @arg @ref LL_ADC_RESOLUTION_8B
  2519. * @arg @ref LL_ADC_RESOLUTION_6B
  2520. * @retval None
  2521. */
  2522. __STATIC_INLINE void LL_ADC_SetResolution(ADC_TypeDef *ADCx, uint32_t Resolution)
  2523. {
  2524. MODIFY_REG(ADCx->CFGR, ADC_CFGR_RES, Resolution);
  2525. }
  2526. /**
  2527. * @brief Get ADC resolution.
  2528. * Refer to reference manual for alignments formats
  2529. * dependencies to ADC resolutions.
  2530. * @rmtoll CFGR RES LL_ADC_GetResolution
  2531. * @param ADCx ADC instance
  2532. * @retval Returned value can be one of the following values:
  2533. * @arg @ref LL_ADC_RESOLUTION_12B
  2534. * @arg @ref LL_ADC_RESOLUTION_10B
  2535. * @arg @ref LL_ADC_RESOLUTION_8B
  2536. * @arg @ref LL_ADC_RESOLUTION_6B
  2537. */
  2538. __STATIC_INLINE uint32_t LL_ADC_GetResolution(ADC_TypeDef *ADCx)
  2539. {
  2540. return (uint32_t)(READ_BIT(ADCx->CFGR, ADC_CFGR_RES));
  2541. }
  2542. /**
  2543. * @brief Set ADC conversion data alignment.
  2544. * @note Refer to reference manual for alignments formats
  2545. * dependencies to ADC resolutions.
  2546. * @note On this STM32 serie, setting of this feature is conditioned to
  2547. * ADC state:
  2548. * ADC must be disabled or enabled without conversion on going
  2549. * on either groups regular or injected.
  2550. * @rmtoll CFGR ALIGN LL_ADC_SetDataAlignment
  2551. * @param ADCx ADC instance
  2552. * @param DataAlignment This parameter can be one of the following values:
  2553. * @arg @ref LL_ADC_DATA_ALIGN_RIGHT
  2554. * @arg @ref LL_ADC_DATA_ALIGN_LEFT
  2555. * @retval None
  2556. */
  2557. __STATIC_INLINE void LL_ADC_SetDataAlignment(ADC_TypeDef *ADCx, uint32_t DataAlignment)
  2558. {
  2559. MODIFY_REG(ADCx->CFGR, ADC_CFGR_ALIGN, DataAlignment);
  2560. }
  2561. /**
  2562. * @brief Get ADC conversion data alignment.
  2563. * @note Refer to reference manual for alignments formats
  2564. * dependencies to ADC resolutions.
  2565. * @rmtoll CFGR ALIGN LL_ADC_GetDataAlignment
  2566. * @param ADCx ADC instance
  2567. * @retval Returned value can be one of the following values:
  2568. * @arg @ref LL_ADC_DATA_ALIGN_RIGHT
  2569. * @arg @ref LL_ADC_DATA_ALIGN_LEFT
  2570. */
  2571. __STATIC_INLINE uint32_t LL_ADC_GetDataAlignment(ADC_TypeDef *ADCx)
  2572. {
  2573. return (uint32_t)(READ_BIT(ADCx->CFGR, ADC_CFGR_ALIGN));
  2574. }
  2575. /**
  2576. * @brief Set ADC low power mode.
  2577. * @note Description of ADC low power modes:
  2578. * - ADC low power mode "auto wait": Dynamic low power mode,
  2579. * ADC conversions occurrences are limited to the minimum necessary
  2580. * in order to reduce power consumption.
  2581. * New ADC conversion starts only when the previous
  2582. * unitary conversion data (for ADC group regular)
  2583. * or previous sequence conversions data (for ADC group injected)
  2584. * has been retrieved by user software.
  2585. * In the meantime, ADC remains idle: does not performs any
  2586. * other conversion.
  2587. * This mode allows to automatically adapt the ADC conversions
  2588. * triggers to the speed of the software that reads the data.
  2589. * Moreover, this avoids risk of overrun for low frequency
  2590. * applications.
  2591. * How to use this low power mode:
  2592. * - Do not use with interruption or DMA since these modes
  2593. * have to clear immediately the EOC flag to free the
  2594. * IRQ vector sequencer.
  2595. * - Do use with polling: 1. Start conversion,
  2596. * 2. Later on, when conversion data is needed: poll for end of
  2597. * conversion to ensure that conversion is completed and
  2598. * retrieve ADC conversion data. This will trig another
  2599. * ADC conversion start.
  2600. * - ADC low power mode "auto power-off" (feature available on
  2601. * this device if parameter LL_ADC_LP_MODE_AUTOOFF is available):
  2602. * the ADC automatically powers-off after a conversion and
  2603. * automatically wakes up when a new conversion is triggered
  2604. * (with startup time between trigger and start of sampling).
  2605. * This feature can be combined with low power mode "auto wait".
  2606. * @note With ADC low power mode "auto wait", the ADC conversion data read
  2607. * is corresponding to previous ADC conversion start, independently
  2608. * of delay during which ADC was idle.
  2609. * Therefore, the ADC conversion data may be outdated: does not
  2610. * correspond to the current voltage level on the selected
  2611. * ADC channel.
  2612. * @note On this STM32 serie, setting of this feature is conditioned to
  2613. * ADC state:
  2614. * ADC must be disabled or enabled without conversion on going
  2615. * on either groups regular or injected.
  2616. * @rmtoll CFGR AUTDLY LL_ADC_SetLowPowerMode
  2617. * @param ADCx ADC instance
  2618. * @param LowPowerMode This parameter can be one of the following values:
  2619. * @arg @ref LL_ADC_LP_MODE_NONE
  2620. * @arg @ref LL_ADC_LP_AUTOWAIT
  2621. * @retval None
  2622. */
  2623. __STATIC_INLINE void LL_ADC_SetLowPowerMode(ADC_TypeDef *ADCx, uint32_t LowPowerMode)
  2624. {
  2625. MODIFY_REG(ADCx->CFGR, ADC_CFGR_AUTDLY, LowPowerMode);
  2626. }
  2627. /**
  2628. * @brief Get ADC low power mode:
  2629. * @note Description of ADC low power modes:
  2630. * - ADC low power mode "auto wait": Dynamic low power mode,
  2631. * ADC conversions occurrences are limited to the minimum necessary
  2632. * in order to reduce power consumption.
  2633. * New ADC conversion starts only when the previous
  2634. * unitary conversion data (for ADC group regular)
  2635. * or previous sequence conversions data (for ADC group injected)
  2636. * has been retrieved by user software.
  2637. * In the meantime, ADC remains idle: does not performs any
  2638. * other conversion.
  2639. * This mode allows to automatically adapt the ADC conversions
  2640. * triggers to the speed of the software that reads the data.
  2641. * Moreover, this avoids risk of overrun for low frequency
  2642. * applications.
  2643. * How to use this low power mode:
  2644. * - Do not use with interruption or DMA since these modes
  2645. * have to clear immediately the EOC flag to free the
  2646. * IRQ vector sequencer.
  2647. * - Do use with polling: 1. Start conversion,
  2648. * 2. Later on, when conversion data is needed: poll for end of
  2649. * conversion to ensure that conversion is completed and
  2650. * retrieve ADC conversion data. This will trig another
  2651. * ADC conversion start.
  2652. * - ADC low power mode "auto power-off" (feature available on
  2653. * this device if parameter LL_ADC_LP_MODE_AUTOOFF is available):
  2654. * the ADC automatically powers-off after a conversion and
  2655. * automatically wakes up when a new conversion is triggered
  2656. * (with startup time between trigger and start of sampling).
  2657. * This feature can be combined with low power mode "auto wait".
  2658. * @note With ADC low power mode "auto wait", the ADC conversion data read
  2659. * is corresponding to previous ADC conversion start, independently
  2660. * of delay during which ADC was idle.
  2661. * Therefore, the ADC conversion data may be outdated: does not
  2662. * correspond to the current voltage level on the selected
  2663. * ADC channel.
  2664. * @rmtoll CFGR AUTDLY LL_ADC_GetLowPowerMode
  2665. * @param ADCx ADC instance
  2666. * @retval Returned value can be one of the following values:
  2667. * @arg @ref LL_ADC_LP_MODE_NONE
  2668. * @arg @ref LL_ADC_LP_AUTOWAIT
  2669. */
  2670. __STATIC_INLINE uint32_t LL_ADC_GetLowPowerMode(ADC_TypeDef *ADCx)
  2671. {
  2672. return (uint32_t)(READ_BIT(ADCx->CFGR, ADC_CFGR_AUTDLY));
  2673. }
  2674. /**
  2675. * @brief Set ADC selected offset number 1, 2, 3 or 4.
  2676. * @note This function set the 2 items of offset configuration:
  2677. * - ADC channel to which the offset programmed will be applied
  2678. * (independently of channel mapped on ADC group regular
  2679. * or group injected)
  2680. * - Offset level (offset to be subtracted from the raw
  2681. * converted data).
  2682. * @note Caution: Offset format is dependent to ADC resolution:
  2683. * offset has to be left-aligned on bit 11, the LSB (right bits)
  2684. * are set to 0.
  2685. * @note This function enables the offset, by default. It can be forced
  2686. * to disable state using function LL_ADC_SetOffsetState().
  2687. * @note If a channel is mapped on several offsets numbers, only the offset
  2688. * with the lowest value is considered for the subtraction.
  2689. * @note On this STM32 serie, setting of this feature is conditioned to
  2690. * ADC state:
  2691. * ADC must be disabled or enabled without conversion on going
  2692. * on either groups regular or injected.
  2693. * @rmtoll OFR1 OFFSET1_CH LL_ADC_SetOffset\n
  2694. * OFR1 OFFSET1 LL_ADC_SetOffset\n
  2695. * OFR1 OFFSET1_EN LL_ADC_SetOffset\n
  2696. * OFR2 OFFSET2_CH LL_ADC_SetOffset\n
  2697. * OFR2 OFFSET2 LL_ADC_SetOffset\n
  2698. * OFR2 OFFSET2_EN LL_ADC_SetOffset\n
  2699. * OFR3 OFFSET3_CH LL_ADC_SetOffset\n
  2700. * OFR3 OFFSET3 LL_ADC_SetOffset\n
  2701. * OFR3 OFFSET3_EN LL_ADC_SetOffset\n
  2702. * OFR4 OFFSET4_CH LL_ADC_SetOffset\n
  2703. * OFR4 OFFSET4 LL_ADC_SetOffset\n
  2704. * OFR4 OFFSET4_EN LL_ADC_SetOffset
  2705. * @param ADCx ADC instance
  2706. * @param Offsety This parameter can be one of the following values:
  2707. * @arg @ref LL_ADC_OFFSET_1
  2708. * @arg @ref LL_ADC_OFFSET_2
  2709. * @arg @ref LL_ADC_OFFSET_3
  2710. * @arg @ref LL_ADC_OFFSET_4
  2711. * @param Channel This parameter can be one of the following values:
  2712. * @arg @ref LL_ADC_CHANNEL_0
  2713. * @arg @ref LL_ADC_CHANNEL_1
  2714. * @arg @ref LL_ADC_CHANNEL_2
  2715. * @arg @ref LL_ADC_CHANNEL_3
  2716. * @arg @ref LL_ADC_CHANNEL_4
  2717. * @arg @ref LL_ADC_CHANNEL_5
  2718. * @arg @ref LL_ADC_CHANNEL_6
  2719. * @arg @ref LL_ADC_CHANNEL_7
  2720. * @arg @ref LL_ADC_CHANNEL_8
  2721. * @arg @ref LL_ADC_CHANNEL_9
  2722. * @arg @ref LL_ADC_CHANNEL_10
  2723. * @arg @ref LL_ADC_CHANNEL_11
  2724. * @arg @ref LL_ADC_CHANNEL_12
  2725. * @arg @ref LL_ADC_CHANNEL_13
  2726. * @arg @ref LL_ADC_CHANNEL_14
  2727. * @arg @ref LL_ADC_CHANNEL_15
  2728. * @arg @ref LL_ADC_CHANNEL_16
  2729. * @arg @ref LL_ADC_CHANNEL_17
  2730. * @arg @ref LL_ADC_CHANNEL_18
  2731. * @arg @ref LL_ADC_CHANNEL_VREFINT (5)
  2732. * @arg @ref LL_ADC_CHANNEL_TEMPSENSOR (1)
  2733. * @arg @ref LL_ADC_CHANNEL_VBAT (1)
  2734. * @arg @ref LL_ADC_CHANNEL_VOPAMP1 (1)
  2735. * @arg @ref LL_ADC_CHANNEL_VOPAMP2 (2)
  2736. * @arg @ref LL_ADC_CHANNEL_VOPAMP3 (3)
  2737. * @arg @ref LL_ADC_CHANNEL_VOPAMP4 (4)
  2738. *
  2739. * (1) On STM32F3, parameter available only on ADC instance: ADC1.\n
  2740. * (2) On STM32F3, parameter available only on ADC instance: ADC2.\n
  2741. * (3) On STM32F3, parameter available only on ADC instance: ADC3.\n
  2742. * (4) On STM32F3, parameter available only on ADC instances: ADC4.\n
  2743. * (5) On STM32F3, ADC channel available only on all ADC instances, but
  2744. * only one ADC instance is allowed to be connected to VrefInt at the same time.
  2745. * @param OffsetLevel Value between Min_Data=0x000 and Max_Data=0xFFF
  2746. * @retval None
  2747. */
  2748. __STATIC_INLINE void LL_ADC_SetOffset(ADC_TypeDef *ADCx, uint32_t Offsety, uint32_t Channel, uint32_t OffsetLevel)
  2749. {
  2750. register uint32_t *preg = __ADC_PTR_REG_OFFSET(ADCx->OFR1, Offsety);
  2751. MODIFY_REG(*preg,
  2752. ADC_OFR1_OFFSET1_EN | ADC_OFR1_OFFSET1_CH | ADC_OFR1_OFFSET1,
  2753. ADC_OFR1_OFFSET1_EN | (Channel & ADC_CHANNEL_ID_NUMBER_MASK) | OffsetLevel);
  2754. }
  2755. /**
  2756. * @brief Get for the ADC selected offset number 1, 2, 3 or 4:
  2757. * Channel to which the offset programmed will be applied
  2758. * (independently of channel mapped on ADC group regular
  2759. * or group injected)
  2760. * @note Usage of the returned channel number:
  2761. * - To reinject this channel into another function LL_ADC_xxx:
  2762. * the returned channel number is only partly formatted on definition
  2763. * of literals LL_ADC_CHANNEL_x. Therefore, it has to be compared
  2764. * with parts of literals LL_ADC_CHANNEL_x or using
  2765. * helper macro @ref __LL_ADC_CHANNEL_TO_DECIMAL_NB().
  2766. * Then the selected literal LL_ADC_CHANNEL_x can be used
  2767. * as parameter for another function.
  2768. * - To get the channel number in decimal format:
  2769. * process the returned value with the helper macro
  2770. * @ref __LL_ADC_CHANNEL_TO_DECIMAL_NB().
  2771. * @rmtoll OFR1 OFFSET1_CH LL_ADC_GetOffsetChannel\n
  2772. * OFR2 OFFSET2_CH LL_ADC_GetOffsetChannel\n
  2773. * OFR3 OFFSET3_CH LL_ADC_GetOffsetChannel\n
  2774. * OFR4 OFFSET4_CH LL_ADC_GetOffsetChannel
  2775. * @param ADCx ADC instance
  2776. * @param Offsety This parameter can be one of the following values:
  2777. * @arg @ref LL_ADC_OFFSET_1
  2778. * @arg @ref LL_ADC_OFFSET_2
  2779. * @arg @ref LL_ADC_OFFSET_3
  2780. * @arg @ref LL_ADC_OFFSET_4
  2781. * @retval Returned value can be one of the following values:
  2782. * @arg @ref LL_ADC_CHANNEL_0
  2783. * @arg @ref LL_ADC_CHANNEL_1
  2784. * @arg @ref LL_ADC_CHANNEL_2
  2785. * @arg @ref LL_ADC_CHANNEL_3
  2786. * @arg @ref LL_ADC_CHANNEL_4
  2787. * @arg @ref LL_ADC_CHANNEL_5
  2788. * @arg @ref LL_ADC_CHANNEL_6
  2789. * @arg @ref LL_ADC_CHANNEL_7
  2790. * @arg @ref LL_ADC_CHANNEL_8
  2791. * @arg @ref LL_ADC_CHANNEL_9
  2792. * @arg @ref LL_ADC_CHANNEL_10
  2793. * @arg @ref LL_ADC_CHANNEL_11
  2794. * @arg @ref LL_ADC_CHANNEL_12
  2795. * @arg @ref LL_ADC_CHANNEL_13
  2796. * @arg @ref LL_ADC_CHANNEL_14
  2797. * @arg @ref LL_ADC_CHANNEL_15
  2798. * @arg @ref LL_ADC_CHANNEL_16
  2799. * @arg @ref LL_ADC_CHANNEL_17
  2800. * @arg @ref LL_ADC_CHANNEL_18
  2801. * @arg @ref LL_ADC_CHANNEL_VREFINT (5)
  2802. * @arg @ref LL_ADC_CHANNEL_TEMPSENSOR (1)
  2803. * @arg @ref LL_ADC_CHANNEL_VBAT (1)
  2804. * @arg @ref LL_ADC_CHANNEL_VOPAMP1 (1)
  2805. * @arg @ref LL_ADC_CHANNEL_VOPAMP2 (2)
  2806. * @arg @ref LL_ADC_CHANNEL_VOPAMP3 (3)
  2807. * @arg @ref LL_ADC_CHANNEL_VOPAMP4 (4)
  2808. *
  2809. * (1) On STM32F3, parameter available only on ADC instance: ADC1.\n
  2810. * (2) On STM32F3, parameter available only on ADC instance: ADC2.\n
  2811. * (3) On STM32F3, parameter available only on ADC instance: ADC3.\n
  2812. * (4) On STM32F3, parameter available only on ADC instances: ADC4.\n
  2813. * (5) On STM32F3, ADC channel available only on all ADC instances, but
  2814. * only one ADC instance is allowed to be connected to VrefInt at the same time.\n
  2815. * (1, 2, 3, 4, 5) For ADC channel read back from ADC register,
  2816. * comparison with internal channel parameter to be done
  2817. * using helper macro @ref __LL_ADC_CHANNEL_INTERNAL_TO_EXTERNAL().
  2818. */
  2819. __STATIC_INLINE uint32_t LL_ADC_GetOffsetChannel(ADC_TypeDef *ADCx, uint32_t Offsety)
  2820. {
  2821. register uint32_t *preg = __ADC_PTR_REG_OFFSET(ADCx->OFR1, Offsety);
  2822. return (uint32_t) READ_BIT(*preg, ADC_OFR1_OFFSET1_CH);
  2823. }
  2824. /**
  2825. * @brief Get for the ADC selected offset number 1, 2, 3 or 4:
  2826. * Offset level (offset to be subtracted from the raw
  2827. * converted data).
  2828. * @note Caution: Offset format is dependent to ADC resolution:
  2829. * offset has to be left-aligned on bit 11, the LSB (right bits)
  2830. * are set to 0.
  2831. * @rmtoll OFR1 OFFSET1 LL_ADC_GetOffsetLevel\n
  2832. * OFR2 OFFSET2 LL_ADC_GetOffsetLevel\n
  2833. * OFR3 OFFSET3 LL_ADC_GetOffsetLevel\n
  2834. * OFR4 OFFSET4 LL_ADC_GetOffsetLevel
  2835. * @param ADCx ADC instance
  2836. * @param Offsety This parameter can be one of the following values:
  2837. * @arg @ref LL_ADC_OFFSET_1
  2838. * @arg @ref LL_ADC_OFFSET_2
  2839. * @arg @ref LL_ADC_OFFSET_3
  2840. * @arg @ref LL_ADC_OFFSET_4
  2841. * @retval Value between Min_Data=0x000 and Max_Data=0xFFF
  2842. */
  2843. __STATIC_INLINE uint32_t LL_ADC_GetOffsetLevel(ADC_TypeDef *ADCx, uint32_t Offsety)
  2844. {
  2845. register uint32_t *preg = __ADC_PTR_REG_OFFSET(ADCx->OFR1, Offsety);
  2846. return (uint32_t) READ_BIT(*preg, ADC_OFR1_OFFSET1);
  2847. }
  2848. /**
  2849. * @brief Set for the ADC selected offset number 1, 2, 3 or 4:
  2850. * force offset state disable or enable
  2851. * without modifying offset channel or offset value.
  2852. * @note This function should be needed only in case of offset to be
  2853. * enabled-disabled dynamically, and should not be needed in other cases:
  2854. * function LL_ADC_SetOffset() automatically enables the offset.
  2855. * @note On this STM32 serie, setting of this feature is conditioned to
  2856. * ADC state:
  2857. * ADC must be disabled or enabled without conversion on going
  2858. * on either groups regular or injected.
  2859. * @rmtoll OFR1 OFFSET1_EN LL_ADC_SetOffsetState\n
  2860. * OFR2 OFFSET2_EN LL_ADC_SetOffsetState\n
  2861. * OFR3 OFFSET3_EN LL_ADC_SetOffsetState\n
  2862. * OFR4 OFFSET4_EN LL_ADC_SetOffsetState
  2863. * @param ADCx ADC instance
  2864. * @param Offsety This parameter can be one of the following values:
  2865. * @arg @ref LL_ADC_OFFSET_1
  2866. * @arg @ref LL_ADC_OFFSET_2
  2867. * @arg @ref LL_ADC_OFFSET_3
  2868. * @arg @ref LL_ADC_OFFSET_4
  2869. * @param OffsetState This parameter can be one of the following values:
  2870. * @arg @ref LL_ADC_OFFSET_DISABLE
  2871. * @arg @ref LL_ADC_OFFSET_ENABLE
  2872. * @retval None
  2873. */
  2874. __STATIC_INLINE void LL_ADC_SetOffsetState(ADC_TypeDef *ADCx, uint32_t Offsety, uint32_t OffsetState)
  2875. {
  2876. register uint32_t *preg = (uint32_t *)((uint32_t)
  2877. ((uint32_t)(&ADCx->OFR1) + (Offsety*4U)));
  2878. MODIFY_REG(*preg,
  2879. ADC_OFR1_OFFSET1_EN,
  2880. OffsetState);
  2881. }
  2882. /**
  2883. * @brief Get for the ADC selected offset number 1, 2, 3 or 4:
  2884. * offset state disabled or enabled.
  2885. * @rmtoll OFR1 OFFSET1_EN LL_ADC_GetOffsetState\n
  2886. * OFR2 OFFSET2_EN LL_ADC_GetOffsetState\n
  2887. * OFR3 OFFSET3_EN LL_ADC_GetOffsetState\n
  2888. * OFR4 OFFSET4_EN LL_ADC_GetOffsetState
  2889. * @param ADCx ADC instance
  2890. * @param Offsety This parameter can be one of the following values:
  2891. * @arg @ref LL_ADC_OFFSET_1
  2892. * @arg @ref LL_ADC_OFFSET_2
  2893. * @arg @ref LL_ADC_OFFSET_3
  2894. * @arg @ref LL_ADC_OFFSET_4
  2895. * @retval Returned value can be one of the following values:
  2896. * @arg @ref LL_ADC_OFFSET_DISABLE
  2897. * @arg @ref LL_ADC_OFFSET_ENABLE
  2898. */
  2899. __STATIC_INLINE uint32_t LL_ADC_GetOffsetState(ADC_TypeDef *ADCx, uint32_t Offsety)
  2900. {
  2901. register uint32_t *preg = __ADC_PTR_REG_OFFSET(ADCx->OFR1, Offsety);
  2902. return (uint32_t) READ_BIT(*preg, ADC_OFR1_OFFSET1_EN);
  2903. }
  2904. /**
  2905. * @}
  2906. */
  2907. /** @defgroup ADC_LL_EF_Configuration_ADC_Group_Regular Configuration of ADC hierarchical scope: group regular
  2908. * @{
  2909. */
  2910. /**
  2911. * @brief Set ADC group regular conversion trigger source:
  2912. * internal (SW start) or from external IP (timer event,
  2913. * external interrupt line).
  2914. * @note On this STM32 serie, setting trigger source to external trigger
  2915. * also set trigger polarity to rising edge
  2916. * (default setting for compatibility with some ADC on other
  2917. * STM32 families having this setting set by HW default value).
  2918. * In case of need to modify trigger edge, use
  2919. * function @ref LL_ADC_REG_SetTriggerEdge().
  2920. * @note Availability of parameters of trigger sources from timer
  2921. * depends on timers availability on the selected device.
  2922. * @note On this STM32 serie, setting of this feature is conditioned to
  2923. * ADC state:
  2924. * ADC must be disabled or enabled without conversion on going
  2925. * on group regular.
  2926. * @rmtoll CFGR EXTSEL LL_ADC_REG_SetTriggerSource\n
  2927. * CFGR EXTEN LL_ADC_REG_SetTriggerSource
  2928. * @param ADCx ADC instance
  2929. * @param TriggerSource This parameter can be one of the following values:
  2930. * @arg @ref LL_ADC_REG_TRIG_SOFTWARE
  2931. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM1_TRGO
  2932. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM1_TRGO2
  2933. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM1_CH1 (3)(4)(5)(6)
  2934. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM1_CH1_ADC12 (1)(2) (7)
  2935. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM1_CH2 (3)(4)(5)(6)
  2936. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM1_CH2_ADC12 (1)(2) (7)
  2937. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM1_CH3
  2938. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM2_TRGO (3)(4)(5)(6)
  2939. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM2_TRGO_ADC12 (1)(2) (7)
  2940. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM2_TRGO__ADC34 (1)(2) (8)
  2941. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM2_CH1_ADC34 (1)(2) (8)
  2942. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM2_CH2_ADC12 (1)(2) (7)
  2943. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM2_CH3_ADC34 (1)(2) (8)
  2944. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM3_TRGO (3)(4)(5)
  2945. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM3_TRGO_ADC12 (1)(2) (7)
  2946. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM3_TRGO__ADC34 (1)(2) (8)
  2947. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM3_CH1_ADC34 (1)(2) (8)
  2948. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM3_CH4 (3)(4)(5)
  2949. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM3_CH4_ADC12 (1)(2) (7)
  2950. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM4_TRGO (1)(2)(3)(5)
  2951. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM4_CH1_ADC34 (1)(2) (8)
  2952. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM4_CH4 (3) (5)
  2953. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM4_CH4_ADC12 (1)(2) (7)
  2954. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM6_TRGO (3)(4)(5)(6)
  2955. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM6_TRGO_ADC12 (1)(2) (7)
  2956. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM8_TRGO (3)
  2957. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM8_TRGO_ADC12 (1)(2) (7)
  2958. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM8_TRGO2 (1)(2)
  2959. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM6_TRGO_ADC12 (1)(2) (7)
  2960. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM7_TRGO_ADC34 (1)(2) (8)
  2961. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM8_TRGO__ADC34 (1)(2) (8)
  2962. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM8_TRGO2 (1)(2)
  2963. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM8_CH1_ADC34 (1)(2) (8)
  2964. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM15_TRGO (5)
  2965. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM20_TRG0_ADC12 (1) (7)
  2966. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM20_TRG02_ADC12 (1) (7)
  2967. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM20_CH1_ADC12 (1) (7)
  2968. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM20_CH2_ADC12 (1) (7)
  2969. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM20_CH3_ADC12 (1) (7)
  2970. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM20_TRG0_ADC3 (1) (8)
  2971. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM20_TRG02_ADC34 (1) (8)
  2972. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM20_CH1_ADC34 (1) (8)
  2973. * @arg @ref LL_ADC_REG_TRIG_EXT_HRTIM_TRG1 (4)
  2974. * @arg @ref LL_ADC_REG_TRIG_EXT_HRTIM_TRG3 (4)
  2975. * @arg @ref LL_ADC_REG_TRIG_EXT_EXTI_LINE2_ADC34 (1)(2) (8)
  2976. * @arg @ref LL_ADC_REG_TRIG_EXT_EXTI_LINE11 (3)(4)(5)(6)
  2977. * @arg @ref LL_ADC_REG_TRIG_EXT_EXTI_LINE11_ADC12 (1)(2) (7)
  2978. * (1) On STM32F3, parameter not available on all devices: among others, on STM32F303xE, STM32F398xx.\n
  2979. * (2) On STM32F3, parameter not available on all devices: among others, on STM32F303xC, STM32F358xx.\n
  2980. * (3) On STM32F3, parameter not available on all devices: among others, on STM32F303x8, STM32F328xx.\n
  2981. * (4) On STM32F3, parameter not available on all devices: among others, on STM32F334x8.\n
  2982. * (5) On STM32F3, parameter not available on all devices: among others, on STM32F302xC, STM32F302xE.\n
  2983. * (6) On STM32F3, parameter not available on all devices: among others, on STM32F301x8, STM32F302x8, STM32F318xx.\n
  2984. * (7) On STM32F3, parameter not available on all ADC instances: ADC1, ADC2 (for ADC instances ADCx available on the selected device).\n
  2985. * (8) On STM32F3, parameter not available on all ADC instances: ADC3, ADC4 (for ADC instances ADCx available on the selected device).
  2986. * @retval None
  2987. */
  2988. __STATIC_INLINE void LL_ADC_REG_SetTriggerSource(ADC_TypeDef *ADCx, uint32_t TriggerSource)
  2989. {
  2990. MODIFY_REG(ADCx->CFGR, ADC_CFGR_EXTEN | ADC_CFGR_EXTSEL, TriggerSource);
  2991. }
  2992. /**
  2993. * @brief Get ADC group regular conversion trigger source:
  2994. * internal (SW start) or from external IP (timer event,
  2995. * external interrupt line).
  2996. * @note To determine whether group regular trigger source is
  2997. * internal (SW start) or external, without detail
  2998. * of which peripheral is selected as external trigger,
  2999. * (equivalent to
  3000. * "if(LL_ADC_REG_GetTriggerSource(ADC1) == LL_ADC_REG_TRIG_SOFTWARE)")
  3001. * use function @ref LL_ADC_REG_IsTriggerSourceSWStart.
  3002. * @note Availability of parameters of trigger sources from timer
  3003. * depends on timers availability on the selected device.
  3004. * @rmtoll CFGR EXTSEL LL_ADC_REG_GetTriggerSource\n
  3005. * CFGR EXTEN LL_ADC_REG_GetTriggerSource
  3006. * @param ADCx ADC instance
  3007. * @retval Returned value can be one of the following values:
  3008. * @arg @ref LL_ADC_REG_TRIG_SOFTWARE
  3009. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM1_TRGO
  3010. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM1_TRGO2
  3011. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM1_CH1 (3)(4)(5)(6)
  3012. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM1_CH1_ADC12 (1)(2) (7)
  3013. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM1_CH2 (3)(4)(5)(6)
  3014. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM1_CH2_ADC12 (1)(2) (7)
  3015. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM1_CH3
  3016. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM2_TRGO (3)(4)(5)(6)
  3017. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM2_TRGO_ADC12 (1)(2) (7)
  3018. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM2_TRGO__ADC34 (1)(2) (8)
  3019. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM2_CH1_ADC34 (1)(2) (8)
  3020. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM2_CH2_ADC12 (1)(2) (7)
  3021. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM2_CH3_ADC34 (1)(2) (8)
  3022. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM3_TRGO (3)(4)(5)
  3023. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM3_TRGO_ADC12 (1)(2) (7)
  3024. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM3_TRGO__ADC34 (1)(2) (8)
  3025. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM3_CH1_ADC34 (1)(2) (8)
  3026. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM3_CH4 (3)(4)(5)
  3027. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM3_CH4_ADC12 (1)(2) (7)
  3028. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM4_TRGO (1)(2)(3)(5)
  3029. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM4_CH1_ADC34 (1)(2) (8)
  3030. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM4_CH4 (3) (5)
  3031. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM4_CH4_ADC12 (1)(2) (7)
  3032. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM6_TRGO (3)(4)(5)(6)
  3033. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM6_TRGO_ADC12 (1)(2) (7)
  3034. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM8_TRGO (3)
  3035. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM8_TRGO_ADC12 (1)(2) (7)
  3036. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM8_TRGO2 (1)(2)
  3037. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM6_TRGO_ADC12 (1)(2) (7)
  3038. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM7_TRGO_ADC34 (1)(2) (8)
  3039. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM8_TRGO__ADC34 (1)(2) (8)
  3040. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM8_TRGO2 (1)(2)
  3041. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM8_CH1_ADC34 (1)(2) (8)
  3042. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM15_TRGO (5)
  3043. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM20_TRG0_ADC12 (1) (7)
  3044. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM20_TRG02_ADC12 (1) (7)
  3045. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM20_CH1_ADC12 (1) (7)
  3046. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM20_CH2_ADC12 (1) (7)
  3047. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM20_CH3_ADC12 (1) (7)
  3048. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM20_TRG0_ADC3 (1) (8)
  3049. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM20_TRG02_ADC34 (1) (8)
  3050. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM20_CH1_ADC34 (1) (8)
  3051. * @arg @ref LL_ADC_REG_TRIG_EXT_HRTIM_TRG1 (4)
  3052. * @arg @ref LL_ADC_REG_TRIG_EXT_HRTIM_TRG3 (4)
  3053. * @arg @ref LL_ADC_REG_TRIG_EXT_EXTI_LINE2_ADC34 (1)(2) (8)
  3054. * @arg @ref LL_ADC_REG_TRIG_EXT_EXTI_LINE11 (3)(4)(5)(6)
  3055. * @arg @ref LL_ADC_REG_TRIG_EXT_EXTI_LINE11_ADC12 (1)(2) (7)
  3056. * (1) On STM32F3, parameter not available on all devices: among others, on STM32F303xE, STM32F398xx.\n
  3057. * (2) On STM32F3, parameter not available on all devices: among others, on STM32F303xC, STM32F358xx.\n
  3058. * (3) On STM32F3, parameter not available on all devices: among others, on STM32F303x8, STM32F328xx.\n
  3059. * (4) On STM32F3, parameter not available on all devices: among others, on STM32F334x8.\n
  3060. * (5) On STM32F3, parameter not available on all devices: among others, on STM32F302xC, STM32F302xE.\n
  3061. * (6) On STM32F3, parameter not available on all devices: among others, on STM32F301x8, STM32F302x8, STM32F318xx.\n
  3062. * (7) On STM32F3, parameter not available on all ADC instances: ADC1, ADC2 (for ADC instances ADCx available on the selected device).\n
  3063. * (8) On STM32F3, parameter not available on all ADC instances: ADC3, ADC4 (for ADC instances ADCx available on the selected device).
  3064. */
  3065. __STATIC_INLINE uint32_t LL_ADC_REG_GetTriggerSource(ADC_TypeDef *ADCx)
  3066. {
  3067. register uint32_t TriggerSource = READ_BIT(ADCx->CFGR, ADC_CFGR_EXTSEL | ADC_CFGR_EXTEN);
  3068. /* Value for shift of {0; 4; 8; 12} depending on value of bitfield */
  3069. /* corresponding to ADC_CFGR_EXTEN {0; 1; 2; 3}. */
  3070. register uint32_t ShiftExten = ((TriggerSource & ADC_CFGR_EXTEN) >> (ADC_REG_TRIG_EXTEN_BITOFFSET_POS - 2U));
  3071. /* Set bitfield corresponding to ADC_CFGR_EXTEN and ADC_CFGR_EXTSEL */
  3072. /* to match with triggers literals definition. */
  3073. return ((TriggerSource
  3074. & (ADC_REG_TRIG_SOURCE_MASK >> ShiftExten) & ADC_CFGR_EXTSEL)
  3075. | ((ADC_REG_TRIG_EDGE_MASK >> ShiftExten) & ADC_CFGR_EXTEN)
  3076. );
  3077. }
  3078. /**
  3079. * @brief Get ADC group regular conversion trigger source internal (SW start)
  3080. or external.
  3081. * @note In case of group regular trigger source set to external trigger,
  3082. * to determine which peripheral is selected as external trigger,
  3083. * use function @ref LL_ADC_REG_GetTriggerSource().
  3084. * @rmtoll CFGR EXTEN LL_ADC_REG_IsTriggerSourceSWStart
  3085. * @param ADCx ADC instance
  3086. * @retval Value "0" if trigger source external trigger
  3087. * Value "1" if trigger source SW start.
  3088. */
  3089. __STATIC_INLINE uint32_t LL_ADC_REG_IsTriggerSourceSWStart(ADC_TypeDef *ADCx)
  3090. {
  3091. return (READ_BIT(ADCx->CFGR, ADC_CFGR_EXTEN) == (LL_ADC_REG_TRIG_SOFTWARE & ADC_CFGR_EXTEN));
  3092. }
  3093. /**
  3094. * @brief Set ADC group regular conversion trigger polarity.
  3095. * @note Applicable only for trigger source set to external trigger.
  3096. * @note On this STM32 serie, setting of this feature is conditioned to
  3097. * ADC state:
  3098. * ADC must be disabled or enabled without conversion on going
  3099. * on group regular.
  3100. * @rmtoll CFGR EXTEN LL_ADC_REG_SetTriggerEdge
  3101. * @param ADCx ADC instance
  3102. * @param ExternalTriggerEdge This parameter can be one of the following values:
  3103. * @arg @ref LL_ADC_REG_TRIG_EXT_RISING
  3104. * @arg @ref LL_ADC_REG_TRIG_EXT_FALLING
  3105. * @arg @ref LL_ADC_REG_TRIG_EXT_RISINGFALLING
  3106. * @retval None
  3107. */
  3108. __STATIC_INLINE void LL_ADC_REG_SetTriggerEdge(ADC_TypeDef *ADCx, uint32_t ExternalTriggerEdge)
  3109. {
  3110. MODIFY_REG(ADCx->CFGR, ADC_CFGR_EXTEN, ExternalTriggerEdge);
  3111. }
  3112. /**
  3113. * @brief Get ADC group regular conversion trigger polarity.
  3114. * @note Applicable only for trigger source set to external trigger.
  3115. * @rmtoll CFGR EXTEN LL_ADC_REG_GetTriggerEdge
  3116. * @param ADCx ADC instance
  3117. * @retval Returned value can be one of the following values:
  3118. * @arg @ref LL_ADC_REG_TRIG_EXT_RISING
  3119. * @arg @ref LL_ADC_REG_TRIG_EXT_FALLING
  3120. * @arg @ref LL_ADC_REG_TRIG_EXT_RISINGFALLING
  3121. */
  3122. __STATIC_INLINE uint32_t LL_ADC_REG_GetTriggerEdge(ADC_TypeDef *ADCx)
  3123. {
  3124. return (uint32_t)(READ_BIT(ADCx->CFGR, ADC_CFGR_EXTEN));
  3125. }
  3126. /**
  3127. * @brief Set ADC group regular sequencer length and scan direction.
  3128. * @note Description of ADC group regular sequencer features:
  3129. * - For devices with sequencer fully configurable
  3130. * (function "LL_ADC_REG_SetSequencerRanks()" available):
  3131. * sequencer length and each rank affectation to a channel
  3132. * are configurable.
  3133. * This function performs configuration of:
  3134. * - Sequence length: Number of ranks in the scan sequence.
  3135. * - Sequence direction: Unless specified in parameters, sequencer
  3136. * scan direction is forward (from rank 1 to rank n).
  3137. * Sequencer ranks are selected using
  3138. * function "LL_ADC_REG_SetSequencerRanks()".
  3139. * - For devices with sequencer not fully configurable
  3140. * (function "LL_ADC_REG_SetSequencerChannels()" available):
  3141. * sequencer length and each rank affectation to a channel
  3142. * are defined by channel number.
  3143. * This function performs configuration of:
  3144. * - Sequence length: Number of ranks in the scan sequence is
  3145. * defined by number of channels set in the sequence,
  3146. * rank of each channel is fixed by channel HW number.
  3147. * (channel 0 fixed on rank 0, channel 1 fixed on rank1, ...).
  3148. * - Sequence direction: Unless specified in parameters, sequencer
  3149. * scan direction is forward (from lowest channel number to
  3150. * highest channel number).
  3151. * Sequencer ranks are selected using
  3152. * function "LL_ADC_REG_SetSequencerChannels()".
  3153. * @note Sequencer disabled is equivalent to sequencer of 1 rank:
  3154. * ADC conversion on only 1 channel.
  3155. * @note On this STM32 serie, setting of this feature is conditioned to
  3156. * ADC state:
  3157. * ADC must be disabled or enabled without conversion on going
  3158. * on group regular.
  3159. * @rmtoll SQR1 L LL_ADC_REG_SetSequencerLength
  3160. * @param ADCx ADC instance
  3161. * @param SequencerNbRanks This parameter can be one of the following values:
  3162. * @arg @ref LL_ADC_REG_SEQ_SCAN_DISABLE
  3163. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_2RANKS
  3164. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_3RANKS
  3165. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_4RANKS
  3166. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_5RANKS
  3167. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_6RANKS
  3168. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_7RANKS
  3169. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_8RANKS
  3170. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_9RANKS
  3171. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_10RANKS
  3172. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_11RANKS
  3173. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_12RANKS
  3174. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_13RANKS
  3175. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_14RANKS
  3176. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_15RANKS
  3177. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_16RANKS
  3178. * @retval None
  3179. */
  3180. __STATIC_INLINE void LL_ADC_REG_SetSequencerLength(ADC_TypeDef *ADCx, uint32_t SequencerNbRanks)
  3181. {
  3182. MODIFY_REG(ADCx->SQR1, ADC_SQR1_L, SequencerNbRanks);
  3183. }
  3184. /**
  3185. * @brief Get ADC group regular sequencer length and scan direction.
  3186. * @note Description of ADC group regular sequencer features:
  3187. * - For devices with sequencer fully configurable
  3188. * (function "LL_ADC_REG_SetSequencerRanks()" available):
  3189. * sequencer length and each rank affectation to a channel
  3190. * are configurable.
  3191. * This function retrieves:
  3192. * - Sequence length: Number of ranks in the scan sequence.
  3193. * - Sequence direction: Unless specified in parameters, sequencer
  3194. * scan direction is forward (from rank 1 to rank n).
  3195. * Sequencer ranks are selected using
  3196. * function "LL_ADC_REG_SetSequencerRanks()".
  3197. * - For devices with sequencer not fully configurable
  3198. * (function "LL_ADC_REG_SetSequencerChannels()" available):
  3199. * sequencer length and each rank affectation to a channel
  3200. * are defined by channel number.
  3201. * This function retrieves:
  3202. * - Sequence length: Number of ranks in the scan sequence is
  3203. * defined by number of channels set in the sequence,
  3204. * rank of each channel is fixed by channel HW number.
  3205. * (channel 0 fixed on rank 0, channel 1 fixed on rank1, ...).
  3206. * - Sequence direction: Unless specified in parameters, sequencer
  3207. * scan direction is forward (from lowest channel number to
  3208. * highest channel number).
  3209. * Sequencer ranks are selected using
  3210. * function "LL_ADC_REG_SetSequencerChannels()".
  3211. * @note Sequencer disabled is equivalent to sequencer of 1 rank:
  3212. * ADC conversion on only 1 channel.
  3213. * @rmtoll SQR1 L LL_ADC_REG_GetSequencerLength
  3214. * @param ADCx ADC instance
  3215. * @retval Returned value can be one of the following values:
  3216. * @arg @ref LL_ADC_REG_SEQ_SCAN_DISABLE
  3217. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_2RANKS
  3218. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_3RANKS
  3219. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_4RANKS
  3220. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_5RANKS
  3221. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_6RANKS
  3222. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_7RANKS
  3223. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_8RANKS
  3224. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_9RANKS
  3225. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_10RANKS
  3226. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_11RANKS
  3227. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_12RANKS
  3228. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_13RANKS
  3229. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_14RANKS
  3230. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_15RANKS
  3231. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_16RANKS
  3232. */
  3233. __STATIC_INLINE uint32_t LL_ADC_REG_GetSequencerLength(ADC_TypeDef *ADCx)
  3234. {
  3235. return (uint32_t)(READ_BIT(ADCx->SQR1, ADC_SQR1_L));
  3236. }
  3237. /**
  3238. * @brief Set ADC group regular sequencer discontinuous mode:
  3239. * sequence subdivided and scan conversions interrupted every selected
  3240. * number of ranks.
  3241. * @note It is not possible to enable both ADC group regular
  3242. * continuous mode and sequencer discontinuous mode.
  3243. * @note It is not possible to enable both ADC auto-injected mode
  3244. * and ADC group regular sequencer discontinuous mode.
  3245. * @note On this STM32 serie, setting of this feature is conditioned to
  3246. * ADC state:
  3247. * ADC must be disabled or enabled without conversion on going
  3248. * on group regular.
  3249. * @rmtoll CFGR DISCEN LL_ADC_REG_SetSequencerDiscont\n
  3250. * CFGR DISCNUM LL_ADC_REG_SetSequencerDiscont
  3251. * @param ADCx ADC instance
  3252. * @param SeqDiscont This parameter can be one of the following values:
  3253. * @arg @ref LL_ADC_REG_SEQ_DISCONT_DISABLE
  3254. * @arg @ref LL_ADC_REG_SEQ_DISCONT_1RANK
  3255. * @arg @ref LL_ADC_REG_SEQ_DISCONT_2RANKS
  3256. * @arg @ref LL_ADC_REG_SEQ_DISCONT_3RANKS
  3257. * @arg @ref LL_ADC_REG_SEQ_DISCONT_4RANKS
  3258. * @arg @ref LL_ADC_REG_SEQ_DISCONT_5RANKS
  3259. * @arg @ref LL_ADC_REG_SEQ_DISCONT_6RANKS
  3260. * @arg @ref LL_ADC_REG_SEQ_DISCONT_7RANKS
  3261. * @arg @ref LL_ADC_REG_SEQ_DISCONT_8RANKS
  3262. * @retval None
  3263. */
  3264. __STATIC_INLINE void LL_ADC_REG_SetSequencerDiscont(ADC_TypeDef *ADCx, uint32_t SeqDiscont)
  3265. {
  3266. MODIFY_REG(ADCx->CFGR, ADC_CFGR_DISCEN | ADC_CFGR_DISCNUM, SeqDiscont);
  3267. }
  3268. /**
  3269. * @brief Get ADC group regular sequencer discontinuous mode:
  3270. * sequence subdivided and scan conversions interrupted every selected
  3271. * number of ranks.
  3272. * @rmtoll CFGR DISCEN LL_ADC_REG_GetSequencerDiscont\n
  3273. * CFGR DISCNUM LL_ADC_REG_GetSequencerDiscont
  3274. * @param ADCx ADC instance
  3275. * @retval Returned value can be one of the following values:
  3276. * @arg @ref LL_ADC_REG_SEQ_DISCONT_DISABLE
  3277. * @arg @ref LL_ADC_REG_SEQ_DISCONT_1RANK
  3278. * @arg @ref LL_ADC_REG_SEQ_DISCONT_2RANKS
  3279. * @arg @ref LL_ADC_REG_SEQ_DISCONT_3RANKS
  3280. * @arg @ref LL_ADC_REG_SEQ_DISCONT_4RANKS
  3281. * @arg @ref LL_ADC_REG_SEQ_DISCONT_5RANKS
  3282. * @arg @ref LL_ADC_REG_SEQ_DISCONT_6RANKS
  3283. * @arg @ref LL_ADC_REG_SEQ_DISCONT_7RANKS
  3284. * @arg @ref LL_ADC_REG_SEQ_DISCONT_8RANKS
  3285. */
  3286. __STATIC_INLINE uint32_t LL_ADC_REG_GetSequencerDiscont(ADC_TypeDef *ADCx)
  3287. {
  3288. return (uint32_t)(READ_BIT(ADCx->CFGR, ADC_CFGR_DISCEN | ADC_CFGR_DISCNUM));
  3289. }
  3290. /**
  3291. * @brief Set ADC group regular sequence: channel on the selected
  3292. * scan sequence rank.
  3293. * @note This function performs configuration of:
  3294. * - Channels ordering into each rank of scan sequence:
  3295. * whatever channel can be placed into whatever rank.
  3296. * @note On this STM32 serie, ADC group regular sequencer is
  3297. * fully configurable: sequencer length and each rank
  3298. * affectation to a channel are configurable.
  3299. * Refer to description of function @ref LL_ADC_REG_SetSequencerLength().
  3300. * @note Depending on devices and packages, some channels may not be available.
  3301. * Refer to device datasheet for channels availability.
  3302. * @note On this STM32 serie, to measure internal channels (VrefInt,
  3303. * TempSensor, ...), measurement paths to internal channels must be
  3304. * enabled separately.
  3305. * This can be done using function @ref LL_ADC_SetCommonPathInternalCh().
  3306. * @note On this STM32 serie, setting of this feature is conditioned to
  3307. * ADC state:
  3308. * ADC must be disabled or enabled without conversion on going
  3309. * on group regular.
  3310. * @rmtoll SQR1 SQ1 LL_ADC_REG_SetSequencerRanks\n
  3311. * SQR1 SQ2 LL_ADC_REG_SetSequencerRanks\n
  3312. * SQR1 SQ3 LL_ADC_REG_SetSequencerRanks\n
  3313. * SQR1 SQ4 LL_ADC_REG_SetSequencerRanks\n
  3314. * SQR2 SQ5 LL_ADC_REG_SetSequencerRanks\n
  3315. * SQR2 SQ6 LL_ADC_REG_SetSequencerRanks\n
  3316. * SQR2 SQ7 LL_ADC_REG_SetSequencerRanks\n
  3317. * SQR2 SQ8 LL_ADC_REG_SetSequencerRanks\n
  3318. * SQR2 SQ9 LL_ADC_REG_SetSequencerRanks\n
  3319. * SQR3 SQ10 LL_ADC_REG_SetSequencerRanks\n
  3320. * SQR3 SQ11 LL_ADC_REG_SetSequencerRanks\n
  3321. * SQR3 SQ12 LL_ADC_REG_SetSequencerRanks\n
  3322. * SQR3 SQ13 LL_ADC_REG_SetSequencerRanks\n
  3323. * SQR3 SQ14 LL_ADC_REG_SetSequencerRanks\n
  3324. * SQR4 SQ15 LL_ADC_REG_SetSequencerRanks\n
  3325. * SQR4 SQ16 LL_ADC_REG_SetSequencerRanks
  3326. * @param ADCx ADC instance
  3327. * @param Rank This parameter can be one of the following values:
  3328. * @arg @ref LL_ADC_REG_RANK_1
  3329. * @arg @ref LL_ADC_REG_RANK_2
  3330. * @arg @ref LL_ADC_REG_RANK_3
  3331. * @arg @ref LL_ADC_REG_RANK_4
  3332. * @arg @ref LL_ADC_REG_RANK_5
  3333. * @arg @ref LL_ADC_REG_RANK_6
  3334. * @arg @ref LL_ADC_REG_RANK_7
  3335. * @arg @ref LL_ADC_REG_RANK_8
  3336. * @arg @ref LL_ADC_REG_RANK_9
  3337. * @arg @ref LL_ADC_REG_RANK_10
  3338. * @arg @ref LL_ADC_REG_RANK_11
  3339. * @arg @ref LL_ADC_REG_RANK_12
  3340. * @arg @ref LL_ADC_REG_RANK_13
  3341. * @arg @ref LL_ADC_REG_RANK_14
  3342. * @arg @ref LL_ADC_REG_RANK_15
  3343. * @arg @ref LL_ADC_REG_RANK_16
  3344. * @param Channel This parameter can be one of the following values:
  3345. * @arg @ref LL_ADC_CHANNEL_0
  3346. * @arg @ref LL_ADC_CHANNEL_1
  3347. * @arg @ref LL_ADC_CHANNEL_2
  3348. * @arg @ref LL_ADC_CHANNEL_3
  3349. * @arg @ref LL_ADC_CHANNEL_4
  3350. * @arg @ref LL_ADC_CHANNEL_5
  3351. * @arg @ref LL_ADC_CHANNEL_6
  3352. * @arg @ref LL_ADC_CHANNEL_7
  3353. * @arg @ref LL_ADC_CHANNEL_8
  3354. * @arg @ref LL_ADC_CHANNEL_9
  3355. * @arg @ref LL_ADC_CHANNEL_10
  3356. * @arg @ref LL_ADC_CHANNEL_11
  3357. * @arg @ref LL_ADC_CHANNEL_12
  3358. * @arg @ref LL_ADC_CHANNEL_13
  3359. * @arg @ref LL_ADC_CHANNEL_14
  3360. * @arg @ref LL_ADC_CHANNEL_15
  3361. * @arg @ref LL_ADC_CHANNEL_16
  3362. * @arg @ref LL_ADC_CHANNEL_17
  3363. * @arg @ref LL_ADC_CHANNEL_18
  3364. * @arg @ref LL_ADC_CHANNEL_VREFINT (5)
  3365. * @arg @ref LL_ADC_CHANNEL_TEMPSENSOR (1)
  3366. * @arg @ref LL_ADC_CHANNEL_VBAT (1)
  3367. * @arg @ref LL_ADC_CHANNEL_VOPAMP1 (1)
  3368. * @arg @ref LL_ADC_CHANNEL_VOPAMP2 (2)
  3369. * @arg @ref LL_ADC_CHANNEL_VOPAMP3 (3)
  3370. * @arg @ref LL_ADC_CHANNEL_VOPAMP4 (4)
  3371. *
  3372. * (1) On STM32F3, parameter available only on ADC instance: ADC1.\n
  3373. * (2) On STM32F3, parameter available only on ADC instance: ADC2.\n
  3374. * (3) On STM32F3, parameter available only on ADC instance: ADC3.\n
  3375. * (4) On STM32F3, parameter available only on ADC instances: ADC4.\n
  3376. * (5) On STM32F3, ADC channel available only on all ADC instances, but
  3377. * only one ADC instance is allowed to be connected to VrefInt at the same time.
  3378. * @retval None
  3379. */
  3380. __STATIC_INLINE void LL_ADC_REG_SetSequencerRanks(ADC_TypeDef *ADCx, uint32_t Rank, uint32_t Channel)
  3381. {
  3382. /* Set bits with content of parameter "Channel" with bits position */
  3383. /* in register and register position depending on parameter "Rank". */
  3384. /* Parameters "Rank" and "Channel" are used with masks because containing */
  3385. /* other bits reserved for other purpose. */
  3386. register uint32_t *preg = __ADC_PTR_REG_OFFSET(ADCx->SQR1, __ADC_MASK_SHIFT(Rank, ADC_REG_SQRX_REGOFFSET_MASK));
  3387. MODIFY_REG(*preg,
  3388. ADC_CHANNEL_ID_NUMBER_MASK_POSBIT0 << (Rank & ADC_REG_RANK_ID_SQRX_MASK),
  3389. (Channel & ADC_CHANNEL_ID_NUMBER_MASK) >> (ADC_CHANNEL_ID_NUMBER_BITOFFSET_POS - (Rank & ADC_REG_RANK_ID_SQRX_MASK)));
  3390. }
  3391. /**
  3392. * @brief Get ADC group regular sequence: channel on the selected
  3393. * scan sequence rank.
  3394. * @note On this STM32 serie, ADC group regular sequencer is
  3395. * fully configurable: sequencer length and each rank
  3396. * affectation to a channel are configurable.
  3397. * Refer to description of function @ref LL_ADC_REG_SetSequencerLength().
  3398. * @note Depending on devices and packages, some channels may not be available.
  3399. * Refer to device datasheet for channels availability.
  3400. * @note Usage of the returned channel number:
  3401. * - To reinject this channel into another function LL_ADC_xxx:
  3402. * the returned channel number is only partly formatted on definition
  3403. * of literals LL_ADC_CHANNEL_x. Therefore, it has to be compared
  3404. * with parts of literals LL_ADC_CHANNEL_x or using
  3405. * helper macro @ref __LL_ADC_CHANNEL_TO_DECIMAL_NB().
  3406. * Then the selected literal LL_ADC_CHANNEL_x can be used
  3407. * as parameter for another function.
  3408. * - To get the channel number in decimal format:
  3409. * process the returned value with the helper macro
  3410. * @ref __LL_ADC_CHANNEL_TO_DECIMAL_NB().
  3411. * @rmtoll SQR1 SQ1 LL_ADC_REG_GetSequencerRanks\n
  3412. * SQR1 SQ2 LL_ADC_REG_GetSequencerRanks\n
  3413. * SQR1 SQ3 LL_ADC_REG_GetSequencerRanks\n
  3414. * SQR1 SQ4 LL_ADC_REG_GetSequencerRanks\n
  3415. * SQR2 SQ5 LL_ADC_REG_GetSequencerRanks\n
  3416. * SQR2 SQ6 LL_ADC_REG_GetSequencerRanks\n
  3417. * SQR2 SQ7 LL_ADC_REG_GetSequencerRanks\n
  3418. * SQR2 SQ8 LL_ADC_REG_GetSequencerRanks\n
  3419. * SQR2 SQ9 LL_ADC_REG_GetSequencerRanks\n
  3420. * SQR3 SQ10 LL_ADC_REG_GetSequencerRanks\n
  3421. * SQR3 SQ11 LL_ADC_REG_GetSequencerRanks\n
  3422. * SQR3 SQ12 LL_ADC_REG_GetSequencerRanks\n
  3423. * SQR3 SQ13 LL_ADC_REG_GetSequencerRanks\n
  3424. * SQR3 SQ14 LL_ADC_REG_GetSequencerRanks\n
  3425. * SQR4 SQ15 LL_ADC_REG_GetSequencerRanks\n
  3426. * SQR4 SQ16 LL_ADC_REG_GetSequencerRanks
  3427. * @param ADCx ADC instance
  3428. * @param Rank This parameter can be one of the following values:
  3429. * @arg @ref LL_ADC_REG_RANK_1
  3430. * @arg @ref LL_ADC_REG_RANK_2
  3431. * @arg @ref LL_ADC_REG_RANK_3
  3432. * @arg @ref LL_ADC_REG_RANK_4
  3433. * @arg @ref LL_ADC_REG_RANK_5
  3434. * @arg @ref LL_ADC_REG_RANK_6
  3435. * @arg @ref LL_ADC_REG_RANK_7
  3436. * @arg @ref LL_ADC_REG_RANK_8
  3437. * @arg @ref LL_ADC_REG_RANK_9
  3438. * @arg @ref LL_ADC_REG_RANK_10
  3439. * @arg @ref LL_ADC_REG_RANK_11
  3440. * @arg @ref LL_ADC_REG_RANK_12
  3441. * @arg @ref LL_ADC_REG_RANK_13
  3442. * @arg @ref LL_ADC_REG_RANK_14
  3443. * @arg @ref LL_ADC_REG_RANK_15
  3444. * @arg @ref LL_ADC_REG_RANK_16
  3445. * @retval Returned value can be one of the following values:
  3446. * @arg @ref LL_ADC_CHANNEL_0
  3447. * @arg @ref LL_ADC_CHANNEL_1
  3448. * @arg @ref LL_ADC_CHANNEL_2
  3449. * @arg @ref LL_ADC_CHANNEL_3
  3450. * @arg @ref LL_ADC_CHANNEL_4
  3451. * @arg @ref LL_ADC_CHANNEL_5
  3452. * @arg @ref LL_ADC_CHANNEL_6
  3453. * @arg @ref LL_ADC_CHANNEL_7
  3454. * @arg @ref LL_ADC_CHANNEL_8
  3455. * @arg @ref LL_ADC_CHANNEL_9
  3456. * @arg @ref LL_ADC_CHANNEL_10
  3457. * @arg @ref LL_ADC_CHANNEL_11
  3458. * @arg @ref LL_ADC_CHANNEL_12
  3459. * @arg @ref LL_ADC_CHANNEL_13
  3460. * @arg @ref LL_ADC_CHANNEL_14
  3461. * @arg @ref LL_ADC_CHANNEL_15
  3462. * @arg @ref LL_ADC_CHANNEL_16
  3463. * @arg @ref LL_ADC_CHANNEL_17
  3464. * @arg @ref LL_ADC_CHANNEL_18
  3465. * @arg @ref LL_ADC_CHANNEL_VREFINT (5)
  3466. * @arg @ref LL_ADC_CHANNEL_TEMPSENSOR (1)
  3467. * @arg @ref LL_ADC_CHANNEL_VBAT (1)
  3468. * @arg @ref LL_ADC_CHANNEL_VOPAMP1 (1)
  3469. * @arg @ref LL_ADC_CHANNEL_VOPAMP2 (2)
  3470. * @arg @ref LL_ADC_CHANNEL_VOPAMP3 (3)
  3471. * @arg @ref LL_ADC_CHANNEL_VOPAMP4 (4)
  3472. *
  3473. * (1) On STM32F3, parameter available only on ADC instance: ADC1.\n
  3474. * (2) On STM32F3, parameter available only on ADC instance: ADC2.\n
  3475. * (3) On STM32F3, parameter available only on ADC instance: ADC3.\n
  3476. * (4) On STM32F3, parameter available only on ADC instances: ADC4.\n
  3477. * (5) On STM32F3, ADC channel available only on all ADC instances, but
  3478. * only one ADC instance is allowed to be connected to VrefInt at the same time.\n
  3479. * (1, 2, 3, 4, 5) For ADC channel read back from ADC register,
  3480. * comparison with internal channel parameter to be done
  3481. * using helper macro @ref __LL_ADC_CHANNEL_INTERNAL_TO_EXTERNAL().
  3482. */
  3483. __STATIC_INLINE uint32_t LL_ADC_REG_GetSequencerRanks(ADC_TypeDef *ADCx, uint32_t Rank)
  3484. {
  3485. register uint32_t *preg = __ADC_PTR_REG_OFFSET(ADCx->SQR1, __ADC_MASK_SHIFT(Rank, ADC_REG_SQRX_REGOFFSET_MASK));
  3486. return (uint32_t) (READ_BIT(*preg,
  3487. ADC_CHANNEL_ID_NUMBER_MASK_POSBIT0 << (Rank & ADC_REG_RANK_ID_SQRX_MASK))
  3488. << (ADC_CHANNEL_ID_NUMBER_BITOFFSET_POS - (Rank & ADC_REG_RANK_ID_SQRX_MASK))
  3489. );
  3490. }
  3491. /**
  3492. * @brief Set ADC continuous conversion mode on ADC group regular.
  3493. * @note Description of ADC continuous conversion mode:
  3494. * - single mode: one conversion per trigger
  3495. * - continuous mode: after the first trigger, following
  3496. * conversions launched successively automatically.
  3497. * @note It is not possible to enable both ADC group regular
  3498. * continuous mode and sequencer discontinuous mode.
  3499. * @note On this STM32 serie, setting of this feature is conditioned to
  3500. * ADC state:
  3501. * ADC must be disabled or enabled without conversion on going
  3502. * on group regular.
  3503. * @rmtoll CFGR CONT LL_ADC_REG_SetContinuousMode
  3504. * @param ADCx ADC instance
  3505. * @param Continuous This parameter can be one of the following values:
  3506. * @arg @ref LL_ADC_REG_CONV_SINGLE
  3507. * @arg @ref LL_ADC_REG_CONV_CONTINUOUS
  3508. * @retval None
  3509. */
  3510. __STATIC_INLINE void LL_ADC_REG_SetContinuousMode(ADC_TypeDef *ADCx, uint32_t Continuous)
  3511. {
  3512. MODIFY_REG(ADCx->CFGR, ADC_CFGR_CONT, Continuous);
  3513. }
  3514. /**
  3515. * @brief Get ADC continuous conversion mode on ADC group regular.
  3516. * @note Description of ADC continuous conversion mode:
  3517. * - single mode: one conversion per trigger
  3518. * - continuous mode: after the first trigger, following
  3519. * conversions launched successively automatically.
  3520. * @rmtoll CFGR CONT LL_ADC_REG_GetContinuousMode
  3521. * @param ADCx ADC instance
  3522. * @retval Returned value can be one of the following values:
  3523. * @arg @ref LL_ADC_REG_CONV_SINGLE
  3524. * @arg @ref LL_ADC_REG_CONV_CONTINUOUS
  3525. */
  3526. __STATIC_INLINE uint32_t LL_ADC_REG_GetContinuousMode(ADC_TypeDef *ADCx)
  3527. {
  3528. return (uint32_t)(READ_BIT(ADCx->CFGR, ADC_CFGR_CONT));
  3529. }
  3530. /**
  3531. * @brief Set ADC group regular conversion data transfer: no transfer or
  3532. * transfer by DMA, and DMA requests mode.
  3533. * @note If transfer by DMA selected, specifies the DMA requests
  3534. * mode:
  3535. * - Limited mode (One shot mode): DMA transfer requests are stopped
  3536. * when number of DMA data transfers (number of
  3537. * ADC conversions) is reached.
  3538. * This ADC mode is intended to be used with DMA mode non-circular.
  3539. * - Unlimited mode: DMA transfer requests are unlimited,
  3540. * whatever number of DMA data transfers (number of
  3541. * ADC conversions).
  3542. * This ADC mode is intended to be used with DMA mode circular.
  3543. * @note If ADC DMA requests mode is set to unlimited and DMA is set to
  3544. * mode non-circular:
  3545. * when DMA transfers size will be reached, DMA will stop transfers of
  3546. * ADC conversions data ADC will raise an overrun error
  3547. * (overrun flag and interruption if enabled).
  3548. * @note For devices with several ADC instances: ADC multimode DMA
  3549. * settings are available using function @ref LL_ADC_SetMultiDMATransfer().
  3550. * @note To configure DMA source address (peripheral address),
  3551. * use function @ref LL_ADC_DMA_GetRegAddr().
  3552. * @note On this STM32 serie, setting of this feature is conditioned to
  3553. * ADC state:
  3554. * ADC must be disabled or enabled without conversion on going
  3555. * on either groups regular or injected.
  3556. * @rmtoll CFGR DMAEN LL_ADC_REG_SetDMATransfer\n
  3557. * CFGR DMACFG LL_ADC_REG_SetDMATransfer
  3558. * @param ADCx ADC instance
  3559. * @param DMATransfer This parameter can be one of the following values:
  3560. * @arg @ref LL_ADC_REG_DMA_TRANSFER_NONE
  3561. * @arg @ref LL_ADC_REG_DMA_TRANSFER_LIMITED
  3562. * @arg @ref LL_ADC_REG_DMA_TRANSFER_UNLIMITED
  3563. * @retval None
  3564. */
  3565. __STATIC_INLINE void LL_ADC_REG_SetDMATransfer(ADC_TypeDef *ADCx, uint32_t DMATransfer)
  3566. {
  3567. MODIFY_REG(ADCx->CFGR, ADC_CFGR_DMAEN | ADC_CFGR_DMACFG, DMATransfer);
  3568. }
  3569. /**
  3570. * @brief Get ADC group regular conversion data transfer: no transfer or
  3571. * transfer by DMA, and DMA requests mode.
  3572. * @note If transfer by DMA selected, specifies the DMA requests
  3573. * mode:
  3574. * - Limited mode (One shot mode): DMA transfer requests are stopped
  3575. * when number of DMA data transfers (number of
  3576. * ADC conversions) is reached.
  3577. * This ADC mode is intended to be used with DMA mode non-circular.
  3578. * - Unlimited mode: DMA transfer requests are unlimited,
  3579. * whatever number of DMA data transfers (number of
  3580. * ADC conversions).
  3581. * This ADC mode is intended to be used with DMA mode circular.
  3582. * @note If ADC DMA requests mode is set to unlimited and DMA is set to
  3583. * mode non-circular:
  3584. * when DMA transfers size will be reached, DMA will stop transfers of
  3585. * ADC conversions data ADC will raise an overrun error
  3586. * (overrun flag and interruption if enabled).
  3587. * @note For devices with several ADC instances: ADC multimode DMA
  3588. * settings are available using function @ref LL_ADC_GetMultiDMATransfer().
  3589. * @note To configure DMA source address (peripheral address),
  3590. * use function @ref LL_ADC_DMA_GetRegAddr().
  3591. * @rmtoll CFGR DMAEN LL_ADC_REG_GetDMATransfer\n
  3592. * CFGR DMACFG LL_ADC_REG_GetDMATransfer
  3593. * @param ADCx ADC instance
  3594. * @retval Returned value can be one of the following values:
  3595. * @arg @ref LL_ADC_REG_DMA_TRANSFER_NONE
  3596. * @arg @ref LL_ADC_REG_DMA_TRANSFER_LIMITED
  3597. * @arg @ref LL_ADC_REG_DMA_TRANSFER_UNLIMITED
  3598. */
  3599. __STATIC_INLINE uint32_t LL_ADC_REG_GetDMATransfer(ADC_TypeDef *ADCx)
  3600. {
  3601. return (uint32_t)(READ_BIT(ADCx->CFGR, ADC_CFGR_DMAEN | ADC_CFGR_DMACFG));
  3602. }
  3603. /**
  3604. * @brief Set ADC group regular behavior in case of overrun:
  3605. * data preserved or overwritten.
  3606. * @note Compatibility with devices without feature overrun:
  3607. * other devices without this feature have a behavior
  3608. * equivalent to data overwritten.
  3609. * The default setting of overrun is data preserved.
  3610. * Therefore, for compatibility with all devices, parameter
  3611. * overrun should be set to data overwritten.
  3612. * @note On this STM32 serie, setting of this feature is conditioned to
  3613. * ADC state:
  3614. * ADC must be disabled or enabled without conversion on going
  3615. * on group regular.
  3616. * @rmtoll CFGR OVRMOD LL_ADC_REG_SetOverrun
  3617. * @param ADCx ADC instance
  3618. * @param Overrun This parameter can be one of the following values:
  3619. * @arg @ref LL_ADC_REG_OVR_DATA_PRESERVED
  3620. * @arg @ref LL_ADC_REG_OVR_DATA_OVERWRITTEN
  3621. * @retval None
  3622. */
  3623. __STATIC_INLINE void LL_ADC_REG_SetOverrun(ADC_TypeDef *ADCx, uint32_t Overrun)
  3624. {
  3625. MODIFY_REG(ADCx->CFGR, ADC_CFGR_OVRMOD, Overrun);
  3626. }
  3627. /**
  3628. * @brief Get ADC group regular behavior in case of overrun:
  3629. * data preserved or overwritten.
  3630. * @rmtoll CFGR OVRMOD LL_ADC_REG_GetOverrun
  3631. * @param ADCx ADC instance
  3632. * @retval Returned value can be one of the following values:
  3633. * @arg @ref LL_ADC_REG_OVR_DATA_PRESERVED
  3634. * @arg @ref LL_ADC_REG_OVR_DATA_OVERWRITTEN
  3635. */
  3636. __STATIC_INLINE uint32_t LL_ADC_REG_GetOverrun(ADC_TypeDef *ADCx)
  3637. {
  3638. return (uint32_t)(READ_BIT(ADCx->CFGR, ADC_CFGR_OVRMOD));
  3639. }
  3640. /**
  3641. * @}
  3642. */
  3643. /** @defgroup ADC_LL_EF_Configuration_ADC_Group_Injected Configuration of ADC hierarchical scope: group injected
  3644. * @{
  3645. */
  3646. /**
  3647. * @brief Set ADC group injected conversion trigger source:
  3648. * internal (SW start) or from external IP (timer event,
  3649. * external interrupt line).
  3650. * @note On this STM32 serie, setting trigger source to external trigger
  3651. * also set trigger polarity to rising edge
  3652. * (default setting for compatibility with some ADC on other
  3653. * STM32 families having this setting set by HW default value).
  3654. * In case of need to modify trigger edge, use
  3655. * function @ref LL_ADC_INJ_SetTriggerEdge().
  3656. * @note Caution to ADC group injected contexts queue: On this STM32 serie,
  3657. * using successively several times this function will appear has
  3658. * having no effect.
  3659. * This is due to ADC group injected contexts queue (this feature
  3660. * cannot be disabled on this STM32 serie).
  3661. * To set several features of ADC group injected, use
  3662. * function @ref LL_ADC_INJ_ConfigQueueContext().
  3663. * @note Availability of parameters of trigger sources from timer
  3664. * depends on timers availability on the selected device.
  3665. * @note On this STM32 serie, setting of this feature is conditioned to
  3666. * ADC state:
  3667. * ADC must not be disabled. Can be enabled with or without conversion
  3668. * on going on either groups regular or injected.
  3669. * @rmtoll JSQR JEXTSEL LL_ADC_INJ_SetTriggerSource\n
  3670. * JSQR JEXTEN LL_ADC_INJ_SetTriggerSource
  3671. * @param ADCx ADC instance
  3672. * @param TriggerSource This parameter can be one of the following values:
  3673. * @arg @ref LL_ADC_INJ_TRIG_SOFTWARE
  3674. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM1_TRGO
  3675. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM1_TRGO2
  3676. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM1_CH3_ADC34 (1)(2) (8)
  3677. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM1_CH4
  3678. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM2_TRGO (3)(4)(5)
  3679. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM2_TRGO_ADC12 (1)(2) (7)
  3680. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM2_TRGO__ADC34 (1)(2) (8)
  3681. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM2_CH1 (3)(4)(5)
  3682. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM2_CH1_ADC12 (1)(2) (7)
  3683. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM3_TRGO (1)(2)(3)(4)(5)
  3684. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM3_CH1 (3)(4)(5)
  3685. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM3_CH1_ADC12 (1)(2) (7)
  3686. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM3_CH3 (3)(4)(5)
  3687. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM3_CH3_ADC12 (1)(2) (7)
  3688. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM3_CH4 (3)(4)(5)
  3689. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM3_CH4_ADC12 (1)(2)(3)(4)(5) (7)
  3690. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM4_TRGO (3) (5)
  3691. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM4_TRGO_ADC12 (1)(2) (7)
  3692. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM4_TRGO__ADC34 (1)(2) (8)
  3693. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM4_CH3_ADC34 (1)(2) (8)
  3694. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM4_CH4_ADC34 (1)(2) (8)
  3695. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM6_TRGO (3)(4)(5)
  3696. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM6_TRGO_ADC12 (1)(2) (7)
  3697. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM7_TRGO_ADC34 (1)(2) (8)
  3698. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM8_TRGO (1)(2)
  3699. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM8_TRGO2 (1)(2)
  3700. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM8_CH2_ADC34 (1)(2) (8)
  3701. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM8_CH4_ADC12 (1)(2) (7)
  3702. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM8_CH4__ADC34 (1)(2) (8)
  3703. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM15_TRGO
  3704. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM20_TRGO_ADC12 (1) (7)
  3705. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM20_TRGO2_ADC12 (1) (7)
  3706. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM20_CH4_ADC12 (1) (7)
  3707. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM20_TRG_ADC34 (1) (8)
  3708. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM20_TRG2_ADC34 (1) (8)
  3709. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM20_CH2_ADC34 (1) (8)
  3710. * @arg @ref LL_ADC_INJ_TRIG_EXT_HRTIM_TRG2 (4)
  3711. * @arg @ref LL_ADC_INJ_TRIG_EXT_HRTIM_TRG4 (4)
  3712. * @arg @ref LL_ADC_INJ_TRIG_EXT_EXTI_LINE15 (3)(4)(5)(6)
  3713. * @arg @ref LL_ADC_INJ_TRIG_EXT_EXTI_LINE15_ADC12 (1)(2) (7)
  3714. *
  3715. * (1) On STM32F3, parameter not available on all devices: among others, on STM32F303xE, STM32F398xx.\n
  3716. * (2) On STM32F3, parameter not available on all devices: among others, on STM32F303xC, STM32F358xx.\n
  3717. * (3) On STM32F3, parameter not available on all devices: among others, on STM32F303x8, STM32F328xx.\n
  3718. * (4) On STM32F3, parameter not available on all devices: among others, on STM32F334x8.\n
  3719. * (5) On STM32F3, parameter not available on all devices: among others, on STM32F302xC, STM32F302xE.\n
  3720. * (6) On STM32F3, parameter not available on all devices: among others, on STM32F301x8, STM32F302x8, STM32F318xx.\n
  3721. * (7) On STM32F3, parameter not available on all ADC instances: ADC1, ADC2 (for ADC instances ADCx available on the selected device).\n
  3722. * (8) On STM32F3, parameter not available on all ADC instances: ADC3, ADC4 (for ADC instances ADCx available on the selected device).
  3723. * @retval None
  3724. */
  3725. __STATIC_INLINE void LL_ADC_INJ_SetTriggerSource(ADC_TypeDef *ADCx, uint32_t TriggerSource)
  3726. {
  3727. MODIFY_REG(ADCx->JSQR, ADC_JSQR_JEXTSEL | ADC_JSQR_JEXTEN, TriggerSource);
  3728. }
  3729. /**
  3730. * @brief Get ADC group injected conversion trigger source:
  3731. * internal (SW start) or from external IP (timer event,
  3732. * external interrupt line).
  3733. * @note To determine whether group injected trigger source is
  3734. * internal (SW start) or external, without detail
  3735. * of which peripheral is selected as external trigger,
  3736. * (equivalent to
  3737. * "if(LL_ADC_INJ_GetTriggerSource(ADC1) == LL_ADC_INJ_TRIG_SOFTWARE)")
  3738. * use function @ref LL_ADC_INJ_IsTriggerSourceSWStart.
  3739. * @note Availability of parameters of trigger sources from timer
  3740. * depends on timers availability on the selected device.
  3741. * @rmtoll JSQR JEXTSEL LL_ADC_INJ_GetTriggerSource\n
  3742. * JSQR JEXTEN LL_ADC_INJ_GetTriggerSource
  3743. * @param ADCx ADC instance
  3744. * @retval Returned value can be one of the following values:
  3745. * @arg @ref LL_ADC_INJ_TRIG_SOFTWARE
  3746. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM1_TRGO
  3747. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM1_TRGO2
  3748. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM1_CH3_ADC34 (1)(2) (8)
  3749. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM1_CH4
  3750. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM2_TRGO (3)(4)(5)
  3751. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM2_TRGO_ADC12 (1)(2) (7)
  3752. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM2_TRGO__ADC34 (1)(2) (8)
  3753. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM2_CH1 (3)(4)(5)
  3754. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM2_CH1_ADC12 (1)(2) (7)
  3755. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM3_TRGO (1)(2)(3)(4)(5)
  3756. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM3_CH1 (3)(4)(5)
  3757. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM3_CH1_ADC12 (1)(2) (7)
  3758. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM3_CH3 (3)(4)(5)
  3759. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM3_CH3_ADC12 (1)(2) (7)
  3760. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM3_CH4 (3)(4)(5)
  3761. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM3_CH4_ADC12 (1)(2)(3)(4)(5) (7)
  3762. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM4_TRGO (3) (5)
  3763. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM4_TRGO_ADC12 (1)(2) (7)
  3764. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM4_TRGO__ADC34 (1)(2) (8)
  3765. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM4_CH3_ADC34 (1)(2) (8)
  3766. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM4_CH4_ADC34 (1)(2) (8)
  3767. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM6_TRGO (3)(4)(5)
  3768. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM6_TRGO_ADC12 (1)(2) (7)
  3769. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM7_TRGO_ADC34 (1)(2) (8)
  3770. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM8_TRGO (1)(2)
  3771. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM8_TRGO2 (1)(2)
  3772. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM8_CH2_ADC34 (1)(2) (8)
  3773. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM8_CH4_ADC12 (1)(2) (7)
  3774. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM8_CH4__ADC34 (1)(2) (8)
  3775. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM15_TRGO
  3776. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM20_TRGO_ADC12 (1) (7)
  3777. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM20_TRGO2_ADC12 (1) (7)
  3778. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM20_CH4_ADC12 (1) (7)
  3779. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM20_TRG_ADC34 (1) (8)
  3780. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM20_TRG2_ADC34 (1) (8)
  3781. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM20_CH2_ADC34 (1) (8)
  3782. * @arg @ref LL_ADC_INJ_TRIG_EXT_HRTIM_TRG2 (4)
  3783. * @arg @ref LL_ADC_INJ_TRIG_EXT_HRTIM_TRG4 (4)
  3784. * @arg @ref LL_ADC_INJ_TRIG_EXT_EXTI_LINE15 (3)(4)(5)(6)
  3785. * @arg @ref LL_ADC_INJ_TRIG_EXT_EXTI_LINE15_ADC12 (1)(2) (7)
  3786. *
  3787. * (1) On STM32F3, parameter not available on all devices: among others, on STM32F303xE, STM32F398xx.\n
  3788. * (2) On STM32F3, parameter not available on all devices: among others, on STM32F303xC, STM32F358xx.\n
  3789. * (3) On STM32F3, parameter not available on all devices: among others, on STM32F303x8, STM32F328xx.\n
  3790. * (4) On STM32F3, parameter not available on all devices: among others, on STM32F334x8.\n
  3791. * (5) On STM32F3, parameter not available on all devices: among others, on STM32F302xC, STM32F302xE.\n
  3792. * (6) On STM32F3, parameter not available on all devices: among others, on STM32F301x8, STM32F302x8, STM32F318xx.\n
  3793. * (7) On STM32F3, parameter not available on all ADC instances: ADC1, ADC2 (for ADC instances ADCx available on the selected device).\n
  3794. * (8) On STM32F3, parameter not available on all ADC instances: ADC3, ADC4 (for ADC instances ADCx available on the selected device).
  3795. */
  3796. __STATIC_INLINE uint32_t LL_ADC_INJ_GetTriggerSource(ADC_TypeDef *ADCx)
  3797. {
  3798. register uint32_t TriggerSource = READ_BIT(ADCx->JSQR, ADC_JSQR_JEXTSEL | ADC_JSQR_JEXTEN);
  3799. /* Value for shift of {0; 4; 8; 12} depending on value of bitfield */
  3800. /* corresponding to ADC_JSQR_JEXTEN {0; 1; 2; 3}. */
  3801. register uint32_t ShiftJexten = ((TriggerSource & ADC_JSQR_JEXTEN) >> (ADC_INJ_TRIG_EXTEN_BITOFFSET_POS - 2U));
  3802. /* Set bitfield corresponding to ADC_JSQR_JEXTEN and ADC_JSQR_JEXTSEL */
  3803. /* to match with triggers literals definition. */
  3804. return ((TriggerSource
  3805. & (ADC_INJ_TRIG_SOURCE_MASK >> ShiftJexten) & ADC_JSQR_JEXTSEL)
  3806. | ((ADC_INJ_TRIG_EDGE_MASK >> ShiftJexten) & ADC_JSQR_JEXTEN)
  3807. );
  3808. }
  3809. /**
  3810. * @brief Get ADC group injected conversion trigger source internal (SW start)
  3811. or external
  3812. * @note In case of group injected trigger source set to external trigger,
  3813. * to determine which peripheral is selected as external trigger,
  3814. * use function @ref LL_ADC_INJ_GetTriggerSource.
  3815. * @rmtoll JSQR JEXTEN LL_ADC_INJ_IsTriggerSourceSWStart
  3816. * @param ADCx ADC instance
  3817. * @retval Value "0" if trigger source external trigger
  3818. * Value "1" if trigger source SW start.
  3819. */
  3820. __STATIC_INLINE uint32_t LL_ADC_INJ_IsTriggerSourceSWStart(ADC_TypeDef *ADCx)
  3821. {
  3822. return (READ_BIT(ADCx->JSQR, ADC_JSQR_JEXTEN) == (LL_ADC_INJ_TRIG_SOFTWARE & ADC_JSQR_JEXTEN));
  3823. }
  3824. /**
  3825. * @brief Set ADC group injected conversion trigger polarity.
  3826. * Applicable only for trigger source set to external trigger.
  3827. * @note On this STM32 serie, setting of this feature is conditioned to
  3828. * ADC state:
  3829. * ADC must not be disabled. Can be enabled with or without conversion
  3830. * on going on either groups regular or injected.
  3831. * @rmtoll JSQR JEXTEN LL_ADC_INJ_SetTriggerEdge
  3832. * @param ADCx ADC instance
  3833. * @param ExternalTriggerEdge This parameter can be one of the following values:
  3834. * @arg @ref LL_ADC_INJ_TRIG_EXT_RISING
  3835. * @arg @ref LL_ADC_INJ_TRIG_EXT_FALLING
  3836. * @arg @ref LL_ADC_INJ_TRIG_EXT_RISINGFALLING
  3837. * @retval None
  3838. */
  3839. __STATIC_INLINE void LL_ADC_INJ_SetTriggerEdge(ADC_TypeDef *ADCx, uint32_t ExternalTriggerEdge)
  3840. {
  3841. MODIFY_REG(ADCx->JSQR, ADC_JSQR_JEXTEN, ExternalTriggerEdge);
  3842. }
  3843. /**
  3844. * @brief Get ADC group injected conversion trigger polarity.
  3845. * Applicable only for trigger source set to external trigger.
  3846. * @rmtoll JSQR JEXTEN LL_ADC_INJ_GetTriggerEdge
  3847. * @param ADCx ADC instance
  3848. * @retval Returned value can be one of the following values:
  3849. * @arg @ref LL_ADC_INJ_TRIG_EXT_RISING
  3850. * @arg @ref LL_ADC_INJ_TRIG_EXT_FALLING
  3851. * @arg @ref LL_ADC_INJ_TRIG_EXT_RISINGFALLING
  3852. */
  3853. __STATIC_INLINE uint32_t LL_ADC_INJ_GetTriggerEdge(ADC_TypeDef *ADCx)
  3854. {
  3855. return (uint32_t)(READ_BIT(ADCx->JSQR, ADC_JSQR_JEXTEN));
  3856. }
  3857. /**
  3858. * @brief Set ADC group injected sequencer length and scan direction.
  3859. * @note This function performs configuration of:
  3860. * - Sequence length: Number of ranks in the scan sequence.
  3861. * - Sequence direction: Unless specified in parameters, sequencer
  3862. * scan direction is forward (from rank 1 to rank n).
  3863. * @note Sequencer disabled is equivalent to sequencer of 1 rank:
  3864. * ADC conversion on only 1 channel.
  3865. * @note Caution to ADC group injected contexts queue: On this STM32 serie,
  3866. * using successively several times this function will appear has
  3867. * having no effect.
  3868. * This is due to ADC group injected contexts queue (this feature
  3869. * cannot be disabled on this STM32 serie).
  3870. * To set several features of ADC group injected, use
  3871. * function @ref LL_ADC_INJ_ConfigQueueContext().
  3872. * @note On this STM32 serie, setting of this feature is conditioned to
  3873. * ADC state:
  3874. * ADC must not be disabled. Can be enabled with or without conversion
  3875. * on going on either groups regular or injected.
  3876. * @rmtoll JSQR JL LL_ADC_INJ_SetSequencerLength
  3877. * @param ADCx ADC instance
  3878. * @param SequencerNbRanks This parameter can be one of the following values:
  3879. * @arg @ref LL_ADC_INJ_SEQ_SCAN_DISABLE
  3880. * @arg @ref LL_ADC_INJ_SEQ_SCAN_ENABLE_2RANKS
  3881. * @arg @ref LL_ADC_INJ_SEQ_SCAN_ENABLE_3RANKS
  3882. * @arg @ref LL_ADC_INJ_SEQ_SCAN_ENABLE_4RANKS
  3883. * @retval None
  3884. */
  3885. __STATIC_INLINE void LL_ADC_INJ_SetSequencerLength(ADC_TypeDef *ADCx, uint32_t SequencerNbRanks)
  3886. {
  3887. MODIFY_REG(ADCx->JSQR, ADC_JSQR_JL, SequencerNbRanks);
  3888. }
  3889. /**
  3890. * @brief Get ADC group injected sequencer length and scan direction.
  3891. * @note This function retrieves:
  3892. * - Sequence length: Number of ranks in the scan sequence.
  3893. * - Sequence direction: Unless specified in parameters, sequencer
  3894. * scan direction is forward (from rank 1 to rank n).
  3895. * @note Sequencer disabled is equivalent to sequencer of 1 rank:
  3896. * ADC conversion on only 1 channel.
  3897. * @rmtoll JSQR JL LL_ADC_INJ_GetSequencerLength
  3898. * @param ADCx ADC instance
  3899. * @retval Returned value can be one of the following values:
  3900. * @arg @ref LL_ADC_INJ_SEQ_SCAN_DISABLE
  3901. * @arg @ref LL_ADC_INJ_SEQ_SCAN_ENABLE_2RANKS
  3902. * @arg @ref LL_ADC_INJ_SEQ_SCAN_ENABLE_3RANKS
  3903. * @arg @ref LL_ADC_INJ_SEQ_SCAN_ENABLE_4RANKS
  3904. */
  3905. __STATIC_INLINE uint32_t LL_ADC_INJ_GetSequencerLength(ADC_TypeDef *ADCx)
  3906. {
  3907. return (uint32_t)(READ_BIT(ADCx->JSQR, ADC_JSQR_JL));
  3908. }
  3909. /**
  3910. * @brief Set ADC group injected sequencer discontinuous mode:
  3911. * sequence subdivided and scan conversions interrupted every selected
  3912. * number of ranks.
  3913. * @note It is not possible to enable both ADC group injected
  3914. * auto-injected mode and sequencer discontinuous mode.
  3915. * @rmtoll CFGR JDISCEN LL_ADC_INJ_SetSequencerDiscont
  3916. * @param ADCx ADC instance
  3917. * @param SeqDiscont This parameter can be one of the following values:
  3918. * @arg @ref LL_ADC_INJ_SEQ_DISCONT_DISABLE
  3919. * @arg @ref LL_ADC_INJ_SEQ_DISCONT_1RANK
  3920. * @retval None
  3921. */
  3922. __STATIC_INLINE void LL_ADC_INJ_SetSequencerDiscont(ADC_TypeDef *ADCx, uint32_t SeqDiscont)
  3923. {
  3924. MODIFY_REG(ADCx->CFGR, ADC_CFGR_JDISCEN, SeqDiscont);
  3925. }
  3926. /**
  3927. * @brief Get ADC group injected sequencer discontinuous mode:
  3928. * sequence subdivided and scan conversions interrupted every selected
  3929. * number of ranks.
  3930. * @rmtoll CFGR JDISCEN LL_ADC_INJ_GetSequencerDiscont
  3931. * @param ADCx ADC instance
  3932. * @retval Returned value can be one of the following values:
  3933. * @arg @ref LL_ADC_INJ_SEQ_DISCONT_DISABLE
  3934. * @arg @ref LL_ADC_INJ_SEQ_DISCONT_1RANK
  3935. */
  3936. __STATIC_INLINE uint32_t LL_ADC_INJ_GetSequencerDiscont(ADC_TypeDef *ADCx)
  3937. {
  3938. return (uint32_t)(READ_BIT(ADCx->CFGR, ADC_CFGR_JDISCEN));
  3939. }
  3940. /**
  3941. * @brief Set ADC group injected sequence: channel on the selected
  3942. * sequence rank.
  3943. * @note Depending on devices and packages, some channels may not be available.
  3944. * Refer to device datasheet for channels availability.
  3945. * @note On this STM32 serie, to measure internal channels (VrefInt,
  3946. * TempSensor, ...), measurement paths to internal channels must be
  3947. * enabled separately.
  3948. * This can be done using function @ref LL_ADC_SetCommonPathInternalCh().
  3949. * @note Caution to ADC group injected contexts queue: On this STM32 serie,
  3950. * using successively several times this function will appear has
  3951. * having no effect.
  3952. * This is due to ADC group injected contexts queue (this feature
  3953. * cannot be disabled on this STM32 serie).
  3954. * To set several features of ADC group injected, use
  3955. * function @ref LL_ADC_INJ_ConfigQueueContext().
  3956. * @note On this STM32 serie, setting of this feature is conditioned to
  3957. * ADC state:
  3958. * ADC must not be disabled. Can be enabled with or without conversion
  3959. * on going on either groups regular or injected.
  3960. * @rmtoll JSQR JSQ1 LL_ADC_INJ_SetSequencerRanks\n
  3961. * JSQR JSQ2 LL_ADC_INJ_SetSequencerRanks\n
  3962. * JSQR JSQ3 LL_ADC_INJ_SetSequencerRanks\n
  3963. * JSQR JSQ4 LL_ADC_INJ_SetSequencerRanks
  3964. * @param ADCx ADC instance
  3965. * @param Rank This parameter can be one of the following values:
  3966. * @arg @ref LL_ADC_INJ_RANK_1
  3967. * @arg @ref LL_ADC_INJ_RANK_2
  3968. * @arg @ref LL_ADC_INJ_RANK_3
  3969. * @arg @ref LL_ADC_INJ_RANK_4
  3970. * @param Channel This parameter can be one of the following values:
  3971. * @arg @ref LL_ADC_CHANNEL_0
  3972. * @arg @ref LL_ADC_CHANNEL_1
  3973. * @arg @ref LL_ADC_CHANNEL_2
  3974. * @arg @ref LL_ADC_CHANNEL_3
  3975. * @arg @ref LL_ADC_CHANNEL_4
  3976. * @arg @ref LL_ADC_CHANNEL_5
  3977. * @arg @ref LL_ADC_CHANNEL_6
  3978. * @arg @ref LL_ADC_CHANNEL_7
  3979. * @arg @ref LL_ADC_CHANNEL_8
  3980. * @arg @ref LL_ADC_CHANNEL_9
  3981. * @arg @ref LL_ADC_CHANNEL_10
  3982. * @arg @ref LL_ADC_CHANNEL_11
  3983. * @arg @ref LL_ADC_CHANNEL_12
  3984. * @arg @ref LL_ADC_CHANNEL_13
  3985. * @arg @ref LL_ADC_CHANNEL_14
  3986. * @arg @ref LL_ADC_CHANNEL_15
  3987. * @arg @ref LL_ADC_CHANNEL_16
  3988. * @arg @ref LL_ADC_CHANNEL_17
  3989. * @arg @ref LL_ADC_CHANNEL_18
  3990. * @arg @ref LL_ADC_CHANNEL_VREFINT (5)
  3991. * @arg @ref LL_ADC_CHANNEL_TEMPSENSOR (1)
  3992. * @arg @ref LL_ADC_CHANNEL_VBAT (1)
  3993. * @arg @ref LL_ADC_CHANNEL_VOPAMP1 (1)
  3994. * @arg @ref LL_ADC_CHANNEL_VOPAMP2 (2)
  3995. * @arg @ref LL_ADC_CHANNEL_VOPAMP3 (3)
  3996. * @arg @ref LL_ADC_CHANNEL_VOPAMP4 (4)
  3997. *
  3998. * (1) On STM32F3, parameter available only on ADC instance: ADC1.\n
  3999. * (2) On STM32F3, parameter available only on ADC instance: ADC2.\n
  4000. * (3) On STM32F3, parameter available only on ADC instance: ADC3.\n
  4001. * (4) On STM32F3, parameter available only on ADC instances: ADC4.\n
  4002. * (5) On STM32F3, ADC channel available only on all ADC instances, but
  4003. * only one ADC instance is allowed to be connected to VrefInt at the same time.
  4004. * @retval None
  4005. */
  4006. __STATIC_INLINE void LL_ADC_INJ_SetSequencerRanks(ADC_TypeDef *ADCx, uint32_t Rank, uint32_t Channel)
  4007. {
  4008. /* Set bits with content of parameter "Channel" with bits position */
  4009. /* in register depending on parameter "Rank". */
  4010. /* Parameters "Rank" and "Channel" are used with masks because containing */
  4011. /* other bits reserved for other purpose. */
  4012. MODIFY_REG(ADCx->JSQR,
  4013. ADC_CHANNEL_ID_NUMBER_MASK >> (ADC_CHANNEL_ID_NUMBER_BITOFFSET_POS - (Rank & ADC_INJ_RANK_ID_JSQR_MASK)),
  4014. (Channel & ADC_CHANNEL_ID_NUMBER_MASK) >> (ADC_CHANNEL_ID_NUMBER_BITOFFSET_POS - (Rank & ADC_INJ_RANK_ID_JSQR_MASK)));
  4015. }
  4016. /**
  4017. * @brief Get ADC group injected sequence: channel on the selected
  4018. * sequence rank.
  4019. * @note Depending on devices and packages, some channels may not be available.
  4020. * Refer to device datasheet for channels availability.
  4021. * @note Usage of the returned channel number:
  4022. * - To reinject this channel into another function LL_ADC_xxx:
  4023. * the returned channel number is only partly formatted on definition
  4024. * of literals LL_ADC_CHANNEL_x. Therefore, it has to be compared
  4025. * with parts of literals LL_ADC_CHANNEL_x or using
  4026. * helper macro @ref __LL_ADC_CHANNEL_TO_DECIMAL_NB().
  4027. * Then the selected literal LL_ADC_CHANNEL_x can be used
  4028. * as parameter for another function.
  4029. * - To get the channel number in decimal format:
  4030. * process the returned value with the helper macro
  4031. * @ref __LL_ADC_CHANNEL_TO_DECIMAL_NB().
  4032. * @rmtoll JSQR JSQ1 LL_ADC_INJ_GetSequencerRanks\n
  4033. * JSQR JSQ2 LL_ADC_INJ_GetSequencerRanks\n
  4034. * JSQR JSQ3 LL_ADC_INJ_GetSequencerRanks\n
  4035. * JSQR JSQ4 LL_ADC_INJ_GetSequencerRanks
  4036. * @param ADCx ADC instance
  4037. * @param Rank This parameter can be one of the following values:
  4038. * @arg @ref LL_ADC_INJ_RANK_1
  4039. * @arg @ref LL_ADC_INJ_RANK_2
  4040. * @arg @ref LL_ADC_INJ_RANK_3
  4041. * @arg @ref LL_ADC_INJ_RANK_4
  4042. * @retval Returned value can be one of the following values:
  4043. * @arg @ref LL_ADC_CHANNEL_0
  4044. * @arg @ref LL_ADC_CHANNEL_1
  4045. * @arg @ref LL_ADC_CHANNEL_2
  4046. * @arg @ref LL_ADC_CHANNEL_3
  4047. * @arg @ref LL_ADC_CHANNEL_4
  4048. * @arg @ref LL_ADC_CHANNEL_5
  4049. * @arg @ref LL_ADC_CHANNEL_6
  4050. * @arg @ref LL_ADC_CHANNEL_7
  4051. * @arg @ref LL_ADC_CHANNEL_8
  4052. * @arg @ref LL_ADC_CHANNEL_9
  4053. * @arg @ref LL_ADC_CHANNEL_10
  4054. * @arg @ref LL_ADC_CHANNEL_11
  4055. * @arg @ref LL_ADC_CHANNEL_12
  4056. * @arg @ref LL_ADC_CHANNEL_13
  4057. * @arg @ref LL_ADC_CHANNEL_14
  4058. * @arg @ref LL_ADC_CHANNEL_15
  4059. * @arg @ref LL_ADC_CHANNEL_16
  4060. * @arg @ref LL_ADC_CHANNEL_17
  4061. * @arg @ref LL_ADC_CHANNEL_18
  4062. * @arg @ref LL_ADC_CHANNEL_VREFINT (5)
  4063. * @arg @ref LL_ADC_CHANNEL_TEMPSENSOR (1)
  4064. * @arg @ref LL_ADC_CHANNEL_VBAT (1)
  4065. * @arg @ref LL_ADC_CHANNEL_VOPAMP1 (1)
  4066. * @arg @ref LL_ADC_CHANNEL_VOPAMP2 (2)
  4067. * @arg @ref LL_ADC_CHANNEL_VOPAMP3 (3)
  4068. * @arg @ref LL_ADC_CHANNEL_VOPAMP4 (4)
  4069. *
  4070. * (1) On STM32F3, parameter available only on ADC instance: ADC1.\n
  4071. * (2) On STM32F3, parameter available only on ADC instance: ADC2.\n
  4072. * (3) On STM32F3, parameter available only on ADC instance: ADC3.\n
  4073. * (4) On STM32F3, parameter available only on ADC instances: ADC4.\n
  4074. * (5) On STM32F3, ADC channel available only on all ADC instances, but
  4075. * only one ADC instance is allowed to be connected to VrefInt at the same time.\n
  4076. * (1, 2, 3, 4, 5) For ADC channel read back from ADC register,
  4077. * comparison with internal channel parameter to be done
  4078. * using helper macro @ref __LL_ADC_CHANNEL_INTERNAL_TO_EXTERNAL().
  4079. */
  4080. __STATIC_INLINE uint32_t LL_ADC_INJ_GetSequencerRanks(ADC_TypeDef *ADCx, uint32_t Rank)
  4081. {
  4082. return (uint32_t)(READ_BIT(ADCx->JSQR,
  4083. ADC_CHANNEL_ID_NUMBER_MASK >> (ADC_CHANNEL_ID_NUMBER_BITOFFSET_POS - (Rank & ADC_INJ_RANK_ID_JSQR_MASK)))
  4084. << (ADC_CHANNEL_ID_NUMBER_BITOFFSET_POS - (Rank & ADC_INJ_RANK_ID_JSQR_MASK))
  4085. );
  4086. }
  4087. /**
  4088. * @brief Set ADC group injected conversion trigger:
  4089. * independent or from ADC group regular.
  4090. * @note This mode can be used to extend number of data registers
  4091. * updated after one ADC conversion trigger and with data
  4092. * permanently kept (not erased by successive conversions of scan of
  4093. * ADC sequencer ranks), up to 5 data registers:
  4094. * 1 data register on ADC group regular, 4 data registers
  4095. * on ADC group injected.
  4096. * @note If ADC group injected injected trigger source is set to an
  4097. * external trigger, this feature must be must be set to
  4098. * independent trigger.
  4099. * ADC group injected automatic trigger is compliant only with
  4100. * group injected trigger source set to SW start, without any
  4101. * further action on ADC group injected conversion start or stop:
  4102. * in this case, ADC group injected is controlled only
  4103. * from ADC group regular.
  4104. * @note It is not possible to enable both ADC group injected
  4105. * auto-injected mode and sequencer discontinuous mode.
  4106. * @note On this STM32 serie, setting of this feature is conditioned to
  4107. * ADC state:
  4108. * ADC must be disabled or enabled without conversion on going
  4109. * on either groups regular or injected.
  4110. * @rmtoll CFGR JAUTO LL_ADC_INJ_SetTrigAuto
  4111. * @param ADCx ADC instance
  4112. * @param TrigAuto This parameter can be one of the following values:
  4113. * @arg @ref LL_ADC_INJ_TRIG_INDEPENDENT
  4114. * @arg @ref LL_ADC_INJ_TRIG_FROM_GRP_REGULAR
  4115. * @retval None
  4116. */
  4117. __STATIC_INLINE void LL_ADC_INJ_SetTrigAuto(ADC_TypeDef *ADCx, uint32_t TrigAuto)
  4118. {
  4119. MODIFY_REG(ADCx->CFGR, ADC_CFGR_JAUTO, TrigAuto);
  4120. }
  4121. /**
  4122. * @brief Get ADC group injected conversion trigger:
  4123. * independent or from ADC group regular.
  4124. * @rmtoll CFGR JAUTO LL_ADC_INJ_GetTrigAuto
  4125. * @param ADCx ADC instance
  4126. * @retval Returned value can be one of the following values:
  4127. * @arg @ref LL_ADC_INJ_TRIG_INDEPENDENT
  4128. * @arg @ref LL_ADC_INJ_TRIG_FROM_GRP_REGULAR
  4129. */
  4130. __STATIC_INLINE uint32_t LL_ADC_INJ_GetTrigAuto(ADC_TypeDef *ADCx)
  4131. {
  4132. return (uint32_t)(READ_BIT(ADCx->CFGR, ADC_CFGR_JAUTO));
  4133. }
  4134. /**
  4135. * @brief Set ADC group injected contexts queue mode.
  4136. * @note A context is a setting of group injected sequencer:
  4137. * - group injected trigger
  4138. * - sequencer length
  4139. * - sequencer ranks
  4140. * If contexts queue is disabled:
  4141. * - only 1 sequence can be configured
  4142. * and is active perpetually.
  4143. * If contexts queue is enabled:
  4144. * - up to 2 contexts can be queued
  4145. * and are checked in and out as a FIFO stack (first-in, first-out).
  4146. * - If a new context is set when queues is full, error is triggered
  4147. * by interruption "Injected Queue Overflow".
  4148. * - Two behaviors are possible when all contexts have been processed:
  4149. * the contexts queue can maintain the last context active perpetually
  4150. * or can be empty and injected group triggers are disabled.
  4151. * - Triggers can be only external (not internal SW start)
  4152. * - Caution: The sequence must be fully configured in one time
  4153. * (one write of register JSQR makes a check-in of a new context
  4154. * into the queue).
  4155. * Therefore functions to set separately injected trigger and
  4156. * sequencer channels cannot be used, register JSQR must be set
  4157. * using function @ref LL_ADC_INJ_ConfigQueueContext().
  4158. * @note This parameter can be modified only when no conversion is on going
  4159. * on either groups regular or injected.
  4160. * @note A modification of the context mode (bit JQDIS) causes the contexts
  4161. * queue to be flushed and the register JSQR is cleared.
  4162. * @note On this STM32 serie, setting of this feature is conditioned to
  4163. * ADC state:
  4164. * ADC must be disabled or enabled without conversion on going
  4165. * on either groups regular or injected.
  4166. * @rmtoll CFGR JQM LL_ADC_INJ_SetQueueMode
  4167. * @param ADCx ADC instance
  4168. * @param QueueMode This parameter can be one of the following values:
  4169. * @arg @ref LL_ADC_INJ_QUEUE_2CONTEXTS_LAST_ACTIVE
  4170. * @arg @ref LL_ADC_INJ_QUEUE_2CONTEXTS_END_EMPTY
  4171. * @retval None
  4172. */
  4173. __STATIC_INLINE void LL_ADC_INJ_SetQueueMode(ADC_TypeDef *ADCx, uint32_t QueueMode)
  4174. {
  4175. MODIFY_REG(ADCx->CFGR, ADC_CFGR_JQM, QueueMode);
  4176. }
  4177. /**
  4178. * @brief Get ADC group injected context queue mode.
  4179. * @rmtoll CFGR JQM LL_ADC_INJ_GetQueueMode
  4180. * @param ADCx ADC instance
  4181. * @retval Returned value can be one of the following values:
  4182. * @arg @ref LL_ADC_INJ_QUEUE_2CONTEXTS_LAST_ACTIVE
  4183. * @arg @ref LL_ADC_INJ_QUEUE_2CONTEXTS_END_EMPTY
  4184. */
  4185. __STATIC_INLINE uint32_t LL_ADC_INJ_GetQueueMode(ADC_TypeDef *ADCx)
  4186. {
  4187. return (uint32_t)(READ_BIT(ADCx->CFGR, ADC_CFGR_JQM));
  4188. }
  4189. /**
  4190. * @brief Set one context on ADC group injected that will be checked in
  4191. * contexts queue.
  4192. * @note A context is a setting of group injected sequencer:
  4193. * - group injected trigger
  4194. * - sequencer length
  4195. * - sequencer ranks
  4196. * This function is intended to be used when contexts queue is enabled,
  4197. * because the sequence must be fully configured in one time
  4198. * (functions to set separately injected trigger and sequencer channels
  4199. * cannot be used):
  4200. * Refer to function @ref LL_ADC_INJ_SetQueueMode().
  4201. * @note In the contexts queue, only the active context can be read.
  4202. * The parameters of this function can be read using functions:
  4203. * @arg @ref LL_ADC_INJ_GetTriggerSource()
  4204. * @arg @ref LL_ADC_INJ_GetTriggerEdge()
  4205. * @arg @ref LL_ADC_INJ_GetSequencerRanks()
  4206. * @note On this STM32 serie, to measure internal channels (VrefInt,
  4207. * TempSensor, ...), measurement paths to internal channels must be
  4208. * enabled separately.
  4209. * This can be done using function @ref LL_ADC_SetCommonPathInternalCh().
  4210. * @note On this STM32 serie, setting of this feature is conditioned to
  4211. * ADC state:
  4212. * ADC must not be disabled. Can be enabled with or without conversion
  4213. * on going on either groups regular or injected.
  4214. * @rmtoll JSQR JEXTSEL LL_ADC_INJ_ConfigQueueContext\n
  4215. * JSQR JEXTEN LL_ADC_INJ_ConfigQueueContext\n
  4216. * JSQR JL LL_ADC_INJ_ConfigQueueContext\n
  4217. * JSQR JSQ1 LL_ADC_INJ_ConfigQueueContext\n
  4218. * JSQR JSQ2 LL_ADC_INJ_ConfigQueueContext\n
  4219. * JSQR JSQ3 LL_ADC_INJ_ConfigQueueContext\n
  4220. * JSQR JSQ4 LL_ADC_INJ_ConfigQueueContext
  4221. * @param ADCx ADC instance
  4222. * @param TriggerSource This parameter can be one of the following values:
  4223. * @arg @ref LL_ADC_INJ_TRIG_SOFTWARE
  4224. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM1_TRGO
  4225. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM1_TRGO2
  4226. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM1_CH3_ADC34 (1)(2) (8)
  4227. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM1_CH4
  4228. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM2_TRGO (3)(4)(5)
  4229. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM2_TRGO_ADC12 (1)(2) (7)
  4230. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM2_TRGO__ADC34 (1)(2) (8)
  4231. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM2_CH1 (3)(4)(5)
  4232. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM2_CH1_ADC12 (1)(2) (7)
  4233. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM3_TRGO (1)(2)(3)(4)(5)
  4234. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM3_CH1 (3)(4)(5)
  4235. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM3_CH1_ADC12 (1)(2) (7)
  4236. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM3_CH3 (3)(4)(5)
  4237. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM3_CH3_ADC12 (1)(2) (7)
  4238. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM3_CH4 (3)(4)(5)
  4239. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM3_CH4_ADC12 (1)(2)(3)(4)(5) (7)
  4240. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM4_TRGO (3) (5)
  4241. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM4_TRGO_ADC12 (1)(2) (7)
  4242. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM4_TRGO__ADC34 (1)(2) (8)
  4243. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM4_CH3_ADC34 (1)(2) (8)
  4244. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM4_CH4_ADC34 (1)(2) (8)
  4245. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM6_TRGO (3)(4)(5)
  4246. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM6_TRGO_ADC12 (1)(2) (7)
  4247. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM7_TRGO_ADC34 (1)(2) (8)
  4248. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM8_TRGO (1)(2)
  4249. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM8_TRGO2 (1)(2)
  4250. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM8_CH2_ADC34 (1)(2) (8)
  4251. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM8_CH4_ADC12 (1)(2) (7)
  4252. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM8_CH4__ADC34 (1)(2) (8)
  4253. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM15_TRGO
  4254. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM20_TRGO_ADC12 (1) (7)
  4255. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM20_TRGO2_ADC12 (1) (7)
  4256. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM20_CH4_ADC12 (1) (7)
  4257. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM20_TRG_ADC34 (1) (8)
  4258. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM20_TRG2_ADC34 (1) (8)
  4259. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM20_CH2_ADC34 (1) (8)
  4260. * @arg @ref LL_ADC_INJ_TRIG_EXT_HRTIM_TRG2 (4)
  4261. * @arg @ref LL_ADC_INJ_TRIG_EXT_HRTIM_TRG4 (4)
  4262. * @arg @ref LL_ADC_INJ_TRIG_EXT_EXTI_LINE15 (3)(4)(5)(6)
  4263. * @arg @ref LL_ADC_INJ_TRIG_EXT_EXTI_LINE15_ADC12 (1)(2) (7)
  4264. *
  4265. * (1) On STM32F3, parameter not available on all devices: among others, on STM32F303xE, STM32F398xx.\n
  4266. * (2) On STM32F3, parameter not available on all devices: among others, on STM32F303xC, STM32F358xx.\n
  4267. * (3) On STM32F3, parameter not available on all devices: among others, on STM32F303x8, STM32F328xx.\n
  4268. * (4) On STM32F3, parameter not available on all devices: among others, on STM32F334x8.\n
  4269. * (5) On STM32F3, parameter not available on all devices: among others, on STM32F302xC, STM32F302xE.\n
  4270. * (6) On STM32F3, parameter not available on all devices: among others, on STM32F301x8, STM32F302x8, STM32F318xx.\n
  4271. * (7) On STM32F3, parameter not available on all ADC instances: ADC1, ADC2 (for ADC instances ADCx available on the selected device).\n
  4272. * (8) On STM32F3, parameter not available on all ADC instances: ADC3, ADC4 (for ADC instances ADCx available on the selected device).
  4273. * @param ExternalTriggerEdge This parameter can be one of the following values:
  4274. * @arg @ref LL_ADC_INJ_TRIG_EXT_RISING
  4275. * @arg @ref LL_ADC_INJ_TRIG_EXT_FALLING
  4276. * @arg @ref LL_ADC_INJ_TRIG_EXT_RISINGFALLING
  4277. *
  4278. * Note: This parameter is discarded in case of SW start:
  4279. * parameter "TriggerSource" set to "LL_ADC_INJ_TRIG_SOFTWARE".
  4280. * @param SequencerNbRanks This parameter can be one of the following values:
  4281. * @arg @ref LL_ADC_INJ_SEQ_SCAN_DISABLE
  4282. * @arg @ref LL_ADC_INJ_SEQ_SCAN_ENABLE_2RANKS
  4283. * @arg @ref LL_ADC_INJ_SEQ_SCAN_ENABLE_3RANKS
  4284. * @arg @ref LL_ADC_INJ_SEQ_SCAN_ENABLE_4RANKS
  4285. * @param Rank1_Channel This parameter can be one of the following values:
  4286. * @arg @ref LL_ADC_CHANNEL_0
  4287. * @arg @ref LL_ADC_CHANNEL_1
  4288. * @arg @ref LL_ADC_CHANNEL_2
  4289. * @arg @ref LL_ADC_CHANNEL_3
  4290. * @arg @ref LL_ADC_CHANNEL_4
  4291. * @arg @ref LL_ADC_CHANNEL_5
  4292. * @arg @ref LL_ADC_CHANNEL_6
  4293. * @arg @ref LL_ADC_CHANNEL_7
  4294. * @arg @ref LL_ADC_CHANNEL_8
  4295. * @arg @ref LL_ADC_CHANNEL_9
  4296. * @arg @ref LL_ADC_CHANNEL_10
  4297. * @arg @ref LL_ADC_CHANNEL_11
  4298. * @arg @ref LL_ADC_CHANNEL_12
  4299. * @arg @ref LL_ADC_CHANNEL_13
  4300. * @arg @ref LL_ADC_CHANNEL_14
  4301. * @arg @ref LL_ADC_CHANNEL_15
  4302. * @arg @ref LL_ADC_CHANNEL_16
  4303. * @arg @ref LL_ADC_CHANNEL_17
  4304. * @arg @ref LL_ADC_CHANNEL_18
  4305. * @arg @ref LL_ADC_CHANNEL_VREFINT (5)
  4306. * @arg @ref LL_ADC_CHANNEL_TEMPSENSOR (1)
  4307. * @arg @ref LL_ADC_CHANNEL_VBAT (1)
  4308. * @arg @ref LL_ADC_CHANNEL_VOPAMP1 (1)
  4309. * @arg @ref LL_ADC_CHANNEL_VOPAMP2 (2)
  4310. * @arg @ref LL_ADC_CHANNEL_VOPAMP3 (3)
  4311. * @arg @ref LL_ADC_CHANNEL_VOPAMP4 (4)
  4312. *
  4313. * (1) On STM32F3, parameter available only on ADC instance: ADC1.\n
  4314. * (2) On STM32F3, parameter available only on ADC instance: ADC2.\n
  4315. * (3) On STM32F3, parameter available only on ADC instance: ADC3.\n
  4316. * (4) On STM32F3, parameter available only on ADC instances: ADC4.\n
  4317. * (5) On STM32F3, ADC channel available only on all ADC instances, but
  4318. * only one ADC instance is allowed to be connected to VrefInt at the same time.
  4319. * @param Rank2_Channel This parameter can be one of the following values:
  4320. * @arg @ref LL_ADC_CHANNEL_0
  4321. * @arg @ref LL_ADC_CHANNEL_1
  4322. * @arg @ref LL_ADC_CHANNEL_2
  4323. * @arg @ref LL_ADC_CHANNEL_3
  4324. * @arg @ref LL_ADC_CHANNEL_4
  4325. * @arg @ref LL_ADC_CHANNEL_5
  4326. * @arg @ref LL_ADC_CHANNEL_6
  4327. * @arg @ref LL_ADC_CHANNEL_7
  4328. * @arg @ref LL_ADC_CHANNEL_8
  4329. * @arg @ref LL_ADC_CHANNEL_9
  4330. * @arg @ref LL_ADC_CHANNEL_10
  4331. * @arg @ref LL_ADC_CHANNEL_11
  4332. * @arg @ref LL_ADC_CHANNEL_12
  4333. * @arg @ref LL_ADC_CHANNEL_13
  4334. * @arg @ref LL_ADC_CHANNEL_14
  4335. * @arg @ref LL_ADC_CHANNEL_15
  4336. * @arg @ref LL_ADC_CHANNEL_16
  4337. * @arg @ref LL_ADC_CHANNEL_17
  4338. * @arg @ref LL_ADC_CHANNEL_18
  4339. * @arg @ref LL_ADC_CHANNEL_VREFINT (5)
  4340. * @arg @ref LL_ADC_CHANNEL_TEMPSENSOR (1)
  4341. * @arg @ref LL_ADC_CHANNEL_VBAT (1)
  4342. * @arg @ref LL_ADC_CHANNEL_VOPAMP1 (1)
  4343. * @arg @ref LL_ADC_CHANNEL_VOPAMP2 (2)
  4344. * @arg @ref LL_ADC_CHANNEL_VOPAMP3 (3)
  4345. * @arg @ref LL_ADC_CHANNEL_VOPAMP4 (4)
  4346. *
  4347. * (1) On STM32F3, parameter available only on ADC instance: ADC1.\n
  4348. * (2) On STM32F3, parameter available only on ADC instance: ADC2.\n
  4349. * (3) On STM32F3, parameter available only on ADC instance: ADC3.\n
  4350. * (4) On STM32F3, parameter available only on ADC instances: ADC4.\n
  4351. * (5) On STM32F3, ADC channel available only on all ADC instances, but
  4352. * only one ADC instance is allowed to be connected to VrefInt at the same time.
  4353. * @param Rank3_Channel This parameter can be one of the following values:
  4354. * @arg @ref LL_ADC_CHANNEL_0
  4355. * @arg @ref LL_ADC_CHANNEL_1
  4356. * @arg @ref LL_ADC_CHANNEL_2
  4357. * @arg @ref LL_ADC_CHANNEL_3
  4358. * @arg @ref LL_ADC_CHANNEL_4
  4359. * @arg @ref LL_ADC_CHANNEL_5
  4360. * @arg @ref LL_ADC_CHANNEL_6
  4361. * @arg @ref LL_ADC_CHANNEL_7
  4362. * @arg @ref LL_ADC_CHANNEL_8
  4363. * @arg @ref LL_ADC_CHANNEL_9
  4364. * @arg @ref LL_ADC_CHANNEL_10
  4365. * @arg @ref LL_ADC_CHANNEL_11
  4366. * @arg @ref LL_ADC_CHANNEL_12
  4367. * @arg @ref LL_ADC_CHANNEL_13
  4368. * @arg @ref LL_ADC_CHANNEL_14
  4369. * @arg @ref LL_ADC_CHANNEL_15
  4370. * @arg @ref LL_ADC_CHANNEL_16
  4371. * @arg @ref LL_ADC_CHANNEL_17
  4372. * @arg @ref LL_ADC_CHANNEL_18
  4373. * @arg @ref LL_ADC_CHANNEL_VREFINT (5)
  4374. * @arg @ref LL_ADC_CHANNEL_TEMPSENSOR (1)
  4375. * @arg @ref LL_ADC_CHANNEL_VBAT (1)
  4376. * @arg @ref LL_ADC_CHANNEL_VOPAMP1 (1)
  4377. * @arg @ref LL_ADC_CHANNEL_VOPAMP2 (2)
  4378. * @arg @ref LL_ADC_CHANNEL_VOPAMP3 (3)
  4379. * @arg @ref LL_ADC_CHANNEL_VOPAMP4 (4)
  4380. *
  4381. * (1) On STM32F3, parameter available only on ADC instance: ADC1.\n
  4382. * (2) On STM32F3, parameter available only on ADC instance: ADC2.\n
  4383. * (3) On STM32F3, parameter available only on ADC instance: ADC3.\n
  4384. * (4) On STM32F3, parameter available only on ADC instances: ADC4.\n
  4385. * (5) On STM32F3, ADC channel available only on all ADC instances, but
  4386. * only one ADC instance is allowed to be connected to VrefInt at the same time.
  4387. * @param Rank4_Channel This parameter can be one of the following values:
  4388. * @arg @ref LL_ADC_CHANNEL_0
  4389. * @arg @ref LL_ADC_CHANNEL_1
  4390. * @arg @ref LL_ADC_CHANNEL_2
  4391. * @arg @ref LL_ADC_CHANNEL_3
  4392. * @arg @ref LL_ADC_CHANNEL_4
  4393. * @arg @ref LL_ADC_CHANNEL_5
  4394. * @arg @ref LL_ADC_CHANNEL_6
  4395. * @arg @ref LL_ADC_CHANNEL_7
  4396. * @arg @ref LL_ADC_CHANNEL_8
  4397. * @arg @ref LL_ADC_CHANNEL_9
  4398. * @arg @ref LL_ADC_CHANNEL_10
  4399. * @arg @ref LL_ADC_CHANNEL_11
  4400. * @arg @ref LL_ADC_CHANNEL_12
  4401. * @arg @ref LL_ADC_CHANNEL_13
  4402. * @arg @ref LL_ADC_CHANNEL_14
  4403. * @arg @ref LL_ADC_CHANNEL_15
  4404. * @arg @ref LL_ADC_CHANNEL_16
  4405. * @arg @ref LL_ADC_CHANNEL_17
  4406. * @arg @ref LL_ADC_CHANNEL_18
  4407. * @arg @ref LL_ADC_CHANNEL_VREFINT (5)
  4408. * @arg @ref LL_ADC_CHANNEL_TEMPSENSOR (1)
  4409. * @arg @ref LL_ADC_CHANNEL_VBAT (1)
  4410. * @arg @ref LL_ADC_CHANNEL_VOPAMP1 (1)
  4411. * @arg @ref LL_ADC_CHANNEL_VOPAMP2 (2)
  4412. * @arg @ref LL_ADC_CHANNEL_VOPAMP3 (3)
  4413. * @arg @ref LL_ADC_CHANNEL_VOPAMP4 (4)
  4414. *
  4415. * (1) On STM32F3, parameter available only on ADC instance: ADC1.\n
  4416. * (2) On STM32F3, parameter available only on ADC instance: ADC2.\n
  4417. * (3) On STM32F3, parameter available only on ADC instance: ADC3.\n
  4418. * (4) On STM32F3, parameter available only on ADC instances: ADC4.\n
  4419. * (5) On STM32F3, ADC channel available only on all ADC instances, but
  4420. * only one ADC instance is allowed to be connected to VrefInt at the same time.
  4421. * @retval None
  4422. */
  4423. __STATIC_INLINE void LL_ADC_INJ_ConfigQueueContext(ADC_TypeDef *ADCx,
  4424. uint32_t TriggerSource,
  4425. uint32_t ExternalTriggerEdge,
  4426. uint32_t SequencerNbRanks,
  4427. uint32_t Rank1_Channel,
  4428. uint32_t Rank2_Channel,
  4429. uint32_t Rank3_Channel,
  4430. uint32_t Rank4_Channel)
  4431. {
  4432. /* Set bits with content of parameter "Rankx_Channel" with bits position */
  4433. /* in register depending on literal "LL_ADC_INJ_RANK_x". */
  4434. /* Parameters "Rankx_Channel" and "LL_ADC_INJ_RANK_x" are used with masks */
  4435. /* because containing other bits reserved for other purpose. */
  4436. /* If parameter "TriggerSource" is set to SW start, then parameter */
  4437. /* "ExternalTriggerEdge" is discarded. */
  4438. MODIFY_REG(ADCx->JSQR ,
  4439. ADC_JSQR_JEXTSEL |
  4440. ADC_JSQR_JEXTEN |
  4441. ADC_JSQR_JSQ4 |
  4442. ADC_JSQR_JSQ3 |
  4443. ADC_JSQR_JSQ2 |
  4444. ADC_JSQR_JSQ1 |
  4445. ADC_JSQR_JL ,
  4446. TriggerSource |
  4447. (ExternalTriggerEdge * ((TriggerSource != LL_ADC_INJ_TRIG_SOFTWARE))) |
  4448. ((Rank4_Channel & ADC_CHANNEL_ID_NUMBER_MASK) >> (ADC_CHANNEL_ID_NUMBER_BITOFFSET_POS - (LL_ADC_INJ_RANK_4 & ADC_INJ_RANK_ID_JSQR_MASK))) |
  4449. ((Rank3_Channel & ADC_CHANNEL_ID_NUMBER_MASK) >> (ADC_CHANNEL_ID_NUMBER_BITOFFSET_POS - (LL_ADC_INJ_RANK_3 & ADC_INJ_RANK_ID_JSQR_MASK))) |
  4450. ((Rank2_Channel & ADC_CHANNEL_ID_NUMBER_MASK) >> (ADC_CHANNEL_ID_NUMBER_BITOFFSET_POS - (LL_ADC_INJ_RANK_2 & ADC_INJ_RANK_ID_JSQR_MASK))) |
  4451. ((Rank1_Channel & ADC_CHANNEL_ID_NUMBER_MASK) >> (ADC_CHANNEL_ID_NUMBER_BITOFFSET_POS - (LL_ADC_INJ_RANK_1 & ADC_INJ_RANK_ID_JSQR_MASK))) |
  4452. SequencerNbRanks
  4453. );
  4454. }
  4455. /**
  4456. * @}
  4457. */
  4458. /** @defgroup ADC_LL_EF_Configuration_Channels Configuration of ADC hierarchical scope: channels
  4459. * @{
  4460. */
  4461. /**
  4462. * @brief Set sampling time of the selected ADC channel
  4463. * Unit: ADC clock cycles.
  4464. * @note On this device, sampling time is on channel scope: independently
  4465. * of channel mapped on ADC group regular or injected.
  4466. * @note In case of internal channel (VrefInt, TempSensor, ...) to be
  4467. * converted:
  4468. * sampling time constraints must be respected (sampling time can be
  4469. * adjusted in function of ADC clock frequency and sampling time
  4470. * setting).
  4471. * Refer to device datasheet for timings values (parameters TS_vrefint,
  4472. * TS_temp, ...).
  4473. * @note Conversion time is the addition of sampling time and processing time.
  4474. * On this STM32 serie, ADC processing time is:
  4475. * - 12.5 ADC clock cycles at ADC resolution 12 bits
  4476. * - 10.5 ADC clock cycles at ADC resolution 10 bits
  4477. * - 8.5 ADC clock cycles at ADC resolution 8 bits
  4478. * - 6.5 ADC clock cycles at ADC resolution 6 bits
  4479. * @note In case of ADC conversion of internal channel (VrefInt,
  4480. * temperature sensor, ...), a sampling time minimum value
  4481. * is required.
  4482. * Refer to device datasheet.
  4483. * @note On this STM32 serie, setting of this feature is conditioned to
  4484. * ADC state:
  4485. * ADC must be disabled or enabled without conversion on going
  4486. * on either groups regular or injected.
  4487. * @rmtoll SMPR1 SMP0 LL_ADC_SetChannelSamplingTime\n
  4488. * SMPR1 SMP1 LL_ADC_SetChannelSamplingTime\n
  4489. * SMPR1 SMP2 LL_ADC_SetChannelSamplingTime\n
  4490. * SMPR1 SMP3 LL_ADC_SetChannelSamplingTime\n
  4491. * SMPR1 SMP4 LL_ADC_SetChannelSamplingTime\n
  4492. * SMPR1 SMP5 LL_ADC_SetChannelSamplingTime\n
  4493. * SMPR1 SMP6 LL_ADC_SetChannelSamplingTime\n
  4494. * SMPR1 SMP7 LL_ADC_SetChannelSamplingTime\n
  4495. * SMPR1 SMP8 LL_ADC_SetChannelSamplingTime\n
  4496. * SMPR1 SMP9 LL_ADC_SetChannelSamplingTime\n
  4497. * SMPR2 SMP10 LL_ADC_SetChannelSamplingTime\n
  4498. * SMPR2 SMP11 LL_ADC_SetChannelSamplingTime\n
  4499. * SMPR2 SMP12 LL_ADC_SetChannelSamplingTime\n
  4500. * SMPR2 SMP13 LL_ADC_SetChannelSamplingTime\n
  4501. * SMPR2 SMP14 LL_ADC_SetChannelSamplingTime\n
  4502. * SMPR2 SMP15 LL_ADC_SetChannelSamplingTime\n
  4503. * SMPR2 SMP16 LL_ADC_SetChannelSamplingTime\n
  4504. * SMPR2 SMP17 LL_ADC_SetChannelSamplingTime\n
  4505. * SMPR2 SMP18 LL_ADC_SetChannelSamplingTime
  4506. * @param ADCx ADC instance
  4507. * @param Channel This parameter can be one of the following values:
  4508. * @arg @ref LL_ADC_CHANNEL_0
  4509. * @arg @ref LL_ADC_CHANNEL_1
  4510. * @arg @ref LL_ADC_CHANNEL_2
  4511. * @arg @ref LL_ADC_CHANNEL_3
  4512. * @arg @ref LL_ADC_CHANNEL_4
  4513. * @arg @ref LL_ADC_CHANNEL_5
  4514. * @arg @ref LL_ADC_CHANNEL_6
  4515. * @arg @ref LL_ADC_CHANNEL_7
  4516. * @arg @ref LL_ADC_CHANNEL_8
  4517. * @arg @ref LL_ADC_CHANNEL_9
  4518. * @arg @ref LL_ADC_CHANNEL_10
  4519. * @arg @ref LL_ADC_CHANNEL_11
  4520. * @arg @ref LL_ADC_CHANNEL_12
  4521. * @arg @ref LL_ADC_CHANNEL_13
  4522. * @arg @ref LL_ADC_CHANNEL_14
  4523. * @arg @ref LL_ADC_CHANNEL_15
  4524. * @arg @ref LL_ADC_CHANNEL_16
  4525. * @arg @ref LL_ADC_CHANNEL_17
  4526. * @arg @ref LL_ADC_CHANNEL_18
  4527. * @arg @ref LL_ADC_CHANNEL_VREFINT (5)
  4528. * @arg @ref LL_ADC_CHANNEL_TEMPSENSOR (1)
  4529. * @arg @ref LL_ADC_CHANNEL_VBAT (1)
  4530. * @arg @ref LL_ADC_CHANNEL_VOPAMP1 (1)
  4531. * @arg @ref LL_ADC_CHANNEL_VOPAMP2 (2)
  4532. * @arg @ref LL_ADC_CHANNEL_VOPAMP3 (3)
  4533. * @arg @ref LL_ADC_CHANNEL_VOPAMP4 (4)
  4534. *
  4535. * (1) On STM32F3, parameter available only on ADC instance: ADC1.\n
  4536. * (2) On STM32F3, parameter available only on ADC instance: ADC2.\n
  4537. * (3) On STM32F3, parameter available only on ADC instance: ADC3.\n
  4538. * (4) On STM32F3, parameter available only on ADC instances: ADC4.\n
  4539. * (5) On STM32F3, ADC channel available only on all ADC instances, but
  4540. * only one ADC instance is allowed to be connected to VrefInt at the same time.
  4541. * @param SamplingTime This parameter can be one of the following values:
  4542. * @arg @ref LL_ADC_SAMPLINGTIME_1CYCLE_5
  4543. * @arg @ref LL_ADC_SAMPLINGTIME_2CYCLES_5
  4544. * @arg @ref LL_ADC_SAMPLINGTIME_4CYCLES_5
  4545. * @arg @ref LL_ADC_SAMPLINGTIME_7CYCLES_5
  4546. * @arg @ref LL_ADC_SAMPLINGTIME_19CYCLES_5
  4547. * @arg @ref LL_ADC_SAMPLINGTIME_61CYCLES_5
  4548. * @arg @ref LL_ADC_SAMPLINGTIME_181CYCLES_5
  4549. * @arg @ref LL_ADC_SAMPLINGTIME_601CYCLES_5
  4550. * @retval None
  4551. */
  4552. __STATIC_INLINE void LL_ADC_SetChannelSamplingTime(ADC_TypeDef *ADCx, uint32_t Channel, uint32_t SamplingTime)
  4553. {
  4554. /* Set bits with content of parameter "SamplingTime" with bits position */
  4555. /* in register and register position depending on parameter "Channel". */
  4556. /* Parameter "Channel" is used with masks because containing */
  4557. /* other bits reserved for other purpose. */
  4558. register uint32_t *preg = __ADC_PTR_REG_OFFSET(ADCx->SMPR1, __ADC_MASK_SHIFT(Channel, ADC_CHANNEL_SMPRX_REGOFFSET_MASK));
  4559. MODIFY_REG(*preg,
  4560. ADC_SMPR1_SMP0 << __ADC_MASK_SHIFT(Channel, ADC_CHANNEL_SMPx_BITOFFSET_MASK),
  4561. SamplingTime << __ADC_MASK_SHIFT(Channel, ADC_CHANNEL_SMPx_BITOFFSET_MASK));
  4562. }
  4563. /**
  4564. * @brief Get sampling time of the selected ADC channel
  4565. * Unit: ADC clock cycles.
  4566. * @note On this device, sampling time is on channel scope: independently
  4567. * of channel mapped on ADC group regular or injected.
  4568. * @note Conversion time is the addition of sampling time and processing time.
  4569. * On this STM32 serie, ADC processing time is:
  4570. * - 12.5 ADC clock cycles at ADC resolution 12 bits
  4571. * - 10.5 ADC clock cycles at ADC resolution 10 bits
  4572. * - 8.5 ADC clock cycles at ADC resolution 8 bits
  4573. * - 6.5 ADC clock cycles at ADC resolution 6 bits
  4574. * @rmtoll SMPR1 SMP0 LL_ADC_GetChannelSamplingTime\n
  4575. * SMPR1 SMP1 LL_ADC_GetChannelSamplingTime\n
  4576. * SMPR1 SMP2 LL_ADC_GetChannelSamplingTime\n
  4577. * SMPR1 SMP3 LL_ADC_GetChannelSamplingTime\n
  4578. * SMPR1 SMP4 LL_ADC_GetChannelSamplingTime\n
  4579. * SMPR1 SMP5 LL_ADC_GetChannelSamplingTime\n
  4580. * SMPR1 SMP6 LL_ADC_GetChannelSamplingTime\n
  4581. * SMPR1 SMP7 LL_ADC_GetChannelSamplingTime\n
  4582. * SMPR1 SMP8 LL_ADC_GetChannelSamplingTime\n
  4583. * SMPR1 SMP9 LL_ADC_GetChannelSamplingTime\n
  4584. * SMPR2 SMP10 LL_ADC_GetChannelSamplingTime\n
  4585. * SMPR2 SMP11 LL_ADC_GetChannelSamplingTime\n
  4586. * SMPR2 SMP12 LL_ADC_GetChannelSamplingTime\n
  4587. * SMPR2 SMP13 LL_ADC_GetChannelSamplingTime\n
  4588. * SMPR2 SMP14 LL_ADC_GetChannelSamplingTime\n
  4589. * SMPR2 SMP15 LL_ADC_GetChannelSamplingTime\n
  4590. * SMPR2 SMP16 LL_ADC_GetChannelSamplingTime\n
  4591. * SMPR2 SMP17 LL_ADC_GetChannelSamplingTime\n
  4592. * SMPR2 SMP18 LL_ADC_GetChannelSamplingTime
  4593. * @param ADCx ADC instance
  4594. * @param Channel This parameter can be one of the following values:
  4595. * @arg @ref LL_ADC_CHANNEL_0
  4596. * @arg @ref LL_ADC_CHANNEL_1
  4597. * @arg @ref LL_ADC_CHANNEL_2
  4598. * @arg @ref LL_ADC_CHANNEL_3
  4599. * @arg @ref LL_ADC_CHANNEL_4
  4600. * @arg @ref LL_ADC_CHANNEL_5
  4601. * @arg @ref LL_ADC_CHANNEL_6
  4602. * @arg @ref LL_ADC_CHANNEL_7
  4603. * @arg @ref LL_ADC_CHANNEL_8
  4604. * @arg @ref LL_ADC_CHANNEL_9
  4605. * @arg @ref LL_ADC_CHANNEL_10
  4606. * @arg @ref LL_ADC_CHANNEL_11
  4607. * @arg @ref LL_ADC_CHANNEL_12
  4608. * @arg @ref LL_ADC_CHANNEL_13
  4609. * @arg @ref LL_ADC_CHANNEL_14
  4610. * @arg @ref LL_ADC_CHANNEL_15
  4611. * @arg @ref LL_ADC_CHANNEL_16
  4612. * @arg @ref LL_ADC_CHANNEL_17
  4613. * @arg @ref LL_ADC_CHANNEL_18
  4614. * @arg @ref LL_ADC_CHANNEL_VREFINT (5)
  4615. * @arg @ref LL_ADC_CHANNEL_TEMPSENSOR (1)
  4616. * @arg @ref LL_ADC_CHANNEL_VBAT (1)
  4617. * @arg @ref LL_ADC_CHANNEL_VOPAMP1 (1)
  4618. * @arg @ref LL_ADC_CHANNEL_VOPAMP2 (2)
  4619. * @arg @ref LL_ADC_CHANNEL_VOPAMP3 (3)
  4620. * @arg @ref LL_ADC_CHANNEL_VOPAMP4 (4)
  4621. *
  4622. * (1) On STM32F3, parameter available only on ADC instance: ADC1.\n
  4623. * (2) On STM32F3, parameter available only on ADC instance: ADC2.\n
  4624. * (3) On STM32F3, parameter available only on ADC instance: ADC3.\n
  4625. * (4) On STM32F3, parameter available only on ADC instances: ADC4.\n
  4626. * (5) On STM32F3, ADC channel available only on all ADC instances, but
  4627. * only one ADC instance is allowed to be connected to VrefInt at the same time.
  4628. * @retval Returned value can be one of the following values:
  4629. * @arg @ref LL_ADC_SAMPLINGTIME_1CYCLE_5
  4630. * @arg @ref LL_ADC_SAMPLINGTIME_2CYCLES_5
  4631. * @arg @ref LL_ADC_SAMPLINGTIME_4CYCLES_5
  4632. * @arg @ref LL_ADC_SAMPLINGTIME_7CYCLES_5
  4633. * @arg @ref LL_ADC_SAMPLINGTIME_19CYCLES_5
  4634. * @arg @ref LL_ADC_SAMPLINGTIME_61CYCLES_5
  4635. * @arg @ref LL_ADC_SAMPLINGTIME_181CYCLES_5
  4636. * @arg @ref LL_ADC_SAMPLINGTIME_601CYCLES_5
  4637. */
  4638. __STATIC_INLINE uint32_t LL_ADC_GetChannelSamplingTime(ADC_TypeDef *ADCx, uint32_t Channel)
  4639. {
  4640. register uint32_t *preg = __ADC_PTR_REG_OFFSET(ADCx->SMPR1, __ADC_MASK_SHIFT(Channel, ADC_CHANNEL_SMPRX_REGOFFSET_MASK));
  4641. return (uint32_t)(READ_BIT(*preg,
  4642. ADC_SMPR1_SMP0 << __ADC_MASK_SHIFT(Channel, ADC_CHANNEL_SMPx_BITOFFSET_MASK))
  4643. >> __ADC_MASK_SHIFT(Channel, ADC_CHANNEL_SMPx_BITOFFSET_MASK)
  4644. );
  4645. }
  4646. /**
  4647. * @brief Set mode single-ended or differential input of the selected
  4648. * ADC channel.
  4649. * @note Channel ending is on channel scope: independently of channel mapped
  4650. * on ADC group regular or injected.
  4651. * In differential mode: Differential measurement is carried out
  4652. * between the selected channel 'i' (positive input) and
  4653. * channel 'i+1' (negative input). Only channel 'i' has to be
  4654. * configured, channel 'i+1' is configured automatically.
  4655. * @note Refer to Reference Manual to ensure the selected channel is
  4656. * available in differential mode.
  4657. * For example, internal channels (VrefInt, TempSensor, ...) are
  4658. * not available in differential mode.
  4659. * @note When configuring a channel 'i' in differential mode,
  4660. * the channel 'i+1' is not usable separately.
  4661. * @note On STM32F3, channels 16, 17, 18 of ADC1,
  4662. * channels 17, 18 of ADC2, ADC3, ADC4 (if available)
  4663. * are internally fixed to single-ended inputs configuration.
  4664. * @note For ADC channels configured in differential mode, both inputs
  4665. * should be biased at (Vref+)/2 +/-200mV.
  4666. * (Vref+ is the analog voltage reference)
  4667. * @note On this STM32 serie, setting of this feature is conditioned to
  4668. * ADC state:
  4669. * ADC must be ADC disabled.
  4670. * @note One or several values can be selected.
  4671. * Example: (LL_ADC_CHANNEL_4 | LL_ADC_CHANNEL_12 | ...)
  4672. * @rmtoll DIFSEL DIFSEL LL_ADC_GetChannelSamplingTime
  4673. * @param ADCx ADC instance
  4674. * @param Channel This parameter can be one of the following values:
  4675. * @arg @ref LL_ADC_CHANNEL_1
  4676. * @arg @ref LL_ADC_CHANNEL_2
  4677. * @arg @ref LL_ADC_CHANNEL_3
  4678. * @arg @ref LL_ADC_CHANNEL_4
  4679. * @arg @ref LL_ADC_CHANNEL_5
  4680. * @arg @ref LL_ADC_CHANNEL_6
  4681. * @arg @ref LL_ADC_CHANNEL_7
  4682. * @arg @ref LL_ADC_CHANNEL_8
  4683. * @arg @ref LL_ADC_CHANNEL_9
  4684. * @arg @ref LL_ADC_CHANNEL_10
  4685. * @arg @ref LL_ADC_CHANNEL_11
  4686. * @arg @ref LL_ADC_CHANNEL_12
  4687. * @arg @ref LL_ADC_CHANNEL_13
  4688. * @arg @ref LL_ADC_CHANNEL_14
  4689. * @arg @ref LL_ADC_CHANNEL_15
  4690. * @arg @ref LL_ADC_CHANNEL_16 (1)
  4691. *
  4692. * (1) On STM32F3, parameter available only on ADC instance: ADC1.
  4693. * @param SingleDiff This parameter can be a combination of the following values:
  4694. * @arg @ref LL_ADC_SINGLE_ENDED
  4695. * @arg @ref LL_ADC_DIFFERENTIAL_ENDED
  4696. * @retval None
  4697. */
  4698. __STATIC_INLINE void LL_ADC_SetChannelSingleDiff(ADC_TypeDef *ADCx, uint32_t Channel, uint32_t SingleDiff)
  4699. {
  4700. /* Bits of channels in single or differential mode are set only for */
  4701. /* differential mode (for single mode, mask of bits allowed to be set is */
  4702. /* shifted out of range of bits of channels in single or differential mode. */
  4703. MODIFY_REG(ADCx->DIFSEL,
  4704. Channel & ADC_SINGLEDIFF_CHANNEL_MASK,
  4705. (Channel & ADC_SINGLEDIFF_CHANNEL_MASK) & (ADC_DIFSEL_DIFSEL << (SingleDiff & ADC_SINGLEDIFF_CHANNEL_SHIFT_MASK)));
  4706. }
  4707. /**
  4708. * @brief Get mode single-ended or differential input of the selected
  4709. * ADC channel.
  4710. * @note When configuring a channel 'i' in differential mode,
  4711. * the channel 'i+1' is not usable separately.
  4712. * Therefore, to ensure a channel is configured in single-ended mode,
  4713. * the configuration of channel itself and the channel 'i-1' must be
  4714. * read back (to ensure that the selected channel channel has not been
  4715. * configured in differential mode by the previous channel).
  4716. * @note Refer to Reference Manual to ensure the selected channel is
  4717. * available in differential mode.
  4718. * For example, internal channels (VrefInt, TempSensor, ...) are
  4719. * not available in differential mode.
  4720. * @note When configuring a channel 'i' in differential mode,
  4721. * the channel 'i+1' is not usable separately.
  4722. * @note On STM32F3, channels 16, 17, 18 of ADC1,
  4723. * channels 17, 18 of ADC2, ADC3, ADC4 (if available)
  4724. * are internally fixed to single-ended inputs configuration.
  4725. * @note One or several values can be selected. In this case, the value
  4726. * returned is null if all channels are in single ended-mode.
  4727. * Example: (LL_ADC_CHANNEL_4 | LL_ADC_CHANNEL_12 | ...)
  4728. * @rmtoll DIFSEL DIFSEL LL_ADC_GetChannelSamplingTime
  4729. * @param ADCx ADC instance
  4730. * @param Channel This parameter can be a combination of the following values:
  4731. * @arg @ref LL_ADC_CHANNEL_0
  4732. * @arg @ref LL_ADC_CHANNEL_1
  4733. * @arg @ref LL_ADC_CHANNEL_2
  4734. * @arg @ref LL_ADC_CHANNEL_3
  4735. * @arg @ref LL_ADC_CHANNEL_4
  4736. * @arg @ref LL_ADC_CHANNEL_5
  4737. * @arg @ref LL_ADC_CHANNEL_6
  4738. * @arg @ref LL_ADC_CHANNEL_7
  4739. * @arg @ref LL_ADC_CHANNEL_8
  4740. * @arg @ref LL_ADC_CHANNEL_9
  4741. * @arg @ref LL_ADC_CHANNEL_10
  4742. * @arg @ref LL_ADC_CHANNEL_11
  4743. * @arg @ref LL_ADC_CHANNEL_12
  4744. * @arg @ref LL_ADC_CHANNEL_13
  4745. * @arg @ref LL_ADC_CHANNEL_14
  4746. * @arg @ref LL_ADC_CHANNEL_15
  4747. * @arg @ref LL_ADC_CHANNEL_16 (1)
  4748. *
  4749. * (1) On STM32F3, parameter available only on ADC instance: ADC1.
  4750. * @retval 0: channel in single-ended mode, else: channel in differential mode
  4751. */
  4752. __STATIC_INLINE uint32_t LL_ADC_GetChannelSingleDiff(ADC_TypeDef *ADCx, uint32_t Channel)
  4753. {
  4754. return (uint32_t)(READ_BIT(ADCx->DIFSEL, (Channel & ADC_SINGLEDIFF_CHANNEL_MASK)));
  4755. }
  4756. /**
  4757. * @}
  4758. */
  4759. /** @defgroup ADC_LL_EF_Configuration_ADC_AnalogWatchdog Configuration of ADC transversal scope: analog watchdog
  4760. * @{
  4761. */
  4762. /**
  4763. * @brief Set ADC analog watchdog monitored channels:
  4764. * a single channel, multiple channels or all channels,
  4765. * on ADC groups regular and-or injected.
  4766. * @note Once monitored channels are selected, analog watchdog
  4767. * is enabled.
  4768. * @note In case of need to define a single channel to monitor
  4769. * with analog watchdog from sequencer channel definition,
  4770. * use helper macro @ref __LL_ADC_ANALOGWD_CHANNEL_GROUP().
  4771. * @note On this STM32 serie, there are 2 kinds of analog watchdog
  4772. * instance:
  4773. * - AWD standard (instance AWD1):
  4774. * - channels monitored: can monitor 1 channel or all channels.
  4775. * - groups monitored: ADC groups regular and-or injected.
  4776. * - resolution: resolution is not limited (corresponds to
  4777. * ADC resolution configured).
  4778. * - AWD flexible (instances AWD2, AWD3):
  4779. * - channels monitored: flexible on channels monitored, selection is
  4780. * channel wise, from from 1 to all channels.
  4781. * Specificity of this analog watchdog: Multiple channels can
  4782. * be selected. For example:
  4783. * (LL_ADC_AWD_CHANNEL4_REG_INJ | LL_ADC_AWD_CHANNEL5_REG_INJ | ...)
  4784. * - groups monitored: not selection possible (monitoring on both
  4785. * groups regular and injected).
  4786. * Channels selected are monitored on groups regular and injected:
  4787. * LL_ADC_AWD_CHANNELxx_REG_INJ (do not use parameters
  4788. * LL_ADC_AWD_CHANNELxx_REG and LL_ADC_AWD_CHANNELxx_INJ)
  4789. * - resolution: resolution is limited to 8 bits: if ADC resolution is
  4790. * 12 bits the 4 LSB are ignored, if ADC resolution is 10 bits
  4791. * the 2 LSB are ignored.
  4792. * @note On this STM32 serie, setting of this feature is conditioned to
  4793. * ADC state:
  4794. * ADC must be disabled or enabled without conversion on going
  4795. * on either groups regular or injected.
  4796. * @rmtoll CFGR AWD1CH LL_ADC_SetAnalogWDMonitChannels\n
  4797. * CFGR AWD1SGL LL_ADC_SetAnalogWDMonitChannels\n
  4798. * CFGR AWD1EN LL_ADC_SetAnalogWDMonitChannels\n
  4799. * CFGR JAWD1EN LL_ADC_SetAnalogWDMonitChannels\n
  4800. * AWD2CR AWD2CH LL_ADC_SetAnalogWDMonitChannels\n
  4801. * AWD3CR AWD3CH LL_ADC_SetAnalogWDMonitChannels
  4802. * @param ADCx ADC instance
  4803. * @param AWDy This parameter can be one of the following values:
  4804. * @arg @ref LL_ADC_AWD1
  4805. * @arg @ref LL_ADC_AWD2
  4806. * @arg @ref LL_ADC_AWD3
  4807. * @param AWDChannelGroup This parameter can be one of the following values:
  4808. * @arg @ref LL_ADC_AWD_DISABLE
  4809. * @arg @ref LL_ADC_AWD_ALL_CHANNELS_REG (0)
  4810. * @arg @ref LL_ADC_AWD_ALL_CHANNELS_INJ (0)
  4811. * @arg @ref LL_ADC_AWD_ALL_CHANNELS_REG_INJ
  4812. * @arg @ref LL_ADC_AWD_CHANNEL_0_REG (0)
  4813. * @arg @ref LL_ADC_AWD_CHANNEL_0_INJ (0)
  4814. * @arg @ref LL_ADC_AWD_CHANNEL_0_REG_INJ
  4815. * @arg @ref LL_ADC_AWD_CHANNEL_1_REG (0)
  4816. * @arg @ref LL_ADC_AWD_CHANNEL_1_INJ (0)
  4817. * @arg @ref LL_ADC_AWD_CHANNEL_1_REG_INJ
  4818. * @arg @ref LL_ADC_AWD_CHANNEL_2_REG (0)
  4819. * @arg @ref LL_ADC_AWD_CHANNEL_2_INJ (0)
  4820. * @arg @ref LL_ADC_AWD_CHANNEL_2_REG_INJ
  4821. * @arg @ref LL_ADC_AWD_CHANNEL_3_REG (0)
  4822. * @arg @ref LL_ADC_AWD_CHANNEL_3_INJ (0)
  4823. * @arg @ref LL_ADC_AWD_CHANNEL_3_REG_INJ
  4824. * @arg @ref LL_ADC_AWD_CHANNEL_4_REG (0)
  4825. * @arg @ref LL_ADC_AWD_CHANNEL_4_INJ (0)
  4826. * @arg @ref LL_ADC_AWD_CHANNEL_4_REG_INJ
  4827. * @arg @ref LL_ADC_AWD_CHANNEL_5_REG (0)
  4828. * @arg @ref LL_ADC_AWD_CHANNEL_5_INJ (0)
  4829. * @arg @ref LL_ADC_AWD_CHANNEL_5_REG_INJ
  4830. * @arg @ref LL_ADC_AWD_CHANNEL_6_REG (0)
  4831. * @arg @ref LL_ADC_AWD_CHANNEL_6_INJ (0)
  4832. * @arg @ref LL_ADC_AWD_CHANNEL_6_REG_INJ
  4833. * @arg @ref LL_ADC_AWD_CHANNEL_7_REG (0)
  4834. * @arg @ref LL_ADC_AWD_CHANNEL_7_INJ (0)
  4835. * @arg @ref LL_ADC_AWD_CHANNEL_7_REG_INJ
  4836. * @arg @ref LL_ADC_AWD_CHANNEL_8_REG (0)
  4837. * @arg @ref LL_ADC_AWD_CHANNEL_8_INJ (0)
  4838. * @arg @ref LL_ADC_AWD_CHANNEL_8_REG_INJ
  4839. * @arg @ref LL_ADC_AWD_CHANNEL_9_REG (0)
  4840. * @arg @ref LL_ADC_AWD_CHANNEL_9_INJ (0)
  4841. * @arg @ref LL_ADC_AWD_CHANNEL_9_REG_INJ
  4842. * @arg @ref LL_ADC_AWD_CHANNEL_10_REG (0)
  4843. * @arg @ref LL_ADC_AWD_CHANNEL_10_INJ (0)
  4844. * @arg @ref LL_ADC_AWD_CHANNEL_10_REG_INJ
  4845. * @arg @ref LL_ADC_AWD_CHANNEL_11_REG (0)
  4846. * @arg @ref LL_ADC_AWD_CHANNEL_11_INJ (0)
  4847. * @arg @ref LL_ADC_AWD_CHANNEL_11_REG_INJ
  4848. * @arg @ref LL_ADC_AWD_CHANNEL_12_REG (0)
  4849. * @arg @ref LL_ADC_AWD_CHANNEL_12_INJ (0)
  4850. * @arg @ref LL_ADC_AWD_CHANNEL_12_REG_INJ
  4851. * @arg @ref LL_ADC_AWD_CHANNEL_13_REG (0)
  4852. * @arg @ref LL_ADC_AWD_CHANNEL_13_INJ (0)
  4853. * @arg @ref LL_ADC_AWD_CHANNEL_13_REG_INJ
  4854. * @arg @ref LL_ADC_AWD_CHANNEL_14_REG (0)
  4855. * @arg @ref LL_ADC_AWD_CHANNEL_14_INJ (0)
  4856. * @arg @ref LL_ADC_AWD_CHANNEL_14_REG_INJ
  4857. * @arg @ref LL_ADC_AWD_CHANNEL_15_REG (0)
  4858. * @arg @ref LL_ADC_AWD_CHANNEL_15_INJ (0)
  4859. * @arg @ref LL_ADC_AWD_CHANNEL_15_REG_INJ
  4860. * @arg @ref LL_ADC_AWD_CHANNEL_16_REG (0)
  4861. * @arg @ref LL_ADC_AWD_CHANNEL_16_INJ (0)
  4862. * @arg @ref LL_ADC_AWD_CHANNEL_16_REG_INJ
  4863. * @arg @ref LL_ADC_AWD_CHANNEL_17_REG (0)
  4864. * @arg @ref LL_ADC_AWD_CHANNEL_17_INJ (0)
  4865. * @arg @ref LL_ADC_AWD_CHANNEL_17_REG_INJ
  4866. * @arg @ref LL_ADC_AWD_CHANNEL_18_REG (0)
  4867. * @arg @ref LL_ADC_AWD_CHANNEL_18_INJ (0)
  4868. * @arg @ref LL_ADC_AWD_CHANNEL_18_REG_INJ
  4869. * @arg @ref LL_ADC_AWD_CH_VREFINT_REG (0)(5)
  4870. * @arg @ref LL_ADC_AWD_CH_VREFINT_INJ (0)(5)
  4871. * @arg @ref LL_ADC_AWD_CH_VREFINT_REG_INJ (5)
  4872. * @arg @ref LL_ADC_AWD_CH_TEMPSENSOR_REG (0)(1)
  4873. * @arg @ref LL_ADC_AWD_CH_TEMPSENSOR_INJ (0)(1)
  4874. * @arg @ref LL_ADC_AWD_CH_TEMPSENSOR_REG_INJ (1)
  4875. * @arg @ref LL_ADC_AWD_CH_VBAT_REG (0)(1)
  4876. * @arg @ref LL_ADC_AWD_CH_VBAT_INJ (0)(1)
  4877. * @arg @ref LL_ADC_AWD_CH_VBAT_REG_INJ (1)
  4878. * @arg @ref LL_ADC_AWD_CH_VOPAMP1_REG (0)(1)
  4879. * @arg @ref LL_ADC_AWD_CH_VOPAMP1_INJ (0)(1)
  4880. * @arg @ref LL_ADC_AWD_CH_VOPAMP1_REG_INJ (1)
  4881. * @arg @ref LL_ADC_AWD_CH_VOPAMP2_REG (0)(2)
  4882. * @arg @ref LL_ADC_AWD_CH_VOPAMP2_INJ (0)(2)
  4883. * @arg @ref LL_ADC_AWD_CH_VOPAMP2_REG_INJ (2)
  4884. * @arg @ref LL_ADC_AWD_CH_VOPAMP3_REG (0)(3)
  4885. * @arg @ref LL_ADC_AWD_CH_VOPAMP3_INJ (0)(3)
  4886. * @arg @ref LL_ADC_AWD_CH_VOPAMP3_REG_INJ (3)
  4887. * @arg @ref LL_ADC_AWD_CH_VOPAMP4_REG (0)(4)
  4888. * @arg @ref LL_ADC_AWD_CH_VOPAMP4_INJ (0)(4)
  4889. * @arg @ref LL_ADC_AWD_CH_VOPAMP4_REG_INJ (4)
  4890. *
  4891. * (0) On STM32F3, parameter available only on analog watchdog number: AWD1.\n
  4892. * (1) On STM32F3, parameter available only on ADC instance: ADC1.\n
  4893. * (2) On STM32F3, parameter available only on ADC instance: ADC2.\n
  4894. * (3) On STM32F3, parameter available only on ADC instance: ADC3.\n
  4895. * (4) On STM32F3, parameter available only on ADC instances: ADC4.\n
  4896. * (5) On STM32F3, ADC channel available only on all ADC instances, but
  4897. * only one ADC instance is allowed to be connected to VrefInt at the same time.
  4898. * @retval None
  4899. */
  4900. __STATIC_INLINE void LL_ADC_SetAnalogWDMonitChannels(ADC_TypeDef *ADCx, uint32_t AWDy, uint32_t AWDChannelGroup)
  4901. {
  4902. /* Set bits with content of parameter "AWDChannelGroup" with bits position */
  4903. /* in register and register position depending on parameter "AWDy". */
  4904. /* Parameters "AWDChannelGroup" and "AWDy" are used with masks because */
  4905. /* containing other bits reserved for other purpose. */
  4906. register uint32_t *preg = __ADC_PTR_REG_OFFSET(ADCx->CFGR, __ADC_MASK_SHIFT(AWDy, ADC_AWD_CRX_REGOFFSET_MASK)
  4907. + ((AWDy & ADC_AWD_CR12_REGOFFSETGAP_MASK) * ADC_AWD_CR12_REGOFFSETGAP_VAL));
  4908. MODIFY_REG(*preg,
  4909. (AWDy & ADC_AWD_CR_ALL_CHANNEL_MASK),
  4910. AWDChannelGroup & AWDy);
  4911. }
  4912. /**
  4913. * @brief Get ADC analog watchdog monitored channel.
  4914. * @note Usage of the returned channel number:
  4915. * - To reinject this channel into another function LL_ADC_xxx:
  4916. * the returned channel number is only partly formatted on definition
  4917. * of literals LL_ADC_CHANNEL_x. Therefore, it has to be compared
  4918. * with parts of literals LL_ADC_CHANNEL_x or using
  4919. * helper macro @ref __LL_ADC_CHANNEL_TO_DECIMAL_NB().
  4920. * Then the selected literal LL_ADC_CHANNEL_x can be used
  4921. * as parameter for another function.
  4922. * - To get the channel number in decimal format:
  4923. * process the returned value with the helper macro
  4924. * @ref __LL_ADC_CHANNEL_TO_DECIMAL_NB().
  4925. * Applicable only when the analog watchdog is set to monitor
  4926. * one channel.
  4927. * @note On this STM32 serie, there are 2 kinds of analog watchdog
  4928. * instance:
  4929. * - AWD standard (instance AWD1):
  4930. * - channels monitored: can monitor 1 channel or all channels.
  4931. * - groups monitored: ADC groups regular and-or injected.
  4932. * - resolution: resolution is not limited (corresponds to
  4933. * ADC resolution configured).
  4934. * - AWD flexible (instances AWD2, AWD3):
  4935. * - channels monitored: flexible on channels monitored, selection is
  4936. * channel wise, from from 1 to all channels.
  4937. * Specificity of this analog watchdog: Multiple channels can
  4938. * be selected. For example:
  4939. * (LL_ADC_AWD_CHANNEL4_REG_INJ | LL_ADC_AWD_CHANNEL5_REG_INJ | ...)
  4940. * - groups monitored: not selection possible (monitoring on both
  4941. * groups regular and injected).
  4942. * Channels selected are monitored on groups regular and injected:
  4943. * LL_ADC_AWD_CHANNELxx_REG_INJ (do not use parameters
  4944. * LL_ADC_AWD_CHANNELxx_REG and LL_ADC_AWD_CHANNELxx_INJ)
  4945. * - resolution: resolution is limited to 8 bits: if ADC resolution is
  4946. * 12 bits the 4 LSB are ignored, if ADC resolution is 10 bits
  4947. * the 2 LSB are ignored.
  4948. * @note On this STM32 serie, setting of this feature is conditioned to
  4949. * ADC state:
  4950. * ADC must be disabled or enabled without conversion on going
  4951. * on either groups regular or injected.
  4952. * @rmtoll CFGR AWD1CH LL_ADC_GetAnalogWDMonitChannels\n
  4953. * CFGR AWD1SGL LL_ADC_GetAnalogWDMonitChannels\n
  4954. * CFGR AWD1EN LL_ADC_GetAnalogWDMonitChannels\n
  4955. * CFGR JAWD1EN LL_ADC_GetAnalogWDMonitChannels\n
  4956. * AWD2CR AWD2CH LL_ADC_GetAnalogWDMonitChannels\n
  4957. * AWD3CR AWD3CH LL_ADC_GetAnalogWDMonitChannels
  4958. * @param ADCx ADC instance
  4959. * @param AWDy This parameter can be one of the following values:
  4960. * @arg @ref LL_ADC_AWD1
  4961. * @arg @ref LL_ADC_AWD2 (1)
  4962. * @arg @ref LL_ADC_AWD3 (1)
  4963. *
  4964. * (1) On this AWD number, monitored channel can be retrieved
  4965. * if only 1 channel is programmed (or none or all channels).
  4966. * This function cannot retrieve monitored channel if
  4967. * multiple channels are programmed simultaneously
  4968. * by bitfield.
  4969. * @retval Returned value can be one of the following values:
  4970. * @arg @ref LL_ADC_AWD_DISABLE
  4971. * @arg @ref LL_ADC_AWD_ALL_CHANNELS_REG (0)
  4972. * @arg @ref LL_ADC_AWD_ALL_CHANNELS_INJ (0)
  4973. * @arg @ref LL_ADC_AWD_ALL_CHANNELS_REG_INJ
  4974. * @arg @ref LL_ADC_AWD_CHANNEL_0_REG (0)
  4975. * @arg @ref LL_ADC_AWD_CHANNEL_0_INJ (0)
  4976. * @arg @ref LL_ADC_AWD_CHANNEL_0_REG_INJ
  4977. * @arg @ref LL_ADC_AWD_CHANNEL_1_REG (0)
  4978. * @arg @ref LL_ADC_AWD_CHANNEL_1_INJ (0)
  4979. * @arg @ref LL_ADC_AWD_CHANNEL_1_REG_INJ
  4980. * @arg @ref LL_ADC_AWD_CHANNEL_2_REG (0)
  4981. * @arg @ref LL_ADC_AWD_CHANNEL_2_INJ (0)
  4982. * @arg @ref LL_ADC_AWD_CHANNEL_2_REG_INJ
  4983. * @arg @ref LL_ADC_AWD_CHANNEL_3_REG (0)
  4984. * @arg @ref LL_ADC_AWD_CHANNEL_3_INJ (0)
  4985. * @arg @ref LL_ADC_AWD_CHANNEL_3_REG_INJ
  4986. * @arg @ref LL_ADC_AWD_CHANNEL_4_REG (0)
  4987. * @arg @ref LL_ADC_AWD_CHANNEL_4_INJ (0)
  4988. * @arg @ref LL_ADC_AWD_CHANNEL_4_REG_INJ
  4989. * @arg @ref LL_ADC_AWD_CHANNEL_5_REG (0)
  4990. * @arg @ref LL_ADC_AWD_CHANNEL_5_INJ (0)
  4991. * @arg @ref LL_ADC_AWD_CHANNEL_5_REG_INJ
  4992. * @arg @ref LL_ADC_AWD_CHANNEL_6_REG (0)
  4993. * @arg @ref LL_ADC_AWD_CHANNEL_6_INJ (0)
  4994. * @arg @ref LL_ADC_AWD_CHANNEL_6_REG_INJ
  4995. * @arg @ref LL_ADC_AWD_CHANNEL_7_REG (0)
  4996. * @arg @ref LL_ADC_AWD_CHANNEL_7_INJ (0)
  4997. * @arg @ref LL_ADC_AWD_CHANNEL_7_REG_INJ
  4998. * @arg @ref LL_ADC_AWD_CHANNEL_8_REG (0)
  4999. * @arg @ref LL_ADC_AWD_CHANNEL_8_INJ (0)
  5000. * @arg @ref LL_ADC_AWD_CHANNEL_8_REG_INJ
  5001. * @arg @ref LL_ADC_AWD_CHANNEL_9_REG (0)
  5002. * @arg @ref LL_ADC_AWD_CHANNEL_9_INJ (0)
  5003. * @arg @ref LL_ADC_AWD_CHANNEL_9_REG_INJ
  5004. * @arg @ref LL_ADC_AWD_CHANNEL_10_REG (0)
  5005. * @arg @ref LL_ADC_AWD_CHANNEL_10_INJ (0)
  5006. * @arg @ref LL_ADC_AWD_CHANNEL_10_REG_INJ
  5007. * @arg @ref LL_ADC_AWD_CHANNEL_11_REG (0)
  5008. * @arg @ref LL_ADC_AWD_CHANNEL_11_INJ (0)
  5009. * @arg @ref LL_ADC_AWD_CHANNEL_11_REG_INJ
  5010. * @arg @ref LL_ADC_AWD_CHANNEL_12_REG (0)
  5011. * @arg @ref LL_ADC_AWD_CHANNEL_12_INJ (0)
  5012. * @arg @ref LL_ADC_AWD_CHANNEL_12_REG_INJ
  5013. * @arg @ref LL_ADC_AWD_CHANNEL_13_REG (0)
  5014. * @arg @ref LL_ADC_AWD_CHANNEL_13_INJ (0)
  5015. * @arg @ref LL_ADC_AWD_CHANNEL_13_REG_INJ
  5016. * @arg @ref LL_ADC_AWD_CHANNEL_14_REG (0)
  5017. * @arg @ref LL_ADC_AWD_CHANNEL_14_INJ (0)
  5018. * @arg @ref LL_ADC_AWD_CHANNEL_14_REG_INJ
  5019. * @arg @ref LL_ADC_AWD_CHANNEL_15_REG (0)
  5020. * @arg @ref LL_ADC_AWD_CHANNEL_15_INJ (0)
  5021. * @arg @ref LL_ADC_AWD_CHANNEL_15_REG_INJ
  5022. * @arg @ref LL_ADC_AWD_CHANNEL_16_REG (0)
  5023. * @arg @ref LL_ADC_AWD_CHANNEL_16_INJ (0)
  5024. * @arg @ref LL_ADC_AWD_CHANNEL_16_REG_INJ
  5025. * @arg @ref LL_ADC_AWD_CHANNEL_17_REG (0)
  5026. * @arg @ref LL_ADC_AWD_CHANNEL_17_INJ (0)
  5027. * @arg @ref LL_ADC_AWD_CHANNEL_17_REG_INJ
  5028. * @arg @ref LL_ADC_AWD_CHANNEL_18_REG (0)
  5029. * @arg @ref LL_ADC_AWD_CHANNEL_18_INJ (0)
  5030. * @arg @ref LL_ADC_AWD_CHANNEL_18_REG_INJ
  5031. *
  5032. * (0) On STM32F3, parameter available only on analog watchdog number: AWD1.
  5033. */
  5034. __STATIC_INLINE uint32_t LL_ADC_GetAnalogWDMonitChannels(ADC_TypeDef *ADCx, uint32_t AWDy)
  5035. {
  5036. register uint32_t *preg = __ADC_PTR_REG_OFFSET(ADCx->CFGR, __ADC_MASK_SHIFT(AWDy, ADC_AWD_CRX_REGOFFSET_MASK)
  5037. + ((AWDy & ADC_AWD_CR12_REGOFFSETGAP_MASK) * ADC_AWD_CR12_REGOFFSETGAP_VAL));
  5038. /* Variable "AWDy" used to retrieve appropriate bitfield corresponding to */
  5039. /* ADC_AWD_CR1_CHANNEL_MASK or ADC_AWD_CR23_CHANNEL_MASK. */
  5040. register uint32_t AWD123ChannelGroup = READ_BIT(*preg, (AWDy | ADC_AWD_CR_ALL_CHANNEL_MASK));
  5041. /* Set variable of AWD1 monitored channel according to AWD1 features */
  5042. /* and ADC channel definition: */
  5043. /* - channel ID with number */
  5044. /* - channel ID with bitfield */
  5045. /* - AWD1 single or all channels */
  5046. /* - AWD1 enable or disable (also used to discard AWD1 bitfield in case of */
  5047. /* AWD2 or AWD3 selected). */
  5048. register uint32_t AWD1ChannelSingle = ((AWD123ChannelGroup & ADC_CFGR_AWD1SGL) >> ADC_CFGR_AWD1SGL_BITOFFSET_POS);
  5049. register uint32_t AWD1ChannelGroup = ( ( AWD123ChannelGroup
  5050. | ((ADC_CHANNEL_0_BITFIELD << ((AWD123ChannelGroup & ADC_CHANNEL_ID_NUMBER_MASK) >> ADC_CHANNEL_ID_NUMBER_BITOFFSET_POS)) * AWD1ChannelSingle)
  5051. | (ADC_CHANNEL_ID_BITFIELD_MASK * (~AWD1ChannelSingle & ((uint32_t)0x00000001U)))
  5052. )
  5053. * (((AWD123ChannelGroup & ADC_CFGR_JAWD1EN) >> ADC_CFGR_JAWD1EN_BITOFFSET_POS) | ((AWD123ChannelGroup & ADC_CFGR_AWD1EN) >> ADC_CFGR_AWD1EN_BITOFFSET_POS))
  5054. );
  5055. /* Set variable of AWD2 and AWD3 monitored channel according to AWD2-3 */
  5056. /* features and ADC channel definition: */
  5057. /* - channel ID with number */
  5058. /* - channel ID with bitfield */
  5059. /* - AWD2-3 single or all channels (shift value 32 (0x1 shift 5) used to */
  5060. /* shift AWD1 equivalent single-all channels out of register) */
  5061. /* - AWD2-3 enable or disable */
  5062. /* Note: Use modulo 3 to avoid a shift value too long. On AWD2 and AWD3, */
  5063. /* channel can be read back if only 1 channel monitoring */
  5064. /* is activated, therefore the channel monitoring value channel "3" */
  5065. /* is not not supported by this function, there is no risk of */
  5066. /* conflict. */
  5067. register uint32_t AWD23Enabled = ((((uint32_t)0x00000001U) >> (AWD123ChannelGroup % 3U)) << 6U); /* Value "0" if AWD2-3 is enabled, value "32" if AWD2-3 is disabled */
  5068. register uint32_t AWD23ChannelGroup = ((( AWD123ChannelGroup
  5069. | ((uint32_t)POSITION_VAL(AWD123ChannelGroup) << ADC_CHANNEL_ID_NUMBER_BITOFFSET_POS)
  5070. | ((ADC_CFGR_AWD1SGL) >> ((((uint32_t)0x00000001U) >> (ADC_AWD_CR23_CHANNEL_MASK - AWD123ChannelGroup)) << 5U))
  5071. | (ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1EN)
  5072. ) >> AWD23Enabled
  5073. ) >> (((AWDy & ADC_CFGR_AWD1SGL) >> ADC_CFGR_AWD1SGL_BITOFFSET_POS) << 5U));
  5074. return (AWD1ChannelGroup | AWD23ChannelGroup);
  5075. }
  5076. /**
  5077. * @brief Set ADC analog watchdog thresholds value of both thresholds
  5078. * high and low.
  5079. * @note If value of only one threshold high or low must be set,
  5080. * use function @ref LL_ADC_SetAnalogWDThresholds().
  5081. * @note In case of ADC resolution different of 12 bits,
  5082. * analog watchdog thresholds data require a specific shift.
  5083. * Use helper macro @ref __LL_ADC_ANALOGWD_SET_THRESHOLD_RESOLUTION().
  5084. * @note On this STM32 serie, there are 2 kinds of analog watchdog
  5085. * instance:
  5086. * - AWD standard (instance AWD1):
  5087. * - channels monitored: can monitor 1 channel or all channels.
  5088. * - groups monitored: ADC groups regular and-or injected.
  5089. * - resolution: resolution is not limited (corresponds to
  5090. * ADC resolution configured).
  5091. * - AWD flexible (instances AWD2, AWD3):
  5092. * - channels monitored: flexible on channels monitored, selection is
  5093. * channel wise, from from 1 to all channels.
  5094. * Specificity of this analog watchdog: Multiple channels can
  5095. * be selected. For example:
  5096. * (LL_ADC_AWD_CHANNEL4_REG_INJ | LL_ADC_AWD_CHANNEL5_REG_INJ | ...)
  5097. * - groups monitored: not selection possible (monitoring on both
  5098. * groups regular and injected).
  5099. * Channels selected are monitored on groups regular and injected:
  5100. * LL_ADC_AWD_CHANNELxx_REG_INJ (do not use parameters
  5101. * LL_ADC_AWD_CHANNELxx_REG and LL_ADC_AWD_CHANNELxx_INJ)
  5102. * - resolution: resolution is limited to 8 bits: if ADC resolution is
  5103. * 12 bits the 4 LSB are ignored, if ADC resolution is 10 bits
  5104. * the 2 LSB are ignored.
  5105. * @note On this STM32 serie, setting of this feature is conditioned to
  5106. * ADC state:
  5107. * ADC must be disabled or enabled without conversion on going
  5108. * on either groups regular or injected.
  5109. * @rmtoll TR1 HT1 LL_ADC_ConfigAnalogWDThresholds\n
  5110. * TR2 HT2 LL_ADC_ConfigAnalogWDThresholds\n
  5111. * TR3 HT3 LL_ADC_ConfigAnalogWDThresholds\n
  5112. * TR1 LT1 LL_ADC_ConfigAnalogWDThresholds\n
  5113. * TR2 LT2 LL_ADC_ConfigAnalogWDThresholds\n
  5114. * TR3 LT3 LL_ADC_ConfigAnalogWDThresholds
  5115. * @param ADCx ADC instance
  5116. * @param AWDy This parameter can be one of the following values:
  5117. * @arg @ref LL_ADC_AWD1
  5118. * @arg @ref LL_ADC_AWD2
  5119. * @arg @ref LL_ADC_AWD3
  5120. * @param AWDThresholdHighValue Value between Min_Data=0x000 and Max_Data=0xFFF
  5121. * @param AWDThresholdLowValue Value between Min_Data=0x000 and Max_Data=0xFFF
  5122. * @retval None
  5123. */
  5124. __STATIC_INLINE void LL_ADC_ConfigAnalogWDThresholds(ADC_TypeDef *ADCx, uint32_t AWDy, uint32_t AWDThresholdHighValue, uint32_t AWDThresholdLowValue)
  5125. {
  5126. /* Set bits with content of parameter "AWDThresholdxxxValue" with bits */
  5127. /* position in register and register position depending on parameter */
  5128. /* "AWDy". */
  5129. /* Parameters "AWDy" and "AWDThresholdxxxValue" are used with masks because */
  5130. /* containing other bits reserved for other purpose. */
  5131. register uint32_t *preg = __ADC_PTR_REG_OFFSET(ADCx->TR1, __ADC_MASK_SHIFT(AWDy, ADC_AWD_TRX_REGOFFSET_MASK));
  5132. MODIFY_REG(*preg,
  5133. ADC_TR1_HT1 | ADC_TR1_LT1,
  5134. (AWDThresholdHighValue << ADC_TR1_HT1_BITOFFSET_POS) | AWDThresholdLowValue);
  5135. }
  5136. /**
  5137. * @brief Set ADC analog watchdog threshold value of threshold
  5138. * high or low.
  5139. * @note If values of both thresholds high or low must be set,
  5140. * use function @ref LL_ADC_ConfigAnalogWDThresholds().
  5141. * @note In case of ADC resolution different of 12 bits,
  5142. * analog watchdog thresholds data require a specific shift.
  5143. * Use helper macro @ref __LL_ADC_ANALOGWD_SET_THRESHOLD_RESOLUTION().
  5144. * @note On this STM32 serie, there are 2 kinds of analog watchdog
  5145. * instance:
  5146. * - AWD standard (instance AWD1):
  5147. * - channels monitored: can monitor 1 channel or all channels.
  5148. * - groups monitored: ADC groups regular and-or injected.
  5149. * - resolution: resolution is not limited (corresponds to
  5150. * ADC resolution configured).
  5151. * - AWD flexible (instances AWD2, AWD3):
  5152. * - channels monitored: flexible on channels monitored, selection is
  5153. * channel wise, from from 1 to all channels.
  5154. * Specificity of this analog watchdog: Multiple channels can
  5155. * be selected. For example:
  5156. * (LL_ADC_AWD_CHANNEL4_REG_INJ | LL_ADC_AWD_CHANNEL5_REG_INJ | ...)
  5157. * - groups monitored: not selection possible (monitoring on both
  5158. * groups regular and injected).
  5159. * Channels selected are monitored on groups regular and injected:
  5160. * LL_ADC_AWD_CHANNELxx_REG_INJ (do not use parameters
  5161. * LL_ADC_AWD_CHANNELxx_REG and LL_ADC_AWD_CHANNELxx_INJ)
  5162. * - resolution: resolution is limited to 8 bits: if ADC resolution is
  5163. * 12 bits the 4 LSB are ignored, if ADC resolution is 10 bits
  5164. * the 2 LSB are ignored.
  5165. * @note On this STM32 serie, setting of this feature is conditioned to
  5166. * ADC state:
  5167. * ADC must be disabled or enabled without conversion on going
  5168. * on either groups regular or injected.
  5169. * @rmtoll TR1 HT1 LL_ADC_SetAnalogWDThresholds\n
  5170. * TR2 HT2 LL_ADC_SetAnalogWDThresholds\n
  5171. * TR3 HT3 LL_ADC_SetAnalogWDThresholds\n
  5172. * TR1 LT1 LL_ADC_SetAnalogWDThresholds\n
  5173. * TR2 LT2 LL_ADC_SetAnalogWDThresholds\n
  5174. * TR3 LT3 LL_ADC_SetAnalogWDThresholds
  5175. * @param ADCx ADC instance
  5176. * @param AWDy This parameter can be one of the following values:
  5177. * @arg @ref LL_ADC_AWD1
  5178. * @arg @ref LL_ADC_AWD2
  5179. * @arg @ref LL_ADC_AWD3
  5180. * @param AWDThresholdsHighLow This parameter can be one of the following values:
  5181. * @arg @ref LL_ADC_AWD_THRESHOLD_HIGH
  5182. * @arg @ref LL_ADC_AWD_THRESHOLD_LOW
  5183. * @param AWDThresholdValue Value between Min_Data=0x000 and Max_Data=0xFFF
  5184. * @retval None
  5185. */
  5186. __STATIC_INLINE void LL_ADC_SetAnalogWDThresholds(ADC_TypeDef *ADCx, uint32_t AWDy, uint32_t AWDThresholdsHighLow, uint32_t AWDThresholdValue)
  5187. {
  5188. /* Set bits with content of parameter "AWDThresholdValue" with bits */
  5189. /* position in register and register position depending on parameters */
  5190. /* "AWDThresholdsHighLow" and "AWDy". */
  5191. /* Parameters "AWDy" and "AWDThresholdValue" are used with masks because */
  5192. /* containing other bits reserved for other purpose. */
  5193. register uint32_t *preg = __ADC_PTR_REG_OFFSET(ADCx->TR1, __ADC_MASK_SHIFT(AWDy, ADC_AWD_TRX_REGOFFSET_MASK));
  5194. MODIFY_REG(*preg,
  5195. AWDThresholdsHighLow,
  5196. AWDThresholdValue << POSITION_VAL(AWDThresholdsHighLow));
  5197. }
  5198. /**
  5199. * @brief Get ADC analog watchdog threshold value of threshold high,
  5200. * threshold low or raw data with ADC thresholds high and low
  5201. * concatenated.
  5202. * @note If raw data with ADC thresholds high and low is retrieved,
  5203. * the data of each threshold high or low can be isolated
  5204. * using helper macro:
  5205. * @ref __LL_ADC_ANALOGWD_THRESHOLDS_HIGH_LOW().
  5206. * @note In case of ADC resolution different of 12 bits,
  5207. * analog watchdog thresholds data require a specific shift.
  5208. * Use helper macro @ref __LL_ADC_ANALOGWD_GET_THRESHOLD_RESOLUTION().
  5209. * @rmtoll TR1 HT1 LL_ADC_GetAnalogWDThresholds\n
  5210. * TR2 HT2 LL_ADC_GetAnalogWDThresholds\n
  5211. * TR3 HT3 LL_ADC_GetAnalogWDThresholds\n
  5212. * TR1 LT1 LL_ADC_GetAnalogWDThresholds\n
  5213. * TR2 LT2 LL_ADC_GetAnalogWDThresholds\n
  5214. * TR3 LT3 LL_ADC_GetAnalogWDThresholds
  5215. * @param ADCx ADC instance
  5216. * @param AWDy This parameter can be one of the following values:
  5217. * @arg @ref LL_ADC_AWD1
  5218. * @arg @ref LL_ADC_AWD2
  5219. * @arg @ref LL_ADC_AWD3
  5220. * @param AWDThresholdsHighLow This parameter can be one of the following values:
  5221. * @arg @ref LL_ADC_AWD_THRESHOLD_HIGH
  5222. * @arg @ref LL_ADC_AWD_THRESHOLD_LOW
  5223. * @arg @ref LL_ADC_AWD_THRESHOLDS_HIGH_LOW
  5224. * @retval Value between Min_Data=0x000 and Max_Data=0xFFF
  5225. */
  5226. __STATIC_INLINE uint32_t LL_ADC_GetAnalogWDThresholds(ADC_TypeDef *ADCx, uint32_t AWDy, uint32_t AWDThresholdsHighLow)
  5227. {
  5228. register uint32_t *preg = __ADC_PTR_REG_OFFSET(ADCx->TR1, __ADC_MASK_SHIFT(AWDy, ADC_AWD_TRX_REGOFFSET_MASK));
  5229. return (uint32_t)(READ_BIT(*preg,
  5230. (AWDThresholdsHighLow | ADC_TR1_LT1))
  5231. >> POSITION_VAL(AWDThresholdsHighLow)
  5232. );
  5233. }
  5234. /**
  5235. * @}
  5236. */
  5237. /** @defgroup ADC_LL_EF_Configuration_ADC_Multimode Configuration of ADC hierarchical scope: multimode
  5238. * @{
  5239. */
  5240. #if defined(ADC_MULTIMODE_SUPPORT)
  5241. /**
  5242. * @brief Set ADC multimode configuration to operate in independent mode
  5243. * or multimode (for devices with several ADC instances).
  5244. * @note If multimode configuration: the selected ADC instance is
  5245. * either master or slave depending on hardware.
  5246. * Refer to reference manual.
  5247. * @note On this STM32 serie, setting of this feature is conditioned to
  5248. * ADC state:
  5249. * All ADC instances of the ADC common group must be disabled.
  5250. * This check can be done with function @ref LL_ADC_IsEnabled() for each
  5251. * ADC instance or by using helper macro
  5252. * @ref __LL_ADC_IS_ENABLED_ALL_COMMON_INSTANCE().
  5253. * @rmtoll CCR DUAL LL_ADC_SetMultimode
  5254. * @param ADCxy_COMMON ADC common instance
  5255. * (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() )
  5256. * @param Multimode This parameter can be one of the following values:
  5257. * @arg @ref LL_ADC_MULTI_INDEPENDENT
  5258. * @arg @ref LL_ADC_MULTI_DUAL_REG_SIMULT
  5259. * @arg @ref LL_ADC_MULTI_DUAL_REG_INTERL
  5260. * @arg @ref LL_ADC_MULTI_DUAL_INJ_SIMULT
  5261. * @arg @ref LL_ADC_MULTI_DUAL_INJ_ALTERN
  5262. * @arg @ref LL_ADC_MULTI_DUAL_REG_SIM_INJ_SIM
  5263. * @arg @ref LL_ADC_MULTI_DUAL_REG_SIM_INJ_ALT
  5264. * @arg @ref LL_ADC_MULTI_DUAL_REG_INT_INJ_SIM
  5265. * @retval None
  5266. */
  5267. __STATIC_INLINE void LL_ADC_SetMultimode(ADC_Common_TypeDef *ADCxy_COMMON, uint32_t Multimode)
  5268. {
  5269. MODIFY_REG(ADCxy_COMMON->CCR, ADC_CCR_DUAL, Multimode);
  5270. }
  5271. /**
  5272. * @brief Get ADC multimode configuration to operate in independent mode
  5273. * or multimode (for devices with several ADC instances).
  5274. * @note If multimode configuration: the selected ADC instance is
  5275. * either master or slave depending on hardware.
  5276. * Refer to reference manual.
  5277. * @rmtoll CCR DUAL LL_ADC_GetMultimode
  5278. * @param ADCxy_COMMON ADC common instance
  5279. * (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() )
  5280. * @retval Returned value can be one of the following values:
  5281. * @arg @ref LL_ADC_MULTI_INDEPENDENT
  5282. * @arg @ref LL_ADC_MULTI_DUAL_REG_SIMULT
  5283. * @arg @ref LL_ADC_MULTI_DUAL_REG_INTERL
  5284. * @arg @ref LL_ADC_MULTI_DUAL_INJ_SIMULT
  5285. * @arg @ref LL_ADC_MULTI_DUAL_INJ_ALTERN
  5286. * @arg @ref LL_ADC_MULTI_DUAL_REG_SIM_INJ_SIM
  5287. * @arg @ref LL_ADC_MULTI_DUAL_REG_SIM_INJ_ALT
  5288. * @arg @ref LL_ADC_MULTI_DUAL_REG_INT_INJ_SIM
  5289. */
  5290. __STATIC_INLINE uint32_t LL_ADC_GetMultimode(ADC_Common_TypeDef *ADCxy_COMMON)
  5291. {
  5292. return (uint32_t)(READ_BIT(ADCxy_COMMON->CCR, ADC_CCR_DUAL));
  5293. }
  5294. /**
  5295. * @brief Set ADC multimode conversion data transfer: no transfer
  5296. * or transfer by DMA.
  5297. * @note If ADC multimode transfer by DMA is not selected:
  5298. * each ADC uses its own DMA channel, with its individual
  5299. * DMA transfer settings.
  5300. * If ADC multimode transfer by DMA is selected:
  5301. * One DMA channel is used for both ADC (DMA of ADC master)
  5302. * Specifies the DMA requests mode:
  5303. * - Limited mode (One shot mode): DMA transfer requests are stopped
  5304. * when number of DMA data transfers (number of
  5305. * ADC conversions) is reached.
  5306. * This ADC mode is intended to be used with DMA mode non-circular.
  5307. * - Unlimited mode: DMA transfer requests are unlimited,
  5308. * whatever number of DMA data transfers (number of
  5309. * ADC conversions).
  5310. * This ADC mode is intended to be used with DMA mode circular.
  5311. * @note If ADC DMA requests mode is set to unlimited and DMA is set to
  5312. * mode non-circular:
  5313. * when DMA transfers size will be reached, DMA will stop transfers of
  5314. * ADC conversions data ADC will raise an overrun error
  5315. * (overrun flag and interruption if enabled).
  5316. * @note How to retrieve multimode conversion data:
  5317. * Whatever multimode transfer by DMA setting: using function
  5318. * @ref LL_ADC_REG_ReadMultiConversionData32().
  5319. * If ADC multimode transfer by DMA is selected: conversion data
  5320. * is a raw data with ADC master and slave concatenated.
  5321. * A macro is available to get the conversion data of
  5322. * ADC master or ADC slave: see helper macro
  5323. * @ref __LL_ADC_MULTI_CONV_DATA_MASTER_SLAVE().
  5324. * @note On this STM32 serie, setting of this feature is conditioned to
  5325. * ADC state:
  5326. * All ADC instances of the ADC common group must be disabled
  5327. * or enabled without conversion on going on group regular.
  5328. * @rmtoll CCR MDMA LL_ADC_SetMultiDMATransfer\n
  5329. * CCR DMACFG LL_ADC_SetMultiDMATransfer
  5330. * @param ADCxy_COMMON ADC common instance
  5331. * (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() )
  5332. * @param MultiDMATransfer This parameter can be one of the following values:
  5333. * @arg @ref LL_ADC_MULTI_REG_DMA_EACH_ADC
  5334. * @arg @ref LL_ADC_MULTI_REG_DMA_LIMIT_RES12_10B
  5335. * @arg @ref LL_ADC_MULTI_REG_DMA_LIMIT_RES8_6B
  5336. * @arg @ref LL_ADC_MULTI_REG_DMA_UNLMT_RES12_10B
  5337. * @arg @ref LL_ADC_MULTI_REG_DMA_UNLMT_RES8_6B
  5338. * @retval None
  5339. */
  5340. __STATIC_INLINE void LL_ADC_SetMultiDMATransfer(ADC_Common_TypeDef *ADCxy_COMMON, uint32_t MultiDMATransfer)
  5341. {
  5342. MODIFY_REG(ADCxy_COMMON->CCR, ADC_CCR_MDMA | ADC_CCR_DMACFG, MultiDMATransfer);
  5343. }
  5344. /**
  5345. * @brief Get ADC multimode conversion data transfer: no transfer
  5346. * or transfer by DMA.
  5347. * @note If ADC multimode transfer by DMA is not selected:
  5348. * each ADC uses its own DMA channel, with its individual
  5349. * DMA transfer settings.
  5350. * If ADC multimode transfer by DMA is selected:
  5351. * One DMA channel is used for both ADC (DMA of ADC master)
  5352. * Specifies the DMA requests mode:
  5353. * - Limited mode (One shot mode): DMA transfer requests are stopped
  5354. * when number of DMA data transfers (number of
  5355. * ADC conversions) is reached.
  5356. * This ADC mode is intended to be used with DMA mode non-circular.
  5357. * - Unlimited mode: DMA transfer requests are unlimited,
  5358. * whatever number of DMA data transfers (number of
  5359. * ADC conversions).
  5360. * This ADC mode is intended to be used with DMA mode circular.
  5361. * @note If ADC DMA requests mode is set to unlimited and DMA is set to
  5362. * mode non-circular:
  5363. * when DMA transfers size will be reached, DMA will stop transfers of
  5364. * ADC conversions data ADC will raise an overrun error
  5365. * (overrun flag and interruption if enabled).
  5366. * @note How to retrieve multimode conversion data:
  5367. * Whatever multimode transfer by DMA setting: using function
  5368. * @ref LL_ADC_REG_ReadMultiConversionData32().
  5369. * If ADC multimode transfer by DMA is selected: conversion data
  5370. * is a raw data with ADC master and slave concatenated.
  5371. * A macro is available to get the conversion data of
  5372. * ADC master or ADC slave: see helper macro
  5373. * @ref __LL_ADC_MULTI_CONV_DATA_MASTER_SLAVE().
  5374. * @rmtoll CCR MDMA LL_ADC_GetMultiDMATransfer\n
  5375. * CCR DMACFG LL_ADC_GetMultiDMATransfer
  5376. * @param ADCxy_COMMON ADC common instance
  5377. * (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() )
  5378. * @retval Returned value can be one of the following values:
  5379. * @arg @ref LL_ADC_MULTI_REG_DMA_EACH_ADC
  5380. * @arg @ref LL_ADC_MULTI_REG_DMA_LIMIT_RES12_10B
  5381. * @arg @ref LL_ADC_MULTI_REG_DMA_LIMIT_RES8_6B
  5382. * @arg @ref LL_ADC_MULTI_REG_DMA_UNLMT_RES12_10B
  5383. * @arg @ref LL_ADC_MULTI_REG_DMA_UNLMT_RES8_6B
  5384. */
  5385. __STATIC_INLINE uint32_t LL_ADC_GetMultiDMATransfer(ADC_Common_TypeDef *ADCxy_COMMON)
  5386. {
  5387. return (uint32_t)(READ_BIT(ADCxy_COMMON->CCR, ADC_CCR_MDMA | ADC_CCR_DMACFG));
  5388. }
  5389. /**
  5390. * @brief Set ADC multimode delay between 2 sampling phases.
  5391. * @note The sampling delay range depends on ADC resolution:
  5392. * - ADC resolution 12 bits can have maximum delay of 12 cycles.
  5393. * - ADC resolution 10 bits can have maximum delay of 10 cycles.
  5394. * - ADC resolution 8 bits can have maximum delay of 8 cycles.
  5395. * - ADC resolution 6 bits can have maximum delay of 6 cycles.
  5396. * @note On this STM32 serie, setting of this feature is conditioned to
  5397. * ADC state:
  5398. * All ADC instances of the ADC common group must be disabled.
  5399. * This check can be done with function @ref LL_ADC_IsEnabled() for each
  5400. * ADC instance or by using helper macro helper macro
  5401. * @ref __LL_ADC_IS_ENABLED_ALL_COMMON_INSTANCE().
  5402. * @rmtoll CCR DELAY LL_ADC_SetMultiTwoSamplingDelay
  5403. * @param ADCxy_COMMON ADC common instance
  5404. * (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() )
  5405. * @param MultiTwoSamplingDelay This parameter can be one of the following values:
  5406. * @arg @ref LL_ADC_MULTI_TWOSMP_DELAY_1CYCLE
  5407. * @arg @ref LL_ADC_MULTI_TWOSMP_DELAY_2CYCLES
  5408. * @arg @ref LL_ADC_MULTI_TWOSMP_DELAY_3CYCLES
  5409. * @arg @ref LL_ADC_MULTI_TWOSMP_DELAY_4CYCLES
  5410. * @arg @ref LL_ADC_MULTI_TWOSMP_DELAY_5CYCLES
  5411. * @arg @ref LL_ADC_MULTI_TWOSMP_DELAY_6CYCLES (1)
  5412. * @arg @ref LL_ADC_MULTI_TWOSMP_DELAY_7CYCLES (1)
  5413. * @arg @ref LL_ADC_MULTI_TWOSMP_DELAY_8CYCLES (2)
  5414. * @arg @ref LL_ADC_MULTI_TWOSMP_DELAY_9CYCLES (2)
  5415. * @arg @ref LL_ADC_MULTI_TWOSMP_DELAY_10CYCLES (2)
  5416. * @arg @ref LL_ADC_MULTI_TWOSMP_DELAY_11CYCLES (3)
  5417. * @arg @ref LL_ADC_MULTI_TWOSMP_DELAY_12CYCLES (3)
  5418. *
  5419. * (1) Parameter available only if ADC resolution is 12, 10 or 8 bits.\n
  5420. * (2) Parameter available only if ADC resolution is 12 or 10 bits.\n
  5421. * (3) Parameter available only if ADC resolution is 12 bits.
  5422. * @retval None
  5423. */
  5424. __STATIC_INLINE void LL_ADC_SetMultiTwoSamplingDelay(ADC_Common_TypeDef *ADCxy_COMMON, uint32_t MultiTwoSamplingDelay)
  5425. {
  5426. MODIFY_REG(ADCxy_COMMON->CCR, ADC_CCR_DELAY, MultiTwoSamplingDelay);
  5427. }
  5428. /**
  5429. * @brief Get ADC multimode delay between 2 sampling phases.
  5430. * @rmtoll CCR DELAY LL_ADC_GetMultiTwoSamplingDelay
  5431. * @param ADCxy_COMMON ADC common instance
  5432. * (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() )
  5433. * @retval Returned value can be one of the following values:
  5434. * @arg @ref LL_ADC_MULTI_TWOSMP_DELAY_1CYCLE
  5435. * @arg @ref LL_ADC_MULTI_TWOSMP_DELAY_2CYCLES
  5436. * @arg @ref LL_ADC_MULTI_TWOSMP_DELAY_3CYCLES
  5437. * @arg @ref LL_ADC_MULTI_TWOSMP_DELAY_4CYCLES
  5438. * @arg @ref LL_ADC_MULTI_TWOSMP_DELAY_5CYCLES
  5439. * @arg @ref LL_ADC_MULTI_TWOSMP_DELAY_6CYCLES (1)
  5440. * @arg @ref LL_ADC_MULTI_TWOSMP_DELAY_7CYCLES (1)
  5441. * @arg @ref LL_ADC_MULTI_TWOSMP_DELAY_8CYCLES (2)
  5442. * @arg @ref LL_ADC_MULTI_TWOSMP_DELAY_9CYCLES (2)
  5443. * @arg @ref LL_ADC_MULTI_TWOSMP_DELAY_10CYCLES (2)
  5444. * @arg @ref LL_ADC_MULTI_TWOSMP_DELAY_11CYCLES (3)
  5445. * @arg @ref LL_ADC_MULTI_TWOSMP_DELAY_12CYCLES (3)
  5446. *
  5447. * (1) Parameter available only if ADC resolution is 12, 10 or 8 bits.\n
  5448. * (2) Parameter available only if ADC resolution is 12 or 10 bits.\n
  5449. * (3) Parameter available only if ADC resolution is 12 bits.
  5450. */
  5451. __STATIC_INLINE uint32_t LL_ADC_GetMultiTwoSamplingDelay(ADC_Common_TypeDef *ADCxy_COMMON)
  5452. {
  5453. return (uint32_t)(READ_BIT(ADCxy_COMMON->CCR, ADC_CCR_DELAY));
  5454. }
  5455. #endif /* ADC_MULTIMODE_SUPPORT */
  5456. /**
  5457. * @}
  5458. */
  5459. /** @defgroup ADC_LL_EF_Operation_ADC_Instance Operation on ADC hierarchical scope: ADC instance
  5460. * @{
  5461. */
  5462. /**
  5463. * @brief Enable ADC instance internal voltage regulator.
  5464. * @note On this STM32 serie, after ADC internal voltage regulator enable,
  5465. * a delay for ADC internal voltage regulator stabilization
  5466. * is required before performing a ADC calibration or ADC enable.
  5467. * Refer to device datasheet, parameter tADCVREG_STUP.
  5468. * Refer to literal @ref LL_ADC_DELAY_INTERNAL_REGUL_STAB_US.
  5469. * @note On this STM32 serie, setting of this feature is conditioned to
  5470. * ADC state:
  5471. * ADC must be ADC disabled.
  5472. * @rmtoll CR ADVREGEN LL_ADC_EnableInternalRegulator
  5473. * @param ADCx ADC instance
  5474. * @retval None
  5475. */
  5476. __STATIC_INLINE void LL_ADC_EnableInternalRegulator(ADC_TypeDef *ADCx)
  5477. {
  5478. /* 1. Set the intermediate state before moving the ADC voltage regulator */
  5479. /* to state enable. */
  5480. CLEAR_BIT(ADCx->CR, (ADC_CR_ADVREGEN_1 | ADC_CR_ADVREGEN_0));
  5481. /* 2. Set the final state of ADC voltage regulator enable */
  5482. /* (ADVREGEN bits set to 0x01). */
  5483. /* Note: Write register with some additional bits forced to state reset */
  5484. /* instead of modifying only the selected bit for this function, */
  5485. /* to not interfere with bits with HW property "rs". */
  5486. MODIFY_REG(ADCx->CR,
  5487. ADC_CR_BITS_PROPERTY_RS,
  5488. ADC_CR_ADVREGEN_0);
  5489. }
  5490. /**
  5491. * @brief Disable ADC internal voltage regulator.
  5492. * @note On this STM32 serie, setting of this feature is conditioned to
  5493. * ADC state:
  5494. * ADC must be ADC disabled.
  5495. * @rmtoll CR ADVREGEN LL_ADC_DisableInternalRegulator
  5496. * @param ADCx ADC instance
  5497. * @retval None
  5498. */
  5499. __STATIC_INLINE void LL_ADC_DisableInternalRegulator(ADC_TypeDef *ADCx)
  5500. {
  5501. CLEAR_BIT(ADCx->CR, (ADC_CR_ADVREGEN | ADC_CR_BITS_PROPERTY_RS));
  5502. }
  5503. /**
  5504. * @brief Get the selected ADC instance internal voltage regulator state.
  5505. * @rmtoll CR ADVREGEN LL_ADC_IsInternalRegulatorEnabled
  5506. * @param ADCx ADC instance
  5507. * @retval 0: internal regulator is disabled, 1: internal regulator is enabled.
  5508. */
  5509. __STATIC_INLINE uint32_t LL_ADC_IsInternalRegulatorEnabled(ADC_TypeDef *ADCx)
  5510. {
  5511. return (READ_BIT(ADCx->CR, (ADC_CR_ADVREGEN_1 | ADC_CR_ADVREGEN_0)) == (ADC_CR_ADVREGEN_0));
  5512. }
  5513. /**
  5514. * @brief Enable the selected ADC instance.
  5515. * @note On this STM32 serie, after ADC enable, a delay for
  5516. * ADC internal analog stabilization is required before performing a
  5517. * ADC conversion start.
  5518. * Refer to device datasheet, parameter tSTAB.
  5519. * @note On this STM32 serie, flag LL_ADC_FLAG_ADRDY is raised when the ADC
  5520. * is enabled and when conversion clock is active.
  5521. * (not only core clock: this ADC has a dual clock domain)
  5522. * @note On this STM32 serie, setting of this feature is conditioned to
  5523. * ADC state:
  5524. * ADC must be ADC disabled and ADC internal voltage regulator enabled.
  5525. * @rmtoll CR ADEN LL_ADC_Enable
  5526. * @param ADCx ADC instance
  5527. * @retval None
  5528. */
  5529. __STATIC_INLINE void LL_ADC_Enable(ADC_TypeDef *ADCx)
  5530. {
  5531. /* Note: Write register with some additional bits forced to state reset */
  5532. /* instead of modifying only the selected bit for this function, */
  5533. /* to not interfere with bits with HW property "rs". */
  5534. MODIFY_REG(ADCx->CR,
  5535. ADC_CR_BITS_PROPERTY_RS,
  5536. ADC_CR_ADEN);
  5537. }
  5538. /**
  5539. * @brief Disable the selected ADC instance.
  5540. * @note On this STM32 serie, setting of this feature is conditioned to
  5541. * ADC state:
  5542. * ADC must be not disabled. Must be enabled without conversion on going
  5543. * on either groups regular or injected.
  5544. * @rmtoll CR ADDIS LL_ADC_Disable
  5545. * @param ADCx ADC instance
  5546. * @retval None
  5547. */
  5548. __STATIC_INLINE void LL_ADC_Disable(ADC_TypeDef *ADCx)
  5549. {
  5550. /* Note: Write register with some additional bits forced to state reset */
  5551. /* instead of modifying only the selected bit for this function, */
  5552. /* to not interfere with bits with HW property "rs". */
  5553. MODIFY_REG(ADCx->CR,
  5554. ADC_CR_BITS_PROPERTY_RS,
  5555. ADC_CR_ADDIS);
  5556. }
  5557. /**
  5558. * @brief Get the selected ADC instance enable state.
  5559. * @note On this STM32 serie, flag LL_ADC_FLAG_ADRDY is raised when the ADC
  5560. * is enabled and when conversion clock is active.
  5561. * (not only core clock: this ADC has a dual clock domain)
  5562. * @rmtoll CR ADEN LL_ADC_IsEnabled
  5563. * @param ADCx ADC instance
  5564. * @retval 0: ADC is disabled, 1: ADC is enabled.
  5565. */
  5566. __STATIC_INLINE uint32_t LL_ADC_IsEnabled(ADC_TypeDef *ADCx)
  5567. {
  5568. return (READ_BIT(ADCx->CR, ADC_CR_ADEN) == (ADC_CR_ADEN));
  5569. }
  5570. /**
  5571. * @brief Get the selected ADC instance disable state.
  5572. * @rmtoll CR ADDIS LL_ADC_IsDisableOngoing
  5573. * @param ADCx ADC instance
  5574. * @retval 0: no ADC disable command on going.
  5575. */
  5576. __STATIC_INLINE uint32_t LL_ADC_IsDisableOngoing(ADC_TypeDef *ADCx)
  5577. {
  5578. return (READ_BIT(ADCx->CR, ADC_CR_ADDIS) == (ADC_CR_ADDIS));
  5579. }
  5580. /**
  5581. * @brief Start ADC calibration in the mode single-ended
  5582. * or differential (for devices with differential mode available).
  5583. * @note On this STM32 serie, a minimum number of ADC clock cycles
  5584. * are required between ADC end of calibration and ADC enable.
  5585. * Refer to literal @ref LL_ADC_DELAY_CALIB_ENABLE_ADC_CYCLES.
  5586. * @note For devices with differential mode available:
  5587. * Calibration of offset is specific to each of
  5588. * single-ended and differential modes
  5589. * (calibration run must be performed for each of these
  5590. * differential modes, if used afterwards and if the application
  5591. * requires their calibration).
  5592. * @note On this STM32 serie, setting of this feature is conditioned to
  5593. * ADC state:
  5594. * ADC must be ADC disabled.
  5595. * @rmtoll CR ADCAL LL_ADC_StartCalibration\n
  5596. * CR ADCALDIF LL_ADC_StartCalibration
  5597. * @param ADCx ADC instance
  5598. * @param SingleDiff This parameter can be one of the following values:
  5599. * @arg @ref LL_ADC_SINGLE_ENDED
  5600. * @arg @ref LL_ADC_DIFFERENTIAL_ENDED
  5601. * @retval None
  5602. */
  5603. __STATIC_INLINE void LL_ADC_StartCalibration(ADC_TypeDef *ADCx, uint32_t SingleDiff)
  5604. {
  5605. /* Note: Write register with some additional bits forced to state reset */
  5606. /* instead of modifying only the selected bit for this function, */
  5607. /* to not interfere with bits with HW property "rs". */
  5608. MODIFY_REG(ADCx->CR,
  5609. ADC_CR_ADCALDIF | ADC_CR_BITS_PROPERTY_RS,
  5610. ADC_CR_ADCAL | (SingleDiff & ADC_SINGLEDIFF_CALIB_START_MASK));
  5611. }
  5612. /**
  5613. * @brief Get ADC calibration state.
  5614. * @rmtoll CR ADCAL LL_ADC_IsCalibrationOnGoing
  5615. * @param ADCx ADC instance
  5616. * @retval 0: calibration complete, 1: calibration in progress.
  5617. */
  5618. __STATIC_INLINE uint32_t LL_ADC_IsCalibrationOnGoing(ADC_TypeDef *ADCx)
  5619. {
  5620. return (READ_BIT(ADCx->CR, ADC_CR_ADCAL) == (ADC_CR_ADCAL));
  5621. }
  5622. /**
  5623. * @}
  5624. */
  5625. /** @defgroup ADC_LL_EF_Operation_ADC_Group_Regular Operation on ADC hierarchical scope: group regular
  5626. * @{
  5627. */
  5628. /**
  5629. * @brief Start ADC group regular conversion.
  5630. * @note On this STM32 serie, this function is relevant for both
  5631. * internal trigger (SW start) and external trigger:
  5632. * - If ADC trigger has been set to software start, ADC conversion
  5633. * starts immediately.
  5634. * - If ADC trigger has been set to external trigger, ADC conversion
  5635. * will start at next trigger event (on the selected trigger edge)
  5636. * following the ADC start conversion command.
  5637. * @note On this STM32 serie, setting of this feature is conditioned to
  5638. * ADC state:
  5639. * ADC must be enabled without conversion on going on group regular,
  5640. * without conversion stop command on going on group regular,
  5641. * without ADC disable command on going.
  5642. * @rmtoll CR ADSTART LL_ADC_REG_StartConversion
  5643. * @param ADCx ADC instance
  5644. * @retval None
  5645. */
  5646. __STATIC_INLINE void LL_ADC_REG_StartConversion(ADC_TypeDef *ADCx)
  5647. {
  5648. /* Note: Write register with some additional bits forced to state reset */
  5649. /* instead of modifying only the selected bit for this function, */
  5650. /* to not interfere with bits with HW property "rs". */
  5651. MODIFY_REG(ADCx->CR,
  5652. ADC_CR_BITS_PROPERTY_RS,
  5653. ADC_CR_ADSTART);
  5654. }
  5655. /**
  5656. * @brief Stop ADC group regular conversion.
  5657. * @note On this STM32 serie, setting of this feature is conditioned to
  5658. * ADC state:
  5659. * ADC must be enabled with conversion on going on group regular,
  5660. * without ADC disable command on going.
  5661. * @rmtoll CR ADSTP LL_ADC_REG_StopConversion
  5662. * @param ADCx ADC instance
  5663. * @retval None
  5664. */
  5665. __STATIC_INLINE void LL_ADC_REG_StopConversion(ADC_TypeDef *ADCx)
  5666. {
  5667. /* Note: Write register with some additional bits forced to state reset */
  5668. /* instead of modifying only the selected bit for this function, */
  5669. /* to not interfere with bits with HW property "rs". */
  5670. MODIFY_REG(ADCx->CR,
  5671. ADC_CR_BITS_PROPERTY_RS,
  5672. ADC_CR_ADSTP);
  5673. }
  5674. /**
  5675. * @brief Get ADC group regular conversion state.
  5676. * @rmtoll CR ADSTART LL_ADC_REG_IsConversionOngoing
  5677. * @param ADCx ADC instance
  5678. * @retval 0: no conversion is on going on ADC group regular.
  5679. */
  5680. __STATIC_INLINE uint32_t LL_ADC_REG_IsConversionOngoing(ADC_TypeDef *ADCx)
  5681. {
  5682. return (READ_BIT(ADCx->CR, ADC_CR_ADSTART) == (ADC_CR_ADSTART));
  5683. }
  5684. /**
  5685. * @brief Get ADC group regular command of conversion stop state
  5686. * @rmtoll CR ADSTP LL_ADC_REG_IsStopConversionOngoing
  5687. * @param ADCx ADC instance
  5688. * @retval 0: no command of conversion stop is on going on ADC group regular.
  5689. */
  5690. __STATIC_INLINE uint32_t LL_ADC_REG_IsStopConversionOngoing(ADC_TypeDef *ADCx)
  5691. {
  5692. return (READ_BIT(ADCx->CR, ADC_CR_ADSTP) == (ADC_CR_ADSTP));
  5693. }
  5694. /**
  5695. * @brief Get ADC group regular conversion data, range fit for
  5696. * all ADC configurations: all ADC resolutions and
  5697. * all oversampling increased data width (for devices
  5698. * with feature oversampling).
  5699. * @rmtoll DR RDATA LL_ADC_REG_ReadConversionData32
  5700. * @param ADCx ADC instance
  5701. * @retval Value between Min_Data=0x00000000 and Max_Data=0xFFFFFFFF
  5702. */
  5703. __STATIC_INLINE uint32_t LL_ADC_REG_ReadConversionData32(ADC_TypeDef *ADCx)
  5704. {
  5705. return (uint32_t)(READ_BIT(ADCx->DR, ADC_DR_RDATA));
  5706. }
  5707. /**
  5708. * @brief Get ADC group regular conversion data, range fit for
  5709. * ADC resolution 12 bits.
  5710. * @note For devices with feature oversampling: Oversampling
  5711. * can increase data width, function for extended range
  5712. * may be needed: @ref LL_ADC_REG_ReadConversionData32.
  5713. * @rmtoll DR RDATA LL_ADC_REG_ReadConversionData12
  5714. * @param ADCx ADC instance
  5715. * @retval Value between Min_Data=0x000 and Max_Data=0xFFF
  5716. */
  5717. __STATIC_INLINE uint16_t LL_ADC_REG_ReadConversionData12(ADC_TypeDef *ADCx)
  5718. {
  5719. return (uint16_t)(READ_BIT(ADCx->DR, ADC_DR_RDATA));
  5720. }
  5721. /**
  5722. * @brief Get ADC group regular conversion data, range fit for
  5723. * ADC resolution 10 bits.
  5724. * @note For devices with feature oversampling: Oversampling
  5725. * can increase data width, function for extended range
  5726. * may be needed: @ref LL_ADC_REG_ReadConversionData32.
  5727. * @rmtoll DR RDATA LL_ADC_REG_ReadConversionData10
  5728. * @param ADCx ADC instance
  5729. * @retval Value between Min_Data=0x000 and Max_Data=0x3FF
  5730. */
  5731. __STATIC_INLINE uint16_t LL_ADC_REG_ReadConversionData10(ADC_TypeDef *ADCx)
  5732. {
  5733. return (uint16_t)(READ_BIT(ADCx->DR, ADC_DR_RDATA));
  5734. }
  5735. /**
  5736. * @brief Get ADC group regular conversion data, range fit for
  5737. * ADC resolution 8 bits.
  5738. * @note For devices with feature oversampling: Oversampling
  5739. * can increase data width, function for extended range
  5740. * may be needed: @ref LL_ADC_REG_ReadConversionData32.
  5741. * @rmtoll DR RDATA LL_ADC_REG_ReadConversionData8
  5742. * @param ADCx ADC instance
  5743. * @retval Value between Min_Data=0x00 and Max_Data=0xFF
  5744. */
  5745. __STATIC_INLINE uint8_t LL_ADC_REG_ReadConversionData8(ADC_TypeDef *ADCx)
  5746. {
  5747. return (uint8_t)(READ_BIT(ADCx->DR, ADC_DR_RDATA));
  5748. }
  5749. /**
  5750. * @brief Get ADC group regular conversion data, range fit for
  5751. * ADC resolution 6 bits.
  5752. * @note For devices with feature oversampling: Oversampling
  5753. * can increase data width, function for extended range
  5754. * may be needed: @ref LL_ADC_REG_ReadConversionData32.
  5755. * @rmtoll DR RDATA LL_ADC_REG_ReadConversionData6
  5756. * @param ADCx ADC instance
  5757. * @retval Value between Min_Data=0x00 and Max_Data=0x3F
  5758. */
  5759. __STATIC_INLINE uint8_t LL_ADC_REG_ReadConversionData6(ADC_TypeDef *ADCx)
  5760. {
  5761. return (uint8_t)(READ_BIT(ADCx->DR, ADC_DR_RDATA));
  5762. }
  5763. #if defined(ADC_MULTIMODE_SUPPORT)
  5764. /**
  5765. * @brief Get ADC multimode conversion data of ADC master, ADC slave
  5766. * or raw data with ADC master and slave concatenated.
  5767. * @note If raw data with ADC master and slave concatenated is retrieved,
  5768. * a macro is available to get the conversion data of
  5769. * ADC master or ADC slave: see helper macro
  5770. * @ref __LL_ADC_MULTI_CONV_DATA_MASTER_SLAVE().
  5771. * (however this macro is mainly intended for multimode
  5772. * transfer by DMA, because this function can do the same
  5773. * by getting multimode conversion data of ADC master or ADC slave
  5774. * separately).
  5775. * @rmtoll CDR RDATA_MST LL_ADC_REG_ReadMultiConversionData32\n
  5776. * CDR RDATA_SLV LL_ADC_REG_ReadMultiConversionData32
  5777. * @param ADCxy_COMMON ADC common instance
  5778. * (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() )
  5779. * @param ConversionData This parameter can be one of the following values:
  5780. * @arg @ref LL_ADC_MULTI_MASTER
  5781. * @arg @ref LL_ADC_MULTI_SLAVE
  5782. * @arg @ref LL_ADC_MULTI_MASTER_SLAVE
  5783. * @retval Value between Min_Data=0x00000000 and Max_Data=0xFFFFFFFF
  5784. */
  5785. __STATIC_INLINE uint32_t LL_ADC_REG_ReadMultiConversionData32(ADC_Common_TypeDef *ADCxy_COMMON, uint32_t ConversionData)
  5786. {
  5787. return (uint32_t)(READ_BIT(ADCxy_COMMON->CDR,
  5788. ConversionData)
  5789. >> POSITION_VAL(ConversionData)
  5790. );
  5791. }
  5792. #endif /* ADC_MULTIMODE_SUPPORT */
  5793. /**
  5794. * @}
  5795. */
  5796. /** @defgroup ADC_LL_EF_Operation_ADC_Group_Injected Operation on ADC hierarchical scope: group injected
  5797. * @{
  5798. */
  5799. /**
  5800. * @brief Start ADC group injected conversion.
  5801. * @note On this STM32 serie, this function is relevant for both
  5802. * internal trigger (SW start) and external trigger:
  5803. * - If ADC trigger has been set to software start, ADC conversion
  5804. * starts immediately.
  5805. * - If ADC trigger has been set to external trigger, ADC conversion
  5806. * will start at next trigger event (on the selected trigger edge)
  5807. * following the ADC start conversion command.
  5808. * @note On this STM32 serie, setting of this feature is conditioned to
  5809. * ADC state:
  5810. * ADC must be enabled without conversion on going on group injected,
  5811. * without conversion stop command on going on group injected,
  5812. * without ADC disable command on going.
  5813. * @rmtoll CR JADSTART LL_ADC_INJ_StartConversion
  5814. * @param ADCx ADC instance
  5815. * @retval None
  5816. */
  5817. __STATIC_INLINE void LL_ADC_INJ_StartConversion(ADC_TypeDef *ADCx)
  5818. {
  5819. /* Note: Write register with some additional bits forced to state reset */
  5820. /* instead of modifying only the selected bit for this function, */
  5821. /* to not interfere with bits with HW property "rs". */
  5822. MODIFY_REG(ADCx->CR,
  5823. ADC_CR_BITS_PROPERTY_RS,
  5824. ADC_CR_JADSTART);
  5825. }
  5826. /**
  5827. * @brief Stop ADC group injected conversion.
  5828. * @note On this STM32 serie, setting of this feature is conditioned to
  5829. * ADC state:
  5830. * ADC must be enabled with conversion on going on group injected,
  5831. * without ADC disable command on going.
  5832. * @rmtoll CR JADSTP LL_ADC_INJ_StopConversion
  5833. * @param ADCx ADC instance
  5834. * @retval None
  5835. */
  5836. __STATIC_INLINE void LL_ADC_INJ_StopConversion(ADC_TypeDef *ADCx)
  5837. {
  5838. /* Note: Write register with some additional bits forced to state reset */
  5839. /* instead of modifying only the selected bit for this function, */
  5840. /* to not interfere with bits with HW property "rs". */
  5841. MODIFY_REG(ADCx->CR,
  5842. ADC_CR_BITS_PROPERTY_RS,
  5843. ADC_CR_JADSTP);
  5844. }
  5845. /**
  5846. * @brief Get ADC group injected conversion state.
  5847. * @rmtoll CR JADSTART LL_ADC_INJ_IsConversionOngoing
  5848. * @param ADCx ADC instance
  5849. * @retval 0: no conversion is on going on ADC group injected.
  5850. */
  5851. __STATIC_INLINE uint32_t LL_ADC_INJ_IsConversionOngoing(ADC_TypeDef *ADCx)
  5852. {
  5853. return (READ_BIT(ADCx->CR, ADC_CR_JADSTART) == (ADC_CR_JADSTART));
  5854. }
  5855. /**
  5856. * @brief Get ADC group injected command of conversion stop state
  5857. * @rmtoll CR JADSTP LL_ADC_INJ_IsStopConversionOngoing
  5858. * @param ADCx ADC instance
  5859. * @retval 0: no command of conversion stop is on going on ADC group injected.
  5860. */
  5861. __STATIC_INLINE uint32_t LL_ADC_INJ_IsStopConversionOngoing(ADC_TypeDef *ADCx)
  5862. {
  5863. return (READ_BIT(ADCx->CR, ADC_CR_JADSTP) == (ADC_CR_JADSTP));
  5864. }
  5865. /**
  5866. * @brief Get ADC group regular conversion data, range fit for
  5867. * all ADC configurations: all ADC resolutions and
  5868. * all oversampling increased data width (for devices
  5869. * with feature oversampling).
  5870. * @rmtoll JDR1 JDATA LL_ADC_INJ_ReadConversionData32\n
  5871. * JDR2 JDATA LL_ADC_INJ_ReadConversionData32\n
  5872. * JDR3 JDATA LL_ADC_INJ_ReadConversionData32\n
  5873. * JDR4 JDATA LL_ADC_INJ_ReadConversionData32
  5874. * @param ADCx ADC instance
  5875. * @param Rank This parameter can be one of the following values:
  5876. * @arg @ref LL_ADC_INJ_RANK_1
  5877. * @arg @ref LL_ADC_INJ_RANK_2
  5878. * @arg @ref LL_ADC_INJ_RANK_3
  5879. * @arg @ref LL_ADC_INJ_RANK_4
  5880. * @retval Value between Min_Data=0x00000000 and Max_Data=0xFFFFFFFF
  5881. */
  5882. __STATIC_INLINE uint32_t LL_ADC_INJ_ReadConversionData32(ADC_TypeDef *ADCx, uint32_t Rank)
  5883. {
  5884. register uint32_t *preg = __ADC_PTR_REG_OFFSET(ADCx->JDR1, __ADC_MASK_SHIFT(Rank, ADC_INJ_JDRX_REGOFFSET_MASK));
  5885. return (uint32_t)(READ_BIT(*preg,
  5886. ADC_JDR1_JDATA)
  5887. );
  5888. }
  5889. /**
  5890. * @brief Get ADC group injected conversion data, range fit for
  5891. * ADC resolution 12 bits.
  5892. * @note For devices with feature oversampling: Oversampling
  5893. * can increase data width, function for extended range
  5894. * may be needed: @ref LL_ADC_INJ_ReadConversionData32.
  5895. * @rmtoll JDR1 JDATA LL_ADC_INJ_ReadConversionData12\n
  5896. * JDR2 JDATA LL_ADC_INJ_ReadConversionData12\n
  5897. * JDR3 JDATA LL_ADC_INJ_ReadConversionData12\n
  5898. * JDR4 JDATA LL_ADC_INJ_ReadConversionData12
  5899. * @param ADCx ADC instance
  5900. * @param Rank This parameter can be one of the following values:
  5901. * @arg @ref LL_ADC_INJ_RANK_1
  5902. * @arg @ref LL_ADC_INJ_RANK_2
  5903. * @arg @ref LL_ADC_INJ_RANK_3
  5904. * @arg @ref LL_ADC_INJ_RANK_4
  5905. * @retval Value between Min_Data=0x000 and Max_Data=0xFFF
  5906. */
  5907. __STATIC_INLINE uint16_t LL_ADC_INJ_ReadConversionData12(ADC_TypeDef *ADCx, uint32_t Rank)
  5908. {
  5909. register uint32_t *preg = __ADC_PTR_REG_OFFSET(ADCx->JDR1, __ADC_MASK_SHIFT(Rank, ADC_INJ_JDRX_REGOFFSET_MASK));
  5910. return (uint16_t)(READ_BIT(*preg,
  5911. ADC_JDR1_JDATA)
  5912. );
  5913. }
  5914. /**
  5915. * @brief Get ADC group injected conversion data, range fit for
  5916. * ADC resolution 10 bits.
  5917. * @note For devices with feature oversampling: Oversampling
  5918. * can increase data width, function for extended range
  5919. * may be needed: @ref LL_ADC_INJ_ReadConversionData32.
  5920. * @rmtoll JDR1 JDATA LL_ADC_INJ_ReadConversionData10\n
  5921. * JDR2 JDATA LL_ADC_INJ_ReadConversionData10\n
  5922. * JDR3 JDATA LL_ADC_INJ_ReadConversionData10\n
  5923. * JDR4 JDATA LL_ADC_INJ_ReadConversionData10
  5924. * @param ADCx ADC instance
  5925. * @param Rank This parameter can be one of the following values:
  5926. * @arg @ref LL_ADC_INJ_RANK_1
  5927. * @arg @ref LL_ADC_INJ_RANK_2
  5928. * @arg @ref LL_ADC_INJ_RANK_3
  5929. * @arg @ref LL_ADC_INJ_RANK_4
  5930. * @retval Value between Min_Data=0x000 and Max_Data=0x3FF
  5931. */
  5932. __STATIC_INLINE uint16_t LL_ADC_INJ_ReadConversionData10(ADC_TypeDef *ADCx, uint32_t Rank)
  5933. {
  5934. register uint32_t *preg = __ADC_PTR_REG_OFFSET(ADCx->JDR1, __ADC_MASK_SHIFT(Rank, ADC_INJ_JDRX_REGOFFSET_MASK));
  5935. return (uint16_t)(READ_BIT(*preg,
  5936. ADC_JDR1_JDATA)
  5937. );
  5938. }
  5939. /**
  5940. * @brief Get ADC group injected conversion data, range fit for
  5941. * ADC resolution 8 bits.
  5942. * @note For devices with feature oversampling: Oversampling
  5943. * can increase data width, function for extended range
  5944. * may be needed: @ref LL_ADC_INJ_ReadConversionData32.
  5945. * @rmtoll JDR1 JDATA LL_ADC_INJ_ReadConversionData8\n
  5946. * JDR2 JDATA LL_ADC_INJ_ReadConversionData8\n
  5947. * JDR3 JDATA LL_ADC_INJ_ReadConversionData8\n
  5948. * JDR4 JDATA LL_ADC_INJ_ReadConversionData8
  5949. * @param ADCx ADC instance
  5950. * @param Rank This parameter can be one of the following values:
  5951. * @arg @ref LL_ADC_INJ_RANK_1
  5952. * @arg @ref LL_ADC_INJ_RANK_2
  5953. * @arg @ref LL_ADC_INJ_RANK_3
  5954. * @arg @ref LL_ADC_INJ_RANK_4
  5955. * @retval Value between Min_Data=0x00 and Max_Data=0xFF
  5956. */
  5957. __STATIC_INLINE uint8_t LL_ADC_INJ_ReadConversionData8(ADC_TypeDef *ADCx, uint32_t Rank)
  5958. {
  5959. register uint32_t *preg = __ADC_PTR_REG_OFFSET(ADCx->JDR1, __ADC_MASK_SHIFT(Rank, ADC_INJ_JDRX_REGOFFSET_MASK));
  5960. return (uint8_t)(READ_BIT(*preg,
  5961. ADC_JDR1_JDATA)
  5962. );
  5963. }
  5964. /**
  5965. * @brief Get ADC group injected conversion data, range fit for
  5966. * ADC resolution 6 bits.
  5967. * @note For devices with feature oversampling: Oversampling
  5968. * can increase data width, function for extended range
  5969. * may be needed: @ref LL_ADC_INJ_ReadConversionData32.
  5970. * @rmtoll JDR1 JDATA LL_ADC_INJ_ReadConversionData6\n
  5971. * JDR2 JDATA LL_ADC_INJ_ReadConversionData6\n
  5972. * JDR3 JDATA LL_ADC_INJ_ReadConversionData6\n
  5973. * JDR4 JDATA LL_ADC_INJ_ReadConversionData6
  5974. * @param ADCx ADC instance
  5975. * @param Rank This parameter can be one of the following values:
  5976. * @arg @ref LL_ADC_INJ_RANK_1
  5977. * @arg @ref LL_ADC_INJ_RANK_2
  5978. * @arg @ref LL_ADC_INJ_RANK_3
  5979. * @arg @ref LL_ADC_INJ_RANK_4
  5980. * @retval Value between Min_Data=0x00 and Max_Data=0x3F
  5981. */
  5982. __STATIC_INLINE uint8_t LL_ADC_INJ_ReadConversionData6(ADC_TypeDef *ADCx, uint32_t Rank)
  5983. {
  5984. register uint32_t *preg = __ADC_PTR_REG_OFFSET(ADCx->JDR1, __ADC_MASK_SHIFT(Rank, ADC_INJ_JDRX_REGOFFSET_MASK));
  5985. return (uint8_t)(READ_BIT(*preg,
  5986. ADC_JDR1_JDATA)
  5987. );
  5988. }
  5989. /**
  5990. * @}
  5991. */
  5992. /** @defgroup ADC_LL_EF_FLAG_Management ADC flag management
  5993. * @{
  5994. */
  5995. /**
  5996. * @brief Get flag ADC ready.
  5997. * @note On this STM32 serie, flag LL_ADC_FLAG_ADRDY is raised when the ADC
  5998. * is enabled and when conversion clock is active.
  5999. * (not only core clock: this ADC has a dual clock domain)
  6000. * @rmtoll ISR ADRDY LL_ADC_IsActiveFlag_ADRDY
  6001. * @param ADCx ADC instance
  6002. * @retval State of bit (1 or 0).
  6003. */
  6004. __STATIC_INLINE uint32_t LL_ADC_IsActiveFlag_ADRDY(ADC_TypeDef *ADCx)
  6005. {
  6006. return (READ_BIT(ADCx->ISR, LL_ADC_FLAG_ADRDY) == (LL_ADC_FLAG_ADRDY));
  6007. }
  6008. /**
  6009. * @brief Get flag ADC group regular end of unitary conversion.
  6010. * @rmtoll ISR EOC LL_ADC_IsActiveFlag_EOC
  6011. * @param ADCx ADC instance
  6012. * @retval State of bit (1 or 0).
  6013. */
  6014. __STATIC_INLINE uint32_t LL_ADC_IsActiveFlag_EOC(ADC_TypeDef *ADCx)
  6015. {
  6016. return (READ_BIT(ADCx->ISR, ADC_ISR_EOC) == (ADC_ISR_EOC));
  6017. }
  6018. /**
  6019. * @brief Get flag ADC group regular end of sequence conversions.
  6020. * @rmtoll ISR EOS LL_ADC_IsActiveFlag_EOS
  6021. * @param ADCx ADC instance
  6022. * @retval State of bit (1 or 0).
  6023. */
  6024. __STATIC_INLINE uint32_t LL_ADC_IsActiveFlag_EOS(ADC_TypeDef *ADCx)
  6025. {
  6026. return (READ_BIT(ADCx->ISR, LL_ADC_FLAG_EOS) == (LL_ADC_FLAG_EOS));
  6027. }
  6028. /**
  6029. * @brief Get flag ADC group regular overrun.
  6030. * @rmtoll ISR OVR LL_ADC_IsActiveFlag_OVR
  6031. * @param ADCx ADC instance
  6032. * @retval State of bit (1 or 0).
  6033. */
  6034. __STATIC_INLINE uint32_t LL_ADC_IsActiveFlag_OVR(ADC_TypeDef *ADCx)
  6035. {
  6036. return (READ_BIT(ADCx->ISR, LL_ADC_FLAG_OVR) == (LL_ADC_FLAG_OVR));
  6037. }
  6038. /**
  6039. * @brief Get flag ADC group regular end of sampling phase.
  6040. * @rmtoll ISR EOSMP LL_ADC_IsActiveFlag_EOSMP
  6041. * @param ADCx ADC instance
  6042. * @retval State of bit (1 or 0).
  6043. */
  6044. __STATIC_INLINE uint32_t LL_ADC_IsActiveFlag_EOSMP(ADC_TypeDef *ADCx)
  6045. {
  6046. return (READ_BIT(ADCx->ISR, LL_ADC_FLAG_EOSMP) == (LL_ADC_FLAG_EOSMP));
  6047. }
  6048. /**
  6049. * @brief Get flag ADC group injected end of unitary conversion.
  6050. * @rmtoll ISR JEOC LL_ADC_IsActiveFlag_JEOC
  6051. * @param ADCx ADC instance
  6052. * @retval State of bit (1 or 0).
  6053. */
  6054. __STATIC_INLINE uint32_t LL_ADC_IsActiveFlag_JEOC(ADC_TypeDef *ADCx)
  6055. {
  6056. return (READ_BIT(ADCx->ISR, LL_ADC_FLAG_JEOC) == (LL_ADC_FLAG_JEOC));
  6057. }
  6058. /**
  6059. * @brief Get flag ADC group injected end of sequence conversions.
  6060. * @rmtoll ISR JEOS LL_ADC_IsActiveFlag_JEOS
  6061. * @param ADCx ADC instance
  6062. * @retval State of bit (1 or 0).
  6063. */
  6064. __STATIC_INLINE uint32_t LL_ADC_IsActiveFlag_JEOS(ADC_TypeDef *ADCx)
  6065. {
  6066. return (READ_BIT(ADCx->ISR, LL_ADC_FLAG_JEOS) == (LL_ADC_FLAG_JEOS));
  6067. }
  6068. /**
  6069. * @brief Get flag ADC group injected contexts queue overflow.
  6070. * @rmtoll ISR JQOVF LL_ADC_IsActiveFlag_JQOVF
  6071. * @param ADCx ADC instance
  6072. * @retval State of bit (1 or 0).
  6073. */
  6074. __STATIC_INLINE uint32_t LL_ADC_IsActiveFlag_JQOVF(ADC_TypeDef *ADCx)
  6075. {
  6076. return (READ_BIT(ADCx->ISR, LL_ADC_FLAG_JQOVF) == (LL_ADC_FLAG_JQOVF));
  6077. }
  6078. /**
  6079. * @brief Get flag ADC analog watchdog 1 flag
  6080. * @rmtoll ISR AWD1 LL_ADC_IsActiveFlag_AWD1
  6081. * @param ADCx ADC instance
  6082. * @retval State of bit (1 or 0).
  6083. */
  6084. __STATIC_INLINE uint32_t LL_ADC_IsActiveFlag_AWD1(ADC_TypeDef *ADCx)
  6085. {
  6086. return (READ_BIT(ADCx->ISR, LL_ADC_FLAG_AWD1) == (LL_ADC_FLAG_AWD1));
  6087. }
  6088. /**
  6089. * @brief Get flag ADC analog watchdog 2.
  6090. * @rmtoll ISR AWD2 LL_ADC_IsActiveFlag_AWD2
  6091. * @param ADCx ADC instance
  6092. * @retval State of bit (1 or 0).
  6093. */
  6094. __STATIC_INLINE uint32_t LL_ADC_IsActiveFlag_AWD2(ADC_TypeDef *ADCx)
  6095. {
  6096. return (READ_BIT(ADCx->ISR, LL_ADC_FLAG_AWD2) == (LL_ADC_FLAG_AWD2));
  6097. }
  6098. /**
  6099. * @brief Get flag ADC analog watchdog 3.
  6100. * @rmtoll ISR AWD3 LL_ADC_IsActiveFlag_AWD3
  6101. * @param ADCx ADC instance
  6102. * @retval State of bit (1 or 0).
  6103. */
  6104. __STATIC_INLINE uint32_t LL_ADC_IsActiveFlag_AWD3(ADC_TypeDef *ADCx)
  6105. {
  6106. return (READ_BIT(ADCx->ISR, LL_ADC_FLAG_AWD3) == (LL_ADC_FLAG_AWD3));
  6107. }
  6108. /**
  6109. * @brief Clear flag ADC ready.
  6110. * @note On this STM32 serie, flag LL_ADC_FLAG_ADRDY is raised when the ADC
  6111. * is enabled and when conversion clock is active.
  6112. * (not only core clock: this ADC has a dual clock domain)
  6113. * @rmtoll ISR ADRDY LL_ADC_ClearFlag_ADRDY
  6114. * @param ADCx ADC instance
  6115. * @retval None
  6116. */
  6117. __STATIC_INLINE void LL_ADC_ClearFlag_ADRDY(ADC_TypeDef *ADCx)
  6118. {
  6119. WRITE_REG(ADCx->ISR, LL_ADC_FLAG_ADRDY);
  6120. }
  6121. /**
  6122. * @brief Clear flag ADC group regular end of unitary conversion.
  6123. * @rmtoll ISR EOC LL_ADC_ClearFlag_EOC
  6124. * @param ADCx ADC instance
  6125. * @retval None
  6126. */
  6127. __STATIC_INLINE void LL_ADC_ClearFlag_EOC(ADC_TypeDef *ADCx)
  6128. {
  6129. WRITE_REG(ADCx->ISR, LL_ADC_FLAG_EOC);
  6130. }
  6131. /**
  6132. * @brief Clear flag ADC group regular end of sequence conversions.
  6133. * @rmtoll ISR EOS LL_ADC_ClearFlag_EOS
  6134. * @param ADCx ADC instance
  6135. * @retval None
  6136. */
  6137. __STATIC_INLINE void LL_ADC_ClearFlag_EOS(ADC_TypeDef *ADCx)
  6138. {
  6139. WRITE_REG(ADCx->ISR, LL_ADC_FLAG_EOS);
  6140. }
  6141. /**
  6142. * @brief Clear flag ADC group regular overrun.
  6143. * @rmtoll ISR OVR LL_ADC_ClearFlag_OVR
  6144. * @param ADCx ADC instance
  6145. * @retval None
  6146. */
  6147. __STATIC_INLINE void LL_ADC_ClearFlag_OVR(ADC_TypeDef *ADCx)
  6148. {
  6149. WRITE_REG(ADCx->ISR, LL_ADC_FLAG_OVR);
  6150. }
  6151. /**
  6152. * @brief Clear flag ADC group regular end of sampling phase.
  6153. * @rmtoll ISR EOSMP LL_ADC_ClearFlag_EOSMP
  6154. * @param ADCx ADC instance
  6155. * @retval None
  6156. */
  6157. __STATIC_INLINE void LL_ADC_ClearFlag_EOSMP(ADC_TypeDef *ADCx)
  6158. {
  6159. WRITE_REG(ADCx->ISR, LL_ADC_FLAG_EOSMP);
  6160. }
  6161. /**
  6162. * @brief Clear flag ADC group injected end of unitary conversion.
  6163. * @rmtoll ISR JEOC LL_ADC_ClearFlag_JEOC
  6164. * @param ADCx ADC instance
  6165. * @retval None
  6166. */
  6167. __STATIC_INLINE void LL_ADC_ClearFlag_JEOC(ADC_TypeDef *ADCx)
  6168. {
  6169. WRITE_REG(ADCx->ISR, LL_ADC_FLAG_JEOC);
  6170. }
  6171. /**
  6172. * @brief Clear flag ADC group injected end of sequence conversions.
  6173. * @rmtoll ISR JEOS LL_ADC_ClearFlag_JEOS
  6174. * @param ADCx ADC instance
  6175. * @retval None
  6176. */
  6177. __STATIC_INLINE void LL_ADC_ClearFlag_JEOS(ADC_TypeDef *ADCx)
  6178. {
  6179. WRITE_REG(ADCx->ISR, LL_ADC_FLAG_JEOS);
  6180. }
  6181. /**
  6182. * @brief Clear flag ADC group injected contexts queue overflow.
  6183. * @rmtoll ISR JQOVF LL_ADC_ClearFlag_JQOVF
  6184. * @param ADCx ADC instance
  6185. * @retval None
  6186. */
  6187. __STATIC_INLINE void LL_ADC_ClearFlag_JQOVF(ADC_TypeDef *ADCx)
  6188. {
  6189. WRITE_REG(ADCx->ISR, LL_ADC_FLAG_JQOVF);
  6190. }
  6191. /**
  6192. * @brief Clear flag ADC analog watchdog 1.
  6193. * @rmtoll ISR AWD1 LL_ADC_ClearFlag_AWD1
  6194. * @param ADCx ADC instance
  6195. * @retval None
  6196. */
  6197. __STATIC_INLINE void LL_ADC_ClearFlag_AWD1(ADC_TypeDef *ADCx)
  6198. {
  6199. WRITE_REG(ADCx->ISR, LL_ADC_FLAG_AWD1);
  6200. }
  6201. /**
  6202. * @brief Clear flag ADC analog watchdog 2.
  6203. * @rmtoll ISR AWD2 LL_ADC_ClearFlag_AWD2
  6204. * @param ADCx ADC instance
  6205. * @retval None
  6206. */
  6207. __STATIC_INLINE void LL_ADC_ClearFlag_AWD2(ADC_TypeDef *ADCx)
  6208. {
  6209. WRITE_REG(ADCx->ISR, LL_ADC_FLAG_AWD2);
  6210. }
  6211. /**
  6212. * @brief Clear flag ADC analog watchdog 3.
  6213. * @rmtoll ISR AWD3 LL_ADC_ClearFlag_AWD3
  6214. * @param ADCx ADC instance
  6215. * @retval None
  6216. */
  6217. __STATIC_INLINE void LL_ADC_ClearFlag_AWD3(ADC_TypeDef *ADCx)
  6218. {
  6219. WRITE_REG(ADCx->ISR, LL_ADC_FLAG_AWD3);
  6220. }
  6221. #if defined(ADC_MULTIMODE_SUPPORT)
  6222. /**
  6223. * @brief Get flag multimode ADC ready of the ADC master.
  6224. * @rmtoll CSR ADRDY_MST LL_ADC_IsActiveFlag_MST_ADRDY
  6225. * @param ADCxy_COMMON ADC common instance
  6226. * (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() )
  6227. * @retval State of bit (1 or 0).
  6228. */
  6229. __STATIC_INLINE uint32_t LL_ADC_IsActiveFlag_MST_ADRDY(ADC_Common_TypeDef *ADCxy_COMMON)
  6230. {
  6231. return (READ_BIT(ADCxy_COMMON->CSR, LL_ADC_FLAG_ADRDY_MST) == (LL_ADC_FLAG_ADRDY_MST));
  6232. }
  6233. /**
  6234. * @brief Get flag multimode ADC ready of the ADC slave.
  6235. * @rmtoll CSR ADRDY_SLV LL_ADC_IsActiveFlag_SLV_ADRDY
  6236. * @param ADCxy_COMMON ADC common instance
  6237. * (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() )
  6238. * @retval State of bit (1 or 0).
  6239. */
  6240. __STATIC_INLINE uint32_t LL_ADC_IsActiveFlag_SLV_ADRDY(ADC_Common_TypeDef *ADCxy_COMMON)
  6241. {
  6242. return (READ_BIT(ADCxy_COMMON->CSR, LL_ADC_FLAG_ADRDY_SLV) == (LL_ADC_FLAG_ADRDY_SLV));
  6243. }
  6244. /**
  6245. * @brief Get flag multimode ADC group regular end of unitary conversion of the ADC master.
  6246. * @rmtoll CSR EOC_MST LL_ADC_IsActiveFlag_MST_EOC
  6247. * @param ADCxy_COMMON ADC common instance
  6248. * (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() )
  6249. * @retval State of bit (1 or 0).
  6250. */
  6251. __STATIC_INLINE uint32_t LL_ADC_IsActiveFlag_MST_EOC(ADC_Common_TypeDef *ADCxy_COMMON)
  6252. {
  6253. return (READ_BIT(ADCxy_COMMON->CSR, LL_ADC_FLAG_EOC_SLV) == (LL_ADC_FLAG_EOC_SLV));
  6254. }
  6255. /**
  6256. * @brief Get flag multimode ADC group regular end of unitary conversion of the ADC slave.
  6257. * @rmtoll CSR EOC_SLV LL_ADC_IsActiveFlag_SLV_EOC
  6258. * @param ADCxy_COMMON ADC common instance
  6259. * (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() )
  6260. * @retval State of bit (1 or 0).
  6261. */
  6262. __STATIC_INLINE uint32_t LL_ADC_IsActiveFlag_SLV_EOC(ADC_Common_TypeDef *ADCxy_COMMON)
  6263. {
  6264. return (READ_BIT(ADCxy_COMMON->CSR, LL_ADC_FLAG_EOC_SLV) == (LL_ADC_FLAG_EOC_SLV));
  6265. }
  6266. /**
  6267. * @brief Get flag multimode ADC group regular end of sequence conversions of the ADC master.
  6268. * @rmtoll CSR EOS_MST LL_ADC_IsActiveFlag_MST_EOS
  6269. * @param ADCxy_COMMON ADC common instance
  6270. * (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() )
  6271. * @retval State of bit (1 or 0).
  6272. */
  6273. __STATIC_INLINE uint32_t LL_ADC_IsActiveFlag_MST_EOS(ADC_Common_TypeDef *ADCxy_COMMON)
  6274. {
  6275. return (READ_BIT(ADCxy_COMMON->CSR, LL_ADC_FLAG_EOS_MST) == (LL_ADC_FLAG_EOS_MST));
  6276. }
  6277. /**
  6278. * @brief Get flag multimode ADC group regular end of sequence conversions of the ADC slave.
  6279. * @rmtoll CSR EOS_SLV LL_ADC_IsActiveFlag_SLV_EOS
  6280. * @param ADCxy_COMMON ADC common instance
  6281. * (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() )
  6282. * @retval State of bit (1 or 0).
  6283. */
  6284. __STATIC_INLINE uint32_t LL_ADC_IsActiveFlag_SLV_EOS(ADC_Common_TypeDef *ADCxy_COMMON)
  6285. {
  6286. return (READ_BIT(ADCxy_COMMON->CSR, LL_ADC_FLAG_EOS_SLV) == (LL_ADC_FLAG_EOS_SLV));
  6287. }
  6288. /**
  6289. * @brief Get flag multimode ADC group regular overrun of the ADC master.
  6290. * @rmtoll CSR OVR_MST LL_ADC_IsActiveFlag_MST_OVR
  6291. * @param ADCxy_COMMON ADC common instance
  6292. * (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() )
  6293. * @retval State of bit (1 or 0).
  6294. */
  6295. __STATIC_INLINE uint32_t LL_ADC_IsActiveFlag_MST_OVR(ADC_Common_TypeDef *ADCxy_COMMON)
  6296. {
  6297. return (READ_BIT(ADCxy_COMMON->CSR, LL_ADC_FLAG_OVR_MST) == (LL_ADC_FLAG_OVR_MST));
  6298. }
  6299. /**
  6300. * @brief Get flag multimode ADC group regular overrun of the ADC slave.
  6301. * @rmtoll CSR OVR_SLV LL_ADC_IsActiveFlag_SLV_OVR
  6302. * @param ADCxy_COMMON ADC common instance
  6303. * (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() )
  6304. * @retval State of bit (1 or 0).
  6305. */
  6306. __STATIC_INLINE uint32_t LL_ADC_IsActiveFlag_SLV_OVR(ADC_Common_TypeDef *ADCxy_COMMON)
  6307. {
  6308. return (READ_BIT(ADCxy_COMMON->CSR, LL_ADC_FLAG_OVR_SLV) == (LL_ADC_FLAG_OVR_SLV));
  6309. }
  6310. /**
  6311. * @brief Get flag multimode ADC group regular end of sampling of the ADC master.
  6312. * @rmtoll CSR EOSMP_MST LL_ADC_IsActiveFlag_MST_EOSMP
  6313. * @param ADCxy_COMMON ADC common instance
  6314. * (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() )
  6315. * @retval State of bit (1 or 0).
  6316. */
  6317. __STATIC_INLINE uint32_t LL_ADC_IsActiveFlag_MST_EOSMP(ADC_Common_TypeDef *ADCxy_COMMON)
  6318. {
  6319. return (READ_BIT(ADCxy_COMMON->CSR, LL_ADC_FLAG_EOSMP_MST) == (LL_ADC_FLAG_EOSMP_MST));
  6320. }
  6321. /**
  6322. * @brief Get flag multimode ADC group regular end of sampling of the ADC slave.
  6323. * @rmtoll CSR EOSMP_SLV LL_ADC_IsActiveFlag_SLV_EOSMP
  6324. * @param ADCxy_COMMON ADC common instance
  6325. * (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() )
  6326. * @retval State of bit (1 or 0).
  6327. */
  6328. __STATIC_INLINE uint32_t LL_ADC_IsActiveFlag_SLV_EOSMP(ADC_Common_TypeDef *ADCxy_COMMON)
  6329. {
  6330. return (READ_BIT(ADCxy_COMMON->CSR, LL_ADC_FLAG_EOSMP_SLV) == (LL_ADC_FLAG_EOSMP_SLV));
  6331. }
  6332. /**
  6333. * @brief Get flag multimode ADC group injected end of unitary conversion of the ADC master.
  6334. * @rmtoll CSR JEOC_MST LL_ADC_IsActiveFlag_MST_JEOC
  6335. * @param ADCxy_COMMON ADC common instance
  6336. * (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() )
  6337. * @retval State of bit (1 or 0).
  6338. */
  6339. __STATIC_INLINE uint32_t LL_ADC_IsActiveFlag_MST_JEOC(ADC_Common_TypeDef *ADCxy_COMMON)
  6340. {
  6341. return (READ_BIT(ADCxy_COMMON->CSR, LL_ADC_FLAG_JEOC_MST) == (LL_ADC_FLAG_JEOC_MST));
  6342. }
  6343. /**
  6344. * @brief Get flag multimode ADC group injected end of unitary conversion of the ADC slave.
  6345. * @rmtoll CSR JEOC_SLV LL_ADC_IsActiveFlag_SLV_JEOC
  6346. * @param ADCxy_COMMON ADC common instance
  6347. * (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() )
  6348. * @retval State of bit (1 or 0).
  6349. */
  6350. __STATIC_INLINE uint32_t LL_ADC_IsActiveFlag_SLV_JEOC(ADC_Common_TypeDef *ADCxy_COMMON)
  6351. {
  6352. return (READ_BIT(ADCxy_COMMON->CSR, LL_ADC_FLAG_JEOC_SLV) == (LL_ADC_FLAG_JEOC_SLV));
  6353. }
  6354. /**
  6355. * @brief Get flag multimode ADC group injected end of sequence conversions of the ADC master.
  6356. * @rmtoll CSR JEOS_MST LL_ADC_IsActiveFlag_MST_JEOS
  6357. * @param ADCxy_COMMON ADC common instance
  6358. * (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() )
  6359. * @retval State of bit (1 or 0).
  6360. */
  6361. __STATIC_INLINE uint32_t LL_ADC_IsActiveFlag_MST_JEOS(ADC_Common_TypeDef *ADCxy_COMMON)
  6362. {
  6363. return (READ_BIT(ADCxy_COMMON->CSR, LL_ADC_FLAG_JEOS_MST) == (LL_ADC_FLAG_JEOS_MST));
  6364. }
  6365. /**
  6366. * @brief Get flag multimode ADC group injected end of sequence conversions of the ADC slave.
  6367. * @rmtoll CSR JEOS_SLV LL_ADC_IsActiveFlag_SLV_JEOS
  6368. * @param ADCxy_COMMON ADC common instance
  6369. * (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() )
  6370. * @retval State of bit (1 or 0).
  6371. */
  6372. __STATIC_INLINE uint32_t LL_ADC_IsActiveFlag_SLV_JEOS(ADC_Common_TypeDef *ADCxy_COMMON)
  6373. {
  6374. return (READ_BIT(ADCxy_COMMON->CSR, LL_ADC_FLAG_JEOS_SLV) == (LL_ADC_FLAG_JEOS_SLV));
  6375. }
  6376. /**
  6377. * @brief Get flag multimode ADC group injected context queue overflow of the ADC master.
  6378. * @rmtoll CSR JQOVF_MST LL_ADC_IsActiveFlag_MST_JQOVF
  6379. * @param ADCxy_COMMON ADC common instance
  6380. * (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() )
  6381. * @retval State of bit (1 or 0).
  6382. */
  6383. __STATIC_INLINE uint32_t LL_ADC_IsActiveFlag_MST_JQOVF(ADC_Common_TypeDef *ADCxy_COMMON)
  6384. {
  6385. return (READ_BIT(ADCxy_COMMON->CSR, LL_ADC_FLAG_JQOVF_MST) == (LL_ADC_FLAG_JQOVF_MST));
  6386. }
  6387. /**
  6388. * @brief Get flag multimode ADC group injected context queue overflow of the ADC slave.
  6389. * @rmtoll CSR JQOVF_SLV LL_ADC_IsActiveFlag_SLV_JQOVF
  6390. * @param ADCxy_COMMON ADC common instance
  6391. * (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() )
  6392. * @retval State of bit (1 or 0).
  6393. */
  6394. __STATIC_INLINE uint32_t LL_ADC_IsActiveFlag_SLV_JQOVF(ADC_Common_TypeDef *ADCxy_COMMON)
  6395. {
  6396. return (READ_BIT(ADCxy_COMMON->CSR, LL_ADC_FLAG_JQOVF_SLV) == (LL_ADC_FLAG_JQOVF_SLV));
  6397. }
  6398. /**
  6399. * @brief Get flag multimode ADC analog watchdog 1 of the ADC master.
  6400. * @rmtoll CSR AWD1_MST LL_ADC_IsActiveFlag_MST_AWD1
  6401. * @param ADCxy_COMMON ADC common instance
  6402. * (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() )
  6403. * @retval State of bit (1 or 0).
  6404. */
  6405. __STATIC_INLINE uint32_t LL_ADC_IsActiveFlag_MST_AWD1(ADC_Common_TypeDef *ADCxy_COMMON)
  6406. {
  6407. return (READ_BIT(ADCxy_COMMON->CSR, LL_ADC_FLAG_AWD1_MST) == (LL_ADC_FLAG_AWD1_MST));
  6408. }
  6409. /**
  6410. * @brief Get flag multimode analog watchdog 1 of the ADC slave.
  6411. * @rmtoll CSR AWD1_SLV LL_ADC_IsActiveFlag_SLV_AWD1
  6412. * @param ADCxy_COMMON ADC common instance
  6413. * (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() )
  6414. * @retval State of bit (1 or 0).
  6415. */
  6416. __STATIC_INLINE uint32_t LL_ADC_IsActiveFlag_SLV_AWD1(ADC_Common_TypeDef *ADCxy_COMMON)
  6417. {
  6418. return (READ_BIT(ADCxy_COMMON->CSR, LL_ADC_FLAG_AWD1_SLV) == (LL_ADC_FLAG_AWD1_SLV));
  6419. }
  6420. /**
  6421. * @brief Get flag multimode ADC analog watchdog 2 of the ADC master.
  6422. * @rmtoll CSR AWD2_MST LL_ADC_IsActiveFlag_MST_AWD2
  6423. * @param ADCxy_COMMON ADC common instance
  6424. * (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() )
  6425. * @retval State of bit (1 or 0).
  6426. */
  6427. __STATIC_INLINE uint32_t LL_ADC_IsActiveFlag_MST_AWD2(ADC_Common_TypeDef *ADCxy_COMMON)
  6428. {
  6429. return (READ_BIT(ADCxy_COMMON->CSR, LL_ADC_FLAG_AWD2_MST) == (LL_ADC_FLAG_AWD2_MST));
  6430. }
  6431. /**
  6432. * @brief Get flag multimode ADC analog watchdog 2 of the ADC slave.
  6433. * @rmtoll CSR AWD2_SLV LL_ADC_IsActiveFlag_SLV_AWD2
  6434. * @param ADCxy_COMMON ADC common instance
  6435. * (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() )
  6436. * @retval State of bit (1 or 0).
  6437. */
  6438. __STATIC_INLINE uint32_t LL_ADC_IsActiveFlag_SLV_AWD2(ADC_Common_TypeDef *ADCxy_COMMON)
  6439. {
  6440. return (READ_BIT(ADCxy_COMMON->CSR, LL_ADC_FLAG_AWD2_SLV) == (LL_ADC_FLAG_AWD2_SLV));
  6441. }
  6442. /**
  6443. * @brief Get flag multimode ADC analog watchdog 3 of the ADC master.
  6444. * @rmtoll CSR AWD3_MST LL_ADC_IsActiveFlag_MST_AWD3
  6445. * @param ADCxy_COMMON ADC common instance
  6446. * (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() )
  6447. * @retval State of bit (1 or 0).
  6448. */
  6449. __STATIC_INLINE uint32_t LL_ADC_IsActiveFlag_MST_AWD3(ADC_Common_TypeDef *ADCxy_COMMON)
  6450. {
  6451. return (READ_BIT(ADCxy_COMMON->CSR, LL_ADC_FLAG_AWD3_MST) == (LL_ADC_FLAG_AWD3_MST));
  6452. }
  6453. /**
  6454. * @brief Get flag multimode ADC analog watchdog 3 of the ADC slave.
  6455. * @rmtoll CSR AWD3_SLV LL_ADC_IsActiveFlag_SLV_AWD3
  6456. * @param ADCxy_COMMON ADC common instance
  6457. * (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() )
  6458. * @retval State of bit (1 or 0).
  6459. */
  6460. __STATIC_INLINE uint32_t LL_ADC_IsActiveFlag_SLV_AWD3(ADC_Common_TypeDef *ADCxy_COMMON)
  6461. {
  6462. return (READ_BIT(ADCxy_COMMON->CSR, LL_ADC_FLAG_AWD3_SLV) == (LL_ADC_FLAG_AWD3_SLV));
  6463. }
  6464. #endif /* ADC_MULTIMODE_SUPPORT */
  6465. /**
  6466. * @}
  6467. */
  6468. /** @defgroup ADC_LL_EF_IT_Management ADC IT management
  6469. * @{
  6470. */
  6471. /**
  6472. * @brief Enable ADC ready.
  6473. * @rmtoll IER ADRDYIE LL_ADC_EnableIT_ADRDY
  6474. * @param ADCx ADC instance
  6475. * @retval None
  6476. */
  6477. __STATIC_INLINE void LL_ADC_EnableIT_ADRDY(ADC_TypeDef *ADCx)
  6478. {
  6479. SET_BIT(ADCx->IER, LL_ADC_IT_ADRDY);
  6480. }
  6481. /**
  6482. * @brief Enable interruption ADC group regular end of unitary conversion.
  6483. * @rmtoll IER EOCIE LL_ADC_EnableIT_EOC
  6484. * @param ADCx ADC instance
  6485. * @retval None
  6486. */
  6487. __STATIC_INLINE void LL_ADC_EnableIT_EOC(ADC_TypeDef *ADCx)
  6488. {
  6489. SET_BIT(ADCx->IER, LL_ADC_IT_EOC);
  6490. }
  6491. /**
  6492. * @brief Enable interruption ADC group regular end of sequence conversions.
  6493. * @rmtoll IER EOSIE LL_ADC_EnableIT_EOS
  6494. * @param ADCx ADC instance
  6495. * @retval None
  6496. */
  6497. __STATIC_INLINE void LL_ADC_EnableIT_EOS(ADC_TypeDef *ADCx)
  6498. {
  6499. SET_BIT(ADCx->IER, LL_ADC_IT_EOS);
  6500. }
  6501. /**
  6502. * @brief Enable ADC group regular interruption overrun.
  6503. * @rmtoll IER OVRIE LL_ADC_EnableIT_OVR
  6504. * @param ADCx ADC instance
  6505. * @retval None
  6506. */
  6507. __STATIC_INLINE void LL_ADC_EnableIT_OVR(ADC_TypeDef *ADCx)
  6508. {
  6509. SET_BIT(ADCx->IER, LL_ADC_IT_OVR);
  6510. }
  6511. /**
  6512. * @brief Enable interruption ADC group regular end of sampling.
  6513. * @rmtoll IER EOSMPIE LL_ADC_EnableIT_EOSMP
  6514. * @param ADCx ADC instance
  6515. * @retval None
  6516. */
  6517. __STATIC_INLINE void LL_ADC_EnableIT_EOSMP(ADC_TypeDef *ADCx)
  6518. {
  6519. SET_BIT(ADCx->IER, LL_ADC_IT_EOSMP);
  6520. }
  6521. /**
  6522. * @brief Enable interruption ADC group injected end of unitary conversion.
  6523. * @rmtoll IER JEOCIE LL_ADC_EnableIT_JEOC
  6524. * @param ADCx ADC instance
  6525. * @retval None
  6526. */
  6527. __STATIC_INLINE void LL_ADC_EnableIT_JEOC(ADC_TypeDef *ADCx)
  6528. {
  6529. SET_BIT(ADCx->IER, LL_ADC_IT_JEOC);
  6530. }
  6531. /**
  6532. * @brief Enable interruption ADC group injected end of sequence conversions.
  6533. * @rmtoll IER JEOSIE LL_ADC_EnableIT_JEOS
  6534. * @param ADCx ADC instance
  6535. * @retval None
  6536. */
  6537. __STATIC_INLINE void LL_ADC_EnableIT_JEOS(ADC_TypeDef *ADCx)
  6538. {
  6539. SET_BIT(ADCx->IER, LL_ADC_IT_JEOS);
  6540. }
  6541. /**
  6542. * @brief Enable interruption ADC group injected context queue overflow.
  6543. * @rmtoll IER JQOVFIE LL_ADC_EnableIT_JQOVF
  6544. * @param ADCx ADC instance
  6545. * @retval None
  6546. */
  6547. __STATIC_INLINE void LL_ADC_EnableIT_JQOVF(ADC_TypeDef *ADCx)
  6548. {
  6549. SET_BIT(ADCx->IER, LL_ADC_IT_JQOVF);
  6550. }
  6551. /**
  6552. * @brief Enable interruption ADC analog watchdog 1.
  6553. * @rmtoll IER AWD1IE LL_ADC_EnableIT_AWD1
  6554. * @param ADCx ADC instance
  6555. * @retval None
  6556. */
  6557. __STATIC_INLINE void LL_ADC_EnableIT_AWD1(ADC_TypeDef *ADCx)
  6558. {
  6559. SET_BIT(ADCx->IER, LL_ADC_IT_AWD1);
  6560. }
  6561. /**
  6562. * @brief Enable interruption ADC analog watchdog 2.
  6563. * @rmtoll IER AWD2IE LL_ADC_EnableIT_AWD2
  6564. * @param ADCx ADC instance
  6565. * @retval None
  6566. */
  6567. __STATIC_INLINE void LL_ADC_EnableIT_AWD2(ADC_TypeDef *ADCx)
  6568. {
  6569. SET_BIT(ADCx->IER, LL_ADC_IT_AWD2);
  6570. }
  6571. /**
  6572. * @brief Enable interruption ADC analog watchdog 3.
  6573. * @rmtoll IER AWD3IE LL_ADC_EnableIT_AWD3
  6574. * @param ADCx ADC instance
  6575. * @retval None
  6576. */
  6577. __STATIC_INLINE void LL_ADC_EnableIT_AWD3(ADC_TypeDef *ADCx)
  6578. {
  6579. SET_BIT(ADCx->IER, LL_ADC_IT_AWD3);
  6580. }
  6581. /**
  6582. * @brief Disable interruption ADC ready.
  6583. * @rmtoll IER ADRDYIE LL_ADC_DisableIT_ADRDY
  6584. * @param ADCx ADC instance
  6585. * @retval None
  6586. */
  6587. __STATIC_INLINE void LL_ADC_DisableIT_ADRDY(ADC_TypeDef *ADCx)
  6588. {
  6589. CLEAR_BIT(ADCx->IER, LL_ADC_IT_ADRDY);
  6590. }
  6591. /**
  6592. * @brief Disable interruption ADC group regular end of unitary conversion.
  6593. * @rmtoll IER EOCIE LL_ADC_DisableIT_EOC
  6594. * @param ADCx ADC instance
  6595. * @retval None
  6596. */
  6597. __STATIC_INLINE void LL_ADC_DisableIT_EOC(ADC_TypeDef *ADCx)
  6598. {
  6599. CLEAR_BIT(ADCx->IER, LL_ADC_IT_EOC);
  6600. }
  6601. /**
  6602. * @brief Disable interruption ADC group regular end of sequence conversions.
  6603. * @rmtoll IER EOSIE LL_ADC_DisableIT_EOS
  6604. * @param ADCx ADC instance
  6605. * @retval None
  6606. */
  6607. __STATIC_INLINE void LL_ADC_DisableIT_EOS(ADC_TypeDef *ADCx)
  6608. {
  6609. CLEAR_BIT(ADCx->IER, LL_ADC_IT_EOS);
  6610. }
  6611. /**
  6612. * @brief Disable interruption ADC group regular overrun.
  6613. * @rmtoll IER OVRIE LL_ADC_DisableIT_OVR
  6614. * @param ADCx ADC instance
  6615. * @retval None
  6616. */
  6617. __STATIC_INLINE void LL_ADC_DisableIT_OVR(ADC_TypeDef *ADCx)
  6618. {
  6619. CLEAR_BIT(ADCx->IER, LL_ADC_IT_OVR);
  6620. }
  6621. /**
  6622. * @brief Disable interruption ADC group regular end of sampling.
  6623. * @rmtoll IER EOSMPIE LL_ADC_DisableIT_EOSMP
  6624. * @param ADCx ADC instance
  6625. * @retval None
  6626. */
  6627. __STATIC_INLINE void LL_ADC_DisableIT_EOSMP(ADC_TypeDef *ADCx)
  6628. {
  6629. CLEAR_BIT(ADCx->IER, LL_ADC_IT_EOSMP);
  6630. }
  6631. /**
  6632. * @brief Disable interruption ADC group regular end of unitary conversion.
  6633. * @rmtoll IER JEOCIE LL_ADC_DisableIT_JEOC
  6634. * @param ADCx ADC instance
  6635. * @retval None
  6636. */
  6637. __STATIC_INLINE void LL_ADC_DisableIT_JEOC(ADC_TypeDef *ADCx)
  6638. {
  6639. CLEAR_BIT(ADCx->IER, LL_ADC_IT_JEOC);
  6640. }
  6641. /**
  6642. * @brief Disable interruption ADC group injected end of sequence conversions.
  6643. * @rmtoll IER JEOSIE LL_ADC_DisableIT_JEOS
  6644. * @param ADCx ADC instance
  6645. * @retval None
  6646. */
  6647. __STATIC_INLINE void LL_ADC_DisableIT_JEOS(ADC_TypeDef *ADCx)
  6648. {
  6649. CLEAR_BIT(ADCx->IER, LL_ADC_IT_JEOS);
  6650. }
  6651. /**
  6652. * @brief Disable interruption ADC group injected context queue overflow.
  6653. * @rmtoll IER JQOVFIE LL_ADC_DisableIT_JQOVF
  6654. * @param ADCx ADC instance
  6655. * @retval None
  6656. */
  6657. __STATIC_INLINE void LL_ADC_DisableIT_JQOVF(ADC_TypeDef *ADCx)
  6658. {
  6659. CLEAR_BIT(ADCx->IER, LL_ADC_IT_JQOVF);
  6660. }
  6661. /**
  6662. * @brief Disable interruption ADC analog watchdog 1.
  6663. * @rmtoll IER AWD1IE LL_ADC_DisableIT_AWD1
  6664. * @param ADCx ADC instance
  6665. * @retval None
  6666. */
  6667. __STATIC_INLINE void LL_ADC_DisableIT_AWD1(ADC_TypeDef *ADCx)
  6668. {
  6669. CLEAR_BIT(ADCx->IER, LL_ADC_IT_AWD1);
  6670. }
  6671. /**
  6672. * @brief Disable interruption ADC analog watchdog 2.
  6673. * @rmtoll IER AWD2IE LL_ADC_DisableIT_AWD2
  6674. * @param ADCx ADC instance
  6675. * @retval None
  6676. */
  6677. __STATIC_INLINE void LL_ADC_DisableIT_AWD2(ADC_TypeDef *ADCx)
  6678. {
  6679. CLEAR_BIT(ADCx->IER, LL_ADC_IT_AWD2);
  6680. }
  6681. /**
  6682. * @brief Disable interruption ADC analog watchdog 3.
  6683. * @rmtoll IER AWD3IE LL_ADC_DisableIT_AWD3
  6684. * @param ADCx ADC instance
  6685. * @retval None
  6686. */
  6687. __STATIC_INLINE void LL_ADC_DisableIT_AWD3(ADC_TypeDef *ADCx)
  6688. {
  6689. CLEAR_BIT(ADCx->IER, LL_ADC_IT_AWD3);
  6690. }
  6691. /**
  6692. * @brief Get state of interruption ADC ready
  6693. * (0: interrupt disabled, 1: interrupt enabled).
  6694. * @rmtoll IER ADRDYIE LL_ADC_IsEnabledIT_ADRDY
  6695. * @param ADCx ADC instance
  6696. * @retval State of bit (1 or 0).
  6697. */
  6698. __STATIC_INLINE uint32_t LL_ADC_IsEnabledIT_ADRDY(ADC_TypeDef *ADCx)
  6699. {
  6700. return (READ_BIT(ADCx->IER, LL_ADC_IT_ADRDY) == (LL_ADC_IT_ADRDY));
  6701. }
  6702. /**
  6703. * @brief Get state of interruption ADC group regular end of unitary conversion
  6704. * (0: interrupt disabled, 1: interrupt enabled).
  6705. * @rmtoll IER EOCIE LL_ADC_IsEnabledIT_EOC
  6706. * @param ADCx ADC instance
  6707. * @retval State of bit (1 or 0).
  6708. */
  6709. __STATIC_INLINE uint32_t LL_ADC_IsEnabledIT_EOC(ADC_TypeDef *ADCx)
  6710. {
  6711. return (READ_BIT(ADCx->IER, LL_ADC_IT_EOC) == (LL_ADC_IT_EOC));
  6712. }
  6713. /**
  6714. * @brief Get state of interruption ADC group regular end of sequence conversions
  6715. * (0: interrupt disabled, 1: interrupt enabled).
  6716. * @rmtoll IER EOSIE LL_ADC_IsEnabledIT_EOS
  6717. * @param ADCx ADC instance
  6718. * @retval State of bit (1 or 0).
  6719. */
  6720. __STATIC_INLINE uint32_t LL_ADC_IsEnabledIT_EOS(ADC_TypeDef *ADCx)
  6721. {
  6722. return (READ_BIT(ADCx->IER, LL_ADC_IT_EOS) == (LL_ADC_IT_EOS));
  6723. }
  6724. /**
  6725. * @brief Get state of interruption ADC group regular overrun
  6726. * (0: interrupt disabled, 1: interrupt enabled).
  6727. * @rmtoll IER OVRIE LL_ADC_IsEnabledIT_OVR
  6728. * @param ADCx ADC instance
  6729. * @retval State of bit (1 or 0).
  6730. */
  6731. __STATIC_INLINE uint32_t LL_ADC_IsEnabledIT_OVR(ADC_TypeDef *ADCx)
  6732. {
  6733. return (READ_BIT(ADCx->IER, LL_ADC_IT_OVR) == (LL_ADC_IT_OVR));
  6734. }
  6735. /**
  6736. * @brief Get state of interruption ADC group regular end of sampling
  6737. * (0: interrupt disabled, 1: interrupt enabled).
  6738. * @rmtoll IER EOSMPIE LL_ADC_IsEnabledIT_EOSMP
  6739. * @param ADCx ADC instance
  6740. * @retval State of bit (1 or 0).
  6741. */
  6742. __STATIC_INLINE uint32_t LL_ADC_IsEnabledIT_EOSMP(ADC_TypeDef *ADCx)
  6743. {
  6744. return (READ_BIT(ADCx->IER, LL_ADC_IT_EOSMP) == (LL_ADC_IT_EOSMP));
  6745. }
  6746. /**
  6747. * @brief Get state of interruption ADC group injected end of unitary conversion
  6748. * (0: interrupt disabled, 1: interrupt enabled).
  6749. * @rmtoll IER JEOCIE LL_ADC_IsEnabledIT_JEOC
  6750. * @param ADCx ADC instance
  6751. * @retval State of bit (1 or 0).
  6752. */
  6753. __STATIC_INLINE uint32_t LL_ADC_IsEnabledIT_JEOC(ADC_TypeDef *ADCx)
  6754. {
  6755. return (READ_BIT(ADCx->IER, LL_ADC_IT_JEOC) == (LL_ADC_IT_JEOC));
  6756. }
  6757. /**
  6758. * @brief Get state of interruption ADC group injected end of sequence conversions
  6759. * (0: interrupt disabled, 1: interrupt enabled).
  6760. * @rmtoll IER JEOSIE LL_ADC_IsEnabledIT_JEOS
  6761. * @param ADCx ADC instance
  6762. * @retval State of bit (1 or 0).
  6763. */
  6764. __STATIC_INLINE uint32_t LL_ADC_IsEnabledIT_JEOS(ADC_TypeDef *ADCx)
  6765. {
  6766. return (READ_BIT(ADCx->IER, LL_ADC_IT_JEOS) == (LL_ADC_IT_JEOS));
  6767. }
  6768. /**
  6769. * @brief Get state of interruption ADC group injected context queue overflow interrupt state
  6770. * (0: interrupt disabled, 1: interrupt enabled).
  6771. * @rmtoll IER JQOVFIE LL_ADC_IsEnabledIT_JQOVF
  6772. * @param ADCx ADC instance
  6773. * @retval State of bit (1 or 0).
  6774. */
  6775. __STATIC_INLINE uint32_t LL_ADC_IsEnabledIT_JQOVF(ADC_TypeDef *ADCx)
  6776. {
  6777. return (READ_BIT(ADCx->IER, LL_ADC_IT_JQOVF) == (LL_ADC_IT_JQOVF));
  6778. }
  6779. /**
  6780. * @brief Get state of interruption ADC analog watchdog 1
  6781. * (0: interrupt disabled, 1: interrupt enabled).
  6782. * @rmtoll IER AWD1IE LL_ADC_IsEnabledIT_AWD1
  6783. * @param ADCx ADC instance
  6784. * @retval State of bit (1 or 0).
  6785. */
  6786. __STATIC_INLINE uint32_t LL_ADC_IsEnabledIT_AWD1(ADC_TypeDef *ADCx)
  6787. {
  6788. return (READ_BIT(ADCx->IER, LL_ADC_IT_AWD1) == (LL_ADC_IT_AWD1));
  6789. }
  6790. /**
  6791. * @brief Get state of interruption Get ADC analog watchdog 2
  6792. * (0: interrupt disabled, 1: interrupt enabled).
  6793. * @rmtoll IER AWD2IE LL_ADC_IsEnabledIT_AWD2
  6794. * @param ADCx ADC instance
  6795. * @retval State of bit (1 or 0).
  6796. */
  6797. __STATIC_INLINE uint32_t LL_ADC_IsEnabledIT_AWD2(ADC_TypeDef *ADCx)
  6798. {
  6799. return (READ_BIT(ADCx->IER, LL_ADC_IT_AWD2) == (LL_ADC_IT_AWD2));
  6800. }
  6801. /**
  6802. * @brief Get state of interruption Get ADC analog watchdog 3
  6803. * (0: interrupt disabled, 1: interrupt enabled).
  6804. * @rmtoll IER AWD3IE LL_ADC_IsEnabledIT_AWD3
  6805. * @param ADCx ADC instance
  6806. * @retval State of bit (1 or 0).
  6807. */
  6808. __STATIC_INLINE uint32_t LL_ADC_IsEnabledIT_AWD3(ADC_TypeDef *ADCx)
  6809. {
  6810. return (READ_BIT(ADCx->IER, LL_ADC_IT_AWD3) == (LL_ADC_IT_AWD3));
  6811. }
  6812. /**
  6813. * @}
  6814. */
  6815. #if defined(USE_FULL_LL_DRIVER)
  6816. /** @defgroup ADC_LL_EF_Init Initialization and de-initialization functions
  6817. * @{
  6818. */
  6819. /* Initialization of some features of ADC common parameters and multimode */
  6820. ErrorStatus LL_ADC_CommonDeInit(ADC_Common_TypeDef *ADCxy_COMMON);
  6821. ErrorStatus LL_ADC_CommonInit(ADC_Common_TypeDef *ADCxy_COMMON, LL_ADC_CommonInitTypeDef *ADC_CommonInitStruct);
  6822. void LL_ADC_CommonStructInit(LL_ADC_CommonInitTypeDef *ADC_CommonInitStruct);
  6823. /* De-initialization of ADC instance, ADC group regular and ADC group injected */
  6824. /* (availability of ADC group injected depends on STM32 families) */
  6825. ErrorStatus LL_ADC_DeInit(ADC_TypeDef *ADCx);
  6826. /* Initialization of some features of ADC instance */
  6827. ErrorStatus LL_ADC_Init(ADC_TypeDef *ADCx, LL_ADC_InitTypeDef *ADC_InitStruct);
  6828. void LL_ADC_StructInit(LL_ADC_InitTypeDef *ADC_InitStruct);
  6829. /* Initialization of some features of ADC instance and ADC group regular */
  6830. ErrorStatus LL_ADC_REG_Init(ADC_TypeDef *ADCx, LL_ADC_REG_InitTypeDef *ADC_REG_InitStruct);
  6831. void LL_ADC_REG_StructInit(LL_ADC_REG_InitTypeDef *ADC_REG_InitStruct);
  6832. /* Initialization of some features of ADC instance and ADC group injected */
  6833. ErrorStatus LL_ADC_INJ_Init(ADC_TypeDef *ADCx, LL_ADC_INJ_InitTypeDef *ADC_INJ_InitStruct);
  6834. void LL_ADC_INJ_StructInit(LL_ADC_INJ_InitTypeDef *ADC_INJ_InitStruct);
  6835. /**
  6836. * @}
  6837. */
  6838. #endif /* USE_FULL_LL_DRIVER */
  6839. /**
  6840. * @}
  6841. */
  6842. /**
  6843. * @}
  6844. */
  6845. #endif /* ADC1 || ADC2 || ADC3 || ADC4 */
  6846. #endif /* STM32F301x8 || STM32F302x8 || STM32F302xC || STM32F302xE || STM32F303x8 || STM32F303xC || STM32F303xE || STM32F318xx || STM32F328xx || STM32F334x8 || STM32F358xx || STM32F398xx */
  6847. #if defined (ADC1_V2_5)
  6848. #if defined (ADC1)
  6849. /** @defgroup ADC_LL ADC
  6850. * @{
  6851. */
  6852. /* Private types -------------------------------------------------------------*/
  6853. /* Private variables ---------------------------------------------------------*/
  6854. /* Private constants ---------------------------------------------------------*/
  6855. /** @defgroup ADC_LL_Private_Constants ADC Private Constants
  6856. * @{
  6857. */
  6858. /* Internal mask for ADC group regular sequencer: */
  6859. /* To select into literal LL_ADC_REG_RANK_x the relevant bits for: */
  6860. /* - sequencer register offset */
  6861. /* - sequencer rank bits position into the selected register */
  6862. /* Internal register offset for ADC group regular sequencer configuration */
  6863. /* (offset placed into a spare area of literal definition) */
  6864. #define ADC_SQR1_REGOFFSET ((uint32_t)0x00000000U)
  6865. #define ADC_SQR2_REGOFFSET ((uint32_t)0x00000100U)
  6866. #define ADC_SQR3_REGOFFSET ((uint32_t)0x00000200U)
  6867. #define ADC_SQR4_REGOFFSET ((uint32_t)0x00000300U)
  6868. #define ADC_REG_SQRX_REGOFFSET_MASK (ADC_SQR1_REGOFFSET | ADC_SQR2_REGOFFSET | ADC_SQR3_REGOFFSET | ADC_SQR4_REGOFFSET)
  6869. #define ADC_REG_RANK_ID_SQRX_MASK (ADC_CHANNEL_ID_NUMBER_MASK_POSBIT0)
  6870. /* Definition of ADC group regular sequencer bits information to be inserted */
  6871. /* into ADC group regular sequencer ranks literals definition. */
  6872. #define ADC_REG_RANK_1_SQRX_BITOFFSET_POS ((uint32_t) 0U) /* Value equivalent to POSITION_VAL(ADC_SQR3_SQ1) */
  6873. #define ADC_REG_RANK_2_SQRX_BITOFFSET_POS ((uint32_t) 5U) /* Value equivalent to POSITION_VAL(ADC_SQR3_SQ2) */
  6874. #define ADC_REG_RANK_3_SQRX_BITOFFSET_POS ((uint32_t)10U) /* Value equivalent to POSITION_VAL(ADC_SQR3_SQ3) */
  6875. #define ADC_REG_RANK_4_SQRX_BITOFFSET_POS ((uint32_t)15U) /* Value equivalent to POSITION_VAL(ADC_SQR3_SQ4) */
  6876. #define ADC_REG_RANK_5_SQRX_BITOFFSET_POS ((uint32_t)20U) /* Value equivalent to POSITION_VAL(ADC_SQR3_SQ5) */
  6877. #define ADC_REG_RANK_6_SQRX_BITOFFSET_POS ((uint32_t)25U) /* Value equivalent to POSITION_VAL(ADC_SQR3_SQ6) */
  6878. #define ADC_REG_RANK_7_SQRX_BITOFFSET_POS ((uint32_t) 0U) /* Value equivalent to POSITION_VAL(ADC_SQR2_SQ7) */
  6879. #define ADC_REG_RANK_8_SQRX_BITOFFSET_POS ((uint32_t) 5U) /* Value equivalent to POSITION_VAL(ADC_SQR2_SQ8) */
  6880. #define ADC_REG_RANK_9_SQRX_BITOFFSET_POS ((uint32_t)10U) /* Value equivalent to POSITION_VAL(ADC_SQR2_SQ9) */
  6881. #define ADC_REG_RANK_10_SQRX_BITOFFSET_POS ((uint32_t)15U) /* Value equivalent to POSITION_VAL(ADC_SQR2_SQ10) */
  6882. #define ADC_REG_RANK_11_SQRX_BITOFFSET_POS ((uint32_t)20U) /* Value equivalent to POSITION_VAL(ADC_SQR2_SQ11) */
  6883. #define ADC_REG_RANK_12_SQRX_BITOFFSET_POS ((uint32_t)25U) /* Value equivalent to POSITION_VAL(ADC_SQR2_SQ12) */
  6884. #define ADC_REG_RANK_13_SQRX_BITOFFSET_POS ((uint32_t) 0U) /* Value equivalent to POSITION_VAL(ADC_SQR1_SQ13) */
  6885. #define ADC_REG_RANK_14_SQRX_BITOFFSET_POS ((uint32_t) 5U) /* Value equivalent to POSITION_VAL(ADC_SQR1_SQ14) */
  6886. #define ADC_REG_RANK_15_SQRX_BITOFFSET_POS ((uint32_t)10U) /* Value equivalent to POSITION_VAL(ADC_SQR1_SQ15) */
  6887. #define ADC_REG_RANK_16_SQRX_BITOFFSET_POS ((uint32_t)15U) /* Value equivalent to POSITION_VAL(ADC_SQR1_SQ16) */
  6888. /* Internal mask for ADC group injected sequencer: */
  6889. /* To select into literal LL_ADC_INJ_RANK_x the relevant bits for: */
  6890. /* - data register offset */
  6891. /* - offset register offset */
  6892. /* - sequencer rank bits position into the selected register */
  6893. /* Internal register offset for ADC group injected data register */
  6894. /* (offset placed into a spare area of literal definition) */
  6895. #define ADC_JDR1_REGOFFSET ((uint32_t)0x00000000U)
  6896. #define ADC_JDR2_REGOFFSET ((uint32_t)0x00000100U)
  6897. #define ADC_JDR3_REGOFFSET ((uint32_t)0x00000200U)
  6898. #define ADC_JDR4_REGOFFSET ((uint32_t)0x00000300U)
  6899. /* Internal register offset for ADC group injected offset configuration */
  6900. /* (offset placed into a spare area of literal definition) */
  6901. #define ADC_JOFR1_REGOFFSET ((uint32_t)0x00000000U)
  6902. #define ADC_JOFR2_REGOFFSET ((uint32_t)0x00001000U)
  6903. #define ADC_JOFR3_REGOFFSET ((uint32_t)0x00002000U)
  6904. #define ADC_JOFR4_REGOFFSET ((uint32_t)0x00003000U)
  6905. #define ADC_INJ_JDRX_REGOFFSET_MASK (ADC_JDR1_REGOFFSET | ADC_JDR2_REGOFFSET | ADC_JDR3_REGOFFSET | ADC_JDR4_REGOFFSET)
  6906. #define ADC_INJ_JOFRX_REGOFFSET_MASK (ADC_JOFR1_REGOFFSET | ADC_JOFR2_REGOFFSET | ADC_JOFR3_REGOFFSET | ADC_JOFR4_REGOFFSET)
  6907. #define ADC_INJ_RANK_ID_JSQR_MASK (ADC_CHANNEL_ID_NUMBER_MASK_POSBIT0)
  6908. /* Definition of ADC group injected sequencer bits information to be inserted */
  6909. /* into ADC group injected sequencer ranks literals definition. */
  6910. #define ADC_INJ_RANK_1_JSQR_BITOFFSET_POS ((uint32_t) 0U) /* Value equivalent to POSITION_VAL(ADC_JSQR_JSQ1) */
  6911. #define ADC_INJ_RANK_2_JSQR_BITOFFSET_POS ((uint32_t) 5U) /* Value equivalent to POSITION_VAL(ADC_JSQR_JSQ2) */
  6912. #define ADC_INJ_RANK_3_JSQR_BITOFFSET_POS ((uint32_t)10U) /* Value equivalent to POSITION_VAL(ADC_JSQR_JSQ3) */
  6913. #define ADC_INJ_RANK_4_JSQR_BITOFFSET_POS ((uint32_t)15U) /* Value equivalent to POSITION_VAL(ADC_JSQR_JSQ4) */
  6914. /* Internal mask for ADC channel: */
  6915. /* To select into literal LL_ADC_CHANNEL_x the relevant bits for: */
  6916. /* - channel identifier defined by number */
  6917. /* - channel differentiation between external channels (connected to */
  6918. /* GPIO pins) and internal channels (connected to internal paths) */
  6919. /* - channel sampling time defined by SMPRx register offset */
  6920. /* and SMPx bits positions into SMPRx register */
  6921. #define ADC_CHANNEL_ID_NUMBER_MASK (ADC_CR1_AWDCH)
  6922. #define ADC_CHANNEL_ID_NUMBER_BITOFFSET_POS ((uint32_t) 0U)/* Value equivalent to POSITION_VAL(ADC_CHANNEL_ID_NUMBER_MASK) */
  6923. #define ADC_CHANNEL_ID_MASK (ADC_CHANNEL_ID_NUMBER_MASK | ADC_CHANNEL_ID_INTERNAL_CH_MASK)
  6924. /* Equivalent mask of ADC_CHANNEL_NUMBER_MASK aligned on register LSB (bit 0) */
  6925. #define ADC_CHANNEL_ID_NUMBER_MASK_POSBIT0 ((uint32_t)0x0000001FU) /* Equivalent to shift: (ADC_CHANNEL_NUMBER_MASK >> POSITION_VAL(ADC_CHANNEL_NUMBER_MASK)) */
  6926. /* Channel differentiation between external and internal channels */
  6927. #define ADC_CHANNEL_ID_INTERNAL_CH ((uint32_t)0x80000000U) /* Marker of internal channel */
  6928. #define ADC_CHANNEL_ID_INTERNAL_CH_2 ((uint32_t)0x40000000U) /* Marker of internal channel for other ADC instances, in case of different ADC internal channels mapped on same channel number on different ADC instances */
  6929. #define ADC_CHANNEL_ID_INTERNAL_CH_MASK (ADC_CHANNEL_ID_INTERNAL_CH | ADC_CHANNEL_ID_INTERNAL_CH_2)
  6930. /* Internal register offset for ADC channel sampling time configuration */
  6931. /* (offset placed into a spare area of literal definition) */
  6932. #define ADC_SMPR1_REGOFFSET ((uint32_t)0x00000000U)
  6933. #define ADC_SMPR2_REGOFFSET ((uint32_t)0x02000000U)
  6934. #define ADC_CHANNEL_SMPRX_REGOFFSET_MASK (ADC_SMPR1_REGOFFSET | ADC_SMPR2_REGOFFSET)
  6935. #define ADC_CHANNEL_SMPx_BITOFFSET_MASK ((uint32_t)0x01F00000U)
  6936. #define ADC_CHANNEL_SMPx_BITOFFSET_POS ((uint32_t)20U) /* Value equivalent to POSITION_VAL(ADC_CHANNEL_SMPx_BITOFFSET_MASK) */
  6937. /* Definition of channels ID number information to be inserted into */
  6938. /* channels literals definition. */
  6939. #define ADC_CHANNEL_0_NUMBER ((uint32_t)0x00000000U)
  6940. #define ADC_CHANNEL_1_NUMBER ( ADC_CR1_AWDCH_0)
  6941. #define ADC_CHANNEL_2_NUMBER ( ADC_CR1_AWDCH_1 )
  6942. #define ADC_CHANNEL_3_NUMBER ( ADC_CR1_AWDCH_1 | ADC_CR1_AWDCH_0)
  6943. #define ADC_CHANNEL_4_NUMBER ( ADC_CR1_AWDCH_2 )
  6944. #define ADC_CHANNEL_5_NUMBER ( ADC_CR1_AWDCH_2 | ADC_CR1_AWDCH_0)
  6945. #define ADC_CHANNEL_6_NUMBER ( ADC_CR1_AWDCH_2 | ADC_CR1_AWDCH_1 )
  6946. #define ADC_CHANNEL_7_NUMBER ( ADC_CR1_AWDCH_2 | ADC_CR1_AWDCH_1 | ADC_CR1_AWDCH_0)
  6947. #define ADC_CHANNEL_8_NUMBER ( ADC_CR1_AWDCH_3 )
  6948. #define ADC_CHANNEL_9_NUMBER ( ADC_CR1_AWDCH_3 | ADC_CR1_AWDCH_0)
  6949. #define ADC_CHANNEL_10_NUMBER ( ADC_CR1_AWDCH_3 | ADC_CR1_AWDCH_1 )
  6950. #define ADC_CHANNEL_11_NUMBER ( ADC_CR1_AWDCH_3 | ADC_CR1_AWDCH_1 | ADC_CR1_AWDCH_0)
  6951. #define ADC_CHANNEL_12_NUMBER ( ADC_CR1_AWDCH_3 | ADC_CR1_AWDCH_2 )
  6952. #define ADC_CHANNEL_13_NUMBER ( ADC_CR1_AWDCH_3 | ADC_CR1_AWDCH_2 | ADC_CR1_AWDCH_0)
  6953. #define ADC_CHANNEL_14_NUMBER ( ADC_CR1_AWDCH_3 | ADC_CR1_AWDCH_2 | ADC_CR1_AWDCH_1 )
  6954. #define ADC_CHANNEL_15_NUMBER ( ADC_CR1_AWDCH_3 | ADC_CR1_AWDCH_2 | ADC_CR1_AWDCH_1 | ADC_CR1_AWDCH_0)
  6955. #define ADC_CHANNEL_16_NUMBER (ADC_CR1_AWDCH_4 )
  6956. #define ADC_CHANNEL_17_NUMBER (ADC_CR1_AWDCH_4 | ADC_CR1_AWDCH_0)
  6957. /* Definition of channels sampling time information to be inserted into */
  6958. /* channels literals definition. */
  6959. #define ADC_CHANNEL_0_SMP (ADC_SMPR2_REGOFFSET | (((uint32_t) 0U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR2_SMP0) */
  6960. #define ADC_CHANNEL_1_SMP (ADC_SMPR2_REGOFFSET | (((uint32_t) 3U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR2_SMP1) */
  6961. #define ADC_CHANNEL_2_SMP (ADC_SMPR2_REGOFFSET | (((uint32_t) 6U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR2_SMP2) */
  6962. #define ADC_CHANNEL_3_SMP (ADC_SMPR2_REGOFFSET | (((uint32_t) 9U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR2_SMP3) */
  6963. #define ADC_CHANNEL_4_SMP (ADC_SMPR2_REGOFFSET | (((uint32_t)12U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR2_SMP4) */
  6964. #define ADC_CHANNEL_5_SMP (ADC_SMPR2_REGOFFSET | (((uint32_t)15U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR2_SMP5) */
  6965. #define ADC_CHANNEL_6_SMP (ADC_SMPR2_REGOFFSET | (((uint32_t)18U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR2_SMP6) */
  6966. #define ADC_CHANNEL_7_SMP (ADC_SMPR2_REGOFFSET | (((uint32_t)21U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR2_SMP7) */
  6967. #define ADC_CHANNEL_8_SMP (ADC_SMPR2_REGOFFSET | (((uint32_t)24U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR2_SMP8) */
  6968. #define ADC_CHANNEL_9_SMP (ADC_SMPR2_REGOFFSET | (((uint32_t)27U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR2_SMP9) */
  6969. #define ADC_CHANNEL_10_SMP (ADC_SMPR1_REGOFFSET | (((uint32_t) 0U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR1_SMP10) */
  6970. #define ADC_CHANNEL_11_SMP (ADC_SMPR1_REGOFFSET | (((uint32_t) 3U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR1_SMP11) */
  6971. #define ADC_CHANNEL_12_SMP (ADC_SMPR1_REGOFFSET | (((uint32_t) 6U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR1_SMP12) */
  6972. #define ADC_CHANNEL_13_SMP (ADC_SMPR1_REGOFFSET | (((uint32_t) 9U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR1_SMP13) */
  6973. #define ADC_CHANNEL_14_SMP (ADC_SMPR1_REGOFFSET | (((uint32_t)12U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR1_SMP14) */
  6974. #define ADC_CHANNEL_15_SMP (ADC_SMPR1_REGOFFSET | (((uint32_t)15U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR1_SMP15) */
  6975. #define ADC_CHANNEL_16_SMP (ADC_SMPR1_REGOFFSET | (((uint32_t)18U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR1_SMP16) */
  6976. #define ADC_CHANNEL_17_SMP (ADC_SMPR1_REGOFFSET | (((uint32_t)21U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR1_SMP17) */
  6977. /* Internal mask for ADC analog watchdog: */
  6978. /* To select into literals LL_ADC_AWD_CHANNELx_xxx the relevant bits for: */
  6979. /* (concatenation of multiple bits used in different analog watchdogs, */
  6980. /* (feature of several watchdogs not available on all STM32 families)). */
  6981. /* - analog watchdog 1: monitored channel defined by number, */
  6982. /* selection of ADC group (ADC groups regular and-or injected). */
  6983. /* Internal register offset for ADC analog watchdog channel configuration */
  6984. #define ADC_AWD_CR1_REGOFFSET ((uint32_t)0x00000000U)
  6985. #define ADC_AWD_CRX_REGOFFSET_MASK (ADC_AWD_CR1_REGOFFSET)
  6986. #define ADC_AWD_CR1_CHANNEL_MASK (ADC_CR1_AWDCH | ADC_CR1_JAWDEN | ADC_CR1_AWDEN | ADC_CR1_AWDSGL)
  6987. #define ADC_AWD_CR_ALL_CHANNEL_MASK (ADC_AWD_CR1_CHANNEL_MASK)
  6988. /* Internal register offset for ADC analog watchdog threshold configuration */
  6989. #define ADC_AWD_TR1_HIGH_REGOFFSET ((uint32_t)0x00000000U)
  6990. #define ADC_AWD_TR1_LOW_REGOFFSET ((uint32_t)0x00000001U)
  6991. #define ADC_AWD_TRX_REGOFFSET_MASK (ADC_AWD_TR1_HIGH_REGOFFSET | ADC_AWD_TR1_LOW_REGOFFSET)
  6992. /* ADC registers bits positions */
  6993. #define ADC_CR1_DUALMOD_BITOFFSET_POS ((uint32_t)16U) /* Value equivalent to POSITION_VAL(ADC_CR1_DUALMOD) */
  6994. /* ADC internal channels related definitions */
  6995. /* Internal voltage reference VrefInt */
  6996. #define VREFINT_CAL_ADDR ((uint16_t*) ((uint32_t)0x1FFFF7BAU)) /* Internal voltage reference, address of parameter VREFINT_CAL: VrefInt ADC raw data acquired at temperature 30 DegC (tolerance: +-5 DegC), Vref+ = 3.3 V (tolerance: +-10 mV). */
  6997. #define VREFINT_CAL_VREF ((uint32_t) 3300U) /* Analog voltage reference (Vref+) value with which temperature sensor has been calibrated in production (tolerance: +-10 mV) (unit: mV). */
  6998. /* Temperature sensor */
  6999. #define TEMPSENSOR_CAL1_ADDR ((uint16_t*) ((uint32_t)0x1FFFF7B8U)) /* Internal temperature sensor, address of parameter TS_CAL1: On STM32F37x, temperature sensor ADC raw data acquired at temperature 30 DegC (tolerance: +-5 DegC), Vref+ = 3.3 V (tolerance: +-10 mV). */
  7000. #define TEMPSENSOR_CAL2_ADDR ((uint16_t*) ((uint32_t)0x1FFFF7C2U)) /* Internal temperature sensor, address of parameter TS_CAL2: On STM32F37x, temperature sensor ADC raw data acquired at temperature 110 DegC (tolerance: +-5 DegC), Vref+ = 3.3 V (tolerance: +-10 mV). */
  7001. #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). */
  7002. #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). */
  7003. #define TEMPSENSOR_CAL_VREFANALOG ((uint32_t) 3300U) /* Analog voltage reference (Vref+) voltage with which temperature sensor has been calibrated in production (+-10 mV) (unit: mV). */
  7004. /**
  7005. * @}
  7006. */
  7007. /* Private macros ------------------------------------------------------------*/
  7008. /** @defgroup ADC_LL_Private_Macros ADC Private Macros
  7009. * @{
  7010. */
  7011. /**
  7012. * @brief Driver macro reserved for internal use: isolate bits with the
  7013. * selected mask and shift them to the register LSB
  7014. * (shift mask on register position bit 0).
  7015. * @param __BITS__ Bits in register 32 bits
  7016. * @param __MASK__ Mask in register 32 bits
  7017. * @retval Bits in register 32 bits
  7018. */
  7019. #define __ADC_MASK_SHIFT(__BITS__, __MASK__) \
  7020. (((__BITS__) & (__MASK__)) >> POSITION_VAL((__MASK__)))
  7021. /**
  7022. * @brief Driver macro reserved for internal use: set a pointer to
  7023. * a register from a register basis from which an offset
  7024. * is applied.
  7025. * @param __REG__ Register basis from which the offset is applied.
  7026. * @param __REG_OFFFSET__ Offset to be applied (unit: number of registers).
  7027. * @retval Pointer to register address
  7028. */
  7029. #define __ADC_PTR_REG_OFFSET(__REG__, __REG_OFFFSET__) \
  7030. ((uint32_t *)((uint32_t) ((uint32_t)(&(__REG__)) + ((__REG_OFFFSET__) << 2U))))
  7031. /**
  7032. * @}
  7033. */
  7034. /* Exported types ------------------------------------------------------------*/
  7035. #if defined(USE_FULL_LL_DRIVER)
  7036. /** @defgroup ADC_LL_ES_INIT ADC Exported Init structure
  7037. * @{
  7038. */
  7039. /**
  7040. * @brief Structure definition of some features of ADC instance.
  7041. * @note These parameters have an impact on ADC scope: ADC instance.
  7042. * Affects both group regular and group injected (availability
  7043. * of ADC group injected depends on STM32 families).
  7044. * Refer to corresponding unitary functions into
  7045. * @ref ADC_LL_EF_Configuration_ADC_Instance .
  7046. * @note The setting of these parameters by function @ref LL_ADC_Init()
  7047. * is conditioned to ADC state:
  7048. * ADC instance must be disabled.
  7049. * This condition is applied to all ADC features, for efficiency
  7050. * and compatibility over all STM32 families. However, the different
  7051. * features can be set under different ADC state conditions
  7052. * (setting possible with ADC enabled without conversion on going,
  7053. * ADC enabled with conversion on going, ...)
  7054. * Each feature can be updated afterwards with a unitary function
  7055. * and potentially with ADC in a different state than disabled,
  7056. * refer to description of each function for setting
  7057. * conditioned to ADC state.
  7058. */
  7059. typedef struct
  7060. {
  7061. uint32_t DataAlignment; /*!< Set ADC conversion data alignment.
  7062. This parameter can be a value of @ref ADC_LL_EC_DATA_ALIGN
  7063. This feature can be modified afterwards using unitary function @ref LL_ADC_SetDataAlignment(). */
  7064. uint32_t SequencersScanMode; /*!< Set ADC scan selection.
  7065. This parameter can be a value of @ref ADC_LL_EC_SCAN_SELECTION
  7066. This feature can be modified afterwards using unitary function @ref LL_ADC_SetSequencersScanMode(). */
  7067. } LL_ADC_InitTypeDef;
  7068. /**
  7069. * @brief Structure definition of some features of ADC group regular.
  7070. * @note These parameters have an impact on ADC scope: ADC group regular.
  7071. * Refer to corresponding unitary functions into
  7072. * @ref ADC_LL_EF_Configuration_ADC_Group_Regular
  7073. * (functions with prefix "REG").
  7074. * @note The setting of these parameters by function @ref LL_ADC_REG_Init()
  7075. * is conditioned to ADC state:
  7076. * ADC instance must be disabled.
  7077. * This condition is applied to all ADC features, for efficiency
  7078. * and compatibility over all STM32 families. However, the different
  7079. * features can be set under different ADC state conditions
  7080. * (setting possible with ADC enabled without conversion on going,
  7081. * ADC enabled with conversion on going, ...)
  7082. * Each feature can be updated afterwards with a unitary function
  7083. * and potentially with ADC in a different state than disabled,
  7084. * refer to description of each function for setting
  7085. * conditioned to ADC state.
  7086. */
  7087. typedef struct
  7088. {
  7089. uint32_t TriggerSource; /*!< Set ADC group regular conversion trigger source: internal (SW start) or external from timer or external interrupt.
  7090. This parameter can be a value of @ref ADC_LL_EC_REG_TRIGGER_SOURCE
  7091. @note On this STM32 serie, external trigger is set with trigger polarity: rising edge
  7092. (only trigger polarity available on this STM32 serie).
  7093. This feature can be modified afterwards using unitary function @ref LL_ADC_REG_SetTriggerSource(). */
  7094. uint32_t SequencerLength; /*!< Set ADC group regular sequencer length.
  7095. This parameter can be a value of @ref ADC_LL_EC_REG_SEQ_SCAN_LENGTH
  7096. @note This parameter is discarded if scan mode is disabled (refer to parameter 'ADC_SequencersScanMode').
  7097. This feature can be modified afterwards using unitary function @ref LL_ADC_REG_SetSequencerLength(). */
  7098. uint32_t SequencerDiscont; /*!< Set ADC group regular sequencer discontinuous mode: sequence subdivided and scan conversions interrupted every selected number of ranks.
  7099. This parameter can be a value of @ref ADC_LL_EC_REG_SEQ_DISCONT_MODE
  7100. @note This parameter has an effect only if group regular sequencer is enabled
  7101. (scan length of 2 ranks or more).
  7102. This feature can be modified afterwards using unitary function @ref LL_ADC_REG_SetSequencerDiscont(). */
  7103. 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).
  7104. This parameter can be a value of @ref ADC_LL_EC_REG_CONTINUOUS_MODE
  7105. Note: It is not possible to enable both ADC group regular continuous mode and discontinuous mode.
  7106. This feature can be modified afterwards using unitary function @ref LL_ADC_REG_SetContinuousMode(). */
  7107. uint32_t DMATransfer; /*!< Set ADC group regular conversion data transfer: no transfer or transfer by DMA, and DMA requests mode.
  7108. This parameter can be a value of @ref ADC_LL_EC_REG_DMA_TRANSFER
  7109. This feature can be modified afterwards using unitary function @ref LL_ADC_REG_SetDMATransfer(). */
  7110. } LL_ADC_REG_InitTypeDef;
  7111. /**
  7112. * @brief Structure definition of some features of ADC group injected.
  7113. * @note These parameters have an impact on ADC scope: ADC group injected.
  7114. * Refer to corresponding unitary functions into
  7115. * @ref ADC_LL_EF_Configuration_ADC_Group_Regular
  7116. * (functions with prefix "INJ").
  7117. * @note The setting of these parameters by function @ref LL_ADC_INJ_Init()
  7118. * is conditioned to ADC state:
  7119. * ADC instance must be disabled.
  7120. * This condition is applied to all ADC features, for efficiency
  7121. * and compatibility over all STM32 families. However, the different
  7122. * features can be set under different ADC state conditions
  7123. * (setting possible with ADC enabled without conversion on going,
  7124. * ADC enabled with conversion on going, ...)
  7125. * Each feature can be updated afterwards with a unitary function
  7126. * and potentially with ADC in a different state than disabled,
  7127. * refer to description of each function for setting
  7128. * conditioned to ADC state.
  7129. */
  7130. typedef struct
  7131. {
  7132. uint32_t TriggerSource; /*!< Set ADC group injected conversion trigger source: internal (SW start) or external from timer or external interrupt.
  7133. This parameter can be a value of @ref ADC_LL_EC_INJ_TRIGGER_SOURCE
  7134. @note On this STM32 serie, external trigger is set with trigger polarity: rising edge
  7135. (only trigger polarity available on this STM32 serie).
  7136. This feature can be modified afterwards using unitary function @ref LL_ADC_INJ_SetTriggerSource(). */
  7137. uint32_t SequencerLength; /*!< Set ADC group injected sequencer length.
  7138. This parameter can be a value of @ref ADC_LL_EC_INJ_SEQ_SCAN_LENGTH
  7139. @note This parameter is discarded if scan mode is disabled (refer to parameter 'ADC_SequencersScanMode').
  7140. This feature can be modified afterwards using unitary function @ref LL_ADC_INJ_SetSequencerLength(). */
  7141. uint32_t SequencerDiscont; /*!< Set ADC group injected sequencer discontinuous mode: sequence subdivided and scan conversions interrupted every selected number of ranks.
  7142. This parameter can be a value of @ref ADC_LL_EC_INJ_SEQ_DISCONT_MODE
  7143. @note This parameter has an effect only if group injected sequencer is enabled
  7144. (scan length of 2 ranks or more).
  7145. This feature can be modified afterwards using unitary function @ref LL_ADC_INJ_SetSequencerDiscont(). */
  7146. uint32_t TrigAuto; /*!< Set ADC group injected conversion trigger: independent or from ADC group regular.
  7147. This parameter can be a value of @ref ADC_LL_EC_INJ_TRIG_AUTO
  7148. Note: This parameter must be set to set to independent trigger if injected trigger source is set to an external trigger.
  7149. This feature can be modified afterwards using unitary function @ref LL_ADC_INJ_SetTrigAuto(). */
  7150. } LL_ADC_INJ_InitTypeDef;
  7151. /**
  7152. * @}
  7153. */
  7154. #endif /* USE_FULL_LL_DRIVER */
  7155. /* Exported constants --------------------------------------------------------*/
  7156. /** @defgroup ADC_LL_Exported_Constants ADC Exported Constants
  7157. * @{
  7158. */
  7159. /** @defgroup ADC_LL_EC_FLAG ADC flags
  7160. * @brief Flags defines which can be used with LL_ADC_ReadReg function
  7161. * @{
  7162. */
  7163. #define LL_ADC_FLAG_STRT ADC_SR_STRT /*!< ADC flag ADC group regular conversion start */
  7164. #define LL_ADC_FLAG_EOS ADC_SR_EOC /*!< ADC flag ADC group regular end of sequence conversions (Note: on this STM32 serie, there is no flag ADC group regular end of unitary conversion. Flag noted as "EOC" is corresponding to flag "EOS" in other STM32 families) */
  7165. #define LL_ADC_FLAG_JSTRT ADC_SR_JSTRT /*!< ADC flag ADC group injected conversion start */
  7166. #define LL_ADC_FLAG_JEOS ADC_SR_JEOC /*!< ADC flag ADC group injected end of sequence conversions (Note: on this STM32 serie, there is no flag ADC group injected end of unitary conversion. Flag noted as "JEOC" is corresponding to flag "JEOS" in other STM32 families) */
  7167. #define LL_ADC_FLAG_AWD1 ADC_SR_AWD /*!< ADC flag ADC analog watchdog 1 */
  7168. /**
  7169. * @}
  7170. */
  7171. /** @defgroup ADC_LL_EC_IT ADC interruptions for configuration (interruption enable or disable)
  7172. * @brief IT defines which can be used with LL_ADC_ReadReg and LL_ADC_WriteReg functions
  7173. * @{
  7174. */
  7175. #define LL_ADC_IT_EOS ADC_CR1_EOCIE /*!< ADC interruption ADC group regular end of sequence conversions (Note: on this STM32 serie, there is no flag ADC group regular end of unitary conversion. Flag noted as "EOC" is corresponding to flag "EOS" in other STM32 families) */
  7176. #define LL_ADC_IT_JEOS ADC_CR1_JEOCIE /*!< ADC interruption ADC group injected end of sequence conversions (Note: on this STM32 serie, there is no flag ADC group injected end of unitary conversion. Flag noted as "JEOC" is corresponding to flag "JEOS" in other STM32 families) */
  7177. #define LL_ADC_IT_AWD1 ADC_CR1_AWDIE /*!< ADC interruption ADC analog watchdog 1 */
  7178. /**
  7179. * @}
  7180. */
  7181. /** @defgroup ADC_LL_EC_REGISTERS ADC registers compliant with specific purpose
  7182. * @{
  7183. */
  7184. /* List of ADC registers intended to be used (most commonly) with */
  7185. /* DMA transfer. */
  7186. /* Refer to function @ref LL_ADC_DMA_GetRegAddr(). */
  7187. #define LL_ADC_DMA_REG_REGULAR_DATA ((uint32_t)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() */
  7188. /**
  7189. * @}
  7190. */
  7191. /** @defgroup ADC_LL_EC_COMMON_PATH_INTERNAL ADC common - Measurement path to internal channels
  7192. * @{
  7193. */
  7194. /* Note: Other measurement paths to internal channels may be available */
  7195. /* (connections to other peripherals). */
  7196. /* If they are not listed below, they do not require any specific */
  7197. /* path enable. In this case, Access to measurement path is done */
  7198. /* only by selecting the corresponding ADC internal channel. */
  7199. #define LL_ADC_PATH_INTERNAL_NONE ((uint32_t)0x00000000U)/*!< ADC measurement pathes all disabled */
  7200. #define LL_ADC_PATH_INTERNAL_VREFINT (ADC_CR2_TSVREFE) /*!< ADC measurement path to internal channel VrefInt */
  7201. #define LL_ADC_PATH_INTERNAL_TEMPSENSOR (ADC_CR2_TSVREFE) /*!< ADC measurement path to internal channel temperature sensor */
  7202. /**
  7203. * @}
  7204. */
  7205. /** @defgroup ADC_LL_EC_RESOLUTION ADC instance - Resolution
  7206. * @{
  7207. */
  7208. #define LL_ADC_RESOLUTION_12B ((uint32_t)0x00000000U) /*!< ADC resolution 12 bits */
  7209. /**
  7210. * @}
  7211. */
  7212. /** @defgroup ADC_LL_EC_DATA_ALIGN ADC instance - Data alignment
  7213. * @{
  7214. */
  7215. #define LL_ADC_DATA_ALIGN_RIGHT ((uint32_t)0x00000000U)/*!< ADC conversion data alignment: right aligned (alignment on data register LSB bit 0)*/
  7216. #define LL_ADC_DATA_ALIGN_LEFT (ADC_CR2_ALIGN) /*!< ADC conversion data alignment: left aligned (aligment on data register MSB bit 15)*/
  7217. /**
  7218. * @}
  7219. */
  7220. /** @defgroup ADC_LL_EC_SCAN_SELECTION ADC instance - Scan selection
  7221. * @{
  7222. */
  7223. #define LL_ADC_SEQ_SCAN_DISABLE ((uint32_t)0x00000000U) /*!< ADC conversion is performed in unitary conversion mode (one channel converted, that defined in rank 1). Configuration of both groups regular and injected sequencers (sequence length, ...) is discarded: equivalent to length of 1 rank.*/
  7224. #define LL_ADC_SEQ_SCAN_ENABLE ((uint32_t)ADC_CR1_SCAN) /*!< ADC conversions are performed in sequence conversions mode, according to configuration of both groups regular and injected sequencers (sequence length, ...). */
  7225. /**
  7226. * @}
  7227. */
  7228. /** @defgroup ADC_LL_EC_GROUPS ADC instance - Groups
  7229. * @{
  7230. */
  7231. #define LL_ADC_GROUP_REGULAR ((uint32_t)0x00000001U) /*!< ADC group regular (available on all STM32 devices) */
  7232. #define LL_ADC_GROUP_INJECTED ((uint32_t)0x00000002U) /*!< ADC group injected (not available on all STM32 devices)*/
  7233. #define LL_ADC_GROUP_REGULAR_INJECTED ((uint32_t)0x00000003U) /*!< ADC both groups regular and injected */
  7234. /**
  7235. * @}
  7236. */
  7237. /** @defgroup ADC_LL_EC_CHANNEL ADC instance - Channel number
  7238. * @{
  7239. */
  7240. #define LL_ADC_CHANNEL_0 (ADC_CHANNEL_0_NUMBER | ADC_CHANNEL_0_SMP) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN0 */
  7241. #define LL_ADC_CHANNEL_1 (ADC_CHANNEL_1_NUMBER | ADC_CHANNEL_1_SMP) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN1 */
  7242. #define LL_ADC_CHANNEL_2 (ADC_CHANNEL_2_NUMBER | ADC_CHANNEL_2_SMP) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN2 */
  7243. #define LL_ADC_CHANNEL_3 (ADC_CHANNEL_3_NUMBER | ADC_CHANNEL_3_SMP) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN3 */
  7244. #define LL_ADC_CHANNEL_4 (ADC_CHANNEL_4_NUMBER | ADC_CHANNEL_4_SMP) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN4 */
  7245. #define LL_ADC_CHANNEL_5 (ADC_CHANNEL_5_NUMBER | ADC_CHANNEL_5_SMP) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN5 */
  7246. #define LL_ADC_CHANNEL_6 (ADC_CHANNEL_6_NUMBER | ADC_CHANNEL_6_SMP) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN6 */
  7247. #define LL_ADC_CHANNEL_7 (ADC_CHANNEL_7_NUMBER | ADC_CHANNEL_7_SMP) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN7 */
  7248. #define LL_ADC_CHANNEL_8 (ADC_CHANNEL_8_NUMBER | ADC_CHANNEL_8_SMP) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN8 */
  7249. #define LL_ADC_CHANNEL_9 (ADC_CHANNEL_9_NUMBER | ADC_CHANNEL_9_SMP) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN9 */
  7250. #define LL_ADC_CHANNEL_10 (ADC_CHANNEL_10_NUMBER | ADC_CHANNEL_10_SMP) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN10 */
  7251. #define LL_ADC_CHANNEL_11 (ADC_CHANNEL_11_NUMBER | ADC_CHANNEL_11_SMP) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN11 */
  7252. #define LL_ADC_CHANNEL_12 (ADC_CHANNEL_12_NUMBER | ADC_CHANNEL_12_SMP) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN12 */
  7253. #define LL_ADC_CHANNEL_13 (ADC_CHANNEL_13_NUMBER | ADC_CHANNEL_13_SMP) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN13 */
  7254. #define LL_ADC_CHANNEL_14 (ADC_CHANNEL_14_NUMBER | ADC_CHANNEL_14_SMP) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN14 */
  7255. #define LL_ADC_CHANNEL_15 (ADC_CHANNEL_15_NUMBER | ADC_CHANNEL_15_SMP) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN15 */
  7256. #define LL_ADC_CHANNEL_16 (ADC_CHANNEL_16_NUMBER | ADC_CHANNEL_16_SMP) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN16 */
  7257. #define LL_ADC_CHANNEL_17 (ADC_CHANNEL_17_NUMBER | ADC_CHANNEL_17_SMP) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN17 */
  7258. #define LL_ADC_CHANNEL_VREFINT (LL_ADC_CHANNEL_17 | ADC_CHANNEL_ID_INTERNAL_CH) /*!< ADC internal channel connected to VrefInt: Internal voltage reference. On STM32F37x, ADC channel available only on ADC instance: ADC1. */
  7259. #define LL_ADC_CHANNEL_TEMPSENSOR (LL_ADC_CHANNEL_16 | ADC_CHANNEL_ID_INTERNAL_CH) /*!< ADC internal channel connected to Temperature sensor. */
  7260. /**
  7261. * @}
  7262. */
  7263. /** @defgroup ADC_LL_EC_REG_TRIGGER_SOURCE ADC group regular - Trigger source
  7264. * @{
  7265. */
  7266. #define LL_ADC_REG_TRIG_SOFTWARE (ADC_CR2_EXTSEL_2 | ADC_CR2_EXTSEL_1 | ADC_CR2_EXTSEL_0) /*!< ADC group regular conversion trigger internal (SW start) */
  7267. #define LL_ADC_REG_TRIG_EXT_TIM2_CH2 (ADC_CR2_EXTSEL_1 | ADC_CR2_EXTSEL_0) /*!< ADC group regular conversion trigger external from TIM2 CC2. Trigger edge set to rising edge (default setting). */
  7268. #define LL_ADC_REG_TRIG_EXT_TIM3_TRGO (ADC_CR2_EXTSEL_2) /*!< ADC group regular conversion trigger external from TIM3 TRGO. Trigger edge set to rising edge (default setting). */
  7269. #define LL_ADC_REG_TRIG_EXT_TIM4_CH2 (ADC_CR2_EXTSEL_2 | ADC_CR2_EXTSEL_0) /*!< ADC group regular conversion trigger external from TIM4 CC4. Trigger edge set to rising edge (default setting). */
  7270. #define LL_ADC_REG_TRIG_EXT_TIM19_TRGO ((uint32_t)0x00000000U) /*!< ADC group regular conversion trigger external from TIM19 TRGO. Trigger edge set to rising edge (default setting). */
  7271. #define LL_ADC_REG_TRIG_EXT_TIM19_CH3 (ADC_CR2_EXTSEL_0) /*!< ADC group regular conversion trigger external from TIM19 CC3. Trigger edge set to rising edge (default setting). */
  7272. #define LL_ADC_REG_TRIG_EXT_TIM19_CH4 (ADC_CR2_EXTSEL_1) /*!< ADC group regular conversion trigger external from TIM19 CC4. Trigger edge set to rising edge (default setting). */
  7273. #define LL_ADC_REG_TRIG_EXT_EXTI_LINE11 (ADC_CR2_EXTSEL_2 | ADC_CR2_EXTSEL_1) /*!< ADC group regular conversion trigger external interrupt line 11. Trigger edge set to rising edge (default setting). */
  7274. /**
  7275. * @}
  7276. */
  7277. /** @defgroup ADC_LL_EC_REG_TRIGGER_EDGE ADC group regular - Trigger edge
  7278. * @{
  7279. */
  7280. #define LL_ADC_REG_TRIG_EXT_RISING ((uint32_t)0x00000000U) /*!< ADC group regular conversion trigger polarity set to rising edge */
  7281. /**
  7282. * @}
  7283. */
  7284. /** @defgroup ADC_LL_EC_REG_CONTINUOUS_MODE ADC group regular - Continuous mode
  7285. * @{
  7286. */
  7287. #define LL_ADC_REG_CONV_SINGLE ((uint32_t)0x00000000U)/*!< ADC conversions are performed in single mode: one conversion per trigger */
  7288. #define LL_ADC_REG_CONV_CONTINUOUS (ADC_CR2_CONT) /*!< ADC conversions are performed in continuous mode: after the first trigger, following conversions launched successively automatically */
  7289. /**
  7290. * @}
  7291. */
  7292. /** @defgroup ADC_LL_EC_REG_DMA_TRANSFER ADC group regular - DMA transfer
  7293. * @{
  7294. */
  7295. #define LL_ADC_REG_DMA_TRANSFER_NONE ((uint32_t)0x00000000U) /*!< ADC conversions are not transferred by DMA */
  7296. #define LL_ADC_REG_DMA_TRANSFER_UNLIMITED (ADC_CR2_DMA) /*!< ADC conversions 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. */
  7297. /**
  7298. * @}
  7299. */
  7300. /** @defgroup ADC_LL_EC_REG_SEQ_SCAN_LENGTH ADC group regular - Sequencer scan length
  7301. * @{
  7302. */
  7303. #define LL_ADC_REG_SEQ_SCAN_DISABLE ((uint32_t)0x00000000U) /*!< ADC group regular sequencer disable (equivalent to sequencer of 1 rank: ADC conversion on only 1 channel) */
  7304. #define LL_ADC_REG_SEQ_SCAN_ENABLE_2RANKS ( ADC_SQR1_L_0) /*!< ADC group regular sequencer enable with 2 ranks in the sequence */
  7305. #define LL_ADC_REG_SEQ_SCAN_ENABLE_3RANKS ( ADC_SQR1_L_1 ) /*!< ADC group regular sequencer enable with 3 ranks in the sequence */
  7306. #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 */
  7307. #define LL_ADC_REG_SEQ_SCAN_ENABLE_5RANKS ( ADC_SQR1_L_2 ) /*!< ADC group regular sequencer enable with 5 ranks in the sequence */
  7308. #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 */
  7309. #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 */
  7310. #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 */
  7311. #define LL_ADC_REG_SEQ_SCAN_ENABLE_9RANKS (ADC_SQR1_L_3 ) /*!< ADC group regular sequencer enable with 9 ranks in the sequence */
  7312. #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 */
  7313. #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 */
  7314. #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 */
  7315. #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 */
  7316. #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 */
  7317. #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 */
  7318. #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 */
  7319. /**
  7320. * @}
  7321. */
  7322. /** @defgroup ADC_LL_EC_REG_SEQ_DISCONT_MODE ADC group regular - Sequencer discontinuous mode
  7323. * @{
  7324. */
  7325. #define LL_ADC_REG_SEQ_DISCONT_DISABLE ((uint32_t)0x00000000U) /*!< ADC group regular sequencer discontinuous mode disable */
  7326. #define LL_ADC_REG_SEQ_DISCONT_1RANK ( ADC_CR1_DISCEN) /*!< ADC group regular sequencer discontinuous mode enable with sequence interruption every rank */
  7327. #define LL_ADC_REG_SEQ_DISCONT_2RANKS ( ADC_CR1_DISCNUM_0 | ADC_CR1_DISCEN) /*!< ADC group regular sequencer discontinuous mode enabled with sequence interruption every 2 ranks */
  7328. #define LL_ADC_REG_SEQ_DISCONT_3RANKS ( ADC_CR1_DISCNUM_1 | ADC_CR1_DISCEN) /*!< ADC group regular sequencer discontinuous mode enable with sequence interruption every 3 ranks */
  7329. #define LL_ADC_REG_SEQ_DISCONT_4RANKS ( ADC_CR1_DISCNUM_1 | ADC_CR1_DISCNUM_0 | ADC_CR1_DISCEN) /*!< ADC group regular sequencer discontinuous mode enable with sequence interruption every 4 ranks */
  7330. #define LL_ADC_REG_SEQ_DISCONT_5RANKS (ADC_CR1_DISCNUM_2 | ADC_CR1_DISCEN) /*!< ADC group regular sequencer discontinuous mode enable with sequence interruption every 5 ranks */
  7331. #define LL_ADC_REG_SEQ_DISCONT_6RANKS (ADC_CR1_DISCNUM_2 | ADC_CR1_DISCNUM_0 | ADC_CR1_DISCEN) /*!< ADC group regular sequencer discontinuous mode enable with sequence interruption every 6 ranks */
  7332. #define LL_ADC_REG_SEQ_DISCONT_7RANKS (ADC_CR1_DISCNUM_2 | ADC_CR1_DISCNUM_1 | ADC_CR1_DISCEN) /*!< ADC group regular sequencer discontinuous mode enable with sequence interruption every 7 ranks */
  7333. #define LL_ADC_REG_SEQ_DISCONT_8RANKS (ADC_CR1_DISCNUM_2 | ADC_CR1_DISCNUM_1 | ADC_CR1_DISCNUM_0 | ADC_CR1_DISCEN) /*!< ADC group regular sequencer discontinuous mode enable with sequence interruption every 8 ranks */
  7334. /**
  7335. * @}
  7336. */
  7337. /** @defgroup ADC_LL_EC_REG_RANKS ADC group regular - Sequencer ranks
  7338. * @{
  7339. */
  7340. #define LL_ADC_REG_RANK_1 (ADC_SQR3_REGOFFSET | ADC_REG_RANK_1_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 1 */
  7341. #define LL_ADC_REG_RANK_2 (ADC_SQR3_REGOFFSET | ADC_REG_RANK_2_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 2 */
  7342. #define LL_ADC_REG_RANK_3 (ADC_SQR3_REGOFFSET | ADC_REG_RANK_3_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 3 */
  7343. #define LL_ADC_REG_RANK_4 (ADC_SQR3_REGOFFSET | ADC_REG_RANK_4_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 4 */
  7344. #define LL_ADC_REG_RANK_5 (ADC_SQR3_REGOFFSET | ADC_REG_RANK_5_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 5 */
  7345. #define LL_ADC_REG_RANK_6 (ADC_SQR3_REGOFFSET | ADC_REG_RANK_6_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 6 */
  7346. #define LL_ADC_REG_RANK_7 (ADC_SQR2_REGOFFSET | ADC_REG_RANK_7_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 7 */
  7347. #define LL_ADC_REG_RANK_8 (ADC_SQR2_REGOFFSET | ADC_REG_RANK_8_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 8 */
  7348. #define LL_ADC_REG_RANK_9 (ADC_SQR2_REGOFFSET | ADC_REG_RANK_9_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 9 */
  7349. #define LL_ADC_REG_RANK_10 (ADC_SQR2_REGOFFSET | ADC_REG_RANK_10_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 10 */
  7350. #define LL_ADC_REG_RANK_11 (ADC_SQR2_REGOFFSET | ADC_REG_RANK_11_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 11 */
  7351. #define LL_ADC_REG_RANK_12 (ADC_SQR2_REGOFFSET | ADC_REG_RANK_12_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 12 */
  7352. #define LL_ADC_REG_RANK_13 (ADC_SQR1_REGOFFSET | ADC_REG_RANK_13_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 13 */
  7353. #define LL_ADC_REG_RANK_14 (ADC_SQR1_REGOFFSET | ADC_REG_RANK_14_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 14 */
  7354. #define LL_ADC_REG_RANK_15 (ADC_SQR1_REGOFFSET | ADC_REG_RANK_15_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 15 */
  7355. #define LL_ADC_REG_RANK_16 (ADC_SQR1_REGOFFSET | ADC_REG_RANK_16_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 16 */
  7356. /**
  7357. * @}
  7358. */
  7359. /** @defgroup ADC_LL_EC_INJ_TRIGGER_SOURCE ADC group injected - Trigger source
  7360. * @{
  7361. */
  7362. #define LL_ADC_INJ_TRIG_SOFTWARE (ADC_CR2_JEXTSEL_2 | ADC_CR2_JEXTSEL_1 | ADC_CR2_JEXTSEL_0) /*!< ADC group injected conversion trigger internal (SW start) */
  7363. #define LL_ADC_INJ_TRIG_EXT_TIM2_TRGO (ADC_CR2_JEXTSEL_1) /*!< ADC group injected conversion trigger external from TIM2 TRGO. Trigger edge set to rising edge (default setting). */
  7364. #define LL_ADC_INJ_TRIG_EXT_TIM2_CH1 (ADC_CR2_JEXTSEL_1 | ADC_CR2_JEXTSEL_0) /*!< ADC group injected conversion trigger external from TIM2 CC1. Trigger edge set to rising edge (default setting). */
  7365. #define LL_ADC_INJ_TRIG_EXT_TIM3_CH4 (ADC_CR2_JEXTSEL_2) /*!< ADC group injected conversion trigger external from TIM3 CC4. Trigger edge set to rising edge (default setting). */
  7366. #define LL_ADC_INJ_TRIG_EXT_TIM4_TRGO (ADC_CR2_JEXTSEL_2 | ADC_CR2_JEXTSEL_0) /*!< ADC group injected conversion trigger external from TIM4 TRGO. Trigger edge set to rising edge (default setting). */
  7367. #define LL_ADC_INJ_TRIG_EXT_TIM19_CH1 ((uint32_t)0x00000000U) /*!< ADC group injected conversion trigger external from TIM19 CC1. Trigger edge set to rising edge (default setting). */
  7368. #define LL_ADC_INJ_TRIG_EXT_TIM19_CH2 (ADC_CR2_JEXTSEL_0) /*!< ADC group injected conversion trigger external from TIM19 CC2. Trigger edge set to rising edge (default setting). */
  7369. #define LL_ADC_INJ_TRIG_EXT_EXTI_LINE15 (ADC_CR2_JEXTSEL_2 | ADC_CR2_JEXTSEL_1) /*!< ADC group injected conversion trigger external interrupt line 15. Trigger edge set to rising edge (default setting). */
  7370. /**
  7371. * @}
  7372. */
  7373. /** @defgroup ADC_LL_EC_INJ_TRIGGER_EDGE ADC group injected - Trigger edge
  7374. * @{
  7375. */
  7376. #define LL_ADC_INJ_TRIG_EXT_RISING ((uint32_t)0x00000000U) /*!< ADC group injected conversion trigger polarity set to rising edge */
  7377. /**
  7378. * @}
  7379. */
  7380. /** @defgroup ADC_LL_EC_INJ_TRIG_AUTO ADC group injected - Automatic trigger mode
  7381. * @{
  7382. */
  7383. #define LL_ADC_INJ_TRIG_INDEPENDENT ((uint32_t)0x00000000U)/*!< ADC group injected conversion trigger independent. Setting mandatory if ADC group injected injected trigger source is set to an external trigger. */
  7384. #define LL_ADC_INJ_TRIG_FROM_GRP_REGULAR (ADC_CR1_JAUTO) /*!< ADC group injected conversion trigger from ADC group regular. Setting compliant only with group injected trigger source set to SW start, without any further action on ADC group injected conversion start or stop: in this case, ADC group injected is controlled only from ADC group regular. */
  7385. /**
  7386. * @}
  7387. */
  7388. /** @defgroup ADC_LL_EC_INJ_SEQ_SCAN_LENGTH ADC group injected - Sequencer scan length
  7389. * @{
  7390. */
  7391. #define LL_ADC_INJ_SEQ_SCAN_DISABLE ((uint32_t)0x00000000U) /*!< ADC group injected sequencer disable (equivalent to sequencer of 1 rank: ADC conversion on only 1 channel) */
  7392. #define LL_ADC_INJ_SEQ_SCAN_ENABLE_2RANKS ( ADC_JSQR_JL_0) /*!< ADC group injected sequencer enable with 2 ranks in the sequence */
  7393. #define LL_ADC_INJ_SEQ_SCAN_ENABLE_3RANKS (ADC_JSQR_JL_1 ) /*!< ADC group injected sequencer enable with 3 ranks in the sequence */
  7394. #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 */
  7395. /**
  7396. * @}
  7397. */
  7398. /** @defgroup ADC_LL_EC_INJ_SEQ_DISCONT_MODE ADC group injected - Sequencer discontinuous mode
  7399. * @{
  7400. */
  7401. #define LL_ADC_INJ_SEQ_DISCONT_DISABLE ((uint32_t)0x00000000U)/*!< ADC group injected sequencer discontinuous mode disable */
  7402. #define LL_ADC_INJ_SEQ_DISCONT_1RANK (ADC_CR1_JDISCEN) /*!< ADC group injected sequencer discontinuous mode enable with sequence interruption every rank */
  7403. /**
  7404. * @}
  7405. */
  7406. /** @defgroup ADC_LL_EC_INJ_RANKS ADC group injected - Sequencer ranks
  7407. * @{
  7408. */
  7409. #define LL_ADC_INJ_RANK_1 (ADC_JDR1_REGOFFSET | ADC_JOFR1_REGOFFSET | ADC_INJ_RANK_1_JSQR_BITOFFSET_POS) /*!< ADC group injected sequencer rank 1 */
  7410. #define LL_ADC_INJ_RANK_2 (ADC_JDR2_REGOFFSET | ADC_JOFR2_REGOFFSET | ADC_INJ_RANK_2_JSQR_BITOFFSET_POS) /*!< ADC group injected sequencer rank 2 */
  7411. #define LL_ADC_INJ_RANK_3 (ADC_JDR3_REGOFFSET | ADC_JOFR3_REGOFFSET | ADC_INJ_RANK_3_JSQR_BITOFFSET_POS) /*!< ADC group injected sequencer rank 3 */
  7412. #define LL_ADC_INJ_RANK_4 (ADC_JDR4_REGOFFSET | ADC_JOFR4_REGOFFSET | ADC_INJ_RANK_4_JSQR_BITOFFSET_POS) /*!< ADC group injected sequencer rank 4 */
  7413. /**
  7414. * @}
  7415. */
  7416. /** @defgroup ADC_LL_EC_SAMPLINGTIME Channel - Sampling time
  7417. * @{
  7418. */
  7419. #define LL_ADC_SAMPLINGTIME_1CYCLE_5 ((uint32_t)0x00000000U) /*!< Sampling time 1.5 ADC clock cycle */
  7420. #define LL_ADC_SAMPLINGTIME_7CYCLES_5 (ADC_SMPR2_SMP0_0) /*!< Sampling time 7.5 ADC clock cycles */
  7421. #define LL_ADC_SAMPLINGTIME_13CYCLES_5 (ADC_SMPR2_SMP0_1) /*!< Sampling time 13.5 ADC clock cycles */
  7422. #define LL_ADC_SAMPLINGTIME_28CYCLES_5 (ADC_SMPR2_SMP0_1 | ADC_SMPR2_SMP0_0) /*!< Sampling time 28.5 ADC clock cycles */
  7423. #define LL_ADC_SAMPLINGTIME_41CYCLES_5 (ADC_SMPR2_SMP0_2) /*!< Sampling time 41.5 ADC clock cycles */
  7424. #define LL_ADC_SAMPLINGTIME_55CYCLES_5 (ADC_SMPR2_SMP0_2 | ADC_SMPR2_SMP0_0) /*!< Sampling time 55.5 ADC clock cycles */
  7425. #define LL_ADC_SAMPLINGTIME_71CYCLES_5 (ADC_SMPR2_SMP0_2 | ADC_SMPR2_SMP0_1) /*!< Sampling time 71.5 ADC clock cycles */
  7426. #define LL_ADC_SAMPLINGTIME_239CYCLES_5 (ADC_SMPR2_SMP0_2 | ADC_SMPR2_SMP0_1 | ADC_SMPR2_SMP0_0) /*!< Sampling time 239.5 ADC clock cycles */
  7427. /**
  7428. * @}
  7429. */
  7430. /** @defgroup ADC_LL_EC_AWD_NUMBER Analog watchdog - Analog watchdog number
  7431. * @{
  7432. */
  7433. #define LL_ADC_AWD1 (ADC_AWD_CR1_CHANNEL_MASK | ADC_AWD_CR1_REGOFFSET) /*!< ADC analog watchdog number 1 */
  7434. /**
  7435. * @}
  7436. */
  7437. /** @defgroup ADC_LL_EC_AWD_CHANNELS Analog watchdog - Monitored channels
  7438. * @{
  7439. */
  7440. #define LL_ADC_AWD_DISABLE ((uint32_t)0x00000000U) /*!< ADC analog watchdog monitoring disabled */
  7441. #define LL_ADC_AWD_ALL_CHANNELS_REG ( ADC_CR1_AWDEN ) /*!< ADC analog watchdog monitoring of all channels, converted by group regular only */
  7442. #define LL_ADC_AWD_ALL_CHANNELS_INJ ( ADC_CR1_JAWDEN ) /*!< ADC analog watchdog monitoring of all channels, converted by group injected only */
  7443. #define LL_ADC_AWD_ALL_CHANNELS_REG_INJ ( ADC_CR1_JAWDEN | ADC_CR1_AWDEN ) /*!< ADC analog watchdog monitoring of all channels, converted by either group regular or injected */
  7444. #define LL_ADC_AWD_CHANNEL_0_REG ((LL_ADC_CHANNEL_0 & ADC_CHANNEL_ID_MASK) | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN0, converted by group regular only */
  7445. #define LL_ADC_AWD_CHANNEL_0_INJ ((LL_ADC_CHANNEL_0 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN0, converted by group injected only */
  7446. #define LL_ADC_AWD_CHANNEL_0_REG_INJ ((LL_ADC_CHANNEL_0 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN0, converted by either group regular or injected */
  7447. #define LL_ADC_AWD_CHANNEL_1_REG ((LL_ADC_CHANNEL_1 & ADC_CHANNEL_ID_MASK) | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN1, converted by group regular only */
  7448. #define LL_ADC_AWD_CHANNEL_1_INJ ((LL_ADC_CHANNEL_1 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN1, converted by group injected only */
  7449. #define LL_ADC_AWD_CHANNEL_1_REG_INJ ((LL_ADC_CHANNEL_1 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN1, converted by either group regular or injected */
  7450. #define LL_ADC_AWD_CHANNEL_2_REG ((LL_ADC_CHANNEL_2 & ADC_CHANNEL_ID_MASK) | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN2, converted by group regular only */
  7451. #define LL_ADC_AWD_CHANNEL_2_INJ ((LL_ADC_CHANNEL_2 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN2, converted by group injected only */
  7452. #define LL_ADC_AWD_CHANNEL_2_REG_INJ ((LL_ADC_CHANNEL_2 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN2, converted by either group regular or injected */
  7453. #define LL_ADC_AWD_CHANNEL_3_REG ((LL_ADC_CHANNEL_3 & ADC_CHANNEL_ID_MASK) | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN3, converted by group regular only */
  7454. #define LL_ADC_AWD_CHANNEL_3_INJ ((LL_ADC_CHANNEL_3 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN3, converted by group injected only */
  7455. #define LL_ADC_AWD_CHANNEL_3_REG_INJ ((LL_ADC_CHANNEL_3 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN3, converted by either group regular or injected */
  7456. #define LL_ADC_AWD_CHANNEL_4_REG ((LL_ADC_CHANNEL_4 & ADC_CHANNEL_ID_MASK) | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN4, converted by group regular only */
  7457. #define LL_ADC_AWD_CHANNEL_4_INJ ((LL_ADC_CHANNEL_4 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN4, converted by group injected only */
  7458. #define LL_ADC_AWD_CHANNEL_4_REG_INJ ((LL_ADC_CHANNEL_4 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN4, converted by either group regular or injected */
  7459. #define LL_ADC_AWD_CHANNEL_5_REG ((LL_ADC_CHANNEL_5 & ADC_CHANNEL_ID_MASK) | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN5, converted by group regular only */
  7460. #define LL_ADC_AWD_CHANNEL_5_INJ ((LL_ADC_CHANNEL_5 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN5, converted by group injected only */
  7461. #define LL_ADC_AWD_CHANNEL_5_REG_INJ ((LL_ADC_CHANNEL_5 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN5, converted by either group regular or injected */
  7462. #define LL_ADC_AWD_CHANNEL_6_REG ((LL_ADC_CHANNEL_6 & ADC_CHANNEL_ID_MASK) | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN6, converted by group regular only */
  7463. #define LL_ADC_AWD_CHANNEL_6_INJ ((LL_ADC_CHANNEL_6 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN6, converted by group injected only */
  7464. #define LL_ADC_AWD_CHANNEL_6_REG_INJ ((LL_ADC_CHANNEL_6 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN6, converted by either group regular or injected */
  7465. #define LL_ADC_AWD_CHANNEL_7_REG ((LL_ADC_CHANNEL_7 & ADC_CHANNEL_ID_MASK) | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN7, converted by group regular only */
  7466. #define LL_ADC_AWD_CHANNEL_7_INJ ((LL_ADC_CHANNEL_7 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN7, converted by group injected only */
  7467. #define LL_ADC_AWD_CHANNEL_7_REG_INJ ((LL_ADC_CHANNEL_7 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN7, converted by either group regular or injected */
  7468. #define LL_ADC_AWD_CHANNEL_8_REG ((LL_ADC_CHANNEL_8 & ADC_CHANNEL_ID_MASK) | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN8, converted by group regular only */
  7469. #define LL_ADC_AWD_CHANNEL_8_INJ ((LL_ADC_CHANNEL_8 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN8, converted by group injected only */
  7470. #define LL_ADC_AWD_CHANNEL_8_REG_INJ ((LL_ADC_CHANNEL_8 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN8, converted by either group regular or injected */
  7471. #define LL_ADC_AWD_CHANNEL_9_REG ((LL_ADC_CHANNEL_9 & ADC_CHANNEL_ID_MASK) | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN9, converted by group regular only */
  7472. #define LL_ADC_AWD_CHANNEL_9_INJ ((LL_ADC_CHANNEL_9 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN9, converted by group injected only */
  7473. #define LL_ADC_AWD_CHANNEL_9_REG_INJ ((LL_ADC_CHANNEL_9 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN9, converted by either group regular or injected */
  7474. #define LL_ADC_AWD_CHANNEL_10_REG ((LL_ADC_CHANNEL_10 & ADC_CHANNEL_ID_MASK) | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN10, converted by group regular only */
  7475. #define LL_ADC_AWD_CHANNEL_10_INJ ((LL_ADC_CHANNEL_10 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN10, converted by group injected only */
  7476. #define LL_ADC_AWD_CHANNEL_10_REG_INJ ((LL_ADC_CHANNEL_10 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN10, converted by either group regular or injected */
  7477. #define LL_ADC_AWD_CHANNEL_11_REG ((LL_ADC_CHANNEL_11 & ADC_CHANNEL_ID_MASK) | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN11, converted by group regular only */
  7478. #define LL_ADC_AWD_CHANNEL_11_INJ ((LL_ADC_CHANNEL_11 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN11, converted by group injected only */
  7479. #define LL_ADC_AWD_CHANNEL_11_REG_INJ ((LL_ADC_CHANNEL_11 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN11, converted by either group regular or injected */
  7480. #define LL_ADC_AWD_CHANNEL_12_REG ((LL_ADC_CHANNEL_12 & ADC_CHANNEL_ID_MASK) | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN12, converted by group regular only */
  7481. #define LL_ADC_AWD_CHANNEL_12_INJ ((LL_ADC_CHANNEL_12 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN12, converted by group injected only */
  7482. #define LL_ADC_AWD_CHANNEL_12_REG_INJ ((LL_ADC_CHANNEL_12 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN12, converted by either group regular or injected */
  7483. #define LL_ADC_AWD_CHANNEL_13_REG ((LL_ADC_CHANNEL_13 & ADC_CHANNEL_ID_MASK) | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN13, converted by group regular only */
  7484. #define LL_ADC_AWD_CHANNEL_13_INJ ((LL_ADC_CHANNEL_13 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN13, converted by group injected only */
  7485. #define LL_ADC_AWD_CHANNEL_13_REG_INJ ((LL_ADC_CHANNEL_13 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN13, converted by either group regular or injected */
  7486. #define LL_ADC_AWD_CHANNEL_14_REG ((LL_ADC_CHANNEL_14 & ADC_CHANNEL_ID_MASK) | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN14, converted by group regular only */
  7487. #define LL_ADC_AWD_CHANNEL_14_INJ ((LL_ADC_CHANNEL_14 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN14, converted by group injected only */
  7488. #define LL_ADC_AWD_CHANNEL_14_REG_INJ ((LL_ADC_CHANNEL_14 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN14, converted by either group regular or injected */
  7489. #define LL_ADC_AWD_CHANNEL_15_REG ((LL_ADC_CHANNEL_15 & ADC_CHANNEL_ID_MASK) | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN15, converted by group regular only */
  7490. #define LL_ADC_AWD_CHANNEL_15_INJ ((LL_ADC_CHANNEL_15 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN15, converted by group injected only */
  7491. #define LL_ADC_AWD_CHANNEL_15_REG_INJ ((LL_ADC_CHANNEL_15 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN15, converted by either group regular or injected */
  7492. #define LL_ADC_AWD_CHANNEL_16_REG ((LL_ADC_CHANNEL_16 & ADC_CHANNEL_ID_MASK) | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN16, converted by group regular only */
  7493. #define LL_ADC_AWD_CHANNEL_16_INJ ((LL_ADC_CHANNEL_16 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN16, converted by group injected only */
  7494. #define LL_ADC_AWD_CHANNEL_16_REG_INJ ((LL_ADC_CHANNEL_16 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN16, converted by either group regular or injected */
  7495. #define LL_ADC_AWD_CHANNEL_17_REG ((LL_ADC_CHANNEL_17 & ADC_CHANNEL_ID_MASK) | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN17, converted by group regular only */
  7496. #define LL_ADC_AWD_CHANNEL_17_INJ ((LL_ADC_CHANNEL_17 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN17, converted by group injected only */
  7497. #define LL_ADC_AWD_CHANNEL_17_REG_INJ ((LL_ADC_CHANNEL_17 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN17, converted by either group regular or injected */
  7498. #define LL_ADC_AWD_CH_VREFINT_REG ((LL_ADC_CHANNEL_VREFINT & ADC_CHANNEL_ID_MASK) | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC internal channel connected to VrefInt: Internal voltage reference, converted by group regular only */
  7499. #define LL_ADC_AWD_CH_VREFINT_INJ ((LL_ADC_CHANNEL_VREFINT & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC internal channel connected to VrefInt: Internal voltage reference, converted by group injected only */
  7500. #define LL_ADC_AWD_CH_VREFINT_REG_INJ ((LL_ADC_CHANNEL_VREFINT & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC internal channel connected to VrefInt: Internal voltage reference, converted by either group regular or injected */
  7501. #define LL_ADC_AWD_CH_TEMPSENSOR_REG ((LL_ADC_CHANNEL_TEMPSENSOR & ADC_CHANNEL_ID_MASK) | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC internal channel connected to Temperature sensor, converted by group regular only */
  7502. #define LL_ADC_AWD_CH_TEMPSENSOR_INJ ((LL_ADC_CHANNEL_TEMPSENSOR & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC internal channel connected to Temperature sensor, converted by group injected only */
  7503. #define LL_ADC_AWD_CH_TEMPSENSOR_REG_INJ ((LL_ADC_CHANNEL_TEMPSENSOR & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC internal channel connected to Temperature sensor, converted by either group regular or injected */
  7504. /**
  7505. * @}
  7506. */
  7507. /** @defgroup ADC_LL_EC_AWD_THRESHOLDS Analog watchdog - Thresholds
  7508. * @{
  7509. */
  7510. #define LL_ADC_AWD_THRESHOLD_HIGH (ADC_AWD_TR1_HIGH_REGOFFSET) /*!< ADC analog watchdog threshold high */
  7511. #define LL_ADC_AWD_THRESHOLD_LOW (ADC_AWD_TR1_LOW_REGOFFSET) /*!< ADC analog watchdog threshold low */
  7512. /**
  7513. * @}
  7514. */
  7515. /** @defgroup ADC_LL_EC_HW_DELAYS Definitions of ADC hardware constraints delays
  7516. * @note Only ADC IP HW delays are defined in ADC LL driver driver,
  7517. * not timeout values.
  7518. * For details on delays values, refer to descriptions in source code
  7519. * above each literal definition.
  7520. * @{
  7521. */
  7522. /* Note: Only ADC IP HW delays are defined in ADC LL driver driver, */
  7523. /* not timeout values. */
  7524. /* Timeout values for ADC operations are dependent to device clock */
  7525. /* configuration (system clock versus ADC clock), */
  7526. /* and therefore must be defined in user application. */
  7527. /* Indications for estimation of ADC timeout delays, for this */
  7528. /* STM32 serie: */
  7529. /* - ADC enable time: maximum delay is 1us */
  7530. /* (refer to device datasheet, parameter "tSTAB") */
  7531. /* - ADC conversion time: duration depending on ADC clock and ADC */
  7532. /* configuration. */
  7533. /* (refer to device reference manual, section "Timing") */
  7534. /* Delay for temperature sensor stabilization time. */
  7535. /* Literal set to maximum value (refer to device datasheet, */
  7536. /* parameter "tSTART"). */
  7537. /* Unit: us */
  7538. #define LL_ADC_DELAY_TEMPSENSOR_STAB_US ((uint32_t) 10U) /*!< Delay for internal voltage reference stabilization time */
  7539. /* Delay required between ADC disable and ADC calibration start. */
  7540. /* Note: On this STM32 serie, before starting a calibration, */
  7541. /* ADC must be disabled. */
  7542. /* A minimum number of ADC clock cycles are required */
  7543. /* between ADC disable state and calibration start. */
  7544. /* Refer to literal @ref LL_ADC_DELAY_CALIB_ENABLE_ADC_CYCLES. */
  7545. /* Wait time can be computed in user application by waiting for the */
  7546. /* equivalent number of CPU cycles, by taking into account */
  7547. /* ratio of CPU clock versus ADC clock prescalers. */
  7548. /* Unit: ADC clock cycles. */
  7549. #define LL_ADC_DELAY_DISABLE_CALIB_ADC_CYCLES ((uint32_t) 2U) /*!< Delay required between ADC disable and ADC calibration start */
  7550. /**
  7551. * @}
  7552. */
  7553. /**
  7554. * @}
  7555. */
  7556. /* Exported macro ------------------------------------------------------------*/
  7557. /** @defgroup ADC_LL_Exported_Macros ADC Exported Macros
  7558. * @{
  7559. */
  7560. /** @defgroup ADC_LL_EM_WRITE_READ Common write and read registers Macros
  7561. * @{
  7562. */
  7563. /**
  7564. * @brief Write a value in ADC register
  7565. * @param __INSTANCE__ ADC Instance
  7566. * @param __REG__ Register to be written
  7567. * @param __VALUE__ Value to be written in the register
  7568. * @retval None
  7569. */
  7570. #define LL_ADC_WriteReg(__INSTANCE__, __REG__, __VALUE__) WRITE_REG(__INSTANCE__->__REG__, (__VALUE__))
  7571. /**
  7572. * @brief Read a value in ADC register
  7573. * @param __INSTANCE__ ADC Instance
  7574. * @param __REG__ Register to be read
  7575. * @retval Register value
  7576. */
  7577. #define LL_ADC_ReadReg(__INSTANCE__, __REG__) READ_REG(__INSTANCE__->__REG__)
  7578. /**
  7579. * @}
  7580. */
  7581. /** @defgroup ADC_LL_EM_HELPER_MACRO ADC helper macro
  7582. * @{
  7583. */
  7584. /**
  7585. * @brief Helper macro to get ADC channel number in decimal format
  7586. * from literals LL_ADC_CHANNEL_x.
  7587. * @note Example:
  7588. * __LL_ADC_CHANNEL_TO_DECIMAL_NB(LL_ADC_CHANNEL_4)
  7589. * will return decimal number "4".
  7590. * @note The input can be a value from functions where a channel
  7591. * number is returned, either defined with number
  7592. * or with bitfield (only one bit must be set).
  7593. * @param __CHANNEL__ This parameter can be one of the following values:
  7594. * @arg @ref LL_ADC_CHANNEL_0
  7595. * @arg @ref LL_ADC_CHANNEL_1
  7596. * @arg @ref LL_ADC_CHANNEL_2
  7597. * @arg @ref LL_ADC_CHANNEL_3
  7598. * @arg @ref LL_ADC_CHANNEL_4
  7599. * @arg @ref LL_ADC_CHANNEL_5
  7600. * @arg @ref LL_ADC_CHANNEL_6
  7601. * @arg @ref LL_ADC_CHANNEL_7
  7602. * @arg @ref LL_ADC_CHANNEL_8
  7603. * @arg @ref LL_ADC_CHANNEL_9
  7604. * @arg @ref LL_ADC_CHANNEL_10
  7605. * @arg @ref LL_ADC_CHANNEL_11
  7606. * @arg @ref LL_ADC_CHANNEL_12
  7607. * @arg @ref LL_ADC_CHANNEL_13
  7608. * @arg @ref LL_ADC_CHANNEL_14
  7609. * @arg @ref LL_ADC_CHANNEL_15
  7610. * @arg @ref LL_ADC_CHANNEL_16
  7611. * @arg @ref LL_ADC_CHANNEL_17
  7612. * @arg @ref LL_ADC_CHANNEL_VREFINT (1)
  7613. * @arg @ref LL_ADC_CHANNEL_TEMPSENSOR (1)
  7614. *
  7615. * (1) On STM32F37x, parameter available only on ADC instance: ADC1.
  7616. * @retval Value between Min_Data=0 and Max_Data=18
  7617. */
  7618. #define __LL_ADC_CHANNEL_TO_DECIMAL_NB(__CHANNEL__) \
  7619. (((__CHANNEL__) & ADC_CHANNEL_ID_NUMBER_MASK) >> ADC_CHANNEL_ID_NUMBER_BITOFFSET_POS)
  7620. /**
  7621. * @brief Helper macro to get ADC channel in literal format LL_ADC_CHANNEL_x
  7622. * from number in decimal format.
  7623. * @note Example:
  7624. * __LL_ADC_DECIMAL_NB_TO_CHANNEL(4)
  7625. * will return a data equivalent to "LL_ADC_CHANNEL_4".
  7626. * @param __DECIMAL_NB__ Value between Min_Data=0 and Max_Data=18
  7627. * @retval Returned value can be one of the following values:
  7628. * @arg @ref LL_ADC_CHANNEL_0
  7629. * @arg @ref LL_ADC_CHANNEL_1
  7630. * @arg @ref LL_ADC_CHANNEL_2
  7631. * @arg @ref LL_ADC_CHANNEL_3
  7632. * @arg @ref LL_ADC_CHANNEL_4
  7633. * @arg @ref LL_ADC_CHANNEL_5
  7634. * @arg @ref LL_ADC_CHANNEL_6
  7635. * @arg @ref LL_ADC_CHANNEL_7
  7636. * @arg @ref LL_ADC_CHANNEL_8
  7637. * @arg @ref LL_ADC_CHANNEL_9
  7638. * @arg @ref LL_ADC_CHANNEL_10
  7639. * @arg @ref LL_ADC_CHANNEL_11
  7640. * @arg @ref LL_ADC_CHANNEL_12
  7641. * @arg @ref LL_ADC_CHANNEL_13
  7642. * @arg @ref LL_ADC_CHANNEL_14
  7643. * @arg @ref LL_ADC_CHANNEL_15
  7644. * @arg @ref LL_ADC_CHANNEL_16
  7645. * @arg @ref LL_ADC_CHANNEL_17
  7646. * @arg @ref LL_ADC_CHANNEL_VREFINT (1)
  7647. * @arg @ref LL_ADC_CHANNEL_TEMPSENSOR (1)
  7648. *
  7649. * (1) On STM32F37x, parameter available only on ADC instance: ADC1.\n
  7650. * (1) For ADC channel read back from ADC register,
  7651. * comparison with internal channel parameter to be done
  7652. * using helper macro @ref __LL_ADC_CHANNEL_INTERNAL_TO_EXTERNAL().
  7653. */
  7654. #define __LL_ADC_DECIMAL_NB_TO_CHANNEL(__DECIMAL_NB__) \
  7655. (((__DECIMAL_NB__) <= 9U) \
  7656. ? ( \
  7657. ((__DECIMAL_NB__) << ADC_CHANNEL_ID_NUMBER_BITOFFSET_POS) | \
  7658. (ADC_SMPR2_REGOFFSET | (((uint32_t) (3U * (__DECIMAL_NB__))) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) \
  7659. ) \
  7660. : \
  7661. ( \
  7662. ((__DECIMAL_NB__) << ADC_CHANNEL_ID_NUMBER_BITOFFSET_POS) | \
  7663. (ADC_SMPR1_REGOFFSET | (((uint32_t) (3U * ((__DECIMAL_NB__) - 10U))) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) \
  7664. ) \
  7665. )
  7666. /**
  7667. * @brief Helper macro to determine whether the selected channel
  7668. * corresponds to literal definitions of driver.
  7669. * @note The different literal definitions of ADC channels are:
  7670. * - ADC internal channel:
  7671. * LL_ADC_CHANNEL_VREFINT, LL_ADC_CHANNEL_TEMPSENSOR, ...
  7672. * - ADC external channel (channel connected to a GPIO pin):
  7673. * LL_ADC_CHANNEL_1, LL_ADC_CHANNEL_2, ...
  7674. * @note The channel parameter must be a value defined from literal
  7675. * definition of a ADC internal channel (LL_ADC_CHANNEL_VREFINT,
  7676. * LL_ADC_CHANNEL_TEMPSENSOR, ...),
  7677. * ADC external channel (LL_ADC_CHANNEL_1, LL_ADC_CHANNEL_2, ...),
  7678. * must not be a value from functions where a channel number is
  7679. * returned from ADC registers,
  7680. * because internal and external channels share the same channel
  7681. * number in ADC registers. The differentiation is made only with
  7682. * parameters definitions of driver.
  7683. * @param __CHANNEL__ This parameter can be one of the following values:
  7684. * @arg @ref LL_ADC_CHANNEL_0
  7685. * @arg @ref LL_ADC_CHANNEL_1
  7686. * @arg @ref LL_ADC_CHANNEL_2
  7687. * @arg @ref LL_ADC_CHANNEL_3
  7688. * @arg @ref LL_ADC_CHANNEL_4
  7689. * @arg @ref LL_ADC_CHANNEL_5
  7690. * @arg @ref LL_ADC_CHANNEL_6
  7691. * @arg @ref LL_ADC_CHANNEL_7
  7692. * @arg @ref LL_ADC_CHANNEL_8
  7693. * @arg @ref LL_ADC_CHANNEL_9
  7694. * @arg @ref LL_ADC_CHANNEL_10
  7695. * @arg @ref LL_ADC_CHANNEL_11
  7696. * @arg @ref LL_ADC_CHANNEL_12
  7697. * @arg @ref LL_ADC_CHANNEL_13
  7698. * @arg @ref LL_ADC_CHANNEL_14
  7699. * @arg @ref LL_ADC_CHANNEL_15
  7700. * @arg @ref LL_ADC_CHANNEL_16
  7701. * @arg @ref LL_ADC_CHANNEL_17
  7702. * @arg @ref LL_ADC_CHANNEL_VREFINT (1)
  7703. * @arg @ref LL_ADC_CHANNEL_TEMPSENSOR (1)
  7704. *
  7705. * (1) On STM32F37x, parameter available only on ADC instance: ADC1.
  7706. * @retval Value "0" if the channel corresponds to a parameter definition of a ADC external channel (channel connected to a GPIO pin)
  7707. * Value "1" if the channel corresponds to a parameter definition of a ADC internal channel
  7708. */
  7709. #define __LL_ADC_IS_CHANNEL_INTERNAL(__CHANNEL__) \
  7710. (((__CHANNEL__) & ADC_CHANNEL_ID_INTERNAL_CH_MASK) != 0U)
  7711. /**
  7712. * @brief Helper macro to convert a channel defined from parameter
  7713. * definition of a ADC internal channel (LL_ADC_CHANNEL_VREFINT,
  7714. * LL_ADC_CHANNEL_TEMPSENSOR, ...),
  7715. * to its equivalent parameter definition of a ADC external channel
  7716. * (LL_ADC_CHANNEL_1, LL_ADC_CHANNEL_2, ...).
  7717. * @note The channel parameter can be, additionally to a value
  7718. * defined from parameter definition of a ADC internal channel
  7719. * (LL_ADC_CHANNEL_VREFINT, LL_ADC_CHANNEL_TEMPSENSOR, ...),
  7720. * a value defined from parameter definition of
  7721. * ADC external channel (LL_ADC_CHANNEL_1, LL_ADC_CHANNEL_2, ...)
  7722. * or a value from functions where a channel number is returned
  7723. * from ADC registers.
  7724. * @param __CHANNEL__ This parameter can be one of the following values:
  7725. * @arg @ref LL_ADC_CHANNEL_0
  7726. * @arg @ref LL_ADC_CHANNEL_1
  7727. * @arg @ref LL_ADC_CHANNEL_2
  7728. * @arg @ref LL_ADC_CHANNEL_3
  7729. * @arg @ref LL_ADC_CHANNEL_4
  7730. * @arg @ref LL_ADC_CHANNEL_5
  7731. * @arg @ref LL_ADC_CHANNEL_6
  7732. * @arg @ref LL_ADC_CHANNEL_7
  7733. * @arg @ref LL_ADC_CHANNEL_8
  7734. * @arg @ref LL_ADC_CHANNEL_9
  7735. * @arg @ref LL_ADC_CHANNEL_10
  7736. * @arg @ref LL_ADC_CHANNEL_11
  7737. * @arg @ref LL_ADC_CHANNEL_12
  7738. * @arg @ref LL_ADC_CHANNEL_13
  7739. * @arg @ref LL_ADC_CHANNEL_14
  7740. * @arg @ref LL_ADC_CHANNEL_15
  7741. * @arg @ref LL_ADC_CHANNEL_16
  7742. * @arg @ref LL_ADC_CHANNEL_17
  7743. * @arg @ref LL_ADC_CHANNEL_VREFINT (1)
  7744. * @arg @ref LL_ADC_CHANNEL_TEMPSENSOR (1)
  7745. *
  7746. * (1) On STM32F37x, parameter available only on ADC instance: ADC1.
  7747. * @retval Returned value can be one of the following values:
  7748. * @arg @ref LL_ADC_CHANNEL_0
  7749. * @arg @ref LL_ADC_CHANNEL_1
  7750. * @arg @ref LL_ADC_CHANNEL_2
  7751. * @arg @ref LL_ADC_CHANNEL_3
  7752. * @arg @ref LL_ADC_CHANNEL_4
  7753. * @arg @ref LL_ADC_CHANNEL_5
  7754. * @arg @ref LL_ADC_CHANNEL_6
  7755. * @arg @ref LL_ADC_CHANNEL_7
  7756. * @arg @ref LL_ADC_CHANNEL_8
  7757. * @arg @ref LL_ADC_CHANNEL_9
  7758. * @arg @ref LL_ADC_CHANNEL_10
  7759. * @arg @ref LL_ADC_CHANNEL_11
  7760. * @arg @ref LL_ADC_CHANNEL_12
  7761. * @arg @ref LL_ADC_CHANNEL_13
  7762. * @arg @ref LL_ADC_CHANNEL_14
  7763. * @arg @ref LL_ADC_CHANNEL_15
  7764. * @arg @ref LL_ADC_CHANNEL_16
  7765. * @arg @ref LL_ADC_CHANNEL_17
  7766. */
  7767. #define __LL_ADC_CHANNEL_INTERNAL_TO_EXTERNAL(__CHANNEL__) \
  7768. ((__CHANNEL__) & ~ADC_CHANNEL_ID_INTERNAL_CH_MASK)
  7769. /**
  7770. * @brief Helper macro to determine whether the internal channel
  7771. * selected is available on the ADC instance selected.
  7772. * @note The channel parameter must be a value defined from parameter
  7773. * definition of a ADC internal channel (LL_ADC_CHANNEL_VREFINT,
  7774. * LL_ADC_CHANNEL_TEMPSENSOR, ...),
  7775. * must not be a value defined from parameter definition of
  7776. * ADC external channel (LL_ADC_CHANNEL_1, LL_ADC_CHANNEL_2, ...)
  7777. * or a value from functions where a channel number is
  7778. * returned from ADC registers,
  7779. * because internal and external channels share the same channel
  7780. * number in ADC registers. The differentiation is made only with
  7781. * parameters definitions of driver.
  7782. * @param __ADC_INSTANCE__ ADC instance
  7783. * @param __CHANNEL__ This parameter can be one of the following values:
  7784. * @arg @ref LL_ADC_CHANNEL_VREFINT (1)
  7785. * @arg @ref LL_ADC_CHANNEL_TEMPSENSOR (1)
  7786. *
  7787. * (1) On STM32F37x, parameter available only on ADC instance: ADC1.
  7788. * @retval Value "0" if the internal channel selected is not available on the ADC instance selected.
  7789. * Value "1" if the internal channel selected is available on the ADC instance selected.
  7790. */
  7791. #define __LL_ADC_IS_CHANNEL_INTERNAL_AVAILABLE(__ADC_INSTANCE__, __CHANNEL__) \
  7792. (((__ADC_INSTANCE__) == ADC1) \
  7793. ? ( \
  7794. ((__CHANNEL__) == LL_ADC_CHANNEL_VREFINT) || \
  7795. ((__CHANNEL__) == LL_ADC_CHANNEL_TEMPSENSOR) \
  7796. ) \
  7797. : \
  7798. (0U) \
  7799. )
  7800. /**
  7801. * @brief Helper macro to define ADC analog watchdog parameter:
  7802. * define a single channel to monitor with analog watchdog
  7803. * from sequencer channel and groups definition.
  7804. * @note To be used with function @ref LL_ADC_SetAnalogWDMonitChannels().
  7805. * Example:
  7806. * LL_ADC_SetAnalogWDMonitChannels(
  7807. * ADC1, LL_ADC_AWD1,
  7808. * __LL_ADC_ANALOGWD_CHANNEL_GROUP(LL_ADC_CHANNEL4, LL_ADC_GROUP_REGULAR))
  7809. * @param __CHANNEL__ This parameter can be one of the following values:
  7810. * @arg @ref LL_ADC_CHANNEL_0
  7811. * @arg @ref LL_ADC_CHANNEL_1
  7812. * @arg @ref LL_ADC_CHANNEL_2
  7813. * @arg @ref LL_ADC_CHANNEL_3
  7814. * @arg @ref LL_ADC_CHANNEL_4
  7815. * @arg @ref LL_ADC_CHANNEL_5
  7816. * @arg @ref LL_ADC_CHANNEL_6
  7817. * @arg @ref LL_ADC_CHANNEL_7
  7818. * @arg @ref LL_ADC_CHANNEL_8
  7819. * @arg @ref LL_ADC_CHANNEL_9
  7820. * @arg @ref LL_ADC_CHANNEL_10
  7821. * @arg @ref LL_ADC_CHANNEL_11
  7822. * @arg @ref LL_ADC_CHANNEL_12
  7823. * @arg @ref LL_ADC_CHANNEL_13
  7824. * @arg @ref LL_ADC_CHANNEL_14
  7825. * @arg @ref LL_ADC_CHANNEL_15
  7826. * @arg @ref LL_ADC_CHANNEL_16
  7827. * @arg @ref LL_ADC_CHANNEL_17
  7828. * @arg @ref LL_ADC_CHANNEL_VREFINT (1)
  7829. * @arg @ref LL_ADC_CHANNEL_TEMPSENSOR (1)
  7830. *
  7831. * (1) On STM32F37x, parameter available only on ADC instance: ADC1.\n
  7832. * (1) For ADC channel read back from ADC register,
  7833. * comparison with internal channel parameter to be done
  7834. * using helper macro @ref __LL_ADC_CHANNEL_INTERNAL_TO_EXTERNAL().
  7835. * @param __GROUP__ This parameter can be one of the following values:
  7836. * @arg @ref LL_ADC_GROUP_REGULAR
  7837. * @arg @ref LL_ADC_GROUP_INJECTED
  7838. * @arg @ref LL_ADC_GROUP_REGULAR_INJECTED
  7839. * @retval Returned value can be one of the following values:
  7840. * @arg @ref LL_ADC_AWD_DISABLE
  7841. * @arg @ref LL_ADC_AWD_ALL_CHANNELS_REG
  7842. * @arg @ref LL_ADC_AWD_ALL_CHANNELS_INJ
  7843. * @arg @ref LL_ADC_AWD_ALL_CHANNELS_REG_INJ
  7844. * @arg @ref LL_ADC_AWD_CHANNEL_0_REG
  7845. * @arg @ref LL_ADC_AWD_CHANNEL_0_INJ
  7846. * @arg @ref LL_ADC_AWD_CHANNEL_0_REG_INJ
  7847. * @arg @ref LL_ADC_AWD_CHANNEL_1_REG
  7848. * @arg @ref LL_ADC_AWD_CHANNEL_1_INJ
  7849. * @arg @ref LL_ADC_AWD_CHANNEL_1_REG_INJ
  7850. * @arg @ref LL_ADC_AWD_CHANNEL_2_REG
  7851. * @arg @ref LL_ADC_AWD_CHANNEL_2_INJ
  7852. * @arg @ref LL_ADC_AWD_CHANNEL_2_REG_INJ
  7853. * @arg @ref LL_ADC_AWD_CHANNEL_3_REG
  7854. * @arg @ref LL_ADC_AWD_CHANNEL_3_INJ
  7855. * @arg @ref LL_ADC_AWD_CHANNEL_3_REG_INJ
  7856. * @arg @ref LL_ADC_AWD_CHANNEL_4_REG
  7857. * @arg @ref LL_ADC_AWD_CHANNEL_4_INJ
  7858. * @arg @ref LL_ADC_AWD_CHANNEL_4_REG_INJ
  7859. * @arg @ref LL_ADC_AWD_CHANNEL_5_REG
  7860. * @arg @ref LL_ADC_AWD_CHANNEL_5_INJ
  7861. * @arg @ref LL_ADC_AWD_CHANNEL_5_REG_INJ
  7862. * @arg @ref LL_ADC_AWD_CHANNEL_6_REG
  7863. * @arg @ref LL_ADC_AWD_CHANNEL_6_INJ
  7864. * @arg @ref LL_ADC_AWD_CHANNEL_6_REG_INJ
  7865. * @arg @ref LL_ADC_AWD_CHANNEL_7_REG
  7866. * @arg @ref LL_ADC_AWD_CHANNEL_7_INJ
  7867. * @arg @ref LL_ADC_AWD_CHANNEL_7_REG_INJ
  7868. * @arg @ref LL_ADC_AWD_CHANNEL_8_REG
  7869. * @arg @ref LL_ADC_AWD_CHANNEL_8_INJ
  7870. * @arg @ref LL_ADC_AWD_CHANNEL_8_REG_INJ
  7871. * @arg @ref LL_ADC_AWD_CHANNEL_9_REG
  7872. * @arg @ref LL_ADC_AWD_CHANNEL_9_INJ
  7873. * @arg @ref LL_ADC_AWD_CHANNEL_9_REG_INJ
  7874. * @arg @ref LL_ADC_AWD_CHANNEL_10_REG
  7875. * @arg @ref LL_ADC_AWD_CHANNEL_10_INJ
  7876. * @arg @ref LL_ADC_AWD_CHANNEL_10_REG_INJ
  7877. * @arg @ref LL_ADC_AWD_CHANNEL_11_REG
  7878. * @arg @ref LL_ADC_AWD_CHANNEL_11_INJ
  7879. * @arg @ref LL_ADC_AWD_CHANNEL_11_REG_INJ
  7880. * @arg @ref LL_ADC_AWD_CHANNEL_12_REG
  7881. * @arg @ref LL_ADC_AWD_CHANNEL_12_INJ
  7882. * @arg @ref LL_ADC_AWD_CHANNEL_12_REG_INJ
  7883. * @arg @ref LL_ADC_AWD_CHANNEL_13_REG
  7884. * @arg @ref LL_ADC_AWD_CHANNEL_13_INJ
  7885. * @arg @ref LL_ADC_AWD_CHANNEL_13_REG_INJ
  7886. * @arg @ref LL_ADC_AWD_CHANNEL_14_REG
  7887. * @arg @ref LL_ADC_AWD_CHANNEL_14_INJ
  7888. * @arg @ref LL_ADC_AWD_CHANNEL_14_REG_INJ
  7889. * @arg @ref LL_ADC_AWD_CHANNEL_15_REG
  7890. * @arg @ref LL_ADC_AWD_CHANNEL_15_INJ
  7891. * @arg @ref LL_ADC_AWD_CHANNEL_15_REG_INJ
  7892. * @arg @ref LL_ADC_AWD_CHANNEL_16_REG
  7893. * @arg @ref LL_ADC_AWD_CHANNEL_16_INJ
  7894. * @arg @ref LL_ADC_AWD_CHANNEL_16_REG_INJ
  7895. * @arg @ref LL_ADC_AWD_CHANNEL_17_REG
  7896. * @arg @ref LL_ADC_AWD_CHANNEL_17_INJ
  7897. * @arg @ref LL_ADC_AWD_CHANNEL_17_REG_INJ
  7898. * @arg @ref LL_ADC_AWD_CH_VREFINT_REG (1)
  7899. * @arg @ref LL_ADC_AWD_CH_VREFINT_INJ (1)
  7900. * @arg @ref LL_ADC_AWD_CH_VREFINT_REG_INJ (1)
  7901. * @arg @ref LL_ADC_AWD_CH_TEMPSENSOR_REG (1)
  7902. * @arg @ref LL_ADC_AWD_CH_TEMPSENSOR_INJ (1)
  7903. * @arg @ref LL_ADC_AWD_CH_TEMPSENSOR_REG_INJ (1)
  7904. *
  7905. * (1) On STM32F37x, parameter available only on ADC instance: ADC1.
  7906. */
  7907. #define __LL_ADC_ANALOGWD_CHANNEL_GROUP(__CHANNEL__, __GROUP__) \
  7908. (((__GROUP__) == LL_ADC_GROUP_REGULAR) \
  7909. ? (((__CHANNEL__) & ADC_CHANNEL_ID_MASK) | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) \
  7910. : \
  7911. ((__GROUP__) == LL_ADC_GROUP_INJECTED) \
  7912. ? (((__CHANNEL__) & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDSGL) \
  7913. : \
  7914. (((__CHANNEL__) & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) \
  7915. )
  7916. /**
  7917. * @brief Helper macro to set the value of ADC analog watchdog threshold high
  7918. * or low in function of ADC resolution, when ADC resolution is
  7919. * different of 12 bits.
  7920. * @note To be used with function @ref LL_ADC_SetAnalogWDThresholds().
  7921. * Example, with a ADC resolution of 8 bits, to set the value of
  7922. * analog watchdog threshold high (on 8 bits):
  7923. * LL_ADC_SetAnalogWDThresholds
  7924. * (< ADCx param >,
  7925. * __LL_ADC_ANALOGWD_SET_THRESHOLD_RESOLUTION(LL_ADC_RESOLUTION_8B, <threshold_value_8_bits>)
  7926. * );
  7927. * @param __ADC_RESOLUTION__ This parameter can be one of the following values:
  7928. * @arg @ref LL_ADC_RESOLUTION_12B
  7929. * @param __AWD_THRESHOLD__ Value between Min_Data=0x000 and Max_Data=0xFFF
  7930. * @retval Value between Min_Data=0x000 and Max_Data=0xFFF
  7931. */
  7932. /* Note: On this STM32 serie, ADC is fixed to resolution 12 bits. */
  7933. /* This macro has been kept anyway for compatibility with other */
  7934. /* STM32 families featuring different ADC resolutions. */
  7935. #define __LL_ADC_ANALOGWD_SET_THRESHOLD_RESOLUTION(__ADC_RESOLUTION__, __AWD_THRESHOLD__) \
  7936. ((__AWD_THRESHOLD__) << (0U))
  7937. /**
  7938. * @brief Helper macro to get the value of ADC analog watchdog threshold high
  7939. * or low in function of ADC resolution, when ADC resolution is
  7940. * different of 12 bits.
  7941. * @note To be used with function @ref LL_ADC_GetAnalogWDThresholds().
  7942. * Example, with a ADC resolution of 8 bits, to get the value of
  7943. * analog watchdog threshold high (on 8 bits):
  7944. * < threshold_value_6_bits > = __LL_ADC_ANALOGWD_GET_THRESHOLD_RESOLUTION
  7945. * (LL_ADC_RESOLUTION_8B,
  7946. * LL_ADC_GetAnalogWDThresholds(<ADCx param>, LL_ADC_AWD_THRESHOLD_HIGH)
  7947. * );
  7948. * @param __ADC_RESOLUTION__ This parameter can be one of the following values:
  7949. * @arg @ref LL_ADC_RESOLUTION_12B
  7950. * @param __AWD_THRESHOLD_12_BITS__ Value between Min_Data=0x000 and Max_Data=0xFFF
  7951. * @retval Value between Min_Data=0x000 and Max_Data=0xFFF
  7952. */
  7953. /* Note: On this STM32 serie, ADC is fixed to resolution 12 bits. */
  7954. /* This macro has been kept anyway for compatibility with other */
  7955. /* STM32 families featuring different ADC resolutions. */
  7956. #define __LL_ADC_ANALOGWD_GET_THRESHOLD_RESOLUTION(__ADC_RESOLUTION__, __AWD_THRESHOLD_12_BITS__) \
  7957. (__AWD_THRESHOLD_12_BITS__)
  7958. /**
  7959. * @brief Helper macro to select the ADC common instance
  7960. * to which is belonging the selected ADC instance.
  7961. * @note ADC common register instance can be used for:
  7962. * - Set parameters common to several ADC instances
  7963. * - Multimode (for devices with several ADC instances)
  7964. * Refer to functions having argument "ADCxy_COMMON" as parameter.
  7965. * @note On STM32F37x, there is no common ADC instance.
  7966. * However, ADC instance ADC1 has a role of common ADC instance
  7967. * (equivalence with other STM32 families featuring several
  7968. * ADC instances).
  7969. * @param __ADCx__ ADC instance
  7970. * @retval ADC common register instance
  7971. */
  7972. #define __LL_ADC_COMMON_INSTANCE(__ADCx__) \
  7973. (ADC1_COMMON)
  7974. /**
  7975. * @brief Helper macro to check if all ADC instances sharing the same
  7976. * ADC common instance are disabled.
  7977. * @note This check is required by functions with setting conditioned to
  7978. * ADC state:
  7979. * All ADC instances of the ADC common group must be disabled.
  7980. * Refer to functions having argument "ADCxy_COMMON" as parameter.
  7981. * @note On devices with only 1 ADC common instance, parameter of this macro
  7982. * is useless and can be ignored (parameter kept for compatibility
  7983. * with devices featuring several ADC common instances).
  7984. * @note On STM32F37x, there is no common ADC instance.
  7985. * However, ADC instance ADC1 has a role of common ADC instance
  7986. * (equivalence with other STM32 families featuring several
  7987. * ADC instances).
  7988. * @param __ADCXY_COMMON__ ADC common instance
  7989. * (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() )
  7990. * @retval Value "0" All ADC instances sharing the same ADC common instance
  7991. * are disabled.
  7992. * Value "1" At least one ADC instance sharing the same ADC common instance
  7993. * is enabled
  7994. */
  7995. #define __LL_ADC_IS_ENABLED_ALL_COMMON_INSTANCE(__ADCXY_COMMON__) \
  7996. LL_ADC_IsEnabled(ADC1)
  7997. /**
  7998. * @brief Helper macro to define the ADC conversion data full-scale digital
  7999. * value corresponding to the selected ADC resolution.
  8000. * @note ADC conversion data full-scale corresponds to voltage range
  8001. * determined by analog voltage references Vref+ and Vref-
  8002. * (refer to reference manual).
  8003. * @param __ADC_RESOLUTION__ This parameter can be one of the following values:
  8004. * @arg @ref LL_ADC_RESOLUTION_12B
  8005. * @retval ADC conversion data equivalent voltage value (unit: mVolt)
  8006. */
  8007. #define __LL_ADC_DIGITAL_SCALE(__ADC_RESOLUTION__) \
  8008. ((uint32_t)0xFFFU)
  8009. /**
  8010. * @brief Helper macro to convert the ADC conversion data from
  8011. * a resolution to another resolution.
  8012. * @note On STM32F37x, the only ADC resolution available is 12 bits.
  8013. * This macro has been kept for compatibility purpose over other
  8014. * STM32 families.
  8015. * @param __DATA__ ADC conversion data to be converted
  8016. * @param __ADC_RESOLUTION_CURRENT__ Resolution of to the data to be converted
  8017. * This parameter can be one of the following values:
  8018. * @arg @ref LL_ADC_RESOLUTION_12B
  8019. * @param __ADC_RESOLUTION_TARGET__ Resolution of the data after conversion
  8020. * This parameter can be one of the following values:
  8021. * @arg @ref LL_ADC_RESOLUTION_12B
  8022. * @retval ADC conversion data to the requested resolution
  8023. */
  8024. #define __LL_ADC_CONVERT_DATA_RESOLUTION(__DATA__,\
  8025. __ADC_RESOLUTION_CURRENT__,\
  8026. __ADC_RESOLUTION_TARGET__) \
  8027. (((__DATA__) \
  8028. << ((__ADC_RESOLUTION_CURRENT__) >> (0U))) \
  8029. >> ((__ADC_RESOLUTION_TARGET__) >> (0U)) \
  8030. )
  8031. /**
  8032. * @brief Helper macro to calculate the voltage (unit: mVolt)
  8033. * corresponding to a ADC conversion data (unit: digital value).
  8034. * @note Analog reference voltage (Vref+) must be either known from
  8035. * user board environment or can be calculated using ADC measurement
  8036. * and ADC helper macro @ref __LL_ADC_CALC_VREFANALOG_VOLTAGE().
  8037. * @param __VREFANALOG_VOLTAGE__ Analog reference voltage (unit: mV)
  8038. * @param __ADC_DATA__ ADC conversion data (resolution 12 bits)
  8039. * (unit: digital value).
  8040. * @param __ADC_RESOLUTION__ This parameter can be one of the following values:
  8041. * @arg @ref LL_ADC_RESOLUTION_12B
  8042. * @retval ADC conversion data equivalent voltage value (unit: mVolt)
  8043. */
  8044. #define __LL_ADC_CALC_DATA_TO_VOLTAGE(__VREFANALOG_VOLTAGE__,\
  8045. __ADC_DATA__,\
  8046. __ADC_RESOLUTION__) \
  8047. ((__ADC_DATA__) * (__VREFANALOG_VOLTAGE__) \
  8048. / __LL_ADC_DIGITAL_SCALE(__ADC_RESOLUTION__) \
  8049. )
  8050. /**
  8051. * @brief Helper macro to calculate analog reference voltage (Vref+)
  8052. * (unit: mVolt) from ADC conversion data of internal voltage
  8053. * reference VrefInt.
  8054. * @note Computation is using VrefInt calibration value
  8055. * stored in system memory for each device during production.
  8056. * @note This voltage depends on user board environment: voltage level
  8057. * connected to pin Vref+.
  8058. * On devices with small package, the pin Vref+ is not present
  8059. * and internally bonded to pin Vdda.
  8060. * @note On this STM32 serie, calibration data of internal voltage reference
  8061. * VrefInt corresponds to a resolution of 12 bits,
  8062. * this is the recommended ADC resolution to convert voltage of
  8063. * internal voltage reference VrefInt.
  8064. * On STM32F37x, the only ADC resolution available is 12 bits.
  8065. * The parameter of ADC resolution is kept for compatibility purpose
  8066. * over other STM32 families.
  8067. * @param __VREFINT_ADC_DATA__ ADC conversion data (resolution 12 bits)
  8068. * of internal voltage reference VrefInt (unit: digital value).
  8069. * @param __ADC_RESOLUTION__ This parameter can be one of the following values:
  8070. * @arg @ref LL_ADC_RESOLUTION_12B
  8071. * @retval Analog reference voltage (unit: mV)
  8072. */
  8073. #define __LL_ADC_CALC_VREFANALOG_VOLTAGE(__VREFINT_ADC_DATA__,\
  8074. __ADC_RESOLUTION__) \
  8075. (((uint32_t)(*VREFINT_CAL_ADDR) * VREFINT_CAL_VREF) \
  8076. / __LL_ADC_CONVERT_DATA_RESOLUTION((__VREFINT_ADC_DATA__), \
  8077. (__ADC_RESOLUTION__), \
  8078. LL_ADC_RESOLUTION_12B) \
  8079. )
  8080. /**
  8081. * @brief Helper macro to calculate the temperature (unit: degree Celsius)
  8082. * from ADC conversion data of internal temperature sensor.
  8083. * @note Computation is using temperature sensor calibration values
  8084. * stored in system memory for each device during production.
  8085. * @note Calculation formula:
  8086. * Temperature = ((TS_ADC_DATA - TS_CAL1)
  8087. * * (TS_CAL2_TEMP - TS_CAL1_TEMP))
  8088. * / (TS_CAL2 - TS_CAL1) + TS_CAL1_TEMP
  8089. * with TS_ADC_DATA = temperature sensor raw data measured by ADC
  8090. * Avg_Slope = (TS_CAL2 - TS_CAL1)
  8091. * / (TS_CAL2_TEMP - TS_CAL1_TEMP)
  8092. * TS_CAL1 = equivalent TS_ADC_DATA at temperature
  8093. * TEMP_DEGC_CAL1 (calibrated in factory)
  8094. * TS_CAL2 = equivalent TS_ADC_DATA at temperature
  8095. * TEMP_DEGC_CAL2 (calibrated in factory)
  8096. * Caution: Calculation relevancy under reserve that calibration
  8097. * parameters are correct (address and data).
  8098. * To calculate temperature using temperature sensor
  8099. * datasheet typical values (generic values less, therefore
  8100. * less accurate than calibrated values),
  8101. * use helper macro @ref __LL_ADC_CALC_TEMPERATURE_TYP_PARAMS().
  8102. * @note As calculation input, the analog reference voltage (Vref+) must be
  8103. * defined as it impacts the ADC LSB equivalent voltage.
  8104. * @note Analog reference voltage (Vref+) must be either known from
  8105. * user board environment or can be calculated using ADC measurement
  8106. * and ADC helper macro @ref __LL_ADC_CALC_VREFANALOG_VOLTAGE().
  8107. * @note On this STM32 serie, calibration data of temperature sensor
  8108. * corresponds to a resolution of 12 bits,
  8109. * this is the recommended ADC resolution to convert voltage of
  8110. * temperature sensor.
  8111. * On STM32F37x, the only ADC resolution available is 12 bits.
  8112. * The parameter of ADC resolution is kept for compatibility purpose
  8113. * over other STM32 families.
  8114. * @param __VREFANALOG_VOLTAGE__ Analog reference voltage (unit: mV)
  8115. * @param __TEMPSENSOR_ADC_DATA__ ADC conversion data of internal
  8116. * temperature sensor (unit: digital value).
  8117. * @param __ADC_RESOLUTION__ ADC resolution at which internal temperature
  8118. * sensor voltage has been measured.
  8119. * This parameter can be one of the following values:
  8120. * @arg @ref LL_ADC_RESOLUTION_12B
  8121. * @retval Temperature (unit: degree Celsius)
  8122. */
  8123. #define __LL_ADC_CALC_TEMPERATURE(__VREFANALOG_VOLTAGE__,\
  8124. __TEMPSENSOR_ADC_DATA__,\
  8125. __ADC_RESOLUTION__) \
  8126. (((( ((int32_t)((__LL_ADC_CONVERT_DATA_RESOLUTION((__TEMPSENSOR_ADC_DATA__), \
  8127. (__ADC_RESOLUTION__), \
  8128. LL_ADC_RESOLUTION_12B) \
  8129. * (__VREFANALOG_VOLTAGE__)) \
  8130. / TEMPSENSOR_CAL_VREFANALOG) \
  8131. - (int32_t) *TEMPSENSOR_CAL1_ADDR) \
  8132. ) * (int32_t)(TEMPSENSOR_CAL2_TEMP - TEMPSENSOR_CAL1_TEMP) \
  8133. ) / (int32_t)((int32_t)*TEMPSENSOR_CAL2_ADDR - (int32_t)*TEMPSENSOR_CAL1_ADDR) \
  8134. ) + TEMPSENSOR_CAL1_TEMP \
  8135. )
  8136. /**
  8137. * @brief Helper macro to calculate the temperature (unit: degree Celsius)
  8138. * from ADC conversion data of internal temperature sensor.
  8139. * @note Computation is using temperature sensor typical values
  8140. * (refer to device datasheet).
  8141. * @note Calculation formula:
  8142. * Temperature = (TS_TYP_CALx_VOLT(uV) - TS_ADC_DATA * Conversion_uV)
  8143. * / Avg_Slope + CALx_TEMP
  8144. * with TS_ADC_DATA = temperature sensor raw data measured by ADC
  8145. * (unit: digital value)
  8146. * Avg_Slope = temperature sensor slope
  8147. * (unit: uV/Degree Celsius)
  8148. * TS_TYP_CALx_VOLT = temperature sensor digital value at
  8149. * temperature CALx_TEMP (unit: mV)
  8150. * Caution: Calculation relevancy under reserve the temperature sensor
  8151. * of the current device has characteristics in line with
  8152. * datasheet typical values.
  8153. * If temperature sensor calibration values are available on
  8154. * on this device (presence of macro __LL_ADC_CALC_TEMPERATURE()),
  8155. * temperature calculation will be more accurate using
  8156. * helper macro @ref __LL_ADC_CALC_TEMPERATURE().
  8157. * @note As calculation input, the analog reference voltage (Vref+) must be
  8158. * defined as it impacts the ADC LSB equivalent voltage.
  8159. * @note Analog reference voltage (Vref+) must be either known from
  8160. * user board environment or can be calculated using ADC measurement
  8161. * and ADC helper macro @ref __LL_ADC_CALC_VREFANALOG_VOLTAGE().
  8162. * @note ADC measurement data must correspond to a resolution of 12bits
  8163. * (full scale digital value 4095). If not the case, the data must be
  8164. * preliminarily rescaled to an equivalent resolution of 12 bits.
  8165. * @param __TEMPSENSOR_TYP_AVGSLOPE__ Device datasheet data: Temperature sensor slope typical value (unit: uV/DegCelsius).
  8166. * On STM32F37x, refer to device datasheet parameter "Avg_Slope".
  8167. * @param __TEMPSENSOR_TYP_CALX_V__ Device datasheet data: Temperature sensor voltage typical value (at temperature and Vref+ defined in parameters below) (unit: mV).
  8168. * On STM32F37x, refer to device datasheet parameter "V25".
  8169. * @param __TEMPSENSOR_CALX_TEMP__ Device datasheet data: Temperature at which temperature sensor voltage (see parameter above) is corresponding (unit: mV)
  8170. * @param __VREFANALOG_VOLTAGE__ Analog voltage reference (Vref+) voltage (unit: mV)
  8171. * @param __TEMPSENSOR_ADC_DATA__ ADC conversion data of internal temperature sensor (unit: digital value).
  8172. * @param __ADC_RESOLUTION__ ADC resolution at which internal temperature sensor voltage has been measured.
  8173. * This parameter can be one of the following values:
  8174. * @arg @ref LL_ADC_RESOLUTION_12B
  8175. * @retval Temperature (unit: degree Celsius)
  8176. */
  8177. #define __LL_ADC_CALC_TEMPERATURE_TYP_PARAMS(__TEMPSENSOR_TYP_AVGSLOPE__,\
  8178. __TEMPSENSOR_TYP_CALX_V__,\
  8179. __TEMPSENSOR_CALX_TEMP__,\
  8180. __VREFANALOG_VOLTAGE__,\
  8181. __TEMPSENSOR_ADC_DATA__,\
  8182. __ADC_RESOLUTION__) \
  8183. ((( ( \
  8184. (int32_t)(((__TEMPSENSOR_TYP_CALX_V__)) \
  8185. * 1000) \
  8186. - \
  8187. (int32_t)((((__TEMPSENSOR_ADC_DATA__) * (__VREFANALOG_VOLTAGE__)) \
  8188. / __LL_ADC_DIGITAL_SCALE(__ADC_RESOLUTION__)) \
  8189. * 1000) \
  8190. ) \
  8191. ) / (__TEMPSENSOR_TYP_AVGSLOPE__) \
  8192. ) + (__TEMPSENSOR_CALX_TEMP__) \
  8193. )
  8194. /**
  8195. * @}
  8196. */
  8197. /**
  8198. * @}
  8199. */
  8200. /* Exported functions --------------------------------------------------------*/
  8201. /** @defgroup ADC_LL_Exported_Functions ADC Exported Functions
  8202. * @{
  8203. */
  8204. /** @defgroup ADC_LL_EF_DMA_Management ADC DMA management
  8205. * @{
  8206. */
  8207. /* Note: LL ADC functions to set DMA transfer are located into sections of */
  8208. /* configuration of ADC instance, groups and multimode (if available): */
  8209. /* @ref LL_ADC_REG_SetDMATransfer(), ... */
  8210. /**
  8211. * @brief Function to help to configure DMA transfer from ADC: retrieve the
  8212. * ADC register address from ADC instance and a list of ADC registers
  8213. * intended to be used (most commonly) with DMA transfer.
  8214. * @note These ADC registers are data registers:
  8215. * when ADC conversion data is available in ADC data registers,
  8216. * ADC generates a DMA transfer request.
  8217. * @note This macro is intended to be used with LL DMA driver, refer to
  8218. * function "LL_DMA_ConfigAddresses()".
  8219. * Example:
  8220. * LL_DMA_ConfigAddresses(DMA1,
  8221. * LL_DMA_CHANNEL_1,
  8222. * LL_ADC_DMA_GetRegAddr(ADC1, LL_ADC_DMA_REG_REGULAR_DATA),
  8223. * (uint32_t)&< array or variable >,
  8224. * LL_DMA_DIRECTION_PERIPH_TO_MEMORY);
  8225. * @note For devices with several ADC: in multimode, some devices
  8226. * use a different data register outside of ADC instance scope
  8227. * (common data register). This macro manages this register difference,
  8228. * only ADC instance has to be set as parameter.
  8229. * @rmtoll DR DATA LL_ADC_DMA_GetRegAddr
  8230. * @param ADCx ADC instance
  8231. * @param Register This parameter can be one of the following values:
  8232. * @arg @ref LL_ADC_DMA_REG_REGULAR_DATA
  8233. * @retval ADC register address
  8234. */
  8235. __STATIC_INLINE uint32_t LL_ADC_DMA_GetRegAddr(ADC_TypeDef *ADCx, uint32_t Register)
  8236. {
  8237. /* Retrieve address of register DR */
  8238. return (uint32_t)&(ADCx->DR);
  8239. }
  8240. /**
  8241. * @}
  8242. */
  8243. /** @defgroup ADC_LL_EF_Configuration_ADC_Common Configuration of ADC hierarchical scope: common to several ADC instances
  8244. * @{
  8245. */
  8246. /**
  8247. * @brief Set parameter common to several ADC: measurement path to internal
  8248. * channels (VrefInt, temperature sensor, ...).
  8249. * @note One or several values can be selected.
  8250. * Example: (LL_ADC_PATH_INTERNAL_VREFINT |
  8251. * LL_ADC_PATH_INTERNAL_TEMPSENSOR)
  8252. * @note Stabilization time of measurement path to internal channel:
  8253. * After enabling internal paths, before starting ADC conversion,
  8254. * a delay is required for internal voltage reference and
  8255. * temperature sensor stabilization time.
  8256. * Refer to device datasheet.
  8257. * Refer to literal @ref LL_ADC_DELAY_TEMPSENSOR_STAB_US.
  8258. * @note ADC internal channel sampling time constraint:
  8259. * For ADC conversion of internal channels,
  8260. * a sampling time minimum value is required.
  8261. * Refer to device datasheet.
  8262. * @rmtoll CR2 TSVREFE LL_ADC_SetCommonPathInternalCh
  8263. * @param ADCxy_COMMON ADC common instance
  8264. * (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() )
  8265. * @param PathInternal This parameter can be a combination of the following values:
  8266. * @arg @ref LL_ADC_PATH_INTERNAL_NONE
  8267. * @arg @ref LL_ADC_PATH_INTERNAL_VREFINT
  8268. * @arg @ref LL_ADC_PATH_INTERNAL_TEMPSENSOR
  8269. * @retval None
  8270. */
  8271. __STATIC_INLINE void LL_ADC_SetCommonPathInternalCh(ADC_Common_TypeDef *ADCxy_COMMON, uint32_t PathInternal)
  8272. {
  8273. MODIFY_REG(ADCxy_COMMON->CR2, (ADC_CR2_TSVREFE), PathInternal);
  8274. }
  8275. /**
  8276. * @brief Get parameter common to several ADC: measurement path to internal
  8277. * channels (VrefInt, temperature sensor, ...).
  8278. * @note One or several values can be selected.
  8279. * Example: (LL_ADC_PATH_INTERNAL_VREFINT |
  8280. * LL_ADC_PATH_INTERNAL_TEMPSENSOR)
  8281. * @rmtoll CR2 TSVREFE LL_ADC_GetCommonPathInternalCh
  8282. * @param ADCxy_COMMON ADC common instance
  8283. * (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() )
  8284. * @retval Returned value can be a combination of the following values:
  8285. * @arg @ref LL_ADC_PATH_INTERNAL_NONE
  8286. * @arg @ref LL_ADC_PATH_INTERNAL_VREFINT
  8287. * @arg @ref LL_ADC_PATH_INTERNAL_TEMPSENSOR
  8288. */
  8289. __STATIC_INLINE uint32_t LL_ADC_GetCommonPathInternalCh(ADC_Common_TypeDef *ADCxy_COMMON)
  8290. {
  8291. return (uint32_t)(READ_BIT(ADCxy_COMMON->CR2, ADC_CR2_TSVREFE));
  8292. }
  8293. /**
  8294. * @}
  8295. */
  8296. /** @defgroup ADC_LL_EF_Configuration_ADC_Instance Configuration of ADC hierarchical scope: ADC instance
  8297. * @{
  8298. */
  8299. /**
  8300. * @brief Set ADC conversion data alignment.
  8301. * @note Refer to reference manual for alignments formats
  8302. * dependencies to ADC resolutions.
  8303. * @rmtoll CR2 ALIGN LL_ADC_SetDataAlignment
  8304. * @param ADCx ADC instance
  8305. * @param DataAlignment This parameter can be one of the following values:
  8306. * @arg @ref LL_ADC_DATA_ALIGN_RIGHT
  8307. * @arg @ref LL_ADC_DATA_ALIGN_LEFT
  8308. * @retval None
  8309. */
  8310. __STATIC_INLINE void LL_ADC_SetDataAlignment(ADC_TypeDef *ADCx, uint32_t DataAlignment)
  8311. {
  8312. MODIFY_REG(ADCx->CR2, ADC_CR2_ALIGN, DataAlignment);
  8313. }
  8314. /**
  8315. * @brief Get ADC conversion data alignment.
  8316. * @note Refer to reference manual for alignments formats
  8317. * dependencies to ADC resolutions.
  8318. * @rmtoll CR2 ALIGN LL_ADC_SetDataAlignment
  8319. * @param ADCx ADC instance
  8320. * @retval Returned value can be one of the following values:
  8321. * @arg @ref LL_ADC_DATA_ALIGN_RIGHT
  8322. * @arg @ref LL_ADC_DATA_ALIGN_LEFT
  8323. */
  8324. __STATIC_INLINE uint32_t LL_ADC_GetDataAlignment(ADC_TypeDef *ADCx)
  8325. {
  8326. return (uint32_t)(READ_BIT(ADCx->CR2, ADC_CR2_ALIGN));
  8327. }
  8328. /**
  8329. * @brief Set ADC sequencers scan mode, for all ADC groups
  8330. * (group regular, group injected).
  8331. * @note According to sequencers scan mode :
  8332. * - If disabled: ADC conversion is performed in unitary conversion
  8333. * mode (one channel converted, that defined in rank 1).
  8334. * Configuration of sequencers of all ADC groups
  8335. * (sequencer scan length, ...) is discarded: equivalent to
  8336. * scan length of 1 rank.
  8337. * - If enabled: ADC conversions are performed in sequence conversions
  8338. * mode, according to configuration of sequencers of
  8339. * each ADC group (sequencer scan length, ...).
  8340. * Refer to function @ref LL_ADC_REG_SetSequencerLength()
  8341. * and to function @ref LL_ADC_INJ_SetSequencerLength().
  8342. * @rmtoll CR1 SCAN LL_ADC_SetSequencersScanMode
  8343. * @param ADCx ADC instance
  8344. * @param ScanMode This parameter can be one of the following values:
  8345. * @arg @ref LL_ADC_SEQ_SCAN_DISABLE
  8346. * @arg @ref LL_ADC_SEQ_SCAN_ENABLE
  8347. * @retval None
  8348. */
  8349. __STATIC_INLINE void LL_ADC_SetSequencersScanMode(ADC_TypeDef *ADCx, uint32_t ScanMode)
  8350. {
  8351. MODIFY_REG(ADCx->CR1, ADC_CR1_SCAN, ScanMode);
  8352. }
  8353. /**
  8354. * @brief Get ADC sequencers scan mode, for all ADC groups
  8355. * (group regular, group injected).
  8356. * @note According to sequencers scan mode :
  8357. * - If disabled: ADC conversion is performed in unitary conversion
  8358. * mode (one channel converted, that defined in rank 1).
  8359. * Configuration of sequencers of all ADC groups
  8360. * (sequencer scan length, ...) is discarded: equivalent to
  8361. * scan length of 1 rank.
  8362. * - If enabled: ADC conversions are performed in sequence conversions
  8363. * mode, according to configuration of sequencers of
  8364. * each ADC group (sequencer scan length, ...).
  8365. * Refer to function @ref LL_ADC_REG_SetSequencerLength()
  8366. * and to function @ref LL_ADC_INJ_SetSequencerLength().
  8367. * @rmtoll CR1 SCAN LL_ADC_GetSequencersScanMode
  8368. * @param ADCx ADC instance
  8369. * @retval Returned value can be one of the following values:
  8370. * @arg @ref LL_ADC_SEQ_SCAN_DISABLE
  8371. * @arg @ref LL_ADC_SEQ_SCAN_ENABLE
  8372. */
  8373. __STATIC_INLINE uint32_t LL_ADC_GetSequencersScanMode(ADC_TypeDef *ADCx)
  8374. {
  8375. return (uint32_t)(READ_BIT(ADCx->CR1, ADC_CR1_SCAN));
  8376. }
  8377. /**
  8378. * @}
  8379. */
  8380. /** @defgroup ADC_LL_EF_Configuration_ADC_Group_Regular Configuration of ADC hierarchical scope: group regular
  8381. * @{
  8382. */
  8383. /**
  8384. * @brief Set ADC group regular conversion trigger source:
  8385. * internal (SW start) or external from timer or external interrupt.
  8386. * @note On this STM32 serie, external trigger is set with trigger polarity:
  8387. * rising edge (only trigger polarity available on this STM32 serie).
  8388. * @note Availability of parameters of trigger sources from timer
  8389. * depends on timers availability on the selected device.
  8390. * @rmtoll CR2 EXTSEL LL_ADC_REG_SetTriggerSource
  8391. * @param ADCx ADC instance
  8392. * @param TriggerSource This parameter can be one of the following values:
  8393. * @arg @ref LL_ADC_REG_TRIG_SOFTWARE
  8394. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM2_CH2
  8395. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM3_TRGO
  8396. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM4_CH2
  8397. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM19_TRGO
  8398. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM19_CH3
  8399. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM19_CH4
  8400. * @arg @ref LL_ADC_REG_TRIG_EXT_EXTI_LINE11
  8401. * @retval None
  8402. */
  8403. __STATIC_INLINE void LL_ADC_REG_SetTriggerSource(ADC_TypeDef *ADCx, uint32_t TriggerSource)
  8404. {
  8405. /* Note: On this STM32 serie, ADC group regular external trigger edge */
  8406. /* is used to perform a ADC conversion start. */
  8407. /* This function does not set external trigger edge. */
  8408. /* This feature is set using function */
  8409. /* @ref LL_ADC_REG_StartConversionExtTrig(). */
  8410. MODIFY_REG(ADCx->CR2, ADC_CR2_EXTSEL, (TriggerSource & ADC_CR2_EXTSEL));
  8411. }
  8412. /**
  8413. * @brief Get ADC group regular conversion trigger source:
  8414. * internal (SW start) or external from timer or external interrupt.
  8415. * @note To determine whether group regular trigger source is
  8416. * internal (SW start) or external, without detail
  8417. * of which peripheral is selected as external trigger,
  8418. * (equivalent to
  8419. * "if(LL_ADC_REG_GetTriggerSource(ADC1) == LL_ADC_REG_TRIG_SOFTWARE)")
  8420. * use function @ref LL_ADC_REG_IsTriggerSourceSWStart.
  8421. * @note Availability of parameters of trigger sources from timer
  8422. * depends on timers availability on the selected device.
  8423. * @rmtoll CR2 EXTSEL LL_ADC_REG_GetTriggerSource
  8424. * @param ADCx ADC instance
  8425. * @retval Returned value can be one of the following values:
  8426. * @arg @ref LL_ADC_REG_TRIG_SOFTWARE
  8427. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM2_CH2
  8428. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM3_TRGO
  8429. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM4_CH2
  8430. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM19_TRGO
  8431. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM19_CH3
  8432. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM19_CH4
  8433. * @arg @ref LL_ADC_REG_TRIG_EXT_EXTI_LINE11
  8434. */
  8435. __STATIC_INLINE uint32_t LL_ADC_REG_GetTriggerSource(ADC_TypeDef *ADCx)
  8436. {
  8437. return (uint32_t)(READ_BIT(ADCx->CR2, ADC_CR2_EXTSEL));
  8438. }
  8439. /**
  8440. * @brief Get ADC group regular conversion trigger source internal (SW start)
  8441. or external.
  8442. * @note In case of group regular trigger source set to external trigger,
  8443. * to determine which peripheral is selected as external trigger,
  8444. * use function @ref LL_ADC_REG_GetTriggerSource().
  8445. * @rmtoll CR2 EXTSEL LL_ADC_REG_IsTriggerSourceSWStart
  8446. * @param ADCx ADC instance
  8447. * @retval Value "0" trigger source external trigger
  8448. * Value "1" trigger source SW start.
  8449. */
  8450. __STATIC_INLINE uint32_t LL_ADC_REG_IsTriggerSourceSWStart(ADC_TypeDef *ADCx)
  8451. {
  8452. return (READ_BIT(ADCx->CR2, ADC_CR2_EXTSEL) == (LL_ADC_REG_TRIG_SOFTWARE));
  8453. }
  8454. /**
  8455. * @brief Set ADC group regular sequencer length and scan direction.
  8456. * @note Description of ADC group regular sequencer features:
  8457. * - For devices with sequencer fully configurable
  8458. * (function "LL_ADC_REG_SetSequencerRanks()" available):
  8459. * sequencer length and each rank affectation to a channel
  8460. * are configurable.
  8461. * This function performs configuration of:
  8462. * - Sequence length: Number of ranks in the scan sequence.
  8463. * - Sequence direction: Unless specified in parameters, sequencer
  8464. * scan direction is forward (from rank 1 to rank n).
  8465. * Sequencer ranks are selected using
  8466. * function "LL_ADC_REG_SetSequencerRanks()".
  8467. * - For devices with sequencer not fully configurable
  8468. * (function "LL_ADC_REG_SetSequencerChannels()" available):
  8469. * sequencer length and each rank affectation to a channel
  8470. * are defined by channel number.
  8471. * This function performs configuration of:
  8472. * - Sequence length: Number of ranks in the scan sequence is
  8473. * defined by number of channels set in the sequence,
  8474. * rank of each channel is fixed by channel HW number.
  8475. * (channel 0 fixed on rank 0, channel 1 fixed on rank1, ...).
  8476. * - Sequence direction: Unless specified in parameters, sequencer
  8477. * scan direction is forward (from lowest channel number to
  8478. * highest channel number).
  8479. * Sequencer ranks are selected using
  8480. * function "LL_ADC_REG_SetSequencerChannels()".
  8481. * @note On this STM32 serie, group regular sequencer configuration
  8482. * is conditioned to ADC instance sequencer mode.
  8483. * If ADC instance sequencer mode is disabled, sequencers of
  8484. * all groups (group regular, group injected) can be configured
  8485. * but their execution is disabled (limited to rank 1).
  8486. * Refer to function @ref LL_ADC_SetSequencersScanMode().
  8487. * @note Sequencer disabled is equivalent to sequencer of 1 rank:
  8488. * ADC conversion on only 1 channel.
  8489. * @rmtoll SQR1 L LL_ADC_REG_SetSequencerLength
  8490. * @param ADCx ADC instance
  8491. * @param SequencerNbRanks This parameter can be one of the following values:
  8492. * @arg @ref LL_ADC_REG_SEQ_SCAN_DISABLE
  8493. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_2RANKS
  8494. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_3RANKS
  8495. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_4RANKS
  8496. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_5RANKS
  8497. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_6RANKS
  8498. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_7RANKS
  8499. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_8RANKS
  8500. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_9RANKS
  8501. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_10RANKS
  8502. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_11RANKS
  8503. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_12RANKS
  8504. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_13RANKS
  8505. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_14RANKS
  8506. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_15RANKS
  8507. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_16RANKS
  8508. * @retval None
  8509. */
  8510. __STATIC_INLINE void LL_ADC_REG_SetSequencerLength(ADC_TypeDef *ADCx, uint32_t SequencerNbRanks)
  8511. {
  8512. MODIFY_REG(ADCx->SQR1, ADC_SQR1_L, SequencerNbRanks);
  8513. }
  8514. /**
  8515. * @brief Get ADC group regular sequencer length and scan direction.
  8516. * @note Description of ADC group regular sequencer features:
  8517. * - For devices with sequencer fully configurable
  8518. * (function "LL_ADC_REG_SetSequencerRanks()" available):
  8519. * sequencer length and each rank affectation to a channel
  8520. * are configurable.
  8521. * This function retrieves:
  8522. * - Sequence length: Number of ranks in the scan sequence.
  8523. * - Sequence direction: Unless specified in parameters, sequencer
  8524. * scan direction is forward (from rank 1 to rank n).
  8525. * Sequencer ranks are selected using
  8526. * function "LL_ADC_REG_SetSequencerRanks()".
  8527. * - For devices with sequencer not fully configurable
  8528. * (function "LL_ADC_REG_SetSequencerChannels()" available):
  8529. * sequencer length and each rank affectation to a channel
  8530. * are defined by channel number.
  8531. * This function retrieves:
  8532. * - Sequence length: Number of ranks in the scan sequence is
  8533. * defined by number of channels set in the sequence,
  8534. * rank of each channel is fixed by channel HW number.
  8535. * (channel 0 fixed on rank 0, channel 1 fixed on rank1, ...).
  8536. * - Sequence direction: Unless specified in parameters, sequencer
  8537. * scan direction is forward (from lowest channel number to
  8538. * highest channel number).
  8539. * Sequencer ranks are selected using
  8540. * function "LL_ADC_REG_SetSequencerChannels()".
  8541. * @note On this STM32 serie, group regular sequencer configuration
  8542. * is conditioned to ADC instance sequencer mode.
  8543. * If ADC instance sequencer mode is disabled, sequencers of
  8544. * all groups (group regular, group injected) can be configured
  8545. * but their execution is disabled (limited to rank 1).
  8546. * Refer to function @ref LL_ADC_SetSequencersScanMode().
  8547. * @note Sequencer disabled is equivalent to sequencer of 1 rank:
  8548. * ADC conversion on only 1 channel.
  8549. * @rmtoll SQR1 L LL_ADC_REG_SetSequencerLength
  8550. * @param ADCx ADC instance
  8551. * @retval Returned value can be one of the following values:
  8552. * @arg @ref LL_ADC_REG_SEQ_SCAN_DISABLE
  8553. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_2RANKS
  8554. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_3RANKS
  8555. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_4RANKS
  8556. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_5RANKS
  8557. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_6RANKS
  8558. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_7RANKS
  8559. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_8RANKS
  8560. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_9RANKS
  8561. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_10RANKS
  8562. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_11RANKS
  8563. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_12RANKS
  8564. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_13RANKS
  8565. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_14RANKS
  8566. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_15RANKS
  8567. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_16RANKS
  8568. */
  8569. __STATIC_INLINE uint32_t LL_ADC_REG_GetSequencerLength(ADC_TypeDef *ADCx)
  8570. {
  8571. return (uint32_t)(READ_BIT(ADCx->SQR1, ADC_SQR1_L));
  8572. }
  8573. /**
  8574. * @brief Set ADC group regular sequencer discontinuous mode:
  8575. * sequence subdivided and scan conversions interrupted every selected
  8576. * number of ranks.
  8577. * @note It is not possible to enable both ADC group regular
  8578. * continuous mode and sequencer discontinuous mode.
  8579. * @note It is not possible to enable both ADC auto-injected mode
  8580. * and ADC group regular sequencer discontinuous mode.
  8581. * @rmtoll CR1 DISCEN LL_ADC_REG_SetSequencerDiscont\n
  8582. * CR1 DISCNUM LL_ADC_REG_SetSequencerDiscont
  8583. * @param ADCx ADC instance
  8584. * @param SeqDiscont This parameter can be one of the following values:
  8585. * @arg @ref LL_ADC_REG_SEQ_DISCONT_DISABLE
  8586. * @arg @ref LL_ADC_REG_SEQ_DISCONT_1RANK
  8587. * @arg @ref LL_ADC_REG_SEQ_DISCONT_2RANKS
  8588. * @arg @ref LL_ADC_REG_SEQ_DISCONT_3RANKS
  8589. * @arg @ref LL_ADC_REG_SEQ_DISCONT_4RANKS
  8590. * @arg @ref LL_ADC_REG_SEQ_DISCONT_5RANKS
  8591. * @arg @ref LL_ADC_REG_SEQ_DISCONT_6RANKS
  8592. * @arg @ref LL_ADC_REG_SEQ_DISCONT_7RANKS
  8593. * @arg @ref LL_ADC_REG_SEQ_DISCONT_8RANKS
  8594. * @retval None
  8595. */
  8596. __STATIC_INLINE void LL_ADC_REG_SetSequencerDiscont(ADC_TypeDef *ADCx, uint32_t SeqDiscont)
  8597. {
  8598. MODIFY_REG(ADCx->CR1, ADC_CR1_DISCEN | ADC_CR1_DISCNUM, SeqDiscont);
  8599. }
  8600. /**
  8601. * @brief Get ADC group regular sequencer discontinuous mode:
  8602. * sequence subdivided and scan conversions interrupted every selected
  8603. * number of ranks.
  8604. * @rmtoll CR1 DISCEN LL_ADC_REG_GetSequencerDiscont\n
  8605. * CR1 DISCNUM LL_ADC_REG_GetSequencerDiscont
  8606. * @param ADCx ADC instance
  8607. * @retval Returned value can be one of the following values:
  8608. * @arg @ref LL_ADC_REG_SEQ_DISCONT_DISABLE
  8609. * @arg @ref LL_ADC_REG_SEQ_DISCONT_1RANK
  8610. * @arg @ref LL_ADC_REG_SEQ_DISCONT_2RANKS
  8611. * @arg @ref LL_ADC_REG_SEQ_DISCONT_3RANKS
  8612. * @arg @ref LL_ADC_REG_SEQ_DISCONT_4RANKS
  8613. * @arg @ref LL_ADC_REG_SEQ_DISCONT_5RANKS
  8614. * @arg @ref LL_ADC_REG_SEQ_DISCONT_6RANKS
  8615. * @arg @ref LL_ADC_REG_SEQ_DISCONT_7RANKS
  8616. * @arg @ref LL_ADC_REG_SEQ_DISCONT_8RANKS
  8617. */
  8618. __STATIC_INLINE uint32_t LL_ADC_REG_GetSequencerDiscont(ADC_TypeDef *ADCx)
  8619. {
  8620. return (uint32_t)(READ_BIT(ADCx->CR1, ADC_CR1_DISCEN | ADC_CR1_DISCNUM));
  8621. }
  8622. /**
  8623. * @brief Set ADC group regular sequence: channel on the selected
  8624. * scan sequence rank.
  8625. * @note This function performs configuration of:
  8626. * - Channels ordering into each rank of scan sequence:
  8627. * whatever channel can be placed into whatever rank.
  8628. * @note On this STM32 serie, ADC group regular sequencer is
  8629. * fully configurable: sequencer length and each rank
  8630. * affectation to a channel are configurable.
  8631. * Refer to description of function @ref LL_ADC_REG_SetSequencerLength().
  8632. * @note Depending on devices and packages, some channels may not be available.
  8633. * Refer to device datasheet for channels availability.
  8634. * @note On this STM32 serie, to measure internal channels (VrefInt,
  8635. * TempSensor, ...), measurement paths to internal channels must be
  8636. * enabled separately.
  8637. * This can be done using function @ref LL_ADC_SetCommonPathInternalCh().
  8638. * @rmtoll SQR3 SQ1 LL_ADC_REG_SetSequencerRanks\n
  8639. * SQR3 SQ2 LL_ADC_REG_SetSequencerRanks\n
  8640. * SQR3 SQ3 LL_ADC_REG_SetSequencerRanks\n
  8641. * SQR3 SQ4 LL_ADC_REG_SetSequencerRanks\n
  8642. * SQR3 SQ5 LL_ADC_REG_SetSequencerRanks\n
  8643. * SQR3 SQ6 LL_ADC_REG_SetSequencerRanks\n
  8644. * SQR2 SQ7 LL_ADC_REG_SetSequencerRanks\n
  8645. * SQR2 SQ8 LL_ADC_REG_SetSequencerRanks\n
  8646. * SQR2 SQ9 LL_ADC_REG_SetSequencerRanks\n
  8647. * SQR2 SQ10 LL_ADC_REG_SetSequencerRanks\n
  8648. * SQR2 SQ11 LL_ADC_REG_SetSequencerRanks\n
  8649. * SQR2 SQ12 LL_ADC_REG_SetSequencerRanks\n
  8650. * SQR1 SQ13 LL_ADC_REG_SetSequencerRanks\n
  8651. * SQR1 SQ14 LL_ADC_REG_SetSequencerRanks\n
  8652. * SQR1 SQ15 LL_ADC_REG_SetSequencerRanks\n
  8653. * SQR1 SQ16 LL_ADC_REG_SetSequencerRanks
  8654. * @param ADCx ADC instance
  8655. * @param Rank This parameter can be one of the following values:
  8656. * @arg @ref LL_ADC_REG_RANK_1
  8657. * @arg @ref LL_ADC_REG_RANK_2
  8658. * @arg @ref LL_ADC_REG_RANK_3
  8659. * @arg @ref LL_ADC_REG_RANK_4
  8660. * @arg @ref LL_ADC_REG_RANK_5
  8661. * @arg @ref LL_ADC_REG_RANK_6
  8662. * @arg @ref LL_ADC_REG_RANK_7
  8663. * @arg @ref LL_ADC_REG_RANK_8
  8664. * @arg @ref LL_ADC_REG_RANK_9
  8665. * @arg @ref LL_ADC_REG_RANK_10
  8666. * @arg @ref LL_ADC_REG_RANK_11
  8667. * @arg @ref LL_ADC_REG_RANK_12
  8668. * @arg @ref LL_ADC_REG_RANK_13
  8669. * @arg @ref LL_ADC_REG_RANK_14
  8670. * @arg @ref LL_ADC_REG_RANK_15
  8671. * @arg @ref LL_ADC_REG_RANK_16
  8672. * @param Channel This parameter can be one of the following values:
  8673. * @arg @ref LL_ADC_CHANNEL_0
  8674. * @arg @ref LL_ADC_CHANNEL_1
  8675. * @arg @ref LL_ADC_CHANNEL_2
  8676. * @arg @ref LL_ADC_CHANNEL_3
  8677. * @arg @ref LL_ADC_CHANNEL_4
  8678. * @arg @ref LL_ADC_CHANNEL_5
  8679. * @arg @ref LL_ADC_CHANNEL_6
  8680. * @arg @ref LL_ADC_CHANNEL_7
  8681. * @arg @ref LL_ADC_CHANNEL_8
  8682. * @arg @ref LL_ADC_CHANNEL_9
  8683. * @arg @ref LL_ADC_CHANNEL_10
  8684. * @arg @ref LL_ADC_CHANNEL_11
  8685. * @arg @ref LL_ADC_CHANNEL_12
  8686. * @arg @ref LL_ADC_CHANNEL_13
  8687. * @arg @ref LL_ADC_CHANNEL_14
  8688. * @arg @ref LL_ADC_CHANNEL_15
  8689. * @arg @ref LL_ADC_CHANNEL_16
  8690. * @arg @ref LL_ADC_CHANNEL_17
  8691. * @arg @ref LL_ADC_CHANNEL_VREFINT (1)
  8692. * @arg @ref LL_ADC_CHANNEL_TEMPSENSOR (1)
  8693. *
  8694. * (1) On STM32F37x, parameter available only on ADC instance: ADC1.
  8695. * @retval None
  8696. */
  8697. __STATIC_INLINE void LL_ADC_REG_SetSequencerRanks(ADC_TypeDef *ADCx, uint32_t Rank, uint32_t Channel)
  8698. {
  8699. /* Set bits with content of parameter "Channel" with bits position */
  8700. /* in register and register position depending on parameter "Rank". */
  8701. /* Parameters "Rank" and "Channel" are used with masks because containing */
  8702. /* other bits reserved for other purpose. */
  8703. register uint32_t *preg = __ADC_PTR_REG_OFFSET(ADCx->SQR1, __ADC_MASK_SHIFT(Rank, ADC_REG_SQRX_REGOFFSET_MASK));
  8704. MODIFY_REG(*preg,
  8705. ADC_CHANNEL_ID_NUMBER_MASK << (Rank & ADC_REG_RANK_ID_SQRX_MASK),
  8706. (Channel & ADC_CHANNEL_ID_NUMBER_MASK) << (Rank & ADC_REG_RANK_ID_SQRX_MASK));
  8707. }
  8708. /**
  8709. * @brief Get ADC group regular sequence: channel on the selected
  8710. * scan sequence rank.
  8711. * @note On this STM32 serie, ADC group regular sequencer is
  8712. * fully configurable: sequencer length and each rank
  8713. * affectation to a channel are configurable.
  8714. * Refer to description of function @ref LL_ADC_REG_SetSequencerLength().
  8715. * @note Depending on devices and packages, some channels may not be available.
  8716. * Refer to device datasheet for channels availability.
  8717. * @note Usage of the returned channel number:
  8718. * - To reinject this channel into another function LL_ADC_xxx:
  8719. * the returned channel number is only partly formatted on definition
  8720. * of literals LL_ADC_CHANNEL_x. Therefore, it has to be compared
  8721. * with parts of literals LL_ADC_CHANNEL_x or using
  8722. * helper macro @ref __LL_ADC_CHANNEL_TO_DECIMAL_NB().
  8723. * Then the selected literal LL_ADC_CHANNEL_x can be used
  8724. * as parameter for another function.
  8725. * - To get the channel number in decimal format:
  8726. * process the returned value with the helper macro
  8727. * @ref __LL_ADC_CHANNEL_TO_DECIMAL_NB().
  8728. * @rmtoll SQR3 SQ1 LL_ADC_REG_GetSequencerRanks\n
  8729. * SQR3 SQ2 LL_ADC_REG_GetSequencerRanks\n
  8730. * SQR3 SQ3 LL_ADC_REG_GetSequencerRanks\n
  8731. * SQR3 SQ4 LL_ADC_REG_GetSequencerRanks\n
  8732. * SQR3 SQ5 LL_ADC_REG_GetSequencerRanks\n
  8733. * SQR3 SQ6 LL_ADC_REG_GetSequencerRanks\n
  8734. * SQR2 SQ7 LL_ADC_REG_GetSequencerRanks\n
  8735. * SQR2 SQ8 LL_ADC_REG_GetSequencerRanks\n
  8736. * SQR2 SQ9 LL_ADC_REG_GetSequencerRanks\n
  8737. * SQR2 SQ10 LL_ADC_REG_GetSequencerRanks\n
  8738. * SQR2 SQ11 LL_ADC_REG_GetSequencerRanks\n
  8739. * SQR2 SQ12 LL_ADC_REG_GetSequencerRanks\n
  8740. * SQR1 SQ13 LL_ADC_REG_GetSequencerRanks\n
  8741. * SQR1 SQ14 LL_ADC_REG_GetSequencerRanks\n
  8742. * SQR1 SQ15 LL_ADC_REG_GetSequencerRanks\n
  8743. * SQR1 SQ16 LL_ADC_REG_GetSequencerRanks
  8744. * @param ADCx ADC instance
  8745. * @param Rank This parameter can be one of the following values:
  8746. * @arg @ref LL_ADC_REG_RANK_1
  8747. * @arg @ref LL_ADC_REG_RANK_2
  8748. * @arg @ref LL_ADC_REG_RANK_3
  8749. * @arg @ref LL_ADC_REG_RANK_4
  8750. * @arg @ref LL_ADC_REG_RANK_5
  8751. * @arg @ref LL_ADC_REG_RANK_6
  8752. * @arg @ref LL_ADC_REG_RANK_7
  8753. * @arg @ref LL_ADC_REG_RANK_8
  8754. * @arg @ref LL_ADC_REG_RANK_9
  8755. * @arg @ref LL_ADC_REG_RANK_10
  8756. * @arg @ref LL_ADC_REG_RANK_11
  8757. * @arg @ref LL_ADC_REG_RANK_12
  8758. * @arg @ref LL_ADC_REG_RANK_13
  8759. * @arg @ref LL_ADC_REG_RANK_14
  8760. * @arg @ref LL_ADC_REG_RANK_15
  8761. * @arg @ref LL_ADC_REG_RANK_16
  8762. * @retval Returned value can be one of the following values:
  8763. * @arg @ref LL_ADC_CHANNEL_0
  8764. * @arg @ref LL_ADC_CHANNEL_1
  8765. * @arg @ref LL_ADC_CHANNEL_2
  8766. * @arg @ref LL_ADC_CHANNEL_3
  8767. * @arg @ref LL_ADC_CHANNEL_4
  8768. * @arg @ref LL_ADC_CHANNEL_5
  8769. * @arg @ref LL_ADC_CHANNEL_6
  8770. * @arg @ref LL_ADC_CHANNEL_7
  8771. * @arg @ref LL_ADC_CHANNEL_8
  8772. * @arg @ref LL_ADC_CHANNEL_9
  8773. * @arg @ref LL_ADC_CHANNEL_10
  8774. * @arg @ref LL_ADC_CHANNEL_11
  8775. * @arg @ref LL_ADC_CHANNEL_12
  8776. * @arg @ref LL_ADC_CHANNEL_13
  8777. * @arg @ref LL_ADC_CHANNEL_14
  8778. * @arg @ref LL_ADC_CHANNEL_15
  8779. * @arg @ref LL_ADC_CHANNEL_16
  8780. * @arg @ref LL_ADC_CHANNEL_17
  8781. * @arg @ref LL_ADC_CHANNEL_VREFINT (1)
  8782. * @arg @ref LL_ADC_CHANNEL_TEMPSENSOR (1)
  8783. *
  8784. * (1) On STM32F37x, parameter available only on ADC instance: ADC1.\n
  8785. * (1) For ADC channel read back from ADC register,
  8786. * comparison with internal channel parameter to be done
  8787. * using helper macro @ref __LL_ADC_CHANNEL_INTERNAL_TO_EXTERNAL().
  8788. */
  8789. __STATIC_INLINE uint32_t LL_ADC_REG_GetSequencerRanks(ADC_TypeDef *ADCx, uint32_t Rank)
  8790. {
  8791. register uint32_t *preg = __ADC_PTR_REG_OFFSET(ADCx->SQR1, __ADC_MASK_SHIFT(Rank, ADC_REG_SQRX_REGOFFSET_MASK));
  8792. return (uint32_t) (READ_BIT(*preg,
  8793. ADC_CHANNEL_ID_NUMBER_MASK << (Rank & ADC_REG_RANK_ID_SQRX_MASK))
  8794. >> (Rank & ADC_REG_RANK_ID_SQRX_MASK)
  8795. );
  8796. }
  8797. /**
  8798. * @brief Set ADC continuous conversion mode on ADC group regular.
  8799. * @note Description of ADC continuous conversion mode:
  8800. * - single mode: one conversion per trigger
  8801. * - continuous mode: after the first trigger, following
  8802. * conversions launched successively automatically.
  8803. * @note It is not possible to enable both ADC group regular
  8804. * continuous mode and sequencer discontinuous mode.
  8805. * @rmtoll CR2 CONT LL_ADC_REG_SetContinuousMode
  8806. * @param ADCx ADC instance
  8807. * @param Continuous This parameter can be one of the following values:
  8808. * @arg @ref LL_ADC_REG_CONV_SINGLE
  8809. * @arg @ref LL_ADC_REG_CONV_CONTINUOUS
  8810. * @retval None
  8811. */
  8812. __STATIC_INLINE void LL_ADC_REG_SetContinuousMode(ADC_TypeDef *ADCx, uint32_t Continuous)
  8813. {
  8814. MODIFY_REG(ADCx->CR2, ADC_CR2_CONT, Continuous);
  8815. }
  8816. /**
  8817. * @brief Get ADC continuous conversion mode on ADC group regular.
  8818. * @note Description of ADC continuous conversion mode:
  8819. * - single mode: one conversion per trigger
  8820. * - continuous mode: after the first trigger, following
  8821. * conversions launched successively automatically.
  8822. * @rmtoll CR2 CONT LL_ADC_REG_GetContinuousMode
  8823. * @param ADCx ADC instance
  8824. * @retval Returned value can be one of the following values:
  8825. * @arg @ref LL_ADC_REG_CONV_SINGLE
  8826. * @arg @ref LL_ADC_REG_CONV_CONTINUOUS
  8827. */
  8828. __STATIC_INLINE uint32_t LL_ADC_REG_GetContinuousMode(ADC_TypeDef *ADCx)
  8829. {
  8830. return (uint32_t)(READ_BIT(ADCx->CR2, ADC_CR2_CONT));
  8831. }
  8832. /**
  8833. * @brief Set ADC group regular conversion data transfer: no transfer or
  8834. * transfer by DMA, and DMA requests mode.
  8835. * @note If transfer by DMA selected, specifies the DMA requests
  8836. * mode:
  8837. * - Limited mode (One shot mode): DMA transfer requests are stopped
  8838. * when number of DMA data transfers (number of
  8839. * ADC conversions) is reached.
  8840. * This ADC mode is intended to be used with DMA mode non-circular.
  8841. * - Unlimited mode: DMA transfer requests are unlimited,
  8842. * whatever number of DMA data transfers (number of
  8843. * ADC conversions).
  8844. * This ADC mode is intended to be used with DMA mode circular.
  8845. * @note If ADC DMA requests mode is set to unlimited and DMA is set to
  8846. * mode non-circular:
  8847. * when DMA transfers size will be reached, DMA will stop transfers of
  8848. * ADC conversions data ADC will raise an overrun error
  8849. * (overrun flag and interruption if enabled).
  8850. * @note To configure DMA source address (peripheral address),
  8851. * use function @ref LL_ADC_DMA_GetRegAddr().
  8852. * @rmtoll CR2 DMA LL_ADC_REG_SetDMATransfer
  8853. * @param ADCx ADC instance
  8854. * @param DMATransfer This parameter can be one of the following values:
  8855. * @arg @ref LL_ADC_REG_DMA_TRANSFER_NONE
  8856. * @arg @ref LL_ADC_REG_DMA_TRANSFER_UNLIMITED
  8857. * @retval None
  8858. */
  8859. __STATIC_INLINE void LL_ADC_REG_SetDMATransfer(ADC_TypeDef *ADCx, uint32_t DMATransfer)
  8860. {
  8861. MODIFY_REG(ADCx->CR2, ADC_CR2_DMA, DMATransfer);
  8862. }
  8863. /**
  8864. * @brief Get ADC group regular conversion data transfer: no transfer or
  8865. * transfer by DMA, and DMA requests mode.
  8866. * @note If transfer by DMA selected, specifies the DMA requests
  8867. * mode:
  8868. * - Limited mode (One shot mode): DMA transfer requests are stopped
  8869. * when number of DMA data transfers (number of
  8870. * ADC conversions) is reached.
  8871. * This ADC mode is intended to be used with DMA mode non-circular.
  8872. * - Unlimited mode: DMA transfer requests are unlimited,
  8873. * whatever number of DMA data transfers (number of
  8874. * ADC conversions).
  8875. * This ADC mode is intended to be used with DMA mode circular.
  8876. * @note If ADC DMA requests mode is set to unlimited and DMA is set to
  8877. * mode non-circular:
  8878. * when DMA transfers size will be reached, DMA will stop transfers of
  8879. * ADC conversions data ADC will raise an overrun error
  8880. * (overrun flag and interruption if enabled).
  8881. * @note To configure DMA source address (peripheral address),
  8882. * use function @ref LL_ADC_DMA_GetRegAddr().
  8883. * @rmtoll CR2 DMA LL_ADC_REG_GetDMATransfer
  8884. * @param ADCx ADC instance
  8885. * @retval Returned value can be one of the following values:
  8886. * @arg @ref LL_ADC_REG_DMA_TRANSFER_NONE
  8887. * @arg @ref LL_ADC_REG_DMA_TRANSFER_UNLIMITED
  8888. */
  8889. __STATIC_INLINE uint32_t LL_ADC_REG_GetDMATransfer(ADC_TypeDef *ADCx)
  8890. {
  8891. return (uint32_t)(READ_BIT(ADCx->CR2, ADC_CR2_DMA));
  8892. }
  8893. /**
  8894. * @}
  8895. */
  8896. /** @defgroup ADC_LL_EF_Configuration_ADC_Group_Injected Configuration of ADC hierarchical scope: group injected
  8897. * @{
  8898. */
  8899. /**
  8900. * @brief Set ADC group injected conversion trigger source:
  8901. * internal (SW start) or external from timer or external interrupt.
  8902. * @note On this STM32 serie, external trigger is set with trigger polarity:
  8903. * rising edge (only trigger polarity available on this STM32 serie).
  8904. * @note Availability of parameters of trigger sources from timer
  8905. * depends on timers availability on the selected device.
  8906. * @rmtoll CR2 JEXTSEL LL_ADC_INJ_SetTriggerSource
  8907. * @param ADCx ADC instance
  8908. * @param TriggerSource This parameter can be one of the following values:
  8909. * @arg @ref LL_ADC_INJ_TRIG_SOFTWARE
  8910. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM2_TRGO
  8911. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM2_CH1
  8912. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM3_CH4
  8913. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM4_TRGO
  8914. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM19_CH1
  8915. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM19_CH2
  8916. * @arg @ref LL_ADC_INJ_TRIG_EXT_EXTI_LINE15
  8917. * @retval None
  8918. */
  8919. __STATIC_INLINE void LL_ADC_INJ_SetTriggerSource(ADC_TypeDef *ADCx, uint32_t TriggerSource)
  8920. {
  8921. /* Note: On this STM32 serie, ADC group injected external trigger edge */
  8922. /* is used to perform a ADC conversion start. */
  8923. /* This function does not set external trigger edge. */
  8924. /* This feature is set using function */
  8925. /* @ref LL_ADC_INJ_StartConversionExtTrig(). */
  8926. MODIFY_REG(ADCx->CR2, ADC_CR2_JEXTSEL, (TriggerSource & ADC_CR2_JEXTSEL));
  8927. }
  8928. /**
  8929. * @brief Get ADC group injected conversion trigger source:
  8930. * internal (SW start) or external from timer or external interrupt.
  8931. * @note To determine whether group injected trigger source is
  8932. * internal (SW start) or external, without detail
  8933. * of which peripheral is selected as external trigger,
  8934. * (equivalent to
  8935. * "if(LL_ADC_INJ_GetTriggerSource(ADC1) == LL_ADC_INJ_TRIG_SOFTWARE)")
  8936. * use function @ref LL_ADC_INJ_IsTriggerSourceSWStart.
  8937. * @note Availability of parameters of trigger sources from timer
  8938. * depends on timers availability on the selected device.
  8939. * @rmtoll CR2 JEXTSEL LL_ADC_INJ_GetTriggerSource
  8940. * @param ADCx ADC instance
  8941. * @retval Returned value can be one of the following values:
  8942. * @arg @ref LL_ADC_INJ_TRIG_SOFTWARE
  8943. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM2_TRGO
  8944. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM2_CH1
  8945. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM3_CH4
  8946. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM4_TRGO
  8947. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM19_CH1
  8948. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM19_CH2
  8949. * @arg @ref LL_ADC_INJ_TRIG_EXT_EXTI_LINE15
  8950. */
  8951. __STATIC_INLINE uint32_t LL_ADC_INJ_GetTriggerSource(ADC_TypeDef *ADCx)
  8952. {
  8953. return (uint32_t)(READ_BIT(ADCx->CR2, ADC_CR2_JEXTSEL));
  8954. }
  8955. /**
  8956. * @brief Get ADC group injected conversion trigger source internal (SW start)
  8957. or external
  8958. * @note In case of group injected trigger source set to external trigger,
  8959. * to determine which peripheral is selected as external trigger,
  8960. * use function @ref LL_ADC_INJ_GetTriggerSource.
  8961. * @rmtoll CR2 JEXTSEL LL_ADC_INJ_IsTriggerSourceSWStart
  8962. * @param ADCx ADC instance
  8963. * @retval Value "0" trigger source external trigger
  8964. * Value "1" trigger source SW start.
  8965. */
  8966. __STATIC_INLINE uint32_t LL_ADC_INJ_IsTriggerSourceSWStart(ADC_TypeDef *ADCx)
  8967. {
  8968. return (READ_BIT(ADCx->CR2, ADC_CR2_JEXTSEL) == LL_ADC_INJ_TRIG_SOFTWARE);
  8969. }
  8970. /**
  8971. * @brief Set ADC group injected sequencer length and scan direction.
  8972. * @note This function performs configuration of:
  8973. * - Sequence length: Number of ranks in the scan sequence.
  8974. * - Sequence direction: Unless specified in parameters, sequencer
  8975. * scan direction is forward (from rank 1 to rank n).
  8976. * @note On this STM32 serie, group injected sequencer configuration
  8977. * is conditioned to ADC instance sequencer mode.
  8978. * If ADC instance sequencer mode is disabled, sequencers of
  8979. * all groups (group regular, group injected) can be configured
  8980. * but their execution is disabled (limited to rank 1).
  8981. * Refer to function @ref LL_ADC_SetSequencersScanMode().
  8982. * @note Sequencer disabled is equivalent to sequencer of 1 rank:
  8983. * ADC conversion on only 1 channel.
  8984. * @rmtoll JSQR JL LL_ADC_INJ_SetSequencerLength
  8985. * @param ADCx ADC instance
  8986. * @param SequencerNbRanks This parameter can be one of the following values:
  8987. * @arg @ref LL_ADC_INJ_SEQ_SCAN_DISABLE
  8988. * @arg @ref LL_ADC_INJ_SEQ_SCAN_ENABLE_2RANKS
  8989. * @arg @ref LL_ADC_INJ_SEQ_SCAN_ENABLE_3RANKS
  8990. * @arg @ref LL_ADC_INJ_SEQ_SCAN_ENABLE_4RANKS
  8991. * @retval None
  8992. */
  8993. __STATIC_INLINE void LL_ADC_INJ_SetSequencerLength(ADC_TypeDef *ADCx, uint32_t SequencerNbRanks)
  8994. {
  8995. MODIFY_REG(ADCx->JSQR, ADC_JSQR_JL, SequencerNbRanks);
  8996. }
  8997. /**
  8998. * @brief Get ADC group injected sequencer length and scan direction.
  8999. * @note This function retrieves:
  9000. * - Sequence length: Number of ranks in the scan sequence.
  9001. * - Sequence direction: Unless specified in parameters, sequencer
  9002. * scan direction is forward (from rank 1 to rank n).
  9003. * @note On this STM32 serie, group injected sequencer configuration
  9004. * is conditioned to ADC instance sequencer mode.
  9005. * If ADC instance sequencer mode is disabled, sequencers of
  9006. * all groups (group regular, group injected) can be configured
  9007. * but their execution is disabled (limited to rank 1).
  9008. * Refer to function @ref LL_ADC_SetSequencersScanMode().
  9009. * @note Sequencer disabled is equivalent to sequencer of 1 rank:
  9010. * ADC conversion on only 1 channel.
  9011. * @rmtoll JSQR JL LL_ADC_INJ_GetSequencerLength
  9012. * @param ADCx ADC instance
  9013. * @retval Returned value can be one of the following values:
  9014. * @arg @ref LL_ADC_INJ_SEQ_SCAN_DISABLE
  9015. * @arg @ref LL_ADC_INJ_SEQ_SCAN_ENABLE_2RANKS
  9016. * @arg @ref LL_ADC_INJ_SEQ_SCAN_ENABLE_3RANKS
  9017. * @arg @ref LL_ADC_INJ_SEQ_SCAN_ENABLE_4RANKS
  9018. */
  9019. __STATIC_INLINE uint32_t LL_ADC_INJ_GetSequencerLength(ADC_TypeDef *ADCx)
  9020. {
  9021. return (uint32_t)(READ_BIT(ADCx->JSQR, ADC_JSQR_JL));
  9022. }
  9023. /**
  9024. * @brief Set ADC group injected sequencer discontinuous mode:
  9025. * sequence subdivided and scan conversions interrupted every selected
  9026. * number of ranks.
  9027. * @note It is not possible to enable both ADC group injected
  9028. * auto-injected mode and sequencer discontinuous mode.
  9029. * @rmtoll CR1 DISCEN LL_ADC_INJ_SetSequencerDiscont
  9030. * @param ADCx ADC instance
  9031. * @param SeqDiscont This parameter can be one of the following values:
  9032. * @arg @ref LL_ADC_INJ_SEQ_DISCONT_DISABLE
  9033. * @arg @ref LL_ADC_INJ_SEQ_DISCONT_1RANK
  9034. * @retval None
  9035. */
  9036. __STATIC_INLINE void LL_ADC_INJ_SetSequencerDiscont(ADC_TypeDef *ADCx, uint32_t SeqDiscont)
  9037. {
  9038. MODIFY_REG(ADCx->CR1, ADC_CR1_JDISCEN, SeqDiscont);
  9039. }
  9040. /**
  9041. * @brief Get ADC group injected sequencer discontinuous mode:
  9042. * sequence subdivided and scan conversions interrupted every selected
  9043. * number of ranks.
  9044. * @rmtoll CR1 DISCEN LL_ADC_REG_GetSequencerDiscont
  9045. * @param ADCx ADC instance
  9046. * @retval Returned value can be one of the following values:
  9047. * @arg @ref LL_ADC_INJ_SEQ_DISCONT_DISABLE
  9048. * @arg @ref LL_ADC_INJ_SEQ_DISCONT_1RANK
  9049. */
  9050. __STATIC_INLINE uint32_t LL_ADC_INJ_GetSequencerDiscont(ADC_TypeDef *ADCx)
  9051. {
  9052. return (uint32_t)(READ_BIT(ADCx->CR1, ADC_CR1_JDISCEN));
  9053. }
  9054. /**
  9055. * @brief Set ADC group injected sequence: channel on the selected
  9056. * sequence rank.
  9057. * @note Depending on devices and packages, some channels may not be available.
  9058. * Refer to device datasheet for channels availability.
  9059. * @note On this STM32 serie, to measure internal channels (VrefInt,
  9060. * TempSensor, ...), measurement paths to internal channels must be
  9061. * enabled separately.
  9062. * This can be done using function @ref LL_ADC_SetCommonPathInternalCh().
  9063. * @rmtoll JSQR JSQ1 LL_ADC_INJ_SetSequencerRanks\n
  9064. * JSQR JSQ2 LL_ADC_INJ_SetSequencerRanks\n
  9065. * JSQR JSQ3 LL_ADC_INJ_SetSequencerRanks\n
  9066. * JSQR JSQ4 LL_ADC_INJ_SetSequencerRanks
  9067. * @param ADCx ADC instance
  9068. * @param Rank This parameter can be one of the following values:
  9069. * @arg @ref LL_ADC_INJ_RANK_1
  9070. * @arg @ref LL_ADC_INJ_RANK_2
  9071. * @arg @ref LL_ADC_INJ_RANK_3
  9072. * @arg @ref LL_ADC_INJ_RANK_4
  9073. * @param Channel This parameter can be one of the following values:
  9074. * @arg @ref LL_ADC_CHANNEL_0
  9075. * @arg @ref LL_ADC_CHANNEL_1
  9076. * @arg @ref LL_ADC_CHANNEL_2
  9077. * @arg @ref LL_ADC_CHANNEL_3
  9078. * @arg @ref LL_ADC_CHANNEL_4
  9079. * @arg @ref LL_ADC_CHANNEL_5
  9080. * @arg @ref LL_ADC_CHANNEL_6
  9081. * @arg @ref LL_ADC_CHANNEL_7
  9082. * @arg @ref LL_ADC_CHANNEL_8
  9083. * @arg @ref LL_ADC_CHANNEL_9
  9084. * @arg @ref LL_ADC_CHANNEL_10
  9085. * @arg @ref LL_ADC_CHANNEL_11
  9086. * @arg @ref LL_ADC_CHANNEL_12
  9087. * @arg @ref LL_ADC_CHANNEL_13
  9088. * @arg @ref LL_ADC_CHANNEL_14
  9089. * @arg @ref LL_ADC_CHANNEL_15
  9090. * @arg @ref LL_ADC_CHANNEL_16
  9091. * @arg @ref LL_ADC_CHANNEL_17
  9092. * @arg @ref LL_ADC_CHANNEL_VREFINT (1)
  9093. * @arg @ref LL_ADC_CHANNEL_TEMPSENSOR (1)
  9094. *
  9095. * (1) On STM32F37x, parameter available only on ADC instance: ADC1.
  9096. * @retval None
  9097. */
  9098. __STATIC_INLINE void LL_ADC_INJ_SetSequencerRanks(ADC_TypeDef *ADCx, uint32_t Rank, uint32_t Channel)
  9099. {
  9100. /* Set bits with content of parameter "Channel" with bits position */
  9101. /* in register depending on parameter "Rank". */
  9102. /* Parameters "Rank" and "Channel" are used with masks because containing */
  9103. /* other bits reserved for other purpose. */
  9104. MODIFY_REG(ADCx->JSQR,
  9105. ADC_CHANNEL_ID_NUMBER_MASK << (Rank & ADC_INJ_RANK_ID_JSQR_MASK),
  9106. (Channel & ADC_CHANNEL_ID_NUMBER_MASK) << (Rank & ADC_INJ_RANK_ID_JSQR_MASK));
  9107. }
  9108. /**
  9109. * @brief Get ADC group injected sequence: channel on the selected
  9110. * sequence rank.
  9111. * @note Depending on devices and packages, some channels may not be available.
  9112. * Refer to device datasheet for channels availability.
  9113. * @note Usage of the returned channel number:
  9114. * - To reinject this channel into another function LL_ADC_xxx:
  9115. * the returned channel number is only partly formatted on definition
  9116. * of literals LL_ADC_CHANNEL_x. Therefore, it has to be compared
  9117. * with parts of literals LL_ADC_CHANNEL_x or using
  9118. * helper macro @ref __LL_ADC_CHANNEL_TO_DECIMAL_NB().
  9119. * Then the selected literal LL_ADC_CHANNEL_x can be used
  9120. * as parameter for another function.
  9121. * - To get the channel number in decimal format:
  9122. * process the returned value with the helper macro
  9123. * @ref __LL_ADC_CHANNEL_TO_DECIMAL_NB().
  9124. * @rmtoll JSQR JSQ1 LL_ADC_INJ_SetSequencerRanks\n
  9125. * JSQR JSQ2 LL_ADC_INJ_SetSequencerRanks\n
  9126. * JSQR JSQ3 LL_ADC_INJ_SetSequencerRanks\n
  9127. * JSQR JSQ4 LL_ADC_INJ_SetSequencerRanks
  9128. * @param ADCx ADC instance
  9129. * @param Rank This parameter can be one of the following values:
  9130. * @arg @ref LL_ADC_INJ_RANK_1
  9131. * @arg @ref LL_ADC_INJ_RANK_2
  9132. * @arg @ref LL_ADC_INJ_RANK_3
  9133. * @arg @ref LL_ADC_INJ_RANK_4
  9134. * @retval Returned value can be one of the following values:
  9135. * @arg @ref LL_ADC_CHANNEL_0
  9136. * @arg @ref LL_ADC_CHANNEL_1
  9137. * @arg @ref LL_ADC_CHANNEL_2
  9138. * @arg @ref LL_ADC_CHANNEL_3
  9139. * @arg @ref LL_ADC_CHANNEL_4
  9140. * @arg @ref LL_ADC_CHANNEL_5
  9141. * @arg @ref LL_ADC_CHANNEL_6
  9142. * @arg @ref LL_ADC_CHANNEL_7
  9143. * @arg @ref LL_ADC_CHANNEL_8
  9144. * @arg @ref LL_ADC_CHANNEL_9
  9145. * @arg @ref LL_ADC_CHANNEL_10
  9146. * @arg @ref LL_ADC_CHANNEL_11
  9147. * @arg @ref LL_ADC_CHANNEL_12
  9148. * @arg @ref LL_ADC_CHANNEL_13
  9149. * @arg @ref LL_ADC_CHANNEL_14
  9150. * @arg @ref LL_ADC_CHANNEL_15
  9151. * @arg @ref LL_ADC_CHANNEL_16
  9152. * @arg @ref LL_ADC_CHANNEL_17
  9153. * @arg @ref LL_ADC_CHANNEL_VREFINT (1)
  9154. * @arg @ref LL_ADC_CHANNEL_TEMPSENSOR (1)
  9155. *
  9156. * (1) On STM32F37x, parameter available only on ADC instance: ADC1.\n
  9157. * (1) For ADC channel read back from ADC register,
  9158. * comparison with internal channel parameter to be done
  9159. * using helper macro @ref __LL_ADC_CHANNEL_INTERNAL_TO_EXTERNAL().
  9160. */
  9161. __STATIC_INLINE uint32_t LL_ADC_INJ_GetSequencerRanks(ADC_TypeDef *ADCx, uint32_t Rank)
  9162. {
  9163. return (uint32_t)(READ_BIT(ADCx->JSQR,
  9164. ADC_CHANNEL_ID_NUMBER_MASK << (Rank & ADC_INJ_RANK_ID_JSQR_MASK))
  9165. >> (Rank & ADC_INJ_RANK_ID_JSQR_MASK)
  9166. );
  9167. }
  9168. /**
  9169. * @brief Set ADC group injected conversion trigger:
  9170. * independent or from ADC group regular.
  9171. * @note This mode can be used to extend number of data registers
  9172. * updated after one ADC conversion trigger and with data
  9173. * permanently kept (not erased by successive conversions of scan of
  9174. * ADC sequencer ranks), up to 5 data registers:
  9175. * 1 data register on ADC group regular, 4 data registers
  9176. * on ADC group injected.
  9177. * @note If ADC group injected injected trigger source is set to an
  9178. * external trigger, this feature must be must be set to
  9179. * independent trigger.
  9180. * ADC group injected automatic trigger is compliant only with
  9181. * group injected trigger source set to SW start, without any
  9182. * further action on ADC group injected conversion start or stop:
  9183. * in this case, ADC group injected is controlled only
  9184. * from ADC group regular.
  9185. * @note It is not possible to enable both ADC group injected
  9186. * auto-injected mode and sequencer discontinuous mode.
  9187. * @rmtoll CR1 JAUTO LL_ADC_INJ_SetTrigAuto
  9188. * @param ADCx ADC instance
  9189. * @param TrigAuto This parameter can be one of the following values:
  9190. * @arg @ref LL_ADC_INJ_TRIG_INDEPENDENT
  9191. * @arg @ref LL_ADC_INJ_TRIG_FROM_GRP_REGULAR
  9192. * @retval None
  9193. */
  9194. __STATIC_INLINE void LL_ADC_INJ_SetTrigAuto(ADC_TypeDef *ADCx, uint32_t TrigAuto)
  9195. {
  9196. MODIFY_REG(ADCx->CR1, ADC_CR1_JAUTO, TrigAuto);
  9197. }
  9198. /**
  9199. * @brief Get ADC group injected conversion trigger:
  9200. * independent or from ADC group regular.
  9201. * @rmtoll CR1 JAUTO LL_ADC_INJ_GetTrigAuto
  9202. * @param ADCx ADC instance
  9203. * @retval Returned value can be one of the following values:
  9204. * @arg @ref LL_ADC_INJ_TRIG_INDEPENDENT
  9205. * @arg @ref LL_ADC_INJ_TRIG_FROM_GRP_REGULAR
  9206. */
  9207. __STATIC_INLINE uint32_t LL_ADC_INJ_GetTrigAuto(ADC_TypeDef *ADCx)
  9208. {
  9209. return (uint32_t)(READ_BIT(ADCx->CR1, ADC_CR1_JAUTO));
  9210. }
  9211. /**
  9212. * @brief Set ADC group injected offset.
  9213. * @note It sets:
  9214. * - ADC group injected rank to which the offset programmed
  9215. * will be applied
  9216. * - Offset level (offset to be subtracted from the raw
  9217. * converted data).
  9218. * Caution: Offset format is dependent to ADC resolution:
  9219. * offset has to be left-aligned on bit 11, the LSB (right bits)
  9220. * are set to 0.
  9221. * @note Offset cannot be enabled or disabled.
  9222. * To emulate offset disabled, set an offset value equal to 0.
  9223. * @rmtoll JOFR1 JOFFSET1 LL_ADC_INJ_SetOffset\n
  9224. * JOFR2 JOFFSET2 LL_ADC_INJ_SetOffset\n
  9225. * JOFR3 JOFFSET3 LL_ADC_INJ_SetOffset\n
  9226. * JOFR4 JOFFSET4 LL_ADC_INJ_SetOffset
  9227. * @param ADCx ADC instance
  9228. * @param Rank This parameter can be one of the following values:
  9229. * @arg @ref LL_ADC_INJ_RANK_1
  9230. * @arg @ref LL_ADC_INJ_RANK_2
  9231. * @arg @ref LL_ADC_INJ_RANK_3
  9232. * @arg @ref LL_ADC_INJ_RANK_4
  9233. * @param OffsetLevel Value between Min_Data=0x000 and Max_Data=0xFFF
  9234. * @retval None
  9235. */
  9236. __STATIC_INLINE void LL_ADC_INJ_SetOffset(ADC_TypeDef *ADCx, uint32_t Rank, uint32_t OffsetLevel)
  9237. {
  9238. register uint32_t *preg = __ADC_PTR_REG_OFFSET(ADCx->JOFR1, __ADC_MASK_SHIFT(Rank, ADC_INJ_JOFRX_REGOFFSET_MASK));
  9239. MODIFY_REG(*preg,
  9240. ADC_JOFR1_JOFFSET1,
  9241. OffsetLevel);
  9242. }
  9243. /**
  9244. * @brief Get ADC group injected offset.
  9245. * @note It gives offset level (offset to be subtracted from the raw converted data).
  9246. * Caution: Offset format is dependent to ADC resolution:
  9247. * offset has to be left-aligned on bit 11, the LSB (right bits)
  9248. * are set to 0.
  9249. * @rmtoll JOFR1 JOFFSET1 LL_ADC_INJ_GetOffset\n
  9250. * JOFR2 JOFFSET2 LL_ADC_INJ_GetOffset\n
  9251. * JOFR3 JOFFSET3 LL_ADC_INJ_GetOffset\n
  9252. * JOFR4 JOFFSET4 LL_ADC_INJ_GetOffset
  9253. * @param ADCx ADC instance
  9254. * @param Rank This parameter can be one of the following values:
  9255. * @arg @ref LL_ADC_INJ_RANK_1
  9256. * @arg @ref LL_ADC_INJ_RANK_2
  9257. * @arg @ref LL_ADC_INJ_RANK_3
  9258. * @arg @ref LL_ADC_INJ_RANK_4
  9259. * @retval Value between Min_Data=0x000 and Max_Data=0xFFF
  9260. */
  9261. __STATIC_INLINE uint32_t LL_ADC_INJ_GetOffset(ADC_TypeDef *ADCx, uint32_t Rank)
  9262. {
  9263. register uint32_t *preg = __ADC_PTR_REG_OFFSET(ADCx->JOFR1, __ADC_MASK_SHIFT(Rank, ADC_INJ_JOFRX_REGOFFSET_MASK));
  9264. return (uint32_t)(READ_BIT(*preg,
  9265. ADC_JOFR1_JOFFSET1)
  9266. );
  9267. }
  9268. /**
  9269. * @}
  9270. */
  9271. /** @defgroup ADC_LL_EF_Configuration_Channels Configuration of ADC hierarchical scope: channels
  9272. * @{
  9273. */
  9274. /**
  9275. * @brief Set sampling time of the selected ADC channel
  9276. * Unit: ADC clock cycles.
  9277. * @note On this device, sampling time is on channel scope: independently
  9278. * of channel mapped on ADC group regular or injected.
  9279. * @note In case of internal channel (VrefInt, TempSensor, ...) to be
  9280. * converted:
  9281. * sampling time constraints must be respected (sampling time can be
  9282. * adjusted in function of ADC clock frequency and sampling time
  9283. * setting).
  9284. * Refer to device datasheet for timings values (parameters TS_vrefint,
  9285. * TS_temp, ...).
  9286. * @note Conversion time is the addition of sampling time and processing time.
  9287. * Refer to reference manual for ADC processing time of
  9288. * this STM32 serie.
  9289. * @note In case of ADC conversion of internal channel (VrefInt,
  9290. * temperature sensor, ...), a sampling time minimum value
  9291. * is required.
  9292. * Refer to device datasheet.
  9293. * @rmtoll SMPR1 SMP17 LL_ADC_SetChannelSamplingTime\n
  9294. * SMPR1 SMP16 LL_ADC_SetChannelSamplingTime\n
  9295. * SMPR1 SMP15 LL_ADC_SetChannelSamplingTime\n
  9296. * SMPR1 SMP14 LL_ADC_SetChannelSamplingTime\n
  9297. * SMPR1 SMP13 LL_ADC_SetChannelSamplingTime\n
  9298. * SMPR1 SMP12 LL_ADC_SetChannelSamplingTime\n
  9299. * SMPR1 SMP11 LL_ADC_SetChannelSamplingTime\n
  9300. * SMPR1 SMP10 LL_ADC_SetChannelSamplingTime\n
  9301. * SMPR2 SMP9 LL_ADC_SetChannelSamplingTime\n
  9302. * SMPR2 SMP8 LL_ADC_SetChannelSamplingTime\n
  9303. * SMPR2 SMP7 LL_ADC_SetChannelSamplingTime\n
  9304. * SMPR2 SMP6 LL_ADC_SetChannelSamplingTime\n
  9305. * SMPR2 SMP5 LL_ADC_SetChannelSamplingTime\n
  9306. * SMPR2 SMP4 LL_ADC_SetChannelSamplingTime\n
  9307. * SMPR2 SMP3 LL_ADC_SetChannelSamplingTime\n
  9308. * SMPR2 SMP2 LL_ADC_SetChannelSamplingTime\n
  9309. * SMPR2 SMP1 LL_ADC_SetChannelSamplingTime\n
  9310. * SMPR2 SMP0 LL_ADC_SetChannelSamplingTime
  9311. * @param ADCx ADC instance
  9312. * @param Channel This parameter can be one of the following values:
  9313. * @arg @ref LL_ADC_CHANNEL_0
  9314. * @arg @ref LL_ADC_CHANNEL_1
  9315. * @arg @ref LL_ADC_CHANNEL_2
  9316. * @arg @ref LL_ADC_CHANNEL_3
  9317. * @arg @ref LL_ADC_CHANNEL_4
  9318. * @arg @ref LL_ADC_CHANNEL_5
  9319. * @arg @ref LL_ADC_CHANNEL_6
  9320. * @arg @ref LL_ADC_CHANNEL_7
  9321. * @arg @ref LL_ADC_CHANNEL_8
  9322. * @arg @ref LL_ADC_CHANNEL_9
  9323. * @arg @ref LL_ADC_CHANNEL_10
  9324. * @arg @ref LL_ADC_CHANNEL_11
  9325. * @arg @ref LL_ADC_CHANNEL_12
  9326. * @arg @ref LL_ADC_CHANNEL_13
  9327. * @arg @ref LL_ADC_CHANNEL_14
  9328. * @arg @ref LL_ADC_CHANNEL_15
  9329. * @arg @ref LL_ADC_CHANNEL_16
  9330. * @arg @ref LL_ADC_CHANNEL_17
  9331. * @arg @ref LL_ADC_CHANNEL_VREFINT (1)
  9332. * @arg @ref LL_ADC_CHANNEL_TEMPSENSOR (1)
  9333. *
  9334. * (1) On STM32F37x, parameter available only on ADC instance: ADC1.
  9335. * @param SamplingTime This parameter can be one of the following values:
  9336. * @arg @ref LL_ADC_SAMPLINGTIME_1CYCLE_5
  9337. * @arg @ref LL_ADC_SAMPLINGTIME_7CYCLES_5
  9338. * @arg @ref LL_ADC_SAMPLINGTIME_13CYCLES_5
  9339. * @arg @ref LL_ADC_SAMPLINGTIME_28CYCLES_5
  9340. * @arg @ref LL_ADC_SAMPLINGTIME_41CYCLES_5
  9341. * @arg @ref LL_ADC_SAMPLINGTIME_55CYCLES_5
  9342. * @arg @ref LL_ADC_SAMPLINGTIME_71CYCLES_5
  9343. * @arg @ref LL_ADC_SAMPLINGTIME_239CYCLES_5
  9344. * @retval None
  9345. */
  9346. __STATIC_INLINE void LL_ADC_SetChannelSamplingTime(ADC_TypeDef *ADCx, uint32_t Channel, uint32_t SamplingTime)
  9347. {
  9348. /* Set bits with content of parameter "SamplingTime" with bits position */
  9349. /* in register and register position depending on parameter "Channel". */
  9350. /* Parameter "Channel" is used with masks because containing */
  9351. /* other bits reserved for other purpose. */
  9352. register uint32_t *preg = __ADC_PTR_REG_OFFSET(ADCx->SMPR1, __ADC_MASK_SHIFT(Channel, ADC_CHANNEL_SMPRX_REGOFFSET_MASK));
  9353. MODIFY_REG(*preg,
  9354. ADC_SMPR2_SMP0 << __ADC_MASK_SHIFT(Channel, ADC_CHANNEL_SMPx_BITOFFSET_MASK),
  9355. SamplingTime << __ADC_MASK_SHIFT(Channel, ADC_CHANNEL_SMPx_BITOFFSET_MASK));
  9356. }
  9357. /**
  9358. * @brief Get sampling time of the selected ADC channel
  9359. * Unit: ADC clock cycles.
  9360. * @note On this device, sampling time is on channel scope: independently
  9361. * of channel mapped on ADC group regular or injected.
  9362. * @note Conversion time is the addition of sampling time and processing time.
  9363. * Refer to reference manual for ADC processing time of
  9364. * this STM32 serie.
  9365. * @rmtoll SMPR1 SMP17 LL_ADC_GetChannelSamplingTime\n
  9366. * SMPR1 SMP16 LL_ADC_GetChannelSamplingTime\n
  9367. * SMPR1 SMP15 LL_ADC_GetChannelSamplingTime\n
  9368. * SMPR1 SMP14 LL_ADC_GetChannelSamplingTime\n
  9369. * SMPR1 SMP13 LL_ADC_GetChannelSamplingTime\n
  9370. * SMPR1 SMP12 LL_ADC_GetChannelSamplingTime\n
  9371. * SMPR1 SMP11 LL_ADC_GetChannelSamplingTime\n
  9372. * SMPR1 SMP10 LL_ADC_GetChannelSamplingTime\n
  9373. * SMPR2 SMP9 LL_ADC_GetChannelSamplingTime\n
  9374. * SMPR2 SMP8 LL_ADC_GetChannelSamplingTime\n
  9375. * SMPR2 SMP7 LL_ADC_GetChannelSamplingTime\n
  9376. * SMPR2 SMP6 LL_ADC_GetChannelSamplingTime\n
  9377. * SMPR2 SMP5 LL_ADC_GetChannelSamplingTime\n
  9378. * SMPR2 SMP4 LL_ADC_GetChannelSamplingTime\n
  9379. * SMPR2 SMP3 LL_ADC_GetChannelSamplingTime\n
  9380. * SMPR2 SMP2 LL_ADC_GetChannelSamplingTime\n
  9381. * SMPR2 SMP1 LL_ADC_GetChannelSamplingTime\n
  9382. * SMPR2 SMP0 LL_ADC_GetChannelSamplingTime
  9383. * @param ADCx ADC instance
  9384. * @param Channel This parameter can be one of the following values:
  9385. * @arg @ref LL_ADC_CHANNEL_0
  9386. * @arg @ref LL_ADC_CHANNEL_1
  9387. * @arg @ref LL_ADC_CHANNEL_2
  9388. * @arg @ref LL_ADC_CHANNEL_3
  9389. * @arg @ref LL_ADC_CHANNEL_4
  9390. * @arg @ref LL_ADC_CHANNEL_5
  9391. * @arg @ref LL_ADC_CHANNEL_6
  9392. * @arg @ref LL_ADC_CHANNEL_7
  9393. * @arg @ref LL_ADC_CHANNEL_8
  9394. * @arg @ref LL_ADC_CHANNEL_9
  9395. * @arg @ref LL_ADC_CHANNEL_10
  9396. * @arg @ref LL_ADC_CHANNEL_11
  9397. * @arg @ref LL_ADC_CHANNEL_12
  9398. * @arg @ref LL_ADC_CHANNEL_13
  9399. * @arg @ref LL_ADC_CHANNEL_14
  9400. * @arg @ref LL_ADC_CHANNEL_15
  9401. * @arg @ref LL_ADC_CHANNEL_16
  9402. * @arg @ref LL_ADC_CHANNEL_17
  9403. * @arg @ref LL_ADC_CHANNEL_VREFINT (1)
  9404. * @arg @ref LL_ADC_CHANNEL_TEMPSENSOR (1)
  9405. *
  9406. * (1) On STM32F37x, parameter available only on ADC instance: ADC1.
  9407. * @retval Returned value can be one of the following values:
  9408. * @arg @ref LL_ADC_SAMPLINGTIME_1CYCLE_5
  9409. * @arg @ref LL_ADC_SAMPLINGTIME_7CYCLES_5
  9410. * @arg @ref LL_ADC_SAMPLINGTIME_13CYCLES_5
  9411. * @arg @ref LL_ADC_SAMPLINGTIME_28CYCLES_5
  9412. * @arg @ref LL_ADC_SAMPLINGTIME_41CYCLES_5
  9413. * @arg @ref LL_ADC_SAMPLINGTIME_55CYCLES_5
  9414. * @arg @ref LL_ADC_SAMPLINGTIME_71CYCLES_5
  9415. * @arg @ref LL_ADC_SAMPLINGTIME_239CYCLES_5
  9416. */
  9417. __STATIC_INLINE uint32_t LL_ADC_GetChannelSamplingTime(ADC_TypeDef *ADCx, uint32_t Channel)
  9418. {
  9419. register uint32_t *preg = __ADC_PTR_REG_OFFSET(ADCx->SMPR1, __ADC_MASK_SHIFT(Channel, ADC_CHANNEL_SMPRX_REGOFFSET_MASK));
  9420. return (uint32_t)(READ_BIT(*preg,
  9421. ADC_SMPR2_SMP0 << __ADC_MASK_SHIFT(Channel, ADC_CHANNEL_SMPx_BITOFFSET_MASK))
  9422. >> __ADC_MASK_SHIFT(Channel, ADC_CHANNEL_SMPx_BITOFFSET_MASK)
  9423. );
  9424. }
  9425. /**
  9426. * @}
  9427. */
  9428. /** @defgroup ADC_LL_EF_Configuration_ADC_AnalogWatchdog Configuration of ADC transversal scope: analog watchdog
  9429. * @{
  9430. */
  9431. /**
  9432. * @brief Set ADC analog watchdog monitored channels:
  9433. * a single channel or all channels,
  9434. * on ADC groups regular and-or injected.
  9435. * @note Once monitored channels are selected, analog watchdog
  9436. * is enabled.
  9437. * @note In case of need to define a single channel to monitor
  9438. * with analog watchdog from sequencer channel definition,
  9439. * use helper macro @ref __LL_ADC_ANALOGWD_CHANNEL_GROUP().
  9440. * @note On this STM32 serie, there is only 1 kind of analog watchdog
  9441. * instance:
  9442. * - AWD standard (instance AWD1):
  9443. * - channels monitored: can monitor 1 channel or all channels.
  9444. * - groups monitored: ADC groups regular and-or injected.
  9445. * - resolution: resolution is not limited (corresponds to
  9446. * ADC resolution configured).
  9447. * @rmtoll CR1 AWD1CH LL_ADC_SetAnalogWDMonitChannels\n
  9448. * CR1 AWD1SGL LL_ADC_SetAnalogWDMonitChannels\n
  9449. * CR1 AWD1EN LL_ADC_SetAnalogWDMonitChannels
  9450. * @param ADCx ADC instance
  9451. * @param AWDChannelGroup This parameter can be one of the following values:
  9452. * @arg @ref LL_ADC_AWD_DISABLE
  9453. * @arg @ref LL_ADC_AWD_ALL_CHANNELS_REG
  9454. * @arg @ref LL_ADC_AWD_ALL_CHANNELS_INJ
  9455. * @arg @ref LL_ADC_AWD_ALL_CHANNELS_REG_INJ
  9456. * @arg @ref LL_ADC_AWD_CHANNEL_0_REG
  9457. * @arg @ref LL_ADC_AWD_CHANNEL_0_INJ
  9458. * @arg @ref LL_ADC_AWD_CHANNEL_0_REG_INJ
  9459. * @arg @ref LL_ADC_AWD_CHANNEL_1_REG
  9460. * @arg @ref LL_ADC_AWD_CHANNEL_1_INJ
  9461. * @arg @ref LL_ADC_AWD_CHANNEL_1_REG_INJ
  9462. * @arg @ref LL_ADC_AWD_CHANNEL_2_REG
  9463. * @arg @ref LL_ADC_AWD_CHANNEL_2_INJ
  9464. * @arg @ref LL_ADC_AWD_CHANNEL_2_REG_INJ
  9465. * @arg @ref LL_ADC_AWD_CHANNEL_3_REG
  9466. * @arg @ref LL_ADC_AWD_CHANNEL_3_INJ
  9467. * @arg @ref LL_ADC_AWD_CHANNEL_3_REG_INJ
  9468. * @arg @ref LL_ADC_AWD_CHANNEL_4_REG
  9469. * @arg @ref LL_ADC_AWD_CHANNEL_4_INJ
  9470. * @arg @ref LL_ADC_AWD_CHANNEL_4_REG_INJ
  9471. * @arg @ref LL_ADC_AWD_CHANNEL_5_REG
  9472. * @arg @ref LL_ADC_AWD_CHANNEL_5_INJ
  9473. * @arg @ref LL_ADC_AWD_CHANNEL_5_REG_INJ
  9474. * @arg @ref LL_ADC_AWD_CHANNEL_6_REG
  9475. * @arg @ref LL_ADC_AWD_CHANNEL_6_INJ
  9476. * @arg @ref LL_ADC_AWD_CHANNEL_6_REG_INJ
  9477. * @arg @ref LL_ADC_AWD_CHANNEL_7_REG
  9478. * @arg @ref LL_ADC_AWD_CHANNEL_7_INJ
  9479. * @arg @ref LL_ADC_AWD_CHANNEL_7_REG_INJ
  9480. * @arg @ref LL_ADC_AWD_CHANNEL_8_REG
  9481. * @arg @ref LL_ADC_AWD_CHANNEL_8_INJ
  9482. * @arg @ref LL_ADC_AWD_CHANNEL_8_REG_INJ
  9483. * @arg @ref LL_ADC_AWD_CHANNEL_9_REG
  9484. * @arg @ref LL_ADC_AWD_CHANNEL_9_INJ
  9485. * @arg @ref LL_ADC_AWD_CHANNEL_9_REG_INJ
  9486. * @arg @ref LL_ADC_AWD_CHANNEL_10_REG
  9487. * @arg @ref LL_ADC_AWD_CHANNEL_10_INJ
  9488. * @arg @ref LL_ADC_AWD_CHANNEL_10_REG_INJ
  9489. * @arg @ref LL_ADC_AWD_CHANNEL_11_REG
  9490. * @arg @ref LL_ADC_AWD_CHANNEL_11_INJ
  9491. * @arg @ref LL_ADC_AWD_CHANNEL_11_REG_INJ
  9492. * @arg @ref LL_ADC_AWD_CHANNEL_12_REG
  9493. * @arg @ref LL_ADC_AWD_CHANNEL_12_INJ
  9494. * @arg @ref LL_ADC_AWD_CHANNEL_12_REG_INJ
  9495. * @arg @ref LL_ADC_AWD_CHANNEL_13_REG
  9496. * @arg @ref LL_ADC_AWD_CHANNEL_13_INJ
  9497. * @arg @ref LL_ADC_AWD_CHANNEL_13_REG_INJ
  9498. * @arg @ref LL_ADC_AWD_CHANNEL_14_REG
  9499. * @arg @ref LL_ADC_AWD_CHANNEL_14_INJ
  9500. * @arg @ref LL_ADC_AWD_CHANNEL_14_REG_INJ
  9501. * @arg @ref LL_ADC_AWD_CHANNEL_15_REG
  9502. * @arg @ref LL_ADC_AWD_CHANNEL_15_INJ
  9503. * @arg @ref LL_ADC_AWD_CHANNEL_15_REG_INJ
  9504. * @arg @ref LL_ADC_AWD_CHANNEL_16_REG
  9505. * @arg @ref LL_ADC_AWD_CHANNEL_16_INJ
  9506. * @arg @ref LL_ADC_AWD_CHANNEL_16_REG_INJ
  9507. * @arg @ref LL_ADC_AWD_CHANNEL_17_REG
  9508. * @arg @ref LL_ADC_AWD_CHANNEL_17_INJ
  9509. * @arg @ref LL_ADC_AWD_CHANNEL_17_REG_INJ
  9510. * @arg @ref LL_ADC_AWD_CH_VREFINT_REG (1)
  9511. * @arg @ref LL_ADC_AWD_CH_VREFINT_INJ (1)
  9512. * @arg @ref LL_ADC_AWD_CH_VREFINT_REG_INJ (1)
  9513. * @arg @ref LL_ADC_AWD_CH_TEMPSENSOR_REG (1)
  9514. * @arg @ref LL_ADC_AWD_CH_TEMPSENSOR_INJ (1)
  9515. * @arg @ref LL_ADC_AWD_CH_TEMPSENSOR_REG_INJ (1)
  9516. *
  9517. * (1) On STM32F37x, parameter available only on ADC instance: ADC1.
  9518. * @retval None
  9519. */
  9520. __STATIC_INLINE void LL_ADC_SetAnalogWDMonitChannels(ADC_TypeDef *ADCx, uint32_t AWDChannelGroup)
  9521. {
  9522. MODIFY_REG(ADCx->CR1,
  9523. (ADC_CR1_AWDEN | ADC_CR1_JAWDEN | ADC_CR1_AWDSGL | ADC_CR1_AWDCH),
  9524. AWDChannelGroup);
  9525. }
  9526. /**
  9527. * @brief Get ADC analog watchdog monitored channel.
  9528. * @note Usage of the returned channel number:
  9529. * - To reinject this channel into another function LL_ADC_xxx:
  9530. * the returned channel number is only partly formatted on definition
  9531. * of literals LL_ADC_CHANNEL_x. Therefore, it has to be compared
  9532. * with parts of literals LL_ADC_CHANNEL_x or using
  9533. * helper macro @ref __LL_ADC_CHANNEL_TO_DECIMAL_NB().
  9534. * Then the selected literal LL_ADC_CHANNEL_x can be used
  9535. * as parameter for another function.
  9536. * - To get the channel number in decimal format:
  9537. * process the returned value with the helper macro
  9538. * @ref __LL_ADC_CHANNEL_TO_DECIMAL_NB().
  9539. * Applicable only when the analog watchdog is set to monitor
  9540. * one channel.
  9541. * @note On this STM32 serie, there is only 1 kind of analog watchdog
  9542. * instance:
  9543. * - AWD standard (instance AWD1):
  9544. * - channels monitored: can monitor 1 channel or all channels.
  9545. * - groups monitored: ADC groups regular and-or injected.
  9546. * - resolution: resolution is not limited (corresponds to
  9547. * ADC resolution configured).
  9548. * @rmtoll CR1 AWD1CH LL_ADC_GetAnalogWDMonitChannels\n
  9549. * CR1 AWD1SGL LL_ADC_GetAnalogWDMonitChannels\n
  9550. * CR1 AWD1EN LL_ADC_GetAnalogWDMonitChannels
  9551. * @param ADCx ADC instance
  9552. * @retval Returned value can be one of the following values:
  9553. * @arg @ref LL_ADC_AWD_DISABLE
  9554. * @arg @ref LL_ADC_AWD_ALL_CHANNELS_REG
  9555. * @arg @ref LL_ADC_AWD_ALL_CHANNELS_INJ
  9556. * @arg @ref LL_ADC_AWD_ALL_CHANNELS_REG_INJ
  9557. * @arg @ref LL_ADC_AWD_CHANNEL_0_REG
  9558. * @arg @ref LL_ADC_AWD_CHANNEL_0_INJ
  9559. * @arg @ref LL_ADC_AWD_CHANNEL_0_REG_INJ
  9560. * @arg @ref LL_ADC_AWD_CHANNEL_1_REG
  9561. * @arg @ref LL_ADC_AWD_CHANNEL_1_INJ
  9562. * @arg @ref LL_ADC_AWD_CHANNEL_1_REG_INJ
  9563. * @arg @ref LL_ADC_AWD_CHANNEL_2_REG
  9564. * @arg @ref LL_ADC_AWD_CHANNEL_2_INJ
  9565. * @arg @ref LL_ADC_AWD_CHANNEL_2_REG_INJ
  9566. * @arg @ref LL_ADC_AWD_CHANNEL_3_REG
  9567. * @arg @ref LL_ADC_AWD_CHANNEL_3_INJ
  9568. * @arg @ref LL_ADC_AWD_CHANNEL_3_REG_INJ
  9569. * @arg @ref LL_ADC_AWD_CHANNEL_4_REG
  9570. * @arg @ref LL_ADC_AWD_CHANNEL_4_INJ
  9571. * @arg @ref LL_ADC_AWD_CHANNEL_4_REG_INJ
  9572. * @arg @ref LL_ADC_AWD_CHANNEL_5_REG
  9573. * @arg @ref LL_ADC_AWD_CHANNEL_5_INJ
  9574. * @arg @ref LL_ADC_AWD_CHANNEL_5_REG_INJ
  9575. * @arg @ref LL_ADC_AWD_CHANNEL_6_REG
  9576. * @arg @ref LL_ADC_AWD_CHANNEL_6_INJ
  9577. * @arg @ref LL_ADC_AWD_CHANNEL_6_REG_INJ
  9578. * @arg @ref LL_ADC_AWD_CHANNEL_7_REG
  9579. * @arg @ref LL_ADC_AWD_CHANNEL_7_INJ
  9580. * @arg @ref LL_ADC_AWD_CHANNEL_7_REG_INJ
  9581. * @arg @ref LL_ADC_AWD_CHANNEL_8_REG
  9582. * @arg @ref LL_ADC_AWD_CHANNEL_8_INJ
  9583. * @arg @ref LL_ADC_AWD_CHANNEL_8_REG_INJ
  9584. * @arg @ref LL_ADC_AWD_CHANNEL_9_REG
  9585. * @arg @ref LL_ADC_AWD_CHANNEL_9_INJ
  9586. * @arg @ref LL_ADC_AWD_CHANNEL_9_REG_INJ
  9587. * @arg @ref LL_ADC_AWD_CHANNEL_10_REG
  9588. * @arg @ref LL_ADC_AWD_CHANNEL_10_INJ
  9589. * @arg @ref LL_ADC_AWD_CHANNEL_10_REG_INJ
  9590. * @arg @ref LL_ADC_AWD_CHANNEL_11_REG
  9591. * @arg @ref LL_ADC_AWD_CHANNEL_11_INJ
  9592. * @arg @ref LL_ADC_AWD_CHANNEL_11_REG_INJ
  9593. * @arg @ref LL_ADC_AWD_CHANNEL_12_REG
  9594. * @arg @ref LL_ADC_AWD_CHANNEL_12_INJ
  9595. * @arg @ref LL_ADC_AWD_CHANNEL_12_REG_INJ
  9596. * @arg @ref LL_ADC_AWD_CHANNEL_13_REG
  9597. * @arg @ref LL_ADC_AWD_CHANNEL_13_INJ
  9598. * @arg @ref LL_ADC_AWD_CHANNEL_13_REG_INJ
  9599. * @arg @ref LL_ADC_AWD_CHANNEL_14_REG
  9600. * @arg @ref LL_ADC_AWD_CHANNEL_14_INJ
  9601. * @arg @ref LL_ADC_AWD_CHANNEL_14_REG_INJ
  9602. * @arg @ref LL_ADC_AWD_CHANNEL_15_REG
  9603. * @arg @ref LL_ADC_AWD_CHANNEL_15_INJ
  9604. * @arg @ref LL_ADC_AWD_CHANNEL_15_REG_INJ
  9605. * @arg @ref LL_ADC_AWD_CHANNEL_16_REG
  9606. * @arg @ref LL_ADC_AWD_CHANNEL_16_INJ
  9607. * @arg @ref LL_ADC_AWD_CHANNEL_16_REG_INJ
  9608. * @arg @ref LL_ADC_AWD_CHANNEL_17_REG
  9609. * @arg @ref LL_ADC_AWD_CHANNEL_17_INJ
  9610. * @arg @ref LL_ADC_AWD_CHANNEL_17_REG_INJ
  9611. */
  9612. __STATIC_INLINE uint32_t LL_ADC_GetAnalogWDMonitChannels(ADC_TypeDef *ADCx)
  9613. {
  9614. return (uint32_t)(READ_BIT(ADCx->CR1, (ADC_CR1_AWDEN | ADC_CR1_JAWDEN | ADC_CR1_AWDSGL | ADC_CR1_AWDCH)));
  9615. }
  9616. /**
  9617. * @brief Set ADC analog watchdog threshold value of threshold
  9618. * high or low.
  9619. * @note On this STM32 serie, there is only 1 kind of analog watchdog
  9620. * instance:
  9621. * - AWD standard (instance AWD1):
  9622. * - channels monitored: can monitor 1 channel or all channels.
  9623. * - groups monitored: ADC groups regular and-or injected.
  9624. * - resolution: resolution is not limited (corresponds to
  9625. * ADC resolution configured).
  9626. * @rmtoll HTR HT LL_ADC_SetAnalogWDThresholds\n
  9627. * LTR LT LL_ADC_SetAnalogWDThresholds
  9628. * @param ADCx ADC instance
  9629. * @param AWDThresholdsHighLow This parameter can be one of the following values:
  9630. * @arg @ref LL_ADC_AWD_THRESHOLD_HIGH
  9631. * @arg @ref LL_ADC_AWD_THRESHOLD_LOW
  9632. * @param AWDThresholdValue Value between Min_Data=0x000 and Max_Data=0xFFF
  9633. * @retval None
  9634. */
  9635. __STATIC_INLINE void LL_ADC_SetAnalogWDThresholds(ADC_TypeDef *ADCx, uint32_t AWDThresholdsHighLow, uint32_t AWDThresholdValue)
  9636. {
  9637. register uint32_t *preg = __ADC_PTR_REG_OFFSET(ADCx->HTR, AWDThresholdsHighLow);
  9638. MODIFY_REG(*preg,
  9639. ADC_HTR_HT,
  9640. AWDThresholdValue);
  9641. }
  9642. /**
  9643. * @brief Get ADC analog watchdog threshold value of threshold high or
  9644. * threshold low.
  9645. * @note In case of ADC resolution different of 12 bits,
  9646. * analog watchdog thresholds data require a specific shift.
  9647. * Use helper macro @ref __LL_ADC_ANALOGWD_GET_THRESHOLD_RESOLUTION().
  9648. * @rmtoll HTR HT LL_ADC_GetAnalogWDThresholds\n
  9649. * LTR LT LL_ADC_GetAnalogWDThresholds
  9650. * @param ADCx ADC instance
  9651. * @param AWDThresholdsHighLow This parameter can be one of the following values:
  9652. * @arg @ref LL_ADC_AWD_THRESHOLD_HIGH
  9653. * @arg @ref LL_ADC_AWD_THRESHOLD_LOW
  9654. * @retval Value between Min_Data=0x000 and Max_Data=0xFFF
  9655. */
  9656. __STATIC_INLINE uint32_t LL_ADC_GetAnalogWDThresholds(ADC_TypeDef *ADCx, uint32_t AWDThresholdsHighLow)
  9657. {
  9658. register uint32_t *preg = __ADC_PTR_REG_OFFSET(ADCx->HTR, AWDThresholdsHighLow);
  9659. return (uint32_t)(READ_BIT(*preg, ADC_HTR_HT));
  9660. }
  9661. /**
  9662. * @}
  9663. */
  9664. /** @defgroup ADC_LL_EF_Operation_ADC_Instance Operation on ADC hierarchical scope: ADC instance
  9665. * @{
  9666. */
  9667. /**
  9668. * @brief Enable the selected ADC instance.
  9669. * @note On this STM32 serie, after ADC enable, a delay for
  9670. * ADC internal analog stabilization is required before performing a
  9671. * ADC conversion start.
  9672. * Refer to device datasheet, parameter tSTAB.
  9673. * @rmtoll CR2 ADON LL_ADC_Enable
  9674. * @param ADCx ADC instance
  9675. * @retval None
  9676. */
  9677. __STATIC_INLINE void LL_ADC_Enable(ADC_TypeDef *ADCx)
  9678. {
  9679. SET_BIT(ADCx->CR2, ADC_CR2_ADON);
  9680. }
  9681. /**
  9682. * @brief Disable the selected ADC instance.
  9683. * @rmtoll CR2 ADON LL_ADC_Disable
  9684. * @param ADCx ADC instance
  9685. * @retval None
  9686. */
  9687. __STATIC_INLINE void LL_ADC_Disable(ADC_TypeDef *ADCx)
  9688. {
  9689. CLEAR_BIT(ADCx->CR2, ADC_CR2_ADON);
  9690. }
  9691. /**
  9692. * @brief Get the selected ADC instance enable state.
  9693. * @rmtoll CR2 ADON LL_ADC_IsEnabled
  9694. * @param ADCx ADC instance
  9695. * @retval 0: ADC is disabled, 1: ADC is enabled.
  9696. */
  9697. __STATIC_INLINE uint32_t LL_ADC_IsEnabled(ADC_TypeDef *ADCx)
  9698. {
  9699. return (READ_BIT(ADCx->CR2, ADC_CR2_ADON) == (ADC_CR2_ADON));
  9700. }
  9701. /**
  9702. * @brief Start ADC calibration in the mode single-ended
  9703. * or differential (for devices with differential mode available).
  9704. * @note On this STM32 serie, before starting a calibration,
  9705. * ADC must be disabled.
  9706. * A minimum number of ADC clock cycles are required
  9707. * between ADC disable state and calibration start.
  9708. * Refer to literal @ref LL_ADC_DELAY_DISABLE_CALIB_ADC_CYCLES.
  9709. * @note On this STM32 serie, hardware prerequisite before starting a calibration:
  9710. the ADC must have been in power-on state for at least
  9711. two ADC clock cycles.
  9712. * @rmtoll CR2 CAL LL_ADC_StartCalibration
  9713. * @param ADCx ADC instance
  9714. * @retval None
  9715. */
  9716. __STATIC_INLINE void LL_ADC_StartCalibration(ADC_TypeDef *ADCx)
  9717. {
  9718. SET_BIT(ADCx->CR2, ADC_CR2_CAL);
  9719. }
  9720. /**
  9721. * @brief Get ADC calibration state.
  9722. * @rmtoll CR2 CAL LL_ADC_IsCalibrationOnGoing
  9723. * @param ADCx ADC instance
  9724. * @retval 0: calibration complete, 1: calibration in progress.
  9725. */
  9726. __STATIC_INLINE uint32_t LL_ADC_IsCalibrationOnGoing(ADC_TypeDef *ADCx)
  9727. {
  9728. return (READ_BIT(ADCx->CR2, ADC_CR2_CAL) == (ADC_CR2_CAL));
  9729. }
  9730. /**
  9731. * @}
  9732. */
  9733. /** @defgroup ADC_LL_EF_Operation_ADC_Group_Regular Operation on ADC hierarchical scope: group regular
  9734. * @{
  9735. */
  9736. /**
  9737. * @brief Start ADC group regular conversion.
  9738. * @note On this STM32 serie, this function is relevant for both
  9739. * internal trigger (SW start) and external trigger:
  9740. * - If ADC trigger has been set to software start, ADC conversion
  9741. * starts immediately.
  9742. * - If ADC trigger has been set to external trigger, ADC conversion
  9743. * will start at next trigger event (on the selected trigger edge)
  9744. * following the ADC start conversion command.
  9745. * @rmtoll CR2 EXTTRIG LL_ADC_REG_StartConversion
  9746. * @param ADCx ADC instance
  9747. * @retval None
  9748. */
  9749. __STATIC_INLINE void LL_ADC_REG_StartConversion(ADC_TypeDef *ADCx)
  9750. {
  9751. /* Note: Set bit ADC_CR2_SWSTART for case of trigger source set to */
  9752. /* SW start. In case of external trigger selected, this bit */
  9753. /* has no effect. */
  9754. SET_BIT(ADCx->CR2, (ADC_CR2_SWSTART | ADC_CR2_EXTTRIG));
  9755. }
  9756. /**
  9757. * @brief Stop ADC group regular conversion from external trigger.
  9758. * @note No more ADC conversion will start at next trigger event
  9759. * following the ADC stop conversion command.
  9760. * If a conversion is on-going, it will be completed.
  9761. * @note On this STM32 serie, there is no specific command
  9762. * to stop a conversion on-going or to stop ADC converting
  9763. * in continuous mode. These actions can be performed
  9764. * using function @ref LL_ADC_Disable().
  9765. * @rmtoll CR2 EXTSEL LL_ADC_REG_StopConversionExtTrig
  9766. * @param ADCx ADC instance
  9767. * @retval None
  9768. */
  9769. __STATIC_INLINE void LL_ADC_REG_StopConversionExtTrig(ADC_TypeDef *ADCx)
  9770. {
  9771. SET_BIT(ADCx->CR2, ADC_CR2_EXTSEL);
  9772. }
  9773. /**
  9774. * @brief Get ADC group regular conversion data, range fit for
  9775. * all ADC configurations: all ADC resolutions and
  9776. * all oversampling increased data width (for devices
  9777. * with feature oversampling).
  9778. * @rmtoll DR RDATA LL_ADC_REG_ReadConversionData32
  9779. * @param ADCx ADC instance
  9780. * @retval Value between Min_Data=0x00000000 and Max_Data=0xFFFFFFFF
  9781. */
  9782. __STATIC_INLINE uint32_t LL_ADC_REG_ReadConversionData32(ADC_TypeDef *ADCx)
  9783. {
  9784. return (uint16_t)(READ_BIT(ADCx->DR, ADC_DR_DATA));
  9785. }
  9786. /**
  9787. * @brief Get ADC group regular conversion data, range fit for
  9788. * ADC resolution 12 bits.
  9789. * @note For devices with feature oversampling: Oversampling
  9790. * can increase data width, function for extended range
  9791. * may be needed: @ref LL_ADC_REG_ReadConversionData32.
  9792. * @rmtoll DR RDATA LL_ADC_REG_ReadConversionData12
  9793. * @param ADCx ADC instance
  9794. * @retval Value between Min_Data=0x000 and Max_Data=0xFFF
  9795. */
  9796. __STATIC_INLINE uint16_t LL_ADC_REG_ReadConversionData12(ADC_TypeDef *ADCx)
  9797. {
  9798. return (uint16_t)(READ_BIT(ADCx->DR, ADC_DR_DATA));
  9799. }
  9800. /**
  9801. * @}
  9802. */
  9803. /** @defgroup ADC_LL_EF_Operation_ADC_Group_Injected Operation on ADC hierarchical scope: group injected
  9804. * @{
  9805. */
  9806. /**
  9807. * @brief Start ADC group injected conversion.
  9808. * @note On this STM32 serie, this function is relevant for both
  9809. * internal trigger (SW start) and external trigger:
  9810. * - If ADC trigger has been set to software start, ADC conversion
  9811. * starts immediately.
  9812. * - If ADC trigger has been set to external trigger, ADC conversion
  9813. * will start at next trigger event (on the selected trigger edge)
  9814. * following the ADC start conversion command.
  9815. * @rmtoll CR2 JEXTTRIG LL_ADC_REG_StartConversion
  9816. * @param ADCx ADC instance
  9817. * @retval None
  9818. */
  9819. __STATIC_INLINE void LL_ADC_INJ_StartConversion(ADC_TypeDef *ADCx)
  9820. {
  9821. /* Note: Set bit ADC_CR2_JSWSTART for case of trigger source set to */
  9822. /* SW start. In case of external trigger selected, this bit */
  9823. /* has no effect. */
  9824. SET_BIT(ADCx->CR2, (ADC_CR2_JSWSTART | ADC_CR2_JEXTTRIG));
  9825. }
  9826. /**
  9827. * @brief Stop ADC group injected conversion from external trigger.
  9828. * @note No more ADC conversion will start at next trigger event
  9829. * following the ADC stop conversion command.
  9830. * If a conversion is on-going, it will be completed.
  9831. * @note On this STM32 serie, there is no specific command
  9832. * to stop a conversion on-going or to stop ADC converting
  9833. * in continuous mode. These actions can be performed
  9834. * using function @ref LL_ADC_Disable().
  9835. * @rmtoll CR2 JEXTSEL LL_ADC_INJ_StopConversionExtTrig
  9836. * @param ADCx ADC instance
  9837. * @retval None
  9838. */
  9839. __STATIC_INLINE void LL_ADC_INJ_StopConversionExtTrig(ADC_TypeDef *ADCx)
  9840. {
  9841. SET_BIT(ADCx->CR2, ADC_CR2_JEXTSEL);
  9842. }
  9843. /**
  9844. * @brief Get ADC group regular conversion data, range fit for
  9845. * all ADC configurations: all ADC resolutions and
  9846. * all oversampling increased data width (for devices
  9847. * with feature oversampling).
  9848. * @rmtoll JDR1 JDATA LL_ADC_INJ_ReadConversionData32\n
  9849. * JDR2 JDATA LL_ADC_INJ_ReadConversionData32\n
  9850. * JDR3 JDATA LL_ADC_INJ_ReadConversionData32\n
  9851. * JDR4 JDATA LL_ADC_INJ_ReadConversionData32
  9852. * @param ADCx ADC instance
  9853. * @param Rank This parameter can be one of the following values:
  9854. * @arg @ref LL_ADC_INJ_RANK_1
  9855. * @arg @ref LL_ADC_INJ_RANK_2
  9856. * @arg @ref LL_ADC_INJ_RANK_3
  9857. * @arg @ref LL_ADC_INJ_RANK_4
  9858. * @retval Value between Min_Data=0x00000000 and Max_Data=0xFFFFFFFF
  9859. */
  9860. __STATIC_INLINE uint32_t LL_ADC_INJ_ReadConversionData32(ADC_TypeDef *ADCx, uint32_t Rank)
  9861. {
  9862. register uint32_t *preg = __ADC_PTR_REG_OFFSET(ADCx->JDR1, __ADC_MASK_SHIFT(Rank, ADC_INJ_JDRX_REGOFFSET_MASK));
  9863. return (uint32_t)(READ_BIT(*preg,
  9864. ADC_JDR1_JDATA)
  9865. );
  9866. }
  9867. /**
  9868. * @brief Get ADC group injected conversion data, range fit for
  9869. * ADC resolution 12 bits.
  9870. * @note For devices with feature oversampling: Oversampling
  9871. * can increase data width, function for extended range
  9872. * may be needed: @ref LL_ADC_INJ_ReadConversionData32.
  9873. * @rmtoll JDR1 JDATA LL_ADC_INJ_ReadConversionData12\n
  9874. * JDR2 JDATA LL_ADC_INJ_ReadConversionData12\n
  9875. * JDR3 JDATA LL_ADC_INJ_ReadConversionData12\n
  9876. * JDR4 JDATA LL_ADC_INJ_ReadConversionData12
  9877. * @param ADCx ADC instance
  9878. * @param Rank This parameter can be one of the following values:
  9879. * @arg @ref LL_ADC_INJ_RANK_1
  9880. * @arg @ref LL_ADC_INJ_RANK_2
  9881. * @arg @ref LL_ADC_INJ_RANK_3
  9882. * @arg @ref LL_ADC_INJ_RANK_4
  9883. * @retval Value between Min_Data=0x000 and Max_Data=0xFFF
  9884. */
  9885. __STATIC_INLINE uint16_t LL_ADC_INJ_ReadConversionData12(ADC_TypeDef *ADCx, uint32_t Rank)
  9886. {
  9887. register uint32_t *preg = __ADC_PTR_REG_OFFSET(ADCx->JDR1, __ADC_MASK_SHIFT(Rank, ADC_INJ_JDRX_REGOFFSET_MASK));
  9888. return (uint16_t)(READ_BIT(*preg,
  9889. ADC_JDR1_JDATA)
  9890. );
  9891. }
  9892. /**
  9893. * @}
  9894. */
  9895. /** @defgroup ADC_LL_EF_FLAG_Management ADC flag management
  9896. * @{
  9897. */
  9898. /**
  9899. * @brief Get flag ADC group regular end of sequence conversions.
  9900. * @rmtoll SR EOC LL_ADC_IsActiveFlag_EOS
  9901. * @param ADCx ADC instance
  9902. * @retval State of bit (1 or 0).
  9903. */
  9904. __STATIC_INLINE uint32_t LL_ADC_IsActiveFlag_EOS(ADC_TypeDef *ADCx)
  9905. {
  9906. /* Note: on this STM32 serie, there is no flag ADC group regular */
  9907. /* end of unitary conversion. */
  9908. /* Flag noted as "EOC" is corresponding to flag "EOS" */
  9909. /* in other STM32 families). */
  9910. return (READ_BIT(ADCx->SR, LL_ADC_FLAG_EOS) == (LL_ADC_FLAG_EOS));
  9911. }
  9912. /**
  9913. * @brief Get flag ADC group injected end of sequence conversions.
  9914. * @rmtoll SR JEOC LL_ADC_IsActiveFlag_JEOS
  9915. * @param ADCx ADC instance
  9916. * @retval State of bit (1 or 0).
  9917. */
  9918. __STATIC_INLINE uint32_t LL_ADC_IsActiveFlag_JEOS(ADC_TypeDef *ADCx)
  9919. {
  9920. /* Note: on this STM32 serie, there is no flag ADC group injected */
  9921. /* end of unitary conversion. */
  9922. /* Flag noted as "JEOC" is corresponding to flag "JEOS" */
  9923. /* in other STM32 families). */
  9924. return (READ_BIT(ADCx->SR, LL_ADC_FLAG_JEOS) == (LL_ADC_FLAG_JEOS));
  9925. }
  9926. /**
  9927. * @brief Get flag ADC analog watchdog 1 flag
  9928. * @rmtoll SR AWD LL_ADC_IsActiveFlag_AWD1
  9929. * @param ADCx ADC instance
  9930. * @retval State of bit (1 or 0).
  9931. */
  9932. __STATIC_INLINE uint32_t LL_ADC_IsActiveFlag_AWD1(ADC_TypeDef *ADCx)
  9933. {
  9934. return (READ_BIT(ADCx->SR, LL_ADC_FLAG_AWD1) == (LL_ADC_FLAG_AWD1));
  9935. }
  9936. /**
  9937. * @brief Clear flag ADC group regular end of sequence conversions.
  9938. * @rmtoll SR EOC LL_ADC_ClearFlag_EOS
  9939. * @param ADCx ADC instance
  9940. * @retval None
  9941. */
  9942. __STATIC_INLINE void LL_ADC_ClearFlag_EOS(ADC_TypeDef *ADCx)
  9943. {
  9944. /* Note: on this STM32 serie, there is no flag ADC group regular */
  9945. /* end of unitary conversion. */
  9946. /* Flag noted as "EOC" is corresponding to flag "EOS" */
  9947. /* in other STM32 families). */
  9948. WRITE_REG(ADCx->SR, ~LL_ADC_FLAG_EOS);
  9949. }
  9950. /**
  9951. * @brief Clear flag ADC group injected end of sequence conversions.
  9952. * @rmtoll SR JEOC LL_ADC_ClearFlag_JEOS
  9953. * @param ADCx ADC instance
  9954. * @retval None
  9955. */
  9956. __STATIC_INLINE void LL_ADC_ClearFlag_JEOS(ADC_TypeDef *ADCx)
  9957. {
  9958. /* Note: on this STM32 serie, there is no flag ADC group injected */
  9959. /* end of unitary conversion. */
  9960. /* Flag noted as "JEOC" is corresponding to flag "JEOS" */
  9961. /* in other STM32 families). */
  9962. WRITE_REG(ADCx->SR, ~LL_ADC_FLAG_JEOS);
  9963. }
  9964. /**
  9965. * @brief Clear flag ADC analog watchdog 1.
  9966. * @rmtoll SR AWD LL_ADC_ClearFlag_AWD1
  9967. * @param ADCx ADC instance
  9968. * @retval None
  9969. */
  9970. __STATIC_INLINE void LL_ADC_ClearFlag_AWD1(ADC_TypeDef *ADCx)
  9971. {
  9972. WRITE_REG(ADCx->SR, ~LL_ADC_FLAG_AWD1);
  9973. }
  9974. /**
  9975. * @}
  9976. */
  9977. /** @defgroup ADC_LL_EF_IT_Management ADC IT management
  9978. * @{
  9979. */
  9980. /**
  9981. * @brief Enable interruption ADC group regular end of sequence conversions.
  9982. * @rmtoll CR1 EOCIE LL_ADC_EnableIT_EOS
  9983. * @param ADCx ADC instance
  9984. * @retval None
  9985. */
  9986. __STATIC_INLINE void LL_ADC_EnableIT_EOS(ADC_TypeDef *ADCx)
  9987. {
  9988. /* Note: on this STM32 serie, there is no flag ADC group regular */
  9989. /* end of unitary conversion. */
  9990. /* Flag noted as "EOC" is corresponding to flag "EOS" */
  9991. /* in other STM32 families). */
  9992. SET_BIT(ADCx->CR1, ADC_CR1_EOCIE);
  9993. }
  9994. /**
  9995. * @brief Enable interruption ADC group injected end of sequence conversions.
  9996. * @rmtoll CR1 JEOCIE LL_ADC_EnableIT_JEOS
  9997. * @param ADCx ADC instance
  9998. * @retval None
  9999. */
  10000. __STATIC_INLINE void LL_ADC_EnableIT_JEOS(ADC_TypeDef *ADCx)
  10001. {
  10002. /* Note: on this STM32 serie, there is no flag ADC group injected */
  10003. /* end of unitary conversion. */
  10004. /* Flag noted as "JEOC" is corresponding to flag "JEOS" */
  10005. /* in other STM32 families). */
  10006. SET_BIT(ADCx->CR1, LL_ADC_IT_JEOS);
  10007. }
  10008. /**
  10009. * @brief Enable interruption ADC analog watchdog 1.
  10010. * @rmtoll CR1 AWDIE LL_ADC_EnableIT_AWD1
  10011. * @param ADCx ADC instance
  10012. * @retval None
  10013. */
  10014. __STATIC_INLINE void LL_ADC_EnableIT_AWD1(ADC_TypeDef *ADCx)
  10015. {
  10016. SET_BIT(ADCx->CR1, LL_ADC_IT_AWD1);
  10017. }
  10018. /**
  10019. * @brief Disable interruption ADC group regular end of sequence conversions.
  10020. * @rmtoll CR1 EOCIE LL_ADC_DisableIT_EOS
  10021. * @param ADCx ADC instance
  10022. * @retval None
  10023. */
  10024. __STATIC_INLINE void LL_ADC_DisableIT_EOS(ADC_TypeDef *ADCx)
  10025. {
  10026. /* Note: on this STM32 serie, there is no flag ADC group regular */
  10027. /* end of unitary conversion. */
  10028. /* Flag noted as "EOC" is corresponding to flag "EOS" */
  10029. /* in other STM32 families). */
  10030. CLEAR_BIT(ADCx->CR1, ADC_CR1_EOCIE);
  10031. }
  10032. /**
  10033. * @brief Disable interruption ADC group injected end of sequence conversions.
  10034. * @rmtoll CR1 JEOCIE LL_ADC_EnableIT_JEOS
  10035. * @param ADCx ADC instance
  10036. * @retval None
  10037. */
  10038. __STATIC_INLINE void LL_ADC_DisableIT_JEOS(ADC_TypeDef *ADCx)
  10039. {
  10040. /* Note: on this STM32 serie, there is no flag ADC group injected */
  10041. /* end of unitary conversion. */
  10042. /* Flag noted as "JEOC" is corresponding to flag "JEOS" */
  10043. /* in other STM32 families). */
  10044. CLEAR_BIT(ADCx->CR1, LL_ADC_IT_JEOS);
  10045. }
  10046. /**
  10047. * @brief Disable interruption ADC analog watchdog 1.
  10048. * @rmtoll CR1 AWDIE LL_ADC_EnableIT_AWD1
  10049. * @param ADCx ADC instance
  10050. * @retval None
  10051. */
  10052. __STATIC_INLINE void LL_ADC_DisableIT_AWD1(ADC_TypeDef *ADCx)
  10053. {
  10054. CLEAR_BIT(ADCx->CR1, LL_ADC_IT_AWD1);
  10055. }
  10056. /**
  10057. * @brief Get state of interruption ADC group regular end of sequence conversions
  10058. * (0: interrupt disabled, 1: interrupt enabled).
  10059. * @rmtoll CR1 EOCIE LL_ADC_IsEnabledIT_EOS
  10060. * @param ADCx ADC instance
  10061. * @retval State of bit (1 or 0).
  10062. */
  10063. __STATIC_INLINE uint32_t LL_ADC_IsEnabledIT_EOS(ADC_TypeDef *ADCx)
  10064. {
  10065. /* Note: on this STM32 serie, there is no flag ADC group regular */
  10066. /* end of unitary conversion. */
  10067. /* Flag noted as "EOC" is corresponding to flag "EOS" */
  10068. /* in other STM32 families). */
  10069. return (READ_BIT(ADCx->CR1, LL_ADC_IT_EOS) == (LL_ADC_IT_EOS));
  10070. }
  10071. /**
  10072. * @brief Get state of interruption ADC group injected end of sequence conversions
  10073. * (0: interrupt disabled, 1: interrupt enabled).
  10074. * @rmtoll CR1 JEOCIE LL_ADC_EnableIT_JEOS
  10075. * @param ADCx ADC instance
  10076. * @retval State of bit (1 or 0).
  10077. */
  10078. __STATIC_INLINE uint32_t LL_ADC_IsEnabledIT_JEOS(ADC_TypeDef *ADCx)
  10079. {
  10080. /* Note: on this STM32 serie, there is no flag ADC group injected */
  10081. /* end of unitary conversion. */
  10082. /* Flag noted as "JEOC" is corresponding to flag "JEOS" */
  10083. /* in other STM32 families). */
  10084. return (READ_BIT(ADCx->CR1, LL_ADC_IT_JEOS) == (LL_ADC_IT_JEOS));
  10085. }
  10086. /**
  10087. * @brief Get state of interruption ADC analog watchdog 1
  10088. * (0: interrupt disabled, 1: interrupt enabled).
  10089. * @rmtoll CR1 AWDIE LL_ADC_EnableIT_AWD1
  10090. * @param ADCx ADC instance
  10091. * @retval State of bit (1 or 0).
  10092. */
  10093. __STATIC_INLINE uint32_t LL_ADC_IsEnabledIT_AWD1(ADC_TypeDef *ADCx)
  10094. {
  10095. return (READ_BIT(ADCx->CR1, LL_ADC_IT_AWD1) == (LL_ADC_IT_AWD1));
  10096. }
  10097. /**
  10098. * @}
  10099. */
  10100. #if defined(USE_FULL_LL_DRIVER)
  10101. /** @defgroup ADC_LL_EF_Init Initialization and de-initialization functions
  10102. * @{
  10103. */
  10104. /* Initialization of some features of ADC common parameters and multimode */
  10105. /* Note: On STM32F37x ADC, there is no ADC common initialization */
  10106. /* function. */
  10107. ErrorStatus LL_ADC_CommonDeInit(ADC_Common_TypeDef *ADCxy_COMMON);
  10108. /* De-initialization of ADC instance, ADC group regular and ADC group injected */
  10109. /* (availability of ADC group injected depends on STM32 families) */
  10110. ErrorStatus LL_ADC_DeInit(ADC_TypeDef *ADCx);
  10111. /* Initialization of some features of ADC instance */
  10112. ErrorStatus LL_ADC_Init(ADC_TypeDef *ADCx, LL_ADC_InitTypeDef *ADC_InitStruct);
  10113. void LL_ADC_StructInit(LL_ADC_InitTypeDef *ADC_InitStruct);
  10114. /* Initialization of some features of ADC instance and ADC group regular */
  10115. ErrorStatus LL_ADC_REG_Init(ADC_TypeDef *ADCx, LL_ADC_REG_InitTypeDef *ADC_REG_InitStruct);
  10116. void LL_ADC_REG_StructInit(LL_ADC_REG_InitTypeDef *ADC_REG_InitStruct);
  10117. /* Initialization of some features of ADC instance and ADC group injected */
  10118. ErrorStatus LL_ADC_INJ_Init(ADC_TypeDef *ADCx, LL_ADC_INJ_InitTypeDef *ADC_INJ_InitStruct);
  10119. void LL_ADC_INJ_StructInit(LL_ADC_INJ_InitTypeDef *ADC_INJ_InitStruct);
  10120. /**
  10121. * @}
  10122. */
  10123. #endif /* USE_FULL_LL_DRIVER */
  10124. /**
  10125. * @}
  10126. */
  10127. /**
  10128. * @}
  10129. */
  10130. #endif /* ADC1 */
  10131. #endif /* STM32F373xC || STM32F378xx */
  10132. /**
  10133. * @}
  10134. */
  10135. #ifdef __cplusplus
  10136. }
  10137. #endif
  10138. #endif /* __STM32F3xx_LL_ADC_H */
  10139. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/