Initialized interrupt thresholds and added missing check
This commit is contained in:
parent
a8a1ebf8b5
commit
7abee394cb
|
@ -102,6 +102,7 @@ PROCESS_THREAD(remote_tsl2563_process, ev, data)
|
||||||
} else {
|
} else {
|
||||||
printf("Error, enable the DEBUG flag in the tsl2563 driver for info, ");
|
printf("Error, enable the DEBUG flag in the tsl2563 driver for info, ");
|
||||||
printf("or check if the sensor is properly connected\n");
|
printf("or check if the sensor is properly connected\n");
|
||||||
|
PROCESS_EXIT();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
PROCESS_END();
|
PROCESS_END();
|
||||||
|
|
|
@ -299,8 +299,29 @@ configure(int type, int value)
|
||||||
timming = buf[0] & TSL2563_TIMMING_INTEG_MASK;
|
timming = buf[0] & TSL2563_TIMMING_INTEG_MASK;
|
||||||
PRINTF("TSL2563: enabled, timming %u gain %u\n", timming, gain);
|
PRINTF("TSL2563: enabled, timming %u gain %u\n", timming, gain);
|
||||||
|
|
||||||
|
/* Restart the over interrupt threshold */
|
||||||
|
buf[0] = (TSL2563_COMMAND + TSL2563_THRHIGHLOW);
|
||||||
|
buf[1] = 0xFF;
|
||||||
|
buf[2] = 0xFF;
|
||||||
|
|
||||||
|
if(tsl2563_write_reg(buf, 3) != TSL2563_SUCCESS) {
|
||||||
|
PRINTF("TSL2563: failed to clear over interrupt\n");
|
||||||
|
return TSL2563_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Restart the below interrupt threshold */
|
||||||
|
buf[0] = (TSL2563_COMMAND + TSL2563_THRLOWLOW);
|
||||||
|
buf[1] = 0x00;
|
||||||
|
buf[2] = 0x00;
|
||||||
|
|
||||||
|
if(tsl2563_write_reg(buf, 3) != TSL2563_SUCCESS) {
|
||||||
|
PRINTF("TSL2563: failed to clear below interrupt\n");
|
||||||
|
return TSL2563_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
/* Clear any pending interrupt */
|
/* Clear any pending interrupt */
|
||||||
if(tsl2563_clear_interrupt() == TSL2563_SUCCESS) {
|
if(tsl2563_clear_interrupt() == TSL2563_SUCCESS) {
|
||||||
|
enabled = 1;
|
||||||
return TSL2563_SUCCESS;
|
return TSL2563_SUCCESS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -311,12 +332,18 @@ configure(int type, int value)
|
||||||
} else {
|
} else {
|
||||||
if(tsl2563_off() == TSL2563_SUCCESS) {
|
if(tsl2563_off() == TSL2563_SUCCESS) {
|
||||||
PRINTF("TSL2563: stopped\n");
|
PRINTF("TSL2563: stopped\n");
|
||||||
|
enabled = 0;
|
||||||
return TSL2563_SUCCESS;
|
return TSL2563_SUCCESS;
|
||||||
}
|
}
|
||||||
return TSL2563_ERROR;
|
return TSL2563_ERROR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(!enabled) {
|
||||||
|
PRINTF("TSL2563: sensor not started\n");
|
||||||
|
return TSL2563_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
if(type == TSL2563_INT_DISABLE) {
|
if(type == TSL2563_INT_DISABLE) {
|
||||||
|
|
||||||
/* Ensure the GPIO doesn't generate more interrupts, this may affect others
|
/* Ensure the GPIO doesn't generate more interrupts, this may affect others
|
||||||
|
@ -447,6 +474,12 @@ static int
|
||||||
value(int type)
|
value(int type)
|
||||||
{
|
{
|
||||||
uint16_t lux;
|
uint16_t lux;
|
||||||
|
|
||||||
|
if(!enabled) {
|
||||||
|
PRINTF("TSL2563: sensor not started\n");
|
||||||
|
return TSL2563_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
if(type == TSL2563_VAL_READ) {
|
if(type == TSL2563_VAL_READ) {
|
||||||
if(tsl2563_read_sensor(&lux) != TSL2563_ERROR) {
|
if(tsl2563_read_sensor(&lux) != TSL2563_ERROR) {
|
||||||
return lux;
|
return lux;
|
||||||
|
|
Loading…
Reference in a new issue