Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
2301_76519099
rt-thread
提交
9860b168
R
rt-thread
项目概览
2301_76519099
/
rt-thread
与 Fork 源项目一致
Fork自
RT-Thread / rt-thread
通知
3
Star
1
Fork
1
代码
文件
提交
分支
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,发现更多精彩内容 >>
提交
9860b168
编写于
12月 12, 2022
作者:
mysterywolf
提交者:
mysterywolf
12月 12, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[sensor] 增加新传感器类型和单位
上级
2aa600e0
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
78 addition
and
42 deletion
+78
-42
components/drivers/include/drivers/sensor.h
components/drivers/include/drivers/sensor.h
+54
-36
components/drivers/sensor/sensor_cmd.c
components/drivers/sensor/sensor_cmd.c
+24
-6
未找到文件。
components/drivers/include/drivers/sensor.h
浏览文件 @
9860b168
...
...
@@ -76,39 +76,47 @@ extern "C" {
#define RT_SENSOR_CLASS_ETOH_STR "EtOH"
#define RT_SENSOR_CLASS_BP (21)
#define RT_SENSOR_CLASS_BP_STR "Blood Pressure"
#define RT_SENSOR_CLASS_VOLTAGE (22)
#define RT_SENSOR_CLASS_VOLTAGE_STR "Voltage"
#define RT_SENSOR_CLASS_CURRENT (23)
#define RT_SENSOR_CLASS_CURRENT_STR "Current"
/* Sensor vendor types */
#define RT_SENSOR_VENDOR_UNKNOWN (0)
#define RT_SENSOR_VENDOR_UNKNOWN_STR "Vendor Unknown"
#define RT_SENSOR_VENDOR_STM (1)
#define RT_SENSOR_VENDOR_UNKNOWN_STR "Unknown"
#define RT_SENSOR_VENDOR_VIRTUAL (1)
#define RT_SENSOR_VENDOR_VIRTUAL_STR "Virtual Sensor"
#define RT_SENSOR_VENDOR_ONCHIP (2)
#define RT_SENSOR_VENDOR_ONCHIP_STR "OnChip"
#define RT_SENSOR_VENDOR_STM (3)
#define RT_SENSOR_VENDOR_STM_STR "STMicroelectronics"
#define RT_SENSOR_VENDOR_BOSCH (
2
)
#define RT_SENSOR_VENDOR_BOSCH (
4
)
#define RT_SENSOR_VENDOR_BOSCH_STR "Bosch"
#define RT_SENSOR_VENDOR_INVENSENSE (
3
)
#define RT_SENSOR_VENDOR_INVENSENSE (
5
)
#define RT_SENSOR_VENDOR_INVENSENSE_STR "Invensense"
#define RT_SENSOR_VENDOR_SEMTECH (
4
)
#define RT_SENSOR_VENDOR_SEMTECH (
6
)
#define RT_SENSOR_VENDOR_SEMTECH_STR "Semtech"
#define RT_SENSOR_VENDOR_GOERTEK (
5
)
#define RT_SENSOR_VENDOR_GOERTEK (
7
)
#define RT_SENSOR_VENDOR_GOERTEK_STR "Goertek"
#define RT_SENSOR_VENDOR_MIRAMEMS (
6
)
#define RT_SENSOR_VENDOR_MIRAMEMS (
8
)
#define RT_SENSOR_VENDOR_MIRAMEMS_STR "MiraMEMS"
#define RT_SENSOR_VENDOR_DALLAS (
7
)
#define RT_SENSOR_VENDOR_DALLAS (
9
)
#define RT_SENSOR_VENDOR_DALLAS_STR "Dallas"
#define RT_SENSOR_VENDOR_ASAIR (
8
)
#define RT_SENSOR_VENDOR_ASAIR (
10
)
#define RT_SENSOR_VENDOR_ASAIR_STR "Aosong"
#define RT_SENSOR_VENDOR_SHARP (
9
)
#define RT_SENSOR_VENDOR_SHARP (
11
)
#define RT_SENSOR_VENDOR_SHARP_STR "Sharp"
#define RT_SENSOR_VENDOR_SENSIRION (1
0
)
#define RT_SENSOR_VENDOR_SENSIRION (1
2
)
#define RT_SENSOR_VENDOR_SENSIRION_STR "Sensirion"
#define RT_SENSOR_VENDOR_TI (1
1
)
#define RT_SENSOR_VENDOR_TI (1
3
)
#define RT_SENSOR_VENDOR_TI_STR "Texas Instruments"
#define RT_SENSOR_VENDOR_PLANTOWER (1
2
)
#define RT_SENSOR_VENDOR_PLANTOWER (1
4
)
#define RT_SENSOR_VENDOR_PLANTOWER_STR "Plantower"
#define RT_SENSOR_VENDOR_AMS (1
3
)
#define RT_SENSOR_VENDOR_AMS (1
5
)
#define RT_SENSOR_VENDOR_AMS_STR "ams-OSRAM AG"
#define RT_SENSOR_VENDOR_MAXIM (1
4
)
#define RT_SENSOR_VENDOR_MAXIM (1
6
)
#define RT_SENSOR_VENDOR_MAXIM_STR "Maxim Integrated"
#define RT_SENSOR_VENDOR_MELEXIS (1
5
)
#define RT_SENSOR_VENDOR_MELEXIS (1
7
)
#define RT_SENSOR_VENDOR_MELEXIS_STR "Melexis"
/* Sensor unit types */
...
...
@@ -122,41 +130,51 @@ extern "C" {
#define RT_SENSOR_UNIT_MGAUSS_STR "mGauss"
#define RT_SENSOR_UNIT_LUX (4)
/* Ambient light unit: lux */
#define RT_SENSOR_UNIT_LUX_STR "lux"
#define RT_SENSOR_UNIT_CM (5)
/* Distance unit: cm */
#define RT_SENSOR_UNIT_M (5)
/* Distance unit: m */
#define RT_SENSOR_UNIT_M_STR "m"
#define RT_SENSOR_UNIT_CM (6)
/* Distance unit: cm */
#define RT_SENSOR_UNIT_CM_STR "cm"
#define RT_SENSOR_UNIT_MM (
6
)
/* Distance unit: mm */
#define RT_SENSOR_UNIT_MM (
7
)
/* Distance unit: mm */
#define RT_SENSOR_UNIT_MM_STR "mm"
#define RT_SENSOR_UNIT_PA (
7
)
/* Barometer unit: Pa */
#define RT_SENSOR_UNIT_PA (
8
)
/* Barometer unit: Pa */
#define RT_SENSOR_UNIT_PA_STR "Pa"
#define RT_SENSOR_UNIT_MMHG (
8
)
/* Blood Pressure unit: mmHg */
#define RT_SENSOR_UNIT_MMHG (
9
)
/* Blood Pressure unit: mmHg */
#define RT_SENSOR_UNIT_MMHG_STR "mmHg"
#define RT_SENSOR_UNIT_PERMILLAGE (9)
/* Relative Humidity unit: permillage */
#define RT_SENSOR_UNIT_PERMILLAGE_STR "‰"
#define RT_SENSOR_UNIT_PERCENTAGE (10)
/* Relative Humidity unit: percentage */
#define RT_SENSOR_UNIT_PERCENTAGE_STR "%"
#define RT_SENSOR_UNIT_CELSIUS (11)
/* Temperature unit: Celsius ℃ */
#define RT_SENSOR_UNIT_PERMILLAGE (11)
/* Relative Humidity unit: permillage */
#define RT_SENSOR_UNIT_PERMILLAGE_STR "‰"
#define RT_SENSOR_UNIT_CELSIUS (12)
/* Temperature unit: Celsius ℃ */
#define RT_SENSOR_UNIT_CELSIUS_STR "℃"
#define RT_SENSOR_UNIT_FAHRENHEIT (1
2
)
/* Temperature unit: Fahrenheit ℉ */
#define RT_SENSOR_UNIT_FAHRENHEIT (1
3
)
/* Temperature unit: Fahrenheit ℉ */
#define RT_SENSOR_UNIT_FAHRENHEIT_STR "℉"
#define RT_SENSOR_UNIT_KELVIN (1
3)
/* Temperature unit: K
*/
#define RT_SENSOR_UNIT_KELVIN (1
4)
/* Temperature unit: Kelvin K
*/
#define RT_SENSOR_UNIT_KELVIN_STR "K"
#define RT_SENSOR_UNIT_HZ (1
4
)
/* Frequency unit: Hz */
#define RT_SENSOR_UNIT_HZ (1
5
)
/* Frequency unit: Hz */
#define RT_SENSOR_UNIT_HZ_STR "Hz"
#define RT_SENSOR_UNIT_BPM (15)
/* Heart rate unit: bpm */
#define RT_SENSOR_UNIT_BPM_STR "bpm"
#define RT_SENSOR_UNIT_MN (16)
/* Force unit: mN */
#define RT_SENSOR_UNIT_MN_STR "mN"
#define RT_SENSOR_UNIT_N (17)
/* Force unit: N */
#define RT_SENSOR_UNIT_V (16)
/* Voltage unit: V */
#define RT_SENSOR_UNIT_V_STR "V"
#define RT_SENSOR_UNIT_MV (17)
/* Voltage unit: mV */
#define RT_SENSOR_UNIT_MV_STR "mV"
#define RT_SENSOR_UNIT_A (18)
/* Current unit: A */
#define RT_SENSOR_UNIT_A_STR "A"
#define RT_SENSOR_UNIT_MA (19)
/* Current unit: mA */
#define RT_SENSOR_UNIT_MA_STR "mA"
#define RT_SENSOR_UNIT_N (20)
/* Force unit: N */
#define RT_SENSOR_UNIT_N_STR "N"
#define RT_SENSOR_UNIT_PPM (18)
/* Concentration unit: ppm */
#define RT_SENSOR_UNIT_MN (21)
/* Force unit: mN */
#define RT_SENSOR_UNIT_MN_STR "mN"
#define RT_SENSOR_UNIT_BPM (22)
/* Heart rate unit: bpm */
#define RT_SENSOR_UNIT_BPM_STR "bpm"
#define RT_SENSOR_UNIT_PPM (23)
/* Concentration unit: ppm */
#define RT_SENSOR_UNIT_PPM_STR "ppm"
#define RT_SENSOR_UNIT_PPB (
19
)
/* Concentration unit: ppb */
#define RT_SENSOR_UNIT_PPB (
24
)
/* Concentration unit: ppb */
#define RT_SENSOR_UNIT_PPB_STR "ppb"
#define RT_SENSOR_UNIT_DMS (2
0
)
/* Coordinates unit: DMS */
#define RT_SENSOR_UNIT_DMS (2
5
)
/* Coordinates unit: DMS */
#define RT_SENSOR_UNIT_DMS_STR "DMS"
#define RT_SENSOR_UNIT_DD (2
1
)
/* Coordinates unit: DD */
#define RT_SENSOR_UNIT_DD (2
6
)
/* Coordinates unit: DD */
#define RT_SENSOR_UNIT_DD_STR "DD"
#define RT_SENSOR_UNIT_MGM3 (2
2
)
/* Concentration unit: mg/m3 */
#define RT_SENSOR_UNIT_MGM3 (2
7
)
/* Concentration unit: mg/m3 */
#define RT_SENSOR_UNIT_MGM3_STR "mg/m3"
/* Sensor communication interface types */
...
...
components/drivers/sensor/sensor_cmd.c
浏览文件 @
9860b168
...
...
@@ -67,6 +67,10 @@ static const char *sensor_get_type_name(rt_sensor_info_t info)
return
RT_SENSOR_MACRO_GET_NAME
(
RT_SENSOR_CLASS_ETOH
);
case
RT_SENSOR_CLASS_BP
:
return
RT_SENSOR_MACRO_GET_NAME
(
RT_SENSOR_CLASS_BP
);
case
RT_SENSOR_CLASS_VOLTAGE
:
return
RT_SENSOR_MACRO_GET_NAME
(
RT_SENSOR_CLASS_VOLTAGE
);
case
RT_SENSOR_CLASS_CURRENT
:
return
RT_SENSOR_MACRO_GET_NAME
(
RT_SENSOR_CLASS_CURRENT
);
case
RT_SENSOR_CLASS_NONE
:
default:
return
RT_SENSOR_MACRO_GET_NAME
(
RT_SENSOR_CLASS_NONE
);
...
...
@@ -77,6 +81,10 @@ static const char *sensor_get_vendor_name(rt_sensor_info_t info)
{
switch
(
info
->
vendor
)
{
case
RT_SENSOR_VENDOR_VIRTUAL
:
return
RT_SENSOR_MACRO_GET_NAME
(
RT_SENSOR_VENDOR_VIRTUAL
);
case
RT_SENSOR_VENDOR_ONCHIP
:
return
RT_SENSOR_MACRO_GET_NAME
(
RT_SENSOR_VENDOR_ONCHIP
);
case
RT_SENSOR_VENDOR_STM
:
return
RT_SENSOR_MACRO_GET_NAME
(
RT_SENSOR_VENDOR_STM
);
case
RT_SENSOR_VENDOR_BOSCH
:
...
...
@@ -125,6 +133,8 @@ static const char *sensor_get_unit_name(rt_sensor_info_t info)
return
RT_SENSOR_MACRO_GET_NAME
(
RT_SENSOR_UNIT_MGAUSS
);
case
RT_SENSOR_UNIT_LUX
:
return
RT_SENSOR_MACRO_GET_NAME
(
RT_SENSOR_UNIT_LUX
);
case
RT_SENSOR_UNIT_M
:
return
RT_SENSOR_MACRO_GET_NAME
(
RT_SENSOR_UNIT_M
);
case
RT_SENSOR_UNIT_CM
:
return
RT_SENSOR_MACRO_GET_NAME
(
RT_SENSOR_UNIT_CM
);
case
RT_SENSOR_UNIT_MM
:
...
...
@@ -133,10 +143,10 @@ static const char *sensor_get_unit_name(rt_sensor_info_t info)
return
RT_SENSOR_MACRO_GET_NAME
(
RT_SENSOR_UNIT_PA
);
case
RT_SENSOR_UNIT_MMHG
:
return
RT_SENSOR_MACRO_GET_NAME
(
RT_SENSOR_UNIT_MMHG
);
case
RT_SENSOR_UNIT_PERMILLAGE
:
return
RT_SENSOR_MACRO_GET_NAME
(
RT_SENSOR_UNIT_PERMILLAGE
);
case
RT_SENSOR_UNIT_PERCENTAGE
:
return
RT_SENSOR_MACRO_GET_NAME
(
RT_SENSOR_UNIT_PERCENTAGE
);
case
RT_SENSOR_UNIT_PERMILLAGE
:
return
RT_SENSOR_MACRO_GET_NAME
(
RT_SENSOR_UNIT_PERMILLAGE
);
case
RT_SENSOR_UNIT_CELSIUS
:
return
RT_SENSOR_MACRO_GET_NAME
(
RT_SENSOR_UNIT_CELSIUS
);
case
RT_SENSOR_UNIT_FAHRENHEIT
:
...
...
@@ -145,12 +155,20 @@ static const char *sensor_get_unit_name(rt_sensor_info_t info)
return
RT_SENSOR_MACRO_GET_NAME
(
RT_SENSOR_UNIT_KELVIN
);
case
RT_SENSOR_UNIT_HZ
:
return
RT_SENSOR_MACRO_GET_NAME
(
RT_SENSOR_UNIT_HZ
);
case
RT_SENSOR_UNIT_BPM
:
return
RT_SENSOR_MACRO_GET_NAME
(
RT_SENSOR_UNIT_BPM
);
case
RT_SENSOR_UNIT_MN
:
return
RT_SENSOR_MACRO_GET_NAME
(
RT_SENSOR_UNIT_MN
);
case
RT_SENSOR_UNIT_V
:
return
RT_SENSOR_MACRO_GET_NAME
(
RT_SENSOR_UNIT_V
);
case
RT_SENSOR_UNIT_MV
:
return
RT_SENSOR_MACRO_GET_NAME
(
RT_SENSOR_UNIT_MV
);
case
RT_SENSOR_UNIT_A
:
return
RT_SENSOR_MACRO_GET_NAME
(
RT_SENSOR_UNIT_A
);
case
RT_SENSOR_UNIT_MA
:
return
RT_SENSOR_MACRO_GET_NAME
(
RT_SENSOR_UNIT_MA
);
case
RT_SENSOR_UNIT_N
:
return
RT_SENSOR_MACRO_GET_NAME
(
RT_SENSOR_UNIT_N
);
case
RT_SENSOR_UNIT_MN
:
return
RT_SENSOR_MACRO_GET_NAME
(
RT_SENSOR_UNIT_MN
);
case
RT_SENSOR_UNIT_BPM
:
return
RT_SENSOR_MACRO_GET_NAME
(
RT_SENSOR_UNIT_BPM
);
case
RT_SENSOR_UNIT_PPM
:
return
RT_SENSOR_MACRO_GET_NAME
(
RT_SENSOR_UNIT_PPM
);
case
RT_SENSOR_UNIT_PPB
:
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录