Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
luozhenger
rt-thread
提交
953a8c26
R
rt-thread
项目概览
luozhenger
/
rt-thread
与 Fork 源项目一致
Fork自
RT-Thread / rt-thread
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
rt-thread
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
953a8c26
编写于
11月 17, 2022
作者:
mysterywolf
提交者:
guo
11月 19, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add rt_sensor_float_t
上级
df397eb7
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
43 addition
and
38 deletion
+43
-38
components/drivers/Kconfig
components/drivers/Kconfig
+5
-1
components/drivers/include/drivers/sensor.h
components/drivers/include/drivers/sensor.h
+34
-33
components/drivers/sensors/sensor.c
components/drivers/sensors/sensor.c
+4
-4
未找到文件。
components/drivers/Kconfig
浏览文件 @
953a8c26
...
...
@@ -322,8 +322,12 @@ config RT_USING_SENSOR
if RT_USING_SENSOR
config RT_USING_SENSOR_CMD
bool "
Using Sensor cmd
"
bool "
Enable sensor commands
"
default y
config RT_USING_SENSOR_DOUBLE_FLOAT
bool "Using double floating as sensor data type"
default n
endif
config RT_USING_TOUCH
...
...
components/drivers/include/drivers/sensor.h
浏览文件 @
953a8c26
...
...
@@ -30,7 +30,6 @@ extern "C" {
#define RT_SENSOR_MODULE_MAX (3)
/* The maximum number of members of a sensor module */
/* Sensor types */
#define RT_SENSOR_CLASS_NONE (0)
#define RT_SENSOR_CLASS_ACCE (1)
/* Accelerometer */
#define RT_SENSOR_CLASS_GYRO (2)
/* Gyroscope */
...
...
@@ -55,7 +54,6 @@ extern "C" {
#define RT_SENSOR_CLASS_BP (21)
/* Blood Pressure */
/* Sensor vendor types */
#define RT_SENSOR_VENDOR_UNKNOWN (0)
#define RT_SENSOR_VENDOR_STM (1)
/* STMicroelectronics */
#define RT_SENSOR_VENDOR_BOSCH (2)
/* Bosch */
...
...
@@ -74,7 +72,6 @@ extern "C" {
#define RT_SENSOR_VENDOR_MELEXIS (15)
/* Melexis */
/* Sensor unit types */
#define RT_SENSOR_UNIT_NONE (0)
#define RT_SENSOR_UNIT_MG (1)
/* Accelerometer unit: mG */
#define RT_SENSOR_UNIT_MDPS (2)
/* Gyroscope unit: mdps */
...
...
@@ -95,15 +92,14 @@ extern "C" {
#define RT_SENSOR_UNIT_DD (17)
/* Coordinates unit: DD */
#define RT_SENSOR_UNIT_MGM3 (18)
/* Concentration unit: mg/m3 */
#define RT_SENSOR_UNIT_MMHG (19)
/* Blood Pressure unit: mmHg */
/* Sensor communication interface types */
/* Sensor communication interface types */
#define RT_SENSOR_INTF_I2C (1 << 0)
#define RT_SENSOR_INTF_SPI (1 << 1)
#define RT_SENSOR_INTF_UART (1 << 2)
#define RT_SENSOR_INTF_ONEWIRE (1 << 3)
/* Sensor power mode types */
#define RT_SENSOR_POWER_NONE (0)
#define RT_SENSOR_POWER_DOWN (1)
/* power down mode */
#define RT_SENSOR_POWER_NORMAL (2)
/* normal-power mode */
...
...
@@ -111,14 +107,12 @@ extern "C" {
#define RT_SENSOR_POWER_HIGH (4)
/* high-power mode */
/* Sensor work mode types */
#define RT_SENSOR_MODE_NONE (0)
#define RT_SENSOR_MODE_POLLING (1)
/* One shot only read a data */
#define RT_SENSOR_MODE_INT (2)
/* TODO: One shot interrupt only read a data */
#define RT_SENSOR_MODE_FIFO (3)
/* TODO: One shot interrupt read all fifo data */
/* Sensor control cmd types */
#define RT_SENSOR_CTRL_GET_ID (RT_DEVICE_CTRL_BASE(Sensor) + 0)
/* Get device id */
#define RT_SENSOR_CTRL_GET_INFO (RT_DEVICE_CTRL_BASE(Sensor) + 1)
/* Get sensor info */
#define RT_SENSOR_CTRL_SET_RANGE (RT_DEVICE_CTRL_BASE(Sensor) + 2)
/* Set the measure range of sensor. unit is info of sensor */
...
...
@@ -129,6 +123,13 @@ extern "C" {
#define RT_SENSOR_CTRL_USER_CMD_START 0x100
/* User commands should be greater than 0x100 */
/* sensor floating data type */
#ifdef RT_USING_SENSOR_DOUBLE_FLOAT
typedef
double
rt_sensor_float_t
;
#else
typedef
float
rt_sensor_float_t
;
#endif
/* RT_USING_SENSOR_DOUBLE_FLOAT */
struct
rt_sensor_info
{
rt_uint8_t
type
;
/* The sensor type */
...
...
@@ -190,22 +191,22 @@ struct rt_sensor_module
/* 3-axis Data Type */
struct
sensor_3_axis
{
floa
t
x
;
floa
t
y
;
floa
t
z
;
rt_sensor_float_
t
x
;
rt_sensor_float_
t
y
;
rt_sensor_float_
t
z
;
};
/* Blood Pressure Data Type */
struct
sensor_bp
{
floa
t
sbp
;
/* SBP : systolic pressure */
floa
t
dbp
;
/* DBP : diastolic pressure */
rt_sensor_float_
t
sbp
;
/* SBP : systolic pressure */
rt_sensor_float_
t
dbp
;
/* DBP : diastolic pressure */
};
struct
coordinates
{
floa
t
longitude
;
floa
t
latitude
;
rt_sensor_float_
t
longitude
;
rt_sensor_float_
t
latitude
;
};
struct
rt_sensor_data
...
...
@@ -219,21 +220,21 @@ struct rt_sensor_data
struct
sensor_3_axis
mag
;
/* Magnetometer. unit: mGauss */
struct
coordinates
coord
;
/* Coordinates unit: degrees */
struct
sensor_bp
bp
;
/* BloodPressure. unit: mmHg */
float
temp
;
/* Temperature. unit: dCelsius */
float
humi
;
/* Relative humidity. unit: permillage */
float
baro
;
/* Pressure. unit: pascal (Pa) */
float
light
;
/* Light. unit: lux */
float
proximity
;
/* Distance. unit: centimeters */
float
hr
;
/* Heart rate. unit: bpm */
float
tvoc
;
/* TVOC. unit: permillage */
float
noise
;
/* Noise Loudness. unit: HZ */
float
step
;
/* Step sensor. unit: 1 */
float
force
;
/* Force sensor. unit: mN */
float
dust
;
/* Dust sensor. unit: ug/m3 */
float
eco2
;
/* eCO2 sensor. unit: ppm */
float
spo2
;
/* SpO2 sensor. unit: permillage */
float
iaq
;
/* IAQ sensor. unit: 1 */
float
etoh
;
/* EtOH sensor. unit: ppm */
rt_sensor_float_t
temp
;
/* Temperature. unit: dCelsius */
rt_sensor_float_t
humi
;
/* Relative humidity. unit: permillage */
rt_sensor_float_t
baro
;
/* Pressure. unit: pascal (Pa) */
rt_sensor_float_t
light
;
/* Light. unit: lux */
rt_sensor_float_t
proximity
;
/* Distance. unit: centimeters */
rt_sensor_float_t
hr
;
/* Heart rate. unit: bpm */
rt_sensor_float_t
tvoc
;
/* TVOC. unit: permillage */
rt_sensor_float_t
noise
;
/* Noise Loudness. unit: HZ */
rt_sensor_float_t
step
;
/* Step sensor. unit: 1 */
rt_sensor_float_t
force
;
/* Force sensor. unit: mN */
rt_sensor_float_t
dust
;
/* Dust sensor. unit: ug/m3 */
rt_sensor_float_t
eco2
;
/* eCO2 sensor. unit: ppm */
rt_sensor_float_t
spo2
;
/* SpO2 sensor. unit: permillage */
rt_sensor_float_t
iaq
;
/* IAQ sensor. unit: 1 */
rt_sensor_float_t
etoh
;
/* EtOH sensor. unit: ppm */
}
data
;
};
...
...
@@ -243,10 +244,10 @@ struct rt_sensor_ops
rt_err_t
(
*
control
)(
rt_sensor_t
sensor
,
int
cmd
,
void
*
arg
);
};
int
rt_hw_sensor_register
(
rt_sensor_t
sensor
,
const
char
*
name
,
rt_uint32_t
flag
,
void
*
data
);
int
rt_hw_sensor_register
(
rt_sensor_t
sensor
,
const
char
*
name
,
rt_uint32_t
flag
,
void
*
data
);
#ifdef __cplusplus
}
...
...
components/drivers/sensors/sensor.c
浏览文件 @
953a8c26
...
...
@@ -421,10 +421,10 @@ const static struct rt_device_ops rt_sensor_ops =
/*
* sensor register
*/
int
rt_hw_sensor_register
(
rt_sensor_t
sensor
,
const
char
*
name
,
rt_uint32_t
flag
,
void
*
data
)
int
rt_hw_sensor_register
(
rt_sensor_t
sensor
,
const
char
*
name
,
rt_uint32_t
flag
,
void
*
data
)
{
rt_int8_t
result
;
rt_device_t
device
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录