Skip to content

Commit 8d0c2f1

Browse files
ubiedanashif
authored andcommitted
sensor: bme280: Use RTIO workq on bme280_submit
To make its execution path non-blocking from the caller's perspective. Signed-off-by: Luis Ubieda <[email protected]>
1 parent 5521fc4 commit 8d0c2f1

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

drivers/sensor/bosch/bme280/Kconfig

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
# Copyright (c) 2016 Intel Corporation
44
# Copyright (c) 2017 IpTronix S.r.l.
5+
# Copyright (c) 2024 Croxel Inc.
56
# SPDX-License-Identifier: Apache-2.0
67

78
menuconfig BME280
@@ -10,6 +11,7 @@ menuconfig BME280
1011
depends on DT_HAS_BOSCH_BME280_ENABLED
1112
select I2C if $(dt_compat_on_bus,$(DT_COMPAT_BOSCH_BME280),i2c)
1213
select SPI if $(dt_compat_on_bus,$(DT_COMPAT_BOSCH_BME280),spi)
14+
select RTIO_WORKQ if SENSOR_ASYNC_API
1315
help
1416
Enable driver for BME280 I2C-based or SPI-based temperature and pressure sensor.
1517

drivers/sensor/bosch/bme280/bme280_async.c

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,26 @@
11
/*
22
* Copyright (c) 2024 Intel Corporation
3+
* Copyright (c) 2024 Croxel Inc.
4+
*
35
* SPDX-License-Identifier: Apache-2.0
46
*/
57

8+
#include <zephyr/rtio/work.h>
69
#include <zephyr/logging/log.h>
710

811
#include "bme280.h"
912

1013
LOG_MODULE_DECLARE(BME280, CONFIG_SENSOR_LOG_LEVEL);
1114

12-
void bme280_submit(const struct device *dev, struct rtio_iodev_sqe *iodev_sqe)
15+
void bme280_submit_sync(struct rtio_iodev_sqe *iodev_sqe)
1316
{
1417
uint32_t min_buf_len = sizeof(struct bme280_encoded_data);
1518
int rc;
1619
uint8_t *buf;
1720
uint32_t buf_len;
1821

1922
const struct sensor_read_config *cfg = iodev_sqe->sqe.iodev->data;
23+
const struct device *dev = cfg->sensor;
2024
const struct sensor_chan_spec *const channels = cfg->channels;
2125
const size_t num_channels = cfg->count;
2226

@@ -67,3 +71,12 @@ void bme280_submit(const struct device *dev, struct rtio_iodev_sqe *iodev_sqe)
6771

6872
rtio_iodev_sqe_ok(iodev_sqe, 0);
6973
}
74+
75+
void bme280_submit(const struct device *dev, struct rtio_iodev_sqe *iodev_sqe)
76+
{
77+
struct rtio_work_req *req = rtio_work_req_alloc();
78+
79+
__ASSERT_NO_MSG(req);
80+
81+
rtio_work_req_submit(req, iodev_sqe, bme280_submit_sync);
82+
}

0 commit comments

Comments
 (0)