sensor: akm09918c: Use RTIO workq on akm09918c_submit
To make its execution path non-blocking from the caller's perspective. Signed-off-by: Luis Ubieda <luisf@croxel.com>
This commit is contained in:
parent
aff6e31ec4
commit
59e8919da7
2 changed files with 17 additions and 1 deletions
|
|
@ -1,4 +1,5 @@
|
|||
# Copyright (c) 2023 Google LLC
|
||||
# Copyright (c) 2024 Croxel Inc.
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
config AKM09918C
|
||||
|
|
@ -6,6 +7,7 @@ config AKM09918C
|
|||
default y
|
||||
depends on DT_HAS_ASAHI_KASEI_AKM09918C_ENABLED
|
||||
select I2C
|
||||
select RTIO_WORKQ if SENSOR_ASYNC_API
|
||||
help
|
||||
Enable driver for AK8975 magnetometer.
|
||||
|
||||
|
|
|
|||
|
|
@ -1,16 +1,21 @@
|
|||
/*
|
||||
* Copyright (c) 2023 Google LLC
|
||||
* Copyright (c) 2024 Croxel Inc.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include <zephyr/logging/log.h>
|
||||
#include <zephyr/rtio/work.h>
|
||||
|
||||
#include "akm09918c.h"
|
||||
|
||||
LOG_MODULE_DECLARE(AKM09918C, CONFIG_SENSOR_LOG_LEVEL);
|
||||
|
||||
void akm09918c_submit(const struct device *dev, struct rtio_iodev_sqe *iodev_sqe)
|
||||
void akm09918c_submit_sync(struct rtio_iodev_sqe *iodev_sqe)
|
||||
{
|
||||
const struct sensor_read_config *cfg = iodev_sqe->sqe.iodev->data;
|
||||
const struct device *dev = cfg->sensor;
|
||||
uint32_t min_buf_len = sizeof(struct akm09918c_encoded_data);
|
||||
int rc;
|
||||
uint8_t *buf;
|
||||
|
|
@ -38,3 +43,12 @@ void akm09918c_submit(const struct device *dev, struct rtio_iodev_sqe *iodev_sqe
|
|||
|
||||
rtio_iodev_sqe_ok(iodev_sqe, 0);
|
||||
}
|
||||
|
||||
void akm09918c_submit(const struct device *dev, struct rtio_iodev_sqe *iodev_sqe)
|
||||
{
|
||||
struct rtio_work_req *req = rtio_work_req_alloc();
|
||||
|
||||
__ASSERT_NO_MSG(req);
|
||||
|
||||
rtio_work_req_submit(req, iodev_sqe, akm09918c_submit_sync);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue