/ * @brief * Get current VDD value in volt * * @details * * @note * * @return * VDD value (unsigned integer) in volt times 100 * ******************************************************************************/
| 85 | * |
| 86 | ******************************************************************************/ |
| 87 | rt_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 |
no outgoing calls
no test coverage detected