zephyr/drivers/sensor/stts751/stts751.h
Martí Bolívar 7e0eed9235 devicetree: allow access to all nodes
Usually, we want to operate only on "available" device
nodes ("available" means "status is okay and a matching binding is
found"), but that's not true in all cases.

Sometimes we want to operate on special nodes without matching
bindings, such as those describing memory.

To handle the distinction, change various additional devicetree APIs
making it clear that they operate only on available device nodes,
adjusting gen_defines and devicetree.h implementation details
accordingly:

- emit macros for all existing nodes in gen_defines.py, regardless
  of status or matching binding
- rename DT_NUM_INST to DT_NUM_INST_STATUS_OKAY
- rename DT_NODE_HAS_COMPAT to DT_NODE_HAS_COMPAT_STATUS_OKAY
- rename DT_INST_FOREACH to DT_INST_FOREACH_STATUS_OKAY
- rename DT_ANY_INST_ON_BUS to DT_ANY_INST_ON_BUS_STATUS_OKAY
- rewrite DT_HAS_NODE_STATUS_OKAY in terms of a new DT_NODE_HAS_STATUS
- resurrect DT_HAS_NODE in the form of DT_NODE_EXISTS
- remove DT_COMPAT_ON_BUS as a public API
- use the new default_prop_types edtlib parameter

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2020-05-08 19:37:18 -05:00

81 lines
1.7 KiB
C

/* ST Microelectronics STTS751 temperature sensor
*
* Copyright (c) 2019 STMicroelectronics
*
* SPDX-License-Identifier: Apache-2.0
*
* Datasheet:
* https://www.st.com/resource/en/datasheet/stts751.pdf
*/
#ifndef ZEPHYR_DRIVERS_SENSOR_STTS751_STTS751_H_
#define ZEPHYR_DRIVERS_SENSOR_STTS751_STTS751_H_
#include <stdint.h>
#include <drivers/i2c.h>
#include <drivers/gpio.h>
#include <drivers/sensor.h>
#include <zephyr/types.h>
#include <sys/util.h>
#include "stts751_reg.h"
union axis1bit16_t {
s16_t i16bit;
u8_t u8bit[2];
};
struct stts751_config {
char *master_dev_name;
int (*bus_init)(struct device *dev);
#ifdef CONFIG_STTS751_TRIGGER
const char *event_port;
u8_t event_pin;
u8_t int_flags;
#endif
#if DT_ANY_INST_ON_BUS_STATUS_OKAY(i2c)
u16_t i2c_slv_addr;
#endif
};
struct stts751_data {
struct device *bus;
s16_t sample_temp;
stmdev_ctx_t *ctx;
#if DT_ANY_INST_ON_BUS_STATUS_OKAY(i2c)
stmdev_ctx_t ctx_i2c;
#endif
#ifdef CONFIG_STTS751_TRIGGER
struct device *gpio;
u32_t pin;
struct gpio_callback gpio_cb;
struct sensor_trigger data_ready_trigger;
sensor_trigger_handler_t thsld_handler;
#if defined(CONFIG_STTS751_TRIGGER_OWN_THREAD)
K_THREAD_STACK_MEMBER(thread_stack, CONFIG_STTS751_THREAD_STACK_SIZE);
struct k_thread thread;
struct k_sem gpio_sem;
#elif defined(CONFIG_STTS751_TRIGGER_GLOBAL_THREAD)
struct k_work work;
struct device *dev;
#endif
#endif /* CONFIG_STTS751_TRIGGER */
};
int stts751_i2c_init(struct device *dev);
#ifdef CONFIG_STTS751_TRIGGER
int stts751_trigger_set(struct device *dev,
const struct sensor_trigger *trig,
sensor_trigger_handler_t handler);
int stts751_init_interrupt(struct device *dev);
#endif
#endif /* ZEPHYR_DRIVERS_SENSOR_STTS751_STTS751_H_ */