/*
 * Copyright (c) 2012-2014 Wind River Systems, Inc.
 *
 * SPDX-License-Identifier: Apache-2.0
 */

#include <zephyr.h>
#include <sys/printk.h>
#include <device.h>
#include <devicetree.h>
#include <drivers/i2c.h>
#include <drivers/sensor.h>
#include <logging/log.h>
#include <stdio.h>

void main(void)
{
	//printk("Hello World! %s\n", CONFIG_BOARD);
	struct sensor_value temp_value;
	int read;
	int ret;
	const struct device *dev = device_get_binding(DT_LABEL(DT_INST(0, ti_lm75)));

	if (dev == NULL) {
		printk("device not found.  aborting test.\n");
		return;
	}
	//lm75_init(dev);

	while(1)
	{
		/*lm75*/
		read = sensor_sample_fetch(dev);
		if (read) {
			printk("sample fetch error\n");
			return;
		}

		ret = sensor_channel_get(dev, SENSOR_CHAN_AMBIENT_TEMP, &temp_value);
		if (ret) {
			printk("Failed to get measurements (%d)\n", ret);
			return;
		}
		printk("temp is %d.%d oC\n", temp_value.val1, temp_value.val2);
		k_sleep(K_MSEC(1000));
	}
}
