µracoli Manual Version foo

- µracoli
- User Guide
- Reference Guide

sensor.h
1 /* Copyright (c) 2013 - 2014 Axel Wachtler
2 All rights reserved.
3
4 Redistribution and use in source and binary forms, with or without
5 modification, are permitted provided that the following conditions
6 are met:
7
8 * Redistributions of source code must retain the above copyright
9 notice, this list of conditions and the following disclaimer.
10 * Redistributions in binary form must reproduce the above copyright
11 notice, this list of conditions and the following disclaimer in the
12 documentation and/or other materials provided with the distribution.
13 * Neither the name of the authors nor the names of its contributors
14 may be used to endorse or promote products derived from this software
15 without specific prior written permission.
16
17 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
21 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27 POSSIBILITY OF SUCH DAMAGE. */
28
29 #ifndef SENSOR_H
30 #define SENSOR_H
31
38 /* === includes ============================================================ */
39 #include "board.h"
40 #include "i2c.h"
41 #include "ow.h"
42 #include "sensor_defs.h"
43 #if defined(HAS_SENSOR_LM73)
44 # include "sensors/lm73.h"
45 #endif
46 #if defined(HAS_SENSOR_MCU_T)
47 # include "sensors/mcu_temp.h"
48 #endif
49 #if defined(HAS_SENSOR_TSL2550)
50 # include "sensors/tsl2550.h"
51 #endif
52 #if defined(HAS_SENSOR_LEDPS)
53 # include "sensors/ledps.h"
54 #endif
55 #if 0
56 #include "sensors/isl29020.h"
57 #endif
58 #if defined(HAS_SENSOR_HMC5883L)
59 #include "sensors/hmc5883l.h"
60 #endif
61 #if defined(HAS_SENSOR_TRXVTG)
62 #include "sensors/trxvtg.h"
63 #endif
64
65 #if defined(HAS_SENSOR_DS18B20)
66 #include "sensors/ds18b20.h"
67 #endif
68
69 /* === macros ============================================================== */
70 #define ALL_SENSORS (-1)
71
72 /* === types =============================================================== */
73
76 typedef struct
77 {
78 #if defined(HAS_SENSOR_LM73) || defined(HAS_SENSOR_LM73_RAW)
79 lm73_ctx_t lm73;
80 #endif
81 #if defined(HAS_SENSOR_MCU_T)
82 mcu_temp_ctx_t mcu_temp;
83 #endif
84 #if defined(HAS_SENSOR_TSL2550)
85 tsl2550_ctx_t mcu_temp;
86 #endif
87 #if defined(HAS_SENSOR_LEDPS)
88 ledps_ctx_t led_photosensor;
89 #endif
90 #if defined(HAS_SENSOR_HMC5883L)
91 hmc5883l_ctx_t hmc5883l;
92 #endif
93 #if defined(HAS_SENSOR_TRXVTG) || defined(HAS_SENSOR_TRXVTG_RAW)
94 trxvtg_ctx_t trxvtg;
95 #endif
96 #if defined(HAS_SENSOR_DS18B20)
97 ds18b20_ctx_t ds18b20;
98 #endif
99 #if NB_BOARD_SENSORS < 1
100 uint8_t dummy;
101 #endif
102 } board_sensor_ctx_t;
103
104
105 /* === prototypes ========================================================== */
106 #ifdef __cplusplus
107 extern "C" {
108 #endif
109
113 uint8_t create_board_sensors(void);
114
123 void sensor_trigger(int idx, bool one_shot);
124
135 uint8_t sensor_get(int idx, uint8_t *pdata);
136
141 void sensor_sleep(int idx);
142
152 char * sensor_decode(uint8_t *buf, char * line, uint16_t size);
153
157 uint8_t sensor_get_number(void);
162 uint8_t sensor_get_id(uint8_t idx);
167 char* sensor_get_type(uint8_t idx);
172 char* sensor_get_name(uint8_t idx);
173
178 uint8_t sensor_get_error(uint8_t idx);
179 #ifdef __cplusplus
180 } /* extern "C" */
181 #endif
182
183 #endif /* #ifndef SENSOR_H */
sensor_trigger
void sensor_trigger(int idx, bool one_shot)
create_board_sensors
uint8_t create_board_sensors(void)
sensor_get_name
char * sensor_get_name(uint8_t idx)
sensor_get_error
uint8_t sensor_get_error(uint8_t idx)
sensor_sleep
void sensor_sleep(int idx)
sensor_decode
char * sensor_decode(uint8_t *buf, char *line, uint16_t size)
ledps_ctx_t
Definition: ledps.h:76
sensor_get
uint8_t sensor_get(int idx, uint8_t *pdata)
sensor_get_number
uint8_t sensor_get_number(void)
ds18b20_ctx_t
Definition: ds18b20.h:109
sensor_get_id
uint8_t sensor_get_id(uint8_t idx)
board_sensor_ctx_t
Definition: sensor.h:76
sensor_get_type
char * sensor_get_type(uint8_t idx)