Toggle navigation
Documentation
The friendly Operating System for the Internet of Things
Loading...
Searching...
No Matches
opt3001_regs.h
Go to the documentation of this file.
1
/*
2
* SPDX-FileCopyrightText: 2019 HAW Hamburg
3
* SPDX-License-Identifier: LGPL-2.1-only
4
*/
5
6
#pragma once
7
17
18
#ifdef __cplusplus
19
extern
"C"
{
20
#endif
21
26
#define OPT3001_REGS_RESULT 0x00
27
#define OPT3001_REGS_CONFIG 0x01
28
#define OPT3001_REGS_LOW_LIMIT 0x02
29
#define OPT3001_REGS_HIGH_LIMIT 0x03
30
#define OPT3001_REGS_MANUFACTURER_ID 0x7E
31
#define OPT3001_REGS_DEVICE_ID 0x7F
32
33
#define OPT3001_DID_VALUE (0x3001)
34
35
#define OPT3001_CONFIG_RESET (0xC810)
36
37
#define OPT3001_CONFIG_RN_FSR (0xC000)
38
39
#define OPT3001_REGS_CONFIG_CT_MASK (0x0800)
40
#define OPT3001_REGS_CONFIG_CT(x) (((uint16_t)(x)) \
41
& OPT3001_REGS_CONFIG_CT_MASK)
42
43
#define OPT3001_CONFIG_M_SHUTDOWN (0x0)
44
#define OPT3001_CONFIG_M_SINGLE (0x1)
45
#define OPT3001_CONFIG_M_CONTINUOUS (0x2)
46
#define OPT3001_CONFIG_MOC_SHIFT (9U)
47
#define OPT3001_CONFIG_MOC_MASK (0x0600)
48
#define OPT3001_REGS_CONFIG_MOC(x) (((uint16_t)(((uint16_t)(x)) \
49
<< OPT3001_CONFIG_MOC_SHIFT)) \
50
& OPT3001_CONFIG_MOC_MASK)
51
52
#define OPT3001_REGS_CONFIG_OVF (1 << 8)
53
#define OPT3001_REGS_CONFIG_CRF (1 << 7)
54
#define OPT3001_REGS_CONFIG_FH (1 << 6)
55
#define OPT3001_REGS_CONFIG_FL (1 << 5)
56
#define OPT3001_REGS_CONFIG_L (1 << 4)
57
#define OPT3001_REGS_CONFIG_POL (1 << 3)
58
#define OPT3001_REGS_CONFIG_ME (1 << 2)
59
60
#define OPT3001_REGS_CONFIG_FC_MASK (0x0003)
61
62
#define OPT3001_REGS_LOW_LIMIT_EOC_ENABLE (0xC000)
63
64
#define OPT3001_REGS_REG_EXPONENT(x) ((x) >> 12)
65
#define OPT3001_REGS_REG_MANTISSA(x) ((x) & 0xFFF)
66
67
/*
68
* Time to wait for the conversion to complete.
69
* The data sheet of the device (sect. 6.5) indicates that the conversion time is the integration time plus 3 ms.
70
* It has been added a bit more time just to be safe.
71
*/
72
#define OPT3001_REGS_INT_TIME_SHORT 100000
73
#define OPT3001_REGS_INT_TIME_LONG 800000
74
75
#define OPT3001_CONVERSION_TIME_OFFSET 4000
76
77
#define OPT3001_CONVERSION_TIME_COMBINED OPT3001_REGS_INT_TIME_SHORT \
78
+ OPT3001_REGS_INT_TIME_LONG \
79
+ OPT3001_CONVERSION_TIME_OFFSET
80
81
82
#ifdef __cplusplus
83
}
84
#endif
85
Generated on Fri May 1 2026 15:22:59 by
1.13.2