Loading...
Searching...
No Matches
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#include "kernel_defines.h"
48
49#ifdef __cplusplus
50extern "C" {
51#endif
52
57#define OPT3001_CONVERSION_TIME_100_MS (0x0000)
58#define OPT3001_CONVERSION_TIME_800_MS (0x0800)
72#ifndef CONFIG_OPT3001_I2C_ADDRESS
73#define CONFIG_OPT3001_I2C_ADDRESS (0x45)
74#endif
75
82#if IS_ACTIVE(CONFIG_OPT3001_CONVERSION_TIME_100)
83#define CONFIG_OPT3001_CONVERSION_TIME OPT3001_CONVERSION_TIME_100_MS
84#elif IS_ACTIVE(CONFIG_OPT3001_CONVERSION_TIME_800)
85#define CONFIG_OPT3001_CONVERSION_TIME OPT3001_CONVERSION_TIME_800_MS
86#endif
87
88#ifndef CONFIG_OPT3001_CONVERSION_TIME
89#define CONFIG_OPT3001_CONVERSION_TIME OPT3001_CONVERSION_TIME_800_MS
90#endif
96typedef struct {
98 uint8_t i2c_addr;
100
104typedef struct {
106} opt3001_t;
107
111enum {
117
128int opt3001_init(opt3001_t *dev, const opt3001_params_t *params);
129
139int opt3001_reset(const opt3001_t *dev);
140
150
160int opt3001_read_lux(const opt3001_t *dev, uint32_t *convl);
161
162#ifdef __cplusplus
163}
164#endif
165
166#endif /* OPT3001_H */
int opt3001_set_active(const opt3001_t *dev)
Set active mode, this enables periodic measurements.
int opt3001_read_lux(const opt3001_t *dev, uint32_t *convl)
Read sensor's raw data and convert it to milliLux.
int opt3001_init(opt3001_t *dev, const opt3001_params_t *params)
Initialize the OPT3001 sensor driver.
int opt3001_reset(const opt3001_t *dev)
Reset the OPT3001 sensor while simultaneous deactivating measurements.
@ OPT3001_OK
Success, no error.
Definition opt3001.h:112
@ OPT3001_ERROR_DEV
Internal device error.
Definition opt3001.h:114
@ OPT3001_ERROR_BUS
I2C bus error.
Definition opt3001.h:113
@ OPT3001_ERROR
General error.
Definition opt3001.h:115
uint_fast8_t i2c_t
Default i2c_t type definition.
Definition i2c.h:151
Low-level I2C peripheral driver interface definition.
Common macros and compiler attributes/pragmas configuration.
Parameters needed for device initialization.
Definition opt3001.h:96
i2c_t i2c_dev
I2C device, the sensor is connected to.
Definition opt3001.h:97
uint8_t i2c_addr
The sensor's slave address on the I2C bus.
Definition opt3001.h:98
Device descriptor for OPT3001 sensors.
Definition opt3001.h:104
opt3001_params_t params
Configuration parameters.
Definition opt3001.h:105