zephyr/drivers/sensor/tmp007/tmp007.h
David B. Kinder ac74d8b652 license: Replace Apache boilerplate with SPDX tag
Replace the existing Apache 2.0 boilerplate header with an SPDX tag
throughout the zephyr code tree. This patch was generated via a
script run over the master branch.

Also updated doc/porting/application.rst that had a dependency on
line numbers in a literal include.

Manually updated subsys/logging/sys_log.c that had a malformed
header in the original file.  Also cleanup several cases that already
had a SPDX tag and we either got a duplicate or missed updating.

Jira: ZEP-1457

Change-Id: I6131a1d4ee0e58f5b938300c2d2fc77d2e69572c
Signed-off-by: David B. Kinder <david.b.kinder@intel.com>
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2017-01-19 03:50:58 +00:00

85 lines
2.1 KiB
C

/*
* Copyright (c) 2016 Intel Corporation
*
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef _SENSOR_TMP007
#define _SENSOR_TMP007
#include <device.h>
#include <gpio.h>
#include <misc/util.h>
#define TMP007_I2C_ADDRESS CONFIG_TMP007_I2C_ADDR
#define TMP007_REG_CONFIG 0x02
#define TMP007_ALERT_EN_BIT BIT(8)
#define TMP007_REG_TOBJ 0x03
#define TMP007_DATA_INVALID_BIT BIT(0)
#define TMP007_REG_STATUS 0x04
#define TMP007_DATA_READY_INT_BIT BIT(14)
#define TMP007_TOBJ_TH_HIGH_INT_BIT BIT(13)
#define TMP007_TOBJ_TH_LOW_INT_BIT BIT(12)
#define TMP007_TOBJ_TH_INT_BITS \
(TMP007_TOBJ_TH_HIGH_INT_BIT | TMP007_TOBJ_TH_LOW_INT_BIT)
#define TMP007_REG_TOBJ_TH_HIGH 0x06
#define TMP007_REG_TOBJ_TH_LOW 0x07
/* scale in micro degrees Celsius */
#define TMP007_TEMP_SCALE 31250
#define TMP007_TEMP_TH_SCALE 500000
struct tmp007_data {
struct device *i2c;
int16_t sample;
#ifdef CONFIG_TMP007_TRIGGER
struct device *gpio;
struct gpio_callback gpio_cb;
sensor_trigger_handler_t drdy_handler;
struct sensor_trigger drdy_trigger;
sensor_trigger_handler_t th_handler;
struct sensor_trigger th_trigger;
#if defined(CONFIG_TMP007_TRIGGER_OWN_THREAD)
char __stack thread_stack[CONFIG_TMP007_THREAD_STACK_SIZE];
struct k_sem gpio_sem;
#elif defined(CONFIG_TMP007_TRIGGER_GLOBAL_THREAD)
struct k_work work;
struct device *dev;
#endif
#endif /* CONFIG_TMP007_TRIGGER */
};
#ifdef CONFIG_TMP007_TRIGGER
int tmp007_reg_read(struct tmp007_data *drv_data, uint8_t reg, uint16_t *val);
int tmp007_reg_write(struct tmp007_data *drv_data, uint8_t reg, uint16_t val);
int tmp007_reg_update(struct tmp007_data *drv_data, uint8_t reg,
uint16_t mask, uint16_t val);
int tmp007_attr_set(struct device *dev,
enum sensor_channel chan,
enum sensor_attribute attr,
const struct sensor_value *val);
int tmp007_trigger_set(struct device *dev,
const struct sensor_trigger *trig,
sensor_trigger_handler_t handler);
int tmp007_init_interrupt(struct device *dev);
#endif
#define SYS_LOG_DOMAIN "TMP007"
#define SYS_LOG_LEVEL CONFIG_SYS_LOG_SENSOR_LEVEL
#include <logging/sys_log.h>
#endif /* _SENSOR_TMP007_ */