stm32f4xx_ll_adc.h 279 KB

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