forked from xuos/xiuos
				
			add g8s sensor support Nuttx on stm32f407-discovery
This commit is contained in:
		
							parent
							
								
									71f00ec06f
								
							
						
					
					
						commit
						21dce4f25e
					
				|  | @ -32,6 +32,7 @@ extern int Ps5308Pm1_0Init(void); | ||||||
| extern int Ps5308Pm2_5Init(void); | extern int Ps5308Pm2_5Init(void); | ||||||
| extern int Ps5308Pm10Init(void); | extern int Ps5308Pm10Init(void); | ||||||
| extern int Zg09Co2Init(void); | extern int Zg09Co2Init(void); | ||||||
|  | extern int G8sCo2Init(void); | ||||||
| extern int As830Ch4Init(void); | extern int As830Ch4Init(void); | ||||||
| extern int Tb600bIaq10IaqInit(void); | extern int Tb600bIaq10IaqInit(void); | ||||||
| extern int Tb600bTvoc10TvocInit(void); | extern int Tb600bTvoc10TvocInit(void); | ||||||
|  | @ -106,6 +107,10 @@ static struct InitDesc sensor_desc[] = | ||||||
| 	{ "zg09_co2", Zg09Co2Init }, | 	{ "zg09_co2", Zg09Co2Init }, | ||||||
| #endif | #endif | ||||||
| 
 | 
 | ||||||
|  | #ifdef SENSOR_G8S | ||||||
|  | 	{ "g8s_co2", G8sCo2Init }, | ||||||
|  | #endif | ||||||
|  | 
 | ||||||
| #ifdef SENSOR_QS_FX | #ifdef SENSOR_QS_FX | ||||||
| 	{ "qs_fx_wind_direction", QsFxWindDirectionInit }, | 	{ "qs_fx_wind_direction", QsFxWindDirectionInit }, | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
|  | @ -23,6 +23,10 @@ ifeq ($(CONFIG_ADD_NUTTX_FETURES),y) | ||||||
|         CSRCS += co2_zg09.c |         CSRCS += co2_zg09.c | ||||||
|     endif |     endif | ||||||
| 
 | 
 | ||||||
|  |     ifeq ($(CONFIG_APPLICATION_SENSOR_CO2_G8S), y) | ||||||
|  |         CSRCS += co2_g8s.c | ||||||
|  |     endif | ||||||
|  | 
 | ||||||
|     ifeq ($(CONFIG_APPLICATION_SENSOR_PM1_0_PS5308), y) |     ifeq ($(CONFIG_APPLICATION_SENSOR_PM1_0_PS5308), y) | ||||||
|         CSRCS += pm1_0_ps5308.c |         CSRCS += pm1_0_ps5308.c | ||||||
|     endif |     endif | ||||||
|  |  | ||||||
|  | @ -17,8 +17,10 @@ | ||||||
|  * @author AIIT XUOS Lab |  * @author AIIT XUOS Lab | ||||||
|  * @date 2021.12.23 |  * @date 2021.12.23 | ||||||
|  */ |  */ | ||||||
| 
 | //
 | ||||||
| #include <user_api.h> | #ifdef ADD_XIZI_FETURES | ||||||
|  | # include <user_api.h> | ||||||
|  | #endif | ||||||
| #include <sensor.h> | #include <sensor.h> | ||||||
| 
 | 
 | ||||||
