sensors: use unified kernel APIs for kernel objects

move both semaphores and nano_work objects to unified kernel APIs.

Change-Id: Icca8a091063544c451e47201cd8e956b95010513
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
This commit is contained in:
Anas Nashif 2016-11-10 08:21:34 -05:00 committed by Andrew Boie
commit 8910c228a2
51 changed files with 161 additions and 173 deletions

View file

@ -16,7 +16,7 @@
#include <device.h>
#include <i2c.h>
#include <nanokernel.h>
#include <kernel.h>
#include <sensor.h>
#include <misc/__assert.h>
#include <misc/byteorder.h>

View file

@ -21,7 +21,6 @@
#include <misc/util.h>
#include <stdint.h>
#include <gpio.h>
#include <misc/nano_work.h>
#define BMA280_I2C_ADDRESS CONFIG_BMA280_I2C_ADDR
@ -143,9 +142,9 @@ struct bma280_data {
#if defined(CONFIG_BMA280_TRIGGER_OWN_FIBER)
char __stack fiber_stack[CONFIG_BMA280_FIBER_STACK_SIZE];
struct nano_sem gpio_sem;
struct k_sem gpio_sem;
#elif defined(CONFIG_BMA280_TRIGGER_GLOBAL_FIBER)
struct nano_work work;
struct k_work work;
struct device *dev;
#endif

View file

@ -17,7 +17,7 @@
#include <device.h>
#include <i2c.h>
#include <misc/util.h>
#include <nanokernel.h>
#include <kernel.h>
#include <sensor.h>
#include "bma280.h"
@ -71,9 +71,9 @@ 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)
nano_sem_give(&drv_data->gpio_sem);
k_sem_give(&drv_data->gpio_sem);
#elif defined(CONFIG_BMA280_TRIGGER_GLOBAL_FIBER)
nano_work_submit(&drv_data->work);
k_work_submit(&drv_data->work);
#endif
}
@ -119,14 +119,14 @@ static void bma280_fiber(int dev_ptr, int unused)
ARG_UNUSED(unused);
while (1) {
nano_fiber_sem_take(&drv_data->gpio_sem, TICKS_UNLIMITED);
k_sem_take(&drv_data->gpio_sem, K_FOREVER);
bma280_fiber_cb(dev);
}
}
#endif
#ifdef CONFIG_BMA280_TRIGGER_GLOBAL_FIBER
static void bma280_work_cb(struct nano_work *work)
static void bma280_work_cb(struct k_work *work)
{
struct bma280_data *drv_data =
CONTAINER_OF(work, struct bma280_data, work);
@ -262,7 +262,7 @@ int bma280_init_interrupt(struct device *dev)
}
#if defined(CONFIG_BMA280_TRIGGER_OWN_FIBER)
nano_sem_init(&drv_data->gpio_sem);
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),

View file

@ -20,7 +20,7 @@
*/
#include <sensor.h>
#include <nanokernel.h>
#include <kernel.h>
#include <device.h>
#include <init.h>
#include <misc/byteorder.h>

View file

@ -124,7 +124,7 @@ struct bmc150_magn_trim_regs {
struct bmc150_magn_data {
struct device *i2c_master;
struct nano_sem sem;
struct k_sem sem;
#if defined(CONFIG_BMC150_MAGN_TRIGGER)
char __stack fiber_stack[CONFIG_BMC150_MAGN_TRIGGER_FIBER_STACK];

View file

@ -17,7 +17,7 @@
#include <device.h>
#include <gpio.h>
#include <misc/util.h>
#include <nanokernel.h>
#include <kernel.h>
#include <sensor.h>
#include "bmc150_magn.h"
@ -77,7 +77,7 @@ static void bmc150_magn_gpio_drdy_callback(struct device *dev,
gpio_pin_disable_callback(dev, config->gpio_drdy_int_pin);
nano_isr_sem_give(&data->sem);
k_sem_give(&data->sem);
}
static void bmc150_magn_fiber_main(int arg1, int gpio_pin)
@ -88,7 +88,7 @@ static void bmc150_magn_fiber_main(int arg1, int gpio_pin)
uint8_t reg_val;
while (1) {
nano_fiber_sem_take(&data->sem, TICKS_UNLIMITED);
k_sem_take(&data->sem, K_FOREVER);
while (i2c_reg_read_byte(data->i2c_master,
config->i2c_slave_addr,
@ -143,7 +143,7 @@ int bmc150_magn_init_interrupt(struct device *dev)
data->handler_drdy = NULL;
nano_sem_init(&data->sem);
k_sem_init(&data->sem, 0, UINT_MAX);
task_fiber_start(data->fiber_stack,
CONFIG_BMC150_MAGN_TRIGGER_FIBER_STACK,

View file

@ -16,7 +16,7 @@
* limitations under the License.
*/
#include <nanokernel.h>
#include <kernel.h>
#include <i2c.h>
#include <sensor.h>
#include <init.h>

View file

@ -21,7 +21,7 @@
#include <init.h>
#include <sensor.h>
#include <misc/byteorder.h>
#include <nanokernel.h>
#include <kernel.h>
#include "bmg160.h"
@ -49,14 +49,14 @@ int bmg160_read(struct device *dev, uint8_t reg_addr, uint8_t *data,
bmg160_bus_config(dev);
nano_sem_take(&bmg160->sem, TICKS_UNLIMITED);
k_sem_take(&bmg160->sem, K_FOREVER);
if (i2c_burst_read(bmg160->i2c, dev_cfg->i2c_addr,
reg_addr, data, len) < 0) {
ret = -EIO;
}
nano_sem_give(&bmg160->sem);
k_sem_give(&bmg160->sem);
return ret;
}
@ -75,14 +75,14 @@ static int bmg160_write(struct device *dev, uint8_t reg_addr, uint8_t *data,
bmg160_bus_config(dev);
nano_sem_take(&bmg160->sem, TICKS_UNLIMITED);
k_sem_take(&bmg160->sem, K_FOREVER);
if (i2c_burst_write(bmg160->i2c, dev_cfg->i2c_addr,
reg_addr, data, len) < 0) {
ret = -EIO;
}
nano_sem_give(&bmg160->sem);
k_sem_give(&bmg160->sem);
return ret;
}
@ -101,14 +101,14 @@ int bmg160_update_byte(struct device *dev, uint8_t reg_addr, uint8_t mask,
bmg160_bus_config(dev);
nano_sem_take(&bmg160->sem, TICKS_UNLIMITED);
k_sem_take(&bmg160->sem, K_FOREVER);
if (i2c_reg_update_byte(bmg160->i2c, dev_cfg->i2c_addr,
reg_addr, mask, value) < 0) {
ret = -EIO;
}
nano_sem_give(&bmg160->sem);
k_sem_give(&bmg160->sem);
return ret;
}
@ -301,8 +301,8 @@ int bmg160_init(struct device *dev)
return -EINVAL;
}
nano_sem_init(&bmg160->sem);
nano_sem_give(&bmg160->sem);
k_sem_init(&bmg160->sem, 0, UINT_MAX);
k_sem_give(&bmg160->sem);
if (bmg160_read_byte(dev, BMG160_REG_CHIPID, &chip_id) < 0) {
SYS_LOG_DBG("Failed to read chip id.");

View file

@ -22,7 +22,6 @@
#include <i2c.h>
#include <gpio.h>
#include <misc/util.h>
#include <misc/nano_work.h>
/* registers */
#define BMG160_REG_CHIPID 0x00
@ -207,11 +206,11 @@ struct bmg160_device_data {
struct gpio_callback gpio_cb;
#endif
#ifdef CONFIG_BMG160_TRIGGER_OWN_FIBER
struct nano_sem trig_sem;
struct k_sem trig_sem;
#endif
struct nano_sem sem;
struct k_sem sem;
#ifdef CONFIG_BMG160_TRIGGER_GLOBAL_FIBER
struct nano_work work;
struct k_work work;
struct device *dev;
#endif
#ifdef CONFIG_BMG160_TRIGGER

View file

@ -18,7 +18,7 @@
* http://ae-bst.resource.bosch.com/media/_tech/media/datasheets/BST-BMG160-DS000-09.pdf
*/
#include <nanokernel.h>
#include <kernel.h>
#include <sensor.h>
#include "bmg160.h"
@ -32,9 +32,9 @@ static void bmg160_gpio_callback(struct device *port, struct gpio_callback *cb,
CONTAINER_OF(cb, struct bmg160_device_data, gpio_cb);
#if defined(CONFIG_BMG160_TRIGGER_OWN_FIBER)
nano_isr_sem_give(&bmg160->trig_sem);
k_sem_give(&bmg160->trig_sem);
#elif defined(CONFIG_BMG160_TRIGGER_GLOBAL_FIBER)
nano_work_submit(&bmg160->work);
k_work_submit(&bmg160->work);
#endif
}
@ -186,7 +186,7 @@ static void bmg160_fiber_main(int arg1, int unused)
struct bmg160_device_data *bmg160 = dev->driver_data;
while (true) {
nano_fiber_sem_take(&bmg160->trig_sem, TICKS_UNLIMITED);
k_sem_take(&bmg160->trig_sem, K_FOREVER);
bmg160_handle_int(dev);
}
@ -194,7 +194,7 @@ static void bmg160_fiber_main(int arg1, int unused)
#endif
#ifdef CONFIG_BMG160_TRIGGER_GLOBAL_FIBER
static void bmg160_work_cb(struct nano_work *work)
static void bmg160_work_cb(struct k_work *work)
{
struct bmg160_device_data *bmg160 =
CONTAINER_OF(work, struct bmg160_device_data, work);
@ -242,7 +242,7 @@ int bmg160_trigger_init(struct device *dev)
}
#if defined(CONFIG_BMG160_TRIGGER_OWN_FIBER)
nano_sem_init(&bmg160->trig_sem);
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)

View file

@ -22,7 +22,7 @@
#include <sensor.h>
#include <spi.h>
#include <misc/byteorder.h>
#include <nanokernel.h>
#include <kernel.h>
#include <misc/__assert.h>
#include "bmi160.h"

View file

@ -20,7 +20,6 @@
#include <gpio.h>
#include <misc/util.h>
#include <misc/nano_work.h>
/* registers */
#define BMI160_REG_CHIPID 0x00
@ -455,11 +454,11 @@ struct bmi160_device_data {
struct bmi160_scale scale;
#ifdef CONFIG_BMI160_TRIGGER_OWN_FIBER
struct nano_sem sem;
struct k_sem sem;
#endif
#ifdef CONFIG_BMI160_TRIGGER_GLOBAL_FIBER
struct nano_work work;
struct k_work work;
struct device *dev;
#endif

View file

@ -15,7 +15,7 @@
* limitations under the License.
*/
#include <nanokernel.h>
#include <kernel.h>
#include <sensor.h>
#ifdef CONFIG_BMI160_TRIGGER_SOURCE_GPIO
@ -101,14 +101,14 @@ static void bmi160_fiber_main(int arg1, int unused)
struct bmi160_device_data *bmi160 = dev->driver_data;
while (1) {
nano_fiber_sem_take(&bmi160->sem, TICKS_UNLIMITED);
k_sem_take(&bmi160->sem, K_FOREVER);
bmi160_handle_interrupts(dev);
}
}
#endif
#ifdef CONFIG_BMI160_TRIGGER_GLOBAL_FIBER
static void bmi160_work_handler(struct nano_work *work)
static void bmi160_work_handler(struct k_work *work)
{
struct bmi160_device_data *bmi160 =
CONTAINER_OF(work, struct bmi160_device_data, work);
@ -127,9 +127,9 @@ static void bmi160_gpio_callback(struct device *port,
CONTAINER_OF(cb, struct bmi160_device_data, gpio_cb);
#if defined(CONFIG_BMI160_TRIGGER_OWN_FIBER)
nano_sem_give(&bmi160->sem);
k_sem_give(&bmi160->sem);
#elif defined(CONFIG_BMI160_TRIGGER_GLOBAL_FIBER)
nano_work_submit(&bmi160->work);
k_work_submit(&bmi160->work);
#endif
}
#else
@ -140,9 +140,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)
nano_sem_give(&bmi160->sem);
k_sem_give(&bmi160->sem);
#elif defined(CONFIG_BMI160_TRIGGER_GLOBAL_FIBER)
nano_work_submit(&bmi160->work);
k_work_submit(&bmi160->work);
#endif
}
#endif
@ -321,7 +321,7 @@ int bmi160_trigger_mode_init(struct device *dev)
#endif
#if defined(CONFIG_BMI160_TRIGGER_OWN_FIBER)
nano_sem_init(&bmi160->sem);
k_sem_init(&bmi160->sem, 0, UINT_MAX);
fiber_start(bmi160_fiber_stack, CONFIG_BMI160_FIBER_STACK_SIZE,
bmi160_fiber_main, (int)dev, 0,

View file

@ -33,7 +33,7 @@ static int fxos8700_sample_fetch(struct device *dev, enum sensor_channel chan)
return -ENOTSUP;
}
nano_sem_take(&data->sem, TICKS_UNLIMITED);
k_sem_take(&data->sem, K_FOREVER);
/* Read all the channels in one I2C transaction. The number of bytes to
* read and the starting register address depend on the mode
@ -65,7 +65,7 @@ static int fxos8700_sample_fetch(struct device *dev, enum sensor_channel chan)
}
exit:
nano_sem_give(&data->sem);
k_sem_give(&data->sem);
return ret;
}
@ -123,7 +123,7 @@ static int fxos8700_channel_get(struct device *dev, enum sensor_channel chan,
int ret;
int i;
nano_sem_take(&data->sem, TICKS_UNLIMITED);
k_sem_take(&data->sem, K_FOREVER);
/* Start with an error return code by default, then clear it if we find
* a supported sensor channel.
@ -209,7 +209,7 @@ static int fxos8700_channel_get(struct device *dev, enum sensor_channel chan,
SYS_LOG_DBG("Unsupported sensor channel");
}
nano_sem_give(&data->sem);
k_sem_give(&data->sem);
return ret;
}
@ -294,8 +294,8 @@ static int fxos8700_init(struct device *dev)
return -EIO;
}
nano_sem_init(&data->sem);
nano_sem_give(&data->sem);
k_sem_init(&data->sem, 0, UINT_MAX);
k_sem_give(&data->sem);
SYS_LOG_DBG("Init complete");

View file

@ -96,6 +96,6 @@ struct fxos8700_config {
struct fxos8700_data {
struct device *i2c;
struct nano_sem sem;
struct k_sem sem;
int16_t raw[FXOS8700_MAX_NUM_CHANNELS];
};

View file

@ -17,7 +17,7 @@
#include <device.h>
#include <i2c.h>
#include <gpio.h>
#include <nanokernel.h>
#include <kernel.h>
#include <sensor.h>
#include <misc/util.h>
#include <misc/__assert.h>
@ -33,7 +33,7 @@ static void hdc1008_gpio_callback(struct device *dev,
ARG_UNUSED(pins);
gpio_pin_disable_callback(dev, CONFIG_HDC1008_GPIO_PIN_NUM);
nano_sem_give(&drv_data->data_sem);
k_sem_give(&drv_data->data_sem);
}
static int hdc1008_sample_fetch(struct device *dev, enum sensor_channel chan)
@ -51,7 +51,7 @@ static int hdc1008_sample_fetch(struct device *dev, enum sensor_channel chan)
return -EIO;
}
nano_sem_take(&drv_data->data_sem, TICKS_UNLIMITED);
k_sem_take(&drv_data->data_sem, K_FOREVER);
if (i2c_read(drv_data->i2c, buf, 4, HDC1008_I2C_ADDRESS) < 0) {
SYS_LOG_DBG("Failed to read sample data");
@ -130,7 +130,7 @@ static int hdc1008_init(struct device *dev)
return -EINVAL;
}
nano_sem_init(&drv_data->data_sem);
k_sem_init(&drv_data->data_sem, 0, UINT_MAX);
/* setup data ready gpio interrupt */
drv_data->gpio = device_get_binding(CONFIG_HDC1008_GPIO_DEV_NAME);

View file

@ -17,7 +17,7 @@
#ifndef _SENSOR_HDC1008
#define _SENSOR_HDC1008
#include <nanokernel.h>
#include <kernel.h>
#define HDC1008_I2C_ADDRESS 0x40
@ -32,7 +32,7 @@ struct hdc1008_data {
struct gpio_callback gpio_cb;
uint16_t t_sample;
uint16_t rh_sample;
struct nano_sem data_sem;
struct k_sem data_sem;
};
#define SYS_LOG_DOMAIN "HDC1008"

View file

@ -21,7 +21,6 @@
#include <misc/util.h>
#include <stdint.h>
#include <gpio.h>
#include <misc/nano_work.h>
#define SYS_LOG_DOMAIN "HMC5883L"
#define SYS_LOG_LEVEL CONFIG_SYS_LOG_SENSOR_LEVEL
@ -73,9 +72,9 @@ struct hmc5883l_data {
#if defined(CONFIG_HMC5883L_TRIGGER_OWN_FIBER)
char __stack fiber_stack[CONFIG_HMC5883L_FIBER_STACK_SIZE];
struct nano_sem gpio_sem;
struct k_sem gpio_sem;
#elif defined(CONFIG_HMC5883L_TRIGGER_GLOBAL_FIBER)
struct nano_work work;
struct k_work work;
struct device *dev;
#endif

View file

@ -18,7 +18,7 @@
#include <i2c.h>
#include <misc/__assert.h>
#include <misc/util.h>
#include <nanokernel.h>
#include <kernel.h>
#include <sensor.h>
#include "hmc5883l.h"
@ -56,9 +56,9 @@ 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)
nano_sem_give(&drv_data->gpio_sem);
k_sem_give(&drv_data->gpio_sem);
#elif defined(CONFIG_HMC5883L_TRIGGER_GLOBAL_FIBER)
nano_work_submit(&drv_data->work);
k_work_submit(&drv_data->work);
#endif
}
@ -84,14 +84,14 @@ static void hmc5883l_fiber(int dev_ptr, int unused)
ARG_UNUSED(unused);
while (1) {
nano_fiber_sem_take(&drv_data->gpio_sem, TICKS_UNLIMITED);
k_sem_take(&drv_data->gpio_sem, K_FOREVER);
hmc5883l_fiber_cb(dev);
}
}
#endif
#ifdef CONFIG_HMC5883L_TRIGGER_GLOBAL_FIBER
static void hmc5883l_work_cb(struct nano_work *work)
static void hmc5883l_work_cb(struct k_work *work)
{
struct hmc5883l_data *drv_data =
CONTAINER_OF(work, struct hmc5883l_data, work);
@ -126,7 +126,7 @@ int hmc5883l_init_interrupt(struct device *dev)
}
#if defined(CONFIG_HMC5883L_TRIGGER_OWN_FIBER)
nano_sem_init(&drv_data->gpio_sem);
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),

View file

@ -22,7 +22,7 @@
#include <sensor.h>
#include <i2c.h>
#include <misc/byteorder.h>
#include <nanokernel.h>
#include <kernel.h>
#include <gpio.h>
#include "hp206c.h"
@ -181,10 +181,10 @@ static int hp206c_wait_dev_ready(struct device *dev, uint32_t timeout_ms)
uint8_t int_src;
#ifdef CONFIG_NANO_TIMERS
nano_timer_start(&hp206c->tmr, MSEC(timeout_ms));
nano_timer_test(&hp206c->tmr, TICKS_UNLIMITED);
k_timer_start(&hp206c->tmr, MSEC(timeout_ms), 0);
k_timer_status_sync(&hp206c->tmr);
#else
sys_thread_busy_wait(timeout_ms * 1000);
k_busy_wait(timeout_ms * 1000);
#endif
if (hp206c_read_reg(dev, HP206C_REG_INT_SRC, &int_src) < 0) {
@ -320,7 +320,7 @@ static int hp206c_init(struct device *dev)
}
#ifdef CONFIG_NANO_TIMERS
nano_timer_init(&hp206c->tmr, NULL);
k_timer_init(&hp206c->tmr, NULL, NULL);
#endif
sys_thread_busy_wait(500);

View file

@ -21,7 +21,6 @@
#include <misc/util.h>
#include <stdint.h>
#include <gpio.h>
#include <misc/nano_work.h>
#define SYS_LOG_DOMAIN "HTS221"
#define SYS_LOG_LEVEL CONFIG_SYS_LOG_SENSOR_LEVEL
@ -71,9 +70,9 @@ struct hts221_data {
#if defined(CONFIG_HTS221_TRIGGER_OWN_FIBER)
char __stack fiber_stack[CONFIG_HTS221_FIBER_STACK_SIZE];
struct nano_sem gpio_sem;
struct k_sem gpio_sem;
#elif defined(CONFIG_HTS221_TRIGGER_GLOBAL_FIBER)
struct nano_work work;
struct k_work work;
struct device *dev;
#endif

View file

@ -18,7 +18,7 @@
#include <i2c.h>
#include <misc/__assert.h>
#include <misc/util.h>
#include <nanokernel.h>
#include <kernel.h>
#include <sensor.h>
#include "hts221.h"
@ -56,9 +56,9 @@ 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)
nano_sem_give(&drv_data->gpio_sem);
k_sem_give(&drv_data->gpio_sem);
#elif defined(CONFIG_HTS221_TRIGGER_GLOBAL_FIBER)
nano_work_submit(&drv_data->work);
k_work_submit(&drv_data->work);
#endif
}
@ -84,14 +84,14 @@ static void hts221_fiber(int dev_ptr, int unused)
ARG_UNUSED(unused);
while (1) {
nano_fiber_sem_take(&drv_data->gpio_sem, TICKS_UNLIMITED);
k_sem_take(&drv_data->gpio_sem, K_FOREVER);
hts221_fiber_cb(dev);
}
}
#endif
#ifdef CONFIG_HTS221_TRIGGER_GLOBAL_FIBER
static void hts221_work_cb(struct nano_work *work)
static void hts221_work_cb(struct k_work *work)
{
struct hts221_data *drv_data =
CONTAINER_OF(work, struct hts221_data, work);
@ -133,7 +133,7 @@ int hts221_init_interrupt(struct device *dev)
}
#if defined(CONFIG_HTS221_TRIGGER_OWN_FIBER)
nano_sem_init(&drv_data->gpio_sem);
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),

View file

@ -16,7 +16,7 @@
* limitations under the License.
*/
#include <nanokernel.h>
#include <kernel.h>
#include <init.h>
#include <i2c.h>
#include <sensor.h>

View file

@ -20,10 +20,9 @@
#define _SENSOR_ISL29035_H_
#include <device.h>
#include <nanokernel.h>
#include <kernel.h>
#include <sensor.h>
#include <gpio.h>
#include <misc/nano_work.h>
#define ISL29035_I2C_ADDRESS 0x44
@ -134,9 +133,9 @@ struct isl29035_driver_data {
#if defined(CONFIG_ISL29035_TRIGGER_OWN_FIBER)
char __stack fiber_stack[CONFIG_ISL29035_FIBER_STACK_SIZE];
struct nano_sem gpio_sem;
struct k_sem gpio_sem;
#elif defined(CONFIG_ISL29035_TRIGGER_GLOBAL_FIBER)
struct nano_work work;
struct k_work work;
struct device *dev;
#endif

View file

@ -18,7 +18,7 @@
#include <i2c.h>
#include <misc/util.h>
#include <nanokernel.h>
#include <kernel.h>
#include "isl29035.h"
@ -85,9 +85,9 @@ 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)
nano_sem_give(&drv_data->gpio_sem);
k_sem_give(&drv_data->gpio_sem);
#elif defined(CONFIG_ISL29035_TRIGGER_GLOBAL_FIBER)
nano_work_submit(&drv_data->work);
k_work_submit(&drv_data->work);
#endif
}
@ -116,14 +116,14 @@ static void isl29035_fiber(int ptr, int unused)
ARG_UNUSED(unused);
while (1) {
nano_fiber_sem_take(&drv_data->gpio_sem, TICKS_UNLIMITED);
k_sem_take(&drv_data->gpio_sem, K_FOREVER);
isl29035_fiber_cb(dev);
}
}
#endif
#ifdef CONFIG_ISL29035_TRIGGER_GLOBAL_FIBER
static void isl29035_work_cb(struct nano_work *work)
static void isl29035_work_cb(struct k_work *work)
{
struct isl29035_driver_data *drv_data =
CONTAINER_OF(work, struct isl29035_driver_data, work);
@ -184,7 +184,7 @@ int isl29035_init_interrupt(struct device *dev)
}
#if defined(CONFIG_ISL29035_TRIGGER_OWN_FIBER)
nano_sem_init(&drv_data->gpio_sem);
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),

View file

@ -21,7 +21,6 @@
#include <misc/util.h>
#include <stdint.h>
#include <gpio.h>
#include <misc/nano_work.h>
#define LIS3DH_I2C_ADDRESS CONFIG_LIS3DH_I2C_ADDR
@ -105,9 +104,9 @@ struct lis3dh_data {
#if defined(CONFIG_LIS3DH_TRIGGER_OWN_FIBER)
char __stack fiber_stack[CONFIG_LIS3DH_FIBER_STACK_SIZE];
struct nano_sem gpio_sem;
struct k_sem gpio_sem;
#elif defined(CONFIG_LIS3DH_TRIGGER_GLOBAL_FIBER)
struct nano_work work;
struct k_work work;
struct device *dev;
#endif

View file

@ -17,7 +17,7 @@
#include <device.h>
#include <i2c.h>
#include <misc/util.h>
#include <nanokernel.h>
#include <kernel.h>
#include <sensor.h>
#include "lis3dh.h"
@ -56,9 +56,9 @@ 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)
nano_sem_give(&drv_data->gpio_sem);
k_sem_give(&drv_data->gpio_sem);
#elif defined(CONFIG_LIS3DH_TRIGGER_GLOBAL_FIBER)
nano_work_submit(&drv_data->work);
k_work_submit(&drv_data->work);
#endif
}
@ -84,14 +84,14 @@ static void lis3dh_fiber(int dev_ptr, int unused)
ARG_UNUSED(unused);
while (1) {
nano_fiber_sem_take(&drv_data->gpio_sem, TICKS_UNLIMITED);
k_sem_take(&drv_data->gpio_sem, K_FOREVER);
lis3dh_fiber_cb(dev);
}
}
#endif
#ifdef CONFIG_LIS3DH_TRIGGER_GLOBAL_FIBER
static void lis3dh_work_cb(struct nano_work *work)
static void lis3dh_work_cb(struct k_work *work)
{
struct lis3dh_data *drv_data =
CONTAINER_OF(work, struct lis3dh_data, work);
@ -139,7 +139,7 @@ int lis3dh_init_interrupt(struct device *dev)
}
#if defined(CONFIG_LIS3DH_TRIGGER_OWN_FIBER)
nano_sem_init(&drv_data->gpio_sem);
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),

View file

@ -21,7 +21,6 @@
#include <misc/util.h>
#include <stdint.h>
#include <gpio.h>
#include <misc/nano_work.h>
#define SYS_LOG_DOMAIN "LIS3MDL"
#define SYS_LOG_LEVEL CONFIG_SYS_LOG_SENSOR_LEVEL
@ -119,9 +118,9 @@ struct lis3mdl_data {
#if defined(CONFIG_LIS3MDL_TRIGGER_OWN_FIBER)
char __stack fiber_stack[CONFIG_LIS3MDL_FIBER_STACK_SIZE];
struct nano_sem gpio_sem;
struct k_sem gpio_sem;
#elif defined(CONFIG_LIS3MDL_TRIGGER_GLOBAL_FIBER)
struct nano_work work;
struct k_work work;
struct device *dev;
#endif

View file

@ -18,7 +18,7 @@
#include <i2c.h>
#include <misc/__assert.h>
#include <misc/util.h>
#include <nanokernel.h>
#include <kernel.h>
#include <sensor.h>
#include "lis3mdl.h"
@ -56,9 +56,9 @@ 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)
nano_sem_give(&drv_data->gpio_sem);
k_sem_give(&drv_data->gpio_sem);
#elif defined(CONFIG_LIS3MDL_TRIGGER_GLOBAL_FIBER)
nano_work_submit(&drv_data->work);
k_work_submit(&drv_data->work);
#endif
}
@ -84,14 +84,14 @@ static void lis3mdl_fiber(int dev_ptr, int unused)
ARG_UNUSED(unused);
while (1) {
nano_fiber_sem_take(&drv_data->gpio_sem, TICKS_UNLIMITED);
k_sem_take(&drv_data->gpio_sem, K_FOREVER);
lis3mdl_fiber_cb(dev);
}
}
#endif
#ifdef CONFIG_LIS3MDL_TRIGGER_GLOBAL_FIBER
static void lis3mdl_work_cb(struct nano_work *work)
static void lis3mdl_work_cb(struct k_work *work)
{
struct lis3mdl_data *drv_data =
CONTAINER_OF(work, struct lis3mdl_data, work);
@ -139,7 +139,7 @@ int lis3mdl_init_interrupt(struct device *dev)
}
#if defined(CONFIG_LIS3MDL_TRIGGER_OWN_FIBER)
nano_sem_init(&drv_data->gpio_sem);
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),

