12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265 |
- /**
- ******************************************************************************
- * @file ft32f0xx_adc.c
- * @author FMD AE
- * @brief This file provides firmware functions to manage the following
- * functionalities of the Analog to Digital Convertor (ADC) peripheral:
- * + Initialization and Configuration
- * + Power saving
- * + Analog Watchdog configuration
- * + Temperature Sensor, Vrefint (Internal Reference Voltage) and
- * Vbat (Voltage battery) management
- * + ADC Channels Configuration
- * + ADC Channels DMA Configuration
- * + Interrupts and flags management.
- * @version V1.0.0
- * @data 2021-07-01
- ******************************************************************************
- */
- /* Includes ------------------------------------------------------------------*/
- #include "ft32f0xx_adc.h"
- #include "ft32f0xx_rcc.h"
- /* ADC CFGR mask */
- #define CFGR1_CLEAR_MASK ((uint32_t)0xFFFFD203)
- /* Calibration time out */
- #define CALIBRATION_TIMEOUT ((uint32_t)0x0000F000)
- /**
- * @brief Deinitializes ADC1 peripheral registers to their default reset values.
- * @param ADCx: where x can be 1 to select the ADC peripheral.
- * @retval None
- */
- void ADC_DeInit(ADC_TypeDef* ADCx)
- {
- /* Check the parameters */
- assert_param(IS_ADC_ALL_PERIPH(ADCx));
- if(ADCx == ADC1)
- {
- /* Enable ADC1 reset state */
- RCC_APB2PeriphResetCmd(RCC_APB2Periph_ADC1, ENABLE);
- /* Release ADC1 from reset state */
- RCC_APB2PeriphResetCmd(RCC_APB2Periph_ADC1, DISABLE);
- }
- }
- /**
- * @brief Initializes the ADCx peripheral according to the specified parameters
- * in the ADC_InitStruct.
- * @note This function is used to configure the global features of the ADC (
- * Resolution, Data Alignment, continuous mode activation, External
- * trigger source and edge, Sequence Scan Direction).
- * @param ADCx: where x can be 1 to select the ADC peripheral.
- * @param ADC_InitStruct: pointer to an ADC_InitTypeDef structure that contains
- * the configuration information for the specified ADC peripheral.
- * @retval None
- */
- void ADC_Init(ADC_TypeDef* ADCx, ADC_InitTypeDef* ADC_InitStruct)
- {
- uint32_t tmpreg = 0;
- /* Check the parameters */
- assert_param(IS_ADC_ALL_PERIPH(ADCx));
- assert_param(IS_ADC_RESOLUTION(ADC_InitStruct->ADC_Resolution));
- assert_param(IS_FUNCTIONAL_STATE(ADC_InitStruct->ADC_ContinuousConvMode));
- assert_param(IS_ADC_EXT_TRIG_EDGE(ADC_InitStruct->ADC_ExternalTrigConvEdge));
- assert_param(IS_ADC_EXTERNAL_TRIG_CONV(ADC_InitStruct->ADC_ExternalTrigConv));
- assert_param(IS_ADC_DATA_ALIGN(ADC_InitStruct->ADC_DataAlign));
- assert_param(IS_ADC_SCAN_DIRECTION(ADC_InitStruct->ADC_ScanDirection));
- /* Get the ADCx CFGR value */
- tmpreg = ADCx->CFGR1;
- /* Clear SCANDIR, RES[1:0], ALIGN, EXTSEL[2:0], EXTEN[1:0] and CONT bits */
- tmpreg &= CFGR1_CLEAR_MASK;
- /*---------------------------- ADCx CFGR Configuration ---------------------*/
- /* Set RES[1:0] bits according to ADC_Resolution value */
- /* Set CONT bit according to ADC_ContinuousConvMode value */
- /* Set EXTEN[1:0] bits according to ADC_ExternalTrigConvEdge value */
- /* Set EXTSEL[2:0] bits according to ADC_ExternalTrigConv value */
- /* Set ALIGN bit according to ADC_DataAlign value */
- /* Set SCANDIR bit according to ADC_ScanDirection value */
- tmpreg |= (uint32_t)(ADC_InitStruct->ADC_Resolution | ((uint32_t)(ADC_InitStruct->ADC_ContinuousConvMode) << 13) |
- ADC_InitStruct->ADC_ExternalTrigConvEdge | ADC_InitStruct->ADC_ExternalTrigConv |
- ADC_InitStruct->ADC_DataAlign | ADC_InitStruct->ADC_ScanDirection);
- /* Write to ADCx CFGR */
- ADCx->CFGR1 = tmpreg;
- }
- /**
- * @brief Fills each ADC_InitStruct member with its default value.
- * @note This function is used to initialize the global features of the ADC (
- * Resolution, Data Alignment, continuous mode activation, External
- * trigger source and edge, Sequence Scan Direction).
- * @param ADC_InitStruct: pointer to an ADC_InitTypeDef structure which will
- * be initialized.
- * @retval None
- */
- void ADC_StructInit(ADC_InitTypeDef* ADC_InitStruct)
- {
- /* Reset ADC init structure parameters values */
- /* Initialize the ADC_Resolution member */
- ADC_InitStruct->ADC_Resolution = ADC_Resolution_12b;
- /* Initialize the ADC_ContinuousConvMode member */
- ADC_InitStruct->ADC_ContinuousConvMode = DISABLE;
- /* Initialize the ADC_ExternalTrigConvEdge member */
- ADC_InitStruct->ADC_ExternalTrigConvEdge = ADC_ExternalTrigConvEdge_None;
- /* Initialize the ADC_ExternalTrigConv member */
- ADC_InitStruct->ADC_ExternalTrigConv = ADC_ExternalTrigConv_T1_TRGO;
- /* Initialize the ADC_DataAlign member */
- ADC_InitStruct->ADC_DataAlign = ADC_DataAlign_Right;
- /* Initialize the ADC_ScanDirection member */
- ADC_InitStruct->ADC_ScanDirection = ADC_ScanDirection_Upward;
- }
- /**
- * @brief Enables or disables the specified ADC peripheral.
- * @param ADCx: where x can be 1 to select the ADC1 peripheral.
- * @param NewState: new state of the ADCx peripheral.
- * This parameter can be: ENABLE or DISABLE.
- * @retval None
- */
- void ADC_Cmd(ADC_TypeDef* ADCx, FunctionalState NewState)
- {
- /* Check the parameters */
- assert_param(IS_ADC_ALL_PERIPH(ADCx));
- assert_param(IS_FUNCTIONAL_STATE(NewState));
- if (NewState != DISABLE)
- {
- /* Set the ADEN bit to Enable the ADC peripheral */
- ADCx->CR |= (uint32_t)ADC_CR_ADEN;
- }
- else
- {
- /* Set the ADDIS to Disable the ADC peripheral */
- ADCx->CR |= (uint32_t)ADC_CR_ADDIS;
- }
- }
- /**
- * @brief Configure the ADC to either be clocked by the asynchronous clock(which is
- * independent, the dedicated 14MHz clock) or the synchronous clock derived from
- * the APB clock of the ADC bus interface divided by 2 or 4
- * @note This function can be called only when ADC is disabled.
- * @param ADCx: where x can be 1 to select the ADC1 peripheral.
- * @param ADC_ClockMode: This parameter can be :
- * @arg ADC_ClockMode_AsynClk: ADC clocked by the dedicated 14MHz clock
- * @arg ADC_ClockMode_SynClkDiv2: ADC clocked by PCLK/2
- * @arg ADC_ClockMode_SynClkDiv4: ADC clocked by PCLK/4
- * @retval None
- */
- void ADC_ClockModeConfig(ADC_TypeDef* ADCx, uint32_t ADC_ClockMode)
- {
- /* Check the parameters */
- assert_param(IS_ADC_ALL_PERIPH(ADCx));
- assert_param(IS_ADC_CLOCKMODE(ADC_ClockMode));
- /* Configure the ADC Clock mode according to ADC_ClockMode */
- ADCx->CFGR2 = (uint32_t)ADC_ClockMode;
- }
- /**
- * @brief Enables or disables the jitter when the ADC is clocked by PCLK div2
- * or div4
- * @note This function is obsolete and maintained for legacy purpose only. ADC_ClockModeConfig()
- * function should be used instead.
- * @param ADCx: where x can be 1 to select the ADC1 peripheral.
- * @param ADC_JitterOff: This parameter can be :
- * @arg ADC_JitterOff_PCLKDiv2: Remove jitter when ADC is clocked by PLCK divided by 2
- * @arg ADC_JitterOff_PCLKDiv4: Remove jitter when ADC is clocked by PLCK divided by 4
- * @param NewState: new state of the ADCx jitter.
- * This parameter can be: ENABLE or DISABLE.
- * @retval None
- */
- void ADC_JitterCmd(ADC_TypeDef* ADCx, uint32_t ADC_JitterOff, FunctionalState NewState)
- {
- /* Check the parameters */
- assert_param(IS_ADC_ALL_PERIPH(ADCx));
- assert_param(IS_ADC_JITTEROFF(ADC_JitterOff));
- assert_param(IS_FUNCTIONAL_STATE(NewState));
- if (NewState != DISABLE)
- {
- /* Disable Jitter */
- ADCx->CFGR2 |= (uint32_t)ADC_JitterOff;
- }
- else
- {
- /* Enable Jitter */
- ADCx->CFGR2 &= (uint32_t)(~ADC_JitterOff);
- }
- }
- /**
- * @}
- */
- /**
- * @brief Enables or disables the ADC Power Off.
- * @note ADC power-on and power-off can be managed by hardware to cut the
- * consumption when the ADC is not converting.
- * @param ADCx: where x can be 1 to select the ADC1 peripheral.
- * @note The ADC can be powered down:
- * - During the Auto delay phase: The ADC is powered on again at the end
- * of the delay (until the previous data is read from the ADC data register).
- * - During the ADC is waiting for a trigger event: The ADC is powered up
- * at the next trigger event (when the conversion is started).
- * @param NewState: new state of the ADCx power Off.
- * This parameter can be: ENABLE or DISABLE.
- * @retval None
- */
- void ADC_AutoPowerOffCmd(ADC_TypeDef* ADCx, FunctionalState NewState)
- {
- /* Check the parameters */
- assert_param(IS_ADC_ALL_PERIPH(ADCx));
- assert_param(IS_FUNCTIONAL_STATE(NewState));
- if (NewState != DISABLE)
- {
- /* Enable the ADC Automatic Power-Off */
- ADCx->CFGR1 |= ADC_CFGR1_AUTOFF;
- }
- else
- {
- /* Disable the ADC Automatic Power-Off */
- ADCx->CFGR1 &= (uint32_t)~ADC_CFGR1_AUTOFF;
- }
- }
- /**
- * @brief Enables or disables the Wait conversion mode.
- * @note When the CPU clock is not fast enough to manage the data rate, a
- * Hardware delay can be introduced between ADC conversions to reduce
- * this data rate.
- * @note The Hardware delay is inserted after each conversions and until the
- * previous data is read from the ADC data register
- * @note This is a way to automatically adapt the speed of the ADC to the speed
- * of the system which will read the data.
- * @note Any hardware triggers wich occur while a conversion is on going or
- * while the automatic Delay is applied are ignored
- * @param ADCx: where x can be 1 to select the ADC1 peripheral.
- * @param NewState: new state of the ADCx Auto-Delay.
- * This parameter can be: ENABLE or DISABLE.
- * @retval None
- */
- void ADC_WaitModeCmd(ADC_TypeDef* ADCx, FunctionalState NewState)
- {
- /* Check the parameters */
- assert_param(IS_ADC_ALL_PERIPH(ADCx));
- assert_param(IS_FUNCTIONAL_STATE(NewState));
- if (NewState != DISABLE)
- {
- /* Enable the ADC Automatic Delayed conversion */
- ADCx->CFGR1 |= ADC_CFGR1_WAIT;
- }
- else
- {
- /* Disable the ADC Automatic Delayed conversion */
- ADCx->CFGR1 &= (uint32_t)~ADC_CFGR1_WAIT;
- }
- }
- /**
- * @}
- */
- /**
- * @brief Enables or disables the analog watchdog
- * @param ADCx: where x can be 1 to select the ADC1 peripheral.
- * @param NewState: new state of the ADCx Analog Watchdog.
- * This parameter can be: ENABLE or DISABLE.
- * @retval None
- */
- void ADC_AnalogWatchdogCmd(ADC_TypeDef* ADCx, FunctionalState NewState)
- {
- /* Check the parameters */
- assert_param(IS_ADC_ALL_PERIPH(ADCx));
- assert_param(IS_FUNCTIONAL_STATE(NewState));
- if (NewState != DISABLE)
- {
- /* Enable the ADC Analog Watchdog */
- ADCx->CFGR1 |= ADC_CFGR1_AWDEN;
- }
- else
- {
- /* Disable the ADC Analog Watchdog */
- ADCx->CFGR1 &= (uint32_t)~ADC_CFGR1_AWDEN;
- }
- }
- /**
- * @brief Configures the high and low thresholds of the analog watchdog.
- * @param ADCx: where x can be 1 to select the ADC1 peripheral.
- * @param HighThreshold: the ADC analog watchdog High threshold value.
- * This parameter must be a 12bit value.
- * @param LowThreshold: the ADC analog watchdog Low threshold value.
- * This parameter must be a 12bit value.
- * @retval None
- */
- void ADC_AnalogWatchdogThresholdsConfig(ADC_TypeDef* ADCx, uint16_t HighThreshold,
- uint16_t LowThreshold)
- {
- /* Check the parameters */
- assert_param(IS_ADC_ALL_PERIPH(ADCx));
- assert_param(IS_ADC_THRESHOLD(HighThreshold));
- assert_param(IS_ADC_THRESHOLD(LowThreshold));
- /* Set the ADCx high and low threshold */
- ADCx->TR = LowThreshold | ((uint32_t)HighThreshold << 16);
- }
- /**
- * @brief Configures the analog watchdog guarded single channel
- * @param ADCx: where x can be 1 to select the ADC1 peripheral.
- * @param ADC_AnalogWatchdog_Channel: the ADC channel to configure for the analog watchdog.
- * This parameter can be one of the following values:
- * @arg ADC_AnalogWatchdog_Channel_0: ADC Channel0 selected
- * @arg ADC_AnalogWatchdog_Channel_1: ADC Channel1 selected
- * @arg ADC_AnalogWatchdog_Channel_2: ADC Channel2 selected
- * @arg ADC_AnalogWatchdog_Channel_3: ADC Channel3 selected
- * @arg ADC_AnalogWatchdog_Channel_4: ADC Channel4 selected
- * @arg ADC_AnalogWatchdog_Channel_5: ADC Channel5 selected
- * @arg ADC_AnalogWatchdog_Channel_6: ADC Channel6 selected
- * @arg ADC_AnalogWatchdog_Channel_7: ADC Channel7 selected
- * @arg ADC_AnalogWatchdog_Channel_8: ADC Channel8 selected
- * @arg ADC_AnalogWatchdog_Channel_9: ADC Channel9 selected
- * @arg ADC_AnalogWatchdog_Channel_10: ADC Channel10 selected
- * @arg ADC_AnalogWatchdog_Channel_11: ADC Channel11 selected
- * @arg ADC_AnalogWatchdog_Channel_12: ADC Channel12 selected
- * @arg ADC_AnalogWatchdog_Channel_13: ADC Channel13 selected
- * @arg ADC_AnalogWatchdog_Channel_14: ADC Channel14 selected
- * @arg ADC_AnalogWatchdog_Channel_15: ADC Channel15 selected
- * @arg ADC_AnalogWatchdog_Channel_16: ADC Channel16 selected
- * @arg ADC_AnalogWatchdog_Channel_17: ADC Channel17 selected
- * @arg ADC_AnalogWatchdog_Channel_18: ADC Channel18 selected
- * @note The channel selected on the AWDCH must be also set into the CHSELR
- * register
- * @retval None
- */
- void ADC_AnalogWatchdogSingleChannelConfig(ADC_TypeDef* ADCx, uint32_t ADC_AnalogWatchdog_Channel)
- {
- uint32_t tmpreg = 0;
- /* Check the parameters */
- assert_param(IS_ADC_ALL_PERIPH(ADCx));
- assert_param(IS_ADC_ANALOG_WATCHDOG_CHANNEL(ADC_AnalogWatchdog_Channel));
- /* Get the old register value */
- tmpreg = ADCx->CFGR1;
- /* Clear the Analog watchdog channel select bits */
- tmpreg &= ~ADC_CFGR1_AWDCH;
- /* Set the Analog watchdog channel */
- tmpreg |= ADC_AnalogWatchdog_Channel;
- /* Store the new register value */
- ADCx->CFGR1 = tmpreg;
- }
- /**
- * @brief Enables or disables the ADC Analog Watchdog Single Channel.
- * @param ADCx: where x can be 1 to select the ADC1 peripheral.
- * @param NewState: new state of the ADCx ADC Analog Watchdog Single Channel.
- * This parameter can be: ENABLE or DISABLE.
- * @retval None
- */
- void ADC_AnalogWatchdogSingleChannelCmd(ADC_TypeDef* ADCx, FunctionalState NewState)
- {
- /* Check the parameters */
- assert_param(IS_ADC_ALL_PERIPH(ADCx));
- assert_param(IS_FUNCTIONAL_STATE(NewState));
- if (NewState != DISABLE)
- {
- /* Enable the ADC Analog Watchdog Single Channel */
- ADCx->CFGR1 |= ADC_CFGR1_AWDSGL;
- }
- else
- {
- /* Disable the ADC Analog Watchdog Single Channel */
- ADCx->CFGR1 &= (uint32_t)~ADC_CFGR1_AWDSGL;
- }
- }
- /**
- * @}
- */
- /**
- * @brief Enables or disables the temperature sensor channel.
- * @param NewState: new state of the temperature sensor input channel.
- * This parameter can be: ENABLE or DISABLE.
- * @retval None
- */
- void ADC_TempSensorCmd(FunctionalState NewState)
- {
- /* Check the parameters */
- assert_param(IS_FUNCTIONAL_STATE(NewState));
- if (NewState != DISABLE)
- {
- /* Enable the temperature sensor channel*/
- ADC->CCR |= (uint32_t)ADC_CCR_TSEN;
- }
- else
- {
- /* Disable the temperature sensor channel*/
- ADC->CCR &= (uint32_t)(~ADC_CCR_TSEN);
- }
- }
- /**
- * @brief Enables or disables the Vrefint channel.
- * @param NewState: new state of the Vref input channel.
- * This parameter can be: ENABLE or DISABLE.
- * @retval None
- */
- void ADC_VrefintCmd(FunctionalState NewState)
- {
- /* Check the parameters */
- assert_param(IS_FUNCTIONAL_STATE(NewState));
- if (NewState != DISABLE)
- {
- /* Enable the Vrefint channel*/
- ADC->CCR |= (uint32_t)ADC_CCR_VREFEN;
- }
- else
- {
- /* Disable the Vrefint channel*/
- ADC->CCR &= (uint32_t)(~ADC_CCR_VREFEN);
- }
- }
- /**
- * @brief Enables or disables the Vbat channel.
- * @note This feature is not applicable for FT32F030 devices.
- * @param NewState: new state of the Vbat input channel.
- * This parameter can be: ENABLE or DISABLE.
- * @retval None
- */
- void ADC_VbatCmd(FunctionalState NewState)
- {
- /* Check the parameters */
- assert_param(IS_FUNCTIONAL_STATE(NewState));
- if (NewState != DISABLE)
- {
- /* Enable the Vbat channel*/
- ADC->CCR |= (uint32_t)ADC_CCR_VBATEN;
- }
- else
- {
- /* Disable the Vbat channel*/
- ADC->CCR &= (uint32_t)(~ADC_CCR_VBATEN);
- }
- }
- /**
- * @}
- */
- /**
- * @brief Configures for the selected ADC and its sampling time.
- * @param ADCx: where x can be 1 to select the ADC peripheral.
- * @param ADC_Channel: the ADC channel to configure.
- * This parameter can be any combination of the following values:
- * @arg ADC_Channel_0: ADC Channel0 selected
- * @arg ADC_Channel_1: ADC Channel1 selected
- * @arg ADC_Channel_2: ADC Channel2 selected
- * @arg ADC_Channel_3: ADC Channel3 selected
- * @arg ADC_Channel_4: ADC Channel4 selected
- * @arg ADC_Channel_5: ADC Channel5 selected
- * @arg ADC_Channel_6: ADC Channel6 selected
- * @arg ADC_Channel_7: ADC Channel7 selected
- * @arg ADC_Channel_8: ADC Channel8 selected
- * @arg ADC_Channel_9: ADC Channel9 selected
- * @arg ADC_Channel_10: ADC Channel10 selected,
- * @arg ADC_Channel_11: ADC Channel11 selected,
- * @arg ADC_Channel_12: ADC Channel12 selected,
- * @arg ADC_Channel_13: ADC Channel13 selected,
- * @arg ADC_Channel_14: ADC Channel14 selected,
- * @arg ADC_Channel_15: ADC Channel15 selected,
- * @arg ADC_Channel_16: ADC Channel16 selected
- * @arg ADC_Channel_17: ADC Channel17 selected
- * @arg ADC_Channel_18: ADC Channel18 selected,
- * @arg ADC_Channel_19: ADC Channel19 selected,
- * @arg ADC_Channel_20: ADC Channel20 selected,
- * @arg ADC_Channel_21: ADC Channel21 selected,
- * @param ADC_SampleTime: The sample time value to be set for the selected channel.
- * This parameter can be one of the following values:
- * @arg ADC_SampleTime_1_5Cycles: Sample time equal to 1.5 cycles
- * @arg ADC_SampleTime_7_5Cycles: Sample time equal to 7.5 cycles
- * @arg ADC_SampleTime_13_5Cycles: Sample time equal to 13.5 cycles
- * @arg ADC_SampleTime_28_5Cycles: Sample time equal to 28.5 cycles
- * @arg ADC_SampleTime_41_5Cycles: Sample time equal to 41.5 cycles
- * @arg ADC_SampleTime_55_5Cycles: Sample time equal to 55.5 cycles
- * @arg ADC_SampleTime_71_5Cycles: Sample time equal to 71.5 cycles
- * @arg ADC_SampleTime_239_5Cycles: Sample time equal to 239.5 cycles
- * @retval None
- */
- void ADC_ChannelConfig(ADC_TypeDef* ADCx, uint32_t ADC_Channel, uint32_t ADC_SampleTime)
- {
- uint32_t tmpreg = 0;
- /* Check the parameters */
- assert_param(IS_ADC_ALL_PERIPH(ADCx));
- assert_param(IS_ADC_CHANNEL(ADC_Channel));
- assert_param(IS_ADC_SAMPLE_TIME(ADC_SampleTime));
- /* Configure the ADC Channel */
- ADCx->CHSELR |= (uint32_t)ADC_Channel;
- /* Clear the Sampling time Selection bits */
- tmpreg &= ~ADC_SMPR1_SMPR;
- /* Set the ADC Sampling Time register */
- tmpreg |= (uint32_t)ADC_SampleTime;
- /* Configure the ADC Sample time register */
- ADCx->SMPR = tmpreg ;
- }
- /**
- * @brief Enable the Continuous mode for the selected ADCx channels.
- * @param ADCx: where x can be 1 to select the ADC1 peripheral.
- * @param NewState: new state of the Continuous mode.
- * This parameter can be: ENABLE or DISABLE.
- * @note It is not possible to have both discontinuous mode and continuous mode
- * enabled. In this case (If DISCEN and CONT are Set), the ADC behaves
- * as if continuous mode was disabled
- * @retval None
- */
- void ADC_ContinuousModeCmd(ADC_TypeDef* ADCx, FunctionalState NewState)
- {
- /* Check the parameters */
- assert_param(IS_ADC_ALL_PERIPH(ADCx));
- assert_param(IS_FUNCTIONAL_STATE(NewState));
- if (NewState != DISABLE)
- {
- /* Enable the Continuous mode*/
- ADCx->CFGR1 |= (uint32_t)ADC_CFGR1_CONT;
- }
- else
- {
- /* Disable the Continuous mode */
- ADCx->CFGR1 &= (uint32_t)(~ADC_CFGR1_CONT);
- }
- }
- /**
- * @brief Enable the discontinuous mode for the selected ADC channels.
- * @param ADCx: where x can be 1 to select the ADC1 peripheral.
- * @param NewState: new state of the discontinuous mode.
- * This parameter can be: ENABLE or DISABLE.
- * @note It is not possible to have both discontinuous mode and continuous mode
- * enabled. In this case (If DISCEN and CONT are Set), the ADC behaves
- * as if continuous mode was disabled
- * @retval None
- */
- void ADC_DiscModeCmd(ADC_TypeDef* ADCx, FunctionalState NewState)
- {
- /* Check the parameters */
- assert_param(IS_ADC_ALL_PERIPH(ADCx));
- assert_param(IS_FUNCTIONAL_STATE(NewState));
- if (NewState != DISABLE)
- {
- /* Enable the Discontinuous mode */
- ADCx->CFGR1 |= (uint32_t)ADC_CFGR1_DISCEN;
- }
- else
- {
- /* Disable the Discontinuous mode */
- ADCx->CFGR1 &= (uint32_t)(~ADC_CFGR1_DISCEN);
- }
- }
- /**
- * @brief Enable the Overrun mode for the selected ADC channels.
- * @param ADCx: where x can be 1 to select the ADC1 peripheral.
- * @param NewState: new state of the Overrun mode.
- * This parameter can be: ENABLE or DISABLE.
- * @retval None
- */
- void ADC_OverrunModeCmd(ADC_TypeDef* ADCx, FunctionalState NewState)
- {
- /* Check the parameters */
- assert_param(IS_ADC_ALL_PERIPH(ADCx));
- assert_param(IS_FUNCTIONAL_STATE(NewState));
- if (NewState != DISABLE)
- {
- /* Enable the Overrun mode */
- ADCx->CFGR1 |= (uint32_t)ADC_CFGR1_OVRMOD;
- }
- else
- {
- /* Disable the Overrun mode */
- ADCx->CFGR1 &= (uint32_t)(~ADC_CFGR1_OVRMOD);
- }
- }
- /**
- * @brief Active the Calibration operation for the selected ADC.
- * @note The Calibration can be initiated only when ADC is still in the
- * reset configuration (ADEN must be equal to 0).
- * @param ADCx: where x can be 1 to select the ADC1 peripheral.
- * @retval ADC Calibration factor
- */
- uint32_t ADC_GetCalibrationFactor(ADC_TypeDef* ADCx)
- {
- uint32_t tmpreg = 0, calibrationcounter = 0, calibrationstatus = 0;
- /* Check the parameters */
- assert_param(IS_ADC_ALL_PERIPH(ADCx));
- /* Set the ADC calibartion */
- ADCx->CR |= (uint32_t)ADC_CR_ADCAL;
- /* Wait until no ADC calibration is completed */
- do
- {
- calibrationstatus = ADCx->CR & ADC_CR_ADCAL;
- calibrationcounter++;
- } while((calibrationcounter != CALIBRATION_TIMEOUT) && (calibrationstatus != 0x00));
- if((uint32_t)(ADCx->CR & ADC_CR_ADCAL) == RESET)
- {
- /*Get the calibration factor from the ADC data register */
- tmpreg = ADCx->DR;
- }
- else
- {
- /* Error factor */
- tmpreg = 0x00000000;
- }
- return tmpreg;
- }
- /**
- * @brief Stop the on going conversions for the selected ADC.
- * @note When ADSTP is set, any on going conversion is aborted, and the ADC
- * data register is not updated with current conversion.
- * @param ADCx: where x can be 1 to select the ADC1 peripheral.
- * @retval None
- */
- void ADC_StopOfConversion(ADC_TypeDef* ADCx)
- {
- /* Check the parameters */
- assert_param(IS_ADC_ALL_PERIPH(ADCx));
- ADCx->CR |= (uint32_t)ADC_CR_ADSTP;
- }
- /**
- * @brief Start Conversion for the selected ADC channels.
- * @note In continuous mode, ADSTART is not cleared by hardware with the
- * assertion of EOSEQ because the sequence is automatic relaunched
- * @param ADCx: where x can be 1 to select the ADC1 peripheral.
- * @retval None
- */
- void ADC_StartOfConversion(ADC_TypeDef* ADCx)
- {
- /* Check the parameters */
- assert_param(IS_ADC_ALL_PERIPH(ADCx));
- ADCx->CR |= (uint32_t)ADC_CR_ADSTART;
- }
- /**
- * @brief Returns the last ADCx conversion result data for ADC channel.
- * @param ADCx: where x can be 1 to select the ADC1 peripheral.
- * @retval The Data conversion value.
- */
- uint16_t ADC_GetConversionValue(ADC_TypeDef* ADCx)
- {
- /* Check the parameters */
- assert_param(IS_ADC_ALL_PERIPH(ADCx));
- /* Return the selected ADC conversion value */
- return (uint16_t) ADCx->DR;
- }
- /**
- * @}
- */
- /**
- * @brief Enables or disables the specified ADC DMA request.
- * @param ADCx: where x can be 1 to select the ADC1 peripheral.
- * @param NewState: new state of the selected ADC DMA transfer.
- * This parameter can be: ENABLE or DISABLE.
- * @retval None
- */
- void ADC_DMACmd(ADC_TypeDef* ADCx, FunctionalState NewState)
- {
- /* Check the parameters */
- assert_param(IS_ADC_ALL_PERIPH(ADCx));
- assert_param(IS_FUNCTIONAL_STATE(NewState));
- if (NewState != DISABLE)
- {
- /* Enable the selected ADC DMA request */
- ADCx->CFGR1 |= (uint32_t)ADC_CFGR1_DMAEN;
- }
- else
- {
- /* Disable the selected ADC DMA request */
- ADCx->CFGR1 &= (uint32_t)(~ADC_CFGR1_DMAEN);
- }
- }
- /**
- * @brief Enables or disables the ADC DMA request after last transfer (Single-ADC mode)
- * @param ADCx: where x can be 1 to select the ADC1 peripheral.
- * @param ADC_DMARequestMode: the ADC channel to configure.
- * This parameter can be one of the following values:
- * @arg ADC_DMAMode_OneShot: DMA One Shot Mode
- * @arg ADC_DMAMode_Circular: DMA Circular Mode
- * @retval None
- */
- void ADC_DMARequestModeConfig(ADC_TypeDef* ADCx, uint32_t ADC_DMARequestMode)
- {
- /* Check the parameters */
- assert_param(IS_ADC_ALL_PERIPH(ADCx));
- ADCx->CFGR1 &= (uint32_t)~ADC_CFGR1_DMACFG;
- ADCx->CFGR1 |= (uint32_t)ADC_DMARequestMode;
- }
- /**
- * @}
- */
- /**
- * @brief Enables or disables the specified ADC interrupts.
- * @param ADCx: where x can be 1 to select the ADC peripheral.
- * @param ADC_IT: specifies the ADC interrupt sources to be enabled or disabled.
- * This parameter can be one of the following values:
- * @arg ADC_IT_ADRDY: ADC ready interrupt
- * @arg ADC_IT_EOSMP: End of sampling interrupt
- * @arg ADC_IT_EOC: End of conversion interrupt
- * @arg ADC_IT_EOSEQ: End of sequence of conversion interrupt
- * @arg ADC_IT_OVR: overrun interrupt
- * @arg ADC_IT_AWD: Analog watchdog interrupt
- * @param NewState: new state of the specified ADC interrupts.
- * This parameter can be: ENABLE or DISABLE.
- * @retval None
- */
- void ADC_ITConfig(ADC_TypeDef* ADCx, uint32_t ADC_IT, FunctionalState NewState)
- {
- /* Check the parameters */
- assert_param(IS_ADC_ALL_PERIPH(ADCx));
- assert_param(IS_FUNCTIONAL_STATE(NewState));
- assert_param(IS_ADC_CONFIG_IT(ADC_IT));
- if (NewState != DISABLE)
- {
- /* Enable the selected ADC interrupts */
- ADCx->IER |= ADC_IT;
- }
- else
- {
- /* Disable the selected ADC interrupts */
- ADCx->IER &= (~(uint32_t)ADC_IT);
- }
- }
- /**
- * @brief Checks whether the specified ADC flag is set or not.
- * @param ADCx: where x can be 1 to select the ADC1 peripheral.
- * @param ADC_FLAG: specifies the flag to check.
- * This parameter can be one of the following values:
- * @arg ADC_FLAG_AWD: Analog watchdog flag
- * @arg ADC_FLAG_OVR: Overrun flag
- * @arg ADC_FLAG_EOSEQ: End of Sequence flag
- * @arg ADC_FLAG_EOC: End of conversion flag
- * @arg ADC_FLAG_EOSMP: End of sampling flag
- * @arg ADC_FLAG_ADRDY: ADC Ready flag
- * @arg ADC_FLAG_ADEN: ADC enable flag
- * @arg ADC_FLAG_ADDIS: ADC disable flag
- * @arg ADC_FLAG_ADSTART: ADC start flag
- * @arg ADC_FLAG_ADSTP: ADC stop flag
- * @arg ADC_FLAG_ADCAL: ADC Calibration flag
- * @retval The new state of ADC_FLAG (SET or RESET).
- */
- FlagStatus ADC_GetFlagStatus(ADC_TypeDef* ADCx, uint32_t ADC_FLAG)
- {
- FlagStatus bitstatus = RESET;
- uint32_t tmpreg = 0;
- /* Check the parameters */
- assert_param(IS_ADC_ALL_PERIPH(ADCx));
- assert_param(IS_ADC_GET_FLAG(ADC_FLAG));
- if((uint32_t)(ADC_FLAG & 0x01000000))
- {
- tmpreg = ADCx->CR & 0xFEFFFFFF;
- }
- else
- {
- tmpreg = ADCx->ISR;
- }
- /* Check the status of the specified ADC flag */
- if ((tmpreg & ADC_FLAG) != (uint32_t)RESET)
- {
- /* ADC_FLAG is set */
- bitstatus = SET;
- }
- else
- {
- /* ADC_FLAG is reset */
- bitstatus = RESET;
- }
- /* Return the ADC_FLAG status */
- return bitstatus;
- }
- /**
- * @brief Clears the ADCx's pending flags.
- * @param ADCx: where x can be 1 to select the ADC1 peripheral.
- * @param ADC_FLAG: specifies the flag to clear.
- * This parameter can be any combination of the following values:
- * @arg ADC_FLAG_AWD: Analog watchdog flag
- * @arg ADC_FLAG_EOC: End of conversion flag
- * @arg ADC_FLAG_ADRDY: ADC Ready flag
- * @arg ADC_FLAG_EOSMP: End of sampling flag
- * @arg ADC_FLAG_EOSEQ: End of Sequence flag
- * @arg ADC_FLAG_OVR: Overrun flag
- * @retval None
- */
- void ADC_ClearFlag(ADC_TypeDef* ADCx, uint32_t ADC_FLAG)
- {
- /* Check the parameters */
- assert_param(IS_ADC_ALL_PERIPH(ADCx));
- assert_param(IS_ADC_CLEAR_FLAG(ADC_FLAG));
- /* Clear the selected ADC flags */
- ADCx->ISR = (uint32_t)ADC_FLAG;
- }
- /**
- * @brief Checks whether the specified ADC interrupt has occurred or not.
- * @param ADCx: where x can be 1 to select the ADC1 peripheral
- * @param ADC_IT: specifies the ADC interrupt source to check.
- * This parameter can be one of the following values:
- * @arg ADC_IT_ADRDY: ADC ready interrupt
- * @arg ADC_IT_EOSMP: End of sampling interrupt
- * @arg ADC_IT_EOC: End of conversion interrupt
- * @arg ADC_IT_EOSEQ: End of sequence of conversion interrupt
- * @arg ADC_IT_OVR: overrun interrupt
- * @arg ADC_IT_AWD: Analog watchdog interrupt
- * @retval The new state of ADC_IT (SET or RESET).
- */
- ITStatus ADC_GetITStatus(ADC_TypeDef* ADCx, uint32_t ADC_IT)
- {
- ITStatus bitstatus = RESET;
- uint32_t enablestatus = 0;
- /* Check the parameters */
- assert_param(IS_ADC_ALL_PERIPH(ADCx));
- assert_param(IS_ADC_GET_IT(ADC_IT));
- /* Get the ADC_IT enable bit status */
- enablestatus = (uint32_t)(ADCx->IER & ADC_IT);
- /* Check the status of the specified ADC interrupt */
- if (((uint32_t)(ADCx->ISR & ADC_IT) != (uint32_t)RESET) && (enablestatus != (uint32_t)RESET))
- {
- /* ADC_IT is set */
- bitstatus = SET;
- }
- else
- {
- /* ADC_IT is reset */
- bitstatus = RESET;
- }
- /* Return the ADC_IT status */
- return bitstatus;
- }
- /**
- * @brief Clears the ADCx's interrupt pending bits.
- * @param ADCx: where x can be 1 to select the ADC1 peripheral.
- * @param ADC_IT: specifies the ADC interrupt pending bit to clear.
- * This parameter can be one of the following values:
- * @arg ADC_IT_ADRDY: ADC ready interrupt
- * @arg ADC_IT_EOSMP: End of sampling interrupt
- * @arg ADC_IT_EOC: End of conversion interrupt
- * @arg ADC_IT_EOSEQ: End of sequence of conversion interrupt
- * @arg ADC_IT_OVR: overrun interrupt
- * @arg ADC_IT_AWD: Analog watchdog interrupt
- * @retval None
- */
- void ADC_ClearITPendingBit(ADC_TypeDef* ADCx, uint32_t ADC_IT)
- {
- /* Check the parameters */
- assert_param(IS_ADC_ALL_PERIPH(ADCx));
- assert_param(IS_ADC_CLEAR_IT(ADC_IT));
- /* Clear the selected ADC interrupt pending bits */
- ADCx->ISR = (uint32_t)ADC_IT;
- }
- /**
- * @brief select the ADC VREF.
- * @param ADC_Vrefsel: The sVREF value to be set for the ADC.
- This parameter can be one of the following values:
- * @arg ADC_Vrefsel_0_625V: VREF 0.625V selected
- * @arg ADC_Vrefsel_1_5V: VREF 1.5V selected
- * @arg ADC_Vrefsel_2_5V: VREF 2.5V selected
- * @arg ADC_Vrefsel_VDDA: VREF VDDA selected
- * @retval None
- */
- void ADC_VrefselConfig(uint32_t ADC_Vrefsel)
- {
- uint32_t tmpreg = 0;
- /* Check the parameters */
- assert_param(IS_ADC_Vrefsel(ADC_Vrefsel));
- /* Read CR2 register */
- tmpreg = ADC->CR2;
- /* Clear the Vref Selection bits */
- tmpreg &= ~((uint32_t)0x0000000E) ;
- /* Set the ADC Vref register */
- tmpreg |= (uint32_t)ADC_Vrefsel;
- /* Configure the ADC Vref register */
- ADC->CR2 = tmpreg;
- }
- /**
- * @brief Enable Reference voltage halved.
- * @param NewState: new state of the reference voltage halved.
- * This parameter can be: ENABLE or DISABLE.
- * @note None
- * @retval None
- */
- void ADC_VrefDecibCmd(FunctionalState NewState)
- {
- /* Check the parameters */
- assert_param(IS_FUNCTIONAL_STATE(NewState));
- if (NewState != DISABLE)
- {
- /* Enable the Discontinuous mode */
- ADC->CR2 |= (uint32_t)ADC_CR2_VREF_DECIB;
- }
- else
- {
- /* Disable the Discontinuous mode */
- ADC->CR2 &= (uint32_t)(~ADC_CR2_VREF_DECIB);
- }
- }
- /**
- * @brief Sampling hold circuit sampling enable or disable.
- * @param SmpEn:
- * @arg ADC_IOSH1_SMPEN
- * @arg ADC_IOSH2_SMPEN
- * @param NewState: new state of SMP.
- * This parameter can be: ENABLE or DISABLE.
- * @note None
- * @retval None
- */
- void ADC_IoshSmpCmd(uint32_t SmpEn, FunctionalState NewState)
- {
- /* Check the parameters */
- assert_param(IS_ADC_SMPEN(SmpEn));
- assert_param(IS_FUNCTIONAL_STATE(NewState));
- if (NewState != DISABLE)
- {
- ADC->CR2 |= SmpEn;
- }
- else
- {
- ADC->CR2 &= ~SmpEn;
- }
- }
- /**
- * @brief The hold enable bit of the sample-hold circuit.
- * @param SmpEn:
- * @arg ADC_IOSH1_AMPEN
- * @arg ADC_IOSH2_AMPEN
- * @param NewState: new state of AMP.
- * This parameter can be: ENABLE or DISABLE.
- * @note None
- * @retval None
- */
- void ADC_IoshAmpCmd(uint32_t AmpEn, FunctionalState NewState)
- {
- /* Check the parameters */
- assert_param(IS_ADC_AMPEN(AmpEn));
- assert_param(IS_FUNCTIONAL_STATE(NewState));
- if (NewState != DISABLE)
- {
- ADC->CR2 |= AmpEn;
- }
- else
- {
- ADC->CR2 &= ~AmpEn;
- }
- }
- /**
- * @brief Input source selection.
- * @param Ioshx:
- * @arg ADC_CR2_IOSH1_SEL
- * @arg ADC_CR2_IOSH2_SEL
- * @param SmpSel:
- * if Ioshx is ADC_CR2_IOSH1_SEL,the SmpSel can be
- * @arg ADC_IOSH1_SMPSEL_PB1
- * @arg ADC_IOSH1_SMPSEL_OP1OUT
- * if Ioshx is ADC_CR2_IOSH2_SEL,the SmpSel can be
- * @arg ADC_IOSH2_SMPSEL_PB0
- * @arg ADC_IOSH2_SMPSEL_OP2OUT
- * @note None
- * @retval None
- */
- #if defined (FT32F072xB)
- void ADC_IoshSmpSel(uint32_t Ioshx, uint32_t SmpSel)
- {
- uint32_t tmpreg = 0;
- /* Check the parameters */
- assert_param(IS_ADC_IOSH(Ioshx));
- assert_param(IS_ADC_SMPSEL(SmpSel));
- /* Read CR2 register */
- tmpreg = ADC->CR2;
- if (Ioshx != ADC_CR2_IOSH1_SEL)
- {
- /* IOSH2 */
- tmpreg &= ~ADC_CR2_IOSH2_SEL;
- }
- else
- {
- /* IOSH1 */
- tmpreg &= ~ADC_CR2_IOSH1_SEL;
- }
- tmpreg |= SmpSel;
- /* Config CR2 register */
- ADC->CR2 = tmpreg;
- }
- /**
- * @brief The hold enable bit of the sample-hold circuit.
- * @param SmpModBit:
- * @arg ADC_CR2_IOSH1_SMPMOD
- * @arg ADC_CR2_IOSH2_SMPMOD
- * @param Mode:
- * @arg ADC_SMP_SOFTWARE_MODE
- * @arg ADC_SMP_HARDWARE_MODE
- * @note None
- * @retval None
- */
- void ADC_IoshSmpMod(uint32_t SmpModBit, uint32_t Mode)
- {
- uint32_t tmpreg = 0;
- /* Check the parameters */
- assert_param(IS_ADC_SMPMOD(SmpModBit));
- assert_param(IS_ADC_MODE(Mode));
- /* Read CR2 register */
- tmpreg = ADC->CR2;
- if (Mode != ADC_SMP_SOFTWARE_MODE)
- {
- /* Hardware mode */
- if (SmpModBit != ADC_CR2_IOSH1_SMPMOD)
- {
- /* IOSH2 */
- tmpreg |= ADC_CR2_IOSH2_SMPMOD | ADC_CR2_IOSH2_AMPEN;
- }
- else
- {
- /* IOSH1 */
- tmpreg |= ADC_CR2_IOSH1_SMPMOD | ADC_CR2_IOSH1_AMPEN;
- }
- }
- else
- {
- /* Software mode */
- if (SmpModBit != ADC_CR2_IOSH1_SMPMOD)
- {
- /* IOSH2 */
- tmpreg &= ~ADC_CR2_IOSH2_AMPEN;
- tmpreg |= ADC_CR2_IOSH2_SMPMOD | ADC_CR2_IOSH2_SMPEN;
- }
- else
- {
- /* IOSH1 */
- tmpreg &= ~ADC_CR2_IOSH1_AMPEN;
- tmpreg |= ADC_CR2_IOSH1_SMPMOD | ADC_CR2_IOSH1_SMPEN;
- }
- }
- /* Config CR2 register */
- ADC->CR2 = tmpreg;
- }
- /**
- * @brief External hardware trigger mode config.
- * @param NewState: new state of .
- * This parameter can be: ENABLE or DISABLE.
- * @note None
- * @retval None
- */
- void ADC_ExtModeCmd(FunctionalState NewState)
- {
- /* Check the parameters */
- assert_param(IS_FUNCTIONAL_STATE(NewState));
- if (NewState != DISABLE)
- {
- ADC1->ETCR |= ADC_ETCR_EXTMOD;
- }
- else
- {
- ADC1->ETCR &= ~ADC_ETCR_EXTMOD;
- }
- }
- /**
- * @brief Stop sampling configuration after triggering.
- * @param NewState: new state of .
- * This parameter can be: ENABLE or DISABLE.
- * @note None
- * @retval None
- */
- void ADC_TrgdDisSmpCmd(FunctionalState NewState)
- {
- /* Check the parameters */
- assert_param(IS_FUNCTIONAL_STATE(NewState));
- if (NewState != DISABLE)
- {
- ADC1->ETCR |= ADC_ETCR_TRGDISSMP;
- }
- else
- {
- ADC1->ETCR &= ~ADC_ETCR_TRGDISSMP;
- }
- }
- /**
- * @brief The delay time of The external hardware triggers.
- * @param ExtDly: 0~1023.
- * @note None
- * @retval None
- */
- void ADC_ExtDlyConfig(uint32_t ExtDly)
- {
- uint32_t tmpreg = 0;
- /* Check the parameters */
- assert_param(IS_ADC_EXTDLY(ExtDly));
- /* Read ETCR register */
- tmpreg = ADC1->ETCR;
- /* Clear EXTDLY */
- tmpreg &= ~ADC_ETCR_EXTDLY;
- /* Config EXTDLY */
- tmpreg |= ExtDly;
- /* Config ETCR */
- ADC1->ETCR = tmpreg;
- }
- /**
- * @brief Rising edge triggering config.
- * @param Rtenx:This parameter can be :
- * ADC_RTENR_RTEN or ADC_RTENR_RTEN_0 ~ ADC_RTENR_RTEN_18
- * @param NewState: new state of .
- * This parameter can be: ENABLE or DISABLE.
- * @note None
- * @retval None
- */
- void ADC_RtenCmd(uint32_t Rtenx, FunctionalState NewState)
- {
- /* Check the parameters */
- assert_param(IS_ADC_RTEN(Rtenx));
- assert_param(IS_FUNCTIONAL_STATE(NewState));
- if (NewState != DISABLE)
- {
- ADC1->RTENR |= Rtenx;
- }
- else
- {
- ADC1->RTENR &= ~Rtenx;
- }
- }
- /**
- * @brief Falling edge triggering config.
- * @param Ftenx:This parameter can be :
- * ADC_FTENR_RTEN or ADC_FTENR_RTEN_0 ~ ADC_FTENR_RTEN_18
- * @param NewState: new state of .
- * This parameter can be: ENABLE or DISABLE.
- * @note None
- * @retval None
- */
- void ADC_FtenCmd(uint32_t Ftenx, FunctionalState NewState)
- {
- /* Check the parameters */
- assert_param(IS_ADC_FTEN(Ftenx));
- assert_param(IS_FUNCTIONAL_STATE(NewState));
- if (NewState != DISABLE)
- {
- ADC1->FTENR |= Ftenx;
- }
- else
- {
- ADC1->FTENR &= ~Ftenx;
- }
- }
- #endif
- /**
- * @}
- */
- /**
- * @}
- */
- /**
- * @}
- */
- /**
- * @}
- */
- /************************ (C) COPYRIGHT FMD *****END OF FILE****/
|