stm32f4xx_ll_adc.h 277 KB

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