diff --git a/src/hal/hal_adc.h b/src/hal/hal_adc.h index 662bc6ce6..df79c4e98 100644 --- a/src/hal/hal_adc.h +++ b/src/hal/hal_adc.h @@ -3,4 +3,6 @@ void HAL_ADC_Init(int pinNumber); int HAL_ADC_Read(int pinNumber); - +#if defined(PLATFORM_W800) || defined(PLATFORM_W600) +float HAL_ADC_Temp(void); +#endif diff --git a/src/hal/w800/hal_adc_w800.c b/src/hal/w800/hal_adc_w800.c index cae04c7c1..f9accb518 100644 --- a/src/hal/w800/hal_adc_w800.c +++ b/src/hal/w800/hal_adc_w800.c @@ -42,5 +42,15 @@ int HAL_ADC_Read(int pinNumber) { return adc_get_inputVolt(gpioToAdc(pinNumber)); } +// cpu internal temperature +float HAL_ADC_Temp(void) +{ + wm_adc_config(0); + adc_get_offset(); + // adc_temp returns + // chip temperature, unit: 1/1000 degree + // we want a float here + return (float)adc_temp()/1000; +} #endif diff --git a/src/user_main.c b/src/user_main.c index 656f2dcdd..5ff2987ad 100644 --- a/src/user_main.c +++ b/src/user_main.c @@ -559,6 +559,8 @@ void Main_OnEverySecond() get_tsen_adc(&g_wifi_temperature, 0); #elif PLATFORM_LN882H // this is set externally, I am just leaving comment here +#elif PLATFORM_W800 || PLATFORM_W600 + g_wifi_temperature = HAL_ADC_Temp(); #endif } // run_adc_test();