Browse Source

stm32: adc common v2: add circular dma mode

Tested only on the F3 so far.
pull/984/head
mfm 7 years ago
committed by Karl Palsson
parent
commit
f6517f7816
  1. 3
      include/libopencm3/stm32/common/adc_common_v2.h
  2. 20
      lib/stm32/common/adc_common_v2.c

3
include/libopencm3/stm32/common/adc_common_v2.h

@ -205,7 +205,8 @@ bool adc_get_overrun_flag(uint32_t adc);
void adc_clear_overrun_flag(uint32_t adc);
uint32_t adc_read_regular(uint32_t adc);
void adc_start_conversion_regular(uint32_t adc);
void adc_enable_dma_circular_mode(uint32_t adc);
void adc_disable_dma_circular_mode(uint32_t adc);
END_DECLS
#endif

20
lib/stm32/common/adc_common_v2.c

@ -389,4 +389,24 @@ void adc_start_conversion_regular(uint32_t adc)
ADC_CR(adc) |= ADC_CR_ADSTART;
}
/** @brief Enable circular mode for DMA transfers
*
* For this to work it needs to be ebabled on the DMA side as well.
*
* @param[in] adc Unsigned int32. ADC base address (@ref adc_reg_base)
*/
void adc_enable_dma_circular_mode(uint32_t adc)
{
ADC_CFGR1(adc) |= ADC_CFGR1_DMACFG;
}
/** @brief Disable circular mode for DMA transfers
*
* @param[in] adc Unsigned int32. ADC base address (@ref adc_reg_base)
*/
void adc_disable_dma_circular_mode(uint32_t adc)
{
ADC_CFGR1(adc) &= ~ADC_CFGR1_DMACFG;
}
/**@}*/

Loading…
Cancel
Save