28 #ifndef SI114X_FUNCTIONS_H
29 #define SI114X_FUNCTIONS_H
103 uint8_t* input_ucoef,
110 #define REG_PART_ID 0x00
111 #define REG_REV_ID 0x01
112 #define REG_SEQ_ID 0x02
113 #define REG_INT_CFG 0x03
114 #define REG_IRQ_ENABLE 0x04
115 #define REG_IRQ_MODE1 0x05
116 #define REG_IRQ_MODE2 0x06
117 #define REG_HW_KEY 0x07
118 #define REG_MEAS_RATE 0x08
119 #define REG_ALS_RATE 0x09
120 #define REG_PS_RATE 0x0A
121 #define REG_ALS_LO_TH_LSB 0x0B
122 #define REG_ALS_LO_TH_MSB 0x0C
123 #define REG_ALS_HI_TH_LSB 0x0D
124 #define REG_ALS_HI_TH_MSB 0x0E
125 #define REG_PS_LED21 0x0F
126 #define REG_PS_LED3 0x10
127 #define REG_PS1_TH_LSB 0x11
128 #define REG_PS1_TH_MSB 0x12
129 #define REG_PS2_TH_LSB 0x13
130 #define REG_PS2_TH_MSB 0x14
131 #define REG_PS3_TH_LSB 0x15
132 #define REG_PS3_TH_MSB 0x16
133 #define REG_PARAM_WR 0x17
134 #define REG_COMMAND 0x18
135 #define REG_RESPONSE 0x20
136 #define REG_IRQ_STATUS 0x21
137 #define REG_ALS_VIS_DATA0 0x22
138 #define REG_ALS_VIS_DATA1 0x23
139 #define REG_ALS_IR_DATA0 0x24
140 #define REG_ALS_IR_DATA1 0x25
141 #define REG_PS1_DATA0 0x26
142 #define REG_PS1_DATA1 0x27
143 #define REG_PS2_DATA0 0x28
144 #define REG_PS2_DATA1 0x29
145 #define REG_PS3_DATA0 0x2A
146 #define REG_PS3_DATA1 0x2B
147 #define REG_AUX_DATA0 0x2C
148 #define REG_AUX_DATA1 0x2D
149 #define REG_PARAM_OUT 0x2E
150 #define REG_PARAM_RD 0x2E
151 #define REG_CHIP_STAT 0x30
152 #define REG_UCOEF0 0x13
153 #define REG_UCOEF1 0x14
154 #define REG_UCOEF2 0x15
155 #define REG_UCOEF3 0x16
156 #define REG_MEAS_RATE_LSB 0x08
157 #define REG_MEAS_RATE_MSB 0x09
164 #define PARAM_I2C_ADDR 0x00
165 #define PARAM_CH_LIST 0x01
166 #define PARAM_PSLED12_SELECT 0x02
167 #define PARAM_PSLED3_SELECT 0x03
168 #define PARAM_FILTER_EN 0x04
169 #define PARAM_PS_ENCODING 0x05
170 #define PARAM_ALS_ENCODING 0x06
171 #define PARAM_PS1_ADC_MUX 0x07
172 #define PARAM_PS2_ADC_MUX 0x08
173 #define PARAM_PS3_ADC_MUX 0x09
174 #define PARAM_PS_ADC_COUNTER 0x0A
175 #define PARAM_PS_ADC_CLKDIV 0x0B
176 #define PARAM_PS_ADC_GAIN 0x0B
177 #define PARAM_PS_ADC_MISC 0x0C
178 #define PARAM_VIS_ADC_MUX 0x0D
179 #define PARAM_IR_ADC_MUX 0x0E
180 #define PARAM_AUX_ADC_MUX 0x0F
181 #define PARAM_ALSVIS_ADC_COUNTER 0x10
182 #define PARAM_ALSVIS_ADC_CLKDIV 0x11
183 #define PARAM_ALSVIS_ADC_GAIN 0x11
184 #define PARAM_ALSVIS_ADC_MISC 0x12
185 #define PARAM_ALS_HYST 0x16
186 #define PARAM_PS_HYST 0x17
187 #define PARAM_PS_HISTORY 0x18
188 #define PARAM_ALS_HISTORY 0x19
189 #define PARAM_ADC_OFFSET 0x1A
190 #define PARAM_SLEEP_CTRL 0x1B
191 #define PARAM_LED_RECOVERY 0x1C
192 #define PARAM_ALSIR_ADC_COUNTER 0x1D
193 #define PARAM_ALSIR_ADC_CLKDIV 0x1E
194 #define PARAM_ALSIR_ADC_GAIN 0x1E
195 #define PARAM_ALSIR_ADC_MISC 0x1F
204 #define ICG_INTOE 0x01
205 #define ICG_INTMODE 0x02
211 #define IE_ALS_NONE 0x00
212 #define IE_ALS_EVRYSAMPLE 0x01
213 #define IE_ALS_EXIT_WIN 0x01
214 #define IE_ALS_ENTER_WIN 0x02
216 #define IE_PS1_NONE 0x00
217 #define IE_PS1_EVRYSAMPLE 0x04
218 #define IE_PS1_CROSS_TH 0x04
219 #define IE_PS1_EXCEED_TH 0x04
222 #define IE_PS2_NONE 0x00
223 #define IE_PS2_EVRYSAMPLE 0x08
224 #define IE_PS2_CROSS_TH 0x08
225 #define IE_PS2_EXCEEED_TH 0x08
228 #define IE_PS3_NONE 0x00
229 #define IE_PS3_EVRYSAMPLE 0x10
230 #define IE_PS3_CROSS_TH 0x10
231 #define IE_PS3_EXCEED_TH 0x10
239 #define IM1_NONE 0x00
240 #define IM1_ALS_NONE 0x00
241 #define IM1_ALS_EVRYSAMPLE 0x00
242 #define IM1_ALS_VIS_EXIT 0x01
243 #define IM1_ALS_VIS_ENTER 0x05
244 #define IM1_ALS_IR_EXIT 0x03
245 #define IM1_ALS_IR_ENTER 0x06
247 #define IM1_PS1_NONE 0x00
248 #define IM1_PS1_EVRYSAMPLE (0x0<<4)
249 #define IM1_PS1_CROSS_TH (0x1<<4)
250 #define IM1_PS1_EXCEED_TH (0x3<<4)
252 #define IM1_PS2_NONE 0x00
253 #define IM1_PS2_EVRYSAMPLE (0x0<<6)
254 #define IM1_PS2_CROSS_TH (0x1<<6)
255 #define IM1_PS2_EXCEED_TH (0x3<<6)
259 #define IM2_PS3_NONE 0x00
260 #define IM2_PS3_EVRYSAMPLE (0x0)
261 #define IM2_PS3_CROSS_TH (0x1)
262 #define IM2_PS3_EXCEED_TH (0x3)
270 #define LEDI_000 0x00
271 #define LEDI_006 0x01
272 #define LEDI_011 0x02
273 #define LEDI_022 0x03
274 #define LEDI_045 0x04
275 #define LEDI_067 0x05
276 #define LEDI_090 0x06
277 #define LEDI_112 0x07
278 #define LEDI_135 0x08
279 #define LEDI_157 0x09
280 #define LEDI_180 0x0A
281 #define LEDI_202 0x0B
282 #define LEDI_224 0x0C
283 #define LEDI_269 0x0D
284 #define LEDI_314 0x0E
285 #define LEDI_359 0x0F
289 #define PS1_TASK 0x01
290 #define PS2_TASK 0x02
291 #define PS3_TASK 0x04
292 #define ALS_VIS_TASK 0x10
293 #define ALS_IR_TASK 0x20
294 #define AUX_TASK 0x40
302 #define RECCNT_001 0x00
303 #define RECCNT_007 0x10
304 #define RECCNT_015 0x20
305 #define RECCNT_031 0x30
306 #define RECCNT_063 0x40
307 #define RECCNT_127 0x50
308 #define RECCNT_255 0x60
309 #define RECCNT_511 0x70
325 #define SEL_LED1_PS1 (LED1_EN)
326 #define SEL_LED2_PS1 (LED2_EN)
327 #define SEL_LED3_PS1 (LED3_EN)
328 #define SEL_LED1_PS2 (LED1_EN<<4)
329 #define SEL_LED2_PS2 (LED2_EN<<4)
330 #define SEL_LED3_PS2 (LED3_EN<<4)
331 #define SEL_LED1_PS3 (LED1_EN)
332 #define SEL_LED2_PS3 (LED2_EN)
333 #define SEL_LED3_PS3 (LED3_EN)
343 #define PS_ENCODING_MASK 0x70
350 #define ALS_VIS_LSB 0x10
351 #define ALS_IR_LSB 0x20
353 #define ALS_ENCODING_MASK 0xCF
404 #define NOT_PS_MEAS_MODE 0x00
405 #define PS_MEAS_MODE 0x04
407 #define RANGE_EN 0x20
409 #define ALS_IR_ADC_MISC_MASK 0x20
410 #define ALS_VIS_ADC_MISC_MASK 0x20
424 #define MUX_SMALL_IR 0x00
426 #define MUX_LARGE_IR 0x03
427 #define MUX_NO_PHOTO_DIODE 0x06
428 #define MUX_VTEMP 0x65
430 #define MUX_LED1 0x15
432 #define MUX_LED2 0x35
441 #define ADC_NORM 0x00
442 #define ADC_DIV2 0x01
443 #define ADC_DIV4 0x02
444 #define ADC_DIV8 0x03
445 #define ADC_DIV16 0x04
446 #define ADC_DIV32 0x05
447 #define ADC_DIV64 0x06
448 #define ADC_DIV128 0x07
449 #define ADC_DIV256 0x08
450 #define ADC_DIV512 0x09
451 #define ADC_DIV1024 0x0A
452 #define ADC_DIV2048 0x0B
456 #define HW_KEY_VAL0 0x17
460 #define SLEEP_DISABLED 0x01
463 #define ANA_KEY_38 0x10
464 #define ANA_KEY_39 0x40
465 #define AMA_KEY_3A 0x62
466 #define ANA_KEY_3B 0x3b
476 #endif // #define SI114X_FUNCTIONS_H
SI114X_CAL_S Data Structure.
void delay_10ms(void)
Implements 10ms delay.
int16_t Si114xPsForce(HANDLE si114x_handle)
Sends a PSFORCE command to the Si113x/4x.
int16_t Si114xNop(HANDLE si114x_handle)
Sends a NOP command to the Si113x/4x.
uint16_t Uncompress(uint8_t input)
Converts an 8-bit compressed value to 16-bit.
uint32_t vispd_correction
int16_t Si114xParamSet(HANDLE si114x_handle, uint8_t address, uint8_t value)
Writes a byte to an Si113x/4x Parameter.
uint8_t Compress(uint16_t input)
Converts a 16-bit value to 8-bit value.
int16_t Si114xBlockWrite(HANDLE si114x_handle, uint8_t address, uint8_t length, uint8_t *values)
Writes block of Si114x registers.
int16_t Si114xWriteToRegister(HANDLE si114x_handle, uint8_t address, uint8_t value)
Writes to Si114x Register.
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.
int16_t Si114xAlsForce(HANDLE si114x_handle)
Sends an ALSFORCE command to the Si113x/4x.
int16_t Si114xParamRead(HANDLE si114x_handle, uint8_t address)
Reads a Parameter from the Si113x/4x.
void delay_1ms(void)
Implements 1ms delay.
int16_t Si114xPsAlsForce(HANDLE si114x_handle)
Sends a PSALSFORCE command to the Si113x/4x.
int16_t Si114xReadFromRegister(HANDLE si114x_handle, uint8_t address)
Reads from Si114x register.
int16_t Si114xBlockRead(HANDLE si114x_handle, uint8_t address, uint8_t length, uint8_t *values)
Reads block of Si114x registers.
int16_t si114x_get_calibration(HANDLE si114x_handle, SI114X_CAL_S *si114x_cal, uint8_t security)
Populates the SI114X_CAL_S structure.
static void * si114x_handle
Si114x PGM toolkit functions uses a void* to pass hardware parameters through to the lower level i2c ...
int16_t Si114xPsAlsAuto(HANDLE si114x_handle)
Sends a PSALSAUTO command to the Si113x/4x.
int16_t Si114xPauseAll(HANDLE si114x_handle)
Pauses autonomous measurements.
int16_t Si114xReset(HANDLE si114x_handle)
Resets the Si113x/4x, clears any interrupts and initializes the HW_KEY register.