You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

stm32l1xx_ll_adc.h 319KB

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