MCPcopy Create free account
hub / github.com/RT-Thread/rt-thread / ADC_Init

Function ADC_Init

bsp/efm32/Libraries/emlib/src/em_adc.c:252–273  ·  view source on GitHub ↗

/ * @brief * Initialize ADC. * * @details * Initializes common parts for both single conversion and scan sequence. * In addition, single and/or scan control configuration must be done, please * refer to ADC_InitSingle() and ADC_InitScan() respectively. * * @note * This function will stop any ongoing conversion. * * @param[in] adc * Pointer to ADC peripheral register block.

Source from the content-addressed store, hash-verified

250 * Pointer to ADC initialization structure.
251 ******************************************************************************/
252void ADC_Init(ADC_TypeDef *adc, const ADC_Init_TypeDef *init)
253{
254 uint32_t tmp;
255
256 EFM_ASSERT(ADC_REF_VALID(adc));
257
258 /* Make sure conversion is not in progress */
259 adc->CMD = ADC_CMD_SINGLESTOP | ADC_CMD_SCANSTOP;
260
261 tmp = ((uint32_t)(init->ovsRateSel) << _ADC_CTRL_OVSRSEL_SHIFT) |
262 (((uint32_t)(init->timebase) << _ADC_CTRL_TIMEBASE_SHIFT) & _ADC_CTRL_TIMEBASE_MASK) |
263 (((uint32_t)(init->prescale) << _ADC_CTRL_PRESC_SHIFT) & _ADC_CTRL_PRESC_MASK) |
264 ((uint32_t)(init->lpfMode) << _ADC_CTRL_LPFMODE_SHIFT) |
265 ((uint32_t)(init->warmUpMode) << _ADC_CTRL_WARMUPMODE_SHIFT);
266
267 if (init->tailgate)
268 {
269 tmp |= ADC_CTRL_TAILGATE;
270 }
271
272 adc->CTRL = tmp;
273}
274
275
276/***************************************************************************//**

Callers 1

rt_hw_adc_unit_initFunction · 0.50

Calls

no outgoing calls

Tested by

no test coverage detected