SI1133 - Ambient Light and UV Index SensorBSP > Thunderboard Sense BSP
Detailed Description
Driver for the Silicon Labs Si1133 Ambient Light and UV sensor.
Data Structures |
|
struct | SI1133_Coeff_TypeDef |
Structure to store the calculation coefficients.
|
|
struct | SI1133_LuxCoeff_TypeDef |
Structure to store the coefficients used for Lux calculation.
|
|
struct | SI1133_Samples_TypeDef |
Structure to store the data measured by the Si1133.
|
|
Functions |
|
uint32_t | SI1133_deInit (void) |
Stops the measurements on all channel and waits until the chip goes to sleep state.
|
|
uint32_t | SI1133_getHardwareID (uint8_t *hardwareID) |
Reads Hardware ID from the SI1133 sensor.
|
|
uint32_t | SI1133_getIrqStatus (uint8_t *irqStatus) |
Reads the interrupt status register of the device.
|
|
int32_t | SI1133_getLux (int32_t vis_high, int32_t vis_low, int32_t ir, SI1133_LuxCoeff_TypeDef *lk) |
Compute lux value.
|
|
uint32_t | SI1133_getMeasurement (float *lux, float *uvi) |
Retrieve the sample values from the chip and convert them to lux and UV index values.
|
|
int32_t | SI1133_getUv (int32_t uv, SI1133_Coeff_TypeDef *uk) |
Compute UV index.
|
|
uint32_t | SI1133_init (void) |
Initializes the Si1133 chip.
|
|
uint32_t | SI1133_measureLuxUvi (float *lux, float *uvi) |
Measure lux and UV index using the Si1133 sensor.
|
|
uint32_t | SI1133_measurementForce (void) |
Sends a FORCE command to the Si1133.
|
|
uint32_t | SI1133_measurementGet ( SI1133_Samples_TypeDef *samples) |
Read samples from the Si1133 chip.
|
|
uint32_t | SI1133_measurementPause (void) |
Sends a PAUSE command to the Si1133.
|
|
uint32_t | SI1133_measurementStart (void) |
Sends a START command to the Si1133.
|
|
uint32_t | SI1133_paramRead (uint8_t address) |
Reads a parameter from the Si1133.
|
|
uint32_t | SI1133_paramSet (uint8_t address, uint8_t value) |
Writes a byte to an Si1133 Parameter.
|
|
uint32_t | SI1133_registerBlockRead (uint8_t reg, uint8_t length, uint8_t *data) |
Reads a block of data from the Si1133 sensor.
|
|
uint32_t | SI1133_registerBlockWrite (uint8_t reg, uint8_t length, uint8_t *data) |
Writes a block of data to the Si1133 sensor.
|
|
uint32_t | SI1133_registerRead (uint8_t reg, uint8_t *data) |
Reads register from the Si1133 sensor.
|
|
uint32_t | SI1133_registerWrite (uint8_t reg, uint8_t data) |
Writes register in the Si1133 sensor.
|
|
uint32_t | SI1133_reset (void) |
Resets the Si1133.
|
|
uint32_t | SI1133_resetCmdCtr (void) |
Sends a RESET COMMAND COUNTER command to the Si1133.
|
|
static uint32_t | SI1133_sendCmd (uint8_t command) |
Helper function to send a command to the Si1133.
|
|
static uint32_t | SI1133_waitUntilSleep (void) |
Waits until the Si1133 is sleeping before proceeding.
|
|
Error Codes |
|
#define | SI1133_OK 0x0000 |
#define | SI1133_ERROR_I2C_TRANSACTION_FAILED 0x0001 |
#define | SI1133_ERROR_SLEEP_FAILED 0x0002 |
Commands |
|
#define | SI1133_CMD_RESET_CMD_CTR 0x00 |
#define | SI1133_CMD_RESET 0x01 |
#define | SI1133_CMD_NEW_ADDR 0x02 |
#define | SI1133_CMD_FORCE_CH 0x11 |
#define | SI1133_CMD_PAUSE_CH 0x12 |
#define | SI1133_CMD_START 0x13 |
#define | SI1133_CMD_PARAM_SET 0x80 |
#define | SI1133_CMD_PARAM_QUERY 0x40 |
Responses |
|
#define | SI1133_RSP0_CHIPSTAT_MASK 0xE0 |
#define | SI1133_RSP0_COUNTER_MASK 0x1F |
#define | SI1133_RSP0_SLEEP 0x20 |
Macro Definition Documentation
#define SI1133_CMD_FORCE_CH 0x11 |
Initiates a set of measurements specified in CHAN_LIST parameter
Definition at line
199
of file
si1133.h
.
Referenced by SI1133_measurementForce() .
#define SI1133_CMD_NEW_ADDR 0x02 |
Stores the new I2C address
Definition at line
198
of file
si1133.h
.
#define SI1133_CMD_PARAM_QUERY 0x40 |
Reads a parameter
Definition at line
203
of file
si1133.h
.
#define SI1133_CMD_PARAM_SET 0x80 |
Sets a parameter
Definition at line
202
of file
si1133.h
.
#define SI1133_CMD_PAUSE_CH 0x12 |
Pauses autonomous measurements
Definition at line
200
of file
si1133.h
.
Referenced by SI1133_measurementPause() .
#define SI1133_CMD_RESET 0x01 |
#define SI1133_CMD_RESET_CMD_CTR 0x00 |
Resets the command counter
Definition at line
196
of file
si1133.h
.
Referenced by SI1133_resetCmdCtr() , and SI1133_sendCmd() .
#define SI1133_CMD_START 0x13 |
Starts autonomous measurements
Definition at line
201
of file
si1133.h
.
Referenced by SI1133_measurementStart() .
#define SI1133_ERROR_I2C_TRANSACTION_FAILED 0x0001 |
I2C transaction failed
Definition at line
73
of file
si1133.h
.
Referenced by SI1133_registerBlockRead() , SI1133_registerBlockWrite() , SI1133_registerRead() , and SI1133_registerWrite() .
#define SI1133_ERROR_SLEEP_FAILED 0x0002 |
Entering sleep mode failed
Definition at line
74
of file
si1133.h
.
Referenced by SI1133_waitUntilSleep() .
#define SI1133_OK 0x0000 |
No errors
Definition at line
72
of file
si1133.h
.
Referenced by SI1133_paramRead() , SI1133_paramSet() , SI1133_registerBlockRead() , SI1133_registerBlockWrite() , SI1133_registerRead() , SI1133_registerWrite() , SI1133_sendCmd() , and SI1133_waitUntilSleep() .
#define SI1133_PARAM_ADCCONFIG0 0x02 |
#define SI1133_PARAM_ADCCONFIG1 0x06 |
#define SI1133_PARAM_ADCCONFIG2 0x0A |
#define SI1133_PARAM_ADCCONFIG3 0x0E |
#define SI1133_PARAM_ADCCONFIG4 0x12 |
ADC config for Channel 4
Definition at line
170
of file
si1133.h
.
#define SI1133_PARAM_ADCCONFIG5 0x16 |
ADC config for Channel 5
Definition at line
174
of file
si1133.h
.
#define SI1133_PARAM_ADCPOST0 0x04 |
ADC resolution, shift and threshold settings for Channel 0
Definition at line
156
of file
si1133.h
.
Referenced by SI1133_init() .
#define SI1133_PARAM_ADCPOST1 0x08 |
ADC resolution, shift and threshold settings for Channel 1
Definition at line
160
of file
si1133.h
.
Referenced by SI1133_init() .
#define SI1133_PARAM_ADCPOST2 0x0C |
ADC resolution, shift and threshold settings for Channel 2
Definition at line
164
of file
si1133.h
.
Referenced by SI1133_init() .
#define SI1133_PARAM_ADCPOST3 0x10 |
ADC resolution, shift and threshold settings for Channel 3
Definition at line
168
of file
si1133.h
.
Referenced by SI1133_init() .
#define SI1133_PARAM_ADCPOST4 0x14 |
ADC resolution, shift and threshold settings for Channel 4
Definition at line
172
of file
si1133.h
.
#define SI1133_PARAM_ADCPOST5 0x18 |
ADC resolution, shift and threshold settings for Channel 5
Definition at line
176
of file
si1133.h
.
#define SI1133_PARAM_ADCSENS0 0x03 |
ADC sensitivity setting for Channel 0
Definition at line
155
of file
si1133.h
.
Referenced by SI1133_init() .
#define SI1133_PARAM_ADCSENS1 0x07 |
ADC sensitivity setting for Channel 1
Definition at line
159
of file
si1133.h
.
Referenced by SI1133_init() .
#define SI1133_PARAM_ADCSENS2 0x0B |
ADC sensitivity setting for Channel 2
Definition at line
163
of file
si1133.h
.
Referenced by SI1133_init() .
#define SI1133_PARAM_ADCSENS3 0x0F |
ADC sensitivity setting for Channel 3
Definition at line
167
of file
si1133.h
.
Referenced by SI1133_init() .
#define SI1133_PARAM_ADCSENS4 0x13 |
ADC sensitivity setting for Channel 4
Definition at line
171
of file
si1133.h
.
#define SI1133_PARAM_ADCSENS5 0x17 |
ADC sensitivity setting for Channel 5
Definition at line
175
of file
si1133.h
.
#define SI1133_PARAM_BURST 0x2B |
Burst enable and burst count
Definition at line
189
of file
si1133.h
.
#define SI1133_PARAM_CH_LIST 0x01 |
Channel list
Definition at line
153
of file
si1133.h
.
Referenced by SI1133_deInit() , and SI1133_init() .
#define SI1133_PARAM_I2C_ADDR 0x00 |
I2C address
Definition at line
152
of file
si1133.h
.
#define SI1133_PARAM_MEASCONFIG0 0x05 |
ADC measurement counter selection for Channel 0
Definition at line
157
of file
si1133.h
.
#define SI1133_PARAM_MEASCONFIG1 0x09 |
ADC measurement counter selection for Channel 1
Definition at line
161
of file
si1133.h
.
#define SI1133_PARAM_MEASCONFIG2 0x0D |
ADC measurement counter selection for Channel 2
Definition at line
165
of file
si1133.h
.
#define SI1133_PARAM_MEASCONFIG3 0x11 |
ADC measurement counter selection for Channel 3
Definition at line
169
of file
si1133.h
.
#define SI1133_PARAM_MEASCONFIG4 0x15 |
ADC measurement counter selection for Channel 4
Definition at line
173
of file
si1133.h
.
#define SI1133_PARAM_MEASCONFIG5 0x19 |
ADC measurement counter selection for Channel 5
Definition at line
177
of file
si1133.h
.
#define SI1133_PARAM_MEASCOUNT0 0x1C |
Measurement rate extension counter 0
Definition at line
180
of file
si1133.h
.
#define SI1133_PARAM_MEASCOUNT1 0x1D |
Measurement rate extension counter 1
Definition at line
181
of file
si1133.h
.
#define SI1133_PARAM_MEASCOUNT2 0x1E |
Measurement rate extension counter 2
Definition at line
182
of file
si1133.h
.
#define SI1133_PARAM_MEASRATE_H 0x1A |
Main measurement rate counter MSB
Definition at line
178
of file
si1133.h
.
#define SI1133_PARAM_MEASRATE_L 0x1B |
Main measurement rate counter LSB
Definition at line
179
of file
si1133.h
.
#define SI1133_PARAM_THRESHOLD0_H 0x25 |
Threshold level 0 MSB
Definition at line
183
of file
si1133.h
.
#define SI1133_PARAM_THRESHOLD0_L 0x26 |
Threshold level 0 LSB
Definition at line
184
of file
si1133.h
.
#define SI1133_PARAM_THRESHOLD1_H 0x27 |
Threshold level 1 MSB
Definition at line
185
of file
si1133.h
.
#define SI1133_PARAM_THRESHOLD1_L 0x28 |
Threshold level 1 LSB
Definition at line
186
of file
si1133.h
.
#define SI1133_PARAM_THRESHOLD2_H 0x29 |
Threshold level 2 MSB
Definition at line
187
of file
si1133.h
.
#define SI1133_PARAM_THRESHOLD2_L 0x2A |
Threshold level 2 LSB
Definition at line
188
of file
si1133.h
.
#define SI1133_REG_COMMAND 0x0B |
Initiated action in Sensor when specific codes written here
Definition at line
115
of file
si1133.h
.
Referenced by SI1133_reset() , and SI1133_sendCmd() .
#define SI1133_REG_HOSTIN0 0x0A |
Data for parameter table on PARAM_SET write to COMMAND register
Definition at line
114
of file
si1133.h
.
Referenced by SI1133_paramSet() .
#define SI1133_REG_HOSTOUT0 0x13 |
Captured Sensor Data
Definition at line
120
of file
si1133.h
.
#define SI1133_REG_HOSTOUT1 0x14 |
Captured Sensor Data
Definition at line
121
of file
si1133.h
.
#define SI1133_REG_HOSTOUT10 0x1D |
Captured Sensor Data
Definition at line
130
of file
si1133.h
.
#define SI1133_REG_HOSTOUT11 0x1E |
Captured Sensor Data
Definition at line
131
of file
si1133.h
.
#define SI1133_REG_HOSTOUT12 0x1F |
Captured Sensor Data
Definition at line
132
of file
si1133.h
.
#define SI1133_REG_HOSTOUT13 0x20 |
Captured Sensor Data
Definition at line
133
of file
si1133.h
.
#define SI1133_REG_HOSTOUT14 0x21 |
Captured Sensor Data
Definition at line
134
of file
si1133.h
.
#define SI1133_REG_HOSTOUT15 0x22 |
Captured Sensor Data
Definition at line
135
of file
si1133.h
.
#define SI1133_REG_HOSTOUT16 0x23 |
Captured Sensor Data
Definition at line
136
of file
si1133.h
.
#define SI1133_REG_HOSTOUT17 0x24 |
Captured Sensor Data
Definition at line
137
of file
si1133.h
.
#define SI1133_REG_HOSTOUT18 0x25 |
Captured Sensor Data
Definition at line
138
of file
si1133.h
.
#define SI1133_REG_HOSTOUT19 0x26 |
Captured Sensor Data
Definition at line
139
of file
si1133.h
.
#define SI1133_REG_HOSTOUT2 0x15 |
Captured Sensor Data
Definition at line
122
of file
si1133.h
.
#define SI1133_REG_HOSTOUT20 0x27 |
Captured Sensor Data
Definition at line
140
of file
si1133.h
.
#define SI1133_REG_HOSTOUT21 0x28 |
Captured Sensor Data
Definition at line
141
of file
si1133.h
.
#define SI1133_REG_HOSTOUT22 0x29 |
Captured Sensor Data
Definition at line
142
of file
si1133.h
.
#define SI1133_REG_HOSTOUT23 0x2A |
Captured Sensor Data
Definition at line
143
of file
si1133.h
.
#define SI1133_REG_HOSTOUT24 0x2B |
Captured Sensor Data
Definition at line
144
of file
si1133.h
.
#define SI1133_REG_HOSTOUT25 0x2C |
Captured Sensor Data
Definition at line
145
of file
si1133.h
.
#define SI1133_REG_HOSTOUT3 0x16 |
Captured Sensor Data
Definition at line
123
of file
si1133.h
.
#define SI1133_REG_HOSTOUT4 0x17 |
Captured Sensor Data
Definition at line
124
of file
si1133.h
.
#define SI1133_REG_HOSTOUT5 0x18 |
Captured Sensor Data
Definition at line
125
of file
si1133.h
.
#define SI1133_REG_HOSTOUT6 0x19 |
Captured Sensor Data
Definition at line
126
of file
si1133.h
.
#define SI1133_REG_HOSTOUT7 0x1A |
Captured Sensor Data
Definition at line
127
of file
si1133.h
.
#define SI1133_REG_HOSTOUT8 0x1B |
Captured Sensor Data
Definition at line
128
of file
si1133.h
.
#define SI1133_REG_HOSTOUT9 0x1C |
Captured Sensor Data
Definition at line
129
of file
si1133.h
.
#define SI1133_REG_HW_ID 0x01 |
Hardware ID
Definition at line
112
of file
si1133.h
.
#define SI1133_REG_IRQ_ENABLE 0x0F |
#define SI1133_REG_IRQ_STATUS 0x12 |
Interrupt status
Definition at line
119
of file
si1133.h
.
Referenced by SI1133_getIrqStatus() , SI1133_measureLuxUvi() , and SI1133_measurementGet() .
#define SI1133_REG_PART_ID 0x00 |
#define SI1133_REG_RESPONSE0 0x11 |
Chip state and error status
Definition at line
118
of file
si1133.h
.
Referenced by SI1133_paramSet() , SI1133_sendCmd() , and SI1133_waitUntilSleep() .
#define SI1133_REG_RESPONSE1 0x10 |
Contains the readback value from a param query or a param set command
Definition at line
117
of file
si1133.h
.
Referenced by SI1133_paramRead() .
#define SI1133_REG_REV_ID 0x02 |
Hardware revision
Definition at line
113
of file
si1133.h
.
#define SI1133_RSP0_CHIPSTAT_MASK 0xE0 |
Chip state mask in Response0 register
Definition at line
210
of file
si1133.h
.
Referenced by SI1133_waitUntilSleep() .
#define SI1133_RSP0_COUNTER_MASK 0x1F |
Command counter and error indicator mask in Response0 register
Definition at line
211
of file
si1133.h
.
Referenced by SI1133_paramSet() , and SI1133_sendCmd() .
#define SI1133_RSP0_SLEEP 0x20 |
Sleep state indicator bit mask in Response0 register
Definition at line
212
of file
si1133.h
.
Referenced by SI1133_waitUntilSleep() .
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
595
of file
si1133.c
.
References BOARD_alsEnable() , 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] hardwareID
The Hardware ID of the chip (should be 0x33)
- Returns
- Returns zero on OK, non-zero otherwise
Definition at line
873
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] irqStatus
The contentof the IRQ status register
- Returns
- Returns zero on OK, non-zero otherwise
Definition at line
925
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_high
Visible light sensor raw data [in] vis_low
Visible light sensor raw data [in] ir
Infrared sensor raw data [in] lk
Lux calculation coefficients
- Returns
- Lux value scaled by LUX_OUPTUT_FRACTION
Definition at line
794
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] lux
The measured ambient light illuminace in lux [out] uvi
UV index
- Returns
- Returns zero on OK, non-zero otherwise
Definition at line
896
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] uv
UV sensor raw data [in] uk
UV calculation coefficients
- Returns
- UV index scaled by UV_OUPTUT_FRACTION
Definition at line
766
of file
si1133.c
.
Referenced by SI1133_getMeasurement() , and SI1133_measureLuxUvi() .
uint32_t SI1133_init | ( | void |
|
) |
Initializes the Si1133 chip.
- Returns
- Returns zero on OK, non-zero otherwise
Definition at line
554
of file
si1133.c
.
References BOARD_alsEnable() , SI1133_PARAM_ADCCONFIG0 , SI1133_PARAM_ADCCONFIG1 , SI1133_PARAM_ADCCONFIG2 , SI1133_PARAM_ADCCONFIG3 , SI1133_PARAM_ADCPOST0 , SI1133_PARAM_ADCPOST1 , SI1133_PARAM_ADCPOST2 , SI1133_PARAM_ADCPOST3 , SI1133_PARAM_ADCSENS0 , SI1133_PARAM_ADCSENS1 , SI1133_PARAM_ADCSENS2 , SI1133_PARAM_ADCSENS3 , SI1133_PARAM_CH_LIST , SI1133_paramSet() , SI1133_REG_IRQ_ENABLE , SI1133_registerWrite() , SI1133_reset() , and UTIL_delay() .
uint32_t SI1133_measureLuxUvi | ( | float * |
lux,
|
float * |
uvi
|
||
) |
Measure lux and UV index using the Si1133 sensor.
- Parameters
-
[out] lux
The measured ambient light illuminace in lux [out] uvi
UV index
- Returns
- Returns zero on OK, non-zero otherwise
Definition at line
830
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
427
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] samples
Retrieves 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
620
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 |
|
) |
Sends a PAUSE command to the Si1133.
- Returns
- Returns zero on OK, non-zero otherwise
Definition at line
542
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
439
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] address
The address of the parameter.
- Returns
- Returns zero on OK, non-zero otherwise
Definition at line
454
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] address
The parameter address [in] value
The 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
492
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] reg
The first register to begin reading from [in] length
The number of bytes to write to the sensor [out] data
The data read from the sensor
- Returns
- Returns zero on OK, non-zero otherwise
Definition at line
240
of file
si1133.c
.
References I2C_TransferSeq_TypeDef::addr , BOARD_i2cBusSelect() , 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 , 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] reg
The first register to begin writing to [in] length
The number of bytes to write to the sensor [in] data
The data to write to the sensor
- Returns
- Returns zero on OK, non-zero otherwise
Definition at line
191
of file
si1133.c
.
References I2C_TransferSeq_TypeDef::addr , BOARD_i2cBusSelect() , 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 , and SI1133_OK .
Referenced by SI1133_paramSet() .
uint32_t SI1133_registerRead | ( | uint8_t |
reg,
|
uint8_t * |
data
|
||
) |
Reads register from the Si1133 sensor.
- Parameters
-
[in] reg
The register address to read from in the sensor. [out] data
The data read from the sensor
- Returns
- Returns zero on OK, non-zero otherwise
Definition at line
102
of file
si1133.c
.
References I2C_TransferSeq_TypeDef::addr , BOARD_i2cBusSelect() , 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 , 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] reg
The register address to write to in the sensor [in] data
The data to write to the sensor
- Returns
- Returns zero on OK, non-zero otherwise
Definition at line
145
of file
si1133.c
.
References I2C_TransferSeq_TypeDef::addr , BOARD_i2cBusSelect() , 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 , 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
311
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
415
of file
si1133.c
.
References SI1133_CMD_RESET_CMD_CTR , and SI1133_sendCmd() .
|
static |
Helper function to send a command to the Si1133.
- Parameters
-
[in] command
The command to send to the sensor
- Returns
- Returns zero on OK, non-zero otherwise
Definition at line
338
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 |
Waits until the Si1133 is sleeping before proceeding.
- Returns
- Returns zero on OK, non-zero otherwise
Definition at line
276
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() .