opt3001.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2019 HAW Hamburg
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 
42 #ifndef OPT3001_H
43 #define OPT3001_H
44 
45 #include <stdint.h>
46 #include "periph/i2c.h"
47 
48 #ifdef __cplusplus
49 extern "C" {
50 #endif
51 
57 #ifndef OPT3001_I2C_ADDRESS
58 #define OPT3001_I2C_ADDRESS (0x45)
59 #endif
60 
65 #define OPT3001_CONVERSION_TIME_100_MS (0x0000)
66 #define OPT3001_CONVERSION_TIME_800_MS (0x0800)
75 #ifndef OPT3001_CONVERSION_TIME
76 #define OPT3001_CONVERSION_TIME OPT3001_CONVERSION_TIME_800_MS
77 #endif
78 
82 typedef struct {
84  uint8_t i2c_addr;
86 
90 typedef struct {
92 } opt3001_t;
93 
97 enum {
102 };
103 
114 int opt3001_init(opt3001_t *dev, const opt3001_params_t *params);
115 
125 int opt3001_reset(const opt3001_t *dev);
126 
135 int opt3001_set_active(const opt3001_t *dev);
136 
146 int opt3001_read_lux(const opt3001_t *dev, uint32_t *convl);
147 
148 #ifdef __cplusplus
149 }
150 #endif
151 
152 #endif /* OPT3001_H */
153 
i2c_t i2c_dev
I2C device, the sensor is connected to.
Definition: opt3001.h:83
Success, no error.
Definition: opt3001.h:98
Internal device error.
Definition: opt3001.h:100
opt3001_params_t params
Configuration parameters.
Definition: opt3001.h:91
unsigned int i2c_t
Default i2c_t type definition.
Definition: i2c.h:157
int opt3001_init(opt3001_t *dev, const opt3001_params_t *params)
Initialize the OPT3001 sensor driver.
int opt3001_read_lux(const opt3001_t *dev, uint32_t *convl)
Read sensor&#39;s raw data and convert it to milliLux.
I2C bus error.
Definition: opt3001.h:99
Parameters needed for device initialization.
Definition: opt3001.h:82
int opt3001_reset(const opt3001_t *dev)
Reset the OPT3001 sensor while simultaneous deactivating measurements.
General error.
Definition: opt3001.h:101
Device descriptor for OPT3001 sensors.
Definition: opt3001.h:90
uint8_t i2c_addr
The sensor&#39;s slave address on the I2C bus.
Definition: opt3001.h:84
int opt3001_set_active(const opt3001_t *dev)
Set active mode, this enables periodic measurements.
Low-level I2C peripheral driver interface definition.