jc42.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2017 Koen Zandberg
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 
33 #ifndef JC42_H
34 #define JC42_H
35 
36 #include "periph/i2c.h"
37 #include "saul.h"
38 
39 
40 #ifdef __cplusplus
41 extern "C" {
42 #endif
43 
48 #define JC42_OK (0)
49 #define JC42_NOI2C (-1)
50 #define JC42_NODEV (-2)
51 
57 typedef struct {
59  uint8_t addr;
60 } jc42_t;
61 
65 typedef struct {
68  uint8_t addr;
70 
75 
86 int jc42_init(jc42_t* dev, const jc42_params_t* params);
87 
97 int jc42_get_config(const jc42_t* dev, uint16_t* data);
98 
108 int jc42_set_config(const jc42_t* dev, uint16_t data);
109 
110 
120 int jc42_get_temperature(const jc42_t* dev, int16_t* temperature);
121 
122 #ifdef __cplusplus
123 }
124 #endif
125 
126 #endif /* JC42_H */
127 
jc42_t::addr
uint8_t addr
I2C address of this particular sensor.
Definition: jc42.h:59
i2c_t
unsigned int i2c_t
Default i2c_t type definition.
Definition: i2c.h:151
jc42_params_t::speed
i2c_speed_t speed
I2C device speed.
Definition: jc42.h:67
jc42_t::i2c
i2c_t i2c
I2C device that sensor is connected to.
Definition: jc42.h:58
i2c_speed_t
i2c_speed_t
Default mapping of I2C bus speed values.
Definition: i2c.h:175
jc42_get_config
int jc42_get_config(const jc42_t *dev, uint16_t *data)
Get content of configuration register.
saul_driver_t
Definition of the RIOT actuator/sensor interface.
Definition: saul.h:279
jc42_init
int jc42_init(jc42_t *dev, const jc42_params_t *params)
Initialize a jc42 device.
jc42_get_temperature
int jc42_get_temperature(const jc42_t *dev, int16_t *temperature)
Get measured temperature.
saul.h
Definition of the generic [S]ensor [A]ctuator [U]ber [L]ayer.
jc42_params_t
Device initialization parameters.
Definition: jc42.h:65
jc42_params_t::i2c
i2c_t i2c
I2C device that sensor is connected to.
Definition: jc42.h:66
jc42_t
Device descriptor for a jc42 device.
Definition: jc42.h:57
i2c.h
Low-level I2C peripheral driver interface definition.
jc42_set_config
int jc42_set_config(const jc42_t *dev, uint16_t data)
Set content of configuration register.
jc42_params_t::addr
uint8_t addr
Configured address of the sensor.
Definition: jc42.h:68
jc42_temperature_saul_driver
const saul_driver_t jc42_temperature_saul_driver
Export SAUL endpoint.