61 changed files with 14576 additions and 124 deletions
@ -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) |
@ -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 |
|||
|
|||
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 |
|||
include $(KERNEL_ROOT)/compiler.mk |
|||
endif |
@ -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 |
@ -0,0 +1,6 @@ |
|||
############################################################################ |
|||
# APP_Framework/Applications/sensor_app/Make.defs |
|||
############################################################################ |
|||
ifneq ($(CONFIG_APPLICATION_SENSOR),) |
|||
CONFIGURED_APPS += $(APPDIR)/../../../APP_Framework/Applications/sensor_app |
|||
endif |
@ -1,39 +1,103 @@ |
|||
SRC_FILES := |
|||
include $(KERNEL_ROOT)/.config |
|||
|
|||
ifeq ($(CONFIG_APPLICATION_SENSOR_HCHO_TB600B_WQ_HCHO1OS), y) |
|||
SRC_FILES += hcho_tb600b_wq_hcho1os.c |
|||
endif |
|||
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) |
|||
SRC_FILES += tvoc_tb600b_tvoc10.c |
|||
endif |
|||
ifeq ($(CONFIG_APPLICATION_SENSOR_TVOC_TB600B_TVOC10), y) |
|||
CSRCS += tvoc_tb600b_tvoc10.c |
|||
endif |
|||
|
|||
ifeq ($(CONFIG_APPLICATION_SENSOR_IAQ_TB600B_IAQ10), y) |
|||
SRC_FILES += iaq_tb600b_iaq10.c |
|||
endif |
|||
ifeq ($(CONFIG_APPLICATION_SENSOR_IAQ_TB600B_IAQ10), y) |
|||
CSRCS += iaq_tb600b_iaq10.c |
|||
endif |
|||
|
|||
ifeq ($(CONFIG_APPLICATION_SENSOR_CH4_AS830), y) |
|||
SRC_FILES += ch4_as830.c |
|||
endif |
|||
ifeq ($(CONFIG_APPLICATION_SENSOR_CH4_AS830), y) |
|||
CSRCS += ch4_as830.c |
|||
endif |
|||
|
|||
ifeq ($(CONFIG_APPLICATION_SENSOR_CO2_ZG09), y) |
|||
SRC_FILES += co2_zg09.c |
|||
endif |
|||
ifeq ($(CONFIG_APPLICATION_SENSOR_CO2_ZG09), y) |
|||
CSRCS += co2_zg09.c |
|||
endif |
|||
|
|||
ifeq ($(CONFIG_APPLICATION_SENSOR_PM1_0_PS5308), y) |
|||
SRC_FILES += pm1_0_ps5308.c |
|||
endif |
|||
ifeq ($(CONFIG_APPLICATION_SENSOR_PM1_0_PS5308), y) |
|||
CSRCS += pm1_0_ps5308.c |
|||
endif |
|||
|
|||
ifeq ($(CONFIG_APPLICATION_SENSOR_VOICE_D124), y) |
|||
SRC_FILES += voice_d124.c |
|||
endif |
|||
ifeq ($(CONFIG_APPLICATION_SENSOR_PM2_5_PS5308), y) |
|||
CSRCS += pm2_5_ps5308.c |
|||
endif |
|||
|
|||
ifeq ($(CONFIG_APPLICATION_SENSOR_HUMIDITY_HS300X), y) |
|||
SRC_FILES += humidity_hs300x.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_TEMPERATURE_HS300X), y) |
|||
SRC_FILES += temperature_hs300x.c |
|||
endif |
|||
|
|||
include $(KERNEL_ROOT)/compiler.mk |
|||
ifeq ($(CONFIG_ADD_XIUOS_FETURES),y) |
|||
SRC_FILES := |
|||
|
|||
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_APPLICATION_SENSOR_IAQ_TB600B_IAQ10), y) |
|||
SRC_FILES += iaq_tb600b_iaq10.c |
|||
endif |
|||
|
|||
ifeq ($(CONFIG_APPLICATION_SENSOR_CH4_AS830), y) |
|||
SRC_FILES += ch4_as830.c |
|||
endif |
|||
|
|||
ifeq ($(CONFIG_APPLICATION_SENSOR_CO2_ZG09), y) |
|||
SRC_FILES += co2_zg09.c |
|||
endif |
|||
|
|||
ifeq ($(CONFIG_APPLICATION_SENSOR_PM1_0_PS5308), y) |
|||
SRC_FILES += pm1_0_ps5308.c |
|||
endif |
|||
|
|||
ifeq ($(CONFIG_APPLICATION_SENSOR_PM2_5_PS5308), y) |
|||
SRC_FILES += pm2_5_ps5308.c |
|||
endif |
|||
|
|||
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 |
|||
|
@ -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); |
|||
} |
@ -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); |
|||
} |
@ -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) |
@ -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) |
@ -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 |
|||
|
|||
ifeq ($(CONFIG_SENSOR_TEMPERATURE),y) |
|||
SRC_DIR += temperature |
|||
endif |
|||
|
|||
include $(KERNEL_ROOT)/compiler.mk |
|||
ifeq ($(CONFIG_SENSOR_HUMIDITY),y) |
|||
SRC_DIR += humidity |
|||
endif |
|||
|
|||
include $(KERNEL_ROOT)/compiler.mk |
|||
endif |
|||
|
@ -0,0 +1,4 @@ |
|||
############################################################################ |
|||
# APP_Framework/Framework/sensor/humidity/Make.defs |
|||
############################################################################ |
|||
include $(wildcard $(APPDIR)/../../../APP_Framework/Framework/sensor/humidity/*/Make.defs) |
@ -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 |
@ -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 |
@ -0,0 +1,4 @@ |
|||
############################################################################ |
|||
# APP_Framework/Framework/sensor/pm/Make.defs |
|||
############################################################################ |
|||
include $(wildcard $(APPDIR)/../../../APP_Framework/Framework/sensor/pm/*/Make.defs) |
@ -0,0 +1,6 @@ |
|||
############################################################################ |
|||
# APP_Framework/Framework/sensor/pm/ps5308//Make.defs |
|||
############################################################################ |
|||
ifneq ($(CONFIG_SENSOR_PS5308),) |
|||
CONFIGURED_APPS += $(APPDIR)/../../../APP_Framework/Framework/sensor/pm/ps5308 |
|||
endif |
@ -1,3 +1,11 @@ |
|||
SRC_FILES := ps5308.c |
|||
include $(KERNEL_ROOT)/.config |
|||
ifeq ($(CONFIG_ADD_NUTTX_FETURES),y) |
|||
include $(APPDIR)/Make.defs |
|||
CSRCS += ps5308.c |
|||
include $(APPDIR)/Application.mk |
|||
endif |
|||
|
|||
include $(KERNEL_ROOT)/compiler.mk |
|||
ifeq ($(CONFIG_ADD_XIUOS_FETURES),y) |
|||
SRC_FILES := ps5308.c |
|||
include $(KERNEL_ROOT)/compiler.mk |
|||
endif |
|||
|
@ -0,0 +1,4 @@ |
|||
############################################################################ |
|||
# APP_Framework/Framework/sensor/temperature//Make.defs |
|||
############################################################################ |
|||
include $(wildcard $(APPDIR)/../../../APP_Framework/Framework/sensor/temperature/*/Make.defs) |
@ -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 |
@ -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 |
|||
|
@ -0,0 +1,5 @@ |
|||
include $(KERNEL_ROOT)/.config |
|||
include $(APPDIR)/Make.defs |
|||
CSRCS = transform.c |
|||
|
|||
include $(APPDIR)/Application.mk |
@ -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); |
|||
} |
|||
|
@ -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 |
@ -0,0 +1,5 @@ |
|||
############################################################################ |
|||
# APP_Framework/Make.defs |
|||
############################################################################ |
|||
CONFIGURED_APPS += $(APPDIR)/../../../APP_Framework |
|||
include $(wildcard $(APPDIR)/../../../APP_Framework/*/Make.defs) |
@ -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 |
|||
|
|||
|
@ -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) |
|||