Definition in file s_temperature.h.
#include "compiler.h"
#include "FreeRTOS.h"
Go to the source code of this file.
Functions | |
Bool | b_temperature_get_value (char *buf) |
Get the current temperature value. |
Bool b_temperature_get_value | ( | char * | buf | ) |
Get the current temperature value.
buf | char buffer in which the temperature value is stored. |
Definition at line 89 of file s_temperature.c.
References adc, and temperature_code.
Referenced by device_full_custom_task().
00090 { 00091 int i_current_val, value, index = 0; 00092 00093 00094 /* enable channel for sensor */ 00095 adc_enable( adc, ADC_TEMPERATURE_CHANNEL ); 00096 // start conversion 00097 adc_start( adc ); 00098 // get value for sensor 00099 value = adc_get_value( adc, ADC_TEMPERATURE_CHANNEL ); 00100 /* Disable channel for sensor */ 00101 adc_disable( adc, ADC_TEMPERATURE_CHANNEL ); 00102 00103 if(value > temperature_code[0]) 00104 { 00105 i_current_val = -20; 00106 } 00107 else 00108 { 00109 while(temperature_code[index++] > value); 00110 i_current_val = (index - 1 - 20); 00111 } 00112 00113 // Build the log string. 00114 sprintf( buf, "%2dC\r\n", i_current_val); 00115 return TRUE; 00116 }