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:
@@ -179,6 +179,9 @@ bool adc_is_power_on(uint32_t adc);
|
|||||||
void adc_power_off_async(uint32_t adc);
|
void adc_power_off_async(uint32_t adc);
|
||||||
void adc_power_off(uint32_t adc);
|
void adc_power_off(uint32_t adc);
|
||||||
bool adc_is_power_off(uint32_t adc);
|
bool adc_is_power_off(uint32_t adc);
|
||||||
|
void adc_calibrate_async(uint32_t adc);
|
||||||
|
bool adc_is_calibrating(uint32_t adc);
|
||||||
|
void adc_calibrate(uint32_t adc);
|
||||||
void adc_set_continuous_conversion_mode(uint32_t adc);
|
void adc_set_continuous_conversion_mode(uint32_t adc);
|
||||||
void adc_set_single_conversion_mode(uint32_t adc);
|
void adc_set_single_conversion_mode(uint32_t adc);
|
||||||
void adc_set_regular_sequence(uint32_t adc, uint8_t length, uint8_t channel[]);
|
void adc_set_regular_sequence(uint32_t adc, uint8_t length, uint8_t channel[]);
|
||||||
|
|||||||
@@ -179,8 +179,10 @@ bool adc_get_eoc_sequence_flag(uint32_t adc);
|
|||||||
void adc_set_clk_source(uint32_t adc, uint32_t source);
|
void adc_set_clk_source(uint32_t adc, uint32_t source);
|
||||||
void adc_enable_vbat_sensor(void);
|
void adc_enable_vbat_sensor(void);
|
||||||
void adc_disable_vbat_sensor(void);
|
void adc_disable_vbat_sensor(void);
|
||||||
void adc_calibrate_start(uint32_t adc);
|
void adc_calibrate_start(uint32_t adc)
|
||||||
void adc_calibrate_wait_finish(uint32_t adc);
|
LIBOPENCM3_DEPRECATED("see adc_calibrate/_async");
|
||||||
|
void adc_calibrate_wait_finish(uint32_t adc)
|
||||||
|
LIBOPENCM3_DEPRECATED("see adc_is_calibrating"); ;
|
||||||
|
|
||||||
/* Analog Watchdog */
|
/* Analog Watchdog */
|
||||||
void adc_enable_analog_watchdog_on_all_channels(uint32_t adc);
|
void adc_enable_analog_watchdog_on_all_channels(uint32_t adc);
|
||||||
|
|||||||
@@ -146,6 +146,37 @@ void adc_power_off(uint32_t adc)
|
|||||||
while (!adc_is_power_off(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
|
* Enable Continuous Conversion Mode
|
||||||
* In this mode the ADC starts a new conversion of a single channel or a channel
|
* In this mode the ADC starts a new conversion of a single channel or a channel
|
||||||
|
|||||||
@@ -398,6 +398,7 @@ void adc_disable_vbat_sensor(void)
|
|||||||
|
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
/** @brief ADC Start the calibration procedure
|
/** @brief ADC Start the calibration procedure
|
||||||
|
* @deprecated Replaced by adc_calibrate/_async/is_calibrating
|
||||||
*
|
*
|
||||||
* @param[in] adc Unsigned int32. ADC base address (@ref adc_reg_base)
|
* @param[in] adc Unsigned int32. ADC base address (@ref adc_reg_base)
|
||||||
*/
|
*/
|
||||||
@@ -409,6 +410,7 @@ void adc_calibrate_start(uint32_t adc)
|
|||||||
|
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
/** @brief ADC Wait to finish the ADC calibration procedure
|
/** @brief ADC Wait to finish the ADC calibration procedure
|
||||||
|
* @deprecated Replaced by adc_calibrate/_async/is_calibrating
|
||||||
*
|
*
|
||||||
* @param[in] adc Unsigned int32. ADC base address (@ref adc_reg_base)
|
* @param[in] adc Unsigned int32. ADC base address (@ref adc_reg_base)
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user