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
@@ -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