stm32: adc-v2: pull up more common functionality
More easy bit on/off settings. Every piece that gets pulled up here becomes automatically available for l0/l4 when they land
This commit is contained in:
parent
77c0a2058c
commit
f1d50d24be
@ -185,6 +185,11 @@ void adc_enable_temperature_sensor(void);
|
||||
void adc_disable_temperature_sensor(void);
|
||||
void adc_enable_vrefint(void);
|
||||
void adc_disable_vrefint(void);
|
||||
void adc_set_resolution(uint32_t adc, uint16_t resolution);
|
||||
void adc_set_left_aligned(uint32_t adc);
|
||||
void adc_set_right_aligned(uint32_t adc);
|
||||
void adc_enable_dma(uint32_t adc);
|
||||
void adc_disable_dma(uint32_t adc);
|
||||
|
||||
END_DECLS
|
||||
|
||||
|
@ -190,11 +190,6 @@ void adc_disable_eoc_interrupt(uint32_t adc);
|
||||
void adc_set_clk_source(uint32_t adc, uint32_t source);
|
||||
void adc_set_regular_sequence(uint32_t adc, uint8_t length, uint8_t channel[]);
|
||||
void adc_set_sample_time_on_all_channels(uint32_t adc, uint8_t time);
|
||||
void adc_set_resolution(uint32_t adc, uint16_t resolution);
|
||||
void adc_set_left_aligned(uint32_t adc);
|
||||
void adc_set_right_aligned(uint32_t adc);
|
||||
void adc_enable_dma(uint32_t adc);
|
||||
void adc_disable_dma(uint32_t adc);
|
||||
void adc_enable_vbat_sensor(void);
|
||||
void adc_disable_vbat_sensor(void);
|
||||
void adc_calibrate_start(uint32_t adc);
|
||||
|
@ -603,10 +603,6 @@ void adc_start_conversion_regular(uint32_t adc);
|
||||
void adc_start_conversion_injected(uint32_t adc);
|
||||
void adc_disable_external_trigger_regular(uint32_t adc);
|
||||
void adc_disable_external_trigger_injected(uint32_t adc);
|
||||
void adc_set_left_aligned(uint32_t adc);
|
||||
void adc_set_right_aligned(uint32_t adc);
|
||||
void adc_enable_dma(uint32_t adc);
|
||||
void adc_disable_dma(uint32_t adc);
|
||||
void adc_set_sample_time(uint32_t adc, uint8_t channel, uint8_t time);
|
||||
void adc_set_sample_time_on_all_channels(uint32_t adc, uint8_t time);
|
||||
void adc_set_watchdog_high_threshold(uint32_t adc, uint8_t threshold);
|
||||
@ -627,7 +623,6 @@ void adc_enable_external_trigger_regular(uint32_t adc, uint32_t trigger,
|
||||
uint32_t polarity);
|
||||
void adc_enable_external_trigger_injected(uint32_t adc, uint32_t trigger,
|
||||
uint32_t polarity);
|
||||
void adc_set_resolution(uint32_t adc, uint16_t resolution);
|
||||
void adc_enable_overrun_interrupt(uint32_t adc);
|
||||
void adc_disable_overrun_interrupt(uint32_t adc);
|
||||
bool adc_get_overrun_flag(uint32_t adc);
|
||||
|
@ -138,6 +138,56 @@ void adc_set_single_conversion_mode(uint32_t adc)
|
||||
ADC_CFGR1(adc) &= ~ADC_CFGR1_CONT;
|
||||
}
|
||||
|
||||
/** @brief ADC Set Resolution
|
||||
*
|
||||
* ADC Resolution can be reduced from 12 bits to 10, 8 or 6 bits for a
|
||||
* corresponding reduction in conversion time.
|
||||
*
|
||||
* @param[in] adc Unsigned int32. ADC base address (@ref adc_reg_base)
|
||||
* @param[in] resolution Unsigned int16. Resolution value (@ref adc_api_res)
|
||||
*/
|
||||
void adc_set_resolution(uint32_t adc, uint16_t resolution)
|
||||
{
|
||||
ADC_CFGR1(adc) = (ADC_CFGR1(adc) & ~ADC_CFGR1_RES_MASK) | resolution;
|
||||
}
|
||||
|
||||
/** @brief ADC Set the Data as Left Aligned
|
||||
*
|
||||
* @param[in] adc Unsigned int32. ADC base address (@ref adc_reg_base)
|
||||
*/
|
||||
void adc_set_left_aligned(uint32_t adc)
|
||||
{
|
||||
ADC_CFGR1(adc) |= ADC_CFGR1_ALIGN;
|
||||
}
|
||||
|
||||
/** @brief ADC Set the Data as Right Aligned
|
||||
*
|
||||
* @param[in] adc Unsigned int32. ADC base address (@ref adc_reg_base)
|
||||
*/
|
||||
void adc_set_right_aligned(uint32_t adc)
|
||||
{
|
||||
ADC_CFGR1(adc) &= ~ADC_CFGR1_ALIGN;
|
||||
}
|
||||
|
||||
/** @brief ADC Enable DMA Transfers
|
||||
*
|
||||
* @param[in] adc Unsigned int32. ADC base address (@ref adc_reg_base)
|
||||
*/
|
||||
void adc_enable_dma(uint32_t adc)
|
||||
{
|
||||
ADC_CFGR1(adc) |= ADC_CFGR1_DMAEN;
|
||||
}
|
||||
|
||||
/** @brief ADC Disable DMA Transfers
|
||||
*
|
||||
* @param[in] adc Unsigned int32. ADC base address (@ref adc_reg_base)
|
||||
*/
|
||||
void adc_disable_dma(uint32_t adc)
|
||||
{
|
||||
ADC_CFGR1(adc) &= ~ADC_CFGR1_DMAEN;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Enable the temperature sensor (only)
|
||||
* The channel this is available on is unfortunately not
|
||||
|
@ -512,66 +512,6 @@ void adc_set_sample_time_on_all_channels(uint32_t adc, uint8_t time)
|
||||
ADC_SMPR(adc) = time & ADC_SMPR_SMP;
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/** @brief ADC Set Resolution
|
||||
*
|
||||
* ADC Resolution can be reduced from 12 bits to 10, 8 or 6 bits for a
|
||||
* corresponding reduction in conversion time.
|
||||
*
|
||||
* @param[in] adc Unsigned int32. ADC base address (@ref adc_reg_base)
|
||||
* @param[in] resolution Unsigned int16. Resolution value (@ref adc_api_res)
|
||||
*/
|
||||
|
||||
void adc_set_resolution(uint32_t adc, uint16_t resolution)
|
||||
{
|
||||
ADC_CFGR1(adc) = (ADC_CFGR1(adc) & ~ADC_CFGR1_RES_MASK) | resolution;
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/** @brief ADC Set the Data as Left Aligned
|
||||
*
|
||||
* @param[in] adc Unsigned int32. ADC base address (@ref adc_reg_base)
|
||||
*/
|
||||
|
||||
void adc_set_left_aligned(uint32_t adc)
|
||||
{
|
||||
ADC_CFGR1(adc) |= ADC_CFGR1_ALIGN;
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/** @brief ADC Set the Data as Right Aligned
|
||||
*
|
||||
* @param[in] adc Unsigned int32. ADC base address (@ref adc_reg_base)
|
||||
*/
|
||||
|
||||
void adc_set_right_aligned(uint32_t adc)
|
||||
{
|
||||
ADC_CFGR1(adc) &= ~ADC_CFGR1_ALIGN;
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/** @brief ADC Enable DMA Transfers
|
||||
*
|
||||
* @param[in] adc Unsigned int32. ADC base address (@ref adc_reg_base)
|
||||
*/
|
||||
|
||||
void adc_enable_dma(uint32_t adc)
|
||||
{
|
||||
ADC_CFGR1(adc) |= ADC_CFGR1_DMAEN;
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/** @brief ADC Disable DMA Transfers
|
||||
*
|
||||
* @param[in] adc Unsigned int32. ADC base address (@ref adc_reg_base)
|
||||
*/
|
||||
|
||||
void adc_disable_dma(uint32_t adc)
|
||||
{
|
||||
ADC_CFGR1(adc) &= ~ADC_CFGR1_DMAEN;
|
||||
}
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/** @brief ADC Enable The VBat Sensor
|
||||
*
|
||||
|
@ -492,55 +492,6 @@ void adc_start_conversion_injected(uint32_t adc)
|
||||
while (ADC_CR(adc) & ADC_CR_JADSTART);
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/** @brief ADC Set the Data as Left Aligned
|
||||
*
|
||||
* @param[in] adc Unsigned int32. ADC block register address base @ref
|
||||
* adc_reg_base
|
||||
*/
|
||||
|
||||
void adc_set_left_aligned(uint32_t adc)
|
||||
{
|
||||
ADC_CFGR1(adc) |= ADC_CFGR1_ALIGN;
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/** @brief ADC Set the Data as Right Aligned
|
||||
*
|
||||
* @param[in] adc Unsigned int32. ADC block register address base @ref
|
||||
* adc_reg_base
|
||||
*/
|
||||
|
||||
void adc_set_right_aligned(uint32_t adc)
|
||||
{
|
||||
ADC_CFGR1(adc) &= ~ADC_CFGR1_ALIGN;
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/** @brief ADC Enable DMA Transfers
|
||||
*
|
||||
* @param[in] adc Unsigned int32. ADC block register address base
|
||||
* @ref adc_reg_base
|
||||
*/
|
||||
|
||||
void adc_enable_dma(uint32_t adc)
|
||||
{
|
||||
ADC_CFGR1(adc) |= ADC_CFGR1_DMAEN;
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/** @brief ADC Disable DMA Transfers
|
||||
*
|
||||
* @param[in] adc Unsigned int32. ADC block register address base
|
||||
* @ref adc_reg_base
|
||||
*/
|
||||
|
||||
void adc_disable_dma(uint32_t adc)
|
||||
{
|
||||
ADC_CFGR1(adc) &= ~ADC_CFGR1_DMAEN;
|
||||
}
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/** @brief ADC Set the Sample Time for a Single Channel
|
||||
*
|
||||
@ -966,26 +917,6 @@ void adc_disable_external_trigger_injected(uint32_t adc)
|
||||
ADC_JSQR(adc) &= ~ADC_JSQR_JEXTEN_MASK;
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/** @brief ADC Set Resolution
|
||||
*
|
||||
* ADC Resolution can be reduced from 12 bits to 10, 8 or 6 bits for a
|
||||
* corresponding reduction in conversion time (resolution + 3 ADC clock cycles).
|
||||
*
|
||||
* @param[in] adc Unsigned int32. ADC block register address base @ref
|
||||
* adc_reg_base
|
||||
* @param[in] resolution Unsigned int8. Resolution value @ref adc_cr1_res
|
||||
*/
|
||||
|
||||
void adc_set_resolution(uint32_t adc, uint16_t resolution)
|
||||
{
|
||||
uint32_t reg32 = ADC_CFGR1(adc);
|
||||
|
||||
reg32 &= ~ADC_CFGR1_RES_MASK;
|
||||
reg32 |= resolution;
|
||||
ADC_CFGR1(adc) = reg32;
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/** @brief ADC Enable the Overrun Interrupt
|
||||
*
|
||||
|
Loading…
x
Reference in New Issue
Block a user