stm32h5xx_ll_adc.h 445 KB

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