3#ifdef SENSOR_AMB_TSL2591
10#define AMBIENT_ADDR (0x29 << 1)
11#define TSL2591_COMMAND 0xA0
12#define REG_ENABLE 0x00
13#define REG_CONFIG 0x01
14#define REG_C0DATAL 0x14
15#define REG_C1DATAL 0x16
17#define THRESH_MAX 60000
45 HAL_StatusTypeDef status = HAL_ERROR;
59 HAL_StatusTypeDef status = HAL_ERROR;
89 for (data = 0; data < 4; data++)
103 HAL_StatusTypeDef status = HAL_ERROR;
115 if (status != HAL_OK)
124 if (status == HAL_OK)
145 HAL_StatusTypeDef status = HAL_OK;
182 HAL_StatusTypeDef status = HAL_ERROR;
195 status = HAL_TIMEOUT;
203 uint16_t ch0 = (buffer[1] << 8) | buffer[0];
204 uint16_t ch1 = (buffer[3] << 8) | buffer[2];
224 multiplier = 9876.0f;
231 float atime = 100.0f;
232 float cpl = (atime * multiplier) / 408.0f;
void amb_tsl2591_LogData(char *buf)
log data to buffer
static HAL_StatusTypeDef ambient_AdjustGain(I2C_HandleTypeDef *hi2c, uint16_t rawCH0)
This function checks the raw channel 0 value. If it is near the 16-bit limit (65535),...
int8_t amb_tsl2591_Is(I2C_HandleTypeDef *hi2c, int8_t tryInit)
check if light sensor is present
HAL_StatusTypeDef amb_tsl2591_Read(I2C_HandleTypeDef *hi2c)
When calculating Lux, you must use the actual multiplier corresponding to the currentGain.
HAL_StatusTypeDef amb_tsl2591_Off(I2C_HandleTypeDef *hi2c)
turn off sensor
HAL_StatusTypeDef amb_tsl2591_On(I2C_HandleTypeDef *hi2c)
turn on sensor, read value 4x to automatically configure the sensor.
HAL_StatusTypeDef amb_tsl2591_Init(I2C_HandleTypeDef *hi2c)
initialization of light sensor, and check if sensor is present or not Subsequently the sensor is turn...
HAL_StatusTypeDef amb_tsl2591_IsOn(I2C_HandleTypeDef *hi2c, uint8_t *onOff)
check if sensor is turned on or not
static TSL2591_Gain_t _currentGain
static int8_t _isAmbientSensor
amb_tsl2591_t _bck_amb_tsl2591Data
Snapshot copy of the last completed TSL2591 measurement; used for LoRaWAN transmission.
amb_tsl2591_t _amb_tsl2591Data
Live measurement data from the TSL2591 sensor; updated by amb_tsl2591_Read().
This file contains all the function prototypes for the i2c.c file.
HAL_StatusTypeDef I2C_IsDeviceReadyMT(I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint32_t Trials, uint32_t Timeout)
Wrapper around HAL_I2C_IsDeviceReady() that recovers from a busy bus. If the HAL I2C bus is in a BUSY...
#define PRIf_02D(fData)
Expands to integer and fractional arguments for use with PRIf_02. Splits a float/double into the inte...
#define PRIf_02
printf format string for printing a float/double as integer with 2 decimal places....
mems_MainBlock_t _memsMainBlock
Global instance of the main flash control block; loaded by mems_ReadMainBlock().
HAL_StatusTypeDef mems_WriteMainBlock()
writing the main block on flash. The main block is stored on address 0
Measurement data produced by the TSL2591 ambient light sensor. Populated by amb_tsl2591_Read(); check...