stm32f3xx_hal_adc_ex.h 251 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965
  1. /**
  2. ******************************************************************************
  3. * @file stm32f3xx_hal_adc_ex.h
  4. * @author MCD Application Team
  5. * @brief Header file containing functions prototypes of ADC HAL library.
  6. ******************************************************************************
  7. * @attention
  8. *
  9. * Copyright (c) 2016 STMicroelectronics.
  10. * All rights reserved.
  11. *
  12. * This software is licensed under terms that can be found in the LICENSE file
  13. * in the root directory of this software component.
  14. * If no LICENSE file comes with this software, it is provided AS-IS.
  15. *
  16. ******************************************************************************
  17. */
  18. /* Define to prevent recursive inclusion -------------------------------------*/
  19. #ifndef __STM32F3xx_ADC_EX_H
  20. #define __STM32F3xx_ADC_EX_H
  21. #ifdef __cplusplus
  22. extern "C" {
  23. #endif
  24. /* Includes ------------------------------------------------------------------*/
  25. #include "stm32f3xx_hal_def.h"
  26. /** @addtogroup STM32F3xx_HAL_Driver
  27. * @{
  28. */
  29. /** @addtogroup ADCEx ADCEx
  30. * @{
  31. */
  32. /* Exported types ------------------------------------------------------------*/
  33. /** @defgroup ADCEx_Exported_Types ADCEx Exported Types
  34. * @{
  35. */
  36. struct __ADC_HandleTypeDef;
  37. #if defined(STM32F302xE) || defined(STM32F303xE) || defined(STM32F398xx) || \
  38. defined(STM32F302xC) || defined(STM32F303xC) || defined(STM32F358xx) || \
  39. defined(STM32F303x8) || defined(STM32F334x8) || defined(STM32F328xx) || \
  40. defined(STM32F301x8) || defined(STM32F302x8) || defined(STM32F318xx)
  41. /**
  42. * @brief Structure definition of ADC initialization and regular group
  43. * @note Parameters of this structure are shared within 2 scopes:
  44. * - Scope entire ADC (affects regular and injected groups): ClockPrescaler, Resolution, DataAlign,
  45. * ScanConvMode, EOCSelection, LowPowerAutoWait.
  46. * - Scope regular group: ContinuousConvMode, NbrOfConversion, DiscontinuousConvMode, NbrOfDiscConversion, ExternalTrigConvEdge, ExternalTrigConv, DMAContinuousRequests, Overrun.
  47. * @note The setting of these parameters with function HAL_ADC_Init() is conditioned to ADC state.
  48. * ADC state can be either:
  49. * - For all parameters: ADC disabled
  50. * - For all parameters except 'LowPowerAutoWait' and 'DMAContinuousRequests': ADC enabled without conversion on going on regular group.
  51. * - For parameters 'LowPowerAutoWait' and 'DMAContinuousRequests': ADC enabled without conversion on going on regular and injected groups.
  52. * If ADC is not in the appropriate state to modify some parameters, these parameters setting is bypassed
  53. * without error reporting (as it can be the expected behaviour in case of intended action to update another parameter (which fulfills the ADC state condition) on the fly).
  54. */
  55. typedef struct
  56. {
  57. uint32_t ClockPrescaler; /*!< Select ADC clock source (synchronous clock derived from AHB clock or asynchronous clock derived from ADC dedicated PLL 72MHz) and clock prescaler.
  58. The clock is common for all the ADCs.
  59. This parameter can be a value of @ref ADCEx_ClockPrescaler
  60. Note: In case of usage of channels on injected group, ADC frequency should be lower than AHB clock frequency /4 for resolution 12 or 10 bits,
  61. AHB clock frequency /3 for resolution 8 bits, AHB clock frequency /2 for resolution 6 bits.
  62. Note: In case of usage of the ADC dedicated PLL clock, this clock must be preliminarily enabled and prescaler set at RCC top level.
  63. Note: This parameter can be modified only if all ADCs of the common ADC group are disabled (for products with several ADCs) */
  64. uint32_t Resolution; /*!< Configures the ADC resolution.
  65. This parameter can be a value of @ref ADCEx_Resolution */
  66. uint32_t DataAlign; /*!< Specifies ADC data alignment to right (for resolution 12 bits: MSB on register bit 11 and LSB on register bit 0U) (default setting)
  67. or to left (for resolution 12 bits, if offset disabled: MSB on register bit 15 and LSB on register bit 4U, if offset enabled: MSB on register bit 14 and LSB on register bit 3U).
  68. See reference manual for alignments with other resolutions.
  69. This parameter can be a value of @ref ADCEx_Data_align */
  70. uint32_t ScanConvMode; /*!< Configures the sequencer of regular and injected groups.
  71. This parameter can be associated to parameter 'DiscontinuousConvMode' to have main sequence subdivided in successive parts.
  72. If disabled: Conversion is performed in single mode (one channel converted, the one defined in rank 1U).
  73. Parameters 'NbrOfConversion' and 'InjectedNbrOfConversion' are discarded (equivalent to set to 1U).
  74. If enabled: Conversions are performed in sequence mode (multiple ranks defined by 'NbrOfConversion'/'InjectedNbrOfConversion' and each channel rank).
  75. Scan direction is upward: from rank1 to rank 'n'.
  76. This parameter can be a value of @ref ADCEx_Scan_mode */
  77. uint32_t EOCSelection; /*!< Specifies what EOC (End Of Conversion) flag is used for conversion by polling and interruption: end of conversion of each rank or complete sequence.
  78. This parameter can be a value of @ref ADCEx_EOCSelection. */
  79. FunctionalState LowPowerAutoWait; /*!< Selects the dynamic low power Auto Delay: ADC conversions are performed only when necessary.
  80. New conversion starts only when the previous conversion (for regular group) or previous sequence (for injected group) has been treated by user software.
  81. This feature automatically adapts the speed of ADC to the speed of the system that reads the data. Moreover, this avoids risk of overrun for low frequency applications.
  82. This parameter can be set to ENABLE or DISABLE.
  83. Note: It is not recommended to use with interruption or DMA (HAL_ADC_Start_IT(), HAL_ADC_Start_DMA()) since these modes have to clear immediately the EOC flag (by CPU to free the IRQ pending event or by DMA).
  84. Auto wait will work but fort a very short time, discarding its intended benefit (except specific case of high load of CPU or DMA transfers which can justify usage of auto wait).
  85. Do use with polling: 1. Start conversion with HAL_ADC_Start(), 2. Later on, when ADC conversion data is needed:
  86. and use HAL_ADC_GetValue() to retrieve conversion result and trig another conversion (in case of usage of injected group, use the equivalent functions HAL_ADCExInjected_Start(), HAL_ADCEx_InjectedGetValue(), ...). */
  87. FunctionalState ContinuousConvMode; /*!< Specifies whether the conversion is performed in single mode (one conversion) or continuous mode for regular group,
  88. after the selected trigger occurred (software start or external trigger).
  89. This parameter can be set to ENABLE or DISABLE. */
  90. uint32_t NbrOfConversion; /*!< Specifies the number of ranks that will be converted within the regular group sequencer.
  91. To use the regular group sequencer and convert several ranks, parameter 'ScanConvMode' must be enabled.
  92. This parameter must be a number between Min_Data = 1 and Max_Data = 16.
  93. Note: This parameter must be modified when no conversion is on going on regular group (ADC disabled, or ADC enabled without continuous mode or external trigger that could launch a conversion). */
  94. FunctionalState DiscontinuousConvMode; /*!< Specifies whether the conversions sequence of regular group is performed in Complete-sequence/Discontinuous-sequence (main sequence subdivided in successive parts).
  95. Discontinuous mode is used only if sequencer is enabled (parameter 'ScanConvMode'). If sequencer is disabled, this parameter is discarded.
  96. Discontinuous mode can be enabled only if continuous mode is disabled. If continuous mode is enabled, this parameter setting is discarded.
  97. This parameter can be set to ENABLE or DISABLE. */
  98. uint32_t NbrOfDiscConversion; /*!< Specifies the number of discontinuous conversions in which the main sequence of regular group (parameter NbrOfConversion) will be subdivided.
  99. If parameter 'DiscontinuousConvMode' is disabled, this parameter is discarded.
  100. This parameter must be a number between Min_Data = 1 and Max_Data = 8. */
  101. uint32_t ExternalTrigConv; /*!< Selects the external event used to trigger the conversion start of regular group.
  102. If set to ADC_SOFTWARE_START, external triggers are disabled.
  103. This parameter can be a value of @ref ADCEx_External_trigger_source_Regular
  104. Caution: For devices with several ADCs, external trigger source is common to ADC common group (for example: ADC1&ADC2, ADC3&ADC4, if available) */
  105. uint32_t ExternalTrigConvEdge; /*!< Selects the external trigger edge of regular group.
  106. If trigger is set to ADC_SOFTWARE_START, this parameter is discarded.
  107. This parameter can be a value of @ref ADCEx_External_trigger_edge_Regular */
  108. FunctionalState DMAContinuousRequests; /*!< Specifies whether the DMA requests are performed in one shot mode (DMA transfer stop when number of conversions is reached)
  109. or in Continuous mode (DMA transfer unlimited, whatever number of conversions).
  110. Note: In continuous mode, DMA must be configured in circular mode. Otherwise an overrun will be triggered when DMA buffer maximum pointer is reached.
  111. This parameter can be set to ENABLE or DISABLE.
  112. Note: This parameter must be modified when no conversion is on going on both regular and injected groups (ADC disabled, or ADC enabled without continuous mode or external trigger that could launch a conversion). */
  113. uint32_t Overrun; /*!< Select the behaviour in case of overrun: data overwritten (default) or preserved.
  114. This parameter is for regular group only.
  115. This parameter can be a value of @ref ADCEx_Overrun
  116. Note: Case of overrun set to data preserved and usage with end on conversion interruption (HAL_Start_IT()): ADC IRQ handler has to clear end of conversion flags, this induces the release of the preserved data. If needed, this data can be saved into function HAL_ADC_ConvCpltCallback() (called before end of conversion flags clear).
  117. Note: Error reporting in function of conversion mode:
  118. - Usage with ADC conversion by polling for event or interruption: Error is reported only if overrun is set to data preserved. If overrun is set to data overwritten, user can willingly not read the conversion data each time, this is not considered as an erroneous case.
  119. - Usage with ADC conversion by DMA: Error is reported whatever overrun setting (DMA is expected to process all data from data register, any data missed would be abnormal). */
  120. }ADC_InitTypeDef;
  121. /**
  122. * @brief Structure definition of ADC channel for regular group
  123. * @note The setting of these parameters with function HAL_ADC_ConfigChannel() is conditioned to ADC state.
  124. * ADC state can be either:
  125. * - For all parameters: ADC disabled (this is the only possible ADC state to modify parameter 'SingleDiff')
  126. * - For all except parameters 'SamplingTime', 'Offset', 'OffsetNumber': ADC enabled without conversion on going on regular group.
  127. * - For parameters 'SamplingTime', 'Offset', 'OffsetNumber': ADC enabled without conversion on going on regular and injected groups.
  128. * If ADC is not in the appropriate state to modify some parameters, these parameters setting is bypassed
  129. * without error reporting (as it can be the expected behaviour in case of intended action to update another parameter (which fulfills the ADC state condition) on the fly).
  130. */
  131. typedef struct
  132. {
  133. uint32_t Channel; /*!< Specifies the channel to configure into ADC regular group.
  134. This parameter can be a value of @ref ADCEx_channels
  135. Note: Depending on devices, some channels may not be available on package pins. Refer to device datasheet for channels availability. */
  136. uint32_t Rank; /*!< Specifies the rank in the regular group sequencer.
  137. This parameter can be a value of @ref ADCEx_regular_rank
  138. Note: In case of need to disable a channel or change order of conversion sequencer, rank containing a previous channel setting can be overwritten by the new channel setting (or parameter number of conversions can be adjusted) */
  139. uint32_t SamplingTime; /*!< Sampling time value to be set for the selected channel.
  140. Unit: ADC clock cycles
  141. Conversion time is the addition of sampling time and processing time (12.5 ADC clock cycles at ADC resolution 12 bits, 10.5 cycles at 10 bits, 8.5 cycles at 8 bits, 6.5 cycles at 6 bits).
  142. This parameter can be a value of @ref ADCEx_sampling_times
  143. Caution: This parameter updates the parameter property of the channel, that can be used into regular and/or injected groups.
  144. If this same channel has been previously configured in the other group (regular/injected), it will be updated to last setting.
  145. Note: In case of usage of internal measurement channels (VrefInt/Vbat/TempSensor),
  146. sampling time constraints must be respected (sampling time can be adjusted in function of ADC clock frequency and sampling time setting)
  147. Refer to device datasheet for timings values, parameters TS_vrefint, TS_vbat, TS_temp (values rough order: 2.2us min). */
  148. uint32_t SingleDiff; /*!< Selection of single-ended or differential input.
  149. In differential mode: Differential measurement is between the selected channel 'i' (positive input) and channel 'i+1' (negative input).
  150. Only channel 'i' has to be configured, channel 'i+1' is configured automatically.
  151. This parameter must be a value of @ref ADCEx_SingleDifferential
  152. Caution: This parameter updates the parameter property of the channel, that can be used into regular and/or injected groups.
  153. If this same channel has been previously configured in the other group (regular/injected), it will be updated to last setting.
  154. Note: Channels 1 to 14 are available in differential mode. Channels 15U, 16U, 17U, 18 can be used only in single-ended mode.
  155. Note: When configuring a channel 'i' in differential mode, the channel 'i+1' is not usable separately.
  156. Note: This parameter must be modified when ADC is disabled (before ADC start conversion or after ADC stop conversion).
  157. If ADC is enabled, this parameter setting is bypassed without error reporting (as it can be the expected behaviour in case of another parameter update on the fly) */
  158. uint32_t OffsetNumber; /*!< Selects the offset number
  159. This parameter can be a value of @ref ADCEx_OffsetNumber
  160. Caution: Only one channel is allowed per channel. If another channel was on this offset number, the offset will be changed to the new channel */
  161. uint32_t Offset; /*!< Defines the offset to be subtracted from the raw converted data when convert channels.
  162. Offset value must be a positive number.
  163. Depending of ADC resolution selected (12U, 10U, 8 or 6 bits), this parameter must be a number between Min_Data = 0x000 and Max_Data = 0xFFFU, 0x3FFU, 0xFF or 0x3F respectively.
  164. Note: This parameter must be modified when no conversion is on going on both regular and injected groups (ADC disabled, or ADC enabled without continuous mode or external trigger that could launch a conversion). */
  165. }ADC_ChannelConfTypeDef;
  166. /**
  167. * @brief Structure definition of ADC injected group and ADC channel for injected group
  168. * @note Parameters of this structure are shared within 2 scopes:
  169. * - Scope channel: InjectedChannel, InjectedRank, InjectedSamplingTime , InjectedSingleDiff, InjectedOffsetNumber, InjectedOffset
  170. * - Scope injected group (affects all channels of injected group): InjectedNbrOfConversion, InjectedDiscontinuousConvMode,
  171. * AutoInjectedConv, QueueInjectedContext, ExternalTrigInjecConvEdge, ExternalTrigInjecConv.
  172. * @note The setting of these parameters with function HAL_ADCEx_InjectedConfigChannel() is conditioned to ADC state.
  173. * ADC state can be either:
  174. * - For all parameters: ADC disabled (this is the only possible ADC state to modify parameter 'InjectedSingleDiff')
  175. * - For parameters 'InjectedDiscontinuousConvMode', 'QueueInjectedContext': ADC enabled without conversion on going on injected group.
  176. * - For parameters 'InjectedSamplingTime', 'InjectedOffset', 'InjectedOffsetNumber', 'AutoInjectedConv': ADC enabled without conversion on going on regular and injected groups.
  177. * - For parameters 'InjectedChannel', 'InjectedRank', 'InjectedNbrOfConversion', 'ExternalTrigInjecConv', 'ExternalTrigInjecConvEdge': ADC enabled and while conversion on going on regular and injected groups.
  178. * If ADC is not in the appropriate state to modify some parameters, these parameters setting is bypassed
  179. * without error reporting (as it can be the expected behaviour in case of intended action to update another parameter (which fulfills the ADC state condition) on the fly).
  180. */
  181. typedef struct
  182. {
  183. uint32_t InjectedChannel; /*!< Configure the ADC injected channel
  184. This parameter can be a value of @ref ADCEx_channels
  185. Note: Depending on devices, some channels may not be available on package pins. Refer to device datasheet for channels availability. */
  186. uint32_t InjectedRank; /*!< The rank in the regular group sequencer
  187. This parameter must be a value of @ref ADCEx_injected_rank
  188. Note: In case of need to disable a channel or change order of conversion sequencer, rank containing a previous channel setting can be overwritten by the new channel setting (or parameter number of conversions can be adjusted) */
  189. uint32_t InjectedSamplingTime; /*!< Sampling time value to be set for the selected channel.
  190. Unit: ADC clock cycles
  191. Conversion time is the addition of sampling time and processing time (12.5 ADC clock cycles at ADC resolution 12 bits, 10.5 cycles at 10 bits, 8.5 cycles at 8 bits, 6.5 cycles at 6 bits).
  192. This parameter can be a value of @ref ADCEx_sampling_times
  193. Caution: This parameter updates the parameter property of the channel, that can be used into regular and/or injected groups.
  194. If this same channel has been previously configured in the other group (regular/injected), it will be updated to last setting.
  195. Note: In case of usage of internal measurement channels (VrefInt/Vbat/TempSensor),
  196. sampling time constraints must be respected (sampling time can be adjusted in function of ADC clock frequency and sampling time setting)
  197. Refer to device datasheet for timings values, parameters TS_vrefint, TS_vbat, TS_temp (values rough order: 2.2us min). */
  198. uint32_t InjectedSingleDiff; /*!< Selection of single-ended or differential input.
  199. In differential mode: Differential measurement is between the selected channel 'i' (positive input) and channel 'i+1' (negative input).
  200. Only channel 'i' has to be configured, channel 'i+1' is configured automatically.
  201. This parameter must be a value of @ref ADCEx_SingleDifferential
  202. Caution: This parameter updates the parameter property of the channel, that can be used into regular and/or injected groups.
  203. If this same channel has been previously configured in the other group (regular/injected), it will be updated to last setting.
  204. Note: Channels 1 to 14 are available in differential mode. Channels 15U, 16U, 17U, 18 can be used only in single-ended mode.
  205. Note: When configuring a channel 'i' in differential mode, the channel 'i-1' is not usable separately.
  206. Note: This parameter must be modified when ADC is disabled (before ADC start conversion or after ADC stop conversion).
  207. If ADC is enabled, this parameter setting is bypassed without error reporting (as it can be the expected behaviour in case of another parameter update on the fly) */
  208. uint32_t InjectedOffsetNumber; /*!< Selects the offset number
  209. This parameter can be a value of @ref ADCEx_OffsetNumber
  210. Caution: Only one channel is allowed per offset number. If another channel was on this offset number, the offset will be changed to the new channel. */
  211. uint32_t InjectedOffset; /*!< Defines the offset to be subtracted from the raw converted data.
  212. Offset value must be a positive number.
  213. Depending of ADC resolution selected (12U, 10U, 8 or 6 bits),
  214. this parameter must be a number between Min_Data = 0x000 and Max_Data = 0xFFFU, 0x3FFU, 0xFF or 0x3F respectively. */
  215. uint32_t InjectedNbrOfConversion; /*!< Specifies the number of ranks that will be converted within the injected group sequencer.
  216. To use the injected group sequencer and convert several ranks, parameter 'ScanConvMode' must be enabled.
  217. This parameter must be a number between Min_Data = 1 and Max_Data = 4.
  218. Caution: this setting impacts the entire injected group. Therefore, call of HAL_ADCEx_InjectedConfigChannel() to
  219. configure a channel on injected group can impact the configuration of other channels previously set. */
  220. FunctionalState InjectedDiscontinuousConvMode; /*!< Specifies whether the conversions sequence of injected group is performed in Complete-sequence/Discontinuous-sequence (main sequence subdivided in successive parts).
  221. Discontinuous mode is used only if sequencer is enabled (parameter 'ScanConvMode'). If sequencer is disabled, this parameter is discarded.
  222. Discontinuous mode can be enabled only if continuous mode is disabled. If continuous mode is enabled, this parameter setting is discarded.
  223. This parameter can be set to ENABLE or DISABLE.
  224. Note: This parameter must be modified when ADC is disabled (before ADC start conversion or after ADC stop conversion).
  225. Note: For injected group, number of discontinuous ranks increment is fixed to one-by-one.
  226. Caution: this setting impacts the entire injected group. Therefore, call of HAL_ADCEx_InjectedConfigChannel() to
  227. configure a channel on injected group can impact the configuration of other channels previously set. */
  228. FunctionalState AutoInjectedConv; /*!< Enables or disables the selected ADC automatic injected group conversion after regular one
  229. This parameter can be set to ENABLE or DISABLE.
  230. Note: To use Automatic injected conversion, discontinuous mode must be disabled ('DiscontinuousConvMode' and 'InjectedDiscontinuousConvMode' set to DISABLE)
  231. Note: To use Automatic injected conversion, injected group external triggers must be disabled ('ExternalTrigInjecConv' set to ADC_SOFTWARE_START)
  232. Note: In case of DMA used with regular group: if DMA configured in normal mode (single shot) JAUTO will be stopped upon DMA transfer complete.
  233. To maintain JAUTO always enabled, DMA must be configured in circular mode.
  234. Caution: this setting impacts the entire injected group. Therefore, call of HAL_ADCEx_InjectedConfigChannel() to
  235. configure a channel on injected group can impact the configuration of other channels previously set. */
  236. FunctionalState QueueInjectedContext; /*!< Specifies whether the context queue feature is enabled.
  237. This parameter can be set to ENABLE or DISABLE.
  238. If context queue is enabled, injected sequencer&channels configurations are queued on up to 2 contexts. If a
  239. new injected context is set when queue is full, error is triggered by interruption and through function 'HAL_ADCEx_InjectedQueueOverflowCallback'.
  240. Caution: This feature request that the sequence is fully configured before injected conversion start.
  241. Therefore, configure channels with HAL_ADCEx_InjectedConfigChannel() as many times as value of 'InjectedNbrOfConversion' parameter.
  242. Caution: this setting impacts the entire injected group. Therefore, call of HAL_ADCEx_InjectedConfigChannel() to
  243. configure a channel on injected group can impact the configuration of other channels previously set.
  244. Note: This parameter must be modified when ADC is disabled (before ADC start conversion or after ADC stop conversion). */
  245. uint32_t ExternalTrigInjecConv; /*!< Selects the external event used to trigger the conversion start of injected group.
  246. If set to ADC_INJECTED_SOFTWARE_START, external triggers are disabled.
  247. This parameter can be a value of @ref ADCEx_External_trigger_source_Injected
  248. Caution: this setting impacts the entire injected group. Therefore, call of HAL_ADCEx_InjectedConfigChannel() to
  249. configure a channel on injected group can impact the configuration of other channels previously set. */
  250. uint32_t ExternalTrigInjecConvEdge; /*!< Selects the external trigger edge of injected group.
  251. This parameter can be a value of @ref ADCEx_External_trigger_edge_Injected.
  252. If trigger is set to ADC_INJECTED_SOFTWARE_START, this parameter is discarded.
  253. Caution: this setting impacts the entire injected group. Therefore, call of HAL_ADCEx_InjectedConfigChannel() to
  254. configure a channel on injected group can impact the configuration of other channels previously set. */
  255. }ADC_InjectionConfTypeDef;
  256. /**
  257. * @brief ADC Injection Configuration
  258. */
  259. typedef struct
  260. {
  261. uint32_t ContextQueue; /*!< Injected channel configuration context: build-up over each
  262. HAL_ADCEx_InjectedConfigChannel() call to finally initialize
  263. JSQR register at HAL_ADCEx_InjectedConfigChannel() last call */
  264. uint32_t ChannelCount; /*!< Number of channels in the injected sequence */
  265. }ADC_InjectionConfigTypeDef;
  266. /**
  267. * @brief Structure definition of ADC analog watchdog
  268. * @note The setting of these parameters with function HAL_ADC_AnalogWDGConfig() is conditioned to ADC state.
  269. * ADC state can be either: ADC disabled or ADC enabled without conversion on going on regular and injected groups.
  270. */
  271. typedef struct
  272. {
  273. uint32_t WatchdogNumber; /*!< Selects which ADC analog watchdog to apply to the selected channel.
  274. For Analog Watchdog 1: Only 1 channel can be monitored (or overall group of channels by setting parameter 'WatchdogMode')
  275. For Analog Watchdog 2 and 3: Several channels can be monitored (by successive calls of 'HAL_ADC_AnalogWDGConfig()' for each channel)
  276. This parameter can be a value of @ref ADCEx_analog_watchdog_number. */
  277. uint32_t WatchdogMode; /*!< For Analog Watchdog 1: Configures the ADC analog watchdog mode: single channel/overall group of channels, regular/injected group.
  278. For Analog Watchdog 2 and 3: There is no configuration for overall group of channels as AWD1. Set value 'ADC_ANALOGWATCHDOG_NONE' to reset channels group programmed with parameter 'Channel', set any other value to not use this parameter.
  279. This parameter can be a value of @ref ADCEx_analog_watchdog_mode. */
  280. uint32_t Channel; /*!< Selects which ADC channel to monitor by analog watchdog.
  281. For Analog Watchdog 1: this parameter has an effect only if parameter 'WatchdogMode' is configured on single channel. Only 1 channel can be monitored.
  282. For Analog Watchdog 2 and 3: Several channels can be monitored (successive calls of HAL_ADC_AnalogWDGConfig() must be done, one for each channel.
  283. Channels group reset can be done by setting WatchdogMode to 'ADC_ANALOGWATCHDOG_NONE').
  284. This parameter can be a value of @ref ADCEx_channels. */
  285. FunctionalState ITMode; /*!< Specifies whether the analog watchdog is configured in interrupt or polling mode.
  286. This parameter can be set to ENABLE or DISABLE */
  287. uint32_t HighThreshold; /*!< Configures the ADC analog watchdog High threshold value.
  288. Depending of ADC resolution selected (12U, 10U, 8 or 6 bits), this parameter must be a number between Min_Data = 0x000 and Max_Data = 0xFFFU, 0x3FFU, 0xFF or 0x3F respectively.
  289. Note: Analog watchdog 2 and 3 are limited to a resolution of 8 bits: if ADC resolution is 12 bits
  290. the 4 LSB are ignored, if ADC resolution is 10 bits the 2 LSB are ignored. */
  291. uint32_t LowThreshold; /*!< Configures the ADC analog watchdog High threshold value.
  292. Depending of ADC resolution selected (12U, 10U, 8 or 6 bits), this parameter must be a number between Min_Data = 0x000 and Max_Data = 0xFFFU, 0x3FFU, 0xFF or 0x3F respectively.
  293. Note: Analog watchdog 2 and 3 are limited to a resolution of 8 bits: if ADC resolution is 12 bits
  294. the 4 LSB are ignored, if ADC resolution is 10 bits the 2 LSB are ignored. */
  295. }ADC_AnalogWDGConfTypeDef;
  296. /**
  297. * @brief Structure definition of ADC multimode
  298. * @note The setting of these parameters with function HAL_ADCEx_MultiModeConfigChannel() is conditioned to ADCs state (both ADCs of the common group).
  299. * ADC state can be either:
  300. * - For all parameters: ADC disabled (this is the only possible ADC state to modify parameter 'DMAAccessMode')
  301. * - For parameter 'DMAAccessMode': ADC enabled without conversion on going on regular group.
  302. * If ADC is not in the appropriate state to modify some parameters, these parameters setting is bypassed
  303. * without error reporting (as it can be the expected behaviour in case of intended action to update another parameter (which fulfills the ADC state condition) on the fly).
  304. */
  305. typedef struct
  306. {
  307. uint32_t Mode; /*!< Configures the ADC to operate in independent or multi mode.
  308. This parameter can be a value of @ref ADCEx_Common_mode */
  309. uint32_t DMAAccessMode; /*!< Configures the DMA mode for multi ADC mode:
  310. selection whether 2 DMA channels (each ADC use its own DMA channel) or 1 DMA channel (one DMA channel for both ADC, DMA of ADC master)
  311. This parameter can be a value of @ref ADCEx_Direct_memory_access_mode_for_multimode
  312. Caution: Limitations with multimode DMA access enabled (1 DMA channel used): In case of dual mode in high speed (more than 5Msps) or high activity of DMA by other peripherals, there is a risk of DMA overrun.
  313. Therefore, it is recommended to disable multimode DMA access: each ADC uses its own DMA channel.
  314. Refer to device errata sheet for more details. */
  315. uint32_t TwoSamplingDelay; /*!< Configures the Delay between 2 sampling phases.
  316. This parameter can be a value of @ref ADCEx_delay_between_2_sampling_phases
  317. Delay range depends on selected resolution: from 1 to 12 clock cycles for 12 bits, from 1 to 10 clock cycles for 10 bits
  318. from 1 to 8 clock cycles for 8 bits, from 1 to 6 clock cycles for 6 bits */
  319. }ADC_MultiModeTypeDef;
  320. #endif /* STM32F302xE || STM32F303xE || STM32F398xx || */
  321. /* STM32F302xC || STM32F303xC || STM32F358xx || */
  322. /* STM32F303x8 || STM32F334x8 || STM32F328xx || */
  323. /* STM32F301x8 || STM32F302x8 || STM32F318xx */
  324. #if defined(STM32F373xC) || defined(STM32F378xx)
  325. /**
  326. * @brief Structure definition of ADC and regular group initialization
  327. * @note Parameters of this structure are shared within 2 scopes:
  328. * - Scope entire ADC (affects regular and injected groups): DataAlign, ScanConvMode.
  329. * - Scope regular group: ContinuousConvMode, NbrOfConversion, DiscontinuousConvMode, NbrOfDiscConversion, ExternalTrigConvEdge, ExternalTrigConv.
  330. * @note The setting of these parameters with function HAL_ADC_Init() is conditioned to ADC state.
  331. * ADC can be either disabled or enabled without conversion on going on regular group.
  332. */
  333. typedef struct
  334. {
  335. uint32_t DataAlign; /*!< Specifies ADC data alignment to right (MSB on register bit 11 and LSB on register bit 0U) (default setting)
  336. or to left (if regular group: MSB on register bit 15 and LSB on register bit 4U, if injected group (MSB kept as signed value due to potential negative value after offset application): MSB on register bit 14 and LSB on register bit 3U).
  337. This parameter can be a value of @ref ADCEx_Data_align */
  338. uint32_t ScanConvMode; /*!< Configures the sequencer of regular and injected groups.
  339. This parameter can be associated to parameter 'DiscontinuousConvMode' to have main sequence subdivided in successive parts.
  340. If disabled: Conversion is performed in single mode (one channel converted, the one defined in rank 1U).
  341. Parameters 'NbrOfConversion' and 'InjectedNbrOfConversion' are discarded (equivalent to set to 1U).
  342. If enabled: Conversions are performed in sequence mode (multiple ranks defined by 'NbrOfConversion'/'InjectedNbrOfConversion' and each channel rank).
  343. Scan direction is upward: from rank1 to rank 'n'.
  344. This parameter can be a value of @ref ADCEx_Scan_mode
  345. Note: For regular group, this parameter should be enabled in conversion either by polling (HAL_ADC_Start with Discontinuous mode and NbrOfDiscConversion=1U)
  346. or by DMA (HAL_ADC_Start_DMA), but not by interruption (HAL_ADC_Start_IT): in scan mode, interruption is triggered only on the
  347. the last conversion of the sequence. All previous conversions would be overwritten by the last one.
  348. Injected group used with scan mode has not this constraint: each rank has its own result register, no data is overwritten. */
  349. FunctionalState ContinuousConvMode; /*!< Specifies whether the conversion is performed in single mode (one conversion) or continuous mode for regular group,
  350. after the selected trigger occurred (software start or external trigger).
  351. This parameter can be set to ENABLE or DISABLE. */
  352. uint32_t NbrOfConversion; /*!< Specifies the number of ranks that will be converted within the regular group sequencer.
  353. To use regular group sequencer and convert several ranks, parameter 'ScanConvMode' must be enabled.
  354. This parameter must be a number between Min_Data = 1 and Max_Data = 16. */
  355. FunctionalState DiscontinuousConvMode; /*!< Specifies whether the conversions sequence of regular group is performed in Complete-sequence/Discontinuous-sequence (main sequence subdivided in successive parts).
  356. Discontinuous mode is used only if sequencer is enabled (parameter 'ScanConvMode'). If sequencer is disabled, this parameter is discarded.
  357. Discontinuous mode can be enabled only if continuous mode is disabled. If continuous mode is enabled, this parameter setting is discarded.
  358. This parameter can be set to ENABLE or DISABLE. */
  359. uint32_t NbrOfDiscConversion; /*!< Specifies the number of discontinuous conversions in which the main sequence of regular group (parameter NbrOfConversion) will be subdivided.
  360. If parameter 'DiscontinuousConvMode' is disabled, this parameter is discarded.
  361. This parameter must be a number between Min_Data = 1 and Max_Data = 8. */
  362. uint32_t ExternalTrigConv; /*!< Selects the external event used to trigger the conversion start of regular group.
  363. If set to ADC_SOFTWARE_START, external triggers are disabled.
  364. If set to external trigger source, triggering is on event rising edge.
  365. This parameter can be a value of @ref ADCEx_External_trigger_source_Regular */
  366. }ADC_InitTypeDef;
  367. /**
  368. * @brief Structure definition of ADC channel for regular group
  369. * @note The setting of these parameters with function HAL_ADC_ConfigChannel() is conditioned to ADC state.
  370. * ADC can be either disabled or enabled without conversion on going on regular group.
  371. */
  372. typedef struct
  373. {
  374. uint32_t Channel; /*!< Specifies the channel to configure into ADC regular group.
  375. This parameter can be a value of @ref ADCEx_channels
  376. Note: Depending on devices, some channels may not be available on package pins. Refer to device datasheet for channels availability. */
  377. uint32_t Rank; /*!< Specifies the rank in the regular group sequencer
  378. This parameter can be a value of @ref ADCEx_regular_rank
  379. Note: In case of need to disable a channel or change order of conversion sequencer, rank containing a previous channel setting can be overwritten by the new channel setting (or parameter number of conversions can be adjusted) */
  380. uint32_t SamplingTime; /*!< Sampling time value to be set for the selected channel.
  381. Unit: ADC clock cycles
  382. Conversion time is the addition of sampling time and processing time (12.5 ADC clock cycles at ADC resolution 12 bits).
  383. This parameter can be a value of @ref ADCEx_sampling_times
  384. Caution: This parameter updates the parameter property of the channel, that can be used into regular and/or injected groups.
  385. If this same channel has been previously configured in the other group (regular/injected), it will be updated to last setting.
  386. Note: In case of usage of internal measurement channels (VrefInt/Vbat/TempSensor),
  387. sampling time constraints must be respected (sampling time can be adjusted in function of ADC clock frequency and sampling time setting)
  388. Refer to device datasheet for timings values, parameters TS_vrefint, TS_vbat, TS_temp (values rough order: 5us to 17.1us min). */
  389. }ADC_ChannelConfTypeDef;
  390. /**
  391. * @brief ADC Configuration injected Channel structure definition
  392. * @note Parameters of this structure are shared within 2 scopes:
  393. * - Scope channel: InjectedChannel, InjectedRank, InjectedSamplingTime, InjectedOffset
  394. * - Scope injected group (affects all channels of injected group): InjectedNbrOfConversion, InjectedDiscontinuousConvMode,
  395. * AutoInjectedConv, ExternalTrigInjecConvEdge, ExternalTrigInjecConv.
  396. * @note The setting of these parameters with function HAL_ADCEx_InjectedConfigChannel() is conditioned to ADC state.
  397. * ADC state can be either:
  398. * - For all parameters: ADC disabled (this is the only possible ADC state to modify parameter 'ExternalTrigInjecConv')
  399. * - For all except parameters 'ExternalTrigInjecConv': ADC enabled without conversion on going on injected group.
  400. */
  401. typedef struct
  402. {
  403. uint32_t InjectedChannel; /*!< Selection of ADC channel to configure
  404. This parameter can be a value of @ref ADCEx_channels
  405. Note: Depending on devices, some channels may not be available on package pins. Refer to device datasheet for channels availability. */
  406. uint32_t InjectedRank; /*!< Rank in the injected group sequencer
  407. This parameter must be a value of @ref ADCEx_injected_rank
  408. Note: In case of need to disable a channel or change order of conversion sequencer, rank containing a previous channel setting can be overwritten by the new channel setting (or parameter number of conversions can be adjusted) */
  409. uint32_t InjectedSamplingTime; /*!< Sampling time value to be set for the selected channel.
  410. Unit: ADC clock cycles
  411. Conversion time is the addition of sampling time and processing time (12.5 ADC clock cycles at ADC resolution 12 bits).
  412. This parameter can be a value of @ref ADCEx_sampling_times
  413. Caution: This parameter updates the parameter property of the channel, that can be used into regular and/or injected groups.
  414. If this same channel has been previously configured in the other group (regular/injected), it will be updated to last setting.
  415. Note: In case of usage of internal measurement channels (VrefInt/Vbat/TempSensor),
  416. sampling time constraints must be respected (sampling time can be adjusted in function of ADC clock frequency and sampling time setting)
  417. Refer to device datasheet for timings values, parameters TS_vrefint, TS_vbat, TS_temp (values rough order: 5us to 17.1us min). */
  418. uint32_t InjectedOffset; /*!< Defines the offset to be subtracted from the raw converted data (for channels set on injected group only).
  419. Offset value must be a positive number.
  420. Depending of ADC resolution selected (12U, 10U, 8 or 6 bits),
  421. this parameter must be a number between Min_Data = 0x000 and Max_Data = 0xFFFU, 0x3FFU, 0xFF or 0x3F respectively. */
  422. uint32_t InjectedNbrOfConversion; /*!< Specifies the number of ranks that will be converted within the injected group sequencer.
  423. To use the injected group sequencer and convert several ranks, parameter 'ScanConvMode' must be enabled.
  424. This parameter must be a number between Min_Data = 1 and Max_Data = 4.
  425. Caution: this setting impacts the entire injected group. Therefore, call of HAL_ADCEx_InjectedConfigChannel() to
  426. configure a channel on injected group can impact the configuration of other channels previously set. */
  427. FunctionalState InjectedDiscontinuousConvMode; /*!< Specifies whether the conversions sequence of injected group is performed in Complete-sequence/Discontinuous-sequence (main sequence subdivided in successive parts).
  428. Discontinuous mode is used only if sequencer is enabled (parameter 'ScanConvMode'). If sequencer is disabled, this parameter is discarded.
  429. Discontinuous mode can be enabled only if continuous mode is disabled. If continuous mode is enabled, this parameter setting is discarded.
  430. This parameter can be set to ENABLE or DISABLE.
  431. Note: For injected group, number of discontinuous ranks increment is fixed to one-by-one.
  432. Caution: this setting impacts the entire injected group. Therefore, call of HAL_ADCEx_InjectedConfigChannel() to
  433. configure a channel on injected group can impact the configuration of other channels previously set. */
  434. FunctionalState AutoInjectedConv; /*!< Enables or disables the selected ADC automatic injected group conversion after regular one
  435. This parameter can be set to ENABLE or DISABLE.
  436. Note: To use Automatic injected conversion, discontinuous mode must be disabled ('DiscontinuousConvMode' and 'InjectedDiscontinuousConvMode' set to DISABLE)
  437. Note: To use Automatic injected conversion, injected group external triggers must be disabled ('ExternalTrigInjecConv' set to ADC_SOFTWARE_START)
  438. Note: In case of DMA used with regular group: if DMA configured in normal mode (single shot) JAUTO will be stopped upon DMA transfer complete.
  439. To maintain JAUTO always enabled, DMA must be configured in circular mode.
  440. Caution: this setting impacts the entire injected group. Therefore, call of HAL_ADCEx_InjectedConfigChannel() to
  441. configure a channel on injected group can impact the configuration of other channels previously set. */
  442. uint32_t ExternalTrigInjecConv; /*!< Selects the external event used to trigger the conversion start of injected group.
  443. If set to ADC_INJECTED_SOFTWARE_START, external triggers are disabled.
  444. If set to external trigger source, triggering is on event rising edge.
  445. This parameter can be a value of @ref ADCEx_External_trigger_source_Injected
  446. Note: This parameter must be modified when ADC is disabled (before ADC start conversion or after ADC stop conversion).
  447. If ADC is enabled, this parameter setting is bypassed without error reporting (as it can be the expected behaviour in case of another parameter update on the fly)
  448. Caution: this setting impacts the entire injected group. Therefore, call of HAL_ADCEx_InjectedConfigChannel() to
  449. configure a channel on injected group can impact the configuration of other channels previously set. */
  450. }ADC_InjectionConfTypeDef;
  451. /**
  452. * @brief ADC Configuration analog watchdog definition
  453. * @note The setting of these parameters with function is conditioned to ADC state.
  454. * ADC state can be either disabled or enabled without conversion on going on regular and injected groups.
  455. */
  456. typedef struct
  457. {
  458. uint32_t WatchdogMode; /*!< Configures the ADC analog watchdog mode: single/all channels, regular/injected group.
  459. This parameter can be a value of @ref ADCEx_analog_watchdog_mode. */
  460. uint32_t Channel; /*!< Selects which ADC channel to monitor by analog watchdog.
  461. This parameter has an effect only if watchdog mode is configured on single channel (parameter WatchdogMode)
  462. This parameter can be a value of @ref ADCEx_channels. */
  463. FunctionalState ITMode; /*!< Specifies whether the analog watchdog is configured in interrupt or polling mode.
  464. This parameter can be set to ENABLE or DISABLE */
  465. uint32_t HighThreshold; /*!< Configures the ADC analog watchdog High threshold value.
  466. This parameter must be a number between Min_Data = 0x000 and Max_Data = 0xFFF. */
  467. uint32_t LowThreshold; /*!< Configures the ADC analog watchdog High threshold value.
  468. This parameter must be a number between Min_Data = 0x000 and Max_Data = 0xFFF. */
  469. uint32_t WatchdogNumber; /*!< Reserved for future use, can be set to 0U */
  470. }ADC_AnalogWDGConfTypeDef;
  471. #endif /* STM32F373xC || STM32F378xx */
  472. /**
  473. * @}
  474. */
  475. /* Exported constants --------------------------------------------------------*/
  476. /** @defgroup ADCEx_Exported_Constants ADCEx Exported Constants
  477. * @{
  478. */
  479. /** @defgroup ADCEx_Error_Code ADC Extended Error Code
  480. * @{
  481. */
  482. #define HAL_ADC_ERROR_NONE (0x00U) /*!< No error */
  483. #define HAL_ADC_ERROR_INTERNAL (0x01U) /*!< ADC IP internal error: if problem of clocking,
  484. enable/disable, erroneous state */
  485. #define HAL_ADC_ERROR_OVR (0x02U) /*!< Overrun error */
  486. #define HAL_ADC_ERROR_DMA (0x04U) /*!< DMA transfer error */
  487. #define HAL_ADC_ERROR_JQOVF (0x08U) /*!< Injected context queue overflow error */
  488. #if (USE_HAL_ADC_REGISTER_CALLBACKS == 1)
  489. #define HAL_ADC_ERROR_INVALID_CALLBACK (0x10U) /*!< Invalid Callback error */
  490. #endif /* USE_HAL_ADC_REGISTER_CALLBACKS */
  491. /**
  492. * @}
  493. */
  494. #if defined(STM32F302xE) || defined(STM32F303xE) || defined(STM32F398xx) || \
  495. defined(STM32F302xC) || defined(STM32F303xC) || defined(STM32F358xx) || \
  496. defined(STM32F303x8) || defined(STM32F334x8) || defined(STM32F328xx) || \
  497. defined(STM32F301x8) || defined(STM32F302x8) || defined(STM32F318xx)
  498. /** @defgroup ADCEx_ClockPrescaler ADC Extended Clock Prescaler
  499. * @{
  500. */
  501. #define ADC_CLOCK_ASYNC_DIV1 (0x00000000U) /*!< ADC asynchronous clock derived from ADC dedicated PLL */
  502. #if defined(STM32F302xE) || defined(STM32F303xE) || defined(STM32F398xx) || \
  503. defined(STM32F302xC) || defined(STM32F303xC) || defined(STM32F358xx) || \
  504. defined(STM32F303x8) || defined(STM32F334x8) || defined(STM32F328xx)
  505. #define ADC_CLOCK_SYNC_PCLK_DIV1 ((uint32_t)ADC12_CCR_CKMODE_0) /*!< ADC synchronous clock derived from AHB clock without prescaler */
  506. #define ADC_CLOCK_SYNC_PCLK_DIV2 ((uint32_t)ADC12_CCR_CKMODE_1) /*!< ADC synchronous clock derived from AHB clock divided by a prescaler of 2U */
  507. #define ADC_CLOCK_SYNC_PCLK_DIV4 ((uint32_t)ADC12_CCR_CKMODE) /*!< ADC synchronous clock derived from AHB clock divided by a prescaler of 4U */
  508. #endif /* STM32F302xE || STM32F303xE || STM32F398xx || */
  509. /* STM32F302xC || STM32F303xC || STM32F358xx || */
  510. /* STM32F303x8 || STM32F334x8 || STM32F328xx */
  511. #if defined(STM32F301x8) || defined(STM32F302x8) || defined(STM32F318xx)
  512. #define ADC_CLOCK_SYNC_PCLK_DIV1 ((uint32_t)ADC1_CCR_CKMODE_0) /*!< ADC synchronous clock derived from AHB clock without prescaler */
  513. #define ADC_CLOCK_SYNC_PCLK_DIV2 ((uint32_t)ADC1_CCR_CKMODE_1) /*!< ADC synchronous clock derived from AHB clock divided by a prescaler of 2U */
  514. #define ADC_CLOCK_SYNC_PCLK_DIV4 ((uint32_t)ADC1_CCR_CKMODE) /*!< ADC synchronous clock derived from AHB clock divided by a prescaler of 4U */
  515. #endif /* STM32F301x8 || STM32F318xx || STM32F302x8 */
  516. #define IS_ADC_CLOCKPRESCALER(ADC_CLOCK) (((ADC_CLOCK) == ADC_CLOCK_ASYNC_DIV1) || \
  517. ((ADC_CLOCK) == ADC_CLOCK_SYNC_PCLK_DIV1) || \
  518. ((ADC_CLOCK) == ADC_CLOCK_SYNC_PCLK_DIV2) || \
  519. ((ADC_CLOCK) == ADC_CLOCK_SYNC_PCLK_DIV4) )
  520. /**
  521. * @}
  522. */
  523. /** @defgroup ADCEx_Resolution ADC Extended Resolution
  524. * @{
  525. */
  526. #define ADC_RESOLUTION_12B (0x00000000U) /*!< ADC 12-bit resolution */
  527. #define ADC_RESOLUTION_10B ((uint32_t)ADC_CFGR_RES_0) /*!< ADC 10-bit resolution */
  528. #define ADC_RESOLUTION_8B ((uint32_t)ADC_CFGR_RES_1) /*!< ADC 8-bit resolution */
  529. #define ADC_RESOLUTION_6B ((uint32_t)ADC_CFGR_RES) /*!< ADC 6-bit resolution */
  530. /**
  531. * @}
  532. */
  533. /** @defgroup ADCEx_Data_align ADC Extended Data Alignment
  534. * @{
  535. */
  536. #define ADC_DATAALIGN_RIGHT (0x00000000U)
  537. #define ADC_DATAALIGN_LEFT ((uint32_t)ADC_CFGR_ALIGN)
  538. /**
  539. * @}
  540. */
  541. /** @defgroup ADCEx_Scan_mode ADC Extended Scan Mode
  542. * @{
  543. */
  544. #define ADC_SCAN_DISABLE (0x00000000U)
  545. #define ADC_SCAN_ENABLE (0x00000001U)
  546. /**
  547. * @}
  548. */
  549. /** @defgroup ADCEx_External_trigger_edge_Regular ADC Extended External trigger enable and polarity selection for regular group
  550. * @{
  551. */
  552. #define ADC_EXTERNALTRIGCONVEDGE_NONE (0x00000000U)
  553. #define ADC_EXTERNALTRIGCONVEDGE_RISING ((uint32_t)ADC_CFGR_EXTEN_0)
  554. #define ADC_EXTERNALTRIGCONVEDGE_FALLING ((uint32_t)ADC_CFGR_EXTEN_1)
  555. #define ADC_EXTERNALTRIGCONVEDGE_RISINGFALLING ((uint32_t)ADC_CFGR_EXTEN)
  556. /**
  557. * @}
  558. */
  559. /** @defgroup ADCEx_External_trigger_source_Regular ADC Extended External trigger selection for regular group
  560. * @{
  561. */
  562. #if defined(STM32F303xE) || defined(STM32F398xx) || \
  563. defined(STM32F303xC) || defined(STM32F358xx)
  564. /*!< List of external triggers with generic trigger name, independently of */
  565. /* ADC target (caution: applies to other ADCs sharing the same common group), */
  566. /* sorted by trigger name: */
  567. /*!< External triggers of regular group for ADC1&ADC2 only */
  568. #define ADC_EXTERNALTRIGCONV_T1_CC1 ADC1_2_EXTERNALTRIG_T1_CC1
  569. #define ADC_EXTERNALTRIGCONV_T1_CC2 ADC1_2_EXTERNALTRIG_T1_CC2
  570. #define ADC_EXTERNALTRIGCONV_T2_CC2 ADC1_2_EXTERNALTRIG_T2_CC2
  571. #define ADC_EXTERNALTRIGCONV_T3_CC4 ADC1_2_EXTERNALTRIG_T3_CC4
  572. #define ADC_EXTERNALTRIGCONV_T4_CC4 ADC1_2_EXTERNALTRIG_T4_CC4
  573. #define ADC_EXTERNALTRIGCONV_T6_TRGO ADC1_2_EXTERNALTRIG_T6_TRGO
  574. #define ADC_EXTERNALTRIGCONV_EXT_IT11 ADC1_2_EXTERNALTRIG_EXT_IT11
  575. /*!< External triggers of regular group for ADC3&ADC4 only */
  576. #define ADC_EXTERNALTRIGCONV_T2_CC1 ADC3_4_EXTERNALTRIG_T2_CC1
  577. #define ADC_EXTERNALTRIGCONV_T2_CC3 ADC3_4_EXTERNALTRIG_T2_CC3
  578. #define ADC_EXTERNALTRIGCONV_T3_CC1 ADC3_4_EXTERNALTRIG_T3_CC1
  579. #define ADC_EXTERNALTRIGCONV_T4_CC1 ADC3_4_EXTERNALTRIG_T4_CC1
  580. #define ADC_EXTERNALTRIGCONV_T7_TRGO ADC3_4_EXTERNALTRIG_T7_TRGO
  581. #define ADC_EXTERNALTRIGCONV_T8_CC1 ADC3_4_EXTERNALTRIG_T8_CC1
  582. #define ADC_EXTERNALTRIGCONV_EXT_IT2 ADC3_4_EXTERNALTRIG_EXT_IT2
  583. /*!< External triggers of regular group for ADC1&ADC2, ADC3&ADC4 */
  584. /* Note: Triggers affected to group ADC1_2 by default, redirected to group */
  585. /* ADC3_4 by driver when needed. */
  586. #define ADC_EXTERNALTRIGCONV_T1_CC3 ADC1_2_EXTERNALTRIG_T1_CC3
  587. #define ADC_EXTERNALTRIGCONV_T1_TRGO ADC1_2_EXTERNALTRIG_T1_TRGO
  588. #define ADC_EXTERNALTRIGCONV_T1_TRGO2 ADC1_2_EXTERNALTRIG_T1_TRGO2
  589. #define ADC_EXTERNALTRIGCONV_T2_TRGO ADC1_2_EXTERNALTRIG_T2_TRGO
  590. #define ADC_EXTERNALTRIGCONV_T3_TRGO ADC1_2_EXTERNALTRIG_T3_TRGO
  591. #define ADC_EXTERNALTRIGCONV_T4_TRGO ADC1_2_EXTERNALTRIG_T4_TRGO
  592. #define ADC_EXTERNALTRIGCONV_T8_TRGO ADC1_2_EXTERNALTRIG_T8_TRGO
  593. #define ADC_EXTERNALTRIGCONV_T8_TRGO2 ADC1_2_EXTERNALTRIG_T8_TRGO2
  594. #define ADC_EXTERNALTRIGCONV_T15_TRGO ADC1_2_EXTERNALTRIG_T15_TRGO
  595. #define ADC_SOFTWARE_START (0x00000001U)
  596. #if defined(STM32F303xE) || defined(STM32F398xx)
  597. /* ADC external triggers specific to device STM303xE: mask to differentiate */
  598. /* standard triggers from specific timer 20U, needed for reallocation of */
  599. /* triggers common to ADC1&2U/ADC3&4 and to avoid mixing with standard */
  600. /* triggers without remap. */
  601. #define ADC_EXTERNALTRIGCONV_T20_MASK 0x1000
  602. /*!< List of external triggers specific to device STM303xE: using Timer20 */
  603. /* with ADC trigger input remap. */
  604. /* To remap ADC trigger from other timers/ExtLine to timer20: use macro */
  605. /* " __HAL_REMAPADCTRIGGER_ENABLE(...) " with parameters described below: */
  606. /*!< External triggers of regular group for ADC1&ADC2 only, specific to */
  607. /* device STM303xE: : using Timer20 with ADC trigger input remap */
  608. #define ADC_EXTERNALTRIGCONV_T20_CC2 ADC_EXTERNALTRIGCONV_T6_TRGO /*!< Remap trigger using macro __HAL_REMAPADCTRIGGER_ENABLE(HAL_REMAPADCTRIGGER_ADC12_EXT13U) */
  609. #define ADC_EXTERNALTRIGCONV_T20_CC3 ADC_EXTERNALTRIGCONV_T3_CC4 /*!< Remap trigger using macro __HAL_REMAPADCTRIGGER_ENABLE(HAL_REMAPADCTRIGGER_ADC12_EXT15U) */
  610. /*!< External triggers of regular group for ADC3&ADC4 only, specific to */
  611. /* device STM303xE: : using Timer20 with ADC trigger input remap */
  612. /* None */
  613. /*!< External triggers of regular group for ADC1&ADC2, ADC3&ADC4, specific to */
  614. /* device STM303xE: : using Timer20 with ADC trigger input remap */
  615. /* Note: Triggers affected to group ADC1_2 by default, redirected to group */
  616. /* ADC3_4 by driver when needed. */
  617. #define ADC_EXTERNALTRIGCONV_T20_CC1 (ADC_EXTERNALTRIGCONV_T4_CC4 | ADC_EXTERNALTRIGCONV_T20_MASK) /*!< For ADC1&ADC2: Remap trigger using macro __HAL_REMAPADCTRIGGER_ENABLE(HAL_REMAPADCTRIGGER_ADC12_EXT5) */
  618. /*!< For ADC3&ADC4: Remap trigger using macro __HAL_REMAPADCTRIGGER_ENABLE(HAL_REMAPADCTRIGGER_ADC34_EXT15U) */
  619. #define ADC_EXTERNALTRIGCONV_T20_TRGO (ADC_EXTERNALTRIGCONV_T1_CC3 | ADC_EXTERNALTRIGCONV_T20_MASK) /*!< For ADC1&ADC2: Remap trigger using macro __HAL_REMAPADCTRIGGER_ENABLE(HAL_REMAPADCTRIGGER_ADC12_EXT2) */
  620. /*!< For ADC3&ADC4: Remap trigger using macro __HAL_REMAPADCTRIGGER_ENABLE(HAL_REMAPADCTRIGGER_ADC34_EXT5) */
  621. #define ADC_EXTERNALTRIGCONV_T20_TRGO2 (ADC_EXTERNALTRIGCONV_T2_CC2 | ADC_EXTERNALTRIGCONV_T20_MASK) /*!< For ADC1&ADC2: Remap trigger using macro __HAL_REMAPADCTRIGGER_ENABLE(HAL_REMAPADCTRIGGER_ADC12_EXT3) */
  622. /*!< For ADC3&ADC4: Remap trigger using macro __HAL_REMAPADCTRIGGER_ENABLE(HAL_REMAPADCTRIGGER_ADC34_EXT6) */
  623. #endif /* STM32F303xE || STM32F398xx */
  624. #endif /* STM32F303xE || STM32F398xx || */
  625. /* STM32F303xC || STM32F358xx */
  626. #if defined(STM32F302xE) || \
  627. defined(STM32F302xC)
  628. /*!< List of external triggers with generic trigger name, independently of */
  629. /* ADC target (caution: applies to other ADCs sharing the same common group), */
  630. /* sorted by trigger name: */
  631. /*!< External triggers of regular group for ADC1&ADC2 */
  632. #define ADC_EXTERNALTRIGCONV_T1_CC1 ADC1_2_EXTERNALTRIG_T1_CC1
  633. #define ADC_EXTERNALTRIGCONV_T1_CC2 ADC1_2_EXTERNALTRIG_T1_CC2
  634. #define ADC_EXTERNALTRIGCONV_T1_CC3 ADC1_2_EXTERNALTRIG_T1_CC3
  635. #define ADC_EXTERNALTRIGCONV_T1_TRGO ADC1_2_EXTERNALTRIG_T1_TRGO
  636. #define ADC_EXTERNALTRIGCONV_T1_TRGO2 ADC1_2_EXTERNALTRIG_T1_TRGO2
  637. #define ADC_EXTERNALTRIGCONV_T2_CC2 ADC1_2_EXTERNALTRIG_T2_CC2
  638. #define ADC_EXTERNALTRIGCONV_T2_TRGO ADC1_2_EXTERNALTRIG_T2_TRGO
  639. #define ADC_EXTERNALTRIGCONV_T3_CC4 ADC1_2_EXTERNALTRIG_T3_CC4
  640. #define ADC_EXTERNALTRIGCONV_T3_TRGO ADC1_2_EXTERNALTRIG_T3_TRGO
  641. #define ADC_EXTERNALTRIGCONV_T4_CC4 ADC1_2_EXTERNALTRIG_T4_CC4
  642. #define ADC_EXTERNALTRIGCONV_T4_TRGO ADC1_2_EXTERNALTRIG_T4_TRGO
  643. #define ADC_EXTERNALTRIGCONV_T6_TRGO ADC1_2_EXTERNALTRIG_T6_TRGO
  644. #define ADC_EXTERNALTRIGCONV_T15_TRGO ADC1_2_EXTERNALTRIG_T15_TRGO
  645. #define ADC_EXTERNALTRIGCONV_EXT_IT11 ADC1_2_EXTERNALTRIG_EXT_IT11
  646. #define ADC_SOFTWARE_START (0x00000001U)
  647. #if defined(STM32F302xE)
  648. /* ADC external triggers specific to device STM302xE: mask to differentiate */
  649. /* standard triggers from specific timer 20U, needed for reallocation of */
  650. /* triggers common to ADC1&2 and to avoid mixing with standard */
  651. /* triggers without remap. */
  652. #define ADC_EXTERNALTRIGCONV_T20_MASK 0x1000
  653. /*!< List of external triggers specific to device STM302xE: using Timer20 */
  654. /* with ADC trigger input remap. */
  655. /* To remap ADC trigger from other timers/ExtLine to timer20: use macro */
  656. /* " __HAL_REMAPADCTRIGGER_ENABLE(...) " with parameters described below: */
  657. /*!< External triggers of regular group for ADC1&ADC2 only, specific to */
  658. /* device STM302xE: : using Timer20 with ADC trigger input remap */
  659. #define ADC_EXTERNALTRIGCONV_T20_CC2 ADC_EXTERNALTRIGCONV_T6_TRGO /*!< Remap trigger using macro __HAL_REMAPADCTRIGGER_ENABLE(HAL_REMAPADCTRIGGER_ADC12_EXT13U) */
  660. #define ADC_EXTERNALTRIGCONV_T20_CC3 ADC_EXTERNALTRIGCONV_T3_CC4 /*!< Remap trigger using macro __HAL_REMAPADCTRIGGER_ENABLE(HAL_REMAPADCTRIGGER_ADC12_EXT15U) */
  661. #endif /* STM32F302xE */
  662. #endif /* STM32F302xE || */
  663. /* STM32F302xC */
  664. #if defined(STM32F303x8) || defined(STM32F328xx)
  665. /*!< List of external triggers with generic trigger name, independently of */
  666. /* ADC target (caution: applies to other ADCs sharing the same common group), */
  667. /* sorted by trigger name: */
  668. /*!< External triggers of regular group for ADC1&ADC2 */
  669. #define ADC_EXTERNALTRIGCONV_T1_CC1 ADC1_2_EXTERNALTRIG_T1_CC1
  670. #define ADC_EXTERNALTRIGCONV_T1_CC2 ADC1_2_EXTERNALTRIG_T1_CC2
  671. #define ADC_EXTERNALTRIGCONV_T1_CC3 ADC1_2_EXTERNALTRIG_T1_CC3
  672. #define ADC_EXTERNALTRIGCONV_T1_TRGO ADC1_2_EXTERNALTRIG_T1_TRGO
  673. #define ADC_EXTERNALTRIGCONV_T1_TRGO2 ADC1_2_EXTERNALTRIG_T1_TRGO2
  674. #define ADC_EXTERNALTRIGCONV_T2_CC2 ADC1_2_EXTERNALTRIG_T2_CC2
  675. #define ADC_EXTERNALTRIGCONV_T2_TRGO ADC1_2_EXTERNALTRIG_T2_TRGO
  676. #define ADC_EXTERNALTRIGCONV_T3_CC4 ADC1_2_EXTERNALTRIG_T3_CC4
  677. #define ADC_EXTERNALTRIGCONV_T3_TRGO ADC1_2_EXTERNALTRIG_T3_TRGO
  678. #define ADC_EXTERNALTRIGCONV_T4_CC4 ADC1_2_EXTERNALTRIG_T4_CC4
  679. #define ADC_EXTERNALTRIGCONV_T4_TRGO ADC1_2_EXTERNALTRIG_T4_TRGO
  680. #define ADC_EXTERNALTRIGCONV_T8_TRGO ADC1_2_EXTERNALTRIG_T8_TRGO
  681. #define ADC_EXTERNALTRIGCONV_T8_TRGO2 ADC1_2_EXTERNALTRIG_T8_TRGO2
  682. #define ADC_EXTERNALTRIGCONV_T6_TRGO ADC1_2_EXTERNALTRIG_T6_TRGO
  683. #define ADC_EXTERNALTRIGCONV_T15_TRGO ADC1_2_EXTERNALTRIG_T15_TRGO
  684. #define ADC_EXTERNALTRIGCONV_EXT_IT11 ADC1_2_EXTERNALTRIG_EXT_IT11
  685. #define ADC_SOFTWARE_START (0x00000001U)
  686. #endif /* STM32F303x8 || STM32F328xx */
  687. #if defined(STM32F334x8)
  688. /*!< List of external triggers with generic trigger name, independently of */
  689. /* ADC target (caution: applies to other ADCs sharing the same common group), */
  690. /* sorted by trigger name: */
  691. /*!< External triggers of regular group for ADC1&ADC2 */
  692. #define ADC_EXTERNALTRIGCONV_T1_CC1 ADC1_2_EXTERNALTRIG_T1_CC1
  693. #define ADC_EXTERNALTRIGCONV_T1_CC2 ADC1_2_EXTERNALTRIG_T1_CC2
  694. #define ADC_EXTERNALTRIGCONV_T1_CC3 ADC1_2_EXTERNALTRIG_T1_CC3
  695. #define ADC_EXTERNALTRIGCONV_T1_TRGO ADC1_2_EXTERNALTRIG_T1_TRGO
  696. #define ADC_EXTERNALTRIGCONV_T1_TRGO2 ADC1_2_EXTERNALTRIG_T1_TRGO2
  697. #define ADC_EXTERNALTRIGCONV_T2_CC2 ADC1_2_EXTERNALTRIG_T2_CC2
  698. #define ADC_EXTERNALTRIGCONV_T2_TRGO ADC1_2_EXTERNALTRIG_T2_TRGO
  699. #define ADC_EXTERNALTRIGCONV_T3_CC4 ADC1_2_EXTERNALTRIG_T3_CC4
  700. #define ADC_EXTERNALTRIGCONV_T3_TRGO ADC1_2_EXTERNALTRIG_T3_TRGO
  701. #define ADC_EXTERNALTRIGCONV_T6_TRGO ADC1_2_EXTERNALTRIG_T6_TRGO
  702. #define ADC_EXTERNALTRIGCONV_T15_TRGO ADC1_2_EXTERNALTRIG_T15_TRGO
  703. #define ADC_EXTERNALTRIGCONVHRTIM_TRG1 ADC1_2_EXTERNALTRIG_HRTIM_TRG1
  704. #define ADC_EXTERNALTRIGCONVHRTIM_TRG3 ADC1_2_EXTERNALTRIG_HRTIM_TRG3
  705. #define ADC_EXTERNALTRIGCONV_EXT_IT11 ADC1_2_EXTERNALTRIG_EXT_IT11
  706. #define ADC_SOFTWARE_START (0x00000001U)
  707. #endif /* STM32F334x8 */
  708. #if defined(STM32F301x8) || defined(STM32F302x8) || defined(STM32F318xx)
  709. /* List of external triggers with generic trigger name, sorted by trigger */
  710. /* name: */
  711. /* External triggers of regular group for ADC1 */
  712. #define ADC_EXTERNALTRIGCONV_T1_CC1 ADC1_EXTERNALTRIG_T1_CC1
  713. #define ADC_EXTERNALTRIGCONV_T1_CC2 ADC1_EXTERNALTRIG_T1_CC2
  714. #define ADC_EXTERNALTRIGCONV_T1_CC3 ADC1_EXTERNALTRIG_T1_CC3
  715. #define ADC_EXTERNALTRIGCONV_T2_CC2 ADC1_EXTERNALTRIG_T2_CC2
  716. #define ADC_EXTERNALTRIGCONV_EXT_IT11 ADC1_EXTERNALTRIG_EXT_IT11
  717. #define ADC_EXTERNALTRIGCONV_T1_TRGO ADC1_EXTERNALTRIG_T1_TRGO
  718. #define ADC_EXTERNALTRIGCONV_T1_TRGO2 ADC1_EXTERNALTRIG_T1_TRGO2
  719. #define ADC_EXTERNALTRIGCONV_T2_TRGO ADC1_EXTERNALTRIG_T2_TRGO
  720. #define ADC_EXTERNALTRIGCONV_T6_TRGO ADC1_EXTERNALTRIG_T6_TRGO
  721. #define ADC_EXTERNALTRIGCONV_T15_TRGO ADC1_EXTERNALTRIG_T15_TRGO
  722. #define ADC_SOFTWARE_START (0x00000001U)
  723. #endif /* STM32F301x8 || STM32F302x8 || STM32F318xx */
  724. /**
  725. * @}
  726. */
  727. /** @defgroup ADCEx_EOCSelection ADC Extended End of Regular Sequence/Conversion
  728. * @{
  729. */
  730. #define ADC_EOC_SINGLE_CONV ((uint32_t) ADC_ISR_EOC)
  731. #define ADC_EOC_SEQ_CONV ((uint32_t) ADC_ISR_EOS)
  732. /**
  733. * @}
  734. */
  735. /** @defgroup ADCEx_Overrun ADC Extended overrun
  736. * @{
  737. */
  738. #define ADC_OVR_DATA_OVERWRITTEN (0x00000000U) /*!< Default setting, to be used for compatibility with other STM32 devices */
  739. #define ADC_OVR_DATA_PRESERVED (0x00000001U)
  740. /**
  741. * @}
  742. */
  743. /** @defgroup ADCEx_channels ADC Extended Channels
  744. * @{
  745. */
  746. /* Note: Depending on devices, some channels may not be available on package */
  747. /* pins. Refer to device datasheet for channels availability. */
  748. #define ADC_CHANNEL_1 ((uint32_t)(ADC_SQR3_SQ10_0))
  749. #define ADC_CHANNEL_2 ((uint32_t)(ADC_SQR3_SQ10_1))
  750. #define ADC_CHANNEL_3 ((uint32_t)(ADC_SQR3_SQ10_1 | ADC_SQR3_SQ10_0))
  751. #define ADC_CHANNEL_4 ((uint32_t)(ADC_SQR3_SQ10_2))
  752. #define ADC_CHANNEL_5 ((uint32_t)(ADC_SQR3_SQ10_2 | ADC_SQR3_SQ10_0))
  753. #define ADC_CHANNEL_6 ((uint32_t)(ADC_SQR3_SQ10_2 | ADC_SQR3_SQ10_1))
  754. #define ADC_CHANNEL_7 ((uint32_t)(ADC_SQR3_SQ10_2 | ADC_SQR3_SQ10_1 | ADC_SQR3_SQ10_0))
  755. #define ADC_CHANNEL_8 ((uint32_t)(ADC_SQR3_SQ10_3))
  756. #define ADC_CHANNEL_9 ((uint32_t)(ADC_SQR3_SQ10_3 | ADC_SQR3_SQ10_0))
  757. #define ADC_CHANNEL_10 ((uint32_t)(ADC_SQR3_SQ10_3 | ADC_SQR3_SQ10_1))
  758. #define ADC_CHANNEL_11 ((uint32_t)(ADC_SQR3_SQ10_3 | ADC_SQR3_SQ10_1 | ADC_SQR3_SQ10_0))
  759. #define ADC_CHANNEL_12 ((uint32_t)(ADC_SQR3_SQ10_3 | ADC_SQR3_SQ10_2))
  760. #define ADC_CHANNEL_13 ((uint32_t)(ADC_SQR3_SQ10_3 | ADC_SQR3_SQ10_2 | ADC_SQR3_SQ10_0))
  761. #define ADC_CHANNEL_14 ((uint32_t)(ADC_SQR3_SQ10_3 | ADC_SQR3_SQ10_2 | ADC_SQR3_SQ10_1))
  762. #define ADC_CHANNEL_15 ((uint32_t)(ADC_SQR3_SQ10_3 | ADC_SQR3_SQ10_2 | ADC_SQR3_SQ10_1 | ADC_SQR3_SQ10_0))
  763. #define ADC_CHANNEL_16 ((uint32_t)(ADC_SQR3_SQ10_4))
  764. #define ADC_CHANNEL_17 ((uint32_t)(ADC_SQR3_SQ10_4 | ADC_SQR3_SQ10_0))
  765. #define ADC_CHANNEL_18 ((uint32_t)(ADC_SQR3_SQ10_4 | ADC_SQR3_SQ10_1))
  766. /* Note: Vopamp1, TempSensor and Vbat internal channels available on ADC1 only */
  767. #define ADC_CHANNEL_VOPAMP1 ADC_CHANNEL_15
  768. #define ADC_CHANNEL_TEMPSENSOR ADC_CHANNEL_16
  769. #define ADC_CHANNEL_VBAT ADC_CHANNEL_17
  770. /* Note: Vopamp2/3U/4 internal channels available on ADC2/3U/4 respectively */
  771. #define ADC_CHANNEL_VOPAMP2 ADC_CHANNEL_17
  772. #define ADC_CHANNEL_VOPAMP3 ADC_CHANNEL_17
  773. #define ADC_CHANNEL_VOPAMP4 ADC_CHANNEL_17
  774. /* Note: VrefInt internal channels available on all ADCs, but only */
  775. /* one ADC is allowed to be connected to VrefInt at the same time. */
  776. #define ADC_CHANNEL_VREFINT ((uint32_t)ADC_CHANNEL_18)
  777. /**
  778. * @}
  779. */
  780. /** @defgroup ADCEx_sampling_times ADC Extended Sampling Times
  781. * @{
  782. */
  783. #define ADC_SAMPLETIME_1CYCLE_5 (0x00000000U) /*!< Sampling time 1.5 ADC clock cycle */
  784. #define ADC_SAMPLETIME_2CYCLES_5 ((uint32_t)ADC_SMPR2_SMP10_0) /*!< Sampling time 2.5 ADC clock cycles */
  785. #define ADC_SAMPLETIME_4CYCLES_5 ((uint32_t)ADC_SMPR2_SMP10_1) /*!< Sampling time 4.5 ADC clock cycles */
  786. #define ADC_SAMPLETIME_7CYCLES_5 ((uint32_t)(ADC_SMPR2_SMP10_1 | ADC_SMPR2_SMP10_0)) /*!< Sampling time 7.5 ADC clock cycles */
  787. #define ADC_SAMPLETIME_19CYCLES_5 ((uint32_t)ADC_SMPR2_SMP10_2) /*!< Sampling time 19.5 ADC clock cycles */
  788. #define ADC_SAMPLETIME_61CYCLES_5 ((uint32_t)(ADC_SMPR2_SMP10_2 | ADC_SMPR2_SMP10_0)) /*!< Sampling time 61.5 ADC clock cycles */
  789. #define ADC_SAMPLETIME_181CYCLES_5 ((uint32_t)(ADC_SMPR2_SMP10_2 | ADC_SMPR2_SMP10_1)) /*!< Sampling time 181.5 ADC clock cycles */
  790. #define ADC_SAMPLETIME_601CYCLES_5 ((uint32_t)ADC_SMPR2_SMP10) /*!< Sampling time 601.5 ADC clock cycles */
  791. /**
  792. * @}
  793. */
  794. /** @defgroup ADCEx_SingleDifferential ADC Extended Single-ended/Differential input mode
  795. * @{
  796. */
  797. #define ADC_SINGLE_ENDED (0x00000000U)
  798. #define ADC_DIFFERENTIAL_ENDED (0x00000001U)
  799. /**
  800. * @}
  801. */
  802. /** @defgroup ADCEx_OffsetNumber ADC Extended Offset Number
  803. * @{
  804. */
  805. #define ADC_OFFSET_NONE (0x00U)
  806. #define ADC_OFFSET_1 (0x01U)
  807. #define ADC_OFFSET_2 (0x02U)
  808. #define ADC_OFFSET_3 (0x03U)
  809. #define ADC_OFFSET_4 (0x04U)
  810. /**
  811. * @}
  812. */
  813. /** @defgroup ADCEx_regular_rank ADC Extended rank into regular group
  814. * @{
  815. */
  816. #define ADC_REGULAR_RANK_1 (0x00000001U)
  817. #define ADC_REGULAR_RANK_2 (0x00000002U)
  818. #define ADC_REGULAR_RANK_3 (0x00000003U)
  819. #define ADC_REGULAR_RANK_4 (0x00000004U)
  820. #define ADC_REGULAR_RANK_5 (0x00000005U)
  821. #define ADC_REGULAR_RANK_6 (0x00000006U)
  822. #define ADC_REGULAR_RANK_7 (0x00000007U)
  823. #define ADC_REGULAR_RANK_8 (0x00000008U)
  824. #define ADC_REGULAR_RANK_9 (0x00000009U)
  825. #define ADC_REGULAR_RANK_10 (0x0000000AU)
  826. #define ADC_REGULAR_RANK_11 (0x0000000BU)
  827. #define ADC_REGULAR_RANK_12 (0x0000000CU)
  828. #define ADC_REGULAR_RANK_13 (0x0000000DU)
  829. #define ADC_REGULAR_RANK_14 (0x0000000EU)
  830. #define ADC_REGULAR_RANK_15 (0x0000000FU)
  831. #define ADC_REGULAR_RANK_16 (0x00000010U)
  832. /**
  833. * @}
  834. */
  835. /** @defgroup ADCEx_injected_rank ADC Extended Injected Channel Rank
  836. * @{
  837. */
  838. #define ADC_INJECTED_RANK_1 (0x00000001U)
  839. #define ADC_INJECTED_RANK_2 (0x00000002U)
  840. #define ADC_INJECTED_RANK_3 (0x00000003U)
  841. #define ADC_INJECTED_RANK_4 (0x00000004U)
  842. /**
  843. * @}
  844. */
  845. /** @defgroup ADCEx_External_trigger_edge_Injected External Trigger Edge of Injected Group
  846. * @{
  847. */
  848. #define ADC_EXTERNALTRIGINJECCONV_EDGE_NONE (0x00000000U)
  849. #define ADC_EXTERNALTRIGINJECCONV_EDGE_RISING ((uint32_t)ADC_JSQR_JEXTEN_0)
  850. #define ADC_EXTERNALTRIGINJECCONV_EDGE_FALLING ((uint32_t)ADC_JSQR_JEXTEN_1)
  851. #define ADC_EXTERNALTRIGINJECCONV_EDGE_RISINGFALLING ((uint32_t)ADC_JSQR_JEXTEN)
  852. /**
  853. * @}
  854. */
  855. /** @defgroup ADCEx_External_trigger_source_Injected External Trigger Source of Injected Group
  856. * @{
  857. */
  858. #if defined(STM32F303xE) || defined(STM32F398xx) || \
  859. defined(STM32F303xC) || defined(STM32F358xx)
  860. /* List of external triggers with generic trigger name, independently of ADC */
  861. /* target (caution: applies to other ADCs sharing the same common group), */
  862. /* sorted by trigger name: */
  863. /* External triggers of injected group for ADC1&ADC2 only */
  864. #define ADC_EXTERNALTRIGINJECCONV_T2_CC1 ADC1_2_EXTERNALTRIGINJEC_T2_CC1
  865. #define ADC_EXTERNALTRIGINJECCONV_T3_CC1 ADC1_2_EXTERNALTRIGINJEC_T3_CC1
  866. #define ADC_EXTERNALTRIGINJECCONV_T3_CC3 ADC1_2_EXTERNALTRIGINJEC_T3_CC3
  867. #define ADC_EXTERNALTRIGINJECCONV_T3_CC4 ADC1_2_EXTERNALTRIGINJEC_T3_CC4
  868. #define ADC_EXTERNALTRIGINJECCONV_T6_TRGO ADC1_2_EXTERNALTRIGINJEC_T6_TRGO
  869. #define ADC_EXTERNALTRIGINJECCONV_EXT_IT15 ADC1_2_EXTERNALTRIGINJEC_EXT_IT15
  870. /* External triggers of injected group for ADC3&ADC4 only */
  871. #define ADC_EXTERNALTRIGINJECCONV_T1_CC3 ADC3_4_EXTERNALTRIGINJEC_T1_CC3
  872. #define ADC_EXTERNALTRIGINJECCONV_T4_CC3 ADC3_4_EXTERNALTRIGINJEC_T4_CC3
  873. #define ADC_EXTERNALTRIGINJECCONV_T4_CC4 ADC3_4_EXTERNALTRIGINJEC_T4_CC4
  874. #define ADC_EXTERNALTRIGINJECCONV_T7_TRGO ADC3_4_EXTERNALTRIGINJEC_T7_TRGO
  875. #define ADC_EXTERNALTRIGINJECCONV_T8_CC2 ADC3_4_EXTERNALTRIGINJEC_T8_CC2
  876. /* External triggers of injected group for ADC1&ADC2, ADC3&ADC4 */
  877. /* Note: Triggers affected to group ADC1_2 by default, redirected to group */
  878. /* ADC3_4 by driver when needed. */
  879. #define ADC_EXTERNALTRIGINJECCONV_T1_CC4 ADC1_2_EXTERNALTRIGINJEC_T1_CC4
  880. #define ADC_EXTERNALTRIGINJECCONV_T1_TRGO ADC1_2_EXTERNALTRIGINJEC_T1_TRGO
  881. #define ADC_EXTERNALTRIGINJECCONV_T1_TRGO2 ADC1_2_EXTERNALTRIGINJEC_T1_TRGO2
  882. #define ADC_EXTERNALTRIGINJECCONV_T2_TRGO ADC1_2_EXTERNALTRIGINJEC_T2_TRGO
  883. #define ADC_EXTERNALTRIGINJECCONV_T3_TRGO ADC1_2_EXTERNALTRIGINJEC_T3_TRGO
  884. #define ADC_EXTERNALTRIGINJECCONV_T4_TRGO ADC1_2_EXTERNALTRIGINJEC_T4_TRGO
  885. #define ADC_EXTERNALTRIGINJECCONV_T8_CC4 ADC1_2_EXTERNALTRIGINJEC_T8_CC4
  886. #define ADC_EXTERNALTRIGINJECCONV_T8_TRGO ADC1_2_EXTERNALTRIGINJEC_T8_TRGO
  887. #define ADC_EXTERNALTRIGINJECCONV_T8_TRGO2 ADC1_2_EXTERNALTRIGINJEC_T8_TRGO2
  888. #define ADC_EXTERNALTRIGINJECCONV_T15_TRGO ADC1_2_EXTERNALTRIGINJEC_T15_TRGO
  889. #define ADC_INJECTED_SOFTWARE_START (0x00000001U)
  890. #if defined(STM32F303xE) || defined(STM32F398xx)
  891. /*!< List of external triggers specific to device STM303xE: using Timer20 */
  892. /* with ADC trigger input remap. */
  893. /* To remap ADC trigger from other timers/ExtLine to timer20: use macro */
  894. /* " __HAL_REMAPADCTRIGGER_ENABLE(...) " with parameters described below: */
  895. /*!< External triggers of injected group for ADC1&ADC2 only, specific to */
  896. /* device STM303xE: : using Timer20 with ADC trigger input remap */
  897. #define ADC_EXTERNALTRIGINJECCONV_T20_CC4 ADC_EXTERNALTRIGINJECCONV_T3_CC1 /*!< Remap trigger using macro __HAL_REMAPADCTRIGGER_ENABLE(HAL_REMAPADCTRIGGER_ADC12_JEXT13U) */
  898. /*!< External triggers of injected group for ADC3&ADC4 only, specific to */
  899. /* device STM303xE: : using Timer20 with ADC trigger input remap */
  900. #define ADC_EXTERNALTRIGINJECCONV_T20_CC2 ADC_EXTERNALTRIGINJECCONV_T7_TRGO /*!< Remap trigger using macro __HAL_REMAPADCTRIGGER_ENABLE(HAL_REMAPADCTRIGGER_ADC34_JEXT14U) */
  901. /*!< External triggers of regular group for ADC1&ADC2, ADC3&ADC4, specific to */
  902. /* device STM303xE: : using Timer20 with ADC trigger input remap */
  903. /* Note: Triggers affected to group ADC1_2 by default, redirected to group */
  904. /* ADC3_4 by driver when needed. */
  905. #define ADC_EXTERNALTRIGINJECCONV_T20_TRGO (ADC_EXTERNALTRIGINJECCONV_T2_CC1 | ADC_EXTERNALTRIGCONV_T20_MASK) /*!< For ADC1&ADC2: Remap trigger using macro __HAL_REMAPADCTRIGGER_ENABLE(HAL_REMAPADCTRIGGER_ADC12_JEXT3) */
  906. /*!< For ADC3&ADC4: Remap trigger using macro __HAL_REMAPADCTRIGGER_ENABLE(HAL_REMAPADCTRIGGER_ADC34_JEXT5) */
  907. #define ADC_EXTERNALTRIGINJECCONV_T20_TRGO2 (ADC_EXTERNALTRIGINJECCONV_EXT_IT15 | ADC_EXTERNALTRIGCONV_T20_MASK) /*!< For ADC1&ADC2: Remap trigger using macro __HAL_REMAPADCTRIGGER_ENABLE(HAL_REMAPADCTRIGGER_ADC12_JEXT6) */
  908. /*!< For ADC3&ADC4: Remap trigger using macro __HAL_REMAPADCTRIGGER_ENABLE(HAL_REMAPADCTRIGGER_ADC34_JEXT11U) */
  909. #endif /* STM32F303xE || STM32F398xx */
  910. #if defined(STM32F303xC) || defined(STM32F358xx)
  911. #define IS_ADC_EXTTRIGINJEC(INJTRIG) (((INJTRIG) == ADC_EXTERNALTRIGINJECCONV_T2_CC1) || \
  912. ((INJTRIG) == ADC_EXTERNALTRIGINJECCONV_T3_CC1) || \
  913. ((INJTRIG) == ADC_EXTERNALTRIGINJECCONV_T3_CC4) || \
  914. ((INJTRIG) == ADC_EXTERNALTRIGINJECCONV_T6_TRGO) || \
  915. ((INJTRIG) == ADC_EXTERNALTRIGINJECCONV_EXT_IT15) || \
  916. \
  917. ((INJTRIG) == ADC_EXTERNALTRIGINJECCONV_T4_CC3) || \
  918. ((INJTRIG) == ADC_EXTERNALTRIGINJECCONV_T4_CC4) || \
  919. ((INJTRIG) == ADC_EXTERNALTRIGINJECCONV_T7_TRGO) || \
  920. ((INJTRIG) == ADC_EXTERNALTRIGINJECCONV_T8_CC2) || \
  921. \
  922. ((INJTRIG) == ADC_EXTERNALTRIGINJECCONV_T1_CC4) || \
  923. ((INJTRIG) == ADC_EXTERNALTRIGINJECCONV_T1_TRGO) || \
  924. ((INJTRIG) == ADC_EXTERNALTRIGINJECCONV_T1_TRGO2) || \
  925. ((INJTRIG) == ADC_EXTERNALTRIGINJECCONV_T2_TRGO) || \
  926. ((INJTRIG) == ADC_EXTERNALTRIGINJECCONV_T3_CC3) || \
  927. ((INJTRIG) == ADC_EXTERNALTRIGINJECCONV_T3_TRGO) || \
  928. ((INJTRIG) == ADC_EXTERNALTRIGINJECCONV_T4_TRGO) || \
  929. ((INJTRIG) == ADC_EXTERNALTRIGINJECCONV_T8_CC4) || \
  930. ((INJTRIG) == ADC_EXTERNALTRIGINJECCONV_T8_TRGO) || \
  931. ((INJTRIG) == ADC_EXTERNALTRIGINJECCONV_T8_TRGO2) || \
  932. ((INJTRIG) == ADC_EXTERNALTRIGINJECCONV_T15_TRGO) || \
  933. \
  934. ((INJTRIG) == ADC_INJECTED_SOFTWARE_START) )
  935. #endif /* STM32F303xC || STM32F358xx */
  936. #if defined(STM32F303xE) || defined(STM32F398xx)
  937. #define IS_ADC_EXTTRIGINJEC(INJTRIG) (((INJTRIG) == ADC_EXTERNALTRIGINJECCONV_T2_CC1) || \
  938. ((INJTRIG) == ADC_EXTERNALTRIGINJECCONV_T3_CC1) || \
  939. ((INJTRIG) == ADC_EXTERNALTRIGINJECCONV_T3_CC4) || \
  940. ((INJTRIG) == ADC_EXTERNALTRIGINJECCONV_T6_TRGO) || \
  941. ((INJTRIG) == ADC_EXTERNALTRIGINJECCONV_EXT_IT15) || \
  942. \
  943. ((INJTRIG) == ADC_EXTERNALTRIGINJECCONV_T4_CC3) || \
  944. ((INJTRIG) == ADC_EXTERNALTRIGINJECCONV_T4_CC4) || \
  945. ((INJTRIG) == ADC_EXTERNALTRIGINJECCONV_T7_TRGO) || \
  946. ((INJTRIG) == ADC_EXTERNALTRIGINJECCONV_T8_CC2) || \
  947. \
  948. ((INJTRIG) == ADC_EXTERNALTRIGINJECCONV_T1_CC4) || \
  949. ((INJTRIG) == ADC_EXTERNALTRIGINJECCONV_T1_TRGO) || \
  950. ((INJTRIG) == ADC_EXTERNALTRIGINJECCONV_T1_TRGO2) || \
  951. ((INJTRIG) == ADC_EXTERNALTRIGINJECCONV_T2_TRGO) || \
  952. ((INJTRIG) == ADC_EXTERNALTRIGINJECCONV_T3_CC3) || \
  953. ((INJTRIG) == ADC_EXTERNALTRIGINJECCONV_T3_TRGO) || \
  954. ((INJTRIG) == ADC_EXTERNALTRIGINJECCONV_T4_TRGO) || \
  955. ((INJTRIG) == ADC_EXTERNALTRIGINJECCONV_T8_CC4) || \
  956. ((INJTRIG) == ADC_EXTERNALTRIGINJECCONV_T8_TRGO) || \
  957. ((INJTRIG) == ADC_EXTERNALTRIGINJECCONV_T8_TRGO2) || \
  958. ((INJTRIG) == ADC_EXTERNALTRIGINJECCONV_T15_TRGO) || \
  959. \
  960. ((INJTRIG) == ADC_EXTERNALTRIGINJECCONV_T20_CC4) || \
  961. ((INJTRIG) == ADC_EXTERNALTRIGINJECCONV_T20_CC2) || \
  962. ((INJTRIG) == ADC_EXTERNALTRIGINJECCONV_T20_TRGO) || \
  963. ((INJTRIG) == ADC_EXTERNALTRIGINJECCONV_T20_TRGO2) || \
  964. \
  965. ((INJTRIG) == ADC_INJECTED_SOFTWARE_START) )
  966. #endif /* STM32F303xE || STM32F398xx */
  967. #endif /* STM32F303xC || STM32F303xE || STM32F398xx || STM32F358xx */
  968. #if defined(STM32F302xE) || \
  969. defined(STM32F302xC)
  970. /*!< List of external triggers with generic trigger name, independently of */
  971. /* ADC target (caution: applies to other ADCs sharing the same common group), */
  972. /* sorted by trigger name: */
  973. /* External triggers of injected group for ADC1&ADC2 */
  974. #define ADC_EXTERNALTRIGINJECCONV_T1_CC4 ADC1_2_EXTERNALTRIGINJEC_T1_CC4
  975. #define ADC_EXTERNALTRIGINJECCONV_T1_TRGO ADC1_2_EXTERNALTRIGINJEC_T1_TRGO
  976. #define ADC_EXTERNALTRIGINJECCONV_T1_TRGO2 ADC1_2_EXTERNALTRIGINJEC_T1_TRGO2
  977. #define ADC_EXTERNALTRIGINJECCONV_T2_CC1 ADC1_2_EXTERNALTRIGINJEC_T2_CC1
  978. #define ADC_EXTERNALTRIGINJECCONV_T2_TRGO ADC1_2_EXTERNALTRIGINJEC_T2_TRGO
  979. #define ADC_EXTERNALTRIGINJECCONV_T3_CC1 ADC1_2_EXTERNALTRIGINJEC_T3_CC1
  980. #define ADC_EXTERNALTRIGINJECCONV_T3_CC3 ADC1_2_EXTERNALTRIGINJEC_T3_CC3
  981. #define ADC_EXTERNALTRIGINJECCONV_T3_CC4 ADC1_2_EXTERNALTRIGINJEC_T3_CC4
  982. #define ADC_EXTERNALTRIGINJECCONV_T3_TRGO ADC1_2_EXTERNALTRIGINJEC_T3_TRGO
  983. #define ADC_EXTERNALTRIGINJECCONV_T4_TRGO ADC1_2_EXTERNALTRIGINJEC_T4_TRGO
  984. #define ADC_EXTERNALTRIGINJECCONV_T6_TRGO ADC1_2_EXTERNALTRIGINJEC_T6_TRGO
  985. #define ADC_EXTERNALTRIGINJECCONV_T15_TRGO ADC1_2_EXTERNALTRIGINJEC_T15_TRGO
  986. #define ADC_EXTERNALTRIGINJECCONV_EXT_IT15 ADC1_2_EXTERNALTRIGINJEC_EXT_IT15
  987. #define ADC_INJECTED_SOFTWARE_START (0x00000001U)
  988. #if defined(STM32F302xE)
  989. /*!< List of external triggers specific to device STM302xE: using Timer20 */
  990. /* with ADC trigger input remap. */
  991. /* To remap ADC trigger from other timers/ExtLine to timer20: use macro */
  992. /* " __HAL_REMAPADCTRIGGER_ENABLE(...) " with parameters described below: */
  993. /*!< External triggers of injected group for ADC1&ADC2 only, specific to */
  994. /* device STM302xE: : using Timer20 with ADC trigger input remap */
  995. #define ADC_EXTERNALTRIGINJECCONV_T20_CC4 ADC_EXTERNALTRIGINJECCONV_T3_CC1 /*!< Remap trigger using macro __HAL_REMAPADCTRIGGER_ENABLE(HAL_REMAPADCTRIGGER_ADC12_JEXT13U) */
  996. #define ADC_EXTERNALTRIGINJECCONV_T20_TRGO (ADC_EXTERNALTRIGINJECCONV_T2_CC1 | ADC_EXTERNALTRIGCONV_T20_MASK) /*!< For ADC1&ADC2: Remap trigger using macro __HAL_REMAPADCTRIGGER_ENABLE(HAL_REMAPADCTRIGGER_ADC12_JEXT3) */
  997. #define ADC_EXTERNALTRIGINJECCONV_T20_TRGO2 (ADC_EXTERNALTRIGINJECCONV_EXT_IT15 | ADC_EXTERNALTRIGCONV_T20_MASK) /*!< For ADC1&ADC2: Remap trigger using macro __HAL_REMAPADCTRIGGER_ENABLE(HAL_REMAPADCTRIGGER_ADC12_JEXT6) */
  998. #endif /* STM32F302xE */
  999. #endif /* STM32F302xE || */
  1000. /* STM32F302xC */
  1001. #if defined(STM32F303x8) || defined(STM32F328xx)
  1002. /*!< List of external triggers with generic trigger name, independently of */
  1003. /* ADC target (caution: applies to other ADCs sharing the same common group), */
  1004. /* sorted by trigger name: */
  1005. /* External triggers of injected group for ADC1&ADC2 */
  1006. #define ADC_EXTERNALTRIGINJECCONV_T1_CC4 ADC1_2_EXTERNALTRIGINJEC_T1_CC4
  1007. #define ADC_EXTERNALTRIGINJECCONV_T1_TRGO ADC1_2_EXTERNALTRIGINJEC_T1_TRGO
  1008. #define ADC_EXTERNALTRIGINJECCONV_T1_TRGO2 ADC1_2_EXTERNALTRIGINJEC_T1_TRGO2
  1009. #define ADC_EXTERNALTRIGINJECCONV_T2_CC1 ADC1_2_EXTERNALTRIGINJEC_T2_CC1
  1010. #define ADC_EXTERNALTRIGINJECCONV_T2_TRGO ADC1_2_EXTERNALTRIGINJEC_T2_TRGO
  1011. #define ADC_EXTERNALTRIGINJECCONV_T3_CC1 ADC1_2_EXTERNALTRIGINJEC_T3_CC1
  1012. #define ADC_EXTERNALTRIGINJECCONV_T3_CC3 ADC1_2_EXTERNALTRIGINJEC_T3_CC3
  1013. #define ADC_EXTERNALTRIGINJECCONV_T3_CC4 ADC1_2_EXTERNALTRIGINJEC_T3_CC4
  1014. #define ADC_EXTERNALTRIGINJECCONV_T3_TRGO ADC1_2_EXTERNALTRIGINJEC_T3_TRGO
  1015. #define ADC_EXTERNALTRIGINJECCONV_T4_TRGO ADC1_2_EXTERNALTRIGINJEC_T4_TRGO
  1016. #define ADC_EXTERNALTRIGINJECCONV_T6_TRGO ADC1_2_EXTERNALTRIGINJEC_T6_TRGO
  1017. #define ADC_EXTERNALTRIGINJECCONV_T8_CC4 ADC1_2_EXTERNALTRIGINJEC_T8_CC4
  1018. #define ADC_EXTERNALTRIGINJECCONV_T8_TRGO ADC1_2_EXTERNALTRIGINJEC_T8_TRGO
  1019. #define ADC_EXTERNALTRIGINJECCONV_T8_TRGO2 ADC1_2_EXTERNALTRIGINJEC_T8_TRGO2
  1020. #define ADC_EXTERNALTRIGINJECCONV_T15_TRGO ADC1_2_EXTERNALTRIGINJEC_T15_TRGO
  1021. #define ADC_EXTERNALTRIGINJECCONV_EXT_IT15 ADC1_2_EXTERNALTRIGINJEC_EXT_IT15
  1022. #define ADC_INJECTED_SOFTWARE_START (0x00000001U)
  1023. #endif /* STM32F303x8 || STM32F328xx */
  1024. #if defined(STM32F334x8)
  1025. /*!< List of external triggers with generic trigger name, independently of */
  1026. /* ADC target (caution: applies to other ADCs sharing the same common group), */
  1027. /* sorted by trigger name: */
  1028. /* External triggers of injected group for ADC1&ADC2 */
  1029. #define ADC_EXTERNALTRIGINJECCONV_T1_CC4 ADC1_2_EXTERNALTRIGINJEC_T1_CC4
  1030. #define ADC_EXTERNALTRIGINJECCONV_T1_TRGO ADC1_2_EXTERNALTRIGINJEC_T1_TRGO
  1031. #define ADC_EXTERNALTRIGINJECCONV_T1_TRGO2 ADC1_2_EXTERNALTRIGINJEC_T1_TRGO2
  1032. #define ADC_EXTERNALTRIGINJECCONV_T2_CC1 ADC1_2_EXTERNALTRIGINJEC_T2_CC1
  1033. #define ADC_EXTERNALTRIGINJECCONV_T2_TRGO ADC1_2_EXTERNALTRIGINJEC_T2_TRGO
  1034. #define ADC_EXTERNALTRIGINJECCONV_T3_CC1 ADC1_2_EXTERNALTRIGINJEC_T3_CC1
  1035. #define ADC_EXTERNALTRIGINJECCONV_T3_CC3 ADC1_2_EXTERNALTRIGINJEC_T3_CC3
  1036. #define ADC_EXTERNALTRIGINJECCONV_T3_CC4 ADC1_2_EXTERNALTRIGINJEC_T3_CC4
  1037. #define ADC_EXTERNALTRIGINJECCONV_T3_TRGO ADC1_2_EXTERNALTRIGINJEC_T3_TRGO
  1038. #define ADC_EXTERNALTRIGINJECCONV_T6_TRGO ADC1_2_EXTERNALTRIGINJEC_T6_TRGO
  1039. #define ADC_EXTERNALTRIGINJECCONV_T15_TRGO ADC1_2_EXTERNALTRIGINJEC_T15_TRGO
  1040. #define ADC_EXTERNALTRIGINJECCONV_HRTIM_TRG2 ADC1_2_EXTERNALTRIGINJEC_HRTIM_TRG2
  1041. #define ADC_EXTERNALTRIGINJECCONV_HRTIM_TRG4 ADC1_2_EXTERNALTRIGINJEC_HRTIM_TRG4
  1042. #define ADC_EXTERNALTRIGINJECCONV_EXT_IT15 ADC1_2_EXTERNALTRIGINJEC_EXT_IT15
  1043. #define ADC_INJECTED_SOFTWARE_START (0x00000001U)
  1044. #endif /* STM32F334x8 */
  1045. #if defined(STM32F301x8) || defined(STM32F302x8) || defined(STM32F318xx)
  1046. /* List of external triggers with generic trigger name, sorted by trigger */
  1047. /* name: */
  1048. /* External triggers of injected group for ADC1 */
  1049. #define ADC_EXTERNALTRIGINJECCONV_T1_CC4 ADC1_EXTERNALTRIGINJEC_T1_CC4
  1050. #define ADC_EXTERNALTRIGINJECCONV_T1_TRGO ADC1_EXTERNALTRIGINJEC_T1_TRGO
  1051. #define ADC_EXTERNALTRIGINJECCONV_T1_TRGO2 ADC1_EXTERNALTRIGINJEC_T1_TRGO2
  1052. #define ADC_EXTERNALTRIGINJECCONV_T2_CC1 ADC1_EXTERNALTRIGINJEC_T2_CC1
  1053. #define ADC_EXTERNALTRIGINJECCONV_T2_TRGO ADC1_EXTERNALTRIGINJEC_T2_TRGO
  1054. #define ADC_EXTERNALTRIGINJECCONV_T6_TRGO ADC1_EXTERNALTRIGINJEC_T6_TRGO
  1055. #define ADC_EXTERNALTRIGINJECCONV_T15_TRGO ADC1_EXTERNALTRIGINJEC_T15_TRGO
  1056. #define ADC_EXTERNALTRIGINJECCONV_EXT_IT15 ADC1_EXTERNALTRIGINJEC_EXT_IT15
  1057. #define ADC_INJECTED_SOFTWARE_START (0x00000001U)
  1058. #endif /* STM32F301x8 || STM32F302x8 || STM32F318xx */
  1059. /**
  1060. * @}
  1061. */
  1062. /** @defgroup ADCEx_Common_mode ADC Extended Dual ADC Mode
  1063. * @{
  1064. */
  1065. #define ADC_MODE_INDEPENDENT ((uint32_t)(0x00000000U))
  1066. #define ADC_DUALMODE_REGSIMULT_INJECSIMULT ((uint32_t)(ADC12_CCR_MULTI_0))
  1067. #define ADC_DUALMODE_REGSIMULT_ALTERTRIG ((uint32_t)(ADC12_CCR_MULTI_1))
  1068. #define ADC_DUALMODE_REGINTERL_INJECSIMULT ((uint32_t)(ADC12_CCR_MULTI_1 | ADC12_CCR_MULTI_0))
  1069. #define ADC_DUALMODE_INJECSIMULT ((uint32_t)(ADC12_CCR_MULTI_2 | ADC12_CCR_MULTI_0))
  1070. #define ADC_DUALMODE_REGSIMULT ((uint32_t)(ADC12_CCR_MULTI_2 | ADC12_CCR_MULTI_1))
  1071. #define ADC_DUALMODE_INTERL ((uint32_t)(ADC12_CCR_MULTI_2 | ADC12_CCR_MULTI_1 | ADC12_CCR_MULTI_0))
  1072. #define ADC_DUALMODE_ALTERTRIG ((uint32_t)(ADC12_CCR_MULTI_3 | ADC12_CCR_MULTI_0))
  1073. /**
  1074. * @}
  1075. */
  1076. /** @defgroup ADCEx_Direct_memory_access_mode_for_multimode ADC Extended DMA Mode for Dual ADC Mode
  1077. * @{
  1078. */
  1079. #define ADC_DMAACCESSMODE_DISABLED (0x00000000U) /*!< DMA multimode disabled: each ADC will use its own DMA channel */
  1080. #define ADC_DMAACCESSMODE_12_10_BITS ((uint32_t)ADC12_CCR_MDMA_1) /*!< DMA multimode enabled (one DMA channel for both ADC, DMA of ADC master) for 12 and 10 bits resolution */
  1081. #define ADC_DMAACCESSMODE_8_6_BITS ((uint32_t)ADC12_CCR_MDMA) /*!< DMA multimode enabled (one DMA channel for both ADC, DMA of ADC master) for 8 and 6 bits resolution */
  1082. /**
  1083. * @}
  1084. */
  1085. /** @defgroup ADCEx_delay_between_2_sampling_phases ADC Extended Delay Between 2 Sampling Phases
  1086. * @{
  1087. */
  1088. #define ADC_TWOSAMPLINGDELAY_1CYCLE ((uint32_t)(0x00000000U))
  1089. #define ADC_TWOSAMPLINGDELAY_2CYCLES ((uint32_t)(ADC12_CCR_DELAY_0))
  1090. #define ADC_TWOSAMPLINGDELAY_3CYCLES ((uint32_t)(ADC12_CCR_DELAY_1))
  1091. #define ADC_TWOSAMPLINGDELAY_4CYCLES ((uint32_t)(ADC12_CCR_DELAY_1 | ADC12_CCR_DELAY_0))
  1092. #define ADC_TWOSAMPLINGDELAY_5CYCLES ((uint32_t)(ADC12_CCR_DELAY_2))
  1093. #define ADC_TWOSAMPLINGDELAY_6CYCLES ((uint32_t)(ADC12_CCR_DELAY_2 | ADC12_CCR_DELAY_0))
  1094. #define ADC_TWOSAMPLINGDELAY_7CYCLES ((uint32_t)(ADC12_CCR_DELAY_2 | ADC12_CCR_DELAY_1))
  1095. #define ADC_TWOSAMPLINGDELAY_8CYCLES ((uint32_t)(ADC12_CCR_DELAY_2 | ADC12_CCR_DELAY_1 | ADC12_CCR_DELAY_0))
  1096. #define ADC_TWOSAMPLINGDELAY_9CYCLES ((uint32_t)(ADC12_CCR_DELAY_3))
  1097. #define ADC_TWOSAMPLINGDELAY_10CYCLES ((uint32_t)(ADC12_CCR_DELAY_3 | ADC12_CCR_DELAY_0))
  1098. #define ADC_TWOSAMPLINGDELAY_11CYCLES ((uint32_t)(ADC12_CCR_DELAY_3 | ADC12_CCR_DELAY_1))
  1099. #define ADC_TWOSAMPLINGDELAY_12CYCLES ((uint32_t)(ADC12_CCR_DELAY_3 | ADC12_CCR_DELAY_1 | ADC12_CCR_DELAY_0))
  1100. /**
  1101. * @}
  1102. */
  1103. /** @defgroup ADCEx_analog_watchdog_number ADC Extended Analog Watchdog Selection
  1104. * @{
  1105. */
  1106. #define ADC_ANALOGWATCHDOG_1 (0x00000001U)
  1107. #define ADC_ANALOGWATCHDOG_2 (0x00000002U)
  1108. #define ADC_ANALOGWATCHDOG_3 (0x00000003U)
  1109. /**
  1110. * @}
  1111. */
  1112. /** @defgroup ADCEx_analog_watchdog_mode ADC Extended Analog Watchdog Mode
  1113. * @{
  1114. */
  1115. #define ADC_ANALOGWATCHDOG_NONE ( 0x00000000U)
  1116. #define ADC_ANALOGWATCHDOG_SINGLE_REG ((uint32_t)(ADC_CFGR_AWD1SGL | ADC_CFGR_AWD1EN))
  1117. #define ADC_ANALOGWATCHDOG_SINGLE_INJEC ((uint32_t)(ADC_CFGR_AWD1SGL | ADC_CFGR_JAWD1EN))
  1118. #define ADC_ANALOGWATCHDOG_SINGLE_REGINJEC ((uint32_t)(ADC_CFGR_AWD1SGL | ADC_CFGR_AWD1EN | ADC_CFGR_JAWD1EN))
  1119. #define ADC_ANALOGWATCHDOG_ALL_REG ((uint32_t) ADC_CFGR_AWD1EN)
  1120. #define ADC_ANALOGWATCHDOG_ALL_INJEC ((uint32_t) ADC_CFGR_JAWD1EN)
  1121. #define ADC_ANALOGWATCHDOG_ALL_REGINJEC ((uint32_t)(ADC_CFGR_AWD1EN | ADC_CFGR_JAWD1EN))
  1122. /**
  1123. * @}
  1124. */
  1125. /** @defgroup ADC_conversion_group ADC Conversion Group
  1126. * @{
  1127. */
  1128. #define ADC_REGULAR_GROUP ((uint32_t)(ADC_FLAG_EOC | ADC_FLAG_EOS))
  1129. #define ADC_INJECTED_GROUP ((uint32_t)(ADC_FLAG_JEOC | ADC_FLAG_JEOS))
  1130. #define ADC_REGULAR_INJECTED_GROUP ((uint32_t)(ADC_FLAG_EOC | ADC_FLAG_EOS | ADC_FLAG_JEOC | ADC_FLAG_JEOS))
  1131. /**
  1132. * @}
  1133. */
  1134. /** @defgroup ADCEx_Event_type ADC Extended Event Type
  1135. * @{
  1136. */
  1137. #define ADC_AWD1_EVENT ((uint32_t)ADC_FLAG_AWD1) /*!< ADC Analog watchdog 1 event (main analog watchdog, present on all STM32 devices) */
  1138. #define ADC_AWD2_EVENT ((uint32_t)ADC_FLAG_AWD2) /*!< ADC Analog watchdog 2 event (additional analog watchdog, not present on all STM32 families) */
  1139. #define ADC_AWD3_EVENT ((uint32_t)ADC_FLAG_AWD3) /*!< ADC Analog watchdog 3 event (additional analog watchdog, not present on all STM32 families) */
  1140. #define ADC_OVR_EVENT ((uint32_t)ADC_FLAG_OVR) /*!< ADC overrun event */
  1141. #define ADC_JQOVF_EVENT ((uint32_t)ADC_FLAG_JQOVF) /*!< ADC Injected Context Queue Overflow event */
  1142. #define ADC_AWD_EVENT ADC_AWD1_EVENT /* ADC Analog watchdog 1 event: Alternate naming for compatibility with other STM32 devices having only 1 analog watchdog */
  1143. /**
  1144. * @}
  1145. */
  1146. /** @defgroup ADCEx_interrupts_definition ADC Extended Interrupts Definition
  1147. * @{
  1148. */
  1149. #define ADC_IT_RDY ADC_IER_RDY /*!< ADC Ready (ADRDY) interrupt source */
  1150. #define ADC_IT_EOSMP ADC_IER_EOSMP /*!< ADC End of Sampling interrupt source */
  1151. #define ADC_IT_EOC ADC_IER_EOC /*!< ADC End of Regular Conversion interrupt source */
  1152. #define ADC_IT_EOS ADC_IER_EOS /*!< ADC End of Regular sequence of Conversions interrupt source */
  1153. #define ADC_IT_OVR ADC_IER_OVR /*!< ADC overrun interrupt source */
  1154. #define ADC_IT_JEOC ADC_IER_JEOC /*!< ADC End of Injected Conversion interrupt source */
  1155. #define ADC_IT_JEOS ADC_IER_JEOS /*!< ADC End of Injected sequence of Conversions interrupt source */
  1156. #define ADC_IT_AWD1 ADC_IER_AWD1 /*!< ADC Analog watchdog 1 interrupt source (main analog watchdog, present on all STM32 devices) */
  1157. #define ADC_IT_AWD2 ADC_IER_AWD2 /*!< ADC Analog watchdog 2 interrupt source (additional analog watchdog, present only on STM32F3 devices) */
  1158. #define ADC_IT_AWD3 ADC_IER_AWD3 /*!< ADC Analog watchdog 3 interrupt source (additional analog watchdog, present only on STM32F3 devices) */
  1159. #define ADC_IT_JQOVF ADC_IER_JQOVF /*!< ADC Injected Context Queue Overflow interrupt source */
  1160. #define ADC_IT_AWD ADC_IT_AWD1 /* ADC Analog watchdog 1 interrupt source: Alternate naming for compatibility with other STM32 devices having only 1 analog watchdog */
  1161. /**
  1162. * @}
  1163. */
  1164. /** @defgroup ADCEx_flags_definition ADC Extended Flags Definition
  1165. * @{
  1166. */
  1167. #define ADC_FLAG_RDY ADC_ISR_ADRD /*!< ADC Ready (ADRDY) flag */
  1168. #define ADC_FLAG_EOSMP ADC_ISR_EOSMP /*!< ADC End of Sampling flag */
  1169. #define ADC_FLAG_EOC ADC_ISR_EOC /*!< ADC End of Regular Conversion flag */
  1170. #define ADC_FLAG_EOS ADC_ISR_EOS /*!< ADC End of Regular sequence of Conversions flag */
  1171. #define ADC_FLAG_OVR ADC_ISR_OVR /*!< ADC overrun flag */
  1172. #define ADC_FLAG_JEOC ADC_ISR_JEOC /*!< ADC End of Injected Conversion flag */
  1173. #define ADC_FLAG_JEOS ADC_ISR_JEOS /*!< ADC End of Injected sequence of Conversions flag */
  1174. #define ADC_FLAG_AWD1 ADC_ISR_AWD1 /*!< ADC Analog watchdog 1 flag (main analog watchdog, present on all STM32 devices) */
  1175. #define ADC_FLAG_AWD2 ADC_ISR_AWD2 /*!< ADC Analog watchdog 2 flag (additional analog watchdog, present only on STM32F3 devices) */
  1176. #define ADC_FLAG_AWD3 ADC_ISR_AWD3 /*!< ADC Analog watchdog 3 flag (additional analog watchdog, present only on STM32F3 devices) */
  1177. #define ADC_FLAG_JQOVF ADC_ISR_JQOVF /*!< ADC Injected Context Queue Overflow flag */
  1178. #define ADC_FLAG_AWD ADC_FLAG_AWD1 /* ADC Analog watchdog 1 flag: Alternate naming for compatibility with other STM32 devices having only 1 analog watchdog */
  1179. /**
  1180. * @}
  1181. */
  1182. #endif /* STM32F302xE || STM32F303xE || STM32F398xx || */
  1183. /* STM32F302xC || STM32F303xC || STM32F358xx || */
  1184. /* STM32F303x8 || STM32F334x8 || STM32F328xx || */
  1185. /* STM32F301x8 || STM32F302x8 || STM32F318xx */
  1186. #if defined(STM32F373xC) || defined(STM32F378xx)
  1187. /** @defgroup ADCEx_Data_align ADC Extended Data Alignment
  1188. * @{
  1189. */
  1190. #define ADC_DATAALIGN_RIGHT (0x00000000U)
  1191. #define ADC_DATAALIGN_LEFT ((uint32_t)ADC_CR2_ALIGN)
  1192. /**
  1193. * @}
  1194. */
  1195. /** @defgroup ADCEx_Scan_mode ADC Extended Scan Mode
  1196. * @{
  1197. */
  1198. #define ADC_SCAN_DISABLE (0x00000000U)
  1199. #define ADC_SCAN_ENABLE ((uint32_t)ADC_CR1_SCAN)
  1200. /**
  1201. * @}
  1202. */
  1203. /** @defgroup ADCEx_External_trigger_edge_Regular ADC Extended External trigger enable for regular group
  1204. * @{
  1205. */
  1206. #define ADC_EXTERNALTRIGCONVEDGE_NONE (0x00000000U)
  1207. #define ADC_EXTERNALTRIGCONVEDGE_RISING ((uint32_t)ADC_CR2_EXTTRIG)
  1208. /**
  1209. * @}
  1210. */
  1211. /** @defgroup ADCEx_External_trigger_source_Regular ADC Extended External trigger selection for regular group
  1212. * @{
  1213. */
  1214. /* List of external triggers with generic trigger name, sorted by trigger */
  1215. /* name: */
  1216. /* External triggers of regular group for ADC1 */
  1217. #define ADC_EXTERNALTRIGCONV_T2_CC2 ADC_EXTERNALTRIG_T2_CC2
  1218. #define ADC_EXTERNALTRIGCONV_T3_TRGO ADC_EXTERNALTRIG_T3_TRGO
  1219. #define ADC_EXTERNALTRIGCONV_T4_CC4 ADC_EXTERNALTRIG_T4_CC4
  1220. #define ADC_EXTERNALTRIGCONV_T19_TRGO ADC_EXTERNALTRIG_T19_TRGO
  1221. #define ADC_EXTERNALTRIGCONV_T19_CC3 ADC_EXTERNALTRIG_T19_CC3
  1222. #define ADC_EXTERNALTRIGCONV_T19_CC4 ADC_EXTERNALTRIG_T19_CC4
  1223. #define ADC_EXTERNALTRIGCONV_EXT_IT11 ADC_EXTERNALTRIG_EXT_IT11
  1224. #define ADC_SOFTWARE_START ADC_SWSTART
  1225. /**
  1226. * @}
  1227. */
  1228. /** @defgroup ADCEx_channels ADC Extended Channels
  1229. * @{
  1230. */
  1231. /* Note: Depending on devices, some channels may not be available on package */
  1232. /* pins. Refer to device datasheet for channels availability. */
  1233. #define ADC_CHANNEL_0 (0x00000000U)
  1234. #define ADC_CHANNEL_1 ((uint32_t)(ADC_SQR3_SQ1_0))
  1235. #define ADC_CHANNEL_2 ((uint32_t)(ADC_SQR3_SQ1_1))
  1236. #define ADC_CHANNEL_3 ((uint32_t)(ADC_SQR3_SQ1_1 | ADC_SQR3_SQ1_0))
  1237. #define ADC_CHANNEL_4 ((uint32_t)(ADC_SQR3_SQ1_2))
  1238. #define ADC_CHANNEL_5 ((uint32_t)(ADC_SQR3_SQ1_2 | ADC_SQR3_SQ1_0))
  1239. #define ADC_CHANNEL_6 ((uint32_t)(ADC_SQR3_SQ1_2 | ADC_SQR3_SQ1_1))
  1240. #define ADC_CHANNEL_7 ((uint32_t)(ADC_SQR3_SQ1_2 | ADC_SQR3_SQ1_1 | ADC_SQR3_SQ1_0))
  1241. #define ADC_CHANNEL_8 ((uint32_t)(ADC_SQR3_SQ1_3))
  1242. #define ADC_CHANNEL_9 ((uint32_t)(ADC_SQR3_SQ1_3 | ADC_SQR3_SQ1_0))
  1243. #define ADC_CHANNEL_10 ((uint32_t)(ADC_SQR3_SQ1_3 | ADC_SQR3_SQ1_1))
  1244. #define ADC_CHANNEL_11 ((uint32_t)(ADC_SQR3_SQ1_3 | ADC_SQR3_SQ1_1 | ADC_SQR3_SQ1_0))
  1245. #define ADC_CHANNEL_12 ((uint32_t)(ADC_SQR3_SQ1_3 | ADC_SQR3_SQ1_2))
  1246. #define ADC_CHANNEL_13 ((uint32_t)(ADC_SQR3_SQ1_3 | ADC_SQR3_SQ1_2 | ADC_SQR3_SQ1_0))
  1247. #define ADC_CHANNEL_14 ((uint32_t)(ADC_SQR3_SQ1_3 | ADC_SQR3_SQ1_2 | ADC_SQR3_SQ1_1))
  1248. #define ADC_CHANNEL_15 ((uint32_t)(ADC_SQR3_SQ1_3 | ADC_SQR3_SQ1_2 | ADC_SQR3_SQ1_1 | ADC_SQR3_SQ1_0))
  1249. #define ADC_CHANNEL_16 ((uint32_t)(ADC_SQR3_SQ1_4))
  1250. #define ADC_CHANNEL_17 ((uint32_t)(ADC_SQR3_SQ1_4 | ADC_SQR3_SQ1_0))
  1251. #define ADC_CHANNEL_18 ((uint32_t)(ADC_SQR3_SQ1_4 | ADC_SQR3_SQ1_1))
  1252. #define ADC_CHANNEL_TEMPSENSOR ADC_CHANNEL_16
  1253. #define ADC_CHANNEL_VREFINT ADC_CHANNEL_17
  1254. #define ADC_CHANNEL_VBAT ADC_CHANNEL_18
  1255. /**
  1256. * @}
  1257. */
  1258. /** @defgroup ADCEx_sampling_times ADC Extended Sampling Times
  1259. * @{
  1260. */
  1261. #define ADC_SAMPLETIME_1CYCLE_5 (0x00000000U) /*!< Sampling time 1.5 ADC clock cycle */
  1262. #define ADC_SAMPLETIME_7CYCLES_5 ((uint32_t) ADC_SMPR2_SMP0_0) /*!< Sampling time 7.5 ADC clock cycles */
  1263. #define ADC_SAMPLETIME_13CYCLES_5 ((uint32_t) ADC_SMPR2_SMP0_1) /*!< Sampling time 13.5 ADC clock cycles */
  1264. #define ADC_SAMPLETIME_28CYCLES_5 ((uint32_t)(ADC_SMPR2_SMP0_1 | ADC_SMPR2_SMP0_0)) /*!< Sampling time 28.5 ADC clock cycles */
  1265. #define ADC_SAMPLETIME_41CYCLES_5 ((uint32_t) ADC_SMPR2_SMP0_2) /*!< Sampling time 41.5 ADC clock cycles */
  1266. #define ADC_SAMPLETIME_55CYCLES_5 ((uint32_t)(ADC_SMPR2_SMP0_2 | ADC_SMPR2_SMP0_0)) /*!< Sampling time 55.5 ADC clock cycles */
  1267. #define ADC_SAMPLETIME_71CYCLES_5 ((uint32_t)(ADC_SMPR2_SMP0_2 | ADC_SMPR2_SMP0_1)) /*!< Sampling time 71.5 ADC clock cycles */
  1268. #define ADC_SAMPLETIME_239CYCLES_5 ((uint32_t) ADC_SMPR2_SMP0) /*!< Sampling time 239.5 ADC clock cycles */
  1269. /**
  1270. * @}
  1271. */
  1272. /** @defgroup ADCEx_regular_rank ADC Extended rank into regular group
  1273. * @{
  1274. */
  1275. #define ADC_REGULAR_RANK_1 (0x00000001U)
  1276. #define ADC_REGULAR_RANK_2 (0x00000002U)
  1277. #define ADC_REGULAR_RANK_3 (0x00000003U)
  1278. #define ADC_REGULAR_RANK_4 (0x00000004U)
  1279. #define ADC_REGULAR_RANK_5 (0x00000005U)
  1280. #define ADC_REGULAR_RANK_6 (0x00000006U)
  1281. #define ADC_REGULAR_RANK_7 (0x00000007U)
  1282. #define ADC_REGULAR_RANK_8 (0x00000008U)
  1283. #define ADC_REGULAR_RANK_9 (0x00000009U)
  1284. #define ADC_REGULAR_RANK_10 (0x0000000AU)
  1285. #define ADC_REGULAR_RANK_11 (0x0000000BU)
  1286. #define ADC_REGULAR_RANK_12 (0x0000000CU)
  1287. #define ADC_REGULAR_RANK_13 (0x0000000DU)
  1288. #define ADC_REGULAR_RANK_14 (0x0000000EU)
  1289. #define ADC_REGULAR_RANK_15 (0x0000000FU)
  1290. #define ADC_REGULAR_RANK_16 (0x00000010U)
  1291. /**
  1292. * @}
  1293. */
  1294. /** @defgroup ADCEx_injected_rank ADC Extended Injected Channel Rank
  1295. * @{
  1296. */
  1297. #define ADC_INJECTED_RANK_1 (0x00000001U)
  1298. #define ADC_INJECTED_RANK_2 (0x00000002U)
  1299. #define ADC_INJECTED_RANK_3 (0x00000003U)
  1300. #define ADC_INJECTED_RANK_4 (0x00000004U)
  1301. /**
  1302. * @}
  1303. */
  1304. /** @defgroup ADCEx_External_trigger_edge_Injected External Trigger Edge of Injected Group
  1305. * @{
  1306. */
  1307. #define ADC_EXTERNALTRIGINJECCONV_EDGE_NONE (0x00000000U)
  1308. #define ADC_EXTERNALTRIGINJECCONV_EDGE_RISING ((uint32_t)ADC_CR2_JEXTTRIG)
  1309. /**
  1310. * @}
  1311. */
  1312. /** @defgroup ADCEx_External_trigger_source_Injected External Trigger Source of Injected Group
  1313. * @{
  1314. */
  1315. /* External triggers for injected groups of ADC1 */
  1316. #define ADC_EXTERNALTRIGINJECCONV_T2_CC1 ADC_EXTERNALTRIGINJEC_T2_CC1
  1317. #define ADC_EXTERNALTRIGINJECCONV_T2_TRGO ADC_EXTERNALTRIGINJEC_T2_TRGO
  1318. #define ADC_EXTERNALTRIGINJECCONV_T3_CC4 ADC_EXTERNALTRIGINJEC_T3_CC4
  1319. #define ADC_EXTERNALTRIGINJECCONV_T4_TRGO ADC_EXTERNALTRIGINJEC_T4_TRGO
  1320. #define ADC_EXTERNALTRIGINJECCONV_T19_CC1 ADC_EXTERNALTRIGINJEC_T19_CC1
  1321. #define ADC_EXTERNALTRIGINJECCONV_T19_CC2 ADC_EXTERNALTRIGINJEC_T19_CC2
  1322. #define ADC_EXTERNALTRIGINJECCONV_EXT_IT15 ADC_EXTERNALTRIGINJEC_EXT_IT15
  1323. #define ADC_INJECTED_SOFTWARE_START ADC_JSWSTART
  1324. /**
  1325. * @}
  1326. */
  1327. /** @defgroup ADCEx_analog_watchdog_mode ADC Extended analog watchdog mode
  1328. * @{
  1329. */
  1330. #define ADC_ANALOGWATCHDOG_NONE (0x00000000U)
  1331. #define ADC_ANALOGWATCHDOG_SINGLE_REG ((uint32_t)(ADC_CR1_AWDSGL | ADC_CR1_AWDEN))
  1332. #define ADC_ANALOGWATCHDOG_SINGLE_INJEC ((uint32_t)(ADC_CR1_AWDSGL | ADC_CR1_JAWDEN))
  1333. #define ADC_ANALOGWATCHDOG_SINGLE_REGINJEC ((uint32_t)(ADC_CR1_AWDSGL | ADC_CR1_AWDEN | ADC_CR1_JAWDEN))
  1334. #define ADC_ANALOGWATCHDOG_ALL_REG ((uint32_t) ADC_CR1_AWDEN)
  1335. #define ADC_ANALOGWATCHDOG_ALL_INJEC ((uint32_t) ADC_CR1_JAWDEN)
  1336. #define ADC_ANALOGWATCHDOG_ALL_REGINJEC ((uint32_t)(ADC_CR1_AWDEN | ADC_CR1_JAWDEN))
  1337. /**
  1338. * @}
  1339. */
  1340. /** @defgroup ADC_conversion_group ADC Conversion Group
  1341. * @{
  1342. */
  1343. #define ADC_REGULAR_GROUP ((uint32_t)(ADC_FLAG_EOC))
  1344. #define ADC_INJECTED_GROUP ((uint32_t)(ADC_FLAG_JEOC))
  1345. #define ADC_REGULAR_INJECTED_GROUP ((uint32_t)(ADC_FLAG_EOC | ADC_FLAG_JEOC))
  1346. /**
  1347. * @}
  1348. */
  1349. /** @defgroup ADCEx_Event_type ADC Extended Event Type
  1350. * @{
  1351. */
  1352. #define ADC_AWD_EVENT ((uint32_t)ADC_FLAG_AWD) /*!< ADC Analog watchdog event */
  1353. /**
  1354. * @}
  1355. */
  1356. /** @defgroup ADCEx_interrupts_definition ADC Extended Interrupts Definition
  1357. * @{
  1358. */
  1359. #define ADC_IT_EOC ADC_CR1_EOCIE /*!< ADC End of Regular Conversion interrupt source */
  1360. #define ADC_IT_JEOC ADC_CR1_JEOCIE /*!< ADC End of Injected Conversion interrupt source */
  1361. #define ADC_IT_AWD ADC_CR1_AWDIE /*!< ADC Analog watchdog interrupt source */
  1362. /**
  1363. * @}
  1364. */
  1365. /** @defgroup ADCEx_flags_definition ADC Extended Flags Definition
  1366. * @{
  1367. */
  1368. #define ADC_FLAG_AWD ADC_SR_AWD /*!< ADC Analog watchdog flag */
  1369. #define ADC_FLAG_EOC ADC_SR_EOC /*!< ADC End of Regular conversion flag */
  1370. #define ADC_FLAG_JEOC ADC_SR_JEOC /*!< ADC End of Injected conversion flag */
  1371. #define ADC_FLAG_JSTRT ADC_SR_JSTRT /*!< ADC Injected group start flag */
  1372. #define ADC_FLAG_STRT ADC_SR_STRT /*!< ADC Regular group start flag */
  1373. /**
  1374. * @}
  1375. */
  1376. #endif /* STM32F373xC || STM32F378xx */
  1377. /**
  1378. * @}
  1379. */
  1380. /* Private constants ---------------------------------------------------------*/
  1381. /** @addtogroup ADCEx_Private_Constants ADCEx Private Constants
  1382. * @{
  1383. */
  1384. #if defined(STM32F302xE) || defined(STM32F303xE) || defined(STM32F398xx) || \
  1385. defined(STM32F302xC) || defined(STM32F303xC) || defined(STM32F358xx) || \
  1386. defined(STM32F303x8) || defined(STM32F334x8) || defined(STM32F328xx) || \
  1387. defined(STM32F301x8) || defined(STM32F302x8) || defined(STM32F318xx)
  1388. /** @defgroup ADCEx_Internal_HAL_driver_Ext_trig_src_Regular ADC Extended Internal HAL driver trigger selection for regular group
  1389. * @{
  1390. */
  1391. #if defined(STM32F303xE) || defined(STM32F398xx) || \
  1392. defined(STM32F303xC) || defined(STM32F358xx)
  1393. /* List of external triggers for common groups ADC1&ADC2 and/or ADC3&ADC4: */
  1394. /* (used internally by HAL driver. To not use into HAL structure parameters) */
  1395. /* External triggers of regular group for ADC1 & ADC2 */
  1396. #define ADC1_2_EXTERNALTRIG_T1_CC1 (0x00000000U)
  1397. #define ADC1_2_EXTERNALTRIG_T1_CC2 ((uint32_t)ADC_CFGR_EXTSEL_0)
  1398. #define ADC1_2_EXTERNALTRIG_T1_CC3 ((uint32_t)ADC_CFGR_EXTSEL_1)
  1399. #define ADC1_2_EXTERNALTRIG_T2_CC2 ((uint32_t)(ADC_CFGR_EXTSEL_1 | ADC_CFGR_EXTSEL_0))
  1400. #define ADC1_2_EXTERNALTRIG_T3_TRGO ((uint32_t)ADC_CFGR_EXTSEL_2)
  1401. #define ADC1_2_EXTERNALTRIG_T4_CC4 ((uint32_t)(ADC_CFGR_EXTSEL_2 | ADC_CFGR_EXTSEL_0))
  1402. #define ADC1_2_EXTERNALTRIG_EXT_IT11 ((uint32_t)(ADC_CFGR_EXTSEL_2 | ADC_CFGR_EXTSEL_1))
  1403. #define ADC1_2_EXTERNALTRIG_T8_TRGO ((uint32_t)(ADC_CFGR_EXTSEL_2 | ADC_CFGR_EXTSEL_1 | ADC_CFGR_EXTSEL_0))
  1404. #define ADC1_2_EXTERNALTRIG_T8_TRGO2 ((uint32_t) ADC_CFGR_EXTSEL_3)
  1405. #define ADC1_2_EXTERNALTRIG_T1_TRGO ((uint32_t)(ADC_CFGR_EXTSEL_3 | ADC_CFGR_EXTSEL_0))
  1406. #define ADC1_2_EXTERNALTRIG_T1_TRGO2 ((uint32_t)(ADC_CFGR_EXTSEL_3 | ADC_CFGR_EXTSEL_1))
  1407. #define ADC1_2_EXTERNALTRIG_T2_TRGO ((uint32_t)(ADC_CFGR_EXTSEL_3 | ADC_CFGR_EXTSEL_1 | ADC_CFGR_EXTSEL_0))
  1408. #define ADC1_2_EXTERNALTRIG_T4_TRGO ((uint32_t)(ADC_CFGR_EXTSEL_3 | ADC_CFGR_EXTSEL_2))
  1409. #define ADC1_2_EXTERNALTRIG_T6_TRGO ((uint32_t)(ADC_CFGR_EXTSEL_3 | ADC_CFGR_EXTSEL_2 | ADC_CFGR_EXTSEL_0))
  1410. #define ADC1_2_EXTERNALTRIG_T15_TRGO ((uint32_t)(ADC_CFGR_EXTSEL_3 | ADC_CFGR_EXTSEL_2 | ADC_CFGR_EXTSEL_1))
  1411. #define ADC1_2_EXTERNALTRIG_T3_CC4 ((uint32_t)ADC_CFGR_EXTSEL)
  1412. /* External triggers of regular group for ADC3 & ADC4 */
  1413. #define ADC3_4_EXTERNALTRIG_T3_CC1 (0x00000000U)
  1414. #define ADC3_4_EXTERNALTRIG_T2_CC3 ((uint32_t)ADC_CFGR_EXTSEL_0)
  1415. #define ADC3_4_EXTERNALTRIG_T1_CC3 ((uint32_t)ADC_CFGR_EXTSEL_1)
  1416. #define ADC3_4_EXTERNALTRIG_T8_CC1 ((uint32_t)(ADC_CFGR_EXTSEL_1 | ADC_CFGR_EXTSEL_0))
  1417. #define ADC3_4_EXTERNALTRIG_T8_TRGO ((uint32_t)ADC_CFGR_EXTSEL_2)
  1418. #define ADC3_4_EXTERNALTRIG_EXT_IT2 ((uint32_t)(ADC_CFGR_EXTSEL_2 | ADC_CFGR_EXTSEL_0))
  1419. #define ADC3_4_EXTERNALTRIG_T4_CC1 ((uint32_t)(ADC_CFGR_EXTSEL_2 | ADC_CFGR_EXTSEL_1))
  1420. #define ADC3_4_EXTERNALTRIG_T2_TRGO ((uint32_t)(ADC_CFGR_EXTSEL_2 | ADC_CFGR_EXTSEL_1 | ADC_CFGR_EXTSEL_0))
  1421. #define ADC3_4_EXTERNALTRIG_T8_TRGO2 ((uint32_t)ADC_CFGR_EXTSEL_3)
  1422. #define ADC3_4_EXTERNALTRIG_T1_TRGO ((uint32_t)(ADC_CFGR_EXTSEL_3 | ADC_CFGR_EXTSEL_0))
  1423. #define ADC3_4_EXTERNALTRIG_T1_TRGO2 ((uint32_t)(ADC_CFGR_EXTSEL_3 | ADC_CFGR_EXTSEL_1))
  1424. #define ADC3_4_EXTERNALTRIG_T3_TRGO ((uint32_t)(ADC_CFGR_EXTSEL_3 | ADC_CFGR_EXTSEL_1 | ADC_CFGR_EXTSEL_0))
  1425. #define ADC3_4_EXTERNALTRIG_T4_TRGO ((uint32_t)(ADC_CFGR_EXTSEL_3 | ADC_CFGR_EXTSEL_2))
  1426. #define ADC3_4_EXTERNALTRIG_T7_TRGO ((uint32_t)(ADC_CFGR_EXTSEL_3 | ADC_CFGR_EXTSEL_2 | ADC_CFGR_EXTSEL_0))
  1427. #define ADC3_4_EXTERNALTRIG_T15_TRGO ((uint32_t)(ADC_CFGR_EXTSEL_3 | ADC_CFGR_EXTSEL_2 | ADC_CFGR_EXTSEL_1))
  1428. #define ADC3_4_EXTERNALTRIG_T2_CC1 ((uint32_t)ADC_CFGR_EXTSEL)
  1429. #endif /* STM32F303xE || STM32F398xx || */
  1430. /* STM32F303xC || STM32F358xx */
  1431. #if defined(STM32F302xE) || \
  1432. defined(STM32F302xC)
  1433. /* List of external triggers of common group ADC1&ADC2: */
  1434. /* (used internally by HAL driver. To not use into HAL structure parameters) */
  1435. #define ADC1_2_EXTERNALTRIG_T1_CC1 (0x00000000U)
  1436. #define ADC1_2_EXTERNALTRIG_T1_CC2 ((uint32_t)ADC_CFGR_EXTSEL_0)
  1437. #define ADC1_2_EXTERNALTRIG_T1_CC3 ((uint32_t)ADC_CFGR_EXTSEL_1)
  1438. #define ADC1_2_EXTERNALTRIG_T1_TRGO ((uint32_t)(ADC_CFGR_EXTSEL_3 | ADC_CFGR_EXTSEL_0))
  1439. #define ADC1_2_EXTERNALTRIG_T1_TRGO2 ((uint32_t)(ADC_CFGR_EXTSEL_3 | ADC_CFGR_EXTSEL_1))
  1440. #define ADC1_2_EXTERNALTRIG_T2_CC2 ((uint32_t)(ADC_CFGR_EXTSEL_1 | ADC_CFGR_EXTSEL_0))
  1441. #define ADC1_2_EXTERNALTRIG_T2_TRGO ((uint32_t)(ADC_CFGR_EXTSEL_3 | ADC_CFGR_EXTSEL_1 | ADC_CFGR_EXTSEL_0))
  1442. #define ADC1_2_EXTERNALTRIG_T3_CC4 ((uint32_t)ADC_CFGR_EXTSEL)
  1443. #define ADC1_2_EXTERNALTRIG_T3_TRGO ((uint32_t)ADC_CFGR_EXTSEL_2)
  1444. #define ADC1_2_EXTERNALTRIG_T4_CC4 ((uint32_t)(ADC_CFGR_EXTSEL_2 | ADC_CFGR_EXTSEL_0))
  1445. #define ADC1_2_EXTERNALTRIG_T4_TRGO ((uint32_t)(ADC_CFGR_EXTSEL_3 | ADC_CFGR_EXTSEL_2))
  1446. #define ADC1_2_EXTERNALTRIG_T6_TRGO ((uint32_t)(ADC_CFGR_EXTSEL_3 | ADC_CFGR_EXTSEL_2 | ADC_CFGR_EXTSEL_0))
  1447. #define ADC1_2_EXTERNALTRIG_T15_TRGO ((uint32_t)(ADC_CFGR_EXTSEL_3 | ADC_CFGR_EXTSEL_2 | ADC_CFGR_EXTSEL_1))
  1448. #define ADC1_2_EXTERNALTRIG_EXT_IT11 ((uint32_t)(ADC_CFGR_EXTSEL_2 | ADC_CFGR_EXTSEL_1))
  1449. #endif /* STM32F302xE || */
  1450. /* STM32F302xC */
  1451. #if defined(STM32F303x8) || defined(STM32F328xx)
  1452. /* List of external triggers of common group ADC1&ADC2: */
  1453. /* (used internally by HAL driver. To not use into HAL structure parameters) */
  1454. #define ADC1_2_EXTERNALTRIG_T1_CC1 (0x00000000U)
  1455. #define ADC1_2_EXTERNALTRIG_T1_CC2 ((uint32_t)ADC_CFGR_EXTSEL_0)
  1456. #define ADC1_2_EXTERNALTRIG_T1_CC3 ((uint32_t)ADC_CFGR_EXTSEL_1)
  1457. #define ADC1_2_EXTERNALTRIG_T2_CC2 ((uint32_t)(ADC_CFGR_EXTSEL_1 | ADC_CFGR_EXTSEL_0))
  1458. #define ADC1_2_EXTERNALTRIG_T3_TRGO ((uint32_t)ADC_CFGR_EXTSEL_2)
  1459. #define ADC1_2_EXTERNALTRIG_T4_CC4 ((uint32_t)(ADC_CFGR_EXTSEL_2 | ADC_CFGR_EXTSEL_0))
  1460. #define ADC1_2_EXTERNALTRIG_EXT_IT11 ((uint32_t)(ADC_CFGR_EXTSEL_2 | ADC_CFGR_EXTSEL_1))
  1461. #define ADC1_2_EXTERNALTRIG_T8_TRGO ((uint32_t)(ADC_CFGR_EXTSEL_2 | ADC_CFGR_EXTSEL_1 | ADC_CFGR_EXTSEL_0))
  1462. #define ADC1_2_EXTERNALTRIG_T8_TRGO2 ((uint32_t) ADC_CFGR_EXTSEL_3)
  1463. #define ADC1_2_EXTERNALTRIG_T1_TRGO ((uint32_t)(ADC_CFGR_EXTSEL_3 | ADC_CFGR_EXTSEL_0))
  1464. #define ADC1_2_EXTERNALTRIG_T1_TRGO2 ((uint32_t)(ADC_CFGR_EXTSEL_3 | ADC_CFGR_EXTSEL_1))
  1465. #define ADC1_2_EXTERNALTRIG_T2_TRGO ((uint32_t)(ADC_CFGR_EXTSEL_3 | ADC_CFGR_EXTSEL_1 | ADC_CFGR_EXTSEL_0))
  1466. #define ADC1_2_EXTERNALTRIG_T4_TRGO ((uint32_t)(ADC_CFGR_EXTSEL_3 | ADC_CFGR_EXTSEL_2))
  1467. #define ADC1_2_EXTERNALTRIG_T6_TRGO ((uint32_t)(ADC_CFGR_EXTSEL_3 | ADC_CFGR_EXTSEL_2 | ADC_CFGR_EXTSEL_0))
  1468. #define ADC1_2_EXTERNALTRIG_T15_TRGO ((uint32_t)(ADC_CFGR_EXTSEL_3 | ADC_CFGR_EXTSEL_2 | ADC_CFGR_EXTSEL_1))
  1469. #define ADC1_2_EXTERNALTRIG_T3_CC4 ((uint32_t)ADC_CFGR_EXTSEL)
  1470. #endif /* STM32F303x8 || STM32F328xx */
  1471. #if defined(STM32F334x8)
  1472. /* List of external triggers of common group ADC1&ADC2: */
  1473. /* (used internally by HAL driver. To not use into HAL structure parameters) */
  1474. #define ADC1_2_EXTERNALTRIG_T1_CC1 (0x00000000U)
  1475. #define ADC1_2_EXTERNALTRIG_T1_CC2 ((uint32_t)ADC_CFGR_EXTSEL_0)
  1476. #define ADC1_2_EXTERNALTRIG_T1_CC3 ((uint32_t)ADC_CFGR_EXTSEL_1)
  1477. #define ADC1_2_EXTERNALTRIG_T2_CC2 ((uint32_t)(ADC_CFGR_EXTSEL_1 | ADC_CFGR_EXTSEL_0))
  1478. #define ADC1_2_EXTERNALTRIG_T3_TRGO ((uint32_t)ADC_CFGR_EXTSEL_2)
  1479. #define ADC1_2_EXTERNALTRIG_EXT_IT11 ((uint32_t)(ADC_CFGR_EXTSEL_2 | ADC_CFGR_EXTSEL_1))
  1480. #define ADC1_2_EXTERNALTRIG_HRTIM_TRG1 ((uint32_t)(ADC_CFGR_EXTSEL_2 | ADC_CFGR_EXTSEL_1 | ADC_CFGR_EXTSEL_0))
  1481. #define ADC1_2_EXTERNALTRIG_HRTIM_TRG3 ((uint32_t) ADC_CFGR_EXTSEL_3)
  1482. #define ADC1_2_EXTERNALTRIG_T1_TRGO ((uint32_t)(ADC_CFGR_EXTSEL_3 | ADC_CFGR_EXTSEL_0))
  1483. #define ADC1_2_EXTERNALTRIG_T1_TRGO2 ((uint32_t)(ADC_CFGR_EXTSEL_3 | ADC_CFGR_EXTSEL_1))
  1484. #define ADC1_2_EXTERNALTRIG_T2_TRGO ((uint32_t)(ADC_CFGR_EXTSEL_3 | ADC_CFGR_EXTSEL_1 | ADC_CFGR_EXTSEL_0))
  1485. #define ADC1_2_EXTERNALTRIG_T6_TRGO ((uint32_t)(ADC_CFGR_EXTSEL_3 | ADC_CFGR_EXTSEL_2 | ADC_CFGR_EXTSEL_0))
  1486. #define ADC1_2_EXTERNALTRIG_T15_TRGO ((uint32_t)(ADC_CFGR_EXTSEL_3 | ADC_CFGR_EXTSEL_2 | ADC_CFGR_EXTSEL_1))
  1487. #define ADC1_2_EXTERNALTRIG_T3_CC4 ((uint32_t)ADC_CFGR_EXTSEL)
  1488. #endif /* STM32F334x8 */
  1489. #if defined(STM32F301x8) || defined(STM32F302x8) || defined(STM32F318xx)
  1490. /* List of external triggers of regular group for ADC1: */
  1491. /* (used internally by HAL driver. To not use into HAL structure parameters) */
  1492. #define ADC1_EXTERNALTRIG_T1_CC1 (0x00000000U)
  1493. #define ADC1_EXTERNALTRIG_T1_CC2 ((uint32_t)ADC_CFGR_EXTSEL_0)
  1494. #define ADC1_EXTERNALTRIG_T1_CC3 ((uint32_t)ADC_CFGR_EXTSEL_1)
  1495. #define ADC1_EXTERNALTRIG_T2_CC2 ((uint32_t)(ADC_CFGR_EXTSEL_1 | ADC_CFGR_EXTSEL_0))
  1496. #define ADC1_EXTERNALTRIG_EXT_IT11 ((uint32_t)(ADC_CFGR_EXTSEL_2 | ADC_CFGR_EXTSEL_1))
  1497. #define ADC1_EXTERNALTRIG_T1_TRGO ((uint32_t)(ADC_CFGR_EXTSEL_3 | ADC_CFGR_EXTSEL_0))
  1498. #define ADC1_EXTERNALTRIG_T1_TRGO2 ((uint32_t)(ADC_CFGR_EXTSEL_3 | ADC_CFGR_EXTSEL_1))
  1499. #define ADC1_EXTERNALTRIG_T2_TRGO ((uint32_t)(ADC_CFGR_EXTSEL_3 | ADC_CFGR_EXTSEL_1 | ADC_CFGR_EXTSEL_0))
  1500. #define ADC1_EXTERNALTRIG_T6_TRGO ((uint32_t)(ADC_CFGR_EXTSEL_3 | ADC_CFGR_EXTSEL_2 | ADC_CFGR_EXTSEL_0))
  1501. #define ADC1_EXTERNALTRIG_T15_TRGO ((uint32_t)(ADC_CFGR_EXTSEL_3 | ADC_CFGR_EXTSEL_2 | ADC_CFGR_EXTSEL_1))
  1502. #define ADC_SOFTWARE_START (0x00000001U)
  1503. #endif /* STM32F301x8 || STM32F302x8 || STM32F318xx */
  1504. /**
  1505. * @}
  1506. */
  1507. /** @defgroup ADCEx_Internal_HAL_driver_Ext_trig_src_Injected ADC Extended Internal HAL driver trigger selection for injected group
  1508. * @{
  1509. */
  1510. #if defined(STM32F303xE) || defined(STM32F398xx) || \
  1511. defined(STM32F303xC) || defined(STM32F358xx)
  1512. /* List of external triggers sorted of groups ADC1&ADC2 and/or ADC3&ADC4: */
  1513. /* (used internally by HAL driver. To not use into HAL structure parameters) */
  1514. /* External triggers for injected groups of ADC1 & ADC2 */
  1515. #define ADC1_2_EXTERNALTRIGINJEC_T1_TRGO (0x00000000U)
  1516. #define ADC1_2_EXTERNALTRIGINJEC_T1_CC4 ((uint32_t)ADC_JSQR_JEXTSEL_0)
  1517. #define ADC1_2_EXTERNALTRIGINJEC_T2_TRGO ((uint32_t)ADC_JSQR_JEXTSEL_1)
  1518. #define ADC1_2_EXTERNALTRIGINJEC_T2_CC1 ((uint32_t)(ADC_JSQR_JEXTSEL_1 | ADC_JSQR_JEXTSEL_0))
  1519. #define ADC1_2_EXTERNALTRIGINJEC_T3_CC4 ((uint32_t)ADC_JSQR_JEXTSEL_2)
  1520. #define ADC1_2_EXTERNALTRIGINJEC_T4_TRGO ((uint32_t)(ADC_JSQR_JEXTSEL_2 | ADC_JSQR_JEXTSEL_0))
  1521. #define ADC1_2_EXTERNALTRIGINJEC_EXT_IT15 ((uint32_t)(ADC_JSQR_JEXTSEL_2 | ADC_JSQR_JEXTSEL_1))
  1522. #define ADC1_2_EXTERNALTRIGINJEC_T8_CC4 ((uint32_t)(ADC_JSQR_JEXTSEL_2 | ADC_JSQR_JEXTSEL_1 | ADC_JSQR_JEXTSEL_0))
  1523. #define ADC1_2_EXTERNALTRIGINJEC_T1_TRGO2 ((uint32_t)ADC_JSQR_JEXTSEL_3)
  1524. #define ADC1_2_EXTERNALTRIGINJEC_T8_TRGO ((uint32_t)(ADC_JSQR_JEXTSEL_3 | ADC_JSQR_JEXTSEL_0))
  1525. #define ADC1_2_EXTERNALTRIGINJEC_T8_TRGO2 ((uint32_t)(ADC_JSQR_JEXTSEL_3 | ADC_JSQR_JEXTSEL_1))
  1526. #define ADC1_2_EXTERNALTRIGINJEC_T3_CC3 ((uint32_t)(ADC_JSQR_JEXTSEL_3 | ADC_JSQR_JEXTSEL_1 | ADC_JSQR_JEXTSEL_0))
  1527. #define ADC1_2_EXTERNALTRIGINJEC_T3_TRGO ((uint32_t)(ADC_JSQR_JEXTSEL_3 | ADC_JSQR_JEXTSEL_2))
  1528. #define ADC1_2_EXTERNALTRIGINJEC_T3_CC1 ((uint32_t)(ADC_JSQR_JEXTSEL_3 | ADC_JSQR_JEXTSEL_2 | ADC_JSQR_JEXTSEL_0))
  1529. #define ADC1_2_EXTERNALTRIGINJEC_T6_TRGO ((uint32_t)(ADC_JSQR_JEXTSEL_3 | ADC_JSQR_JEXTSEL_2 | ADC_JSQR_JEXTSEL_1))
  1530. #define ADC1_2_EXTERNALTRIGINJEC_T15_TRGO ((uint32_t)ADC_JSQR_JEXTSEL)
  1531. /* External triggers for injected groups of ADC3 & ADC4 */
  1532. /* Note: External triggers JEXT2 and JEXT5 are the same (TIM4_CC3 event). */
  1533. /* JEXT2 is the main trigger, JEXT5 could be redirected to another */
  1534. /* in future devices. */
  1535. /* However, this channel is implemented with a SW offset of 0x10000 for */
  1536. /* differentiation between similar triggers of common groups ADC1&ADC2, */
  1537. /* ADC3&ADC4 (Differentiation processed into macro */
  1538. /* ADC_JSQR_JEXTSEL_SET) */
  1539. #define ADC3_4_EXTERNALTRIGINJEC_T1_TRGO (0x00000000U)
  1540. #define ADC3_4_EXTERNALTRIGINJEC_T1_CC4 ((uint32_t)ADC_JSQR_JEXTSEL_0)
  1541. #define ADC3_4_EXTERNALTRIGINJEC_T4_CC3 ((uint32_t)ADC_JSQR_JEXTSEL_1 | 0x10000U)
  1542. #define ADC3_4_EXTERNALTRIGINJEC_T8_CC2 ((uint32_t)(ADC_JSQR_JEXTSEL_1 | ADC_JSQR_JEXTSEL_0))
  1543. #define ADC3_4_EXTERNALTRIGINJEC_T8_CC4 ((uint32_t)ADC_JSQR_JEXTSEL_2)
  1544. #if defined(STM32F303xE) || defined(STM32F398xx)
  1545. #define ADC3_4_EXTERNALTRIGINJEC_T20_TRGO ((uint32_t)(ADC_JSQR_JEXTSEL_2 | ADC_JSQR_JEXTSEL_0))
  1546. #endif /* STM32F303xE || STM32F398xx */
  1547. #define ADC3_4_EXTERNALTRIGINJEC_T4_CC4 ((uint32_t)(ADC_JSQR_JEXTSEL_2 | ADC_JSQR_JEXTSEL_1))
  1548. #define ADC3_4_EXTERNALTRIGINJEC_T4_TRGO ((uint32_t)(ADC_JSQR_JEXTSEL_2 | ADC_JSQR_JEXTSEL_1 | ADC_JSQR_JEXTSEL_0))
  1549. #define ADC3_4_EXTERNALTRIGINJEC_T1_TRGO2 ((uint32_t)ADC_JSQR_JEXTSEL_3)
  1550. #define ADC3_4_EXTERNALTRIGINJEC_T8_TRGO ((uint32_t)(ADC_JSQR_JEXTSEL_3 | ADC_JSQR_JEXTSEL_0))
  1551. #define ADC3_4_EXTERNALTRIGINJEC_T8_TRGO2 ((uint32_t)(ADC_JSQR_JEXTSEL_3 | ADC_JSQR_JEXTSEL_1))
  1552. #define ADC3_4_EXTERNALTRIGINJEC_T1_CC3 ((uint32_t)(ADC_JSQR_JEXTSEL_3 | ADC_JSQR_JEXTSEL_1 | ADC_JSQR_JEXTSEL_0))
  1553. #define ADC3_4_EXTERNALTRIGINJEC_T3_TRGO ((uint32_t)(ADC_JSQR_JEXTSEL_3 | ADC_JSQR_JEXTSEL_2))
  1554. #define ADC3_4_EXTERNALTRIGINJEC_T2_TRGO ((uint32_t)(ADC_JSQR_JEXTSEL_3 | ADC_JSQR_JEXTSEL_2 | ADC_JSQR_JEXTSEL_0))
  1555. #define ADC3_4_EXTERNALTRIGINJEC_T7_TRGO ((uint32_t)(ADC_JSQR_JEXTSEL_3 | ADC_JSQR_JEXTSEL_2 | ADC_JSQR_JEXTSEL_1))
  1556. #define ADC3_4_EXTERNALTRIGINJEC_T15_TRGO ((uint32_t)ADC_JSQR_JEXTSEL)
  1557. #endif /* STM32F303xE || STM32F398xx || */
  1558. /* STM32F303xC || STM32F358xx */
  1559. #if defined(STM32F302xE) || \
  1560. defined(STM32F302xC)
  1561. /* List of external triggers of group ADC1&ADC2: */
  1562. /* (used internally by HAL driver. To not use into HAL structure parameters) */
  1563. #define ADC1_2_EXTERNALTRIGINJEC_T1_TRGO (0x00000000U)
  1564. #define ADC1_2_EXTERNALTRIGINJEC_T1_CC4 ((uint32_t)ADC_JSQR_JEXTSEL_0)
  1565. #define ADC1_2_EXTERNALTRIGINJEC_T2_TRGO ((uint32_t)ADC_JSQR_JEXTSEL_1)
  1566. #define ADC1_2_EXTERNALTRIGINJEC_T2_CC1 ((uint32_t)(ADC_JSQR_JEXTSEL_1 | ADC_JSQR_JEXTSEL_0))
  1567. #define ADC1_2_EXTERNALTRIGINJEC_T3_CC4 ((uint32_t)ADC_JSQR_JEXTSEL_2)
  1568. #define ADC1_2_EXTERNALTRIGINJEC_T4_TRGO ((uint32_t)(ADC_JSQR_JEXTSEL_2 | ADC_JSQR_JEXTSEL_0))
  1569. #define ADC1_2_EXTERNALTRIGINJEC_EXT_IT15 ((uint32_t)(ADC_JSQR_JEXTSEL_2 | ADC_JSQR_JEXTSEL_1))
  1570. #define ADC1_2_EXTERNALTRIGINJEC_T1_TRGO2 ((uint32_t)ADC_JSQR_JEXTSEL_3)
  1571. #define ADC1_2_EXTERNALTRIGINJEC_T3_CC3 ((uint32_t)(ADC_JSQR_JEXTSEL_3 | ADC_JSQR_JEXTSEL_1 | ADC_JSQR_JEXTSEL_0))
  1572. #define ADC1_2_EXTERNALTRIGINJEC_T3_TRGO ((uint32_t)(ADC_JSQR_JEXTSEL_3 | ADC_JSQR_JEXTSEL_2))
  1573. #define ADC1_2_EXTERNALTRIGINJEC_T3_CC1 ((uint32_t)(ADC_JSQR_JEXTSEL_3 | ADC_JSQR_JEXTSEL_2 | ADC_JSQR_JEXTSEL_0))
  1574. #define ADC1_2_EXTERNALTRIGINJEC_T6_TRGO ((uint32_t)(ADC_JSQR_JEXTSEL_3 | ADC_JSQR_JEXTSEL_2 | ADC_JSQR_JEXTSEL_1))
  1575. #define ADC1_2_EXTERNALTRIGINJEC_T15_TRGO ((uint32_t)ADC_JSQR_JEXTSEL)
  1576. #endif /* STM32F302xE || */
  1577. /* STM32F302xC */
  1578. #if defined(STM32F303x8) || defined(STM32F328xx)
  1579. /* List of external triggers of group ADC1&ADC2: */
  1580. /* (used internally by HAL driver. To not use into HAL structure parameters) */
  1581. #define ADC1_2_EXTERNALTRIGINJEC_T1_TRGO (0x00000000U)
  1582. #define ADC1_2_EXTERNALTRIGINJEC_T1_CC4 ((uint32_t)ADC_JSQR_JEXTSEL_0)
  1583. #define ADC1_2_EXTERNALTRIGINJEC_T2_TRGO ((uint32_t)ADC_JSQR_JEXTSEL_1)
  1584. #define ADC1_2_EXTERNALTRIGINJEC_T2_CC1 ((uint32_t)(ADC_JSQR_JEXTSEL_1 | ADC_JSQR_JEXTSEL_0))
  1585. #define ADC1_2_EXTERNALTRIGINJEC_T3_CC4 ((uint32_t)ADC_JSQR_JEXTSEL_2)
  1586. #define ADC1_2_EXTERNALTRIGINJEC_T4_TRGO ((uint32_t)(ADC_JSQR_JEXTSEL_2 | ADC_JSQR_JEXTSEL_0))
  1587. #define ADC1_2_EXTERNALTRIGINJEC_EXT_IT15 ((uint32_t)(ADC_JSQR_JEXTSEL_2 | ADC_JSQR_JEXTSEL_1))
  1588. #define ADC1_2_EXTERNALTRIGINJEC_T8_CC4 ((uint32_t)(ADC_JSQR_JEXTSEL_2 | ADC_JSQR_JEXTSEL_1 | ADC_JSQR_JEXTSEL_0))
  1589. #define ADC1_2_EXTERNALTRIGINJEC_T1_TRGO2 ((uint32_t)ADC_JSQR_JEXTSEL_3)
  1590. #define ADC1_2_EXTERNALTRIGINJEC_T8_TRGO ((uint32_t)(ADC_JSQR_JEXTSEL_3 | ADC_JSQR_JEXTSEL_0))
  1591. #define ADC1_2_EXTERNALTRIGINJEC_T8_TRGO2 ((uint32_t)(ADC_JSQR_JEXTSEL_3 | ADC_JSQR_JEXTSEL_1))
  1592. #define ADC1_2_EXTERNALTRIGINJEC_T3_CC3 ((uint32_t)(ADC_JSQR_JEXTSEL_3 | ADC_JSQR_JEXTSEL_1 | ADC_JSQR_JEXTSEL_0))
  1593. #define ADC1_2_EXTERNALTRIGINJEC_T3_TRGO ((uint32_t)(ADC_JSQR_JEXTSEL_3 | ADC_JSQR_JEXTSEL_2))
  1594. #define ADC1_2_EXTERNALTRIGINJEC_T3_CC1 ((uint32_t)(ADC_JSQR_JEXTSEL_3 | ADC_JSQR_JEXTSEL_2 | ADC_JSQR_JEXTSEL_0))
  1595. #define ADC1_2_EXTERNALTRIGINJEC_T6_TRGO ((uint32_t)(ADC_JSQR_JEXTSEL_3 | ADC_JSQR_JEXTSEL_2 | ADC_JSQR_JEXTSEL_1))
  1596. #define ADC1_2_EXTERNALTRIGINJEC_T15_TRGO ((uint32_t)ADC_JSQR_JEXTSEL)
  1597. #endif /* STM32F303x8 || STM32F328xx */
  1598. #if defined(STM32F334x8)
  1599. /* List of external triggers of group ADC1&ADC2: */
  1600. /* (used internally by HAL driver. To not use into HAL structure parameters) */
  1601. #define ADC1_2_EXTERNALTRIGINJEC_T1_TRGO (0x00000000U)
  1602. #define ADC1_2_EXTERNALTRIGINJEC_T1_CC4 ((uint32_t)ADC_JSQR_JEXTSEL_0)
  1603. #define ADC1_2_EXTERNALTRIGINJEC_T2_TRGO ((uint32_t)ADC_JSQR_JEXTSEL_1)
  1604. #define ADC1_2_EXTERNALTRIGINJEC_T2_CC1 ((uint32_t)(ADC_JSQR_JEXTSEL_1 | ADC_JSQR_JEXTSEL_0))
  1605. #define ADC1_2_EXTERNALTRIGINJEC_T3_CC4 ((uint32_t)ADC_JSQR_JEXTSEL_2)
  1606. #define ADC1_2_EXTERNALTRIGINJEC_EXT_IT15 ((uint32_t)(ADC_JSQR_JEXTSEL_2 | ADC_JSQR_JEXTSEL_1))
  1607. #define ADC1_2_EXTERNALTRIGINJEC_T1_TRGO2 ((uint32_t)ADC_JSQR_JEXTSEL_3)
  1608. #define ADC1_2_EXTERNALTRIGINJEC_HRTIM_TRG2 ((uint32_t)(ADC_JSQR_JEXTSEL_3 | ADC_JSQR_JEXTSEL_0))
  1609. #define ADC1_2_EXTERNALTRIGINJEC_HRTIM_TRG4 ((uint32_t)(ADC_JSQR_JEXTSEL_3 | ADC_JSQR_JEXTSEL_1))
  1610. #define ADC1_2_EXTERNALTRIGINJEC_T3_CC3 ((uint32_t)(ADC_JSQR_JEXTSEL_3 | ADC_JSQR_JEXTSEL_1 | ADC_JSQR_JEXTSEL_0))
  1611. #define ADC1_2_EXTERNALTRIGINJEC_T3_TRGO ((uint32_t)(ADC_JSQR_JEXTSEL_3 | ADC_JSQR_JEXTSEL_2))
  1612. #define ADC1_2_EXTERNALTRIGINJEC_T3_CC1 ((uint32_t)(ADC_JSQR_JEXTSEL_3 | ADC_JSQR_JEXTSEL_2 | ADC_JSQR_JEXTSEL_0))
  1613. #define ADC1_2_EXTERNALTRIGINJEC_T6_TRGO ((uint32_t)(ADC_JSQR_JEXTSEL_3 | ADC_JSQR_JEXTSEL_2 | ADC_JSQR_JEXTSEL_1))
  1614. #define ADC1_2_EXTERNALTRIGINJEC_T15_TRGO ((uint32_t)ADC_JSQR_JEXTSEL)
  1615. #endif /* STM32F334x8 */
  1616. #if defined(STM32F301x8) || defined(STM32F302x8) || defined(STM32F318xx)
  1617. /* List of external triggers of injected group for ADC1: */
  1618. /* (used internally by HAL driver. To not use into HAL structure parameters) */
  1619. #define ADC1_EXTERNALTRIGINJEC_T1_TRGO (0x00000000U)
  1620. #define ADC1_EXTERNALTRIGINJEC_T1_CC4 ((uint32_t)ADC_JSQR_JEXTSEL_0)
  1621. #define ADC1_EXTERNALTRIGINJEC_T2_TRGO ((uint32_t)ADC_JSQR_JEXTSEL_1)
  1622. #define ADC1_EXTERNALTRIGINJEC_T2_CC1 ((uint32_t)(ADC_JSQR_JEXTSEL_1 | ADC_JSQR_JEXTSEL_0))
  1623. #define ADC1_EXTERNALTRIGINJEC_EXT_IT15 ((uint32_t)(ADC_JSQR_JEXTSEL_2 | ADC_JSQR_JEXTSEL_1))
  1624. #define ADC1_EXTERNALTRIGINJEC_T1_TRGO2 ((uint32_t)ADC_JSQR_JEXTSEL_3)
  1625. #define ADC1_EXTERNALTRIGINJEC_T6_TRGO ((uint32_t)(ADC_JSQR_JEXTSEL_3 | ADC_JSQR_JEXTSEL_2 | ADC_JSQR_JEXTSEL_1))
  1626. #define ADC1_EXTERNALTRIGINJEC_T15_TRGO ((uint32_t)ADC_JSQR_JEXTSEL)
  1627. #endif /* STM32F301x8 || STM32F302x8 || STM32F318xx */
  1628. /**
  1629. * @}
  1630. */
  1631. #define ADC_FLAG_ALL (ADC_FLAG_RDY | ADC_FLAG_EOSMP | ADC_FLAG_EOC | ADC_FLAG_EOS | \
  1632. ADC_FLAG_JEOC | ADC_FLAG_JEOS | ADC_FLAG_OVR | ADC_FLAG_AWD1 | \
  1633. ADC_FLAG_AWD2 | ADC_FLAG_AWD3 | ADC_FLAG_JQOVF)
  1634. /* Combination of all post-conversion flags bits: EOC/EOS, JEOC/JEOS, OVR, AWDx */
  1635. #define ADC_FLAG_POSTCONV_ALL (ADC_FLAG_EOC | ADC_FLAG_EOS | ADC_FLAG_JEOC | ADC_FLAG_JEOS | \
  1636. ADC_FLAG_OVR | ADC_FLAG_AWD1 | ADC_FLAG_AWD2 | ADC_FLAG_AWD3 | \
  1637. ADC_FLAG_JQOVF)
  1638. #endif /* STM32F302xE || STM32F303xE || STM32F398xx || */
  1639. /* STM32F302xC || STM32F303xC || STM32F358xx || */
  1640. /* STM32F303x8 || STM32F334x8 || STM32F328xx || */
  1641. /* STM32F301x8 || STM32F302x8 || STM32F318xx */
  1642. #if defined(STM32F373xC) || defined(STM32F378xx)
  1643. /** @defgroup ADCEx_Internal_HAL_driver_Ext_trig_src_Regular ADC Extended Internal HAL driver trigger selection for regular group
  1644. * @{
  1645. */
  1646. /* List of external triggers of regular group for ADC1: */
  1647. /* (used internally by HAL driver. To not use into HAL structure parameters) */
  1648. /* External triggers of regular group for ADC1 */
  1649. #define ADC_EXTERNALTRIG_T19_TRGO (0x00000000U)
  1650. #define ADC_EXTERNALTRIG_T19_CC3 ((uint32_t)ADC_CR2_EXTSEL_0)
  1651. #define ADC_EXTERNALTRIG_T19_CC4 ((uint32_t)ADC_CR2_EXTSEL_1)
  1652. #define ADC_EXTERNALTRIG_T2_CC2 ((uint32_t)(ADC_CR2_EXTSEL_1 | ADC_CR2_EXTSEL_0))
  1653. #define ADC_EXTERNALTRIG_T3_TRGO ((uint32_t)ADC_CR2_EXTSEL_2)
  1654. #define ADC_EXTERNALTRIG_T4_CC4 ((uint32_t)(ADC_CR2_EXTSEL_2 | ADC_CR2_EXTSEL_0))
  1655. #define ADC_EXTERNALTRIG_EXT_IT11 ((uint32_t)(ADC_CR2_EXTSEL_2 | ADC_CR2_EXTSEL_1))
  1656. #define ADC_SWSTART ((uint32_t)(ADC_CR2_EXTSEL_2 | ADC_CR2_EXTSEL_1 | ADC_CR2_EXTSEL_0))
  1657. /**
  1658. * @}
  1659. */
  1660. /** @defgroup ADCEx_Internal_HAL_driver_Ext_trig_src_Injected ADC Extended Internal HAL driver trigger selection for injected group
  1661. * @{
  1662. */
  1663. /* List of external triggers of injected group for ADC1: */
  1664. /* (used internally by HAL driver. To not use into HAL structure parameters) */
  1665. /* External triggers of injected group for ADC1 */
  1666. #define ADC_EXTERNALTRIGINJEC_T19_CC1 ( 0x00000000U)
  1667. #define ADC_EXTERNALTRIGINJEC_T19_CC2 ((uint32_t) ADC_CR2_JEXTSEL_0)
  1668. #define ADC_EXTERNALTRIGINJEC_T2_TRGO ((uint32_t) ADC_CR2_JEXTSEL_1)
  1669. #define ADC_EXTERNALTRIGINJEC_T2_CC1 ((uint32_t)(ADC_CR2_JEXTSEL_1 | ADC_CR2_JEXTSEL_0))
  1670. #define ADC_EXTERNALTRIGINJEC_T3_CC4 ((uint32_t) ADC_CR2_JEXTSEL_2)
  1671. #define ADC_EXTERNALTRIGINJEC_T4_TRGO ((uint32_t)(ADC_CR2_JEXTSEL_2 | ADC_CR2_JEXTSEL_0))
  1672. #define ADC_EXTERNALTRIGINJEC_EXT_IT15 ((uint32_t)(ADC_CR2_JEXTSEL_2 | ADC_CR2_JEXTSEL_1))
  1673. #define ADC_JSWSTART ((uint32_t)(ADC_CR2_JEXTSEL_2 | ADC_CR2_JEXTSEL_1 | ADC_CR2_JEXTSEL_0))
  1674. /**
  1675. * @}
  1676. */
  1677. /** @defgroup ADCEx_sampling_times_all_channels ADC Extended Sampling Times All Channels
  1678. * @{
  1679. */
  1680. #define ADC_SAMPLETIME_ALLCHANNELS_SMPR2BIT2 \
  1681. (ADC_SMPR2_SMP9_2 | ADC_SMPR2_SMP8_2 | ADC_SMPR2_SMP7_2 | ADC_SMPR2_SMP6_2 | \
  1682. ADC_SMPR2_SMP5_2 | ADC_SMPR2_SMP4_2 | ADC_SMPR2_SMP3_2 | ADC_SMPR2_SMP2_2 | \
  1683. ADC_SMPR2_SMP1_2 | ADC_SMPR2_SMP0_2)
  1684. #define ADC_SAMPLETIME_ALLCHANNELS_SMPR1BIT2 \
  1685. (ADC_SMPR1_SMP17_2 | ADC_SMPR1_SMP16_2 | ADC_SMPR1_SMP15_2 | ADC_SMPR1_SMP14_2 | \
  1686. ADC_SMPR1_SMP13_2 | ADC_SMPR1_SMP12_2 | ADC_SMPR1_SMP11_2 | ADC_SMPR1_SMP10_2 )
  1687. #define ADC_SAMPLETIME_ALLCHANNELS_SMPR2BIT1 \
  1688. (ADC_SMPR2_SMP9_1 | ADC_SMPR2_SMP8_1 | ADC_SMPR2_SMP7_1 | ADC_SMPR2_SMP6_1 | \
  1689. ADC_SMPR2_SMP5_1 | ADC_SMPR2_SMP4_1 | ADC_SMPR2_SMP3_1 | ADC_SMPR2_SMP2_1 | \
  1690. ADC_SMPR2_SMP1_1 | ADC_SMPR2_SMP0_1)
  1691. #define ADC_SAMPLETIME_ALLCHANNELS_SMPR1BIT1 \
  1692. (ADC_SMPR1_SMP17_1 | ADC_SMPR1_SMP16_1 | ADC_SMPR1_SMP15_1 | ADC_SMPR1_SMP14_1 | \
  1693. ADC_SMPR1_SMP13_1 | ADC_SMPR1_SMP12_1 | ADC_SMPR1_SMP11_1 | ADC_SMPR1_SMP10_1 )
  1694. #define ADC_SAMPLETIME_ALLCHANNELS_SMPR2BIT0 \
  1695. (ADC_SMPR2_SMP9_0 | ADC_SMPR2_SMP8_0 | ADC_SMPR2_SMP7_0 | ADC_SMPR2_SMP6_0 | \
  1696. ADC_SMPR2_SMP5_0 | ADC_SMPR2_SMP4_0 | ADC_SMPR2_SMP3_0 | ADC_SMPR2_SMP2_0 | \
  1697. ADC_SMPR2_SMP1_0 | ADC_SMPR2_SMP0_0)
  1698. #define ADC_SAMPLETIME_ALLCHANNELS_SMPR1BIT0 \
  1699. (ADC_SMPR1_SMP17_0 | ADC_SMPR1_SMP16_0 | ADC_SMPR1_SMP15_0 | ADC_SMPR1_SMP14_0 | \
  1700. ADC_SMPR1_SMP13_0 | ADC_SMPR1_SMP12_0 | ADC_SMPR1_SMP11_0 | ADC_SMPR1_SMP10_0 )
  1701. #define ADC_SAMPLETIME_1CYCLE5_SMPR2ALLCHANNELS (0x00000000U)
  1702. #define ADC_SAMPLETIME_7CYCLES5_SMPR2ALLCHANNELS (ADC_SAMPLETIME_ALLCHANNELS_SMPR2BIT0)
  1703. #define ADC_SAMPLETIME_13CYCLES5_SMPR2ALLCHANNELS (ADC_SAMPLETIME_ALLCHANNELS_SMPR2BIT1)
  1704. #define ADC_SAMPLETIME_28CYCLES5_SMPR2ALLCHANNELS (ADC_SAMPLETIME_ALLCHANNELS_SMPR2BIT1 | ADC_SAMPLETIME_ALLCHANNELS_SMPR2BIT0)
  1705. #define ADC_SAMPLETIME_41CYCLES5_SMPR2ALLCHANNELS (ADC_SAMPLETIME_ALLCHANNELS_SMPR2BIT2)
  1706. #define ADC_SAMPLETIME_55CYCLES5_SMPR2ALLCHANNELS (ADC_SAMPLETIME_ALLCHANNELS_SMPR2BIT2 | ADC_SAMPLETIME_ALLCHANNELS_SMPR2BIT0)
  1707. #define ADC_SAMPLETIME_71CYCLES5_SMPR2ALLCHANNELS (ADC_SAMPLETIME_ALLCHANNELS_SMPR2BIT2 | ADC_SAMPLETIME_ALLCHANNELS_SMPR2BIT1)
  1708. #define ADC_SAMPLETIME_239CYCLES5_SMPR2ALLCHANNELS (ADC_SAMPLETIME_ALLCHANNELS_SMPR2BIT2 | ADC_SAMPLETIME_ALLCHANNELS_SMPR2BIT1 | ADC_SAMPLETIME_ALLCHANNELS_SMPR2BIT0)
  1709. #define ADC_SAMPLETIME_1CYCLE5_SMPR1ALLCHANNELS (0x00000000U)
  1710. #define ADC_SAMPLETIME_7CYCLES5_SMPR1ALLCHANNELS (ADC_SAMPLETIME_ALLCHANNELS_SMPR1BIT0)
  1711. #define ADC_SAMPLETIME_13CYCLES5_SMPR1ALLCHANNELS (ADC_SAMPLETIME_ALLCHANNELS_SMPR1BIT1)
  1712. #define ADC_SAMPLETIME_28CYCLES5_SMPR1ALLCHANNELS (ADC_SAMPLETIME_ALLCHANNELS_SMPR1BIT1 | ADC_SAMPLETIME_ALLCHANNELS_SMPR1BIT0)
  1713. #define ADC_SAMPLETIME_41CYCLES5_SMPR1ALLCHANNELS (ADC_SAMPLETIME_ALLCHANNELS_SMPR1BIT2)
  1714. #define ADC_SAMPLETIME_55CYCLES5_SMPR1ALLCHANNELS (ADC_SAMPLETIME_ALLCHANNELS_SMPR1BIT2 | ADC_SAMPLETIME_ALLCHANNELS_SMPR1BIT0)
  1715. #define ADC_SAMPLETIME_71CYCLES5_SMPR1ALLCHANNELS (ADC_SAMPLETIME_ALLCHANNELS_SMPR1BIT2 | ADC_SAMPLETIME_ALLCHANNELS_SMPR1BIT1)
  1716. #define ADC_SAMPLETIME_239CYCLES5_SMPR1ALLCHANNELS (ADC_SAMPLETIME_ALLCHANNELS_SMPR1BIT2 | ADC_SAMPLETIME_ALLCHANNELS_SMPR1BIT1 | ADC_SAMPLETIME_ALLCHANNELS_SMPR1BIT0)
  1717. /* Combination of all post-conversion flags bits: EOC/EOS, JEOC/JEOS, OVR, AWDx */
  1718. #define ADC_FLAG_POSTCONV_ALL (ADC_FLAG_EOC | ADC_FLAG_JEOC | ADC_FLAG_AWD )
  1719. /**
  1720. * @}
  1721. */
  1722. #endif /* STM32F373xC || STM32F378xx */
  1723. /**
  1724. * @}
  1725. */
  1726. /* Exported macro ------------------------------------------------------------*/
  1727. /** @defgroup ADCEx_Exported_Macros ADCEx Exported Macros
  1728. * @{
  1729. */
  1730. /* Macro for internal HAL driver usage, and possibly can be used into code of */
  1731. /* final user. */
  1732. #if defined(STM32F302xE) || defined(STM32F303xE) || defined(STM32F398xx) || \
  1733. defined(STM32F302xC) || defined(STM32F303xC) || defined(STM32F358xx) || \
  1734. defined(STM32F303x8) || defined(STM32F334x8) || defined(STM32F328xx) || \
  1735. defined(STM32F301x8) || defined(STM32F302x8) || defined(STM32F318xx)
  1736. /**
  1737. * @brief Enable the ADC peripheral
  1738. * @param __HANDLE__ ADC handle
  1739. * @note ADC enable requires a delay for ADC stabilization time
  1740. * (refer to device datasheet, parameter tSTAB)
  1741. * @note On STM32F3 devices, some hardware constraints must be strictly
  1742. * respected before using this macro:
  1743. * - ADC internal voltage regulator must be preliminarily enabled.
  1744. * This is performed by function HAL_ADC_Init().
  1745. * - ADC state requirements: ADC must be disabled, no conversion on
  1746. * going, no calibration on going.
  1747. * These checks are performed by functions HAL_ADC_start_xxx().
  1748. * @retval None
  1749. */
  1750. #define __HAL_ADC_ENABLE(__HANDLE__) \
  1751. (SET_BIT((__HANDLE__)->Instance->CR, ADC_CR_ADEN))
  1752. /**
  1753. * @brief Disable the ADC peripheral
  1754. * @param __HANDLE__ ADC handle
  1755. * @note On STM32F3 devices, some hardware constraints must be strictly
  1756. * respected before using this macro:
  1757. * - ADC state requirements: ADC must be enabled, no conversion on
  1758. * going.
  1759. * These checks are performed by functions HAL_ADC_start_xxx().
  1760. * @retval None
  1761. */
  1762. #define __HAL_ADC_DISABLE(__HANDLE__) \
  1763. do{ \
  1764. SET_BIT((__HANDLE__)->Instance->CR, ADC_CR_ADDIS); \
  1765. __HAL_ADC_CLEAR_FLAG((__HANDLE__), (ADC_FLAG_EOSMP | ADC_FLAG_RDY)); \
  1766. } while(0U)
  1767. /**
  1768. * @brief Enable the ADC end of conversion interrupt.
  1769. * @param __HANDLE__ ADC handle
  1770. * @param __INTERRUPT__ ADC Interrupt
  1771. * This parameter can be any combination of the following values:
  1772. * @arg ADC_IT_RDY: ADC Ready (ADRDY) interrupt source
  1773. * @arg ADC_IT_EOSMP: ADC End of Sampling interrupt source
  1774. * @arg ADC_IT_EOC: ADC End of Regular Conversion interrupt source
  1775. * @arg ADC_IT_EOS: ADC End of Regular sequence of Conversions interrupt source
  1776. * @arg ADC_IT_OVR: ADC overrun interrupt source
  1777. * @arg ADC_IT_JEOC: ADC End of Injected Conversion interrupt source
  1778. * @arg ADC_IT_JEOS: ADC End of Injected sequence of Conversions interrupt source
  1779. * @arg ADC_IT_AWD1: ADC Analog watchdog 1 interrupt source (main analog watchdog, present on all STM32 devices)
  1780. * @arg ADC_IT_AWD2: ADC Analog watchdog 2 interrupt source (additional analog watchdog, present only on STM32F3 devices)
  1781. * @arg ADC_IT_AWD3: ADC Analog watchdog 3 interrupt source (additional analog watchdog, present only on STM32F3 devices)
  1782. * @arg ADC_IT_JQOVF: ADC Injected Context Queue Overflow interrupt source
  1783. * @retval None
  1784. */
  1785. #define __HAL_ADC_ENABLE_IT(__HANDLE__, __INTERRUPT__) \
  1786. (SET_BIT((__HANDLE__)->Instance->IER, (__INTERRUPT__)))
  1787. /**
  1788. * @brief Disable the ADC end of conversion interrupt.
  1789. * @param __HANDLE__ ADC handle
  1790. * @param __INTERRUPT__ ADC Interrupt
  1791. * This parameter can be any combination of the following values:
  1792. * @arg ADC_IT_RDY: ADC Ready (ADRDY) interrupt source
  1793. * @arg ADC_IT_EOSMP: ADC End of Sampling interrupt source
  1794. * @arg ADC_IT_EOC: ADC End of Regular Conversion interrupt source
  1795. * @arg ADC_IT_EOS: ADC End of Regular sequence of Conversions interrupt source
  1796. * @arg ADC_IT_OVR: ADC overrun interrupt source
  1797. * @arg ADC_IT_JEOC: ADC End of Injected Conversion interrupt source
  1798. * @arg ADC_IT_JEOS: ADC End of Injected sequence of Conversions interrupt source
  1799. * @arg ADC_IT_AWD1: ADC Analog watchdog 1 interrupt source (main analog watchdog, present on all STM32 devices)
  1800. * @arg ADC_IT_AWD2: ADC Analog watchdog 2 interrupt source (additional analog watchdog, present only on STM32F3 devices)
  1801. * @arg ADC_IT_AWD3: ADC Analog watchdog 3 interrupt source (additional analog watchdog, present only on STM32F3 devices)
  1802. * @arg ADC_IT_JQOVF: ADC Injected Context Queue Overflow interrupt source
  1803. * @retval None
  1804. */
  1805. #define __HAL_ADC_DISABLE_IT(__HANDLE__, __INTERRUPT__) \
  1806. (CLEAR_BIT((__HANDLE__)->Instance->IER, (__INTERRUPT__)))
  1807. /** @brief Checks if the specified ADC interrupt source is enabled or disabled.
  1808. * @param __HANDLE__ ADC handle
  1809. * @param __INTERRUPT__ ADC interrupt source to check
  1810. * This parameter can be any combination of the following values:
  1811. * @arg ADC_IT_RDY: ADC Ready (ADRDY) interrupt source
  1812. * @arg ADC_IT_EOSMP: ADC End of Sampling interrupt source
  1813. * @arg ADC_IT_EOC: ADC End of Regular Conversion interrupt source
  1814. * @arg ADC_IT_EOS: ADC End of Regular sequence of Conversions interrupt source
  1815. * @arg ADC_IT_OVR: ADC overrun interrupt source
  1816. * @arg ADC_IT_JEOC: ADC End of Injected Conversion interrupt source
  1817. * @arg ADC_IT_JEOS: ADC End of Injected sequence of Conversions interrupt source
  1818. * @arg ADC_IT_AWD1: ADC Analog watchdog 1 interrupt source (main analog watchdog, present on all STM32 devices)
  1819. * @arg ADC_IT_AWD2: ADC Analog watchdog 2 interrupt source (additional analog watchdog, present only on STM32F3 devices)
  1820. * @arg ADC_IT_AWD3: ADC Analog watchdog 3 interrupt source (additional analog watchdog, present only on STM32F3 devices)
  1821. * @arg ADC_IT_JQOVF: ADC Injected Context Queue Overflow interrupt source
  1822. * @retval State of interruption (SET or RESET)
  1823. */
  1824. #define __HAL_ADC_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) \
  1825. (((__HANDLE__)->Instance->IER & (__INTERRUPT__)) == (__INTERRUPT__))
  1826. /**
  1827. * @brief Get the selected ADC's flag status.
  1828. * @param __HANDLE__ ADC handle
  1829. * @param __FLAG__ ADC flag
  1830. * This parameter can be any combination of the following values:
  1831. * @arg ADC_FLAG_RDY: ADC Ready (ADRDY) flag
  1832. * @arg ADC_FLAG_EOSMP: ADC End of Sampling flag
  1833. * @arg ADC_FLAG_EOC: ADC End of Regular Conversion flag
  1834. * @arg ADC_FLAG_EOS: ADC End of Regular sequence of Conversions flag
  1835. * @arg ADC_FLAG_OVR: ADC overrun flag
  1836. * @arg ADC_FLAG_JEOC: ADC End of Injected Conversion flag
  1837. * @arg ADC_FLAG_JEOS: ADC End of Injected sequence of Conversions flag
  1838. * @arg ADC_FLAG_AWD1: ADC Analog watchdog 1 flag (main analog watchdog, present on all STM32 devices)
  1839. * @arg ADC_FLAG_AWD2: ADC Analog watchdog 2 flag (additional analog watchdog, present only on STM32F3 devices)
  1840. * @arg ADC_FLAG_AWD3: ADC Analog watchdog 3 flag (additional analog watchdog, present only on STM32F3 devices)
  1841. * @arg ADC_FLAG_JQOVF: ADC Injected Context Queue Overflow flag
  1842. * @retval None
  1843. */
  1844. #define __HAL_ADC_GET_FLAG(__HANDLE__, __FLAG__) \
  1845. ((((__HANDLE__)->Instance->ISR) & (__FLAG__)) == (__FLAG__))
  1846. /**
  1847. * @brief Clear the ADC's pending flags
  1848. * @param __HANDLE__ ADC handle
  1849. * @param __FLAG__ ADC flag
  1850. * This parameter can be any combination of the following values:
  1851. * @arg ADC_FLAG_RDY: ADC Ready (ADRDY) flag
  1852. * @arg ADC_FLAG_EOSMP: ADC End of Sampling flag
  1853. * @arg ADC_FLAG_EOC: ADC End of Regular Conversion flag
  1854. * @arg ADC_FLAG_EOS: ADC End of Regular sequence of Conversions flag
  1855. * @arg ADC_FLAG_OVR: ADC overrun flag
  1856. * @arg ADC_FLAG_JEOC: ADC End of Injected Conversion flag
  1857. * @arg ADC_FLAG_JEOS: ADC End of Injected sequence of Conversions flag
  1858. * @arg ADC_FLAG_AWD1: ADC Analog watchdog 1 flag (main analog watchdog, present on all STM32 devices)
  1859. * @arg ADC_FLAG_AWD2: ADC Analog watchdog 2 flag (additional analog watchdog, present only on STM32F3 devices)
  1860. * @arg ADC_FLAG_AWD3: ADC Analog watchdog 3 flag (additional analog watchdog, present only on STM32F3 devices)
  1861. * @arg ADC_FLAG_JQOVF: ADC Injected Context Queue Overflow flag
  1862. * @retval None
  1863. */
  1864. /* Note: bit cleared bit by writing 1 (writing 0 has no effect on any bit of */
  1865. /* register ISR). */
  1866. #define __HAL_ADC_CLEAR_FLAG(__HANDLE__, __FLAG__) \
  1867. (WRITE_REG((__HANDLE__)->Instance->ISR, (__FLAG__)))
  1868. #endif /* STM32F302xE || STM32F303xE || STM32F398xx || */
  1869. /* STM32F302xC || STM32F303xC || STM32F358xx || */
  1870. /* STM32F303x8 || STM32F334x8 || STM32F328xx || */
  1871. /* STM32F301x8 || STM32F302x8 || STM32F318xx */
  1872. #if defined(STM32F373xC) || defined(STM32F378xx)
  1873. /**
  1874. * @brief Enable the ADC peripheral
  1875. * @note ADC enable requires a delay for ADC stabilization time
  1876. * (refer to device datasheet, parameter tSTAB)
  1877. * @note On STM32F37x devices, if ADC is already enabled this macro trigs
  1878. * a conversion SW start on regular group.
  1879. * @param __HANDLE__ ADC handle
  1880. * @retval None
  1881. */
  1882. #define __HAL_ADC_ENABLE(__HANDLE__) \
  1883. (SET_BIT((__HANDLE__)->Instance->CR2, (ADC_CR2_ADON)))
  1884. /**
  1885. * @brief Disable the ADC peripheral
  1886. * @param __HANDLE__ ADC handle
  1887. * @retval None
  1888. */
  1889. #define __HAL_ADC_DISABLE(__HANDLE__) \
  1890. (CLEAR_BIT((__HANDLE__)->Instance->CR2, (ADC_CR2_ADON)))
  1891. /** @brief Enable the ADC end of conversion interrupt.
  1892. * @param __HANDLE__ ADC handle
  1893. * @param __INTERRUPT__ ADC Interrupt
  1894. * This parameter can be any combination of the following values:
  1895. * @arg ADC_IT_EOC: ADC End of Regular Conversion interrupt source
  1896. * @arg ADC_IT_JEOC: ADC End of Injected Conversion interrupt source
  1897. * @arg ADC_IT_AWD: ADC Analog watchdog interrupt source
  1898. * @retval None
  1899. */
  1900. #define __HAL_ADC_ENABLE_IT(__HANDLE__, __INTERRUPT__) \
  1901. (SET_BIT((__HANDLE__)->Instance->CR1, (__INTERRUPT__)))
  1902. /** @brief Disable the ADC end of conversion interrupt.
  1903. * @param __HANDLE__ ADC handle
  1904. * @param __INTERRUPT__ ADC Interrupt
  1905. * This parameter can be any combination of the following values:
  1906. * @arg ADC_IT_EOC: ADC End of Regular Conversion interrupt source
  1907. * @arg ADC_IT_JEOC: ADC End of Injected Conversion interrupt source
  1908. * @arg ADC_IT_AWD: ADC Analog watchdog interrupt source
  1909. * @retval None
  1910. */
  1911. #define __HAL_ADC_DISABLE_IT(__HANDLE__, __INTERRUPT__) \
  1912. (CLEAR_BIT((__HANDLE__)->Instance->CR1, (__INTERRUPT__)))
  1913. /** @brief Checks if the specified ADC interrupt source is enabled or disabled.
  1914. * @param __HANDLE__ ADC handle
  1915. * @param __INTERRUPT__ ADC interrupt source to check
  1916. * This parameter can be any combination of the following values:
  1917. * @arg ADC_IT_EOC: ADC End of Regular Conversion interrupt source
  1918. * @arg ADC_IT_JEOC: ADC End of Injected Conversion interrupt source
  1919. * @arg ADC_IT_AWD: ADC Analog watchdog interrupt source
  1920. * @retval State of interruption (SET or RESET)
  1921. */
  1922. #define __HAL_ADC_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) \
  1923. (((__HANDLE__)->Instance->CR1 & (__INTERRUPT__)) == (__INTERRUPT__))
  1924. /** @brief Get the selected ADC's flag status.
  1925. * @param __HANDLE__ ADC handle
  1926. * @param __FLAG__ ADC flag
  1927. * This parameter can be any combination of the following values:
  1928. * @arg ADC_FLAG_STRT: ADC Regular group start flag
  1929. * @arg ADC_FLAG_JSTRT: ADC Injected group start flag
  1930. * @arg ADC_FLAG_EOC: ADC End of Regular conversion flag
  1931. * @arg ADC_FLAG_JEOC: ADC End of Injected conversion flag
  1932. * @arg ADC_FLAG_AWD: ADC Analog watchdog flag
  1933. * @retval None
  1934. */
  1935. #define __HAL_ADC_GET_FLAG(__HANDLE__, __FLAG__) \
  1936. ((((__HANDLE__)->Instance->SR) & (__FLAG__)) == (__FLAG__))
  1937. /** @brief Clear the ADC's pending flags
  1938. * @param __HANDLE__ ADC handle
  1939. * @param __FLAG__ ADC flag
  1940. * This parameter can be any combination of the following values:
  1941. * @arg ADC_FLAG_STRT: ADC Regular group start flag
  1942. * @arg ADC_FLAG_JSTRT: ADC Injected group start flag
  1943. * @arg ADC_FLAG_EOC: ADC End of Regular conversion flag
  1944. * @arg ADC_FLAG_JEOC: ADC End of Injected conversion flag
  1945. * @arg ADC_FLAG_AWD: ADC Analog watchdog flag
  1946. * @retval None
  1947. */
  1948. #define __HAL_ADC_CLEAR_FLAG(__HANDLE__, __FLAG__) \
  1949. (WRITE_REG((__HANDLE__)->Instance->SR, ~(__FLAG__)))
  1950. #endif /* STM32F373xC || STM32F378xx */
  1951. /**
  1952. * @}
  1953. */
  1954. /* Private macro ------------------------------------------------------------*/
  1955. /** @addtogroup ADCEx_Private_Macro ADCEx Private Macros
  1956. * @{
  1957. */
  1958. /* Macro reserved for internal HAL driver usage, not intended to be used in */
  1959. /* code of final user. */
  1960. #if defined(STM32F302xE) || defined(STM32F303xE) || defined(STM32F398xx) || \
  1961. defined(STM32F302xC) || defined(STM32F303xC) || defined(STM32F358xx) || \
  1962. defined(STM32F303x8) || defined(STM32F334x8) || defined(STM32F328xx) || \
  1963. defined(STM32F301x8) || defined(STM32F302x8) || defined(STM32F318xx)
  1964. /**
  1965. * @brief Verification of hardware constraints before ADC can be enabled
  1966. * @param __HANDLE__ ADC handle
  1967. * @retval SET (ADC can be enabled) or RESET (ADC cannot be enabled)
  1968. */
  1969. #define ADC_ENABLING_CONDITIONS(__HANDLE__) \
  1970. (( HAL_IS_BIT_CLR((__HANDLE__)->Instance->CR , \
  1971. (ADC_CR_ADCAL | ADC_CR_JADSTP | ADC_CR_ADSTP | \
  1972. ADC_CR_JADSTART |ADC_CR_ADSTART | ADC_CR_ADDIS | \
  1973. ADC_CR_ADEN ) ) \
  1974. ) ? SET : RESET)
  1975. /**
  1976. * @brief Verification of ADC state: enabled or disabled
  1977. * @param __HANDLE__ ADC handle
  1978. * @retval SET (ADC enabled) or RESET (ADC disabled)
  1979. */
  1980. #define ADC_IS_ENABLE(__HANDLE__) \
  1981. (( ((((__HANDLE__)->Instance->CR) & (ADC_CR_ADEN | ADC_CR_ADDIS)) == ADC_CR_ADEN) && \
  1982. ((((__HANDLE__)->Instance->ISR) & ADC_FLAG_RDY) == ADC_FLAG_RDY) \
  1983. ) ? SET : RESET)
  1984. /**
  1985. * @brief Test if conversion trigger of regular group is software start
  1986. * or external trigger.
  1987. * @param __HANDLE__ ADC handle
  1988. * @retval SET (software start) or RESET (external trigger)
  1989. */
  1990. #define ADC_IS_SOFTWARE_START_REGULAR(__HANDLE__) \
  1991. (((__HANDLE__)->Instance->CFGR & ADC_CFGR_EXTEN) == RESET)
  1992. /**
  1993. * @brief Test if conversion trigger of injected group is software start
  1994. * or external trigger.
  1995. * @param __HANDLE__ ADC handle
  1996. * @retval SET (software start) or RESET (external trigger)
  1997. */
  1998. #define ADC_IS_SOFTWARE_START_INJECTED(__HANDLE__) \
  1999. (((__HANDLE__)->Instance->JSQR & ADC_JSQR_JEXTEN) == RESET)
  2000. /**
  2001. * @brief Check if no conversion on going on regular and/or injected groups
  2002. * @param __HANDLE__ ADC handle
  2003. * @retval SET (conversion is on going) or RESET (no conversion is on going)
  2004. */
  2005. #define ADC_IS_CONVERSION_ONGOING_REGULAR_INJECTED(__HANDLE__) \
  2006. (( (((__HANDLE__)->Instance->CR) & (ADC_CR_ADSTART | ADC_CR_JADSTART)) == RESET \
  2007. ) ? RESET : SET)
  2008. /**
  2009. * @brief Check if no conversion on going on regular group
  2010. * @param __HANDLE__ ADC handle
  2011. * @retval SET (conversion is on going) or RESET (no conversion is on going)
  2012. */
  2013. #define ADC_IS_CONVERSION_ONGOING_REGULAR(__HANDLE__) \
  2014. (( (((__HANDLE__)->Instance->CR) & ADC_CR_ADSTART) == RESET \
  2015. ) ? RESET : SET)
  2016. /**
  2017. * @brief Check if no conversion on going on injected group
  2018. * @param __HANDLE__ ADC handle
  2019. * @retval SET (conversion is on going) or RESET (no conversion is on going)
  2020. */
  2021. #define ADC_IS_CONVERSION_ONGOING_INJECTED(__HANDLE__) \
  2022. (( (((__HANDLE__)->Instance->CR) & ADC_CR_JADSTART) == RESET \
  2023. ) ? RESET : SET)
  2024. /**
  2025. * @brief Returns resolution bits in CFGR1 register: RES[1:0].
  2026. * Returned value is among parameters to @ref ADCEx_Resolution.
  2027. * @param __HANDLE__ ADC handle
  2028. * @retval None
  2029. */
  2030. #define ADC_GET_RESOLUTION(__HANDLE__) (((__HANDLE__)->Instance->CFGR) & ADC_CFGR_RES)
  2031. /**
  2032. * @brief Simultaneously clears and sets specific bits of the handle State
  2033. * @note: ADC_STATE_CLR_SET() macro is merely aliased to generic macro MODIFY_REG(),
  2034. * the first parameter is the ADC handle State, the second parameter is the
  2035. * bit field to clear, the third and last parameter is the bit field to set.
  2036. * @retval None
  2037. */
  2038. #define ADC_STATE_CLR_SET MODIFY_REG
  2039. /**
  2040. * @brief Clear ADC error code (set it to error code: "no error")
  2041. * @param __HANDLE__ ADC handle
  2042. * @retval None
  2043. */
  2044. #define ADC_CLEAR_ERRORCODE(__HANDLE__) ((__HANDLE__)->ErrorCode = HAL_ADC_ERROR_NONE)
  2045. /**
  2046. * @brief Set the ADC's sample time for Channels numbers between 0 and 9.
  2047. * @param _SAMPLETIME_ Sample time parameter.
  2048. * @param _CHANNELNB_ Channel number.
  2049. * @retval None
  2050. */
  2051. #define ADC_SMPR1(_SAMPLETIME_, _CHANNELNB_) ((_SAMPLETIME_) << (3U * (_CHANNELNB_)))
  2052. /**
  2053. * @brief Set the ADC's sample time for Channels numbers between 10 and 18.
  2054. * @param _SAMPLETIME_ Sample time parameter.
  2055. * @param _CHANNELNB_ Channel number.
  2056. * @retval None
  2057. */
  2058. #define ADC_SMPR2(_SAMPLETIME_, _CHANNELNB_) ((_SAMPLETIME_) << (3U * ((_CHANNELNB_) - 10U)))
  2059. /**
  2060. * @brief Set the selected regular Channel rank for rank between 1 and 4.
  2061. * @param _CHANNELNB_ Channel number.
  2062. * @param _RANKNB_ Rank number.
  2063. * @retval None
  2064. */
  2065. #define ADC_SQR1_RK(_CHANNELNB_, _RANKNB_) ((_CHANNELNB_) << (6U * (_RANKNB_)))
  2066. /**
  2067. * @brief Set the selected regular Channel rank for rank between 5 and 9.
  2068. * @param _CHANNELNB_ Channel number.
  2069. * @param _RANKNB_ Rank number.
  2070. * @retval None
  2071. */
  2072. #define ADC_SQR2_RK(_CHANNELNB_, _RANKNB_) ((_CHANNELNB_) << (6U * ((_RANKNB_) - 5U)))
  2073. /**
  2074. * @brief Set the selected regular Channel rank for rank between 10 and 14.
  2075. * @param _CHANNELNB_ Channel number.
  2076. * @param _RANKNB_ Rank number.
  2077. * @retval None
  2078. */
  2079. #define ADC_SQR3_RK(_CHANNELNB_, _RANKNB_) ((_CHANNELNB_) << (6U * ((_RANKNB_) - 10U)))
  2080. /**
  2081. * @brief Set the selected regular Channel rank for rank between 15 and 16.
  2082. * @param _CHANNELNB_ Channel number.
  2083. * @param _RANKNB_ Rank number.
  2084. * @retval None
  2085. */
  2086. #define ADC_SQR4_RK(_CHANNELNB_, _RANKNB_) ((_CHANNELNB_) << (6U * ((_RANKNB_) - 15U)))
  2087. /**
  2088. * @brief Set the selected injected Channel rank.
  2089. * @param _CHANNELNB_ Channel number.
  2090. * @param _RANKNB_ Rank number.
  2091. * @retval None
  2092. */
  2093. #define ADC_JSQR_RK(_CHANNELNB_, _RANKNB_) ((_CHANNELNB_) << (6U * (_RANKNB_) +2U))
  2094. /**
  2095. * @brief Set the Analog Watchdog 1 channel.
  2096. * @param _CHANNEL_ channel to be monitored by Analog Watchdog 1.
  2097. * @retval None
  2098. */
  2099. #define ADC_CFGR_AWD1CH_SHIFT(_CHANNEL_) ((_CHANNEL_) << 26U)
  2100. /**
  2101. * @brief Configure the channel number into Analog Watchdog 2 or 3.
  2102. * @param _CHANNEL_ ADC Channel
  2103. * @retval None
  2104. */
  2105. #define ADC_CFGR_AWD23CR(_CHANNEL_) (1U << (_CHANNEL_))
  2106. /**
  2107. * @brief Enable automatic conversion of injected group
  2108. * @param _INJECT_AUTO_CONVERSION_ Injected automatic conversion.
  2109. * @retval None
  2110. */
  2111. #define ADC_CFGR_INJECT_AUTO_CONVERSION(_INJECT_AUTO_CONVERSION_) ((_INJECT_AUTO_CONVERSION_) << 25U)
  2112. /**
  2113. * @brief Enable ADC injected context queue
  2114. * @param _INJECT_CONTEXT_QUEUE_MODE_ Injected context queue mode.
  2115. * @retval None
  2116. */
  2117. #define ADC_CFGR_INJECT_CONTEXT_QUEUE(_INJECT_CONTEXT_QUEUE_MODE_) ((_INJECT_CONTEXT_QUEUE_MODE_) << 21U)
  2118. /**
  2119. * @brief Enable ADC discontinuous conversion mode for injected group
  2120. * @param _INJECT_DISCONTINUOUS_MODE_ Injected discontinuous mode.
  2121. * @retval None
  2122. */
  2123. #define ADC_CFGR_INJECT_DISCCONTINUOUS(_INJECT_DISCONTINUOUS_MODE_) ((_INJECT_DISCONTINUOUS_MODE_) << 20U)
  2124. /**
  2125. * @brief Enable ADC discontinuous conversion mode for regular group
  2126. * @param _REG_DISCONTINUOUS_MODE_ Regular discontinuous mode.
  2127. * @retval None
  2128. */
  2129. #define ADC_CFGR_REG_DISCCONTINUOUS(_REG_DISCONTINUOUS_MODE_) ((_REG_DISCONTINUOUS_MODE_) << 16U)
  2130. /**
  2131. * @brief Configures the number of discontinuous conversions for regular group.
  2132. * @param _NBR_DISCONTINUOUS_CONV_ Number of discontinuous conversions.
  2133. * @retval None
  2134. */
  2135. #define ADC_CFGR_DISCONTINUOUS_NUM(_NBR_DISCONTINUOUS_CONV_) (((_NBR_DISCONTINUOUS_CONV_) - 1U) << 17U)
  2136. /**
  2137. * @brief Enable the ADC auto delay mode.
  2138. * @param _AUTOWAIT_ Auto delay bit enable or disable.
  2139. * @retval None
  2140. */
  2141. #define ADC_CFGR_AUTOWAIT(_AUTOWAIT_) ((_AUTOWAIT_) << 14U)
  2142. /**
  2143. * @brief Enable ADC continuous conversion mode.
  2144. * @param _CONTINUOUS_MODE_ Continuous mode.
  2145. * @retval None
  2146. */
  2147. #define ADC_CFGR_CONTINUOUS(_CONTINUOUS_MODE_) ((_CONTINUOUS_MODE_) << 13U)
  2148. /**
  2149. * @brief Enable ADC overrun mode.
  2150. * @param _OVERRUN_MODE_ Overrun mode.
  2151. * @retval Overrun bit setting to be programmed into CFGR register
  2152. */
  2153. /* Note: Bit ADC_CFGR_OVRMOD not used directly in constant */
  2154. /* "ADC_OVR_DATA_OVERWRITTEN" to have this case defined to 0x00U, to set it */
  2155. /* as the default case to be compliant with other STM32 devices. */
  2156. #define ADC_CFGR_OVERRUN(_OVERRUN_MODE_) \
  2157. ( ( (_OVERRUN_MODE_) != (ADC_OVR_DATA_PRESERVED) \
  2158. )? (ADC_CFGR_OVRMOD) : (0x00000000U) \
  2159. )
  2160. /**
  2161. * @brief Enable the ADC DMA continuous request.
  2162. * @param _DMACONTREQ_MODE_ DMA continuous request mode.
  2163. * @retval None
  2164. */
  2165. #define ADC_CFGR_DMACONTREQ(_DMACONTREQ_MODE_) ((_DMACONTREQ_MODE_) << 1U)
  2166. /**
  2167. * @brief For devices with 3 ADCs or more: Defines the external trigger source
  2168. * for regular group according to ADC into common group ADC1&ADC2 or
  2169. * ADC3&ADC4 (some triggers with same source have different value to
  2170. * be programmed into ADC EXTSEL bits of CFGR register).
  2171. * Note: No risk of trigger bits value of common group ADC1&ADC2
  2172. * misleading to another trigger at same bits value, because the 3
  2173. * exceptions below are circular and do not point to any other trigger
  2174. * with direct treatment.
  2175. * For devices with 2 ADCs or less: this macro makes no change.
  2176. * @param __HANDLE__ ADC handle
  2177. * @param __EXT_TRIG_CONV__ External trigger selected for regular group.
  2178. * @retval External trigger to be programmed into EXTSEL bits of CFGR register
  2179. */
  2180. #if defined(STM32F303xE) || defined(STM32F398xx) || \
  2181. defined(STM32F303xC) || defined(STM32F358xx)
  2182. #if defined(STM32F303xC) || defined(STM32F358xx)
  2183. #define ADC_CFGR_EXTSEL_SET(__HANDLE__, __EXT_TRIG_CONV__) \
  2184. (( ((((__HANDLE__)->Instance) == ADC3) || (((__HANDLE__)->Instance) == ADC4)) \
  2185. )? \
  2186. ( ( (__EXT_TRIG_CONV__) == ADC_EXTERNALTRIGCONV_T2_TRGO \
  2187. )? \
  2188. (ADC3_4_EXTERNALTRIG_T2_TRGO) \
  2189. : \
  2190. ( ( (__EXT_TRIG_CONV__) == ADC_EXTERNALTRIGCONV_T3_TRGO \
  2191. )? \
  2192. (ADC3_4_EXTERNALTRIG_T3_TRGO) \
  2193. : \
  2194. ( ( (__EXT_TRIG_CONV__) == ADC_EXTERNALTRIGCONV_T8_TRGO \
  2195. )? \
  2196. (ADC3_4_EXTERNALTRIG_T8_TRGO) \
  2197. : \
  2198. (__EXT_TRIG_CONV__) \
  2199. ) \
  2200. ) \
  2201. ) \
  2202. : \
  2203. (__EXT_TRIG_CONV__) \
  2204. )
  2205. #endif /* STM32F303xC || STM32F358xx */
  2206. #if defined(STM32F303xE) || defined(STM32F398xx)
  2207. /* Note: Macro including external triggers specific to device STM303xE: using */
  2208. /* Timer20 with ADC trigger input remap. */
  2209. #define ADC_CFGR_EXTSEL_SET(__HANDLE__, __EXT_TRIG_CONV__) \
  2210. (( ((((__HANDLE__)->Instance) == ADC3) || (((__HANDLE__)->Instance) == ADC4)) \
  2211. )? \
  2212. ( ( (__EXT_TRIG_CONV__) == ADC_EXTERNALTRIGCONV_T2_TRGO \
  2213. )? \
  2214. (ADC3_4_EXTERNALTRIG_T2_TRGO) \
  2215. : \
  2216. ( ( (__EXT_TRIG_CONV__) == ADC_EXTERNALTRIGCONV_T3_TRGO \
  2217. )? \
  2218. (ADC3_4_EXTERNALTRIG_T3_TRGO) \
  2219. : \
  2220. ( ( (__EXT_TRIG_CONV__) == ADC_EXTERNALTRIGCONV_T8_TRGO \
  2221. )? \
  2222. (ADC3_4_EXTERNALTRIG_T8_TRGO) \
  2223. : \
  2224. ( ( (__EXT_TRIG_CONV__) == ADC_EXTERNALTRIGCONV_T20_CC1 \
  2225. )? \
  2226. (ADC3_4_EXTERNALTRIG_T2_CC1) \
  2227. : \
  2228. ( ( (__EXT_TRIG_CONV__) == ADC_EXTERNALTRIGCONV_T20_TRGO \
  2229. )? \
  2230. (ADC3_4_EXTERNALTRIG_EXT_IT2) \
  2231. : \
  2232. ( ( (__EXT_TRIG_CONV__) == ADC_EXTERNALTRIGCONV_T20_TRGO2 \
  2233. )? \
  2234. (ADC3_4_EXTERNALTRIG_T4_CC1) \
  2235. : \
  2236. (__EXT_TRIG_CONV__) \
  2237. ) \
  2238. ) \
  2239. ) \
  2240. ) \
  2241. ) \
  2242. ) \
  2243. : \
  2244. (__EXT_TRIG_CONV__ & (~ADC_EXTERNALTRIGCONV_T20_MASK)) \
  2245. )
  2246. #endif /* STM32F303xE || STM32F398xx */
  2247. #else
  2248. #define ADC_CFGR_EXTSEL_SET(__HANDLE__, __EXT_TRIG_CONV__) \
  2249. (__EXT_TRIG_CONV__)
  2250. #endif /* STM32F303xE || STM32F398xx || */
  2251. /* STM32F303xC || STM32F358xx */
  2252. /**
  2253. * @brief For devices with 3 ADCs or more: Defines the external trigger source
  2254. * for injected group according to ADC into common group ADC1&ADC2 or
  2255. * ADC3&ADC4 (some triggers with same source have different value to
  2256. * be programmed into ADC JEXTSEL bits of JSQR register).
  2257. * Note: No risk of trigger bits value of common group ADC1&ADC2
  2258. * misleading to another trigger at same bits value, because the 3
  2259. * exceptions below are circular and do not point to any other trigger
  2260. * with direct treatment, except trigger
  2261. * ADC_EXTERNALTRIGINJECCONV_T4_CC3 differentiated with SW offset.
  2262. * For devices with 2 ADCs or less: this macro makes no change.
  2263. * @param __HANDLE__ ADC handle
  2264. * @param __EXT_TRIG_INJECTCONV__ External trigger selected for injected group
  2265. * @retval External trigger to be programmed into JEXTSEL bits of JSQR register
  2266. */
  2267. #if defined(STM32F303xC) || defined(STM32F303xE) || defined(STM32F398xx) || defined(STM32F358xx)
  2268. #if defined(STM32F303xC) || defined(STM32F358xx)
  2269. #define ADC_JSQR_JEXTSEL_SET(__HANDLE__, __EXT_TRIG_INJECTCONV__) \
  2270. (( ((((__HANDLE__)->Instance) == ADC3) || (((__HANDLE__)->Instance) == ADC4)) \
  2271. )? \
  2272. ( ( (__EXT_TRIG_INJECTCONV__) == ADC_EXTERNALTRIGINJECCONV_T2_TRGO \
  2273. )? \
  2274. (ADC3_4_EXTERNALTRIGINJEC_T2_TRGO) \
  2275. : \
  2276. ( ( (__EXT_TRIG_INJECTCONV__) == ADC_EXTERNALTRIGINJECCONV_T4_TRGO \
  2277. )? \
  2278. (ADC3_4_EXTERNALTRIGINJEC_T4_TRGO) \
  2279. : \
  2280. ( ( (__EXT_TRIG_INJECTCONV__) == ADC_EXTERNALTRIGINJECCONV_T8_CC4 \
  2281. )? \
  2282. (ADC3_4_EXTERNALTRIGINJEC_T8_CC4) \
  2283. : \
  2284. ( ( (__EXT_TRIG_INJECTCONV__) == ADC_EXTERNALTRIGINJECCONV_T4_CC3 \
  2285. )? \
  2286. (ADC3_4_EXTERNALTRIGINJEC_T4_CC3) \
  2287. : \
  2288. (__EXT_TRIG_INJECTCONV__) \
  2289. ) \
  2290. ) \
  2291. ) \
  2292. ) \
  2293. : \
  2294. (__EXT_TRIG_INJECTCONV__) \
  2295. )
  2296. #endif /* STM32F303xC || STM32F358xx */
  2297. #if defined(STM32F303xE) || defined(STM32F398xx)
  2298. /* Note: Macro including external triggers specific to device STM303xE: using */
  2299. /* Timer20 with ADC trigger input remap. */
  2300. #define ADC_JSQR_JEXTSEL_SET(__HANDLE__, __EXT_TRIG_INJECTCONV__) \
  2301. (( ((((__HANDLE__)->Instance) == ADC3) || (((__HANDLE__)->Instance) == ADC4)) \
  2302. )? \
  2303. ( ( (__EXT_TRIG_INJECTCONV__) == ADC_EXTERNALTRIGINJECCONV_T2_TRGO \
  2304. )? \
  2305. (ADC3_4_EXTERNALTRIGINJEC_T2_TRGO) \
  2306. : \
  2307. ( ( (__EXT_TRIG_INJECTCONV__) == ADC_EXTERNALTRIGINJECCONV_T4_TRGO \
  2308. )? \
  2309. (ADC3_4_EXTERNALTRIGINJEC_T4_TRGO) \
  2310. : \
  2311. ( ( (__EXT_TRIG_INJECTCONV__) == ADC_EXTERNALTRIGINJECCONV_T8_CC4 \
  2312. )? \
  2313. (ADC3_4_EXTERNALTRIGINJEC_T8_CC4) \
  2314. : \
  2315. ( ( (__EXT_TRIG_INJECTCONV__) == ADC_EXTERNALTRIGINJECCONV_T4_CC3 \
  2316. )? \
  2317. (ADC3_4_EXTERNALTRIGINJEC_T4_CC3) \
  2318. : \
  2319. ( ( (__EXT_TRIG_INJECTCONV__) \
  2320. == ADC_EXTERNALTRIGINJECCONV_T20_TRGO \
  2321. )? \
  2322. (ADC3_4_EXTERNALTRIGINJEC_T20_TRGO) \
  2323. : \
  2324. ( ( (__EXT_TRIG_INJECTCONV__) \
  2325. == ADC_EXTERNALTRIGINJECCONV_T20_TRGO2 \
  2326. )? \
  2327. (ADC3_4_EXTERNALTRIGINJEC_T1_CC3) \
  2328. : \
  2329. (__EXT_TRIG_INJECTCONV__) \
  2330. ) \
  2331. ) \
  2332. ) \
  2333. ) \
  2334. ) \
  2335. ) \
  2336. : \
  2337. (__EXT_TRIG_INJECTCONV__ & (~ADC_EXTERNALTRIGCONV_T20_MASK)) \
  2338. )
  2339. #endif /* STM32F303xE || STM32F398xx */
  2340. #else
  2341. #define ADC_JSQR_JEXTSEL_SET(__HANDLE__, __EXT_TRIG_INJECTCONV__) \
  2342. (__EXT_TRIG_INJECTCONV__)
  2343. #endif /* STM32F303xE || STM32F398xx || */
  2344. /* STM32F303xC || STM32F358xx */
  2345. /**
  2346. * @brief Configure the channel number into offset OFRx register
  2347. * @param _CHANNEL_ ADC Channel
  2348. * @retval None
  2349. */
  2350. #define ADC_OFR_CHANNEL(_CHANNEL_) ((_CHANNEL_) << 26U)
  2351. /**
  2352. * @brief Configure the channel number into differential mode selection register
  2353. * @param _CHANNEL_ ADC Channel
  2354. * @retval None
  2355. */
  2356. #define ADC_DIFSEL_CHANNEL(_CHANNEL_) (1U << (_CHANNEL_))
  2357. /**
  2358. * @brief Calibration factor in differential mode to be set into calibration register
  2359. * @param _Calibration_Factor_ Calibration factor value
  2360. * @retval None
  2361. */
  2362. #define ADC_CALFACT_DIFF_SET(_Calibration_Factor_) ((_Calibration_Factor_) << 16U)
  2363. /**
  2364. * @brief Calibration factor in differential mode to be retrieved from calibration register
  2365. * @param _Calibration_Factor_ Calibration factor value
  2366. * @retval None
  2367. */
  2368. #define ADC_CALFACT_DIFF_GET(_Calibration_Factor_) ((_Calibration_Factor_) >> 16U)
  2369. /**
  2370. * @brief Configure the analog watchdog high threshold into registers TR1, TR2 or TR3.
  2371. * @param _Threshold_ Threshold value
  2372. * @retval None
  2373. */
  2374. #define ADC_TRX_HIGHTHRESHOLD(_Threshold_) ((_Threshold_) << 16U)
  2375. /**
  2376. * @brief Enable the ADC DMA continuous request for ADC multimode.
  2377. * @param _DMAContReq_MODE_ DMA continuous request mode.
  2378. * @retval None
  2379. */
  2380. #define ADC_CCR_MULTI_DMACONTREQ(_DMAContReq_MODE_) ((_DMAContReq_MODE_) << 13U)
  2381. /**
  2382. * @brief Verification of hardware constraints before ADC can be disabled
  2383. * @param __HANDLE__ ADC handle
  2384. * @retval SET (ADC can be disabled) or RESET (ADC cannot be disabled)
  2385. */
  2386. #define ADC_DISABLING_CONDITIONS(__HANDLE__) \
  2387. (( ( ((__HANDLE__)->Instance->CR) & \
  2388. (ADC_CR_JADSTART | ADC_CR_ADSTART | ADC_CR_ADEN)) == ADC_CR_ADEN \
  2389. ) ? SET : RESET)
  2390. /**
  2391. * @brief Shift the offset in function of the selected ADC resolution.
  2392. * Offset has to be left-aligned on bit 11, the LSB (right bits) are set to 0
  2393. * If resolution 12 bits, no shift.
  2394. * If resolution 10 bits, shift of 2 ranks on the left.
  2395. * If resolution 8 bits, shift of 4 ranks on the left.
  2396. * If resolution 6 bits, shift of 6 ranks on the left.
  2397. * therefore, shift = (12 - resolution) = 12 - (12- (((RES[1:0]) >> 3)*2))
  2398. * @param __HANDLE__ ADC handle
  2399. * @param _Offset_ Value to be shifted
  2400. * @retval None
  2401. */
  2402. #define ADC_OFFSET_SHIFT_RESOLUTION(__HANDLE__, _Offset_) \
  2403. ((_Offset_) << ((((__HANDLE__)->Instance->CFGR & ADC_CFGR_RES) >> 3U)*2U))
  2404. /**
  2405. * @brief Shift the AWD1 threshold in function of the selected ADC resolution.
  2406. * Thresholds have to be left-aligned on bit 11, the LSB (right bits) are set to 0.
  2407. * If resolution 12 bits, no shift.
  2408. * If resolution 10 bits, shift of 2 ranks on the left.
  2409. * If resolution 8 bits, shift of 4 ranks on the left.
  2410. * If resolution 6 bits, shift of 6 ranks on the left.
  2411. * therefore, shift = (12 - resolution) = 12 - (12- (((RES[1:0]) >> 3)*2))
  2412. * @param __HANDLE__ ADC handle
  2413. * @param _Threshold_ Value to be shifted
  2414. * @retval None
  2415. */
  2416. #define ADC_AWD1THRESHOLD_SHIFT_RESOLUTION(__HANDLE__, _Threshold_) \
  2417. ((_Threshold_) << ((((__HANDLE__)->Instance->CFGR & ADC_CFGR_RES) >> 3U)*2U))
  2418. /**
  2419. * @brief Shift the AWD2 and AWD3 threshold in function of the selected ADC resolution.
  2420. * Thresholds have to be left-aligned on bit 7.
  2421. * If resolution 12 bits, shift of 4 ranks on the right (the 4 LSB are discarded)
  2422. * If resolution 10 bits, shift of 2 ranks on the right (the 2 LSB are discarded)
  2423. * If resolution 8 bits, no shift.
  2424. * If resolution 6 bits, shift of 2 ranks on the left (the 2 LSB are set to 0)
  2425. * @param __HANDLE__ ADC handle
  2426. * @param _Threshold_ Value to be shifted
  2427. * @retval None
  2428. */
  2429. #define ADC_AWD23THRESHOLD_SHIFT_RESOLUTION(__HANDLE__, _Threshold_) \
  2430. ( ((__HANDLE__)->Instance->CFGR & ADC_CFGR_RES) != (ADC_CFGR_RES_1 | ADC_CFGR_RES_0) ? \
  2431. ((_Threshold_) >> (4U- ((((__HANDLE__)->Instance->CFGR & ADC_CFGR_RES) >> 3U)*2U))) : \
  2432. (_Threshold_) << 2U )
  2433. /**
  2434. * @brief Defines if the selected ADC is within ADC common register ADC1_2 or ADC3_4
  2435. * if available (ADC2, ADC3, ADC4 availability depends on STM32 product)
  2436. * @param __HANDLE__ ADC handle
  2437. * @retval Common control register ADC1_2 or ADC3_4
  2438. */
  2439. #if defined(STM32F303xE) || defined(STM32F398xx) || \
  2440. defined(STM32F303xC) || defined(STM32F358xx)
  2441. #define ADC_MASTER_INSTANCE(__HANDLE__) \
  2442. ( ( ((((__HANDLE__)->Instance) == ADC1) || (((__HANDLE__)->Instance) == ADC2)) \
  2443. )? (ADC1) : (ADC3) \
  2444. )
  2445. #endif /* STM32F303xE || STM32F398xx || */
  2446. /* STM32F303xC || STM32F358xx */
  2447. #if defined(STM32F302xE) || \
  2448. defined(STM32F302xC) || \
  2449. defined(STM32F303x8) || defined(STM32F334x8) || defined(STM32F328xx)
  2450. #define ADC_MASTER_INSTANCE(__HANDLE__) \
  2451. (ADC1)
  2452. #endif /* STM32F302xE || */
  2453. /* STM32F302xC || */
  2454. /* STM32F303x8 || STM32F328xx || STM32F334x8 */
  2455. #if defined(STM32F301x8) || defined(STM32F302x8) || defined(STM32F318xx)
  2456. #define ADC_MASTER_INSTANCE(__HANDLE__) \
  2457. (ADC1)
  2458. #endif /* STM32F301x8 || STM32F302x8 || STM32F318xx */
  2459. /**
  2460. * @brief Defines if the selected ADC is within ADC common register ADC1_2 or ADC3_4
  2461. * if available (ADC2, ADC3, ADC4 availability depends on STM32 product)
  2462. * @param __HANDLE__ ADC handle
  2463. * @retval Common control register ADC1_2 or ADC3_4
  2464. */
  2465. #if defined(STM32F303xE) || defined(STM32F398xx) || \
  2466. defined(STM32F303xC) || defined(STM32F358xx)
  2467. #define ADC_COMMON_REGISTER(__HANDLE__) \
  2468. ( ( ((((__HANDLE__)->Instance) == ADC1) || (((__HANDLE__)->Instance) == ADC2)) \
  2469. )? (ADC1_2_COMMON) : (ADC3_4_COMMON) \
  2470. )
  2471. #endif /* STM32F303xE || STM32F398xx || */
  2472. /* STM32F303xC || STM32F358xx */
  2473. #if defined(STM32F302xE) || \
  2474. defined(STM32F302xC) || \
  2475. defined(STM32F303x8) || defined(STM32F334x8) || defined(STM32F328xx)
  2476. #define ADC_COMMON_REGISTER(__HANDLE__) \
  2477. (ADC1_2_COMMON)
  2478. #endif /* STM32F302xE || */
  2479. /* STM32F302xC || */
  2480. /* STM32F303x8 || STM32F328xx || STM32F334x8 */
  2481. #if defined(STM32F301x8) || defined(STM32F302x8) || defined(STM32F318xx)
  2482. #define ADC_COMMON_REGISTER(__HANDLE__) \
  2483. (ADC1_COMMON)
  2484. #endif /* STM32F301x8 || STM32F302x8 || STM32F318xx */
  2485. /**
  2486. * @brief Selection of ADC common register CCR bits MULTI[4:0]corresponding to the selected ADC (applicable for devices with several ADCs)
  2487. * @param __HANDLE__ ADC handle
  2488. * @retval None
  2489. */
  2490. #if defined(STM32F303xE) || defined(STM32F398xx) || \
  2491. defined(STM32F303xC) || defined(STM32F358xx)
  2492. #define ADC_COMMON_CCR_MULTI(__HANDLE__) \
  2493. ( ( ((((__HANDLE__)->Instance) == ADC1) || (((__HANDLE__)->Instance) == ADC2)) \
  2494. )? \
  2495. (ADC1_2_COMMON->CCR & ADC12_CCR_MULTI) \
  2496. : \
  2497. (ADC3_4_COMMON->CCR & ADC34_CCR_MULTI) \
  2498. )
  2499. #endif /* STM32F303xE || STM32F398xx || */
  2500. /* STM32F303xC || STM32F358xx */
  2501. #if defined(STM32F302xE) || \
  2502. defined(STM32F302xC) || \
  2503. defined(STM32F303x8) || defined(STM32F334x8) || defined(STM32F328xx)
  2504. #define ADC_COMMON_CCR_MULTI(__HANDLE__) \
  2505. (ADC1_2_COMMON->CCR & ADC12_CCR_MULTI)
  2506. #endif /* STM32F302xE || */
  2507. /* STM32F302xC || */
  2508. /* STM32F303x8 || STM32F328xx || STM32F334x8 */
  2509. #if defined(STM32F301x8) || defined(STM32F302x8) || defined(STM32F318xx)
  2510. #define ADC_COMMON_CCR_MULTI(__HANDLE__) \
  2511. (RESET)
  2512. #endif /* STM32F301x8 || STM32F302x8 || STM32F318xx */
  2513. /**
  2514. * @brief Verification of condition for ADC start conversion: ADC must be in non-multimode, or multimode with handle of ADC master (applicable for devices with several ADCs)
  2515. * @param __HANDLE__ ADC handle
  2516. * @retval None
  2517. */
  2518. #if defined(STM32F302xE) || defined(STM32F303xE) || defined(STM32F398xx) || \
  2519. defined(STM32F302xC) || defined(STM32F303xC) || defined(STM32F358xx) || \
  2520. defined(STM32F303x8) || defined(STM32F334x8) || defined(STM32F328xx)
  2521. #define ADC_NONMULTIMODE_OR_MULTIMODEMASTER(__HANDLE__) \
  2522. ((ADC_COMMON_CCR_MULTI(__HANDLE__) == ADC_MODE_INDEPENDENT) || \
  2523. (IS_ADC_MULTIMODE_MASTER_INSTANCE((__HANDLE__)->Instance)) )
  2524. #endif /* STM32F302xE || STM32F303xE || STM32F398xx || */
  2525. /* STM32F302xC || STM32F303xC || STM32F358xx || */
  2526. /* STM32F303x8 || STM32F334x8 || STM32F328xx */
  2527. #if defined(STM32F301x8) || defined(STM32F302x8) || defined(STM32F318xx)
  2528. #define ADC_NONMULTIMODE_OR_MULTIMODEMASTER(__HANDLE__) \
  2529. (!RESET)
  2530. #endif /* STM32F301x8 || STM32F302x8 || STM32F318xx */
  2531. /**
  2532. * @brief Verification of condition for ADC group regular start conversion: ADC must be in non-multimode or multimode on group injected only, or multimode with handle of ADC master (applicable for devices with several ADCs)
  2533. * @param __HANDLE__ ADC handle.
  2534. * @retval None
  2535. */
  2536. #if defined(STM32F302xE) || defined(STM32F303xE) || defined(STM32F398xx) || \
  2537. defined(STM32F302xC) || defined(STM32F303xC) || defined(STM32F358xx) || \
  2538. defined(STM32F303x8) || defined(STM32F334x8) || defined(STM32F328xx)
  2539. #define ADC_NONMULTIMODE_REG_OR_MULTIMODEMASTER(__HANDLE__) \
  2540. ((ADC_COMMON_CCR_MULTI(__HANDLE__) == ADC_MODE_INDEPENDENT) || \
  2541. (ADC_COMMON_CCR_MULTI(__HANDLE__) == ADC_DUALMODE_INJECSIMULT) || \
  2542. (ADC_COMMON_CCR_MULTI(__HANDLE__) == ADC_DUALMODE_ALTERTRIG) || \
  2543. (IS_ADC_MULTIMODE_MASTER_INSTANCE((__HANDLE__)->Instance)) )
  2544. #endif /* STM32F302xE || STM32F303xE || STM32F398xx || */
  2545. /* STM32F302xC || STM32F303xC || STM32F358xx || */
  2546. /* STM32F303x8 || STM32F334x8 || STM32F328xx */
  2547. #if defined(STM32F301x8) || defined(STM32F302x8) || defined(STM32F318xx)
  2548. #define ADC_NONMULTIMODE_REG_OR_MULTIMODEMASTER(__HANDLE__) \
  2549. (!RESET)
  2550. #endif /* STM32F301x8 || STM32F302x8 || STM32F318xx */
  2551. /**
  2552. * @brief Verification of condition for ADC group injected start conversion: ADC must be in non-multimode or multimode on group regular only, or multimode with handle of ADC master (applicable for devices with several ADCs)
  2553. * @param __HANDLE__ ADC handle.
  2554. * @retval None
  2555. */
  2556. #if defined(STM32F302xE) || defined(STM32F303xE) || defined(STM32F398xx) || \
  2557. defined(STM32F302xC) || defined(STM32F303xC) || defined(STM32F358xx) || \
  2558. defined(STM32F303x8) || defined(STM32F334x8) || defined(STM32F328xx)
  2559. #define ADC_NONMULTIMODE_INJ_OR_MULTIMODEMASTER(__HANDLE__) \
  2560. ((ADC_COMMON_CCR_MULTI(__HANDLE__) == ADC_MODE_INDEPENDENT) || \
  2561. (ADC_COMMON_CCR_MULTI(__HANDLE__) == ADC_DUALMODE_REGSIMULT) || \
  2562. (ADC_COMMON_CCR_MULTI(__HANDLE__) == ADC_DUALMODE_INTERL) || \
  2563. (IS_ADC_MULTIMODE_MASTER_INSTANCE((__HANDLE__)->Instance)) )
  2564. #endif /* STM32F302xE || STM32F303xE || STM32F398xx || */
  2565. /* STM32F302xC || STM32F303xC || STM32F358xx || */
  2566. /* STM32F303x8 || STM32F334x8 || STM32F328xx */
  2567. #if defined(STM32F301x8) || defined(STM32F302x8) || defined(STM32F318xx)
  2568. #define ADC_NONMULTIMODE_INJ_OR_MULTIMODEMASTER(__HANDLE__) \
  2569. (!RESET)
  2570. #endif /* STM32F301x8 || STM32F302x8 || STM32F318xx */
  2571. /**
  2572. * @brief Check ADC multimode setting: In case of multimode, check whether ADC master of the selected ADC has feature auto-injection enabled (applicable for devices with several ADCs)
  2573. * @param __HANDLE__ ADC handle
  2574. * @retval None
  2575. */
  2576. #if defined(STM32F303xE) || defined(STM32F398xx) || \
  2577. defined(STM32F303xC) || defined(STM32F358xx)
  2578. #define ADC_MULTIMODE_AUTO_INJECTED(__HANDLE__) \
  2579. (( (((__HANDLE__)->Instance) == ADC1) || (((__HANDLE__)->Instance) == ADC2) \
  2580. )? \
  2581. (ADC1->CFGR & ADC_CFGR_JAUTO) \
  2582. : \
  2583. (ADC3->CFGR & ADC_CFGR_JAUTO) \
  2584. )
  2585. #elif defined(STM32F302xE) || \
  2586. defined(STM32F302xC) || \
  2587. defined(STM32F303x8) || defined(STM32F334x8) || defined(STM32F328xx)
  2588. #define ADC_MULTIMODE_AUTO_INJECTED(__HANDLE__) \
  2589. (( (((__HANDLE__)->Instance) == ADC1) || (((__HANDLE__)->Instance) == ADC2) \
  2590. )? \
  2591. (ADC1->CFGR & ADC_CFGR_JAUTO) \
  2592. : \
  2593. (RESET) \
  2594. )
  2595. #else
  2596. #define ADC_MULTIMODE_AUTO_INJECTED(__HANDLE__) \
  2597. (RESET)
  2598. #endif
  2599. /**
  2600. * @brief Set handle of the other ADC sharing the same common register ADC1_2 or ADC3_4
  2601. * if available (ADC2, ADC3, ADC4 availability depends on STM32 product)
  2602. * @param __HANDLE__ ADC handle
  2603. * @param __HANDLE_OTHER_ADC__ other ADC handle
  2604. * @retval None
  2605. */
  2606. #if defined(STM32F303xE) || defined(STM32F398xx) || \
  2607. defined(STM32F303xC) || defined(STM32F358xx)
  2608. #define ADC_COMMON_ADC_OTHER(__HANDLE__, __HANDLE_OTHER_ADC__) \
  2609. ( ( ((__HANDLE__)->Instance == ADC1) \
  2610. )? \
  2611. ((__HANDLE_OTHER_ADC__)->Instance = ADC2) \
  2612. : \
  2613. ( ( ((__HANDLE__)->Instance == ADC2) \
  2614. )? \
  2615. ((__HANDLE_OTHER_ADC__)->Instance = ADC1) \
  2616. : \
  2617. ( ( ((__HANDLE__)->Instance == ADC3) \
  2618. )? \
  2619. ((__HANDLE_OTHER_ADC__)->Instance = ADC4) \
  2620. : \
  2621. ( ( ((__HANDLE__)->Instance == ADC4) \
  2622. )? \
  2623. ((__HANDLE_OTHER_ADC__)->Instance = ADC3) \
  2624. : \
  2625. ((__HANDLE_OTHER_ADC__)->Instance = NULL) \
  2626. ) \
  2627. ) \
  2628. ) \
  2629. )
  2630. #endif /* STM32F303xE || STM32F398xx || */
  2631. /* STM32F303xC || STM32F358xx */
  2632. #if defined(STM32F302xE) || \
  2633. defined(STM32F302xC) || \
  2634. defined(STM32F303x8) || defined(STM32F334x8) || defined(STM32F328xx)
  2635. #define ADC_COMMON_ADC_OTHER(__HANDLE__, __HANDLE_OTHER_ADC__) \
  2636. ( ( ((__HANDLE__)->Instance == ADC1) \
  2637. )? \
  2638. ((__HANDLE_OTHER_ADC__)->Instance = ADC2) \
  2639. : \
  2640. ((__HANDLE_OTHER_ADC__)->Instance = ADC1) \
  2641. )
  2642. #endif /* STM32F302xE || */
  2643. /* STM32F302xC || */
  2644. /* STM32F303x8 || STM32F328xx || STM32F334x8 */
  2645. #if defined(STM32F301x8) || defined(STM32F302x8) || defined(STM32F318xx)
  2646. #define ADC_COMMON_ADC_OTHER(__HANDLE__, __HANDLE_OTHER_ADC__) \
  2647. ((__HANDLE_OTHER_ADC__)->Instance = NULL)
  2648. #endif /* STM32F301x8 || STM32F302x8 || STM32F318xx */
  2649. /**
  2650. * @brief Set handle of the ADC slave associated to the ADC master
  2651. * if available (ADC2, ADC3, ADC4 availability depends on STM32 product)
  2652. * @param __HANDLE_MASTER__ ADC master handle
  2653. * @param __HANDLE_SLAVE__ ADC slave handle
  2654. * @retval None
  2655. */
  2656. #if defined(STM32F303xE) || defined(STM32F398xx) || \
  2657. defined(STM32F303xC) || defined(STM32F358xx)
  2658. #define ADC_MULTI_SLAVE(__HANDLE_MASTER__, __HANDLE_SLAVE__) \
  2659. ( ( ((__HANDLE_MASTER__)->Instance == ADC1) \
  2660. )? \
  2661. ((__HANDLE_SLAVE__)->Instance = ADC2) \
  2662. : \
  2663. ( ( ((__HANDLE_MASTER__)->Instance == ADC3) \
  2664. )? \
  2665. ((__HANDLE_SLAVE__)->Instance = ADC4) \
  2666. : \
  2667. ((__HANDLE_SLAVE__)->Instance = NULL) \
  2668. ) \
  2669. )
  2670. #endif /* STM32F303xE || STM32F398xx || */
  2671. /* STM32F303xC || STM32F358xx */
  2672. #if defined(STM32F302xE) || \
  2673. defined(STM32F302xC) || \
  2674. defined(STM32F303x8) || defined(STM32F334x8) || defined(STM32F328xx)
  2675. #define ADC_MULTI_SLAVE(__HANDLE_MASTER__, __HANDLE_SLAVE__) \
  2676. ( ( ((__HANDLE_MASTER__)->Instance == ADC1) \
  2677. )? \
  2678. ((__HANDLE_SLAVE__)->Instance = ADC2) \
  2679. : \
  2680. ( NULL ) \
  2681. )
  2682. #endif /* STM32F302xE || */
  2683. /* STM32F302xC || */
  2684. /* STM32F303x8 || STM32F328xx || STM32F334x8 */
  2685. #define IS_ADC_RESOLUTION(RESOLUTION) (((RESOLUTION) == ADC_RESOLUTION_12B) || \
  2686. ((RESOLUTION) == ADC_RESOLUTION_10B) || \
  2687. ((RESOLUTION) == ADC_RESOLUTION_8B) || \
  2688. ((RESOLUTION) == ADC_RESOLUTION_6B) )
  2689. #define IS_ADC_RESOLUTION_8_6_BITS(RESOLUTION) (((RESOLUTION) == ADC_RESOLUTION_8B) || \
  2690. ((RESOLUTION) == ADC_RESOLUTION_6B) )
  2691. #define IS_ADC_DATA_ALIGN(ALIGN) (((ALIGN) == ADC_DATAALIGN_RIGHT) || \
  2692. ((ALIGN) == ADC_DATAALIGN_LEFT) )
  2693. #define IS_ADC_SCAN_MODE(SCAN_MODE) (((SCAN_MODE) == ADC_SCAN_DISABLE) || \
  2694. ((SCAN_MODE) == ADC_SCAN_ENABLE) )
  2695. #define IS_ADC_EOC_SELECTION(EOC_SELECTION) (((EOC_SELECTION) == ADC_EOC_SINGLE_CONV) || \
  2696. ((EOC_SELECTION) == ADC_EOC_SEQ_CONV) )
  2697. #define IS_ADC_OVERRUN(OVR) (((OVR) == ADC_OVR_DATA_PRESERVED) || \
  2698. ((OVR) == ADC_OVR_DATA_OVERWRITTEN) )
  2699. #define IS_ADC_CHANNEL(CHANNEL) (((CHANNEL) == ADC_CHANNEL_1) || \
  2700. ((CHANNEL) == ADC_CHANNEL_2) || \
  2701. ((CHANNEL) == ADC_CHANNEL_3) || \
  2702. ((CHANNEL) == ADC_CHANNEL_4) || \
  2703. ((CHANNEL) == ADC_CHANNEL_5) || \
  2704. ((CHANNEL) == ADC_CHANNEL_6) || \
  2705. ((CHANNEL) == ADC_CHANNEL_7) || \
  2706. ((CHANNEL) == ADC_CHANNEL_8) || \
  2707. ((CHANNEL) == ADC_CHANNEL_9) || \
  2708. ((CHANNEL) == ADC_CHANNEL_10) || \
  2709. ((CHANNEL) == ADC_CHANNEL_11) || \
  2710. ((CHANNEL) == ADC_CHANNEL_12) || \
  2711. ((CHANNEL) == ADC_CHANNEL_13) || \
  2712. ((CHANNEL) == ADC_CHANNEL_14) || \
  2713. ((CHANNEL) == ADC_CHANNEL_15) || \
  2714. ((CHANNEL) == ADC_CHANNEL_TEMPSENSOR) || \
  2715. ((CHANNEL) == ADC_CHANNEL_VBAT) || \
  2716. ((CHANNEL) == ADC_CHANNEL_VREFINT) || \
  2717. ((CHANNEL) == ADC_CHANNEL_VOPAMP1) || \
  2718. ((CHANNEL) == ADC_CHANNEL_VOPAMP2) || \
  2719. ((CHANNEL) == ADC_CHANNEL_VOPAMP3) || \
  2720. ((CHANNEL) == ADC_CHANNEL_VOPAMP4) )
  2721. #define IS_ADC_DIFF_CHANNEL(CHANNEL) (((CHANNEL) == ADC_CHANNEL_1) || \
  2722. ((CHANNEL) == ADC_CHANNEL_2) || \
  2723. ((CHANNEL) == ADC_CHANNEL_3) || \
  2724. ((CHANNEL) == ADC_CHANNEL_4) || \
  2725. ((CHANNEL) == ADC_CHANNEL_5) || \
  2726. ((CHANNEL) == ADC_CHANNEL_6) || \
  2727. ((CHANNEL) == ADC_CHANNEL_7) || \
  2728. ((CHANNEL) == ADC_CHANNEL_8) || \
  2729. ((CHANNEL) == ADC_CHANNEL_9) || \
  2730. ((CHANNEL) == ADC_CHANNEL_10) || \
  2731. ((CHANNEL) == ADC_CHANNEL_11) || \
  2732. ((CHANNEL) == ADC_CHANNEL_12) || \
  2733. ((CHANNEL) == ADC_CHANNEL_13) || \
  2734. ((CHANNEL) == ADC_CHANNEL_14) )
  2735. #define IS_ADC_SAMPLE_TIME(TIME) (((TIME) == ADC_SAMPLETIME_1CYCLE_5) || \
  2736. ((TIME) == ADC_SAMPLETIME_2CYCLES_5) || \
  2737. ((TIME) == ADC_SAMPLETIME_4CYCLES_5) || \
  2738. ((TIME) == ADC_SAMPLETIME_7CYCLES_5) || \
  2739. ((TIME) == ADC_SAMPLETIME_19CYCLES_5) || \
  2740. ((TIME) == ADC_SAMPLETIME_61CYCLES_5) || \
  2741. ((TIME) == ADC_SAMPLETIME_181CYCLES_5) || \
  2742. ((TIME) == ADC_SAMPLETIME_601CYCLES_5) )
  2743. #define IS_ADC_SINGLE_DIFFERENTIAL(SING_DIFF) (((SING_DIFF) == ADC_SINGLE_ENDED) || \
  2744. ((SING_DIFF) == ADC_DIFFERENTIAL_ENDED) )
  2745. #define IS_ADC_OFFSET_NUMBER(OFFSET_NUMBER) (((OFFSET_NUMBER) == ADC_OFFSET_NONE) || \
  2746. ((OFFSET_NUMBER) == ADC_OFFSET_1) || \
  2747. ((OFFSET_NUMBER) == ADC_OFFSET_2) || \
  2748. ((OFFSET_NUMBER) == ADC_OFFSET_3) || \
  2749. ((OFFSET_NUMBER) == ADC_OFFSET_4) )
  2750. #define IS_ADC_REGULAR_RANK(CHANNEL) (((CHANNEL) == ADC_REGULAR_RANK_1 ) || \
  2751. ((CHANNEL) == ADC_REGULAR_RANK_2 ) || \
  2752. ((CHANNEL) == ADC_REGULAR_RANK_3 ) || \
  2753. ((CHANNEL) == ADC_REGULAR_RANK_4 ) || \
  2754. ((CHANNEL) == ADC_REGULAR_RANK_5 ) || \
  2755. ((CHANNEL) == ADC_REGULAR_RANK_6 ) || \
  2756. ((CHANNEL) == ADC_REGULAR_RANK_7 ) || \
  2757. ((CHANNEL) == ADC_REGULAR_RANK_8 ) || \
  2758. ((CHANNEL) == ADC_REGULAR_RANK_9 ) || \
  2759. ((CHANNEL) == ADC_REGULAR_RANK_10) || \
  2760. ((CHANNEL) == ADC_REGULAR_RANK_11) || \
  2761. ((CHANNEL) == ADC_REGULAR_RANK_12) || \
  2762. ((CHANNEL) == ADC_REGULAR_RANK_13) || \
  2763. ((CHANNEL) == ADC_REGULAR_RANK_14) || \
  2764. ((CHANNEL) == ADC_REGULAR_RANK_15) || \
  2765. ((CHANNEL) == ADC_REGULAR_RANK_16) )
  2766. #define IS_ADC_EXTTRIG_EDGE(EDGE) (((EDGE) == ADC_EXTERNALTRIGCONVEDGE_NONE) || \
  2767. ((EDGE) == ADC_EXTERNALTRIGCONVEDGE_RISING) || \
  2768. ((EDGE) == ADC_EXTERNALTRIGCONVEDGE_FALLING) || \
  2769. ((EDGE) == ADC_EXTERNALTRIGCONVEDGE_RISINGFALLING) )
  2770. #if defined(STM32F303xE) || defined(STM32F398xx) || \
  2771. defined(STM32F303xC) || defined(STM32F358xx)
  2772. #if defined(STM32F303xC) || defined(STM32F358xx)
  2773. #define IS_ADC_EXTTRIG(REGTRIG) (((REGTRIG) == ADC_EXTERNALTRIGCONV_T1_CC1) || \
  2774. ((REGTRIG) == ADC_EXTERNALTRIGCONV_T1_CC2) || \
  2775. ((REGTRIG) == ADC_EXTERNALTRIGCONV_T2_CC2) || \
  2776. ((REGTRIG) == ADC_EXTERNALTRIGCONV_T3_CC4) || \
  2777. ((REGTRIG) == ADC_EXTERNALTRIGCONV_T4_CC4) || \
  2778. ((REGTRIG) == ADC_EXTERNALTRIGCONV_T6_TRGO) || \
  2779. ((REGTRIG) == ADC_EXTERNALTRIGCONV_EXT_IT11) || \
  2780. \
  2781. ((REGTRIG) == ADC_EXTERNALTRIGCONV_T2_CC1) || \
  2782. ((REGTRIG) == ADC_EXTERNALTRIGCONV_T2_CC3) || \
  2783. ((REGTRIG) == ADC_EXTERNALTRIGCONV_T3_CC1) || \
  2784. ((REGTRIG) == ADC_EXTERNALTRIGCONV_T4_CC1) || \
  2785. ((REGTRIG) == ADC_EXTERNALTRIGCONV_T7_TRGO) || \
  2786. ((REGTRIG) == ADC_EXTERNALTRIGCONV_T8_CC1) || \
  2787. ((REGTRIG) == ADC_EXTERNALTRIGCONV_EXT_IT2) || \
  2788. \
  2789. ((REGTRIG) == ADC_EXTERNALTRIGCONV_T1_CC3) || \
  2790. ((REGTRIG) == ADC_EXTERNALTRIGCONV_T1_TRGO) || \
  2791. ((REGTRIG) == ADC_EXTERNALTRIGCONV_T1_TRGO2) || \
  2792. ((REGTRIG) == ADC_EXTERNALTRIGCONV_T2_TRGO) || \
  2793. ((REGTRIG) == ADC_EXTERNALTRIGCONV_T3_TRGO) || \
  2794. ((REGTRIG) == ADC_EXTERNALTRIGCONV_T4_TRGO) || \
  2795. ((REGTRIG) == ADC_EXTERNALTRIGCONV_T8_TRGO) || \
  2796. ((REGTRIG) == ADC_EXTERNALTRIGCONV_T8_TRGO2) || \
  2797. ((REGTRIG) == ADC_EXTERNALTRIGCONV_T15_TRGO) || \
  2798. \
  2799. ((REGTRIG) == ADC_SOFTWARE_START) )
  2800. #endif /* STM32F303xC || STM32F358xx */
  2801. #if defined(STM32F303xE) || defined(STM32F398xx)
  2802. #define IS_ADC_EXTTRIG(REGTRIG) (((REGTRIG) == ADC_EXTERNALTRIGCONV_T1_CC1) || \
  2803. ((REGTRIG) == ADC_EXTERNALTRIGCONV_T1_CC2) || \
  2804. ((REGTRIG) == ADC_EXTERNALTRIGCONV_T2_CC2) || \
  2805. ((REGTRIG) == ADC_EXTERNALTRIGCONV_T3_CC4) || \
  2806. ((REGTRIG) == ADC_EXTERNALTRIGCONV_T4_CC4) || \
  2807. ((REGTRIG) == ADC_EXTERNALTRIGCONV_T6_TRGO) || \
  2808. ((REGTRIG) == ADC_EXTERNALTRIGCONV_EXT_IT11) || \
  2809. \
  2810. ((REGTRIG) == ADC_EXTERNALTRIGCONV_T2_CC1) || \
  2811. ((REGTRIG) == ADC_EXTERNALTRIGCONV_T2_CC3) || \
  2812. ((REGTRIG) == ADC_EXTERNALTRIGCONV_T3_CC1) || \
  2813. ((REGTRIG) == ADC_EXTERNALTRIGCONV_T4_CC1) || \
  2814. ((REGTRIG) == ADC_EXTERNALTRIGCONV_T7_TRGO) || \
  2815. ((REGTRIG) == ADC_EXTERNALTRIGCONV_T8_CC1) || \
  2816. ((REGTRIG) == ADC_EXTERNALTRIGCONV_EXT_IT2) || \
  2817. \
  2818. ((REGTRIG) == ADC_EXTERNALTRIGCONV_T1_CC3) || \
  2819. ((REGTRIG) == ADC_EXTERNALTRIGCONV_T1_TRGO) || \
  2820. ((REGTRIG) == ADC_EXTERNALTRIGCONV_T1_TRGO2) || \
  2821. ((REGTRIG) == ADC_EXTERNALTRIGCONV_T2_TRGO) || \
  2822. ((REGTRIG) == ADC_EXTERNALTRIGCONV_T3_TRGO) || \
  2823. ((REGTRIG) == ADC_EXTERNALTRIGCONV_T4_TRGO) || \
  2824. ((REGTRIG) == ADC_EXTERNALTRIGCONV_T8_TRGO) || \
  2825. ((REGTRIG) == ADC_EXTERNALTRIGCONV_T8_TRGO2) || \
  2826. ((REGTRIG) == ADC_EXTERNALTRIGCONV_T15_TRGO) || \
  2827. \
  2828. ((REGTRIG) == ADC_EXTERNALTRIGCONV_T20_CC2) || \
  2829. ((REGTRIG) == ADC_EXTERNALTRIGCONV_T20_CC3) || \
  2830. ((REGTRIG) == ADC_EXTERNALTRIGCONV_T20_CC1) || \
  2831. ((REGTRIG) == ADC_EXTERNALTRIGCONV_T20_TRGO) || \
  2832. ((REGTRIG) == ADC_EXTERNALTRIGCONV_T20_TRGO2) || \
  2833. \
  2834. ((REGTRIG) == ADC_SOFTWARE_START) )
  2835. #endif /* STM32F303xE || STM32F398xx */
  2836. #endif /* STM32F303xC || STM32F303xE || STM32F398xx || STM32F358xx */
  2837. #if defined(STM32F302xE) || \
  2838. defined(STM32F302xC)
  2839. #if defined(STM32F302xE)
  2840. #define IS_ADC_EXTTRIG(REGTRIG) (((REGTRIG) == ADC_EXTERNALTRIGCONV_T1_CC1) || \
  2841. ((REGTRIG) == ADC_EXTERNALTRIGCONV_T1_CC2) || \
  2842. ((REGTRIG) == ADC_EXTERNALTRIGCONV_T1_CC3) || \
  2843. ((REGTRIG) == ADC_EXTERNALTRIGCONV_T2_CC2) || \
  2844. ((REGTRIG) == ADC_EXTERNALTRIGCONV_T3_TRGO) || \
  2845. ((REGTRIG) == ADC_EXTERNALTRIGCONV_T4_CC4) || \
  2846. ((REGTRIG) == ADC_EXTERNALTRIGCONV_EXT_IT11) || \
  2847. ((REGTRIG) == ADC_EXTERNALTRIGCONV_T1_TRGO) || \
  2848. ((REGTRIG) == ADC_EXTERNALTRIGCONV_T1_TRGO2) || \
  2849. ((REGTRIG) == ADC_EXTERNALTRIGCONV_T2_TRGO) || \
  2850. ((REGTRIG) == ADC_EXTERNALTRIGCONV_T4_TRGO) || \
  2851. ((REGTRIG) == ADC_EXTERNALTRIGCONV_T6_TRGO) || \
  2852. ((REGTRIG) == ADC_EXTERNALTRIGCONV_T15_TRGO) || \
  2853. ((REGTRIG) == ADC_EXTERNALTRIGCONV_T3_CC4) || \
  2854. \
  2855. ((REGTRIG) == ADC_EXTERNALTRIGCONV_T20_CC2) || \
  2856. ((REGTRIG) == ADC_EXTERNALTRIGCONV_T20_CC3) || \
  2857. \
  2858. ((REGTRIG) == ADC_SOFTWARE_START) )
  2859. #endif /* STM32F302xE */
  2860. #if defined(STM32F302xC)
  2861. #define IS_ADC_EXTTRIG(REGTRIG) (((REGTRIG) == ADC_EXTERNALTRIGCONV_T1_CC1) || \
  2862. ((REGTRIG) == ADC_EXTERNALTRIGCONV_T1_CC2) || \
  2863. ((REGTRIG) == ADC_EXTERNALTRIGCONV_T1_CC3) || \
  2864. ((REGTRIG) == ADC_EXTERNALTRIGCONV_T2_CC2) || \
  2865. ((REGTRIG) == ADC_EXTERNALTRIGCONV_T3_TRGO) || \
  2866. ((REGTRIG) == ADC_EXTERNALTRIGCONV_T4_CC4) || \
  2867. ((REGTRIG) == ADC_EXTERNALTRIGCONV_EXT_IT11) || \
  2868. ((REGTRIG) == ADC_EXTERNALTRIGCONV_T1_TRGO) || \
  2869. ((REGTRIG) == ADC_EXTERNALTRIGCONV_T1_TRGO2) || \
  2870. ((REGTRIG) == ADC_EXTERNALTRIGCONV_T2_TRGO) || \
  2871. ((REGTRIG) == ADC_EXTERNALTRIGCONV_T4_TRGO) || \
  2872. ((REGTRIG) == ADC_EXTERNALTRIGCONV_T6_TRGO) || \
  2873. ((REGTRIG) == ADC_EXTERNALTRIGCONV_T15_TRGO) || \
  2874. ((REGTRIG) == ADC_EXTERNALTRIGCONV_T3_CC4) || \
  2875. \
  2876. ((REGTRIG) == ADC_SOFTWARE_START) )
  2877. #endif /* STM32F302xC */
  2878. #endif /* STM32F302xE || */
  2879. /* STM32F302xC */
  2880. #if defined(STM32F303x8) || defined(STM32F328xx)
  2881. #define IS_ADC_EXTTRIG(REGTRIG) (((REGTRIG) == ADC_EXTERNALTRIGCONV_T1_CC1) || \
  2882. ((REGTRIG) == ADC_EXTERNALTRIGCONV_T1_CC2) || \
  2883. ((REGTRIG) == ADC_EXTERNALTRIGCONV_T1_CC3) || \
  2884. ((REGTRIG) == ADC_EXTERNALTRIGCONV_T2_CC2) || \
  2885. ((REGTRIG) == ADC_EXTERNALTRIGCONV_T3_TRGO) || \
  2886. ((REGTRIG) == ADC_EXTERNALTRIGCONV_T4_CC4) || \
  2887. ((REGTRIG) == ADC_EXTERNALTRIGCONV_EXT_IT11) || \
  2888. ((REGTRIG) == ADC_EXTERNALTRIGCONV_T8_TRGO) || \
  2889. ((REGTRIG) == ADC_EXTERNALTRIGCONV_T8_TRGO2) || \
  2890. ((REGTRIG) == ADC_EXTERNALTRIGCONV_T1_TRGO) || \
  2891. ((REGTRIG) == ADC_EXTERNALTRIGCONV_T1_TRGO2) || \
  2892. ((REGTRIG) == ADC_EXTERNALTRIGCONV_T2_TRGO) || \
  2893. ((REGTRIG) == ADC_EXTERNALTRIGCONV_T4_TRGO) || \
  2894. ((REGTRIG) == ADC_EXTERNALTRIGCONV_T6_TRGO) || \
  2895. ((REGTRIG) == ADC_EXTERNALTRIGCONV_T15_TRGO) || \
  2896. ((REGTRIG) == ADC_EXTERNALTRIGCONV_T3_CC4) || \
  2897. \
  2898. ((REGTRIG) == ADC_SOFTWARE_START) )
  2899. #endif /* STM32F303x8 || STM32F328xx */
  2900. #if defined(STM32F334x8)
  2901. #define IS_ADC_EXTTRIG(REGTRIG) (((REGTRIG) == ADC_EXTERNALTRIGCONV_T1_CC1) || \
  2902. ((REGTRIG) == ADC_EXTERNALTRIGCONV_T1_CC2) || \
  2903. ((REGTRIG) == ADC_EXTERNALTRIGCONV_T1_CC3) || \
  2904. ((REGTRIG) == ADC_EXTERNALTRIGCONV_T2_CC2) || \
  2905. ((REGTRIG) == ADC_EXTERNALTRIGCONV_T3_TRGO) || \
  2906. ((REGTRIG) == ADC_EXTERNALTRIGCONV_EXT_IT11) || \
  2907. ((REGTRIG) == ADC_EXTERNALTRIGCONVHRTIM_TRG1) || \
  2908. ((REGTRIG) == ADC_EXTERNALTRIGCONVHRTIM_TRG3) || \
  2909. ((REGTRIG) == ADC_EXTERNALTRIGCONV_T1_TRGO) || \
  2910. ((REGTRIG) == ADC_EXTERNALTRIGCONV_T1_TRGO2) || \
  2911. ((REGTRIG) == ADC_EXTERNALTRIGCONV_T2_TRGO) || \
  2912. ((REGTRIG) == ADC_EXTERNALTRIGCONV_T6_TRGO) || \
  2913. ((REGTRIG) == ADC_EXTERNALTRIGCONV_T15_TRGO) || \
  2914. ((REGTRIG) == ADC_EXTERNALTRIGCONV_T3_CC4) || \
  2915. \
  2916. ((REGTRIG) == ADC_SOFTWARE_START) )
  2917. #endif /* STM32F334x8 */
  2918. #if defined(STM32F301x8) || defined(STM32F302x8) || defined(STM32F318xx)
  2919. #define IS_ADC_EXTTRIG(REGTRIG) (((REGTRIG) == ADC_EXTERNALTRIGCONV_T1_CC1) || \
  2920. ((REGTRIG) == ADC_EXTERNALTRIGCONV_T1_CC2) || \
  2921. ((REGTRIG) == ADC_EXTERNALTRIGCONV_T1_CC3) || \
  2922. ((REGTRIG) == ADC_EXTERNALTRIGCONV_T2_CC2) || \
  2923. ((REGTRIG) == ADC_EXTERNALTRIGCONV_EXT_IT11) || \
  2924. ((REGTRIG) == ADC_EXTERNALTRIGCONV_T1_TRGO) || \
  2925. ((REGTRIG) == ADC_EXTERNALTRIGCONV_T1_TRGO2) || \
  2926. ((REGTRIG) == ADC_EXTERNALTRIGCONV_T2_TRGO) || \
  2927. ((REGTRIG) == ADC_EXTERNALTRIGCONV_T6_TRGO) || \
  2928. ((REGTRIG) == ADC_EXTERNALTRIGCONV_T15_TRGO) || \
  2929. ((REGTRIG) == ADC_SOFTWARE_START) )
  2930. #endif /* STM32F301x8 || STM32F302x8 || STM32F318xx */
  2931. #define IS_ADC_EXTTRIGINJEC_EDGE(EDGE) (((EDGE) == ADC_EXTERNALTRIGINJECCONV_EDGE_NONE) || \
  2932. ((EDGE) == ADC_EXTERNALTRIGINJECCONV_EDGE_RISING) || \
  2933. ((EDGE) == ADC_EXTERNALTRIGINJECCONV_EDGE_FALLING) || \
  2934. ((EDGE) == ADC_EXTERNALTRIGINJECCONV_EDGE_RISINGFALLING) )
  2935. #if defined(STM32F303xE) || defined(STM32F398xx) || \
  2936. defined(STM32F303xC) || defined(STM32F358xx)
  2937. #if defined(STM32F303xC) || defined(STM32F358xx)
  2938. #define IS_ADC_EXTTRIGINJEC(INJTRIG) (((INJTRIG) == ADC_EXTERNALTRIGINJECCONV_T2_CC1) || \
  2939. ((INJTRIG) == ADC_EXTERNALTRIGINJECCONV_T3_CC1) || \
  2940. ((INJTRIG) == ADC_EXTERNALTRIGINJECCONV_T3_CC4) || \
  2941. ((INJTRIG) == ADC_EXTERNALTRIGINJECCONV_T6_TRGO) || \
  2942. ((INJTRIG) == ADC_EXTERNALTRIGINJECCONV_EXT_IT15) || \
  2943. \
  2944. ((INJTRIG) == ADC_EXTERNALTRIGINJECCONV_T4_CC3) || \
  2945. ((INJTRIG) == ADC_EXTERNALTRIGINJECCONV_T4_CC4) || \
  2946. ((INJTRIG) == ADC_EXTERNALTRIGINJECCONV_T7_TRGO) || \
  2947. ((INJTRIG) == ADC_EXTERNALTRIGINJECCONV_T8_CC2) || \
  2948. \
  2949. ((INJTRIG) == ADC_EXTERNALTRIGINJECCONV_T1_CC4) || \
  2950. ((INJTRIG) == ADC_EXTERNALTRIGINJECCONV_T1_TRGO) || \
  2951. ((INJTRIG) == ADC_EXTERNALTRIGINJECCONV_T1_TRGO2) || \
  2952. ((INJTRIG) == ADC_EXTERNALTRIGINJECCONV_T2_TRGO) || \
  2953. ((INJTRIG) == ADC_EXTERNALTRIGINJECCONV_T3_CC3) || \
  2954. ((INJTRIG) == ADC_EXTERNALTRIGINJECCONV_T3_TRGO) || \
  2955. ((INJTRIG) == ADC_EXTERNALTRIGINJECCONV_T4_TRGO) || \
  2956. ((INJTRIG) == ADC_EXTERNALTRIGINJECCONV_T8_CC4) || \
  2957. ((INJTRIG) == ADC_EXTERNALTRIGINJECCONV_T8_TRGO) || \
  2958. ((INJTRIG) == ADC_EXTERNALTRIGINJECCONV_T8_TRGO2) || \
  2959. ((INJTRIG) == ADC_EXTERNALTRIGINJECCONV_T15_TRGO) || \
  2960. \
  2961. ((INJTRIG) == ADC_INJECTED_SOFTWARE_START) )
  2962. #endif /* STM32F303xC || STM32F358xx */
  2963. #if defined(STM32F303xE) || defined(STM32F398xx)
  2964. #define IS_ADC_EXTTRIGINJEC(INJTRIG) (((INJTRIG) == ADC_EXTERNALTRIGINJECCONV_T2_CC1) || \
  2965. ((INJTRIG) == ADC_EXTERNALTRIGINJECCONV_T3_CC1) || \
  2966. ((INJTRIG) == ADC_EXTERNALTRIGINJECCONV_T3_CC4) || \
  2967. ((INJTRIG) == ADC_EXTERNALTRIGINJECCONV_T6_TRGO) || \
  2968. ((INJTRIG) == ADC_EXTERNALTRIGINJECCONV_EXT_IT15) || \
  2969. \
  2970. ((INJTRIG) == ADC_EXTERNALTRIGINJECCONV_T4_CC3) || \
  2971. ((INJTRIG) == ADC_EXTERNALTRIGINJECCONV_T4_CC4) || \
  2972. ((INJTRIG) == ADC_EXTERNALTRIGINJECCONV_T7_TRGO) || \
  2973. ((INJTRIG) == ADC_EXTERNALTRIGINJECCONV_T8_CC2) || \
  2974. \
  2975. ((INJTRIG) == ADC_EXTERNALTRIGINJECCONV_T1_CC4) || \
  2976. ((INJTRIG) == ADC_EXTERNALTRIGINJECCONV_T1_TRGO) || \
  2977. ((INJTRIG) == ADC_EXTERNALTRIGINJECCONV_T1_TRGO2) || \
  2978. ((INJTRIG) == ADC_EXTERNALTRIGINJECCONV_T2_TRGO) || \
  2979. ((INJTRIG) == ADC_EXTERNALTRIGINJECCONV_T3_CC3) || \
  2980. ((INJTRIG) == ADC_EXTERNALTRIGINJECCONV_T3_TRGO) || \
  2981. ((INJTRIG) == ADC_EXTERNALTRIGINJECCONV_T4_TRGO) || \
  2982. ((INJTRIG) == ADC_EXTERNALTRIGINJECCONV_T8_CC4) || \
  2983. ((INJTRIG) == ADC_EXTERNALTRIGINJECCONV_T8_TRGO) || \
  2984. ((INJTRIG) == ADC_EXTERNALTRIGINJECCONV_T8_TRGO2) || \
  2985. ((INJTRIG) == ADC_EXTERNALTRIGINJECCONV_T15_TRGO) || \
  2986. \
  2987. ((INJTRIG) == ADC_EXTERNALTRIGINJECCONV_T20_CC4) || \
  2988. ((INJTRIG) == ADC_EXTERNALTRIGINJECCONV_T20_CC2) || \
  2989. ((INJTRIG) == ADC_EXTERNALTRIGINJECCONV_T20_TRGO) || \
  2990. ((INJTRIG) == ADC_EXTERNALTRIGINJECCONV_T20_TRGO2) || \
  2991. \
  2992. ((INJTRIG) == ADC_INJECTED_SOFTWARE_START) )
  2993. #endif /* STM32F303xE || STM32F398xx */
  2994. #endif /* STM32F303xC || STM32F303xE || STM32F398xx || STM32F358xx */
  2995. #if defined(STM32F302xE) || \
  2996. defined(STM32F302xC)
  2997. #if defined(STM32F302xE)
  2998. #define IS_ADC_EXTTRIGINJEC(INJTRIG) (((INJTRIG) == ADC_EXTERNALTRIGINJECCONV_T1_CC4) || \
  2999. ((INJTRIG) == ADC_EXTERNALTRIGINJECCONV_T1_TRGO) || \
  3000. ((INJTRIG) == ADC_EXTERNALTRIGINJECCONV_T1_TRGO2) || \
  3001. ((INJTRIG) == ADC_EXTERNALTRIGINJECCONV_T2_CC1) || \
  3002. ((INJTRIG) == ADC_EXTERNALTRIGINJECCONV_T2_TRGO) || \
  3003. ((INJTRIG) == ADC_EXTERNALTRIGINJECCONV_T3_CC1) || \
  3004. ((INJTRIG) == ADC_EXTERNALTRIGINJECCONV_T3_CC3) || \
  3005. ((INJTRIG) == ADC_EXTERNALTRIGINJECCONV_T3_CC4) || \
  3006. ((INJTRIG) == ADC_EXTERNALTRIGINJECCONV_T3_TRGO) || \
  3007. ((INJTRIG) == ADC_EXTERNALTRIGINJECCONV_T4_TRGO) || \
  3008. ((INJTRIG) == ADC_EXTERNALTRIGINJECCONV_T6_TRGO) || \
  3009. ((INJTRIG) == ADC_EXTERNALTRIGINJECCONV_T15_TRGO) || \
  3010. ((INJTRIG) == ADC_EXTERNALTRIGINJECCONV_EXT_IT15) || \
  3011. ((INJTRIG) == ADC_EXTERNALTRIGINJECCONV_T20_CC4) || \
  3012. ((INJTRIG) == ADC_EXTERNALTRIGINJECCONV_T20_TRGO) || \
  3013. ((INJTRIG) == ADC_EXTERNALTRIGINJECCONV_T20_TRGO2) || \
  3014. ((INJTRIG) == ADC_INJECTED_SOFTWARE_START) )
  3015. #endif /* STM32F302xE */
  3016. #if defined(STM32F302xC)
  3017. #define IS_ADC_EXTTRIGINJEC(INJTRIG) (((INJTRIG) == ADC_EXTERNALTRIGINJECCONV_T1_CC4) || \
  3018. ((INJTRIG) == ADC_EXTERNALTRIGINJECCONV_T1_TRGO) || \
  3019. ((INJTRIG) == ADC_EXTERNALTRIGINJECCONV_T1_TRGO2) || \
  3020. ((INJTRIG) == ADC_EXTERNALTRIGINJECCONV_T2_CC1) || \
  3021. ((INJTRIG) == ADC_EXTERNALTRIGINJECCONV_T2_TRGO) || \
  3022. ((INJTRIG) == ADC_EXTERNALTRIGINJECCONV_T3_CC1) || \
  3023. ((INJTRIG) == ADC_EXTERNALTRIGINJECCONV_T3_CC3) || \
  3024. ((INJTRIG) == ADC_EXTERNALTRIGINJECCONV_T3_CC4) || \
  3025. ((INJTRIG) == ADC_EXTERNALTRIGINJECCONV_T3_TRGO) || \
  3026. ((INJTRIG) == ADC_EXTERNALTRIGINJECCONV_T4_TRGO) || \
  3027. ((INJTRIG) == ADC_EXTERNALTRIGINJECCONV_T6_TRGO) || \
  3028. ((INJTRIG) == ADC_EXTERNALTRIGINJECCONV_T15_TRGO) || \
  3029. ((INJTRIG) == ADC_EXTERNALTRIGINJECCONV_EXT_IT15) || \
  3030. ((INJTRIG) == ADC_INJECTED_SOFTWARE_START) )
  3031. #endif /* STM32F302xC */
  3032. #endif /* STM32F302xE || */
  3033. /* STM32F302xC */
  3034. #if defined(STM32F303x8) || defined(STM32F328xx)
  3035. #define IS_ADC_EXTTRIGINJEC(INJTRIG) (((INJTRIG) == ADC_EXTERNALTRIGINJECCONV_T1_TRGO) || \
  3036. ((INJTRIG) == ADC_EXTERNALTRIGINJECCONV_T1_CC4) || \
  3037. ((INJTRIG) == ADC_EXTERNALTRIGINJECCONV_T2_TRGO) || \
  3038. ((INJTRIG) == ADC_EXTERNALTRIGINJECCONV_T2_CC1) || \
  3039. ((INJTRIG) == ADC_EXTERNALTRIGINJECCONV_T3_CC4) || \
  3040. ((INJTRIG) == ADC_EXTERNALTRIGINJECCONV_T4_TRGO) || \
  3041. ((INJTRIG) == ADC_EXTERNALTRIGINJECCONV_EXT_IT15) || \
  3042. ((INJTRIG) == ADC_EXTERNALTRIGINJECCONV_T8_CC4) || \
  3043. ((INJTRIG) == ADC_EXTERNALTRIGINJECCONV_T1_TRGO2) || \
  3044. ((INJTRIG) == ADC_EXTERNALTRIGINJECCONV_T8_TRGO) || \
  3045. ((INJTRIG) == ADC_EXTERNALTRIGINJECCONV_T8_TRGO2) || \
  3046. ((INJTRIG) == ADC_EXTERNALTRIGINJECCONV_T3_CC3) || \
  3047. ((INJTRIG) == ADC_EXTERNALTRIGINJECCONV_T3_TRGO) || \
  3048. ((INJTRIG) == ADC_EXTERNALTRIGINJECCONV_T3_CC1) || \
  3049. ((INJTRIG) == ADC_EXTERNALTRIGINJECCONV_T6_TRGO) || \
  3050. ((INJTRIG) == ADC_EXTERNALTRIGINJECCONV_T15_TRGO) || \
  3051. ((INJTRIG) == ADC_INJECTED_SOFTWARE_START) )
  3052. #endif /* STM32F303x8 || STM32F328xx */
  3053. #if defined(STM32F334x8)
  3054. #define IS_ADC_EXTTRIGINJEC(INJTRIG) (((INJTRIG) == ADC_EXTERNALTRIGINJECCONV_T1_TRGO) || \
  3055. ((INJTRIG) == ADC_EXTERNALTRIGINJECCONV_T1_CC4) || \
  3056. ((INJTRIG) == ADC_EXTERNALTRIGINJECCONV_T2_TRGO) || \
  3057. ((INJTRIG) == ADC_EXTERNALTRIGINJECCONV_T2_CC1) || \
  3058. ((INJTRIG) == ADC_EXTERNALTRIGINJECCONV_T3_CC4) || \
  3059. ((INJTRIG) == ADC_EXTERNALTRIGINJECCONV_EXT_IT15) || \
  3060. ((INJTRIG) == ADC_EXTERNALTRIGINJECCONV_T1_TRGO2) || \
  3061. ((INJTRIG) == ADC_EXTERNALTRIGINJECCONV_HRTIM_TRG2) || \
  3062. ((INJTRIG) == ADC_EXTERNALTRIGINJECCONV_HRTIM_TRG4) || \
  3063. ((INJTRIG) == ADC_EXTERNALTRIGINJECCONV_T3_CC3) || \
  3064. ((INJTRIG) == ADC_EXTERNALTRIGINJECCONV_T3_TRGO) || \
  3065. ((INJTRIG) == ADC_EXTERNALTRIGINJECCONV_T3_CC1) || \
  3066. ((INJTRIG) == ADC_EXTERNALTRIGINJECCONV_T6_TRGO) || \
  3067. ((INJTRIG) == ADC_EXTERNALTRIGINJECCONV_T15_TRGO) || \
  3068. ((INJTRIG) == ADC_INJECTED_SOFTWARE_START) )
  3069. #endif /* STM32F334x8 */
  3070. #if defined(STM32F301x8) || defined(STM32F302x8) || defined(STM32F318xx)
  3071. #define IS_ADC_EXTTRIGINJEC(INJTRIG) (((INJTRIG) == ADC_EXTERNALTRIGINJECCONV_T1_TRGO) || \
  3072. ((INJTRIG) == ADC_EXTERNALTRIGINJECCONV_T1_CC4) || \
  3073. ((INJTRIG) == ADC_EXTERNALTRIGINJECCONV_EXT_IT15) || \
  3074. ((INJTRIG) == ADC_EXTERNALTRIGINJECCONV_T1_TRGO2) || \
  3075. ((INJTRIG) == ADC_EXTERNALTRIGINJECCONV_T6_TRGO) || \
  3076. ((INJTRIG) == ADC_EXTERNALTRIGINJECCONV_T15_TRGO) || \
  3077. ((INJTRIG) == ADC_INJECTED_SOFTWARE_START) )
  3078. #endif /* STM32F301x8 || STM32F302x8 || STM32F318xx */
  3079. #define IS_ADC_INJECTED_RANK(CHANNEL) (((CHANNEL) == ADC_INJECTED_RANK_1) || \
  3080. ((CHANNEL) == ADC_INJECTED_RANK_2) || \
  3081. ((CHANNEL) == ADC_INJECTED_RANK_3) || \
  3082. ((CHANNEL) == ADC_INJECTED_RANK_4) )
  3083. #define IS_ADC_MODE(MODE) (((MODE) == ADC_MODE_INDEPENDENT) || \
  3084. ((MODE) == ADC_DUALMODE_REGSIMULT_INJECSIMULT) || \
  3085. ((MODE) == ADC_DUALMODE_REGSIMULT_ALTERTRIG) || \
  3086. ((MODE) == ADC_DUALMODE_REGINTERL_INJECSIMULT) || \
  3087. ((MODE) == ADC_DUALMODE_INJECSIMULT) || \
  3088. ((MODE) == ADC_DUALMODE_REGSIMULT) || \
  3089. ((MODE) == ADC_DUALMODE_INTERL) || \
  3090. ((MODE) == ADC_DUALMODE_ALTERTRIG) )
  3091. #define IS_ADC_DMA_ACCESS_MODE(MODE) (((MODE) == ADC_DMAACCESSMODE_DISABLED) || \
  3092. ((MODE) == ADC_DMAACCESSMODE_12_10_BITS) || \
  3093. ((MODE) == ADC_DMAACCESSMODE_8_6_BITS) )
  3094. #define IS_ADC_SAMPLING_DELAY(DELAY) (((DELAY) == ADC_TWOSAMPLINGDELAY_1CYCLE) || \
  3095. ((DELAY) == ADC_TWOSAMPLINGDELAY_2CYCLES) || \
  3096. ((DELAY) == ADC_TWOSAMPLINGDELAY_3CYCLES) || \
  3097. ((DELAY) == ADC_TWOSAMPLINGDELAY_4CYCLES) || \
  3098. ((DELAY) == ADC_TWOSAMPLINGDELAY_5CYCLES) || \
  3099. ((DELAY) == ADC_TWOSAMPLINGDELAY_6CYCLES) || \
  3100. ((DELAY) == ADC_TWOSAMPLINGDELAY_7CYCLES) || \
  3101. ((DELAY) == ADC_TWOSAMPLINGDELAY_8CYCLES) || \
  3102. ((DELAY) == ADC_TWOSAMPLINGDELAY_9CYCLES) || \
  3103. ((DELAY) == ADC_TWOSAMPLINGDELAY_10CYCLES) || \
  3104. ((DELAY) == ADC_TWOSAMPLINGDELAY_11CYCLES) || \
  3105. ((DELAY) == ADC_TWOSAMPLINGDELAY_12CYCLES) )
  3106. #define IS_ADC_ANALOG_WATCHDOG_NUMBER(WATCHDOG) (((WATCHDOG) == ADC_ANALOGWATCHDOG_1) || \
  3107. ((WATCHDOG) == ADC_ANALOGWATCHDOG_2) || \
  3108. ((WATCHDOG) == ADC_ANALOGWATCHDOG_3) )
  3109. #define IS_ADC_ANALOG_WATCHDOG_MODE(WATCHDOG) (((WATCHDOG) == ADC_ANALOGWATCHDOG_NONE) || \
  3110. ((WATCHDOG) == ADC_ANALOGWATCHDOG_SINGLE_REG) || \
  3111. ((WATCHDOG) == ADC_ANALOGWATCHDOG_SINGLE_INJEC) || \
  3112. ((WATCHDOG) == ADC_ANALOGWATCHDOG_SINGLE_REGINJEC) || \
  3113. ((WATCHDOG) == ADC_ANALOGWATCHDOG_ALL_REG) || \
  3114. ((WATCHDOG) == ADC_ANALOGWATCHDOG_ALL_INJEC) || \
  3115. ((WATCHDOG) == ADC_ANALOGWATCHDOG_ALL_REGINJEC) )
  3116. #define IS_ADC_CONVERSION_GROUP(CONVERSION) (((CONVERSION) == ADC_REGULAR_GROUP) || \
  3117. ((CONVERSION) == ADC_INJECTED_GROUP) || \
  3118. ((CONVERSION) == ADC_REGULAR_INJECTED_GROUP) )
  3119. #define IS_ADC_EVENT_TYPE(EVENT) (((EVENT) == ADC_AWD_EVENT) || \
  3120. ((EVENT) == ADC_AWD2_EVENT) || \
  3121. ((EVENT) == ADC_AWD3_EVENT) || \
  3122. ((EVENT) == ADC_OVR_EVENT) || \
  3123. ((EVENT) == ADC_JQOVF_EVENT) )
  3124. /** @defgroup ADCEx_range_verification ADC Extended Range Verification
  3125. * in function of ADC resolution selected (12, 10, 8 or 6 bits)
  3126. * @{
  3127. */
  3128. #define IS_ADC_RANGE(RESOLUTION, ADC_VALUE) \
  3129. ((((RESOLUTION) == ADC_RESOLUTION_12B) && ((ADC_VALUE) <= (0x0FFFU))) || \
  3130. (((RESOLUTION) == ADC_RESOLUTION_10B) && ((ADC_VALUE) <= (0x03FFU))) || \
  3131. (((RESOLUTION) == ADC_RESOLUTION_8B) && ((ADC_VALUE) <= (0x00FFU))) || \
  3132. (((RESOLUTION) == ADC_RESOLUTION_6B) && ((ADC_VALUE) <= (0x003FU))) )
  3133. /**
  3134. * @}
  3135. */
  3136. /** @defgroup ADC_injected_nb_conv_verification ADC Injected Conversion Number Verification
  3137. * @{
  3138. */
  3139. #define IS_ADC_INJECTED_NB_CONV(LENGTH) (((LENGTH) >= (1U)) && ((LENGTH) <= (4U)))
  3140. /**
  3141. * @}
  3142. */
  3143. /** @defgroup ADC_regular_nb_conv_verification ADC Regular Conversion Number Verification
  3144. * @{
  3145. */
  3146. #define IS_ADC_REGULAR_NB_CONV(LENGTH) (((LENGTH) >= (1U)) && ((LENGTH) <= (16U)))
  3147. /**
  3148. * @}
  3149. */
  3150. /** @defgroup ADC_regular_discontinuous_mode_number_verification ADC Regular Discontinuous Mode NumberVerification
  3151. * @{
  3152. */
  3153. #define IS_ADC_REGULAR_DISCONT_NUMBER(NUMBER) (((NUMBER) >= (1U)) && ((NUMBER) <= (8U)))
  3154. /**
  3155. * @}
  3156. */
  3157. /** @defgroup ADC_calibration_factor_length_verification ADC Calibration Factor Length Verification
  3158. * @{
  3159. */
  3160. /**
  3161. * @brief Calibration factor length verification (7 bits maximum)
  3162. * @param _Calibration_Factor_ Calibration factor value
  3163. * @retval None
  3164. */
  3165. #define IS_ADC_CALFACT(_Calibration_Factor_) ((_Calibration_Factor_) <= (0x7FU))
  3166. /**
  3167. * @}
  3168. */
  3169. #endif /* STM32F302xE || STM32F303xE || STM32F398xx || */
  3170. /* STM32F302xC || STM32F303xC || STM32F358xx || */
  3171. /* STM32F303x8 || STM32F334x8 || STM32F328xx || */
  3172. /* STM32F301x8 || STM32F302x8 || STM32F318xx */
  3173. #if defined(STM32F373xC) || defined(STM32F378xx)
  3174. /**
  3175. * @brief Verification of ADC state: enabled or disabled
  3176. * @param __HANDLE__ ADC handle
  3177. * @retval SET (ADC enabled) or RESET (ADC disabled)
  3178. */
  3179. #define ADC_IS_ENABLE(__HANDLE__) \
  3180. ((( ((__HANDLE__)->Instance->CR2 & ADC_CR2_ADON) == ADC_CR2_ADON ) \
  3181. ) ? SET : RESET)
  3182. /**
  3183. * @brief Test if conversion trigger of regular group is software start
  3184. * or external trigger.
  3185. * @param __HANDLE__ ADC handle
  3186. * @retval SET (software start) or RESET (external trigger)
  3187. */
  3188. #define ADC_IS_SOFTWARE_START_REGULAR(__HANDLE__) \
  3189. (((__HANDLE__)->Instance->CR2 & ADC_CR2_EXTSEL) == ADC_SOFTWARE_START)
  3190. /**
  3191. * @brief Test if conversion trigger of injected group is software start
  3192. * or external trigger.
  3193. * @param __HANDLE__ ADC handle
  3194. * @retval SET (software start) or RESET (external trigger)
  3195. */
  3196. #define ADC_IS_SOFTWARE_START_INJECTED(__HANDLE__) \
  3197. (((__HANDLE__)->Instance->CR2 & ADC_CR2_JEXTSEL) == ADC_INJECTED_SOFTWARE_START)
  3198. /**
  3199. * @brief Simultaneously clears and sets specific bits of the handle State
  3200. * @note: ADC_STATE_CLR_SET() macro is merely aliased to generic macro MODIFY_REG(),
  3201. * the first parameter is the ADC handle State, the second parameter is the
  3202. * bit field to clear, the third and last parameter is the bit field to set.
  3203. * @retval None
  3204. */
  3205. #define ADC_STATE_CLR_SET MODIFY_REG
  3206. /**
  3207. * @brief Clear ADC error code (set it to error code: "no error")
  3208. * @param __HANDLE__ ADC handle
  3209. * @retval None
  3210. */
  3211. #define ADC_CLEAR_ERRORCODE(__HANDLE__) \
  3212. ((__HANDLE__)->ErrorCode = HAL_ADC_ERROR_NONE)
  3213. /**
  3214. * @brief Set ADC number of conversions into regular channel sequence length.
  3215. * @param _NbrOfConversion_ Regular channel sequence length
  3216. * @retval None
  3217. */
  3218. #define ADC_SQR1_L_SHIFT(_NbrOfConversion_) \
  3219. (((_NbrOfConversion_) - (uint8_t)1U) << 20U)
  3220. /**
  3221. * @brief Set the ADC's sample time for channel numbers between 10 and 18.
  3222. * @param _SAMPLETIME_ Sample time parameter.
  3223. * @param _CHANNELNB_ Channel number.
  3224. * @retval None
  3225. */
  3226. #define ADC_SMPR1(_SAMPLETIME_, _CHANNELNB_) \
  3227. ((_SAMPLETIME_) << (3U * ((_CHANNELNB_) - 10U)))
  3228. /**
  3229. * @brief Set the ADC's sample time for channel numbers between 0 and 9.
  3230. * @param _SAMPLETIME_ Sample time parameter.
  3231. * @param _CHANNELNB_ Channel number.
  3232. * @retval None
  3233. */
  3234. #define ADC_SMPR2(_SAMPLETIME_, _CHANNELNB_) \
  3235. ((_SAMPLETIME_) << (3U * (_CHANNELNB_)))
  3236. /**
  3237. * @brief Set the selected regular channel rank for rank between 1 and 6.
  3238. * @param _CHANNELNB_ Channel number.
  3239. * @param _RANKNB_ Rank number.
  3240. * @retval None
  3241. */
  3242. #define ADC_SQR3_RK(_CHANNELNB_, _RANKNB_) \
  3243. ((_CHANNELNB_) << (5U * ((_RANKNB_) - 1U)))
  3244. /**
  3245. * @brief Set the selected regular channel rank for rank between 7 and 12.
  3246. * @param _CHANNELNB_ Channel number.
  3247. * @param _RANKNB_ Rank number.
  3248. * @retval None
  3249. */
  3250. #define ADC_SQR2_RK(_CHANNELNB_, _RANKNB_) \
  3251. ((_CHANNELNB_) << (5U * ((_RANKNB_) - 7U)))
  3252. /**
  3253. * @brief Set the selected regular channel rank for rank between 13 and 16.
  3254. * @param _CHANNELNB_ Channel number.
  3255. * @param _RANKNB_ Rank number.
  3256. * @retval None
  3257. */
  3258. #define ADC_SQR1_RK(_CHANNELNB_, _RANKNB_) \
  3259. ((_CHANNELNB_) << (5U * ((_RANKNB_) - 13U)))
  3260. /**
  3261. * @brief Set the injected sequence length.
  3262. * @param _JSQR_JL_ Sequence length.
  3263. * @retval None
  3264. */
  3265. #define ADC_JSQR_JL_SHIFT(_JSQR_JL_) \
  3266. (((_JSQR_JL_) -1U) << 20U)
  3267. /**
  3268. * @brief Set the selected injected channel rank
  3269. * Note: on STM32F37x devices, channel rank position in JSQR register
  3270. * is depending on total number of ranks selected into
  3271. * injected sequencer (ranks sequence starting from 4-JL)
  3272. * @param _CHANNELNB_ Channel number.
  3273. * @param _RANKNB_ Rank number.
  3274. * @param _JSQR_JL_ Sequence length.
  3275. * @retval None
  3276. */
  3277. #define ADC_JSQR_RK_JL(_CHANNELNB_, _RANKNB_, _JSQR_JL_) \
  3278. ((_CHANNELNB_) << (5U * ((4U - ((_JSQR_JL_) - (_RANKNB_))) - 1U)))
  3279. /**
  3280. * @brief Enable ADC continuous conversion mode.
  3281. * @param _CONTINUOUS_MODE_ Continuous mode.
  3282. * @retval None
  3283. */
  3284. #define ADC_CR2_CONTINUOUS(_CONTINUOUS_MODE_) \
  3285. ((_CONTINUOUS_MODE_) << 1U)
  3286. /**
  3287. * @brief Configures the number of discontinuous conversions for the regular group channels.
  3288. * @param _NBR_DISCONTINUOUS_CONV_ Number of discontinuous conversions.
  3289. * @retval None
  3290. */
  3291. #define ADC_CR1_DISCONTINUOUS_NUM(_NBR_DISCONTINUOUS_CONV_) \
  3292. (((_NBR_DISCONTINUOUS_CONV_) - 1U) << 13U)
  3293. /**
  3294. * @brief Enable ADC scan mode to convert multiple ranks with sequencer.
  3295. * @param _SCAN_MODE_ Scan conversion mode.
  3296. * @retval None
  3297. */
  3298. /* Note: Scan mode is compared to ENABLE for legacy purpose, this parameter */
  3299. /* is equivalent to ADC_SCAN_ENABLE. */
  3300. #define ADC_CR1_SCAN_SET(_SCAN_MODE_) \
  3301. (( ((_SCAN_MODE_) == ADC_SCAN_ENABLE) || ((_SCAN_MODE_) == ENABLE) \
  3302. )? (ADC_SCAN_ENABLE) : (ADC_SCAN_DISABLE) \
  3303. )
  3304. /**
  3305. * @brief Calibration factor in differential mode to be set into calibration register
  3306. * @param _Calibration_Factor_ Calibration factor value
  3307. * @retval None
  3308. */
  3309. #define ADC_CALFACT_DIFF_SET(_Calibration_Factor_) \
  3310. ((_Calibration_Factor_) << 16U)
  3311. /**
  3312. * @brief Calibration factor in differential mode to be retrieved from calibration register
  3313. * @param _Calibration_Factor_ Calibration factor value
  3314. * @retval None
  3315. */
  3316. #define ADC_CALFACT_DIFF_GET(_Calibration_Factor_) \
  3317. ((_Calibration_Factor_) >> 16U)
  3318. /**
  3319. * @brief Get the maximum ADC conversion cycles on all channels.
  3320. * Returns the selected sampling time + conversion time (12.5 ADC clock cycles)
  3321. * Approximation of sampling time within 4 ranges, returns the highest value:
  3322. * below 7.5 cycles {1.5 cycle; 7.5 cycles},
  3323. * between 13.5 cycles and 28.5 cycles {13.5 cycles; 28.5 cycles}
  3324. * between 41.5 cycles and 71.5 cycles {41.5 cycles; 55.5 cycles; 71.5cycles}
  3325. * equal to 239.5 cycles
  3326. * Unit: ADC clock cycles
  3327. * @param __HANDLE__ ADC handle
  3328. * @retval ADC conversion cycles on all channels
  3329. */
  3330. #define ADC_CONVCYCLES_MAX_RANGE(__HANDLE__) \
  3331. (( (((__HANDLE__)->Instance->SMPR2 & ADC_SAMPLETIME_ALLCHANNELS_SMPR2BIT2) == RESET) && \
  3332. (((__HANDLE__)->Instance->SMPR1 & ADC_SAMPLETIME_ALLCHANNELS_SMPR1BIT2) == RESET) ) ? \
  3333. \
  3334. (( (((__HANDLE__)->Instance->SMPR2 & ADC_SAMPLETIME_ALLCHANNELS_SMPR2BIT1) == RESET) && \
  3335. (((__HANDLE__)->Instance->SMPR1 & ADC_SAMPLETIME_ALLCHANNELS_SMPR1BIT1) == RESET) ) ? \
  3336. ADC_CONVERSIONCLOCKCYCLES_SAMPLETIME_7CYCLES5 : ADC_CONVERSIONCLOCKCYCLES_SAMPLETIME_28CYCLES5) \
  3337. : \
  3338. ((((((__HANDLE__)->Instance->SMPR2 & ADC_SAMPLETIME_ALLCHANNELS_SMPR2BIT1) == RESET) && \
  3339. (((__HANDLE__)->Instance->SMPR1 & ADC_SAMPLETIME_ALLCHANNELS_SMPR1BIT1) == RESET)) || \
  3340. ((((__HANDLE__)->Instance->SMPR2 & ADC_SAMPLETIME_ALLCHANNELS_SMPR1BIT0) == RESET) && \
  3341. (((__HANDLE__)->Instance->SMPR1 & ADC_SAMPLETIME_ALLCHANNELS_SMPR1BIT0) == RESET))) ? \
  3342. ADC_CONVERSIONCLOCKCYCLES_SAMPLETIME_71CYCLES5 : ADC_CONVERSIONCLOCKCYCLES_SAMPLETIME_239CYCLES5) \
  3343. )
  3344. /**
  3345. * @brief Get the total ADC clock prescaler (APB2 prescaler x ADC prescaler)
  3346. * from system clock configuration register.
  3347. * Approximation within 3 ranges, returns the higher value:
  3348. * total prescaler minimum: 2 (ADC presc 2, APB2 presc 0)
  3349. * total prescaler 32 (ADC presc 0 and APB2 presc all, or
  3350. * ADC presc {4, 6, 8} and APB2 presc {0, 2, 4})
  3351. * total prescaler maximum: 128 (ADC presc {4, 6, 8} and APB2 presc {8, 16})
  3352. * Unit: none (prescaler factor)
  3353. * @retval ADC and APB2 prescaler factor
  3354. */
  3355. #define ADC_CLOCK_PRESCALER_RANGE() \
  3356. (( (RCC->CFGR & (RCC_CFGR_ADCPRE_1 | RCC_CFGR_ADCPRE_0)) == RESET) ? \
  3357. (( (RCC->CFGR & RCC_CFGR_PPRE2_2) == RESET) ? 2 : 32U ) \
  3358. : \
  3359. (( (RCC->CFGR & RCC_CFGR_PPRE2_1) == RESET) ? 32 : 128U ) \
  3360. )
  3361. /**
  3362. * @brief Get the ADC clock prescaler from system clock configuration register.
  3363. * @retval None
  3364. */
  3365. #define ADC_GET_CLOCK_PRESCALER() (((RCC->CFGR & RCC_CFGR_ADCPRE) >> 14U) +1U)
  3366. #define IS_ADC_DATA_ALIGN(ALIGN) (((ALIGN) == ADC_DATAALIGN_RIGHT) || \
  3367. ((ALIGN) == ADC_DATAALIGN_LEFT) )
  3368. #define IS_ADC_SCAN_MODE(SCAN_MODE) (((SCAN_MODE) == ADC_SCAN_DISABLE) || \
  3369. ((SCAN_MODE) == ADC_SCAN_ENABLE) )
  3370. #define IS_ADC_CHANNEL(CHANNEL) (((CHANNEL) == ADC_CHANNEL_0) || \
  3371. ((CHANNEL) == ADC_CHANNEL_1) || \
  3372. ((CHANNEL) == ADC_CHANNEL_2) || \
  3373. ((CHANNEL) == ADC_CHANNEL_3) || \
  3374. ((CHANNEL) == ADC_CHANNEL_4) || \
  3375. ((CHANNEL) == ADC_CHANNEL_5) || \
  3376. ((CHANNEL) == ADC_CHANNEL_6) || \
  3377. ((CHANNEL) == ADC_CHANNEL_7) || \
  3378. ((CHANNEL) == ADC_CHANNEL_8) || \
  3379. ((CHANNEL) == ADC_CHANNEL_9) || \
  3380. ((CHANNEL) == ADC_CHANNEL_10) || \
  3381. ((CHANNEL) == ADC_CHANNEL_11) || \
  3382. ((CHANNEL) == ADC_CHANNEL_12) || \
  3383. ((CHANNEL) == ADC_CHANNEL_13) || \
  3384. ((CHANNEL) == ADC_CHANNEL_14) || \
  3385. ((CHANNEL) == ADC_CHANNEL_15) || \
  3386. ((CHANNEL) == ADC_CHANNEL_TEMPSENSOR) || \
  3387. ((CHANNEL) == ADC_CHANNEL_VREFINT) || \
  3388. ((CHANNEL) == ADC_CHANNEL_VBAT) )
  3389. #define IS_ADC_SAMPLE_TIME(TIME) (((TIME) == ADC_SAMPLETIME_1CYCLE_5) || \
  3390. ((TIME) == ADC_SAMPLETIME_7CYCLES_5) || \
  3391. ((TIME) == ADC_SAMPLETIME_13CYCLES_5) || \
  3392. ((TIME) == ADC_SAMPLETIME_28CYCLES_5) || \
  3393. ((TIME) == ADC_SAMPLETIME_41CYCLES_5) || \
  3394. ((TIME) == ADC_SAMPLETIME_55CYCLES_5) || \
  3395. ((TIME) == ADC_SAMPLETIME_71CYCLES_5) || \
  3396. ((TIME) == ADC_SAMPLETIME_239CYCLES_5) )
  3397. #define IS_ADC_REGULAR_RANK(CHANNEL) (((CHANNEL) == ADC_REGULAR_RANK_1 ) || \
  3398. ((CHANNEL) == ADC_REGULAR_RANK_2 ) || \
  3399. ((CHANNEL) == ADC_REGULAR_RANK_3 ) || \
  3400. ((CHANNEL) == ADC_REGULAR_RANK_4 ) || \
  3401. ((CHANNEL) == ADC_REGULAR_RANK_5 ) || \
  3402. ((CHANNEL) == ADC_REGULAR_RANK_6 ) || \
  3403. ((CHANNEL) == ADC_REGULAR_RANK_7 ) || \
  3404. ((CHANNEL) == ADC_REGULAR_RANK_8 ) || \
  3405. ((CHANNEL) == ADC_REGULAR_RANK_9 ) || \
  3406. ((CHANNEL) == ADC_REGULAR_RANK_10) || \
  3407. ((CHANNEL) == ADC_REGULAR_RANK_11) || \
  3408. ((CHANNEL) == ADC_REGULAR_RANK_12) || \
  3409. ((CHANNEL) == ADC_REGULAR_RANK_13) || \
  3410. ((CHANNEL) == ADC_REGULAR_RANK_14) || \
  3411. ((CHANNEL) == ADC_REGULAR_RANK_15) || \
  3412. ((CHANNEL) == ADC_REGULAR_RANK_16) )
  3413. #define IS_ADC_EXTTRIG_EDGE(EDGE) (((EDGE) == ADC_EXTERNALTRIGCONVEDGE_NONE) || \
  3414. ((EDGE) == ADC_EXTERNALTRIGCONVEDGE_RISING) )
  3415. #define IS_ADC_EXTTRIG(REGTRIG) (((REGTRIG) == ADC_EXTERNALTRIGCONV_T2_CC2) || \
  3416. ((REGTRIG) == ADC_EXTERNALTRIGCONV_T3_TRGO) || \
  3417. ((REGTRIG) == ADC_EXTERNALTRIGCONV_T4_CC4) || \
  3418. ((REGTRIG) == ADC_EXTERNALTRIGCONV_T19_TRGO) || \
  3419. ((REGTRIG) == ADC_EXTERNALTRIGCONV_T19_CC3) || \
  3420. ((REGTRIG) == ADC_EXTERNALTRIGCONV_T19_CC4) || \
  3421. ((REGTRIG) == ADC_EXTERNALTRIGCONV_EXT_IT11) || \
  3422. ((REGTRIG) == ADC_SOFTWARE_START) )
  3423. #define IS_ADC_EXTTRIGINJEC_EDGE(EDGE) (((EDGE) == ADC_EXTERNALTRIGINJECCONV_EDGE_NONE) || \
  3424. ((EDGE) == ADC_EXTERNALTRIGINJECCONV_EDGE_RISING) )
  3425. #define IS_ADC_EXTTRIGINJEC(INJTRIG) (((INJTRIG) == ADC_EXTERNALTRIGINJECCONV_T2_CC1) || \
  3426. ((INJTRIG) == ADC_EXTERNALTRIGINJECCONV_T2_TRGO) || \
  3427. ((INJTRIG) == ADC_EXTERNALTRIGINJECCONV_T3_CC4) || \
  3428. ((INJTRIG) == ADC_EXTERNALTRIGINJECCONV_T4_TRGO) || \
  3429. ((INJTRIG) == ADC_EXTERNALTRIGINJECCONV_T19_CC1) || \
  3430. ((INJTRIG) == ADC_EXTERNALTRIGINJECCONV_T19_CC2) || \
  3431. ((INJTRIG) == ADC_EXTERNALTRIGINJECCONV_EXT_IT15) || \
  3432. ((INJTRIG) == ADC_INJECTED_SOFTWARE_START) )
  3433. #define IS_ADC_INJECTED_RANK(CHANNEL) (((CHANNEL) == ADC_INJECTED_RANK_1) || \
  3434. ((CHANNEL) == ADC_INJECTED_RANK_2) || \
  3435. ((CHANNEL) == ADC_INJECTED_RANK_3) || \
  3436. ((CHANNEL) == ADC_INJECTED_RANK_4) )
  3437. #define IS_ADC_ANALOG_WATCHDOG_MODE(WATCHDOG) (((WATCHDOG) == ADC_ANALOGWATCHDOG_NONE) || \
  3438. ((WATCHDOG) == ADC_ANALOGWATCHDOG_SINGLE_REG) || \
  3439. ((WATCHDOG) == ADC_ANALOGWATCHDOG_SINGLE_INJEC) || \
  3440. ((WATCHDOG) == ADC_ANALOGWATCHDOG_SINGLE_REGINJEC) || \
  3441. ((WATCHDOG) == ADC_ANALOGWATCHDOG_ALL_REG) || \
  3442. ((WATCHDOG) == ADC_ANALOGWATCHDOG_ALL_INJEC) || \
  3443. ((WATCHDOG) == ADC_ANALOGWATCHDOG_ALL_REGINJEC) )
  3444. #define IS_ADC_CONVERSION_GROUP(CONVERSION) (((CONVERSION) == ADC_REGULAR_GROUP) || \
  3445. ((CONVERSION) == ADC_INJECTED_GROUP) || \
  3446. ((CONVERSION) == ADC_REGULAR_INJECTED_GROUP) )
  3447. #define IS_ADC_EVENT_TYPE(EVENT) ((EVENT) == ADC_AWD_EVENT)
  3448. /** @defgroup ADCEx_range_verification ADC Extended Range Verification
  3449. * For a unique ADC resolution: 12 bits
  3450. * @{
  3451. */
  3452. #define IS_ADC_RANGE(ADC_VALUE) ((ADC_VALUE) <= (0x0FFFU))
  3453. /**
  3454. * @}
  3455. */
  3456. /** @defgroup ADC_injected_nb_conv_verification ADC Injected Conversion Number Verification
  3457. * @{
  3458. */
  3459. #define IS_ADC_INJECTED_NB_CONV(LENGTH) (((LENGTH) >= (1U)) && ((LENGTH) <= (4U)))
  3460. /**
  3461. * @}
  3462. */
  3463. /** @defgroup ADC_regular_nb_conv_verification ADC Regular Conversion Number Verification
  3464. * @{
  3465. */
  3466. #define IS_ADC_REGULAR_NB_CONV(LENGTH) (((LENGTH) >= (1U)) && ((LENGTH) <= (16U)))
  3467. /**
  3468. * @}
  3469. */
  3470. /** @defgroup ADC_regular_discontinuous_mode_number_verification ADC Regular Discontinuous Mode NumberVerification
  3471. * @{
  3472. */
  3473. #define IS_ADC_REGULAR_DISCONT_NUMBER(NUMBER) (((NUMBER) >= (1U)) && ((NUMBER) <= (8U)))
  3474. /**
  3475. * @}
  3476. */
  3477. #endif /* STM32F373xC || STM32F378xx */
  3478. /**
  3479. * @}
  3480. */
  3481. /* Exported functions --------------------------------------------------------*/
  3482. /** @addtogroup ADCEx_Exported_Functions ADCEx Exported Functions
  3483. * @{
  3484. */
  3485. /* Initialization/de-initialization functions *********************************/
  3486. /** @addtogroup ADCEx_Exported_Functions_Group2 ADCEx Input and Output operation functions
  3487. * @{
  3488. */
  3489. /* I/O operation functions ****************************************************/
  3490. /* ADC calibration */
  3491. #if defined(STM32F302xE) || defined(STM32F303xE) || defined(STM32F398xx) || \
  3492. defined(STM32F302xC) || defined(STM32F303xC) || defined(STM32F358xx) || \
  3493. defined(STM32F303x8) || defined(STM32F334x8) || defined(STM32F328xx) || \
  3494. defined(STM32F301x8) || defined(STM32F302x8) || defined(STM32F318xx)
  3495. HAL_StatusTypeDef HAL_ADCEx_Calibration_Start(struct __ADC_HandleTypeDef* hadc, uint32_t SingleDiff);
  3496. uint32_t HAL_ADCEx_Calibration_GetValue(struct __ADC_HandleTypeDef *hadc, uint32_t SingleDiff);
  3497. HAL_StatusTypeDef HAL_ADCEx_Calibration_SetValue(struct __ADC_HandleTypeDef *hadc, uint32_t SingleDiff, uint32_t CalibrationFactor);
  3498. #endif /* STM32F302xE || STM32F303xE || STM32F398xx || */
  3499. /* STM32F302xC || STM32F303xC || STM32F358xx || */
  3500. /* STM32F303x8 || STM32F334x8 || STM32F328xx || */
  3501. /* STM32F301x8 || STM32F302x8 || STM32F318xx */
  3502. #if defined(STM32F373xC) || defined(STM32F378xx)
  3503. HAL_StatusTypeDef HAL_ADCEx_Calibration_Start(struct __ADC_HandleTypeDef* hadc);
  3504. #endif /* STM32F373xC || STM32F378xx */
  3505. /* Blocking mode: Polling */
  3506. HAL_StatusTypeDef HAL_ADCEx_InjectedStart(struct __ADC_HandleTypeDef* hadc);
  3507. HAL_StatusTypeDef HAL_ADCEx_InjectedStop(struct __ADC_HandleTypeDef* hadc);
  3508. HAL_StatusTypeDef HAL_ADCEx_InjectedPollForConversion(struct __ADC_HandleTypeDef* hadc, uint32_t Timeout);
  3509. /* Non-blocking mode: Interruption */
  3510. HAL_StatusTypeDef HAL_ADCEx_InjectedStart_IT(struct __ADC_HandleTypeDef* hadc);
  3511. HAL_StatusTypeDef HAL_ADCEx_InjectedStop_IT(struct __ADC_HandleTypeDef* hadc);
  3512. #if defined(STM32F302xE) || defined(STM32F303xE) || defined(STM32F398xx) || \
  3513. defined(STM32F302xC) || defined(STM32F303xC) || defined(STM32F358xx) || \
  3514. defined(STM32F303x8) || defined(STM32F334x8) || defined(STM32F328xx) || \
  3515. defined(STM32F301x8) || defined(STM32F302x8) || defined(STM32F318xx)
  3516. /* ADC multimode */
  3517. HAL_StatusTypeDef HAL_ADCEx_MultiModeStart_DMA(struct __ADC_HandleTypeDef *hadc, uint32_t *pData, uint32_t Length);
  3518. HAL_StatusTypeDef HAL_ADCEx_MultiModeStop_DMA(struct __ADC_HandleTypeDef *hadc);
  3519. uint32_t HAL_ADCEx_MultiModeGetValue(struct __ADC_HandleTypeDef *hadc);
  3520. #endif /* STM32F302xE || STM32F303xE || STM32F398xx || */
  3521. /* STM32F302xC || STM32F303xC || STM32F358xx || */
  3522. /* STM32F303x8 || STM32F334x8 || STM32F328xx || */
  3523. /* STM32F301x8 || STM32F302x8 || STM32F318xx */
  3524. /* ADC group regular stop conversion without impacting group injected */
  3525. /* Blocking mode: Polling */
  3526. HAL_StatusTypeDef HAL_ADCEx_RegularStop(struct __ADC_HandleTypeDef* hadc);
  3527. /* Non-blocking mode: Interruption */
  3528. HAL_StatusTypeDef HAL_ADCEx_RegularStop_IT(struct __ADC_HandleTypeDef* hadc);
  3529. /* Non-blocking mode: DMA */
  3530. HAL_StatusTypeDef HAL_ADCEx_RegularStop_DMA(struct __ADC_HandleTypeDef* hadc);
  3531. #if defined(STM32F302xE) || defined(STM32F303xE) || defined(STM32F398xx) || \
  3532. defined(STM32F302xC) || defined(STM32F303xC) || defined(STM32F358xx) || \
  3533. defined(STM32F303x8) || defined(STM32F334x8) || defined(STM32F328xx) || \
  3534. defined(STM32F301x8) || defined(STM32F302x8) || defined(STM32F318xx)
  3535. /* ADC multimode */
  3536. HAL_StatusTypeDef HAL_ADCEx_RegularMultiModeStop_DMA(struct __ADC_HandleTypeDef *hadc);
  3537. #endif /* STM32F302xE || STM32F303xE || STM32F398xx || */
  3538. /* STM32F302xC || STM32F303xC || STM32F358xx || */
  3539. /* STM32F303x8 || STM32F334x8 || STM32F328xx || */
  3540. /* STM32F301x8 || STM32F302x8 || STM32F318xx */
  3541. /* ADC retrieve conversion value intended to be used with polling or interruption */
  3542. uint32_t HAL_ADCEx_InjectedGetValue(struct __ADC_HandleTypeDef* hadc, uint32_t InjectedRank);
  3543. /* ADC IRQHandler and Callbacks used in non-blocking modes (Interruption) */
  3544. void HAL_ADCEx_InjectedConvCpltCallback(struct __ADC_HandleTypeDef* hadc);
  3545. #if defined(STM32F302xE) || defined(STM32F303xE) || defined(STM32F398xx) || \
  3546. defined(STM32F302xC) || defined(STM32F303xC) || defined(STM32F358xx) || \
  3547. defined(STM32F303x8) || defined(STM32F334x8) || defined(STM32F328xx) || \
  3548. defined(STM32F301x8) || defined(STM32F302x8) || defined(STM32F318xx)
  3549. void HAL_ADCEx_InjectedQueueOverflowCallback(struct __ADC_HandleTypeDef* hadc);
  3550. void HAL_ADCEx_LevelOutOfWindow2Callback(struct __ADC_HandleTypeDef* hadc);
  3551. void HAL_ADCEx_LevelOutOfWindow3Callback(struct __ADC_HandleTypeDef* hadc);
  3552. #endif /* STM32F302xE || STM32F303xE || STM32F398xx || */
  3553. /* STM32F302xC || STM32F303xC || STM32F358xx || */
  3554. /* STM32F303x8 || STM32F334x8 || STM32F328xx || */
  3555. /* STM32F301x8 || STM32F302x8 || STM32F318xx */
  3556. /**
  3557. * @}
  3558. */
  3559. /** @addtogroup ADCEx_Exported_Functions_Group3 ADCEx Peripheral Control functions
  3560. * @{
  3561. */
  3562. /* Peripheral Control functions ***********************************************/
  3563. HAL_StatusTypeDef HAL_ADCEx_InjectedConfigChannel(struct __ADC_HandleTypeDef* hadc,ADC_InjectionConfTypeDef* sConfigInjected);
  3564. #if defined(STM32F302xE) || defined(STM32F303xE) || defined(STM32F398xx) || \
  3565. defined(STM32F302xC) || defined(STM32F303xC) || defined(STM32F358xx) || \
  3566. defined(STM32F303x8) || defined(STM32F334x8) || defined(STM32F328xx) || \
  3567. defined(STM32F301x8) || defined(STM32F302x8) || defined(STM32F318xx)
  3568. HAL_StatusTypeDef HAL_ADCEx_MultiModeConfigChannel(struct __ADC_HandleTypeDef *hadc, ADC_MultiModeTypeDef *multimode);
  3569. #endif /* STM32F302xE || STM32F303xE || STM32F398xx || */
  3570. /* STM32F302xC || STM32F303xC || STM32F358xx || */
  3571. /* STM32F303x8 || STM32F334x8 || STM32F328xx || */
  3572. /* STM32F301x8 || STM32F302x8 || STM32F318xx */
  3573. /**
  3574. * @}
  3575. */
  3576. /**
  3577. * @}
  3578. */
  3579. /**
  3580. * @}
  3581. */
  3582. /**
  3583. * @}
  3584. */
  3585. #ifdef __cplusplus
  3586. }
  3587. #endif
  3588. #endif /*__STM32F3xx_ADC_H */