| /**
 | /**
 | ||||||
|  |  | ||||||
|  | @ -64,6 +64,7 @@ config SENSOR_ZG09 | ||||||
|                 endif                 |                 endif                 | ||||||
|         endif |         endif | ||||||
| 
 | 
 | ||||||
|  | 
 | ||||||
| config SENSOR_G8S | config SENSOR_G8S | ||||||
|         bool "Using g8-s" |         bool "Using g8-s" | ||||||
|         default n |         default n | ||||||
|  | @ -99,10 +100,31 @@ config SENSOR_G8S | ||||||
|                 endif |                 endif | ||||||
| 
 | 
 | ||||||
|                 if ADD_NUTTX_FETURES |                 if ADD_NUTTX_FETURES | ||||||
| 
 |                        config SENSOR_DEVICE_G8S_DEV | ||||||
|  |                                string "CO2 device name" | ||||||
|  |                                default "/dev/ttyS1" | ||||||
|  |                                ---help--- | ||||||
|  |                                    If USART1 is selected, then fill in /dev/ttyS1 here. | ||||||
|                 endif |                 endif | ||||||
| 
 | 
 | ||||||
|                 if ADD_RTTHREAD_FETURES |                 if ADD_RTTHREAD_FETURES | ||||||
|  |                         config SENSOR_G8S_DRIVER_EXTUART | ||||||
|  |                                 bool "Using extra uart to support g8-s" | ||||||
|  |                                 default y | ||||||
| 
 | 
 | ||||||
|  |                         config SENSOR_DEVICE_G8S_DEV | ||||||
|  |                                 string "g8-s device uart path" | ||||||
|  |                                 default "/dev/uart2_dev2" | ||||||
|  |                                 depends on !SENSOR_G8S_DRIVER_EXTUART | ||||||
|  | 
 | ||||||
|  |                         if SENSOR_G8S_DRIVER_EXTUART | ||||||
|  |                                 config SENSOR_DEVICE_G8S_DEV | ||||||
|  |                                         string "g8-s device extra uart path" | ||||||
|  |                                         default "/dev/extuart_dev4" | ||||||
|  | 
 | ||||||
|  |                                 config SENSOR_DEVICE_G8S_DEV_EXT_PORT | ||||||
|  |                                         int "if G8S device using extuart, choose port" | ||||||
|  |                                         default "4" | ||||||
|  |                         endif | ||||||
|                 endif                 |                 endif                 | ||||||
|         endif |         endif | ||||||
|  |  | ||||||
|  | @ -1,3 +1,13 @@ | ||||||
| SRC_FILES := g8s.c | include $(KERNEL_ROOT)/.config | ||||||
|  | 
 | ||||||
|  | ifeq ($(CONFIG_ADD_NUTTX_FETURES),y) | ||||||
|  |     include $(APPDIR)/Make.defs | ||||||
|  |     CSRCS += g8s.c | ||||||
|  |     include $(APPDIR)/Application.mk | ||||||
|  | endif | ||||||
|  | 
 | ||||||
|  | ifeq ($(CONFIG_ADD_XIZI_FETURES),y) | ||||||
|  |     SRC_FILES := g8s.c | ||||||
|  |     include $(KERNEL_ROOT)/compiler.mk | ||||||
|  | endif | ||||||
| 
 | 
 | ||||||
| include $(KERNEL_ROOT)/compiler.mk |  | ||||||
|  |  | ||||||
|  | @ -37,6 +37,7 @@ static struct SensorProductInfo info = | ||||||
|  * @param sdev - sensor device pointer |  * @param sdev - sensor device pointer | ||||||
|  * @return success: 1 , failure: other |  * @return success: 1 , failure: other | ||||||
|  */ |  */ | ||||||
|  | #ifdef ADD_NUTTX_FETURES | ||||||
| static int SensorDeviceOpen(struct SensorDevice *sdev) | static int SensorDeviceOpen(struct SensorDevice *sdev) | ||||||
| { | { | ||||||
|     int result = 0; |     int result = 0; | ||||||
|  | @ -47,6 +48,26 @@ static int SensorDeviceOpen(struct SensorDevice *sdev) | ||||||
|         return -1; |         return -1; | ||||||
|     } |     } | ||||||
|      |      | ||||||
|  | 
 | ||||||
|  |     result = sdev->done->ioctl(sdev, SENSOR_DEVICE_PASSIVE); | ||||||
|  |     if (result != 0){ | ||||||
|  |         printf("SensorDeviceOpen:ioctl failed, status=%d\n", result); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     return result; | ||||||
|  | } | ||||||
|  | #else | ||||||
|  | static int SensorDeviceOpen(struct SensorDevice *sdev) | ||||||
|  | { | ||||||
|  |     int result = 0; | ||||||
|  | 
 | ||||||
|  |     sdev->fd = PrivOpen(SENSOR_DEVICE_G8S_DEV, O_RDWR); | ||||||
|  |     if (sdev->fd < 0) { | ||||||
|  |         printf("open %s error\n", SENSOR_DEVICE_G8S_DEV); | ||||||
|  |         return -1; | ||||||
|  |     }     | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|     struct SerialDataCfg cfg; |     struct SerialDataCfg cfg; | ||||||
|     cfg.serial_baud_rate    = BAUD_RATE_9600; |     cfg.serial_baud_rate    = BAUD_RATE_9600; | ||||||
|     cfg.serial_data_bits    = DATA_BITS_8; |     cfg.serial_data_bits    = DATA_BITS_8; | ||||||
|  | @ -67,7 +88,7 @@ static int SensorDeviceOpen(struct SensorDevice *sdev) | ||||||
| 
 | 
 | ||||||
|     return result; |     return result; | ||||||
| } | } | ||||||
| 
 | #endif | ||||||
