sensing: add Sensing Subsystem skeleton

Add Sensing Subsystem skeleton.

Signed-off-by: Guangfu Hu <guangfu.hu@intel.com>
Signed-off-by: Zhang Lixu <lixu.zhang@intel.com>
This commit is contained in:
Zhang Lixu 2023-02-06 16:43:11 +08:00 committed by Anas Nashif
parent 703ad12188
commit 685160b4bf
11 changed files with 218 additions and 0 deletions

View file

@ -0,0 +1,13 @@
# Copyright (c) 2023, Intel Corporation
# SPDX-License-Identifier: Apache-2.0
#
description: Sensing subsystem physical sensor properties bindings.
include: zephyr,sensing-sensor.yaml
properties:
underlying-device:
type: phandle
required: true
description: underlying sensor device for physical sensor

View file

@ -0,0 +1,25 @@
# Copyright (c) 2023, Intel Corporation
# SPDX-License-Identifier: Apache-2.0
#
description: Sensing subsystem sensor common properties bindings.
include: sensor-device.yaml
properties:
sensor-type:
type: int
required: true
description: sensor type id (follow HID spec definition)
friendly-name:
required: true
minimal-interval:
type: int
required: true
description: sensor minimal report interval
reporters:
type: phandles
description: sensor reporters

View file

@ -0,0 +1,9 @@
# Copyright (c) 2023, Intel Corporation
# SPDX-License-Identifier: Apache-2.0
#
description: Sensing Subsystem
compatible: "zephyr,sensing"
# To add sensor subsystem related common feature

View file

@ -32,6 +32,7 @@ add_subdirectory_ifdef(CONFIG_JWT jwt)
add_subdirectory_ifdef(CONFIG_LORAWAN lorawan)
add_subdirectory_ifdef(CONFIG_NET_BUF net)
add_subdirectory_ifdef(CONFIG_RETENTION retention)
add_subdirectory_ifdef(CONFIG_SENSING sensing)
add_subdirectory_ifdef(CONFIG_SETTINGS settings)
add_subdirectory_ifdef(CONFIG_SHELL shell)
add_subdirectory_ifdef(CONFIG_TIMING_FUNCTIONS timing)

View file

@ -31,6 +31,7 @@ source "subsys/random/Kconfig"
source "subsys/retention/Kconfig"
source "subsys/rtio/Kconfig"
source "subsys/sd/Kconfig"
source "subsys/sensing/Kconfig"
source "subsys/settings/Kconfig"
source "subsys/shell/Kconfig"
source "subsys/stats/Kconfig"

View file

@ -0,0 +1,10 @@
# SPDX-License-Identifier: Apache-2.0
zephyr_library()
zephyr_library_include_directories(include)
zephyr_library_sources(
sensor_mgmt.c
sensing.c
sensing_sensor.c
)

17
subsys/sensing/Kconfig Normal file
View file

@ -0,0 +1,17 @@
# Copyright (c) 2023 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
config SENSING
bool "Sensing Subsystem"
default y
depends on DT_HAS_ZEPHYR_SENSING_ENABLED
help
Enable Sensing Subsystem.
if SENSING
module = SENSING
module-str = sensing
source "subsys/logging/Kconfig.template.log_config"
endif # SENSING

51
subsys/sensing/sensing.c Normal file
View file

@ -0,0 +1,51 @@
/*
* Copyright (c) 2023 Intel Corporation.
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <zephyr/sensing/sensing.h>
#include <zephyr/sensing/sensing_sensor.h>
#include <zephyr/logging/log.h>
LOG_MODULE_DECLARE(sensing, CONFIG_SENSING_LOG_LEVEL);
/* sensing_open_sensor is normally called by applications: hid, chre, zephyr main, etc */
int sensing_open_sensor(const struct sensing_sensor_info *info,
const struct sensing_callback_list *cb_list,
sensing_sensor_handle_t *handle)
{
return -ENOTSUP;
}
int sensing_open_sensor_by_dt(const struct device *dev,
const struct sensing_callback_list *cb_list,
sensing_sensor_handle_t *handle)
{
return -ENOTSUP;
}
/* sensing_close_sensor is normally called by applications: hid, chre, zephyr main, etc */
int sensing_close_sensor(sensing_sensor_handle_t handle)
{
return -ENOTSUP;
}
int sensing_set_config(sensing_sensor_handle_t handle,
struct sensing_sensor_config *configs,
int count)
{
return -ENOTSUP;
}
int sensing_get_config(sensing_sensor_handle_t handle,
struct sensing_sensor_config *configs,
int count)
{
return -ENOTSUP;
}
const struct sensing_sensor_info *sensing_get_sensor_info(sensing_sensor_handle_t handle)
{
return NULL;
}

View file

@ -0,0 +1,28 @@
/*
* Copyright (c) 2023 Intel Corporation.
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <zephyr/kernel.h>
#include <zephyr/sensing/sensing.h>
#include <zephyr/sensing/sensing_sensor.h>
#include <zephyr/sys/__assert.h>
#include <zephyr/logging/log.h>
LOG_MODULE_DECLARE(sensing, CONFIG_SENSING_LOG_LEVEL);
int sensing_sensor_notify_data_ready(const struct device *dev)
{
return -ENOTSUP;
}
int sensing_sensor_set_data_ready(const struct device *dev, bool data_ready)
{
return -ENOTSUP;
}
int sensing_sensor_post_data(const struct device *dev, void *buf, int size)
{
return -ENOTSUP;
}

View file

@ -0,0 +1,32 @@
/*
* Copyright (c) 2023 Intel Corporation.
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <zephyr/sys/__assert.h>
#include <zephyr/devicetree.h>
#include <zephyr/device.h>
#include <zephyr/kernel.h>
#include <zephyr/sensing/sensing.h>
#include <zephyr/sensing/sensing_sensor.h>
#include <zephyr/logging/log.h>
#include <stdlib.h>
#include "sensor_mgmt.h"
#define DT_DRV_COMPAT zephyr_sensing
LOG_MODULE_REGISTER(sensing, CONFIG_SENSING_LOG_LEVEL);
static struct sensing_mgmt_context sensing_ctx = {0};
static int sensing_init(void)
{
return -ENOTSUP;
}
int sensing_get_sensors(int *sensor_nums, const struct sensing_sensor_info **info)
{
return 0;
}
SYS_INIT(sensing_init, APPLICATION, CONFIG_APPLICATION_INIT_PRIORITY);

View file

@ -0,0 +1,31 @@
/*
* Copyright (c) 2023 Intel Corporation.
*
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef SENSOR_MGMT_H_
#define SENSOR_MGMT_H_
#include <zephyr/sensing/sensing_datatypes.h>
#include <zephyr/sensing/sensing_sensor.h>
#ifdef __cplusplus
extern "C" {
#endif
struct sensing_mgmt_context {
bool sensing_initialized;
int sensor_num;
struct sensing_sensor_info *info;
};
/**
* @}
*/
#ifdef __cplusplus
}
#endif
#endif /* SENSOR_MGMT_H_ */