Toggle navigation
Documentation
The friendly Operating System for the Internet of Things
opt3001_regs.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
9
#pragma once
10
21
#ifdef __cplusplus
22
extern
"C"
{
23
#endif
24
29
#define OPT3001_REGS_RESULT 0x00
30
#define OPT3001_REGS_CONFIG 0x01
31
#define OPT3001_REGS_LOW_LIMIT 0x02
32
#define OPT3001_REGS_HIGH_LIMIT 0x03
33
#define OPT3001_REGS_MANUFACTURER_ID 0x7E
34
#define OPT3001_REGS_DEVICE_ID 0x7F
36
#define OPT3001_DID_VALUE (0x3001)
38
#define OPT3001_CONFIG_RESET (0xC810)
40
#define OPT3001_CONFIG_RN_FSR (0xC000)
42
#define OPT3001_REGS_CONFIG_CT_MASK (0x0800)
43
#define OPT3001_REGS_CONFIG_CT(x) (((uint16_t)(x)) \
44
& OPT3001_REGS_CONFIG_CT_MASK)
46
#define OPT3001_CONFIG_M_SHUTDOWN (0x0)
47
#define OPT3001_CONFIG_M_SINGLE (0x1)
48
#define OPT3001_CONFIG_M_CONTINUOUS (0x2)
49
#define OPT3001_CONFIG_MOC_SHIFT (9U)
50
#define OPT3001_CONFIG_MOC_MASK (0x0600)
51
#define OPT3001_REGS_CONFIG_MOC(x) (((uint16_t)(((uint16_t)(x)) \
52
<< OPT3001_CONFIG_MOC_SHIFT)) \
53
& OPT3001_CONFIG_MOC_MASK)
55
#define OPT3001_REGS_CONFIG_OVF (1 << 8)
56
#define OPT3001_REGS_CONFIG_CRF (1 << 7)
57
#define OPT3001_REGS_CONFIG_FH (1 << 6)
58
#define OPT3001_REGS_CONFIG_FL (1 << 5)
59
#define OPT3001_REGS_CONFIG_L (1 << 4)
60
#define OPT3001_REGS_CONFIG_POL (1 << 3)
61
#define OPT3001_REGS_CONFIG_ME (1 << 2)
63
#define OPT3001_REGS_CONFIG_FC_MASK (0x0003)
65
#define OPT3001_REGS_LOW_LIMIT_EOC_ENABLE (0xC000)
67
#define OPT3001_REGS_REG_EXPONENT(x) ((x) >> 12)
68
#define OPT3001_REGS_REG_MANTISSA(x) ((x) & 0xFFF)
70
/*
71
* Time to wait for the conversion to complete.
72
* The data sheet of the device (sect. 6.5) indicates that the conversion time is the integration time plus 3 ms.
73
* It has been added a bit more time just to be safe.
74
*/
75
#define OPT3001_REGS_INT_TIME_SHORT 100000
76
#define OPT3001_REGS_INT_TIME_LONG 800000
78
#define OPT3001_CONVERSION_TIME_OFFSET 4000
80
#define OPT3001_CONVERSION_TIME_COMBINED OPT3001_REGS_INT_TIME_SHORT \
81
+ OPT3001_REGS_INT_TIME_LONG \
82
+ OPT3001_CONVERSION_TIME_OFFSET
85
#ifdef __cplusplus
86
}
87
#endif
88
Generated on Mon Jun 30 2025 14:58:02 by
1.9.1