µracoli Manual Version foo

- µracoli
- User Guide
- Reference Guide

sensor_defs.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_DEFS_H
30 #define SENSOR_DEFS_H
31
32 /* === includes ============================================================ */
33
34 /* === macros ============================================================== */
35
36 #define SENSOR_DATA_TEMPERATURE (1)
37 #define SENSOR_DATA_RELHUMIDITY (2)
38 #define SENSOR_DATA_ACCELERATION (3)
39 #define SENSOR_DATA_LIGHT (4)
40 #define SENSOR_DATA_MAGNETIC (5)
41 #define SENSOR_DATA_VOLTAGE (6)
42
44 #define SENSOR_DATA_EOR (0x0)
45
47 #define SENSOR_DATA_RAW (0x80)
48
49 /* === types =============================================================== */
50 typedef enum
51 {
52 SENSOR_ERR_OK = 0,
53 SENSOR_ERR_INIT,
54 SENSOR_ERR_CRC,
55 SENSOR_ERR_PWRON
56 } sensor_error_t;
57
59 typedef struct
60 {
61 uint8_t id;
62 sensor_error_t last_error;
63 void (* f_trigger)(void *ctx, bool one_shot);
64 uint8_t (* f_get_val)(void *ctx, uint8_t *pdata);
65 void (* f_sleep)(void * ctx);
66 } sensor_driver_t;
67
69 typedef struct
70 {
71 uint8_t type;
72 uint8_t sensor;
73 float temp;
74 } sensor_temperature_t;
75
77 typedef struct
78 {
79 uint8_t type;
80 uint8_t sensor;
81 uint16_t light;
82 } sensor_light_t;
83
85 typedef struct
86 {
87 uint8_t type;
88 uint8_t sensor;
89 float x;
90 float y;
91 float z;
92 } sensor_magnetic_t;
93
95 typedef struct
96 {
97 uint8_t type;
98 uint8_t sensor;
99 float voltage;
100 } sensor_voltage_t;
101
102
104 typedef struct
105 {
106 uint8_t type;
107 uint8_t sensor;
108 uint8_t data[1];
109 } sensor_raw_t;
110
111 /* === prototypes ========================================================== */
112 #ifdef __cplusplus
113 extern "C" {
114 #endif
115
116 #ifdef __cplusplus
117 } /* extern "C" */
118 #endif
119
120 #endif /* #ifndef SENSOR_DEFS_H */
sensor_voltage_t
Definition: sensor_defs.h:95
sensor_light_t
Definition: sensor_defs.h:77
sensor_magnetic_t
Definition: sensor_defs.h:85
sensor_driver_t
Definition: sensor_defs.h:59
sensor_temperature_t
Definition: sensor_defs.h:69
sensor_raw_t
Definition: sensor_defs.h:104