diff options
author | Anas Nashif <anas.nashif@intel.com> | 2016-10-08 17:35:34 -0400 |
---|---|---|
committer | Anas Nashif <nashif@linux.intel.com> | 2016-10-27 22:14:33 +0000 |
commit | b5427473fcae7f99875f62926d5590663fc53de6 (patch) | |
tree | c38f83a1aa6ab2aa07d2f3edeb54283b228f3399 /samples | |
parent | 2af8eb17c1324222916361e68c481183d6c10026 (diff) |
samples: add light sensor sample using the grove kit
Change-Id: Idf88aac781b2fd2314694c38dfa20d36fee517f9
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
Diffstat (limited to 'samples')
-rw-r--r-- | samples/grove/light/Makefile | 5 | ||||
-rw-r--r-- | samples/grove/light/prj.conf | 8 | ||||
-rw-r--r-- | samples/grove/light/src/Makefile | 1 | ||||
-rw-r--r-- | samples/grove/light/src/main.c | 42 |
4 files changed, 56 insertions, 0 deletions
diff --git a/samples/grove/light/Makefile b/samples/grove/light/Makefile new file mode 100644 index 000000000..768404d65 --- /dev/null +++ b/samples/grove/light/Makefile @@ -0,0 +1,5 @@ +BOARD ?= arduino_101_sss +KERNEL_TYPE ?= nano +CONF_FILE ?= prj.conf + +include ${ZEPHYR_BASE}/Makefile.inc diff --git a/samples/grove/light/prj.conf b/samples/grove/light/prj.conf new file mode 100644 index 000000000..294675538 --- /dev/null +++ b/samples/grove/light/prj.conf @@ -0,0 +1,8 @@ +CONFIG_ADC=y +CONFIG_GROVE_LIGHT_SENSOR=y +CONFIG_GROVE=y +CONFIG_SENSOR=y +CONFIG_NEWLIB_LIBC=y +CONFIG_MINIMAL_LIBC=n +CONFIG_STDOUT_CONSOLE=y +CONFIG_NANO_TIMEOUTS=y diff --git a/samples/grove/light/src/Makefile b/samples/grove/light/src/Makefile new file mode 100644 index 000000000..b666967fd --- /dev/null +++ b/samples/grove/light/src/Makefile @@ -0,0 +1 @@ +obj-y += main.o diff --git a/samples/grove/light/src/main.c b/samples/grove/light/src/main.c new file mode 100644 index 000000000..3eb5f107e --- /dev/null +++ b/samples/grove/light/src/main.c @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2016 Intel Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include <zephyr.h> +#include <init.h> +#include <misc/printk.h> +#include <stdio.h> +#include <sensor.h> + +void main(void) +{ + struct device *dev = device_get_binding("GROVE_LIGHT_SENSOR"); + + if (dev == NULL) { + printk("device not found. aborting test.\n"); + return; + } + while (1) { + struct sensor_value lux; + + sensor_sample_fetch(dev); + sensor_channel_get(dev, SENSOR_CHAN_LIGHT, &lux); + + printf("lux: %f\n", lux.dval); + + task_sleep(sys_clock_ticks_per_sec); + } +} + |