drivers: sensors: use unified kernel threads
convert all sensor drivers to use threads and the unified kernel API and remove all legacy APIs. Change-Id: Ica43ea74ecbbf85273f718f182c413a9dcd8abc6 Signed-off-by: Anas Nashif <anas.nashif@intel.com>
This commit is contained in:
parent
8910c228a2
commit
3fe2575f0d
48 changed files with 400 additions and 391 deletions
|
@ -80,7 +80,7 @@ config BMA280_I2C_MASTER_DEV_NAME
|
|||
choice
|
||||
prompt "Trigger mode"
|
||||
depends on BMA280
|
||||
default BMA280_TRIGGER_GLOBAL_FIBER
|
||||
default BMA280_TRIGGER_GLOBAL_THREAD
|
||||
help
|
||||
Specify the type of triggering to be used by the driver.
|
||||
|
||||
|
@ -88,15 +88,15 @@ config BMA280_TRIGGER_NONE
|
|||
bool
|
||||
prompt "No trigger"
|
||||
|
||||
config BMA280_TRIGGER_GLOBAL_FIBER
|
||||
config BMA280_TRIGGER_GLOBAL_THREAD
|
||||
bool
|
||||
prompt "Use global fiber"
|
||||
prompt "Use global thread"
|
||||
depends on GPIO
|
||||
select BMA280_TRIGGER
|
||||
|
||||
config BMA280_TRIGGER_OWN_FIBER
|
||||
config BMA280_TRIGGER_OWN_THREAD
|
||||
bool
|
||||
prompt "Use own fiber"
|
||||
prompt "Use own thread"
|
||||
depends on GPIO
|
||||
select BMA280_TRIGGER
|
||||
|
||||
|
@ -124,21 +124,21 @@ config BMA280_GPIO_PIN_NUM
|
|||
The number of the GPIO on which the interrupt signal from the chip
|
||||
will be received.
|
||||
|
||||
config BMA280_FIBER_PRIORITY
|
||||
config BMA280_THREAD_PRIORITY
|
||||
int
|
||||
prompt "Fiber priority"
|
||||
depends on BMA280 && BMA280_TRIGGER_OWN_FIBER
|
||||
prompt "Thread priority"
|
||||
depends on BMA280 && BMA280_TRIGGER_OWN_THREAD
|
||||
default 10
|
||||
help
|
||||
Priority of fiber used by the driver to handle interrupts.
|
||||
Priority of thread used by the driver to handle interrupts.
|
||||
|
||||
config BMA280_FIBER_STACK_SIZE
|
||||
config BMA280_THREAD_STACK_SIZE
|
||||
int
|
||||
prompt "Fiber stack size"
|
||||
depends on BMA280 && BMA280_TRIGGER_OWN_FIBER
|
||||
prompt "Thread stack size"
|
||||
depends on BMA280 && BMA280_TRIGGER_OWN_THREAD
|
||||
default 1024
|
||||
help
|
||||
Stack size of fiber used by the driver to handle interrupts.
|
||||
Stack size of thread used by the driver to handle interrupts.
|
||||
|
||||
choice
|
||||
prompt "Acceleration measurement range"
|
||||
|
|
|
@ -120,8 +120,8 @@
|
|||
#define BMA280_REG_ACCEL_Y_MSB 0x5
|
||||
#define BMA280_REG_ACCEL_Z_MSB 0x7
|
||||
|
||||
#define BMA280_FIBER_PRIORITY 10
|
||||
#define BMA280_FIBER_STACKSIZE_UNIT 1024
|
||||
#define BMA280_THREAD_PRIORITY 10
|
||||
#define BMA280_THREAD_STACKSIZE_UNIT 1024
|
||||
|
||||
struct bma280_data {
|
||||
struct device *i2c;
|
||||
|
@ -140,10 +140,10 @@ struct bma280_data {
|
|||
struct sensor_trigger any_motion_trigger;
|
||||
sensor_trigger_handler_t any_motion_handler;
|
||||
|
||||
#if defined(CONFIG_BMA280_TRIGGER_OWN_FIBER)
|
||||
char __stack fiber_stack[CONFIG_BMA280_FIBER_STACK_SIZE];
|
||||
#if defined(CONFIG_BMA280_TRIGGER_OWN_THREAD)
|
||||
char __stack thread_stack[CONFIG_BMA280_THREAD_STACK_SIZE];
|
||||
struct k_sem gpio_sem;
|
||||
#elif defined(CONFIG_BMA280_TRIGGER_GLOBAL_FIBER)
|
||||
#elif defined(CONFIG_BMA280_TRIGGER_GLOBAL_THREAD)
|
||||
struct k_work work;
|
||||
struct device *dev;
|
||||
#endif
|
||||
|
|
|
@ -70,14 +70,14 @@ static void bma280_gpio_callback(struct device *dev,
|
|||
|
||||
gpio_pin_disable_callback(dev, CONFIG_BMA280_GPIO_PIN_NUM);
|
||||
|
||||
#if defined(CONFIG_BMA280_TRIGGER_OWN_FIBER)
|
||||
#if defined(CONFIG_BMA280_TRIGGER_OWN_THREAD)
|
||||
k_sem_give(&drv_data->gpio_sem);
|
||||
#elif defined(CONFIG_BMA280_TRIGGER_GLOBAL_FIBER)
|
||||
#elif defined(CONFIG_BMA280_TRIGGER_GLOBAL_THREAD)
|
||||
k_work_submit(&drv_data->work);
|
||||
#endif
|
||||
}
|
||||
|
||||
static void bma280_fiber_cb(void *arg)
|
||||
static void bma280_thread_cb(void *arg)
|
||||
{
|
||||
struct device *dev = arg;
|
||||
struct bma280_data *drv_data = dev->driver_data;
|
||||
|
@ -110,8 +110,8 @@ static void bma280_fiber_cb(void *arg)
|
|||
gpio_pin_enable_callback(drv_data->gpio, CONFIG_BMA280_GPIO_PIN_NUM);
|
||||
}
|
||||
|
||||
#ifdef CONFIG_BMA280_TRIGGER_OWN_FIBER
|
||||
static void bma280_fiber(int dev_ptr, int unused)
|
||||
#ifdef CONFIG_BMA280_TRIGGER_OWN_THREAD
|
||||
static void bma280_thread(int dev_ptr, int unused)
|
||||
{
|
||||
struct device *dev = INT_TO_POINTER(dev_ptr);
|
||||
struct bma280_data *drv_data = dev->driver_data;
|
||||
|
@ -120,18 +120,18 @@ static void bma280_fiber(int dev_ptr, int unused)
|
|||
|
||||
while (1) {
|
||||
k_sem_take(&drv_data->gpio_sem, K_FOREVER);
|
||||
bma280_fiber_cb(dev);
|
||||
bma280_thread_cb(dev);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_BMA280_TRIGGER_GLOBAL_FIBER
|
||||
#ifdef CONFIG_BMA280_TRIGGER_GLOBAL_THREAD
|
||||
static void bma280_work_cb(struct k_work *work)
|
||||
{
|
||||
struct bma280_data *drv_data =
|
||||
CONTAINER_OF(work, struct bma280_data, work);
|
||||
|
||||
bma280_fiber_cb(drv_data->dev);
|
||||
bma280_thread_cb(drv_data->dev);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -261,13 +261,13 @@ int bma280_init_interrupt(struct device *dev)
|
|||
return -EIO;
|
||||
}
|
||||
|
||||
#if defined(CONFIG_BMA280_TRIGGER_OWN_FIBER)
|
||||
#if defined(CONFIG_BMA280_TRIGGER_OWN_THREAD)
|
||||
k_sem_init(&drv_data->gpio_sem, 0, UINT_MAX);
|
||||
|
||||
fiber_start(drv_data->fiber_stack, CONFIG_BMA280_FIBER_STACK_SIZE,
|
||||
(nano_fiber_entry_t)bma280_fiber, POINTER_TO_INT(dev),
|
||||
0, CONFIG_BMA280_FIBER_PRIORITY, 0);
|
||||
#elif defined(CONFIG_BMA280_TRIGGER_GLOBAL_FIBER)
|
||||
k_thread_spawn(drv_data->thread_stack, CONFIG_BMA280_THREAD_STACK_SIZE,
|
||||
(k_thread_entry_t)bma280_thread, POINTER_TO_INT(dev), 0, NULL,
|
||||
K_PRIO_COOP(CONFIG_BMA280_THREAD_PRIORITY), 0, 0);
|
||||
#elif defined(CONFIG_BMA280_TRIGGER_GLOBAL_THREAD)
|
||||
drv_data->work.handler = bma280_work_cb;
|
||||
drv_data->dev = dev;
|
||||
#endif
|
||||
|
|
|
@ -105,12 +105,12 @@ config BMC150_MAGN_TRIGGER
|
|||
help
|
||||
Enable triggers for BMC150 magnetometer
|
||||
|
||||
config BMC150_MAGN_TRIGGER_FIBER_STACK
|
||||
int "Fiber stack size"
|
||||
config BMC150_MAGN_TRIGGER_THREAD_STACK
|
||||
int "Thread stack size"
|
||||
depends on BMC150_MAGN_TRIGGER
|
||||
default 1024
|
||||
help
|
||||
Specify the internal fiber stack size.
|
||||
Specify the internal thread stack size.
|
||||
|
||||
config BMC150_MAGN_TRIGGER_DRDY
|
||||
bool "Enable data ready trigger"
|
||||
|
|
|
@ -127,7 +127,7 @@ struct bmc150_magn_data {
|
|||
struct k_sem sem;
|
||||
|
||||
#if defined(CONFIG_BMC150_MAGN_TRIGGER)
|
||||
char __stack fiber_stack[CONFIG_BMC150_MAGN_TRIGGER_FIBER_STACK];
|
||||
char __stack thread_stack[CONFIG_BMC150_MAGN_TRIGGER_THREAD_STACK];
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_BMC150_MAGN_TRIGGER_DRDY)
|
||||
|
|
|
@ -80,13 +80,15 @@ static void bmc150_magn_gpio_drdy_callback(struct device *dev,
|
|||
k_sem_give(&data->sem);
|
||||
}
|
||||
|
||||
static void bmc150_magn_fiber_main(int arg1, int gpio_pin)
|
||||
static void bmc150_magn_thread_main(void *arg1, void *arg2, void *arg3)
|
||||
{
|
||||
struct device *dev = (struct device *) arg1;
|
||||
struct bmc150_magn_data *data = dev->driver_data;
|
||||
const struct bmc150_magn_config *config = dev->config->config_info;
|
||||
uint8_t reg_val;
|
||||
|
||||
int gpio_pin = config->gpio_drdy_int_pin;
|
||||
|
||||
while (1) {
|
||||
k_sem_take(&data->sem, K_FOREVER);
|
||||
|
||||
|
@ -126,6 +128,7 @@ int bmc150_magn_init_interrupt(struct device *dev)
|
|||
dev->config->config_info;
|
||||
struct bmc150_magn_data *data = dev->driver_data;
|
||||
|
||||
|
||||
#if defined(CONFIG_BMC150_MAGN_TRIGGER_DRDY)
|
||||
if (bmc150_magn_set_drdy_polarity(dev, 0) < 0) {
|
||||
SYS_LOG_DBG("failed to set DR polarity");
|
||||
|
@ -145,10 +148,10 @@ int bmc150_magn_init_interrupt(struct device *dev)
|
|||
|
||||
k_sem_init(&data->sem, 0, UINT_MAX);
|
||||
|
||||
task_fiber_start(data->fiber_stack,
|
||||
CONFIG_BMC150_MAGN_TRIGGER_FIBER_STACK,
|
||||
bmc150_magn_fiber_main, (int) dev,
|
||||
config->gpio_drdy_int_pin, 10, 0);
|
||||
k_thread_spawn(data->thread_stack,
|
||||
CONFIG_BMC150_MAGN_TRIGGER_THREAD_STACK,
|
||||
bmc150_magn_thread_main, dev, NULL, NULL,
|
||||
K_PRIO_COOP(10), 0, 0);
|
||||
|
||||
data->gpio_drdy = device_get_binding(config->gpio_drdy_dev_name);
|
||||
if (!data->gpio_drdy) {
|
||||
|
|
|
@ -47,7 +47,7 @@ endchoice
|
|||
choice
|
||||
prompt "Trigger mode"
|
||||
depends on BMG160
|
||||
default BMG160_TRIGGER_GLOBAL_FIBER
|
||||
default BMG160_TRIGGER_GLOBAL_THREAD
|
||||
help
|
||||
Specify the type of triggering to be used by the driver.
|
||||
|
||||
|
@ -55,12 +55,12 @@ config BMG160_TRIGGER_NONE
|
|||
bool
|
||||
prompt "No trigger"
|
||||
|
||||
config BMG160_TRIGGER_GLOBAL_FIBER
|
||||
bool "Use global fiber"
|
||||
config BMG160_TRIGGER_GLOBAL_THREAD
|
||||
bool "Use global thread"
|
||||
select BMG160_TRIGGER
|
||||
|
||||
config BMG160_TRIGGER_OWN_FIBER
|
||||
bool "Use own fiber"
|
||||
config BMG160_TRIGGER_OWN_THREAD
|
||||
bool "Use own thread"
|
||||
select BMG160_TRIGGER
|
||||
endchoice
|
||||
|
||||
|
@ -68,19 +68,19 @@ config BMG160_TRIGGER
|
|||
bool
|
||||
depends on BMG160
|
||||
|
||||
config BMG160_FIBER_PRIORITY
|
||||
int "Own fiber priority"
|
||||
depends on BMG160 && BMG160_TRIGGER_OWN_FIBER
|
||||
config BMG160_THREAD_PRIORITY
|
||||
int "Own thread priority"
|
||||
depends on BMG160 && BMG160_TRIGGER_OWN_THREAD
|
||||
default 10
|
||||
help
|
||||
The priority of the fiber used for handling interrupts.
|
||||
The priority of the thread used for handling interrupts.
|
||||
|
||||
config BMG160_FIBER_STACK_SIZE
|
||||
int "Own fiber stack size"
|
||||
depends on BMG160 && BMG160_TRIGGER_OWN_FIBER
|
||||
config BMG160_THREAD_STACK_SIZE
|
||||
int "Own thread stack size"
|
||||
depends on BMG160 && BMG160_TRIGGER_OWN_THREAD
|
||||
default 1024
|
||||
help
|
||||
The fiber stack size.
|
||||
The thread stack size.
|
||||
|
||||
config BMG160_GPIO_PORT_NAME
|
||||
string "GPIO controller port name"
|
||||
|
|
|
@ -205,11 +205,11 @@ struct bmg160_device_data {
|
|||
struct device *gpio;
|
||||
struct gpio_callback gpio_cb;
|
||||
#endif
|
||||
#ifdef CONFIG_BMG160_TRIGGER_OWN_FIBER
|
||||
#ifdef CONFIG_BMG160_TRIGGER_OWN_THREAD
|
||||
struct k_sem trig_sem;
|
||||
#endif
|
||||
struct k_sem sem;
|
||||
#ifdef CONFIG_BMG160_TRIGGER_GLOBAL_FIBER
|
||||
#ifdef CONFIG_BMG160_TRIGGER_GLOBAL_THREAD
|
||||
struct k_work work;
|
||||
struct device *dev;
|
||||
#endif
|
||||
|
|
|
@ -31,9 +31,9 @@ static void bmg160_gpio_callback(struct device *port, struct gpio_callback *cb,
|
|||
struct bmg160_device_data *bmg160 =
|
||||
CONTAINER_OF(cb, struct bmg160_device_data, gpio_cb);
|
||||
|
||||
#if defined(CONFIG_BMG160_TRIGGER_OWN_FIBER)
|
||||
#if defined(CONFIG_BMG160_TRIGGER_OWN_THREAD)
|
||||
k_sem_give(&bmg160->trig_sem);
|
||||
#elif defined(CONFIG_BMG160_TRIGGER_GLOBAL_FIBER)
|
||||
#elif defined(CONFIG_BMG160_TRIGGER_GLOBAL_THREAD)
|
||||
k_work_submit(&bmg160->work);
|
||||
#endif
|
||||
}
|
||||
|
@ -177,10 +177,10 @@ static void bmg160_handle_int(void *arg)
|
|||
}
|
||||
}
|
||||
|
||||
#ifdef CONFIG_BMG160_TRIGGER_OWN_FIBER
|
||||
static char __stack bmg160_fiber_stack[CONFIG_BMG160_FIBER_STACK_SIZE];
|
||||
#ifdef CONFIG_BMG160_TRIGGER_OWN_THREAD
|
||||
static char __stack bmg160_thread_stack[CONFIG_BMG160_THREAD_STACK_SIZE];
|
||||
|
||||
static void bmg160_fiber_main(int arg1, int unused)
|
||||
static void bmg160_thread_main(void *arg1, void *arg2, void *arg3)
|
||||
{
|
||||
struct device *dev = (struct device *)arg1;
|
||||
struct bmg160_device_data *bmg160 = dev->driver_data;
|
||||
|
@ -193,7 +193,7 @@ static void bmg160_fiber_main(int arg1, int unused)
|
|||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_BMG160_TRIGGER_GLOBAL_FIBER
|
||||
#ifdef CONFIG_BMG160_TRIGGER_GLOBAL_THREAD
|
||||
static void bmg160_work_cb(struct k_work *work)
|
||||
{
|
||||
struct bmg160_device_data *bmg160 =
|
||||
|
@ -241,11 +241,12 @@ int bmg160_trigger_init(struct device *dev)
|
|||
return -EINVAL;
|
||||
}
|
||||
|
||||
#if defined(CONFIG_BMG160_TRIGGER_OWN_FIBER)
|
||||
#if defined(CONFIG_BMG160_TRIGGER_OWN_THREAD)
|
||||
k_sem_init(&bmg160->trig_sem, 0, UINT_MAX);
|
||||
fiber_start(bmg160_fiber_stack, CONFIG_BMG160_FIBER_STACK_SIZE,
|
||||
bmg160_fiber_main, (int)dev, 0, 10, 0);
|
||||
#elif defined(CONFIG_BMG160_TRIGGER_GLOBAL_FIBER)
|
||||
k_thread_spawn(bmg160_thread_stack, CONFIG_BMG160_THREAD_STACK_SIZE,
|
||||
bmg160_thread_main, dev, NULL, NULL, K_PRIO_COOP(10), 0, 0);
|
||||
|
||||
#elif defined(CONFIG_BMG160_TRIGGER_GLOBAL_THREAD)
|
||||
bmg160->work.handler = bmg160_work_cb;
|
||||
bmg160->dev = dev;
|
||||
#endif
|
||||
|
|
|
@ -37,7 +37,7 @@ config BMI160_SPI_BUS_FREQ
|
|||
choice
|
||||
prompt "Trigger mode"
|
||||
depends on BMI160
|
||||
default BMI160_TRIGGER_GLOBAL_FIBER
|
||||
default BMI160_TRIGGER_GLOBAL_THREAD
|
||||
help
|
||||
Specify the type of triggering to be used by the driver.
|
||||
|
||||
|
@ -45,12 +45,12 @@ config BMI160_TRIGGER_NONE
|
|||
bool
|
||||
prompt "No trigger"
|
||||
|
||||
config BMI160_TRIGGER_GLOBAL_FIBER
|
||||
bool "Use global fiber"
|
||||
config BMI160_TRIGGER_GLOBAL_THREAD
|
||||
bool "Use global thread"
|
||||
select BMI160_TRIGGER
|
||||
|
||||
config BMI160_TRIGGER_OWN_FIBER
|
||||
bool "Use own fiber"
|
||||
config BMI160_TRIGGER_OWN_THREAD
|
||||
bool "Use own thread"
|
||||
select BMI160_TRIGGER
|
||||
endchoice
|
||||
|
||||
|
@ -72,19 +72,19 @@ config BMI160_TRIGGER_SOURCE_GPIO
|
|||
depends on GPIO
|
||||
endchoice
|
||||
|
||||
config BMI160_FIBER_PRIORITY
|
||||
int "Own fiber priority"
|
||||
depends on BMI160 && BMI160_TRIGGER_OWN_FIBER
|
||||
config BMI160_THREAD_PRIORITY
|
||||
int "Own thread priority"
|
||||
depends on BMI160 && BMI160_TRIGGER_OWN_THREAD
|
||||
default 10
|
||||
help
|
||||
The priority of the fiber used for handling interrupts.
|
||||
The priority of the thread used for handling interrupts.
|
||||
|
||||
config BMI160_FIBER_STACK_SIZE
|
||||
int "Own fiber stack size"
|
||||
depends on BMI160 && BMI160_TRIGGER_OWN_FIBER
|
||||
config BMI160_THREAD_STACK_SIZE
|
||||
int "Own thread stack size"
|
||||
depends on BMI160 && BMI160_TRIGGER_OWN_THREAD
|
||||
default 1024
|
||||
help
|
||||
The fiber stack size.
|
||||
The thread stack size.
|
||||
|
||||
config BMI160_GPIO_DEV_NAME
|
||||
string "Gpio device"
|
||||
|
|
|
@ -879,7 +879,7 @@ int bmi160_init(struct device *dev)
|
|||
|
||||
/*
|
||||
* The next command will take around 100ms (contains some necessary busy
|
||||
* waits), but we cannot do it in a separate fiber since we need to
|
||||
* waits), but we cannot do it in a separate thread since we need to
|
||||
* guarantee the BMI is up and running, befoare the app's main() is
|
||||
* called.
|
||||
*/
|
||||
|
|
|
@ -453,11 +453,11 @@ struct bmi160_device_data {
|
|||
union bmi160_sample sample;
|
||||
struct bmi160_scale scale;
|
||||
|
||||
#ifdef CONFIG_BMI160_TRIGGER_OWN_FIBER
|
||||
#ifdef CONFIG_BMI160_TRIGGER_OWN_THREAD
|
||||
struct k_sem sem;
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_BMI160_TRIGGER_GLOBAL_FIBER
|
||||
#ifdef CONFIG_BMI160_TRIGGER_GLOBAL_THREAD
|
||||
struct k_work work;
|
||||
struct device *dev;
|
||||
#endif
|
||||
|
|
|
@ -92,11 +92,13 @@ static void bmi160_handle_interrupts(void *arg)
|
|||
|
||||
}
|
||||
|
||||
#ifdef CONFIG_BMI160_TRIGGER_OWN_FIBER
|
||||
static char __stack bmi160_fiber_stack[CONFIG_BMI160_FIBER_STACK_SIZE];
|
||||
#ifdef CONFIG_BMI160_TRIGGER_OWN_THREAD
|
||||
static char __stack bmi160_thread_stack[CONFIG_BMI160_THREAD_STACK_SIZE];
|
||||
|
||||
static void bmi160_fiber_main(int arg1, int unused)
|
||||
static void bmi160_thread_main(void *arg1, void *unused1, void *unused2)
|
||||
{
|
||||
ARG_UNUSED(unused1);
|
||||
ARG_UNUSED(unused2);
|
||||
struct device *dev = (struct device *)arg1;
|
||||
struct bmi160_device_data *bmi160 = dev->driver_data;
|
||||
|
||||
|
@ -107,7 +109,7 @@ static void bmi160_fiber_main(int arg1, int unused)
|
|||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_BMI160_TRIGGER_GLOBAL_FIBER
|
||||
#ifdef CONFIG_BMI160_TRIGGER_GLOBAL_THREAD
|
||||
static void bmi160_work_handler(struct k_work *work)
|
||||
{
|
||||
struct bmi160_device_data *bmi160 =
|
||||
|
@ -126,9 +128,9 @@ static void bmi160_gpio_callback(struct device *port,
|
|||
struct bmi160_device_data *bmi160 =
|
||||
CONTAINER_OF(cb, struct bmi160_device_data, gpio_cb);
|
||||
|
||||
#if defined(CONFIG_BMI160_TRIGGER_OWN_FIBER)
|
||||
#if defined(CONFIG_BMI160_TRIGGER_OWN_THREAD)
|
||||
k_sem_give(&bmi160->sem);
|
||||
#elif defined(CONFIG_BMI160_TRIGGER_GLOBAL_FIBER)
|
||||
#elif defined(CONFIG_BMI160_TRIGGER_GLOBAL_THREAD)
|
||||
k_work_submit(&bmi160->work);
|
||||
#endif
|
||||
}
|
||||
|
@ -139,9 +141,9 @@ static void bmi160_ipm_callback(void *context, uint32_t id, volatile void *data)
|
|||
{
|
||||
struct bmi160_device_data *bmi160 = context;
|
||||
|
||||
#if defined(CONFIG_BMI160_TRIGGER_OWN_FIBER)
|
||||
#if defined(CONFIG_BMI160_TRIGGER_OWN_THREAD)
|
||||
k_sem_give(&bmi160->sem);
|
||||
#elif defined(CONFIG_BMI160_TRIGGER_GLOBAL_FIBER)
|
||||
#elif defined(CONFIG_BMI160_TRIGGER_GLOBAL_THREAD)
|
||||
k_work_submit(&bmi160->work);
|
||||
#endif
|
||||
}
|
||||
|
@ -320,13 +322,13 @@ int bmi160_trigger_mode_init(struct device *dev)
|
|||
}
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_BMI160_TRIGGER_OWN_FIBER)
|
||||
#if defined(CONFIG_BMI160_TRIGGER_OWN_THREAD)
|
||||
k_sem_init(&bmi160->sem, 0, UINT_MAX);
|
||||
|
||||
fiber_start(bmi160_fiber_stack, CONFIG_BMI160_FIBER_STACK_SIZE,
|
||||
bmi160_fiber_main, (int)dev, 0,
|
||||
CONFIG_BMI160_FIBER_PRIORITY, 0);
|
||||
#elif defined(CONFIG_BMI160_TRIGGER_GLOBAL_FIBER)
|
||||
k_thread_spawn(bmi160_thread_stack, CONFIG_BMI160_THREAD_STACK_SIZE,
|
||||
bmi160_thread_main, dev, NULL, NULL,
|
||||
K_PRIO_COOP(CONFIG_BMI160_THREAD_PRIORITY), 0, 0);
|
||||
#elif defined(CONFIG_BMI160_TRIGGER_GLOBAL_THREAD)
|
||||
bmi160->work.handler = bmi160_work_handler;
|
||||
bmi160->dev = dev;
|
||||
#endif
|
||||
|
|
|
@ -42,7 +42,7 @@ config HMC5883L_I2C_MASTER_DEV_NAME
|
|||
choice
|
||||
prompt "Trigger mode"
|
||||
depends on HMC5883L
|
||||
default HMC5883L_TRIGGER_GLOBAL_FIBER
|
||||
default HMC5883L_TRIGGER_GLOBAL_THREAD
|
||||
help
|
||||
Specify the type of triggering to be used by the driver.
|
||||
|
||||
|
@ -50,15 +50,15 @@ config HMC5883L_TRIGGER_NONE
|
|||
bool
|
||||
prompt "No trigger"
|
||||
|
||||
config HMC5883L_TRIGGER_GLOBAL_FIBER
|
||||
config HMC5883L_TRIGGER_GLOBAL_THREAD
|
||||
bool
|
||||
prompt "Use global fiber"
|
||||
prompt "Use global thread"
|
||||
depends on GPIO
|
||||
select HMC5883L_TRIGGER
|
||||
|
||||
config HMC5883L_TRIGGER_OWN_FIBER
|
||||
config HMC5883L_TRIGGER_OWN_THREAD
|
||||
bool
|
||||
prompt "Use own fiber"
|
||||
prompt "Use own thread"
|
||||
depends on GPIO
|
||||
select HMC5883L_TRIGGER
|
||||
|
||||
|
@ -86,21 +86,21 @@ config HMC5883L_GPIO_PIN_NUM
|
|||
The number of the GPIO on which the interrupt signal from the
|
||||
HMC5883L chip will be received.
|
||||
|
||||
config HMC5883L_FIBER_PRIORITY
|
||||
config HMC5883L_THREAD_PRIORITY
|
||||
int
|
||||
prompt "Fiber priority"
|
||||
depends on HMC5883L && HMC5883L_TRIGGER_OWN_FIBER
|
||||
prompt "Thread priority"
|
||||
depends on HMC5883L && HMC5883L_TRIGGER_OWN_THREAD
|
||||
default 10
|
||||
help
|
||||
Priority of fiber used by the driver to handle interrupts.
|
||||
Priority of thread used by the driver to handle interrupts.
|
||||
|
||||
config HMC5883L_FIBER_STACK_SIZE
|
||||
config HMC5883L_THREAD_STACK_SIZE
|
||||
int
|
||||
prompt "Fiber stack size"
|
||||
depends on HMC5883L && HMC5883L_TRIGGER_OWN_FIBER
|
||||
prompt "Thread stack size"
|
||||
depends on HMC5883L && HMC5883L_TRIGGER_OWN_THREAD
|
||||
default 1024
|
||||
help
|
||||
Stack size of fiber used by the driver to handle interrupts.
|
||||
Stack size of thread used by the driver to handle interrupts.
|
||||
|
||||
config HMC5883L_ODR
|
||||
string
|
||||
|
|
|
@ -70,10 +70,10 @@ struct hmc5883l_data {
|
|||
struct sensor_trigger data_ready_trigger;
|
||||
sensor_trigger_handler_t data_ready_handler;
|
||||
|
||||
#if defined(CONFIG_HMC5883L_TRIGGER_OWN_FIBER)
|
||||
char __stack fiber_stack[CONFIG_HMC5883L_FIBER_STACK_SIZE];
|
||||
#if defined(CONFIG_HMC5883L_TRIGGER_OWN_THREAD)
|
||||
char __stack thread_stack[CONFIG_HMC5883L_THREAD_STACK_SIZE];
|
||||
struct k_sem gpio_sem;
|
||||
#elif defined(CONFIG_HMC5883L_TRIGGER_GLOBAL_FIBER)
|
||||
#elif defined(CONFIG_HMC5883L_TRIGGER_GLOBAL_THREAD)
|
||||
struct k_work work;
|
||||
struct device *dev;
|
||||
#endif
|
||||
|
|
|
@ -55,14 +55,14 @@ static void hmc5883l_gpio_callback(struct device *dev,
|
|||
|
||||
gpio_pin_disable_callback(dev, CONFIG_HMC5883L_GPIO_PIN_NUM);
|
||||
|
||||
#if defined(CONFIG_HMC5883L_TRIGGER_OWN_FIBER)
|
||||
#if defined(CONFIG_HMC5883L_TRIGGER_OWN_THREAD)
|
||||
k_sem_give(&drv_data->gpio_sem);
|
||||
#elif defined(CONFIG_HMC5883L_TRIGGER_GLOBAL_FIBER)
|
||||
#elif defined(CONFIG_HMC5883L_TRIGGER_GLOBAL_THREAD)
|
||||
k_work_submit(&drv_data->work);
|
||||
#endif
|
||||
}
|
||||
|
||||
static void hmc5883l_fiber_cb(void *arg)
|
||||
static void hmc5883l_thread_cb(void *arg)
|
||||
{
|
||||
struct device *dev = arg;
|
||||
struct hmc5883l_data *drv_data = dev->driver_data;
|
||||
|
@ -75,8 +75,8 @@ static void hmc5883l_fiber_cb(void *arg)
|
|||
gpio_pin_enable_callback(drv_data->gpio, CONFIG_HMC5883L_GPIO_PIN_NUM);
|
||||
}
|
||||
|
||||
#ifdef CONFIG_HMC5883L_TRIGGER_OWN_FIBER
|
||||
static void hmc5883l_fiber(int dev_ptr, int unused)
|
||||
#ifdef CONFIG_HMC5883L_TRIGGER_OWN_THREAD
|
||||
static void hmc5883l_thread(int dev_ptr, int unused)
|
||||
{
|
||||
struct device *dev = INT_TO_POINTER(dev_ptr);
|
||||
struct hmc5883l_data *drv_data = dev->driver_data;
|
||||
|
@ -85,18 +85,18 @@ static void hmc5883l_fiber(int dev_ptr, int unused)
|
|||
|
||||
while (1) {
|
||||
k_sem_take(&drv_data->gpio_sem, K_FOREVER);
|
||||
hmc5883l_fiber_cb(dev);
|
||||
hmc5883l_thread_cb(dev);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_HMC5883L_TRIGGER_GLOBAL_FIBER
|
||||
#ifdef CONFIG_HMC5883L_TRIGGER_GLOBAL_THREAD
|
||||
static void hmc5883l_work_cb(struct k_work *work)
|
||||
{
|
||||
struct hmc5883l_data *drv_data =
|
||||
CONTAINER_OF(work, struct hmc5883l_data, work);
|
||||
|
||||
hmc5883l_fiber_cb(drv_data->dev);
|
||||
hmc5883l_thread_cb(drv_data->dev);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -125,13 +125,13 @@ int hmc5883l_init_interrupt(struct device *dev)
|
|||
return -EIO;
|
||||
}
|
||||
|
||||
#if defined(CONFIG_HMC5883L_TRIGGER_OWN_FIBER)
|
||||
#if defined(CONFIG_HMC5883L_TRIGGER_OWN_THREAD)
|
||||
k_sem_init(&drv_data->gpio_sem, 0, UINT_MAX);
|
||||
|
||||
fiber_start(drv_data->fiber_stack, CONFIG_HMC5883L_FIBER_STACK_SIZE,
|
||||
(nano_fiber_entry_t)hmc5883l_fiber, POINTER_TO_INT(dev),
|
||||
0, CONFIG_HMC5883L_FIBER_PRIORITY, 0);
|
||||
#elif defined(CONFIG_HMC5883L_TRIGGER_GLOBAL_FIBER)
|
||||
k_thread_spawn(drv_data->thread_stack, CONFIG_HMC5883L_THREAD_STACK_SIZE,
|
||||
(k_thread_entry_t)hmc5883l_thread, POINTER_TO_INT(dev),
|
||||
0, NULL, K_PRIO_COOP(CONFIG_HMC5883L_THREAD_PRIORITY), 0, 0);
|
||||
#elif defined(CONFIG_HMC5883L_TRIGGER_GLOBAL_THREAD)
|
||||
drv_data->work.handler = hmc5883l_work_cb;
|
||||
drv_data->dev = dev;
|
||||
#endif
|
||||
|
|
|
@ -42,7 +42,7 @@ config HTS221_I2C_MASTER_DEV_NAME
|
|||
choice
|
||||
prompt "Trigger mode"
|
||||
depends on HTS221
|
||||
default HTS221_TRIGGER_GLOBAL_FIBER
|
||||
default HTS221_TRIGGER_GLOBAL_THREAD
|
||||
help
|
||||
Specify the type of triggering to be used by the driver.
|
||||
|
||||
|
@ -50,15 +50,15 @@ config HTS221_TRIGGER_NONE
|
|||
bool
|
||||
prompt "No trigger"
|
||||
|
||||
config HTS221_TRIGGER_GLOBAL_FIBER
|
||||
config HTS221_TRIGGER_GLOBAL_THREAD
|
||||
bool
|
||||
prompt "Use global fiber"
|
||||
prompt "Use global thread"
|
||||
depends on GPIO
|
||||
select HTS221_TRIGGER
|
||||
|
||||
config HTS221_TRIGGER_OWN_FIBER
|
||||
config HTS221_TRIGGER_OWN_THREAD
|
||||
bool
|
||||
prompt "Use own fiber"
|
||||
prompt "Use own thread"
|
||||
depends on GPIO
|
||||
select HTS221_TRIGGER
|
||||
|
||||
|
@ -86,21 +86,21 @@ config HTS221_GPIO_PIN_NUM
|
|||
The number of the GPIO on which the interrupt signal from the HTS221
|
||||
chip will be received.
|
||||
|
||||
config HTS221_FIBER_PRIORITY
|
||||
config HTS221_THREAD_PRIORITY
|
||||
int
|
||||
prompt "Fiber priority"
|
||||
depends on HTS221 && HTS221_TRIGGER_OWN_FIBER
|
||||
prompt "Thread priority"
|
||||
depends on HTS221 && HTS221_TRIGGER_OWN_THREAD
|
||||
default 10
|
||||
help
|
||||
Priority of fiber used by the driver to handle interrupts.
|
||||
Priority of thread used by the driver to handle interrupts.
|
||||
|
||||
config HTS221_FIBER_STACK_SIZE
|
||||
config HTS221_THREAD_STACK_SIZE
|
||||
int
|
||||
prompt "Fiber stack size"
|
||||
depends on HTS221 && HTS221_TRIGGER_OWN_FIBER
|
||||
prompt "Thread stack size"
|
||||
depends on HTS221 && HTS221_TRIGGER_OWN_THREAD
|
||||
default 1024
|
||||
help
|
||||
Stack size of fiber used by the driver to handle interrupts.
|
||||
Stack size of thread used by the driver to handle interrupts.
|
||||
|
||||
config HTS221_ODR
|
||||
string
|
||||
|
|
|
@ -68,10 +68,10 @@ struct hts221_data {
|
|||
struct sensor_trigger data_ready_trigger;
|
||||
sensor_trigger_handler_t data_ready_handler;
|
||||
|
||||
#if defined(CONFIG_HTS221_TRIGGER_OWN_FIBER)
|
||||
char __stack fiber_stack[CONFIG_HTS221_FIBER_STACK_SIZE];
|
||||
#if defined(CONFIG_HTS221_TRIGGER_OWN_THREAD)
|
||||
char __stack thread_stack[CONFIG_HTS221_THREAD_STACK_SIZE];
|
||||
struct k_sem gpio_sem;
|
||||
#elif defined(CONFIG_HTS221_TRIGGER_GLOBAL_FIBER)
|
||||
#elif defined(CONFIG_HTS221_TRIGGER_GLOBAL_THREAD)
|
||||
struct k_work work;
|
||||
struct device *dev;
|
||||
#endif
|
||||
|
|
|
@ -55,14 +55,14 @@ static void hts221_gpio_callback(struct device *dev,
|
|||
|
||||
gpio_pin_disable_callback(dev, CONFIG_HTS221_GPIO_PIN_NUM);
|
||||
|
||||
#if defined(CONFIG_HTS221_TRIGGER_OWN_FIBER)
|
||||
#if defined(CONFIG_HTS221_TRIGGER_OWN_THREAD)
|
||||
k_sem_give(&drv_data->gpio_sem);
|
||||
#elif defined(CONFIG_HTS221_TRIGGER_GLOBAL_FIBER)
|
||||
#elif defined(CONFIG_HTS221_TRIGGER_GLOBAL_THREAD)
|
||||
k_work_submit(&drv_data->work);
|
||||
#endif
|
||||
}
|
||||
|
||||
static void hts221_fiber_cb(void *arg)
|
||||
static void hts221_thread_cb(void *arg)
|
||||
{
|
||||
struct device *dev = arg;
|
||||
struct hts221_data *drv_data = dev->driver_data;
|
||||
|
@ -75,8 +75,8 @@ static void hts221_fiber_cb(void *arg)
|
|||
gpio_pin_enable_callback(drv_data->gpio, CONFIG_HTS221_GPIO_PIN_NUM);
|
||||
}
|
||||
|
||||
#ifdef CONFIG_HTS221_TRIGGER_OWN_FIBER
|
||||
static void hts221_fiber(int dev_ptr, int unused)
|
||||
#ifdef CONFIG_HTS221_TRIGGER_OWN_THREAD
|
||||
static void hts221_thread(int dev_ptr, int unused)
|
||||
{
|
||||
struct device *dev = INT_TO_POINTER(dev_ptr);
|
||||
struct hts221_data *drv_data = dev->driver_data;
|
||||
|
@ -85,18 +85,18 @@ static void hts221_fiber(int dev_ptr, int unused)
|
|||
|
||||
while (1) {
|
||||
k_sem_take(&drv_data->gpio_sem, K_FOREVER);
|
||||
hts221_fiber_cb(dev);
|
||||
hts221_thread_cb(dev);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_HTS221_TRIGGER_GLOBAL_FIBER
|
||||
#ifdef CONFIG_HTS221_TRIGGER_GLOBAL_THREAD
|
||||
static void hts221_work_cb(struct k_work *work)
|
||||
{
|
||||
struct hts221_data *drv_data =
|
||||
CONTAINER_OF(work, struct hts221_data, work);
|
||||
|
||||
hts221_fiber_cb(drv_data->dev);
|
||||
hts221_thread_cb(drv_data->dev);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -132,13 +132,13 @@ int hts221_init_interrupt(struct device *dev)
|
|||
return -EIO;
|
||||
}
|
||||
|
||||
#if defined(CONFIG_HTS221_TRIGGER_OWN_FIBER)
|
||||
#if defined(CONFIG_HTS221_TRIGGER_OWN_THREAD)
|
||||
k_sem_init(&drv_data->gpio_sem, 0, UINT_MAX);
|
||||
|
||||
fiber_start(drv_data->fiber_stack, CONFIG_HTS221_FIBER_STACK_SIZE,
|
||||
(nano_fiber_entry_t)hts221_fiber, POINTER_TO_INT(dev),
|
||||
0, CONFIG_HTS221_FIBER_PRIORITY, 0);
|
||||
#elif defined(CONFIG_HTS221_TRIGGER_GLOBAL_FIBER)
|
||||
k_thread_spawn(drv_data->thread_stack, CONFIG_HTS221_THREAD_STACK_SIZE,
|
||||
(k_thread_entry_t)hts221_thread, POINTER_TO_INT(dev),
|
||||
0, NULL, K_PRIO_COOP(CONFIG_HTS221_THREAD_PRIORITY), 0, 0);
|
||||
#elif defined(CONFIG_HTS221_TRIGGER_GLOBAL_THREAD)
|
||||
drv_data->work.handler = hts221_work_cb;
|
||||
drv_data->dev = dev;
|
||||
#endif
|
||||
|
|
|
@ -41,13 +41,13 @@ config ISL29035_I2C_MASTER_DEV_NAME
|
|||
The device name of the I2C master device to which the ISL29035
|
||||
chip is connected.
|
||||
|
||||
config ISL29035_FIBER_PRIORITY
|
||||
config ISL29035_THREAD_PRIORITY
|
||||
int
|
||||
prompt "Fiber priority"
|
||||
prompt "Thread priority"
|
||||
depends on ISL29035
|
||||
default 10
|
||||
help
|
||||
Priority of fiber used to handle the timer and threshold triggers.
|
||||
Priority of thread used to handle the timer and threshold triggers.
|
||||
|
||||
choice
|
||||
prompt "Full scale lux range"
|
||||
|
@ -135,15 +135,15 @@ config ISL29035_TRIGGER_NONE
|
|||
bool
|
||||
prompt "No trigger"
|
||||
|
||||
config ISL29035_TRIGGER_GLOBAL_FIBER
|
||||
config ISL29035_TRIGGER_GLOBAL_THREAD
|
||||
bool
|
||||
prompt "Use global fiber"
|
||||
prompt "Use global thread"
|
||||
depends on GPIO
|
||||
select ISL29035_TRIGGER
|
||||
|
||||
config ISL29035_TRIGGER_OWN_FIBER
|
||||
config ISL29035_TRIGGER_OWN_THREAD
|
||||
bool
|
||||
prompt "Use own fiber"
|
||||
prompt "Use own thread"
|
||||
depends on GPIO
|
||||
select ISL29035_TRIGGER
|
||||
|
||||
|
@ -171,21 +171,21 @@ config ISL29035_GPIO_PIN_NUM
|
|||
The number of the GPIO pin to which the ISL29035 interrupt pin is
|
||||
connected.
|
||||
|
||||
config ISL29035_FIBER_PRIORITY
|
||||
config ISL29035_THREAD_PRIORITY
|
||||
int
|
||||
prompt "Fiber priority"
|
||||
depends on ISL29035 && ISL29035_TRIGGER_OWN_FIBER
|
||||
prompt "Thread priority"
|
||||
depends on ISL29035 && ISL29035_TRIGGER_OWN_THREAD
|
||||
default 10
|
||||
help
|
||||
Priority of fiber used by the driver to handle interrupts.
|
||||
Priority of thread used by the driver to handle interrupts.
|
||||
|
||||
config ISL29035_FIBER_STACK_SIZE
|
||||
config ISL29035_THREAD_STACK_SIZE
|
||||
int
|
||||
prompt "Fiber stack size"
|
||||
depends on ISL29035 && ISL29035_TRIGGER_OWN_FIBER
|
||||
prompt "Thread stack size"
|
||||
depends on ISL29035 && ISL29035_TRIGGER_OWN_THREAD
|
||||
default 1024
|
||||
help
|
||||
Stack size of fiber used by the driver to handle interrupts.
|
||||
Stack size of thread used by the driver to handle interrupts.
|
||||
|
||||
choice
|
||||
prompt "Interrupt persist cycles"
|
||||
|
|
|
@ -131,10 +131,10 @@ struct isl29035_driver_data {
|
|||
struct sensor_trigger th_trigger;
|
||||
sensor_trigger_handler_t th_handler;
|
||||
|
||||
#if defined(CONFIG_ISL29035_TRIGGER_OWN_FIBER)
|
||||
char __stack fiber_stack[CONFIG_ISL29035_FIBER_STACK_SIZE];
|
||||
#if defined(CONFIG_ISL29035_TRIGGER_OWN_THREAD)
|
||||
char __stack thread_stack[CONFIG_ISL29035_THREAD_STACK_SIZE];
|
||||
struct k_sem gpio_sem;
|
||||
#elif defined(CONFIG_ISL29035_TRIGGER_GLOBAL_FIBER)
|
||||
#elif defined(CONFIG_ISL29035_TRIGGER_GLOBAL_THREAD)
|
||||
struct k_work work;
|
||||
struct device *dev;
|
||||
#endif
|
||||
|
|
|
@ -84,14 +84,14 @@ static void isl29035_gpio_callback(struct device *dev,
|
|||
|
||||
gpio_pin_disable_callback(dev, CONFIG_ISL29035_GPIO_PIN_NUM);
|
||||
|
||||
#if defined(CONFIG_ISL29035_TRIGGER_OWN_FIBER)
|
||||
#if defined(CONFIG_ISL29035_TRIGGER_OWN_THREAD)
|
||||
k_sem_give(&drv_data->gpio_sem);
|
||||
#elif defined(CONFIG_ISL29035_TRIGGER_GLOBAL_FIBER)
|
||||
#elif defined(CONFIG_ISL29035_TRIGGER_GLOBAL_THREAD)
|
||||
k_work_submit(&drv_data->work);
|
||||
#endif
|
||||
}
|
||||
|
||||
static void isl29035_fiber_cb(struct device *dev)
|
||||
static void isl29035_thread_cb(struct device *dev)
|
||||
{
|
||||
struct isl29035_driver_data *drv_data = dev->driver_data;
|
||||
uint8_t val;
|
||||
|
@ -107,8 +107,8 @@ static void isl29035_fiber_cb(struct device *dev)
|
|||
gpio_pin_enable_callback(drv_data->gpio, CONFIG_ISL29035_GPIO_PIN_NUM);
|
||||
}
|
||||
|
||||
#ifdef CONFIG_ISL29035_TRIGGER_OWN_FIBER
|
||||
static void isl29035_fiber(int ptr, int unused)
|
||||
#ifdef CONFIG_ISL29035_TRIGGER_OWN_THREAD
|
||||
static void isl29035_thread(int ptr, int unused)
|
||||
{
|
||||
struct device *dev = INT_TO_POINTER(ptr);
|
||||
struct isl29035_driver_data *drv_data = dev->driver_data;
|
||||
|
@ -117,18 +117,18 @@ static void isl29035_fiber(int ptr, int unused)
|
|||
|
||||
while (1) {
|
||||
k_sem_take(&drv_data->gpio_sem, K_FOREVER);
|
||||
isl29035_fiber_cb(dev);
|
||||
isl29035_thread_cb(dev);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_ISL29035_TRIGGER_GLOBAL_FIBER
|
||||
#ifdef CONFIG_ISL29035_TRIGGER_GLOBAL_THREAD
|
||||
static void isl29035_work_cb(struct k_work *work)
|
||||
{
|
||||
struct isl29035_driver_data *drv_data =
|
||||
CONTAINER_OF(work, struct isl29035_driver_data, work);
|
||||
|
||||
isl29035_fiber_cb(drv_data->dev);
|
||||
isl29035_thread_cb(drv_data->dev);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -183,13 +183,13 @@ int isl29035_init_interrupt(struct device *dev)
|
|||
return -EIO;
|
||||
}
|
||||
|
||||
#if defined(CONFIG_ISL29035_TRIGGER_OWN_FIBER)
|
||||
#if defined(CONFIG_ISL29035_TRIGGER_OWN_THREAD)
|
||||
k_sem_init(&drv_data->gpio_sem, 0, UINT_MAX);
|
||||
|
||||
fiber_start(drv_data->fiber_stack, CONFIG_ISL29035_FIBER_STACK_SIZE,
|
||||
(nano_fiber_entry_t)isl29035_fiber, POINTER_TO_INT(dev),
|
||||
0, CONFIG_ISL29035_FIBER_PRIORITY, 0);
|
||||
#elif defined(CONFIG_ISL29035_TRIGGER_GLOBAL_FIBER)
|
||||
k_thread_spawn(drv_data->thread_stack, CONFIG_ISL29035_THREAD_STACK_SIZE,
|
||||
(k_thread_entry_t)isl29035_thread, POINTER_TO_INT(dev),
|
||||
0, NULL, K_PRIO_COOP(CONFIG_ISL29035_THREAD_PRIORITY), 0, 0);
|
||||
#elif defined(CONFIG_ISL29035_TRIGGER_GLOBAL_THREAD)
|
||||
drv_data->work.handler = isl29035_work_cb;
|
||||
drv_data->dev = dev;
|
||||
#endif
|
||||
|
|
|
@ -55,7 +55,7 @@ config LIS3DH_I2C_MASTER_DEV_NAME
|
|||
choice
|
||||
prompt "Trigger mode"
|
||||
depends on LIS3DH
|
||||
default LIS3DH_TRIGGER_GLOBAL_FIBER
|
||||
default LIS3DH_TRIGGER_GLOBAL_THREAD
|
||||
help
|
||||
Specify the type of triggering to be used by the driver.
|
||||
|
||||
|
@ -63,15 +63,15 @@ config LIS3DH_TRIGGER_NONE
|
|||
bool
|
||||
prompt "No trigger"
|
||||
|
||||
config LIS3DH_TRIGGER_GLOBAL_FIBER
|
||||
config LIS3DH_TRIGGER_GLOBAL_THREAD
|
||||
bool
|
||||
prompt "Use global fiber"
|
||||
prompt "Use global thread"
|
||||
depends on GPIO
|
||||
select LIS3DH_TRIGGER
|
||||
|
||||
config LIS3DH_TRIGGER_OWN_FIBER
|
||||
config LIS3DH_TRIGGER_OWN_THREAD
|
||||
bool
|
||||
prompt "Use own fiber"
|
||||
prompt "Use own thread"
|
||||
depends on GPIO
|
||||
select LIS3DH_TRIGGER
|
||||
|
||||
|
@ -99,21 +99,21 @@ config LIS3DH_GPIO_PIN_NUM
|
|||
The number of the GPIO on which the interrupt signal from the LIS3DH
|
||||
chip will be received.
|
||||
|
||||
config LIS3DH_FIBER_PRIORITY
|
||||
config LIS3DH_THREAD_PRIORITY
|
||||
int
|
||||
prompt "Fiber priority"
|
||||
depends on LIS3DH && LIS3DH_TRIGGER_OWN_FIBER
|
||||
prompt "Thread priority"
|
||||
depends on LIS3DH && LIS3DH_TRIGGER_OWN_THREAD
|
||||
default 10
|
||||
help
|
||||
Priority of fiber used by the driver to handle interrupts.
|
||||
Priority of thread used by the driver to handle interrupts.
|
||||
|
||||
config LIS3DH_FIBER_STACK_SIZE
|
||||
config LIS3DH_THREAD_STACK_SIZE
|
||||
int
|
||||
prompt "Fiber stack size"
|
||||
depends on LIS3DH && LIS3DH_TRIGGER_OWN_FIBER
|
||||
prompt "Thread stack size"
|
||||
depends on LIS3DH && LIS3DH_TRIGGER_OWN_THREAD
|
||||
default 1024
|
||||
help
|
||||
Stack size of fiber used by the driver to handle interrupts.
|
||||
Stack size of thread used by the driver to handle interrupts.
|
||||
|
||||
choice
|
||||
prompt "Acceleration measurement range"
|
||||
|
|
|
@ -102,10 +102,10 @@ struct lis3dh_data {
|
|||
struct sensor_trigger data_ready_trigger;
|
||||
sensor_trigger_handler_t data_ready_handler;
|
||||
|
||||
#if defined(CONFIG_LIS3DH_TRIGGER_OWN_FIBER)
|
||||
char __stack fiber_stack[CONFIG_LIS3DH_FIBER_STACK_SIZE];
|
||||
#if defined(CONFIG_LIS3DH_TRIGGER_OWN_THREAD)
|
||||
char __stack thread_stack[CONFIG_LIS3DH_THREAD_STACK_SIZE];
|
||||
struct k_sem gpio_sem;
|
||||
#elif defined(CONFIG_LIS3DH_TRIGGER_GLOBAL_FIBER)
|
||||
#elif defined(CONFIG_LIS3DH_TRIGGER_GLOBAL_THREAD)
|
||||
struct k_work work;
|
||||
struct device *dev;
|
||||
#endif
|
||||
|
|
|
@ -55,14 +55,14 @@ static void lis3dh_gpio_callback(struct device *dev,
|
|||
|
||||
gpio_pin_disable_callback(dev, CONFIG_LIS3DH_GPIO_PIN_NUM);
|
||||
|
||||
#if defined(CONFIG_LIS3DH_TRIGGER_OWN_FIBER)
|
||||
#if defined(CONFIG_LIS3DH_TRIGGER_OWN_THREAD)
|
||||
k_sem_give(&drv_data->gpio_sem);
|
||||
#elif defined(CONFIG_LIS3DH_TRIGGER_GLOBAL_FIBER)
|
||||
#elif defined(CONFIG_LIS3DH_TRIGGER_GLOBAL_THREAD)
|
||||
k_work_submit(&drv_data->work);
|
||||
#endif
|
||||
}
|
||||
|
||||
static void lis3dh_fiber_cb(void *arg)
|
||||
static void lis3dh_thread_cb(void *arg)
|
||||
{
|
||||
struct device *dev = arg;
|
||||
struct lis3dh_data *drv_data = dev->driver_data;
|
||||
|
@ -75,8 +75,8 @@ static void lis3dh_fiber_cb(void *arg)
|
|||
gpio_pin_enable_callback(drv_data->gpio, CONFIG_LIS3DH_GPIO_PIN_NUM);
|
||||
}
|
||||
|
||||
#ifdef CONFIG_LIS3DH_TRIGGER_OWN_FIBER
|
||||
static void lis3dh_fiber(int dev_ptr, int unused)
|
||||
#ifdef CONFIG_LIS3DH_TRIGGER_OWN_THREAD
|
||||
static void lis3dh_thread(int dev_ptr, int unused)
|
||||
{
|
||||
struct device *dev = INT_TO_POINTER(dev_ptr);
|
||||
struct lis3dh_data *drv_data = dev->driver_data;
|
||||
|
@ -85,18 +85,18 @@ static void lis3dh_fiber(int dev_ptr, int unused)
|
|||
|
||||
while (1) {
|
||||
k_sem_take(&drv_data->gpio_sem, K_FOREVER);
|
||||
lis3dh_fiber_cb(dev);
|
||||
lis3dh_thread_cb(dev);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_LIS3DH_TRIGGER_GLOBAL_FIBER
|
||||
#ifdef CONFIG_LIS3DH_TRIGGER_GLOBAL_THREAD
|
||||
static void lis3dh_work_cb(struct k_work *work)
|
||||
{
|
||||
struct lis3dh_data *drv_data =
|
||||
CONTAINER_OF(work, struct lis3dh_data, work);
|
||||
|
||||
lis3dh_fiber_cb(drv_data->dev);
|
||||
lis3dh_thread_cb(drv_data->dev);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -138,13 +138,13 @@ int lis3dh_init_interrupt(struct device *dev)
|
|||
return -EIO;
|
||||
}
|
||||
|
||||
#if defined(CONFIG_LIS3DH_TRIGGER_OWN_FIBER)
|
||||
#if defined(CONFIG_LIS3DH_TRIGGER_OWN_THREAD)
|
||||
k_sem_init(&drv_data->gpio_sem, 0, UINT_MAX);
|
||||
|
||||
fiber_start(drv_data->fiber_stack, CONFIG_LIS3DH_FIBER_STACK_SIZE,
|
||||
(nano_fiber_entry_t)lis3dh_fiber, POINTER_TO_INT(dev),
|
||||
0, CONFIG_LIS3DH_FIBER_PRIORITY, 0);
|
||||
#elif defined(CONFIG_LIS3DH_TRIGGER_GLOBAL_FIBER)
|
||||
k_thread_spawn(drv_data->thread_stack, CONFIG_LIS3DH_THREAD_STACK_SIZE,
|
||||
(k_thread_entry_t)lis3dh_thread, POINTER_TO_INT(dev),
|
||||
0, NULL, K_PRIO_COOP(CONFIG_LIS3DH_THREAD_PRIORITY), 0, 0);
|
||||
#elif defined(CONFIG_LIS3DH_TRIGGER_GLOBAL_THREAD)
|
||||
drv_data->work.handler = lis3dh_work_cb;
|
||||
drv_data->dev = dev;
|
||||
#endif
|
||||
|
|
|
@ -52,7 +52,7 @@ config LIS3MDL_I2C_MASTER_DEV_NAME
|
|||
choice
|
||||
prompt "Trigger mode"
|
||||
depends on LIS3MDL
|
||||
default LIS3MDL_TRIGGER_GLOBAL_FIBER
|
||||
default LIS3MDL_TRIGGER_GLOBAL_THREAD
|
||||
help
|
||||
Specify the type of triggering to be used by the driver.
|
||||
|
||||
|
@ -60,15 +60,15 @@ config LIS3MDL_TRIGGER_NONE
|
|||
bool
|
||||
prompt "No trigger"
|
||||
|
||||
config LIS3MDL_TRIGGER_GLOBAL_FIBER
|
||||
config LIS3MDL_TRIGGER_GLOBAL_THREAD
|
||||
bool
|
||||
prompt "Use global fiber"
|
||||
prompt "Use global thread"
|
||||
depends on GPIO
|
||||
select LIS3MDL_TRIGGER
|
||||
|
||||
config LIS3MDL_TRIGGER_OWN_FIBER
|
||||
config LIS3MDL_TRIGGER_OWN_THREAD
|
||||
bool
|
||||
prompt "Use own fiber"
|
||||
prompt "Use own thread"
|
||||
depends on GPIO
|
||||
select LIS3MDL_TRIGGER
|
||||
|
||||
|
@ -96,21 +96,21 @@ config LIS3MDL_GPIO_PIN_NUM
|
|||
The number of the GPIO on which the interrupt signal from the LIS3MDL
|
||||
chip will be received.
|
||||
|
||||
config LIS3MDL_FIBER_PRIORITY
|
||||
config LIS3MDL_THREAD_PRIORITY
|
||||
int
|
||||
prompt "Fiber priority"
|
||||
depends on LIS3MDL && LIS3MDL_TRIGGER_OWN_FIBER
|
||||
prompt "Thread priority"
|
||||
depends on LIS3MDL && LIS3MDL_TRIGGER_OWN_THREAD
|
||||
default 10
|
||||
help
|
||||
Priority of fiber used by the driver to handle interrupts.
|
||||
Priority of thread used by the driver to handle interrupts.
|
||||
|
||||
config LIS3MDL_FIBER_STACK_SIZE
|
||||
config LIS3MDL_THREAD_STACK_SIZE
|
||||
int
|
||||
prompt "Fiber stack size"
|
||||
depends on LIS3MDL && LIS3MDL_TRIGGER_OWN_FIBER
|
||||
prompt "Thread stack size"
|
||||
depends on LIS3MDL && LIS3MDL_TRIGGER_OWN_THREAD
|
||||
default 1024
|
||||
help
|
||||
Stack size of fiber used by the driver to handle interrupts.
|
||||
Stack size of thread used by the driver to handle interrupts.
|
||||
|
||||
config LIS3MDL_ODR
|
||||
string
|
||||
|
|
|
@ -116,10 +116,10 @@ struct lis3mdl_data {
|
|||
struct sensor_trigger data_ready_trigger;
|
||||
sensor_trigger_handler_t data_ready_handler;
|
||||
|
||||
#if defined(CONFIG_LIS3MDL_TRIGGER_OWN_FIBER)
|
||||
char __stack fiber_stack[CONFIG_LIS3MDL_FIBER_STACK_SIZE];
|
||||
#if defined(CONFIG_LIS3MDL_TRIGGER_OWN_THREAD)
|
||||
char __stack thread_stack[CONFIG_LIS3MDL_THREAD_STACK_SIZE];
|
||||
struct k_sem gpio_sem;
|
||||
#elif defined(CONFIG_LIS3MDL_TRIGGER_GLOBAL_FIBER)
|
||||
#elif defined(CONFIG_LIS3MDL_TRIGGER_GLOBAL_THREAD)
|
||||
struct k_work work;
|
||||
struct device *dev;
|
||||
#endif
|
||||
|
|
|
@ -55,14 +55,14 @@ static void lis3mdl_gpio_callback(struct device *dev,
|
|||
|
||||
gpio_pin_disable_callback(dev, CONFIG_LIS3MDL_GPIO_PIN_NUM);
|
||||
|
||||
#if defined(CONFIG_LIS3MDL_TRIGGER_OWN_FIBER)
|
||||
#if defined(CONFIG_LIS3MDL_TRIGGER_OWN_THREAD)
|
||||
k_sem_give(&drv_data->gpio_sem);
|
||||
#elif defined(CONFIG_LIS3MDL_TRIGGER_GLOBAL_FIBER)
|
||||
#elif defined(CONFIG_LIS3MDL_TRIGGER_GLOBAL_THREAD)
|
||||
k_work_submit(&drv_data->work);
|
||||
#endif
|
||||
}
|
||||
|
||||
static void lis3mdl_fiber_cb(void *arg)
|
||||
static void lis3mdl_thread_cb(void *arg)
|
||||
{
|
||||
struct device *dev = arg;
|
||||
struct lis3mdl_data *drv_data = dev->driver_data;
|
||||
|
@ -75,8 +75,8 @@ static void lis3mdl_fiber_cb(void *arg)
|
|||
gpio_pin_enable_callback(drv_data->gpio, CONFIG_LIS3MDL_GPIO_PIN_NUM);
|
||||
}
|
||||
|
||||
#ifdef CONFIG_LIS3MDL_TRIGGER_OWN_FIBER
|
||||
static void lis3mdl_fiber(int dev_ptr, int unused)
|
||||
#ifdef CONFIG_LIS3MDL_TRIGGER_OWN_THREAD
|
||||
static void lis3mdl_thread(int dev_ptr, int unused)
|
||||
{
|
||||
struct device *dev = INT_TO_POINTER(dev_ptr);
|
||||
struct lis3mdl_data *drv_data = dev->driver_data;
|
||||
|
@ -85,18 +85,18 @@ static void lis3mdl_fiber(int dev_ptr, int unused)
|
|||
|
||||
while (1) {
|
||||
k_sem_take(&drv_data->gpio_sem, K_FOREVER);
|
||||
lis3mdl_fiber_cb(dev);
|
||||
lis3mdl_thread_cb(dev);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_LIS3MDL_TRIGGER_GLOBAL_FIBER
|
||||
#ifdef CONFIG_LIS3MDL_TRIGGER_GLOBAL_THREAD
|
||||
static void lis3mdl_work_cb(struct k_work *work)
|
||||
{
|
||||
struct lis3mdl_data *drv_data =
|
||||
CONTAINER_OF(work, struct lis3mdl_data, work);
|
||||
|
||||
lis3mdl_fiber_cb(drv_data->dev);
|
||||
lis3mdl_thread_cb(drv_data->dev);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -138,13 +138,13 @@ int lis3mdl_init_interrupt(struct device *dev)
|
|||
return -EIO;
|
||||
}
|
||||
|
||||
#if defined(CONFIG_LIS3MDL_TRIGGER_OWN_FIBER)
|
||||
#if defined(CONFIG_LIS3MDL_TRIGGER_OWN_THREAD)
|
||||
k_sem_init(&drv_data->gpio_sem, 0, UINT_MAX);
|
||||
|
||||
fiber_start(drv_data->fiber_stack, CONFIG_LIS3MDL_FIBER_STACK_SIZE,
|
||||
(nano_fiber_entry_t)lis3mdl_fiber, POINTER_TO_INT(dev),
|
||||
0, CONFIG_LIS3MDL_FIBER_PRIORITY, 0);
|
||||
#elif defined(CONFIG_LIS3MDL_TRIGGER_GLOBAL_FIBER)
|
||||
k_thread_spawn(drv_data->thread_stack, CONFIG_LIS3MDL_THREAD_STACK_SIZE,
|
||||
(k_thread_entry_t)lis3mdl_thread, POINTER_TO_INT(dev),
|
||||
0, NULL, K_PRIO_COOP(CONFIG_LIS3MDL_THREAD_PRIORITY), 0, 0);
|
||||
#elif defined(CONFIG_LIS3MDL_TRIGGER_GLOBAL_THREAD)
|
||||
drv_data->work.handler = lis3mdl_work_cb;
|
||||
drv_data->dev = dev;
|
||||
#endif
|
||||
|
|
|
@ -117,12 +117,12 @@ config LSM9DS0_GYRO_TRIGGERS
|
|||
depends on LSM9DS0_GYRO && GPIO
|
||||
default n
|
||||
|
||||
config LSM9DS0_GYRO_FIBER_STACK_SIZE
|
||||
int "Fiber stack size"
|
||||
config LSM9DS0_GYRO_THREAD_STACK_SIZE
|
||||
int "Thread stack size"
|
||||
depends on LSM9DS0_GYRO_TRIGGERS
|
||||
default 1024
|
||||
help
|
||||
Specify the internal fiber stack size.
|
||||
Specify the internal thread stack size.
|
||||
|
||||
config LSM9DS0_GYRO_TRIGGER_DRDY
|
||||
bool "Enable data ready trigger"
|
||||
|
|
|
@ -239,7 +239,7 @@ struct lsm9ds0_gyro_data {
|
|||
#endif
|
||||
|
||||
#if defined(CONFIG_LSM9DS0_GYRO_TRIGGER_DRDY)
|
||||
char __stack fiber_stack[CONFIG_LSM9DS0_GYRO_FIBER_STACK_SIZE];
|
||||
char __stack thread_stack[CONFIG_LSM9DS0_GYRO_THREAD_STACK_SIZE];
|
||||
struct device *dev;
|
||||
|
||||
struct device *gpio_drdy;
|
||||
|
|
|
@ -80,10 +80,13 @@ static void lsm9ds0_gyro_gpio_drdy_callback(struct device *dev,
|
|||
k_sem_give(&data->sem);
|
||||
}
|
||||
|
||||
static void lsm9ds0_gyro_fiber_main(int arg1, int gpio_pin)
|
||||
static void lsm9ds0_gyro_thread_main(void *arg1, void *arg2, void *arg3)
|
||||
{
|
||||
struct device *dev = (struct device *) arg1;
|
||||
struct lsm9ds0_gyro_data *data = dev->driver_data;
|
||||
const struct lsm9ds0_gyro_config *config = dev->config->config_info;
|
||||
|
||||
int gpio_pin = config->gpio_drdy_int_pin;
|
||||
|
||||
while (1) {
|
||||
k_sem_take(&data->sem, K_FOREVER);
|
||||
|
@ -104,10 +107,10 @@ int lsm9ds0_gyro_init_interrupt(struct device *dev)
|
|||
|
||||
k_sem_init(&data->sem, 0, UINT_MAX);
|
||||
|
||||
task_fiber_start(data->fiber_stack,
|
||||
CONFIG_LSM9DS0_GYRO_FIBER_STACK_SIZE,
|
||||
lsm9ds0_gyro_fiber_main, (int) dev,
|
||||
config->gpio_drdy_int_pin, 10, 0);
|
||||
k_thread_spawn(data->thread_stack,
|
||||
CONFIG_LSM9DS0_GYRO_THREAD_STACK_SIZE,
|
||||
lsm9ds0_gyro_thread_main, dev, NULL, NULL,
|
||||
K_PRIO_COOP(10), 0, 0);
|
||||
|
||||
data->gpio_drdy = device_get_binding(config->gpio_drdy_dev_name);
|
||||
if (!data->gpio_drdy) {
|
||||
|
|
|
@ -52,15 +52,15 @@ choice
|
|||
config MCP9808_TRIGGER_NONE
|
||||
bool "No trigger"
|
||||
|
||||
config MCP9808_TRIGGER_GLOBAL_FIBER
|
||||
config MCP9808_TRIGGER_GLOBAL_THREAD
|
||||
depends on GPIO
|
||||
select MCP9808_TRIGGER
|
||||
bool "Use global fiber"
|
||||
bool "Use global thread"
|
||||
|
||||
config MCP9808_TRIGGER_OWN_FIBER
|
||||
config MCP9808_TRIGGER_OWN_THREAD
|
||||
depends on GPIO
|
||||
select MCP9808_TRIGGER
|
||||
bool "Use own fiber"
|
||||
bool "Use own thread"
|
||||
|
||||
endchoice
|
||||
|
||||
|
@ -82,12 +82,12 @@ config MCP9808_GPIO_PIN
|
|||
help
|
||||
The GPIO pin the MCP9808 interrupt is connected to.
|
||||
|
||||
config MCP9808_FIBER_STACK_SIZE
|
||||
int "Sensor delayed work fiber stack size"
|
||||
depends on MCP9808 && MCP9808_TRIGGER_OWN_FIBER
|
||||
config MCP9808_THREAD_STACK_SIZE
|
||||
int "Sensor delayed work thread stack size"
|
||||
depends on MCP9808 && MCP9808_TRIGGER_OWN_THREAD
|
||||
default 1024
|
||||
|
||||
config MCP9808_FIBER_PRIORITY
|
||||
int "MCP9808 fiber priority"
|
||||
depends on MCP9808 && MCP9808_TRIGGER_OWN_FIBER
|
||||
config MCP9808_THREAD_PRIORITY
|
||||
int "MCP9808 thread priority"
|
||||
depends on MCP9808 && MCP9808_TRIGGER_OWN_THREAD
|
||||
default 10
|
||||
|
|
|
@ -50,11 +50,11 @@ struct mcp9808_data {
|
|||
|
||||
struct gpio_callback gpio_cb;
|
||||
|
||||
#ifdef CONFIG_MCP9808_TRIGGER_OWN_FIBER
|
||||
#ifdef CONFIG_MCP9808_TRIGGER_OWN_THREAD
|
||||
struct k_sem sem;
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_MCP9808_TRIGGER_GLOBAL_FIBER
|
||||
#ifdef CONFIG_MCP9808_TRIGGER_GLOBAL_THREAD
|
||||
struct k_work work;
|
||||
struct device *dev;
|
||||
#endif
|
||||
|
|
|
@ -116,7 +116,7 @@ int mcp9808_trigger_set(struct device *dev,
|
|||
handler == NULL ? 0 : MCP9808_ALERT_CNT);
|
||||
}
|
||||
|
||||
#ifdef CONFIG_MCP9808_TRIGGER_OWN_FIBER
|
||||
#ifdef CONFIG_MCP9808_TRIGGER_OWN_THREAD
|
||||
|
||||
static void mcp9808_gpio_cb(struct device *dev,
|
||||
struct gpio_callback *cb, uint32_t pins)
|
||||
|
@ -129,7 +129,7 @@ static void mcp9808_gpio_cb(struct device *dev,
|
|||
k_sem_give(&data->sem);
|
||||
}
|
||||
|
||||
static void mcp9808_fiber_main(int arg1, int arg2)
|
||||
static void mcp9808_thread_main(int arg1, int arg2)
|
||||
{
|
||||
struct device *dev = INT_TO_POINTER(arg1);
|
||||
struct mcp9808_data *data = dev->driver_data;
|
||||
|
@ -144,9 +144,9 @@ static void mcp9808_fiber_main(int arg1, int arg2)
|
|||
}
|
||||
}
|
||||
|
||||
static char __stack mcp9808_fiber_stack[CONFIG_MCP9808_FIBER_STACK_SIZE];
|
||||
static char __stack mcp9808_thread_stack[CONFIG_MCP9808_THREAD_STACK_SIZE];
|
||||
|
||||
#else /* CONFIG_MCP9808_TRIGGER_GLOBAL_FIBER */
|
||||
#else /* CONFIG_MCP9808_TRIGGER_GLOBAL_THREAD */
|
||||
|
||||
static void mcp9808_gpio_cb(struct device *dev,
|
||||
struct gpio_callback *cb, uint32_t pins)
|
||||
|
@ -159,7 +159,7 @@ static void mcp9808_gpio_cb(struct device *dev,
|
|||
k_work_submit(&data->work);
|
||||
}
|
||||
|
||||
static void mcp9808_gpio_fiber_cb(struct k_work *work)
|
||||
static void mcp9808_gpio_thread_cb(struct k_work *work)
|
||||
{
|
||||
struct mcp9808_data *data =
|
||||
CONTAINER_OF(work, struct mcp9808_data, work);
|
||||
|
@ -170,7 +170,7 @@ static void mcp9808_gpio_fiber_cb(struct k_work *work)
|
|||
MCP9808_INT_CLEAR, MCP9808_INT_CLEAR);
|
||||
}
|
||||
|
||||
#endif /* CONFIG_MCP9808_TRIGGER_GLOBAL_FIBER */
|
||||
#endif /* CONFIG_MCP9808_TRIGGER_GLOBAL_THREAD */
|
||||
|
||||
void mcp9808_setup_interrupt(struct device *dev)
|
||||
{
|
||||
|
@ -183,15 +183,15 @@ void mcp9808_setup_interrupt(struct device *dev)
|
|||
mcp9808_reg_update(data, MCP9808_REG_CONFIG, MCP9808_INT_CLEAR,
|
||||
MCP9808_INT_CLEAR);
|
||||
|
||||
#ifdef CONFIG_MCP9808_TRIGGER_OWN_FIBER
|
||||
#ifdef CONFIG_MCP9808_TRIGGER_OWN_THREAD
|
||||
k_sem_init(&data->sem, 0, UINT_MAX);
|
||||
|
||||
fiber_fiber_start(mcp9808_fiber_stack,
|
||||
CONFIG_MCP9808_FIBER_STACK_SIZE,
|
||||
mcp9808_fiber_main, POINTER_TO_INT(dev), 0,
|
||||
CONFIG_MCP9808_FIBER_PRIORITY, 0);
|
||||
#else /* CONFIG_MCP9808_TRIGGER_GLOBAL_FIBER */
|
||||
data->work.handler = mcp9808_gpio_fiber_cb;
|
||||
k_thread_spawn(mcp9808_thread_stack,
|
||||
CONFIG_MCP9808_THREAD_STACK_SIZE,
|
||||
mcp9808_thread_main, POINTER_TO_INT(dev), 0, NULL,
|
||||
K_PRIO_COOP(CONFIG_MCP9808_THREAD_PRIORITY), 0, 0);
|
||||
#else /* CONFIG_MCP9808_TRIGGER_GLOBAL_THREAD */
|
||||
data->work.handler = mcp9808_gpio_thread_cb;
|
||||
data->dev = dev;
|
||||
#endif
|
||||
|
||||
|
|
|
@ -55,7 +55,7 @@ config MPU6050_I2C_MASTER_DEV_NAME
|
|||
choice
|
||||
prompt "Trigger mode"
|
||||
depends on MPU6050
|
||||
default MPU6050_TRIGGER_GLOBAL_FIBER
|
||||
default MPU6050_TRIGGER_GLOBAL_THREAD
|
||||
help
|
||||
Specify the type of triggering to be used by the driver.
|
||||
|
||||
|
@ -63,15 +63,15 @@ config MPU6050_TRIGGER_NONE
|
|||
bool
|
||||
prompt "No trigger"
|
||||
|
||||
config MPU6050_TRIGGER_GLOBAL_FIBER
|
||||
config MPU6050_TRIGGER_GLOBAL_THREAD
|
||||
bool
|
||||
prompt "Use global fiber"
|
||||
prompt "Use global thread"
|
||||
depends on GPIO
|
||||
select MPU6050_TRIGGER
|
||||
|
||||
config MPU6050_TRIGGER_OWN_FIBER
|
||||
config MPU6050_TRIGGER_OWN_THREAD
|
||||
bool
|
||||
prompt "Use own fiber"
|
||||
prompt "Use own thread"
|
||||
depends on GPIO
|
||||
select MPU6050_TRIGGER
|
||||
|
||||
|
@ -99,21 +99,21 @@ config MPU6050_GPIO_PIN_NUM
|
|||
The number of the GPIO on which the interrupt signal from the MPU6050
|
||||
chip will be received.
|
||||
|
||||
config MPU6050_FIBER_PRIORITY
|
||||
config MPU6050_THREAD_PRIORITY
|
||||
int
|
||||
prompt "Fiber priority"
|
||||
depends on MPU6050 && MPU6050_TRIGGER_OWN_FIBER
|
||||
prompt "Thread priority"
|
||||
depends on MPU6050 && MPU6050_TRIGGER_OWN_THREAD
|
||||
default 10
|
||||
help
|
||||
Priority of fiber used by the driver to handle interrupts.
|
||||
Priority of thread used by the driver to handle interrupts.
|
||||
|
||||
config MPU6050_FIBER_STACK_SIZE
|
||||
config MPU6050_THREAD_STACK_SIZE
|
||||
int
|
||||
prompt "Fiber stack size"
|
||||
depends on MPU6050 && MPU6050_TRIGGER_OWN_FIBER
|
||||
prompt "Thread stack size"
|
||||
depends on MPU6050 && MPU6050_TRIGGER_OWN_THREAD
|
||||
default 1024
|
||||
help
|
||||
Stack size of fiber used by the driver to handle interrupts.
|
||||
Stack size of thread used by the driver to handle interrupts.
|
||||
|
||||
config MPU6050_ACCEL_FS
|
||||
int
|
||||
|
|
|
@ -70,10 +70,10 @@ struct mpu6050_data {
|
|||
struct sensor_trigger data_ready_trigger;
|
||||
sensor_trigger_handler_t data_ready_handler;
|
||||
|
||||
#if defined(CONFIG_MPU6050_TRIGGER_OWN_FIBER)
|
||||
char __stack fiber_stack[CONFIG_MPU6050_FIBER_STACK_SIZE];
|
||||
#if defined(CONFIG_MPU6050_TRIGGER_OWN_THREAD)
|
||||
char __stack thread_stack[CONFIG_MPU6050_THREAD_STACK_SIZE];
|
||||
struct k_sem gpio_sem;
|
||||
#elif defined(CONFIG_MPU6050_TRIGGER_GLOBAL_FIBER)
|
||||
#elif defined(CONFIG_MPU6050_TRIGGER_GLOBAL_THREAD)
|
||||
struct k_work work;
|
||||
struct device *dev;
|
||||
#endif
|
||||
|
|
|
@ -56,14 +56,14 @@ static void mpu6050_gpio_callback(struct device *dev,
|
|||
|
||||
gpio_pin_disable_callback(dev, CONFIG_MPU6050_GPIO_PIN_NUM);
|
||||
|
||||
#if defined(CONFIG_MPU6050_TRIGGER_OWN_FIBER)
|
||||
#if defined(CONFIG_MPU6050_TRIGGER_OWN_THREAD)
|
||||
k_sem_give(&drv_data->gpio_sem);
|
||||
#elif defined(CONFIG_MPU6050_TRIGGER_GLOBAL_FIBER)
|
||||
#elif defined(CONFIG_MPU6050_TRIGGER_GLOBAL_THREAD)
|
||||
k_work_submit(&drv_data->work);
|
||||
#endif
|
||||
}
|
||||
|
||||
static void mpu6050_fiber_cb(void *arg)
|
||||
static void mpu6050_thread_cb(void *arg)
|
||||
{
|
||||
struct device *dev = arg;
|
||||
struct mpu6050_data *drv_data = dev->driver_data;
|
||||
|
@ -76,8 +76,8 @@ static void mpu6050_fiber_cb(void *arg)
|
|||
gpio_pin_enable_callback(drv_data->gpio, CONFIG_MPU6050_GPIO_PIN_NUM);
|
||||
}
|
||||
|
||||
#ifdef CONFIG_MPU6050_TRIGGER_OWN_FIBER
|
||||
static void mpu6050_fiber(int dev_ptr, int unused)
|
||||
#ifdef CONFIG_MPU6050_TRIGGER_OWN_THREAD
|
||||
static void mpu6050_thread(int dev_ptr, int unused)
|
||||
{
|
||||
struct device *dev = INT_TO_POINTER(dev_ptr);
|
||||
struct mpu6050_data *drv_data = dev->driver_data;
|
||||
|
@ -86,18 +86,18 @@ static void mpu6050_fiber(int dev_ptr, int unused)
|
|||
|
||||
while (1) {
|
||||
k_sem_take(&drv_data->gpio_sem, K_FOREVER);
|
||||
mpu6050_fiber_cb(dev);
|
||||
mpu6050_thread_cb(dev);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_MPU6050_TRIGGER_GLOBAL_FIBER
|
||||
#ifdef CONFIG_MPU6050_TRIGGER_GLOBAL_THREAD
|
||||
static void mpu6050_work_cb(struct k_work *work)
|
||||
{
|
||||
struct mpu6050_data *drv_data =
|
||||
CONTAINER_OF(work, struct mpu6050_data, work);
|
||||
|
||||
mpu6050_fiber_cb(drv_data->dev);
|
||||
mpu6050_thread_cb(drv_data->dev);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -133,13 +133,13 @@ int mpu6050_init_interrupt(struct device *dev)
|
|||
return -EIO;
|
||||
}
|
||||
|
||||
#if defined(CONFIG_MPU6050_TRIGGER_OWN_FIBER)
|
||||
#if defined(CONFIG_MPU6050_TRIGGER_OWN_THREAD)
|
||||
k_sem_init(&drv_data->gpio_sem, 0, UINT_MAX);
|
||||
|
||||
fiber_start(drv_data->fiber_stack, CONFIG_MPU6050_FIBER_STACK_SIZE,
|
||||
(nano_fiber_entry_t)mpu6050_fiber, POINTER_TO_INT(dev),
|
||||
0, CONFIG_MPU6050_FIBER_PRIORITY, 0);
|
||||
#elif defined(CONFIG_MPU6050_TRIGGER_GLOBAL_FIBER)
|
||||
k_thread_spawn(drv_data->thread_stack, CONFIG_MPU6050_THREAD_STACK_SIZE,
|
||||
(k_thread_entry_t)mpu6050_thread, POINTER_TO_INT(dev),
|
||||
0, NULL, K_PRIO_COOP(CONFIG_MPU6050_THREAD_PRIORITY), 0, 0);
|
||||
#elif defined(CONFIG_MPU6050_TRIGGER_GLOBAL_THREAD)
|
||||
drv_data->work.handler = mpu6050_work_cb;
|
||||
drv_data->dev = dev;
|
||||
#endif
|
||||
|
|
|
@ -62,15 +62,15 @@ config SHT3XD_TRIGGER_NONE
|
|||
bool
|
||||
prompt "No trigger"
|
||||
|
||||
config SHT3XD_TRIGGER_GLOBAL_FIBER
|
||||
config SHT3XD_TRIGGER_GLOBAL_THREAD
|
||||
bool
|
||||
prompt "Use global fiber"
|
||||
prompt "Use global thread"
|
||||
depends on GPIO
|
||||
select SHT3XD_TRIGGER
|
||||
|
||||
config SHT3XD_TRIGGER_OWN_FIBER
|
||||
config SHT3XD_TRIGGER_OWN_THREAD
|
||||
bool
|
||||
prompt "Use own fiber"
|
||||
prompt "Use own thread"
|
||||
depends on GPIO
|
||||
select SHT3XD_TRIGGER
|
||||
|
||||
|
@ -98,21 +98,21 @@ config SHT3XD_GPIO_PIN_NUM
|
|||
The number of the GPIO on which the interrupt signal from the
|
||||
SHT3xD chip will be received.
|
||||
|
||||
config SHT3XD_FIBER_PRIORITY
|
||||
config SHT3XD_THREAD_PRIORITY
|
||||
int
|
||||
prompt "Fiber priority"
|
||||
depends on SHT3XD && SHT3XD_TRIGGER_OWN_FIBER
|
||||
prompt "Thread priority"
|
||||
depends on SHT3XD && SHT3XD_TRIGGER_OWN_THREAD
|
||||
default 10
|
||||
help
|
||||
Priority of fiber used by the driver to handle interrupts.
|
||||
Priority of thread used by the driver to handle interrupts.
|
||||
|
||||
config SHT3XD_FIBER_STACK_SIZE
|
||||
config SHT3XD_THREAD_STACK_SIZE
|
||||
int
|
||||
prompt "Fiber stack size"
|
||||
depends on SHT3XD && SHT3XD_TRIGGER_OWN_FIBER
|
||||
prompt "Thread stack size"
|
||||
depends on SHT3XD && SHT3XD_TRIGGER_OWN_THREAD
|
||||
default 1024
|
||||
help
|
||||
Stack size of fiber used by the driver to handle interrupts.
|
||||
Stack size of thread used by the driver to handle interrupts.
|
||||
|
||||
choice
|
||||
prompt "Measurement repeatability"
|
||||
|
|
|
@ -84,10 +84,10 @@ struct sht3xd_data {
|
|||
sensor_trigger_handler_t handler;
|
||||
struct sensor_trigger trigger;
|
||||
|
||||
#if defined(CONFIG_SHT3XD_TRIGGER_OWN_FIBER)
|
||||
char __stack fiber_stack[CONFIG_SHT3XD_FIBER_STACK_SIZE];
|
||||
#if defined(CONFIG_SHT3XD_TRIGGER_OWN_THREAD)
|
||||
char __stack thread_stack[CONFIG_SHT3XD_THREAD_STACK_SIZE];
|
||||
struct k_sem gpio_sem;
|
||||
#elif defined(CONFIG_SHT3XD_TRIGGER_GLOBAL_FIBER)
|
||||
#elif defined(CONFIG_SHT3XD_TRIGGER_GLOBAL_THREAD)
|
||||
struct k_work work;
|
||||
struct device *dev;
|
||||
#endif
|
||||
|
|
|
@ -117,14 +117,14 @@ static void sht3xd_gpio_callback(struct device *dev,
|
|||
|
||||
gpio_pin_disable_callback(dev, CONFIG_SHT3XD_GPIO_PIN_NUM);
|
||||
|
||||
#if defined(CONFIG_SHT3XD_TRIGGER_OWN_FIBER)
|
||||
#if defined(CONFIG_SHT3XD_TRIGGER_OWN_THREAD)
|
||||
k_sem_give(&drv_data->gpio_sem);
|
||||
#elif defined(CONFIG_SHT3XD_TRIGGER_GLOBAL_FIBER)
|
||||
#elif defined(CONFIG_SHT3XD_TRIGGER_GLOBAL_THREAD)
|
||||
k_work_submit(&drv_data->work);
|
||||
#endif
|
||||
}
|
||||
|
||||
static void sht3xd_fiber_cb(void *arg)
|
||||
static void sht3xd_thread_cb(void *arg)
|
||||
{
|
||||
struct device *dev = arg;
|
||||
struct sht3xd_data *drv_data = dev->driver_data;
|
||||
|
@ -136,8 +136,8 @@ static void sht3xd_fiber_cb(void *arg)
|
|||
gpio_pin_enable_callback(drv_data->gpio, CONFIG_SHT3XD_GPIO_PIN_NUM);
|
||||
}
|
||||
|
||||
#ifdef CONFIG_SHT3XD_TRIGGER_OWN_FIBER
|
||||
static void sht3xd_fiber(int dev_ptr, int unused)
|
||||
#ifdef CONFIG_SHT3XD_TRIGGER_OWN_THREAD
|
||||
static void sht3xd_thread(int dev_ptr, int unused)
|
||||
{
|
||||
struct device *dev = INT_TO_POINTER(dev_ptr);
|
||||
struct sht3xd_data *drv_data = dev->driver_data;
|
||||
|
@ -146,18 +146,18 @@ static void sht3xd_fiber(int dev_ptr, int unused)
|
|||
|
||||
while (1) {
|
||||
k_sem_take(&drv_data->gpio_sem, K_FOREVER);
|
||||
sht3xd_fiber_cb(dev);
|
||||
sht3xd_thread_cb(dev);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_SHT3XD_TRIGGER_GLOBAL_FIBER
|
||||
#ifdef CONFIG_SHT3XD_TRIGGER_GLOBAL_THREAD
|
||||
static void sht3xd_work_cb(struct k_work *work)
|
||||
{
|
||||
struct sht3xd_data *drv_data =
|
||||
CONTAINER_OF(work, struct sht3xd_data, work);
|
||||
|
||||
sht3xd_fiber_cb(drv_data->dev);
|
||||
sht3xd_thread_cb(drv_data->dev);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -232,13 +232,13 @@ int sht3xd_init_interrupt(struct device *dev)
|
|||
return -EIO;
|
||||
}
|
||||
|
||||
#if defined(CONFIG_SHT3XD_TRIGGER_OWN_FIBER)
|
||||
#if defined(CONFIG_SHT3XD_TRIGGER_OWN_THREAD)
|
||||
k_sem_init(&drv_data->gpio_sem, 0, UINT_MAX);
|
||||
|
||||
fiber_start(drv_data->fiber_stack, CONFIG_SHT3XD_FIBER_STACK_SIZE,
|
||||
(nano_fiber_entry_t)sht3xd_fiber, POINTER_TO_INT(dev),
|
||||
0, CONFIG_SHT3XD_FIBER_PRIORITY, 0);
|
||||
#elif defined(CONFIG_SHT3XD_TRIGGER_GLOBAL_FIBER)
|
||||
k_thread_spawn(drv_data->thread_stack, CONFIG_SHT3XD_THREAD_STACK_SIZE,
|
||||
(k_thread_entry_t)sht3xd_thread, POINTER_TO_INT(dev),
|
||||
0, NULL, K_PRIO_COOP(CONFIG_SHT3XD_THREAD_PRIORITY), 0, 0);
|
||||
#elif defined(CONFIG_SHT3XD_TRIGGER_GLOBAL_THREAD)
|
||||
drv_data->work.handler = sht3xd_work_cb;
|
||||
drv_data->dev = dev;
|
||||
#endif
|
||||
|
|
|
@ -55,20 +55,20 @@ config SX9500_PROX_CHANNEL
|
|||
choice
|
||||
prompt "SX9500 trigger mode"
|
||||
depends on SX9500
|
||||
default SX9500_TRIGGER_GLOBAL_FIBER
|
||||
default SX9500_TRIGGER_GLOBAL_THREAD
|
||||
|
||||
config SX9500_TRIGGER_NONE
|
||||
bool "No trigger"
|
||||
|
||||
config SX9500_TRIGGER_GLOBAL_FIBER
|
||||
config SX9500_TRIGGER_GLOBAL_THREAD
|
||||
depends on GPIO
|
||||
select SX9500_TRIGGER
|
||||
bool "Use global fiber"
|
||||
bool "Use global thread"
|
||||
|
||||
config SX9500_TRIGGER_OWN_FIBER
|
||||
config SX9500_TRIGGER_OWN_THREAD
|
||||
depends on GPIO
|
||||
select SX9500_TRIGGER
|
||||
bool "Use own fiber"
|
||||
bool "Use own thread"
|
||||
|
||||
endchoice
|
||||
|
||||
|
@ -89,12 +89,12 @@ config SX9500_GPIO_PIN
|
|||
depends on SX9500 && SX9500_TRIGGER
|
||||
default 3
|
||||
|
||||
config SX9500_FIBER_STACK_SIZE
|
||||
int "Sensor delayed work fiber stack size"
|
||||
depends on SX9500 && SX9500_TRIGGER_OWN_FIBER
|
||||
config SX9500_THREAD_STACK_SIZE
|
||||
int "Sensor delayed work thread stack size"
|
||||
depends on SX9500 && SX9500_TRIGGER_OWN_THREAD
|
||||
default 1024
|
||||
|
||||
config SX9500_FIBER_PRIORITY
|
||||
int "Fiber priority"
|
||||
depends on SX9500 && SX9500_TRIGGER_OWN_FIBER
|
||||
config SX9500_THREAD_PRIORITY
|
||||
int "Thread priority"
|
||||
depends on SX9500 && SX9500_TRIGGER_OWN_THREAD
|
||||
default 10
|
||||
|
|
|
@ -41,11 +41,11 @@ struct sx9500_data {
|
|||
|
||||
struct gpio_callback gpio_cb;
|
||||
|
||||
#ifdef CONFIG_SX9500_TRIGGER_OWN_FIBER
|
||||
#ifdef CONFIG_SX9500_TRIGGER_OWN_THREAD
|
||||
struct k_sem sem;
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_SX9500_TRIGGER_GLOBAL_FIBER
|
||||
#ifdef CONFIG_SX9500_TRIGGER_GLOBAL_THREAD
|
||||
struct k_work work;
|
||||
struct device *dev;
|
||||
#endif
|
||||
|
|
|
@ -23,8 +23,8 @@
|
|||
#include <misc/util.h>
|
||||
#include "sx9500.h"
|
||||
|
||||
#ifdef CONFIG_SX9500_TRIGGER_OWN_FIBER
|
||||
static char __stack sx9500_fiber_stack[CONFIG_SX9500_FIBER_STACK_SIZE];
|
||||
#ifdef CONFIG_SX9500_TRIGGER_OWN_THREAD
|
||||
static char __stack sx9500_thread_stack[CONFIG_SX9500_THREAD_STACK_SIZE];
|
||||
#endif
|
||||
|
||||
int sx9500_trigger_set(struct device *dev,
|
||||
|
@ -65,7 +65,7 @@ int sx9500_trigger_set(struct device *dev,
|
|||
return 0;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_SX9500_TRIGGER_OWN_FIBER
|
||||
#ifdef CONFIG_SX9500_TRIGGER_OWN_THREAD
|
||||
|
||||
static void sx9500_gpio_cb(struct device *port,
|
||||
struct gpio_callback *cb, uint32_t pins)
|
||||
|
@ -78,7 +78,7 @@ static void sx9500_gpio_cb(struct device *port,
|
|||
k_sem_give(&data->sem);
|
||||
}
|
||||
|
||||
static void sx9500_fiber_main(int arg1, int unused)
|
||||
static void sx9500_thread_main(int arg1, int unused)
|
||||
{
|
||||
struct device *dev = INT_TO_POINTER(arg1);
|
||||
struct sx9500_data *data = dev->driver_data;
|
||||
|
@ -105,7 +105,7 @@ static void sx9500_fiber_main(int arg1, int unused)
|
|||
}
|
||||
}
|
||||
|
||||
#else /* CONFIG_SX9500_TRIGGER_GLOBAL_FIBER */
|
||||
#else /* CONFIG_SX9500_TRIGGER_GLOBAL_THREAD */
|
||||
|
||||
static void sx9500_gpio_cb(struct device *port,
|
||||
struct gpio_callback *cb, uint32_t pins)
|
||||
|
@ -118,7 +118,7 @@ static void sx9500_gpio_cb(struct device *port,
|
|||
k_work_submit(&data->work);
|
||||
}
|
||||
|
||||
static void sx9500_gpio_fiber_cb(void *arg)
|
||||
static void sx9500_gpio_thread_cb(void *arg)
|
||||
{
|
||||
struct device *dev = arg;
|
||||
struct sx9500_data *data = dev->driver_data;
|
||||
|
@ -138,15 +138,15 @@ static void sx9500_gpio_fiber_cb(void *arg)
|
|||
data->handler_near_far(dev, &data->trigger_near_far);
|
||||
}
|
||||
}
|
||||
#endif /* CONFIG_SX9500_TRIGGER_GLOBAL_FIBER */
|
||||
#endif /* CONFIG_SX9500_TRIGGER_GLOBAL_THREAD */
|
||||
|
||||
#ifdef CONFIG_SX9500_TRIGGER_GLOBAL_FIBER
|
||||
#ifdef CONFIG_SX9500_TRIGGER_GLOBAL_THREAD
|
||||
static void sx9500_work_cb(struct k_work *work)
|
||||
{
|
||||
struct sx9500_data *data =
|
||||
CONTAINER_OF(work, struct sx9500_data, work);
|
||||
|
||||
sx9500_gpio_fiber_cb(data->dev);
|
||||
sx9500_gpio_thread_cb(data->dev);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -155,7 +155,7 @@ int sx9500_setup_interrupt(struct device *dev)
|
|||
struct sx9500_data *data = dev->driver_data;
|
||||
struct device *gpio;
|
||||
|
||||
#ifdef CONFIG_SX9500_TRIGGER_OWN_FIBER
|
||||
#ifdef CONFIG_SX9500_TRIGGER_OWN_THREAD
|
||||
k_sem_init(&data->sem, 0, UINT_MAX);
|
||||
#else
|
||||
data->work.handler = sx9500_work_cb;
|
||||
|
@ -180,10 +180,10 @@ int sx9500_setup_interrupt(struct device *dev)
|
|||
gpio_add_callback(gpio, &data->gpio_cb);
|
||||
gpio_pin_enable_callback(gpio, CONFIG_SX9500_GPIO_PIN);
|
||||
|
||||
#ifdef CONFIG_SX9500_TRIGGER_OWN_FIBER
|
||||
fiber_fiber_start(sx9500_fiber_stack, CONFIG_SX9500_FIBER_STACK_SIZE,
|
||||
sx9500_fiber_main, POINTER_TO_INT(dev), 0,
|
||||
CONFIG_SX9500_FIBER_PRIORITY, 0);
|
||||
#ifdef CONFIG_SX9500_TRIGGER_OWN_THREAD
|
||||
k_thread_spawn(sx9500_thread_stack, CONFIG_SX9500_THREAD_STACK_SIZE,
|
||||
sx9500_thread_main, POINTER_TO_INT(dev), 0, NULL,
|
||||
K_PRIO_COOP(CONFIG_SX9500_THREAD_PRIORITY), 0, 0);
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
|
|
|
@ -69,15 +69,15 @@ config TMP007_TRIGGER_NONE
|
|||
bool
|
||||
prompt "No trigger"
|
||||
|
||||
config TMP007_TRIGGER_GLOBAL_FIBER
|
||||
config TMP007_TRIGGER_GLOBAL_THREAD
|
||||
bool
|
||||
prompt "Use global fiber"
|
||||
prompt "Use global thread"
|
||||
depends on GPIO
|
||||
select TMP007_TRIGGER
|
||||
|
||||
config TMP007_TRIGGER_OWN_FIBER
|
||||
config TMP007_TRIGGER_OWN_THREAD
|
||||
bool
|
||||
prompt "Use own fiber"
|
||||
prompt "Use own thread"
|
||||
depends on GPIO
|
||||
select TMP007_TRIGGER
|
||||
|
||||
|
@ -105,18 +105,18 @@ config TMP007_GPIO_PIN_NUM
|
|||
The number of the GPIO pin on which the interrupt signal from the
|
||||
TMP007 chip will be received.
|
||||
|
||||
config TMP007_FIBER_PRIORITY
|
||||
config TMP007_THREAD_PRIORITY
|
||||
int
|
||||
prompt "Fiber priority"
|
||||
depends on TMP007 && TMP007_TRIGGER_OWN_FIBER
|
||||
prompt "Thread priority"
|
||||
depends on TMP007 && TMP007_TRIGGER_OWN_THREAD
|
||||
default 10
|
||||
help
|
||||
Priority of fiber used by the driver to handle interrupts.
|
||||
Priority of thread used by the driver to handle interrupts.
|
||||
|
||||
config TMP007_FIBER_STACK_SIZE
|
||||
config TMP007_THREAD_STACK_SIZE
|
||||
int
|
||||
prompt "Fiber stack size"
|
||||
depends on TMP007 && TMP007_TRIGGER_OWN_FIBER
|
||||
prompt "Thread stack size"
|
||||
depends on TMP007 && TMP007_TRIGGER_OWN_THREAD
|
||||
default 1024
|
||||
help
|
||||
Stack size of fiber used by the driver to handle interrupts.
|
||||
Stack size of thread used by the driver to handle interrupts.
|
||||
|
|
|
@ -57,10 +57,10 @@ struct tmp007_data {
|
|||
sensor_trigger_handler_t th_handler;
|
||||
struct sensor_trigger th_trigger;
|
||||
|
||||
#if defined(CONFIG_TMP007_TRIGGER_OWN_FIBER)
|
||||
char __stack fiber_stack[CONFIG_TMP007_FIBER_STACK_SIZE];
|
||||
#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_FIBER)
|
||||
#elif defined(CONFIG_TMP007_TRIGGER_GLOBAL_THREAD)
|
||||
struct k_work work;
|
||||
struct device *dev;
|
||||
#endif
|
||||
|
|
|
@ -64,14 +64,14 @@ static void tmp007_gpio_callback(struct device *dev,
|
|||
|
||||
gpio_pin_disable_callback(dev, CONFIG_TMP007_GPIO_PIN_NUM);
|
||||
|
||||
#if defined(CONFIG_TMP007_TRIGGER_OWN_FIBER)
|
||||
#if defined(CONFIG_TMP007_TRIGGER_OWN_THREAD)
|
||||
k_sem_give(&drv_data->gpio_sem);
|
||||
#elif defined(CONFIG_TMP007_TRIGGER_GLOBAL_FIBER)
|
||||
#elif defined(CONFIG_TMP007_TRIGGER_GLOBAL_THREAD)
|
||||
k_work_submit(&drv_data->work);
|
||||
#endif
|
||||
}
|
||||
|
||||
static void tmp007_fiber_cb(void *arg)
|
||||
static void tmp007_thread_cb(void *arg)
|
||||
{
|
||||
struct device *dev = arg;
|
||||
struct tmp007_data *drv_data = dev->driver_data;
|
||||
|
@ -94,8 +94,8 @@ static void tmp007_fiber_cb(void *arg)
|
|||
gpio_pin_enable_callback(drv_data->gpio, CONFIG_TMP007_GPIO_PIN_NUM);
|
||||
}
|
||||
|
||||
#ifdef CONFIG_TMP007_TRIGGER_OWN_FIBER
|
||||
static void tmp007_fiber(int dev_ptr, int unused)
|
||||
#ifdef CONFIG_TMP007_TRIGGER_OWN_THREAD
|
||||
static void tmp007_thread(int dev_ptr, int unused)
|
||||
{
|
||||
struct device *dev = INT_TO_POINTER(dev_ptr);
|
||||
struct tmp007_data *drv_data = dev->driver_data;
|
||||
|
@ -104,18 +104,18 @@ static void tmp007_fiber(int dev_ptr, int unused)
|
|||
|
||||
while (1) {
|
||||
k_sem_take(&drv_data->gpio_sem, K_FOREVER);
|
||||
tmp007_fiber_cb(dev);
|
||||
tmp007_thread_cb(dev);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_TMP007_TRIGGER_GLOBAL_FIBER
|
||||
#ifdef CONFIG_TMP007_TRIGGER_GLOBAL_THREAD
|
||||
static void tmp007_work_cb(struct k_work *work)
|
||||
{
|
||||
struct tmp007_data *drv_data =
|
||||
CONTAINER_OF(work, struct tmp007_data, work);
|
||||
|
||||
tmp007_fiber_cb(drv_data->dev);
|
||||
tmp007_thread_cb(drv_data->dev);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -171,13 +171,13 @@ int tmp007_init_interrupt(struct device *dev)
|
|||
return -EIO;
|
||||
}
|
||||
|
||||
#if defined(CONFIG_TMP007_TRIGGER_OWN_FIBER)
|
||||
#if defined(CONFIG_TMP007_TRIGGER_OWN_THREAD)
|
||||
k_sem_init(&drv_data->gpio_sem, 0, UINT_MAX);
|
||||
|
||||
fiber_start(drv_data->fiber_stack, CONFIG_TMP007_FIBER_STACK_SIZE,
|
||||
(nano_fiber_entry_t)tmp007_fiber, POINTER_TO_INT(dev),
|
||||
0, CONFIG_TMP007_FIBER_PRIORITY, 0);
|
||||
#elif defined(CONFIG_TMP007_TRIGGER_GLOBAL_FIBER)
|
||||
k_thread_spawn(drv_data->thread_stack, CONFIG_TMP007_THREAD_STACK_SIZE,
|
||||
(k_thread_entry_t)tmp007_thread, POINTER_TO_INT(dev),
|
||||
0, NULL, K_PRIO_COOP(CONFIG_TMP007_THREAD_PRIORITY), 0, 0);
|
||||
#elif defined(CONFIG_TMP007_TRIGGER_GLOBAL_THREAD)
|
||||
drv_data->work.handler = tmp007_work_cb;
|
||||
drv_data->dev = dev;
|
||||
#endif
|
||||
|
|
|
@ -11,5 +11,5 @@ CONFIG_BMI160_NAME="bmi160"
|
|||
CONFIG_BMI160_SPI_PORT_NAME="SPI_1"
|
||||
CONFIG_BMI160_SLAVE=1
|
||||
CONFIG_BMI160_SPI_BUS_FREQ=88
|
||||
CONFIG_BMI160_TRIGGER_OWN_FIBER=y
|
||||
CONFIG_BMI160_TRIGGER_OWN_THREAD=y
|
||||
CONFIG_BMI160_TRIGGER=y
|
||||
|
|
|
@ -8,9 +8,9 @@ CONFIG_BMC150_MAGN=y
|
|||
CONFIG_BMC150_MAGN_TRIGGER=y
|
||||
CONFIG_BMC150_MAGN_TRIGGER_DRDY=y
|
||||
CONFIG_BMG160=y
|
||||
CONFIG_BMG160_TRIGGER_OWN_FIBER=y
|
||||
CONFIG_BMG160_TRIGGER_OWN_THREAD=y
|
||||
CONFIG_BMI160=y
|
||||
CONFIG_BMI160_TRIGGER_OWN_FIBER=y
|
||||
CONFIG_BMI160_TRIGGER_OWN_THREAD=y
|
||||
CONFIG_LSM6DS0=y
|
||||
CONFIG_LSM9DS0_GYRO=y
|
||||
CONFIG_LSM9DS0_GYRO_TRIGGERS=y
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue