ESPHome 2026.5.0b1
Loading...
Searching...
No Matches
ltr_definitions_501.h
Go to the documentation of this file.
1#pragma once
3#include <cstdint>
5namespace esphome::ltr501 {
7enum class CommandRegisters : uint8_t {
8 ALS_CONTR = 0x80, // ALS operation mode control and SW reset
9 PS_CONTR = 0x81, // PS operation mode control
10 PS_LED = 0x82, // PS LED pulse frequency control
11 PS_N_PULSES = 0x83, // PS number of pulses control
12 PS_MEAS_RATE = 0x84, // PS measurement rate in active mode
13 MEAS_RATE = 0x85, // ALS measurement rate in active mode
14 PART_ID = 0x86, // Part Number ID and Revision ID
15 MANUFAC_ID = 0x87, // Manufacturer ID
16 ALS_DATA_CH1_0 = 0x88, // ALS measurement CH1 data, lower byte - infrared only
17 ALS_DATA_CH1_1 = 0x89, // ALS measurement CH1 data, upper byte - infrared only
18 ALS_DATA_CH0_0 = 0x8A, // ALS measurement CH0 data, lower byte - visible + infrared
19 ALS_DATA_CH0_1 = 0x8B, // ALS measurement CH0 data, upper byte - visible + infrared
20 ALS_PS_STATUS = 0x8C, // ALS PS new data status
21 PS_DATA_0 = 0x8D, // PS measurement data, lower byte
22 PS_DATA_1 = 0x8E, // PS measurement data, upper byte
23 ALS_PS_INTERRUPT = 0x8F, // Interrupt status
24 PS_THRES_UP_0 = 0x90, // PS interrupt upper threshold, lower byte
25 PS_THRES_UP_1 = 0x91, // PS interrupt upper threshold, upper byte
26 PS_THRES_LOW_0 = 0x92, // PS interrupt lower threshold, lower byte
27 PS_THRES_LOW_1 = 0x93, // PS interrupt lower threshold, upper byte
28 PS_OFFSET_1 = 0x94, // PS offset, upper byte
29 PS_OFFSET_0 = 0x95, // PS offset, lower byte
30 // 0x96 - reserved
31 ALS_THRES_UP_0 = 0x97, // ALS interrupt upper threshold, lower byte
32 ALS_THRES_UP_1 = 0x98, // ALS interrupt upper threshold, upper byte
33 ALS_THRES_LOW_0 = 0x99, // ALS interrupt lower threshold, lower byte
34 ALS_THRES_LOW_1 = 0x9A, // ALS interrupt lower threshold, upper byte
35 // 0x9B - reserved
36 // 0x9C - reserved
37 // 0x9D - reserved
38 INTERRUPT_PERSIST = 0x9E // Interrupt persistence filter
39};
40
41// ALS Sensor gain levels
42enum AlsGain501 : uint8_t {
43 GAIN_1 = 0, // GAIN_RANGE_2 // default
44 GAIN_150 = 1, // GAIN_RANGE_1
45};
46static const uint8_t GAINS_COUNT = 2;
47
48// ALS Sensor integration times
49enum IntegrationTime501 : uint8_t {
50 INTEGRATION_TIME_100MS = 0, // default
51 INTEGRATION_TIME_50MS = 1, // only in Dynamic GAIN_RANGE_2
52 INTEGRATION_TIME_200MS = 2, // only in Dynamic GAIN_RANGE_1
53 INTEGRATION_TIME_400MS = 3, // only in Dynamic GAIN_RANGE_1
54};
55static const uint8_t TIMES_COUNT = 4;
56
57// ALS Sensor measurement repeat rate
66
67// PS Sensor gain levels
68enum PsGain501 : uint8_t {
69 PS_GAIN_1 = 0, // default
73};
74
75// LED Pulse Modulation Frequency
86
87// LED current duty
88enum PsLedDuty : uint8_t {
90 PS_LED_DUTY_50 = 1, // default
93};
94
95// LED pulsed current level
106
107// PS measurement rate
118
119//
120// ALS_CONTR Register (0x80)
121//
123 uint8_t raw;
124 struct {
125 bool asl_mode_xxx : 1;
127 bool sw_reset : 1;
129 uint8_t reserved : 4;
130 } __attribute__((packed));
131};
132
133//
134// PS_CONTR Register (0x81)
135//
137 uint8_t raw;
138 struct {
139 bool ps_mode_xxx : 1;
142 bool reserved_4 : 1;
143 bool reserved_5 : 1;
144 bool reserved_6 : 1;
145 bool reserved_7 : 1;
146 } __attribute__((packed));
147};
148
149//
150// PS_LED Register (0x82)
151//
159};
160
161//
162// PS_N_PULSES Register (0x83)
163//
165 uint8_t raw;
167};
168
169//
170// PS_MEAS_RATE Register (0x84)
171//
173 uint8_t raw;
174 struct {
176 uint8_t reserved : 4;
177 } __attribute__((packed));
178};
179
180//
181// ALS_MEAS_RATE Register (0x85)
182//
193
194//
195// PART_ID Register (0x86) (Read Only)
196//
198 uint8_t raw;
199 struct {
200 uint8_t part_number_id : 4;
201 uint8_t revision_id : 4;
202 } __attribute__((packed));
203};
204
205//
206// ALS_PS_STATUS Register (0x8C) (Read Only)
207//
209 uint8_t raw;
210 struct {
211 bool ps_new_data : 1; // 0 - old data, 1 - new data
212 bool ps_interrupt : 1; // 0 - interrupt signal not active, 1 - interrupt signal active
213 bool als_new_data : 1; // 0 - old data, 1 - new data
214 bool als_interrupt : 1; // 0 - interrupt signal not active, 1 - interrupt signal active
215 AlsGain501 gain : 1; // current ALS gain
216 bool reserved_5 : 1;
217 bool reserved_6 : 1;
218 bool reserved_7 : 1;
219 } __attribute__((packed));
220};
221
222//
223// PS_DATA_1 Register (0x8E) (Read Only)
224//
226 uint8_t raw;
227 struct {
228 uint8_t ps_data_high : 3;
229 uint8_t reserved : 4;
231 } __attribute__((packed));
232};
233
234//
235// INTERRUPT Register (0x8F) (Read Only)
236//
238 uint8_t raw;
239 struct {
240 bool ps_interrupt : 1;
242 bool interrupt_polarity : 1; // 0 - active low (default), 1 - active high
243 uint8_t reserved : 5;
244 } __attribute__((packed));
245};
246
247//
248// INTERRUPT_PERSIST Register (0x9E)
249//
251 uint8_t raw;
252 struct {
253 uint8_t als_persist : 4; // 0 - every ALS cycle, 1 - every 2 ALS cycles, ... 15 - every 16 ALS cycles
254 uint8_t ps_persist : 4; // 0 - every PS cycle, 1 - every 2 PS cycles, ... 15 - every 16 PS cycles
255 } __attribute__((packed));
256};
257
258} // namespace esphome::ltr501
struct @65::@66 __attribute__
Wake the main loop task from an ISR. ISR-safe.
Definition main_task.h:32