[component][drivers][sensors]Increase the output of sensor information
Signed-off-by: Willian Chan <chentingwei@rt-thread.com>
This commit is contained in:
parent
c574c49b2f
commit
7db27345c2
|
@ -55,6 +55,7 @@ extern "C" {
|
|||
#define RT_SENSOR_VENDOR_SEMTECH (4) /* Semtech */
|
||||
#define RT_SENSOR_VENDOR_GOERTEK (5) /* Goertek */
|
||||
#define RT_SENSOR_VENDOR_MIRAMEMS (6) /* MiraMEMS */
|
||||
#define RT_SENSOR_VENDOR_DALLAS (7) /* Dallas */
|
||||
|
||||
/* Sensor unit types */
|
||||
|
||||
|
|
|
@ -4,8 +4,9 @@
|
|||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
* 2019-01-31 flybreak first version
|
||||
* Date Author Notes
|
||||
* 2019-01-31 flybreak first version
|
||||
* 2019-07-16 WillianChan Increase the output of sensor information
|
||||
*/
|
||||
|
||||
#include "sensor.h"
|
||||
|
@ -55,7 +56,7 @@ static void sensor_show_data(rt_size_t num, rt_sensor_t sensor, struct rt_sensor
|
|||
}
|
||||
}
|
||||
|
||||
static rt_err_t rx_callback(rt_device_t dev, rt_size_t size)
|
||||
rt_err_t rx_callback(rt_device_t dev, rt_size_t size)
|
||||
{
|
||||
rt_sem_release(sensor_rx_sem);
|
||||
return 0;
|
||||
|
@ -63,15 +64,15 @@ static rt_err_t rx_callback(rt_device_t dev, rt_size_t size)
|
|||
|
||||
static void sensor_fifo_rx_entry(void *parameter)
|
||||
{
|
||||
rt_device_t dev = (rt_device_t)parameter;
|
||||
rt_sensor_t sensor = (rt_sensor_t)parameter;
|
||||
rt_device_t dev = parameter;
|
||||
rt_sensor_t sensor = parameter;
|
||||
struct rt_sensor_data *data = RT_NULL;
|
||||
struct rt_sensor_info info;
|
||||
rt_size_t res, i;
|
||||
|
||||
rt_device_control(dev, RT_SENSOR_CTRL_GET_INFO, &info);
|
||||
|
||||
data = (struct rt_sensor_data *)rt_malloc(sizeof(struct rt_sensor_data) * info.fifo_max);
|
||||
data = rt_malloc(sizeof(struct rt_sensor_data) * info.fifo_max);
|
||||
if (data == RT_NULL)
|
||||
{
|
||||
LOG_E("Memory allocation failed!");
|
||||
|
@ -137,8 +138,8 @@ MSH_CMD_EXPORT(sensor_fifo, Sensor fifo mode test function);
|
|||
|
||||
static void sensor_irq_rx_entry(void *parameter)
|
||||
{
|
||||
rt_device_t dev = (rt_device_t)parameter;
|
||||
rt_sensor_t sensor = (rt_sensor_t)parameter;
|
||||
rt_device_t dev = parameter;
|
||||
rt_sensor_t sensor = parameter;
|
||||
struct rt_sensor_data data;
|
||||
rt_size_t res, i = 0;
|
||||
|
||||
|
@ -268,13 +269,88 @@ static void sensor(int argc, char **argv)
|
|||
else if (!strcmp(argv[1], "info"))
|
||||
{
|
||||
struct rt_sensor_info info;
|
||||
if (dev == RT_NULL)
|
||||
{
|
||||
LOG_W("Please probe sensor device first!");
|
||||
return ;
|
||||
}
|
||||
rt_device_control(dev, RT_SENSOR_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);
|
||||
switch (info.vendor)
|
||||
{
|
||||
case 0:
|
||||
rt_kprintf("vendor :unknown vendor\n");
|
||||
break;
|
||||
case 1:
|
||||
rt_kprintf("vendor :STMicroelectronics\n");
|
||||
break;
|
||||
case 2:
|
||||
rt_kprintf("vendor :Bosch\n");
|
||||
break;
|
||||
case 3:
|
||||
rt_kprintf("vendor :Invensense\n");
|
||||
break;
|
||||
case 4:
|
||||
rt_kprintf("vendor :Semtech\n");
|
||||
break;
|
||||
case 5:
|
||||
rt_kprintf("vendor :Goertek\n");
|
||||
break;
|
||||
case 6:
|
||||
rt_kprintf("vendor :MiraMEMS\n");
|
||||
break;
|
||||
case 7:
|
||||
rt_kprintf("vendor :Dallas\n");
|
||||
break;
|
||||
}
|
||||
rt_kprintf("model :%s\n", info.model);
|
||||
switch (info.unit)
|
||||
{
|
||||
case 0:
|
||||
rt_kprintf("unit :none\n");
|
||||
break;
|
||||
case 1:
|
||||
rt_kprintf("unit :mG\n");
|
||||
break;
|
||||
case 2:
|
||||
rt_kprintf("unit :mdps\n");
|
||||
break;
|
||||
case 3:
|
||||
rt_kprintf("unit :mGauss\n");
|
||||
break;
|
||||
case 4:
|
||||
rt_kprintf("unit :lux\n");
|
||||
break;
|
||||
case 5:
|
||||
rt_kprintf("unit :cm\n");
|
||||
break;
|
||||
case 6:
|
||||
rt_kprintf("unit :pa\n");
|
||||
break;
|
||||
case 7:
|
||||
rt_kprintf("unit :permillage\n");
|
||||
break;
|
||||
case 8:
|
||||
rt_kprintf("unit :Celsius\n");
|
||||
break;
|
||||
case 9:
|
||||
rt_kprintf("unit :HZ\n");
|
||||
break;
|
||||
case 10:
|
||||
rt_kprintf("unit :1\n");
|
||||
break;
|
||||
case 11:
|
||||
rt_kprintf("unit :bpm\n");
|
||||
break;
|
||||
case 12:
|
||||
rt_kprintf("unit :mm\n");
|
||||
break;
|
||||
case 13:
|
||||
rt_kprintf("unit :mN\n");
|
||||
break;
|
||||
}
|
||||
rt_kprintf("range_max :%d\n", info.range_max);
|
||||
rt_kprintf("range_min :%d\n", info.range_min);
|
||||
rt_kprintf("period_min:%d\n", info.period_min);
|
||||
rt_kprintf("period_min:%dms\n", info.period_min);
|
||||
rt_kprintf("fifo_max :%d\n", info.fifo_max);
|
||||
}
|
||||
else if (!strcmp(argv[1], "read"))
|
||||
|
|
Loading…
Reference in New Issue