add hs300x and ps5308 sensor support Nuttx on stm32f407-discovery

This commit is contained in:
wgzAIIT
2021-12-28 16:45:44 +08:00
parent 7ecf1af00f
commit d59acc2e03
61 changed files with 14578 additions and 126 deletions
+34 -11
View File
@@ -8,18 +8,36 @@ config SENSOR_PS5308
string "PS5308 sensor name"
default "ps5308_1"
config SENSOR_QUANTITY_PS5308_PM1_0
string "PS5308 quantity PM1.0 name"
default "pm1_0_1"
config PS5308_PM1_0
bool "Using pm1.0 function"
default n
if PS5308_PM1_0
config SENSOR_QUANTITY_PS5308_PM1_0
string "PS5308 quantity PM1.0 name"
default "pm1_0_1"
endif
config PS5308_PM2_5
bool "Using pm2.5 function"
default n
if PS5308_PM2_5
config SENSOR_QUANTITY_PS5308_PM2_5
string "PS5308 quantity PM2.5 name"
default "pm2_5_1"
endif
config PS5308_PM10
bool "Using pm10 function"
default n
if PS5308_PM10
config SENSOR_QUANTITY_PS5308_PM10
string "PS5308 quantity PM10 name"
default "pm10_1"
endif
config SENSOR_QUANTITY_PS5308_PM2_5
string "PS5308 quantity PM2.5 name"
default "pm2_5_1"
config SENSOR_QUANTITY_PS5308_PM10
string "PS5308 quantity PM10 name"
default "pm10_1"
if ADD_XIUOS_FETURES
config SENSOR_PS5308_DRIVER_EXTUART
bool "Using extra uart to support PS5308"
@@ -42,6 +60,11 @@ config SENSOR_PS5308
endif
if ADD_NUTTX_FETURES
config SENSOR_DEVICE_PS5308_DEV
string "PS5308 device name"
default "/dev/ttyS1"
---help---
If USART1 is selected, then fill in /dev/ttyS1 here.
endif
@@ -0,0 +1,4 @@
############################################################################
# APP_Framework/Framework/sensor/pm/Make.defs
############################################################################
include $(wildcard $(APPDIR)/../../../APP_Framework/Framework/sensor/pm/*/Make.defs)
@@ -0,0 +1,6 @@
############################################################################
# APP_Framework/Framework/sensor/pm/ps5308//Make.defs
############################################################################
ifneq ($(CONFIG_SENSOR_PS5308),)
CONFIGURED_APPS += $(APPDIR)/../../../APP_Framework/Framework/sensor/pm/ps5308
endif
@@ -1,3 +1,11 @@
SRC_FILES := ps5308.c
include $(KERNEL_ROOT)/.config
ifeq ($(CONFIG_ADD_NUTTX_FETURES),y)
include $(APPDIR)/Make.defs
CSRCS += ps5308.c
include $(APPDIR)/Application.mk
endif
include $(KERNEL_ROOT)/compiler.mk
ifeq ($(CONFIG_ADD_XIUOS_FETURES),y)
SRC_FILES := ps5308.c
include $(KERNEL_ROOT)/compiler.mk
endif
@@ -51,6 +51,32 @@ static void *ReadTask(void *parameter)
* @param sdev - sensor device pointer
* @return success: 1 , failure: other
*/
#ifdef ADD_NUTTX_FETURES
static int SensorDeviceOpen(struct SensorDevice *sdev)
{
int result = 0;
result = PrivMutexCreate(&buff_lock, 0);
if (result != 0){
printf("SensorDeviceOpen:mutex create failed, status=%d\n", result);
}
sdev->fd = open(SENSOR_DEVICE_PS5308_DEV, O_RDWR);
if (sdev->fd < 0) {
printf("SensorDeviceOpen:open %s error\n", SENSOR_DEVICE_PS5308_DEV);
return -1;
}
result = PrivTaskCreate(&active_task_id, NULL, &ReadTask, sdev);
if (result != 0){
printf("SensorDeviceOpen:task create failed, status=%d\n", result);
}
PrivTaskStartup(&active_task_id);
return result;
}
#else
static int SensorDeviceOpen(struct SensorDevice *sdev)
{
int result = 0;
@@ -76,13 +102,14 @@ static int SensorDeviceOpen(struct SensorDevice *sdev)
cfg.port_configure = PORT_CFG_INIT;
#endif
result = ioctl(sdev->fd, OPE_INT, &cfg);
//result = PrivIoctl(sdev->fd, OPE_INT, &cfg);
PrivTaskCreate(&active_task_id, NULL, &ReadTask, sdev);
PrivTaskStartup(&active_task_id);
return result;
}
#endif
/**
* @description: Close PS5308 sensor device