saul_reg.h
Go to the documentation of this file.
1 /*
2  * SPDX-FileCopyrightText: 2015 Freie Universität Berlin
3  * SPDX-License-Identifier: LGPL-2.1-only
4  */
5 
6 #pragma once
7 
23 #include <stdint.h>
24 
25 #include "saul.h"
26 #include "phydat.h"
27 
28 #ifdef __cplusplus
29 extern "C" {
30 #endif
31 
35 typedef struct saul_reg {
36  struct saul_reg *next;
37  void *dev;
38  const char *name;
41 
45 typedef struct {
46  const char *name;
48 
52 extern saul_reg_t *saul_reg;
53 
67 
77 
87 
96 saul_reg_t *saul_reg_find_name(const char *name);
97 
107 saul_reg_t *saul_reg_find_type_and_name(uint8_t type, const char *name);
108 
121 
133 int saul_reg_write(saul_reg_t *dev, const phydat_t *data);
134 
135 #ifdef __cplusplus
136 }
137 #endif
138 
saul_reg_t * saul_reg_find_type(uint8_t type)
Find the first device by its type in the registry.
saul_reg_t * saul_reg_find_nth(int pos)
Find a device by its position in the registry.
int saul_reg_write(saul_reg_t *dev, const phydat_t *data)
Write data to the given device.
saul_reg_t * saul_reg_find_type_and_name(uint8_t type, const char *name)
Find the first device by its type and name in the registry.
saul_reg_t * saul_reg
Export the SAUL registry as global variable.
int saul_reg_add(saul_reg_t *dev)
Register a device with the SAUL registry.
saul_reg_t * saul_reg_find_name(const char *name)
Find the first device by its name in the registry.
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.
Functionality for converting from Phydat to SenML.
Generic data structure for expressing physical values.
Definition: phydat.h:151
Definition of the RIOT actuator/sensor interface.
Definition: saul.h:283
Additional data to collect for each entry.
Definition: saul_reg.h:45
const char * name
string identifier for a device
Definition: saul_reg.h:46
SAUL registry entry.
Definition: saul_reg.h:35
saul_driver_t const * driver
the devices read callback
Definition: saul_reg.h:39
const char * name
string identifier for the device
Definition: saul_reg.h:38
void * dev
pointer to the device descriptor
Definition: saul_reg.h:37
struct saul_reg * next
pointer to the next device
Definition: saul_reg.h:36