stm32l4xx_ll_adc.h 414 KB

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