stm32: adc-v2: extract common calibration code

Extract the calibration code from the f0, and share it with the other
adc-v2 peripheral users (f0,l0,f3,l4)

Uses the same naming set of is/async naming conventions requested by the
RTOS guys instead of having blocking only calls.

Old code:
	adc_calibrate_start(ADC);
	adc_calibrate_wait_finish(ADC);

New code (blocking):
	adc_calibrate(ADC);

New code (asynch):
	adc_calibrate_async(ADC);
	// do stuff
	adc_is_calibrating(ADC);  // will be false when it's finished.

Old code for f0 is still available, but marked deprecated.
This commit is contained in:
Karl Palsson
2016-09-09 22:08:59 +00:00
parent c2e0afdb05
commit 23cf491501
4 changed files with 40 additions and 2 deletions

View File

@@ -146,6 +146,37 @@ void adc_power_off(uint32_t adc)
while (!adc_is_power_off(adc));
}
/**
* Start the ADC calibration and immediately return.
* @sa adc_calibrate
* @sa adc_is_calibrate
* @param adc ADC Block register address base @ref adc_reg_base
*/
void adc_calibrate_async(uint32_t adc)
{
ADC_CR(adc) = ADC_CR_ADCAL;
}
/**
* Is the ADC Calibrating?
* @param adc ADC Block register address base @ref adc_reg_base
* @return true if the adc is currently calibrating
*/
bool adc_is_calibrating(uint32_t adc)
{
return (ADC_CR(adc) & ADC_CR_ADCAL);
}
/**
* Start ADC calibration and wait for it to finish
* @param adc ADC Block register address base @ref adc_reg_base
*/
void adc_calibrate(uint32_t adc)
{
adc_calibrate_async(adc);
while (adc_is_calibrating(adc));
}
/**
* Enable Continuous Conversion Mode
* In this mode the ADC starts a new conversion of a single channel or a channel