EFM32 Jade Gecko 12 Software Documentation  efm32jg12-doc-5.1.2

Detailed Description

Si1133 driver and support functions.

DO_NOT_INCLUDE_WITH_DOXYGEN

Functions

uint32_t SI1133_deInit (void)
 Stops the measurements on all channel and waits until the chip goes to sleep state. More...
 
uint32_t SI1133_getHardwareID (uint8_t *hardwareID)
 Reads Hardware ID from the SI1133 sensor. More...
 
uint32_t SI1133_getIrqStatus (uint8_t *irqStatus)
 Reads the interrupt status register of the device. More...
 
int32_t SI1133_getLux (int32_t vis_high, int32_t vis_low, int32_t ir, SI1133_LuxCoeff_TypeDef *lk)
 Compute lux value. More...
 
uint32_t SI1133_getMeasurement (float *lux, float *uvi)
 Retrieve the sample values from the chip and convert them to lux and UV index values. More...
 
int32_t SI1133_getUv (int32_t uv, SI1133_Coeff_TypeDef *uk)
 Compute UV index. More...
 
uint32_t SI1133_init (void)
 Initializes the Si1133 chip. More...
 
uint32_t SI1133_measureLuxUvi (float *lux, float *uvi)
 Measure lux and UV index using the Si1133 sensor. More...
 
uint32_t SI1133_measurementForce (void)
 Sends a FORCE command to the Si1133. More...
 
uint32_t SI1133_measurementGet (SI1133_Samples_TypeDef *samples)
 Read samples from the Si1133 chip. More...
 
static uint32_t SI1133_measurementPause (void)
 Sends a PAUSE command to the Si1133. More...
 
uint32_t SI1133_measurementStart (void)
 Sends a START command to the Si1133. More...
 
uint32_t SI1133_paramRead (uint8_t address)
 Reads a parameter from the Si1133. More...
 
uint32_t SI1133_paramSet (uint8_t address, uint8_t value)
 Writes a byte to an Si1133 Parameter. More...
 
uint32_t SI1133_registerBlockRead (uint8_t reg, uint8_t length, uint8_t *data)
 Reads a block of data from the Si1133 sensor. More...
 
uint32_t SI1133_registerBlockWrite (uint8_t reg, uint8_t length, uint8_t *data)
 Writes a block of data to the Si1133 sensor. More...
 
uint32_t SI1133_registerRead (uint8_t reg, uint8_t *data)
 Reads register from the Si1133 sensor. More...
 
uint32_t SI1133_registerWrite (uint8_t reg, uint8_t data)
 Writes register in the Si1133 sensor. More...
 
uint32_t SI1133_reset (void)
 Resets the Si1133. More...
 
uint32_t SI1133_resetCmdCtr (void)
 Sends a RESET COMMAND COUNTER command to the Si1133. More...
 
static uint32_t SI1133_sendCmd (uint8_t command)
 Helper function to send a command to the Si1133. More...
 
static uint32_t SI1133_waitUntilSleep (void)
 Waits until the Si1133 is sleeping before proceeding. More...
 

Function Documentation

uint32_t SI1133_deInit ( void  )

Stops the measurements on all channel and waits until the chip goes to sleep state.

Returns
Returns zero on OK, non-zero otherwise

Definition at line 621 of file si1133.c.

References SI1133_measurementPause(), SI1133_PARAM_CH_LIST, SI1133_paramSet(), and SI1133_waitUntilSleep().

uint32_t SI1133_getHardwareID ( uint8_t *  hardwareID)

Reads Hardware ID from the SI1133 sensor.

Parameters
[out]hardwareIDThe Hardware ID of the chip (should be 0x33)
Returns
Returns zero on OK, non-zero otherwise

Definition at line 920 of file si1133.c.

References SI1133_REG_PART_ID, and SI1133_registerRead().

uint32_t SI1133_getIrqStatus ( uint8_t *  irqStatus)

