stm32: adc-v2: Pull up more common basic functionality

Pull up eoc/eos/read_regular functions.  More simple, basic core functionality.
This commit is contained in:
Karl Palsson
2015-11-05 23:31:41 +00:00
parent f1d50d24be
commit b2af9e632c
6 changed files with 46 additions and 84 deletions

View File

@@ -35,6 +35,35 @@ LGPL License Terms @ref lgpl_license
#include <libopencm3/stm32/adc.h>
/** @brief ADC Read the End-of-Conversion Flag
*
* This flag is set by hardware at the end of each regular conversion of a
* channel when a new data is available in the ADCx_DR register.
*
* @param[in] adc Unsigned int32. ADC block register address base
* @ref adc_reg_base
* @returns bool. End of conversion flag.
*/
bool adc_eoc(uint32_t adc)
{
return ADC_ISR(adc) & ADC_ISR_EOC;
}
/** @brief ADC Read the End-of-Sequence Flag for Regular Conversions
*
* This flag is set after all channels of an regular group have been
* converted.
*
* @param[in] adc Unsigned int32. ADC block register address base
* @ref adc_reg_base
* @returns bool. End of conversion flag.
*/
bool adc_eos(uint32_t adc)
{
return ADC_ISR(adc) & ADC_ISR_EOS;
}
/**
* Turn on the ADC (async)
* @sa adc_wait_power_on
@@ -188,6 +217,20 @@ void adc_disable_dma(uint32_t adc)
}
/** @brief ADC Read from the Regular Conversion Result Register
*
* The result read back is 12 bits, right or left aligned within the first
* 16 bits.
*
* @param[in] adc Unsigned int32. ADC block register address base
* @ref adc_reg_base
* @returns Unsigned int32 conversion result.
*/
uint32_t adc_read_regular(uint32_t adc)
{
return ADC_DR(adc);
}
/**
* Enable the temperature sensor (only)
* The channel this is available on is unfortunately not

View File

@@ -172,37 +172,6 @@ void adc_start_conversion_regular(uint32_t adc)
while (ADC_CR(adc) & ADC_CR_ADSTART);
}
/*---------------------------------------------------------------------------*/
/** @brief ADC Read the End-of-Conversion Flag
*
* This flag is set after all channels of a regular or injected group have been
* converted.
*
* @param[in] adc Unsigned int32. ADC base address (@ref adc_reg_base)
* @returns bool. End of conversion flag.
*/
bool adc_eoc(uint32_t adc)
{
return ((ADC_ISR(adc) & ADC_ISR_EOC) != 0);
}
/*---------------------------------------------------------------------------*/
/** @brief ADC Read from the Regular Conversion Result Register
*
* The result read back is 12 bits, right or left aligned within the first
* 16 bits. For ADC1 only, the higher 16 bits will hold the result from ADC2 if
* an appropriate dual mode has been set @see adc_set_dual_mode.
*
* @param[in] adc Unsigned int32. ADC base address (@ref adc_reg_base)
* @returns Unsigned int32 conversion result.
*/
uint32_t adc_read_regular(uint32_t adc)
{
return ADC_DR(adc);
}
/**@}*/
/*---------------------------------------------------------------------------*/

View File

@@ -668,22 +668,6 @@ void adc_set_injected_sequence(uint32_t adc, uint8_t length, uint8_t channel[])
ADC_JSQR(adc) = reg32;
}
/*---------------------------------------------------------------------------*/
/** @brief ADC Read the End-of-Conversion Flag
*
* This flag is set by hardware at the end of each regular conversion of a
* channel when a new data is available in the ADCx_DR register.
*
* @param[in] adc Unsigned int32. ADC block register address base
* @ref adc_reg_base
* @returns bool. End of conversion flag.
*/
bool adc_eoc(uint32_t adc)
{
return ADC_ISR(adc) & ADC_ISR_EOC;
}
/*---------------------------------------------------------------------------*/
/** @brief ADC Read the End-of-Conversion Flag for Injected Conversion
*
@@ -700,21 +684,6 @@ bool adc_eoc_injected(uint32_t adc)
return ADC_ISR(adc) & ADC_ISR_JEOC;
}
/*---------------------------------------------------------------------------*/
/** @brief ADC Read the End-of-Sequence Flag for Regular Conversions
*
* This flag is set after all channels of an regular group have been
* converted.
*
* @param[in] adc Unsigned int32. ADC block register address base
* @ref adc_reg_base
* @returns bool. End of conversion flag.
*/
bool adc_eos(uint32_t adc)
{
return ADC_ISR(adc) & ADC_ISR_EOS;
}
/*---------------------------------------------------------------------------*/
/** @brief ADC Read the End-of-Sequence Flag for Injected Conversions
*
@@ -731,23 +700,6 @@ bool adc_eos_injected(uint32_t adc)
}
/*---------------------------------------------------------------------------*/
/** @brief ADC Read from the Regular Conversion Result Register
*
* The result read back is 12 bits, right or left aligned within the first
* 16 bits. For ADC1 only, the higher 16 bits will hold the result from ADC2 if
* an appropriate dual mode has been set @see adc_set_dual_mode.
*
* @param[in] adc Unsigned int32. ADC block register address base
* @ref adc_reg_base
* @returns Unsigned int32 conversion result.
*/
uint32_t adc_read_regular(uint32_t adc)
{
return ADC_DR(adc);
}
/*---------------------------------------------------------------------------*/
/** @brief ADC Read from an Injected Conversion Result Register
*