L14-Click 1.0
STM32WLE5CC LoRaWAN Sensor Platform
Loading...
Searching...
No Matches
amb_tsl2591.h File Reference
#include "mysensors_def.h"
#include "stm32wlxx_hal.h"
Include dependency graph for amb_tsl2591.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  amb_tsl2591_t
 Measurement data produced by the TSL2591 ambient light sensor. Populated by amb_tsl2591_Read(); check IsDataValid before using Lux. More...

Functions

int8_t amb_tsl2591_Is (I2C_HandleTypeDef *hi2c, int8_t tryInit)
 
  • check if light sensor is present

HAL_StatusTypeDef amb_tsl2591_Init (I2C_HandleTypeDef *hi2c)
 initialization of light sensor, and check if sensor is present or not Subsequently the sensor is turned off so it doesn't run unnecessarily
HAL_StatusTypeDef amb_tsl2591_IsOn (I2C_HandleTypeDef *hi2c, uint8_t *onOff)
 check if sensor is turned on or not
HAL_StatusTypeDef amb_tsl2591_On (I2C_HandleTypeDef *hi2c)
 turn on sensor, read value 4x to automatically configure the sensor.
HAL_StatusTypeDef amb_tsl2591_Off (I2C_HandleTypeDef *hi2c)
 turn off sensor
HAL_StatusTypeDef amb_tsl2591_Read (I2C_HandleTypeDef *hi2c)
 read value from sensor, the value is in _ambientData
void amb_tsl2591_LogData (char *buf)
 log data to buffer

Variables

amb_tsl2591_t _amb_tsl2591Data
 Live measurement data from the TSL2591 sensor; updated by amb_tsl2591_Read().
amb_tsl2591_t _bck_amb_tsl2591Data
 Snapshot copy of the last completed TSL2591 measurement; used for LoRaWAN transmission.

Function Documentation

◆ amb_tsl2591_Init()

HAL_StatusTypeDef amb_tsl2591_Init ( I2C_HandleTypeDef * hi2c)

initialization of light sensor, and check if sensor is present or not Subsequently the sensor is turned off so it doesn't run unnecessarily

Return values
HAL_OK- sensor is present, HAL_ERROR

Definition at line 121 of file amb_tsl2591.c.

References _isAmbientSensor, amb_tsl2591_Off(), amb_tsl2591_On(), AMBIENT_ADDR, and I2C_IsDeviceReadyMT().

Referenced by amb_tsl2591_Is().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ amb_tsl2591_Is()

int8_t amb_tsl2591_Is ( I2C_HandleTypeDef * hi2c,
int8_t tryInit )

  • check if light sensor is present

Parameters
tryInit- in case sensor is not yet initialized, 1 - attempt to initialize again, 0 - no
Return values
1- is present, 0 - is not

Definition at line 35 of file amb_tsl2591.c.

References _isAmbientSensor, and amb_tsl2591_Init().

Here is the call graph for this function:

◆ amb_tsl2591_IsOn()

HAL_StatusTypeDef amb_tsl2591_IsOn ( I2C_HandleTypeDef * hi2c,
uint8_t * onOff )

check if sensor is turned on or not

Parameters
onOff- on output contains 1-on 0-off, but only if status is HAL_OK
Return values
HAL_OK- onOff contains sensor state, HAL_ERROR

Definition at line 42 of file amb_tsl2591.c.

References _isAmbientSensor, AMBIENT_ADDR, REG_ENABLE, and TSL2591_COMMAND.

Referenced by amb_tsl2591_Read().

Here is the caller graph for this function:

◆ amb_tsl2591_LogData()

void amb_tsl2591_LogData ( char * buf)

log data to buffer

Definition at line 248 of file amb_tsl2591.c.

References _amb_tsl2591Data, PRIf_02, and PRIf_02D.

◆ amb_tsl2591_Off()

HAL_StatusTypeDef amb_tsl2591_Off ( I2C_HandleTypeDef * hi2c)

turn off sensor

Return values
HAL_OK,HAL_ERROR

Definition at line 101 of file amb_tsl2591.c.

References _isAmbientSensor, AMBIENT_ADDR, REG_ENABLE, and TSL2591_COMMAND.

Referenced by amb_tsl2591_Init().

Here is the caller graph for this function:

◆ amb_tsl2591_On()

HAL_StatusTypeDef amb_tsl2591_On ( I2C_HandleTypeDef * hi2c)

turn on sensor, read value 4x to automatically configure the sensor.

Return values
HAL_OK,HAL_ERROR

Definition at line 57 of file amb_tsl2591.c.

References _amb_tsl2591Data, _currentGain, _isAmbientSensor, _memsMainBlock, amb_tsl2591_Read(), AMBIENT_ADDR, mems_WriteMainBlock(), REG_CONFIG, REG_ENABLE, TSL2591_COMMAND, and TSL2591_GAIN_MED.

Referenced by amb_tsl2591_Init().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ amb_tsl2591_Read()

HAL_StatusTypeDef amb_tsl2591_Read ( I2C_HandleTypeDef * hi2c)

read value from sensor, the value is in _ambientData

Return values
HAL_OK- have data, HAL_BUSY - next reading in progress, HAL_TIMEOUT - sensor is not turned on HAL_ERROR - error

read value from sensor, the value is in _ambientData

Definition at line 179 of file amb_tsl2591.c.

References _amb_tsl2591Data, _currentGain, _isAmbientSensor, amb_tsl2591_IsOn(), AMBIENT_ADDR, ambient_AdjustGain(), REG_C0DATAL, THRESH_MAX, TSL2591_COMMAND, TSL2591_GAIN_HIGH, TSL2591_GAIN_LOW, TSL2591_GAIN_MAX, and TSL2591_GAIN_MED.

Referenced by amb_tsl2591_On().

Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ _amb_tsl2591Data

amb_tsl2591_t _amb_tsl2591Data
extern

Live measurement data from the TSL2591 sensor; updated by amb_tsl2591_Read().

Definition at line 32 of file amb_tsl2591.c.

Referenced by amb_tsl2591_LogData(), amb_tsl2591_On(), amb_tsl2591_Read(), and sensors_CopyToBck().

◆ _bck_amb_tsl2591Data

amb_tsl2591_t _bck_amb_tsl2591Data
extern

Snapshot copy of the last completed TSL2591 measurement; used for LoRaWAN transmission.

Definition at line 33 of file amb_tsl2591.c.

Referenced by sensors_CayennelFromBckData(), sensors_CopyToBck(), sensors_ReadToBckFromDataBlock(), and sensors_WriteFromBckToDataBlock().