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
* 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
19
#ifndef OPT3001_REGS_H
20
#define OPT3001_REGS_H
21
22
#ifdef __cplusplus
23
extern
"C"
{
24
#endif
25
30
#define OPT3001_REGS_RESULT 0x00
31
#define OPT3001_REGS_CONFIG 0x01
32
#define OPT3001_REGS_LOW_LIMIT 0x02
33
#define OPT3001_REGS_HIGH_LIMIT 0x03
34
#define OPT3001_REGS_MANUFACTURER_ID 0x7E
35
#define OPT3001_REGS_DEVICE_ID 0x7F
37
#define OPT3001_DID_VALUE (0x3001)
39
#define OPT3001_CONFIG_RESET (0xC810)
41
#define OPT3001_CONFIG_RN_FSR (0xC000)
43
#define OPT3001_REGS_CONFIG_CT_MASK (0x0800)
44
#define OPT3001_REGS_CONFIG_CT(x) (((uint16_t)(x)) \
45
& OPT3001_REGS_CONFIG_CT_MASK)
47
#define OPT3001_CONFIG_M_SHUTDOWN (0x0)
48
#define OPT3001_CONFIG_M_SINGLE (0x1)
49
#define OPT3001_CONFIG_M_CONTINUOUS (0x2)
50
#define OPT3001_CONFIG_MOC_SHIFT (9U)
51
#define OPT3001_CONFIG_MOC_MASK (0x0600)
52
#define OPT3001_REGS_CONFIG_MOC(x) (((uint16_t)(((uint16_t)(x)) \
53
<< OPT3001_CONFIG_MOC_SHIFT)) \
54
& OPT3001_CONFIG_MOC_MASK)
56
#define OPT3001_REGS_CONFIG_OVF (1 << 8)
57
#define OPT3001_REGS_CONFIG_CRF (1 << 7)
58
#define OPT3001_REGS_CONFIG_FH (1 << 6)
59
#define OPT3001_REGS_CONFIG_FL (1 << 5)
60
#define OPT3001_REGS_CONFIG_L (1 << 4)
61
#define OPT3001_REGS_CONFIG_POL (1 << 3)
62
#define OPT3001_REGS_CONFIG_ME (1 << 2)
64
#define OPT3001_REGS_CONFIG_FC_MASK (0x0003)
66
#define OPT3001_REGS_LOW_LIMIT_EOC_ENABLE (0xC000)
68
#define OPT3001_REGS_REG_EXPONENT(x) ((x) >> 12)
69
#define OPT3001_REGS_REG_MANTISSA(x) ((x) & 0xFFF)
71
/*
72
* Time to wait for the conversion to complete.
73
* The data sheet of the device (sect. 6.5) indicates that the conversion time is the integration time plus 3 ms.
74
* It has been added a bit more time just to be safe.
75
*/
76
#define OPT3001_REGS_INT_TIME_SHORT 100000
77
#define OPT3001_REGS_INT_TIME_LONG 800000
79
#define OPT3001_CONVERSION_TIME_OFFSET 4000
81
#define OPT3001_CONVERSION_TIME_COMBINED OPT3001_REGS_INT_TIME_SHORT \
82
+ OPT3001_REGS_INT_TIME_LONG \
83
+ OPT3001_CONVERSION_TIME_OFFSET
86
#ifdef __cplusplus
87
}
88
#endif
89
90
#endif
/* OPT3001_REGS_H */
Generated on Fri Nov 15 2024 22:46:37 by
1.9.8