00001
00013 #ifndef SENSORS_H_
00014 #define SENSORS_H_
00015
00016
00017 #include <types.h>
00018 #include <pwrCtrl.h>
00019 #include <lm73.h>
00020 #include <tsl2550.h>
00021 #include <battery.h>
00022
00023 #define SENSOR_LIGHT 1
00024 #define SENSOR_TEMPERATURE 2
00025 #define SENSOR_BATTERY 3
00026 #define SENSOR_LED 4
00027
00028
00029
00035 static inline result_t BSP_OpenTemperatureSensor()
00036 {
00037 result_t result;
00038 if ((result = openLm73()) == SUCCESS)
00039 {
00040 bspOnPeriphery(SENSOR_TEMPERATURE);
00041 }
00042 return result;
00043 }
00044
00045
00052 static inline result_t BSP_CloseTemperatureSensor()
00053 {
00054 result_t result;
00055 if ((result = closeLm73()) == SUCCESS)
00056 {
00057 bspOffPeriphery(SENSOR_TEMPERATURE);
00058 }
00059 return result;
00060 }
00061
00062
00074 static inline result_t BSP_ReadTemperatureData(void (*f)(bool result, int16_t data))
00075 {
00076 return readLm73Data(f);
00077 }
00078
00079
00080
00086 static inline result_t BSP_OpenLightSensor()
00087 {
00088 result_t result;
00089 if ((result = openTsl2550()) == SUCCESS)
00090 {
00091 bspOnPeriphery(SENSOR_LIGHT);
00092 }
00093 return result;
00094 }
00095
00096
00103 static inline result_t BSP_CloseLightSensor()
00104 {
00105 result_t result;
00106 if ((result = closeTsl2550()) == SUCCESS)
00107 {
00108 bspOffPeriphery(SENSOR_LIGHT);
00109 }
00110 return result;
00111 }
00112
00113
00125 static inline result_t BSP_ReadLightData(void (*f)(bool result, int16_t data))
00126 {
00127 return readTsl2550Data(f);
00128 }
00129
00130
00136 static inline result_t BSP_OpenBatterySensor()
00137 {
00138 result_t result;
00139 if ((result = openBattery()) == SUCCESS)
00140 {
00141 bspOnPeriphery(SENSOR_BATTERY);
00142 }
00143 return result;
00144 }
00145
00146
00152 static inline result_t BSP_CloseBatterySensor()
00153 {
00154 result_t result;
00155 if ((result = closeBattery()) == SUCCESS)
00156 {
00157 bspOffPeriphery(SENSOR_BATTERY);
00158 }
00159 return result;
00160 }
00161
00162
00170 static inline result_t BSP_ReadBatteryData(void (*callback)(uint8_t data))
00171 {
00172 return readBatteryData(callback);
00173 }
00174
00175 #endif
00176
00177
00178