2016-01-26 00:23:04 +08:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2016 Intel Corporation
|
|
|
|
*
|
2017-01-19 09:01:01 +08:00
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
2016-01-26 00:23:04 +08:00
|
|
|
*/
|
|
|
|
|
2018-09-15 01:43:44 +08:00
|
|
|
#ifndef ZEPHYR_DRIVERS_SENSOR_SX9500_SX9500_H_
|
|
|
|
#define ZEPHYR_DRIVERS_SENSOR_SX9500_SX9500_H_
|
2016-01-26 00:23:04 +08:00
|
|
|
|
Introduce new sized integer typedefs
This is a start to move away from the C99 {u}int{8,16,32,64}_t types to
Zephyr defined u{8,16,32,64}_t and s{8,16,32,64}_t. This allows Zephyr
to define the sized types in a consistent manor across all the
architectures we support and not conflict with what various compilers
and libc might do with regards to the C99 types.
We introduce <zephyr/types.h> as part of this and have it include
<stdint.h> for now until we transition all the code away from the C99
types.
We go with u{8,16,32,64}_t and s{8,16,32,64}_t as there are some
existing variables defined u8 & u16 as well as to be consistent with
Zephyr naming conventions.
Jira: ZEP-2051
Change-Id: I451fed0623b029d65866622e478225dfab2c0ca8
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2017-04-19 23:32:08 +08:00
|
|
|
#include <zephyr/types.h>
|
2016-01-26 00:23:04 +08:00
|
|
|
#include <device.h>
|
|
|
|
|
|
|
|
#define SX9500_REG_IRQ_SRC 0x00
|
|
|
|
#define SX9500_REG_STAT 0x01
|
|
|
|
#define SX9500_REG_IRQ_MSK 0x03
|
|
|
|
|
|
|
|
#define SX9500_REG_PROX_CTRL0 0x06
|
|
|
|
#define SX9500_REG_PROX_CTRL1 0x07
|
|
|
|
|
|
|
|
/* These are used both in the IRQ_SRC register, to identify which
|
|
|
|
* interrupt occur, and in the IRQ_MSK register, to enable specific
|
|
|
|
* interrupts.
|
|
|
|
*/
|
|
|
|
#define SX9500_CONV_DONE_IRQ (1 << 3)
|
|
|
|
#define SX9500_NEAR_FAR_IRQ ((1 << 5) | (1 << 6))
|
|
|
|
|
|
|
|
struct sx9500_data {
|
2020-05-01 02:33:38 +08:00
|
|
|
const struct device *i2c_master;
|
2020-05-28 00:26:57 +08:00
|
|
|
uint16_t i2c_slave_addr;
|
|
|
|
uint8_t prox_stat;
|
2016-01-26 00:23:04 +08:00
|
|
|
|
2016-04-06 20:52:53 +08:00
|
|
|
struct gpio_callback gpio_cb;
|
|
|
|
|
2016-11-10 23:05:53 +08:00
|
|
|
#ifdef CONFIG_SX9500_TRIGGER_OWN_THREAD
|
2016-11-10 21:21:34 +08:00
|
|
|
struct k_sem sem;
|
2016-01-26 00:23:04 +08:00
|
|
|
#endif
|
|
|
|
|
2016-11-10 23:05:53 +08:00
|
|
|
#ifdef CONFIG_SX9500_TRIGGER_GLOBAL_THREAD
|
2016-11-10 21:21:34 +08:00
|
|
|
struct k_work work;
|
2016-01-26 00:23:04 +08:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef CONFIG_SX9500_TRIGGER
|
2020-07-09 15:13:48 +08:00
|
|
|
const struct device *dev;
|
2016-01-26 00:23:04 +08:00
|
|
|
struct sensor_trigger trigger_drdy;
|
|
|
|
struct sensor_trigger trigger_near_far;
|
|
|
|
|
|
|
|
sensor_trigger_handler_t handler_drdy;
|
|
|
|
sensor_trigger_handler_t handler_near_far;
|
|
|
|
#endif
|
|
|
|
};
|
|
|
|
|
|
|
|
#ifdef CONFIG_SX9500_TRIGGER
|
2020-05-01 02:33:38 +08:00
|
|
|
int sx9500_setup_interrupt(const struct device *dev);
|
|
|
|
int sx9500_trigger_set(const struct device *dev,
|
2016-01-26 00:23:04 +08:00
|
|
|
const struct sensor_trigger *trig,
|
|
|
|
sensor_trigger_handler_t handler);
|
|
|
|
#else
|
2020-05-01 02:33:38 +08:00
|
|
|
static inline int sx9500_setup_interrupt(const struct device *dev)
|
2016-01-26 00:23:04 +08:00
|
|
|
{
|
2016-03-10 01:01:20 +08:00
|
|
|
return 0;
|
2016-01-26 00:23:04 +08:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2018-09-15 01:43:44 +08:00
|
|
|
#endif /* ZEPHYR_DRIVERS_SENSOR_SX9500_SX9500_H_ */
|