Merge branch 'prepare_for_master' of https://www.gitlink.org.cn/xuos/xiuos into 2023_open

This commit is contained in:
Liu_Weichao
2023-11-01 16:22:01 +08:00
194 changed files with 18573 additions and 2564 deletions

View File

@@ -46,7 +46,12 @@ ifeq ($(CONFIG_ADD_XIZI_FEATURES),y)
endif
ifeq ($(CONFIG_USER_TEST_I2C),y)
SRC_FILES += test_i2c.c
ifeq ($(CONFIG_BOARD_EDU_RISCV64_EVB),y)
SRC_FILES += test_i2c_riscv.c
endif
ifeq ($(CONFIG_BOARD_EDU_ARM32_EVB),y)
SRC_FILES += test_i2c_arm.c
endif
endif
ifeq ($(CONFIG_USER_TEST_UART),y)
@@ -66,7 +71,12 @@ ifeq ($(CONFIG_ADD_XIZI_FEATURES),y)
endif
ifeq ($(CONFIG_USER_TEST_RS485),y)
SRC_FILES += test_rs485.c
ifeq ($(CONFIG_BOARD_EDU_RISCV64_EVB),y)
SRC_FILES += test_rs485_riscv.c
endif
ifeq ($(CONFIG_BOARD_EDU_ARM32_EVB),y)
SRC_FILES += test_rs485_arm.c
endif
endif
ifeq ($(CONFIG_USER_TEST_HWTIMER),y)

View File

@@ -22,7 +22,7 @@
#include <transform.h>
#ifdef ADD_XIZI_FEATURES
#define BSP_LED_PIN 134
#define BSP_LED_PIN 29
#define NULL_PARAMETER 0
static uint16_t pin_fd=0;
@@ -37,7 +37,7 @@ void LedFlip(void *parameter)
void TestHwTimer(void)
{
x_ticks_t period = 100000;
x_ticks_t period = 1;
pin_fd = PrivOpen(HWTIMER_PIN_DEV_DRIVER, O_RDWR);
if(pin_fd<0) {

View File

@@ -0,0 +1,81 @@
/*
* 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: test_i2c.c
* @brief: a application of i2c function
* @version: 1.1
* @author: AIIT XUOS Lab
* @date: 2022/12/17
*/
#include <stdio.h>
#include <string.h>
#include <transform.h>
#include <sleep.h>
#ifdef ADD_XIZI_FEATURES
#define I2C_SLAVE_ADDRESS (0x44U)
void TestI2C(void)
{
// config IIC pin(SCL:34.SDA:35) in menuconfig
int iic_fd = PrivOpen(I2C_DEV_DRIVER, O_RDWR);
if (iic_fd < 0)
{
printf("open iic_fd fd error:%d\n", iic_fd);
return;
}
printf("IIC open successful!\n");
// init iic
uint16 iic_address = I2C_SLAVE_ADDRESS;
struct PrivIoctlCfg ioctl_cfg;
ioctl_cfg.ioctl_driver_type = I2C_TYPE;
ioctl_cfg.args = (void *)&iic_address;
if (0 != PrivIoctl(iic_fd, OPE_INT, &ioctl_cfg))
{
printf("ioctl iic fd error %d\n", iic_fd);
PrivClose(iic_fd);
return;
}
printf("IIC configure successful!\n");
// I2C read and write
uint8_t data[32];
while (1)
{
PrivWrite(iic_fd, NONE, 0);
msleep(40);
PrivRead(iic_fd, data, 4);
float result = ((data[2] << 8 | data[3]) >> 2) * 165.0 /( (1 << 14) - 1) - 40.0;
int temperature = result*10;
printf("Temperature : %d.%d ℃\n", temperature/10, temperature%10);
result = ((data[0] << 8 | data[1] ) & 0x3fff) * 100.0 / ( (1 << 14) - 1);
int humidity = result*10;
printf("Humidity : %d.%d %%RH\n", humidity/10, humidity%10);
printf("HS300X origin data1:0x%2x%2x%2x%2x\n", data[0],data[1],data[2],data[3]);
msleep(1000);
}
PrivClose(iic_fd);
return;
}
PRIV_SHELL_CMD_FUNCTION(TestI2C, a iic test sample, PRIV_SHELL_CMD_MAIN_ATTR);
#endif

View File

@@ -0,0 +1,108 @@
/*
* 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: test_rs485.c
* @brief: a application of rs485 function
* @version: 1.1
* @author: AIIT XUOS Lab
* @date: 2022/12/17
*/
#include <stdio.h>
#include <string.h>
#include <transform.h>
#ifdef ADD_XIZI_FEATURES
#define BSP_485_DIR_PIN 24
void Test485(void)
{
int pin_fd = PrivOpen(RS485_PIN_DEV_DRIVER, O_RDWR);
if (pin_fd < 0)
{
printf("open pin fd error:%d\n", pin_fd);
return;
}
int uart_fd = PrivOpen(RS485_UART_DEV_DRIVER, O_RDWR);
if (uart_fd < 0)
{
printf("open pin fd error:%d\n", uart_fd);
return;
}
printf("uart and pin fopen success\n");
//config led pin in board
struct PinParam pin_parameter;
memset(&pin_parameter, 0, sizeof(struct PinParam));
pin_parameter.cmd = GPIO_CONFIG_MODE;
pin_parameter.pin = BSP_485_DIR_PIN;
pin_parameter.mode = GPIO_CFG_OUTPUT;
struct PrivIoctlCfg ioctl_cfg;
ioctl_cfg.ioctl_driver_type = PIN_TYPE;
ioctl_cfg.args = (void *)&pin_parameter;
if (0 != PrivIoctl(pin_fd, OPE_CFG, &ioctl_cfg)) {
printf("ioctl pin fd error %d\n", pin_fd);
PrivClose(pin_fd);
return;
}
struct SerialDataCfg uart_cfg;
memset(&uart_cfg, 0, sizeof(struct SerialDataCfg));
uart_cfg.serial_baud_rate = BAUD_RATE_115200;
uart_cfg.serial_data_bits = DATA_BITS_8;
uart_cfg.serial_stop_bits = STOP_BITS_1;
uart_cfg.serial_parity_mode = PARITY_NONE;
uart_cfg.serial_bit_order = BIT_ORDER_LSB;
uart_cfg.serial_invert_mode = NRZ_NORMAL;
uart_cfg.serial_buffer_size = SERIAL_RB_BUFSZ;
uart_cfg.serial_timeout = 1000;
uart_cfg.is_ext_uart = 0;
ioctl_cfg.ioctl_driver_type = SERIAL_TYPE;
ioctl_cfg.args = (void *)&uart_cfg;
if (0 != PrivIoctl(uart_fd, OPE_INT, &ioctl_cfg))
{
printf("ioctl uart fd error %d\n", uart_fd);
PrivClose(uart_fd);
return;
}
struct PinStat pin_dir;
pin_dir.pin = BSP_485_DIR_PIN;
while (1)
{
pin_dir.val = GPIO_HIGH;
PrivWrite(pin_fd,&pin_dir,0);
PrivWrite(uart_fd,"Hello world!\n",sizeof("Hello world!\n"));
printf("Send: Hello world!\n");
PrivTaskDelay(1000);
pin_dir.val = GPIO_LOW;
PrivWrite(pin_fd,&pin_dir,0);
char recv_buff[100];
memset(recv_buff,0,sizeof(recv_buff));
PrivRead(uart_fd,recv_buff,20);
printf("Recv: %s\n",recv_buff);
PrivTaskDelay(1000);
}
PrivClose(pin_fd);
PrivClose(uart_fd);
return;
}
PRIV_SHELL_CMD_FUNCTION(Test485, a RS485 test sample, PRIV_SHELL_CMD_MAIN_ATTR);
#endif

View File

@@ -324,7 +324,7 @@ void TestSocket(int argc, char* argv[])
return;
} else {
memset(iperf_param.host, 0, sizeof(iperf_param.host));
strncpy(iperf_param.host, ip_ptr, strlen(ip_ptr));
strncpy(iperf_param.host, ip_ptr, sizeof(iperf_param.host));
}
iperf_mode->mode = IPERF_MODE_CLIENT;
}
@@ -335,10 +335,22 @@ void TestSocket(int argc, char* argv[])
if (mode == IPERF_MODE_SERVER) {
printf("[%s] Running iperf server at port %d.\n", __func__, iperf_param.port);
PrivTaskCreate(&thd, NULL, TestIperfServer, (void*)&iperf_param);
#ifdef ADD_XIZI_FEATURES
char task_name[] = "test_iperf_server";
pthread_args_t args;
args.pthread_name = task_name;
args.arg = (void *)&iperf_param;
PrivTaskCreate(&thd, NULL, TestIperfServer, (void*)&args);
#endif
} else if (mode == IPERF_MODE_CLIENT) {
printf("[%s] Running iperf client to server at %s:%d.\n", __func__, iperf_param.host, iperf_param.port);
PrivTaskCreate(&thd, NULL, TestIperfClient, (void*)&iperf_param);
#ifdef ADD_XIZI_FEATURES
char task_name[] = "test_iperf_client";
pthread_args_t args;
args.pthread_name = task_name;
args.arg = (void *)&iperf_param;
PrivTaskCreate(&thd, NULL, TestIperfClient, (void*)&args);
#endif
}
PrivTaskStartup(&thd);

