diff --git a/components/drivers/include/drivers/sensor.h b/components/drivers/include/drivers/sensor.h index 537266d705..ca1c84e0c2 100644 --- a/components/drivers/include/drivers/sensor.h +++ b/components/drivers/include/drivers/sensor.h @@ -53,6 +53,9 @@ extern "C" { #define RT_SENSOR_CLASS_IAQ (19) /* IAQ sensor. */ #define RT_SENSOR_CLASS_ETOH (20) /* EtOH sensor. */ #define RT_SENSOR_CLASS_BP (21) /* Blood Pressure */ +#define RT_SENSOR_CLASS_VOLTAGE (22) /* Voltage sensor */ +#define RT_SENSOR_CLASS_CURRENT (23) /* Current sensor */ +#define RT_SENSOR_CLASS_POWER (24) /* Power sensor */ /* Sensor vendor types */ @@ -95,6 +98,9 @@ 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 */ +#define RT_SENSOR_UNIT_MV (20) /* Voltage unit: mV */ +#define RT_SENSOR_UNIT_MA (21) /* Current unit: mA */ +#define RT_SENSOR_UNIT_MW (22) /* Power unit: mW */ /* Sensor communication interface types */ #define RT_SENSOR_INTF_I2C (1 << 0) @@ -230,9 +236,12 @@ struct rt_sensor_data rt_uint32_t dust; /* Dust sensor. unit: ug/m3 */ rt_uint32_t eco2; /* eCO2 sensor. unit: ppm */ rt_uint32_t spo2; /* SpO2 sensor. unit: permillage */ - rt_uint32_t iaq; /* IAQ sensor. unit: 1 */ - rt_uint32_t etoh; /* EtOH sensor. unit: ppm */ + rt_uint32_t iaq; /* IAQ sensor. unit: 1 */ + rt_uint32_t etoh; /* EtOH sensor. unit: ppm */ struct sensor_bp bp; /* BloodPressure. unit: mmHg */ + float mv; /* Voltage sensor. unit: mv */ + float ma; /* Current sensor. unit: ma */ + float mw; /* Power sensor. unit: mw */ } data; }; diff --git a/components/drivers/sensor/v1/sensor.c b/components/drivers/sensor/v1/sensor.c index 6da12f9342..479cf8326c 100644 --- a/components/drivers/sensor/v1/sensor.c +++ b/components/drivers/sensor/v1/sensor.c @@ -40,7 +40,10 @@ static char *const sensor_name_str[] = "spo2_", /* SpO2 sensor */ "iaq_", /* IAQ sensor */ "etoh_", /* EtOH sensor */ - "bp_" /* Blood Pressure */ + "bp_", /* Blood Pressure */ + "volt_", /* Voltage sensor */ + "curr_", /* Current sensor */ + "pow_" /* Power sensor */ }; /* Sensor interrupt correlation function */ diff --git a/components/drivers/sensor/v1/sensor_cmd.c b/components/drivers/sensor/v1/sensor_cmd.c index cb98385b79..486bd0bd04 100644 --- a/components/drivers/sensor/v1/sensor_cmd.c +++ b/components/drivers/sensor/v1/sensor_cmd.c @@ -83,6 +83,15 @@ static void sensor_show_data(rt_size_t num, rt_sensor_t sensor, struct rt_sensor case RT_SENSOR_CLASS_BP: LOG_I("num:%3d, bp.sbp:%5d mmHg, bp.dbp:%5d mmHg, timestamp:%5d", num, sensor_data->data.bp.sbp, sensor_data->data.bp.dbp, sensor_data->timestamp); break; + case RT_SENSOR_CLASS_VOLTAGE: + LOG_I("num:%3d, voltage:%5d mV, timestamp:%5d", num, sensor_data->data.mv, sensor_data->timestamp); + break; + case RT_SENSOR_CLASS_CURRENT: + LOG_I("num:%3d, current:%5d mA, timestamp:%5d", num, sensor_data->data.ma, sensor_data->timestamp); + break; + case RT_SENSOR_CLASS_POWER: + LOG_I("num:%3d, power:%5d mW, timestamp:%5d", num, sensor_data->data.mv, sensor_data->timestamp); + break; default: break; } @@ -302,7 +311,7 @@ static int sensor(int argc, char **argv) rt_kprintf(" sodr Set output date rate to var\n"); rt_kprintf(" read [num] Read [num] times sensor\n"); rt_kprintf(" num default 5\n"); - return ; + return -RT_EINVAL; } else if (!strcmp(argv[1], "info")) { @@ -418,6 +427,15 @@ static int sensor(int argc, char **argv) case RT_SENSOR_UNIT_MMHG: rt_kprintf("unit :mmHg\n"); break; + case RT_SENSOR_UNIT_MV: + rt_kprintf("unit :mV\n"); + break; + case RT_SENSOR_UNIT_MA: + rt_kprintf("unit :mA\n"); + break; + case RT_SENSOR_UNIT_MW: + rt_kprintf("unit :mW\n"); + break; } rt_kprintf("range_max :%d\n", info.range_max); rt_kprintf("range_min :%d\n", info.range_min);