sensor: icm42688: Use RTIO workq on icm42688_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:
Luis Ubieda 2024-06-19 17:31:32 -04:00 committed by Anas Nashif
parent 8d0c2f15df
commit 00a3be90d7
2 changed files with 15 additions and 1 deletions

View file

@ -1,6 +1,7 @@
# ICM42688-P Six-Axis Motion Tracking device configuration options
#
# Copyright (c) 2022 Intel Corporation
# Copyright (c) 2024 Croxel Inc.
#
# SPDX-License-Identifier: Apache-2.0
@ -9,6 +10,7 @@ menuconfig ICM42688
default y
depends on DT_HAS_INVENSENSE_ICM42688_ENABLED
select SPI
select RTIO_WORKQ if SENSOR_ASYNC_API
help
Enable driver for ICM42688 SPI-based six-axis motion tracking device.

View file

@ -1,10 +1,12 @@
/*
* Copyright (c) 2023 Google LLC
* Copyright (c) 2024 Croxel Inc.
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <zephyr/drivers/sensor.h>
#include <zephyr/rtio/work.h>
#include "icm42688.h"
#include "icm42688_decoder.h"
#include "icm42688_reg.h"
@ -77,9 +79,10 @@ static void icm42688_submit_one_shot(const struct device *dev, struct rtio_iodev
rtio_iodev_sqe_ok(iodev_sqe, 0);
}
void icm42688_submit(const struct device *dev, struct rtio_iodev_sqe *iodev_sqe)
void icm42688_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;
if (!cfg->is_streaming) {
icm42688_submit_one_shot(dev, iodev_sqe);
@ -90,4 +93,13 @@ void icm42688_submit(const struct device *dev, struct rtio_iodev_sqe *iodev_sqe)
}
}
void icm42688_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, icm42688_submit_sync);
}
BUILD_ASSERT(sizeof(struct icm42688_decoder_header) == 9);