stm32f1xx_ll_adc.h 223 KB

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