esp-open-rtos/extras/tsl2561/tsl2561.h

57 lines
1.2 KiB
C
Raw Normal View History

2016-08-25 16:39:25 +00:00
/*
* Part of esp-open-rtos
* Copyright (C) 2016 Brian Schwind (https://github.com/bschwind)
* BSD Licensed as described in the file LICENSE
*/
#ifndef __TSL2561_H__
#define __TSL2561_H__
#include <stdint.h>
#include <stdbool.h>
2016-10-11 13:52:11 +00:00
#ifdef __cplusplus
extern "C" {
#endif
2016-08-25 16:39:25 +00:00
// I2C Addresses
2016-10-11 12:39:22 +00:00
typedef enum
{
TSL2561_I2C_ADDR_VCC = 0x49,
TSL2561_I2C_ADDR_GND = 0x29,
TSL2561_I2C_ADDR_FLOAT = 0x39 // Default
} tsl2561_i2c_addr_t;
2016-08-25 16:39:25 +00:00
// Integration time IDs
2016-10-11 12:39:22 +00:00
typedef enum
{
TSL2561_INTEGRATION_13MS = 0x00,
TSL2561_INTEGRATION_101MS = 0x01,
TSL2561_INTEGRATION_402MS = 0x02 // Default
} tsl2561_integration_time_t;
2016-08-25 16:39:25 +00:00
// Gain IDs
2016-10-11 12:39:22 +00:00
typedef enum
{
TSL2561_GAIN_1X = 0x00, // Default
TSL2561_GAIN_16X = 0x10
} tsl2561_gain_t;
2016-08-25 16:39:25 +00:00
typedef struct {
2016-10-11 12:39:22 +00:00
tsl2561_i2c_addr_t i2c_addr;
2016-08-25 16:39:25 +00:00
uint8_t integration_time;
uint8_t gain;
uint8_t package_type;
} tsl2561_t;
void tsl2561_init(tsl2561_t *device);
2016-10-11 12:39:22 +00:00
void tsl2561_set_integration_time(tsl2561_t *device, tsl2561_integration_time_t integration_time_id);
void tsl2561_set_gain(tsl2561_t *device, tsl2561_gain_t gain);
2016-08-25 16:39:25 +00:00
bool tsl2561_read_lux(tsl2561_t *device, uint32_t *lux);
2016-10-11 13:52:11 +00:00
#ifdef __cplusplus
}
#endif
2016-08-25 16:39:25 +00:00
#endif // __TSL2561_H__