stm32f3xx_ll_adc.h 645 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829
  1. /**
  2. ******************************************************************************
  3. * @file stm32f3xx_ll_adc.h
  4. * @author MCD Application Team
  5. * @brief Header file of ADC LL module.
  6. ******************************************************************************
  7. * @attention
  8. *
  9. * Copyright (c) 2016 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 __STM32F3xx_LL_ADC_H
  20. #define __STM32F3xx_LL_ADC_H
  21. #ifdef __cplusplus
  22. extern "C" {
  23. #endif
  24. /* Includes ------------------------------------------------------------------*/
  25. #include "stm32f3xx.h"
  26. /** @addtogroup STM32F3xx_LL_Driver
  27. * @{
  28. */
  29. /* Note: Devices of STM32F3 series embed 1 out of 2 different ADC IP. */
  30. /* - STM32F30x, STM32F31x, STM32F32x, STM32F33x, STM32F35x, STM32F39x: */
  31. /* ADC IP 5Msamples/sec, from 1 to 4 ADC instances and other specific */
  32. /* features (refer to reference manual). */
  33. /* - STM32F37x: */
  34. /* ADC IP 1Msamples/sec, 1 ADC instance */
  35. /* This file contains the drivers of these ADC IP, located in 2 area */
  36. /* delimited by compilation switches. */
  37. #if defined(ADC5_V1_1)
  38. #if defined (ADC1) || defined (ADC2) || defined (ADC3) || defined (ADC4)
  39. /** @defgroup ADC_LL ADC
  40. * @{
  41. */
  42. /* Private types -------------------------------------------------------------*/
  43. /* Private variables ---------------------------------------------------------*/
  44. /* Private constants ---------------------------------------------------------*/
  45. /** @defgroup ADC_LL_Private_Constants ADC Private Constants
  46. * @{
  47. */
  48. /* Internal mask for ADC group regular sequencer: */
  49. /* To select into literal LL_ADC_REG_RANK_x the relevant bits for: */
  50. /* - sequencer register offset */
  51. /* - sequencer rank bits position into the selected register */
  52. /* Internal register offset for ADC group regular sequencer configuration */
  53. /* (offset placed into a spare area of literal definition) */
  54. #define ADC_SQR1_REGOFFSET ((uint32_t)0x00000000U)
  55. #define ADC_SQR2_REGOFFSET ((uint32_t)0x00000100U)
  56. #define ADC_SQR3_REGOFFSET ((uint32_t)0x00000200U)
  57. #define ADC_SQR4_REGOFFSET ((uint32_t)0x00000300U)
  58. #define ADC_REG_SQRX_REGOFFSET_MASK (ADC_SQR1_REGOFFSET | ADC_SQR2_REGOFFSET | ADC_SQR3_REGOFFSET | ADC_SQR4_REGOFFSET)
  59. #define ADC_REG_RANK_ID_SQRX_MASK (ADC_CHANNEL_ID_NUMBER_MASK_POSBIT0)
  60. /* Definition of ADC group regular sequencer bits information to be inserted */
  61. /* into ADC group regular sequencer ranks literals definition. */
  62. #define ADC_REG_RANK_1_SQRX_BITOFFSET_POS ((uint32_t) 6U) /* Value equivalent to POSITION_VAL(ADC_SQR1_SQ1) */
  63. #define ADC_REG_RANK_2_SQRX_BITOFFSET_POS ((uint32_t)12U) /* Value equivalent to POSITION_VAL(ADC_SQR1_SQ2) */
  64. #define ADC_REG_RANK_3_SQRX_BITOFFSET_POS ((uint32_t)18U) /* Value equivalent to POSITION_VAL(ADC_SQR1_SQ3) */
  65. #define ADC_REG_RANK_4_SQRX_BITOFFSET_POS ((uint32_t)24U) /* Value equivalent to POSITION_VAL(ADC_SQR1_SQ4) */
  66. #define ADC_REG_RANK_5_SQRX_BITOFFSET_POS ((uint32_t) 0U) /* Value equivalent to POSITION_VAL(ADC_SQR2_SQ5) */
  67. #define ADC_REG_RANK_6_SQRX_BITOFFSET_POS ((uint32_t) 6U) /* Value equivalent to POSITION_VAL(ADC_SQR2_SQ6) */
  68. #define ADC_REG_RANK_7_SQRX_BITOFFSET_POS ((uint32_t)12U) /* Value equivalent to POSITION_VAL(ADC_SQR2_SQ7) */
  69. #define ADC_REG_RANK_8_SQRX_BITOFFSET_POS ((uint32_t)18U) /* Value equivalent to POSITION_VAL(ADC_SQR2_SQ8) */
  70. #define ADC_REG_RANK_9_SQRX_BITOFFSET_POS ((uint32_t)24U) /* Value equivalent to POSITION_VAL(ADC_SQR2_SQ9) */
  71. #define ADC_REG_RANK_10_SQRX_BITOFFSET_POS ((uint32_t) 0U) /* Value equivalent to POSITION_VAL(ADC_SQR3_SQ10) */
  72. #define ADC_REG_RANK_11_SQRX_BITOFFSET_POS ((uint32_t) 6U) /* Value equivalent to POSITION_VAL(ADC_SQR3_SQ11) */
  73. #define ADC_REG_RANK_12_SQRX_BITOFFSET_POS ((uint32_t)12U) /* Value equivalent to POSITION_VAL(ADC_SQR3_SQ12) */
  74. #define ADC_REG_RANK_13_SQRX_BITOFFSET_POS ((uint32_t)18U) /* Value equivalent to POSITION_VAL(ADC_SQR3_SQ13) */
  75. #define ADC_REG_RANK_14_SQRX_BITOFFSET_POS ((uint32_t)24U) /* Value equivalent to POSITION_VAL(ADC_SQR3_SQ14) */
  76. #define ADC_REG_RANK_15_SQRX_BITOFFSET_POS ((uint32_t) 0U) /* Value equivalent to POSITION_VAL(ADC_SQR4_SQ15) */
  77. #define ADC_REG_RANK_16_SQRX_BITOFFSET_POS ((uint32_t) 6U) /* Value equivalent to POSITION_VAL(ADC_SQR4_SQ16) */
  78. /* Internal mask for ADC group injected sequencer: */
  79. /* To select into literal LL_ADC_INJ_RANK_x the relevant bits for: */
  80. /* - data register offset */
  81. /* - sequencer rank bits position into the selected register */
  82. /* Internal register offset for ADC group injected data register */
  83. /* (offset placed into a spare area of literal definition) */
  84. #define ADC_JDR1_REGOFFSET ((uint32_t)0x00000000U)
  85. #define ADC_JDR2_REGOFFSET ((uint32_t)0x00000100U)
  86. #define ADC_JDR3_REGOFFSET ((uint32_t)0x00000200U)
  87. #define ADC_JDR4_REGOFFSET ((uint32_t)0x00000300U)
  88. #define ADC_INJ_JDRX_REGOFFSET_MASK (ADC_JDR1_REGOFFSET | ADC_JDR2_REGOFFSET | ADC_JDR3_REGOFFSET | ADC_JDR4_REGOFFSET)
  89. #define ADC_INJ_RANK_ID_JSQR_MASK (ADC_CHANNEL_ID_NUMBER_MASK_POSBIT0)
  90. /* Definition of ADC group injected sequencer bits information to be inserted */
  91. /* into ADC group injected sequencer ranks literals definition. */
  92. #define ADC_INJ_RANK_1_JSQR_BITOFFSET_POS ((uint32_t) 8U) /* Value equivalent to POSITION_VAL(ADC_JSQR_JSQ1) */
  93. #define ADC_INJ_RANK_2_JSQR_BITOFFSET_POS ((uint32_t)14U) /* Value equivalent to POSITION_VAL(ADC_JSQR_JSQ2) */
  94. #define ADC_INJ_RANK_3_JSQR_BITOFFSET_POS ((uint32_t)20U) /* Value equivalent to POSITION_VAL(ADC_JSQR_JSQ3) */
  95. #define ADC_INJ_RANK_4_JSQR_BITOFFSET_POS ((uint32_t)26U) /* Value equivalent to POSITION_VAL(ADC_JSQR_JSQ4) */
  96. /* Internal mask for ADC group regular trigger: */
  97. /* To select into literal LL_ADC_REG_TRIG_x the relevant bits for: */
  98. /* - regular trigger source */
  99. /* - regular trigger edge */
  100. #define ADC_REG_TRIG_EXT_EDGE_DEFAULT (ADC_CFGR_EXTEN_0) /* Trigger edge set to rising edge (default setting for compatibility with some ADC on other STM32 families having this setting set by HW default value) */
  101. /* Mask containing trigger source masks for each of possible */
  102. /* trigger edge selection duplicated with shifts [0; 4; 8; 12] */
  103. /* corresponding to {SW start; ext trigger; ext trigger; ext trigger}. */
  104. #define ADC_REG_TRIG_SOURCE_MASK (((LL_ADC_REG_TRIG_SOFTWARE & ADC_CFGR_EXTSEL) << (4U * 0U)) | \
  105. ((ADC_CFGR_EXTSEL) << (4U * 1U)) | \
  106. ((ADC_CFGR_EXTSEL) << (4U * 2U)) | \
  107. ((ADC_CFGR_EXTSEL) << (4U * 3U)) )
  108. /* Mask containing trigger edge masks for each of possible */
  109. /* trigger edge selection duplicated with shifts [0; 4; 8; 12] */
  110. /* corresponding to {SW start; ext trigger; ext trigger; ext trigger}. */
  111. #define ADC_REG_TRIG_EDGE_MASK (((LL_ADC_REG_TRIG_SOFTWARE & ADC_CFGR_EXTEN) << (4U * 0U)) | \
  112. ((ADC_REG_TRIG_EXT_EDGE_DEFAULT) << (4U * 1U)) | \
  113. ((ADC_REG_TRIG_EXT_EDGE_DEFAULT) << (4U * 2U)) | \
  114. ((ADC_REG_TRIG_EXT_EDGE_DEFAULT) << (4U * 3U)) )
  115. /* Definition of ADC group regular trigger bits information. */
  116. #define ADC_REG_TRIG_EXTSEL_BITOFFSET_POS ((uint32_t) 6U) /* Value equivalent to POSITION_VAL(ADC_CFGR_EXTSEL) */
  117. #define ADC_REG_TRIG_EXTEN_BITOFFSET_POS ((uint32_t)10U) /* Value equivalent to POSITION_VAL(ADC_CFGR_EXTEN) */
  118. /* Internal definitions for ADC group regular trigger sources: */
  119. /* To differentiate into literal LL_ADC_REG_TRIG_x the trigger sources */
  120. /* depending on ADC instances ADC1, ADC2, ADC3, ADC4 (if ADC instance is */
  121. /* available on the selected device). */
  122. #if defined(STM32F303xC) || defined(STM32F358xx) || defined(STM32F303xE) || defined(STM32F398xx)
  123. /* Internal mask offset for ADC group injected trigger sources */
  124. /* available only on specific ADC instances. */
  125. /* (offset placed into a spare area of literal definition) */
  126. #define ADC_REG_TRIG_EXT_INST_ADC12 ((uint32_t)0x00000001U) /* Marker for differentiation of ADC group regular external trigger available only on ADC instance: ADC1, ADC2 */
  127. #define ADC_REG_TRIG_EXT_INST_ADC34 ((uint32_t)0x00000002U) /* Marker for differentiation of ADC group regular external trigger available only on ADC instance: ADC3, ADC4 */
  128. #endif
  129. /* Internal mask for ADC group injected trigger: */
  130. /* To select into literal LL_ADC_INJ_TRIG_x the relevant bits for: */
  131. /* - injected trigger source */
  132. /* - injected trigger edge */
  133. #define ADC_INJ_TRIG_EXT_EDGE_DEFAULT (ADC_JSQR_JEXTEN_0) /* Trigger edge set to rising edge (default setting for compatibility with some ADC on other STM32 families having this setting set by HW default value) */
  134. /* Mask containing trigger source masks for each of possible */
  135. /* trigger edge selection duplicated with shifts [0; 4; 8; 12] */
  136. /* corresponding to {SW start; ext trigger; ext trigger; ext trigger}. */
  137. #define ADC_INJ_TRIG_SOURCE_MASK (((LL_ADC_INJ_TRIG_SOFTWARE & ADC_JSQR_JEXTSEL) << (4U * 0U)) | \
  138. ((ADC_JSQR_JEXTSEL) << (4U * 1U)) | \
  139. ((ADC_JSQR_JEXTSEL) << (4U * 2U)) | \
  140. ((ADC_JSQR_JEXTSEL) << (4U * 3U)) )
  141. /* Mask containing trigger edge masks for each of possible */
  142. /* trigger edge selection duplicated with shifts [0; 4; 8; 12] */
  143. /* corresponding to {SW start; ext trigger; ext trigger; ext trigger}. */
  144. #define ADC_INJ_TRIG_EDGE_MASK (((LL_ADC_INJ_TRIG_SOFTWARE & ADC_JSQR_JEXTEN) << (4U * 0U)) | \
  145. ((ADC_INJ_TRIG_EXT_EDGE_DEFAULT) << (4U * 1U)) | \
  146. ((ADC_INJ_TRIG_EXT_EDGE_DEFAULT) << (4U * 2U)) | \
  147. ((ADC_INJ_TRIG_EXT_EDGE_DEFAULT) << (4U * 3U)) )
  148. /* Definition of ADC group injected trigger bits information. */
  149. #define ADC_INJ_TRIG_EXTSEL_BITOFFSET_POS ((uint32_t) 2U) /* Value equivalent to POSITION_VAL(ADC_JSQR_JEXTSEL) */
  150. #define ADC_INJ_TRIG_EXTEN_BITOFFSET_POS ((uint32_t) 6U) /* Value equivalent to POSITION_VAL(ADC_JSQR_JEXTEN) */
  151. /* Internal definitions for ADC group injected trigger sources: */
  152. /* To differentiate into literal LL_ADC_INJ_TRIG_x the trigger sources */
  153. /* depending on ADC instances ADC1, ADC2, ADC3, ADC4 (if ADC instance is */
  154. /* available on the selected device). */
  155. #if defined(STM32F303xC) || defined(STM32F358xx) || defined(STM32F303xE) || defined(STM32F398xx)
  156. /* Internal mask offset for ADC group injected trigger sources */
  157. /* available only on specific ADC instances. */
  158. /* (offset placed into a spare area of literal definition) */
  159. #define ADC_INJ_TRIG_EXT_INST_ADC12 ((uint32_t)0x00000001U) /* Marker for differentiation of ADC group injected external trigger available only on ADC instance: ADC1, ADC2 */
  160. #define ADC_INJ_TRIG_EXT_INST_ADC34 ((uint32_t)0x00000002U) /* Marker for differentiation of ADC group injected external trigger available only on ADC instance: ADC3, ADC4 */
  161. #endif
  162. /* Internal mask for ADC channel: */
  163. /* To select into literal LL_ADC_CHANNEL_x the relevant bits for: */
  164. /* - channel identifier defined by number */
  165. /* - channel identifier defined by bitfield */
  166. /* - channel differentiation between external channels (connected to */
  167. /* GPIO pins) and internal channels (connected to internal paths) */
  168. /* - channel sampling time defined by SMPRx register offset */
  169. /* and SMPx bits positions into SMPRx register */
  170. #define ADC_CHANNEL_ID_NUMBER_MASK (ADC_CFGR_AWD1CH)
  171. #define ADC_CHANNEL_ID_BITFIELD_MASK (ADC_AWD2CR_AWD2CH)
  172. #define ADC_CHANNEL_ID_NUMBER_BITOFFSET_POS ((uint32_t)26U)/* Value equivalent to POSITION_VAL(ADC_CHANNEL_ID_NUMBER_MASK) */
  173. #define ADC_CHANNEL_ID_MASK (ADC_CHANNEL_ID_NUMBER_MASK | ADC_CHANNEL_ID_BITFIELD_MASK | ADC_CHANNEL_ID_INTERNAL_CH_MASK)
  174. /* Equivalent mask of ADC_CHANNEL_NUMBER_MASK aligned on register LSB (bit 0) */
  175. #define ADC_CHANNEL_ID_NUMBER_MASK_POSBIT0 (ADC_SQR2_SQ5) /* Equivalent to shift: (ADC_CHANNEL_NUMBER_MASK >> POSITION_VAL(ADC_CHANNEL_NUMBER_MASK)) */
  176. /* Channel differentiation between external and internal channels */
  177. #define ADC_CHANNEL_ID_INTERNAL_CH ((uint32_t)0x80000000U) /* Marker of internal channel */
  178. #define ADC_CHANNEL_ID_INTERNAL_CH_2 ((uint32_t)0x00080000U) /* Marker of internal channel for other ADC instances, in case of different ADC internal channels mapped on same channel number on different ADC instances */
  179. #define ADC_CHANNEL_ID_INTERNAL_CH_MASK (ADC_CHANNEL_ID_INTERNAL_CH | ADC_CHANNEL_ID_INTERNAL_CH_2)
  180. /* Internal register offset for ADC channel sampling time configuration */
  181. /* (offset placed into a spare area of literal definition) */
  182. #define ADC_SMPR1_REGOFFSET ((uint32_t)0x00000000U)
  183. #define ADC_SMPR2_REGOFFSET ((uint32_t)0x02000000U)
  184. #define ADC_CHANNEL_SMPRX_REGOFFSET_MASK (ADC_SMPR1_REGOFFSET | ADC_SMPR2_REGOFFSET)
  185. #define ADC_CHANNEL_SMPx_BITOFFSET_MASK ((uint32_t)0x01F00000U)
  186. #define ADC_CHANNEL_SMPx_BITOFFSET_POS ((uint32_t)20U) /* Value equivalent to POSITION_VAL(ADC_CHANNEL_SMPx_BITOFFSET_MASK) */
  187. /* Definition of channels ID number information to be inserted into */
  188. /* channels literals definition. */
  189. #define ADC_CHANNEL_0_NUMBER ((uint32_t)0x00000000U)
  190. #define ADC_CHANNEL_1_NUMBER ( ADC_CFGR_AWD1CH_0)
  191. #define ADC_CHANNEL_2_NUMBER ( ADC_CFGR_AWD1CH_1 )
  192. #define ADC_CHANNEL_3_NUMBER ( ADC_CFGR_AWD1CH_1 | ADC_CFGR_AWD1CH_0)
  193. #define ADC_CHANNEL_4_NUMBER ( ADC_CFGR_AWD1CH_2 )
  194. #define ADC_CHANNEL_5_NUMBER ( ADC_CFGR_AWD1CH_2 | ADC_CFGR_AWD1CH_0)
  195. #define ADC_CHANNEL_6_NUMBER ( ADC_CFGR_AWD1CH_2 | ADC_CFGR_AWD1CH_1 )
  196. #define ADC_CHANNEL_7_NUMBER ( ADC_CFGR_AWD1CH_2 | ADC_CFGR_AWD1CH_1 | ADC_CFGR_AWD1CH_0)
  197. #define ADC_CHANNEL_8_NUMBER ( ADC_CFGR_AWD1CH_3 )
  198. #define ADC_CHANNEL_9_NUMBER ( ADC_CFGR_AWD1CH_3 | ADC_CFGR_AWD1CH_0)
  199. #define ADC_CHANNEL_10_NUMBER ( ADC_CFGR_AWD1CH_3 | ADC_CFGR_AWD1CH_1 )
  200. #define ADC_CHANNEL_11_NUMBER ( ADC_CFGR_AWD1CH_3 | ADC_CFGR_AWD1CH_1 | ADC_CFGR_AWD1CH_0)
  201. #define ADC_CHANNEL_12_NUMBER ( ADC_CFGR_AWD1CH_3 | ADC_CFGR_AWD1CH_2 )
  202. #define ADC_CHANNEL_13_NUMBER ( ADC_CFGR_AWD1CH_3 | ADC_CFGR_AWD1CH_2 | ADC_CFGR_AWD1CH_0)
  203. #define ADC_CHANNEL_14_NUMBER ( ADC_CFGR_AWD1CH_3 | ADC_CFGR_AWD1CH_2 | ADC_CFGR_AWD1CH_1 )
  204. #define ADC_CHANNEL_15_NUMBER ( ADC_CFGR_AWD1CH_3 | ADC_CFGR_AWD1CH_2 | ADC_CFGR_AWD1CH_1 | ADC_CFGR_AWD1CH_0)
  205. #define ADC_CHANNEL_16_NUMBER (ADC_CFGR_AWD1CH_4 )
  206. #define ADC_CHANNEL_17_NUMBER (ADC_CFGR_AWD1CH_4 | ADC_CFGR_AWD1CH_0)
  207. #define ADC_CHANNEL_18_NUMBER (ADC_CFGR_AWD1CH_4 | ADC_CFGR_AWD1CH_1 )
  208. /* Definition of channels ID bitfield information to be inserted into */
  209. /* channels literals definition. */
  210. #define ADC_CHANNEL_0_BITFIELD 0x00000001UL
  211. #define ADC_CHANNEL_1_BITFIELD 0x00000002UL
  212. #define ADC_CHANNEL_2_BITFIELD 0x00000004UL
  213. #define ADC_CHANNEL_3_BITFIELD 0x00000008UL
  214. #define ADC_CHANNEL_4_BITFIELD 0x00000010UL
  215. #define ADC_CHANNEL_5_BITFIELD 0x00000020UL
  216. #define ADC_CHANNEL_6_BITFIELD 0x00000040UL
  217. #define ADC_CHANNEL_7_BITFIELD 0x00000080UL
  218. #define ADC_CHANNEL_8_BITFIELD 0x00000100UL
  219. #define ADC_CHANNEL_9_BITFIELD 0x00000200UL
  220. #define ADC_CHANNEL_10_BITFIELD 0x00000400UL
  221. #define ADC_CHANNEL_11_BITFIELD 0x00000800UL
  222. #define ADC_CHANNEL_12_BITFIELD 0x00001000UL
  223. #define ADC_CHANNEL_13_BITFIELD 0x00002000UL
  224. #define ADC_CHANNEL_14_BITFIELD 0x00004000UL
  225. #define ADC_CHANNEL_15_BITFIELD 0x00008000UL
  226. #define ADC_CHANNEL_16_BITFIELD 0x00010000UL
  227. #define ADC_CHANNEL_17_BITFIELD 0x00020000UL
  228. #define ADC_CHANNEL_18_BITFIELD 0x00040000UL
  229. /* Definition of channels sampling time information to be inserted into */
  230. /* channels literals definition. */
  231. #define ADC_CHANNEL_0_SMP (ADC_SMPR1_REGOFFSET | (((uint32_t) 0U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR1_SMP0) */
  232. #define ADC_CHANNEL_1_SMP (ADC_SMPR1_REGOFFSET | (((uint32_t) 3U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR1_SMP1) */
  233. #define ADC_CHANNEL_2_SMP (ADC_SMPR1_REGOFFSET | (((uint32_t) 6U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR1_SMP2) */
  234. #define ADC_CHANNEL_3_SMP (ADC_SMPR1_REGOFFSET | (((uint32_t) 9U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR1_SMP3) */
  235. #define ADC_CHANNEL_4_SMP (ADC_SMPR1_REGOFFSET | (((uint32_t)12U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR1_SMP4) */
  236. #define ADC_CHANNEL_5_SMP (ADC_SMPR1_REGOFFSET | (((uint32_t)15U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR1_SMP5) */
  237. #define ADC_CHANNEL_6_SMP (ADC_SMPR1_REGOFFSET | (((uint32_t)18U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR1_SMP6) */
  238. #define ADC_CHANNEL_7_SMP (ADC_SMPR1_REGOFFSET | (((uint32_t)21U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR1_SMP7) */
  239. #define ADC_CHANNEL_8_SMP (ADC_SMPR1_REGOFFSET | (((uint32_t)24U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR1_SMP8) */
  240. #define ADC_CHANNEL_9_SMP (ADC_SMPR1_REGOFFSET | (((uint32_t)27U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR1_SMP9) */
  241. #define ADC_CHANNEL_10_SMP (ADC_SMPR2_REGOFFSET | (((uint32_t) 0U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR2_SMP10) */
  242. #define ADC_CHANNEL_11_SMP (ADC_SMPR2_REGOFFSET | (((uint32_t) 3U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR2_SMP11) */
  243. #define ADC_CHANNEL_12_SMP (ADC_SMPR2_REGOFFSET | (((uint32_t) 6U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR2_SMP12) */
  244. #define ADC_CHANNEL_13_SMP (ADC_SMPR2_REGOFFSET | (((uint32_t) 9U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR2_SMP13) */
  245. #define ADC_CHANNEL_14_SMP (ADC_SMPR2_REGOFFSET | (((uint32_t)12U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR2_SMP14) */
  246. #define ADC_CHANNEL_15_SMP (ADC_SMPR2_REGOFFSET | (((uint32_t)15U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR2_SMP15) */
  247. #define ADC_CHANNEL_16_SMP (ADC_SMPR2_REGOFFSET | (((uint32_t)18U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR2_SMP16) */
  248. #define ADC_CHANNEL_17_SMP (ADC_SMPR2_REGOFFSET | (((uint32_t)21U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR2_SMP17) */
  249. #define ADC_CHANNEL_18_SMP (ADC_SMPR2_REGOFFSET | (((uint32_t)24U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR2_SMP18) */
  250. /* Internal mask for ADC mode single or differential ended: */
  251. /* To select into literals LL_ADC_SINGLE_ENDED or LL_ADC_SINGLE_DIFFERENTIAL */
  252. /* the relevant bits for: */
  253. /* (concatenation of multiple bits used in different registers) */
  254. /* - ADC calibration: calibration start, calibration factor get or set */
  255. /* - ADC channels: set each ADC channel ending mode */
  256. #define ADC_SINGLEDIFF_CALIB_START_MASK (ADC_CR_ADCALDIF)
  257. #define ADC_SINGLEDIFF_CALIB_FACTOR_MASK (ADC_CALFACT_CALFACT_D | ADC_CALFACT_CALFACT_S)
  258. #define ADC_SINGLEDIFF_CHANNEL_MASK (ADC_CHANNEL_ID_BITFIELD_MASK) /* Equivalent to ADC_DIFSEL_DIFSEL */
  259. #define ADC_SINGLEDIFF_CHANNEL_SHIFT_MASK (ADC_CALFACT_CALFACT_S_4 | ADC_CALFACT_CALFACT_S_3) /* Bits chosen to perform of shift when single mode is selected, shift value out of channels bits range. */
  260. /* Internal mask for ADC analog watchdog: */
  261. /* To select into literals LL_ADC_AWD_CHANNELx_xxx the relevant bits for: */
  262. /* (concatenation of multiple bits used in different analog watchdogs, */
  263. /* (feature of several watchdogs not available on all STM32 families)). */
  264. /* - analog watchdog 1: monitored channel defined by number, */
  265. /* selection of ADC group (ADC groups regular and-or injected). */
  266. /* - analog watchdog 2 and 3: monitored channel defined by bitfield, no */
  267. /* selection on groups. */
  268. /* Internal register offset for ADC analog watchdog channel configuration */
  269. #define ADC_AWD_CR1_REGOFFSET ((uint32_t)0x00000000U)
  270. #define ADC_AWD_CR2_REGOFFSET ((uint32_t)0x00100000U)
  271. #define ADC_AWD_CR3_REGOFFSET ((uint32_t)0x00200000U)
  272. /* Register offset gap between AWD1 and AWD2-AWD3 configuration registers */
  273. /* (Set separately as ADC_AWD_CRX_REGOFFSET to spare 32 bits space */
  274. #define ADC_AWD_CR12_REGOFFSETGAP_MASK (ADC_AWD2CR_AWD2CH_0)
  275. #define ADC_AWD_CR12_REGOFFSETGAP_VAL ((uint32_t)0x00000024U)
  276. #define ADC_AWD_CRX_REGOFFSET_MASK (ADC_AWD_CR1_REGOFFSET | ADC_AWD_CR2_REGOFFSET | ADC_AWD_CR3_REGOFFSET)
  277. #define ADC_AWD_CR1_CHANNEL_MASK (ADC_CFGR_AWD1CH | ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1EN | ADC_CFGR_AWD1SGL)
  278. #define ADC_AWD_CR23_CHANNEL_MASK (ADC_AWD2CR_AWD2CH)
  279. #define ADC_AWD_CR_ALL_CHANNEL_MASK (ADC_AWD_CR1_CHANNEL_MASK | ADC_AWD_CR23_CHANNEL_MASK)
  280. /* 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. /* Internal mask for ADC offset: */
  286. /* Internal register offset for ADC offset number configuration */
  287. #define ADC_OFR1_REGOFFSET ((uint32_t)0x00000000U)
  288. #define ADC_OFR2_REGOFFSET ((uint32_t)0x00000001U)
  289. #define ADC_OFR3_REGOFFSET ((uint32_t)0x00000002U)
  290. #define ADC_OFR4_REGOFFSET ((uint32_t)0x00000003U)
  291. #define ADC_OFRx_REGOFFSET_MASK (ADC_OFR1_REGOFFSET | ADC_OFR2_REGOFFSET | ADC_OFR3_REGOFFSET | ADC_OFR4_REGOFFSET)
  292. /* ADC registers bits positions */
  293. #define ADC_CFGR_RES_BITOFFSET_POS ((uint32_t) 3U) /* Value equivalent to POSITION_VAL(ADC_CFGR_RES) */
  294. #define ADC_CFGR_AWD1SGL_BITOFFSET_POS ((uint32_t)22U) /* Value equivalent to POSITION_VAL(ADC_CFGR_AWD1SGL) */
  295. #define ADC_CFGR_AWD1EN_BITOFFSET_POS ((uint32_t)23U) /* Value equivalent to POSITION_VAL(ADC_CFGR_AWD1EN) */
  296. #define ADC_CFGR_JAWD1EN_BITOFFSET_POS ((uint32_t)24U) /* Value equivalent to POSITION_VAL(ADC_CFGR_JAWD1EN) */
  297. #define ADC_TR1_HT1_BITOFFSET_POS ((uint32_t)16U) /* Value equivalent to POSITION_VAL(ADC_TR1_HT1) */
  298. /* ADC registers bits groups */
  299. #define ADC_CR_BITS_PROPERTY_RS (ADC_CR_ADCAL | ADC_CR_JADSTP | ADC_CR_ADSTP | ADC_CR_JADSTART | ADC_CR_ADSTART | ADC_CR_ADDIS | ADC_CR_ADEN) /* ADC register CR bits with HW property "rs": Software can read as well as set this bit. Writing '0' has no effect on the bit value. */
  300. /* ADC internal channels related definitions */
  301. /* Internal voltage reference VrefInt */
  302. #define VREFINT_CAL_ADDR ((uint16_t*) ((uint32_t)0x1FFFF7BAU)) /* Internal voltage reference, address of parameter VREFINT_CAL: VrefInt ADC raw data acquired at temperature 30 DegC (tolerance: +-5 DegC), Vref+ = 3.3 V (tolerance: +-10 mV). */
  303. #define VREFINT_CAL_VREF ((uint32_t) 3300U) /* Analog voltage reference (Vref+) value with which temperature sensor has been calibrated in production (tolerance: +-10 mV) (unit: mV). */
  304. /* Temperature sensor */
  305. #define TEMPSENSOR_CAL1_ADDR ((uint16_t*) ((uint32_t)0x1FFFF7B8U)) /* Internal temperature sensor, address of parameter TS_CAL1: On STM32F3, temperature sensor ADC raw data acquired at temperature 30 DegC (tolerance: +-5 DegC), Vref+ = 3.3 V (tolerance: +-10 mV). */
  306. #define TEMPSENSOR_CAL2_ADDR ((uint16_t*) ((uint32_t)0x1FFFF7C2U)) /* Internal temperature sensor, address of parameter TS_CAL2: On STM32F3, temperature sensor ADC raw data acquired at temperature 110 DegC (tolerance: +-5 DegC), Vref+ = 3.3 V (tolerance: +-10 mV). */
  307. #define TEMPSENSOR_CAL1_TEMP (( int32_t) 30) /* Internal temperature sensor, temperature at which temperature sensor has been calibrated in production for data into TEMPSENSOR_CAL1_ADDR (tolerance: +-5 DegC) (unit: DegC). */
  308. #define TEMPSENSOR_CAL2_TEMP (( int32_t) 110) /* Internal temperature sensor, temperature at which temperature sensor has been calibrated in production for data into TEMPSENSOR_CAL2_ADDR (tolerance: +-5 DegC) (unit: DegC). */
  309. #define TEMPSENSOR_CAL_VREFANALOG ((uint32_t) 3300U) /* Analog voltage reference (Vref+) voltage with which temperature sensor has been calibrated in production (+-10 mV) (unit: mV). */
  310. /**
  311. * @}
  312. */
  313. /* Private macros ------------------------------------------------------------*/
  314. /** @defgroup ADC_LL_Private_Macros ADC Private Macros
  315. * @{
  316. */
  317. /**
  318. * @brief Driver macro reserved for internal use: isolate bits with the
  319. * selected mask and shift them to the register LSB
  320. * (shift mask on register position bit 0).
  321. * @param __BITS__ Bits in register 32 bits
  322. * @param __MASK__ Mask in register 32 bits
  323. * @retval Bits in register 32 bits
  324. */
  325. #define __ADC_MASK_SHIFT(__BITS__, __MASK__) \
  326. (((__BITS__) & (__MASK__)) >> POSITION_VAL((__MASK__)))
  327. /**
  328. * @brief Driver macro reserved for internal use: set a pointer to
  329. * a register from a register basis from which an offset
  330. * is applied.
  331. * @param __REG__ Register basis from which the offset is applied.
  332. * @param __REG_OFFFSET__ Offset to be applied (unit: number of registers).
  333. * @retval Pointer to register address
  334. */
  335. #define __ADC_PTR_REG_OFFSET(__REG__, __REG_OFFFSET__) \
  336. ((__IO uint32_t *)((uint32_t) ((uint32_t)(&(__REG__)) + ((__REG_OFFFSET__) << 2U))))
  337. /**
  338. * @}
  339. */
  340. /* Exported types ------------------------------------------------------------*/
  341. #if defined(USE_FULL_LL_DRIVER)
  342. /** @defgroup ADC_LL_ES_INIT ADC Exported Init structure
  343. * @{
  344. */
  345. /**
  346. * @brief Structure definition of some features of ADC common parameters
  347. * and multimode
  348. * (all ADC instances belonging to the same ADC common instance).
  349. * @note The setting of these parameters by function @ref LL_ADC_CommonInit()
  350. * is conditioned to ADC instances state (all ADC instances
  351. * sharing the same ADC common instance):
  352. * All ADC instances sharing the same ADC common instance must be
  353. * disabled.
  354. */
  355. typedef struct
  356. {
  357. uint32_t CommonClock; /*!< Set parameter common to several ADC: Clock source and prescaler.
  358. This parameter can be a value of @ref ADC_LL_EC_COMMON_CLOCK_SOURCE
  359. @note On this STM32 series, if ADC group injected is used, some
  360. clock ratio constraints between ADC clock and AHB clock
  361. must be respected. Refer to reference manual.
  362. This feature can be modified afterwards using unitary function @ref LL_ADC_SetCommonClock(). */
  363. #if defined(ADC_MULTIMODE_SUPPORT)
  364. uint32_t Multimode; /*!< Set ADC multimode configuration to operate in independent mode or multimode (for devices with several ADC instances).
  365. This parameter can be a value of @ref ADC_LL_EC_MULTI_MODE
  366. This feature can be modified afterwards using unitary function @ref LL_ADC_SetMultimode(). */
  367. uint32_t MultiDMATransfer; /*!< Set ADC multimode conversion data transfer: no transfer or transfer by DMA.
  368. This parameter can be a value of @ref ADC_LL_EC_MULTI_DMA_TRANSFER
  369. This feature can be modified afterwards using unitary function @ref LL_ADC_SetMultiDMATransfer(). */
  370. uint32_t MultiTwoSamplingDelay; /*!< Set ADC multimode delay between 2 sampling phases.
  371. This parameter can be a value of @ref ADC_LL_EC_MULTI_TWOSMP_DELAY
  372. This feature can be modified afterwards using unitary function @ref LL_ADC_SetMultiTwoSamplingDelay(). */
  373. #endif /* ADC_MULTIMODE_SUPPORT */
  374. } LL_ADC_CommonInitTypeDef;
  375. /**
  376. * @brief Structure definition of some features of ADC instance.
  377. * @note These parameters have an impact on ADC scope: ADC instance.
  378. * Affects both group regular and group injected (availability
  379. * of ADC group injected depends on STM32 families).
  380. * Refer to corresponding unitary functions into
  381. * @ref ADC_LL_EF_Configuration_ADC_Instance .
  382. * @note The setting of these parameters by function @ref LL_ADC_Init()
  383. * is conditioned to ADC state:
  384. * ADC instance must be disabled.
  385. * This condition is applied to all ADC features, for efficiency
  386. * and compatibility over all STM32 families. However, the different
  387. * features can be set under different ADC state conditions
  388. * (setting possible with ADC enabled without conversion on going,
  389. * ADC enabled with conversion on going, ...)
  390. * Each feature can be updated afterwards with a unitary function
  391. * and potentially with ADC in a different state than disabled,
  392. * refer to description of each function for setting
  393. * conditioned to ADC state.
  394. */
  395. typedef struct
  396. {
  397. uint32_t Resolution; /*!< Set ADC resolution.
  398. This parameter can be a value of @ref ADC_LL_EC_RESOLUTION
  399. This feature can be modified afterwards using unitary function @ref LL_ADC_SetResolution(). */
  400. uint32_t DataAlignment; /*!< Set ADC conversion data alignment.
  401. This parameter can be a value of @ref ADC_LL_EC_DATA_ALIGN
  402. This feature can be modified afterwards using unitary function @ref LL_ADC_SetDataAlignment(). */
  403. uint32_t LowPowerMode; /*!< Set ADC low power mode.
  404. This parameter can be a value of @ref ADC_LL_EC_LP_MODE
  405. This feature can be modified afterwards using unitary function @ref LL_ADC_SetLowPowerMode(). */
  406. } LL_ADC_InitTypeDef;
  407. /**
  408. * @brief Structure definition of some features of ADC group regular.
  409. * @note These parameters have an impact on ADC scope: ADC group regular.
  410. * Refer to corresponding unitary functions into
  411. * @ref ADC_LL_EF_Configuration_ADC_Group_Regular
  412. * (functions with prefix "REG").
  413. * @note The setting of these parameters by function @ref LL_ADC_REG_Init()
  414. * is conditioned to ADC state:
  415. * ADC instance must be disabled.
  416. * This condition is applied to all ADC features, for efficiency
  417. * and compatibility over all STM32 families. However, the different
  418. * features can be set under different ADC state conditions
  419. * (setting possible with ADC enabled without conversion on going,
  420. * ADC enabled with conversion on going, ...)
  421. * Each feature can be updated afterwards with a unitary function
  422. * and potentially with ADC in a different state than disabled,
  423. * refer to description of each function for setting
  424. * conditioned to ADC state.
  425. */
  426. typedef struct
  427. {
  428. uint32_t TriggerSource; /*!< Set ADC group regular conversion trigger source: internal (SW start) or from external IP (timer event, external interrupt line).
  429. This parameter can be a value of @ref ADC_LL_EC_REG_TRIGGER_SOURCE
  430. @note On this STM32 series, setting trigger source to external trigger also set trigger polarity to rising edge
  431. (default setting for compatibility with some ADC on other STM32 families having this setting set by HW default value).
  432. In case of need to modify trigger edge, use function @ref LL_ADC_REG_SetTriggerEdge().
  433. This feature can be modified afterwards using unitary function @ref LL_ADC_REG_SetTriggerSource(). */
  434. uint32_t SequencerLength; /*!< Set ADC group regular sequencer length.
  435. This parameter can be a value of @ref ADC_LL_EC_REG_SEQ_SCAN_LENGTH
  436. This feature can be modified afterwards using unitary function @ref LL_ADC_REG_SetSequencerLength(). */
  437. uint32_t SequencerDiscont; /*!< Set ADC group regular sequencer discontinuous mode: sequence subdivided and scan conversions interrupted every selected number of ranks.
  438. This parameter can be a value of @ref ADC_LL_EC_REG_SEQ_DISCONT_MODE
  439. @note This parameter has an effect only if group regular sequencer is enabled
  440. (scan length of 2 ranks or more).
  441. This feature can be modified afterwards using unitary function @ref LL_ADC_REG_SetSequencerDiscont(). */
  442. uint32_t ContinuousMode; /*!< Set ADC continuous conversion mode on ADC group regular, whether ADC conversions are performed in single mode (one conversion per trigger) or in continuous mode (after the first trigger, following conversions launched successively automatically).
  443. This parameter can be a value of @ref ADC_LL_EC_REG_CONTINUOUS_MODE
  444. Note: It is not possible to enable both ADC group regular continuous mode and discontinuous mode.
  445. This feature can be modified afterwards using unitary function @ref LL_ADC_REG_SetContinuousMode(). */
  446. uint32_t DMATransfer; /*!< Set ADC group regular conversion data transfer: no transfer or transfer by DMA, and DMA requests mode.
  447. This parameter can be a value of @ref ADC_LL_EC_REG_DMA_TRANSFER
  448. This feature can be modified afterwards using unitary function @ref LL_ADC_REG_SetDMATransfer(). */
  449. uint32_t Overrun; /*!< Set ADC group regular behavior in case of overrun:
  450. data preserved or overwritten.
  451. This parameter can be a value of @ref ADC_LL_EC_REG_OVR_DATA_BEHAVIOR
  452. This feature can be modified afterwards using unitary function @ref LL_ADC_REG_SetOverrun(). */
  453. } LL_ADC_REG_InitTypeDef;
  454. /**
  455. * @brief Structure definition of some features of ADC group injected.
  456. * @note These parameters have an impact on ADC scope: ADC group injected.
  457. * Refer to corresponding unitary functions into
  458. * @ref ADC_LL_EF_Configuration_ADC_Group_Regular
  459. * (functions with prefix "INJ").
  460. * @note The setting of these parameters by function @ref LL_ADC_INJ_Init()
  461. * is conditioned to ADC state:
  462. * ADC instance must be disabled.
  463. * This condition is applied to all ADC features, for efficiency
  464. * and compatibility over all STM32 families. However, the different
  465. * features can be set under different ADC state conditions
  466. * (setting possible with ADC enabled without conversion on going,
  467. * ADC enabled with conversion on going, ...)
  468. * Each feature can be updated afterwards with a unitary function
  469. * and potentially with ADC in a different state than disabled,
  470. * refer to description of each function for setting
  471. * conditioned to ADC state.
  472. */
  473. typedef struct
  474. {
  475. uint32_t TriggerSource; /*!< Set ADC group injected conversion trigger source: internal (SW start) or from external IP (timer event, external interrupt line).
  476. This parameter can be a value of @ref ADC_LL_EC_INJ_TRIGGER_SOURCE
  477. @note On this STM32 series, setting trigger source to external trigger also set trigger polarity to rising edge
  478. (default setting for compatibility with some ADC on other STM32 families having this setting set by HW default value).
  479. In case of need to modify trigger edge, use function @ref LL_ADC_INJ_SetTriggerEdge().
  480. This feature can be modified afterwards using unitary function @ref LL_ADC_INJ_SetTriggerSource(). */
  481. uint32_t SequencerLength; /*!< Set ADC group injected sequencer length.
  482. This parameter can be a value of @ref ADC_LL_EC_INJ_SEQ_SCAN_LENGTH
  483. This feature can be modified afterwards using unitary function @ref LL_ADC_INJ_SetSequencerLength(). */
  484. uint32_t SequencerDiscont; /*!< Set ADC group injected sequencer discontinuous mode: sequence subdivided and scan conversions interrupted every selected number of ranks.
  485. This parameter can be a value of @ref ADC_LL_EC_INJ_SEQ_DISCONT_MODE
  486. @note This parameter has an effect only if group injected sequencer is enabled
  487. (scan length of 2 ranks or more).
  488. This feature can be modified afterwards using unitary function @ref LL_ADC_INJ_SetSequencerDiscont(). */
  489. uint32_t TrigAuto; /*!< Set ADC group injected conversion trigger: independent or from ADC group regular.
  490. This parameter can be a value of @ref ADC_LL_EC_INJ_TRIG_AUTO
  491. Note: This parameter must be set to set to independent trigger if injected trigger source is set to an external trigger.
  492. This feature can be modified afterwards using unitary function @ref LL_ADC_INJ_SetTrigAuto(). */
  493. } LL_ADC_INJ_InitTypeDef;
  494. /**
  495. * @}
  496. */
  497. #endif /* USE_FULL_LL_DRIVER */
  498. /* Exported constants --------------------------------------------------------*/
  499. /** @defgroup ADC_LL_Exported_Constants ADC Exported Constants
  500. * @{
  501. */
  502. /** @defgroup ADC_LL_EC_FLAG ADC flags
  503. * @brief Flags defines which can be used with LL_ADC_ReadReg function
  504. * @{
  505. */
  506. #define LL_ADC_FLAG_ADRDY ADC_ISR_ADRDY /*!< ADC flag ADC instance ready */
  507. #define LL_ADC_FLAG_EOC ADC_ISR_EOC /*!< ADC flag ADC group regular end of unitary conversion */
  508. #define LL_ADC_FLAG_EOS ADC_ISR_EOS /*!< ADC flag ADC group regular end of sequence conversions */
  509. #define LL_ADC_FLAG_OVR ADC_ISR_OVR /*!< ADC flag ADC group regular overrun */
  510. #define LL_ADC_FLAG_EOSMP ADC_ISR_EOSMP /*!< ADC flag ADC group regular end of sampling phase */
  511. #define LL_ADC_FLAG_JEOC ADC_ISR_JEOC /*!< ADC flag ADC group injected end of unitary conversion */
  512. #define LL_ADC_FLAG_JEOS ADC_ISR_JEOS /*!< ADC flag ADC group injected end of sequence conversions */
  513. #define LL_ADC_FLAG_JQOVF ADC_ISR_JQOVF /*!< ADC flag ADC group injected contexts queue overflow */
  514. #define LL_ADC_FLAG_AWD1 ADC_ISR_AWD1 /*!< ADC flag ADC analog watchdog 1 */
  515. #define LL_ADC_FLAG_AWD2 ADC_ISR_AWD2 /*!< ADC flag ADC analog watchdog 2 */
  516. #define LL_ADC_FLAG_AWD3 ADC_ISR_AWD3 /*!< ADC flag ADC analog watchdog 3 */
  517. #if defined(ADC_MULTIMODE_SUPPORT)
  518. #define LL_ADC_FLAG_ADRDY_MST ADC_CSR_ADRDY_MST /*!< ADC flag ADC multimode master instance ready */
  519. #define LL_ADC_FLAG_ADRDY_SLV ADC_CSR_ADRDY_SLV /*!< ADC flag ADC multimode slave instance ready */
  520. #define LL_ADC_FLAG_EOC_MST ADC_CSR_EOC_MST /*!< ADC flag ADC multimode master group regular end of unitary conversion */
  521. #define LL_ADC_FLAG_EOC_SLV ADC_CSR_EOC_SLV /*!< ADC flag ADC multimode slave group regular end of unitary conversion */
  522. #define LL_ADC_FLAG_EOS_MST ADC_CSR_EOS_MST /*!< ADC flag ADC multimode master group regular end of sequence conversions */
  523. #define LL_ADC_FLAG_EOS_SLV ADC_CSR_EOS_SLV /*!< ADC flag ADC multimode slave group regular end of sequence conversions */
  524. #define LL_ADC_FLAG_OVR_MST ADC_CSR_OVR_MST /*!< ADC flag ADC multimode master group regular overrun */
  525. #define LL_ADC_FLAG_OVR_SLV ADC_CSR_OVR_SLV /*!< ADC flag ADC multimode slave group regular overrun */
  526. #define LL_ADC_FLAG_EOSMP_MST ADC_CSR_EOSMP_MST /*!< ADC flag ADC multimode master group regular end of sampling phase */
  527. #define LL_ADC_FLAG_EOSMP_SLV ADC_CSR_EOSMP_SLV /*!< ADC flag ADC multimode slave group regular end of sampling phase */
  528. #define LL_ADC_FLAG_JEOC_MST ADC_CSR_JEOC_MST /*!< ADC flag ADC multimode master group injected end of unitary conversion */
  529. #define LL_ADC_FLAG_JEOC_SLV ADC_CSR_JEOC_SLV /*!< ADC flag ADC multimode slave group injected end of unitary conversion */
  530. #define LL_ADC_FLAG_JEOS_MST ADC_CSR_JEOS_MST /*!< ADC flag ADC multimode master group injected end of sequence conversions */
  531. #define LL_ADC_FLAG_JEOS_SLV ADC_CSR_JEOS_SLV /*!< ADC flag ADC multimode slave group injected end of sequence conversions */
  532. #define LL_ADC_FLAG_JQOVF_MST ADC_CSR_JQOVF_MST /*!< ADC flag ADC multimode master group injected contexts queue overflow */
  533. #define LL_ADC_FLAG_JQOVF_SLV ADC_CSR_JQOVF_SLV /*!< ADC flag ADC multimode slave group injected contexts queue overflow */
  534. #define LL_ADC_FLAG_AWD1_MST ADC_CSR_AWD1_MST /*!< ADC flag ADC multimode master analog watchdog 1 of the ADC master */
  535. #define LL_ADC_FLAG_AWD1_SLV ADC_CSR_AWD1_SLV /*!< ADC flag ADC multimode slave analog watchdog 1 of the ADC slave */
  536. #define LL_ADC_FLAG_AWD2_MST ADC_CSR_AWD2_MST /*!< ADC flag ADC multimode master analog watchdog 2 of the ADC master */
  537. #define LL_ADC_FLAG_AWD2_SLV ADC_CSR_AWD2_SLV /*!< ADC flag ADC multimode slave analog watchdog 2 of the ADC slave */
  538. #define LL_ADC_FLAG_AWD3_MST ADC_CSR_AWD3_MST /*!< ADC flag ADC multimode master analog watchdog 3 of the ADC master */
  539. #define LL_ADC_FLAG_AWD3_SLV ADC_CSR_AWD3_SLV /*!< ADC flag ADC multimode slave analog watchdog 3 of the ADC slave */
  540. #endif
  541. /**
  542. * @}
  543. */
  544. /** @defgroup ADC_LL_EC_IT ADC interruptions for configuration (interruption enable or disable)
  545. * @brief IT defines which can be used with LL_ADC_ReadReg and LL_ADC_WriteReg functions
  546. * @{
  547. */
  548. #define LL_ADC_IT_ADRDY ADC_IER_ADRDYIE /*!< ADC interruption ADC instance ready */
  549. #define LL_ADC_IT_EOC ADC_IER_EOCIE /*!< ADC interruption ADC group regular end of unitary conversion */
  550. #define LL_ADC_IT_EOS ADC_IER_EOSIE /*!< ADC interruption ADC group regular end of sequence conversions */
  551. #define LL_ADC_IT_OVR ADC_IER_OVRIE /*!< ADC interruption ADC group regular overrun */
  552. #define LL_ADC_IT_EOSMP ADC_IER_EOSMPIE /*!< ADC interruption ADC group regular end of sampling phase */
  553. #define LL_ADC_IT_JEOC ADC_IER_JEOCIE /*!< ADC interruption ADC group injected end of unitary conversion */
  554. #define LL_ADC_IT_JEOS ADC_IER_JEOSIE /*!< ADC interruption ADC group injected end of sequence conversions */
  555. #define LL_ADC_IT_JQOVF ADC_IER_JQOVFIE /*!< ADC interruption ADC group injected contexts queue overflow */
  556. #define LL_ADC_IT_AWD1 ADC_IER_AWD1IE /*!< ADC interruption ADC analog watchdog 1 */
  557. #define LL_ADC_IT_AWD2 ADC_IER_AWD2IE /*!< ADC interruption ADC analog watchdog 2 */
  558. #define LL_ADC_IT_AWD3 ADC_IER_AWD3IE /*!< ADC interruption ADC analog watchdog 3 */
  559. /**
  560. * @}
  561. */
  562. /** @defgroup ADC_LL_EC_REGISTERS ADC registers compliant with specific purpose
  563. * @{
  564. */
  565. /* List of ADC registers intended to be used (most commonly) with */
  566. /* DMA transfer. */
  567. /* Refer to function @ref LL_ADC_DMA_GetRegAddr(). */
  568. #define LL_ADC_DMA_REG_REGULAR_DATA ((uint32_t)0x00000000U) /* ADC group regular conversion data register (corresponding to register DR) to be used with ADC configured in independent mode. Without DMA transfer, register accessed by LL function @ref LL_ADC_REG_ReadConversionData32() and other functions @ref LL_ADC_REG_ReadConversionDatax() */
  569. #if defined(ADC_MULTIMODE_SUPPORT)
  570. #define LL_ADC_DMA_REG_REGULAR_DATA_MULTI ((uint32_t)0x00000001U) /* ADC group regular conversion data register (corresponding to register CDR) to be used with ADC configured in multimode (available on STM32 devices with several ADC instances). Without DMA transfer, register accessed by LL function @ref LL_ADC_REG_ReadMultiConversionData32() */
  571. #endif
  572. /**
  573. * @}
  574. */
  575. /** @defgroup ADC_LL_EC_COMMON_CLOCK_SOURCE ADC common - Clock source
  576. * @{
  577. */
  578. #define LL_ADC_CLOCK_SYNC_PCLK_DIV1 (ADC_CCR_CKMODE_0) /*!< ADC synchronous clock derived from AHB clock without prescaler */
  579. #define LL_ADC_CLOCK_SYNC_PCLK_DIV2 (ADC_CCR_CKMODE_1 ) /*!< ADC synchronous clock derived from AHB clock with prescaler division by 2 */
  580. #define LL_ADC_CLOCK_SYNC_PCLK_DIV4 (ADC_CCR_CKMODE_1 | ADC_CCR_CKMODE_0) /*!< ADC synchronous clock derived from AHB clock with prescaler division by 4 */
  581. #define LL_ADC_CLOCK_ASYNC_DIV1 ((uint32_t)0x00000000U) /*!< ADC asynchronous clock without prescaler */
  582. /**
  583. * @}
  584. */
  585. /** @defgroup ADC_LL_EC_COMMON_PATH_INTERNAL ADC common - Measurement path to internal channels
  586. * @{
  587. */
  588. /* Note: Other measurement paths to internal channels may be available */
  589. /* (connections to other peripherals). */
  590. /* If they are not listed below, they do not require any specific */
  591. /* path enable. In this case, Access to measurement path is done */
  592. /* only by selecting the corresponding ADC internal channel. */
  593. #define LL_ADC_PATH_INTERNAL_NONE ((uint32_t)0x00000000U)/*!< ADC measurement paths all disabled */
  594. #define LL_ADC_PATH_INTERNAL_VREFINT (ADC_CCR_VREFEN) /*!< ADC measurement path to internal channel VrefInt */
  595. #define LL_ADC_PATH_INTERNAL_TEMPSENSOR (ADC_CCR_TSEN) /*!< ADC measurement path to internal channel temperature sensor */
  596. #define LL_ADC_PATH_INTERNAL_VBAT (ADC_CCR_VBATEN) /*!< ADC measurement path to internal channel Vbat */
  597. /**
  598. * @}
  599. */
  600. /** @defgroup ADC_LL_EC_RESOLUTION ADC instance - Resolution
  601. * @{
  602. */
  603. #define LL_ADC_RESOLUTION_12B ((uint32_t)0x00000000U) /*!< ADC resolution 12 bits */
  604. #define LL_ADC_RESOLUTION_10B ( ADC_CFGR_RES_0) /*!< ADC resolution 10 bits */
  605. #define LL_ADC_RESOLUTION_8B (ADC_CFGR_RES_1 ) /*!< ADC resolution 8 bits */
  606. #define LL_ADC_RESOLUTION_6B (ADC_CFGR_RES_1 | ADC_CFGR_RES_0) /*!< ADC resolution 6 bits */
  607. /**
  608. * @}
  609. */
  610. /** @defgroup ADC_LL_EC_DATA_ALIGN ADC instance - Data alignment
  611. * @{
  612. */
  613. #define LL_ADC_DATA_ALIGN_RIGHT ((uint32_t)0x00000000U)/*!< ADC conversion data alignment: right aligned (alignment on data register LSB bit 0)*/
  614. #define LL_ADC_DATA_ALIGN_LEFT (ADC_CFGR_ALIGN) /*!< ADC conversion data alignment: left aligned (alignment on data register MSB bit 15)*/
  615. /**
  616. * @}
  617. */
  618. /** @defgroup ADC_LL_EC_LP_MODE ADC instance - Low power mode
  619. * @{
  620. */
  621. #define LL_ADC_LP_MODE_NONE ((uint32_t)0x00000000U) /*!< No ADC low power mode activated */
  622. #define LL_ADC_LP_AUTOWAIT (ADC_CFGR_AUTDLY) /*!< ADC low power mode auto delay: Dynamic low power mode, ADC conversions are performed only when necessary (when previous ADC conversion data is read). See description with function @ref LL_ADC_SetLowPowerMode(). */
  623. /**
  624. * @}
  625. */
  626. /** @defgroup ADC_LL_EC_OFFSET_NB ADC instance - Offset number
  627. * @{
  628. */
  629. #define LL_ADC_OFFSET_1 ADC_OFR1_REGOFFSET /*!< ADC offset number 1: ADC channel and offset level to which the offset programmed will be applied (independently of channel mapped on ADC group regular or group injected) */
  630. #define LL_ADC_OFFSET_2 ADC_OFR2_REGOFFSET /*!< ADC offset number 2: ADC channel and offset level to which the offset programmed will be applied (independently of channel mapped on ADC group regular or group injected) */
  631. #define LL_ADC_OFFSET_3 ADC_OFR3_REGOFFSET /*!< ADC offset number 3: ADC channel and offset level to which the offset programmed will be applied (independently of channel mapped on ADC group regular or group injected) */
  632. #define LL_ADC_OFFSET_4 ADC_OFR4_REGOFFSET /*!< ADC offset number 4: ADC channel and offset level to which the offset programmed will be applied (independently of channel mapped on ADC group regular or group injected) */
  633. /**
  634. * @}
  635. */
  636. /** @defgroup ADC_LL_EC_OFFSET_STATE ADC instance - Offset state
  637. * @{
  638. */
  639. #define LL_ADC_OFFSET_DISABLE ((uint32_t)0x00000000U)/*!< ADC offset disabled (among ADC selected offset number 1, 2, 3 or 4) */
  640. #define LL_ADC_OFFSET_ENABLE (ADC_OFR1_OFFSET1_EN) /*!< ADC offset enabled (among ADC selected offset number 1, 2, 3 or 4) */
  641. /**
  642. * @}
  643. */
  644. /** @defgroup ADC_LL_EC_GROUPS ADC instance - Groups
  645. * @{
  646. */
  647. #define LL_ADC_GROUP_REGULAR ((uint32_t)0x00000001U) /*!< ADC group regular (available on all STM32 devices) */
  648. #define LL_ADC_GROUP_INJECTED ((uint32_t)0x00000002U) /*!< ADC group injected (not available on all STM32 devices)*/
  649. #define LL_ADC_GROUP_REGULAR_INJECTED ((uint32_t)0x00000003U) /*!< ADC both groups regular and injected */
  650. /**
  651. * @}
  652. */
  653. /** @defgroup ADC_LL_EC_CHANNEL ADC instance - Channel number
  654. * @{
  655. */
  656. #define LL_ADC_CHANNEL_0 (ADC_CHANNEL_0_NUMBER | ADC_CHANNEL_0_SMP | ADC_CHANNEL_0_BITFIELD ) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN0 */
  657. #define LL_ADC_CHANNEL_1 (ADC_CHANNEL_1_NUMBER | ADC_CHANNEL_1_SMP | ADC_CHANNEL_1_BITFIELD ) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN1 */
  658. #define LL_ADC_CHANNEL_2 (ADC_CHANNEL_2_NUMBER | ADC_CHANNEL_2_SMP | ADC_CHANNEL_2_BITFIELD ) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN2 */
  659. #define LL_ADC_CHANNEL_3 (ADC_CHANNEL_3_NUMBER | ADC_CHANNEL_3_SMP | ADC_CHANNEL_3_BITFIELD ) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN3 */
  660. #define LL_ADC_CHANNEL_4 (ADC_CHANNEL_4_NUMBER | ADC_CHANNEL_4_SMP | ADC_CHANNEL_4_BITFIELD ) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN4 */
  661. #define LL_ADC_CHANNEL_5 (ADC_CHANNEL_5_NUMBER | ADC_CHANNEL_5_SMP | ADC_CHANNEL_5_BITFIELD ) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN5 */
  662. #define LL_ADC_CHANNEL_6 (ADC_CHANNEL_6_NUMBER | ADC_CHANNEL_6_SMP | ADC_CHANNEL_6_BITFIELD ) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN6 */
  663. #define LL_ADC_CHANNEL_7 (ADC_CHANNEL_7_NUMBER | ADC_CHANNEL_7_SMP | ADC_CHANNEL_7_BITFIELD ) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN7 */
  664. #define LL_ADC_CHANNEL_8 (ADC_CHANNEL_8_NUMBER | ADC_CHANNEL_8_SMP | ADC_CHANNEL_8_BITFIELD ) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN8 */
  665. #define LL_ADC_CHANNEL_9 (ADC_CHANNEL_9_NUMBER | ADC_CHANNEL_9_SMP | ADC_CHANNEL_9_BITFIELD ) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN9 */
  666. #define LL_ADC_CHANNEL_10 (ADC_CHANNEL_10_NUMBER | ADC_CHANNEL_10_SMP | ADC_CHANNEL_10_BITFIELD) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN10 */
  667. #define LL_ADC_CHANNEL_11 (ADC_CHANNEL_11_NUMBER | ADC_CHANNEL_11_SMP | ADC_CHANNEL_11_BITFIELD) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN11 */
  668. #define LL_ADC_CHANNEL_12 (ADC_CHANNEL_12_NUMBER | ADC_CHANNEL_12_SMP | ADC_CHANNEL_12_BITFIELD) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN12 */
  669. #define LL_ADC_CHANNEL_13 (ADC_CHANNEL_13_NUMBER | ADC_CHANNEL_13_SMP | ADC_CHANNEL_13_BITFIELD) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN13 */
  670. #define LL_ADC_CHANNEL_14 (ADC_CHANNEL_14_NUMBER | ADC_CHANNEL_14_SMP | ADC_CHANNEL_14_BITFIELD) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN14 */
  671. #define LL_ADC_CHANNEL_15 (ADC_CHANNEL_15_NUMBER | ADC_CHANNEL_15_SMP | ADC_CHANNEL_15_BITFIELD) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN15 */
  672. #define LL_ADC_CHANNEL_16 (ADC_CHANNEL_16_NUMBER | ADC_CHANNEL_16_SMP | ADC_CHANNEL_16_BITFIELD) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN16 */
  673. #define LL_ADC_CHANNEL_17 (ADC_CHANNEL_17_NUMBER | ADC_CHANNEL_17_SMP | ADC_CHANNEL_17_BITFIELD) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN17 */
  674. #define LL_ADC_CHANNEL_18 (ADC_CHANNEL_18_NUMBER | ADC_CHANNEL_18_SMP | ADC_CHANNEL_18_BITFIELD) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN18 */
  675. #define LL_ADC_CHANNEL_VREFINT (LL_ADC_CHANNEL_18 | ADC_CHANNEL_ID_INTERNAL_CH) /*!< ADC internal channel connected to VrefInt: Internal voltage reference. On STM32F3, ADC channel available only on all ADC instances, but only one ADC instance is allowed to be connected to VrefInt at the same time. */
  676. #define LL_ADC_CHANNEL_TEMPSENSOR (LL_ADC_CHANNEL_16 | ADC_CHANNEL_ID_INTERNAL_CH) /*!< ADC internal channel connected to Temperature sensor. On STM32F3, ADC channel available only on ADC instance: ADC1. */
  677. #define LL_ADC_CHANNEL_VBAT (LL_ADC_CHANNEL_17 | ADC_CHANNEL_ID_INTERNAL_CH) /*!< ADC internal channel connected to Vbat/3: Vbat voltage through a divider ladder of factor 1/3 to have Vbat always below Vdda. On STM32F3, ADC channel available only on ADC instance: ADC1. */
  678. #if defined(OPAMP1_CSR_OPAMP1EN)
  679. #define LL_ADC_CHANNEL_VOPAMP1 (LL_ADC_CHANNEL_15 | ADC_CHANNEL_ID_INTERNAL_CH) /*!< ADC internal channel connected to OPAMP1 output. On STM32F3, ADC channel available only on ADC instance: ADC1. */
  680. #endif
  681. #if defined(OPAMP2_CSR_OPAMP2EN)
  682. #define LL_ADC_CHANNEL_VOPAMP2 (LL_ADC_CHANNEL_17 | ADC_CHANNEL_ID_INTERNAL_CH | ADC_CHANNEL_ID_INTERNAL_CH_2) /*!< ADC internal channel connected to OPAMP2 output. On STM32F3, ADC channel available only on ADC instance: ADC2. */
  683. #endif
  684. #if defined(OPAMP3_CSR_OPAMP3EN)
  685. #define LL_ADC_CHANNEL_VOPAMP3 (LL_ADC_CHANNEL_17 | ADC_CHANNEL_ID_INTERNAL_CH | ADC_CHANNEL_ID_INTERNAL_CH_2) /*!< ADC internal channel connected to OPAMP3 output. On STM32F3, ADC channel available only on ADC instance: ADC3. */
  686. #endif
  687. #if defined(OPAMP4_CSR_OPAMP4EN)
  688. #define LL_ADC_CHANNEL_VOPAMP4 (LL_ADC_CHANNEL_17 | ADC_CHANNEL_ID_INTERNAL_CH | ADC_CHANNEL_ID_INTERNAL_CH_2) /*!< ADC internal channel connected to OPAMP4 output. On STM32F3, ADC channel available only on ADC instance: ADC4. */
  689. #endif
  690. /**
  691. * @}
  692. */
  693. /** @defgroup ADC_LL_EC_REG_TRIGGER_SOURCE ADC group regular - Trigger source
  694. * @{
  695. */
  696. #define LL_ADC_REG_TRIG_SOFTWARE ((uint32_t)0x00000000U) /*!< ADC group regular conversion trigger internal: SW start. */
  697. #if defined(STM32F303xC) || defined(STM32F358xx) || defined(STM32F303xE) || defined(STM32F398xx)
  698. /* ADC group regular external triggers for ADC instances: ADC1, ADC2 (for */
  699. /* ADC instances ADCx available on the selected device) */
  700. /* Note: Literal without suffix "ADCxy" means that external trigger */
  701. /* is available on all ADC instances. */
  702. /* Note: For devices STM32F303xE, STM32F398xx: some triggers require to set */
  703. /* register SYSCFG_CFGR4. Refer to reference manual. */
  704. #define LL_ADC_REG_TRIG_EXT_TIM1_CH1_ADC12 (ADC_REG_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group regular conversion trigger from external IP: TIM1 channel 1 event (capture compare: input capture or output capture). Trigger edge set to rising edge (default setting). */
  705. #define LL_ADC_REG_TRIG_EXT_TIM1_CH2_ADC12 (ADC_CFGR_EXTSEL_0 | ADC_REG_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group regular conversion trigger from external IP: TIM1 channel 2 event (capture compare: input capture or output capture). Trigger edge set to rising edge (default setting). */
  706. #define LL_ADC_REG_TRIG_EXT_TIM1_CH3 (ADC_CFGR_EXTSEL_1 | ADC_REG_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group regular conversion trigger from external IP: TIM1 channel 3 event (capture compare: input capture or output capture). Trigger edge set to rising edge (default setting). */
  707. #define LL_ADC_REG_TRIG_EXT_TIM2_CH2_ADC12 (ADC_CFGR_EXTSEL_1 | ADC_CFGR_EXTSEL_0 | ADC_REG_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group regular conversion trigger from external IP: TIM2 channel 2 event (capture compare: input capture or output capture). Trigger edge set to rising edge (default setting). */
  708. #define LL_ADC_REG_TRIG_EXT_TIM3_TRGO_ADC12 (ADC_CFGR_EXTSEL_2 | ADC_REG_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group regular conversion trigger from external IP: TIM3 TRGO. Trigger edge set to rising edge (default setting). */
  709. #define LL_ADC_REG_TRIG_EXT_TIM4_CH4_ADC12 (ADC_CFGR_EXTSEL_2 | ADC_CFGR_EXTSEL_0 | ADC_REG_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group regular conversion trigger from external IP: TIM4 channel 4 event (capture compare: input capture or output capture). Trigger edge set to rising edge (default setting). */
  710. #define LL_ADC_REG_TRIG_EXT_EXTI_LINE11_ADC12 (ADC_CFGR_EXTSEL_2 | ADC_CFGR_EXTSEL_1 | ADC_REG_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group regular conversion trigger from external IP: external interrupt line 11. Trigger edge set to rising edge (default setting). */
  711. #define LL_ADC_REG_TRIG_EXT_TIM8_TRGO_ADC12 (ADC_CFGR_EXTSEL_2 | ADC_CFGR_EXTSEL_1 | ADC_CFGR_EXTSEL_0 | ADC_REG_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group regular conversion trigger from external IP: TIM8 TRGO. Trigger edge set to rising edge (default setting). */
  712. #define LL_ADC_REG_TRIG_EXT_TIM8_TRGO2 (ADC_CFGR_EXTSEL_3 | ADC_REG_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group regular conversion trigger from external IP: TIM8 TRGO2. Trigger edge set to rising edge (default setting). */
  713. #define LL_ADC_REG_TRIG_EXT_TIM1_TRGO (ADC_CFGR_EXTSEL_3 | ADC_CFGR_EXTSEL_0 | ADC_REG_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group regular conversion trigger from external IP: TIM1 TRGO. Trigger edge set to rising edge (default setting). */
  714. #define LL_ADC_REG_TRIG_EXT_TIM1_TRGO2 (ADC_CFGR_EXTSEL_3 | ADC_CFGR_EXTSEL_1 | ADC_REG_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group regular conversion trigger from external IP: TIM1 TRGO2. Trigger edge set to rising edge (default setting). */
  715. #define LL_ADC_REG_TRIG_EXT_TIM2_TRGO_ADC12 (ADC_CFGR_EXTSEL_3 | ADC_CFGR_EXTSEL_1 | ADC_CFGR_EXTSEL_0 | ADC_REG_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group regular conversion trigger from external IP: TIM2 TRGO. Trigger edge set to rising edge (default setting). */
  716. #define LL_ADC_REG_TRIG_EXT_TIM4_TRGO (ADC_CFGR_EXTSEL_3 | ADC_CFGR_EXTSEL_2 | ADC_REG_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group regular conversion trigger from external IP: TIM4 TRGO. Trigger edge set to rising edge (default setting). */
  717. #define LL_ADC_REG_TRIG_EXT_TIM6_TRGO_ADC12 (ADC_CFGR_EXTSEL_3 | ADC_CFGR_EXTSEL_2 | ADC_CFGR_EXTSEL_0 | ADC_REG_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group regular conversion trigger from external IP: TIM6 TRGO. Trigger edge set to rising edge (default setting). */
  718. #define LL_ADC_REG_TRIG_EXT_TIM15_TRGO (ADC_CFGR_EXTSEL_3 | ADC_CFGR_EXTSEL_2 | ADC_CFGR_EXTSEL_1 | ADC_REG_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group regular conversion trigger from external IP: TIM15 TRGO. Trigger edge set to rising edge (default setting). */
  719. #define LL_ADC_REG_TRIG_EXT_TIM3_CH4_ADC12 (ADC_CFGR_EXTSEL | ADC_REG_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group regular conversion trigger from external IP: TIM3 channel 4 event (capture compare: input capture or output capture). Trigger edge set to rising edge (default setting). */
  720. #if defined(STM32F303xE) || defined(STM32F398xx)
  721. #define LL_ADC_REG_TRIG_EXT_TIM20_TRG0_ADC12 (LL_ADC_REG_TRIG_EXT_TIM1_CH3) /*!< ADC group regular conversion trigger from external IP: TIM20 TRGO. Trigger edge set to rising edge (default setting). */
  722. #define LL_ADC_REG_TRIG_EXT_TIM20_TRG02_ADC12 (LL_ADC_REG_TRIG_EXT_TIM2_CH2_ADC12) /*!< ADC group regular conversion trigger from external IP: TIM20 TRGO2. Trigger edge set to rising edge (default setting). */
  723. #define LL_ADC_REG_TRIG_EXT_TIM20_CH1_ADC12 (LL_ADC_REG_TRIG_EXT_TIM4_CH4_ADC12) /*!< ADC group regular conversion trigger from external IP: TIM20 channel 1 event (capture compare: input capture or output capture). Trigger edge set to rising edge (default setting). */
  724. #define LL_ADC_REG_TRIG_EXT_TIM20_CH2_ADC12 (LL_ADC_REG_TRIG_EXT_TIM6_TRGO_ADC12) /*!< ADC group regular conversion trigger from external IP: TIM20 channel 2 event (capture compare: input capture or output capture). Trigger edge set to rising edge (default setting). */
  725. #define LL_ADC_REG_TRIG_EXT_TIM20_CH3_ADC12 (LL_ADC_REG_TRIG_EXT_TIM3_CH4_ADC12) /*!< ADC group regular conversion trigger from external IP: TIM20 channel 3 event (capture compare: input capture or output capture). Trigger edge set to rising edge (default setting). */
  726. #endif /* STM32F303xE || STM32F398xx */
  727. /* ADC group regular external triggers for ADC instances: ADC3, ADC4 (for */
  728. /* ADC instances ADCx available on the selected device) */
  729. /* Note: Literal without suffix "ADCxy" means that external trigger */
  730. /* is available on all ADC instances. */
  731. /* Note: For devices STM32F303xE, STM32F398xx: some triggers require to set */
  732. /* register SYSCFG_CFGR4. Refer to reference manual. */
  733. #define LL_ADC_REG_TRIG_EXT_TIM3_CH1_ADC34 (ADC_REG_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group regular conversion trigger from external IP: TIM3 channel 1 event (capture compare: input capture or output capture). Trigger edge set to rising edge (default setting). */
  734. #define LL_ADC_REG_TRIG_EXT_TIM2_CH3_ADC34 (ADC_CFGR_EXTSEL_0 | ADC_REG_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group regular conversion trigger from external IP: TIM2 channel 3 event (capture compare: input capture or output capture). Trigger edge set to rising edge (default setting). */
  735. #define LL_ADC_REG_TRIG_EXT_TIM1_CH3 (ADC_CFGR_EXTSEL_1 | ADC_REG_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group regular conversion trigger from external IP: TIM1 channel 3 event (capture compare: input capture or output capture). Trigger edge set to rising edge (default setting). */
  736. #define LL_ADC_REG_TRIG_EXT_TIM8_CH1_ADC34 (ADC_CFGR_EXTSEL_1 | ADC_CFGR_EXTSEL_0 | ADC_REG_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group regular conversion trigger from external IP: TIM8 channel 1 event (capture compare: input capture or output capture). Trigger edge set to rising edge (default setting). */
  737. #define LL_ADC_REG_TRIG_EXT_TIM8_TRGO__ADC34 (ADC_CFGR_EXTSEL_2 | ADC_REG_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group regular conversion trigger from external IP: TIM8 TRGO. Trigger edge set to rising edge (default setting). */
  738. #define LL_ADC_REG_TRIG_EXT_EXTI_LINE2_ADC34 (ADC_CFGR_EXTSEL_2 | ADC_CFGR_EXTSEL_0 | ADC_REG_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group regular conversion trigger from external IP: external interrupt line 2. Trigger edge set to rising edge (default setting). */
  739. #define LL_ADC_REG_TRIG_EXT_TIM4_CH1_ADC34 (ADC_CFGR_EXTSEL_2 | ADC_CFGR_EXTSEL_1 | ADC_REG_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group regular conversion trigger from external IP: TIM4 channel 1 event (capture compare: input capture or output capture). Trigger edge set to rising edge (default setting). */
  740. #define LL_ADC_REG_TRIG_EXT_TIM2_TRGO__ADC34 (ADC_CFGR_EXTSEL_2 | ADC_CFGR_EXTSEL_1 | ADC_CFGR_EXTSEL_0 | ADC_REG_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group regular conversion trigger from external IP: TIM2 TRGO. Trigger edge set to rising edge (default setting). */
  741. #define LL_ADC_REG_TRIG_EXT_TIM8_TRGO2 (ADC_CFGR_EXTSEL_3 | ADC_REG_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group regular conversion trigger from external IP: TIM8 TRGO2. Trigger edge set to rising edge (default setting). */
  742. #define LL_ADC_REG_TRIG_EXT_TIM1_TRGO (ADC_CFGR_EXTSEL_3 | ADC_CFGR_EXTSEL_0 | ADC_REG_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group regular conversion trigger from external IP: TIM1 TRGO. Trigger edge set to rising edge (default setting). */
  743. #define LL_ADC_REG_TRIG_EXT_TIM1_TRGO2 (ADC_CFGR_EXTSEL_3 | ADC_CFGR_EXTSEL_1 | ADC_REG_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group regular conversion trigger from external IP: TIM1 TRGO2. Trigger edge set to rising edge (default setting). */
  744. #define LL_ADC_REG_TRIG_EXT_TIM3_TRGO__ADC34 (ADC_CFGR_EXTSEL_3 | ADC_CFGR_EXTSEL_1 | ADC_CFGR_EXTSEL_0 | ADC_REG_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group regular conversion trigger from external IP: TIM3 TRGO. Trigger edge set to rising edge (default setting). */
  745. #define LL_ADC_REG_TRIG_EXT_TIM4_TRGO (ADC_CFGR_EXTSEL_3 | ADC_CFGR_EXTSEL_2 | ADC_REG_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group regular conversion trigger from external IP: TIM4 TRGO. Trigger edge set to rising edge (default setting). */
  746. #define LL_ADC_REG_TRIG_EXT_TIM7_TRGO_ADC34 (ADC_CFGR_EXTSEL_3 | ADC_CFGR_EXTSEL_2 | ADC_CFGR_EXTSEL_0 | ADC_REG_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group regular conversion trigger from external IP: TIM7 TRGO. Trigger edge set to rising edge (default setting). */
  747. #define LL_ADC_REG_TRIG_EXT_TIM15_TRGO (ADC_CFGR_EXTSEL_3 | ADC_CFGR_EXTSEL_2 | ADC_CFGR_EXTSEL_1 | ADC_REG_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group regular conversion trigger from external IP: TIM15 TRGO. Trigger edge set to rising edge (default setting). */
  748. #define LL_ADC_REG_TRIG_EXT_TIM2_CH1_ADC34 (ADC_CFGR_EXTSEL | ADC_REG_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group regular conversion trigger from external IP: TIM2 CCx. Trigger edge set to rising edge (default setting). */
  749. #if defined(STM32F303xE) || defined(STM32F398xx)
  750. #define LL_ADC_REG_TRIG_EXT_TIM20_TRG0_ADC34 (LL_ADC_REG_TRIG_EXT_EXTI_LINE2_ADC34) /*!< ADC group regular conversion trigger from external IP: TIM20 TRGO. Trigger edge set to rising edge (default setting). */
  751. #define LL_ADC_REG_TRIG_EXT_TIM20_TRG02_ADC34 (LL_ADC_REG_TRIG_EXT_TIM4_CH1_ADC34) /*!< ADC group regular conversion trigger from external IP: TIM20 TRGO2. Trigger edge set to rising edge (default setting). */
  752. #define LL_ADC_REG_TRIG_EXT_TIM20_CH1_ADC34 (LL_ADC_REG_TRIG_EXT_TIM2_CH1_ADC34) /*!< ADC group regular conversion trigger from external IP: TIM20 channel 1 event (capture compare: input capture or output capture). Trigger edge set to rising edge (default setting). */
  753. #endif /* STM32F303xE || STM32F398xx */
  754. #elif defined(STM32F303x8) || defined(STM32F328xx)
  755. #define LL_ADC_REG_TRIG_EXT_TIM1_CH1 (ADC_REG_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group regular conversion trigger from external IP: TIM1 channel 1 event (capture compare: input capture or output capture). Trigger edge set to rising edge (default setting). */
  756. #define LL_ADC_REG_TRIG_EXT_TIM1_CH2 (ADC_CFGR_EXTSEL_0 | ADC_REG_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group regular conversion trigger from external IP: TIM1 channel 2 event (capture compare: input capture or output capture). Trigger edge set to rising edge (default setting). */
  757. #define LL_ADC_REG_TRIG_EXT_TIM1_CH3 (ADC_CFGR_EXTSEL_1 | ADC_REG_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group regular conversion trigger from external IP: TIM1 channel 3 event (capture compare: input capture or output capture). Trigger edge set to rising edge (default setting). */
  758. #define LL_ADC_REG_TRIG_EXT_TIM2_CH2 (ADC_CFGR_EXTSEL_1 | ADC_CFGR_EXTSEL_0 | ADC_REG_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group regular conversion trigger from external IP: TIM2 channel 2 event (capture compare: input capture or output capture). Trigger edge set to rising edge (default setting). */
  759. #define LL_ADC_REG_TRIG_EXT_TIM3_TRGO (ADC_CFGR_EXTSEL_2 | ADC_REG_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group regular conversion trigger from external IP: TIM3 TRGO. Trigger edge set to rising edge (default setting). */
  760. #define LL_ADC_REG_TRIG_EXT_TIM4_CH4 (ADC_CFGR_EXTSEL_2 | ADC_CFGR_EXTSEL_0 | ADC_REG_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group regular conversion trigger from external IP: TIM4 channel 4 event (capture compare: input capture or output capture). Trigger edge set to rising edge (default setting). */
  761. #define LL_ADC_REG_TRIG_EXT_EXTI_LINE11 (ADC_CFGR_EXTSEL_2 | ADC_CFGR_EXTSEL_1 | ADC_REG_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group regular conversion trigger from external IP: external interrupt line 11. Trigger edge set to rising edge (default setting). */
  762. #define LL_ADC_REG_TRIG_EXT_TIM8_TRGO (ADC_CFGR_EXTSEL_2 | ADC_CFGR_EXTSEL_1 | ADC_CFGR_EXTSEL_0 | ADC_REG_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group regular conversion trigger from external IP: TIM8 TRGO. Trigger edge set to rising edge (default setting). */
  763. #define LL_ADC_REG_TRIG_EXT_TIM1_TRGO (ADC_CFGR_EXTSEL_3 | ADC_CFGR_EXTSEL_0 | ADC_REG_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group regular conversion trigger from external IP: TIM1 TRGO. Trigger edge set to rising edge (default setting). */
  764. #define LL_ADC_REG_TRIG_EXT_TIM1_TRGO2 (ADC_CFGR_EXTSEL_3 | ADC_CFGR_EXTSEL_1 | ADC_REG_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group regular conversion trigger from external IP: TIM1 TRGO2. Trigger edge set to rising edge (default setting). */
  765. #define LL_ADC_REG_TRIG_EXT_TIM2_TRGO (ADC_CFGR_EXTSEL_3 | ADC_CFGR_EXTSEL_1 | ADC_CFGR_EXTSEL_0 | ADC_REG_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group regular conversion trigger from external IP: TIM2 TRGO. Trigger edge set to rising edge (default setting). */
  766. #define LL_ADC_REG_TRIG_EXT_TIM4_TRGO (ADC_CFGR_EXTSEL_3 | ADC_CFGR_EXTSEL_2 | ADC_REG_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group regular conversion trigger from external IP: TIM4 TRGO. Trigger edge set to rising edge (default setting). */
  767. #define LL_ADC_REG_TRIG_EXT_TIM6_TRGO (ADC_CFGR_EXTSEL_3 | ADC_CFGR_EXTSEL_2 | ADC_CFGR_EXTSEL_0 | ADC_REG_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group regular conversion trigger from external IP: TIM6 TRGO. Trigger edge set to rising edge (default setting). */
  768. #define LL_ADC_REG_TRIG_EXT_TIM15_TRGO (ADC_CFGR_EXTSEL_3 | ADC_CFGR_EXTSEL_2 | ADC_CFGR_EXTSEL_1 | ADC_REG_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group regular conversion trigger from external IP: TIM15 TRGO. Trigger edge set to rising edge (default setting). */
  769. #define LL_ADC_REG_TRIG_EXT_TIM3_CH4 (ADC_CFGR_EXTSEL | ADC_REG_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group regular conversion trigger from external IP: TIM3 channel 4 event (capture compare: input capture or output capture). Trigger edge set to rising edge (default setting). */
  770. #elif defined(STM32F334x8)
  771. #define LL_ADC_REG_TRIG_EXT_TIM1_CH1 (ADC_REG_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group regular conversion trigger from external IP: TIM1 channel 1 event (capture compare: input capture or output capture). Trigger edge set to rising edge (default setting). */
  772. #define LL_ADC_REG_TRIG_EXT_TIM1_CH2 (ADC_CFGR_EXTSEL_0 | ADC_REG_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group regular conversion trigger from external IP: TIM1 channel 2 event (capture compare: input capture or output capture). Trigger edge set to rising edge (default setting). */
  773. #define LL_ADC_REG_TRIG_EXT_TIM1_CH3 (ADC_CFGR_EXTSEL_1 | ADC_REG_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group regular conversion trigger from external IP: TIM1 channel 3 event (capture compare: input capture or output capture). Trigger edge set to rising edge (default setting). */
  774. #define LL_ADC_REG_TRIG_EXT_TIM2_CH2 (ADC_CFGR_EXTSEL_1 | ADC_CFGR_EXTSEL_0 | ADC_REG_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group regular conversion trigger from external IP: TIM2 channel 2 event (capture compare: input capture or output capture). Trigger edge set to rising edge (default setting). */
  775. #define LL_ADC_REG_TRIG_EXT_TIM3_TRGO (ADC_CFGR_EXTSEL_2 | ADC_REG_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group regular conversion trigger from external IP: TIM3 TRGO. Trigger edge set to rising edge (default setting). */
  776. #define LL_ADC_REG_TRIG_EXT_EXTI_LINE11 (ADC_CFGR_EXTSEL_2 | ADC_CFGR_EXTSEL_1 | ADC_REG_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group regular conversion trigger from external IP: external interrupt line 11. Trigger edge set to rising edge (default setting). */
  777. #define LL_ADC_REG_TRIG_EXT_HRTIM_TRG1 (ADC_CFGR_EXTSEL_2 | ADC_CFGR_EXTSEL_1 | ADC_CFGR_EXTSEL_0 | ADC_REG_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group regular conversion trigger from external IP: HRTIM TRG1. Trigger edge set to rising edge (default setting). */
  778. #define LL_ADC_REG_TRIG_EXT_HRTIM_TRG3 (ADC_CFGR_EXTSEL_3 | ADC_REG_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group regular conversion trigger from external IP: HRTIM TRG3. Trigger edge set to rising edge (default setting). */
  779. #define LL_ADC_REG_TRIG_EXT_TIM1_TRGO (ADC_CFGR_EXTSEL_3 | ADC_CFGR_EXTSEL_0 | ADC_REG_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group regular conversion trigger from external IP: TIM1 TRGO. Trigger edge set to rising edge (default setting). */
  780. #define LL_ADC_REG_TRIG_EXT_TIM1_TRGO2 (ADC_CFGR_EXTSEL_3 | ADC_CFGR_EXTSEL_1 | ADC_REG_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group regular conversion trigger from external IP: TIM1 TRGO2. Trigger edge set to rising edge (default setting). */
  781. #define LL_ADC_REG_TRIG_EXT_TIM2_TRGO (ADC_CFGR_EXTSEL_3 | ADC_CFGR_EXTSEL_1 | ADC_CFGR_EXTSEL_0 | ADC_REG_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group regular conversion trigger from external IP: TIM2 TRGO. Trigger edge set to rising edge (default setting). */
  782. #define LL_ADC_REG_TRIG_EXT_TIM6_TRGO (ADC_CFGR_EXTSEL_3 | ADC_CFGR_EXTSEL_2 | ADC_CFGR_EXTSEL_0 | ADC_REG_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group regular conversion trigger from external IP: TIM6 TRGO. Trigger edge set to rising edge (default setting). */
  783. #define LL_ADC_REG_TRIG_EXT_TIM15_TRGO (ADC_CFGR_EXTSEL_3 | ADC_CFGR_EXTSEL_2 | ADC_CFGR_EXTSEL_1 | ADC_REG_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group regular conversion trigger from external IP: TIM15 TRGO. Trigger edge set to rising edge (default setting). */
  784. #define LL_ADC_REG_TRIG_EXT_TIM3_CH4 (ADC_CFGR_EXTSEL | ADC_REG_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group regular conversion trigger from external IP: TIM3 channel 4 event (capture compare: input capture or output capture). Trigger edge set to rising edge (default setting). */
  785. #elif defined(STM32F302xC) || defined(STM32F302xE)
  786. #define LL_ADC_REG_TRIG_EXT_TIM1_CH1 (ADC_REG_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group regular conversion trigger from external IP: TIM1 channel 1 event (capture compare: input capture or output capture). Trigger edge set to rising edge (default setting). */
  787. #define LL_ADC_REG_TRIG_EXT_TIM1_CH2 (ADC_CFGR_EXTSEL_0 | ADC_REG_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group regular conversion trigger from external IP: TIM1 channel 2 event (capture compare: input capture or output capture). Trigger edge set to rising edge (default setting). */
  788. #define LL_ADC_REG_TRIG_EXT_TIM1_CH3 (ADC_CFGR_EXTSEL_1 | ADC_REG_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group regular conversion trigger from external IP: TIM1 channel 3 event (capture compare: input capture or output capture). Trigger edge set to rising edge (default setting). */
  789. #define LL_ADC_REG_TRIG_EXT_TIM2_CH2 (ADC_CFGR_EXTSEL_1 | ADC_CFGR_EXTSEL_0 | ADC_REG_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group regular conversion trigger from external IP: TIM2 channel 2 event (capture compare: input capture or output capture). Trigger edge set to rising edge (default setting). */
  790. #define LL_ADC_REG_TRIG_EXT_TIM3_TRGO (ADC_CFGR_EXTSEL_2 | ADC_REG_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group regular conversion trigger from external IP: TIM3 TRGO. Trigger edge set to rising edge (default setting). */
  791. #define LL_ADC_REG_TRIG_EXT_TIM4_CH4 (ADC_CFGR_EXTSEL_2 | ADC_CFGR_EXTSEL_0 | ADC_REG_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group regular conversion trigger from external IP: TIM4 channel 4 event (capture compare: input capture or output capture). Trigger edge set to rising edge (default setting). */
  792. #define LL_ADC_REG_TRIG_EXT_EXTI_LINE11 (ADC_CFGR_EXTSEL_2 | ADC_CFGR_EXTSEL_1 | ADC_REG_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group regular conversion trigger from external IP: external interrupt line 11. Trigger edge set to rising edge (default setting). */
  793. #define LL_ADC_REG_TRIG_EXT_TIM1_TRGO (ADC_CFGR_EXTSEL_3 | ADC_CFGR_EXTSEL_0 | ADC_REG_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group regular conversion trigger from external IP: TIM1 TRGO. Trigger edge set to rising edge (default setting). */
  794. #define LL_ADC_REG_TRIG_EXT_TIM1_TRGO2 (ADC_CFGR_EXTSEL_3 | ADC_CFGR_EXTSEL_1 | ADC_REG_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group regular conversion trigger from external IP: TIM1 TRGO2. Trigger edge set to rising edge (default setting). */
  795. #define LL_ADC_REG_TRIG_EXT_TIM2_TRGO (ADC_CFGR_EXTSEL_3 | ADC_CFGR_EXTSEL_1 | ADC_CFGR_EXTSEL_0 | ADC_REG_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group regular conversion trigger from external IP: TIM2 TRGO. Trigger edge set to rising edge (default setting). */
  796. #define LL_ADC_REG_TRIG_EXT_TIM4_TRGO (ADC_CFGR_EXTSEL_3 | ADC_CFGR_EXTSEL_2 | ADC_REG_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group regular conversion trigger from external IP: TIM4 TRGO. Trigger edge set to rising edge (default setting). */
  797. #define LL_ADC_REG_TRIG_EXT_TIM6_TRGO (ADC_CFGR_EXTSEL_3 | ADC_CFGR_EXTSEL_2 | ADC_CFGR_EXTSEL_0 | ADC_REG_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group regular conversion trigger from external IP: TIM6 TRGO. Trigger edge set to rising edge (default setting). */
  798. #define LL_ADC_REG_TRIG_EXT_TIM15_TRGO (ADC_CFGR_EXTSEL_3 | ADC_CFGR_EXTSEL_2 | ADC_CFGR_EXTSEL_1 | ADC_REG_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group regular conversion trigger from external IP: TIM15 TRGO. Trigger edge set to rising edge (default setting). */
  799. #define LL_ADC_REG_TRIG_EXT_TIM3_CH4 (ADC_CFGR_EXTSEL | ADC_REG_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group regular conversion trigger from external IP: TIM3 channel 4 event (capture compare: input capture or output capture). Trigger edge set to rising edge (default setting). */
  800. #elif defined(STM32F301x8) || defined(STM32F302x8) || defined(STM32F318xx)
  801. #define LL_ADC_REG_TRIG_EXT_TIM1_CH1 (ADC_REG_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group regular conversion trigger from external IP: TIM1 channel 1 event (capture compare: input capture or output capture). Trigger edge set to rising edge (default setting). */
  802. #define LL_ADC_REG_TRIG_EXT_TIM1_CH2 (ADC_CFGR_EXTSEL_0 | ADC_REG_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group regular conversion trigger from external IP: TIM1 channel 2 event (capture compare: input capture or output capture). Trigger edge set to rising edge (default setting). */
  803. #define LL_ADC_REG_TRIG_EXT_TIM1_CH3 (ADC_CFGR_EXTSEL_1 | ADC_REG_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group regular conversion trigger from external IP: TIM1 channel 3 event (capture compare: input capture or output capture). Trigger edge set to rising edge (default setting). */
  804. #define LL_ADC_REG_TRIG_EXT_TIM2_CH2 (ADC_CFGR_EXTSEL_1 | ADC_CFGR_EXTSEL_0 | ADC_REG_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group regular conversion trigger from external IP: TIM2 channel 2 event (capture compare: input capture or output capture). Trigger edge set to rising edge (default setting). */
  805. #define LL_ADC_REG_TRIG_EXT_EXTI_LINE11 (ADC_CFGR_EXTSEL_2 | ADC_CFGR_EXTSEL_1 | ADC_REG_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group regular conversion trigger from external IP: external interrupt line 11. Trigger edge set to rising edge (default setting). */
  806. #define LL_ADC_REG_TRIG_EXT_TIM1_TRGO (ADC_CFGR_EXTSEL_3 | ADC_CFGR_EXTSEL_0 | ADC_REG_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group regular conversion trigger from external IP: TIM1 TRGO. Trigger edge set to rising edge (default setting). */
  807. #define LL_ADC_REG_TRIG_EXT_TIM1_TRGO2 (ADC_CFGR_EXTSEL_3 | ADC_CFGR_EXTSEL_1 | ADC_REG_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group regular conversion trigger from external IP: TIM1 TRGO2. Trigger edge set to rising edge (default setting). */
  808. #define LL_ADC_REG_TRIG_EXT_TIM2_TRGO (ADC_CFGR_EXTSEL_3 | ADC_CFGR_EXTSEL_1 | ADC_CFGR_EXTSEL_0 | ADC_REG_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group regular conversion trigger from external IP: TIM2 TRGO. Trigger edge set to rising edge (default setting). */
  809. #define LL_ADC_REG_TRIG_EXT_TIM6_TRGO (ADC_CFGR_EXTSEL_3 | ADC_CFGR_EXTSEL_2 | ADC_CFGR_EXTSEL_0 | ADC_REG_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group regular conversion trigger from external IP: TIM6 TRGO. Trigger edge set to rising edge (default setting). */
  810. #define LL_ADC_REG_TRIG_EXT_TIM15_TRGO (ADC_CFGR_EXTSEL_3 | ADC_CFGR_EXTSEL_2 | ADC_CFGR_EXTSEL_1 | ADC_REG_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group regular conversion trigger from external IP: TIM15 TRGO. Trigger edge set to rising edge (default setting). */
  811. #endif
  812. /**
  813. * @}
  814. */
  815. /** @defgroup ADC_LL_EC_REG_TRIGGER_EDGE ADC group regular - Trigger edge
  816. * @{
  817. */
  818. #define LL_ADC_REG_TRIG_EXT_RISING ( ADC_CFGR_EXTEN_0) /*!< ADC group regular conversion trigger polarity set to rising edge */
  819. #define LL_ADC_REG_TRIG_EXT_FALLING (ADC_CFGR_EXTEN_1 ) /*!< ADC group regular conversion trigger polarity set to falling edge */
  820. #define LL_ADC_REG_TRIG_EXT_RISINGFALLING (ADC_CFGR_EXTEN_1 | ADC_CFGR_EXTEN_0) /*!< ADC group regular conversion trigger polarity set to both rising and falling edges */
  821. /**
  822. * @}
  823. */
  824. /** @defgroup ADC_LL_EC_REG_CONTINUOUS_MODE ADC group regular - Continuous mode
  825. * @{
  826. */
  827. #define LL_ADC_REG_CONV_SINGLE ((uint32_t)0x00000000U) /*!< ADC conversions are performed in single mode: one conversion per trigger */
  828. #define LL_ADC_REG_CONV_CONTINUOUS (ADC_CFGR_CONT) /*!< ADC conversions are performed in continuous mode: after the first trigger, following conversions launched successively automatically */
  829. /**
  830. * @}
  831. */
  832. /** @defgroup ADC_LL_EC_REG_DMA_TRANSFER ADC group regular - DMA transfer of ADC conversion data
  833. * @{
  834. */
  835. #define LL_ADC_REG_DMA_TRANSFER_NONE ((uint32_t)0x00000000U) /*!< ADC conversions are not transferred by DMA */
  836. #define LL_ADC_REG_DMA_TRANSFER_LIMITED ( ADC_CFGR_DMAEN) /*!< ADC conversion data are transferred by DMA, in limited mode (one shot mode): DMA transfer requests are stopped when number of DMA data transfers (number of ADC conversions) is reached. This ADC mode is intended to be used with DMA mode non-circular. */
  837. #define LL_ADC_REG_DMA_TRANSFER_UNLIMITED (ADC_CFGR_DMACFG | ADC_CFGR_DMAEN) /*!< ADC conversion data are transferred by DMA, in unlimited mode: DMA transfer requests are unlimited, whatever number of DMA data transferred (number of ADC conversions). This ADC mode is intended to be used with DMA mode circular. */
  838. /**
  839. * @}
  840. */
  841. /** @defgroup ADC_LL_EC_REG_OVR_DATA_BEHAVIOR ADC group regular - Overrun behavior on conversion data
  842. * @{
  843. */
  844. #define LL_ADC_REG_OVR_DATA_PRESERVED ((uint32_t)0x00000000U)/*!< ADC group regular behavior in case of overrun: data preserved */
  845. #define LL_ADC_REG_OVR_DATA_OVERWRITTEN (ADC_CFGR_OVRMOD) /*!< ADC group regular behavior in case of overrun: data overwritten */
  846. /**
  847. * @}
  848. */
  849. /** @defgroup ADC_LL_EC_REG_SEQ_SCAN_LENGTH ADC group regular - Sequencer scan length
  850. * @{
  851. */
  852. #define LL_ADC_REG_SEQ_SCAN_DISABLE ((uint32_t)0x00000000U) /*!< ADC group regular sequencer disable (equivalent to sequencer of 1 rank: ADC conversion on only 1 channel) */
  853. #define LL_ADC_REG_SEQ_SCAN_ENABLE_2RANKS ( ADC_SQR1_L_0) /*!< ADC group regular sequencer enable with 2 ranks in the sequence */
  854. #define LL_ADC_REG_SEQ_SCAN_ENABLE_3RANKS ( ADC_SQR1_L_1 ) /*!< ADC group regular sequencer enable with 3 ranks in the sequence */
  855. #define LL_ADC_REG_SEQ_SCAN_ENABLE_4RANKS ( ADC_SQR1_L_1 | ADC_SQR1_L_0) /*!< ADC group regular sequencer enable with 4 ranks in the sequence */
  856. #define LL_ADC_REG_SEQ_SCAN_ENABLE_5RANKS ( ADC_SQR1_L_2 ) /*!< ADC group regular sequencer enable with 5 ranks in the sequence */
  857. #define LL_ADC_REG_SEQ_SCAN_ENABLE_6RANKS ( ADC_SQR1_L_2 | ADC_SQR1_L_0) /*!< ADC group regular sequencer enable with 6 ranks in the sequence */
  858. #define LL_ADC_REG_SEQ_SCAN_ENABLE_7RANKS ( ADC_SQR1_L_2 | ADC_SQR1_L_1 ) /*!< ADC group regular sequencer enable with 7 ranks in the sequence */
  859. #define LL_ADC_REG_SEQ_SCAN_ENABLE_8RANKS ( ADC_SQR1_L_2 | ADC_SQR1_L_1 | ADC_SQR1_L_0) /*!< ADC group regular sequencer enable with 8 ranks in the sequence */
  860. #define LL_ADC_REG_SEQ_SCAN_ENABLE_9RANKS (ADC_SQR1_L_3 ) /*!< ADC group regular sequencer enable with 9 ranks in the sequence */
  861. #define LL_ADC_REG_SEQ_SCAN_ENABLE_10RANKS (ADC_SQR1_L_3 | ADC_SQR1_L_0) /*!< ADC group regular sequencer enable with 10 ranks in the sequence */
  862. #define LL_ADC_REG_SEQ_SCAN_ENABLE_11RANKS (ADC_SQR1_L_3 | ADC_SQR1_L_1 ) /*!< ADC group regular sequencer enable with 11 ranks in the sequence */
  863. #define LL_ADC_REG_SEQ_SCAN_ENABLE_12RANKS (ADC_SQR1_L_3 | ADC_SQR1_L_1 | ADC_SQR1_L_0) /*!< ADC group regular sequencer enable with 12 ranks in the sequence */
  864. #define LL_ADC_REG_SEQ_SCAN_ENABLE_13RANKS (ADC_SQR1_L_3 | ADC_SQR1_L_2 ) /*!< ADC group regular sequencer enable with 13 ranks in the sequence */
  865. #define LL_ADC_REG_SEQ_SCAN_ENABLE_14RANKS (ADC_SQR1_L_3 | ADC_SQR1_L_2 | ADC_SQR1_L_0) /*!< ADC group regular sequencer enable with 14 ranks in the sequence */
  866. #define LL_ADC_REG_SEQ_SCAN_ENABLE_15RANKS (ADC_SQR1_L_3 | ADC_SQR1_L_2 | ADC_SQR1_L_1 ) /*!< ADC group regular sequencer enable with 15 ranks in the sequence */
  867. #define LL_ADC_REG_SEQ_SCAN_ENABLE_16RANKS (ADC_SQR1_L_3 | ADC_SQR1_L_2 | ADC_SQR1_L_1 | ADC_SQR1_L_0) /*!< ADC group regular sequencer enable with 16 ranks in the sequence */
  868. /**
  869. * @}
  870. */
  871. /** @defgroup ADC_LL_EC_REG_SEQ_DISCONT_MODE ADC group regular - Sequencer discontinuous mode
  872. * @{
  873. */
  874. #define LL_ADC_REG_SEQ_DISCONT_DISABLE ((uint32_t)0x00000000U) /*!< ADC group regular sequencer discontinuous mode disable */
  875. #define LL_ADC_REG_SEQ_DISCONT_1RANK ( ADC_CFGR_DISCEN) /*!< ADC group regular sequencer discontinuous mode enable with sequence interruption every rank */
  876. #define LL_ADC_REG_SEQ_DISCONT_2RANKS ( ADC_CFGR_DISCNUM_0 | ADC_CFGR_DISCEN) /*!< ADC group regular sequencer discontinuous mode enabled with sequence interruption every 2 ranks */
  877. #define LL_ADC_REG_SEQ_DISCONT_3RANKS ( ADC_CFGR_DISCNUM_1 | ADC_CFGR_DISCEN) /*!< ADC group regular sequencer discontinuous mode enable with sequence interruption every 3 ranks */
  878. #define LL_ADC_REG_SEQ_DISCONT_4RANKS ( ADC_CFGR_DISCNUM_1 | ADC_CFGR_DISCNUM_0 | ADC_CFGR_DISCEN) /*!< ADC group regular sequencer discontinuous mode enable with sequence interruption every 4 ranks */
  879. #define LL_ADC_REG_SEQ_DISCONT_5RANKS (ADC_CFGR_DISCNUM_2 | ADC_CFGR_DISCEN) /*!< ADC group regular sequencer discontinuous mode enable with sequence interruption every 5 ranks */
  880. #define LL_ADC_REG_SEQ_DISCONT_6RANKS (ADC_CFGR_DISCNUM_2 | ADC_CFGR_DISCNUM_0 | ADC_CFGR_DISCEN) /*!< ADC group regular sequencer discontinuous mode enable with sequence interruption every 6 ranks */
  881. #define LL_ADC_REG_SEQ_DISCONT_7RANKS (ADC_CFGR_DISCNUM_2 | ADC_CFGR_DISCNUM_1 | ADC_CFGR_DISCEN) /*!< ADC group regular sequencer discontinuous mode enable with sequence interruption every 7 ranks */
  882. #define LL_ADC_REG_SEQ_DISCONT_8RANKS (ADC_CFGR_DISCNUM_2 | ADC_CFGR_DISCNUM_1 | ADC_CFGR_DISCNUM_0 | ADC_CFGR_DISCEN) /*!< ADC group regular sequencer discontinuous mode enable with sequence interruption every 8 ranks */
  883. /**
  884. * @}
  885. */
  886. /** @defgroup ADC_LL_EC_REG_SEQ_RANKS ADC group regular - Sequencer ranks
  887. * @{
  888. */
  889. #define LL_ADC_REG_RANK_1 (ADC_SQR1_REGOFFSET | ADC_REG_RANK_1_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 1 */
  890. #define LL_ADC_REG_RANK_2 (ADC_SQR1_REGOFFSET | ADC_REG_RANK_2_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 2 */
  891. #define LL_ADC_REG_RANK_3 (ADC_SQR1_REGOFFSET | ADC_REG_RANK_3_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 3 */
  892. #define LL_ADC_REG_RANK_4 (ADC_SQR1_REGOFFSET | ADC_REG_RANK_4_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 4 */
  893. #define LL_ADC_REG_RANK_5 (ADC_SQR2_REGOFFSET | ADC_REG_RANK_5_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 5 */
  894. #define LL_ADC_REG_RANK_6 (ADC_SQR2_REGOFFSET | ADC_REG_RANK_6_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 6 */
  895. #define LL_ADC_REG_RANK_7 (ADC_SQR2_REGOFFSET | ADC_REG_RANK_7_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 7 */
  896. #define LL_ADC_REG_RANK_8 (ADC_SQR2_REGOFFSET | ADC_REG_RANK_8_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 8 */
  897. #define LL_ADC_REG_RANK_9 (ADC_SQR2_REGOFFSET | ADC_REG_RANK_9_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 9 */
  898. #define LL_ADC_REG_RANK_10 (ADC_SQR3_REGOFFSET | ADC_REG_RANK_10_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 10 */
  899. #define LL_ADC_REG_RANK_11 (ADC_SQR3_REGOFFSET | ADC_REG_RANK_11_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 11 */
  900. #define LL_ADC_REG_RANK_12 (ADC_SQR3_REGOFFSET | ADC_REG_RANK_12_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 12 */
  901. #define LL_ADC_REG_RANK_13 (ADC_SQR3_REGOFFSET | ADC_REG_RANK_13_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 13 */
  902. #define LL_ADC_REG_RANK_14 (ADC_SQR3_REGOFFSET | ADC_REG_RANK_14_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 14 */
  903. #define LL_ADC_REG_RANK_15 (ADC_SQR4_REGOFFSET | ADC_REG_RANK_15_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 15 */
  904. #define LL_ADC_REG_RANK_16 (ADC_SQR4_REGOFFSET | ADC_REG_RANK_16_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 16 */
  905. /**
  906. * @}
  907. */
  908. /** @defgroup ADC_LL_EC_INJ_TRIGGER_SOURCE ADC group injected - Trigger source
  909. * @{
  910. */
  911. #define LL_ADC_INJ_TRIG_SOFTWARE ((uint32_t)0x00000000U) /*!< ADC group injected conversion trigger internal: SW start.. Trigger edge set to rising edge (default setting). */
  912. #if defined(STM32F303xC) || defined(STM32F358xx) || defined(STM32F303xE) || defined(STM32F398xx)
  913. /* ADC group injected external triggers for ADC instances: ADC1, ADC2 (for */
  914. /* ADC instances ADCx available on the selected device) */
  915. /* Note: Literal without suffix "ADCxy" means that external trigger */
  916. /* is available on all ADC instances. */
  917. /* Note: For devices STM32F303xE, STM32F398xx: some triggers require to set */
  918. /* register SYSCFG_CFGR4. Refer to reference manual. */
  919. #define LL_ADC_INJ_TRIG_EXT_TIM1_TRGO (ADC_INJ_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group injected conversion trigger from external IP: TIM1 TRG0. Trigger edge set to rising edge (default setting). */
  920. #define LL_ADC_INJ_TRIG_EXT_TIM1_CH4 (ADC_JSQR_JEXTSEL_0 | ADC_INJ_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group injected conversion trigger from external IP: TIM1 channel 4 event (capture compare: input capture or output capture). Trigger edge set to rising edge (default setting). */
  921. #define LL_ADC_INJ_TRIG_EXT_TIM2_TRGO_ADC12 (ADC_JSQR_JEXTSEL_1 | ADC_INJ_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group injected conversion trigger from external IP: TIM2 TRG0. Trigger edge set to rising edge (default setting). */
  922. #define LL_ADC_INJ_TRIG_EXT_TIM2_CH1_ADC12 (ADC_JSQR_JEXTSEL_1 | ADC_JSQR_JEXTSEL_0 | ADC_INJ_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group injected conversion trigger from external IP: TIM2 channel 1 event (capture compare: input capture or output capture). Trigger edge set to rising edge (default setting). */
  923. #define LL_ADC_INJ_TRIG_EXT_TIM3_CH4_ADC12 (ADC_JSQR_JEXTSEL_2 | ADC_INJ_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group injected conversion trigger from external IP: TIM3 channel 4 event (capture compare: input capture or output capture). Trigger edge set to rising edge (default setting). */
  924. #define LL_ADC_INJ_TRIG_EXT_TIM4_TRGO_ADC12 (ADC_JSQR_JEXTSEL_2 | ADC_JSQR_JEXTSEL_0 | ADC_INJ_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group injected conversion trigger from external IP: TIM4 TRG0. Trigger edge set to rising edge (default setting). */
  925. #define LL_ADC_INJ_TRIG_EXT_EXTI_LINE15_ADC12 (ADC_JSQR_JEXTSEL_2 | ADC_JSQR_JEXTSEL_1 | ADC_INJ_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group injected conversion trigger from external IP: external interrupt line 15. Trigger edge set to rising edge (default setting). */
  926. #define LL_ADC_INJ_TRIG_EXT_TIM8_CH4_ADC12 (ADC_JSQR_JEXTSEL_2 | ADC_JSQR_JEXTSEL_1 | ADC_JSQR_JEXTSEL_0 | ADC_INJ_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group injected conversion trigger from external IP: TIM8 channel 4 event (capture compare: input capture or output capture). Trigger edge set to rising edge (default setting). */
  927. #define LL_ADC_INJ_TRIG_EXT_TIM1_TRGO2 (ADC_JSQR_JEXTSEL_3 | ADC_INJ_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group injected conversion trigger from external IP: TIM1 TRG02. Trigger edge set to rising edge (default setting). */
  928. #define LL_ADC_INJ_TRIG_EXT_TIM8_TRGO (ADC_JSQR_JEXTSEL_3 | ADC_JSQR_JEXTSEL_0 | ADC_INJ_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group injected conversion trigger from external IP: TIM8 TRG0. Trigger edge set to rising edge (default setting). */
  929. #define LL_ADC_INJ_TRIG_EXT_TIM8_TRGO2 (ADC_JSQR_JEXTSEL_3 | ADC_JSQR_JEXTSEL_1 | ADC_INJ_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group injected conversion trigger from external IP: TIM8 TRG02. Trigger edge set to rising edge (default setting). */
  930. #define LL_ADC_INJ_TRIG_EXT_TIM3_CH3_ADC12 (ADC_JSQR_JEXTSEL_3 | ADC_JSQR_JEXTSEL_1 | ADC_JSQR_JEXTSEL_0 | ADC_INJ_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group injected conversion trigger from external IP: TIM3 channel 3 event (capture compare: input capture or output capture). Trigger edge set to rising edge (default setting). */
  931. #define LL_ADC_INJ_TRIG_EXT_TIM3_TRGO (ADC_JSQR_JEXTSEL_3 | ADC_JSQR_JEXTSEL_2 | ADC_INJ_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group injected conversion trigger from external IP: TIM3 TRG0. Trigger edge set to rising edge (default setting). */
  932. #define LL_ADC_INJ_TRIG_EXT_TIM3_CH1_ADC12 (ADC_JSQR_JEXTSEL_3 | ADC_JSQR_JEXTSEL_2 | ADC_JSQR_JEXTSEL_0 | ADC_INJ_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group injected conversion trigger from external IP: TIM3 channel 1 event (capture compare: input capture or output capture). Trigger edge set to rising edge (default setting). */
  933. #define LL_ADC_INJ_TRIG_EXT_TIM6_TRGO_ADC12 (ADC_JSQR_JEXTSEL_3 | ADC_JSQR_JEXTSEL_2 | ADC_JSQR_JEXTSEL_1 | ADC_INJ_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group injected conversion trigger from external IP: TIM6 TRG0. Trigger edge set to rising edge (default setting). */
  934. #define LL_ADC_INJ_TRIG_EXT_TIM15_TRGO (ADC_JSQR_JEXTSEL | ADC_INJ_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group injected conversion trigger from external IP: TIM15 TRG0. Trigger edge set to rising edge (default setting). */
  935. #if defined(STM32F303xE) || defined(STM32F398xx)
  936. #define LL_ADC_INJ_TRIG_EXT_TIM20_TRGO_ADC12 (LL_ADC_INJ_TRIG_EXT_TIM2_CH1_ADC12) /*!< ADC group injected conversion trigger from external IP: TIM20 TRG0. Trigger edge set to rising edge (default setting). */
  937. #define LL_ADC_INJ_TRIG_EXT_TIM20_TRGO2_ADC12 (LL_ADC_INJ_TRIG_EXT_EXTI_LINE15_ADC12) /*!< ADC group injected conversion trigger from external IP: TIM20 TRG02. Trigger edge set to rising edge (default setting). */
  938. #define LL_ADC_INJ_TRIG_EXT_TIM20_CH4_ADC12 (LL_ADC_INJ_TRIG_EXT_TIM2_CH1_ADC12) /*!< ADC group injected conversion trigger from external IP: TIM20 channel 4 event (capture compare: input capture or output capture). Trigger edge set to rising edge (default setting). */
  939. #endif /* STM32F303xE || STM32F398xx */
  940. /* ADC group injected external triggers for ADC instances: ADC3, ADC4 (for */
  941. /* ADC instances ADCx available on the selected device) */
  942. /* Note: Literal without suffix "ADCxy" means that external trigger */
  943. /* is available on all ADC instances. */
  944. /* Note: External triggers JEXT2 and JEXT5 are the same (TIM4_CH3 event). */
  945. /* JEXT2 is the main trigger, JEXT5 is kept as spare trigger for */
  946. /* future devices. */
  947. /* Note: For devices STM32F303xE, STM32F398xx: some triggers require to set */
  948. /* register SYSCFG_CFGR4. Refer to reference manual. */
  949. #define LL_ADC_INJ_TRIG_EXT_TIM1_TRGO (ADC_INJ_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group injected conversion trigger from external IP: TIM1 TRG0. Trigger edge set to rising edge (default setting). */
  950. #define LL_ADC_INJ_TRIG_EXT_TIM1_CH4 (ADC_JSQR_JEXTSEL_0 | ADC_INJ_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group injected conversion trigger from external IP: TIM1 channel 4 event (capture compare: input capture or output capture). Trigger edge set to rising edge (default setting). */
  951. #define LL_ADC_INJ_TRIG_EXT_TIM4_CH3_ADC34 (ADC_JSQR_JEXTSEL_1 | ADC_INJ_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group injected conversion trigger from external IP: TIM4 channel 3 event (capture compare: input capture or output capture). Trigger edge set to rising edge (default setting). */
  952. #define LL_ADC_INJ_TRIG_EXT_TIM8_CH2_ADC34 (ADC_JSQR_JEXTSEL_1 | ADC_JSQR_JEXTSEL_0 | ADC_INJ_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group injected conversion trigger from external IP: TIM8 channel 2 event (capture compare: input capture or output capture). Trigger edge set to rising edge (default setting). */
  953. #define LL_ADC_INJ_TRIG_EXT_TIM8_CH4__ADC34 (ADC_JSQR_JEXTSEL_2 | ADC_INJ_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group injected conversion trigger from external IP: TIM8 channel 4 event (capture compare: input capture or output capture). Trigger edge set to rising edge (default setting). */
  954. #define LL_ADC_INJ_TRIG_EXT_TIM4_CH4_ADC34 (ADC_JSQR_JEXTSEL_2 | ADC_JSQR_JEXTSEL_1 | ADC_INJ_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group injected conversion trigger from external IP: TIM4 channel 4 event (capture compare: input capture or output capture). Trigger edge set to rising edge (default setting). */
  955. #define LL_ADC_INJ_TRIG_EXT_TIM4_TRGO__ADC34 (ADC_JSQR_JEXTSEL_2 | ADC_JSQR_JEXTSEL_1 | ADC_JSQR_JEXTSEL_0 | ADC_INJ_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group injected conversion trigger from external IP: TIM4 TRG0. Trigger edge set to rising edge (default setting). */
  956. #define LL_ADC_INJ_TRIG_EXT_TIM1_TRGO2 (ADC_JSQR_JEXTSEL_3 | ADC_INJ_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group injected conversion trigger from external IP: TIM1 TRG02. Trigger edge set to rising edge (default setting). */
  957. #define LL_ADC_INJ_TRIG_EXT_TIM8_TRGO (ADC_JSQR_JEXTSEL_3 | ADC_JSQR_JEXTSEL_0 | ADC_INJ_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group injected conversion trigger from external IP: TIM8 TRG0. Trigger edge set to rising edge (default setting). */
  958. #define LL_ADC_INJ_TRIG_EXT_TIM8_TRGO2 (ADC_JSQR_JEXTSEL_3 | ADC_JSQR_JEXTSEL_1 | ADC_INJ_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group injected conversion trigger from external IP: TIM8 TRG02. Trigger edge set to rising edge (default setting). */
  959. #define LL_ADC_INJ_TRIG_EXT_TIM1_CH3_ADC34 (ADC_JSQR_JEXTSEL_3 | ADC_JSQR_JEXTSEL_1 | ADC_JSQR_JEXTSEL_0 | ADC_INJ_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group injected conversion trigger from external IP: TIM1 channel 3 event (capture compare: input capture or output capture). Trigger edge set to rising edge (default setting). */
  960. #define LL_ADC_INJ_TRIG_EXT_TIM3_TRGO (ADC_JSQR_JEXTSEL_3 | ADC_JSQR_JEXTSEL_2 | ADC_INJ_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group injected conversion trigger from external IP: TIM3 TRG0. Trigger edge set to rising edge (default setting). */
  961. #define LL_ADC_INJ_TRIG_EXT_TIM2_TRGO__ADC34 (ADC_JSQR_JEXTSEL_3 | ADC_JSQR_JEXTSEL_2 | ADC_JSQR_JEXTSEL_0 | ADC_INJ_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group injected conversion trigger from external IP: TIM2 TRG0. Trigger edge set to rising edge (default setting). */
  962. #define LL_ADC_INJ_TRIG_EXT_TIM7_TRGO_ADC34 (ADC_JSQR_JEXTSEL_3 | ADC_JSQR_JEXTSEL_2 | ADC_JSQR_JEXTSEL_1 | ADC_INJ_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group injected conversion trigger from external IP: TIM7 TRG0. Trigger edge set to rising edge (default setting). */
  963. #define LL_ADC_INJ_TRIG_EXT_TIM15_TRGO (ADC_JSQR_JEXTSEL | ADC_INJ_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group injected conversion trigger from external IP: TIM15 TRG0. Trigger edge set to rising edge (default setting). */
  964. #if defined(STM32F303xE) || defined(STM32F398xx)
  965. #define LL_ADC_INJ_TRIG_EXT_TIM20_TRG_ADC34 (ADC_JSQR_JEXTSEL_2 | ADC_JSQR_JEXTSEL_0 | ADC_INJ_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group injected conversion trigger from external IP: TIM20 TRG0. Trigger edge set to rising edge (default setting). */
  966. #define LL_ADC_INJ_TRIG_EXT_TIM20_TRG2_ADC34 (LL_ADC_INJ_TRIG_EXT_TIM1_CH3_ADC34) /*!< ADC group injected conversion trigger from external IP: TIM20 TRG02. Trigger edge set to rising edge (default setting). */
  967. #define LL_ADC_INJ_TRIG_EXT_TIM20_CH2 (LL_ADC_INJ_TRIG_EXT_TIM15_TRGO) /*!< ADC group injected conversion trigger from external IP: TIM20 channel 2 event (capture compare: input capture or output capture). Trigger edge set to rising edge (default setting). */
  968. #endif /* STM32F303xE || STM32F398xx */
  969. #elif defined(STM32F303x8) || defined(STM32F328xx)
  970. #define LL_ADC_INJ_TRIG_EXT_TIM1_TRGO (ADC_INJ_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group injected conversion trigger from external IP: TIM1 TRG0. Trigger edge set to rising edge (default setting). */
  971. #define LL_ADC_INJ_TRIG_EXT_TIM1_CH4 (ADC_JSQR_JEXTSEL_0 | ADC_INJ_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group injected conversion trigger from external IP: TIM1 channel 4 event (capture compare: input capture or output capture). Trigger edge set to rising edge (default setting). */
  972. #define LL_ADC_INJ_TRIG_EXT_TIM2_TRGO (ADC_JSQR_JEXTSEL_1 | ADC_INJ_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group injected conversion trigger from external IP: TIM2 TRG0. Trigger edge set to rising edge (default setting). */
  973. #define LL_ADC_INJ_TRIG_EXT_TIM2_CH1 (ADC_JSQR_JEXTSEL_1 | ADC_JSQR_JEXTSEL_0 | ADC_INJ_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group injected conversion trigger from external IP: TIM2 channel 1 event (capture compare: input capture or output capture). Trigger edge set to rising edge (default setting). */
  974. #define LL_ADC_INJ_TRIG_EXT_TIM3_CH4 (ADC_JSQR_JEXTSEL_2 | ADC_INJ_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group injected conversion trigger from external IP: TIM3 channel 4 event (capture compare: input capture or output capture). Trigger edge set to rising edge (default setting). */
  975. #define LL_ADC_INJ_TRIG_EXT_TIM4_TRGO (ADC_JSQR_JEXTSEL_2 | ADC_JSQR_JEXTSEL_0 | ADC_INJ_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group injected conversion trigger from external IP: TIM4 TRG0. Trigger edge set to rising edge (default setting). */
  976. #define LL_ADC_INJ_TRIG_EXT_EXTI_LINE15 (ADC_JSQR_JEXTSEL_2 | ADC_JSQR_JEXTSEL_1 | ADC_INJ_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group injected conversion trigger from external IP: external interrupt line 15. Trigger edge set to rising edge (default setting). */
  977. #define LL_ADC_INJ_TRIG_EXT_TIM8_CH4 (ADC_JSQR_JEXTSEL_2 | ADC_JSQR_JEXTSEL_1 | ADC_JSQR_JEXTSEL_0 | ADC_INJ_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group injected conversion trigger from external IP: TIM8 channel 4 event (capture compare: input capture or output capture). Trigger edge set to rising edge (default setting). */
  978. #define LL_ADC_INJ_TRIG_EXT_TIM1_TRGO2 (ADC_JSQR_JEXTSEL_3 | ADC_INJ_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group injected conversion trigger from external IP: TIM1 TRG02. Trigger edge set to rising edge (default setting). */
  979. #define LL_ADC_INJ_TRIG_EXT_TIM8_TRGO (ADC_JSQR_JEXTSEL_3 | ADC_JSQR_JEXTSEL_0 | ADC_INJ_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group injected conversion trigger from external IP: TIM8 TRG0. Trigger edge set to rising edge (default setting). */
  980. #define LL_ADC_INJ_TRIG_EXT_TIM8_TRGO2 (ADC_JSQR_JEXTSEL_3 | ADC_JSQR_JEXTSEL_1 | ADC_INJ_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group injected conversion trigger from external IP: TIM8 TRG02. Trigger edge set to rising edge (default setting). */
  981. #define LL_ADC_INJ_TRIG_EXT_TIM3_CH3 (ADC_JSQR_JEXTSEL_3 | ADC_JSQR_JEXTSEL_1 | ADC_JSQR_JEXTSEL_0 | ADC_INJ_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group injected conversion trigger from external IP: TIM3 channel 3 event (capture compare: input capture or output capture). Trigger edge set to rising edge (default setting). */
  982. #define LL_ADC_INJ_TRIG_EXT_TIM3_TRGO (ADC_JSQR_JEXTSEL_3 | ADC_JSQR_JEXTSEL_2 | ADC_INJ_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group injected conversion trigger from external IP: TIM3 TRG0. Trigger edge set to rising edge (default setting). */
  983. #define LL_ADC_INJ_TRIG_EXT_TIM3_CH1 (ADC_JSQR_JEXTSEL_3 | ADC_JSQR_JEXTSEL_2 | ADC_JSQR_JEXTSEL_0 | ADC_INJ_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group injected conversion trigger from external IP: TIM3 channel 1 event (capture compare: input capture or output capture). Trigger edge set to rising edge (default setting). */
  984. #define LL_ADC_INJ_TRIG_EXT_TIM6_TRGO (ADC_JSQR_JEXTSEL_3 | ADC_JSQR_JEXTSEL_2 | ADC_JSQR_JEXTSEL_1 | ADC_INJ_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group injected conversion trigger from external IP: TIM6 TRG0. Trigger edge set to rising edge (default setting). */
  985. #define LL_ADC_INJ_TRIG_EXT_TIM15_TRGO (ADC_JSQR_JEXTSEL | ADC_INJ_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group injected conversion trigger from external IP: TIM15 TRG0. Trigger edge set to rising edge (default setting). */
  986. #elif defined(STM32F334x8)
  987. #define LL_ADC_INJ_TRIG_EXT_TIM1_TRGO (ADC_INJ_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group injected conversion trigger from external IP: TIM1 TRG0. Trigger edge set to rising edge (default setting). */
  988. #define LL_ADC_INJ_TRIG_EXT_TIM1_CH4 (ADC_JSQR_JEXTSEL_0 | ADC_INJ_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group injected conversion trigger from external IP: TIM1 channel 4 event (capture compare: input capture or output capture). Trigger edge set to rising edge (default setting). */
  989. #define LL_ADC_INJ_TRIG_EXT_TIM2_TRGO (ADC_JSQR_JEXTSEL_1 | ADC_INJ_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group injected conversion trigger from external IP: TIM2 TRG0. Trigger edge set to rising edge (default setting). */
  990. #define LL_ADC_INJ_TRIG_EXT_TIM2_CH1 (ADC_JSQR_JEXTSEL_1 | ADC_JSQR_JEXTSEL_0 | ADC_INJ_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group injected conversion trigger from external IP: TIM2 channel 1 event (capture compare: input capture or output capture). Trigger edge set to rising edge (default setting). */
  991. #define LL_ADC_INJ_TRIG_EXT_TIM3_CH4 (ADC_JSQR_JEXTSEL_2 | ADC_INJ_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group injected conversion trigger from external IP: TIM3 channel 4 event (capture compare: input capture or output capture). Trigger edge set to rising edge (default setting). */
  992. #define LL_ADC_INJ_TRIG_EXT_EXTI_LINE15 (ADC_JSQR_JEXTSEL_2 | ADC_JSQR_JEXTSEL_1 | ADC_INJ_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group injected conversion trigger from external IP: external interrupt line 15. Trigger edge set to rising edge (default setting). */
  993. #define LL_ADC_INJ_TRIG_EXT_TIM1_TRGO2 (ADC_JSQR_JEXTSEL_3 | ADC_INJ_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group injected conversion trigger from external IP: TIM1 TRG02. Trigger edge set to rising edge (default setting). */
  994. #define LL_ADC_INJ_TRIG_EXT_HRTIM_TRG2 (ADC_JSQR_JEXTSEL_3 | ADC_JSQR_JEXTSEL_0 | ADC_INJ_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group injected conversion trigger from external IP: HRTIM TRG2. Trigger edge set to rising edge (default setting). */
  995. #define LL_ADC_INJ_TRIG_EXT_HRTIM_TRG4 (ADC_JSQR_JEXTSEL_3 | ADC_JSQR_JEXTSEL_1 | ADC_INJ_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group injected conversion trigger from external IP: HRTIM TRG4. Trigger edge set to rising edge (default setting). */
  996. #define LL_ADC_INJ_TRIG_EXT_TIM3_CH3 (ADC_JSQR_JEXTSEL_3 | ADC_JSQR_JEXTSEL_1 | ADC_JSQR_JEXTSEL_0 | ADC_INJ_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group injected conversion trigger from external IP: TIM3 channel 3 event (capture compare: input capture or output capture). Trigger edge set to rising edge (default setting). */
  997. #define LL_ADC_INJ_TRIG_EXT_TIM3_TRGO (ADC_JSQR_JEXTSEL_3 | ADC_JSQR_JEXTSEL_2 | ADC_INJ_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group injected conversion trigger from external IP: TIM3 TRG0. Trigger edge set to rising edge (default setting). */
  998. #define LL_ADC_INJ_TRIG_EXT_TIM3_CH1 (ADC_JSQR_JEXTSEL_3 | ADC_JSQR_JEXTSEL_2 | ADC_JSQR_JEXTSEL_0 | ADC_INJ_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group injected conversion trigger from external IP: TIM3 channel 1 event (capture compare: input capture or output capture). Trigger edge set to rising edge (default setting). */
  999. #define LL_ADC_INJ_TRIG_EXT_TIM6_TRGO (ADC_JSQR_JEXTSEL_3 | ADC_JSQR_JEXTSEL_2 | ADC_JSQR_JEXTSEL_1 | ADC_INJ_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group injected conversion trigger from external IP: TIM6 TRG0. Trigger edge set to rising edge (default setting). */
  1000. #define LL_ADC_INJ_TRIG_EXT_TIM15_TRGO (ADC_JSQR_JEXTSEL | ADC_INJ_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group injected conversion trigger from external IP: TIM15 TRG0. Trigger edge set to rising edge (default setting). */
  1001. #elif defined(STM32F302xC) || defined(STM32F302xE)
  1002. #define LL_ADC_INJ_TRIG_EXT_TIM1_TRGO (ADC_INJ_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group injected conversion trigger from external IP: TIM1 TRG0. Trigger edge set to rising edge (default setting). */
  1003. #define LL_ADC_INJ_TRIG_EXT_TIM1_CH4 (ADC_JSQR_JEXTSEL_0 | ADC_INJ_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group injected conversion trigger from external IP: TIM1 channel 4 event (capture compare: input capture or output capture). Trigger edge set to rising edge (default setting). */
  1004. #define LL_ADC_INJ_TRIG_EXT_TIM2_TRGO (ADC_JSQR_JEXTSEL_1 | ADC_INJ_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group injected conversion trigger from external IP: TIM2 TRG0. Trigger edge set to rising edge (default setting). */
  1005. #define LL_ADC_INJ_TRIG_EXT_TIM2_CH1 (ADC_JSQR_JEXTSEL_1 | ADC_JSQR_JEXTSEL_0 | ADC_INJ_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group injected conversion trigger from external IP: TIM2 channel 1 event (capture compare: input capture or output capture). Trigger edge set to rising edge (default setting). */
  1006. #define LL_ADC_INJ_TRIG_EXT_TIM3_CH4 (ADC_JSQR_JEXTSEL_2 | ADC_INJ_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group injected conversion trigger from external IP: TIM3 channel 4 event (capture compare: input capture or output capture). Trigger edge set to rising edge (default setting). */
  1007. #define LL_ADC_INJ_TRIG_EXT_TIM4_TRGO (ADC_JSQR_JEXTSEL_2 | ADC_JSQR_JEXTSEL_0 | ADC_INJ_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group injected conversion trigger from external IP: TIM4 TRG0. Trigger edge set to rising edge (default setting). */
  1008. #define LL_ADC_INJ_TRIG_EXT_EXTI_LINE15 (ADC_JSQR_JEXTSEL_2 | ADC_JSQR_JEXTSEL_1 | ADC_INJ_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group injected conversion trigger from external IP: external interrupt line 15. Trigger edge set to rising edge (default setting). */
  1009. #define LL_ADC_INJ_TRIG_EXT_TIM1_TRGO2 (ADC_JSQR_JEXTSEL_3 | ADC_INJ_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group injected conversion trigger from external IP: TIM1 TRG02. Trigger edge set to rising edge (default setting). */
  1010. #define LL_ADC_INJ_TRIG_EXT_TIM3_CH3 (ADC_JSQR_JEXTSEL_3 | ADC_JSQR_JEXTSEL_1 | ADC_JSQR_JEXTSEL_0 | ADC_INJ_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group injected conversion trigger from external IP: TIM3 channel 3 event (capture compare: input capture or output capture). Trigger edge set to rising edge (default setting). */
  1011. #define LL_ADC_INJ_TRIG_EXT_TIM3_TRGO (ADC_JSQR_JEXTSEL_3 | ADC_JSQR_JEXTSEL_2 | ADC_INJ_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group injected conversion trigger from external IP: TIM3 TRG0. Trigger edge set to rising edge (default setting). */
  1012. #define LL_ADC_INJ_TRIG_EXT_TIM3_CH1 (ADC_JSQR_JEXTSEL_3 | ADC_JSQR_JEXTSEL_2 | ADC_JSQR_JEXTSEL_0 | ADC_INJ_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group injected conversion trigger from external IP: TIM3 channel 1 event (capture compare: input capture or output capture). Trigger edge set to rising edge (default setting). */
  1013. #define LL_ADC_INJ_TRIG_EXT_TIM6_TRGO (ADC_JSQR_JEXTSEL_3 | ADC_JSQR_JEXTSEL_2 | ADC_JSQR_JEXTSEL_1 | ADC_INJ_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group injected conversion trigger from external IP: TIM6 TRG0. Trigger edge set to rising edge (default setting). */
  1014. #define LL_ADC_INJ_TRIG_EXT_TIM15_TRGO (ADC_JSQR_JEXTSEL | ADC_INJ_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group injected conversion trigger from external IP: TIM15 TRG0. Trigger edge set to rising edge (default setting). */
  1015. #elif defined(STM32F301x8) || defined(STM32F302x8) || defined(STM32F318xx)
  1016. #define LL_ADC_INJ_TRIG_EXT_TIM1_TRGO (ADC_INJ_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group injected conversion trigger from external IP: TIM1 TRG0. Trigger edge set to rising edge (default setting). */
  1017. #define LL_ADC_INJ_TRIG_EXT_TIM1_CH4 (ADC_JSQR_JEXTSEL_0 | ADC_INJ_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group injected conversion trigger from external IP: TIM1 channel 4 event (capture compare: input capture or output capture). Trigger edge set to rising edge (default setting). */
  1018. #define LL_ADC_INJ_TRIG_EXT_EXTI_LINE15 (ADC_JSQR_JEXTSEL_2 | ADC_JSQR_JEXTSEL_1 | ADC_INJ_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group injected conversion trigger from external IP: external interrupt line 15. Trigger edge set to rising edge (default setting). */
  1019. #define LL_ADC_INJ_TRIG_EXT_TIM1_TRGO2 (ADC_JSQR_JEXTSEL_3 | ADC_INJ_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group injected conversion trigger from external IP: TIM1 TRG02. Trigger edge set to rising edge (default setting). */
  1020. #define LL_ADC_INJ_TRIG_EXT_TIM6_TRGO (ADC_JSQR_JEXTSEL_3 | ADC_JSQR_JEXTSEL_2 | ADC_JSQR_JEXTSEL_1 | ADC_INJ_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group injected conversion trigger from external IP: TIM6 TRG0. Trigger edge set to rising edge (default setting). */
  1021. #define LL_ADC_INJ_TRIG_EXT_TIM15_TRGO (ADC_JSQR_JEXTSEL | ADC_INJ_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group injected conversion trigger from external IP: TIM15 TRG0. Trigger edge set to rising edge (default setting). */
  1022. #endif
  1023. /**
  1024. * @}
  1025. */
  1026. /** @defgroup ADC_LL_EC_INJ_TRIGGER_EDGE ADC group injected - Trigger edge
  1027. * @{
  1028. */
  1029. #define LL_ADC_INJ_TRIG_EXT_RISING ( ADC_JSQR_JEXTEN_0) /*!< ADC group injected conversion trigger polarity set to rising edge */
  1030. #define LL_ADC_INJ_TRIG_EXT_FALLING (ADC_JSQR_JEXTEN_1 ) /*!< ADC group injected conversion trigger polarity set to falling edge */
  1031. #define LL_ADC_INJ_TRIG_EXT_RISINGFALLING (ADC_JSQR_JEXTEN_1 | ADC_JSQR_JEXTEN_0) /*!< ADC group injected conversion trigger polarity set to both rising and falling edges */
  1032. /**
  1033. * @}
  1034. */
  1035. /** @defgroup ADC_LL_EC_INJ_TRIG_AUTO ADC group injected - Automatic trigger mode
  1036. * @{
  1037. */
  1038. #define LL_ADC_INJ_TRIG_INDEPENDENT ((uint32_t)0x00000000U)/*!< ADC group injected conversion trigger independent. Setting mandatory if ADC group injected injected trigger source is set to an external trigger. */
  1039. #define LL_ADC_INJ_TRIG_FROM_GRP_REGULAR (ADC_CFGR_JAUTO) /*!< ADC group injected conversion trigger from ADC group regular. Setting compliant only with group injected trigger source set to SW start, without any further action on ADC group injected conversion start or stop: in this case, ADC group injected is controlled only from ADC group regular. */
  1040. /**
  1041. * @}
  1042. */
  1043. /** @defgroup ADC_LL_EC_INJ_CONTEXT_QUEUE ADC group injected - Context queue mode
  1044. * @{
  1045. */
  1046. #define LL_ADC_INJ_QUEUE_2CONTEXTS_LAST_ACTIVE ((uint32_t)0x00000000U)/* Group injected sequence context queue is enabled and can contain up to 2 contexts. When all contexts have been processed, the queue maintains the last context active perpetually. */
  1047. #define LL_ADC_INJ_QUEUE_2CONTEXTS_END_EMPTY (ADC_CFGR_JQM) /* Group injected sequence context queue is enabled and can contain up to 2 contexts. When all contexts have been processed, the queue is empty and injected group triggers are disabled. */
  1048. /**
  1049. * @}
  1050. */
  1051. /** @defgroup ADC_LL_EC_INJ_SEQ_SCAN_LENGTH ADC group injected - Sequencer scan length
  1052. * @{
  1053. */
  1054. #define LL_ADC_INJ_SEQ_SCAN_DISABLE ((uint32_t)0x00000000U) /*!< ADC group injected sequencer disable (equivalent to sequencer of 1 rank: ADC conversion on only 1 channel) */
  1055. #define LL_ADC_INJ_SEQ_SCAN_ENABLE_2RANKS ( ADC_JSQR_JL_0) /*!< ADC group injected sequencer enable with 2 ranks in the sequence */
  1056. #define LL_ADC_INJ_SEQ_SCAN_ENABLE_3RANKS (ADC_JSQR_JL_1 ) /*!< ADC group injected sequencer enable with 3 ranks in the sequence */
  1057. #define LL_ADC_INJ_SEQ_SCAN_ENABLE_4RANKS (ADC_JSQR_JL_1 | ADC_JSQR_JL_0) /*!< ADC group injected sequencer enable with 4 ranks in the sequence */
  1058. /**
  1059. * @}
  1060. */
  1061. /** @defgroup ADC_LL_EC_INJ_SEQ_DISCONT_MODE ADC group injected - Sequencer discontinuous mode
  1062. * @{
  1063. */
  1064. #define LL_ADC_INJ_SEQ_DISCONT_DISABLE ((uint32_t)0x00000000U)/*!< ADC group injected sequencer discontinuous mode disable */
  1065. #define LL_ADC_INJ_SEQ_DISCONT_1RANK (ADC_CFGR_JDISCEN) /*!< ADC group injected sequencer discontinuous mode enable with sequence interruption every rank */
  1066. /**
  1067. * @}
  1068. */
  1069. /** @defgroup ADC_LL_EC_INJ_SEQ_RANKS ADC group injected - Sequencer ranks
  1070. * @{
  1071. */
  1072. #define LL_ADC_INJ_RANK_1 (ADC_JDR1_REGOFFSET | ADC_INJ_RANK_1_JSQR_BITOFFSET_POS) /*!< ADC group injected sequencer rank 1 */
  1073. #define LL_ADC_INJ_RANK_2 (ADC_JDR2_REGOFFSET | ADC_INJ_RANK_2_JSQR_BITOFFSET_POS) /*!< ADC group injected sequencer rank 2 */
  1074. #define LL_ADC_INJ_RANK_3 (ADC_JDR3_REGOFFSET | ADC_INJ_RANK_3_JSQR_BITOFFSET_POS) /*!< ADC group injected sequencer rank 3 */
  1075. #define LL_ADC_INJ_RANK_4 (ADC_JDR4_REGOFFSET | ADC_INJ_RANK_4_JSQR_BITOFFSET_POS) /*!< ADC group injected sequencer rank 4 */
  1076. /**
  1077. * @}
  1078. */
  1079. /** @defgroup ADC_LL_EC_CHANNEL_SAMPLINGTIME Channel - Sampling time
  1080. * @{
  1081. */
  1082. #define LL_ADC_SAMPLINGTIME_1CYCLE_5 (0x00000000U) /*!< Sampling time 1.5 ADC clock cycle */
  1083. #define LL_ADC_SAMPLINGTIME_2CYCLES_5 ( ADC_SMPR2_SMP10_0) /*!< Sampling time 2.5 ADC clock cycles */
  1084. #define LL_ADC_SAMPLINGTIME_4CYCLES_5 ( ADC_SMPR2_SMP10_1 ) /*!< Sampling time 4.5 ADC clock cycles */
  1085. #define LL_ADC_SAMPLINGTIME_7CYCLES_5 ( ADC_SMPR2_SMP10_1 | ADC_SMPR2_SMP10_0) /*!< Sampling time 7.5 ADC clock cycles */
  1086. #define LL_ADC_SAMPLINGTIME_19CYCLES_5 (ADC_SMPR2_SMP10_2 ) /*!< Sampling time 19.5 ADC clock cycles */
  1087. #define LL_ADC_SAMPLINGTIME_61CYCLES_5 (ADC_SMPR2_SMP10_2 | ADC_SMPR2_SMP10_0) /*!< Sampling time 61.5 ADC clock cycles */
  1088. #define LL_ADC_SAMPLINGTIME_181CYCLES_5 (ADC_SMPR2_SMP10_2 | ADC_SMPR2_SMP10_1 ) /*!< Sampling time 181.5 ADC clock cycles */
  1089. #define LL_ADC_SAMPLINGTIME_601CYCLES_5 (ADC_SMPR2_SMP10_2 | ADC_SMPR2_SMP10_1 | ADC_SMPR2_SMP10_0) /*!< Sampling time 601.5 ADC clock cycles */
  1090. /**
  1091. * @}
  1092. */
  1093. /** @defgroup ADC_LL_EC_CHANNEL_SINGLE_DIFF_ENDING Channel - Single or differential ending
  1094. * @{
  1095. */
  1096. #define LL_ADC_SINGLE_ENDED ( ADC_CALFACT_CALFACT_S) /*!< ADC channel ending set to single ended (literal also used to set calibration mode) */
  1097. #define LL_ADC_DIFFERENTIAL_ENDED (ADC_CR_ADCALDIF | ADC_CALFACT_CALFACT_D) /*!< ADC channel ending set to differential (literal also used to set calibration mode) */
  1098. #define LL_ADC_BOTH_SINGLE_DIFF_ENDED (LL_ADC_SINGLE_ENDED | LL_ADC_DIFFERENTIAL_ENDED) /*!< ADC channel ending set to both single ended and differential (literal used only to set calibration factors) */
  1099. /**
  1100. * @}
  1101. */
  1102. /** @defgroup ADC_LL_EC_AWD_NUMBER Analog watchdog - Analog watchdog number
  1103. * @{
  1104. */
  1105. #define LL_ADC_AWD1 (ADC_AWD_CR1_CHANNEL_MASK | ADC_AWD_CR1_REGOFFSET) /*!< ADC analog watchdog number 1 */
  1106. #define LL_ADC_AWD2 (ADC_AWD_CR23_CHANNEL_MASK | ADC_AWD_CR2_REGOFFSET) /*!< ADC analog watchdog number 2 */
  1107. #define LL_ADC_AWD3 (ADC_AWD_CR23_CHANNEL_MASK | ADC_AWD_CR3_REGOFFSET) /*!< ADC analog watchdog number 3 */
  1108. /**
  1109. * @}
  1110. */
  1111. /** @defgroup ADC_LL_EC_AWD_CHANNELS Analog watchdog - Monitored channels
  1112. * @{
  1113. */
  1114. #define LL_ADC_AWD_DISABLE ((uint32_t)0x00000000U) /*!< ADC analog watchdog monitoring disabled */
  1115. #define LL_ADC_AWD_ALL_CHANNELS_REG (ADC_AWD_CR23_CHANNEL_MASK | ADC_CFGR_AWD1EN ) /*!< ADC analog watchdog monitoring of all channels, converted by group regular only */
  1116. #define LL_ADC_AWD_ALL_CHANNELS_INJ (ADC_AWD_CR23_CHANNEL_MASK | ADC_CFGR_JAWD1EN ) /*!< ADC analog watchdog monitoring of all channels, converted by group injected only */
  1117. #define LL_ADC_AWD_ALL_CHANNELS_REG_INJ (ADC_AWD_CR23_CHANNEL_MASK | ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1EN ) /*!< ADC analog watchdog monitoring of all channels, converted by either group regular or injected */
  1118. #define LL_ADC_AWD_CHANNEL_0_REG ((LL_ADC_CHANNEL_0 & ADC_CHANNEL_ID_MASK) | ADC_CFGR_AWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN0, converted by group regular only */
  1119. #define LL_ADC_AWD_CHANNEL_0_INJ ((LL_ADC_CHANNEL_0 & ADC_CHANNEL_ID_MASK) | ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN0, converted by group injected only */
  1120. #define LL_ADC_AWD_CHANNEL_0_REG_INJ ((LL_ADC_CHANNEL_0 & ADC_CHANNEL_ID_MASK) | ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN0, converted by either group regular or injected */
  1121. #define LL_ADC_AWD_CHANNEL_1_REG ((LL_ADC_CHANNEL_1 & ADC_CHANNEL_ID_MASK) | ADC_CFGR_AWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN1, converted by group regular only */
  1122. #define LL_ADC_AWD_CHANNEL_1_INJ ((LL_ADC_CHANNEL_1 & ADC_CHANNEL_ID_MASK) | ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN1, converted by group injected only */
  1123. #define LL_ADC_AWD_CHANNEL_1_REG_INJ ((LL_ADC_CHANNEL_1 & ADC_CHANNEL_ID_MASK) | ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN1, converted by either group regular or injected */
  1124. #define LL_ADC_AWD_CHANNEL_2_REG ((LL_ADC_CHANNEL_2 & ADC_CHANNEL_ID_MASK) | ADC_CFGR_AWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN2, converted by group regular only */
  1125. #define LL_ADC_AWD_CHANNEL_2_INJ ((LL_ADC_CHANNEL_2 & ADC_CHANNEL_ID_MASK) | ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN2, converted by group injected only */
  1126. #define LL_ADC_AWD_CHANNEL_2_REG_INJ ((LL_ADC_CHANNEL_2 & ADC_CHANNEL_ID_MASK) | ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN2, converted by either group regular or injected */
  1127. #define LL_ADC_AWD_CHANNEL_3_REG ((LL_ADC_CHANNEL_3 & ADC_CHANNEL_ID_MASK) | ADC_CFGR_AWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN3, converted by group regular only */
  1128. #define LL_ADC_AWD_CHANNEL_3_INJ ((LL_ADC_CHANNEL_3 & ADC_CHANNEL_ID_MASK) | ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN3, converted by group injected only */
  1129. #define LL_ADC_AWD_CHANNEL_3_REG_INJ ((LL_ADC_CHANNEL_3 & ADC_CHANNEL_ID_MASK) | ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN3, converted by either group regular or injected */
  1130. #define LL_ADC_AWD_CHANNEL_4_REG ((LL_ADC_CHANNEL_4 & ADC_CHANNEL_ID_MASK) | ADC_CFGR_AWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN4, converted by group regular only */
  1131. #define LL_ADC_AWD_CHANNEL_4_INJ ((LL_ADC_CHANNEL_4 & ADC_CHANNEL_ID_MASK) | ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN4, converted by group injected only */
  1132. #define LL_ADC_AWD_CHANNEL_4_REG_INJ ((LL_ADC_CHANNEL_4 & ADC_CHANNEL_ID_MASK) | ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN4, converted by either group regular or injected */
  1133. #define LL_ADC_AWD_CHANNEL_5_REG ((LL_ADC_CHANNEL_5 & ADC_CHANNEL_ID_MASK) | ADC_CFGR_AWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN5, converted by group regular only */
  1134. #define LL_ADC_AWD_CHANNEL_5_INJ ((LL_ADC_CHANNEL_5 & ADC_CHANNEL_ID_MASK) | ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN5, converted by group injected only */
  1135. #define LL_ADC_AWD_CHANNEL_5_REG_INJ ((LL_ADC_CHANNEL_5 & ADC_CHANNEL_ID_MASK) | ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN5, converted by either group regular or injected */
  1136. #define LL_ADC_AWD_CHANNEL_6_REG ((LL_ADC_CHANNEL_6 & ADC_CHANNEL_ID_MASK) | ADC_CFGR_AWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN6, converted by group regular only */
  1137. #define LL_ADC_AWD_CHANNEL_6_INJ ((LL_ADC_CHANNEL_6 & ADC_CHANNEL_ID_MASK) | ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN6, converted by group injected only */
  1138. #define LL_ADC_AWD_CHANNEL_6_REG_INJ ((LL_ADC_CHANNEL_6 & ADC_CHANNEL_ID_MASK) | ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN6, converted by either group regular or injected */
  1139. #define LL_ADC_AWD_CHANNEL_7_REG ((LL_ADC_CHANNEL_7 & ADC_CHANNEL_ID_MASK) | ADC_CFGR_AWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN7, converted by group regular only */
  1140. #define LL_ADC_AWD_CHANNEL_7_INJ ((LL_ADC_CHANNEL_7 & ADC_CHANNEL_ID_MASK) | ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN7, converted by group injected only */
  1141. #define LL_ADC_AWD_CHANNEL_7_REG_INJ ((LL_ADC_CHANNEL_7 & ADC_CHANNEL_ID_MASK) | ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN7, converted by either group regular or injected */
  1142. #define LL_ADC_AWD_CHANNEL_8_REG ((LL_ADC_CHANNEL_8 & ADC_CHANNEL_ID_MASK) | ADC_CFGR_AWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN8, converted by group regular only */
  1143. #define LL_ADC_AWD_CHANNEL_8_INJ ((LL_ADC_CHANNEL_8 & ADC_CHANNEL_ID_MASK) | ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN8, converted by group injected only */
  1144. #define LL_ADC_AWD_CHANNEL_8_REG_INJ ((LL_ADC_CHANNEL_8 & ADC_CHANNEL_ID_MASK) | ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN8, converted by either group regular or injected */
  1145. #define LL_ADC_AWD_CHANNEL_9_REG ((LL_ADC_CHANNEL_9 & ADC_CHANNEL_ID_MASK) | ADC_CFGR_AWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN9, converted by group regular only */
  1146. #define LL_ADC_AWD_CHANNEL_9_INJ ((LL_ADC_CHANNEL_9 & ADC_CHANNEL_ID_MASK) | ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN9, converted by group injected only */
  1147. #define LL_ADC_AWD_CHANNEL_9_REG_INJ ((LL_ADC_CHANNEL_9 & ADC_CHANNEL_ID_MASK) | ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN9, converted by either group regular or injected */
  1148. #define LL_ADC_AWD_CHANNEL_10_REG ((LL_ADC_CHANNEL_10 & ADC_CHANNEL_ID_MASK) | ADC_CFGR_AWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN10, converted by group regular only */
  1149. #define LL_ADC_AWD_CHANNEL_10_INJ ((LL_ADC_CHANNEL_10 & ADC_CHANNEL_ID_MASK) | ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN10, converted by group injected only */
  1150. #define LL_ADC_AWD_CHANNEL_10_REG_INJ ((LL_ADC_CHANNEL_10 & ADC_CHANNEL_ID_MASK) | ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN10, converted by either group regular or injected */
  1151. #define LL_ADC_AWD_CHANNEL_11_REG ((LL_ADC_CHANNEL_11 & ADC_CHANNEL_ID_MASK) | ADC_CFGR_AWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN11, converted by group regular only */
  1152. #define LL_ADC_AWD_CHANNEL_11_INJ ((LL_ADC_CHANNEL_11 & ADC_CHANNEL_ID_MASK) | ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN11, converted by group injected only */
  1153. #define LL_ADC_AWD_CHANNEL_11_REG_INJ ((LL_ADC_CHANNEL_11 & ADC_CHANNEL_ID_MASK) | ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN11, converted by either group regular or injected */
  1154. #define LL_ADC_AWD_CHANNEL_12_REG ((LL_ADC_CHANNEL_12 & ADC_CHANNEL_ID_MASK) | ADC_CFGR_AWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN12, converted by group regular only */
  1155. #define LL_ADC_AWD_CHANNEL_12_INJ ((LL_ADC_CHANNEL_12 & ADC_CHANNEL_ID_MASK) | ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN12, converted by group injected only */
  1156. #define LL_ADC_AWD_CHANNEL_12_REG_INJ ((LL_ADC_CHANNEL_12 & ADC_CHANNEL_ID_MASK) | ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN12, converted by either group regular or injected */
  1157. #define LL_ADC_AWD_CHANNEL_13_REG ((LL_ADC_CHANNEL_13 & ADC_CHANNEL_ID_MASK) | ADC_CFGR_AWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN13, converted by group regular only */
  1158. #define LL_ADC_AWD_CHANNEL_13_INJ ((LL_ADC_CHANNEL_13 & ADC_CHANNEL_ID_MASK) | ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN13, converted by group injected only */
  1159. #define LL_ADC_AWD_CHANNEL_13_REG_INJ ((LL_ADC_CHANNEL_13 & ADC_CHANNEL_ID_MASK) | ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN13, converted by either group regular or injected */
  1160. #define LL_ADC_AWD_CHANNEL_14_REG ((LL_ADC_CHANNEL_14 & ADC_CHANNEL_ID_MASK) | ADC_CFGR_AWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN14, converted by group regular only */
  1161. #define LL_ADC_AWD_CHANNEL_14_INJ ((LL_ADC_CHANNEL_14 & ADC_CHANNEL_ID_MASK) | ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN14, converted by group injected only */
  1162. #define LL_ADC_AWD_CHANNEL_14_REG_INJ ((LL_ADC_CHANNEL_14 & ADC_CHANNEL_ID_MASK) | ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN14, converted by either group regular or injected */
  1163. #define LL_ADC_AWD_CHANNEL_15_REG ((LL_ADC_CHANNEL_15 & ADC_CHANNEL_ID_MASK) | ADC_CFGR_AWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN15, converted by group regular only */
  1164. #define LL_ADC_AWD_CHANNEL_15_INJ ((LL_ADC_CHANNEL_15 & ADC_CHANNEL_ID_MASK) | ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN15, converted by group injected only */
  1165. #define LL_ADC_AWD_CHANNEL_15_REG_INJ ((LL_ADC_CHANNEL_15 & ADC_CHANNEL_ID_MASK) | ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN15, converted by either group regular or injected */
  1166. #define LL_ADC_AWD_CHANNEL_16_REG ((LL_ADC_CHANNEL_16 & ADC_CHANNEL_ID_MASK) | ADC_CFGR_AWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN16, converted by group regular only */
  1167. #define LL_ADC_AWD_CHANNEL_16_INJ ((LL_ADC_CHANNEL_16 & ADC_CHANNEL_ID_MASK) | ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN16, converted by group injected only */
  1168. #define LL_ADC_AWD_CHANNEL_16_REG_INJ ((LL_ADC_CHANNEL_16 & ADC_CHANNEL_ID_MASK) | ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN16, converted by either group regular or injected */
  1169. #define LL_ADC_AWD_CHANNEL_17_REG ((LL_ADC_CHANNEL_17 & ADC_CHANNEL_ID_MASK) | ADC_CFGR_AWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN17, converted by group regular only */
  1170. #define LL_ADC_AWD_CHANNEL_17_INJ ((LL_ADC_CHANNEL_17 & ADC_CHANNEL_ID_MASK) | ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN17, converted by group injected only */
  1171. #define LL_ADC_AWD_CHANNEL_17_REG_INJ ((LL_ADC_CHANNEL_17 & ADC_CHANNEL_ID_MASK) | ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN17, converted by either group regular or injected */
  1172. #define LL_ADC_AWD_CHANNEL_18_REG ((LL_ADC_CHANNEL_18 & ADC_CHANNEL_ID_MASK) | ADC_CFGR_AWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN18, converted by group regular only */
  1173. #define LL_ADC_AWD_CHANNEL_18_INJ ((LL_ADC_CHANNEL_18 & ADC_CHANNEL_ID_MASK) | ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN18, converted by group injected only */
  1174. #define LL_ADC_AWD_CHANNEL_18_REG_INJ ((LL_ADC_CHANNEL_18 & ADC_CHANNEL_ID_MASK) | ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN18, converted by either group regular or injected */
  1175. #define LL_ADC_AWD_CH_VREFINT_REG ((LL_ADC_CHANNEL_VREFINT & ADC_CHANNEL_ID_MASK) | ADC_CFGR_AWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC internal channel connected to VrefInt: Internal voltage reference, converted by group regular only */
  1176. #define LL_ADC_AWD_CH_VREFINT_INJ ((LL_ADC_CHANNEL_VREFINT & ADC_CHANNEL_ID_MASK) | ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC internal channel connected to VrefInt: Internal voltage reference, converted by group injected only */
  1177. #define LL_ADC_AWD_CH_VREFINT_REG_INJ ((LL_ADC_CHANNEL_VREFINT & ADC_CHANNEL_ID_MASK) | ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC internal channel connected to VrefInt: Internal voltage reference, converted by either group regular or injected */
  1178. #define LL_ADC_AWD_CH_TEMPSENSOR_REG ((LL_ADC_CHANNEL_TEMPSENSOR & ADC_CHANNEL_ID_MASK) | ADC_CFGR_AWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC internal channel connected to Temperature sensor, converted by group regular only */
  1179. #define LL_ADC_AWD_CH_TEMPSENSOR_INJ ((LL_ADC_CHANNEL_TEMPSENSOR & ADC_CHANNEL_ID_MASK) | ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC internal channel connected to Temperature sensor, converted by group injected only */
  1180. #define LL_ADC_AWD_CH_TEMPSENSOR_REG_INJ ((LL_ADC_CHANNEL_TEMPSENSOR & ADC_CHANNEL_ID_MASK) | ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC internal channel connected to Temperature sensor, converted by either group regular or injected */
  1181. #define LL_ADC_AWD_CH_VBAT_REG ((LL_ADC_CHANNEL_VBAT & ADC_CHANNEL_ID_MASK) | ADC_CFGR_AWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC internal channel connected to Vbat/3: Vbat voltage through a divider ladder of factor 1/3 to have Vbat always below Vdda, converted by group regular only */
  1182. #define LL_ADC_AWD_CH_VBAT_INJ ((LL_ADC_CHANNEL_VBAT & ADC_CHANNEL_ID_MASK) | ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC internal channel connected to Vbat/3: Vbat voltage through a divider ladder of factor 1/3 to have Vbat always below Vdda, converted by group injected only */
  1183. #define LL_ADC_AWD_CH_VBAT_REG_INJ ((LL_ADC_CHANNEL_VBAT & ADC_CHANNEL_ID_MASK) | ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC internal channel connected to Vbat/3: Vbat voltage through a divider ladder of factor 1/3 to have Vbat always below Vdda */
  1184. #if defined(OPAMP1_CSR_OPAMP1EN)
  1185. #define LL_ADC_AWD_CH_VOPAMP1_REG ((LL_ADC_CHANNEL_VOPAMP1 & ADC_CHANNEL_ID_MASK) | ADC_CFGR_AWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC internal channel connected to DAC1 channel 1, channel specific to ADC2, converted by group regular only */
  1186. #define LL_ADC_AWD_CH_VOPAMP1_INJ ((LL_ADC_CHANNEL_VOPAMP1 & ADC_CHANNEL_ID_MASK) | ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC internal channel connected to DAC1 channel 1, channel specific to ADC2, converted by group injected only */
  1187. #define LL_ADC_AWD_CH_VOPAMP1_REG_INJ ((LL_ADC_CHANNEL_VOPAMP1 & ADC_CHANNEL_ID_MASK) | ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC internal channel connected to DAC1 channel 1, channel specific to ADC2, converted by either group regular or injected */
  1188. #endif
  1189. #if defined(OPAMP2_CSR_OPAMP2EN)
  1190. #define LL_ADC_AWD_CH_VOPAMP2_REG ((LL_ADC_CHANNEL_VOPAMP2 & ADC_CHANNEL_ID_MASK) | ADC_CFGR_AWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC internal channel connected to DAC1 channel 1, channel specific to ADC2, converted by group regular only */
  1191. #define LL_ADC_AWD_CH_VOPAMP2_INJ ((LL_ADC_CHANNEL_VOPAMP2 & ADC_CHANNEL_ID_MASK) | ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC internal channel connected to DAC1 channel 1, channel specific to ADC2, converted by group injected only */
  1192. #define LL_ADC_AWD_CH_VOPAMP2_REG_INJ ((LL_ADC_CHANNEL_VOPAMP2 & ADC_CHANNEL_ID_MASK) | ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC internal channel connected to DAC1 channel 1, channel specific to ADC2, converted by either group regular or injected */
  1193. #endif
  1194. #if defined(OPAMP3_CSR_OPAMP3EN)
  1195. #define LL_ADC_AWD_CH_VOPAMP3_REG ((LL_ADC_CHANNEL_VOPAMP3 & ADC_CHANNEL_ID_MASK) | ADC_CFGR_AWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC internal channel connected to DAC1 channel 1, channel specific to ADC3, converted by group regular only */
  1196. #define LL_ADC_AWD_CH_VOPAMP3_INJ ((LL_ADC_CHANNEL_VOPAMP3 & ADC_CHANNEL_ID_MASK) | ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC internal channel connected to DAC1 channel 1, channel specific to ADC3, converted by group injected only */
  1197. #define LL_ADC_AWD_CH_VOPAMP3_REG_INJ ((LL_ADC_CHANNEL_VOPAMP3 & ADC_CHANNEL_ID_MASK) | ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC internal channel connected to DAC1 channel 1, channel specific to ADC3, converted by either group regular or injected */
  1198. #endif
  1199. #if defined(OPAMP4_CSR_OPAMP4EN)
  1200. #define LL_ADC_AWD_CH_VOPAMP4_REG ((LL_ADC_CHANNEL_VOPAMP4 & ADC_CHANNEL_ID_MASK) | ADC_CFGR_AWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC internal channel connected to DAC1 channel 1, channel specific to ADC3, converted by group regular only */
  1201. #define LL_ADC_AWD_CH_VOPAMP4_INJ ((LL_ADC_CHANNEL_VOPAMP4 & ADC_CHANNEL_ID_MASK) | ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC internal channel connected to DAC1 channel 1, channel specific to ADC3, converted by group injected only */
  1202. #define LL_ADC_AWD_CH_VOPAMP4_REG_INJ ((LL_ADC_CHANNEL_VOPAMP4 & ADC_CHANNEL_ID_MASK) | ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC internal channel connected to DAC1 channel 1, channel specific to ADC3, converted by either group regular or injected */
  1203. #endif
  1204. /**
  1205. * @}
  1206. */
  1207. /** @defgroup ADC_LL_EC_AWD_THRESHOLDS Analog watchdog - Thresholds
  1208. * @{
  1209. */
  1210. #define LL_ADC_AWD_THRESHOLD_HIGH (ADC_TR1_HT1 ) /*!< ADC analog watchdog threshold high */
  1211. #define LL_ADC_AWD_THRESHOLD_LOW ( ADC_TR1_LT1) /*!< ADC analog watchdog threshold low */
  1212. #define LL_ADC_AWD_THRESHOLDS_HIGH_LOW (ADC_TR1_HT1 | ADC_TR1_LT1) /*!< ADC analog watchdog both thresholds high and low concatenated into the same data */
  1213. /**
  1214. * @}
  1215. */
  1216. #if defined(ADC_MULTIMODE_SUPPORT)
  1217. /** @defgroup ADC_LL_EC_MULTI_MODE Multimode - Mode
  1218. * @{
  1219. */
  1220. #define LL_ADC_MULTI_INDEPENDENT ((uint32_t)0x00000000U) /*!< ADC dual mode disabled (ADC independent mode) */
  1221. #define LL_ADC_MULTI_DUAL_REG_SIMULT ( ADC_CCR_DUAL_2 | ADC_CCR_DUAL_1 ) /*!< ADC dual mode enabled: group regular simultaneous */
  1222. #define LL_ADC_MULTI_DUAL_REG_INTERL ( ADC_CCR_DUAL_2 | ADC_CCR_DUAL_1 | ADC_CCR_DUAL_0) /*!< ADC dual mode enabled: Combined group regular interleaved */
  1223. #define LL_ADC_MULTI_DUAL_INJ_SIMULT ( ADC_CCR_DUAL_2 | ADC_CCR_DUAL_0) /*!< ADC dual mode enabled: group injected simultaneous */
  1224. #define LL_ADC_MULTI_DUAL_INJ_ALTERN (ADC_CCR_DUAL_3 | ADC_CCR_DUAL_0) /*!< ADC dual mode enabled: group injected alternate trigger. Works only with external triggers (not internal SW start) */
  1225. #define LL_ADC_MULTI_DUAL_REG_SIM_INJ_SIM ( ADC_CCR_DUAL_0) /*!< ADC dual mode enabled: Combined group regular simultaneous + group injected simultaneous */
  1226. #define LL_ADC_MULTI_DUAL_REG_SIM_INJ_ALT ( ADC_CCR_DUAL_1 ) /*!< ADC dual mode enabled: Combined group regular simultaneous + group injected alternate trigger */
  1227. #define LL_ADC_MULTI_DUAL_REG_INT_INJ_SIM ( ADC_CCR_DUAL_1 | ADC_CCR_DUAL_0) /*!< ADC dual mode enabled: Combined group regular interleaved + group injected simultaneous */
  1228. /**
  1229. * @}
  1230. */
  1231. /** @defgroup ADC_LL_EC_MULTI_DMA_TRANSFER Multimode - DMA transfer
  1232. * @{
  1233. */
  1234. #define LL_ADC_MULTI_REG_DMA_EACH_ADC ((uint32_t)0x00000000U) /*!< ADC multimode group regular conversions are transferred by DMA: each ADC uses its own DMA channel, with its individual DMA transfer settings */
  1235. #define LL_ADC_MULTI_REG_DMA_LIMIT_RES12_10B ( ADC_CCR_MDMA_1 ) /*!< ADC multimode group regular conversions are transferred by DMA, one DMA channel for both ADC (DMA of ADC master), in limited mode (one shot mode): DMA transfer requests are stopped when number of DMA data transfers (number of ADC conversions) is reached. This ADC mode is intended to be used with DMA mode non-circular. Setting for ADC resolution of 12 and 10 bits */
  1236. #define LL_ADC_MULTI_REG_DMA_LIMIT_RES8_6B ( ADC_CCR_MDMA_1 | ADC_CCR_MDMA_0) /*!< ADC multimode group regular conversions are transferred by DMA, one DMA channel for both ADC (DMA of ADC master), in limited mode (one shot mode): DMA transfer requests are stopped when number of DMA data transfers (number of ADC conversions) is reached. This ADC mode is intended to be used with DMA mode non-circular. Setting for ADC resolution of 8 and 6 bits */
  1237. #define LL_ADC_MULTI_REG_DMA_UNLMT_RES12_10B (ADC_CCR_DMACFG | ADC_CCR_MDMA_1 ) /*!< ADC multimode group regular conversions are transferred by DMA, one DMA channel for both ADC (DMA of ADC master), in unlimited mode: DMA transfer requests are unlimited, whatever number of DMA data transferred (number of ADC conversions). This ADC mode is intended to be used with DMA mode circular. Setting for ADC resolution of 12 and 10 bits */
  1238. #define LL_ADC_MULTI_REG_DMA_UNLMT_RES8_6B (ADC_CCR_DMACFG | ADC_CCR_MDMA_1 | ADC_CCR_MDMA_0) /*!< ADC multimode group regular conversions are transferred by DMA, one DMA channel for both ADC (DMA of ADC master), in unlimited mode: DMA transfer requests are unlimited, whatever number of DMA data transferred (number of ADC conversions). This ADC mode is intended to be used with DMA mode circular. Setting for ADC resolution of 8 and 6 bits */
  1239. /**
  1240. * @}
  1241. */
  1242. /** @defgroup ADC_LL_EC_MULTI_TWOSMP_DELAY Multimode - Delay between two sampling phases
  1243. * @{
  1244. */
  1245. #define LL_ADC_MULTI_TWOSMP_DELAY_1CYCLE ((uint32_t)0x00000000U) /*!< ADC multimode delay between two sampling phases: 1 ADC clock cycle */
  1246. #define LL_ADC_MULTI_TWOSMP_DELAY_2CYCLES ( ADC_CCR_DELAY_0) /*!< ADC multimode delay between two sampling phases: 2 ADC clock cycles */
  1247. #define LL_ADC_MULTI_TWOSMP_DELAY_3CYCLES ( ADC_CCR_DELAY_1 ) /*!< ADC multimode delay between two sampling phases: 3 ADC clock cycles */
  1248. #define LL_ADC_MULTI_TWOSMP_DELAY_4CYCLES ( ADC_CCR_DELAY_1 | ADC_CCR_DELAY_0) /*!< ADC multimode delay between two sampling phases: 4 ADC clock cycles */
  1249. #define LL_ADC_MULTI_TWOSMP_DELAY_5CYCLES ( ADC_CCR_DELAY_2 ) /*!< ADC multimode delay between two sampling phases: 5 ADC clock cycles */
  1250. #define LL_ADC_MULTI_TWOSMP_DELAY_6CYCLES ( ADC_CCR_DELAY_2 | ADC_CCR_DELAY_0) /*!< ADC multimode delay between two sampling phases: 6 ADC clock cycles */
  1251. #define LL_ADC_MULTI_TWOSMP_DELAY_7CYCLES ( ADC_CCR_DELAY_2 | ADC_CCR_DELAY_1 ) /*!< ADC multimode delay between two sampling phases: 7 ADC clock cycles */
  1252. #define LL_ADC_MULTI_TWOSMP_DELAY_8CYCLES ( ADC_CCR_DELAY_2 | ADC_CCR_DELAY_1 | ADC_CCR_DELAY_0) /*!< ADC multimode delay between two sampling phases: 8 ADC clock cycles */
  1253. #define LL_ADC_MULTI_TWOSMP_DELAY_9CYCLES (ADC_CCR_DELAY_3 ) /*!< ADC multimode delay between two sampling phases: 9 ADC clock cycles */
  1254. #define LL_ADC_MULTI_TWOSMP_DELAY_10CYCLES (ADC_CCR_DELAY_3 | ADC_CCR_DELAY_0) /*!< ADC multimode delay between two sampling phases: 10 ADC clock cycles */
  1255. #define LL_ADC_MULTI_TWOSMP_DELAY_11CYCLES (ADC_CCR_DELAY_3 | ADC_CCR_DELAY_1 ) /*!< ADC multimode delay between two sampling phases: 11 ADC clock cycles */
  1256. #define LL_ADC_MULTI_TWOSMP_DELAY_12CYCLES (ADC_CCR_DELAY_3 | ADC_CCR_DELAY_1 | ADC_CCR_DELAY_0) /*!< ADC multimode delay between two sampling phases: 12 ADC clock cycles */
  1257. /**
  1258. * @}
  1259. */
  1260. /** @defgroup ADC_LL_EC_MULTI_MASTER_SLAVE Multimode - ADC master or slave
  1261. * @{
  1262. */
  1263. #define LL_ADC_MULTI_MASTER ( ADC_CDR_RDATA_MST) /*!< In multimode, selection among several ADC instances: ADC master */
  1264. #define LL_ADC_MULTI_SLAVE (ADC_CDR_RDATA_SLV ) /*!< In multimode, selection among several ADC instances: ADC slave */
  1265. #define LL_ADC_MULTI_MASTER_SLAVE (ADC_CDR_RDATA_SLV | ADC_CDR_RDATA_MST) /*!< In multimode, selection among several ADC instances: both ADC master and ADC slave */
  1266. /**
  1267. * @}
  1268. */
  1269. #endif /* ADC_MULTIMODE_SUPPORT */
  1270. /** @defgroup ADC_LL_EC_HW_DELAYS Definitions of ADC hardware constraints delays
  1271. * @note Only ADC IP HW delays are defined in ADC LL driver driver,
  1272. * not timeout values.
  1273. * For details on delays values, refer to descriptions in source code
  1274. * above each literal definition.
  1275. * @{
  1276. */
  1277. /* Note: Only ADC IP HW delays are defined in ADC LL driver driver, */
  1278. /* not timeout values. */
  1279. /* Timeout values for ADC operations are dependent to device clock */
  1280. /* configuration (system clock versus ADC clock), */
  1281. /* and therefore must be defined in user application. */
  1282. /* Indications for estimation of ADC timeout delays, for this */
  1283. /* STM32 series: */
  1284. /* - ADC calibration time: maximum delay is 112/fADC. */
  1285. /* (refer to device datasheet, parameter "tCAL") */
  1286. /* - ADC enable time: maximum delay is 1 conversion cycle. */
  1287. /* (refer to device datasheet, parameter "tSTAB") */
  1288. /* - ADC disable time: maximum delay should be a few ADC clock cycles */
  1289. /* - ADC stop conversion time: maximum delay should be a few ADC clock */
  1290. /* cycles */
  1291. /* - ADC conversion time: duration depending on ADC clock and ADC */
  1292. /* configuration. */
  1293. /* (refer to device reference manual, section "Timing") */
  1294. /* Delay for ADC stabilization time (ADC voltage regulator start-up time) */
  1295. /* Delay set to maximum value (refer to device datasheet, */
  1296. /* parameter "tADCVREG_STUP"). */
  1297. /* Unit: us */
  1298. #define LL_ADC_DELAY_INTERNAL_REGUL_STAB_US ((uint32_t) 10U) /*!< Delay for ADC stabilization time (ADC voltage regulator start-up time) */
  1299. /* Delay for internal voltage reference stabilization time. */
  1300. /* Delay set to maximum value (refer to device datasheet, */
  1301. /* parameter "tstart_vrefint"). */
  1302. /* Unit: us */
  1303. #define LL_ADC_DELAY_VREFINT_STAB_US ((uint32_t) 12U) /*!< Delay for internal voltage reference stabilization time */
  1304. /* Delay for temperature sensor stabilization time. */
  1305. /* Literal set to maximum value (refer to device datasheet, */
  1306. /* parameter "tSTART"). */
  1307. /* Unit: us */
  1308. #define LL_ADC_DELAY_TEMPSENSOR_STAB_US ((uint32_t) 120U) /*!< Delay for temperature sensor stabilization time */
  1309. /* Delay required between ADC end of calibration and ADC enable. */
  1310. /* Note: On this STM32 series, a minimum number of ADC clock cycles */
  1311. /* are required between ADC end of calibration and ADC enable. */
  1312. /* Wait time can be computed in user application by waiting for the */
  1313. /* equivalent number of CPU cycles, by taking into account */
  1314. /* ratio of CPU clock versus ADC clock prescalers. */
  1315. /* Unit: ADC clock cycles. */
  1316. #define LL_ADC_DELAY_CALIB_ENABLE_ADC_CYCLES ((uint32_t) 4U) /*!< Delay required between ADC end of calibration and ADC enable */
  1317. /**
  1318. * @}
  1319. */
  1320. /**
  1321. * @}
  1322. */
  1323. /* Exported macro ------------------------------------------------------------*/
  1324. /** @defgroup ADC_LL_Exported_Macros ADC Exported Macros
  1325. * @{
  1326. */
  1327. /** @defgroup ADC_LL_EM_WRITE_READ Common write and read registers Macros
  1328. * @{
  1329. */
  1330. /**
  1331. * @brief Write a value in ADC register
  1332. * @param __INSTANCE__ ADC Instance
  1333. * @param __REG__ Register to be written
  1334. * @param __VALUE__ Value to be written in the register
  1335. * @retval None
  1336. */
  1337. #define LL_ADC_WriteReg(__INSTANCE__, __REG__, __VALUE__) WRITE_REG(__INSTANCE__->__REG__, (__VALUE__))
  1338. /**
  1339. * @brief Read a value in ADC register
  1340. * @param __INSTANCE__ ADC Instance
  1341. * @param __REG__ Register to be read
  1342. * @retval Register value
  1343. */
  1344. #define LL_ADC_ReadReg(__INSTANCE__, __REG__) READ_REG(__INSTANCE__->__REG__)
  1345. /**
  1346. * @}
  1347. */
  1348. /** @defgroup ADC_LL_EM_HELPER_MACRO ADC helper macro
  1349. * @{
  1350. */
  1351. /**
  1352. * @brief Helper macro to get ADC channel number in decimal format
  1353. * from literals LL_ADC_CHANNEL_x.
  1354. * @note Example:
  1355. * __LL_ADC_CHANNEL_TO_DECIMAL_NB(LL_ADC_CHANNEL_4)
  1356. * will return decimal number "4".
  1357. * @note The input can be a value from functions where a channel
  1358. * number is returned, either defined with number
  1359. * or with bitfield (only one bit must be set).
  1360. * @param __CHANNEL__ This parameter can be one of the following values:
  1361. * @arg @ref LL_ADC_CHANNEL_0
  1362. * @arg @ref LL_ADC_CHANNEL_1
  1363. * @arg @ref LL_ADC_CHANNEL_2
  1364. * @arg @ref LL_ADC_CHANNEL_3
  1365. * @arg @ref LL_ADC_CHANNEL_4
  1366. * @arg @ref LL_ADC_CHANNEL_5
  1367. * @arg @ref LL_ADC_CHANNEL_6
  1368. * @arg @ref LL_ADC_CHANNEL_7
  1369. * @arg @ref LL_ADC_CHANNEL_8
  1370. * @arg @ref LL_ADC_CHANNEL_9
  1371. * @arg @ref LL_ADC_CHANNEL_10
  1372. * @arg @ref LL_ADC_CHANNEL_11
  1373. * @arg @ref LL_ADC_CHANNEL_12
  1374. * @arg @ref LL_ADC_CHANNEL_13
  1375. * @arg @ref LL_ADC_CHANNEL_14
  1376. * @arg @ref LL_ADC_CHANNEL_15
  1377. * @arg @ref LL_ADC_CHANNEL_16
  1378. * @arg @ref LL_ADC_CHANNEL_17
  1379. * @arg @ref LL_ADC_CHANNEL_18
  1380. * @arg @ref LL_ADC_CHANNEL_VREFINT (5)
  1381. * @arg @ref LL_ADC_CHANNEL_TEMPSENSOR (1)
  1382. * @arg @ref LL_ADC_CHANNEL_VBAT (1)
  1383. * @arg @ref LL_ADC_CHANNEL_VOPAMP1 (1)
  1384. * @arg @ref LL_ADC_CHANNEL_VOPAMP2 (2)
  1385. * @arg @ref LL_ADC_CHANNEL_VOPAMP3 (3)
  1386. * @arg @ref LL_ADC_CHANNEL_VOPAMP4 (4)
  1387. *
  1388. * (1) On STM32F3, parameter available only on ADC instance: ADC1.\n
  1389. * (2) On STM32F3, parameter available only on ADC instance: ADC2.\n
  1390. * (3) On STM32F3, parameter available only on ADC instance: ADC3.\n
  1391. * (4) On STM32F3, parameter available only on ADC instances: ADC4.\n
  1392. * (5) On STM32F3, ADC channel available only on all ADC instances, but
  1393. * only one ADC instance is allowed to be connected to VrefInt at the same time.
  1394. * @retval Value between Min_Data=0 and Max_Data=18
  1395. */
  1396. #define __LL_ADC_CHANNEL_TO_DECIMAL_NB(__CHANNEL__) \
  1397. ((((__CHANNEL__) & ADC_CHANNEL_ID_BITFIELD_MASK) == 0U) \
  1398. ? ( \
  1399. ((__CHANNEL__) & ADC_CHANNEL_ID_NUMBER_MASK) >> ADC_CHANNEL_ID_NUMBER_BITOFFSET_POS \
  1400. ) \
  1401. : \
  1402. ( \
  1403. POSITION_VAL((__CHANNEL__)) \
  1404. ) \
  1405. )
  1406. /**
  1407. * @brief Helper macro to get ADC channel in literal format LL_ADC_CHANNEL_x
  1408. * from number in decimal format.
  1409. * @note Example:
  1410. * __LL_ADC_DECIMAL_NB_TO_CHANNEL(4)
  1411. * will return a data equivalent to "LL_ADC_CHANNEL_4".
  1412. * @param __DECIMAL_NB__ Value between Min_Data=0 and Max_Data=18
  1413. * @retval Returned value can be one of the following values:
  1414. * @arg @ref LL_ADC_CHANNEL_0
  1415. * @arg @ref LL_ADC_CHANNEL_1
  1416. * @arg @ref LL_ADC_CHANNEL_2
  1417. * @arg @ref LL_ADC_CHANNEL_3
  1418. * @arg @ref LL_ADC_CHANNEL_4
  1419. * @arg @ref LL_ADC_CHANNEL_5
  1420. * @arg @ref LL_ADC_CHANNEL_6
  1421. * @arg @ref LL_ADC_CHANNEL_7
  1422. * @arg @ref LL_ADC_CHANNEL_8
  1423. * @arg @ref LL_ADC_CHANNEL_9
  1424. * @arg @ref LL_ADC_CHANNEL_10
  1425. * @arg @ref LL_ADC_CHANNEL_11
  1426. * @arg @ref LL_ADC_CHANNEL_12
  1427. * @arg @ref LL_ADC_CHANNEL_13
  1428. * @arg @ref LL_ADC_CHANNEL_14
  1429. * @arg @ref LL_ADC_CHANNEL_15
  1430. * @arg @ref LL_ADC_CHANNEL_16
  1431. * @arg @ref LL_ADC_CHANNEL_17
  1432. * @arg @ref LL_ADC_CHANNEL_18
  1433. * @arg @ref LL_ADC_CHANNEL_VREFINT (5)
  1434. * @arg @ref LL_ADC_CHANNEL_TEMPSENSOR (1)
  1435. * @arg @ref LL_ADC_CHANNEL_VBAT (1)
  1436. * @arg @ref LL_ADC_CHANNEL_VOPAMP1 (1)
  1437. * @arg @ref LL_ADC_CHANNEL_VOPAMP2 (2)
  1438. * @arg @ref LL_ADC_CHANNEL_VOPAMP3 (3)
  1439. * @arg @ref LL_ADC_CHANNEL_VOPAMP4 (4)
  1440. *
  1441. * (1) On STM32F3, parameter available only on ADC instance: ADC1.\n
  1442. * (2) On STM32F3, parameter available only on ADC instance: ADC2.\n
  1443. * (3) On STM32F3, parameter available only on ADC instance: ADC3.\n
  1444. * (4) On STM32F3, parameter available only on ADC instances: ADC4.\n
  1445. * (5) On STM32F3, ADC channel available only on all ADC instances, but
  1446. * only one ADC instance is allowed to be connected to VrefInt at the same time.\n
  1447. * (1, 2, 3, 4, 5) For ADC channel read back from ADC register,
  1448. * comparison with internal channel parameter to be done
  1449. * using helper macro @ref __LL_ADC_CHANNEL_INTERNAL_TO_EXTERNAL().
  1450. */
  1451. #define __LL_ADC_DECIMAL_NB_TO_CHANNEL(__DECIMAL_NB__) \
  1452. (((__DECIMAL_NB__) <= 9U) \
  1453. ? ( \
  1454. ((__DECIMAL_NB__) << ADC_CHANNEL_ID_NUMBER_BITOFFSET_POS) | \
  1455. (ADC_AWD2CR_AWD2CH_0 << (__DECIMAL_NB__)) | \
  1456. (ADC_SMPR1_REGOFFSET | (((uint32_t) (3U * (__DECIMAL_NB__))) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) \
  1457. ) \
  1458. : \
  1459. ( \
  1460. ((__DECIMAL_NB__) << ADC_CHANNEL_ID_NUMBER_BITOFFSET_POS) | \
  1461. (ADC_AWD2CR_AWD2CH_0 << (__DECIMAL_NB__)) | \
  1462. (ADC_SMPR2_REGOFFSET | (((uint32_t) (3U * ((__DECIMAL_NB__) - 10U))) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) \
  1463. ) \
  1464. )
  1465. /**
  1466. * @brief Helper macro to determine whether the selected channel
  1467. * corresponds to literal definitions of driver.
  1468. * @note The different literal definitions of ADC channels are:
  1469. * - ADC internal channel:
  1470. * LL_ADC_CHANNEL_VREFINT, LL_ADC_CHANNEL_TEMPSENSOR, ...
  1471. * - ADC external channel (channel connected to a GPIO pin):
  1472. * LL_ADC_CHANNEL_1, LL_ADC_CHANNEL_2, ...
  1473. * @note The channel parameter must be a value defined from literal
  1474. * definition of a ADC internal channel (LL_ADC_CHANNEL_VREFINT,
  1475. * LL_ADC_CHANNEL_TEMPSENSOR, ...),
  1476. * ADC external channel (LL_ADC_CHANNEL_1, LL_ADC_CHANNEL_2, ...),
  1477. * must not be a value from functions where a channel number is
  1478. * returned from ADC registers,
  1479. * because internal and external channels share the same channel
  1480. * number in ADC registers. The differentiation is made only with
  1481. * parameters definitions of driver.
  1482. * @param __CHANNEL__ This parameter can be one of the following values:
  1483. * @arg @ref LL_ADC_CHANNEL_0
  1484. * @arg @ref LL_ADC_CHANNEL_1
  1485. * @arg @ref LL_ADC_CHANNEL_2
  1486. * @arg @ref LL_ADC_CHANNEL_3
  1487. * @arg @ref LL_ADC_CHANNEL_4
  1488. * @arg @ref LL_ADC_CHANNEL_5
  1489. * @arg @ref LL_ADC_CHANNEL_6
  1490. * @arg @ref LL_ADC_CHANNEL_7
  1491. * @arg @ref LL_ADC_CHANNEL_8
  1492. * @arg @ref LL_ADC_CHANNEL_9
  1493. * @arg @ref LL_ADC_CHANNEL_10
  1494. * @arg @ref LL_ADC_CHANNEL_11
  1495. * @arg @ref LL_ADC_CHANNEL_12
  1496. * @arg @ref LL_ADC_CHANNEL_13
  1497. * @arg @ref LL_ADC_CHANNEL_14
  1498. * @arg @ref LL_ADC_CHANNEL_15
  1499. * @arg @ref LL_ADC_CHANNEL_16
  1500. * @arg @ref LL_ADC_CHANNEL_17
  1501. * @arg @ref LL_ADC_CHANNEL_18
  1502. * @arg @ref LL_ADC_CHANNEL_VREFINT (5)
  1503. * @arg @ref LL_ADC_CHANNEL_TEMPSENSOR (1)
  1504. * @arg @ref LL_ADC_CHANNEL_VBAT (1)
  1505. * @arg @ref LL_ADC_CHANNEL_VOPAMP1 (1)
  1506. * @arg @ref LL_ADC_CHANNEL_VOPAMP2 (2)
  1507. * @arg @ref LL_ADC_CHANNEL_VOPAMP3 (3)
  1508. * @arg @ref LL_ADC_CHANNEL_VOPAMP4 (4)
  1509. *
  1510. * (1) On STM32F3, parameter available only on ADC instance: ADC1.\n
  1511. * (2) On STM32F3, parameter available only on ADC instance: ADC2.\n
  1512. * (3) On STM32F3, parameter available only on ADC instance: ADC3.\n
  1513. * (4) On STM32F3, parameter available only on ADC instances: ADC4.\n
  1514. * (5) On STM32F3, ADC channel available only on all ADC instances, but
  1515. * only one ADC instance is allowed to be connected to VrefInt at the same time.
  1516. * @retval Value "0" if the channel corresponds to a parameter definition of a ADC external channel (channel connected to a GPIO pin).
  1517. * Value "1" if the channel corresponds to a parameter definition of a ADC internal channel.
  1518. */
  1519. #define __LL_ADC_IS_CHANNEL_INTERNAL(__CHANNEL__) \
  1520. (((__CHANNEL__) & ADC_CHANNEL_ID_INTERNAL_CH_MASK) != 0U)
  1521. /**
  1522. * @brief Helper macro to convert a channel defined from parameter
  1523. * definition of a ADC internal channel (LL_ADC_CHANNEL_VREFINT,
  1524. * LL_ADC_CHANNEL_TEMPSENSOR, ...),
  1525. * to its equivalent parameter definition of a ADC external channel
  1526. * (LL_ADC_CHANNEL_1, LL_ADC_CHANNEL_2, ...).
  1527. * @note The channel parameter can be, additionally to a value
  1528. * defined from parameter definition of a ADC internal channel
  1529. * (LL_ADC_CHANNEL_VREFINT, LL_ADC_CHANNEL_TEMPSENSOR, ...),
  1530. * a value defined from parameter definition of
  1531. * ADC external channel (LL_ADC_CHANNEL_1, LL_ADC_CHANNEL_2, ...)
  1532. * or a value from functions where a channel number is returned
  1533. * from ADC registers.
  1534. * @param __CHANNEL__ This parameter can be one of the following values:
  1535. * @arg @ref LL_ADC_CHANNEL_0
  1536. * @arg @ref LL_ADC_CHANNEL_1
  1537. * @arg @ref LL_ADC_CHANNEL_2
  1538. * @arg @ref LL_ADC_CHANNEL_3
  1539. * @arg @ref LL_ADC_CHANNEL_4
  1540. * @arg @ref LL_ADC_CHANNEL_5
  1541. * @arg @ref LL_ADC_CHANNEL_6
  1542. * @arg @ref LL_ADC_CHANNEL_7
  1543. * @arg @ref LL_ADC_CHANNEL_8
  1544. * @arg @ref LL_ADC_CHANNEL_9
  1545. * @arg @ref LL_ADC_CHANNEL_10
  1546. * @arg @ref LL_ADC_CHANNEL_11
  1547. * @arg @ref LL_ADC_CHANNEL_12
  1548. * @arg @ref LL_ADC_CHANNEL_13
  1549. * @arg @ref LL_ADC_CHANNEL_14
  1550. * @arg @ref LL_ADC_CHANNEL_15
  1551. * @arg @ref LL_ADC_CHANNEL_16
  1552. * @arg @ref LL_ADC_CHANNEL_17
  1553. * @arg @ref LL_ADC_CHANNEL_18
  1554. * @arg @ref LL_ADC_CHANNEL_VREFINT (5)
  1555. * @arg @ref LL_ADC_CHANNEL_TEMPSENSOR (1)
  1556. * @arg @ref LL_ADC_CHANNEL_VBAT (1)
  1557. * @arg @ref LL_ADC_CHANNEL_VOPAMP1 (1)
  1558. * @arg @ref LL_ADC_CHANNEL_VOPAMP2 (2)
  1559. * @arg @ref LL_ADC_CHANNEL_VOPAMP3 (3)
  1560. * @arg @ref LL_ADC_CHANNEL_VOPAMP4 (4)
  1561. *
  1562. * (1) On STM32F3, parameter available only on ADC instance: ADC1.\n
  1563. * (2) On STM32F3, parameter available only on ADC instance: ADC2.\n
  1564. * (3) On STM32F3, parameter available only on ADC instance: ADC3.\n
  1565. * (4) On STM32F3, parameter available only on ADC instances: ADC4.\n
  1566. * (5) On STM32F3, ADC channel available only on all ADC instances, but
  1567. * only one ADC instance is allowed to be connected to VrefInt at the same time.
  1568. * @retval Returned value can be one of the following values:
  1569. * @arg @ref LL_ADC_CHANNEL_0
  1570. * @arg @ref LL_ADC_CHANNEL_1
  1571. * @arg @ref LL_ADC_CHANNEL_2
  1572. * @arg @ref LL_ADC_CHANNEL_3
  1573. * @arg @ref LL_ADC_CHANNEL_4
  1574. * @arg @ref LL_ADC_CHANNEL_5
  1575. * @arg @ref LL_ADC_CHANNEL_6
  1576. * @arg @ref LL_ADC_CHANNEL_7
  1577. * @arg @ref LL_ADC_CHANNEL_8
  1578. * @arg @ref LL_ADC_CHANNEL_9
  1579. * @arg @ref LL_ADC_CHANNEL_10
  1580. * @arg @ref LL_ADC_CHANNEL_11
  1581. * @arg @ref LL_ADC_CHANNEL_12
  1582. * @arg @ref LL_ADC_CHANNEL_13
  1583. * @arg @ref LL_ADC_CHANNEL_14
  1584. * @arg @ref LL_ADC_CHANNEL_15
  1585. * @arg @ref LL_ADC_CHANNEL_16
  1586. * @arg @ref LL_ADC_CHANNEL_17
  1587. * @arg @ref LL_ADC_CHANNEL_18
  1588. */
  1589. #define __LL_ADC_CHANNEL_INTERNAL_TO_EXTERNAL(__CHANNEL__) \
  1590. ((__CHANNEL__) & ~ADC_CHANNEL_ID_INTERNAL_CH_MASK)
  1591. /**
  1592. * @brief Helper macro to determine whether the internal channel
  1593. * selected is available on the ADC instance selected.
  1594. * @note The channel parameter must be a value defined from parameter
  1595. * definition of a ADC internal channel (LL_ADC_CHANNEL_VREFINT,
  1596. * LL_ADC_CHANNEL_TEMPSENSOR, ...),
  1597. * must not be a value defined from parameter definition of
  1598. * ADC external channel (LL_ADC_CHANNEL_1, LL_ADC_CHANNEL_2, ...)
  1599. * or a value from functions where a channel number is
  1600. * returned from ADC registers,
  1601. * because internal and external channels share the same channel
  1602. * number in ADC registers. The differentiation is made only with
  1603. * parameters definitions of driver.
  1604. * @param __ADC_INSTANCE__ ADC instance
  1605. * @param __CHANNEL__ This parameter can be one of the following values:
  1606. * @arg @ref LL_ADC_CHANNEL_VREFINT (5)
  1607. * @arg @ref LL_ADC_CHANNEL_TEMPSENSOR (1)
  1608. * @arg @ref LL_ADC_CHANNEL_VBAT (1)
  1609. * @arg @ref LL_ADC_CHANNEL_VOPAMP1 (1)
  1610. * @arg @ref LL_ADC_CHANNEL_VOPAMP2 (2)
  1611. * @arg @ref LL_ADC_CHANNEL_VOPAMP3 (3)
  1612. * @arg @ref LL_ADC_CHANNEL_VOPAMP4 (4)
  1613. *
  1614. * (1) On STM32F3, parameter available only on ADC instance: ADC1.\n
  1615. * (2) On STM32F3, parameter available only on ADC instance: ADC2.\n
  1616. * (3) On STM32F3, parameter available only on ADC instance: ADC3.\n
  1617. * (4) On STM32F3, parameter available only on ADC instances: ADC4.\n
  1618. * (5) On STM32F3, ADC channel available only on all ADC instances, but
  1619. * only one ADC instance is allowed to be connected to VrefInt at the same time.
  1620. * @retval Value "0" if the internal channel selected is not available on the ADC instance selected.
  1621. * Value "1" if the internal channel selected is available on the ADC instance selected.
  1622. */
  1623. #if defined (ADC1) && defined (ADC2) && defined (ADC3) && defined (ADC4)
  1624. #define __LL_ADC_IS_CHANNEL_INTERNAL_AVAILABLE(__ADC_INSTANCE__, __CHANNEL__) \
  1625. (((__ADC_INSTANCE__) == ADC1) \
  1626. ? ( \
  1627. ((__CHANNEL__) == LL_ADC_CHANNEL_VREFINT) || \
  1628. ((__CHANNEL__) == LL_ADC_CHANNEL_TEMPSENSOR) || \
  1629. ((__CHANNEL__) == LL_ADC_CHANNEL_VBAT) || \
  1630. ((__CHANNEL__) == LL_ADC_CHANNEL_VOPAMP1) \
  1631. ) \
  1632. : \
  1633. ((__ADC_INSTANCE__) == ADC2) \
  1634. ? ( \
  1635. ((__CHANNEL__) == LL_ADC_CHANNEL_VREFINT) || \
  1636. ((__CHANNEL__) == LL_ADC_CHANNEL_VOPAMP2) \
  1637. ) \
  1638. : \
  1639. ((__ADC_INSTANCE__) == ADC3) \
  1640. ? ( \
  1641. ((__CHANNEL__) == LL_ADC_CHANNEL_VREFINT) || \
  1642. ((__CHANNEL__) == LL_ADC_CHANNEL_VOPAMP3) \
  1643. ) \
  1644. : \
  1645. ((__ADC_INSTANCE__) == ADC4) \
  1646. ? ( \
  1647. ((__CHANNEL__) == LL_ADC_CHANNEL_VREFINT) || \
  1648. ((__CHANNEL__) == LL_ADC_CHANNEL_VOPAMP4) \
  1649. ) \
  1650. : \
  1651. (0U) \
  1652. )
  1653. #elif defined (ADC1) && defined (ADC2)
  1654. #if defined(OPAMP1_CSR_OPAMP1EN) && defined(OPAMP2_CSR_OPAMP2EN)
  1655. #define __LL_ADC_IS_CHANNEL_INTERNAL_AVAILABLE(__ADC_INSTANCE__, __CHANNEL__) \
  1656. (((__ADC_INSTANCE__) == ADC1) \
  1657. ? ( \
  1658. ((__CHANNEL__) == LL_ADC_CHANNEL_VREFINT) || \
  1659. ((__CHANNEL__) == LL_ADC_CHANNEL_TEMPSENSOR) || \
  1660. ((__CHANNEL__) == LL_ADC_CHANNEL_VBAT) || \
  1661. ((__CHANNEL__) == LL_ADC_CHANNEL_VOPAMP1) \
  1662. ) \
  1663. : \
  1664. ((__ADC_INSTANCE__) == ADC2) \
  1665. ? ( \
  1666. ((__CHANNEL__) == LL_ADC_CHANNEL_VREFINT) || \
  1667. ((__CHANNEL__) == LL_ADC_CHANNEL_VOPAMP2) \
  1668. ) \
  1669. : \
  1670. (0U) \
  1671. )
  1672. #elif defined(OPAMP2_CSR_OPAMP2EN)
  1673. #define __LL_ADC_IS_CHANNEL_INTERNAL_AVAILABLE(__ADC_INSTANCE__, __CHANNEL__) \
  1674. (((__ADC_INSTANCE__) == ADC1) \
  1675. ? ( \
  1676. ((__CHANNEL__) == LL_ADC_CHANNEL_VREFINT) || \
  1677. ((__CHANNEL__) == LL_ADC_CHANNEL_TEMPSENSOR) || \
  1678. ((__CHANNEL__) == LL_ADC_CHANNEL_VBAT) \
  1679. ) \
  1680. : \
  1681. ((__ADC_INSTANCE__) == ADC2) \
  1682. ? ( \
  1683. ((__CHANNEL__) == LL_ADC_CHANNEL_VREFINT) || \
  1684. ((__CHANNEL__) == LL_ADC_CHANNEL_VOPAMP2) \
  1685. ) \
  1686. : \
  1687. (0U) \
  1688. )
  1689. #else
  1690. #define __LL_ADC_IS_CHANNEL_INTERNAL_AVAILABLE(__ADC_INSTANCE__, __CHANNEL__) \
  1691. (((__ADC_INSTANCE__) == ADC1) \
  1692. ? ( \
  1693. ((__CHANNEL__) == LL_ADC_CHANNEL_VREFINT) || \
  1694. ((__CHANNEL__) == LL_ADC_CHANNEL_TEMPSENSOR) || \
  1695. ((__CHANNEL__) == LL_ADC_CHANNEL_VBAT) || \
  1696. ((__CHANNEL__) == LL_ADC_CHANNEL_VOPAMP1) \
  1697. ) \
  1698. : \
  1699. ((__ADC_INSTANCE__) == ADC2) \
  1700. ? ( \
  1701. ((__CHANNEL__) == LL_ADC_CHANNEL_VREFINT) \
  1702. ) \
  1703. : \
  1704. (0U) \
  1705. )
  1706. #endif
  1707. #elif defined (ADC1)
  1708. #if defined(OPAMP1_CSR_OPAMP1EN)
  1709. #define __LL_ADC_IS_CHANNEL_INTERNAL_AVAILABLE(__ADC_INSTANCE__, __CHANNEL__) \
  1710. ( \
  1711. ((__CHANNEL__) == LL_ADC_CHANNEL_VREFINT) || \
  1712. ((__CHANNEL__) == LL_ADC_CHANNEL_TEMPSENSOR) || \
  1713. ((__CHANNEL__) == LL_ADC_CHANNEL_VBAT) || \
  1714. ((__CHANNEL__) == LL_ADC_CHANNEL_VOPAMP1) \
  1715. )
  1716. #else
  1717. #define __LL_ADC_IS_CHANNEL_INTERNAL_AVAILABLE(__ADC_INSTANCE__, __CHANNEL__) \
  1718. ( \
  1719. ((__CHANNEL__) == LL_ADC_CHANNEL_VREFINT) || \
  1720. ((__CHANNEL__) == LL_ADC_CHANNEL_TEMPSENSOR) || \
  1721. ((__CHANNEL__) == LL_ADC_CHANNEL_VBAT) \
  1722. )
  1723. #endif
  1724. #endif
  1725. /**
  1726. * @brief Helper macro to define ADC analog watchdog parameter:
  1727. * define a single channel to monitor with analog watchdog
  1728. * from sequencer channel and groups definition.
  1729. * @note To be used with function @ref LL_ADC_SetAnalogWDMonitChannels().
  1730. * Example:
  1731. * LL_ADC_SetAnalogWDMonitChannels(
  1732. * ADC1, LL_ADC_AWD1,
  1733. * __LL_ADC_ANALOGWD_CHANNEL_GROUP(LL_ADC_CHANNEL4, LL_ADC_GROUP_REGULAR))
  1734. * @param __CHANNEL__ This parameter can be one of the following values:
  1735. * @arg @ref LL_ADC_CHANNEL_0
  1736. * @arg @ref LL_ADC_CHANNEL_1
  1737. * @arg @ref LL_ADC_CHANNEL_2
  1738. * @arg @ref LL_ADC_CHANNEL_3
  1739. * @arg @ref LL_ADC_CHANNEL_4
  1740. * @arg @ref LL_ADC_CHANNEL_5
  1741. * @arg @ref LL_ADC_CHANNEL_6
  1742. * @arg @ref LL_ADC_CHANNEL_7
  1743. * @arg @ref LL_ADC_CHANNEL_8
  1744. * @arg @ref LL_ADC_CHANNEL_9
  1745. * @arg @ref LL_ADC_CHANNEL_10
  1746. * @arg @ref LL_ADC_CHANNEL_11
  1747. * @arg @ref LL_ADC_CHANNEL_12
  1748. * @arg @ref LL_ADC_CHANNEL_13
  1749. * @arg @ref LL_ADC_CHANNEL_14
  1750. * @arg @ref LL_ADC_CHANNEL_15
  1751. * @arg @ref LL_ADC_CHANNEL_16
  1752. * @arg @ref LL_ADC_CHANNEL_17
  1753. * @arg @ref LL_ADC_CHANNEL_18
  1754. * @arg @ref LL_ADC_CHANNEL_VREFINT (5)
  1755. * @arg @ref LL_ADC_CHANNEL_TEMPSENSOR (1)
  1756. * @arg @ref LL_ADC_CHANNEL_VBAT (1)
  1757. * @arg @ref LL_ADC_CHANNEL_VOPAMP1 (1)
  1758. * @arg @ref LL_ADC_CHANNEL_VOPAMP2 (2)
  1759. * @arg @ref LL_ADC_CHANNEL_VOPAMP3 (3)
  1760. * @arg @ref LL_ADC_CHANNEL_VOPAMP4 (4)
  1761. *
  1762. * (1) On STM32F3, parameter available only on ADC instance: ADC1.\n
  1763. * (2) On STM32F3, parameter available only on ADC instance: ADC2.\n
  1764. * (3) On STM32F3, parameter available only on ADC instance: ADC3.\n
  1765. * (4) On STM32F3, parameter available only on ADC instances: ADC4.\n
  1766. * (5) On STM32F3, ADC channel available only on all ADC instances, but
  1767. * only one ADC instance is allowed to be connected to VrefInt at the same time.\n
  1768. * (1, 2, 3, 4, 5) For ADC channel read back from ADC register,
  1769. * comparison with internal channel parameter to be done
  1770. * using helper macro @ref __LL_ADC_CHANNEL_INTERNAL_TO_EXTERNAL().
  1771. * @param __GROUP__ This parameter can be one of the following values:
  1772. * @arg @ref LL_ADC_GROUP_REGULAR
  1773. * @arg @ref LL_ADC_GROUP_INJECTED
  1774. * @arg @ref LL_ADC_GROUP_REGULAR_INJECTED
  1775. * @retval Returned value can be one of the following values:
  1776. * @arg @ref LL_ADC_AWD_DISABLE
  1777. * @arg @ref LL_ADC_AWD_ALL_CHANNELS_REG (0)
  1778. * @arg @ref LL_ADC_AWD_ALL_CHANNELS_INJ (0)
  1779. * @arg @ref LL_ADC_AWD_ALL_CHANNELS_REG_INJ
  1780. * @arg @ref LL_ADC_AWD_CHANNEL_0_REG (0)
  1781. * @arg @ref LL_ADC_AWD_CHANNEL_0_INJ (0)
  1782. * @arg @ref LL_ADC_AWD_CHANNEL_0_REG_INJ
  1783. * @arg @ref LL_ADC_AWD_CHANNEL_1_REG (0)
  1784. * @arg @ref LL_ADC_AWD_CHANNEL_1_INJ (0)
  1785. * @arg @ref LL_ADC_AWD_CHANNEL_1_REG_INJ
  1786. * @arg @ref LL_ADC_AWD_CHANNEL_2_REG (0)
  1787. * @arg @ref LL_ADC_AWD_CHANNEL_2_INJ (0)
  1788. * @arg @ref LL_ADC_AWD_CHANNEL_2_REG_INJ
  1789. * @arg @ref LL_ADC_AWD_CHANNEL_3_REG (0)
  1790. * @arg @ref LL_ADC_AWD_CHANNEL_3_INJ (0)
  1791. * @arg @ref LL_ADC_AWD_CHANNEL_3_REG_INJ
  1792. * @arg @ref LL_ADC_AWD_CHANNEL_4_REG (0)
  1793. * @arg @ref LL_ADC_AWD_CHANNEL_4_INJ (0)
  1794. * @arg @ref LL_ADC_AWD_CHANNEL_4_REG_INJ
  1795. * @arg @ref LL_ADC_AWD_CHANNEL_5_REG (0)
  1796. * @arg @ref LL_ADC_AWD_CHANNEL_5_INJ (0)
  1797. * @arg @ref LL_ADC_AWD_CHANNEL_5_REG_INJ
  1798. * @arg @ref LL_ADC_AWD_CHANNEL_6_REG (0)
  1799. * @arg @ref LL_ADC_AWD_CHANNEL_6_INJ (0)
  1800. * @arg @ref LL_ADC_AWD_CHANNEL_6_REG_INJ
  1801. * @arg @ref LL_ADC_AWD_CHANNEL_7_REG (0)
  1802. * @arg @ref LL_ADC_AWD_CHANNEL_7_INJ (0)
  1803. * @arg @ref LL_ADC_AWD_CHANNEL_7_REG_INJ
  1804. * @arg @ref LL_ADC_AWD_CHANNEL_8_REG (0)
  1805. * @arg @ref LL_ADC_AWD_CHANNEL_8_INJ (0)
  1806. * @arg @ref LL_ADC_AWD_CHANNEL_8_REG_INJ
  1807. * @arg @ref LL_ADC_AWD_CHANNEL_9_REG (0)
  1808. * @arg @ref LL_ADC_AWD_CHANNEL_9_INJ (0)
  1809. * @arg @ref LL_ADC_AWD_CHANNEL_9_REG_INJ
  1810. * @arg @ref LL_ADC_AWD_CHANNEL_10_REG (0)
  1811. * @arg @ref LL_ADC_AWD_CHANNEL_10_INJ (0)
  1812. * @arg @ref LL_ADC_AWD_CHANNEL_10_REG_INJ
  1813. * @arg @ref LL_ADC_AWD_CHANNEL_11_REG (0)
  1814. * @arg @ref LL_ADC_AWD_CHANNEL_11_INJ (0)
  1815. * @arg @ref LL_ADC_AWD_CHANNEL_11_REG_INJ
  1816. * @arg @ref LL_ADC_AWD_CHANNEL_12_REG (0)
  1817. * @arg @ref LL_ADC_AWD_CHANNEL_12_INJ (0)
  1818. * @arg @ref LL_ADC_AWD_CHANNEL_12_REG_INJ
  1819. * @arg @ref LL_ADC_AWD_CHANNEL_13_REG (0)
  1820. * @arg @ref LL_ADC_AWD_CHANNEL_13_INJ (0)
  1821. * @arg @ref LL_ADC_AWD_CHANNEL_13_REG_INJ
  1822. * @arg @ref LL_ADC_AWD_CHANNEL_14_REG (0)
  1823. * @arg @ref LL_ADC_AWD_CHANNEL_14_INJ (0)
  1824. * @arg @ref LL_ADC_AWD_CHANNEL_14_REG_INJ
  1825. * @arg @ref LL_ADC_AWD_CHANNEL_15_REG (0)
  1826. * @arg @ref LL_ADC_AWD_CHANNEL_15_INJ (0)
  1827. * @arg @ref LL_ADC_AWD_CHANNEL_15_REG_INJ
  1828. * @arg @ref LL_ADC_AWD_CHANNEL_16_REG (0)
  1829. * @arg @ref LL_ADC_AWD_CHANNEL_16_INJ (0)
  1830. * @arg @ref LL_ADC_AWD_CHANNEL_16_REG_INJ
  1831. * @arg @ref LL_ADC_AWD_CHANNEL_17_REG (0)
  1832. * @arg @ref LL_ADC_AWD_CHANNEL_17_INJ (0)
  1833. * @arg @ref LL_ADC_AWD_CHANNEL_17_REG_INJ
  1834. * @arg @ref LL_ADC_AWD_CHANNEL_18_REG (0)
  1835. * @arg @ref LL_ADC_AWD_CHANNEL_18_INJ (0)
  1836. * @arg @ref LL_ADC_AWD_CHANNEL_18_REG_INJ
  1837. * @arg @ref LL_ADC_AWD_CH_VREFINT_REG (0)(5)
  1838. * @arg @ref LL_ADC_AWD_CH_VREFINT_INJ (0)(5)
  1839. * @arg @ref LL_ADC_AWD_CH_VREFINT_REG_INJ (5)
  1840. * @arg @ref LL_ADC_AWD_CH_TEMPSENSOR_REG (0)(1)
  1841. * @arg @ref LL_ADC_AWD_CH_TEMPSENSOR_INJ (0)(1)
  1842. * @arg @ref LL_ADC_AWD_CH_TEMPSENSOR_REG_INJ (1)
  1843. * @arg @ref LL_ADC_AWD_CH_VBAT_REG (0)(1)
  1844. * @arg @ref LL_ADC_AWD_CH_VBAT_INJ (0)(1)
  1845. * @arg @ref LL_ADC_AWD_CH_VBAT_REG_INJ (1)
  1846. * @arg @ref LL_ADC_AWD_CH_VOPAMP1_REG (0)(1)
  1847. * @arg @ref LL_ADC_AWD_CH_VOPAMP1_INJ (0)(1)
  1848. * @arg @ref LL_ADC_AWD_CH_VOPAMP1_REG_INJ (1)
  1849. * @arg @ref LL_ADC_AWD_CH_VOPAMP2_REG (0)(2)
  1850. * @arg @ref LL_ADC_AWD_CH_VOPAMP2_INJ (0)(2)
  1851. * @arg @ref LL_ADC_AWD_CH_VOPAMP2_REG_INJ (2)
  1852. * @arg @ref LL_ADC_AWD_CH_VOPAMP3_REG (0)(3)
  1853. * @arg @ref LL_ADC_AWD_CH_VOPAMP3_INJ (0)(3)
  1854. * @arg @ref LL_ADC_AWD_CH_VOPAMP3_REG_INJ (3)
  1855. * @arg @ref LL_ADC_AWD_CH_VOPAMP4_REG (0)(4)
  1856. * @arg @ref LL_ADC_AWD_CH_VOPAMP4_INJ (0)(4)
  1857. * @arg @ref LL_ADC_AWD_CH_VOPAMP4_REG_INJ (4)
  1858. *
  1859. * (0) On STM32F3, parameter available only on analog watchdog number: AWD1.\n
  1860. * (1) On STM32F3, parameter available only on ADC instance: ADC1.\n
  1861. * (2) On STM32F3, parameter available only on ADC instance: ADC2.\n
  1862. * (3) On STM32F3, parameter available only on ADC instance: ADC3.\n
  1863. * (4) On STM32F3, parameter available only on ADC instances: ADC4.\n
  1864. * (5) On STM32F3, ADC channel available only on all ADC instances, but
  1865. * only one ADC instance is allowed to be connected to VrefInt at the same time.
  1866. */
  1867. #define __LL_ADC_ANALOGWD_CHANNEL_GROUP(__CHANNEL__, __GROUP__) \
  1868. (((__GROUP__) == LL_ADC_GROUP_REGULAR) \
  1869. ? (((__CHANNEL__) & ADC_CHANNEL_ID_MASK) | ADC_CFGR_AWD1EN | ADC_CFGR_AWD1SGL) \
  1870. : \
  1871. ((__GROUP__) == LL_ADC_GROUP_INJECTED) \
  1872. ? (((__CHANNEL__) & ADC_CHANNEL_ID_MASK) | ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1SGL) \
  1873. : \
  1874. (((__CHANNEL__) & ADC_CHANNEL_ID_MASK) | ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1EN | ADC_CFGR_AWD1SGL) \
  1875. )
  1876. /**
  1877. * @brief Helper macro to set the value of ADC analog watchdog threshold high
  1878. * or low in function of ADC resolution, when ADC resolution is
  1879. * different of 12 bits.
  1880. * @note To be used with function @ref LL_ADC_ConfigAnalogWDThresholds()
  1881. * or @ref LL_ADC_SetAnalogWDThresholds().
  1882. * Example, with a ADC resolution of 8 bits, to set the value of
  1883. * analog watchdog threshold high (on 8 bits):
  1884. * LL_ADC_SetAnalogWDThresholds
  1885. * (< ADCx param >,
  1886. * __LL_ADC_ANALOGWD_SET_THRESHOLD_RESOLUTION(LL_ADC_RESOLUTION_8B, <threshold_value_8_bits>)
  1887. * );
  1888. * @param __ADC_RESOLUTION__ This parameter can be one of the following values:
  1889. * @arg @ref LL_ADC_RESOLUTION_12B
  1890. * @arg @ref LL_ADC_RESOLUTION_10B
  1891. * @arg @ref LL_ADC_RESOLUTION_8B
  1892. * @arg @ref LL_ADC_RESOLUTION_6B
  1893. * @param __AWD_THRESHOLD__ Value between Min_Data=0x000 and Max_Data=0xFFF
  1894. * @retval Value between Min_Data=0x000 and Max_Data=0xFFF
  1895. */
  1896. #define __LL_ADC_ANALOGWD_SET_THRESHOLD_RESOLUTION(__ADC_RESOLUTION__, __AWD_THRESHOLD__) \
  1897. ((__AWD_THRESHOLD__) << ((__ADC_RESOLUTION__) >> (ADC_CFGR_RES_BITOFFSET_POS - 1U )))
  1898. /**
  1899. * @brief Helper macro to get the value of ADC analog watchdog threshold high
  1900. * or low in function of ADC resolution, when ADC resolution is
  1901. * different of 12 bits.
  1902. * @note To be used with function @ref LL_ADC_GetAnalogWDThresholds().
  1903. * Example, with a ADC resolution of 8 bits, to get the value of
  1904. * analog watchdog threshold high (on 8 bits):
  1905. * < threshold_value_6_bits > = __LL_ADC_ANALOGWD_GET_THRESHOLD_RESOLUTION
  1906. * (LL_ADC_RESOLUTION_8B,
  1907. * LL_ADC_GetAnalogWDThresholds(<ADCx param>, LL_ADC_AWD_THRESHOLD_HIGH)
  1908. * );
  1909. * @param __ADC_RESOLUTION__ This parameter can be one of the following values:
  1910. * @arg @ref LL_ADC_RESOLUTION_12B
  1911. * @arg @ref LL_ADC_RESOLUTION_10B
  1912. * @arg @ref LL_ADC_RESOLUTION_8B
  1913. * @arg @ref LL_ADC_RESOLUTION_6B
  1914. * @param __AWD_THRESHOLD_12_BITS__ Value between Min_Data=0x000 and Max_Data=0xFFF
  1915. * @retval Value between Min_Data=0x000 and Max_Data=0xFFF
  1916. */
  1917. #define __LL_ADC_ANALOGWD_GET_THRESHOLD_RESOLUTION(__ADC_RESOLUTION__, __AWD_THRESHOLD_12_BITS__) \
  1918. ((__AWD_THRESHOLD_12_BITS__) >> ((__ADC_RESOLUTION__) >> (ADC_CFGR_RES_BITOFFSET_POS - 1U )))
  1919. /**
  1920. * @brief Helper macro to get the ADC analog watchdog threshold high
  1921. * or low from raw value containing both thresholds concatenated.
  1922. * @note To be used with function @ref LL_ADC_GetAnalogWDThresholds().
  1923. * Example, to get analog watchdog threshold high from the register raw value:
  1924. * __LL_ADC_ANALOGWD_THRESHOLDS_HIGH_LOW(LL_ADC_AWD_THRESHOLD_HIGH, <raw_value_with_both_thresholds>);
  1925. * @param __AWD_THRESHOLD_TYPE__ This parameter can be one of the following values:
  1926. * @arg @ref LL_ADC_AWD_THRESHOLD_HIGH
  1927. * @arg @ref LL_ADC_AWD_THRESHOLD_LOW
  1928. * @param __AWD_THRESHOLDS__ Value between Min_Data=0x00000000 and Max_Data=0xFFFFFFFF
  1929. * @retval Value between Min_Data=0x000 and Max_Data=0xFFF
  1930. */
  1931. #define __LL_ADC_ANALOGWD_THRESHOLDS_HIGH_LOW(__AWD_THRESHOLD_TYPE__, __AWD_THRESHOLDS__) \
  1932. (((__AWD_THRESHOLDS__) >> POSITION_VAL((__AWD_THRESHOLD_TYPE__))) & LL_ADC_AWD_THRESHOLD_LOW)
  1933. /**
  1934. * @brief Helper macro to set the ADC calibration value with both single ended
  1935. * and differential modes calibration factors concatenated.
  1936. * @note To be used with function @ref LL_ADC_SetCalibrationFactor().
  1937. * Example, to set calibration factors single ended to 0x55
  1938. * and differential ended to 0x2A:
  1939. * LL_ADC_SetCalibrationFactor(
  1940. * ADC1,
  1941. * __LL_ADC_CALIB_FACTOR_SINGLE_DIFF(0x55, 0x2A))
  1942. * @param __CALIB_FACTOR_SINGLE_ENDED__ Value between Min_Data=0x00 and Max_Data=0x7F
  1943. * @param __CALIB_FACTOR_DIFFERENTIAL__ Value between Min_Data=0x00 and Max_Data=0x7F
  1944. * @retval Value between Min_Data=0x00000000 and Max_Data=0xFFFFFFFF
  1945. */
  1946. #define __LL_ADC_CALIB_FACTOR_SINGLE_DIFF(__CALIB_FACTOR_SINGLE_ENDED__, __CALIB_FACTOR_DIFFERENTIAL__) \
  1947. (((__CALIB_FACTOR_DIFFERENTIAL__) << POSITION_VAL(ADC_CALFACT_CALFACT_D)) | (__CALIB_FACTOR_SINGLE_ENDED__))
  1948. #if defined(ADC_MULTIMODE_SUPPORT)
  1949. /**
  1950. * @brief Helper macro to get the ADC multimode conversion data of ADC master
  1951. * or ADC slave from raw value with both ADC conversion data concatenated.
  1952. * @note This macro is intended to be used when multimode transfer by DMA
  1953. * is enabled: refer to function @ref LL_ADC_SetMultiDMATransfer().
  1954. * In this case the transferred data need to processed with this macro
  1955. * to separate the conversion data of ADC master and ADC slave.
  1956. * @param __ADC_MULTI_MASTER_SLAVE__ This parameter can be one of the following values:
  1957. * @arg @ref LL_ADC_MULTI_MASTER
  1958. * @arg @ref LL_ADC_MULTI_SLAVE
  1959. * @param __ADC_MULTI_CONV_DATA__ Value between Min_Data=0x000 and Max_Data=0xFFF
  1960. * @retval Value between Min_Data=0x000 and Max_Data=0xFFF
  1961. */
  1962. #define __LL_ADC_MULTI_CONV_DATA_MASTER_SLAVE(__ADC_MULTI_MASTER_SLAVE__, __ADC_MULTI_CONV_DATA__) \
  1963. (((__ADC_MULTI_CONV_DATA__) >> POSITION_VAL((__ADC_MULTI_MASTER_SLAVE__))) & ADC_CDR_RDATA_MST)
  1964. #endif
  1965. /**
  1966. * @brief Helper macro to select the ADC common instance
  1967. * to which is belonging the selected ADC instance.
  1968. * @note ADC common register instance can be used for:
  1969. * - Set parameters common to several ADC instances
  1970. * - Multimode (for devices with several ADC instances)
  1971. * Refer to functions having argument "ADCxy_COMMON" as parameter.
  1972. * @param __ADCx__ ADC instance
  1973. * @retval ADC common register instance
  1974. */
  1975. #if defined(ADC3) && defined(ADC4)
  1976. #define __LL_ADC_COMMON_INSTANCE(__ADCx__) \
  1977. ((((__ADCx__) == ADC1) || ((__ADCx__) == ADC2)) \
  1978. ? ( \
  1979. (ADC12_COMMON) \
  1980. ) \
  1981. : \
  1982. ( \
  1983. (ADC34_COMMON) \
  1984. ) \
  1985. )
  1986. #elif defined(ADC1) && defined(ADC2)
  1987. #define __LL_ADC_COMMON_INSTANCE(__ADCx__) \
  1988. (ADC12_COMMON)
  1989. #else
  1990. #define __LL_ADC_COMMON_INSTANCE(__ADCx__) \
  1991. (ADC1_COMMON)
  1992. #endif
  1993. /**
  1994. * @brief Helper macro to check if all ADC instances sharing the same
  1995. * ADC common instance are disabled.
  1996. * @note This check is required by functions with setting conditioned to
  1997. * ADC state:
  1998. * All ADC instances of the ADC common group must be disabled.
  1999. * Refer to functions having argument "ADCxy_COMMON" as parameter.
  2000. * @note On devices with only 1 ADC common instance, parameter of this macro
  2001. * is useless and can be ignored (parameter kept for compatibility
  2002. * with devices featuring several ADC common instances).
  2003. * @param __ADCXY_COMMON__ ADC common instance
  2004. * (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() )
  2005. * @retval Value "0" if all ADC instances sharing the same ADC common instance
  2006. * are disabled.
  2007. * Value "1" if at least one ADC instance sharing the same ADC common instance
  2008. * is enabled.
  2009. */
  2010. #if defined(ADC3) && defined(ADC4)
  2011. #define __LL_ADC_IS_ENABLED_ALL_COMMON_INSTANCE(__ADCXY_COMMON__) \
  2012. (((__ADCXY_COMMON__) == ADC12_COMMON) \
  2013. ? ( \
  2014. (LL_ADC_IsEnabled(ADC1) | \
  2015. LL_ADC_IsEnabled(ADC2) ) \
  2016. ) \
  2017. : \
  2018. ( \
  2019. (LL_ADC_IsEnabled(ADC3) | \
  2020. LL_ADC_IsEnabled(ADC4) ) \
  2021. ) \
  2022. )
  2023. #elif defined(ADC1) && defined(ADC2)
  2024. #define __LL_ADC_IS_ENABLED_ALL_COMMON_INSTANCE(__ADCXY_COMMON__) \
  2025. (LL_ADC_IsEnabled(ADC1) | \
  2026. LL_ADC_IsEnabled(ADC2) )
  2027. #else
  2028. #define __LL_ADC_IS_ENABLED_ALL_COMMON_INSTANCE(__ADCXY_COMMON__) \
  2029. LL_ADC_IsEnabled(ADC1)
  2030. #endif
  2031. /**
  2032. * @brief Helper macro to define the ADC conversion data full-scale digital
  2033. * value corresponding to the selected ADC resolution.
  2034. * @note ADC conversion data full-scale corresponds to voltage range
  2035. * determined by analog voltage references Vref+ and Vref-
  2036. * (refer to reference manual).
  2037. * @param __ADC_RESOLUTION__ This parameter can be one of the following values:
  2038. * @arg @ref LL_ADC_RESOLUTION_12B
  2039. * @arg @ref LL_ADC_RESOLUTION_10B
  2040. * @arg @ref LL_ADC_RESOLUTION_8B
  2041. * @arg @ref LL_ADC_RESOLUTION_6B
  2042. * @retval ADC conversion data equivalent voltage value (unit: mVolt)
  2043. */
  2044. #define __LL_ADC_DIGITAL_SCALE(__ADC_RESOLUTION__) \
  2045. (((uint32_t)0xFFFU) >> ((__ADC_RESOLUTION__) >> (ADC_CFGR_RES_BITOFFSET_POS - 1U)))
  2046. /**
  2047. * @brief Helper macro to convert the ADC conversion data from
  2048. * a resolution to another resolution.
  2049. * @param __DATA__ ADC conversion data to be converted
  2050. * @param __ADC_RESOLUTION_CURRENT__ Resolution of to the data to be converted
  2051. * This parameter can be one of the following values:
  2052. * @arg @ref LL_ADC_RESOLUTION_12B
  2053. * @arg @ref LL_ADC_RESOLUTION_10B
  2054. * @arg @ref LL_ADC_RESOLUTION_8B
  2055. * @arg @ref LL_ADC_RESOLUTION_6B
  2056. * @param __ADC_RESOLUTION_TARGET__ Resolution of the data after conversion
  2057. * This parameter can be one of the following values:
  2058. * @arg @ref LL_ADC_RESOLUTION_12B
  2059. * @arg @ref LL_ADC_RESOLUTION_10B
  2060. * @arg @ref LL_ADC_RESOLUTION_8B
  2061. * @arg @ref LL_ADC_RESOLUTION_6B
  2062. * @retval ADC conversion data to the requested resolution
  2063. */
  2064. #define __LL_ADC_CONVERT_DATA_RESOLUTION(__DATA__,\
  2065. __ADC_RESOLUTION_CURRENT__,\
  2066. __ADC_RESOLUTION_TARGET__) \
  2067. (((__DATA__) \
  2068. << ((__ADC_RESOLUTION_CURRENT__) >> (ADC_CFGR_RES_BITOFFSET_POS - 1U))) \
  2069. >> ((__ADC_RESOLUTION_TARGET__) >> (ADC_CFGR_RES_BITOFFSET_POS - 1U)) \
  2070. )
  2071. /**
  2072. * @brief Helper macro to calculate the voltage (unit: mVolt)
  2073. * corresponding to a ADC conversion data (unit: digital value).
  2074. * @note Analog reference voltage (Vref+) must be either known from
  2075. * user board environment or can be calculated using ADC measurement
  2076. * and ADC helper macro @ref __LL_ADC_CALC_VREFANALOG_VOLTAGE().
  2077. * @param __VREFANALOG_VOLTAGE__ Analog reference voltage (unit: mV)
  2078. * @param __ADC_DATA__ ADC conversion data (resolution 12 bits)
  2079. * (unit: digital value).
  2080. * @param __ADC_RESOLUTION__ This parameter can be one of the following values:
  2081. * @arg @ref LL_ADC_RESOLUTION_12B
  2082. * @arg @ref LL_ADC_RESOLUTION_10B
  2083. * @arg @ref LL_ADC_RESOLUTION_8B
  2084. * @arg @ref LL_ADC_RESOLUTION_6B
  2085. * @retval ADC conversion data equivalent voltage value (unit: mVolt)
  2086. */
  2087. #define __LL_ADC_CALC_DATA_TO_VOLTAGE(__VREFANALOG_VOLTAGE__,\
  2088. __ADC_DATA__,\
  2089. __ADC_RESOLUTION__) \
  2090. ((__ADC_DATA__) * (__VREFANALOG_VOLTAGE__) \
  2091. / __LL_ADC_DIGITAL_SCALE(__ADC_RESOLUTION__) \
  2092. )
  2093. /**
  2094. * @brief Helper macro to calculate analog reference voltage (Vref+)
  2095. * (unit: mVolt) from ADC conversion data of internal voltage
  2096. * reference VrefInt.
  2097. * @note Computation is using VrefInt calibration value
  2098. * stored in system memory for each device during production.
  2099. * @note This voltage depends on user board environment: voltage level
  2100. * connected to pin Vref+.
  2101. * On devices with small package, the pin Vref+ is not present
  2102. * and internally bonded to pin Vdda.
  2103. * @note On this STM32 series, calibration data of internal voltage reference
  2104. * VrefInt corresponds to a resolution of 12 bits,
  2105. * this is the recommended ADC resolution to convert voltage of
  2106. * internal voltage reference VrefInt.
  2107. * Otherwise, this macro performs the processing to scale
  2108. * ADC conversion data to 12 bits.
  2109. * @param __VREFINT_ADC_DATA__ ADC conversion data (resolution 12 bits)
  2110. * of internal voltage reference VrefInt (unit: digital value).
  2111. * @param __ADC_RESOLUTION__ This parameter can be one of the following values:
  2112. * @arg @ref LL_ADC_RESOLUTION_12B
  2113. * @arg @ref LL_ADC_RESOLUTION_10B
  2114. * @arg @ref LL_ADC_RESOLUTION_8B
  2115. * @arg @ref LL_ADC_RESOLUTION_6B
  2116. * @retval Analog reference voltage (unit: mV)
  2117. */
  2118. #define __LL_ADC_CALC_VREFANALOG_VOLTAGE(__VREFINT_ADC_DATA__,\
  2119. __ADC_RESOLUTION__) \
  2120. (((uint32_t)(*VREFINT_CAL_ADDR) * VREFINT_CAL_VREF) \
  2121. / __LL_ADC_CONVERT_DATA_RESOLUTION((__VREFINT_ADC_DATA__), \
  2122. (__ADC_RESOLUTION__), \
  2123. LL_ADC_RESOLUTION_12B) \
  2124. )
  2125. /**
  2126. * @brief Helper macro to calculate the temperature (unit: degree Celsius)
  2127. * from ADC conversion data of internal temperature sensor.
  2128. * @note Computation is using temperature sensor calibration values
  2129. * stored in system memory for each device during production.
  2130. * @note Calculation formula:
  2131. * Temperature = ((TS_ADC_DATA - TS_CAL1)
  2132. * * (TS_CAL2_TEMP - TS_CAL1_TEMP))
  2133. * / (TS_CAL2 - TS_CAL1) + TS_CAL1_TEMP
  2134. * with TS_ADC_DATA = temperature sensor raw data measured by ADC
  2135. * Avg_Slope = (TS_CAL2 - TS_CAL1)
  2136. * / (TS_CAL2_TEMP - TS_CAL1_TEMP)
  2137. * TS_CAL1 = equivalent TS_ADC_DATA at temperature
  2138. * TEMP_DEGC_CAL1 (calibrated in factory)
  2139. * TS_CAL2 = equivalent TS_ADC_DATA at temperature
  2140. * TEMP_DEGC_CAL2 (calibrated in factory)
  2141. * Caution: Calculation relevancy under reserve that calibration
  2142. * parameters are correct (address and data).
  2143. * To calculate temperature using temperature sensor
  2144. * datasheet typical values (generic values less, therefore
  2145. * less accurate than calibrated values),
  2146. * use helper macro @ref __LL_ADC_CALC_TEMPERATURE_TYP_PARAMS().
  2147. * @note As calculation input, the analog reference voltage (Vref+) must be
  2148. * defined as it impacts the ADC LSB equivalent voltage.
  2149. * @note Analog reference voltage (Vref+) must be either known from
  2150. * user board environment or can be calculated using ADC measurement
  2151. * and ADC helper macro @ref __LL_ADC_CALC_VREFANALOG_VOLTAGE().
  2152. * @note On this STM32 series, calibration data of temperature sensor
  2153. * corresponds to a resolution of 12 bits,
  2154. * this is the recommended ADC resolution to convert voltage of
  2155. * temperature sensor.
  2156. * Otherwise, this macro performs the processing to scale
  2157. * ADC conversion data to 12 bits.
  2158. * @param __VREFANALOG_VOLTAGE__ Analog reference voltage (unit: mV)
  2159. * @param __TEMPSENSOR_ADC_DATA__ ADC conversion data of internal
  2160. * temperature sensor (unit: digital value).
  2161. * @param __ADC_RESOLUTION__ ADC resolution at which internal temperature
  2162. * sensor voltage has been measured.
  2163. * This parameter can be one of the following values:
  2164. * @arg @ref LL_ADC_RESOLUTION_12B
  2165. * @arg @ref LL_ADC_RESOLUTION_10B
  2166. * @arg @ref LL_ADC_RESOLUTION_8B
  2167. * @arg @ref LL_ADC_RESOLUTION_6B
  2168. * @retval Temperature (unit: degree Celsius)
  2169. */
  2170. #define __LL_ADC_CALC_TEMPERATURE(__VREFANALOG_VOLTAGE__,\
  2171. __TEMPSENSOR_ADC_DATA__,\
  2172. __ADC_RESOLUTION__) \
  2173. (((( ((int32_t)((__LL_ADC_CONVERT_DATA_RESOLUTION((__TEMPSENSOR_ADC_DATA__), \
  2174. (__ADC_RESOLUTION__), \
  2175. LL_ADC_RESOLUTION_12B) \
  2176. * (__VREFANALOG_VOLTAGE__)) \
  2177. / TEMPSENSOR_CAL_VREFANALOG) \
  2178. - (int32_t) *TEMPSENSOR_CAL1_ADDR) \
  2179. ) * (int32_t)(TEMPSENSOR_CAL2_TEMP - TEMPSENSOR_CAL1_TEMP) \
  2180. ) / (int32_t)((int32_t)*TEMPSENSOR_CAL2_ADDR - (int32_t)*TEMPSENSOR_CAL1_ADDR) \
  2181. ) + TEMPSENSOR_CAL1_TEMP \
  2182. )
  2183. /**
  2184. * @brief Helper macro to calculate the temperature (unit: degree Celsius)
  2185. * from ADC conversion data of internal temperature sensor.
  2186. * @note Computation is using temperature sensor typical values
  2187. * (refer to device datasheet).
  2188. * @note Calculation formula:
  2189. * Temperature = (TS_TYP_CALx_VOLT(uV) - TS_ADC_DATA * Conversion_uV)
  2190. * / Avg_Slope + CALx_TEMP
  2191. * with TS_ADC_DATA = temperature sensor raw data measured by ADC
  2192. * (unit: digital value)
  2193. * Avg_Slope = temperature sensor slope
  2194. * (unit: uV/Degree Celsius)
  2195. * TS_TYP_CALx_VOLT = temperature sensor digital value at
  2196. * temperature CALx_TEMP (unit: mV)
  2197. * Caution: Calculation relevancy under reserve the temperature sensor
  2198. * of the current device has characteristics in line with
  2199. * datasheet typical values.
  2200. * If temperature sensor calibration values are available on
  2201. * on this device (presence of macro __LL_ADC_CALC_TEMPERATURE()),
  2202. * temperature calculation will be more accurate using
  2203. * helper macro @ref __LL_ADC_CALC_TEMPERATURE().
  2204. * @note As calculation input, the analog reference voltage (Vref+) must be
  2205. * defined as it impacts the ADC LSB equivalent voltage.
  2206. * @note Analog reference voltage (Vref+) must be either known from
  2207. * user board environment or can be calculated using ADC measurement
  2208. * and ADC helper macro @ref __LL_ADC_CALC_VREFANALOG_VOLTAGE().
  2209. * @note ADC measurement data must correspond to a resolution of 12bits
  2210. * (full scale digital value 4095). If not the case, the data must be
  2211. * preliminarily rescaled to an equivalent resolution of 12 bits.
  2212. * @param __TEMPSENSOR_TYP_AVGSLOPE__ Device datasheet data: Temperature sensor slope typical value (unit: uV/DegCelsius).
  2213. * On STM32F3, refer to device datasheet parameter "Avg_Slope".
  2214. * @param __TEMPSENSOR_TYP_CALX_V__ Device datasheet data: Temperature sensor voltage typical value (at temperature and Vref+ defined in parameters below) (unit: mV).
  2215. * On STM32F3, refer to device datasheet parameter "V25" (corresponding to TS_CAL1).
  2216. * @param __TEMPSENSOR_CALX_TEMP__ Device datasheet data: Temperature at which temperature sensor voltage (see parameter above) is corresponding (unit: DegC)
  2217. * @param __VREFANALOG_VOLTAGE__ Analog voltage reference (Vref+) voltage (unit: mV)
  2218. * @param __TEMPSENSOR_ADC_DATA__ ADC conversion data of internal temperature sensor (unit: digital value).
  2219. * @param __ADC_RESOLUTION__ ADC resolution at which internal temperature sensor voltage has been measured.
  2220. * This parameter can be one of the following values:
  2221. * @arg @ref LL_ADC_RESOLUTION_12B
  2222. * @arg @ref LL_ADC_RESOLUTION_10B
  2223. * @arg @ref LL_ADC_RESOLUTION_8B
  2224. * @arg @ref LL_ADC_RESOLUTION_6B
  2225. * @retval Temperature (unit: degree Celsius)
  2226. */
  2227. #define __LL_ADC_CALC_TEMPERATURE_TYP_PARAMS(__TEMPSENSOR_TYP_AVGSLOPE__,\
  2228. __TEMPSENSOR_TYP_CALX_V__,\
  2229. __TEMPSENSOR_CALX_TEMP__,\
  2230. __VREFANALOG_VOLTAGE__,\
  2231. __TEMPSENSOR_ADC_DATA__,\
  2232. __ADC_RESOLUTION__) \
  2233. ((( ( \
  2234. (int32_t)(((__TEMPSENSOR_TYP_CALX_V__)) \
  2235. * 1000) \
  2236. - \
  2237. (int32_t)((((__TEMPSENSOR_ADC_DATA__) * (__VREFANALOG_VOLTAGE__)) \
  2238. / __LL_ADC_DIGITAL_SCALE(__ADC_RESOLUTION__)) \
  2239. * 1000) \
  2240. ) \
  2241. ) / (__TEMPSENSOR_TYP_AVGSLOPE__) \
  2242. ) + (__TEMPSENSOR_CALX_TEMP__) \
  2243. )
  2244. /**
  2245. * @}
  2246. */
  2247. /**
  2248. * @}
  2249. */
  2250. /* Exported functions --------------------------------------------------------*/
  2251. /** @defgroup ADC_LL_Exported_Functions ADC Exported Functions
  2252. * @{
  2253. */
  2254. /** @defgroup ADC_LL_EF_DMA_Management ADC DMA management
  2255. * @{
  2256. */
  2257. /* Note: LL ADC functions to set DMA transfer are located into sections of */
  2258. /* configuration of ADC instance, groups and multimode (if available): */
  2259. /* @ref LL_ADC_REG_SetDMATransfer(), ... */
  2260. /**
  2261. * @brief Function to help to configure DMA transfer from ADC: retrieve the
  2262. * ADC register address from ADC instance and a list of ADC registers
  2263. * intended to be used (most commonly) with DMA transfer.
  2264. * @note These ADC registers are data registers:
  2265. * when ADC conversion data is available in ADC data registers,
  2266. * ADC generates a DMA transfer request.
  2267. * @note This macro is intended to be used with LL DMA driver, refer to
  2268. * function "LL_DMA_ConfigAddresses()".
  2269. * Example:
  2270. * LL_DMA_ConfigAddresses(DMA1,
  2271. * LL_DMA_CHANNEL_1,
  2272. * LL_ADC_DMA_GetRegAddr(ADC1, LL_ADC_DMA_REG_REGULAR_DATA),
  2273. * (uint32_t)&< array or variable >,
  2274. * LL_DMA_DIRECTION_PERIPH_TO_MEMORY);
  2275. * @note For devices with several ADC: in multimode, some devices
  2276. * use a different data register outside of ADC instance scope
  2277. * (common data register). This macro manages this register difference,
  2278. * only ADC instance has to be set as parameter.
  2279. * @rmtoll DR RDATA LL_ADC_DMA_GetRegAddr\n
  2280. * CDR RDATA_MST LL_ADC_DMA_GetRegAddr\n
  2281. * CDR RDATA_SLV LL_ADC_DMA_GetRegAddr
  2282. * @param ADCx ADC instance
  2283. * @param Register This parameter can be one of the following values:
  2284. * @arg @ref LL_ADC_DMA_REG_REGULAR_DATA
  2285. * @arg @ref LL_ADC_DMA_REG_REGULAR_DATA_MULTI (1)
  2286. *
  2287. * (1) Available on devices with several ADC instances.
  2288. * @retval ADC register address
  2289. */
  2290. #if defined(ADC_MULTIMODE_SUPPORT)
  2291. __STATIC_INLINE uint32_t LL_ADC_DMA_GetRegAddr(ADC_TypeDef *ADCx, uint32_t Register)
  2292. {
  2293. uint32_t data_reg_addr = 0U;
  2294. if (Register == LL_ADC_DMA_REG_REGULAR_DATA)
  2295. {
  2296. /* Retrieve address of register DR */
  2297. data_reg_addr = (uint32_t)&(ADCx->DR);
  2298. }
  2299. else /* (Register == LL_ADC_DMA_REG_REGULAR_DATA_MULTI) */
  2300. {
  2301. /* Retrieve address of register CDR */
  2302. data_reg_addr = (uint32_t)&((__LL_ADC_COMMON_INSTANCE(ADCx))->CDR);
  2303. }
  2304. return data_reg_addr;
  2305. }
  2306. #else
  2307. __STATIC_INLINE uint32_t LL_ADC_DMA_GetRegAddr(ADC_TypeDef *ADCx, uint32_t Register)
  2308. {
  2309. /* Prevent unused argument compilation warning */
  2310. (void)Register;
  2311. /* Retrieve address of register DR */
  2312. return (uint32_t)&(ADCx->DR);
  2313. }
  2314. #endif
  2315. /**
  2316. * @}
  2317. */
  2318. /** @defgroup ADC_LL_EF_Configuration_ADC_Common Configuration of ADC hierarchical scope: common to several ADC instances
  2319. * @{
  2320. */
  2321. /**
  2322. * @brief Set parameter common to several ADC: Clock source and prescaler.
  2323. * @note On this STM32 series, if ADC group injected is used, some
  2324. * clock ratio constraints between ADC clock and AHB clock
  2325. * must be respected.
  2326. * Refer to reference manual.
  2327. * @note On this STM32 series, setting of this feature is conditioned to
  2328. * ADC state:
  2329. * All ADC instances of the ADC common group must be disabled.
  2330. * This check can be done with function @ref LL_ADC_IsEnabled() for each
  2331. * ADC instance or by using helper macro helper macro
  2332. * @ref __LL_ADC_IS_ENABLED_ALL_COMMON_INSTANCE().
  2333. * @rmtoll CCR CKMODE LL_ADC_SetCommonClock\n
  2334. * CCR PRESC LL_ADC_SetCommonClock
  2335. * @param ADCxy_COMMON ADC common instance
  2336. * (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() )
  2337. * @param CommonClock This parameter can be one of the following values:
  2338. * @arg @ref LL_ADC_CLOCK_SYNC_PCLK_DIV1
  2339. * @arg @ref LL_ADC_CLOCK_SYNC_PCLK_DIV2
  2340. * @arg @ref LL_ADC_CLOCK_SYNC_PCLK_DIV4
  2341. * @arg @ref LL_ADC_CLOCK_ASYNC_DIV1
  2342. * @retval None
  2343. */
  2344. __STATIC_INLINE void LL_ADC_SetCommonClock(ADC_Common_TypeDef *ADCxy_COMMON, uint32_t CommonClock)
  2345. {
  2346. MODIFY_REG(ADCxy_COMMON->CCR, ADC_CCR_CKMODE, CommonClock);
  2347. }
  2348. /**
  2349. * @brief Get parameter common to several ADC: Clock source and prescaler.
  2350. * @rmtoll CCR CKMODE LL_ADC_GetCommonClock\n
  2351. * CCR PRESC LL_ADC_GetCommonClock
  2352. * @param ADCxy_COMMON ADC common instance
  2353. * (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() )
  2354. * @retval Returned value can be one of the following values:
  2355. * @arg @ref LL_ADC_CLOCK_SYNC_PCLK_DIV1
  2356. * @arg @ref LL_ADC_CLOCK_SYNC_PCLK_DIV2
  2357. * @arg @ref LL_ADC_CLOCK_SYNC_PCLK_DIV4
  2358. * @arg @ref LL_ADC_CLOCK_ASYNC_DIV1
  2359. */
  2360. __STATIC_INLINE uint32_t LL_ADC_GetCommonClock(ADC_Common_TypeDef *ADCxy_COMMON)
  2361. {
  2362. return (uint32_t)(READ_BIT(ADCxy_COMMON->CCR, ADC_CCR_CKMODE));
  2363. }
  2364. /**
  2365. * @brief Set parameter common to several ADC: measurement path to internal
  2366. * channels (VrefInt, temperature sensor, ...).
  2367. * @note One or several values can be selected.
  2368. * Example: (LL_ADC_PATH_INTERNAL_VREFINT |
  2369. * LL_ADC_PATH_INTERNAL_TEMPSENSOR)
  2370. * @note Stabilization time of measurement path to internal channel:
  2371. * After enabling internal paths, before starting ADC conversion,
  2372. * a delay is required for internal voltage reference and
  2373. * temperature sensor stabilization time.
  2374. * Refer to device datasheet.
  2375. * Refer to literal @ref LL_ADC_DELAY_VREFINT_STAB_US.
  2376. * Refer to literal @ref LL_ADC_DELAY_TEMPSENSOR_STAB_US.
  2377. * @note ADC internal channel sampling time constraint:
  2378. * For ADC conversion of internal channels,
  2379. * a sampling time minimum value is required.
  2380. * Refer to device datasheet.
  2381. * @note On this STM32 series, setting of this feature is conditioned to
  2382. * ADC state:
  2383. * All ADC instances of the ADC common group must be disabled.
  2384. * This check can be done with function @ref LL_ADC_IsEnabled() for each
  2385. * ADC instance or by using helper macro helper macro
  2386. * @ref __LL_ADC_IS_ENABLED_ALL_COMMON_INSTANCE().
  2387. * @rmtoll CCR VREFEN LL_ADC_SetCommonPathInternalCh\n
  2388. * CCR TSEN LL_ADC_SetCommonPathInternalCh\n
  2389. * CCR VBATEN LL_ADC_SetCommonPathInternalCh
  2390. * @param ADCxy_COMMON ADC common instance
  2391. * (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() )
  2392. * @param PathInternal This parameter can be a combination of the following values:
  2393. * @arg @ref LL_ADC_PATH_INTERNAL_NONE
  2394. * @arg @ref LL_ADC_PATH_INTERNAL_VREFINT
  2395. * @arg @ref LL_ADC_PATH_INTERNAL_TEMPSENSOR
  2396. * @arg @ref LL_ADC_PATH_INTERNAL_VBAT
  2397. * @retval None
  2398. */
  2399. __STATIC_INLINE void LL_ADC_SetCommonPathInternalCh(ADC_Common_TypeDef *ADCxy_COMMON, uint32_t PathInternal)
  2400. {
  2401. MODIFY_REG(ADCxy_COMMON->CCR, ADC_CCR_VREFEN | ADC_CCR_TSEN | ADC_CCR_VBATEN, PathInternal);
  2402. }
  2403. /**
  2404. * @brief Get parameter common to several ADC: measurement path to internal
  2405. * channels (VrefInt, temperature sensor, ...).
  2406. * @note One or several values can be selected.
  2407. * Example: (LL_ADC_PATH_INTERNAL_VREFINT |
  2408. * LL_ADC_PATH_INTERNAL_TEMPSENSOR)
  2409. * @rmtoll CCR VREFEN LL_ADC_GetCommonPathInternalCh\n
  2410. * CCR TSEN LL_ADC_GetCommonPathInternalCh\n
  2411. * CCR VBATEN LL_ADC_GetCommonPathInternalCh
  2412. * @param ADCxy_COMMON ADC common instance
  2413. * (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() )
  2414. * @retval Returned value can be a combination of the following values:
  2415. * @arg @ref LL_ADC_PATH_INTERNAL_NONE
  2416. * @arg @ref LL_ADC_PATH_INTERNAL_VREFINT
  2417. * @arg @ref LL_ADC_PATH_INTERNAL_TEMPSENSOR
  2418. * @arg @ref LL_ADC_PATH_INTERNAL_VBAT
  2419. */
  2420. __STATIC_INLINE uint32_t LL_ADC_GetCommonPathInternalCh(ADC_Common_TypeDef *ADCxy_COMMON)
  2421. {
  2422. return (uint32_t)(READ_BIT(ADCxy_COMMON->CCR, ADC_CCR_VREFEN | ADC_CCR_TSEN | ADC_CCR_VBATEN));
  2423. }
  2424. /**
  2425. * @}
  2426. */
  2427. /** @defgroup ADC_LL_EF_Configuration_ADC_Instance Configuration of ADC hierarchical scope: ADC instance
  2428. * @{
  2429. */
  2430. /**
  2431. * @brief Set ADC calibration factor in the mode single-ended
  2432. * or differential (for devices with differential mode available).
  2433. * @note This function is intended to set calibration parameters
  2434. * without having to perform a new calibration using
  2435. * @ref LL_ADC_StartCalibration().
  2436. * @note For devices with differential mode available:
  2437. * Calibration of offset is specific to each of
  2438. * single-ended and differential modes
  2439. * (calibration factor must be specified for each of these
  2440. * differential modes, if used afterwards and if the application
  2441. * requires their calibration).
  2442. * @note In case of setting calibration factors of both modes single ended
  2443. * and differential (parameter LL_ADC_BOTH_SINGLE_DIFF_ENDED):
  2444. * both calibration factors must be concatenated.
  2445. * To perform this processing, use helper macro
  2446. * @ref __LL_ADC_CALIB_FACTOR_SINGLE_DIFF().
  2447. * @note On this STM32 series, setting of this feature is conditioned to
  2448. * ADC state:
  2449. * ADC must be enabled, without calibration on going, without conversion
  2450. * on going on group regular.
  2451. * @rmtoll CALFACT CALFACT_S LL_ADC_SetCalibrationFactor\n
  2452. * CALFACT CALFACT_D LL_ADC_SetCalibrationFactor
  2453. * @param ADCx ADC instance
  2454. * @param SingleDiff This parameter can be one of the following values:
  2455. * @arg @ref LL_ADC_SINGLE_ENDED
  2456. * @arg @ref LL_ADC_DIFFERENTIAL_ENDED
  2457. * @arg @ref LL_ADC_BOTH_SINGLE_DIFF_ENDED
  2458. * @param CalibrationFactor Value between Min_Data=0x00 and Max_Data=0x7F
  2459. * @retval None
  2460. */
  2461. __STATIC_INLINE void LL_ADC_SetCalibrationFactor(ADC_TypeDef *ADCx, uint32_t SingleDiff, uint32_t CalibrationFactor)
  2462. {
  2463. MODIFY_REG(ADCx->CALFACT,
  2464. SingleDiff & ADC_SINGLEDIFF_CALIB_FACTOR_MASK,
  2465. CalibrationFactor << POSITION_VAL(SingleDiff & ADC_SINGLEDIFF_CALIB_FACTOR_MASK));
  2466. }
  2467. /**
  2468. * @brief Get ADC calibration factor in the mode single-ended
  2469. * or differential (for devices with differential mode available).
  2470. * @note Calibration factors are set by hardware after performing
  2471. * a calibration run using function @ref LL_ADC_StartCalibration().
  2472. * @note For devices with differential mode available:
  2473. * Calibration of offset is specific to each of
  2474. * single-ended and differential modes
  2475. * @rmtoll CALFACT CALFACT_S LL_ADC_GetCalibrationFactor\n
  2476. * CALFACT CALFACT_D LL_ADC_GetCalibrationFactor
  2477. * @param ADCx ADC instance
  2478. * @param SingleDiff This parameter can be one of the following values:
  2479. * @arg @ref LL_ADC_SINGLE_ENDED
  2480. * @arg @ref LL_ADC_DIFFERENTIAL_ENDED
  2481. * @retval Value between Min_Data=0x00 and Max_Data=0x7F
  2482. */
  2483. __STATIC_INLINE uint32_t LL_ADC_GetCalibrationFactor(ADC_TypeDef *ADCx, uint32_t SingleDiff)
  2484. {
  2485. /* Retrieve bits with position in register depending on parameter */
  2486. /* "SingleDiff". */
  2487. /* Parameter used with mask "ADC_SINGLEDIFF_CALIB_FACTOR_MASK" because */
  2488. /* containing other bits reserved for other purpose. */
  2489. return (uint32_t)(READ_BIT(ADCx->CALFACT, (SingleDiff & ADC_SINGLEDIFF_CALIB_FACTOR_MASK)) >> POSITION_VAL(SingleDiff & ADC_SINGLEDIFF_CALIB_FACTOR_MASK));
  2490. }
  2491. /**
  2492. * @brief Set ADC resolution.
  2493. * Refer to reference manual for alignments formats
  2494. * dependencies to ADC resolutions.
  2495. * @note On this STM32 series, setting of this feature is conditioned to
  2496. * ADC state:
  2497. * ADC must be disabled or enabled without conversion on going
  2498. * on either groups regular or injected.
  2499. * @rmtoll CFGR RES LL_ADC_SetResolution
  2500. * @param ADCx ADC instance
  2501. * @param Resolution This parameter can be one of the following values:
  2502. * @arg @ref LL_ADC_RESOLUTION_12B
  2503. * @arg @ref LL_ADC_RESOLUTION_10B
  2504. * @arg @ref LL_ADC_RESOLUTION_8B
  2505. * @arg @ref LL_ADC_RESOLUTION_6B
  2506. * @retval None
  2507. */
  2508. __STATIC_INLINE void LL_ADC_SetResolution(ADC_TypeDef *ADCx, uint32_t Resolution)
  2509. {
  2510. MODIFY_REG(ADCx->CFGR, ADC_CFGR_RES, Resolution);
  2511. }
  2512. /**
  2513. * @brief Get ADC resolution.
  2514. * Refer to reference manual for alignments formats
  2515. * dependencies to ADC resolutions.
  2516. * @rmtoll CFGR RES LL_ADC_GetResolution
  2517. * @param ADCx ADC instance
  2518. * @retval Returned value can be one of the following values:
  2519. * @arg @ref LL_ADC_RESOLUTION_12B
  2520. * @arg @ref LL_ADC_RESOLUTION_10B
  2521. * @arg @ref LL_ADC_RESOLUTION_8B
  2522. * @arg @ref LL_ADC_RESOLUTION_6B
  2523. */
  2524. __STATIC_INLINE uint32_t LL_ADC_GetResolution(ADC_TypeDef *ADCx)
  2525. {
  2526. return (uint32_t)(READ_BIT(ADCx->CFGR, ADC_CFGR_RES));
  2527. }
  2528. /**
  2529. * @brief Set ADC conversion data alignment.
  2530. * @note Refer to reference manual for alignments formats
  2531. * dependencies to ADC resolutions.
  2532. * @note On this STM32 series, setting of this feature is conditioned to
  2533. * ADC state:
  2534. * ADC must be disabled or enabled without conversion on going
  2535. * on either groups regular or injected.
  2536. * @rmtoll CFGR ALIGN LL_ADC_SetDataAlignment
  2537. * @param ADCx ADC instance
  2538. * @param DataAlignment This parameter can be one of the following values:
  2539. * @arg @ref LL_ADC_DATA_ALIGN_RIGHT
  2540. * @arg @ref LL_ADC_DATA_ALIGN_LEFT
  2541. * @retval None
  2542. */
  2543. __STATIC_INLINE void LL_ADC_SetDataAlignment(ADC_TypeDef *ADCx, uint32_t DataAlignment)
  2544. {
  2545. MODIFY_REG(ADCx->CFGR, ADC_CFGR_ALIGN, DataAlignment);
  2546. }
  2547. /**
  2548. * @brief Get ADC conversion data alignment.
  2549. * @note Refer to reference manual for alignments formats
  2550. * dependencies to ADC resolutions.
  2551. * @rmtoll CFGR ALIGN LL_ADC_GetDataAlignment
  2552. * @param ADCx ADC instance
  2553. * @retval Returned value can be one of the following values:
  2554. * @arg @ref LL_ADC_DATA_ALIGN_RIGHT
  2555. * @arg @ref LL_ADC_DATA_ALIGN_LEFT
  2556. */
  2557. __STATIC_INLINE uint32_t LL_ADC_GetDataAlignment(ADC_TypeDef *ADCx)
  2558. {
  2559. return (uint32_t)(READ_BIT(ADCx->CFGR, ADC_CFGR_ALIGN));
  2560. }
  2561. /**
  2562. * @brief Set ADC low power mode.
  2563. * @note Description of ADC low power modes:
  2564. * - ADC low power mode "auto wait": Dynamic low power mode,
  2565. * ADC conversions occurrences are limited to the minimum necessary
  2566. * in order to reduce power consumption.
  2567. * New ADC conversion starts only when the previous
  2568. * unitary conversion data (for ADC group regular)
  2569. * or previous sequence conversions data (for ADC group injected)
  2570. * has been retrieved by user software.
  2571. * In the meantime, ADC remains idle: does not performs any
  2572. * other conversion.
  2573. * This mode allows to automatically adapt the ADC conversions
  2574. * triggers to the speed of the software that reads the data.
  2575. * Moreover, this avoids risk of overrun for low frequency
  2576. * applications.
  2577. * How to use this low power mode:
  2578. * - It is not recommended to use with interruption or DMA
  2579. * since these modes have to clear immediately the EOC flag
  2580. * (by CPU to free the IRQ pending event or by DMA).
  2581. * Auto wait will work but fort a very short time, discarding
  2582. * its intended benefit (except specific case of high load of CPU
  2583. * or DMA transfers which can justify usage of auto wait).
  2584. * - Do use with polling: 1. Start conversion,
  2585. * 2. Later on, when conversion data is needed: poll for end of
  2586. * conversion to ensure that conversion is completed and
  2587. * retrieve ADC conversion data. This will trig another
  2588. * ADC conversion start.
  2589. * - ADC low power mode "auto power-off" (feature available on
  2590. * this device if parameter LL_ADC_LP_MODE_AUTOOFF is available):
  2591. * the ADC automatically powers-off after a conversion and
  2592. * automatically wakes up when a new conversion is triggered
  2593. * (with startup time between trigger and start of sampling).
  2594. * This feature can be combined with low power mode "auto wait".
  2595. * @note With ADC low power mode "auto wait", the ADC conversion data read
  2596. * is corresponding to previous ADC conversion start, independently
  2597. * of delay during which ADC was idle.
  2598. * Therefore, the ADC conversion data may be outdated: does not
  2599. * correspond to the current voltage level on the selected
  2600. * ADC channel.
  2601. * @note On this STM32 series, setting of this feature is conditioned to
  2602. * ADC state:
  2603. * ADC must be disabled or enabled without conversion on going
  2604. * on either groups regular or injected.
  2605. * @rmtoll CFGR AUTDLY LL_ADC_SetLowPowerMode
  2606. * @param ADCx ADC instance
  2607. * @param LowPowerMode This parameter can be one of the following values:
  2608. * @arg @ref LL_ADC_LP_MODE_NONE
  2609. * @arg @ref LL_ADC_LP_AUTOWAIT
  2610. * @retval None
  2611. */
  2612. __STATIC_INLINE void LL_ADC_SetLowPowerMode(ADC_TypeDef *ADCx, uint32_t LowPowerMode)
  2613. {
  2614. MODIFY_REG(ADCx->CFGR, ADC_CFGR_AUTDLY, LowPowerMode);
  2615. }
  2616. /**
  2617. * @brief Get ADC low power mode:
  2618. * @note Description of ADC low power modes:
  2619. * - ADC low power mode "auto wait": Dynamic low power mode,
  2620. * ADC conversions occurrences are limited to the minimum necessary
  2621. * in order to reduce power consumption.
  2622. * New ADC conversion starts only when the previous
  2623. * unitary conversion data (for ADC group regular)
  2624. * or previous sequence conversions data (for ADC group injected)
  2625. * has been retrieved by user software.
  2626. * In the meantime, ADC remains idle: does not performs any
  2627. * other conversion.
  2628. * This mode allows to automatically adapt the ADC conversions
  2629. * triggers to the speed of the software that reads the data.
  2630. * Moreover, this avoids risk of overrun for low frequency
  2631. * applications.
  2632. * How to use this low power mode:
  2633. * - It is not recommended to use with interruption or DMA
  2634. * since these modes have to clear immediately the EOC flag
  2635. * (by CPU to free the IRQ pending event or by DMA).
  2636. * Auto wait will work but fort a very short time, discarding
  2637. * its intended benefit (except specific case of high load of CPU
  2638. * or DMA transfers which can justify usage of auto wait).
  2639. * - Do use with polling: 1. Start conversion,
  2640. * 2. Later on, when conversion data is needed: poll for end of
  2641. * conversion to ensure that conversion is completed and
  2642. * retrieve ADC conversion data. This will trig another
  2643. * ADC conversion start.
  2644. * - ADC low power mode "auto power-off" (feature available on
  2645. * this device if parameter LL_ADC_LP_MODE_AUTOOFF is available):
  2646. * the ADC automatically powers-off after a conversion and
  2647. * automatically wakes up when a new conversion is triggered
  2648. * (with startup time between trigger and start of sampling).
  2649. * This feature can be combined with low power mode "auto wait".
  2650. * @note With ADC low power mode "auto wait", the ADC conversion data read
  2651. * is corresponding to previous ADC conversion start, independently
  2652. * of delay during which ADC was idle.
  2653. * Therefore, the ADC conversion data may be outdated: does not
  2654. * correspond to the current voltage level on the selected
  2655. * ADC channel.
  2656. * @rmtoll CFGR AUTDLY LL_ADC_GetLowPowerMode
  2657. * @param ADCx ADC instance
  2658. * @retval Returned value can be one of the following values:
  2659. * @arg @ref LL_ADC_LP_MODE_NONE
  2660. * @arg @ref LL_ADC_LP_AUTOWAIT
  2661. */
  2662. __STATIC_INLINE uint32_t LL_ADC_GetLowPowerMode(ADC_TypeDef *ADCx)
  2663. {
  2664. return (uint32_t)(READ_BIT(ADCx->CFGR, ADC_CFGR_AUTDLY));
  2665. }
  2666. /**
  2667. * @brief Set ADC selected offset number 1, 2, 3 or 4.
  2668. * @note This function set the 2 items of offset configuration:
  2669. * - ADC channel to which the offset programmed will be applied
  2670. * (independently of channel mapped on ADC group regular
  2671. * or group injected)
  2672. * - Offset level (offset to be subtracted from the raw
  2673. * converted data).
  2674. * @note Caution: Offset format is dependent to ADC resolution:
  2675. * offset has to be left-aligned on bit 11, the LSB (right bits)
  2676. * are set to 0.
  2677. * @note This function enables the offset, by default. It can be forced
  2678. * to disable state using function LL_ADC_SetOffsetState().
  2679. * @note If a channel is mapped on several offsets numbers, only the offset
  2680. * with the lowest value is considered for the subtraction.
  2681. * @note On this STM32 series, setting of this feature is conditioned to
  2682. * ADC state:
  2683. * ADC must be disabled or enabled without conversion on going
  2684. * on either groups regular or injected.
  2685. * @rmtoll OFR1 OFFSET1_CH LL_ADC_SetOffset\n
  2686. * OFR1 OFFSET1 LL_ADC_SetOffset\n
  2687. * OFR1 OFFSET1_EN LL_ADC_SetOffset\n
  2688. * OFR2 OFFSET2_CH LL_ADC_SetOffset\n
  2689. * OFR2 OFFSET2 LL_ADC_SetOffset\n
  2690. * OFR2 OFFSET2_EN LL_ADC_SetOffset\n
  2691. * OFR3 OFFSET3_CH LL_ADC_SetOffset\n
  2692. * OFR3 OFFSET3 LL_ADC_SetOffset\n
  2693. * OFR3 OFFSET3_EN LL_ADC_SetOffset\n
  2694. * OFR4 OFFSET4_CH LL_ADC_SetOffset\n
  2695. * OFR4 OFFSET4 LL_ADC_SetOffset\n
  2696. * OFR4 OFFSET4_EN LL_ADC_SetOffset
  2697. * @param ADCx ADC instance
  2698. * @param Offsety This parameter can be one of the following values:
  2699. * @arg @ref LL_ADC_OFFSET_1
  2700. * @arg @ref LL_ADC_OFFSET_2
  2701. * @arg @ref LL_ADC_OFFSET_3
  2702. * @arg @ref LL_ADC_OFFSET_4
  2703. * @param Channel This parameter can be one of the following values:
  2704. * @arg @ref LL_ADC_CHANNEL_0
  2705. * @arg @ref LL_ADC_CHANNEL_1
  2706. * @arg @ref LL_ADC_CHANNEL_2
  2707. * @arg @ref LL_ADC_CHANNEL_3
  2708. * @arg @ref LL_ADC_CHANNEL_4
  2709. * @arg @ref LL_ADC_CHANNEL_5
  2710. * @arg @ref LL_ADC_CHANNEL_6
  2711. * @arg @ref LL_ADC_CHANNEL_7
  2712. * @arg @ref LL_ADC_CHANNEL_8
  2713. * @arg @ref LL_ADC_CHANNEL_9
  2714. * @arg @ref LL_ADC_CHANNEL_10
  2715. * @arg @ref LL_ADC_CHANNEL_11
  2716. * @arg @ref LL_ADC_CHANNEL_12
  2717. * @arg @ref LL_ADC_CHANNEL_13
  2718. * @arg @ref LL_ADC_CHANNEL_14
  2719. * @arg @ref LL_ADC_CHANNEL_15
  2720. * @arg @ref LL_ADC_CHANNEL_16
  2721. * @arg @ref LL_ADC_CHANNEL_17
  2722. * @arg @ref LL_ADC_CHANNEL_18
  2723. * @arg @ref LL_ADC_CHANNEL_VREFINT (5)
  2724. * @arg @ref LL_ADC_CHANNEL_TEMPSENSOR (1)
  2725. * @arg @ref LL_ADC_CHANNEL_VBAT (1)
  2726. * @arg @ref LL_ADC_CHANNEL_VOPAMP1 (1)
  2727. * @arg @ref LL_ADC_CHANNEL_VOPAMP2 (2)
  2728. * @arg @ref LL_ADC_CHANNEL_VOPAMP3 (3)
  2729. * @arg @ref LL_ADC_CHANNEL_VOPAMP4 (4)
  2730. *
  2731. * (1) On STM32F3, parameter available only on ADC instance: ADC1.\n
  2732. * (2) On STM32F3, parameter available only on ADC instance: ADC2.\n
  2733. * (3) On STM32F3, parameter available only on ADC instance: ADC3.\n
  2734. * (4) On STM32F3, parameter available only on ADC instances: ADC4.\n
  2735. * (5) On STM32F3, ADC channel available only on all ADC instances, but
  2736. * only one ADC instance is allowed to be connected to VrefInt at the same time.
  2737. * @param OffsetLevel Value between Min_Data=0x000 and Max_Data=0xFFF
  2738. * @retval None
  2739. */
  2740. __STATIC_INLINE void LL_ADC_SetOffset(ADC_TypeDef *ADCx, uint32_t Offsety, uint32_t Channel, uint32_t OffsetLevel)
  2741. {
  2742. __IO uint32_t *preg = __ADC_PTR_REG_OFFSET(ADCx->OFR1, Offsety);
  2743. MODIFY_REG(*preg,
  2744. ADC_OFR1_OFFSET1_EN | ADC_OFR1_OFFSET1_CH | ADC_OFR1_OFFSET1,
  2745. ADC_OFR1_OFFSET1_EN | (Channel & ADC_CHANNEL_ID_NUMBER_MASK) | OffsetLevel);
  2746. }
  2747. /**
  2748. * @brief Get for the ADC selected offset number 1, 2, 3 or 4:
  2749. * Channel to which the offset programmed will be applied
  2750. * (independently of channel mapped on ADC group regular
  2751. * or group injected)
  2752. * @note Usage of the returned channel number:
  2753. * - To reinject this channel into another function LL_ADC_xxx:
  2754. * the returned channel number is only partly formatted on definition
  2755. * of literals LL_ADC_CHANNEL_x. Therefore, it has to be compared
  2756. * with parts of literals LL_ADC_CHANNEL_x or using
  2757. * helper macro @ref __LL_ADC_CHANNEL_TO_DECIMAL_NB().
  2758. * Then the selected literal LL_ADC_CHANNEL_x can be used
  2759. * as parameter for another function.
  2760. * - To get the channel number in decimal format:
  2761. * process the returned value with the helper macro
  2762. * @ref __LL_ADC_CHANNEL_TO_DECIMAL_NB().
  2763. * @rmtoll OFR1 OFFSET1_CH LL_ADC_GetOffsetChannel\n
  2764. * OFR2 OFFSET2_CH LL_ADC_GetOffsetChannel\n
  2765. * OFR3 OFFSET3_CH LL_ADC_GetOffsetChannel\n
  2766. * OFR4 OFFSET4_CH LL_ADC_GetOffsetChannel
  2767. * @param ADCx ADC instance
  2768. * @param Offsety This parameter can be one of the following values:
  2769. * @arg @ref LL_ADC_OFFSET_1
  2770. * @arg @ref LL_ADC_OFFSET_2
  2771. * @arg @ref LL_ADC_OFFSET_3
  2772. * @arg @ref LL_ADC_OFFSET_4
  2773. * @retval Returned value can be one of the following values:
  2774. * @arg @ref LL_ADC_CHANNEL_0
  2775. * @arg @ref LL_ADC_CHANNEL_1
  2776. * @arg @ref LL_ADC_CHANNEL_2
  2777. * @arg @ref LL_ADC_CHANNEL_3
  2778. * @arg @ref LL_ADC_CHANNEL_4
  2779. * @arg @ref LL_ADC_CHANNEL_5
  2780. * @arg @ref LL_ADC_CHANNEL_6
  2781. * @arg @ref LL_ADC_CHANNEL_7
  2782. * @arg @ref LL_ADC_CHANNEL_8
  2783. * @arg @ref LL_ADC_CHANNEL_9
  2784. * @arg @ref LL_ADC_CHANNEL_10
  2785. * @arg @ref LL_ADC_CHANNEL_11
  2786. * @arg @ref LL_ADC_CHANNEL_12
  2787. * @arg @ref LL_ADC_CHANNEL_13
  2788. * @arg @ref LL_ADC_CHANNEL_14
  2789. * @arg @ref LL_ADC_CHANNEL_15
  2790. * @arg @ref LL_ADC_CHANNEL_16
  2791. * @arg @ref LL_ADC_CHANNEL_17
  2792. * @arg @ref LL_ADC_CHANNEL_18
  2793. * @arg @ref LL_ADC_CHANNEL_VREFINT (5)
  2794. * @arg @ref LL_ADC_CHANNEL_TEMPSENSOR (1)
  2795. * @arg @ref LL_ADC_CHANNEL_VBAT (1)
  2796. * @arg @ref LL_ADC_CHANNEL_VOPAMP1 (1)
  2797. * @arg @ref LL_ADC_CHANNEL_VOPAMP2 (2)
  2798. * @arg @ref LL_ADC_CHANNEL_VOPAMP3 (3)
  2799. * @arg @ref LL_ADC_CHANNEL_VOPAMP4 (4)
  2800. *
  2801. * (1) On STM32F3, parameter available only on ADC instance: ADC1.\n
  2802. * (2) On STM32F3, parameter available only on ADC instance: ADC2.\n
  2803. * (3) On STM32F3, parameter available only on ADC instance: ADC3.\n
  2804. * (4) On STM32F3, parameter available only on ADC instances: ADC4.\n
  2805. * (5) On STM32F3, ADC channel available only on all ADC instances, but
  2806. * only one ADC instance is allowed to be connected to VrefInt at the same time.\n
  2807. * (1, 2, 3, 4, 5) For ADC channel read back from ADC register,
  2808. * comparison with internal channel parameter to be done
  2809. * using helper macro @ref __LL_ADC_CHANNEL_INTERNAL_TO_EXTERNAL().
  2810. */
  2811. __STATIC_INLINE uint32_t LL_ADC_GetOffsetChannel(ADC_TypeDef *ADCx, uint32_t Offsety)
  2812. {
  2813. __IO uint32_t *preg = __ADC_PTR_REG_OFFSET(ADCx->OFR1, Offsety);
  2814. return (uint32_t) READ_BIT(*preg, ADC_OFR1_OFFSET1_CH);
  2815. }
  2816. /**
  2817. * @brief Get for the ADC selected offset number 1, 2, 3 or 4:
  2818. * Offset level (offset to be subtracted from the raw
  2819. * converted data).
  2820. * @note Caution: Offset format is dependent to ADC resolution:
  2821. * offset has to be left-aligned on bit 11, the LSB (right bits)
  2822. * are set to 0.
  2823. * @rmtoll OFR1 OFFSET1 LL_ADC_GetOffsetLevel\n
  2824. * OFR2 OFFSET2 LL_ADC_GetOffsetLevel\n
  2825. * OFR3 OFFSET3 LL_ADC_GetOffsetLevel\n
  2826. * OFR4 OFFSET4 LL_ADC_GetOffsetLevel
  2827. * @param ADCx ADC instance
  2828. * @param Offsety This parameter can be one of the following values:
  2829. * @arg @ref LL_ADC_OFFSET_1
  2830. * @arg @ref LL_ADC_OFFSET_2
  2831. * @arg @ref LL_ADC_OFFSET_3
  2832. * @arg @ref LL_ADC_OFFSET_4
  2833. * @retval Value between Min_Data=0x000 and Max_Data=0xFFF
  2834. */
  2835. __STATIC_INLINE uint32_t LL_ADC_GetOffsetLevel(ADC_TypeDef *ADCx, uint32_t Offsety)
  2836. {
  2837. __IO uint32_t *preg = __ADC_PTR_REG_OFFSET(ADCx->OFR1, Offsety);
  2838. return (uint32_t) READ_BIT(*preg, ADC_OFR1_OFFSET1);
  2839. }
  2840. /**
  2841. * @brief Set for the ADC selected offset number 1, 2, 3 or 4:
  2842. * force offset state disable or enable
  2843. * without modifying offset channel or offset value.
  2844. * @note This function should be needed only in case of offset to be
  2845. * enabled-disabled dynamically, and should not be needed in other cases:
  2846. * function LL_ADC_SetOffset() automatically enables the offset.
  2847. * @note On this STM32 series, setting of this feature is conditioned to
  2848. * ADC state:
  2849. * ADC must be disabled or enabled without conversion on going
  2850. * on either groups regular or injected.
  2851. * @rmtoll OFR1 OFFSET1_EN LL_ADC_SetOffsetState\n
  2852. * OFR2 OFFSET2_EN LL_ADC_SetOffsetState\n
  2853. * OFR3 OFFSET3_EN LL_ADC_SetOffsetState\n
  2854. * OFR4 OFFSET4_EN LL_ADC_SetOffsetState
  2855. * @param ADCx ADC instance
  2856. * @param Offsety This parameter can be one of the following values:
  2857. * @arg @ref LL_ADC_OFFSET_1
  2858. * @arg @ref LL_ADC_OFFSET_2
  2859. * @arg @ref LL_ADC_OFFSET_3
  2860. * @arg @ref LL_ADC_OFFSET_4
  2861. * @param OffsetState This parameter can be one of the following values:
  2862. * @arg @ref LL_ADC_OFFSET_DISABLE
  2863. * @arg @ref LL_ADC_OFFSET_ENABLE
  2864. * @retval None
  2865. */
  2866. __STATIC_INLINE void LL_ADC_SetOffsetState(ADC_TypeDef *ADCx, uint32_t Offsety, uint32_t OffsetState)
  2867. {
  2868. __IO uint32_t *preg = (__IO uint32_t *)((uint32_t)
  2869. ((uint32_t)(&ADCx->OFR1) + (Offsety*4U)));
  2870. MODIFY_REG(*preg,
  2871. ADC_OFR1_OFFSET1_EN,
  2872. OffsetState);
  2873. }
  2874. /**
  2875. * @brief Get for the ADC selected offset number 1, 2, 3 or 4:
  2876. * offset state disabled or enabled.
  2877. * @rmtoll OFR1 OFFSET1_EN LL_ADC_GetOffsetState\n
  2878. * OFR2 OFFSET2_EN LL_ADC_GetOffsetState\n
  2879. * OFR3 OFFSET3_EN LL_ADC_GetOffsetState\n
  2880. * OFR4 OFFSET4_EN LL_ADC_GetOffsetState
  2881. * @param ADCx ADC instance
  2882. * @param Offsety This parameter can be one of the following values:
  2883. * @arg @ref LL_ADC_OFFSET_1
  2884. * @arg @ref LL_ADC_OFFSET_2
  2885. * @arg @ref LL_ADC_OFFSET_3
  2886. * @arg @ref LL_ADC_OFFSET_4
  2887. * @retval Returned value can be one of the following values:
  2888. * @arg @ref LL_ADC_OFFSET_DISABLE
  2889. * @arg @ref LL_ADC_OFFSET_ENABLE
  2890. */
  2891. __STATIC_INLINE uint32_t LL_ADC_GetOffsetState(ADC_TypeDef *ADCx, uint32_t Offsety)
  2892. {
  2893. __IO uint32_t *preg = __ADC_PTR_REG_OFFSET(ADCx->OFR1, Offsety);
  2894. return (uint32_t) READ_BIT(*preg, ADC_OFR1_OFFSET1_EN);
  2895. }
  2896. /**
  2897. * @}
  2898. */
  2899. /** @defgroup ADC_LL_EF_Configuration_ADC_Group_Regular Configuration of ADC hierarchical scope: group regular
  2900. * @{
  2901. */
  2902. /**
  2903. * @brief Set ADC group regular conversion trigger source:
  2904. * internal (SW start) or from external IP (timer event,
  2905. * external interrupt line).
  2906. * @note On this STM32 series, setting trigger source to external trigger
  2907. * also set trigger polarity to rising edge
  2908. * (default setting for compatibility with some ADC on other
  2909. * STM32 families having this setting set by HW default value).
  2910. * In case of need to modify trigger edge, use
  2911. * function @ref LL_ADC_REG_SetTriggerEdge().
  2912. * @note Availability of parameters of trigger sources from timer
  2913. * depends on timers availability on the selected device.
  2914. * @note On this STM32 series, setting of this feature is conditioned to
  2915. * ADC state:
  2916. * ADC must be disabled or enabled without conversion on going
  2917. * on group regular.
  2918. * @rmtoll CFGR EXTSEL LL_ADC_REG_SetTriggerSource\n
  2919. * CFGR EXTEN LL_ADC_REG_SetTriggerSource
  2920. * @param ADCx ADC instance
  2921. * @param TriggerSource This parameter can be one of the following values:
  2922. * @arg @ref LL_ADC_REG_TRIG_SOFTWARE
  2923. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM1_TRGO
  2924. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM1_TRGO2
  2925. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM1_CH1 (3)(4)(5)(6)
  2926. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM1_CH1_ADC12 (1)(2) (7)
  2927. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM1_CH2 (3)(4)(5)(6)
  2928. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM1_CH2_ADC12 (1)(2) (7)
  2929. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM1_CH3
  2930. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM2_TRGO (3)(4)(5)(6)
  2931. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM2_TRGO_ADC12 (1)(2) (7)
  2932. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM2_TRGO__ADC34 (1)(2) (8)
  2933. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM2_CH1_ADC34 (1)(2) (8)
  2934. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM2_CH2_ADC12 (1)(2) (7)
  2935. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM2_CH3_ADC34 (1)(2) (8)
  2936. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM3_TRGO (3)(4)(5)
  2937. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM3_TRGO_ADC12 (1)(2) (7)
  2938. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM3_TRGO__ADC34 (1)(2) (8)
  2939. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM3_CH1_ADC34 (1)(2) (8)
  2940. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM3_CH4 (3)(4)(5)
  2941. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM3_CH4_ADC12 (1)(2) (7)
  2942. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM4_TRGO (1)(2)(3)(5)
  2943. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM4_CH1_ADC34 (1)(2) (8)
  2944. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM4_CH4 (3) (5)
  2945. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM4_CH4_ADC12 (1)(2) (7)
  2946. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM6_TRGO (3)(4)(5)(6)
  2947. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM6_TRGO_ADC12 (1)(2) (7)
  2948. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM8_TRGO (3)
  2949. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM8_TRGO_ADC12 (1)(2) (7)
  2950. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM8_TRGO2 (1)(2)
  2951. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM6_TRGO_ADC12 (1)(2) (7)
  2952. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM7_TRGO_ADC34 (1)(2) (8)
  2953. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM8_TRGO__ADC34 (1)(2) (8)
  2954. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM8_TRGO2 (1)(2)
  2955. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM8_CH1_ADC34 (1)(2) (8)
  2956. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM15_TRGO (5)
  2957. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM20_TRG0_ADC12 (1) (7)
  2958. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM20_TRG02_ADC12 (1) (7)
  2959. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM20_CH1_ADC12 (1) (7)
  2960. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM20_CH2_ADC12 (1) (7)
  2961. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM20_CH3_ADC12 (1) (7)
  2962. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM20_TRG0_ADC3 (1) (8)
  2963. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM20_TRG02_ADC34 (1) (8)
  2964. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM20_CH1_ADC34 (1) (8)
  2965. * @arg @ref LL_ADC_REG_TRIG_EXT_HRTIM_TRG1 (4)
  2966. * @arg @ref LL_ADC_REG_TRIG_EXT_HRTIM_TRG3 (4)
  2967. * @arg @ref LL_ADC_REG_TRIG_EXT_EXTI_LINE2_ADC34 (1)(2) (8)
  2968. * @arg @ref LL_ADC_REG_TRIG_EXT_EXTI_LINE11 (3)(4)(5)(6)
  2969. * @arg @ref LL_ADC_REG_TRIG_EXT_EXTI_LINE11_ADC12 (1)(2) (7)
  2970. * (1) On STM32F3, parameter not available on all devices: among others, on STM32F303xE, STM32F398xx.\n
  2971. * (2) On STM32F3, parameter not available on all devices: among others, on STM32F303xC, STM32F358xx.\n
  2972. * (3) On STM32F3, parameter not available on all devices: among others, on STM32F303x8, STM32F328xx.\n
  2973. * (4) On STM32F3, parameter not available on all devices: among others, on STM32F334x8.\n
  2974. * (5) On STM32F3, parameter not available on all devices: among others, on STM32F302xC, STM32F302xE.\n
  2975. * (6) On STM32F3, parameter not available on all devices: among others, on STM32F301x8, STM32F302x8, STM32F318xx.\n
  2976. * (7) On STM32F3, parameter not available on all ADC instances: ADC1, ADC2 (for ADC instances ADCx available on the selected device).\n
  2977. * (8) On STM32F3, parameter not available on all ADC instances: ADC3, ADC4 (for ADC instances ADCx available on the selected device).
  2978. * @retval None
  2979. */
  2980. __STATIC_INLINE void LL_ADC_REG_SetTriggerSource(ADC_TypeDef *ADCx, uint32_t TriggerSource)
  2981. {
  2982. MODIFY_REG(ADCx->CFGR, ADC_CFGR_EXTEN | ADC_CFGR_EXTSEL, TriggerSource);
  2983. }
  2984. /**
  2985. * @brief Get ADC group regular conversion trigger source:
  2986. * internal (SW start) or from external IP (timer event,
  2987. * external interrupt line).
  2988. * @note To determine whether group regular trigger source is
  2989. * internal (SW start) or external, without detail
  2990. * of which peripheral is selected as external trigger,
  2991. * (equivalent to
  2992. * "if(LL_ADC_REG_GetTriggerSource(ADC1) == LL_ADC_REG_TRIG_SOFTWARE)")
  2993. * use function @ref LL_ADC_REG_IsTriggerSourceSWStart.
  2994. * @note Availability of parameters of trigger sources from timer
  2995. * depends on timers availability on the selected device.
  2996. * @rmtoll CFGR EXTSEL LL_ADC_REG_GetTriggerSource\n
  2997. * CFGR EXTEN LL_ADC_REG_GetTriggerSource
  2998. * @param ADCx ADC instance
  2999. * @retval Returned value can be one of the following values:
  3000. * @arg @ref LL_ADC_REG_TRIG_SOFTWARE
  3001. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM1_TRGO
  3002. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM1_TRGO2
  3003. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM1_CH1 (3)(4)(5)(6)
  3004. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM1_CH1_ADC12 (1)(2) (7)
  3005. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM1_CH2 (3)(4)(5)(6)
  3006. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM1_CH2_ADC12 (1)(2) (7)
  3007. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM1_CH3
  3008. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM2_TRGO (3)(4)(5)(6)
  3009. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM2_TRGO_ADC12 (1)(2) (7)
  3010. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM2_TRGO__ADC34 (1)(2) (8)
  3011. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM2_CH1_ADC34 (1)(2) (8)
  3012. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM2_CH2_ADC12 (1)(2) (7)
  3013. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM2_CH3_ADC34 (1)(2) (8)
  3014. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM3_TRGO (3)(4)(5)
  3015. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM3_TRGO_ADC12 (1)(2) (7)
  3016. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM3_TRGO__ADC34 (1)(2) (8)
  3017. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM3_CH1_ADC34 (1)(2) (8)
  3018. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM3_CH4 (3)(4)(5)
  3019. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM3_CH4_ADC12 (1)(2) (7)
  3020. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM4_TRGO (1)(2)(3)(5)
  3021. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM4_CH1_ADC34 (1)(2) (8)
  3022. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM4_CH4 (3) (5)
  3023. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM4_CH4_ADC12 (1)(2) (7)
  3024. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM6_TRGO (3)(4)(5)(6)
  3025. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM6_TRGO_ADC12 (1)(2) (7)
  3026. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM8_TRGO (3)
  3027. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM8_TRGO_ADC12 (1)(2) (7)
  3028. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM8_TRGO2 (1)(2)
  3029. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM6_TRGO_ADC12 (1)(2) (7)
  3030. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM7_TRGO_ADC34 (1)(2) (8)
  3031. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM8_TRGO__ADC34 (1)(2) (8)
  3032. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM8_TRGO2 (1)(2)
  3033. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM8_CH1_ADC34 (1)(2) (8)
  3034. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM15_TRGO (5)
  3035. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM20_TRG0_ADC12 (1) (7)
  3036. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM20_TRG02_ADC12 (1) (7)
  3037. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM20_CH1_ADC12 (1) (7)
  3038. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM20_CH2_ADC12 (1) (7)
  3039. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM20_CH3_ADC12 (1) (7)
  3040. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM20_TRG0_ADC3 (1) (8)
  3041. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM20_TRG02_ADC34 (1) (8)
  3042. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM20_CH1_ADC34 (1) (8)
  3043. * @arg @ref LL_ADC_REG_TRIG_EXT_HRTIM_TRG1 (4)
  3044. * @arg @ref LL_ADC_REG_TRIG_EXT_HRTIM_TRG3 (4)
  3045. * @arg @ref LL_ADC_REG_TRIG_EXT_EXTI_LINE2_ADC34 (1)(2) (8)
  3046. * @arg @ref LL_ADC_REG_TRIG_EXT_EXTI_LINE11 (3)(4)(5)(6)
  3047. * @arg @ref LL_ADC_REG_TRIG_EXT_EXTI_LINE11_ADC12 (1)(2) (7)
  3048. * (1) On STM32F3, parameter not available on all devices: among others, on STM32F303xE, STM32F398xx.\n
  3049. * (2) On STM32F3, parameter not available on all devices: among others, on STM32F303xC, STM32F358xx.\n
  3050. * (3) On STM32F3, parameter not available on all devices: among others, on STM32F303x8, STM32F328xx.\n
  3051. * (4) On STM32F3, parameter not available on all devices: among others, on STM32F334x8.\n
  3052. * (5) On STM32F3, parameter not available on all devices: among others, on STM32F302xC, STM32F302xE.\n
  3053. * (6) On STM32F3, parameter not available on all devices: among others, on STM32F301x8, STM32F302x8, STM32F318xx.\n
  3054. * (7) On STM32F3, parameter not available on all ADC instances: ADC1, ADC2 (for ADC instances ADCx available on the selected device).\n
  3055. * (8) On STM32F3, parameter not available on all ADC instances: ADC3, ADC4 (for ADC instances ADCx available on the selected device).
  3056. */
  3057. __STATIC_INLINE uint32_t LL_ADC_REG_GetTriggerSource(ADC_TypeDef *ADCx)
  3058. {
  3059. uint32_t TriggerSource = READ_BIT(ADCx->CFGR, ADC_CFGR_EXTSEL | ADC_CFGR_EXTEN);
  3060. /* Value for shift of {0; 4; 8; 12} depending on value of bitfield */
  3061. /* corresponding to ADC_CFGR_EXTEN {0; 1; 2; 3}. */
  3062. uint32_t ShiftExten = ((TriggerSource & ADC_CFGR_EXTEN) >> (ADC_REG_TRIG_EXTEN_BITOFFSET_POS - 2U));
  3063. /* Set bitfield corresponding to ADC_CFGR_EXTEN and ADC_CFGR_EXTSEL */
  3064. /* to match with triggers literals definition. */
  3065. return ((TriggerSource
  3066. & (ADC_REG_TRIG_SOURCE_MASK >> ShiftExten) & ADC_CFGR_EXTSEL)
  3067. | ((ADC_REG_TRIG_EDGE_MASK >> ShiftExten) & ADC_CFGR_EXTEN)
  3068. );
  3069. }
  3070. /**
  3071. * @brief Get ADC group regular conversion trigger source internal (SW start)
  3072. or external.
  3073. * @note In case of group regular trigger source set to external trigger,
  3074. * to determine which peripheral is selected as external trigger,
  3075. * use function @ref LL_ADC_REG_GetTriggerSource().
  3076. * @rmtoll CFGR EXTEN LL_ADC_REG_IsTriggerSourceSWStart
  3077. * @param ADCx ADC instance
  3078. * @retval Value "0" if trigger source external trigger
  3079. * Value "1" if trigger source SW start.
  3080. */
  3081. __STATIC_INLINE uint32_t LL_ADC_REG_IsTriggerSourceSWStart(ADC_TypeDef *ADCx)
  3082. {
  3083. return (READ_BIT(ADCx->CFGR, ADC_CFGR_EXTEN) == (LL_ADC_REG_TRIG_SOFTWARE & ADC_CFGR_EXTEN));
  3084. }
  3085. /**
  3086. * @brief Set ADC group regular conversion trigger polarity.
  3087. * @note Applicable only for trigger source set to external trigger.
  3088. * @note On this STM32 series, setting of this feature is conditioned to
  3089. * ADC state:
  3090. * ADC must be disabled or enabled without conversion on going
  3091. * on group regular.
  3092. * @rmtoll CFGR EXTEN LL_ADC_REG_SetTriggerEdge
  3093. * @param ADCx ADC instance
  3094. * @param ExternalTriggerEdge This parameter can be one of the following values:
  3095. * @arg @ref LL_ADC_REG_TRIG_EXT_RISING
  3096. * @arg @ref LL_ADC_REG_TRIG_EXT_FALLING
  3097. * @arg @ref LL_ADC_REG_TRIG_EXT_RISINGFALLING
  3098. * @retval None
  3099. */
  3100. __STATIC_INLINE void LL_ADC_REG_SetTriggerEdge(ADC_TypeDef *ADCx, uint32_t ExternalTriggerEdge)
  3101. {
  3102. MODIFY_REG(ADCx->CFGR, ADC_CFGR_EXTEN, ExternalTriggerEdge);
  3103. }
  3104. /**
  3105. * @brief Get ADC group regular conversion trigger polarity.
  3106. * @note Applicable only for trigger source set to external trigger.
  3107. * @rmtoll CFGR EXTEN LL_ADC_REG_GetTriggerEdge
  3108. * @param ADCx ADC instance
  3109. * @retval Returned value can be one of the following values:
  3110. * @arg @ref LL_ADC_REG_TRIG_EXT_RISING
  3111. * @arg @ref LL_ADC_REG_TRIG_EXT_FALLING
  3112. * @arg @ref LL_ADC_REG_TRIG_EXT_RISINGFALLING
  3113. */
  3114. __STATIC_INLINE uint32_t LL_ADC_REG_GetTriggerEdge(ADC_TypeDef *ADCx)
  3115. {
  3116. return (uint32_t)(READ_BIT(ADCx->CFGR, ADC_CFGR_EXTEN));
  3117. }
  3118. /**
  3119. * @brief Set ADC group regular sequencer length and scan direction.
  3120. * @note Description of ADC group regular sequencer features:
  3121. * - For devices with sequencer fully configurable
  3122. * (function "LL_ADC_REG_SetSequencerRanks()" available):
  3123. * sequencer length and each rank affectation to a channel
  3124. * are configurable.
  3125. * This function performs configuration of:
  3126. * - Sequence length: Number of ranks in the scan sequence.
  3127. * - Sequence direction: Unless specified in parameters, sequencer
  3128. * scan direction is forward (from rank 1 to rank n).
  3129. * Sequencer ranks are selected using
  3130. * function "LL_ADC_REG_SetSequencerRanks()".
  3131. * - For devices with sequencer not fully configurable
  3132. * (function "LL_ADC_REG_SetSequencerChannels()" available):
  3133. * sequencer length and each rank affectation to a channel
  3134. * are defined by channel number.
  3135. * This function performs configuration of:
  3136. * - Sequence length: Number of ranks in the scan sequence is
  3137. * defined by number of channels set in the sequence,
  3138. * rank of each channel is fixed by channel HW number.
  3139. * (channel 0 fixed on rank 0, channel 1 fixed on rank1, ...).
  3140. * - Sequence direction: Unless specified in parameters, sequencer
  3141. * scan direction is forward (from lowest channel number to
  3142. * highest channel number).
  3143. * Sequencer ranks are selected using
  3144. * function "LL_ADC_REG_SetSequencerChannels()".
  3145. * @note Sequencer disabled is equivalent to sequencer of 1 rank:
  3146. * ADC conversion on only 1 channel.
  3147. * @note On this STM32 series, setting of this feature is conditioned to
  3148. * ADC state:
  3149. * ADC must be disabled or enabled without conversion on going
  3150. * on group regular.
  3151. * @rmtoll SQR1 L LL_ADC_REG_SetSequencerLength
  3152. * @param ADCx ADC instance
  3153. * @param SequencerNbRanks This parameter can be one of the following values:
  3154. * @arg @ref LL_ADC_REG_SEQ_SCAN_DISABLE
  3155. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_2RANKS
  3156. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_3RANKS
  3157. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_4RANKS
  3158. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_5RANKS
  3159. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_6RANKS
  3160. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_7RANKS
  3161. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_8RANKS
  3162. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_9RANKS
  3163. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_10RANKS
  3164. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_11RANKS
  3165. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_12RANKS
  3166. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_13RANKS
  3167. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_14RANKS
  3168. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_15RANKS
  3169. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_16RANKS
  3170. * @retval None
  3171. */
  3172. __STATIC_INLINE void LL_ADC_REG_SetSequencerLength(ADC_TypeDef *ADCx, uint32_t SequencerNbRanks)
  3173. {
  3174. MODIFY_REG(ADCx->SQR1, ADC_SQR1_L, SequencerNbRanks);
  3175. }
  3176. /**
  3177. * @brief Get ADC group regular sequencer length and scan direction.
  3178. * @note Description of ADC group regular sequencer features:
  3179. * - For devices with sequencer fully configurable
  3180. * (function "LL_ADC_REG_SetSequencerRanks()" available):
  3181. * sequencer length and each rank affectation to a channel
  3182. * are configurable.
  3183. * This function retrieves:
  3184. * - Sequence length: Number of ranks in the scan sequence.
  3185. * - Sequence direction: Unless specified in parameters, sequencer
  3186. * scan direction is forward (from rank 1 to rank n).
  3187. * Sequencer ranks are selected using
  3188. * function "LL_ADC_REG_SetSequencerRanks()".
  3189. * - For devices with sequencer not fully configurable
  3190. * (function "LL_ADC_REG_SetSequencerChannels()" available):
  3191. * sequencer length and each rank affectation to a channel
  3192. * are defined by channel number.
  3193. * This function retrieves:
  3194. * - Sequence length: Number of ranks in the scan sequence is
  3195. * defined by number of channels set in the sequence,
  3196. * rank of each channel is fixed by channel HW number.
  3197. * (channel 0 fixed on rank 0, channel 1 fixed on rank1, ...).
  3198. * - Sequence direction: Unless specified in parameters, sequencer
  3199. * scan direction is forward (from lowest channel number to
  3200. * highest channel number).
  3201. * Sequencer ranks are selected using
  3202. * function "LL_ADC_REG_SetSequencerChannels()".
  3203. * @note Sequencer disabled is equivalent to sequencer of 1 rank:
  3204. * ADC conversion on only 1 channel.
  3205. * @rmtoll SQR1 L LL_ADC_REG_GetSequencerLength
  3206. * @param ADCx ADC instance
  3207. * @retval Returned value can be one of the following values:
  3208. * @arg @ref LL_ADC_REG_SEQ_SCAN_DISABLE
  3209. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_2RANKS
  3210. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_3RANKS
  3211. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_4RANKS
  3212. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_5RANKS
  3213. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_6RANKS
  3214. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_7RANKS
  3215. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_8RANKS
  3216. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_9RANKS
  3217. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_10RANKS
  3218. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_11RANKS
  3219. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_12RANKS
  3220. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_13RANKS
  3221. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_14RANKS
  3222. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_15RANKS
  3223. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_16RANKS
  3224. */
  3225. __STATIC_INLINE uint32_t LL_ADC_REG_GetSequencerLength(ADC_TypeDef *ADCx)
  3226. {
  3227. return (uint32_t)(READ_BIT(ADCx->SQR1, ADC_SQR1_L));
  3228. }
  3229. /**
  3230. * @brief Set ADC group regular sequencer discontinuous mode:
  3231. * sequence subdivided and scan conversions interrupted every selected
  3232. * number of ranks.
  3233. * @note It is not possible to enable both ADC group regular
  3234. * continuous mode and sequencer discontinuous mode.
  3235. * @note It is not possible to enable both ADC auto-injected mode
  3236. * and ADC group regular sequencer discontinuous mode.
  3237. * @note On this STM32 series, setting of this feature is conditioned to
  3238. * ADC state:
  3239. * ADC must be disabled or enabled without conversion on going
  3240. * on group regular.
  3241. * @rmtoll CFGR DISCEN LL_ADC_REG_SetSequencerDiscont\n
  3242. * CFGR DISCNUM LL_ADC_REG_SetSequencerDiscont
  3243. * @param ADCx ADC instance
  3244. * @param SeqDiscont This parameter can be one of the following values:
  3245. * @arg @ref LL_ADC_REG_SEQ_DISCONT_DISABLE
  3246. * @arg @ref LL_ADC_REG_SEQ_DISCONT_1RANK
  3247. * @arg @ref LL_ADC_REG_SEQ_DISCONT_2RANKS
  3248. * @arg @ref LL_ADC_REG_SEQ_DISCONT_3RANKS
  3249. * @arg @ref LL_ADC_REG_SEQ_DISCONT_4RANKS
  3250. * @arg @ref LL_ADC_REG_SEQ_DISCONT_5RANKS
  3251. * @arg @ref LL_ADC_REG_SEQ_DISCONT_6RANKS
  3252. * @arg @ref LL_ADC_REG_SEQ_DISCONT_7RANKS
  3253. * @arg @ref LL_ADC_REG_SEQ_DISCONT_8RANKS
  3254. * @retval None
  3255. */
  3256. __STATIC_INLINE void LL_ADC_REG_SetSequencerDiscont(ADC_TypeDef *ADCx, uint32_t SeqDiscont)
  3257. {
  3258. MODIFY_REG(ADCx->CFGR, ADC_CFGR_DISCEN | ADC_CFGR_DISCNUM, SeqDiscont);
  3259. }
  3260. /**
  3261. * @brief Get ADC group regular sequencer discontinuous mode:
  3262. * sequence subdivided and scan conversions interrupted every selected
  3263. * number of ranks.
  3264. * @rmtoll CFGR DISCEN LL_ADC_REG_GetSequencerDiscont\n
  3265. * CFGR DISCNUM LL_ADC_REG_GetSequencerDiscont
  3266. * @param ADCx ADC instance
  3267. * @retval Returned value can be one of the following values:
  3268. * @arg @ref LL_ADC_REG_SEQ_DISCONT_DISABLE
  3269. * @arg @ref LL_ADC_REG_SEQ_DISCONT_1RANK
  3270. * @arg @ref LL_ADC_REG_SEQ_DISCONT_2RANKS
  3271. * @arg @ref LL_ADC_REG_SEQ_DISCONT_3RANKS
  3272. * @arg @ref LL_ADC_REG_SEQ_DISCONT_4RANKS
  3273. * @arg @ref LL_ADC_REG_SEQ_DISCONT_5RANKS
  3274. * @arg @ref LL_ADC_REG_SEQ_DISCONT_6RANKS
  3275. * @arg @ref LL_ADC_REG_SEQ_DISCONT_7RANKS
  3276. * @arg @ref LL_ADC_REG_SEQ_DISCONT_8RANKS
  3277. */
  3278. __STATIC_INLINE uint32_t LL_ADC_REG_GetSequencerDiscont(ADC_TypeDef *ADCx)
  3279. {
  3280. return (uint32_t)(READ_BIT(ADCx->CFGR, ADC_CFGR_DISCEN | ADC_CFGR_DISCNUM));
  3281. }
  3282. /**
  3283. * @brief Set ADC group regular sequence: channel on the selected
  3284. * scan sequence rank.
  3285. * @note This function performs configuration of:
  3286. * - Channels ordering into each rank of scan sequence:
  3287. * whatever channel can be placed into whatever rank.
  3288. * @note On this STM32 series, ADC group regular sequencer is
  3289. * fully configurable: sequencer length and each rank
  3290. * affectation to a channel are configurable.
  3291. * Refer to description of function @ref LL_ADC_REG_SetSequencerLength().
  3292. * @note Depending on devices and packages, some channels may not be available.
  3293. * Refer to device datasheet for channels availability.
  3294. * @note On this STM32 series, to measure internal channels (VrefInt,
  3295. * TempSensor, ...), measurement paths to internal channels must be
  3296. * enabled separately.
  3297. * This can be done using function @ref LL_ADC_SetCommonPathInternalCh().
  3298. * @note On this STM32 series, setting of this feature is conditioned to
  3299. * ADC state:
  3300. * ADC must be disabled or enabled without conversion on going
  3301. * on group regular.
  3302. * @rmtoll SQR1 SQ1 LL_ADC_REG_SetSequencerRanks\n
  3303. * SQR1 SQ2 LL_ADC_REG_SetSequencerRanks\n
  3304. * SQR1 SQ3 LL_ADC_REG_SetSequencerRanks\n
  3305. * SQR1 SQ4 LL_ADC_REG_SetSequencerRanks\n
  3306. * SQR2 SQ5 LL_ADC_REG_SetSequencerRanks\n
  3307. * SQR2 SQ6 LL_ADC_REG_SetSequencerRanks\n
  3308. * SQR2 SQ7 LL_ADC_REG_SetSequencerRanks\n
  3309. * SQR2 SQ8 LL_ADC_REG_SetSequencerRanks\n
  3310. * SQR2 SQ9 LL_ADC_REG_SetSequencerRanks\n
  3311. * SQR3 SQ10 LL_ADC_REG_SetSequencerRanks\n
  3312. * SQR3 SQ11 LL_ADC_REG_SetSequencerRanks\n
  3313. * SQR3 SQ12 LL_ADC_REG_SetSequencerRanks\n
  3314. * SQR3 SQ13 LL_ADC_REG_SetSequencerRanks\n
  3315. * SQR3 SQ14 LL_ADC_REG_SetSequencerRanks\n
  3316. * SQR4 SQ15 LL_ADC_REG_SetSequencerRanks\n
  3317. * SQR4 SQ16 LL_ADC_REG_SetSequencerRanks
  3318. * @param ADCx ADC instance
  3319. * @param Rank This parameter can be one of the following values:
  3320. * @arg @ref LL_ADC_REG_RANK_1
  3321. * @arg @ref LL_ADC_REG_RANK_2
  3322. * @arg @ref LL_ADC_REG_RANK_3
  3323. * @arg @ref LL_ADC_REG_RANK_4
  3324. * @arg @ref LL_ADC_REG_RANK_5
  3325. * @arg @ref LL_ADC_REG_RANK_6
  3326. * @arg @ref LL_ADC_REG_RANK_7
  3327. * @arg @ref LL_ADC_REG_RANK_8
  3328. * @arg @ref LL_ADC_REG_RANK_9
  3329. * @arg @ref LL_ADC_REG_RANK_10
  3330. * @arg @ref LL_ADC_REG_RANK_11
  3331. * @arg @ref LL_ADC_REG_RANK_12
  3332. * @arg @ref LL_ADC_REG_RANK_13
  3333. * @arg @ref LL_ADC_REG_RANK_14
  3334. * @arg @ref LL_ADC_REG_RANK_15
  3335. * @arg @ref LL_ADC_REG_RANK_16
  3336. * @param Channel This parameter can be one of the following values:
  3337. * @arg @ref LL_ADC_CHANNEL_0
  3338. * @arg @ref LL_ADC_CHANNEL_1
  3339. * @arg @ref LL_ADC_CHANNEL_2
  3340. * @arg @ref LL_ADC_CHANNEL_3
  3341. * @arg @ref LL_ADC_CHANNEL_4
  3342. * @arg @ref LL_ADC_CHANNEL_5
  3343. * @arg @ref LL_ADC_CHANNEL_6
  3344. * @arg @ref LL_ADC_CHANNEL_7
  3345. * @arg @ref LL_ADC_CHANNEL_8
  3346. * @arg @ref LL_ADC_CHANNEL_9
  3347. * @arg @ref LL_ADC_CHANNEL_10
  3348. * @arg @ref LL_ADC_CHANNEL_11
  3349. * @arg @ref LL_ADC_CHANNEL_12
  3350. * @arg @ref LL_ADC_CHANNEL_13
  3351. * @arg @ref LL_ADC_CHANNEL_14
  3352. * @arg @ref LL_ADC_CHANNEL_15
  3353. * @arg @ref LL_ADC_CHANNEL_16
  3354. * @arg @ref LL_ADC_CHANNEL_17
  3355. * @arg @ref LL_ADC_CHANNEL_18
  3356. * @arg @ref LL_ADC_CHANNEL_VREFINT (5)
  3357. * @arg @ref LL_ADC_CHANNEL_TEMPSENSOR (1)
  3358. * @arg @ref LL_ADC_CHANNEL_VBAT (1)
  3359. * @arg @ref LL_ADC_CHANNEL_VOPAMP1 (1)
  3360. * @arg @ref LL_ADC_CHANNEL_VOPAMP2 (2)
  3361. * @arg @ref LL_ADC_CHANNEL_VOPAMP3 (3)
  3362. * @arg @ref LL_ADC_CHANNEL_VOPAMP4 (4)
  3363. *
  3364. * (1) On STM32F3, parameter available only on ADC instance: ADC1.\n
  3365. * (2) On STM32F3, parameter available only on ADC instance: ADC2.\n
  3366. * (3) On STM32F3, parameter available only on ADC instance: ADC3.\n
  3367. * (4) On STM32F3, parameter available only on ADC instances: ADC4.\n
  3368. * (5) On STM32F3, ADC channel available only on all ADC instances, but
  3369. * only one ADC instance is allowed to be connected to VrefInt at the same time.
  3370. * @retval None
  3371. */
  3372. __STATIC_INLINE void LL_ADC_REG_SetSequencerRanks(ADC_TypeDef *ADCx, uint32_t Rank, uint32_t Channel)
  3373. {
  3374. /* Set bits with content of parameter "Channel" with bits position */
  3375. /* in register and register position depending on parameter "Rank". */
  3376. /* Parameters "Rank" and "Channel" are used with masks because containing */
  3377. /* other bits reserved for other purpose. */
  3378. __IO uint32_t *preg = __ADC_PTR_REG_OFFSET(ADCx->SQR1, __ADC_MASK_SHIFT(Rank, ADC_REG_SQRX_REGOFFSET_MASK));
  3379. MODIFY_REG(*preg,
  3380. ADC_CHANNEL_ID_NUMBER_MASK_POSBIT0 << (Rank & ADC_REG_RANK_ID_SQRX_MASK),
  3381. ((Channel & ADC_CHANNEL_ID_NUMBER_MASK) >> ADC_CHANNEL_ID_NUMBER_BITOFFSET_POS) << (Rank & ADC_REG_RANK_ID_SQRX_MASK));
  3382. }
  3383. /**
  3384. * @brief Get ADC group regular sequence: channel on the selected
  3385. * scan sequence rank.
  3386. * @note On this STM32 series, ADC group regular sequencer is
  3387. * fully configurable: sequencer length and each rank
  3388. * affectation to a channel are configurable.
  3389. * Refer to description of function @ref LL_ADC_REG_SetSequencerLength().
  3390. * @note Depending on devices and packages, some channels may not be available.
  3391. * Refer to device datasheet for channels availability.
  3392. * @note Usage of the returned channel number:
  3393. * - To reinject this channel into another function LL_ADC_xxx:
  3394. * the returned channel number is only partly formatted on definition
  3395. * of literals LL_ADC_CHANNEL_x. Therefore, it has to be compared
  3396. * with parts of literals LL_ADC_CHANNEL_x or using
  3397. * helper macro @ref __LL_ADC_CHANNEL_TO_DECIMAL_NB().
  3398. * Then the selected literal LL_ADC_CHANNEL_x can be used
  3399. * as parameter for another function.
  3400. * - To get the channel number in decimal format:
  3401. * process the returned value with the helper macro
  3402. * @ref __LL_ADC_CHANNEL_TO_DECIMAL_NB().
  3403. * @rmtoll SQR1 SQ1 LL_ADC_REG_GetSequencerRanks\n
  3404. * SQR1 SQ2 LL_ADC_REG_GetSequencerRanks\n
  3405. * SQR1 SQ3 LL_ADC_REG_GetSequencerRanks\n
  3406. * SQR1 SQ4 LL_ADC_REG_GetSequencerRanks\n
  3407. * SQR2 SQ5 LL_ADC_REG_GetSequencerRanks\n
  3408. * SQR2 SQ6 LL_ADC_REG_GetSequencerRanks\n
  3409. * SQR2 SQ7 LL_ADC_REG_GetSequencerRanks\n
  3410. * SQR2 SQ8 LL_ADC_REG_GetSequencerRanks\n
  3411. * SQR2 SQ9 LL_ADC_REG_GetSequencerRanks\n
  3412. * SQR3 SQ10 LL_ADC_REG_GetSequencerRanks\n
  3413. * SQR3 SQ11 LL_ADC_REG_GetSequencerRanks\n
  3414. * SQR3 SQ12 LL_ADC_REG_GetSequencerRanks\n
  3415. * SQR3 SQ13 LL_ADC_REG_GetSequencerRanks\n
  3416. * SQR3 SQ14 LL_ADC_REG_GetSequencerRanks\n
  3417. * SQR4 SQ15 LL_ADC_REG_GetSequencerRanks\n
  3418. * SQR4 SQ16 LL_ADC_REG_GetSequencerRanks
  3419. * @param ADCx ADC instance
  3420. * @param Rank This parameter can be one of the following values:
  3421. * @arg @ref LL_ADC_REG_RANK_1
  3422. * @arg @ref LL_ADC_REG_RANK_2
  3423. * @arg @ref LL_ADC_REG_RANK_3
  3424. * @arg @ref LL_ADC_REG_RANK_4
  3425. * @arg @ref LL_ADC_REG_RANK_5
  3426. * @arg @ref LL_ADC_REG_RANK_6
  3427. * @arg @ref LL_ADC_REG_RANK_7
  3428. * @arg @ref LL_ADC_REG_RANK_8
  3429. * @arg @ref LL_ADC_REG_RANK_9
  3430. * @arg @ref LL_ADC_REG_RANK_10
  3431. * @arg @ref LL_ADC_REG_RANK_11
  3432. * @arg @ref LL_ADC_REG_RANK_12
  3433. * @arg @ref LL_ADC_REG_RANK_13
  3434. * @arg @ref LL_ADC_REG_RANK_14
  3435. * @arg @ref LL_ADC_REG_RANK_15
  3436. * @arg @ref LL_ADC_REG_RANK_16
  3437. * @retval Returned value can be one of the following values:
  3438. * @arg @ref LL_ADC_CHANNEL_0
  3439. * @arg @ref LL_ADC_CHANNEL_1
  3440. * @arg @ref LL_ADC_CHANNEL_2
  3441. * @arg @ref LL_ADC_CHANNEL_3
  3442. * @arg @ref LL_ADC_CHANNEL_4
  3443. * @arg @ref LL_ADC_CHANNEL_5
  3444. * @arg @ref LL_ADC_CHANNEL_6
  3445. * @arg @ref LL_ADC_CHANNEL_7
  3446. * @arg @ref LL_ADC_CHANNEL_8
  3447. * @arg @ref LL_ADC_CHANNEL_9
  3448. * @arg @ref LL_ADC_CHANNEL_10
  3449. * @arg @ref LL_ADC_CHANNEL_11
  3450. * @arg @ref LL_ADC_CHANNEL_12
  3451. * @arg @ref LL_ADC_CHANNEL_13
  3452. * @arg @ref LL_ADC_CHANNEL_14
  3453. * @arg @ref LL_ADC_CHANNEL_15
  3454. * @arg @ref LL_ADC_CHANNEL_16
  3455. * @arg @ref LL_ADC_CHANNEL_17
  3456. * @arg @ref LL_ADC_CHANNEL_18
  3457. * @arg @ref LL_ADC_CHANNEL_VREFINT (5)
  3458. * @arg @ref LL_ADC_CHANNEL_TEMPSENSOR (1)
  3459. * @arg @ref LL_ADC_CHANNEL_VBAT (1)
  3460. * @arg @ref LL_ADC_CHANNEL_VOPAMP1 (1)
  3461. * @arg @ref LL_ADC_CHANNEL_VOPAMP2 (2)
  3462. * @arg @ref LL_ADC_CHANNEL_VOPAMP3 (3)
  3463. * @arg @ref LL_ADC_CHANNEL_VOPAMP4 (4)
  3464. *
  3465. * (1) On STM32F3, parameter available only on ADC instance: ADC1.\n
  3466. * (2) On STM32F3, parameter available only on ADC instance: ADC2.\n
  3467. * (3) On STM32F3, parameter available only on ADC instance: ADC3.\n
  3468. * (4) On STM32F3, parameter available only on ADC instances: ADC4.\n
  3469. * (5) On STM32F3, ADC channel available only on all ADC instances, but
  3470. * only one ADC instance is allowed to be connected to VrefInt at the same time.\n
  3471. * (1, 2, 3, 4, 5) For ADC channel read back from ADC register,
  3472. * comparison with internal channel parameter to be done
  3473. * using helper macro @ref __LL_ADC_CHANNEL_INTERNAL_TO_EXTERNAL().
  3474. */
  3475. __STATIC_INLINE uint32_t LL_ADC_REG_GetSequencerRanks(ADC_TypeDef *ADCx, uint32_t Rank)
  3476. {
  3477. __IO uint32_t *preg = __ADC_PTR_REG_OFFSET(ADCx->SQR1, __ADC_MASK_SHIFT(Rank, ADC_REG_SQRX_REGOFFSET_MASK));
  3478. return (uint32_t) ((READ_BIT(*preg,
  3479. ADC_CHANNEL_ID_NUMBER_MASK_POSBIT0 << (Rank & ADC_REG_RANK_ID_SQRX_MASK))
  3480. >> (Rank & ADC_REG_RANK_ID_SQRX_MASK)) << ADC_CHANNEL_ID_NUMBER_BITOFFSET_POS
  3481. );
  3482. }
  3483. /**
  3484. * @brief Set ADC continuous conversion mode on ADC group regular.
  3485. * @note Description of ADC continuous conversion mode:
  3486. * - single mode: one conversion per trigger
  3487. * - continuous mode: after the first trigger, following
  3488. * conversions launched successively automatically.
  3489. * @note It is not possible to enable both ADC group regular
  3490. * continuous mode and sequencer discontinuous mode.
  3491. * @note On this STM32 series, setting of this feature is conditioned to
  3492. * ADC state:
  3493. * ADC must be disabled or enabled without conversion on going
  3494. * on group regular.
  3495. * @rmtoll CFGR CONT LL_ADC_REG_SetContinuousMode
  3496. * @param ADCx ADC instance
  3497. * @param Continuous This parameter can be one of the following values:
  3498. * @arg @ref LL_ADC_REG_CONV_SINGLE
  3499. * @arg @ref LL_ADC_REG_CONV_CONTINUOUS
  3500. * @retval None
  3501. */
  3502. __STATIC_INLINE void LL_ADC_REG_SetContinuousMode(ADC_TypeDef *ADCx, uint32_t Continuous)
  3503. {
  3504. MODIFY_REG(ADCx->CFGR, ADC_CFGR_CONT, Continuous);
  3505. }
  3506. /**
  3507. * @brief Get ADC continuous conversion mode on ADC group regular.
  3508. * @note Description of ADC continuous conversion mode:
  3509. * - single mode: one conversion per trigger
  3510. * - continuous mode: after the first trigger, following
  3511. * conversions launched successively automatically.
  3512. * @rmtoll CFGR CONT LL_ADC_REG_GetContinuousMode
  3513. * @param ADCx ADC instance
  3514. * @retval Returned value can be one of the following values:
  3515. * @arg @ref LL_ADC_REG_CONV_SINGLE
  3516. * @arg @ref LL_ADC_REG_CONV_CONTINUOUS
  3517. */
  3518. __STATIC_INLINE uint32_t LL_ADC_REG_GetContinuousMode(ADC_TypeDef *ADCx)
  3519. {
  3520. return (uint32_t)(READ_BIT(ADCx->CFGR, ADC_CFGR_CONT));
  3521. }
  3522. /**
  3523. * @brief Set ADC group regular conversion data transfer: no transfer or
  3524. * transfer by DMA, and DMA requests mode.
  3525. * @note If transfer by DMA selected, specifies the DMA requests
  3526. * mode:
  3527. * - Limited mode (One shot mode): DMA transfer requests are stopped
  3528. * when number of DMA data transfers (number of
  3529. * ADC conversions) is reached.
  3530. * This ADC mode is intended to be used with DMA mode non-circular.
  3531. * - Unlimited mode: DMA transfer requests are unlimited,
  3532. * whatever number of DMA data transfers (number of
  3533. * ADC conversions).
  3534. * This ADC mode is intended to be used with DMA mode circular.
  3535. * @note If ADC DMA requests mode is set to unlimited and DMA is set to
  3536. * mode non-circular:
  3537. * when DMA transfers size will be reached, DMA will stop transfers of
  3538. * ADC conversions data ADC will raise an overrun error
  3539. * (overrun flag and interruption if enabled).
  3540. * @note For devices with several ADC instances: ADC multimode DMA
  3541. * settings are available using function @ref LL_ADC_SetMultiDMATransfer().
  3542. * @note To configure DMA source address (peripheral address),
  3543. * use function @ref LL_ADC_DMA_GetRegAddr().
  3544. * @note On this STM32 series, setting of this feature is conditioned to
  3545. * ADC state:
  3546. * ADC must be disabled or enabled without conversion on going
  3547. * on either groups regular or injected.
  3548. * @rmtoll CFGR DMAEN LL_ADC_REG_SetDMATransfer\n
  3549. * CFGR DMACFG LL_ADC_REG_SetDMATransfer
  3550. * @param ADCx ADC instance
  3551. * @param DMATransfer This parameter can be one of the following values:
  3552. * @arg @ref LL_ADC_REG_DMA_TRANSFER_NONE
  3553. * @arg @ref LL_ADC_REG_DMA_TRANSFER_LIMITED
  3554. * @arg @ref LL_ADC_REG_DMA_TRANSFER_UNLIMITED
  3555. * @retval None
  3556. */
  3557. __STATIC_INLINE void LL_ADC_REG_SetDMATransfer(ADC_TypeDef *ADCx, uint32_t DMATransfer)
  3558. {
  3559. MODIFY_REG(ADCx->CFGR, ADC_CFGR_DMAEN | ADC_CFGR_DMACFG, DMATransfer);
  3560. }
  3561. /**
  3562. * @brief Get ADC group regular conversion data transfer: no transfer or
  3563. * transfer by DMA, and DMA requests mode.
  3564. * @note If transfer by DMA selected, specifies the DMA requests
  3565. * mode:
  3566. * - Limited mode (One shot mode): DMA transfer requests are stopped
  3567. * when number of DMA data transfers (number of
  3568. * ADC conversions) is reached.
  3569. * This ADC mode is intended to be used with DMA mode non-circular.
  3570. * - Unlimited mode: DMA transfer requests are unlimited,
  3571. * whatever number of DMA data transfers (number of
  3572. * ADC conversions).
  3573. * This ADC mode is intended to be used with DMA mode circular.
  3574. * @note If ADC DMA requests mode is set to unlimited and DMA is set to
  3575. * mode non-circular:
  3576. * when DMA transfers size will be reached, DMA will stop transfers of
  3577. * ADC conversions data ADC will raise an overrun error
  3578. * (overrun flag and interruption if enabled).
  3579. * @note For devices with several ADC instances: ADC multimode DMA
  3580. * settings are available using function @ref LL_ADC_GetMultiDMATransfer().
  3581. * @note To configure DMA source address (peripheral address),
  3582. * use function @ref LL_ADC_DMA_GetRegAddr().
  3583. * @rmtoll CFGR DMAEN LL_ADC_REG_GetDMATransfer\n
  3584. * CFGR DMACFG LL_ADC_REG_GetDMATransfer
  3585. * @param ADCx ADC instance
  3586. * @retval Returned value can be one of the following values:
  3587. * @arg @ref LL_ADC_REG_DMA_TRANSFER_NONE
  3588. * @arg @ref LL_ADC_REG_DMA_TRANSFER_LIMITED
  3589. * @arg @ref LL_ADC_REG_DMA_TRANSFER_UNLIMITED
  3590. */
  3591. __STATIC_INLINE uint32_t LL_ADC_REG_GetDMATransfer(ADC_TypeDef *ADCx)
  3592. {
  3593. return (uint32_t)(READ_BIT(ADCx->CFGR, ADC_CFGR_DMAEN | ADC_CFGR_DMACFG));
  3594. }
  3595. /**
  3596. * @brief Set ADC group regular behavior in case of overrun:
  3597. * data preserved or overwritten.
  3598. * @note Compatibility with devices without feature overrun:
  3599. * other devices without this feature have a behavior
  3600. * equivalent to data overwritten.
  3601. * The default setting of overrun is data preserved.
  3602. * Therefore, for compatibility with all devices, parameter
  3603. * overrun should be set to data overwritten.
  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 group regular.
  3608. * @rmtoll CFGR OVRMOD LL_ADC_REG_SetOverrun
  3609. * @param ADCx ADC instance
  3610. * @param Overrun This parameter can be one of the following values:
  3611. * @arg @ref LL_ADC_REG_OVR_DATA_PRESERVED
  3612. * @arg @ref LL_ADC_REG_OVR_DATA_OVERWRITTEN
  3613. * @retval None
  3614. */
  3615. __STATIC_INLINE void LL_ADC_REG_SetOverrun(ADC_TypeDef *ADCx, uint32_t Overrun)
  3616. {
  3617. MODIFY_REG(ADCx->CFGR, ADC_CFGR_OVRMOD, Overrun);
  3618. }
  3619. /**
  3620. * @brief Get ADC group regular behavior in case of overrun:
  3621. * data preserved or overwritten.
  3622. * @rmtoll CFGR OVRMOD LL_ADC_REG_GetOverrun
  3623. * @param ADCx ADC instance
  3624. * @retval Returned value can be one of the following values:
  3625. * @arg @ref LL_ADC_REG_OVR_DATA_PRESERVED
  3626. * @arg @ref LL_ADC_REG_OVR_DATA_OVERWRITTEN
  3627. */
  3628. __STATIC_INLINE uint32_t LL_ADC_REG_GetOverrun(ADC_TypeDef *ADCx)
  3629. {
  3630. return (uint32_t)(READ_BIT(ADCx->CFGR, ADC_CFGR_OVRMOD));
  3631. }
  3632. /**
  3633. * @}
  3634. */
  3635. /** @defgroup ADC_LL_EF_Configuration_ADC_Group_Injected Configuration of ADC hierarchical scope: group injected
  3636. * @{
  3637. */
  3638. /**
  3639. * @brief Set ADC group injected conversion trigger source:
  3640. * internal (SW start) or from external IP (timer event,
  3641. * external interrupt line).
  3642. * @note On this STM32 series, setting trigger source to external trigger
  3643. * also set trigger polarity to rising edge
  3644. * (default setting for compatibility with some ADC on other
  3645. * STM32 families having this setting set by HW default value).
  3646. * In case of need to modify trigger edge, use
  3647. * function @ref LL_ADC_INJ_SetTriggerEdge().
  3648. * @note Caution to ADC group injected contexts queue: On this STM32 series,
  3649. * using successively several times this function will appear has
  3650. * having no effect.
  3651. * This is due to ADC group injected contexts queue (this feature
  3652. * cannot be disabled on this STM32 series).
  3653. * To set several features of ADC group injected, use
  3654. * function @ref LL_ADC_INJ_ConfigQueueContext().
  3655. * @note Availability of parameters of trigger sources from timer
  3656. * depends on timers availability on the selected device.
  3657. * @note On this STM32 series, setting of this feature is conditioned to
  3658. * ADC state:
  3659. * ADC must not be disabled. Can be enabled with or without conversion
  3660. * on going on either groups regular or injected.
  3661. * @rmtoll JSQR JEXTSEL LL_ADC_INJ_SetTriggerSource\n
  3662. * JSQR JEXTEN LL_ADC_INJ_SetTriggerSource
  3663. * @param ADCx ADC instance
  3664. * @param TriggerSource This parameter can be one of the following values:
  3665. * @arg @ref LL_ADC_INJ_TRIG_SOFTWARE
  3666. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM1_TRGO
  3667. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM1_TRGO2
  3668. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM1_CH3_ADC34 (1)(2) (8)
  3669. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM1_CH4
  3670. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM2_TRGO (3)(4)(5)
  3671. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM2_TRGO_ADC12 (1)(2) (7)
  3672. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM2_TRGO__ADC34 (1)(2) (8)
  3673. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM2_CH1 (3)(4)(5)
  3674. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM2_CH1_ADC12 (1)(2) (7)
  3675. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM3_TRGO (1)(2)(3)(4)(5)
  3676. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM3_CH1 (3)(4)(5)
  3677. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM3_CH1_ADC12 (1)(2) (7)
  3678. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM3_CH3 (3)(4)(5)
  3679. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM3_CH3_ADC12 (1)(2) (7)
  3680. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM3_CH4 (3)(4)(5)
  3681. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM3_CH4_ADC12 (1)(2)(3)(4)(5) (7)
  3682. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM4_TRGO (3) (5)
  3683. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM4_TRGO_ADC12 (1)(2) (7)
  3684. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM4_TRGO__ADC34 (1)(2) (8)
  3685. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM4_CH3_ADC34 (1)(2) (8)
  3686. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM4_CH4_ADC34 (1)(2) (8)
  3687. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM6_TRGO (3)(4)(5)
  3688. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM6_TRGO_ADC12 (1)(2) (7)
  3689. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM7_TRGO_ADC34 (1)(2) (8)
  3690. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM8_TRGO (1)(2)
  3691. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM8_TRGO2 (1)(2)
  3692. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM8_CH2_ADC34 (1)(2) (8)
  3693. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM8_CH4_ADC12 (1)(2) (7)
  3694. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM8_CH4__ADC34 (1)(2) (8)
  3695. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM15_TRGO
  3696. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM20_TRGO_ADC12 (1) (7)
  3697. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM20_TRGO2_ADC12 (1) (7)
  3698. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM20_CH4_ADC12 (1) (7)
  3699. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM20_TRG_ADC34 (1) (8)
  3700. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM20_TRG2_ADC34 (1) (8)
  3701. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM20_CH2_ADC34 (1) (8)
  3702. * @arg @ref LL_ADC_INJ_TRIG_EXT_HRTIM_TRG2 (4)
  3703. * @arg @ref LL_ADC_INJ_TRIG_EXT_HRTIM_TRG4 (4)
  3704. * @arg @ref LL_ADC_INJ_TRIG_EXT_EXTI_LINE15 (3)(4)(5)(6)
  3705. * @arg @ref LL_ADC_INJ_TRIG_EXT_EXTI_LINE15_ADC12 (1)(2) (7)
  3706. *
  3707. * (1) On STM32F3, parameter not available on all devices: among others, on STM32F303xE, STM32F398xx.\n
  3708. * (2) On STM32F3, parameter not available on all devices: among others, on STM32F303xC, STM32F358xx.\n
  3709. * (3) On STM32F3, parameter not available on all devices: among others, on STM32F303x8, STM32F328xx.\n
  3710. * (4) On STM32F3, parameter not available on all devices: among others, on STM32F334x8.\n
  3711. * (5) On STM32F3, parameter not available on all devices: among others, on STM32F302xC, STM32F302xE.\n
  3712. * (6) On STM32F3, parameter not available on all devices: among others, on STM32F301x8, STM32F302x8, STM32F318xx.\n
  3713. * (7) On STM32F3, parameter not available on all ADC instances: ADC1, ADC2 (for ADC instances ADCx available on the selected device).\n
  3714. * (8) On STM32F3, parameter not available on all ADC instances: ADC3, ADC4 (for ADC instances ADCx available on the selected device).
  3715. * @retval None
  3716. */
  3717. __STATIC_INLINE void LL_ADC_INJ_SetTriggerSource(ADC_TypeDef *ADCx, uint32_t TriggerSource)
  3718. {
  3719. MODIFY_REG(ADCx->JSQR, ADC_JSQR_JEXTSEL | ADC_JSQR_JEXTEN, TriggerSource);
  3720. }
  3721. /**
  3722. * @brief Get ADC group injected conversion trigger source:
  3723. * internal (SW start) or from external IP (timer event,
  3724. * external interrupt line).
  3725. * @note To determine whether group injected trigger source is
  3726. * internal (SW start) or external, without detail
  3727. * of which peripheral is selected as external trigger,
  3728. * (equivalent to
  3729. * "if(LL_ADC_INJ_GetTriggerSource(ADC1) == LL_ADC_INJ_TRIG_SOFTWARE)")
  3730. * use function @ref LL_ADC_INJ_IsTriggerSourceSWStart.
  3731. * @note Availability of parameters of trigger sources from timer
  3732. * depends on timers availability on the selected device.
  3733. * @rmtoll JSQR JEXTSEL LL_ADC_INJ_GetTriggerSource\n
  3734. * JSQR JEXTEN LL_ADC_INJ_GetTriggerSource
  3735. * @param ADCx ADC instance
  3736. * @retval Returned value can be one of the following values:
  3737. * @arg @ref LL_ADC_INJ_TRIG_SOFTWARE
  3738. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM1_TRGO
  3739. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM1_TRGO2
  3740. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM1_CH3_ADC34 (1)(2) (8)
  3741. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM1_CH4
  3742. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM2_TRGO (3)(4)(5)
  3743. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM2_TRGO_ADC12 (1)(2) (7)
  3744. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM2_TRGO__ADC34 (1)(2) (8)
  3745. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM2_CH1 (3)(4)(5)
  3746. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM2_CH1_ADC12 (1)(2) (7)
  3747. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM3_TRGO (1)(2)(3)(4)(5)
  3748. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM3_CH1 (3)(4)(5)
  3749. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM3_CH1_ADC12 (1)(2) (7)
  3750. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM3_CH3 (3)(4)(5)
  3751. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM3_CH3_ADC12 (1)(2) (7)
  3752. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM3_CH4 (3)(4)(5)
  3753. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM3_CH4_ADC12 (1)(2)(3)(4)(5) (7)
  3754. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM4_TRGO (3) (5)
  3755. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM4_TRGO_ADC12 (1)(2) (7)
  3756. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM4_TRGO__ADC34 (1)(2) (8)
  3757. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM4_CH3_ADC34 (1)(2) (8)
  3758. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM4_CH4_ADC34 (1)(2) (8)
  3759. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM6_TRGO (3)(4)(5)
  3760. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM6_TRGO_ADC12 (1)(2) (7)
  3761. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM7_TRGO_ADC34 (1)(2) (8)
  3762. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM8_TRGO (1)(2)
  3763. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM8_TRGO2 (1)(2)
  3764. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM8_CH2_ADC34 (1)(2) (8)
  3765. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM8_CH4_ADC12 (1)(2) (7)
  3766. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM8_CH4__ADC34 (1)(2) (8)
  3767. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM15_TRGO
  3768. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM20_TRGO_ADC12 (1) (7)
  3769. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM20_TRGO2_ADC12 (1) (7)
  3770. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM20_CH4_ADC12 (1) (7)
  3771. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM20_TRG_ADC34 (1) (8)
  3772. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM20_TRG2_ADC34 (1) (8)
  3773. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM20_CH2_ADC34 (1) (8)
  3774. * @arg @ref LL_ADC_INJ_TRIG_EXT_HRTIM_TRG2 (4)
  3775. * @arg @ref LL_ADC_INJ_TRIG_EXT_HRTIM_TRG4 (4)
  3776. * @arg @ref LL_ADC_INJ_TRIG_EXT_EXTI_LINE15 (3)(4)(5)(6)
  3777. * @arg @ref LL_ADC_INJ_TRIG_EXT_EXTI_LINE15_ADC12 (1)(2) (7)
  3778. *
  3779. * (1) On STM32F3, parameter not available on all devices: among others, on STM32F303xE, STM32F398xx.\n
  3780. * (2) On STM32F3, parameter not available on all devices: among others, on STM32F303xC, STM32F358xx.\n
  3781. * (3) On STM32F3, parameter not available on all devices: among others, on STM32F303x8, STM32F328xx.\n
  3782. * (4) On STM32F3, parameter not available on all devices: among others, on STM32F334x8.\n
  3783. * (5) On STM32F3, parameter not available on all devices: among others, on STM32F302xC, STM32F302xE.\n
  3784. * (6) On STM32F3, parameter not available on all devices: among others, on STM32F301x8, STM32F302x8, STM32F318xx.\n
  3785. * (7) On STM32F3, parameter not available on all ADC instances: ADC1, ADC2 (for ADC instances ADCx available on the selected device).\n
  3786. * (8) On STM32F3, parameter not available on all ADC instances: ADC3, ADC4 (for ADC instances ADCx available on the selected device).
  3787. */
  3788. __STATIC_INLINE uint32_t LL_ADC_INJ_GetTriggerSource(ADC_TypeDef *ADCx)
  3789. {
  3790. uint32_t TriggerSource = READ_BIT(ADCx->JSQR, ADC_JSQR_JEXTSEL | ADC_JSQR_JEXTEN);
  3791. /* Value for shift of {0; 4; 8; 12} depending on value of bitfield */
  3792. /* corresponding to ADC_JSQR_JEXTEN {0; 1; 2; 3}. */
  3793. uint32_t ShiftJexten = ((TriggerSource & ADC_JSQR_JEXTEN) >> (ADC_INJ_TRIG_EXTEN_BITOFFSET_POS - 2U));
  3794. /* Set bitfield corresponding to ADC_JSQR_JEXTEN and ADC_JSQR_JEXTSEL */
  3795. /* to match with triggers literals definition. */
  3796. return ((TriggerSource
  3797. & (ADC_INJ_TRIG_SOURCE_MASK >> ShiftJexten) & ADC_JSQR_JEXTSEL)
  3798. | ((ADC_INJ_TRIG_EDGE_MASK >> ShiftJexten) & ADC_JSQR_JEXTEN)
  3799. );
  3800. }
  3801. /**
  3802. * @brief Get ADC group injected conversion trigger source internal (SW start)
  3803. or external
  3804. * @note In case of group injected trigger source set to external trigger,
  3805. * to determine which peripheral is selected as external trigger,
  3806. * use function @ref LL_ADC_INJ_GetTriggerSource.
  3807. * @rmtoll JSQR JEXTEN LL_ADC_INJ_IsTriggerSourceSWStart
  3808. * @param ADCx ADC instance
  3809. * @retval Value "0" if trigger source external trigger
  3810. * Value "1" if trigger source SW start.
  3811. */
  3812. __STATIC_INLINE uint32_t LL_ADC_INJ_IsTriggerSourceSWStart(ADC_TypeDef *ADCx)
  3813. {
  3814. return (READ_BIT(ADCx->JSQR, ADC_JSQR_JEXTEN) == (LL_ADC_INJ_TRIG_SOFTWARE & ADC_JSQR_JEXTEN));
  3815. }
  3816. /**
  3817. * @brief Set ADC group injected conversion trigger polarity.
  3818. * Applicable only for trigger source set to external trigger.
  3819. * @note On this STM32 series, setting of this feature is conditioned to
  3820. * ADC state:
  3821. * ADC must not be disabled. Can be enabled with or without conversion
  3822. * on going on either groups regular or injected.
  3823. * @rmtoll JSQR JEXTEN LL_ADC_INJ_SetTriggerEdge
  3824. * @param ADCx ADC instance
  3825. * @param ExternalTriggerEdge This parameter can be one of the following values:
  3826. * @arg @ref LL_ADC_INJ_TRIG_EXT_RISING
  3827. * @arg @ref LL_ADC_INJ_TRIG_EXT_FALLING
  3828. * @arg @ref LL_ADC_INJ_TRIG_EXT_RISINGFALLING
  3829. * @retval None
  3830. */
  3831. __STATIC_INLINE void LL_ADC_INJ_SetTriggerEdge(ADC_TypeDef *ADCx, uint32_t ExternalTriggerEdge)
  3832. {
  3833. MODIFY_REG(ADCx->JSQR, ADC_JSQR_JEXTEN, ExternalTriggerEdge);
  3834. }
  3835. /**
  3836. * @brief Get ADC group injected conversion trigger polarity.
  3837. * Applicable only for trigger source set to external trigger.
  3838. * @rmtoll JSQR JEXTEN LL_ADC_INJ_GetTriggerEdge
  3839. * @param ADCx ADC instance
  3840. * @retval Returned value can be one of the following values:
  3841. * @arg @ref LL_ADC_INJ_TRIG_EXT_RISING
  3842. * @arg @ref LL_ADC_INJ_TRIG_EXT_FALLING
  3843. * @arg @ref LL_ADC_INJ_TRIG_EXT_RISINGFALLING
  3844. */
  3845. __STATIC_INLINE uint32_t LL_ADC_INJ_GetTriggerEdge(ADC_TypeDef *ADCx)
  3846. {
  3847. return (uint32_t)(READ_BIT(ADCx->JSQR, ADC_JSQR_JEXTEN));
  3848. }
  3849. /**
  3850. * @brief Set ADC group injected sequencer length and scan direction.
  3851. * @note This function performs configuration of:
  3852. * - Sequence length: Number of ranks in the scan sequence.
  3853. * - Sequence direction: Unless specified in parameters, sequencer
  3854. * scan direction is forward (from rank 1 to rank n).
  3855. * @note Sequencer disabled is equivalent to sequencer of 1 rank:
  3856. * ADC conversion on only 1 channel.
  3857. * @note Caution to ADC group injected contexts queue: On this STM32 series,
  3858. * using successively several times this function will appear has
  3859. * having no effect.
  3860. * This is due to ADC group injected contexts queue (this feature
  3861. * cannot be disabled on this STM32 series).
  3862. * To set several features of ADC group injected, use
  3863. * function @ref LL_ADC_INJ_ConfigQueueContext().
  3864. * @note On this STM32 series, setting of this feature is conditioned to
  3865. * ADC state:
  3866. * ADC must not be disabled. Can be enabled with or without conversion
  3867. * on going on either groups regular or injected.
  3868. * @rmtoll JSQR JL LL_ADC_INJ_SetSequencerLength
  3869. * @param ADCx ADC instance
  3870. * @param SequencerNbRanks This parameter can be one of the following values:
  3871. * @arg @ref LL_ADC_INJ_SEQ_SCAN_DISABLE
  3872. * @arg @ref LL_ADC_INJ_SEQ_SCAN_ENABLE_2RANKS
  3873. * @arg @ref LL_ADC_INJ_SEQ_SCAN_ENABLE_3RANKS
  3874. * @arg @ref LL_ADC_INJ_SEQ_SCAN_ENABLE_4RANKS
  3875. * @retval None
  3876. */
  3877. __STATIC_INLINE void LL_ADC_INJ_SetSequencerLength(ADC_TypeDef *ADCx, uint32_t SequencerNbRanks)
  3878. {
  3879. MODIFY_REG(ADCx->JSQR, ADC_JSQR_JL, SequencerNbRanks);
  3880. }
  3881. /**
  3882. * @brief Get ADC group injected sequencer length and scan direction.
  3883. * @note This function retrieves:
  3884. * - Sequence length: Number of ranks in the scan sequence.
  3885. * - Sequence direction: Unless specified in parameters, sequencer
  3886. * scan direction is forward (from rank 1 to rank n).
  3887. * @note Sequencer disabled is equivalent to sequencer of 1 rank:
  3888. * ADC conversion on only 1 channel.
  3889. * @rmtoll JSQR JL LL_ADC_INJ_GetSequencerLength
  3890. * @param ADCx ADC instance
  3891. * @retval Returned value can be one of the following values:
  3892. * @arg @ref LL_ADC_INJ_SEQ_SCAN_DISABLE
  3893. * @arg @ref LL_ADC_INJ_SEQ_SCAN_ENABLE_2RANKS
  3894. * @arg @ref LL_ADC_INJ_SEQ_SCAN_ENABLE_3RANKS
  3895. * @arg @ref LL_ADC_INJ_SEQ_SCAN_ENABLE_4RANKS
  3896. */
  3897. __STATIC_INLINE uint32_t LL_ADC_INJ_GetSequencerLength(ADC_TypeDef *ADCx)
  3898. {
  3899. return (uint32_t)(READ_BIT(ADCx->JSQR, ADC_JSQR_JL));
  3900. }
  3901. /**
  3902. * @brief Set ADC group injected sequencer discontinuous mode:
  3903. * sequence subdivided and scan conversions interrupted every selected
  3904. * number of ranks.
  3905. * @note It is not possible to enable both ADC group injected
  3906. * auto-injected mode and sequencer discontinuous mode.
  3907. * @rmtoll CFGR JDISCEN LL_ADC_INJ_SetSequencerDiscont
  3908. * @param ADCx ADC instance
  3909. * @param SeqDiscont This parameter can be one of the following values:
  3910. * @arg @ref LL_ADC_INJ_SEQ_DISCONT_DISABLE
  3911. * @arg @ref LL_ADC_INJ_SEQ_DISCONT_1RANK
  3912. * @retval None
  3913. */
  3914. __STATIC_INLINE void LL_ADC_INJ_SetSequencerDiscont(ADC_TypeDef *ADCx, uint32_t SeqDiscont)
  3915. {
  3916. MODIFY_REG(ADCx->CFGR, ADC_CFGR_JDISCEN, SeqDiscont);
  3917. }
  3918. /**
  3919. * @brief Get ADC group injected sequencer discontinuous mode:
  3920. * sequence subdivided and scan conversions interrupted every selected
  3921. * number of ranks.
  3922. * @rmtoll CFGR JDISCEN LL_ADC_INJ_GetSequencerDiscont
  3923. * @param ADCx ADC instance
  3924. * @retval Returned value can be one of the following values:
  3925. * @arg @ref LL_ADC_INJ_SEQ_DISCONT_DISABLE
  3926. * @arg @ref LL_ADC_INJ_SEQ_DISCONT_1RANK
  3927. */
  3928. __STATIC_INLINE uint32_t LL_ADC_INJ_GetSequencerDiscont(ADC_TypeDef *ADCx)
  3929. {
  3930. return (uint32_t)(READ_BIT(ADCx->CFGR, ADC_CFGR_JDISCEN));
  3931. }
  3932. /**
  3933. * @brief Set ADC group injected sequence: channel on the selected
  3934. * sequence rank.
  3935. * @note Depending on devices and packages, some channels may not be available.
  3936. * Refer to device datasheet for channels availability.
  3937. * @note On this STM32 series, to measure internal channels (VrefInt,
  3938. * TempSensor, ...), measurement paths to internal channels must be
  3939. * enabled separately.
  3940. * This can be done using function @ref LL_ADC_SetCommonPathInternalCh().
  3941. * @note Caution to ADC group injected contexts queue: On this STM32 series,
  3942. * using successively several times this function will appear has
  3943. * having no effect.
  3944. * This is due to ADC group injected contexts queue (this feature
  3945. * cannot be disabled on this STM32 series).
  3946. * To set several features of ADC group injected, use
  3947. * function @ref LL_ADC_INJ_ConfigQueueContext().
  3948. * @note On this STM32 series, setting of this feature is conditioned to
  3949. * ADC state:
  3950. * ADC must not be disabled. Can be enabled with or without conversion
  3951. * on going on either groups regular or injected.
  3952. * @rmtoll JSQR JSQ1 LL_ADC_INJ_SetSequencerRanks\n
  3953. * JSQR JSQ2 LL_ADC_INJ_SetSequencerRanks\n
  3954. * JSQR JSQ3 LL_ADC_INJ_SetSequencerRanks\n
  3955. * JSQR JSQ4 LL_ADC_INJ_SetSequencerRanks
  3956. * @param ADCx ADC instance
  3957. * @param Rank This parameter can be one of the following values:
  3958. * @arg @ref LL_ADC_INJ_RANK_1
  3959. * @arg @ref LL_ADC_INJ_RANK_2
  3960. * @arg @ref LL_ADC_INJ_RANK_3
  3961. * @arg @ref LL_ADC_INJ_RANK_4
  3962. * @param Channel This parameter can be one of the following values:
  3963. * @arg @ref LL_ADC_CHANNEL_0
  3964. * @arg @ref LL_ADC_CHANNEL_1
  3965. * @arg @ref LL_ADC_CHANNEL_2
  3966. * @arg @ref LL_ADC_CHANNEL_3
  3967. * @arg @ref LL_ADC_CHANNEL_4
  3968. * @arg @ref LL_ADC_CHANNEL_5
  3969. * @arg @ref LL_ADC_CHANNEL_6
  3970. * @arg @ref LL_ADC_CHANNEL_7
  3971. * @arg @ref LL_ADC_CHANNEL_8
  3972. * @arg @ref LL_ADC_CHANNEL_9
  3973. * @arg @ref LL_ADC_CHANNEL_10
  3974. * @arg @ref LL_ADC_CHANNEL_11
  3975. * @arg @ref LL_ADC_CHANNEL_12
  3976. * @arg @ref LL_ADC_CHANNEL_13
  3977. * @arg @ref LL_ADC_CHANNEL_14
  3978. * @arg @ref LL_ADC_CHANNEL_15
  3979. * @arg @ref LL_ADC_CHANNEL_16
  3980. * @arg @ref LL_ADC_CHANNEL_17
  3981. * @arg @ref LL_ADC_CHANNEL_18
  3982. * @arg @ref LL_ADC_CHANNEL_VREFINT (5)
  3983. * @arg @ref LL_ADC_CHANNEL_TEMPSENSOR (1)
  3984. * @arg @ref LL_ADC_CHANNEL_VBAT (1)
  3985. * @arg @ref LL_ADC_CHANNEL_VOPAMP1 (1)
  3986. * @arg @ref LL_ADC_CHANNEL_VOPAMP2 (2)
  3987. * @arg @ref LL_ADC_CHANNEL_VOPAMP3 (3)
  3988. * @arg @ref LL_ADC_CHANNEL_VOPAMP4 (4)
  3989. *
  3990. * (1) On STM32F3, parameter available only on ADC instance: ADC1.\n
  3991. * (2) On STM32F3, parameter available only on ADC instance: ADC2.\n
  3992. * (3) On STM32F3, parameter available only on ADC instance: ADC3.\n
  3993. * (4) On STM32F3, parameter available only on ADC instances: ADC4.\n
  3994. * (5) On STM32F3, ADC channel available only on all ADC instances, but
  3995. * only one ADC instance is allowed to be connected to VrefInt at the same time.
  3996. * @retval None
  3997. */
  3998. __STATIC_INLINE void LL_ADC_INJ_SetSequencerRanks(ADC_TypeDef *ADCx, uint32_t Rank, uint32_t Channel)
  3999. {
  4000. /* Set bits with content of parameter "Channel" with bits position */
  4001. /* in register depending on parameter "Rank". */
  4002. /* Parameters "Rank" and "Channel" are used with masks because containing */
  4003. /* other bits reserved for other purpose. */
  4004. MODIFY_REG(ADCx->JSQR,
  4005. (ADC_CHANNEL_ID_NUMBER_MASK >> ADC_CHANNEL_ID_NUMBER_BITOFFSET_POS) << (Rank & ADC_INJ_RANK_ID_JSQR_MASK),
  4006. ((Channel & ADC_CHANNEL_ID_NUMBER_MASK) >> ADC_CHANNEL_ID_NUMBER_BITOFFSET_POS) << (Rank & ADC_INJ_RANK_ID_JSQR_MASK));
  4007. }
  4008. /**
  4009. * @brief Get ADC group injected sequence: channel on the selected
  4010. * sequence rank.
  4011. * @note Depending on devices and packages, some channels may not be available.
  4012. * Refer to device datasheet for channels availability.
  4013. * @note Usage of the returned channel number:
  4014. * - To reinject this channel into another function LL_ADC_xxx:
  4015. * the returned channel number is only partly formatted on definition
  4016. * of literals LL_ADC_CHANNEL_x. Therefore, it has to be compared
  4017. * with parts of literals LL_ADC_CHANNEL_x or using
  4018. * helper macro @ref __LL_ADC_CHANNEL_TO_DECIMAL_NB().
  4019. * Then the selected literal LL_ADC_CHANNEL_x can be used
  4020. * as parameter for another function.
  4021. * - To get the channel number in decimal format:
  4022. * process the returned value with the helper macro
  4023. * @ref __LL_ADC_CHANNEL_TO_DECIMAL_NB().
  4024. * @rmtoll JSQR JSQ1 LL_ADC_INJ_GetSequencerRanks\n
  4025. * JSQR JSQ2 LL_ADC_INJ_GetSequencerRanks\n
  4026. * JSQR JSQ3 LL_ADC_INJ_GetSequencerRanks\n
  4027. * JSQR JSQ4 LL_ADC_INJ_GetSequencerRanks
  4028. * @param ADCx ADC instance
  4029. * @param Rank This parameter can be one of the following values:
  4030. * @arg @ref LL_ADC_INJ_RANK_1
  4031. * @arg @ref LL_ADC_INJ_RANK_2
  4032. * @arg @ref LL_ADC_INJ_RANK_3
  4033. * @arg @ref LL_ADC_INJ_RANK_4
  4034. * @retval Returned value can be one of the following values:
  4035. * @arg @ref LL_ADC_CHANNEL_0
  4036. * @arg @ref LL_ADC_CHANNEL_1
  4037. * @arg @ref LL_ADC_CHANNEL_2
  4038. * @arg @ref LL_ADC_CHANNEL_3
  4039. * @arg @ref LL_ADC_CHANNEL_4
  4040. * @arg @ref LL_ADC_CHANNEL_5
  4041. * @arg @ref LL_ADC_CHANNEL_6
  4042. * @arg @ref LL_ADC_CHANNEL_7
  4043. * @arg @ref LL_ADC_CHANNEL_8
  4044. * @arg @ref LL_ADC_CHANNEL_9
  4045. * @arg @ref LL_ADC_CHANNEL_10
  4046. * @arg @ref LL_ADC_CHANNEL_11
  4047. * @arg @ref LL_ADC_CHANNEL_12
  4048. * @arg @ref LL_ADC_CHANNEL_13
  4049. * @arg @ref LL_ADC_CHANNEL_14
  4050. * @arg @ref LL_ADC_CHANNEL_15
  4051. * @arg @ref LL_ADC_CHANNEL_16
  4052. * @arg @ref LL_ADC_CHANNEL_17
  4053. * @arg @ref LL_ADC_CHANNEL_18
  4054. * @arg @ref LL_ADC_CHANNEL_VREFINT (5)
  4055. * @arg @ref LL_ADC_CHANNEL_TEMPSENSOR (1)
  4056. * @arg @ref LL_ADC_CHANNEL_VBAT (1)
  4057. * @arg @ref LL_ADC_CHANNEL_VOPAMP1 (1)
  4058. * @arg @ref LL_ADC_CHANNEL_VOPAMP2 (2)
  4059. * @arg @ref LL_ADC_CHANNEL_VOPAMP3 (3)
  4060. * @arg @ref LL_ADC_CHANNEL_VOPAMP4 (4)
  4061. *
  4062. * (1) On STM32F3, parameter available only on ADC instance: ADC1.\n
  4063. * (2) On STM32F3, parameter available only on ADC instance: ADC2.\n
  4064. * (3) On STM32F3, parameter available only on ADC instance: ADC3.\n
  4065. * (4) On STM32F3, parameter available only on ADC instances: ADC4.\n
  4066. * (5) On STM32F3, ADC channel available only on all ADC instances, but
  4067. * only one ADC instance is allowed to be connected to VrefInt at the same time.\n
  4068. * (1, 2, 3, 4, 5) For ADC channel read back from ADC register,
  4069. * comparison with internal channel parameter to be done
  4070. * using helper macro @ref __LL_ADC_CHANNEL_INTERNAL_TO_EXTERNAL().
  4071. */
  4072. __STATIC_INLINE uint32_t LL_ADC_INJ_GetSequencerRanks(ADC_TypeDef *ADCx, uint32_t Rank)
  4073. {
  4074. return (uint32_t)((READ_BIT(ADCx->JSQR,
  4075. (ADC_CHANNEL_ID_NUMBER_MASK >> ADC_CHANNEL_ID_NUMBER_BITOFFSET_POS) << (Rank & ADC_INJ_RANK_ID_JSQR_MASK))
  4076. >> (Rank & ADC_INJ_RANK_ID_JSQR_MASK)) << ADC_CHANNEL_ID_NUMBER_BITOFFSET_POS
  4077. );
  4078. }
  4079. /**
  4080. * @brief Set ADC group injected conversion trigger:
  4081. * independent or from ADC group regular.
  4082. * @note This mode can be used to extend number of data registers
  4083. * updated after one ADC conversion trigger and with data
  4084. * permanently kept (not erased by successive conversions of scan of
  4085. * ADC sequencer ranks), up to 5 data registers:
  4086. * 1 data register on ADC group regular, 4 data registers
  4087. * on ADC group injected.
  4088. * @note If ADC group injected injected trigger source is set to an
  4089. * external trigger, this feature must be must be set to
  4090. * independent trigger.
  4091. * ADC group injected automatic trigger is compliant only with
  4092. * group injected trigger source set to SW start, without any
  4093. * further action on ADC group injected conversion start or stop:
  4094. * in this case, ADC group injected is controlled only
  4095. * from ADC group regular.
  4096. * @note It is not possible to enable both ADC group injected
  4097. * auto-injected mode and sequencer discontinuous mode.
  4098. * @note On this STM32 series, setting of this feature is conditioned to
  4099. * ADC state:
  4100. * ADC must be disabled or enabled without conversion on going
  4101. * on either groups regular or injected.
  4102. * @rmtoll CFGR JAUTO LL_ADC_INJ_SetTrigAuto
  4103. * @param ADCx ADC instance
  4104. * @param TrigAuto This parameter can be one of the following values:
  4105. * @arg @ref LL_ADC_INJ_TRIG_INDEPENDENT
  4106. * @arg @ref LL_ADC_INJ_TRIG_FROM_GRP_REGULAR
  4107. * @retval None
  4108. */
  4109. __STATIC_INLINE void LL_ADC_INJ_SetTrigAuto(ADC_TypeDef *ADCx, uint32_t TrigAuto)
  4110. {
  4111. MODIFY_REG(ADCx->CFGR, ADC_CFGR_JAUTO, TrigAuto);
  4112. }
  4113. /**
  4114. * @brief Get ADC group injected conversion trigger:
  4115. * independent or from ADC group regular.
  4116. * @rmtoll CFGR JAUTO LL_ADC_INJ_GetTrigAuto
  4117. * @param ADCx ADC instance
  4118. * @retval Returned value can be one of the following values:
  4119. * @arg @ref LL_ADC_INJ_TRIG_INDEPENDENT
  4120. * @arg @ref LL_ADC_INJ_TRIG_FROM_GRP_REGULAR
  4121. */
  4122. __STATIC_INLINE uint32_t LL_ADC_INJ_GetTrigAuto(ADC_TypeDef *ADCx)
  4123. {
  4124. return (uint32_t)(READ_BIT(ADCx->CFGR, ADC_CFGR_JAUTO));
  4125. }
  4126. /**
  4127. * @brief Set ADC group injected contexts queue mode.
  4128. * @note A context is a setting of group injected sequencer:
  4129. * - group injected trigger
  4130. * - sequencer length
  4131. * - sequencer ranks
  4132. * If contexts queue is disabled:
  4133. * - only 1 sequence can be configured
  4134. * and is active perpetually.
  4135. * If contexts queue is enabled:
  4136. * - up to 2 contexts can be queued
  4137. * and are checked in and out as a FIFO stack (first-in, first-out).
  4138. * - If a new context is set when queues is full, error is triggered
  4139. * by interruption "Injected Queue Overflow".
  4140. * - Two behaviors are possible when all contexts have been processed:
  4141. * the contexts queue can maintain the last context active perpetually
  4142. * or can be empty and injected group triggers are disabled.
  4143. * - Triggers can be only external (not internal SW start)
  4144. * - Caution: The sequence must be fully configured in one time
  4145. * (one write of register JSQR makes a check-in of a new context
  4146. * into the queue).
  4147. * Therefore functions to set separately injected trigger and
  4148. * sequencer channels cannot be used, register JSQR must be set
  4149. * using function @ref LL_ADC_INJ_ConfigQueueContext().
  4150. * @note This parameter can be modified only when no conversion is on going
  4151. * on either groups regular or injected.
  4152. * @note A modification of the context mode (bit JQDIS) causes the contexts
  4153. * queue to be flushed and the register JSQR is cleared.
  4154. * @note On this STM32 series, setting of this feature is conditioned to
  4155. * ADC state:
  4156. * ADC must be disabled or enabled without conversion on going
  4157. * on either groups regular or injected.
  4158. * @rmtoll CFGR JQM LL_ADC_INJ_SetQueueMode
  4159. * @param ADCx ADC instance
  4160. * @param QueueMode This parameter can be one of the following values:
  4161. * @arg @ref LL_ADC_INJ_QUEUE_2CONTEXTS_LAST_ACTIVE
  4162. * @arg @ref LL_ADC_INJ_QUEUE_2CONTEXTS_END_EMPTY
  4163. * @retval None
  4164. */
  4165. __STATIC_INLINE void LL_ADC_INJ_SetQueueMode(ADC_TypeDef *ADCx, uint32_t QueueMode)
  4166. {
  4167. MODIFY_REG(ADCx->CFGR, ADC_CFGR_JQM, QueueMode);
  4168. }
  4169. /**
  4170. * @brief Get ADC group injected context queue mode.
  4171. * @rmtoll CFGR JQM LL_ADC_INJ_GetQueueMode
  4172. * @param ADCx ADC instance
  4173. * @retval Returned value can be one of the following values:
  4174. * @arg @ref LL_ADC_INJ_QUEUE_2CONTEXTS_LAST_ACTIVE
  4175. * @arg @ref LL_ADC_INJ_QUEUE_2CONTEXTS_END_EMPTY
  4176. */
  4177. __STATIC_INLINE uint32_t LL_ADC_INJ_GetQueueMode(ADC_TypeDef *ADCx)
  4178. {
  4179. return (uint32_t)(READ_BIT(ADCx->CFGR, ADC_CFGR_JQM));
  4180. }
  4181. /**
  4182. * @brief Set one context on ADC group injected that will be checked in
  4183. * contexts queue.
  4184. * @note A context is a setting of group injected sequencer:
  4185. * - group injected trigger
  4186. * - sequencer length
  4187. * - sequencer ranks
  4188. * This function is intended to be used when contexts queue is enabled,
  4189. * because the sequence must be fully configured in one time
  4190. * (functions to set separately injected trigger and sequencer channels
  4191. * cannot be used):
  4192. * Refer to function @ref LL_ADC_INJ_SetQueueMode().
  4193. * @note In the contexts queue, only the active context can be read.
  4194. * The parameters of this function can be read using functions:
  4195. * @arg @ref LL_ADC_INJ_GetTriggerSource()
  4196. * @arg @ref LL_ADC_INJ_GetTriggerEdge()
  4197. * @arg @ref LL_ADC_INJ_GetSequencerRanks()
  4198. * @note On this STM32 series, to measure internal channels (VrefInt,
  4199. * TempSensor, ...), measurement paths to internal channels must be
  4200. * enabled separately.
  4201. * This can be done using function @ref LL_ADC_SetCommonPathInternalCh().
  4202. * @note On this STM32 series, setting of this feature is conditioned to
  4203. * ADC state:
  4204. * ADC must not be disabled. Can be enabled with or without conversion
  4205. * on going on either groups regular or injected.
  4206. * @rmtoll JSQR JEXTSEL LL_ADC_INJ_ConfigQueueContext\n
  4207. * JSQR JEXTEN LL_ADC_INJ_ConfigQueueContext\n
  4208. * JSQR JL LL_ADC_INJ_ConfigQueueContext\n
  4209. * JSQR JSQ1 LL_ADC_INJ_ConfigQueueContext\n
  4210. * JSQR JSQ2 LL_ADC_INJ_ConfigQueueContext\n
  4211. * JSQR JSQ3 LL_ADC_INJ_ConfigQueueContext\n
  4212. * JSQR JSQ4 LL_ADC_INJ_ConfigQueueContext
  4213. * @param ADCx ADC instance
  4214. * @param TriggerSource This parameter can be one of the following values:
  4215. * @arg @ref LL_ADC_INJ_TRIG_SOFTWARE
  4216. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM1_TRGO
  4217. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM1_TRGO2
  4218. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM1_CH3_ADC34 (1)(2) (8)
  4219. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM1_CH4
  4220. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM2_TRGO (3)(4)(5)
  4221. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM2_TRGO_ADC12 (1)(2) (7)
  4222. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM2_TRGO__ADC34 (1)(2) (8)
  4223. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM2_CH1 (3)(4)(5)
  4224. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM2_CH1_ADC12 (1)(2) (7)
  4225. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM3_TRGO (1)(2)(3)(4)(5)
  4226. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM3_CH1 (3)(4)(5)
  4227. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM3_CH1_ADC12 (1)(2) (7)
  4228. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM3_CH3 (3)(4)(5)
  4229. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM3_CH3_ADC12 (1)(2) (7)
  4230. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM3_CH4 (3)(4)(5)
  4231. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM3_CH4_ADC12 (1)(2)(3)(4)(5) (7)
  4232. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM4_TRGO (3) (5)
  4233. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM4_TRGO_ADC12 (1)(2) (7)
  4234. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM4_TRGO__ADC34 (1)(2) (8)
  4235. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM4_CH3_ADC34 (1)(2) (8)
  4236. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM4_CH4_ADC34 (1)(2) (8)
  4237. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM6_TRGO (3)(4)(5)
  4238. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM6_TRGO_ADC12 (1)(2) (7)
  4239. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM7_TRGO_ADC34 (1)(2) (8)
  4240. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM8_TRGO (1)(2)
  4241. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM8_TRGO2 (1)(2)
  4242. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM8_CH2_ADC34 (1)(2) (8)
  4243. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM8_CH4_ADC12 (1)(2) (7)
  4244. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM8_CH4__ADC34 (1)(2) (8)
  4245. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM15_TRGO
  4246. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM20_TRGO_ADC12 (1) (7)
  4247. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM20_TRGO2_ADC12 (1) (7)
  4248. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM20_CH4_ADC12 (1) (7)
  4249. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM20_TRG_ADC34 (1) (8)
  4250. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM20_TRG2_ADC34 (1) (8)
  4251. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM20_CH2_ADC34 (1) (8)
  4252. * @arg @ref LL_ADC_INJ_TRIG_EXT_HRTIM_TRG2 (4)
  4253. * @arg @ref LL_ADC_INJ_TRIG_EXT_HRTIM_TRG4 (4)
  4254. * @arg @ref LL_ADC_INJ_TRIG_EXT_EXTI_LINE15 (3)(4)(5)(6)
  4255. * @arg @ref LL_ADC_INJ_TRIG_EXT_EXTI_LINE15_ADC12 (1)(2) (7)
  4256. *
  4257. * (1) On STM32F3, parameter not available on all devices: among others, on STM32F303xE, STM32F398xx.\n
  4258. * (2) On STM32F3, parameter not available on all devices: among others, on STM32F303xC, STM32F358xx.\n
  4259. * (3) On STM32F3, parameter not available on all devices: among others, on STM32F303x8, STM32F328xx.\n
  4260. * (4) On STM32F3, parameter not available on all devices: among others, on STM32F334x8.\n
  4261. * (5) On STM32F3, parameter not available on all devices: among others, on STM32F302xC, STM32F302xE.\n
  4262. * (6) On STM32F3, parameter not available on all devices: among others, on STM32F301x8, STM32F302x8, STM32F318xx.\n
  4263. * (7) On STM32F3, parameter not available on all ADC instances: ADC1, ADC2 (for ADC instances ADCx available on the selected device).\n
  4264. * (8) On STM32F3, parameter not available on all ADC instances: ADC3, ADC4 (for ADC instances ADCx available on the selected device).
  4265. * @param ExternalTriggerEdge This parameter can be one of the following values:
  4266. * @arg @ref LL_ADC_INJ_TRIG_EXT_RISING
  4267. * @arg @ref LL_ADC_INJ_TRIG_EXT_FALLING
  4268. * @arg @ref LL_ADC_INJ_TRIG_EXT_RISINGFALLING
  4269. *
  4270. * Note: This parameter is discarded in case of SW start:
  4271. * parameter "TriggerSource" set to "LL_ADC_INJ_TRIG_SOFTWARE".
  4272. * @param SequencerNbRanks This parameter can be one of the following values:
  4273. * @arg @ref LL_ADC_INJ_SEQ_SCAN_DISABLE
  4274. * @arg @ref LL_ADC_INJ_SEQ_SCAN_ENABLE_2RANKS
  4275. * @arg @ref LL_ADC_INJ_SEQ_SCAN_ENABLE_3RANKS
  4276. * @arg @ref LL_ADC_INJ_SEQ_SCAN_ENABLE_4RANKS
  4277. * @param Rank1_Channel This parameter can be one of the following values:
  4278. * @arg @ref LL_ADC_CHANNEL_0
  4279. * @arg @ref LL_ADC_CHANNEL_1
  4280. * @arg @ref LL_ADC_CHANNEL_2
  4281. * @arg @ref LL_ADC_CHANNEL_3
  4282. * @arg @ref LL_ADC_CHANNEL_4
  4283. * @arg @ref LL_ADC_CHANNEL_5
  4284. * @arg @ref LL_ADC_CHANNEL_6
  4285. * @arg @ref LL_ADC_CHANNEL_7
  4286. * @arg @ref LL_ADC_CHANNEL_8
  4287. * @arg @ref LL_ADC_CHANNEL_9
  4288. * @arg @ref LL_ADC_CHANNEL_10
  4289. * @arg @ref LL_ADC_CHANNEL_11
  4290. * @arg @ref LL_ADC_CHANNEL_12
  4291. * @arg @ref LL_ADC_CHANNEL_13
  4292. * @arg @ref LL_ADC_CHANNEL_14
  4293. * @arg @ref LL_ADC_CHANNEL_15
  4294. * @arg @ref LL_ADC_CHANNEL_16
  4295. * @arg @ref LL_ADC_CHANNEL_17
  4296. * @arg @ref LL_ADC_CHANNEL_18
  4297. * @arg @ref LL_ADC_CHANNEL_VREFINT (5)
  4298. * @arg @ref LL_ADC_CHANNEL_TEMPSENSOR (1)
  4299. * @arg @ref LL_ADC_CHANNEL_VBAT (1)
  4300. * @arg @ref LL_ADC_CHANNEL_VOPAMP1 (1)
  4301. * @arg @ref LL_ADC_CHANNEL_VOPAMP2 (2)
  4302. * @arg @ref LL_ADC_CHANNEL_VOPAMP3 (3)
  4303. * @arg @ref LL_ADC_CHANNEL_VOPAMP4 (4)
  4304. *
  4305. * (1) On STM32F3, parameter available only on ADC instance: ADC1.\n
  4306. * (2) On STM32F3, parameter available only on ADC instance: ADC2.\n
  4307. * (3) On STM32F3, parameter available only on ADC instance: ADC3.\n
  4308. * (4) On STM32F3, parameter available only on ADC instances: ADC4.\n
  4309. * (5) On STM32F3, ADC channel available only on all ADC instances, but
  4310. * only one ADC instance is allowed to be connected to VrefInt at the same time.
  4311. * @param Rank2_Channel This parameter can be one of the following values:
  4312. * @arg @ref LL_ADC_CHANNEL_0
  4313. * @arg @ref LL_ADC_CHANNEL_1
  4314. * @arg @ref LL_ADC_CHANNEL_2
  4315. * @arg @ref LL_ADC_CHANNEL_3
  4316. * @arg @ref LL_ADC_CHANNEL_4
  4317. * @arg @ref LL_ADC_CHANNEL_5
  4318. * @arg @ref LL_ADC_CHANNEL_6
  4319. * @arg @ref LL_ADC_CHANNEL_7
  4320. * @arg @ref LL_ADC_CHANNEL_8
  4321. * @arg @ref LL_ADC_CHANNEL_9
  4322. * @arg @ref LL_ADC_CHANNEL_10
  4323. * @arg @ref LL_ADC_CHANNEL_11
  4324. * @arg @ref LL_ADC_CHANNEL_12
  4325. * @arg @ref LL_ADC_CHANNEL_13
  4326. * @arg @ref LL_ADC_CHANNEL_14
  4327. * @arg @ref LL_ADC_CHANNEL_15
  4328. * @arg @ref LL_ADC_CHANNEL_16
  4329. * @arg @ref LL_ADC_CHANNEL_17
  4330. * @arg @ref LL_ADC_CHANNEL_18
  4331. * @arg @ref LL_ADC_CHANNEL_VREFINT (5)
  4332. * @arg @ref LL_ADC_CHANNEL_TEMPSENSOR (1)
  4333. * @arg @ref LL_ADC_CHANNEL_VBAT (1)
  4334. * @arg @ref LL_ADC_CHANNEL_VOPAMP1 (1)
  4335. * @arg @ref LL_ADC_CHANNEL_VOPAMP2 (2)
  4336. * @arg @ref LL_ADC_CHANNEL_VOPAMP3 (3)
  4337. * @arg @ref LL_ADC_CHANNEL_VOPAMP4 (4)
  4338. *
  4339. * (1) On STM32F3, parameter available only on ADC instance: ADC1.\n
  4340. * (2) On STM32F3, parameter available only on ADC instance: ADC2.\n
  4341. * (3) On STM32F3, parameter available only on ADC instance: ADC3.\n
  4342. * (4) On STM32F3, parameter available only on ADC instances: ADC4.\n
  4343. * (5) On STM32F3, ADC channel available only on all ADC instances, but
  4344. * only one ADC instance is allowed to be connected to VrefInt at the same time.
  4345. * @param Rank3_Channel This parameter can be one of the following values:
  4346. * @arg @ref LL_ADC_CHANNEL_0
  4347. * @arg @ref LL_ADC_CHANNEL_1
  4348. * @arg @ref LL_ADC_CHANNEL_2
  4349. * @arg @ref LL_ADC_CHANNEL_3
  4350. * @arg @ref LL_ADC_CHANNEL_4
  4351. * @arg @ref LL_ADC_CHANNEL_5
  4352. * @arg @ref LL_ADC_CHANNEL_6
  4353. * @arg @ref LL_ADC_CHANNEL_7
  4354. * @arg @ref LL_ADC_CHANNEL_8
  4355. * @arg @ref LL_ADC_CHANNEL_9
  4356. * @arg @ref LL_ADC_CHANNEL_10
  4357. * @arg @ref LL_ADC_CHANNEL_11
  4358. * @arg @ref LL_ADC_CHANNEL_12
  4359. * @arg @ref LL_ADC_CHANNEL_13
  4360. * @arg @ref LL_ADC_CHANNEL_14
  4361. * @arg @ref LL_ADC_CHANNEL_15
  4362. * @arg @ref LL_ADC_CHANNEL_16
  4363. * @arg @ref LL_ADC_CHANNEL_17
  4364. * @arg @ref LL_ADC_CHANNEL_18
  4365. * @arg @ref LL_ADC_CHANNEL_VREFINT (5)
  4366. * @arg @ref LL_ADC_CHANNEL_TEMPSENSOR (1)
  4367. * @arg @ref LL_ADC_CHANNEL_VBAT (1)
  4368. * @arg @ref LL_ADC_CHANNEL_VOPAMP1 (1)
  4369. * @arg @ref LL_ADC_CHANNEL_VOPAMP2 (2)
  4370. * @arg @ref LL_ADC_CHANNEL_VOPAMP3 (3)
  4371. * @arg @ref LL_ADC_CHANNEL_VOPAMP4 (4)
  4372. *
  4373. * (1) On STM32F3, parameter available only on ADC instance: ADC1.\n
  4374. * (2) On STM32F3, parameter available only on ADC instance: ADC2.\n
  4375. * (3) On STM32F3, parameter available only on ADC instance: ADC3.\n
  4376. * (4) On STM32F3, parameter available only on ADC instances: ADC4.\n
  4377. * (5) On STM32F3, ADC channel available only on all ADC instances, but
  4378. * only one ADC instance is allowed to be connected to VrefInt at the same time.
  4379. * @param Rank4_Channel This parameter can be one of the following values:
  4380. * @arg @ref LL_ADC_CHANNEL_0
  4381. * @arg @ref LL_ADC_CHANNEL_1
  4382. * @arg @ref LL_ADC_CHANNEL_2
  4383. * @arg @ref LL_ADC_CHANNEL_3
  4384. * @arg @ref LL_ADC_CHANNEL_4
  4385. * @arg @ref LL_ADC_CHANNEL_5
  4386. * @arg @ref LL_ADC_CHANNEL_6
  4387. * @arg @ref LL_ADC_CHANNEL_7
  4388. * @arg @ref LL_ADC_CHANNEL_8
  4389. * @arg @ref LL_ADC_CHANNEL_9
  4390. * @arg @ref LL_ADC_CHANNEL_10
  4391. * @arg @ref LL_ADC_CHANNEL_11
  4392. * @arg @ref LL_ADC_CHANNEL_12
  4393. * @arg @ref LL_ADC_CHANNEL_13
  4394. * @arg @ref LL_ADC_CHANNEL_14
  4395. * @arg @ref LL_ADC_CHANNEL_15
  4396. * @arg @ref LL_ADC_CHANNEL_16
  4397. * @arg @ref LL_ADC_CHANNEL_17
  4398. * @arg @ref LL_ADC_CHANNEL_18
  4399. * @arg @ref LL_ADC_CHANNEL_VREFINT (5)
  4400. * @arg @ref LL_ADC_CHANNEL_TEMPSENSOR (1)
  4401. * @arg @ref LL_ADC_CHANNEL_VBAT (1)
  4402. * @arg @ref LL_ADC_CHANNEL_VOPAMP1 (1)
  4403. * @arg @ref LL_ADC_CHANNEL_VOPAMP2 (2)
  4404. * @arg @ref LL_ADC_CHANNEL_VOPAMP3 (3)
  4405. * @arg @ref LL_ADC_CHANNEL_VOPAMP4 (4)
  4406. *
  4407. * (1) On STM32F3, parameter available only on ADC instance: ADC1.\n
  4408. * (2) On STM32F3, parameter available only on ADC instance: ADC2.\n
  4409. * (3) On STM32F3, parameter available only on ADC instance: ADC3.\n
  4410. * (4) On STM32F3, parameter available only on ADC instances: ADC4.\n
  4411. * (5) On STM32F3, ADC channel available only on all ADC instances, but
  4412. * only one ADC instance is allowed to be connected to VrefInt at the same time.
  4413. * @retval None
  4414. */
  4415. __STATIC_INLINE void LL_ADC_INJ_ConfigQueueContext(ADC_TypeDef *ADCx,
  4416. uint32_t TriggerSource,
  4417. uint32_t ExternalTriggerEdge,
  4418. uint32_t SequencerNbRanks,
  4419. uint32_t Rank1_Channel,
  4420. uint32_t Rank2_Channel,
  4421. uint32_t Rank3_Channel,
  4422. uint32_t Rank4_Channel)
  4423. {
  4424. /* Set bits with content of parameter "Rankx_Channel" with bits position */
  4425. /* in register depending on literal "LL_ADC_INJ_RANK_x". */
  4426. /* Parameters "Rankx_Channel" and "LL_ADC_INJ_RANK_x" are used with masks */
  4427. /* because containing other bits reserved for other purpose. */
  4428. /* If parameter "TriggerSource" is set to SW start, then parameter */
  4429. /* "ExternalTriggerEdge" is discarded. */
  4430. MODIFY_REG(ADCx->JSQR ,
  4431. ADC_JSQR_JEXTSEL |
  4432. ADC_JSQR_JEXTEN |
  4433. ADC_JSQR_JSQ4 |
  4434. ADC_JSQR_JSQ3 |
  4435. ADC_JSQR_JSQ2 |
  4436. ADC_JSQR_JSQ1 |
  4437. ADC_JSQR_JL ,
  4438. TriggerSource |
  4439. (ExternalTriggerEdge * ((TriggerSource != LL_ADC_INJ_TRIG_SOFTWARE))) |
  4440. ((Rank4_Channel & ADC_CHANNEL_ID_NUMBER_MASK) >> (ADC_CHANNEL_ID_NUMBER_BITOFFSET_POS - (LL_ADC_INJ_RANK_4 & ADC_INJ_RANK_ID_JSQR_MASK))) |
  4441. ((Rank3_Channel & ADC_CHANNEL_ID_NUMBER_MASK) >> (ADC_CHANNEL_ID_NUMBER_BITOFFSET_POS - (LL_ADC_INJ_RANK_3 & ADC_INJ_RANK_ID_JSQR_MASK))) |
  4442. ((Rank2_Channel & ADC_CHANNEL_ID_NUMBER_MASK) >> (ADC_CHANNEL_ID_NUMBER_BITOFFSET_POS - (LL_ADC_INJ_RANK_2 & ADC_INJ_RANK_ID_JSQR_MASK))) |
  4443. ((Rank1_Channel & ADC_CHANNEL_ID_NUMBER_MASK) >> (ADC_CHANNEL_ID_NUMBER_BITOFFSET_POS - (LL_ADC_INJ_RANK_1 & ADC_INJ_RANK_ID_JSQR_MASK))) |
  4444. SequencerNbRanks
  4445. );
  4446. }
  4447. /**
  4448. * @}
  4449. */
  4450. /** @defgroup ADC_LL_EF_Configuration_Channels Configuration of ADC hierarchical scope: channels
  4451. * @{
  4452. */
  4453. /**
  4454. * @brief Set sampling time of the selected ADC channel
  4455. * Unit: ADC clock cycles.
  4456. * @note On this device, sampling time is on channel scope: independently
  4457. * of channel mapped on ADC group regular or injected.
  4458. * @note In case of internal channel (VrefInt, TempSensor, ...) to be
  4459. * converted:
  4460. * sampling time constraints must be respected (sampling time can be
  4461. * adjusted in function of ADC clock frequency and sampling time
  4462. * setting).
  4463. * Refer to device datasheet for timings values (parameters TS_vrefint,
  4464. * TS_temp, ...).
  4465. * @note Conversion time is the addition of sampling time and processing time.
  4466. * On this STM32 series, ADC processing time is:
  4467. * - 12.5 ADC clock cycles at ADC resolution 12 bits
  4468. * - 10.5 ADC clock cycles at ADC resolution 10 bits
  4469. * - 8.5 ADC clock cycles at ADC resolution 8 bits
  4470. * - 6.5 ADC clock cycles at ADC resolution 6 bits
  4471. * @note In case of ADC conversion of internal channel (VrefInt,
  4472. * temperature sensor, ...), a sampling time minimum value
  4473. * is required.
  4474. * Refer to device datasheet.
  4475. * @note On this STM32 series, setting of this feature is conditioned to
  4476. * ADC state:
  4477. * ADC must be disabled or enabled without conversion on going
  4478. * on either groups regular or injected.
  4479. * @rmtoll SMPR1 SMP0 LL_ADC_SetChannelSamplingTime\n
  4480. * SMPR1 SMP1 LL_ADC_SetChannelSamplingTime\n
  4481. * SMPR1 SMP2 LL_ADC_SetChannelSamplingTime\n
  4482. * SMPR1 SMP3 LL_ADC_SetChannelSamplingTime\n
  4483. * SMPR1 SMP4 LL_ADC_SetChannelSamplingTime\n
  4484. * SMPR1 SMP5 LL_ADC_SetChannelSamplingTime\n
  4485. * SMPR1 SMP6 LL_ADC_SetChannelSamplingTime\n
  4486. * SMPR1 SMP7 LL_ADC_SetChannelSamplingTime\n
  4487. * SMPR1 SMP8 LL_ADC_SetChannelSamplingTime\n
  4488. * SMPR1 SMP9 LL_ADC_SetChannelSamplingTime\n
  4489. * SMPR2 SMP10 LL_ADC_SetChannelSamplingTime\n
  4490. * SMPR2 SMP11 LL_ADC_SetChannelSamplingTime\n
  4491. * SMPR2 SMP12 LL_ADC_SetChannelSamplingTime\n
  4492. * SMPR2 SMP13 LL_ADC_SetChannelSamplingTime\n
  4493. * SMPR2 SMP14 LL_ADC_SetChannelSamplingTime\n
  4494. * SMPR2 SMP15 LL_ADC_SetChannelSamplingTime\n
  4495. * SMPR2 SMP16 LL_ADC_SetChannelSamplingTime\n
  4496. * SMPR2 SMP17 LL_ADC_SetChannelSamplingTime\n
  4497. * SMPR2 SMP18 LL_ADC_SetChannelSamplingTime
  4498. * @param ADCx ADC instance
  4499. * @param Channel This parameter can be one of the following values:
  4500. * @arg @ref LL_ADC_CHANNEL_0
  4501. * @arg @ref LL_ADC_CHANNEL_1
  4502. * @arg @ref LL_ADC_CHANNEL_2
  4503. * @arg @ref LL_ADC_CHANNEL_3
  4504. * @arg @ref LL_ADC_CHANNEL_4
  4505. * @arg @ref LL_ADC_CHANNEL_5
  4506. * @arg @ref LL_ADC_CHANNEL_6
  4507. * @arg @ref LL_ADC_CHANNEL_7
  4508. * @arg @ref LL_ADC_CHANNEL_8
  4509. * @arg @ref LL_ADC_CHANNEL_9
  4510. * @arg @ref LL_ADC_CHANNEL_10
  4511. * @arg @ref LL_ADC_CHANNEL_11
  4512. * @arg @ref LL_ADC_CHANNEL_12
  4513. * @arg @ref LL_ADC_CHANNEL_13
  4514. * @arg @ref LL_ADC_CHANNEL_14
  4515. * @arg @ref LL_ADC_CHANNEL_15
  4516. * @arg @ref LL_ADC_CHANNEL_16
  4517. * @arg @ref LL_ADC_CHANNEL_17
  4518. * @arg @ref LL_ADC_CHANNEL_18
  4519. * @arg @ref LL_ADC_CHANNEL_VREFINT (5)
  4520. * @arg @ref LL_ADC_CHANNEL_TEMPSENSOR (1)
  4521. * @arg @ref LL_ADC_CHANNEL_VBAT (1)
  4522. * @arg @ref LL_ADC_CHANNEL_VOPAMP1 (1)
  4523. * @arg @ref LL_ADC_CHANNEL_VOPAMP2 (2)
  4524. * @arg @ref LL_ADC_CHANNEL_VOPAMP3 (3)
  4525. * @arg @ref LL_ADC_CHANNEL_VOPAMP4 (4)
  4526. *
  4527. * (1) On STM32F3, parameter available only on ADC instance: ADC1.\n
  4528. * (2) On STM32F3, parameter available only on ADC instance: ADC2.\n
  4529. * (3) On STM32F3, parameter available only on ADC instance: ADC3.\n
  4530. * (4) On STM32F3, parameter available only on ADC instances: ADC4.\n
  4531. * (5) On STM32F3, ADC channel available only on all ADC instances, but
  4532. * only one ADC instance is allowed to be connected to VrefInt at the same time.
  4533. * @param SamplingTime This parameter can be one of the following values:
  4534. * @arg @ref LL_ADC_SAMPLINGTIME_1CYCLE_5
  4535. * @arg @ref LL_ADC_SAMPLINGTIME_2CYCLES_5
  4536. * @arg @ref LL_ADC_SAMPLINGTIME_4CYCLES_5
  4537. * @arg @ref LL_ADC_SAMPLINGTIME_7CYCLES_5
  4538. * @arg @ref LL_ADC_SAMPLINGTIME_19CYCLES_5
  4539. * @arg @ref LL_ADC_SAMPLINGTIME_61CYCLES_5
  4540. * @arg @ref LL_ADC_SAMPLINGTIME_181CYCLES_5
  4541. * @arg @ref LL_ADC_SAMPLINGTIME_601CYCLES_5
  4542. * @retval None
  4543. */
  4544. __STATIC_INLINE void LL_ADC_SetChannelSamplingTime(ADC_TypeDef *ADCx, uint32_t Channel, uint32_t SamplingTime)
  4545. {
  4546. /* Set bits with content of parameter "SamplingTime" with bits position */
  4547. /* in register and register position depending on parameter "Channel". */
  4548. /* Parameter "Channel" is used with masks because containing */
  4549. /* other bits reserved for other purpose. */
  4550. __IO uint32_t *preg = __ADC_PTR_REG_OFFSET(ADCx->SMPR1, __ADC_MASK_SHIFT(Channel, ADC_CHANNEL_SMPRX_REGOFFSET_MASK));
  4551. MODIFY_REG(*preg,
  4552. ADC_SMPR1_SMP0 << __ADC_MASK_SHIFT(Channel, ADC_CHANNEL_SMPx_BITOFFSET_MASK),
  4553. SamplingTime << __ADC_MASK_SHIFT(Channel, ADC_CHANNEL_SMPx_BITOFFSET_MASK));
  4554. }
  4555. /**
  4556. * @brief Get sampling time of the selected ADC channel
  4557. * Unit: ADC clock cycles.
  4558. * @note On this device, sampling time is on channel scope: independently
  4559. * of channel mapped on ADC group regular or injected.
  4560. * @note Conversion time is the addition of sampling time and processing time.
  4561. * On this STM32 series, ADC processing time is:
  4562. * - 12.5 ADC clock cycles at ADC resolution 12 bits
  4563. * - 10.5 ADC clock cycles at ADC resolution 10 bits
  4564. * - 8.5 ADC clock cycles at ADC resolution 8 bits
  4565. * - 6.5 ADC clock cycles at ADC resolution 6 bits
  4566. * @rmtoll SMPR1 SMP0 LL_ADC_GetChannelSamplingTime\n
  4567. * SMPR1 SMP1 LL_ADC_GetChannelSamplingTime\n
  4568. * SMPR1 SMP2 LL_ADC_GetChannelSamplingTime\n
  4569. * SMPR1 SMP3 LL_ADC_GetChannelSamplingTime\n
  4570. * SMPR1 SMP4 LL_ADC_GetChannelSamplingTime\n
  4571. * SMPR1 SMP5 LL_ADC_GetChannelSamplingTime\n
  4572. * SMPR1 SMP6 LL_ADC_GetChannelSamplingTime\n
  4573. * SMPR1 SMP7 LL_ADC_GetChannelSamplingTime\n
  4574. * SMPR1 SMP8 LL_ADC_GetChannelSamplingTime\n
  4575. * SMPR1 SMP9 LL_ADC_GetChannelSamplingTime\n
  4576. * SMPR2 SMP10 LL_ADC_GetChannelSamplingTime\n
  4577. * SMPR2 SMP11 LL_ADC_GetChannelSamplingTime\n
  4578. * SMPR2 SMP12 LL_ADC_GetChannelSamplingTime\n
  4579. * SMPR2 SMP13 LL_ADC_GetChannelSamplingTime\n
  4580. * SMPR2 SMP14 LL_ADC_GetChannelSamplingTime\n
  4581. * SMPR2 SMP15 LL_ADC_GetChannelSamplingTime\n
  4582. * SMPR2 SMP16 LL_ADC_GetChannelSamplingTime\n
  4583. * SMPR2 SMP17 LL_ADC_GetChannelSamplingTime\n
  4584. * SMPR2 SMP18 LL_ADC_GetChannelSamplingTime
  4585. * @param ADCx ADC instance
  4586. * @param Channel This parameter can be one of the following values:
  4587. * @arg @ref LL_ADC_CHANNEL_0
  4588. * @arg @ref LL_ADC_CHANNEL_1
  4589. * @arg @ref LL_ADC_CHANNEL_2
  4590. * @arg @ref LL_ADC_CHANNEL_3
  4591. * @arg @ref LL_ADC_CHANNEL_4
  4592. * @arg @ref LL_ADC_CHANNEL_5
  4593. * @arg @ref LL_ADC_CHANNEL_6
  4594. * @arg @ref LL_ADC_CHANNEL_7
  4595. * @arg @ref LL_ADC_CHANNEL_8
  4596. * @arg @ref LL_ADC_CHANNEL_9
  4597. * @arg @ref LL_ADC_CHANNEL_10
  4598. * @arg @ref LL_ADC_CHANNEL_11
  4599. * @arg @ref LL_ADC_CHANNEL_12
  4600. * @arg @ref LL_ADC_CHANNEL_13
  4601. * @arg @ref LL_ADC_CHANNEL_14
  4602. * @arg @ref LL_ADC_CHANNEL_15
  4603. * @arg @ref LL_ADC_CHANNEL_16
  4604. * @arg @ref LL_ADC_CHANNEL_17
  4605. * @arg @ref LL_ADC_CHANNEL_18
  4606. * @arg @ref LL_ADC_CHANNEL_VREFINT (5)
  4607. * @arg @ref LL_ADC_CHANNEL_TEMPSENSOR (1)
  4608. * @arg @ref LL_ADC_CHANNEL_VBAT (1)
  4609. * @arg @ref LL_ADC_CHANNEL_VOPAMP1 (1)
  4610. * @arg @ref LL_ADC_CHANNEL_VOPAMP2 (2)
  4611. * @arg @ref LL_ADC_CHANNEL_VOPAMP3 (3)
  4612. * @arg @ref LL_ADC_CHANNEL_VOPAMP4 (4)
  4613. *
  4614. * (1) On STM32F3, parameter available only on ADC instance: ADC1.\n
  4615. * (2) On STM32F3, parameter available only on ADC instance: ADC2.\n
  4616. * (3) On STM32F3, parameter available only on ADC instance: ADC3.\n
  4617. * (4) On STM32F3, parameter available only on ADC instances: ADC4.\n
  4618. * (5) On STM32F3, ADC channel available only on all ADC instances, but
  4619. * only one ADC instance is allowed to be connected to VrefInt at the same time.
  4620. * @retval Returned value can be one of the following values:
  4621. * @arg @ref LL_ADC_SAMPLINGTIME_1CYCLE_5
  4622. * @arg @ref LL_ADC_SAMPLINGTIME_2CYCLES_5
  4623. * @arg @ref LL_ADC_SAMPLINGTIME_4CYCLES_5
  4624. * @arg @ref LL_ADC_SAMPLINGTIME_7CYCLES_5
  4625. * @arg @ref LL_ADC_SAMPLINGTIME_19CYCLES_5
  4626. * @arg @ref LL_ADC_SAMPLINGTIME_61CYCLES_5
  4627. * @arg @ref LL_ADC_SAMPLINGTIME_181CYCLES_5
  4628. * @arg @ref LL_ADC_SAMPLINGTIME_601CYCLES_5
  4629. */
  4630. __STATIC_INLINE uint32_t LL_ADC_GetChannelSamplingTime(ADC_TypeDef *ADCx, uint32_t Channel)
  4631. {
  4632. __IO uint32_t *preg = __ADC_PTR_REG_OFFSET(ADCx->SMPR1, __ADC_MASK_SHIFT(Channel, ADC_CHANNEL_SMPRX_REGOFFSET_MASK));
  4633. return (uint32_t)(READ_BIT(*preg,
  4634. ADC_SMPR1_SMP0 << __ADC_MASK_SHIFT(Channel, ADC_CHANNEL_SMPx_BITOFFSET_MASK))
  4635. >> __ADC_MASK_SHIFT(Channel, ADC_CHANNEL_SMPx_BITOFFSET_MASK)
  4636. );
  4637. }
  4638. /**
  4639. * @brief Set mode single-ended or differential input of the selected
  4640. * ADC channel.
  4641. * @note Channel ending is on channel scope: independently of channel mapped
  4642. * on ADC group regular or injected.
  4643. * In differential mode: Differential measurement is carried out
  4644. * between the selected channel 'i' (positive input) and
  4645. * channel 'i+1' (negative input). Only channel 'i' has to be
  4646. * configured, channel 'i+1' is configured automatically.
  4647. * @note Refer to Reference Manual to ensure the selected channel is
  4648. * available in differential mode.
  4649. * For example, internal channels (VrefInt, TempSensor, ...) are
  4650. * not available in differential mode.
  4651. * @note When configuring a channel 'i' in differential mode,
  4652. * the channel 'i+1' is not usable separately.
  4653. * @note On STM32F3, channels 16, 17, 18 of ADC1,
  4654. * channels 17, 18 of ADC2, ADC3, ADC4 (if available)
  4655. * are internally fixed to single-ended inputs configuration.
  4656. * @note For ADC channels configured in differential mode, both inputs
  4657. * should be biased at (Vref+)/2 +/-200mV.
  4658. * (Vref+ is the analog voltage reference)
  4659. * @note On this STM32 series, setting of this feature is conditioned to
  4660. * ADC state:
  4661. * ADC must be ADC disabled.
  4662. * @note One or several values can be selected.
  4663. * Example: (LL_ADC_CHANNEL_4 | LL_ADC_CHANNEL_12 | ...)
  4664. * @rmtoll DIFSEL DIFSEL LL_ADC_GetChannelSamplingTime
  4665. * @param ADCx ADC instance
  4666. * @param Channel This parameter can be one of the following values:
  4667. * @arg @ref LL_ADC_CHANNEL_1
  4668. * @arg @ref LL_ADC_CHANNEL_2
  4669. * @arg @ref LL_ADC_CHANNEL_3
  4670. * @arg @ref LL_ADC_CHANNEL_4
  4671. * @arg @ref LL_ADC_CHANNEL_5
  4672. * @arg @ref LL_ADC_CHANNEL_6
  4673. * @arg @ref LL_ADC_CHANNEL_7
  4674. * @arg @ref LL_ADC_CHANNEL_8
  4675. * @arg @ref LL_ADC_CHANNEL_9
  4676. * @arg @ref LL_ADC_CHANNEL_10
  4677. * @arg @ref LL_ADC_CHANNEL_11
  4678. * @arg @ref LL_ADC_CHANNEL_12
  4679. * @arg @ref LL_ADC_CHANNEL_13
  4680. * @arg @ref LL_ADC_CHANNEL_14
  4681. * @arg @ref LL_ADC_CHANNEL_15
  4682. * @arg @ref LL_ADC_CHANNEL_16 (1)
  4683. *
  4684. * (1) On STM32F3, parameter available only on ADC instance: ADC1.
  4685. * @param SingleDiff This parameter can be a combination of the following values:
  4686. * @arg @ref LL_ADC_SINGLE_ENDED
  4687. * @arg @ref LL_ADC_DIFFERENTIAL_ENDED
  4688. * @retval None
  4689. */
  4690. __STATIC_INLINE void LL_ADC_SetChannelSingleDiff(ADC_TypeDef *ADCx, uint32_t Channel, uint32_t SingleDiff)
  4691. {
  4692. /* Bits of channels in single or differential mode are set only for */
  4693. /* differential mode (for single mode, mask of bits allowed to be set is */
  4694. /* shifted out of range of bits of channels in single or differential mode. */
  4695. MODIFY_REG(ADCx->DIFSEL,
  4696. Channel & ADC_SINGLEDIFF_CHANNEL_MASK,
  4697. (Channel & ADC_SINGLEDIFF_CHANNEL_MASK) & (ADC_DIFSEL_DIFSEL >> (SingleDiff & ADC_SINGLEDIFF_CHANNEL_SHIFT_MASK)));
  4698. }
  4699. /**
  4700. * @brief Get mode single-ended or differential input of the selected
  4701. * ADC channel.
  4702. * @note When configuring a channel 'i' in differential mode,
  4703. * the channel 'i+1' is not usable separately.
  4704. * Therefore, to ensure a channel is configured in single-ended mode,
  4705. * the configuration of channel itself and the channel 'i-1' must be
  4706. * read back (to ensure that the selected channel channel has not been
  4707. * configured in differential mode by the previous channel).
  4708. * @note Refer to Reference Manual to ensure the selected channel is
  4709. * available in differential mode.
  4710. * For example, internal channels (VrefInt, TempSensor, ...) are
  4711. * not available in differential mode.
  4712. * @note When configuring a channel 'i' in differential mode,
  4713. * the channel 'i+1' is not usable separately.
  4714. * @note On STM32F3, channels 16, 17, 18 of ADC1,
  4715. * channels 17, 18 of ADC2, ADC3, ADC4 (if available)
  4716. * are internally fixed to single-ended inputs configuration.
  4717. * @note One or several values can be selected. In this case, the value
  4718. * returned is null if all channels are in single ended-mode.
  4719. * Example: (LL_ADC_CHANNEL_4 | LL_ADC_CHANNEL_12 | ...)
  4720. * @rmtoll DIFSEL DIFSEL LL_ADC_GetChannelSamplingTime
  4721. * @param ADCx ADC instance
  4722. * @param Channel This parameter can be a combination of the following values:
  4723. * @arg @ref LL_ADC_CHANNEL_0
  4724. * @arg @ref LL_ADC_CHANNEL_1
  4725. * @arg @ref LL_ADC_CHANNEL_2
  4726. * @arg @ref LL_ADC_CHANNEL_3
  4727. * @arg @ref LL_ADC_CHANNEL_4
  4728. * @arg @ref LL_ADC_CHANNEL_5
  4729. * @arg @ref LL_ADC_CHANNEL_6
  4730. * @arg @ref LL_ADC_CHANNEL_7
  4731. * @arg @ref LL_ADC_CHANNEL_8
  4732. * @arg @ref LL_ADC_CHANNEL_9
  4733. * @arg @ref LL_ADC_CHANNEL_10
  4734. * @arg @ref LL_ADC_CHANNEL_11
  4735. * @arg @ref LL_ADC_CHANNEL_12
  4736. * @arg @ref LL_ADC_CHANNEL_13
  4737. * @arg @ref LL_ADC_CHANNEL_14
  4738. * @arg @ref LL_ADC_CHANNEL_15
  4739. * @arg @ref LL_ADC_CHANNEL_16 (1)
  4740. *
  4741. * (1) On STM32F3, parameter available only on ADC instance: ADC1.
  4742. * @retval 0: channel in single-ended mode, else: channel in differential mode
  4743. */
  4744. __STATIC_INLINE uint32_t LL_ADC_GetChannelSingleDiff(ADC_TypeDef *ADCx, uint32_t Channel)
  4745. {
  4746. return (uint32_t)(READ_BIT(ADCx->DIFSEL, (Channel & ADC_SINGLEDIFF_CHANNEL_MASK)));
  4747. }
  4748. /**
  4749. * @}
  4750. */
  4751. /** @defgroup ADC_LL_EF_Configuration_ADC_AnalogWatchdog Configuration of ADC transversal scope: analog watchdog
  4752. * @{
  4753. */
  4754. /**
  4755. * @brief Set ADC analog watchdog monitored channels:
  4756. * a single channel, multiple channels or all channels,
  4757. * on ADC groups regular and-or injected.
  4758. * @note Once monitored channels are selected, analog watchdog
  4759. * is enabled.
  4760. * @note In case of need to define a single channel to monitor
  4761. * with analog watchdog from sequencer channel definition,
  4762. * use helper macro @ref __LL_ADC_ANALOGWD_CHANNEL_GROUP().
  4763. * @note On this STM32 series, there are 2 kinds of analog watchdog
  4764. * instance:
  4765. * - AWD standard (instance AWD1):
  4766. * - channels monitored: can monitor 1 channel or all channels.
  4767. * - groups monitored: ADC groups regular and-or injected.
  4768. * - resolution: resolution is not limited (corresponds to
  4769. * ADC resolution configured).
  4770. * - AWD flexible (instances AWD2, AWD3):
  4771. * - channels monitored: flexible on channels monitored, selection is
  4772. * channel wise, from from 1 to all channels.
  4773. * Specificity of this analog watchdog: Multiple channels can
  4774. * be selected. For example:
  4775. * (LL_ADC_AWD_CHANNEL4_REG_INJ | LL_ADC_AWD_CHANNEL5_REG_INJ | ...)
  4776. * - groups monitored: not selection possible (monitoring on both
  4777. * groups regular and injected).
  4778. * Channels selected are monitored on groups regular and injected:
  4779. * LL_ADC_AWD_CHANNELxx_REG_INJ (do not use parameters
  4780. * LL_ADC_AWD_CHANNELxx_REG and LL_ADC_AWD_CHANNELxx_INJ)
  4781. * - resolution: resolution is limited to 8 bits: if ADC resolution is
  4782. * 12 bits the 4 LSB are ignored, if ADC resolution is 10 bits
  4783. * the 2 LSB are ignored.
  4784. * @note On this STM32 series, setting of this feature is conditioned to
  4785. * ADC state:
  4786. * ADC must be disabled or enabled without conversion on going
  4787. * on either groups regular or injected.
  4788. * @rmtoll CFGR AWD1CH LL_ADC_SetAnalogWDMonitChannels\n
  4789. * CFGR AWD1SGL LL_ADC_SetAnalogWDMonitChannels\n
  4790. * CFGR AWD1EN LL_ADC_SetAnalogWDMonitChannels\n
  4791. * CFGR JAWD1EN LL_ADC_SetAnalogWDMonitChannels\n
  4792. * AWD2CR AWD2CH LL_ADC_SetAnalogWDMonitChannels\n
  4793. * AWD3CR AWD3CH LL_ADC_SetAnalogWDMonitChannels
  4794. * @param ADCx ADC instance
  4795. * @param AWDy This parameter can be one of the following values:
  4796. * @arg @ref LL_ADC_AWD1
  4797. * @arg @ref LL_ADC_AWD2
  4798. * @arg @ref LL_ADC_AWD3
  4799. * @param AWDChannelGroup This parameter can be one of the following values:
  4800. * @arg @ref LL_ADC_AWD_DISABLE
  4801. * @arg @ref LL_ADC_AWD_ALL_CHANNELS_REG (0)
  4802. * @arg @ref LL_ADC_AWD_ALL_CHANNELS_INJ (0)
  4803. * @arg @ref LL_ADC_AWD_ALL_CHANNELS_REG_INJ
  4804. * @arg @ref LL_ADC_AWD_CHANNEL_0_REG (0)
  4805. * @arg @ref LL_ADC_AWD_CHANNEL_0_INJ (0)
  4806. * @arg @ref LL_ADC_AWD_CHANNEL_0_REG_INJ
  4807. * @arg @ref LL_ADC_AWD_CHANNEL_1_REG (0)
  4808. * @arg @ref LL_ADC_AWD_CHANNEL_1_INJ (0)
  4809. * @arg @ref LL_ADC_AWD_CHANNEL_1_REG_INJ
  4810. * @arg @ref LL_ADC_AWD_CHANNEL_2_REG (0)
  4811. * @arg @ref LL_ADC_AWD_CHANNEL_2_INJ (0)
  4812. * @arg @ref LL_ADC_AWD_CHANNEL_2_REG_INJ
  4813. * @arg @ref LL_ADC_AWD_CHANNEL_3_REG (0)
  4814. * @arg @ref LL_ADC_AWD_CHANNEL_3_INJ (0)
  4815. * @arg @ref LL_ADC_AWD_CHANNEL_3_REG_INJ
  4816. * @arg @ref LL_ADC_AWD_CHANNEL_4_REG (0)
  4817. * @arg @ref LL_ADC_AWD_CHANNEL_4_INJ (0)
  4818. * @arg @ref LL_ADC_AWD_CHANNEL_4_REG_INJ
  4819. * @arg @ref LL_ADC_AWD_CHANNEL_5_REG (0)
  4820. * @arg @ref LL_ADC_AWD_CHANNEL_5_INJ (0)
  4821. * @arg @ref LL_ADC_AWD_CHANNEL_5_REG_INJ
  4822. * @arg @ref LL_ADC_AWD_CHANNEL_6_REG (0)
  4823. * @arg @ref LL_ADC_AWD_CHANNEL_6_INJ (0)
  4824. * @arg @ref LL_ADC_AWD_CHANNEL_6_REG_INJ
  4825. * @arg @ref LL_ADC_AWD_CHANNEL_7_REG (0)
  4826. * @arg @ref LL_ADC_AWD_CHANNEL_7_INJ (0)
  4827. * @arg @ref LL_ADC_AWD_CHANNEL_7_REG_INJ
  4828. * @arg @ref LL_ADC_AWD_CHANNEL_8_REG (0)
  4829. * @arg @ref LL_ADC_AWD_CHANNEL_8_INJ (0)
  4830. * @arg @ref LL_ADC_AWD_CHANNEL_8_REG_INJ
  4831. * @arg @ref LL_ADC_AWD_CHANNEL_9_REG (0)
  4832. * @arg @ref LL_ADC_AWD_CHANNEL_9_INJ (0)
  4833. * @arg @ref LL_ADC_AWD_CHANNEL_9_REG_INJ
  4834. * @arg @ref LL_ADC_AWD_CHANNEL_10_REG (0)
  4835. * @arg @ref LL_ADC_AWD_CHANNEL_10_INJ (0)
  4836. * @arg @ref LL_ADC_AWD_CHANNEL_10_REG_INJ
  4837. * @arg @ref LL_ADC_AWD_CHANNEL_11_REG (0)
  4838. * @arg @ref LL_ADC_AWD_CHANNEL_11_INJ (0)
  4839. * @arg @ref LL_ADC_AWD_CHANNEL_11_REG_INJ
  4840. * @arg @ref LL_ADC_AWD_CHANNEL_12_REG (0)
  4841. * @arg @ref LL_ADC_AWD_CHANNEL_12_INJ (0)
  4842. * @arg @ref LL_ADC_AWD_CHANNEL_12_REG_INJ
  4843. * @arg @ref LL_ADC_AWD_CHANNEL_13_REG (0)
  4844. * @arg @ref LL_ADC_AWD_CHANNEL_13_INJ (0)
  4845. * @arg @ref LL_ADC_AWD_CHANNEL_13_REG_INJ
  4846. * @arg @ref LL_ADC_AWD_CHANNEL_14_REG (0)
  4847. * @arg @ref LL_ADC_AWD_CHANNEL_14_INJ (0)
  4848. * @arg @ref LL_ADC_AWD_CHANNEL_14_REG_INJ
  4849. * @arg @ref LL_ADC_AWD_CHANNEL_15_REG (0)
  4850. * @arg @ref LL_ADC_AWD_CHANNEL_15_INJ (0)
  4851. * @arg @ref LL_ADC_AWD_CHANNEL_15_REG_INJ
  4852. * @arg @ref LL_ADC_AWD_CHANNEL_16_REG (0)
  4853. * @arg @ref LL_ADC_AWD_CHANNEL_16_INJ (0)
  4854. * @arg @ref LL_ADC_AWD_CHANNEL_16_REG_INJ
  4855. * @arg @ref LL_ADC_AWD_CHANNEL_17_REG (0)
  4856. * @arg @ref LL_ADC_AWD_CHANNEL_17_INJ (0)
  4857. * @arg @ref LL_ADC_AWD_CHANNEL_17_REG_INJ
  4858. * @arg @ref LL_ADC_AWD_CHANNEL_18_REG (0)
  4859. * @arg @ref LL_ADC_AWD_CHANNEL_18_INJ (0)
  4860. * @arg @ref LL_ADC_AWD_CHANNEL_18_REG_INJ
  4861. * @arg @ref LL_ADC_AWD_CH_VREFINT_REG (0)(5)
  4862. * @arg @ref LL_ADC_AWD_CH_VREFINT_INJ (0)(5)
  4863. * @arg @ref LL_ADC_AWD_CH_VREFINT_REG_INJ (5)
  4864. * @arg @ref LL_ADC_AWD_CH_TEMPSENSOR_REG (0)(1)
  4865. * @arg @ref LL_ADC_AWD_CH_TEMPSENSOR_INJ (0)(1)
  4866. * @arg @ref LL_ADC_AWD_CH_TEMPSENSOR_REG_INJ (1)
  4867. * @arg @ref LL_ADC_AWD_CH_VBAT_REG (0)(1)
  4868. * @arg @ref LL_ADC_AWD_CH_VBAT_INJ (0)(1)
  4869. * @arg @ref LL_ADC_AWD_CH_VBAT_REG_INJ (1)
  4870. * @arg @ref LL_ADC_AWD_CH_VOPAMP1_REG (0)(1)
  4871. * @arg @ref LL_ADC_AWD_CH_VOPAMP1_INJ (0)(1)
  4872. * @arg @ref LL_ADC_AWD_CH_VOPAMP1_REG_INJ (1)
  4873. * @arg @ref LL_ADC_AWD_CH_VOPAMP2_REG (0)(2)
  4874. * @arg @ref LL_ADC_AWD_CH_VOPAMP2_INJ (0)(2)
  4875. * @arg @ref LL_ADC_AWD_CH_VOPAMP2_REG_INJ (2)
  4876. * @arg @ref LL_ADC_AWD_CH_VOPAMP3_REG (0)(3)
  4877. * @arg @ref LL_ADC_AWD_CH_VOPAMP3_INJ (0)(3)
  4878. * @arg @ref LL_ADC_AWD_CH_VOPAMP3_REG_INJ (3)
  4879. * @arg @ref LL_ADC_AWD_CH_VOPAMP4_REG (0)(4)
  4880. * @arg @ref LL_ADC_AWD_CH_VOPAMP4_INJ (0)(4)
  4881. * @arg @ref LL_ADC_AWD_CH_VOPAMP4_REG_INJ (4)
  4882. *
  4883. * (0) On STM32F3, parameter available only on analog watchdog number: AWD1.\n
  4884. * (1) On STM32F3, parameter available only on ADC instance: ADC1.\n
  4885. * (2) On STM32F3, parameter available only on ADC instance: ADC2.\n
  4886. * (3) On STM32F3, parameter available only on ADC instance: ADC3.\n
  4887. * (4) On STM32F3, parameter available only on ADC instances: ADC4.\n
  4888. * (5) On STM32F3, ADC channel available only on all ADC instances, but
  4889. * only one ADC instance is allowed to be connected to VrefInt at the same time.
  4890. * @retval None
  4891. */
  4892. __STATIC_INLINE void LL_ADC_SetAnalogWDMonitChannels(ADC_TypeDef *ADCx, uint32_t AWDy, uint32_t AWDChannelGroup)
  4893. {
  4894. /* Set bits with content of parameter "AWDChannelGroup" with bits position */
  4895. /* in register and register position depending on parameter "AWDy". */
  4896. /* Parameters "AWDChannelGroup" and "AWDy" are used with masks because */
  4897. /* containing other bits reserved for other purpose. */
  4898. __IO uint32_t *preg = __ADC_PTR_REG_OFFSET(ADCx->CFGR, __ADC_MASK_SHIFT(AWDy, ADC_AWD_CRX_REGOFFSET_MASK)
  4899. + ((AWDy & ADC_AWD_CR12_REGOFFSETGAP_MASK) * ADC_AWD_CR12_REGOFFSETGAP_VAL));
  4900. MODIFY_REG(*preg,
  4901. (AWDy & ADC_AWD_CR_ALL_CHANNEL_MASK),
  4902. AWDChannelGroup & AWDy);
  4903. }
  4904. /**
  4905. * @brief Get ADC analog watchdog monitored channel.
  4906. * @note Usage of the returned channel number:
  4907. * - To reinject this channel into another function LL_ADC_xxx:
  4908. * the returned channel number is only partly formatted on definition
  4909. * of literals LL_ADC_CHANNEL_x. Therefore, it has to be compared
  4910. * with parts of literals LL_ADC_CHANNEL_x or using
  4911. * helper macro @ref __LL_ADC_CHANNEL_TO_DECIMAL_NB().
  4912. * Then the selected literal LL_ADC_CHANNEL_x can be used
  4913. * as parameter for another function.
  4914. * - To get the channel number in decimal format:
  4915. * process the returned value with the helper macro
  4916. * @ref __LL_ADC_CHANNEL_TO_DECIMAL_NB().
  4917. * Applicable only when the analog watchdog is set to monitor
  4918. * one channel.
  4919. * @note On this STM32 series, there are 2 kinds of analog watchdog
  4920. * instance:
  4921. * - AWD standard (instance AWD1):
  4922. * - channels monitored: can monitor 1 channel or all channels.
  4923. * - groups monitored: ADC groups regular and-or injected.
  4924. * - resolution: resolution is not limited (corresponds to
  4925. * ADC resolution configured).
  4926. * - AWD flexible (instances AWD2, AWD3):
  4927. * - channels monitored: flexible on channels monitored, selection is
  4928. * channel wise, from from 1 to all channels.
  4929. * Specificity of this analog watchdog: Multiple channels can
  4930. * be selected. For example:
  4931. * (LL_ADC_AWD_CHANNEL4_REG_INJ | LL_ADC_AWD_CHANNEL5_REG_INJ | ...)
  4932. * - groups monitored: not selection possible (monitoring on both
  4933. * groups regular and injected).
  4934. * Channels selected are monitored on groups regular and injected:
  4935. * LL_ADC_AWD_CHANNELxx_REG_INJ (do not use parameters
  4936. * LL_ADC_AWD_CHANNELxx_REG and LL_ADC_AWD_CHANNELxx_INJ)
  4937. * - resolution: resolution is limited to 8 bits: if ADC resolution is
  4938. * 12 bits the 4 LSB are ignored, if ADC resolution is 10 bits
  4939. * the 2 LSB are ignored.
  4940. * @note On this STM32 series, setting of this feature is conditioned to
  4941. * ADC state:
  4942. * ADC must be disabled or enabled without conversion on going
  4943. * on either groups regular or injected.
  4944. * @rmtoll CFGR AWD1CH LL_ADC_GetAnalogWDMonitChannels\n
  4945. * CFGR AWD1SGL LL_ADC_GetAnalogWDMonitChannels\n
  4946. * CFGR AWD1EN LL_ADC_GetAnalogWDMonitChannels\n
  4947. * CFGR JAWD1EN LL_ADC_GetAnalogWDMonitChannels\n
  4948. * AWD2CR AWD2CH LL_ADC_GetAnalogWDMonitChannels\n
  4949. * AWD3CR AWD3CH LL_ADC_GetAnalogWDMonitChannels
  4950. * @param ADCx ADC instance
  4951. * @param AWDy This parameter can be one of the following values:
  4952. * @arg @ref LL_ADC_AWD1
  4953. * @arg @ref LL_ADC_AWD2 (1)
  4954. * @arg @ref LL_ADC_AWD3 (1)
  4955. *
  4956. * (1) On this AWD number, monitored channel can be retrieved
  4957. * if only 1 channel is programmed (or none or all channels).
  4958. * This function cannot retrieve monitored channel if
  4959. * multiple channels are programmed simultaneously
  4960. * by bitfield.
  4961. * @retval Returned value can be one of the following values:
  4962. * @arg @ref LL_ADC_AWD_DISABLE
  4963. * @arg @ref LL_ADC_AWD_ALL_CHANNELS_REG (0)
  4964. * @arg @ref LL_ADC_AWD_ALL_CHANNELS_INJ (0)
  4965. * @arg @ref LL_ADC_AWD_ALL_CHANNELS_REG_INJ
  4966. * @arg @ref LL_ADC_AWD_CHANNEL_0_REG (0)
  4967. * @arg @ref LL_ADC_AWD_CHANNEL_0_INJ (0)
  4968. * @arg @ref LL_ADC_AWD_CHANNEL_0_REG_INJ
  4969. * @arg @ref LL_ADC_AWD_CHANNEL_1_REG (0)
  4970. * @arg @ref LL_ADC_AWD_CHANNEL_1_INJ (0)
  4971. * @arg @ref LL_ADC_AWD_CHANNEL_1_REG_INJ
  4972. * @arg @ref LL_ADC_AWD_CHANNEL_2_REG (0)
  4973. * @arg @ref LL_ADC_AWD_CHANNEL_2_INJ (0)
  4974. * @arg @ref LL_ADC_AWD_CHANNEL_2_REG_INJ
  4975. * @arg @ref LL_ADC_AWD_CHANNEL_3_REG (0)
  4976. * @arg @ref LL_ADC_AWD_CHANNEL_3_INJ (0)
  4977. * @arg @ref LL_ADC_AWD_CHANNEL_3_REG_INJ
  4978. * @arg @ref LL_ADC_AWD_CHANNEL_4_REG (0)
  4979. * @arg @ref LL_ADC_AWD_CHANNEL_4_INJ (0)
  4980. * @arg @ref LL_ADC_AWD_CHANNEL_4_REG_INJ
  4981. * @arg @ref LL_ADC_AWD_CHANNEL_5_REG (0)
  4982. * @arg @ref LL_ADC_AWD_CHANNEL_5_INJ (0)
  4983. * @arg @ref LL_ADC_AWD_CHANNEL_5_REG_INJ
  4984. * @arg @ref LL_ADC_AWD_CHANNEL_6_REG (0)
  4985. * @arg @ref LL_ADC_AWD_CHANNEL_6_INJ (0)
  4986. * @arg @ref LL_ADC_AWD_CHANNEL_6_REG_INJ
  4987. * @arg @ref LL_ADC_AWD_CHANNEL_7_REG (0)
  4988. * @arg @ref LL_ADC_AWD_CHANNEL_7_INJ (0)
  4989. * @arg @ref LL_ADC_AWD_CHANNEL_7_REG_INJ
  4990. * @arg @ref LL_ADC_AWD_CHANNEL_8_REG (0)
  4991. * @arg @ref LL_ADC_AWD_CHANNEL_8_INJ (0)
  4992. * @arg @ref LL_ADC_AWD_CHANNEL_8_REG_INJ
  4993. * @arg @ref LL_ADC_AWD_CHANNEL_9_REG (0)
  4994. * @arg @ref LL_ADC_AWD_CHANNEL_9_INJ (0)
  4995. * @arg @ref LL_ADC_AWD_CHANNEL_9_REG_INJ
  4996. * @arg @ref LL_ADC_AWD_CHANNEL_10_REG (0)
  4997. * @arg @ref LL_ADC_AWD_CHANNEL_10_INJ (0)
  4998. * @arg @ref LL_ADC_AWD_CHANNEL_10_REG_INJ
  4999. * @arg @ref LL_ADC_AWD_CHANNEL_11_REG (0)
  5000. * @arg @ref LL_ADC_AWD_CHANNEL_11_INJ (0)
  5001. * @arg @ref LL_ADC_AWD_CHANNEL_11_REG_INJ
  5002. * @arg @ref LL_ADC_AWD_CHANNEL_12_REG (0)
  5003. * @arg @ref LL_ADC_AWD_CHANNEL_12_INJ (0)
  5004. * @arg @ref LL_ADC_AWD_CHANNEL_12_REG_INJ
  5005. * @arg @ref LL_ADC_AWD_CHANNEL_13_REG (0)
  5006. * @arg @ref LL_ADC_AWD_CHANNEL_13_INJ (0)
  5007. * @arg @ref LL_ADC_AWD_CHANNEL_13_REG_INJ
  5008. * @arg @ref LL_ADC_AWD_CHANNEL_14_REG (0)
  5009. * @arg @ref LL_ADC_AWD_CHANNEL_14_INJ (0)
  5010. * @arg @ref LL_ADC_AWD_CHANNEL_14_REG_INJ
  5011. * @arg @ref LL_ADC_AWD_CHANNEL_15_REG (0)
  5012. * @arg @ref LL_ADC_AWD_CHANNEL_15_INJ (0)
  5013. * @arg @ref LL_ADC_AWD_CHANNEL_15_REG_INJ
  5014. * @arg @ref LL_ADC_AWD_CHANNEL_16_REG (0)
  5015. * @arg @ref LL_ADC_AWD_CHANNEL_16_INJ (0)
  5016. * @arg @ref LL_ADC_AWD_CHANNEL_16_REG_INJ
  5017. * @arg @ref LL_ADC_AWD_CHANNEL_17_REG (0)
  5018. * @arg @ref LL_ADC_AWD_CHANNEL_17_INJ (0)
  5019. * @arg @ref LL_ADC_AWD_CHANNEL_17_REG_INJ
  5020. * @arg @ref LL_ADC_AWD_CHANNEL_18_REG (0)
  5021. * @arg @ref LL_ADC_AWD_CHANNEL_18_INJ (0)
  5022. * @arg @ref LL_ADC_AWD_CHANNEL_18_REG_INJ
  5023. *
  5024. * (0) On STM32F3, parameter available only on analog watchdog number: AWD1.
  5025. */
  5026. __STATIC_INLINE uint32_t LL_ADC_GetAnalogWDMonitChannels(ADC_TypeDef *ADCx, uint32_t AWDy)
  5027. {
  5028. __IO uint32_t *preg = __ADC_PTR_REG_OFFSET(ADCx->CFGR, __ADC_MASK_SHIFT(AWDy, ADC_AWD_CRX_REGOFFSET_MASK)
  5029. + ((AWDy & ADC_AWD_CR12_REGOFFSETGAP_MASK) * ADC_AWD_CR12_REGOFFSETGAP_VAL));
  5030. /* Variable "AWDy" used to retrieve appropriate bitfield corresponding to */
  5031. /* ADC_AWD_CR1_CHANNEL_MASK or ADC_AWD_CR23_CHANNEL_MASK. */
  5032. uint32_t AWD123ChannelGroup = READ_BIT(*preg, (AWDy | ADC_AWD_CR_ALL_CHANNEL_MASK));
  5033. /* Set variable of AWD1 monitored channel according to AWD1 features */
  5034. /* and ADC channel definition: */
  5035. /* - channel ID with number */
  5036. /* - channel ID with bitfield */
  5037. /* - AWD1 single or all channels */
  5038. /* - AWD1 enable or disable (also used to discard AWD1 bitfield in case of */
  5039. /* AWD2 or AWD3 selected). */
  5040. uint32_t AWD1ChannelSingle = ((AWD123ChannelGroup & ADC_CFGR_AWD1SGL) >> ADC_CFGR_AWD1SGL_BITOFFSET_POS);
  5041. uint32_t AWD1ChannelGroup = ( ( AWD123ChannelGroup
  5042. | ((ADC_CHANNEL_0_BITFIELD << ((AWD123ChannelGroup & ADC_CHANNEL_ID_NUMBER_MASK) >> ADC_CHANNEL_ID_NUMBER_BITOFFSET_POS)) * AWD1ChannelSingle)
  5043. | (ADC_CHANNEL_ID_BITFIELD_MASK * (~AWD1ChannelSingle & ((uint32_t)0x00000001U)))
  5044. )
  5045. * (((AWD123ChannelGroup & ADC_CFGR_JAWD1EN) >> ADC_CFGR_JAWD1EN_BITOFFSET_POS) | ((AWD123ChannelGroup & ADC_CFGR_AWD1EN) >> ADC_CFGR_AWD1EN_BITOFFSET_POS))
  5046. );
  5047. /* Set variable of AWD2 and AWD3 monitored channel according to AWD2-3 */
  5048. /* features and ADC channel definition: */
  5049. /* - channel ID with number */
  5050. /* - channel ID with bitfield */
  5051. /* - AWD2-3 single or all channels (shift value 32 (0x1 shift 5) used to */
  5052. /* shift AWD1 equivalent single-all channels out of register) */
  5053. /* - AWD2-3 enable or disable */
  5054. /* Note: Use modulo 3 to avoid a shift value too long. On AWD2 and AWD3, */
  5055. /* channel can be read back if only 1 channel monitoring */
  5056. /* is activated, therefore the channel monitoring value channel "3" */
  5057. /* is not not supported by this function, there is no risk of */
  5058. /* conflict. */
  5059. uint32_t AWD23Enabled = ((((uint32_t)0x00000001U) >> (AWD123ChannelGroup % 3U)) << 6U); /* Value "0" if AWD2-3 is enabled, value "32" if AWD2-3 is disabled */
  5060. uint32_t AWD23ChannelGroup = ((( AWD123ChannelGroup
  5061. | ((uint32_t)POSITION_VAL(AWD123ChannelGroup) << ADC_CHANNEL_ID_NUMBER_BITOFFSET_POS)
  5062. | ((ADC_CFGR_AWD1SGL) >> ((((uint32_t)0x00000001U) >> (ADC_AWD_CR23_CHANNEL_MASK - AWD123ChannelGroup)) << 5U))
  5063. | (ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1EN)
  5064. ) >> AWD23Enabled
  5065. ) >> (((AWDy & ADC_CFGR_AWD1SGL) >> ADC_CFGR_AWD1SGL_BITOFFSET_POS) << 5U));
  5066. return (AWD1ChannelGroup | AWD23ChannelGroup);
  5067. }
  5068. /**
  5069. * @brief Set ADC analog watchdog thresholds value of both thresholds
  5070. * high and low.
  5071. * @note If value of only one threshold high or low must be set,
  5072. * use function @ref LL_ADC_SetAnalogWDThresholds().
  5073. * @note In case of ADC resolution different of 12 bits,
  5074. * analog watchdog thresholds data require a specific shift.
  5075. * Use helper macro @ref __LL_ADC_ANALOGWD_SET_THRESHOLD_RESOLUTION().
  5076. * @note On this STM32 series, there are 2 kinds of analog watchdog
  5077. * instance:
  5078. * - AWD standard (instance AWD1):
  5079. * - channels monitored: can monitor 1 channel or all channels.
  5080. * - groups monitored: ADC groups regular and-or injected.
  5081. * - resolution: resolution is not limited (corresponds to
  5082. * ADC resolution configured).
  5083. * - AWD flexible (instances AWD2, AWD3):
  5084. * - channels monitored: flexible on channels monitored, selection is
  5085. * channel wise, from from 1 to all channels.
  5086. * Specificity of this analog watchdog: Multiple channels can
  5087. * be selected. For example:
  5088. * (LL_ADC_AWD_CHANNEL4_REG_INJ | LL_ADC_AWD_CHANNEL5_REG_INJ | ...)
  5089. * - groups monitored: not selection possible (monitoring on both
  5090. * groups regular and injected).
  5091. * Channels selected are monitored on groups regular and injected:
  5092. * LL_ADC_AWD_CHANNELxx_REG_INJ (do not use parameters
  5093. * LL_ADC_AWD_CHANNELxx_REG and LL_ADC_AWD_CHANNELxx_INJ)
  5094. * - resolution: resolution is limited to 8 bits: if ADC resolution is
  5095. * 12 bits the 4 LSB are ignored, if ADC resolution is 10 bits
  5096. * the 2 LSB are ignored.
  5097. * @note On this STM32 series, setting of this feature is conditioned to
  5098. * ADC state:
  5099. * ADC must be disabled or enabled without conversion on going
  5100. * on either groups regular or injected.
  5101. * @rmtoll TR1 HT1 LL_ADC_ConfigAnalogWDThresholds\n
  5102. * TR2 HT2 LL_ADC_ConfigAnalogWDThresholds\n
  5103. * TR3 HT3 LL_ADC_ConfigAnalogWDThresholds\n
  5104. * TR1 LT1 LL_ADC_ConfigAnalogWDThresholds\n
  5105. * TR2 LT2 LL_ADC_ConfigAnalogWDThresholds\n
  5106. * TR3 LT3 LL_ADC_ConfigAnalogWDThresholds
  5107. * @param ADCx ADC instance
  5108. * @param AWDy This parameter can be one of the following values:
  5109. * @arg @ref LL_ADC_AWD1
  5110. * @arg @ref LL_ADC_AWD2
  5111. * @arg @ref LL_ADC_AWD3
  5112. * @param AWDThresholdHighValue Value between Min_Data=0x000 and Max_Data=0xFFF
  5113. * @param AWDThresholdLowValue Value between Min_Data=0x000 and Max_Data=0xFFF
  5114. * @retval None
  5115. */
  5116. __STATIC_INLINE void LL_ADC_ConfigAnalogWDThresholds(ADC_TypeDef *ADCx, uint32_t AWDy, uint32_t AWDThresholdHighValue, uint32_t AWDThresholdLowValue)
  5117. {
  5118. /* Set bits with content of parameter "AWDThresholdxxxValue" with bits */
  5119. /* position in register and register position depending on parameter */
  5120. /* "AWDy". */
  5121. /* Parameters "AWDy" and "AWDThresholdxxxValue" are used with masks because */
  5122. /* containing other bits reserved for other purpose. */
  5123. __IO uint32_t *preg = __ADC_PTR_REG_OFFSET(ADCx->TR1, __ADC_MASK_SHIFT(AWDy, ADC_AWD_TRX_REGOFFSET_MASK));
  5124. MODIFY_REG(*preg,
  5125. ADC_TR1_HT1 | ADC_TR1_LT1,
  5126. (AWDThresholdHighValue << ADC_TR1_HT1_BITOFFSET_POS) | AWDThresholdLowValue);
  5127. }
  5128. /**
  5129. * @brief Set ADC analog watchdog threshold value of threshold
  5130. * high or low.
  5131. * @note If values of both thresholds high or low must be set,
  5132. * use function @ref LL_ADC_ConfigAnalogWDThresholds().
  5133. * @note In case of ADC resolution different of 12 bits,
  5134. * analog watchdog thresholds data require a specific shift.
  5135. * Use helper macro @ref __LL_ADC_ANALOGWD_SET_THRESHOLD_RESOLUTION().
  5136. * @note On this STM32 series, there are 2 kinds of analog watchdog
  5137. * instance:
  5138. * - AWD standard (instance AWD1):
  5139. * - channels monitored: can monitor 1 channel or all channels.
  5140. * - groups monitored: ADC groups regular and-or injected.
  5141. * - resolution: resolution is not limited (corresponds to
  5142. * ADC resolution configured).
  5143. * - AWD flexible (instances AWD2, AWD3):
  5144. * - channels monitored: flexible on channels monitored, selection is
  5145. * channel wise, from from 1 to all channels.
  5146. * Specificity of this analog watchdog: Multiple channels can
  5147. * be selected. For example:
  5148. * (LL_ADC_AWD_CHANNEL4_REG_INJ | LL_ADC_AWD_CHANNEL5_REG_INJ | ...)
  5149. * - groups monitored: not selection possible (monitoring on both
  5150. * groups regular and injected).
  5151. * Channels selected are monitored on groups regular and injected:
  5152. * LL_ADC_AWD_CHANNELxx_REG_INJ (do not use parameters
  5153. * LL_ADC_AWD_CHANNELxx_REG and LL_ADC_AWD_CHANNELxx_INJ)
  5154. * - resolution: resolution is limited to 8 bits: if ADC resolution is
  5155. * 12 bits the 4 LSB are ignored, if ADC resolution is 10 bits
  5156. * the 2 LSB are ignored.
  5157. * @note On this STM32 series, setting of this feature is conditioned to
  5158. * ADC state:
  5159. * ADC must be disabled or enabled without conversion on going
  5160. * on either groups regular or injected.
  5161. * @rmtoll TR1 HT1 LL_ADC_SetAnalogWDThresholds\n
  5162. * TR2 HT2 LL_ADC_SetAnalogWDThresholds\n
  5163. * TR3 HT3 LL_ADC_SetAnalogWDThresholds\n
  5164. * TR1 LT1 LL_ADC_SetAnalogWDThresholds\n
  5165. * TR2 LT2 LL_ADC_SetAnalogWDThresholds\n
  5166. * TR3 LT3 LL_ADC_SetAnalogWDThresholds
  5167. * @param ADCx ADC instance
  5168. * @param AWDy This parameter can be one of the following values:
  5169. * @arg @ref LL_ADC_AWD1
  5170. * @arg @ref LL_ADC_AWD2
  5171. * @arg @ref LL_ADC_AWD3
  5172. * @param AWDThresholdsHighLow This parameter can be one of the following values:
  5173. * @arg @ref LL_ADC_AWD_THRESHOLD_HIGH
  5174. * @arg @ref LL_ADC_AWD_THRESHOLD_LOW
  5175. * @param AWDThresholdValue Value between Min_Data=0x000 and Max_Data=0xFFF
  5176. * @retval None
  5177. */
  5178. __STATIC_INLINE void LL_ADC_SetAnalogWDThresholds(ADC_TypeDef *ADCx, uint32_t AWDy, uint32_t AWDThresholdsHighLow, uint32_t AWDThresholdValue)
  5179. {
  5180. /* Set bits with content of parameter "AWDThresholdValue" with bits */
  5181. /* position in register and register position depending on parameters */
  5182. /* "AWDThresholdsHighLow" and "AWDy". */
  5183. /* Parameters "AWDy" and "AWDThresholdValue" are used with masks because */
  5184. /* containing other bits reserved for other purpose. */
  5185. __IO uint32_t *preg = __ADC_PTR_REG_OFFSET(ADCx->TR1, __ADC_MASK_SHIFT(AWDy, ADC_AWD_TRX_REGOFFSET_MASK));
  5186. MODIFY_REG(*preg,
  5187. AWDThresholdsHighLow,
  5188. AWDThresholdValue << POSITION_VAL(AWDThresholdsHighLow));
  5189. }
  5190. /**
  5191. * @brief Get ADC analog watchdog threshold value of threshold high,
  5192. * threshold low or raw data with ADC thresholds high and low
  5193. * concatenated.
  5194. * @note If raw data with ADC thresholds high and low is retrieved,
  5195. * the data of each threshold high or low can be isolated
  5196. * using helper macro:
  5197. * @ref __LL_ADC_ANALOGWD_THRESHOLDS_HIGH_LOW().
  5198. * @note In case of ADC resolution different of 12 bits,
  5199. * analog watchdog thresholds data require a specific shift.
  5200. * Use helper macro @ref __LL_ADC_ANALOGWD_GET_THRESHOLD_RESOLUTION().
  5201. * @rmtoll TR1 HT1 LL_ADC_GetAnalogWDThresholds\n
  5202. * TR2 HT2 LL_ADC_GetAnalogWDThresholds\n
  5203. * TR3 HT3 LL_ADC_GetAnalogWDThresholds\n
  5204. * TR1 LT1 LL_ADC_GetAnalogWDThresholds\n
  5205. * TR2 LT2 LL_ADC_GetAnalogWDThresholds\n
  5206. * TR3 LT3 LL_ADC_GetAnalogWDThresholds
  5207. * @param ADCx ADC instance
  5208. * @param AWDy This parameter can be one of the following values:
  5209. * @arg @ref LL_ADC_AWD1
  5210. * @arg @ref LL_ADC_AWD2
  5211. * @arg @ref LL_ADC_AWD3
  5212. * @param AWDThresholdsHighLow This parameter can be one of the following values:
  5213. * @arg @ref LL_ADC_AWD_THRESHOLD_HIGH
  5214. * @arg @ref LL_ADC_AWD_THRESHOLD_LOW
  5215. * @arg @ref LL_ADC_AWD_THRESHOLDS_HIGH_LOW
  5216. * @retval Value between Min_Data=0x000 and Max_Data=0xFFF
  5217. */
  5218. __STATIC_INLINE uint32_t LL_ADC_GetAnalogWDThresholds(ADC_TypeDef *ADCx, uint32_t AWDy, uint32_t AWDThresholdsHighLow)
  5219. {
  5220. __IO uint32_t *preg = __ADC_PTR_REG_OFFSET(ADCx->TR1, __ADC_MASK_SHIFT(AWDy, ADC_AWD_TRX_REGOFFSET_MASK));
  5221. return (uint32_t)(READ_BIT(*preg,
  5222. (AWDThresholdsHighLow | ADC_TR1_LT1))
  5223. >> POSITION_VAL(AWDThresholdsHighLow)
  5224. );
  5225. }
  5226. /**
  5227. * @}
  5228. */
  5229. /** @defgroup ADC_LL_EF_Configuration_ADC_Multimode Configuration of ADC hierarchical scope: multimode
  5230. * @{
  5231. */
  5232. #if defined(ADC_MULTIMODE_SUPPORT)
  5233. /**
  5234. * @brief Set ADC multimode configuration to operate in independent mode
  5235. * or multimode (for devices with several ADC instances).
  5236. * @note If multimode configuration: the selected ADC instance is
  5237. * either master or slave depending on hardware.
  5238. * Refer to reference manual.
  5239. * @note On this STM32 series, setting of this feature is conditioned to
  5240. * ADC state:
  5241. * All ADC instances of the ADC common group must be disabled.
  5242. * This check can be done with function @ref LL_ADC_IsEnabled() for each
  5243. * ADC instance or by using helper macro
  5244. * @ref __LL_ADC_IS_ENABLED_ALL_COMMON_INSTANCE().
  5245. * @rmtoll CCR DUAL LL_ADC_SetMultimode
  5246. * @param ADCxy_COMMON ADC common instance
  5247. * (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() )
  5248. * @param Multimode This parameter can be one of the following values:
  5249. * @arg @ref LL_ADC_MULTI_INDEPENDENT
  5250. * @arg @ref LL_ADC_MULTI_DUAL_REG_SIMULT
  5251. * @arg @ref LL_ADC_MULTI_DUAL_REG_INTERL
  5252. * @arg @ref LL_ADC_MULTI_DUAL_INJ_SIMULT
  5253. * @arg @ref LL_ADC_MULTI_DUAL_INJ_ALTERN
  5254. * @arg @ref LL_ADC_MULTI_DUAL_REG_SIM_INJ_SIM
  5255. * @arg @ref LL_ADC_MULTI_DUAL_REG_SIM_INJ_ALT
  5256. * @arg @ref LL_ADC_MULTI_DUAL_REG_INT_INJ_SIM
  5257. * @retval None
  5258. */
  5259. __STATIC_INLINE void LL_ADC_SetMultimode(ADC_Common_TypeDef *ADCxy_COMMON, uint32_t Multimode)
  5260. {
  5261. MODIFY_REG(ADCxy_COMMON->CCR, ADC_CCR_DUAL, Multimode);
  5262. }
  5263. /**
  5264. * @brief Get ADC multimode configuration to operate in independent mode
  5265. * or multimode (for devices with several ADC instances).
  5266. * @note If multimode configuration: the selected ADC instance is
  5267. * either master or slave depending on hardware.
  5268. * Refer to reference manual.
  5269. * @rmtoll CCR DUAL LL_ADC_GetMultimode
  5270. * @param ADCxy_COMMON ADC common instance
  5271. * (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() )
  5272. * @retval Returned value can be one of the following values:
  5273. * @arg @ref LL_ADC_MULTI_INDEPENDENT
  5274. * @arg @ref LL_ADC_MULTI_DUAL_REG_SIMULT
  5275. * @arg @ref LL_ADC_MULTI_DUAL_REG_INTERL
  5276. * @arg @ref LL_ADC_MULTI_DUAL_INJ_SIMULT
  5277. * @arg @ref LL_ADC_MULTI_DUAL_INJ_ALTERN
  5278. * @arg @ref LL_ADC_MULTI_DUAL_REG_SIM_INJ_SIM
  5279. * @arg @ref LL_ADC_MULTI_DUAL_REG_SIM_INJ_ALT
  5280. * @arg @ref LL_ADC_MULTI_DUAL_REG_INT_INJ_SIM
  5281. */
  5282. __STATIC_INLINE uint32_t LL_ADC_GetMultimode(ADC_Common_TypeDef *ADCxy_COMMON)
  5283. {
  5284. return (uint32_t)(READ_BIT(ADCxy_COMMON->CCR, ADC_CCR_DUAL));
  5285. }
  5286. /**
  5287. * @brief Set ADC multimode conversion data transfer: no transfer
  5288. * or transfer by DMA.
  5289. * @note If ADC multimode transfer by DMA is not selected:
  5290. * each ADC uses its own DMA channel, with its individual
  5291. * DMA transfer settings.
  5292. * If ADC multimode transfer by DMA is selected:
  5293. * One DMA channel is used for both ADC (DMA of ADC master)
  5294. * Specifies the DMA requests mode:
  5295. * - Limited mode (One shot mode): DMA transfer requests are stopped
  5296. * when number of DMA data transfers (number of
  5297. * ADC conversions) is reached.
  5298. * This ADC mode is intended to be used with DMA mode non-circular.
  5299. * - Unlimited mode: DMA transfer requests are unlimited,
  5300. * whatever number of DMA data transfers (number of
  5301. * ADC conversions).
  5302. * This ADC mode is intended to be used with DMA mode circular.
  5303. * @note If ADC DMA requests mode is set to unlimited and DMA is set to
  5304. * mode non-circular:
  5305. * when DMA transfers size will be reached, DMA will stop transfers of
  5306. * ADC conversions data ADC will raise an overrun error
  5307. * (overrun flag and interruption if enabled).
  5308. * @note How to retrieve multimode conversion data:
  5309. * Whatever multimode transfer by DMA setting: using function
  5310. * @ref LL_ADC_REG_ReadMultiConversionData32().
  5311. * If ADC multimode transfer by DMA is selected: conversion data
  5312. * is a raw data with ADC master and slave concatenated.
  5313. * A macro is available to get the conversion data of
  5314. * ADC master or ADC slave: see helper macro
  5315. * @ref __LL_ADC_MULTI_CONV_DATA_MASTER_SLAVE().
  5316. * @note On this STM32 series, setting of this feature is conditioned to
  5317. * ADC state:
  5318. * All ADC instances of the ADC common group must be disabled
  5319. * or enabled without conversion on going on group regular.
  5320. * @rmtoll CCR MDMA LL_ADC_SetMultiDMATransfer\n
  5321. * CCR DMACFG LL_ADC_SetMultiDMATransfer
  5322. * @param ADCxy_COMMON ADC common instance
  5323. * (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() )
  5324. * @param MultiDMATransfer This parameter can be one of the following values:
  5325. * @arg @ref LL_ADC_MULTI_REG_DMA_EACH_ADC
  5326. * @arg @ref LL_ADC_MULTI_REG_DMA_LIMIT_RES12_10B
  5327. * @arg @ref LL_ADC_MULTI_REG_DMA_LIMIT_RES8_6B
  5328. * @arg @ref LL_ADC_MULTI_REG_DMA_UNLMT_RES12_10B
  5329. * @arg @ref LL_ADC_MULTI_REG_DMA_UNLMT_RES8_6B
  5330. * @retval None
  5331. */
  5332. __STATIC_INLINE void LL_ADC_SetMultiDMATransfer(ADC_Common_TypeDef *ADCxy_COMMON, uint32_t MultiDMATransfer)
  5333. {
  5334. MODIFY_REG(ADCxy_COMMON->CCR, ADC_CCR_MDMA | ADC_CCR_DMACFG, MultiDMATransfer);
  5335. }
  5336. /**
  5337. * @brief Get ADC multimode conversion data transfer: no transfer
  5338. * or transfer by DMA.
  5339. * @note If ADC multimode transfer by DMA is not selected:
  5340. * each ADC uses its own DMA channel, with its individual
  5341. * DMA transfer settings.
  5342. * If ADC multimode transfer by DMA is selected:
  5343. * One DMA channel is used for both ADC (DMA of ADC master)
  5344. * Specifies the DMA requests mode:
  5345. * - Limited mode (One shot mode): DMA transfer requests are stopped
  5346. * when number of DMA data transfers (number of
  5347. * ADC conversions) is reached.
  5348. * This ADC mode is intended to be used with DMA mode non-circular.
  5349. * - Unlimited mode: DMA transfer requests are unlimited,
  5350. * whatever number of DMA data transfers (number of
  5351. * ADC conversions).
  5352. * This ADC mode is intended to be used with DMA mode circular.
  5353. * @note If ADC DMA requests mode is set to unlimited and DMA is set to
  5354. * mode non-circular:
  5355. * when DMA transfers size will be reached, DMA will stop transfers of
  5356. * ADC conversions data ADC will raise an overrun error
  5357. * (overrun flag and interruption if enabled).
  5358. * @note How to retrieve multimode conversion data:
  5359. * Whatever multimode transfer by DMA setting: using function
  5360. * @ref LL_ADC_REG_ReadMultiConversionData32().
  5361. * If ADC multimode transfer by DMA is selected: conversion data
  5362. * is a raw data with ADC master and slave concatenated.
  5363. * A macro is available to get the conversion data of
  5364. * ADC master or ADC slave: see helper macro
  5365. * @ref __LL_ADC_MULTI_CONV_DATA_MASTER_SLAVE().
  5366. * @rmtoll CCR MDMA LL_ADC_GetMultiDMATransfer\n
  5367. * CCR DMACFG LL_ADC_GetMultiDMATransfer
  5368. * @param ADCxy_COMMON ADC common instance
  5369. * (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() )
  5370. * @retval Returned value can be one of the following values:
  5371. * @arg @ref LL_ADC_MULTI_REG_DMA_EACH_ADC
  5372. * @arg @ref LL_ADC_MULTI_REG_DMA_LIMIT_RES12_10B
  5373. * @arg @ref LL_ADC_MULTI_REG_DMA_LIMIT_RES8_6B
  5374. * @arg @ref LL_ADC_MULTI_REG_DMA_UNLMT_RES12_10B
  5375. * @arg @ref LL_ADC_MULTI_REG_DMA_UNLMT_RES8_6B
  5376. */
  5377. __STATIC_INLINE uint32_t LL_ADC_GetMultiDMATransfer(ADC_Common_TypeDef *ADCxy_COMMON)
  5378. {
  5379. return (uint32_t)(READ_BIT(ADCxy_COMMON->CCR, ADC_CCR_MDMA | ADC_CCR_DMACFG));
  5380. }
  5381. /**
  5382. * @brief Set ADC multimode delay between 2 sampling phases.
  5383. * @note The sampling delay range depends on ADC resolution:
  5384. * - ADC resolution 12 bits can have maximum delay of 12 cycles.
  5385. * - ADC resolution 10 bits can have maximum delay of 10 cycles.
  5386. * - ADC resolution 8 bits can have maximum delay of 8 cycles.
  5387. * - ADC resolution 6 bits can have maximum delay of 6 cycles.
  5388. * @note On this STM32 series, setting of this feature is conditioned to
  5389. * ADC state:
  5390. * All ADC instances of the ADC common group must be disabled.
  5391. * This check can be done with function @ref LL_ADC_IsEnabled() for each
  5392. * ADC instance or by using helper macro helper macro
  5393. * @ref __LL_ADC_IS_ENABLED_ALL_COMMON_INSTANCE().
  5394. * @rmtoll CCR DELAY LL_ADC_SetMultiTwoSamplingDelay
  5395. * @param ADCxy_COMMON ADC common instance
  5396. * (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() )
  5397. * @param MultiTwoSamplingDelay This parameter can be one of the following values:
  5398. * @arg @ref LL_ADC_MULTI_TWOSMP_DELAY_1CYCLE
  5399. * @arg @ref LL_ADC_MULTI_TWOSMP_DELAY_2CYCLES
  5400. * @arg @ref LL_ADC_MULTI_TWOSMP_DELAY_3CYCLES
  5401. * @arg @ref LL_ADC_MULTI_TWOSMP_DELAY_4CYCLES
  5402. * @arg @ref LL_ADC_MULTI_TWOSMP_DELAY_5CYCLES
  5403. * @arg @ref LL_ADC_MULTI_TWOSMP_DELAY_6CYCLES (1)
  5404. * @arg @ref LL_ADC_MULTI_TWOSMP_DELAY_7CYCLES (1)
  5405. * @arg @ref LL_ADC_MULTI_TWOSMP_DELAY_8CYCLES (2)
  5406. * @arg @ref LL_ADC_MULTI_TWOSMP_DELAY_9CYCLES (2)
  5407. * @arg @ref LL_ADC_MULTI_TWOSMP_DELAY_10CYCLES (2)
  5408. * @arg @ref LL_ADC_MULTI_TWOSMP_DELAY_11CYCLES (3)
  5409. * @arg @ref LL_ADC_MULTI_TWOSMP_DELAY_12CYCLES (3)
  5410. *
  5411. * (1) Parameter available only if ADC resolution is 12, 10 or 8 bits.\n
  5412. * (2) Parameter available only if ADC resolution is 12 or 10 bits.\n
  5413. * (3) Parameter available only if ADC resolution is 12 bits.
  5414. * @retval None
  5415. */
  5416. __STATIC_INLINE void LL_ADC_SetMultiTwoSamplingDelay(ADC_Common_TypeDef *ADCxy_COMMON, uint32_t MultiTwoSamplingDelay)
  5417. {
  5418. MODIFY_REG(ADCxy_COMMON->CCR, ADC_CCR_DELAY, MultiTwoSamplingDelay);
  5419. }
  5420. /**
  5421. * @brief Get ADC multimode delay between 2 sampling phases.
  5422. * @rmtoll CCR DELAY LL_ADC_GetMultiTwoSamplingDelay
  5423. * @param ADCxy_COMMON ADC common instance
  5424. * (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() )
  5425. * @retval Returned value can be one of the following values:
  5426. * @arg @ref LL_ADC_MULTI_TWOSMP_DELAY_1CYCLE
  5427. * @arg @ref LL_ADC_MULTI_TWOSMP_DELAY_2CYCLES
  5428. * @arg @ref LL_ADC_MULTI_TWOSMP_DELAY_3CYCLES
  5429. * @arg @ref LL_ADC_MULTI_TWOSMP_DELAY_4CYCLES
  5430. * @arg @ref LL_ADC_MULTI_TWOSMP_DELAY_5CYCLES
  5431. * @arg @ref LL_ADC_MULTI_TWOSMP_DELAY_6CYCLES (1)
  5432. * @arg @ref LL_ADC_MULTI_TWOSMP_DELAY_7CYCLES (1)
  5433. * @arg @ref LL_ADC_MULTI_TWOSMP_DELAY_8CYCLES (2)
  5434. * @arg @ref LL_ADC_MULTI_TWOSMP_DELAY_9CYCLES (2)
  5435. * @arg @ref LL_ADC_MULTI_TWOSMP_DELAY_10CYCLES (2)
  5436. * @arg @ref LL_ADC_MULTI_TWOSMP_DELAY_11CYCLES (3)
  5437. * @arg @ref LL_ADC_MULTI_TWOSMP_DELAY_12CYCLES (3)
  5438. *
  5439. * (1) Parameter available only if ADC resolution is 12, 10 or 8 bits.\n
  5440. * (2) Parameter available only if ADC resolution is 12 or 10 bits.\n
  5441. * (3) Parameter available only if ADC resolution is 12 bits.
  5442. */
  5443. __STATIC_INLINE uint32_t LL_ADC_GetMultiTwoSamplingDelay(ADC_Common_TypeDef *ADCxy_COMMON)
  5444. {
  5445. return (uint32_t)(READ_BIT(ADCxy_COMMON->CCR, ADC_CCR_DELAY));
  5446. }
  5447. #endif /* ADC_MULTIMODE_SUPPORT */
  5448. /**
  5449. * @}
  5450. */
  5451. /** @defgroup ADC_LL_EF_Operation_ADC_Instance Operation on ADC hierarchical scope: ADC instance
  5452. * @{
  5453. */
  5454. /**
  5455. * @brief Enable ADC instance internal voltage regulator.
  5456. * @note On this STM32 series, after ADC internal voltage regulator enable,
  5457. * a delay for ADC internal voltage regulator stabilization
  5458. * is required before performing a ADC calibration or ADC enable.
  5459. * Refer to device datasheet, parameter tADCVREG_STUP.
  5460. * Refer to literal @ref LL_ADC_DELAY_INTERNAL_REGUL_STAB_US.
  5461. * @note On this STM32 series, setting of this feature is conditioned to
  5462. * ADC state:
  5463. * ADC must be ADC disabled.
  5464. * @rmtoll CR ADVREGEN LL_ADC_EnableInternalRegulator
  5465. * @param ADCx ADC instance
  5466. * @retval None
  5467. */
  5468. __STATIC_INLINE void LL_ADC_EnableInternalRegulator(ADC_TypeDef *ADCx)
  5469. {
  5470. /* 1. Set the intermediate state before moving the ADC voltage regulator */
  5471. /* to state enable. */
  5472. CLEAR_BIT(ADCx->CR, (ADC_CR_ADVREGEN_1 | ADC_CR_ADVREGEN_0));
  5473. /* 2. Set the final state of ADC voltage regulator enable */
  5474. /* (ADVREGEN bits set to 0x01). */
  5475. /* Note: Write register with some additional bits forced to state reset */
  5476. /* instead of modifying only the selected bit for this function, */
  5477. /* to not interfere with bits with HW property "rs". */
  5478. MODIFY_REG(ADCx->CR,
  5479. ADC_CR_BITS_PROPERTY_RS,
  5480. ADC_CR_ADVREGEN_0);
  5481. }
  5482. /**
  5483. * @brief Disable ADC internal voltage regulator.
  5484. * @note On this STM32 series, setting of this feature is conditioned to
  5485. * ADC state:
  5486. * ADC must be ADC disabled.
  5487. * @rmtoll CR ADVREGEN LL_ADC_DisableInternalRegulator
  5488. * @param ADCx ADC instance
  5489. * @retval None
  5490. */
  5491. __STATIC_INLINE void LL_ADC_DisableInternalRegulator(ADC_TypeDef *ADCx)
  5492. {
  5493. CLEAR_BIT(ADCx->CR, (ADC_CR_ADVREGEN | ADC_CR_BITS_PROPERTY_RS));
  5494. }
  5495. /**
  5496. * @brief Get the selected ADC instance internal voltage regulator state.
  5497. * @rmtoll CR ADVREGEN LL_ADC_IsInternalRegulatorEnabled
  5498. * @param ADCx ADC instance
  5499. * @retval 0: internal regulator is disabled, 1: internal regulator is enabled.
  5500. */
  5501. __STATIC_INLINE uint32_t LL_ADC_IsInternalRegulatorEnabled(ADC_TypeDef *ADCx)
  5502. {
  5503. return (READ_BIT(ADCx->CR, (ADC_CR_ADVREGEN_1 | ADC_CR_ADVREGEN_0)) == (ADC_CR_ADVREGEN_0));
  5504. }
  5505. /**
  5506. * @brief Enable the selected ADC instance.
  5507. * @note On this STM32 series, after ADC enable, a delay for
  5508. * ADC internal analog stabilization is required before performing a
  5509. * ADC conversion start.
  5510. * Refer to device datasheet, parameter tSTAB.
  5511. * @note On this STM32 series, flag LL_ADC_FLAG_ADRDY is raised when the ADC
  5512. * is enabled and when conversion clock is active.
  5513. * (not only core clock: this ADC has a dual clock domain)
  5514. * @note On this STM32 series, setting of this feature is conditioned to
  5515. * ADC state:
  5516. * ADC must be ADC disabled and ADC internal voltage regulator enabled.
  5517. * @rmtoll CR ADEN LL_ADC_Enable
  5518. * @param ADCx ADC instance
  5519. * @retval None
  5520. */
  5521. __STATIC_INLINE void LL_ADC_Enable(ADC_TypeDef *ADCx)
  5522. {
  5523. /* Note: Write register with some additional bits forced to state reset */
  5524. /* instead of modifying only the selected bit for this function, */
  5525. /* to not interfere with bits with HW property "rs". */
  5526. MODIFY_REG(ADCx->CR,
  5527. ADC_CR_BITS_PROPERTY_RS,
  5528. ADC_CR_ADEN);
  5529. }
  5530. /**
  5531. * @brief Disable the selected ADC instance.
  5532. * @note On this STM32 series, setting of this feature is conditioned to
  5533. * ADC state:
  5534. * ADC must be not disabled. Must be enabled without conversion on going
  5535. * on either groups regular or injected.
  5536. * @rmtoll CR ADDIS LL_ADC_Disable
  5537. * @param ADCx ADC instance
  5538. * @retval None
  5539. */
  5540. __STATIC_INLINE void LL_ADC_Disable(ADC_TypeDef *ADCx)
  5541. {
  5542. /* Note: Write register with some additional bits forced to state reset */
  5543. /* instead of modifying only the selected bit for this function, */
  5544. /* to not interfere with bits with HW property "rs". */
  5545. MODIFY_REG(ADCx->CR,
  5546. ADC_CR_BITS_PROPERTY_RS,
  5547. ADC_CR_ADDIS);
  5548. }
  5549. /**
  5550. * @brief Get the selected ADC instance enable state.
  5551. * @note On this STM32 series, flag LL_ADC_FLAG_ADRDY is raised when the ADC
  5552. * is enabled and when conversion clock is active.
  5553. * (not only core clock: this ADC has a dual clock domain)
  5554. * @rmtoll CR ADEN LL_ADC_IsEnabled
  5555. * @param ADCx ADC instance
  5556. * @retval 0: ADC is disabled, 1: ADC is enabled.
  5557. */
  5558. __STATIC_INLINE uint32_t LL_ADC_IsEnabled(ADC_TypeDef *ADCx)
  5559. {
  5560. return (READ_BIT(ADCx->CR, ADC_CR_ADEN) == (ADC_CR_ADEN));
  5561. }
  5562. /**
  5563. * @brief Get the selected ADC instance disable state.
  5564. * @rmtoll CR ADDIS LL_ADC_IsDisableOngoing
  5565. * @param ADCx ADC instance
  5566. * @retval 0: no ADC disable command on going.
  5567. */
  5568. __STATIC_INLINE uint32_t LL_ADC_IsDisableOngoing(ADC_TypeDef *ADCx)
  5569. {
  5570. return (READ_BIT(ADCx->CR, ADC_CR_ADDIS) == (ADC_CR_ADDIS));
  5571. }
  5572. /**
  5573. * @brief Start ADC calibration in the mode single-ended
  5574. * or differential (for devices with differential mode available).
  5575. * @note On this STM32 series, a minimum number of ADC clock cycles
  5576. * are required between ADC end of calibration and ADC enable.
  5577. * Refer to literal @ref LL_ADC_DELAY_CALIB_ENABLE_ADC_CYCLES.
  5578. * @note For devices with differential mode available:
  5579. * Calibration of offset is specific to each of
  5580. * single-ended and differential modes
  5581. * (calibration run must be performed for each of these
  5582. * differential modes, if used afterwards and if the application
  5583. * requires their calibration).
  5584. * @note On this STM32 series, setting of this feature is conditioned to
  5585. * ADC state:
  5586. * ADC must be ADC disabled.
  5587. * @rmtoll CR ADCAL LL_ADC_StartCalibration\n
  5588. * CR ADCALDIF LL_ADC_StartCalibration
  5589. * @param ADCx ADC instance
  5590. * @param SingleDiff This parameter can be one of the following values:
  5591. * @arg @ref LL_ADC_SINGLE_ENDED
  5592. * @arg @ref LL_ADC_DIFFERENTIAL_ENDED
  5593. * @retval None
  5594. */
  5595. __STATIC_INLINE void LL_ADC_StartCalibration(ADC_TypeDef *ADCx, uint32_t SingleDiff)
  5596. {
  5597. /* Note: Write register with some additional bits forced to state reset */
  5598. /* instead of modifying only the selected bit for this function, */
  5599. /* to not interfere with bits with HW property "rs". */
  5600. MODIFY_REG(ADCx->CR,
  5601. ADC_CR_ADCALDIF | ADC_CR_BITS_PROPERTY_RS,
  5602. ADC_CR_ADCAL | (SingleDiff & ADC_SINGLEDIFF_CALIB_START_MASK));
  5603. }
  5604. /**
  5605. * @brief Get ADC calibration state.
  5606. * @rmtoll CR ADCAL LL_ADC_IsCalibrationOnGoing
  5607. * @param ADCx ADC instance
  5608. * @retval 0: calibration complete, 1: calibration in progress.
  5609. */
  5610. __STATIC_INLINE uint32_t LL_ADC_IsCalibrationOnGoing(ADC_TypeDef *ADCx)
  5611. {
  5612. return (READ_BIT(ADCx->CR, ADC_CR_ADCAL) == (ADC_CR_ADCAL));
  5613. }
  5614. /**
  5615. * @}
  5616. */
  5617. /** @defgroup ADC_LL_EF_Operation_ADC_Group_Regular Operation on ADC hierarchical scope: group regular
  5618. * @{
  5619. */
  5620. /**
  5621. * @brief Start ADC group regular conversion.
  5622. * @note On this STM32 series, this function is relevant for both
  5623. * internal trigger (SW start) and external trigger:
  5624. * - If ADC trigger has been set to software start, ADC conversion
  5625. * starts immediately.
  5626. * - If ADC trigger has been set to external trigger, ADC conversion
  5627. * will start at next trigger event (on the selected trigger edge)
  5628. * following the ADC start conversion command.
  5629. * @note On this STM32 series, setting of this feature is conditioned to
  5630. * ADC state:
  5631. * ADC must be enabled without conversion on going on group regular,
  5632. * without conversion stop command on going on group regular,
  5633. * without ADC disable command on going.
  5634. * @rmtoll CR ADSTART LL_ADC_REG_StartConversion
  5635. * @param ADCx ADC instance
  5636. * @retval None
  5637. */
  5638. __STATIC_INLINE void LL_ADC_REG_StartConversion(ADC_TypeDef *ADCx)
  5639. {
  5640. /* Note: Write register with some additional bits forced to state reset */
  5641. /* instead of modifying only the selected bit for this function, */
  5642. /* to not interfere with bits with HW property "rs". */
  5643. MODIFY_REG(ADCx->CR,
  5644. ADC_CR_BITS_PROPERTY_RS,
  5645. ADC_CR_ADSTART);
  5646. }
  5647. /**
  5648. * @brief Stop ADC group regular conversion.
  5649. * @note On this STM32 series, setting of this feature is conditioned to
  5650. * ADC state:
  5651. * ADC must be enabled with conversion on going on group regular,
  5652. * without ADC disable command on going.
  5653. * @rmtoll CR ADSTP LL_ADC_REG_StopConversion
  5654. * @param ADCx ADC instance
  5655. * @retval None
  5656. */
  5657. __STATIC_INLINE void LL_ADC_REG_StopConversion(ADC_TypeDef *ADCx)
  5658. {
  5659. /* Note: Write register with some additional bits forced to state reset */
  5660. /* instead of modifying only the selected bit for this function, */
  5661. /* to not interfere with bits with HW property "rs". */
  5662. MODIFY_REG(ADCx->CR,
  5663. ADC_CR_BITS_PROPERTY_RS,
  5664. ADC_CR_ADSTP);
  5665. }
  5666. /**
  5667. * @brief Get ADC group regular conversion state.
  5668. * @rmtoll CR ADSTART LL_ADC_REG_IsConversionOngoing
  5669. * @param ADCx ADC instance
  5670. * @retval 0: no conversion is on going on ADC group regular.
  5671. */
  5672. __STATIC_INLINE uint32_t LL_ADC_REG_IsConversionOngoing(ADC_TypeDef *ADCx)
  5673. {
  5674. return (READ_BIT(ADCx->CR, ADC_CR_ADSTART) == (ADC_CR_ADSTART));
  5675. }
  5676. /**
  5677. * @brief Get ADC group regular command of conversion stop state
  5678. * @rmtoll CR ADSTP LL_ADC_REG_IsStopConversionOngoing
  5679. * @param ADCx ADC instance
  5680. * @retval 0: no command of conversion stop is on going on ADC group regular.
  5681. */
  5682. __STATIC_INLINE uint32_t LL_ADC_REG_IsStopConversionOngoing(ADC_TypeDef *ADCx)
  5683. {
  5684. return (READ_BIT(ADCx->CR, ADC_CR_ADSTP) == (ADC_CR_ADSTP));
  5685. }
  5686. /**
  5687. * @brief Get ADC group regular conversion data, range fit for
  5688. * all ADC configurations: all ADC resolutions and
  5689. * all oversampling increased data width (for devices
  5690. * with feature oversampling).
  5691. * @rmtoll DR RDATA LL_ADC_REG_ReadConversionData32
  5692. * @param ADCx ADC instance
  5693. * @retval Value between Min_Data=0x00000000 and Max_Data=0xFFFFFFFF
  5694. */
  5695. __STATIC_INLINE uint32_t LL_ADC_REG_ReadConversionData32(ADC_TypeDef *ADCx)
  5696. {
  5697. return (uint32_t)(READ_BIT(ADCx->DR, ADC_DR_RDATA));
  5698. }
  5699. /**
  5700. * @brief Get ADC group regular conversion data, range fit for
  5701. * ADC resolution 12 bits.
  5702. * @note For devices with feature oversampling: Oversampling
  5703. * can increase data width, function for extended range
  5704. * may be needed: @ref LL_ADC_REG_ReadConversionData32.
  5705. * @rmtoll DR RDATA LL_ADC_REG_ReadConversionData12
  5706. * @param ADCx ADC instance
  5707. * @retval Value between Min_Data=0x000 and Max_Data=0xFFF
  5708. */
  5709. __STATIC_INLINE uint16_t LL_ADC_REG_ReadConversionData12(ADC_TypeDef *ADCx)
  5710. {
  5711. return (uint16_t)(READ_BIT(ADCx->DR, ADC_DR_RDATA));
  5712. }
  5713. /**
  5714. * @brief Get ADC group regular conversion data, range fit for
  5715. * ADC resolution 10 bits.
  5716. * @note For devices with feature oversampling: Oversampling
  5717. * can increase data width, function for extended range
  5718. * may be needed: @ref LL_ADC_REG_ReadConversionData32.
  5719. * @rmtoll DR RDATA LL_ADC_REG_ReadConversionData10
  5720. * @param ADCx ADC instance
  5721. * @retval Value between Min_Data=0x000 and Max_Data=0x3FF
  5722. */
  5723. __STATIC_INLINE uint16_t LL_ADC_REG_ReadConversionData10(ADC_TypeDef *ADCx)
  5724. {
  5725. return (uint16_t)(READ_BIT(ADCx->DR, ADC_DR_RDATA));
  5726. }
  5727. /**
  5728. * @brief Get ADC group regular conversion data, range fit for
  5729. * ADC resolution 8 bits.
  5730. * @note For devices with feature oversampling: Oversampling
  5731. * can increase data width, function for extended range
  5732. * may be needed: @ref LL_ADC_REG_ReadConversionData32.
  5733. * @rmtoll DR RDATA LL_ADC_REG_ReadConversionData8
  5734. * @param ADCx ADC instance
  5735. * @retval Value between Min_Data=0x00 and Max_Data=0xFF
  5736. */
  5737. __STATIC_INLINE uint8_t LL_ADC_REG_ReadConversionData8(ADC_TypeDef *ADCx)
  5738. {
  5739. return (uint8_t)(READ_BIT(ADCx->DR, ADC_DR_RDATA));
  5740. }
  5741. /**
  5742. * @brief Get ADC group regular conversion data, range fit for
  5743. * ADC resolution 6 bits.
  5744. * @note For devices with feature oversampling: Oversampling
  5745. * can increase data width, function for extended range
  5746. * may be needed: @ref LL_ADC_REG_ReadConversionData32.
  5747. * @rmtoll DR RDATA LL_ADC_REG_ReadConversionData6
  5748. * @param ADCx ADC instance
  5749. * @retval Value between Min_Data=0x00 and Max_Data=0x3F
  5750. */
  5751. __STATIC_INLINE uint8_t LL_ADC_REG_ReadConversionData6(ADC_TypeDef *ADCx)
  5752. {
  5753. return (uint8_t)(READ_BIT(ADCx->DR, ADC_DR_RDATA));
  5754. }
  5755. #if defined(ADC_MULTIMODE_SUPPORT)
  5756. /**
  5757. * @brief Get ADC multimode conversion data of ADC master, ADC slave
  5758. * or raw data with ADC master and slave concatenated.
  5759. * @note If raw data with ADC master and slave concatenated is retrieved,
  5760. * a macro is available to get the conversion data of
  5761. * ADC master or ADC slave: see helper macro
  5762. * @ref __LL_ADC_MULTI_CONV_DATA_MASTER_SLAVE().
  5763. * (however this macro is mainly intended for multimode
  5764. * transfer by DMA, because this function can do the same
  5765. * by getting multimode conversion data of ADC master or ADC slave
  5766. * separately).
  5767. * @rmtoll CDR RDATA_MST LL_ADC_REG_ReadMultiConversionData32\n
  5768. * CDR RDATA_SLV LL_ADC_REG_ReadMultiConversionData32
  5769. * @param ADCxy_COMMON ADC common instance
  5770. * (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() )
  5771. * @param ConversionData This parameter can be one of the following values:
  5772. * @arg @ref LL_ADC_MULTI_MASTER
  5773. * @arg @ref LL_ADC_MULTI_SLAVE
  5774. * @arg @ref LL_ADC_MULTI_MASTER_SLAVE
  5775. * @retval Value between Min_Data=0x00000000 and Max_Data=0xFFFFFFFF
  5776. */
  5777. __STATIC_INLINE uint32_t LL_ADC_REG_ReadMultiConversionData32(ADC_Common_TypeDef *ADCxy_COMMON, uint32_t ConversionData)
  5778. {
  5779. return (uint32_t)(READ_BIT(ADCxy_COMMON->CDR,
  5780. ConversionData)
  5781. >> POSITION_VAL(ConversionData)
  5782. );
  5783. }
  5784. #endif /* ADC_MULTIMODE_SUPPORT */
  5785. /**
  5786. * @}
  5787. */
  5788. /** @defgroup ADC_LL_EF_Operation_ADC_Group_Injected Operation on ADC hierarchical scope: group injected
  5789. * @{
  5790. */
  5791. /**
  5792. * @brief Start ADC group injected conversion.
  5793. * @note On this STM32 series, this function is relevant for both
  5794. * internal trigger (SW start) and external trigger:
  5795. * - If ADC trigger has been set to software start, ADC conversion
  5796. * starts immediately.
  5797. * - If ADC trigger has been set to external trigger, ADC conversion
  5798. * will start at next trigger event (on the selected trigger edge)
  5799. * following the ADC start conversion command.
  5800. * @note On this STM32 series, setting of this feature is conditioned to
  5801. * ADC state:
  5802. * ADC must be enabled without conversion on going on group injected,
  5803. * without conversion stop command on going on group injected,
  5804. * without ADC disable command on going.
  5805. * @rmtoll CR JADSTART LL_ADC_INJ_StartConversion
  5806. * @param ADCx ADC instance
  5807. * @retval None
  5808. */
  5809. __STATIC_INLINE void LL_ADC_INJ_StartConversion(ADC_TypeDef *ADCx)
  5810. {
  5811. /* Note: Write register with some additional bits forced to state reset */
  5812. /* instead of modifying only the selected bit for this function, */
  5813. /* to not interfere with bits with HW property "rs". */
  5814. MODIFY_REG(ADCx->CR,
  5815. ADC_CR_BITS_PROPERTY_RS,
  5816. ADC_CR_JADSTART);
  5817. }
  5818. /**
  5819. * @brief Stop ADC group injected conversion.
  5820. * @note On this STM32 series, setting of this feature is conditioned to
  5821. * ADC state:
  5822. * ADC must be enabled with conversion on going on group injected,
  5823. * without ADC disable command on going.
  5824. * @rmtoll CR JADSTP LL_ADC_INJ_StopConversion
  5825. * @param ADCx ADC instance
  5826. * @retval None
  5827. */
  5828. __STATIC_INLINE void LL_ADC_INJ_StopConversion(ADC_TypeDef *ADCx)
  5829. {
  5830. /* Note: Write register with some additional bits forced to state reset */
  5831. /* instead of modifying only the selected bit for this function, */
  5832. /* to not interfere with bits with HW property "rs". */
  5833. MODIFY_REG(ADCx->CR,
  5834. ADC_CR_BITS_PROPERTY_RS,
  5835. ADC_CR_JADSTP);
  5836. }
  5837. /**
  5838. * @brief Get ADC group injected conversion state.
  5839. * @rmtoll CR JADSTART LL_ADC_INJ_IsConversionOngoing
  5840. * @param ADCx ADC instance
  5841. * @retval 0: no conversion is on going on ADC group injected.
  5842. */
  5843. __STATIC_INLINE uint32_t LL_ADC_INJ_IsConversionOngoing(ADC_TypeDef *ADCx)
  5844. {
  5845. return (READ_BIT(ADCx->CR, ADC_CR_JADSTART) == (ADC_CR_JADSTART));
  5846. }
  5847. /**
  5848. * @brief Get ADC group injected command of conversion stop state
  5849. * @rmtoll CR JADSTP LL_ADC_INJ_IsStopConversionOngoing
  5850. * @param ADCx ADC instance
  5851. * @retval 0: no command of conversion stop is on going on ADC group injected.
  5852. */
  5853. __STATIC_INLINE uint32_t LL_ADC_INJ_IsStopConversionOngoing(ADC_TypeDef *ADCx)
  5854. {
  5855. return (READ_BIT(ADCx->CR, ADC_CR_JADSTP) == (ADC_CR_JADSTP));
  5856. }
  5857. /**
  5858. * @brief Get ADC group regular conversion data, range fit for
  5859. * all ADC configurations: all ADC resolutions and
  5860. * all oversampling increased data width (for devices
  5861. * with feature oversampling).
  5862. * @rmtoll JDR1 JDATA LL_ADC_INJ_ReadConversionData32\n
  5863. * JDR2 JDATA LL_ADC_INJ_ReadConversionData32\n
  5864. * JDR3 JDATA LL_ADC_INJ_ReadConversionData32\n
  5865. * JDR4 JDATA LL_ADC_INJ_ReadConversionData32
  5866. * @param ADCx ADC instance
  5867. * @param Rank This parameter can be one of the following values:
  5868. * @arg @ref LL_ADC_INJ_RANK_1
  5869. * @arg @ref LL_ADC_INJ_RANK_2
  5870. * @arg @ref LL_ADC_INJ_RANK_3
  5871. * @arg @ref LL_ADC_INJ_RANK_4
  5872. * @retval Value between Min_Data=0x00000000 and Max_Data=0xFFFFFFFF
  5873. */
  5874. __STATIC_INLINE uint32_t LL_ADC_INJ_ReadConversionData32(ADC_TypeDef *ADCx, uint32_t Rank)
  5875. {
  5876. __IO uint32_t *preg = __ADC_PTR_REG_OFFSET(ADCx->JDR1, __ADC_MASK_SHIFT(Rank, ADC_INJ_JDRX_REGOFFSET_MASK));
  5877. return (uint32_t)(READ_BIT(*preg,
  5878. ADC_JDR1_JDATA)
  5879. );
  5880. }
  5881. /**
  5882. * @brief Get ADC group injected conversion data, range fit for
  5883. * ADC resolution 12 bits.
  5884. * @note For devices with feature oversampling: Oversampling
  5885. * can increase data width, function for extended range
  5886. * may be needed: @ref LL_ADC_INJ_ReadConversionData32.
  5887. * @rmtoll JDR1 JDATA LL_ADC_INJ_ReadConversionData12\n
  5888. * JDR2 JDATA LL_ADC_INJ_ReadConversionData12\n
  5889. * JDR3 JDATA LL_ADC_INJ_ReadConversionData12\n
  5890. * JDR4 JDATA LL_ADC_INJ_ReadConversionData12
  5891. * @param ADCx ADC instance
  5892. * @param Rank This parameter can be one of the following values:
  5893. * @arg @ref LL_ADC_INJ_RANK_1
  5894. * @arg @ref LL_ADC_INJ_RANK_2
  5895. * @arg @ref LL_ADC_INJ_RANK_3
  5896. * @arg @ref LL_ADC_INJ_RANK_4
  5897. * @retval Value between Min_Data=0x000 and Max_Data=0xFFF
  5898. */
  5899. __STATIC_INLINE uint16_t LL_ADC_INJ_ReadConversionData12(ADC_TypeDef *ADCx, uint32_t Rank)
  5900. {
  5901. __IO uint32_t *preg = __ADC_PTR_REG_OFFSET(ADCx->JDR1, __ADC_MASK_SHIFT(Rank, ADC_INJ_JDRX_REGOFFSET_MASK));
  5902. return (uint16_t)(READ_BIT(*preg,
  5903. ADC_JDR1_JDATA)
  5904. );
  5905. }
  5906. /**
  5907. * @brief Get ADC group injected conversion data, range fit for
  5908. * ADC resolution 10 bits.
  5909. * @note For devices with feature oversampling: Oversampling
  5910. * can increase data width, function for extended range
  5911. * may be needed: @ref LL_ADC_INJ_ReadConversionData32.
  5912. * @rmtoll JDR1 JDATA LL_ADC_INJ_ReadConversionData10\n
  5913. * JDR2 JDATA LL_ADC_INJ_ReadConversionData10\n
  5914. * JDR3 JDATA LL_ADC_INJ_ReadConversionData10\n
  5915. * JDR4 JDATA LL_ADC_INJ_ReadConversionData10
  5916. * @param ADCx ADC instance
  5917. * @param Rank This parameter can be one of the following values:
  5918. * @arg @ref LL_ADC_INJ_RANK_1
  5919. * @arg @ref LL_ADC_INJ_RANK_2
  5920. * @arg @ref LL_ADC_INJ_RANK_3
  5921. * @arg @ref LL_ADC_INJ_RANK_4
  5922. * @retval Value between Min_Data=0x000 and Max_Data=0x3FF
  5923. */
  5924. __STATIC_INLINE uint16_t LL_ADC_INJ_ReadConversionData10(ADC_TypeDef *ADCx, uint32_t Rank)
  5925. {
  5926. __IO uint32_t *preg = __ADC_PTR_REG_OFFSET(ADCx->JDR1, __ADC_MASK_SHIFT(Rank, ADC_INJ_JDRX_REGOFFSET_MASK));
  5927. return (uint16_t)(READ_BIT(*preg,
  5928. ADC_JDR1_JDATA)
  5929. );
  5930. }
  5931. /**
  5932. * @brief Get ADC group injected conversion data, range fit for
  5933. * ADC resolution 8 bits.
  5934. * @note For devices with feature oversampling: Oversampling
  5935. * can increase data width, function for extended range
  5936. * may be needed: @ref LL_ADC_INJ_ReadConversionData32.
  5937. * @rmtoll JDR1 JDATA LL_ADC_INJ_ReadConversionData8\n
  5938. * JDR2 JDATA LL_ADC_INJ_ReadConversionData8\n
  5939. * JDR3 JDATA LL_ADC_INJ_ReadConversionData8\n
  5940. * JDR4 JDATA LL_ADC_INJ_ReadConversionData8
  5941. * @param ADCx ADC instance
  5942. * @param Rank This parameter can be one of the following values:
  5943. * @arg @ref LL_ADC_INJ_RANK_1
  5944. * @arg @ref LL_ADC_INJ_RANK_2
  5945. * @arg @ref LL_ADC_INJ_RANK_3
  5946. * @arg @ref LL_ADC_INJ_RANK_4
  5947. * @retval Value between Min_Data=0x00 and Max_Data=0xFF
  5948. */
  5949. __STATIC_INLINE uint8_t LL_ADC_INJ_ReadConversionData8(ADC_TypeDef *ADCx, uint32_t Rank)
  5950. {
  5951. __IO uint32_t *preg = __ADC_PTR_REG_OFFSET(ADCx->JDR1, __ADC_MASK_SHIFT(Rank, ADC_INJ_JDRX_REGOFFSET_MASK));
  5952. return (uint8_t)(READ_BIT(*preg,
  5953. ADC_JDR1_JDATA)
  5954. );
  5955. }
  5956. /**
  5957. * @brief Get ADC group injected conversion data, range fit for
  5958. * ADC resolution 6 bits.
  5959. * @note For devices with feature oversampling: Oversampling
  5960. * can increase data width, function for extended range
  5961. * may be needed: @ref LL_ADC_INJ_ReadConversionData32.
  5962. * @rmtoll JDR1 JDATA LL_ADC_INJ_ReadConversionData6\n
  5963. * JDR2 JDATA LL_ADC_INJ_ReadConversionData6\n
  5964. * JDR3 JDATA LL_ADC_INJ_ReadConversionData6\n
  5965. * JDR4 JDATA LL_ADC_INJ_ReadConversionData6
  5966. * @param ADCx ADC instance
  5967. * @param Rank This parameter can be one of the following values:
  5968. * @arg @ref LL_ADC_INJ_RANK_1
  5969. * @arg @ref LL_ADC_INJ_RANK_2
  5970. * @arg @ref LL_ADC_INJ_RANK_3
  5971. * @arg @ref LL_ADC_INJ_RANK_4
  5972. * @retval Value between Min_Data=0x00 and Max_Data=0x3F
  5973. */
  5974. __STATIC_INLINE uint8_t LL_ADC_INJ_ReadConversionData6(ADC_TypeDef *ADCx, uint32_t Rank)
  5975. {
  5976. __IO uint32_t *preg = __ADC_PTR_REG_OFFSET(ADCx->JDR1, __ADC_MASK_SHIFT(Rank, ADC_INJ_JDRX_REGOFFSET_MASK));
  5977. return (uint8_t)(READ_BIT(*preg,
  5978. ADC_JDR1_JDATA)
  5979. );
  5980. }
  5981. /**
  5982. * @}
  5983. */
  5984. /** @defgroup ADC_LL_EF_FLAG_Management ADC flag management
  5985. * @{
  5986. */
  5987. /**
  5988. * @brief Get flag ADC ready.
  5989. * @note On this STM32 series, flag LL_ADC_FLAG_ADRDY is raised when the ADC
  5990. * is enabled and when conversion clock is active.
  5991. * (not only core clock: this ADC has a dual clock domain)
  5992. * @rmtoll ISR ADRDY LL_ADC_IsActiveFlag_ADRDY
  5993. * @param ADCx ADC instance
  5994. * @retval State of bit (1 or 0).
  5995. */
  5996. __STATIC_INLINE uint32_t LL_ADC_IsActiveFlag_ADRDY(ADC_TypeDef *ADCx)
  5997. {
  5998. return (READ_BIT(ADCx->ISR, LL_ADC_FLAG_ADRDY) == (LL_ADC_FLAG_ADRDY));
  5999. }
  6000. /**
  6001. * @brief Get flag ADC group regular end of unitary conversion.
  6002. * @rmtoll ISR EOC LL_ADC_IsActiveFlag_EOC
  6003. * @param ADCx ADC instance
  6004. * @retval State of bit (1 or 0).
  6005. */
  6006. __STATIC_INLINE uint32_t LL_ADC_IsActiveFlag_EOC(ADC_TypeDef *ADCx)
  6007. {
  6008. return (READ_BIT(ADCx->ISR, ADC_ISR_EOC) == (ADC_ISR_EOC));
  6009. }
  6010. /**
  6011. * @brief Get flag ADC group regular end of sequence conversions.
  6012. * @rmtoll ISR EOS LL_ADC_IsActiveFlag_EOS
  6013. * @param ADCx ADC instance
  6014. * @retval State of bit (1 or 0).
  6015. */
  6016. __STATIC_INLINE uint32_t LL_ADC_IsActiveFlag_EOS(ADC_TypeDef *ADCx)
  6017. {
  6018. return (READ_BIT(ADCx->ISR, LL_ADC_FLAG_EOS) == (LL_ADC_FLAG_EOS));
  6019. }
  6020. /**
  6021. * @brief Get flag ADC group regular overrun.
  6022. * @rmtoll ISR OVR LL_ADC_IsActiveFlag_OVR
  6023. * @param ADCx ADC instance
  6024. * @retval State of bit (1 or 0).
  6025. */
  6026. __STATIC_INLINE uint32_t LL_ADC_IsActiveFlag_OVR(ADC_TypeDef *ADCx)
  6027. {
  6028. return (READ_BIT(ADCx->ISR, LL_ADC_FLAG_OVR) == (LL_ADC_FLAG_OVR));
  6029. }
  6030. /**
  6031. * @brief Get flag ADC group regular end of sampling phase.
  6032. * @rmtoll ISR EOSMP LL_ADC_IsActiveFlag_EOSMP
  6033. * @param ADCx ADC instance
  6034. * @retval State of bit (1 or 0).
  6035. */
  6036. __STATIC_INLINE uint32_t LL_ADC_IsActiveFlag_EOSMP(ADC_TypeDef *ADCx)
  6037. {
  6038. return (READ_BIT(ADCx->ISR, LL_ADC_FLAG_EOSMP) == (LL_ADC_FLAG_EOSMP));
  6039. }
  6040. /**
  6041. * @brief Get flag ADC group injected end of unitary conversion.
  6042. * @rmtoll ISR JEOC LL_ADC_IsActiveFlag_JEOC
  6043. * @param ADCx ADC instance
  6044. * @retval State of bit (1 or 0).
  6045. */
  6046. __STATIC_INLINE uint32_t LL_ADC_IsActiveFlag_JEOC(ADC_TypeDef *ADCx)
  6047. {
  6048. return (READ_BIT(ADCx->ISR, LL_ADC_FLAG_JEOC) == (LL_ADC_FLAG_JEOC));
  6049. }
  6050. /**
  6051. * @brief Get flag ADC group injected end of sequence conversions.
  6052. * @rmtoll ISR JEOS LL_ADC_IsActiveFlag_JEOS
  6053. * @param ADCx ADC instance
  6054. * @retval State of bit (1 or 0).
  6055. */
  6056. __STATIC_INLINE uint32_t LL_ADC_IsActiveFlag_JEOS(ADC_TypeDef *ADCx)
  6057. {
  6058. return (READ_BIT(ADCx->ISR, LL_ADC_FLAG_JEOS) == (LL_ADC_FLAG_JEOS));
  6059. }
  6060. /**
  6061. * @brief Get flag ADC group injected contexts queue overflow.
  6062. * @rmtoll ISR JQOVF LL_ADC_IsActiveFlag_JQOVF
  6063. * @param ADCx ADC instance
  6064. * @retval State of bit (1 or 0).
  6065. */
  6066. __STATIC_INLINE uint32_t LL_ADC_IsActiveFlag_JQOVF(ADC_TypeDef *ADCx)
  6067. {
  6068. return (READ_BIT(ADCx->ISR, LL_ADC_FLAG_JQOVF) == (LL_ADC_FLAG_JQOVF));
  6069. }
  6070. /**
  6071. * @brief Get flag ADC analog watchdog 1 flag
  6072. * @rmtoll ISR AWD1 LL_ADC_IsActiveFlag_AWD1
  6073. * @param ADCx ADC instance
  6074. * @retval State of bit (1 or 0).
  6075. */
  6076. __STATIC_INLINE uint32_t LL_ADC_IsActiveFlag_AWD1(ADC_TypeDef *ADCx)
  6077. {
  6078. return (READ_BIT(ADCx->ISR, LL_ADC_FLAG_AWD1) == (LL_ADC_FLAG_AWD1));
  6079. }
  6080. /**
  6081. * @brief Get flag ADC analog watchdog 2.
  6082. * @rmtoll ISR AWD2 LL_ADC_IsActiveFlag_AWD2
  6083. * @param ADCx ADC instance
  6084. * @retval State of bit (1 or 0).
  6085. */
  6086. __STATIC_INLINE uint32_t LL_ADC_IsActiveFlag_AWD2(ADC_TypeDef *ADCx)
  6087. {
  6088. return (READ_BIT(ADCx->ISR, LL_ADC_FLAG_AWD2) == (LL_ADC_FLAG_AWD2));
  6089. }
  6090. /**
  6091. * @brief Get flag ADC analog watchdog 3.
  6092. * @rmtoll ISR AWD3 LL_ADC_IsActiveFlag_AWD3
  6093. * @param ADCx ADC instance
  6094. * @retval State of bit (1 or 0).
  6095. */
  6096. __STATIC_INLINE uint32_t LL_ADC_IsActiveFlag_AWD3(ADC_TypeDef *ADCx)
  6097. {
  6098. return (READ_BIT(ADCx->ISR, LL_ADC_FLAG_AWD3) == (LL_ADC_FLAG_AWD3));
  6099. }
  6100. /**
  6101. * @brief Clear flag ADC ready.
  6102. * @note On this STM32 series, flag LL_ADC_FLAG_ADRDY is raised when the ADC
  6103. * is enabled and when conversion clock is active.
  6104. * (not only core clock: this ADC has a dual clock domain)
  6105. * @rmtoll ISR ADRDY LL_ADC_ClearFlag_ADRDY
  6106. * @param ADCx ADC instance
  6107. * @retval None
  6108. */
  6109. __STATIC_INLINE void LL_ADC_ClearFlag_ADRDY(ADC_TypeDef *ADCx)
  6110. {
  6111. WRITE_REG(ADCx->ISR, LL_ADC_FLAG_ADRDY);
  6112. }
  6113. /**
  6114. * @brief Clear flag ADC group regular end of unitary conversion.
  6115. * @rmtoll ISR EOC LL_ADC_ClearFlag_EOC
  6116. * @param ADCx ADC instance
  6117. * @retval None
  6118. */
  6119. __STATIC_INLINE void LL_ADC_ClearFlag_EOC(ADC_TypeDef *ADCx)
  6120. {
  6121. WRITE_REG(ADCx->ISR, LL_ADC_FLAG_EOC);
  6122. }
  6123. /**
  6124. * @brief Clear flag ADC group regular end of sequence conversions.
  6125. * @rmtoll ISR EOS LL_ADC_ClearFlag_EOS
  6126. * @param ADCx ADC instance
  6127. * @retval None
  6128. */
  6129. __STATIC_INLINE void LL_ADC_ClearFlag_EOS(ADC_TypeDef *ADCx)
  6130. {
  6131. WRITE_REG(ADCx->ISR, LL_ADC_FLAG_EOS);
  6132. }
  6133. /**
  6134. * @brief Clear flag ADC group regular overrun.
  6135. * @rmtoll ISR OVR LL_ADC_ClearFlag_OVR
  6136. * @param ADCx ADC instance
  6137. * @retval None
  6138. */
  6139. __STATIC_INLINE void LL_ADC_ClearFlag_OVR(ADC_TypeDef *ADCx)
  6140. {
  6141. WRITE_REG(ADCx->ISR, LL_ADC_FLAG_OVR);
  6142. }
  6143. /**
  6144. * @brief Clear flag ADC group regular end of sampling phase.
  6145. * @rmtoll ISR EOSMP LL_ADC_ClearFlag_EOSMP
  6146. * @param ADCx ADC instance
  6147. * @retval None
  6148. */
  6149. __STATIC_INLINE void LL_ADC_ClearFlag_EOSMP(ADC_TypeDef *ADCx)
  6150. {
  6151. WRITE_REG(ADCx->ISR, LL_ADC_FLAG_EOSMP);
  6152. }
  6153. /**
  6154. * @brief Clear flag ADC group injected end of unitary conversion.
  6155. * @rmtoll ISR JEOC LL_ADC_ClearFlag_JEOC
  6156. * @param ADCx ADC instance
  6157. * @retval None
  6158. */
  6159. __STATIC_INLINE void LL_ADC_ClearFlag_JEOC(ADC_TypeDef *ADCx)
  6160. {
  6161. WRITE_REG(ADCx->ISR, LL_ADC_FLAG_JEOC);
  6162. }
  6163. /**
  6164. * @brief Clear flag ADC group injected end of sequence conversions.
  6165. * @rmtoll ISR JEOS LL_ADC_ClearFlag_JEOS
  6166. * @param ADCx ADC instance
  6167. * @retval None
  6168. */
  6169. __STATIC_INLINE void LL_ADC_ClearFlag_JEOS(ADC_TypeDef *ADCx)
  6170. {
  6171. WRITE_REG(ADCx->ISR, LL_ADC_FLAG_JEOS);
  6172. }
  6173. /**
  6174. * @brief Clear flag ADC group injected contexts queue overflow.
  6175. * @rmtoll ISR JQOVF LL_ADC_ClearFlag_JQOVF
  6176. * @param ADCx ADC instance
  6177. * @retval None
  6178. */
  6179. __STATIC_INLINE void LL_ADC_ClearFlag_JQOVF(ADC_TypeDef *ADCx)
  6180. {
  6181. WRITE_REG(ADCx->ISR, LL_ADC_FLAG_JQOVF);
  6182. }
  6183. /**
  6184. * @brief Clear flag ADC analog watchdog 1.
  6185. * @rmtoll ISR AWD1 LL_ADC_ClearFlag_AWD1
  6186. * @param ADCx ADC instance
  6187. * @retval None
  6188. */
  6189. __STATIC_INLINE void LL_ADC_ClearFlag_AWD1(ADC_TypeDef *ADCx)
  6190. {
  6191. WRITE_REG(ADCx->ISR, LL_ADC_FLAG_AWD1);
  6192. }
  6193. /**
  6194. * @brief Clear flag ADC analog watchdog 2.
  6195. * @rmtoll ISR AWD2 LL_ADC_ClearFlag_AWD2
  6196. * @param ADCx ADC instance
  6197. * @retval None
  6198. */
  6199. __STATIC_INLINE void LL_ADC_ClearFlag_AWD2(ADC_TypeDef *ADCx)
  6200. {
  6201. WRITE_REG(ADCx->ISR, LL_ADC_FLAG_AWD2);
  6202. }
  6203. /**
  6204. * @brief Clear flag ADC analog watchdog 3.
  6205. * @rmtoll ISR AWD3 LL_ADC_ClearFlag_AWD3
  6206. * @param ADCx ADC instance
  6207. * @retval None
  6208. */
  6209. __STATIC_INLINE void LL_ADC_ClearFlag_AWD3(ADC_TypeDef *ADCx)
  6210. {
  6211. WRITE_REG(ADCx->ISR, LL_ADC_FLAG_AWD3);
  6212. }
  6213. #if defined(ADC_MULTIMODE_SUPPORT)
  6214. /**
  6215. * @brief Get flag multimode ADC ready of the ADC master.
  6216. * @rmtoll CSR ADRDY_MST LL_ADC_IsActiveFlag_MST_ADRDY
  6217. * @param ADCxy_COMMON ADC common instance
  6218. * (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() )
  6219. * @retval State of bit (1 or 0).
  6220. */
  6221. __STATIC_INLINE uint32_t LL_ADC_IsActiveFlag_MST_ADRDY(ADC_Common_TypeDef *ADCxy_COMMON)
  6222. {
  6223. return (READ_BIT(ADCxy_COMMON->CSR, LL_ADC_FLAG_ADRDY_MST) == (LL_ADC_FLAG_ADRDY_MST));
  6224. }
  6225. /**
  6226. * @brief Get flag multimode ADC ready of the ADC slave.
  6227. * @rmtoll CSR ADRDY_SLV LL_ADC_IsActiveFlag_SLV_ADRDY
  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 State of bit (1 or 0).
  6231. */
  6232. __STATIC_INLINE uint32_t LL_ADC_IsActiveFlag_SLV_ADRDY(ADC_Common_TypeDef *ADCxy_COMMON)
  6233. {
  6234. return (READ_BIT(ADCxy_COMMON->CSR, LL_ADC_FLAG_ADRDY_SLV) == (LL_ADC_FLAG_ADRDY_SLV));
  6235. }
  6236. /**
  6237. * @brief Get flag multimode ADC group regular end of unitary conversion of the ADC master.
  6238. * @rmtoll CSR EOC_MST LL_ADC_IsActiveFlag_MST_EOC
  6239. * @param ADCxy_COMMON ADC common instance
  6240. * (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() )
  6241. * @retval State of bit (1 or 0).
  6242. */
  6243. __STATIC_INLINE uint32_t LL_ADC_IsActiveFlag_MST_EOC(ADC_Common_TypeDef *ADCxy_COMMON)
  6244. {
  6245. return (READ_BIT(ADCxy_COMMON->CSR, LL_ADC_FLAG_EOC_SLV) == (LL_ADC_FLAG_EOC_SLV));
  6246. }
  6247. /**
  6248. * @brief Get flag multimode ADC group regular end of unitary conversion of the ADC slave.
  6249. * @rmtoll CSR EOC_SLV LL_ADC_IsActiveFlag_SLV_EOC
  6250. * @param ADCxy_COMMON ADC common instance
  6251. * (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() )
  6252. * @retval State of bit (1 or 0).
  6253. */
  6254. __STATIC_INLINE uint32_t LL_ADC_IsActiveFlag_SLV_EOC(ADC_Common_TypeDef *ADCxy_COMMON)
  6255. {
  6256. return (READ_BIT(ADCxy_COMMON->CSR, LL_ADC_FLAG_EOC_SLV) == (LL_ADC_FLAG_EOC_SLV));
  6257. }
  6258. /**
  6259. * @brief Get flag multimode ADC group regular end of sequence conversions of the ADC master.
  6260. * @rmtoll CSR EOS_MST LL_ADC_IsActiveFlag_MST_EOS
  6261. * @param ADCxy_COMMON ADC common instance
  6262. * (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() )
  6263. * @retval State of bit (1 or 0).
  6264. */
  6265. __STATIC_INLINE uint32_t LL_ADC_IsActiveFlag_MST_EOS(ADC_Common_TypeDef *ADCxy_COMMON)
  6266. {
  6267. return (READ_BIT(ADCxy_COMMON->CSR, LL_ADC_FLAG_EOS_MST) == (LL_ADC_FLAG_EOS_MST));
  6268. }
  6269. /**
  6270. * @brief Get flag multimode ADC group regular end of sequence conversions of the ADC slave.
  6271. * @rmtoll CSR EOS_SLV LL_ADC_IsActiveFlag_SLV_EOS
  6272. * @param ADCxy_COMMON ADC common instance
  6273. * (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() )
  6274. * @retval State of bit (1 or 0).
  6275. */
  6276. __STATIC_INLINE uint32_t LL_ADC_IsActiveFlag_SLV_EOS(ADC_Common_TypeDef *ADCxy_COMMON)
  6277. {
  6278. return (READ_BIT(ADCxy_COMMON->CSR, LL_ADC_FLAG_EOS_SLV) == (LL_ADC_FLAG_EOS_SLV));
  6279. }
  6280. /**
  6281. * @brief Get flag multimode ADC group regular overrun of the ADC master.
  6282. * @rmtoll CSR OVR_MST LL_ADC_IsActiveFlag_MST_OVR
  6283. * @param ADCxy_COMMON ADC common instance
  6284. * (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() )
  6285. * @retval State of bit (1 or 0).
  6286. */
  6287. __STATIC_INLINE uint32_t LL_ADC_IsActiveFlag_MST_OVR(ADC_Common_TypeDef *ADCxy_COMMON)
  6288. {
  6289. return (READ_BIT(ADCxy_COMMON->CSR, LL_ADC_FLAG_OVR_MST) == (LL_ADC_FLAG_OVR_MST));
  6290. }
  6291. /**
  6292. * @brief Get flag multimode ADC group regular overrun of the ADC slave.
  6293. * @rmtoll CSR OVR_SLV LL_ADC_IsActiveFlag_SLV_OVR
  6294. * @param ADCxy_COMMON ADC common instance
  6295. * (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() )
  6296. * @retval State of bit (1 or 0).
  6297. */
  6298. __STATIC_INLINE uint32_t LL_ADC_IsActiveFlag_SLV_OVR(ADC_Common_TypeDef *ADCxy_COMMON)
  6299. {
  6300. return (READ_BIT(ADCxy_COMMON->CSR, LL_ADC_FLAG_OVR_SLV) == (LL_ADC_FLAG_OVR_SLV));
  6301. }
  6302. /**
  6303. * @brief Get flag multimode ADC group regular end of sampling of the ADC master.
  6304. * @rmtoll CSR EOSMP_MST LL_ADC_IsActiveFlag_MST_EOSMP
  6305. * @param ADCxy_COMMON ADC common instance
  6306. * (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() )
  6307. * @retval State of bit (1 or 0).
  6308. */
  6309. __STATIC_INLINE uint32_t LL_ADC_IsActiveFlag_MST_EOSMP(ADC_Common_TypeDef *ADCxy_COMMON)
  6310. {
  6311. return (READ_BIT(ADCxy_COMMON->CSR, LL_ADC_FLAG_EOSMP_MST) == (LL_ADC_FLAG_EOSMP_MST));
  6312. }
  6313. /**
  6314. * @brief Get flag multimode ADC group regular end of sampling of the ADC slave.
  6315. * @rmtoll CSR EOSMP_SLV LL_ADC_IsActiveFlag_SLV_EOSMP
  6316. * @param ADCxy_COMMON ADC common instance
  6317. * (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() )
  6318. * @retval State of bit (1 or 0).
  6319. */
  6320. __STATIC_INLINE uint32_t LL_ADC_IsActiveFlag_SLV_EOSMP(ADC_Common_TypeDef *ADCxy_COMMON)
  6321. {
  6322. return (READ_BIT(ADCxy_COMMON->CSR, LL_ADC_FLAG_EOSMP_SLV) == (LL_ADC_FLAG_EOSMP_SLV));
  6323. }
  6324. /**
  6325. * @brief Get flag multimode ADC group injected end of unitary conversion of the ADC master.
  6326. * @rmtoll CSR JEOC_MST LL_ADC_IsActiveFlag_MST_JEOC
  6327. * @param ADCxy_COMMON ADC common instance
  6328. * (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() )
  6329. * @retval State of bit (1 or 0).
  6330. */
  6331. __STATIC_INLINE uint32_t LL_ADC_IsActiveFlag_MST_JEOC(ADC_Common_TypeDef *ADCxy_COMMON)
  6332. {
  6333. return (READ_BIT(ADCxy_COMMON->CSR, LL_ADC_FLAG_JEOC_MST) == (LL_ADC_FLAG_JEOC_MST));
  6334. }
  6335. /**
  6336. * @brief Get flag multimode ADC group injected end of unitary conversion of the ADC slave.
  6337. * @rmtoll CSR JEOC_SLV LL_ADC_IsActiveFlag_SLV_JEOC
  6338. * @param ADCxy_COMMON ADC common instance
  6339. * (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() )
  6340. * @retval State of bit (1 or 0).
  6341. */
  6342. __STATIC_INLINE uint32_t LL_ADC_IsActiveFlag_SLV_JEOC(ADC_Common_TypeDef *ADCxy_COMMON)
  6343. {
  6344. return (READ_BIT(ADCxy_COMMON->CSR, LL_ADC_FLAG_JEOC_SLV) == (LL_ADC_FLAG_JEOC_SLV));
  6345. }
  6346. /**
  6347. * @brief Get flag multimode ADC group injected end of sequence conversions of the ADC master.
  6348. * @rmtoll CSR JEOS_MST LL_ADC_IsActiveFlag_MST_JEOS
  6349. * @param ADCxy_COMMON ADC common instance
  6350. * (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() )
  6351. * @retval State of bit (1 or 0).
  6352. */
  6353. __STATIC_INLINE uint32_t LL_ADC_IsActiveFlag_MST_JEOS(ADC_Common_TypeDef *ADCxy_COMMON)
  6354. {
  6355. return (READ_BIT(ADCxy_COMMON->CSR, LL_ADC_FLAG_JEOS_MST) == (LL_ADC_FLAG_JEOS_MST));
  6356. }
  6357. /**
  6358. * @brief Get flag multimode ADC group injected end of sequence conversions of the ADC slave.
  6359. * @rmtoll CSR JEOS_SLV LL_ADC_IsActiveFlag_SLV_JEOS
  6360. * @param ADCxy_COMMON ADC common instance
  6361. * (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() )
  6362. * @retval State of bit (1 or 0).
  6363. */
  6364. __STATIC_INLINE uint32_t LL_ADC_IsActiveFlag_SLV_JEOS(ADC_Common_TypeDef *ADCxy_COMMON)
  6365. {
  6366. return (READ_BIT(ADCxy_COMMON->CSR, LL_ADC_FLAG_JEOS_SLV) == (LL_ADC_FLAG_JEOS_SLV));
  6367. }
  6368. /**
  6369. * @brief Get flag multimode ADC group injected context queue overflow of the ADC master.
  6370. * @rmtoll CSR JQOVF_MST LL_ADC_IsActiveFlag_MST_JQOVF
  6371. * @param ADCxy_COMMON ADC common instance
  6372. * (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() )
  6373. * @retval State of bit (1 or 0).
  6374. */
  6375. __STATIC_INLINE uint32_t LL_ADC_IsActiveFlag_MST_JQOVF(ADC_Common_TypeDef *ADCxy_COMMON)
  6376. {
  6377. return (READ_BIT(ADCxy_COMMON->CSR, LL_ADC_FLAG_JQOVF_MST) == (LL_ADC_FLAG_JQOVF_MST));
  6378. }
  6379. /**
  6380. * @brief Get flag multimode ADC group injected context queue overflow of the ADC slave.
  6381. * @rmtoll CSR JQOVF_SLV LL_ADC_IsActiveFlag_SLV_JQOVF
  6382. * @param ADCxy_COMMON ADC common instance
  6383. * (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() )
  6384. * @retval State of bit (1 or 0).
  6385. */
  6386. __STATIC_INLINE uint32_t LL_ADC_IsActiveFlag_SLV_JQOVF(ADC_Common_TypeDef *ADCxy_COMMON)
  6387. {
  6388. return (READ_BIT(ADCxy_COMMON->CSR, LL_ADC_FLAG_JQOVF_SLV) == (LL_ADC_FLAG_JQOVF_SLV));
  6389. }
  6390. /**
  6391. * @brief Get flag multimode ADC analog watchdog 1 of the ADC master.
  6392. * @rmtoll CSR AWD1_MST LL_ADC_IsActiveFlag_MST_AWD1
  6393. * @param ADCxy_COMMON ADC common instance
  6394. * (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() )
  6395. * @retval State of bit (1 or 0).
  6396. */
  6397. __STATIC_INLINE uint32_t LL_ADC_IsActiveFlag_MST_AWD1(ADC_Common_TypeDef *ADCxy_COMMON)
  6398. {
  6399. return (READ_BIT(ADCxy_COMMON->CSR, LL_ADC_FLAG_AWD1_MST) == (LL_ADC_FLAG_AWD1_MST));
  6400. }
  6401. /**
  6402. * @brief Get flag multimode analog watchdog 1 of the ADC slave.
  6403. * @rmtoll CSR AWD1_SLV LL_ADC_IsActiveFlag_SLV_AWD1
  6404. * @param ADCxy_COMMON ADC common instance
  6405. * (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() )
  6406. * @retval State of bit (1 or 0).
  6407. */
  6408. __STATIC_INLINE uint32_t LL_ADC_IsActiveFlag_SLV_AWD1(ADC_Common_TypeDef *ADCxy_COMMON)
  6409. {
  6410. return (READ_BIT(ADCxy_COMMON->CSR, LL_ADC_FLAG_AWD1_SLV) == (LL_ADC_FLAG_AWD1_SLV));
  6411. }
  6412. /**
  6413. * @brief Get flag multimode ADC analog watchdog 2 of the ADC master.
  6414. * @rmtoll CSR AWD2_MST LL_ADC_IsActiveFlag_MST_AWD2
  6415. * @param ADCxy_COMMON ADC common instance
  6416. * (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() )
  6417. * @retval State of bit (1 or 0).
  6418. */
  6419. __STATIC_INLINE uint32_t LL_ADC_IsActiveFlag_MST_AWD2(ADC_Common_TypeDef *ADCxy_COMMON)
  6420. {
  6421. return (READ_BIT(ADCxy_COMMON->CSR, LL_ADC_FLAG_AWD2_MST) == (LL_ADC_FLAG_AWD2_MST));
  6422. }
  6423. /**
  6424. * @brief Get flag multimode ADC analog watchdog 2 of the ADC slave.
  6425. * @rmtoll CSR AWD2_SLV LL_ADC_IsActiveFlag_SLV_AWD2
  6426. * @param ADCxy_COMMON ADC common instance
  6427. * (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() )
  6428. * @retval State of bit (1 or 0).
  6429. */
  6430. __STATIC_INLINE uint32_t LL_ADC_IsActiveFlag_SLV_AWD2(ADC_Common_TypeDef *ADCxy_COMMON)
  6431. {
  6432. return (READ_BIT(ADCxy_COMMON->CSR, LL_ADC_FLAG_AWD2_SLV) == (LL_ADC_FLAG_AWD2_SLV));
  6433. }
  6434. /**
  6435. * @brief Get flag multimode ADC analog watchdog 3 of the ADC master.
  6436. * @rmtoll CSR AWD3_MST LL_ADC_IsActiveFlag_MST_AWD3
  6437. * @param ADCxy_COMMON ADC common instance
  6438. * (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() )
  6439. * @retval State of bit (1 or 0).
  6440. */
  6441. __STATIC_INLINE uint32_t LL_ADC_IsActiveFlag_MST_AWD3(ADC_Common_TypeDef *ADCxy_COMMON)
  6442. {
  6443. return (READ_BIT(ADCxy_COMMON->CSR, LL_ADC_FLAG_AWD3_MST) == (LL_ADC_FLAG_AWD3_MST));
  6444. }
  6445. /**
  6446. * @brief Get flag multimode ADC analog watchdog 3 of the ADC slave.
  6447. * @rmtoll CSR AWD3_SLV LL_ADC_IsActiveFlag_SLV_AWD3
  6448. * @param ADCxy_COMMON ADC common instance
  6449. * (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() )
  6450. * @retval State of bit (1 or 0).
  6451. */
  6452. __STATIC_INLINE uint32_t LL_ADC_IsActiveFlag_SLV_AWD3(ADC_Common_TypeDef *ADCxy_COMMON)
  6453. {
  6454. return (READ_BIT(ADCxy_COMMON->CSR, LL_ADC_FLAG_AWD3_SLV) == (LL_ADC_FLAG_AWD3_SLV));
  6455. }
  6456. #endif /* ADC_MULTIMODE_SUPPORT */
  6457. /**
  6458. * @}
  6459. */
  6460. /** @defgroup ADC_LL_EF_IT_Management ADC IT management
  6461. * @{
  6462. */
  6463. /**
  6464. * @brief Enable ADC ready.
  6465. * @rmtoll IER ADRDYIE LL_ADC_EnableIT_ADRDY
  6466. * @param ADCx ADC instance
  6467. * @retval None
  6468. */
  6469. __STATIC_INLINE void LL_ADC_EnableIT_ADRDY(ADC_TypeDef *ADCx)
  6470. {
  6471. SET_BIT(ADCx->IER, LL_ADC_IT_ADRDY);
  6472. }
  6473. /**
  6474. * @brief Enable interruption ADC group regular end of unitary conversion.
  6475. * @rmtoll IER EOCIE LL_ADC_EnableIT_EOC
  6476. * @param ADCx ADC instance
  6477. * @retval None
  6478. */
  6479. __STATIC_INLINE void LL_ADC_EnableIT_EOC(ADC_TypeDef *ADCx)
  6480. {
  6481. SET_BIT(ADCx->IER, LL_ADC_IT_EOC);
  6482. }
  6483. /**
  6484. * @brief Enable interruption ADC group regular end of sequence conversions.
  6485. * @rmtoll IER EOSIE LL_ADC_EnableIT_EOS
  6486. * @param ADCx ADC instance
  6487. * @retval None
  6488. */
  6489. __STATIC_INLINE void LL_ADC_EnableIT_EOS(ADC_TypeDef *ADCx)
  6490. {
  6491. SET_BIT(ADCx->IER, LL_ADC_IT_EOS);
  6492. }
  6493. /**
  6494. * @brief Enable ADC group regular interruption overrun.
  6495. * @rmtoll IER OVRIE LL_ADC_EnableIT_OVR
  6496. * @param ADCx ADC instance
  6497. * @retval None
  6498. */
  6499. __STATIC_INLINE void LL_ADC_EnableIT_OVR(ADC_TypeDef *ADCx)
  6500. {
  6501. SET_BIT(ADCx->IER, LL_ADC_IT_OVR);
  6502. }
  6503. /**
  6504. * @brief Enable interruption ADC group regular end of sampling.
  6505. * @rmtoll IER EOSMPIE LL_ADC_EnableIT_EOSMP
  6506. * @param ADCx ADC instance
  6507. * @retval None
  6508. */
  6509. __STATIC_INLINE void LL_ADC_EnableIT_EOSMP(ADC_TypeDef *ADCx)
  6510. {
  6511. SET_BIT(ADCx->IER, LL_ADC_IT_EOSMP);
  6512. }
  6513. /**
  6514. * @brief Enable interruption ADC group injected end of unitary conversion.
  6515. * @rmtoll IER JEOCIE LL_ADC_EnableIT_JEOC
  6516. * @param ADCx ADC instance
  6517. * @retval None
  6518. */
  6519. __STATIC_INLINE void LL_ADC_EnableIT_JEOC(ADC_TypeDef *ADCx)
  6520. {
  6521. SET_BIT(ADCx->IER, LL_ADC_IT_JEOC);
  6522. }
  6523. /**
  6524. * @brief Enable interruption ADC group injected end of sequence conversions.
  6525. * @rmtoll IER JEOSIE LL_ADC_EnableIT_JEOS
  6526. * @param ADCx ADC instance
  6527. * @retval None
  6528. */
  6529. __STATIC_INLINE void LL_ADC_EnableIT_JEOS(ADC_TypeDef *ADCx)
  6530. {
  6531. SET_BIT(ADCx->IER, LL_ADC_IT_JEOS);
  6532. }
  6533. /**
  6534. * @brief Enable interruption ADC group injected context queue overflow.
  6535. * @rmtoll IER JQOVFIE LL_ADC_EnableIT_JQOVF
  6536. * @param ADCx ADC instance
  6537. * @retval None
  6538. */
  6539. __STATIC_INLINE void LL_ADC_EnableIT_JQOVF(ADC_TypeDef *ADCx)
  6540. {
  6541. SET_BIT(ADCx->IER, LL_ADC_IT_JQOVF);
  6542. }
  6543. /**
  6544. * @brief Enable interruption ADC analog watchdog 1.
  6545. * @rmtoll IER AWD1IE LL_ADC_EnableIT_AWD1
  6546. * @param ADCx ADC instance
  6547. * @retval None
  6548. */
  6549. __STATIC_INLINE void LL_ADC_EnableIT_AWD1(ADC_TypeDef *ADCx)
  6550. {
  6551. SET_BIT(ADCx->IER, LL_ADC_IT_AWD1);
  6552. }
  6553. /**
  6554. * @brief Enable interruption ADC analog watchdog 2.
  6555. * @rmtoll IER AWD2IE LL_ADC_EnableIT_AWD2
  6556. * @param ADCx ADC instance
  6557. * @retval None
  6558. */
  6559. __STATIC_INLINE void LL_ADC_EnableIT_AWD2(ADC_TypeDef *ADCx)
  6560. {
  6561. SET_BIT(ADCx->IER, LL_ADC_IT_AWD2);
  6562. }
  6563. /**
  6564. * @brief Enable interruption ADC analog watchdog 3.
  6565. * @rmtoll IER AWD3IE LL_ADC_EnableIT_AWD3
  6566. * @param ADCx ADC instance
  6567. * @retval None
  6568. */
  6569. __STATIC_INLINE void LL_ADC_EnableIT_AWD3(ADC_TypeDef *ADCx)
  6570. {
  6571. SET_BIT(ADCx->IER, LL_ADC_IT_AWD3);
  6572. }
  6573. /**
  6574. * @brief Disable interruption ADC ready.
  6575. * @rmtoll IER ADRDYIE LL_ADC_DisableIT_ADRDY
  6576. * @param ADCx ADC instance
  6577. * @retval None
  6578. */
  6579. __STATIC_INLINE void LL_ADC_DisableIT_ADRDY(ADC_TypeDef *ADCx)
  6580. {
  6581. CLEAR_BIT(ADCx->IER, LL_ADC_IT_ADRDY);
  6582. }
  6583. /**
  6584. * @brief Disable interruption ADC group regular end of unitary conversion.
  6585. * @rmtoll IER EOCIE LL_ADC_DisableIT_EOC
  6586. * @param ADCx ADC instance
  6587. * @retval None
  6588. */
  6589. __STATIC_INLINE void LL_ADC_DisableIT_EOC(ADC_TypeDef *ADCx)
  6590. {
  6591. CLEAR_BIT(ADCx->IER, LL_ADC_IT_EOC);
  6592. }
  6593. /**
  6594. * @brief Disable interruption ADC group regular end of sequence conversions.
  6595. * @rmtoll IER EOSIE LL_ADC_DisableIT_EOS
  6596. * @param ADCx ADC instance
  6597. * @retval None
  6598. */
  6599. __STATIC_INLINE void LL_ADC_DisableIT_EOS(ADC_TypeDef *ADCx)
  6600. {
  6601. CLEAR_BIT(ADCx->IER, LL_ADC_IT_EOS);
  6602. }
  6603. /**
  6604. * @brief Disable interruption ADC group regular overrun.
  6605. * @rmtoll IER OVRIE LL_ADC_DisableIT_OVR
  6606. * @param ADCx ADC instance
  6607. * @retval None
  6608. */
  6609. __STATIC_INLINE void LL_ADC_DisableIT_OVR(ADC_TypeDef *ADCx)
  6610. {
  6611. CLEAR_BIT(ADCx->IER, LL_ADC_IT_OVR);
  6612. }
  6613. /**
  6614. * @brief Disable interruption ADC group regular end of sampling.
  6615. * @rmtoll IER EOSMPIE LL_ADC_DisableIT_EOSMP
  6616. * @param ADCx ADC instance
  6617. * @retval None
  6618. */
  6619. __STATIC_INLINE void LL_ADC_DisableIT_EOSMP(ADC_TypeDef *ADCx)
  6620. {
  6621. CLEAR_BIT(ADCx->IER, LL_ADC_IT_EOSMP);
  6622. }
  6623. /**
  6624. * @brief Disable interruption ADC group regular end of unitary conversion.
  6625. * @rmtoll IER JEOCIE LL_ADC_DisableIT_JEOC
  6626. * @param ADCx ADC instance
  6627. * @retval None
  6628. */
  6629. __STATIC_INLINE void LL_ADC_DisableIT_JEOC(ADC_TypeDef *ADCx)
  6630. {
  6631. CLEAR_BIT(ADCx->IER, LL_ADC_IT_JEOC);
  6632. }
  6633. /**
  6634. * @brief Disable interruption ADC group injected end of sequence conversions.
  6635. * @rmtoll IER JEOSIE LL_ADC_DisableIT_JEOS
  6636. * @param ADCx ADC instance
  6637. * @retval None
  6638. */
  6639. __STATIC_INLINE void LL_ADC_DisableIT_JEOS(ADC_TypeDef *ADCx)
  6640. {
  6641. CLEAR_BIT(ADCx->IER, LL_ADC_IT_JEOS);
  6642. }
  6643. /**
  6644. * @brief Disable interruption ADC group injected context queue overflow.
  6645. * @rmtoll IER JQOVFIE LL_ADC_DisableIT_JQOVF
  6646. * @param ADCx ADC instance
  6647. * @retval None
  6648. */
  6649. __STATIC_INLINE void LL_ADC_DisableIT_JQOVF(ADC_TypeDef *ADCx)
  6650. {
  6651. CLEAR_BIT(ADCx->IER, LL_ADC_IT_JQOVF);
  6652. }
  6653. /**
  6654. * @brief Disable interruption ADC analog watchdog 1.
  6655. * @rmtoll IER AWD1IE LL_ADC_DisableIT_AWD1
  6656. * @param ADCx ADC instance
  6657. * @retval None
  6658. */
  6659. __STATIC_INLINE void LL_ADC_DisableIT_AWD1(ADC_TypeDef *ADCx)
  6660. {
  6661. CLEAR_BIT(ADCx->IER, LL_ADC_IT_AWD1);
  6662. }
  6663. /**
  6664. * @brief Disable interruption ADC analog watchdog 2.
  6665. * @rmtoll IER AWD2IE LL_ADC_DisableIT_AWD2
  6666. * @param ADCx ADC instance
  6667. * @retval None
  6668. */
  6669. __STATIC_INLINE void LL_ADC_DisableIT_AWD2(ADC_TypeDef *ADCx)
  6670. {
  6671. CLEAR_BIT(ADCx->IER, LL_ADC_IT_AWD2);
  6672. }
  6673. /**
  6674. * @brief Disable interruption ADC analog watchdog 3.
  6675. * @rmtoll IER AWD3IE LL_ADC_DisableIT_AWD3
  6676. * @param ADCx ADC instance
  6677. * @retval None
  6678. */
  6679. __STATIC_INLINE void LL_ADC_DisableIT_AWD3(ADC_TypeDef *ADCx)
  6680. {
  6681. CLEAR_BIT(ADCx->IER, LL_ADC_IT_AWD3);
  6682. }
  6683. /**
  6684. * @brief Get state of interruption ADC ready
  6685. * (0: interrupt disabled, 1: interrupt enabled).
  6686. * @rmtoll IER ADRDYIE LL_ADC_IsEnabledIT_ADRDY
  6687. * @param ADCx ADC instance
  6688. * @retval State of bit (1 or 0).
  6689. */
  6690. __STATIC_INLINE uint32_t LL_ADC_IsEnabledIT_ADRDY(ADC_TypeDef *ADCx)
  6691. {
  6692. return (READ_BIT(ADCx->IER, LL_ADC_IT_ADRDY) == (LL_ADC_IT_ADRDY));
  6693. }
  6694. /**
  6695. * @brief Get state of interruption ADC group regular end of unitary conversion
  6696. * (0: interrupt disabled, 1: interrupt enabled).
  6697. * @rmtoll IER EOCIE LL_ADC_IsEnabledIT_EOC
  6698. * @param ADCx ADC instance
  6699. * @retval State of bit (1 or 0).
  6700. */
  6701. __STATIC_INLINE uint32_t LL_ADC_IsEnabledIT_EOC(ADC_TypeDef *ADCx)
  6702. {
  6703. return (READ_BIT(ADCx->IER, LL_ADC_IT_EOC) == (LL_ADC_IT_EOC));
  6704. }
  6705. /**
  6706. * @brief Get state of interruption ADC group regular end of sequence conversions
  6707. * (0: interrupt disabled, 1: interrupt enabled).
  6708. * @rmtoll IER EOSIE LL_ADC_IsEnabledIT_EOS
  6709. * @param ADCx ADC instance
  6710. * @retval State of bit (1 or 0).
  6711. */
  6712. __STATIC_INLINE uint32_t LL_ADC_IsEnabledIT_EOS(ADC_TypeDef *ADCx)
  6713. {
  6714. return (READ_BIT(ADCx->IER, LL_ADC_IT_EOS) == (LL_ADC_IT_EOS));
  6715. }
  6716. /**
  6717. * @brief Get state of interruption ADC group regular overrun
  6718. * (0: interrupt disabled, 1: interrupt enabled).
  6719. * @rmtoll IER OVRIE LL_ADC_IsEnabledIT_OVR
  6720. * @param ADCx ADC instance
  6721. * @retval State of bit (1 or 0).
  6722. */
  6723. __STATIC_INLINE uint32_t LL_ADC_IsEnabledIT_OVR(ADC_TypeDef *ADCx)
  6724. {
  6725. return (READ_BIT(ADCx->IER, LL_ADC_IT_OVR) == (LL_ADC_IT_OVR));
  6726. }
  6727. /**
  6728. * @brief Get state of interruption ADC group regular end of sampling
  6729. * (0: interrupt disabled, 1: interrupt enabled).
  6730. * @rmtoll IER EOSMPIE LL_ADC_IsEnabledIT_EOSMP
  6731. * @param ADCx ADC instance
  6732. * @retval State of bit (1 or 0).
  6733. */
  6734. __STATIC_INLINE uint32_t LL_ADC_IsEnabledIT_EOSMP(ADC_TypeDef *ADCx)
  6735. {
  6736. return (READ_BIT(ADCx->IER, LL_ADC_IT_EOSMP) == (LL_ADC_IT_EOSMP));
  6737. }
  6738. /**
  6739. * @brief Get state of interruption ADC group injected end of unitary conversion
  6740. * (0: interrupt disabled, 1: interrupt enabled).
  6741. * @rmtoll IER JEOCIE LL_ADC_IsEnabledIT_JEOC
  6742. * @param ADCx ADC instance
  6743. * @retval State of bit (1 or 0).
  6744. */
  6745. __STATIC_INLINE uint32_t LL_ADC_IsEnabledIT_JEOC(ADC_TypeDef *ADCx)
  6746. {
  6747. return (READ_BIT(ADCx->IER, LL_ADC_IT_JEOC) == (LL_ADC_IT_JEOC));
  6748. }
  6749. /**
  6750. * @brief Get state of interruption ADC group injected end of sequence conversions
  6751. * (0: interrupt disabled, 1: interrupt enabled).
  6752. * @rmtoll IER JEOSIE LL_ADC_IsEnabledIT_JEOS
  6753. * @param ADCx ADC instance
  6754. * @retval State of bit (1 or 0).
  6755. */
  6756. __STATIC_INLINE uint32_t LL_ADC_IsEnabledIT_JEOS(ADC_TypeDef *ADCx)
  6757. {
  6758. return (READ_BIT(ADCx->IER, LL_ADC_IT_JEOS) == (LL_ADC_IT_JEOS));
  6759. }
  6760. /**
  6761. * @brief Get state of interruption ADC group injected context queue overflow interrupt state
  6762. * (0: interrupt disabled, 1: interrupt enabled).
  6763. * @rmtoll IER JQOVFIE LL_ADC_IsEnabledIT_JQOVF
  6764. * @param ADCx ADC instance
  6765. * @retval State of bit (1 or 0).
  6766. */
  6767. __STATIC_INLINE uint32_t LL_ADC_IsEnabledIT_JQOVF(ADC_TypeDef *ADCx)
  6768. {
  6769. return (READ_BIT(ADCx->IER, LL_ADC_IT_JQOVF) == (LL_ADC_IT_JQOVF));
  6770. }
  6771. /**
  6772. * @brief Get state of interruption ADC analog watchdog 1
  6773. * (0: interrupt disabled, 1: interrupt enabled).
  6774. * @rmtoll IER AWD1IE LL_ADC_IsEnabledIT_AWD1
  6775. * @param ADCx ADC instance
  6776. * @retval State of bit (1 or 0).
  6777. */
  6778. __STATIC_INLINE uint32_t LL_ADC_IsEnabledIT_AWD1(ADC_TypeDef *ADCx)
  6779. {
  6780. return (READ_BIT(ADCx->IER, LL_ADC_IT_AWD1) == (LL_ADC_IT_AWD1));
  6781. }
  6782. /**
  6783. * @brief Get state of interruption Get ADC analog watchdog 2
  6784. * (0: interrupt disabled, 1: interrupt enabled).
  6785. * @rmtoll IER AWD2IE LL_ADC_IsEnabledIT_AWD2
  6786. * @param ADCx ADC instance
  6787. * @retval State of bit (1 or 0).
  6788. */
  6789. __STATIC_INLINE uint32_t LL_ADC_IsEnabledIT_AWD2(ADC_TypeDef *ADCx)
  6790. {
  6791. return (READ_BIT(ADCx->IER, LL_ADC_IT_AWD2) == (LL_ADC_IT_AWD2));
  6792. }
  6793. /**
  6794. * @brief Get state of interruption Get ADC analog watchdog 3
  6795. * (0: interrupt disabled, 1: interrupt enabled).
  6796. * @rmtoll IER AWD3IE LL_ADC_IsEnabledIT_AWD3
  6797. * @param ADCx ADC instance
  6798. * @retval State of bit (1 or 0).
  6799. */
  6800. __STATIC_INLINE uint32_t LL_ADC_IsEnabledIT_AWD3(ADC_TypeDef *ADCx)
  6801. {
  6802. return (READ_BIT(ADCx->IER, LL_ADC_IT_AWD3) == (LL_ADC_IT_AWD3));
  6803. }
  6804. /**
  6805. * @}
  6806. */
  6807. #if defined(USE_FULL_LL_DRIVER)
  6808. /** @defgroup ADC_LL_EF_Init Initialization and de-initialization functions
  6809. * @{
  6810. */
  6811. /* Initialization of some features of ADC common parameters and multimode */
  6812. ErrorStatus LL_ADC_CommonDeInit(ADC_Common_TypeDef *ADCxy_COMMON);
  6813. ErrorStatus LL_ADC_CommonInit(ADC_Common_TypeDef *ADCxy_COMMON, LL_ADC_CommonInitTypeDef *ADC_CommonInitStruct);
  6814. void LL_ADC_CommonStructInit(LL_ADC_CommonInitTypeDef *ADC_CommonInitStruct);
  6815. /* De-initialization of ADC instance, ADC group regular and ADC group injected */
  6816. /* (availability of ADC group injected depends on STM32 families) */
  6817. ErrorStatus LL_ADC_DeInit(ADC_TypeDef *ADCx);
  6818. /* Initialization of some features of ADC instance */
  6819. ErrorStatus LL_ADC_Init(ADC_TypeDef *ADCx, LL_ADC_InitTypeDef *ADC_InitStruct);
  6820. void LL_ADC_StructInit(LL_ADC_InitTypeDef *ADC_InitStruct);
  6821. /* Initialization of some features of ADC instance and ADC group regular */
  6822. ErrorStatus LL_ADC_REG_Init(ADC_TypeDef *ADCx, LL_ADC_REG_InitTypeDef *ADC_REG_InitStruct);
  6823. void LL_ADC_REG_StructInit(LL_ADC_REG_InitTypeDef *ADC_REG_InitStruct);
  6824. /* Initialization of some features of ADC instance and ADC group injected */
  6825. ErrorStatus LL_ADC_INJ_Init(ADC_TypeDef *ADCx, LL_ADC_INJ_InitTypeDef *ADC_INJ_InitStruct);
  6826. void LL_ADC_INJ_StructInit(LL_ADC_INJ_InitTypeDef *ADC_INJ_InitStruct);
  6827. /**
  6828. * @}
  6829. */
  6830. #endif /* USE_FULL_LL_DRIVER */
  6831. /**
  6832. * @}
  6833. */
  6834. /**
  6835. * @}
  6836. */
  6837. #endif /* ADC1 || ADC2 || ADC3 || ADC4 */
  6838. #endif /* STM32F301x8 || STM32F302x8 || STM32F302xC || STM32F302xE || STM32F303x8 || STM32F303xC || STM32F303xE || STM32F318xx || STM32F328xx || STM32F334x8 || STM32F358xx || STM32F398xx */
  6839. #if defined (ADC1_V2_5)
  6840. #if defined (ADC1)
  6841. /** @defgroup ADC_LL ADC
  6842. * @{
  6843. */
  6844. /* Private types -------------------------------------------------------------*/
  6845. /* Private variables ---------------------------------------------------------*/
  6846. /* Private constants ---------------------------------------------------------*/
  6847. /** @defgroup ADC_LL_Private_Constants ADC Private Constants
  6848. * @{
  6849. */
  6850. /* Internal mask for ADC group regular sequencer: */
  6851. /* To select into literal LL_ADC_REG_RANK_x the relevant bits for: */
  6852. /* - sequencer register offset */
  6853. /* - sequencer rank bits position into the selected register */
  6854. /* Internal register offset for ADC group regular sequencer configuration */
  6855. /* (offset placed into a spare area of literal definition) */
  6856. #define ADC_SQR1_REGOFFSET ((uint32_t)0x00000000U)
  6857. #define ADC_SQR2_REGOFFSET ((uint32_t)0x00000100U)
  6858. #define ADC_SQR3_REGOFFSET ((uint32_t)0x00000200U)
  6859. #define ADC_SQR4_REGOFFSET ((uint32_t)0x00000300U)
  6860. #define ADC_REG_SQRX_REGOFFSET_MASK (ADC_SQR1_REGOFFSET | ADC_SQR2_REGOFFSET | ADC_SQR3_REGOFFSET | ADC_SQR4_REGOFFSET)
  6861. #define ADC_REG_RANK_ID_SQRX_MASK (ADC_CHANNEL_ID_NUMBER_MASK_POSBIT0)
  6862. /* Definition of ADC group regular sequencer bits information to be inserted */
  6863. /* into ADC group regular sequencer ranks literals definition. */
  6864. #define ADC_REG_RANK_1_SQRX_BITOFFSET_POS ((uint32_t) 0U) /* Value equivalent to POSITION_VAL(ADC_SQR3_SQ1) */
  6865. #define ADC_REG_RANK_2_SQRX_BITOFFSET_POS ((uint32_t) 5U) /* Value equivalent to POSITION_VAL(ADC_SQR3_SQ2) */
  6866. #define ADC_REG_RANK_3_SQRX_BITOFFSET_POS ((uint32_t)10U) /* Value equivalent to POSITION_VAL(ADC_SQR3_SQ3) */
  6867. #define ADC_REG_RANK_4_SQRX_BITOFFSET_POS ((uint32_t)15U) /* Value equivalent to POSITION_VAL(ADC_SQR3_SQ4) */
  6868. #define ADC_REG_RANK_5_SQRX_BITOFFSET_POS ((uint32_t)20U) /* Value equivalent to POSITION_VAL(ADC_SQR3_SQ5) */
  6869. #define ADC_REG_RANK_6_SQRX_BITOFFSET_POS ((uint32_t)25U) /* Value equivalent to POSITION_VAL(ADC_SQR3_SQ6) */
  6870. #define ADC_REG_RANK_7_SQRX_BITOFFSET_POS ((uint32_t) 0U) /* Value equivalent to POSITION_VAL(ADC_SQR2_SQ7) */
  6871. #define ADC_REG_RANK_8_SQRX_BITOFFSET_POS ((uint32_t) 5U) /* Value equivalent to POSITION_VAL(ADC_SQR2_SQ8) */
  6872. #define ADC_REG_RANK_9_SQRX_BITOFFSET_POS ((uint32_t)10U) /* Value equivalent to POSITION_VAL(ADC_SQR2_SQ9) */
  6873. #define ADC_REG_RANK_10_SQRX_BITOFFSET_POS ((uint32_t)15U) /* Value equivalent to POSITION_VAL(ADC_SQR2_SQ10) */
  6874. #define ADC_REG_RANK_11_SQRX_BITOFFSET_POS ((uint32_t)20U) /* Value equivalent to POSITION_VAL(ADC_SQR2_SQ11) */
  6875. #define ADC_REG_RANK_12_SQRX_BITOFFSET_POS ((uint32_t)25U) /* Value equivalent to POSITION_VAL(ADC_SQR2_SQ12) */
  6876. #define ADC_REG_RANK_13_SQRX_BITOFFSET_POS ((uint32_t) 0U) /* Value equivalent to POSITION_VAL(ADC_SQR1_SQ13) */
  6877. #define ADC_REG_RANK_14_SQRX_BITOFFSET_POS ((uint32_t) 5U) /* Value equivalent to POSITION_VAL(ADC_SQR1_SQ14) */
  6878. #define ADC_REG_RANK_15_SQRX_BITOFFSET_POS ((uint32_t)10U) /* Value equivalent to POSITION_VAL(ADC_SQR1_SQ15) */
  6879. #define ADC_REG_RANK_16_SQRX_BITOFFSET_POS ((uint32_t)15U) /* Value equivalent to POSITION_VAL(ADC_SQR1_SQ16) */
  6880. /* Internal mask for ADC group injected sequencer: */
  6881. /* To select into literal LL_ADC_INJ_RANK_x the relevant bits for: */
  6882. /* - data register offset */
  6883. /* - offset register offset */
  6884. /* - sequencer rank bits position into the selected register */
  6885. /* Internal register offset for ADC group injected data register */
  6886. /* (offset placed into a spare area of literal definition) */
  6887. #define ADC_JDR1_REGOFFSET ((uint32_t)0x00000000U)
  6888. #define ADC_JDR2_REGOFFSET ((uint32_t)0x00000100U)
  6889. #define ADC_JDR3_REGOFFSET ((uint32_t)0x00000200U)
  6890. #define ADC_JDR4_REGOFFSET ((uint32_t)0x00000300U)
  6891. /* Internal register offset for ADC group injected offset configuration */
  6892. /* (offset placed into a spare area of literal definition) */
  6893. #define ADC_JOFR1_REGOFFSET ((uint32_t)0x00000000U)
  6894. #define ADC_JOFR2_REGOFFSET ((uint32_t)0x00001000U)
  6895. #define ADC_JOFR3_REGOFFSET ((uint32_t)0x00002000U)
  6896. #define ADC_JOFR4_REGOFFSET ((uint32_t)0x00003000U)
  6897. #define ADC_INJ_JDRX_REGOFFSET_MASK (ADC_JDR1_REGOFFSET | ADC_JDR2_REGOFFSET | ADC_JDR3_REGOFFSET | ADC_JDR4_REGOFFSET)
  6898. #define ADC_INJ_JOFRX_REGOFFSET_MASK (ADC_JOFR1_REGOFFSET | ADC_JOFR2_REGOFFSET | ADC_JOFR3_REGOFFSET | ADC_JOFR4_REGOFFSET)
  6899. #define ADC_INJ_RANK_ID_JSQR_MASK (ADC_CHANNEL_ID_NUMBER_MASK_POSBIT0)
  6900. /* Definition of ADC group injected sequencer bits information to be inserted */
  6901. /* into ADC group injected sequencer ranks literals definition. */
  6902. #define ADC_INJ_RANK_1_JSQR_BITOFFSET_POS ((uint32_t) 0U) /* Value equivalent to POSITION_VAL(ADC_JSQR_JSQ1) */
  6903. #define ADC_INJ_RANK_2_JSQR_BITOFFSET_POS ((uint32_t) 5U) /* Value equivalent to POSITION_VAL(ADC_JSQR_JSQ2) */
  6904. #define ADC_INJ_RANK_3_JSQR_BITOFFSET_POS ((uint32_t)10U) /* Value equivalent to POSITION_VAL(ADC_JSQR_JSQ3) */
  6905. #define ADC_INJ_RANK_4_JSQR_BITOFFSET_POS ((uint32_t)15U) /* Value equivalent to POSITION_VAL(ADC_JSQR_JSQ4) */
  6906. /* Internal mask for ADC channel: */
  6907. /* To select into literal LL_ADC_CHANNEL_x the relevant bits for: */
  6908. /* - channel identifier defined by number */
  6909. /* - channel differentiation between external channels (connected to */
  6910. /* GPIO pins) and internal channels (connected to internal paths) */
  6911. /* - channel sampling time defined by SMPRx register offset */
  6912. /* and SMPx bits positions into SMPRx register */
  6913. #define ADC_CHANNEL_ID_NUMBER_MASK (ADC_CR1_AWDCH)
  6914. #define ADC_CHANNEL_ID_NUMBER_BITOFFSET_POS ((uint32_t) 0U)/* Value equivalent to POSITION_VAL(ADC_CHANNEL_ID_NUMBER_MASK) */
  6915. #define ADC_CHANNEL_ID_MASK (ADC_CHANNEL_ID_NUMBER_MASK | ADC_CHANNEL_ID_INTERNAL_CH_MASK)
  6916. /* Equivalent mask of ADC_CHANNEL_NUMBER_MASK aligned on register LSB (bit 0) */
  6917. #define ADC_CHANNEL_ID_NUMBER_MASK_POSBIT0 ((uint32_t)0x0000001FU) /* Equivalent to shift: (ADC_CHANNEL_NUMBER_MASK >> POSITION_VAL(ADC_CHANNEL_NUMBER_MASK)) */
  6918. /* Channel differentiation between external and internal channels */
  6919. #define ADC_CHANNEL_ID_INTERNAL_CH ((uint32_t)0x80000000U) /* Marker of internal channel */
  6920. #define ADC_CHANNEL_ID_INTERNAL_CH_2 ((uint32_t)0x40000000U) /* Marker of internal channel for other ADC instances, in case of different ADC internal channels mapped on same channel number on different ADC instances */
  6921. #define ADC_CHANNEL_ID_INTERNAL_CH_MASK (ADC_CHANNEL_ID_INTERNAL_CH | ADC_CHANNEL_ID_INTERNAL_CH_2)
  6922. /* Internal register offset for ADC channel sampling time configuration */
  6923. /* (offset placed into a spare area of literal definition) */
  6924. #define ADC_SMPR1_REGOFFSET ((uint32_t)0x00000000U)
  6925. #define ADC_SMPR2_REGOFFSET ((uint32_t)0x02000000U)
  6926. #define ADC_CHANNEL_SMPRX_REGOFFSET_MASK (ADC_SMPR1_REGOFFSET | ADC_SMPR2_REGOFFSET)
  6927. #define ADC_CHANNEL_SMPx_BITOFFSET_MASK ((uint32_t)0x01F00000U)
  6928. #define ADC_CHANNEL_SMPx_BITOFFSET_POS ((uint32_t)20U) /* Value equivalent to POSITION_VAL(ADC_CHANNEL_SMPx_BITOFFSET_MASK) */
  6929. /* Definition of channels ID number information to be inserted into */
  6930. /* channels literals definition. */
  6931. #define ADC_CHANNEL_0_NUMBER ((uint32_t)0x00000000U)
  6932. #define ADC_CHANNEL_1_NUMBER ( ADC_CR1_AWDCH_0)
  6933. #define ADC_CHANNEL_2_NUMBER ( ADC_CR1_AWDCH_1 )
  6934. #define ADC_CHANNEL_3_NUMBER ( ADC_CR1_AWDCH_1 | ADC_CR1_AWDCH_0)
  6935. #define ADC_CHANNEL_4_NUMBER ( ADC_CR1_AWDCH_2 )
  6936. #define ADC_CHANNEL_5_NUMBER ( ADC_CR1_AWDCH_2 | ADC_CR1_AWDCH_0)
  6937. #define ADC_CHANNEL_6_NUMBER ( ADC_CR1_AWDCH_2 | ADC_CR1_AWDCH_1 )
  6938. #define ADC_CHANNEL_7_NUMBER ( ADC_CR1_AWDCH_2 | ADC_CR1_AWDCH_1 | ADC_CR1_AWDCH_0)
  6939. #define ADC_CHANNEL_8_NUMBER ( ADC_CR1_AWDCH_3 )
  6940. #define ADC_CHANNEL_9_NUMBER ( ADC_CR1_AWDCH_3 | ADC_CR1_AWDCH_0)
  6941. #define ADC_CHANNEL_10_NUMBER ( ADC_CR1_AWDCH_3 | ADC_CR1_AWDCH_1 )
  6942. #define ADC_CHANNEL_11_NUMBER ( ADC_CR1_AWDCH_3 | ADC_CR1_AWDCH_1 | ADC_CR1_AWDCH_0)
  6943. #define ADC_CHANNEL_12_NUMBER ( ADC_CR1_AWDCH_3 | ADC_CR1_AWDCH_2 )
  6944. #define ADC_CHANNEL_13_NUMBER ( ADC_CR1_AWDCH_3 | ADC_CR1_AWDCH_2 | ADC_CR1_AWDCH_0)
  6945. #define ADC_CHANNEL_14_NUMBER ( ADC_CR1_AWDCH_3 | ADC_CR1_AWDCH_2 | ADC_CR1_AWDCH_1 )
  6946. #define ADC_CHANNEL_15_NUMBER ( ADC_CR1_AWDCH_3 | ADC_CR1_AWDCH_2 | ADC_CR1_AWDCH_1 | ADC_CR1_AWDCH_0)
  6947. #define ADC_CHANNEL_16_NUMBER (ADC_CR1_AWDCH_4 )
  6948. #define ADC_CHANNEL_17_NUMBER (ADC_CR1_AWDCH_4 | ADC_CR1_AWDCH_0)
  6949. /* Definition of channels sampling time information to be inserted into */
  6950. /* channels literals definition. */
  6951. #define ADC_CHANNEL_0_SMP (ADC_SMPR2_REGOFFSET | (((uint32_t) 0U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR2_SMP0) */
  6952. #define ADC_CHANNEL_1_SMP (ADC_SMPR2_REGOFFSET | (((uint32_t) 3U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR2_SMP1) */
  6953. #define ADC_CHANNEL_2_SMP (ADC_SMPR2_REGOFFSET | (((uint32_t) 6U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR2_SMP2) */
  6954. #define ADC_CHANNEL_3_SMP (ADC_SMPR2_REGOFFSET | (((uint32_t) 9U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR2_SMP3) */
  6955. #define ADC_CHANNEL_4_SMP (ADC_SMPR2_REGOFFSET | (((uint32_t)12U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR2_SMP4) */
  6956. #define ADC_CHANNEL_5_SMP (ADC_SMPR2_REGOFFSET | (((uint32_t)15U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR2_SMP5) */
  6957. #define ADC_CHANNEL_6_SMP (ADC_SMPR2_REGOFFSET | (((uint32_t)18U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR2_SMP6) */
  6958. #define ADC_CHANNEL_7_SMP (ADC_SMPR2_REGOFFSET | (((uint32_t)21U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR2_SMP7) */
  6959. #define ADC_CHANNEL_8_SMP (ADC_SMPR2_REGOFFSET | (((uint32_t)24U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR2_SMP8) */
  6960. #define ADC_CHANNEL_9_SMP (ADC_SMPR2_REGOFFSET | (((uint32_t)27U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR2_SMP9) */
  6961. #define ADC_CHANNEL_10_SMP (ADC_SMPR1_REGOFFSET | (((uint32_t) 0U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR1_SMP10) */
  6962. #define ADC_CHANNEL_11_SMP (ADC_SMPR1_REGOFFSET | (((uint32_t) 3U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR1_SMP11) */
  6963. #define ADC_CHANNEL_12_SMP (ADC_SMPR1_REGOFFSET | (((uint32_t) 6U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR1_SMP12) */
  6964. #define ADC_CHANNEL_13_SMP (ADC_SMPR1_REGOFFSET | (((uint32_t) 9U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR1_SMP13) */
  6965. #define ADC_CHANNEL_14_SMP (ADC_SMPR1_REGOFFSET | (((uint32_t)12U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR1_SMP14) */
  6966. #define ADC_CHANNEL_15_SMP (ADC_SMPR1_REGOFFSET | (((uint32_t)15U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR1_SMP15) */
  6967. #define ADC_CHANNEL_16_SMP (ADC_SMPR1_REGOFFSET | (((uint32_t)18U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR1_SMP16) */
  6968. #define ADC_CHANNEL_17_SMP (ADC_SMPR1_REGOFFSET | (((uint32_t)21U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR1_SMP17) */
  6969. /* Internal mask for ADC analog watchdog: */
  6970. /* To select into literals LL_ADC_AWD_CHANNELx_xxx the relevant bits for: */
  6971. /* (concatenation of multiple bits used in different analog watchdogs, */
  6972. /* (feature of several watchdogs not available on all STM32 families)). */
  6973. /* - analog watchdog 1: monitored channel defined by number, */
  6974. /* selection of ADC group (ADC groups regular and-or injected). */
  6975. /* Internal register offset for ADC analog watchdog channel configuration */
  6976. #define ADC_AWD_CR1_REGOFFSET ((uint32_t)0x00000000U)
  6977. #define ADC_AWD_CRX_REGOFFSET_MASK (ADC_AWD_CR1_REGOFFSET)
  6978. #define ADC_AWD_CR1_CHANNEL_MASK (ADC_CR1_AWDCH | ADC_CR1_JAWDEN | ADC_CR1_AWDEN | ADC_CR1_AWDSGL)
  6979. #define ADC_AWD_CR_ALL_CHANNEL_MASK (ADC_AWD_CR1_CHANNEL_MASK)
  6980. /* Internal register offset for ADC analog watchdog threshold configuration */
  6981. #define ADC_AWD_TR1_HIGH_REGOFFSET ((uint32_t)0x00000000U)
  6982. #define ADC_AWD_TR1_LOW_REGOFFSET ((uint32_t)0x00000001U)
  6983. #define ADC_AWD_TRX_REGOFFSET_MASK (ADC_AWD_TR1_HIGH_REGOFFSET | ADC_AWD_TR1_LOW_REGOFFSET)
  6984. /* ADC registers bits positions */
  6985. #define ADC_CR1_DUALMOD_BITOFFSET_POS ((uint32_t)16U) /* Value equivalent to POSITION_VAL(ADC_CR1_DUALMOD) */
  6986. /* ADC internal channels related definitions */
  6987. /* Internal voltage reference VrefInt */
  6988. #define VREFINT_CAL_ADDR ((uint16_t*) ((uint32_t)0x1FFFF7BAU)) /* Internal voltage reference, address of parameter VREFINT_CAL: VrefInt ADC raw data acquired at temperature 30 DegC (tolerance: +-5 DegC), Vref+ = 3.3 V (tolerance: +-10 mV). */
  6989. #define VREFINT_CAL_VREF ((uint32_t) 3300U) /* Analog voltage reference (Vref+) value with which temperature sensor has been calibrated in production (tolerance: +-10 mV) (unit: mV). */
  6990. /* Temperature sensor */
  6991. #define TEMPSENSOR_CAL1_ADDR ((uint16_t*) ((uint32_t)0x1FFFF7B8U)) /* Internal temperature sensor, address of parameter TS_CAL1: On STM32F37x, temperature sensor ADC raw data acquired at temperature 30 DegC (tolerance: +-5 DegC), Vref+ = 3.3 V (tolerance: +-10 mV). */
  6992. #define TEMPSENSOR_CAL2_ADDR ((uint16_t*) ((uint32_t)0x1FFFF7C2U)) /* Internal temperature sensor, address of parameter TS_CAL2: On STM32F37x, temperature sensor ADC raw data acquired at temperature 110 DegC (tolerance: +-5 DegC), Vref+ = 3.3 V (tolerance: +-10 mV). */
  6993. #define TEMPSENSOR_CAL1_TEMP (( int32_t) 30) /* Internal temperature sensor, temperature at which temperature sensor has been calibrated in production for data into TEMPSENSOR_CAL1_ADDR (tolerance: +-5 DegC) (unit: DegC). */
  6994. #define TEMPSENSOR_CAL2_TEMP (( int32_t) 110) /* Internal temperature sensor, temperature at which temperature sensor has been calibrated in production for data into TEMPSENSOR_CAL2_ADDR (tolerance: +-5 DegC) (unit: DegC). */
  6995. #define TEMPSENSOR_CAL_VREFANALOG ((uint32_t) 3300U) /* Analog voltage reference (Vref+) voltage with which temperature sensor has been calibrated in production (+-10 mV) (unit: mV). */
  6996. /**
  6997. * @}
  6998. */
  6999. /* Private macros ------------------------------------------------------------*/
  7000. /** @defgroup ADC_LL_Private_Macros ADC Private Macros
  7001. * @{
  7002. */
  7003. /**
  7004. * @brief Driver macro reserved for internal use: isolate bits with the
  7005. * selected mask and shift them to the register LSB
  7006. * (shift mask on register position bit 0).
  7007. * @param __BITS__ Bits in register 32 bits
  7008. * @param __MASK__ Mask in register 32 bits
  7009. * @retval Bits in register 32 bits
  7010. */
  7011. #define __ADC_MASK_SHIFT(__BITS__, __MASK__) \
  7012. (((__BITS__) & (__MASK__)) >> POSITION_VAL((__MASK__)))
  7013. /**
  7014. * @brief Driver macro reserved for internal use: set a pointer to
  7015. * a register from a register basis from which an offset
  7016. * is applied.
  7017. * @param __REG__ Register basis from which the offset is applied.
  7018. * @param __REG_OFFFSET__ Offset to be applied (unit: number of registers).
  7019. * @retval Pointer to register address
  7020. */
  7021. #define __ADC_PTR_REG_OFFSET(__REG__, __REG_OFFFSET__) \
  7022. ((uint32_t *)((uint32_t) ((uint32_t)(&(__REG__)) + ((__REG_OFFFSET__) << 2U))))
  7023. /**
  7024. * @}
  7025. */
  7026. /* Exported types ------------------------------------------------------------*/
  7027. #if defined(USE_FULL_LL_DRIVER)
  7028. /** @defgroup ADC_LL_ES_INIT ADC Exported Init structure
  7029. * @{
  7030. */
  7031. /**
  7032. * @brief Structure definition of some features of ADC instance.
  7033. * @note These parameters have an impact on ADC scope: ADC instance.
  7034. * Affects both group regular and group injected (availability
  7035. * of ADC group injected depends on STM32 families).
  7036. * Refer to corresponding unitary functions into
  7037. * @ref ADC_LL_EF_Configuration_ADC_Instance .
  7038. * @note The setting of these parameters by function @ref LL_ADC_Init()
  7039. * is conditioned to ADC state:
  7040. * ADC instance must be disabled.
  7041. * This condition is applied to all ADC features, for efficiency
  7042. * and compatibility over all STM32 families. However, the different
  7043. * features can be set under different ADC state conditions
  7044. * (setting possible with ADC enabled without conversion on going,
  7045. * ADC enabled with conversion on going, ...)
  7046. * Each feature can be updated afterwards with a unitary function
  7047. * and potentially with ADC in a different state than disabled,
  7048. * refer to description of each function for setting
  7049. * conditioned to ADC state.
  7050. */
  7051. typedef struct
  7052. {
  7053. uint32_t DataAlignment; /*!< Set ADC conversion data alignment.
  7054. This parameter can be a value of @ref ADC_LL_EC_DATA_ALIGN
  7055. This feature can be modified afterwards using unitary function @ref LL_ADC_SetDataAlignment(). */
  7056. uint32_t SequencersScanMode; /*!< Set ADC scan selection.
  7057. This parameter can be a value of @ref ADC_LL_EC_SCAN_SELECTION
  7058. This feature can be modified afterwards using unitary function @ref LL_ADC_SetSequencersScanMode(). */
  7059. } LL_ADC_InitTypeDef;
  7060. /**
  7061. * @brief Structure definition of some features of ADC group regular.
  7062. * @note These parameters have an impact on ADC scope: ADC group regular.
  7063. * Refer to corresponding unitary functions into
  7064. * @ref ADC_LL_EF_Configuration_ADC_Group_Regular
  7065. * (functions with prefix "REG").
  7066. * @note The setting of these parameters by function @ref LL_ADC_REG_Init()
  7067. * is conditioned to ADC state:
  7068. * ADC instance must be disabled.
  7069. * This condition is applied to all ADC features, for efficiency
  7070. * and compatibility over all STM32 families. However, the different
  7071. * features can be set under different ADC state conditions
  7072. * (setting possible with ADC enabled without conversion on going,
  7073. * ADC enabled with conversion on going, ...)
  7074. * Each feature can be updated afterwards with a unitary function
  7075. * and potentially with ADC in a different state than disabled,
  7076. * refer to description of each function for setting
  7077. * conditioned to ADC state.
  7078. */
  7079. typedef struct
  7080. {
  7081. uint32_t TriggerSource; /*!< Set ADC group regular conversion trigger source: internal (SW start) or external from timer or external interrupt.
  7082. This parameter can be a value of @ref ADC_LL_EC_REG_TRIGGER_SOURCE
  7083. @note On this STM32 series, external trigger is set with trigger polarity: rising edge
  7084. (only trigger polarity available on this STM32 series).
  7085. This feature can be modified afterwards using unitary function @ref LL_ADC_REG_SetTriggerSource(). */
  7086. uint32_t SequencerLength; /*!< Set ADC group regular sequencer length.
  7087. This parameter can be a value of @ref ADC_LL_EC_REG_SEQ_SCAN_LENGTH
  7088. @note This parameter is discarded if scan mode is disabled (refer to parameter 'ADC_SequencersScanMode').
  7089. This feature can be modified afterwards using unitary function @ref LL_ADC_REG_SetSequencerLength(). */
  7090. uint32_t SequencerDiscont; /*!< Set ADC group regular sequencer discontinuous mode: sequence subdivided and scan conversions interrupted every selected number of ranks.
  7091. This parameter can be a value of @ref ADC_LL_EC_REG_SEQ_DISCONT_MODE
  7092. @note This parameter has an effect only if group regular sequencer is enabled
  7093. (scan length of 2 ranks or more).
  7094. This feature can be modified afterwards using unitary function @ref LL_ADC_REG_SetSequencerDiscont(). */
  7095. uint32_t ContinuousMode; /*!< Set ADC continuous conversion mode on ADC group regular, whether ADC conversions are performed in single mode (one conversion per trigger) or in continuous mode (after the first trigger, following conversions launched successively automatically).
  7096. This parameter can be a value of @ref ADC_LL_EC_REG_CONTINUOUS_MODE
  7097. Note: It is not possible to enable both ADC group regular continuous mode and discontinuous mode.
  7098. This feature can be modified afterwards using unitary function @ref LL_ADC_REG_SetContinuousMode(). */
  7099. uint32_t DMATransfer; /*!< Set ADC group regular conversion data transfer: no transfer or transfer by DMA, and DMA requests mode.
  7100. This parameter can be a value of @ref ADC_LL_EC_REG_DMA_TRANSFER
  7101. This feature can be modified afterwards using unitary function @ref LL_ADC_REG_SetDMATransfer(). */
  7102. } LL_ADC_REG_InitTypeDef;
  7103. /**
  7104. * @brief Structure definition of some features of ADC group injected.
  7105. * @note These parameters have an impact on ADC scope: ADC group injected.
  7106. * Refer to corresponding unitary functions into
  7107. * @ref ADC_LL_EF_Configuration_ADC_Group_Regular
  7108. * (functions with prefix "INJ").
  7109. * @note The setting of these parameters by function @ref LL_ADC_INJ_Init()
  7110. * is conditioned to ADC state:
  7111. * ADC instance must be disabled.
  7112. * This condition is applied to all ADC features, for efficiency
  7113. * and compatibility over all STM32 families. However, the different
  7114. * features can be set under different ADC state conditions
  7115. * (setting possible with ADC enabled without conversion on going,
  7116. * ADC enabled with conversion on going, ...)
  7117. * Each feature can be updated afterwards with a unitary function
  7118. * and potentially with ADC in a different state than disabled,
  7119. * refer to description of each function for setting
  7120. * conditioned to ADC state.
  7121. */
  7122. typedef struct
  7123. {
  7124. uint32_t TriggerSource; /*!< Set ADC group injected conversion trigger source: internal (SW start) or external from timer or external interrupt.
  7125. This parameter can be a value of @ref ADC_LL_EC_INJ_TRIGGER_SOURCE
  7126. @note On this STM32 series, external trigger is set with trigger polarity: rising edge
  7127. (only trigger polarity available on this STM32 series).
  7128. This feature can be modified afterwards using unitary function @ref LL_ADC_INJ_SetTriggerSource(). */
  7129. uint32_t SequencerLength; /*!< Set ADC group injected sequencer length.
  7130. This parameter can be a value of @ref ADC_LL_EC_INJ_SEQ_SCAN_LENGTH
  7131. @note This parameter is discarded if scan mode is disabled (refer to parameter 'ADC_SequencersScanMode').
  7132. This feature can be modified afterwards using unitary function @ref LL_ADC_INJ_SetSequencerLength(). */
  7133. uint32_t SequencerDiscont; /*!< Set ADC group injected sequencer discontinuous mode: sequence subdivided and scan conversions interrupted every selected number of ranks.
  7134. This parameter can be a value of @ref ADC_LL_EC_INJ_SEQ_DISCONT_MODE
  7135. @note This parameter has an effect only if group injected sequencer is enabled
  7136. (scan length of 2 ranks or more).
  7137. This feature can be modified afterwards using unitary function @ref LL_ADC_INJ_SetSequencerDiscont(). */
  7138. uint32_t TrigAuto; /*!< Set ADC group injected conversion trigger: independent or from ADC group regular.
  7139. This parameter can be a value of @ref ADC_LL_EC_INJ_TRIG_AUTO
  7140. Note: This parameter must be set to set to independent trigger if injected trigger source is set to an external trigger.
  7141. This feature can be modified afterwards using unitary function @ref LL_ADC_INJ_SetTrigAuto(). */
  7142. } LL_ADC_INJ_InitTypeDef;
  7143. /**
  7144. * @}
  7145. */
  7146. #endif /* USE_FULL_LL_DRIVER */
  7147. /* Exported constants --------------------------------------------------------*/
  7148. /** @defgroup ADC_LL_Exported_Constants ADC Exported Constants
  7149. * @{
  7150. */
  7151. /** @defgroup ADC_LL_EC_FLAG ADC flags
  7152. * @brief Flags defines which can be used with LL_ADC_ReadReg function
  7153. * @{
  7154. */
  7155. #define LL_ADC_FLAG_STRT ADC_SR_STRT /*!< ADC flag ADC group regular conversion start */
  7156. #define LL_ADC_FLAG_EOS ADC_SR_EOC /*!< ADC flag ADC group regular end of sequence conversions (Note: on this STM32 series, there is no flag ADC group regular end of unitary conversion. Flag noted as "EOC" is corresponding to flag "EOS" in other STM32 families) */
  7157. #define LL_ADC_FLAG_JSTRT ADC_SR_JSTRT /*!< ADC flag ADC group injected conversion start */
  7158. #define LL_ADC_FLAG_JEOS ADC_SR_JEOC /*!< ADC flag ADC group injected end of sequence conversions (Note: on this STM32 series, there is no flag ADC group injected end of unitary conversion. Flag noted as "JEOC" is corresponding to flag "JEOS" in other STM32 families) */
  7159. #define LL_ADC_FLAG_AWD1 ADC_SR_AWD /*!< ADC flag ADC analog watchdog 1 */
  7160. /**
  7161. * @}
  7162. */
  7163. /** @defgroup ADC_LL_EC_IT ADC interruptions for configuration (interruption enable or disable)
  7164. * @brief IT defines which can be used with LL_ADC_ReadReg and LL_ADC_WriteReg functions
  7165. * @{
  7166. */
  7167. #define LL_ADC_IT_EOS ADC_CR1_EOCIE /*!< ADC interruption ADC group regular end of sequence conversions (Note: on this STM32 series, there is no flag ADC group regular end of unitary conversion. Flag noted as "EOC" is corresponding to flag "EOS" in other STM32 families) */
  7168. #define LL_ADC_IT_JEOS ADC_CR1_JEOCIE /*!< ADC interruption ADC group injected end of sequence conversions (Note: on this STM32 series, there is no flag ADC group injected end of unitary conversion. Flag noted as "JEOC" is corresponding to flag "JEOS" in other STM32 families) */
  7169. #define LL_ADC_IT_AWD1 ADC_CR1_AWDIE /*!< ADC interruption ADC analog watchdog 1 */
  7170. /**
  7171. * @}
  7172. */
  7173. /** @defgroup ADC_LL_EC_REGISTERS ADC registers compliant with specific purpose
  7174. * @{
  7175. */
  7176. /* List of ADC registers intended to be used (most commonly) with */
  7177. /* DMA transfer. */
  7178. /* Refer to function @ref LL_ADC_DMA_GetRegAddr(). */
  7179. #define LL_ADC_DMA_REG_REGULAR_DATA ((uint32_t)0x00000000U) /* ADC group regular conversion data register (corresponding to register DR) to be used with ADC configured in independent mode. Without DMA transfer, register accessed by LL function @ref LL_ADC_REG_ReadConversionData32() and other functions @ref LL_ADC_REG_ReadConversionDatax() */
  7180. /**
  7181. * @}
  7182. */
  7183. /** @defgroup ADC_LL_EC_COMMON_PATH_INTERNAL ADC common - Measurement path to internal channels
  7184. * @{
  7185. */
  7186. /* Note: Other measurement paths to internal channels may be available */
  7187. /* (connections to other peripherals). */
  7188. /* If they are not listed below, they do not require any specific */
  7189. /* path enable. In this case, Access to measurement path is done */
  7190. /* only by selecting the corresponding ADC internal channel. */
  7191. #define LL_ADC_PATH_INTERNAL_NONE ((uint32_t)0x00000000U)/*!< ADC measurement paths all disabled */
  7192. #define LL_ADC_PATH_INTERNAL_VREFINT (ADC_CR2_TSVREFE) /*!< ADC measurement path to internal channel VrefInt */
  7193. #define LL_ADC_PATH_INTERNAL_TEMPSENSOR (ADC_CR2_TSVREFE) /*!< ADC measurement path to internal channel temperature sensor */
  7194. /**
  7195. * @}
  7196. */
  7197. /** @defgroup ADC_LL_EC_RESOLUTION ADC instance - Resolution
  7198. * @{
  7199. */
  7200. #define LL_ADC_RESOLUTION_12B ((uint32_t)0x00000000U) /*!< ADC resolution 12 bits */
  7201. /**
  7202. * @}
  7203. */
  7204. /** @defgroup ADC_LL_EC_DATA_ALIGN ADC instance - Data alignment
  7205. * @{
  7206. */
  7207. #define LL_ADC_DATA_ALIGN_RIGHT ((uint32_t)0x00000000U)/*!< ADC conversion data alignment: right aligned (alignment on data register LSB bit 0)*/
  7208. #define LL_ADC_DATA_ALIGN_LEFT (ADC_CR2_ALIGN) /*!< ADC conversion data alignment: left aligned (alignment on data register MSB bit 15)*/
  7209. /**
  7210. * @}
  7211. */
  7212. /** @defgroup ADC_LL_EC_SCAN_SELECTION ADC instance - Scan selection
  7213. * @{
  7214. */
  7215. #define LL_ADC_SEQ_SCAN_DISABLE ((uint32_t)0x00000000U) /*!< ADC conversion is performed in unitary conversion mode (one channel converted, that defined in rank 1). Configuration of both groups regular and injected sequencers (sequence length, ...) is discarded: equivalent to length of 1 rank.*/
  7216. #define LL_ADC_SEQ_SCAN_ENABLE ((uint32_t)ADC_CR1_SCAN) /*!< ADC conversions are performed in sequence conversions mode, according to configuration of both groups regular and injected sequencers (sequence length, ...). */
  7217. /**
  7218. * @}
  7219. */
  7220. /** @defgroup ADC_LL_EC_GROUPS ADC instance - Groups
  7221. * @{
  7222. */
  7223. #define LL_ADC_GROUP_REGULAR ((uint32_t)0x00000001U) /*!< ADC group regular (available on all STM32 devices) */
  7224. #define LL_ADC_GROUP_INJECTED ((uint32_t)0x00000002U) /*!< ADC group injected (not available on all STM32 devices)*/
  7225. #define LL_ADC_GROUP_REGULAR_INJECTED ((uint32_t)0x00000003U) /*!< ADC both groups regular and injected */
  7226. /**
  7227. * @}
  7228. */
  7229. /** @defgroup ADC_LL_EC_CHANNEL ADC instance - Channel number
  7230. * @{
  7231. */
  7232. #define LL_ADC_CHANNEL_0 (ADC_CHANNEL_0_NUMBER | ADC_CHANNEL_0_SMP) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN0 */
  7233. #define LL_ADC_CHANNEL_1 (ADC_CHANNEL_1_NUMBER | ADC_CHANNEL_1_SMP) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN1 */
  7234. #define LL_ADC_CHANNEL_2 (ADC_CHANNEL_2_NUMBER | ADC_CHANNEL_2_SMP) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN2 */
  7235. #define LL_ADC_CHANNEL_3 (ADC_CHANNEL_3_NUMBER | ADC_CHANNEL_3_SMP) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN3 */
  7236. #define LL_ADC_CHANNEL_4 (ADC_CHANNEL_4_NUMBER | ADC_CHANNEL_4_SMP) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN4 */
  7237. #define LL_ADC_CHANNEL_5 (ADC_CHANNEL_5_NUMBER | ADC_CHANNEL_5_SMP) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN5 */
  7238. #define LL_ADC_CHANNEL_6 (ADC_CHANNEL_6_NUMBER | ADC_CHANNEL_6_SMP) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN6 */
  7239. #define LL_ADC_CHANNEL_7 (ADC_CHANNEL_7_NUMBER | ADC_CHANNEL_7_SMP) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN7 */
  7240. #define LL_ADC_CHANNEL_8 (ADC_CHANNEL_8_NUMBER | ADC_CHANNEL_8_SMP) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN8 */
  7241. #define LL_ADC_CHANNEL_9 (ADC_CHANNEL_9_NUMBER | ADC_CHANNEL_9_SMP) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN9 */
  7242. #define LL_ADC_CHANNEL_10 (ADC_CHANNEL_10_NUMBER | ADC_CHANNEL_10_SMP) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN10 */
  7243. #define LL_ADC_CHANNEL_11 (ADC_CHANNEL_11_NUMBER | ADC_CHANNEL_11_SMP) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN11 */
  7244. #define LL_ADC_CHANNEL_12 (ADC_CHANNEL_12_NUMBER | ADC_CHANNEL_12_SMP) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN12 */
  7245. #define LL_ADC_CHANNEL_13 (ADC_CHANNEL_13_NUMBER | ADC_CHANNEL_13_SMP) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN13 */
  7246. #define LL_ADC_CHANNEL_14 (ADC_CHANNEL_14_NUMBER | ADC_CHANNEL_14_SMP) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN14 */
  7247. #define LL_ADC_CHANNEL_15 (ADC_CHANNEL_15_NUMBER | ADC_CHANNEL_15_SMP) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN15 */
  7248. #define LL_ADC_CHANNEL_16 (ADC_CHANNEL_16_NUMBER | ADC_CHANNEL_16_SMP) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN16 */
  7249. #define LL_ADC_CHANNEL_17 (ADC_CHANNEL_17_NUMBER | ADC_CHANNEL_17_SMP) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN17 */
  7250. #define LL_ADC_CHANNEL_VREFINT (LL_ADC_CHANNEL_17 | ADC_CHANNEL_ID_INTERNAL_CH) /*!< ADC internal channel connected to VrefInt: Internal voltage reference. On STM32F37x, ADC channel available only on ADC instance: ADC1. */
  7251. #define LL_ADC_CHANNEL_TEMPSENSOR (LL_ADC_CHANNEL_16 | ADC_CHANNEL_ID_INTERNAL_CH) /*!< ADC internal channel connected to Temperature sensor. */
  7252. /**
  7253. * @}
  7254. */
  7255. /** @defgroup ADC_LL_EC_REG_TRIGGER_SOURCE ADC group regular - Trigger source
  7256. * @{
  7257. */
  7258. #define LL_ADC_REG_TRIG_SOFTWARE (ADC_CR2_EXTSEL_2 | ADC_CR2_EXTSEL_1 | ADC_CR2_EXTSEL_0) /*!< ADC group regular conversion trigger internal (SW start) */
  7259. #define LL_ADC_REG_TRIG_EXT_TIM2_CH2 (ADC_CR2_EXTSEL_1 | ADC_CR2_EXTSEL_0) /*!< ADC group regular conversion trigger external from TIM2 CC2. Trigger edge set to rising edge (default setting). */
  7260. #define LL_ADC_REG_TRIG_EXT_TIM3_TRGO (ADC_CR2_EXTSEL_2) /*!< ADC group regular conversion trigger external from TIM3 TRGO. Trigger edge set to rising edge (default setting). */
  7261. #define LL_ADC_REG_TRIG_EXT_TIM4_CH2 (ADC_CR2_EXTSEL_2 | ADC_CR2_EXTSEL_0) /*!< ADC group regular conversion trigger external from TIM4 CC4. Trigger edge set to rising edge (default setting). */
  7262. #define LL_ADC_REG_TRIG_EXT_TIM19_TRGO ((uint32_t)0x00000000U) /*!< ADC group regular conversion trigger external from TIM19 TRGO. Trigger edge set to rising edge (default setting). */
  7263. #define LL_ADC_REG_TRIG_EXT_TIM19_CH3 (ADC_CR2_EXTSEL_0) /*!< ADC group regular conversion trigger external from TIM19 CC3. Trigger edge set to rising edge (default setting). */
  7264. #define LL_ADC_REG_TRIG_EXT_TIM19_CH4 (ADC_CR2_EXTSEL_1) /*!< ADC group regular conversion trigger external from TIM19 CC4. Trigger edge set to rising edge (default setting). */
  7265. #define LL_ADC_REG_TRIG_EXT_EXTI_LINE11 (ADC_CR2_EXTSEL_2 | ADC_CR2_EXTSEL_1) /*!< ADC group regular conversion trigger external interrupt line 11. Trigger edge set to rising edge (default setting). */
  7266. /**
  7267. * @}
  7268. */
  7269. /** @defgroup ADC_LL_EC_REG_TRIGGER_EDGE ADC group regular - Trigger edge
  7270. * @{
  7271. */
  7272. #define LL_ADC_REG_TRIG_EXT_RISING ((uint32_t)0x00000000U) /*!< ADC group regular conversion trigger polarity set to rising edge */
  7273. /**
  7274. * @}
  7275. */
  7276. /** @defgroup ADC_LL_EC_REG_CONTINUOUS_MODE ADC group regular - Continuous mode
  7277. * @{
  7278. */
  7279. #define LL_ADC_REG_CONV_SINGLE ((uint32_t)0x00000000U)/*!< ADC conversions are performed in single mode: one conversion per trigger */
  7280. #define LL_ADC_REG_CONV_CONTINUOUS (ADC_CR2_CONT) /*!< ADC conversions are performed in continuous mode: after the first trigger, following conversions launched successively automatically */
  7281. /**
  7282. * @}
  7283. */
  7284. /** @defgroup ADC_LL_EC_REG_DMA_TRANSFER ADC group regular - DMA transfer
  7285. * @{
  7286. */
  7287. #define LL_ADC_REG_DMA_TRANSFER_NONE ((uint32_t)0x00000000U) /*!< ADC conversions are not transferred by DMA */
  7288. #define LL_ADC_REG_DMA_TRANSFER_UNLIMITED (ADC_CR2_DMA) /*!< ADC conversions are transferred by DMA, in unlimited mode: DMA transfer requests are unlimited, whatever number of DMA data transferred (number of ADC conversions). This ADC mode is intended to be used with DMA mode circular. */
  7289. /**
  7290. * @}
  7291. */
  7292. /** @defgroup ADC_LL_EC_REG_SEQ_SCAN_LENGTH ADC group regular - Sequencer scan length
  7293. * @{
  7294. */
  7295. #define LL_ADC_REG_SEQ_SCAN_DISABLE ((uint32_t)0x00000000U) /*!< ADC group regular sequencer disable (equivalent to sequencer of 1 rank: ADC conversion on only 1 channel) */
  7296. #define LL_ADC_REG_SEQ_SCAN_ENABLE_2RANKS ( ADC_SQR1_L_0) /*!< ADC group regular sequencer enable with 2 ranks in the sequence */
  7297. #define LL_ADC_REG_SEQ_SCAN_ENABLE_3RANKS ( ADC_SQR1_L_1 ) /*!< ADC group regular sequencer enable with 3 ranks in the sequence */
  7298. #define LL_ADC_REG_SEQ_SCAN_ENABLE_4RANKS ( ADC_SQR1_L_1 | ADC_SQR1_L_0) /*!< ADC group regular sequencer enable with 4 ranks in the sequence */
  7299. #define LL_ADC_REG_SEQ_SCAN_ENABLE_5RANKS ( ADC_SQR1_L_2 ) /*!< ADC group regular sequencer enable with 5 ranks in the sequence */
  7300. #define LL_ADC_REG_SEQ_SCAN_ENABLE_6RANKS ( ADC_SQR1_L_2 | ADC_SQR1_L_0) /*!< ADC group regular sequencer enable with 6 ranks in the sequence */
  7301. #define LL_ADC_REG_SEQ_SCAN_ENABLE_7RANKS ( ADC_SQR1_L_2 | ADC_SQR1_L_1 ) /*!< ADC group regular sequencer enable with 7 ranks in the sequence */
  7302. #define LL_ADC_REG_SEQ_SCAN_ENABLE_8RANKS ( ADC_SQR1_L_2 | ADC_SQR1_L_1 | ADC_SQR1_L_0) /*!< ADC group regular sequencer enable with 8 ranks in the sequence */
  7303. #define LL_ADC_REG_SEQ_SCAN_ENABLE_9RANKS (ADC_SQR1_L_3 ) /*!< ADC group regular sequencer enable with 9 ranks in the sequence */
  7304. #define LL_ADC_REG_SEQ_SCAN_ENABLE_10RANKS (ADC_SQR1_L_3 | ADC_SQR1_L_0) /*!< ADC group regular sequencer enable with 10 ranks in the sequence */
  7305. #define LL_ADC_REG_SEQ_SCAN_ENABLE_11RANKS (ADC_SQR1_L_3 | ADC_SQR1_L_1 ) /*!< ADC group regular sequencer enable with 11 ranks in the sequence */
  7306. #define LL_ADC_REG_SEQ_SCAN_ENABLE_12RANKS (ADC_SQR1_L_3 | ADC_SQR1_L_1 | ADC_SQR1_L_0) /*!< ADC group regular sequencer enable with 12 ranks in the sequence */
  7307. #define LL_ADC_REG_SEQ_SCAN_ENABLE_13RANKS (ADC_SQR1_L_3 | ADC_SQR1_L_2 ) /*!< ADC group regular sequencer enable with 13 ranks in the sequence */
  7308. #define LL_ADC_REG_SEQ_SCAN_ENABLE_14RANKS (ADC_SQR1_L_3 | ADC_SQR1_L_2 | ADC_SQR1_L_0) /*!< ADC group regular sequencer enable with 14 ranks in the sequence */
  7309. #define LL_ADC_REG_SEQ_SCAN_ENABLE_15RANKS (ADC_SQR1_L_3 | ADC_SQR1_L_2 | ADC_SQR1_L_1 ) /*!< ADC group regular sequencer enable with 15 ranks in the sequence */
  7310. #define LL_ADC_REG_SEQ_SCAN_ENABLE_16RANKS (ADC_SQR1_L_3 | ADC_SQR1_L_2 | ADC_SQR1_L_1 | ADC_SQR1_L_0) /*!< ADC group regular sequencer enable with 16 ranks in the sequence */
  7311. /**
  7312. * @}
  7313. */
  7314. /** @defgroup ADC_LL_EC_REG_SEQ_DISCONT_MODE ADC group regular - Sequencer discontinuous mode
  7315. * @{
  7316. */
  7317. #define LL_ADC_REG_SEQ_DISCONT_DISABLE ((uint32_t)0x00000000U) /*!< ADC group regular sequencer discontinuous mode disable */
  7318. #define LL_ADC_REG_SEQ_DISCONT_1RANK ( ADC_CR1_DISCEN) /*!< ADC group regular sequencer discontinuous mode enable with sequence interruption every rank */
  7319. #define LL_ADC_REG_SEQ_DISCONT_2RANKS ( ADC_CR1_DISCNUM_0 | ADC_CR1_DISCEN) /*!< ADC group regular sequencer discontinuous mode enabled with sequence interruption every 2 ranks */
  7320. #define LL_ADC_REG_SEQ_DISCONT_3RANKS ( ADC_CR1_DISCNUM_1 | ADC_CR1_DISCEN) /*!< ADC group regular sequencer discontinuous mode enable with sequence interruption every 3 ranks */
  7321. #define LL_ADC_REG_SEQ_DISCONT_4RANKS ( ADC_CR1_DISCNUM_1 | ADC_CR1_DISCNUM_0 | ADC_CR1_DISCEN) /*!< ADC group regular sequencer discontinuous mode enable with sequence interruption every 4 ranks */
  7322. #define LL_ADC_REG_SEQ_DISCONT_5RANKS (ADC_CR1_DISCNUM_2 | ADC_CR1_DISCEN) /*!< ADC group regular sequencer discontinuous mode enable with sequence interruption every 5 ranks */
  7323. #define LL_ADC_REG_SEQ_DISCONT_6RANKS (ADC_CR1_DISCNUM_2 | ADC_CR1_DISCNUM_0 | ADC_CR1_DISCEN) /*!< ADC group regular sequencer discontinuous mode enable with sequence interruption every 6 ranks */
  7324. #define LL_ADC_REG_SEQ_DISCONT_7RANKS (ADC_CR1_DISCNUM_2 | ADC_CR1_DISCNUM_1 | ADC_CR1_DISCEN) /*!< ADC group regular sequencer discontinuous mode enable with sequence interruption every 7 ranks */
  7325. #define LL_ADC_REG_SEQ_DISCONT_8RANKS (ADC_CR1_DISCNUM_2 | ADC_CR1_DISCNUM_1 | ADC_CR1_DISCNUM_0 | ADC_CR1_DISCEN) /*!< ADC group regular sequencer discontinuous mode enable with sequence interruption every 8 ranks */
  7326. /**
  7327. * @}
  7328. */
  7329. /** @defgroup ADC_LL_EC_REG_RANKS ADC group regular - Sequencer ranks
  7330. * @{
  7331. */
  7332. #define LL_ADC_REG_RANK_1 (ADC_SQR3_REGOFFSET | ADC_REG_RANK_1_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 1 */
  7333. #define LL_ADC_REG_RANK_2 (ADC_SQR3_REGOFFSET | ADC_REG_RANK_2_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 2 */
  7334. #define LL_ADC_REG_RANK_3 (ADC_SQR3_REGOFFSET | ADC_REG_RANK_3_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 3 */
  7335. #define LL_ADC_REG_RANK_4 (ADC_SQR3_REGOFFSET | ADC_REG_RANK_4_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 4 */
  7336. #define LL_ADC_REG_RANK_5 (ADC_SQR3_REGOFFSET | ADC_REG_RANK_5_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 5 */
  7337. #define LL_ADC_REG_RANK_6 (ADC_SQR3_REGOFFSET | ADC_REG_RANK_6_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 6 */
  7338. #define LL_ADC_REG_RANK_7 (ADC_SQR2_REGOFFSET | ADC_REG_RANK_7_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 7 */
  7339. #define LL_ADC_REG_RANK_8 (ADC_SQR2_REGOFFSET | ADC_REG_RANK_8_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 8 */
  7340. #define LL_ADC_REG_RANK_9 (ADC_SQR2_REGOFFSET | ADC_REG_RANK_9_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 9 */
  7341. #define LL_ADC_REG_RANK_10 (ADC_SQR2_REGOFFSET | ADC_REG_RANK_10_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 10 */
  7342. #define LL_ADC_REG_RANK_11 (ADC_SQR2_REGOFFSET | ADC_REG_RANK_11_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 11 */
  7343. #define LL_ADC_REG_RANK_12 (ADC_SQR2_REGOFFSET | ADC_REG_RANK_12_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 12 */
  7344. #define LL_ADC_REG_RANK_13 (ADC_SQR1_REGOFFSET | ADC_REG_RANK_13_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 13 */
  7345. #define LL_ADC_REG_RANK_14 (ADC_SQR1_REGOFFSET | ADC_REG_RANK_14_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 14 */
  7346. #define LL_ADC_REG_RANK_15 (ADC_SQR1_REGOFFSET | ADC_REG_RANK_15_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 15 */
  7347. #define LL_ADC_REG_RANK_16 (ADC_SQR1_REGOFFSET | ADC_REG_RANK_16_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 16 */
  7348. /**
  7349. * @}
  7350. */
  7351. /** @defgroup ADC_LL_EC_INJ_TRIGGER_SOURCE ADC group injected - Trigger source
  7352. * @{
  7353. */
  7354. #define LL_ADC_INJ_TRIG_SOFTWARE (ADC_CR2_JEXTSEL_2 | ADC_CR2_JEXTSEL_1 | ADC_CR2_JEXTSEL_0) /*!< ADC group injected conversion trigger internal (SW start) */
  7355. #define LL_ADC_INJ_TRIG_EXT_TIM2_TRGO (ADC_CR2_JEXTSEL_1) /*!< ADC group injected conversion trigger external from TIM2 TRGO. Trigger edge set to rising edge (default setting). */
  7356. #define LL_ADC_INJ_TRIG_EXT_TIM2_CH1 (ADC_CR2_JEXTSEL_1 | ADC_CR2_JEXTSEL_0) /*!< ADC group injected conversion trigger external from TIM2 CC1. Trigger edge set to rising edge (default setting). */
  7357. #define LL_ADC_INJ_TRIG_EXT_TIM3_CH4 (ADC_CR2_JEXTSEL_2) /*!< ADC group injected conversion trigger external from TIM3 CC4. Trigger edge set to rising edge (default setting). */
  7358. #define LL_ADC_INJ_TRIG_EXT_TIM4_TRGO (ADC_CR2_JEXTSEL_2 | ADC_CR2_JEXTSEL_0) /*!< ADC group injected conversion trigger external from TIM4 TRGO. Trigger edge set to rising edge (default setting). */
  7359. #define LL_ADC_INJ_TRIG_EXT_TIM19_CH1 ((uint32_t)0x00000000U) /*!< ADC group injected conversion trigger external from TIM19 CC1. Trigger edge set to rising edge (default setting). */
  7360. #define LL_ADC_INJ_TRIG_EXT_TIM19_CH2 (ADC_CR2_JEXTSEL_0) /*!< ADC group injected conversion trigger external from TIM19 CC2. Trigger edge set to rising edge (default setting). */
  7361. #define LL_ADC_INJ_TRIG_EXT_EXTI_LINE15 (ADC_CR2_JEXTSEL_2 | ADC_CR2_JEXTSEL_1) /*!< ADC group injected conversion trigger external interrupt line 15. Trigger edge set to rising edge (default setting). */
  7362. /**
  7363. * @}
  7364. */
  7365. /** @defgroup ADC_LL_EC_INJ_TRIGGER_EDGE ADC group injected - Trigger edge
  7366. * @{
  7367. */
  7368. #define LL_ADC_INJ_TRIG_EXT_RISING ((uint32_t)0x00000000U) /*!< ADC group injected conversion trigger polarity set to rising edge */
  7369. /**
  7370. * @}
  7371. */
  7372. /** @defgroup ADC_LL_EC_INJ_TRIG_AUTO ADC group injected - Automatic trigger mode
  7373. * @{
  7374. */
  7375. #define LL_ADC_INJ_TRIG_INDEPENDENT ((uint32_t)0x00000000U)/*!< ADC group injected conversion trigger independent. Setting mandatory if ADC group injected injected trigger source is set to an external trigger. */
  7376. #define LL_ADC_INJ_TRIG_FROM_GRP_REGULAR (ADC_CR1_JAUTO) /*!< ADC group injected conversion trigger from ADC group regular. Setting compliant only with group injected trigger source set to SW start, without any further action on ADC group injected conversion start or stop: in this case, ADC group injected is controlled only from ADC group regular. */
  7377. /**
  7378. * @}
  7379. */
  7380. /** @defgroup ADC_LL_EC_INJ_SEQ_SCAN_LENGTH ADC group injected - Sequencer scan length
  7381. * @{
  7382. */
  7383. #define LL_ADC_INJ_SEQ_SCAN_DISABLE ((uint32_t)0x00000000U) /*!< ADC group injected sequencer disable (equivalent to sequencer of 1 rank: ADC conversion on only 1 channel) */
  7384. #define LL_ADC_INJ_SEQ_SCAN_ENABLE_2RANKS ( ADC_JSQR_JL_0) /*!< ADC group injected sequencer enable with 2 ranks in the sequence */
  7385. #define LL_ADC_INJ_SEQ_SCAN_ENABLE_3RANKS (ADC_JSQR_JL_1 ) /*!< ADC group injected sequencer enable with 3 ranks in the sequence */
  7386. #define LL_ADC_INJ_SEQ_SCAN_ENABLE_4RANKS (ADC_JSQR_JL_1 | ADC_JSQR_JL_0) /*!< ADC group injected sequencer enable with 4 ranks in the sequence */
  7387. /**
  7388. * @}
  7389. */
  7390. /** @defgroup ADC_LL_EC_INJ_SEQ_DISCONT_MODE ADC group injected - Sequencer discontinuous mode
  7391. * @{
  7392. */
  7393. #define LL_ADC_INJ_SEQ_DISCONT_DISABLE ((uint32_t)0x00000000U)/*!< ADC group injected sequencer discontinuous mode disable */
  7394. #define LL_ADC_INJ_SEQ_DISCONT_1RANK (ADC_CR1_JDISCEN) /*!< ADC group injected sequencer discontinuous mode enable with sequence interruption every rank */
  7395. /**
  7396. * @}
  7397. */
  7398. /** @defgroup ADC_LL_EC_INJ_RANKS ADC group injected - Sequencer ranks
  7399. * @{
  7400. */
  7401. #define LL_ADC_INJ_RANK_1 (ADC_JDR1_REGOFFSET | ADC_JOFR1_REGOFFSET | ADC_INJ_RANK_1_JSQR_BITOFFSET_POS) /*!< ADC group injected sequencer rank 1 */
  7402. #define LL_ADC_INJ_RANK_2 (ADC_JDR2_REGOFFSET | ADC_JOFR2_REGOFFSET | ADC_INJ_RANK_2_JSQR_BITOFFSET_POS) /*!< ADC group injected sequencer rank 2 */
  7403. #define LL_ADC_INJ_RANK_3 (ADC_JDR3_REGOFFSET | ADC_JOFR3_REGOFFSET | ADC_INJ_RANK_3_JSQR_BITOFFSET_POS) /*!< ADC group injected sequencer rank 3 */
  7404. #define LL_ADC_INJ_RANK_4 (ADC_JDR4_REGOFFSET | ADC_JOFR4_REGOFFSET | ADC_INJ_RANK_4_JSQR_BITOFFSET_POS) /*!< ADC group injected sequencer rank 4 */
  7405. /**
  7406. * @}
  7407. */
  7408. /** @defgroup ADC_LL_EC_SAMPLINGTIME Channel - Sampling time
  7409. * @{
  7410. */
  7411. #define LL_ADC_SAMPLINGTIME_1CYCLE_5 ((uint32_t)0x00000000U) /*!< Sampling time 1.5 ADC clock cycle */
  7412. #define LL_ADC_SAMPLINGTIME_7CYCLES_5 (ADC_SMPR2_SMP0_0) /*!< Sampling time 7.5 ADC clock cycles */
  7413. #define LL_ADC_SAMPLINGTIME_13CYCLES_5 (ADC_SMPR2_SMP0_1) /*!< Sampling time 13.5 ADC clock cycles */
  7414. #define LL_ADC_SAMPLINGTIME_28CYCLES_5 (ADC_SMPR2_SMP0_1 | ADC_SMPR2_SMP0_0) /*!< Sampling time 28.5 ADC clock cycles */
  7415. #define LL_ADC_SAMPLINGTIME_41CYCLES_5 (ADC_SMPR2_SMP0_2) /*!< Sampling time 41.5 ADC clock cycles */
  7416. #define LL_ADC_SAMPLINGTIME_55CYCLES_5 (ADC_SMPR2_SMP0_2 | ADC_SMPR2_SMP0_0) /*!< Sampling time 55.5 ADC clock cycles */
  7417. #define LL_ADC_SAMPLINGTIME_71CYCLES_5 (ADC_SMPR2_SMP0_2 | ADC_SMPR2_SMP0_1) /*!< Sampling time 71.5 ADC clock cycles */
  7418. #define LL_ADC_SAMPLINGTIME_239CYCLES_5 (ADC_SMPR2_SMP0_2 | ADC_SMPR2_SMP0_1 | ADC_SMPR2_SMP0_0) /*!< Sampling time 239.5 ADC clock cycles */
  7419. /**
  7420. * @}
  7421. */
  7422. /** @defgroup ADC_LL_EC_AWD_NUMBER Analog watchdog - Analog watchdog number
  7423. * @{
  7424. */
  7425. #define LL_ADC_AWD1 (ADC_AWD_CR1_CHANNEL_MASK | ADC_AWD_CR1_REGOFFSET) /*!< ADC analog watchdog number 1 */
  7426. /**
  7427. * @}
  7428. */
  7429. /** @defgroup ADC_LL_EC_AWD_CHANNELS Analog watchdog - Monitored channels
  7430. * @{
  7431. */
  7432. #define LL_ADC_AWD_DISABLE ((uint32_t)0x00000000U) /*!< ADC analog watchdog monitoring disabled */
  7433. #define LL_ADC_AWD_ALL_CHANNELS_REG ( ADC_CR1_AWDEN ) /*!< ADC analog watchdog monitoring of all channels, converted by group regular only */
  7434. #define LL_ADC_AWD_ALL_CHANNELS_INJ ( ADC_CR1_JAWDEN ) /*!< ADC analog watchdog monitoring of all channels, converted by group injected only */
  7435. #define LL_ADC_AWD_ALL_CHANNELS_REG_INJ ( ADC_CR1_JAWDEN | ADC_CR1_AWDEN ) /*!< ADC analog watchdog monitoring of all channels, converted by either group regular or injected */
  7436. #define LL_ADC_AWD_CHANNEL_0_REG ((LL_ADC_CHANNEL_0 & ADC_CHANNEL_ID_MASK) | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN0, converted by group regular only */
  7437. #define LL_ADC_AWD_CHANNEL_0_INJ ((LL_ADC_CHANNEL_0 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN0, converted by group injected only */
  7438. #define LL_ADC_AWD_CHANNEL_0_REG_INJ ((LL_ADC_CHANNEL_0 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN0, converted by either group regular or injected */
  7439. #define LL_ADC_AWD_CHANNEL_1_REG ((LL_ADC_CHANNEL_1 & ADC_CHANNEL_ID_MASK) | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN1, converted by group regular only */
  7440. #define LL_ADC_AWD_CHANNEL_1_INJ ((LL_ADC_CHANNEL_1 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN1, converted by group injected only */
  7441. #define LL_ADC_AWD_CHANNEL_1_REG_INJ ((LL_ADC_CHANNEL_1 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN1, converted by either group regular or injected */
  7442. #define LL_ADC_AWD_CHANNEL_2_REG ((LL_ADC_CHANNEL_2 & ADC_CHANNEL_ID_MASK) | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN2, converted by group regular only */
  7443. #define LL_ADC_AWD_CHANNEL_2_INJ ((LL_ADC_CHANNEL_2 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN2, converted by group injected only */
  7444. #define LL_ADC_AWD_CHANNEL_2_REG_INJ ((LL_ADC_CHANNEL_2 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN2, converted by either group regular or injected */
  7445. #define LL_ADC_AWD_CHANNEL_3_REG ((LL_ADC_CHANNEL_3 & ADC_CHANNEL_ID_MASK) | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN3, converted by group regular only */
  7446. #define LL_ADC_AWD_CHANNEL_3_INJ ((LL_ADC_CHANNEL_3 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN3, converted by group injected only */
  7447. #define LL_ADC_AWD_CHANNEL_3_REG_INJ ((LL_ADC_CHANNEL_3 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN3, converted by either group regular or injected */
  7448. #define LL_ADC_AWD_CHANNEL_4_REG ((LL_ADC_CHANNEL_4 & ADC_CHANNEL_ID_MASK) | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN4, converted by group regular only */
  7449. #define LL_ADC_AWD_CHANNEL_4_INJ ((LL_ADC_CHANNEL_4 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN4, converted by group injected only */
  7450. #define LL_ADC_AWD_CHANNEL_4_REG_INJ ((LL_ADC_CHANNEL_4 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN4, converted by either group regular or injected */
  7451. #define LL_ADC_AWD_CHANNEL_5_REG ((LL_ADC_CHANNEL_5 & ADC_CHANNEL_ID_MASK) | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN5, converted by group regular only */
  7452. #define LL_ADC_AWD_CHANNEL_5_INJ ((LL_ADC_CHANNEL_5 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN5, converted by group injected only */
  7453. #define LL_ADC_AWD_CHANNEL_5_REG_INJ ((LL_ADC_CHANNEL_5 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN5, converted by either group regular or injected */
  7454. #define LL_ADC_AWD_CHANNEL_6_REG ((LL_ADC_CHANNEL_6 & ADC_CHANNEL_ID_MASK) | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN6, converted by group regular only */
  7455. #define LL_ADC_AWD_CHANNEL_6_INJ ((LL_ADC_CHANNEL_6 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN6, converted by group injected only */
  7456. #define LL_ADC_AWD_CHANNEL_6_REG_INJ ((LL_ADC_CHANNEL_6 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN6, converted by either group regular or injected */
  7457. #define LL_ADC_AWD_CHANNEL_7_REG ((LL_ADC_CHANNEL_7 & ADC_CHANNEL_ID_MASK) | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN7, converted by group regular only */
  7458. #define LL_ADC_AWD_CHANNEL_7_INJ ((LL_ADC_CHANNEL_7 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN7, converted by group injected only */
  7459. #define LL_ADC_AWD_CHANNEL_7_REG_INJ ((LL_ADC_CHANNEL_7 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN7, converted by either group regular or injected */
  7460. #define LL_ADC_AWD_CHANNEL_8_REG ((LL_ADC_CHANNEL_8 & ADC_CHANNEL_ID_MASK) | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN8, converted by group regular only */
  7461. #define LL_ADC_AWD_CHANNEL_8_INJ ((LL_ADC_CHANNEL_8 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN8, converted by group injected only */
  7462. #define LL_ADC_AWD_CHANNEL_8_REG_INJ ((LL_ADC_CHANNEL_8 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN8, converted by either group regular or injected */
  7463. #define LL_ADC_AWD_CHANNEL_9_REG ((LL_ADC_CHANNEL_9 & ADC_CHANNEL_ID_MASK) | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN9, converted by group regular only */
  7464. #define LL_ADC_AWD_CHANNEL_9_INJ ((LL_ADC_CHANNEL_9 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN9, converted by group injected only */
  7465. #define LL_ADC_AWD_CHANNEL_9_REG_INJ ((LL_ADC_CHANNEL_9 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN9, converted by either group regular or injected */
  7466. #define LL_ADC_AWD_CHANNEL_10_REG ((LL_ADC_CHANNEL_10 & ADC_CHANNEL_ID_MASK) | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN10, converted by group regular only */
  7467. #define LL_ADC_AWD_CHANNEL_10_INJ ((LL_ADC_CHANNEL_10 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN10, converted by group injected only */
  7468. #define LL_ADC_AWD_CHANNEL_10_REG_INJ ((LL_ADC_CHANNEL_10 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN10, converted by either group regular or injected */
  7469. #define LL_ADC_AWD_CHANNEL_11_REG ((LL_ADC_CHANNEL_11 & ADC_CHANNEL_ID_MASK) | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN11, converted by group regular only */
  7470. #define LL_ADC_AWD_CHANNEL_11_INJ ((LL_ADC_CHANNEL_11 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN11, converted by group injected only */
  7471. #define LL_ADC_AWD_CHANNEL_11_REG_INJ ((LL_ADC_CHANNEL_11 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN11, converted by either group regular or injected */
  7472. #define LL_ADC_AWD_CHANNEL_12_REG ((LL_ADC_CHANNEL_12 & ADC_CHANNEL_ID_MASK) | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN12, converted by group regular only */
  7473. #define LL_ADC_AWD_CHANNEL_12_INJ ((LL_ADC_CHANNEL_12 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN12, converted by group injected only */
  7474. #define LL_ADC_AWD_CHANNEL_12_REG_INJ ((LL_ADC_CHANNEL_12 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN12, converted by either group regular or injected */
  7475. #define LL_ADC_AWD_CHANNEL_13_REG ((LL_ADC_CHANNEL_13 & ADC_CHANNEL_ID_MASK) | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN13, converted by group regular only */
  7476. #define LL_ADC_AWD_CHANNEL_13_INJ ((LL_ADC_CHANNEL_13 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN13, converted by group injected only */
  7477. #define LL_ADC_AWD_CHANNEL_13_REG_INJ ((LL_ADC_CHANNEL_13 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN13, converted by either group regular or injected */
  7478. #define LL_ADC_AWD_CHANNEL_14_REG ((LL_ADC_CHANNEL_14 & ADC_CHANNEL_ID_MASK) | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN14, converted by group regular only */
  7479. #define LL_ADC_AWD_CHANNEL_14_INJ ((LL_ADC_CHANNEL_14 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN14, converted by group injected only */
  7480. #define LL_ADC_AWD_CHANNEL_14_REG_INJ ((LL_ADC_CHANNEL_14 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN14, converted by either group regular or injected */
  7481. #define LL_ADC_AWD_CHANNEL_15_REG ((LL_ADC_CHANNEL_15 & ADC_CHANNEL_ID_MASK) | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN15, converted by group regular only */
  7482. #define LL_ADC_AWD_CHANNEL_15_INJ ((LL_ADC_CHANNEL_15 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN15, converted by group injected only */
  7483. #define LL_ADC_AWD_CHANNEL_15_REG_INJ ((LL_ADC_CHANNEL_15 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN15, converted by either group regular or injected */
  7484. #define LL_ADC_AWD_CHANNEL_16_REG ((LL_ADC_CHANNEL_16 & ADC_CHANNEL_ID_MASK) | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN16, converted by group regular only */
  7485. #define LL_ADC_AWD_CHANNEL_16_INJ ((LL_ADC_CHANNEL_16 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN16, converted by group injected only */
  7486. #define LL_ADC_AWD_CHANNEL_16_REG_INJ ((LL_ADC_CHANNEL_16 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN16, converted by either group regular or injected */
  7487. #define LL_ADC_AWD_CHANNEL_17_REG ((LL_ADC_CHANNEL_17 & ADC_CHANNEL_ID_MASK) | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN17, converted by group regular only */
  7488. #define LL_ADC_AWD_CHANNEL_17_INJ ((LL_ADC_CHANNEL_17 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN17, converted by group injected only */
  7489. #define LL_ADC_AWD_CHANNEL_17_REG_INJ ((LL_ADC_CHANNEL_17 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN17, converted by either group regular or injected */
  7490. #define LL_ADC_AWD_CH_VREFINT_REG ((LL_ADC_CHANNEL_VREFINT & ADC_CHANNEL_ID_MASK) | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC internal channel connected to VrefInt: Internal voltage reference, converted by group regular only */
  7491. #define LL_ADC_AWD_CH_VREFINT_INJ ((LL_ADC_CHANNEL_VREFINT & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC internal channel connected to VrefInt: Internal voltage reference, converted by group injected only */
  7492. #define LL_ADC_AWD_CH_VREFINT_REG_INJ ((LL_ADC_CHANNEL_VREFINT & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC internal channel connected to VrefInt: Internal voltage reference, converted by either group regular or injected */
  7493. #define LL_ADC_AWD_CH_TEMPSENSOR_REG ((LL_ADC_CHANNEL_TEMPSENSOR & ADC_CHANNEL_ID_MASK) | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC internal channel connected to Temperature sensor, converted by group regular only */
  7494. #define LL_ADC_AWD_CH_TEMPSENSOR_INJ ((LL_ADC_CHANNEL_TEMPSENSOR & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC internal channel connected to Temperature sensor, converted by group injected only */
  7495. #define LL_ADC_AWD_CH_TEMPSENSOR_REG_INJ ((LL_ADC_CHANNEL_TEMPSENSOR & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC internal channel connected to Temperature sensor, converted by either group regular or injected */
  7496. /**
  7497. * @}
  7498. */
  7499. /** @defgroup ADC_LL_EC_AWD_THRESHOLDS Analog watchdog - Thresholds
  7500. * @{
  7501. */
  7502. #define LL_ADC_AWD_THRESHOLD_HIGH (ADC_AWD_TR1_HIGH_REGOFFSET) /*!< ADC analog watchdog threshold high */
  7503. #define LL_ADC_AWD_THRESHOLD_LOW (ADC_AWD_TR1_LOW_REGOFFSET) /*!< ADC analog watchdog threshold low */
  7504. /**
  7505. * @}
  7506. */
  7507. /** @defgroup ADC_LL_EC_HW_DELAYS Definitions of ADC hardware constraints delays
  7508. * @note Only ADC IP HW delays are defined in ADC LL driver driver,
  7509. * not timeout values.
  7510. * For details on delays values, refer to descriptions in source code
  7511. * above each literal definition.
  7512. * @{
  7513. */
  7514. /* Note: Only ADC IP HW delays are defined in ADC LL driver driver, */
  7515. /* not timeout values. */
  7516. /* Timeout values for ADC operations are dependent to device clock */
  7517. /* configuration (system clock versus ADC clock), */
  7518. /* and therefore must be defined in user application. */
  7519. /* Indications for estimation of ADC timeout delays, for this */
  7520. /* STM32 series: */
  7521. /* - ADC enable time: maximum delay is 1us */
  7522. /* (refer to device datasheet, parameter "tSTAB") */
  7523. /* - ADC conversion time: duration depending on ADC clock and ADC */
  7524. /* configuration. */
  7525. /* (refer to device reference manual, section "Timing") */
  7526. /* Delay for temperature sensor stabilization time. */
  7527. /* Literal set to maximum value (refer to device datasheet, */
  7528. /* parameter "tSTART"). */
  7529. /* Unit: us */
  7530. #define LL_ADC_DELAY_TEMPSENSOR_STAB_US ((uint32_t) 10U) /*!< Delay for internal voltage reference stabilization time */
  7531. /* Delay required between ADC disable and ADC calibration start. */
  7532. /* Note: On this STM32 series, before starting a calibration, */
  7533. /* ADC must be enabled on STM32F37x and disabled on */
  7534. /* other STM32F3 devices. */
  7535. /* A minimum number of ADC clock cycles are required */
  7536. /* between ADC disable state and calibration start. */
  7537. /* Refer to literal @ref LL_ADC_DELAY_CALIB_ENABLE_ADC_CYCLES. */
  7538. /* Wait time can be computed in user application by waiting for the */
  7539. /* equivalent number of CPU cycles, by taking into account */
  7540. /* ratio of CPU clock versus ADC clock prescalers. */
  7541. /* Unit: ADC clock cycles. */
  7542. #define LL_ADC_DELAY_DISABLE_CALIB_ADC_CYCLES ((uint32_t) 2U) /*!< Delay required between ADC disable and ADC calibration start */
  7543. /**
  7544. * @}
  7545. */
  7546. /**
  7547. * @}
  7548. */
  7549. /* Exported macro ------------------------------------------------------------*/
  7550. /** @defgroup ADC_LL_Exported_Macros ADC Exported Macros
  7551. * @{
  7552. */
  7553. /** @defgroup ADC_LL_EM_WRITE_READ Common write and read registers Macros
  7554. * @{
  7555. */
  7556. /**
  7557. * @brief Write a value in ADC register
  7558. * @param __INSTANCE__ ADC Instance
  7559. * @param __REG__ Register to be written
  7560. * @param __VALUE__ Value to be written in the register
  7561. * @retval None
  7562. */
  7563. #define LL_ADC_WriteReg(__INSTANCE__, __REG__, __VALUE__) WRITE_REG(__INSTANCE__->__REG__, (__VALUE__))
  7564. /**
  7565. * @brief Read a value in ADC register
  7566. * @param __INSTANCE__ ADC Instance
  7567. * @param __REG__ Register to be read
  7568. * @retval Register value
  7569. */
  7570. #define LL_ADC_ReadReg(__INSTANCE__, __REG__) READ_REG(__INSTANCE__->__REG__)
  7571. /**
  7572. * @}
  7573. */
  7574. /** @defgroup ADC_LL_EM_HELPER_MACRO ADC helper macro
  7575. * @{
  7576. */
  7577. /**
  7578. * @brief Helper macro to get ADC channel number in decimal format
  7579. * from literals LL_ADC_CHANNEL_x.
  7580. * @note Example:
  7581. * __LL_ADC_CHANNEL_TO_DECIMAL_NB(LL_ADC_CHANNEL_4)
  7582. * will return decimal number "4".
  7583. * @note The input can be a value from functions where a channel
  7584. * number is returned, either defined with number
  7585. * or with bitfield (only one bit must be set).
  7586. * @param __CHANNEL__ This parameter can be one of the following values:
  7587. * @arg @ref LL_ADC_CHANNEL_0
  7588. * @arg @ref LL_ADC_CHANNEL_1
  7589. * @arg @ref LL_ADC_CHANNEL_2
  7590. * @arg @ref LL_ADC_CHANNEL_3
  7591. * @arg @ref LL_ADC_CHANNEL_4
  7592. * @arg @ref LL_ADC_CHANNEL_5
  7593. * @arg @ref LL_ADC_CHANNEL_6
  7594. * @arg @ref LL_ADC_CHANNEL_7
  7595. * @arg @ref LL_ADC_CHANNEL_8
  7596. * @arg @ref LL_ADC_CHANNEL_9
  7597. * @arg @ref LL_ADC_CHANNEL_10
  7598. * @arg @ref LL_ADC_CHANNEL_11
  7599. * @arg @ref LL_ADC_CHANNEL_12
  7600. * @arg @ref LL_ADC_CHANNEL_13
  7601. * @arg @ref LL_ADC_CHANNEL_14
  7602. * @arg @ref LL_ADC_CHANNEL_15
  7603. * @arg @ref LL_ADC_CHANNEL_16
  7604. * @arg @ref LL_ADC_CHANNEL_17
  7605. * @arg @ref LL_ADC_CHANNEL_VREFINT (1)
  7606. * @arg @ref LL_ADC_CHANNEL_TEMPSENSOR (1)
  7607. *
  7608. * (1) On STM32F37x, parameter available only on ADC instance: ADC1.
  7609. * @retval Value between Min_Data=0 and Max_Data=18
  7610. */
  7611. #define __LL_ADC_CHANNEL_TO_DECIMAL_NB(__CHANNEL__) \
  7612. (((__CHANNEL__) & ADC_CHANNEL_ID_NUMBER_MASK) >> ADC_CHANNEL_ID_NUMBER_BITOFFSET_POS)
  7613. /**
  7614. * @brief Helper macro to get ADC channel in literal format LL_ADC_CHANNEL_x
  7615. * from number in decimal format.
  7616. * @note Example:
  7617. * __LL_ADC_DECIMAL_NB_TO_CHANNEL(4)
  7618. * will return a data equivalent to "LL_ADC_CHANNEL_4".
  7619. * @param __DECIMAL_NB__ Value between Min_Data=0 and Max_Data=18
  7620. * @retval Returned value can be one of the following values:
  7621. * @arg @ref LL_ADC_CHANNEL_0
  7622. * @arg @ref LL_ADC_CHANNEL_1
  7623. * @arg @ref LL_ADC_CHANNEL_2
  7624. * @arg @ref LL_ADC_CHANNEL_3
  7625. * @arg @ref LL_ADC_CHANNEL_4
  7626. * @arg @ref LL_ADC_CHANNEL_5
  7627. * @arg @ref LL_ADC_CHANNEL_6
  7628. * @arg @ref LL_ADC_CHANNEL_7
  7629. * @arg @ref LL_ADC_CHANNEL_8
  7630. * @arg @ref LL_ADC_CHANNEL_9
  7631. * @arg @ref LL_ADC_CHANNEL_10
  7632. * @arg @ref LL_ADC_CHANNEL_11
  7633. * @arg @ref LL_ADC_CHANNEL_12
  7634. * @arg @ref LL_ADC_CHANNEL_13
  7635. * @arg @ref LL_ADC_CHANNEL_14
  7636. * @arg @ref LL_ADC_CHANNEL_15
  7637. * @arg @ref LL_ADC_CHANNEL_16
  7638. * @arg @ref LL_ADC_CHANNEL_17
  7639. * @arg @ref LL_ADC_CHANNEL_VREFINT (1)
  7640. * @arg @ref LL_ADC_CHANNEL_TEMPSENSOR (1)
  7641. *
  7642. * (1) On STM32F37x, parameter available only on ADC instance: ADC1.\n
  7643. * (1) For ADC channel read back from ADC register,
  7644. * comparison with internal channel parameter to be done
  7645. * using helper macro @ref __LL_ADC_CHANNEL_INTERNAL_TO_EXTERNAL().
  7646. */
  7647. #define __LL_ADC_DECIMAL_NB_TO_CHANNEL(__DECIMAL_NB__) \
  7648. (((__DECIMAL_NB__) <= 9U) \
  7649. ? ( \
  7650. ((__DECIMAL_NB__) << ADC_CHANNEL_ID_NUMBER_BITOFFSET_POS) | \
  7651. (ADC_SMPR2_REGOFFSET | (((uint32_t) (3U * (__DECIMAL_NB__))) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) \
  7652. ) \
  7653. : \
  7654. ( \
  7655. ((__DECIMAL_NB__) << ADC_CHANNEL_ID_NUMBER_BITOFFSET_POS) | \
  7656. (ADC_SMPR1_REGOFFSET | (((uint32_t) (3U * ((__DECIMAL_NB__) - 10U))) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) \
  7657. ) \
  7658. )
  7659. /**
  7660. * @brief Helper macro to determine whether the selected channel
  7661. * corresponds to literal definitions of driver.
  7662. * @note The different literal definitions of ADC channels are:
  7663. * - ADC internal channel:
  7664. * LL_ADC_CHANNEL_VREFINT, LL_ADC_CHANNEL_TEMPSENSOR, ...
  7665. * - ADC external channel (channel connected to a GPIO pin):
  7666. * LL_ADC_CHANNEL_1, LL_ADC_CHANNEL_2, ...
  7667. * @note The channel parameter must be a value defined from literal
  7668. * definition of a ADC internal channel (LL_ADC_CHANNEL_VREFINT,
  7669. * LL_ADC_CHANNEL_TEMPSENSOR, ...),
  7670. * ADC external channel (LL_ADC_CHANNEL_1, LL_ADC_CHANNEL_2, ...),
  7671. * must not be a value from functions where a channel number is
  7672. * returned from ADC registers,
  7673. * because internal and external channels share the same channel
  7674. * number in ADC registers. The differentiation is made only with
  7675. * parameters definitions of driver.
  7676. * @param __CHANNEL__ This parameter can be one of the following values:
  7677. * @arg @ref LL_ADC_CHANNEL_0
  7678. * @arg @ref LL_ADC_CHANNEL_1
  7679. * @arg @ref LL_ADC_CHANNEL_2
  7680. * @arg @ref LL_ADC_CHANNEL_3
  7681. * @arg @ref LL_ADC_CHANNEL_4
  7682. * @arg @ref LL_ADC_CHANNEL_5
  7683. * @arg @ref LL_ADC_CHANNEL_6
  7684. * @arg @ref LL_ADC_CHANNEL_7
  7685. * @arg @ref LL_ADC_CHANNEL_8
  7686. * @arg @ref LL_ADC_CHANNEL_9
  7687. * @arg @ref LL_ADC_CHANNEL_10
  7688. * @arg @ref LL_ADC_CHANNEL_11
  7689. * @arg @ref LL_ADC_CHANNEL_12
  7690. * @arg @ref LL_ADC_CHANNEL_13
  7691. * @arg @ref LL_ADC_CHANNEL_14
  7692. * @arg @ref LL_ADC_CHANNEL_15
  7693. * @arg @ref LL_ADC_CHANNEL_16
  7694. * @arg @ref LL_ADC_CHANNEL_17
  7695. * @arg @ref LL_ADC_CHANNEL_VREFINT (1)
  7696. * @arg @ref LL_ADC_CHANNEL_TEMPSENSOR (1)
  7697. *
  7698. * (1) On STM32F37x, parameter available only on ADC instance: ADC1.
  7699. * @retval Value "0" if the channel corresponds to a parameter definition of a ADC external channel (channel connected to a GPIO pin)
  7700. * Value "1" if the channel corresponds to a parameter definition of a ADC internal channel
  7701. */
  7702. #define __LL_ADC_IS_CHANNEL_INTERNAL(__CHANNEL__) \
  7703. (((__CHANNEL__) & ADC_CHANNEL_ID_INTERNAL_CH_MASK) != 0U)
  7704. /**
  7705. * @brief Helper macro to convert a channel defined from parameter
  7706. * definition of a ADC internal channel (LL_ADC_CHANNEL_VREFINT,
  7707. * LL_ADC_CHANNEL_TEMPSENSOR, ...),
  7708. * to its equivalent parameter definition of a ADC external channel
  7709. * (LL_ADC_CHANNEL_1, LL_ADC_CHANNEL_2, ...).
  7710. * @note The channel parameter can be, additionally to a value
  7711. * defined from parameter definition of a ADC internal channel
  7712. * (LL_ADC_CHANNEL_VREFINT, LL_ADC_CHANNEL_TEMPSENSOR, ...),
  7713. * a value defined from parameter definition of
  7714. * ADC external channel (LL_ADC_CHANNEL_1, LL_ADC_CHANNEL_2, ...)
  7715. * or a value from functions where a channel number is returned
  7716. * from ADC registers.
  7717. * @param __CHANNEL__ This parameter can be one of the following values:
  7718. * @arg @ref LL_ADC_CHANNEL_0
  7719. * @arg @ref LL_ADC_CHANNEL_1
  7720. * @arg @ref LL_ADC_CHANNEL_2
  7721. * @arg @ref LL_ADC_CHANNEL_3
  7722. * @arg @ref LL_ADC_CHANNEL_4
  7723. * @arg @ref LL_ADC_CHANNEL_5
  7724. * @arg @ref LL_ADC_CHANNEL_6
  7725. * @arg @ref LL_ADC_CHANNEL_7
  7726. * @arg @ref LL_ADC_CHANNEL_8
  7727. * @arg @ref LL_ADC_CHANNEL_9
  7728. * @arg @ref LL_ADC_CHANNEL_10
  7729. * @arg @ref LL_ADC_CHANNEL_11
  7730. * @arg @ref LL_ADC_CHANNEL_12
  7731. * @arg @ref LL_ADC_CHANNEL_13
  7732. * @arg @ref LL_ADC_CHANNEL_14
  7733. * @arg @ref LL_ADC_CHANNEL_15
  7734. * @arg @ref LL_ADC_CHANNEL_16
  7735. * @arg @ref LL_ADC_CHANNEL_17
  7736. * @arg @ref LL_ADC_CHANNEL_VREFINT (1)
  7737. * @arg @ref LL_ADC_CHANNEL_TEMPSENSOR (1)
  7738. *
  7739. * (1) On STM32F37x, parameter available only on ADC instance: ADC1.
  7740. * @retval Returned value can be one of the following values:
  7741. * @arg @ref LL_ADC_CHANNEL_0
  7742. * @arg @ref LL_ADC_CHANNEL_1
  7743. * @arg @ref LL_ADC_CHANNEL_2
  7744. * @arg @ref LL_ADC_CHANNEL_3
  7745. * @arg @ref LL_ADC_CHANNEL_4
  7746. * @arg @ref LL_ADC_CHANNEL_5
  7747. * @arg @ref LL_ADC_CHANNEL_6
  7748. * @arg @ref LL_ADC_CHANNEL_7
  7749. * @arg @ref LL_ADC_CHANNEL_8
  7750. * @arg @ref LL_ADC_CHANNEL_9
  7751. * @arg @ref LL_ADC_CHANNEL_10
  7752. * @arg @ref LL_ADC_CHANNEL_11
  7753. * @arg @ref LL_ADC_CHANNEL_12
  7754. * @arg @ref LL_ADC_CHANNEL_13
  7755. * @arg @ref LL_ADC_CHANNEL_14
  7756. * @arg @ref LL_ADC_CHANNEL_15
  7757. * @arg @ref LL_ADC_CHANNEL_16
  7758. * @arg @ref LL_ADC_CHANNEL_17
  7759. */
  7760. #define __LL_ADC_CHANNEL_INTERNAL_TO_EXTERNAL(__CHANNEL__) \
  7761. ((__CHANNEL__) & ~ADC_CHANNEL_ID_INTERNAL_CH_MASK)
  7762. /**
  7763. * @brief Helper macro to determine whether the internal channel
  7764. * selected is available on the ADC instance selected.
  7765. * @note The channel parameter must be a value defined from parameter
  7766. * definition of a ADC internal channel (LL_ADC_CHANNEL_VREFINT,
  7767. * LL_ADC_CHANNEL_TEMPSENSOR, ...),
  7768. * must not be a value defined from parameter definition of
  7769. * ADC external channel (LL_ADC_CHANNEL_1, LL_ADC_CHANNEL_2, ...)
  7770. * or a value from functions where a channel number is
  7771. * returned from ADC registers,
  7772. * because internal and external channels share the same channel
  7773. * number in ADC registers. The differentiation is made only with
  7774. * parameters definitions of driver.
  7775. * @param __ADC_INSTANCE__ ADC instance
  7776. * @param __CHANNEL__ This parameter can be one of the following values:
  7777. * @arg @ref LL_ADC_CHANNEL_VREFINT (1)
  7778. * @arg @ref LL_ADC_CHANNEL_TEMPSENSOR (1)
  7779. *
  7780. * (1) On STM32F37x, parameter available only on ADC instance: ADC1.
  7781. * @retval Value "0" if the internal channel selected is not available on the ADC instance selected.
  7782. * Value "1" if the internal channel selected is available on the ADC instance selected.
  7783. */
  7784. #define __LL_ADC_IS_CHANNEL_INTERNAL_AVAILABLE(__ADC_INSTANCE__, __CHANNEL__) \
  7785. (((__ADC_INSTANCE__) == ADC1) \
  7786. ? ( \
  7787. ((__CHANNEL__) == LL_ADC_CHANNEL_VREFINT) || \
  7788. ((__CHANNEL__) == LL_ADC_CHANNEL_TEMPSENSOR) \
  7789. ) \
  7790. : \
  7791. (0U) \
  7792. )
  7793. /**
  7794. * @brief Helper macro to define ADC analog watchdog parameter:
  7795. * define a single channel to monitor with analog watchdog
  7796. * from sequencer channel and groups definition.
  7797. * @note To be used with function @ref LL_ADC_SetAnalogWDMonitChannels().
  7798. * Example:
  7799. * LL_ADC_SetAnalogWDMonitChannels(
  7800. * ADC1, LL_ADC_AWD1,
  7801. * __LL_ADC_ANALOGWD_CHANNEL_GROUP(LL_ADC_CHANNEL4, LL_ADC_GROUP_REGULAR))
  7802. * @param __CHANNEL__ This parameter can be one of the following values:
  7803. * @arg @ref LL_ADC_CHANNEL_0
  7804. * @arg @ref LL_ADC_CHANNEL_1
  7805. * @arg @ref LL_ADC_CHANNEL_2
  7806. * @arg @ref LL_ADC_CHANNEL_3
  7807. * @arg @ref LL_ADC_CHANNEL_4
  7808. * @arg @ref LL_ADC_CHANNEL_5
  7809. * @arg @ref LL_ADC_CHANNEL_6
  7810. * @arg @ref LL_ADC_CHANNEL_7
  7811. * @arg @ref LL_ADC_CHANNEL_8
  7812. * @arg @ref LL_ADC_CHANNEL_9
  7813. * @arg @ref LL_ADC_CHANNEL_10
  7814. * @arg @ref LL_ADC_CHANNEL_11
  7815. * @arg @ref LL_ADC_CHANNEL_12
  7816. * @arg @ref LL_ADC_CHANNEL_13
  7817. * @arg @ref LL_ADC_CHANNEL_14
  7818. * @arg @ref LL_ADC_CHANNEL_15
  7819. * @arg @ref LL_ADC_CHANNEL_16
  7820. * @arg @ref LL_ADC_CHANNEL_17
  7821. * @arg @ref LL_ADC_CHANNEL_VREFINT (1)
  7822. * @arg @ref LL_ADC_CHANNEL_TEMPSENSOR (1)
  7823. *
  7824. * (1) On STM32F37x, parameter available only on ADC instance: ADC1.\n
  7825. * (1) For ADC channel read back from ADC register,
  7826. * comparison with internal channel parameter to be done
  7827. * using helper macro @ref __LL_ADC_CHANNEL_INTERNAL_TO_EXTERNAL().
  7828. * @param __GROUP__ This parameter can be one of the following values:
  7829. * @arg @ref LL_ADC_GROUP_REGULAR
  7830. * @arg @ref LL_ADC_GROUP_INJECTED
  7831. * @arg @ref LL_ADC_GROUP_REGULAR_INJECTED
  7832. * @retval Returned value can be one of the following values:
  7833. * @arg @ref LL_ADC_AWD_DISABLE
  7834. * @arg @ref LL_ADC_AWD_ALL_CHANNELS_REG
  7835. * @arg @ref LL_ADC_AWD_ALL_CHANNELS_INJ
  7836. * @arg @ref LL_ADC_AWD_ALL_CHANNELS_REG_INJ
  7837. * @arg @ref LL_ADC_AWD_CHANNEL_0_REG
  7838. * @arg @ref LL_ADC_AWD_CHANNEL_0_INJ
  7839. * @arg @ref LL_ADC_AWD_CHANNEL_0_REG_INJ
  7840. * @arg @ref LL_ADC_AWD_CHANNEL_1_REG
  7841. * @arg @ref LL_ADC_AWD_CHANNEL_1_INJ
  7842. * @arg @ref LL_ADC_AWD_CHANNEL_1_REG_INJ
  7843. * @arg @ref LL_ADC_AWD_CHANNEL_2_REG
  7844. * @arg @ref LL_ADC_AWD_CHANNEL_2_INJ
  7845. * @arg @ref LL_ADC_AWD_CHANNEL_2_REG_INJ
  7846. * @arg @ref LL_ADC_AWD_CHANNEL_3_REG
  7847. * @arg @ref LL_ADC_AWD_CHANNEL_3_INJ
  7848. * @arg @ref LL_ADC_AWD_CHANNEL_3_REG_INJ
  7849. * @arg @ref LL_ADC_AWD_CHANNEL_4_REG
  7850. * @arg @ref LL_ADC_AWD_CHANNEL_4_INJ
  7851. * @arg @ref LL_ADC_AWD_CHANNEL_4_REG_INJ
  7852. * @arg @ref LL_ADC_AWD_CHANNEL_5_REG
  7853. * @arg @ref LL_ADC_AWD_CHANNEL_5_INJ
  7854. * @arg @ref LL_ADC_AWD_CHANNEL_5_REG_INJ
  7855. * @arg @ref LL_ADC_AWD_CHANNEL_6_REG
  7856. * @arg @ref LL_ADC_AWD_CHANNEL_6_INJ
  7857. * @arg @ref LL_ADC_AWD_CHANNEL_6_REG_INJ
  7858. * @arg @ref LL_ADC_AWD_CHANNEL_7_REG
  7859. * @arg @ref LL_ADC_AWD_CHANNEL_7_INJ
  7860. * @arg @ref LL_ADC_AWD_CHANNEL_7_REG_INJ
  7861. * @arg @ref LL_ADC_AWD_CHANNEL_8_REG
  7862. * @arg @ref LL_ADC_AWD_CHANNEL_8_INJ
  7863. * @arg @ref LL_ADC_AWD_CHANNEL_8_REG_INJ
  7864. * @arg @ref LL_ADC_AWD_CHANNEL_9_REG
  7865. * @arg @ref LL_ADC_AWD_CHANNEL_9_INJ
  7866. * @arg @ref LL_ADC_AWD_CHANNEL_9_REG_INJ
  7867. * @arg @ref LL_ADC_AWD_CHANNEL_10_REG
  7868. * @arg @ref LL_ADC_AWD_CHANNEL_10_INJ
  7869. * @arg @ref LL_ADC_AWD_CHANNEL_10_REG_INJ
  7870. * @arg @ref LL_ADC_AWD_CHANNEL_11_REG
  7871. * @arg @ref LL_ADC_AWD_CHANNEL_11_INJ
  7872. * @arg @ref LL_ADC_AWD_CHANNEL_11_REG_INJ
  7873. * @arg @ref LL_ADC_AWD_CHANNEL_12_REG
  7874. * @arg @ref LL_ADC_AWD_CHANNEL_12_INJ
  7875. * @arg @ref LL_ADC_AWD_CHANNEL_12_REG_INJ
  7876. * @arg @ref LL_ADC_AWD_CHANNEL_13_REG
  7877. * @arg @ref LL_ADC_AWD_CHANNEL_13_INJ
  7878. * @arg @ref LL_ADC_AWD_CHANNEL_13_REG_INJ
  7879. * @arg @ref LL_ADC_AWD_CHANNEL_14_REG
  7880. * @arg @ref LL_ADC_AWD_CHANNEL_14_INJ
  7881. * @arg @ref LL_ADC_AWD_CHANNEL_14_REG_INJ
  7882. * @arg @ref LL_ADC_AWD_CHANNEL_15_REG
  7883. * @arg @ref LL_ADC_AWD_CHANNEL_15_INJ
  7884. * @arg @ref LL_ADC_AWD_CHANNEL_15_REG_INJ
  7885. * @arg @ref LL_ADC_AWD_CHANNEL_16_REG
  7886. * @arg @ref LL_ADC_AWD_CHANNEL_16_INJ
  7887. * @arg @ref LL_ADC_AWD_CHANNEL_16_REG_INJ
  7888. * @arg @ref LL_ADC_AWD_CHANNEL_17_REG
  7889. * @arg @ref LL_ADC_AWD_CHANNEL_17_INJ
  7890. * @arg @ref LL_ADC_AWD_CHANNEL_17_REG_INJ
  7891. * @arg @ref LL_ADC_AWD_CH_VREFINT_REG (1)
  7892. * @arg @ref LL_ADC_AWD_CH_VREFINT_INJ (1)
  7893. * @arg @ref LL_ADC_AWD_CH_VREFINT_REG_INJ (1)
  7894. * @arg @ref LL_ADC_AWD_CH_TEMPSENSOR_REG (1)
  7895. * @arg @ref LL_ADC_AWD_CH_TEMPSENSOR_INJ (1)
  7896. * @arg @ref LL_ADC_AWD_CH_TEMPSENSOR_REG_INJ (1)
  7897. *
  7898. * (1) On STM32F37x, parameter available only on ADC instance: ADC1.
  7899. */
  7900. #define __LL_ADC_ANALOGWD_CHANNEL_GROUP(__CHANNEL__, __GROUP__) \
  7901. (((__GROUP__) == LL_ADC_GROUP_REGULAR) \
  7902. ? (((__CHANNEL__) & ADC_CHANNEL_ID_MASK) | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) \
  7903. : \
  7904. ((__GROUP__) == LL_ADC_GROUP_INJECTED) \
  7905. ? (((__CHANNEL__) & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDSGL) \
  7906. : \
  7907. (((__CHANNEL__) & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) \
  7908. )
  7909. /**
  7910. * @brief Helper macro to set the value of ADC analog watchdog threshold high
  7911. * or low in function of ADC resolution, when ADC resolution is
  7912. * different of 12 bits.
  7913. * @note To be used with function @ref LL_ADC_SetAnalogWDThresholds().
  7914. * Example, with a ADC resolution of 8 bits, to set the value of
  7915. * analog watchdog threshold high (on 8 bits):
  7916. * LL_ADC_SetAnalogWDThresholds
  7917. * (< ADCx param >,
  7918. * __LL_ADC_ANALOGWD_SET_THRESHOLD_RESOLUTION(LL_ADC_RESOLUTION_8B, <threshold_value_8_bits>)
  7919. * );
  7920. * @param __ADC_RESOLUTION__ This parameter can be one of the following values:
  7921. * @arg @ref LL_ADC_RESOLUTION_12B
  7922. * @param __AWD_THRESHOLD__ Value between Min_Data=0x000 and Max_Data=0xFFF
  7923. * @retval Value between Min_Data=0x000 and Max_Data=0xFFF
  7924. */
  7925. /* Note: On this STM32 series, ADC is fixed to resolution 12 bits. */
  7926. /* This macro has been kept anyway for compatibility with other */
  7927. /* STM32 families featuring different ADC resolutions. */
  7928. #define __LL_ADC_ANALOGWD_SET_THRESHOLD_RESOLUTION(__ADC_RESOLUTION__, __AWD_THRESHOLD__) \
  7929. ((__AWD_THRESHOLD__) << (0U))
  7930. /**
  7931. * @brief Helper macro to get the value of ADC analog watchdog threshold high
  7932. * or low in function of ADC resolution, when ADC resolution is
  7933. * different of 12 bits.
  7934. * @note To be used with function @ref LL_ADC_GetAnalogWDThresholds().
  7935. * Example, with a ADC resolution of 8 bits, to get the value of
  7936. * analog watchdog threshold high (on 8 bits):
  7937. * < threshold_value_6_bits > = __LL_ADC_ANALOGWD_GET_THRESHOLD_RESOLUTION
  7938. * (LL_ADC_RESOLUTION_8B,
  7939. * LL_ADC_GetAnalogWDThresholds(<ADCx param>, LL_ADC_AWD_THRESHOLD_HIGH)
  7940. * );
  7941. * @param __ADC_RESOLUTION__ This parameter can be one of the following values:
  7942. * @arg @ref LL_ADC_RESOLUTION_12B
  7943. * @param __AWD_THRESHOLD_12_BITS__ Value between Min_Data=0x000 and Max_Data=0xFFF
  7944. * @retval Value between Min_Data=0x000 and Max_Data=0xFFF
  7945. */
  7946. /* Note: On this STM32 series, ADC is fixed to resolution 12 bits. */
  7947. /* This macro has been kept anyway for compatibility with other */
  7948. /* STM32 families featuring different ADC resolutions. */
  7949. #define __LL_ADC_ANALOGWD_GET_THRESHOLD_RESOLUTION(__ADC_RESOLUTION__, __AWD_THRESHOLD_12_BITS__) \
  7950. (__AWD_THRESHOLD_12_BITS__)
  7951. /**
  7952. * @brief Helper macro to select the ADC common instance
  7953. * to which is belonging the selected ADC instance.
  7954. * @note ADC common register instance can be used for:
  7955. * - Set parameters common to several ADC instances
  7956. * - Multimode (for devices with several ADC instances)
  7957. * Refer to functions having argument "ADCxy_COMMON" as parameter.
  7958. * @note On STM32F37x, there is no common ADC instance.
  7959. * However, ADC instance ADC1 has a role of common ADC instance
  7960. * (equivalence with other STM32 families featuring several
  7961. * ADC instances).
  7962. * @param __ADCx__ ADC instance
  7963. * @retval ADC common register instance
  7964. */
  7965. #define __LL_ADC_COMMON_INSTANCE(__ADCx__) \
  7966. (ADC1_COMMON)
  7967. /**
  7968. * @brief Helper macro to check if all ADC instances sharing the same
  7969. * ADC common instance are disabled.
  7970. * @note This check is required by functions with setting conditioned to
  7971. * ADC state:
  7972. * All ADC instances of the ADC common group must be disabled.
  7973. * Refer to functions having argument "ADCxy_COMMON" as parameter.
  7974. * @note On devices with only 1 ADC common instance, parameter of this macro
  7975. * is useless and can be ignored (parameter kept for compatibility
  7976. * with devices featuring several ADC common instances).
  7977. * @note On STM32F37x, there is no common ADC instance.
  7978. * However, ADC instance ADC1 has a role of common ADC instance
  7979. * (equivalence with other STM32 families featuring several
  7980. * ADC instances).
  7981. * @param __ADCXY_COMMON__ ADC common instance
  7982. * (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() )
  7983. * @retval Value "0" All ADC instances sharing the same ADC common instance
  7984. * are disabled.
  7985. * Value "1" At least one ADC instance sharing the same ADC common instance
  7986. * is enabled
  7987. */
  7988. #define __LL_ADC_IS_ENABLED_ALL_COMMON_INSTANCE(__ADCXY_COMMON__) \
  7989. LL_ADC_IsEnabled(ADC1)
  7990. /**
  7991. * @brief Helper macro to define the ADC conversion data full-scale digital
  7992. * value corresponding to the selected ADC resolution.
  7993. * @note ADC conversion data full-scale corresponds to voltage range
  7994. * determined by analog voltage references Vref+ and Vref-
  7995. * (refer to reference manual).
  7996. * @param __ADC_RESOLUTION__ This parameter can be one of the following values:
  7997. * @arg @ref LL_ADC_RESOLUTION_12B
  7998. * @retval ADC conversion data equivalent voltage value (unit: mVolt)
  7999. */
  8000. #define __LL_ADC_DIGITAL_SCALE(__ADC_RESOLUTION__) \
  8001. ((uint32_t)0xFFFU)
  8002. /**
  8003. * @brief Helper macro to convert the ADC conversion data from
  8004. * a resolution to another resolution.
  8005. * @note On STM32F37x, the only ADC resolution available is 12 bits.
  8006. * This macro has been kept for compatibility purpose over other
  8007. * STM32 families.
  8008. * @param __DATA__ ADC conversion data to be converted
  8009. * @param __ADC_RESOLUTION_CURRENT__ Resolution of to the data to be converted
  8010. * This parameter can be one of the following values:
  8011. * @arg @ref LL_ADC_RESOLUTION_12B
  8012. * @param __ADC_RESOLUTION_TARGET__ Resolution of the data after conversion
  8013. * This parameter can be one of the following values:
  8014. * @arg @ref LL_ADC_RESOLUTION_12B
  8015. * @retval ADC conversion data to the requested resolution
  8016. */
  8017. #define __LL_ADC_CONVERT_DATA_RESOLUTION(__DATA__,\
  8018. __ADC_RESOLUTION_CURRENT__,\
  8019. __ADC_RESOLUTION_TARGET__) \
  8020. (((__DATA__) \
  8021. << ((__ADC_RESOLUTION_CURRENT__) >> (0U))) \
  8022. >> ((__ADC_RESOLUTION_TARGET__) >> (0U)) \
  8023. )
  8024. /**
  8025. * @brief Helper macro to calculate the voltage (unit: mVolt)
  8026. * corresponding to a ADC conversion data (unit: digital value).
  8027. * @note Analog reference voltage (Vref+) must be either known from
  8028. * user board environment or can be calculated using ADC measurement
  8029. * and ADC helper macro @ref __LL_ADC_CALC_VREFANALOG_VOLTAGE().
  8030. * @param __VREFANALOG_VOLTAGE__ Analog reference voltage (unit: mV)
  8031. * @param __ADC_DATA__ ADC conversion data (resolution 12 bits)
  8032. * (unit: digital value).
  8033. * @param __ADC_RESOLUTION__ This parameter can be one of the following values:
  8034. * @arg @ref LL_ADC_RESOLUTION_12B
  8035. * @retval ADC conversion data equivalent voltage value (unit: mVolt)
  8036. */
  8037. #define __LL_ADC_CALC_DATA_TO_VOLTAGE(__VREFANALOG_VOLTAGE__,\
  8038. __ADC_DATA__,\
  8039. __ADC_RESOLUTION__) \
  8040. ((__ADC_DATA__) * (__VREFANALOG_VOLTAGE__) \
  8041. / __LL_ADC_DIGITAL_SCALE(__ADC_RESOLUTION__) \
  8042. )
  8043. /**
  8044. * @brief Helper macro to calculate analog reference voltage (Vref+)
  8045. * (unit: mVolt) from ADC conversion data of internal voltage
  8046. * reference VrefInt.
  8047. * @note Computation is using VrefInt calibration value
  8048. * stored in system memory for each device during production.
  8049. * @note This voltage depends on user board environment: voltage level
  8050. * connected to pin Vref+.
  8051. * On devices with small package, the pin Vref+ is not present
  8052. * and internally bonded to pin Vdda.
  8053. * @note On this STM32 series, calibration data of internal voltage reference
  8054. * VrefInt corresponds to a resolution of 12 bits,
  8055. * this is the recommended ADC resolution to convert voltage of
  8056. * internal voltage reference VrefInt.
  8057. * On STM32F37x, the only ADC resolution available is 12 bits.
  8058. * The parameter of ADC resolution is kept for compatibility purpose
  8059. * over other STM32 families.
  8060. * @param __VREFINT_ADC_DATA__ ADC conversion data (resolution 12 bits)
  8061. * of internal voltage reference VrefInt (unit: digital value).
  8062. * @param __ADC_RESOLUTION__ This parameter can be one of the following values:
  8063. * @arg @ref LL_ADC_RESOLUTION_12B
  8064. * @retval Analog reference voltage (unit: mV)
  8065. */
  8066. #define __LL_ADC_CALC_VREFANALOG_VOLTAGE(__VREFINT_ADC_DATA__,\
  8067. __ADC_RESOLUTION__) \
  8068. (((uint32_t)(*VREFINT_CAL_ADDR) * VREFINT_CAL_VREF) \
  8069. / __LL_ADC_CONVERT_DATA_RESOLUTION((__VREFINT_ADC_DATA__), \
  8070. (__ADC_RESOLUTION__), \
  8071. LL_ADC_RESOLUTION_12B) \
  8072. )
  8073. /**
  8074. * @brief Helper macro to calculate the temperature (unit: degree Celsius)
  8075. * from ADC conversion data of internal temperature sensor.
  8076. * @note Computation is using temperature sensor calibration values
  8077. * stored in system memory for each device during production.
  8078. * @note Calculation formula:
  8079. * Temperature = ((TS_ADC_DATA - TS_CAL1)
  8080. * * (TS_CAL2_TEMP - TS_CAL1_TEMP))
  8081. * / (TS_CAL2 - TS_CAL1) + TS_CAL1_TEMP
  8082. * with TS_ADC_DATA = temperature sensor raw data measured by ADC
  8083. * Avg_Slope = (TS_CAL2 - TS_CAL1)
  8084. * / (TS_CAL2_TEMP - TS_CAL1_TEMP)
  8085. * TS_CAL1 = equivalent TS_ADC_DATA at temperature
  8086. * TEMP_DEGC_CAL1 (calibrated in factory)
  8087. * TS_CAL2 = equivalent TS_ADC_DATA at temperature
  8088. * TEMP_DEGC_CAL2 (calibrated in factory)
  8089. * Caution: Calculation relevancy under reserve that calibration
  8090. * parameters are correct (address and data).
  8091. * To calculate temperature using temperature sensor
  8092. * datasheet typical values (generic values less, therefore
  8093. * less accurate than calibrated values),
  8094. * use helper macro @ref __LL_ADC_CALC_TEMPERATURE_TYP_PARAMS().
  8095. * @note As calculation input, the analog reference voltage (Vref+) must be
  8096. * defined as it impacts the ADC LSB equivalent voltage.
  8097. * @note Analog reference voltage (Vref+) must be either known from
  8098. * user board environment or can be calculated using ADC measurement
  8099. * and ADC helper macro @ref __LL_ADC_CALC_VREFANALOG_VOLTAGE().
  8100. * @note On this STM32 series, calibration data of temperature sensor
  8101. * corresponds to a resolution of 12 bits,
  8102. * this is the recommended ADC resolution to convert voltage of
  8103. * temperature sensor.
  8104. * On STM32F37x, the only ADC resolution available is 12 bits.
  8105. * The parameter of ADC resolution is kept for compatibility purpose
  8106. * over other STM32 families.
  8107. * @param __VREFANALOG_VOLTAGE__ Analog reference voltage (unit: mV)
  8108. * @param __TEMPSENSOR_ADC_DATA__ ADC conversion data of internal
  8109. * temperature sensor (unit: digital value).
  8110. * @param __ADC_RESOLUTION__ ADC resolution at which internal temperature
  8111. * sensor voltage has been measured.
  8112. * This parameter can be one of the following values:
  8113. * @arg @ref LL_ADC_RESOLUTION_12B
  8114. * @retval Temperature (unit: degree Celsius)
  8115. */
  8116. #define __LL_ADC_CALC_TEMPERATURE(__VREFANALOG_VOLTAGE__,\
  8117. __TEMPSENSOR_ADC_DATA__,\
  8118. __ADC_RESOLUTION__) \
  8119. (((( ((int32_t)((__LL_ADC_CONVERT_DATA_RESOLUTION((__TEMPSENSOR_ADC_DATA__), \
  8120. (__ADC_RESOLUTION__), \
  8121. LL_ADC_RESOLUTION_12B) \
  8122. * (__VREFANALOG_VOLTAGE__)) \
  8123. / TEMPSENSOR_CAL_VREFANALOG) \
  8124. - (int32_t) *TEMPSENSOR_CAL1_ADDR) \
  8125. ) * (int32_t)(TEMPSENSOR_CAL2_TEMP - TEMPSENSOR_CAL1_TEMP) \
  8126. ) / (int32_t)((int32_t)*TEMPSENSOR_CAL2_ADDR - (int32_t)*TEMPSENSOR_CAL1_ADDR) \
  8127. ) + TEMPSENSOR_CAL1_TEMP \
  8128. )
  8129. /**
  8130. * @brief Helper macro to calculate the temperature (unit: degree Celsius)
  8131. * from ADC conversion data of internal temperature sensor.
  8132. * @note Computation is using temperature sensor typical values
  8133. * (refer to device datasheet).
  8134. * @note Calculation formula:
  8135. * Temperature = (TS_TYP_CALx_VOLT(uV) - TS_ADC_DATA * Conversion_uV)
  8136. * / Avg_Slope + CALx_TEMP
  8137. * with TS_ADC_DATA = temperature sensor raw data measured by ADC
  8138. * (unit: digital value)
  8139. * Avg_Slope = temperature sensor slope
  8140. * (unit: uV/Degree Celsius)
  8141. * TS_TYP_CALx_VOLT = temperature sensor digital value at
  8142. * temperature CALx_TEMP (unit: mV)
  8143. * Caution: Calculation relevancy under reserve the temperature sensor
  8144. * of the current device has characteristics in line with
  8145. * datasheet typical values.
  8146. * If temperature sensor calibration values are available on
  8147. * on this device (presence of macro __LL_ADC_CALC_TEMPERATURE()),
  8148. * temperature calculation will be more accurate using
  8149. * helper macro @ref __LL_ADC_CALC_TEMPERATURE().
  8150. * @note As calculation input, the analog reference voltage (Vref+) must be
  8151. * defined as it impacts the ADC LSB equivalent voltage.
  8152. * @note Analog reference voltage (Vref+) must be either known from
  8153. * user board environment or can be calculated using ADC measurement
  8154. * and ADC helper macro @ref __LL_ADC_CALC_VREFANALOG_VOLTAGE().
  8155. * @note ADC measurement data must correspond to a resolution of 12bits
  8156. * (full scale digital value 4095). If not the case, the data must be
  8157. * preliminarily rescaled to an equivalent resolution of 12 bits.
  8158. * @param __TEMPSENSOR_TYP_AVGSLOPE__ Device datasheet data: Temperature sensor slope typical value (unit: uV/DegCelsius).
  8159. * On STM32F37x, refer to device datasheet parameter "Avg_Slope".
  8160. * @param __TEMPSENSOR_TYP_CALX_V__ Device datasheet data: Temperature sensor voltage typical value (at temperature and Vref+ defined in parameters below) (unit: mV).
  8161. * On STM32F37x, refer to device datasheet parameter "V25".
  8162. * @param __TEMPSENSOR_CALX_TEMP__ Device datasheet data: Temperature at which temperature sensor voltage (see parameter above) is corresponding (unit: degC)
  8163. * @param __VREFANALOG_VOLTAGE__ Analog voltage reference (Vref+) voltage (unit: mV)
  8164. * @param __TEMPSENSOR_ADC_DATA__ ADC conversion data of internal temperature sensor (unit: digital value).
  8165. * @param __ADC_RESOLUTION__ ADC resolution at which internal temperature sensor voltage has been measured.
  8166. * This parameter can be one of the following values:
  8167. * @arg @ref LL_ADC_RESOLUTION_12B
  8168. * @retval Temperature (unit: degree Celsius)
  8169. */
  8170. #define __LL_ADC_CALC_TEMPERATURE_TYP_PARAMS(__TEMPSENSOR_TYP_AVGSLOPE__,\
  8171. __TEMPSENSOR_TYP_CALX_V__,\
  8172. __TEMPSENSOR_CALX_TEMP__,\
  8173. __VREFANALOG_VOLTAGE__,\
  8174. __TEMPSENSOR_ADC_DATA__,\
  8175. __ADC_RESOLUTION__) \
  8176. ((( ( \
  8177. (int32_t)(((__TEMPSENSOR_TYP_CALX_V__)) \
  8178. * 1000) \
  8179. - \
  8180. (int32_t)((((__TEMPSENSOR_ADC_DATA__) * (__VREFANALOG_VOLTAGE__)) \
  8181. / __LL_ADC_DIGITAL_SCALE(__ADC_RESOLUTION__)) \
  8182. * 1000) \
  8183. ) \
  8184. ) / (__TEMPSENSOR_TYP_AVGSLOPE__) \
  8185. ) + (__TEMPSENSOR_CALX_TEMP__) \
  8186. )
  8187. /**
  8188. * @}
  8189. */
  8190. /**
  8191. * @}
  8192. */
  8193. /* Exported functions --------------------------------------------------------*/
  8194. /** @defgroup ADC_LL_Exported_Functions ADC Exported Functions
  8195. * @{
  8196. */
  8197. /** @defgroup ADC_LL_EF_DMA_Management ADC DMA management
  8198. * @{
  8199. */
  8200. /* Note: LL ADC functions to set DMA transfer are located into sections of */
  8201. /* configuration of ADC instance, groups and multimode (if available): */
  8202. /* @ref LL_ADC_REG_SetDMATransfer(), ... */
  8203. /**
  8204. * @brief Function to help to configure DMA transfer from ADC: retrieve the
  8205. * ADC register address from ADC instance and a list of ADC registers
  8206. * intended to be used (most commonly) with DMA transfer.
  8207. * @note These ADC registers are data registers:
  8208. * when ADC conversion data is available in ADC data registers,
  8209. * ADC generates a DMA transfer request.
  8210. * @note This macro is intended to be used with LL DMA driver, refer to
  8211. * function "LL_DMA_ConfigAddresses()".
  8212. * Example:
  8213. * LL_DMA_ConfigAddresses(DMA1,
  8214. * LL_DMA_CHANNEL_1,
  8215. * LL_ADC_DMA_GetRegAddr(ADC1, LL_ADC_DMA_REG_REGULAR_DATA),
  8216. * (uint32_t)&< array or variable >,
  8217. * LL_DMA_DIRECTION_PERIPH_TO_MEMORY);
  8218. * @note For devices with several ADC: in multimode, some devices
  8219. * use a different data register outside of ADC instance scope
  8220. * (common data register). This macro manages this register difference,
  8221. * only ADC instance has to be set as parameter.
  8222. * @rmtoll DR DATA LL_ADC_DMA_GetRegAddr
  8223. * @param ADCx ADC instance
  8224. * @param Register This parameter can be one of the following values:
  8225. * @arg @ref LL_ADC_DMA_REG_REGULAR_DATA
  8226. * @retval ADC register address
  8227. */
  8228. __STATIC_INLINE uint32_t LL_ADC_DMA_GetRegAddr(ADC_TypeDef *ADCx, uint32_t Register)
  8229. {
  8230. /* Prevent unused argument compilation warning */
  8231. (void)Register;
  8232. /* Retrieve address of register DR */
  8233. return (uint32_t)&(ADCx->DR);
  8234. }
  8235. /**
  8236. * @}
  8237. */
  8238. /** @defgroup ADC_LL_EF_Configuration_ADC_Common Configuration of ADC hierarchical scope: common to several ADC instances
  8239. * @{
  8240. */
  8241. /**
  8242. * @brief Set parameter common to several ADC: measurement path to internal
  8243. * channels (VrefInt, temperature sensor, ...).
  8244. * @note One or several values can be selected.
  8245. * Example: (LL_ADC_PATH_INTERNAL_VREFINT |
  8246. * LL_ADC_PATH_INTERNAL_TEMPSENSOR)
  8247. * @note Stabilization time of measurement path to internal channel:
  8248. * After enabling internal paths, before starting ADC conversion,
  8249. * a delay is required for internal voltage reference and
  8250. * temperature sensor stabilization time.
  8251. * Refer to device datasheet.
  8252. * Refer to literal @ref LL_ADC_DELAY_TEMPSENSOR_STAB_US.
  8253. * @note ADC internal channel sampling time constraint:
  8254. * For ADC conversion of internal channels,
  8255. * a sampling time minimum value is required.
  8256. * Refer to device datasheet.
  8257. * @rmtoll CR2 TSVREFE LL_ADC_SetCommonPathInternalCh
  8258. * @param ADCxy_COMMON ADC common instance
  8259. * (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() )
  8260. * @param PathInternal This parameter can be a combination of the following values:
  8261. * @arg @ref LL_ADC_PATH_INTERNAL_NONE
  8262. * @arg @ref LL_ADC_PATH_INTERNAL_VREFINT
  8263. * @arg @ref LL_ADC_PATH_INTERNAL_TEMPSENSOR
  8264. * @retval None
  8265. */
  8266. __STATIC_INLINE void LL_ADC_SetCommonPathInternalCh(ADC_Common_TypeDef *ADCxy_COMMON, uint32_t PathInternal)
  8267. {
  8268. MODIFY_REG(ADCxy_COMMON->CR2, (ADC_CR2_TSVREFE), PathInternal);
  8269. }
  8270. /**
  8271. * @brief Get parameter common to several ADC: measurement path to internal
  8272. * channels (VrefInt, temperature sensor, ...).
  8273. * @note One or several values can be selected.
  8274. * Example: (LL_ADC_PATH_INTERNAL_VREFINT |
  8275. * LL_ADC_PATH_INTERNAL_TEMPSENSOR)
  8276. * @rmtoll CR2 TSVREFE LL_ADC_GetCommonPathInternalCh
  8277. * @param ADCxy_COMMON ADC common instance
  8278. * (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() )
  8279. * @retval Returned value can be a combination of the following values:
  8280. * @arg @ref LL_ADC_PATH_INTERNAL_NONE
  8281. * @arg @ref LL_ADC_PATH_INTERNAL_VREFINT
  8282. * @arg @ref LL_ADC_PATH_INTERNAL_TEMPSENSOR
  8283. */
  8284. __STATIC_INLINE uint32_t LL_ADC_GetCommonPathInternalCh(ADC_Common_TypeDef *ADCxy_COMMON)
  8285. {
  8286. return (uint32_t)(READ_BIT(ADCxy_COMMON->CR2, ADC_CR2_TSVREFE));
  8287. }
  8288. /**
  8289. * @}
  8290. */
  8291. /** @defgroup ADC_LL_EF_Configuration_ADC_Instance Configuration of ADC hierarchical scope: ADC instance
  8292. * @{
  8293. */
  8294. /**
  8295. * @brief Set ADC conversion data alignment.
  8296. * @note Refer to reference manual for alignments formats
  8297. * dependencies to ADC resolutions.
  8298. * @rmtoll CR2 ALIGN LL_ADC_SetDataAlignment
  8299. * @param ADCx ADC instance
  8300. * @param DataAlignment This parameter can be one of the following values:
  8301. * @arg @ref LL_ADC_DATA_ALIGN_RIGHT
  8302. * @arg @ref LL_ADC_DATA_ALIGN_LEFT
  8303. * @retval None
  8304. */
  8305. __STATIC_INLINE void LL_ADC_SetDataAlignment(ADC_TypeDef *ADCx, uint32_t DataAlignment)
  8306. {
  8307. MODIFY_REG(ADCx->CR2, ADC_CR2_ALIGN, DataAlignment);
  8308. }
  8309. /**
  8310. * @brief Get ADC conversion data alignment.
  8311. * @note Refer to reference manual for alignments formats
  8312. * dependencies to ADC resolutions.
  8313. * @rmtoll CR2 ALIGN LL_ADC_SetDataAlignment
  8314. * @param ADCx ADC instance
  8315. * @retval Returned value can be one of the following values:
  8316. * @arg @ref LL_ADC_DATA_ALIGN_RIGHT
  8317. * @arg @ref LL_ADC_DATA_ALIGN_LEFT
  8318. */
  8319. __STATIC_INLINE uint32_t LL_ADC_GetDataAlignment(ADC_TypeDef *ADCx)
  8320. {
  8321. return (uint32_t)(READ_BIT(ADCx->CR2, ADC_CR2_ALIGN));
  8322. }
  8323. /**
  8324. * @brief Set ADC sequencers scan mode, for all ADC groups
  8325. * (group regular, group injected).
  8326. * @note According to sequencers scan mode :
  8327. * - If disabled: ADC conversion is performed in unitary conversion
  8328. * mode (one channel converted, that defined in rank 1).
  8329. * Configuration of sequencers of all ADC groups
  8330. * (sequencer scan length, ...) is discarded: equivalent to
  8331. * scan length of 1 rank.
  8332. * - If enabled: ADC conversions are performed in sequence conversions
  8333. * mode, according to configuration of sequencers of
  8334. * each ADC group (sequencer scan length, ...).
  8335. * Refer to function @ref LL_ADC_REG_SetSequencerLength()
  8336. * and to function @ref LL_ADC_INJ_SetSequencerLength().
  8337. * @rmtoll CR1 SCAN LL_ADC_SetSequencersScanMode
  8338. * @param ADCx ADC instance
  8339. * @param ScanMode This parameter can be one of the following values:
  8340. * @arg @ref LL_ADC_SEQ_SCAN_DISABLE
  8341. * @arg @ref LL_ADC_SEQ_SCAN_ENABLE
  8342. * @retval None
  8343. */
  8344. __STATIC_INLINE void LL_ADC_SetSequencersScanMode(ADC_TypeDef *ADCx, uint32_t ScanMode)
  8345. {
  8346. MODIFY_REG(ADCx->CR1, ADC_CR1_SCAN, ScanMode);
  8347. }
  8348. /**
  8349. * @brief Get ADC sequencers scan mode, for all ADC groups
  8350. * (group regular, group injected).
  8351. * @note According to sequencers scan mode :
  8352. * - If disabled: ADC conversion is performed in unitary conversion
  8353. * mode (one channel converted, that defined in rank 1).
  8354. * Configuration of sequencers of all ADC groups
  8355. * (sequencer scan length, ...) is discarded: equivalent to
  8356. * scan length of 1 rank.
  8357. * - If enabled: ADC conversions are performed in sequence conversions
  8358. * mode, according to configuration of sequencers of
  8359. * each ADC group (sequencer scan length, ...).
  8360. * Refer to function @ref LL_ADC_REG_SetSequencerLength()
  8361. * and to function @ref LL_ADC_INJ_SetSequencerLength().
  8362. * @rmtoll CR1 SCAN LL_ADC_GetSequencersScanMode
  8363. * @param ADCx ADC instance
  8364. * @retval Returned value can be one of the following values:
  8365. * @arg @ref LL_ADC_SEQ_SCAN_DISABLE
  8366. * @arg @ref LL_ADC_SEQ_SCAN_ENABLE
  8367. */
  8368. __STATIC_INLINE uint32_t LL_ADC_GetSequencersScanMode(ADC_TypeDef *ADCx)
  8369. {
  8370. return (uint32_t)(READ_BIT(ADCx->CR1, ADC_CR1_SCAN));
  8371. }
  8372. /**
  8373. * @}
  8374. */
  8375. /** @defgroup ADC_LL_EF_Configuration_ADC_Group_Regular Configuration of ADC hierarchical scope: group regular
  8376. * @{
  8377. */
  8378. /**
  8379. * @brief Set ADC group regular conversion trigger source:
  8380. * internal (SW start) or external from timer or external interrupt.
  8381. * @note On this STM32 series, external trigger is set with trigger polarity:
  8382. * rising edge (only trigger polarity available on this STM32 series).
  8383. * @note Availability of parameters of trigger sources from timer
  8384. * depends on timers availability on the selected device.
  8385. * @rmtoll CR2 EXTSEL LL_ADC_REG_SetTriggerSource
  8386. * @param ADCx ADC instance
  8387. * @param TriggerSource This parameter can be one of the following values:
  8388. * @arg @ref LL_ADC_REG_TRIG_SOFTWARE
  8389. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM2_CH2
  8390. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM3_TRGO
  8391. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM4_CH2
  8392. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM19_TRGO
  8393. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM19_CH3
  8394. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM19_CH4
  8395. * @arg @ref LL_ADC_REG_TRIG_EXT_EXTI_LINE11
  8396. * @retval None
  8397. */
  8398. __STATIC_INLINE void LL_ADC_REG_SetTriggerSource(ADC_TypeDef *ADCx, uint32_t TriggerSource)
  8399. {
  8400. /* Note: On this STM32 series, ADC group regular external trigger edge */
  8401. /* is used to perform a ADC conversion start. */
  8402. /* This function does not set external trigger edge. */
  8403. /* This feature is set using function */
  8404. /* @ref LL_ADC_REG_StartConversionExtTrig(). */
  8405. MODIFY_REG(ADCx->CR2, ADC_CR2_EXTSEL, (TriggerSource & ADC_CR2_EXTSEL));
  8406. }
  8407. /**
  8408. * @brief Get ADC group regular conversion trigger source:
  8409. * internal (SW start) or external from timer or external interrupt.
  8410. * @note To determine whether group regular trigger source is
  8411. * internal (SW start) or external, without detail
  8412. * of which peripheral is selected as external trigger,
  8413. * (equivalent to
  8414. * "if(LL_ADC_REG_GetTriggerSource(ADC1) == LL_ADC_REG_TRIG_SOFTWARE)")
  8415. * use function @ref LL_ADC_REG_IsTriggerSourceSWStart.
  8416. * @note Availability of parameters of trigger sources from timer
  8417. * depends on timers availability on the selected device.
  8418. * @rmtoll CR2 EXTSEL LL_ADC_REG_GetTriggerSource
  8419. * @param ADCx ADC instance
  8420. * @retval Returned value can be one of the following values:
  8421. * @arg @ref LL_ADC_REG_TRIG_SOFTWARE
  8422. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM2_CH2
  8423. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM3_TRGO
  8424. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM4_CH2
  8425. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM19_TRGO
  8426. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM19_CH3
  8427. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM19_CH4
  8428. * @arg @ref LL_ADC_REG_TRIG_EXT_EXTI_LINE11
  8429. */
  8430. __STATIC_INLINE uint32_t LL_ADC_REG_GetTriggerSource(ADC_TypeDef *ADCx)
  8431. {
  8432. return (uint32_t)(READ_BIT(ADCx->CR2, ADC_CR2_EXTSEL));
  8433. }
  8434. /**
  8435. * @brief Get ADC group regular conversion trigger source internal (SW start)
  8436. or external.
  8437. * @note In case of group regular trigger source set to external trigger,
  8438. * to determine which peripheral is selected as external trigger,
  8439. * use function @ref LL_ADC_REG_GetTriggerSource().
  8440. * @rmtoll CR2 EXTSEL LL_ADC_REG_IsTriggerSourceSWStart
  8441. * @param ADCx ADC instance
  8442. * @retval Value "0" trigger source external trigger
  8443. * Value "1" trigger source SW start.
  8444. */
  8445. __STATIC_INLINE uint32_t LL_ADC_REG_IsTriggerSourceSWStart(ADC_TypeDef *ADCx)
  8446. {
  8447. return (READ_BIT(ADCx->CR2, ADC_CR2_EXTSEL) == (LL_ADC_REG_TRIG_SOFTWARE));
  8448. }
  8449. /**
  8450. * @brief Set ADC group regular sequencer length and scan direction.
  8451. * @note Description of ADC group regular sequencer features:
  8452. * - For devices with sequencer fully configurable
  8453. * (function "LL_ADC_REG_SetSequencerRanks()" available):
  8454. * sequencer length and each rank affectation to a channel
  8455. * are configurable.
  8456. * This function performs configuration of:
  8457. * - Sequence length: Number of ranks in the scan sequence.
  8458. * - Sequence direction: Unless specified in parameters, sequencer
  8459. * scan direction is forward (from rank 1 to rank n).
  8460. * Sequencer ranks are selected using
  8461. * function "LL_ADC_REG_SetSequencerRanks()".
  8462. * - For devices with sequencer not fully configurable
  8463. * (function "LL_ADC_REG_SetSequencerChannels()" available):
  8464. * sequencer length and each rank affectation to a channel
  8465. * are defined by channel number.
  8466. * This function performs configuration of:
  8467. * - Sequence length: Number of ranks in the scan sequence is
  8468. * defined by number of channels set in the sequence,
  8469. * rank of each channel is fixed by channel HW number.
  8470. * (channel 0 fixed on rank 0, channel 1 fixed on rank1, ...).
  8471. * - Sequence direction: Unless specified in parameters, sequencer
  8472. * scan direction is forward (from lowest channel number to
  8473. * highest channel number).
  8474. * Sequencer ranks are selected using
  8475. * function "LL_ADC_REG_SetSequencerChannels()".
  8476. * @note On this STM32 series, group regular sequencer configuration
  8477. * is conditioned to ADC instance sequencer mode.
  8478. * If ADC instance sequencer mode is disabled, sequencers of
  8479. * all groups (group regular, group injected) can be configured
  8480. * but their execution is disabled (limited to rank 1).
  8481. * Refer to function @ref LL_ADC_SetSequencersScanMode().
  8482. * @note Sequencer disabled is equivalent to sequencer of 1 rank:
  8483. * ADC conversion on only 1 channel.
  8484. * @rmtoll SQR1 L LL_ADC_REG_SetSequencerLength
  8485. * @param ADCx ADC instance
  8486. * @param SequencerNbRanks This parameter can be one of the following values:
  8487. * @arg @ref LL_ADC_REG_SEQ_SCAN_DISABLE
  8488. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_2RANKS
  8489. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_3RANKS
  8490. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_4RANKS
  8491. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_5RANKS
  8492. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_6RANKS
  8493. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_7RANKS
  8494. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_8RANKS
  8495. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_9RANKS
  8496. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_10RANKS
  8497. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_11RANKS
  8498. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_12RANKS
  8499. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_13RANKS
  8500. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_14RANKS
  8501. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_15RANKS
  8502. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_16RANKS
  8503. * @retval None
  8504. */
  8505. __STATIC_INLINE void LL_ADC_REG_SetSequencerLength(ADC_TypeDef *ADCx, uint32_t SequencerNbRanks)
  8506. {
  8507. MODIFY_REG(ADCx->SQR1, ADC_SQR1_L, SequencerNbRanks);
  8508. }
  8509. /**
  8510. * @brief Get ADC group regular sequencer length and scan direction.
  8511. * @note Description of ADC group regular sequencer features:
  8512. * - For devices with sequencer fully configurable
  8513. * (function "LL_ADC_REG_SetSequencerRanks()" available):
  8514. * sequencer length and each rank affectation to a channel
  8515. * are configurable.
  8516. * This function retrieves:
  8517. * - Sequence length: Number of ranks in the scan sequence.
  8518. * - Sequence direction: Unless specified in parameters, sequencer
  8519. * scan direction is forward (from rank 1 to rank n).
  8520. * Sequencer ranks are selected using
  8521. * function "LL_ADC_REG_SetSequencerRanks()".
  8522. * - For devices with sequencer not fully configurable
  8523. * (function "LL_ADC_REG_SetSequencerChannels()" available):
  8524. * sequencer length and each rank affectation to a channel
  8525. * are defined by channel number.
  8526. * This function retrieves:
  8527. * - Sequence length: Number of ranks in the scan sequence is
  8528. * defined by number of channels set in the sequence,
  8529. * rank of each channel is fixed by channel HW number.
  8530. * (channel 0 fixed on rank 0, channel 1 fixed on rank1, ...).
  8531. * - Sequence direction: Unless specified in parameters, sequencer
  8532. * scan direction is forward (from lowest channel number to
  8533. * highest channel number).
  8534. * Sequencer ranks are selected using
  8535. * function "LL_ADC_REG_SetSequencerChannels()".
  8536. * @note On this STM32 series, group regular sequencer configuration
  8537. * is conditioned to ADC instance sequencer mode.
  8538. * If ADC instance sequencer mode is disabled, sequencers of
  8539. * all groups (group regular, group injected) can be configured
  8540. * but their execution is disabled (limited to rank 1).
  8541. * Refer to function @ref LL_ADC_SetSequencersScanMode().
  8542. * @note Sequencer disabled is equivalent to sequencer of 1 rank:
  8543. * ADC conversion on only 1 channel.
  8544. * @rmtoll SQR1 L LL_ADC_REG_SetSequencerLength
  8545. * @param ADCx ADC instance
  8546. * @retval Returned value can be one of the following values:
  8547. * @arg @ref LL_ADC_REG_SEQ_SCAN_DISABLE
  8548. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_2RANKS
  8549. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_3RANKS
  8550. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_4RANKS
  8551. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_5RANKS
  8552. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_6RANKS
  8553. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_7RANKS
  8554. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_8RANKS
  8555. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_9RANKS
  8556. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_10RANKS
  8557. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_11RANKS
  8558. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_12RANKS
  8559. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_13RANKS
  8560. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_14RANKS
  8561. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_15RANKS
  8562. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_16RANKS
  8563. */
  8564. __STATIC_INLINE uint32_t LL_ADC_REG_GetSequencerLength(ADC_TypeDef *ADCx)
  8565. {
  8566. return (uint32_t)(READ_BIT(ADCx->SQR1, ADC_SQR1_L));
  8567. }
  8568. /**
  8569. * @brief Set ADC group regular sequencer discontinuous mode:
  8570. * sequence subdivided and scan conversions interrupted every selected
  8571. * number of ranks.
  8572. * @note It is not possible to enable both ADC group regular
  8573. * continuous mode and sequencer discontinuous mode.
  8574. * @note It is not possible to enable both ADC auto-injected mode
  8575. * and ADC group regular sequencer discontinuous mode.
  8576. * @rmtoll CR1 DISCEN LL_ADC_REG_SetSequencerDiscont\n
  8577. * CR1 DISCNUM LL_ADC_REG_SetSequencerDiscont
  8578. * @param ADCx ADC instance
  8579. * @param SeqDiscont This parameter can be one of the following values:
  8580. * @arg @ref LL_ADC_REG_SEQ_DISCONT_DISABLE
  8581. * @arg @ref LL_ADC_REG_SEQ_DISCONT_1RANK
  8582. * @arg @ref LL_ADC_REG_SEQ_DISCONT_2RANKS
  8583. * @arg @ref LL_ADC_REG_SEQ_DISCONT_3RANKS
  8584. * @arg @ref LL_ADC_REG_SEQ_DISCONT_4RANKS
  8585. * @arg @ref LL_ADC_REG_SEQ_DISCONT_5RANKS
  8586. * @arg @ref LL_ADC_REG_SEQ_DISCONT_6RANKS
  8587. * @arg @ref LL_ADC_REG_SEQ_DISCONT_7RANKS
  8588. * @arg @ref LL_ADC_REG_SEQ_DISCONT_8RANKS
  8589. * @retval None
  8590. */
  8591. __STATIC_INLINE void LL_ADC_REG_SetSequencerDiscont(ADC_TypeDef *ADCx, uint32_t SeqDiscont)
  8592. {
  8593. MODIFY_REG(ADCx->CR1, ADC_CR1_DISCEN | ADC_CR1_DISCNUM, SeqDiscont);
  8594. }
  8595. /**
  8596. * @brief Get ADC group regular sequencer discontinuous mode:
  8597. * sequence subdivided and scan conversions interrupted every selected
  8598. * number of ranks.
  8599. * @rmtoll CR1 DISCEN LL_ADC_REG_GetSequencerDiscont\n
  8600. * CR1 DISCNUM LL_ADC_REG_GetSequencerDiscont
  8601. * @param ADCx ADC instance
  8602. * @retval Returned value can be one of the following values:
  8603. * @arg @ref LL_ADC_REG_SEQ_DISCONT_DISABLE
  8604. * @arg @ref LL_ADC_REG_SEQ_DISCONT_1RANK
  8605. * @arg @ref LL_ADC_REG_SEQ_DISCONT_2RANKS
  8606. * @arg @ref LL_ADC_REG_SEQ_DISCONT_3RANKS
  8607. * @arg @ref LL_ADC_REG_SEQ_DISCONT_4RANKS
  8608. * @arg @ref LL_ADC_REG_SEQ_DISCONT_5RANKS
  8609. * @arg @ref LL_ADC_REG_SEQ_DISCONT_6RANKS
  8610. * @arg @ref LL_ADC_REG_SEQ_DISCONT_7RANKS
  8611. * @arg @ref LL_ADC_REG_SEQ_DISCONT_8RANKS
  8612. */
  8613. __STATIC_INLINE uint32_t LL_ADC_REG_GetSequencerDiscont(ADC_TypeDef *ADCx)
  8614. {
  8615. return (uint32_t)(READ_BIT(ADCx->CR1, ADC_CR1_DISCEN | ADC_CR1_DISCNUM));
  8616. }
  8617. /**
  8618. * @brief Set ADC group regular sequence: channel on the selected
  8619. * scan sequence rank.
  8620. * @note This function performs configuration of:
  8621. * - Channels ordering into each rank of scan sequence:
  8622. * whatever channel can be placed into whatever rank.
  8623. * @note On this STM32 series, ADC group regular sequencer is
  8624. * fully configurable: sequencer length and each rank
  8625. * affectation to a channel are configurable.
  8626. * Refer to description of function @ref LL_ADC_REG_SetSequencerLength().
  8627. * @note Depending on devices and packages, some channels may not be available.
  8628. * Refer to device datasheet for channels availability.
  8629. * @note On this STM32 series, to measure internal channels (VrefInt,
  8630. * TempSensor, ...), measurement paths to internal channels must be
  8631. * enabled separately.
  8632. * This can be done using function @ref LL_ADC_SetCommonPathInternalCh().
  8633. * @rmtoll SQR3 SQ1 LL_ADC_REG_SetSequencerRanks\n
  8634. * SQR3 SQ2 LL_ADC_REG_SetSequencerRanks\n
  8635. * SQR3 SQ3 LL_ADC_REG_SetSequencerRanks\n
  8636. * SQR3 SQ4 LL_ADC_REG_SetSequencerRanks\n
  8637. * SQR3 SQ5 LL_ADC_REG_SetSequencerRanks\n
  8638. * SQR3 SQ6 LL_ADC_REG_SetSequencerRanks\n
  8639. * SQR2 SQ7 LL_ADC_REG_SetSequencerRanks\n
  8640. * SQR2 SQ8 LL_ADC_REG_SetSequencerRanks\n
  8641. * SQR2 SQ9 LL_ADC_REG_SetSequencerRanks\n
  8642. * SQR2 SQ10 LL_ADC_REG_SetSequencerRanks\n
  8643. * SQR2 SQ11 LL_ADC_REG_SetSequencerRanks\n
  8644. * SQR2 SQ12 LL_ADC_REG_SetSequencerRanks\n
  8645. * SQR1 SQ13 LL_ADC_REG_SetSequencerRanks\n
  8646. * SQR1 SQ14 LL_ADC_REG_SetSequencerRanks\n
  8647. * SQR1 SQ15 LL_ADC_REG_SetSequencerRanks\n
  8648. * SQR1 SQ16 LL_ADC_REG_SetSequencerRanks
  8649. * @param ADCx ADC instance
  8650. * @param Rank This parameter can be one of the following values:
  8651. * @arg @ref LL_ADC_REG_RANK_1
  8652. * @arg @ref LL_ADC_REG_RANK_2
  8653. * @arg @ref LL_ADC_REG_RANK_3
  8654. * @arg @ref LL_ADC_REG_RANK_4
  8655. * @arg @ref LL_ADC_REG_RANK_5
  8656. * @arg @ref LL_ADC_REG_RANK_6
  8657. * @arg @ref LL_ADC_REG_RANK_7
  8658. * @arg @ref LL_ADC_REG_RANK_8
  8659. * @arg @ref LL_ADC_REG_RANK_9
  8660. * @arg @ref LL_ADC_REG_RANK_10
  8661. * @arg @ref LL_ADC_REG_RANK_11
  8662. * @arg @ref LL_ADC_REG_RANK_12
  8663. * @arg @ref LL_ADC_REG_RANK_13
  8664. * @arg @ref LL_ADC_REG_RANK_14
  8665. * @arg @ref LL_ADC_REG_RANK_15
  8666. * @arg @ref LL_ADC_REG_RANK_16
  8667. * @param Channel This parameter can be one of the following values:
  8668. * @arg @ref LL_ADC_CHANNEL_0
  8669. * @arg @ref LL_ADC_CHANNEL_1
  8670. * @arg @ref LL_ADC_CHANNEL_2
  8671. * @arg @ref LL_ADC_CHANNEL_3
  8672. * @arg @ref LL_ADC_CHANNEL_4
  8673. * @arg @ref LL_ADC_CHANNEL_5
  8674. * @arg @ref LL_ADC_CHANNEL_6
  8675. * @arg @ref LL_ADC_CHANNEL_7
  8676. * @arg @ref LL_ADC_CHANNEL_8
  8677. * @arg @ref LL_ADC_CHANNEL_9
  8678. * @arg @ref LL_ADC_CHANNEL_10
  8679. * @arg @ref LL_ADC_CHANNEL_11
  8680. * @arg @ref LL_ADC_CHANNEL_12
  8681. * @arg @ref LL_ADC_CHANNEL_13
  8682. * @arg @ref LL_ADC_CHANNEL_14
  8683. * @arg @ref LL_ADC_CHANNEL_15
  8684. * @arg @ref LL_ADC_CHANNEL_16
  8685. * @arg @ref LL_ADC_CHANNEL_17
  8686. * @arg @ref LL_ADC_CHANNEL_VREFINT (1)
  8687. * @arg @ref LL_ADC_CHANNEL_TEMPSENSOR (1)
  8688. *
  8689. * (1) On STM32F37x, parameter available only on ADC instance: ADC1.
  8690. * @retval None
  8691. */
  8692. __STATIC_INLINE void LL_ADC_REG_SetSequencerRanks(ADC_TypeDef *ADCx, uint32_t Rank, uint32_t Channel)
  8693. {
  8694. /* Set bits with content of parameter "Channel" with bits position */
  8695. /* in register and register position depending on parameter "Rank". */
  8696. /* Parameters "Rank" and "Channel" are used with masks because containing */
  8697. /* other bits reserved for other purpose. */
  8698. __IO uint32_t *preg = __ADC_PTR_REG_OFFSET(ADCx->SQR1, __ADC_MASK_SHIFT(Rank, ADC_REG_SQRX_REGOFFSET_MASK));
  8699. MODIFY_REG(*preg,
  8700. ADC_CHANNEL_ID_NUMBER_MASK << (Rank & ADC_REG_RANK_ID_SQRX_MASK),
  8701. (Channel & ADC_CHANNEL_ID_NUMBER_MASK) << (Rank & ADC_REG_RANK_ID_SQRX_MASK));
  8702. }
  8703. /**
  8704. * @brief Get ADC group regular sequence: channel on the selected
  8705. * scan sequence rank.
  8706. * @note On this STM32 series, ADC group regular sequencer is
  8707. * fully configurable: sequencer length and each rank
  8708. * affectation to a channel are configurable.
  8709. * Refer to description of function @ref LL_ADC_REG_SetSequencerLength().
  8710. * @note Depending on devices and packages, some channels may not be available.
  8711. * Refer to device datasheet for channels availability.
  8712. * @note Usage of the returned channel number:
  8713. * - To reinject this channel into another function LL_ADC_xxx:
  8714. * the returned channel number is only partly formatted on definition
  8715. * of literals LL_ADC_CHANNEL_x. Therefore, it has to be compared
  8716. * with parts of literals LL_ADC_CHANNEL_x or using
  8717. * helper macro @ref __LL_ADC_CHANNEL_TO_DECIMAL_NB().
  8718. * Then the selected literal LL_ADC_CHANNEL_x can be used
  8719. * as parameter for another function.
  8720. * - To get the channel number in decimal format:
  8721. * process the returned value with the helper macro
  8722. * @ref __LL_ADC_CHANNEL_TO_DECIMAL_NB().
  8723. * @rmtoll SQR3 SQ1 LL_ADC_REG_GetSequencerRanks\n
  8724. * SQR3 SQ2 LL_ADC_REG_GetSequencerRanks\n
  8725. * SQR3 SQ3 LL_ADC_REG_GetSequencerRanks\n
  8726. * SQR3 SQ4 LL_ADC_REG_GetSequencerRanks\n
  8727. * SQR3 SQ5 LL_ADC_REG_GetSequencerRanks\n
  8728. * SQR3 SQ6 LL_ADC_REG_GetSequencerRanks\n
  8729. * SQR2 SQ7 LL_ADC_REG_GetSequencerRanks\n
  8730. * SQR2 SQ8 LL_ADC_REG_GetSequencerRanks\n
  8731. * SQR2 SQ9 LL_ADC_REG_GetSequencerRanks\n
  8732. * SQR2 SQ10 LL_ADC_REG_GetSequencerRanks\n
  8733. * SQR2 SQ11 LL_ADC_REG_GetSequencerRanks\n
  8734. * SQR2 SQ12 LL_ADC_REG_GetSequencerRanks\n
  8735. * SQR1 SQ13 LL_ADC_REG_GetSequencerRanks\n
  8736. * SQR1 SQ14 LL_ADC_REG_GetSequencerRanks\n
  8737. * SQR1 SQ15 LL_ADC_REG_GetSequencerRanks\n
  8738. * SQR1 SQ16 LL_ADC_REG_GetSequencerRanks
  8739. * @param ADCx ADC instance
  8740. * @param Rank This parameter can be one of the following values:
  8741. * @arg @ref LL_ADC_REG_RANK_1
  8742. * @arg @ref LL_ADC_REG_RANK_2
  8743. * @arg @ref LL_ADC_REG_RANK_3
  8744. * @arg @ref LL_ADC_REG_RANK_4
  8745. * @arg @ref LL_ADC_REG_RANK_5
  8746. * @arg @ref LL_ADC_REG_RANK_6
  8747. * @arg @ref LL_ADC_REG_RANK_7
  8748. * @arg @ref LL_ADC_REG_RANK_8
  8749. * @arg @ref LL_ADC_REG_RANK_9
  8750. * @arg @ref LL_ADC_REG_RANK_10
  8751. * @arg @ref LL_ADC_REG_RANK_11
  8752. * @arg @ref LL_ADC_REG_RANK_12
  8753. * @arg @ref LL_ADC_REG_RANK_13
  8754. * @arg @ref LL_ADC_REG_RANK_14
  8755. * @arg @ref LL_ADC_REG_RANK_15
  8756. * @arg @ref LL_ADC_REG_RANK_16
  8757. * @retval Returned value can be one of the following values:
  8758. * @arg @ref LL_ADC_CHANNEL_0
  8759. * @arg @ref LL_ADC_CHANNEL_1
  8760. * @arg @ref LL_ADC_CHANNEL_2
  8761. * @arg @ref LL_ADC_CHANNEL_3
  8762. * @arg @ref LL_ADC_CHANNEL_4
  8763. * @arg @ref LL_ADC_CHANNEL_5
  8764. * @arg @ref LL_ADC_CHANNEL_6
  8765. * @arg @ref LL_ADC_CHANNEL_7
  8766. * @arg @ref LL_ADC_CHANNEL_8
  8767. * @arg @ref LL_ADC_CHANNEL_9
  8768. * @arg @ref LL_ADC_CHANNEL_10
  8769. * @arg @ref LL_ADC_CHANNEL_11
  8770. * @arg @ref LL_ADC_CHANNEL_12
  8771. * @arg @ref LL_ADC_CHANNEL_13
  8772. * @arg @ref LL_ADC_CHANNEL_14
  8773. * @arg @ref LL_ADC_CHANNEL_15
  8774. * @arg @ref LL_ADC_CHANNEL_16
  8775. * @arg @ref LL_ADC_CHANNEL_17
  8776. * @arg @ref LL_ADC_CHANNEL_VREFINT (1)
  8777. * @arg @ref LL_ADC_CHANNEL_TEMPSENSOR (1)
  8778. *
  8779. * (1) On STM32F37x, parameter available only on ADC instance: ADC1.\n
  8780. * (1) For ADC channel read back from ADC register,
  8781. * comparison with internal channel parameter to be done
  8782. * using helper macro @ref __LL_ADC_CHANNEL_INTERNAL_TO_EXTERNAL().
  8783. */
  8784. __STATIC_INLINE uint32_t LL_ADC_REG_GetSequencerRanks(ADC_TypeDef *ADCx, uint32_t Rank)
  8785. {
  8786. __IO uint32_t *preg = __ADC_PTR_REG_OFFSET(ADCx->SQR1, __ADC_MASK_SHIFT(Rank, ADC_REG_SQRX_REGOFFSET_MASK));
  8787. return (uint32_t) (READ_BIT(*preg,
  8788. ADC_CHANNEL_ID_NUMBER_MASK << (Rank & ADC_REG_RANK_ID_SQRX_MASK))
  8789. >> (Rank & ADC_REG_RANK_ID_SQRX_MASK)
  8790. );
  8791. }
  8792. /**
  8793. * @brief Set ADC continuous conversion mode on ADC group regular.
  8794. * @note Description of ADC continuous conversion mode:
  8795. * - single mode: one conversion per trigger
  8796. * - continuous mode: after the first trigger, following
  8797. * conversions launched successively automatically.
  8798. * @note It is not possible to enable both ADC group regular
  8799. * continuous mode and sequencer discontinuous mode.
  8800. * @rmtoll CR2 CONT LL_ADC_REG_SetContinuousMode
  8801. * @param ADCx ADC instance
  8802. * @param Continuous This parameter can be one of the following values:
  8803. * @arg @ref LL_ADC_REG_CONV_SINGLE
  8804. * @arg @ref LL_ADC_REG_CONV_CONTINUOUS
  8805. * @retval None
  8806. */
  8807. __STATIC_INLINE void LL_ADC_REG_SetContinuousMode(ADC_TypeDef *ADCx, uint32_t Continuous)
  8808. {
  8809. MODIFY_REG(ADCx->CR2, ADC_CR2_CONT, Continuous);
  8810. }
  8811. /**
  8812. * @brief Get ADC continuous conversion mode on ADC group regular.
  8813. * @note Description of ADC continuous conversion mode:
  8814. * - single mode: one conversion per trigger
  8815. * - continuous mode: after the first trigger, following
  8816. * conversions launched successively automatically.
  8817. * @rmtoll CR2 CONT LL_ADC_REG_GetContinuousMode
  8818. * @param ADCx ADC instance
  8819. * @retval Returned value can be one of the following values:
  8820. * @arg @ref LL_ADC_REG_CONV_SINGLE
  8821. * @arg @ref LL_ADC_REG_CONV_CONTINUOUS
  8822. */
  8823. __STATIC_INLINE uint32_t LL_ADC_REG_GetContinuousMode(ADC_TypeDef *ADCx)
  8824. {
  8825. return (uint32_t)(READ_BIT(ADCx->CR2, ADC_CR2_CONT));
  8826. }
  8827. /**
  8828. * @brief Set ADC group regular conversion data transfer: no transfer or
  8829. * transfer by DMA, and DMA requests mode.
  8830. * @note If transfer by DMA selected, specifies the DMA requests
  8831. * mode:
  8832. * - Limited mode (One shot mode): DMA transfer requests are stopped
  8833. * when number of DMA data transfers (number of
  8834. * ADC conversions) is reached.
  8835. * This ADC mode is intended to be used with DMA mode non-circular.
  8836. * - Unlimited mode: DMA transfer requests are unlimited,
  8837. * whatever number of DMA data transfers (number of
  8838. * ADC conversions).
  8839. * This ADC mode is intended to be used with DMA mode circular.
  8840. * @note If ADC DMA requests mode is set to unlimited and DMA is set to
  8841. * mode non-circular:
  8842. * when DMA transfers size will be reached, DMA will stop transfers of
  8843. * ADC conversions data ADC will raise an overrun error
  8844. * (overrun flag and interruption if enabled).
  8845. * @note To configure DMA source address (peripheral address),
  8846. * use function @ref LL_ADC_DMA_GetRegAddr().
  8847. * @rmtoll CR2 DMA LL_ADC_REG_SetDMATransfer
  8848. * @param ADCx ADC instance
  8849. * @param DMATransfer This parameter can be one of the following values:
  8850. * @arg @ref LL_ADC_REG_DMA_TRANSFER_NONE
  8851. * @arg @ref LL_ADC_REG_DMA_TRANSFER_UNLIMITED
  8852. * @retval None
  8853. */
  8854. __STATIC_INLINE void LL_ADC_REG_SetDMATransfer(ADC_TypeDef *ADCx, uint32_t DMATransfer)
  8855. {
  8856. MODIFY_REG(ADCx->CR2, ADC_CR2_DMA, DMATransfer);
  8857. }
  8858. /**
  8859. * @brief Get ADC group regular conversion data transfer: no transfer or
  8860. * transfer by DMA, and DMA requests mode.
  8861. * @note If transfer by DMA selected, specifies the DMA requests
  8862. * mode:
  8863. * - Limited mode (One shot mode): DMA transfer requests are stopped
  8864. * when number of DMA data transfers (number of
  8865. * ADC conversions) is reached.
  8866. * This ADC mode is intended to be used with DMA mode non-circular.
  8867. * - Unlimited mode: DMA transfer requests are unlimited,
  8868. * whatever number of DMA data transfers (number of
  8869. * ADC conversions).
  8870. * This ADC mode is intended to be used with DMA mode circular.
  8871. * @note If ADC DMA requests mode is set to unlimited and DMA is set to
  8872. * mode non-circular:
  8873. * when DMA transfers size will be reached, DMA will stop transfers of
  8874. * ADC conversions data ADC will raise an overrun error
  8875. * (overrun flag and interruption if enabled).
  8876. * @note To configure DMA source address (peripheral address),
  8877. * use function @ref LL_ADC_DMA_GetRegAddr().
  8878. * @rmtoll CR2 DMA LL_ADC_REG_GetDMATransfer
  8879. * @param ADCx ADC instance
  8880. * @retval Returned value can be one of the following values:
  8881. * @arg @ref LL_ADC_REG_DMA_TRANSFER_NONE
  8882. * @arg @ref LL_ADC_REG_DMA_TRANSFER_UNLIMITED
  8883. */
  8884. __STATIC_INLINE uint32_t LL_ADC_REG_GetDMATransfer(ADC_TypeDef *ADCx)
  8885. {
  8886. return (uint32_t)(READ_BIT(ADCx->CR2, ADC_CR2_DMA));
  8887. }
  8888. /**
  8889. * @}
  8890. */
  8891. /** @defgroup ADC_LL_EF_Configuration_ADC_Group_Injected Configuration of ADC hierarchical scope: group injected
  8892. * @{
  8893. */
  8894. /**
  8895. * @brief Set ADC group injected conversion trigger source:
  8896. * internal (SW start) or external from timer or external interrupt.
  8897. * @note On this STM32 series, external trigger is set with trigger polarity:
  8898. * rising edge (only trigger polarity available on this STM32 series).
  8899. * @note Availability of parameters of trigger sources from timer
  8900. * depends on timers availability on the selected device.
  8901. * @rmtoll CR2 JEXTSEL LL_ADC_INJ_SetTriggerSource
  8902. * @param ADCx ADC instance
  8903. * @param TriggerSource This parameter can be one of the following values:
  8904. * @arg @ref LL_ADC_INJ_TRIG_SOFTWARE
  8905. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM2_TRGO
  8906. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM2_CH1
  8907. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM3_CH4
  8908. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM4_TRGO
  8909. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM19_CH1
  8910. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM19_CH2
  8911. * @arg @ref LL_ADC_INJ_TRIG_EXT_EXTI_LINE15
  8912. * @retval None
  8913. */
  8914. __STATIC_INLINE void LL_ADC_INJ_SetTriggerSource(ADC_TypeDef *ADCx, uint32_t TriggerSource)
  8915. {
  8916. /* Note: On this STM32 series, ADC group injected external trigger edge */
  8917. /* is used to perform a ADC conversion start. */
  8918. /* This function does not set external trigger edge. */
  8919. /* This feature is set using function */
  8920. /* @ref LL_ADC_INJ_StartConversionExtTrig(). */
  8921. MODIFY_REG(ADCx->CR2, ADC_CR2_JEXTSEL, (TriggerSource & ADC_CR2_JEXTSEL));
  8922. }
  8923. /**
  8924. * @brief Get ADC group injected conversion trigger source:
  8925. * internal (SW start) or external from timer or external interrupt.
  8926. * @note To determine whether group injected trigger source is
  8927. * internal (SW start) or external, without detail
  8928. * of which peripheral is selected as external trigger,
  8929. * (equivalent to
  8930. * "if(LL_ADC_INJ_GetTriggerSource(ADC1) == LL_ADC_INJ_TRIG_SOFTWARE)")
  8931. * use function @ref LL_ADC_INJ_IsTriggerSourceSWStart.
  8932. * @note Availability of parameters of trigger sources from timer
  8933. * depends on timers availability on the selected device.
  8934. * @rmtoll CR2 JEXTSEL LL_ADC_INJ_GetTriggerSource
  8935. * @param ADCx ADC instance
  8936. * @retval Returned value can be one of the following values:
  8937. * @arg @ref LL_ADC_INJ_TRIG_SOFTWARE
  8938. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM2_TRGO
  8939. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM2_CH1
  8940. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM3_CH4
  8941. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM4_TRGO
  8942. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM19_CH1
  8943. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM19_CH2
  8944. * @arg @ref LL_ADC_INJ_TRIG_EXT_EXTI_LINE15
  8945. */
  8946. __STATIC_INLINE uint32_t LL_ADC_INJ_GetTriggerSource(ADC_TypeDef *ADCx)
  8947. {
  8948. return (uint32_t)(READ_BIT(ADCx->CR2, ADC_CR2_JEXTSEL));
  8949. }
  8950. /**
  8951. * @brief Get ADC group injected conversion trigger source internal (SW start)
  8952. or external
  8953. * @note In case of group injected trigger source set to external trigger,
  8954. * to determine which peripheral is selected as external trigger,
  8955. * use function @ref LL_ADC_INJ_GetTriggerSource.
  8956. * @rmtoll CR2 JEXTSEL LL_ADC_INJ_IsTriggerSourceSWStart
  8957. * @param ADCx ADC instance
  8958. * @retval Value "0" trigger source external trigger
  8959. * Value "1" trigger source SW start.
  8960. */
  8961. __STATIC_INLINE uint32_t LL_ADC_INJ_IsTriggerSourceSWStart(ADC_TypeDef *ADCx)
  8962. {
  8963. return (READ_BIT(ADCx->CR2, ADC_CR2_JEXTSEL) == LL_ADC_INJ_TRIG_SOFTWARE);
  8964. }
  8965. /**
  8966. * @brief Set ADC group injected sequencer length and scan direction.
  8967. * @note This function performs configuration of:
  8968. * - Sequence length: Number of ranks in the scan sequence.
  8969. * - Sequence direction: Unless specified in parameters, sequencer
  8970. * scan direction is forward (from rank 1 to rank n).
  8971. * @note On this STM32 series, group injected sequencer configuration
  8972. * is conditioned to ADC instance sequencer mode.
  8973. * If ADC instance sequencer mode is disabled, sequencers of
  8974. * all groups (group regular, group injected) can be configured
  8975. * but their execution is disabled (limited to rank 1).
  8976. * Refer to function @ref LL_ADC_SetSequencersScanMode().
  8977. * @note Sequencer disabled is equivalent to sequencer of 1 rank:
  8978. * ADC conversion on only 1 channel.
  8979. * @rmtoll JSQR JL LL_ADC_INJ_SetSequencerLength
  8980. * @param ADCx ADC instance
  8981. * @param SequencerNbRanks This parameter can be one of the following values:
  8982. * @arg @ref LL_ADC_INJ_SEQ_SCAN_DISABLE
  8983. * @arg @ref LL_ADC_INJ_SEQ_SCAN_ENABLE_2RANKS
  8984. * @arg @ref LL_ADC_INJ_SEQ_SCAN_ENABLE_3RANKS
  8985. * @arg @ref LL_ADC_INJ_SEQ_SCAN_ENABLE_4RANKS
  8986. * @retval None
  8987. */
  8988. __STATIC_INLINE void LL_ADC_INJ_SetSequencerLength(ADC_TypeDef *ADCx, uint32_t SequencerNbRanks)
  8989. {
  8990. MODIFY_REG(ADCx->JSQR, ADC_JSQR_JL, SequencerNbRanks);
  8991. }
  8992. /**
  8993. * @brief Get ADC group injected sequencer length and scan direction.
  8994. * @note This function retrieves:
  8995. * - Sequence length: Number of ranks in the scan sequence.
  8996. * - Sequence direction: Unless specified in parameters, sequencer
  8997. * scan direction is forward (from rank 1 to rank n).
  8998. * @note On this STM32 series, group injected sequencer configuration
  8999. * is conditioned to ADC instance sequencer mode.
  9000. * If ADC instance sequencer mode is disabled, sequencers of
  9001. * all groups (group regular, group injected) can be configured
  9002. * but their execution is disabled (limited to rank 1).
  9003. * Refer to function @ref LL_ADC_SetSequencersScanMode().
  9004. * @note Sequencer disabled is equivalent to sequencer of 1 rank:
  9005. * ADC conversion on only 1 channel.
  9006. * @rmtoll JSQR JL LL_ADC_INJ_GetSequencerLength
  9007. * @param ADCx ADC instance
  9008. * @retval Returned value can be one of the following values:
  9009. * @arg @ref LL_ADC_INJ_SEQ_SCAN_DISABLE
  9010. * @arg @ref LL_ADC_INJ_SEQ_SCAN_ENABLE_2RANKS
  9011. * @arg @ref LL_ADC_INJ_SEQ_SCAN_ENABLE_3RANKS
  9012. * @arg @ref LL_ADC_INJ_SEQ_SCAN_ENABLE_4RANKS
  9013. */
  9014. __STATIC_INLINE uint32_t LL_ADC_INJ_GetSequencerLength(ADC_TypeDef *ADCx)
  9015. {
  9016. return (uint32_t)(READ_BIT(ADCx->JSQR, ADC_JSQR_JL));
  9017. }
  9018. /**
  9019. * @brief Set ADC group injected sequencer discontinuous mode:
  9020. * sequence subdivided and scan conversions interrupted every selected
  9021. * number of ranks.
  9022. * @note It is not possible to enable both ADC group injected
  9023. * auto-injected mode and sequencer discontinuous mode.
  9024. * @rmtoll CR1 DISCEN LL_ADC_INJ_SetSequencerDiscont
  9025. * @param ADCx ADC instance
  9026. * @param SeqDiscont This parameter can be one of the following values:
  9027. * @arg @ref LL_ADC_INJ_SEQ_DISCONT_DISABLE
  9028. * @arg @ref LL_ADC_INJ_SEQ_DISCONT_1RANK
  9029. * @retval None
  9030. */
  9031. __STATIC_INLINE void LL_ADC_INJ_SetSequencerDiscont(ADC_TypeDef *ADCx, uint32_t SeqDiscont)
  9032. {
  9033. MODIFY_REG(ADCx->CR1, ADC_CR1_JDISCEN, SeqDiscont);
  9034. }
  9035. /**
  9036. * @brief Get ADC group injected sequencer discontinuous mode:
  9037. * sequence subdivided and scan conversions interrupted every selected
  9038. * number of ranks.
  9039. * @rmtoll CR1 DISCEN LL_ADC_REG_GetSequencerDiscont
  9040. * @param ADCx ADC instance
  9041. * @retval Returned value can be one of the following values:
  9042. * @arg @ref LL_ADC_INJ_SEQ_DISCONT_DISABLE
  9043. * @arg @ref LL_ADC_INJ_SEQ_DISCONT_1RANK
  9044. */
  9045. __STATIC_INLINE uint32_t LL_ADC_INJ_GetSequencerDiscont(ADC_TypeDef *ADCx)
  9046. {
  9047. return (uint32_t)(READ_BIT(ADCx->CR1, ADC_CR1_JDISCEN));
  9048. }
  9049. /**
  9050. * @brief Set ADC group injected sequence: channel on the selected
  9051. * sequence rank.
  9052. * @note Depending on devices and packages, some channels may not be available.
  9053. * Refer to device datasheet for channels availability.
  9054. * @note On this STM32 series, to measure internal channels (VrefInt,
  9055. * TempSensor, ...), measurement paths to internal channels must be
  9056. * enabled separately.
  9057. * This can be done using function @ref LL_ADC_SetCommonPathInternalCh().
  9058. * @rmtoll JSQR JSQ1 LL_ADC_INJ_SetSequencerRanks\n
  9059. * JSQR JSQ2 LL_ADC_INJ_SetSequencerRanks\n
  9060. * JSQR JSQ3 LL_ADC_INJ_SetSequencerRanks\n
  9061. * JSQR JSQ4 LL_ADC_INJ_SetSequencerRanks
  9062. * @param ADCx ADC instance
  9063. * @param Rank This parameter can be one of the following values:
  9064. * @arg @ref LL_ADC_INJ_RANK_1
  9065. * @arg @ref LL_ADC_INJ_RANK_2
  9066. * @arg @ref LL_ADC_INJ_RANK_3
  9067. * @arg @ref LL_ADC_INJ_RANK_4
  9068. * @param Channel This parameter can be one of the following values:
  9069. * @arg @ref LL_ADC_CHANNEL_0
  9070. * @arg @ref LL_ADC_CHANNEL_1
  9071. * @arg @ref LL_ADC_CHANNEL_2
  9072. * @arg @ref LL_ADC_CHANNEL_3
  9073. * @arg @ref LL_ADC_CHANNEL_4
  9074. * @arg @ref LL_ADC_CHANNEL_5
  9075. * @arg @ref LL_ADC_CHANNEL_6
  9076. * @arg @ref LL_ADC_CHANNEL_7
  9077. * @arg @ref LL_ADC_CHANNEL_8
  9078. * @arg @ref LL_ADC_CHANNEL_9
  9079. * @arg @ref LL_ADC_CHANNEL_10
  9080. * @arg @ref LL_ADC_CHANNEL_11
  9081. * @arg @ref LL_ADC_CHANNEL_12
  9082. * @arg @ref LL_ADC_CHANNEL_13
  9083. * @arg @ref LL_ADC_CHANNEL_14
  9084. * @arg @ref LL_ADC_CHANNEL_15
  9085. * @arg @ref LL_ADC_CHANNEL_16
  9086. * @arg @ref LL_ADC_CHANNEL_17
  9087. * @arg @ref LL_ADC_CHANNEL_VREFINT (1)
  9088. * @arg @ref LL_ADC_CHANNEL_TEMPSENSOR (1)
  9089. *
  9090. * (1) On STM32F37x, parameter available only on ADC instance: ADC1.
  9091. * @retval None
  9092. */
  9093. __STATIC_INLINE void LL_ADC_INJ_SetSequencerRanks(ADC_TypeDef *ADCx, uint32_t Rank, uint32_t Channel)
  9094. {
  9095. /* Set bits with content of parameter "Channel" with bits position */
  9096. /* in register depending on parameter "Rank". */
  9097. /* Parameters "Rank" and "Channel" are used with masks because containing */
  9098. /* other bits reserved for other purpose. */
  9099. MODIFY_REG(ADCx->JSQR,
  9100. ADC_CHANNEL_ID_NUMBER_MASK << (Rank & ADC_INJ_RANK_ID_JSQR_MASK),
  9101. (Channel & ADC_CHANNEL_ID_NUMBER_MASK) << (Rank & ADC_INJ_RANK_ID_JSQR_MASK));
  9102. }
  9103. /**
  9104. * @brief Get ADC group injected sequence: channel on the selected
  9105. * sequence rank.
  9106. * @note Depending on devices and packages, some channels may not be available.
  9107. * Refer to device datasheet for channels availability.
  9108. * @note Usage of the returned channel number:
  9109. * - To reinject this channel into another function LL_ADC_xxx:
  9110. * the returned channel number is only partly formatted on definition
  9111. * of literals LL_ADC_CHANNEL_x. Therefore, it has to be compared
  9112. * with parts of literals LL_ADC_CHANNEL_x or using
  9113. * helper macro @ref __LL_ADC_CHANNEL_TO_DECIMAL_NB().
  9114. * Then the selected literal LL_ADC_CHANNEL_x can be used
  9115. * as parameter for another function.
  9116. * - To get the channel number in decimal format:
  9117. * process the returned value with the helper macro
  9118. * @ref __LL_ADC_CHANNEL_TO_DECIMAL_NB().
  9119. * @rmtoll JSQR JSQ1 LL_ADC_INJ_SetSequencerRanks\n
  9120. * JSQR JSQ2 LL_ADC_INJ_SetSequencerRanks\n
  9121. * JSQR JSQ3 LL_ADC_INJ_SetSequencerRanks\n
  9122. * JSQR JSQ4 LL_ADC_INJ_SetSequencerRanks
  9123. * @param ADCx ADC instance
  9124. * @param Rank This parameter can be one of the following values:
  9125. * @arg @ref LL_ADC_INJ_RANK_1
  9126. * @arg @ref LL_ADC_INJ_RANK_2
  9127. * @arg @ref LL_ADC_INJ_RANK_3
  9128. * @arg @ref LL_ADC_INJ_RANK_4
  9129. * @retval Returned value can be one of the following values:
  9130. * @arg @ref LL_ADC_CHANNEL_0
  9131. * @arg @ref LL_ADC_CHANNEL_1
  9132. * @arg @ref LL_ADC_CHANNEL_2
  9133. * @arg @ref LL_ADC_CHANNEL_3
  9134. * @arg @ref LL_ADC_CHANNEL_4
  9135. * @arg @ref LL_ADC_CHANNEL_5
  9136. * @arg @ref LL_ADC_CHANNEL_6
  9137. * @arg @ref LL_ADC_CHANNEL_7
  9138. * @arg @ref LL_ADC_CHANNEL_8
  9139. * @arg @ref LL_ADC_CHANNEL_9
  9140. * @arg @ref LL_ADC_CHANNEL_10
  9141. * @arg @ref LL_ADC_CHANNEL_11
  9142. * @arg @ref LL_ADC_CHANNEL_12
  9143. * @arg @ref LL_ADC_CHANNEL_13
  9144. * @arg @ref LL_ADC_CHANNEL_14
  9145. * @arg @ref LL_ADC_CHANNEL_15
  9146. * @arg @ref LL_ADC_CHANNEL_16
  9147. * @arg @ref LL_ADC_CHANNEL_17
  9148. * @arg @ref LL_ADC_CHANNEL_VREFINT (1)
  9149. * @arg @ref LL_ADC_CHANNEL_TEMPSENSOR (1)
  9150. *
  9151. * (1) On STM32F37x, parameter available only on ADC instance: ADC1.\n
  9152. * (1) For ADC channel read back from ADC register,
  9153. * comparison with internal channel parameter to be done
  9154. * using helper macro @ref __LL_ADC_CHANNEL_INTERNAL_TO_EXTERNAL().
  9155. */
  9156. __STATIC_INLINE uint32_t LL_ADC_INJ_GetSequencerRanks(ADC_TypeDef *ADCx, uint32_t Rank)
  9157. {
  9158. return (uint32_t)(READ_BIT(ADCx->JSQR,
  9159. ADC_CHANNEL_ID_NUMBER_MASK << (Rank & ADC_INJ_RANK_ID_JSQR_MASK))
  9160. >> (Rank & ADC_INJ_RANK_ID_JSQR_MASK)
  9161. );
  9162. }
  9163. /**
  9164. * @brief Set ADC group injected conversion trigger:
  9165. * independent or from ADC group regular.
  9166. * @note This mode can be used to extend number of data registers
  9167. * updated after one ADC conversion trigger and with data
  9168. * permanently kept (not erased by successive conversions of scan of
  9169. * ADC sequencer ranks), up to 5 data registers:
  9170. * 1 data register on ADC group regular, 4 data registers
  9171. * on ADC group injected.
  9172. * @note If ADC group injected injected trigger source is set to an
  9173. * external trigger, this feature must be must be set to
  9174. * independent trigger.
  9175. * ADC group injected automatic trigger is compliant only with
  9176. * group injected trigger source set to SW start, without any
  9177. * further action on ADC group injected conversion start or stop:
  9178. * in this case, ADC group injected is controlled only
  9179. * from ADC group regular.
  9180. * @note It is not possible to enable both ADC group injected
  9181. * auto-injected mode and sequencer discontinuous mode.
  9182. * @rmtoll CR1 JAUTO LL_ADC_INJ_SetTrigAuto
  9183. * @param ADCx ADC instance
  9184. * @param TrigAuto This parameter can be one of the following values:
  9185. * @arg @ref LL_ADC_INJ_TRIG_INDEPENDENT
  9186. * @arg @ref LL_ADC_INJ_TRIG_FROM_GRP_REGULAR
  9187. * @retval None
  9188. */
  9189. __STATIC_INLINE void LL_ADC_INJ_SetTrigAuto(ADC_TypeDef *ADCx, uint32_t TrigAuto)
  9190. {
  9191. MODIFY_REG(ADCx->CR1, ADC_CR1_JAUTO, TrigAuto);
  9192. }
  9193. /**
  9194. * @brief Get ADC group injected conversion trigger:
  9195. * independent or from ADC group regular.
  9196. * @rmtoll CR1 JAUTO LL_ADC_INJ_GetTrigAuto
  9197. * @param ADCx ADC instance
  9198. * @retval Returned value can be one of the following values:
  9199. * @arg @ref LL_ADC_INJ_TRIG_INDEPENDENT
  9200. * @arg @ref LL_ADC_INJ_TRIG_FROM_GRP_REGULAR
  9201. */
  9202. __STATIC_INLINE uint32_t LL_ADC_INJ_GetTrigAuto(ADC_TypeDef *ADCx)
  9203. {
  9204. return (uint32_t)(READ_BIT(ADCx->CR1, ADC_CR1_JAUTO));
  9205. }
  9206. /**
  9207. * @brief Set ADC group injected offset.
  9208. * @note It sets:
  9209. * - ADC group injected rank to which the offset programmed
  9210. * will be applied
  9211. * - Offset level (offset to be subtracted from the raw
  9212. * converted data).
  9213. * Caution: Offset format is dependent to ADC resolution:
  9214. * offset has to be left-aligned on bit 11, the LSB (right bits)
  9215. * are set to 0.
  9216. * @note Offset cannot be enabled or disabled.
  9217. * To emulate offset disabled, set an offset value equal to 0.
  9218. * @rmtoll JOFR1 JOFFSET1 LL_ADC_INJ_SetOffset\n
  9219. * JOFR2 JOFFSET2 LL_ADC_INJ_SetOffset\n
  9220. * JOFR3 JOFFSET3 LL_ADC_INJ_SetOffset\n
  9221. * JOFR4 JOFFSET4 LL_ADC_INJ_SetOffset
  9222. * @param ADCx ADC instance
  9223. * @param Rank This parameter can be one of the following values:
  9224. * @arg @ref LL_ADC_INJ_RANK_1
  9225. * @arg @ref LL_ADC_INJ_RANK_2
  9226. * @arg @ref LL_ADC_INJ_RANK_3
  9227. * @arg @ref LL_ADC_INJ_RANK_4
  9228. * @param OffsetLevel Value between Min_Data=0x000 and Max_Data=0xFFF
  9229. * @retval None
  9230. */
  9231. __STATIC_INLINE void LL_ADC_INJ_SetOffset(ADC_TypeDef *ADCx, uint32_t Rank, uint32_t OffsetLevel)
  9232. {
  9233. __IO uint32_t *preg = __ADC_PTR_REG_OFFSET(ADCx->JOFR1, __ADC_MASK_SHIFT(Rank, ADC_INJ_JOFRX_REGOFFSET_MASK));
  9234. MODIFY_REG(*preg,
  9235. ADC_JOFR1_JOFFSET1,
  9236. OffsetLevel);
  9237. }
  9238. /**
  9239. * @brief Get ADC group injected offset.
  9240. * @note It gives offset level (offset to be subtracted from the raw converted data).
  9241. * Caution: Offset format is dependent to ADC resolution:
  9242. * offset has to be left-aligned on bit 11, the LSB (right bits)
  9243. * are set to 0.
  9244. * @rmtoll JOFR1 JOFFSET1 LL_ADC_INJ_GetOffset\n
  9245. * JOFR2 JOFFSET2 LL_ADC_INJ_GetOffset\n
  9246. * JOFR3 JOFFSET3 LL_ADC_INJ_GetOffset\n
  9247. * JOFR4 JOFFSET4 LL_ADC_INJ_GetOffset
  9248. * @param ADCx ADC instance
  9249. * @param Rank This parameter can be one of the following values:
  9250. * @arg @ref LL_ADC_INJ_RANK_1
  9251. * @arg @ref LL_ADC_INJ_RANK_2
  9252. * @arg @ref LL_ADC_INJ_RANK_3
  9253. * @arg @ref LL_ADC_INJ_RANK_4
  9254. * @retval Value between Min_Data=0x000 and Max_Data=0xFFF
  9255. */
  9256. __STATIC_INLINE uint32_t LL_ADC_INJ_GetOffset(ADC_TypeDef *ADCx, uint32_t Rank)
  9257. {
  9258. __IO uint32_t *preg = __ADC_PTR_REG_OFFSET(ADCx->JOFR1, __ADC_MASK_SHIFT(Rank, ADC_INJ_JOFRX_REGOFFSET_MASK));
  9259. return (uint32_t)(READ_BIT(*preg,
  9260. ADC_JOFR1_JOFFSET1)
  9261. );
  9262. }
  9263. /**
  9264. * @}
  9265. */
  9266. /** @defgroup ADC_LL_EF_Configuration_Channels Configuration of ADC hierarchical scope: channels
  9267. * @{
  9268. */
  9269. /**
  9270. * @brief Set sampling time of the selected ADC channel
  9271. * Unit: ADC clock cycles.
  9272. * @note On this device, sampling time is on channel scope: independently
  9273. * of channel mapped on ADC group regular or injected.
  9274. * @note In case of internal channel (VrefInt, TempSensor, ...) to be
  9275. * converted:
  9276. * sampling time constraints must be respected (sampling time can be
  9277. * adjusted in function of ADC clock frequency and sampling time
  9278. * setting).
  9279. * Refer to device datasheet for timings values (parameters TS_vrefint,
  9280. * TS_temp, ...).
  9281. * @note Conversion time is the addition of sampling time and processing time.
  9282. * Refer to reference manual for ADC processing time of
  9283. * this STM32 series.
  9284. * @note In case of ADC conversion of internal channel (VrefInt,
  9285. * temperature sensor, ...), a sampling time minimum value
  9286. * is required.
  9287. * Refer to device datasheet.
  9288. * @rmtoll SMPR1 SMP17 LL_ADC_SetChannelSamplingTime\n
  9289. * SMPR1 SMP16 LL_ADC_SetChannelSamplingTime\n
  9290. * SMPR1 SMP15 LL_ADC_SetChannelSamplingTime\n
  9291. * SMPR1 SMP14 LL_ADC_SetChannelSamplingTime\n
  9292. * SMPR1 SMP13 LL_ADC_SetChannelSamplingTime\n
  9293. * SMPR1 SMP12 LL_ADC_SetChannelSamplingTime\n
  9294. * SMPR1 SMP11 LL_ADC_SetChannelSamplingTime\n
  9295. * SMPR1 SMP10 LL_ADC_SetChannelSamplingTime\n
  9296. * SMPR2 SMP9 LL_ADC_SetChannelSamplingTime\n
  9297. * SMPR2 SMP8 LL_ADC_SetChannelSamplingTime\n
  9298. * SMPR2 SMP7 LL_ADC_SetChannelSamplingTime\n
  9299. * SMPR2 SMP6 LL_ADC_SetChannelSamplingTime\n
  9300. * SMPR2 SMP5 LL_ADC_SetChannelSamplingTime\n
  9301. * SMPR2 SMP4 LL_ADC_SetChannelSamplingTime\n
  9302. * SMPR2 SMP3 LL_ADC_SetChannelSamplingTime\n
  9303. * SMPR2 SMP2 LL_ADC_SetChannelSamplingTime\n
  9304. * SMPR2 SMP1 LL_ADC_SetChannelSamplingTime\n
  9305. * SMPR2 SMP0 LL_ADC_SetChannelSamplingTime
  9306. * @param ADCx ADC instance
  9307. * @param Channel This parameter can be one of the following values:
  9308. * @arg @ref LL_ADC_CHANNEL_0
  9309. * @arg @ref LL_ADC_CHANNEL_1
  9310. * @arg @ref LL_ADC_CHANNEL_2
  9311. * @arg @ref LL_ADC_CHANNEL_3
  9312. * @arg @ref LL_ADC_CHANNEL_4
  9313. * @arg @ref LL_ADC_CHANNEL_5
  9314. * @arg @ref LL_ADC_CHANNEL_6
  9315. * @arg @ref LL_ADC_CHANNEL_7
  9316. * @arg @ref LL_ADC_CHANNEL_8
  9317. * @arg @ref LL_ADC_CHANNEL_9
  9318. * @arg @ref LL_ADC_CHANNEL_10
  9319. * @arg @ref LL_ADC_CHANNEL_11
  9320. * @arg @ref LL_ADC_CHANNEL_12
  9321. * @arg @ref LL_ADC_CHANNEL_13
  9322. * @arg @ref LL_ADC_CHANNEL_14
  9323. * @arg @ref LL_ADC_CHANNEL_15
  9324. * @arg @ref LL_ADC_CHANNEL_16
  9325. * @arg @ref LL_ADC_CHANNEL_17
  9326. * @arg @ref LL_ADC_CHANNEL_VREFINT (1)
  9327. * @arg @ref LL_ADC_CHANNEL_TEMPSENSOR (1)
  9328. *
  9329. * (1) On STM32F37x, parameter available only on ADC instance: ADC1.
  9330. * @param SamplingTime This parameter can be one of the following values:
  9331. * @arg @ref LL_ADC_SAMPLINGTIME_1CYCLE_5
  9332. * @arg @ref LL_ADC_SAMPLINGTIME_7CYCLES_5
  9333. * @arg @ref LL_ADC_SAMPLINGTIME_13CYCLES_5
  9334. * @arg @ref LL_ADC_SAMPLINGTIME_28CYCLES_5
  9335. * @arg @ref LL_ADC_SAMPLINGTIME_41CYCLES_5
  9336. * @arg @ref LL_ADC_SAMPLINGTIME_55CYCLES_5
  9337. * @arg @ref LL_ADC_SAMPLINGTIME_71CYCLES_5
  9338. * @arg @ref LL_ADC_SAMPLINGTIME_239CYCLES_5
  9339. * @retval None
  9340. */
  9341. __STATIC_INLINE void LL_ADC_SetChannelSamplingTime(ADC_TypeDef *ADCx, uint32_t Channel, uint32_t SamplingTime)
  9342. {
  9343. /* Set bits with content of parameter "SamplingTime" with bits position */
  9344. /* in register and register position depending on parameter "Channel". */
  9345. /* Parameter "Channel" is used with masks because containing */
  9346. /* other bits reserved for other purpose. */
  9347. __IO uint32_t *preg = __ADC_PTR_REG_OFFSET(ADCx->SMPR1, __ADC_MASK_SHIFT(Channel, ADC_CHANNEL_SMPRX_REGOFFSET_MASK));
  9348. MODIFY_REG(*preg,
  9349. ADC_SMPR2_SMP0 << __ADC_MASK_SHIFT(Channel, ADC_CHANNEL_SMPx_BITOFFSET_MASK),
  9350. SamplingTime << __ADC_MASK_SHIFT(Channel, ADC_CHANNEL_SMPx_BITOFFSET_MASK));
  9351. }
  9352. /**
  9353. * @brief Get sampling time of the selected ADC channel
  9354. * Unit: ADC clock cycles.
  9355. * @note On this device, sampling time is on channel scope: independently
  9356. * of channel mapped on ADC group regular or injected.
  9357. * @note Conversion time is the addition of sampling time and processing time.
  9358. * Refer to reference manual for ADC processing time of
  9359. * this STM32 series.
  9360. * @rmtoll SMPR1 SMP17 LL_ADC_GetChannelSamplingTime\n
  9361. * SMPR1 SMP16 LL_ADC_GetChannelSamplingTime\n
  9362. * SMPR1 SMP15 LL_ADC_GetChannelSamplingTime\n
  9363. * SMPR1 SMP14 LL_ADC_GetChannelSamplingTime\n
  9364. * SMPR1 SMP13 LL_ADC_GetChannelSamplingTime\n
  9365. * SMPR1 SMP12 LL_ADC_GetChannelSamplingTime\n
  9366. * SMPR1 SMP11 LL_ADC_GetChannelSamplingTime\n
  9367. * SMPR1 SMP10 LL_ADC_GetChannelSamplingTime\n
  9368. * SMPR2 SMP9 LL_ADC_GetChannelSamplingTime\n
  9369. * SMPR2 SMP8 LL_ADC_GetChannelSamplingTime\n
  9370. * SMPR2 SMP7 LL_ADC_GetChannelSamplingTime\n
  9371. * SMPR2 SMP6 LL_ADC_GetChannelSamplingTime\n
  9372. * SMPR2 SMP5 LL_ADC_GetChannelSamplingTime\n
  9373. * SMPR2 SMP4 LL_ADC_GetChannelSamplingTime\n
  9374. * SMPR2 SMP3 LL_ADC_GetChannelSamplingTime\n
  9375. * SMPR2 SMP2 LL_ADC_GetChannelSamplingTime\n
  9376. * SMPR2 SMP1 LL_ADC_GetChannelSamplingTime\n
  9377. * SMPR2 SMP0 LL_ADC_GetChannelSamplingTime
  9378. * @param ADCx ADC instance
  9379. * @param Channel This parameter can be one of the following values:
  9380. * @arg @ref LL_ADC_CHANNEL_0
  9381. * @arg @ref LL_ADC_CHANNEL_1
  9382. * @arg @ref LL_ADC_CHANNEL_2
  9383. * @arg @ref LL_ADC_CHANNEL_3
  9384. * @arg @ref LL_ADC_CHANNEL_4
  9385. * @arg @ref LL_ADC_CHANNEL_5
  9386. * @arg @ref LL_ADC_CHANNEL_6
  9387. * @arg @ref LL_ADC_CHANNEL_7
  9388. * @arg @ref LL_ADC_CHANNEL_8
  9389. * @arg @ref LL_ADC_CHANNEL_9
  9390. * @arg @ref LL_ADC_CHANNEL_10
  9391. * @arg @ref LL_ADC_CHANNEL_11
  9392. * @arg @ref LL_ADC_CHANNEL_12
  9393. * @arg @ref LL_ADC_CHANNEL_13
  9394. * @arg @ref LL_ADC_CHANNEL_14
  9395. * @arg @ref LL_ADC_CHANNEL_15
  9396. * @arg @ref LL_ADC_CHANNEL_16
  9397. * @arg @ref LL_ADC_CHANNEL_17
  9398. * @arg @ref LL_ADC_CHANNEL_VREFINT (1)
  9399. * @arg @ref LL_ADC_CHANNEL_TEMPSENSOR (1)
  9400. *
  9401. * (1) On STM32F37x, parameter available only on ADC instance: ADC1.
  9402. * @retval Returned value can be one of the following values:
  9403. * @arg @ref LL_ADC_SAMPLINGTIME_1CYCLE_5
  9404. * @arg @ref LL_ADC_SAMPLINGTIME_7CYCLES_5
  9405. * @arg @ref LL_ADC_SAMPLINGTIME_13CYCLES_5
  9406. * @arg @ref LL_ADC_SAMPLINGTIME_28CYCLES_5
  9407. * @arg @ref LL_ADC_SAMPLINGTIME_41CYCLES_5
  9408. * @arg @ref LL_ADC_SAMPLINGTIME_55CYCLES_5
  9409. * @arg @ref LL_ADC_SAMPLINGTIME_71CYCLES_5
  9410. * @arg @ref LL_ADC_SAMPLINGTIME_239CYCLES_5
  9411. */
  9412. __STATIC_INLINE uint32_t LL_ADC_GetChannelSamplingTime(ADC_TypeDef *ADCx, uint32_t Channel)
  9413. {
  9414. __IO uint32_t *preg = __ADC_PTR_REG_OFFSET(ADCx->SMPR1, __ADC_MASK_SHIFT(Channel, ADC_CHANNEL_SMPRX_REGOFFSET_MASK));
  9415. return (uint32_t)(READ_BIT(*preg,
  9416. ADC_SMPR2_SMP0 << __ADC_MASK_SHIFT(Channel, ADC_CHANNEL_SMPx_BITOFFSET_MASK))
  9417. >> __ADC_MASK_SHIFT(Channel, ADC_CHANNEL_SMPx_BITOFFSET_MASK)
  9418. );
  9419. }
  9420. /**
  9421. * @}
  9422. */
  9423. /** @defgroup ADC_LL_EF_Configuration_ADC_AnalogWatchdog Configuration of ADC transversal scope: analog watchdog
  9424. * @{
  9425. */
  9426. /**
  9427. * @brief Set ADC analog watchdog monitored channels:
  9428. * a single channel or all channels,
  9429. * on ADC groups regular and-or injected.
  9430. * @note Once monitored channels are selected, analog watchdog
  9431. * is enabled.
  9432. * @note In case of need to define a single channel to monitor
  9433. * with analog watchdog from sequencer channel definition,
  9434. * use helper macro @ref __LL_ADC_ANALOGWD_CHANNEL_GROUP().
  9435. * @note On this STM32 series, there is only 1 kind of analog watchdog
  9436. * instance:
  9437. * - AWD standard (instance AWD1):
  9438. * - channels monitored: can monitor 1 channel or all channels.
  9439. * - groups monitored: ADC groups regular and-or injected.
  9440. * - resolution: resolution is not limited (corresponds to
  9441. * ADC resolution configured).
  9442. * @rmtoll CR1 AWD1CH LL_ADC_SetAnalogWDMonitChannels\n
  9443. * CR1 AWD1SGL LL_ADC_SetAnalogWDMonitChannels\n
  9444. * CR1 AWD1EN LL_ADC_SetAnalogWDMonitChannels
  9445. * @param ADCx ADC instance
  9446. * @param AWDChannelGroup This parameter can be one of the following values:
  9447. * @arg @ref LL_ADC_AWD_DISABLE
  9448. * @arg @ref LL_ADC_AWD_ALL_CHANNELS_REG
  9449. * @arg @ref LL_ADC_AWD_ALL_CHANNELS_INJ
  9450. * @arg @ref LL_ADC_AWD_ALL_CHANNELS_REG_INJ
  9451. * @arg @ref LL_ADC_AWD_CHANNEL_0_REG
  9452. * @arg @ref LL_ADC_AWD_CHANNEL_0_INJ
  9453. * @arg @ref LL_ADC_AWD_CHANNEL_0_REG_INJ
  9454. * @arg @ref LL_ADC_AWD_CHANNEL_1_REG
  9455. * @arg @ref LL_ADC_AWD_CHANNEL_1_INJ
  9456. * @arg @ref LL_ADC_AWD_CHANNEL_1_REG_INJ
  9457. * @arg @ref LL_ADC_AWD_CHANNEL_2_REG
  9458. * @arg @ref LL_ADC_AWD_CHANNEL_2_INJ
  9459. * @arg @ref LL_ADC_AWD_CHANNEL_2_REG_INJ
  9460. * @arg @ref LL_ADC_AWD_CHANNEL_3_REG
  9461. * @arg @ref LL_ADC_AWD_CHANNEL_3_INJ
  9462. * @arg @ref LL_ADC_AWD_CHANNEL_3_REG_INJ
  9463. * @arg @ref LL_ADC_AWD_CHANNEL_4_REG
  9464. * @arg @ref LL_ADC_AWD_CHANNEL_4_INJ
  9465. * @arg @ref LL_ADC_AWD_CHANNEL_4_REG_INJ
  9466. * @arg @ref LL_ADC_AWD_CHANNEL_5_REG
  9467. * @arg @ref LL_ADC_AWD_CHANNEL_5_INJ
  9468. * @arg @ref LL_ADC_AWD_CHANNEL_5_REG_INJ
  9469. * @arg @ref LL_ADC_AWD_CHANNEL_6_REG
  9470. * @arg @ref LL_ADC_AWD_CHANNEL_6_INJ
  9471. * @arg @ref LL_ADC_AWD_CHANNEL_6_REG_INJ
  9472. * @arg @ref LL_ADC_AWD_CHANNEL_7_REG
  9473. * @arg @ref LL_ADC_AWD_CHANNEL_7_INJ
  9474. * @arg @ref LL_ADC_AWD_CHANNEL_7_REG_INJ
  9475. * @arg @ref LL_ADC_AWD_CHANNEL_8_REG
  9476. * @arg @ref LL_ADC_AWD_CHANNEL_8_INJ
  9477. * @arg @ref LL_ADC_AWD_CHANNEL_8_REG_INJ
  9478. * @arg @ref LL_ADC_AWD_CHANNEL_9_REG
  9479. * @arg @ref LL_ADC_AWD_CHANNEL_9_INJ
  9480. * @arg @ref LL_ADC_AWD_CHANNEL_9_REG_INJ
  9481. * @arg @ref LL_ADC_AWD_CHANNEL_10_REG
  9482. * @arg @ref LL_ADC_AWD_CHANNEL_10_INJ
  9483. * @arg @ref LL_ADC_AWD_CHANNEL_10_REG_INJ
  9484. * @arg @ref LL_ADC_AWD_CHANNEL_11_REG
  9485. * @arg @ref LL_ADC_AWD_CHANNEL_11_INJ
  9486. * @arg @ref LL_ADC_AWD_CHANNEL_11_REG_INJ
  9487. * @arg @ref LL_ADC_AWD_CHANNEL_12_REG
  9488. * @arg @ref LL_ADC_AWD_CHANNEL_12_INJ
  9489. * @arg @ref LL_ADC_AWD_CHANNEL_12_REG_INJ
  9490. * @arg @ref LL_ADC_AWD_CHANNEL_13_REG
  9491. * @arg @ref LL_ADC_AWD_CHANNEL_13_INJ
  9492. * @arg @ref LL_ADC_AWD_CHANNEL_13_REG_INJ
  9493. * @arg @ref LL_ADC_AWD_CHANNEL_14_REG
  9494. * @arg @ref LL_ADC_AWD_CHANNEL_14_INJ
  9495. * @arg @ref LL_ADC_AWD_CHANNEL_14_REG_INJ
  9496. * @arg @ref LL_ADC_AWD_CHANNEL_15_REG
  9497. * @arg @ref LL_ADC_AWD_CHANNEL_15_INJ
  9498. * @arg @ref LL_ADC_AWD_CHANNEL_15_REG_INJ
  9499. * @arg @ref LL_ADC_AWD_CHANNEL_16_REG
  9500. * @arg @ref LL_ADC_AWD_CHANNEL_16_INJ
  9501. * @arg @ref LL_ADC_AWD_CHANNEL_16_REG_INJ
  9502. * @arg @ref LL_ADC_AWD_CHANNEL_17_REG
  9503. * @arg @ref LL_ADC_AWD_CHANNEL_17_INJ
  9504. * @arg @ref LL_ADC_AWD_CHANNEL_17_REG_INJ
  9505. * @arg @ref LL_ADC_AWD_CH_VREFINT_REG (1)
  9506. * @arg @ref LL_ADC_AWD_CH_VREFINT_INJ (1)
  9507. * @arg @ref LL_ADC_AWD_CH_VREFINT_REG_INJ (1)
  9508. * @arg @ref LL_ADC_AWD_CH_TEMPSENSOR_REG (1)
  9509. * @arg @ref LL_ADC_AWD_CH_TEMPSENSOR_INJ (1)
  9510. * @arg @ref LL_ADC_AWD_CH_TEMPSENSOR_REG_INJ (1)
  9511. *
  9512. * (1) On STM32F37x, parameter available only on ADC instance: ADC1.
  9513. * @retval None
  9514. */
  9515. __STATIC_INLINE void LL_ADC_SetAnalogWDMonitChannels(ADC_TypeDef *ADCx, uint32_t AWDChannelGroup)
  9516. {
  9517. MODIFY_REG(ADCx->CR1,
  9518. (ADC_CR1_AWDEN | ADC_CR1_JAWDEN | ADC_CR1_AWDSGL | ADC_CR1_AWDCH),
  9519. AWDChannelGroup);
  9520. }
  9521. /**
  9522. * @brief Get ADC analog watchdog monitored channel.
  9523. * @note Usage of the returned channel number:
  9524. * - To reinject this channel into another function LL_ADC_xxx:
  9525. * the returned channel number is only partly formatted on definition
  9526. * of literals LL_ADC_CHANNEL_x. Therefore, it has to be compared
  9527. * with parts of literals LL_ADC_CHANNEL_x or using
  9528. * helper macro @ref __LL_ADC_CHANNEL_TO_DECIMAL_NB().
  9529. * Then the selected literal LL_ADC_CHANNEL_x can be used
  9530. * as parameter for another function.
  9531. * - To get the channel number in decimal format:
  9532. * process the returned value with the helper macro
  9533. * @ref __LL_ADC_CHANNEL_TO_DECIMAL_NB().
  9534. * Applicable only when the analog watchdog is set to monitor
  9535. * one channel.
  9536. * @note On this STM32 series, there is only 1 kind of analog watchdog
  9537. * instance:
  9538. * - AWD standard (instance AWD1):
  9539. * - channels monitored: can monitor 1 channel or all channels.
  9540. * - groups monitored: ADC groups regular and-or injected.
  9541. * - resolution: resolution is not limited (corresponds to
  9542. * ADC resolution configured).
  9543. * @rmtoll CR1 AWD1CH LL_ADC_GetAnalogWDMonitChannels\n
  9544. * CR1 AWD1SGL LL_ADC_GetAnalogWDMonitChannels\n
  9545. * CR1 AWD1EN LL_ADC_GetAnalogWDMonitChannels
  9546. * @param ADCx ADC instance
  9547. * @retval Returned value can be one of the following values:
  9548. * @arg @ref LL_ADC_AWD_DISABLE
  9549. * @arg @ref LL_ADC_AWD_ALL_CHANNELS_REG
  9550. * @arg @ref LL_ADC_AWD_ALL_CHANNELS_INJ
  9551. * @arg @ref LL_ADC_AWD_ALL_CHANNELS_REG_INJ
  9552. * @arg @ref LL_ADC_AWD_CHANNEL_0_REG
  9553. * @arg @ref LL_ADC_AWD_CHANNEL_0_INJ
  9554. * @arg @ref LL_ADC_AWD_CHANNEL_0_REG_INJ
  9555. * @arg @ref LL_ADC_AWD_CHANNEL_1_REG
  9556. * @arg @ref LL_ADC_AWD_CHANNEL_1_INJ
  9557. * @arg @ref LL_ADC_AWD_CHANNEL_1_REG_INJ
  9558. * @arg @ref LL_ADC_AWD_CHANNEL_2_REG
  9559. * @arg @ref LL_ADC_AWD_CHANNEL_2_INJ
  9560. * @arg @ref LL_ADC_AWD_CHANNEL_2_REG_INJ
  9561. * @arg @ref LL_ADC_AWD_CHANNEL_3_REG
  9562. * @arg @ref LL_ADC_AWD_CHANNEL_3_INJ
  9563. * @arg @ref LL_ADC_AWD_CHANNEL_3_REG_INJ
  9564. * @arg @ref LL_ADC_AWD_CHANNEL_4_REG
  9565. * @arg @ref LL_ADC_AWD_CHANNEL_4_INJ
  9566. * @arg @ref LL_ADC_AWD_CHANNEL_4_REG_INJ
  9567. * @arg @ref LL_ADC_AWD_CHANNEL_5_REG
  9568. * @arg @ref LL_ADC_AWD_CHANNEL_5_INJ
  9569. * @arg @ref LL_ADC_AWD_CHANNEL_5_REG_INJ
  9570. * @arg @ref LL_ADC_AWD_CHANNEL_6_REG
  9571. * @arg @ref LL_ADC_AWD_CHANNEL_6_INJ
  9572. * @arg @ref LL_ADC_AWD_CHANNEL_6_REG_INJ
  9573. * @arg @ref LL_ADC_AWD_CHANNEL_7_REG
  9574. * @arg @ref LL_ADC_AWD_CHANNEL_7_INJ
  9575. * @arg @ref LL_ADC_AWD_CHANNEL_7_REG_INJ
  9576. * @arg @ref LL_ADC_AWD_CHANNEL_8_REG
  9577. * @arg @ref LL_ADC_AWD_CHANNEL_8_INJ
  9578. * @arg @ref LL_ADC_AWD_CHANNEL_8_REG_INJ
  9579. * @arg @ref LL_ADC_AWD_CHANNEL_9_REG
  9580. * @arg @ref LL_ADC_AWD_CHANNEL_9_INJ
  9581. * @arg @ref LL_ADC_AWD_CHANNEL_9_REG_INJ
  9582. * @arg @ref LL_ADC_AWD_CHANNEL_10_REG
  9583. * @arg @ref LL_ADC_AWD_CHANNEL_10_INJ
  9584. * @arg @ref LL_ADC_AWD_CHANNEL_10_REG_INJ
  9585. * @arg @ref LL_ADC_AWD_CHANNEL_11_REG
  9586. * @arg @ref LL_ADC_AWD_CHANNEL_11_INJ
  9587. * @arg @ref LL_ADC_AWD_CHANNEL_11_REG_INJ
  9588. * @arg @ref LL_ADC_AWD_CHANNEL_12_REG
  9589. * @arg @ref LL_ADC_AWD_CHANNEL_12_INJ
  9590. * @arg @ref LL_ADC_AWD_CHANNEL_12_REG_INJ
  9591. * @arg @ref LL_ADC_AWD_CHANNEL_13_REG
  9592. * @arg @ref LL_ADC_AWD_CHANNEL_13_INJ
  9593. * @arg @ref LL_ADC_AWD_CHANNEL_13_REG_INJ
  9594. * @arg @ref LL_ADC_AWD_CHANNEL_14_REG
  9595. * @arg @ref LL_ADC_AWD_CHANNEL_14_INJ
  9596. * @arg @ref LL_ADC_AWD_CHANNEL_14_REG_INJ
  9597. * @arg @ref LL_ADC_AWD_CHANNEL_15_REG
  9598. * @arg @ref LL_ADC_AWD_CHANNEL_15_INJ
  9599. * @arg @ref LL_ADC_AWD_CHANNEL_15_REG_INJ
  9600. * @arg @ref LL_ADC_AWD_CHANNEL_16_REG
  9601. * @arg @ref LL_ADC_AWD_CHANNEL_16_INJ
  9602. * @arg @ref LL_ADC_AWD_CHANNEL_16_REG_INJ
  9603. * @arg @ref LL_ADC_AWD_CHANNEL_17_REG
  9604. * @arg @ref LL_ADC_AWD_CHANNEL_17_INJ
  9605. * @arg @ref LL_ADC_AWD_CHANNEL_17_REG_INJ
  9606. */
  9607. __STATIC_INLINE uint32_t LL_ADC_GetAnalogWDMonitChannels(ADC_TypeDef *ADCx)
  9608. {
  9609. return (uint32_t)(READ_BIT(ADCx->CR1, (ADC_CR1_AWDEN | ADC_CR1_JAWDEN | ADC_CR1_AWDSGL | ADC_CR1_AWDCH)));
  9610. }
  9611. /**
  9612. * @brief Set ADC analog watchdog threshold value of threshold
  9613. * high or low.
  9614. * @note On this STM32 series, there is only 1 kind of analog watchdog
  9615. * instance:
  9616. * - AWD standard (instance AWD1):
  9617. * - channels monitored: can monitor 1 channel or all channels.
  9618. * - groups monitored: ADC groups regular and-or injected.
  9619. * - resolution: resolution is not limited (corresponds to
  9620. * ADC resolution configured).
  9621. * @rmtoll HTR HT LL_ADC_SetAnalogWDThresholds\n
  9622. * LTR LT LL_ADC_SetAnalogWDThresholds
  9623. * @param ADCx ADC instance
  9624. * @param AWDThresholdsHighLow This parameter can be one of the following values:
  9625. * @arg @ref LL_ADC_AWD_THRESHOLD_HIGH
  9626. * @arg @ref LL_ADC_AWD_THRESHOLD_LOW
  9627. * @param AWDThresholdValue Value between Min_Data=0x000 and Max_Data=0xFFF
  9628. * @retval None
  9629. */
  9630. __STATIC_INLINE void LL_ADC_SetAnalogWDThresholds(ADC_TypeDef *ADCx, uint32_t AWDThresholdsHighLow, uint32_t AWDThresholdValue)
  9631. {
  9632. __IO uint32_t *preg = __ADC_PTR_REG_OFFSET(ADCx->HTR, AWDThresholdsHighLow);
  9633. MODIFY_REG(*preg,
  9634. ADC_HTR_HT,
  9635. AWDThresholdValue);
  9636. }
  9637. /**
  9638. * @brief Get ADC analog watchdog threshold value of threshold high or
  9639. * threshold low.
  9640. * @note In case of ADC resolution different of 12 bits,
  9641. * analog watchdog thresholds data require a specific shift.
  9642. * Use helper macro @ref __LL_ADC_ANALOGWD_GET_THRESHOLD_RESOLUTION().
  9643. * @rmtoll HTR HT LL_ADC_GetAnalogWDThresholds\n
  9644. * LTR LT LL_ADC_GetAnalogWDThresholds
  9645. * @param ADCx ADC instance
  9646. * @param AWDThresholdsHighLow This parameter can be one of the following values:
  9647. * @arg @ref LL_ADC_AWD_THRESHOLD_HIGH
  9648. * @arg @ref LL_ADC_AWD_THRESHOLD_LOW
  9649. * @retval Value between Min_Data=0x000 and Max_Data=0xFFF
  9650. */
  9651. __STATIC_INLINE uint32_t LL_ADC_GetAnalogWDThresholds(ADC_TypeDef *ADCx, uint32_t AWDThresholdsHighLow)
  9652. {
  9653. __IO uint32_t *preg = __ADC_PTR_REG_OFFSET(ADCx->HTR, AWDThresholdsHighLow);
  9654. return (uint32_t)(READ_BIT(*preg, ADC_HTR_HT));
  9655. }
  9656. /**
  9657. * @}
  9658. */
  9659. /** @defgroup ADC_LL_EF_Operation_ADC_Instance Operation on ADC hierarchical scope: ADC instance
  9660. * @{
  9661. */
  9662. /**
  9663. * @brief Enable the selected ADC instance.
  9664. * @note On this STM32 series, after ADC enable, a delay for
  9665. * ADC internal analog stabilization is required before performing a
  9666. * ADC conversion start.
  9667. * Refer to device datasheet, parameter tSTAB.
  9668. * @rmtoll CR2 ADON LL_ADC_Enable
  9669. * @param ADCx ADC instance
  9670. * @retval None
  9671. */
  9672. __STATIC_INLINE void LL_ADC_Enable(ADC_TypeDef *ADCx)
  9673. {
  9674. SET_BIT(ADCx->CR2, ADC_CR2_ADON);
  9675. }
  9676. /**
  9677. * @brief Disable the selected ADC instance.
  9678. * @rmtoll CR2 ADON LL_ADC_Disable
  9679. * @param ADCx ADC instance
  9680. * @retval None
  9681. */
  9682. __STATIC_INLINE void LL_ADC_Disable(ADC_TypeDef *ADCx)
  9683. {
  9684. CLEAR_BIT(ADCx->CR2, ADC_CR2_ADON);
  9685. }
  9686. /**
  9687. * @brief Get the selected ADC instance enable state.
  9688. * @rmtoll CR2 ADON LL_ADC_IsEnabled
  9689. * @param ADCx ADC instance
  9690. * @retval 0: ADC is disabled, 1: ADC is enabled.
  9691. */
  9692. __STATIC_INLINE uint32_t LL_ADC_IsEnabled(ADC_TypeDef *ADCx)
  9693. {
  9694. return (READ_BIT(ADCx->CR2, ADC_CR2_ADON) == (ADC_CR2_ADON));
  9695. }
  9696. /**
  9697. * @brief Start ADC calibration in the mode single-ended
  9698. * or differential (for devices with differential mode available).
  9699. * @note On this STM32 series, before starting a calibration,
  9700. * ADC must be disabled.
  9701. * A minimum number of ADC clock cycles are required
  9702. * between ADC disable state and calibration start.
  9703. * Refer to literal @ref LL_ADC_DELAY_DISABLE_CALIB_ADC_CYCLES.
  9704. * @note On this STM32 series, hardware prerequisite before starting a calibration:
  9705. the ADC must have been in power-on state for at least
  9706. two ADC clock cycles.
  9707. * @rmtoll CR2 CAL LL_ADC_StartCalibration
  9708. * @param ADCx ADC instance
  9709. * @retval None
  9710. */
  9711. __STATIC_INLINE void LL_ADC_StartCalibration(ADC_TypeDef *ADCx)
  9712. {
  9713. SET_BIT(ADCx->CR2, ADC_CR2_CAL);
  9714. }
  9715. /**
  9716. * @brief Get ADC calibration state.
  9717. * @rmtoll CR2 CAL LL_ADC_IsCalibrationOnGoing
  9718. * @param ADCx ADC instance
  9719. * @retval 0: calibration complete, 1: calibration in progress.
  9720. */
  9721. __STATIC_INLINE uint32_t LL_ADC_IsCalibrationOnGoing(ADC_TypeDef *ADCx)
  9722. {
  9723. return (READ_BIT(ADCx->CR2, ADC_CR2_CAL) == (ADC_CR2_CAL));
  9724. }
  9725. /**
  9726. * @}
  9727. */
  9728. /** @defgroup ADC_LL_EF_Operation_ADC_Group_Regular Operation on ADC hierarchical scope: group regular
  9729. * @{
  9730. */
  9731. /**
  9732. * @brief Start ADC group regular conversion.
  9733. * @note On this STM32 series, this function is relevant for both
  9734. * internal trigger (SW start) and external trigger:
  9735. * - If ADC trigger has been set to software start, ADC conversion
  9736. * starts immediately.
  9737. * - If ADC trigger has been set to external trigger, ADC conversion
  9738. * will start at next trigger event (on the selected trigger edge)
  9739. * following the ADC start conversion command.
  9740. * @rmtoll CR2 EXTTRIG LL_ADC_REG_StartConversion
  9741. * @param ADCx ADC instance
  9742. * @retval None
  9743. */
  9744. __STATIC_INLINE void LL_ADC_REG_StartConversion(ADC_TypeDef *ADCx)
  9745. {
  9746. /* Note: Set bit ADC_CR2_SWSTART for case of trigger source set to */
  9747. /* SW start. In case of external trigger selected, this bit */
  9748. /* has no effect. */
  9749. SET_BIT(ADCx->CR2, (ADC_CR2_SWSTART | ADC_CR2_EXTTRIG));
  9750. }
  9751. /**
  9752. * @brief Stop ADC group regular conversion from external trigger.
  9753. * @note No more ADC conversion will start at next trigger event
  9754. * following the ADC stop conversion command.
  9755. * If a conversion is on-going, it will be completed.
  9756. * @note On this STM32 series, there is no specific command
  9757. * to stop a conversion on-going or to stop ADC converting
  9758. * in continuous mode. These actions can be performed
  9759. * using function @ref LL_ADC_Disable().
  9760. * @rmtoll CR2 EXTSEL LL_ADC_REG_StopConversionExtTrig
  9761. * @param ADCx ADC instance
  9762. * @retval None
  9763. */
  9764. __STATIC_INLINE void LL_ADC_REG_StopConversionExtTrig(ADC_TypeDef *ADCx)
  9765. {
  9766. SET_BIT(ADCx->CR2, ADC_CR2_EXTSEL);
  9767. }
  9768. /**
  9769. * @brief Get ADC group regular conversion data, range fit for
  9770. * all ADC configurations: all ADC resolutions and
  9771. * all oversampling increased data width (for devices
  9772. * with feature oversampling).
  9773. * @rmtoll DR RDATA LL_ADC_REG_ReadConversionData32
  9774. * @param ADCx ADC instance
  9775. * @retval Value between Min_Data=0x00000000 and Max_Data=0xFFFFFFFF
  9776. */
  9777. __STATIC_INLINE uint32_t LL_ADC_REG_ReadConversionData32(ADC_TypeDef *ADCx)
  9778. {
  9779. return (uint16_t)(READ_BIT(ADCx->DR, ADC_DR_DATA));
  9780. }
  9781. /**
  9782. * @brief Get ADC group regular conversion data, range fit for
  9783. * ADC resolution 12 bits.
  9784. * @note For devices with feature oversampling: Oversampling
  9785. * can increase data width, function for extended range
  9786. * may be needed: @ref LL_ADC_REG_ReadConversionData32.
  9787. * @rmtoll DR RDATA LL_ADC_REG_ReadConversionData12
  9788. * @param ADCx ADC instance
  9789. * @retval Value between Min_Data=0x000 and Max_Data=0xFFF
  9790. */
  9791. __STATIC_INLINE uint16_t LL_ADC_REG_ReadConversionData12(ADC_TypeDef *ADCx)
  9792. {
  9793. return (uint16_t)(READ_BIT(ADCx->DR, ADC_DR_DATA));
  9794. }
  9795. /**
  9796. * @}
  9797. */
  9798. /** @defgroup ADC_LL_EF_Operation_ADC_Group_Injected Operation on ADC hierarchical scope: group injected
  9799. * @{
  9800. */
  9801. /**
  9802. * @brief Start ADC group injected conversion.
  9803. * @note On this STM32 series, this function is relevant for both
  9804. * internal trigger (SW start) and external trigger:
  9805. * - If ADC trigger has been set to software start, ADC conversion
  9806. * starts immediately.
  9807. * - If ADC trigger has been set to external trigger, ADC conversion
  9808. * will start at next trigger event (on the selected trigger edge)
  9809. * following the ADC start conversion command.
  9810. * @rmtoll CR2 JEXTTRIG LL_ADC_REG_StartConversion
  9811. * @param ADCx ADC instance
  9812. * @retval None
  9813. */
  9814. __STATIC_INLINE void LL_ADC_INJ_StartConversion(ADC_TypeDef *ADCx)
  9815. {
  9816. /* Note: Set bit ADC_CR2_JSWSTART for case of trigger source set to */
  9817. /* SW start. In case of external trigger selected, this bit */
  9818. /* has no effect. */
  9819. SET_BIT(ADCx->CR2, (ADC_CR2_JSWSTART | ADC_CR2_JEXTTRIG));
  9820. }
  9821. /**
  9822. * @brief Stop ADC group injected conversion from external trigger.
  9823. * @note No more ADC conversion will start at next trigger event
  9824. * following the ADC stop conversion command.
  9825. * If a conversion is on-going, it will be completed.
  9826. * @note On this STM32 series, there is no specific command
  9827. * to stop a conversion on-going or to stop ADC converting
  9828. * in continuous mode. These actions can be performed
  9829. * using function @ref LL_ADC_Disable().
  9830. * @rmtoll CR2 JEXTSEL LL_ADC_INJ_StopConversionExtTrig
  9831. * @param ADCx ADC instance
  9832. * @retval None
  9833. */
  9834. __STATIC_INLINE void LL_ADC_INJ_StopConversionExtTrig(ADC_TypeDef *ADCx)
  9835. {
  9836. SET_BIT(ADCx->CR2, ADC_CR2_JEXTSEL);
  9837. }
  9838. /**
  9839. * @brief Get ADC group regular conversion data, range fit for
  9840. * all ADC configurations: all ADC resolutions and
  9841. * all oversampling increased data width (for devices
  9842. * with feature oversampling).
  9843. * @rmtoll JDR1 JDATA LL_ADC_INJ_ReadConversionData32\n
  9844. * JDR2 JDATA LL_ADC_INJ_ReadConversionData32\n
  9845. * JDR3 JDATA LL_ADC_INJ_ReadConversionData32\n
  9846. * JDR4 JDATA LL_ADC_INJ_ReadConversionData32
  9847. * @param ADCx ADC instance
  9848. * @param Rank This parameter can be one of the following values:
  9849. * @arg @ref LL_ADC_INJ_RANK_1
  9850. * @arg @ref LL_ADC_INJ_RANK_2
  9851. * @arg @ref LL_ADC_INJ_RANK_3
  9852. * @arg @ref LL_ADC_INJ_RANK_4
  9853. * @retval Value between Min_Data=0x00000000 and Max_Data=0xFFFFFFFF
  9854. */
  9855. __STATIC_INLINE uint32_t LL_ADC_INJ_ReadConversionData32(ADC_TypeDef *ADCx, uint32_t Rank)
  9856. {
  9857. __IO uint32_t *preg = __ADC_PTR_REG_OFFSET(ADCx->JDR1, __ADC_MASK_SHIFT(Rank, ADC_INJ_JDRX_REGOFFSET_MASK));
  9858. return (uint32_t)(READ_BIT(*preg,
  9859. ADC_JDR1_JDATA)
  9860. );
  9861. }
  9862. /**
  9863. * @brief Get ADC group injected conversion data, range fit for
  9864. * ADC resolution 12 bits.
  9865. * @note For devices with feature oversampling: Oversampling
  9866. * can increase data width, function for extended range
  9867. * may be needed: @ref LL_ADC_INJ_ReadConversionData32.
  9868. * @rmtoll JDR1 JDATA LL_ADC_INJ_ReadConversionData12\n
  9869. * JDR2 JDATA LL_ADC_INJ_ReadConversionData12\n
  9870. * JDR3 JDATA LL_ADC_INJ_ReadConversionData12\n
  9871. * JDR4 JDATA LL_ADC_INJ_ReadConversionData12
  9872. * @param ADCx ADC instance
  9873. * @param Rank This parameter can be one of the following values:
  9874. * @arg @ref LL_ADC_INJ_RANK_1
  9875. * @arg @ref LL_ADC_INJ_RANK_2
  9876. * @arg @ref LL_ADC_INJ_RANK_3
  9877. * @arg @ref LL_ADC_INJ_RANK_4
  9878. * @retval Value between Min_Data=0x000 and Max_Data=0xFFF
  9879. */
  9880. __STATIC_INLINE uint16_t LL_ADC_INJ_ReadConversionData12(ADC_TypeDef *ADCx, uint32_t Rank)
  9881. {
  9882. __IO uint32_t *preg = __ADC_PTR_REG_OFFSET(ADCx->JDR1, __ADC_MASK_SHIFT(Rank, ADC_INJ_JDRX_REGOFFSET_MASK));
  9883. return (uint16_t)(READ_BIT(*preg,
  9884. ADC_JDR1_JDATA)
  9885. );
  9886. }
  9887. /**
  9888. * @}
  9889. */
  9890. /** @defgroup ADC_LL_EF_FLAG_Management ADC flag management
  9891. * @{
  9892. */
  9893. /**
  9894. * @brief Get flag ADC group regular end of sequence conversions.
  9895. * @rmtoll SR EOC LL_ADC_IsActiveFlag_EOS
  9896. * @param ADCx ADC instance
  9897. * @retval State of bit (1 or 0).
  9898. */
  9899. __STATIC_INLINE uint32_t LL_ADC_IsActiveFlag_EOS(ADC_TypeDef *ADCx)
  9900. {
  9901. /* Note: on this STM32 series, there is no flag ADC group regular */
  9902. /* end of unitary conversion. */
  9903. /* Flag noted as "EOC" is corresponding to flag "EOS" */
  9904. /* in other STM32 families). */
  9905. return (READ_BIT(ADCx->SR, LL_ADC_FLAG_EOS) == (LL_ADC_FLAG_EOS));
  9906. }
  9907. /**
  9908. * @brief Get flag ADC group injected end of sequence conversions.
  9909. * @rmtoll SR JEOC LL_ADC_IsActiveFlag_JEOS
  9910. * @param ADCx ADC instance
  9911. * @retval State of bit (1 or 0).
  9912. */
  9913. __STATIC_INLINE uint32_t LL_ADC_IsActiveFlag_JEOS(ADC_TypeDef *ADCx)
  9914. {
  9915. /* Note: on this STM32 series, there is no flag ADC group injected */
  9916. /* end of unitary conversion. */
  9917. /* Flag noted as "JEOC" is corresponding to flag "JEOS" */
  9918. /* in other STM32 families). */
  9919. return (READ_BIT(ADCx->SR, LL_ADC_FLAG_JEOS) == (LL_ADC_FLAG_JEOS));
  9920. }
  9921. /**
  9922. * @brief Get flag ADC analog watchdog 1 flag
  9923. * @rmtoll SR AWD LL_ADC_IsActiveFlag_AWD1
  9924. * @param ADCx ADC instance
  9925. * @retval State of bit (1 or 0).
  9926. */
  9927. __STATIC_INLINE uint32_t LL_ADC_IsActiveFlag_AWD1(ADC_TypeDef *ADCx)
  9928. {
  9929. return (READ_BIT(ADCx->SR, LL_ADC_FLAG_AWD1) == (LL_ADC_FLAG_AWD1));
  9930. }
  9931. /**
  9932. * @brief Clear flag ADC group regular end of sequence conversions.
  9933. * @rmtoll SR EOC LL_ADC_ClearFlag_EOS
  9934. * @param ADCx ADC instance
  9935. * @retval None
  9936. */
  9937. __STATIC_INLINE void LL_ADC_ClearFlag_EOS(ADC_TypeDef *ADCx)
  9938. {
  9939. /* Note: on this STM32 series, there is no flag ADC group regular */
  9940. /* end of unitary conversion. */
  9941. /* Flag noted as "EOC" is corresponding to flag "EOS" */
  9942. /* in other STM32 families). */
  9943. WRITE_REG(ADCx->SR, ~LL_ADC_FLAG_EOS);
  9944. }
  9945. /**
  9946. * @brief Clear flag ADC group injected end of sequence conversions.
  9947. * @rmtoll SR JEOC LL_ADC_ClearFlag_JEOS
  9948. * @param ADCx ADC instance
  9949. * @retval None
  9950. */
  9951. __STATIC_INLINE void LL_ADC_ClearFlag_JEOS(ADC_TypeDef *ADCx)
  9952. {
  9953. /* Note: on this STM32 series, there is no flag ADC group injected */
  9954. /* end of unitary conversion. */
  9955. /* Flag noted as "JEOC" is corresponding to flag "JEOS" */
  9956. /* in other STM32 families). */
  9957. WRITE_REG(ADCx->SR, ~LL_ADC_FLAG_JEOS);
  9958. }
  9959. /**
  9960. * @brief Clear flag ADC analog watchdog 1.
  9961. * @rmtoll SR AWD LL_ADC_ClearFlag_AWD1
  9962. * @param ADCx ADC instance
  9963. * @retval None
  9964. */
  9965. __STATIC_INLINE void LL_ADC_ClearFlag_AWD1(ADC_TypeDef *ADCx)
  9966. {
  9967. WRITE_REG(ADCx->SR, ~LL_ADC_FLAG_AWD1);
  9968. }
  9969. /**
  9970. * @}
  9971. */
  9972. /** @defgroup ADC_LL_EF_IT_Management ADC IT management
  9973. * @{
  9974. */
  9975. /**
  9976. * @brief Enable interruption ADC group regular end of sequence conversions.
  9977. * @rmtoll CR1 EOCIE LL_ADC_EnableIT_EOS
  9978. * @param ADCx ADC instance
  9979. * @retval None
  9980. */
  9981. __STATIC_INLINE void LL_ADC_EnableIT_EOS(ADC_TypeDef *ADCx)
  9982. {
  9983. /* Note: on this STM32 series, there is no flag ADC group regular */
  9984. /* end of unitary conversion. */
  9985. /* Flag noted as "EOC" is corresponding to flag "EOS" */
  9986. /* in other STM32 families). */
  9987. SET_BIT(ADCx->CR1, ADC_CR1_EOCIE);
  9988. }
  9989. /**
  9990. * @brief Enable interruption ADC group injected end of sequence conversions.
  9991. * @rmtoll CR1 JEOCIE LL_ADC_EnableIT_JEOS
  9992. * @param ADCx ADC instance
  9993. * @retval None
  9994. */
  9995. __STATIC_INLINE void LL_ADC_EnableIT_JEOS(ADC_TypeDef *ADCx)
  9996. {
  9997. /* Note: on this STM32 series, there is no flag ADC group injected */
  9998. /* end of unitary conversion. */
  9999. /* Flag noted as "JEOC" is corresponding to flag "JEOS" */
  10000. /* in other STM32 families). */
  10001. SET_BIT(ADCx->CR1, LL_ADC_IT_JEOS);
  10002. }
  10003. /**
  10004. * @brief Enable interruption ADC analog watchdog 1.
  10005. * @rmtoll CR1 AWDIE LL_ADC_EnableIT_AWD1
  10006. * @param ADCx ADC instance
  10007. * @retval None
  10008. */
  10009. __STATIC_INLINE void LL_ADC_EnableIT_AWD1(ADC_TypeDef *ADCx)
  10010. {
  10011. SET_BIT(ADCx->CR1, LL_ADC_IT_AWD1);
  10012. }
  10013. /**
  10014. * @brief Disable interruption ADC group regular end of sequence conversions.
  10015. * @rmtoll CR1 EOCIE LL_ADC_DisableIT_EOS
  10016. * @param ADCx ADC instance
  10017. * @retval None
  10018. */
  10019. __STATIC_INLINE void LL_ADC_DisableIT_EOS(ADC_TypeDef *ADCx)
  10020. {
  10021. /* Note: on this STM32 series, there is no flag ADC group regular */
  10022. /* end of unitary conversion. */
  10023. /* Flag noted as "EOC" is corresponding to flag "EOS" */
  10024. /* in other STM32 families). */
  10025. CLEAR_BIT(ADCx->CR1, ADC_CR1_EOCIE);
  10026. }
  10027. /**
  10028. * @brief Disable interruption ADC group injected end of sequence conversions.
  10029. * @rmtoll CR1 JEOCIE LL_ADC_EnableIT_JEOS
  10030. * @param ADCx ADC instance
  10031. * @retval None
  10032. */
  10033. __STATIC_INLINE void LL_ADC_DisableIT_JEOS(ADC_TypeDef *ADCx)
  10034. {
  10035. /* Note: on this STM32 series, there is no flag ADC group injected */
  10036. /* end of unitary conversion. */
  10037. /* Flag noted as "JEOC" is corresponding to flag "JEOS" */
  10038. /* in other STM32 families). */
  10039. CLEAR_BIT(ADCx->CR1, LL_ADC_IT_JEOS);
  10040. }
  10041. /**
  10042. * @brief Disable interruption ADC analog watchdog 1.
  10043. * @rmtoll CR1 AWDIE LL_ADC_EnableIT_AWD1
  10044. * @param ADCx ADC instance
  10045. * @retval None
  10046. */
  10047. __STATIC_INLINE void LL_ADC_DisableIT_AWD1(ADC_TypeDef *ADCx)
  10048. {
  10049. CLEAR_BIT(ADCx->CR1, LL_ADC_IT_AWD1);
  10050. }
  10051. /**
  10052. * @brief Get state of interruption ADC group regular end of sequence conversions
  10053. * (0: interrupt disabled, 1: interrupt enabled).
  10054. * @rmtoll CR1 EOCIE LL_ADC_IsEnabledIT_EOS
  10055. * @param ADCx ADC instance
  10056. * @retval State of bit (1 or 0).
  10057. */
  10058. __STATIC_INLINE uint32_t LL_ADC_IsEnabledIT_EOS(ADC_TypeDef *ADCx)
  10059. {
  10060. /* Note: on this STM32 series, there is no flag ADC group regular */
  10061. /* end of unitary conversion. */
  10062. /* Flag noted as "EOC" is corresponding to flag "EOS" */
  10063. /* in other STM32 families). */
  10064. return (READ_BIT(ADCx->CR1, LL_ADC_IT_EOS) == (LL_ADC_IT_EOS));
  10065. }
  10066. /**
  10067. * @brief Get state of interruption ADC group injected end of sequence conversions
  10068. * (0: interrupt disabled, 1: interrupt enabled).
  10069. * @rmtoll CR1 JEOCIE LL_ADC_EnableIT_JEOS
  10070. * @param ADCx ADC instance
  10071. * @retval State of bit (1 or 0).
  10072. */
  10073. __STATIC_INLINE uint32_t LL_ADC_IsEnabledIT_JEOS(ADC_TypeDef *ADCx)
  10074. {
  10075. /* Note: on this STM32 series, there is no flag ADC group injected */
  10076. /* end of unitary conversion. */
  10077. /* Flag noted as "JEOC" is corresponding to flag "JEOS" */
  10078. /* in other STM32 families). */
  10079. return (READ_BIT(ADCx->CR1, LL_ADC_IT_JEOS) == (LL_ADC_IT_JEOS));
  10080. }
  10081. /**
  10082. * @brief Get state of interruption ADC analog watchdog 1
  10083. * (0: interrupt disabled, 1: interrupt enabled).
  10084. * @rmtoll CR1 AWDIE LL_ADC_EnableIT_AWD1
  10085. * @param ADCx ADC instance
  10086. * @retval State of bit (1 or 0).
  10087. */
  10088. __STATIC_INLINE uint32_t LL_ADC_IsEnabledIT_AWD1(ADC_TypeDef *ADCx)
  10089. {
  10090. return (READ_BIT(ADCx->CR1, LL_ADC_IT_AWD1) == (LL_ADC_IT_AWD1));
  10091. }
  10092. /**
  10093. * @}
  10094. */
  10095. #if defined(USE_FULL_LL_DRIVER)
  10096. /** @defgroup ADC_LL_EF_Init Initialization and de-initialization functions
  10097. * @{
  10098. */
  10099. /* Initialization of some features of ADC common parameters and multimode */
  10100. /* Note: On STM32F37x ADC, there is no ADC common initialization */
  10101. /* function. */
  10102. ErrorStatus LL_ADC_CommonDeInit(ADC_Common_TypeDef *ADCxy_COMMON);
  10103. /* De-initialization of ADC instance, ADC group regular and ADC group injected */
  10104. /* (availability of ADC group injected depends on STM32 families) */
  10105. ErrorStatus LL_ADC_DeInit(ADC_TypeDef *ADCx);
  10106. /* Initialization of some features of ADC instance */
  10107. ErrorStatus LL_ADC_Init(ADC_TypeDef *ADCx, LL_ADC_InitTypeDef *ADC_InitStruct);
  10108. void LL_ADC_StructInit(LL_ADC_InitTypeDef *ADC_InitStruct);
  10109. /* Initialization of some features of ADC instance and ADC group regular */
  10110. ErrorStatus LL_ADC_REG_Init(ADC_TypeDef *ADCx, LL_ADC_REG_InitTypeDef *ADC_REG_InitStruct);
  10111. void LL_ADC_REG_StructInit(LL_ADC_REG_InitTypeDef *ADC_REG_InitStruct);
  10112. /* Initialization of some features of ADC instance and ADC group injected */
  10113. ErrorStatus LL_ADC_INJ_Init(ADC_TypeDef *ADCx, LL_ADC_INJ_InitTypeDef *ADC_INJ_InitStruct);
  10114. void LL_ADC_INJ_StructInit(LL_ADC_INJ_InitTypeDef *ADC_INJ_InitStruct);
  10115. /**
  10116. * @}
  10117. */
  10118. #endif /* USE_FULL_LL_DRIVER */
  10119. /**
  10120. * @}
  10121. */
  10122. /**
  10123. * @}
  10124. */
  10125. #endif /* ADC1 */
  10126. #endif /* STM32F373xC || STM32F378xx */
  10127. /**
  10128. * @}
  10129. */
  10130. #ifdef __cplusplus
  10131. }
  10132. #endif
  10133. #endif /* __STM32F3xx_LL_ADC_H */