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

View File

@ -0,0 +1,7 @@
############################################################################
# APP_Framework/Applications/Make.defs
############################################################################
CONFIGURED_APPS += $(APPDIR)/../../../APP_Framework/Applications
CONFIGURED_APPS += $(APPDIR)/../../../APP_Framework/Applications/general_functions/list
include $(wildcard $(APPDIR)/../../../APP_Framework/Applications/*/Make.defs)

View File

@ -1,25 +1,36 @@
SRC_DIR := general_functions app_test
include $(KERNEL_ROOT)/.config
SRC_FILES := main.c framework_init.c
ifeq ($(CONFIG_ADD_NUTTX_FETURES),y)
include $(APPDIR)/Make.defs
CSRCS += framework_init.c
include $(APPDIR)/Application.mk
ifeq ($(CONFIG_APPLICATION_OTA),y)
SRC_DIR += ota
endif
ifeq ($(CONFIG_APPLICATION_SENSOR),y)
SRC_DIR += sensor_app
endif
ifeq ($(CONFIG_ADD_XIUOS_FETURES),y)
SRC_DIR := general_functions app_test
ifeq ($(CONFIG_APPLICATION_CONNECTION),y)
SRC_DIR += connection_app
endif
SRC_FILES := main.c framework_init.c
ifeq ($(CONFIG_APPLICATION_KNOWING),y)
SRC_DIR += knowing_app
endif
ifeq ($(CONFIG_APPLICATION_OTA),y)
SRC_DIR += ota
endif
ifeq ($(CONFIG_APPLICATION_CONTROL),y)
SRC_DIR += control_app
endif
ifeq ($(CONFIG_APPLICATION_SENSOR),y)
SRC_DIR += sensor_app
endif
include $(KERNEL_ROOT)/compiler.mk
ifeq ($(CONFIG_APPLICATION_CONNECTION),y)
SRC_DIR += connection_app
endif
ifeq ($(CONFIG_APPLICATION_KNOWING),y)
SRC_DIR += knowing_app
endif
ifeq ($(CONFIG_APPLICATION_CONTROL),y)
SRC_DIR += control_app
endif
include $(KERNEL_ROOT)/compiler.mk
endif

View File

@ -28,6 +28,8 @@ extern int D124VoiceInit(void);
extern int Hs300xTemperatureInit(void);
extern int Hs300xHumidityInit(void);
extern int Ps5308Pm1_0Init(void);
extern int Ps5308Pm2_5Init(void);
extern int Ps5308Pm10Init(void);
extern int Zg09Co2Init(void);
extern int As830Ch4Init(void);
extern int Tb600bIaq10IaqInit(void);
@ -87,6 +89,12 @@ static struct InitDesc sensor_desc[] =
#ifdef SENSOR_QUANTITY_PS5308_PM1_0
{ "ps5308_pm1_0", Ps5308Pm1_0Init },
#endif
#ifdef SENSOR_QUANTITY_PS5308_PM2_5
{ "ps5308_pm2_5", Ps5308Pm2_5Init },
#endif
#ifdef SENSOR_QUANTITY_PS5308_PM10
{ "ps5308_pm10", Ps5308Pm10Init },
#endif
#endif
#ifdef SENSOR_ZG09
@ -190,7 +198,7 @@ static int ConnectionDeviceFrameworkInit(struct InitDesc sub_desc[])
* This function will init system framework
*
*/
int FrameworkInit()
int FrameworkInit(void)
{
#ifdef SUPPORT_SENSOR_FRAMEWORK
SensorDeviceFrameworkInit(framework);

View File

@ -1,3 +1,11 @@
SRC_FILES := double_list.c single_list.c
include $(KERNEL_ROOT)/.config
ifeq ($(CONFIG_ADD_NUTTX_FETURES),y)
include $(APPDIR)/Make.defs
CSRCS += double_list.c single_list.c
include $(APPDIR)/Application.mk
endif
include $(KERNEL_ROOT)/compiler.mk
ifeq ($(CONFIG_ADD_XIUOS_FETURES),y)
SRC_FILES := double_list.c single_list.c
include $(KERNEL_ROOT)/compiler.mk
endif

View File

@ -22,7 +22,9 @@
#ifndef __LIST_H__
#define __LIST_H__
#include "libc.h"
#include <errno.h>
#include <stdarg.h>
#include <fcntl.h>
#include<stddef.h>
#ifdef __cplusplus
extern "C" {

View File

@ -65,6 +65,26 @@ menu "sensor app"
default n
endif
menuconfig APPLICATION_SENSOR_PM2_5
bool "Using sensor PM2.5 apps"
default n
if APPLICATION_SENSOR_PM2_5
config APPLICATION_SENSOR_PM2_5_PS5308
bool "Using sensor PS5308 apps"
default n
endif
menuconfig APPLICATION_SENSOR_PM10
bool "Using sensor PM10 apps"
default n
if APPLICATION_SENSOR_PM10
config APPLICATION_SENSOR_PM10_PS5308
bool "Using sensor PS5308 apps"
default n
endif
menuconfig APPLICATION_SENSOR_VOICE
bool "Using sensor voice apps"
default n
@ -75,16 +95,6 @@ menu "sensor app"
default n
endif
menuconfig APPLICATION_SENSOR_HUMIDITY
bool "Using sensor humidity apps"
default n
if APPLICATION_SENSOR_HUMIDITY
config APPLICATION_SENSOR_HUMIDITY_HS300X
bool "Using sensor HS300x apps"
default n
endif
menuconfig APPLICATION_SENSOR_TEMPERATURE
bool "Using sensor temperature apps"
default n
@ -93,7 +103,26 @@ menu "sensor app"
config APPLICATION_SENSOR_TEMPERATURE_HS300X
bool "Using sensor HS300x apps"
default n
if ADD_NUTTX_FETURES
endif
endif
menuconfig APPLICATION_SENSOR_HUMIDITY
bool "Using sensor humidity apps"
default n
if APPLICATION_SENSOR_HUMIDITY
config APPLICATION_SENSOR_HUMIDITY_HS300X
bool "Using sensor HS300x apps"
default n
if ADD_NUTTX_FETURES
endif
endif
endif
endmenu

View File

@ -0,0 +1,6 @@
############################################################################
# APP_Framework/Applications/sensor_app/Make.defs
############################################################################
ifneq ($(CONFIG_APPLICATION_SENSOR),)
CONFIGURED_APPS += $(APPDIR)/../../../APP_Framework/Applications/sensor_app
endif

View File

@ -1,39 +1,103 @@
SRC_FILES :=
include $(KERNEL_ROOT)/.config
ifeq ($(CONFIG_ADD_NUTTX_FETURES),y)
include $(APPDIR)/Make.defs
ifeq ($(CONFIG_APPLICATION_SENSOR_HCHO_TB600B_WQ_HCHO1OS), y)
CSRCS += hcho_tb600b_wq_hcho1os.c
endif
ifeq ($(CONFIG_APPLICATION_SENSOR_TVOC_TB600B_TVOC10), y)
CSRCS += tvoc_tb600b_tvoc10.c
endif
ifeq ($(CONFIG_APPLICATION_SENSOR_IAQ_TB600B_IAQ10), y)
CSRCS += iaq_tb600b_iaq10.c
endif
ifeq ($(CONFIG_APPLICATION_SENSOR_CH4_AS830), y)
CSRCS += ch4_as830.c
endif
ifeq ($(CONFIG_APPLICATION_SENSOR_CO2_ZG09), y)
CSRCS += co2_zg09.c
endif
ifeq ($(CONFIG_APPLICATION_SENSOR_PM1_0_PS5308), y)
CSRCS += pm1_0_ps5308.c
endif
ifeq ($(CONFIG_APPLICATION_SENSOR_PM2_5_PS5308), y)
CSRCS += pm2_5_ps5308.c
endif
ifeq ($(CONFIG_APPLICATION_SENSOR_PM10_PS5308), y)
CSRCS += pm10_0_ps5308.c
endif
ifeq ($(CONFIG_APPLICATION_SENSOR_VOICE_D124), y)
CSRCS += voice_d124.c
endif
ifeq ($(CONFIG_APPLICATION_SENSOR_HUMIDITY_HS300X), y)
CSRCS += humidity_hs300x.c
endif
ifeq ($(CONFIG_APPLICATION_SENSOR_TEMPERATURE_HS300X), y)
CSRCS += temperature_hs300x.c
endif
include $(APPDIR)/Application.mk
ifeq ($(CONFIG_APPLICATION_SENSOR_HCHO_TB600B_WQ_HCHO1OS), y)
SRC_FILES += hcho_tb600b_wq_hcho1os.c
endif
ifeq ($(CONFIG_APPLICATION_SENSOR_TVOC_TB600B_TVOC10), y)
SRC_FILES += tvoc_tb600b_tvoc10.c
endif
ifeq ($(CONFIG_ADD_XIUOS_FETURES),y)
SRC_FILES :=
ifeq ($(CONFIG_APPLICATION_SENSOR_IAQ_TB600B_IAQ10), y)
SRC_FILES += iaq_tb600b_iaq10.c
endif
ifeq ($(CONFIG_APPLICATION_SENSOR_HCHO_TB600B_WQ_HCHO1OS), y)
SRC_FILES += hcho_tb600b_wq_hcho1os.c
endif
ifeq ($(CONFIG_APPLICATION_SENSOR_CH4_AS830), y)
SRC_FILES += ch4_as830.c
endif
ifeq ($(CONFIG_APPLICATION_SENSOR_TVOC_TB600B_TVOC10), y)
SRC_FILES += tvoc_tb600b_tvoc10.c
endif
ifeq ($(CONFIG_APPLICATION_SENSOR_CO2_ZG09), y)
SRC_FILES += co2_zg09.c
endif
ifeq ($(CONFIG_APPLICATION_SENSOR_IAQ_TB600B_IAQ10), y)
SRC_FILES += iaq_tb600b_iaq10.c
endif
ifeq ($(CONFIG_APPLICATION_SENSOR_PM1_0_PS5308), y)
SRC_FILES += pm1_0_ps5308.c
endif
ifeq ($(CONFIG_APPLICATION_SENSOR_CH4_AS830), y)
SRC_FILES += ch4_as830.c
endif
ifeq ($(CONFIG_APPLICATION_SENSOR_VOICE_D124), y)
SRC_FILES += voice_d124.c
endif
ifeq ($(CONFIG_APPLICATION_SENSOR_CO2_ZG09), y)
SRC_FILES += co2_zg09.c
endif
ifeq ($(CONFIG_APPLICATION_SENSOR_HUMIDITY_HS300X), y)
SRC_FILES += humidity_hs300x.c
endif
ifeq ($(CONFIG_APPLICATION_SENSOR_PM1_0_PS5308), y)
SRC_FILES += pm1_0_ps5308.c
endif
ifeq ($(CONFIG_APPLICATION_SENSOR_TEMPERATURE_HS300X), y)
SRC_FILES += temperature_hs300x.c
endif
ifeq ($(CONFIG_APPLICATION_SENSOR_PM2_5_PS5308), y)
SRC_FILES += pm2_5_ps5308.c
endif
include $(KERNEL_ROOT)/compiler.mk
ifeq ($(CONFIG_APPLICATION_SENSOR_PM10_PS5308), y)
SRC_FILES += pm10_0_ps5308.c
endif
ifeq ($(CONFIG_APPLICATION_SENSOR_VOICE_D124), y)
SRC_FILES += voice_d124.c
endif
ifeq ($(CONFIG_APPLICATION_SENSOR_HUMIDITY_HS300X), y)
SRC_FILES += humidity_hs300x.c
endif
ifeq ($(CONFIG_APPLICATION_SENSOR_TEMPERATURE_HS300X), y)
SRC_FILES += temperature_hs300x.c
endif
include $(KERNEL_ROOT)/compiler.mk
endif

View File

@ -18,7 +18,10 @@
* @date 2021.04.23
*/
#include <user_api.h>
#ifdef ADD_XIUOS_FETURES
# include <user_api.h>
#endif
#include <sensor.h>
/**

View File

@ -0,0 +1,38 @@
/*
* Copyright (c) 2020 AIIT XUOS Lab
* XiOS is licensed under Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
* http://license.coscl.org.cn/MulanPSL2
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PSL v2 for more details.
*/
/**
* @file pm1_0_ps5308.c
* @brief PS5308 PM1.0 example
* @version 1.0
* @author AIIT XUOS Lab
* @date 2021.04.23
*/
#ifdef ADD_XIUOS_FETURES
# include <user_api.h>
#endif
#include <sensor.h>
/**
* @description: Read a PM10
* @return 0
*/
void Pm100Ps5308(void)
{
struct SensorQuantity *pm10_0 = SensorQuantityFind(SENSOR_QUANTITY_PS5308_PM10, SENSOR_QUANTITY_PM);
SensorQuantityOpen(pm10_0);
PrivTaskDelay(2000);
printf("PM10 : %d ug/m³\n", SensorQuantityRead(pm10_0));
SensorQuantityClose(pm10_0);
}

View File

@ -18,7 +18,10 @@
* @date 2021.04.23
*/
#include <user_api.h>
#ifdef ADD_XIUOS_FETURES
# include <user_api.h>
#endif
#include <sensor.h>
/**

View File

@ -0,0 +1,38 @@
/*
* Copyright (c) 2020 AIIT XUOS Lab
* XiOS is licensed under Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
* http://license.coscl.org.cn/MulanPSL2
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PSL v2 for more details.
*/
/**
* @file pm1_0_ps5308.c
* @brief PS5308 PM1.0 example
* @version 1.0
* @author AIIT XUOS Lab
* @date 2021.04.23
*/
#ifdef ADD_XIUOS_FETURES
# include <user_api.h>
#endif
#include <sensor.h>
/**
* @description: Read a PM2.5
* @return 0
*/
void Pm25Ps5308(void)
{
struct SensorQuantity *pm2_5 = SensorQuantityFind(SENSOR_QUANTITY_PS5308_PM2_5, SENSOR_QUANTITY_PM);
SensorQuantityOpen(pm2_5);
PrivTaskDelay(2000);
printf("PM2.5 : %d ug/m³\n", SensorQuantityRead(pm2_5));
SensorQuantityClose(pm2_5);
}

View File

@ -18,7 +18,10 @@
* @date 2021.04.23
*/
#include <user_api.h>
#ifdef ADD_XIUOS_FETURES
# include <user_api.h>
#endif
#include <sensor.h>
/**
@ -43,4 +46,3 @@ void TempHs300x(void)
SensorQuantityClose(temp);
}
SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_CMD_FUNC)|SHELL_CMD_PARAM_NUM(0)|SHELL_CMD_DISABLE_RETURN, TempHs300x, TempHs300x, TempHs300x function);

View File

@ -0,0 +1,5 @@
############################################################################
# APP_Framework/Framework/Make.defs
############################################################################
CONFIGURED_APPS += $(APPDIR)/../../../APP_Framework/Framework/transform_layer/nuttx
include $(wildcard $(APPDIR)/../../../APP_Framework/Framework/*/Make.defs)

View File

@ -0,0 +1,7 @@
############################################################################
# APP_Framework/Framework/sensor/Make.defs
############################################################################
ifneq ($(CONFIG_SUPPORT_SENSOR_FRAMEWORK),)
CONFIGURED_APPS += $(APPDIR)/../../../APP_Framework/Framework/sensor
endif
include $(wildcard $(APPDIR)/../../../APP_Framework/Framework/sensor/*/Make.defs)

View File

@ -1,39 +1,49 @@
SRC_FILES := sensor.c
include $(KERNEL_ROOT)/.config
ifeq ($(CONFIG_ADD_NUTTX_FETURES),y)
include $(APPDIR)/Make.defs
CSRCS += sensor.c
include $(APPDIR)/Application.mk
ifeq ($(CONFIG_SENSOR_HCHO),y)
SRC_DIR += hcho
endif
ifeq ($(CONFIG_SENSOR_TVOC),y)
SRC_DIR += tvoc
endif
ifeq ($(CONFIG_ADD_XIUOS_FETURES),y)
SRC_FILES := sensor.c
ifeq ($(CONFIG_SENSOR_IAQ),y)
SRC_DIR += iaq
endif
ifeq ($(CONFIG_SENSOR_HCHO),y)
SRC_DIR += hcho
endif
ifeq ($(CONFIG_SENSOR_CH4),y)
SRC_DIR += ch4
endif
ifeq ($(CONFIG_SENSOR_TVOC),y)
SRC_DIR += tvoc
endif
ifeq ($(CONFIG_SENSOR_CO2),y)
SRC_DIR += co2
endif
ifeq ($(CONFIG_SENSOR_IAQ),y)
SRC_DIR += iaq
endif
ifeq ($(CONFIG_SENSOR_PM),y)
SRC_DIR += pm
endif
ifeq ($(CONFIG_SENSOR_CH4),y)
SRC_DIR += ch4
endif
ifeq ($(CONFIG_SENSOR_VOICE),y)
SRC_DIR += voice
endif
ifeq ($(CONFIG_SENSOR_CO2),y)
SRC_DIR += co2
endif
ifeq ($(CONFIG_SENSOR_TEMPERATURE),y)
SRC_DIR += temperature
endif
ifeq ($(CONFIG_SENSOR_PM),y)
SRC_DIR += pm
endif
ifeq ($(CONFIG_SENSOR_HUMIDITY),y)
SRC_DIR += humidity
endif
ifeq ($(CONFIG_SENSOR_VOICE),y)
SRC_DIR += voice
endif
include $(KERNEL_ROOT)/compiler.mk
ifeq ($(CONFIG_SENSOR_TEMPERATURE),y)
SRC_DIR += temperature
endif
ifeq ($(CONFIG_SENSOR_HUMIDITY),y)
SRC_DIR += humidity
endif
include $(KERNEL_ROOT)/compiler.mk
endif

View File

@ -1,9 +1,9 @@
config SENSOR_HS300X
bool "Using HS300x"
config SENSOR_HS300X_HUMIDITY
bool "Using HS300x for humidity"
default n
if SENSOR_HS300X
if SENSOR_HS300X_HUMIDITY
config SENSOR_DEVICE_HS300X
string "HS300x sensor name"
default "hs300x_1"
@ -22,7 +22,15 @@ config SENSOR_HS300X
default 0x44
endif
if ADD_NUTTX_FETURES
config SENSOR_DEVICE_HS300X_DEV
string "HS300x device name"
default "/dev/i2c1"
config SENSOR_DEVICE_HS300X_I2C_ADDR
hex "HS300x device i2c address"
default 0x44
endif

View File

@ -0,0 +1,4 @@
############################################################################
# APP_Framework/Framework/sensor/humidity/Make.defs
############################################################################
include $(wildcard $(APPDIR)/../../../APP_Framework/Framework/sensor/humidity/*/Make.defs)

View File

@ -1,4 +1,4 @@
ifeq ($(CONFIG_SENSOR_HS300X),y)
ifeq ($(CONFIG_SENSOR_HS300X_HUMIDITY),y)
SRC_DIR += hs300x_humi
endif

View File

@ -0,0 +1,6 @@
############################################################################
# APP_Framework/Framework/sensor/humidity/hs300x_humi/Make.defs
############################################################################
ifneq ($(CONFIG_SENSOR_HS300X_HUMIDITY),)
CONFIGURED_APPS += $(APPDIR)/../../../APP_Framework/Framework/sensor/humidity/hs300x_humi
endif

View File

@ -1,3 +1,13 @@
SRC_FILES := hs300x_humi.c
include $(KERNEL_ROOT)/.config
ifeq ($(CONFIG_ADD_NUTTX_FETURES),y)
include $(APPDIR)/Make.defs
CSRCS += hs300x_humi.c
include $(APPDIR)/Application.mk
include $(KERNEL_ROOT)/compiler.mk
endif
ifeq ($(CONFIG_ADD_XIUOS_FETURES),y)
SRC_FILES := hs300x_humi.c
include $(KERNEL_ROOT)/compiler.mk
endif

View File

@ -36,6 +36,12 @@ static struct SensorProductInfo info =
*/
static int SensorDeviceOpen(struct SensorDevice *sdev)
{
#ifdef ADD_NUTTX_FETURES
sdev->fd = PrivOpen(SENSOR_DEVICE_HS300X_DEV, O_RDWR);
return sdev->fd;
#else
int result;
uint16_t i2c_dev_addr = SENSOR_DEVICE_HS300X_I2C_ADDR;
@ -52,6 +58,7 @@ static int SensorDeviceOpen(struct SensorDevice *sdev)
result = PrivIoctl(sdev->fd, OPE_INT, &ioctl_cfg);
return result;
#endif
}
/**
@ -62,6 +69,16 @@ static int SensorDeviceOpen(struct SensorDevice *sdev)
*/
static int SensorDeviceRead(struct SensorDevice *sdev, size_t len)
{
#ifdef ADD_NUTTX_FETURES
int ret;
ret = PrivRead(sdev->fd, sdev->buffer, len);
if (ret != len ){
perror("Failed to read data!\n");
return -1;
}
return 0;
#else
//send i2c device start signal and address, need to implemente in OS i2c driver
if (PrivWrite(sdev->fd, NULL, 0) != 1)
return -1;
@ -73,6 +90,7 @@ static int SensorDeviceRead(struct SensorDevice *sdev, size_t len)
return -1;
return 0;
#endif
}
static struct SensorDone done =

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

View File

@ -0,0 +1,4 @@
############################################################################
# APP_Framework/Framework/sensor/pm/Make.defs
############################################################################
include $(wildcard $(APPDIR)/../../../APP_Framework/Framework/sensor/pm/*/Make.defs)

View File

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

View File

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

View File

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

View File

@ -151,12 +151,9 @@ static int SensorDeviceOpen(struct SensorDevice *sdev)
if (sdev->done->open != NULL)
result = sdev->done->open(sdev);
if (result == 0) {
if (result >= 0) {
printf("Device %s open success.\n", sdev->name);
}else{
if (sdev->fd)
PrivClose(sdev->fd);
printf("Device %s open failed(%d).\n", sdev->name, result);
memset(sdev, 0, sizeof(struct SensorDevice));
}
@ -173,13 +170,13 @@ static int SensorDeviceClose(struct SensorDevice *sdev)
{
int result = 0;
if (sdev->fd)
if (sdev->fd >= 0)
PrivClose(sdev->fd);
if (sdev->done->close != NULL)
result = sdev->done->close(sdev);
if (result == 0)
if (result >= 0)
printf("%s successfully closed.\n", sdev->name);
else
printf("Closed %s failure.\n", sdev->name);
@ -276,7 +273,7 @@ int SensorQuantityOpen(struct SensorQuantity *quant)
if (sdev->ref_cnt == 0) {
ret = SensorDeviceOpen(sdev);
if (ret != 0) {
if (ret < 0) {
printf("%s: open sensor device failed\n", __func__);
return ret;
}

View File

@ -1,9 +1,9 @@
config SENSOR_HS300X
bool "Using HS300x"
config SENSOR_HS300X_TEMPERATURE
bool "Using HS300x for temperature"
default n
if SENSOR_HS300X
if SENSOR_HS300X_TEMPERATURE
config SENSOR_DEVICE_HS300X
string "HS300x sensor name"
default "hs300x_1"
@ -23,6 +23,13 @@ config SENSOR_HS300X
endif
if ADD_NUTTX_FETURES
config SENSOR_DEVICE_HS300X_DEV
string "HS300x device name"
default "/dev/i2c1"
config SENSOR_DEVICE_HS300X_I2C_ADDR
hex "HS300x device i2c address"
default 0x44
endif

View File

@ -0,0 +1,4 @@
############################################################################
# APP_Framework/Framework/sensor/temperature//Make.defs
############################################################################
include $(wildcard $(APPDIR)/../../../APP_Framework/Framework/sensor/temperature/*/Make.defs)

View File

@ -1,4 +1,4 @@
ifeq ($(CONFIG_SENSOR_HS300X),y)
ifeq ($(CONFIG_SENSOR_HS300X_TEMPERATURE),y)
SRC_DIR += hs300x_temp
endif

View File

@ -0,0 +1,6 @@
############################################################################
# APP_Framework/Framework/sensor/temperature/hs300x_temp//Make.defs
############################################################################
ifneq ($(CONFIG_SENSOR_HS300X_TEMPERATURE),)
CONFIGURED_APPS += $(APPDIR)/../../../APP_Framework/Framework/sensor/temperature/hs300x_temp
endif

View File

@ -1,3 +1,12 @@
SRC_FILES := hs300x_temp.c
include $(KERNEL_ROOT)/.config
ifeq ($(CONFIG_ADD_NUTTX_FETURES),y)
include $(APPDIR)/Make.defs
CSRCS += hs300x_temp.c
include $(APPDIR)/Application.mk
include $(KERNEL_ROOT)/compiler.mk
endif
ifeq ($(CONFIG_ADD_XIUOS_FETURES),y)
SRC_FILES := hs300x_temp.c
include $(KERNEL_ROOT)/compiler.mk
endif

View File

@ -36,6 +36,12 @@ static struct SensorProductInfo info =
*/
static int SensorDeviceOpen(struct SensorDevice *sdev)
{
#ifdef ADD_NUTTX_FETURES
sdev->fd = PrivOpen(SENSOR_DEVICE_HS300X_DEV, O_RDWR);
return sdev->fd;
#else
int result;
uint16_t i2c_dev_addr = SENSOR_DEVICE_HS300X_I2C_ADDR;
@ -51,6 +57,7 @@ static int SensorDeviceOpen(struct SensorDevice *sdev)
result = PrivIoctl(sdev->fd, OPE_INT, &ioctl_cfg);
return result;
#endif
}
/**
@ -61,6 +68,16 @@ static int SensorDeviceOpen(struct SensorDevice *sdev)
*/
static int SensorDeviceRead(struct SensorDevice *sdev, size_t len)
{
#ifdef ADD_NUTTX_FETURES
int ret;
ret = PrivRead(sdev->fd, sdev->buffer, len);
if (ret != len ){
perror("Failed to read data!\n");
return -1;
}
return 0;
#else
//send i2c device start signal and address, need to implemente in OS i2c driver
if (PrivWrite(sdev->fd, NULL, 0) != 1)
return -1;
@ -72,6 +89,7 @@ static int SensorDeviceRead(struct SensorDevice *sdev, size_t len)
return -1;
return 0;
#endif
}
static struct SensorDone done =

View File

@ -0,0 +1,5 @@
include $(KERNEL_ROOT)/.config
include $(APPDIR)/Make.defs
CSRCS = transform.c
include $(APPDIR)/Application.mk

View File

@ -0,0 +1,177 @@
/*
* Copyright (c) 2020 AIIT XUOS Lab
* XiUOS is licensed under Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
* http://license.coscl.org.cn/MulanPSL2
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PSL v2 for more details.
*/
/**
* @file xiuos.c
* @brief Converts the framework interface to an operating system interface
* @version 1.0
* @author AIIT XUOS Lab
* @date 2021.06.07
*/
#include "transform.h"
/**************************mutex***************************/
/* private mutex API */
int PrivMutexCreate(pthread_mutex_t *p_mutex, const pthread_mutexattr_t *attr)
{
return pthread_mutex_init(p_mutex, attr);
}
int PrivMutexDelete(pthread_mutex_t *p_mutex)
{
return pthread_mutex_destroy(p_mutex);
}
int PrivMutexObtain(pthread_mutex_t *p_mutex)
{
return pthread_mutex_lock(p_mutex);
}
int PrivMutexAbandon(pthread_mutex_t *p_mutex)
{
return pthread_mutex_unlock(p_mutex);
}
/**********************semaphore****************************/
int PrivSemaphoreCreate(sem_t *sem, int pshared, unsigned int value)
{
return sem_init(sem, pshared, value);
}
int PrivSemaphoreDelete(sem_t *sem)
{
return sem_destroy(sem);
}
int PrivSemaphoreObtainWait(sem_t *sem, const struct timespec *abstime)
{
return sem_timedwait(sem, abstime);
}
int PrivSemaphoreObtainNoWait(sem_t *sem)
{
return sem_trywait(sem);
}
int PrivSemaphoreAbandon(sem_t *sem)
{
return sem_post(sem);
}
/**************************task*************************/
int PrivTaskCreate(pthread_t *thread, const pthread_attr_t *attr,
void *(*start_routine)(void *), void *arg)
{
return pthread_create(thread, attr, start_routine, arg);
}
int PrivTaskStartup(pthread_t *thread)
{
return 0;
}
int PrivTaskDelete(pthread_t thread, int sig)
{
return pthread_kill(thread, sig);
}
void PrivTaskQuit(void *value_ptr)
{
pthread_exit(value_ptr);
}
int PrivTaskDelay(int32_t ms)
{
return usleep(ms);
}
/*********************fs**************************/
/************************Driver Posix Transform***********************/
int PrivOpen(const char *path, int flags)
{
return open(path, flags);
}
int PrivClose(int fd)
{
return close(fd);
}
int PrivRead(int fd, void *buf, size_t len)
{
return read(fd, buf, len);
}
int PrivWrite(int fd, const void *buf, size_t len)
{
return write(fd, buf, len);
}
static int PrivSerialIoctl(int fd, int cmd, void *args)
{
struct SerialDataCfg *serial_cfg = (struct SerialDataCfg *)args;
return ioctl(fd, cmd, serial_cfg);
}
static int PrivPinIoctl(int fd, int cmd, void *args)
{
struct PinParam *pin_cfg = (struct PinParam *)args;
return ioctl(fd, cmd, pin_cfg);
}
int PrivIoctl(int fd, int cmd, void *args)
{
int ret = 0;
struct PrivIoctlCfg *ioctl_cfg = (struct PrivIoctlCfg *)args;
switch (ioctl_cfg->ioctl_driver_type)
{
case SERIAL_TYPE:
ret = PrivSerialIoctl(fd, cmd, ioctl_cfg->args);
break;
case PIN_TYPE:
ret = PrivPinIoctl(fd, cmd, ioctl_cfg->args);
break;
case I2C_TYPE:
ret = ioctl(fd, cmd, ioctl_cfg->args);
break;
default:
break;
}
return ret;
}
/********************memory api************/
void *PrivMalloc(size_t size)
{
return malloc(size);
}
void *PrivRealloc(void *pointer, size_t size)
{
return realloc(pointer, size);
}
void *PrivCalloc(size_t count, size_t size)
{
return calloc(count, size);
}
void PrivFree(void *pointer)
{
free(pointer);
}

View File

@ -0,0 +1,214 @@
/*
* Copyright (c) 2020 AIIT XUOS Lab
* XiUOS is licensed under Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
* http://license.coscl.org.cn/MulanPSL2
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PSL v2 for more details.
*/
/**
* @file transform.h
* @brief Interface function declarations required by the framework
* @version 1.0
* @author AIIT XUOS Lab
* @date 2021.06.04
*/
#ifndef TRANSFORM_H
#define TRANSFORM_H
#include <pthread.h>
#include <semaphore.h>
#include <stddef.h>
#include <stdint.h>
#include <time.h>
typedef uint8_t uint8;
typedef uint16_t uint16;
typedef uint32_t uint32;
typedef uint64_t uint64;
typedef int8_t int8;
typedef int16_t int16;
typedef int32_t int32;
typedef int64_t int64;
#ifdef __cplusplus
extern "C" {
#endif
#define OPE_INT 0x0000
#define OPE_CFG 0x0001
#define NAME_NUM_MAX 32
/*********************GPIO define*********************/
#define GPIO_LOW 0x00
#define GPIO_HIGH 0x01
#define GPIO_CFG_OUTPUT 0x00
#define GPIO_CFG_INPUT 0x01
#define GPIO_CFG_INPUT_PULLUP 0x02
#define GPIO_CFG_INPUT_PULLDOWN 0x03
#define GPIO_CFG_OUTPUT_OD 0x04
#define GPIO_CONFIG_MODE 0xffffffff
/********************SERIAL define*******************/
#define BAUD_RATE_2400 2400
#define BAUD_RATE_4800 4800
#define BAUD_RATE_9600 9600
#define BAUD_RATE_19200 19200
#define BAUD_RATE_38400 38400
#define BAUD_RATE_57600 57600
#define BAUD_RATE_115200 115200
#define BAUD_RATE_230400 230400
#define BAUD_RATE_460800 460800
#define BAUD_RATE_921600 921600
#define BAUD_RATE_2000000 2000000
#define BAUD_RATE_3000000 3000000
#define DATA_BITS_5 5
#define DATA_BITS_6 6
#define DATA_BITS_7 7
#define DATA_BITS_8 8
#define DATA_BITS_9 9
#define STOP_BITS_1 1
#define STOP_BITS_2 2
#define STOP_BITS_3 3
#define STOP_BITS_4 4
#define PARITY_NONE 1
#define PARITY_ODD 2
#define PARITY_EVEN 3
#define BIT_ORDER_LSB 1
#define BIT_ORDER_MSB 2
#define NRZ_NORMAL 1
#define NRZ_INVERTED 2
#ifndef SERIAL_RB_BUFSZ
#define SERIAL_RB_BUFSZ 128
#endif
struct PinDevIrq
{
int irq_mode;//< RISING/FALLING/HIGH/LOW
void (*hdr) (void *args);//< callback function
void *args;//< the params of callback function
};
struct PinParam
{
int cmd;//< cmd:GPIO_CONFIG_MODE/GPIO_IRQ_REGISTER/GPIO_IRQ_FREE/GPIO_IRQ_DISABLE/GPIO_IRQ_ENABLE
long pin;//< pin number
int mode;//< pin mode: input/output
struct PinDevIrq irq_set;//< pin irq set
uint64 arg;
};
struct PinStat
{
long pin;//< pin number
uint16_t val;//< pin level
};
enum ExtSerialPortConfigure
{
PORT_CFG_INIT = 0,
PORT_CFG_PARITY_CHECK,
PORT_CFG_DISABLE,
PORT_CFG_DIV,
};
struct SerialDataCfg
{
uint32_t serial_baud_rate;
uint8_t serial_data_bits;
uint8_t serial_stop_bits;
uint8_t serial_parity_mode;
uint8_t serial_bit_order;
uint8_t serial_invert_mode;
uint16_t serial_buffer_size;
uint8 ext_uart_no;
enum ExtSerialPortConfigure port_configure;
};
enum IoctlDriverType
{
SERIAL_TYPE = 0,
SPI_TYPE,
I2C_TYPE,
PIN_TYPE,
DEFAULT_TYPE,
};
struct PrivIoctlCfg
{
enum IoctlDriverType ioctl_driver_type;
void *args;
};
int open(FAR const char *path, int oflags, ...);
int ioctl(int fd, int req, ...);
FAR void *malloc(size_t size);
FAR void *realloc(FAR void *oldmem, size_t size);
FAR void *calloc(size_t n, size_t elem_size);
void free(FAR void *mem);
/**********************mutex**************************/
int PrivMutexCreate(pthread_mutex_t *p_mutex, const pthread_mutexattr_t *attr);
int PrivMutexDelete(pthread_mutex_t *p_mutex);
int PrivMutexObtain(pthread_mutex_t *p_mutex);
int PrivMutexAbandon(pthread_mutex_t *p_mutex);
/*********************semaphore**********************/
int PrivSemaphoreCreate(sem_t *sem, int pshared, unsigned int value);
int PrivSemaphoreDelete(sem_t *sem);
int PrivSemaphoreObtainWait(sem_t *sem, const struct timespec *abstime);
int PrivSemaphoreObtainNoWait(sem_t *sem);
int PrivSemaphoreAbandon(sem_t *sem);
int32_t PrivSemaphoreSetValue(int32_t sem, uint16_t val);
/*********************task**************************/
int PrivTaskCreate(pthread_t *thread, const pthread_attr_t *attr,
void *(*start_routine)(void *), void *arg);
int PrivTaskStartup(pthread_t *thread);
int PrivTaskDelete(pthread_t thread, int sig);
void PrivTaskQuit(void *value_ptr);
int PrivTaskDelay(int32_t ms);
/*********************driver*************************/
int PrivOpen(const char *path, int flags);
int PrivRead(int fd, void *buf, size_t len);
int PrivWrite(int fd, const void *buf, size_t len);
int PrivClose(int fd);
int PrivIoctl(int fd, int cmd, void *args);
/*********************memory***********************/
void *PrivMalloc(size_t size);
void *PrivRealloc(void *pointer, size_t size);
void *PrivCalloc(size_t count, size_t size);
void PrivFree(void *pointer);
#ifdef __cplusplus
}
#endif
#endif

5
APP_Framework/Make.defs Normal file
View File

@ -0,0 +1,5 @@
############################################################################
# APP_Framework/Make.defs
############################################################################
CONFIGURED_APPS += $(APPDIR)/../../../APP_Framework
include $(wildcard $(APPDIR)/../../../APP_Framework/*/Make.defs)

View File

@ -1,4 +1,11 @@
SRC_DIR := Applications Framework lib
include $(KERNEL_ROOT)/.config
ifeq ($(CONFIG_ADD_NUTTX_FETURES),y)
include $(APPDIR)/Make.defs
include $(APPDIR)/Application.mk
endif
include $(KERNEL_ROOT)/compiler.mk
ifeq ($(CONFIG_ADD_XIUOS_FETURES),y)
SRC_DIR := Applications Framework lib
include $(KERNEL_ROOT)/compiler.mk
endif

View File

@ -0,0 +1,224 @@
############################################################################
# apps/Makefile
#
# Copyright (C) 2011 Uros Platise. All rights reserved.
# Copyright (C) 2011-2014, 2018-2019 Gregory Nutt. All rights reserved.
# Authors: Uros Platise <uros.platise@isotel.eu>
# Gregory Nutt <gnutt@nuttx.org>
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in
# the documentation and/or other materials provided with the
# distribution.
# 3. Neither the name NuttX nor the names of its contributors may be
# used to endorse or promote products derived from this software
# without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
############################################################################
export APPDIR = $(CURDIR)
include $(APPDIR)/Make.defs
include $(APPDIR)/../../../APP_Framework/Make.defs
# Symbol table for loadable apps.
SYMTABSRC = symtab_apps.c
SYMTABOBJ = $(SYMTABSRC:.c=$(OBJEXT))
# Build targets
# We first remove libapps.a before letting the other rules add objects to it
# so that we ensure libapps.a does not contain objects from prior build
all:
$(RM) $(BIN)
$(MAKE) $(BIN)
.PHONY: import install dirlinks export .depdirs preconfig depend clean distclean
.PHONY: context clean_context context_all register register_all
.PRECIOUS: $(BIN)
$(foreach SDIR, $(CONFIGURED_APPS), $(eval $(call SDIR_template,$(SDIR),all)))
$(foreach SDIR, $(CONFIGURED_APPS), $(eval $(call SDIR_template,$(SDIR),install)))
$(foreach SDIR, $(CONFIGURED_APPS), $(eval $(call SDIR_template,$(SDIR),context)))
$(foreach SDIR, $(CONFIGURED_APPS), $(eval $(call SDIR_template,$(SDIR),register)))
$(foreach SDIR, $(CONFIGURED_APPS), $(eval $(call SDIR_template,$(SDIR),depend)))
$(foreach SDIR, $(CLEANDIRS), $(eval $(call SDIR_template,$(SDIR),clean)))
$(foreach SDIR, $(CLEANDIRS), $(eval $(call SDIR_template,$(SDIR),distclean)))
$(MKDEP): $(TOPDIR)/tools/mkdeps.c
$(HOSTCC) $(HOSTINCLUDES) $(HOSTCFLAGS) $< -o $@
$(INCDIR): $(TOPDIR)/tools/incdir.c
$(HOSTCC) $(HOSTINCLUDES) $(HOSTCFLAGS) $< -o $@
IMPORT_TOOLS = $(MKDEP) $(INCDIR)
# In the KERNEL build, we must build and install all of the modules. No
# symbol table is needed
ifeq ($(CONFIG_BUILD_KERNEL),y)
install: $(foreach SDIR, $(CONFIGURED_APPS), $(SDIR)_install)
.import: $(foreach SDIR, $(CONFIGURED_APPS), $(SDIR)_all)
$(Q) $(MAKE) install
import: $(IMPORT_TOOLS)
$(Q) $(MAKE) context TOPDIR="$(APPDIR)$(DELIM)import"
$(Q) $(MAKE) register TOPDIR="$(APPDIR)$(DELIM)import"
$(Q) $(MAKE) depend TOPDIR="$(APPDIR)$(DELIM)import"
$(Q) $(MAKE) .import TOPDIR="$(APPDIR)$(DELIM)import"
else
# In FLAT and protected modes, the modules have already been created. A
# symbol table is required.
ifeq ($(CONFIG_BUILD_LOADABLE),)
$(BIN): $(foreach SDIR, $(CONFIGURED_APPS), $(SDIR)_all)
$(Q) for app in ${CONFIGURED_APPS}; do \
$(MAKE) -C "$${app}" archive ; \
done
else
$(SYMTABSRC): $(foreach SDIR, $(CONFIGURED_APPS), $(SDIR)_all)
$(Q) for app in ${CONFIGURED_APPS}; do \
$(MAKE) -C "$${app}" archive ; \
done
$(Q) $(MAKE) install
$(Q) $(APPDIR)$(DELIM)tools$(DELIM)mksymtab.sh $(BINDIR) >$@.tmp
$(Q) $(call TESTANDREPLACEFILE, $@.tmp, $@)
$(SYMTABOBJ): %$(OBJEXT): %.c
$(call COMPILE, -fno-lto $<, $@)
$(BIN): $(SYMTABOBJ)
ifeq ($(CONFIG_CYGWIN_WINTOOL),y)
$(call ARCHIVE_ADD, "${shell cygpath -w $(BIN)}", $^)
else
$(call ARCHIVE_ADD, $(BIN), $^)
endif
endif # !CONFIG_BUILD_LOADABLE
install: $(foreach SDIR, $(CONFIGURED_APPS), $(SDIR)_install)
# Link nuttx
HEAD_OBJ += $(wildcard $(APPDIR)$(DELIM)import$(DELIM)startup$(DELIM)*$(OBJEXT))
HEAD_OBJ += $(wildcard $(APPDIR)$(DELIM)builtin$(DELIM)*$(OBJEXT))
.import: $(BIN) install
$(Q) echo "LD: nuttx"
$(Q) $(LD) --entry=__start $(LDFLAGS) $(LDLIBPATH) $(EXTRA_LIBPATHS) \
-L$(APPDIR)$(DELIM)import$(DELIM)scripts -T$(LDNAME) \
-o nuttx$(EXEEXT) $(HEAD_OBJ) $(EXTRA_OBJS) $(LDSTARTGROUP) \
$(BIN) $(LDLIBS) $(EXTRA_LIBS) $(LDENDGROUP)
ifeq ($(CONFIG_INTELHEX_BINARY),y)
$(Q) echo "CP: nuttx.hex"
$(Q) $(OBJCOPY) $(OBJCOPYARGS) -O ihex nuttx$(EXEEXT) nuttx.hex
endif
ifeq ($(CONFIG_RAW_BINARY),y)
$(Q) echo "CP: nuttx.bin"
$(Q) $(OBJCOPY) $(OBJCOPYARGS) -O binary nuttx$(EXEEXT) nuttx.bin
endif
$(call POSTBUILD, $(APPDIR))
import: $(IMPORT_TOOLS)
$(Q) $(MAKE) context TOPDIR="$(APPDIR)$(DELIM)import"
$(Q) $(MAKE) register TOPDIR="$(APPDIR)$(DELIM)import"
$(Q) $(MAKE) depend TOPDIR="$(APPDIR)$(DELIM)import"
$(Q) $(MAKE) .import TOPDIR="$(APPDIR)$(DELIM)import"
endif # CONFIG_BUILD_KERNEL
dirlinks:
$(Q) $(MAKE) -C platform dirlinks
context_all: $(foreach SDIR, $(CONFIGURED_APPS), $(SDIR)_context)
register_all: $(foreach SDIR, $(CONFIGURED_APPS), $(SDIR)_register)
context:
$(Q) $(MAKE) context_all
$(Q) $(MAKE) register_all
Kconfig:
$(foreach SDIR, $(CONFIGDIRS), $(call MAKE_template,$(SDIR),preconfig))
$(Q) $(MKKCONFIG)
preconfig: Kconfig
export:
ifneq ($(EXPORTDIR),)
ifneq ($(BUILTIN_REGISTRY),)
$(Q) mkdir -p "${EXPORTDIR}"/registry || exit 1; \
for f in "${BUILTIN_REGISTRY}"/*.bdat "${BUILTIN_REGISTRY}"/*.pdat ; do \
[ -f "$${f}" ] && cp -f "$${f}" "${EXPORTDIR}"/registry ; \
done
endif
endif
.depdirs: $(foreach SDIR, $(CONFIGURED_APPS), $(SDIR)_depend)
.depend: Makefile .depdirs
$(Q) touch $@
depend: .depend
clean_context:
$(Q) $(MAKE) -C platform clean_context
$(Q) $(MAKE) -C builtin clean_context
clean: $(foreach SDIR, $(CLEANDIRS), $(SDIR)_clean)
$(call DELFILE, $(SYMTABSRC))
$(call DELFILE, $(SYMTABOBJ))
$(call DELFILE, $(BIN))
$(call DELFILE, Kconfig)
$(call DELDIR, $(BINDIR))
$(call CLEAN)
distclean: $(foreach SDIR, $(CLEANDIRS), $(SDIR)_distclean)
ifeq ($(CONFIG_WINDOWS_NATIVE),y)
$(Q) ( if exist external ( \
echo ********************************************************" \
echo * The external directory/link must be removed manually *" \
echo ********************************************************" \
)
else
$(Q) ( if [ -e external ]; then \
echo "********************************************************"; \
echo "* The external directory/link must be removed manually *"; \
echo "********************************************************"; \
fi; \
)
endif
$(call DELFILE, .depend)
$(call DELFILE, $(SYMTABSRC))
$(call DELFILE, $(SYMTABOBJ))
$(call DELFILE, $(BIN))
$(call DELFILE, Kconfig)
$(call DELDIR, $(BINDIR))
$(call CLEAN)

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,131 @@
############################################################################
# apps/nshlib/Makefile
#
# Copyright (C) 2011-2013, 2016 Gregory Nutt. All rights reserved.
# Author: Gregory Nutt <gnutt@nuttx.org>
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in
# the documentation and/or other materials provided with the
# distribution.
# 3. Neither the name NuttX nor the names of its contributors may be
# used to endorse or promote products derived from this software
# without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
############################################################################
include $(APPDIR)/Make.defs
# NSH Library
CSRCS = nsh_init.c nsh_parse.c nsh_console.c nsh_script.c nsh_system.c
CSRCS += nsh_command.c nsh_fscmds.c nsh_ddcmd.c nsh_proccmds.c nsh_mmcmds.c
CSRCS += nsh_timcmds.c nsh_envcmds.c nsh_syscmds.c nsh_dbgcmds.c nsh_Applicationscmd.c
ifeq ($(CONFIG_FILE_STREAM),y)
CSRCS += nsh_session.c
ifeq ($(CONFIG_NSH_CONSOLE_LOGIN),y)
CSRCS += nsh_login.c
endif
else
CSRCS += nsh_stdsession.c
ifeq ($(CONFIG_NSH_CONSOLE_LOGIN),y)
CSRCS += nsh_stdlogin.c
endif
endif
CSRCS += nsh_fsutils.c
ifeq ($(CONFIG_NSH_BUILTIN_APPS),y)
CSRCS += nsh_builtin.c
endif
ifeq ($(CONFIG_NSH_FILE_APPS),y)
CSRCS += nsh_fileapps.c
endif
ifeq ($(CONFIG_NSH_VARS),y)
CSRCS += nsh_vars.c
endif
ifeq ($(CONFIG_NSH_ROMFSETC),y)
CSRCS += nsh_romfsetc.c
endif
ifeq ($(CONFIG_NET),y)
CSRCS += nsh_netcmds.c
ifeq ($(CONFIG_NET_ROUTE),y)
CSRCS += nsh_routecmds.c
endif
endif
ifneq ($(CONFIG_DISABLE_MOUNTPOINT),y)
CSRCS += nsh_mntcmds.c
endif
ifeq ($(CONFIG_MODULE),y)
ifneq ($(CONFIG_NSH_DISABLE_MODCMDS),y)
CSRCS += nsh_modcmds.c
endif
endif
ifeq ($(CONFIG_NSH_CONSOLE),y)
CSRCS += nsh_consolemain.c
endif
ifneq ($(CONFIG_NSH_DISABLE_PRINTF),y)
CSRCS += nsh_printf.c
endif
ifeq ($(CONFIG_NSH_TELNET),y)
CSRCS += nsh_telnetd.c
ifeq ($(CONFIG_NSH_TELNET_LOGIN),y)
CSRCS += nsh_telnetlogin.c
endif
endif
ifneq ($(CONFIG_NSH_DISABLESCRIPT),y)
CSRCS += nsh_test.c
endif
ifeq ($(CONFIG_USBDEV),y)
CSRCS += nsh_usbconsole.c
endif
ifeq ($(CONFIG_NSH_ALTCONDEV),y)
CSRCS += nsh_altconsole.c
endif
ifeq ($(CONFIG_NSH_USBDEV_TRACE),y)
CSRCS += nsh_usbtrace.c
endif
ifeq ($(CONFIG_NETUTILS_CODECS),y)
CSRCS += nsh_codeccmd.c
endif
ifeq ($(CONFIG_NSH_LOGIN_PASSWD),y)
CSRCS += nsh_passwdcmds.c
endif
include $(APPDIR)/Application.mk

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,128 @@
/****************************************************************************
* apps/nshlib/nsh_Applicationscmd.c
*
* Copyright (C) 2016 Alan Carvalho de Assis. All rights reserved.
* Author: Alan Carvalho de Assis <acassis@gmail.com>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* 3. Neither the name NuttX nor the names of its contributors may be
* used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <ctype.h>
#include <libgen.h>
#include <errno.h>
#include "nsh.h"
#include "nsh_console.h"
extern int FrameworkInit(void);
/****************************************************************************
* Name: cmd_Pm10Ps5308
****************************************************************************/
#if defined(CONFIG_APPLICATION_SENSOR_PM1_0_PS5308) && !defined(CONFIG_NSH_DISABLE_PM1_0PS5308)
extern void Pm10Ps5308(void);
int cmd_Pm10Ps5308(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
{
printf("Hello, world!\n");
FrameworkInit();
Pm10Ps5308();
return 0;
}
#endif
/****************************************************************************
* Name: cmd_Pm25Ps5308
****************************************************************************/
#if defined(CONFIG_APPLICATION_SENSOR_PM2_5_PS5308) && !defined(CONFIG_NSH_DISABLE_PM2_5PS5308)
extern void Pm25Ps5308(void);
int cmd_Pm25Ps5308(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
{
printf("Hello, world!\n");
FrameworkInit();
Pm25Ps5308();
return 0;
}
#endif
/****************************************************************************
* Name: cmd_Pm10Ps5308
****************************************************************************/
#if defined(CONFIG_APPLICATION_SENSOR_PM10_PS5308) && !defined(CONFIG_NSH_DISABLE_PM10PS5308)
extern void Pm100Ps5308(void);
int cmd_Pm100Ps5308(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
{
printf("Hello, world!\n");
FrameworkInit();
Pm100Ps5308();
return 0;
}
#endif
/****************************************************************************
* Name: cmd_TempHs300x
****************************************************************************/
#if defined(CONFIG_APPLICATION_SENSOR_TEMPERATURE_HS300X) && !defined(CONFIG_NSH_DISABLE_TEMPHS300X)
extern void TempHs300x(void);
int cmd_TempHs300x(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
{
printf("Hello, world!\n");
FrameworkInit();
TempHs300x();
return 0;
}
#endif
/****************************************************************************
* Name: cmd_HumiHs300x
****************************************************************************/
#if defined(CONFIG_APPLICATION_SENSOR_HUMIDITY_HS300X) && !defined(CONFIG_NSH_DISABLE_HUMIHS300X)
extern void HumiHs300x(void);
int cmd_HumiHs300x(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
{
printf("Hello, world!\n");
FrameworkInit();
HumiHs300x();
return 0;
}
#endif

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,13 @@
#!/usr/bin/env bash
export current=$(pwd)
export nuttx=$current/..
export top=$current/../../..
chmod -R +x $top
find $top -name Kconfig -exec dos2unix -q {} \;
cp -rf $current/nuttx $nuttx
cp -rf $current/apps $nuttx
cd ../nuttx

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,48 @@
############################################################################
# Makefile
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership. The
# ASF licenses this file to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance with the
# License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
#
############################################################################
# Check if the system has been configured
ifeq ($(wildcard .config),)
.DEFAULT default:
@echo "NuttX has not been configured!"
@echo "To configure the project:"
@echo " tools/configure.sh <config>"
@echo "For a list of available configurations:"
@echo " tools/configure.sh -L"
else
include .config
# Build any necessary tools needed early in the build.
# incdir - Is needed immediately by all Make.defs file.
TOPDIR := ${shell echo $(CURDIR) | sed -e 's/ /\\ /g'}
DUMMY := ${shell $(MAKE) -C tools -f Makefile.host incdir \
INCDIR="$(TOPDIR)/tools/incdir.sh"}
# Include the correct Makefile for the selected architecture.
ifeq ($(CONFIG_WINDOWS_NATIVE),y)
include tools/Makefile.win
else
export KERNEL_ROOT = $(CURDIR)
include tools/Makefile.unix
endif
endif

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,80 @@
/****************************************************************************
* boards/arm/stm32/common/include/stm32_hs300x.h
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
****************************************************************************/
#ifndef __STM32_HS300X_H
#define __STM32_HS300X_H
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/****************************************************************************
* Public Types
****************************************************************************/
/****************************************************************************
* Public Data
****************************************************************************/
#ifdef __cplusplus
#define EXTERN extern "C"
extern "C"
{
#else
#define EXTERN extern
#endif
/****************************************************************************
* Inline Functions
****************************************************************************/
/****************************************************************************
* Public Function Prototypes
****************************************************************************/
/****************************************************************************
* Name: board_hs300x_initialize
*
* Description:
* Initialize and register the hs300x Temperature Sensor driver.
*
* Input Parameters:
* devno - The device number, used to build the device path as /dev/i2cN
* busno - The I2C bus number
*
* Returned Value:
* Zero (OK) on success; a negated errno value on failure.
*
****************************************************************************/
int board_hs300x_initialize(int devno, int busno);
#undef EXTERN
#ifdef __cplusplus
}
#endif
#endif // __STM32_HS300X_H

View File

@ -0,0 +1,131 @@
#############################################################################
# boards/arm/stm32/common/src/Make.defs
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership. The
# ASF licenses this file to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance with the
# License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
#
#############################################################################
ifeq ($(CONFIG_SENSORS_BMP180),y)
CSRCS += stm32_bmp180.c
endif
ifeq ($(CONFIG_LEDS_APA102),y)
CSRCS += stm32_apa102.c
endif
ifeq ($(CONFIG_WS2812),y)
CSRCS += stm32_ws2812.c
endif
ifeq ($(CONFIG_SENSORS_MAX6675),y)
CSRCS += stm32_max6675.c
endif
ifeq ($(CONFIG_SENSORS_VEML6070),y)
CSRCS += stm32_veml6070.c
endif
ifeq ($(CONFIG_INPUT_NUNCHUCK),y)
CSRCS += stm32_nunchuck.c
endif
ifeq ($(CONFIG_AUDIO_TONE),y)
CSRCS += stm32_tone.c
endif
ifeq ($(CONFIG_LCD_BACKPACK),y)
CSRCS += stm32_lcd_backpack.c
endif
ifeq ($(CONFIG_LCD_SSD1306),y)
CSRCS += stm32_ssd1306.c
endif
ifeq ($(CONFIG_SENSORS_LM75),y)
CSRCS += stm32_lm75.c
endif
ifeq ($(CONFIG_WL_NRF24L01),y)
CSRCS += stm32_nrf24l01.c
endif
ifeq ($(CONFIG_SENSORS_HCSR04),y)
CSRCS += stm32_hcsr04.c
endif
ifeq ($(CONFIG_SENSORS_APDS9960),y)
CSRCS += stm32_apds9960.c
endif
ifeq ($(CONFIG_SENSORS_ZEROCROSS),y)
CSRCS += stm32_zerocross.c
endif
ifeq ($(CONFIG_SENSORS_QENCODER),y)
CSRCS += stm32_qencoder.c
endif
ifeq ($(CONFIG_SENSORS_INA219),y)
CSRCS += stm32_ina219.c
endif
ifeq ($(CONFIG_SENSORS_L3GD20),y)
CSRCS += stm32_l3gd20.c
endif
ifeq ($(CONFIG_SENSORS_MPL115A),y)
CSRCS += stm32_mpl115a.c
endif
ifeq ($(CONFIG_SENSORS_DHTXX),y)
CSRCS += stm32_dhtxx.c
endif
ifeq ($(CONFIG_SENSORS_XEN1210),y)
CSRCS += stm32_xen1210.c
endif
ifeq ($(CONFIG_SENSORS_BH1750FVI),y)
CSRCS += stm32_bh1750.c
endif
ifeq ($(CONFIG_SENSORS_MLX90614),y)
CSRCS += stm32_mlx90614.c
endif
ifeq ($(CONFIG_SENSORS_MAX31855),y)
CSRCS += stm32_max31855.c
endif
ifeq ($(CONFIG_LIS3DSH),y)
CSRCS += stm32_lis3dsh.c
endif
ifeq ($(CONFIG_BOARD_STM32_IHM07M1),y)
CSRCS += stm32_ihm07m1.c
endif
ifeq ($(CONFIG_BOARD_STM32_IHM08M1),y)
CSRCS += stm32_ihm08m1.c
endif
ifeq ($(CONFIG_SENSORS_HS300X),y)
CSRCS += stm32_hs300x.c
endif
DEPPATH += --dep-path src
VPATH += :src
CFLAGS += $(shell $(INCDIR) "$(CC)" $(TOPDIR)$(DELIM)arch$(DELIM)$(CONFIG_ARCH)$(DELIM)src$(DELIM)board$(DELIM)src)

View File

@ -0,0 +1,102 @@
/****************************************************************************
* boards/arm/stm32/common/src/stm32_hs300x.c
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <stdio.h>
#include <errno.h>
#include <nuttx/i2c/i2c_master.h>
#include <nuttx/sensors/hs300x.h>
#include "stm32.h"
#include "stm32_i2c.h"
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/****************************************************************************
* Private Types
****************************************************************************/
/****************************************************************************
* Private Function Prototypes
****************************************************************************/
/****************************************************************************
* Private Data
****************************************************************************/
/****************************************************************************
* Public Data
****************************************************************************/
/****************************************************************************
* Private Functions
****************************************************************************/
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: board_hs300x_initialize
*
* Description:
* Initialize and register the HS300x Temperature Sensor driver.
*
* Input Parameters:
* devno - The device number, used to build the device path as /dev/i2cN
* busno - The I2C bus number
*
* Returned Value:
* Zero (OK) on success; a negated errno value on failure.
*
****************************************************************************/
int board_hs300x_initialize(int devno, int busno)
{
FAR struct i2c_master_s *i2c;
char devpath[12];
int ret;
/* Get an instance of the I2C1 interface */
i2c = stm32_i2cbus_initialize(busno);
if (!i2c)
{
return -ENODEV;
}
/* Then register the temperature sensor */
snprintf(devpath, 12, "/dev/i2c%d", devno);
ret = hs300x_register(devpath, i2c, CONFIG_SENSOR_DEVICE_HS300X_I2C_ADDR);
if (ret < 0)
{
stm32_i2cbus_uninitialize(i2c);
}
return ret;
}

View File

@ -0,0 +1,99 @@
############################################################################
# boards/arm/stm32/stm32f4discovery/scripts/Make.defs
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership. The
# ASF licenses this file to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance with the
# License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
#
############################################################################
include $(TOPDIR)/.config
include $(TOPDIR)/tools/Config.mk
include $(TOPDIR)/arch/arm/src/armv7-m/Toolchain.defs
LDSCRIPT = ld.script
ifeq ($(CONFIG_CYGWIN_WINTOOL),y)
ARCHSCRIPT = -T "${shell cygpath -w $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT)}"
else
ARCHSCRIPT = -T$(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT)
endif
ifeq ($(CONFIG_DEBUG_SYMBOLS),y)
ARCHOPTIMIZATION = -g
endif
ifneq ($(CONFIG_DEBUG_NOOPT),y)
ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -fomit-frame-pointer
endif
ARCHCFLAGS = -fno-builtin
ARCHCXXFLAGS = -fno-builtin -fno-exceptions -fcheck-new
ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef
ARCHWARNINGSXX = -Wall -Wshadow -Wundef
ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10
ifeq ($(CONFIG_ARMV7M_TOOLCHAIN_CLANGL),y)
ARCHCFLAGS += -nostdlib -ffreestanding
ARCHCXXFLAGS += -nostdlib -ffreestanding
else
ARCHCFLAGS += -funwind-tables
ARCHCXXFLAGS += -fno-rtti -funwind-tables
ifneq ($(CONFIG_DEBUG_NOOPT),y)
ARCHOPTIMIZATION += -fno-strength-reduce
endif
endif
CFLAGS := $(APPPATHS) $(ARCHCFLAGS) $(ARCHWARNINGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) -pipe
CPICFLAGS = $(ARCHPICFLAGS) $(CFLAGS)
CXXFLAGS := $(ARCHCXXFLAGS) $(ARCHWARNINGSXX) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHXXINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) -pipe
CXXPICFLAGS = $(ARCHPICFLAGS) $(CXXFLAGS)
CPPFLAGS := $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS)
AFLAGS := $(CFLAGS) -D__ASSEMBLY__
NXFLATLDFLAGS1 = -r -d -warn-common
NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat-pcrel.ld -no-check-sections
LDNXFLATFLAGS = -e main -s 2048
# Loadable module definitions
CMODULEFLAGS = $(CFLAGS) -mlong-calls # --target1-abs
LDMODULEFLAGS = -r -e module_initialize
ifeq ($(CONFIG_CYGWIN_WINTOOL),y)
LDMODULEFLAGS += -T "${shell cygpath -w $(TOPDIR)/libs/libc/modlib/gnu-elf.ld}"
else
LDMODULEFLAGS += -T $(TOPDIR)/libs/libc/modlib/gnu-elf.ld
endif
# ELF module definitions
CELFFLAGS = $(CFLAGS) -mlong-calls # --target1-abs
CXXELFFLAGS = $(CXXFLAGS) -mlong-calls # --target1-abs
LDELFFLAGS = -r -e main
ifeq ($(CONFIG_CYGWIN_WINTOOL),y)
LDELFFLAGS += -T "${shell cygpath -w $(BOARD_DIR)$(DELIM)scripts$(DELIM)gnu-elf.ld}"
else
LDELFFLAGS += -T $(BOARD_DIR)$(DELIM)scripts$(DELIM)gnu-elf.ld
endif
ifneq ($(CROSSDEV),arm-nuttx-elf-)
LDFLAGS += -nostartfiles -nodefaultlibs
endif
ifeq ($(CONFIG_DEBUG_SYMBOLS),y)
LDFLAGS += -g
endif

View File

@ -0,0 +1,552 @@
/****************************************************************************
* boards/arm/stm32/stm32f4discovery/src/stm32_bringup.c
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <stdbool.h>
#include <stdio.h>
#include <debug.h>
#include <errno.h>
#include <nuttx/fs/fs.h>
#ifdef CONFIG_USBMONITOR
# include <nuttx/usb/usbmonitor.h>
#endif
#include "stm32.h"
#include "stm32_romfs.h"
#ifdef CONFIG_STM32_OTGFS
# include "stm32_usbhost.h"
#endif
#ifdef CONFIG_INPUT_BUTTONS
# include <nuttx/input/buttons.h>
#endif
#ifdef CONFIG_USERLED
# include <nuttx/leds/userled.h>
#endif
#ifdef CONFIG_RNDIS
# include <nuttx/usb/rndis.h>
#endif
#include "stm32f4discovery.h"
/* Conditional logic in stm32f4discovery.h will determine if certain features
* are supported. Tests for these features need to be made after including
* stm32f4discovery.h.
*/
#ifdef HAVE_RTC_DRIVER
# include <nuttx/timers/rtc.h>
# include "stm32_rtc.h"
#endif
/* The following are includes from board-common logic */
#ifdef CONFIG_SENSORS_BMP180
#include "stm32_bmp180.h"
#endif
#ifdef CONFIG_SENSORS_MAX6675
#include "stm32_max6675.h"
#endif
#ifdef CONFIG_INPUT_NUNCHUCK
#include "stm32_nunchuck.h"
#endif
#ifdef CONFIG_SENSORS_ZEROCROSS
#include "stm32_zerocross.h"
#endif
#ifdef CONFIG_SENSORS_QENCODER
#include "board_qencoder.h"
#endif
#ifdef CONFIG_SENSORS_BH1750FVI
#include "stm32_bh1750.h"
#endif
#ifdef CONFIG_LIS3DSH
#include "stm32_lis3dsh.h"
#endif
#ifdef CONFIG_LCD_BACKPACK
#include "stm32_lcd_backpack.h"
#endif
#ifdef CONFIG_SENSORS_MAX31855
#include "stm32_max31855.h"
#endif
#ifdef CONFIG_SENSORS_MLX90614
#include "stm32_mlx90614.h"
#endif
#ifdef CONFIG_SENSORS_XEN1210
#include "stm32_xen1210.h"
#endif
#ifdef CONFIG_SENSORS_HS300X
#include "stm32_hs300x.h"
#endif
#ifdef CONFIG_USBADB
# include <nuttx/usb/adb.h>
#endif
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: stm32_i2c_register
*
* Description:
* Register one I2C drivers for the I2C tool.
*
****************************************************************************/
#if defined(CONFIG_I2C) && defined(CONFIG_SYSTEM_I2CTOOL)
static void stm32_i2c_register(int bus)
{
FAR struct i2c_master_s *i2c;
int ret;
i2c = stm32_i2cbus_initialize(bus);
if (i2c == NULL)
{
syslog(LOG_ERR, "ERROR: Failed to get I2C%d interface\n", bus);
}
else
{
ret = i2c_register(i2c, bus);
if (ret < 0)
{
syslog(LOG_ERR, "ERROR: Failed to register I2C%d driver: %d\n",
bus, ret);
stm32_i2cbus_uninitialize(i2c);
}
}
}
#endif
/****************************************************************************
* Name: stm32_i2ctool
*
* Description:
* Register I2C drivers for the I2C tool.
*
****************************************************************************/
#if defined(CONFIG_I2C) && defined(CONFIG_SYSTEM_I2CTOOL)
static void stm32_i2ctool(void)
{
stm32_i2c_register(1);
#if 0
stm32_i2c_register(1);
stm32_i2c_register(2);
#endif
}
#else
# define stm32_i2ctool()
#endif
/****************************************************************************
* Name: stm32_bringup
*
* Description:
* Perform architecture-specific initialization
*
* CONFIG_BOARD_LATE_INITIALIZE=y :
* Called from board_late_initialize().
*
* CONFIG_BOARD_LATE_INITIALIZE=n && CONFIG_LIB_BOARDCTL=y :
* Called from the NSH library
*
****************************************************************************/
int stm32_bringup(void)
{
#ifdef HAVE_RTC_DRIVER
FAR struct rtc_lowerhalf_s *lower;
#endif
int ret = OK;
#if defined(CONFIG_I2C) && defined(CONFIG_SYSTEM_I2CTOOL)
stm32_i2ctool();
#endif
#ifdef CONFIG_SENSORS_BMP180
/* Initialize the BMP180 pressure sensor. */
ret = board_bmp180_initialize(0, 1);
if (ret < 0)
{
syslog(LOG_ERR, "Failed to initialize BMP180, error %d\n", ret);
return ret;
}
#endif
#ifdef CONFIG_SENSORS_BH1750FVI
ret = board_bh1750_initialize(0, 1);
if (ret < 0)
{
syslog(LOG_ERR, "ERROR: stm32_bh1750initialize() failed: %d\n", ret);
}
#endif
#ifdef CONFIG_SENSORS_ZEROCROSS
/* Configure the zero-crossing driver */
board_zerocross_initialize(0);
#endif
#ifdef CONFIG_LEDS_MAX7219
ret = stm32_max7219init("/dev/numdisp0");
if (ret < 0)
{
syslog(LOG_ERR, "ERROR: max7219_leds_register failed: %d\n", ret);
}
#endif
#ifdef CONFIG_LCD_ST7032
ret = stm32_st7032init("/dev/slcd0");
if (ret < 0)
{
syslog(LOG_ERR, "ERROR: st7032_register failed: %d\n", ret);
}
#endif
#ifdef CONFIG_RGBLED
/* Configure the RGB LED driver */
stm32_rgbled_setup();
#endif
#if defined(CONFIG_PCA9635PW)
/* Initialize the PCA9635 chip */
ret = stm32_pca9635_initialize();
if (ret < 0)
{
serr("ERROR: stm32_pca9635_initialize failed: %d\n", ret);
}
#endif
#ifdef CONFIG_VIDEO_FB
/* Initialize and register the framebuffer driver */
ret = fb_register(0, 0);
if (ret < 0)
{
syslog(LOG_ERR, "ERROR: fb_register() failed: %d\n", ret);
}
#endif
#ifdef CONFIG_LCD_BACKPACK
/* slcd:0, i2c:1, rows=2, cols=16 */
ret = board_lcd_backpack_init(0, 1, 2, 16);
if (ret < 0)
{
syslog(LOG_ERR, "Failed to initialize PCF8574 LCD, error %d\n", ret);
return ret;
}
#endif
#ifdef HAVE_SDIO
/* Initialize the SDIO block driver */
ret = stm32_sdio_initialize();
if (ret != OK)
{
ferr("ERROR: Failed to initialize MMC/SD driver: %d\n", ret);
return ret;
}
#endif
#ifdef CONFIG_MMCSD_SPI
/* Initialize the MMC/SD SPI driver (SPI2 is used) */
ret = stm32_mmcsd_initialize(2, CONFIG_NSH_MMCSDMINOR);
if (ret < 0)
{
syslog(LOG_ERR, "Failed to initialize SD slot %d: %d\n",
CONFIG_NSH_MMCSDMINOR, ret);
}
#endif
#ifdef HAVE_USBHOST
/* Initialize USB host operation. stm32_usbhost_initialize() starts a
* thread will monitor for USB connection and disconnection events.
*/
ret = stm32_usbhost_initialize();
if (ret != OK)
{
uerr("ERROR: Failed to initialize USB host: %d\n", ret);
return ret;
}
#endif
#ifdef HAVE_USBMONITOR
/* Start the USB Monitor */
ret = usbmonitor_start();
if (ret != OK)
{
uerr("ERROR: Failed to start USB monitor: %d\n", ret);
return ret;
}
#endif
#ifdef CONFIG_PWM
/* Initialize PWM and register the PWM device. */
ret = stm32_pwm_setup();
if (ret < 0)
{
syslog(LOG_ERR, "ERROR: stm32_pwm_setup() failed: %d\n", ret);
}
#endif
#ifdef CONFIG_CAN
/* Initialize CAN and register the CAN driver. */
ret = stm32_can_setup();
if (ret < 0)
{
syslog(LOG_ERR, "ERROR: stm32_can_setup failed: %d\n", ret);
}
#endif
#ifdef CONFIG_INPUT_BUTTONS
/* Register the BUTTON driver */
ret = btn_lower_initialize("/dev/buttons");
if (ret < 0)
{
syslog(LOG_ERR, "ERROR: btn_lower_initialize() failed: %d\n", ret);
}
#endif
#ifdef CONFIG_INPUT_NUNCHUCK
/* Register the Nunchuck driver */
ret = board_nunchuck_initialize(0, 1);
if (ret < 0)
{
syslog(LOG_ERR, "ERROR: nunchuck_initialize() failed: %d\n", ret);
}
#endif
#ifdef CONFIG_SENSORS_MLX90614
ret = board_mlx90614_initialize(0, 1);
if (ret < 0)
{
syslog(LOG_ERR, "Failed to initialize MLX90614, error %d\n", ret);
return ret;
}
#endif
#ifdef CONFIG_SENSORS_QENCODER
/* Initialize and register the qencoder driver */
ret = board_qencoder_initialize(0, CONFIG_STM32F4DISCO_QETIMER);
if (ret != OK)
{
syslog(LOG_ERR,
"ERROR: Failed to register the qencoder: %d\n",
ret);
return ret;
}
#endif
#ifdef CONFIG_USERLED
/* Register the LED driver */
ret = userled_lower_initialize("/dev/userleds");
if (ret < 0)
{
syslog(LOG_ERR, "ERROR: userled_lower_initialize() failed: %d\n", ret);
}
#endif
#ifdef CONFIG_RTC_DS1307
ret = stm32_ds1307_init();
if (ret < 0)
{
syslog(LOG_ERR, "Failed to initialize DS1307 RTC driver: %d\n", ret);
return ret;
}
#endif
#ifdef HAVE_RTC_DRIVER
/* Instantiate the STM32 lower-half RTC driver */
lower = stm32_rtc_lowerhalf();
if (!lower)
{
serr("ERROR: Failed to instantiate the RTC lower-half driver\n");
return -ENOMEM;
}
else
{
/* Bind the lower half driver and register the combined RTC driver
* as /dev/rtc0
*/
ret = rtc_initialize(0, lower);
if (ret < 0)
{
serr("ERROR: Failed to bind/register the RTC driver: %d\n", ret);
return ret;
}
}
#endif
#ifdef HAVE_CS43L22
/* Configure CS43L22 audio */
ret = stm32_cs43l22_initialize(1);
if (ret != OK)
{
serr("Failed to initialize CS43L22 audio: %d\n", ret);
}
#endif
#ifdef CONFIG_SENSORS_MAX31855
/* Register device 0 on spi channel 2 */
ret = board_max31855_initialize(0, 2);
if (ret < 0)
{
serr("ERROR: stm32_max31855initialize failed: %d\n", ret);
}
#endif
#ifdef CONFIG_SENSORS_MAX6675
ret = board_max6675_initialize(0, 2);
if (ret < 0)
{
serr("ERROR: stm32_max6675initialize failed: %d\n", ret);
}
#endif
#ifdef CONFIG_FS_PROCFS
/* Mount the procfs file system */
ret = nx_mount(NULL, STM32_PROCFS_MOUNTPOINT, "procfs", 0, NULL);
if (ret < 0)
{
serr("ERROR: Failed to mount procfs at %s: %d\n",
STM32_PROCFS_MOUNTPOINT, ret);
}
#endif
#ifdef CONFIG_STM32_ROMFS
ret = stm32_romfs_initialize();
if (ret < 0)
{
serr("ERROR: Failed to mount romfs at %s: %d\n",
CONFIG_STM32_ROMFS_MOUNTPOINT, ret);
}
#endif
#ifdef CONFIG_SENSORS_XEN1210
ret = board_xen1210_initialize(0, 1);
if (ret < 0)
{
serr("ERROR: xen1210_archinitialize failed: %d\n", ret);
}
#endif
#ifdef CONFIG_LIS3DSH
/* Create a lis3dsh driver instance fitting the chip built into
* stm32f4discovery
*/
ret = board_lis3dsh_initialize(0, 1);
if (ret < 0)
{
serr("ERROR: Failed to initialize LIS3DSH driver: %d\n", ret);
}
#endif
#ifdef HAVE_HCIUART
ret = hciuart_dev_initialize();
if (ret < 0)
{
serr("ERROR: Failed to initialize HCI UART driver: %d\n", ret);
}
#endif
#if defined(CONFIG_RNDIS)
uint8_t mac[6];
mac[0] = 0xa0; /* TODO */
mac[1] = (CONFIG_NETINIT_MACADDR_2 >> (8 * 0)) & 0xff;
mac[2] = (CONFIG_NETINIT_MACADDR_1 >> (8 * 3)) & 0xff;
mac[3] = (CONFIG_NETINIT_MACADDR_1 >> (8 * 2)) & 0xff;
mac[4] = (CONFIG_NETINIT_MACADDR_1 >> (8 * 1)) & 0xff;
mac[5] = (CONFIG_NETINIT_MACADDR_1 >> (8 * 0)) & 0xff;
usbdev_rndis_initialize(mac);
#endif
#ifdef CONFIG_WL_GS2200M
ret = stm32_gs2200m_initialize("/dev/gs2200m", 3);
if (ret < 0)
{
serr("ERROR: Failed to initialize GS2200M: %d \n", ret);
}
#endif
#ifdef CONFIG_LPWAN_SX127X
ret = stm32_lpwaninitialize();
if (ret < 0)
{
syslog(LOG_ERR, "ERROR: Failed to initialize wireless driver:"
" %d\n", ret);
}
#endif /* CONFIG_LPWAN_SX127X */
#ifdef CONFIG_SENSORS_HS300X
ret = board_hs300x_initialize(1,1);
if (ret < 0)
{
syslog(LOG_ERR, "ERROR: Failed to initialize hs300x:"
" %d\n", ret);
}
#endif /* CONFIG_SENSORS_HS300X */
#ifdef CONFIG_USBADB
usbdev_adb_initialize();
#endif
return ret;
}

View File

@ -0,0 +1,993 @@
#
# For a description of the syntax of this configuration file,
# see the file kconfig-language.txt in the NuttX tools repository.
#
menuconfig SENSORS
bool "Sensor Device Support"
select MM_CIRCBUF
default n
---help---
Drivers for various sensors
if SENSORS
config SENSORS_NPOLLWAITERS
int "Number of poll threads"
default 2
---help---
Maximum number of threads than can be waiting for POLL events.
Default: 2
config SENSORS_WTGAHRS2
bool "Wtgahrs2 Sensor Support"
default n
---help---
We can read sensor data by serial interface. It need the hardware sensor
wtgashrs2(JY901) as data source. This sensor can generate accelerometer,
gyroscope, magnetic, barometer and gps data.
config SENSORS_FAKESENSOR
bool "Fake Sensor Support"
default n
---help---
Simulate physical sensor by reading data from csv file.
The file structure is as follows:
First row : set interval, unit millisecond
Second row: csv file header
third row : data
(Each line should not exceed 50 characters)
For example:
interval:12
x,y,z
2.1234,3.23443,2.23456
...
config SENSORS_APDS9960
bool "Avago APDS-9960 Gesture Sensor support"
default n
select I2C
---help---
Enable driver support for the Avago APDS-9960 gesture sensor.
config APDS9960_I2C_FREQUENCY
int "APDS-9960 I2C frequency"
default 400000
depends on SENSORS_APDS9960
config SENSORS_AK09912
bool "Asahi AK09911/AK09912 Compass Sensor"
default n
select I2C
---help---
Enable driver for AK09911/AK09912 Compass sensor.
config SENSORS_AS5048B
bool "AMS AS5048B Magnetic Rotary Encoder support"
default n
select I2C
select SENSORS_QENCODER
---help---
Enable driver support for the AMS AS5048B magnetic rotary encoder.
config SENSORS_AS726X
bool "AMS AS726X Spetral sensor support"
default n
select I2C
---help---
Enable driver support for the AS726X Spectral Sensor.
config SENSORS_BH1750FVI
bool "Rohm BH1750FVI Ambient Light Sensor support"
default n
select I2C
---help---
Enable driver support for the Rohm BH1750FVI light sensor.
config BH1750FVI_I2C_FREQUENCY
int "BH1750FVI I2C frequency"
default 400000
depends on SENSORS_BH1750FVI
config SENSORS_BMG160
bool "Bosch BMG160 Gyroscope Sensor support"
default n
select SPI
---help---
Enable driver support for the Bosch BMG160 gyroscope sensor.
config SENSORS_BMI160
bool "Bosch BMI160 Inertial Measurement Sensor support"
default n
select I2C
---help---
Enable driver support for the Bosch BMI160 Inertial
Measurement sensor
if SENSORS_BMI160
choice
prompt "BMI160 Interface"
default SENSORS_BMI160_SPI
config SENSORS_BMI160_I2C
bool "BMI160 I2C Interface"
select I2C
---help---
Enables support for the I2C interface
config SENSORS_BMI160_SPI
bool "BMI160 SPI Interface"
select SPI
---help---
Enables support for the SPI interface
endchoice
choice
prompt "I2C Address"
default BMI160_I2C_ADDR_68
config BMI160_I2C_ADDR_68
bool "0x68"
---help---
Default address.
If SDO pin is pulled to VDDIO, use 0x69
config BMI160_I2C_ADDR_69
bool "0x69"
---help---
If SDO pin is pulled to VDDIO, use 0x69
endchoice
endif
config SENSORS_BMP180
bool "Bosch BMP180 Barometer Sensor support"
default n
select I2C
---help---
Enable driver support for the Bosch BMP180 barometer sensor.
config SENSORS_BMP280
bool "Bosch BMP280 Barometic Pressure Sensor"
default n
select I2C
---help---
Enable driver for the Bosch BMP280 barometic pressure sensor.
if SENSORS_BMP280
config BMP280_I2C_FREQUENCY
int "BMP280 I2C frequency"
default 400000
endif # SENSORS_BMP280
config SENSORS_DHTXX
bool "DHTxx humidity/temperature Sensor support"
default n
---help---
Enable driver support for the DHTxx humidity/temperature sensor.
config SENSORS_FXOS8700CQ
bool "NXP FXOS8700CQ Motion Sensor support"
default n
select I2C
---help---
Enable driver support for the NXP FXOS8700CQ Motion sensor
config SENSORS_HCSR04
bool "HC-SR04 Distance Measurement Sensor"
default n
---help---
Enable driver support for the HC-SR04 Distance Sensor.
config SENSORS_HYT271
bool "IST HYT271 Humidity and Temperature Sensor support"
default n
---help---
Enable driver support for the HYT271/HYT221/HYT939 humidity/temperature sensor family.
config SENSORS_HYT271_POLL
bool "Enables polling sensor data"
depends on SENSORS_HYT271
default n
---help---
Enables polling of sensor.
config SENSORS_HYT271_POLL_INTERVAL
int "Polling interval in microseconds, default 1 sec"
depends on SENSORS_HYT271 && SENSORS_HYT271_POLL
default 1000000
range 0 4294967295
---help---
The interval until a new sensor measurement will be triggered.
config SENSORS_HYT271_THREAD_STACKSIZE
int "Worker thread stack size"
depends on SENSORS_HYT271 && SENSORS_HYT271_POLL
default 1024
---help---
The stack size for the worker thread.
if SENSORS_HCSR04
config HCSR04_DEBUG
bool "Debug support for the HC-SR04"
default n
---help---
Enables debug features for the HC-SR04
config HCSR04_NPOLLWAITERS
int "Number of waiters to poll"
default 1
---help---
Number of waiters to poll
endif # SENSORS_HCSR04
config SENSORS_ISL29023
bool "Renesas ISL29023 ALS sensor"
default n
select I2C
---help---
Enable driver support for the Renesas ISL29023 ambient light sensor.
if SENSORS_ISL29023
config ISL29023_I2C_FREQUENCY
int "ISL29023 I2C frequency"
default 400000
endif # SENSORS_ISL29023
config SENSORS_HTS221
bool "STMicro HTS221 humidity sensor"
default n
select I2C
---help---
Enable driver support for the STMicro HTS221 humidity sensor.
if SENSORS_HTS221
config HTS221_I2C_FREQUENCY
int "HTS221 I2C frequency"
default 400000
range 1 400000
config HTS221_DEBUG
bool "Debug support for the HTS221"
default n
---help---
Enables debug features for the HTS221
config HTS221_NPOLLWAITERS
int "Number of waiters to poll"
default 1
---help---
Number of waiters to poll
endif # SENSORS_HTS221
config SENSORS_L3GD20
bool "STMicro L3GD20 Gyroscope Sensor support"
default n
select SPI
select SCHED_HPWORK if SENSORS_L3GD20_BUFFER_SIZE > 0
---help---
Enable driver support for the STMicro L3GD20 gyroscope sensor.
config SENSORS_L3GD20_BUFFER_SIZE
int "size of buffer"
default 1
depends on SENSORS_L3GD20
---help---
The size of the circular buffer used. If the value equal to zero,
indicates that the circular buffer is disabled.
config SENSOR_KXTJ9
bool "Kionix KXTJ9 Accelerometer support"
default n
select I2C
if SENSORS_KXTJ9
config KXTJ9_I2C_BUS_SPEED
int "Kionix KXTJ9 Bus Speed in Hz"
default 400000
endif # SENSORS_KXTJ9
config SENSORS_LIS2DH
bool "STMicro LIS2DH device support"
default n
select I2C
---help---
Enable driver support for the STMicro LIS2DH accelerometer
if SENSORS_LIS2DH
config LIS2DH_I2C_FREQUENCY
int "LIS2DH I2C frequency"
default 400000
range 1 400000
config LIS2DH_DEBUG
bool "Debug support for the LIS2DH"
default n
---help---
Enables debug features for the LIS2DH
config LIS2DH_NPOLLWAITERS
int "Number of waiters to poll"
default 2
---help---
Maximum number of threads that can be waiting on poll()
config LIS2DH_DRIVER_SELFTEST
bool "Enable selftest in LIS2DH driver"
default n
---help---
Enable selftest in LIS2DH driver
endif # SENSORS_LIS2DH
config LIS3DSH
bool "STMicro LIS3DSH 3-Axis accelerometer support"
default n
select SPI
---help---
Enable driver support for the STMicro LIS3DSH 3-Axis accelerometer.
config LIS3DH
bool "STMicro LIS3DH 3-Axis accelerometer support"
default n
select SPI
---help---
Enable driver support for the STMicro LIS3DH 3-Axis accelerometer.
config LIS331DL
bool "STMicro LIS331DL device support"
default n
select I2C
config LIS331DL_I2C_FREQUENCY
int "LIS331DL I2C frequency"
default 100000
range 1 100000
depends on LIS331DL
config SENSORS_LSM330SPI
bool "STMicro LSM330 SPI support"
default n
select SPI
---help---
Enable driver support for the STMicro LSM330 on SPI.
config SENSORS_LSM303AGR
bool "STMicro LSM303AGR support"
default n
select I2C
---help---
Enable driver support for the STMicro LSM303AGR.
config LSM303AGR_I2C_FREQUENCY
int "LSM303AGR I2C frequency"
default 400000
range 1 400000
depends on SN_LSM303AGR
config SENSORS_LSM6DSL
bool "STMicro LSM6DSL support"
default n
select I2C
---help---
Enable driver support for the STMicro LSM6DSL.
config LSM6DSL_I2C_FREQUENCY
int "LSM6DSL I2C frequency"
default 400000
range 1 400000
depends on SN_LSM6DSL
config SENSORS_LSM9DS1
bool "STMicro LSM9DS1 support"
default n
select I2C
---help---
Enable driver support for the STMicro LSM9DS1.
config LSM9DS1_I2C_FREQUENCY
int "LSM9DS1 I2C frequency"
default 400000
range 1 400000
depends on SN_LSM9DS1
config SENSORS_LPS25H
bool "STMicro LPS25H pressure sensor"
default n
select I2C
---help---
Enable driver support for the STMicro LPS25H barometer sensor.
if SENSORS_LPS25H
config LPS25H_I2C_FREQUENCY
int "LPS25H I2C frequency"
default 400000
range 1 400000
config DEBUG_LPS25H
bool "Debug support for the LPS25H"
default n
---help---
Enables debug features for the LPS25H
endif # SENSORS_LPS25H
config SENSORS_LTC4151
bool "LTC4151 current and voltage monitor"
default n
select I2C
---help---
Enable driver support for the LinearTechnology LTC4151 current and voltage monitor.
config LTC4151_I2C_FREQUENCY
int "LTC4151 I2C frequency"
default 400000
depends on SENSORS_LTC4151
config SENSORS_INA219
bool "INA219 current and voltage monitor"
default n
select I2C
---help---
Enable driver support for the Texas Instruments INA219 current and voltage monitor.
config INA219_I2C_FREQUENCY
int "INA219 I2C frequency"
default 400000
depends on SENSORS_INA219
config SENSORS_INA226
bool "INA226 current and voltage monitor"
default n
select I2C
---help---
Enable driver support for the Texas Instruments INA226 power monitor.
config INA226_I2C_FREQUENCY
int "INA226 I2C frequency"
default 400000
depends on SENSORS_INA226
config SENSORS_INA3221
bool "INA3221 current and voltage monitor"
default n
select I2C
---help---
Enable driver support for the Texas Instruments INA3221 current and voltage monitor.
config INA3221_I2C_FREQUENCY
int "INA3221 I2C frequency"
default 400000
depends on SENSORS_INA3221
config SENSORS_MB7040
bool "MaxBotix MB7040 Sonar support"
default n
select I2C
---help---
Enable driver support for the MaxBotix MB7040 sonar.
config MB7040_I2C_FREQUENCY
int "MB7040 I2C frequency"
default 400000
range 1 400000
depends on SENSORS_MB7040
config SENSORS_MLX90393
bool "MLX90393 3-Axis Magnetometer"
default n
select SPI
---help---
Enable driver support for the Melex MLX90393 3-Axis magnetometer.
config SENSORS_MLX90614
bool "MLX90614 Infrared Thermometer"
default n
select I2C
---help---
Enable driver support for the Melexis MLX90614 Infrared Thermometer.
if SENSORS_MLX90614
config MLX90614_CRC
bool "Enable CRC Checking (verify if PEC field is valid)"
default n
---help---
Enable checking of CRC-8 (PEC field) checking to guarantee that
read data is valid.
endif
config SENSORS_MCP9844
bool "MCP9844 Temperature Sensor"
default n
select I2C
---help---
Enable driver support for the MCP9844 I2C Temperature sensor.
config MCP9844_I2C_FREQUENCY
int "MCP9844 I2C frequency"
default 400000
range 1 400000
depends on SENSORS_MCP9844
config SENSORS_MS58XX
bool "MEAS MS58XX Altimeter support"
default n
select I2C
---help---
Enable driver support for MEAS MS58XX altimeters.
config MS58XX_I2C_FREQUENCY
int "MS58XX I2C frequency"
default 400000
range 1 400000
depends on SENSORS_MS58XX
config MS58XX_VDD
int "MEAS MS58XX VDD"
default 30
depends on SENSORS_MS58XX
config SENSORS_MPL115A
bool "Freescale MPL115A Barometer Sensor support"
default n
select SPI
---help---
Enable driver support for the Freescale MPL115A barometer sensor.
config MPL115A_REGDEBUG
bool "Debug support for the MPL115A"
default n
depends on SENSORS_MPL115A
---help---
Enables register level debug features for the MPL115A
config SENSORS_ADXL345
bool "Analog Devices ADXL345 Driver"
default n
---help---
Enables support for the ADXL345 driver
if SENSORS_ADXL345
choice
prompt "ADXL345 Interface"
default ADXL345_SPI
config ADXL345_SPI
bool "ADXL345 SPI Interface"
select SPI
---help---
Enables support for the SPI interface.
config ADXL345_I2C
bool "ADXL345 I2C Interface"
select I2C
---help---
Enables support for the I2C interface
endchoice
config ADXL345_ACTIVELOW
bool "Active Low Interrupt"
default n
---help---
The ADXL345 interrupt will be inverted. Instead starting low and going
high, it will start high and will go low when an interrupt is fired.
Default: Active high/rising edge.
config ADXL345_REGDEBUG
bool "Enable Register-Level ADXL345 Debug"
default n
depends on DEBUG_FEATURES
---help---
Enable very low register-level debug output.
endif # SENSORS_ADXL345
config SENSORS_ADXL372
bool "Analog Devices ADXL372 Sensor support"
default n
select SPI
---help---
Enable driver support for the Analog Devices ADXL372 Sensor.
config SENSORS_MPU60X0
bool "Invensense MPU60x0 Sensor support"
default n
---help---
Enable driver support for Invensense MPU60x0 MotionTracker(tm) device.
if SENSORS_MPU60X0
choice
prompt "MPU60x0 Interface"
default MPU60X0_SPI
config MPU60X0_SPI
bool "MPU6000 SPI Interface"
select SPI
---help---
Enables support for the SPI interface (MPU6000 only)
config MPU60X0_I2C
bool "MPU60x0 I2C Interface"
select I2C
---help---
Enables support for the I2C interface (MPU6000
or MPU6050, autodetected during driver initialization)
endchoice
config MPU60X0_I2C_FREQ
int "MPU60x0 I2C Frequency"
depends on MPU60X0_I2C
default 400000
config MPU60X0_EXTI
bool "Enable interrupts"
default n
---help---
Select this when the MPU60x0's INT pin is connected to an
interrupt line on the host processor, and identify the pin
during device registration. The driver will use interrupts to
manage FIFO-full and/or sample-ready events, depending on how
the device is being used. The interface will block until the
next sample is ready, which will naturally synchronize the user
to the sampling rate chosen during operation.
Default: No interrupts or blocking, i.e. user-driven sampling.
endif # SENSORS_MPU60X0
config SENSORS_MAX44009
bool "Maxim MAX44009 ALS sensor"
default n
select I2C
---help---
Enables MAX44009 Ambient Light Sensor
if SENSORS_MAX44009
config MAX44009_I2C_FREQUENCY
int "MAX44009 I2C frequency"
default 400000
range 1 400000
config DEBUG_MAX44009
bool "Enable debug support for the MAX44009"
default n
---help---
Enables debug support for the MAX44009
config MAX44009_NPOLLWAITERS
int "Number of waiters to poll"
default 1
---help---
Number of waiters to poll
endif # SENSORS_MAX44009
config SENSORS_MAX31855
bool "Maxim MAX31855 Driver"
default n
select SPI
---help---
Enables support for the MAX31855 driver
config SENSORS_MAX6675
bool "Maxim MAX6675 Driver"
default n
select SPI
---help---
Enables support for the MAX6675 driver
config SENSORS_LIS3MDL
bool "STMicro LIS3MDL 3-Axis magnetometer support"
default n
select SPI
---help---
Enable driver support for the STMicro LIS3MDL 3-axis magnetometer.
config LM75_I2C
bool
default y if LM75
config SENSORS_LM75
bool "STMicro LM-75 Temperature Sensor support"
default n
select I2C
select LM75_I2C
---help---
Enable driver support for the STMicro LM-75 temperature sensor.
This should also work with compatible temperature sensors such as
the TI TMP100/101.
config LM75_I2C_FREQUENCY
int "LM75 I2C frequency"
default 100000
range 1 100000
depends on LM75_I2C
config SENSORS_LM92
bool "TI LM92 Temperature Sensor support"
default n
select I2C
---help---
Enable driver support for the TI LM92 Temperature Sensor.
config LM92_I2C_FREQUENCY
int "LM92 I2C frequency"
default 400000
range 1 400000
depends on LM92
config SENSORS_SCD30
bool "Sensirion SCD30 CO2, humidity and temperature sensor"
default n
---help---
Enable driver support for the Sensirion SCD30 CO₂, humidity and
temperature sensor.
if SENSORS_SCD30
config SCD30_I2C
bool "Sensirion SCD30 I2C mode"
default y
select I2C
config SCD30_I2C_FREQUENCY
int "SCD30 I2C frequency"
default 100000
range 1 100000
depends on SCD30_I2C
---help---
I2C frequency for SCD30. Note, maximum supported frequency for
this sensor is 100kHz.
config SCD30_DEBUG
bool "Debug support for the SCD30"
default n
---help---
Enables debug features for the SCD30
endif # SENSORS_SCD30
config SENSORS_SGP30
bool "Sensirion SGP30 Gas Platform sensor"
default n
select I2C
---help---
Enable driver support for the Sensirion SCD30 CO₂ and TVOC gas sensor.
if SENSORS_SGP30
config SGP30_I2C_FREQUENCY
int "SGP30 I2C frequency"
default 400000
range 1 400000
config SGP30_DEBUG
bool "Debug support for the SGP30"
default n
---help---
Enables debug features for the SGP30
endif # SENSORS_SGP30
config SENSORS_AHT10
bool "ASAIR AHT10 temperature and humidity sensor"
default n
select I2C
---help---
Enable driver support for the ASAIR AHT10 temperature and humidity sensors.
if SENSORS_AHT10
config AHT10_I2C_FREQUENCY
int "AHT10 I2C frequency"
default 400000
range 1 400000
endif # SENSORS_AHT10
config SENSORS_SHT21
bool "Sensirion SHT21 temperature and humidity sensor"
default n
select I2C
---help---
Enable driver support for the Sensirion SHT20 and SHT21 temperature
and humidity sensors. SHT20 is a budget model with limited humidity
precision.
if SENSORS_SHT21
config SHT21_I2C_FREQUENCY
int "SHT21 I2C frequency"
default 400000
range 1 400000
config SHT21_DEBUG
bool "Debug support for the SHT21"
default n
---help---
Enables debug features for the SHT21
endif # SENSORS_SHT21
config SENSORS_SHT3X
bool "Sensirion SHT3x temperature and humidity sensor"
default n
select I2C
---help---
Enable driver support for the Sensirion SHT3x temperature
and humidity sensors.
if SENSORS_SHT3X
config SHT3X_I2C_FREQUENCY
int "SHT3x I2C frequency"
default 400000
range 1 400000
config SHT3X_I2C_ADDR
hex "SHT3x I2C addr"
default 0x44
range 0x44 0x45
config SHT3X_DEBUG
bool "Debug support for the SHT3x"
default n
---help---
Enables debug features for the SHT3x
endif # SENSORS_SHT3X
config SENSORS_SPS30
bool "Sensirion SPS30 particulate matter sensor"
default n
---help---
Enable driver support for the Sensirion SPS30 particulate matter sensor
sensor.
if SENSORS_SPS30
config SPS30_I2C
bool "Sensirion SPS30 I2C mode"
default y
select I2C
config SPS30_I2C_FREQUENCY
int "SPS30 I2C frequency"
default 100000
range 1 100000
depends on SPS30_I2C
---help---
I2C frequency for SPS30. Note, maximum supported frequency for
this sensor is 100kHz.
config SPS30_DEBUG
bool "Debug support for the SPS30"
default n
---help---
Enables debug features for the SPS30
endif # SENSORS_SPS30
config SENSORS_T67XX
bool "Telair T6713 carbon dioxide sensor"
default n
select I2C
---help---
Enable driver support for the Telair T6713 and T6703 carbon
dioxide sensors.
config SENSORS_QENCODER
bool "Qencoder"
default n
config SENSORS_VEML6070
bool "Vishay VEML6070 UV-A Light Sensor support"
default n
select I2C
---help---
Enable driver support for the Vishay VEML6070 UV-A light sensor.
config VEML6070_I2C_FREQUENCY
int "VEML6070 I2C frequency"
default 100000
depends on SENSORS_VEML6070
config SENSORS_VL53L1X
bool "ST VL53L1X TOF sensor"
default n
select I2C
---help---
Enable driver support for the VL53L1X Time Of Flight sensor.
config SENSORS_XEN1210
bool "Sensixs XEN1210 Magnetometer"
default n
select SPI
---help---
Enable driver support for the Sensixs XEN1210 Magnetometer.
config XEN1210_REGDEBUG
bool "Debug support for the XEN1210"
default n
depends on SENSORS_XEN1210
---help---
Enables register level debug features for the XEN1210
config SENSORS_ZEROCROSS
bool "Zero Cross Sensor"
default n
config SENSORS_ADT7320
bool "Analog Devices ADT7320 Driver"
default n
select SPI
---help---
Enables support for the ADT7320 Driver
config SENSORS_HDC1008
bool "TI HDC1008 temperature and humidity sensor"
default n
select I2C
---help---
Enable driver support for the TI HDC1008 temperature and humidity sensor.
if SENSORS_HDC1008
config HDC1008_I2C_ADDRESS
hex "HDC1008 I2C address"
default 0x40
range 0x40 0x43
---help---
The I2C address of the HDC1008 sensor. It can be configured via straps to
a value between 0x40 and 0x43.
config HDC1008_I2C_FREQUENCY
int "HDC1008 I2C frequency"
default 400000
range 1 400000
config HDC1008_DEBUG
bool "Debug support for the HDC1008"
default n
---help---
Enables debug features for the HDC1008
endif # SENSORS_HDC1008
config HS300X_I2C
bool
default y if HS300X
config SENSORS_HS300X
bool "HS300X Temperature and Humidity Sensor support"
default n
select I2C
select HS300X_I2C
---help---
Enable driver support for the HS300X Temperature and Humidity sensor.
config HS300X_I2C_FREQUENCY
int "HS300X I2C frequency"
default 400000
range 1 900000
depends on HS300X_I2C
endif # SENSORS

View File

@ -0,0 +1,315 @@
############################################################################
# drivers/sensors/Make.defs
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership. The
# ASF licenses this file to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance with the
# License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
#
############################################################################
# Include sensor drivers
ifeq ($(CONFIG_SENSORS),y)
CSRCS += sensor.c
ifeq ($(CONFIG_SENSORS_WTGAHRS2),y)
CSRCS += wtgahrs2.c
endif
ifeq ($(CONFIG_SENSORS_FAKESENSOR),y)
CSRCS += fakesensor.c
endif
ifeq ($(CONFIG_SENSORS_HCSR04),y)
CSRCS += hc_sr04.c
endif
ifeq ($(CONFIG_SENSORS_ADXL345),y)
CSRCS += adxl345_base.c
endif
ifeq ($(CONFIG_SENSORS_DHTXX),y)
CSRCS += dhtxx.c
endif
# These drivers depend on I2C support
ifeq ($(CONFIG_I2C),y)
ifeq ($(CONFIG_SENSORS_APDS9960),y)
CSRCS += apds9960.c
endif
ifeq ($(CONFIG_SENSORS_AK09912),y)
CSRCS += ak09912.c
endif
ifeq ($(CONFIG_SENSORS_AS5048B),y)
CSRCS += as5048b.c
endif
ifeq ($(CONFIG_SENSORS_AS726X),y)
CSRCS += as726x.c
endif
ifeq ($(CONFIG_SENSORS_FXOS8700CQ),y)
CSRCS += fxos8700cq.c
endif
ifeq ($(CONFIG_SENSORS_HYT271),y)
CSRCS += hyt271.c
endif
ifeq ($(CONFIG_SENSORS_KXTJ9),y)
CSRCS += kxtj9.c
endif
ifeq ($(CONFIG_SENSORS_LIS2DH),y)
CSRCS += lis2dh.c
endif
ifeq ($(CONFIG_LIS331DL),y)
CSRCS += lis331dl.c
endif
ifeq ($(CONFIG_SENSORS_LSM303AGR),y)
CSRCS += lsm303agr.c
endif
ifeq ($(CONFIG_SENSORS_LSM6DSL),y)
CSRCS += lsm6dsl.c
endif
ifeq ($(CONFIG_SENSORS_LSM9DS1),y)
CSRCS += lsm9ds1.c
endif
ifeq ($(CONFIG_SENSORS_LPS25H),y)
CSRCS += lps25h.c
endif
ifeq ($(CONFIG_ADXL345_I2C),y)
CSRCS += adxl345_i2c.c
endif
ifeq ($(CONFIG_SENSORS_BH1750FVI),y)
CSRCS += bh1750fvi.c
endif
ifeq ($(CONFIG_SENSORS_BMG160),y)
CSRCS += bmg160.c
endif
ifeq ($(CONFIG_SENSORS_BMI160),y)
CSRCS += bmi160.c
endif
ifeq ($(CONFIG_SENSORS_BMP180),y)
CSRCS += bmp180.c
endif
ifeq ($(CONFIG_SENSORS_BMP280),y)
CSRCS += bmp280.c
endif
ifeq ($(CONFIG_SENSORS_ISL29023),y)
CSRCS += isl29023.c
endif
ifeq ($(CONFIG_SENSORS_HTS221),y)
CSRCS += hts221.c
endif
ifeq ($(CONFIG_LM75_I2C),y)
CSRCS += lm75.c
endif
ifeq ($(CONFIG_SENSORS_LM92),y)
CSRCS += lm92.c
endif
ifeq ($(CONFIG_SENSORS_MAX44009),y)
CSRCS += max44009.c
endif
ifeq ($(CONFIG_SENSORS_MB7040),y)
CSRCS += mb7040.c
endif
ifeq ($(CONFIG_SENSORS_MCP9844),y)
CSRCS += mcp9844.c
endif
ifeq ($(CONFIG_SENSORS_MLX90393),y)
CSRCS += mlx90393.c
endif
ifeq ($(CONFIG_SENSORS_MLX90614),y)
CSRCS += mlx90614.c
endif
ifeq ($(CONFIG_SENSORS_MS58XX),y)
CSRCS += ms58xx.c
endif
ifeq ($(CONFIG_SENSORS_LTC4151),y)
CSRCS += ltc4151.c
endif
ifeq ($(CONFIG_SENSORS_INA219),y)
CSRCS += ina219.c
endif
ifeq ($(CONFIG_SENSORS_INA226),y)
CSRCS += ina226.c
endif
ifeq ($(CONFIG_SENSORS_INA3221),y)
CSRCS += ina3221.c
endif
ifeq ($(CONFIG_SENSORS_SCD30),y)
CSRCS += scd30.c
endif
ifeq ($(CONFIG_SENSORS_SGP30),y)
CSRCS += sgp30.c
endif
ifeq ($(CONFIG_SENSORS_AHT10),y)
CSRCS += aht10.c
endif
ifeq ($(CONFIG_SENSORS_SHT21),y)
CSRCS += sht21.c
endif
ifeq ($(CONFIG_SENSORS_SHT3X),y)
CSRCS += sht3x.c
endif
ifeq ($(CONFIG_SENSORS_SPS30),y)
CSRCS += sps30.c
endif
ifeq ($(CONFIG_SENSORS_T67XX),y)
CSRCS += t67xx.c
endif
endif # CONFIG_I2C
# These drivers depend on SPI support
ifeq ($(CONFIG_SPI),y)
ifeq ($(CONFIG_ADXL345_SPI),y)
CSRCS += adxl345_spi.c
endif
ifeq ($(CONFIG_SENSORS_ADXL372),y)
CSRCS += adxl372.c
endif
ifeq ($(CONFIG_LIS3DSH),y)
CSRCS += lis3dsh.c
endif
ifeq ($(CONFIG_LIS3DH),y)
CSRCS += lis3dh.c
endif
ifeq ($(CONFIG_SENSORS_MAX31855),y)
CSRCS += max31855.c
endif
ifeq ($(CONFIG_SENSORS_MAX6675),y)
CSRCS += max6675.c
endif
ifeq ($(CONFIG_SENSORS_MPL115A),y)
CSRCS += mpl115a.c
endif
ifeq ($(CONFIG_SENSORS_LIS3MDL),y)
CSRCS += lis3mdl.c
endif
ifeq ($(CONFIG_SENSORS_LSM330SPI),y)
CSRCS += lsm330_spi.c
endif
ifeq ($(CONFIG_SENSORS_L3GD20),y)
CSRCS += l3gd20.c
endif
ifeq ($(CONFIG_SENSORS_ADT7320),y)
CSRCS += adt7320.c
endif
endif # CONFIG_SPI
ifeq ($(CONFIG_SENSORS_MPU60X0),y)
CSRCS += mpu60x0.c
endif
# Quadrature encoder upper half
ifeq ($(CONFIG_SENSORS_QENCODER),y)
CSRCS += qencoder.c
endif
# Vishay VEML6070
ifeq ($(CONFIG_SENSORS_VEML6070),y)
CSRCS += veml6070.c
endif
# ST VL53L1X
ifeq ($(CONFIG_SENSORS_VL53L1X),y)
CSRCS += vl53l1x.c
endif
# Sensixs XEN1210
ifeq ($(CONFIG_SENSORS_XEN1210),y)
CSRCS += xen1210.c
endif
# Zero Cross upper half
ifeq ($(CONFIG_SENSORS_ZEROCROSS),y)
CSRCS += zerocross.c
endif
# TI HDC1008
ifeq ($(CONFIG_SENSORS_HDC1008),y)
CSRCS += hdc1008.c
endif
# HS300x
ifeq ($(CONFIG_SENSORS_HS300X),y)
CSRCS += hs300x.c
endif
# Include sensor driver build support
DEPPATH += --dep-path sensors
VPATH += :sensors
CFLAGS += ${shell $(INCDIR) "$(CC)" $(TOPDIR)$(DELIM)drivers$(DELIM)sensors}
endif # CONFIG_SENSORS

View File

@ -0,0 +1,253 @@
/****************************************************************************
* drivers/sensors/hs300x.c
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <inttypes.h>
#include <stdlib.h>
#include <fixedmath.h>
#include <errno.h>
#include <debug.h>
#include <nuttx/kmalloc.h>
#include <nuttx/fs/fs.h>
#include <nuttx/i2c/i2c_master.h>
#include <nuttx/sensors/hs300x.h>
#include <nuttx/random.h>
#if defined(CONFIG_I2C) && defined(CONFIG_HS300X_I2C)
/****************************************************************************
* Private
****************************************************************************/
struct hs300x_dev_s
{
FAR struct i2c_master_s *i2c; /* I2C interface */
uint8_t addr; /* I2C address */
};
/****************************************************************************
* Private Function Prototypes
****************************************************************************/
/* I2C Helpers */
static int hs300x_i2c_write(FAR struct hs300x_dev_s *priv, FAR char *buffer, int buflen);
static int hs300x_i2c_read(FAR struct hs300x_dev_s *priv, FAR char *buffer, int buflen);
/* Character driver methods */
static int hs300x_open(FAR struct file *filep);
static int hs300x_close(FAR struct file *filep);
static ssize_t hs300x_read(FAR struct file *filep, FAR char *buffer, size_t buflen);
static ssize_t hs300x_write(FAR struct file *filep, FAR const char *buffer, size_t buflen);
/****************************************************************************
* Private Data
****************************************************************************/
static const struct file_operations g_hs300xfops =
{
hs300x_open,
hs300x_close,
hs300x_read,
hs300x_write,
NULL,
NULL,
NULL
};
/****************************************************************************
* Private Functions
****************************************************************************/
/****************************************************************************
* Name: hs300x_i2c_write
*
* Description:
* Write to the I2C device.
*
****************************************************************************/
static int hs300x_i2c_write(FAR struct hs300x_dev_s *priv,
FAR char *buffer, int buflen)
{
struct i2c_msg_s msg;
int ret;
/* Setup for the transfer */
msg.frequency = CONFIG_HS300X_I2C_FREQUENCY,
msg.addr = priv->addr;
msg.flags = 0;
msg.buffer = (FAR uint8_t *)buffer; /* Override const */
msg.length = buflen;
/* Then perform the transfer. */
ret = I2C_TRANSFER(priv->i2c, &msg, 1);
return (ret >= 0) ? OK : ret;
}
/****************************************************************************
* Name: hs300x_i2c_read
*
* Description:
* Read from the I2C device.
*
****************************************************************************/
static int hs300x_i2c_read(FAR struct hs300x_dev_s *priv,
FAR char *buffer, int buflen)
{
struct i2c_msg_s msg;
int ret;
/* Setup for the transfer */
msg.frequency = CONFIG_HS300X_I2C_FREQUENCY,
msg.addr = priv->addr,
msg.flags = I2C_M_READ;
msg.buffer = (FAR uint8_t *)buffer;
msg.length = buflen;
/* Then perform the transfer. */
ret = I2C_TRANSFER(priv->i2c, &msg, 1);
return (ret >= 0) ? OK : ret;
}
/****************************************************************************
* Name: hs300x_open
****************************************************************************/
static int hs300x_open(FAR struct file *filep)
{
return OK;
}
/****************************************************************************
* Name: hs300x_close
****************************************************************************/
static int hs300x_close(FAR struct file *filep)
{
return OK;
}
/****************************************************************************
* Name: hs300x_read
****************************************************************************/
static ssize_t hs300x_read(FAR struct file *filep, FAR char *buffer,
size_t buflen)
{
FAR struct inode *inode = filep->f_inode;
FAR struct hs300x_dev_s *priv = inode->i_private;
int ret;
if (buflen != 4)
{
snerr("ERROR: You can't read something other than 32 bits (4 bytes)\n");
return -1;
}
/* Restart and read 32-bits from the register */
ret = hs300x_i2c_read(priv, buffer, 4);
if (ret < 0)
{
snerr("ERROR: i2c_read failed: %d\n", ret);
return (ssize_t)ret;;
}
return buflen;
}
/****************************************************************************
* Name: hs300x_write
****************************************************************************/
static ssize_t hs300x_write(FAR struct file *filep, FAR const char *buffer,
size_t buflen)
{
FAR struct inode *inode = filep->f_inode;
FAR struct hs300x_dev_s *priv = inode->i_private;
int ret;
ret = hs300x_i2c_write(priv, buffer, buflen);
if (ret < 0)
{
snerr("ERROR: i2c_write failed: %d\n", ret);
return (ssize_t)ret;;
}
return buflen;
}
/****************************************************************************
* Name: hs300x_register
*
* Description:
* Register the HS300x character device as 'devpath'
*
* Input Parameters:
* devpath - The full path to the driver to register. E.g., "/dev/i2c1"
* i2c - An instance of the I2C interface to use to communicate with HS300X
* addr - The I2C address of the HS300x. The base I2C address of the HS300X
* is 0x44.
*
* Returned Value:
* Zero (OK) on success; a negated errno value on failure.
*
****************************************************************************/
int hs300x_register(FAR const char *devpath, FAR struct i2c_master_s *i2c,
uint8_t addr)
{
FAR struct hs300x_dev_s *priv;
int ret;
/* Sanity check */
DEBUGASSERT(i2c != NULL);
DEBUGASSERT(addr == CONFIG_SENSOR_DEVICE_HS300X_I2C_ADDR);
/* Initialize the HS300x device structure */
priv = (FAR struct hs300x_dev_s *)kmm_malloc(sizeof(struct hs300x_dev_s));
if (priv == NULL)
{
snerr("ERROR: Failed to allocate instance\n");
return -ENOMEM;
}
priv->i2c = i2c;
priv->addr = addr;
/* Register the character driver */
ret = register_driver(devpath, &g_hs300xfops, 0666, priv);
if (ret < 0)
{
snerr("ERROR: Failed to register driver: %d\n", ret);
kmm_free(priv);
}
sninfo("HS300X driver loaded successfully!\n");
return ret;
}
#endif /* CONFIG_I2C && CONFIG_HS300X_I2C */

View File

@ -0,0 +1,88 @@
/****************************************************************************
* include/nuttx/sensors/hs300x.h
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
****************************************************************************/
#ifndef __INCLUDE_NUTTX_SENSORS_HS300X_H
#define __INCLUDE_NUTTX_SENSORS_HS300X_H
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <nuttx/sensors/ioctl.h>
#if defined(CONFIG_I2C) && defined(CONFIG_HS300X_I2C)
/* HS300X Registers frequency and addresses*/
#ifndef CONFIG_HS300X_I2C_FREQUENCY
# define CONFIG_HS300X_I2C_FREQUENCY 400000
#endif
#ifndef CONFIG_SENSOR_DEVICE_HS300X_I2C_ADDR
# define CONFIG_SENSOR_DEVICE_HS300X_I2C_ADDR 0x44
#endif
/****************************************************************************
* Public Types
****************************************************************************/
struct i2c_master_s;
/****************************************************************************
* Public Function Prototypes
****************************************************************************/
#ifdef __cplusplus
#define EXTERN extern "C"
extern "C"
{
#else
#define EXTERN extern
#endif
/****************************************************************************
* Name: hs300x_register
*
* Description:
* Register the HS300x character device as 'devpath'
*
* Input Parameters:
* devpath - The full path to the driver to register. E.g., "/dev/i2c1"
* i2c - An instance of the I2C interface to use to communicate with HS300X
* addr - The I2C address of the HS300x. The base I2C address of the HS300X
* is 0x44.
*
* Returned Value:
* Zero (OK) on success; a negated errno value on failure.
*
****************************************************************************/
int hs300x_register(FAR const char *devpath, FAR struct i2c_master_s *i2c,
uint8_t addr);
#undef EXTERN
#ifdef __cplusplus
}
#endif
#endif /* CONFIG_I2C && CONFIG_HS300X_I2C */
#endif /* __INCLUDE_NUTTX_SENSORS_HS300X_H */

View File

@ -0,0 +1,618 @@
############################################################################
# tools/Makefile.unix
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership. The
# ASF licenses this file to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance with the
# License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
#
############################################################################
export TOPDIR := ${shell echo $(CURDIR) | sed -e 's/ /\\ /g'}
include $(TOPDIR)/Make.defs
# GIT directory present
GIT_DIR = $(if $(wildcard $(TOPDIR)$(DELIM).git),y,)
ifeq ($(GIT_DIR),y)
GIT_PRESENT = `git rev-parse --git-dir 2> /dev/null`
endif
# In case we cannot get version information from GIT
ifeq ($(GIT_PRESENT),)
-include $(TOPDIR)/.version
# In case the version file does not exist
CONFIG_VERSION_STRING ?= "0.0.0"
CONFIG_VERSION_BUILD ?= "0"
VERSION_ARG = -v $(CONFIG_VERSION_STRING) -b $(CONFIG_VERSION_BUILD)
else
# Generate .version every time from GIT history
.PHONY: $(TOPDIR)/.version
endif
# Process architecture specific directories
ARCH_DIR = arch/$(CONFIG_ARCH)
ARCH_SRC = $(ARCH_DIR)/src
ARCH_INC = $(ARCH_DIR)/include
export APPPATHS = -I$(APPDIR)/../../../APP_Framework/Framework/sensor
APPPATHS += -I$(APPDIR)/../../../APP_Framework/Applications/general_functions/list
APPPATHS += -I$(APPDIR)/../../../APP_Framework/Framework/transform_layer/nuttx
export SRC_APP_DIR = ../../../APP_Framework
# CONFIG_APPS_DIR can be over-ridden from the command line or in the .config file.
# The default value of CONFIG_APPS_DIR is ../apps. Ultimately, the application
# will be built if APPDIR is defined. APPDIR will be defined if a directory containing
# a Makefile is found at the path provided by CONFIG_APPS_DIR
ifeq ($(CONFIG_APPS_DIR),)
CONFIG_APPS_DIR = ../apps
endif
APPDIR := $(realpath ${shell if [ -r $(CONFIG_APPS_DIR)/Makefile ]; then echo "$(CONFIG_APPS_DIR)"; fi})
# External code support
# If external/ contains a Kconfig, we define the EXTERNALDIR variable to 'external'
# so that main Kconfig can find it. Otherwise, we redirect it to a dummy Kconfig
# This is due to kconfig inability to do conditional inclusion.
EXTERNALDIR := $(shell if [ -r $(TOPDIR)/external/Kconfig ]; then echo 'external'; else echo 'dummy'; fi)
# CONTEXTDIRS include directories that have special, one-time pre-build
# requirements. Normally this includes things like auto-generation of
# configuration specific files or creation of configurable symbolic links
# CLEANDIRS are the directories that the clean target will executed in.
# These are all directories that we know about.
# CCLEANDIRS are directories that the clean_context target will execute in.
# The clean_context target "undoes" the actions of the context target.
# Only directories known to require cleaning are included.
# KERNDEPDIRS are the directories in which we will build target dependencies.
# If NuttX and applications are built separately (CONFIG_BUILD_PROTECTED or
# CONFIG_BUILD_KERNEL), then this holds only the directories containing
# kernel files.
# USERDEPDIRS. If NuttX and applications are built separately (CONFIG_BUILD_PROTECTED),
# then this holds only the directories containing user files. If
# CONFIG_BUILD_KERNEL is selected, then applications are not build at all.
include tools/Directories.mk
#
# Extra objects used in the final link.
#
# Pass 1 Incremental (relative) link objects should be put into the
# processor-specific source directory (where other link objects will
# be created). If the pass1 object is an archive, it could go anywhere.
ifeq ($(CONFIG_BUILD_2PASS),y)
EXTRA_OBJS += $(CONFIG_PASS1_OBJECT)
endif
# Library build selections
#
# NUTTXLIBS is the list of NuttX libraries that is passed to the
# processor-specific Makefile to build the final NuttX target.
# USERLIBS is the list of libraries used to build the final user-space
# application
# EXPORTLIBS is the list of libraries that should be exported by
# 'make export' is
ifeq ($(CONFIG_BUILD_PROTECTED),y)
include tools/ProtectedLibs.mk
else ifeq ($(CONFIG_BUILD_KERNEL),y)
include tools/KernelLibs.mk
else
include tools/FlatLibs.mk
endif
# LINKLIBS derives from NUTTXLIBS and is simply the same list with the
# subdirectory removed
LINKLIBS = $(patsubst staging/%,%,$(NUTTXLIBS))
# Export tool definitions
MKEXPORT= tools/mkexport.sh
MKEXPORT_ARGS = -t "$(TOPDIR)" -b "$(BOARD_DIR)"
ifneq ($(CONFIG_BUILD_FLAT),y)
MKEXPORT_ARGS += -u
endif
ifneq ($(APPDIR),)
ifneq ($(shell [ -e $(APPDIR)/Makefile ] && echo yes),)
MKEXPORT_ARGS += -a "$(APPDIR)"
MKEXPORT_ARGS += -m "$(MAKE)"
endif
endif
ifeq ($(V),2)
MKEXPORT_ARGS += -d
endif
# This is the name of the final target (relative to the top level directory)
BIN = nuttx$(EXEEXT)
all: $(BIN)
.PHONY: dirlinks context clean_context config oldconfig menuconfig nconfig qconfig gconfig export subdir_clean clean subdir_distclean distclean apps_clean apps_distclean
.PHONY: pass1 pass1dep
.PHONY: pass2 pass2dep
# Target used to copy include/nuttx/lib/math.h. If CONFIG_ARCH_MATH_H is
# defined, then there is an architecture specific math.h header file
# that will be included indirectly from include/math.h. But first, we
# have to copy math.h from include/nuttx/. to include/. Logic within
# include/nuttx/lib/math.h will hand the redirection to the architecture-
# specific math.h header file.
#
# If the CONFIG_LIBM is defined, the Rhombus libm will be built at libc/math.
# Definitions and prototypes for the Rhombus libm are also contained in
# include/nuttx/lib/math.h and so the file must also be copied in that case.
#
# If neither CONFIG_ARCH_MATH_H nor CONFIG_LIBM is defined, then no math.h
# header file will be provided. You would want that behavior if (1) you
# don't use libm, or (2) you want to use the math.h and libm provided
# within your toolchain.
ifeq ($(CONFIG_ARCH_MATH_H),y)
NEED_MATH_H = y
else ifeq ($(CONFIG_LIBM),y)
NEED_MATH_H = y
endif
ifeq ($(NEED_MATH_H),y)
include/math.h: include/nuttx/lib/math.h .clean_context
$(Q) cp -f include/nuttx/lib/math.h include/math.h
else
include/math.h:
endif
# The float.h header file defines the properties of your floating point
# implementation. It would always be best to use your toolchain's float.h
# header file but if none is available, a default float.h header file will
# provided if this option is selected. However there is no assurance that
# the settings in this float.h are actually correct for your platform!
ifeq ($(CONFIG_ARCH_FLOAT_H),y)
include/float.h: include/nuttx/lib/float.h .clean_context
$(Q) cp -f include/nuttx/lib/float.h include/float.h
else
include/float.h:
endif
# Target used to copy include/nuttx/lib/stdarg.h. If CONFIG_ARCH_STDARG_H is
# defined, then there is an architecture specific stdarg.h header file
# that will be included indirectly from include/lib/stdarg.h. But first, we
# have to copy stdarg.h from include/nuttx/. to include/.
ifeq ($(CONFIG_ARCH_STDARG_H),y)
include/stdarg.h: include/nuttx/lib/stdarg.h .clean_context
$(Q) cp -f include/nuttx/lib/stdarg.h include/stdarg.h
else
include/stdarg.h:
endif
# Target used to copy include/nuttx/lib/setjmp.h. If CONFIG_ARCH_SETJMP_H is
# defined, then there is an architecture specific setjmp.h header file
# that will be included indirectly from include/lib/setjmp.h. But first, we
# have to copy setjmp.h from include/nuttx/. to include/.
ifeq ($(CONFIG_ARCH_SETJMP_H),y)
include/setjmp.h: include/nuttx/lib/setjmp.h .clean_context
$(Q) cp -f include/nuttx/lib/setjmp.h include/setjmp.h
else
include/setjmp.h:
endif
# Targets used to build include/nuttx/version.h. Creation of version.h is
# part of the overall NuttX configuration sequence. Notice that the
# tools/mkversion tool is built and used to create include/nuttx/version.h
tools/mkversion$(HOSTEXEEXT):
$(Q) $(MAKE) -C tools -f Makefile.host mkversion$(HOSTEXEEXT)
# [Re-]create .version if it doesn't already exist.
$(TOPDIR)/.version:
$(Q) echo "Create .version"
$(Q) tools/version.sh $(VERSION_ARG) .version
$(Q) chmod 755 .version
include/nuttx/version.h: $(TOPDIR)/.version tools/mkversion$(HOSTEXEEXT) .clean_context
$(Q) echo "Create version.h"
$(Q) tools/mkversion $(TOPDIR) > $@.tmp
$(Q) $(call TESTANDREPLACEFILE, $@.tmp, $@)
# Targets used to build include/nuttx/config.h. Creation of config.h is
# part of the overall NuttX configuration sequence. Notice that the
# tools/mkconfig tool is built and used to create include/nuttx/config.h
tools/mkconfig$(HOSTEXEEXT):
$(Q) $(MAKE) -C tools -f Makefile.host mkconfig$(HOSTEXEEXT)
include/nuttx/config.h: $(TOPDIR)/.config tools/mkconfig$(HOSTEXEEXT) .clean_context
$(Q) tools/mkconfig $(TOPDIR) > $@.tmp
$(Q) $(call TESTANDREPLACEFILE, $@.tmp, $@)
# Targets used to create dependencies
tools/mkdeps$(HOSTEXEEXT):
$(Q) $(MAKE) -C tools -f Makefile.host mkdeps$(HOSTEXEEXT)
tools/cnvwindeps$(HOSTEXEEXT):
$(Q) $(MAKE) -C tools -f Makefile.host cnvwindeps$(HOSTEXEEXT)
# dirlinks, and helpers
#
# Directories links. Most of establishing the NuttX configuration involves
# setting up symbolic links with 'generic' directory names to specific,
# configured directories.
# Link the arch/<arch-name>/include directory to include/arch
include/arch: .clean_context
@echo "LN: include/arch to $(ARCH_DIR)/include"
$(Q) $(DIRLINK) $(TOPDIR)/$(ARCH_DIR)/include include/arch
$(Q) touch $@
# Link the boards/<arch>/<chip>/<board>/include directory to include/arch/board
include/arch/board: include/arch
@echo "LN: include/arch/board to $(BOARD_DIR)/include"
$(Q) $(DIRLINK) $(BOARD_DIR)/include include/arch/board
$(Q) touch $@
ifneq ($(BOARD_COMMON_DIR),)
# Link the boards/<arch>/<chip>/common dir to arch/<arch-name>/src/board
# Link the boards/<arch>/<chip>/<board>/src dir to arch/<arch-name>/src/board/board
$(ARCH_SRC)/board: .clean_context
@echo "LN: $(ARCH_SRC)/board to $(BOARD_COMMON_DIR)"
$(Q) $(DIRLINK) $(BOARD_COMMON_DIR) $(ARCH_SRC)/board
@echo "LN: $(ARCH_SRC)/board/board to $(BOARD_DIR)/src"
$(Q) $(DIRLINK) $(BOARD_DIR)/src $(ARCH_SRC)/board/board
$(Q) touch $@
else
# Link the boards/<arch>/<chip>/<board>/src dir to arch/<arch-name>/src/board
$(ARCH_SRC)/board: .clean_context
@echo "LN: $(ARCH_SRC)/board to $(BOARD_DIR)/src"
$(Q) $(DIRLINK) $(BOARD_DIR)/src $(ARCH_SRC)/board
$(Q) touch $@
endif
# Link the boards/<arch>/<chip>/drivers dir to drivers/platform
drivers/platform: .clean_context
@echo "LN: $(TOPDIR)/drivers/platform to $(BOARD_DRIVERS_DIR)"
$(Q) $(DIRLINK) $(BOARD_DRIVERS_DIR) $(TOPDIR)/drivers/platform
$(Q) touch $@
# Link arch/<arch-name>/src/<chip-name> to arch/<arch-name>/src/chip
$(ARCH_SRC)/chip: .clean_context
ifeq ($(CONFIG_ARCH_CHIP_CUSTOM),y)
@echo "LN: $(ARCH_SRC)/chip to $(CHIP_DIR)"
$(Q) $(DIRLINK) $(CHIP_DIR) $(ARCH_SRC)/chip
else ifneq ($(CONFIG_ARCH_CHIP),)
@echo "LN: $(ARCH_SRC)/chip to $(ARCH_SRC)/$(CONFIG_ARCH_CHIP)"
$(Q) $(DIRLINK) $(TOPDIR)/$(ARCH_SRC)/$(CONFIG_ARCH_CHIP) $(ARCH_SRC)/chip
endif
$(Q) cp -f $(CHIP_KCONFIG) $(TOPDIR)/arch/dummy/Kconfig
$(Q) touch $@
# Link arch/<arch-name>/include/<chip-name> to include/arch/chip
include/arch/chip: include/arch
ifeq ($(CONFIG_ARCH_CHIP_CUSTOM),y)
@echo "LN: include/arch/chip to $(CHIP_DIR)/include"
$(Q) $(DIRLINK) $(CHIP_DIR)/include include/arch/chip
else ifneq ($(CONFIG_ARCH_CHIP),)
@echo "LN: include/arch/chip to $(ARCH_INC)/$(CONFIG_ARCH_CHIP)"
$(Q) $(DIRLINK) $(TOPDIR)/$(ARCH_INC)/$(CONFIG_ARCH_CHIP) include/arch/chip
endif
$(Q) touch $@
dirlinks: include/arch include/arch/board include/arch/chip $(ARCH_SRC)/board $(ARCH_SRC)/chip drivers/platform
$(Q) $(MAKE) -C libs/libxx dirlinks
$(Q) $(MAKE) -C boards dirlinks
$(Q) $(MAKE) -C openamp dirlinks
$(Q) $(MAKE) -C $(CONFIG_APPS_DIR) dirlinks
# context
#
# The context target is invoked on each target build to assure that NuttX is
# properly configured. The basic configuration steps include creation of the
# the config.h and version.h header files in the include/nuttx directory and
# the establishment of symbolic links to configured directories.
context: include/nuttx/config.h include/nuttx/version.h include/math.h include/float.h include/stdarg.h include/setjmp.h dirlinks
$(Q) mkdir -p staging
$(Q) for dir in $(CONTEXTDIRS) ; do \
$(MAKE) -C $$dir context || exit; \
done
# clean_context
#
# This is part of the distclean target. It removes all of the header files
# and symbolic links created by the context target.
clean_context:
$(Q) for dir in $(CCLEANDIRS) ; do \
if [ -e $$dir/Makefile ]; then \
$(MAKE) -C $$dir clean_context ; \
fi \
done
$(call DELFILE, include/nuttx/config.h)
$(call DELFILE, include/nuttx/version.h)
$(call DELFILE, include/float.h)
$(call DELFILE, include/math.h)
$(call DELFILE, include/stdarg.h)
$(call DELFILE, include/setjmp.h)
$(call DELFILE, arch/dummy/Kconfig)
$(Q) $(DIRUNLINK) include/arch/board
$(Q) $(DIRUNLINK) include/arch/chip
$(Q) $(DIRUNLINK) include/arch
$(Q) $(DIRUNLINK) $(ARCH_SRC)/board/board
$(Q) $(DIRUNLINK) $(ARCH_SRC)/board
$(Q) $(DIRUNLINK) $(ARCH_SRC)/chip
$(Q) $(DIRUNLINK) $(TOPDIR)/drivers/platform
.clean_context: .config
+$(Q) $(MAKE) clean_context
$(Q) touch $@
# Archive targets. The target build sequence will first create a series of
# libraries, one per configured source file directory. The final NuttX
# execution will then be built from those libraries. The following targets
# build those libraries.
include tools/LibTargets.mk
# pass1 and pass2
#
# If the 2 pass build option is selected, then this pass1 target is
# configured to be built before the pass2 target. This pass1 target may, as an
# example, build an extra link object (CONFIG_PASS1_OBJECT) which may be an
# incremental (relative) link object, but could be a static library (archive);
# some modification to this Makefile would be required if CONFIG_PASS1_OBJECT
# is an archive. Exactly what is performed during pass1 or what it generates
# is unknown to this makefile unless CONFIG_PASS1_OBJECT is defined.
pass1: $(USERLIBS)
pass2: $(NUTTXLIBS)
# $(BIN)
#
# Create the final NuttX executable in a two pass build process. In the
# normal case, all pass1 and pass2 dependencies are created then pass1
# and pass2 targets are built. However, in some cases, you may need to build
# pass1 dependencies and pass1 first, then build pass2 dependencies and pass2.
# in that case, execute 'make pass1 pass2' from the command line.
$(BIN): pass1 pass2
ifeq ($(CONFIG_BUILD_2PASS),y)
$(Q) if [ -z "$(CONFIG_PASS1_BUILDIR)" ]; then \
echo "ERROR: CONFIG_PASS1_BUILDIR not defined"; \
exit 1; \
fi
$(Q) if [ ! -d "$(CONFIG_PASS1_BUILDIR)" ]; then \
echo "ERROR: CONFIG_PASS1_BUILDIR does not exist"; \
exit 1; \
fi
$(Q) if [ ! -f "$(CONFIG_PASS1_BUILDIR)/Makefile" ]; then \
echo "ERROR: No Makefile in CONFIG_PASS1_BUILDIR"; \
exit 1; \
fi
$(Q) $(MAKE) -C $(CONFIG_PASS1_BUILDIR) LINKLIBS="$(LINKLIBS)" USERLIBS="$(USERLIBS)" "$(CONFIG_PASS1_TARGET)"
endif
$(Q) $(MAKE) -C $(ARCH_SRC) EXTRA_OBJS="$(EXTRA_OBJS)" LINKLIBS="$(LINKLIBS)" EXTRAFLAGS="$(KDEFINE) $(EXTRAFLAGS)" $(BIN)
$(Q) if [ -w /tftpboot ] ; then \
cp -f $(BIN) /tftpboot/$(BIN).${CONFIG_ARCH}; \
fi
$(Q) echo $(BIN) > nuttx.manifest
$(Q) printf "%s\n" *.map >> nuttx.manifest
ifeq ($(CONFIG_INTELHEX_BINARY),y)
@echo "CP: nuttx.hex"
$(Q) $(OBJCOPY) $(OBJCOPYARGS) -O ihex $(BIN) nuttx.hex
$(Q) echo nuttx.hex >> nuttx.manifest
endif
ifeq ($(CONFIG_MOTOROLA_SREC),y)
@echo "CP: nuttx.srec"
$(Q) $(OBJCOPY) $(OBJCOPYARGS) -O srec $(BIN) nuttx.srec
$(Q) echo nuttx.srec >> nuttx.manifest
endif
ifeq ($(CONFIG_RAW_BINARY),y)
@echo "CP: nuttx.bin"
$(Q) $(OBJCOPY) $(OBJCOPYARGS) -O binary $(BIN) nuttx.bin
$(Q) echo nuttx.bin >> nuttx.manifest
endif
ifeq ($(CONFIG_UBOOT_UIMAGE),y)
@echo "MKIMAGE: uImage"
$(Q) mkimage -A $(CONFIG_ARCH) -O linux -C none -T kernel -a $(CONFIG_UIMAGE_LOAD_ADDRESS) \
-e $(CONFIG_UIMAGE_ENTRY_POINT) -n $(BIN) -d nuttx.bin uImage
$(Q) if [ -w /tftpboot ] ; then \
cp -f uImage /tftpboot/uImage; \
fi
$(Q) echo "uImage" >> nuttx.manifest
endif
$(call POSTBUILD, $(TOPDIR))
# download
#
# This is a helper target that will rebuild NuttX and download it to the target
# system in one step. The operation of this target depends completely upon
# implementation of the DOWNLOAD command in the user Make.defs file. It will
# generate an error if the DOWNLOAD command is not defined.
download: $(BIN)
$(call DOWNLOAD, $<)
# pass1dep: Create pass1 build dependencies
# pass2dep: Create pass2 build dependencies
pass1dep: context tools/mkdeps$(HOSTEXEEXT) tools/cnvwindeps$(HOSTEXEEXT)
$(Q) for dir in $(USERDEPDIRS) ; do \
$(MAKE) -C $$dir depend || exit; \
done
pass2dep: context tools/mkdeps$(HOSTEXEEXT) tools/cnvwindeps$(HOSTEXEEXT)
$(Q) for dir in $(KERNDEPDIRS) ; do \
$(MAKE) -C $$dir EXTRAFLAGS="$(KDEFINE) $(EXTRAFLAGS)" depend || exit; \
done
# Configuration targets
#
# These targets depend on the kconfig-frontends packages. To use these, you
# must first download and install the kconfig-frontends package from this
# location: https://bitbucket.org/nuttx/tools/downloads/. See README.txt
# file in the NuttX tools GIT repository for additional information.
config: apps_preconfig
$(Q) APPSDIR=${CONFIG_APPS_DIR} EXTERNALDIR=$(EXTERNALDIR) kconfig-conf Kconfig
oldconfig: apps_preconfig
$(Q) APPSDIR=${CONFIG_APPS_DIR} EXTERNALDIR=$(EXTERNALDIR) kconfig-conf --oldconfig Kconfig
olddefconfig: apps_preconfig
$(Q) APPSDIR=${CONFIG_APPS_DIR} EXTERNALDIR=$(EXTERNALDIR) kconfig-conf --olddefconfig Kconfig
menuconfig: apps_preconfig
$(Q) APPSDIR=${CONFIG_APPS_DIR} EXTERNALDIR=$(EXTERNALDIR) kconfig-mconf Kconfig
nconfig: apps_preconfig
$(Q) APPSDIR=${CONFIG_APPS_DIR} EXTERNALDIR=$(EXTERNALDIR) kconfig-nconf Kconfig
qconfig: apps_preconfig
$(Q) APPSDIR=${CONFIG_APPS_DIR} EXTERNALDIR=$(EXTERNALDIR) kconfig-qconf Kconfig
gconfig: apps_preconfig
$(Q) APPSDIR=${CONFIG_APPS_DIR} EXTERNALDIR=$(EXTERNALDIR) kconfig-gconf Kconfig
savedefconfig: apps_preconfig
$(Q) APPSDIR=${CONFIG_APPS_DIR} EXTERNALDIR=$(EXTERNALDIR) kconfig-conf --savedefconfig defconfig.tmp Kconfig
$(Q) kconfig-tweak --file defconfig.tmp -u CONFIG_APPS_DIR
$(Q) grep "CONFIG_ARCH=" .config >> defconfig.tmp
$(Q) grep "^CONFIG_ARCH_CHIP_" .config >> defconfig.tmp; true
$(Q) grep "CONFIG_ARCH_CHIP=" .config >> defconfig.tmp; true
$(Q) grep "CONFIG_ARCH_BOARD=" .config >> defconfig.tmp; true
$(Q) grep "^CONFIG_ARCH_CUSTOM" .config >> defconfig.tmp; true
$(Q) grep "^CONFIG_ARCH_BOARD_CUSTOM" .config >> defconfig.tmp; true
$(Q) export LC_ALL=C; cat defconfig.tmp | sort | uniq > sortedconfig.tmp
$(Q) echo "#" > warning.tmp
$(Q) echo "# This file is autogenerated: PLEASE DO NOT EDIT IT." >> warning.tmp
$(Q) echo "#" >> warning.tmp
$(Q) echo "# You can use \"make menuconfig\" to make any modifications to the installed .config file." >> warning.tmp
$(Q) echo "# You can then do \"make savedefconfig\" to generate a new defconfig file that includes your" >> warning.tmp
$(Q) echo "# modifications." >> warning.tmp
$(Q) echo "#" >> warning.tmp
$(Q) cat warning.tmp sortedconfig.tmp > defconfig
$(Q) rm -f warning.tmp
$(Q) rm -f defconfig.tmp
$(Q) rm -f sortedconfig.tmp
# export
#
# The export target will package the NuttX libraries and header files into
# an exportable package. Caveats: (1) These needs some extension for the KERNEL
# build; it needs to receive USERLIBS and create a libuser.a). (2) The logic
# in tools/mkexport.sh only supports GCC and, for example, explicitly assumes
# that the archiver is 'ar'
export: $(NUTTXLIBS)
$(Q) MAKE=${MAKE} $(MKEXPORT) $(MKEXPORT_ARGS) -l "$(EXPORTLIBS)"
# General housekeeping targets: dependencies, cleaning, etc.
#
# depend: Create both PASS1 and PASS2 dependencies
# clean: Removes derived object files, archives, executables, and
# temporary files, but retains the configuration and context
# files and directories.
# distclean: Does 'clean' then also removes all configuration and context
# files. This essentially restores the directory structure
# to its original, unconfigured stated.
depend: pass1dep pass2dep
$(foreach SDIR, $(CLEANDIRS), $(eval $(call SDIR_template,$(SDIR),clean)))
subdir_clean: $(foreach SDIR, $(CLEANDIRS), $(SDIR)_clean)
ifeq ($(CONFIG_BUILD_2PASS),y)
$(Q) $(MAKE) -C $(CONFIG_PASS1_BUILDIR) clean
endif
clean: subdir_clean
$(call DELFILE, $(BIN))
$(call DELFILE, nuttx.*)
$(call DELFILE, *.map)
$(call DELFILE, _SAVED_APPS_config)
$(call DELFILE, nuttx-export*.zip)
$(call DELDIR, nuttx-export*)
$(call DELFILE, nuttx_user*)
$(call DELDIR, staging)
$(call DELFILE, uImage)
$(call CLEAN)
$(foreach SDIR, $(CLEANDIRS), $(eval $(call SDIR_template,$(SDIR),distclean)))
subdir_distclean: $(foreach SDIR, $(CLEANDIRS), $(SDIR)_distclean)
distclean: clean subdir_distclean clean_context
ifeq ($(CONFIG_BUILD_2PASS),y)
$(Q) $(MAKE) -C $(CONFIG_PASS1_BUILDIR) distclean
endif
$(call DELFILE, Make.defs)
$(call DELFILE, defconfig)
$(call DELFILE, .config)
$(call DELFILE, .config.old)
$(call DELFILE, .gdbinit)
$(call DELFILE, .clean_context)
$(Q) $(MAKE) -C tools -f Makefile.host clean
# Application housekeeping targets. The APPDIR variable refers to the user
# application directory. A sample apps/ directory is included with NuttX,
# however, this is not treated as part of NuttX and may be replaced with a
# different application directory. For the most part, the application
# directory is treated like any other build directory in this script. However,
# as a convenience, the following targets are included to support housekeeping
# functions in the user application directory from the NuttX build directory.
#
# apps_preconfig: Prepare applications to be configured
# apps_clean: Perform the clean operation only in the user application
# directory
# apps_distclean: Perform the distclean operation only in the user application
# directory.
apps_preconfig: dirlinks
ifneq ($(APPDIR),)
$(Q) $(MAKE) -C $(APPDIR) preconfig
endif
apps_clean:
ifneq ($(APPDIR),)
$(Q) $(MAKE) -C $(APPDIR) clean
endif
apps_distclean:
ifneq ($(APPDIR),)
$(Q) $(MAKE) -C $(APPDIR) distclean
endif

View File

@ -0,0 +1,360 @@
/****************************************************************************
* tools/cfgdefine.c
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <string.h>
#include <ctype.h>
#include "cfgdefine.h"
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/****************************************************************************
* Public Data
****************************************************************************/
char line[LINESIZE + 1];
/****************************************************************************
* Private Data
****************************************************************************/
/* These are configuration variable name that are quoted by configuration
* tool but which must be unquoted when used in C code.
*/
static const char *dequote_list[] =
{
/* NuttX */
"CONFIG_DEBUG_OPTLEVEL", /* Custom debug level */
"CONFIG_EXECFUNCS_NSYMBOLS_VAR", /* Variable holding number of symbols in the table */
"CONFIG_EXECFUNCS_SYMTAB_ARRAY", /* Symbol table array used by exec[l|v] */
"CONFIG_INIT_ARGS", /* Argument list of entry point */
"CONFIG_INIT_SYMTAB", /* Global symbol table */
"CONFIG_INIT_NEXPORTS", /* Global symbol table size */
"CONFIG_MODLIB_SYMTAB_ARRAY", /* Symbol table array used by modlib functions */
"CONFIG_MODLIB_NSYMBOLS_VAR", /* Variable holding number of symbols in the table */
"CONFIG_PASS1_BUILDIR", /* Pass1 build directory */
"CONFIG_PASS1_TARGET", /* Pass1 build target */
"CONFIG_PASS1_OBJECT", /* Pass1 build object */
"CONFIG_USER_ENTRYPOINT", /* Name of entry point function */
/* NxWidgets/NxWM */
"CONFIG_NXWM_BACKGROUND_IMAGE", /* Name of bitmap image class */
"CONFIG_NXWM_CALIBRATION_ICON", /* Name of bitmap image class */
"CONFIG_NXWM_HEXCALCULATOR_ICON", /* Name of bitmap image class */
"CONFIG_NXWM_MINIMIZE_BITMAP", /* Name of bitmap image class */
"CONFIG_NXWM_NXTERM_ICON", /* Name of bitmap image class */
"CONFIG_NXWM_STARTWINDOW_ICON", /* Name of bitmap image class */
"CONFIG_NXWM_STOP_BITMAP", /* Name of bitmap image class */
/* apps/ definitions */
"CONFIG_SYSTEM_NSH_SYMTAB_ARRAYNAME", /* Symbol table array name */
"CONFIG_SYSTEM_NSH_SYMTAB_COUNTNAME", /* Name of the variable holding the number of symbols */
NULL /* Marks the end of the list */
};
/****************************************************************************
* Private Functions
****************************************************************************/
/* Skip over any spaces */
static char *skip_space(char *ptr)
{
while (*ptr && isspace((int)*ptr)) ptr++;
return ptr;
}
/* Find the end of a variable string */
static char *find_name_end(char *ptr)
{
while (*ptr && (isalnum((int)*ptr) || *ptr == '_')) ptr++;
return ptr;
}
/* Find the end of a value string */
static char *find_value_end(char *ptr)
{
while (*ptr && !isspace((int)*ptr))
{
if (*ptr == '"')
{
do ptr++; while (*ptr && *ptr != '"');
if (*ptr) ptr++;
}
else
{
do ptr++; while (*ptr && !isspace((int)*ptr) && *ptr != '"');
}
}
return ptr;
}
/* Read the next line from the configuration file */
static char *read_line(FILE *stream)
{
char *ptr;
for (; ; )
{
line[LINESIZE] = '\0';
if (!fgets(line, LINESIZE, stream))
{
return NULL;
}
else
{
ptr = skip_space(line);
if (*ptr && *ptr != '#' && *ptr != '\n')
{
return ptr;
}
}
}
}
/* Parse the line from the configuration file into a variable name
* string and a value string.
*/
static void parse_line(char *ptr, char **varname, char **varval)
{
/* Skip over any leading spaces */
ptr = skip_space(ptr);
/* The first no-space is the beginning of the variable name */
*varname = skip_space(ptr);
*varval = NULL;
/* Parse to the end of the variable name */
ptr = find_name_end(ptr);
/* An equal sign is expected next, perhaps after some white space */
if (*ptr && *ptr != '=')
{
/* Some else follows the variable name. Terminate the variable
* name and skip over any spaces.
*/
*ptr = '\0';
ptr = skip_space(ptr + 1);
}
/* Verify that the equal sign is present */
if (*ptr == '=')
{
/* Make sure that the variable name is terminated (this was already
* done if the name was followed by white space.
*/
*ptr = '\0';
/* The variable value should follow =, perhaps separated by some
* white space.
*/
ptr = skip_space(ptr + 1);
if (*ptr)
{
/* Yes.. a variable follows. Save the pointer to the start
* of the variable string.
*/
*varval = ptr;
/* Find the end of the variable string and make sure that it
* is terminated.
*/
ptr = find_value_end(ptr);
*ptr = '\0';
}
}
}
static char *dequote_value(const char *varname, char *varval)
{
const char **dqnam;
char *dqval = varval;
char *ptr;
int len;
int i;
if (dqval)
{
/* Check if the variable name is in the dequoted list of strings */
for (dqnam = dequote_list; *dqnam; dqnam++)
{
if (strcmp(*dqnam, varname) == 0)
{
break;
}
}
/* Did we find the variable name in the list of configuration variables
* to be dequoted?
*/
if (*dqnam)
{
/* Yes... Check if there is a trailing quote */
len = strlen(dqval);
if (dqval[len - 1] == '"')
{
/* Yes... replace it with a terminator */
dqval[len - 1] = '\0';
len--;
}
/* Is there a leading quote? */
if (dqval[0] == '"')
{
/* Yes.. skip over the leading quote */
dqval++;
len--;
}
/* A special case is a quoted list of quoted strings. In that case
* we will need to remove the backspaces from the internally quoted
* strings. NOTE: this will not handle nested quoted quotes.
*/
for (ptr = dqval; *ptr; ptr++)
{
/* Check for a quoted quote */
if (ptr[0] == '\\' && ptr[1] == '"')
{
/* Delete the backslash by moving the rest of the string */
for (i = 0; ptr[i]; i++)
{
ptr[i] = ptr[i + 1];
}
len--;
}
}
/* Handle the case where nothing is left after dequoting */
if (len <= 0)
{
dqval = NULL;
}
}
}
return dqval;
}
/****************************************************************************
* Public Functions
****************************************************************************/
void generate_definitions(FILE *stream)
{
char *varname;
char *varval;
char *ptr;
/* Loop until the entire file has been parsed. */
do
{
/* Read the next line from the file */
ptr = read_line(stream);
if (ptr)
{
/* Parse the line into a variable and a value field */
parse_line(ptr, &varname, &varval);
/* Was a variable name found? */
if (varname)
{
/* Yes.. dequote the value if necessary */
varval = dequote_value(varname, varval);
/* If no value was provided or if the special value 'n' was
* provided, then undefine the configuration variable.
*/
if (!varval || strcmp(varval, "n") == 0)
{
printf("#undef %s\n", varname);
}
/* Simply define the configuration variable to '1' if it has
* the special value "y"
*/
else if (strcmp(varval, "y") == 0)
{
printf("#define %s 1\n", varname);
printf("#define %s 1\n", &varname[7]);
}
/* Or to '2' if it has the special value 'm' */
else if (strcmp(varval, "m") == 0)
{
printf("#define %s 2\n", varname);
printf("#define %s 2\n", &varname[7]);
}
/* Otherwise, use the value as provided */
else
{
printf("#define %s %s\n", varname, varval);
printf("#define %s %s\n", &varname[7], varval);
}
}
}
}
while (ptr);
}

315
readme.md Normal file
View File

@ -0,0 +1,315 @@
# 写在前面
如果期望该框架运行在Nuttx系统上请阅读此文档否则请跳过即可。
## 1、感 - 传感器框架支持Nuttx
目前感框架下面的传感器有I2C和串口两种使用两种方式的传感器在APP_Framework下的修改大同小异这里以hs300x传感器测量温度为例说明增加一款传感器适配Nuttx时APP_Framework目录下需要修改的文件
### APP_Framework目录下修改
```shell
└── APP_Framework
├── Applications
│   ├── framework_init.c
│   ├── Make.defs
│   ├── Makefile
│   └── sensor_app
│   ├── Kconfig
│   ├── Make.defs
│   ├── Makefile
│   └── temperature_hs300x.c
├── Framework
│   ├── Make.defs
│   └── sensor
│   ├── Make.defs
│   ├── Makefile
│   ├── sensor.c
│   └── temperature
│   ├── hs300x_temp
│   │   ├── hs300x_temp.c
│   │   ├── Make.defs
│   │   └── Makefile
│   ├── Kconfig
│   ├── Make.defs
│   └── Makefile
├── Make.defs
└── Makefile
```
(1)在上述文件中Make.defs文件是Nuttx特有的文件描述每个Make.defs有两个作用
①根据对应的宏控制是否为CONFIGURED_APPS添加需要编译的目录
②包含子目录中的所有Make.defs向上传递
(2)Makefile文件是多个操作系统共用的里面用CONFIG_ADD_XXXX_FETURES宏来区别不同的操作系统
(3)Kconfig文件也是多个操作系统共用的不同操作系统配置时略有差异也用CONFIG_ADD_XXXX_FETURES进行了控制。
(4)*.c文件的针对适配Nuttx的修改一般是头文件的包含或者接口的调用需要区分不同的操作系统
### Ubiquitous目录下修改
#### 使用I2C外设--以hs300x为例
```shell
└── Nuttx
└── app_match_nuttx
├── apps
│   ├── Makefile
│   └── nshlib
│   ├── Kconfig
│   ├── Makefile
│   ├── nsh_Applicationscmd.c
│   ├── nsh_command.c
│   └── nsh.h
├── build.sh
└── nuttx
├── boards
│   └── arm
│   └── stm32
│   ├── common
│   │   ├── include
│   │   │   └── stm32_hs300x.h
│   │   └── src
│   │   ├── Make.defs
│   │   └── stm32_hs300x.c
│   └── stm32f4discovery
│   ├── scripts
│   │   └── Make.defs
│   └── src
│   └── stm32_bringup.c
├── drivers
│   └── sensors
│   ├── hs300x.c
│   ├── Kconfig
│   └── Make.defs
├── include
│   └── nuttx
│   └── sensors
│   └── hs300x.h
├── Kconfig
├── Makefile
└── tools
├── cfgdefine.c
└── Makefile.unix
```
适配Nuttx系统需要修改Nuttx原生代码中多处文件为了不破坏Nuttx原生代码我们可以先在Nuttx原生代码中进行修改然后将修改的文件导出到app_match_nuttx目录下该目录下的文件结构与Nuttx原生代码完全一致在编译前在app_match_nuttx目录执行一下source build.sh即可将修改同步到nuttx中进行编译。
(1)app_match_nuttx/apps下的Makefile文件进行了一处修改把APP_Framework目录最上层的Make.defs包含进来这样在编译的时候就会引导进入APP_Framework目录进行相应的编译该处已经修改完成后续不用再去修改
```makefile
include $(APPDIR)/../../../APP_Framework/Make.defs
```
(2)app_match_nuttx/apps/nshlib下的修改Nuttx下应用的编译方式有两种一种是编译在Builtin Apps下另一种是编译成系统命令cmd为了与XiUos和rt-thread等其他操作系统保持一致采用后面一种编译方式。具体修改参见该目录下的修改即可这里不加赘述。
(3)app_match_nuttx/nuttx下修改
目前感框架的传感器使用的外设有I2C和串口两种Nuttx针对串口外设的驱动做了比较完善支持因此使用串口的传感器只需要去使能相应的串口即可使用目前ps5308传感器就是这种方式使用I2C和SPI外设的传感器目前Nuttx的做法是在nuttx/drivers/sensors进行传感器的注册主要是定义open/close/read/write等标准的操作接口。传感器的注册这一过程主要涉及到文件主要是上图中的
stm32_hs300x.h
stm32_hs300x.c
stm32f4discovery/stm32_bringup.c(注意支持不同的板子需要在对应的文件下去修改这里当前是stm32f4discovery)
hs300x.c
hs300x.h
(4)nuttx/Makefile的修改在这个文件里只有一出修改设置了一个环境变量 KERNEL_ROOT这个环境变量在APP_Framework中会用到。该处已经修改完成后续不用再去修改
```makefile
export KERNEL_ROOT = $(CURDIR)
```
(5) nuttx/tools/Makefile.unix的修改这个文件中新定义了一个环境变量APPPATHS将APP_Framework中所以的头文件的路径包含进去如果后面有新的头文件加入一定需要在这里加入新头文件的路径设置了一个环境变量SRC_APP_DIR这个环境变量在APP_Framework中会用到。
```makefile
export APPPATHS = -I$(APPDIR)/../../../APP_Framework/Framework/sensor
APPPATHS += -I$(APPDIR)/../../../APP_Framework/Applications/general_functions/list
APPPATHS += -I$(APPDIR)/../../../APP_Framework/Framework/transform_layer/nuttx
export SRC_APP_DIR = ../../../APP_Framework
```
(6)要使(5)中的修改生效需要修改对应板子的Make.defs文件以stm32f4discovery为例在nuttx/boards/arm/stm32/stm32f4discovery/scripts/Make.defs中CFLAGS编译选项加上在(5)中设置的APPPATHS
```makefile
CFLAGS := $(APPPATHS) $(ARCHCFLAGS) $(ARCHWARNINGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) -pipe
```
该Make.defs文件在实际编译时会被拷贝至nuttx目录下
#### 使用串口外设--以ps5308传感器为例
```
.
├── APP_Framework
│   ├── Applications
│   │   ├── framework_init.c
│   │   └── sensor_app
│   │   ├── Kconfig
│   │   ├── Makefile
│   │   ├── pm10_0_ps5308.c
│   │   ├── pm1_0_ps5308.c
│   │   └── pm2_5_ps5308.c
│   └── Framework
│   └── sensor
│   └── pm
│   ├── Kconfig
│   ├── Make.defs
│   └── ps5308
│   ├── Make.defs
│   ├── Makefile
│   └── ps5308.c
└── Ubiquitous
└── Nuttx
└── app_match_nuttx
├── apps
│   └── nshlib
│   ├── Kconfig
│   ├── nsh_Applicationscmd.c
│   ├── nsh_command.c
│   └── nsh.h
└── nuttx
└── arch
└── arm
└── src
└── stm32
└── stm32_serial.c
```
(1)Nuttx/app_match_nuttx/apps/nshlib下修改将应用编译成cmd形式与上面HS300x处描述一致参考上面即可
(2)/nuttx/arch/arm/src/stm32/stm32_serial.c此处代码原本是会将所有打开的串口从0开始依次注册为ttyS1-ttySN比较不方便例如打开了USART1、USART3、USART5USART3将会被注册为ttyS2容易引起歧义这边做的修改会将USARTN注册为ttySN。
其他架构的板卡如K210需要在nuttx/arch/risc-v/src/k210/k210_serial.c进行适配修改。
## 2、硬件支持
目前Nuttx支持ARM和RISC-V两种架构的微处理器:
### ARM
ARM架构系列的开发板有
stm32f407-st-discovery
### RISC-V
RISC-V架构系列的开发板有
## 3、开发环境
### 推荐使用:
### 操作系统: [Ubuntu18.04](https://ubuntu.com/download/desktop)
### 开发工具: [VSCode](http://101.36.126.201:8011/vscode_1.55.2-1618307277_amd64.deb)
### 依赖包安装:
```
$ sudo apt install build-essential pkg-config git
$ sudo apt install gcc make libncurses5-dev openssl libssl-dev bison flex libelf-dev autoconf libtool gperf libc6-dev
```
### 裁减配置工具:
kconfig-frontends工具地址 https://forgeplus.trustie.net/projects/xuos/kconfig-frontends下载与安装的具体命令如下
```shell
mkdir kfrontends && cd kfrontends
git clone https://git.trustie.net/xuos/kconfig-frontends.git
```
下载源码后按以下步骤执行软件安装:
```shell
cd kconfig-frontends
./xs_build.sh
```
### 编译工具链:
ARM arm-none-eabi默认安装到Ubuntu的/usr/bin/arm-none-eabi-,使用如下命令行下载
```shell
mkdir kfrontends && cd kfrontends
git clone https://git.trustie.net/xuos/kconfig-frontends.git
```
## 4、编译及配置
#### 在Nuttx\app_match_nuttx目录下执行
```shell
chmod +x build.sh
source build.sh
```
#### 执行完毕会跳转到Nuttx\nuttx目录执行
```shell
sudo ./tools/configure.sh stm32f4discovery:nsh (应用内核一起编译)
sudo ./tools/configure.sh stm32f4discovery:kostest (应用内核分开编译)
```
#### 然后执行
```shell
sudo make menuconfig
```
##### 使用I2C外设--以hs300x温度传感器为例说明配置过程
①进入XIUOS features > APP_Framework > Framework ,选择操作系统(这一步一定要最先配置)
②依次进入XIUOS features > APP_Framework > Framework > support sensor framework > Using temperature sensor device
进行sensor name、quantity name、device name(这里是一个字符设备的路径)、i2c address的配置。注意这里设置的 HS300x device name 设置的/dev/i2cN需要与第④步勾选的i2cN保持一致
③依次进入XIUOS features > APP_Framework > Applications > sensor app > Using sensor apps > Using sensor temperature apps ,并进行勾选
④依次进入System Type > STM32 Peripheral Support 勾选传感器使用的I2C外设。
⑤ 进入Device Drivers > I2C Driver Support 找到I2C Driver Support 勾选上I2C Slave
⑥在Device Drivers 下找到Sensor Device Support勾选上后进入勾选HS300X Temperature and Humidity Sensor support并设置频率
退出menuconfig界面注意记得保存此时会在nuttx目录下生成一个.config文件。
##### 使用串口外设--以ps5308传感器pm1.0为例说明配置过程:
①进入XIUOS features > APP_Framework > Framework ,选择操作系统(这一步一定要最先配置)
②依次进入XIUOS features > APP_Framework > Framework > support sensor framework > Using PM sensor device进行相应的勾选与设置注意这里设置的 PS5308 device name 设置的/dev/ttySN需要与第④步勾选的USART-N保持一致
③依次进入XIUOS features > APP_Framework > Applications > sensor app > Using sensor apps > Using sensor PM1.0 apps并进行勾选
④依次进入System Type > STM32 Peripheral Support 勾选传感器使用的USART外设。
⑤ 依次进入RTOS Features > Tasks and Scheduling勾选Support parent/child task relationships及Retain child exit status
⑥ 依次进入Device Drivers > Serial Driver Support > USARTN Configuration进行外设buffesize大小、波特率等设置。
退出menuconfig界面注意记得保存此时会在nuttx目录下生成一个.config文件。
#### 在当前目录执行编译
```shell
sudo make -j8
```
make时加上V=1参数可以看到较为详细的编译信息但是编译过程会比较慢。最后在nuttx下会编译出一个nuttx.bin文件(应用内核一起编译)