Reads the interrupt status register of the device.

Parameters
[out]irqStatusThe contentof the IRQ status register
Returns
Returns zero on OK, non-zero otherwise

Definition at line 976 of file si1133.c.

References SI1133_REG_IRQ_STATUS, and SI1133_registerRead().

int32_t SI1133_getLux ( int32_t  vis_high,
int32_t  vis_low,
int32_t  ir,
SI1133_LuxCoeff_TypeDef lk 
)

Compute lux value.

Parameters
[in]vis_highVisible light sensor raw data
[in]vis_lowVisible light sensor raw data
[in]irInfrared sensor raw data
[in]lkLux calculation coefficients
Returns
Lux value scaled by LUX_OUPTUT_FRACTION

Definition at line 835 of file si1133.c.

References SI1133_LuxCoeff_TypeDef::coeff_high, and SI1133_LuxCoeff_TypeDef::coeff_low.

Referenced by SI1133_getMeasurement(), and SI1133_measureLuxUvi().

uint32_t SI1133_getMeasurement ( float *  lux,
float *  uvi 
)

Retrieve the sample values from the chip and convert them to lux and UV index values.

Parameters
[out]luxThe measured ambient light illuminace in lux
[out]uviUV index
Returns
Returns zero on OK, non-zero otherwise

Definition at line 945 of file si1133.c.

References SI1133_Samples_TypeDef::ch0, SI1133_Samples_TypeDef::ch1, SI1133_Samples_TypeDef::ch2, SI1133_Samples_TypeDef::ch3, SI1133_getLux(), SI1133_getUv(), and SI1133_measurementGet().

int32_t SI1133_getUv ( int32_t  uv,
SI1133_Coeff_TypeDef uk 
)

Compute UV index.

Parameters
[in]uvUV sensor raw data
[in]ukUV calculation coefficients
Returns
UV index scaled by UV_OUPTUT_FRACTION

Definition at line 805 of file si1133.c.

Referenced by SI1133_getMeasurement(), and SI1133_measureLuxUvi().

uint32_t SI1133_measureLuxUvi ( float *  lux,
float *  uvi 
)

Measure lux and UV index using the Si1133 sensor.

Parameters
[out]luxThe measured ambient light illuminace in lux
[out]uviUV index
Returns
Returns zero on OK, non-zero otherwise

Definition at line 874 of file si1133.c.

References SI1133_Samples_TypeDef::ch0, SI1133_Samples_TypeDef::ch1, SI1133_Samples_TypeDef::ch2, SI1133_Samples_TypeDef::ch3, SI1133_getLux(), SI1133_getUv(), SI1133_measurementForce(), SI1133_measurementGet(), SI1133_REG_IRQ_STATUS, SI1133_registerRead(), and UTIL_delay().

uint32_t SI1133_measurementForce ( void  )

Sends a FORCE command to the Si1133.

Returns
Returns zero on OK, non-zero otherwise

Definition at line 438 of file si1133.c.

References SI1133_CMD_FORCE_CH, and SI1133_sendCmd().

Referenced by SI1133_measureLuxUvi().

uint32_t SI1133_measurementGet ( SI1133_Samples_TypeDef samples)

Read samples from the Si1133 chip.

Parameters
[out]samplesRetrieves interrupt status and measurement data for channel 0..3 and converts the data to int32_t format
Returns
Returns zero on OK, non-zero otherwise

Definition at line 645 of file si1133.c.

References SI1133_Samples_TypeDef::ch0, SI1133_Samples_TypeDef::ch1, SI1133_Samples_TypeDef::ch2, SI1133_Samples_TypeDef::ch3, SI1133_Samples_TypeDef::irq_status, SI1133_REG_IRQ_STATUS, and SI1133_registerBlockRead().

Referenced by SI1133_getMeasurement(), and SI1133_measureLuxUvi().

uint32_t SI1133_measurementPause ( void  )
static