View File

@@ -272,7 +272,7 @@ CircularAreaAppType CircularAreaAppInit(uint32_t circular_area_length)
circular_area->p_tail = circular_area->data_buffer + circular_area_length;
circular_area->area_length = circular_area_length;
printf("CircularAreaAppInit done p_head %8p p_tail %8p length %u\n",
printf("CircularAreaAppInit done p_head %8p p_tail %8p length %lu\n",
circular_area->p_head, circular_area->p_tail, circular_area->area_length);
circular_area->CircularAreaAppOperations = &CircularAreaAppOperations;

View File

@@ -1,5 +1,5 @@
#include <cstdio>
#include <transform.h>
// #include <transform.h>
#include <stdio.h>
#include "tensorflow/lite/micro/all_ops_resolver.h"

View File

@@ -26,3 +26,4 @@ void mnist_app(void);
int tfmnist(void) {
mnist_app();
}
PRIV_SHELL_CMD_FUNCTION(tfmnist, a tenorflow_lite_for_microcontroller sample, PRIV_SHELL_CMD_FUNC_ATTR);

View File

@@ -24,23 +24,10 @@
#include "lv_demo_calendar.h"
#include <transform.h>
// extern void lv_example_chart_2(void);
// extern void lv_example_img_1(void);
// extern void lv_example_img_2(void);
// extern void lv_example_img_3(void);
// extern void lv_example_img_4(void);
// extern void lv_example_line_1(void);
// extern void lv_example_aoteman(void);
extern void lv_example_show(void);
void* lvgl_thread(void *parameter)
{
/* display demo; you may replace with your LVGL application at here */
lv_demo_calendar();
// lv_example_img_1();
// lv_example_chart_2();
// lv_example_table_1();
// lv_example_line_1();
// lv_example_aoteman();
/* handle the tasks of LVGL */
lv_example_show();
while(1)
{
lv_task_handler();
@@ -48,12 +35,12 @@ void* lvgl_thread(void *parameter)
}
}
pthread_t lvgl_task;
static pthread_t lvgl_task;
static int lvgl_demo_init(void)
{
pthread_attr_t attr;
attr.schedparam.sched_priority = 25;
attr.stacksize = 4096;
attr.stacksize = 8192;
PrivTaskCreate(&lvgl_task, &attr, lvgl_thread, NULL);

View File

@@ -52,7 +52,7 @@ int lv_port_init(void)
#endif
#ifndef PKG_USING_LVGL_INDEV_DEVICE
lv_port_indev_init();
// lv_port_indev_init();
#endif
return 0;

View File

@@ -17,12 +17,21 @@
extern int FrameworkInit();
extern void ApplicationOtaTaskInit(void);
#ifdef OTA_BY_PLATFORM
extern int OtaTask(void);
#endif
int main(void)
{
printf("Hello, world! \n");
FrameworkInit();
printf("Hello, world! \n");
FrameworkInit();
#ifdef APPLICATION_OTA
ApplicationOtaTaskInit();
ApplicationOtaTaskInit();
#endif
#ifdef OTA_BY_PLATFORM
OtaTask();
#endif
return 0;
}

View File

@@ -28,10 +28,14 @@ void TvocTb600bTvoc10(void)
{
struct SensorQuantity *tvoc = SensorQuantityFind(SENSOR_QUANTITY_TB600B_TVOC, SENSOR_QUANTITY_TVOC);
SensorQuantityOpen(tvoc);
int32_t result = 0;
result = SensorQuantityReadValue(tvoc);
for(int i = 0; i < 10;i++)
{
PrivTaskDelay(1000);
SensorQuantityReadValue(tvoc);
}
printf("tvoc concentration is : %dppb\n", result);
SensorQuantityClose(tvoc);
}
}
SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_CMD_FUNC)|SHELL_CMD_PARAM_NUM(0),tvoc, TvocTb600bTvoc10, read data from tvoc sensor);

View File

@@ -39,7 +39,7 @@ void* ttf_thread(void *parameter)
}
}
pthread_t lvgl_task;
static pthread_t lvgl_task;
static int ttf_demo_init(void)
{
pthread_attr_t attr;