EFR32 Mighty Gecko 1 Software Documentation
efr32mg1-doc-5.1.2
|
Data Structures | |
struct | SI114X_CAL_S |
SI114X_CAL_S Data Structure. More... | |
struct | SI114X_IRQ_SAMPLE |
Si114x Sample Data Structure. More... | |
Macros | |
#define | SI1147_ADDR 0xc0 |
Enumerations | |
enum | gesture_t { NONE, UP, DOWN, LEFT, RIGHT, TAP } |
Functions | |
uint8_t | Compress (uint16_t input) |
Converts a 16-bit value to 8-bit value. More... | |
void | delay_10ms (void) |
Implements 10ms delay. More... | |
void | delay_1ms (void) |
Implements 1ms delay. More... | |
int | Si1147_ConfigureDetection (I2C_TypeDef *i2c, uint8_t addr, int slow) |
Initializes and configures the Si1147 sensor. More... | |
int | Si1147_Detect_Device (I2C_TypeDef *i2c, uint8_t addr) |
Detects whether Si1147 is on the i2c bus. More... | |
int | Si1147_GetInterruptOutputEnable (I2C_TypeDef *i2c, uint8_t addr, int *enable) |
Get the enable status of the Si1147 interrupt pin. More... | |
int | Si1147_MeasureUVAndObjectPresent (I2C_TypeDef *i2c, uint8_t addr, uint16_t *uvIndex, int *objectDetect) |
Reads the UV measurement data and checks for object in proximity to the Si1147. More... | |
gesture_t | Si1147_NewSample (I2C_TypeDef *i2c, uint8_t addr, uint32_t timestamp) |
Reads new measurement data and processes a new sample. This function should be called every time an interrupt for a new sample is received. More... | |
uint32_t | Si1147_Read_Block_Register (I2C_TypeDef *i2c, uint8_t addr, uint8_t reg, uint8_t length, uint8_t *data) |
Reads a block of data from the Si1147 sensor. More... | |
uint32_t | Si1147_Read_Register (I2C_TypeDef *i2c, uint8_t addr, uint8_t reg, uint8_t *data) |
Reads register from the Si1147 sensor. More... | |
int | Si1147_SetInterruptOutputEnable (I2C_TypeDef *i2c, uint8_t addr, int enable) |
Enables or disables the Si1147 interrupt pin. More... | |
uint32_t | Si1147_Write_Block_Register (I2C_TypeDef *i2c, uint8_t addr, uint8_t reg, uint8_t length, uint8_t const *data) |
Writes a block of data to the Si1147 sensor. More... | |
uint32_t | Si1147_Write_Register (I2C_TypeDef *i2c, uint8_t addr, uint8_t reg, uint8_t data) |
Writes register in the Si1147 sensor. More... | |
int16_t | si114x_get_calibration (HANDLE si114x_handle, SI114X_CAL_S *si114x_cal, uint8_t security) |
Populates the SI114X_CAL_S structure. More... | |
int16_t | si114x_set_ucoef (HANDLE si114x_handle, uint8_t *input_ucoef, SI114X_CAL_S *si114x_cal) |
Initializes the Si113x/46/47/48 UCOEF Registers. More... | |
int16_t | Si114xAlsForce (HANDLE si114x_handle) |
Sends an ALSFORCE command to the Si113x/4x. More... | |
int16_t | Si114xBlockRead (HANDLE si114x_handle, uint8_t address, uint8_t length, uint8_t *values) |
Reads block of Si114x registers. More... | |
int16_t | Si114xBlockWrite (HANDLE si114x_handle, uint8_t address, uint8_t length, uint8_t *values) |
Writes block of Si114x registers. More... | |
int16_t | Si114xNop (HANDLE si114x_handle) |
Sends a NOP command to the Si113x/4x. More... | |
int16_t | Si114xParamRead (HANDLE si114x_handle, uint8_t address) |
Reads a Parameter from the Si113x/4x. More... | |
int16_t | Si114xParamSet (HANDLE si114x_handle, uint8_t address, uint8_t value) |
Writes a byte to an Si113x/4x Parameter. More... | |
int16_t | Si114xPauseAll (HANDLE si114x_handle) |
Pauses autonomous measurements. More... | |
int16_t | Si114xPsAlsAuto (HANDLE si114x_handle) |
Sends a PSALSAUTO command to the Si113x/4x. More... | |
int16_t | Si114xPsAlsForce (HANDLE si114x_handle) |
Sends a PSALSFORCE command to the Si113x/4x. More... | |
int16_t | Si114xPsForce (HANDLE si114x_handle) |
Sends a PSFORCE command to the Si113x/4x. More... | |
int16_t | Si114xReadFromRegister (HANDLE si114x_handle, uint8_t address) |
Reads from Si114x register. More... | |
int16_t | Si114xReset (HANDLE si114x_handle) |
Resets the Si113x/4x, clears any interrupts and initializes the HW_KEY register. More... | |
int16_t | Si114xWriteToRegister (HANDLE si114x_handle, uint8_t address, uint8_t value) |
Writes to Si114x Register. More... | |
uint16_t | Uncompress (uint8_t input) |
Converts an 8-bit compressed value to 16-bit. More... | |
#define SI1147_ADDR 0xc0 |
I2C device address for Si1147 on weather station board.
Definition at line 41 of file si114x_algorithm.h.
enum gesture_t |
Si114x gestures
Definition at line 67 of file si114x_algorithm.h.
uint8_t Compress | ( | uint16_t | input | ) |
Converts a 16-bit value to 8-bit value.
[in] | input | The 16-bit input to be compressed |
0-255 | The compressed value |
<0 | Error |
Definition at line 645 of file si114x_functions.c.
void delay_10ms | ( | void | ) |
Implements 10ms delay.
Implements 10ms delay.
Definition at line 267 of file si1147_i2c.c.
References RTCDRV_Delay().
Referenced by Si114xReset().
void delay_1ms | ( | void | ) |
Implements 1ms delay.
Implements 1ms delay.
Definition at line 279 of file si1147_i2c.c.
References RTCDRV_Delay().
Referenced by si114x_get_calibration(), Si114xParamSet(), and Si114xPauseAll().
int Si1147_ConfigureDetection | ( | I2C_TypeDef * | i2c, |
uint8_t | addr, | ||
int | lowpower | ||
) |
Initializes and configures the Si1147 sensor.
[in] | i2c | The I2C peripheral to use (not used). |
[in] | addr | The I2C address of the sensor. |
[in] | lowpower | Set to 1 to initialize without autonomous mode (low power) or set to 0 to enable autonomous mode. |
Definition at line 386 of file si114x_algorithm.c.
References si114x_get_calibration(), si114x_handle, si114x_set_ucoef(), Si114xParamSet(), Si114xPsAlsAuto(), Si114xReset(), Si114xWriteToRegister(), and UV_TASKLIST.
int Si1147_Detect_Device | ( | I2C_TypeDef * | i2c, |
uint8_t | addr | ||
) |
Detects whether Si1147 is on the i2c bus.
[in] | i2c | The I2C peripheral to use (not used). |
[in] | addr | The I2C address of the sensor. |
Definition at line 56 of file si114x_algorithm.c.
References si114x_handle, and Si114xReadFromRegister().
int Si1147_GetInterruptOutputEnable | ( | I2C_TypeDef * | i2c, |
uint8_t | addr, | ||
int * | enable | ||
) |
Get the enable status of the Si1147 interrupt pin.
[in] | i2c | The I2C peripheral to use (not used). |
[in] | addr | The I2C address of the sensor. |
[out] | enable | Will be set to 1 if the interrupt output pin is enabled or set to 0 if disabled. |
Definition at line 111 of file si114x_algorithm.c.
References si114x_handle, and Si114xReadFromRegister().
Referenced by Si1147_MeasureUVAndObjectPresent().
int Si1147_MeasureUVAndObjectPresent | ( | I2C_TypeDef * | i2c, |
uint8_t | addr, | ||
uint16_t * | uvIndex, | ||
int * | objectDetect | ||
) |
Reads the UV measurement data and checks for object in proximity to the Si1147.
[in] | i2c | The I2C peripheral to use (not used). |
[in] | addr | The I2C address of the sensor. |
[out] | uvIndex | The UV index read from the sensor |
[out] | objectDetect | Returns true if an object is detected in front of the sensor, otherwise false. |
Definition at line 137 of file si114x_algorithm.c.
References Si1147_GetInterruptOutputEnable(), si114x_handle, Si114xPsAlsForce(), Si114xReadFromRegister(), and Si114xWriteToRegister().
gesture_t Si1147_NewSample | ( | I2C_TypeDef * | i2c, |
uint8_t | addr, | ||
uint32_t | timestamp | ||
) |
Reads new measurement data and processes a new sample. This function should be called every time an interrupt for a new sample is received.
[in] | i2c | The I2C peripheral to use (not used). |
[in] | addr | The I2C address of the sensor. |
[in] | timestamp | The timestamp for when the sample interrupt was received. |
Definition at line 208 of file si114x_algorithm.c.
References si114x_handle, Si114xReadFromRegister(), and Si114xWriteToRegister().
uint32_t Si1147_Read_Block_Register | ( | I2C_TypeDef * | i2c, |
uint8_t | addr, | ||
uint8_t | reg, | ||
uint8_t | length, | ||
uint8_t * | data | ||
) |
Reads a block of data from the Si1147 sensor.
[in] | i2c | The I2C peripheral to use (not used). |
[in] | addr | The I2C address of the sensor. |
[out] | data | The data read from the sensor. |
[in] | length | The number of bytes to write to the sensor. |
[in] | reg | The first register to begin reading from. |
Definition at line 170 of file si1147_i2c.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, and I2C_TransferSeq_TypeDef::len.
Referenced by Si114xBlockRead().
uint32_t Si1147_Read_Register | ( | I2C_TypeDef * | i2c, |
uint8_t | addr, | ||
uint8_t | reg, | ||
uint8_t * | data | ||
) |
Reads register from the Si1147 sensor.
[in] | i2c | The I2C peripheral to use (not used). |
[in] | addr | The I2C address of the sensor. |
[out] | data | The data read from the sensor. |
[in] | reg | The register address to read from in the sensor. |
Definition at line 42 of file si1147_i2c.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, and I2C_TransferSeq_TypeDef::len.
Referenced by Si114xReadFromRegister().
int Si1147_SetInterruptOutputEnable | ( | I2C_TypeDef * | i2c, |
uint8_t | addr, | ||
int | enable | ||
) |
Enables or disables the Si1147 interrupt pin.
[in] | i2c | The I2C peripheral to use (not used). |
[in] | addr | The I2C address of the sensor. |
[in] | enable | Set to 1 to enable the interrupt output pin or set to 0 to disable the pin. |
Definition at line 82 of file si114x_algorithm.c.
References si114x_handle, and Si114xWriteToRegister().
uint32_t Si1147_Write_Block_Register | ( | I2C_TypeDef * | i2c, |
uint8_t | addr, | ||
uint8_t | reg, | ||
uint8_t | length, | ||
uint8_t const * | data | ||
) |
Writes a block of data to the Si1147 sensor.
[in] | i2c | The I2C peripheral to use (not used). |
[in] | addr | The I2C address of the sensor. |
[in] | data | The data to write to the sensor. |
[in] | length | The number of bytes to write to the sensor. |
[in] | reg | The first register to begin writing to. |
Definition at line 124 of file si1147_i2c.c.
References I2C_TransferSeq_TypeDef::addr, I2C_TransferSeq_TypeDef::buf, I2C_TransferSeq_TypeDef::data, I2C_TransferSeq_TypeDef::flags, I2C_FLAG_WRITE, I2CSPM_Transfer(), i2cTransferDone, and I2C_TransferSeq_TypeDef::len.
Referenced by Si114xBlockWrite().
uint32_t Si1147_Write_Register | ( | I2C_TypeDef * | i2c, |
uint8_t | addr, | ||
uint8_t | reg, | ||
uint8_t | data | ||
) |
Writes register in the Si1147 sensor.
[in] | i2c | The I2C peripheral to use (not used). |
[in] | addr | The I2C address of the sensor. |
[in] | data | The data to write to the sensor. |
[in] | reg | The register address to write to in the sensor. |
Definition at line 82 of file si1147_i2c.c.
References I2C_TransferSeq_TypeDef::addr, I2C_TransferSeq_TypeDef::buf, I2C_TransferSeq_TypeDef::data, I2C_TransferSeq_TypeDef::flags, I2C_FLAG_WRITE, I2CSPM_Transfer(), i2cTransferDone, and I2C_TransferSeq_TypeDef::len.
Referenced by Si114xWriteToRegister().
int16_t si114x_get_calibration | ( | HANDLE | si114x_handle, |
SI114X_CAL_S * | si114x_cal, | ||
uint8_t | security | ||
) |
Populates the SI114X_CAL_S structure.
Performs some initial checking based on the security level. If the checks fail, the function returns without attempting to fetch calibration values. The reason for the checking is that the Si114x uses the same registers to store calibration values as used for storing proximity and ambient light measurements. Therefore, this function needs to be used only if there is no possibility of an autonomous process possibly overwriting the output registers.
If the checks are successful, then the si114x retrieves the compressed values from the Si114x, then populates the SI114X_CAL_S structure whose pointer is passed to si114x_calibration()
If there are any errors, si114x_cal is populated with default values
[in] | si114x_handle | The programmer's toolkit handle |
[out] | si114x_cal | Points to the SI114X_CAL_S structure that will hold the calibration values from the Si114x. If there are any errors, si114x_cal is populated with default values. |
[in] | security |
|
0 | Success |
-1 | Security Check failed |
-2 | i2c communication error |
-3 | Chip does not support factory calibration |
-4 | Null pointers found for si114x_handle or si114x_cal |
Definition at line 1330 of file si114x_functions.c.
References SI114X_CAL_S::adcrange_ratio, delay_1ms(), SI114X_CAL_S::irpd_correction, SI114X_CAL_S::irsize_ratio, SI114X_CAL_S::ledi_ratio, Si114xBlockRead(), Si114xNop(), Si114xReadFromRegister(), Si114xWriteToRegister(), cal_ref_t::ucoef, SI114X_CAL_S::ucoef_p, and SI114X_CAL_S::vispd_correction.
Referenced by Si1147_ConfigureDetection(), and Si114x_ConfigureUV().
int16_t si114x_set_ucoef | ( | HANDLE | si114x_handle, |
uint8_t * | input_ucoef, | ||
SI114X_CAL_S * | si114x_cal | ||
) |
Initializes the Si113x/46/47/48 UCOEF Registers.
Takes in an optional input ucoef pointer, then modifies it based on calibration. If the input ucoef is NULL, default values for clear overlay is assumed and then the si114x_cal is used to adjust it before setting the ucoef. Note that the Si114x ucoef registers are updated by this function; no additional action is required. This routine also performs the necessary querying of the chip identification to make sure that it is a uvindex-capable device.
[in] | si114x_handle | The programmer's toolkit handle |
[in] | input_ucoef | if NULL, a clear overlay is assumed, and datasheet values for ucoef is used. Otherwise, pointer to 4 bytes array representing the reference coefficients is passed. |
[in] | si114x_cal | Points to the SI114X_CAL_S structure that holds the calibration values from the Si113x/4x |
0 | Success |
-1 | The device is neither Si1132, Si1145, Si1146 nor Si1147 |
<-1 | Error |
Definition at line 1470 of file si114x_functions.c.
References SI114X_CAL_S::irpd_correction, operand_t::op1, operand_t::op2, Si114xBlockWrite(), Si114xReadFromRegister(), SI114X_CAL_S::ucoef_p, and SI114X_CAL_S::vispd_correction.
Referenced by Si1147_ConfigureDetection(), and Si114x_ConfigureUV().
int16_t Si114xAlsForce | ( | HANDLE | si114x_handle | ) |
Sends an ALSFORCE command to the Si113x/4x.
[in] | si114x_handle | The programmer's toolkit handle |
0 | Success |
<0 | Error |
Definition at line 220 of file si114x_functions.c.
int16_t Si114xBlockRead | ( | HANDLE | si114x_handle, |
uint8_t | address, | ||
uint8_t | length, | ||
uint8_t * | values | ||
) |
Reads block of Si114x registers.
[in] | si114x_handle | The programmer toolkit handle. |
[in] | address | The register address to read from. |
[in] | length | The number of bytes to read. |
[in] | values | The data read from the sensor. |
Reads block of Si114x registers.
Definition at line 258 of file si1147_i2c.c.
References Si1147_Read_Block_Register().
Referenced by si114x_get_calibration().
int16_t Si114xBlockWrite | ( | HANDLE | si114x_handle, |
uint8_t | address, | ||
uint8_t | length, | ||
uint8_t * | values | ||
) |
Writes block of Si114x registers.
[in] | si114x_handle | The programmer toolkit handle. |
[in] | address | The register address to write to. |
[in] | length | The number of bytes to write. |
[in] | values | The data to write to the sensor. |
Writes block of Si114x registers.
Definition at line 239 of file si1147_i2c.c.
References Si1147_Write_Block_Register().
Referenced by si114x_set_ucoef(), and Si114xParamSet().
int16_t Si114xNop | ( | HANDLE | si114x_handle | ) |
Sends a NOP command to the Si113x/4x.
[in] | si114x_handle | The programmer's toolkit handle |
0 | Success |
<0 | Error |
Definition at line 190 of file si114x_functions.c.
Referenced by si114x_get_calibration().
int16_t Si114xParamRead | ( | HANDLE | si114x_handle, |
uint8_t | address | ||
) |
Reads a Parameter from the Si113x/4x.
[in] | si114x_handle | The programmer's toolkit handle |
[in] | address | The address of the parameter. |
<0 | Error |
0-255 | Parameter contents |
Definition at line 267 of file si114x_functions.c.
References Si114xReadFromRegister().
int16_t Si114xParamSet | ( | HANDLE | si114x_handle, |
uint8_t | address, | ||
uint8_t | value | ||
) |
Writes a byte to an Si113x/4x Parameter.
[in] | si114x_handle | The programmer's toolkit handle |
[in] | address | The parameter address |
[in] | value | The byte value to be written to the Si113x/4x parameter |
0 | Success |
<0 | Error |
Definition at line 300 of file si114x_functions.c.
References delay_1ms(), Si114xBlockWrite(), and Si114xReadFromRegister().
Referenced by Si1147_ConfigureDetection(), Si114x_ConfigureUV(), and Si114x_EnableVisRange().
int16_t Si114xPauseAll | ( | HANDLE | si114x_handle | ) |
Pauses autonomous measurements.
[in] | si114x_handle | The programmer's toolkit handle |
0 | Success |
<0 | Error |
Definition at line 355 of file si114x_functions.c.
References delay_1ms(), Si114xReadFromRegister(), and Si114xWriteToRegister().
Referenced by Si114xReset().
int16_t Si114xPsAlsAuto | ( | HANDLE | si114x_handle | ) |
Sends a PSALSAUTO command to the Si113x/4x.
[in] | si114x_handle | The programmer's toolkit handle |
0 | Success |
<0 | Error |
Definition at line 250 of file si114x_functions.c.
Referenced by Si1147_ConfigureDetection().
int16_t Si114xPsAlsForce | ( | HANDLE | si114x_handle | ) |
Sends a PSALSFORCE command to the Si113x/4x.
[in] | si114x_handle | The programmer's toolkit handle |
0 | Success |
<0 | Error |
Definition at line 235 of file si114x_functions.c.
Referenced by Si1147_MeasureUVAndObjectPresent(), and Si114x_MeasureUVIndex().
int16_t Si114xPsForce | ( | HANDLE | si114x_handle | ) |
Sends a PSFORCE command to the Si113x/4x.
[in] | si114x_handle | The programmer's toolkit handle |
0 | Success |
<0 | Error |
Definition at line 205 of file si114x_functions.c.
int16_t Si114xReadFromRegister | ( | HANDLE | si114x_handle, |
uint8_t | address | ||
) |
Reads from Si114x register.
[in] | si114x_handle | The programmer toolkit handle. |
[in] | address | The register address to read from. |
Reads from Si114x register.
Definition at line 219 of file si1147_i2c.c.
References Si1147_Read_Register().
Referenced by Si1147_Detect_Device(), Si1147_GetInterruptOutputEnable(), Si1147_MeasureUVAndObjectPresent(), Si1147_NewSample(), si114x_get_calibration(), Si114x_MeasureUVIndex(), si114x_set_ucoef(), Si114xParamRead(), Si114xParamSet(), and Si114xPauseAll().
int16_t Si114xReset | ( | HANDLE | si114x_handle | ) |
Resets the Si113x/4x, clears any interrupts and initializes the HW_KEY register.
[in] | si114x_handle | The programmer's toolkit handle |
0 | Success |
<0 | Error |
Definition at line 92 of file si114x_functions.c.
References delay_10ms(), Si114xPauseAll(), and Si114xWriteToRegister().
Referenced by Si1147_ConfigureDetection(), and Si114x_ConfigureUV().
int16_t Si114xWriteToRegister | ( | HANDLE | si114x_handle, |
uint8_t | address, | ||
uint8_t | data | ||
) |
Writes to Si114x Register.
[in] | si114x_handle | The programmer toolkit handle. |
[in] | address | The register address to write to. |
[in] | data | The data to write to the sensor. |
Writes to Si114x Register.
Definition at line 205 of file si1147_i2c.c.
References Si1147_Write_Register().
Referenced by Si1147_ConfigureDetection(), Si1147_MeasureUVAndObjectPresent(), Si1147_NewSample(), Si1147_SetInterruptOutputEnable(), Si114x_ConfigureUV(), si114x_get_calibration(), Si114x_MeasureUVIndex(), Si114xPauseAll(), and Si114xReset().
uint16_t Uncompress | ( | uint8_t | input | ) |
Converts an 8-bit compressed value to 16-bit.
[in] | input | The 8-bit compressed input to be uncompressed |
Definition at line 557 of file si114x_functions.c.