drivers: sensor: wsen_pads: remove wsen_pads driver
Remove wsen_pads since the hal update is no longer compatible with this version. Signed-off-by: Wajdi ELMuhtadi <wajdi.elmuhtadi@we-online.com>
This commit is contained in:
parent
449bf8019c
commit
8c0b09ddc3
14 changed files with 0 additions and 658 deletions
|
@ -2,7 +2,6 @@
|
|||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
# zephyr-keep-sorted-start
|
||||
add_subdirectory_ifdef(CONFIG_WSEN_PADS wsen_pads)
|
||||
add_subdirectory_ifdef(CONFIG_WSEN_PDUS wsen_pdus)
|
||||
add_subdirectory_ifdef(CONFIG_WSEN_TIDS wsen_tids)
|
||||
# zephyr-keep-sorted-stop
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
# zephyr-keep-sorted-start
|
||||
source "drivers/sensor/wsen/wsen_pads/Kconfig"
|
||||
source "drivers/sensor/wsen/wsen_pdus/Kconfig"
|
||||
source "drivers/sensor/wsen/wsen_tids/Kconfig"
|
||||
# zephyr-keep-sorted-stop
|
||||
|
|
|
@ -1,7 +0,0 @@
|
|||
# Copyright (c) 2023 Würth Elektronik eiSos GmbH & Co. KG
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
zephyr_library()
|
||||
|
||||
zephyr_library_sources(wsen_pads.c)
|
||||
zephyr_library_sources_ifdef(CONFIG_WSEN_PADS_TRIGGER wsen_pads_trigger.c)
|
|
@ -1,55 +0,0 @@
|
|||
# Copyright (c) 2023 Würth Elektronik eiSos GmbH & Co. KG
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
menuconfig WSEN_PADS
|
||||
bool "WSEN-PADS absolute pressure and temperature sensor"
|
||||
default y
|
||||
depends on DT_HAS_WE_WSEN_PADS_ENABLED
|
||||
select I2C if $(dt_compat_on_bus,$(DT_COMPAT_WE_WSEN_PADS),i2c)
|
||||
select SPI if $(dt_compat_on_bus,$(DT_COMPAT_WE_WSEN_PADS),spi)
|
||||
select HAS_WESENSORS
|
||||
help
|
||||
Enable driver for the WSEN-PADS I2C/SPI-based absolute pressure sensor with integrated
|
||||
temperature sensor.
|
||||
|
||||
if WSEN_PADS
|
||||
|
||||
choice WSEN_PADS_TRIGGER_MODE
|
||||
prompt "Trigger mode"
|
||||
default WSEN_PADS_TRIGGER_NONE
|
||||
help
|
||||
Specify the type of triggering to be used by the driver.
|
||||
|
||||
config WSEN_PADS_TRIGGER_NONE
|
||||
bool "No trigger"
|
||||
|
||||
config WSEN_PADS_TRIGGER_GLOBAL_THREAD
|
||||
bool "Use global thread"
|
||||
depends on GPIO
|
||||
select WSEN_PADS_TRIGGER
|
||||
|
||||
config WSEN_PADS_TRIGGER_OWN_THREAD
|
||||
bool "Use own thread"
|
||||
depends on GPIO
|
||||
select WSEN_PADS_TRIGGER
|
||||
|
||||
endchoice # WSEN_PADS_TRIGGER_MODE
|
||||
|
||||
config WSEN_PADS_TRIGGER
|
||||
bool
|
||||
|
||||
config WSEN_PADS_THREAD_PRIORITY
|
||||
int "Thread priority"
|
||||
depends on WSEN_PADS_TRIGGER_OWN_THREAD
|
||||
default 10
|
||||
help
|
||||
Priority of thread used by the driver to handle interrupts.
|
||||
|
||||
config WSEN_PADS_THREAD_STACK_SIZE
|
||||
int "Thread stack size"
|
||||
depends on WSEN_PADS_TRIGGER_OWN_THREAD
|
||||
default 1024
|
||||
help
|
||||
Stack size of thread used by the driver to handle interrupts.
|
||||
|
||||
endif # WSEN_PADS
|
|
@ -1,273 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2023 Würth Elektronik eiSos GmbH & Co. KG
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#define DT_DRV_COMPAT we_wsen_pads
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include <zephyr/sys/__assert.h>
|
||||
#include <zephyr/sys/byteorder.h>
|
||||
#include <zephyr/logging/log.h>
|
||||
|
||||
#include "wsen_pads.h"
|
||||
|
||||
LOG_MODULE_REGISTER(WSEN_PADS, CONFIG_SENSOR_LOG_LEVEL);
|
||||
|
||||
/*
|
||||
* List of supported output data rates. Index into this list is used as
|
||||
* argument for PADS_setOutputDataRate()
|
||||
*/
|
||||
static const int32_t pads_odr_list[] = {
|
||||
0, 1, 10, 25, 50, 75, 100, 200,
|
||||
};
|
||||
|
||||
static int pads_sample_fetch(const struct device *dev, enum sensor_channel channel)
|
||||
{
|
||||
struct pads_data *data = dev->data;
|
||||
|
||||
__ASSERT_NO_MSG(channel == SENSOR_CHAN_ALL);
|
||||
|
||||
if (PADS_getPressure_int(&data->sensor_interface, &data->pressure) != WE_SUCCESS) {
|
||||
LOG_ERR("Failed to fetch %s sample.", "pressure");
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
if (PADS_getTemperature_int(&data->sensor_interface, &data->temperature) != WE_SUCCESS) {
|
||||
LOG_ERR("Failed to fetch %s sample.", "temperature");
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int pads_channel_get(const struct device *dev, enum sensor_channel channel,
|
||||
struct sensor_value *value)
|
||||
{
|
||||
struct pads_data *data = dev->data;
|
||||
int32_t value_converted;
|
||||
|
||||
if (channel == SENSOR_CHAN_AMBIENT_TEMP) {
|
||||
value_converted = (int32_t)data->temperature;
|
||||
|
||||
/* Convert temperature from 0.01 degrees Celsius to degrees Celsius */
|
||||
value->val1 = value_converted / 100;
|
||||
value->val2 = (value_converted % 100) * (1000000 / 100);
|
||||
} else if (channel == SENSOR_CHAN_PRESS) {
|
||||
value_converted = (int32_t)data->pressure;
|
||||
|
||||
/* Convert pressure from Pa to kPa */
|
||||
value->val1 = value_converted / 1000;
|
||||
value->val2 = (value_converted % 1000) * (1000000 / 1000);
|
||||
} else {
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Set output data rate. See pads_odr_list for allowed values. */
|
||||
static int pads_odr_set(const struct device *dev, const struct sensor_value *odr)
|
||||
{
|
||||
struct pads_data *data = dev->data;
|
||||
int odr_index;
|
||||
|
||||
for (odr_index = 0; odr_index < ARRAY_SIZE(pads_odr_list); odr_index++) {
|
||||
if (odr->val1 == pads_odr_list[odr_index] && odr->val2 == 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (odr_index == ARRAY_SIZE(pads_odr_list)) {
|
||||
/* ODR not allowed (was not found in pads_odr_list) */
|
||||
LOG_ERR("Bad sampling frequency %d.%d", odr->val1, odr->val2);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (PADS_setOutputDataRate(&data->sensor_interface, (PADS_outputDataRate_t)odr_index) !=
|
||||
WE_SUCCESS) {
|
||||
LOG_ERR("Failed to set output data rate");
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int pads_attr_set(const struct device *dev, enum sensor_channel chan,
|
||||
enum sensor_attribute attr, const struct sensor_value *val)
|
||||
{
|
||||
if (chan != SENSOR_CHAN_ALL) {
|
||||
LOG_WRN("attr_set() is not supported on channel %d.", chan);
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
if (attr == SENSOR_ATTR_SAMPLING_FREQUENCY) {
|
||||
return pads_odr_set(dev, val);
|
||||
} else {
|
||||
return -ENOTSUP;
|
||||
}
|
||||
}
|
||||
|
||||
static const struct sensor_driver_api pads_driver_api = {
|
||||
.attr_set = pads_attr_set,
|
||||
#if CONFIG_WSEN_PADS_TRIGGER
|
||||
.trigger_set = pads_trigger_set,
|
||||
#endif
|
||||
.sample_fetch = pads_sample_fetch,
|
||||
.channel_get = pads_channel_get,
|
||||
};
|
||||
|
||||
static int pads_init(const struct device *dev)
|
||||
{
|
||||
const struct pads_config *config = dev->config;
|
||||
struct pads_data *data = dev->data;
|
||||
struct sensor_value odr;
|
||||
int status;
|
||||
uint8_t device_id;
|
||||
|
||||
/* Initialize WE sensor interface */
|
||||
WE_sensorInterfaceType_t interface_type = data->sensor_interface.interfaceType;
|
||||
|
||||
PADS_getDefaultInterface(&data->sensor_interface);
|
||||
data->sensor_interface.interfaceType = interface_type;
|
||||
|
||||
switch (data->sensor_interface.interfaceType) {
|
||||
#if DT_ANY_INST_ON_BUS_STATUS_OKAY(i2c)
|
||||
case WE_i2c:
|
||||
data->sensor_interface.handle = (void *)&config->bus_cfg.i2c;
|
||||
break;
|
||||
#endif
|
||||
#if DT_ANY_INST_ON_BUS_STATUS_OKAY(spi)
|
||||
case WE_spi:
|
||||
data->sensor_interface.handle = (void *)&config->bus_cfg.spi;
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
LOG_ERR("Invalid interface type");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
/* First communication test - check device ID */
|
||||
if (PADS_getDeviceID(&data->sensor_interface, &device_id) != WE_SUCCESS) {
|
||||
LOG_ERR("Failed to read device ID.");
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
if (device_id != PADS_DEVICE_ID_VALUE) {
|
||||
LOG_ERR("Invalid device ID 0x%x.", device_id);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
/* Reset sensor */
|
||||
PADS_softReset(&data->sensor_interface, PADS_enable);
|
||||
|
||||
k_sleep(K_USEC(50));
|
||||
|
||||
PADS_state_t swReset;
|
||||
|
||||
do {
|
||||
if (PADS_getSoftResetState(&data->sensor_interface, &swReset) != WE_SUCCESS) {
|
||||
LOG_ERR("Failed to get sensor reset state.");
|
||||
return -EIO;
|
||||
}
|
||||
} while (PADS_enable == swReset);
|
||||
|
||||
if (PADS_enableBlockDataUpdate(&data->sensor_interface, PADS_enable) != WE_SUCCESS) {
|
||||
LOG_ERR("Failed to enable block data update.");
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
#if CONFIG_WSEN_PADS_TRIGGER
|
||||
status = pads_init_interrupt(dev);
|
||||
if (status < 0) {
|
||||
LOG_ERR("Failed to initialize data-ready interrupt.");
|
||||
return status;
|
||||
}
|
||||
#endif
|
||||
|
||||
odr.val1 = pads_odr_list[config->odr];
|
||||
odr.val2 = 0;
|
||||
status = pads_odr_set(dev, &odr);
|
||||
if (status < 0) {
|
||||
LOG_ERR("Failed to set output data rate.");
|
||||
return status;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if DT_NUM_INST_STATUS_OKAY(DT_DRV_COMPAT) == 0
|
||||
#warning "PADS driver enabled without any devices"
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Device creation macros
|
||||
*/
|
||||
|
||||
#define PADS_DEVICE_INIT(inst) \
|
||||
SENSOR_DEVICE_DT_INST_DEFINE(inst, \
|
||||
pads_init, \
|
||||
NULL, \
|
||||
&pads_data_##inst, \
|
||||
&pads_config_##inst, \
|
||||
POST_KERNEL, \
|
||||
CONFIG_SENSOR_INIT_PRIORITY, \
|
||||
&pads_driver_api);
|
||||
|
||||
#ifdef CONFIG_WSEN_PADS_TRIGGER
|
||||
#define PADS_CFG_IRQ(inst) .gpio_drdy = GPIO_DT_SPEC_INST_GET(inst, drdy_gpios)
|
||||
#else
|
||||
#define PADS_CFG_IRQ(inst)
|
||||
#endif /* CONFIG_WSEN_PADS_TRIGGER */
|
||||
|
||||
#define PADS_CONFIG_COMMON(inst) \
|
||||
.odr = (PADS_outputDataRate_t)(DT_INST_ENUM_IDX(inst, odr)), \
|
||||
COND_CODE_1(DT_INST_NODE_HAS_PROP(inst, drdy_gpios), \
|
||||
(PADS_CFG_IRQ(inst)), ())
|
||||
|
||||
/*
|
||||
* Instantiation macros used when device is on SPI bus.
|
||||
*/
|
||||
|
||||
#define PADS_SPI_OPERATION (SPI_WORD_SET(8) | SPI_OP_MODE_MASTER | SPI_MODE_CPOL | SPI_MODE_CPHA)
|
||||
|
||||
#define PADS_CONFIG_SPI(inst) \
|
||||
{ \
|
||||
.bus_cfg = { \
|
||||
.spi = SPI_DT_SPEC_INST_GET(inst, \
|
||||
PADS_SPI_OPERATION, \
|
||||
0), \
|
||||
}, \
|
||||
PADS_CONFIG_COMMON(inst) \
|
||||
}
|
||||
|
||||
/*
|
||||
* Instantiation macros used when device is on I2C bus.
|
||||
*/
|
||||
|
||||
#define PADS_CONFIG_I2C(inst) \
|
||||
{ \
|
||||
.bus_cfg = { \
|
||||
.i2c = I2C_DT_SPEC_INST_GET(inst), \
|
||||
}, \
|
||||
PADS_CONFIG_COMMON(inst) \
|
||||
}
|
||||
|
||||
/*
|
||||
* Main instantiation macro. Use of COND_CODE_1() selects the right
|
||||
* bus-specific macro at preprocessor time.
|
||||
*/
|
||||
#define PADS_DEFINE(inst) \
|
||||
static struct pads_data pads_data_##inst = \
|
||||
COND_CODE_1(DT_INST_ON_BUS(inst, i2c), \
|
||||
({ .sensor_interface = { .interfaceType = WE_i2c } }), ()) \
|
||||
COND_CODE_1(DT_INST_ON_BUS(inst, spi), \
|
||||
({ .sensor_interface = { .interfaceType = WE_spi } }), ()); \
|
||||
static const struct pads_config pads_config_##inst = \
|
||||
COND_CODE_1(DT_INST_ON_BUS(inst, i2c), (PADS_CONFIG_I2C(inst)), ()) \
|
||||
COND_CODE_1(DT_INST_ON_BUS(inst, spi), (PADS_CONFIG_SPI(inst)), ()); \
|
||||
PADS_DEVICE_INIT(inst)
|
||||
|
||||
DT_INST_FOREACH_STATUS_OKAY(PADS_DEFINE)
|
|
@ -1,82 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2023 Würth Elektronik eiSos GmbH & Co. KG
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#ifndef ZEPHYR_DRIVERS_SENSOR_WSEN_PADS_WSEN_PADS_H_
|
||||
#define ZEPHYR_DRIVERS_SENSOR_WSEN_PADS_WSEN_PADS_H_
|
||||
|
||||
#include <zephyr/drivers/gpio.h>
|
||||
#include <zephyr/drivers/sensor.h>
|
||||
|
||||
#include <weplatform.h>
|
||||
|
||||
#include "WSEN_PADS_2511020213301.h"
|
||||
|
||||
#if DT_ANY_INST_ON_BUS_STATUS_OKAY(spi)
|
||||
#include <zephyr/drivers/spi.h>
|
||||
#endif /* DT_ANY_INST_ON_BUS_STATUS_OKAY(spi) */
|
||||
|
||||
#if DT_ANY_INST_ON_BUS_STATUS_OKAY(i2c)
|
||||
#include <zephyr/drivers/i2c.h>
|
||||
#endif /* DT_ANY_INST_ON_BUS_STATUS_OKAY(i2c) */
|
||||
|
||||
struct pads_data {
|
||||
/* WE sensor interface configuration */
|
||||
WE_sensorInterface_t sensor_interface;
|
||||
|
||||
/* Last pressure sample */
|
||||
int32_t pressure;
|
||||
|
||||
/* Last temperature sample */
|
||||
int16_t temperature;
|
||||
|
||||
#ifdef CONFIG_WSEN_PADS_TRIGGER
|
||||
const struct device *dev;
|
||||
|
||||
struct gpio_callback data_ready_cb;
|
||||
|
||||
const struct sensor_trigger *data_ready_triggerP;
|
||||
sensor_trigger_handler_t data_ready_handler;
|
||||
|
||||
#if defined(CONFIG_WSEN_PADS_TRIGGER_OWN_THREAD)
|
||||
K_KERNEL_STACK_MEMBER(thread_stack, CONFIG_WSEN_PADS_THREAD_STACK_SIZE);
|
||||
struct k_thread thread;
|
||||
struct k_sem drdy_sem;
|
||||
#elif defined(CONFIG_WSEN_PADS_TRIGGER_GLOBAL_THREAD)
|
||||
struct k_work work;
|
||||
#endif
|
||||
#endif /* CONFIG_WSEN_PADS_TRIGGER */
|
||||
};
|
||||
|
||||
struct pads_config {
|
||||
union {
|
||||
#if DT_ANY_INST_ON_BUS_STATUS_OKAY(i2c)
|
||||
const struct i2c_dt_spec i2c;
|
||||
#endif
|
||||
#if DT_ANY_INST_ON_BUS_STATUS_OKAY(spi)
|
||||
const struct spi_dt_spec spi;
|
||||
#endif
|
||||
} bus_cfg;
|
||||
|
||||
/* Output data rate */
|
||||
const PADS_outputDataRate_t odr;
|
||||
|
||||
#ifdef CONFIG_WSEN_PADS_TRIGGER
|
||||
/* Interrupt pin used for data-ready */
|
||||
const struct gpio_dt_spec gpio_drdy;
|
||||
#endif /* CONFIG_WSEN_PADS_TRIGGER */
|
||||
};
|
||||
|
||||
#ifdef CONFIG_WSEN_PADS_TRIGGER
|
||||
int pads_trigger_set(const struct device *dev, const struct sensor_trigger *trig,
|
||||
sensor_trigger_handler_t handler);
|
||||
|
||||
int pads_init_interrupt(const struct device *dev);
|
||||
#endif /* CONFIG_WSEN_PADS_TRIGGER */
|
||||
|
||||
int pads_spi_init(const struct device *dev);
|
||||
int pads_i2c_init(const struct device *dev);
|
||||
|
||||
#endif /* ZEPHYR_DRIVERS_SENSOR_WSEN_PADS_WSEN_PADS_H_ */
|
|
@ -1,183 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2023 Würth Elektronik eiSos GmbH & Co. KG
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#define DT_DRV_COMPAT we_wsen_pads
|
||||
|
||||
#include <zephyr/logging/log.h>
|
||||
|
||||
#include "wsen_pads.h"
|
||||
|
||||
LOG_MODULE_DECLARE(WSEN_PADS, CONFIG_SENSOR_LOG_LEVEL);
|
||||
|
||||
/* Enable/disable data-ready interrupt handling */
|
||||
static inline int pads_setup_drdy_interrupt(const struct device *dev, bool enable)
|
||||
{
|
||||
const struct pads_config *cfg = dev->config;
|
||||
unsigned int flags = enable ? GPIO_INT_EDGE_TO_ACTIVE : GPIO_INT_DISABLE;
|
||||
|
||||
return gpio_pin_interrupt_configure_dt(&cfg->gpio_drdy, flags);
|
||||
}
|
||||
|
||||
/*
|
||||
* Is called when a data-ready interrupt has occurred. Triggers
|
||||
* asynchronous processing of the interrupt in pads_process_drdy_interrupt().
|
||||
*/
|
||||
static inline void pads_handle_drdy_interrupt(const struct device *dev)
|
||||
{
|
||||
struct pads_data *data = dev->data;
|
||||
|
||||
/* Disable interrupt handling until the interrupt has been processed */
|
||||
pads_setup_drdy_interrupt(dev, false);
|
||||
|
||||
#if defined(CONFIG_WSEN_PADS_TRIGGER_OWN_THREAD)
|
||||
k_sem_give(&data->drdy_sem);
|
||||
#elif defined(CONFIG_WSEN_PADS_TRIGGER_GLOBAL_THREAD)
|
||||
k_work_submit(&data->work);
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Calls data-ready trigger handler (if any) */
|
||||
static void pads_process_drdy_interrupt(const struct device *dev)
|
||||
{
|
||||
struct pads_data *data = dev->data;
|
||||
|
||||
if (data->data_ready_handler != NULL) {
|
||||
data->data_ready_handler(dev, data->data_ready_triggerP);
|
||||
pads_setup_drdy_interrupt(dev, true);
|
||||
}
|
||||
}
|
||||
|
||||
int pads_trigger_set(const struct device *dev, const struct sensor_trigger *trig,
|
||||
sensor_trigger_handler_t handler)
|
||||
{
|
||||
struct pads_data *data = dev->data;
|
||||
const struct pads_config *cfg = dev->config;
|
||||
int32_t pressure_dummy;
|
||||
|
||||
if (trig->type != SENSOR_TRIG_DATA_READY) {
|
||||
LOG_ERR("Unsupported sensor trigger");
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
pads_setup_drdy_interrupt(dev, false);
|
||||
|
||||
data->data_ready_handler = handler;
|
||||
if (handler == NULL) {
|
||||
/* Disable data-ready interrupt */
|
||||
if (PADS_enableDataReadyInterrupt(&data->sensor_interface, PADS_disable) !=
|
||||
WE_SUCCESS) {
|
||||
LOG_ERR("Failed to disable data-ready interrupt.");
|
||||
return -EIO;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
data->data_ready_triggerP = trig;
|
||||
|
||||
pads_setup_drdy_interrupt(dev, true);
|
||||
|
||||
/* Read pressure to retrigger interrupt */
|
||||
if (PADS_getPressure_int(&data->sensor_interface, &pressure_dummy) != WE_SUCCESS) {
|
||||
LOG_ERR("Failed to read sample");
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
/* Enable data-ready interrupt */
|
||||
if (PADS_enableDataReadyInterrupt(&data->sensor_interface, PADS_enable) != WE_SUCCESS) {
|
||||
LOG_ERR("Failed to enable data-ready interrupt.");
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
/*
|
||||
* If data-ready is active we probably won't get the rising edge, so
|
||||
* invoke the handler manually.
|
||||
*/
|
||||
if (gpio_pin_get_dt(&cfg->gpio_drdy) > 0) {
|
||||
pads_handle_drdy_interrupt(dev);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void pads_drdy_callback(const struct device *dev, struct gpio_callback *cb, uint32_t pins)
|
||||
{
|
||||
struct pads_data *data = CONTAINER_OF(cb, struct pads_data, data_ready_cb);
|
||||
|
||||
ARG_UNUSED(pins);
|
||||
|
||||
pads_handle_drdy_interrupt(data->dev);
|
||||
}
|
||||
|
||||
#ifdef CONFIG_WSEN_PADS_TRIGGER_OWN_THREAD
|
||||
static void pads_thread(void *p1, void *p2, void *p3)
|
||||
{
|
||||
ARG_UNUSED(p2);
|
||||
ARG_UNUSED(p3);
|
||||
|
||||
struct pads_data *data = p1;
|
||||
|
||||
while (true) {
|
||||
k_sem_take(&data->drdy_sem, K_FOREVER);
|
||||
pads_process_drdy_interrupt(data->dev);
|
||||
}
|
||||
}
|
||||
#endif /* CONFIG_WSEN_PADS_TRIGGER_OWN_THREAD */
|
||||
|
||||
#ifdef CONFIG_WSEN_PADS_TRIGGER_GLOBAL_THREAD
|
||||
static void pads_work_cb(struct k_work *work)
|
||||
{
|
||||
struct pads_data *data = CONTAINER_OF(work, struct pads_data, work);
|
||||
|
||||
pads_process_drdy_interrupt(data->dev);
|
||||
}
|
||||
#endif /* CONFIG_WSEN_PADS_TRIGGER_GLOBAL_THREAD */
|
||||
|
||||
int pads_init_interrupt(const struct device *dev)
|
||||
{
|
||||
struct pads_data *data = dev->data;
|
||||
const struct pads_config *cfg = dev->config;
|
||||
int status;
|
||||
|
||||
data->dev = dev;
|
||||
|
||||
if (cfg->gpio_drdy.port == NULL) {
|
||||
LOG_ERR("drdy-gpios is not defined in the device tree.");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (!gpio_is_ready_dt(&cfg->gpio_drdy)) {
|
||||
LOG_ERR("Device %s is not ready", cfg->gpio_drdy.port->name);
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
/* Setup data-ready gpio interrupt */
|
||||
status = gpio_pin_configure_dt(&cfg->gpio_drdy, GPIO_INPUT);
|
||||
if (status < 0) {
|
||||
LOG_ERR("Failed to configure %s.%02u", cfg->gpio_drdy.port->name,
|
||||
cfg->gpio_drdy.pin);
|
||||
return status;
|
||||
}
|
||||
|
||||
gpio_init_callback(&data->data_ready_cb, pads_drdy_callback, BIT(cfg->gpio_drdy.pin));
|
||||
|
||||
status = gpio_add_callback(cfg->gpio_drdy.port, &data->data_ready_cb);
|
||||
if (status < 0) {
|
||||
LOG_ERR("Failed to set gpio callback.");
|
||||
return status;
|
||||
}
|
||||
|
||||
#if defined(CONFIG_WSEN_PADS_TRIGGER_OWN_THREAD)
|
||||
k_sem_init(&data->drdy_sem, 0, K_SEM_MAX_LIMIT);
|
||||
|
||||
k_thread_create(&data->thread, data->thread_stack, CONFIG_WSEN_PADS_THREAD_STACK_SIZE,
|
||||
pads_thread, data, NULL, NULL,
|
||||
K_PRIO_COOP(CONFIG_WSEN_PADS_THREAD_PRIORITY), 0, K_NO_WAIT);
|
||||
#elif defined(CONFIG_WSEN_PADS_TRIGGER_GLOBAL_THREAD)
|
||||
data->work.handler = pads_work_cb;
|
||||
#endif
|
||||
|
||||
return pads_setup_drdy_interrupt(dev, true);
|
||||
}
|
|
@ -1,28 +0,0 @@
|
|||
# Copyright (c) 2023 Würth Elektronik eiSos GmbH & Co. KG
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
include: sensor-device.yaml
|
||||
|
||||
properties:
|
||||
drdy-gpios:
|
||||
type: phandle-array
|
||||
description: |
|
||||
Data-ready interrupt pin.
|
||||
Interrupt is active high by default.
|
||||
|
||||
odr:
|
||||
type: int
|
||||
required: true
|
||||
enum:
|
||||
- 0
|
||||
- 1
|
||||
- 10
|
||||
- 25
|
||||
- 50
|
||||
- 75
|
||||
- 100
|
||||
- 200
|
||||
description: |
|
||||
Sensor output data rate expressed in samples per second.
|
||||
Data rates supported by the chip are 0 (power down), 1,
|
||||
10, 25, 50, 75, 100 and 200.
|
|
@ -1,9 +0,0 @@
|
|||
# Copyright (c) 2023 Würth Elektronik eiSos GmbH & Co. KG
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
description: |
|
||||
Würth Elektronik WSEN-PADS absolute pressure sensor (I2C bus)
|
||||
|
||||
compatible: "we,wsen-pads"
|
||||
|
||||
include: ["i2c-device.yaml", "we,wsen-pads-common.yaml"]
|
|
@ -1,9 +0,0 @@
|
|||
# Copyright (c) 2023 Würth Elektronik eiSos GmbH & Co. KG
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
description: |
|
||||
Würth Elektronik WSEN-PADS absolute pressure sensor (SPI bus)
|
||||
|
||||
compatible: "we,wsen-pads"
|
||||
|
||||
include: ["spi-device.yaml", "we,wsen-pads-common.yaml"]
|
|
@ -678,13 +678,6 @@ test_i2c_tmd2620: tmd2620@62 {
|
|||
wait-time-factor = <0>;
|
||||
};
|
||||
|
||||
test_i2c_wsen_pads: wsen_pads@63 {
|
||||
compatible = "we,wsen-pads";
|
||||
reg = <0x63>;
|
||||
drdy-gpios = <&test_gpio 0 0>;
|
||||
odr = <1>;
|
||||
};
|
||||
|
||||
test_i2c_s11059: s11059@64 {
|
||||
compatible = "hamamatsu,s11059";
|
||||
reg = <0x64>;
|
||||
|
|
|
@ -64,5 +64,4 @@ CONFIG_TMP007_TRIGGER_GLOBAL_THREAD=y
|
|||
CONFIG_TSL2540_TRIGGER_GLOBAL_THREAD=y
|
||||
CONFIG_TSL2591_TRIGGER_GLOBAL_THREAD=y
|
||||
CONFIG_VCNL4040_TRIGGER_GLOBAL_THREAD=y
|
||||
CONFIG_WSEN_PADS_TRIGGER_GLOBAL_THREAD=y
|
||||
CONFIG_WSEN_TIDS_TRIGGER_GLOBAL_THREAD=y
|
||||
|
|
|
@ -65,5 +65,4 @@ CONFIG_TMP007_TRIGGER_NONE=y
|
|||
CONFIG_TSL2540_TRIGGER_NONE=y
|
||||
CONFIG_TSL2591_TRIGGER_NONE=y
|
||||
CONFIG_VCNL4040_TRIGGER_NONE=y
|
||||
CONFIG_WSEN_PADS_TRIGGER_NONE=y
|
||||
CONFIG_WSEN_TIDS_TRIGGER_NONE=y
|
||||
|
|
|
@ -61,5 +61,4 @@ CONFIG_TMP007_TRIGGER_OWN_THREAD=y
|
|||
CONFIG_TSL2540_TRIGGER_OWN_THREAD=y
|
||||
CONFIG_TSL2591_TRIGGER_OWN_THREAD=y
|
||||
CONFIG_VCNL4040_TRIGGER_OWN_THREAD=y
|
||||
CONFIG_WSEN_PADS_TRIGGER_OWN_THREAD=y
|
||||
CONFIG_WSEN_TIDS_TRIGGER_OWN_THREAD=y
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue