Merge branch 'prepare_for_master' of https://gitlink.org.cn/xuos/xiuos into mqtt

This commit is contained in:
wgzAIIT
2023-08-24 10:17:32 +08:00
24 changed files with 672 additions and 52 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

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

@@ -30,16 +30,16 @@
// 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_xiuos(void);
void* lvgl_thread(void *parameter)
{
/* display demo; you may replace with your LVGL application at here */
lv_demo_calendar();
// lv_demo_calendar();
// lv_example_img_1();
// lv_example_chart_2();
// lv_example_table_1();
// lv_example_line_1();
// lv_example_aoteman();
lv_example_xiuos();
/* handle the tasks of LVGL */
while(1)
{
@@ -48,7 +48,7 @@ void* lvgl_thread(void *parameter)
}
}
pthread_t lvgl_task;
static pthread_t lvgl_task;
static int lvgl_demo_init(void)
{
pthread_attr_t attr;

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

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