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

Function rt_hw_get_vdd

bsp/efm32/dev_misc.c:87–106  ·  view source on GitHub ↗

/ * @brief * Get current VDD value in volt * * @details * * @note * * @return * VDD value (unsigned integer) in volt times 100 * ******************************************************************************/

Source from the content-addressed store, hash-verified

85 *
86 ******************************************************************************/
87rt_uint32_t rt_hw_get_vdd(void)
88{
89 ADC_InitSingle_TypeDef singleInit = ADC_INITSINGLE_DEFAULT;
90 struct efm32_adc_result_t result;
91 rt_uint32_t vdd;
92
93 /* Set input to temperature sensor. Reference must be 1.25V */
94 singleInit.acqTime = adcAcqTime32;
95 singleInit.reference = adcRef1V25;
96 singleInit.input = adcSingleInpVDDDiv3;
97
98 control.single.init = &singleInit;
99 adc0->control(adc0, RT_DEVICE_CTRL_ADC_MODE, &control);
100 result.mode = control.mode;
101 result.buffer = (void *)&vdd;
102 adc0->control(adc0, RT_DEVICE_CTRL_RESUME, &result);
103 adc0->control(adc0, RT_DEVICE_CTRL_ADC_RESULT, &result);
104
105 return (vdd * 125 * 3) / 4096;
106}
107
108/***************************************************************************//**
109 * @brief

Callers 2

dev_misc.cFile · 0.85
http_recvFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected