1 /* 2 * Copyright (c) 2017, NXP 3 * 4 * SPDX-License-Identifier: Apache-2.0 5 */ 6 7 #include <zephyr/kernel.h> 8 #include <zephyr/drivers/sensor.h> 9 #include <stdio.h> 10 main(void)11int main(void) 12 { 13 struct sensor_value green; 14 const struct device *const dev = DEVICE_DT_GET_ANY(maxim_max30101); 15 16 if (dev == NULL) { 17 printf("Could not get max30101 device\n"); 18 return 0; 19 } 20 if (!device_is_ready(dev)) { 21 printf("max30101 device %s is not ready\n", dev->name); 22 return 0; 23 } 24 25 while (1) { 26 sensor_sample_fetch(dev); 27 sensor_channel_get(dev, SENSOR_CHAN_GREEN, &green); 28 29 /* Print green LED data*/ 30 printf("GREEN=%d\n", green.val1); 31 32 k_sleep(K_MSEC(20)); 33 } 34 return 0; 35 } 36