saul_reg.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 
24 #ifndef SAUL_REG_H
25 #define SAUL_REG_H
26 
27 #include <stdint.h>
28 
29 #include "saul.h"
30 #include "phydat.h"
31 
32 #ifdef __cplusplus
33 extern "C" {
34 #endif
35 
39 typedef struct saul_reg {
40  struct saul_reg *next;
41  void *dev;
42  const char *name;
44 } saul_reg_t;
45 
49 typedef struct {
50  const char *name;
52 
56 extern saul_reg_t *saul_reg;
57 
70 int saul_reg_add(saul_reg_t *dev);
71 
80 int saul_reg_rm(saul_reg_t *dev);
81 
91 
100 saul_reg_t *saul_reg_find_type(uint8_t type);
101 
110 saul_reg_t *saul_reg_find_name(const char *name);
111 
123 int saul_reg_read(saul_reg_t *dev, phydat_t *res);
124 
136 int saul_reg_write(saul_reg_t *dev, phydat_t *data);
137 
138 #ifdef __cplusplus
139 }
140 #endif
141 
142 #endif /* SAUL_REG_H */
143 
int saul_reg_read(saul_reg_t *dev, phydat_t *res)
Read data from the given device.
struct saul_reg saul_reg_t
SAUL registry entry.
saul_reg_t * saul_reg_find_name(const char *name)
Find a device by its name.
saul_reg_t * saul_reg_find_nth(int pos)
Find a device by it's position in the registry.
Generic data container for physical data interface.
saul_driver_t const * driver
the devices read callback
Definition: saul_reg.h:43
saul_reg_t * saul_reg_find_type(uint8_t type)
Find the first device of the given type in the registry.
void * dev
pointer to the device descriptor
Definition: saul_reg.h:41
saul_reg_t * saul_reg
Export the SAUL registry as global variable.
Definition of the RIOT actuator/sensor interface.
Definition: saul.h:140
int saul_reg_add(saul_reg_t *dev)
Register a device with the SAUL registry.
struct saul_reg * next
pointer to the next device
Definition: saul_reg.h:40
Definition of the generic [S]ensor [A]ctuator [U]ber [L]ayer.
Generic data structure for expressing physical values.
Definition: phydat.h:135
int saul_reg_write(saul_reg_t *dev, phydat_t *data)
Write data to the given device.
Additional data to collect for each entry.
Definition: saul_reg.h:49
SAUL registry entry.
Definition: saul_reg.h:39
int saul_reg_rm(saul_reg_t *dev)
Unregister a device from the SAUL registry.
const char * name
string identifier for a device
Definition: saul_reg.h:50
const char * name
string identifier for the device
Definition: saul_reg.h:42