8.2.2. TSL45315 (AMS-TAOS)

8.2.2.1. Introduction

The TSL4531 family of devices provides ambient light sensing (ALS) that approximates human eye response under a variety of lighting conditions. The devices have three selectable integration times (400 ms, 200 ms and 100 ms) and provide a direct 16-bit lux output via an I2C bus interface. Range is 3 lux to 220k lux.

8.2.2.2. Applications

The wide dynamic range of the ALS makes it particularly useful in outdoor applications where it is exposed to direct sunlight. The device is ideal for use in automatic control of street lights and security, billboard and automotive lighting. The TSL4531 devices can also be used in solid state and general lighting for automatic control and daylight harvesting to maximize energy conservation. Other applications include display backlight control to extend battery life and optimize visibility in cell phones, tablets and notebooks.

8.2.2.3. Resources

8.2.2.4. Platform Integration

The sensor can be enabled by defining compile-time flag PLTFRM_TSL45315_ENA. An example of using this sensor is illustrated in App Examples.

8.2.2.4.1. Functions

PLTFRM_sts_t TSL45315_init(UINT8_t devId)

Initializes the device. This function is normally called during platform initialization. When the function returns, device is put in shutdown mode: TSL45315_PWR_DOWN_MODE_ENC.

Parameters:
  • devId – Identity of the device.
Returns:

PLTFRM_STS_SUCCESS is returned on success. A non-zero value indicates a failure. Possible errors are PLTFRM_STS_INV_DEV_ID, PLTFRM_STS_UNKNOWN_DEV_OPN_MODE and PLTFRM_STS_DEV_REG_UPDATE_ERR.

PLTFRM_sts_t TSL45315_startALSConv(UINT8_t devId, SINT32_t *luxVal_p, UINT16_t *tmoVal_p)

Starts the sensing and conversion of ambient light intensity. If the device is in TSL45315_OPN_MODE_NORMAL mode, light intensity value is immediately returned. If mode is TSL45315_OPN_MODE_POWER_DOWN, conversion is triggered. A timeout value is returned to caller so that caller can read the value later when it becomes available.

Parameters:
  • devId – Identity of the device.
  • luxVal_p – Points to location where light intensity is returned. This is applicable only when mode is TSL45315_OPN_MODE_NORMAL.
  • tmoVal_p – Points to location where timeout value is returned. This is applicable only when mode is TSL45315_OPN_MODE_POWER_DOWN. Value is in milliseconds.
Returns:

PLTFRM_STS_SUCCESS is returned on success. A non-zero value indicates a failure. Possible errors are PLTFRM_STS_INV_DEV_ID, PLTFRM_STS_I2C_BUS_WR_ERROR, PLTFRM_STS_DEV_NOT_READY and PLTFRM_STS_DEV_REG_UPDATE_ERR.

PLTFRM_sts_t TSL45315_cfgALSOpnMode(UINT8_t devId, TSL45315_mode_t reqOpnMode, UINT16_t *opnTime_p)

Configure the device in a desired operation mode. Note that device is reconfigured only if there is a change in mode.

Parameters:
  • devId – Identity of the device.
  • reqOpnMode – Desired operation mode. Valid values are TSL45315_OPN_MODE_NORMAL and TSL45315_OPN_MODE_POWER_DOWN.
  • opnTime_p – This parameter is not used at the moment. Call function with NULL value.
Returns:

PLTFRM_STS_SUCCESS is returned on success. A non-zero value indicates a failure. Possible errors are PLTFRM_STS_INV_DEV_ID, PLTFRM_STS_INV_PARAM and PLTFRM_STS_DEV_REG_UPDATE_ERR.

PLTFRM_sts_t TSL45315_getALSOutput(UINT8_t devId, SINT32_t *luxVal_p)

Read from the device and obtain the ambient light intensity.

Parameters:
  • devId – Identity of the device.
  • luxVal_p – Points to location where the light intensity value is returned.
Returns:

PLTFRM_STS_SUCCESS is returned on success. A non-zero value indicates a failure. Possible errors are PLTFRM_STS_INV_DEV_ID and PLTFRM_STS_I2C_BUS_WR_ERROR.

8.2.2.4.2. Macros

#define TSL45315_SENSOR_OUTPUT_VALUE_SZ  4

// See table 2 (Command register)
#define TSL45315_COMMAND_FMT_BM  0x80


#define TSL45315_I2C_ADDR_PREFIX   0x29    // 0101 001  (7 bit address)

#define TSL45315_CONTROL_REG_ADDR    0x0
#define TSL45315_CONFIG_REG_ADDR     0x1
#define TSL45315_DATA_LOW_REG_ADDR   0x4
#define TSL45315_DATA_HIGH_REG_ADDR  0x5
#define TSL45315_ID_REG_ADDR         0xa

/*
 * ID Register
 */
#define TSL45315_PART_NR_SHIFT  0x4
#define TSL45315_PART_NR_SHIFT_BIT_MSK  0xf

#define TSL45311_PART_NUMBER_ID   0xb
#define TSL45313_PART_NUMBER_ID   0x9
#define TSL45315_PART_NUMBER_ID   0xa
#define TSL45317_PART_NUMBER_ID   0x8


/*
 * Control register
 */
#define TSL45315_PWR_DOWN_MODE_ENC      0x0
#define TSL45315_SINGLE_CYCLE_MODE_ENC  0x2
#define TSL45315_NORMAL_MODE_ENC        0x3

#define TSL45315_CONTROL_REG_MODE_BIT_MSK  0x3

/*
 * Configuration register
 */
#define TSL45315_DFLT_INTEGRATION_TIME  400

#define TSL45315_CONFIG_REG_TCNTRL_BIT_MSK  0x3

#define TSL45315_400_MS_INTEGRATION_TIME_ENC  0x0
#define TSL45315_200_MS_INTEGRATION_TIME_ENC  0x1
#define TSL45315_100_MS_INTEGRATION_TIME_ENC  0x2

8.2.2.4.3. Type Definitions

/*
 * The device allows the user to control the integration time. This
 * enables the user to control the sensitivity of the device to allow
 * for the greater dynamic range needed in bright lighting conditions
 * such as sunlight. Integration times of 400 ms, 200 ms, or 100 ms
 * are available.
 */

typedef enum
{
   // Implementation specific
   TSL45315_OPN_MODE_UNKNOWN,

   TSL45315_OPN_MODE_POWER_DOWN,

   TSL45315_OPN_MODE_NORMAL
} TSL45315_mode_t;


typedef struct
{
   UINT8_t devId;
   UINT8_t tcntrlEnc;  // 0 - 400 msecs, 1 - 200 msecs, 2 - 100 msecs
   TSL45315_mode_t opnMode;
} TSL45315_cntxt_s;