Sends a PAUSE command to the Si1133.

Returns
Returns zero on OK, non-zero otherwise

Definition at line 564 of file si1133.c.

References SI1133_CMD_PAUSE_CH, and SI1133_sendCmd().

Referenced by SI1133_deInit().

uint32_t SI1133_measurementStart ( void  )

Sends a START command to the Si1133.

Returns
Returns zero on OK, non-zero otherwise

Definition at line 452 of file si1133.c.

References SI1133_CMD_START, and SI1133_sendCmd().

uint32_t SI1133_paramRead ( uint8_t  address)

Reads a parameter from the Si1133.

Parameters
[in]addressThe address of the parameter.
Returns
Returns zero on OK, non-zero otherwise

Definition at line 469 of file si1133.c.

References SI1133_OK, SI1133_REG_RESPONSE1, SI1133_registerRead(), and SI1133_sendCmd().

uint32_t SI1133_paramSet ( uint8_t  address,
uint8_t  value 
)

Writes a byte to an Si1133 Parameter.

Parameters
[in]addressThe parameter address
[in]valueThe byte value to be written to the Si1133 parameter
Returns
Returns zero on OK, non-zero otherwise
Note
This function ensures that the Si1133 is idle and ready to receive a command before writing the parameter. Furthermore, command completion is checked. If setting parameter is not done properly, no measurements will occur. This is the most common error. It is highly recommended that host code make use of this function.

Definition at line 509 of file si1133.c.

References SI1133_OK, SI1133_REG_HOSTIN0, SI1133_REG_RESPONSE0, SI1133_registerBlockWrite(), SI1133_registerRead(), SI1133_RSP0_COUNTER_MASK, and SI1133_waitUntilSleep().

Referenced by SI1133_deInit(), and SI1133_init().

uint32_t SI1133_registerBlockRead ( uint8_t  reg,
uint8_t  length,
uint8_t *  data 
)

Reads a block of data from the Si1133 sensor.

Parameters
[in]regThe first register to begin reading from
[in]lengthThe number of bytes to write to the sensor
[out]dataThe data read from the sensor
Returns
Returns zero on OK, non-zero otherwise

Definition at line 238 of file si1133.c.

References I2C_TransferSeq_TypeDef::addr, I2C_TransferSeq_TypeDef::buf, I2C_TransferSeq_TypeDef::data, I2C_TransferSeq_TypeDef::flags, I2C_FLAG_WRITE_READ, I2CSPM_Transfer(), i2cTransferDone, I2C_TransferSeq_TypeDef::len, SI1133_ERROR_I2C_TRANSACTION_FAILED, SI1133_I2C_DEVICE, SI1133_I2C_DEVICE_BUS_ADDRESS, and SI1133_OK.

Referenced by SI1133_measurementGet().

uint32_t SI1133_registerBlockWrite ( uint8_t  reg,
uint8_t  length,
uint8_t *  data 
)

Writes a block of data to the Si1133 sensor.

Parameters
[in]regThe first register to begin writing to
[in]lengthThe number of bytes to write to the sensor
[in]dataThe data to write to the sensor
Returns
Returns zero on OK, non-zero otherwise

Definition at line 189 of file si1133.c.

References I2C_TransferSeq_TypeDef::addr, I2C_TransferSeq_TypeDef::buf, I2C_TransferSeq_TypeDef::data, I2C_TransferSeq_TypeDef::flags, I2C_FLAG_WRITE, I2CSPM_Transfer(), i2cTransferDone, I2C_TransferSeq_TypeDef::len, SI1133_ERROR_I2C_TRANSACTION_FAILED, SI1133_I2C_DEVICE, SI1133_I2C_DEVICE_BUS_ADDRESS, and SI1133_OK.

Referenced by SI1133_paramSet().

uint32_t SI1133_registerRead ( uint8_t  reg,
uint8_t *  data 
)

Reads register from the Si1133 sensor.

