tsl256xreg.h revision 1.2 1 1.2 thorpej /* $NetBSD: tsl256xreg.h,v 1.2 2021/01/04 21:59:48 thorpej Exp $ */
2 1.1 thorpej
3 1.1 thorpej /*-
4 1.1 thorpej * Copyright (c) 2018 Jason R. Thorpe
5 1.1 thorpej * All rights reserved.
6 1.1 thorpej *
7 1.1 thorpej * Redistribution and use in source and binary forms, with or without
8 1.1 thorpej * modification, are permitted provided that the following conditions
9 1.1 thorpej * are met:
10 1.1 thorpej * 1. Redistributions of source code must retain the above copyright
11 1.1 thorpej * notice, this list of conditions and the following disclaimer.
12 1.1 thorpej * 2. Redistributions in binary form must reproduce the above copyright
13 1.1 thorpej * notice, this list of conditions and the following disclaimer in the
14 1.1 thorpej * documentation and/or other materials provided with the distribution.
15 1.1 thorpej *
16 1.1 thorpej * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
17 1.1 thorpej * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
18 1.1 thorpej * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
19 1.1 thorpej * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
20 1.1 thorpej * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21 1.1 thorpej * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22 1.1 thorpej * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23 1.1 thorpej * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24 1.1 thorpej * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25 1.1 thorpej * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26 1.1 thorpej * POSSIBILITY OF SUCH DAMAGE.
27 1.1 thorpej */
28 1.1 thorpej
29 1.1 thorpej #ifndef tsl256xreg_h_included
30 1.1 thorpej #define tsl256xreg_h_included
31 1.1 thorpej
32 1.1 thorpej /*
33 1.1 thorpej * Hardware definitions for the TAOS TSL2560 (SMBus) and TSL2561 (I2C).
34 1.1 thorpej *
35 1.1 thorpej * These devices combine a broadband photodiode (visible light + infrared)
36 1.1 thorpej * and an additional ifrared phtodiode onto a single CMOS integrated circuit.
37 1.1 thorpej * The devices include programmable thresholds that can trigger SMB-Alert
38 1.1 thorpej * type interrupts (TSL2560) or a traditional level-triggered interrupt
39 1.1 thorpej * (TSL2561) that remains asserted until cleared.
40 1.1 thorpej */
41 1.1 thorpej
42 1.1 thorpej /*
43 1.1 thorpej * Valid I2C addresses for the TSL2561. The address is selected based
44 1.1 thorpej * on how the ADDR_SEL pin is connected.
45 1.1 thorpej */
46 1.1 thorpej #define TSL256x_SLAVEADDR_GND 0x29 /* ADDR SEL tied to ground */
47 1.1 thorpej #define TSL256x_SLAVEADDR_FLOAT 0x39 /* ADDR SEL left floating */
48 1.1 thorpej #define TSL256x_SLAVEADDR_VDD 0x49 /* ADDR SEL tied to Vdd */
49 1.1 thorpej #define TSL256x_SMB_ALERT_ADDR 0x0c /* SMB Alert address (all configs) */
50 1.1 thorpej
51 1.1 thorpej /*
52 1.1 thorpej * TSL256x register definitions.
53 1.1 thorpej */
54 1.1 thorpej
55 1.1 thorpej /* COMMAND - Specifies register address and other parameters */
56 1.2 thorpej #define COMMAND6x_REGMASK 0x0f /* register address mask */
57 1.2 thorpej #define COMMAND6x_BLOCK 0x10 /* transaction uses block read/write */
58 1.2 thorpej #define COMMAND6x_WORD 0x20 /* transaction uses word read/write */
59 1.2 thorpej #define COMMAND6x_CLEAR 0x40 /* clear pending interrupt */
60 1.2 thorpej #define COMMAND6x_CMD 0x80 /* Select command register; MBO */
61 1.1 thorpej
62 1.1 thorpej
63 1.1 thorpej /* CONTROL - Control of basic functions */
64 1.1 thorpej #define TSL256x_REG_CONTROL 0x0
65 1.2 thorpej #define CONTROL6x_POWER_OFF 0x00
66 1.2 thorpej #define CONTROL6x_POWER_ON 0x03
67 1.1 thorpej
68 1.1 thorpej
69 1.1 thorpej /* TIMING - Integration time / gain control */
70 1.1 thorpej #define TSL256x_REG_TIMING 0x1
71 1.2 thorpej #define TIMING6x_INTEG_13_7ms 0x00 /* 13.7ms integration time */
72 1.2 thorpej #define TIMING6x_INTEG_101ms 0x01 /* 101ms integration time */
73 1.2 thorpej #define TIMING6x_INTEG_402ms 0x02 /* 402ms integration time */
74 1.2 thorpej #define TIMING6x_INTEG_MANUAL 0x03 /* use manual timing */
75 1.2 thorpej #define TIMING6x_MANUAL 0x08 /* manual timing; 1 starts, 0 stops */
76 1.2 thorpej #define TIMING6x_GAIN_1X 0x00
77 1.2 thorpej #define TIMING6x_GAIN_16X 0x10
78 1.1 thorpej
79 1.1 thorpej
80 1.1 thorpej /* THRESHLOWLOW - Low byte of low interrupt threshold */
81 1.1 thorpej #define TSL256x_REG_LOWLOW 0x2
82 1.1 thorpej
83 1.1 thorpej
84 1.1 thorpej /* THRESHLOWHIGH - High byte of low interrupt threshold */
85 1.1 thorpej #define TSL256x_REG_LOWHIGH 0x3
86 1.1 thorpej
87 1.1 thorpej
88 1.1 thorpej /* THRESHHIGHLOW - Low byte of high interrupt threshold */
89 1.1 thorpej #define TSL256x_REG_HIGHLOW 0x4
90 1.1 thorpej
91 1.1 thorpej
92 1.1 thorpej /* THRESHHIGHHIGH - High byte of high interrupt threshold */
93 1.1 thorpej #define TSL256x_REG_HIGHHIGH 0x5
94 1.1 thorpej
95 1.1 thorpej
96 1.1 thorpej /* INTERRUPT - Interrupt control */
97 1.1 thorpej #define TSL256x_REG_INTERRUPT 0x6
98 1.2 thorpej #define INTERRUPT6x_LEVEL 0x01 /* Level-triggered interrupt */
99 1.2 thorpej #define INTERRUPT6x_SMB_ALERT 0x02 /* SMB Alert compliant interrupt */
100 1.2 thorpej #define INTERRUPT6x_TEST 0x03 /* interrupt test */
101 1.2 thorpej #define INTERRUPT6x_PERSIST(x) ((x) << 4)
102 1.1 thorpej /*
103 1.1 thorpej * Interrupt persist settings:
104 1.1 thorpej * 0 - Every ADC cycle generates an interrupt
105 1.1 thorpej * 1..15 - # integration periods outside threshold range
106 1.1 thorpej */
107 1.1 thorpej
108 1.1 thorpej
109 1.1 thorpej /* 0x7 - Reserved */
110 1.1 thorpej
111 1.1 thorpej
112 1.1 thorpej /* CRC - Factory test -- not a user register */
113 1.1 thorpej #define TSL256x_REG_CRC 0x8
114 1.1 thorpej
115 1.1 thorpej
116 1.1 thorpej /* 0x9 - Reserved */
117 1.1 thorpej
118 1.1 thorpej
119 1.1 thorpej /* ID - Part number / Rev ID */
120 1.1 thorpej #define TSL256x_REG_ID 0xa
121 1.2 thorpej #define ID6x_GET_PARTNO(x) (((x) & 0xf0) >> 4)
122 1.2 thorpej #define ID6x_PARTNO_TSL2560 0x0
123 1.2 thorpej #define ID6x_PARTNO_TSL2561 0x1
124 1.2 thorpej #define ID6x_GET_REVNO(x) ((x) & 0x0f)
125 1.1 thorpej
126 1.1 thorpej
127 1.1 thorpej /* 0xb - Reserved */
128 1.1 thorpej
129 1.1 thorpej
130 1.1 thorpej /* DATA0LOW - Low byte of ADC channel 0 */
131 1.1 thorpej #define TSL256x_REG_DATA0LOW 0xc
132 1.1 thorpej
133 1.1 thorpej
134 1.1 thorpej /* DATA0HIGH - High byte of ADC channel 0 */
135 1.1 thorpej #define TSL256x_REG_DATA0HIGH 0xd
136 1.1 thorpej
137 1.1 thorpej
138 1.1 thorpej /* DATA1LOW - Low byte of ADC channel 1 */
139 1.1 thorpej #define TSL256x_REG_DATA1LOW 0xe
140 1.1 thorpej
141 1.1 thorpej
142 1.1 thorpej /* DATA1HIGH - High byte of ADC channel 1 */
143 1.1 thorpej #define TSL256x_REG_DATA1HIGH 0xf
144 1.1 thorpej
145 1.1 thorpej #endif /* tsl256xreg_h_included */
146