Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Richard 祝发兴 - -IT
rt-thread
提交
37d04007
R
rt-thread
项目概览
Richard 祝发兴 - -IT
/
rt-thread
与 Fork 源项目一致
Fork自
RT-Thread / rt-thread
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
rt-thread
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
37d04007
编写于
2月 13, 2019
作者:
G
guozhanxin
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
rename rt_sen_ to rt_sensor_
上级
9458791c
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
103 addition
and
103 deletion
+103
-103
components/drivers/sensors/sensor.c
components/drivers/sensors/sensor.c
+28
-28
components/drivers/sensors/sensor.h
components/drivers/sensors/sensor.h
+57
-57
components/drivers/sensors/sensor_test.c
components/drivers/sensors/sensor_test.c
+18
-18
未找到文件。
components/drivers/sensors/sensor.c
浏览文件 @
37d04007
...
...
@@ -51,12 +51,12 @@ void rt_sensor_cb(rt_sensor_t sen)
{
sen
->
parent
.
rx_indicate
(
&
sen
->
parent
,
sen
->
data_len
/
sizeof
(
struct
rt_sensor_data
));
}
else
if
(
sen
->
config
.
mode
==
RT_SEN_MODE_INT
)
else
if
(
sen
->
config
.
mode
==
RT_SEN
SOR
_MODE_INT
)
{
/* The interrupt mode only produces one data at a time */
sen
->
parent
.
rx_indicate
(
&
sen
->
parent
,
1
);
}
else
if
(
sen
->
config
.
mode
==
RT_SEN_MODE_FIFO
)
else
if
(
sen
->
config
.
mode
==
RT_SEN
SOR
_MODE_FIFO
)
{
sen
->
parent
.
rx_indicate
(
&
sen
->
parent
,
sen
->
info
.
fifo_max
);
}
...
...
@@ -164,27 +164,27 @@ static rt_err_t rt_sensor_open(rt_device_t dev, rt_uint16_t oflag)
if
(
oflag
&
RT_DEVICE_FLAG_RDONLY
&&
dev
->
flag
&
RT_DEVICE_FLAG_RDONLY
)
{
/* If polling mode is supported, configure it to polling mode */
if
(
sensor
->
ops
->
control
(
sensor
,
RT_SEN
_CTRL_SET_MODE
,
(
void
*
)
RT_SEN
_MODE_POLLING
)
==
RT_EOK
)
if
(
sensor
->
ops
->
control
(
sensor
,
RT_SEN
SOR_CTRL_SET_MODE
,
(
void
*
)
RT_SENSOR
_MODE_POLLING
)
==
RT_EOK
)
{
sensor
->
config
.
mode
=
RT_SEN_MODE_POLLING
;
sensor
->
config
.
mode
=
RT_SEN
SOR
_MODE_POLLING
;
}
}
else
if
(
oflag
&
RT_DEVICE_FLAG_INT_RX
&&
dev
->
flag
&
RT_DEVICE_FLAG_INT_RX
)
{
/* If interrupt mode is supported, configure it to interrupt mode */
if
(
sensor
->
ops
->
control
(
sensor
,
RT_SEN
_CTRL_SET_MODE
,
(
void
*
)
RT_SEN
_MODE_INT
)
==
RT_EOK
)
if
(
sensor
->
ops
->
control
(
sensor
,
RT_SEN
SOR_CTRL_SET_MODE
,
(
void
*
)
RT_SENSOR
_MODE_INT
)
==
RT_EOK
)
{
sensor
->
config
.
mode
=
RT_SEN_MODE_INT
;
sensor
->
config
.
mode
=
RT_SEN
SOR
_MODE_INT
;
/* Initialization sensor interrupt */
rt_sensor_irq_init
(
sensor
);
}
}
else
if
(
oflag
&
RT_SEN
_FLAG_FIFO
&&
dev
->
flag
&
RT_SEN
_FLAG_FIFO
)
else
if
(
oflag
&
RT_SEN
SOR_FLAG_FIFO
&&
dev
->
flag
&
RT_SENSOR
_FLAG_FIFO
)
{
/* If fifo mode is supported, configure it to fifo mode */
if
(
sensor
->
ops
->
control
(
sensor
,
RT_SEN
_CTRL_SET_MODE
,
(
void
*
)
RT_SEN
_MODE_FIFO
)
==
RT_EOK
)
if
(
sensor
->
ops
->
control
(
sensor
,
RT_SEN
SOR_CTRL_SET_MODE
,
(
void
*
)
RT_SENSOR
_MODE_FIFO
)
==
RT_EOK
)
{
sensor
->
config
.
mode
=
RT_SEN_MODE_FIFO
;
sensor
->
config
.
mode
=
RT_SEN
SOR
_MODE_FIFO
;
/* Initialization sensor interrupt */
rt_sensor_irq_init
(
sensor
);
}
...
...
@@ -195,9 +195,9 @@ static rt_err_t rt_sensor_open(rt_device_t dev, rt_uint16_t oflag)
}
/* Configure power mode to normal mode */
if
(
sensor
->
ops
->
control
(
sensor
,
RT_SEN
_CTRL_SET_POWER
,
(
void
*
)
RT_SEN
_POWER_NORMAL
)
==
RT_EOK
)
if
(
sensor
->
ops
->
control
(
sensor
,
RT_SEN
SOR_CTRL_SET_POWER
,
(
void
*
)
RT_SENSOR
_POWER_NORMAL
)
==
RT_EOK
)
{
sensor
->
config
.
power
=
RT_SEN_POWER_NORMAL
;
sensor
->
config
.
power
=
RT_SEN
SOR
_POWER_NORMAL
;
}
if
(
sensor
->
module
)
...
...
@@ -220,9 +220,9 @@ static rt_err_t rt_sensor_close(rt_device_t dev)
}
/* Configure power mode to power down mode */
if
(
sensor
->
ops
->
control
(
sensor
,
RT_SEN
_CTRL_SET_POWER
,
(
void
*
)
RT_SEN
_POWER_DOWN
)
==
RT_EOK
)
if
(
sensor
->
ops
->
control
(
sensor
,
RT_SEN
SOR_CTRL_SET_POWER
,
(
void
*
)
RT_SENSOR
_POWER_DOWN
)
==
RT_EOK
)
{
sensor
->
config
.
power
=
RT_SEN_POWER_DOWN
;
sensor
->
config
.
power
=
RT_SEN
SOR
_POWER_DOWN
;
}
/* Sensor disable interrupt */
...
...
@@ -293,71 +293,71 @@ static rt_err_t rt_sensor_control(rt_device_t dev, int cmd, void *args)
switch
(
cmd
)
{
case
RT_SEN_CTRL_GET_ID
:
case
RT_SEN
SOR
_CTRL_GET_ID
:
if
(
args
)
{
sensor
->
ops
->
control
(
sensor
,
RT_SEN_CTRL_GET_ID
,
args
);
sensor
->
ops
->
control
(
sensor
,
RT_SEN
SOR
_CTRL_GET_ID
,
args
);
}
break
;
case
RT_SEN_CTRL_GET_INFO
:
case
RT_SEN
SOR
_CTRL_GET_INFO
:
if
(
args
)
{
rt_memcpy
(
args
,
&
sensor
->
info
,
sizeof
(
struct
rt_sensor_info
));
}
break
;
case
RT_SEN_CTRL_SET_RANGE
:
case
RT_SEN
SOR
_CTRL_SET_RANGE
:
/* Configuration measurement range */
result
=
sensor
->
ops
->
control
(
sensor
,
RT_SEN_CTRL_SET_RANGE
,
args
);
result
=
sensor
->
ops
->
control
(
sensor
,
RT_SEN
SOR
_CTRL_SET_RANGE
,
args
);
if
(
result
==
RT_EOK
)
{
sensor
->
config
.
range
=
(
rt_int32_t
)
args
;
LOG_D
(
"set range %d"
,
sensor
->
config
.
range
);
}
break
;
case
RT_SEN_CTRL_SET_ODR
:
case
RT_SEN
SOR
_CTRL_SET_ODR
:
/* Configuration data output rate */
result
=
sensor
->
ops
->
control
(
sensor
,
RT_SEN_CTRL_SET_ODR
,
args
);
result
=
sensor
->
ops
->
control
(
sensor
,
RT_SEN
SOR
_CTRL_SET_ODR
,
args
);
if
(
result
==
RT_EOK
)
{
sensor
->
config
.
odr
=
(
rt_uint32_t
)
args
&
0xFFFF
;
LOG_D
(
"set odr %d"
,
sensor
->
config
.
odr
);
}
break
;
case
RT_SEN_CTRL_SET_MODE
:
case
RT_SEN
SOR
_CTRL_SET_MODE
:
/* Configuration sensor work mode */
result
=
sensor
->
ops
->
control
(
sensor
,
RT_SEN_CTRL_SET_MODE
,
args
);
result
=
sensor
->
ops
->
control
(
sensor
,
RT_SEN
SOR
_CTRL_SET_MODE
,
args
);
if
(
result
==
RT_EOK
)
{
sensor
->
config
.
mode
=
(
rt_uint32_t
)
args
&
0xFF
;
LOG_D
(
"set work mode code:"
,
sensor
->
config
.
mode
);
if
(
sensor
->
config
.
mode
==
RT_SEN_MODE_POLLING
)
if
(
sensor
->
config
.
mode
==
RT_SEN
SOR
_MODE_POLLING
)
{
rt_sensor_irq_disable
(
sensor
);
}
else
if
(
sensor
->
config
.
mode
==
RT_SEN
_MODE_INT
||
sensor
->
config
.
mode
==
RT_SEN
_MODE_FIFO
)
else
if
(
sensor
->
config
.
mode
==
RT_SEN
SOR_MODE_INT
||
sensor
->
config
.
mode
==
RT_SENSOR
_MODE_FIFO
)
{
rt_sensor_irq_enable
(
sensor
);
}
}
break
;
case
RT_SEN_CTRL_SET_POWER
:
case
RT_SEN
SOR
_CTRL_SET_POWER
:
/* Configuration sensor power mode */
result
=
sensor
->
ops
->
control
(
sensor
,
RT_SEN_CTRL_SET_POWER
,
args
);
result
=
sensor
->
ops
->
control
(
sensor
,
RT_SEN
SOR
_CTRL_SET_POWER
,
args
);
if
(
result
==
RT_EOK
)
{
sensor
->
config
.
power
=
(
rt_uint32_t
)
args
&
0xFF
;
LOG_D
(
"set power mode code:"
,
sensor
->
config
.
power
);
}
break
;
case
RT_SEN_CTRL_SELF_TEST
:
case
RT_SEN
SOR
_CTRL_SELF_TEST
:
/* Device self-test */
result
=
sensor
->
ops
->
control
(
sensor
,
RT_SEN_CTRL_SELF_TEST
,
args
);
result
=
sensor
->
ops
->
control
(
sensor
,
RT_SEN
SOR
_CTRL_SELF_TEST
,
args
);
break
;
default:
return
-
RT_ERROR
;
...
...
components/drivers/sensors/sensor.h
浏览文件 @
37d04007
...
...
@@ -19,86 +19,86 @@ extern "C" {
#endif
#ifdef RT_USING_RTC
#define rt_sen
_get_timestamp
() time()
/* API for the sensor to get the timestamp */
#define rt_sen
sor_get_ts
() time()
/* API for the sensor to get the timestamp */
#else
#define rt_sen
_get_timestamp
() rt_tick_get()
/* API for the sensor to get the timestamp */
#define rt_sen
sor_get_ts
() rt_tick_get()
/* API for the sensor to get the timestamp */
#endif
#define RT_PIN_NONE 0xFFFF
/* RT PIN NONE */
#define RT_SEN
_FLAG_FIFO
0x200
/* Flag to use when the sensor is open by fifo mode */
#define RT_SEN
SOR_FLAG_FIFO
0x200
/* Flag to use when the sensor is open by fifo mode */
#define RT_SEN
_MODULE_MAX
(3)
/* The maximum number of members of a sensor module */
#define RT_SEN
SOR_MODULE_MAX
(3)
/* The maximum number of members of a sensor module */
/* Sensor types */
#define RT_SEN
_CLASS_NONE
(0)
#define RT_SEN
_CLASS_ACCE
(1)
/* Accelerometer */
#define RT_SEN
_CLASS_GYRO
(2)
/* Gyroscope */
#define RT_SEN
_CLASS_MAG
(3)
/* Magnetometer */
#define RT_SEN
_CLASS_TEMP
(4)
/* Temperature */
#define RT_SEN
_CLASS_HUMI
(5)
/* Relative Humidity */
#define RT_SEN
_CLASS_BARO
(6)
/* Barometer */
#define RT_SEN
_CLASS_LIGHT
(7)
/* Ambient light */
#define RT_SEN
_CLASS_PROXIMITY
(8)
/* Proximity */
#define RT_SEN
_CLASS_HR
(9)
/* Heart Rate */
#define RT_SEN
_CLASS_TVOC
(10)
/* TVOC Level */
#define RT_SEN
_CLASS_NOISE
(11)
/* Noise Loudness */
#define RT_SEN
_CLASS_STEP
(12)
/* Step sensor */
#define RT_SEN
SOR_CLASS_NONE
(0)
#define RT_SEN
SOR_CLASS_ACCE
(1)
/* Accelerometer */
#define RT_SEN
SOR_CLASS_GYRO
(2)
/* Gyroscope */
#define RT_SEN
SOR_CLASS_MAG
(3)
/* Magnetometer */
#define RT_SEN
SOR_CLASS_TEMP
(4)
/* Temperature */
#define RT_SEN
SOR_CLASS_HUMI
(5)
/* Relative Humidity */
#define RT_SEN
SOR_CLASS_BARO
(6)
/* Barometer */
#define RT_SEN
SOR_CLASS_LIGHT
(7)
/* Ambient light */
#define RT_SEN
SOR_CLASS_PROXIMITY
(8)
/* Proximity */
#define RT_SEN
SOR_CLASS_HR
(9)
/* Heart Rate */
#define RT_SEN
SOR_CLASS_TVOC
(10)
/* TVOC Level */
#define RT_SEN
SOR_CLASS_NOISE
(11)
/* Noise Loudness */
#define RT_SEN
SOR_CLASS_STEP
(12)
/* Step sensor */
/* Sensor vendor types */
#define RT_SEN
_VENDOR_UNKNOWN
(0)
#define RT_SEN
_VENDOR_STM
(1)
/* STMicroelectronics */
#define RT_SEN
_VENDOR_BOSCH
(2)
/* Bosch */
#define RT_SEN
_VENDOR_INVENSENSE
(3)
/* Invensense */
#define RT_SEN
_VENDOR_SEMTECH
(4)
/* Semtech */
#define RT_SEN
_VENDOR_GOERTEK
(5)
/* Goertek */
#define RT_SEN
SOR_VENDOR_UNKNOWN
(0)
#define RT_SEN
SOR_VENDOR_STM
(1)
/* STMicroelectronics */
#define RT_SEN
SOR_VENDOR_BOSCH
(2)
/* Bosch */
#define RT_SEN
SOR_VENDOR_INVENSENSE
(3)
/* Invensense */
#define RT_SEN
SOR_VENDOR_SEMTECH
(4)
/* Semtech */
#define RT_SEN
SOR_VENDOR_GOERTEK
(5)
/* Goertek */
/* Sensor unit types */
#define RT_SEN
_UNIT_NONE
(0)
#define RT_SEN
_UNIT_MG
(1)
/* Accelerometer unit: mG */
#define RT_SEN
_UNIT_MDPS
(2)
/* Gyroscope unit: mdps */
#define RT_SEN
_UNIT_MGAUSS
(3)
/* Magnetometer unit: mGauss */
#define RT_SEN
_UNIT_LUX
(4)
/* Ambient light unit: lux */
#define RT_SEN
_UNIT_CM
(5)
/* Distance unit: cm */
#define RT_SEN
_UNIT_PA
(6)
/* Barometer unit: pa */
#define RT_SEN
_UNIT_PERMILLAGE
(7)
/* Relative Humidity unit: permillage */
#define RT_SEN
_UNIT_DCELSIUS
(8)
/* Temperature unit: dCelsius */
#define RT_SEN
_UNIT_HZ
(9)
/* Frequency unit: HZ */
#define RT_SEN
_UNIT_ONE
(10)
/* Dimensionless quantity unit: 1 */
#define RT_SEN
SOR_UNIT_NONE
(0)
#define RT_SEN
SOR_UNIT_MG
(1)
/* Accelerometer unit: mG */
#define RT_SEN
SOR_UNIT_MDPS
(2)
/* Gyroscope unit: mdps */
#define RT_SEN
SOR_UNIT_MGAUSS
(3)
/* Magnetometer unit: mGauss */
#define RT_SEN
SOR_UNIT_LUX
(4)
/* Ambient light unit: lux */
#define RT_SEN
SOR_UNIT_CM
(5)
/* Distance unit: cm */
#define RT_SEN
SOR_UNIT_PA
(6)
/* Barometer unit: pa */
#define RT_SEN
SOR_UNIT_PERMILLAGE
(7)
/* Relative Humidity unit: permillage */
#define RT_SEN
SOR_UNIT_DCELSIUS
(8)
/* Temperature unit: dCelsius */
#define RT_SEN
SOR_UNIT_HZ
(9)
/* Frequency unit: HZ */
#define RT_SEN
SOR_UNIT_ONE
(10)
/* Dimensionless quantity unit: 1 */
/* Sensor communication interface types */
#define RT_SEN
_INTF_I2C
(1 << 0)
#define RT_SEN
_INTF_SPI
(1 << 1)
#define RT_SEN
_INTF_UART
(1 << 2)
#define RT_SEN
_INTF_ONEWIRE
(1 << 3)
#define RT_SEN
SOR_INTF_I2C
(1 << 0)
#define RT_SEN
SOR_INTF_SPI
(1 << 1)
#define RT_SEN
SOR_INTF_UART
(1 << 2)
#define RT_SEN
SOR_INTF_ONEWIRE
(1 << 3)
/* Sensor power mode types */
#define RT_SEN
_POWER_NONE
(0)
#define RT_SEN
_POWER_DOWN
(1)
/* power down mode */
#define RT_SEN
_POWER_NORMAL
(2)
/* normal-power mode */
#define RT_SEN
_POWER_LOW
(3)
/* low-power mode */
#define RT_SEN
_POWER_HIGH
(4)
/* high-power mode */
#define RT_SEN
SOR_POWER_NONE
(0)
#define RT_SEN
SOR_POWER_DOWN
(1)
/* power down mode */
#define RT_SEN
SOR_POWER_NORMAL
(2)
/* normal-power mode */
#define RT_SEN
SOR_POWER_LOW
(3)
/* low-power mode */
#define RT_SEN
SOR_POWER_HIGH
(4)
/* high-power mode */
/* Sensor work mode types */
#define RT_SEN
_MODE_NONE
(0)
#define RT_SEN
_MODE_POLLING
(1)
/* One shot only read a data */
#define RT_SEN
_MODE_INT
(2)
/* TODO: One shot interrupt only read a data */
#define RT_SEN
_MODE_FIFO
(3)
/* TODO: One shot interrupt read all fifo data */
#define RT_SEN
SOR_MODE_NONE
(0)
#define RT_SEN
SOR_MODE_POLLING
(1)
/* One shot only read a data */
#define RT_SEN
SOR_MODE_INT
(2)
/* TODO: One shot interrupt only read a data */
#define RT_SEN
SOR_MODE_FIFO
(3)
/* TODO: One shot interrupt read all fifo data */
/* Sensor control cmd types */
#define RT_SEN
_CTRL_GET_ID
(0)
/* Get device id */
#define RT_SEN
_CTRL_GET_INFO
(1)
/* Get sensor info */
#define RT_SEN
_CTRL_SET_RANGE
(2)
/* Set the measure range of sensor. unit is info of sensor */
#define RT_SEN
_CTRL_SET_ODR
(3)
/* Set output date rate. unit is HZ */
#define RT_SEN
_CTRL_SET_MODE (4)
/* Set sensor's work mode. ex. RT_SEN_MODE_POLLING,RT_SEN
_MODE_INT */
#define RT_SEN
_CTRL_SET_POWER (5)
/* Set power mode. args type of sensor power mode. ex. RT_SEN_POWER_DOWN,RT_SEN
_POWER_NORMAL */
#define RT_SEN
_CTRL_SELF_TEST
(6)
/* Take a self test */
#define RT_SEN
SOR_CTRL_GET_ID
(0)
/* Get device id */
#define RT_SEN
SOR_CTRL_GET_INFO
(1)
/* Get sensor info */
#define RT_SEN
SOR_CTRL_SET_RANGE
(2)
/* Set the measure range of sensor. unit is info of sensor */
#define RT_SEN
SOR_CTRL_SET_ODR
(3)
/* Set output date rate. unit is HZ */
#define RT_SEN
SOR_CTRL_SET_MODE (4)
/* Set sensor's work mode. ex. RT_SENSOR_MODE_POLLING,RT_SENSOR
_MODE_INT */
#define RT_SEN
SOR_CTRL_SET_POWER (5)
/* Set power mode. args type of sensor power mode. ex. RT_SENSOR_POWER_DOWN,RT_SENSOR
_POWER_NORMAL */
#define RT_SEN
SOR_CTRL_SELF_TEST
(6)
/* Take a self test */
struct
rt_sensor_info
{
...
...
@@ -148,10 +148,10 @@ typedef struct rt_sensor_device *rt_sensor_t;
struct
rt_sensor_module
{
rt_mutex_t
lock
;
/* The module lock */
rt_mutex_t
lock
;
/* The module lock */
rt_sensor_t
sen
[
RT_SEN_MODULE_MAX
];
/* The module contains a list of sensors */
rt_uint8_t
sen_num
;
/* Number of sensors contained in the module */
rt_sensor_t
sen
[
RT_SEN
SOR
_MODULE_MAX
];
/* The module contains a list of sensors */
rt_uint8_t
sen_num
;
/* Number of sensors contained in the module */
};
/* 3-axis Data Type */
...
...
components/drivers/sensors/sensor_test.c
浏览文件 @
37d04007
...
...
@@ -25,25 +25,25 @@ static void sensor_show_data(rt_size_t num, rt_sensor_t sensor, struct rt_sensor
{
switch
(
sensor
->
info
.
type
)
{
case
RT_SEN_CLASS_ACCE
:
case
RT_SEN
SOR
_CLASS_ACCE
:
LOG_I
(
"num:%3d, x:%5d, y:%5d, z:%5d, timestamp:%5d"
,
num
,
sensor_data
->
data
.
acce
.
x
,
sensor_data
->
data
.
acce
.
y
,
sensor_data
->
data
.
acce
.
z
,
sensor_data
->
timestamp
);
break
;
case
RT_SEN_CLASS_GYRO
:
case
RT_SEN
SOR
_CLASS_GYRO
:
LOG_I
(
"num:%3d, x:%8d, y:%8d, z:%8d, timestamp:%5d"
,
num
,
sensor_data
->
data
.
gyro
.
x
,
sensor_data
->
data
.
gyro
.
y
,
sensor_data
->
data
.
gyro
.
z
,
sensor_data
->
timestamp
);
break
;
case
RT_SEN_CLASS_MAG
:
case
RT_SEN
SOR
_CLASS_MAG
:
LOG_I
(
"num:%3d, x:%5d, y:%5d, z:%5d, timestamp:%5d"
,
num
,
sensor_data
->
data
.
mag
.
x
,
sensor_data
->
data
.
mag
.
y
,
sensor_data
->
data
.
mag
.
z
,
sensor_data
->
timestamp
);
break
;
case
RT_SEN_CLASS_HUMI
:
case
RT_SEN
SOR
_CLASS_HUMI
:
LOG_I
(
"num:%3d, humi:%3d.%d%%, timestamp:%5d"
,
num
,
sensor_data
->
data
.
humi
/
10
,
sensor_data
->
data
.
humi
%
10
,
sensor_data
->
timestamp
);
break
;
case
RT_SEN_CLASS_TEMP
:
case
RT_SEN
SOR
_CLASS_TEMP
:
LOG_I
(
"num:%3d, temp:%3d.%dC, timestamp:%5d"
,
num
,
sensor_data
->
data
.
temp
/
10
,
sensor_data
->
data
.
temp
%
10
,
sensor_data
->
timestamp
);
break
;
case
RT_SEN_CLASS_BARO
:
case
RT_SEN
SOR
_CLASS_BARO
:
LOG_I
(
"num:%3d, press:%5d, timestamp:%5d"
,
num
,
sensor_data
->
data
.
baro
,
sensor_data
->
timestamp
);
break
;
case
RT_SEN_CLASS_STEP
:
case
RT_SEN
SOR
_CLASS_STEP
:
LOG_I
(
"num:%3d, step:%5d, timestamp:%5d"
,
num
,
sensor_data
->
data
.
step
,
sensor_data
->
timestamp
);
break
;
default:
...
...
@@ -65,7 +65,7 @@ static void sensor_fifo_rx_entry(void *parameter)
struct
rt_sensor_info
info
;
rt_size_t
res
,
i
;
rt_device_control
(
dev
,
RT_SEN_CTRL_GET_INFO
,
&
info
);
rt_device_control
(
dev
,
RT_SEN
SOR
_CTRL_GET_INFO
,
&
info
);
data
=
rt_malloc
(
sizeof
(
struct
rt_sensor_data
)
*
info
.
fifo_max
);
if
(
data
==
RT_NULL
)
...
...
@@ -119,12 +119,12 @@ static void sensor_fifo(int argc, char **argv)
rt_device_set_rx_indicate
(
dev
,
rx_callback
);
if
(
rt_device_open
(
dev
,
RT_SEN_FLAG_FIFO
)
!=
RT_EOK
)
if
(
rt_device_open
(
dev
,
RT_SEN
SOR
_FLAG_FIFO
)
!=
RT_EOK
)
{
LOG_E
(
"open device failed!"
);
return
;
}
rt_device_control
(
dev
,
RT_SEN_CTRL_SET_ODR
,
(
void
*
)
20
);
rt_device_control
(
dev
,
RT_SEN
SOR
_CTRL_SET_ODR
,
(
void
*
)
20
);
}
#ifdef FINSH_USING_MSH
MSH_CMD_EXPORT
(
sensor_fifo
,
Sensor
fifo
mode
test
function
);
...
...
@@ -188,7 +188,7 @@ static void sensor_int(int argc, char **argv)
LOG_E
(
"open device failed!"
);
return
;
}
rt_device_control
(
dev
,
RT_SEN_CTRL_SET_ODR
,
(
void
*
)
20
);
rt_device_control
(
dev
,
RT_SEN
SOR
_CTRL_SET_ODR
,
(
void
*
)
20
);
}
#ifdef FINSH_USING_MSH
MSH_CMD_EXPORT
(
sensor_int
,
Sensor
interrupt
mode
test
function
);
...
...
@@ -218,7 +218,7 @@ static void sensor_polling(int argc, char **argv)
LOG_E
(
"open device failed!"
);
return
;
}
rt_device_control
(
dev
,
RT_SEN_CTRL_SET_ODR
,
(
void
*
)
100
);
rt_device_control
(
dev
,
RT_SEN
SOR
_CTRL_SET_ODR
,
(
void
*
)
100
);
for
(
i
=
0
;
i
<
num
;
i
++
)
{
...
...
@@ -263,7 +263,7 @@ static void sensor(int argc, char **argv)
else
if
(
!
strcmp
(
argv
[
1
],
"info"
))
{
struct
rt_sensor_info
info
;
rt_device_control
(
dev
,
RT_SEN_CTRL_GET_INFO
,
&
info
);
rt_device_control
(
dev
,
RT_SEN
SOR
_CTRL_GET_INFO
,
&
info
);
rt_kprintf
(
"vendor :%d
\n
"
,
info
.
vendor
);
rt_kprintf
(
"model :%s
\n
"
,
info
.
model
);
rt_kprintf
(
"unit :%d
\n
"
,
info
.
unit
);
...
...
@@ -321,7 +321,7 @@ static void sensor(int argc, char **argv)
LOG_E
(
"open device failed!"
);
return
;
}
rt_device_control
(
dev
,
RT_SEN_CTRL_GET_ID
,
&
reg
);
rt_device_control
(
dev
,
RT_SEN
SOR
_CTRL_GET_ID
,
&
reg
);
LOG_I
(
"device id: 0x%x!"
,
reg
);
}
...
...
@@ -332,19 +332,19 @@ static void sensor(int argc, char **argv)
}
else
if
(
!
strcmp
(
argv
[
1
],
"sr"
))
{
rt_device_control
(
dev
,
RT_SEN_CTRL_SET_RANGE
,
(
void
*
)
atoi
(
argv
[
2
]));
rt_device_control
(
dev
,
RT_SEN
SOR
_CTRL_SET_RANGE
,
(
void
*
)
atoi
(
argv
[
2
]));
}
else
if
(
!
strcmp
(
argv
[
1
],
"sm"
))
{
rt_device_control
(
dev
,
RT_SEN_CTRL_SET_MODE
,
(
void
*
)
atoi
(
argv
[
2
]));
rt_device_control
(
dev
,
RT_SEN
SOR
_CTRL_SET_MODE
,
(
void
*
)
atoi
(
argv
[
2
]));
}
else
if
(
!
strcmp
(
argv
[
1
],
"sp"
))
{
rt_device_control
(
dev
,
RT_SEN_CTRL_SET_POWER
,
(
void
*
)
atoi
(
argv
[
2
]));
rt_device_control
(
dev
,
RT_SEN
SOR
_CTRL_SET_POWER
,
(
void
*
)
atoi
(
argv
[
2
]));
}
else
if
(
!
strcmp
(
argv
[
1
],
"sodr"
))
{
rt_device_control
(
dev
,
RT_SEN_CTRL_SET_ODR
,
(
void
*
)
atoi
(
argv
[
2
]));
rt_device_control
(
dev
,
RT_SEN
SOR
_CTRL_SET_ODR
,
(
void
*
)
atoi
(
argv
[
2
]));
}
else
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录