View file

@ -17,7 +17,7 @@
*/
#include <sensor.h>
#include <nanokernel.h>
#include <kernel.h>
#include <device.h>
#include <init.h>
#include <misc/byteorder.h>

View file

@ -19,7 +19,7 @@
*/
#include <sensor.h>
#include <nanokernel.h>
#include <kernel.h>
#include <device.h>
#include <init.h>
#include <misc/byteorder.h>

View file

@ -17,7 +17,7 @@
*/
#include <sensor.h>
#include <nanokernel.h>
#include <kernel.h>
#include <device.h>
#include <init.h>
#include <misc/byteorder.h>

View file

@ -235,7 +235,7 @@ struct lsm9ds0_gyro_data {
struct device *i2c_master;
#if defined(CONFIG_LSM9DS0_GYRO_TRIGGERS)
struct nano_sem sem;
struct k_sem sem;
#endif
#if defined(CONFIG_LSM9DS0_GYRO_TRIGGER_DRDY)

View file

@ -15,7 +15,7 @@
*/
#include <sensor.h>
#include <nanokernel.h>
#include <kernel.h>
#include <device.h>
#include <init.h>
#include <i2c.h>
@ -77,7 +77,7 @@ static void lsm9ds0_gyro_gpio_drdy_callback(struct device *dev,
gpio_pin_disable_callback(dev, config->gpio_drdy_int_pin);
nano_isr_sem_give(&data->sem);
k_sem_give(&data->sem);
}
static void lsm9ds0_gyro_fiber_main(int arg1, int gpio_pin)
@ -86,7 +86,7 @@ static void lsm9ds0_gyro_fiber_main(int arg1, int gpio_pin)
struct lsm9ds0_gyro_data *data = dev->driver_data;
while (1) {
nano_fiber_sem_take(&data->sem, TICKS_UNLIMITED);
k_sem_take(&data->sem, K_FOREVER);
if (data->handler_drdy) {
data->handler_drdy(dev, &data->trigger_drdy);
@ -102,7 +102,7 @@ int lsm9ds0_gyro_init_interrupt(struct device *dev)
dev->config->config_info;
struct lsm9ds0_gyro_data *data = dev->driver_data;
nano_sem_init(&data->sem);
k_sem_init(&data->sem, 0, UINT_MAX);
task_fiber_start(data->fiber_stack,
CONFIG_LSM9DS0_GYRO_FIBER_STACK_SIZE,

View file

@ -19,7 +19,7 @@
*/
#include <sensor.h>
#include <nanokernel.h>
#include <kernel.h>
#include <device.h>
#include <init.h>
#include <i2c.h>

View file

@ -18,7 +18,7 @@
#include <errno.h>
#include <nanokernel.h>
#include <kernel.h>
#include <i2c.h>
#include <init.h>
#include <misc/byteorder.h>

View file

@ -24,7 +24,6 @@
#include <sensor.h>
#include <misc/util.h>
#include <gpio.h>
#include <misc/nano_work.h>
#define MCP9808_REG_CONFIG 0x01
#define MCP9808_REG_UPPER_LIMIT 0x02
@ -52,11 +51,11 @@ struct mcp9808_data {
struct gpio_callback gpio_cb;
#ifdef CONFIG_MCP9808_TRIGGER_OWN_FIBER
struct nano_sem sem;
struct k_sem sem;
#endif
#ifdef CONFIG_MCP9808_TRIGGER_GLOBAL_FIBER
struct nano_work work;
struct k_work work;
struct device *dev;
#endif

View file

@ -17,7 +17,7 @@
*/
#include <errno.h>
#include <nanokernel.h>
#include <kernel.h>
#include <i2c.h>
#include <misc/byteorder.h>
#include <misc/__assert.h>
@ -126,7 +126,7 @@ static void mcp9808_gpio_cb(struct device *dev,
ARG_UNUSED(pins);
nano_isr_sem_give(&data->sem);
k_sem_give(&data->sem);
}
static void mcp9808_fiber_main(int arg1, int arg2)
@ -137,7 +137,7 @@ static void mcp9808_fiber_main(int arg1, int arg2)
ARG_UNUSED(arg2);
while (1) {
nano_fiber_sem_take(&data->sem, TICKS_UNLIMITED);
k_sem_take(&data->sem, K_FOREVER);
data->trigger_handler(dev, &data->trig);
mcp9808_reg_update(data, MCP9808_REG_CONFIG,
MCP9808_INT_CLEAR, MCP9808_INT_CLEAR);
@ -156,10 +156,10 @@ static void mcp9808_gpio_cb(struct device *dev,
ARG_UNUSED(pins);
nano_work_submit(&data->work);
k_work_submit(&data->work);
}
static void mcp9808_gpio_fiber_cb(struct nano_work *work)
static void mcp9808_gpio_fiber_cb(struct k_work *work)
{
struct mcp9808_data *data =
CONTAINER_OF(work, struct mcp9808_data, work);
@ -184,7 +184,7 @@ void mcp9808_setup_interrupt(struct device *dev)
MCP9808_INT_CLEAR);
#ifdef CONFIG_MCP9808_TRIGGER_OWN_FIBER
nano_sem_init(&data->sem);
k_sem_init(&data->sem, 0, UINT_MAX);
fiber_fiber_start(mcp9808_fiber_stack,
CONFIG_MCP9808_FIBER_STACK_SIZE,

View file

@ -19,7 +19,6 @@
#include <device.h>
#include <gpio.h>
#include <misc/nano_work.h>
#include <misc/util.h>
#include <stdint.h>
@ -73,9 +72,9 @@ struct mpu6050_data {
#if defined(CONFIG_MPU6050_TRIGGER_OWN_FIBER)
char __stack fiber_stack[CONFIG_MPU6050_FIBER_STACK_SIZE];
struct nano_sem gpio_sem;
struct k_sem gpio_sem;
#elif defined(CONFIG_MPU6050_TRIGGER_GLOBAL_FIBER)
struct nano_work work;
struct k_work work;
struct device *dev;
#endif

View file

@ -17,7 +17,7 @@
#include <device.h>
#include <i2c.h>
#include <misc/util.h>
#include <nanokernel.h>
#include <kernel.h>
#include <sensor.h>
#include "mpu6050.h"
@ -57,9 +57,9 @@ 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)
nano_sem_give(&drv_data->gpio_sem);
k_sem_give(&drv_data->gpio_sem);
#elif defined(CONFIG_MPU6050_TRIGGER_GLOBAL_FIBER)
nano_work_submit(&drv_data->work);
k_work_submit(&drv_data->work);
#endif
}
@ -85,14 +85,14 @@ static void mpu6050_fiber(int dev_ptr, int unused)
ARG_UNUSED(unused);
while (1) {
nano_fiber_sem_take(&drv_data->gpio_sem, TICKS_UNLIMITED);
k_sem_take(&drv_data->gpio_sem, K_FOREVER);
mpu6050_fiber_cb(dev);
}
}
#endif
#ifdef CONFIG_MPU6050_TRIGGER_GLOBAL_FIBER
static void mpu6050_work_cb(struct nano_work *work)
static void mpu6050_work_cb(struct k_work *work)
{
struct mpu6050_data *drv_data =
CONTAINER_OF(work, struct mpu6050_data, work);
@ -134,7 +134,7 @@ int mpu6050_init_interrupt(struct device *dev)
}
#if defined(CONFIG_MPU6050_TRIGGER_OWN_FIBER)
nano_sem_init(&drv_data->gpio_sem);
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),

View file

@ -16,7 +16,7 @@
#include <device.h>
#include <i2c.h>
#include <nanokernel.h>
#include <kernel.h>
#include <sensor.h>
#include <misc/__assert.h>

View file

@ -18,9 +18,8 @@
#define _SENSOR_SHT3XD_
#include <device.h>
#include <nanokernel.h>
#include <kernel.h>
#include <gpio.h>
#include <misc/nano_work.h>
#define SHT3XD_I2C_ADDRESS CONFIG_SHT3XD_I2C_ADDR
@ -87,9 +86,9 @@ struct sht3xd_data {
#if defined(CONFIG_SHT3XD_TRIGGER_OWN_FIBER)
char __stack fiber_stack[CONFIG_SHT3XD_FIBER_STACK_SIZE];
struct nano_sem gpio_sem;
struct k_sem gpio_sem;
#elif defined(CONFIG_SHT3XD_TRIGGER_GLOBAL_FIBER)
struct nano_work work;
struct k_work work;
struct device *dev;
#endif

View file

@ -16,7 +16,7 @@
#include <device.h>
#include <misc/util.h>
#include <nanokernel.h>
#include <kernel.h>
#include <sensor.h>
#include "sht3xd.h"
@ -118,9 +118,9 @@ 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)
nano_sem_give(&drv_data->gpio_sem);
k_sem_give(&drv_data->gpio_sem);
#elif defined(CONFIG_SHT3XD_TRIGGER_GLOBAL_FIBER)
nano_work_submit(&drv_data->work);
k_work_submit(&drv_data->work);
#endif
}
@ -145,14 +145,14 @@ static void sht3xd_fiber(int dev_ptr, int unused)
ARG_UNUSED(unused);
while (1) {
nano_fiber_sem_take(&drv_data->gpio_sem, TICKS_UNLIMITED);
k_sem_take(&drv_data->gpio_sem, K_FOREVER);
sht3xd_fiber_cb(dev);
}
}
#endif
#ifdef CONFIG_SHT3XD_TRIGGER_GLOBAL_FIBER
static void sht3xd_work_cb(struct nano_work *work)
static void sht3xd_work_cb(struct k_work *work)
{
struct sht3xd_data *drv_data =
CONTAINER_OF(work, struct sht3xd_data, work);
@ -233,7 +233,7 @@ int sht3xd_init_interrupt(struct device *dev)
}
#if defined(CONFIG_SHT3XD_TRIGGER_OWN_FIBER)
nano_sem_init(&drv_data->gpio_sem);
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),

View file

@ -18,7 +18,7 @@
#include <errno.h>
#include <nanokernel.h>
#include <kernel.h>
#include <i2c.h>
#include <sensor.h>
#include <init.h>

View file

@ -19,7 +19,6 @@
#include <stdint.h>
#include <device.h>
#include <misc/nano_work.h>
#define SX9500_REG_IRQ_SRC 0x00
#define SX9500_REG_STAT 0x01
@ -43,11 +42,11 @@ struct sx9500_data {
struct gpio_callback gpio_cb;
#ifdef CONFIG_SX9500_TRIGGER_OWN_FIBER
struct nano_sem sem;
struct k_sem sem;
#endif
#ifdef CONFIG_SX9500_TRIGGER_GLOBAL_FIBER
struct nano_work work;
struct k_work work;
struct device *dev;
#endif

View file

@ -16,7 +16,7 @@
#include <errno.h>
#include <nanokernel.h>
#include <kernel.h>
#include <i2c.h>
#include <sensor.h>
#include <gpio.h>
@ -75,7 +75,7 @@ static void sx9500_gpio_cb(struct device *port,
ARG_UNUSED(pins);
nano_isr_sem_give(&data->sem);
k_sem_give(&data->sem);
}
static void sx9500_fiber_main(int arg1, int unused)
@ -87,7 +87,7 @@ static void sx9500_fiber_main(int arg1, int unused)
ARG_UNUSED(unused);
while (1) {
nano_fiber_sem_take(&data->sem, TICKS_UNLIMITED);
k_sem_take(&data->sem, K_FOREVER);
if (i2c_reg_read_byte(data->i2c_master, data->i2c_slave_addr,
SX9500_REG_IRQ_SRC, &reg_val) < 0) {
@ -115,7 +115,7 @@ static void sx9500_gpio_cb(struct device *port,
ARG_UNUSED(pins);
nano_work_submit(&data->work);
k_work_submit(&data->work);
}
static void sx9500_gpio_fiber_cb(void *arg)
@ -141,7 +141,7 @@ static void sx9500_gpio_fiber_cb(void *arg)
#endif /* CONFIG_SX9500_TRIGGER_GLOBAL_FIBER */
#ifdef CONFIG_SX9500_TRIGGER_GLOBAL_FIBER
static void sx9500_work_cb(struct nano_work *work)
static void sx9500_work_cb(struct k_work *work)
{
struct sx9500_data *data =
CONTAINER_OF(work, struct sx9500_data, work);
@ -156,7 +156,7 @@ int sx9500_setup_interrupt(struct device *dev)
struct device *gpio;
#ifdef CONFIG_SX9500_TRIGGER_OWN_FIBER
nano_sem_init(&data->sem);
k_sem_init(&data->sem, 0, UINT_MAX);
#else
data->work.handler = sx9500_work_cb;
data->dev = dev;

View file

@ -14,7 +14,7 @@
* limitations under the License.
*/
#include <nanokernel.h>
#include <kernel.h>
#include <device.h>
#include <i2c.h>
#include <misc/byteorder.h>

View file

@ -19,7 +19,7 @@
#include <gpio.h>
#include <misc/byteorder.h>
#include <misc/util.h>
#include <nanokernel.h>
#include <kernel.h>
#include <sensor.h>
#include <misc/__assert.h>

View file

@ -59,9 +59,9 @@ struct tmp007_data {
#if defined(CONFIG_TMP007_TRIGGER_OWN_FIBER)
char __stack fiber_stack[CONFIG_TMP007_FIBER_STACK_SIZE];
struct nano_sem gpio_sem;
struct k_sem gpio_sem;
#elif defined(CONFIG_TMP007_TRIGGER_GLOBAL_FIBER)
struct nano_work work;
struct k_work work;
struct device *dev;
#endif

View file

@ -17,7 +17,7 @@
#include <device.h>
#include <gpio.h>
#include <misc/util.h>
#include <nanokernel.h>
#include <kernel.h>
#include <sensor.h>
#include "tmp007.h"
@ -65,9 +65,9 @@ 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)
nano_sem_give(&drv_data->gpio_sem);
k_sem_give(&drv_data->gpio_sem);
#elif defined(CONFIG_TMP007_TRIGGER_GLOBAL_FIBER)
nano_work_submit(&drv_data->work);
k_work_submit(&drv_data->work);
#endif
}
@ -103,14 +103,14 @@ static void tmp007_fiber(int dev_ptr, int unused)
ARG_UNUSED(unused);
while (1) {
nano_fiber_sem_take(&drv_data->gpio_sem, TICKS_UNLIMITED);
k_sem_take(&drv_data->gpio_sem, K_FOREVER);
tmp007_fiber_cb(dev);
}
}
#endif
#ifdef CONFIG_TMP007_TRIGGER_GLOBAL_FIBER
static void tmp007_work_cb(struct nano_work *work)
static void tmp007_work_cb(struct k_work *work)
{
struct tmp007_data *drv_data =
CONTAINER_OF(work, struct tmp007_data, work);
@ -172,7 +172,7 @@ int tmp007_init_interrupt(struct device *dev)
}
#if defined(CONFIG_TMP007_TRIGGER_OWN_FIBER)
nano_sem_init(&drv_data->gpio_sem);
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),

View file

@ -18,7 +18,7 @@
#include <i2c.h>
#include <misc/byteorder.h>
#include <misc/util.h>
#include <nanokernel.h>
#include <kernel.h>
#include <sensor.h>
#include <misc/__assert.h>