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 
90 int saul_reg_rm(saul_reg_t *dev);
91 
100 saul_reg_t *saul_reg_find_nth(int pos);
101 
110 saul_reg_t *saul_reg_find_type(uint8_t type);
111 
120 saul_reg_t *saul_reg_find_name(const char *name);
121 
133 int saul_reg_read(saul_reg_t *dev, phydat_t *res);
134 
146 int saul_reg_write(saul_reg_t *dev, phydat_t *data);
147 
148 #ifdef __cplusplus
149 }
150 #endif
151 
152 #endif /* SAUL_REG_H */
153 
saul_reg
saul_reg_t * saul_reg
Export the SAUL registry as global variable.
saul_reg_rm
int saul_reg_rm(saul_reg_t *dev)
Unregister a device from the SAUL registry.
saul_reg_find_type
saul_reg_t * saul_reg_find_type(uint8_t type)
Find the first device of the given type in the registry.
saul_reg_add
int saul_reg_add(saul_reg_t *dev)
Register a device with the SAUL registry.
saul_reg_find_name
saul_reg_t * saul_reg_find_name(const char *name)
Find a device by its name.
saul_reg_info_t
Additional data to collect for each entry.
Definition: saul_reg.h:49
phydat_t
Generic data structure for expressing physical values.
Definition: phydat.h:149
saul_reg_t
struct saul_reg saul_reg_t
SAUL registry entry.
saul_reg::name
const char * name
string identifier for the device
Definition: saul_reg.h:42
saul_reg
SAUL registry entry.
Definition: saul_reg.h:39
saul_reg_info_t::name
const char * name
string identifier for a device
Definition: saul_reg.h:50
saul_driver_t
Definition of the RIOT actuator/sensor interface.
Definition: saul.h:279
saul_reg::driver
const saul_driver_t * driver
the devices read callback
Definition: saul_reg.h:43
saul_reg_write
int saul_reg_write(saul_reg_t *dev, phydat_t *data)
Write data to the given device.
phydat.h
Generic data container for physical data interface.
saul_reg::dev
void * dev
pointer to the device descriptor
Definition: saul_reg.h:41
saul.h
Definition of the generic [S]ensor [A]ctuator [U]ber [L]ayer.
saul_reg_read
int saul_reg_read(saul_reg_t *dev, phydat_t *res)
Read data from the given device.
saul_reg::next
struct saul_reg * next
pointer to the next device
Definition: saul_reg.h:40
saul_reg_find_nth
saul_reg_t * saul_reg_find_nth(int pos)
Find a device by it's position in the registry.