stm32f1xx_ll_adc.h 224 KB

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