a752c7ab
elopes
add first test an...
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
|
/*
* Copyright (C) 2016 Freie Universitรคt Berlin
*
* This file is subject to the terms and conditions of the GNU Lesser
* General Public License v2.1. See the file LICENSE in the top level
* directory for more details.
*/
/**
* @defgroup drivers_bh1750fvi BH1750FVI Light Sensor
* @ingroup drivers_sensors
* @brief Driver for the Rohm BH1750FVI ambient light sensor
*
* @{
* @file
* @brief Interface definition for the Rohm BH1750FVI ambient light sensor
*
* @author Hauke Petersen <hauke.petersen@fu-berlin.de>
*/
#ifndef BH1750FVI_H
#define BH1750FVI_H
#include "periph/i2c.h"
#ifdef __cplusplus
extern "C" {
#endif
/**
* @name Possible I2C bus addresses of the device
*
* The actual address of the device depends on the state of the ADDR pin.
* @{
*/
#define BH1750FVI_ADDR_PIN_LOW (0x5c) /**< ADDR pin := 0 */
#define BH1750FVI_ADDR_PIN_HIGH (0x23) /**< ADDR pin := 1 */
/** @} */
/**
* @brief Default address of BH1750FVI sensors
*/
#define BH1750FVI_DEFAULT_ADDR BH1750FVI_ADDR_PIN_HIGH
/**
* @brief Maximum I2C bus speed to use with the device
*/
#define BH1750FVI_I2C_MAX_CLK I2C_SPEED_FAST
/**
* @brief Status and error return codes
*/
enum {
BH1750FVI_OK = 0, /**< everything was fine */
BH1750FVI_ERR_I2C = -1 /**< error initializing the I2C bus */
};
/**
* @brief Device descriptor for BH1570FVI devices
*/
typedef struct {
i2c_t i2c; /**< I2C bus the device is connected to */
uint8_t addr; /**< slave address of the device */
} bh1750fvi_t;
/**
* @brief Set of configuration parameters for BH1750FV devices
*/
typedef struct {
i2c_t i2c; /**< I2C bus the device is connected to */
uint8_t addr; /**< slave address of the device */
i2c_speed_t clk; /**< clock speed to use on the I2C bus */
} bh1750fvi_params_t;
/**
* @brief Initialize the given BH1750FVI device
*
* @param[out] dev device descriptor of the targeted device
* @param[in] params device configuration (i2c bus, address and bus clock)
*
* @return 0 on success
* @return -1 if unable to speak to the device
*/
int bh1750fvi_init(bh1750fvi_t *dev, bh1750fvi_params_t *params);
/**
* @brief Read a ambient light value from the given device [in LUX]
*
* The result value is the measured ambient light intensity in LUX and ranges
* from 0 to 54612. Taking one measurement takes ~120ms, so it takes this amount
* of time until the function returns.
*
* @param[in] dev device descriptor of the targeted device
*
* @return ambient light intensity in LUX
*/
uint16_t bh1750fvi_sample(const bh1750fvi_t *dev);
#ifdef __cplusplus
}
#endif
#endif /* BH1750FVI_H */
/** @} */
|