upm  1.7.1
Sensor/Actuator repository for libmraa (v2.0.0)
Data Structures | Functions | Macros | Typedefs
Include dependency graph for tsl2561.h:

API Description

//Modified: Abhishek Malik <abhishek.malik@intel.com>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include "tsl2561.h"
#include "upm_utilities.h"
int main()
{
tsl2561_context dev = tsl2561_init(0, TSL2561_Address, GAIN_0X, INTEGRATION_TIME1_101MS);
float abc = 0;
if(tsl2561_get_lux(dev, &abc) != UPM_SUCCESS){
printf("ERROR !! ERROR !! ERROR!!");
}
printf("value retrieved: %f\n", abc);
return 0;
}

Go to the source code of this file.

Data Structures

struct  _tsl2561_context
 

Functions

tsl2561_context tsl2561_init (int bus, uint8_t dev_address, uint8_t gain, uint8_t integration_time)
 
void tsl2561_close (tsl2561_context dev)
 
upm_result_t tsl2561_get_lux (const tsl2561_context, float *lux)
 
upm_result_t tsl2561_i2c_write_reg (tsl2561_context dev, uint8_t reg, uint8_t value)
 
upm_result_t tsl2561_i2c_read_reg (tsl2561_context dev, uint8_t reg, uint8_t *data)
 

Macros

#define TSL2561_Address   (0x29)
 
#define INTEGRATION_TIME0_13MS   (0x00)
 
#define INTEGRATION_TIME1_101MS   (0x01)
 
#define INTEGRATION_TIME2_402MS   (0x02)
 
#define GAIN_0X   (0x00)
 
#define GAIN_16X   (0x10)
 
#define CONTROL_POWERON   (0x03)
 
#define CONTROL_POWEROFF   (0x00)
 
#define REGISTER_Control   (0x80)
 
#define REGISTER_Timing   (0x81)
 
#define REGISTER_Interrupt   (0x86)
 
#define REGISTER_Channal0L   (0x8C)
 
#define REGISTER_Channal0H   (0x8D)
 
#define REGISTER_Channal1L   (0x8E)
 
#define REGISTER_Channal1H   (0x8F)
 
#define LUX_SCALE   (14)
 
#define LUX_RATIOSCALE   (9)
 
#define LUX_CHSCALE   (10)
 
#define LUX_CHSCALE_TINT0   (0x7517)
 
#define LUX_CHSCALE_TINT1   (0x0FE7)
 
#define LUX_K1C   (0x0043)
 
#define LUX_B1C   (0x0204)
 
#define LUX_M1C   (0x01ad)
 
#define LUX_K2C   (0x0085)
 
#define LUX_B2C   (0x0228)
 
#define LUX_M2C   (0x02c1)
 
#define LUX_K3C   (0x00c8)
 
#define LUX_B3C   (0x0253)
 
#define LUX_M3C   (0x0363)
 
#define LUX_K4C   (0x010a)
 
#define LUX_B4C   (0x0282)
 
#define LUX_M4C   (0x03df)
 
#define LUX_K5C   (0x014d)
 
#define LUX_B5C   (0x0177)
 
#define LUX_M5C   (0x01dd)
 
#define LUX_K6C   (0x019a)
 
#define LUX_B6C   (0x0101)
 
#define LUX_M6C   (0x0127)
 
#define LUX_K7C   (0x029a)
 
#define LUX_B7C   (0x0037)
 
#define LUX_M7C   (0x002b)
 
#define LUX_K8C   (0x029a)
 
#define LUX_B8C   (0x0000)
 
#define LUX_M8C   (0x0000)
 

Typedefs

typedef struct _tsl2561_contexttsl2561_context
 

Function Documentation

tsl2561_context tsl2561_init ( int  bus,
uint8_t  dev_address,
uint8_t  gain,
uint8_t  integration_time 
)

Sensor Init Function

Parameters
busI2C bus
dev_addressI2C address
gainGain associated with the driver
integration_timeTime to keep the shutter open
Returns
void* pointer to the sensor struct
void tsl2561_close ( tsl2561_context  dev)

Closes the sensor module

Parameters
devpointer to the sensor struct
upm_result_t tsl2561_get_lux ( const tsl2561_context  ,
float *  lux 
)

Gets the Lux value

Parameters
devpointer to the sensor struct
luxpointer to store the lux value
Returns
upm_result_t UPM success/error code
upm_result_t tsl2561_i2c_write_reg ( tsl2561_context  dev,
uint8_t  reg,
uint8_t  value 
)

Write I2C register on the device

Parameters
devpointer to the sensor struct
regregister to write value to
valuethe value to be written
Returns
upm_result_t UPM success/error code
upm_result_t tsl2561_i2c_read_reg ( tsl2561_context  dev,
uint8_t  reg,
uint8_t *  data 
)

Read from an I2C register from the device

Parameters
devpointer to the sensor struct
regregister to write value to
dataData read in from the register
Returns
upm_result_t UPM success/error code

Typedef Documentation

device context