stm32f3: adc: support voltage regulator on/off

The "Intermediate" value isn't a value you can do anything with, you need to
clear those bits when making changes.
This commit is contained in:
Karl Palsson 2015-10-19 00:43:00 +00:00
parent 6eb846d356
commit 7373d3ad58
2 changed files with 29 additions and 3 deletions

View File

@ -334,11 +334,10 @@
/* ADCALDIF: Differential mode for calibration */
#define ADC_CR_ADCALDIF (1 << 30)
/* ADVREGEN: ADC voltage regulador enable */
#define ADC_CR_ADVREGEN_INTERMEDIATE (0x0 << 28)
/** ADVREGEN: ADC voltage regulator enable */
#define ADC_CR_ADVREGEN_ENABLE (0x1 << 28)
#define ADC_CR_ADVREGEN_DISABLE (0x2 << 28)
/* --- Bit 0x3 reserved --- */
#define ADC_CR_ADVREGEN_MASK (0x3 << 28)
/* JADSTP: ADC stop of injected conversion command */
#define ADC_CR_JADSTP (1 << 5)
@ -920,6 +919,8 @@ bool adc_awd(uint32_t adc);
/*void adc_set_dma_terminate(uint32_t adc);*/
void adc_enable_temperature_sensor(void);
void adc_disable_temperature_sensor(void);
void adc_enable_regulator(uint32_t adc);
void adc_disable_regulator(uint32_t adc);
END_DECLS

View File

@ -1197,5 +1197,30 @@ void adc_disable_temperature_sensor()
/*---------------------------------------------------------------------------*/
/**
* Enable the ADC Voltage regulator
* Before any use of the ADC, the ADC Voltage regulator must be enabled.
* You must wait up to 10uSecs afterwards before trying anything else.
* @param[in] adc ADC block register address base
* @sa adc_disable_regulator
*/
void adc_enable_regulator(uint32_t adc)
{
ADC_CR(adc) &= ~ADC_CR_ADVREGEN_MASK;
ADC_CR(adc) |= ADC_CR_ADVREGEN_ENABLE;
}
/**
* Disable the ADC Voltage regulator
* You can disable the adc vreg when not in use to save power
* @param[in] adc ADC block register address base
* @sa adc_enable_regulator
*/
void adc_disable_regulator(uint32_t adc)
{
ADC_CR(adc) &= ~ADC_CR_ADVREGEN_MASK;
ADC_CR(adc) |= ADC_CR_ADVREGEN_DISABLE;
}
/**@}*/