saul.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2015 Freie Universität Berlin
3  *
4  * This file is subject to the terms and conditions of the GNU Lesser
5  * General Public License v2.1. See the file LICENSE in the top level
6  * directory for more details.
7  */
8 
44 #ifndef SAUL_H
45 #define SAUL_H
46 
47 #include <stdint.h>
48 #include <errno.h>
49 
50 #include "phydat.h"
51 
52 #ifdef __cplusplus
53 extern "C" {
54 #endif
55 
84 enum {
85  SAUL_CAT_UNDEF = 0x00,
86  SAUL_CAT_ACT = 0x40,
87  SAUL_CAT_SENSE = 0x80,
88 };
89 
93 enum {
101  /* Extend this list as needed, but keep SAUL_ACT_ID_ANY the first and
102  * SAUL_ACT_NUMOF the last entry
103  */
104 };
105 
109 enum {
140  /* Extend this list as needed, but keep SAUL_SENSE_ID_ANY the first and
141  * SAUL_SENSE_NUMOF the last entry
142  */
143 };
144 
151 enum {
224  /* extend this list as needed... */
225 };
226 
231 enum {
232  SAUL_CAT_MASK = 0xc0,
233  SAUL_ID_MASK = 0x3f,
234 };
254 typedef int(*saul_read_t)(const void *dev, phydat_t *res);
255 
274 typedef int(*saul_write_t)(const void *dev, phydat_t *data);
275 
279 typedef struct {
282  uint8_t type;
283 } saul_driver_t;
284 
293 void saul_init_devs(void);
294 
298 int saul_notsup(const void *dev, phydat_t *dat);
299 
308 const char *saul_class_to_str(const uint8_t class_id);
309 
310 #ifdef __cplusplus
311 }
312 #endif
313 
314 #endif /* SAUL_H */
315 
SAUL_ACT_ID_SERVO
@ SAUL_ACT_ID_SERVO
actuator: servo motor
Definition: saul.h:96
SAUL_SENSE_ID_PH
@ SAUL_SENSE_ID_PH
sensor: pH
Definition: saul.h:136
SAUL_SENSE_ID_CHARGE
@ SAUL_SENSE_ID_CHARGE
sensor: coulomb counter
Definition: saul.h:131
SAUL_SENSE_NUMOF
@ SAUL_SENSE_NUMOF
Number of actuators supported.
Definition: saul.h:139
SAUL_ACT_ANY
@ SAUL_ACT_ANY
any actuator - wildcard
Definition: saul.h:153
SAUL_SENSE_BTN
@ SAUL_SENSE_BTN
sensor: simple button
Definition: saul.h:167
SAUL_SENSE_ACCEL
@ SAUL_SENSE_ACCEL
sensor: accelerometer
Definition: saul.h:175
SAUL_SENSE_LIGHT
@ SAUL_SENSE_LIGHT
sensor: light
Definition: saul.h:173
saul_notsup
int saul_notsup(const void *dev, phydat_t *dat)
Default not supported function.
SAUL_ACT_ID_SWITCH
@ SAUL_ACT_ID_SWITCH
actuator: simple on/off switch
Definition: saul.h:98
SAUL_ID_MASK
@ SAUL_ID_MASK
Bitmask to obtain the intra-category ID.
Definition: saul.h:233
SAUL_ACT_SERVO
@ SAUL_ACT_SERVO
actuator: servo motor
Definition: saul.h:157
SAUL_SENSE_CURRENT
@ SAUL_SENSE_CURRENT
sensor: ammeter
Definition: saul.h:209
SAUL_SENSE_COUNT
@ SAUL_SENSE_COUNT
sensor: pulse counter
Definition: saul.h:191
SAUL_SENSE_ID_ANY
@ SAUL_SENSE_ID_ANY
any sensor - wildcard
Definition: saul.h:110
SAUL_SENSE_ID_ANALOG
@ SAUL_SENSE_ID_ANALOG
sensor: raw analog value
Definition: saul.h:120
SAUL_SENSE_ID_OBJTEMP
@ SAUL_SENSE_ID_OBJTEMP
sensor: object temperature
Definition: saul.h:122
SAUL_CAT_ACT
@ SAUL_CAT_ACT
Actuator device class.
Definition: saul.h:86
SAUL_ACT_ID_LED_RGB
@ SAUL_ACT_ID_LED_RGB
actuator: RGB LED
Definition: saul.h:95
SAUL_SENSE_ID_SIZE
@ SAUL_SENSE_ID_SIZE
sensor: size
Definition: saul.h:138
SAUL_SENSE_ID_MAG
@ SAUL_SENSE_ID_MAG
sensor: magnetometer
Definition: saul.h:116
SAUL_SENSE_GAS
@ SAUL_SENSE_GAS
sensor: Gas common
Definition: saul.h:199
saul_driver_t::read
saul_read_t read
read function pointer
Definition: saul.h:280
SAUL_ACT_ID_ANY
@ SAUL_ACT_ID_ANY
any actuator - wildcard
Definition: saul.h:94
SAUL_SENSE_ID_CO2
@ SAUL_SENSE_ID_CO2
sensor: CO2 Gas
Definition: saul.h:125
SAUL_ACT_DIMMER
@ SAUL_ACT_DIMMER
actuator: dimmable switch
Definition: saul.h:163
SAUL_SENSE_CAPACITANCE
@ SAUL_SENSE_CAPACITANCE
sensor: capacitance
Definition: saul.h:213
SAUL_SENSE_ID_COUNT
@ SAUL_SENSE_ID_COUNT
sensor: pulse counter
Definition: saul.h:123
SAUL_SENSE_ID_LIGHT
@ SAUL_SENSE_ID_LIGHT
sensor: light
Definition: saul.h:114
SAUL_ACT_NUMOF
@ SAUL_ACT_NUMOF
Number of actuators supported.
Definition: saul.h:100
SAUL_SENSE_RSSI
@ SAUL_SENSE_RSSI
sensor: RSSI
Definition: saul.h:205
SAUL_SENSE_ID_ACCEL
@ SAUL_SENSE_ID_ACCEL
sensor: accelerometer
Definition: saul.h:115
SAUL_SENSE_ID_GYRO
@ SAUL_SENSE_ID_GYRO
sensor: gyroscope
Definition: saul.h:117
SAUL_SENSE_CHARGE
@ SAUL_SENSE_CHARGE
sensor: coulomb counter
Definition: saul.h:207
SAUL_SENSE_PM
@ SAUL_SENSE_PM
sensor: particulate matter
Definition: saul.h:211
phydat_t
Generic data structure for expressing physical values.
Definition: phydat.h:149
SAUL_SENSE_ID_PRESS
@ SAUL_SENSE_ID_PRESS
sensor: pressure
Definition: saul.h:119
SAUL_SENSE_DISTANCE
@ SAUL_SENSE_DISTANCE
sensor: distance
Definition: saul.h:193
saul_driver_t::write
saul_write_t write
write function pointer
Definition: saul.h:281
SAUL_SENSE_ID_PM
@ SAUL_SENSE_ID_PM
sensor: particulate matter
Definition: saul.h:133
SAUL_SENSE_ID_CAPACITANCE
@ SAUL_SENSE_ID_CAPACITANCE
sensor: capacitance
Definition: saul.h:134
SAUL_SENSE_ANY
@ SAUL_SENSE_ANY
any sensor - wildcard
Definition: saul.h:165
SAUL_SENSE_ID_GAS
@ SAUL_SENSE_ID_GAS
sensor: Gas common
Definition: saul.h:127
saul_init_devs
void saul_init_devs(void)
Initialize all available SAUL drivers.
SAUL_SENSE_VOLTAGE
@ SAUL_SENSE_VOLTAGE
sensor: voltage
Definition: saul.h:215
SAUL_ACT_LED_RGB
@ SAUL_ACT_LED_RGB
actuator: RGB LED
Definition: saul.h:155
SAUL_ACT_MOTOR
@ SAUL_ACT_MOTOR
actuator: motor
Definition: saul.h:159
saul_driver_t
Definition of the RIOT actuator/sensor interface.
Definition: saul.h:279
SAUL_SENSE_TVOC
@ SAUL_SENSE_TVOC
sensor: TVOC Gas
Definition: saul.h:197
SAUL_SENSE_SIZE
@ SAUL_SENSE_SIZE
sensor: size
Definition: saul.h:221
saul_write_t
int(* saul_write_t)(const void *dev, phydat_t *data)
Write a value (a set of values) to a device.
Definition: saul.h:274
SAUL_SENSE_ID_BTN
@ SAUL_SENSE_ID_BTN
sensor: simple button
Definition: saul.h:111
saul_read_t
int(* saul_read_t)(const void *dev, phydat_t *res)
Read a value (a set of values) from a device.
Definition: saul.h:254
SAUL_SENSE_ID_TVOC
@ SAUL_SENSE_ID_TVOC
sensor: TVOC Gas
Definition: saul.h:126
SAUL_SENSE_UV
@ SAUL_SENSE_UV
sensor: UV index
Definition: saul.h:187
SAUL_SENSE_OBJTEMP
@ SAUL_SENSE_OBJTEMP
sensor: object temperature
Definition: saul.h:189
SAUL_SENSE_HUM
@ SAUL_SENSE_HUM
sensor: humidity
Definition: saul.h:171
SAUL_SENSE_COLOR
@ SAUL_SENSE_COLOR
sensor: (light) color
Definition: saul.h:181
SAUL_CLASS_ANY
@ SAUL_CLASS_ANY
any device - wildcard
Definition: saul.h:223
SAUL_SENSE_ID_HUM
@ SAUL_SENSE_ID_HUM
sensor: humidity
Definition: saul.h:113
SAUL_SENSE_PROXIMITY
@ SAUL_SENSE_PROXIMITY
sensor: proximity
Definition: saul.h:203
SAUL_SENSE_ID_DISTANCE
@ SAUL_SENSE_ID_DISTANCE
sensor: distance
Definition: saul.h:124
SAUL_SENSE_ID_COLOR
@ SAUL_SENSE_ID_COLOR
sensor: (light) color
Definition: saul.h:118
SAUL_SENSE_POWER
@ SAUL_SENSE_POWER
sensor: power
Definition: saul.h:219
SAUL_SENSE_MAG
@ SAUL_SENSE_MAG
sensor: magnetometer
Definition: saul.h:177
SAUL_SENSE_ID_CURRENT
@ SAUL_SENSE_ID_CURRENT
sensor: ammeter
Definition: saul.h:132
SAUL_CAT_UNDEF
@ SAUL_CAT_UNDEF
device class undefined
Definition: saul.h:85
saul_driver_t::type
uint8_t type
device class the device belongs to
Definition: saul.h:282
SAUL_SENSE_ID_OCCUP
@ SAUL_SENSE_ID_OCCUP
sensor: occupancy
Definition: saul.h:128
phydat.h
Generic data container for physical data interface.
saul_class_to_str
const char * saul_class_to_str(const uint8_t class_id)
Helper function converts a class ID to a string.
SAUL_SENSE_OCCUP
@ SAUL_SENSE_OCCUP
sensor: occupancy
Definition: saul.h:201
SAUL_CAT_SENSE
@ SAUL_CAT_SENSE
Sensor device class.
Definition: saul.h:87
SAUL_ACT_ID_MOTOR
@ SAUL_ACT_ID_MOTOR
actuator: motor
Definition: saul.h:97
SAUL_SENSE_ID_UV
@ SAUL_SENSE_ID_UV
sensor: UV index
Definition: saul.h:121
SAUL_SENSE_ID_TEMP
@ SAUL_SENSE_ID_TEMP
sensor: temperature
Definition: saul.h:112
SAUL_SENSE_ID_PROXIMITY
@ SAUL_SENSE_ID_PROXIMITY
sensor: proximity
Definition: saul.h:129
SAUL_CAT_MASK
@ SAUL_CAT_MASK
Bitmask to obtain the category ID.
Definition: saul.h:232
SAUL_ACT_ID_DIMMER
@ SAUL_ACT_ID_DIMMER
actuator: dimmable switch
Definition: saul.h:99
SAUL_SENSE_ID_VOLTAGE
@ SAUL_SENSE_ID_VOLTAGE
sensor: voltage
Definition: saul.h:135
SAUL_SENSE_ID_RSSI
@ SAUL_SENSE_ID_RSSI
sensor: RSSI
Definition: saul.h:130
SAUL_SENSE_CO2
@ SAUL_SENSE_CO2
sensor: CO2 Gas
Definition: saul.h:195
SAUL_SENSE_PRESS
@ SAUL_SENSE_PRESS
sensor: pressure
Definition: saul.h:183
SAUL_SENSE_PH
@ SAUL_SENSE_PH
sensor: pH
Definition: saul.h:217
errno.h
SAUL_SENSE_TEMP
@ SAUL_SENSE_TEMP
sensor: temperature
Definition: saul.h:169
SAUL_SENSE_GYRO
@ SAUL_SENSE_GYRO
sensor: gyroscope
Definition: saul.h:179
SAUL_SENSE_ANALOG
@ SAUL_SENSE_ANALOG
sensor: raw analog value
Definition: saul.h:185
SAUL_ACT_SWITCH
@ SAUL_ACT_SWITCH
actuator: simple on/off switch
Definition: saul.h:161
SAUL_SENSE_ID_POWER
@ SAUL_SENSE_ID_POWER
sensor: power
Definition: saul.h:137