Toggle navigation
Documentation
The friendly Operating System for the Internet of Things
Loading...
Searching...
No Matches
tsl4531x_internals.h
Go to the documentation of this file.
1
/*
2
* SPDX-FileCopyrightText: 2017 Inria
3
* SPDX-FileCopyrightText: 2018 Freie Universität Berlin
4
* SPDX-License-Identifier: LGPL-2.1-only
5
*/
6
7
#pragma once
8
23
24
#ifdef __cplusplus
25
extern
"C"
{
26
#endif
27
32
#define TSL4531X_CONTROL_REG (0x0)
33
#define TSL4531X_CONFIGURATION_REG (0x01)
34
#define TSL4531X_ALSDATA1_REG (0x04)
35
#define TSL4531X_ALSDATA2_REG (0x05)
36
#define TSL4531X_ID_REG (0x0A)
38
43
#define TSL4531X_MODE_POWER_DOWN (0x00)
44
#define TSL4531X_MODE_RESERVED (0x01)
45
#define TSL4531X_MODE_SINGLE_ADC_CYCLE (0x02)
47
#define TSL4531X_MODE_NORMAL (0x03)
48
49
/* PowerSave saves some power in full power mode. PowerSave skip turns this off.
50
* Currently PowerSave skip is hard-coded to be on for simplicity, as it's just
51
* an intermediate between normal mode and low-power mode. */
52
#define TSL4531X_PSAVESKIP_OFF (0)
53
#define TSL4531X_PSAVESKIP_ON (1)
55
60
/* Assemble the Command register */
61
#define TSL4531X_COMMAND(addr) ((1 << 7) | (addr))
62
63
/* Assemble the Configuration register */
64
#define TSL4531X_CONFIG(psaveskip, tcntrl) (((!!(psaveskip)) << 3) | (tcntrl))
65
66
/* Assemble the Control register */
67
#define TSL4531X_CONTROL(mode) (mode)
68
69
#define TSL4531X_GET_PARTNO(id_reg) ((id_reg) >> 4)
70
71
/* Data multiplier according to integration time.
72
*
73
* From the manual:
74
* MULTIPLIER = 1 for TCNTRL = 00 (Tint = 400 ms)
75
* MULTIPLIER = 2 for TCNTRL = 01 (Tint = 200 ms)
76
* MULTIPLIER = 4 for TCNTRL = 10 (Tint = 100 ms)
77
*/
78
#define MULTIPLY_DATA(data_raw, integration_time) ((data_raw) << (integration_time))
79
80
/* This allows either full power mode or power down mode. */
81
#define TSL4531X_POWER_MODE(mode) ((!mode) * (0x03))
82
83
/* The full integration time is a sum of:
84
* 1. A worst-case time for each of the integration times, which according to
85
* the datasheet is 5% more than the nominal time
86
* 2. 60, 30 or 15 ms, according to the integration time, if PowerSave is on;
87
* which is the power down period in between integration cycles in this mode.
88
* Note that in the current implementation, the "PowerSave skip" option is
89
* hard-coded to be on, as PowerSave only gives slightly less power
90
* consumption than normal mode.
91
*/
92
#define TSL4531X_GET_INTEGRATION_TIME_USEC(int_time_setting, psaveskip) \
93
(uint32_t)1000 * (((0x04 >> int_time_setting) * 105) + ((!psaveskip) * (60 >> int_time_setting)))
95
96
#ifdef __cplusplus
97
}
98
#endif
99
Generated on Tue Apr 14 2026 10:02:08 by
1.13.2