mirror of
https://github.com/apache/nuttx-apps.git
synced 2026-10-08 22:55:12 +00:00
system/uorb: add voltage, current and power topics
Declare and define the uORB metadata for the voltage, current and power types, and register them in g_sensor_list[] so that orb_get_meta() and uorb_listener can resolve them by name. Signed-off-by: likun17 <likun17@xiaomi.com>
This commit is contained in:
parent
00d9af873d
commit
b93c947608
7 changed files with 243 additions and 0 deletions
41
system/uorb/sensor/current.c
Normal file
41
system/uorb/sensor/current.c
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
/****************************************************************************
|
||||
* apps/system/uorb/sensor/current.c
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership. The
|
||||
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <sensor/current.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_UORB_FORMAT
|
||||
static const char sensor_current_format[] =
|
||||
"timestamp:%" PRIu64 ",current:%hf";
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
ORB_DEFINE(sensor_current, struct sensor_current,
|
||||
sensor_current_format);
|
||||
38
system/uorb/sensor/current.h
Normal file
38
system/uorb/sensor/current.h
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
/****************************************************************************
|
||||
* apps/system/uorb/sensor/current.h
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership. The
|
||||
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __APPS_SYSTEM_UORB_SENSOR_CURRENT_H
|
||||
#define __APPS_SYSTEM_UORB_SENSOR_CURRENT_H
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <uORB/uORB.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
/* register this as object request broker structure */
|
||||
|
||||
ORB_DECLARE(sensor_current);
|
||||
|
||||
#endif
|
||||
41
system/uorb/sensor/power.c
Normal file
41
system/uorb/sensor/power.c
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
/****************************************************************************
|
||||
* apps/system/uorb/sensor/power.c
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership. The
|
||||
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <sensor/power.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_UORB_FORMAT
|
||||
static const char sensor_power_format[] =
|
||||
"timestamp:%" PRIu64 ",power:%hf";
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
ORB_DEFINE(sensor_power, struct sensor_power,
|
||||
sensor_power_format);
|
||||
38
system/uorb/sensor/power.h
Normal file
38
system/uorb/sensor/power.h
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
/****************************************************************************
|
||||
* apps/system/uorb/sensor/power.h
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership. The
|
||||
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __APPS_SYSTEM_UORB_SENSOR_POWER_H
|
||||
#define __APPS_SYSTEM_UORB_SENSOR_POWER_H
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <uORB/uORB.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
/* register this as object request broker structure */
|
||||
|
||||
ORB_DECLARE(sensor_power);
|
||||
|
||||
#endif
|
||||
|
|
@ -36,6 +36,7 @@
|
|||
#include <sensor/baro.h>
|
||||
#include <sensor/cap.h>
|
||||
#include <sensor/co2.h>
|
||||
#include <sensor/current.h>
|
||||
#include <sensor/dust.h>
|
||||
#include <sensor/ecg.h>
|
||||
#include <sensor/eng.h>
|
||||
|
|
@ -61,6 +62,7 @@
|
|||
#include <sensor/pm1p0.h>
|
||||
#include <sensor/pm10.h>
|
||||
#include <sensor/pose_6dof.h>
|
||||
#include <sensor/power.h>
|
||||
#include <sensor/ppgd.h>
|
||||
#include <sensor/ppgq.h>
|
||||
#include <sensor/prox.h>
|
||||
|
|
@ -71,6 +73,7 @@
|
|||
#include <sensor/tvoc.h>
|
||||
#include <sensor/uv.h>
|
||||
#include <sensor/velocity.h>
|
||||
#include <sensor/voltage.h>
|
||||
|
||||
#include <uORB/uORB.h>
|
||||
|
||||
|
|
@ -87,6 +90,7 @@ static FAR const struct orb_metadata *g_sensor_list[] =
|
|||
ORB_ID(sensor_baro),
|
||||
ORB_ID(sensor_cap),
|
||||
ORB_ID(sensor_co2),
|
||||
ORB_ID(sensor_current),
|
||||
ORB_ID(sensor_device_orientation),
|
||||
ORB_ID(sensor_dust),
|
||||
ORB_ID(sensor_ecg),
|
||||
|
|
@ -128,6 +132,7 @@ static FAR const struct orb_metadata *g_sensor_list[] =
|
|||
ORB_ID(sensor_pm1p0),
|
||||
ORB_ID(sensor_pm25),
|
||||
ORB_ID(sensor_pose_6dof),
|
||||
ORB_ID(sensor_power),
|
||||
ORB_ID(sensor_ppgd),
|
||||
ORB_ID(sensor_ppgq),
|
||||
ORB_ID(sensor_prox),
|
||||
|
|
@ -142,6 +147,7 @@ static FAR const struct orb_metadata *g_sensor_list[] =
|
|||
ORB_ID(sensor_tvoc),
|
||||
ORB_ID(sensor_uv),
|
||||
ORB_ID(sensor_velocity),
|
||||
ORB_ID(sensor_voltage),
|
||||
ORB_ID(sensor_wake_gesture),
|
||||
ORB_ID(sensor_wake_gesture_uncal),
|
||||
ORB_ID(sensor_wrist_tilt),
|
||||
|
|
|
|||
41
system/uorb/sensor/voltage.c
Normal file
41
system/uorb/sensor/voltage.c
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
/****************************************************************************
|
||||
* apps/system/uorb/sensor/voltage.c
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership. The
|
||||
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <sensor/voltage.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_UORB_FORMAT
|
||||
static const char sensor_voltage_format[] =
|
||||
"timestamp:%" PRIu64 ",voltage:%hf";
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
ORB_DEFINE(sensor_voltage, struct sensor_voltage,
|
||||
sensor_voltage_format);
|
||||
38
system/uorb/sensor/voltage.h
Normal file
38
system/uorb/sensor/voltage.h
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
/****************************************************************************
|
||||
* apps/system/uorb/sensor/voltage.h
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership. The
|
||||
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __APPS_SYSTEM_UORB_SENSOR_VOLTAGE_H
|
||||
#define __APPS_SYSTEM_UORB_SENSOR_VOLTAGE_H
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <uORB/uORB.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
/* register this as object request broker structure */
|
||||
|
||||
ORB_DECLARE(sensor_voltage);
|
||||
|
||||
#endif
|
||||
Loading…
Add table
Add a link
Reference in a new issue