RocketLogger 2.1.1
tsl4531.h File Reference
#include <stdint.h>
+ Include dependency graph for tsl4531.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define TSL4531_I2C_ADDRESS_LEFT   0x29
 
#define TSL4531_I2C_ADDRESS_RIGHT   0x28
 
#define TSL4531_I2C_ADDRESSES    { (TSL4531_I2C_ADDRESS_LEFT), (TSL4531_I2C_ADDRESS_RIGHT) }
 
#define TSL4531_CHANNEL_DEFAULT   0
 
#define TSL4531_ID   162
 
#define TSL4531_COMMAND   0x80
 
#define TSL4531_REG_CONTROL   0x00
 
#define TSL4531_REG_CONFIG   0x01
 
#define TSL4531_REG_DATALOW   0x04
 
#define TSL4531_REG_DATAHIGH   0x05
 
#define TSL4531_REG_ID   0x0A
 
#define TSL4531_SAMPLE_OFF   0x00
 
#define TSL4531_SAMPLE_SINGLE   0x2
 
#define TSL4531_SAMPLE_CONTINUOUS   0x03
 
#define TSL4531_HIGH_POWER   0x08
 
#define TSL4531_LOW_POWER   0x00
 
#define TSL4531_INT_TIME_100   0x02
 
#define TSL4531_INT_TIME_200   0x01
 
#define TSL4531_INT_TIME_400   0x00
 
#define TSL4531_MULT_100   4
 
#define TSL4531_MULT_200   2
 
#define TSL4531_MULT_400   1
 
#define TSL4531_RANGE_LOW_MAX   65000
 
#define TSL4531_RANGE_MEDIUM_MAX   130000
 
#define TSL4531_RANGE_HYSTERESIS   5000
 

Typedefs

typedef enum tsl4531_range tsl4531_range_t
 

Enumerations

enum  tsl4531_range { TSL4531_RANGE_LOW , TSL4531_RANGE_MEDIUM , TSL4531_RANGE_HIGH , TSL4531_RANGE_AUTO }
 

Functions

int tsl4531_init (int sensor_identifier)
 
void tsl4531_deinit (int sensor_identifier)
 
int tsl4531_read (int sensor_identifier)
 
int32_t tsl4531_get_value (int sensor_identifier, int channel)
 

Macro Definition Documentation

◆ TSL4531_CHANNEL_DEFAULT

#define TSL4531_CHANNEL_DEFAULT   0

Definition at line 43 of file tsl4531.h.

◆ TSL4531_COMMAND

#define TSL4531_COMMAND   0x80

Definition at line 48 of file tsl4531.h.

◆ TSL4531_HIGH_POWER

#define TSL4531_HIGH_POWER   0x08

Definition at line 60 of file tsl4531.h.

◆ TSL4531_I2C_ADDRESS_LEFT

#define TSL4531_I2C_ADDRESS_LEFT   0x29

Copyright (c) 2016-2020, ETH Zurich, Computer Engineering Group All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  • Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  • Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  • Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Definition at line 37 of file tsl4531.h.

◆ TSL4531_I2C_ADDRESS_RIGHT

#define TSL4531_I2C_ADDRESS_RIGHT   0x28

Definition at line 38 of file tsl4531.h.

◆ TSL4531_I2C_ADDRESSES

#define TSL4531_I2C_ADDRESSES    { (TSL4531_I2C_ADDRESS_LEFT), (TSL4531_I2C_ADDRESS_RIGHT) }

Definition at line 40 of file tsl4531.h.

◆ TSL4531_ID

#define TSL4531_ID   162

Definition at line 46 of file tsl4531.h.

◆ TSL4531_INT_TIME_100

#define TSL4531_INT_TIME_100   0x02

Definition at line 63 of file tsl4531.h.

◆ TSL4531_INT_TIME_200

#define TSL4531_INT_TIME_200   0x01

Definition at line 64 of file tsl4531.h.

◆ TSL4531_INT_TIME_400

#define TSL4531_INT_TIME_400   0x00

Definition at line 65 of file tsl4531.h.

◆ TSL4531_LOW_POWER

#define TSL4531_LOW_POWER   0x00

Definition at line 61 of file tsl4531.h.

◆ TSL4531_MULT_100

#define TSL4531_MULT_100   4

Definition at line 67 of file tsl4531.h.

◆ TSL4531_MULT_200

#define TSL4531_MULT_200   2

Definition at line 68 of file tsl4531.h.

◆ TSL4531_MULT_400

