samples: Add max30101 sample application
Adds a max30101 sample application that polls sensor data and prints it to the console. Jira: ZEP-720 Change-Id: I50f28eaf9ea2ff5bfbb9fb6922c4006d5c02e739 Signed-off-by: Maureen Helm <maureen.helm@nxp.com>
This commit is contained in:
parent
6b0b545f90
commit
0ab8874fde
11
samples/sensor/max30101/Makefile
Normal file
11
samples/sensor/max30101/Makefile
Normal file
|
@ -0,0 +1,11 @@
|
|||
# Makefile - max30101 sample
|
||||
#
|
||||
# Copyright (c) 2017, NXP
|
||||
#
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
|
||||
BOARD ?= hexiwear_k64
|
||||
CONF_FILE ?= prj.conf
|
||||
|
||||
include $(ZEPHYR_BASE)/Makefile.inc
|
39
samples/sensor/max30101/README.rst
Normal file
39
samples/sensor/max30101/README.rst
Normal file
|
@ -0,0 +1,39 @@
|
|||
.. _max30101:
|
||||
|
||||
MAX30101 Heart Rate Sensor
|
||||
##########################
|
||||
|
||||
Overview
|
||||
********
|
||||
|
||||
A sensor application that demonstrates how to poll data from the max30101 heart
|
||||
rate sensor.
|
||||
|
||||
Building and Running
|
||||
********************
|
||||
|
||||
This project configures the max30101 sensor on the :ref:`hexiwear_k64` board to
|
||||
enable the green LED and measure the reflected light with a photodiode. The raw
|
||||
ADC data prints to the console. Further processing (not included in this
|
||||
sample) is required to extract a heart rate signal from the light measurement.
|
||||
|
||||
.. code-block:: console
|
||||
|
||||
$ cd samples/sensors/max30101
|
||||
$ make BOARD=hexiwear_k64
|
||||
|
||||
Sample Output
|
||||
=============
|
||||
|
||||
.. code-block:: console
|
||||
|
||||
GREEN=5731
|
||||
GREEN=5750
|
||||
GREEN=5748
|
||||
GREEN=5741
|
||||
GREEN=5735
|
||||
GREEN=5737
|
||||
GREEN=5736
|
||||
GREEN=5748
|
||||
|
||||
<repeats endlessly>
|
6
samples/sensor/max30101/prj.conf
Normal file
6
samples/sensor/max30101/prj.conf
Normal file
|
@ -0,0 +1,6 @@
|
|||
CONFIG_STDOUT_CONSOLE=y
|
||||
CONFIG_SYS_LOG=y
|
||||
CONFIG_I2C=y
|
||||
CONFIG_SENSOR=y
|
||||
CONFIG_SYS_LOG_SENSOR_LEVEL=4
|
||||
CONFIG_MAX30101=y
|
8
samples/sensor/max30101/src/Makefile
Normal file
8
samples/sensor/max30101/src/Makefile
Normal file
|
@ -0,0 +1,8 @@
|
|||
# Makefile - max30101 sample
|
||||
#
|
||||
# Copyright (c) 2017, NXP
|
||||
#
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
|
||||
obj-y = main.o
|
30
samples/sensor/max30101/src/main.c
Normal file
30
samples/sensor/max30101/src/main.c
Normal file
|
@ -0,0 +1,30 @@
|
|||
/*
|
||||
* Copyright (c) 2017, NXP
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include <zephyr.h>
|
||||
#include <sensor.h>
|
||||
#include <stdio.h>
|
||||
|
||||
void main(void)
|
||||
{
|
||||
struct sensor_value green;
|
||||
struct device *dev = device_get_binding(CONFIG_MAX30101_NAME);
|
||||
|
||||
if (dev == NULL) {
|
||||
printf("Could not get max30101 device\n");
|
||||
return;
|
||||
}
|
||||
|
||||
while (1) {
|
||||
sensor_sample_fetch(dev);
|
||||
sensor_channel_get(dev, SENSOR_CHAN_GREEN, &green);
|
||||
|
||||
/* Print green LED data*/
|
||||
printf("GREEN=%d\n", green.val1);
|
||||
|
||||
k_sleep(20);
|
||||
}
|
||||
}
|
4
samples/sensor/max30101/testcase.ini
Normal file
4
samples/sensor/max30101/testcase.ini
Normal file
|
@ -0,0 +1,4 @@
|
|||
[test]
|
||||
build_only = true
|
||||
tags = samples sensor
|
||||
platform_whitelist = hexiwear_k64
|
Loading…
Reference in a new issue