00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00024 #include <stdio.h>
00025 #include "sceptre.h"
00026 #include "thermometer.h"
00027
00028
00029 static FILE *p_thermometer = NULL;
00030
00031
00037 bool_t thermometer_init(void)
00038 {
00039 p_thermometer = fopen("/thermo/","rw");
00040 if (p_thermometer!=NULL) return true;
00041 return false;
00042 }
00043
00044
00050 float thermometer_read(void)
00051 {
00052 float result = THERMOMETER_INVALID;
00053 if (p_thermometer!=NULL)
00054 {
00055 fread(&result,sizeof(float),1,p_thermometer);
00056 }
00057 return result;
00058 }
00059
00060
00068 int thermometer_write(uint8_t *p_data, uint32_t data_size)
00069 {
00070 if (p_thermometer!=NULL)
00071 {
00072 return fwrite(p_data,sizeof(uint8_t),data_size,p_thermometer);
00073 }
00074 return 0;
00075 }