#define TSL4531_MULT_400   1

Definition at line 69 of file tsl4531.h.

◆ TSL4531_RANGE_HYSTERESIS

#define TSL4531_RANGE_HYSTERESIS   5000

Definition at line 88 of file tsl4531.h.

◆ TSL4531_RANGE_LOW_MAX

#define TSL4531_RANGE_LOW_MAX   65000

Definition at line 86 of file tsl4531.h.

◆ TSL4531_RANGE_MEDIUM_MAX

#define TSL4531_RANGE_MEDIUM_MAX   130000

Definition at line 87 of file tsl4531.h.

◆ TSL4531_REG_CONFIG

#define TSL4531_REG_CONFIG   0x01

Definition at line 51 of file tsl4531.h.

◆ TSL4531_REG_CONTROL

#define TSL4531_REG_CONTROL   0x00

Definition at line 50 of file tsl4531.h.

◆ TSL4531_REG_DATAHIGH

#define TSL4531_REG_DATAHIGH   0x05

Definition at line 53 of file tsl4531.h.

◆ TSL4531_REG_DATALOW

#define TSL4531_REG_DATALOW   0x04

Definition at line 52 of file tsl4531.h.

◆ TSL4531_REG_ID

#define TSL4531_REG_ID   0x0A

Definition at line 54 of file tsl4531.h.

◆ TSL4531_SAMPLE_CONTINUOUS

#define TSL4531_SAMPLE_CONTINUOUS   0x03

Definition at line 58 of file tsl4531.h.

◆ TSL4531_SAMPLE_OFF

#define TSL4531_SAMPLE_OFF   0x00

Definition at line 56 of file tsl4531.h.

◆ TSL4531_SAMPLE_SINGLE

#define TSL4531_SAMPLE_SINGLE   0x2

Definition at line 57 of file tsl4531.h.

Typedef Documentation

◆ tsl4531_range_t

Typedef for TSL4531 measurement ranges.

Definition at line 84 of file tsl4531.h.

Enumeration Type Documentation

◆ tsl4531_range

TSL4531 measurement ranges.

Enumerator
TSL4531_RANGE_LOW 
TSL4531_RANGE_MEDIUM 
TSL4531_RANGE_HIGH 
TSL4531_RANGE_AUTO 

Definition at line 74 of file tsl4531.h.

Function Documentation

◆ tsl4531_deinit()

void tsl4531_deinit ( int  sensor_identifier)

Deinitialize TSL sensor.

Parameters
sensor_identifierThe I2C address of the sensor

Definition at line 157 of file tsl4531.c.

◆ tsl4531_get_value()

int32_t tsl4531_get_value ( int  sensor_identifier,
int  channel 
)

Get the values read from the sensor.

Parameters
sensor_identifierThe I2C address of the sensor
channelThe channel of the sensor to get
Returns
Sensor value in lux

Definition at line 227 of file tsl4531.c.

References tsl4531_get_index(), and tsl4531_values.

+ Here is the call graph for this function:

◆ tsl4531_init()

int tsl4531_init ( int  sensor_identifier)

Initialize the light sensor.

Parameters
sensor_identifierThe I2C address of the sensor
Returns
Returns 0 on success, negative on failure with errno set accordingly

Definition at line 120 of file tsl4531.c.

References rl_log(), RL_LOG_ERROR, sensor_bus, sensors_get_bus(), sensors_init_comm(), tsl4531_get_id(), TSL4531_ID, and tsl4531_set_parameters().

+ Here is the call graph for this function:

◆ tsl4531_read()

int tsl4531_read ( int  sensor_identifier)

Read the sensor values.

Parameters
sensor_identifierThe I2C address of the sensor
Returns
Returns 0 on success, negative on failure with errno set accordingly

Definition at line 161 of file tsl4531.c.

References data, ERROR, rl_log(), RL_LOG_ERROR, sensor_bus, sensors_get_bus(), sensors_init_comm(), tsl4531_auto_range, TSL4531_COMMAND, tsl4531_get_index(), tsl4531_multiplier, TSL4531_RANGE_AUTO, TSL4531_RANGE_HIGH, TSL4531_RANGE_HYSTERESIS, TSL4531_RANGE_LOW, TSL4531_RANGE_LOW_MAX, TSL4531_RANGE_MEDIUM, TSL4531_RANGE_MEDIUM_MAX, TSL4531_REG_DATALOW, tsl4531_send_range(), and tsl4531_values.

+ Here is the call graph for this function: