tcs37727-internal.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2015 PHYTEC Messtechnik GmbH
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 
21 #ifndef TCS37727_INTERNAL_H
22 #define TCS37727_INTERNAL_H
23 
24 #ifdef __cplusplus
25 extern "C"
26 {
27 #endif
28 
29 #ifndef TCS37727_AG_THRESHOLD_LOW
30 #define TCS37727_AG_THRESHOLD_LOW 200
31 #endif
32 
33 #ifndef TCS37727_AG_THRESHOLD_HIGH
34 #define TCS37727_AG_THRESHOLD_HIGH (65535 - TCS37727_AG_THRESHOLD_LOW)
35 #endif
36 
42 #define TCS37727_ENABLE 0x80 /* Enables states and interrupts */
43 #define TCS37727_ATIME 0x81 /* RGBC time */
44 #define TCS37727_PTIME 0x82 /* Proximity time */
45 #define TCS37727_WTIME 0x83 /* Wait time */
46 #define TCS37727_AILTL 0x04 /* Clear interrupt low threshold low byte */
47 #define TCS37727_AILTH 0x05 /* Clear interrupt low threshold high byte */
48 #define TCS37727_AIHTL 0x06 /* Clear interrupt high threshold low byte */
49 #define TCS37727_AIHTH 0x07 /* Clear interrupt high threshold high byte */
50 #define TCS37727_PILTL 0x08 /* Proximity interrupt low threshold low byte */
51 #define TCS37727_PILTH 0x09 /* Proximity interrupt low threshold high byte */
52 #define TCS37727_PIHTL 0x0A /* Proximity interrupt high threshold low byte */
53 #define TCS37727_PIHTH 0x0B /* Proximity interrupt high threshold high byte */
54 #define TCS37727_PERS 0x8C /* Interrupt persistence filters */
55 #define TCS37727_CONFIG 0x8D /* Configuration */
56 #define TCS37727_PPULSE 0x8E /* Proximity pulse count */
57 #define TCS37727_CONTROL 0x8F /* Gain control register */
58 #define TCS37727_ID 0x92 /* Device IDID */
59 #define TCS37727_STATUS 0x93 /* Device status */
60 #define TCS37727_CDATA 0x14 /* Clear ADC data low byte */
61 #define TCS37727_CDATAH 0x15 /* Clear ADC data high byte */
62 #define TCS37727_RDATA 0x16 /* Red ADC data low byte */
63 #define TCS37727_RDATAH 0x17 /* Red ADC data high byte */
64 #define TCS37727_GDATA 0x18 /* Green ADC data low byte */
65 #define TCS37727_GDATAH 0x19 /* Green ADC data high byte */
66 #define TCS37727_BDATA 0x1A /* Blue ADC data low byte */
67 #define TCS37727_BDATAH 0x1B /* Blue ADC data high byte */
68 #define TCS37727_PDATA 0x1C /* Proximity ADC data low byte */
69 #define TCS37727_PDATAH 0x1D /* Proximity ADC data high byte */
70 
74 #define TCS37727_BYTE_TRANS 0x80 /* Repeated byte protocol transaction */
75 #define TCS37727_INC_TRANS 0xA0 /* Auto-increment protocol transaction */
76 #define TCS37727_SF_PICLR 0xE5 /* Proximity interrupt clear */
77 #define TCS37727_SF_CICLR 0xE6 /* Clear channel interrupt clear */
78 #define TCS37727_SF_PCICLR 0xE7 /* Proximity and Clear channel interrupt clear */
79 
83 #define TCS37727_ENABLE_PIEN (1 << 5) /* Proximity interrupt enable */
84 #define TCS37727_ENABLE_AIEN (1 << 4) /* Clear channel interrupt enable */
85 #define TCS37727_ENABLE_WEN (1 << 3) /* Wait enable, activates the wait feature */
86 #define TCS37727_ENABLE_PEN (1 << 2) /* Proximity enable, activates the proximity function */
87 #define TCS37727_ENABLE_AEN (1 << 1) /* RGBC enable, actives the two-channel ADC */
88 #define TCS37727_ENABLE_PON (1 << 0) /* Power ON */
89 
93 #define TCS37727_CONTROL_PDRIVE_100 0x00 /* 100 mA LED Drive Strength */
94 #define TCS37727_CONTROL_PDRIVE_50 0x04 /* 50 mA LED Drive Strength */
95 #define TCS37727_CONTROL_PDRIVE_25 0x08 /* 25 mA LED Drive Strength */
96 #define TCS37727_CONTROL_PDRIVE_12 0x0C /* 12.5 mA LED Drive Strength */
97 #define TCS37727_CONTROL_PDRIVE_MASK 0x0C /* PDRIVE Mask */
98 #define TCS37727_CONTROL_AGAIN_1 0x00 /* 1 × gain RGBC Gain Value */
99 #define TCS37727_CONTROL_AGAIN_4 0x01 /* 4 × gain RGBC Gain Value */
100 #define TCS37727_CONTROL_AGAIN_16 0x02 /* 16 × gain RGBC Gain Value */
101 #define TCS37727_CONTROL_AGAIN_60 0x03 /* 60 × gain RGBC Gain Value */
102 #define TCS37727_CONTROL_AGAIN_MASK 0x03 /* AGAIN Mask */
103 
107 #define TCS37727_ID_VALUE 0x49
108 
112 #define TCS37727_ATIME_MIN 2400 /* 2.4ms integration time, max count 1024 */
113 #define TCS37727_ATIME_MAX 614000 /* 614ms integration time, max count 0xffff */
114 
115 #define TCS37727_ATIME_TO_REG(val) (256 - (uint8_t)((val) / 2400))
116 #define TCS37727_ATIME_TO_US(reg) ((256 - (uint8_t)(reg)) * 2400)
117 
123 #define DGF_IF 310
124 #define R_COEF_IF 136
125 #define G_COEF_IF 1000
126 #define B_COEF_IF -444
127 #define CT_COEF_IF 3810
128 #define CT_OFFSET_IF 1391
129 
130 #ifdef __cplusplus
131 }
132 #endif
133 
134 #endif
135