py32f0xx_ll_adc.h 171 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401
  1. /**
  2. ******************************************************************************
  3. * @file py32f0xx_ll_adc.h
  4. * @author MCU Application Team
  5. * @brief Header file of ADC LL module.
  6. ******************************************************************************
  7. * @attention
  8. *
  9. * <h2><center>&copy; Copyright (c) 2023 Puya Semiconductor Co.
  10. * All rights reserved.</center></h2>
  11. *
  12. * This software component is licensed by Puya under BSD 3-Clause license,
  13. * the "License"; You may not use this file except in compliance with the
  14. * License. You may obtain a copy of the License at:
  15. * opensource.org/licenses/BSD-3-Clause
  16. *
  17. ******************************************************************************
  18. * @attention
  19. *
  20. * <h2><center>&copy; Copyright (c) 2016 STMicroelectronics.
  21. * All rights reserved.</center></h2>
  22. *
  23. * This software component is licensed by ST under BSD 3-Clause license,
  24. * the "License"; You may not use this file except in compliance with the
  25. * License. You may obtain a copy of the License at:
  26. * opensource.org/licenses/BSD-3-Clause
  27. *
  28. ******************************************************************************
  29. */
  30. /* Define to prevent recursive inclusion -------------------------------------*/
  31. #ifndef __PY32F0XX_LL_ADC_H
  32. #define __PY32F0XX_LL_ADC_H
  33. #ifdef __cplusplus
  34. extern "C" {
  35. #endif
  36. /* Includes ------------------------------------------------------------------*/
  37. #include "py32f0xx.h"
  38. #include "py32f0xx_ll_bus.h"
  39. /** @addtogroup PY32F0xx_LL_Driver
  40. * @{
  41. */
  42. #if defined (ADC1)
  43. /** @defgroup ADC_LL ADC
  44. * @{
  45. */
  46. /* Private types -------------------------------------------------------------*/
  47. /* Private variables ---------------------------------------------------------*/
  48. /* Private constants ---------------------------------------------------------*/
  49. /** @defgroup ADC_LL_Private_Constants ADC Private Constants
  50. * @{
  51. */
  52. /* Internal mask for ADC group regular trigger: */
  53. /* To select into literal LL_ADC_REG_TRIG_x the relevant bits for: */
  54. /* - regular trigger source */
  55. /* - regular trigger edge */
  56. #define ADC_REG_TRIG_EXT_EDGE_DEFAULT (ADC_CFGR1_EXTEN_0) /* Trigger edge set to rising edge (default setting for compatibility with some ADC on other PY32 families having this setting set by HW default value) */
  57. /* Mask containing trigger source masks for each of possible */
  58. /* trigger edge selection duplicated with shifts [0; 4; 8; 12] */
  59. /* corresponding to {SW start; ext trigger; ext trigger; ext trigger}. */
  60. #define ADC_REG_TRIG_SOURCE_MASK (((LL_ADC_REG_TRIG_SOFTWARE & ADC_CFGR1_EXTSEL) << (4U * 0U)) | \
  61. (( ADC_CFGR1_EXTSEL) << (4U * 1U)) | \
  62. (( ADC_CFGR1_EXTSEL) << (4U * 2U)) | \
  63. (( ADC_CFGR1_EXTSEL) << (4U * 3U)) )
  64. /* Mask containing trigger edge masks for each of possible */
  65. /* trigger edge selection duplicated with shifts [0; 4; 8; 12] */
  66. /* corresponding to {SW start; ext trigger; ext trigger; ext trigger}. */
  67. #define ADC_REG_TRIG_EDGE_MASK (((LL_ADC_REG_TRIG_SOFTWARE & ADC_CFGR1_EXTEN) << (4U * 0U)) | \
  68. ((ADC_REG_TRIG_EXT_EDGE_DEFAULT) << (4U * 1U)) | \
  69. ((ADC_REG_TRIG_EXT_EDGE_DEFAULT) << (4U * 2U)) | \
  70. ((ADC_REG_TRIG_EXT_EDGE_DEFAULT) << (4U * 3U)) )
  71. /* Definition of ADC group regular trigger bits information. */
  72. #define ADC_REG_TRIG_EXTSEL_BITOFFSET_POS ( 6U) /* Value equivalent to POSITION_VAL(ADC_CFGR1_EXTSEL) */
  73. #define ADC_REG_TRIG_EXTEN_BITOFFSET_POS (10U) /* Value equivalent to POSITION_VAL(ADC_CFGR1_EXTEN) */
  74. /* Internal mask for ADC channel: */
  75. /* To select into literal LL_ADC_CHANNEL_x the relevant bits for: */
  76. /* - channel identifier defined by number */
  77. /* - channel identifier defined by bitfield */
  78. /* - channel differentiation between external channels (connected to */
  79. /* GPIO pins) and internal channels (connected to internal paths) */
  80. #define ADC_CHANNEL_ID_NUMBER_MASK (ADC_CFGR1_AWDCH)
  81. #define ADC_CHANNEL_ID_BITFIELD_MASK (ADC_CHSELR_CHSEL)
  82. #define ADC_CHANNEL_ID_NUMBER_BITOFFSET_POS (26U)/* Value equivalent to POSITION_VAL(ADC_CHANNEL_ID_NUMBER_MASK) */
  83. #define ADC_CHANNEL_ID_MASK (ADC_CHANNEL_ID_NUMBER_MASK | ADC_CHANNEL_ID_BITFIELD_MASK | ADC_CHANNEL_ID_INTERNAL_CH_MASK)
  84. /* Equivalent mask of ADC_CHANNEL_NUMBER_MASK aligned on register LSB (bit 0) */
  85. #define ADC_CHANNEL_ID_NUMBER_MASK_POSBIT0 (0x0000001FU) /* Equivalent to shift: (ADC_CHANNEL_NUMBER_MASK >> POSITION_VAL(ADC_CHANNEL_NUMBER_MASK)) */
  86. /* Channel differentiation between external and internal channels */
  87. #define ADC_CHANNEL_ID_INTERNAL_CH (0x80000000U) /* Marker of internal channel */
  88. #define ADC_CHANNEL_ID_INTERNAL_CH_MASK (ADC_CHANNEL_ID_INTERNAL_CH)
  89. /* Definition of channels ID number information to be inserted into */
  90. /* channels literals definition. */
  91. #define ADC_CHANNEL_0_NUMBER (0x00000000U)
  92. #define ADC_CHANNEL_1_NUMBER ( ADC_CFGR1_AWDCH_0)
  93. #define ADC_CHANNEL_2_NUMBER ( ADC_CFGR1_AWDCH_1 )
  94. #define ADC_CHANNEL_3_NUMBER ( ADC_CFGR1_AWDCH_1 | ADC_CFGR1_AWDCH_0)
  95. #define ADC_CHANNEL_4_NUMBER ( ADC_CFGR1_AWDCH_2 )
  96. #define ADC_CHANNEL_5_NUMBER ( ADC_CFGR1_AWDCH_2 | ADC_CFGR1_AWDCH_0)
  97. #define ADC_CHANNEL_6_NUMBER ( ADC_CFGR1_AWDCH_2 | ADC_CFGR1_AWDCH_1 )
  98. #define ADC_CHANNEL_7_NUMBER ( ADC_CFGR1_AWDCH_2 | ADC_CFGR1_AWDCH_1 | ADC_CFGR1_AWDCH_0)
  99. #define ADC_CHANNEL_8_NUMBER (ADC_CFGR1_AWDCH_3 )
  100. #define ADC_CHANNEL_9_NUMBER (ADC_CFGR1_AWDCH_3 | ADC_CFGR1_AWDCH_0)
  101. #define ADC_CHANNEL_11_NUMBER (ADC_CFGR1_AWDCH_3 | ADC_CFGR1_AWDCH_1 | ADC_CFGR1_AWDCH_0)
  102. #define ADC_CHANNEL_12_NUMBER (ADC_CFGR1_AWDCH_3 | ADC_CFGR1_AWDCH_2 )
  103. /* Definition of channels ID bitfield information to be inserted into */
  104. /* channels literals definition. */
  105. #define ADC_CHANNEL_0_BITFIELD (ADC_CHSELR_CHSEL0)
  106. #define ADC_CHANNEL_1_BITFIELD (ADC_CHSELR_CHSEL1)
  107. #define ADC_CHANNEL_2_BITFIELD (ADC_CHSELR_CHSEL2)
  108. #define ADC_CHANNEL_3_BITFIELD (ADC_CHSELR_CHSEL3)
  109. #define ADC_CHANNEL_4_BITFIELD (ADC_CHSELR_CHSEL4)
  110. #define ADC_CHANNEL_5_BITFIELD (ADC_CHSELR_CHSEL5)
  111. #define ADC_CHANNEL_6_BITFIELD (ADC_CHSELR_CHSEL6)
  112. #define ADC_CHANNEL_7_BITFIELD (ADC_CHSELR_CHSEL7)
  113. #define ADC_CHANNEL_8_BITFIELD (ADC_CHSELR_CHSEL8)
  114. #define ADC_CHANNEL_9_BITFIELD (ADC_CHSELR_CHSEL9)
  115. #define ADC_CHANNEL_11_BITFIELD (ADC_CHSELR_CHSEL11)
  116. #define ADC_CHANNEL_12_BITFIELD (ADC_CHSELR_CHSEL12)
  117. /* Internal mask for ADC analog watchdog: */
  118. /* To select into literals LL_ADC_AWD_CHANNELx_xxx the relevant bits for: */
  119. /* - analog watchdog 1: monitored channel defined by number, */
  120. /* selection of ADC group (ADC group regular). */
  121. /* Internal register offset for ADC analog watchdog channel configuration */
  122. #define ADC_AWD_CR1_REGOFFSET (0x00000000U)
  123. #define ADC_AWD_CRX_REGOFFSET_MASK (ADC_AWD_CR1_REGOFFSET)
  124. #define ADC_AWD_CR1_CHANNEL_MASK (ADC_CFGR1_AWDCH | ADC_CFGR1_AWDEN | ADC_CFGR1_AWDSGL)
  125. #define ADC_AWD_CR_ALL_CHANNEL_MASK (ADC_AWD_CR1_CHANNEL_MASK)
  126. /* Internal register offset for ADC analog watchdog threshold configuration */
  127. #define ADC_AWD_TR1_REGOFFSET (ADC_AWD_CR1_REGOFFSET)
  128. #define ADC_AWD_TRX_REGOFFSET_MASK (ADC_AWD_TR1_REGOFFSET)
  129. /* ADC registers bits positions */
  130. #define ADC_CFGR1_RES_BITOFFSET_POS ( 3U) /* Value equivalent to POSITION_VAL(ADC_CFGR1_RESSEL) */
  131. #define ADC_CFGR1_AWDSGL_BITOFFSET_POS (22U) /* Value equivalent to POSITION_VAL(ADC_CFGR1_AWDSGL) */
  132. #define ADC_TR_HT_BITOFFSET_POS (16U) /* Value equivalent to POSITION_VAL(ADC_TR_HT) */
  133. #define ADC_CHSELR_CHSEL0_BITOFFSET_POS ( 0U) /* Value equivalent to POSITION_VAL(ADC_CHSELR_CHSEL0) */
  134. #define ADC_CHSELR_CHSEL1_BITOFFSET_POS ( 1U) /* Value equivalent to POSITION_VAL(ADC_CHSELR_CHSEL1) */
  135. #define ADC_CHSELR_CHSEL2_BITOFFSET_POS ( 2U) /* Value equivalent to POSITION_VAL(ADC_CHSELR_CHSEL2) */
  136. #define ADC_CHSELR_CHSEL3_BITOFFSET_POS ( 3U) /* Value equivalent to POSITION_VAL(ADC_CHSELR_CHSEL3) */
  137. #define ADC_CHSELR_CHSEL4_BITOFFSET_POS ( 4U) /* Value equivalent to POSITION_VAL(ADC_CHSELR_CHSEL4) */
  138. #define ADC_CHSELR_CHSEL5_BITOFFSET_POS ( 5U) /* Value equivalent to POSITION_VAL(ADC_CHSELR_CHSEL5) */
  139. #define ADC_CHSELR_CHSEL6_BITOFFSET_POS ( 6U) /* Value equivalent to POSITION_VAL(ADC_CHSELR_CHSEL6) */
  140. #define ADC_CHSELR_CHSEL7_BITOFFSET_POS ( 7U) /* Value equivalent to POSITION_VAL(ADC_CHSELR_CHSEL7) */
  141. #define ADC_CHSELR_CHSEL8_BITOFFSET_POS ( 8U) /* Value equivalent to POSITION_VAL(ADC_CHSELR_CHSEL8) */
  142. #define ADC_CHSELR_CHSEL9_BITOFFSET_POS ( 9U) /* Value equivalent to POSITION_VAL(ADC_CHSELR_CHSEL9) */
  143. #define ADC_CHSELR_CHSEL11_BITOFFSET_POS (11U) /* Value equivalent to POSITION_VAL(ADC_CHSELR_CHSEL11) */
  144. #define ADC_CHSELR_CHSEL12_BITOFFSET_POS (12U) /* Value equivalent to POSITION_VAL(ADC_CHSELR_CHSEL12) */
  145. /* ADC registers bits groups */
  146. #define ADC_CR_BITS_PROPERTY_RS (ADC_CR_ADCAL | ADC_CR_ADSTP | ADC_CR_ADSTART | ADC_CR_ADEN) /* ADC register CR bits with HW property "rs": Software can read as well as set this bit. Writing '0' has no effect on the bit value. */
  147. /* ADC internal channels related definitions */
  148. /* Internal voltage reference VrefInt */
  149. #define VREFINT_CAL_VREF ( 1200U) /* Analog voltage reference (Vref+) value (tolerance: +-10 mV) (unit: mV). */
  150. /* Temperature sensor */
  151. #define TEMPSENSOR_CAL1_ADDR ((uint16_t*) (0x1fff0f14)) /* Internal temperature sensor, address of parameter TS_CAL1: On PY32F0, temperature sensor ADC raw data acquired at temperature 30 DegC (tolerance: +-5 DegC), Vref+ = 3.3 V (tolerance: +-10 mV). */
  152. #define TEMPSENSOR_CAL2_ADDR ((uint16_t*) (0x1fff0f18)) /* Internal temperature sensor, address of parameter TS_CAL2: On PY32F0, temperature sensor ADC raw data acquired at temperature 85 or 105 DegC (tolerance: +-5 DegC), Vref+ = 3.3 V (tolerance: +-10 mV). */
  153. #define TEMPSENSOR_CAL1_TEMP (( int32_t) 30) /* Internal temperature sensor, temperature at which temperature sensor has been calibrated in production for data into TEMPSENSOR_CAL1_ADDR (tolerance: +-5 DegC) (unit: DegC). */
  154. #define TEMPSENSOR_CAL2_TEMP (( int32_t) 85) /* Internal temperature sensor, temperature at which temperature sensor has been calibrated in production for data into TEMPSENSOR_CAL2_ADDR (tolerance: +-5 DegC) (unit: DegC). */
  155. #define TEMPSENSOR_CAL3_TEMP (( int32_t) 105) /* Internal temperature sensor, temperature at which temperature sensor has been calibrated in production for data into TEMPSENSOR_CAL2_ADDR (tolerance: +-5 DegC) (unit: DegC). */
  156. #define TEMPSENSOR_CAL_VREFANALOG ( 3300U) /* Analog voltage reference (Vref+) voltage with which temperature sensor has been calibrated in production (+-10 mV) (unit: mV). */
  157. /* Definitions of ADC hardware constraints delays */
  158. /* Note: Only ADC IP HW delays are defined in ADC LL driver driver, */
  159. /* not timeout values: */
  160. /* Timeout values for ADC operations are dependent to device clock */
  161. /* configuration (system clock versus ADC clock), */
  162. /* and therefore must be defined in user application. */
  163. /* Refer to @ref ADC_LL_EC_HW_DELAYS for description of ADC timeout */
  164. /* values definition. */
  165. /* Unit: CPU cycles. */
  166. #define LL_ADC_CLOCK_RATIO_VS_CPU_HIGHEST ((uint32_t) 512U * 16U * 4U)
  167. #define LL_ADC_TIMEOUT_DISABLE_CPU_CYCLES (LL_ADC_CLOCK_RATIO_VS_CPU_HIGHEST * 1U)
  168. #define LL_ADC_TIMEOUT_STOP_CONVERSION_CPU_CYCLES (LL_ADC_CLOCK_RATIO_VS_CPU_HIGHEST * 1U)
  169. /**
  170. * @}
  171. */
  172. /* Exported types ------------------------------------------------------------*/
  173. #if defined(USE_FULL_LL_DRIVER)
  174. /** @defgroup ADC_LL_ES_INIT ADC Exported Init structure
  175. * @{
  176. */
  177. /**
  178. * @brief Structure definition of some features of ADC instance.
  179. * @note These parameters have an impact on ADC scope: ADC instance.
  180. * Refer to corresponding unitary functions into
  181. * @ref ADC_LL_EF_Configuration_ADC_Instance .
  182. * @note The setting of these parameters by function @ref LL_ADC_Init()
  183. * is conditioned to ADC state:
  184. * ADC instance must be disabled.
  185. * This condition is applied to all ADC features, for efficiency
  186. * and compatibility over all PY32 families. However, the different
  187. * features can be set under different ADC state conditions
  188. * (setting possible with ADC enabled without conversion on going,
  189. * ADC enabled with conversion on going, ...)
  190. * Each feature can be updated afterwards with a unitary function
  191. * and potentially with ADC in a different state than disabled,
  192. * refer to description of each function for setting
  193. * conditioned to ADC state.
  194. */
  195. typedef struct
  196. {
  197. uint32_t Clock; /*!< Set ADC instance clock source and prescaler.
  198. This parameter can be a value of @ref ADC_LL_EC_CLOCK_SOURCE
  199. @note On this PY32 serie, this parameter has some clock ratio constraints:
  200. Note: In case of usage of the ADC dedicated HSI RC oscillator, it must be preliminarily enabled at RCC top level.
  201. Note: This parameter can be modified only if the ADC is disabled
  202. This feature can be modified afterwards using unitary function @ref LL_ADC_SetClock().
  203. For more details, refer to description of this function. */
  204. uint32_t Resolution; /*!< Set ADC resolution.
  205. This parameter can be a value of @ref ADC_LL_EC_RESOLUTION
  206. This feature can be modified afterwards using unitary function @ref LL_ADC_SetResolution(). */
  207. uint32_t DataAlignment; /*!< Set ADC conversion data alignment.
  208. This parameter can be a value of @ref ADC_LL_EC_DATA_ALIGN
  209. This feature can be modified afterwards using unitary function @ref LL_ADC_SetDataAlignment(). */
  210. uint32_t LowPowerMode; /*!< Set ADC low power mode.
  211. This parameter can be a value of @ref ADC_LL_EC_LP_MODE
  212. This feature can be modified afterwards using unitary function @ref LL_ADC_SetLowPowerMode(). */
  213. } LL_ADC_InitTypeDef;
  214. /**
  215. * @brief Structure definition of some features of ADC group regular.
  216. * @note These parameters have an impact on ADC scope: ADC group regular.
  217. * Refer to corresponding unitary functions into
  218. * @ref ADC_LL_EF_Configuration_ADC_Group_Regular
  219. * (functions with prefix "REG").
  220. * @note The setting of these parameters by function @ref LL_ADC_REG_Init()
  221. * is conditioned to ADC state:
  222. * ADC instance must be disabled.
  223. * This condition is applied to all ADC features, for efficiency
  224. * and compatibility over all PY32 families. However, the different
  225. * features can be set under different ADC state conditions
  226. * (setting possible with ADC enabled without conversion on going,
  227. * ADC enabled with conversion on going, ...)
  228. * Each feature can be updated afterwards with a unitary function
  229. * and potentially with ADC in a different state than disabled,
  230. * refer to description of each function for setting
  231. * conditioned to ADC state.
  232. * @note Depending on devices and packages, DMA may not be available.
  233. * Refer to device datasheet for DMA availability.
  234. */
  235. typedef struct
  236. {
  237. uint32_t TriggerSource; /*!< Set ADC group regular conversion trigger source: internal (SW start) or from external IP (timer event).
  238. This parameter can be a value of @ref ADC_LL_EC_REG_TRIGGER_SOURCE
  239. @note On this PY32 serie, setting trigger source to external trigger also set trigger polarity to rising edge
  240. (default setting for compatibility with some ADC on other PY32 families having this setting set by HW default value).
  241. In case of need to modify trigger edge, use function @ref LL_ADC_REG_SetTriggerEdge().
  242. This feature can be modified afterwards using unitary function @ref LL_ADC_REG_SetTriggerSource(). */
  243. uint32_t SequencerDiscont; /*!< Set ADC group regular sequencer discontinuous mode: sequence subdivided and scan conversions interrupted every selected number of ranks.
  244. This parameter can be a value of @ref ADC_LL_EC_REG_SEQ_DISCONT_MODE
  245. @note This parameter has an effect only if group regular sequencer is enabled
  246. (several ADC channels enabled in group regular sequencer).
  247. This feature can be modified afterwards using unitary function @ref LL_ADC_REG_SetSequencerDiscont(). */
  248. 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).
  249. This parameter can be a value of @ref ADC_LL_EC_REG_CONTINUOUS_MODE
  250. Note: It is not possible to enable both ADC group regular continuous mode and discontinuous mode.
  251. This feature can be modified afterwards using unitary function @ref LL_ADC_REG_SetContinuousMode(). */
  252. #if (defined(DMA) || defined(DMA1))
  253. uint32_t DMATransfer; /*!< Set ADC group regular conversion data transfer: no transfer or transfer by DMA, and DMA requests mode.
  254. This parameter can be a value of @ref ADC_LL_EC_REG_DMA_TRANSFER
  255. This feature can be modified afterwards using unitary function @ref LL_ADC_REG_SetDMATransfer(). */
  256. #endif
  257. uint32_t Overrun; /*!< Set ADC group regular behavior in case of overrun:
  258. data preserved or overwritten.
  259. This parameter can be a value of @ref ADC_LL_EC_REG_OVR_DATA_BEHAVIOR
  260. This feature can be modified afterwards using unitary function @ref LL_ADC_REG_SetOverrun(). */
  261. } LL_ADC_REG_InitTypeDef;
  262. /**
  263. * @}
  264. */
  265. #endif /* USE_FULL_LL_DRIVER */
  266. /* Exported constants --------------------------------------------------------*/
  267. /** @defgroup ADC_LL_Exported_Constants ADC Exported Constants
  268. * @{
  269. */
  270. /** @defgroup ADC_LL_EC_FLAG ADC flags
  271. * @brief Flags defines which can be used with LL_ADC_ReadReg function
  272. * @{
  273. */
  274. #define LL_ADC_FLAG_EOC ADC_ISR_EOC /*!< ADC flag ADC group regular end of unitary conversion */
  275. #define LL_ADC_FLAG_EOS ADC_ISR_EOSEQ /*!< ADC flag ADC group regular end of sequence conversions */
  276. #define LL_ADC_FLAG_OVR ADC_ISR_OVR /*!< ADC flag ADC group regular overrun */
  277. #define LL_ADC_FLAG_EOSMP ADC_ISR_EOSMP /*!< ADC flag ADC group regular end of sampling phase */
  278. #define LL_ADC_FLAG_AWD ADC_ISR_AWD /*!< ADC flag ADC analog watchdog 1 */
  279. /**
  280. * @}
  281. */
  282. /** @defgroup ADC_LL_EC_IT ADC interruptions for configuration (interruption enable or disable)
  283. * @brief IT defines which can be used with LL_ADC_ReadReg and LL_ADC_WriteReg functions
  284. * @{
  285. */
  286. #define LL_ADC_IT_EOC ADC_IER_EOCIE /*!< ADC interruption ADC group regular end of unitary conversion */
  287. #define LL_ADC_IT_EOS ADC_IER_EOSEQIE /*!< ADC interruption ADC group regular end of sequence conversions */
  288. #define LL_ADC_IT_OVR ADC_IER_OVRIE /*!< ADC interruption ADC group regular overrun */
  289. #define LL_ADC_IT_EOSMP ADC_IER_EOSMPIE /*!< ADC interruption ADC group regular end of sampling phase */
  290. #define LL_ADC_IT_AWD ADC_IER_AWDIE /*!< ADC interruption ADC analog watchdog 1 */
  291. /**
  292. * @}
  293. */
  294. /** @defgroup ADC_LL_EC_REGISTERS ADC registers compliant with specific purpose
  295. * @{
  296. */
  297. /* List of ADC registers intended to be used (most commonly) with */
  298. /* DMA transfer. */
  299. /* Refer to function @ref LL_ADC_DMA_GetRegAddr(). */
  300. #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() */
  301. /**
  302. * @}
  303. */
  304. /** @defgroup ADC_LL_EC_COMMON_PATH_INTERNAL ADC common - Measurement path to internal channels
  305. * @{
  306. */
  307. /* Note: Other measurement paths to internal channels may be available */
  308. /* (connections to other peripherals). */
  309. /* If they are not listed below, they do not require any specific */
  310. /* path enable. In this case, Access to measurement path is done */
  311. /* only by selecting the corresponding ADC internal channel. */
  312. #define LL_ADC_PATH_INTERNAL_NONE (0x00000000U) /*!< ADC measurement pathes all disabled */
  313. #define LL_ADC_PATH_INTERNAL_VREFINT (ADC_CCR_VREFEN) /*!< ADC measurement path to internal channel VrefInt */
  314. #define LL_ADC_PATH_INTERNAL_TEMPSENSOR (ADC_CCR_TSEN) /*!< ADC measurement path to internal channel temperature sensor */
  315. /**
  316. * @}
  317. */
  318. /** @defgroup ADC_LL_EC_CLOCK_SOURCE ADC instance - Clock source
  319. * @{
  320. */
  321. #define LL_ADC_CLOCK_SYNC_PCLK_DIV1 (0x00000000U) /*!< ADC synchronous clock derived from APB clock divided by a prescaler of 1 */
  322. #define LL_ADC_CLOCK_SYNC_PCLK_DIV2 (ADC_CFGR2_CKMODE_0 ) /*!< ADC synchronous clock derived from APB clock divided by a prescaler of 2 */
  323. #define LL_ADC_CLOCK_SYNC_PCLK_DIV4 ( ADC_CFGR2_CKMODE_1 ) /*!< ADC synchronous clock derived from APB clock divided by a prescaler of 4 */
  324. #define LL_ADC_CLOCK_SYNC_PCLK_DIV8 (ADC_CFGR2_CKMODE_0 | ADC_CFGR2_CKMODE_1 ) /*!< ADC synchronous clock derived from APB clock divided by a prescaler of 8 */
  325. #define LL_ADC_CLOCK_SYNC_PCLK_DIV16 ( ADC_CFGR2_CKMODE_2 ) /*!< ADC synchronous clock derived from APB clock divided by a prescaler of 16 */
  326. #define LL_ADC_CLOCK_SYNC_PCLK_DIV32 (ADC_CFGR2_CKMODE_0 | ADC_CFGR2_CKMODE_2 ) /*!< ADC synchronous clock derived from APB clock divided by a prescaler of 32 */
  327. #define LL_ADC_CLOCK_SYNC_PCLK_DIV64 ( ADC_CFGR2_CKMODE_1 | ADC_CFGR2_CKMODE_2 ) /*!< ADC synchronous clock derived from APB clock divided by a prescaler of 64 */
  328. #define LL_ADC_CLOCK_ASYNC_HSI_DIV1 ( ADC_CFGR2_CKMODE_3) /*!< ADC asynchronous clock derived from HSI clock divided by a prescaler of 1 */
  329. #define LL_ADC_CLOCK_ASYNC_HSI_DIV2 (ADC_CFGR2_CKMODE_0 | ADC_CFGR2_CKMODE_3) /*!< ADC asynchronous clock derived from HSI clock divided by a prescaler of 2 */
  330. #define LL_ADC_CLOCK_ASYNC_HSI_DIV4 ( ADC_CFGR2_CKMODE_1 | ADC_CFGR2_CKMODE_3) /*!< ADC asynchronous clock derived from HSI clock divided by a prescaler of 4 */
  331. #define LL_ADC_CLOCK_ASYNC_HSI_DIV8 (ADC_CFGR2_CKMODE_0 | ADC_CFGR2_CKMODE_1 | ADC_CFGR2_CKMODE_3) /*!< ADC asynchronous clock derived from HSI clock divided by a prescaler of 8 */
  332. #define LL_ADC_CLOCK_ASYNC_HSI_DIV16 ( ADC_CFGR2_CKMODE_2 | ADC_CFGR2_CKMODE_3) /*!< ADC asynchronous clock derived from HSI clock divided by a prescaler of 16 */
  333. #define LL_ADC_CLOCK_ASYNC_HSI_DIV32 (ADC_CFGR2_CKMODE_0 | ADC_CFGR2_CKMODE_2 | ADC_CFGR2_CKMODE_3) /*!< ADC asynchronous clock derived from HSI clock divided by a prescaler of 32 */
  334. #define LL_ADC_CLOCK_ASYNC_HSI_DIV64 ( ADC_CFGR2_CKMODE_1 | ADC_CFGR2_CKMODE_2 | ADC_CFGR2_CKMODE_3) /*!< ADC asynchronous clock derived from HSI clock divided by a prescaler of 64 */
  335. /**
  336. * @}
  337. */
  338. /** @defgroup ADC_LL_EC_RESOLUTION ADC instance - Resolution
  339. * @{
  340. */
  341. #define LL_ADC_RESOLUTION_12B (0x00000000U) /*!< ADC resolution 12 bits */
  342. #define LL_ADC_RESOLUTION_10B (ADC_CFGR1_RESSEL_0) /*!< ADC resolution 10 bits */
  343. #define LL_ADC_RESOLUTION_8B (ADC_CFGR1_RESSEL_1) /*!< ADC resolution 8 bits */
  344. #define LL_ADC_RESOLUTION_6B (ADC_CFGR1_RESSEL_1 | ADC_CFGR1_RESSEL_0) /*!< ADC resolution 6 bits */
  345. /**
  346. * @}
  347. */
  348. /** @defgroup ADC_LL_EC_DATA_ALIGN ADC instance - Data alignment
  349. * @{
  350. */
  351. #define LL_ADC_DATA_ALIGN_RIGHT (0x00000000U) /*!< ADC conversion data alignment: right aligned (alignment on data register LSB bit 0)*/
  352. #define LL_ADC_DATA_ALIGN_LEFT (ADC_CFGR1_ALIGN) /*!< ADC conversion data alignment: left aligned (aligment on data register MSB bit 15)*/
  353. /**
  354. * @}
  355. */
  356. /** @defgroup ADC_LL_EC_LP_MODE ADC instance - Low power mode
  357. * @{
  358. */
  359. #define LL_ADC_LP_MODE_NONE (0x00000000U) /*!< No ADC low power mode activated */
  360. #define LL_ADC_LP_AUTOWAIT (ADC_CFGR1_WAIT) /*!< ADC low power mode auto delay: Dynamic low power mode, ADC conversions are performed only when necessary (when previous ADC conversion data is read). See description with function @ref LL_ADC_SetLowPowerMode(). */
  361. /**
  362. * @}
  363. */
  364. /** @defgroup ADC_LL_EC_GROUPS ADC instance - Groups
  365. * @{
  366. */
  367. #define LL_ADC_GROUP_REGULAR (0x00000001U) /*!< ADC group regular (available on all PY32 devices) */
  368. /**
  369. * @}
  370. */
  371. /** @defgroup ADC_LL_EC_CHANNEL ADC instance - Channel number
  372. * @{
  373. */
  374. #define LL_ADC_CHANNEL_0 (ADC_CHANNEL_0_NUMBER | ADC_CHANNEL_0_BITFIELD ) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN0 */
  375. #define LL_ADC_CHANNEL_1 (ADC_CHANNEL_1_NUMBER | ADC_CHANNEL_1_BITFIELD ) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN1 */
  376. #define LL_ADC_CHANNEL_2 (ADC_CHANNEL_2_NUMBER | ADC_CHANNEL_2_BITFIELD ) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN2 */
  377. #define LL_ADC_CHANNEL_3 (ADC_CHANNEL_3_NUMBER | ADC_CHANNEL_3_BITFIELD ) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN3 */
  378. #define LL_ADC_CHANNEL_4 (ADC_CHANNEL_4_NUMBER | ADC_CHANNEL_4_BITFIELD ) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN4 */
  379. #define LL_ADC_CHANNEL_5 (ADC_CHANNEL_5_NUMBER | ADC_CHANNEL_5_BITFIELD ) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN5 */
  380. #define LL_ADC_CHANNEL_6 (ADC_CHANNEL_6_NUMBER | ADC_CHANNEL_6_BITFIELD ) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN6 */
  381. #define LL_ADC_CHANNEL_7 (ADC_CHANNEL_7_NUMBER | ADC_CHANNEL_7_BITFIELD ) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN7 */
  382. #define LL_ADC_CHANNEL_8 (ADC_CHANNEL_8_NUMBER | ADC_CHANNEL_8_BITFIELD ) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN8 */
  383. #define LL_ADC_CHANNEL_9 (ADC_CHANNEL_9_NUMBER | ADC_CHANNEL_9_BITFIELD ) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN9 */
  384. #define LL_ADC_CHANNEL_11 (ADC_CHANNEL_11_NUMBER | ADC_CHANNEL_11_BITFIELD) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN11 */
  385. #define LL_ADC_CHANNEL_12 (ADC_CHANNEL_12_NUMBER | ADC_CHANNEL_12_BITFIELD) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN12 */
  386. #define LL_ADC_CHANNEL_VREFINT (LL_ADC_CHANNEL_12 | ADC_CHANNEL_ID_INTERNAL_CH) /*!< ADC internal channel connected to VrefInt: Internal voltage reference. */
  387. #define LL_ADC_CHANNEL_TEMPSENSOR (LL_ADC_CHANNEL_11 | ADC_CHANNEL_ID_INTERNAL_CH) /*!< ADC internal channel connected to Temperature sensor. */
  388. /**
  389. * @}
  390. */
  391. /** @defgroup ADC_LL_EC_REG_TRIGGER_SOURCE ADC group regular - Trigger source
  392. * @{
  393. */
  394. #define LL_ADC_REG_TRIG_SOFTWARE (0x00000000U) /*!< ADC group regular conversion trigger internal: SW start. */
  395. #define LL_ADC_REG_TRIG_EXT_TIM1_TRGO ( ADC_REG_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group regular conversion trigger from external IP: TIM1 TRGO. Trigger edge set to rising edge (default setting). */
  396. #define LL_ADC_REG_TRIG_EXT_TIM1_CH4 ( ADC_CFGR1_EXTSEL_0 | ADC_REG_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group regular conversion trigger from external IP: TIM1 channel 4 event (capture compare: input capture or output capture). Trigger edge set to rising edge (default setting). */
  397. #define LL_ADC_REG_TRIG_EXT_TIM3_TRGO (ADC_CFGR1_EXTSEL_1 | ADC_CFGR1_EXTSEL_0 | ADC_REG_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group regular conversion trigger from external IP: TIM3 TRGO. Trigger edge set to rising edge (default setting). */
  398. /**
  399. * @}
  400. */
  401. /** @defgroup ADC_LL_EC_REG_TRIGGER_EDGE ADC group regular - Trigger edge
  402. * @{
  403. */
  404. #define LL_ADC_REG_TRIG_EXT_RISING ( ADC_CFGR1_EXTEN_0) /*!< ADC group regular conversion trigger polarity set to rising edge */
  405. #define LL_ADC_REG_TRIG_EXT_FALLING (ADC_CFGR1_EXTEN_1 ) /*!< ADC group regular conversion trigger polarity set to falling edge */
  406. #define LL_ADC_REG_TRIG_EXT_RISINGFALLING (ADC_CFGR1_EXTEN_1 | ADC_CFGR1_EXTEN_0) /*!< ADC group regular conversion trigger polarity set to both rising and falling edges */
  407. /**
  408. * @}
  409. */
  410. /** @defgroup ADC_LL_EC_REG_CONTINUOUS_MODE ADC group regular - Continuous mode
  411. * @{
  412. */
  413. #define LL_ADC_REG_CONV_SINGLE (0x00000000U) /*!< ADC conversions are performed in single mode: one conversion per trigger */
  414. #define LL_ADC_REG_CONV_CONTINUOUS (ADC_CFGR1_CONT) /*!< ADC conversions are performed in continuous mode: after the first trigger, following conversions launched successively automatically */
  415. /**
  416. * @}
  417. */
  418. #if (defined(DMA) || defined(DMA1))
  419. /** @defgroup ADC_LL_EC_REG_DMA_TRANSFER ADC group regular - DMA transfer of ADC conversion data
  420. * @{
  421. */
  422. #define LL_ADC_REG_DMA_TRANSFER_NONE (0x00000000U) /*!< ADC conversions are not transferred by DMA */
  423. #define LL_ADC_REG_DMA_TRANSFER_LIMITED ( ADC_CFGR1_DMAEN) /*!< ADC conversion data are transferred by DMA, in limited mode (one shot mode): DMA transfer requests are stopped when number of DMA data transfers (number of ADC conversions) is reached. This ADC mode is intended to be used with DMA mode non-circular. */
  424. #define LL_ADC_REG_DMA_TRANSFER_UNLIMITED (ADC_CFGR1_DMACFG | ADC_CFGR1_DMAEN) /*!< ADC conversion data are transferred by DMA, in unlimited mode: DMA transfer requests are unlimited, whatever number of DMA data transferred (number of ADC conversions). This ADC mode is intended to be used with DMA mode circular. */
  425. /**
  426. * @}
  427. */
  428. #endif
  429. /** @defgroup ADC_LL_EC_REG_OVR_DATA_BEHAVIOR ADC group regular - Overrun behavior on conversion data
  430. * @{
  431. */
  432. #define LL_ADC_REG_OVR_DATA_PRESERVED (0x00000000U) /*!< ADC group regular behavior in case of overrun: data preserved */
  433. #define LL_ADC_REG_OVR_DATA_OVERWRITTEN (ADC_CFGR1_OVRMOD) /*!< ADC group regular behavior in case of overrun: data overwritten */
  434. /**
  435. * @}
  436. */
  437. /** @defgroup ADC_LL_EC_REG_SEQ_SCAN_DIRECTION ADC group regular - Sequencer scan direction
  438. * @{
  439. */
  440. #define LL_ADC_REG_SEQ_SCAN_DIR_FORWARD (0x00000000U) /*!< ADC group regular sequencer scan direction forward: from lowest channel number to highest channel number (scan of all ranks, ADC conversion of ranks with channels enabled in sequencer). On some other PY32 families, this setting is not available and the default scan direction is forward. */
  441. #define LL_ADC_REG_SEQ_SCAN_DIR_BACKWARD (ADC_CFGR1_SCANDIR) /*!< ADC group regular sequencer scan direction backward: from highest channel number to lowest channel number (scan of all ranks, ADC conversion of ranks with channels enabled in sequencer) */
  442. /**
  443. * @}
  444. */
  445. /** @defgroup ADC_LL_EC_REG_SEQ_DISCONT_MODE ADC group regular - Sequencer discontinuous mode
  446. * @{
  447. */
  448. #define LL_ADC_REG_SEQ_DISCONT_DISABLE (0x00000000U) /*!< ADC group regular sequencer discontinuous mode disable */
  449. #define LL_ADC_REG_SEQ_DISCONT_1RANK (ADC_CFGR1_DISCEN) /*!< ADC group regular sequencer discontinuous mode enable with sequence interruption every rank */
  450. /**
  451. * @}
  452. */
  453. /** @defgroup ADC_LL_EC_CHANNEL_SAMPLINGTIME Channel - Sampling time
  454. * @{
  455. */
  456. #define LL_ADC_SAMPLINGTIME_3CYCLES_5 (0x00000000U) /*!< Sampling time 3.5 ADC clock cycles */
  457. #define LL_ADC_SAMPLINGTIME_5CYCLES_5 ( ADC_SMPR_SMP_0) /*!< Sampling time 5.5 ADC clock cycles */
  458. #define LL_ADC_SAMPLINGTIME_7CYCLES_5 ( ADC_SMPR_SMP_1 ) /*!< Sampling time 7.5 ADC clock cycles */
  459. #define LL_ADC_SAMPLINGTIME_13CYCLES_5 ( ADC_SMPR_SMP_1 | ADC_SMPR_SMP_0) /*!< Sampling time 13.5 ADC clock cycles */
  460. #define LL_ADC_SAMPLINGTIME_28CYCLES_5 (ADC_SMPR_SMP_2 ) /*!< Sampling time 28.5 ADC clock cycles */
  461. #define LL_ADC_SAMPLINGTIME_41CYCLES_5 (ADC_SMPR_SMP_2 | ADC_SMPR_SMP_0) /*!< Sampling time 41.5 ADC clock cycles */
  462. #define LL_ADC_SAMPLINGTIME_71CYCLES_5 (ADC_SMPR_SMP_2 | ADC_SMPR_SMP_1 ) /*!< Sampling time 71.5 ADC clock cycles */
  463. #define LL_ADC_SAMPLINGTIME_239CYCLES_5 (ADC_SMPR_SMP_2 | ADC_SMPR_SMP_1 | ADC_SMPR_SMP_0) /*!< Sampling time 239.5 ADC clock cycles */
  464. /**
  465. * @}
  466. */
  467. /** @defgroup ADC_LL_EC_AWD_NUMBER Analog watchdog - Analog watchdog number
  468. * @{
  469. */
  470. #define LL_ADC_AWD (ADC_AWD_CR1_CHANNEL_MASK | ADC_AWD_CR1_REGOFFSET) /*!< ADC analog watchdog number 1 */
  471. /**
  472. * @}
  473. */
  474. /** @defgroup ADC_LL_EC_AWD_CHANNELS Analog watchdog - Monitored channels
  475. * @{
  476. */
  477. #define LL_ADC_AWD_DISABLE (0x00000000U) /*!< ADC analog watchdog monitoring disabled */
  478. #define LL_ADC_AWD_ALL_CHANNELS_REG ( ADC_CFGR1_AWDEN ) /*!< ADC analog watchdog monitoring of all channels, converted by group regular only */
  479. #define LL_ADC_AWD_CHANNEL_0_REG ((LL_ADC_CHANNEL_0 & ADC_CHANNEL_ID_MASK) | ADC_CFGR1_AWDEN | ADC_CFGR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN0, converted by group regular only */
  480. #define LL_ADC_AWD_CHANNEL_1_REG ((LL_ADC_CHANNEL_1 & ADC_CHANNEL_ID_MASK) | ADC_CFGR1_AWDEN | ADC_CFGR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN1, converted by group regular only */
  481. #define LL_ADC_AWD_CHANNEL_2_REG ((LL_ADC_CHANNEL_2 & ADC_CHANNEL_ID_MASK) | ADC_CFGR1_AWDEN | ADC_CFGR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN2, converted by group regular only */
  482. #define LL_ADC_AWD_CHANNEL_3_REG ((LL_ADC_CHANNEL_3 & ADC_CHANNEL_ID_MASK) | ADC_CFGR1_AWDEN | ADC_CFGR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN3, converted by group regular only */
  483. #define LL_ADC_AWD_CHANNEL_4_REG ((LL_ADC_CHANNEL_4 & ADC_CHANNEL_ID_MASK) | ADC_CFGR1_AWDEN | ADC_CFGR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN4, converted by group regular only */
  484. #define LL_ADC_AWD_CHANNEL_5_REG ((LL_ADC_CHANNEL_5 & ADC_CHANNEL_ID_MASK) | ADC_CFGR1_AWDEN | ADC_CFGR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN5, converted by group regular only */
  485. #define LL_ADC_AWD_CHANNEL_6_REG ((LL_ADC_CHANNEL_6 & ADC_CHANNEL_ID_MASK) | ADC_CFGR1_AWDEN | ADC_CFGR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN6, converted by group regular only */
  486. #define LL_ADC_AWD_CHANNEL_7_REG ((LL_ADC_CHANNEL_7 & ADC_CHANNEL_ID_MASK) | ADC_CFGR1_AWDEN | ADC_CFGR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN7, converted by group regular only */
  487. #define LL_ADC_AWD_CHANNEL_8_REG ((LL_ADC_CHANNEL_8 & ADC_CHANNEL_ID_MASK) | ADC_CFGR1_AWDEN | ADC_CFGR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN8, converted by group regular only */
  488. #define LL_ADC_AWD_CHANNEL_9_REG ((LL_ADC_CHANNEL_9 & ADC_CHANNEL_ID_MASK) | ADC_CFGR1_AWDEN | ADC_CFGR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN9, converted by group regular only */
  489. #define LL_ADC_AWD_CHANNEL_11_REG ((LL_ADC_CHANNEL_11 & ADC_CHANNEL_ID_MASK) | ADC_CFGR1_AWDEN | ADC_CFGR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN11, converted by group regular only */
  490. #define LL_ADC_AWD_CHANNEL_12_REG ((LL_ADC_CHANNEL_12 & ADC_CHANNEL_ID_MASK) | ADC_CFGR1_AWDEN | ADC_CFGR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN12, converted by group regular only */
  491. #define LL_ADC_AWD_CH_VREFINT_REG ((LL_ADC_CHANNEL_VREFINT & ADC_CHANNEL_ID_MASK) | ADC_CFGR1_AWDEN | ADC_CFGR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC internal channel connected to VrefInt: Internal voltage reference, converted by group regular only */
  492. #define LL_ADC_AWD_CH_TEMPSENSOR_REG ((LL_ADC_CHANNEL_TEMPSENSOR & ADC_CHANNEL_ID_MASK) | ADC_CFGR1_AWDEN | ADC_CFGR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC internal channel connected to Temperature sensor, converted by group regular only */
  493. /**
  494. * @}
  495. */
  496. /** @defgroup ADC_LL_EC_AWD_THRESHOLDS Analog watchdog - Thresholds
  497. * @{
  498. */
  499. #define LL_ADC_AWD_THRESHOLD_HIGH (ADC_TR_HT ) /*!< ADC analog watchdog threshold high */
  500. #define LL_ADC_AWD_THRESHOLD_LOW ( ADC_TR_LT) /*!< ADC analog watchdog threshold low */
  501. #define LL_ADC_AWD_THRESHOLDS_HIGH_LOW (ADC_TR_HT | ADC_TR_LT) /*!< ADC analog watchdog both thresholds high and low concatenated into the same data */
  502. /**
  503. * @}
  504. */
  505. /** @defgroup ADC_LL_EC_CAL_SAMPLINGTIME Calibration - Sampling time
  506. * @{
  507. */
  508. #define LL_ADC_CAL_SAMPLINGTIME_2CYCLES (0x00000000U) /*!< CAL Sampling time 2 ADC clock cycles */
  509. #define LL_ADC_CAL_SAMPLINGTIME_4CYCLES ( ADC_CCSR_CALSMP_0) /*!< CAL Sampling time 4 ADC clock cycles */
  510. #define LL_ADC_CAL_SAMPLINGTIME_8CYCLES (ADC_CCSR_CALSMP_1 ) /*!< CAL Sampling time 8 ADC clock cycles */
  511. #define LL_ADC_CAL_SAMPLINGTIME_1CYCLE (ADC_CCSR_CALSMP_1 | ADC_CCSR_CALSMP_0) /*!< CAL Sampling time 1 ADC clock cycle */
  512. /**
  513. * @}
  514. */
  515. /** @defgroup ADC_LL_EC_CAL_MODE Calibration - Mode
  516. * @{
  517. */
  518. #define LL_ADC_CAL_MODE_OFFSET (0x00000000U) /*!< ADC calibration mode selection only OFFSET */
  519. #define LL_ADC_CAL_MODE_OFFSETANDLINEARITY ADC_CCSR_CALSEL /*!< ADC calibration mode selection OFFSET AND LINERARITY */
  520. /**
  521. * @}
  522. */
  523. /** @defgroup ADC_LL_EC_CAL_STATUS Calibration - Status
  524. * @{
  525. */
  526. #define LL_ADC_CAL_STATUS_SUCCESS (0x00000000U) /*!< ADC calibration status SUCCESS */
  527. #define LL_ADC_CAL_STATUS_FAIL ( ADC_CCSR_CALFAIL) /*!< ADC calibration status FAIL */
  528. #define LL_ADC_CAL_STATUS_ONGOING (ADC_CCSR_CALON ) /*!< ADC calibration status ONGOING */
  529. #define LL_ADC_CAL_STATUS_INVALID (ADC_CCSR_CALON | ADC_CCSR_CALFAIL) /*!< ADC calibration status INVALID */
  530. /**
  531. * @}
  532. */
  533. /** @defgroup ADC_LL_EC_HW_DELAYS Definitions of ADC hardware constraints delays
  534. * @note Only ADC IP HW delays are defined in ADC LL driver driver,
  535. * not timeout values.
  536. * For details on delays values, refer to descriptions in source code
  537. * above each literal definition.
  538. * @{
  539. */
  540. /* Note: Only ADC IP HW delays are defined in ADC LL driver driver, */
  541. /* not timeout values. */
  542. /* Timeout values for ADC operations are dependent to device clock */
  543. /* configuration (system clock versus ADC clock), */
  544. /* and therefore must be defined in user application. */
  545. /* Indications for estimation of ADC timeout delays, for this */
  546. /* PY32 serie: */
  547. /* - ADC calibration time: maximum delay is 64/fADC. */
  548. /* - ADC enable time: maximum delay is 8 ADC Clock Cycles. */
  549. /* - ADC disable time: maximum delay should be a few ADC clock cycles */
  550. /* - ADC stop conversion time: maximum delay should be a few ADC clock */
  551. /* cycles */
  552. /* - ADC conversion time: duration depending on ADC clock and ADC */
  553. /* configuration. */
  554. /* (refer to device reference manual, section "Timing") */
  555. /* Delay for internal voltage reference stabilization time. */
  556. /* Delay set to maximum value (refer to device datasheet, */
  557. /* parameter "tSTART"). */
  558. /* Unit: us */
  559. #define LL_ADC_DELAY_VREFINT_STAB_US ( 10U) /*!< Delay for internal voltage reference stabilization time */
  560. /* Delay for temperature sensor stabilization time. */
  561. /* Literal set to maximum value (refer to device datasheet, */
  562. /* parameter "tSTART"). */
  563. /* Unit: us */
  564. #define LL_ADC_DELAY_TEMPSENSOR_STAB_US ( 10U) /*!< Delay for temperature sensor stabilization time */
  565. /* Delay required between ADC end of calibration and ADC enable. */
  566. /* Note: On this PY32 serie, a minimum number of ADC clock cycles */
  567. /* are required between ADC end of calibration and ADC enable. */
  568. /* Wait time can be computed in user application by waiting for the */
  569. /* equivalent number of CPU cycles, by taking into account */
  570. /* ratio of CPU clock versus ADC clock prescalers. */
  571. /* Unit: ADC clock cycles. */
  572. #define LL_ADC_DELAY_CALIB_ENABLE_ADC_CYCLES ( 4U) /*!< Delay required between ADC end of calibration and ADC enable */
  573. /* Delay between ADC end of calibration and ADC enable. */
  574. /* Delay estimation in CPU cycles: Case of ADC enable done */
  575. /* immediately after ADC calibration, ADC clock setting slow */
  576. /* (CPU clock / ADC clock) is above 64. */
  577. #define LL_ADC_DELAY_CALIB_ENABLE_CPU_CYCLES (LL_ADC_DELAY_CALIB_ENABLE_ADC_CYCLES * 64)
  578. /* Timeout values for ADC Calibration. */
  579. #define LL_ADC_CALIBRATION_TIMEOUT_CPU_CYCLES ( 1000U)
  580. /**
  581. * @}
  582. */
  583. /**
  584. * @}
  585. */
  586. /* Exported macro ------------------------------------------------------------*/
  587. /** @defgroup ADC_LL_Exported_Macros ADC Exported Macros
  588. * @{
  589. */
  590. /** @defgroup ADC_LL_EM_WRITE_READ Common write and read registers Macros
  591. * @{
  592. */
  593. /**
  594. * @brief Write a value in ADC register
  595. * @param __INSTANCE__ ADC Instance
  596. * @param __REG__ Register to be written
  597. * @param __VALUE__ Value to be written in the register
  598. * @retval None
  599. */
  600. #define LL_ADC_WriteReg(__INSTANCE__, __REG__, __VALUE__) WRITE_REG(__INSTANCE__->__REG__, (__VALUE__))
  601. /**
  602. * @brief Read a value in ADC register
  603. * @param __INSTANCE__ ADC Instance
  604. * @param __REG__ Register to be read
  605. * @retval Register value
  606. */
  607. #define LL_ADC_ReadReg(__INSTANCE__, __REG__) READ_REG(__INSTANCE__->__REG__)
  608. /**
  609. * @}
  610. */
  611. /** @defgroup ADC_LL_EM_HELPER_MACRO ADC helper macro
  612. * @{
  613. */
  614. /**
  615. * @brief Helper macro to get ADC channel number in decimal format
  616. * from literals LL_ADC_CHANNEL_x.
  617. * @note Example:
  618. * __LL_ADC_CHANNEL_TO_DECIMAL_NB(LL_ADC_CHANNEL_4)
  619. * will return decimal number "4".
  620. * @note The input can be a value from functions where a channel
  621. * number is returned, either defined with number
  622. * or with bitfield (only one bit must be set).
  623. * @note Depending on devices and packages, some channels may not be available.
  624. * Refer to device datasheet for channels availability.
  625. * @param __CHANNEL__ This parameter can be one of the following values:
  626. * @arg @ref LL_ADC_CHANNEL_0
  627. * @arg @ref LL_ADC_CHANNEL_1
  628. * @arg @ref LL_ADC_CHANNEL_2
  629. * @arg @ref LL_ADC_CHANNEL_3
  630. * @arg @ref LL_ADC_CHANNEL_4
  631. * @arg @ref LL_ADC_CHANNEL_5
  632. * @arg @ref LL_ADC_CHANNEL_6
  633. * @arg @ref LL_ADC_CHANNEL_7
  634. * @arg @ref LL_ADC_CHANNEL_8
  635. * @arg @ref LL_ADC_CHANNEL_9
  636. * @arg @ref LL_ADC_CHANNEL_11
  637. * @arg @ref LL_ADC_CHANNEL_12
  638. * @arg @ref LL_ADC_CHANNEL_VREFINT
  639. * @arg @ref LL_ADC_CHANNEL_TEMPSENSOR
  640. * @retval Value between Min_Data=0 and Max_Data=12
  641. */
  642. #define __LL_ADC_CHANNEL_TO_DECIMAL_NB(__CHANNEL__) \
  643. ((((__CHANNEL__) & ADC_CHANNEL_ID_BITFIELD_MASK) == 0U) \
  644. ? ( \
  645. ((__CHANNEL__) & ADC_CHANNEL_ID_NUMBER_MASK) >> ADC_CHANNEL_ID_NUMBER_BITOFFSET_POS \
  646. ) \
  647. : \
  648. ( \
  649. (((__CHANNEL__) & ADC_CHSELR_CHSEL0) == ADC_CHSELR_CHSEL0) ? (0U) : \
  650. ( \
  651. (((__CHANNEL__) & ADC_CHSELR_CHSEL1) == ADC_CHSELR_CHSEL1) ? (1U) : \
  652. ( \
  653. (((__CHANNEL__) & ADC_CHSELR_CHSEL2) == ADC_CHSELR_CHSEL2) ? (2U) : \
  654. ( \
  655. (((__CHANNEL__) & ADC_CHSELR_CHSEL3) == ADC_CHSELR_CHSEL3) ? (3U) : \
  656. ( \
  657. (((__CHANNEL__) & ADC_CHSELR_CHSEL4) == ADC_CHSELR_CHSEL4) ? (4U) : \
  658. ( \
  659. (((__CHANNEL__) & ADC_CHSELR_CHSEL5) == ADC_CHSELR_CHSEL5) ? (5U) : \
  660. ( \
  661. (((__CHANNEL__) & ADC_CHSELR_CHSEL6) == ADC_CHSELR_CHSEL6) ? (6U) : \
  662. ( \
  663. (((__CHANNEL__) & ADC_CHSELR_CHSEL7) == ADC_CHSELR_CHSEL7) ? (7U) : \
  664. ( \
  665. (((__CHANNEL__) & ADC_CHSELR_CHSEL8) == ADC_CHSELR_CHSEL8) ? (8U) : \
  666. ( \
  667. (((__CHANNEL__) & ADC_CHSELR_CHSEL9) == ADC_CHSELR_CHSEL9) ? (9U) : \
  668. ( \
  669. (((__CHANNEL__) & ADC_CHSELR_CHSEL11) == ADC_CHSELR_CHSEL11) ? (11U) : \
  670. ( \
  671. (((__CHANNEL__) & ADC_CHSELR_CHSEL12) == ADC_CHSELR_CHSEL12) ? (12U) : \
  672. (0U) \
  673. ) \
  674. ) \
  675. ) \
  676. ) \
  677. ) \
  678. ) \
  679. ) \
  680. ) \
  681. ) \
  682. ) \
  683. ) \
  684. ) \
  685. )
  686. /**
  687. * @brief Helper macro to get ADC channel in literal format LL_ADC_CHANNEL_x
  688. * from number in decimal format.
  689. * @note Example:
  690. * __LL_ADC_DECIMAL_NB_TO_CHANNEL(4)
  691. * will return a data equivalent to "LL_ADC_CHANNEL_4".
  692. * @note Depending on devices and packages, some channels may not be available.
  693. * Refer to device datasheet for channels availability.
  694. * @param __DECIMAL_NB__ Value between Min_Data=0 and Max_Data=12
  695. * @retval Returned value can be one of the following values:
  696. * @arg @ref LL_ADC_CHANNEL_0
  697. * @arg @ref LL_ADC_CHANNEL_1
  698. * @arg @ref LL_ADC_CHANNEL_2
  699. * @arg @ref LL_ADC_CHANNEL_3
  700. * @arg @ref LL_ADC_CHANNEL_4
  701. * @arg @ref LL_ADC_CHANNEL_5
  702. * @arg @ref LL_ADC_CHANNEL_6
  703. * @arg @ref LL_ADC_CHANNEL_7
  704. * @arg @ref LL_ADC_CHANNEL_8
  705. * @arg @ref LL_ADC_CHANNEL_9
  706. * @arg @ref LL_ADC_CHANNEL_11
  707. * @arg @ref LL_ADC_CHANNEL_12
  708. * @arg @ref LL_ADC_CHANNEL_VREFINT (1)
  709. * @arg @ref LL_ADC_CHANNEL_TEMPSENSOR (1)
  710. * (1) For ADC channel read back from ADC register,
  711. * comparison with internal channel parameter to be done
  712. * using helper macro @ref __LL_ADC_CHANNEL_INTERNAL_TO_EXTERNAL().
  713. */
  714. #define __LL_ADC_DECIMAL_NB_TO_CHANNEL(__DECIMAL_NB__) \
  715. ( \
  716. ((__DECIMAL_NB__) << ADC_CHANNEL_ID_NUMBER_BITOFFSET_POS) | \
  717. (ADC_CHSELR_CHSEL0 << (__DECIMAL_NB__)) \
  718. )
  719. /**
  720. * @brief Helper macro to determine whether the selected channel
  721. * corresponds to literal definitions of driver.
  722. * @note The different literal definitions of ADC channels are:
  723. * - ADC internal channel:
  724. * LL_ADC_CHANNEL_VREFINT, LL_ADC_CHANNEL_TEMPSENSOR, ...
  725. * - ADC external channel (channel connected to a GPIO pin):
  726. * LL_ADC_CHANNEL_1, LL_ADC_CHANNEL_2, ...
  727. * @note The channel parameter must be a value defined from literal
  728. * definition of a ADC internal channel (LL_ADC_CHANNEL_VREFINT,
  729. * LL_ADC_CHANNEL_TEMPSENSOR, ...),
  730. * ADC external channel (LL_ADC_CHANNEL_1, LL_ADC_CHANNEL_2, ...),
  731. * must not be a value from functions where a channel number is
  732. * returned from ADC registers,
  733. * because internal and external channels share the same channel
  734. * number in ADC registers. The differentiation is made only with
  735. * parameters definitions of driver.
  736. * @note Depending on devices and packages, some channels may not be available.
  737. * Refer to device datasheet for channels availability.
  738. * @param __CHANNEL__ This parameter can be one of the following values:
  739. * @arg @ref LL_ADC_CHANNEL_0
  740. * @arg @ref LL_ADC_CHANNEL_1
  741. * @arg @ref LL_ADC_CHANNEL_2
  742. * @arg @ref LL_ADC_CHANNEL_3
  743. * @arg @ref LL_ADC_CHANNEL_4
  744. * @arg @ref LL_ADC_CHANNEL_5
  745. * @arg @ref LL_ADC_CHANNEL_6
  746. * @arg @ref LL_ADC_CHANNEL_7
  747. * @arg @ref LL_ADC_CHANNEL_8
  748. * @arg @ref LL_ADC_CHANNEL_9
  749. * @arg @ref LL_ADC_CHANNEL_11
  750. * @arg @ref LL_ADC_CHANNEL_12
  751. * @arg @ref LL_ADC_CHANNEL_VREFINT
  752. * @arg @ref LL_ADC_CHANNEL_TEMPSENSOR
  753. * @retval Value "0" if the channel corresponds to a parameter definition of a ADC external channel (channel connected to a GPIO pin).
  754. * Value "1" if the channel corresponds to a parameter definition of a ADC internal channel.
  755. */
  756. #define __LL_ADC_IS_CHANNEL_INTERNAL(__CHANNEL__) \
  757. (((__CHANNEL__) & ADC_CHANNEL_ID_INTERNAL_CH_MASK) != 0U)
  758. /**
  759. * @brief Helper macro to convert a channel defined from parameter
  760. * definition of a ADC internal channel (LL_ADC_CHANNEL_VREFINT,
  761. * LL_ADC_CHANNEL_TEMPSENSOR, ...),
  762. * to its equivalent parameter definition of a ADC external channel
  763. * (LL_ADC_CHANNEL_1, LL_ADC_CHANNEL_2, ...).
  764. * @note The channel parameter can be, additionally to a value
  765. * defined from parameter definition of a ADC internal channel
  766. * (LL_ADC_CHANNEL_VREFINT, LL_ADC_CHANNEL_TEMPSENSOR, ...),
  767. * a value defined from parameter definition of
  768. * ADC external channel (LL_ADC_CHANNEL_1, LL_ADC_CHANNEL_2, ...)
  769. * or a value from functions where a channel number is returned
  770. * from ADC registers.
  771. * @note Depending on devices and packages, some channels may not be available.
  772. * Refer to device datasheet for channels availability.
  773. * @param __CHANNEL__ This parameter can be one of the following values:
  774. * @arg @ref LL_ADC_CHANNEL_0
  775. * @arg @ref LL_ADC_CHANNEL_1
  776. * @arg @ref LL_ADC_CHANNEL_2
  777. * @arg @ref LL_ADC_CHANNEL_3
  778. * @arg @ref LL_ADC_CHANNEL_4
  779. * @arg @ref LL_ADC_CHANNEL_5
  780. * @arg @ref LL_ADC_CHANNEL_6
  781. * @arg @ref LL_ADC_CHANNEL_7
  782. * @arg @ref LL_ADC_CHANNEL_8
  783. * @arg @ref LL_ADC_CHANNEL_9
  784. * @arg @ref LL_ADC_CHANNEL_11
  785. * @arg @ref LL_ADC_CHANNEL_12
  786. * @arg @ref LL_ADC_CHANNEL_VREFINT
  787. * @arg @ref LL_ADC_CHANNEL_TEMPSENSOR
  788. * @retval Returned value can be one of the following values:
  789. * @arg @ref LL_ADC_CHANNEL_0
  790. * @arg @ref LL_ADC_CHANNEL_1
  791. * @arg @ref LL_ADC_CHANNEL_2
  792. * @arg @ref LL_ADC_CHANNEL_3
  793. * @arg @ref LL_ADC_CHANNEL_4
  794. * @arg @ref LL_ADC_CHANNEL_5
  795. * @arg @ref LL_ADC_CHANNEL_6
  796. * @arg @ref LL_ADC_CHANNEL_7
  797. * @arg @ref LL_ADC_CHANNEL_8
  798. * @arg @ref LL_ADC_CHANNEL_9
  799. * @arg @ref LL_ADC_CHANNEL_11
  800. * @arg @ref LL_ADC_CHANNEL_12
  801. */
  802. #define __LL_ADC_CHANNEL_INTERNAL_TO_EXTERNAL(__CHANNEL__) \
  803. ((__CHANNEL__) & ~ADC_CHANNEL_ID_INTERNAL_CH_MASK)
  804. /**
  805. * @brief Helper macro to determine whether the internal channel
  806. * selected is available on the ADC instance selected.
  807. * @note The channel parameter must be a value defined from parameter
  808. * definition of a ADC internal channel (LL_ADC_CHANNEL_VREFINT,
  809. * LL_ADC_CHANNEL_TEMPSENSOR, ...),
  810. * must not be a value defined from parameter definition of
  811. * ADC external channel (LL_ADC_CHANNEL_1, LL_ADC_CHANNEL_2, ...)
  812. * or a value from functions where a channel number is
  813. * returned from ADC registers,
  814. * because internal and external channels share the same channel
  815. * number in ADC registers. The differentiation is made only with
  816. * parameters definitions of driver.
  817. * @param __ADC_INSTANCE__ ADC instance
  818. * @param __CHANNEL__ This parameter can be one of the following values:
  819. * @arg @ref LL_ADC_CHANNEL_VREFINT
  820. * @arg @ref LL_ADC_CHANNEL_TEMPSENSOR
  821. * @retval Value "0" if the internal channel selected is not available on the ADC instance selected.
  822. * Value "1" if the internal channel selected is available on the ADC instance selected.
  823. */
  824. #define __LL_ADC_IS_CHANNEL_INTERNAL_AVAILABLE(__ADC_INSTANCE__, __CHANNEL__) \
  825. ( \
  826. ((__CHANNEL__) == LL_ADC_CHANNEL_VREFINT) || \
  827. ((__CHANNEL__) == LL_ADC_CHANNEL_TEMPSENSOR) \
  828. )
  829. /**
  830. * @brief Helper macro to define ADC analog watchdog parameter:
  831. * define a single channel to monitor with analog watchdog
  832. * from sequencer channel and groups definition.
  833. * @note To be used with function @ref LL_ADC_SetAnalogWDMonitChannels().
  834. * Example:
  835. * LL_ADC_SetAnalogWDMonitChannels(
  836. * ADC1, LL_ADC_AWD,
  837. * __LL_ADC_ANALOGWD_CHANNEL_GROUP(LL_ADC_CHANNEL4, LL_ADC_GROUP_REGULAR))
  838. * @note Depending on devices and packages, some channels may not be available.
  839. * Refer to device datasheet for channels availability.
  840. * @param __CHANNEL__ This parameter can be one of the following values:
  841. * @arg @ref LL_ADC_CHANNEL_0
  842. * @arg @ref LL_ADC_CHANNEL_1
  843. * @arg @ref LL_ADC_CHANNEL_2
  844. * @arg @ref LL_ADC_CHANNEL_3
  845. * @arg @ref LL_ADC_CHANNEL_4
  846. * @arg @ref LL_ADC_CHANNEL_5
  847. * @arg @ref LL_ADC_CHANNEL_6
  848. * @arg @ref LL_ADC_CHANNEL_7
  849. * @arg @ref LL_ADC_CHANNEL_8
  850. * @arg @ref LL_ADC_CHANNEL_9
  851. * @arg @ref LL_ADC_CHANNEL_11
  852. * @arg @ref LL_ADC_CHANNEL_12
  853. * @arg @ref LL_ADC_CHANNEL_VREFINT (1)
  854. * @arg @ref LL_ADC_CHANNEL_TEMPSENSOR (1)
  855. * (1) For ADC channel read back from ADC register,
  856. * comparison with internal channel parameter to be done
  857. * using helper macro @ref __LL_ADC_CHANNEL_INTERNAL_TO_EXTERNAL().
  858. * @param __GROUP__ This parameter can be one of the following values:
  859. * @arg @ref LL_ADC_GROUP_REGULAR
  860. * @retval Returned value can be one of the following values:
  861. * @arg @ref LL_ADC_AWD_DISABLE
  862. * @arg @ref LL_ADC_AWD_ALL_CHANNELS_REG
  863. * @arg @ref LL_ADC_AWD_CHANNEL_0_REG
  864. * @arg @ref LL_ADC_AWD_CHANNEL_1_REG
  865. * @arg @ref LL_ADC_AWD_CHANNEL_2_REG
  866. * @arg @ref LL_ADC_AWD_CHANNEL_3_REG
  867. * @arg @ref LL_ADC_AWD_CHANNEL_4_REG
  868. * @arg @ref LL_ADC_AWD_CHANNEL_5_REG
  869. * @arg @ref LL_ADC_AWD_CHANNEL_6_REG
  870. * @arg @ref LL_ADC_AWD_CHANNEL_7_REG
  871. * @arg @ref LL_ADC_AWD_CHANNEL_8_REG
  872. * @arg @ref LL_ADC_AWD_CHANNEL_9_REG
  873. * @arg @ref LL_ADC_AWD_CHANNEL_11_REG
  874. * @arg @ref LL_ADC_AWD_CHANNEL_12_REG
  875. * @arg @ref LL_ADC_AWD_CH_VREFINT_REG
  876. * @arg @ref LL_ADC_AWD_CH_TEMPSENSOR_REG
  877. */
  878. #define __LL_ADC_ANALOGWD_CHANNEL_GROUP(__CHANNEL__, __GROUP__)\
  879. (((__CHANNEL__) & ADC_CHANNEL_ID_MASK) | ADC_CFGR1_AWDEN | ADC_CFGR1_AWDSGL)
  880. /**
  881. * @brief Helper macro to set the value of ADC analog watchdog threshold high
  882. * or low in function of ADC resolution, when ADC resolution is
  883. * different of 12 bits.
  884. * @note To be used with function @ref LL_ADC_ConfigAnalogWDThresholds()
  885. * or @ref LL_ADC_SetAnalogWDThresholds().
  886. * Example, with a ADC resolution of 8 bits, to set the value of
  887. * analog watchdog threshold high (on 8 bits):
  888. * LL_ADC_SetAnalogWDThresholds
  889. * (< ADCx param >,
  890. * __LL_ADC_ANALOGWD_SET_THRESHOLD_RESOLUTION(LL_ADC_RESOLUTION_8B, <threshold_value_8_bits>)
  891. * );
  892. * @param __ADC_RESOLUTION__ This parameter can be one of the following values:
  893. * @arg @ref LL_ADC_RESOLUTION_12B
  894. * @arg @ref LL_ADC_RESOLUTION_10B
  895. * @arg @ref LL_ADC_RESOLUTION_8B
  896. * @arg @ref LL_ADC_RESOLUTION_6B
  897. * @param __AWD_THRESHOLD__ Value between Min_Data=0x000 and Max_Data=0xFFF
  898. * @retval Value between Min_Data=0x000 and Max_Data=0xFFF
  899. */
  900. #define __LL_ADC_ANALOGWD_SET_THRESHOLD_RESOLUTION(__ADC_RESOLUTION__, __AWD_THRESHOLD__) \
  901. ((__AWD_THRESHOLD__) << ((__ADC_RESOLUTION__) >> (ADC_CFGR1_RES_BITOFFSET_POS - 1U )))
  902. /**
  903. * @brief Helper macro to get the value of ADC analog watchdog threshold high
  904. * or low in function of ADC resolution, when ADC resolution is
  905. * different of 12 bits.
  906. * @note To be used with function @ref LL_ADC_GetAnalogWDThresholds().
  907. * Example, with a ADC resolution of 8 bits, to get the value of
  908. * analog watchdog threshold high (on 8 bits):
  909. * < threshold_value_6_bits > = __LL_ADC_ANALOGWD_GET_THRESHOLD_RESOLUTION
  910. * (LL_ADC_RESOLUTION_8B,
  911. * LL_ADC_GetAnalogWDThresholds(<ADCx param>, LL_ADC_AWD_THRESHOLD_HIGH)
  912. * );
  913. * @param __ADC_RESOLUTION__ This parameter can be one of the following values:
  914. * @arg @ref LL_ADC_RESOLUTION_12B
  915. * @arg @ref LL_ADC_RESOLUTION_10B
  916. * @arg @ref LL_ADC_RESOLUTION_8B
  917. * @arg @ref LL_ADC_RESOLUTION_6B
  918. * @param __AWD_THRESHOLD_12_BITS__ Value between Min_Data=0x000 and Max_Data=0xFFF
  919. * @retval Value between Min_Data=0x000 and Max_Data=0xFFF
  920. */
  921. #define __LL_ADC_ANALOGWD_GET_THRESHOLD_RESOLUTION(__ADC_RESOLUTION__, __AWD_THRESHOLD_12_BITS__) \
  922. ((__AWD_THRESHOLD_12_BITS__) >> ((__ADC_RESOLUTION__) >> (ADC_CFGR1_RES_BITOFFSET_POS - 1U )))
  923. /**
  924. * @brief Helper macro to get the ADC analog watchdog threshold high
  925. * or low from raw value containing both thresholds concatenated.
  926. * @note To be used with function @ref LL_ADC_GetAnalogWDThresholds().
  927. * Example, to get analog watchdog threshold high from the register raw value:
  928. * __LL_ADC_ANALOGWD_THRESHOLDS_HIGH_LOW(LL_ADC_AWD_THRESHOLD_HIGH, <raw_value_with_both_thresholds>);
  929. * @param __AWD_THRESHOLD_TYPE__ This parameter can be one of the following values:
  930. * @arg @ref LL_ADC_AWD_THRESHOLD_HIGH
  931. * @arg @ref LL_ADC_AWD_THRESHOLD_LOW
  932. * @param __AWD_THRESHOLDS__ Value between Min_Data=0x00000000 and Max_Data=0xFFFFFFFF
  933. * @retval Value between Min_Data=0x000 and Max_Data=0xFFF
  934. */
  935. #define __LL_ADC_ANALOGWD_THRESHOLDS_HIGH_LOW(__AWD_THRESHOLD_TYPE__, __AWD_THRESHOLDS__) \
  936. (((__AWD_THRESHOLD_TYPE__) == LL_ADC_AWD_THRESHOLD_LOW) \
  937. ? ( \
  938. (__AWD_THRESHOLDS__) & LL_ADC_AWD_THRESHOLD_LOW \
  939. ) \
  940. : \
  941. ( \
  942. ((__AWD_THRESHOLDS__) >> ADC_TR_HT_BITOFFSET_POS) & LL_ADC_AWD_THRESHOLD_LOW \
  943. ) \
  944. )
  945. /**
  946. * @brief Helper macro to select the ADC common instance
  947. * to which is belonging the selected ADC instance.
  948. * @note ADC common register instance can be used for:
  949. * - Set parameters common to several ADC instances
  950. * - Multimode (for devices with several ADC instances)
  951. * Refer to functions having argument "ADCxy_COMMON" as parameter.
  952. * @param __ADCx__ ADC instance
  953. * @retval ADC common register instance
  954. */
  955. #define __LL_ADC_COMMON_INSTANCE(__ADCx__) \
  956. (ADC1_COMMON)
  957. /**
  958. * @brief Helper macro to check if all ADC instances sharing the same
  959. * ADC common instance are disabled.
  960. * @note This check is required by functions with setting conditioned to
  961. * ADC state:
  962. * All ADC instances of the ADC common group must be disabled.
  963. * Refer to functions having argument "ADCxy_COMMON" as parameter.
  964. * @note On devices with only 1 ADC common instance, parameter of this macro
  965. * is useless and can be ignored (parameter kept for compatibility
  966. * with devices featuring several ADC common instances).
  967. * @param __ADCXY_COMMON__ ADC common instance
  968. * (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() )
  969. * @retval Value "0" if all ADC instances sharing the same ADC common instance
  970. * are disabled.
  971. * Value "1" if at least one ADC instance sharing the same ADC common instance
  972. * is enabled.
  973. */
  974. #define __LL_ADC_IS_ENABLED_ALL_COMMON_INSTANCE(__ADCXY_COMMON__) \
  975. LL_ADC_IsEnabled(ADC1)
  976. /**
  977. * @brief Helper macro to define the ADC conversion data full-scale digital
  978. * value corresponding to the selected ADC resolution.
  979. * @note ADC conversion data full-scale corresponds to voltage range
  980. * determined by analog voltage references Vref+ and Vref-
  981. * (refer to reference manual).
  982. * @param __ADC_RESOLUTION__ This parameter can be one of the following values:
  983. * @arg @ref LL_ADC_RESOLUTION_12B
  984. * @arg @ref LL_ADC_RESOLUTION_10B
  985. * @arg @ref LL_ADC_RESOLUTION_8B
  986. * @arg @ref LL_ADC_RESOLUTION_6B
  987. * @retval ADC conversion data equivalent voltage value (unit: mVolt)
  988. */
  989. #define __LL_ADC_DIGITAL_SCALE(__ADC_RESOLUTION__) \
  990. (0xFFFU >> ((__ADC_RESOLUTION__) >> (ADC_CFGR1_RES_BITOFFSET_POS - 1U)))
  991. /**
  992. * @brief Helper macro to convert the ADC conversion data from
  993. * a resolution to another resolution.
  994. * @param __DATA__ ADC conversion data to be converted
  995. * @param __ADC_RESOLUTION_CURRENT__ Resolution of to the data to be converted
  996. * This parameter can be one of the following values:
  997. * @arg @ref LL_ADC_RESOLUTION_12B
  998. * @arg @ref LL_ADC_RESOLUTION_10B
  999. * @arg @ref LL_ADC_RESOLUTION_8B
  1000. * @arg @ref LL_ADC_RESOLUTION_6B
  1001. * @param __ADC_RESOLUTION_TARGET__ Resolution of the data after conversion
  1002. * This parameter can be one of the following values:
  1003. * @arg @ref LL_ADC_RESOLUTION_12B
  1004. * @arg @ref LL_ADC_RESOLUTION_10B
  1005. * @arg @ref LL_ADC_RESOLUTION_8B
  1006. * @arg @ref LL_ADC_RESOLUTION_6B
  1007. * @retval ADC conversion data to the requested resolution
  1008. */
  1009. #define __LL_ADC_CONVERT_DATA_RESOLUTION(__DATA__, __ADC_RESOLUTION_CURRENT__, __ADC_RESOLUTION_TARGET__) \
  1010. (((__DATA__) \
  1011. << ((__ADC_RESOLUTION_CURRENT__) >> (ADC_CFGR1_RES_BITOFFSET_POS - 1U))) \
  1012. >> ((__ADC_RESOLUTION_TARGET__) >> (ADC_CFGR1_RES_BITOFFSET_POS - 1U)) \
  1013. )
  1014. /**
  1015. * @brief Helper macro to calculate the voltage (unit: mVolt)
  1016. * corresponding to a ADC conversion data (unit: digital value).
  1017. * @note Analog reference voltage (Vref+) must be either known from
  1018. * user board environment or can be calculated using ADC measurement
  1019. * and ADC helper macro @ref __LL_ADC_CALC_VREFANALOG_VOLTAGE().
  1020. * @param __VREFANALOG_VOLTAGE__ Analog reference voltage (unit: mV)
  1021. * @param __ADC_DATA__ ADC conversion data (resolution 12 bits)
  1022. * (unit: digital value).
  1023. * @param __ADC_RESOLUTION__ This parameter can be one of the following values:
  1024. * @arg @ref LL_ADC_RESOLUTION_12B
  1025. * @arg @ref LL_ADC_RESOLUTION_10B
  1026. * @arg @ref LL_ADC_RESOLUTION_8B
  1027. * @arg @ref LL_ADC_RESOLUTION_6B
  1028. * @retval ADC conversion data equivalent voltage value (unit: mVolt)
  1029. */
  1030. #define __LL_ADC_CALC_DATA_TO_VOLTAGE(__VREFANALOG_VOLTAGE__,__ADC_DATA__,__ADC_RESOLUTION__) \
  1031. ((__ADC_DATA__) * (__VREFANALOG_VOLTAGE__)/ __LL_ADC_DIGITAL_SCALE(__ADC_RESOLUTION__))
  1032. /**
  1033. * @brief Helper macro to calculate analog reference voltage (Vref+)
  1034. * (unit: mVolt) from ADC conversion data of internal voltage
  1035. * reference VrefInt.
  1036. * @note Computation is using VrefInt calibration value
  1037. * stored in system memory for each device during production.
  1038. * @note This voltage depends on user board environment: voltage level
  1039. * connected to pin Vref+.
  1040. * On devices with small package, the pin Vref+ is not present
  1041. * and internally bonded to pin Vdda.
  1042. * @note On this PY32 serie, calibration data of internal voltage reference
  1043. * VrefInt corresponds to a resolution of 12 bits,
  1044. * this is the recommended ADC resolution to convert voltage of
  1045. * internal voltage reference VrefInt.
  1046. * Otherwise, this macro performs the processing to scale
  1047. * ADC conversion data to 12 bits.
  1048. * @param __VREFINT_ADC_DATA__ ADC conversion data (resolution 12 bits)
  1049. * of internal voltage reference VrefInt (unit: digital value).
  1050. * @param __ADC_RESOLUTION__ This parameter can be one of the following values:
  1051. * @arg @ref LL_ADC_RESOLUTION_12B
  1052. * @arg @ref LL_ADC_RESOLUTION_10B
  1053. * @arg @ref LL_ADC_RESOLUTION_8B
  1054. * @arg @ref LL_ADC_RESOLUTION_6B
  1055. * @retval Analog reference voltage (unit: mV)
  1056. */
  1057. #define __LL_ADC_CALC_VREFANALOG_VOLTAGE(__VREFINT_ADC_DATA__,__ADC_RESOLUTION__) \
  1058. (4095*( VREFINT_CAL_VREF)/ __LL_ADC_CONVERT_DATA_RESOLUTION((__VREFINT_ADC_DATA__),(__ADC_RESOLUTION__),LL_ADC_RESOLUTION_12B))
  1059. /**
  1060. * @brief Helper macro to calculate the temperature (unit: degree Celsius)
  1061. * from ADC conversion data of internal temperature sensor.
  1062. * @note Computation is using temperature sensor calibration values
  1063. * stored in system memory for each device during production.
  1064. * @note Calculation formula:
  1065. * Temperature = ((TS_ADC_DATA - TS_CAL1)
  1066. * * (TS_CAL2_TEMP - TS_CAL1_TEMP))
  1067. * / (TS_CAL2 - TS_CAL1) + TS_CAL1_TEMP
  1068. * with TS_ADC_DATA = temperature sensor raw data measured by ADC
  1069. * Avg_Slope = (TS_CAL2 - TS_CAL1)
  1070. * / (TS_CAL2_TEMP - TS_CAL1_TEMP)
  1071. * TS_CAL1 = equivalent TS_ADC_DATA at temperature
  1072. * TEMP_DEGC_CAL1 (calibrated in factory)
  1073. * TS_CAL2 = equivalent TS_ADC_DATA at temperature
  1074. * TEMP_DEGC_CAL2 (calibrated in factory)
  1075. * Caution: Calculation relevancy under reserve that calibration
  1076. * parameters are correct (address and data).
  1077. * To calculate temperature using temperature sensor
  1078. * datasheet typical values (generic values less, therefore
  1079. * less accurate than calibrated values),
  1080. * use helper macro @ref __LL_ADC_CALC_TEMPERATURE_TYP_PARAMS().
  1081. * @note As calculation input, the analog reference voltage (Vref+) must be
  1082. * defined as it impacts the ADC LSB equivalent voltage.
  1083. * @note Analog reference voltage (Vref+) must be either known from
  1084. * user board environment or can be calculated using ADC measurement
  1085. * and ADC helper macro @ref __LL_ADC_CALC_VREFANALOG_VOLTAGE().
  1086. * @note On this PY32 serie, calibration data of temperature sensor
  1087. * corresponds to a resolution of 12 bits,
  1088. * this is the recommended ADC resolution to convert voltage of
  1089. * temperature sensor.
  1090. * Otherwise, this macro performs the processing to scale
  1091. * ADC conversion data to 12 bits.
  1092. * @param __VREFANALOG_VOLTAGE__ Analog reference voltage (unit: mV)
  1093. * @param __TEMPSENSOR_ADC_DATA__ ADC conversion data of internal
  1094. * temperature sensor (unit: digital value).
  1095. * @param __ADC_RESOLUTION__ ADC resolution at which internal temperature
  1096. * sensor voltage has been measured.
  1097. * This parameter can be one of the following values:
  1098. * @arg @ref LL_ADC_RESOLUTION_12B
  1099. * @arg @ref LL_ADC_RESOLUTION_10B
  1100. * @arg @ref LL_ADC_RESOLUTION_8B
  1101. * @arg @ref LL_ADC_RESOLUTION_6B
  1102. * @retval Temperature (unit: degree Celsius)
  1103. */
  1104. #define __LL_ADC_CALC_TEMPERATURE(__VREFANALOG_VOLTAGE__,\
  1105. __TEMPSENSOR_ADC_DATA__,\
  1106. __ADC_RESOLUTION__) \
  1107. (((( ((int32_t)((__LL_ADC_CONVERT_DATA_RESOLUTION((__TEMPSENSOR_ADC_DATA__), \
  1108. (__ADC_RESOLUTION__), \
  1109. LL_ADC_RESOLUTION_12B) \
  1110. * (__VREFANALOG_VOLTAGE__)) \
  1111. / TEMPSENSOR_CAL_VREFANALOG) \
  1112. - (int32_t) *TEMPSENSOR_CAL1_ADDR) \
  1113. ) * (int32_t)(TEMPSENSOR_CAL2_TEMP - TEMPSENSOR_CAL1_TEMP) \
  1114. ) / (int32_t)((int32_t)*TEMPSENSOR_CAL2_ADDR - (int32_t)*TEMPSENSOR_CAL1_ADDR) \
  1115. ) + TEMPSENSOR_CAL1_TEMP \
  1116. )
  1117. /**
  1118. * @brief Helper macro to calculate the temperature (unit: degree Celsius)
  1119. * from ADC conversion data of internal temperature sensor.
  1120. * @note Computation is using temperature sensor calibration values
  1121. * stored in system memory for each device during production.
  1122. * @note Calculation formula:
  1123. * Temperature = ((TS_ADC_DATA - TS_CAL1)
  1124. * * (TS_CAL2_TEMP - TS_CAL1_TEMP))
  1125. * / (TS_CAL2 - TS_CAL1) + TS_CAL1_TEMP
  1126. * with TS_ADC_DATA = temperature sensor raw data measured by ADC
  1127. * Avg_Slope = (TS_CAL2 - TS_CAL1)
  1128. * / (TS_CAL2_TEMP - TS_CAL1_TEMP)
  1129. * TS_CAL1 = equivalent TS_ADC_DATA at temperature
  1130. * TEMP_DEGC_CAL1 (calibrated in factory)
  1131. * TS_CAL2 = equivalent TS_ADC_DATA at temperature
  1132. * TEMP_DEGC_CAL2 (calibrated in factory)
  1133. * Caution: Calculation relevancy under reserve that calibration
  1134. * parameters are correct (address and data).
  1135. * To calculate temperature using temperature sensor
  1136. * datasheet typical values (generic values less, therefore
  1137. * less accurate than calibrated values),
  1138. * use helper macro @ref __LL_ADC_CALC_TEMPERATURE_TYP_PARAMS().
  1139. * @note As calculation input, the analog reference voltage (Vref+) must be
  1140. * defined as it impacts the ADC LSB equivalent voltage.
  1141. * @note Analog reference voltage (Vref+) must be either known from
  1142. * user board environment or can be calculated using ADC measurement
  1143. * and ADC helper macro @ref __LL_ADC_CALC_VREFANALOG_VOLTAGE().
  1144. * @param __VREFANALOG_VOLTAGE__ Analog reference voltage (unit: mV)
  1145. * @param __TEMPSENSOR_ADC_DATA__ ADC conversion data of internal
  1146. * temperature sensor (unit: digital value).
  1147. * @param __ADC_RESOLUTION__ ADC resolution at which internal temperature
  1148. * sensor voltage has been measured.
  1149. * This parameter can be one of the following values:
  1150. * @arg @ref LL_ADC_RESOLUTION_12B
  1151. * @arg @ref LL_ADC_RESOLUTION_10B
  1152. * @arg @ref LL_ADC_RESOLUTION_8B
  1153. * @arg @ref LL_ADC_RESOLUTION_6B
  1154. * @retval Temperature (unit: degree Celsius)
  1155. */
  1156. #define __LL_ADC_CALC_TEMPERATURE_85(__VREFANALOG_VOLTAGE__,\
  1157. __TEMPSENSOR_ADC_DATA__,\
  1158. __ADC_RESOLUTION__) \
  1159. (((( ((int32_t)((__LL_ADC_CONVERT_DATA_RESOLUTION((__TEMPSENSOR_ADC_DATA__), \
  1160. (__ADC_RESOLUTION__), \
  1161. LL_ADC_RESOLUTION_12B) \
  1162. * (__VREFANALOG_VOLTAGE__)) \
  1163. / TEMPSENSOR_CAL_VREFANALOG) \
  1164. - (int32_t) *TEMPSENSOR_CAL1_ADDR) \
  1165. ) * (int32_t)(TEMPSENSOR_CAL2_TEMP - TEMPSENSOR_CAL1_TEMP) \
  1166. ) / (int32_t)((int32_t)*TEMPSENSOR_CAL2_ADDR - (int32_t)*TEMPSENSOR_CAL1_ADDR) \
  1167. ) + TEMPSENSOR_CAL1_TEMP \
  1168. )
  1169. /**
  1170. * @brief Helper macro to calculate the temperature (unit: degree Celsius)
  1171. * from ADC conversion data of internal temperature sensor.
  1172. * @note Computation is using temperature sensor calibration values
  1173. * stored in system memory for each device during production.
  1174. * @note Calculation formula:
  1175. * Temperature = ((TS_ADC_DATA - TS_CAL1)
  1176. * * (TS_CAL3_TEMP - TS_CAL1_TEMP))
  1177. * / (TS_CAL2 - TS_CAL1) + TS_CAL1_TEMP
  1178. * with TS_ADC_DATA = temperature sensor raw data measured by ADC
  1179. * Avg_Slope = (TS_CAL2 - TS_CAL1)
  1180. * / (TS_CAL3_TEMP - TS_CAL1_TEMP)
  1181. * TS_CAL1 = equivalent TS_ADC_DATA at temperature
  1182. * TEMP_DEGC_CAL1 (calibrated in factory)
  1183. * TS_CAL2 = equivalent TS_ADC_DATA at temperature
  1184. * TEMP_DEGC_CAL2 (calibrated in factory)
  1185. * Caution: Calculation relevancy under reserve that calibration
  1186. * parameters are correct (address and data).
  1187. * To calculate temperature using temperature sensor
  1188. * datasheet typical values (generic values less, therefore
  1189. * less accurate than calibrated values),
  1190. * use helper macro @ref __LL_ADC_CALC_TEMPERATURE_TYP_PARAMS().
  1191. * @note As calculation input, the analog reference voltage (Vref+) must be
  1192. * defined as it impacts the ADC LSB equivalent voltage.
  1193. * @note Analog reference voltage (Vref+) must be either known from
  1194. * user board environment or can be calculated using ADC measurement
  1195. * and ADC helper macro @ref __LL_ADC_CALC_VREFANALOG_VOLTAGE().
  1196. * @param __VREFANALOG_VOLTAGE__ Analog reference voltage (unit: mV)
  1197. * @param __TEMPSENSOR_ADC_DATA__ ADC conversion data of internal
  1198. * temperature sensor (unit: digital value).
  1199. * @param __ADC_RESOLUTION__ ADC resolution at which internal temperature
  1200. * sensor voltage has been measured.
  1201. * This parameter can be one of the following values:
  1202. * @arg @ref LL_ADC_RESOLUTION_12B
  1203. * @arg @ref LL_ADC_RESOLUTION_10B
  1204. * @arg @ref LL_ADC_RESOLUTION_8B
  1205. * @arg @ref LL_ADC_RESOLUTION_6B
  1206. * @retval Temperature (unit: degree Celsius)
  1207. */
  1208. #define __LL_ADC_CALC_TEMPERATURE_105(__VREFANALOG_VOLTAGE__,\
  1209. __TEMPSENSOR_ADC_DATA__,\
  1210. __ADC_RESOLUTION__) \
  1211. (((( ((int32_t)((__LL_ADC_CONVERT_DATA_RESOLUTION((__TEMPSENSOR_ADC_DATA__), \
  1212. (__ADC_RESOLUTION__), \
  1213. LL_ADC_RESOLUTION_12B) \
  1214. * (__VREFANALOG_VOLTAGE__)) \
  1215. / TEMPSENSOR_CAL_VREFANALOG) \
  1216. - (int32_t) *TEMPSENSOR_CAL1_ADDR) \
  1217. ) * (int32_t)(TEMPSENSOR_CAL3_TEMP - TEMPSENSOR_CAL1_TEMP) \
  1218. ) / (int32_t)((int32_t)*TEMPSENSOR_CAL2_ADDR - (int32_t)*TEMPSENSOR_CAL1_ADDR) \
  1219. ) + TEMPSENSOR_CAL1_TEMP \
  1220. )
  1221. /**
  1222. * @brief Helper macro to calculate the temperature (unit: degree Celsius)
  1223. * from ADC conversion data of internal temperature sensor.
  1224. * @note Computation is using temperature sensor typical values
  1225. * (refer to device datasheet).
  1226. * @note Calculation formula:
  1227. * Temperature = (TS_ADC_DATA * Conversion_uV-TS_TYP_CALx_VOLT(uV) )
  1228. * / Avg_Slope + CALx_TEMP
  1229. * with TS_ADC_DATA = temperature sensor raw data measured by ADC
  1230. * (unit: digital value)
  1231. * Avg_Slope = temperature sensor slope
  1232. * (unit: uV/Degree Celsius)
  1233. * TS_TYP_CALx_VOLT = temperature sensor digital value at
  1234. * temperature CALx_TEMP (unit: mV)
  1235. * Caution: Calculation relevancy under reserve the temperature sensor
  1236. * of the current device has characteristics in line with
  1237. * datasheet typical values.
  1238. * If temperature sensor calibration values are available on
  1239. * on this device (presence of macro __LL_ADC_CALC_TEMPERATURE()),
  1240. * temperature calculation will be more accurate using
  1241. * helper macro @ref __LL_ADC_CALC_TEMPERATURE().
  1242. * @note As calculation input, the analog reference voltage (Vref+) must be
  1243. * defined as it impacts the ADC LSB equivalent voltage.
  1244. * @note Analog reference voltage (Vref+) must be either known from
  1245. * user board environment or can be calculated using ADC measurement
  1246. * and ADC helper macro @ref __LL_ADC_CALC_VREFANALOG_VOLTAGE().
  1247. * @note ADC measurement data must correspond to a resolution of 12bits
  1248. * (full scale digital value 4095). If not the case, the data must be
  1249. * preliminarily rescaled to an equivalent resolution of 12 bits.
  1250. * @param __TEMPSENSOR_TYP_AVGSLOPE__ Device datasheet data: Temperature sensor slope typical value (unit: uV/DegCelsius).
  1251. * On PY32F0, refer to device datasheet parameter "Avg_Slope".
  1252. * @param __TEMPSENSOR_TYP_CALX_V__ Device datasheet data: Temperature sensor voltage typical value (at temperature and Vref+ defined in parameters below) (unit: mV).
  1253. * On PY32F0, refer to device datasheet parameter "V30" (corresponding to TS_CAL1).
  1254. * @param __TEMPSENSOR_CALX_TEMP__ Device datasheet data: Temperature at which temperature sensor voltage (see parameter above) is corresponding (unit: mV)
  1255. * @param __VREFANALOG_VOLTAGE__ Analog voltage reference (Vref+) voltage (unit: mV)
  1256. * @param __TEMPSENSOR_ADC_DATA__ ADC conversion data of internal temperature sensor (unit: digital value).
  1257. * @param __ADC_RESOLUTION__ ADC resolution at which internal temperature sensor voltage has been measured.
  1258. * This parameter can be one of the following values:
  1259. * @arg @ref LL_ADC_RESOLUTION_12B
  1260. * @arg @ref LL_ADC_RESOLUTION_10B
  1261. * @arg @ref LL_ADC_RESOLUTION_8B
  1262. * @arg @ref LL_ADC_RESOLUTION_6B
  1263. * @retval Temperature (unit: degree Celsius)
  1264. */
  1265. #define __LL_ADC_CALC_TEMPERATURE_TYP_PARAMS(__TEMPSENSOR_TYP_AVGSLOPE__,\
  1266. __TEMPSENSOR_TYP_CALX_V__,\
  1267. __TEMPSENSOR_CALX_TEMP__,\
  1268. __VREFANALOG_VOLTAGE__,\
  1269. __TEMPSENSOR_ADC_DATA__,\
  1270. __ADC_RESOLUTION__) \
  1271. (((( (int32_t)((((__TEMPSENSOR_ADC_DATA__) * (__VREFANALOG_VOLTAGE__)) \
  1272. / __LL_ADC_DIGITAL_SCALE(__ADC_RESOLUTION__)) \
  1273. * 1000)- (int32_t)(((__TEMPSENSOR_TYP_CALX_V__)) \
  1274. * 1000))) / (__TEMPSENSOR_TYP_AVGSLOPE__) \
  1275. ) + (__TEMPSENSOR_CALX_TEMP__) \
  1276. )
  1277. #if (defined(DMA) || defined(DMA1))
  1278. /**
  1279. * @}
  1280. */
  1281. /**
  1282. * @}
  1283. */
  1284. /* Exported functions --------------------------------------------------------*/
  1285. /** @defgroup ADC_LL_Exported_Functions ADC Exported Functions
  1286. * @{
  1287. */
  1288. /** @defgroup ADC_LL_EF_DMA_Management ADC DMA management
  1289. * @{
  1290. */
  1291. /* Note: LL ADC functions to set DMA transfer are located into sections of */
  1292. /* configuration of ADC instance, groups and multimode (if available): */
  1293. /* @ref LL_ADC_REG_SetDMATransfer(), ... */
  1294. /**
  1295. * @brief Function to help to configure DMA transfer from ADC: retrieve the
  1296. * ADC register address from ADC instance and a list of ADC registers
  1297. * intended to be used (most commonly) with DMA transfer.
  1298. * @note These ADC registers are data registers:
  1299. * when ADC conversion data is available in ADC data registers,
  1300. * ADC generates a DMA transfer request.
  1301. * @note This macro is intended to be used with LL DMA driver, refer to
  1302. * function "LL_DMA_ConfigAddresses()".
  1303. * Example:
  1304. * LL_DMA_ConfigAddresses(DMA1,
  1305. * LL_DMA_CHANNEL_1,
  1306. * LL_ADC_DMA_GetRegAddr(ADC1, LL_ADC_DMA_REG_REGULAR_DATA),
  1307. * (uint32_t)&< array or variable >,
  1308. * LL_DMA_DIRECTION_PERIPH_TO_MEMORY);
  1309. * @note For devices with several ADC: in multimode, some devices
  1310. * use a different data register outside of ADC instance scope
  1311. * (common data register). This macro manages this register difference,
  1312. * only ADC instance has to be set as parameter.
  1313. * @note Depending on devices and packages, DMA may not be available.
  1314. * Refer to device datasheet for DMA availability.
  1315. * @rmtoll DR DATA LL_ADC_DMA_GetRegAddr
  1316. * @param ADCx ADC instance
  1317. * @param Register This parameter can be one of the following values:
  1318. * @arg @ref LL_ADC_DMA_REG_REGULAR_DATA
  1319. * @retval ADC register address
  1320. */
  1321. __STATIC_INLINE uint32_t LL_ADC_DMA_GetRegAddr(ADC_TypeDef *ADCx, uint32_t Register)
  1322. {
  1323. /* Retrieve address of register DR */
  1324. return (uint32_t)&(ADCx->DR);
  1325. }
  1326. #endif
  1327. /**
  1328. * @}
  1329. */
  1330. /** @defgroup ADC_LL_EF_Configuration_ADC_Common Configuration of ADC hierarchical scope: common to several ADC instances
  1331. * @{
  1332. */
  1333. /**
  1334. * @brief Set parameter common to several ADC: measurement path to internal
  1335. * channels (VrefInt, temperature sensor, ...).
  1336. * @note One or several values can be selected.
  1337. * Example: (LL_ADC_PATH_INTERNAL_VREFINT |
  1338. * LL_ADC_PATH_INTERNAL_TEMPSENSOR)
  1339. * @note Stabilization time of measurement path to internal channel:
  1340. * After enabling internal paths, before starting ADC conversion,
  1341. * a delay is required for internal voltage reference and
  1342. * temperature sensor stabilization time.
  1343. * Refer to device datasheet.
  1344. * Refer to literal @ref LL_ADC_DELAY_VREFINT_STAB_US.
  1345. * Refer to literal @ref LL_ADC_DELAY_TEMPSENSOR_STAB_US.
  1346. * @note ADC internal channel sampling time constraint:
  1347. * For ADC conversion of internal channels,
  1348. * a sampling time minimum value is required.
  1349. * Refer to device datasheet.
  1350. * @note On this PY32 serie, setting of this feature is conditioned to
  1351. * ADC state:
  1352. * All ADC instances of the ADC common group must be disabled.
  1353. * This check can be done with function @ref LL_ADC_IsEnabled() for each
  1354. * ADC instance or by using helper macro helper macro
  1355. * @ref __LL_ADC_IS_ENABLED_ALL_COMMON_INSTANCE().
  1356. * @rmtoll CCR VREFEN LL_ADC_SetCommonPathInternalCh\n
  1357. * CCR TSEN LL_ADC_SetCommonPathInternalCh
  1358. * @param ADCxy_COMMON ADC common instance
  1359. * (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() )
  1360. * @param PathInternal This parameter can be a combination of the following values:
  1361. * @arg @ref LL_ADC_PATH_INTERNAL_NONE
  1362. * @arg @ref LL_ADC_PATH_INTERNAL_VREFINT
  1363. * @arg @ref LL_ADC_PATH_INTERNAL_TEMPSENSOR
  1364. * @retval None
  1365. */
  1366. __STATIC_INLINE void LL_ADC_SetCommonPathInternalCh(ADC_Common_TypeDef *ADCxy_COMMON, uint32_t PathInternal)
  1367. {
  1368. MODIFY_REG(ADCxy_COMMON->CCR, ADC_CCR_VREFEN | ADC_CCR_TSEN, PathInternal);
  1369. }
  1370. /**
  1371. * @brief Get parameter common to several ADC: measurement path to internal
  1372. * channels (VrefInt, temperature sensor, ...).
  1373. * @note One or several values can be selected.
  1374. * Example: (LL_ADC_PATH_INTERNAL_VREFINT |
  1375. * LL_ADC_PATH_INTERNAL_TEMPSENSOR)
  1376. * @rmtoll CCR VREFEN LL_ADC_GetCommonPathInternalCh\n
  1377. * CCR TSEN LL_ADC_GetCommonPathInternalCh
  1378. * @param ADCxy_COMMON ADC common instance
  1379. * (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() )
  1380. * @retval Returned value can be a combination of the following values:
  1381. * @arg @ref LL_ADC_PATH_INTERNAL_NONE
  1382. * @arg @ref LL_ADC_PATH_INTERNAL_VREFINT
  1383. * @arg @ref LL_ADC_PATH_INTERNAL_TEMPSENSOR
  1384. */
  1385. __STATIC_INLINE uint32_t LL_ADC_GetCommonPathInternalCh(ADC_Common_TypeDef *ADCxy_COMMON)
  1386. {
  1387. return (uint32_t)(READ_BIT(ADCxy_COMMON->CCR, ADC_CCR_VREFEN | ADC_CCR_TSEN));
  1388. }
  1389. /**
  1390. * @}
  1391. */
  1392. /** @defgroup ADC_LL_EF_Configuration_ADC_Instance Configuration of ADC hierarchical scope: ADC instance
  1393. * @{
  1394. */
  1395. /**
  1396. * @brief Set ADC instance clock source and prescaler.
  1397. * @note On this PY32 serie, setting of this feature is conditioned to
  1398. * ADC state:
  1399. * ADC must be disabled.
  1400. * @rmtoll CFGR2 CKMODE LL_ADC_SetClock
  1401. * @param ADCx ADC instance
  1402. * @param ClockSource This parameter can be one of the following values:
  1403. * @arg @ref LL_ADC_CLOCK_SYNC_PCLK_DIV1
  1404. * @arg @ref LL_ADC_CLOCK_SYNC_PCLK_DIV2
  1405. * @arg @ref LL_ADC_CLOCK_SYNC_PCLK_DIV4
  1406. * @arg @ref LL_ADC_CLOCK_SYNC_PCLK_DIV8
  1407. * @arg @ref LL_ADC_CLOCK_SYNC_PCLK_DIV16
  1408. * @arg @ref LL_ADC_CLOCK_SYNC_PCLK_DIV32
  1409. * @arg @ref LL_ADC_CLOCK_SYNC_PCLK_DIV64
  1410. * @arg @ref LL_ADC_CLOCK_ASYNC_HSI_DIV1
  1411. * @arg @ref LL_ADC_CLOCK_ASYNC_HSI_DIV2
  1412. * @arg @ref LL_ADC_CLOCK_ASYNC_HSI_DIV4
  1413. * @arg @ref LL_ADC_CLOCK_ASYNC_HSI_DIV8
  1414. * @arg @ref LL_ADC_CLOCK_ASYNC_HSI_DIV16
  1415. * @arg @ref LL_ADC_CLOCK_ASYNC_HSI_DIV32
  1416. * @arg @ref LL_ADC_CLOCK_ASYNC_HSI_DIV64
  1417. * @retval None
  1418. */
  1419. __STATIC_INLINE void LL_ADC_SetClock(ADC_TypeDef *ADCx, uint32_t ClockSource)
  1420. {
  1421. MODIFY_REG(ADCx->CFGR2, ADC_CFGR2_CKMODE, ClockSource);
  1422. }
  1423. /**
  1424. * @brief Get ADC instance clock source and prescaler.
  1425. * @rmtoll CFGR2 CKMODE LL_ADC_GetClock
  1426. * @param ADCx ADC instance
  1427. * @retval Returned value can be one of the following values:
  1428. * @arg @ref LL_ADC_CLOCK_SYNC_PCLK_DIV1
  1429. * @arg @ref LL_ADC_CLOCK_SYNC_PCLK_DIV2
  1430. * @arg @ref LL_ADC_CLOCK_SYNC_PCLK_DIV4
  1431. * @arg @ref LL_ADC_CLOCK_SYNC_PCLK_DIV8
  1432. * @arg @ref LL_ADC_CLOCK_SYNC_PCLK_DIV16
  1433. * @arg @ref LL_ADC_CLOCK_SYNC_PCLK_DIV32
  1434. * @arg @ref LL_ADC_CLOCK_SYNC_PCLK_DIV64
  1435. * @arg @ref LL_ADC_CLOCK_ASYNC_HSI_DIV1
  1436. * @arg @ref LL_ADC_CLOCK_ASYNC_HSI_DIV2
  1437. * @arg @ref LL_ADC_CLOCK_ASYNC_HSI_DIV4
  1438. * @arg @ref LL_ADC_CLOCK_ASYNC_HSI_DIV8
  1439. * @arg @ref LL_ADC_CLOCK_ASYNC_HSI_DIV16
  1440. * @arg @ref LL_ADC_CLOCK_ASYNC_HSI_DIV32
  1441. * @arg @ref LL_ADC_CLOCK_ASYNC_HSI_DIV64
  1442. */
  1443. __STATIC_INLINE uint32_t LL_ADC_GetClock(ADC_TypeDef *ADCx)
  1444. {
  1445. return (uint32_t)(READ_BIT(ADCx->CFGR2, ADC_CFGR2_CKMODE));
  1446. }
  1447. /**
  1448. * @brief Set ADC resolution.
  1449. * Refer to reference manual for alignments formats
  1450. * dependencies to ADC resolutions.
  1451. * @note On this PY32 serie, setting of this feature is conditioned to
  1452. * ADC state:
  1453. * ADC must be disabled or enabled without conversion on going
  1454. * on group regular.
  1455. * @rmtoll CFGR1 RES LL_ADC_SetResolution
  1456. * @param ADCx ADC instance
  1457. * @param Resolution This parameter can be one of the following values:
  1458. * @arg @ref LL_ADC_RESOLUTION_12B
  1459. * @arg @ref LL_ADC_RESOLUTION_10B
  1460. * @arg @ref LL_ADC_RESOLUTION_8B
  1461. * @arg @ref LL_ADC_RESOLUTION_6B
  1462. * @retval None
  1463. */
  1464. __STATIC_INLINE void LL_ADC_SetResolution(ADC_TypeDef *ADCx, uint32_t Resolution)
  1465. {
  1466. MODIFY_REG(ADCx->CFGR1, ADC_CFGR1_RESSEL, Resolution);
  1467. }
  1468. /**
  1469. * @brief Get ADC resolution.
  1470. * Refer to reference manual for alignments formats
  1471. * dependencies to ADC resolutions.
  1472. * @rmtoll CFGR1 RES LL_ADC_GetResolution
  1473. * @param ADCx ADC instance
  1474. * @retval Returned value can be one of the following values:
  1475. * @arg @ref LL_ADC_RESOLUTION_12B
  1476. * @arg @ref LL_ADC_RESOLUTION_10B
  1477. * @arg @ref LL_ADC_RESOLUTION_8B
  1478. * @arg @ref LL_ADC_RESOLUTION_6B
  1479. */
  1480. __STATIC_INLINE uint32_t LL_ADC_GetResolution(ADC_TypeDef *ADCx)
  1481. {
  1482. return (uint32_t)(READ_BIT(ADCx->CFGR1, ADC_CFGR1_RESSEL));
  1483. }
  1484. /**
  1485. * @brief Set ADC conversion data alignment.
  1486. * @note Refer to reference manual for alignments formats
  1487. * dependencies to ADC resolutions.
  1488. * @note On this PY32 serie, setting of this feature is conditioned to
  1489. * ADC state:
  1490. * ADC must be disabled or enabled without conversion on going
  1491. * on group regular.
  1492. * @rmtoll CFGR1 ALIGN LL_ADC_SetDataAlignment
  1493. * @param ADCx ADC instance
  1494. * @param DataAlignment This parameter can be one of the following values:
  1495. * @arg @ref LL_ADC_DATA_ALIGN_RIGHT
  1496. * @arg @ref LL_ADC_DATA_ALIGN_LEFT
  1497. * @retval None
  1498. */
  1499. __STATIC_INLINE void LL_ADC_SetDataAlignment(ADC_TypeDef *ADCx, uint32_t DataAlignment)
  1500. {
  1501. MODIFY_REG(ADCx->CFGR1, ADC_CFGR1_ALIGN, DataAlignment);
  1502. }
  1503. /**
  1504. * @brief Get ADC conversion data alignment.
  1505. * @note Refer to reference manual for alignments formats
  1506. * dependencies to ADC resolutions.
  1507. * @rmtoll CFGR1 ALIGN LL_ADC_GetDataAlignment
  1508. * @param ADCx ADC instance
  1509. * @retval Returned value can be one of the following values:
  1510. * @arg @ref LL_ADC_DATA_ALIGN_RIGHT
  1511. * @arg @ref LL_ADC_DATA_ALIGN_LEFT
  1512. */
  1513. __STATIC_INLINE uint32_t LL_ADC_GetDataAlignment(ADC_TypeDef *ADCx)
  1514. {
  1515. return (uint32_t)(READ_BIT(ADCx->CFGR1, ADC_CFGR1_ALIGN));
  1516. }
  1517. /**
  1518. * @brief Set ADC low power mode.
  1519. * @note Description of ADC low power modes:
  1520. * - ADC low power mode "auto wait": Dynamic low power mode,
  1521. * ADC conversions occurrences are limited to the minimum necessary
  1522. * in order to reduce power consumption.
  1523. * New ADC conversion starts only when the previous
  1524. * unitary conversion data (for ADC group regular)
  1525. * has been retrieved by user software.
  1526. * In the meantime, ADC remains idle: does not performs any
  1527. * other conversion.
  1528. * This mode allows to automatically adapt the ADC conversions
  1529. * triggers to the speed of the software that reads the data.
  1530. * Moreover, this avoids risk of overrun for low frequency
  1531. * applications.
  1532. * How to use this low power mode:
  1533. * - Do not use with interruption or DMA since these modes
  1534. * have to clear immediately the EOC flag to free the
  1535. * IRQ vector sequencer.
  1536. * - Do use with polling: 1. Start conversion,
  1537. * 2. Later on, when conversion data is needed: poll for end of
  1538. * conversion to ensure that conversion is completed and
  1539. * retrieve ADC conversion data. This will trig another
  1540. * ADC conversion start.
  1541. *
  1542. * @note With ADC low power mode "auto wait", the ADC conversion data read
  1543. * is corresponding to previous ADC conversion start, independently
  1544. * of delay during which ADC was idle.
  1545. * Therefore, the ADC conversion data may be outdated: does not
  1546. * correspond to the current voltage level on the selected
  1547. * ADC channel.
  1548. * @note On this PY32 serie, setting of this feature is conditioned to
  1549. * ADC state:
  1550. * ADC must be disabled or enabled without conversion on going
  1551. * on group regular.
  1552. * @note Depending on devices and packages, DMA may not be available.
  1553. * Refer to device datasheet for DMA availability.
  1554. * @rmtoll CFGR1 WAIT LL_ADC_SetLowPowerMode
  1555. * @param ADCx ADC instance
  1556. * @param LowPowerMode This parameter can be one of the following values:
  1557. * @arg @ref LL_ADC_LP_MODE_NONE
  1558. * @arg @ref LL_ADC_LP_AUTOWAIT
  1559. * @retval None
  1560. */
  1561. __STATIC_INLINE void LL_ADC_SetLowPowerMode(ADC_TypeDef *ADCx, uint32_t LowPowerMode)
  1562. {
  1563. MODIFY_REG(ADCx->CFGR1, (ADC_CFGR1_WAIT), LowPowerMode);
  1564. }
  1565. /**
  1566. * @brief Get ADC low power mode:
  1567. * @note Description of ADC low power modes:
  1568. * - ADC low power mode "auto wait": Dynamic low power mode,
  1569. * ADC conversions occurrences are limited to the minimum necessary
  1570. * in order to reduce power consumption.
  1571. * New ADC conversion starts only when the previous
  1572. * unitary conversion data (for ADC group regular)
  1573. * has been retrieved by user software.
  1574. * In the meantime, ADC remains idle: does not performs any
  1575. * other conversion.
  1576. * This mode allows to automatically adapt the ADC conversions
  1577. * triggers to the speed of the software that reads the data.
  1578. * Moreover, this avoids risk of overrun for low frequency
  1579. * applications.
  1580. * How to use this low power mode:
  1581. * - Do not use with interruption or DMA since these modes
  1582. * have to clear immediately the EOC flag to free the
  1583. * IRQ vector sequencer.
  1584. * - Do use with polling: 1. Start conversion,
  1585. * 2. Later on, when conversion data is needed: poll for end of
  1586. * conversion to ensure that conversion is completed and
  1587. * retrieve ADC conversion data. This will trig another
  1588. * ADC conversion start.
  1589. * This feature can be combined with low power mode "auto wait".
  1590. * @note With ADC low power mode "auto wait", the ADC conversion data read
  1591. * is corresponding to previous ADC conversion start, independently
  1592. * of delay during which ADC was idle.
  1593. * Therefore, the ADC conversion data may be outdated: does not
  1594. * correspond to the current voltage level on the selected
  1595. * ADC channel.
  1596. * @note Depending on devices and packages, DMA may not be available.
  1597. * Refer to device datasheet for DMA availability.
  1598. * @rmtoll CFGR1 WAIT LL_ADC_GetLowPowerMode
  1599. * @param ADCx ADC instance
  1600. * @retval Returned value can be one of the following values:
  1601. * @arg @ref LL_ADC_LP_MODE_NONE
  1602. * @arg @ref LL_ADC_LP_AUTOWAIT
  1603. */
  1604. __STATIC_INLINE uint32_t LL_ADC_GetLowPowerMode(ADC_TypeDef *ADCx)
  1605. {
  1606. return (uint32_t)(READ_BIT(ADCx->CFGR1, (ADC_CFGR1_WAIT )));
  1607. }
  1608. /**
  1609. * @brief Set sampling time common to a group of channels.
  1610. * @note Unit: ADC clock cycles.
  1611. * @note On this PY32 serie, sampling time scope is on ADC instance:
  1612. * Sampling time common to all channels.
  1613. * (on some other PY32 families, sampling time is channel wise)
  1614. * @note In case of internal channel (VrefInt, TempSensor, ...) to be
  1615. * converted:
  1616. * sampling time constraints must be respected (sampling time can be
  1617. * adjusted in function of ADC clock frequency and sampling time
  1618. * setting).
  1619. * Refer to device datasheet for timings values (parameters TS_vrefint,
  1620. * TS_temp, ...).
  1621. * @note Conversion time is the addition of sampling time and processing time.
  1622. * On this PY32 serie, ADC processing time is:
  1623. * - 12.5 ADC clock cycles at ADC resolution 12 bits
  1624. * - 10.5 ADC clock cycles at ADC resolution 10 bits
  1625. * - 8.5 ADC clock cycles at ADC resolution 8 bits
  1626. * - 6.5 ADC clock cycles at ADC resolution 6 bits
  1627. * @note In case of ADC conversion of internal channel (VrefInt,
  1628. * temperature sensor, ...), a sampling time minimum value
  1629. * is required.
  1630. * Refer to device datasheet.
  1631. * @note On this PY32 serie, setting of this feature is conditioned to
  1632. * ADC state:
  1633. * ADC must be disabled or enabled without conversion on going
  1634. * on group regular.
  1635. * @rmtoll SMPR SMP LL_ADC_SetSamplingTimeCommonChannels
  1636. * @param ADCx ADC instance
  1637. * @param SamplingTime This parameter can be one of the following values:
  1638. * @arg @ref LL_ADC_SAMPLINGTIME_3CYCLES_5
  1639. * @arg @ref LL_ADC_SAMPLINGTIME_5CYCLES_5
  1640. * @arg @ref LL_ADC_SAMPLINGTIME_7CYCLES_5
  1641. * @arg @ref LL_ADC_SAMPLINGTIME_13CYCLES_5
  1642. * @arg @ref LL_ADC_SAMPLINGTIME_28CYCLES_5
  1643. * @arg @ref LL_ADC_SAMPLINGTIME_41CYCLES_5
  1644. * @arg @ref LL_ADC_SAMPLINGTIME_71CYCLES_5
  1645. * @arg @ref LL_ADC_SAMPLINGTIME_239CYCLES_5
  1646. * @retval None
  1647. */
  1648. __STATIC_INLINE void LL_ADC_SetSamplingTimeCommonChannels(ADC_TypeDef *ADCx, uint32_t SamplingTime)
  1649. {
  1650. MODIFY_REG(ADCx->SMPR, ADC_SMPR_SMP, SamplingTime);
  1651. }
  1652. /**
  1653. * @brief Get sampling time common to a group of channels.
  1654. * @note Unit: ADC clock cycles.
  1655. * @note On this PY32 serie, sampling time scope is on ADC instance:
  1656. * Sampling time common to all channels.
  1657. * (on some other PY32 families, sampling time is channel wise)
  1658. * @note Conversion time is the addition of sampling time and processing time.
  1659. * Refer to reference manual for ADC processing time of
  1660. * this PY32 serie.
  1661. * @rmtoll SMPR SMP LL_ADC_GetSamplingTimeCommonChannels
  1662. * @param ADCx ADC instance
  1663. * @retval Returned value can be one of the following values:
  1664. * @arg @ref LL_ADC_SAMPLINGTIME_3CYCLES_5
  1665. * @arg @ref LL_ADC_SAMPLINGTIME_5CYCLES_5
  1666. * @arg @ref LL_ADC_SAMPLINGTIME_7CYCLES_5
  1667. * @arg @ref LL_ADC_SAMPLINGTIME_13CYCLES_5
  1668. * @arg @ref LL_ADC_SAMPLINGTIME_28CYCLES_5
  1669. * @arg @ref LL_ADC_SAMPLINGTIME_41CYCLES_5
  1670. * @arg @ref LL_ADC_SAMPLINGTIME_71CYCLES_5
  1671. * @arg @ref LL_ADC_SAMPLINGTIME_239CYCLES_5
  1672. */
  1673. __STATIC_INLINE uint32_t LL_ADC_GetSamplingTimeCommonChannels(ADC_TypeDef *ADCx)
  1674. {
  1675. return (uint32_t)(READ_BIT(ADCx->SMPR, ADC_SMPR_SMP));
  1676. }
  1677. /**
  1678. * @}
  1679. */
  1680. /** @defgroup ADC_LL_EF_Configuration_ADC_Group_Regular Configuration of ADC hierarchical scope: group regular
  1681. * @{
  1682. */
  1683. /**
  1684. * @brief Set ADC group regular conversion trigger source:
  1685. * internal (SW start) or from external IP (timer event,
  1686. * external interrupt line).
  1687. * @note On this PY32 serie, setting trigger source to external trigger
  1688. * also set trigger polarity to rising edge
  1689. * (default setting for compatibility with some ADC on other
  1690. * PY32 families having this setting set by HW default value).
  1691. * In case of need to modify trigger edge, use
  1692. * function @ref LL_ADC_REG_SetTriggerEdge().
  1693. * @note Availability of parameters of trigger sources from timer
  1694. * depends on timers availability on the selected device.
  1695. * @note On this PY32 serie, setting of this feature is conditioned to
  1696. * ADC state:
  1697. * ADC must be disabled or enabled without conversion on going
  1698. * on group regular.
  1699. * @rmtoll CFGR1 EXTSEL LL_ADC_REG_SetTriggerSource\n
  1700. * CFGR1 EXTEN LL_ADC_REG_SetTriggerSource
  1701. * @param ADCx ADC instance
  1702. * @param TriggerSource This parameter can be one of the following values:
  1703. * @arg @ref LL_ADC_REG_TRIG_SOFTWARE
  1704. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM1_TRGO
  1705. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM1_CH4
  1706. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM3_TRGO
  1707. * @retval None
  1708. */
  1709. __STATIC_INLINE void LL_ADC_REG_SetTriggerSource(ADC_TypeDef *ADCx, uint32_t TriggerSource)
  1710. {
  1711. MODIFY_REG(ADCx->CFGR1, ADC_CFGR1_EXTEN | ADC_CFGR1_EXTSEL, TriggerSource);
  1712. }
  1713. /**
  1714. * @brief Get ADC group regular conversion trigger source:
  1715. * internal (SW start) or from external IP (timer event,
  1716. * external interrupt line).
  1717. * @note To determine whether group regular trigger source is
  1718. * internal (SW start) or external, without detail
  1719. * of which peripheral is selected as external trigger,
  1720. * (equivalent to
  1721. * "if(LL_ADC_REG_GetTriggerSource(ADC1) == LL_ADC_REG_TRIG_SOFTWARE)")
  1722. * use function @ref LL_ADC_REG_IsTriggerSourceSWStart.
  1723. * @note Availability of parameters of trigger sources from timer
  1724. * depends on timers availability on the selected device.
  1725. * @rmtoll CFGR1 EXTSEL LL_ADC_REG_GetTriggerSource\n
  1726. * CFGR1 EXTEN LL_ADC_REG_GetTriggerSource
  1727. * @param ADCx ADC instance
  1728. * @retval Returned value can be one of the following values:
  1729. * @arg @ref LL_ADC_REG_TRIG_SOFTWARE
  1730. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM1_TRGO
  1731. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM1_CH4
  1732. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM3_TRGO
  1733. */
  1734. __STATIC_INLINE uint32_t LL_ADC_REG_GetTriggerSource(ADC_TypeDef *ADCx)
  1735. {
  1736. register uint32_t TriggerSource = READ_BIT(ADCx->CFGR1, ADC_CFGR1_EXTSEL | ADC_CFGR1_EXTEN);
  1737. /* Value for shift of {0; 4; 8; 12} depending on value of bitfield */
  1738. /* corresponding to ADC_CFGR1_EXTEN {0; 1; 2; 3}. */
  1739. register uint32_t ShiftExten = ((TriggerSource & ADC_CFGR1_EXTEN) >> (ADC_REG_TRIG_EXTEN_BITOFFSET_POS - 2U));
  1740. /* Set bitfield corresponding to ADC_CFGR1_EXTEN and ADC_CFGR1_EXTSEL */
  1741. /* to match with triggers literals definition. */
  1742. return ((TriggerSource
  1743. & (ADC_REG_TRIG_SOURCE_MASK >> ShiftExten) & ADC_CFGR1_EXTSEL)
  1744. | ((ADC_REG_TRIG_EDGE_MASK >> ShiftExten) & ADC_CFGR1_EXTEN)
  1745. );
  1746. }
  1747. /**
  1748. * @brief Get ADC group regular conversion trigger source internal (SW start)
  1749. * or external.
  1750. * @note In case of group regular trigger source set to external trigger,
  1751. * to determine which peripheral is selected as external trigger,
  1752. * use function @ref LL_ADC_REG_GetTriggerSource().
  1753. * @rmtoll CFGR1 EXTEN LL_ADC_REG_IsTriggerSourceSWStart
  1754. * @param ADCx ADC instance
  1755. * @retval Value "0" if trigger source external trigger
  1756. * Value "1" if trigger source SW start.
  1757. */
  1758. __STATIC_INLINE uint32_t LL_ADC_REG_IsTriggerSourceSWStart(ADC_TypeDef *ADCx)
  1759. {
  1760. return (READ_BIT(ADCx->CFGR1, ADC_CFGR1_EXTEN) == (LL_ADC_REG_TRIG_SOFTWARE & ADC_CFGR1_EXTEN));
  1761. }
  1762. /**
  1763. * @brief Set ADC group regular conversion trigger polarity.
  1764. * @note Applicable only for trigger source set to external trigger.
  1765. * @note On this PY32 serie, setting of this feature is conditioned to
  1766. * ADC state:
  1767. * ADC must be disabled or enabled without conversion on going
  1768. * on group regular.
  1769. * @rmtoll CFGR1 EXTEN LL_ADC_REG_SetTriggerEdge
  1770. * @param ADCx ADC instance
  1771. * @param ExternalTriggerEdge This parameter can be one of the following values:
  1772. * @arg @ref LL_ADC_REG_TRIG_EXT_RISING
  1773. * @arg @ref LL_ADC_REG_TRIG_EXT_FALLING
  1774. * @arg @ref LL_ADC_REG_TRIG_EXT_RISINGFALLING
  1775. * @retval None
  1776. */
  1777. __STATIC_INLINE void LL_ADC_REG_SetTriggerEdge(ADC_TypeDef *ADCx, uint32_t ExternalTriggerEdge)
  1778. {
  1779. MODIFY_REG(ADCx->CFGR1, ADC_CFGR1_EXTEN, ExternalTriggerEdge);
  1780. }
  1781. /**
  1782. * @brief Get ADC group regular conversion trigger polarity.
  1783. * @note Applicable only for trigger source set to external trigger.
  1784. * @rmtoll CFGR1 EXTEN LL_ADC_REG_GetTriggerEdge
  1785. * @param ADCx ADC instance
  1786. * @retval Returned value can be one of the following values:
  1787. * @arg @ref LL_ADC_REG_TRIG_EXT_RISING
  1788. * @arg @ref LL_ADC_REG_TRIG_EXT_FALLING
  1789. * @arg @ref LL_ADC_REG_TRIG_EXT_RISINGFALLING
  1790. */
  1791. __STATIC_INLINE uint32_t LL_ADC_REG_GetTriggerEdge(ADC_TypeDef *ADCx)
  1792. {
  1793. return (uint32_t)(READ_BIT(ADCx->CFGR1, ADC_CFGR1_EXTEN));
  1794. }
  1795. /**
  1796. * @brief Set ADC group regular sequencer scan direction.
  1797. * @note On some other PY32 families, this setting is not available and
  1798. * the default scan direction is forward.
  1799. * @note On this PY32 serie, setting of this feature is conditioned to
  1800. * ADC state:
  1801. * ADC must be disabled or enabled without conversion on going
  1802. * on group regular.
  1803. * @rmtoll CFGR1 SCANDIR LL_ADC_REG_SetSequencerScanDirection
  1804. * @param ADCx ADC instance
  1805. * @param ScanDirection This parameter can be one of the following values:
  1806. * @arg @ref LL_ADC_REG_SEQ_SCAN_DIR_FORWARD
  1807. * @arg @ref LL_ADC_REG_SEQ_SCAN_DIR_BACKWARD
  1808. * @retval None
  1809. */
  1810. __STATIC_INLINE void LL_ADC_REG_SetSequencerScanDirection(ADC_TypeDef *ADCx, uint32_t ScanDirection)
  1811. {
  1812. MODIFY_REG(ADCx->CFGR1, ADC_CFGR1_SCANDIR, ScanDirection);
  1813. }
  1814. /**
  1815. * @brief Get ADC group regular sequencer scan direction.
  1816. * @note On some other PY32 families, this setting is not available and
  1817. * the default scan direction is forward.
  1818. * @rmtoll CFGR1 SCANDIR LL_ADC_REG_GetSequencerScanDirection
  1819. * @param ADCx ADC instance
  1820. * @retval Returned value can be one of the following values:
  1821. * @arg @ref LL_ADC_REG_SEQ_SCAN_DIR_FORWARD
  1822. * @arg @ref LL_ADC_REG_SEQ_SCAN_DIR_BACKWARD
  1823. */
  1824. __STATIC_INLINE uint32_t LL_ADC_REG_GetSequencerScanDirection(ADC_TypeDef *ADCx)
  1825. {
  1826. return (uint32_t)(READ_BIT(ADCx->CFGR1, ADC_CFGR1_SCANDIR));
  1827. }
  1828. /**
  1829. * @brief Set ADC group regular sequencer discontinuous mode:
  1830. * sequence subdivided and scan conversions interrupted every selected
  1831. * number of ranks.
  1832. * @note It is not possible to enable both ADC group regular
  1833. * continuous mode and sequencer discontinuous mode.
  1834. * @note On this PY32 serie, setting of this feature is conditioned to
  1835. * ADC state:
  1836. * ADC must be disabled or enabled without conversion on going
  1837. * on group regular.
  1838. * @rmtoll CFGR1 DISCEN LL_ADC_REG_SetSequencerDiscont\n
  1839. * @param ADCx ADC instance
  1840. * @param SeqDiscont This parameter can be one of the following values:
  1841. * @arg @ref LL_ADC_REG_SEQ_DISCONT_DISABLE
  1842. * @arg @ref LL_ADC_REG_SEQ_DISCONT_1RANK
  1843. * @retval None
  1844. */
  1845. __STATIC_INLINE void LL_ADC_REG_SetSequencerDiscont(ADC_TypeDef *ADCx, uint32_t SeqDiscont)
  1846. {
  1847. MODIFY_REG(ADCx->CFGR1, ADC_CFGR1_DISCEN, SeqDiscont);
  1848. }
  1849. /**
  1850. * @brief Get ADC group regular sequencer discontinuous mode:
  1851. * sequence subdivided and scan conversions interrupted every selected
  1852. * number of ranks.
  1853. * @rmtoll CFGR1 DISCEN LL_ADC_REG_GetSequencerDiscont\n
  1854. * @param ADCx ADC instance
  1855. * @retval Returned value can be one of the following values:
  1856. * @arg @ref LL_ADC_REG_SEQ_DISCONT_DISABLE
  1857. * @arg @ref LL_ADC_REG_SEQ_DISCONT_1RANK
  1858. */
  1859. __STATIC_INLINE uint32_t LL_ADC_REG_GetSequencerDiscont(ADC_TypeDef *ADCx)
  1860. {
  1861. return (uint32_t)(READ_BIT(ADCx->CFGR1, ADC_CFGR1_DISCEN));
  1862. }
  1863. /**
  1864. * @brief Set ADC group regular sequence: channel on rank corresponding to
  1865. * channel number.
  1866. * @note This function performs:
  1867. * - Channels ordering into each rank of scan sequence:
  1868. * rank of each channel is fixed by channel HW number
  1869. * (channel 0 fixed on rank 0, channel 1 fixed on rank1, ...).
  1870. * - Set channels selected by overwriting the current sequencer
  1871. * configuration.
  1872. * @note On this PY32 serie, ADC group regular sequencer is
  1873. * not fully configurable: sequencer length and each rank
  1874. * affectation to a channel are fixed by channel HW number.
  1875. * @note Depending on devices and packages, some channels may not be available.
  1876. * Refer to device datasheet for channels availability.
  1877. * @note On this PY32 serie, to measure internal channels (VrefInt,
  1878. * TempSensor, ...), measurement paths to internal channels must be
  1879. * enabled separately.
  1880. * This can be done using function @ref LL_ADC_SetCommonPathInternalCh().
  1881. * @note On this PY32 serie, setting of this feature is conditioned to
  1882. * ADC state:
  1883. * ADC must be disabled or enabled without conversion on going
  1884. * on group regular.
  1885. * @note One or several values can be selected.
  1886. * Example: (LL_ADC_CHANNEL_4 | LL_ADC_CHANNEL_12 | ...)
  1887. * @rmtoll CHSELR CHSEL0 LL_ADC_REG_SetSequencerChannels\n
  1888. * CHSELR CHSEL1 LL_ADC_REG_SetSequencerChannels\n
  1889. * CHSELR CHSEL2 LL_ADC_REG_SetSequencerChannels\n
  1890. * CHSELR CHSEL3 LL_ADC_REG_SetSequencerChannels\n
  1891. * CHSELR CHSEL4 LL_ADC_REG_SetSequencerChannels\n
  1892. * CHSELR CHSEL5 LL_ADC_REG_SetSequencerChannels\n
  1893. * CHSELR CHSEL6 LL_ADC_REG_SetSequencerChannels\n
  1894. * CHSELR CHSEL7 LL_ADC_REG_SetSequencerChannels\n
  1895. * CHSELR CHSEL8 LL_ADC_REG_SetSequencerChannels\n
  1896. * CHSELR CHSEL9 LL_ADC_REG_SetSequencerChannels\n
  1897. * CHSELR CHSEL11 LL_ADC_REG_SetSequencerChannels\n
  1898. * CHSELR CHSEL12 LL_ADC_REG_SetSequencerChannels
  1899. * @param ADCx ADC instance
  1900. * @param Channel This parameter can be a combination of the following values:
  1901. * @arg @ref LL_ADC_CHANNEL_0
  1902. * @arg @ref LL_ADC_CHANNEL_1
  1903. * @arg @ref LL_ADC_CHANNEL_2
  1904. * @arg @ref LL_ADC_CHANNEL_3
  1905. * @arg @ref LL_ADC_CHANNEL_4
  1906. * @arg @ref LL_ADC_CHANNEL_5
  1907. * @arg @ref LL_ADC_CHANNEL_6
  1908. * @arg @ref LL_ADC_CHANNEL_7
  1909. * @arg @ref LL_ADC_CHANNEL_8
  1910. * @arg @ref LL_ADC_CHANNEL_9
  1911. * @arg @ref LL_ADC_CHANNEL_11
  1912. * @arg @ref LL_ADC_CHANNEL_12
  1913. * @arg @ref LL_ADC_CHANNEL_VREFINT
  1914. * @arg @ref LL_ADC_CHANNEL_TEMPSENSOR
  1915. * @retval None
  1916. */
  1917. __STATIC_INLINE void LL_ADC_REG_SetSequencerChannels(ADC_TypeDef *ADCx, uint32_t Channel)
  1918. {
  1919. /* Parameter "Channel" is used with masks because containing */
  1920. /* other bits reserved for other purpose. */
  1921. WRITE_REG(ADCx->CHSELR, (Channel & ADC_CHANNEL_ID_BITFIELD_MASK));
  1922. }
  1923. /**
  1924. * @brief Add channel to ADC group regular sequence: channel on rank corresponding to
  1925. * channel number.
  1926. * @note This function performs:
  1927. * - Channels ordering into each rank of scan sequence:
  1928. * rank of each channel is fixed by channel HW number
  1929. * (channel 0 fixed on rank 0, channel 1 fixed on rank1, ...).
  1930. * - Set channels selected by adding them to the current sequencer
  1931. * configuration.
  1932. * @note On this PY32 serie, ADC group regular sequencer is
  1933. * not fully configurable: sequencer length and each rank
  1934. * affectation to a channel are fixed by channel HW number.
  1935. * @note Depending on devices and packages, some channels may not be available.
  1936. * Refer to device datasheet for channels availability.
  1937. * @note On this PY32 serie, to measure internal channels (VrefInt,
  1938. * TempSensor, ...), measurement paths to internal channels must be
  1939. * enabled separately.
  1940. * This can be done using function @ref LL_ADC_SetCommonPathInternalCh().
  1941. * @note On this PY32 serie, setting of this feature is conditioned to
  1942. * ADC state:
  1943. * ADC must be disabled or enabled without conversion on going
  1944. * on group regular.
  1945. * @note One or several values can be selected.
  1946. * Example: (LL_ADC_CHANNEL_4 | LL_ADC_CHANNEL_12 | ...)
  1947. * @rmtoll CHSELR CHSEL0 LL_ADC_REG_SetSequencerChAdd\n
  1948. * CHSELR CHSEL1 LL_ADC_REG_SetSequencerChAdd\n
  1949. * CHSELR CHSEL2 LL_ADC_REG_SetSequencerChAdd\n
  1950. * CHSELR CHSEL3 LL_ADC_REG_SetSequencerChAdd\n
  1951. * CHSELR CHSEL4 LL_ADC_REG_SetSequencerChAdd\n
  1952. * CHSELR CHSEL5 LL_ADC_REG_SetSequencerChAdd\n
  1953. * CHSELR CHSEL6 LL_ADC_REG_SetSequencerChAdd\n
  1954. * CHSELR CHSEL7 LL_ADC_REG_SetSequencerChAdd\n
  1955. * CHSELR CHSEL8 LL_ADC_REG_SetSequencerChAdd\n
  1956. * CHSELR CHSEL9 LL_ADC_REG_SetSequencerChAdd\n
  1957. * CHSELR CHSEL11 LL_ADC_REG_SetSequencerChAdd\n
  1958. * CHSELR CHSEL12 LL_ADC_REG_SetSequencerChAdd
  1959. * @param ADCx ADC instance
  1960. * @param Channel This parameter can be a combination of the following values:
  1961. * @arg @ref LL_ADC_CHANNEL_0
  1962. * @arg @ref LL_ADC_CHANNEL_1
  1963. * @arg @ref LL_ADC_CHANNEL_2
  1964. * @arg @ref LL_ADC_CHANNEL_3
  1965. * @arg @ref LL_ADC_CHANNEL_4
  1966. * @arg @ref LL_ADC_CHANNEL_5
  1967. * @arg @ref LL_ADC_CHANNEL_6
  1968. * @arg @ref LL_ADC_CHANNEL_7
  1969. * @arg @ref LL_ADC_CHANNEL_8
  1970. * @arg @ref LL_ADC_CHANNEL_9
  1971. * @arg @ref LL_ADC_CHANNEL_11
  1972. * @arg @ref LL_ADC_CHANNEL_12
  1973. * @arg @ref LL_ADC_CHANNEL_VREFINT
  1974. * @arg @ref LL_ADC_CHANNEL_TEMPSENSOR
  1975. * @retval None
  1976. */
  1977. __STATIC_INLINE void LL_ADC_REG_SetSequencerChAdd(ADC_TypeDef *ADCx, uint32_t Channel)
  1978. {
  1979. /* Parameter "Channel" is used with masks because containing */
  1980. /* other bits reserved for other purpose. */
  1981. SET_BIT(ADCx->CHSELR, (Channel & ADC_CHANNEL_ID_BITFIELD_MASK));
  1982. }
  1983. /**
  1984. * @brief Remove channel to ADC group regular sequence: channel on rank corresponding to
  1985. * channel number.
  1986. * @note This function performs:
  1987. * - Channels ordering into each rank of scan sequence:
  1988. * rank of each channel is fixed by channel HW number
  1989. * (channel 0 fixed on rank 0, channel 1 fixed on rank1, ...).
  1990. * - Set channels selected by removing them to the current sequencer
  1991. * configuration.
  1992. * @note On this PY32 serie, ADC group regular sequencer is
  1993. * not fully configurable: sequencer length and each rank
  1994. * affectation to a channel are fixed by channel HW number.
  1995. * @note Depending on devices and packages, some channels may not be available.
  1996. * Refer to device datasheet for channels availability.
  1997. * @note On this PY32 serie, to measure internal channels (VrefInt,
  1998. * TempSensor, ...), measurement paths to internal channels must be
  1999. * enabled separately.
  2000. * This can be done using function @ref LL_ADC_SetCommonPathInternalCh().
  2001. * @note On this PY32 serie, setting of this feature is conditioned to
  2002. * ADC state:
  2003. * ADC must be disabled or enabled without conversion on going
  2004. * on group regular.
  2005. * @note One or several values can be selected.
  2006. * Example: (LL_ADC_CHANNEL_4 | LL_ADC_CHANNEL_12 | ...)
  2007. * @rmtoll CHSELR CHSEL0 LL_ADC_REG_SetSequencerChRem\n
  2008. * CHSELR CHSEL1 LL_ADC_REG_SetSequencerChRem\n
  2009. * CHSELR CHSEL2 LL_ADC_REG_SetSequencerChRem\n
  2010. * CHSELR CHSEL3 LL_ADC_REG_SetSequencerChRem\n
  2011. * CHSELR CHSEL4 LL_ADC_REG_SetSequencerChRem\n
  2012. * CHSELR CHSEL5 LL_ADC_REG_SetSequencerChRem\n
  2013. * CHSELR CHSEL6 LL_ADC_REG_SetSequencerChRem\n
  2014. * CHSELR CHSEL7 LL_ADC_REG_SetSequencerChRem\n
  2015. * CHSELR CHSEL8 LL_ADC_REG_SetSequencerChRem\n
  2016. * CHSELR CHSEL9 LL_ADC_REG_SetSequencerChRem\n
  2017. * CHSELR CHSEL11 LL_ADC_REG_SetSequencerChRem\n
  2018. * CHSELR CHSEL12 LL_ADC_REG_SetSequencerChRem
  2019. * @param ADCx ADC instance
  2020. * @param Channel This parameter can be a combination of the following values:
  2021. * @arg @ref LL_ADC_CHANNEL_0
  2022. * @arg @ref LL_ADC_CHANNEL_1
  2023. * @arg @ref LL_ADC_CHANNEL_2
  2024. * @arg @ref LL_ADC_CHANNEL_3
  2025. * @arg @ref LL_ADC_CHANNEL_4
  2026. * @arg @ref LL_ADC_CHANNEL_5
  2027. * @arg @ref LL_ADC_CHANNEL_6
  2028. * @arg @ref LL_ADC_CHANNEL_7
  2029. * @arg @ref LL_ADC_CHANNEL_8
  2030. * @arg @ref LL_ADC_CHANNEL_9
  2031. * @arg @ref LL_ADC_CHANNEL_11
  2032. * @arg @ref LL_ADC_CHANNEL_12
  2033. * @arg @ref LL_ADC_CHANNEL_VREFINT
  2034. * @arg @ref LL_ADC_CHANNEL_TEMPSENSOR
  2035. * @retval None
  2036. */
  2037. __STATIC_INLINE void LL_ADC_REG_SetSequencerChRem(ADC_TypeDef *ADCx, uint32_t Channel)
  2038. {
  2039. /* Parameter "Channel" is used with masks because containing */
  2040. /* other bits reserved for other purpose. */
  2041. CLEAR_BIT(ADCx->CHSELR, (Channel & ADC_CHANNEL_ID_BITFIELD_MASK));
  2042. }
  2043. /**
  2044. * @brief Get ADC group regular sequence: channel on rank corresponding to
  2045. * channel number.
  2046. * @note This function performs:
  2047. * - Channels order reading into each rank of scan sequence:
  2048. * rank of each channel is fixed by channel HW number
  2049. * (channel 0 fixed on rank 0, channel 1 fixed on rank1, ...).
  2050. * @note On this PY32 serie, ADC group regular sequencer is
  2051. * not fully configurable: sequencer length and each rank
  2052. * affectation to a channel are fixed by channel HW number.
  2053. * @note Depending on devices and packages, some channels may not be available.
  2054. * Refer to device datasheet for channels availability.
  2055. * @note On this PY32 serie, to measure internal channels (VrefInt,
  2056. * TempSensor, ...), measurement paths to internal channels must be
  2057. * enabled separately.
  2058. * This can be done using function @ref LL_ADC_SetCommonPathInternalCh().
  2059. * @note On this PY32 serie, setting of this feature is conditioned to
  2060. * ADC state:
  2061. * ADC must be disabled or enabled without conversion on going
  2062. * on group regular.
  2063. * @note One or several values can be retrieved.
  2064. * Example: (LL_ADC_CHANNEL_4 | LL_ADC_CHANNEL_12 | ...)
  2065. * @rmtoll CHSELR CHSEL0 LL_ADC_REG_GetSequencerChannels\n
  2066. * CHSELR CHSEL1 LL_ADC_REG_GetSequencerChannels\n
  2067. * CHSELR CHSEL2 LL_ADC_REG_GetSequencerChannels\n
  2068. * CHSELR CHSEL3 LL_ADC_REG_GetSequencerChannels\n
  2069. * CHSELR CHSEL4 LL_ADC_REG_GetSequencerChannels\n
  2070. * CHSELR CHSEL5 LL_ADC_REG_GetSequencerChannels\n
  2071. * CHSELR CHSEL6 LL_ADC_REG_GetSequencerChannels\n
  2072. * CHSELR CHSEL7 LL_ADC_REG_GetSequencerChannels\n
  2073. * CHSELR CHSEL8 LL_ADC_REG_GetSequencerChannels\n
  2074. * CHSELR CHSEL9 LL_ADC_REG_GetSequencerChannels\n
  2075. * CHSELR CHSEL11 LL_ADC_REG_GetSequencerChannels\n
  2076. * CHSELR CHSEL12 LL_ADC_REG_GetSequencerChannels
  2077. * @param ADCx ADC instance
  2078. * @retval Returned value can be a combination of the following values:
  2079. * @arg @ref LL_ADC_CHANNEL_0
  2080. * @arg @ref LL_ADC_CHANNEL_1
  2081. * @arg @ref LL_ADC_CHANNEL_2
  2082. * @arg @ref LL_ADC_CHANNEL_3
  2083. * @arg @ref LL_ADC_CHANNEL_4
  2084. * @arg @ref LL_ADC_CHANNEL_5
  2085. * @arg @ref LL_ADC_CHANNEL_6
  2086. * @arg @ref LL_ADC_CHANNEL_7
  2087. * @arg @ref LL_ADC_CHANNEL_8
  2088. * @arg @ref LL_ADC_CHANNEL_9
  2089. * @arg @ref LL_ADC_CHANNEL_11
  2090. * @arg @ref LL_ADC_CHANNEL_12
  2091. * @arg @ref LL_ADC_CHANNEL_VREFINT
  2092. * @arg @ref LL_ADC_CHANNEL_TEMPSENSOR
  2093. */
  2094. __STATIC_INLINE uint32_t LL_ADC_REG_GetSequencerChannels(ADC_TypeDef *ADCx)
  2095. {
  2096. register uint32_t ChannelsBitfield = READ_BIT(ADCx->CHSELR, ADC_CHSELR_CHSEL);
  2097. return ( (((ChannelsBitfield & ADC_CHSELR_CHSEL0) >> ADC_CHSELR_CHSEL0_BITOFFSET_POS) * LL_ADC_CHANNEL_0)
  2098. | (((ChannelsBitfield & ADC_CHSELR_CHSEL1) >> ADC_CHSELR_CHSEL1_BITOFFSET_POS) * LL_ADC_CHANNEL_1)
  2099. | (((ChannelsBitfield & ADC_CHSELR_CHSEL2) >> ADC_CHSELR_CHSEL2_BITOFFSET_POS) * LL_ADC_CHANNEL_2)
  2100. | (((ChannelsBitfield & ADC_CHSELR_CHSEL3) >> ADC_CHSELR_CHSEL3_BITOFFSET_POS) * LL_ADC_CHANNEL_3)
  2101. | (((ChannelsBitfield & ADC_CHSELR_CHSEL4) >> ADC_CHSELR_CHSEL4_BITOFFSET_POS) * LL_ADC_CHANNEL_4)
  2102. | (((ChannelsBitfield & ADC_CHSELR_CHSEL5) >> ADC_CHSELR_CHSEL5_BITOFFSET_POS) * LL_ADC_CHANNEL_5)
  2103. | (((ChannelsBitfield & ADC_CHSELR_CHSEL6) >> ADC_CHSELR_CHSEL6_BITOFFSET_POS) * LL_ADC_CHANNEL_6)
  2104. | (((ChannelsBitfield & ADC_CHSELR_CHSEL7) >> ADC_CHSELR_CHSEL7_BITOFFSET_POS) * LL_ADC_CHANNEL_7)
  2105. | (((ChannelsBitfield & ADC_CHSELR_CHSEL8) >> ADC_CHSELR_CHSEL8_BITOFFSET_POS) * LL_ADC_CHANNEL_8)
  2106. | (((ChannelsBitfield & ADC_CHSELR_CHSEL9) >> ADC_CHSELR_CHSEL9_BITOFFSET_POS) * LL_ADC_CHANNEL_9)
  2107. | (((ChannelsBitfield & ADC_CHSELR_CHSEL11) >> ADC_CHSELR_CHSEL11_BITOFFSET_POS) * LL_ADC_CHANNEL_11)
  2108. | (((ChannelsBitfield & ADC_CHSELR_CHSEL12) >> ADC_CHSELR_CHSEL12_BITOFFSET_POS) * LL_ADC_CHANNEL_12)
  2109. );
  2110. }
  2111. /**
  2112. * @brief Set ADC continuous conversion mode on ADC group regular.
  2113. * @note Description of ADC continuous conversion mode:
  2114. * - single mode: one conversion per trigger
  2115. * - continuous mode: after the first trigger, following
  2116. * conversions launched successively automatically.
  2117. * @note It is not possible to enable both ADC group regular
  2118. * continuous mode and sequencer discontinuous mode.
  2119. * @note On this PY32 serie, setting of this feature is conditioned to
  2120. * ADC state:
  2121. * ADC must be disabled or enabled without conversion on going
  2122. * on group regular.
  2123. * @rmtoll CFGR1 CONT LL_ADC_REG_SetContinuousMode
  2124. * @param ADCx ADC instance
  2125. * @param Continuous This parameter can be one of the following values:
  2126. * @arg @ref LL_ADC_REG_CONV_SINGLE
  2127. * @arg @ref LL_ADC_REG_CONV_CONTINUOUS
  2128. * @retval None
  2129. */
  2130. __STATIC_INLINE void LL_ADC_REG_SetContinuousMode(ADC_TypeDef *ADCx, uint32_t Continuous)
  2131. {
  2132. MODIFY_REG(ADCx->CFGR1, ADC_CFGR1_CONT, Continuous);
  2133. }
  2134. /**
  2135. * @brief Get ADC continuous conversion mode on ADC group regular.
  2136. * @note Description of ADC continuous conversion mode:
  2137. * - single mode: one conversion per trigger
  2138. * - continuous mode: after the first trigger, following
  2139. * conversions launched successively automatically.
  2140. * @rmtoll CFGR1 CONT LL_ADC_REG_GetContinuousMode
  2141. * @param ADCx ADC instance
  2142. * @retval Returned value can be one of the following values:
  2143. * @arg @ref LL_ADC_REG_CONV_SINGLE
  2144. * @arg @ref LL_ADC_REG_CONV_CONTINUOUS
  2145. */
  2146. __STATIC_INLINE uint32_t LL_ADC_REG_GetContinuousMode(ADC_TypeDef *ADCx)
  2147. {
  2148. return (uint32_t)(READ_BIT(ADCx->CFGR1, ADC_CFGR1_CONT));
  2149. }
  2150. #if (defined(DMA) || defined(DMA1))
  2151. /**
  2152. * @brief Set ADC group regular conversion data transfer: no transfer or
  2153. * transfer by DMA, and DMA requests mode.
  2154. * @note If transfer by DMA selected, specifies the DMA requests
  2155. * mode:
  2156. * - Limited mode (One shot mode): DMA transfer requests are stopped
  2157. * when number of DMA data transfers (number of
  2158. * ADC conversions) is reached.
  2159. * This ADC mode is intended to be used with DMA mode non-circular.
  2160. * - Unlimited mode: DMA transfer requests are unlimited,
  2161. * whatever number of DMA data transfers (number of
  2162. * ADC conversions).
  2163. * This ADC mode is intended to be used with DMA mode circular.
  2164. * @note If ADC DMA requests mode is set to unlimited and DMA is set to
  2165. * mode non-circular:
  2166. * when DMA transfers size will be reached, DMA will stop transfers of
  2167. * ADC conversions data ADC will raise an overrun error
  2168. * (overrun flag and interruption if enabled).
  2169. * @note To configure DMA source address (peripheral address),
  2170. * use function @ref LL_ADC_DMA_GetRegAddr().
  2171. * @note On this PY32 serie, setting of this feature is conditioned to
  2172. * ADC state:
  2173. * ADC must be disabled or enabled without conversion on going
  2174. * on group regular.
  2175. * @note Depending on devices and packages, DMA may not be available.
  2176. * Refer to device datasheet for DMA availability.
  2177. * @rmtoll CFGR1 DMAEN LL_ADC_REG_SetDMATransfer\n
  2178. * CFGR1 DMACFG LL_ADC_REG_SetDMATransfer
  2179. * @param ADCx ADC instance
  2180. * @param DMATransfer This parameter can be one of the following values:
  2181. * @arg @ref LL_ADC_REG_DMA_TRANSFER_NONE
  2182. * @arg @ref LL_ADC_REG_DMA_TRANSFER_LIMITED
  2183. * @arg @ref LL_ADC_REG_DMA_TRANSFER_UNLIMITED
  2184. * @retval None
  2185. */
  2186. __STATIC_INLINE void LL_ADC_REG_SetDMATransfer(ADC_TypeDef *ADCx, uint32_t DMATransfer)
  2187. {
  2188. MODIFY_REG(ADCx->CFGR1, ADC_CFGR1_DMAEN | ADC_CFGR1_DMACFG, DMATransfer);
  2189. }
  2190. /**
  2191. * @brief Get ADC group regular conversion data transfer: no transfer or
  2192. * transfer by DMA, and DMA requests mode.
  2193. * @note If transfer by DMA selected, specifies the DMA requests
  2194. * mode:
  2195. * - Limited mode (One shot mode): DMA transfer requests are stopped
  2196. * when number of DMA data transfers (number of
  2197. * ADC conversions) is reached.
  2198. * This ADC mode is intended to be used with DMA mode non-circular.
  2199. * - Unlimited mode: DMA transfer requests are unlimited,
  2200. * whatever number of DMA data transfers (number of
  2201. * ADC conversions).
  2202. * This ADC mode is intended to be used with DMA mode circular.
  2203. * @note If ADC DMA requests mode is set to unlimited and DMA is set to
  2204. * mode non-circular:
  2205. * when DMA transfers size will be reached, DMA will stop transfers of
  2206. * ADC conversions data ADC will raise an overrun error
  2207. * (overrun flag and interruption if enabled).
  2208. * @note To configure DMA source address (peripheral address),
  2209. * use function @ref LL_ADC_DMA_GetRegAddr().
  2210. * @note Depending on devices and packages, DMA may not be available.
  2211. * Refer to device datasheet for DMA availability.
  2212. * @rmtoll CFGR1 DMAEN LL_ADC_REG_GetDMATransfer\n
  2213. * CFGR1 DMACFG LL_ADC_REG_GetDMATransfer
  2214. * @param ADCx ADC instance
  2215. * @retval Returned value can be one of the following values:
  2216. * @arg @ref LL_ADC_REG_DMA_TRANSFER_NONE
  2217. * @arg @ref LL_ADC_REG_DMA_TRANSFER_LIMITED
  2218. * @arg @ref LL_ADC_REG_DMA_TRANSFER_UNLIMITED
  2219. */
  2220. __STATIC_INLINE uint32_t LL_ADC_REG_GetDMATransfer(ADC_TypeDef *ADCx)
  2221. {
  2222. return (uint32_t)(READ_BIT(ADCx->CFGR1, ADC_CFGR1_DMAEN | ADC_CFGR1_DMACFG));
  2223. }
  2224. #endif
  2225. /**
  2226. * @brief Set ADC group regular behavior in case of overrun:
  2227. * data preserved or overwritten.
  2228. * @note Compatibility with devices without feature overrun:
  2229. * other devices without this feature have a behavior
  2230. * equivalent to data overwritten.
  2231. * The default setting of overrun is data preserved.
  2232. * Therefore, for compatibility with all devices, parameter
  2233. * overrun should be set to data overwritten.
  2234. * @note On this PY32 serie, setting of this feature is conditioned to
  2235. * ADC state:
  2236. * ADC must be disabled or enabled without conversion on going
  2237. * on group regular.
  2238. * @rmtoll CFGR1 OVRMOD LL_ADC_REG_SetOverrun
  2239. * @param ADCx ADC instance
  2240. * @param Overrun This parameter can be one of the following values:
  2241. * @arg @ref LL_ADC_REG_OVR_DATA_PRESERVED
  2242. * @arg @ref LL_ADC_REG_OVR_DATA_OVERWRITTEN
  2243. * @retval None
  2244. */
  2245. __STATIC_INLINE void LL_ADC_REG_SetOverrun(ADC_TypeDef *ADCx, uint32_t Overrun)
  2246. {
  2247. MODIFY_REG(ADCx->CFGR1, ADC_CFGR1_OVRMOD, Overrun);
  2248. }
  2249. /**
  2250. * @brief Get ADC group regular behavior in case of overrun:
  2251. * data preserved or overwritten.
  2252. * @rmtoll CFGR1 OVRMOD LL_ADC_REG_GetOverrun
  2253. * @param ADCx ADC instance
  2254. * @retval Returned value can be one of the following values:
  2255. * @arg @ref LL_ADC_REG_OVR_DATA_PRESERVED
  2256. * @arg @ref LL_ADC_REG_OVR_DATA_OVERWRITTEN
  2257. */
  2258. __STATIC_INLINE uint32_t LL_ADC_REG_GetOverrun(ADC_TypeDef *ADCx)
  2259. {
  2260. return (uint32_t)(READ_BIT(ADCx->CFGR1, ADC_CFGR1_OVRMOD));
  2261. }
  2262. /**
  2263. * @}
  2264. */
  2265. /** @defgroup ADC_LL_EF_Configuration_ADC_AnalogWatchdog Configuration of ADC transversal scope: analog watchdog
  2266. * @{
  2267. */
  2268. /**
  2269. * @brief Set ADC analog watchdog monitored channels:
  2270. * a single channel or all channels,
  2271. * on ADC group regular.
  2272. * @note Once monitored channels are selected, analog watchdog
  2273. * is enabled.
  2274. * @note In case of need to define a single channel to monitor
  2275. * with analog watchdog from sequencer channel definition,
  2276. * use helper macro @ref __LL_ADC_ANALOGWD_CHANNEL_GROUP().
  2277. * @note On this PY32 serie, there is only 1 kind of analog watchdog
  2278. * instance:
  2279. * - AWD standard (instance AWD):
  2280. * - channels monitored: can monitor 1 channel or all channels.
  2281. * - groups monitored: ADC group regular.
  2282. * - resolution: resolution is not limited (corresponds to
  2283. * ADC resolution configured).
  2284. * @note On this PY32 serie, setting of this feature is conditioned to
  2285. * ADC state:
  2286. * ADC must be disabled or enabled without conversion on going
  2287. * on group regular.
  2288. * @note Depending on devices and packages, some channels may not be available.
  2289. * Refer to device datasheet for channels availability.
  2290. * @rmtoll CFGR1 AWDCH LL_ADC_SetAnalogWDMonitChannels\n
  2291. * CFGR1 AWDSGL LL_ADC_SetAnalogWDMonitChannels\n
  2292. * CFGR1 AWDEN LL_ADC_SetAnalogWDMonitChannels
  2293. * @param ADCx ADC instance
  2294. * @param AWDChannelGroup This parameter can be one of the following values:
  2295. * @arg @ref LL_ADC_AWD_DISABLE
  2296. * @arg @ref LL_ADC_AWD_ALL_CHANNELS_REG
  2297. * @arg @ref LL_ADC_AWD_CHANNEL_0_REG
  2298. * @arg @ref LL_ADC_AWD_CHANNEL_1_REG
  2299. * @arg @ref LL_ADC_AWD_CHANNEL_2_REG
  2300. * @arg @ref LL_ADC_AWD_CHANNEL_3_REG
  2301. * @arg @ref LL_ADC_AWD_CHANNEL_4_REG
  2302. * @arg @ref LL_ADC_AWD_CHANNEL_5_REG
  2303. * @arg @ref LL_ADC_AWD_CHANNEL_6_REG
  2304. * @arg @ref LL_ADC_AWD_CHANNEL_7_REG
  2305. * @arg @ref LL_ADC_AWD_CHANNEL_8_REG
  2306. * @arg @ref LL_ADC_AWD_CHANNEL_9_REG
  2307. * @arg @ref LL_ADC_AWD_CHANNEL_11_REG
  2308. * @arg @ref LL_ADC_AWD_CHANNEL_12_REG
  2309. * @arg @ref LL_ADC_AWD_CH_VREFINT_REG
  2310. * @arg @ref LL_ADC_AWD_CH_TEMPSENSOR_REG
  2311. * @retval None
  2312. */
  2313. __STATIC_INLINE void LL_ADC_SetAnalogWDMonitChannels(ADC_TypeDef *ADCx, uint32_t AWDChannelGroup)
  2314. {
  2315. MODIFY_REG(ADCx->CFGR1,
  2316. (ADC_CFGR1_AWDCH | ADC_CFGR1_AWDSGL | ADC_CFGR1_AWDEN),
  2317. (AWDChannelGroup & ADC_AWD_CR_ALL_CHANNEL_MASK));
  2318. }
  2319. /**
  2320. * @brief Get ADC analog watchdog monitored channel.
  2321. * @note Usage of the returned channel number:
  2322. * - To reinject this channel into another function LL_ADC_xxx:
  2323. * the returned channel number is only partly formatted on definition
  2324. * of literals LL_ADC_CHANNEL_x. Therefore, it has to be compared
  2325. * with parts of literals LL_ADC_CHANNEL_x or using
  2326. * helper macro @ref __LL_ADC_CHANNEL_TO_DECIMAL_NB().
  2327. * Then the selected literal LL_ADC_CHANNEL_x can be used
  2328. * as parameter for another function.
  2329. * - To get the channel number in decimal format:
  2330. * process the returned value with the helper macro
  2331. * @ref __LL_ADC_CHANNEL_TO_DECIMAL_NB().
  2332. * Applicable only when the analog watchdog is set to monitor
  2333. * one channel.
  2334. * @note On this PY32 serie, there is only 1 kind of analog watchdog
  2335. * instance:
  2336. * - AWD standard (instance AWD):
  2337. * - channels monitored: can monitor 1 channel or all channels.
  2338. * - groups monitored: ADC group regular.
  2339. * - resolution: resolution is not limited (corresponds to
  2340. * ADC resolution configured).
  2341. * @note On this PY32 serie, setting of this feature is conditioned to
  2342. * ADC state:
  2343. * ADC must be disabled or enabled without conversion on going
  2344. * on group regular.
  2345. * @note Depending on devices and packages, some channels may not be available.
  2346. * Refer to device datasheet for channels availability.
  2347. * @rmtoll CFGR1 AWDCH LL_ADC_GetAnalogWDMonitChannels\n
  2348. * CFGR1 AWDSGL LL_ADC_GetAnalogWDMonitChannels\n
  2349. * CFGR1 AWDEN LL_ADC_GetAnalogWDMonitChannels
  2350. * @param ADCx ADC instance
  2351. * @retval Returned value can be one of the following values:
  2352. * @arg @ref LL_ADC_AWD_DISABLE
  2353. * @arg @ref LL_ADC_AWD_ALL_CHANNELS_REG
  2354. * @arg @ref LL_ADC_AWD_CHANNEL_0_REG
  2355. * @arg @ref LL_ADC_AWD_CHANNEL_1_REG
  2356. * @arg @ref LL_ADC_AWD_CHANNEL_2_REG
  2357. * @arg @ref LL_ADC_AWD_CHANNEL_3_REG
  2358. * @arg @ref LL_ADC_AWD_CHANNEL_4_REG
  2359. * @arg @ref LL_ADC_AWD_CHANNEL_5_REG
  2360. * @arg @ref LL_ADC_AWD_CHANNEL_6_REG
  2361. * @arg @ref LL_ADC_AWD_CHANNEL_7_REG
  2362. * @arg @ref LL_ADC_AWD_CHANNEL_8_REG
  2363. * @arg @ref LL_ADC_AWD_CHANNEL_9_REG
  2364. * @arg @ref LL_ADC_AWD_CHANNEL_11_REG
  2365. * @arg @ref LL_ADC_AWD_CHANNEL_12_REG
  2366. */
  2367. __STATIC_INLINE uint32_t LL_ADC_GetAnalogWDMonitChannels(ADC_TypeDef *ADCx)
  2368. {
  2369. register uint32_t AWDChannelGroup = READ_BIT(ADCx->CFGR1, (ADC_CFGR1_AWDCH | ADC_CFGR1_AWDSGL | ADC_CFGR1_AWDEN));
  2370. /* Note: Set variable according to channel definition including channel ID */
  2371. /* with bitfield. */
  2372. register uint32_t AWDChannelSingle = ((AWDChannelGroup & ADC_CFGR1_AWDSGL) >> ADC_CFGR1_AWDSGL_BITOFFSET_POS);
  2373. register uint32_t AWDChannelBitField = (ADC_CHANNEL_0_BITFIELD << ((AWDChannelGroup & ADC_CHANNEL_ID_NUMBER_MASK) >> ADC_CHANNEL_ID_NUMBER_BITOFFSET_POS));
  2374. return (AWDChannelGroup | (AWDChannelBitField * AWDChannelSingle));
  2375. }
  2376. /**
  2377. * @brief Set ADC analog watchdog thresholds value of both thresholds
  2378. * high and low.
  2379. * @note If value of only one threshold high or low must be set,
  2380. * use function @ref LL_ADC_SetAnalogWDThresholds().
  2381. * @note In case of ADC resolution different of 12 bits,
  2382. * analog watchdog thresholds data require a specific shift.
  2383. * Use helper macro @ref __LL_ADC_ANALOGWD_SET_THRESHOLD_RESOLUTION().
  2384. * @note On this PY32 serie, there is only 1 kind of analog watchdog
  2385. * instance:
  2386. * - AWD standard (instance AWD):
  2387. * - channels monitored: can monitor 1 channel or all channels.
  2388. * - groups monitored: ADC group regular.
  2389. * - resolution: resolution is not limited (corresponds to
  2390. * ADC resolution configured).
  2391. * @note On this PY32 serie, setting of this feature is conditioned to
  2392. * ADC state:
  2393. * ADC must be disabled or enabled without conversion on going
  2394. * on group regular.
  2395. * @rmtoll TR HT LL_ADC_ConfigAnalogWDThresholds\n
  2396. * TR LT LL_ADC_ConfigAnalogWDThresholds
  2397. * @param ADCx ADC instance
  2398. * @param AWDThresholdHighValue Value between Min_Data=0x000 and Max_Data=0xFFF
  2399. * @param AWDThresholdLowValue Value between Min_Data=0x000 and Max_Data=0xFFF
  2400. * @retval None
  2401. */
  2402. __STATIC_INLINE void LL_ADC_ConfigAnalogWDThresholds(ADC_TypeDef *ADCx, uint32_t AWDThresholdHighValue, uint32_t AWDThresholdLowValue)
  2403. {
  2404. MODIFY_REG(ADCx->TR,ADC_TR_HT | ADC_TR_LT,(AWDThresholdHighValue << ADC_TR_HT_BITOFFSET_POS) | AWDThresholdLowValue);
  2405. }
  2406. /**
  2407. * @brief Set ADC analog watchdog threshold value of threshold
  2408. * high or low.
  2409. * @note If values of both thresholds high or low must be set,
  2410. * use function @ref LL_ADC_ConfigAnalogWDThresholds().
  2411. * @note In case of ADC resolution different of 12 bits,
  2412. * analog watchdog thresholds data require a specific shift.
  2413. * Use helper macro @ref __LL_ADC_ANALOGWD_SET_THRESHOLD_RESOLUTION().
  2414. * @note On this PY32 serie, there is only 1 kind of analog watchdog
  2415. * instance:
  2416. * - AWD standard (instance AWD):
  2417. * - channels monitored: can monitor 1 channel or all channels.
  2418. * - groups monitored: ADC group regular.
  2419. * - resolution: resolution is not limited (corresponds to
  2420. * ADC resolution configured).
  2421. * @note On this PY32 serie, setting of this feature is conditioned to
  2422. * ADC state:
  2423. * ADC must be disabled or enabled without conversion on going
  2424. * on group regular.
  2425. * @rmtoll TR HT LL_ADC_SetAnalogWDThresholds\n
  2426. * TR LT LL_ADC_SetAnalogWDThresholds
  2427. * @param ADCx ADC instance
  2428. * @param AWDThresholdsHighLow This parameter can be one of the following values:
  2429. * @arg @ref LL_ADC_AWD_THRESHOLD_HIGH
  2430. * @arg @ref LL_ADC_AWD_THRESHOLD_LOW
  2431. * @param AWDThresholdValue Value between Min_Data=0x000 and Max_Data=0xFFF
  2432. * @retval None
  2433. */
  2434. __STATIC_INLINE void LL_ADC_SetAnalogWDThresholds(ADC_TypeDef *ADCx, uint32_t AWDThresholdsHighLow, uint32_t AWDThresholdValue)
  2435. {
  2436. /* Parameter "AWDThresholdsHighLow" is used with mask "0x00000010" */
  2437. /* to be equivalent to "POSITION_VAL(AWDThresholdsHighLow)": if threshold */
  2438. /* high is selected, then data is shifted to LSB. Else(threshold low), */
  2439. /* data is not shifted. */
  2440. MODIFY_REG(ADCx->TR, AWDThresholdsHighLow,AWDThresholdValue << ((AWDThresholdsHighLow >> ADC_TR_HT_BITOFFSET_POS) & 0x00000010U));
  2441. }
  2442. /**
  2443. * @brief Get ADC analog watchdog threshold value of threshold high,
  2444. * threshold low or raw data with ADC thresholds high and low
  2445. * concatenated.
  2446. * @note If raw data with ADC thresholds high and low is retrieved,
  2447. * the data of each threshold high or low can be isolated
  2448. * using helper macro:
  2449. * @ref __LL_ADC_ANALOGWD_THRESHOLDS_HIGH_LOW().
  2450. * @note In case of ADC resolution different of 12 bits,
  2451. * analog watchdog thresholds data require a specific shift.
  2452. * Use helper macro @ref __LL_ADC_ANALOGWD_GET_THRESHOLD_RESOLUTION().
  2453. * @rmtoll TR HT LL_ADC_GetAnalogWDThresholds\n
  2454. * TR LT LL_ADC_GetAnalogWDThresholds
  2455. * @param ADCx ADC instance
  2456. * @param AWDThresholdsHighLow This parameter can be one of the following values:
  2457. * @arg @ref LL_ADC_AWD_THRESHOLD_HIGH
  2458. * @arg @ref LL_ADC_AWD_THRESHOLD_LOW
  2459. * @arg @ref LL_ADC_AWD_THRESHOLDS_HIGH_LOW
  2460. * @retval Value between Min_Data=0x000 and Max_Data=0xFFF
  2461. */
  2462. __STATIC_INLINE uint32_t LL_ADC_GetAnalogWDThresholds(ADC_TypeDef *ADCx, uint32_t AWDThresholdsHighLow)
  2463. {
  2464. /* Parameter "AWDThresholdsHighLow" is used with mask "0x00000010" */
  2465. /* to be equivalent to "POSITION_VAL(AWDThresholdsHighLow)": if threshold */
  2466. /* high is selected, then data is shifted to LSB. Else(threshold low or */
  2467. /* both thresholds), data is not shifted. */
  2468. return (uint32_t)(READ_BIT(ADCx->TR,(AWDThresholdsHighLow | ADC_TR_LT))>> ((~AWDThresholdsHighLow) & 0x00000010U));
  2469. }
  2470. /**
  2471. * @brief Start ADC calibration in the mode single-ended
  2472. * or differential (for devices with differential mode available).
  2473. * @note On this PY32 serie, a minimum number of ADC clock cycles
  2474. * are required between ADC end of calibration and ADC enable.
  2475. * Refer to literal @ref LL_ADC_DELAY_CALIB_ENABLE_ADC_CYCLES.
  2476. * @note In case of usage of ADC with DMA transfer:
  2477. * On this PY32 serie, ADC DMA transfer request should be disabled
  2478. * during calibration:
  2479. * Calibration factor is available in data register
  2480. * and also transfered by DMA.
  2481. * To not insert ADC calibration factor among ADC conversion data
  2482. * in array variable, DMA transfer must be disabled during
  2483. * calibration.
  2484. * (DMA transfer setting backup and disable before calibration,
  2485. * DMA transfer setting restore after calibration.
  2486. * Refer to functions @ref LL_ADC_REG_GetDMATransfer(),
  2487. * @ref LL_ADC_REG_SetDMATransfer() ).
  2488. * @note On this PY32 serie, setting of this feature is conditioned to
  2489. * ADC state:
  2490. * ADC must be ADC disabled.
  2491. * @note Depending on devices and packages, DMA may not be available.
  2492. * Refer to device datasheet for DMA availability.
  2493. * @rmtoll CR ADCAL LL_ADC_StartCalibration
  2494. * @param ADCx ADC instance
  2495. * @retval None
  2496. */
  2497. __STATIC_INLINE void LL_ADC_StartCalibration(ADC_TypeDef *ADCx)
  2498. {
  2499. /* Note: Write register with some additional bits forced to state reset */
  2500. /* instead of modifying only the selected bit for this function, */
  2501. /* to not interfere with bits with HW property "rs". */
  2502. MODIFY_REG(ADCx->CR,ADC_CR_BITS_PROPERTY_RS,ADC_CR_ADCAL);
  2503. }
  2504. /**
  2505. * @brief Get ADC calibration state.
  2506. * @rmtoll CR ADCAL LL_ADC_IsCalibrationOnGoing
  2507. * @param ADCx ADC instance
  2508. * @retval 0: calibration complete, 1: calibration in progress.
  2509. */
  2510. __STATIC_INLINE uint32_t LL_ADC_IsCalibrationOnGoing(ADC_TypeDef *ADCx)
  2511. {
  2512. return (READ_BIT(ADCx->CR, ADC_CR_ADCAL) == (ADC_CR_ADCAL));
  2513. }
  2514. /**
  2515. * @}
  2516. */
  2517. /** @defgroup ADC_LL_EF_Operation_ADC_Instance Operation on ADC hierarchical scope: ADC instance
  2518. * @{
  2519. */
  2520. /**
  2521. * @brief Enable the selected ADC instance.
  2522. * @note On this PY32 serie, after ADC enable, a delay for
  2523. * ADC internal analog stabilization is required before performing a
  2524. * ADC conversion start.
  2525. * Refer to device datasheet, parameter tSTAB.
  2526. * @note On this PY32 serie, setting of this feature is conditioned to
  2527. * ADC state:
  2528. * ADC must be ADC disabled and ADC internal voltage regulator enabled.
  2529. * @rmtoll CR ADEN LL_ADC_Enable
  2530. * @param ADCx ADC instance
  2531. * @retval None
  2532. */
  2533. __STATIC_INLINE void LL_ADC_Enable(ADC_TypeDef *ADCx)
  2534. {
  2535. /* Note: Write register with some additional bits forced to state reset */
  2536. /* instead of modifying only the selected bit for this function, */
  2537. /* to not interfere with bits with HW property "rs". */
  2538. MODIFY_REG(ADCx->CR,ADC_CR_BITS_PROPERTY_RS,ADC_CR_ADEN);
  2539. }
  2540. /**
  2541. * @brief Reset the selected ADC instance.
  2542. * @note On this PY32 serie, Reset the ADC
  2543. * @param ADCx ADC instance
  2544. * @retval None
  2545. */
  2546. __STATIC_INLINE void LL_ADC_Reset(ADC_TypeDef *ADCx)
  2547. {
  2548. /* Note: Write register with some additional bits forced to state reset */
  2549. /* instead of modifying only the selected bit for this function */
  2550. /* Force reset of ADC clock (core clock) */
  2551. LL_APB1_GRP2_ForceReset(LL_APB1_GRP2_PERIPH_ADC1);
  2552. /* Release reset of ADC clock (core clock) */
  2553. LL_APB1_GRP2_ReleaseReset(LL_APB1_GRP2_PERIPH_ADC1);
  2554. }
  2555. /**
  2556. * @brief Get the selected ADC instance enable state.
  2557. * (not only core clock: this ADC has a dual clock domain)
  2558. * @rmtoll CR ADEN LL_ADC_IsEnabled
  2559. * @param ADCx ADC instance
  2560. * @retval 0: ADC is disabled, 1: ADC is enabled.
  2561. */
  2562. __STATIC_INLINE uint32_t LL_ADC_IsEnabled(ADC_TypeDef *ADCx)
  2563. {
  2564. return (READ_BIT(ADCx->CR, ADC_CR_ADEN) == (ADC_CR_ADEN));
  2565. }
  2566. /**
  2567. * @}
  2568. */
  2569. /** @defgroup ADC_LL_EF_Operation_ADC_Group_Regular Operation on ADC hierarchical scope: group regular
  2570. * @{
  2571. */
  2572. /**
  2573. * @brief Start ADC group regular conversion.
  2574. * @note On this PY32 serie, this function is relevant for both
  2575. * internal trigger (SW start) and external trigger:
  2576. * - If ADC trigger has been set to software start, ADC conversion
  2577. * starts immediately.
  2578. * - If ADC trigger has been set to external trigger, ADC conversion
  2579. * will start at next trigger event (on the selected trigger edge)
  2580. * following the ADC start conversion command.
  2581. * @note On this PY32 serie, setting of this feature is conditioned to
  2582. * ADC state:
  2583. * ADC must be enabled without conversion on going on group regular,
  2584. * without conversion stop command on going on group regular,
  2585. * without ADC disable command on going.
  2586. * @rmtoll CR ADSTART LL_ADC_REG_StartConversion
  2587. * @param ADCx ADC instance
  2588. * @retval None
  2589. */
  2590. __STATIC_INLINE void LL_ADC_REG_StartConversion(ADC_TypeDef *ADCx)
  2591. {
  2592. /* Note: Write register with some additional bits forced to state reset */
  2593. /* instead of modifying only the selected bit for this function, */
  2594. /* to not interfere with bits with HW property "rs". */
  2595. MODIFY_REG(ADCx->CR, ADC_CR_BITS_PROPERTY_RS,ADC_CR_ADSTART);
  2596. }
  2597. /**
  2598. * @brief Stop ADC group regular conversion.
  2599. * @note On this PY32 serie, setting of this feature is conditioned to
  2600. * ADC state:
  2601. * ADC must be enabled with conversion on going on group regular,
  2602. * without ADC disable command on going.
  2603. * @rmtoll CR ADSTP LL_ADC_REG_StopConversion
  2604. * @param ADCx ADC instance
  2605. * @retval None
  2606. */
  2607. __STATIC_INLINE void LL_ADC_REG_StopConversion(ADC_TypeDef *ADCx)
  2608. {
  2609. /* Note: Write register with some additional bits forced to state reset */
  2610. /* instead of modifying only the selected bit for this function, */
  2611. /* to not interfere with bits with HW property "rs". */
  2612. MODIFY_REG(ADCx->CR,ADC_CR_BITS_PROPERTY_RS,ADC_CR_ADSTP);
  2613. }
  2614. /**
  2615. * @brief Get ADC group regular conversion state.
  2616. * @rmtoll CR ADSTART LL_ADC_REG_IsConversionOngoing
  2617. * @param ADCx ADC instance
  2618. * @retval 0: no conversion is on going on ADC group regular.
  2619. */
  2620. __STATIC_INLINE uint32_t LL_ADC_REG_IsConversionOngoing(ADC_TypeDef *ADCx)
  2621. {
  2622. return (READ_BIT(ADCx->CR, ADC_CR_ADSTART) == (ADC_CR_ADSTART));
  2623. }
  2624. /**
  2625. * @brief Get ADC group regular command of conversion stop state
  2626. * @rmtoll CR ADSTP LL_ADC_REG_IsStopConversionOngoing
  2627. * @param ADCx ADC instance
  2628. * @retval 0: no command of conversion stop is on going on ADC group regular.
  2629. */
  2630. __STATIC_INLINE uint32_t LL_ADC_REG_IsStopConversionOngoing(ADC_TypeDef *ADCx)
  2631. {
  2632. return (READ_BIT(ADCx->CR, ADC_CR_ADSTP) == (ADC_CR_ADSTP));
  2633. }
  2634. /**
  2635. * @brief Get ADC group regular conversion data, range fit for
  2636. * all ADC configurations: all ADC resolutions and
  2637. * all oversampling increased data width (for devices
  2638. * with feature oversampling).
  2639. * @rmtoll DR DATA LL_ADC_REG_ReadConversionData32
  2640. * @param ADCx ADC instance
  2641. * @retval Value between Min_Data=0x00000000 and Max_Data=0xFFFFFFFF
  2642. */
  2643. __STATIC_INLINE uint32_t LL_ADC_REG_ReadConversionData32(ADC_TypeDef *ADCx)
  2644. {
  2645. return (uint32_t)(READ_BIT(ADCx->DR, ADC_DR_DATA));
  2646. }
  2647. /**
  2648. * @brief Get ADC group regular conversion data, range fit for
  2649. * ADC resolution 12 bits.
  2650. * @note For devices with feature oversampling: Oversampling
  2651. * can increase data width, function for extended range
  2652. * may be needed: @ref LL_ADC_REG_ReadConversionData32.
  2653. * @rmtoll DR DATA LL_ADC_REG_ReadConversionData12
  2654. * @param ADCx ADC instance
  2655. * @retval Value between Min_Data=0x000 and Max_Data=0xFFF
  2656. */
  2657. __STATIC_INLINE uint16_t LL_ADC_REG_ReadConversionData12(ADC_TypeDef *ADCx)
  2658. {
  2659. return (uint16_t)(READ_BIT(ADCx->DR, ADC_DR_DATA));
  2660. }
  2661. /**
  2662. * @brief Get ADC group regular conversion data, range fit for
  2663. * ADC resolution 10 bits.
  2664. * @note For devices with feature oversampling: Oversampling
  2665. * can increase data width, function for extended range
  2666. * may be needed: @ref LL_ADC_REG_ReadConversionData32.
  2667. * @rmtoll DR DATA LL_ADC_REG_ReadConversionData10
  2668. * @param ADCx ADC instance
  2669. * @retval Value between Min_Data=0x000 and Max_Data=0x3FF
  2670. */
  2671. __STATIC_INLINE uint16_t LL_ADC_REG_ReadConversionData10(ADC_TypeDef *ADCx)
  2672. {
  2673. return (uint16_t)(READ_BIT(ADCx->DR, ADC_DR_DATA));
  2674. }
  2675. /**
  2676. * @brief Get ADC group regular conversion data, range fit for
  2677. * ADC resolution 8 bits.
  2678. * @note For devices with feature oversampling: Oversampling
  2679. * can increase data width, function for extended range
  2680. * may be needed: @ref LL_ADC_REG_ReadConversionData32.
  2681. * @rmtoll DR DATA LL_ADC_REG_ReadConversionData8
  2682. * @param ADCx ADC instance
  2683. * @retval Value between Min_Data=0x00 and Max_Data=0xFF
  2684. */
  2685. __STATIC_INLINE uint8_t LL_ADC_REG_ReadConversionData8(ADC_TypeDef *ADCx)
  2686. {
  2687. return (uint8_t)(READ_BIT(ADCx->DR, ADC_DR_DATA));
  2688. }
  2689. /**
  2690. * @brief Get ADC group regular conversion data, range fit for
  2691. * ADC resolution 6 bits.
  2692. * @note For devices with feature oversampling: Oversampling
  2693. * can increase data width, function for extended range
  2694. * may be needed: @ref LL_ADC_REG_ReadConversionData32.
  2695. * @rmtoll DR DATA LL_ADC_REG_ReadConversionData6
  2696. * @param ADCx ADC instance
  2697. * @retval Value between Min_Data=0x00 and Max_Data=0x3F
  2698. */
  2699. __STATIC_INLINE uint8_t LL_ADC_REG_ReadConversionData6(ADC_TypeDef *ADCx)
  2700. {
  2701. return (uint8_t)(READ_BIT(ADCx->DR, ADC_DR_DATA));
  2702. }
  2703. /**
  2704. * @brief Disable the selected ADC instance.
  2705. * @note On this PY32 serie, Disable the selected ADC instance
  2706. * @param ADCx ADC instance
  2707. * @retval 0: ADC Disable Failed,1:ADC Disable Success.
  2708. */
  2709. __STATIC_INLINE ErrorStatus LL_ADC_Disable(ADC_TypeDef *ADCx)
  2710. {
  2711. ErrorStatus status = SUCCESS;
  2712. uint32_t tmpCFGR1=ADCx->CFGR1;
  2713. __IO uint32_t timeout_cpu_cycles = 0U;
  2714. /* Check the parameters */
  2715. /* Disable ADC instance if not already disabled. */
  2716. if(LL_ADC_IsEnabled(ADCx) == 1U)
  2717. {
  2718. /* Set ADC group regular trigger source to SW start to ensure to not */
  2719. /* have an external trigger event occurring during the conversion stop */
  2720. /* ADC disable process. */
  2721. LL_ADC_REG_SetTriggerSource(ADCx, LL_ADC_REG_TRIG_SOFTWARE);
  2722. /* Stop potential ADC conversion on going on ADC group regular. */
  2723. if(LL_ADC_REG_IsConversionOngoing(ADCx) != 0U)
  2724. {
  2725. if(LL_ADC_REG_IsStopConversionOngoing(ADCx) == 0U)
  2726. {
  2727. LL_ADC_REG_StopConversion(ADCx);
  2728. }
  2729. }
  2730. else
  2731. {
  2732. (ADCx->CFGR1)|=(0x7<<6);
  2733. (ADCx->CFGR1)|=(0x3<<10);
  2734. __disable_irq();
  2735. LL_ADC_REG_StartConversion(ADCx);
  2736. LL_ADC_REG_StopConversion(ADCx);
  2737. __enable_irq();
  2738. }
  2739. /* Wait for ADC conversions are effectively stopped */
  2740. timeout_cpu_cycles =LL_ADC_TIMEOUT_STOP_CONVERSION_CPU_CYCLES;
  2741. while (LL_ADC_REG_IsStopConversionOngoing(ADCx) == 1U)
  2742. {
  2743. if(timeout_cpu_cycles-- == 0U)
  2744. {
  2745. /* Time-out error */
  2746. status = ERROR;
  2747. }
  2748. }
  2749. /* Wait for ADC instance is effectively disabled */
  2750. timeout_cpu_cycles =LL_ADC_TIMEOUT_DISABLE_CPU_CYCLES;
  2751. while (LL_ADC_IsEnabled(ADCx) == 1U)
  2752. {
  2753. if(timeout_cpu_cycles-- == 0U)
  2754. {
  2755. /* Time-out error */
  2756. status = ERROR;
  2757. }
  2758. }
  2759. /* Restore the CFGR1 Configure */
  2760. ADCx->CFGR1=tmpCFGR1;
  2761. }
  2762. return status;
  2763. }
  2764. /**
  2765. * @}
  2766. */
  2767. /** @defgroup ADC_LL_EF_FLAG_Management ADC flag management
  2768. * @{
  2769. */
  2770. /**
  2771. * @brief Get flag ADC group regular end of unitary conversion.
  2772. * @rmtoll ISR EOC LL_ADC_IsActiveFlag_EOC
  2773. * @param ADCx ADC instance
  2774. * @retval State of bit (1 or 0).
  2775. */
  2776. __STATIC_INLINE uint32_t LL_ADC_IsActiveFlag_EOC(ADC_TypeDef *ADCx)
  2777. {
  2778. return (READ_BIT(ADCx->ISR, ADC_ISR_EOC) == (ADC_ISR_EOC));
  2779. }
  2780. /**
  2781. * @brief Get flag ADC group regular end of sequence conversions.
  2782. * @rmtoll ISR EOSEQ LL_ADC_IsActiveFlag_EOS
  2783. * @param ADCx ADC instance
  2784. * @retval State of bit (1 or 0).
  2785. */
  2786. __STATIC_INLINE uint32_t LL_ADC_IsActiveFlag_EOS(ADC_TypeDef *ADCx)
  2787. {
  2788. return (READ_BIT(ADCx->ISR, LL_ADC_FLAG_EOS) == (LL_ADC_FLAG_EOS));
  2789. }
  2790. /**
  2791. * @brief Get flag ADC group regular overrun.
  2792. * @rmtoll ISR OVR LL_ADC_IsActiveFlag_OVR
  2793. * @param ADCx ADC instance
  2794. * @retval State of bit (1 or 0).
  2795. */
  2796. __STATIC_INLINE uint32_t LL_ADC_IsActiveFlag_OVR(ADC_TypeDef *ADCx)
  2797. {
  2798. return (READ_BIT(ADCx->ISR, LL_ADC_FLAG_OVR) == (LL_ADC_FLAG_OVR));
  2799. }
  2800. /**
  2801. * @brief Get flag ADC group regular end of sampling phase.
  2802. * @rmtoll ISR EOSMP LL_ADC_IsActiveFlag_EOSMP
  2803. * @param ADCx ADC instance
  2804. * @retval State of bit (1 or 0).
  2805. */
  2806. __STATIC_INLINE uint32_t LL_ADC_IsActiveFlag_EOSMP(ADC_TypeDef *ADCx)
  2807. {
  2808. return (READ_BIT(ADCx->ISR, LL_ADC_FLAG_EOSMP) == (LL_ADC_FLAG_EOSMP));
  2809. }
  2810. /**
  2811. * @brief Get flag ADC analog watchdog 1 flag
  2812. * @rmtoll ISR AWD LL_ADC_IsActiveFlag_AWD
  2813. * @param ADCx ADC instance
  2814. * @retval State of bit (1 or 0).
  2815. */
  2816. __STATIC_INLINE uint32_t LL_ADC_IsActiveFlag_AWD(ADC_TypeDef *ADCx)
  2817. {
  2818. return (READ_BIT(ADCx->ISR, LL_ADC_FLAG_AWD) == (LL_ADC_FLAG_AWD));
  2819. }
  2820. /**
  2821. * @brief Clear flag ADC group regular end of unitary conversion.
  2822. * @rmtoll ISR EOC LL_ADC_ClearFlag_EOC
  2823. * @param ADCx ADC instance
  2824. * @retval None
  2825. */
  2826. __STATIC_INLINE void LL_ADC_ClearFlag_EOC(ADC_TypeDef *ADCx)
  2827. {
  2828. WRITE_REG(ADCx->ISR, LL_ADC_FLAG_EOC);
  2829. }
  2830. /**
  2831. * @brief Clear flag ADC group regular end of sequence conversions.
  2832. * @rmtoll ISR EOSEQ LL_ADC_ClearFlag_EOS
  2833. * @param ADCx ADC instance
  2834. * @retval None
  2835. */
  2836. __STATIC_INLINE void LL_ADC_ClearFlag_EOS(ADC_TypeDef *ADCx)
  2837. {
  2838. WRITE_REG(ADCx->ISR, LL_ADC_FLAG_EOS);
  2839. }
  2840. /**
  2841. * @brief Clear flag ADC group regular overrun.
  2842. * @rmtoll ISR OVR LL_ADC_ClearFlag_OVR
  2843. * @param ADCx ADC instance
  2844. * @retval None
  2845. */
  2846. __STATIC_INLINE void LL_ADC_ClearFlag_OVR(ADC_TypeDef *ADCx)
  2847. {
  2848. WRITE_REG(ADCx->ISR, LL_ADC_FLAG_OVR);
  2849. }
  2850. /**
  2851. * @brief Clear flag ADC group regular end of sampling phase.
  2852. * @rmtoll ISR EOSMP LL_ADC_ClearFlag_EOSMP
  2853. * @param ADCx ADC instance
  2854. * @retval None
  2855. */
  2856. __STATIC_INLINE void LL_ADC_ClearFlag_EOSMP(ADC_TypeDef *ADCx)
  2857. {
  2858. WRITE_REG(ADCx->ISR, LL_ADC_FLAG_EOSMP);
  2859. }
  2860. /**
  2861. * @brief Clear flag ADC analog watchdog 1.
  2862. * @rmtoll ISR AWD LL_ADC_ClearFlag_AWD
  2863. * @param ADCx ADC instance
  2864. * @retval None
  2865. */
  2866. __STATIC_INLINE void LL_ADC_ClearFlag_AWD(ADC_TypeDef *ADCx)
  2867. {
  2868. WRITE_REG(ADCx->ISR, LL_ADC_FLAG_AWD);
  2869. }
  2870. /**
  2871. * @}
  2872. */
  2873. /** @defgroup ADC_LL_EF_IT_Management ADC IT management
  2874. * @{
  2875. */
  2876. /**
  2877. * @brief Enable interruption ADC group regular end of unitary conversion.
  2878. * @rmtoll IER EOCIE LL_ADC_EnableIT_EOC
  2879. * @param ADCx ADC instance
  2880. * @retval None
  2881. */
  2882. __STATIC_INLINE void LL_ADC_EnableIT_EOC(ADC_TypeDef *ADCx)
  2883. {
  2884. SET_BIT(ADCx->IER, LL_ADC_IT_EOC);
  2885. }
  2886. /**
  2887. * @brief Enable interruption ADC group regular end of sequence conversions.
  2888. * @rmtoll IER EOSEQIE LL_ADC_EnableIT_EOS
  2889. * @param ADCx ADC instance
  2890. * @retval None
  2891. */
  2892. __STATIC_INLINE void LL_ADC_EnableIT_EOS(ADC_TypeDef *ADCx)
  2893. {
  2894. SET_BIT(ADCx->IER, LL_ADC_IT_EOS);
  2895. }
  2896. /**
  2897. * @brief Enable ADC group regular interruption overrun.
  2898. * @rmtoll IER OVRIE LL_ADC_EnableIT_OVR
  2899. * @param ADCx ADC instance
  2900. * @retval None
  2901. */
  2902. __STATIC_INLINE void LL_ADC_EnableIT_OVR(ADC_TypeDef *ADCx)
  2903. {
  2904. SET_BIT(ADCx->IER, LL_ADC_IT_OVR);
  2905. }
  2906. /**
  2907. * @brief Enable interruption ADC group regular end of sampling.
  2908. * @rmtoll IER EOSMPIE LL_ADC_EnableIT_EOSMP
  2909. * @param ADCx ADC instance
  2910. * @retval None
  2911. */
  2912. __STATIC_INLINE void LL_ADC_EnableIT_EOSMP(ADC_TypeDef *ADCx)
  2913. {
  2914. SET_BIT(ADCx->IER, LL_ADC_IT_EOSMP);
  2915. }
  2916. /**
  2917. * @brief Enable interruption ADC analog watchdog 1.
  2918. * @rmtoll IER AWDIE LL_ADC_EnableIT_AWD
  2919. * @param ADCx ADC instance
  2920. * @retval None
  2921. */
  2922. __STATIC_INLINE void LL_ADC_EnableIT_AWD(ADC_TypeDef *ADCx)
  2923. {
  2924. SET_BIT(ADCx->IER, LL_ADC_IT_AWD);
  2925. }
  2926. /**
  2927. * @brief Disable interruption ADC group regular end of unitary conversion.
  2928. * @rmtoll IER EOCIE LL_ADC_DisableIT_EOC
  2929. * @param ADCx ADC instance
  2930. * @retval None
  2931. */
  2932. __STATIC_INLINE void LL_ADC_DisableIT_EOC(ADC_TypeDef *ADCx)
  2933. {
  2934. CLEAR_BIT(ADCx->IER, LL_ADC_IT_EOC);
  2935. }
  2936. /**
  2937. * @brief Disable interruption ADC group regular end of sequence conversions.
  2938. * @rmtoll IER EOSEQIE LL_ADC_DisableIT_EOS
  2939. * @param ADCx ADC instance
  2940. * @retval None
  2941. */
  2942. __STATIC_INLINE void LL_ADC_DisableIT_EOS(ADC_TypeDef *ADCx)
  2943. {
  2944. CLEAR_BIT(ADCx->IER, LL_ADC_IT_EOS);
  2945. }
  2946. /**
  2947. * @brief Disable interruption ADC group regular overrun.
  2948. * @rmtoll IER OVRIE LL_ADC_DisableIT_OVR
  2949. * @param ADCx ADC instance
  2950. * @retval None
  2951. */
  2952. __STATIC_INLINE void LL_ADC_DisableIT_OVR(ADC_TypeDef *ADCx)
  2953. {
  2954. CLEAR_BIT(ADCx->IER, LL_ADC_IT_OVR);
  2955. }
  2956. /**
  2957. * @brief Disable interruption ADC group regular end of sampling.
  2958. * @rmtoll IER EOSMPIE LL_ADC_DisableIT_EOSMP
  2959. * @param ADCx ADC instance
  2960. * @retval None
  2961. */
  2962. __STATIC_INLINE void LL_ADC_DisableIT_EOSMP(ADC_TypeDef *ADCx)
  2963. {
  2964. CLEAR_BIT(ADCx->IER, LL_ADC_IT_EOSMP);
  2965. }
  2966. /**
  2967. * @brief Disable interruption ADC analog watchdog 1.
  2968. * @rmtoll IER AWDIE LL_ADC_DisableIT_AWD
  2969. * @param ADCx ADC instance
  2970. * @retval None
  2971. */
  2972. __STATIC_INLINE void LL_ADC_DisableIT_AWD(ADC_TypeDef *ADCx)
  2973. {
  2974. CLEAR_BIT(ADCx->IER, LL_ADC_IT_AWD);
  2975. }
  2976. /**
  2977. * @brief Get state of interruption ADC group regular end of unitary conversion
  2978. * (0: interrupt disabled, 1: interrupt enabled).
  2979. * @rmtoll IER EOCIE LL_ADC_IsEnabledIT_EOC
  2980. * @param ADCx ADC instance
  2981. * @retval State of bit (1 or 0).
  2982. */
  2983. __STATIC_INLINE uint32_t LL_ADC_IsEnabledIT_EOC(ADC_TypeDef *ADCx)
  2984. {
  2985. return (READ_BIT(ADCx->IER, LL_ADC_IT_EOC) == (LL_ADC_IT_EOC));
  2986. }
  2987. /**
  2988. * @brief Get state of interruption ADC group regular end of sequence conversions
  2989. * (0: interrupt disabled, 1: interrupt enabled).
  2990. * @rmtoll IER EOSEQIE LL_ADC_IsEnabledIT_EOS
  2991. * @param ADCx ADC instance
  2992. * @retval State of bit (1 or 0).
  2993. */
  2994. __STATIC_INLINE uint32_t LL_ADC_IsEnabledIT_EOS(ADC_TypeDef *ADCx)
  2995. {
  2996. return (READ_BIT(ADCx->IER, LL_ADC_IT_EOS) == (LL_ADC_IT_EOS));
  2997. }
  2998. /**
  2999. * @brief Get state of interruption ADC group regular overrun
  3000. * (0: interrupt disabled, 1: interrupt enabled).
  3001. * @rmtoll IER OVRIE LL_ADC_IsEnabledIT_OVR
  3002. * @param ADCx ADC instance
  3003. * @retval State of bit (1 or 0).
  3004. */
  3005. __STATIC_INLINE uint32_t LL_ADC_IsEnabledIT_OVR(ADC_TypeDef *ADCx)
  3006. {
  3007. return (READ_BIT(ADCx->IER, LL_ADC_IT_OVR) == (LL_ADC_IT_OVR));
  3008. }
  3009. /**
  3010. * @brief Get state of interruption ADC group regular end of sampling
  3011. * (0: interrupt disabled, 1: interrupt enabled).
  3012. * @rmtoll IER EOSMPIE LL_ADC_IsEnabledIT_EOSMP
  3013. * @param ADCx ADC instance
  3014. * @retval State of bit (1 or 0).
  3015. */
  3016. __STATIC_INLINE uint32_t LL_ADC_IsEnabledIT_EOSMP(ADC_TypeDef *ADCx)
  3017. {
  3018. return (READ_BIT(ADCx->IER, LL_ADC_IT_EOSMP) == (LL_ADC_IT_EOSMP));
  3019. }
  3020. /**
  3021. * @brief Get state of interruption ADC analog watchdog 1
  3022. * (0: interrupt disabled, 1: interrupt enabled).
  3023. * @rmtoll IER AWDIE LL_ADC_IsEnabledIT_AWD
  3024. * @param ADCx ADC instance
  3025. * @retval State of bit (1 or 0).
  3026. */
  3027. __STATIC_INLINE uint32_t LL_ADC_IsEnabledIT_AWD(ADC_TypeDef *ADCx)
  3028. {
  3029. return (READ_BIT(ADCx->IER, LL_ADC_IT_AWD) == (LL_ADC_IT_AWD));
  3030. }
  3031. /**
  3032. * @}
  3033. */
  3034. /** @defgroup ADC_LL_EF_Calibration_Management ADC Calibration management
  3035. * @{
  3036. */
  3037. /**
  3038. * @brief Set calibration sample time
  3039. * @note Unit: ADC clock cycles.
  3040. * @rmtoll CCSR CALSMP LL_ADC_SetCalSamplingTime
  3041. * @param ADCx ADC instance
  3042. * @param CalibrationSamplingTime This parameter can be one of the following values:
  3043. * @arg @ref LL_ADC_CAL_SAMPLINGTIME_2CYCLES
  3044. * @arg @ref LL_ADC_CAL_SAMPLINGTIME_4CYCLES
  3045. * @arg @ref LL_ADC_CAL_SAMPLINGTIME_8CYCLES
  3046. * @arg @ref LL_ADC_CAL_SAMPLINGTIME_1CYCLE
  3047. * @retval None
  3048. */
  3049. __STATIC_INLINE void LL_ADC_SetCalibrationSamplingTime(ADC_TypeDef *ADCx, uint32_t CalibrationSamplingTime)
  3050. {
  3051. MODIFY_REG(ADCx->CCSR, ADC_CCSR_CALSMP, CalibrationSamplingTime);
  3052. }
  3053. /**
  3054. * @brief Get sampling time common to a group of channels.
  3055. * @note Unit: ADC clock cycles.
  3056. * @rmtoll CCSR CALSMP LL_ADC_GetCalSamplingTime
  3057. * @param ADCx ADC instance
  3058. * @retval Returned value can be one of the following values:
  3059. * @arg @ref LL_ADC_CAL_SAMPLINGTIME_2CYCLES
  3060. * @arg @ref LL_ADC_CAL_SAMPLINGTIME_4CYCLES
  3061. * @arg @ref LL_ADC_CAL_SAMPLINGTIME_8CYCLES
  3062. * @arg @ref LL_ADC_CAL_SAMPLINGTIME_1CYCLE
  3063. */
  3064. __STATIC_INLINE uint32_t LL_ADC_GetCalibrationSamplingTime(ADC_TypeDef *ADCx)
  3065. {
  3066. return (uint32_t)(READ_BIT(ADCx->CCSR, ADC_CCSR_CALSMP));
  3067. }
  3068. /**
  3069. * @brief Clear the calibration status
  3070. * @rmtoll CCSR CALFAIL LL_ADC_ClearCalibrationStatus
  3071. * @param ADCx ADC instance
  3072. * @retval None
  3073. */
  3074. __STATIC_INLINE void LL_ADC_ClearCalibrationStatus(ADC_TypeDef *ADCx)
  3075. {
  3076. SET_BIT(ADCx->CCSR, ADC_CCSR_CALFAIL);
  3077. }
  3078. /**
  3079. * @brief Get the calibration status
  3080. * @rmtoll CCSR CALFAIL LL_ADC_GetCalibrationStatus
  3081. * @param ADCx ADC instance
  3082. * @retval Returned value can be one of the following values:
  3083. * @arg @ref LL_ADC_CAL_STATUS_SUCCESS
  3084. * @arg @ref LL_ADC_CAL_STATUS_FAIL
  3085. * @arg @ref LL_ADC_CAL_STATUS_ONGOING
  3086. * @arg @ref LL_ADC_CAL_STATUS_INVALID
  3087. */
  3088. __STATIC_INLINE uint32_t LL_ADC_GetCalibrationStatus(ADC_TypeDef *ADCx)
  3089. {
  3090. return (uint32_t)(READ_BIT(ADCx->CCSR, ADC_CCSR_CALFAIL)) | (uint32_t)(READ_BIT(ADCx->CCSR, ADC_CCSR_CALON));
  3091. }
  3092. /**
  3093. * @brief Set the calibration mode
  3094. * @rmtoll CCSR CALSEL LL_ADC_SetCalibrationMode
  3095. * @param ADCx ADC instance
  3096. * @param CalibrationMode This parameter can be one of the following values:
  3097. @arg @ref LL_ADC_CAL_MODE_OFFSET
  3098. * @arg @ref LL_ADC_CAL_MODE_OFFSETANDLINEARITY
  3099. * @retval None
  3100. */
  3101. __STATIC_INLINE void LL_ADC_SetCalibrationMode(ADC_TypeDef *ADCx,uint32_t CalibrationMode)
  3102. {
  3103. MODIFY_REG(ADCx->CCSR,ADC_CCSR_CALSEL, CalibrationMode);
  3104. }
  3105. /**
  3106. * @brief Get the calibration contents
  3107. * @rmtoll CCSR CALSEL LL_ADC_GetCalibrationMode
  3108. * @param ADCx ADC instance
  3109. * @retval Returned value can be one of the following values:
  3110. * @arg @ref LL_ADC_CAL_MODE_OFFSET
  3111. * @arg @ref LL_ADC_CAL_MODE_OFFSETANDLINEARITY
  3112. */
  3113. __STATIC_INLINE uint32_t LL_ADC_GetCalibrationMode(ADC_TypeDef *ADCx)
  3114. {
  3115. return (uint32_t)(READ_BIT(ADCx->CCSR, ADC_CCSR_CALSEL));
  3116. }
  3117. /**
  3118. * @}
  3119. */
  3120. #if defined(USE_FULL_LL_DRIVER)
  3121. /** @defgroup ADC_LL_EF_Init Initialization and de-initialization functions
  3122. * @{
  3123. */
  3124. /* Initialization of some features of ADC common parameters and multimode */
  3125. /* Note: On this PY32 serie, there is no ADC common initialization */
  3126. /* function. */
  3127. ErrorStatus LL_ADC_CommonDeInit(ADC_Common_TypeDef *ADCxy_COMMON);
  3128. /* De-initialization of ADC instance */
  3129. ErrorStatus LL_ADC_DeInit(ADC_TypeDef *ADCx);
  3130. /* Initialization of some features of ADC instance */
  3131. ErrorStatus LL_ADC_Init(ADC_TypeDef *ADCx, LL_ADC_InitTypeDef *ADC_InitStruct);
  3132. void LL_ADC_StructInit(LL_ADC_InitTypeDef *ADC_InitStruct);
  3133. /* Initialization of some features of ADC instance and ADC group regular */
  3134. ErrorStatus LL_ADC_REG_Init(ADC_TypeDef *ADCx, LL_ADC_REG_InitTypeDef *ADC_REG_InitStruct);
  3135. void LL_ADC_REG_StructInit(LL_ADC_REG_InitTypeDef *ADC_REG_InitStruct);
  3136. /**
  3137. * @}
  3138. */
  3139. #endif /* USE_FULL_LL_DRIVER */
  3140. /**
  3141. * @}
  3142. */
  3143. /**
  3144. * @}
  3145. */
  3146. #endif /* ADC1 */
  3147. /**
  3148. * @}
  3149. */
  3150. #ifdef __cplusplus
  3151. }
  3152. #endif
  3153. #endif /* __PY32F0xx_LL_ADC_H */
  3154. /************************ (C) COPYRIGHT Puya *****END OF FILE****/