stm32: adc: Add functions to get and clear flags
This includes adding documentation to the status flags. Originally tracked at: https://github.com/libopencm3/libopencm3/pull/833 Modified to drop whitespace changes, and simply boolean return.
This commit is contained in:
committed by
Karl Palsson
parent
743513a4b1
commit
889b7de0d7
@@ -748,6 +748,32 @@ void adc_disable_dma(uint32_t adc)
|
||||
ADC_CR2(adc) &= ~ADC_CR2_DMA;
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/** @brief Read a Status Flag.
|
||||
|
||||
@param[in] adc Unsigned int32. ADC register address base @ref adc_reg_base
|
||||
@param[in] flag Unsigned int32. Status register flag @ref adc_sr_values.
|
||||
@returns boolean: flag set.
|
||||
*/
|
||||
|
||||
bool adc_get_flag(uint32_t adc, uint32_t flag)
|
||||
{
|
||||
return ADC_SR(adc) & flag;
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/** @brief Clear a Status Flag.
|
||||
|
||||
@param[in] adc Unsigned int32. ADC register address base @ref adc_reg_base
|
||||
@param[in] flag Unsigned int32. Status register flag @ref adc_sr_values.
|
||||
*/
|
||||
|
||||
void adc_clear_flag(uint32_t adc, uint32_t flag)
|
||||
{
|
||||
/* All defined bits are 'r' or 'rc_w0' */
|
||||
ADC_SR(adc) = ~flag;
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
/**@}*/
|
||||
|
||||
Reference in New Issue
Block a user