stm32f4xx_ll_adc.h 277 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744
  1. /**
  2. ******************************************************************************
  3. * @file stm32f4xx_ll_adc.h
  4. * @author MCD Application Team
  5. * @brief Header file of ADC LL module.
  6. ******************************************************************************
  7. * @attention
  8. *
  9. * <h2><center>&copy; Copyright (c) 2017 STMicroelectronics.
  10. * All rights reserved.</center></h2>
  11. *
  12. * This software component is licensed by ST under BSD 3-Clause license,
  13. * the "License"; You may not use this file except in compliance with the
  14. * License. You may obtain a copy of the License at:
  15. * opensource.org/licenses/BSD-3-Clause
  16. *
  17. ******************************************************************************
  18. */
  19. /* Define to prevent recursive inclusion -------------------------------------*/
  20. #ifndef __STM32F4xx_LL_ADC_H
  21. #define __STM32F4xx_LL_ADC_H
  22. #ifdef __cplusplus
  23. extern "C" {
  24. #endif
  25. /* Includes ------------------------------------------------------------------*/
  26. #include "stm32f4xx.h"
  27. /** @addtogroup STM32F4xx_LL_Driver
  28. * @{
  29. */
  30. #if defined (ADC1) || defined (ADC2) || defined (ADC3)
  31. /** @defgroup ADC_LL ADC
  32. * @{
  33. */
  34. /* Private types -------------------------------------------------------------*/
  35. /* Private variables ---------------------------------------------------------*/
  36. /* Private constants ---------------------------------------------------------*/
  37. /** @defgroup ADC_LL_Private_Constants ADC Private Constants
  38. * @{
  39. */
  40. /* Internal mask for ADC group regular sequencer: */
  41. /* To select into literal LL_ADC_REG_RANK_x the relevant bits for: */
  42. /* - sequencer register offset */
  43. /* - sequencer rank bits position into the selected register */
  44. /* Internal register offset for ADC group regular sequencer configuration */
  45. /* (offset placed into a spare area of literal definition) */
  46. #define ADC_SQR1_REGOFFSET 0x00000000U
  47. #define ADC_SQR2_REGOFFSET 0x00000100U
  48. #define ADC_SQR3_REGOFFSET 0x00000200U
  49. #define ADC_SQR4_REGOFFSET 0x00000300U
  50. #define ADC_REG_SQRX_REGOFFSET_MASK (ADC_SQR1_REGOFFSET | ADC_SQR2_REGOFFSET | ADC_SQR3_REGOFFSET | ADC_SQR4_REGOFFSET)
  51. #define ADC_REG_RANK_ID_SQRX_MASK (ADC_CHANNEL_ID_NUMBER_MASK_POSBIT0)
  52. /* Definition of ADC group regular sequencer bits information to be inserted */
  53. /* into ADC group regular sequencer ranks literals definition. */
  54. #define ADC_REG_RANK_1_SQRX_BITOFFSET_POS ( 0U) /* Value equivalent to POSITION_VAL(ADC_SQR3_SQ1) */
  55. #define ADC_REG_RANK_2_SQRX_BITOFFSET_POS ( 5U) /* Value equivalent to POSITION_VAL(ADC_SQR3_SQ2) */
  56. #define ADC_REG_RANK_3_SQRX_BITOFFSET_POS (10U) /* Value equivalent to POSITION_VAL(ADC_SQR3_SQ3) */
  57. #define ADC_REG_RANK_4_SQRX_BITOFFSET_POS (15U) /* Value equivalent to POSITION_VAL(ADC_SQR3_SQ4) */
  58. #define ADC_REG_RANK_5_SQRX_BITOFFSET_POS (20U) /* Value equivalent to POSITION_VAL(ADC_SQR3_SQ5) */
  59. #define ADC_REG_RANK_6_SQRX_BITOFFSET_POS (25U) /* Value equivalent to POSITION_VAL(ADC_SQR3_SQ6) */
  60. #define ADC_REG_RANK_7_SQRX_BITOFFSET_POS ( 0U) /* Value equivalent to POSITION_VAL(ADC_SQR2_SQ7) */
  61. #define ADC_REG_RANK_8_SQRX_BITOFFSET_POS ( 5U) /* Value equivalent to POSITION_VAL(ADC_SQR2_SQ8) */
  62. #define ADC_REG_RANK_9_SQRX_BITOFFSET_POS (10U) /* Value equivalent to POSITION_VAL(ADC_SQR2_SQ9) */
  63. #define ADC_REG_RANK_10_SQRX_BITOFFSET_POS (15U) /* Value equivalent to POSITION_VAL(ADC_SQR2_SQ10) */
  64. #define ADC_REG_RANK_11_SQRX_BITOFFSET_POS (20U) /* Value equivalent to POSITION_VAL(ADC_SQR2_SQ11) */
  65. #define ADC_REG_RANK_12_SQRX_BITOFFSET_POS (25U) /* Value equivalent to POSITION_VAL(ADC_SQR2_SQ12) */
  66. #define ADC_REG_RANK_13_SQRX_BITOFFSET_POS ( 0U) /* Value equivalent to POSITION_VAL(ADC_SQR1_SQ13) */
  67. #define ADC_REG_RANK_14_SQRX_BITOFFSET_POS ( 5U) /* Value equivalent to POSITION_VAL(ADC_SQR1_SQ14) */
  68. #define ADC_REG_RANK_15_SQRX_BITOFFSET_POS (10U) /* Value equivalent to POSITION_VAL(ADC_SQR1_SQ15) */
  69. #define ADC_REG_RANK_16_SQRX_BITOFFSET_POS (15U) /* Value equivalent to POSITION_VAL(ADC_SQR1_SQ16) */
  70. /* Internal mask for ADC group injected sequencer: */
  71. /* To select into literal LL_ADC_INJ_RANK_x the relevant bits for: */
  72. /* - data register offset */
  73. /* - offset register offset */
  74. /* - sequencer rank bits position into the selected register */
  75. /* Internal register offset for ADC group injected data register */
  76. /* (offset placed into a spare area of literal definition) */
  77. #define ADC_JDR1_REGOFFSET 0x00000000U
  78. #define ADC_JDR2_REGOFFSET 0x00000100U
  79. #define ADC_JDR3_REGOFFSET 0x00000200U
  80. #define ADC_JDR4_REGOFFSET 0x00000300U
  81. /* Internal register offset for ADC group injected offset configuration */
  82. /* (offset placed into a spare area of literal definition) */
  83. #define ADC_JOFR1_REGOFFSET 0x00000000U
  84. #define ADC_JOFR2_REGOFFSET 0x00001000U
  85. #define ADC_JOFR3_REGOFFSET 0x00002000U
  86. #define ADC_JOFR4_REGOFFSET 0x00003000U
  87. #define ADC_INJ_JDRX_REGOFFSET_MASK (ADC_JDR1_REGOFFSET | ADC_JDR2_REGOFFSET | ADC_JDR3_REGOFFSET | ADC_JDR4_REGOFFSET)
  88. #define ADC_INJ_JOFRX_REGOFFSET_MASK (ADC_JOFR1_REGOFFSET | ADC_JOFR2_REGOFFSET | ADC_JOFR3_REGOFFSET | ADC_JOFR4_REGOFFSET)
  89. #define ADC_INJ_RANK_ID_JSQR_MASK (ADC_CHANNEL_ID_NUMBER_MASK_POSBIT0)
  90. /* Internal mask for ADC group regular trigger: */
  91. /* To select into literal LL_ADC_REG_TRIG_x the relevant bits for: */
  92. /* - regular trigger source */
  93. /* - regular trigger edge */
  94. #define ADC_REG_TRIG_EXT_EDGE_DEFAULT (ADC_CR2_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) */
  95. /* Mask containing trigger source masks for each of possible */
  96. /* trigger edge selection duplicated with shifts [0; 4; 8; 12] */
  97. /* corresponding to {SW start; ext trigger; ext trigger; ext trigger}. */
  98. #define ADC_REG_TRIG_SOURCE_MASK (((LL_ADC_REG_TRIG_SOFTWARE & ADC_CR2_EXTSEL) >> (4U * 0U)) | \
  99. ((ADC_CR2_EXTSEL) >> (4U * 1U)) | \
  100. ((ADC_CR2_EXTSEL) >> (4U * 2U)) | \
  101. ((ADC_CR2_EXTSEL) >> (4U * 3U)))
  102. /* Mask containing trigger edge masks for each of possible */
  103. /* trigger edge selection duplicated with shifts [0; 4; 8; 12] */
  104. /* corresponding to {SW start; ext trigger; ext trigger; ext trigger}. */
  105. #define ADC_REG_TRIG_EDGE_MASK (((LL_ADC_REG_TRIG_SOFTWARE & ADC_CR2_EXTEN) >> (4U * 0U)) | \
  106. ((ADC_REG_TRIG_EXT_EDGE_DEFAULT) >> (4U * 1U)) | \
  107. ((ADC_REG_TRIG_EXT_EDGE_DEFAULT) >> (4U * 2U)) | \
  108. ((ADC_REG_TRIG_EXT_EDGE_DEFAULT) >> (4U * 3U)))
  109. /* Definition of ADC group regular trigger bits information. */
  110. #define ADC_REG_TRIG_EXTSEL_BITOFFSET_POS (24U) /* Value equivalent to POSITION_VAL(ADC_CR2_EXTSEL) */
  111. #define ADC_REG_TRIG_EXTEN_BITOFFSET_POS (28U) /* Value equivalent to POSITION_VAL(ADC_CR2_EXTEN) */
  112. /* Internal mask for ADC group injected trigger: */
  113. /* To select into literal LL_ADC_INJ_TRIG_x the relevant bits for: */
  114. /* - injected trigger source */
  115. /* - injected trigger edge */
  116. #define ADC_INJ_TRIG_EXT_EDGE_DEFAULT (ADC_CR2_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) */
  117. /* Mask containing trigger source masks for each of possible */
  118. /* trigger edge selection duplicated with shifts [0; 4; 8; 12] */
  119. /* corresponding to {SW start; ext trigger; ext trigger; ext trigger}. */
  120. #define ADC_INJ_TRIG_SOURCE_MASK (((LL_ADC_REG_TRIG_SOFTWARE & ADC_CR2_JEXTSEL) >> (4U * 0U)) | \
  121. ((ADC_CR2_JEXTSEL) >> (4U * 1U)) | \
  122. ((ADC_CR2_JEXTSEL) >> (4U * 2U)) | \
  123. ((ADC_CR2_JEXTSEL) >> (4U * 3U)))
  124. /* Mask containing trigger edge masks for each of possible */
  125. /* trigger edge selection duplicated with shifts [0; 4; 8; 12] */
  126. /* corresponding to {SW start; ext trigger; ext trigger; ext trigger}. */
  127. #define ADC_INJ_TRIG_EDGE_MASK (((LL_ADC_INJ_TRIG_SOFTWARE & ADC_CR2_JEXTEN) >> (4U * 0U)) | \
  128. ((ADC_INJ_TRIG_EXT_EDGE_DEFAULT) >> (4U * 1U)) | \
  129. ((ADC_INJ_TRIG_EXT_EDGE_DEFAULT) >> (4U * 2U)) | \
  130. ((ADC_INJ_TRIG_EXT_EDGE_DEFAULT) >> (4U * 3U)))
  131. /* Definition of ADC group injected trigger bits information. */
  132. #define ADC_INJ_TRIG_EXTSEL_BITOFFSET_POS (16U) /* Value equivalent to POSITION_VAL(ADC_CR2_JEXTSEL) */
  133. #define ADC_INJ_TRIG_EXTEN_BITOFFSET_POS (20U) /* Value equivalent to POSITION_VAL(ADC_CR2_JEXTEN) */
  134. /* Internal mask for ADC channel: */
  135. /* To select into literal LL_ADC_CHANNEL_x the relevant bits for: */
  136. /* - channel identifier defined by number */
  137. /* - channel differentiation between external channels (connected to */
  138. /* GPIO pins) and internal channels (connected to internal paths) */
  139. /* - channel sampling time defined by SMPRx register offset */
  140. /* and SMPx bits positions into SMPRx register */
  141. #define ADC_CHANNEL_ID_NUMBER_MASK (ADC_CR1_AWDCH)
  142. #define ADC_CHANNEL_ID_NUMBER_BITOFFSET_POS ( 0U)/* Value equivalent to POSITION_VAL(ADC_CHANNEL_ID_NUMBER_MASK) */
  143. #define ADC_CHANNEL_ID_MASK (ADC_CHANNEL_ID_NUMBER_MASK | ADC_CHANNEL_ID_INTERNAL_CH_MASK)
  144. /* Equivalent mask of ADC_CHANNEL_NUMBER_MASK aligned on register LSB (bit 0) */
  145. #define ADC_CHANNEL_ID_NUMBER_MASK_POSBIT0 0x0000001FU /* Equivalent to shift: (ADC_CHANNEL_NUMBER_MASK >> POSITION_VAL(ADC_CHANNEL_NUMBER_MASK)) */
  146. /* Channel differentiation between external and internal channels */
  147. #define ADC_CHANNEL_ID_INTERNAL_CH 0x80000000U /* Marker of internal channel */
  148. #define ADC_CHANNEL_ID_INTERNAL_CH_2 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 */
  149. #define ADC_CHANNEL_DIFFERENCIATION_TEMPSENSOR_VBAT 0x10000000U /* Dummy bit for driver internal usage, not used in ADC channel setting registers CR1 or SQRx */
  150. #define ADC_CHANNEL_ID_INTERNAL_CH_MASK (ADC_CHANNEL_ID_INTERNAL_CH | ADC_CHANNEL_ID_INTERNAL_CH_2 | ADC_CHANNEL_DIFFERENCIATION_TEMPSENSOR_VBAT)
  151. /* Internal register offset for ADC channel sampling time configuration */
  152. /* (offset placed into a spare area of literal definition) */
  153. #define ADC_SMPR1_REGOFFSET 0x00000000U
  154. #define ADC_SMPR2_REGOFFSET 0x02000000U
  155. #define ADC_CHANNEL_SMPRX_REGOFFSET_MASK (ADC_SMPR1_REGOFFSET | ADC_SMPR2_REGOFFSET)
  156. #define ADC_CHANNEL_SMPx_BITOFFSET_MASK 0x01F00000U
  157. #define ADC_CHANNEL_SMPx_BITOFFSET_POS (20U) /* Value equivalent to POSITION_VAL(ADC_CHANNEL_SMPx_BITOFFSET_MASK) */
  158. /* Definition of channels ID number information to be inserted into */
  159. /* channels literals definition. */
  160. #define ADC_CHANNEL_0_NUMBER 0x00000000U
  161. #define ADC_CHANNEL_1_NUMBER ( ADC_CR1_AWDCH_0)
  162. #define ADC_CHANNEL_2_NUMBER ( ADC_CR1_AWDCH_1 )
  163. #define ADC_CHANNEL_3_NUMBER ( ADC_CR1_AWDCH_1 | ADC_CR1_AWDCH_0)
  164. #define ADC_CHANNEL_4_NUMBER ( ADC_CR1_AWDCH_2 )
  165. #define ADC_CHANNEL_5_NUMBER ( ADC_CR1_AWDCH_2 | ADC_CR1_AWDCH_0)
  166. #define ADC_CHANNEL_6_NUMBER ( ADC_CR1_AWDCH_2 | ADC_CR1_AWDCH_1 )
  167. #define ADC_CHANNEL_7_NUMBER ( ADC_CR1_AWDCH_2 | ADC_CR1_AWDCH_1 | ADC_CR1_AWDCH_0)
  168. #define ADC_CHANNEL_8_NUMBER ( ADC_CR1_AWDCH_3 )
  169. #define ADC_CHANNEL_9_NUMBER ( ADC_CR1_AWDCH_3 | ADC_CR1_AWDCH_0)
  170. #define ADC_CHANNEL_10_NUMBER ( ADC_CR1_AWDCH_3 | ADC_CR1_AWDCH_1 )
  171. #define ADC_CHANNEL_11_NUMBER ( ADC_CR1_AWDCH_3 | ADC_CR1_AWDCH_1 | ADC_CR1_AWDCH_0)
  172. #define ADC_CHANNEL_12_NUMBER ( ADC_CR1_AWDCH_3 | ADC_CR1_AWDCH_2 )
  173. #define ADC_CHANNEL_13_NUMBER ( ADC_CR1_AWDCH_3 | ADC_CR1_AWDCH_2 | ADC_CR1_AWDCH_0)
  174. #define ADC_CHANNEL_14_NUMBER ( ADC_CR1_AWDCH_3 | ADC_CR1_AWDCH_2 | ADC_CR1_AWDCH_1 )
  175. #define ADC_CHANNEL_15_NUMBER ( ADC_CR1_AWDCH_3 | ADC_CR1_AWDCH_2 | ADC_CR1_AWDCH_1 | ADC_CR1_AWDCH_0)
  176. #define ADC_CHANNEL_16_NUMBER (ADC_CR1_AWDCH_4 )
  177. #define ADC_CHANNEL_17_NUMBER (ADC_CR1_AWDCH_4 | ADC_CR1_AWDCH_0)
  178. #define ADC_CHANNEL_18_NUMBER (ADC_CR1_AWDCH_4 | ADC_CR1_AWDCH_1 )
  179. /* Definition of channels sampling time information to be inserted into */
  180. /* channels literals definition. */
  181. #define ADC_CHANNEL_0_SMP (ADC_SMPR2_REGOFFSET | (( 0U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR2_SMP0) */
  182. #define ADC_CHANNEL_1_SMP (ADC_SMPR2_REGOFFSET | (( 3U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR2_SMP1) */
  183. #define ADC_CHANNEL_2_SMP (ADC_SMPR2_REGOFFSET | (( 6U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR2_SMP2) */
  184. #define ADC_CHANNEL_3_SMP (ADC_SMPR2_REGOFFSET | (( 9U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR2_SMP3) */
  185. #define ADC_CHANNEL_4_SMP (ADC_SMPR2_REGOFFSET | ((12U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR2_SMP4) */
  186. #define ADC_CHANNEL_5_SMP (ADC_SMPR2_REGOFFSET | ((15U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR2_SMP5) */
  187. #define ADC_CHANNEL_6_SMP (ADC_SMPR2_REGOFFSET | ((18U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR2_SMP6) */
  188. #define ADC_CHANNEL_7_SMP (ADC_SMPR2_REGOFFSET | ((21U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR2_SMP7) */
  189. #define ADC_CHANNEL_8_SMP (ADC_SMPR2_REGOFFSET | ((24U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR2_SMP8) */
  190. #define ADC_CHANNEL_9_SMP (ADC_SMPR2_REGOFFSET | ((27U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR2_SMP9) */
  191. #define ADC_CHANNEL_10_SMP (ADC_SMPR1_REGOFFSET | (( 0U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR1_SMP10) */
  192. #define ADC_CHANNEL_11_SMP (ADC_SMPR1_REGOFFSET | (( 3U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR1_SMP11) */
  193. #define ADC_CHANNEL_12_SMP (ADC_SMPR1_REGOFFSET | (( 6U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR1_SMP12) */
  194. #define ADC_CHANNEL_13_SMP (ADC_SMPR1_REGOFFSET | (( 9U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR1_SMP13) */
  195. #define ADC_CHANNEL_14_SMP (ADC_SMPR1_REGOFFSET | ((12U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR1_SMP14) */
  196. #define ADC_CHANNEL_15_SMP (ADC_SMPR1_REGOFFSET | ((15U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR1_SMP15) */
  197. #define ADC_CHANNEL_16_SMP (ADC_SMPR1_REGOFFSET | ((18U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR1_SMP16) */
  198. #define ADC_CHANNEL_17_SMP (ADC_SMPR1_REGOFFSET | ((21U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR1_SMP17) */
  199. #define ADC_CHANNEL_18_SMP (ADC_SMPR1_REGOFFSET | ((24U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR1_SMP18) */
  200. /* Internal mask for ADC analog watchdog: */
  201. /* To select into literals LL_ADC_AWD_CHANNELx_xxx the relevant bits for: */
  202. /* (concatenation of multiple bits used in different analog watchdogs, */
  203. /* (feature of several watchdogs not available on all STM32 families)). */
  204. /* - analog watchdog 1: monitored channel defined by number, */
  205. /* selection of ADC group (ADC groups regular and-or injected). */
  206. /* Internal register offset for ADC analog watchdog channel configuration */
  207. #define ADC_AWD_CR1_REGOFFSET 0x00000000U
  208. #define ADC_AWD_CRX_REGOFFSET_MASK (ADC_AWD_CR1_REGOFFSET)
  209. #define ADC_AWD_CR1_CHANNEL_MASK (ADC_CR1_AWDCH | ADC_CR1_JAWDEN | ADC_CR1_AWDEN | ADC_CR1_AWDSGL)
  210. #define ADC_AWD_CR_ALL_CHANNEL_MASK (ADC_AWD_CR1_CHANNEL_MASK)
  211. /* Internal register offset for ADC analog watchdog threshold configuration */
  212. #define ADC_AWD_TR1_HIGH_REGOFFSET 0x00000000U
  213. #define ADC_AWD_TR1_LOW_REGOFFSET 0x00000001U
  214. #define ADC_AWD_TRX_REGOFFSET_MASK (ADC_AWD_TR1_HIGH_REGOFFSET | ADC_AWD_TR1_LOW_REGOFFSET)
  215. /* ADC registers bits positions */
  216. #define ADC_CR1_RES_BITOFFSET_POS (24U) /* Value equivalent to POSITION_VAL(ADC_CR1_RES) */
  217. #define ADC_TR_HT_BITOFFSET_POS (16U) /* Value equivalent to POSITION_VAL(ADC_TR_HT) */
  218. /* ADC internal channels related definitions */
  219. /* Internal voltage reference VrefInt */
  220. #define VREFINT_CAL_ADDR ((uint16_t*) (0x1FFF7A2AU)) /* 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). */
  221. #define VREFINT_CAL_VREF ( 3300U) /* Analog voltage reference (Vref+) value with which temperature sensor has been calibrated in production (tolerance: +-10 mV) (unit: mV). */
  222. /* Temperature sensor */
  223. #define TEMPSENSOR_CAL1_ADDR ((uint16_t*) (0x1FFF7A2CU)) /* Internal temperature sensor, address of parameter TS_CAL1: On STM32F4, temperature sensor ADC raw data acquired at temperature 30 DegC (tolerance: +-5 DegC), Vref+ = 3.3 V (tolerance: +-10 mV). */
  224. #define TEMPSENSOR_CAL2_ADDR ((uint16_t*) (0x1FFF7A2EU)) /* Internal temperature sensor, address of parameter TS_CAL2: On STM32F4, temperature sensor ADC raw data acquired at temperature 110 DegC (tolerance: +-5 DegC), Vref+ = 3.3 V (tolerance: +-10 mV). */
  225. #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). */
  226. #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). */
  227. #define TEMPSENSOR_CAL_VREFANALOG ( 3300U) /* Analog voltage reference (Vref+) voltage with which temperature sensor has been calibrated in production (+-10 mV) (unit: mV). */
  228. /**
  229. * @}
  230. */
  231. /* Private macros ------------------------------------------------------------*/
  232. /** @defgroup ADC_LL_Private_Macros ADC Private Macros
  233. * @{
  234. */
  235. /**
  236. * @brief Driver macro reserved for internal use: isolate bits with the
  237. * selected mask and shift them to the register LSB
  238. * (shift mask on register position bit 0).
  239. * @param __BITS__ Bits in register 32 bits
  240. * @param __MASK__ Mask in register 32 bits
  241. * @retval Bits in register 32 bits
  242. */
  243. #define __ADC_MASK_SHIFT(__BITS__, __MASK__) \
  244. (((__BITS__) & (__MASK__)) >> POSITION_VAL((__MASK__)))
  245. /**
  246. * @brief Driver macro reserved for internal use: set a pointer to
  247. * a register from a register basis from which an offset
  248. * is applied.
  249. * @param __REG__ Register basis from which the offset is applied.
  250. * @param __REG_OFFFSET__ Offset to be applied (unit number of registers).
  251. * @retval Pointer to register address
  252. */
  253. #define __ADC_PTR_REG_OFFSET(__REG__, __REG_OFFFSET__) \
  254. ((__IO uint32_t *)((uint32_t) ((uint32_t)(&(__REG__)) + ((__REG_OFFFSET__) << 2U))))
  255. /**
  256. * @}
  257. */
  258. /* Exported types ------------------------------------------------------------*/
  259. #if defined(USE_FULL_LL_DRIVER)
  260. /** @defgroup ADC_LL_ES_INIT ADC Exported Init structure
  261. * @{
  262. */
  263. /**
  264. * @brief Structure definition of some features of ADC common parameters
  265. * and multimode
  266. * (all ADC instances belonging to the same ADC common instance).
  267. * @note The setting of these parameters by function @ref LL_ADC_CommonInit()
  268. * is conditioned to ADC instances state (all ADC instances
  269. * sharing the same ADC common instance):
  270. * All ADC instances sharing the same ADC common instance must be
  271. * disabled.
  272. */
  273. typedef struct
  274. {
  275. uint32_t CommonClock; /*!< Set parameter common to several ADC: Clock source and prescaler.
  276. This parameter can be a value of @ref ADC_LL_EC_COMMON_CLOCK_SOURCE
  277. This feature can be modified afterwards using unitary function @ref LL_ADC_SetCommonClock(). */
  278. #if defined(ADC_MULTIMODE_SUPPORT)
  279. uint32_t Multimode; /*!< Set ADC multimode configuration to operate in independent mode or multimode (for devices with several ADC instances).
  280. This parameter can be a value of @ref ADC_LL_EC_MULTI_MODE
  281. This feature can be modified afterwards using unitary function @ref LL_ADC_SetMultimode(). */
  282. uint32_t MultiDMATransfer; /*!< Set ADC multimode conversion data transfer: no transfer or transfer by DMA.
  283. This parameter can be a value of @ref ADC_LL_EC_MULTI_DMA_TRANSFER
  284. This feature can be modified afterwards using unitary function @ref LL_ADC_SetMultiDMATransfer(). */
  285. uint32_t MultiTwoSamplingDelay; /*!< Set ADC multimode delay between 2 sampling phases.
  286. This parameter can be a value of @ref ADC_LL_EC_MULTI_TWOSMP_DELAY
  287. This feature can be modified afterwards using unitary function @ref LL_ADC_SetMultiTwoSamplingDelay(). */
  288. #endif /* ADC_MULTIMODE_SUPPORT */
  289. } LL_ADC_CommonInitTypeDef;
  290. /**
  291. * @brief Structure definition of some features of ADC instance.
  292. * @note These parameters have an impact on ADC scope: ADC instance.
  293. * Affects both group regular and group injected (availability
  294. * of ADC group injected depends on STM32 families).
  295. * Refer to corresponding unitary functions into
  296. * @ref ADC_LL_EF_Configuration_ADC_Instance .
  297. * @note The setting of these parameters by function @ref LL_ADC_Init()
  298. * is conditioned to ADC state:
  299. * ADC instance must be disabled.
  300. * This condition is applied to all ADC features, for efficiency
  301. * and compatibility over all STM32 families. However, the different
  302. * features can be set under different ADC state conditions
  303. * (setting possible with ADC enabled without conversion on going,
  304. * ADC enabled with conversion on going, ...)
  305. * Each feature can be updated afterwards with a unitary function
  306. * and potentially with ADC in a different state than disabled,
  307. * refer to description of each function for setting
  308. * conditioned to ADC state.
  309. */
  310. typedef struct
  311. {
  312. uint32_t Resolution; /*!< Set ADC resolution.
  313. This parameter can be a value of @ref ADC_LL_EC_RESOLUTION
  314. This feature can be modified afterwards using unitary function @ref LL_ADC_SetResolution(). */
  315. uint32_t DataAlignment; /*!< Set ADC conversion data alignment.
  316. This parameter can be a value of @ref ADC_LL_EC_DATA_ALIGN
  317. This feature can be modified afterwards using unitary function @ref LL_ADC_SetDataAlignment(). */
  318. uint32_t SequencersScanMode; /*!< Set ADC scan selection.
  319. This parameter can be a value of @ref ADC_LL_EC_SCAN_SELECTION
  320. This feature can be modified afterwards using unitary function @ref LL_ADC_SetSequencersScanMode(). */
  321. } LL_ADC_InitTypeDef;
  322. /**
  323. * @brief Structure definition of some features of ADC group regular.
  324. * @note These parameters have an impact on ADC scope: ADC group regular.
  325. * Refer to corresponding unitary functions into
  326. * @ref ADC_LL_EF_Configuration_ADC_Group_Regular
  327. * (functions with prefix "REG").
  328. * @note The setting of these parameters by function @ref LL_ADC_REG_Init()
  329. * is conditioned to ADC state:
  330. * ADC instance must be disabled.
  331. * This condition is applied to all ADC features, for efficiency
  332. * and compatibility over all STM32 families. However, the different
  333. * features can be set under different ADC state conditions
  334. * (setting possible with ADC enabled without conversion on going,
  335. * ADC enabled with conversion on going, ...)
  336. * Each feature can be updated afterwards with a unitary function
  337. * and potentially with ADC in a different state than disabled,
  338. * refer to description of each function for setting
  339. * conditioned to ADC state.
  340. */
  341. typedef struct
  342. {
  343. uint32_t TriggerSource; /*!< Set ADC group regular conversion trigger source: internal (SW start) or from external IP (timer event, external interrupt line).
  344. This parameter can be a value of @ref ADC_LL_EC_REG_TRIGGER_SOURCE
  345. @note On this STM32 serie, setting of external trigger edge is performed
  346. using function @ref LL_ADC_REG_StartConversionExtTrig().
  347. This feature can be modified afterwards using unitary function @ref LL_ADC_REG_SetTriggerSource(). */
  348. uint32_t SequencerLength; /*!< Set ADC group regular sequencer length.
  349. This parameter can be a value of @ref ADC_LL_EC_REG_SEQ_SCAN_LENGTH
  350. @note This parameter is discarded if scan mode is disabled (refer to parameter 'ADC_SequencersScanMode').
  351. This feature can be modified afterwards using unitary function @ref LL_ADC_REG_SetSequencerLength(). */
  352. uint32_t SequencerDiscont; /*!< Set ADC group regular sequencer discontinuous mode: sequence subdivided and scan conversions interrupted every selected number of ranks.
  353. This parameter can be a value of @ref ADC_LL_EC_REG_SEQ_DISCONT_MODE
  354. @note This parameter has an effect only if group regular sequencer is enabled
  355. (scan length of 2 ranks or more).
  356. This feature can be modified afterwards using unitary function @ref LL_ADC_REG_SetSequencerDiscont(). */
  357. 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).
  358. This parameter can be a value of @ref ADC_LL_EC_REG_CONTINUOUS_MODE
  359. Note: It is not possible to enable both ADC group regular continuous mode and discontinuous mode.
  360. This feature can be modified afterwards using unitary function @ref LL_ADC_REG_SetContinuousMode(). */
  361. uint32_t DMATransfer; /*!< Set ADC group regular conversion data transfer: no transfer or transfer by DMA, and DMA requests mode.
  362. This parameter can be a value of @ref ADC_LL_EC_REG_DMA_TRANSFER
  363. This feature can be modified afterwards using unitary function @ref LL_ADC_REG_SetDMATransfer(). */
  364. } LL_ADC_REG_InitTypeDef;
  365. /**
  366. * @brief Structure definition of some features of ADC group injected.
  367. * @note These parameters have an impact on ADC scope: ADC group injected.
  368. * Refer to corresponding unitary functions into
  369. * @ref ADC_LL_EF_Configuration_ADC_Group_Regular
  370. * (functions with prefix "INJ").
  371. * @note The setting of these parameters by function @ref LL_ADC_INJ_Init()
  372. * is conditioned to ADC state:
  373. * ADC instance must be disabled.
  374. * This condition is applied to all ADC features, for efficiency
  375. * and compatibility over all STM32 families. However, the different
  376. * features can be set under different ADC state conditions
  377. * (setting possible with ADC enabled without conversion on going,
  378. * ADC enabled with conversion on going, ...)
  379. * Each feature can be updated afterwards with a unitary function
  380. * and potentially with ADC in a different state than disabled,
  381. * refer to description of each function for setting
  382. * conditioned to ADC state.
  383. */
  384. typedef struct
  385. {
  386. uint32_t TriggerSource; /*!< Set ADC group injected conversion trigger source: internal (SW start) or from external IP (timer event, external interrupt line).
  387. This parameter can be a value of @ref ADC_LL_EC_INJ_TRIGGER_SOURCE
  388. @note On this STM32 serie, setting of external trigger edge is performed
  389. using function @ref LL_ADC_INJ_StartConversionExtTrig().
  390. This feature can be modified afterwards using unitary function @ref LL_ADC_INJ_SetTriggerSource(). */
  391. uint32_t SequencerLength; /*!< Set ADC group injected sequencer length.
  392. This parameter can be a value of @ref ADC_LL_EC_INJ_SEQ_SCAN_LENGTH
  393. @note This parameter is discarded if scan mode is disabled (refer to parameter 'ADC_SequencersScanMode').
  394. This feature can be modified afterwards using unitary function @ref LL_ADC_INJ_SetSequencerLength(). */
  395. uint32_t SequencerDiscont; /*!< Set ADC group injected sequencer discontinuous mode: sequence subdivided and scan conversions interrupted every selected number of ranks.
  396. This parameter can be a value of @ref ADC_LL_EC_INJ_SEQ_DISCONT_MODE
  397. @note This parameter has an effect only if group injected sequencer is enabled
  398. (scan length of 2 ranks or more).
  399. This feature can be modified afterwards using unitary function @ref LL_ADC_INJ_SetSequencerDiscont(). */
  400. uint32_t TrigAuto; /*!< Set ADC group injected conversion trigger: independent or from ADC group regular.
  401. This parameter can be a value of @ref ADC_LL_EC_INJ_TRIG_AUTO
  402. Note: This parameter must be set to set to independent trigger if injected trigger source is set to an external trigger.
  403. This feature can be modified afterwards using unitary function @ref LL_ADC_INJ_SetTrigAuto(). */
  404. } LL_ADC_INJ_InitTypeDef;
  405. /**
  406. * @}
  407. */
  408. #endif /* USE_FULL_LL_DRIVER */
  409. /* Exported constants --------------------------------------------------------*/
  410. /** @defgroup ADC_LL_Exported_Constants ADC Exported Constants
  411. * @{
  412. */
  413. /** @defgroup ADC_LL_EC_FLAG ADC flags
  414. * @brief Flags defines which can be used with LL_ADC_ReadReg function
  415. * @{
  416. */
  417. #define LL_ADC_FLAG_STRT ADC_SR_STRT /*!< ADC flag ADC group regular conversion start */
  418. #define LL_ADC_FLAG_EOCS ADC_SR_EOC /*!< ADC flag ADC group regular end of unitary conversion or sequence conversions (to configure flag of end of conversion, use function @ref LL_ADC_REG_SetFlagEndOfConversion() ) */
  419. #define LL_ADC_FLAG_OVR ADC_SR_OVR /*!< ADC flag ADC group regular overrun */
  420. #define LL_ADC_FLAG_JSTRT ADC_SR_JSTRT /*!< ADC flag ADC group injected conversion start */
  421. #define LL_ADC_FLAG_JEOS ADC_SR_JEOC /*!< ADC flag ADC group injected end of sequence conversions (Note: on this STM32 serie, there is no flag ADC group injected end of unitary conversion. Flag noted as "JEOC" is corresponding to flag "JEOS" in other STM32 families) */
  422. #define LL_ADC_FLAG_AWD1 ADC_SR_AWD /*!< ADC flag ADC analog watchdog 1 */
  423. #if defined(ADC_MULTIMODE_SUPPORT)
  424. #define LL_ADC_FLAG_EOCS_MST ADC_CSR_EOC1 /*!< ADC flag ADC multimode master group regular end of unitary conversion or sequence conversions (to configure flag of end of conversion, use function @ref LL_ADC_REG_SetFlagEndOfConversion() ) */
  425. #define LL_ADC_FLAG_EOCS_SLV1 ADC_CSR_EOC2 /*!< ADC flag ADC multimode slave 1 group regular end of unitary conversion or sequence conversions (to configure flag of end of conversion, use function @ref LL_ADC_REG_SetFlagEndOfConversion() ) */
  426. #define LL_ADC_FLAG_EOCS_SLV2 ADC_CSR_EOC3 /*!< ADC flag ADC multimode slave 2 group regular end of unitary conversion or sequence conversions (to configure flag of end of conversion, use function @ref LL_ADC_REG_SetFlagEndOfConversion() ) */
  427. #define LL_ADC_FLAG_OVR_MST ADC_CSR_OVR1 /*!< ADC flag ADC multimode master group regular overrun */
  428. #define LL_ADC_FLAG_OVR_SLV1 ADC_CSR_OVR2 /*!< ADC flag ADC multimode slave 1 group regular overrun */
  429. #define LL_ADC_FLAG_OVR_SLV2 ADC_CSR_OVR3 /*!< ADC flag ADC multimode slave 2 group regular overrun */
  430. #define LL_ADC_FLAG_JEOS_MST ADC_CSR_JEOC1 /*!< ADC flag ADC multimode master group injected end of sequence conversions (Note: on this STM32 serie, there is no flag ADC group injected end of unitary conversion. Flag noted as "JEOC" is corresponding to flag "JEOS" in other STM32 families) */
  431. #define LL_ADC_FLAG_JEOS_SLV1 ADC_CSR_JEOC2 /*!< ADC flag ADC multimode slave 1 group injected end of sequence conversions (Note: on this STM32 serie, there is no flag ADC group injected end of unitary conversion. Flag noted as "JEOC" is corresponding to flag "JEOS" in other STM32 families) */
  432. #define LL_ADC_FLAG_JEOS_SLV2 ADC_CSR_JEOC3 /*!< ADC flag ADC multimode slave 2 group injected end of sequence conversions (Note: on this STM32 serie, there is no flag ADC group injected end of unitary conversion. Flag noted as "JEOC" is corresponding to flag "JEOS" in other STM32 families) */
  433. #define LL_ADC_FLAG_AWD1_MST ADC_CSR_AWD1 /*!< ADC flag ADC multimode master analog watchdog 1 of the ADC master */
  434. #define LL_ADC_FLAG_AWD1_SLV1 ADC_CSR_AWD2 /*!< ADC flag ADC multimode slave 1 analog watchdog 1 */
  435. #define LL_ADC_FLAG_AWD1_SLV2 ADC_CSR_AWD3 /*!< ADC flag ADC multimode slave 2 analog watchdog 1 */
  436. #endif
  437. /**
  438. * @}
  439. */
  440. /** @defgroup ADC_LL_EC_IT ADC interruptions for configuration (interruption enable or disable)
  441. * @brief IT defines which can be used with LL_ADC_ReadReg and LL_ADC_WriteReg functions
  442. * @{
  443. */
  444. #define LL_ADC_IT_EOCS ADC_CR1_EOCIE /*!< ADC interruption ADC group regular end of unitary conversion or sequence conversions (to configure flag of end of conversion, use function @ref LL_ADC_REG_SetFlagEndOfConversion() ) */
  445. #define LL_ADC_IT_OVR ADC_CR1_OVRIE /*!< ADC interruption ADC group regular overrun */
  446. #define LL_ADC_IT_JEOS ADC_CR1_JEOCIE /*!< ADC interruption ADC group injected end of sequence conversions (Note: on this STM32 serie, there is no flag ADC group injected end of unitary conversion. Flag noted as "JEOC" is corresponding to flag "JEOS" in other STM32 families) */
  447. #define LL_ADC_IT_AWD1 ADC_CR1_AWDIE /*!< ADC interruption ADC analog watchdog 1 */
  448. /**
  449. * @}
  450. */
  451. /** @defgroup ADC_LL_EC_REGISTERS ADC registers compliant with specific purpose
  452. * @{
  453. */
  454. /* List of ADC registers intended to be used (most commonly) with */
  455. /* DMA transfer. */
  456. /* Refer to function @ref LL_ADC_DMA_GetRegAddr(). */
  457. #define LL_ADC_DMA_REG_REGULAR_DATA 0x00000000U /* ADC group regular conversion data register (corresponding to register DR) to be used with ADC configured in independent mode. Without DMA transfer, register accessed by LL function @ref LL_ADC_REG_ReadConversionData32() and other functions @ref LL_ADC_REG_ReadConversionDatax() */
  458. #if defined(ADC_MULTIMODE_SUPPORT)
  459. #define LL_ADC_DMA_REG_REGULAR_DATA_MULTI 0x00000001U /* ADC group regular conversion data register (corresponding to register CDR) to be used with ADC configured in multimode (available on STM32 devices with several ADC instances). Without DMA transfer, register accessed by LL function @ref LL_ADC_REG_ReadMultiConversionData32() */
  460. #endif
  461. /**
  462. * @}
  463. */
  464. /** @defgroup ADC_LL_EC_COMMON_CLOCK_SOURCE ADC common - Clock source
  465. * @{
  466. */
  467. #define LL_ADC_CLOCK_SYNC_PCLK_DIV2 0x00000000U /*!< ADC synchronous clock derived from AHB clock with prescaler division by 2 */
  468. #define LL_ADC_CLOCK_SYNC_PCLK_DIV4 ( ADC_CCR_ADCPRE_0) /*!< ADC synchronous clock derived from AHB clock with prescaler division by 4 */
  469. #define LL_ADC_CLOCK_SYNC_PCLK_DIV6 (ADC_CCR_ADCPRE_1 ) /*!< ADC synchronous clock derived from AHB clock with prescaler division by 6 */
  470. #define LL_ADC_CLOCK_SYNC_PCLK_DIV8 (ADC_CCR_ADCPRE_1 | ADC_CCR_ADCPRE_0) /*!< ADC synchronous clock derived from AHB clock with prescaler division by 8 */
  471. /**
  472. * @}
  473. */
  474. /** @defgroup ADC_LL_EC_COMMON_PATH_INTERNAL ADC common - Measurement path to internal channels
  475. * @{
  476. */
  477. /* Note: Other measurement paths to internal channels may be available */
  478. /* (connections to other peripherals). */
  479. /* If they are not listed below, they do not require any specific */
  480. /* path enable. In this case, Access to measurement path is done */
  481. /* only by selecting the corresponding ADC internal channel. */
  482. #define LL_ADC_PATH_INTERNAL_NONE 0x00000000U /*!< ADC measurement pathes all disabled */
  483. #define LL_ADC_PATH_INTERNAL_VREFINT (ADC_CCR_TSVREFE) /*!< ADC measurement path to internal channel VrefInt */
  484. #define LL_ADC_PATH_INTERNAL_TEMPSENSOR (ADC_CCR_TSVREFE) /*!< ADC measurement path to internal channel temperature sensor */
  485. #define LL_ADC_PATH_INTERNAL_VBAT (ADC_CCR_VBATE) /*!< ADC measurement path to internal channel Vbat */
  486. /**
  487. * @}
  488. */
  489. /** @defgroup ADC_LL_EC_RESOLUTION ADC instance - Resolution
  490. * @{
  491. */
  492. #define LL_ADC_RESOLUTION_12B 0x00000000U /*!< ADC resolution 12 bits */
  493. #define LL_ADC_RESOLUTION_10B ( ADC_CR1_RES_0) /*!< ADC resolution 10 bits */
  494. #define LL_ADC_RESOLUTION_8B (ADC_CR1_RES_1 ) /*!< ADC resolution 8 bits */
  495. #define LL_ADC_RESOLUTION_6B (ADC_CR1_RES_1 | ADC_CR1_RES_0) /*!< ADC resolution 6 bits */
  496. /**
  497. * @}
  498. */
  499. /** @defgroup ADC_LL_EC_DATA_ALIGN ADC instance - Data alignment
  500. * @{
  501. */
  502. #define LL_ADC_DATA_ALIGN_RIGHT 0x00000000U /*!< ADC conversion data alignment: right aligned (alignment on data register LSB bit 0)*/
  503. #define LL_ADC_DATA_ALIGN_LEFT (ADC_CR2_ALIGN) /*!< ADC conversion data alignment: left aligned (aligment on data register MSB bit 15)*/
  504. /**
  505. * @}
  506. */
  507. /** @defgroup ADC_LL_EC_SCAN_SELECTION ADC instance - Scan selection
  508. * @{
  509. */
  510. #define LL_ADC_SEQ_SCAN_DISABLE 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.*/
  511. #define LL_ADC_SEQ_SCAN_ENABLE (ADC_CR1_SCAN) /*!< ADC conversions are performed in sequence conversions mode, according to configuration of both groups regular and injected sequencers (sequence length, ...). */
  512. /**
  513. * @}
  514. */
  515. /** @defgroup ADC_LL_EC_GROUPS ADC instance - Groups
  516. * @{
  517. */
  518. #define LL_ADC_GROUP_REGULAR 0x00000001U /*!< ADC group regular (available on all STM32 devices) */
  519. #define LL_ADC_GROUP_INJECTED 0x00000002U /*!< ADC group injected (not available on all STM32 devices)*/
  520. #define LL_ADC_GROUP_REGULAR_INJECTED 0x00000003U /*!< ADC both groups regular and injected */
  521. /**
  522. * @}
  523. */
  524. /** @defgroup ADC_LL_EC_CHANNEL ADC instance - Channel number
  525. * @{
  526. */
  527. #define LL_ADC_CHANNEL_0 (ADC_CHANNEL_0_NUMBER | ADC_CHANNEL_0_SMP) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN0 */
  528. #define LL_ADC_CHANNEL_1 (ADC_CHANNEL_1_NUMBER | ADC_CHANNEL_1_SMP) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN1 */
  529. #define LL_ADC_CHANNEL_2 (ADC_CHANNEL_2_NUMBER | ADC_CHANNEL_2_SMP) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN2 */
  530. #define LL_ADC_CHANNEL_3 (ADC_CHANNEL_3_NUMBER | ADC_CHANNEL_3_SMP) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN3 */
  531. #define LL_ADC_CHANNEL_4 (ADC_CHANNEL_4_NUMBER | ADC_CHANNEL_4_SMP) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN4 */
  532. #define LL_ADC_CHANNEL_5 (ADC_CHANNEL_5_NUMBER | ADC_CHANNEL_5_SMP) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN5 */
  533. #define LL_ADC_CHANNEL_6 (ADC_CHANNEL_6_NUMBER | ADC_CHANNEL_6_SMP) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN6 */
  534. #define LL_ADC_CHANNEL_7 (ADC_CHANNEL_7_NUMBER | ADC_CHANNEL_7_SMP) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN7 */
  535. #define LL_ADC_CHANNEL_8 (ADC_CHANNEL_8_NUMBER | ADC_CHANNEL_8_SMP) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN8 */
  536. #define LL_ADC_CHANNEL_9 (ADC_CHANNEL_9_NUMBER | ADC_CHANNEL_9_SMP) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN9 */
  537. #define LL_ADC_CHANNEL_10 (ADC_CHANNEL_10_NUMBER | ADC_CHANNEL_10_SMP) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN10 */
  538. #define LL_ADC_CHANNEL_11 (ADC_CHANNEL_11_NUMBER | ADC_CHANNEL_11_SMP) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN11 */
  539. #define LL_ADC_CHANNEL_12 (ADC_CHANNEL_12_NUMBER | ADC_CHANNEL_12_SMP) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN12 */
  540. #define LL_ADC_CHANNEL_13 (ADC_CHANNEL_13_NUMBER | ADC_CHANNEL_13_SMP) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN13 */
  541. #define LL_ADC_CHANNEL_14 (ADC_CHANNEL_14_NUMBER | ADC_CHANNEL_14_SMP) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN14 */
  542. #define LL_ADC_CHANNEL_15 (ADC_CHANNEL_15_NUMBER | ADC_CHANNEL_15_SMP) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN15 */
  543. #define LL_ADC_CHANNEL_16 (ADC_CHANNEL_16_NUMBER | ADC_CHANNEL_16_SMP) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN16 */
  544. #define LL_ADC_CHANNEL_17 (ADC_CHANNEL_17_NUMBER | ADC_CHANNEL_17_SMP) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN17 */
  545. #define LL_ADC_CHANNEL_18 (ADC_CHANNEL_18_NUMBER | ADC_CHANNEL_18_SMP) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN18 */
  546. #define LL_ADC_CHANNEL_VREFINT (LL_ADC_CHANNEL_17 | ADC_CHANNEL_ID_INTERNAL_CH) /*!< ADC internal channel connected to VrefInt: Internal voltage reference. On STM32F4, ADC channel available only on ADC instance: ADC1. */
  547. #define LL_ADC_CHANNEL_VBAT (LL_ADC_CHANNEL_18 | ADC_CHANNEL_ID_INTERNAL_CH) /*!< ADC internal channel connected to Vbat/3: Vbat voltage through a divider ladder of factor 1/3 to have Vbat always below Vdda. On STM32F4, ADC channel available only on ADC instance: ADC1. */
  548. #if defined(STM32F401xC) || defined(STM32F401xE) || defined(STM32F405xx) || defined(STM32F407xx) || defined(STM32F410Tx) || defined(STM32F410Cx) || defined(STM32F410Rx) || defined(STM32F415xx) || defined(STM32F417xx)
  549. #define LL_ADC_CHANNEL_TEMPSENSOR (LL_ADC_CHANNEL_16 | ADC_CHANNEL_ID_INTERNAL_CH) /*!< ADC internal channel connected to Temperature sensor. On STM32F4, ADC channel available only on ADC instance: ADC1. */
  550. #endif /* STM32F405xx || STM32F415xx || STM32F407xx || STM32F417xx || STM32F401xC || STM32F401xE || STM32F410xx */
  551. #if defined(STM32F411xE) || defined(STM32F412Cx) || defined(STM32F412Rx) || defined(STM32F412Vx) || defined(STM32F412Zx) || defined(STM32F413xx) || defined(STM32F423xx) || defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx) || defined(STM32F446xx) || defined(STM32F469xx) || defined(STM32F479xx)
  552. #define LL_ADC_CHANNEL_TEMPSENSOR (LL_ADC_CHANNEL_18 | ADC_CHANNEL_ID_INTERNAL_CH | ADC_CHANNEL_DIFFERENCIATION_TEMPSENSOR_VBAT) /*!< ADC internal channel connected to Temperature sensor. On STM32F4, ADC channel available only on ADC instance: ADC1. This internal channel is shared between temperature sensor and Vbat, only 1 measurement path must be enabled. */
  553. #endif /* STM32F411xE || STM32F412Cx || STM32F412Rx || STM32F412Vx || STM32F412Zx || STM32F413xx || STM32F423xx || STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx || STM32F446xx || STM32F469xx || STM32F479xx */
  554. /**
  555. * @}
  556. */
  557. /** @defgroup ADC_LL_EC_REG_TRIGGER_SOURCE ADC group regular - Trigger source
  558. * @{
  559. */
  560. #define LL_ADC_REG_TRIG_SOFTWARE 0x00000000U /*!< ADC group regular conversion trigger internal: SW start. */
  561. #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). */
  562. #define LL_ADC_REG_TRIG_EXT_TIM1_CH2 (ADC_CR2_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). */
  563. #define LL_ADC_REG_TRIG_EXT_TIM1_CH3 (ADC_CR2_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). */
  564. #define LL_ADC_REG_TRIG_EXT_TIM2_CH2 (ADC_CR2_EXTSEL_1 | ADC_CR2_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). */
  565. #define LL_ADC_REG_TRIG_EXT_TIM2_CH3 (ADC_CR2_EXTSEL_2 | 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). */
  566. #define LL_ADC_REG_TRIG_EXT_TIM2_CH4 (ADC_CR2_EXTSEL_2 | ADC_CR2_EXTSEL_0 | ADC_REG_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group regular conversion trigger from external IP: TIM2 channel 4 event (capture compare: input capture or output capture). Trigger edge set to rising edge (default setting). */
  567. #define LL_ADC_REG_TRIG_EXT_TIM2_TRGO (ADC_CR2_EXTSEL_2 | ADC_CR2_EXTSEL_1 | ADC_REG_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group regular conversion trigger from external IP: TIM2 TRGO. Trigger edge set to rising edge (default setting). */
  568. #define LL_ADC_REG_TRIG_EXT_TIM3_CH1 (ADC_CR2_EXTSEL_2 | ADC_CR2_EXTSEL_1 | ADC_CR2_EXTSEL_0 | 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). */
  569. #define LL_ADC_REG_TRIG_EXT_TIM3_TRGO (ADC_CR2_EXTSEL_3 | ADC_REG_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group regular conversion trigger from external IP: TIM3 TRGO. Trigger edge set to rising edge (default setting). */
  570. #define LL_ADC_REG_TRIG_EXT_TIM4_CH4 (ADC_CR2_EXTSEL_3 | ADC_CR2_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). */
  571. #define LL_ADC_REG_TRIG_EXT_TIM5_CH1 (ADC_CR2_EXTSEL_3 | ADC_CR2_EXTSEL_1 | ADC_REG_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group regular conversion trigger from external IP: TIM5 channel 1 event (capture compare: input capture or output capture). Trigger edge set to rising edge (default setting). */
  572. #define LL_ADC_REG_TRIG_EXT_TIM5_CH2 (ADC_CR2_EXTSEL_3 | ADC_CR2_EXTSEL_1 | ADC_CR2_EXTSEL_0 | ADC_REG_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group regular conversion trigger from external IP: TIM5 channel 2 event (capture compare: input capture or output capture). Trigger edge set to rising edge (default setting). */
  573. #define LL_ADC_REG_TRIG_EXT_TIM5_CH3 (ADC_CR2_EXTSEL_3 | ADC_CR2_EXTSEL_2 | ADC_REG_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group regular conversion trigger from external IP: TIM5 channel 3 event (capture compare: input capture or output capture). Trigger edge set to rising edge (default setting). */
  574. #define LL_ADC_REG_TRIG_EXT_TIM8_CH1 (ADC_CR2_EXTSEL_3 | ADC_CR2_EXTSEL_2 | ADC_CR2_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). */
  575. #define LL_ADC_REG_TRIG_EXT_TIM8_TRGO (ADC_CR2_EXTSEL_3 | ADC_CR2_EXTSEL_2 | ADC_CR2_EXTSEL_1 | ADC_REG_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group regular conversion trigger from external IP: TIM8 TRGO. Trigger edge set to rising edge (default setting). */
  576. #define LL_ADC_REG_TRIG_EXT_EXTI_LINE11 (ADC_CR2_EXTSEL_3 | ADC_CR2_EXTSEL_2 | ADC_CR2_EXTSEL_1 | ADC_CR2_EXTSEL_0 | 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). */
  577. /**
  578. * @}
  579. */
  580. /** @defgroup ADC_LL_EC_REG_TRIGGER_EDGE ADC group regular - Trigger edge
  581. * @{
  582. */
  583. #define LL_ADC_REG_TRIG_EXT_RISING ( ADC_CR2_EXTEN_0) /*!< ADC group regular conversion trigger polarity set to rising edge */
  584. #define LL_ADC_REG_TRIG_EXT_FALLING (ADC_CR2_EXTEN_1 ) /*!< ADC group regular conversion trigger polarity set to falling edge */
  585. #define LL_ADC_REG_TRIG_EXT_RISINGFALLING (ADC_CR2_EXTEN_1 | ADC_CR2_EXTEN_0) /*!< ADC group regular conversion trigger polarity set to both rising and falling edges */
  586. /**
  587. * @}
  588. */
  589. /** @defgroup ADC_LL_EC_REG_CONTINUOUS_MODE ADC group regular - Continuous mode
  590. * @{
  591. */
  592. #define LL_ADC_REG_CONV_SINGLE 0x00000000U /*!< ADC conversions are performed in single mode: one conversion per trigger */
  593. #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 */
  594. /**
  595. * @}
  596. */
  597. /** @defgroup ADC_LL_EC_REG_DMA_TRANSFER ADC group regular - DMA transfer of ADC conversion data
  598. * @{
  599. */
  600. #define LL_ADC_REG_DMA_TRANSFER_NONE 0x00000000U /*!< ADC conversions are not transferred by DMA */
  601. #define LL_ADC_REG_DMA_TRANSFER_LIMITED ( ADC_CR2_DMA) /*!< 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. */
  602. #define LL_ADC_REG_DMA_TRANSFER_UNLIMITED (ADC_CR2_DDS | ADC_CR2_DMA) /*!< 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. */
  603. /**
  604. * @}
  605. */
  606. /** @defgroup ADC_LL_EC_REG_FLAG_EOC_SELECTION ADC group regular - Flag EOC selection (unitary or sequence conversions)
  607. * @{
  608. */
  609. #define LL_ADC_REG_FLAG_EOC_SEQUENCE_CONV 0x00000000U /*!< ADC flag EOC (end of unitary conversion) selected */
  610. #define LL_ADC_REG_FLAG_EOC_UNITARY_CONV (ADC_CR2_EOCS) /*!< ADC flag EOS (end of sequence conversions) selected */
  611. /**
  612. * @}
  613. */
  614. /** @defgroup ADC_LL_EC_REG_SEQ_SCAN_LENGTH ADC group regular - Sequencer scan length
  615. * @{
  616. */
  617. #define LL_ADC_REG_SEQ_SCAN_DISABLE 0x00000000U /*!< ADC group regular sequencer disable (equivalent to sequencer of 1 rank: ADC conversion on only 1 channel) */
  618. #define LL_ADC_REG_SEQ_SCAN_ENABLE_2RANKS ( ADC_SQR1_L_0) /*!< ADC group regular sequencer enable with 2 ranks in the sequence */
  619. #define LL_ADC_REG_SEQ_SCAN_ENABLE_3RANKS ( ADC_SQR1_L_1 ) /*!< ADC group regular sequencer enable with 3 ranks in the sequence */
  620. #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 */
  621. #define LL_ADC_REG_SEQ_SCAN_ENABLE_5RANKS ( ADC_SQR1_L_2 ) /*!< ADC group regular sequencer enable with 5 ranks in the sequence */
  622. #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 */
  623. #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 */
  624. #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 */
  625. #define LL_ADC_REG_SEQ_SCAN_ENABLE_9RANKS (ADC_SQR1_L_3 ) /*!< ADC group regular sequencer enable with 9 ranks in the sequence */
  626. #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 */
  627. #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 */
  628. #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 */
  629. #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 */
  630. #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 */
  631. #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 */
  632. #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 */
  633. /**
  634. * @}
  635. */
  636. /** @defgroup ADC_LL_EC_REG_SEQ_DISCONT_MODE ADC group regular - Sequencer discontinuous mode
  637. * @{
  638. */
  639. #define LL_ADC_REG_SEQ_DISCONT_DISABLE 0x00000000U /*!< ADC group regular sequencer discontinuous mode disable */
  640. #define LL_ADC_REG_SEQ_DISCONT_1RANK ( ADC_CR1_DISCEN) /*!< ADC group regular sequencer discontinuous mode enable with sequence interruption every rank */
  641. #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 */
  642. #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 */
  643. #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 */
  644. #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 */
  645. #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 */
  646. #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 */
  647. #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 */
  648. /**
  649. * @}
  650. */
  651. /** @defgroup ADC_LL_EC_REG_SEQ_RANKS ADC group regular - Sequencer ranks
  652. * @{
  653. */
  654. #define LL_ADC_REG_RANK_1 (ADC_SQR3_REGOFFSET | ADC_REG_RANK_1_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 1 */
  655. #define LL_ADC_REG_RANK_2 (ADC_SQR3_REGOFFSET | ADC_REG_RANK_2_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 2 */
  656. #define LL_ADC_REG_RANK_3 (ADC_SQR3_REGOFFSET | ADC_REG_RANK_3_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 3 */
  657. #define LL_ADC_REG_RANK_4 (ADC_SQR3_REGOFFSET | ADC_REG_RANK_4_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 4 */
  658. #define LL_ADC_REG_RANK_5 (ADC_SQR3_REGOFFSET | ADC_REG_RANK_5_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 5 */
  659. #define LL_ADC_REG_RANK_6 (ADC_SQR3_REGOFFSET | ADC_REG_RANK_6_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 6 */
  660. #define LL_ADC_REG_RANK_7 (ADC_SQR2_REGOFFSET | ADC_REG_RANK_7_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 7 */
  661. #define LL_ADC_REG_RANK_8 (ADC_SQR2_REGOFFSET | ADC_REG_RANK_8_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 8 */
  662. #define LL_ADC_REG_RANK_9 (ADC_SQR2_REGOFFSET | ADC_REG_RANK_9_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 9 */
  663. #define LL_ADC_REG_RANK_10 (ADC_SQR2_REGOFFSET | ADC_REG_RANK_10_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 10 */
  664. #define LL_ADC_REG_RANK_11 (ADC_SQR2_REGOFFSET | ADC_REG_RANK_11_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 11 */
  665. #define LL_ADC_REG_RANK_12 (ADC_SQR2_REGOFFSET | ADC_REG_RANK_12_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 12 */
  666. #define LL_ADC_REG_RANK_13 (ADC_SQR1_REGOFFSET | ADC_REG_RANK_13_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 13 */
  667. #define LL_ADC_REG_RANK_14 (ADC_SQR1_REGOFFSET | ADC_REG_RANK_14_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 14 */
  668. #define LL_ADC_REG_RANK_15 (ADC_SQR1_REGOFFSET | ADC_REG_RANK_15_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 15 */
  669. #define LL_ADC_REG_RANK_16 (ADC_SQR1_REGOFFSET | ADC_REG_RANK_16_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 16 */
  670. /**
  671. * @}
  672. */
  673. /** @defgroup ADC_LL_EC_INJ_TRIGGER_SOURCE ADC group injected - Trigger source
  674. * @{
  675. */
  676. #define LL_ADC_INJ_TRIG_SOFTWARE 0x00000000U /*!< ADC group injected conversion trigger internal: SW start. */
  677. #define LL_ADC_INJ_TRIG_EXT_TIM1_CH4 (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). */
  678. #define LL_ADC_INJ_TRIG_EXT_TIM1_TRGO (ADC_CR2_JEXTSEL_0 | ADC_INJ_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group injected conversion trigger from external IP: TIM1 TRGO. Trigger edge set to rising edge (default setting). */
  679. #define LL_ADC_INJ_TRIG_EXT_TIM2_CH1 (ADC_CR2_JEXTSEL_1 | 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). */
  680. #define LL_ADC_INJ_TRIG_EXT_TIM2_TRGO (ADC_CR2_JEXTSEL_1 | ADC_CR2_JEXTSEL_0 | ADC_INJ_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group injected conversion trigger from external IP: TIM2 TRGO. Trigger edge set to rising edge (default setting). */
  681. #define LL_ADC_INJ_TRIG_EXT_TIM3_CH2 (ADC_CR2_JEXTSEL_2 | ADC_INJ_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group injected conversion trigger from external IP: TIM3 channel 2 event (capture compare: input capture or output capture). Trigger edge set to rising edge (default setting). */
  682. #define LL_ADC_INJ_TRIG_EXT_TIM3_CH4 (ADC_CR2_JEXTSEL_2 | ADC_CR2_JEXTSEL_0 | 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). */
  683. #define LL_ADC_INJ_TRIG_EXT_TIM4_CH1 (ADC_CR2_JEXTSEL_2 | ADC_CR2_JEXTSEL_1 | ADC_INJ_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group injected conversion trigger from external IP: TIM4 channel 1 event (capture compare: input capture or output capture). Trigger edge set to rising edge (default setting). */
  684. #define LL_ADC_INJ_TRIG_EXT_TIM4_CH2 (ADC_CR2_JEXTSEL_2 | ADC_CR2_JEXTSEL_1 | ADC_CR2_JEXTSEL_0 | ADC_INJ_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group injected conversion trigger from external IP: TIM4 channel 2 event (capture compare: input capture or output capture). Trigger edge set to rising edge (default setting). */
  685. #define LL_ADC_INJ_TRIG_EXT_TIM4_CH3 (ADC_CR2_JEXTSEL_3 | 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). */
  686. #define LL_ADC_INJ_TRIG_EXT_TIM4_TRGO (ADC_CR2_JEXTSEL_3 | ADC_CR2_JEXTSEL_0 | ADC_INJ_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group injected conversion trigger from external IP: TIM4 TRGO. Trigger edge set to rising edge (default setting). */
  687. #define LL_ADC_INJ_TRIG_EXT_TIM5_CH4 (ADC_CR2_JEXTSEL_3 | ADC_CR2_JEXTSEL_1 | ADC_INJ_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group injected conversion trigger from external IP: TIM5 channel 4 event (capture compare: input capture or output capture). Trigger edge set to rising edge (default setting). */
  688. #define LL_ADC_INJ_TRIG_EXT_TIM5_TRGO (ADC_CR2_JEXTSEL_3 | ADC_CR2_JEXTSEL_1 | ADC_CR2_JEXTSEL_0 | ADC_INJ_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group injected conversion trigger from external IP: TIM5 TRGO. Trigger edge set to rising edge (default setting). */
  689. #define LL_ADC_INJ_TRIG_EXT_TIM8_CH2 (ADC_CR2_JEXTSEL_3 | ADC_CR2_JEXTSEL_2 | 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). */
  690. #define LL_ADC_INJ_TRIG_EXT_TIM8_CH3 (ADC_CR2_JEXTSEL_3 | ADC_CR2_JEXTSEL_2 | ADC_CR2_JEXTSEL_0 | ADC_INJ_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group injected conversion trigger from external IP: TIM8 channel 3 event (capture compare: input capture or output capture). Trigger edge set to rising edge (default setting). */
  691. #define LL_ADC_INJ_TRIG_EXT_TIM8_CH4 (ADC_CR2_JEXTSEL_3 | ADC_CR2_JEXTSEL_2 | ADC_CR2_JEXTSEL_1 | 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). */
  692. #define LL_ADC_INJ_TRIG_EXT_EXTI_LINE15 (ADC_CR2_JEXTSEL_3 | ADC_CR2_JEXTSEL_2 | ADC_CR2_JEXTSEL_1 | ADC_CR2_JEXTSEL_0 | 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). */
  693. /**
  694. * @}
  695. */
  696. /** @defgroup ADC_LL_EC_INJ_TRIGGER_EDGE ADC group injected - Trigger edge
  697. * @{
  698. */
  699. #define LL_ADC_INJ_TRIG_EXT_RISING ( ADC_CR2_JEXTEN_0) /*!< ADC group injected conversion trigger polarity set to rising edge */
  700. #define LL_ADC_INJ_TRIG_EXT_FALLING (ADC_CR2_JEXTEN_1 ) /*!< ADC group injected conversion trigger polarity set to falling edge */
  701. #define LL_ADC_INJ_TRIG_EXT_RISINGFALLING (ADC_CR2_JEXTEN_1 | ADC_CR2_JEXTEN_0) /*!< ADC group injected conversion trigger polarity set to both rising and falling edges */
  702. /**
  703. * @}
  704. */
  705. /** @defgroup ADC_LL_EC_INJ_TRIG_AUTO ADC group injected - Automatic trigger mode
  706. * @{
  707. */
  708. #define LL_ADC_INJ_TRIG_INDEPENDENT 0x00000000U /*!< ADC group injected conversion trigger independent. Setting mandatory if ADC group injected injected trigger source is set to an external trigger. */
  709. #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. */
  710. /**
  711. * @}
  712. */
  713. /** @defgroup ADC_LL_EC_INJ_SEQ_SCAN_LENGTH ADC group injected - Sequencer scan length
  714. * @{
  715. */
  716. #define LL_ADC_INJ_SEQ_SCAN_DISABLE 0x00000000U /*!< ADC group injected sequencer disable (equivalent to sequencer of 1 rank: ADC conversion on only 1 channel) */
  717. #define LL_ADC_INJ_SEQ_SCAN_ENABLE_2RANKS ( ADC_JSQR_JL_0) /*!< ADC group injected sequencer enable with 2 ranks in the sequence */
  718. #define LL_ADC_INJ_SEQ_SCAN_ENABLE_3RANKS (ADC_JSQR_JL_1 ) /*!< ADC group injected sequencer enable with 3 ranks in the sequence */
  719. #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 */
  720. /**
  721. * @}
  722. */
  723. /** @defgroup ADC_LL_EC_INJ_SEQ_DISCONT_MODE ADC group injected - Sequencer discontinuous mode
  724. * @{
  725. */
  726. #define LL_ADC_INJ_SEQ_DISCONT_DISABLE 0x00000000U /*!< ADC group injected sequencer discontinuous mode disable */
  727. #define LL_ADC_INJ_SEQ_DISCONT_1RANK (ADC_CR1_JDISCEN) /*!< ADC group injected sequencer discontinuous mode enable with sequence interruption every rank */
  728. /**
  729. * @}
  730. */
  731. /** @defgroup ADC_LL_EC_INJ_SEQ_RANKS ADC group injected - Sequencer ranks
  732. * @{
  733. */
  734. #define LL_ADC_INJ_RANK_1 (ADC_JDR1_REGOFFSET | ADC_JOFR1_REGOFFSET | 0x00000001U) /*!< ADC group injected sequencer rank 1 */
  735. #define LL_ADC_INJ_RANK_2 (ADC_JDR2_REGOFFSET | ADC_JOFR2_REGOFFSET | 0x00000002U) /*!< ADC group injected sequencer rank 2 */
  736. #define LL_ADC_INJ_RANK_3 (ADC_JDR3_REGOFFSET | ADC_JOFR3_REGOFFSET | 0x00000003U) /*!< ADC group injected sequencer rank 3 */
  737. #define LL_ADC_INJ_RANK_4 (ADC_JDR4_REGOFFSET | ADC_JOFR4_REGOFFSET | 0x00000004U) /*!< ADC group injected sequencer rank 4 */
  738. /**
  739. * @}
  740. */
  741. /** @defgroup ADC_LL_EC_CHANNEL_SAMPLINGTIME Channel - Sampling time
  742. * @{
  743. */
  744. #define LL_ADC_SAMPLINGTIME_3CYCLES 0x00000000U /*!< Sampling time 3 ADC clock cycles */
  745. #define LL_ADC_SAMPLINGTIME_15CYCLES (ADC_SMPR1_SMP10_0) /*!< Sampling time 15 ADC clock cycles */
  746. #define LL_ADC_SAMPLINGTIME_28CYCLES (ADC_SMPR1_SMP10_1) /*!< Sampling time 28 ADC clock cycles */
  747. #define LL_ADC_SAMPLINGTIME_56CYCLES (ADC_SMPR1_SMP10_1 | ADC_SMPR1_SMP10_0) /*!< Sampling time 56 ADC clock cycles */
  748. #define LL_ADC_SAMPLINGTIME_84CYCLES (ADC_SMPR1_SMP10_2) /*!< Sampling time 84 ADC clock cycles */
  749. #define LL_ADC_SAMPLINGTIME_112CYCLES (ADC_SMPR1_SMP10_2 | ADC_SMPR1_SMP10_0) /*!< Sampling time 112 ADC clock cycles */
  750. #define LL_ADC_SAMPLINGTIME_144CYCLES (ADC_SMPR1_SMP10_2 | ADC_SMPR1_SMP10_1) /*!< Sampling time 144 ADC clock cycles */
  751. #define LL_ADC_SAMPLINGTIME_480CYCLES (ADC_SMPR1_SMP10) /*!< Sampling time 480 ADC clock cycles */
  752. /**
  753. * @}
  754. */
  755. /** @defgroup ADC_LL_EC_AWD_NUMBER Analog watchdog - Analog watchdog number
  756. * @{
  757. */
  758. #define LL_ADC_AWD1 (ADC_AWD_CR1_CHANNEL_MASK | ADC_AWD_CR1_REGOFFSET) /*!< ADC analog watchdog number 1 */
  759. /**
  760. * @}
  761. */
  762. /** @defgroup ADC_LL_EC_AWD_CHANNELS Analog watchdog - Monitored channels
  763. * @{
  764. */
  765. #define LL_ADC_AWD_DISABLE 0x00000000U /*!< ADC analog watchdog monitoring disabled */
  766. #define LL_ADC_AWD_ALL_CHANNELS_REG ( ADC_CR1_AWDEN ) /*!< ADC analog watchdog monitoring of all channels, converted by group regular only */
  767. #define LL_ADC_AWD_ALL_CHANNELS_INJ ( ADC_CR1_JAWDEN ) /*!< ADC analog watchdog monitoring of all channels, converted by group injected only */
  768. #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 */
  769. #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 */
  770. #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 */
  771. #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 */
  772. #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 */
  773. #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 */
  774. #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 */
  775. #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 */
  776. #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 */
  777. #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 */
  778. #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 */
  779. #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 */
  780. #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 */
  781. #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 */
  782. #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 */
  783. #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 */
  784. #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 */
  785. #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 */
  786. #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 */
  787. #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 */
  788. #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 */
  789. #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 */
  790. #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 */
  791. #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 */
  792. #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 */
  793. #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 */
  794. #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 */
  795. #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 */
  796. #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 */
  797. #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 */
  798. #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 */
  799. #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 */
  800. #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 */
  801. #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 */
  802. #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 */
  803. #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 */
  804. #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 */
  805. #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 */
  806. #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 */
  807. #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 */
  808. #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 */
  809. #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 */
  810. #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 */
  811. #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 */
  812. #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 */
  813. #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 */
  814. #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 */
  815. #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 */
  816. #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 */
  817. #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 */
  818. #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 */
  819. #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 */
  820. #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 */
  821. #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 */
  822. #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 */
  823. #define LL_ADC_AWD_CHANNEL_18_REG ((LL_ADC_CHANNEL_18 & ADC_CHANNEL_ID_MASK) | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN18, converted by group regular only */
  824. #define LL_ADC_AWD_CHANNEL_18_INJ ((LL_ADC_CHANNEL_18 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN18, converted by group injected only */
  825. #define LL_ADC_AWD_CHANNEL_18_REG_INJ ((LL_ADC_CHANNEL_18 & 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_IN18, converted by either group regular or injected */
  826. #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 */
  827. #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 */
  828. #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 */
  829. #define LL_ADC_AWD_CH_VBAT_REG ((LL_ADC_CHANNEL_VBAT & ADC_CHANNEL_ID_MASK) | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< 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 */
  830. #define LL_ADC_AWD_CH_VBAT_INJ ((LL_ADC_CHANNEL_VBAT & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDSGL) /*!< 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 */
  831. #define LL_ADC_AWD_CH_VBAT_REG_INJ ((LL_ADC_CHANNEL_VBAT & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< 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 */
  832. #if defined(STM32F401xC) || defined(STM32F401xE) || defined(STM32F405xx) || defined(STM32F407xx) || defined(STM32F410Tx) || defined(STM32F410Cx) || defined(STM32F410Rx) || defined(STM32F415xx) || defined(STM32F417xx)
  833. #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 */
  834. #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 */
  835. #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 */
  836. #endif /* STM32F405xx || STM32F415xx || STM32F407xx || STM32F417xx || STM32F401xC || STM32F401xE || STM32F410xx */
  837. #if defined(STM32F411xE) || defined(STM32F412Cx) || defined(STM32F412Rx) || defined(STM32F412Vx) || defined(STM32F412Zx) || defined(STM32F413xx) || defined(STM32F423xx) || defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx) || defined(STM32F446xx) || defined(STM32F469xx) || defined(STM32F479xx)
  838. #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. This internal channel is shared between temperature sensor and Vbat, only 1 measurement path must be enabled. */
  839. #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. This internal channel is shared between temperature sensor and Vbat, only 1 measurement path must be enabled. */
  840. #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. This internal channel is shared between temperature sensor and Vbat, only 1 measurement path must be enabled. */
  841. #endif /* STM32F411xE || STM32F412Cx || STM32F412Rx || STM32F412Vx || STM32F412Zx || STM32F413xx || STM32F423xx || STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx || STM32F446xx || STM32F469xx || STM32F479xx */
  842. /**
  843. * @}
  844. */
  845. /** @defgroup ADC_LL_EC_AWD_THRESHOLDS Analog watchdog - Thresholds
  846. * @{
  847. */
  848. #define LL_ADC_AWD_THRESHOLD_HIGH (ADC_AWD_TR1_HIGH_REGOFFSET) /*!< ADC analog watchdog threshold high */
  849. #define LL_ADC_AWD_THRESHOLD_LOW (ADC_AWD_TR1_LOW_REGOFFSET) /*!< ADC analog watchdog threshold low */
  850. /**
  851. * @}
  852. */
  853. #if defined(ADC_MULTIMODE_SUPPORT)
  854. /** @defgroup ADC_LL_EC_MULTI_MODE Multimode - Mode
  855. * @{
  856. */
  857. #define LL_ADC_MULTI_INDEPENDENT 0x00000000U /*!< ADC dual mode disabled (ADC independent mode) */
  858. #define LL_ADC_MULTI_DUAL_REG_SIMULT ( ADC_CCR_MULTI_2 | ADC_CCR_MULTI_1 ) /*!< ADC dual mode enabled: group regular simultaneous */
  859. #define LL_ADC_MULTI_DUAL_REG_INTERL ( ADC_CCR_MULTI_2 | ADC_CCR_MULTI_1 | ADC_CCR_MULTI_0) /*!< ADC dual mode enabled: Combined group regular interleaved */
  860. #define LL_ADC_MULTI_DUAL_INJ_SIMULT ( ADC_CCR_MULTI_2 | ADC_CCR_MULTI_0) /*!< ADC dual mode enabled: group injected simultaneous */
  861. #define LL_ADC_MULTI_DUAL_INJ_ALTERN (ADC_CCR_MULTI_3 | ADC_CCR_MULTI_0) /*!< ADC dual mode enabled: group injected alternate trigger. Works only with external triggers (not internal SW start) */
  862. #define LL_ADC_MULTI_DUAL_REG_SIM_INJ_SIM ( ADC_CCR_MULTI_0) /*!< ADC dual mode enabled: Combined group regular simultaneous + group injected simultaneous */
  863. #define LL_ADC_MULTI_DUAL_REG_SIM_INJ_ALT ( ADC_CCR_MULTI_1 ) /*!< ADC dual mode enabled: Combined group regular simultaneous + group injected alternate trigger */
  864. #define LL_ADC_MULTI_DUAL_REG_INT_INJ_SIM ( ADC_CCR_MULTI_1 | ADC_CCR_MULTI_0) /*!< ADC dual mode enabled: Combined group regular interleaved + group injected simultaneous */
  865. #if defined(ADC3)
  866. #define LL_ADC_MULTI_TRIPLE_REG_SIM_INJ_SIM (ADC_CCR_MULTI_4 | ADC_CCR_MULTI_0) /*!< ADC triple mode enabled: Combined group regular simultaneous + group injected simultaneous */
  867. #define LL_ADC_MULTI_TRIPLE_REG_SIM_INJ_ALT (ADC_CCR_MULTI_4 | ADC_CCR_MULTI_1 ) /*!< ADC triple mode enabled: Combined group regular simultaneous + group injected alternate trigger */
  868. #define LL_ADC_MULTI_TRIPLE_INJ_SIMULT (ADC_CCR_MULTI_4 | ADC_CCR_MULTI_2 | ADC_CCR_MULTI_0) /*!< ADC triple mode enabled: group injected simultaneous */
  869. #define LL_ADC_MULTI_TRIPLE_REG_SIMULT (ADC_CCR_MULTI_4 | ADC_CCR_MULTI_2 | ADC_CCR_MULTI_1 ) /*!< ADC triple mode enabled: group regular simultaneous */
  870. #define LL_ADC_MULTI_TRIPLE_REG_INTERL (ADC_CCR_MULTI_4 | ADC_CCR_MULTI_2 | ADC_CCR_MULTI_1 | ADC_CCR_MULTI_0) /*!< ADC triple mode enabled: Combined group regular interleaved */
  871. #define LL_ADC_MULTI_TRIPLE_INJ_ALTERN (ADC_CCR_MULTI_4 | ADC_CCR_MULTI_0) /*!< ADC triple mode enabled: group injected alternate trigger. Works only with external triggers (not internal SW start) */
  872. #endif
  873. /**
  874. * @}
  875. */
  876. /** @defgroup ADC_LL_EC_MULTI_DMA_TRANSFER Multimode - DMA transfer
  877. * @{
  878. */
  879. #define LL_ADC_MULTI_REG_DMA_EACH_ADC 0x00000000U /*!< ADC multimode group regular conversions are transferred by DMA: each ADC uses its own DMA channel, with its individual DMA transfer settings */
  880. #define LL_ADC_MULTI_REG_DMA_LIMIT_1 ( ADC_CCR_DMA_0) /*!< ADC multimode group regular conversions are transferred by DMA, one DMA channel for all ADC instances (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 of DMA mode 1: 2 or 3 (dual or triple mode) half-words one by one, ADC1 then ADC2 then ADC3. */
  881. #define LL_ADC_MULTI_REG_DMA_LIMIT_2 ( ADC_CCR_DMA_1 ) /*!< ADC multimode group regular conversions are transferred by DMA, one DMA channel for all ADC instances (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 of DMA mode 2: 2 or 3 (dual or triple mode) half-words one by one, ADC2&1 then ADC1&3 then ADC3&2. */
  882. #define LL_ADC_MULTI_REG_DMA_LIMIT_3 ( ADC_CCR_DMA_0 | ADC_CCR_DMA_0) /*!< ADC multimode group regular conversions are transferred by DMA, one DMA channel for all ADC instances (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 of DMA mode 3: 2 or 3 (dual or triple mode) bytes one by one, ADC2&1 then ADC1&3 then ADC3&2. */
  883. #define LL_ADC_MULTI_REG_DMA_UNLMT_1 (ADC_CCR_DDS | ADC_CCR_DMA_0) /*!< ADC multimode group regular conversions are transferred by DMA, one DMA channel for all ADC instances (DMA of ADC master), in unlimited mode: DMA transfer requests are unlimited, whatever number of DMA data transferred (number of ADC conversions) is reached. This ADC mode is intended to be used with DMA mode non-circular. Setting of DMA mode 1: 2 or 3 (dual or triple mode) half-words one by one, ADC1 then ADC2 then ADC3. */
  884. #define LL_ADC_MULTI_REG_DMA_UNLMT_2 (ADC_CCR_DDS | ADC_CCR_DMA_1 ) /*!< ADC multimode group regular conversions are transferred by DMA, one DMA channel for all ADC instances (DMA of ADC master), in unlimited mode: DMA transfer requests are unlimited, whatever number of DMA data transferred (number of ADC conversions) is reached. This ADC mode is intended to be used with DMA mode non-circular. Setting of DMA mode 2: 2 or 3 (dual or triple mode) half-words by pairs, ADC2&1 then ADC1&3 then ADC3&2. */
  885. #define LL_ADC_MULTI_REG_DMA_UNLMT_3 (ADC_CCR_DDS | ADC_CCR_DMA_0 | ADC_CCR_DMA_0) /*!< ADC multimode group regular conversions are transferred by DMA, one DMA channel for all ADC instances (DMA of ADC master), in unlimited mode: DMA transfer requests are unlimited, whatever number of DMA data transferred (number of ADC conversions) is reached. This ADC mode is intended to be used with DMA mode non-circular. Setting of DMA mode 3: 2 or 3 (dual or triple mode) bytes one by one, ADC2&1 then ADC1&3 then ADC3&2. */
  886. /**
  887. * @}
  888. */
  889. /** @defgroup ADC_LL_EC_MULTI_TWOSMP_DELAY Multimode - Delay between two sampling phases
  890. * @{
  891. */
  892. #define LL_ADC_MULTI_TWOSMP_DELAY_5CYCLES 0x00000000U /*!< ADC multimode delay between two sampling phases: 5 ADC clock cycles*/
  893. #define LL_ADC_MULTI_TWOSMP_DELAY_6CYCLES ( ADC_CCR_DELAY_0) /*!< ADC multimode delay between two sampling phases: 6 ADC clock cycles */
  894. #define LL_ADC_MULTI_TWOSMP_DELAY_7CYCLES ( ADC_CCR_DELAY_1 ) /*!< ADC multimode delay between two sampling phases: 7 ADC clock cycles */
  895. #define LL_ADC_MULTI_TWOSMP_DELAY_8CYCLES ( ADC_CCR_DELAY_1 | ADC_CCR_DELAY_0) /*!< ADC multimode delay between two sampling phases: 8 ADC clock cycles */
  896. #define LL_ADC_MULTI_TWOSMP_DELAY_9CYCLES ( ADC_CCR_DELAY_2 ) /*!< ADC multimode delay between two sampling phases: 9 ADC clock cycles */
  897. #define LL_ADC_MULTI_TWOSMP_DELAY_10CYCLES ( ADC_CCR_DELAY_2 | ADC_CCR_DELAY_0) /*!< ADC multimode delay between two sampling phases: 10 ADC clock cycles */
  898. #define LL_ADC_MULTI_TWOSMP_DELAY_11CYCLES ( ADC_CCR_DELAY_2 | ADC_CCR_DELAY_1 ) /*!< ADC multimode delay between two sampling phases: 11 ADC clock cycles */
  899. #define LL_ADC_MULTI_TWOSMP_DELAY_12CYCLES ( ADC_CCR_DELAY_2 | ADC_CCR_DELAY_1 | ADC_CCR_DELAY_0) /*!< ADC multimode delay between two sampling phases: 12 ADC clock cycles */
  900. #define LL_ADC_MULTI_TWOSMP_DELAY_13CYCLES (ADC_CCR_DELAY_3 ) /*!< ADC multimode delay between two sampling phases: 13 ADC clock cycles */
  901. #define LL_ADC_MULTI_TWOSMP_DELAY_14CYCLES (ADC_CCR_DELAY_3 | ADC_CCR_DELAY_0) /*!< ADC multimode delay between two sampling phases: 14 ADC clock cycles */
  902. #define LL_ADC_MULTI_TWOSMP_DELAY_15CYCLES (ADC_CCR_DELAY_3 | ADC_CCR_DELAY_1 ) /*!< ADC multimode delay between two sampling phases: 15 ADC clock cycles */
  903. #define LL_ADC_MULTI_TWOSMP_DELAY_16CYCLES (ADC_CCR_DELAY_3 | ADC_CCR_DELAY_1 | ADC_CCR_DELAY_0) /*!< ADC multimode delay between two sampling phases: 16 ADC clock cycles */
  904. #define LL_ADC_MULTI_TWOSMP_DELAY_17CYCLES (ADC_CCR_DELAY_3 | ADC_CCR_DELAY_2 ) /*!< ADC multimode delay between two sampling phases: 17 ADC clock cycles */
  905. #define LL_ADC_MULTI_TWOSMP_DELAY_18CYCLES (ADC_CCR_DELAY_3 | ADC_CCR_DELAY_2 | ADC_CCR_DELAY_0) /*!< ADC multimode delay between two sampling phases: 18 ADC clock cycles */
  906. #define LL_ADC_MULTI_TWOSMP_DELAY_19CYCLES (ADC_CCR_DELAY_3 | ADC_CCR_DELAY_2 | ADC_CCR_DELAY_1 ) /*!< ADC multimode delay between two sampling phases: 19 ADC clock cycles */
  907. #define LL_ADC_MULTI_TWOSMP_DELAY_20CYCLES (ADC_CCR_DELAY_3 | ADC_CCR_DELAY_2 | ADC_CCR_DELAY_1 | ADC_CCR_DELAY_0) /*!< ADC multimode delay between two sampling phases: 20 ADC clock cycles */
  908. /**
  909. * @}
  910. */
  911. /** @defgroup ADC_LL_EC_MULTI_MASTER_SLAVE Multimode - ADC master or slave
  912. * @{
  913. */
  914. #define LL_ADC_MULTI_MASTER ( ADC_CDR_RDATA_MST) /*!< In multimode, selection among several ADC instances: ADC master */
  915. #define LL_ADC_MULTI_SLAVE (ADC_CDR_RDATA_SLV ) /*!< In multimode, selection among several ADC instances: ADC slave */
  916. #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 */
  917. /**
  918. * @}
  919. */
  920. #endif /* ADC_MULTIMODE_SUPPORT */
  921. /** @defgroup ADC_LL_EC_HW_DELAYS Definitions of ADC hardware constraints delays
  922. * @note Only ADC IP HW delays are defined in ADC LL driver driver,
  923. * not timeout values.
  924. * For details on delays values, refer to descriptions in source code
  925. * above each literal definition.
  926. * @{
  927. */
  928. /* Note: Only ADC IP HW delays are defined in ADC LL driver driver, */
  929. /* not timeout values. */
  930. /* Timeout values for ADC operations are dependent to device clock */
  931. /* configuration (system clock versus ADC clock), */
  932. /* and therefore must be defined in user application. */
  933. /* Indications for estimation of ADC timeout delays, for this */
  934. /* STM32 serie: */
  935. /* - ADC enable time: maximum delay is 2us */
  936. /* (refer to device datasheet, parameter "tSTAB") */
  937. /* - ADC conversion time: duration depending on ADC clock and ADC */
  938. /* configuration. */
  939. /* (refer to device reference manual, section "Timing") */
  940. /* Delay for internal voltage reference stabilization time. */
  941. /* Delay set to maximum value (refer to device datasheet, */
  942. /* parameter "tSTART"). */
  943. /* Unit: us */
  944. #define LL_ADC_DELAY_VREFINT_STAB_US ( 10U) /*!< Delay for internal voltage reference stabilization time */
  945. /* Delay for temperature sensor stabilization time. */
  946. /* Literal set to maximum value (refer to device datasheet, */
  947. /* parameter "tSTART"). */
  948. /* Unit: us */
  949. #define LL_ADC_DELAY_TEMPSENSOR_STAB_US ( 10U) /*!< Delay for internal voltage reference stabilization time */
  950. /**
  951. * @}
  952. */
  953. /**
  954. * @}
  955. */
  956. /* Exported macro ------------------------------------------------------------*/
  957. /** @defgroup ADC_LL_Exported_Macros ADC Exported Macros
  958. * @{
  959. */
  960. /** @defgroup ADC_LL_EM_WRITE_READ Common write and read registers Macros
  961. * @{
  962. */
  963. /**
  964. * @brief Write a value in ADC register
  965. * @param __INSTANCE__ ADC Instance
  966. * @param __REG__ Register to be written
  967. * @param __VALUE__ Value to be written in the register
  968. * @retval None
  969. */
  970. #define LL_ADC_WriteReg(__INSTANCE__, __REG__, __VALUE__) WRITE_REG(__INSTANCE__->__REG__, (__VALUE__))
  971. /**
  972. * @brief Read a value in ADC register
  973. * @param __INSTANCE__ ADC Instance
  974. * @param __REG__ Register to be read
  975. * @retval Register value
  976. */
  977. #define LL_ADC_ReadReg(__INSTANCE__, __REG__) READ_REG(__INSTANCE__->__REG__)
  978. /**
  979. * @}
  980. */
  981. /** @defgroup ADC_LL_EM_HELPER_MACRO ADC helper macro
  982. * @{
  983. */
  984. /**
  985. * @brief Helper macro to get ADC channel number in decimal format
  986. * from literals LL_ADC_CHANNEL_x.
  987. * @note Example:
  988. * __LL_ADC_CHANNEL_TO_DECIMAL_NB(LL_ADC_CHANNEL_4)
  989. * will return decimal number "4".
  990. * @note The input can be a value from functions where a channel
  991. * number is returned, either defined with number
  992. * or with bitfield (only one bit must be set).
  993. * @param __CHANNEL__ This parameter can be one of the following values:
  994. * @arg @ref LL_ADC_CHANNEL_0
  995. * @arg @ref LL_ADC_CHANNEL_1
  996. * @arg @ref LL_ADC_CHANNEL_2
  997. * @arg @ref LL_ADC_CHANNEL_3
  998. * @arg @ref LL_ADC_CHANNEL_4
  999. * @arg @ref LL_ADC_CHANNEL_5
  1000. * @arg @ref LL_ADC_CHANNEL_6
  1001. * @arg @ref LL_ADC_CHANNEL_7
  1002. * @arg @ref LL_ADC_CHANNEL_8
  1003. * @arg @ref LL_ADC_CHANNEL_9
  1004. * @arg @ref LL_ADC_CHANNEL_10
  1005. * @arg @ref LL_ADC_CHANNEL_11
  1006. * @arg @ref LL_ADC_CHANNEL_12
  1007. * @arg @ref LL_ADC_CHANNEL_13
  1008. * @arg @ref LL_ADC_CHANNEL_14
  1009. * @arg @ref LL_ADC_CHANNEL_15
  1010. * @arg @ref LL_ADC_CHANNEL_16
  1011. * @arg @ref LL_ADC_CHANNEL_17
  1012. * @arg @ref LL_ADC_CHANNEL_18
  1013. * @arg @ref LL_ADC_CHANNEL_VREFINT (1)
  1014. * @arg @ref LL_ADC_CHANNEL_TEMPSENSOR (1)(2)
  1015. * @arg @ref LL_ADC_CHANNEL_VBAT (1)
  1016. *
  1017. * (1) On STM32F4, parameter available only on ADC instance: ADC1.\n
  1018. * (2) On devices STM32F42x and STM32F43x, limitation: this internal channel is shared between temperature sensor and Vbat, only 1 measurement path must be enabled.
  1019. * @retval Value between Min_Data=0 and Max_Data=18
  1020. */
  1021. #define __LL_ADC_CHANNEL_TO_DECIMAL_NB(__CHANNEL__) \
  1022. (((__CHANNEL__) & ADC_CHANNEL_ID_NUMBER_MASK) >> ADC_CHANNEL_ID_NUMBER_BITOFFSET_POS)
  1023. /**
  1024. * @brief Helper macro to get ADC channel in literal format LL_ADC_CHANNEL_x
  1025. * from number in decimal format.
  1026. * @note Example:
  1027. * __LL_ADC_DECIMAL_NB_TO_CHANNEL(4)
  1028. * will return a data equivalent to "LL_ADC_CHANNEL_4".
  1029. * @param __DECIMAL_NB__ Value between Min_Data=0 and Max_Data=18
  1030. * @retval Returned value can be one of the following values:
  1031. * @arg @ref LL_ADC_CHANNEL_0
  1032. * @arg @ref LL_ADC_CHANNEL_1
  1033. * @arg @ref LL_ADC_CHANNEL_2
  1034. * @arg @ref LL_ADC_CHANNEL_3
  1035. * @arg @ref LL_ADC_CHANNEL_4
  1036. * @arg @ref LL_ADC_CHANNEL_5
  1037. * @arg @ref LL_ADC_CHANNEL_6
  1038. * @arg @ref LL_ADC_CHANNEL_7
  1039. * @arg @ref LL_ADC_CHANNEL_8
  1040. * @arg @ref LL_ADC_CHANNEL_9
  1041. * @arg @ref LL_ADC_CHANNEL_10
  1042. * @arg @ref LL_ADC_CHANNEL_11
  1043. * @arg @ref LL_ADC_CHANNEL_12
  1044. * @arg @ref LL_ADC_CHANNEL_13
  1045. * @arg @ref LL_ADC_CHANNEL_14
  1046. * @arg @ref LL_ADC_CHANNEL_15
  1047. * @arg @ref LL_ADC_CHANNEL_16
  1048. * @arg @ref LL_ADC_CHANNEL_17
  1049. * @arg @ref LL_ADC_CHANNEL_18
  1050. * @arg @ref LL_ADC_CHANNEL_VREFINT (1)
  1051. * @arg @ref LL_ADC_CHANNEL_TEMPSENSOR (1)(2)
  1052. * @arg @ref LL_ADC_CHANNEL_VBAT (1)
  1053. *
  1054. * (1) On STM32F4, parameter available only on ADC instance: ADC1.\n
  1055. * (2) On devices STM32F42x and STM32F43x, limitation: this internal channel is shared between temperature sensor and Vbat, only 1 measurement path must be enabled.\n
  1056. * (1) For ADC channel read back from ADC register,
  1057. * comparison with internal channel parameter to be done
  1058. * using helper macro @ref __LL_ADC_CHANNEL_INTERNAL_TO_EXTERNAL().
  1059. */
  1060. #define __LL_ADC_DECIMAL_NB_TO_CHANNEL(__DECIMAL_NB__) \
  1061. (((__DECIMAL_NB__) <= 9U) \
  1062. ? ( \
  1063. ((__DECIMAL_NB__) << ADC_CHANNEL_ID_NUMBER_BITOFFSET_POS) | \
  1064. (ADC_SMPR2_REGOFFSET | (((uint32_t) (3U * (__DECIMAL_NB__))) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) \
  1065. ) \
  1066. : \
  1067. ( \
  1068. ((__DECIMAL_NB__) << ADC_CHANNEL_ID_NUMBER_BITOFFSET_POS) | \
  1069. (ADC_SMPR1_REGOFFSET | (((uint32_t) (3U * ((__DECIMAL_NB__) - 10U))) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) \
  1070. ) \
  1071. )
  1072. /**
  1073. * @brief Helper macro to determine whether the selected channel
  1074. * corresponds to literal definitions of driver.
  1075. * @note The different literal definitions of ADC channels are:
  1076. * - ADC internal channel:
  1077. * LL_ADC_CHANNEL_VREFINT, LL_ADC_CHANNEL_TEMPSENSOR, ...
  1078. * - ADC external channel (channel connected to a GPIO pin):
  1079. * LL_ADC_CHANNEL_1, LL_ADC_CHANNEL_2, ...
  1080. * @note The channel parameter must be a value defined from literal
  1081. * definition of a ADC internal channel (LL_ADC_CHANNEL_VREFINT,
  1082. * LL_ADC_CHANNEL_TEMPSENSOR, ...),
  1083. * ADC external channel (LL_ADC_CHANNEL_1, LL_ADC_CHANNEL_2, ...),
  1084. * must not be a value from functions where a channel number is
  1085. * returned from ADC registers,
  1086. * because internal and external channels share the same channel
  1087. * number in ADC registers. The differentiation is made only with
  1088. * parameters definitions of driver.
  1089. * @param __CHANNEL__ This parameter can be one of the following values:
  1090. * @arg @ref LL_ADC_CHANNEL_0
  1091. * @arg @ref LL_ADC_CHANNEL_1
  1092. * @arg @ref LL_ADC_CHANNEL_2
  1093. * @arg @ref LL_ADC_CHANNEL_3
  1094. * @arg @ref LL_ADC_CHANNEL_4
  1095. * @arg @ref LL_ADC_CHANNEL_5
  1096. * @arg @ref LL_ADC_CHANNEL_6
  1097. * @arg @ref LL_ADC_CHANNEL_7
  1098. * @arg @ref LL_ADC_CHANNEL_8
  1099. * @arg @ref LL_ADC_CHANNEL_9
  1100. * @arg @ref LL_ADC_CHANNEL_10
  1101. * @arg @ref LL_ADC_CHANNEL_11
  1102. * @arg @ref LL_ADC_CHANNEL_12
  1103. * @arg @ref LL_ADC_CHANNEL_13
  1104. * @arg @ref LL_ADC_CHANNEL_14
  1105. * @arg @ref LL_ADC_CHANNEL_15
  1106. * @arg @ref LL_ADC_CHANNEL_16
  1107. * @arg @ref LL_ADC_CHANNEL_17
  1108. * @arg @ref LL_ADC_CHANNEL_18
  1109. * @arg @ref LL_ADC_CHANNEL_VREFINT (1)
  1110. * @arg @ref LL_ADC_CHANNEL_TEMPSENSOR (1)(2)
  1111. * @arg @ref LL_ADC_CHANNEL_VBAT (1)
  1112. *
  1113. * (1) On STM32F4, parameter available only on ADC instance: ADC1.\n
  1114. * (2) On devices STM32F42x and STM32F43x, limitation: this internal channel is shared between temperature sensor and Vbat, only 1 measurement path must be enabled.
  1115. * @retval Value "0" if the channel corresponds to a parameter definition of a ADC external channel (channel connected to a GPIO pin).
  1116. * Value "1" if the channel corresponds to a parameter definition of a ADC internal channel.
  1117. */
  1118. #define __LL_ADC_IS_CHANNEL_INTERNAL(__CHANNEL__) \
  1119. (((__CHANNEL__) & ADC_CHANNEL_ID_INTERNAL_CH_MASK) != 0U)
  1120. /**
  1121. * @brief Helper macro to convert a channel defined from parameter
  1122. * definition of a ADC internal channel (LL_ADC_CHANNEL_VREFINT,
  1123. * LL_ADC_CHANNEL_TEMPSENSOR, ...),
  1124. * to its equivalent parameter definition of a ADC external channel
  1125. * (LL_ADC_CHANNEL_1, LL_ADC_CHANNEL_2, ...).
  1126. * @note The channel parameter can be, additionally to a value
  1127. * defined from parameter definition of a ADC internal channel
  1128. * (LL_ADC_CHANNEL_VREFINT, LL_ADC_CHANNEL_TEMPSENSOR, ...),
  1129. * a value defined from parameter definition of
  1130. * ADC external channel (LL_ADC_CHANNEL_1, LL_ADC_CHANNEL_2, ...)
  1131. * or a value from functions where a channel number is returned
  1132. * from ADC registers.
  1133. * @param __CHANNEL__ This parameter can be one of the following values:
  1134. * @arg @ref LL_ADC_CHANNEL_0
  1135. * @arg @ref LL_ADC_CHANNEL_1
  1136. * @arg @ref LL_ADC_CHANNEL_2
  1137. * @arg @ref LL_ADC_CHANNEL_3
  1138. * @arg @ref LL_ADC_CHANNEL_4
  1139. * @arg @ref LL_ADC_CHANNEL_5
  1140. * @arg @ref LL_ADC_CHANNEL_6
  1141. * @arg @ref LL_ADC_CHANNEL_7
  1142. * @arg @ref LL_ADC_CHANNEL_8
  1143. * @arg @ref LL_ADC_CHANNEL_9
  1144. * @arg @ref LL_ADC_CHANNEL_10
  1145. * @arg @ref LL_ADC_CHANNEL_11
  1146. * @arg @ref LL_ADC_CHANNEL_12
  1147. * @arg @ref LL_ADC_CHANNEL_13
  1148. * @arg @ref LL_ADC_CHANNEL_14
  1149. * @arg @ref LL_ADC_CHANNEL_15
  1150. * @arg @ref LL_ADC_CHANNEL_16
  1151. * @arg @ref LL_ADC_CHANNEL_17
  1152. * @arg @ref LL_ADC_CHANNEL_18
  1153. * @arg @ref LL_ADC_CHANNEL_VREFINT (1)
  1154. * @arg @ref LL_ADC_CHANNEL_TEMPSENSOR (1)(2)
  1155. * @arg @ref LL_ADC_CHANNEL_VBAT (1)
  1156. *
  1157. * (1) On STM32F4, parameter available only on ADC instance: ADC1.\n
  1158. * (2) On devices STM32F42x and STM32F43x, limitation: this internal channel is shared between temperature sensor and Vbat, only 1 measurement path must be enabled.
  1159. * @retval Returned value can be one of the following values:
  1160. * @arg @ref LL_ADC_CHANNEL_0
  1161. * @arg @ref LL_ADC_CHANNEL_1
  1162. * @arg @ref LL_ADC_CHANNEL_2
  1163. * @arg @ref LL_ADC_CHANNEL_3
  1164. * @arg @ref LL_ADC_CHANNEL_4
  1165. * @arg @ref LL_ADC_CHANNEL_5
  1166. * @arg @ref LL_ADC_CHANNEL_6
  1167. * @arg @ref LL_ADC_CHANNEL_7
  1168. * @arg @ref LL_ADC_CHANNEL_8
  1169. * @arg @ref LL_ADC_CHANNEL_9
  1170. * @arg @ref LL_ADC_CHANNEL_10
  1171. * @arg @ref LL_ADC_CHANNEL_11
  1172. * @arg @ref LL_ADC_CHANNEL_12
  1173. * @arg @ref LL_ADC_CHANNEL_13
  1174. * @arg @ref LL_ADC_CHANNEL_14
  1175. * @arg @ref LL_ADC_CHANNEL_15
  1176. * @arg @ref LL_ADC_CHANNEL_16
  1177. * @arg @ref LL_ADC_CHANNEL_17
  1178. * @arg @ref LL_ADC_CHANNEL_18
  1179. */
  1180. #define __LL_ADC_CHANNEL_INTERNAL_TO_EXTERNAL(__CHANNEL__) \
  1181. ((__CHANNEL__) & ~ADC_CHANNEL_ID_INTERNAL_CH_MASK)
  1182. /**
  1183. * @brief Helper macro to determine whether the internal channel
  1184. * selected is available on the ADC instance selected.
  1185. * @note The channel parameter must be a value defined from parameter
  1186. * definition of a ADC internal channel (LL_ADC_CHANNEL_VREFINT,
  1187. * LL_ADC_CHANNEL_TEMPSENSOR, ...),
  1188. * must not be a value defined from parameter definition of
  1189. * ADC external channel (LL_ADC_CHANNEL_1, LL_ADC_CHANNEL_2, ...)
  1190. * or a value from functions where a channel number is
  1191. * returned from ADC registers,
  1192. * because internal and external channels share the same channel
  1193. * number in ADC registers. The differentiation is made only with
  1194. * parameters definitions of driver.
  1195. * @param __ADC_INSTANCE__ ADC instance
  1196. * @param __CHANNEL__ This parameter can be one of the following values:
  1197. * @arg @ref LL_ADC_CHANNEL_VREFINT (1)
  1198. * @arg @ref LL_ADC_CHANNEL_TEMPSENSOR (1)(2)
  1199. * @arg @ref LL_ADC_CHANNEL_VBAT (1)
  1200. *
  1201. * (1) On STM32F4, parameter available only on ADC instance: ADC1.
  1202. * (2) On devices STM32F42x and STM32F43x, limitation: this internal channel is shared between temperature sensor and Vbat, only 1 measurement path must be enabled.
  1203. * @retval Value "0" if the internal channel selected is not available on the ADC instance selected.
  1204. * Value "1" if the internal channel selected is available on the ADC instance selected.
  1205. */
  1206. #define __LL_ADC_IS_CHANNEL_INTERNAL_AVAILABLE(__ADC_INSTANCE__, __CHANNEL__) \
  1207. ( \
  1208. ((__CHANNEL__) == LL_ADC_CHANNEL_VREFINT) || \
  1209. ((__CHANNEL__) == LL_ADC_CHANNEL_TEMPSENSOR) || \
  1210. ((__CHANNEL__) == LL_ADC_CHANNEL_VBAT) \
  1211. )
  1212. /**
  1213. * @brief Helper macro to define ADC analog watchdog parameter:
  1214. * define a single channel to monitor with analog watchdog
  1215. * from sequencer channel and groups definition.
  1216. * @note To be used with function @ref LL_ADC_SetAnalogWDMonitChannels().
  1217. * Example:
  1218. * LL_ADC_SetAnalogWDMonitChannels(
  1219. * ADC1, LL_ADC_AWD1,
  1220. * __LL_ADC_ANALOGWD_CHANNEL_GROUP(LL_ADC_CHANNEL4, LL_ADC_GROUP_REGULAR))
  1221. * @param __CHANNEL__ This parameter can be one of the following values:
  1222. * @arg @ref LL_ADC_CHANNEL_0
  1223. * @arg @ref LL_ADC_CHANNEL_1
  1224. * @arg @ref LL_ADC_CHANNEL_2
  1225. * @arg @ref LL_ADC_CHANNEL_3
  1226. * @arg @ref LL_ADC_CHANNEL_4
  1227. * @arg @ref LL_ADC_CHANNEL_5
  1228. * @arg @ref LL_ADC_CHANNEL_6
  1229. * @arg @ref LL_ADC_CHANNEL_7
  1230. * @arg @ref LL_ADC_CHANNEL_8
  1231. * @arg @ref LL_ADC_CHANNEL_9
  1232. * @arg @ref LL_ADC_CHANNEL_10
  1233. * @arg @ref LL_ADC_CHANNEL_11
  1234. * @arg @ref LL_ADC_CHANNEL_12
  1235. * @arg @ref LL_ADC_CHANNEL_13
  1236. * @arg @ref LL_ADC_CHANNEL_14
  1237. * @arg @ref LL_ADC_CHANNEL_15
  1238. * @arg @ref LL_ADC_CHANNEL_16
  1239. * @arg @ref LL_ADC_CHANNEL_17
  1240. * @arg @ref LL_ADC_CHANNEL_18
  1241. * @arg @ref LL_ADC_CHANNEL_VREFINT (1)
  1242. * @arg @ref LL_ADC_CHANNEL_TEMPSENSOR (1)(2)
  1243. * @arg @ref LL_ADC_CHANNEL_VBAT (1)
  1244. *
  1245. * (1) On STM32F4, parameter available only on ADC instance: ADC1.\n
  1246. * (2) On devices STM32F42x and STM32F43x, limitation: this internal channel is shared between temperature sensor and Vbat, only 1 measurement path must be enabled.\n
  1247. * (1) For ADC channel read back from ADC register,
  1248. * comparison with internal channel parameter to be done
  1249. * using helper macro @ref __LL_ADC_CHANNEL_INTERNAL_TO_EXTERNAL().
  1250. * @param __GROUP__ This parameter can be one of the following values:
  1251. * @arg @ref LL_ADC_GROUP_REGULAR
  1252. * @arg @ref LL_ADC_GROUP_INJECTED
  1253. * @arg @ref LL_ADC_GROUP_REGULAR_INJECTED
  1254. * @retval Returned value can be one of the following values:
  1255. * @arg @ref LL_ADC_AWD_DISABLE
  1256. * @arg @ref LL_ADC_AWD_ALL_CHANNELS_REG
  1257. * @arg @ref LL_ADC_AWD_ALL_CHANNELS_INJ
  1258. * @arg @ref LL_ADC_AWD_ALL_CHANNELS_REG_INJ
  1259. * @arg @ref LL_ADC_AWD_CHANNEL_0_REG
  1260. * @arg @ref LL_ADC_AWD_CHANNEL_0_INJ
  1261. * @arg @ref LL_ADC_AWD_CHANNEL_0_REG_INJ
  1262. * @arg @ref LL_ADC_AWD_CHANNEL_1_REG
  1263. * @arg @ref LL_ADC_AWD_CHANNEL_1_INJ
  1264. * @arg @ref LL_ADC_AWD_CHANNEL_1_REG_INJ
  1265. * @arg @ref LL_ADC_AWD_CHANNEL_2_REG
  1266. * @arg @ref LL_ADC_AWD_CHANNEL_2_INJ
  1267. * @arg @ref LL_ADC_AWD_CHANNEL_2_REG_INJ
  1268. * @arg @ref LL_ADC_AWD_CHANNEL_3_REG
  1269. * @arg @ref LL_ADC_AWD_CHANNEL_3_INJ
  1270. * @arg @ref LL_ADC_AWD_CHANNEL_3_REG_INJ
  1271. * @arg @ref LL_ADC_AWD_CHANNEL_4_REG
  1272. * @arg @ref LL_ADC_AWD_CHANNEL_4_INJ
  1273. * @arg @ref LL_ADC_AWD_CHANNEL_4_REG_INJ
  1274. * @arg @ref LL_ADC_AWD_CHANNEL_5_REG
  1275. * @arg @ref LL_ADC_AWD_CHANNEL_5_INJ
  1276. * @arg @ref LL_ADC_AWD_CHANNEL_5_REG_INJ
  1277. * @arg @ref LL_ADC_AWD_CHANNEL_6_REG
  1278. * @arg @ref LL_ADC_AWD_CHANNEL_6_INJ
  1279. * @arg @ref LL_ADC_AWD_CHANNEL_6_REG_INJ
  1280. * @arg @ref LL_ADC_AWD_CHANNEL_7_REG
  1281. * @arg @ref LL_ADC_AWD_CHANNEL_7_INJ
  1282. * @arg @ref LL_ADC_AWD_CHANNEL_7_REG_INJ
  1283. * @arg @ref LL_ADC_AWD_CHANNEL_8_REG
  1284. * @arg @ref LL_ADC_AWD_CHANNEL_8_INJ
  1285. * @arg @ref LL_ADC_AWD_CHANNEL_8_REG_INJ
  1286. * @arg @ref LL_ADC_AWD_CHANNEL_9_REG
  1287. * @arg @ref LL_ADC_AWD_CHANNEL_9_INJ
  1288. * @arg @ref LL_ADC_AWD_CHANNEL_9_REG_INJ
  1289. * @arg @ref LL_ADC_AWD_CHANNEL_10_REG
  1290. * @arg @ref LL_ADC_AWD_CHANNEL_10_INJ
  1291. * @arg @ref LL_ADC_AWD_CHANNEL_10_REG_INJ
  1292. * @arg @ref LL_ADC_AWD_CHANNEL_11_REG
  1293. * @arg @ref LL_ADC_AWD_CHANNEL_11_INJ
  1294. * @arg @ref LL_ADC_AWD_CHANNEL_11_REG_INJ
  1295. * @arg @ref LL_ADC_AWD_CHANNEL_12_REG
  1296. * @arg @ref LL_ADC_AWD_CHANNEL_12_INJ
  1297. * @arg @ref LL_ADC_AWD_CHANNEL_12_REG_INJ
  1298. * @arg @ref LL_ADC_AWD_CHANNEL_13_REG
  1299. * @arg @ref LL_ADC_AWD_CHANNEL_13_INJ
  1300. * @arg @ref LL_ADC_AWD_CHANNEL_13_REG_INJ
  1301. * @arg @ref LL_ADC_AWD_CHANNEL_14_REG
  1302. * @arg @ref LL_ADC_AWD_CHANNEL_14_INJ
  1303. * @arg @ref LL_ADC_AWD_CHANNEL_14_REG_INJ
  1304. * @arg @ref LL_ADC_AWD_CHANNEL_15_REG
  1305. * @arg @ref LL_ADC_AWD_CHANNEL_15_INJ
  1306. * @arg @ref LL_ADC_AWD_CHANNEL_15_REG_INJ
  1307. * @arg @ref LL_ADC_AWD_CHANNEL_16_REG
  1308. * @arg @ref LL_ADC_AWD_CHANNEL_16_INJ
  1309. * @arg @ref LL_ADC_AWD_CHANNEL_16_REG_INJ
  1310. * @arg @ref LL_ADC_AWD_CHANNEL_17_REG
  1311. * @arg @ref LL_ADC_AWD_CHANNEL_17_INJ
  1312. * @arg @ref LL_ADC_AWD_CHANNEL_17_REG_INJ
  1313. * @arg @ref LL_ADC_AWD_CHANNEL_18_REG
  1314. * @arg @ref LL_ADC_AWD_CHANNEL_18_INJ
  1315. * @arg @ref LL_ADC_AWD_CHANNEL_18_REG_INJ
  1316. * @arg @ref LL_ADC_AWD_CH_VREFINT_REG (1)
  1317. * @arg @ref LL_ADC_AWD_CH_VREFINT_INJ (1)
  1318. * @arg @ref LL_ADC_AWD_CH_VREFINT_REG_INJ (1)
  1319. * @arg @ref LL_ADC_AWD_CH_TEMPSENSOR_REG (1)(2)
  1320. * @arg @ref LL_ADC_AWD_CH_TEMPSENSOR_INJ (1)(2)
  1321. * @arg @ref LL_ADC_AWD_CH_TEMPSENSOR_REG_INJ (1)(2)
  1322. * @arg @ref LL_ADC_AWD_CH_VBAT_REG (1)
  1323. * @arg @ref LL_ADC_AWD_CH_VBAT_INJ (1)
  1324. * @arg @ref LL_ADC_AWD_CH_VBAT_REG_INJ (1)
  1325. *
  1326. * (1) On STM32F4, parameter available only on ADC instance: ADC1.\n
  1327. * (2) On devices STM32F42x and STM32F43x, limitation: this internal channel is shared between temperature sensor and Vbat, only 1 measurement path must be enabled.
  1328. */
  1329. #define __LL_ADC_ANALOGWD_CHANNEL_GROUP(__CHANNEL__, __GROUP__) \
  1330. (((__GROUP__) == LL_ADC_GROUP_REGULAR) \
  1331. ? (((__CHANNEL__) & ADC_CHANNEL_ID_MASK) | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) \
  1332. : \
  1333. ((__GROUP__) == LL_ADC_GROUP_INJECTED) \
  1334. ? (((__CHANNEL__) & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDSGL) \
  1335. : \
  1336. (((__CHANNEL__) & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) \
  1337. )
  1338. /**
  1339. * @brief Helper macro to set the value of ADC analog watchdog threshold high
  1340. * or low in function of ADC resolution, when ADC resolution is
  1341. * different of 12 bits.
  1342. * @note To be used with function @ref LL_ADC_SetAnalogWDThresholds().
  1343. * Example, with a ADC resolution of 8 bits, to set the value of
  1344. * analog watchdog threshold high (on 8 bits):
  1345. * LL_ADC_SetAnalogWDThresholds
  1346. * (< ADCx param >,
  1347. * __LL_ADC_ANALOGWD_SET_THRESHOLD_RESOLUTION(LL_ADC_RESOLUTION_8B, <threshold_value_8_bits>)
  1348. * );
  1349. * @param __ADC_RESOLUTION__ This parameter can be one of the following values:
  1350. * @arg @ref LL_ADC_RESOLUTION_12B
  1351. * @arg @ref LL_ADC_RESOLUTION_10B
  1352. * @arg @ref LL_ADC_RESOLUTION_8B
  1353. * @arg @ref LL_ADC_RESOLUTION_6B
  1354. * @param __AWD_THRESHOLD__ Value between Min_Data=0x000 and Max_Data=0xFFF
  1355. * @retval Value between Min_Data=0x000 and Max_Data=0xFFF
  1356. */
  1357. #define __LL_ADC_ANALOGWD_SET_THRESHOLD_RESOLUTION(__ADC_RESOLUTION__, __AWD_THRESHOLD__) \
  1358. ((__AWD_THRESHOLD__) << ((__ADC_RESOLUTION__) >> (ADC_CR1_RES_BITOFFSET_POS - 1U )))
  1359. /**
  1360. * @brief Helper macro to get the value of ADC analog watchdog threshold high
  1361. * or low in function of ADC resolution, when ADC resolution is
  1362. * different of 12 bits.
  1363. * @note To be used with function @ref LL_ADC_GetAnalogWDThresholds().
  1364. * Example, with a ADC resolution of 8 bits, to get the value of
  1365. * analog watchdog threshold high (on 8 bits):
  1366. * < threshold_value_6_bits > = __LL_ADC_ANALOGWD_GET_THRESHOLD_RESOLUTION
  1367. * (LL_ADC_RESOLUTION_8B,
  1368. * LL_ADC_GetAnalogWDThresholds(<ADCx param>, LL_ADC_AWD_THRESHOLD_HIGH)
  1369. * );
  1370. * @param __ADC_RESOLUTION__ This parameter can be one of the following values:
  1371. * @arg @ref LL_ADC_RESOLUTION_12B
  1372. * @arg @ref LL_ADC_RESOLUTION_10B
  1373. * @arg @ref LL_ADC_RESOLUTION_8B
  1374. * @arg @ref LL_ADC_RESOLUTION_6B
  1375. * @param __AWD_THRESHOLD_12_BITS__ Value between Min_Data=0x000 and Max_Data=0xFFF
  1376. * @retval Value between Min_Data=0x000 and Max_Data=0xFFF
  1377. */
  1378. #define __LL_ADC_ANALOGWD_GET_THRESHOLD_RESOLUTION(__ADC_RESOLUTION__, __AWD_THRESHOLD_12_BITS__) \
  1379. ((__AWD_THRESHOLD_12_BITS__) >> ((__ADC_RESOLUTION__) >> (ADC_CR1_RES_BITOFFSET_POS - 1U )))
  1380. #if defined(ADC_MULTIMODE_SUPPORT)
  1381. /**
  1382. * @brief Helper macro to get the ADC multimode conversion data of ADC master
  1383. * or ADC slave from raw value with both ADC conversion data concatenated.
  1384. * @note This macro is intended to be used when multimode transfer by DMA
  1385. * is enabled: refer to function @ref LL_ADC_SetMultiDMATransfer().
  1386. * In this case the transferred data need to processed with this macro
  1387. * to separate the conversion data of ADC master and ADC slave.
  1388. * @param __ADC_MULTI_MASTER_SLAVE__ This parameter can be one of the following values:
  1389. * @arg @ref LL_ADC_MULTI_MASTER
  1390. * @arg @ref LL_ADC_MULTI_SLAVE
  1391. * @param __ADC_MULTI_CONV_DATA__ Value between Min_Data=0x000 and Max_Data=0xFFF
  1392. * @retval Value between Min_Data=0x000 and Max_Data=0xFFF
  1393. */
  1394. #define __LL_ADC_MULTI_CONV_DATA_MASTER_SLAVE(__ADC_MULTI_MASTER_SLAVE__, __ADC_MULTI_CONV_DATA__) \
  1395. (((__ADC_MULTI_CONV_DATA__) >> POSITION_VAL((__ADC_MULTI_MASTER_SLAVE__))) & ADC_CDR_RDATA_MST)
  1396. #endif
  1397. /**
  1398. * @brief Helper macro to select the ADC common instance
  1399. * to which is belonging the selected ADC instance.
  1400. * @note ADC common register instance can be used for:
  1401. * - Set parameters common to several ADC instances
  1402. * - Multimode (for devices with several ADC instances)
  1403. * Refer to functions having argument "ADCxy_COMMON" as parameter.
  1404. * @param __ADCx__ ADC instance
  1405. * @retval ADC common register instance
  1406. */
  1407. #if defined(ADC1) && defined(ADC2) && defined(ADC3)
  1408. #define __LL_ADC_COMMON_INSTANCE(__ADCx__) \
  1409. (ADC123_COMMON)
  1410. #elif defined(ADC1) && defined(ADC2)
  1411. #define __LL_ADC_COMMON_INSTANCE(__ADCx__) \
  1412. (ADC12_COMMON)
  1413. #else
  1414. #define __LL_ADC_COMMON_INSTANCE(__ADCx__) \
  1415. (ADC1_COMMON)
  1416. #endif
  1417. /**
  1418. * @brief Helper macro to check if all ADC instances sharing the same
  1419. * ADC common instance are disabled.
  1420. * @note This check is required by functions with setting conditioned to
  1421. * ADC state:
  1422. * All ADC instances of the ADC common group must be disabled.
  1423. * Refer to functions having argument "ADCxy_COMMON" as parameter.
  1424. * @note On devices with only 1 ADC common instance, parameter of this macro
  1425. * is useless and can be ignored (parameter kept for compatibility
  1426. * with devices featuring several ADC common instances).
  1427. * @param __ADCXY_COMMON__ ADC common instance
  1428. * (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() )
  1429. * @retval Value "0" if all ADC instances sharing the same ADC common instance
  1430. * are disabled.
  1431. * Value "1" if at least one ADC instance sharing the same ADC common instance
  1432. * is enabled.
  1433. */
  1434. #if defined(ADC1) && defined(ADC2) && defined(ADC3)
  1435. #define __LL_ADC_IS_ENABLED_ALL_COMMON_INSTANCE(__ADCXY_COMMON__) \
  1436. (LL_ADC_IsEnabled(ADC1) | \
  1437. LL_ADC_IsEnabled(ADC2) | \
  1438. LL_ADC_IsEnabled(ADC3) )
  1439. #elif defined(ADC1) && defined(ADC2)
  1440. #define __LL_ADC_IS_ENABLED_ALL_COMMON_INSTANCE(__ADCXY_COMMON__) \
  1441. (LL_ADC_IsEnabled(ADC1) | \
  1442. LL_ADC_IsEnabled(ADC2) )
  1443. #else
  1444. #define __LL_ADC_IS_ENABLED_ALL_COMMON_INSTANCE(__ADCXY_COMMON__) \
  1445. (LL_ADC_IsEnabled(ADC1))
  1446. #endif
  1447. /**
  1448. * @brief Helper macro to define the ADC conversion data full-scale digital
  1449. * value corresponding to the selected ADC resolution.
  1450. * @note ADC conversion data full-scale corresponds to voltage range
  1451. * determined by analog voltage references Vref+ and Vref-
  1452. * (refer to reference manual).
  1453. * @param __ADC_RESOLUTION__ This parameter can be one of the following values:
  1454. * @arg @ref LL_ADC_RESOLUTION_12B
  1455. * @arg @ref LL_ADC_RESOLUTION_10B
  1456. * @arg @ref LL_ADC_RESOLUTION_8B
  1457. * @arg @ref LL_ADC_RESOLUTION_6B
  1458. * @retval ADC conversion data equivalent voltage value (unit: mVolt)
  1459. */
  1460. #define __LL_ADC_DIGITAL_SCALE(__ADC_RESOLUTION__) \
  1461. (0xFFFU >> ((__ADC_RESOLUTION__) >> (ADC_CR1_RES_BITOFFSET_POS - 1U)))
  1462. /**
  1463. * @brief Helper macro to convert the ADC conversion data from
  1464. * a resolution to another resolution.
  1465. * @param __DATA__ ADC conversion data to be converted
  1466. * @param __ADC_RESOLUTION_CURRENT__ Resolution of to the data to be converted
  1467. * This parameter can be one of the following values:
  1468. * @arg @ref LL_ADC_RESOLUTION_12B
  1469. * @arg @ref LL_ADC_RESOLUTION_10B
  1470. * @arg @ref LL_ADC_RESOLUTION_8B
  1471. * @arg @ref LL_ADC_RESOLUTION_6B
  1472. * @param __ADC_RESOLUTION_TARGET__ Resolution of the data after conversion
  1473. * This parameter can be one of the following values:
  1474. * @arg @ref LL_ADC_RESOLUTION_12B
  1475. * @arg @ref LL_ADC_RESOLUTION_10B
  1476. * @arg @ref LL_ADC_RESOLUTION_8B
  1477. * @arg @ref LL_ADC_RESOLUTION_6B
  1478. * @retval ADC conversion data to the requested resolution
  1479. */
  1480. #define __LL_ADC_CONVERT_DATA_RESOLUTION(__DATA__, __ADC_RESOLUTION_CURRENT__, __ADC_RESOLUTION_TARGET__) \
  1481. (((__DATA__) \
  1482. << ((__ADC_RESOLUTION_CURRENT__) >> (ADC_CR1_RES_BITOFFSET_POS - 1U))) \
  1483. >> ((__ADC_RESOLUTION_TARGET__) >> (ADC_CR1_RES_BITOFFSET_POS - 1U)) \
  1484. )
  1485. /**
  1486. * @brief Helper macro to calculate the voltage (unit: mVolt)
  1487. * corresponding to a ADC conversion data (unit: digital value).
  1488. * @note Analog reference voltage (Vref+) must be either known from
  1489. * user board environment or can be calculated using ADC measurement
  1490. * and ADC helper macro @ref __LL_ADC_CALC_VREFANALOG_VOLTAGE().
  1491. * @param __VREFANALOG_VOLTAGE__ Analog reference voltage (unit mV)
  1492. * @param __ADC_DATA__ ADC conversion data (resolution 12 bits)
  1493. * (unit: digital value).
  1494. * @param __ADC_RESOLUTION__ This parameter can be one of the following values:
  1495. * @arg @ref LL_ADC_RESOLUTION_12B
  1496. * @arg @ref LL_ADC_RESOLUTION_10B
  1497. * @arg @ref LL_ADC_RESOLUTION_8B
  1498. * @arg @ref LL_ADC_RESOLUTION_6B
  1499. * @retval ADC conversion data equivalent voltage value (unit: mVolt)
  1500. */
  1501. #define __LL_ADC_CALC_DATA_TO_VOLTAGE(__VREFANALOG_VOLTAGE__,\
  1502. __ADC_DATA__,\
  1503. __ADC_RESOLUTION__) \
  1504. ((__ADC_DATA__) * (__VREFANALOG_VOLTAGE__) \
  1505. / __LL_ADC_DIGITAL_SCALE(__ADC_RESOLUTION__) \
  1506. )
  1507. /**
  1508. * @brief Helper macro to calculate the temperature (unit: degree Celsius)
  1509. * from ADC conversion data of internal temperature sensor.
  1510. * @note Computation is using temperature sensor calibration values
  1511. * stored in system memory for each device during production.
  1512. * @note Calculation formula:
  1513. * Temperature = ((TS_ADC_DATA - TS_CAL1)
  1514. * * (TS_CAL2_TEMP - TS_CAL1_TEMP))
  1515. * / (TS_CAL2 - TS_CAL1) + TS_CAL1_TEMP
  1516. * with TS_ADC_DATA = temperature sensor raw data measured by ADC
  1517. * Avg_Slope = (TS_CAL2 - TS_CAL1)
  1518. * / (TS_CAL2_TEMP - TS_CAL1_TEMP)
  1519. * TS_CAL1 = equivalent TS_ADC_DATA at temperature
  1520. * TEMP_DEGC_CAL1 (calibrated in factory)
  1521. * TS_CAL2 = equivalent TS_ADC_DATA at temperature
  1522. * TEMP_DEGC_CAL2 (calibrated in factory)
  1523. * Caution: Calculation relevancy under reserve that calibration
  1524. * parameters are correct (address and data).
  1525. * To calculate temperature using temperature sensor
  1526. * datasheet typical values (generic values less, therefore
  1527. * less accurate than calibrated values),
  1528. * use helper macro @ref __LL_ADC_CALC_TEMPERATURE_TYP_PARAMS().
  1529. * @note As calculation input, the analog reference voltage (Vref+) must be
  1530. * defined as it impacts the ADC LSB equivalent voltage.
  1531. * @note Analog reference voltage (Vref+) must be either known from
  1532. * user board environment or can be calculated using ADC measurement
  1533. * and ADC helper macro @ref __LL_ADC_CALC_VREFANALOG_VOLTAGE().
  1534. * @note On this STM32 serie, calibration data of temperature sensor
  1535. * corresponds to a resolution of 12 bits,
  1536. * this is the recommended ADC resolution to convert voltage of
  1537. * temperature sensor.
  1538. * Otherwise, this macro performs the processing to scale
  1539. * ADC conversion data to 12 bits.
  1540. * @param __VREFANALOG_VOLTAGE__ Analog reference voltage (unit mV)
  1541. * @param __TEMPSENSOR_ADC_DATA__ ADC conversion data of internal
  1542. * temperature sensor (unit: digital value).
  1543. * @param __ADC_RESOLUTION__ ADC resolution at which internal temperature
  1544. * sensor voltage has been measured.
  1545. * This parameter can be one of the following values:
  1546. * @arg @ref LL_ADC_RESOLUTION_12B
  1547. * @arg @ref LL_ADC_RESOLUTION_10B
  1548. * @arg @ref LL_ADC_RESOLUTION_8B
  1549. * @arg @ref LL_ADC_RESOLUTION_6B
  1550. * @retval Temperature (unit: degree Celsius)
  1551. */
  1552. #define __LL_ADC_CALC_TEMPERATURE(__VREFANALOG_VOLTAGE__,\
  1553. __TEMPSENSOR_ADC_DATA__,\
  1554. __ADC_RESOLUTION__) \
  1555. (((( ((int32_t)((__LL_ADC_CONVERT_DATA_RESOLUTION((__TEMPSENSOR_ADC_DATA__), \
  1556. (__ADC_RESOLUTION__), \
  1557. LL_ADC_RESOLUTION_12B) \
  1558. * (__VREFANALOG_VOLTAGE__)) \
  1559. / TEMPSENSOR_CAL_VREFANALOG) \
  1560. - (int32_t) *TEMPSENSOR_CAL1_ADDR) \
  1561. ) * (int32_t)(TEMPSENSOR_CAL2_TEMP - TEMPSENSOR_CAL1_TEMP) \
  1562. ) / (int32_t)((int32_t)*TEMPSENSOR_CAL2_ADDR - (int32_t)*TEMPSENSOR_CAL1_ADDR) \
  1563. ) + TEMPSENSOR_CAL1_TEMP \
  1564. )
  1565. /**
  1566. * @brief Helper macro to calculate the temperature (unit: degree Celsius)
  1567. * from ADC conversion data of internal temperature sensor.
  1568. * @note Computation is using temperature sensor typical values
  1569. * (refer to device datasheet).
  1570. * @note Calculation formula:
  1571. * Temperature = (TS_TYP_CALx_VOLT(uV) - TS_ADC_DATA * Conversion_uV)
  1572. * / Avg_Slope + CALx_TEMP
  1573. * with TS_ADC_DATA = temperature sensor raw data measured by ADC
  1574. * (unit: digital value)
  1575. * Avg_Slope = temperature sensor slope
  1576. * (unit: uV/Degree Celsius)
  1577. * TS_TYP_CALx_VOLT = temperature sensor digital value at
  1578. * temperature CALx_TEMP (unit: mV)
  1579. * Caution: Calculation relevancy under reserve the temperature sensor
  1580. * of the current device has characteristics in line with
  1581. * datasheet typical values.
  1582. * If temperature sensor calibration values are available on
  1583. * on this device (presence of macro __LL_ADC_CALC_TEMPERATURE()),
  1584. * temperature calculation will be more accurate using
  1585. * helper macro @ref __LL_ADC_CALC_TEMPERATURE().
  1586. * @note As calculation input, the analog reference voltage (Vref+) must be
  1587. * defined as it impacts the ADC LSB equivalent voltage.
  1588. * @note Analog reference voltage (Vref+) must be either known from
  1589. * user board environment or can be calculated using ADC measurement
  1590. * and ADC helper macro @ref __LL_ADC_CALC_VREFANALOG_VOLTAGE().
  1591. * @note ADC measurement data must correspond to a resolution of 12bits
  1592. * (full scale digital value 4095). If not the case, the data must be
  1593. * preliminarily rescaled to an equivalent resolution of 12 bits.
  1594. * @param __TEMPSENSOR_TYP_AVGSLOPE__ Device datasheet data Temperature sensor slope typical value (unit uV/DegCelsius).
  1595. * On STM32F4, refer to device datasheet parameter "Avg_Slope".
  1596. * @param __TEMPSENSOR_TYP_CALX_V__ Device datasheet data Temperature sensor voltage typical value (at temperature and Vref+ defined in parameters below) (unit mV).
  1597. * On STM32F4, refer to device datasheet parameter "V25".
  1598. * @param __TEMPSENSOR_CALX_TEMP__ Device datasheet data Temperature at which temperature sensor voltage (see parameter above) is corresponding (unit mV)
  1599. * @param __VREFANALOG_VOLTAGE__ Analog voltage reference (Vref+) voltage (unit mV)
  1600. * @param __TEMPSENSOR_ADC_DATA__ ADC conversion data of internal temperature sensor (unit digital value).
  1601. * @param __ADC_RESOLUTION__ ADC resolution at which internal temperature sensor voltage has been measured.
  1602. * This parameter can be one of the following values:
  1603. * @arg @ref LL_ADC_RESOLUTION_12B
  1604. * @arg @ref LL_ADC_RESOLUTION_10B
  1605. * @arg @ref LL_ADC_RESOLUTION_8B
  1606. * @arg @ref LL_ADC_RESOLUTION_6B
  1607. * @retval Temperature (unit: degree Celsius)
  1608. */
  1609. #define __LL_ADC_CALC_TEMPERATURE_TYP_PARAMS(__TEMPSENSOR_TYP_AVGSLOPE__,\
  1610. __TEMPSENSOR_TYP_CALX_V__,\
  1611. __TEMPSENSOR_CALX_TEMP__,\
  1612. __VREFANALOG_VOLTAGE__,\
  1613. __TEMPSENSOR_ADC_DATA__,\
  1614. __ADC_RESOLUTION__) \
  1615. ((( ( \
  1616. (int32_t)(((__TEMPSENSOR_TYP_CALX_V__)) \
  1617. * 1000) \
  1618. - \
  1619. (int32_t)((((__TEMPSENSOR_ADC_DATA__) * (__VREFANALOG_VOLTAGE__)) \
  1620. / __LL_ADC_DIGITAL_SCALE(__ADC_RESOLUTION__)) \
  1621. * 1000) \
  1622. ) \
  1623. ) / (__TEMPSENSOR_TYP_AVGSLOPE__) \
  1624. ) + (__TEMPSENSOR_CALX_TEMP__) \
  1625. )
  1626. /**
  1627. * @}
  1628. */
  1629. /**
  1630. * @}
  1631. */
  1632. /* Exported functions --------------------------------------------------------*/
  1633. /** @defgroup ADC_LL_Exported_Functions ADC Exported Functions
  1634. * @{
  1635. */
  1636. /** @defgroup ADC_LL_EF_DMA_Management ADC DMA management
  1637. * @{
  1638. */
  1639. /* Note: LL ADC functions to set DMA transfer are located into sections of */
  1640. /* configuration of ADC instance, groups and multimode (if available): */
  1641. /* @ref LL_ADC_REG_SetDMATransfer(), ... */
  1642. /**
  1643. * @brief Function to help to configure DMA transfer from ADC: retrieve the
  1644. * ADC register address from ADC instance and a list of ADC registers
  1645. * intended to be used (most commonly) with DMA transfer.
  1646. * @note These ADC registers are data registers:
  1647. * when ADC conversion data is available in ADC data registers,
  1648. * ADC generates a DMA transfer request.
  1649. * @note This macro is intended to be used with LL DMA driver, refer to
  1650. * function "LL_DMA_ConfigAddresses()".
  1651. * Example:
  1652. * LL_DMA_ConfigAddresses(DMA1,
  1653. * LL_DMA_CHANNEL_1,
  1654. * LL_ADC_DMA_GetRegAddr(ADC1, LL_ADC_DMA_REG_REGULAR_DATA),
  1655. * (uint32_t)&< array or variable >,
  1656. * LL_DMA_DIRECTION_PERIPH_TO_MEMORY);
  1657. * @note For devices with several ADC: in multimode, some devices
  1658. * use a different data register outside of ADC instance scope
  1659. * (common data register). This macro manages this register difference,
  1660. * only ADC instance has to be set as parameter.
  1661. * @rmtoll DR RDATA LL_ADC_DMA_GetRegAddr\n
  1662. * CDR RDATA_MST LL_ADC_DMA_GetRegAddr\n
  1663. * CDR RDATA_SLV LL_ADC_DMA_GetRegAddr
  1664. * @param ADCx ADC instance
  1665. * @param Register This parameter can be one of the following values:
  1666. * @arg @ref LL_ADC_DMA_REG_REGULAR_DATA
  1667. * @arg @ref LL_ADC_DMA_REG_REGULAR_DATA_MULTI (1)
  1668. *
  1669. * (1) Available on devices with several ADC instances.
  1670. * @retval ADC register address
  1671. */
  1672. #if defined(ADC_MULTIMODE_SUPPORT)
  1673. __STATIC_INLINE uint32_t LL_ADC_DMA_GetRegAddr(ADC_TypeDef *ADCx, uint32_t Register)
  1674. {
  1675. register uint32_t data_reg_addr = 0U;
  1676. if (Register == LL_ADC_DMA_REG_REGULAR_DATA)
  1677. {
  1678. /* Retrieve address of register DR */
  1679. data_reg_addr = (uint32_t)&(ADCx->DR);
  1680. }
  1681. else /* (Register == LL_ADC_DMA_REG_REGULAR_DATA_MULTI) */
  1682. {
  1683. /* Retrieve address of register CDR */
  1684. data_reg_addr = (uint32_t)&((__LL_ADC_COMMON_INSTANCE(ADCx))->CDR);
  1685. }
  1686. return data_reg_addr;
  1687. }
  1688. #else
  1689. __STATIC_INLINE uint32_t LL_ADC_DMA_GetRegAddr(ADC_TypeDef *ADCx, uint32_t Register)
  1690. {
  1691. /* Retrieve address of register DR */
  1692. return (uint32_t)&(ADCx->DR);
  1693. }
  1694. #endif
  1695. /**
  1696. * @}
  1697. */
  1698. /** @defgroup ADC_LL_EF_Configuration_ADC_Common Configuration of ADC hierarchical scope: common to several ADC instances
  1699. * @{
  1700. */
  1701. /**
  1702. * @brief Set parameter common to several ADC: Clock source and prescaler.
  1703. * @rmtoll CCR ADCPRE LL_ADC_SetCommonClock
  1704. * @param ADCxy_COMMON ADC common instance
  1705. * (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() )
  1706. * @param CommonClock This parameter can be one of the following values:
  1707. * @arg @ref LL_ADC_CLOCK_SYNC_PCLK_DIV2
  1708. * @arg @ref LL_ADC_CLOCK_SYNC_PCLK_DIV4
  1709. * @arg @ref LL_ADC_CLOCK_SYNC_PCLK_DIV6
  1710. * @arg @ref LL_ADC_CLOCK_SYNC_PCLK_DIV8
  1711. * @retval None
  1712. */
  1713. __STATIC_INLINE void LL_ADC_SetCommonClock(ADC_Common_TypeDef *ADCxy_COMMON, uint32_t CommonClock)
  1714. {
  1715. MODIFY_REG(ADCxy_COMMON->CCR, ADC_CCR_ADCPRE, CommonClock);
  1716. }
  1717. /**
  1718. * @brief Get parameter common to several ADC: Clock source and prescaler.
  1719. * @rmtoll CCR ADCPRE LL_ADC_GetCommonClock
  1720. * @param ADCxy_COMMON ADC common instance
  1721. * (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() )
  1722. * @retval Returned value can be one of the following values:
  1723. * @arg @ref LL_ADC_CLOCK_SYNC_PCLK_DIV2
  1724. * @arg @ref LL_ADC_CLOCK_SYNC_PCLK_DIV4
  1725. * @arg @ref LL_ADC_CLOCK_SYNC_PCLK_DIV6
  1726. * @arg @ref LL_ADC_CLOCK_SYNC_PCLK_DIV8
  1727. */
  1728. __STATIC_INLINE uint32_t LL_ADC_GetCommonClock(ADC_Common_TypeDef *ADCxy_COMMON)
  1729. {
  1730. return (uint32_t)(READ_BIT(ADCxy_COMMON->CCR, ADC_CCR_ADCPRE));
  1731. }
  1732. /**
  1733. * @brief Set parameter common to several ADC: measurement path to internal
  1734. * channels (VrefInt, temperature sensor, ...).
  1735. * @note One or several values can be selected.
  1736. * Example: (LL_ADC_PATH_INTERNAL_VREFINT |
  1737. * LL_ADC_PATH_INTERNAL_TEMPSENSOR)
  1738. * @note Stabilization time of measurement path to internal channel:
  1739. * After enabling internal paths, before starting ADC conversion,
  1740. * a delay is required for internal voltage reference and
  1741. * temperature sensor stabilization time.
  1742. * Refer to device datasheet.
  1743. * Refer to literal @ref LL_ADC_DELAY_VREFINT_STAB_US.
  1744. * Refer to literal @ref LL_ADC_DELAY_TEMPSENSOR_STAB_US.
  1745. * @note ADC internal channel sampling time constraint:
  1746. * For ADC conversion of internal channels,
  1747. * a sampling time minimum value is required.
  1748. * Refer to device datasheet.
  1749. * @rmtoll CCR TSVREFE LL_ADC_SetCommonPathInternalCh\n
  1750. * CCR VBATE LL_ADC_SetCommonPathInternalCh
  1751. * @param ADCxy_COMMON ADC common instance
  1752. * (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() )
  1753. * @param PathInternal This parameter can be a combination of the following values:
  1754. * @arg @ref LL_ADC_PATH_INTERNAL_NONE
  1755. * @arg @ref LL_ADC_PATH_INTERNAL_VREFINT
  1756. * @arg @ref LL_ADC_PATH_INTERNAL_TEMPSENSOR
  1757. * @arg @ref LL_ADC_PATH_INTERNAL_VBAT
  1758. * @retval None
  1759. */
  1760. __STATIC_INLINE void LL_ADC_SetCommonPathInternalCh(ADC_Common_TypeDef *ADCxy_COMMON, uint32_t PathInternal)
  1761. {
  1762. MODIFY_REG(ADCxy_COMMON->CCR, ADC_CCR_TSVREFE | ADC_CCR_VBATE, PathInternal);
  1763. }
  1764. /**
  1765. * @brief Get parameter common to several ADC: measurement path to internal
  1766. * channels (VrefInt, temperature sensor, ...).
  1767. * @note One or several values can be selected.
  1768. * Example: (LL_ADC_PATH_INTERNAL_VREFINT |
  1769. * LL_ADC_PATH_INTERNAL_TEMPSENSOR)
  1770. * @rmtoll CCR TSVREFE LL_ADC_GetCommonPathInternalCh\n
  1771. * CCR VBATE LL_ADC_GetCommonPathInternalCh
  1772. * @param ADCxy_COMMON ADC common instance
  1773. * (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() )
  1774. * @retval Returned value can be a combination of the following values:
  1775. * @arg @ref LL_ADC_PATH_INTERNAL_NONE
  1776. * @arg @ref LL_ADC_PATH_INTERNAL_VREFINT
  1777. * @arg @ref LL_ADC_PATH_INTERNAL_TEMPSENSOR
  1778. * @arg @ref LL_ADC_PATH_INTERNAL_VBAT
  1779. */
  1780. __STATIC_INLINE uint32_t LL_ADC_GetCommonPathInternalCh(ADC_Common_TypeDef *ADCxy_COMMON)
  1781. {
  1782. return (uint32_t)(READ_BIT(ADCxy_COMMON->CCR, ADC_CCR_TSVREFE | ADC_CCR_VBATE));
  1783. }
  1784. /**
  1785. * @}
  1786. */
  1787. /** @defgroup ADC_LL_EF_Configuration_ADC_Instance Configuration of ADC hierarchical scope: ADC instance
  1788. * @{
  1789. */
  1790. /**
  1791. * @brief Set ADC resolution.
  1792. * Refer to reference manual for alignments formats
  1793. * dependencies to ADC resolutions.
  1794. * @rmtoll CR1 RES LL_ADC_SetResolution
  1795. * @param ADCx ADC instance
  1796. * @param Resolution This parameter can be one of the following values:
  1797. * @arg @ref LL_ADC_RESOLUTION_12B
  1798. * @arg @ref LL_ADC_RESOLUTION_10B
  1799. * @arg @ref LL_ADC_RESOLUTION_8B
  1800. * @arg @ref LL_ADC_RESOLUTION_6B
  1801. * @retval None
  1802. */
  1803. __STATIC_INLINE void LL_ADC_SetResolution(ADC_TypeDef *ADCx, uint32_t Resolution)
  1804. {
  1805. MODIFY_REG(ADCx->CR1, ADC_CR1_RES, Resolution);
  1806. }
  1807. /**
  1808. * @brief Get ADC resolution.
  1809. * Refer to reference manual for alignments formats
  1810. * dependencies to ADC resolutions.
  1811. * @rmtoll CR1 RES LL_ADC_GetResolution
  1812. * @param ADCx ADC instance
  1813. * @retval Returned value can be one of the following values:
  1814. * @arg @ref LL_ADC_RESOLUTION_12B
  1815. * @arg @ref LL_ADC_RESOLUTION_10B
  1816. * @arg @ref LL_ADC_RESOLUTION_8B
  1817. * @arg @ref LL_ADC_RESOLUTION_6B
  1818. */
  1819. __STATIC_INLINE uint32_t LL_ADC_GetResolution(ADC_TypeDef *ADCx)
  1820. {
  1821. return (uint32_t)(READ_BIT(ADCx->CR1, ADC_CR1_RES));
  1822. }
  1823. /**
  1824. * @brief Set ADC conversion data alignment.
  1825. * @note Refer to reference manual for alignments formats
  1826. * dependencies to ADC resolutions.
  1827. * @rmtoll CR2 ALIGN LL_ADC_SetDataAlignment
  1828. * @param ADCx ADC instance
  1829. * @param DataAlignment This parameter can be one of the following values:
  1830. * @arg @ref LL_ADC_DATA_ALIGN_RIGHT
  1831. * @arg @ref LL_ADC_DATA_ALIGN_LEFT
  1832. * @retval None
  1833. */
  1834. __STATIC_INLINE void LL_ADC_SetDataAlignment(ADC_TypeDef *ADCx, uint32_t DataAlignment)
  1835. {
  1836. MODIFY_REG(ADCx->CR2, ADC_CR2_ALIGN, DataAlignment);
  1837. }
  1838. /**
  1839. * @brief Get ADC conversion data alignment.
  1840. * @note Refer to reference manual for alignments formats
  1841. * dependencies to ADC resolutions.
  1842. * @rmtoll CR2 ALIGN LL_ADC_SetDataAlignment
  1843. * @param ADCx ADC instance
  1844. * @retval Returned value can be one of the following values:
  1845. * @arg @ref LL_ADC_DATA_ALIGN_RIGHT
  1846. * @arg @ref LL_ADC_DATA_ALIGN_LEFT
  1847. */
  1848. __STATIC_INLINE uint32_t LL_ADC_GetDataAlignment(ADC_TypeDef *ADCx)
  1849. {
  1850. return (uint32_t)(READ_BIT(ADCx->CR2, ADC_CR2_ALIGN));
  1851. }
  1852. /**
  1853. * @brief Set ADC sequencers scan mode, for all ADC groups
  1854. * (group regular, group injected).
  1855. * @note According to sequencers scan mode :
  1856. * - If disabled: ADC conversion is performed in unitary conversion
  1857. * mode (one channel converted, that defined in rank 1).
  1858. * Configuration of sequencers of all ADC groups
  1859. * (sequencer scan length, ...) is discarded: equivalent to
  1860. * scan length of 1 rank.
  1861. * - If enabled: ADC conversions are performed in sequence conversions
  1862. * mode, according to configuration of sequencers of
  1863. * each ADC group (sequencer scan length, ...).
  1864. * Refer to function @ref LL_ADC_REG_SetSequencerLength()
  1865. * and to function @ref LL_ADC_INJ_SetSequencerLength().
  1866. * @rmtoll CR1 SCAN LL_ADC_SetSequencersScanMode
  1867. * @param ADCx ADC instance
  1868. * @param ScanMode This parameter can be one of the following values:
  1869. * @arg @ref LL_ADC_SEQ_SCAN_DISABLE
  1870. * @arg @ref LL_ADC_SEQ_SCAN_ENABLE
  1871. * @retval None
  1872. */
  1873. __STATIC_INLINE void LL_ADC_SetSequencersScanMode(ADC_TypeDef *ADCx, uint32_t ScanMode)
  1874. {
  1875. MODIFY_REG(ADCx->CR1, ADC_CR1_SCAN, ScanMode);
  1876. }
  1877. /**
  1878. * @brief Get ADC sequencers scan mode, for all ADC groups
  1879. * (group regular, group injected).
  1880. * @note According to sequencers scan mode :
  1881. * - If disabled: ADC conversion is performed in unitary conversion
  1882. * mode (one channel converted, that defined in rank 1).
  1883. * Configuration of sequencers of all ADC groups
  1884. * (sequencer scan length, ...) is discarded: equivalent to
  1885. * scan length of 1 rank.
  1886. * - If enabled: ADC conversions are performed in sequence conversions
  1887. * mode, according to configuration of sequencers of
  1888. * each ADC group (sequencer scan length, ...).
  1889. * Refer to function @ref LL_ADC_REG_SetSequencerLength()
  1890. * and to function @ref LL_ADC_INJ_SetSequencerLength().
  1891. * @rmtoll CR1 SCAN LL_ADC_GetSequencersScanMode
  1892. * @param ADCx ADC instance
  1893. * @retval Returned value can be one of the following values:
  1894. * @arg @ref LL_ADC_SEQ_SCAN_DISABLE
  1895. * @arg @ref LL_ADC_SEQ_SCAN_ENABLE
  1896. */
  1897. __STATIC_INLINE uint32_t LL_ADC_GetSequencersScanMode(ADC_TypeDef *ADCx)
  1898. {
  1899. return (uint32_t)(READ_BIT(ADCx->CR1, ADC_CR1_SCAN));
  1900. }
  1901. /**
  1902. * @}
  1903. */
  1904. /** @defgroup ADC_LL_EF_Configuration_ADC_Group_Regular Configuration of ADC hierarchical scope: group regular
  1905. * @{
  1906. */
  1907. /**
  1908. * @brief Set ADC group regular conversion trigger source:
  1909. * internal (SW start) or from external IP (timer event,
  1910. * external interrupt line).
  1911. * @note On this STM32 serie, setting of external trigger edge is performed
  1912. * using function @ref LL_ADC_REG_StartConversionExtTrig().
  1913. * @note Availability of parameters of trigger sources from timer
  1914. * depends on timers availability on the selected device.
  1915. * @rmtoll CR2 EXTSEL LL_ADC_REG_SetTriggerSource\n
  1916. * CR2 EXTEN LL_ADC_REG_SetTriggerSource
  1917. * @param ADCx ADC instance
  1918. * @param TriggerSource This parameter can be one of the following values:
  1919. * @arg @ref LL_ADC_REG_TRIG_SOFTWARE
  1920. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM1_CH1
  1921. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM1_CH2
  1922. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM1_CH3
  1923. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM2_CH2
  1924. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM2_CH3
  1925. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM2_CH4
  1926. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM2_TRGO
  1927. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM3_CH1
  1928. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM3_TRGO
  1929. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM4_CH4
  1930. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM5_CH1
  1931. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM5_CH2
  1932. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM5_CH3
  1933. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM8_CH1
  1934. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM8_TRGO
  1935. * @arg @ref LL_ADC_REG_TRIG_EXT_EXTI_LINE11
  1936. * @retval None
  1937. */
  1938. __STATIC_INLINE void LL_ADC_REG_SetTriggerSource(ADC_TypeDef *ADCx, uint32_t TriggerSource)
  1939. {
  1940. /* Note: On this STM32 serie, ADC group regular external trigger edge */
  1941. /* is used to perform a ADC conversion start. */
  1942. /* This function does not set external trigger edge. */
  1943. /* This feature is set using function */
  1944. /* @ref LL_ADC_REG_StartConversionExtTrig(). */
  1945. MODIFY_REG(ADCx->CR2, ADC_CR2_EXTSEL, (TriggerSource & ADC_CR2_EXTSEL));
  1946. }
  1947. /**
  1948. * @brief Get ADC group regular conversion trigger source:
  1949. * internal (SW start) or from external IP (timer event,
  1950. * external interrupt line).
  1951. * @note To determine whether group regular trigger source is
  1952. * internal (SW start) or external, without detail
  1953. * of which peripheral is selected as external trigger,
  1954. * (equivalent to
  1955. * "if(LL_ADC_REG_GetTriggerSource(ADC1) == LL_ADC_REG_TRIG_SOFTWARE)")
  1956. * use function @ref LL_ADC_REG_IsTriggerSourceSWStart.
  1957. * @note Availability of parameters of trigger sources from timer
  1958. * depends on timers availability on the selected device.
  1959. * @rmtoll CR2 EXTSEL LL_ADC_REG_GetTriggerSource\n
  1960. * CR2 EXTEN LL_ADC_REG_GetTriggerSource
  1961. * @param ADCx ADC instance
  1962. * @retval Returned value can be one of the following values:
  1963. * @arg @ref LL_ADC_REG_TRIG_SOFTWARE
  1964. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM1_CH1
  1965. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM1_CH2
  1966. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM1_CH3
  1967. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM2_CH2
  1968. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM2_CH3
  1969. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM2_CH4
  1970. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM2_TRGO
  1971. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM3_CH1
  1972. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM3_TRGO
  1973. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM4_CH4
  1974. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM5_CH1
  1975. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM5_CH2
  1976. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM5_CH3
  1977. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM8_CH1
  1978. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM8_TRGO
  1979. * @arg @ref LL_ADC_REG_TRIG_EXT_EXTI_LINE11
  1980. */
  1981. __STATIC_INLINE uint32_t LL_ADC_REG_GetTriggerSource(ADC_TypeDef *ADCx)
  1982. {
  1983. register uint32_t TriggerSource = READ_BIT(ADCx->CR2, ADC_CR2_EXTSEL | ADC_CR2_EXTEN);
  1984. /* Value for shift of {0; 4; 8; 12} depending on value of bitfield */
  1985. /* corresponding to ADC_CR2_EXTEN {0; 1; 2; 3}. */
  1986. register uint32_t ShiftExten = ((TriggerSource & ADC_CR2_EXTEN) >> (ADC_REG_TRIG_EXTEN_BITOFFSET_POS - 2U));
  1987. /* Set bitfield corresponding to ADC_CR2_EXTEN and ADC_CR2_EXTSEL */
  1988. /* to match with triggers literals definition. */
  1989. return ((TriggerSource
  1990. & (ADC_REG_TRIG_SOURCE_MASK << ShiftExten) & ADC_CR2_EXTSEL)
  1991. | ((ADC_REG_TRIG_EDGE_MASK << ShiftExten) & ADC_CR2_EXTEN)
  1992. );
  1993. }
  1994. /**
  1995. * @brief Get ADC group regular conversion trigger source internal (SW start)
  1996. or external.
  1997. * @note In case of group regular trigger source set to external trigger,
  1998. * to determine which peripheral is selected as external trigger,
  1999. * use function @ref LL_ADC_REG_GetTriggerSource().
  2000. * @rmtoll CR2 EXTEN LL_ADC_REG_IsTriggerSourceSWStart
  2001. * @param ADCx ADC instance
  2002. * @retval Value "0" if trigger source external trigger
  2003. * Value "1" if trigger source SW start.
  2004. */
  2005. __STATIC_INLINE uint32_t LL_ADC_REG_IsTriggerSourceSWStart(ADC_TypeDef *ADCx)
  2006. {
  2007. return (READ_BIT(ADCx->CR2, ADC_CR2_EXTEN) == (LL_ADC_REG_TRIG_SOFTWARE & ADC_CR2_EXTEN));
  2008. }
  2009. /**
  2010. * @brief Get ADC group regular conversion trigger polarity.
  2011. * @note Applicable only for trigger source set to external trigger.
  2012. * @note On this STM32 serie, setting of external trigger edge is performed
  2013. * using function @ref LL_ADC_REG_StartConversionExtTrig().
  2014. * @rmtoll CR2 EXTEN LL_ADC_REG_GetTriggerEdge
  2015. * @param ADCx ADC instance
  2016. * @retval Returned value can be one of the following values:
  2017. * @arg @ref LL_ADC_REG_TRIG_EXT_RISING
  2018. * @arg @ref LL_ADC_REG_TRIG_EXT_FALLING
  2019. * @arg @ref LL_ADC_REG_TRIG_EXT_RISINGFALLING
  2020. */
  2021. __STATIC_INLINE uint32_t LL_ADC_REG_GetTriggerEdge(ADC_TypeDef *ADCx)
  2022. {
  2023. return (uint32_t)(READ_BIT(ADCx->CR2, ADC_CR2_EXTEN));
  2024. }
  2025. /**
  2026. * @brief Set ADC group regular sequencer length and scan direction.
  2027. * @note Description of ADC group regular sequencer features:
  2028. * - For devices with sequencer fully configurable
  2029. * (function "LL_ADC_REG_SetSequencerRanks()" available):
  2030. * sequencer length and each rank affectation to a channel
  2031. * are configurable.
  2032. * This function performs configuration of:
  2033. * - Sequence length: Number of ranks in the scan sequence.
  2034. * - Sequence direction: Unless specified in parameters, sequencer
  2035. * scan direction is forward (from rank 1 to rank n).
  2036. * Sequencer ranks are selected using
  2037. * function "LL_ADC_REG_SetSequencerRanks()".
  2038. * - For devices with sequencer not fully configurable
  2039. * (function "LL_ADC_REG_SetSequencerChannels()" available):
  2040. * sequencer length and each rank affectation to a channel
  2041. * are defined by channel number.
  2042. * This function performs configuration of:
  2043. * - Sequence length: Number of ranks in the scan sequence is
  2044. * defined by number of channels set in the sequence,
  2045. * rank of each channel is fixed by channel HW number.
  2046. * (channel 0 fixed on rank 0, channel 1 fixed on rank1, ...).
  2047. * - Sequence direction: Unless specified in parameters, sequencer
  2048. * scan direction is forward (from lowest channel number to
  2049. * highest channel number).
  2050. * Sequencer ranks are selected using
  2051. * function "LL_ADC_REG_SetSequencerChannels()".
  2052. * @note On this STM32 serie, group regular sequencer configuration
  2053. * is conditioned to ADC instance sequencer mode.
  2054. * If ADC instance sequencer mode is disabled, sequencers of
  2055. * all groups (group regular, group injected) can be configured
  2056. * but their execution is disabled (limited to rank 1).
  2057. * Refer to function @ref LL_ADC_SetSequencersScanMode().
  2058. * @note Sequencer disabled is equivalent to sequencer of 1 rank:
  2059. * ADC conversion on only 1 channel.
  2060. * @rmtoll SQR1 L LL_ADC_REG_SetSequencerLength
  2061. * @param ADCx ADC instance
  2062. * @param SequencerNbRanks This parameter can be one of the following values:
  2063. * @arg @ref LL_ADC_REG_SEQ_SCAN_DISABLE
  2064. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_2RANKS
  2065. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_3RANKS
  2066. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_4RANKS
  2067. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_5RANKS
  2068. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_6RANKS
  2069. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_7RANKS
  2070. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_8RANKS
  2071. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_9RANKS
  2072. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_10RANKS
  2073. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_11RANKS
  2074. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_12RANKS
  2075. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_13RANKS
  2076. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_14RANKS
  2077. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_15RANKS
  2078. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_16RANKS
  2079. * @retval None
  2080. */
  2081. __STATIC_INLINE void LL_ADC_REG_SetSequencerLength(ADC_TypeDef *ADCx, uint32_t SequencerNbRanks)
  2082. {
  2083. MODIFY_REG(ADCx->SQR1, ADC_SQR1_L, SequencerNbRanks);
  2084. }
  2085. /**
  2086. * @brief Get ADC group regular sequencer length and scan direction.
  2087. * @note Description of ADC group regular sequencer features:
  2088. * - For devices with sequencer fully configurable
  2089. * (function "LL_ADC_REG_SetSequencerRanks()" available):
  2090. * sequencer length and each rank affectation to a channel
  2091. * are configurable.
  2092. * This function retrieves:
  2093. * - Sequence length: Number of ranks in the scan sequence.
  2094. * - Sequence direction: Unless specified in parameters, sequencer
  2095. * scan direction is forward (from rank 1 to rank n).
  2096. * Sequencer ranks are selected using
  2097. * function "LL_ADC_REG_SetSequencerRanks()".
  2098. * - For devices with sequencer not fully configurable
  2099. * (function "LL_ADC_REG_SetSequencerChannels()" available):
  2100. * sequencer length and each rank affectation to a channel
  2101. * are defined by channel number.
  2102. * This function retrieves:
  2103. * - Sequence length: Number of ranks in the scan sequence is
  2104. * defined by number of channels set in the sequence,
  2105. * rank of each channel is fixed by channel HW number.
  2106. * (channel 0 fixed on rank 0, channel 1 fixed on rank1, ...).
  2107. * - Sequence direction: Unless specified in parameters, sequencer
  2108. * scan direction is forward (from lowest channel number to
  2109. * highest channel number).
  2110. * Sequencer ranks are selected using
  2111. * function "LL_ADC_REG_SetSequencerChannels()".
  2112. * @note On this STM32 serie, group regular sequencer configuration
  2113. * is conditioned to ADC instance sequencer mode.
  2114. * If ADC instance sequencer mode is disabled, sequencers of
  2115. * all groups (group regular, group injected) can be configured
  2116. * but their execution is disabled (limited to rank 1).
  2117. * Refer to function @ref LL_ADC_SetSequencersScanMode().
  2118. * @note Sequencer disabled is equivalent to sequencer of 1 rank:
  2119. * ADC conversion on only 1 channel.
  2120. * @rmtoll SQR1 L LL_ADC_REG_SetSequencerLength
  2121. * @param ADCx ADC instance
  2122. * @retval Returned value can be one of the following values:
  2123. * @arg @ref LL_ADC_REG_SEQ_SCAN_DISABLE
  2124. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_2RANKS
  2125. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_3RANKS
  2126. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_4RANKS
  2127. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_5RANKS
  2128. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_6RANKS
  2129. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_7RANKS
  2130. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_8RANKS
  2131. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_9RANKS
  2132. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_10RANKS
  2133. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_11RANKS
  2134. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_12RANKS
  2135. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_13RANKS
  2136. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_14RANKS
  2137. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_15RANKS
  2138. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_16RANKS
  2139. */
  2140. __STATIC_INLINE uint32_t LL_ADC_REG_GetSequencerLength(ADC_TypeDef *ADCx)
  2141. {
  2142. return (uint32_t)(READ_BIT(ADCx->SQR1, ADC_SQR1_L));
  2143. }
  2144. /**
  2145. * @brief Set ADC group regular sequencer discontinuous mode:
  2146. * sequence subdivided and scan conversions interrupted every selected
  2147. * number of ranks.
  2148. * @note It is not possible to enable both ADC group regular
  2149. * continuous mode and sequencer discontinuous mode.
  2150. * @note It is not possible to enable both ADC auto-injected mode
  2151. * and ADC group regular sequencer discontinuous mode.
  2152. * @rmtoll CR1 DISCEN LL_ADC_REG_SetSequencerDiscont\n
  2153. * CR1 DISCNUM LL_ADC_REG_SetSequencerDiscont
  2154. * @param ADCx ADC instance
  2155. * @param SeqDiscont This parameter can be one of the following values:
  2156. * @arg @ref LL_ADC_REG_SEQ_DISCONT_DISABLE
  2157. * @arg @ref LL_ADC_REG_SEQ_DISCONT_1RANK
  2158. * @arg @ref LL_ADC_REG_SEQ_DISCONT_2RANKS
  2159. * @arg @ref LL_ADC_REG_SEQ_DISCONT_3RANKS
  2160. * @arg @ref LL_ADC_REG_SEQ_DISCONT_4RANKS
  2161. * @arg @ref LL_ADC_REG_SEQ_DISCONT_5RANKS
  2162. * @arg @ref LL_ADC_REG_SEQ_DISCONT_6RANKS
  2163. * @arg @ref LL_ADC_REG_SEQ_DISCONT_7RANKS
  2164. * @arg @ref LL_ADC_REG_SEQ_DISCONT_8RANKS
  2165. * @retval None
  2166. */
  2167. __STATIC_INLINE void LL_ADC_REG_SetSequencerDiscont(ADC_TypeDef *ADCx, uint32_t SeqDiscont)
  2168. {
  2169. MODIFY_REG(ADCx->CR1, ADC_CR1_DISCEN | ADC_CR1_DISCNUM, SeqDiscont);
  2170. }
  2171. /**
  2172. * @brief Get ADC group regular sequencer discontinuous mode:
  2173. * sequence subdivided and scan conversions interrupted every selected
  2174. * number of ranks.
  2175. * @rmtoll CR1 DISCEN LL_ADC_REG_GetSequencerDiscont\n
  2176. * CR1 DISCNUM LL_ADC_REG_GetSequencerDiscont
  2177. * @param ADCx ADC instance
  2178. * @retval Returned value can be one of the following values:
  2179. * @arg @ref LL_ADC_REG_SEQ_DISCONT_DISABLE
  2180. * @arg @ref LL_ADC_REG_SEQ_DISCONT_1RANK
  2181. * @arg @ref LL_ADC_REG_SEQ_DISCONT_2RANKS
  2182. * @arg @ref LL_ADC_REG_SEQ_DISCONT_3RANKS
  2183. * @arg @ref LL_ADC_REG_SEQ_DISCONT_4RANKS
  2184. * @arg @ref LL_ADC_REG_SEQ_DISCONT_5RANKS
  2185. * @arg @ref LL_ADC_REG_SEQ_DISCONT_6RANKS
  2186. * @arg @ref LL_ADC_REG_SEQ_DISCONT_7RANKS
  2187. * @arg @ref LL_ADC_REG_SEQ_DISCONT_8RANKS
  2188. */
  2189. __STATIC_INLINE uint32_t LL_ADC_REG_GetSequencerDiscont(ADC_TypeDef *ADCx)
  2190. {
  2191. return (uint32_t)(READ_BIT(ADCx->CR1, ADC_CR1_DISCEN | ADC_CR1_DISCNUM));
  2192. }
  2193. /**
  2194. * @brief Set ADC group regular sequence: channel on the selected
  2195. * scan sequence rank.
  2196. * @note This function performs configuration of:
  2197. * - Channels ordering into each rank of scan sequence:
  2198. * whatever channel can be placed into whatever rank.
  2199. * @note On this STM32 serie, ADC group regular sequencer is
  2200. * fully configurable: sequencer length and each rank
  2201. * affectation to a channel are configurable.
  2202. * Refer to description of function @ref LL_ADC_REG_SetSequencerLength().
  2203. * @note Depending on devices and packages, some channels may not be available.
  2204. * Refer to device datasheet for channels availability.
  2205. * @note On this STM32 serie, to measure internal channels (VrefInt,
  2206. * TempSensor, ...), measurement paths to internal channels must be
  2207. * enabled separately.
  2208. * This can be done using function @ref LL_ADC_SetCommonPathInternalCh().
  2209. * @rmtoll SQR3 SQ1 LL_ADC_REG_SetSequencerRanks\n
  2210. * SQR3 SQ2 LL_ADC_REG_SetSequencerRanks\n
  2211. * SQR3 SQ3 LL_ADC_REG_SetSequencerRanks\n
  2212. * SQR3 SQ4 LL_ADC_REG_SetSequencerRanks\n
  2213. * SQR3 SQ5 LL_ADC_REG_SetSequencerRanks\n
  2214. * SQR3 SQ6 LL_ADC_REG_SetSequencerRanks\n
  2215. * SQR2 SQ7 LL_ADC_REG_SetSequencerRanks\n
  2216. * SQR2 SQ8 LL_ADC_REG_SetSequencerRanks\n
  2217. * SQR2 SQ9 LL_ADC_REG_SetSequencerRanks\n
  2218. * SQR2 SQ10 LL_ADC_REG_SetSequencerRanks\n
  2219. * SQR2 SQ11 LL_ADC_REG_SetSequencerRanks\n
  2220. * SQR2 SQ12 LL_ADC_REG_SetSequencerRanks\n
  2221. * SQR1 SQ13 LL_ADC_REG_SetSequencerRanks\n
  2222. * SQR1 SQ14 LL_ADC_REG_SetSequencerRanks\n
  2223. * SQR1 SQ15 LL_ADC_REG_SetSequencerRanks\n
  2224. * SQR1 SQ16 LL_ADC_REG_SetSequencerRanks
  2225. * @param ADCx ADC instance
  2226. * @param Rank This parameter can be one of the following values:
  2227. * @arg @ref LL_ADC_REG_RANK_1
  2228. * @arg @ref LL_ADC_REG_RANK_2
  2229. * @arg @ref LL_ADC_REG_RANK_3
  2230. * @arg @ref LL_ADC_REG_RANK_4
  2231. * @arg @ref LL_ADC_REG_RANK_5
  2232. * @arg @ref LL_ADC_REG_RANK_6
  2233. * @arg @ref LL_ADC_REG_RANK_7
  2234. * @arg @ref LL_ADC_REG_RANK_8
  2235. * @arg @ref LL_ADC_REG_RANK_9
  2236. * @arg @ref LL_ADC_REG_RANK_10
  2237. * @arg @ref LL_ADC_REG_RANK_11
  2238. * @arg @ref LL_ADC_REG_RANK_12
  2239. * @arg @ref LL_ADC_REG_RANK_13
  2240. * @arg @ref LL_ADC_REG_RANK_14
  2241. * @arg @ref LL_ADC_REG_RANK_15
  2242. * @arg @ref LL_ADC_REG_RANK_16
  2243. * @param Channel This parameter can be one of the following values:
  2244. * @arg @ref LL_ADC_CHANNEL_0
  2245. * @arg @ref LL_ADC_CHANNEL_1
  2246. * @arg @ref LL_ADC_CHANNEL_2
  2247. * @arg @ref LL_ADC_CHANNEL_3
  2248. * @arg @ref LL_ADC_CHANNEL_4
  2249. * @arg @ref LL_ADC_CHANNEL_5
  2250. * @arg @ref LL_ADC_CHANNEL_6
  2251. * @arg @ref LL_ADC_CHANNEL_7
  2252. * @arg @ref LL_ADC_CHANNEL_8
  2253. * @arg @ref LL_ADC_CHANNEL_9
  2254. * @arg @ref LL_ADC_CHANNEL_10
  2255. * @arg @ref LL_ADC_CHANNEL_11
  2256. * @arg @ref LL_ADC_CHANNEL_12
  2257. * @arg @ref LL_ADC_CHANNEL_13
  2258. * @arg @ref LL_ADC_CHANNEL_14
  2259. * @arg @ref LL_ADC_CHANNEL_15
  2260. * @arg @ref LL_ADC_CHANNEL_16
  2261. * @arg @ref LL_ADC_CHANNEL_17
  2262. * @arg @ref LL_ADC_CHANNEL_18
  2263. * @arg @ref LL_ADC_CHANNEL_VREFINT (1)
  2264. * @arg @ref LL_ADC_CHANNEL_TEMPSENSOR (1)(2)
  2265. * @arg @ref LL_ADC_CHANNEL_VBAT (1)
  2266. *
  2267. * (1) On STM32F4, parameter available only on ADC instance: ADC1.\n
  2268. * (2) On devices STM32F42x and STM32F43x, limitation: this internal channel is shared between temperature sensor and Vbat, only 1 measurement path must be enabled.
  2269. * @retval None
  2270. */
  2271. __STATIC_INLINE void LL_ADC_REG_SetSequencerRanks(ADC_TypeDef *ADCx, uint32_t Rank, uint32_t Channel)
  2272. {
  2273. /* Set bits with content of parameter "Channel" with bits position */
  2274. /* in register and register position depending on parameter "Rank". */
  2275. /* Parameters "Rank" and "Channel" are used with masks because containing */
  2276. /* other bits reserved for other purpose. */
  2277. register __IO uint32_t *preg = __ADC_PTR_REG_OFFSET(ADCx->SQR1, __ADC_MASK_SHIFT(Rank, ADC_REG_SQRX_REGOFFSET_MASK));
  2278. MODIFY_REG(*preg,
  2279. ADC_CHANNEL_ID_NUMBER_MASK << (Rank & ADC_REG_RANK_ID_SQRX_MASK),
  2280. (Channel & ADC_CHANNEL_ID_NUMBER_MASK) << (Rank & ADC_REG_RANK_ID_SQRX_MASK));
  2281. }
  2282. /**
  2283. * @brief Get ADC group regular sequence: channel on the selected
  2284. * scan sequence rank.
  2285. * @note On this STM32 serie, ADC group regular sequencer is
  2286. * fully configurable: sequencer length and each rank
  2287. * affectation to a channel are configurable.
  2288. * Refer to description of function @ref LL_ADC_REG_SetSequencerLength().
  2289. * @note Depending on devices and packages, some channels may not be available.
  2290. * Refer to device datasheet for channels availability.
  2291. * @note Usage of the returned channel number:
  2292. * - To reinject this channel into another function LL_ADC_xxx:
  2293. * the returned channel number is only partly formatted on definition
  2294. * of literals LL_ADC_CHANNEL_x. Therefore, it has to be compared
  2295. * with parts of literals LL_ADC_CHANNEL_x or using
  2296. * helper macro @ref __LL_ADC_CHANNEL_TO_DECIMAL_NB().
  2297. * Then the selected literal LL_ADC_CHANNEL_x can be used
  2298. * as parameter for another function.
  2299. * - To get the channel number in decimal format:
  2300. * process the returned value with the helper macro
  2301. * @ref __LL_ADC_CHANNEL_TO_DECIMAL_NB().
  2302. * @rmtoll SQR3 SQ1 LL_ADC_REG_GetSequencerRanks\n
  2303. * SQR3 SQ2 LL_ADC_REG_GetSequencerRanks\n
  2304. * SQR3 SQ3 LL_ADC_REG_GetSequencerRanks\n
  2305. * SQR3 SQ4 LL_ADC_REG_GetSequencerRanks\n
  2306. * SQR3 SQ5 LL_ADC_REG_GetSequencerRanks\n
  2307. * SQR3 SQ6 LL_ADC_REG_GetSequencerRanks\n
  2308. * SQR2 SQ7 LL_ADC_REG_GetSequencerRanks\n
  2309. * SQR2 SQ8 LL_ADC_REG_GetSequencerRanks\n
  2310. * SQR2 SQ9 LL_ADC_REG_GetSequencerRanks\n
  2311. * SQR2 SQ10 LL_ADC_REG_GetSequencerRanks\n
  2312. * SQR2 SQ11 LL_ADC_REG_GetSequencerRanks\n
  2313. * SQR2 SQ12 LL_ADC_REG_GetSequencerRanks\n
  2314. * SQR1 SQ13 LL_ADC_REG_GetSequencerRanks\n
  2315. * SQR1 SQ14 LL_ADC_REG_GetSequencerRanks\n
  2316. * SQR1 SQ15 LL_ADC_REG_GetSequencerRanks\n
  2317. * SQR1 SQ16 LL_ADC_REG_GetSequencerRanks
  2318. * @param ADCx ADC instance
  2319. * @param Rank This parameter can be one of the following values:
  2320. * @arg @ref LL_ADC_REG_RANK_1
  2321. * @arg @ref LL_ADC_REG_RANK_2
  2322. * @arg @ref LL_ADC_REG_RANK_3
  2323. * @arg @ref LL_ADC_REG_RANK_4
  2324. * @arg @ref LL_ADC_REG_RANK_5
  2325. * @arg @ref LL_ADC_REG_RANK_6
  2326. * @arg @ref LL_ADC_REG_RANK_7
  2327. * @arg @ref LL_ADC_REG_RANK_8
  2328. * @arg @ref LL_ADC_REG_RANK_9
  2329. * @arg @ref LL_ADC_REG_RANK_10
  2330. * @arg @ref LL_ADC_REG_RANK_11
  2331. * @arg @ref LL_ADC_REG_RANK_12
  2332. * @arg @ref LL_ADC_REG_RANK_13
  2333. * @arg @ref LL_ADC_REG_RANK_14
  2334. * @arg @ref LL_ADC_REG_RANK_15
  2335. * @arg @ref LL_ADC_REG_RANK_16
  2336. * @retval Returned value can be one of the following values:
  2337. * @arg @ref LL_ADC_CHANNEL_0
  2338. * @arg @ref LL_ADC_CHANNEL_1
  2339. * @arg @ref LL_ADC_CHANNEL_2
  2340. * @arg @ref LL_ADC_CHANNEL_3
  2341. * @arg @ref LL_ADC_CHANNEL_4
  2342. * @arg @ref LL_ADC_CHANNEL_5
  2343. * @arg @ref LL_ADC_CHANNEL_6
  2344. * @arg @ref LL_ADC_CHANNEL_7
  2345. * @arg @ref LL_ADC_CHANNEL_8
  2346. * @arg @ref LL_ADC_CHANNEL_9
  2347. * @arg @ref LL_ADC_CHANNEL_10
  2348. * @arg @ref LL_ADC_CHANNEL_11
  2349. * @arg @ref LL_ADC_CHANNEL_12
  2350. * @arg @ref LL_ADC_CHANNEL_13
  2351. * @arg @ref LL_ADC_CHANNEL_14
  2352. * @arg @ref LL_ADC_CHANNEL_15
  2353. * @arg @ref LL_ADC_CHANNEL_16
  2354. * @arg @ref LL_ADC_CHANNEL_17
  2355. * @arg @ref LL_ADC_CHANNEL_18
  2356. * @arg @ref LL_ADC_CHANNEL_VREFINT (1)
  2357. * @arg @ref LL_ADC_CHANNEL_TEMPSENSOR (1)(2)
  2358. * @arg @ref LL_ADC_CHANNEL_VBAT (1)
  2359. *
  2360. * (1) On STM32F4, parameter available only on ADC instance: ADC1.\n
  2361. * (2) On devices STM32F42x and STM32F43x, limitation: this internal channel is shared between temperature sensor and Vbat, only 1 measurement path must be enabled.\n
  2362. * (1) For ADC channel read back from ADC register,
  2363. * comparison with internal channel parameter to be done
  2364. * using helper macro @ref __LL_ADC_CHANNEL_INTERNAL_TO_EXTERNAL().
  2365. */
  2366. __STATIC_INLINE uint32_t LL_ADC_REG_GetSequencerRanks(ADC_TypeDef *ADCx, uint32_t Rank)
  2367. {
  2368. register __IO uint32_t *preg = __ADC_PTR_REG_OFFSET(ADCx->SQR1, __ADC_MASK_SHIFT(Rank, ADC_REG_SQRX_REGOFFSET_MASK));
  2369. return (uint32_t) (READ_BIT(*preg,
  2370. ADC_CHANNEL_ID_NUMBER_MASK << (Rank & ADC_REG_RANK_ID_SQRX_MASK))
  2371. >> (Rank & ADC_REG_RANK_ID_SQRX_MASK)
  2372. );
  2373. }
  2374. /**
  2375. * @brief Set ADC continuous conversion mode on ADC group regular.
  2376. * @note Description of ADC continuous conversion mode:
  2377. * - single mode: one conversion per trigger
  2378. * - continuous mode: after the first trigger, following
  2379. * conversions launched successively automatically.
  2380. * @note It is not possible to enable both ADC group regular
  2381. * continuous mode and sequencer discontinuous mode.
  2382. * @rmtoll CR2 CONT LL_ADC_REG_SetContinuousMode
  2383. * @param ADCx ADC instance
  2384. * @param Continuous This parameter can be one of the following values:
  2385. * @arg @ref LL_ADC_REG_CONV_SINGLE
  2386. * @arg @ref LL_ADC_REG_CONV_CONTINUOUS
  2387. * @retval None
  2388. */
  2389. __STATIC_INLINE void LL_ADC_REG_SetContinuousMode(ADC_TypeDef *ADCx, uint32_t Continuous)
  2390. {
  2391. MODIFY_REG(ADCx->CR2, ADC_CR2_CONT, Continuous);
  2392. }
  2393. /**
  2394. * @brief Get ADC continuous conversion mode on ADC group regular.
  2395. * @note Description of ADC continuous conversion mode:
  2396. * - single mode: one conversion per trigger
  2397. * - continuous mode: after the first trigger, following
  2398. * conversions launched successively automatically.
  2399. * @rmtoll CR2 CONT LL_ADC_REG_GetContinuousMode
  2400. * @param ADCx ADC instance
  2401. * @retval Returned value can be one of the following values:
  2402. * @arg @ref LL_ADC_REG_CONV_SINGLE
  2403. * @arg @ref LL_ADC_REG_CONV_CONTINUOUS
  2404. */
  2405. __STATIC_INLINE uint32_t LL_ADC_REG_GetContinuousMode(ADC_TypeDef *ADCx)
  2406. {
  2407. return (uint32_t)(READ_BIT(ADCx->CR2, ADC_CR2_CONT));
  2408. }
  2409. /**
  2410. * @brief Set ADC group regular conversion data transfer: no transfer or
  2411. * transfer by DMA, and DMA requests mode.
  2412. * @note If transfer by DMA selected, specifies the DMA requests
  2413. * mode:
  2414. * - Limited mode (One shot mode): DMA transfer requests are stopped
  2415. * when number of DMA data transfers (number of
  2416. * ADC conversions) is reached.
  2417. * This ADC mode is intended to be used with DMA mode non-circular.
  2418. * - Unlimited mode: DMA transfer requests are unlimited,
  2419. * whatever number of DMA data transfers (number of
  2420. * ADC conversions).
  2421. * This ADC mode is intended to be used with DMA mode circular.
  2422. * @note If ADC DMA requests mode is set to unlimited and DMA is set to
  2423. * mode non-circular:
  2424. * when DMA transfers size will be reached, DMA will stop transfers of
  2425. * ADC conversions data ADC will raise an overrun error
  2426. * (overrun flag and interruption if enabled).
  2427. * @note For devices with several ADC instances: ADC multimode DMA
  2428. * settings are available using function @ref LL_ADC_SetMultiDMATransfer().
  2429. * @note To configure DMA source address (peripheral address),
  2430. * use function @ref LL_ADC_DMA_GetRegAddr().
  2431. * @rmtoll CR2 DMA LL_ADC_REG_SetDMATransfer\n
  2432. * CR2 DDS LL_ADC_REG_SetDMATransfer
  2433. * @param ADCx ADC instance
  2434. * @param DMATransfer This parameter can be one of the following values:
  2435. * @arg @ref LL_ADC_REG_DMA_TRANSFER_NONE
  2436. * @arg @ref LL_ADC_REG_DMA_TRANSFER_LIMITED
  2437. * @arg @ref LL_ADC_REG_DMA_TRANSFER_UNLIMITED
  2438. * @retval None
  2439. */
  2440. __STATIC_INLINE void LL_ADC_REG_SetDMATransfer(ADC_TypeDef *ADCx, uint32_t DMATransfer)
  2441. {
  2442. MODIFY_REG(ADCx->CR2, ADC_CR2_DMA | ADC_CR2_DDS, DMATransfer);
  2443. }
  2444. /**
  2445. * @brief Get ADC group regular conversion data transfer: no transfer or
  2446. * transfer by DMA, and DMA requests mode.
  2447. * @note If transfer by DMA selected, specifies the DMA requests
  2448. * mode:
  2449. * - Limited mode (One shot mode): DMA transfer requests are stopped
  2450. * when number of DMA data transfers (number of
  2451. * ADC conversions) is reached.
  2452. * This ADC mode is intended to be used with DMA mode non-circular.
  2453. * - Unlimited mode: DMA transfer requests are unlimited,
  2454. * whatever number of DMA data transfers (number of
  2455. * ADC conversions).
  2456. * This ADC mode is intended to be used with DMA mode circular.
  2457. * @note If ADC DMA requests mode is set to unlimited and DMA is set to
  2458. * mode non-circular:
  2459. * when DMA transfers size will be reached, DMA will stop transfers of
  2460. * ADC conversions data ADC will raise an overrun error
  2461. * (overrun flag and interruption if enabled).
  2462. * @note For devices with several ADC instances: ADC multimode DMA
  2463. * settings are available using function @ref LL_ADC_GetMultiDMATransfer().
  2464. * @note To configure DMA source address (peripheral address),
  2465. * use function @ref LL_ADC_DMA_GetRegAddr().
  2466. * @rmtoll CR2 DMA LL_ADC_REG_GetDMATransfer\n
  2467. * CR2 DDS LL_ADC_REG_GetDMATransfer
  2468. * @param ADCx ADC instance
  2469. * @retval Returned value can be one of the following values:
  2470. * @arg @ref LL_ADC_REG_DMA_TRANSFER_NONE
  2471. * @arg @ref LL_ADC_REG_DMA_TRANSFER_LIMITED
  2472. * @arg @ref LL_ADC_REG_DMA_TRANSFER_UNLIMITED
  2473. */
  2474. __STATIC_INLINE uint32_t LL_ADC_REG_GetDMATransfer(ADC_TypeDef *ADCx)
  2475. {
  2476. return (uint32_t)(READ_BIT(ADCx->CR2, ADC_CR2_DMA | ADC_CR2_DDS));
  2477. }
  2478. /**
  2479. * @brief Specify which ADC flag between EOC (end of unitary conversion)
  2480. * or EOS (end of sequence conversions) is used to indicate
  2481. * the end of conversion.
  2482. * @note This feature is aimed to be set when using ADC with
  2483. * programming model by polling or interruption
  2484. * (programming model by DMA usually uses DMA interruptions
  2485. * to indicate end of conversion and data transfer).
  2486. * @note For ADC group injected, end of conversion (flag&IT) is raised
  2487. * only at the end of the sequence.
  2488. * @rmtoll CR2 EOCS LL_ADC_REG_SetFlagEndOfConversion
  2489. * @param ADCx ADC instance
  2490. * @param EocSelection This parameter can be one of the following values:
  2491. * @arg @ref LL_ADC_REG_FLAG_EOC_SEQUENCE_CONV
  2492. * @arg @ref LL_ADC_REG_FLAG_EOC_UNITARY_CONV
  2493. * @retval None
  2494. */
  2495. __STATIC_INLINE void LL_ADC_REG_SetFlagEndOfConversion(ADC_TypeDef *ADCx, uint32_t EocSelection)
  2496. {
  2497. MODIFY_REG(ADCx->CR2, ADC_CR2_EOCS, EocSelection);
  2498. }
  2499. /**
  2500. * @brief Get which ADC flag between EOC (end of unitary conversion)
  2501. * or EOS (end of sequence conversions) is used to indicate
  2502. * the end of conversion.
  2503. * @rmtoll CR2 EOCS LL_ADC_REG_GetFlagEndOfConversion
  2504. * @param ADCx ADC instance
  2505. * @retval Returned value can be one of the following values:
  2506. * @arg @ref LL_ADC_REG_FLAG_EOC_SEQUENCE_CONV
  2507. * @arg @ref LL_ADC_REG_FLAG_EOC_UNITARY_CONV
  2508. */
  2509. __STATIC_INLINE uint32_t LL_ADC_REG_GetFlagEndOfConversion(ADC_TypeDef *ADCx)
  2510. {
  2511. return (uint32_t)(READ_BIT(ADCx->CR2, ADC_CR2_EOCS));
  2512. }
  2513. /**
  2514. * @}
  2515. */
  2516. /** @defgroup ADC_LL_EF_Configuration_ADC_Group_Injected Configuration of ADC hierarchical scope: group injected
  2517. * @{
  2518. */
  2519. /**
  2520. * @brief Set ADC group injected conversion trigger source:
  2521. * internal (SW start) or from external IP (timer event,
  2522. * external interrupt line).
  2523. * @note On this STM32 serie, setting of external trigger edge is performed
  2524. * using function @ref LL_ADC_INJ_StartConversionExtTrig().
  2525. * @note Availability of parameters of trigger sources from timer
  2526. * depends on timers availability on the selected device.
  2527. * @rmtoll CR2 JEXTSEL LL_ADC_INJ_SetTriggerSource\n
  2528. * CR2 JEXTEN LL_ADC_INJ_SetTriggerSource
  2529. * @param ADCx ADC instance
  2530. * @param TriggerSource This parameter can be one of the following values:
  2531. * @arg @ref LL_ADC_INJ_TRIG_SOFTWARE
  2532. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM1_CH4
  2533. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM1_TRGO
  2534. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM2_CH1
  2535. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM2_TRGO
  2536. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM3_CH2
  2537. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM3_CH4
  2538. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM4_CH1
  2539. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM4_CH2
  2540. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM4_CH3
  2541. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM4_TRGO
  2542. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM5_CH4
  2543. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM5_TRGO
  2544. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM8_CH2
  2545. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM8_CH3
  2546. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM8_CH4
  2547. * @arg @ref LL_ADC_INJ_TRIG_EXT_EXTI_LINE15
  2548. * @retval None
  2549. */
  2550. __STATIC_INLINE void LL_ADC_INJ_SetTriggerSource(ADC_TypeDef *ADCx, uint32_t TriggerSource)
  2551. {
  2552. /* Note: On this STM32 serie, ADC group injected external trigger edge */
  2553. /* is used to perform a ADC conversion start. */
  2554. /* This function does not set external trigger edge. */
  2555. /* This feature is set using function */
  2556. /* @ref LL_ADC_INJ_StartConversionExtTrig(). */
  2557. MODIFY_REG(ADCx->CR2, ADC_CR2_JEXTSEL, (TriggerSource & ADC_CR2_JEXTSEL));
  2558. }
  2559. /**
  2560. * @brief Get ADC group injected conversion trigger source:
  2561. * internal (SW start) or from external IP (timer event,
  2562. * external interrupt line).
  2563. * @note To determine whether group injected trigger source is
  2564. * internal (SW start) or external, without detail
  2565. * of which peripheral is selected as external trigger,
  2566. * (equivalent to
  2567. * "if(LL_ADC_INJ_GetTriggerSource(ADC1) == LL_ADC_INJ_TRIG_SOFTWARE)")
  2568. * use function @ref LL_ADC_INJ_IsTriggerSourceSWStart.
  2569. * @note Availability of parameters of trigger sources from timer
  2570. * depends on timers availability on the selected device.
  2571. * @rmtoll CR2 JEXTSEL LL_ADC_INJ_GetTriggerSource\n
  2572. * CR2 JEXTEN LL_ADC_INJ_GetTriggerSource
  2573. * @param ADCx ADC instance
  2574. * @retval Returned value can be one of the following values:
  2575. * @arg @ref LL_ADC_INJ_TRIG_SOFTWARE
  2576. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM1_CH4
  2577. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM1_TRGO
  2578. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM2_CH1
  2579. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM2_TRGO
  2580. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM3_CH2
  2581. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM3_CH4
  2582. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM4_CH1
  2583. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM4_CH2
  2584. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM4_CH3
  2585. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM4_TRGO
  2586. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM5_CH4
  2587. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM5_TRGO
  2588. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM8_CH2
  2589. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM8_CH3
  2590. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM8_CH4
  2591. * @arg @ref LL_ADC_INJ_TRIG_EXT_EXTI_LINE15
  2592. */
  2593. __STATIC_INLINE uint32_t LL_ADC_INJ_GetTriggerSource(ADC_TypeDef *ADCx)
  2594. {
  2595. register uint32_t TriggerSource = READ_BIT(ADCx->CR2, ADC_CR2_JEXTSEL | ADC_CR2_JEXTEN);
  2596. /* Value for shift of {0; 4; 8; 12} depending on value of bitfield */
  2597. /* corresponding to ADC_CR2_JEXTEN {0; 1; 2; 3}. */
  2598. register uint32_t ShiftExten = ((TriggerSource & ADC_CR2_JEXTEN) >> (ADC_INJ_TRIG_EXTEN_BITOFFSET_POS - 2U));
  2599. /* Set bitfield corresponding to ADC_CR2_JEXTEN and ADC_CR2_JEXTSEL */
  2600. /* to match with triggers literals definition. */
  2601. return ((TriggerSource
  2602. & (ADC_INJ_TRIG_SOURCE_MASK << ShiftExten) & ADC_CR2_JEXTSEL)
  2603. | ((ADC_INJ_TRIG_EDGE_MASK << ShiftExten) & ADC_CR2_JEXTEN)
  2604. );
  2605. }
  2606. /**
  2607. * @brief Get ADC group injected conversion trigger source internal (SW start)
  2608. or external
  2609. * @note In case of group injected trigger source set to external trigger,
  2610. * to determine which peripheral is selected as external trigger,
  2611. * use function @ref LL_ADC_INJ_GetTriggerSource.
  2612. * @rmtoll CR2 JEXTEN LL_ADC_INJ_IsTriggerSourceSWStart
  2613. * @param ADCx ADC instance
  2614. * @retval Value "0" if trigger source external trigger
  2615. * Value "1" if trigger source SW start.
  2616. */
  2617. __STATIC_INLINE uint32_t LL_ADC_INJ_IsTriggerSourceSWStart(ADC_TypeDef *ADCx)
  2618. {
  2619. return (READ_BIT(ADCx->CR2, ADC_CR2_JEXTEN) == (LL_ADC_INJ_TRIG_SOFTWARE & ADC_CR2_JEXTEN));
  2620. }
  2621. /**
  2622. * @brief Get ADC group injected conversion trigger polarity.
  2623. * Applicable only for trigger source set to external trigger.
  2624. * @rmtoll CR2 JEXTEN LL_ADC_INJ_GetTriggerEdge
  2625. * @param ADCx ADC instance
  2626. * @retval Returned value can be one of the following values:
  2627. * @arg @ref LL_ADC_INJ_TRIG_EXT_RISING
  2628. * @arg @ref LL_ADC_INJ_TRIG_EXT_FALLING
  2629. * @arg @ref LL_ADC_INJ_TRIG_EXT_RISINGFALLING
  2630. */
  2631. __STATIC_INLINE uint32_t LL_ADC_INJ_GetTriggerEdge(ADC_TypeDef *ADCx)
  2632. {
  2633. return (uint32_t)(READ_BIT(ADCx->CR2, ADC_CR2_JEXTEN));
  2634. }
  2635. /**
  2636. * @brief Set ADC group injected sequencer length and scan direction.
  2637. * @note This function performs configuration of:
  2638. * - Sequence length: Number of ranks in the scan sequence.
  2639. * - Sequence direction: Unless specified in parameters, sequencer
  2640. * scan direction is forward (from rank 1 to rank n).
  2641. * @note On this STM32 serie, group injected sequencer configuration
  2642. * is conditioned to ADC instance sequencer mode.
  2643. * If ADC instance sequencer mode is disabled, sequencers of
  2644. * all groups (group regular, group injected) can be configured
  2645. * but their execution is disabled (limited to rank 1).
  2646. * Refer to function @ref LL_ADC_SetSequencersScanMode().
  2647. * @note Sequencer disabled is equivalent to sequencer of 1 rank:
  2648. * ADC conversion on only 1 channel.
  2649. * @rmtoll JSQR JL LL_ADC_INJ_SetSequencerLength
  2650. * @param ADCx ADC instance
  2651. * @param SequencerNbRanks This parameter can be one of the following values:
  2652. * @arg @ref LL_ADC_INJ_SEQ_SCAN_DISABLE
  2653. * @arg @ref LL_ADC_INJ_SEQ_SCAN_ENABLE_2RANKS
  2654. * @arg @ref LL_ADC_INJ_SEQ_SCAN_ENABLE_3RANKS
  2655. * @arg @ref LL_ADC_INJ_SEQ_SCAN_ENABLE_4RANKS
  2656. * @retval None
  2657. */
  2658. __STATIC_INLINE void LL_ADC_INJ_SetSequencerLength(ADC_TypeDef *ADCx, uint32_t SequencerNbRanks)
  2659. {
  2660. MODIFY_REG(ADCx->JSQR, ADC_JSQR_JL, SequencerNbRanks);
  2661. }
  2662. /**
  2663. * @brief Get ADC group injected sequencer length and scan direction.
  2664. * @note This function retrieves:
  2665. * - Sequence length: Number of ranks in the scan sequence.
  2666. * - Sequence direction: Unless specified in parameters, sequencer
  2667. * scan direction is forward (from rank 1 to rank n).
  2668. * @note On this STM32 serie, group injected sequencer configuration
  2669. * is conditioned to ADC instance sequencer mode.
  2670. * If ADC instance sequencer mode is disabled, sequencers of
  2671. * all groups (group regular, group injected) can be configured
  2672. * but their execution is disabled (limited to rank 1).
  2673. * Refer to function @ref LL_ADC_SetSequencersScanMode().
  2674. * @note Sequencer disabled is equivalent to sequencer of 1 rank:
  2675. * ADC conversion on only 1 channel.
  2676. * @rmtoll JSQR JL LL_ADC_INJ_GetSequencerLength
  2677. * @param ADCx ADC instance
  2678. * @retval Returned value can be one of the following values:
  2679. * @arg @ref LL_ADC_INJ_SEQ_SCAN_DISABLE
  2680. * @arg @ref LL_ADC_INJ_SEQ_SCAN_ENABLE_2RANKS
  2681. * @arg @ref LL_ADC_INJ_SEQ_SCAN_ENABLE_3RANKS
  2682. * @arg @ref LL_ADC_INJ_SEQ_SCAN_ENABLE_4RANKS
  2683. */
  2684. __STATIC_INLINE uint32_t LL_ADC_INJ_GetSequencerLength(ADC_TypeDef *ADCx)
  2685. {
  2686. return (uint32_t)(READ_BIT(ADCx->JSQR, ADC_JSQR_JL));
  2687. }
  2688. /**
  2689. * @brief Set ADC group injected sequencer discontinuous mode:
  2690. * sequence subdivided and scan conversions interrupted every selected
  2691. * number of ranks.
  2692. * @note It is not possible to enable both ADC group injected
  2693. * auto-injected mode and sequencer discontinuous mode.
  2694. * @rmtoll CR1 DISCEN LL_ADC_INJ_SetSequencerDiscont
  2695. * @param ADCx ADC instance
  2696. * @param SeqDiscont This parameter can be one of the following values:
  2697. * @arg @ref LL_ADC_INJ_SEQ_DISCONT_DISABLE
  2698. * @arg @ref LL_ADC_INJ_SEQ_DISCONT_1RANK
  2699. * @retval None
  2700. */
  2701. __STATIC_INLINE void LL_ADC_INJ_SetSequencerDiscont(ADC_TypeDef *ADCx, uint32_t SeqDiscont)
  2702. {
  2703. MODIFY_REG(ADCx->CR1, ADC_CR1_JDISCEN, SeqDiscont);
  2704. }
  2705. /**
  2706. * @brief Get ADC group injected sequencer discontinuous mode:
  2707. * sequence subdivided and scan conversions interrupted every selected
  2708. * number of ranks.
  2709. * @rmtoll CR1 DISCEN LL_ADC_REG_GetSequencerDiscont
  2710. * @param ADCx ADC instance
  2711. * @retval Returned value can be one of the following values:
  2712. * @arg @ref LL_ADC_INJ_SEQ_DISCONT_DISABLE
  2713. * @arg @ref LL_ADC_INJ_SEQ_DISCONT_1RANK
  2714. */
  2715. __STATIC_INLINE uint32_t LL_ADC_INJ_GetSequencerDiscont(ADC_TypeDef *ADCx)
  2716. {
  2717. return (uint32_t)(READ_BIT(ADCx->CR1, ADC_CR1_JDISCEN));
  2718. }
  2719. /**
  2720. * @brief Set ADC group injected sequence: channel on the selected
  2721. * sequence rank.
  2722. * @note Depending on devices and packages, some channels may not be available.
  2723. * Refer to device datasheet for channels availability.
  2724. * @note On this STM32 serie, to measure internal channels (VrefInt,
  2725. * TempSensor, ...), measurement paths to internal channels must be
  2726. * enabled separately.
  2727. * This can be done using function @ref LL_ADC_SetCommonPathInternalCh().
  2728. * @rmtoll JSQR JSQ1 LL_ADC_INJ_SetSequencerRanks\n
  2729. * JSQR JSQ2 LL_ADC_INJ_SetSequencerRanks\n
  2730. * JSQR JSQ3 LL_ADC_INJ_SetSequencerRanks\n
  2731. * JSQR JSQ4 LL_ADC_INJ_SetSequencerRanks
  2732. * @param ADCx ADC instance
  2733. * @param Rank This parameter can be one of the following values:
  2734. * @arg @ref LL_ADC_INJ_RANK_1
  2735. * @arg @ref LL_ADC_INJ_RANK_2
  2736. * @arg @ref LL_ADC_INJ_RANK_3
  2737. * @arg @ref LL_ADC_INJ_RANK_4
  2738. * @param Channel This parameter can be one of the following values:
  2739. * @arg @ref LL_ADC_CHANNEL_0
  2740. * @arg @ref LL_ADC_CHANNEL_1
  2741. * @arg @ref LL_ADC_CHANNEL_2
  2742. * @arg @ref LL_ADC_CHANNEL_3
  2743. * @arg @ref LL_ADC_CHANNEL_4
  2744. * @arg @ref LL_ADC_CHANNEL_5
  2745. * @arg @ref LL_ADC_CHANNEL_6
  2746. * @arg @ref LL_ADC_CHANNEL_7
  2747. * @arg @ref LL_ADC_CHANNEL_8
  2748. * @arg @ref LL_ADC_CHANNEL_9
  2749. * @arg @ref LL_ADC_CHANNEL_10
  2750. * @arg @ref LL_ADC_CHANNEL_11
  2751. * @arg @ref LL_ADC_CHANNEL_12
  2752. * @arg @ref LL_ADC_CHANNEL_13
  2753. * @arg @ref LL_ADC_CHANNEL_14
  2754. * @arg @ref LL_ADC_CHANNEL_15
  2755. * @arg @ref LL_ADC_CHANNEL_16
  2756. * @arg @ref LL_ADC_CHANNEL_17
  2757. * @arg @ref LL_ADC_CHANNEL_18
  2758. * @arg @ref LL_ADC_CHANNEL_VREFINT (1)
  2759. * @arg @ref LL_ADC_CHANNEL_TEMPSENSOR (1)(2)
  2760. * @arg @ref LL_ADC_CHANNEL_VBAT (1)
  2761. *
  2762. * (1) On STM32F4, parameter available only on ADC instance: ADC1.\n
  2763. * (2) On devices STM32F42x and STM32F43x, limitation: this internal channel is shared between temperature sensor and Vbat, only 1 measurement path must be enabled.
  2764. * @retval None
  2765. */
  2766. __STATIC_INLINE void LL_ADC_INJ_SetSequencerRanks(ADC_TypeDef *ADCx, uint32_t Rank, uint32_t Channel)
  2767. {
  2768. /* Set bits with content of parameter "Channel" with bits position */
  2769. /* in register depending on parameter "Rank". */
  2770. /* Parameters "Rank" and "Channel" are used with masks because containing */
  2771. /* other bits reserved for other purpose. */
  2772. register uint32_t tmpreg1 = (READ_BIT(ADCx->JSQR, ADC_JSQR_JL) >> ADC_JSQR_JL_Pos) + 1U;
  2773. MODIFY_REG(ADCx->JSQR,
  2774. ADC_CHANNEL_ID_NUMBER_MASK << (5U * (uint8_t)(((Rank) + 3U) - (tmpreg1))),
  2775. (Channel & ADC_CHANNEL_ID_NUMBER_MASK) << (5U * (uint8_t)(((Rank) + 3U) - (tmpreg1))));
  2776. }
  2777. /**
  2778. * @brief Get ADC group injected sequence: channel on the selected
  2779. * sequence rank.
  2780. * @note Depending on devices and packages, some channels may not be available.
  2781. * Refer to device datasheet for channels availability.
  2782. * @note Usage of the returned channel number:
  2783. * - To reinject this channel into another function LL_ADC_xxx:
  2784. * the returned channel number is only partly formatted on definition
  2785. * of literals LL_ADC_CHANNEL_x. Therefore, it has to be compared
  2786. * with parts of literals LL_ADC_CHANNEL_x or using
  2787. * helper macro @ref __LL_ADC_CHANNEL_TO_DECIMAL_NB().
  2788. * Then the selected literal LL_ADC_CHANNEL_x can be used
  2789. * as parameter for another function.
  2790. * - To get the channel number in decimal format:
  2791. * process the returned value with the helper macro
  2792. * @ref __LL_ADC_CHANNEL_TO_DECIMAL_NB().
  2793. * @rmtoll JSQR JSQ1 LL_ADC_INJ_SetSequencerRanks\n
  2794. * JSQR JSQ2 LL_ADC_INJ_SetSequencerRanks\n
  2795. * JSQR JSQ3 LL_ADC_INJ_SetSequencerRanks\n
  2796. * JSQR JSQ4 LL_ADC_INJ_SetSequencerRanks
  2797. * @param ADCx ADC instance
  2798. * @param Rank This parameter can be one of the following values:
  2799. * @arg @ref LL_ADC_INJ_RANK_1
  2800. * @arg @ref LL_ADC_INJ_RANK_2
  2801. * @arg @ref LL_ADC_INJ_RANK_3
  2802. * @arg @ref LL_ADC_INJ_RANK_4
  2803. * @retval Returned value can be one of the following values:
  2804. * @arg @ref LL_ADC_CHANNEL_0
  2805. * @arg @ref LL_ADC_CHANNEL_1
  2806. * @arg @ref LL_ADC_CHANNEL_2
  2807. * @arg @ref LL_ADC_CHANNEL_3
  2808. * @arg @ref LL_ADC_CHANNEL_4
  2809. * @arg @ref LL_ADC_CHANNEL_5
  2810. * @arg @ref LL_ADC_CHANNEL_6
  2811. * @arg @ref LL_ADC_CHANNEL_7
  2812. * @arg @ref LL_ADC_CHANNEL_8
  2813. * @arg @ref LL_ADC_CHANNEL_9
  2814. * @arg @ref LL_ADC_CHANNEL_10
  2815. * @arg @ref LL_ADC_CHANNEL_11
  2816. * @arg @ref LL_ADC_CHANNEL_12
  2817. * @arg @ref LL_ADC_CHANNEL_13
  2818. * @arg @ref LL_ADC_CHANNEL_14
  2819. * @arg @ref LL_ADC_CHANNEL_15
  2820. * @arg @ref LL_ADC_CHANNEL_16
  2821. * @arg @ref LL_ADC_CHANNEL_17
  2822. * @arg @ref LL_ADC_CHANNEL_18
  2823. * @arg @ref LL_ADC_CHANNEL_VREFINT (1)
  2824. * @arg @ref LL_ADC_CHANNEL_TEMPSENSOR (1)(2)
  2825. * @arg @ref LL_ADC_CHANNEL_VBAT (1)
  2826. *
  2827. * (1) On STM32F4, parameter available only on ADC instance: ADC1.\n
  2828. * (2) On devices STM32F42x and STM32F43x, limitation: this internal channel is shared between temperature sensor and Vbat, only 1 measurement path must be enabled.\n
  2829. * (1) For ADC channel read back from ADC register,
  2830. * comparison with internal channel parameter to be done
  2831. * using helper macro @ref __LL_ADC_CHANNEL_INTERNAL_TO_EXTERNAL().
  2832. */
  2833. __STATIC_INLINE uint32_t LL_ADC_INJ_GetSequencerRanks(ADC_TypeDef *ADCx, uint32_t Rank)
  2834. {
  2835. register uint32_t tmpreg1 = (READ_BIT(ADCx->JSQR, ADC_JSQR_JL) >> ADC_JSQR_JL_Pos) + 1U;
  2836. return (uint32_t)(READ_BIT(ADCx->JSQR,
  2837. ADC_CHANNEL_ID_NUMBER_MASK << (5U * (uint8_t)(((Rank) + 3U) - (tmpreg1))))
  2838. >> (5U * (uint8_t)(((Rank) + 3U) - (tmpreg1)))
  2839. );
  2840. }
  2841. /**
  2842. * @brief Set ADC group injected conversion trigger:
  2843. * independent or from ADC group regular.
  2844. * @note This mode can be used to extend number of data registers
  2845. * updated after one ADC conversion trigger and with data
  2846. * permanently kept (not erased by successive conversions of scan of
  2847. * ADC sequencer ranks), up to 5 data registers:
  2848. * 1 data register on ADC group regular, 4 data registers
  2849. * on ADC group injected.
  2850. * @note If ADC group injected injected trigger source is set to an
  2851. * external trigger, this feature must be must be set to
  2852. * independent trigger.
  2853. * ADC group injected automatic trigger is compliant only with
  2854. * group injected trigger source set to SW start, without any
  2855. * further action on ADC group injected conversion start or stop:
  2856. * in this case, ADC group injected is controlled only
  2857. * from ADC group regular.
  2858. * @note It is not possible to enable both ADC group injected
  2859. * auto-injected mode and sequencer discontinuous mode.
  2860. * @rmtoll CR1 JAUTO LL_ADC_INJ_SetTrigAuto
  2861. * @param ADCx ADC instance
  2862. * @param TrigAuto This parameter can be one of the following values:
  2863. * @arg @ref LL_ADC_INJ_TRIG_INDEPENDENT
  2864. * @arg @ref LL_ADC_INJ_TRIG_FROM_GRP_REGULAR
  2865. * @retval None
  2866. */
  2867. __STATIC_INLINE void LL_ADC_INJ_SetTrigAuto(ADC_TypeDef *ADCx, uint32_t TrigAuto)
  2868. {
  2869. MODIFY_REG(ADCx->CR1, ADC_CR1_JAUTO, TrigAuto);
  2870. }
  2871. /**
  2872. * @brief Get ADC group injected conversion trigger:
  2873. * independent or from ADC group regular.
  2874. * @rmtoll CR1 JAUTO LL_ADC_INJ_GetTrigAuto
  2875. * @param ADCx ADC instance
  2876. * @retval Returned value can be one of the following values:
  2877. * @arg @ref LL_ADC_INJ_TRIG_INDEPENDENT
  2878. * @arg @ref LL_ADC_INJ_TRIG_FROM_GRP_REGULAR
  2879. */
  2880. __STATIC_INLINE uint32_t LL_ADC_INJ_GetTrigAuto(ADC_TypeDef *ADCx)
  2881. {
  2882. return (uint32_t)(READ_BIT(ADCx->CR1, ADC_CR1_JAUTO));
  2883. }
  2884. /**
  2885. * @brief Set ADC group injected offset.
  2886. * @note It sets:
  2887. * - ADC group injected rank to which the offset programmed
  2888. * will be applied
  2889. * - Offset level (offset to be subtracted from the raw
  2890. * converted data).
  2891. * Caution: Offset format is dependent to ADC resolution:
  2892. * offset has to be left-aligned on bit 11, the LSB (right bits)
  2893. * are set to 0.
  2894. * @note Offset cannot be enabled or disabled.
  2895. * To emulate offset disabled, set an offset value equal to 0.
  2896. * @rmtoll JOFR1 JOFFSET1 LL_ADC_INJ_SetOffset\n
  2897. * JOFR2 JOFFSET2 LL_ADC_INJ_SetOffset\n
  2898. * JOFR3 JOFFSET3 LL_ADC_INJ_SetOffset\n
  2899. * JOFR4 JOFFSET4 LL_ADC_INJ_SetOffset
  2900. * @param ADCx ADC instance
  2901. * @param Rank This parameter can be one of the following values:
  2902. * @arg @ref LL_ADC_INJ_RANK_1
  2903. * @arg @ref LL_ADC_INJ_RANK_2
  2904. * @arg @ref LL_ADC_INJ_RANK_3
  2905. * @arg @ref LL_ADC_INJ_RANK_4
  2906. * @param OffsetLevel Value between Min_Data=0x000 and Max_Data=0xFFF
  2907. * @retval None
  2908. */
  2909. __STATIC_INLINE void LL_ADC_INJ_SetOffset(ADC_TypeDef *ADCx, uint32_t Rank, uint32_t OffsetLevel)
  2910. {
  2911. register __IO uint32_t *preg = __ADC_PTR_REG_OFFSET(ADCx->JOFR1, __ADC_MASK_SHIFT(Rank, ADC_INJ_JOFRX_REGOFFSET_MASK));
  2912. MODIFY_REG(*preg,
  2913. ADC_JOFR1_JOFFSET1,
  2914. OffsetLevel);
  2915. }
  2916. /**
  2917. * @brief Get ADC group injected offset.
  2918. * @note It gives offset level (offset to be subtracted from the raw converted data).
  2919. * Caution: Offset format is dependent to ADC resolution:
  2920. * offset has to be left-aligned on bit 11, the LSB (right bits)
  2921. * are set to 0.
  2922. * @rmtoll JOFR1 JOFFSET1 LL_ADC_INJ_GetOffset\n
  2923. * JOFR2 JOFFSET2 LL_ADC_INJ_GetOffset\n
  2924. * JOFR3 JOFFSET3 LL_ADC_INJ_GetOffset\n
  2925. * JOFR4 JOFFSET4 LL_ADC_INJ_GetOffset
  2926. * @param ADCx ADC instance
  2927. * @param Rank This parameter can be one of the following values:
  2928. * @arg @ref LL_ADC_INJ_RANK_1
  2929. * @arg @ref LL_ADC_INJ_RANK_2
  2930. * @arg @ref LL_ADC_INJ_RANK_3
  2931. * @arg @ref LL_ADC_INJ_RANK_4
  2932. * @retval Value between Min_Data=0x000 and Max_Data=0xFFF
  2933. */
  2934. __STATIC_INLINE uint32_t LL_ADC_INJ_GetOffset(ADC_TypeDef *ADCx, uint32_t Rank)
  2935. {
  2936. register __IO uint32_t *preg = __ADC_PTR_REG_OFFSET(ADCx->JOFR1, __ADC_MASK_SHIFT(Rank, ADC_INJ_JOFRX_REGOFFSET_MASK));
  2937. return (uint32_t)(READ_BIT(*preg,
  2938. ADC_JOFR1_JOFFSET1)
  2939. );
  2940. }
  2941. /**
  2942. * @}
  2943. */
  2944. /** @defgroup ADC_LL_EF_Configuration_Channels Configuration of ADC hierarchical scope: channels
  2945. * @{
  2946. */
  2947. /**
  2948. * @brief Set sampling time of the selected ADC channel
  2949. * Unit: ADC clock cycles.
  2950. * @note On this device, sampling time is on channel scope: independently
  2951. * of channel mapped on ADC group regular or injected.
  2952. * @note In case of internal channel (VrefInt, TempSensor, ...) to be
  2953. * converted:
  2954. * sampling time constraints must be respected (sampling time can be
  2955. * adjusted in function of ADC clock frequency and sampling time
  2956. * setting).
  2957. * Refer to device datasheet for timings values (parameters TS_vrefint,
  2958. * TS_temp, ...).
  2959. * @note Conversion time is the addition of sampling time and processing time.
  2960. * Refer to reference manual for ADC processing time of
  2961. * this STM32 serie.
  2962. * @note In case of ADC conversion of internal channel (VrefInt,
  2963. * temperature sensor, ...), a sampling time minimum value
  2964. * is required.
  2965. * Refer to device datasheet.
  2966. * @rmtoll SMPR1 SMP18 LL_ADC_SetChannelSamplingTime\n
  2967. * SMPR1 SMP17 LL_ADC_SetChannelSamplingTime\n
  2968. * SMPR1 SMP16 LL_ADC_SetChannelSamplingTime\n
  2969. * SMPR1 SMP15 LL_ADC_SetChannelSamplingTime\n
  2970. * SMPR1 SMP14 LL_ADC_SetChannelSamplingTime\n
  2971. * SMPR1 SMP13 LL_ADC_SetChannelSamplingTime\n
  2972. * SMPR1 SMP12 LL_ADC_SetChannelSamplingTime\n
  2973. * SMPR1 SMP11 LL_ADC_SetChannelSamplingTime\n
  2974. * SMPR1 SMP10 LL_ADC_SetChannelSamplingTime\n
  2975. * SMPR2 SMP9 LL_ADC_SetChannelSamplingTime\n
  2976. * SMPR2 SMP8 LL_ADC_SetChannelSamplingTime\n
  2977. * SMPR2 SMP7 LL_ADC_SetChannelSamplingTime\n
  2978. * SMPR2 SMP6 LL_ADC_SetChannelSamplingTime\n
  2979. * SMPR2 SMP5 LL_ADC_SetChannelSamplingTime\n
  2980. * SMPR2 SMP4 LL_ADC_SetChannelSamplingTime\n
  2981. * SMPR2 SMP3 LL_ADC_SetChannelSamplingTime\n
  2982. * SMPR2 SMP2 LL_ADC_SetChannelSamplingTime\n
  2983. * SMPR2 SMP1 LL_ADC_SetChannelSamplingTime\n
  2984. * SMPR2 SMP0 LL_ADC_SetChannelSamplingTime
  2985. * @param ADCx ADC instance
  2986. * @param Channel This parameter can be one of the following values:
  2987. * @arg @ref LL_ADC_CHANNEL_0
  2988. * @arg @ref LL_ADC_CHANNEL_1
  2989. * @arg @ref LL_ADC_CHANNEL_2
  2990. * @arg @ref LL_ADC_CHANNEL_3
  2991. * @arg @ref LL_ADC_CHANNEL_4
  2992. * @arg @ref LL_ADC_CHANNEL_5
  2993. * @arg @ref LL_ADC_CHANNEL_6
  2994. * @arg @ref LL_ADC_CHANNEL_7
  2995. * @arg @ref LL_ADC_CHANNEL_8
  2996. * @arg @ref LL_ADC_CHANNEL_9
  2997. * @arg @ref LL_ADC_CHANNEL_10
  2998. * @arg @ref LL_ADC_CHANNEL_11
  2999. * @arg @ref LL_ADC_CHANNEL_12
  3000. * @arg @ref LL_ADC_CHANNEL_13
  3001. * @arg @ref LL_ADC_CHANNEL_14
  3002. * @arg @ref LL_ADC_CHANNEL_15
  3003. * @arg @ref LL_ADC_CHANNEL_16
  3004. * @arg @ref LL_ADC_CHANNEL_17
  3005. * @arg @ref LL_ADC_CHANNEL_18
  3006. * @arg @ref LL_ADC_CHANNEL_VREFINT (1)
  3007. * @arg @ref LL_ADC_CHANNEL_TEMPSENSOR (1)(2)
  3008. * @arg @ref LL_ADC_CHANNEL_VBAT (1)
  3009. *
  3010. * (1) On STM32F4, parameter available only on ADC instance: ADC1.\n
  3011. * (2) On devices STM32F42x and STM32F43x, limitation: this internal channel is shared between temperature sensor and Vbat, only 1 measurement path must be enabled.
  3012. * @param SamplingTime This parameter can be one of the following values:
  3013. * @arg @ref LL_ADC_SAMPLINGTIME_3CYCLES
  3014. * @arg @ref LL_ADC_SAMPLINGTIME_15CYCLES
  3015. * @arg @ref LL_ADC_SAMPLINGTIME_28CYCLES
  3016. * @arg @ref LL_ADC_SAMPLINGTIME_56CYCLES
  3017. * @arg @ref LL_ADC_SAMPLINGTIME_84CYCLES
  3018. * @arg @ref LL_ADC_SAMPLINGTIME_112CYCLES
  3019. * @arg @ref LL_ADC_SAMPLINGTIME_144CYCLES
  3020. * @arg @ref LL_ADC_SAMPLINGTIME_480CYCLES
  3021. * @retval None
  3022. */
  3023. __STATIC_INLINE void LL_ADC_SetChannelSamplingTime(ADC_TypeDef *ADCx, uint32_t Channel, uint32_t SamplingTime)
  3024. {
  3025. /* Set bits with content of parameter "SamplingTime" with bits position */
  3026. /* in register and register position depending on parameter "Channel". */
  3027. /* Parameter "Channel" is used with masks because containing */
  3028. /* other bits reserved for other purpose. */
  3029. register __IO uint32_t *preg = __ADC_PTR_REG_OFFSET(ADCx->SMPR1, __ADC_MASK_SHIFT(Channel, ADC_CHANNEL_SMPRX_REGOFFSET_MASK));
  3030. MODIFY_REG(*preg,
  3031. ADC_SMPR2_SMP0 << __ADC_MASK_SHIFT(Channel, ADC_CHANNEL_SMPx_BITOFFSET_MASK),
  3032. SamplingTime << __ADC_MASK_SHIFT(Channel, ADC_CHANNEL_SMPx_BITOFFSET_MASK));
  3033. }
  3034. /**
  3035. * @brief Get sampling time of the selected ADC channel
  3036. * Unit: ADC clock cycles.
  3037. * @note On this device, sampling time is on channel scope: independently
  3038. * of channel mapped on ADC group regular or injected.
  3039. * @note Conversion time is the addition of sampling time and processing time.
  3040. * Refer to reference manual for ADC processing time of
  3041. * this STM32 serie.
  3042. * @rmtoll SMPR1 SMP18 LL_ADC_GetChannelSamplingTime\n
  3043. * SMPR1 SMP17 LL_ADC_GetChannelSamplingTime\n
  3044. * SMPR1 SMP16 LL_ADC_GetChannelSamplingTime\n
  3045. * SMPR1 SMP15 LL_ADC_GetChannelSamplingTime\n
  3046. * SMPR1 SMP14 LL_ADC_GetChannelSamplingTime\n
  3047. * SMPR1 SMP13 LL_ADC_GetChannelSamplingTime\n
  3048. * SMPR1 SMP12 LL_ADC_GetChannelSamplingTime\n
  3049. * SMPR1 SMP11 LL_ADC_GetChannelSamplingTime\n
  3050. * SMPR1 SMP10 LL_ADC_GetChannelSamplingTime\n
  3051. * SMPR2 SMP9 LL_ADC_GetChannelSamplingTime\n
  3052. * SMPR2 SMP8 LL_ADC_GetChannelSamplingTime\n
  3053. * SMPR2 SMP7 LL_ADC_GetChannelSamplingTime\n
  3054. * SMPR2 SMP6 LL_ADC_GetChannelSamplingTime\n
  3055. * SMPR2 SMP5 LL_ADC_GetChannelSamplingTime\n
  3056. * SMPR2 SMP4 LL_ADC_GetChannelSamplingTime\n
  3057. * SMPR2 SMP3 LL_ADC_GetChannelSamplingTime\n
  3058. * SMPR2 SMP2 LL_ADC_GetChannelSamplingTime\n
  3059. * SMPR2 SMP1 LL_ADC_GetChannelSamplingTime\n
  3060. * SMPR2 SMP0 LL_ADC_GetChannelSamplingTime
  3061. * @param ADCx ADC instance
  3062. * @param Channel This parameter can be one of the following values:
  3063. * @arg @ref LL_ADC_CHANNEL_0
  3064. * @arg @ref LL_ADC_CHANNEL_1
  3065. * @arg @ref LL_ADC_CHANNEL_2
  3066. * @arg @ref LL_ADC_CHANNEL_3
  3067. * @arg @ref LL_ADC_CHANNEL_4
  3068. * @arg @ref LL_ADC_CHANNEL_5
  3069. * @arg @ref LL_ADC_CHANNEL_6
  3070. * @arg @ref LL_ADC_CHANNEL_7
  3071. * @arg @ref LL_ADC_CHANNEL_8
  3072. * @arg @ref LL_ADC_CHANNEL_9
  3073. * @arg @ref LL_ADC_CHANNEL_10
  3074. * @arg @ref LL_ADC_CHANNEL_11
  3075. * @arg @ref LL_ADC_CHANNEL_12
  3076. * @arg @ref LL_ADC_CHANNEL_13
  3077. * @arg @ref LL_ADC_CHANNEL_14
  3078. * @arg @ref LL_ADC_CHANNEL_15
  3079. * @arg @ref LL_ADC_CHANNEL_16
  3080. * @arg @ref LL_ADC_CHANNEL_17
  3081. * @arg @ref LL_ADC_CHANNEL_18
  3082. * @arg @ref LL_ADC_CHANNEL_VREFINT (1)
  3083. * @arg @ref LL_ADC_CHANNEL_TEMPSENSOR (1)(2)
  3084. * @arg @ref LL_ADC_CHANNEL_VBAT (1)
  3085. *
  3086. * (1) On STM32F4, parameter available only on ADC instance: ADC1.\n
  3087. * (2) On devices STM32F42x and STM32F43x, limitation: this internal channel is shared between temperature sensor and Vbat, only 1 measurement path must be enabled.
  3088. * @retval Returned value can be one of the following values:
  3089. * @arg @ref LL_ADC_SAMPLINGTIME_3CYCLES
  3090. * @arg @ref LL_ADC_SAMPLINGTIME_15CYCLES
  3091. * @arg @ref LL_ADC_SAMPLINGTIME_28CYCLES
  3092. * @arg @ref LL_ADC_SAMPLINGTIME_56CYCLES
  3093. * @arg @ref LL_ADC_SAMPLINGTIME_84CYCLES
  3094. * @arg @ref LL_ADC_SAMPLINGTIME_112CYCLES
  3095. * @arg @ref LL_ADC_SAMPLINGTIME_144CYCLES
  3096. * @arg @ref LL_ADC_SAMPLINGTIME_480CYCLES
  3097. */
  3098. __STATIC_INLINE uint32_t LL_ADC_GetChannelSamplingTime(ADC_TypeDef *ADCx, uint32_t Channel)
  3099. {
  3100. register __IO uint32_t *preg = __ADC_PTR_REG_OFFSET(ADCx->SMPR1, __ADC_MASK_SHIFT(Channel, ADC_CHANNEL_SMPRX_REGOFFSET_MASK));
  3101. return (uint32_t)(READ_BIT(*preg,
  3102. ADC_SMPR2_SMP0 << __ADC_MASK_SHIFT(Channel, ADC_CHANNEL_SMPx_BITOFFSET_MASK))
  3103. >> __ADC_MASK_SHIFT(Channel, ADC_CHANNEL_SMPx_BITOFFSET_MASK)
  3104. );
  3105. }
  3106. /**
  3107. * @}
  3108. */
  3109. /** @defgroup ADC_LL_EF_Configuration_ADC_AnalogWatchdog Configuration of ADC transversal scope: analog watchdog
  3110. * @{
  3111. */
  3112. /**
  3113. * @brief Set ADC analog watchdog monitored channels:
  3114. * a single channel or all channels,
  3115. * on ADC groups regular and-or injected.
  3116. * @note Once monitored channels are selected, analog watchdog
  3117. * is enabled.
  3118. * @note In case of need to define a single channel to monitor
  3119. * with analog watchdog from sequencer channel definition,
  3120. * use helper macro @ref __LL_ADC_ANALOGWD_CHANNEL_GROUP().
  3121. * @note On this STM32 serie, there is only 1 kind of analog watchdog
  3122. * instance:
  3123. * - AWD standard (instance AWD1):
  3124. * - channels monitored: can monitor 1 channel or all channels.
  3125. * - groups monitored: ADC groups regular and-or injected.
  3126. * - resolution: resolution is not limited (corresponds to
  3127. * ADC resolution configured).
  3128. * @rmtoll CR1 AWD1CH LL_ADC_SetAnalogWDMonitChannels\n
  3129. * CR1 AWD1SGL LL_ADC_SetAnalogWDMonitChannels\n
  3130. * CR1 AWD1EN LL_ADC_SetAnalogWDMonitChannels
  3131. * @param ADCx ADC instance
  3132. * @param AWDChannelGroup This parameter can be one of the following values:
  3133. * @arg @ref LL_ADC_AWD_DISABLE
  3134. * @arg @ref LL_ADC_AWD_ALL_CHANNELS_REG
  3135. * @arg @ref LL_ADC_AWD_ALL_CHANNELS_INJ
  3136. * @arg @ref LL_ADC_AWD_ALL_CHANNELS_REG_INJ
  3137. * @arg @ref LL_ADC_AWD_CHANNEL_0_REG
  3138. * @arg @ref LL_ADC_AWD_CHANNEL_0_INJ
  3139. * @arg @ref LL_ADC_AWD_CHANNEL_0_REG_INJ
  3140. * @arg @ref LL_ADC_AWD_CHANNEL_1_REG
  3141. * @arg @ref LL_ADC_AWD_CHANNEL_1_INJ
  3142. * @arg @ref LL_ADC_AWD_CHANNEL_1_REG_INJ
  3143. * @arg @ref LL_ADC_AWD_CHANNEL_2_REG
  3144. * @arg @ref LL_ADC_AWD_CHANNEL_2_INJ
  3145. * @arg @ref LL_ADC_AWD_CHANNEL_2_REG_INJ
  3146. * @arg @ref LL_ADC_AWD_CHANNEL_3_REG
  3147. * @arg @ref LL_ADC_AWD_CHANNEL_3_INJ
  3148. * @arg @ref LL_ADC_AWD_CHANNEL_3_REG_INJ
  3149. * @arg @ref LL_ADC_AWD_CHANNEL_4_REG
  3150. * @arg @ref LL_ADC_AWD_CHANNEL_4_INJ
  3151. * @arg @ref LL_ADC_AWD_CHANNEL_4_REG_INJ
  3152. * @arg @ref LL_ADC_AWD_CHANNEL_5_REG
  3153. * @arg @ref LL_ADC_AWD_CHANNEL_5_INJ
  3154. * @arg @ref LL_ADC_AWD_CHANNEL_5_REG_INJ
  3155. * @arg @ref LL_ADC_AWD_CHANNEL_6_REG
  3156. * @arg @ref LL_ADC_AWD_CHANNEL_6_INJ
  3157. * @arg @ref LL_ADC_AWD_CHANNEL_6_REG_INJ
  3158. * @arg @ref LL_ADC_AWD_CHANNEL_7_REG
  3159. * @arg @ref LL_ADC_AWD_CHANNEL_7_INJ
  3160. * @arg @ref LL_ADC_AWD_CHANNEL_7_REG_INJ
  3161. * @arg @ref LL_ADC_AWD_CHANNEL_8_REG
  3162. * @arg @ref LL_ADC_AWD_CHANNEL_8_INJ
  3163. * @arg @ref LL_ADC_AWD_CHANNEL_8_REG_INJ
  3164. * @arg @ref LL_ADC_AWD_CHANNEL_9_REG
  3165. * @arg @ref LL_ADC_AWD_CHANNEL_9_INJ
  3166. * @arg @ref LL_ADC_AWD_CHANNEL_9_REG_INJ
  3167. * @arg @ref LL_ADC_AWD_CHANNEL_10_REG
  3168. * @arg @ref LL_ADC_AWD_CHANNEL_10_INJ
  3169. * @arg @ref LL_ADC_AWD_CHANNEL_10_REG_INJ
  3170. * @arg @ref LL_ADC_AWD_CHANNEL_11_REG
  3171. * @arg @ref LL_ADC_AWD_CHANNEL_11_INJ
  3172. * @arg @ref LL_ADC_AWD_CHANNEL_11_REG_INJ
  3173. * @arg @ref LL_ADC_AWD_CHANNEL_12_REG
  3174. * @arg @ref LL_ADC_AWD_CHANNEL_12_INJ
  3175. * @arg @ref LL_ADC_AWD_CHANNEL_12_REG_INJ
  3176. * @arg @ref LL_ADC_AWD_CHANNEL_13_REG
  3177. * @arg @ref LL_ADC_AWD_CHANNEL_13_INJ
  3178. * @arg @ref LL_ADC_AWD_CHANNEL_13_REG_INJ
  3179. * @arg @ref LL_ADC_AWD_CHANNEL_14_REG
  3180. * @arg @ref LL_ADC_AWD_CHANNEL_14_INJ
  3181. * @arg @ref LL_ADC_AWD_CHANNEL_14_REG_INJ
  3182. * @arg @ref LL_ADC_AWD_CHANNEL_15_REG
  3183. * @arg @ref LL_ADC_AWD_CHANNEL_15_INJ
  3184. * @arg @ref LL_ADC_AWD_CHANNEL_15_REG_INJ
  3185. * @arg @ref LL_ADC_AWD_CHANNEL_16_REG
  3186. * @arg @ref LL_ADC_AWD_CHANNEL_16_INJ
  3187. * @arg @ref LL_ADC_AWD_CHANNEL_16_REG_INJ
  3188. * @arg @ref LL_ADC_AWD_CHANNEL_17_REG
  3189. * @arg @ref LL_ADC_AWD_CHANNEL_17_INJ
  3190. * @arg @ref LL_ADC_AWD_CHANNEL_17_REG_INJ
  3191. * @arg @ref LL_ADC_AWD_CHANNEL_18_REG
  3192. * @arg @ref LL_ADC_AWD_CHANNEL_18_INJ
  3193. * @arg @ref LL_ADC_AWD_CHANNEL_18_REG_INJ
  3194. * @arg @ref LL_ADC_AWD_CH_VREFINT_REG (1)
  3195. * @arg @ref LL_ADC_AWD_CH_VREFINT_INJ (1)
  3196. * @arg @ref LL_ADC_AWD_CH_VREFINT_REG_INJ (1)
  3197. * @arg @ref LL_ADC_AWD_CH_TEMPSENSOR_REG (1)(2)
  3198. * @arg @ref LL_ADC_AWD_CH_TEMPSENSOR_INJ (1)(2)
  3199. * @arg @ref LL_ADC_AWD_CH_TEMPSENSOR_REG_INJ (1)(2)
  3200. * @arg @ref LL_ADC_AWD_CH_VBAT_REG (1)
  3201. * @arg @ref LL_ADC_AWD_CH_VBAT_INJ (1)
  3202. * @arg @ref LL_ADC_AWD_CH_VBAT_REG_INJ (1)
  3203. *
  3204. * (1) On STM32F4, parameter available only on ADC instance: ADC1.\n
  3205. * (2) On devices STM32F42x and STM32F43x, limitation: this internal channel is shared between temperature sensor and Vbat, only 1 measurement path must be enabled.
  3206. * @retval None
  3207. */
  3208. __STATIC_INLINE void LL_ADC_SetAnalogWDMonitChannels(ADC_TypeDef *ADCx, uint32_t AWDChannelGroup)
  3209. {
  3210. MODIFY_REG(ADCx->CR1,
  3211. (ADC_CR1_AWDEN | ADC_CR1_JAWDEN | ADC_CR1_AWDSGL | ADC_CR1_AWDCH),
  3212. AWDChannelGroup);
  3213. }
  3214. /**
  3215. * @brief Get ADC analog watchdog monitored channel.
  3216. * @note Usage of the returned channel number:
  3217. * - To reinject this channel into another function LL_ADC_xxx:
  3218. * the returned channel number is only partly formatted on definition
  3219. * of literals LL_ADC_CHANNEL_x. Therefore, it has to be compared
  3220. * with parts of literals LL_ADC_CHANNEL_x or using
  3221. * helper macro @ref __LL_ADC_CHANNEL_TO_DECIMAL_NB().
  3222. * Then the selected literal LL_ADC_CHANNEL_x can be used
  3223. * as parameter for another function.
  3224. * - To get the channel number in decimal format:
  3225. * process the returned value with the helper macro
  3226. * @ref __LL_ADC_CHANNEL_TO_DECIMAL_NB().
  3227. * Applicable only when the analog watchdog is set to monitor
  3228. * one channel.
  3229. * @note On this STM32 serie, there is only 1 kind of analog watchdog
  3230. * instance:
  3231. * - AWD standard (instance AWD1):
  3232. * - channels monitored: can monitor 1 channel or all channels.
  3233. * - groups monitored: ADC groups regular and-or injected.
  3234. * - resolution: resolution is not limited (corresponds to
  3235. * ADC resolution configured).
  3236. * @rmtoll CR1 AWD1CH LL_ADC_GetAnalogWDMonitChannels\n
  3237. * CR1 AWD1SGL LL_ADC_GetAnalogWDMonitChannels\n
  3238. * CR1 AWD1EN LL_ADC_GetAnalogWDMonitChannels
  3239. * @param ADCx ADC instance
  3240. * @retval Returned value can be one of the following values:
  3241. * @arg @ref LL_ADC_AWD_DISABLE
  3242. * @arg @ref LL_ADC_AWD_ALL_CHANNELS_REG
  3243. * @arg @ref LL_ADC_AWD_ALL_CHANNELS_INJ
  3244. * @arg @ref LL_ADC_AWD_ALL_CHANNELS_REG_INJ
  3245. * @arg @ref LL_ADC_AWD_CHANNEL_0_REG
  3246. * @arg @ref LL_ADC_AWD_CHANNEL_0_INJ
  3247. * @arg @ref LL_ADC_AWD_CHANNEL_0_REG_INJ
  3248. * @arg @ref LL_ADC_AWD_CHANNEL_1_REG
  3249. * @arg @ref LL_ADC_AWD_CHANNEL_1_INJ
  3250. * @arg @ref LL_ADC_AWD_CHANNEL_1_REG_INJ
  3251. * @arg @ref LL_ADC_AWD_CHANNEL_2_REG
  3252. * @arg @ref LL_ADC_AWD_CHANNEL_2_INJ
  3253. * @arg @ref LL_ADC_AWD_CHANNEL_2_REG_INJ
  3254. * @arg @ref LL_ADC_AWD_CHANNEL_3_REG
  3255. * @arg @ref LL_ADC_AWD_CHANNEL_3_INJ
  3256. * @arg @ref LL_ADC_AWD_CHANNEL_3_REG_INJ
  3257. * @arg @ref LL_ADC_AWD_CHANNEL_4_REG
  3258. * @arg @ref LL_ADC_AWD_CHANNEL_4_INJ
  3259. * @arg @ref LL_ADC_AWD_CHANNEL_4_REG_INJ
  3260. * @arg @ref LL_ADC_AWD_CHANNEL_5_REG
  3261. * @arg @ref LL_ADC_AWD_CHANNEL_5_INJ
  3262. * @arg @ref LL_ADC_AWD_CHANNEL_5_REG_INJ
  3263. * @arg @ref LL_ADC_AWD_CHANNEL_6_REG
  3264. * @arg @ref LL_ADC_AWD_CHANNEL_6_INJ
  3265. * @arg @ref LL_ADC_AWD_CHANNEL_6_REG_INJ
  3266. * @arg @ref LL_ADC_AWD_CHANNEL_7_REG
  3267. * @arg @ref LL_ADC_AWD_CHANNEL_7_INJ
  3268. * @arg @ref LL_ADC_AWD_CHANNEL_7_REG_INJ
  3269. * @arg @ref LL_ADC_AWD_CHANNEL_8_REG
  3270. * @arg @ref LL_ADC_AWD_CHANNEL_8_INJ
  3271. * @arg @ref LL_ADC_AWD_CHANNEL_8_REG_INJ
  3272. * @arg @ref LL_ADC_AWD_CHANNEL_9_REG
  3273. * @arg @ref LL_ADC_AWD_CHANNEL_9_INJ
  3274. * @arg @ref LL_ADC_AWD_CHANNEL_9_REG_INJ
  3275. * @arg @ref LL_ADC_AWD_CHANNEL_10_REG
  3276. * @arg @ref LL_ADC_AWD_CHANNEL_10_INJ
  3277. * @arg @ref LL_ADC_AWD_CHANNEL_10_REG_INJ
  3278. * @arg @ref LL_ADC_AWD_CHANNEL_11_REG
  3279. * @arg @ref LL_ADC_AWD_CHANNEL_11_INJ
  3280. * @arg @ref LL_ADC_AWD_CHANNEL_11_REG_INJ
  3281. * @arg @ref LL_ADC_AWD_CHANNEL_12_REG
  3282. * @arg @ref LL_ADC_AWD_CHANNEL_12_INJ
  3283. * @arg @ref LL_ADC_AWD_CHANNEL_12_REG_INJ
  3284. * @arg @ref LL_ADC_AWD_CHANNEL_13_REG
  3285. * @arg @ref LL_ADC_AWD_CHANNEL_13_INJ
  3286. * @arg @ref LL_ADC_AWD_CHANNEL_13_REG_INJ
  3287. * @arg @ref LL_ADC_AWD_CHANNEL_14_REG
  3288. * @arg @ref LL_ADC_AWD_CHANNEL_14_INJ
  3289. * @arg @ref LL_ADC_AWD_CHANNEL_14_REG_INJ
  3290. * @arg @ref LL_ADC_AWD_CHANNEL_15_REG
  3291. * @arg @ref LL_ADC_AWD_CHANNEL_15_INJ
  3292. * @arg @ref LL_ADC_AWD_CHANNEL_15_REG_INJ
  3293. * @arg @ref LL_ADC_AWD_CHANNEL_16_REG
  3294. * @arg @ref LL_ADC_AWD_CHANNEL_16_INJ
  3295. * @arg @ref LL_ADC_AWD_CHANNEL_16_REG_INJ
  3296. * @arg @ref LL_ADC_AWD_CHANNEL_17_REG
  3297. * @arg @ref LL_ADC_AWD_CHANNEL_17_INJ
  3298. * @arg @ref LL_ADC_AWD_CHANNEL_17_REG_INJ
  3299. * @arg @ref LL_ADC_AWD_CHANNEL_18_REG
  3300. * @arg @ref LL_ADC_AWD_CHANNEL_18_INJ
  3301. * @arg @ref LL_ADC_AWD_CHANNEL_18_REG_INJ
  3302. */
  3303. __STATIC_INLINE uint32_t LL_ADC_GetAnalogWDMonitChannels(ADC_TypeDef *ADCx)
  3304. {
  3305. return (uint32_t)(READ_BIT(ADCx->CR1, (ADC_CR1_AWDEN | ADC_CR1_JAWDEN | ADC_CR1_AWDSGL | ADC_CR1_AWDCH)));
  3306. }
  3307. /**
  3308. * @brief Set ADC analog watchdog threshold value of threshold
  3309. * high or low.
  3310. * @note In case of ADC resolution different of 12 bits,
  3311. * analog watchdog thresholds data require a specific shift.
  3312. * Use helper macro @ref __LL_ADC_ANALOGWD_SET_THRESHOLD_RESOLUTION().
  3313. * @note On this STM32 serie, there is only 1 kind of analog watchdog
  3314. * instance:
  3315. * - AWD standard (instance AWD1):
  3316. * - channels monitored: can monitor 1 channel or all channels.
  3317. * - groups monitored: ADC groups regular and-or injected.
  3318. * - resolution: resolution is not limited (corresponds to
  3319. * ADC resolution configured).
  3320. * @rmtoll HTR HT LL_ADC_SetAnalogWDThresholds\n
  3321. * LTR LT LL_ADC_SetAnalogWDThresholds
  3322. * @param ADCx ADC instance
  3323. * @param AWDThresholdsHighLow This parameter can be one of the following values:
  3324. * @arg @ref LL_ADC_AWD_THRESHOLD_HIGH
  3325. * @arg @ref LL_ADC_AWD_THRESHOLD_LOW
  3326. * @param AWDThresholdValue Value between Min_Data=0x000 and Max_Data=0xFFF
  3327. * @retval None
  3328. */
  3329. __STATIC_INLINE void LL_ADC_SetAnalogWDThresholds(ADC_TypeDef *ADCx, uint32_t AWDThresholdsHighLow, uint32_t AWDThresholdValue)
  3330. {
  3331. register __IO uint32_t *preg = __ADC_PTR_REG_OFFSET(ADCx->HTR, AWDThresholdsHighLow);
  3332. MODIFY_REG(*preg,
  3333. ADC_HTR_HT,
  3334. AWDThresholdValue);
  3335. }
  3336. /**
  3337. * @brief Get ADC analog watchdog threshold value of threshold high or
  3338. * threshold low.
  3339. * @note In case of ADC resolution different of 12 bits,
  3340. * analog watchdog thresholds data require a specific shift.
  3341. * Use helper macro @ref __LL_ADC_ANALOGWD_GET_THRESHOLD_RESOLUTION().
  3342. * @rmtoll HTR HT LL_ADC_GetAnalogWDThresholds\n
  3343. * LTR LT LL_ADC_GetAnalogWDThresholds
  3344. * @param ADCx ADC instance
  3345. * @param AWDThresholdsHighLow This parameter can be one of the following values:
  3346. * @arg @ref LL_ADC_AWD_THRESHOLD_HIGH
  3347. * @arg @ref LL_ADC_AWD_THRESHOLD_LOW
  3348. * @retval Value between Min_Data=0x000 and Max_Data=0xFFF
  3349. */
  3350. __STATIC_INLINE uint32_t LL_ADC_GetAnalogWDThresholds(ADC_TypeDef *ADCx, uint32_t AWDThresholdsHighLow)
  3351. {
  3352. register __IO uint32_t *preg = __ADC_PTR_REG_OFFSET(ADCx->HTR, AWDThresholdsHighLow);
  3353. return (uint32_t)(READ_BIT(*preg, ADC_HTR_HT));
  3354. }
  3355. /**
  3356. * @}
  3357. */
  3358. /** @defgroup ADC_LL_EF_Configuration_ADC_Multimode Configuration of ADC hierarchical scope: multimode
  3359. * @{
  3360. */
  3361. #if defined(ADC_MULTIMODE_SUPPORT)
  3362. /**
  3363. * @brief Set ADC multimode configuration to operate in independent mode
  3364. * or multimode (for devices with several ADC instances).
  3365. * @note If multimode configuration: the selected ADC instance is
  3366. * either master or slave depending on hardware.
  3367. * Refer to reference manual.
  3368. * @rmtoll CCR MULTI LL_ADC_SetMultimode
  3369. * @param ADCxy_COMMON ADC common instance
  3370. * (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() )
  3371. * @param Multimode This parameter can be one of the following values:
  3372. * @arg @ref LL_ADC_MULTI_INDEPENDENT
  3373. * @arg @ref LL_ADC_MULTI_DUAL_REG_SIMULT
  3374. * @arg @ref LL_ADC_MULTI_DUAL_REG_INTERL
  3375. * @arg @ref LL_ADC_MULTI_DUAL_INJ_SIMULT
  3376. * @arg @ref LL_ADC_MULTI_DUAL_INJ_ALTERN
  3377. * @arg @ref LL_ADC_MULTI_DUAL_REG_SIM_INJ_SIM
  3378. * @arg @ref LL_ADC_MULTI_DUAL_REG_SIM_INJ_ALT
  3379. * @arg @ref LL_ADC_MULTI_DUAL_REG_INT_INJ_SIM
  3380. * @arg @ref LL_ADC_MULTI_TRIPLE_REG_SIM_INJ_SIM
  3381. * @arg @ref LL_ADC_MULTI_TRIPLE_REG_SIM_INJ_ALT
  3382. * @arg @ref LL_ADC_MULTI_TRIPLE_INJ_SIMULT
  3383. * @arg @ref LL_ADC_MULTI_TRIPLE_REG_SIMULT
  3384. * @arg @ref LL_ADC_MULTI_TRIPLE_REG_INTERL
  3385. * @arg @ref LL_ADC_MULTI_TRIPLE_INJ_ALTERN
  3386. * @retval None
  3387. */
  3388. __STATIC_INLINE void LL_ADC_SetMultimode(ADC_Common_TypeDef *ADCxy_COMMON, uint32_t Multimode)
  3389. {
  3390. MODIFY_REG(ADCxy_COMMON->CCR, ADC_CCR_MULTI, Multimode);
  3391. }
  3392. /**
  3393. * @brief Get ADC multimode configuration to operate in independent mode
  3394. * or multimode (for devices with several ADC instances).
  3395. * @note If multimode configuration: the selected ADC instance is
  3396. * either master or slave depending on hardware.
  3397. * Refer to reference manual.
  3398. * @rmtoll CCR MULTI LL_ADC_GetMultimode
  3399. * @param ADCxy_COMMON ADC common instance
  3400. * (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() )
  3401. * @retval Returned value can be one of the following values:
  3402. * @arg @ref LL_ADC_MULTI_INDEPENDENT
  3403. * @arg @ref LL_ADC_MULTI_DUAL_REG_SIMULT
  3404. * @arg @ref LL_ADC_MULTI_DUAL_REG_INTERL
  3405. * @arg @ref LL_ADC_MULTI_DUAL_INJ_SIMULT
  3406. * @arg @ref LL_ADC_MULTI_DUAL_INJ_ALTERN
  3407. * @arg @ref LL_ADC_MULTI_DUAL_REG_SIM_INJ_SIM
  3408. * @arg @ref LL_ADC_MULTI_DUAL_REG_SIM_INJ_ALT
  3409. * @arg @ref LL_ADC_MULTI_DUAL_REG_INT_INJ_SIM
  3410. * @arg @ref LL_ADC_MULTI_TRIPLE_REG_SIM_INJ_SIM
  3411. * @arg @ref LL_ADC_MULTI_TRIPLE_REG_SIM_INJ_ALT
  3412. * @arg @ref LL_ADC_MULTI_TRIPLE_INJ_SIMULT
  3413. * @arg @ref LL_ADC_MULTI_TRIPLE_REG_SIMULT
  3414. * @arg @ref LL_ADC_MULTI_TRIPLE_REG_INTERL
  3415. * @arg @ref LL_ADC_MULTI_TRIPLE_INJ_ALTERN
  3416. */
  3417. __STATIC_INLINE uint32_t LL_ADC_GetMultimode(ADC_Common_TypeDef *ADCxy_COMMON)
  3418. {
  3419. return (uint32_t)(READ_BIT(ADCxy_COMMON->CCR, ADC_CCR_MULTI));
  3420. }
  3421. /**
  3422. * @brief Set ADC multimode conversion data transfer: no transfer
  3423. * or transfer by DMA.
  3424. * @note If ADC multimode transfer by DMA is not selected:
  3425. * each ADC uses its own DMA channel, with its individual
  3426. * DMA transfer settings.
  3427. * If ADC multimode transfer by DMA is selected:
  3428. * One DMA channel is used for both ADC (DMA of ADC master)
  3429. * Specifies the DMA requests mode:
  3430. * - Limited mode (One shot mode): DMA transfer requests are stopped
  3431. * when number of DMA data transfers (number of
  3432. * ADC conversions) is reached.
  3433. * This ADC mode is intended to be used with DMA mode non-circular.
  3434. * - Unlimited mode: DMA transfer requests are unlimited,
  3435. * whatever number of DMA data transfers (number of
  3436. * ADC conversions).
  3437. * This ADC mode is intended to be used with DMA mode circular.
  3438. * @note If ADC DMA requests mode is set to unlimited and DMA is set to
  3439. * mode non-circular:
  3440. * when DMA transfers size will be reached, DMA will stop transfers of
  3441. * ADC conversions data ADC will raise an overrun error
  3442. * (overrun flag and interruption if enabled).
  3443. * @note How to retrieve multimode conversion data:
  3444. * Whatever multimode transfer by DMA setting: using function
  3445. * @ref LL_ADC_REG_ReadMultiConversionData32().
  3446. * If ADC multimode transfer by DMA is selected: conversion data
  3447. * is a raw data with ADC master and slave concatenated.
  3448. * A macro is available to get the conversion data of
  3449. * ADC master or ADC slave: see helper macro
  3450. * @ref __LL_ADC_MULTI_CONV_DATA_MASTER_SLAVE().
  3451. * @rmtoll CCR MDMA LL_ADC_SetMultiDMATransfer\n
  3452. * CCR DDS LL_ADC_SetMultiDMATransfer
  3453. * @param ADCxy_COMMON ADC common instance
  3454. * (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() )
  3455. * @param MultiDMATransfer This parameter can be one of the following values:
  3456. * @arg @ref LL_ADC_MULTI_REG_DMA_EACH_ADC
  3457. * @arg @ref LL_ADC_MULTI_REG_DMA_LIMIT_1
  3458. * @arg @ref LL_ADC_MULTI_REG_DMA_LIMIT_2
  3459. * @arg @ref LL_ADC_MULTI_REG_DMA_LIMIT_3
  3460. * @arg @ref LL_ADC_MULTI_REG_DMA_UNLMT_1
  3461. * @arg @ref LL_ADC_MULTI_REG_DMA_UNLMT_2
  3462. * @arg @ref LL_ADC_MULTI_REG_DMA_UNLMT_3
  3463. * @retval None
  3464. */
  3465. __STATIC_INLINE void LL_ADC_SetMultiDMATransfer(ADC_Common_TypeDef *ADCxy_COMMON, uint32_t MultiDMATransfer)
  3466. {
  3467. MODIFY_REG(ADCxy_COMMON->CCR, ADC_CCR_DMA | ADC_CCR_DDS, MultiDMATransfer);
  3468. }
  3469. /**
  3470. * @brief Get ADC multimode conversion data transfer: no transfer
  3471. * or transfer by DMA.
  3472. * @note If ADC multimode transfer by DMA is not selected:
  3473. * each ADC uses its own DMA channel, with its individual
  3474. * DMA transfer settings.
  3475. * If ADC multimode transfer by DMA is selected:
  3476. * One DMA channel is used for both ADC (DMA of ADC master)
  3477. * Specifies the DMA requests mode:
  3478. * - Limited mode (One shot mode): DMA transfer requests are stopped
  3479. * when number of DMA data transfers (number of
  3480. * ADC conversions) is reached.
  3481. * This ADC mode is intended to be used with DMA mode non-circular.
  3482. * - Unlimited mode: DMA transfer requests are unlimited,
  3483. * whatever number of DMA data transfers (number of
  3484. * ADC conversions).
  3485. * This ADC mode is intended to be used with DMA mode circular.
  3486. * @note If ADC DMA requests mode is set to unlimited and DMA is set to
  3487. * mode non-circular:
  3488. * when DMA transfers size will be reached, DMA will stop transfers of
  3489. * ADC conversions data ADC will raise an overrun error
  3490. * (overrun flag and interruption if enabled).
  3491. * @note How to retrieve multimode conversion data:
  3492. * Whatever multimode transfer by DMA setting: using function
  3493. * @ref LL_ADC_REG_ReadMultiConversionData32().
  3494. * If ADC multimode transfer by DMA is selected: conversion data
  3495. * is a raw data with ADC master and slave concatenated.
  3496. * A macro is available to get the conversion data of
  3497. * ADC master or ADC slave: see helper macro
  3498. * @ref __LL_ADC_MULTI_CONV_DATA_MASTER_SLAVE().
  3499. * @rmtoll CCR MDMA LL_ADC_GetMultiDMATransfer\n
  3500. * CCR DDS LL_ADC_GetMultiDMATransfer
  3501. * @param ADCxy_COMMON ADC common instance
  3502. * (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() )
  3503. * @retval Returned value can be one of the following values:
  3504. * @arg @ref LL_ADC_MULTI_REG_DMA_EACH_ADC
  3505. * @arg @ref LL_ADC_MULTI_REG_DMA_LIMIT_1
  3506. * @arg @ref LL_ADC_MULTI_REG_DMA_LIMIT_2
  3507. * @arg @ref LL_ADC_MULTI_REG_DMA_LIMIT_3
  3508. * @arg @ref LL_ADC_MULTI_REG_DMA_UNLMT_1
  3509. * @arg @ref LL_ADC_MULTI_REG_DMA_UNLMT_2
  3510. * @arg @ref LL_ADC_MULTI_REG_DMA_UNLMT_3
  3511. */
  3512. __STATIC_INLINE uint32_t LL_ADC_GetMultiDMATransfer(ADC_Common_TypeDef *ADCxy_COMMON)
  3513. {
  3514. return (uint32_t)(READ_BIT(ADCxy_COMMON->CCR, ADC_CCR_DMA | ADC_CCR_DDS));
  3515. }
  3516. /**
  3517. * @brief Set ADC multimode delay between 2 sampling phases.
  3518. * @note The sampling delay range depends on ADC resolution:
  3519. * - ADC resolution 12 bits can have maximum delay of 12 cycles.
  3520. * - ADC resolution 10 bits can have maximum delay of 10 cycles.
  3521. * - ADC resolution 8 bits can have maximum delay of 8 cycles.
  3522. * - ADC resolution 6 bits can have maximum delay of 6 cycles.
  3523. * @rmtoll CCR DELAY LL_ADC_SetMultiTwoSamplingDelay
  3524. * @param ADCxy_COMMON ADC common instance
  3525. * (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() )
  3526. * @param MultiTwoSamplingDelay This parameter can be one of the following values:
  3527. * @arg @ref LL_ADC_MULTI_TWOSMP_DELAY_5CYCLES
  3528. * @arg @ref LL_ADC_MULTI_TWOSMP_DELAY_6CYCLES
  3529. * @arg @ref LL_ADC_MULTI_TWOSMP_DELAY_7CYCLES
  3530. * @arg @ref LL_ADC_MULTI_TWOSMP_DELAY_8CYCLES
  3531. * @arg @ref LL_ADC_MULTI_TWOSMP_DELAY_9CYCLES
  3532. * @arg @ref LL_ADC_MULTI_TWOSMP_DELAY_10CYCLES
  3533. * @arg @ref LL_ADC_MULTI_TWOSMP_DELAY_11CYCLES
  3534. * @arg @ref LL_ADC_MULTI_TWOSMP_DELAY_12CYCLES
  3535. * @arg @ref LL_ADC_MULTI_TWOSMP_DELAY_13CYCLES
  3536. * @arg @ref LL_ADC_MULTI_TWOSMP_DELAY_14CYCLES
  3537. * @arg @ref LL_ADC_MULTI_TWOSMP_DELAY_15CYCLES
  3538. * @arg @ref LL_ADC_MULTI_TWOSMP_DELAY_16CYCLES
  3539. * @arg @ref LL_ADC_MULTI_TWOSMP_DELAY_17CYCLES
  3540. * @arg @ref LL_ADC_MULTI_TWOSMP_DELAY_18CYCLES
  3541. * @arg @ref LL_ADC_MULTI_TWOSMP_DELAY_19CYCLES
  3542. * @arg @ref LL_ADC_MULTI_TWOSMP_DELAY_20CYCLES
  3543. * @retval None
  3544. */
  3545. __STATIC_INLINE void LL_ADC_SetMultiTwoSamplingDelay(ADC_Common_TypeDef *ADCxy_COMMON, uint32_t MultiTwoSamplingDelay)
  3546. {
  3547. MODIFY_REG(ADCxy_COMMON->CCR, ADC_CCR_DELAY, MultiTwoSamplingDelay);
  3548. }
  3549. /**
  3550. * @brief Get ADC multimode delay between 2 sampling phases.
  3551. * @rmtoll CCR DELAY LL_ADC_GetMultiTwoSamplingDelay
  3552. * @param ADCxy_COMMON ADC common instance
  3553. * (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() )
  3554. * @retval Returned value can be one of the following values:
  3555. * @arg @ref LL_ADC_MULTI_TWOSMP_DELAY_5CYCLES
  3556. * @arg @ref LL_ADC_MULTI_TWOSMP_DELAY_6CYCLES
  3557. * @arg @ref LL_ADC_MULTI_TWOSMP_DELAY_7CYCLES
  3558. * @arg @ref LL_ADC_MULTI_TWOSMP_DELAY_8CYCLES
  3559. * @arg @ref LL_ADC_MULTI_TWOSMP_DELAY_9CYCLES
  3560. * @arg @ref LL_ADC_MULTI_TWOSMP_DELAY_10CYCLES
  3561. * @arg @ref LL_ADC_MULTI_TWOSMP_DELAY_11CYCLES
  3562. * @arg @ref LL_ADC_MULTI_TWOSMP_DELAY_12CYCLES
  3563. * @arg @ref LL_ADC_MULTI_TWOSMP_DELAY_13CYCLES
  3564. * @arg @ref LL_ADC_MULTI_TWOSMP_DELAY_14CYCLES
  3565. * @arg @ref LL_ADC_MULTI_TWOSMP_DELAY_15CYCLES
  3566. * @arg @ref LL_ADC_MULTI_TWOSMP_DELAY_16CYCLES
  3567. * @arg @ref LL_ADC_MULTI_TWOSMP_DELAY_17CYCLES
  3568. * @arg @ref LL_ADC_MULTI_TWOSMP_DELAY_18CYCLES
  3569. * @arg @ref LL_ADC_MULTI_TWOSMP_DELAY_19CYCLES
  3570. * @arg @ref LL_ADC_MULTI_TWOSMP_DELAY_20CYCLES
  3571. */
  3572. __STATIC_INLINE uint32_t LL_ADC_GetMultiTwoSamplingDelay(ADC_Common_TypeDef *ADCxy_COMMON)
  3573. {
  3574. return (uint32_t)(READ_BIT(ADCxy_COMMON->CCR, ADC_CCR_DELAY));
  3575. }
  3576. #endif /* ADC_MULTIMODE_SUPPORT */
  3577. /**
  3578. * @}
  3579. */
  3580. /** @defgroup ADC_LL_EF_Operation_ADC_Instance Operation on ADC hierarchical scope: ADC instance
  3581. * @{
  3582. */
  3583. /**
  3584. * @brief Enable the selected ADC instance.
  3585. * @note On this STM32 serie, after ADC enable, a delay for
  3586. * ADC internal analog stabilization is required before performing a
  3587. * ADC conversion start.
  3588. * Refer to device datasheet, parameter tSTAB.
  3589. * @rmtoll CR2 ADON LL_ADC_Enable
  3590. * @param ADCx ADC instance
  3591. * @retval None
  3592. */
  3593. __STATIC_INLINE void LL_ADC_Enable(ADC_TypeDef *ADCx)
  3594. {
  3595. SET_BIT(ADCx->CR2, ADC_CR2_ADON);
  3596. }
  3597. /**
  3598. * @brief Disable the selected ADC instance.
  3599. * @rmtoll CR2 ADON LL_ADC_Disable
  3600. * @param ADCx ADC instance
  3601. * @retval None
  3602. */
  3603. __STATIC_INLINE void LL_ADC_Disable(ADC_TypeDef *ADCx)
  3604. {
  3605. CLEAR_BIT(ADCx->CR2, ADC_CR2_ADON);
  3606. }
  3607. /**
  3608. * @brief Get the selected ADC instance enable state.
  3609. * @rmtoll CR2 ADON LL_ADC_IsEnabled
  3610. * @param ADCx ADC instance
  3611. * @retval 0: ADC is disabled, 1: ADC is enabled.
  3612. */
  3613. __STATIC_INLINE uint32_t LL_ADC_IsEnabled(ADC_TypeDef *ADCx)
  3614. {
  3615. return (READ_BIT(ADCx->CR2, ADC_CR2_ADON) == (ADC_CR2_ADON));
  3616. }
  3617. /**
  3618. * @}
  3619. */
  3620. /** @defgroup ADC_LL_EF_Operation_ADC_Group_Regular Operation on ADC hierarchical scope: group regular
  3621. * @{
  3622. */
  3623. /**
  3624. * @brief Start ADC group regular conversion.
  3625. * @note On this STM32 serie, this function is relevant only for
  3626. * internal trigger (SW start), not for external trigger:
  3627. * - If ADC trigger has been set to software start, ADC conversion
  3628. * starts immediately.
  3629. * - If ADC trigger has been set to external trigger, ADC conversion
  3630. * start must be performed using function
  3631. * @ref LL_ADC_REG_StartConversionExtTrig().
  3632. * (if external trigger edge would have been set during ADC other
  3633. * settings, ADC conversion would start at trigger event
  3634. * as soon as ADC is enabled).
  3635. * @rmtoll CR2 SWSTART LL_ADC_REG_StartConversionSWStart
  3636. * @param ADCx ADC instance
  3637. * @retval None
  3638. */
  3639. __STATIC_INLINE void LL_ADC_REG_StartConversionSWStart(ADC_TypeDef *ADCx)
  3640. {
  3641. SET_BIT(ADCx->CR2, ADC_CR2_SWSTART);
  3642. }
  3643. /**
  3644. * @brief Start ADC group regular conversion from external trigger.
  3645. * @note ADC conversion will start at next trigger event (on the selected
  3646. * trigger edge) following the ADC start conversion command.
  3647. * @note On this STM32 serie, this function is relevant for
  3648. * ADC conversion start from external trigger.
  3649. * If internal trigger (SW start) is needed, perform ADC conversion
  3650. * start using function @ref LL_ADC_REG_StartConversionSWStart().
  3651. * @rmtoll CR2 EXTEN LL_ADC_REG_StartConversionExtTrig
  3652. * @param ExternalTriggerEdge This parameter can be one of the following values:
  3653. * @arg @ref LL_ADC_REG_TRIG_EXT_RISING
  3654. * @arg @ref LL_ADC_REG_TRIG_EXT_FALLING
  3655. * @arg @ref LL_ADC_REG_TRIG_EXT_RISINGFALLING
  3656. * @param ADCx ADC instance
  3657. * @retval None
  3658. */
  3659. __STATIC_INLINE void LL_ADC_REG_StartConversionExtTrig(ADC_TypeDef *ADCx, uint32_t ExternalTriggerEdge)
  3660. {
  3661. SET_BIT(ADCx->CR2, ExternalTriggerEdge);
  3662. }
  3663. /**
  3664. * @brief Stop ADC group regular conversion from external trigger.
  3665. * @note No more ADC conversion will start at next trigger event
  3666. * following the ADC stop conversion command.
  3667. * If a conversion is on-going, it will be completed.
  3668. * @note On this STM32 serie, there is no specific command
  3669. * to stop a conversion on-going or to stop ADC converting
  3670. * in continuous mode. These actions can be performed
  3671. * using function @ref LL_ADC_Disable().
  3672. * @rmtoll CR2 EXTEN LL_ADC_REG_StopConversionExtTrig
  3673. * @param ADCx ADC instance
  3674. * @retval None
  3675. */
  3676. __STATIC_INLINE void LL_ADC_REG_StopConversionExtTrig(ADC_TypeDef *ADCx)
  3677. {
  3678. CLEAR_BIT(ADCx->CR2, ADC_CR2_EXTEN);
  3679. }
  3680. /**
  3681. * @brief Get ADC group regular conversion data, range fit for
  3682. * all ADC configurations: all ADC resolutions and
  3683. * all oversampling increased data width (for devices
  3684. * with feature oversampling).
  3685. * @rmtoll DR RDATA LL_ADC_REG_ReadConversionData32
  3686. * @param ADCx ADC instance
  3687. * @retval Value between Min_Data=0x00000000 and Max_Data=0xFFFFFFFF
  3688. */
  3689. __STATIC_INLINE uint32_t LL_ADC_REG_ReadConversionData32(ADC_TypeDef *ADCx)
  3690. {
  3691. return (uint16_t)(READ_BIT(ADCx->DR, ADC_DR_DATA));
  3692. }
  3693. /**
  3694. * @brief Get ADC group regular conversion data, range fit for
  3695. * ADC resolution 12 bits.
  3696. * @note For devices with feature oversampling: Oversampling
  3697. * can increase data width, function for extended range
  3698. * may be needed: @ref LL_ADC_REG_ReadConversionData32.
  3699. * @rmtoll DR RDATA LL_ADC_REG_ReadConversionData12
  3700. * @param ADCx ADC instance
  3701. * @retval Value between Min_Data=0x000 and Max_Data=0xFFF
  3702. */
  3703. __STATIC_INLINE uint16_t LL_ADC_REG_ReadConversionData12(ADC_TypeDef *ADCx)
  3704. {
  3705. return (uint16_t)(READ_BIT(ADCx->DR, ADC_DR_DATA));
  3706. }
  3707. /**
  3708. * @brief Get ADC group regular conversion data, range fit for
  3709. * ADC resolution 10 bits.
  3710. * @note For devices with feature oversampling: Oversampling
  3711. * can increase data width, function for extended range
  3712. * may be needed: @ref LL_ADC_REG_ReadConversionData32.
  3713. * @rmtoll DR RDATA LL_ADC_REG_ReadConversionData10
  3714. * @param ADCx ADC instance
  3715. * @retval Value between Min_Data=0x000 and Max_Data=0x3FF
  3716. */
  3717. __STATIC_INLINE uint16_t LL_ADC_REG_ReadConversionData10(ADC_TypeDef *ADCx)
  3718. {
  3719. return (uint16_t)(READ_BIT(ADCx->DR, ADC_DR_DATA));
  3720. }
  3721. /**
  3722. * @brief Get ADC group regular conversion data, range fit for
  3723. * ADC resolution 8 bits.
  3724. * @note For devices with feature oversampling: Oversampling
  3725. * can increase data width, function for extended range
  3726. * may be needed: @ref LL_ADC_REG_ReadConversionData32.
  3727. * @rmtoll DR RDATA LL_ADC_REG_ReadConversionData8
  3728. * @param ADCx ADC instance
  3729. * @retval Value between Min_Data=0x00 and Max_Data=0xFF
  3730. */
  3731. __STATIC_INLINE uint8_t LL_ADC_REG_ReadConversionData8(ADC_TypeDef *ADCx)
  3732. {
  3733. return (uint16_t)(READ_BIT(ADCx->DR, ADC_DR_DATA));
  3734. }
  3735. /**
  3736. * @brief Get ADC group regular conversion data, range fit for
  3737. * ADC resolution 6 bits.
  3738. * @note For devices with feature oversampling: Oversampling
  3739. * can increase data width, function for extended range
  3740. * may be needed: @ref LL_ADC_REG_ReadConversionData32.
  3741. * @rmtoll DR RDATA LL_ADC_REG_ReadConversionData6
  3742. * @param ADCx ADC instance
  3743. * @retval Value between Min_Data=0x00 and Max_Data=0x3F
  3744. */
  3745. __STATIC_INLINE uint8_t LL_ADC_REG_ReadConversionData6(ADC_TypeDef *ADCx)
  3746. {
  3747. return (uint16_t)(READ_BIT(ADCx->DR, ADC_DR_DATA));
  3748. }
  3749. #if defined(ADC_MULTIMODE_SUPPORT)
  3750. /**
  3751. * @brief Get ADC multimode conversion data of ADC master, ADC slave
  3752. * or raw data with ADC master and slave concatenated.
  3753. * @note If raw data with ADC master and slave concatenated is retrieved,
  3754. * a macro is available to get the conversion data of
  3755. * ADC master or ADC slave: see helper macro
  3756. * @ref __LL_ADC_MULTI_CONV_DATA_MASTER_SLAVE().
  3757. * (however this macro is mainly intended for multimode
  3758. * transfer by DMA, because this function can do the same
  3759. * by getting multimode conversion data of ADC master or ADC slave
  3760. * separately).
  3761. * @rmtoll CDR DATA1 LL_ADC_REG_ReadMultiConversionData32\n
  3762. * CDR DATA2 LL_ADC_REG_ReadMultiConversionData32
  3763. * @param ADCxy_COMMON ADC common instance
  3764. * (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() )
  3765. * @param ConversionData This parameter can be one of the following values:
  3766. * @arg @ref LL_ADC_MULTI_MASTER
  3767. * @arg @ref LL_ADC_MULTI_SLAVE
  3768. * @arg @ref LL_ADC_MULTI_MASTER_SLAVE
  3769. * @retval Value between Min_Data=0x00000000 and Max_Data=0xFFFFFFFF
  3770. */
  3771. __STATIC_INLINE uint32_t LL_ADC_REG_ReadMultiConversionData32(ADC_Common_TypeDef *ADCxy_COMMON, uint32_t ConversionData)
  3772. {
  3773. return (uint32_t)(READ_BIT(ADCxy_COMMON->CDR,
  3774. ADC_DR_ADC2DATA)
  3775. >> POSITION_VAL(ConversionData)
  3776. );
  3777. }
  3778. #endif /* ADC_MULTIMODE_SUPPORT */
  3779. /**
  3780. * @}
  3781. */
  3782. /** @defgroup ADC_LL_EF_Operation_ADC_Group_Injected Operation on ADC hierarchical scope: group injected
  3783. * @{
  3784. */
  3785. /**
  3786. * @brief Start ADC group injected conversion.
  3787. * @note On this STM32 serie, this function is relevant only for
  3788. * internal trigger (SW start), not for external trigger:
  3789. * - If ADC trigger has been set to software start, ADC conversion
  3790. * starts immediately.
  3791. * - If ADC trigger has been set to external trigger, ADC conversion
  3792. * start must be performed using function
  3793. * @ref LL_ADC_INJ_StartConversionExtTrig().
  3794. * (if external trigger edge would have been set during ADC other
  3795. * settings, ADC conversion would start at trigger event
  3796. * as soon as ADC is enabled).
  3797. * @rmtoll CR2 JSWSTART LL_ADC_INJ_StartConversionSWStart
  3798. * @param ADCx ADC instance
  3799. * @retval None
  3800. */
  3801. __STATIC_INLINE void LL_ADC_INJ_StartConversionSWStart(ADC_TypeDef *ADCx)
  3802. {
  3803. SET_BIT(ADCx->CR2, ADC_CR2_JSWSTART);
  3804. }
  3805. /**
  3806. * @brief Start ADC group injected conversion from external trigger.
  3807. * @note ADC conversion will start at next trigger event (on the selected
  3808. * trigger edge) following the ADC start conversion command.
  3809. * @note On this STM32 serie, this function is relevant for
  3810. * ADC conversion start from external trigger.
  3811. * If internal trigger (SW start) is needed, perform ADC conversion
  3812. * start using function @ref LL_ADC_INJ_StartConversionSWStart().
  3813. * @rmtoll CR2 JEXTEN LL_ADC_INJ_StartConversionExtTrig
  3814. * @param ExternalTriggerEdge This parameter can be one of the following values:
  3815. * @arg @ref LL_ADC_INJ_TRIG_EXT_RISING
  3816. * @arg @ref LL_ADC_INJ_TRIG_EXT_FALLING
  3817. * @arg @ref LL_ADC_INJ_TRIG_EXT_RISINGFALLING
  3818. * @param ADCx ADC instance
  3819. * @retval None
  3820. */
  3821. __STATIC_INLINE void LL_ADC_INJ_StartConversionExtTrig(ADC_TypeDef *ADCx, uint32_t ExternalTriggerEdge)
  3822. {
  3823. SET_BIT(ADCx->CR2, ExternalTriggerEdge);
  3824. }
  3825. /**
  3826. * @brief Stop ADC group injected conversion from external trigger.
  3827. * @note No more ADC conversion will start at next trigger event
  3828. * following the ADC stop conversion command.
  3829. * If a conversion is on-going, it will be completed.
  3830. * @note On this STM32 serie, there is no specific command
  3831. * to stop a conversion on-going or to stop ADC converting
  3832. * in continuous mode. These actions can be performed
  3833. * using function @ref LL_ADC_Disable().
  3834. * @rmtoll CR2 JEXTEN LL_ADC_INJ_StopConversionExtTrig
  3835. * @param ADCx ADC instance
  3836. * @retval None
  3837. */
  3838. __STATIC_INLINE void LL_ADC_INJ_StopConversionExtTrig(ADC_TypeDef *ADCx)
  3839. {
  3840. CLEAR_BIT(ADCx->CR2, ADC_CR2_JEXTEN);
  3841. }
  3842. /**
  3843. * @brief Get ADC group regular conversion data, range fit for
  3844. * all ADC configurations: all ADC resolutions and
  3845. * all oversampling increased data width (for devices
  3846. * with feature oversampling).
  3847. * @rmtoll JDR1 JDATA LL_ADC_INJ_ReadConversionData32\n
  3848. * JDR2 JDATA LL_ADC_INJ_ReadConversionData32\n
  3849. * JDR3 JDATA LL_ADC_INJ_ReadConversionData32\n
  3850. * JDR4 JDATA LL_ADC_INJ_ReadConversionData32
  3851. * @param ADCx ADC instance
  3852. * @param Rank This parameter can be one of the following values:
  3853. * @arg @ref LL_ADC_INJ_RANK_1
  3854. * @arg @ref LL_ADC_INJ_RANK_2
  3855. * @arg @ref LL_ADC_INJ_RANK_3
  3856. * @arg @ref LL_ADC_INJ_RANK_4
  3857. * @retval Value between Min_Data=0x00000000 and Max_Data=0xFFFFFFFF
  3858. */
  3859. __STATIC_INLINE uint32_t LL_ADC_INJ_ReadConversionData32(ADC_TypeDef *ADCx, uint32_t Rank)
  3860. {
  3861. register __IO uint32_t *preg = __ADC_PTR_REG_OFFSET(ADCx->JDR1, __ADC_MASK_SHIFT(Rank, ADC_INJ_JDRX_REGOFFSET_MASK));
  3862. return (uint32_t)(READ_BIT(*preg,
  3863. ADC_JDR1_JDATA)
  3864. );
  3865. }
  3866. /**
  3867. * @brief Get ADC group injected conversion data, range fit for
  3868. * ADC resolution 12 bits.
  3869. * @note For devices with feature oversampling: Oversampling
  3870. * can increase data width, function for extended range
  3871. * may be needed: @ref LL_ADC_INJ_ReadConversionData32.
  3872. * @rmtoll JDR1 JDATA LL_ADC_INJ_ReadConversionData12\n
  3873. * JDR2 JDATA LL_ADC_INJ_ReadConversionData12\n
  3874. * JDR3 JDATA LL_ADC_INJ_ReadConversionData12\n
  3875. * JDR4 JDATA LL_ADC_INJ_ReadConversionData12
  3876. * @param ADCx ADC instance
  3877. * @param Rank This parameter can be one of the following values:
  3878. * @arg @ref LL_ADC_INJ_RANK_1
  3879. * @arg @ref LL_ADC_INJ_RANK_2
  3880. * @arg @ref LL_ADC_INJ_RANK_3
  3881. * @arg @ref LL_ADC_INJ_RANK_4
  3882. * @retval Value between Min_Data=0x000 and Max_Data=0xFFF
  3883. */
  3884. __STATIC_INLINE uint16_t LL_ADC_INJ_ReadConversionData12(ADC_TypeDef *ADCx, uint32_t Rank)
  3885. {
  3886. register __IO uint32_t *preg = __ADC_PTR_REG_OFFSET(ADCx->JDR1, __ADC_MASK_SHIFT(Rank, ADC_INJ_JDRX_REGOFFSET_MASK));
  3887. return (uint16_t)(READ_BIT(*preg,
  3888. ADC_JDR1_JDATA)
  3889. );
  3890. }
  3891. /**
  3892. * @brief Get ADC group injected conversion data, range fit for
  3893. * ADC resolution 10 bits.
  3894. * @note For devices with feature oversampling: Oversampling
  3895. * can increase data width, function for extended range
  3896. * may be needed: @ref LL_ADC_INJ_ReadConversionData32.
  3897. * @rmtoll JDR1 JDATA LL_ADC_INJ_ReadConversionData10\n
  3898. * JDR2 JDATA LL_ADC_INJ_ReadConversionData10\n
  3899. * JDR3 JDATA LL_ADC_INJ_ReadConversionData10\n
  3900. * JDR4 JDATA LL_ADC_INJ_ReadConversionData10
  3901. * @param ADCx ADC instance
  3902. * @param Rank This parameter can be one of the following values:
  3903. * @arg @ref LL_ADC_INJ_RANK_1
  3904. * @arg @ref LL_ADC_INJ_RANK_2
  3905. * @arg @ref LL_ADC_INJ_RANK_3
  3906. * @arg @ref LL_ADC_INJ_RANK_4
  3907. * @retval Value between Min_Data=0x000 and Max_Data=0x3FF
  3908. */
  3909. __STATIC_INLINE uint16_t LL_ADC_INJ_ReadConversionData10(ADC_TypeDef *ADCx, uint32_t Rank)
  3910. {
  3911. register __IO uint32_t *preg = __ADC_PTR_REG_OFFSET(ADCx->JDR1, __ADC_MASK_SHIFT(Rank, ADC_INJ_JDRX_REGOFFSET_MASK));
  3912. return (uint16_t)(READ_BIT(*preg,
  3913. ADC_JDR1_JDATA)
  3914. );
  3915. }
  3916. /**
  3917. * @brief Get ADC group injected conversion data, range fit for
  3918. * ADC resolution 8 bits.
  3919. * @note For devices with feature oversampling: Oversampling
  3920. * can increase data width, function for extended range
  3921. * may be needed: @ref LL_ADC_INJ_ReadConversionData32.
  3922. * @rmtoll JDR1 JDATA LL_ADC_INJ_ReadConversionData8\n
  3923. * JDR2 JDATA LL_ADC_INJ_ReadConversionData8\n
  3924. * JDR3 JDATA LL_ADC_INJ_ReadConversionData8\n
  3925. * JDR4 JDATA LL_ADC_INJ_ReadConversionData8
  3926. * @param ADCx ADC instance
  3927. * @param Rank This parameter can be one of the following values:
  3928. * @arg @ref LL_ADC_INJ_RANK_1
  3929. * @arg @ref LL_ADC_INJ_RANK_2
  3930. * @arg @ref LL_ADC_INJ_RANK_3
  3931. * @arg @ref LL_ADC_INJ_RANK_4
  3932. * @retval Value between Min_Data=0x00 and Max_Data=0xFF
  3933. */
  3934. __STATIC_INLINE uint8_t LL_ADC_INJ_ReadConversionData8(ADC_TypeDef *ADCx, uint32_t Rank)
  3935. {
  3936. register __IO uint32_t *preg = __ADC_PTR_REG_OFFSET(ADCx->JDR1, __ADC_MASK_SHIFT(Rank, ADC_INJ_JDRX_REGOFFSET_MASK));
  3937. return (uint8_t)(READ_BIT(*preg,
  3938. ADC_JDR1_JDATA)
  3939. );
  3940. }
  3941. /**
  3942. * @brief Get ADC group injected conversion data, range fit for
  3943. * ADC resolution 6 bits.
  3944. * @note For devices with feature oversampling: Oversampling
  3945. * can increase data width, function for extended range
  3946. * may be needed: @ref LL_ADC_INJ_ReadConversionData32.
  3947. * @rmtoll JDR1 JDATA LL_ADC_INJ_ReadConversionData6\n
  3948. * JDR2 JDATA LL_ADC_INJ_ReadConversionData6\n
  3949. * JDR3 JDATA LL_ADC_INJ_ReadConversionData6\n
  3950. * JDR4 JDATA LL_ADC_INJ_ReadConversionData6
  3951. * @param ADCx ADC instance
  3952. * @param Rank This parameter can be one of the following values:
  3953. * @arg @ref LL_ADC_INJ_RANK_1
  3954. * @arg @ref LL_ADC_INJ_RANK_2
  3955. * @arg @ref LL_ADC_INJ_RANK_3
  3956. * @arg @ref LL_ADC_INJ_RANK_4
  3957. * @retval Value between Min_Data=0x00 and Max_Data=0x3F
  3958. */
  3959. __STATIC_INLINE uint8_t LL_ADC_INJ_ReadConversionData6(ADC_TypeDef *ADCx, uint32_t Rank)
  3960. {
  3961. register __IO uint32_t *preg = __ADC_PTR_REG_OFFSET(ADCx->JDR1, __ADC_MASK_SHIFT(Rank, ADC_INJ_JDRX_REGOFFSET_MASK));
  3962. return (uint8_t)(READ_BIT(*preg,
  3963. ADC_JDR1_JDATA)
  3964. );
  3965. }
  3966. /**
  3967. * @}
  3968. */
  3969. /** @defgroup ADC_LL_EF_FLAG_Management ADC flag management
  3970. * @{
  3971. */
  3972. /**
  3973. * @brief Get flag ADC group regular end of unitary conversion
  3974. * or end of sequence conversions, depending on
  3975. * ADC configuration.
  3976. * @note To configure flag of end of conversion,
  3977. * use function @ref LL_ADC_REG_SetFlagEndOfConversion().
  3978. * @rmtoll SR EOC LL_ADC_IsActiveFlag_EOCS
  3979. * @param ADCx ADC instance
  3980. * @retval State of bit (1 or 0).
  3981. */
  3982. __STATIC_INLINE uint32_t LL_ADC_IsActiveFlag_EOCS(ADC_TypeDef *ADCx)
  3983. {
  3984. return (READ_BIT(ADCx->SR, LL_ADC_FLAG_EOCS) == (LL_ADC_FLAG_EOCS));
  3985. }
  3986. /**
  3987. * @brief Get flag ADC group regular overrun.
  3988. * @rmtoll SR OVR LL_ADC_IsActiveFlag_OVR
  3989. * @param ADCx ADC instance
  3990. * @retval State of bit (1 or 0).
  3991. */
  3992. __STATIC_INLINE uint32_t LL_ADC_IsActiveFlag_OVR(ADC_TypeDef *ADCx)
  3993. {
  3994. return (READ_BIT(ADCx->SR, LL_ADC_FLAG_OVR) == (LL_ADC_FLAG_OVR));
  3995. }
  3996. /**
  3997. * @brief Get flag ADC group injected end of sequence conversions.
  3998. * @rmtoll SR JEOC LL_ADC_IsActiveFlag_JEOS
  3999. * @param ADCx ADC instance
  4000. * @retval State of bit (1 or 0).
  4001. */
  4002. __STATIC_INLINE uint32_t LL_ADC_IsActiveFlag_JEOS(ADC_TypeDef *ADCx)
  4003. {
  4004. /* Note: on this STM32 serie, there is no flag ADC group injected */
  4005. /* end of unitary conversion. */
  4006. /* Flag noted as "JEOC" is corresponding to flag "JEOS" */
  4007. /* in other STM32 families). */
  4008. return (READ_BIT(ADCx->SR, LL_ADC_FLAG_JEOS) == (LL_ADC_FLAG_JEOS));
  4009. }
  4010. /**
  4011. * @brief Get flag ADC analog watchdog 1 flag
  4012. * @rmtoll SR AWD LL_ADC_IsActiveFlag_AWD1
  4013. * @param ADCx ADC instance
  4014. * @retval State of bit (1 or 0).
  4015. */
  4016. __STATIC_INLINE uint32_t LL_ADC_IsActiveFlag_AWD1(ADC_TypeDef *ADCx)
  4017. {
  4018. return (READ_BIT(ADCx->SR, LL_ADC_FLAG_AWD1) == (LL_ADC_FLAG_AWD1));
  4019. }
  4020. /**
  4021. * @brief Clear flag ADC group regular end of unitary conversion
  4022. * or end of sequence conversions, depending on
  4023. * ADC configuration.
  4024. * @note To configure flag of end of conversion,
  4025. * use function @ref LL_ADC_REG_SetFlagEndOfConversion().
  4026. * @rmtoll SR EOC LL_ADC_ClearFlag_EOCS
  4027. * @param ADCx ADC instance
  4028. * @retval None
  4029. */
  4030. __STATIC_INLINE void LL_ADC_ClearFlag_EOCS(ADC_TypeDef *ADCx)
  4031. {
  4032. WRITE_REG(ADCx->SR, ~LL_ADC_FLAG_EOCS);
  4033. }
  4034. /**
  4035. * @brief Clear flag ADC group regular overrun.
  4036. * @rmtoll SR OVR LL_ADC_ClearFlag_OVR
  4037. * @param ADCx ADC instance
  4038. * @retval None
  4039. */
  4040. __STATIC_INLINE void LL_ADC_ClearFlag_OVR(ADC_TypeDef *ADCx)
  4041. {
  4042. WRITE_REG(ADCx->SR, ~LL_ADC_FLAG_OVR);
  4043. }
  4044. /**
  4045. * @brief Clear flag ADC group injected end of sequence conversions.
  4046. * @rmtoll SR JEOC LL_ADC_ClearFlag_JEOS
  4047. * @param ADCx ADC instance
  4048. * @retval None
  4049. */
  4050. __STATIC_INLINE void LL_ADC_ClearFlag_JEOS(ADC_TypeDef *ADCx)
  4051. {
  4052. /* Note: on this STM32 serie, there is no flag ADC group injected */
  4053. /* end of unitary conversion. */
  4054. /* Flag noted as "JEOC" is corresponding to flag "JEOS" */
  4055. /* in other STM32 families). */
  4056. WRITE_REG(ADCx->SR, ~LL_ADC_FLAG_JEOS);
  4057. }
  4058. /**
  4059. * @brief Clear flag ADC analog watchdog 1.
  4060. * @rmtoll SR AWD LL_ADC_ClearFlag_AWD1
  4061. * @param ADCx ADC instance
  4062. * @retval None
  4063. */
  4064. __STATIC_INLINE void LL_ADC_ClearFlag_AWD1(ADC_TypeDef *ADCx)
  4065. {
  4066. WRITE_REG(ADCx->SR, ~LL_ADC_FLAG_AWD1);
  4067. }
  4068. #if defined(ADC_MULTIMODE_SUPPORT)
  4069. /**
  4070. * @brief Get flag multimode ADC group regular end of unitary conversion
  4071. * or end of sequence conversions, depending on
  4072. * ADC configuration, of the ADC master.
  4073. * @note To configure flag of end of conversion,
  4074. * use function @ref LL_ADC_REG_SetFlagEndOfConversion().
  4075. * @rmtoll CSR EOC1 LL_ADC_IsActiveFlag_MST_EOCS
  4076. * @param ADCxy_COMMON ADC common instance
  4077. * (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() )
  4078. * @retval State of bit (1 or 0).
  4079. */
  4080. __STATIC_INLINE uint32_t LL_ADC_IsActiveFlag_MST_EOCS(ADC_Common_TypeDef *ADCxy_COMMON)
  4081. {
  4082. return (READ_BIT(ADC1->SR, LL_ADC_FLAG_EOCS) == (LL_ADC_FLAG_EOCS));
  4083. }
  4084. /**
  4085. * @brief Get flag multimode ADC group regular end of unitary conversion
  4086. * or end of sequence conversions, depending on
  4087. * ADC configuration, of the ADC slave 1.
  4088. * @note To configure flag of end of conversion,
  4089. * use function @ref LL_ADC_REG_SetFlagEndOfConversion().
  4090. * @rmtoll CSR EOC2 LL_ADC_IsActiveFlag_SLV1_EOCS
  4091. * @param ADCxy_COMMON ADC common instance
  4092. * (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() )
  4093. * @retval State of bit (1 or 0).
  4094. */
  4095. __STATIC_INLINE uint32_t LL_ADC_IsActiveFlag_SLV1_EOCS(ADC_Common_TypeDef *ADCxy_COMMON)
  4096. {
  4097. return (READ_BIT(ADCxy_COMMON->CSR, LL_ADC_FLAG_EOCS_SLV1) == (LL_ADC_FLAG_EOCS_SLV1));
  4098. }
  4099. /**
  4100. * @brief Get flag multimode ADC group regular end of unitary conversion
  4101. * or end of sequence conversions, depending on
  4102. * ADC configuration, of the ADC slave 2.
  4103. * @note To configure flag of end of conversion,
  4104. * use function @ref LL_ADC_REG_SetFlagEndOfConversion().
  4105. * @rmtoll CSR EOC3 LL_ADC_IsActiveFlag_SLV2_EOCS
  4106. * @param ADCxy_COMMON ADC common instance
  4107. * (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() )
  4108. * @retval State of bit (1 or 0).
  4109. */
  4110. __STATIC_INLINE uint32_t LL_ADC_IsActiveFlag_SLV2_EOCS(ADC_Common_TypeDef *ADCxy_COMMON)
  4111. {
  4112. return (READ_BIT(ADCxy_COMMON->CSR, LL_ADC_FLAG_EOCS_SLV2) == (LL_ADC_FLAG_EOCS_SLV2));
  4113. }
  4114. /**
  4115. * @brief Get flag multimode ADC group regular overrun of the ADC master.
  4116. * @rmtoll CSR OVR1 LL_ADC_IsActiveFlag_MST_OVR
  4117. * @param ADCxy_COMMON ADC common instance
  4118. * (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() )
  4119. * @retval State of bit (1 or 0).
  4120. */
  4121. __STATIC_INLINE uint32_t LL_ADC_IsActiveFlag_MST_OVR(ADC_Common_TypeDef *ADCxy_COMMON)
  4122. {
  4123. return (READ_BIT(ADCxy_COMMON->CSR, LL_ADC_FLAG_OVR_MST) == (LL_ADC_FLAG_OVR_MST));
  4124. }
  4125. /**
  4126. * @brief Get flag multimode ADC group regular overrun of the ADC slave 1.
  4127. * @rmtoll CSR OVR2 LL_ADC_IsActiveFlag_SLV1_OVR
  4128. * @param ADCxy_COMMON ADC common instance
  4129. * (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() )
  4130. * @retval State of bit (1 or 0).
  4131. */
  4132. __STATIC_INLINE uint32_t LL_ADC_IsActiveFlag_SLV1_OVR(ADC_Common_TypeDef *ADCxy_COMMON)
  4133. {
  4134. return (READ_BIT(ADCxy_COMMON->CSR, LL_ADC_FLAG_OVR_SLV1) == (LL_ADC_FLAG_OVR_SLV1));
  4135. }
  4136. /**
  4137. * @brief Get flag multimode ADC group regular overrun of the ADC slave 2.
  4138. * @rmtoll CSR OVR3 LL_ADC_IsActiveFlag_SLV2_OVR
  4139. * @param ADCxy_COMMON ADC common instance
  4140. * (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() )
  4141. * @retval State of bit (1 or 0).
  4142. */
  4143. __STATIC_INLINE uint32_t LL_ADC_IsActiveFlag_SLV2_OVR(ADC_Common_TypeDef *ADCxy_COMMON)
  4144. {
  4145. return (READ_BIT(ADCxy_COMMON->CSR, LL_ADC_FLAG_OVR_SLV2) == (LL_ADC_FLAG_OVR_SLV2));
  4146. }
  4147. /**
  4148. * @brief Get flag multimode ADC group injected end of sequence conversions of the ADC master.
  4149. * @rmtoll CSR JEOC LL_ADC_IsActiveFlag_MST_EOCS
  4150. * @param ADCxy_COMMON ADC common instance
  4151. * (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() )
  4152. * @retval State of bit (1 or 0).
  4153. */
  4154. __STATIC_INLINE uint32_t LL_ADC_IsActiveFlag_MST_JEOS(ADC_Common_TypeDef *ADCxy_COMMON)
  4155. {
  4156. /* Note: on this STM32 serie, there is no flag ADC group injected */
  4157. /* end of unitary conversion. */
  4158. /* Flag noted as "JEOC" is corresponding to flag "JEOS" */
  4159. /* in other STM32 families). */
  4160. return (READ_BIT(ADCxy_COMMON->CSR, ADC_CSR_JEOC1) == (ADC_CSR_JEOC1));
  4161. }
  4162. /**
  4163. * @brief Get flag multimode ADC group injected end of sequence conversions of the ADC slave 1.
  4164. * @rmtoll CSR JEOC2 LL_ADC_IsActiveFlag_SLV1_JEOS
  4165. * @param ADCxy_COMMON ADC common instance
  4166. * (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() )
  4167. * @retval State of bit (1 or 0).
  4168. */
  4169. __STATIC_INLINE uint32_t LL_ADC_IsActiveFlag_SLV1_JEOS(ADC_Common_TypeDef *ADCxy_COMMON)
  4170. {
  4171. /* Note: on this STM32 serie, there is no flag ADC group injected */
  4172. /* end of unitary conversion. */
  4173. /* Flag noted as "JEOC" is corresponding to flag "JEOS" */
  4174. /* in other STM32 families). */
  4175. return (READ_BIT(ADCxy_COMMON->CSR, ADC_CSR_JEOC2) == (ADC_CSR_JEOC2));
  4176. }
  4177. /**
  4178. * @brief Get flag multimode ADC group injected end of sequence conversions of the ADC slave 2.
  4179. * @rmtoll CSR JEOC3 LL_ADC_IsActiveFlag_SLV2_JEOS
  4180. * @param ADCxy_COMMON ADC common instance
  4181. * (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() )
  4182. * @retval State of bit (1 or 0).
  4183. */
  4184. __STATIC_INLINE uint32_t LL_ADC_IsActiveFlag_SLV2_JEOS(ADC_Common_TypeDef *ADCxy_COMMON)
  4185. {
  4186. /* Note: on this STM32 serie, there is no flag ADC group injected */
  4187. /* end of unitary conversion. */
  4188. /* Flag noted as "JEOC" is corresponding to flag "JEOS" */
  4189. /* in other STM32 families). */
  4190. return (READ_BIT(ADCxy_COMMON->CSR, ADC_CSR_JEOC3) == (ADC_CSR_JEOC3));
  4191. }
  4192. /**
  4193. * @brief Get flag multimode ADC analog watchdog 1 of the ADC master.
  4194. * @rmtoll CSR AWD1 LL_ADC_IsActiveFlag_MST_AWD1
  4195. * @param ADCxy_COMMON ADC common instance
  4196. * (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() )
  4197. * @retval State of bit (1 or 0).
  4198. */
  4199. __STATIC_INLINE uint32_t LL_ADC_IsActiveFlag_MST_AWD1(ADC_Common_TypeDef *ADCxy_COMMON)
  4200. {
  4201. return (READ_BIT(ADCxy_COMMON->CSR, LL_ADC_FLAG_AWD1_MST) == (LL_ADC_FLAG_AWD1_MST));
  4202. }
  4203. /**
  4204. * @brief Get flag multimode analog watchdog 1 of the ADC slave 1.
  4205. * @rmtoll CSR AWD2 LL_ADC_IsActiveFlag_SLV1_AWD1
  4206. * @param ADCxy_COMMON ADC common instance
  4207. * (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() )
  4208. * @retval State of bit (1 or 0).
  4209. */
  4210. __STATIC_INLINE uint32_t LL_ADC_IsActiveFlag_SLV1_AWD1(ADC_Common_TypeDef *ADCxy_COMMON)
  4211. {
  4212. return (READ_BIT(ADCxy_COMMON->CSR, LL_ADC_FLAG_AWD1_SLV1) == (LL_ADC_FLAG_AWD1_SLV1));
  4213. }
  4214. /**
  4215. * @brief Get flag multimode analog watchdog 1 of the ADC slave 2.
  4216. * @rmtoll CSR AWD3 LL_ADC_IsActiveFlag_SLV2_AWD1
  4217. * @param ADCxy_COMMON ADC common instance
  4218. * (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() )
  4219. * @retval State of bit (1 or 0).
  4220. */
  4221. __STATIC_INLINE uint32_t LL_ADC_IsActiveFlag_SLV2_AWD1(ADC_Common_TypeDef *ADCxy_COMMON)
  4222. {
  4223. return (READ_BIT(ADCxy_COMMON->CSR, LL_ADC_FLAG_AWD1_SLV2) == (LL_ADC_FLAG_AWD1_SLV2));
  4224. }
  4225. #endif /* ADC_MULTIMODE_SUPPORT */
  4226. /**
  4227. * @}
  4228. */
  4229. /** @defgroup ADC_LL_EF_IT_Management ADC IT management
  4230. * @{
  4231. */
  4232. /**
  4233. * @brief Enable interruption ADC group regular end of unitary conversion
  4234. * or end of sequence conversions, depending on
  4235. * ADC configuration.
  4236. * @note To configure flag of end of conversion,
  4237. * use function @ref LL_ADC_REG_SetFlagEndOfConversion().
  4238. * @rmtoll CR1 EOCIE LL_ADC_EnableIT_EOCS
  4239. * @param ADCx ADC instance
  4240. * @retval None
  4241. */
  4242. __STATIC_INLINE void LL_ADC_EnableIT_EOCS(ADC_TypeDef *ADCx)
  4243. {
  4244. SET_BIT(ADCx->CR1, LL_ADC_IT_EOCS);
  4245. }
  4246. /**
  4247. * @brief Enable ADC group regular interruption overrun.
  4248. * @rmtoll CR1 OVRIE LL_ADC_EnableIT_OVR
  4249. * @param ADCx ADC instance
  4250. * @retval None
  4251. */
  4252. __STATIC_INLINE void LL_ADC_EnableIT_OVR(ADC_TypeDef *ADCx)
  4253. {
  4254. SET_BIT(ADCx->CR1, LL_ADC_IT_OVR);
  4255. }
  4256. /**
  4257. * @brief Enable interruption ADC group injected end of sequence conversions.
  4258. * @rmtoll CR1 JEOCIE LL_ADC_EnableIT_JEOS
  4259. * @param ADCx ADC instance
  4260. * @retval None
  4261. */
  4262. __STATIC_INLINE void LL_ADC_EnableIT_JEOS(ADC_TypeDef *ADCx)
  4263. {
  4264. /* Note: on this STM32 serie, there is no flag ADC group injected */
  4265. /* end of unitary conversion. */
  4266. /* Flag noted as "JEOC" is corresponding to flag "JEOS" */
  4267. /* in other STM32 families). */
  4268. SET_BIT(ADCx->CR1, LL_ADC_IT_JEOS);
  4269. }
  4270. /**
  4271. * @brief Enable interruption ADC analog watchdog 1.
  4272. * @rmtoll CR1 AWDIE LL_ADC_EnableIT_AWD1
  4273. * @param ADCx ADC instance
  4274. * @retval None
  4275. */
  4276. __STATIC_INLINE void LL_ADC_EnableIT_AWD1(ADC_TypeDef *ADCx)
  4277. {
  4278. SET_BIT(ADCx->CR1, LL_ADC_IT_AWD1);
  4279. }
  4280. /**
  4281. * @brief Disable interruption ADC group regular end of unitary conversion
  4282. * or end of sequence conversions, depending on
  4283. * ADC configuration.
  4284. * @note To configure flag of end of conversion,
  4285. * use function @ref LL_ADC_REG_SetFlagEndOfConversion().
  4286. * @rmtoll CR1 EOCIE LL_ADC_DisableIT_EOCS
  4287. * @param ADCx ADC instance
  4288. * @retval None
  4289. */
  4290. __STATIC_INLINE void LL_ADC_DisableIT_EOCS(ADC_TypeDef *ADCx)
  4291. {
  4292. CLEAR_BIT(ADCx->CR1, LL_ADC_IT_EOCS);
  4293. }
  4294. /**
  4295. * @brief Disable interruption ADC group regular overrun.
  4296. * @rmtoll CR1 OVRIE LL_ADC_DisableIT_OVR
  4297. * @param ADCx ADC instance
  4298. * @retval None
  4299. */
  4300. __STATIC_INLINE void LL_ADC_DisableIT_OVR(ADC_TypeDef *ADCx)
  4301. {
  4302. CLEAR_BIT(ADCx->CR1, LL_ADC_IT_OVR);
  4303. }
  4304. /**
  4305. * @brief Disable interruption ADC group injected end of sequence conversions.
  4306. * @rmtoll CR1 JEOCIE LL_ADC_EnableIT_JEOS
  4307. * @param ADCx ADC instance
  4308. * @retval None
  4309. */
  4310. __STATIC_INLINE void LL_ADC_DisableIT_JEOS(ADC_TypeDef *ADCx)
  4311. {
  4312. /* Note: on this STM32 serie, there is no flag ADC group injected */
  4313. /* end of unitary conversion. */
  4314. /* Flag noted as "JEOC" is corresponding to flag "JEOS" */
  4315. /* in other STM32 families). */
  4316. CLEAR_BIT(ADCx->CR1, LL_ADC_IT_JEOS);
  4317. }
  4318. /**
  4319. * @brief Disable interruption ADC analog watchdog 1.
  4320. * @rmtoll CR1 AWDIE LL_ADC_EnableIT_AWD1
  4321. * @param ADCx ADC instance
  4322. * @retval None
  4323. */
  4324. __STATIC_INLINE void LL_ADC_DisableIT_AWD1(ADC_TypeDef *ADCx)
  4325. {
  4326. CLEAR_BIT(ADCx->CR1, LL_ADC_IT_AWD1);
  4327. }
  4328. /**
  4329. * @brief Get state of interruption ADC group regular end of unitary conversion
  4330. * or end of sequence conversions, depending on
  4331. * ADC configuration.
  4332. * @note To configure flag of end of conversion,
  4333. * use function @ref LL_ADC_REG_SetFlagEndOfConversion().
  4334. * (0: interrupt disabled, 1: interrupt enabled)
  4335. * @rmtoll CR1 EOCIE LL_ADC_IsEnabledIT_EOCS
  4336. * @param ADCx ADC instance
  4337. * @retval State of bit (1 or 0).
  4338. */
  4339. __STATIC_INLINE uint32_t LL_ADC_IsEnabledIT_EOCS(ADC_TypeDef *ADCx)
  4340. {
  4341. return (READ_BIT(ADCx->CR1, LL_ADC_IT_EOCS) == (LL_ADC_IT_EOCS));
  4342. }
  4343. /**
  4344. * @brief Get state of interruption ADC group regular overrun
  4345. * (0: interrupt disabled, 1: interrupt enabled).
  4346. * @rmtoll CR1 OVRIE LL_ADC_IsEnabledIT_OVR
  4347. * @param ADCx ADC instance
  4348. * @retval State of bit (1 or 0).
  4349. */
  4350. __STATIC_INLINE uint32_t LL_ADC_IsEnabledIT_OVR(ADC_TypeDef *ADCx)
  4351. {
  4352. return (READ_BIT(ADCx->CR1, LL_ADC_IT_OVR) == (LL_ADC_IT_OVR));
  4353. }
  4354. /**
  4355. * @brief Get state of interruption ADC group injected end of sequence conversions
  4356. * (0: interrupt disabled, 1: interrupt enabled).
  4357. * @rmtoll CR1 JEOCIE LL_ADC_EnableIT_JEOS
  4358. * @param ADCx ADC instance
  4359. * @retval State of bit (1 or 0).
  4360. */
  4361. __STATIC_INLINE uint32_t LL_ADC_IsEnabledIT_JEOS(ADC_TypeDef *ADCx)
  4362. {
  4363. /* Note: on this STM32 serie, there is no flag ADC group injected */
  4364. /* end of unitary conversion. */
  4365. /* Flag noted as "JEOC" is corresponding to flag "JEOS" */
  4366. /* in other STM32 families). */
  4367. return (READ_BIT(ADCx->CR1, LL_ADC_IT_JEOS) == (LL_ADC_IT_JEOS));
  4368. }
  4369. /**
  4370. * @brief Get state of interruption ADC analog watchdog 1
  4371. * (0: interrupt disabled, 1: interrupt enabled).
  4372. * @rmtoll CR1 AWDIE LL_ADC_EnableIT_AWD1
  4373. * @param ADCx ADC instance
  4374. * @retval State of bit (1 or 0).
  4375. */
  4376. __STATIC_INLINE uint32_t LL_ADC_IsEnabledIT_AWD1(ADC_TypeDef *ADCx)
  4377. {
  4378. return (READ_BIT(ADCx->CR1, LL_ADC_IT_AWD1) == (LL_ADC_IT_AWD1));
  4379. }
  4380. /**
  4381. * @}
  4382. */
  4383. #if defined(USE_FULL_LL_DRIVER)
  4384. /** @defgroup ADC_LL_EF_Init Initialization and de-initialization functions
  4385. * @{
  4386. */
  4387. /* Initialization of some features of ADC common parameters and multimode */
  4388. ErrorStatus LL_ADC_CommonDeInit(ADC_Common_TypeDef *ADCxy_COMMON);
  4389. ErrorStatus LL_ADC_CommonInit(ADC_Common_TypeDef *ADCxy_COMMON, LL_ADC_CommonInitTypeDef *ADC_CommonInitStruct);
  4390. void LL_ADC_CommonStructInit(LL_ADC_CommonInitTypeDef *ADC_CommonInitStruct);
  4391. /* De-initialization of ADC instance, ADC group regular and ADC group injected */
  4392. /* (availability of ADC group injected depends on STM32 families) */
  4393. ErrorStatus LL_ADC_DeInit(ADC_TypeDef *ADCx);
  4394. /* Initialization of some features of ADC instance */
  4395. ErrorStatus LL_ADC_Init(ADC_TypeDef *ADCx, LL_ADC_InitTypeDef *ADC_InitStruct);
  4396. void LL_ADC_StructInit(LL_ADC_InitTypeDef *ADC_InitStruct);
  4397. /* Initialization of some features of ADC instance and ADC group regular */
  4398. ErrorStatus LL_ADC_REG_Init(ADC_TypeDef *ADCx, LL_ADC_REG_InitTypeDef *ADC_REG_InitStruct);
  4399. void LL_ADC_REG_StructInit(LL_ADC_REG_InitTypeDef *ADC_REG_InitStruct);
  4400. /* Initialization of some features of ADC instance and ADC group injected */
  4401. ErrorStatus LL_ADC_INJ_Init(ADC_TypeDef *ADCx, LL_ADC_INJ_InitTypeDef *ADC_INJ_InitStruct);
  4402. void LL_ADC_INJ_StructInit(LL_ADC_INJ_InitTypeDef *ADC_INJ_InitStruct);
  4403. /**
  4404. * @}
  4405. */
  4406. #endif /* USE_FULL_LL_DRIVER */
  4407. /**
  4408. * @}
  4409. */
  4410. /**
  4411. * @}
  4412. */
  4413. #endif /* ADC1 || ADC2 || ADC3 */
  4414. /**
  4415. * @}
  4416. */
  4417. #ifdef __cplusplus
  4418. }
  4419. #endif
  4420. #endif /* __STM32F4xx_LL_ADC_H */
  4421. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/