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

Function rt_hw_get_temp

bsp/efm32/dev_misc.c:53–73  ·  view source on GitHub ↗

Private functions ---------------------------------------------------------*/ / * @brief * Get current temperature value in degree celsius * * @details * * @note * * @return * Temperature value (signed integer) in degree celsius times 100 * ******************************************************************************/

Source from the content-addressed store, hash-verified

51 *
52 ******************************************************************************/
53rt_int32_t rt_hw_get_temp(void)
54{
55 ADC_InitSingle_TypeDef singleInit = ADC_INITSINGLE_DEFAULT;
56 struct efm32_adc_result_t result;
57 rt_uint32_t temp;
58
59 /* Set input to temperature sensor. Acquisition time must be 256 cycles.
60 Reference must be 1.25V */
61 singleInit.acqTime = adcAcqTime32;
62 singleInit.reference = adcRef1V25;
63 singleInit.input = adcSingleInpTemp;
64
65 control.single.init = &singleInit;
66 adc0->control(adc0, RT_DEVICE_CTRL_ADC_MODE, &control);
67 result.mode = control.mode;
68 result.buffer = (void *)&temp;
69 adc0->control(adc0, RT_DEVICE_CTRL_RESUME, &result);
70 adc0->control(adc0, RT_DEVICE_CTRL_ADC_RESULT, &result);
71
72 return efm32_misc_getCelsius(temp);
73}
74
75/***************************************************************************//**
76 * @brief

Callers 2

list_tempFunction · 0.85
http_recvFunction · 0.85

Calls 1

efm32_misc_getCelsiusFunction · 0.85

Tested by

no test coverage detected