stm32f7xx_ll_adc.h 274 KB

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