Intersil ISL29003

The ISL29003 is an integrated light sensor with a 16-bit integrating type ADC, I²C user programmable lux range select for optimized counts/lux, and I²C multi-function control and monitoring capabilities. The driver is implemented in source files isl29003.c/.h and provides communications support with the device over an I²C bus.

Device Information

Basic Usage

The code snippet below demonstrates how to create and initialize an instance of the ISL29003 driver. The snippet enables the device and continually reads the sensor value within a forever loop.

       
#include "Drivers/Intersil/isl29003.h"
#include <assert.h>

static I2C i2c;                             /* Allocate an I2C port for communicating with the device */
static ISL29003 driver;                     /* Allocate an instance of the driver */

void APP_ExampleThread(void)
{
    STATUS status;


    status = I2C_Open(&i2c,                 /* Open an I2C port */
                      0,                    /* Port number (0) */
                      400000);              /* Clock rate (400khz) */

    assert(status == SUCCESS);

    status = ISL29003_Open(&driver,         /* Open the driver */
                           &i2c);           /* Provide the I2C port to be used by the driver */

    assert(status == SUCCESS);


    status = ISL29003_Enable(&driver,       /* Enable the device */
                             0,             /* Timing mode */
                             0,             /* ADC work mode */
                             0,             /* Clock cycles, n-bit resolution */
                             1,             /* Gain */
                             0);            /* Interrupt persist */

    assert(status == SUCCESS);


    for (;;) {
	
        status = ISL29003_ReadSensor(&driver, &value);      /* Read the most recent sensor value */
        if (status == SUCCESS) {
            printf("%d\n", value);                          /* Display the sensor value */
        }
    }
}

API Reference

STATUS ISL29003_Open(ISL29003* driver, I2C* port)
Creates and initializes an instance of the ISL29003 sensor driver.
PARAMETERS
driver A pointer to a caller allocated instance of a ISL29003 driver to be initialized.
port A pointer to an open I2C port to be used for communications.
RETURNS
SUCCESS The driver has been initialized and is ready for communications.
ERR_NULLREFERENCE The argument 'driver' or 'port' was found to be NULL.
STATUS ISL29003_Enable(ISL29003* driver, BYTE timing, BYTE mode, BYTE clock, BYTE gain, BYTE intPersist)
Enables the ISL29003 device with the specified options.
PARAMETERS
driver A pointer to the target driver instance.
timing The timing mode for the device.
0 Integration is internally timed.
1 Integration is externally sync/controlled by I2C host.
mode The ADC work mode.
0 Diode1's current to unsigned 16-bit data.
1 Diode2's current to unsigned 16-bit data.
2 Difference between diodes (I1 - I2) to signed 15-bit data.
3 Reserved.
clock The number of clock cycles; n-bit resolution.
0 2^16 cycles.
1 2^12 cycles.
2 2^8 cycles.
3 2^4 cycles.
gain The gain range.
0 0 to 1000 lux.
1 0 to 4000 lux.
2 0 to 16000 lux.
3 0 to 64000 lux.
intPersist The interrupt trigger rate.
0 Interrupt is triggered after 1 integration cycle.
1 Interrupt is triggered after 4 integration cycles.
2 Interrupt is triggered after 8 integration cycles.
3 Interrupt is triggered after 16 integration cycles.
RETURNS
SUCCESS The driver has been initialized and is ready for communications.
ERR_NULLREFERENCE The argument 'driver' was found to be NULL.
ERR_DEVICENAK The target device returned a NAK.
ERR_INCOMPLETE An error occurred while transferring the data and the transfer did not complete.
STATUS ISL29003_Disable(ISL29003* driver, BOOLEAN powerDown)
Disables, and optionally powers down, the ISL29003 device.
PARAMETERS
driver A pointer to the target driver instance.
powerDown TRUE to command the device to power down; otherwise FALSE.
RETURNS
SUCCESS The device has been disabled.
ERR_NULLREFERENCE The argument 'driver' was found to be NULL.
ERR_DEVICENAK The target device returned a NAK.
ERR_INCOMPLETE An error occurred while transferring the data and the transfer did not complete.
STATUS ISL29003_SetTimeout(ISL29003* driver, UINT32 timeout)
Sets the timeout, in kernel ticks, to be used by the driver for I/O operations
PARAMETERS
driver A pointer to the driver to receive the new timeout value.
timeout The new timeout value, in kernel ticks, for the driver.
RETURNS
SUCCESS The driver timeout has been updated.
ERR_NULLREFERENCE The argument 'driver' was found to be NULL.
STATUS ISL29003_Write(ISL29003* driver, const void* data, UINT32 nbytes)
Writes data to the device. The first byte of data is the address of the register to receive the data.
PARAMETERS
driver A pointer to the target driver instance.
data A pointer to the data to be written to the device. The first bytes is the address of the register to receive the subsequent data bytes.
nbytes The total amount, in bytes, to be written to the device.
RETURNS
SUCCESS The data has been written to the device.
ERR_NULLREFERENCE The argument 'driver' or 'data' was found to be NULL.
ERR_DEVICENAK The target device returned a NAK.
ERR_INCOMPLETE An error occurred while transferring the data and the transfer did not complete.
STATUS ISL29003_Read(ISL29003* driver, BYTE reg, void* buf, UINT32 nbytes)
Reads and returns data from the device.
PARAMETERS
driver A pointer to the target driver instance.
reg The register address to be read.
buf The argument 'driver' or 'buf' was found to be NULL.
nbytes The total amount, in bytes, to be read and returned.
RETURNS
SUCCESS The data has been read and returned.
ERR_NULLREFERENCE The argument 'driver' or 'data' was found to be NULL.
ERR_DEVICENAK The target device returned a NAK.
ERR_INCOMPLETE An error occurred while transferring the data and the transfer did not complete.
STATUS ISL29003_ReadSensor(ISL29003* driver, UINT16* value)
Reads and returns the current sensor reading from the device.
PARAMETERS
driver A pointer to the target driver instance.
value A pointer to a caller allocated variable to receive the sensor value.
RETURNS
SUCCESS The sensor value has been returned.
ERR_NULLREFERENCE The argument 'driver' or 'value' was found to be NULL.
ERR_DEVICENAK The target device returned a NAK.
ERR_INCOMPLETE An error occurred while transferring the data and the transfer did not complete.
STATUS ISL29003_ReadTimer(ISL29003* driver, UINT16* value)
Reads and returns the current timer value from the device.
PARAMETERS
driver A pointer to the target driver instance.
value A pointer to a caller allocated variable to receive the timer value.
RETURNS
SUCCESS The timer value has been returned.
ERR_NULLREFERENCE The argument 'driver' or 'value' was found to be NULL.
ERR_DEVICENAK The target device returned a NAK.
ERR_INCOMPLETE An error occurred while transferring the data and the transfer did not complete.