Merge pull request #2587 from baozi119/master

Add new sensor type and vendor type.
This commit is contained in:
Bernard Xiong 2019-04-17 22:07:32 +08:00 committed by GitHub
commit 5d87dce636
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 0 deletions

1
components/drivers/sensors/sensor.c Normal file → Executable file
View File

@ -31,6 +31,7 @@ static char *const sensor_name_str[] =
"tvoc_", /* TVOC Level */
"noi_", /* Noise Loudness */
"step_" /* Step sensor */
"forc_" /* Force sensor */
};
/* Sensor interrupt correlation function */

4
components/drivers/sensors/sensor.h Normal file → Executable file
View File

@ -44,6 +44,7 @@ extern "C" {
#define RT_SENSOR_CLASS_TVOC (10) /* TVOC Level */
#define RT_SENSOR_CLASS_NOISE (11) /* Noise Loudness */
#define RT_SENSOR_CLASS_STEP (12) /* Step sensor */
#define RT_SENSOR_CLASS_FORCE (13) /* Force sensor */
/* Sensor vendor types */
@ -53,6 +54,7 @@ extern "C" {
#define RT_SENSOR_VENDOR_INVENSENSE (3) /* Invensense */
#define RT_SENSOR_VENDOR_SEMTECH (4) /* Semtech */
#define RT_SENSOR_VENDOR_GOERTEK (5) /* Goertek */
#define RT_SENSOR_VENDOR_MIRAMEMS (6) /* MiraMEMS */
/* Sensor unit types */
@ -69,6 +71,7 @@ extern "C" {
#define RT_SENSOR_UNIT_ONE (10) /* Dimensionless quantity unit: 1 */
#define RT_SENSOR_UNIT_BPM (11) /* Heart rate unit: bpm */
#define RT_SENSOR_UNIT_MM (12) /* Distance unit: mm */
#define RT_SENSOR_UNIT_MN (13) /* Force unit: mN */
/* Sensor communication interface types */
@ -185,6 +188,7 @@ struct rt_sensor_data
rt_int32_t tvoc; /* TVOC. unit: permillage */
rt_int32_t noise; /* Noise Loudness. unit: HZ */
rt_uint32_t step; /* Step sensor. unit: 1 */
rt_int32_t force; /* Force sensor. unit: mN */
} data;
};

3
components/drivers/sensors/sensor_cmd.c Normal file → Executable file
View File

@ -47,6 +47,9 @@ static void sensor_show_data(rt_size_t num, rt_sensor_t sensor, struct rt_sensor
case RT_SENSOR_CLASS_PROXIMITY:
LOG_I("num:%3d, distance:%5d, timestamp:%5d", num, sensor_data->data.proximity, sensor_data->timestamp);
break;
case RT_SENSOR_CLASS_FORCE:
LOG_I("num:%3d, force:%5d, timestamp:%5d", num, sensor_data->data.force, sensor_data->timestamp);
break;
default:
break;
}