From 6bfbbc18f2c285264362b95e1a75567a36e57a4f Mon Sep 17 00:00:00 2001 From: wgzAIIT <820906721@qq.com> Date: Fri, 7 Jan 2022 12:08:14 +0800 Subject: [PATCH] add hcho1os sensor support Nuttx --- .../sensor_app/hcho_tb600b_wq_hcho1os.c | 4 +++- APP_Framework/Framework/sensor/hcho/Kconfig | 5 +++++ APP_Framework/Framework/sensor/hcho/Make.defs | 4 ++++ .../sensor/hcho/tb600b_wq_hcho1os/Make.defs | 6 ++++++ .../sensor/hcho/tb600b_wq_hcho1os/Makefile | 13 +++++++++++-- .../hcho/tb600b_wq_hcho1os/tb600b_wq_hcho1os.c | 13 +++++++++++++ .../Nuttx/app_match_nuttx/apps/nshlib/Kconfig | 5 ++++- .../Nuttx/app_match_nuttx/apps/nshlib/nsh.h | 5 ++++- .../apps/nshlib/nsh_Applicationscmd.c | 17 ++++++++++++++++- .../app_match_nuttx/apps/nshlib/nsh_command.c | 6 +++++- 10 files changed, 71 insertions(+), 7 deletions(-) create mode 100644 APP_Framework/Framework/sensor/hcho/Make.defs create mode 100644 APP_Framework/Framework/sensor/hcho/tb600b_wq_hcho1os/Make.defs diff --git a/APP_Framework/Applications/sensor_app/hcho_tb600b_wq_hcho1os.c b/APP_Framework/Applications/sensor_app/hcho_tb600b_wq_hcho1os.c index 09e2b7858..45bceb20e 100644 --- a/APP_Framework/Applications/sensor_app/hcho_tb600b_wq_hcho1os.c +++ b/APP_Framework/Applications/sensor_app/hcho_tb600b_wq_hcho1os.c @@ -18,7 +18,9 @@ * @date 2021.12.15 */ -#include +#ifdef ADD_XIUOS_FETURES +# include +#endif #include diff --git a/APP_Framework/Framework/sensor/hcho/Kconfig b/APP_Framework/Framework/sensor/hcho/Kconfig index 0b5ad82dd..3ed337687 100644 --- a/APP_Framework/Framework/sensor/hcho/Kconfig +++ b/APP_Framework/Framework/sensor/hcho/Kconfig @@ -34,6 +34,11 @@ config SENSOR_TB600B_WQ_HCHO1OS endif if ADD_NUTTX_FETURES + config SENSOR_DEVICE_TB600B_WQ_HCHO1OS_DEV + string "tb600b wq_hcho1os device uart path" + default "/dev/ttyS1" + ---help--- + If USART1 is selected, then fill in /dev/ttyS1 here. endif diff --git a/APP_Framework/Framework/sensor/hcho/Make.defs b/APP_Framework/Framework/sensor/hcho/Make.defs new file mode 100644 index 000000000..d3012ada7 --- /dev/null +++ b/APP_Framework/Framework/sensor/hcho/Make.defs @@ -0,0 +1,4 @@ +############################################################################ +# APP_Framework/Framework/sensor/hcho/Make.defs +############################################################################ +include $(wildcard $(APPDIR)/../../../APP_Framework/Framework/sensor/hcho/*/Make.defs) diff --git a/APP_Framework/Framework/sensor/hcho/tb600b_wq_hcho1os/Make.defs b/APP_Framework/Framework/sensor/hcho/tb600b_wq_hcho1os/Make.defs new file mode 100644 index 000000000..3d040f6c5 --- /dev/null +++ b/APP_Framework/Framework/sensor/hcho/tb600b_wq_hcho1os/Make.defs @@ -0,0 +1,6 @@ +############################################################################ +# APP_Framework/Framework/sensor/hcho/tb600b_wq_hcho1os/Make.defs +############################################################################ +ifneq ($(CONFIG_SENSOR_TB600B_WQ_HCHO1OS),) +CONFIGURED_APPS += $(APPDIR)/../../../APP_Framework/Framework/sensor/hcho/tb600b_wq_hcho1os +endif diff --git a/APP_Framework/Framework/sensor/hcho/tb600b_wq_hcho1os/Makefile b/APP_Framework/Framework/sensor/hcho/tb600b_wq_hcho1os/Makefile index 3dec9399d..796f89510 100644 --- a/APP_Framework/Framework/sensor/hcho/tb600b_wq_hcho1os/Makefile +++ b/APP_Framework/Framework/sensor/hcho/tb600b_wq_hcho1os/Makefile @@ -1,3 +1,12 @@ -SRC_FILES := tb600b_wq_hcho1os.c +include $(KERNEL_ROOT)/.config -include $(KERNEL_ROOT)/compiler.mk +ifeq ($(CONFIG_ADD_NUTTX_FETURES),y) + include $(APPDIR)/Make.defs + CSRCS += tb600b_wq_hcho1os.c + include $(APPDIR)/Application.mk +endif + +ifeq ($(CONFIG_ADD_XIUOS_FETURES),y) + SRC_FILES := tb600b_wq_hcho1os.c + include $(KERNEL_ROOT)/compiler.mk +endif diff --git a/APP_Framework/Framework/sensor/hcho/tb600b_wq_hcho1os/tb600b_wq_hcho1os.c b/APP_Framework/Framework/sensor/hcho/tb600b_wq_hcho1os/tb600b_wq_hcho1os.c index 96ede2fc9..d1c103c8e 100644 --- a/APP_Framework/Framework/sensor/hcho/tb600b_wq_hcho1os/tb600b_wq_hcho1os.c +++ b/APP_Framework/Framework/sensor/hcho/tb600b_wq_hcho1os/tb600b_wq_hcho1os.c @@ -35,6 +35,18 @@ static struct SensorProductInfo info = * @param sdev - sensor device pointer * @return success: 1 , failure: other */ +#ifdef ADD_NUTTX_FETURES +static int SensorDeviceOpen(struct SensorDevice *sdev) +{ + sdev->fd = PrivOpen(SENSOR_DEVICE_TB600B_WQ_HCHO1OS_DEV, O_RDWR); + if (sdev->fd < 0) { + printf("open %s error\n", SENSOR_DEVICE_TB600B_WQ_HCHO1OS_DEV); + return -1; + } + + return sdev->fd; +} +#else static int SensorDeviceOpen(struct SensorDevice *sdev) { int result = 0; @@ -65,6 +77,7 @@ static int SensorDeviceOpen(struct SensorDevice *sdev) return result; } +#endif /** * @description: Read sensor device diff --git a/Ubiquitous/Nuttx/app_match_nuttx/apps/nshlib/Kconfig b/Ubiquitous/Nuttx/app_match_nuttx/apps/nshlib/Kconfig index ba14ac2ba..d093e55d2 100644 --- a/Ubiquitous/Nuttx/app_match_nuttx/apps/nshlib/Kconfig +++ b/Ubiquitous/Nuttx/app_match_nuttx/apps/nshlib/Kconfig @@ -588,8 +588,11 @@ config NSH_DISABLE_XD default y if DEFAULT_SMALL default n if !DEFAULT_SMALL +config NSH_DISABLE_HCHO_TB600B_WQ_HCHO1OS + bool "Disable the sensor tb600b_wq_hcho1os." + default n -config NSH_DISABLE_TVOC_10 +config NSH_DISABLE_TB600B_TVOC10 bool "Disable the sensor tb600b_tvoc10." default n diff --git a/Ubiquitous/Nuttx/app_match_nuttx/apps/nshlib/nsh.h b/Ubiquitous/Nuttx/app_match_nuttx/apps/nshlib/nsh.h index 0319d4f2b..b27206912 100644 --- a/Ubiquitous/Nuttx/app_match_nuttx/apps/nshlib/nsh.h +++ b/Ubiquitous/Nuttx/app_match_nuttx/apps/nshlib/nsh.h @@ -1403,8 +1403,11 @@ int nsh_foreach_var(FAR struct nsh_vtbl_s *vtbl, nsh_foreach_var_t cb, FAR void *arg); #endif +#if defined(CONFIG_APPLICATION_SENSOR_HCHO_TB600B_WQ_HCHO1OS) && !defined(CONFIG_NSH_DISABLE_HCHO_TB600B_WQ_HCHO1OS) + int cmd_Hcho1os(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv); +#endif -#if defined(CONFIG_APPLICATION_SENSOR_TVOC_TB600B_TVOC10) && !defined(CONFIG_NSH_DISABLE_TVOC_10) +#if defined(CONFIG_APPLICATION_SENSOR_TVOC_TB600B_TVOC10) && !defined(CONFIG_NSH_DISABLE_TB600B_TVOC10) int cmd_Tvoc10(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv); #endif diff --git a/Ubiquitous/Nuttx/app_match_nuttx/apps/nshlib/nsh_Applicationscmd.c b/Ubiquitous/Nuttx/app_match_nuttx/apps/nshlib/nsh_Applicationscmd.c index 2288cff38..676ea9959 100644 --- a/Ubiquitous/Nuttx/app_match_nuttx/apps/nshlib/nsh_Applicationscmd.c +++ b/Ubiquitous/Nuttx/app_match_nuttx/apps/nshlib/nsh_Applicationscmd.c @@ -52,11 +52,26 @@ extern int FrameworkInit(void); +/**************************************************************************** + * Name: cmd_Hcho1os + ****************************************************************************/ + +#if defined(CONFIG_APPLICATION_SENSOR_TVOC_TB600B_TVOC10) && !defined(CONFIG_NSH_DISABLE_TB600B_TVOC10) +extern void HchoTb600bHcho1os(void); +int cmd_Hcho1os(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv) +{ + printf("Hello, world!\n"); + FrameworkInit(); + HchoTb600bHcho1os(); + return 0; +} +#endif + /**************************************************************************** * Name: cmd_Tvoc10 ****************************************************************************/ -#if defined(CONFIG_APPLICATION_SENSOR_TVOC_TB600B_TVOC10) && !defined(CONFIG_NSH_DISABLE_TVOC_10) +#if defined(CONFIG_APPLICATION_SENSOR_TVOC_TB600B_TVOC10) && !defined(CONFIG_NSH_DISABLE_TB600B_TVOC10) extern void TvocTb600bTvoc10(void); int cmd_Tvoc10(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv) { diff --git a/Ubiquitous/Nuttx/app_match_nuttx/apps/nshlib/nsh_command.c b/Ubiquitous/Nuttx/app_match_nuttx/apps/nshlib/nsh_command.c index 0ba866d6d..28dc9468a 100644 --- a/Ubiquitous/Nuttx/app_match_nuttx/apps/nshlib/nsh_command.c +++ b/Ubiquitous/Nuttx/app_match_nuttx/apps/nshlib/nsh_command.c @@ -580,7 +580,11 @@ static const struct cmdmap_s g_cmdmap[] = { "xd", cmd_xd, 3, 3, " " }, #endif -#if defined(CONFIG_APPLICATION_SENSOR_TVOC_TB600B_TVOC10) && !defined(CONFIG_NSH_DISABLE_TVOC_10) +#if defined(CONFIG_APPLICATION_SENSOR_HCHO_TB600B_WQ_HCHO1OS) && !defined(CONFIG_NSH_DISABLE_HCHO_TB600B_WQ_HCHO1OS) + { "hcho1os", cmd_Hcho1os, 1, 1, "[get the concentration of formaldehyde with sensor tb600b_wq_hcho1os.]" }, +#endif + +#if defined(CONFIG_APPLICATION_SENSOR_TVOC_TB600B_TVOC10) && !defined(CONFIG_NSH_DISABLE_TB600B_TVOC10) { "tvoc10", cmd_Tvoc10, 1, 1, "[get the concentration of tvoc with sensor tb600b_tvoc10.]" }, #endif