add g8s sensor support Nuttx on stm32f407-discovery
This commit is contained in:
@@ -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
|
||||
* @return success: 1 , failure: other
|
||||
*/
|
||||
#ifdef ADD_NUTTX_FETURES
|
||||
static int SensorDeviceOpen(struct SensorDevice *sdev)
|
||||
{
|
||||
int result = 0;
|
||||
@@ -47,6 +48,26 @@ static int SensorDeviceOpen(struct SensorDevice *sdev)
|
||||
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;
|
||||
cfg.serial_baud_rate = BAUD_RATE_9600;
|
||||
cfg.serial_data_bits = DATA_BITS_8;
|
||||
@@ -67,7 +88,7 @@ static int SensorDeviceOpen(struct SensorDevice *sdev)
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
#endif
|
||||
/**
|
||||
* @description: Read sensor device
|
||||
* @param sdev - sensor device pointer
|
||||
|
||||
Reference in New Issue
Block a user