| /**
 | /**
 | ||||||
|  * @description: Read sensor device |  * @description: Read sensor device | ||||||
|  * @param sdev - sensor device pointer |  * @param sdev - sensor device pointer | ||||||
|  |  | ||||||
|  | @ -571,6 +571,10 @@ config NSH_DISABLE_CO2ZG09 | ||||||
| 	bool "Disable the sensor zg09." | 	bool "Disable the sensor zg09." | ||||||
| 	default n | 	default n | ||||||
| 
 | 
 | ||||||
|  | config NSH_DISABLE_CO2G8S | ||||||
|  | 	bool "Disable the sensor g8-s." | ||||||
|  | 	default n | ||||||
|  | 
 | ||||||
| config NSH_DISABLE_PM1_0PS5308 | config NSH_DISABLE_PM1_0PS5308 | ||||||
| 	bool "Disable the pm1.0 function of the sensor ps5308." | 	bool "Disable the pm1.0 function of the sensor ps5308." | ||||||
| 	default n | 	default n | ||||||
|  |  | ||||||
|  | @ -1474,6 +1474,10 @@ int nsh_foreach_var(FAR struct nsh_vtbl_s *vtbl, nsh_foreach_var_t cb, | ||||||
|   int cmd_Co2Zg09(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv); |   int cmd_Co2Zg09(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv); | ||||||
| #endif | #endif | ||||||
| 
 | 
 | ||||||
|  | #if defined(CONFIG_APPLICATION_SENSOR_CO2_G8S) && !defined(CONFIG_NSH_DISABLE_CO2G8S) | ||||||
|  |   int cmd_Co2G8S(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv); | ||||||
|  | #endif | ||||||
|  | 
 | ||||||
| #if defined(CONFIG_APPLICATION_SENSOR_PM1_0_PS5308) && !defined(CONFIG_NSH_DISABLE_PM1_0PS5308) | #if defined(CONFIG_APPLICATION_SENSOR_PM1_0_PS5308) && !defined(CONFIG_NSH_DISABLE_PM1_0PS5308) | ||||||
|   int cmd_Pm10Ps5308(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv); |   int cmd_Pm10Ps5308(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv); | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
|  | @ -125,6 +125,21 @@ int cmd_Co2Zg09(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv) | ||||||
| } | } | ||||||
| #endif | #endif | ||||||
| 
 | 
 | ||||||
|  | /****************************************************************************
 | ||||||
|  |  * Name: cmd_Co2g8s | ||||||
|  |  ****************************************************************************/ | ||||||
|  | 
 | ||||||
|  | #if defined(CONFIG_APPLICATION_SENSOR_CO2_G8S) && !defined(CONFIG_NSH_DISABLE_CO2G8S) | ||||||
|  | extern void Co2G8s(void); | ||||||
|  | int cmd_Co2G8S(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv) | ||||||
|  | { | ||||||
|  |     nsh_output(vtbl, "Hello, world!\n"); | ||||||
|  |     FrameworkInit(); | ||||||
|  |     Co2G8s(); | ||||||
|  |     return OK; | ||||||
|  | } | ||||||
|  | #endif | ||||||
|  | 
 | ||||||
| /****************************************************************************
 | /****************************************************************************
 | ||||||
|  * Name: cmd_Pm10Ps5308 |  * Name: cmd_Pm10Ps5308 | ||||||
|  ****************************************************************************/ |  ****************************************************************************/ | ||||||
|  |  | ||||||
|  | @ -620,6 +620,10 @@ static const struct cmdmap_s g_cmdmap[] = | ||||||
|   { "zg09",       cmd_Co2Zg09,       1, 1, "[get the concentration of co2  with sensor ZG09.]" }, |   { "zg09",       cmd_Co2Zg09,       1, 1, "[get the concentration of co2  with sensor ZG09.]" }, | ||||||
| #endif | #endif | ||||||
| 
 | 
 | ||||||
|  | #if defined(CONFIG_APPLICATION_SENSOR_CO2_G8S) && !defined(CONFIG_NSH_DISABLE_CO2G8S) | ||||||
|  |   { "g8s",       cmd_Co2G8S,       1, 1, "[get the concentration of co2  with sensor G8S.]" }, | ||||||
|  | #endif | ||||||
|  | 
 | ||||||
| #if defined(CONFIG_APPLICATION_SENSOR_PM1_0_PS5308) && !defined(CONFIG_NSH_DISABLE_PM1_0PS5308) | #if defined(CONFIG_APPLICATION_SENSOR_PM1_0_PS5308) && !defined(CONFIG_NSH_DISABLE_PM1_0PS5308) | ||||||
|   { "pm1.0",       cmd_Pm10Ps5308,       1, 1, "[get pm1.0 with sensor Ps5308.]" }, |   { "pm1.0",       cmd_Pm10Ps5308,       1, 1, "[get pm1.0 with sensor Ps5308.]" }, | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue