Browse Source

add transform layer of xiuos for applications framework from Wang weigen

it is OK
pull/3/head
xuedongliang 1 year ago
parent
commit
4510a95e90
  1. 93
      APP_Framework/Applications/Kconfig
  2. 44
      APP_Framework/Applications/Makefile
  3. 0
      APP_Framework/Applications/app_test/Kconfig
  4. 0
      APP_Framework/Applications/app_test/Makefile
  5. 0
      APP_Framework/Applications/app_test/test_adhoc_lora.c
  6. 0
      APP_Framework/Applications/app_test/test_spi_flash.c
  7. 0
      APP_Framework/Applications/connection_demo/adhoc_lora_demo/Makefile
  8. 0
      APP_Framework/Applications/connection_demo/adhoc_lora_demo/client.c
  9. 0
      APP_Framework/Applications/connection_demo/adhoc_lora_demo/gateway.c
  10. 0
      APP_Framework/Applications/connection_demo/bluetooth_demo/Makefile
  11. 0
      APP_Framework/Applications/connection_demo/bluetooth_demo/bluetooth_receive_demo.c
  12. 0
      APP_Framework/Applications/connection_demo/bluetooth_demo/bluetooth_send_demo.c
  13. 0
      APP_Framework/Applications/connection_demo/ethernet_demo/Makefile
  14. 0
      APP_Framework/Applications/connection_demo/ethernet_demo/ethernet_demo.c
  15. 0
      APP_Framework/Applications/connection_demo/nbiot_demo/Makefile
  16. 0
      APP_Framework/Applications/connection_demo/nbiot_demo/nbiot_demo.c
  17. 0
      APP_Framework/Applications/connection_demo/wifi_demo/Makefile
  18. 0
      APP_Framework/Applications/connection_demo/wifi_demo/wifi_demo.c
  19. 0
      APP_Framework/Applications/connection_demo/zigbee_demo/Makefile
  20. 0
      APP_Framework/Applications/connection_demo/zigbee_demo/zigbee_receive_demo.c
  21. 0
      APP_Framework/Applications/connection_demo/zigbee_demo/zigbee_send_demo.c
  22. 0
      APP_Framework/Applications/cppmain.cpp
  23. 4
      APP_Framework/Applications/framework_init.c
  24. 2
      APP_Framework/Applications/general_functions/Makefile
  25. 3
      APP_Framework/Applications/general_functions/linklist/Makefile
  26. 84
      APP_Framework/Applications/general_functions/linklist/double_linklist.c
  27. 129
      APP_Framework/Applications/general_functions/linklist/list.h
  28. 91
      APP_Framework/Applications/general_functions/linklist/single_linklist.c
  29. 3
      APP_Framework/Applications/general_functions/list/Makefile
  30. 84
      APP_Framework/Applications/general_functions/list/double_list.c
  31. 118
      APP_Framework/Applications/general_functions/list/list.h
  32. 91
      APP_Framework/Applications/general_functions/list/single_list.c
  33. 8
      APP_Framework/Applications/main.c
  34. 0
      APP_Framework/Applications/sd_card_mount.c
  35. 0
      APP_Framework/Applications/sensor_app/Makefile
  36. 0
      APP_Framework/Applications/sensor_app/co2_zg09.c
  37. 0
      APP_Framework/Applications/sensor_app/humidity_hs300x.c
  38. 0
      APP_Framework/Applications/sensor_app/pm1_0_ps5308.c
  39. 0
      APP_Framework/Applications/sensor_app/temperature_hs300x.c
  40. 0
      APP_Framework/Applications/sensor_app/voice_d124.c
  41. 0
      APP_Framework/Applications/spi_sd_card_mount.c
  42. 22
      APP_Framework/Framework/Kconfig
  43. 10
      APP_Framework/Framework/Makefile
  44. 3
      APP_Framework/Framework/connection/Kconfig
  45. 3
      APP_Framework/Framework/connection/Makefile
  46. 310
      APP_Framework/Framework/connection/adapter.c
  47. 123
      APP_Framework/Framework/connection/adapter.h
  48. 0
      APP_Framework/Framework/know/tflite_mnist/.gitignore
  49. 0
      APP_Framework/Framework/know/tflite_mnist/Kconfig
  50. 0
      APP_Framework/Framework/know/tflite_mnist/Makefile
  51. 0
      APP_Framework/Framework/know/tflite_mnist/README.md
  52. 0
      APP_Framework/Framework/know/tflite_mnist/digit.h
  53. 0
      APP_Framework/Framework/know/tflite_mnist/mnistapp.cpp
  54. 0
      APP_Framework/Framework/know/tflite_mnist/mnistmain.c
  55. 0
      APP_Framework/Framework/know/tflite_mnist/model.h
  56. 0
      APP_Framework/Framework/know/tflite_mnist/tools/mnist-c-digit.py
  57. 0
      APP_Framework/Framework/know/tflite_mnist/tools/mnist-c-model.py
  58. 0
      APP_Framework/Framework/know/tflite_mnist/tools/mnist-inference.py
  59. 0
      APP_Framework/Framework/know/tflite_mnist/tools/mnist-train.py
  60. 0
      APP_Framework/Framework/know/tflite_sin/Kconfig
  61. 0
      APP_Framework/Framework/know/tflite_sin/Makefile
  62. 0
      APP_Framework/Framework/know/tflite_sin/constants.cc
  63. 0
      APP_Framework/Framework/know/tflite_sin/constants.h
  64. 0
      APP_Framework/Framework/know/tflite_sin/main_functions.cc
  65. 0
      APP_Framework/Framework/know/tflite_sin/main_functions.h
  66. 0
      APP_Framework/Framework/know/tflite_sin/model.cc
  67. 0
      APP_Framework/Framework/know/tflite_sin/model.h
  68. 0
      APP_Framework/Framework/know/tflite_sin/output_handler.cc
  69. 0
      APP_Framework/Framework/know/tflite_sin/output_handler.h
  70. 0
      APP_Framework/Framework/know/tflite_sin/sinmain.c
  71. 40
      APP_Framework/Framework/sensor/Kconfig
  72. 22
      APP_Framework/Framework/sensor/Makefile
  73. 4
      APP_Framework/Framework/sensor/co2/Kconfig
  74. 2
      APP_Framework/Framework/sensor/co2/Makefile
  75. 0
      APP_Framework/Framework/sensor/co2/zg09/Makefile
  76. 61
      APP_Framework/Framework/sensor/co2/zg09/zg09.c
  77. 0
      APP_Framework/Framework/sensor/humidity/Kconfig
  78. 2
      APP_Framework/Framework/sensor/humidity/Makefile
  79. 0
      APP_Framework/Framework/sensor/humidity/hs300x_humi/Makefile
  80. 36
      APP_Framework/Framework/sensor/humidity/hs300x_humi/hs300x_humi.c
  81. 4
      APP_Framework/Framework/sensor/pm/Kconfig
  82. 2
      APP_Framework/Framework/sensor/pm/Makefile
  83. 0
      APP_Framework/Framework/sensor/pm/ps5308/Makefile
  84. 70
      APP_Framework/Framework/sensor/pm/ps5308/ps5308.c
  85. 65
      APP_Framework/Framework/sensor/sensor.c
  86. 10
      APP_Framework/Framework/sensor/sensor.h
  87. 4
      APP_Framework/Framework/sensor/temperature/Kconfig
  88. 2
      APP_Framework/Framework/sensor/temperature/Makefile
  89. 0
      APP_Framework/Framework/sensor/temperature/hs300x_temp/Makefile
  90. 36
      APP_Framework/Framework/sensor/temperature/hs300x_temp/hs300x_temp.c
  91. 4
      APP_Framework/Framework/sensor/voice/Kconfig
  92. 2
      APP_Framework/Framework/sensor/voice/Makefile
  93. 0
      APP_Framework/Framework/sensor/voice/d124/Makefile
  94. 43
      APP_Framework/Framework/sensor/voice/d124/d124.c
  95. 127
      APP_Framework/Framework/transform.h
  96. 6
      APP_Framework/Framework/transform_layer/Makefile
  97. 5
      APP_Framework/Framework/transform_layer/xiuos/Makefile
  98. 130
      APP_Framework/Framework/transform_layer/xiuos/transform.c
  99. 77
      APP_Framework/Framework/transform_layer/xiuos/transform.h
  100. 7
      APP_Framework/Framework/transform_layer/xiuos/user_api/Makefile

93
APP_Framework/Applications/Kconfig

@ -0,0 +1,93 @@
menu "Applications"
menu "config stack size and priority of main task"
config MAIN_KTASK_STACK_SIZE
int "Set main task stack size"
default 1024
config MAIN_KTASK_PRIORITY
int
default 4 if KTASK_PRIORITY_8
default 10 if KTASK_PRIORITY_32
default 85 if KTASK_PRIORITY_256
endmenu
menuconfig APPLICATION_SENSOR
bool "Using sensor apps"
default n
select PERCEPTION_SENSORDEVICE
if APPLICATION_SENSOR
menuconfig APPLICATION_SENSOR_CO2
bool "Using sensor CO2 apps"
default n
select PERCEPTION_CO2
if APPLICATION_SENSOR_CO2
config APPLICATION_SENSOR_CO2_ZG09
bool "Using sensor ZG09 apps"
default n
select PERCEPTION_ZG09
endif
menuconfig APPLICATION_SENSOR_PM1_0
bool "Using sensor PM1.0 apps"
default n
select PERCEPTION_PM
if APPLICATION_SENSOR_PM1_0
config APPLICATION_SENSOR_PM1_0_PS5308
bool "Using sensor PS5308 apps"
default n
select PERCEPTION_PS5308
endif
menuconfig APPLICATION_SENSOR_VOICE
bool "Using sensor voice apps"
default n
select PERCEPTION_VOICE
if APPLICATION_SENSOR_VOICE
config APPLICATION_SENSOR_VOICE_D124
bool "Using sensor D124 apps"
default n
select PERCEPTION_D124
endif
menuconfig APPLICATION_SENSOR_HUMIDITY
bool "Using sensor humidity apps"
default n
select PERCEPTION_HUMIDITY
if APPLICATION_SENSOR_HUMIDITY
config APPLICATION_SENSOR_HUMIDITY_HS300X
bool "Using sensor HS300x apps"
default n
select PERCEPTION_HS300X
endif
menuconfig APPLICATION_SENSOR_TEMPERATURE
bool "Using sensor temperature apps"
default n
select PERCEPTION_TEMPERATURE
if APPLICATION_SENSOR_TEMPERATURE
config APPLICATION_SENSOR_TEMPERATURE_HS300X
bool "Using sensor HS300x apps"
default n
select PERCEPTION_HS300X
endif
endif
menuconfig CONNECTION_COMMUNICATION_ZIGBEE
bool "enable zigbee demo"
default n
select CONFIG_CONNECTION_COMMUNICATION_ZIGBEE
if CONNECTION_COMMUNICATION_ZIGBEE
source "$KERNEL_DIR/framework/connection/Adapter/zigbee/Kconfig"
endif
source "$APP_DIR/Applications/app_test/Kconfig"
endmenu

44
APP_Framework/Applications/Makefile

@ -1,5 +1,45 @@
SRC_FILES := main.c
SRC_DIR := general_functions
SRC_FILES := main.c framework_init.c
ifeq ($(CONFIG_RESOURCES_SDIO), y)
SRC_FILES += sd_card_mount.c
endif
ifeq ($(CONFIG_RESOURCES_SPI_SD), y)
SRC_FILES += spi_sd_card_mount.c
endif
ifeq ($(CONFIG_CONNECTION_COMMUNICATION_BOOTSTART_LORA_NET_SAMPLE), y)
SRC_DIR += connection_demo/adhoc_lora_demo
endif
ifeq ($(CONFIG_CONNECTION_COMMUNICATION_ZIGBEE), y)
SRC_DIR += connection_demo/zigbee_demo
endif
ifeq ($(CONFIG_CONNECTION_COMMUNICATION_ETHERNET), y)
SRC_DIR += connection_demo/ethernet_demo
endif
ifeq ($(CONFIG_CONNECTION_COMMUNICATION_WIFI), y)
SRC_DIR += connection_demo/wifi_demo
endif
ifeq ($(CONFIG_CONNECTION_COMMUNICATION_NB_IOT), y)
SRC_DIR += connection_demo/nbiot_demo
endif
# ifeq ($(CONFIG_CONNECTION_COMMUNICATION_4G), y)
# SRC_DIR += connection_demo/4G_demo
# endif
ifeq ($(CONFIG_CONNECTION_COMMUNICATION_BLUETOOTH), y)
SRC_DIR += connection_demo/bluetooth_demo
endif
ifeq ($(CONFIG_APPLICATION_SENSOR),y)
SRC_DIR += sensor_app
endif
include $(KERNEL_ROOT)/compiler.mk

0
Ubiquitous/XiUOS/applications/app_test/Kconfig → APP_Framework/Applications/app_test/Kconfig

0
Ubiquitous/XiUOS/applications/app_test/Makefile → APP_Framework/Applications/app_test/Makefile

0
Ubiquitous/XiUOS/applications/app_test/test_adhoc_lora.c → APP_Framework/Applications/app_test/test_adhoc_lora.c

0
Ubiquitous/XiUOS/applications/app_test/test_spi_flash.c → APP_Framework/Applications/app_test/test_spi_flash.c

0
Ubiquitous/XiUOS/applications/connection_demo/adhoc_lora_demo/Makefile → APP_Framework/Applications/connection_demo/adhoc_lora_demo/Makefile

0
Ubiquitous/XiUOS/applications/connection_demo/adhoc_lora_demo/client.c → APP_Framework/Applications/connection_demo/adhoc_lora_demo/client.c

0
Ubiquitous/XiUOS/applications/connection_demo/adhoc_lora_demo/gateway.c → APP_Framework/Applications/connection_demo/adhoc_lora_demo/gateway.c

0
Ubiquitous/XiUOS/applications/connection_demo/bluetooth_demo/Makefile → APP_Framework/Applications/connection_demo/bluetooth_demo/Makefile

0
Ubiquitous/XiUOS/applications/connection_demo/bluetooth_demo/bluetooth_receive_demo.c → APP_Framework/Applications/connection_demo/bluetooth_demo/bluetooth_receive_demo.c

0
Ubiquitous/XiUOS/applications/connection_demo/bluetooth_demo/bluetooth_send_demo.c → APP_Framework/Applications/connection_demo/bluetooth_demo/bluetooth_send_demo.c

0
Ubiquitous/XiUOS/applications/connection_demo/ethernet_demo/Makefile → APP_Framework/Applications/connection_demo/ethernet_demo/Makefile

0
Ubiquitous/XiUOS/applications/connection_demo/ethernet_demo/ethernet_demo.c → APP_Framework/Applications/connection_demo/ethernet_demo/ethernet_demo.c

0
Ubiquitous/XiUOS/applications/connection_demo/nbiot_demo/Makefile → APP_Framework/Applications/connection_demo/nbiot_demo/Makefile

0
Ubiquitous/XiUOS/applications/connection_demo/nbiot_demo/nbiot_demo.c → APP_Framework/Applications/connection_demo/nbiot_demo/nbiot_demo.c

0
Ubiquitous/XiUOS/applications/connection_demo/wifi_demo/Makefile → APP_Framework/Applications/connection_demo/wifi_demo/Makefile

0
Ubiquitous/XiUOS/applications/connection_demo/wifi_demo/wifi_demo.c → APP_Framework/Applications/connection_demo/wifi_demo/wifi_demo.c

0
Ubiquitous/XiUOS/applications/connection_demo/zigbee_demo/Makefile → APP_Framework/Applications/connection_demo/zigbee_demo/Makefile

0
Ubiquitous/XiUOS/applications/connection_demo/zigbee_demo/zigbee_receive_demo.c → APP_Framework/Applications/connection_demo/zigbee_demo/zigbee_receive_demo.c

0
Ubiquitous/XiUOS/applications/connection_demo/zigbee_demo/zigbee_send_demo.c → APP_Framework/Applications/connection_demo/zigbee_demo/zigbee_send_demo.c

0
Ubiquitous/XiUOS/applications/cppmain.cpp → APP_Framework/Applications/cppmain.cpp

4
Ubiquitous/XiUOS/applications/framework_init.c → APP_Framework/Applications/framework_init.c

@ -50,7 +50,7 @@ static int AppInitDesc(struct InitDesc sub_desc[])
static struct InitDesc framework[] =
{
#ifdef PERCEPTION_SENSORDEVICE
#ifdef SUPPORT_SENSOR_FRAMEWORK
{ "perception_framework", SensorFrameworkInit },
#endif
@ -150,7 +150,7 @@ static int ConnectionFrameworkInit(struct InitDesc sub_desc[])
*/
int FrameworkInit()
{
#ifdef PERCEPTION_SENSORDEVICE
#ifdef SUPPORT_SENSOR_FRAMEWORK
PerceptionFrameworkInit(framework);
#endif

2
APP_Framework/Applications/general_functions/Makefile

@ -1,3 +1,3 @@
SRC_DIR := linklist
SRC_DIR := list
include $(KERNEL_ROOT)/compiler.mk

3
APP_Framework/Applications/general_functions/linklist/Makefile

@ -1,3 +0,0 @@
SRC_FILES := double_linklist.c single_linklist.c
include $(KERNEL_ROOT)/compiler.mk

84
APP_Framework/Applications/general_functions/linklist/double_linklist.c

@ -1,84 +0,0 @@
/*
* 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: double_link.c
* @brief: functions definition of double linklist for application
* @version: 1.0
* @author: AIIT XUOS Lab
* @date: 2020/3/15
*
*/
#include "list.h"
void InitDoubleLinkList(DoubleLinklistType *linklist_head)
{
linklist_head->node_next = linklist_head;
linklist_head->node_prev = linklist_head;
}
void DoubleLinkListInsertNodeAfter(DoubleLinklistType *linklist, DoubleLinklistType *linklist_node)
{
linklist->node_next->node_prev = linklist_node;
linklist_node->node_next = linklist->node_next;
linklist->node_next = linklist_node;
linklist_node->node_prev = linklist;
}
void DoubleLinkListInsertNodeBefore(DoubleLinklistType *linklist, DoubleLinklistType *linklist_node)
{
linklist->node_prev->node_next = linklist_node;
linklist_node->node_prev = linklist->node_prev;
linklist->node_prev = linklist_node;
linklist_node->node_next = linklist;
}
void DoubleLinkListRmNode(DoubleLinklistType *linklist_node)
{
linklist_node->node_next->node_prev = linklist_node->node_prev;
linklist_node->node_prev->node_next = linklist_node->node_next;
linklist_node->node_next = linklist_node;
linklist_node->node_prev = linklist_node;
}
int IsDoubleLinkListEmpty(const DoubleLinklistType *linklist)
{
return linklist->node_next == linklist;
}
struct SysDoubleLinklistNode *DoubleLinkListGetHead(const DoubleLinklistType *linklist)
{
return IsDoubleLinkListEmpty(linklist) ? NULL : linklist->node_next;
}
struct SysDoubleLinklistNode *DoubleLinkListGetNext(const DoubleLinklistType *linklist,
const struct SysDoubleLinklistNode *linklist_node)
{
return linklist_node->node_next == linklist ? NULL : linklist_node->node_next;
}
unsigned int DoubleLinkListLenGet(const DoubleLinklistType *linklist)
{
unsigned int linklist_length = 0;
const DoubleLinklistType *tmp_node = linklist;
while (tmp_node->node_next != linklist)
{
tmp_node = tmp_node->node_next;
linklist_length ++;
}
return linklist_length;
}

129
APP_Framework/Applications/general_functions/linklist/list.h

@ -1,129 +0,0 @@
/*
* 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: xs_klist.h
* @brief: function declaration and structure defintion of linklist
* @version: 1.0
* @author: AIIT XUOS Lab
* @date: 2020/3/2
*
*/
#ifndef __XS_KLIST_H__
#define __XS_KLIST_H__
#include <errno.h>
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#endif
#define LINKLIST_FLAG_FIFO 0x00
#define LINKLIST_FLAG_PRIO 0x01
typedef struct SysDoubleLinklistNode
{
struct SysDoubleLinklistNode *node_next;
struct SysDoubleLinklistNode *node_prev;
} DoubleLinklistType;
// Single List
typedef struct SingleLinklistNode
{
struct SingleLinklistNode *node_next;
} SysSingleLinklistType;
struct CommonMember
{
char name[32];
uint8_t type;
uint8_t flag;
DoubleLinklistType list;
};
#define CONTAINER_OF(item, type, member) \
((type *)((char *)(item) - (unsigned long)(&((type *)0)->member)))
#define DOUBLE_LINKLIST_OBJ_INIT(obj) { &(obj), &(obj) }
void InitDoubleLinkList(DoubleLinklistType *linklist_head);
void DoubleLinkListInsertNodeAfter(DoubleLinklistType *linklist, DoubleLinklistType *linklist_node);
void DoubleLinkListInsertNodeBefore(DoubleLinklistType *linklist, DoubleLinklistType *linklist_node);
void DoubleLinkListRmNode(DoubleLinklistType *linklist_node);
int IsDoubleLinkListEmpty(const DoubleLinklistType *linklist);
struct SysDoubleLinklistNode *DoubleLinkListGetHead(const DoubleLinklistType *linklist);
struct SysDoubleLinklistNode *DoubleLinkListGetNext(const DoubleLinklistType *linklist,
const struct SysDoubleLinklistNode *linklist_node);
unsigned int DoubleLinkListLenGet(const DoubleLinklistType *linklist);
#define SYS_DOUBLE_LINKLIST_ENTRY(item, type, member) \
CONTAINER_OF(item, type, member)
#define DOUBLE_LINKLIST_FOR_EACH(item, head) \
for (item = (head)->node_next; item != (head); item = item->node_next)
#define DOUBLE_LINKLIST_FOR_EACH_SAFE(item, node_next, head) \
for (item = (head)->node_next, node_next = item->node_next; item != (head); \
item = node_next, node_next = item->node_next)
#define DOUBLE_LINKLIST_FOR_EACH_ENTRY(item, head, member) \
for (item = SYS_DOUBLE_LINKLIST_ENTRY((head)->node_next, typeof(*item), member); \
&item->member != (head); \
item = SYS_DOUBLE_LINKLIST_ENTRY(item->member.node_next, typeof(*item), member))
#define DOUBLE_LINKLIST_FOR_EACH_ENTRY_SAFE(item, node_next, head, member) \
for (item = SYS_DOUBLE_LINKLIST_ENTRY((head)->node_next, typeof(*item), member), \
node_next = SYS_DOUBLE_LINKLIST_ENTRY(item->member.node_next, typeof(*item), member); \
&item->member != (head); \
item = node_next, node_next = SYS_DOUBLE_LINKLIST_ENTRY(node_next->member.node_next, typeof(*node_next), member))
#define DOUBLE_LINKLIST_FIRST_ENTRY(ptr, type, member) \
SYS_DOUBLE_LINKLIST_ENTRY((ptr)->node_next, type, member)
#define SYS_SINGLE_LINKLIST_OBJ_INIT(obj) { NONE }
void InitSingleLinkList(SysSingleLinklistType *linklist);
void AppendSingleLinkList(SysSingleLinklistType *linklist, SysSingleLinklistType *linklist_node);
void SingleLinkListNodeInsert(SysSingleLinklistType *linklist, SysSingleLinklistType *linklist_node);
unsigned int SingleLinkListGetLen(const SysSingleLinklistType *linklist);
SysSingleLinklistType *SingleLinkListRmNode(SysSingleLinklistType *linklist, SysSingleLinklistType *linklist_node);
SysSingleLinklistType *SingleLinkListGetFirstNode(SysSingleLinklistType *linklist);
SysSingleLinklistType *SingleLinkListGetTailNode(SysSingleLinklistType *linklist);
SysSingleLinklistType *SingleLinkListGetNextNode(SysSingleLinklistType *linklist_node);
int IsSingleLinkListEmpty(SysSingleLinklistType *linklist);
#define SYS_SINGLE_LINKLIST_ENTRY(node, type, member) \
CONTAINER_OF(node, type, member)
#define SINGLE_LINKLIST_FOR_EACH(item, head) \
for (item = (head)->node_next; item != NONE; item = item->node_next)
#define SINGLE_LINKLIST_FOR_EACH_ENTRY(item, head, member) \
for (item = SYS_SINGLE_LINKLIST_ENTRY((head)->node_next, typeof(*item), member); \
&item->member != (NONE); \
item = SYS_SINGLE_LINKLIST_ENTRY(item->member.node_next, typeof(*item), member))
#define SINGLE_LINKLIST_FIRST_ENTRY(ptr, type, member) \
SYS_SINGLE_LINKLIST_ENTRY((ptr)->node_next, type, member)
#define SINGLE_LINKLIST_TAIL_ENTRY(ptr, type, member) \
SYS_SINGLE_LINKLIST_ENTRY(SingleLinkListGetTailNode(ptr), type, member)
#ifdef __cplusplus
}
#endif
#endif

91
APP_Framework/Applications/general_functions/linklist/single_linklist.c

@ -1,91 +0,0 @@
/*
* 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: double_link.c
* @brief: functions definition of single linklist for application
* @version: 1.0
* @author: AIIT XUOS Lab
* @date: 2020/3/15
*
*/
#include "list.h"
void InitSingleLinkList(SysSingleLinklistType *linklist)
{
linklist->node_next = NULL;
}
void AppendSingleLinkList(SysSingleLinklistType *linklist, SysSingleLinklistType *linklist_node)
{
struct SingleLinklistNode *node;
node = linklist;
while (node->node_next) node = node->node_next;
node->node_next = linklist_node;
linklist_node->node_next = NULL;
}
void SingleLinkListNodeInsert(SysSingleLinklistType *linklist, SysSingleLinklistType *linklist_node)
{
linklist_node->node_next = linklist->node_next;
linklist->node_next = linklist_node;
}
unsigned int SingleLinkListGetLen(const SysSingleLinklistType *linklist)
{
unsigned int length = 0;
const SysSingleLinklistType *tmp_list = linklist->node_next;
while (tmp_list != NULL)
{
tmp_list = tmp_list->node_next;
length ++;
}
return length;
}
SysSingleLinklistType *SingleLinkListRmNode(SysSingleLinklistType *linklist, SysSingleLinklistType *linklist_node)
{
struct SingleLinklistNode *node = linklist;
while (node->node_next && node->node_next != linklist_node) node = node->node_next;
if (node->node_next != (SysSingleLinklistType *)0){
node->node_next = node->node_next->node_next;
}
return linklist;
}
SysSingleLinklistType *SingleLinkListGetFirstNode(SysSingleLinklistType *linklist)
{
return linklist->node_next;
}
SysSingleLinklistType *SingleLinkListGetTailNode(SysSingleLinklistType *linklist)
{
while (linklist->node_next) linklist = linklist->node_next;
return linklist;
}
SysSingleLinklistType *SingleLinkListGetNextNode(SysSingleLinklistType *linklist_node)
{
return linklist_node->node_next;
}
int IsSingleLinkListEmpty(SysSingleLinklistType *linklist)
{
return linklist->node_next == NULL;
}

3
APP_Framework/Applications/general_functions/list/Makefile

@ -0,0 +1,3 @@
SRC_FILES := double_list.c single_list.c
include $(KERNEL_ROOT)/compiler.mk

84
APP_Framework/Applications/general_functions/list/double_list.c

@ -0,0 +1,84 @@
/*
* 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: double_link.c
* @brief: functions definition of double list for application
* @version: 1.0
* @author: AIIT XUOS Lab
* @date: 2020/3/15
*
*/
#include "list.h"
void AppInitDoubleList(DoublelistType *list_head)
{
list_head->node_next = list_head;
list_head->node_prev = list_head;
}
void AppDoubleListInsertNodeAfter(DoublelistType *list, DoublelistType *list_node)
{
list->node_next->node_prev = list_node;
list_node->node_next = list->node_next;
list->node_next = list_node;
list_node->node_prev = list;
}
void AppDoubleListInsertNodeBefore(DoublelistType *list, DoublelistType *list_node)
{
list->node_prev->node_next = list_node;
list_node->node_prev = list->node_prev;
list->node_prev = list_node;
list_node->node_next = list;
}
void AppDoubleListRmNode(DoublelistType *list_node)
{
list_node->node_next->node_prev = list_node->node_prev;
list_node->node_prev->node_next = list_node->node_next;
list_node->node_next = list_node;
list_node->node_prev = list_node;
}
int AppIsDoubleListEmpty(const DoublelistType *list)
{
return list->node_next == list;
}
struct DoublelistNode *AppDoubleListGetHead(const DoublelistType *list)
{
return AppIsDoubleListEmpty(list) ? NULL : list->node_next;
}
struct DoublelistNode *AppDoubleListGetNext(const DoublelistType *list,
const struct DoublelistNode *list_node)
{
return list_node->node_next == list ? NULL : list_node->node_next;
}
unsigned int AppDoubleListLenGet(const DoublelistType *list)
{
unsigned int linklist_length = 0;
const DoublelistType *tmp_node = list;
while (tmp_node->node_next != list)
{
tmp_node = tmp_node->node_next;
linklist_length ++;
}
return linklist_length;
}

118
APP_Framework/Applications/general_functions/list/list.h

@ -0,0 +1,118 @@
/*
* 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: xs_klist.h
* @brief: function declaration and structure defintion of list
* @version: 1.0
* @author: AIIT XUOS Lab
* @date: 2020/3/2
*
*/
#ifndef __LIST_H__
#define __LIST_H__
#include "libc.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef struct DoublelistNode
{
struct DoublelistNode *node_next;
struct DoublelistNode *node_prev;
} DoublelistType;
// Single List
typedef struct SinglelistNode
{
struct SinglelistNode *node_next;
} SinglelistType;
#define CONTAINER_OF(item, type, member) \
((type *)((char *)(item) - (unsigned long)(&((type *)0)->member)))
#define DOUBLE_LIST_OBJ_INIT(obj) { &(obj), &(obj) }
void AppInitDoubleList(DoublelistType *linklist_head);
void AppDoubleListInsertNodeAfter(DoublelistType *list, DoublelistType *list_node);
void AppDoubleListInsertNodeBefore(DoublelistType *list, DoublelistType *list_node);
void AppDoubleListRmNode(DoublelistType *list_node);
int AppIsDoubleListEmpty(const DoublelistType *list);
struct DoublelistNode *AppDoubleLinkListGetHead(const DoublelistType *list);
struct DoublelistNode *AppDoubleLinkListGetNext(const DoublelistType *list,
const struct DoublelistNode *list_node);
unsigned int AppDoubleListLenGet(const DoublelistType *list);
#define DOUBLE_LIST_ENTRY(item, type, member) \
CONTAINER_OF(item, type, member)
#define DOUBLE_LIST_FOR_EACH(item, head) \
for (item = (head)->node_next; item != (head); item = item->node_next)
#define DOUBLE_LIST_FOR_EACH_SAFE(item, node_next, head) \
for (item = (head)->node_next, node_next = item->node_next; item != (head); \
item = node_next, node_next = item->node_next)
#define DOUBLE_LIST_FOR_EACH_ENTRY(item, head, member) \
for (item = DOUBLE_LIST_ENTRY((head)->node_next, typeof(*item), member); \
&item->member != (head); \
item = DOUBLE_LIST_ENTRY(item->member.node_next, typeof(*item), member))
#define DOUBLE_LIST_FOR_EACH_ENTRY_SAFE(item, node_next, head, member) \
for (item = DOUBLE_LIST_ENTRY((head)->node_next, typeof(*item), member), \
node_next = DOUBLE_LIST_ENTRY(item->member.node_next, typeof(*item), member); \
&item->member != (head); \
item = node_next, node_next = DOUBLE_LIST_ENTRY(node_next->member.node_next, typeof(*node_next), member))
#define DOUBLE_LIST_FIRST_ENTRY(ptr, type, member) \
DOUBLE_LIST_ENTRY((ptr)->node_next, type, member)
#define SINGLE_LIST_OBJ_INIT(obj) { NONE }
void AppInitSingleList(SinglelistType *list);
void AppAppendSingleList(SinglelistType *list, SinglelistType *list_node);
void AppSingleListNodeInsert(SinglelistType *list, SinglelistType *list_node);
unsigned int AppSingleListGetLen(const SinglelistType *list);
SinglelistType *AppSingleListRmNode(SinglelistType *list, SinglelistType *list_node);
SinglelistType *AppSingleListGetFirstNode(SinglelistType *list);
SinglelistType *AppSingleListGetTailNode(SinglelistType *list);
SinglelistType *AppSingleListGetNextNode(SinglelistType *list_node);
int AppIsSingleListEmpty(SinglelistType *list);
#define SINGLE_LIST_ENTRY(node, type, member) \
CONTAINER_OF(node, type, member)
#define SINGLE_LIST_FOR_EACH(item, head) \
for (item = (head)->node_next; item != NONE; item = item->node_next)
#define SINGLE_LIST_FOR_EACH_ENTRY(item, head, member) \
for (item = SINGLE_LIST_ENTRY((head)->node_next, typeof(*item), member); \
&item->member != (NONE); \
item = SINGLE_LIST_ENTRY(item->member.node_next, typeof(*item), member))
#define SINGLE_LIST_FIRST_ENTRY(ptr, type, member) \
SINGLE_LIST_ENTRY((ptr)->node_next, type, member)
#define SINGLE_LIST_TAIL_ENTRY(ptr, type, member) \
SINGLE_LIST_ENTRY(AppSingleListGetTailNode(ptr), type, member)
#ifdef __cplusplus
}
#endif
#endif

91
APP_Framework/Applications/general_functions/list/single_list.c

@ -0,0 +1,91 @@
/*
* 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: double_link.c
* @brief: functions definition of single list for application
* @version: 1.0
* @author: AIIT XUOS Lab
* @date: 2020/3/15
*
*/
#include "list.h"
void AppInitSingleList(SinglelistType *list)
{
list->node_next = NULL;
}
void AppAppendSingleList(SinglelistType *list, SinglelistType *list_node)
{
struct SinglelistNode *node;
node = list;
while (node->node_next) node = node->node_next;
node->node_next = list_node;
list_node->node_next = NULL;
}
void AppSingleListNodeInsert(SinglelistType *list, SinglelistType *list_node)
{
list_node->node_next = list->node_next;
list->node_next = list_node;
}
unsigned int AppSingleListGetLen(const SinglelistType *list)
{
unsigned int length = 0;
const SinglelistType *tmp_list = list->node_next;
while (tmp_list != NULL)
{
tmp_list = tmp_list->node_next;
length ++;
}
return length;
}
SinglelistType *AppSingleListRmNode(SinglelistType *list, SinglelistType *list_node)
{
struct SinglelistNode *node = list;
while (node->node_next && node->node_next != list_node) node = node->node_next;
if (node->node_next != (SinglelistType *)0){
node->node_next = node->node_next->node_next;
}
return list;
}
SinglelistType *AppSingleListGetFirstNode(SinglelistType *list)
{
return list->node_next;
}
SinglelistType *AppSingleListGetTailNode(SinglelistType *list)
{
while (list->node_next) list = list->node_next;
return list;
}
SinglelistType *AppSingleListGetNextNode(SinglelistType *list_node)
{
return list_node->node_next;
}
int AppIsSingleListEmpty(SinglelistType *list)
{
return list->node_next == NULL;
}

8
APP_Framework/Applications/main.c

@ -12,8 +12,16 @@
#include <stdio.h>
#include <string.h>
#include <user_api.h>
extern int FrameworkInit();
int main(void)
{
printf("Hello, world!\n");
FrameworkInit();
return 0;
}
// int cppmain(void);

0
Ubiquitous/XiUOS/applications/sd_card_mount.c → APP_Framework/Applications/sd_card_mount.c

0
Ubiquitous/XiUOS/applications/sensor_app/Makefile → APP_Framework/Applications/sensor_app/Makefile

0
Ubiquitous/XiUOS/applications/sensor_app/co2_zg09.c → APP_Framework/Applications/sensor_app/co2_zg09.c

0
Ubiquitous/XiUOS/applications/sensor_app/humidity_hs300x.c → APP_Framework/Applications/sensor_app/humidity_hs300x.c

0
Ubiquitous/XiUOS/applications/sensor_app/pm1_0_ps5308.c → APP_Framework/Applications/sensor_app/pm1_0_ps5308.c

0
Ubiquitous/XiUOS/applications/sensor_app/temperature_hs300x.c → APP_Framework/Applications/sensor_app/temperature_hs300x.c

0
Ubiquitous/XiUOS/applications/sensor_app/voice_d124.c → APP_Framework/Applications/sensor_app/voice_d124.c

0
Ubiquitous/XiUOS/applications/spi_sd_card_mount.c → APP_Framework/Applications/spi_sd_card_mount.c

22
APP_Framework/Framework/Kconfig

@ -0,0 +1,22 @@
config TRANSFORM_LAYER_ATTRIUBUTE
bool "support transform layer"
default y
choice
prompt "select os features"
default ADD_XIUOS_FETURES
config ADD_XIUOS_FETURES
bool "add xiuos fetures"
config ADD_NUTTX_FETURES
bool "add nuttx fetures"
config ADD_RTTHREAD_FETURES
bool "add rt_thread fetures"
endchoice
source "$APP_DIR/Framework/sensor/Kconfig"
source "$APP_DIR/Framework/connection/Kconfig"
source "$APP_DIR/Framework/know/tflite_sin/Kconfig"
source "$APP_DIR/Framework/know/tflite_mnist/Kconfig"

10
APP_Framework/Framework/Makefile

@ -1,4 +1,12 @@
SRC_DIR := sensor transform_layer
SRC_DIR := transform_layer
ifeq ($(CONFIG_SUPPORT_SENSOR_FRAMEWORK),y)
SRC_DIR += sensor
endif
ifeq ($(CONFIG_SUPPORT_CONNECTION_FRAMEWORK),y)
SRC_DIR += connection
endif
include $(KERNEL_ROOT)/compiler.mk

3
APP_Framework/Framework/connection/Kconfig

@ -0,0 +1,3 @@
menuconfig SUPPORT_CONNECTION_FRAMEWORK
bool "support connection framework"
default n

3
APP_Framework/Framework/connection/Makefile

@ -0,0 +1,3 @@
SRC_FILES := adapter.c
include $(KERNEL_ROOT)/compiler.mk

310
APP_Framework/Framework/connection/adapter.c

@ -0,0 +1,310 @@
/*
* 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 adapter.c
* @brief Implement the communication adapter framework management and API
* @version 1.0
* @author AIIT XUOS Lab
* @date 2021.05.10
*/
#include <adapter.h>
static DoublelistType adapter_list;
static int adapter_list_lock;
/**
* @description: Init adapter framework
* @return 0
*/
int AdapterFrameworkInit(void)
{
int ret = 0;
AppInitDoubleList(&adapter_list);
ret = PrivMutexCreate(&adapter_list_lock, 0);
if(ret < 0) {
printf("AdapterFrameworkInit mutex create failed.\n");
}
return 0;
}
/**
* @description: Find adapter device by name
* @param name - name string
* @return adapter device pointer
*/
struct Adapter *AdapterDeviceFindByName(const char *name)
{
struct Adapter *ret = NULL;
struct DoublelistNode *node;
if (NULL == name)
return NULL;
PrivMutexObtain(&adapter_list_lock);
DOUBLE_LIST_FOR_EACH(node, &adapter_list) {
struct Adapter *adapter = CONTAINER_OF(node,
struct Adapter, link);
if (0 == strncmp(adapter->name, name, NAME_NUM_MAX)) {
ret = adapter;
break;
}
}
PrivMutexAbandon(&adapter_list_lock);
return ret;
}
/**
* @description: Register the adapter to the linked list
* @param adapter - adapter device pointer
* @return success: 0 , failure: -1
*/
int AdapterDeviceRegister(struct Adapter *adapter)
{
if (NULL == adapter )
return -1;
if (NULL != AdapterDeviceFindByName(adapter->name)) {
printf("%s: sensor with the same name already registered\n", __func__);
return -1;
}
PrivMutexObtain(&adapter_list_lock);
AppDoubleListInsertNodeAfter(&adapter_list, &adapter->link);
PrivMutexAbandon(&adapter_list_lock);
return 0;
}
/**
* @description: Unregister the adapter from the linked list
* @param adapter - adapter device pointer
* @return 0
*/
int AdapterDeviceUnregister(struct Adapter *adapter)
{
if (!adapter)
return -1;
PrivMutexObtain(&adapter_list_lock);
AppDoubleListRmNode(&adapter->link);
PrivMutexAbandon(&adapter_list_lock);
return 0;
}
/**
* @description: Open adapter device
* @param adapter - adapter device pointer
* @return success: 0 , failure: other
*/
int AdapterDeviceOpen(struct Adapter *adapter)
{
if (!adapter)
return -1;
int result = 0;
struct IpProtocolDone *ip_done = NULL;
struct PrivProtocolDone *priv_done = NULL;
switch (adapter->net_protocol)
{
case PRIVATE_PROTOCOL:
priv_done = (struct PrivProtocolDone *)adapter->done;
if (NULL == priv_done->open)
return 0;
result = priv_done->open(adapter);
if (0 == result) {
printf("Device %s open success.\n", adapter->name);
}else{
if (adapter->fd) {
PrivClose(adapter->fd);
adapter->fd = 0;
}
printf("Device %s open failed(%d).\n", adapter->name, result);
}
break;
case IP_PROTOCOL:
ip_done = (struct IpProtocolDone *)adapter->done;
if (NULL == ip_done->open)
return 0;
result = ip_done->open(adapter);
if (0 == result) {
printf("Device %s open success.\n", adapter->name);
}else{
if (adapter->fd) {
PrivClose(adapter->fd);
adapter->fd = 0;
}
printf("Device %s open failed(%d).\n", adapter->name, result);
}
break;
default:
break;
}
return result;
}
/**
* @description: Close adapter device
* @param adapter - adapter device pointer
* @return success: 0 , failure: other
*/
int AdapterDeviceClose(struct Adapter *adapter)
{
if (!adapter)
return -1;
int result = 0;
struct IpProtocolDone *ip_done = NULL;
struct PrivProtocolDone *priv_done = NULL;
switch (adapter->net_protocol)
{
case PRIVATE_PROTOCOL:
priv_done = (struct PrivProtocolDone *)adapter->done;
if (NULL == priv_done->close)
return 0;
result = priv_done->close(adapter);
if (0 == result)
printf("%s successfully closed.\n", adapter->name);
else
printf("Closed %s failure.\n", adapter->name);
break;
case IP_PROTOCOL:
ip_done = (struct IpProtocolDone *)adapter->done;
if (NULL == ip_done->close)
return 0;
result = ip_done->close(adapter);
if (0 == result)
printf("%s successfully closed.\n", adapter->name);
else
printf("Closed %s failure.\n", adapter->name);
break;
default:
break;
}
return result;
}
/**
* @description: Read data from adapter
* @param adapter - adapter device pointer
* @param dst - buffer to save data
* @param len - buffer length
* @return gotten data length
*/
ssize_t AdapterDeviceRead(struct Adapter *adapter, void *dst, size_t len)
{
if (!adapter)
return -1;
if (PRIVATE_PROTOCOL == adapter->net_protocol) {
struct PrivProtocolDone *priv_done = (struct PrivProtocolDone *)adapter->done;
if (NULL == priv_done->recv)
return -1;
return priv_done->recv(adapter, dst, len);
} else if (IP_PROTOCOL == adapter->net_protocol) {
struct IpProtocolDone *ip_done = (struct IpProtocolDone *)adapter->done;
if (NULL == ip_done->recv)
return -1;
return ip_done->recv(adapter->socket, dst, len);
} else {
printf("AdapterDeviceRead net_protocol %d not support\n", adapter->net_protocol);
return -1;
}
}
/**
* @description: Write data to adapter
* @param adapter - adapter device pointer
* @param src - data buffer
* @param len - data length
* @return length of data written
*/
ssize_t AdapterDeviceWrite(struct Adapter *adapter, const void *src, size_t len)
{
if (!adapter)
return -1;
if (PRIVATE_PROTOCOL == adapter->net_protocol) {
struct PrivProtocolDone *priv_done = (struct PrivProtocolDone *)adapter->done;
if (NULL == priv_done->send)
return -1;
return priv_done->send(adapter, src, len);
} else if (IP_PROTOCOL == adapter->net_protocol) {
struct IpProtocolDone *ip_done = (struct IpProtocolDone *)adapter->done;
if (NULL == ip_done->send)
return -1;
return ip_done->send(adapter->socket, src, len);
} else {
printf("AdapterDeviceWrite net_protocol %d not support\n", adapter->net_protocol);
return -1;
}
}
/**
* @description: Configure adapter
* @param adapter - adapter device pointer
* @param cmd - command
* @param args - command parameter
* @return success: 0 , failure: other
*/
int AdapterDeviceControl(struct Adapter *adapter, int cmd, void *args)
{
if (!adapter)
return -1;
if (PRIVATE_PROTOCOL == adapter->net_protocol) {
struct PrivProtocolDone *priv_done = (struct PrivProtocolDone *)adapter->done;
if (NULL == priv_done->ioctl)
return -1;
return priv_done->ioctl(adapter, cmd, args);
} else if (IP_PROTOCOL == adapter->net_protocol) {
struct IpProtocolDone *ip_done = (struct IpProtocolDone *)adapter->done;
if (NULL == ip_done->ioctl)
return -1;
return ip_done->ioctl(adapter, cmd, args);
} else {
printf("AdapterDeviceControl net_protocol %d not support\n", adapter->net_protocol);
return -1;
}
}

123
APP_Framework/Framework/connection/adapter.h

@ -0,0 +1,123 @@
/*
* 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 adapter.h
* @brief Structure and function declarations of the communication adapter framework
* @version 1.0
* @author AIIT XUOS Lab
* @date 2021.05.10
*/
#ifndef ADAPTER_H
#define ADAPTER_H
#include <list.h>
#include <transform.h>
#include <stdio.h>
#include <string.h>
#include <stdint.h>
#include <sys/types.h>
#define ADAPTER_BUFFSIZE 64
#define ADAPTER_LORA_FUNC ((uint32_t)(1 << ATAPTER_LORA))
#define ADAPTER_4G_FUNC ((uint32_t)(1 << ADAPTER_4G))
#define ADAPTER_NBIOT_FUNC ((uint32_t)(1 << ADAPTER_NBIOT))
#define ADAPTER_WIFI_FUNC ((uint32_t)(1 << ADAPTER_WIFI))
#define ADAPTER_ETHERNET_FUNC ((uint32_t)(1 << ADAPTER_ETHERNET))
#define ADAPTER_BLUETOOTH_FUNC ((uint32_t)(1 << ADAPTER_BLUETOOTH))
#define ADAPTER_ZIGBEE_FUNC ((uint32_t)(1 << ADAPTER_ZIGBEE))
#define ADAPTER_5G_FUNC ((uint32_t)(1 << ADAPTER_5G))
struct Adapter;
struct Socket
{
int id;
struct Adapter *adapter;
};
enum AdapterType
{
ADAPTER_LORA = 0,
ADAPTER_4G ,
ADAPTER_NBIOT ,
ADAPTER_WIFI ,
ADAPTER_ETHERNET ,
ADAPTER_BLUETOOTH ,
ADAPTER_ZIGBEE ,
ADAPTER_5G ,
};
enum NetProtocolType
{
PRIVATE_PROTOCOL = 1,
IP_PROTOCOL,
PROTOCOL_NONE,
};
enum NetRoleType
{
CLIENT = 1,
SERVER,
ROLE_NONE,
};
struct AdapterProductInfo
{
uint32_t functions;
const char *vendor_name;
const char *model_name;
};
struct IpProtocolDone
{
int (*open)(struct Adapter *adapter);
int (*close)(struct Adapter *adapter);
int (*ioctl)(struct Adapter *adapter, int cmd, void *args);
int (*connect)(struct Adapter *adapter, const char *ip, const char *port, uint8_t ip_type);
int (*send)(struct Socket *socket, const void *buf, size_t len);
int (*recv)(struct Socket *socket, void *buf, size_t len);
int (*disconnect)(struct Socket *socket);
};
struct PrivProtocolDone
{
int (*open)(struct Adapter *adapter);
int (*close)(struct Adapter *adapter);
int (*ioctl)(struct Adapter *adapter, int cmd, void *args);
int (*join)(struct Adapter *adapter, const char *priv_net_group);
int (*send)(struct Adapter *adapter, const void *buf, size_t len);
int (*recv)(struct Adapter *adapter, void *buf, size_t len);
int (*disconnect)(struct Adapter *adapter);
};
struct Adapter
{
char *name;
int fd;
struct AdapterProductInfo *info;
struct Socket *socket;
enum NetProtocolType net_protocol;
enum NetRoleType net_role;
char buffer[ADAPTER_BUFFSIZE];
void *done;
struct DoublelistNode link;
};
#endif

0
Ubiquitous/XiUOS/applications/tflite_mnist/.gitignore → APP_Framework/Framework/know/tflite_mnist/.gitignore

0
Ubiquitous/XiUOS/applications/tflite_mnist/Kconfig → APP_Framework/Framework/know/tflite_mnist/Kconfig

0
Ubiquitous/XiUOS/applications/tflite_mnist/Makefile → APP_Framework/Framework/know/tflite_mnist/Makefile

0
Ubiquitous/XiUOS/applications/tflite_mnist/README.md → APP_Framework/Framework/know/tflite_mnist/README.md

0
Ubiquitous/XiUOS/applications/tflite_mnist/digit.h → APP_Framework/Framework/know/tflite_mnist/digit.h

0
Ubiquitous/XiUOS/applications/tflite_mnist/mnistapp.cpp → APP_Framework/Framework/know/tflite_mnist/mnistapp.cpp

0
Ubiquitous/XiUOS/applications/tflite_mnist/mnistmain.c → APP_Framework/Framework/know/tflite_mnist/mnistmain.c

0
Ubiquitous/XiUOS/applications/tflite_mnist/model.h → APP_Framework/Framework/know/tflite_mnist/model.h

0
Ubiquitous/XiUOS/applications/tflite_mnist/tools/mnist-c-digit.py → APP_Framework/Framework/know/tflite_mnist/tools/mnist-c-digit.py

0
Ubiquitous/XiUOS/applications/tflite_mnist/tools/mnist-c-model.py → APP_Framework/Framework/know/tflite_mnist/tools/mnist-c-model.py

0
Ubiquitous/XiUOS/applications/tflite_mnist/tools/mnist-inference.py → APP_Framework/Framework/know/tflite_mnist/tools/mnist-inference.py

0
Ubiquitous/XiUOS/applications/tflite_mnist/tools/mnist-train.py → APP_Framework/Framework/know/tflite_mnist/tools/mnist-train.py

0
Ubiquitous/XiUOS/applications/tflite_sin/Kconfig → APP_Framework/Framework/know/tflite_sin/Kconfig

0
Ubiquitous/XiUOS/applications/tflite_sin/Makefile → APP_Framework/Framework/know/tflite_sin/Makefile

0
Ubiquitous/XiUOS/applications/tflite_sin/constants.cc → APP_Framework/Framework/know/tflite_sin/constants.cc

0
Ubiquitous/XiUOS/applications/tflite_sin/constants.h → APP_Framework/Framework/know/tflite_sin/constants.h

0
Ubiquitous/XiUOS/applications/tflite_sin/main_functions.cc → APP_Framework/Framework/know/tflite_sin/main_functions.cc

0
Ubiquitous/XiUOS/applications/tflite_sin/main_functions.h → APP_Framework/Framework/know/tflite_sin/main_functions.h

0
Ubiquitous/XiUOS/applications/tflite_sin/model.cc → APP_Framework/Framework/know/tflite_sin/model.cc

0
Ubiquitous/XiUOS/applications/tflite_sin/model.h → APP_Framework/Framework/know/tflite_sin/model.h

0
Ubiquitous/XiUOS/applications/tflite_sin/output_handler.cc → APP_Framework/Framework/know/tflite_sin/output_handler.cc

0
Ubiquitous/XiUOS/applications/tflite_sin/output_handler.h → APP_Framework/Framework/know/tflite_sin/output_handler.h

0
Ubiquitous/XiUOS/applications/tflite_sin/sinmain.c → APP_Framework/Framework/know/tflite_sin/sinmain.c

40
APP_Framework/Framework/sensor/Kconfig

@ -0,0 +1,40 @@
menuconfig SUPPORT_SENSOR_FRAMEWORK
bool "support sensor framework"
default y
if SUPPORT_SENSOR_FRAMEWORK
menuconfig SENSOR_CO2
bool "Using CO2 sensor device"
default n
if SENSOR_CO2
source "$APP_DIR/Framework/sensor/co2/Kconfig"
endif
menuconfig SENSOR_PM
bool "Using PM sensor device"
default n
if SENSOR_PM
source "$APP_DIR/Framework/sensor/pm/Kconfig"
endif
menuconfig SENSOR_VOICE
bool "Using voice sensor device"
default n
if SENSOR_VOICE
source "$APP_DIR/Framework/sensor/voice/Kconfig"
endif
menuconfig SENSOR_TEMPERATURE
bool "Using temperature sensor device"
default n
if SENSOR_TEMPERATURE
source "$APP_DIR/Framework/sensor/temperature/Kconfig"
endif
menuconfig SENSOR_HUMIDITY
bool "Using humidity sensor device"
default n
if SENSOR_HUMIDITY
source "$APP_DIR/Framework/sensor/humidity/Kconfig"
endif
endif

22
APP_Framework/Framework/sensor/Makefile

@ -1,3 +1,23 @@
SRC_FILES := sensor.c
include $(KERNEL_ROOT)/compiler.mk
ifeq ($(CONFIG_SENSOR_CO2),y)
SRC_DIR += co2
endif
ifeq ($(CONFIG_SENSOR_PM),y)
SRC_DIR += pm
endif
ifeq ($(CONFIG_SENSOR_VOICE),y)
SRC_DIR += voice
endif
ifeq ($(CONFIG_SENSOR_TEMPERATURE),y)
SRC_DIR += temperature
endif
ifeq ($(CONFIG_SENSOR_HUMIDITY),y)
SRC_DIR += humidity
endif
include $(KERNEL_ROOT)/compiler.mk

4
Ubiquitous/XiUOS/framework/perception/co2/Kconfig → APP_Framework/Framework/sensor/co2/Kconfig

@ -1,9 +1,9 @@
config PERCEPTION_ZG09
config SENSOR_ZG09
bool "Using zg09"
default n
if PERCEPTION_ZG09
if SENSOR_ZG09
config SENSOR_DEVICE_ZG09
string "zg09 sensor name"
default "zg09_1"

2
Ubiquitous/XiUOS/framework/perception/co2/Makefile → APP_Framework/Framework/sensor/co2/Makefile

@ -1,4 +1,4 @@
ifeq ($(CONFIG_PERCEPTION_ZG09),y)
ifeq ($(CONFIG_SENSOR_ZG09),y)
SRC_DIR += zg09
endif

0
Ubiquitous/XiUOS/framework/perception/co2/zg09/Makefile → APP_Framework/Framework/sensor/co2/zg09/Makefile

61
Ubiquitous/XiUOS/framework/perception/co2/zg09/zg09.c → APP_Framework/Framework/sensor/co2/zg09/zg09.c

@ -20,9 +20,9 @@
#include <sensor.h>
static uint8 zg09_set_passive[8]={0xFE, 0x06, 0x00, 0x05, 0x00, 0x00, 0x8D, 0xC4};
static uint8 zg09_set_active[8]={0xFE, 0x06, 0x00, 0x05, 0x00, 0x01, 0x4C, 0x04};
static uint8 zg09_read_instruction[8]={0xFE, 0x03, 0x00, 0x0B, 0x00, 0x01, 0xE1, 0xC7};
static uint8_t zg09_set_passive[8]={0xFE, 0x06, 0x00, 0x05, 0x00, 0x00, 0x8D, 0xC4};
static uint8_t zg09_set_active[8]={0xFE, 0x06, 0x00, 0x05, 0x00, 0x01, 0x4C, 0x04};
static uint8_t zg09_read_instruction[8]={0xFE, 0x03, 0x00, 0x0B, 0x00, 0x01, 0xE1, 0xC7};
static struct SensorDevice zg09;
@ -36,13 +36,13 @@ static struct SensorProductInfo info =
/**
* @description: Open ZG09 sensor device
* @param sdev - sensor device pointer