Browse Source

tests/driver_isl29125: extended test for interrupt use

patch-1
martinheusmann 6 years ago committed by Cenk Gündoğan
parent
commit
c2458dbd6d
  1. 4
      tests/driver_isl29125/Makefile
  2. 23
      tests/driver_isl29125/main.c

4
tests/driver_isl29125/Makefile

@ -1,4 +1,8 @@
APPLICATION = driver_isl29125
# If no BOARD is found in the environment, use this default:
BOARD ?= samr21-xpro
include ../Makefile.tests_common
FEATURES_REQUIRED = periph_i2c

23
tests/driver_isl29125/main.c

@ -1,5 +1,6 @@
/*
* Copyright 2015 Ludwig Knüpfer
* Copyright 2017 HAW Hamburg
*
* This file is subject to the terms and conditions of the GNU Lesser
* General Public License v2.1. See the file LICENSE in the top level
@ -14,6 +15,8 @@
* @brief Test application for the ISL29125 RGB light sensor
*
* @author Ludwig Knüpfer <ludwig.knuepfer@fu-berlin.de>
* @author Martin Heusmann <martin.heusmann@haw-hamburg.de>
* @author Cenk Gündoğan <mail-github@cgundogan.de>
*
* @}
*/
@ -34,6 +37,12 @@
#define SLEEP (250 * 1000U)
void cb(void *arg)
{
(void) arg;
printf("INT: external interrupt\n");
}
int main(void)
{
isl29125_t dev;
@ -41,6 +50,10 @@ int main(void)
color_rgb_t data8bit;
memset(&data, 0x00, sizeof(data));
/* Parameters for testing, change if needed. */
uint16_t lower_threshold = 0;
uint16_t higher_threshold = 8000;
puts("ISL29125 light sensor test application\n");
printf("Initializing ISL29125 sensor at I2C_%i... ", TEST_ISL29125_I2C);
if (isl29125_init(&dev, TEST_ISL29125_I2C, TEST_ISL29125_IRQ_PIN,
@ -53,6 +66,15 @@ int main(void)
return 1;
}
puts("Initializing interrupt");
if (isl29125_init_int(&dev, ISL29125_INTERRUPT_STATUS_RED,
ISL29125_INTERRUPT_PERSIST_1, ISL29125_INTERRUPT_CONV_DIS,
lower_threshold, higher_threshold, cb, NULL) != 0) {
puts("[Failed]");
return 1;
}
/* try out some modes */
static const isl29125_mode_t modes[] = {
ISL29125_MODE_DOWN, ISL29125_MODE_STANDBY, ISL29125_MODE_RGB,
@ -80,6 +102,7 @@ int main(void)
printf("RGB value: (%5i / %5i / %5i) lux\n",
(int)data.red, (int)data.green, (int)data.blue);
xtimer_usleep(SLEEP);
printf("IRQ-Status: %i \n", isl29125_read_irq_status(&dev));
}
return 0;

Loading…
Cancel
Save