stm32l5xx_ll_adc.h 431 KB

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