DO_NOT_INCLUDE_WITH_DOXYGEN

Parameters
[in]regThe register address to read from in the sensor.
[out]dataThe data read from the sensor
Returns
Returns zero on OK, non-zero otherwise

Definition at line 100 of file si1133.c.

References I2C_TransferSeq_TypeDef::addr, I2C_TransferSeq_TypeDef::buf, I2C_TransferSeq_TypeDef::data, I2C_TransferSeq_TypeDef::flags, I2C_FLAG_WRITE_READ, I2CSPM_Transfer(), i2cTransferDone, I2C_TransferSeq_TypeDef::len, SI1133_ERROR_I2C_TRANSACTION_FAILED, SI1133_I2C_DEVICE, SI1133_I2C_DEVICE_BUS_ADDRESS, and SI1133_OK.

Referenced by SI1133_getHardwareID(), SI1133_getIrqStatus(), SI1133_measureLuxUvi(), SI1133_paramRead(), SI1133_paramSet(), SI1133_sendCmd(), and SI1133_waitUntilSleep().

uint32_t SI1133_registerWrite ( uint8_t  reg,
uint8_t  data 
)

Writes register in the Si1133 sensor.

Parameters
[in]regThe register address to write to in the sensor
[in]dataThe data to write to the sensor
Returns
Returns zero on OK, non-zero otherwise

Definition at line 143 of file si1133.c.

References I2C_TransferSeq_TypeDef::addr, I2C_TransferSeq_TypeDef::buf, I2C_TransferSeq_TypeDef::data, I2C_TransferSeq_TypeDef::flags, I2C_FLAG_WRITE, I2CSPM_Transfer(), i2cTransferDone, I2C_TransferSeq_TypeDef::len, SI1133_ERROR_I2C_TRANSACTION_FAILED, SI1133_I2C_DEVICE, SI1133_I2C_DEVICE_BUS_ADDRESS, and SI1133_OK.

Referenced by SI1133_init(), SI1133_reset(), and SI1133_sendCmd().

uint32_t SI1133_reset ( void  )

Resets the Si1133.

Returns
Returns zero on OK, non-zero otherwise

Definition at line 312 of file si1133.c.

References SI1133_CMD_RESET, SI1133_REG_COMMAND, SI1133_registerWrite(), and UTIL_delay().

Referenced by SI1133_init().

uint32_t SI1133_resetCmdCtr ( void  )

Sends a RESET COMMAND COUNTER command to the Si1133.

Returns
Returns zero on OK, non-zero otherwise

Definition at line 424 of file si1133.c.

References SI1133_CMD_RESET_CMD_CTR, and SI1133_sendCmd().

static uint32_t SI1133_sendCmd ( uint8_t  command)
static

Helper function to send a command to the Si1133.

Parameters
[in]commandThe command to send to the sensor
Returns
Returns zero on OK, non-zero otherwise

Definition at line 341 of file si1133.c.

References SI1133_CMD_RESET_CMD_CTR, SI1133_OK, SI1133_REG_COMMAND, SI1133_REG_RESPONSE0, SI1133_registerRead(), SI1133_registerWrite(), SI1133_RSP0_COUNTER_MASK, and SI1133_waitUntilSleep().

Referenced by SI1133_measurementForce(), SI1133_measurementPause(), SI1133_measurementStart(), SI1133_paramRead(), and SI1133_resetCmdCtr().

static uint32_t SI1133_waitUntilSleep ( void  )
static

Waits until the Si1133 is sleeping before proceeding.

Returns
Returns zero on OK, non-zero otherwise

Definition at line 274 of file si1133.c.

References SI1133_ERROR_SLEEP_FAILED, SI1133_OK, SI1133_REG_RESPONSE0, SI1133_registerRead(), SI1133_RSP0_CHIPSTAT_MASK, and SI1133_RSP0_SLEEP.

Referenced by SI1133_deInit(), SI1133_paramSet(), and SI1133_sendCmd().