add cortex-m0 support and fix some bugs

This commit is contained in:
Kiritoy 2021-11-11 21:53:11 +08:00
parent 21e01b2f6b
commit b16f2bd865
122 changed files with 6244 additions and 2470 deletions

View File

@ -1,9 +1,15 @@
import os import os
Import('RTT_ROOT') Import('RTT_ROOT')
Import('rtconfig')
from building import * from building import *
cwd = GetCurrentDir() cwd = GetCurrentDir()
SOURCES = ['framework_init.c']
path = [cwd]
objs = [] objs = []
group = DefineGroup('sensor', SOURCES, depend = [], CPPPATH = [cwd])
objs = objs + group
list = os.listdir(cwd) list = os.listdir(cwd)
for d in list: for d in list:

View File

@ -11,13 +11,16 @@
*/ */
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include <user_api.h> #include <transform.h>
extern int SensorFrameworkInit(void); extern int SensorFrameworkInit(void);
extern int AdapterFrameworkInit(void); extern int AdapterFrameworkInit(void);
extern int Adapter4GInit(void); extern int Adapter4GInit(void);
extern int AdapterNbiotInit(void);
extern int AdapterBlueToothInit(void);
extern int AdapterWifiInit(void); extern int AdapterWifiInit(void);
extern int AdapterZigbeeInit(void);
extern int D124VoiceInit(void); extern int D124VoiceInit(void);
extern int Hs300xTemperatureInit(void); extern int Hs300xTemperatureInit(void);
@ -89,10 +92,19 @@ static struct InitDesc sensor_desc[] =
static struct InitDesc connection_desc[] = static struct InitDesc connection_desc[] =
{ {
#ifdef ADAPTER_4G #ifdef CONNECTION_ADAPTER_4G
{ "4G adpter", Adapter4GInit}, { "4G adpter", Adapter4GInit},
#endif #endif
#ifdef ADAPTER_WIFI #ifdef CONNECTION_ADAPTER_NB
{ "NB adpter", AdapterNbiotInit},
#endif
#ifdef CONNECTION_ADAPTER_ZIGBEE
{ "zigbee adpter", AdapterZigbeeInit},
#endif
#ifdef CONNECTION_ADAPTER_BLUETOOTH
{ "BlueTooth adpter", AdapterBlueToothInit},
#endif
#ifdef CONNECTION_ADAPTER_WIFI
{ "Wifi adpter", AdapterWifiInit}, { "Wifi adpter", AdapterWifiInit},
#endif #endif
{ "NULL", NULL }, { "NULL", NULL },

View File

@ -23,7 +23,7 @@
#define __LIST_H__ #define __LIST_H__
#include "libc.h" #include "libc.h"
#include<stddef.h>
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif

View File

@ -9,5 +9,6 @@ menu "knowing app"
source "$APP_DIR/Applications/knowing_app/instrusion_detect/Kconfig" source "$APP_DIR/Applications/knowing_app/instrusion_detect/Kconfig"
source "$APP_DIR/Applications/knowing_app/helmet_detect/Kconfig" source "$APP_DIR/Applications/knowing_app/helmet_detect/Kconfig"
source "$APP_DIR/Applications/knowing_app/iris_ml_demo/Kconfig" source "$APP_DIR/Applications/knowing_app/iris_ml_demo/Kconfig"
source "$APP_DIR/Applications/knowing_app/k210_fft_test/Kconfig"
endif endif
endmenu endmenu

View File

@ -7,7 +7,7 @@
#define STACK_SIZE (128 * 1024) #define STACK_SIZE (128 * 1024)
#define JSON_FILE_PATH "/kmodel/detect.json" #define JSON_FILE_PATH "/kmodel/detect.json"
#define JSON_BUFFER_SIZE (4 * 1024) #define JSON_BUFFER_SIZE (4 * 1024)
static dmac_channel_number_t dma_ch = DMAC_CHANNEL_MAX;
// params from json // params from json
static float anchor[ANCHOR_NUM * 2] = {}; static float anchor[ANCHOR_NUM * 2] = {};
static int net_output_shape[3] = {}; static int net_output_shape[3] = {};
@ -184,23 +184,23 @@ void face_detect()
} }
_ioctl_set_dvp_reso set_dvp_reso = {sensor_output_size[1], sensor_output_size[0]}; _ioctl_set_dvp_reso set_dvp_reso = {sensor_output_size[1], sensor_output_size[0]};
ioctl(g_fd, IOCTRL_CAMERA_SET_DVP_RESO, &set_dvp_reso); ioctl(g_fd, IOCTRL_CAMERA_SET_DVP_RESO, &set_dvp_reso);
showbuffer = (unsigned char *)malloc(sensor_output_size[0] * sensor_output_size[1] * 2); showbuffer = (unsigned char *)rt_malloc_align(sensor_output_size[0] * sensor_output_size[1] * 2,64);
if (NULL == showbuffer) { if (NULL == showbuffer) {
close(g_fd); close(g_fd);
printf("showbuffer apply memory fail !!"); printf("showbuffer apply memory fail !!");
return; return;
} }
kpurgbbuffer = (unsigned char *)malloc(net_input_size[0] * net_input_size[1] * 3); kpurgbbuffer = (unsigned char *)rt_malloc_align(net_input_size[0] * net_input_size[1] * 3,64);
if (NULL == kpurgbbuffer) { if (NULL == kpurgbbuffer) {
close(g_fd); close(g_fd);
free(showbuffer); rt_free_align(showbuffer);
printf("kpurgbbuffer apply memory fail !!"); printf("kpurgbbuffer apply memory fail !!");
return; return;
} }
model_data = (unsigned char *)malloc(kmodel_size + 255); model_data = (unsigned char *)malloc(kmodel_size + 255);
if (NULL == model_data) { if (NULL == model_data) {
free(showbuffer); rt_free_align(showbuffer);
free(kpurgbbuffer); rt_free_align(kpurgbbuffer);
close(g_fd); close(g_fd);
printf("model_data apply memory fail !!"); printf("model_data apply memory fail !!");
return; return;
@ -296,27 +296,33 @@ static void *thread_face_detcet_entry(void *parameter)
pthread_exit(NULL); pthread_exit(NULL);
return NULL; return NULL;
} }
if (dmalock_sync_take(&dma_ch, 2000))
{
printf("Fail to take DMA channel");
}
kpu_run_kmodel(&face_detect_task, kpurgbbuffer, DMAC_CHANNEL5, ai_done, NULL); kpu_run_kmodel(&face_detect_task, kpurgbbuffer, DMAC_CHANNEL5, ai_done, NULL);
while (!g_ai_done_flag) while (!g_ai_done_flag)
; ;
dmalock_release(dma_ch);
float *output; float *output;
size_t output_size; size_t output_size;
kpu_get_output(&face_detect_task, 0, (uint8_t **)&output, &output_size); kpu_get_output(&face_detect_task, 0, (uint8_t **)&output, &output_size);
face_detect_rl.input = output; face_detect_rl.input = output;
region_layer_run(&face_detect_rl, &face_detect_info); region_layer_run(&face_detect_rl, &face_detect_info);
/* display result */ /* display result */
#ifdef BSP_USING_LCD
for (int face_cnt = 0; face_cnt < face_detect_info.obj_number; face_cnt++) { for (int face_cnt = 0; face_cnt < face_detect_info.obj_number; face_cnt++) {
draw_edge((uint32_t *)showbuffer, &face_detect_info, face_cnt, 0xF800, (uint16_t)sensor_output_size[1], draw_edge((uint32_t *)showbuffer, &face_detect_info, face_cnt, 0xF800, (uint16_t)sensor_output_size[1],
(uint16_t)sensor_output_size[0]); (uint16_t)sensor_output_size[0]);
printf("%d: (%d, %d, %d, %d) cls: %s conf: %f\t", face_cnt, face_detect_info.obj[face_cnt].x1, // printf("%d: (%d, %d, %d, %d) cls: %s conf: %f\t", face_cnt, face_detect_info.obj[face_cnt].x1,
face_detect_info.obj[face_cnt].y1, face_detect_info.obj[face_cnt].x2, face_detect_info.obj[face_cnt].y2, // face_detect_info.obj[face_cnt].y1, face_detect_info.obj[face_cnt].x2, face_detect_info.obj[face_cnt].y2,
labels[face_detect_info.obj[face_cnt].class_id], face_detect_info.obj[face_cnt].prob); // labels[face_detect_info.obj[face_cnt].class_id], face_detect_info.obj[face_cnt].prob);
} }
if (0 != face_detect_info.obj_number) printf("\n"); #ifdef BSP_USING_LCD
lcd_draw_picture(0, 0, (uint16_t)sensor_output_size[1], (uint16_t)sensor_output_size[0], (unsigned int *)showbuffer); lcd_draw_picture(0, 0, (uint16_t)sensor_output_size[1], (uint16_t)sensor_output_size[0], (uint32_t *)showbuffer);
//lcd_show_image(0, 0, (uint16_t)sensor_output_size[1], (uint16_t)sensor_output_size[0], (unsigned int *)showbuffer);
#endif #endif
usleep(1); usleep(500);
if (1 == if_exit) { if (1 == if_exit) {
if_exit = 0; if_exit = 0;
printf("thread_face_detcet_entry exit"); printf("thread_face_detcet_entry exit");

View File

@ -27,7 +27,7 @@
"kmodel_path": "/kmodel/human.kmodel", "kmodel_path": "/kmodel/human.kmodel",
"kmodel_size": 2713236, "kmodel_size": 2713236,
"obj_thresh": [ "obj_thresh": [
0.55 0.7
], ],
"labels": [ "labels": [
"human" "human"

View File

@ -1,4 +1,5 @@
#include <transform.h> #include <transform.h>
#include <unistd.h>
#ifdef LIB_USING_CJSON #ifdef LIB_USING_CJSON
#include <cJSON.h> #include <cJSON.h>
#endif #endif
@ -7,7 +8,9 @@
#define STACK_SIZE (128 * 1024) #define STACK_SIZE (128 * 1024)
#define JSON_FILE_PATH "/kmodel/human.json" #define JSON_FILE_PATH "/kmodel/human.json"
#define JSON_BUFFER_SIZE (4 * 1024) #define JSON_BUFFER_SIZE (4 * 1024)
static dmac_channel_number_t dma_ch = DMAC_CHANNEL_MAX;
extern void lcd_show_image(int x, int y, int wide, int height,const rt_uint8_t *buf);
// params from json // params from json
static float anchor[ANCHOR_NUM * 2] = {}; static float anchor[ANCHOR_NUM * 2] = {};
static int net_output_shape[3] = {}; static int net_output_shape[3] = {};
@ -184,23 +187,23 @@ void instrusion_detect()
} }
_ioctl_set_dvp_reso set_dvp_reso = {sensor_output_size[1], sensor_output_size[0]}; _ioctl_set_dvp_reso set_dvp_reso = {sensor_output_size[1], sensor_output_size[0]};
ioctl(g_fd, IOCTRL_CAMERA_SET_DVP_RESO, &set_dvp_reso); ioctl(g_fd, IOCTRL_CAMERA_SET_DVP_RESO, &set_dvp_reso);
showbuffer = (unsigned char *)malloc(sensor_output_size[0] * sensor_output_size[1] * 2); showbuffer = (unsigned char *)rt_malloc_align(sensor_output_size[0] * sensor_output_size[1] * 2,64);
if (NULL == showbuffer) { if (NULL == showbuffer) {
close(g_fd); close(g_fd);
printf("showbuffer apply memory fail !!"); printf("showbuffer apply memory fail !!");
return; return;
} }
kpurgbbuffer = (unsigned char *)malloc(net_input_size[0] * net_input_size[1] * 3); kpurgbbuffer = (unsigned char *)rt_malloc_align(net_input_size[0] * net_input_size[1] * 3,64);
if (NULL == kpurgbbuffer) { if (NULL == kpurgbbuffer) {
close(g_fd); close(g_fd);
free(showbuffer); rt_free_align(showbuffer);
printf("kpurgbbuffer apply memory fail !!"); printf("kpurgbbuffer apply memory fail !!");
return; return;
} }
model_data = (unsigned char *)malloc(kmodel_size + 255); model_data = (unsigned char *)malloc(kmodel_size + 255);
if (NULL == model_data) { if (NULL == model_data) {
free(showbuffer); rt_free_align(showbuffer);
free(kpurgbbuffer); rt_free_align(kpurgbbuffer);
close(g_fd); close(g_fd);
printf("model_data apply memory fail !!"); printf("model_data apply memory fail !!");
return; return;
@ -281,10 +284,12 @@ void instrusion_detect()
#ifdef __RT_THREAD_H__ #ifdef __RT_THREAD_H__
MSH_CMD_EXPORT(instrusion_detect, instrusion detect task); MSH_CMD_EXPORT(instrusion_detect, instrusion detect task);
#endif #endif
extern void lcd_draw_picture(uint16_t x1, uint16_t y1, uint16_t width, uint16_t height, uint32_t * ptr);
extern void lcd_show_image(int x, int y, int wide, int height,const rt_uint8_t *buf);
extern void lcd_draw_16_picture(uint16_t x1, uint16_t y1, uint16_t width, uint16_t height, uint32_t * ptr);
static void *thread_instrusion_detect_entry(void *parameter) static void *thread_instrusion_detect_entry(void *parameter)
{ {
extern void lcd_draw_picture(uint16_t x1, uint16_t y1, uint16_t width, uint16_t height, uint32_t * ptr);
printf("thread_instrusion_detect_entry start!\n"); printf("thread_instrusion_detect_entry start!\n");
int ret = 0; int ret = 0;
// sysctl_enable_irq(); // sysctl_enable_irq();
@ -299,31 +304,35 @@ static void *thread_instrusion_detect_entry(void *parameter)
pthread_exit(NULL); pthread_exit(NULL);
return NULL; return NULL;
} }
if (dmalock_sync_take(&dma_ch, 2000))
{
printf("Fail to take DMA channel");
}
kpu_run_kmodel(&instrusion_detect_task, kpurgbbuffer, DMAC_CHANNEL5, ai_done, NULL); kpu_run_kmodel(&instrusion_detect_task, kpurgbbuffer, DMAC_CHANNEL5, ai_done, NULL);
while (!g_ai_done_flag) while (!g_ai_done_flag)
; ;
dmalock_release(dma_ch);
float *output; float *output;
size_t output_size; size_t output_size;
kpu_get_output(&instrusion_detect_task, 0, (uint8_t **)&output, &output_size); kpu_get_output(&instrusion_detect_task, 0, (uint8_t **)&output, &output_size);
instrusion_detect_rl.input = output; instrusion_detect_rl.input = output;
region_layer_run(&instrusion_detect_rl, &instrusion_detect_info); region_layer_run(&instrusion_detect_rl, &instrusion_detect_info);
/* display result */ /* display result */
for (int instrusion_cnt = 0; instrusion_cnt < instrusion_detect_info.obj_number; instrusion_cnt++)
for (int instrusion_cnt = 0; instrusion_cnt < instrusion_detect_info.obj_number; instrusion_cnt++) { {
// draw_edge((uint32_t *)showbuffer, &instrusion_detect_info, instrusion_cnt, 0xF800, draw_edge((uint32_t *)showbuffer, &instrusion_detect_info, instrusion_cnt, 0xF800,(uint16_t)sensor_output_size[1],(uint16_t)sensor_output_size[0]);
// (uint16_t)sensor_output_size[1],
// (uint16_t)sensor_output_size[0]);
printf("%d: (%d, %d, %d, %d) cls: %s conf: %f\t", instrusion_cnt, instrusion_detect_info.obj[instrusion_cnt].x1, printf("%d: (%d, %d, %d, %d) cls: %s conf: %f\t", instrusion_cnt, instrusion_detect_info.obj[instrusion_cnt].x1,
instrusion_detect_info.obj[instrusion_cnt].y1, instrusion_detect_info.obj[instrusion_cnt].x2, instrusion_detect_info.obj[instrusion_cnt].y1, instrusion_detect_info.obj[instrusion_cnt].x2,
instrusion_detect_info.obj[instrusion_cnt].y2, labels[instrusion_detect_info.obj[instrusion_cnt].class_id], instrusion_detect_info.obj[instrusion_cnt].y2, labels[instrusion_detect_info.obj[instrusion_cnt].class_id],
instrusion_detect_info.obj[instrusion_cnt].prob); instrusion_detect_info.obj[instrusion_cnt].prob);
} }
#ifdef BSP_USING_LCD
//lcd_show_image(0, 0,(uint16_t)sensor_output_size[1], (uint16_t)sensor_output_size[0],(unsigned int *)showbuffer);
lcd_draw_picture(0, 0, (uint16_t)sensor_output_size[1], (uint16_t)sensor_output_size[0], (uint32_t *)showbuffer);
#endif
if (0 != instrusion_detect_info.obj_number) { if (0 != instrusion_detect_info.obj_number) {
printf("\n"); printf("\n");
} }
#ifdef BSP_USING_LCD
lcd_draw_picture(0, 0, (uint16_t)sensor_output_size[1], (uint16_t)sensor_output_size[0], (unsigned int *)showbuffer);
#endif
usleep(1); usleep(1);
if (1 == if_exit) { if (1 == if_exit) {
if_exit = 0; if_exit = 0;

View File

@ -29,7 +29,7 @@ void Pm10Ps5308(void)
{ {
struct SensorQuantity *pm1_0 = SensorQuantityFind(SENSOR_QUANTITY_PS5308_PM1_0, SENSOR_QUANTITY_PM); struct SensorQuantity *pm1_0 = SensorQuantityFind(SENSOR_QUANTITY_PS5308_PM1_0, SENSOR_QUANTITY_PM);
SensorQuantityOpen(pm1_0); SensorQuantityOpen(pm1_0);
UserTaskDelay(2000); PrivTaskDelay(2000);
printf("PM1.0 : %d ug/m³\n", SensorQuantityRead(pm1_0)); printf("PM1.0 : %d ug/m³\n", SensorQuantityRead(pm1_0));
SensorQuantityClose(pm1_0); SensorQuantityClose(pm1_0);
} }

View File

@ -18,7 +18,7 @@
* @date 2021.04.23 * @date 2021.04.23
*/ */
#include <user_api.h> #include <transform.h>
#include <sensor.h> #include <sensor.h>
/** /**
@ -29,7 +29,7 @@ void VoiceD124(void)
{ {
struct SensorQuantity *voice = SensorQuantityFind(SENSOR_QUANTITY_D124_VOICE, SENSOR_QUANTITY_VOICE); struct SensorQuantity *voice = SensorQuantityFind(SENSOR_QUANTITY_D124_VOICE, SENSOR_QUANTITY_VOICE);
SensorQuantityOpen(voice); SensorQuantityOpen(voice);
UserTaskDelay(2000); PrivTaskDelay(2000);
uint16 result = SensorQuantityRead(voice); uint16 result = SensorQuantityRead(voice);
printf("voice : %d.%d dB\n", result/(10*voice->value.decimal_places), result%(10*voice->value.decimal_places)); printf("voice : %d.%d dB\n", result/(10*voice->value.decimal_places), result%(10*voice->value.decimal_places));
SensorQuantityClose(voice); SensorQuantityClose(voice);

View File

@ -1,40 +0,0 @@
config ADAPTER_4G_EC200T
string "EC200T adapter name"
default "ec200t"
if ADD_XIUOS_FETURES
config ADAPTER_EC200T_PWRKEY
int "EC200T PWRKEY pin number"
default "97"
config ADAPTER_EC200T_PIN_DRIVER
string "EC200T device pin driver path"
default "/dev/pin_dev"
config ADAPTER_EC200T_DRIVER_EXTUART
bool "Using extra uart to support 4G"
default n
config ADAPTER_EC200T_DRIVER
string "EC200T device uart driver path"
default "/dev/uart2_dev2"
depends on !ADAPTER_EC200T_DRIVER_EXTUART
if ADAPTER_EC200T_DRIVER_EXTUART
config ADAPTER_EC200T_DRIVER
string "EC200T device extra uart driver path"
default "/dev/extuart_dev5"
config ADAPTER_EC200T_DRIVER_EXT_PORT
int "if EC200T device using extuart, choose port"
default "5"
endif
endif
if ADD_NUTTX_FETURES
endif
if ADD_RTTHREAD_FETURES
endif

View File

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

View File

@ -1,270 +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 ec200t.c
* @brief Implement the connection 4G adapter function, using EC200T device
* @version 1.1
* @author AIIT XUOS Lab
* @date 2021.07.08
*/
#include <adapter.h>
#include <at_agent.h>
static void Ec200tPowerSet(void)
{
int pin_fd;
pin_fd = PrivOpen(ADAPTER_EC200T_PIN_DRIVER, O_RDWR);
struct PinParam pin_param;
pin_param.cmd = GPIO_CONFIG_MODE;
pin_param.mode = GPIO_CFG_INPUT_PULLUP;
pin_param.pin = ADAPTER_EC200T_PWRKEY;
struct PrivIoctlCfg ioctl_cfg;
ioctl_cfg.ioctl_driver_type = PIN_TYPE;
ioctl_cfg.args = &pin_param;
PrivIoctl(pin_fd, OPE_CFG, &ioctl_cfg);
struct PinStat pin_stat;
pin_stat.pin = ADAPTER_EC200T_PWRKEY;
pin_stat.val = GPIO_HIGH;
PrivWrite(pin_fd, &pin_stat, 1);
PrivTaskDelay(600);//at least 500ms
pin_stat.val = GPIO_LOW;
PrivWrite(pin_fd, &pin_stat, 1);
PrivClose(pin_fd);
}
static int Ec200tOpen(struct Adapter *adapter)
{
/*step1: open ec200t serial port*/
adapter->fd = PrivOpen(ADAPTER_EC200T_DRIVER, O_RDWR);
if (adapter->fd < 0) {
printf("Ec200tOpen get serial %s fd error\n", ADAPTER_EC200T_DRIVER);
return -1;
}
/*step2: init AT agent*/
if (!adapter->agent) {
char *agent_name = "4G_uart_client";
if (EOK != InitATAgent(agent_name, adapter->fd, 512)) {
printf("at agent init failed !\n");
return -1;
}
ATAgentType at_agent = GetATAgent(agent_name);
adapter->agent = at_agent;
}
/*step3: serial write "+++", quit transparent mode*/
ATOrderSend(adapter->agent, REPLY_TIME_OUT, NULL, "+++");
/*step4: serial write "AT+CCID", get SIM ID*/
ATOrderSend(adapter->agent, REPLY_TIME_OUT, NULL, "AT+CCID\r\n");
PrivTaskDelay(2500);
/*step5: serial write "AT+CPIN?", check SIM status*/
ATOrderSend(adapter->agent, REPLY_TIME_OUT, NULL, "AT+CPIN?\r\n");
PrivTaskDelay(2500);
/*step6: serial write "AT+CREG?", check whether registered to GSM net*/
ATOrderSend(adapter->agent, REPLY_TIME_OUT, NULL, "AT+CREG?\r\n");
PrivTaskDelay(2500);
/*step7: serial write "AT+QICLOSE", close socket connect before open socket*/
ATOrderSend(adapter->agent, REPLY_TIME_OUT, NULL, "AT+QICLOSE=0\r\n");
PrivTaskDelay(2500);
/*step8: serial write "AT+QIDEACT", close TCP net before open socket*/
ATOrderSend(adapter->agent, REPLY_TIME_OUT, NULL, "AT+QIDEACT=1\r\n");
PrivTaskDelay(2500);
ADAPTER_DEBUG("Ec200t open done\n");
return 0;
}
static int Ec200tClose(struct Adapter *adapter)
{
if (!adapter->agent) {
printf("Ec200tClose AT agent NULL\n");
return -1;
}
/*step1: serial write "+++", quit transparent mode*/
ATOrderSend(adapter->agent, REPLY_TIME_OUT, NULL, "+++");
/*step2: serial write "AT+QICLOSE", close socket connect before open socket*/
ATOrderSend(adapter->agent, REPLY_TIME_OUT, NULL, "AT+QICLOSE=0\r\n");
PrivTaskDelay(2500);
/*step3: serial write "AT+QIDEACT", close TCP net before open socket*/
ATOrderSend(adapter->agent, REPLY_TIME_OUT, NULL, "AT+QIDEACT=1\r\n");
PrivTaskDelay(2500);
/*step4: close ec200t serial port*/
PrivClose(adapter->fd);
/*step5: power down ec200t*/
Ec200tPowerSet();
return 0;
}
static int Ec200tIoctl(struct Adapter *adapter, int cmd, void *args)
{
if (OPE_INT != cmd) {
printf("Ec200tIoctl only support OPE_INT, do not support %d\n", cmd);
return -1;
}
uint32_t baud_rate = *((uint32_t *)args);
struct SerialDataCfg serial_cfg;
memset(&serial_cfg, 0 ,sizeof(struct SerialDataCfg));
serial_cfg.serial_baud_rate = baud_rate;
serial_cfg.serial_data_bits = DATA_BITS_8;
serial_cfg.serial_stop_bits = STOP_BITS_1;
serial_cfg.serial_buffer_size = SERIAL_RB_BUFSZ;
serial_cfg.serial_parity_mode = PARITY_NONE;
serial_cfg.serial_bit_order = STOP_BITS_1;
serial_cfg.serial_invert_mode = NRZ_NORMAL;
#ifdef ADAPTER_EC200T_DRIVER_EXT_PORT
serial_cfg.ext_uart_no = ADAPTER_EC200T_DRIVER_EXT_PORT;
serial_cfg.port_configure = PORT_CFG_INIT;
#endif
struct PrivIoctlCfg ioctl_cfg;
ioctl_cfg.ioctl_driver_type = SERIAL_TYPE;
ioctl_cfg.args = &serial_cfg;
PrivIoctl(adapter->fd, OPE_INT, &ioctl_cfg);
return 0;
}
static int Ec200tConnect(struct Adapter *adapter, enum NetRoleType net_role, const char *ip, const char *port, enum IpType ip_type)
{
uint8_t ec200t_cmd[64];
/*step1: serial write "AT+QICSGP", connect to China Mobile using ipv4 or ipv6*/
memset(ec200t_cmd, 0, sizeof(ec200t_cmd));
if (IPV4 == ip_type) {
strcpy(ec200t_cmd, "AT+QICSGP=1,1,\"CMNET\",\"\",\"\",1\r\n");
} else if (IPV6 == ip_type) {
strcpy(ec200t_cmd, "AT+QICSGP=1,2,\"CMNET\",\"\",\"\",1\r\n");
}
ATOrderSend(adapter->agent, REPLY_TIME_OUT, NULL, ec200t_cmd);
PrivTaskDelay(2500);
/*step2: serial write "AT+QIACT", open TCP net*/
ATOrderSend(adapter->agent, REPLY_TIME_OUT, NULL, "AT+QIACT=1\r\n");
PrivTaskDelay(2500);
/*step3: serial write "AT+QIOPEN", connect socket using TCP*/
memset(ec200t_cmd, 0, sizeof(ec200t_cmd));
strcpy(ec200t_cmd, "AT+QIOPEN=1,0,\"TCP\",\"");
strcat(ec200t_cmd, ip);
strcat(ec200t_cmd, "\",");
strcat(ec200t_cmd, port);
strcat(ec200t_cmd, ",0,2\r\n");
ADAPTER_DEBUG("Ec200t connect AT CMD :%s\n", ec200t_cmd);
ATOrderSend(adapter->agent, REPLY_TIME_OUT, NULL, ec200t_cmd);
ADAPTER_DEBUG("Ec200t connect TCP done\n");
return 0;
}
static int Ec200tSend(struct Adapter *adapter, const void *buf, size_t len)
{
PrivWrite(adapter->fd, buf, len);
return 0;
}
static int Ec200tRecv(struct Adapter *adapter, void *buf, size_t len)
{
PrivRead(adapter->fd, buf, len);
return 0;
}
static int Ec200tDisconnect(struct Adapter *adapter)
{
uint8_t ec200t_cmd[64];
/*step1: serial write "+++", quit transparent mode*/
ATOrderSend(adapter->agent, REPLY_TIME_OUT, NULL, "+++");
/*step2: serial write "AT+QICLOSE", close socket connect before open socket*/
ATOrderSend(adapter->agent, REPLY_TIME_OUT, NULL, "AT+QICLOSE=0\r\n");
PrivTaskDelay(2500);
ADAPTER_DEBUG("Ec200t disconnect TCP done\n");
return 0;
}
static const struct IpProtocolDone ec200t_done =
{
.open = Ec200tOpen,
.close = Ec200tClose,
.ioctl = Ec200tIoctl,
.setup = NULL,
.setdown = NULL,
.setaddr = NULL,
.setdns = NULL,
.setdhcp = NULL,
.ping = NULL,
.netstat = NULL,
.connect = Ec200tConnect,
.send = Ec200tSend,
.recv = Ec200tRecv,
.disconnect = Ec200tDisconnect,
};
AdapterProductInfoType Ec200tAttach(struct Adapter *adapter)
{
struct AdapterProductInfo *product_info = malloc(sizeof(struct AdapterProductInfo));
if (!product_info) {
printf("Ec200tAttach malloc product_info error\n");
free(product_info);
return NULL;
}
product_info->model_name = ADAPTER_4G_EC200T;
product_info->model_done = (void *)&ec200t_done;
Ec200tPowerSet();
return product_info;
}

View File

@ -1,14 +0,0 @@
config ADAPTER_4G
bool "Using 4G adapter function"
default y
if ADAPTER_4G
config ADAPTER_EC200T
bool "Using 4G adapter device EC200T"
default y
if ADAPTER_EC200T
source "$APP_DIR/Framework/connection/4G/EC200T/Kconfig"
endif
endif

View File

@ -1,7 +0,0 @@
SRC_FILES := adapter_4G.c
ifeq ($(CONFIG_ADAPTER_EC200T),y)
SRC_DIR += EC200T
endif
include $(KERNEL_ROOT)/compiler.mk

View File

@ -1,110 +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 adapter_4G.c
* @brief Implement the connection 4G adapter function
* @version 1.1
* @author AIIT XUOS Lab
* @date 2021.06.25
*/
#include <adapter.h>
#ifdef ADAPTER_EC200T
extern AdapterProductInfoType Ec200tAttach(struct Adapter *adapter);
#endif
#define ADAPTER_4G_NAME "4G"
static int Adapter4GRegister(struct Adapter *adapter)
{
int ret = 0;
strncpy(adapter->name, ADAPTER_4G_NAME, NAME_NUM_MAX);
adapter->net_protocol = IP_PROTOCOL;
adapter->net_role = CLIENT;
adapter->adapter_status = UNREGISTERED;
ret = AdapterDeviceRegister(adapter);
if (ret < 0) {
printf("Adapter4G register error\n");
return -1;
}
return ret;
}
int Adapter4GInit(void)
{
int ret = 0;
struct Adapter *adapter = malloc(sizeof(struct Adapter));
if (!adapter) {
free(adapter);
return -1;
}
ret = Adapter4GRegister(adapter);
if (ret < 0) {
printf("Adapter4GInit register 4G adapter error\n");
free(adapter);
return -1;
}
#ifdef ADAPTER_EC200T
AdapterProductInfoType product_info = Ec200tAttach(adapter);
if (!product_info) {
printf("Adapter4GInit ec200t attach error\n");
free(adapter);
return -1;
}
adapter->product_info_flag = 1;
adapter->info = product_info;
adapter->done = product_info->model_done;
#endif
return ret;
}
/******************4G TEST*********************/
int Adapter4GTest(void)
{
const char *send_msg = "SendHeart";
char recv_msg[128];
int baud_rate = BAUD_RATE_115200;
struct Adapter* adapter = AdapterDeviceFindByName(ADAPTER_4G_NAME);
#ifdef ADAPTER_EC200T
//Using DSD server to test 4G Socket connection
uint8 server_addr[64] = "115.238.53.61";
uint8 server_port[64] = "33333";
AdapterDeviceOpen(adapter);
AdapterDeviceControl(adapter, OPE_INT, &baud_rate);
AdapterDeviceConnect(adapter, CLIENT, server_addr, server_port, IPV4);
while (1) {
AdapterDeviceSend(adapter, send_msg, strlen(send_msg));
AdapterDeviceRecv(adapter, recv_msg, 128);
printf("4G recv msg %s\n", recv_msg);
}
#endif
return 0;
}
SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_CMD_FUNC)|SHELL_CMD_PARAM_NUM(0)|SHELL_CMD_DISABLE_RETURN, Adapter4GTest, Adapter4GTest, show adapter 4G information);

View File

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

View File

@ -18,7 +18,7 @@ if SUPPORT_CONNECTION_FRAMEWORK
bool "Using 4G adapter device" bool "Using 4G adapter device"
default n default n
if CONNECTION_ADAPTER_4G if CONNECTION_ADAPTER_4G
source "$APP_DIR/Framework/connection/4G/Kconfig" source "$APP_DIR/Framework/connection/4g/Kconfig"
endif endif
menuconfig CONNECTION_ADAPTER_NB menuconfig CONNECTION_ADAPTER_NB
@ -60,6 +60,6 @@ if SUPPORT_CONNECTION_FRAMEWORK
bool "Using 5G adapter device" bool "Using 5G adapter device"
default n default n
if CONNECTION_ADAPTER_5G if CONNECTION_ADAPTER_5G
source "$APP_DIR/Framework/connection/5G/Kconfig" source "$APP_DIR/Framework/connection/5g/Kconfig"
endif endif
endif endif

View File

@ -1,35 +1,35 @@
SRC_FILES := adapter.c adapter_agent.c SRC_FILES := adapter.c adapter_agent.c
ifeq ($(CONFIG_ADAPTER_LORA),y) ifeq ($(CONFIG_CONNECTION_ADAPTER_LORA),y)
SRC_DIR += lora SRC_DIR += lora
endif endif
ifeq ($(CONFIG_ADAPTER_4G),y) ifeq ($(CONFIG_CONNECTION_ADAPTER_4G),y)
SRC_DIR += 4G SRC_DIR += 4g
endif endif
ifeq ($(CONFIG_ADAPTER_NB),y) ifeq ($(CONFIG_CONNECTION_ADAPTER_NB),y)
SRC_DIR += nbiot SRC_DIR += nbiot
endif endif
ifeq ($(CONFIG_ADAPTER_WIFI),y) ifeq ($(CONFIG_CONNECTION_ADAPTER_WIFI),y)
SRC_DIR += wifi SRC_DIR += wifi
endif endif
ifeq ($(CONFIG_ADAPTER_ETHERNET),y) ifeq ($(CONFIG_CONNECTION_ADAPTER_ETHERNET),y)
SRC_DIR += ethernet SRC_DIR += ethernet
endif endif
ifeq ($(CONFIG_ADAPTER_BLUETOOTH),y) ifeq ($(CONFIG_CONNECTION_ADAPTER_BLUETOOTH),y)
SRC_DIR += bluetooth SRC_DIR += bluetooth
endif endif
ifeq ($(CONFIG_ADAPTER_ZIGBEE),y) ifeq ($(CONFIG_CONNECTION_ADAPTER_ZIGBEE),y)
SRC_DIR += zigbee SRC_DIR += zigbee
endif endif
ifeq ($(CONFIG_ADAPTER_5G),y) ifeq ($(CONFIG_CONNECTION_ADAPTER_5G),y)
SRC_DIR += 5G SRC_DIR += 5g
endif endif
include $(KERNEL_ROOT)/compiler.mk include $(KERNEL_ROOT)/compiler.mk

View File

@ -39,19 +39,10 @@ extern "C" {
#define ADAPTER_LWIP_OPERATION 2 #define ADAPTER_LWIP_OPERATION 2
#define ADAPTER_RAWIP_OPERATION 3 #define ADAPTER_RAWIP_OPERATION 3
#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))
#ifdef CONNECTION_FRAMEWORK_DEBUG #ifdef CONNECTION_FRAMEWORK_DEBUG
#define ADAPTER_DEBUG printf #define ADAPTER_DEBUG printf
#else #else
#define ADAPTER_DEBUF #define ADAPTER_DEBUG
#endif #endif
struct Adapter; struct Adapter;
@ -61,8 +52,14 @@ typedef struct AdapterProductInfo *AdapterProductInfoType;
struct Socket struct Socket
{ {
int id; uint8_t type; ///< socket type:DGRAM->UDP,STREAM->TCP
struct Adapter *adapter; uint8_t protocal; ///< udp or tcp
unsigned short listen_port; ///< 0-65535
uint8_t socket_id; ///< socket id
uint8_t recv_control; ///< receive control
uint8_t af_type; ///< IPv4 or IPv6
char *src_ip_addr; ///< source P address
char *dst_ip_addr; ///< destination IP address
}; };
enum AdapterType enum AdapterType
@ -90,6 +87,9 @@ enum NetRoleType
SERVER, SERVER,
MASTER, MASTER,
SLAVE, SLAVE,
COORDINATOR,
ROUTER,
END_DEVICE,
ROLE_NONE, ROLE_NONE,
}; };
@ -110,8 +110,9 @@ enum IpType
struct AdapterProductInfo struct AdapterProductInfo
{ {
uint32_t functions; uint32_t functions;
const char *vendor_name; char vendor_name[NAME_NUM_MAX];
const char *model_name; char model_name[NAME_NUM_MAX];
uint32_t work_mode;
void *model_done; void *model_done;
}; };
@ -154,14 +155,14 @@ struct PrivProtocolDone
struct Adapter struct Adapter
{ {
char *name; char name[NAME_NUM_MAX];
int fd; int fd;
int product_info_flag; int product_info_flag;
struct AdapterProductInfo *info; struct AdapterProductInfo *info;
ATAgentType agent; ATAgentType agent;
//struct Socket *socket; struct Socket socket;
enum NetProtocolType net_protocol; enum NetProtocolType net_protocol;
enum NetRoleType net_role; enum NetRoleType net_role;

View File

@ -27,7 +27,6 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <user_api.h> #include <user_api.h>
#include <bus.h>
#define AT_CMD_MAX_LEN 128 #define AT_CMD_MAX_LEN 128
#define AT_AGENT_MAX 2 #define AT_AGENT_MAX 2
@ -36,18 +35,19 @@ static uint32 last_cmd_len = 0;
static struct ATAgent at_agent_table[AT_AGENT_MAX] = {0}; static struct ATAgent at_agent_table[AT_AGENT_MAX] = {0};
uint IpTint(char *ipstr){ unsigned int IpTint(char *ipstr)
{
if (ipstr == NULL) if (ipstr == NULL)
return 0; return 0;
char *token; char *token;
uint i = 3, total = 0, cur; unsigned int i = 3, total = 0, cur;
token = strtok(ipstr, "."); token = strtok(ipstr, ".");
while (token != NULL){ while (token != NULL) {
cur = atoi(token); cur = atoi(token);
if (cur >= 0 && cur <= 255){ if (cur >= 0 && cur <= 255) {
total += cur * pow(256, i); total += cur * pow(256, i);
} }
i--; i--;
@ -61,8 +61,8 @@ void SwapStr(char *str, int begin, int end)
{ {
int i, j; int i, j;
for (i = begin, j = end; i <= j; i++, j--){ for (i = begin, j = end; i <= j; i++, j--) {
if (str[i] != str[j]){ if (str[i] != str[j]) {
str[i] = str[i] ^ str[j]; str[i] = str[i] ^ str[j];
str[j] = str[i] ^ str[j]; str[j] = str[i] ^ str[j];
str[i] = str[i] ^ str[j]; str[i] = str[i] ^ str[j];
@ -70,16 +70,16 @@ void SwapStr(char *str, int begin, int end)
} }
} }
char *IpTstr(uint ipint) char *IpTstr(unsigned int ipint)
{ {
int LEN = 16; int LEN = 16;
char *new = (char *)malloc(LEN); char *new = (char *)PrivMalloc(LEN);
memset(new, '\0', LEN); memset(new, '\0', LEN);
new[0] = '.'; new[0] = '.';
char token[4]; char token[4];
int bt, ed, len, cur; int bt, ed, len, cur;
while (ipint){ while (ipint) {
cur = ipint % 256; cur = ipint % 256;
sprintf(token, "%d", cur); sprintf(token, "%d", cur);
strcat(new, token); strcat(new, token);
@ -91,8 +91,8 @@ char *IpTstr(uint ipint)
len = strlen(new); len = strlen(new);
SwapStr(new, 0, len - 1); SwapStr(new, 0, len - 1);
for (bt = ed = 0; ed < len;){ for (bt = ed = 0; ed < len;) {
while (ed < len && new[ed] != '.'){ while (ed < len && new[ed] != '.') {
ed++; ed++;
} }
SwapStr(new, bt, ed - 1); SwapStr(new, bt, ed - 1);
@ -120,17 +120,21 @@ int ParseATReply(char *str, const char *format, ...)
uint32 ATSprintf(int fd, const char *format, va_list params) uint32 ATSprintf(int fd, const char *format, va_list params)
{ {
last_cmd_len = vsnprintf(send_buf, sizeof(send_buf), format, params); last_cmd_len = vsnprintf(send_buf, sizeof(send_buf), format, params);
printf("ATSprintf send %s\n",send_buf); printf("ATSprintf send %s len %u\n",send_buf, last_cmd_len);
PrivWrite(fd, send_buf, last_cmd_len); PrivWrite(fd, send_buf, last_cmd_len);
} }
int ATOrderSend(ATAgentType agent, uint32 timeout, ATReplyType reply, const char *cmd_expr, ...) int ATOrderSend(ATAgentType agent, uint32 timeout_s, ATReplyType reply, const char *cmd_expr, ...)
{ {
if (agent == NULL){ if (agent == NULL) {
printf("ATAgent is null"); printf("ATAgent is null");
return -ERROR; return -ERROR;
} }
struct timespec abstime;
abstime.tv_sec = timeout_s;
agent->receive_mode = AT_MODE; agent->receive_mode = AT_MODE;
memset(agent->maintain_buffer, 0x00, agent->maintain_max); memset(agent->maintain_buffer, 0x00, agent->maintain_max);
@ -147,16 +151,16 @@ int ATOrderSend(ATAgentType agent, uint32 timeout, ATReplyType reply, const char
agent->reply = reply; agent->reply = reply;
if(agent->reply != NULL){ if(agent->reply != NULL) {
reply->reply_len = 0; reply->reply_len = 0;
va_start(params, cmd_expr); va_start(params, cmd_expr);
ATSprintf(agent->fd, cmd_expr, params); ATSprintf(agent->fd, cmd_expr, params);
va_end(params); va_end(params);
if (UserSemaphoreObtain(agent->rsp_sem, timeout) != EOK){ if (PrivSemaphoreObtainWait(&agent->rsp_sem, &abstime) != EOK) {
result = -ETIMEOUT; result = -ETIMEOUT;
goto __out; goto __out;
} }
}else{ } else {
va_start(params, cmd_expr); va_start(params, cmd_expr);
ATSprintf(agent->fd, cmd_expr, params); ATSprintf(agent->fd, cmd_expr, params);
va_end(params); va_end(params);
@ -166,16 +170,87 @@ int ATOrderSend(ATAgentType agent, uint32 timeout, ATReplyType reply, const char
__out: __out:
agent->reply = NULL; agent->reply = NULL;
PrivMutexAbandon(&agent->lock); PrivMutexAbandon(&agent->lock);
agent->receive_mode = ENTM_MODE; agent->receive_mode = DEFAULT_MODE;
return result; return result;
} }
int AtCmdConfigAndCheck(ATAgentType agent, char *cmd, char *check)
{
int ret = 0;
char *result = NULL;
if (NULL == agent || NULL == cmd || NULL == check ) {
return -1;
}
ATReplyType reply = CreateATReply(64);
if (NULL == reply) {
printf("%s %d at_create_resp failed!\n",__func__,__LINE__);
ret = -1;
goto __exit;
}
ATOrderSend(agent, REPLY_TIME_OUT, reply, cmd);
PrivTaskDelay(3000);
result = GetReplyText(reply);
if (!result) {
printf("%s %n get reply failed.\n",__func__,__LINE__);
ret = -1;
goto __exit;
}
printf("[reply result :\n");
printf("%s]\n", result);
if(!strstr(result, check)) {
printf("%s %d check[%s] reply[%s] failed.\n",__func__,__LINE__,check,result);
ret = -1;
goto __exit;
}
__exit:
DeleteATReply(reply);
return ret;
}
char *GetReplyText(ATReplyType reply) char *GetReplyText(ATReplyType reply)
{ {
return reply->reply_buffer; return reply->reply_buffer;
} }
int AtSetReplyLrEnd(ATAgentType agent, char enable)
{
if (!agent) {
return -ERROR;
}
agent->reply_lr_end = enable;
return EOK;
}
int AtSetReplyEndChar(ATAgentType agent, char last_ch, char end_ch)
{
if (!agent) {
return -ERROR;
}
agent->reply_end_last_char = last_ch;
agent->reply_end_char = end_ch;
return EOK;
}
int AtSetReplyCharNum(ATAgentType agent, unsigned int num)
{
if (!agent) {
return -ERROR;
}
agent->reply_char_num = num;
return EOK;
}
int EntmSend(ATAgentType agent, const char *data, int len) int EntmSend(ATAgentType agent, const char *data, int len)
{ {
char send_buf[128]; char send_buf[128];
@ -185,32 +260,40 @@ int EntmSend(ATAgentType agent, const char *data, int len)
memcpy(send_buf, data, len); memcpy(send_buf, data, len);
memcpy(send_buf + len, "!@", 2); memcpy(send_buf + len, "!@", 2);
write(agent->fd, send_buf, len + 2); PrivWrite(agent->fd, send_buf, len + 2);
return EOK; return EOK;
} }
int EntmRecv(ATAgentType agent, char *rev_buffer, int buffer_len, int time_out) int EntmRecv(ATAgentType agent, char *rev_buffer, int buffer_len, int timeout_s)
{ {
UserTaskDelay(1000); struct timespec abstime;
abstime.tv_sec = timeout_s;
agent->receive_mode = ENTM_MODE;
PrivTaskDelay(1000);
if (PrivSemaphoreObtainWait(&agent->entm_rx_notice, &abstime)) {
return -ERROR;
}
PrivMutexObtain(&agent->lock);
if (buffer_len < agent->entm_recv_len) {
return -ERROR;
}
printf("EntmRecv once len %u.\n", agent->entm_recv_len);
agent->entm_recv_buf[agent->entm_recv_len - 1] = '\0';
memcpy(rev_buffer, agent->entm_recv_buf, agent->entm_recv_len - 2);
memset(agent->entm_recv_buf, 0, ENTM_RECV_MAX); memset(agent->entm_recv_buf, 0, ENTM_RECV_MAX);
agent->entm_recv_len = 0; agent->entm_recv_len = 0;
UserSemaphoreSetValue(agent->entm_rx_notice, 0); PrivMutexAbandon(&agent->lock);
if (UserSemaphoreObtain(agent->entm_rx_notice, time_out)){
return ERROR;
}
if (buffer_len < agent->entm_recv_len){
return ERROR;
}
printf("EntmRecv once .\n");
agent->entm_recv_buf[agent->entm_recv_len - 2] = '\0';
memcpy(rev_buffer, agent->entm_recv_buf, agent->entm_recv_len - 2);
return EOK; return EOK;
} }
@ -224,42 +307,49 @@ static int GetCompleteATReply(ATAgentType agent)
memset(agent->maintain_buffer, 0x00, agent->maintain_max); memset(agent->maintain_buffer, 0x00, agent->maintain_max);
agent->maintain_len = 0; agent->maintain_len = 0;
while (1){ while (1) {
read(agent->fd, &ch, 1); PrivRead(agent->fd, &ch, 1);
#ifdef CONNECTION_FRAMEWORK_DEBUG
printf(" %c(0x%x)\n", ch, ch); printf(" %c (0x%x)\n", ch, ch);
#endif
if (agent->receive_mode == ENTM_MODE){ if (agent->receive_mode == ENTM_MODE){
if (agent->entm_recv_len < ENTM_RECV_MAX){ if (agent->entm_recv_len < ENTM_RECV_MAX) {
agent->entm_recv_buf[agent->entm_recv_len++] = ch; PrivMutexObtain(&agent->lock);
agent->entm_recv_buf[agent->entm_recv_len] = ch;
agent->entm_recv_len++;
PrivMutexAbandon(&agent->lock);
if (last_ch == '!' && ch == '@'){ if (last_ch == '!' && ch == '@'){
UserSemaphoreAbandon(agent->entm_rx_notice); PrivSemaphoreAbandon(&agent->entm_rx_notice);
} }
last_ch = ch; last_ch = ch;
} } else {
else{
printf("entm_recv_buf is_full ...\n"); printf("entm_recv_buf is_full ...\n");
} }
} } else if (agent->receive_mode == AT_MODE) {
else if (agent->receive_mode == AT_MODE){
if (read_len < agent->maintain_max){ if (read_len < agent->maintain_max){
agent->maintain_buffer[read_len++] = ch; agent->maintain_buffer[read_len] = ch;
read_len++;
agent->maintain_len = read_len; agent->maintain_len = read_len;
}else{ } else {
printf("maintain_len is_full ...\n"); printf("maintain_len is_full ...\n");
is_full = true; is_full = true;
} }
if ((ch == '\n' && last_ch == '\r')){ if (((ch == '\n') && (last_ch == '\r') && (agent->reply_lr_end)) ||
if (is_full){ ((ch == agent->reply_end_char) && (agent->reply_end_char) &&
(last_ch == agent->reply_end_last_char) && (agent->reply_end_last_char)) ||
((read_len == agent->reply_char_num) && (agent->reply_char_num))){
if (is_full) {
printf("read line failed. The line data length is out of buffer size(%d)!", agent->maintain_max); printf("read line failed. The line data length is out of buffer size(%d)!", agent->maintain_max);
memset(agent->maintain_buffer, 0x00, agent->maintain_max); memset(agent->maintain_buffer, 0x00, agent->maintain_max);
agent->maintain_len = 0; agent->maintain_len = 0;
return -ERROR; return -ERROR;
} }
printf("GetCompleteATReply get n r ...\n"); printf("GetCompleteATReply done\n");
break; break;
} }
last_ch = ch; last_ch = ch;
@ -272,8 +362,8 @@ static int GetCompleteATReply(ATAgentType agent)
ATAgentType GetATAgent(const char *agent_name) ATAgentType GetATAgent(const char *agent_name)
{ {
struct ATAgent* result = NULL; struct ATAgent* result = NULL;
for (int i = 0; i < AT_AGENT_MAX; i++){ for (int i = 0; i < AT_AGENT_MAX; i++) {
if (strcmp(at_agent_table[i].agent_name, agent_name) == 0){ if (strcmp(at_agent_table[i].agent_name, agent_name) == 0) {
result = &at_agent_table[i]; result = &at_agent_table[i];
} }
} }
@ -284,52 +374,51 @@ ATAgentType GetATAgent(const char *agent_name)
static int DeleteATAgent(ATAgentType agent) static int DeleteATAgent(ATAgentType agent)
{ {
if (agent->lock){ if (agent->lock) {
PrivMutexDelete(&agent->lock); PrivMutexDelete(&agent->lock);
} }
if (agent->entm_rx_notice){ if (agent->entm_rx_notice) {
UserSemaphoreDelete(agent->entm_rx_notice); PrivSemaphoreDelete(&agent->entm_rx_notice);
} }
if (agent->fd > 0){ if (agent->fd > 0) {
close(agent->fd); PrivClose(agent->fd);
} }
if (agent->rsp_sem){ if (agent->rsp_sem) {
UserSemaphoreDelete(agent->rsp_sem); PrivSemaphoreDelete(&agent->rsp_sem);
} }
if (agent->maintain_buffer){ if (agent->maintain_buffer) {
free(agent->maintain_buffer); PrivFree(agent->maintain_buffer);
} }
memset(agent, 0x00, sizeof(struct ATAgent)); memset(agent, 0x00, sizeof(struct ATAgent));
} }
static void ATAgentReceiveProcess(void *param) static void *ATAgentReceiveProcess(void *param)
{ {
ATAgentType agent = (ATAgentType)param; ATAgentType agent = (ATAgentType)param;
const struct at_urc *urc; const struct at_urc *urc;
while (1){ while (1) {
if (GetCompleteATReply(agent) > 0){ if (GetCompleteATReply(agent) > 0) {
if (agent->reply != NULL){ if (agent->reply != NULL){
ATReplyType reply = agent->reply; ATReplyType reply = agent->reply;
agent->maintain_buffer[agent->maintain_len - 1] = '\0'; agent->maintain_buffer[agent->maintain_len] = '\0';
if (agent->maintain_len < reply->reply_max_len){ if (agent->maintain_len < reply->reply_max_len) {
memcpy(reply->reply_buffer, agent->maintain_buffer, agent->maintain_len); memcpy(reply->reply_buffer, agent->maintain_buffer, agent->maintain_len);
reply->reply_len = agent->maintain_len; reply->reply_len = agent->maintain_len;
} } else {
else{
printf("out of memory (%d)!", reply->reply_max_len); printf("out of memory (%d)!", reply->reply_max_len);
} }
agent->reply = NULL; agent->reply = NULL;
UserSemaphoreAbandon(agent->rsp_sem); PrivSemaphoreAbandon(&agent->rsp_sem);
} }
} }
} }
@ -339,56 +428,48 @@ static int ATAgentInit(ATAgentType agent)
{ {
int result = EOK; int result = EOK;
UtaskType at_utask; UtaskType at_utask;
do
{
agent->maintain_len = 0;
agent->maintain_buffer = (char *)malloc(agent->maintain_max);
if (agent->maintain_buffer == NONE){ agent->maintain_len = 0;
break; agent->maintain_buffer = (char *)PrivMalloc(agent->maintain_max);
}
agent->entm_rx_notice = UserSemaphoreCreate(0); if (agent->maintain_buffer == NONE) {
if (agent->entm_rx_notice == 0){ printf("ATAgentInit malloc maintain_buffer error\n");
break; goto __out;
} }
agent->rsp_sem = UserSemaphoreCreate(0); memset(agent->maintain_buffer, 0, agent->maintain_max);
if (agent->rsp_sem == 0){
break;
}
if(PrivMutexCreate(&agent->lock, 0) < 0) {
printf("AdapterFrameworkInit mutex create failed.\n");
}
if (agent->lock == 0){
break;
}
agent->receive_mode = ENTM_MODE; result = PrivSemaphoreCreate(&agent->entm_rx_notice, 0, 0);
if (result < 0) {
printf("ATAgentInit create entm sem error\n");
goto __out;
}
strncpy(at_utask.name, "recv_task", strlen("recv_task")); result = PrivSemaphoreCreate(&agent->rsp_sem, 0, 0);
at_utask.func_entry = ATAgentReceiveProcess; if (result < 0) {
at_utask.func_param = agent; printf("ATAgentInit create rsp sem error\n");
at_utask.stack_size = 1024; goto __out;
at_utask.prio = 18; }
agent->at_handler = UserTaskCreate(at_utask); if(PrivMutexCreate(&agent->lock, 0) < 0) {
printf("AdapterFrameworkInit mutex create failed.\n");
goto __out;
}
// struct SerialDataCfg data_cfg; agent->receive_mode = ENTM_MODE;
// memset(&data_cfg, 0, sizeof(struct SerialDataCfg));
// data_cfg.serial_baud_rate = 57600;
// ioctl(agent->fd, OPE_INT, &data_cfg);
if (agent->at_handler == 0) { pthread_attr_t attr;
break; attr.schedparam.sched_priority = 18;
} attr.stacksize = 2048;
result = EOK; PrivTaskCreate(&agent->at_handler, &attr, ATAgentReceiveProcess, agent);
return result;
} while (1);
return result;
__out:
DeleteATAgent(agent); DeleteATAgent(agent);
result = -ERROR; result = -ERROR;
return result; return result;
} }
@ -422,9 +503,8 @@ int InitATAgent(const char *agent_name, int agent_fd, uint32 maintain_max)
agent->maintain_max = maintain_max; agent->maintain_max = maintain_max;
result = ATAgentInit(agent); result = ATAgentInit(agent);
if (result == EOK) if (result == EOK) {
{ PrivTaskStartup(&agent->at_handler);
UserTaskStartup(agent->at_handler);
} }
return result; return result;
@ -434,38 +514,37 @@ ATReplyType CreateATReply(uint32 reply_max_len)
{ {
ATReplyType reply = NULL; ATReplyType reply = NULL;
reply = (ATReplyType)malloc(sizeof(struct ATReply)); reply = (ATReplyType)PrivMalloc(sizeof(struct ATReply));
if (reply == NULL){ if (reply == NULL) {
printf("no more memory\n"); printf("no more memory\n");
return NULL; return NULL;
} }
reply->reply_max_len = reply_max_len; reply->reply_max_len = reply_max_len;
reply->reply_buffer = (char *)malloc(reply_max_len); reply->reply_buffer = (char *)PrivMalloc(reply_max_len);
if (reply->reply_buffer == NULL){ if (reply->reply_buffer == NULL) {
printf("no more memory\n"); printf("no more memory\n");
free(reply); PrivFree(reply);
return NULL; return NULL;
} }
memset(reply->reply_buffer, 0, reply_max_len);
return reply; return reply;
} }
void DeleteATReply(ATReplyType reply) void DeleteATReply(ATReplyType reply)
{ {
if (reply){ if (reply) {
if (reply->reply_buffer){ if (reply->reply_buffer) {
free(reply->reply_buffer); PrivFree(reply->reply_buffer);
reply->reply_buffer = NULL; reply->reply_buffer = NULL;
} }
} }
if (reply){ if (reply) {
free(reply); PrivFree(reply);
reply = NULL; reply = NULL;
} }
} }

View File

@ -26,8 +26,11 @@
#include <stdio.h> #include <stdio.h>
#include <sys/types.h> #include <sys/types.h>
#define REPLY_TIME_OUT 3
enum ReceiveMode enum ReceiveMode
{ {
DEFAULT_MODE = 0,
ENTM_MODE = 1, ENTM_MODE = 1,
AT_MODE = 2, AT_MODE = 2,
}; };
@ -52,9 +55,13 @@ struct ATAgent
int lock; int lock;
ATReplyType reply; ATReplyType reply;
char reply_lr_end;
char reply_end_last_char;
char reply_end_char;
uint32 reply_char_num;
int rsp_sem; int rsp_sem;
int32 at_handler; pthread_t at_handler;
#define ENTM_RECV_MAX 256 #define ENTM_RECV_MAX 256
char entm_recv_buf[ENTM_RECV_MAX]; char entm_recv_buf[ENTM_RECV_MAX];
@ -65,18 +72,20 @@ struct ATAgent
typedef struct ATAgent *ATAgentType; typedef struct ATAgent *ATAgentType;
int EntmSend(ATAgentType agent, const char *data, int len); int EntmSend(ATAgentType agent, const char *data, int len);
int EntmRecv(ATAgentType agent, char *rev_buffer, int buffer_len, int time_out); int EntmRecv(ATAgentType agent, char *rev_buffer, int buffer_len, int timeout_s);
char *GetReplyText(ATReplyType reply); char *GetReplyText(ATReplyType reply);
int AtSetReplyEndChar(ATAgentType agent, char last_ch, char end_ch);
int AtSetReplyCharNum(ATAgentType agent, unsigned int num);
int AtSetReplyLrEnd(ATAgentType agent, char enable);
ATReplyType CreateATReply(uint32 reply_max_len); ATReplyType CreateATReply(uint32 reply_max_len);
uint IpTint(char *ipstr); unsigned int IpTint(char *ipstr);
void SwapStr(char *str, int begin, int end); void SwapStr(char *str, int begin, int end);
char* IpTstr(uint ipint); char* IpTstr(unsigned int ipint);
ATAgentType GetATAgent(const char *agent_name); ATAgentType GetATAgent(const char *agent_name);
int InitATAgent(const char *agent_name, int fd, uint32 maintain_max); int InitATAgent(const char *agent_name, int fd, uint32 maintain_max);
int ParseATReply(char* str, const char *format, ...); int ParseATReply(char* str, const char *format, ...);
void DeleteATReply(ATReplyType reply); void DeleteATReply(ATReplyType reply);
int ATOrderSend(ATAgentType agent, uint32 timeout, ATReplyType reply, const char *cmd_expr, ...); int ATOrderSend(ATAgentType agent, uint32 timeout_s, ATReplyType reply, const char *cmd_expr, ...);
int AtCmdConfigAndCheck(ATAgentType agent, char *cmd, char *check);
#define REPLY_TIME_OUT 3000
#endif #endif

View File

@ -1,32 +0,0 @@
config ADAPTER_BLUETOOTH_HC08
string "HC08 adapter name"
default "hc08"
if ADD_XIUOS_FETURES
config ADAPTER_HC08_DRIVER_EXTUART
bool "Using extra uart to support bluetooth"
default n
config ADAPTER_HC08_DRIVER
string "HC08 device uart driver path"
default "/dev/uart4_dev4"
depends on !ADAPTER_HC08_DRIVER_EXTUART
if ADAPTER_HC08_DRIVER_EXTUART
config ADAPTER_HC08_DRIVER
string "HC08 device extra uart driver path"
default "/dev/extuart_dev7"
config ADAPTER_HC08_DRIVER_EXT_PORT
int "if HC08 device using extuart, choose port"
default "7"
endif
endif
if ADD_NUTTX_FETURES
endif
if ADD_RTTHREAD_FETURES
endif

View File

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

View File

@ -1,170 +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 hc08.c
* @brief Implement the connection Bluetooth adapter function, using HC08 device
* @version 1.1
* @author AIIT XUOS Lab
* @date 2021.07.12
*/
#include <adapter.h>
#include <at_agent.h>
static int rx_sem;
static sem_t *hc08_sem;
static pthread_t hc08_recv_thread;
void Hc08RecvThreadEntry(void *parameter)
{
while (1)
{
PrivRead(adapter->fd, buf, len);
UserSemaphoreAbandon(rx_sem);
}
}
static int Hc08Open(struct Adapter *adapter)
{
if (INSTALL == adapter->adapter_status) {
printf("Hc08 has already been open\n");
return 0;
}
/*step1: open hc08 serial port*/
adapter->fd = PrivOpen(ADAPTER_HC08_DRIVER, O_RDWR);
if (adapter->fd < 0) {
printf("Hc08Open get serial %s fd error\n", ADAPTER_HC08_DRIVER);
return -1;
}
/*step2: init AT agent*/
if (!adapter->agent) {
char *agent_name = "bluetooth_uart_client";
if (EOK != InitATAgent(agent_name, adapter->fd, 512)) {
printf("at agent init failed !\n");
return -1;
}
ATAgentType at_agent = GetATAgent(agent_name);
adapter->agent = at_agent;
}
/*step3: create bluetooth receive task*/
PrivSemaphoreCreate(hc08_sem, 0, rx_sem);
PrivTaskCreate(&hc08_recv_thread, NULL, Hc08RecvThreadEntry, NULL);
ADAPTER_DEBUG("Hc08 open done\n");
}
static int Hc08Close(struct Adapter *adapter)
{
return 0;
}
static int Hc08Ioctl(struct Adapter *adapter, int cmd, void *args)
{
if (OPE_INT != cmd) {
printf("Hc08Ioctl only support OPE_INT, do not support %d\n", cmd);
return -1;
}
uint32_t baud_rate = *((uint32_t *)args);
struct SerialDataCfg serial_cfg;
memset(&serial_cfg, 0 ,sizeof(struct SerialDataCfg));
serial_cfg.serial_baud_rate = baud_rate;
serial_cfg.serial_data_bits = DATA_BITS_8;
serial_cfg.serial_stop_bits = STOP_BITS_1;
serial_cfg.serial_buffer_size = SERIAL_RB_BUFSZ;
serial_cfg.serial_parity_mode = PARITY_NONE;
serial_cfg.serial_bit_order = STOP_BITS_1;
serial_cfg.serial_invert_mode = NRZ_NORMAL;
#ifdef ADAPTER_HC08_DRIVER_EXT_PORT
serial_cfg.ext_uart_no = ADAPTER_HC08_DRIVER_EXT_PORT;
serial_cfg.port_configure = PORT_CFG_INIT;
#endif
struct PrivIoctlCfg ioctl_cfg;
ioctl_cfg.ioctl_driver_type = SERIAL_TYPE;
ioctl_cfg.args = &serial_cfg;
PrivIoctl(adapter->fd, OPE_INT, &ioctl_cfg);
ADAPTER_DEBUG("Hc08 ioctl done\n");
return 0;
}
static int Hc08SetAddr(struct Adapter *adapter, const char *ip, const char *gateway, const char *netmask)
{
}
static int Hc08Connect(struct Adapter *adapter, enum NetRoleType net_role, const char *ip, const char *port, enum IpType ip_type)
{
}
static int Hc08Send(struct Adapter *adapter, const void *buf, size_t len)
{
PrivWrite(adapter->fd, buf, len);
return 0;
}
static int Hc08Recv(struct Adapter *adapter, void *buf, size_t len)
{
return 0;
}
static int Hc08Disconnect(struct Adapter *adapter)
{
}
static const struct IpProtocolDone hc08_done =
{
.open = Hc08Open,
.close = Hc08Close,
.ioctl = Hc08Ioctl,
.setup = NULL,
.setdown = NULL,
.setaddr = Hc08SetAddr,
.setdns = NULL,
.setdhcp = NULL,
.ping = NULL,
.netstat = NULL,
.connect = Hc08Connect,
.send = Hc08Send,
.recv = Hc08Recv,
.disconnect = Hc08Disconnect,
};
AdapterProductInfoType Hc08Attach(struct Adapter *adapter)
{
struct AdapterProductInfo *product_info = malloc(sizeof(struct AdapterProductInfo));
if (!product_info) {
printf("Hc08Attach malloc product_info error\n");
free(product_info);
return NULL;
}
product_info->model_name = ADAPTER_BLUETOOTH_HC08;
product_info->model_done = (void *)&hc08_done;
return product_info;
}

View File

@ -1,14 +1,7 @@
config ADAPTER_BLUETOOTH config ADAPTER_HC08
bool "Using bluetooth adapter function" bool "Using bluetooth adapter device HC08"
default y default y
if ADAPTER_BLUETOOTH if ADAPTER_HC08
config ADAPTER_HC08 source "$APP_DIR/Framework/connection/bluetooth/hc08/Kconfig"
bool "Using bluetooth adapter device HC08" endif
default y
if ADAPTER_HC08
source "$APP_DIR/Framework/connection/bluetooth/HC08/Kconfig"
endif
endif

View File

@ -1,7 +1,7 @@
SRC_FILES := adapter_bluetooth.c SRC_FILES := adapter_bluetooth.c
ifeq ($(CONFIG_ADAPTER_HC08),y) ifeq ($(CONFIG_ADAPTER_HC08),y)
SRC_DIR += HC08 SRC_DIR += hc08
endif endif
include $(KERNEL_ROOT)/compiler.mk include $(KERNEL_ROOT)/compiler.mk

View File

@ -17,3 +17,96 @@
* @author AIIT XUOS Lab * @author AIIT XUOS Lab
* @date 2021.06.25 * @date 2021.06.25
*/ */
#include <adapter.h>
#ifdef ADAPTER_HC08
extern AdapterProductInfoType Hc08Attach(struct Adapter *adapter);
#endif
#define ADAPTER_BLUETOOTH_NAME "BlueTooth"
static int AdapterBlueToothRegister(struct Adapter *adapter)
{
int ret = 0;
strncpy(adapter->name, ADAPTER_BLUETOOTH_NAME, NAME_NUM_MAX);
adapter->net_protocol = IP_PROTOCOL;
adapter->adapter_status = UNREGISTERED;
ret = AdapterDeviceRegister(adapter);
if (ret < 0) {
printf("AdapterBlueToothRegister register error\n");
return -1;
}
return ret;
}
int AdapterBlueToothInit(void)
{
int ret = 0;
struct Adapter *adapter = PrivMalloc(sizeof(struct Adapter));
if (!adapter) {
free(adapter);
return -1;
}
memset(adapter, 0, sizeof(struct Adapter));
ret = AdapterBlueToothRegister(adapter);
if (ret < 0) {
printf("AdapterBlueToothInit register BT adapter error\n");
free(adapter);
return -1;
}
#ifdef ADAPTER_HC08
AdapterProductInfoType product_info = Hc08Attach(adapter);
if (!product_info) {
printf("AdapterBlueToothInit hc08 attach error\n");
free(adapter);
return -1;
}
adapter->product_info_flag = 1;
adapter->info = product_info;
adapter->done = product_info->model_done;
#endif
return ret;
}
/******************4G TEST*********************/
int AdapterBlueToothTest(void)
{
const char *bluetooth_msg = "BT Adapter Test";
char bluetooth_recv_msg[128];
int len;
int baud_rate = BAUD_RATE_115200;
struct Adapter *adapter = AdapterDeviceFindByName(ADAPTER_BLUETOOTH_NAME);
#ifdef ADAPTER_HC08
AdapterDeviceOpen(adapter);
AdapterDeviceControl(adapter, OPE_INT, &baud_rate);
len = strlen(bluetooth_msg);
while (1) {
AdapterDeviceRecv(adapter, bluetooth_recv_msg, 128);
printf("bluetooth_recv_msg %s\n", bluetooth_recv_msg);
AdapterDeviceSend(adapter, bluetooth_msg, len);
printf("send %s after recv\n", bluetooth_msg);
PrivTaskDelay(100);
memset(bluetooth_recv_msg, 0, 128);
}
#endif
return 0;
}
SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_CMD_FUNC)|SHELL_CMD_PARAM_NUM(0)|SHELL_CMD_DISABLE_RETURN, AdapterBlueToothTest, AdapterBlueToothTest, show adapter BT information);

View File

@ -0,0 +1,10 @@
if CONNECTION_ADAPTER_NB
config ADAPTER_BC28
bool "Using nbiot adapter device BC28"
default y
if ADAPTER_BC28
source "$APP_DIR/Framework/connection/nbiot/bc28/Kconfig"
endif
endif

View File

@ -1,3 +1,7 @@
SRC_FILES := adapter_nbiot.c SRC_FILES := adapter_nbiot.c
ifeq ($(CONFIG_ADAPTER_BC28),y)
SRC_DIR += bc28
endif
include $(KERNEL_ROOT)/compiler.mk include $(KERNEL_ROOT)/compiler.mk

View File

@ -17,3 +17,156 @@
* @author AIIT XUOS Lab * @author AIIT XUOS Lab
* @date 2021.06.25 * @date 2021.06.25
*/ */
#include <adapter.h>
#ifdef ADAPTER_BC28
extern AdapterProductInfoType BC28Attach(struct Adapter *adapter);
#endif
#define ADAPTER_NBIOT_NAME "nbiot"
static int AdapterNbiotRegister(struct Adapter *adapter)
{
int ret = 0;
strncpy(adapter->name, ADAPTER_NBIOT_NAME, NAME_NUM_MAX);
adapter->net_protocol = IP_PROTOCOL;
adapter->net_role = CLIENT;
adapter->adapter_status = UNREGISTERED;
ret = AdapterDeviceRegister(adapter);
if (ret < 0) {
printf("AdapterNbiot register error\n");
return -1;
}
return ret;
}
int AdapterNbiotInit(void)
{
int ret = 0;
struct Adapter *adapter = malloc(sizeof(struct Adapter));
if (!adapter) {
printf("malloc adapter failed.\n");
return -1;
}
memset(adapter, 0, sizeof(struct Adapter));
ret = AdapterNbiotRegister(adapter);
if (ret < 0) {
printf("register nbiot adapter error\n");
free(adapter);
return -1;
}
#ifdef ADAPTER_BC28
AdapterProductInfoType product_info = BC28Attach(adapter);
if (!product_info) {
printf("bc28 attach error\n");
free(adapter);
return -1;
}
adapter->product_info_flag = 1;
adapter->info = product_info;
adapter->done = product_info->model_done;
#endif
return ret;
}
/******************TEST*********************/
int opennb(void)
{
int ret = 0;
struct Adapter* adapter = AdapterDeviceFindByName(ADAPTER_NBIOT_NAME);
#ifdef ADAPTER_BC28
ret = AdapterDeviceOpen(adapter);
if(ret < 0){
printf("open adapter failed\n");
return -1;
}
#endif
return 0;
}
SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_CMD_FUNC)|SHELL_CMD_PARAM_NUM(0)|SHELL_CMD_DISABLE_RETURN, opennb, opennb, show adapter nb information);
int closenb(void)
{
int ret = 0;
struct Adapter* adapter = AdapterDeviceFindByName(ADAPTER_NBIOT_NAME);
#ifdef ADAPTER_BC28
ret = AdapterDeviceClose(adapter);
if(ret < 0){
printf("open adapter failed\n");
return -1;
}
#endif
return 0;
}
SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_CMD_FUNC)|SHELL_CMD_PARAM_NUM(0)|SHELL_CMD_DISABLE_RETURN, closenb, closenb, show adapter nb information);
int connectnb(int argc, char *argv[])
{
const char *send_msg = argv[1];
int ret = 0;
struct Adapter* adapter = AdapterDeviceFindByName(ADAPTER_NBIOT_NAME);
ret = AdapterDeviceConnect(adapter, 1, "101.68.82.219","9898",1);
if(ret < 0){
printf(" adapter send failed\n");
return -1;
}
return 0;
}
SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_CMD_MAIN)|SHELL_CMD_PARAM_NUM(2)|SHELL_CMD_DISABLE_RETURN, connectnb, connectnb, show adapter nb information);
int sendnb(int argc, char *argv[])
{
const char *send_msg = argv[1];
int msg_len = atoi(argv[2]);
int ret = 0;
struct Adapter* adapter = AdapterDeviceFindByName(ADAPTER_NBIOT_NAME);
printf("send argv1 %s len = %d\n",argv[1],msg_len);
ret = AdapterDeviceSend(adapter, send_msg, msg_len);
if(ret < 0){
printf(" adapter send failed\n");
return -1;
}
printf("nb send msg %s\n", send_msg);
return 0;
}
SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_CMD_MAIN)|SHELL_CMD_PARAM_NUM(2)|SHELL_CMD_DISABLE_RETURN, sendnb, sendnb, show adapter nb information);
int recvnb(void)
{
char recv_msg[128];
struct Adapter* adapter = AdapterDeviceFindByName(ADAPTER_NBIOT_NAME);
memset(recv_msg,0,128);
AdapterDeviceRecv(adapter, recv_msg, 128);
PrivTaskDelay(2000);
printf("nb recv msg %s\n", recv_msg);
return 0;
}
SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_CMD_FUNC)|SHELL_CMD_PARAM_NUM(0)|SHELL_CMD_DISABLE_RETURN, recvnb, recvnb, show adapter nb information);

View File

@ -1,33 +0,0 @@
config ADAPTER_WIFI_HFA21
string "HFA21 adapter name"
default "hfa21"
if ADD_XIUOS_FETURES
config ADAPTER_HFA21_DRIVER_EXTUART
bool "Using extra uart to support wifi"
default n
config ADAPTER_HFA21_DRIVER
string "HFA21 device uart driver path"
default "/dev/usart3_dev3"
depends on !ADAPTER_HFA21_DRIVER_EXTUART
if ADAPTER_HFA21_DRIVER_EXTUART
config ADAPTER_HFA21_DRIVER
string "HFA21 device extra uart driver path"
default "/dev/extuart_dev6"
config ADAPTER_HFA21_DRIVER_EXT_PORT
int "if HFA21 device using extuart, choose port"
default "6"
endif
endif
if ADD_NUTTX_FETURES
endif
if ADD_RTTHREAD_FETURES
endif

View File

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

View File

@ -1,516 +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 hfa21.c
* @brief Implement the connection wifi adapter function, using HFA21 device
* @version 1.1
* @author AIIT XUOS Lab
* @date 2021.07.08
*/
#include <adapter.h>
#include <at_agent.h>
#define LEN_PARA_BUF 128
static int Hfa21SetDown(struct Adapter *adapter_at);
/**
* @description: enter AT command mode
* @param at_agent - wifi device agent pointer
* @return success: EOK
*/
static int Hfa21InitAtCmd(ATAgentType at_agent)
{
ATOrderSend(at_agent, REPLY_TIME_OUT, NULL, "+++");
PrivTaskDelay(100);
ATOrderSend(at_agent, REPLY_TIME_OUT, NULL, "a");
PrivTaskDelay(500);
return 0;
}
/**
* @description: Open wifi
* @param adapter - wifi device pointer
* @return success: EOK, failure: ENOMEMORY
*/
static int Hfa21Open(struct Adapter *adapter)
{
/*step1: open ec200t serial port*/
adapter->fd = PrivOpen(ADAPTER_HFA21_DRIVER, O_RDWR);
if (adapter->fd < 0) {
printf("Hfa21Open get serial %s fd error\n", ADAPTER_HFA21_DRIVER);
return -1;
}
/*step2: init AT agent*/
if (!adapter->agent) {
char *agent_name = "wifi_uart_client";
if (EOK != InitATAgent(agent_name, adapter->fd, 512)) {
printf("at agent init failed !\n");
return -1;
}
ATAgentType at_agent = GetATAgent(agent_name);
adapter->agent = at_agent;
}
ADAPTER_DEBUG("Hfa21 open done\n");
return 0;
}
/**
* @description: Close wifi
* @param adapter - wifi device pointer
* @return success: EOK
*/
static int Hfa21Close(struct Adapter *adapter)
{
return Hfa21SetDown(adapter);
}
/**
* @description: send data to adapter
* @param adapter - wifi device pointer
* @param data - data bufferd
* @param data - data length
* @return success: EOK
*/
static int Hfa21Send(struct Adapter *adapter, const void *data, size_t len)
{
x_err_t result = EOK;
if (adapter->agent) {
EntmSend(adapter->agent, (const char *)data, len);
}else {
printf("Can not find agent \n");
}
__exit:
return result;
}
/**
* @description: receive data from adapter
* @param adapter - wifi device pointer
* @param data - data bufferd
* @param data - data length
* @return success: EOK
*/
static int Hfa21Receive(struct Adapter *adapter, void *rev_buffer, size_t buffer_len)
{
x_err_t result = EOK;
printf("hfa21 receive waiting ... \n");
if (adapter->agent) {
return EntmRecv(adapter->agent, (char *)rev_buffer, buffer_len, 40000);
} else {
printf("Can not find agent \n");
}
__exit:
return result;
}
/**
* @description: connnect wifi to internet
* @param adapter - wifi device pointer
* @return success: EOK
*/
static int Hfa21SetUp(struct Adapter *adapter)
{
uint8 wifi_ssid[LEN_PARA_BUF] = "AIIT-Guest";
uint8 wifi_pwd[LEN_PARA_BUF] = "";
char cmd[LEN_PARA_BUF];
//struct at_device_esp8266 *esp8266 = (struct at_device_esp8266 *) device->UserData;
struct ATAgent *agent = adapter->agent;
/* wait hfa21 device startup finish */
PrivTaskDelay(5000);
Hfa21InitAtCmd(agent);
memset(cmd,0,sizeof(cmd));
strcpy(cmd,"AT+FCLR\r");
ATOrderSend(agent, REPLY_TIME_OUT, NULL, cmd);
PrivTaskDelay(20000);
Hfa21InitAtCmd(agent);
memset(cmd,0,sizeof(cmd));
strcpy(cmd,"AT+WSSSID=");
strcat(cmd,wifi_ssid);
strcat(cmd,"\r");
ATOrderSend(agent, REPLY_TIME_OUT, NULL, cmd);
PrivTaskDelay(2500);
memset(cmd,0,sizeof(cmd));
strcpy(cmd,"AT+WSKEY=OPEN,NONE,");
strcat(cmd,wifi_pwd);
strcat(cmd,"\r");
ATOrderSend(agent, REPLY_TIME_OUT, NULL, cmd);
PrivTaskDelay(2500);
memset(cmd,0,sizeof(cmd));
strcpy(cmd,"AT+WMODE=sta\r");
ATOrderSend(agent, REPLY_TIME_OUT, NULL, cmd);
PrivTaskDelay(2500);
memset(cmd,0,sizeof(cmd));
strcat(cmd,"AT+Z\r");
ATOrderSend(agent, REPLY_TIME_OUT, NULL, cmd);
PrivTaskDelay(10000);
return 0;
}
/**
* @description: disconnnect wifi from internet
* @param adapter - wifi device pointer
* @return success: EOK
*/
static int Hfa21SetDown(struct Adapter *adapter)
{
Hfa21InitAtCmd(adapter->agent);
ATOrderSend(adapter->agent, REPLY_TIME_OUT, NULL, "AT+FCLR\r");
PrivTaskDelay(20000);
return 0;
}
/**
* @description: set wifi ip/gateway/netmask address(in sta mode)
* @param adapter - wifi device pointer
* @param ip - ip address
* @param gateway - gateway address
* @param netmask - netmask address
* @return success: EOK, failure: ENOMEMORY
*/
static int Hfa21SetAddr(struct Adapter *adapter, const char *ip, const char *gateway, const char *netmask)
{
#define HFA21_SET_ADDR_EXPRESSION "+ok=%[^,],%[^,],%[^,],%[^,]\r"
char *dhcp_mode =NULL;
char *ip_str = NULL;
char *gw_str = NULL;
char *mask_str = NULL;
dhcp_mode = (char *) UserCalloc(1, 8);
ip_str = (char *) UserCalloc(1, 17);
gw_str = (char *) UserCalloc(1, 17);
mask_str = (char *) UserCalloc(1, 17);
Hfa21InitAtCmd(adapter->agent);
x_err_t result = EOK;
ATReplyType reply = CreateATReply(64);
if (NULL == reply) {
printf("at_create_resp failed ! \n");
result = ENOMEMORY;
goto __exit;
}
ATOrderSend(adapter->agent, REPLY_TIME_OUT, NULL, "AT+WANN=%s,%s,%s,%s\r", "dhcp", ip, netmask, gateway);
PrivTaskDelay(2500);
ATOrderSend(adapter->agent, REPLY_TIME_OUT, reply, "AT+WANN\r");
PrivTaskDelay(2500);
ATOrderSend(adapter->agent, REPLY_TIME_OUT, NULL, "AT+Z\r");
PrivTaskDelay(10000);
const char * result_buf = GetReplyText(reply);
char* str = strstr(result_buf, "+ok=");
ParseATReply(str, HFA21_SET_ADDR_EXPRESSION, dhcp_mode,ip_str,mask_str,gw_str);
printf("after configure:\n mode:%s\n ip:%s\n netmask:%s\n gateway:%s\n", dhcp_mode, ip_str, mask_str, gw_str);
__exit:
if (reply) {
DeleteATReply(reply);
}
return result;
}
/**
* @description: ping
* @param adapter - wifi device pointer
* @param destination - domain name or ip address
* @return success: EOK, failure: ENOMEMORY
*/
static int Hfa21Ping(struct Adapter *adapter, const char *destination)
{
char *ping_result = NONE;
char *dst = NONE;
ping_result = (char *) UserCalloc(1, 17);
dst = (char *) UserCalloc(1, 17);
strcpy(dst, destination);
strcat(dst, "\r");
Hfa21InitAtCmd(adapter->agent);
uint32 result = EOK;
ATReplyType reply = CreateATReply(64);
if (NULL == reply) {
printf("at_create_resp failed ! \n");
result = ENOMEMORY;
goto __exit;
}
//ping baidu.com
ATOrderSend(adapter->agent, REPLY_TIME_OUT, reply, "AT+PING=%s", dst);
PrivTaskDelay(2500);
ATOrderSend(adapter->agent, REPLY_TIME_OUT, NULL, "AT+Z\r");
PrivTaskDelay(10000);
const char * result_buf = GetReplyText(reply);
char* str = strstr(result_buf, "+ok=");
ParseATReply(str, "+ok=%s\r", ping_result);
printf("ping www.baidu.com(36.152.44.95) result is:%s\n", ping_result);
__exit:
if (reply) {
DeleteATReply(reply);
}
return result;
}
/**
* @description: display network configuration
* @param adapter - wifi device pointer
* @return success: EOK, failure: ENOMEMORY
*/
static int Hfa21Netstat(struct Adapter *adapter)
{
#define HFA21_NETSTAT_RESP_SIZE 320
#define HFA21_NETSTAT_TYPE_SIZE 10
#define HFA21_NETSTAT_IPADDR_SIZE 17
#define HFA21_WANN_EXPRESSION "+ok=%[^,],%[^,],%[^,],%[^,]\r"
#define HFA21_LANN_EXPRESSION "+ok=%[^,],%[^,]\r"
#define HFA21_WMODE_EXPRESSION "+ok=%s\r"
ATReplyType reply = NULL;
struct ATAgent *agent = adapter->agent;
uint32 result;
char * result_buf = NULL;
char * str = NULL;
/* sta/ap */
char *work_mode = NULL;
/* dhcp/static */
char *ip_mode = NULL;
char *local_ipaddr = NULL;
char *gateway = NULL;
char *netmask = NULL;
local_ipaddr = (char *) UserCalloc(1, HFA21_NETSTAT_IPADDR_SIZE);
gateway = (char *) UserCalloc(1, HFA21_NETSTAT_IPADDR_SIZE);
netmask = (char *) UserCalloc(1, HFA21_NETSTAT_IPADDR_SIZE);
work_mode = (char *) UserCalloc(1, HFA21_NETSTAT_IPADDR_SIZE);
ip_mode = (char *) UserCalloc(1, HFA21_NETSTAT_IPADDR_SIZE);
reply = CreateATReply(HFA21_NETSTAT_RESP_SIZE);
if (reply == NULL) {
result = ENOMEMORY;
goto __exit;
}
ATOrderSend(agent, REPLY_TIME_OUT, NULL, "+++");
PrivTaskDelay(100);
ATOrderSend(agent, REPLY_TIME_OUT, NULL, "a");
PrivTaskDelay(2500);
ATOrderSend(agent, REPLY_TIME_OUT, reply, "AT+WMODE\r");
PrivTaskDelay(2500);
result_buf = GetReplyText(reply);
str = strstr(result_buf, "+ok=");
/* parse the third line of response data, get the network connection information */
ParseATReply(str, HFA21_WMODE_EXPRESSION, work_mode);
if (work_mode[0]=='S') {
if (ATOrderSend(agent, REPLY_TIME_OUT, reply, "AT+WANN\r") < 0) {
goto __exit;
}
PrivTaskDelay(2500);
GetReplyText(reply);
str = strstr(result_buf, "+ok=");
/* parse the third line of response data, get the network connection information */
ParseATReply(str, HFA21_WANN_EXPRESSION, ip_mode, local_ipaddr, netmask, gateway);
} else {
ATOrderSend(agent, REPLY_TIME_OUT, reply, "AT+LANN\r");
PrivTaskDelay(2500);
GetReplyText(reply);
str = strstr(result_buf, "+ok=");
/* parse the third line of response data, get the network connection information */
ParseATReply(str, HFA21_LANN_EXPRESSION, local_ipaddr, netmask);
}
ATOrderSend(adapter->agent, REPLY_TIME_OUT, NULL, "AT+Z\r");
PrivTaskDelay(10000);
printf("work mode: %s\n", work_mode);
if (work_mode[0]=='S')
printf("ip mode: %s\nlocal ip: %s\nnetmask: %s\ngateway: %s\n", ip_mode, local_ipaddr, netmask, gateway);
else
printf("local ip: %s\nnetmask: %s\n", local_ipaddr, netmask);
return EOK;
__exit:
if (reply)
DeleteATReply(reply);
if (local_ipaddr)
UserFree(local_ipaddr);
if (netmask)
UserFree(netmask);
if (gateway)
UserFree(gateway);
if (work_mode)
UserFree(work_mode);
}
static int Hfa21Connect(struct Adapter *adapter, enum NetRoleType net_role, const char *ip, const char *port, enum IpType ip_type)
{
int result = EOK;
ATReplyType reply = NONE;
char cmd[LEN_PARA_BUF];
struct ATAgent *agent = adapter->agent;
reply = CreateATReply(64);
if (reply == NONE) {
printf("no memory for reply struct.");
return ENOMEMORY;
}
Hfa21InitAtCmd(adapter->agent);
memset(cmd,0,sizeof(cmd));
strcpy(cmd,"AT+NETP=TCP,");
if(net_role == CLIENT)
strcat(cmd,"CLIENT,");
else if(net_role == SERVER)
strcat(cmd,"SERVER,");
strcat(cmd,port);
strcat(cmd,",");
if(ip_type == IPV4)
strcat(cmd,ip);
else if(ip_type == IPV6)
{
}
strcat(cmd,"\r");
ATOrderSend(agent, REPLY_TIME_OUT, NULL, cmd);
PrivTaskDelay(2500);
ATOrderSend(adapter->agent, REPLY_TIME_OUT, NULL, "AT+Z\r");
PrivTaskDelay(10000);
adapter->net_role = net_role;
__exit:
if (reply) {
DeleteATReply(reply);
}
return result;
}
static int Hfa21Ioctl(struct Adapter *adapter, int cmd, void *args)
{
if (OPE_INT != cmd) {
printf("Hfa21Ioctl only support OPE_INT, do not support %d\n", cmd);
return -1;
}
uint32_t baud_rate = *((uint32_t *)args);
struct SerialDataCfg serial_cfg;
memset(&serial_cfg, 0 ,sizeof(struct SerialDataCfg));
serial_cfg.serial_baud_rate = baud_rate;
serial_cfg.serial_data_bits = DATA_BITS_8;
serial_cfg.serial_stop_bits = STOP_BITS_1;
serial_cfg.serial_buffer_size = SERIAL_RB_BUFSZ;
serial_cfg.serial_parity_mode = PARITY_NONE;
serial_cfg.serial_bit_order = BIT_ORDER_LSB;
serial_cfg.serial_invert_mode = NRZ_NORMAL;
#ifdef ADAPTER_HFA21_DRIVER_EXT_PORT
serial_cfg.ext_uart_no = ADAPTER_HFA21_DRIVER_EXT_PORT;
serial_cfg.port_configure = PORT_CFG_INIT;
#endif
struct PrivIoctlCfg ioctl_cfg;
ioctl_cfg.ioctl_driver_type = SERIAL_TYPE;
ioctl_cfg.args = &serial_cfg;
PrivIoctl(adapter->fd, OPE_INT, &ioctl_cfg);
printf("Hfa21Ioctl success\n");
return 0;
}
static const struct IpProtocolDone hfa21_done =
{
.open = Hfa21Open,
.close = Hfa21Close,
.ioctl = Hfa21Ioctl,
.setup = Hfa21SetUp,
.setdown = Hfa21SetDown,
.setaddr = Hfa21SetAddr,
.setdns = NULL,
.setdhcp = NULL,
.ping = Hfa21Ping,
.netstat = Hfa21Netstat,
.connect = Hfa21Connect,
.send = Hfa21Send,
.recv = Hfa21Receive,
.disconnect = NULL,
};
/**
* @description: Register wifi device hfa21
* @return success: EOK, failure: ERROR
*/
AdapterProductInfoType Hfa21Attach(struct Adapter *adapter)
{
struct AdapterProductInfo *product_info = malloc(sizeof(struct AdapterProductInfo));
if (!product_info) {
printf("Hfa21Attach Attach malloc product_info error\n");
free(product_info);
return NULL;
}
product_info->model_name = ADAPTER_WIFI_HFA21;
product_info->model_done = (void *)&hfa21_done;
return product_info;
}

View File

@ -1,14 +1,7 @@
config ADAPTER_WIFI config ADAPTER_HFA21_WIFI
bool "Using WIFI adapter function" bool "Using wifi adapter device HFA21"
default y default y
if ADAPTER_WIFI if ADAPTER_HFA21_WIFI
config ADAPTER_HFA21 source "$APP_DIR/Framework/connection/wifi/hfa21_wifi/Kconfig"
bool "Using wifi adapter device HFA21" endif
default y
if ADAPTER_HFA21
source "$APP_DIR/Framework/connection/wifi/HFA21/Kconfig"
endif
endif

View File

@ -1,7 +1,7 @@
SRC_FILES := adapter_wifi.c SRC_FILES := adapter_wifi.c
ifeq ($(CONFIG_ADAPTER_HFA21),y) ifeq ($(CONFIG_ADAPTER_HFA21_WIFI),y)
SRC_DIR += HFA21 SRC_DIR += hfa21_wifi
endif endif
include $(KERNEL_ROOT)/compiler.mk include $(KERNEL_ROOT)/compiler.mk

View File

@ -21,7 +21,7 @@
#include <adapter.h> #include <adapter.h>
#include <bus_pin.h> #include <bus_pin.h>
#ifdef ADAPTER_HFA21 #ifdef ADAPTER_HFA21_WIFI
extern AdapterProductInfoType Hfa21Attach(struct Adapter *adapter); extern AdapterProductInfoType Hfa21Attach(struct Adapter *adapter);
#endif #endif
@ -49,13 +49,15 @@ int AdapterWifiInit(void)
{ {
int ret = 0; int ret = 0;
struct Adapter *adapter = malloc(sizeof(struct Adapter)); struct Adapter *adapter = PrivMalloc(sizeof(struct Adapter));
if (!adapter) { if (!adapter) {
printf("AdapterWifiInit malloc error\n"); printf("AdapterWifiInit malloc error\n");
free(adapter); free(adapter);
return -1; return -1;
} }
memset(adapter, 0, sizeof(struct Adapter));
ret = AdapterWifiRegister(adapter); ret = AdapterWifiRegister(adapter);
if (ret < 0) { if (ret < 0) {
printf("AdapterWifiInit register wifi adapter error\n"); printf("AdapterWifiInit register wifi adapter error\n");
@ -63,7 +65,7 @@ int AdapterWifiInit(void)
return -1; return -1;
} }
#ifdef ADAPTER_HFA21 #ifdef ADAPTER_HFA21_WIFI
AdapterProductInfoType product_info = Hfa21Attach(adapter); AdapterProductInfoType product_info = Hfa21Attach(adapter);
if (!product_info) { if (!product_info) {
printf("AdapterWifiInit hfa21 attach error\n"); printf("AdapterWifiInit hfa21 attach error\n");

View File

@ -0,0 +1,10 @@
if CONNECTION_ADAPTER_ZIGBEE
config ADAPTER_E18
bool "Using zigbee adapter device E18"
default y
if ADAPTER_E18
source "$APP_DIR/Framework/connection/zigbee/e18/Kconfig"
endif
endif

View File

@ -1,3 +1,7 @@
SRC_FILES := adapter_zigbee.c SRC_FILES := adapter_zigbee.c
ifeq ($(CONFIG_ADAPTER_E18),y)
SRC_DIR += e18
endif
include $(KERNEL_ROOT)/compiler.mk include $(KERNEL_ROOT)/compiler.mk

View File

@ -15,5 +15,143 @@
* @brief Implement the connection zigbee adapter function * @brief Implement the connection zigbee adapter function
* @version 1.1 * @version 1.1
* @author AIIT XUOS Lab * @author AIIT XUOS Lab
* @date 2021.06.25 * @date 2021.09.15
*/ */
#include <adapter.h>
#include "adapter_zigbee.h"
#ifdef ADAPTER_E18
extern AdapterProductInfoType E18Attach(struct Adapter *adapter);
#endif
#define ADAPTER_ZIGBEE_NAME "zigbee"
static int AdapterZigbeeRegister(struct Adapter *adapter)
{
int ret = 0;
strncpy(adapter->name, ADAPTER_ZIGBEE_NAME, NAME_NUM_MAX);
/* config adapter net protocol as network mode */
adapter->net_protocol = PRIVATE_PROTOCOL;
/* config adapter net role as coordinator/router/end_device */
#ifdef AS_COORDINATOR_ROLE
adapter->net_role = COORDINATOR;
#endif
#ifdef AS_ROUTER_ROLE
adapter->net_role = ROUTER;
#endif
#ifdef AS_END_DEVICE_ROLE
adapter->net_role = END_DEVICE;
#endif
adapter->adapter_status = UNREGISTERED;
ret = AdapterDeviceRegister(adapter);
if (ret < 0) {
printf("AdapterZigbee register error\n");
return -1;
}
return ret;
}
int AdapterZigbeeInit(void)
{
int ret = 0;
struct Adapter *adapter = malloc(sizeof(struct Adapter));
if (!adapter) {
printf("malloc adapter failed.\n");
return -1;
}
memset(adapter, 0, sizeof(struct Adapter));
ret = AdapterZigbeeRegister(adapter);
if (ret < 0) {
printf("AdapterZigbeeRegister register zigbee adapter error\n");
free(adapter);
return -1;
}
#ifdef ADAPTER_E18
AdapterProductInfoType product_info = E18Attach(adapter);
if (!product_info) {
printf("AdapterZigbeeRegister e18 attach error\n");
free(adapter);
return -1;
}
adapter->product_info_flag = 1;
adapter->info = product_info;
adapter->done = product_info->model_done;
#endif
return ret;
}
/******************TEST*********************/
int openzigbee(void)
{
int ret = 0;
struct Adapter* adapter = AdapterDeviceFindByName(ADAPTER_ZIGBEE_NAME);
#ifdef ADAPTER_E18
ret = AdapterDeviceOpen(adapter);
if(ret < 0){
printf("open adapter failed\n");
return -1;
}
adapter->info->work_mode = 1;
ret = AdapterDeviceControl(adapter, CONFIG_ZIGBEE_NET_MODE,NULL);
if(ret < 0){
printf("control adapter failed\n");
return -1;
}
ret = AdapterDeviceJoin(adapter, NULL);
if(ret < 0){
printf("join adapter failed\n");
return -1;
}
#endif
return 0;
}
SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_CMD_FUNC)|SHELL_CMD_PARAM_NUM(0)|SHELL_CMD_DISABLE_RETURN, openzigbee, openzigbee, show adapter zigbee information);
int sendzigbee(int argc, char *argv[])
{
const char *send_msg = argv[1];
int ret = 0;
struct Adapter* adapter = AdapterDeviceFindByName(ADAPTER_ZIGBEE_NAME);
printf("send argv1 %s\n",argv[1]);
ret = AdapterDeviceSend(adapter, send_msg, strlen(send_msg));
if(ret < 0){
printf(" adapter send failed\n");
return -1;
}
printf("zigbee send msg %s\n", send_msg);
return 0;
}
SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_CMD_MAIN)|SHELL_CMD_PARAM_NUM(2)|SHELL_CMD_DISABLE_RETURN, sendzigbee, sendzigbee, show adapter zigbee information);
int recvzigbee(void)
{
char recv_msg[128];
struct Adapter* adapter = AdapterDeviceFindByName(ADAPTER_ZIGBEE_NAME);
memset(recv_msg,0,128);
AdapterDeviceRecv(adapter, recv_msg, 128);
PrivTaskDelay(2000);
printf("zigbee recv msg %s\n", recv_msg);
return 0;
}
SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_CMD_FUNC)|SHELL_CMD_PARAM_NUM(0)|SHELL_CMD_DISABLE_RETURN, recvzigbee, recvzigbee, show adapter zigbee information);

View File

@ -81,7 +81,7 @@ static int SensorDeviceRead(struct SensorDevice *sdev, size_t len)
PrivRead(sdev->fd, &tmp, 1); PrivRead(sdev->fd, &tmp, 1);
if ((tmp == 0xFE) || (timeout >= 1000)) if ((tmp == 0xFE) || (timeout >= 1000))
break; break;
UserTaskDelay(10); PrivTaskDelay(10);
++timeout; ++timeout;
} }

View File

@ -52,7 +52,7 @@ static int SensorDeviceRead(struct SensorDevice *sdev, size_t len)
if (PrivWrite(sdev->fd, NULL, 0) != 1) if (PrivWrite(sdev->fd, NULL, 0) != 1)
return -1; return -1;
UserTaskDelay(50); PrivTaskDelay(50);
if (PrivRead(sdev->fd, sdev->buffer, len) != 1) if (PrivRead(sdev->fd, sdev->buffer, len) != 1)
return -1; return -1;

View File

@ -21,8 +21,8 @@
#include <sensor.h> #include <sensor.h>
static struct SensorDevice ps5308; static struct SensorDevice ps5308;
static int32_t active_task_id; static pthread_t active_task_id;
static int buff_lock; static pthread_mutex_t buff_lock;
static struct SensorProductInfo info = static struct SensorProductInfo info =
{ {
@ -35,13 +35,14 @@ static struct SensorProductInfo info =
* @description: Read sensor task * @description: Read sensor task
* @param sdev - sensor device pointer * @param sdev - sensor device pointer
*/ */
static void ReadTask(struct SensorDevice *sdev) static void *ReadTask(void *parameter)
{ {
struct SensorDevice *sdev = (struct SensorDevice *)parameter;
while (1) { while (1) {
UserMutexObtain(buff_lock, WAITING_FOREVER); PrivMutexObtain(&buff_lock);
sdev->done->read(sdev, 32); sdev->done->read(sdev, 32);
UserMutexAbandon(buff_lock); PrivMutexAbandon(&buff_lock);
UserTaskDelay(750); PrivTaskDelay(750);
} }
} }
@ -54,7 +55,7 @@ static int SensorDeviceOpen(struct SensorDevice *sdev)
{ {
int result = 0; int result = 0;
buff_lock = UserMutexCreate(); PrivMutexCreate(&buff_lock, 0);
sdev->fd = open(SENSOR_DEVICE_PS5308_DEV, O_RDWR); sdev->fd = open(SENSOR_DEVICE_PS5308_DEV, O_RDWR);
@ -73,17 +74,8 @@ static int SensorDeviceOpen(struct SensorDevice *sdev)
result = ioctl(sdev->fd, OPE_INT, &cfg); result = ioctl(sdev->fd, OPE_INT, &cfg);
UtaskType active_task; PrivTaskCreate(&active_task_id, NULL, &ReadTask, sdev);
const char name[NAME_NUM_MAX] = "ps5308_task"; PrivTaskStartup(&active_task_id);
strncpy(active_task.name, name, strlen(name));
active_task.func_entry = ReadTask;
active_task.func_param = sdev;
active_task.prio = KTASK_PRIORITY_MAX/2;
active_task.stack_size = 1024;
active_task_id = UserTaskCreate(active_task);
result = UserTaskStartup(active_task_id);
return result; return result;
} }
@ -95,8 +87,8 @@ static int SensorDeviceOpen(struct SensorDevice *sdev)
*/ */
static int SensorDeviceClose(struct SensorDevice *sdev) static int SensorDeviceClose(struct SensorDevice *sdev)
{ {
UserTaskDelete(active_task_id); PrivTaskDelete(active_task_id, 0);
UserMutexDelete(buff_lock); PrivMutexDelete(&buff_lock);
return 0; return 0;
} }
@ -114,7 +106,7 @@ static int SensorDeviceRead(struct SensorDevice *sdev, size_t len)
read(sdev->fd, &tmp, 1); read(sdev->fd, &tmp, 1);
if ((tmp == 0x44) || (timeout >= 1000)) if ((tmp == 0x44) || (timeout >= 1000))
break; break;
UserTaskDelay(10); PrivTaskDelay(10);
++timeout; ++timeout;
} }
@ -175,7 +167,7 @@ static int32_t ReadPm1_0(struct SensorQuantity *quant)
uint32_t result; uint32_t result;
if (quant->sdev->done->read != NULL) { if (quant->sdev->done->read != NULL) {
uint16_t checksum = 0; uint16_t checksum = 0;
UserMutexObtain(buff_lock, WAITING_FOREVER); PrivMutexObtain(&buff_lock);
for (uint8_t i = 0; i < 30; i++) for (uint8_t i = 0; i < 30; i++)
checksum += quant->sdev->buffer[i]; checksum += quant->sdev->buffer[i];
@ -242,7 +234,7 @@ static int32_t ReadPm2_5(struct SensorQuantity *quant)
uint32_t result; uint32_t result;
if (quant->sdev->done->read != NULL) { if (quant->sdev->done->read != NULL) {
uint16_t checksum = 0; uint16_t checksum = 0;
UserMutexObtain(buff_lock, WAITING_FOREVER); PrivMutexObtain(&buff_lock);
for (uint i = 0; i < 30; i++) for (uint i = 0; i < 30; i++)
checksum += quant->sdev->buffer[i]; checksum += quant->sdev->buffer[i];
@ -309,7 +301,7 @@ static int32_t ReadPm10(struct SensorQuantity *quant)
uint32_t result; uint32_t result;
if (quant->sdev->done->read != NULL) { if (quant->sdev->done->read != NULL) {
uint16_t checksum = 0; uint16_t checksum = 0;
UserMutexObtain(buff_lock, WAITING_FOREVER); PrivMutexObtain(&buff_lock);
for (uint i = 0; i < 30; i++) for (uint i = 0; i < 30; i++)
checksum += quant->sdev->buffer[i]; checksum += quant->sdev->buffer[i];

View File

@ -52,7 +52,7 @@ static int SensorDeviceRead(struct SensorDevice *sdev, size_t len)
if (PrivWrite(sdev->fd, NULL, 0) != 1) if (PrivWrite(sdev->fd, NULL, 0) != 1)
return -1; return -1;
UserTaskDelay(50); PrivTaskDelay(50);
if (PrivRead(sdev->fd, sdev->buffer, len) != 1) if (PrivRead(sdev->fd, sdev->buffer, len) != 1)
return -1; return -1;

View File

@ -9,7 +9,7 @@ config SENSOR_D124
default "d124_1" default "d124_1"
config SENSOR_QUANTITY_D124_VOICE config SENSOR_QUANTITY_D124_VOICE
string "D124 quantity PM1.0 name" string "D124 quantity voice name"
default "voice_1" default "voice_1"
if ADD_XIUOS_FETURES if ADD_XIUOS_FETURES

View File

@ -21,8 +21,8 @@
#include <sensor.h> #include <sensor.h>
static struct SensorDevice d124; static struct SensorDevice d124;
static int32_t active_task_id; static pthread_t active_task_id;
static int buff_lock; static pthread_mutex_t buff_lock;
static struct SensorProductInfo info = static struct SensorProductInfo info =
{ {
@ -35,13 +35,14 @@ static struct SensorProductInfo info =
* @description: Read sensor task * @description: Read sensor task
* @param sdev - sensor device pointer * @param sdev - sensor device pointer
*/ */
static void ReadTask(struct SensorDevice *sdev) static void *ReadTask(void *parameter)
{ {
struct SensorDevice *sdev = (struct SensorDevice *)parameter;
while (1) { while (1) {
UserMutexObtain(buff_lock, WAITING_FOREVER); PrivMutexObtain(&buff_lock);
sdev->done->read(sdev, 5); sdev->done->read(sdev, 5);
UserMutexAbandon(buff_lock); PrivMutexAbandon(&buff_lock);
UserTaskDelay(750); PrivTaskDelay(750);
} }
} }
@ -53,8 +54,9 @@ static void ReadTask(struct SensorDevice *sdev)
static int SensorDeviceOpen(struct SensorDevice *sdev) static int SensorDeviceOpen(struct SensorDevice *sdev)
{ {
int result = 0; int result = 0;
pthread_attr_t attr;
buff_lock = UserMutexCreate(); PrivMutexCreate(&buff_lock, 0);
sdev->fd = PrivOpen(SENSOR_DEVICE_D124_DEV, O_RDWR); sdev->fd = PrivOpen(SENSOR_DEVICE_D124_DEV, O_RDWR);
@ -76,17 +78,11 @@ static int SensorDeviceOpen(struct SensorDevice *sdev)
ioctl_cfg.args = &cfg; ioctl_cfg.args = &cfg;
result = PrivIoctl(sdev->fd, OPE_INT, &ioctl_cfg); result = PrivIoctl(sdev->fd, OPE_INT, &ioctl_cfg);
UtaskType active_task; attr.schedparam.sched_priority = 20;
const char name[NAME_NUM_MAX] = "d124_task"; attr.stacksize = 2048;
strncpy(active_task.name, name, strlen(name)); PrivTaskCreate(&active_task_id, &attr, &ReadTask, sdev);
active_task.func_entry = ReadTask; PrivTaskStartup(&active_task_id);
active_task.func_param = sdev;
active_task.prio = KTASK_PRIORITY_MAX/2;
active_task.stack_size = 2048;
active_task_id = UserTaskCreate(active_task);
result = UserTaskStartup(active_task_id);
return result; return result;
} }
@ -98,8 +94,8 @@ static int SensorDeviceOpen(struct SensorDevice *sdev)
*/ */
static int SensorDeviceClose(struct SensorDevice *sdev) static int SensorDeviceClose(struct SensorDevice *sdev)
{ {
UserTaskDelete(active_task_id); PrivTaskDelete(active_task_id, 0);
UserMutexDelete(buff_lock); PrivMutexDelete(&buff_lock);
return 0; return 0;
} }
@ -117,7 +113,7 @@ static int SensorDeviceRead(struct SensorDevice *sdev, size_t len)
PrivRead(sdev->fd, &tmp, 1); PrivRead(sdev->fd, &tmp, 1);
if ((tmp == 0xAA) || (timeout >= 1000)) if ((tmp == 0xAA) || (timeout >= 1000))
break; break;
UserTaskDelay(10); PrivTaskDelay(10);
++timeout; ++timeout;
} }
@ -176,7 +172,7 @@ static int32_t ReadVoice(struct SensorQuantity *quant)
uint32_t result; uint32_t result;
if (quant->sdev->done->read != NULL) { if (quant->sdev->done->read != NULL) {
UserMutexObtain(buff_lock, WAITING_FOREVER); PrivMutexObtain(&buff_lock);
if (quant->sdev->buffer[3] == quant->sdev->buffer[1] + quant->sdev->buffer[2]) { if (quant->sdev->buffer[3] == quant->sdev->buffer[1] + quant->sdev->buffer[2]) {
result = ((uint16_t)quant->sdev->buffer[1] << 8) + (uint16_t)quant->sdev->buffer[2]; result = ((uint16_t)quant->sdev->buffer[1] << 8) + (uint16_t)quant->sdev->buffer[2];

View File

@ -5,7 +5,7 @@ Import('rtconfig')
cwd = GetCurrentDir() cwd = GetCurrentDir()
DEPENDS = [""] DEPENDS = [""]
SOURCES = [] SOURCES = ['transform.c']
path = [cwd] path = [cwd]
objs = DefineGroup('transform', src = SOURCES, depend = DEPENDS,CPPPATH = path) objs = DefineGroup('transform', src = SOURCES, depend = DEPENDS,CPPPATH = path)
Return("objs") Return("objs")

View File

@ -30,26 +30,170 @@
#include <sys/time.h> #include <sys/time.h>
#include <errno.h> #include <errno.h>
#include <pthread.h> #include <pthread.h>
#include <pthread_internal.h>
#include <semaphore.h>
#include <sched.h> #include <sched.h>
#include <unistd.h> #include <unistd.h>
#include <dfs_poll.h> #include <dfs_poll.h>
#include <dfs_posix.h>
#include <dfs.h>
#include<sys/ioctl.h>
#ifdef RT_USING_POSIX_TERMIOS #ifdef RT_USING_POSIX_TERMIOS
#include <posix_termios.h> #include <posix_termios.h>
#endif #endif
#ifdef DRV_USING_OV2640 #ifdef DRV_USING_OV2640
#include <drv_ov2640.h> #include <drv_ov2640.h>
#endif #endif
#if defined(RT_USING_SAL) #if defined(RT_USING_SAL)&& defined (RT_USING_LWIP)
#include <netdb.h> #include <netdb.h>
#include <sys/socket.h> #include <sys/socket.h>
#else #elif defined RT_USING_LWIP
#include <lwip/netdb.h> #include <lwip/netdb.h>
#include <lwip/sockets.h> #include <lwip/sockets.h>
#endif /* RT_USING_SAL */ #endif /* RT_USING_SAL */
#ifdef BOARD_K210_EVB
#include <dmac.h>
#include <dmalock.h>
#endif
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
typedef signed char int8;
typedef signed short int16;
typedef signed int int32;
typedef unsigned char uint8;
typedef unsigned short uint16;
typedef unsigned int uint32;
#ifdef ARCH_CPU_64BIT
typedef signed long int64;
typedef unsigned long uint64;
#else
typedef signed long long int64;
typedef unsigned long long uint64;
#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
#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_t 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_t 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;
};
/**********************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 #ifdef __cplusplus

View File

@ -18,7 +18,8 @@
* @date: 2020/4/20 * @date: 2020/4/20
* *
*/ */
#include<string.h> #include <string.h>
#include <stdio.h>
#include "include/pthread.h" #include "include/pthread.h"
int pthread_create(pthread_t *thread, const pthread_attr_t *attr, int pthread_create(pthread_t *thread, const pthread_attr_t *attr,
@ -26,12 +27,22 @@ int pthread_create(pthread_t *thread, const pthread_attr_t *attr,
{ {
int ret ; int ret ;
int pid ; int pid ;
char task_name[32] = {0};
static int utask_id = 0;
UtaskType task ; UtaskType task ;
if (NULL == attr) {
task.prio = KTASK_PRIORITY_MAX / 2;
task.stack_size = 1024 ;
} else {
task.prio = attr->schedparam.sched_priority ;
task.stack_size = attr->stacksize ;
}
task.func_entry = start_routine ; task.func_entry = start_routine ;
task.func_param = arg ; task.func_param = arg;
memcpy(task.name , "utask", 6); snprintf(task_name, sizeof(task_name) - 1, "utask%02d",utask_id++);
task.prio = 20 ; memcpy(task.name , task_name, sizeof(task_name) - 1);
task.stack_size = 1024 ;
pid = UserTaskCreate(task); pid = UserTaskCreate(task);
if (pid < 0) if (pid < 0)

View File

@ -24,9 +24,8 @@
int sem_init(sem_t *sem, int pshared, unsigned int value) int sem_init(sem_t *sem, int pshared, unsigned int value)
{ {
int32 ret = 0; *sem = UserSemaphoreCreate(value);
ret = UserSemaphoreCreate(value); if (*sem < 0) {
if (ret < 0) {
return -1; return -1;
} }

View File

@ -22,6 +22,7 @@
#ifndef XS_USER_API_H #ifndef XS_USER_API_H
#define XS_USER_API_H #define XS_USER_API_H
#include <xiuos.h>
#include <xsconfig.h> #include <xsconfig.h>
#include <stddef.h> #include <stddef.h>
#include <stdint.h> #include <stdint.h>

View File

@ -1748,6 +1748,15 @@ config ARCH_BOARD_STM32F4_DISCOVERY
---help--- ---help---
STMicro STM32F4-Discovery board based on the STMicro STM32F407VGT6 MCU. STMicro STM32F4-Discovery board based on the STMicro STM32F407VGT6 MCU.
config ARCH_BOARD_STM32F4_AIIT
bool "STMicro STM32F4-AIIT board"
depends on ARCH_CHIP_STM32F407VG
select ARCH_HAVE_LEDS
select ARCH_HAVE_BUTTONS
select ARCH_HAVE_IRQBUTTONS
---help---
STMicro STM32F4-Discovery board based on the STMicro STM32F407VGT6 MCU.
config ARCH_BOARD_STM32F411E_DISCO config ARCH_BOARD_STM32F411E_DISCO
bool "STMicro STM32F411E-Discovery board" bool "STMicro STM32F411E-Discovery board"
depends on ARCH_CHIP_STM32F411VE depends on ARCH_CHIP_STM32F411VE
@ -2415,6 +2424,7 @@ config ARCH_BOARD
default "stm32f3discovery" if ARCH_BOARD_STM32F3_DISCOVERY default "stm32f3discovery" if ARCH_BOARD_STM32F3_DISCOVERY
default "stm32f334-disco" if ARCH_BOARD_STM32F334_DISCO default "stm32f334-disco" if ARCH_BOARD_STM32F334_DISCO
default "stm32f4discovery" if ARCH_BOARD_STM32F4_DISCOVERY default "stm32f4discovery" if ARCH_BOARD_STM32F4_DISCOVERY
default "aiit-arm32-board" if ARCH_BOARD_STM32F4_AIIT
default "stm32f411e-disco" if ARCH_BOARD_STM32F411E_DISCO default "stm32f411e-disco" if ARCH_BOARD_STM32F411E_DISCO
default "stm32f429i-disco" if ARCH_BOARD_STM32F429I_DISCO default "stm32f429i-disco" if ARCH_BOARD_STM32F429I_DISCO
default "stm32f746g-disco" if ARCH_BOARD_STM32F746G_DISCO default "stm32f746g-disco" if ARCH_BOARD_STM32F746G_DISCO
@ -2804,6 +2814,9 @@ endif
if ARCH_BOARD_STM32H747I_DISCO if ARCH_BOARD_STM32H747I_DISCO
source "boards/arm/stm32h7/stm32h747i-disco/Kconfig" source "boards/arm/stm32h7/stm32h747i-disco/Kconfig"
endif endif
if ARCH_BOARD_STM32F4_AIIT
source "boards/arm/stm32/aiit-arm32-board/Kconfig"
endif
if ARCH_BOARD_NUCLEO_H743ZI if ARCH_BOARD_NUCLEO_H743ZI
source "boards/arm/stm32h7/nucleo-h743zi/Kconfig" source "boards/arm/stm32h7/nucleo-h743zi/Kconfig"
endif endif

View File

@ -756,6 +756,9 @@ boards/arm/stm32/stm32f103-minimum
boards/arm/stm32/stm32f4discovery boards/arm/stm32/stm32f4discovery
STMicro STM32F4-Discovery board based on the STMicro STM32F407VGT6 MCU. STMicro STM32F4-Discovery board based on the STMicro STM32F407VGT6 MCU.
boards/arm/stm32/aiit-arm32-board
STMicro STM32F4-AIIT board based on the STMicro STM32F407VGT6 MCU.
boards/arm/stm32/stm32f411e-disco boards/arm/stm32/stm32f411e-disco
This is a minimal configuration that supports low-level test of the This is a minimal configuration that supports low-level test of the
STMicro STM32F411E-Discovery Board. STMicro STM32F411E-Discovery Board.

View File

@ -12,6 +12,7 @@ CONFIG_BOARD_K210_EVB=y
# RT-Thread Kernel # RT-Thread Kernel
# #
CONFIG_RT_NAME_MAX=8 CONFIG_RT_NAME_MAX=8
# CONFIG_RT_USING_BIG_ENDIAN is not set
# CONFIG_RT_USING_ARCH_DATA_TYPE is not set # CONFIG_RT_USING_ARCH_DATA_TYPE is not set
CONFIG_RT_USING_SMP=y CONFIG_RT_USING_SMP=y
CONFIG_RT_CPUS_NR=2 CONFIG_RT_CPUS_NR=2
@ -20,12 +21,13 @@ CONFIG_RT_ALIGN_SIZE=8
CONFIG_RT_THREAD_PRIORITY_32=y CONFIG_RT_THREAD_PRIORITY_32=y
# CONFIG_RT_THREAD_PRIORITY_256 is not set # CONFIG_RT_THREAD_PRIORITY_256 is not set
CONFIG_RT_THREAD_PRIORITY_MAX=32 CONFIG_RT_THREAD_PRIORITY_MAX=32
CONFIG_RT_TICK_PER_SECOND=1000 CONFIG_RT_TICK_PER_SECOND=100
CONFIG_RT_USING_OVERFLOW_CHECK=y CONFIG_RT_USING_OVERFLOW_CHECK=y
CONFIG_RT_USING_HOOK=y CONFIG_RT_USING_HOOK=y
CONFIG_RT_USING_IDLE_HOOK=y CONFIG_RT_USING_IDLE_HOOK=y
CONFIG_RT_IDLE_HOOK_LIST_SIZE=4 CONFIG_RT_IDLE_HOOK_LIST_SIZE=4
CONFIG_IDLE_THREAD_STACK_SIZE=4096 CONFIG_IDLE_THREAD_STACK_SIZE=4096
CONFIG_SYSTEM_THREAD_STACK_SIZE=4096
# CONFIG_RT_USING_TIMER_SOFT is not set # CONFIG_RT_USING_TIMER_SOFT is not set
# #
@ -33,6 +35,7 @@ CONFIG_IDLE_THREAD_STACK_SIZE=4096
# #
# CONFIG_RT_KSERVICE_USING_STDLIB is not set # CONFIG_RT_KSERVICE_USING_STDLIB is not set
# CONFIG_RT_KSERVICE_USING_TINY_SIZE is not set # CONFIG_RT_KSERVICE_USING_TINY_SIZE is not set
# CONFIG_RT_USING_ASM_MEMCPY is not set
CONFIG_RT_DEBUG=y CONFIG_RT_DEBUG=y
CONFIG_RT_DEBUG_COLOR=y CONFIG_RT_DEBUG_COLOR=y
CONFIG_RT_DEBUG_INIT_CONFIG=y CONFIG_RT_DEBUG_INIT_CONFIG=y
@ -79,6 +82,7 @@ CONFIG_RT_USING_DEVICE=y
CONFIG_RT_USING_CONSOLE=y CONFIG_RT_USING_CONSOLE=y
CONFIG_RT_CONSOLEBUF_SIZE=128 CONFIG_RT_CONSOLEBUF_SIZE=128
CONFIG_RT_CONSOLE_DEVICE_NAME="uarths" CONFIG_RT_CONSOLE_DEVICE_NAME="uarths"
# CONFIG_RT_PRINTF_LONGLONG is not set
CONFIG_RT_VER_NUM=0x40004 CONFIG_RT_VER_NUM=0x40004
CONFIG_ARCH_CPU_64BIT=y CONFIG_ARCH_CPU_64BIT=y
# CONFIG_RT_USING_CPU_FFS is not set # CONFIG_RT_USING_CPU_FFS is not set
@ -99,25 +103,26 @@ CONFIG_RT_MAIN_THREAD_PRIORITY=10
# #
# C++ features # C++ features
# #
# CONFIG_RT_USING_CPLUSPLUS is not set CONFIG_RT_USING_CPLUSPLUS=y
# CONFIG_RT_USING_CPLUSPLUS11 is not set
# #
# Command shell # Command shell
# #
CONFIG_RT_USING_FINSH=y CONFIG_RT_USING_FINSH=y
CONFIG_RT_USING_MSH=y
CONFIG_FINSH_USING_MSH=y
CONFIG_FINSH_THREAD_NAME="tshell" CONFIG_FINSH_THREAD_NAME="tshell"
CONFIG_FINSH_THREAD_PRIORITY=20
CONFIG_FINSH_THREAD_STACK_SIZE=16384
CONFIG_FINSH_USING_HISTORY=y CONFIG_FINSH_USING_HISTORY=y
CONFIG_FINSH_HISTORY_LINES=5 CONFIG_FINSH_HISTORY_LINES=5
CONFIG_FINSH_USING_SYMTAB=y CONFIG_FINSH_USING_SYMTAB=y
CONFIG_FINSH_CMD_SIZE=80
CONFIG_MSH_USING_BUILT_IN_COMMANDS=y
CONFIG_FINSH_USING_DESCRIPTION=y CONFIG_FINSH_USING_DESCRIPTION=y
# CONFIG_FINSH_ECHO_DISABLE_DEFAULT is not set # CONFIG_FINSH_ECHO_DISABLE_DEFAULT is not set
CONFIG_FINSH_THREAD_PRIORITY=20
CONFIG_FINSH_THREAD_STACK_SIZE=16384
CONFIG_FINSH_CMD_SIZE=80
# CONFIG_FINSH_USING_AUTH is not set # CONFIG_FINSH_USING_AUTH is not set
CONFIG_FINSH_USING_MSH=y
CONFIG_FINSH_USING_MSH_DEFAULT=y
CONFIG_FINSH_USING_MSH_ONLY=y
CONFIG_FINSH_ARG_MAX=10 CONFIG_FINSH_ARG_MAX=10
# #
@ -151,6 +156,7 @@ CONFIG_RT_DFS_ELM_DRIVES=2
CONFIG_RT_DFS_ELM_MAX_SECTOR_SIZE=4096 CONFIG_RT_DFS_ELM_MAX_SECTOR_SIZE=4096
# CONFIG_RT_DFS_ELM_USE_ERASE is not set # CONFIG_RT_DFS_ELM_USE_ERASE is not set
CONFIG_RT_DFS_ELM_REENTRANT=y CONFIG_RT_DFS_ELM_REENTRANT=y
CONFIG_RT_DFS_ELM_MUTEX_TIMEOUT=3000
CONFIG_RT_USING_DFS_DEVFS=y CONFIG_RT_USING_DFS_DEVFS=y
# CONFIG_RT_USING_DFS_ROMFS is not set # CONFIG_RT_USING_DFS_ROMFS is not set
# CONFIG_RT_USING_DFS_RAMFS is not set # CONFIG_RT_USING_DFS_RAMFS is not set
@ -165,6 +171,8 @@ CONFIG_RT_USING_SYSTEM_WORKQUEUE=y
CONFIG_RT_SYSTEM_WORKQUEUE_STACKSIZE=2048 CONFIG_RT_SYSTEM_WORKQUEUE_STACKSIZE=2048
CONFIG_RT_SYSTEM_WORKQUEUE_PRIORITY=23 CONFIG_RT_SYSTEM_WORKQUEUE_PRIORITY=23
CONFIG_RT_USING_SERIAL=y CONFIG_RT_USING_SERIAL=y
CONFIG_RT_USING_SERIAL_V1=y
# CONFIG_RT_USING_SERIAL_V2 is not set
CONFIG_RT_SERIAL_USING_DMA=y CONFIG_RT_SERIAL_USING_DMA=y
CONFIG_RT_SERIAL_RB_BUFSZ=64 CONFIG_RT_SERIAL_RB_BUFSZ=64
# CONFIG_RT_USING_CAN is not set # CONFIG_RT_USING_CAN is not set
@ -179,7 +187,9 @@ CONFIG_RT_USING_PIN=y
# CONFIG_RT_USING_MTD_NOR is not set # CONFIG_RT_USING_MTD_NOR is not set
# CONFIG_RT_USING_MTD_NAND is not set # CONFIG_RT_USING_MTD_NAND is not set
# CONFIG_RT_USING_PM is not set # CONFIG_RT_USING_PM is not set
# CONFIG_RT_USING_RTC is not set CONFIG_RT_USING_RTC=y
# CONFIG_RT_USING_ALARM is not set
# CONFIG_RT_USING_SOFT_RTC is not set
# CONFIG_RT_USING_SDIO is not set # CONFIG_RT_USING_SDIO is not set
CONFIG_RT_USING_SPI=y CONFIG_RT_USING_SPI=y
# CONFIG_RT_USING_QSPI is not set # CONFIG_RT_USING_QSPI is not set
@ -244,8 +254,9 @@ CONFIG_RT_USING_POSIX=y
# CONFIG_RT_USING_POSIX_TERMIOS is not set # CONFIG_RT_USING_POSIX_TERMIOS is not set
# CONFIG_RT_USING_POSIX_GETLINE is not set # CONFIG_RT_USING_POSIX_GETLINE is not set
# CONFIG_RT_USING_POSIX_AIO is not set # CONFIG_RT_USING_POSIX_AIO is not set
CONFIG_RT_LIBC_USING_TIME=y
# CONFIG_RT_USING_MODULE is not set # CONFIG_RT_USING_MODULE is not set
CONFIG_RT_LIBC_FIXED_TIMEZONE=8 CONFIG_RT_LIBC_DEFAULT_TIMEZONE=8
# #
# Network # Network
@ -261,8 +272,7 @@ CONFIG_RT_USING_SAL=y
# protocol stack implement # protocol stack implement
# #
CONFIG_SAL_USING_LWIP=y CONFIG_SAL_USING_LWIP=y
# CONFIG_SAL_USING_POSIX is not set CONFIG_SAL_USING_POSIX=y
CONFIG_SAL_SOCKETS_NUM=16
# #
# Network interface device # Network interface device
@ -283,6 +293,7 @@ CONFIG_NETDEV_IPV6=0
CONFIG_RT_USING_LWIP=y CONFIG_RT_USING_LWIP=y
# CONFIG_RT_USING_LWIP141 is not set # CONFIG_RT_USING_LWIP141 is not set
CONFIG_RT_USING_LWIP202=y CONFIG_RT_USING_LWIP202=y
# CONFIG_RT_USING_LWIP203 is not set
# CONFIG_RT_USING_LWIP212 is not set # CONFIG_RT_USING_LWIP212 is not set
# CONFIG_RT_USING_LWIP_IPV6 is not set # CONFIG_RT_USING_LWIP_IPV6 is not set
CONFIG_RT_LWIP_MEM_ALIGNMENT=8 CONFIG_RT_LWIP_MEM_ALIGNMENT=8
@ -352,6 +363,7 @@ CONFIG_RT_LWIP_USING_PING=y
# CONFIG_RT_USING_RYM is not set # CONFIG_RT_USING_RYM is not set
# CONFIG_RT_USING_ULOG is not set # CONFIG_RT_USING_ULOG is not set
# CONFIG_RT_USING_UTEST is not set # CONFIG_RT_USING_UTEST is not set
# CONFIG_RT_USING_VAR_EXPORT is not set
# CONFIG_RT_USING_RT_LINK is not set # CONFIG_RT_USING_RT_LINK is not set
# #
@ -363,9 +375,15 @@ CONFIG_RT_LWIP_USING_PING=y
# Board Drivers Config # Board Drivers Config
# #
CONFIG_BSP_USING_UART_HS=y CONFIG_BSP_USING_UART_HS=y
#
# General Purpose UARTs
#
CONFIG_BSP_USING_UART1=y CONFIG_BSP_USING_UART1=y
CONFIG_BSP_UART1_TXD_PIN=20 CONFIG_BSP_UART1_TXD_PIN=20
CONFIG_BSP_UART1_RXD_PIN=21 CONFIG_BSP_UART1_RXD_PIN=21
CONFIG_BSP_UART1_RTS_PIN=-1
CONFIG_BSP_UART1_CTS_PIN=-1
# CONFIG_BSP_USING_UART2 is not set # CONFIG_BSP_USING_UART2 is not set
# CONFIG_BSP_USING_UART3 is not set # CONFIG_BSP_USING_UART3 is not set
# CONFIG_BSP_USING_I2C1 is not set # CONFIG_BSP_USING_I2C1 is not set
@ -385,6 +403,13 @@ CONFIG_BSP_LCD_CS_PIN=36
CONFIG_BSP_LCD_WR_PIN=39 CONFIG_BSP_LCD_WR_PIN=39
CONFIG_BSP_LCD_DC_PIN=38 CONFIG_BSP_LCD_DC_PIN=38
CONFIG_BSP_LCD_RST_PIN=37 CONFIG_BSP_LCD_RST_PIN=37
CONFIG_BSP_LCD_BACKLIGHT_PIN=-1
CONFIG_BSP_LCD_BACKLIGHT_ACTIVE_LOW=y
# CONFIG_BSP_LCD_BACKLIGHT_ACTIVE_HIGH is not set
CONFIG_BSP_LCD_CLK_FREQ=20000000
# CONFIG_BSP_BOARD_KD233 is not set
# CONFIG_BSP_BOARD_K210_OPENMV_TEST is not set
CONFIG_BSP_BOARD_USER=y
CONFIG_BSP_LCD_X_MAX=240 CONFIG_BSP_LCD_X_MAX=240
CONFIG_BSP_LCD_Y_MAX=320 CONFIG_BSP_LCD_Y_MAX=320
CONFIG_BSP_USING_SDCARD=y CONFIG_BSP_USING_SDCARD=y
@ -401,6 +426,9 @@ CONFIG_BSP_DVP_CMOS_PWDN_PIN=44
CONFIG_BSP_DVP_CMOS_XCLK_PIN=46 CONFIG_BSP_DVP_CMOS_XCLK_PIN=46
CONFIG_BSP_DVP_CMOS_PCLK_PIN=47 CONFIG_BSP_DVP_CMOS_PCLK_PIN=47
CONFIG_BSP_DVP_CMOS_HREF_PIN=45 CONFIG_BSP_DVP_CMOS_HREF_PIN=45
CONFIG_RW007_SPIDEV_NAME="spi11"
CONFIG_RW007_INT_BUSY_PIN=7
CONFIG_RW007_RST_PIN=6
# #
# Kendryte SDK Config # Kendryte SDK Config
@ -410,7 +438,10 @@ CONFIG_PKG_KENDRYTE_SDK_VERNUM=0x0055
# #
# More Drivers # More Drivers
# #
# CONFIG_PKG_USING_RW007 is not set CONFIG_PKG_USING_RW007=y
CONFIG_RW007_NOT_USE_EXAMPLE_DRIVERS=y
# CONFIG_RW007_USING_STM32_DRIVERS is not set
CONFIG_RW007_SPI_MAX_HZ=20000000
CONFIG_DRV_USING_OV2640=y CONFIG_DRV_USING_OV2640=y
# #
@ -443,12 +474,23 @@ CONFIG_MAIN_KTASK_STACK_SIZE=1024
# #
# knowing app # knowing app
# #
CONFIG_APPLICATION_KNOWING=y
CONFIG_APP_MNIST=y
CONFIG_FACE_DETECT=y CONFIG_FACE_DETECT=y
# CONFIG_INSTRUSION_DETECT is not set
# CONFIG_HELMET_DETECT is not set
# CONFIG_IRIS_ML_DEMO is not set
# #
# sensor app # sensor app
# #
# CONFIG_APPLICATION_SENSOR is not set CONFIG_APPLICATION_SENSOR=y
# CONFIG_APPLICATION_SENSOR_CO2 is not set
# CONFIG_APPLICATION_SENSOR_PM1_0 is not set
CONFIG_APPLICATION_SENSOR_VOICE=y
CONFIG_APPLICATION_SENSOR_VOICE_D124=y
# CONFIG_APPLICATION_SENSOR_HUMIDITY is not set
# CONFIG_APPLICATION_SENSOR_TEMPERATURE is not set
# #
# Framework # Framework
@ -460,19 +502,36 @@ CONFIG_ADD_XIUOS_FETURES=y
CONFIG_SUPPORT_SENSOR_FRAMEWORK=y CONFIG_SUPPORT_SENSOR_FRAMEWORK=y
# CONFIG_SENSOR_CO2 is not set # CONFIG_SENSOR_CO2 is not set
# CONFIG_SENSOR_PM is not set # CONFIG_SENSOR_PM is not set
# CONFIG_SENSOR_VOICE is not set CONFIG_SENSOR_VOICE=y
CONFIG_SENSOR_D124=y
CONFIG_SENSOR_DEVICE_D124="d124_1"
CONFIG_SENSOR_QUANTITY_D124_VOICE="voice_1"
# CONFIG_SENSOR_D124_DRIVER_EXTUART is not set
CONFIG_SENSOR_DEVICE_D124_DEV="/dev/uar2"
# CONFIG_SENSOR_TEMPERATURE is not set # CONFIG_SENSOR_TEMPERATURE is not set
# CONFIG_SENSOR_HUMIDITY is not set # CONFIG_SENSOR_HUMIDITY is not set
# CONFIG_SUPPORT_CONNECTION_FRAMEWORK is not set # CONFIG_SUPPORT_CONNECTION_FRAMEWORK is not set
CONFIG_SUPPORT_KNOWING_FRAMEWORK=y CONFIG_SUPPORT_KNOWING_FRAMEWORK=y
# CONFIG_USING_TENSORFLOWLITEMICRO is not set CONFIG_USING_TENSORFLOWLITEMICRO=y
CONFIG_USING_TENSORFLOWLITEMICRO_NORMAL=y
# CONFIG_USING_TENSORFLOWLITEMICRO_CMSISNN is not set
# CONFIG_USING_TENSORFLOWLITEMICRO_DEMOAPP is not set
CONFIG_USING_KPU_POSTPROCESSING=y CONFIG_USING_KPU_POSTPROCESSING=y
CONFIG_USING_YOLOV2=y CONFIG_USING_YOLOV2=y
# CONFIG_USING_KNOWING_FILTER is not set
# CONFIG_USING_OTA_MODEL is not set
# CONFIG_SUPPORT_CONTROL_FRAMEWORK is not set # CONFIG_SUPPORT_CONTROL_FRAMEWORK is not set
# #
# app lib # Security
#
# CONFIG_CRYPTO is not set
#
# lib
# #
CONFIG_APP_SELECT_NEWLIB=y CONFIG_APP_SELECT_NEWLIB=y
# CONFIG_APP_SELECT_OTHER_LIB is not set # CONFIG_APP_SELECT_OTHER_LIB is not set
CONFIG_LIB_USING_CJSON=y
# CONFIG_LIB_USING_QUEUE is not set
CONFIG___STACKSIZE__=4096 CONFIG___STACKSIZE__=4096

View File

@ -1,3 +1,11 @@
/*
* @Author: your name
* @Date: 2021-10-11 22:04:25
* @LastEditTime: 2021-10-14 11:12:52
* @LastEditors: Please set LastEditors
* @Description: In User Settings Edit
* @FilePath: \xiuos\Ubiquitous\RT_Thread\bsp\k210\applications\main.c
*/
/* /*
* Copyright (c) 2020 AIIT XUOS Lab * Copyright (c) 2020 AIIT XUOS Lab
* XiUOS is licensed under Mulan PSL v2. * XiUOS is licensed under Mulan PSL v2.
@ -21,14 +29,13 @@ int main(void)
rt_thread_mdelay(100); rt_thread_mdelay(100);
char info1[25] ={0}; char info1[25] ={0};
char info2[25] ={0}; char info2[25] ={0};
sprintf(info1,"xuos-intelligence k210 build "); sprintf(info1,"xuos-intelligence k210 ");
sprintf(info2,"%s %s",__DATE__,__TIME__); sprintf(info2,"build %s %s",__DATE__,__TIME__);
printf("%s %s \n",info1,info2); printf("%s %s \n",info1,info2);
#ifdef BSP_USING_LCD #ifdef BSP_USING_LCD
#include<drv_lcd.h> #include<drv_lcd.h>
lcd_clear(PINK); lcd_show_string(0,60,24,info1);
lcd_draw_string(70,100,info1,BLACK); lcd_show_string(0,90,24,info2);
lcd_draw_string(70,120,info2,BLACK);
#endif #endif
while(1) while(1)
{ {

View File

@ -21,10 +21,10 @@
static int g_fd = 0; static int g_fd = 0;
static _ioctl_shoot_para shoot_para_t = {0}; static _ioctl_shoot_para shoot_para_t = {0};
extern void lcd_show_image(int x, int y, int wide, int height,const rt_uint8_t *buf);
extern void lcd_draw_picture(uint16_t x1, uint16_t y1, uint16_t width, uint16_t height, uint32_t *ptr);
void ov2640_test(int argc, char **argv) void ov2640_test(int argc, char **argv)
{ {
extern void lcd_draw_picture(uint16_t x1, uint16_t y1, uint16_t width, uint16_t height, uint32_t *ptr);
g_fd = open("/dev/ov2640",O_RDONLY); g_fd = open("/dev/ov2640",O_RDONLY);
if(g_fd < 0) if(g_fd < 0)
@ -71,7 +71,7 @@ void ov2640_test(int argc, char **argv)
close(g_fd); close(g_fd);
return; return;
} }
lcd_draw_picture(0, 0, 320, 240, rgbbuffer); lcd_show_image(0, 0, 320, 240, rgbbuffer);
rt_thread_mdelay(100); rt_thread_mdelay(100);
printf("the lcd has shown the image \n"); printf("the lcd has shown the image \n");
rt_free(rgbbuffer); rt_free(rgbbuffer);
@ -82,7 +82,6 @@ MSH_CMD_EXPORT(ov2640_test,lcd show camera shot image);
void lcd_show_ov2640_thread(uint32_t* rgbbuffer) void lcd_show_ov2640_thread(uint32_t* rgbbuffer)
{ {
extern void lcd_draw_picture(uint16_t x1, uint16_t y1, uint16_t width, uint16_t height, uint32_t *ptr);
rt_err_t ret = 0; rt_err_t ret = 0;
while(1) while(1)
{ {
@ -94,8 +93,9 @@ void lcd_show_ov2640_thread(uint32_t* rgbbuffer)
rt_free(rgbbuffer); rt_free(rgbbuffer);
return; return;
} }
//lcd_show_image(0, 0, 320, 240, rgbbuffer);
lcd_draw_picture(0, 0, 320, 240, rgbbuffer); lcd_draw_picture(0, 0, 320, 240, rgbbuffer);
rt_thread_mdelay(2); rt_thread_mdelay(1);
} }
} }

View File

@ -5,6 +5,7 @@ config BSP_USING_UART_HS
default y default y
menu "General Purpose UARTs"
menuconfig BSP_USING_UART1 menuconfig BSP_USING_UART1
bool "Enable UART1" bool "Enable UART1"
default n default n
@ -15,6 +16,12 @@ menuconfig BSP_USING_UART1
config BSP_UART1_RXD_PIN config BSP_UART1_RXD_PIN
int "uart1 RXD pin number" int "uart1 RXD pin number"
default 21 default 21
config BSP_UART1_RTS_PIN
int "uart1 RTS pin number (-1 for not used)"
default -1
config BSP_UART1_CTS_PIN
int "uart1 CTS pin number (-1 for not used)"
default -1
endif endif
menuconfig BSP_USING_UART2 menuconfig BSP_USING_UART2
@ -27,6 +34,12 @@ menuconfig BSP_USING_UART2
config BSP_UART2_RXD_PIN config BSP_UART2_RXD_PIN
int "uart2 RXD pin number" int "uart2 RXD pin number"
default 27 default 27
config BSP_UART2_RTS_PIN
int "uart2 RTS pin number (-1 for not used)"
default -1
config BSP_UART2_CTS_PIN
int "uart2 CTS pin number (-1 for not used)"
default -1
endif endif
menuconfig BSP_USING_UART3 menuconfig BSP_USING_UART3
@ -39,7 +52,14 @@ menuconfig BSP_USING_UART3
config BSP_UART3_RXD_PIN config BSP_UART3_RXD_PIN
int "uart3 RXD pin number" int "uart3 RXD pin number"
default 23 default 23
config BSP_UART3_RTS_PIN
int "uart3 RTS pin number (-1 for not used)"
default -1
config BSP_UART3_CTS_PIN
int "uart3 CTS pin number (-1 for not used)"
default -1
endif endif
endmenu
config BSP_USING_I2C1 config BSP_USING_I2C1
bool "Enable I2C1 (GPIO0/1)" bool "Enable I2C1 (GPIO0/1)"
@ -119,9 +139,40 @@ if BSP_USING_LCD
config BSP_LCD_DC_PIN config BSP_LCD_DC_PIN
int "DC pin number of 8080 interface" int "DC pin number of 8080 interface"
default 38 default 38
config BSP_LCD_RST_PIN config BSP_LCD_RST_PIN
int "RST pin number of 8080 interface" int "RESET pin number of 8080 interface (-1 for not used)"
default 37 default 37
config BSP_LCD_BACKLIGHT_PIN
int "Backlight control pin number (-1 for not used)"
default -1
choice
prompt "backlight active polarity"
default BSP_LCD_BACKLIGHT_ACTIVE_LOW
config BSP_LCD_BACKLIGHT_ACTIVE_LOW
bool "lcd backlight on low level"
config BSP_LCD_BACKLIGHT_ACTIVE_HIGH
bool "lcd_backlight on high level"
endchoice
config BSP_LCD_CLK_FREQ
int "Lcd max clk frequency"
default 15000000
choice
prompt "lcd scan direction"
default BSP_BOARD_KD233
config BSP_BOARD_KD233
bool "board_kd233 lcd scan: DIR_YX_RLUD"
config BSP_BOARD_K210_OPENMV_TEST
bool "board_k210_openmv lcd scan: DIR_YX_LRUD"
config BSP_BOARD_USER
bool "board_user: user defined."
endchoice
config BSP_LCD_X_MAX config BSP_LCD_X_MAX
int "LCD Height" int "LCD Height"
default 240 default 240

View File

@ -5,28 +5,26 @@ from building import *
cwd = GetCurrentDir() cwd = GetCurrentDir()
drv_path = cwd+"/../../../rt-thread/bsp/k210/driver/" drv_path = cwd+"/../../../rt-thread/bsp/k210/driver/"
src = [ src = [
drv_path + 'board.c', 'board.c',
drv_path + 'heap.c', 'heap.c',
drv_path + 'drv_uart.c', drv_path + 'drv_uart.c',
drv_path + 'drv_interrupt.c', 'drv_interrupt.c',
'drv_io_config.c' 'drv_io_config.c',
'dmalock.c'
] ]
CPPPATH = [cwd,drv_path] CPPPATH = [cwd,drv_path]
if GetDepend('RT_USING_PIN'): if GetDepend('RT_USING_PIN'):
src += [drv_path + 'drv_gpio.c'] src += ['drv_gpio.c']
if GetDepend('RT_USING_HWTIMER'): if GetDepend('RT_USING_HWTIMER'):
src += [drv_path + 'drv_hw_timer.c'] src += [drv_path + 'drv_hw_timer.c']
if GetDepend('RT_USING_CPUTIME'):
src += [drv_path + 'drv_cputime.c']
if GetDepend('RT_USING_I2C'): if GetDepend('RT_USING_I2C'):
src += [drv_path + 'drv_i2c.c'] src += [drv_path + 'drv_i2c.c']
if GetDepend('RT_USING_SPI'): if GetDepend('RT_USING_SPI'):
src += [drv_path + 'drv_spi.c'] src += ['drv_spi.c']
if GetDepend('RT_USING_PWM'): if GetDepend('RT_USING_PWM'):
src += [drv_path + 'drv_pwm.c'] src += [drv_path + 'drv_pwm.c']
@ -42,6 +40,7 @@ if GetDepend('BSP_USING_DVP'):
if GetDepend('BSP_USING_LCD'): if GetDepend('BSP_USING_LCD'):
src += ['drv_lcd.c'] src += ['drv_lcd.c']
src += ['drv_mpylcd.c']
if GetDepend('PKG_USING_RW007'): if GetDepend('PKG_USING_RW007'):
src += ['rw007_port.c'] src += ['rw007_port.c']

View File

@ -6,7 +6,6 @@
* Change Logs: * Change Logs:
* Date Author Notes * Date Author Notes
* 2019-03-19 ZYH first version * 2019-03-19 ZYH first version
* 2021-01-28 tianchunyu Modify macro definitions
*/ */
#include <rtthread.h> #include <rtthread.h>
@ -25,6 +24,17 @@ static struct io_config
const char * func_name; const char * func_name;
} io_config[] = } io_config[] =
{ {
#ifdef BSP_USING_LCD
IOCONFIG(BSP_LCD_CS_PIN, FUNC_SPI0_SS0), /* LCD CS PIN */
IOCONFIG(BSP_LCD_WR_PIN, FUNC_SPI0_SCLK), /* LCD WR PIN */
IOCONFIG(BSP_LCD_DC_PIN, HS_GPIO(LCD_DC_PIN)), /* LCD DC PIN */
#if BSP_LCD_RST_PIN >= 0
IOCONFIG(BSP_LCD_RST_PIN, HS_GPIO(LCD_RST_PIN)), /* LCD RESET PIN */
#endif
#if BSP_LCD_BACKLIGHT_PIN >= 0
IOCONFIG(BSP_LCD_BACKLIGHT_PIN, HS_GPIO(LCD_BACKLIGHT_PIN)), /* LCD BACKLIGHT PIN */
#endif
#endif
#ifdef BSP_USING_DVP #ifdef BSP_USING_DVP
IOCONFIG(BSP_DVP_SCCB_SDA_PIN, FUNC_SCCB_SDA), IOCONFIG(BSP_DVP_SCCB_SDA_PIN, FUNC_SCCB_SDA),
@ -37,13 +47,6 @@ static struct io_config
IOCONFIG(BSP_DVP_CMOS_HREF_PIN, FUNC_CMOS_HREF), IOCONFIG(BSP_DVP_CMOS_HREF_PIN, FUNC_CMOS_HREF),
#endif #endif
#if 0 //here is a drv lcd bug now don't know why
IOCONFIG(BSP_LCD_CS_PIN, FUNC_SPI0_SS3), /* LCD CS PIN */
IOCONFIG(BSP_LCD_WR_PIN, FUNC_SPI0_SCLK), /* LCD WR PIN */
IOCONFIG(BSP_LCD_DC_PIN, FUNC_GPIOHS2), /* LCD DC PIN */
IOCONFIG(BSP_LCD_RST_PIN,FUNC_GPIOHS3), /* LCD DC PIN */
#endif
#ifdef BSP_USING_SPI1 #ifdef BSP_USING_SPI1
IOCONFIG(BSP_SPI1_CLK_PIN, FUNC_SPI1_SCLK), IOCONFIG(BSP_SPI1_CLK_PIN, FUNC_SPI1_SCLK),
IOCONFIG(BSP_SPI1_D0_PIN, FUNC_SPI1_D0), IOCONFIG(BSP_SPI1_D0_PIN, FUNC_SPI1_D0),
@ -69,14 +72,72 @@ static struct io_config
#ifdef BSP_USING_UART1 #ifdef BSP_USING_UART1
IOCONFIG(BSP_UART1_TXD_PIN, FUNC_UART1_TX), IOCONFIG(BSP_UART1_TXD_PIN, FUNC_UART1_TX),
IOCONFIG(BSP_UART1_RXD_PIN, FUNC_UART1_RX), IOCONFIG(BSP_UART1_RXD_PIN, FUNC_UART1_RX),
#if BSP_UART1_RTS_PIN >= 0
IOCONFIG(BSP_UART1_RTS_PIN, FUNC_UART1_RTS),
#endif
#if BSP_UART1_CTS_PIN >= 0
IOCONFIG(BSP_UART1_CTS_PIN, FUNC_UART1_CTS),
#endif
#endif #endif
#ifdef BSP_USING_UART2 #ifdef BSP_USING_UART2
IOCONFIG(BSP_UART2_TXD_PIN, FUNC_UART2_TX), IOCONFIG(BSP_UART2_TXD_PIN, FUNC_UART2_TX),
IOCONFIG(BSP_UART2_RXD_PIN, FUNC_UART2_RX), IOCONFIG(BSP_UART2_RXD_PIN, FUNC_UART2_RX),
#if BSP_UART2_RTS_PIN >= 0
IOCONFIG(BSP_UART2_RTS_PIN, FUNC_UART2_RTS),
#endif
#if BSP_UART2_CTS_PIN >= 0
IOCONFIG(BSP_UART2_CTS_PIN, FUNC_UART2_CTS),
#endif
#endif #endif
#ifdef BSP_USING_UART3 #ifdef BSP_USING_UART3
IOCONFIG(BSP_UART3_TXD_PIN, FUNC_UART3_TX), IOCONFIG(BSP_UART3_TXD_PIN, FUNC_UART3_TX),
IOCONFIG(BSP_UART3_RXD_PIN, FUNC_UART3_RX), IOCONFIG(BSP_UART3_RXD_PIN, FUNC_UART3_RX),
#if BSP_UART3_RTS_PIN >= 0
IOCONFIG(BSP_UART3_RTS_PIN, FUNC_UART3_RTS),
#endif
#if BSP_UART3_CTS_PIN >= 0
IOCONFIG(BSP_UART3_CTS_PIN, FUNC_UART3_CTS),
#endif
#endif
#ifdef BSP_USING_I2C0
IOCONFIG(BSP_I2C0_SCL_PIN, FUNC_I2C0_SCLK),
IOCONFIG(BSP_I2C0_SDA_PIN, FUNC_I2C0_SDA),
#endif
#ifdef BSP_USING_I2C1
IOCONFIG(BSP_I2C1_SCL_PIN, FUNC_I2C1_SCLK),
IOCONFIG(BSP_I2C1_SDA_PIN, FUNC_I2C1_SDA),
#endif
#ifdef BSP_USING_I2C2
IOCONFIG(BSP_I2C2_SCL_PIN, FUNC_I2C2_SCLK),
IOCONFIG(BSP_I2C2_SDA_PIN, FUNC_I2C2_SDA),
#endif
#ifdef BSP_USING_I2S0
IOCONFIG(BSP_I2S0_OUT_D1_PIN, FUNC_I2S0_OUT_D1),
IOCONFIG(BSP_I2S0_WS_PIN, FUNC_I2S0_WS),
IOCONFIG(BSP_I2S0_SCLK_PIN, FUNC_I2S0_SCLK),
#endif
#ifdef BSP_USING_I2S1
IOCONFIG(BSP_I2S1_IN_D0_PIN, FUNC_I2S1_IN_D0),
IOCONFIG(BSP_I2S1_WS_PIN, FUNC_I2S1_WS),
IOCONFIG(BSP_I2S1_SCLK_PIN, FUNC_I2S1_SCLK),
#endif
#ifdef BSP_USING_I2S2
IOCONFIG(BSP_I2S2_OUT_D1_PIN, FUNC_I2S2_OUT_D1),
IOCONFIG(BSP_I2S2_WS_PIN, FUNC_I2S2_WS),
IOCONFIG(BSP_I2S2_SCLK_PIN, FUNC_I2S2_SCLK),
#endif
#ifdef BSP_PWM_CHN0_ENABLE
IOCONFIG(BSP_PWM_CHN0_PIN, FUNC_TIMER2_TOGGLE1),
#endif
#ifdef BSP_PWM_CHN1_ENABLE
IOCONFIG(BSP_PWM_CHN1_PIN, FUNC_TIMER2_TOGGLE2),
#endif
#ifdef BSP_PWM_CHN2_ENABLE
IOCONFIG(BSP_PWM_CHN2_PIN, FUNC_TIMER2_TOGGLE3),
#endif
#ifdef BSP_PWM_CHN3_ENABLE
IOCONFIG(BSP_PWM_CHN3_PIN, FUNC_TIMER2_TOGGLE4),
#endif #endif
}; };
@ -101,16 +162,35 @@ int io_config_init(void)
int count = sizeof(io_config) / sizeof(io_config[0]); int count = sizeof(io_config) / sizeof(io_config[0]);
int i; int i;
/* IO GroupA Power Supply Setting */
#if defined(BSP_GROUPA_POWER_SUPPLY_3V3)
sysctl_set_power_mode(SYSCTL_POWER_BANK0, SYSCTL_POWER_V33);
sysctl_set_power_mode(SYSCTL_POWER_BANK1, SYSCTL_POWER_V33);
sysctl_set_power_mode(SYSCTL_POWER_BANK2, SYSCTL_POWER_V33);
#else
sysctl_set_power_mode(SYSCTL_POWER_BANK0, SYSCTL_POWER_V18); sysctl_set_power_mode(SYSCTL_POWER_BANK0, SYSCTL_POWER_V18);
sysctl_set_power_mode(SYSCTL_POWER_BANK1, SYSCTL_POWER_V18); sysctl_set_power_mode(SYSCTL_POWER_BANK1, SYSCTL_POWER_V18);
sysctl_set_power_mode(SYSCTL_POWER_BANK2, SYSCTL_POWER_V18); sysctl_set_power_mode(SYSCTL_POWER_BANK2, SYSCTL_POWER_V18);
#ifdef BSP_USING_UART2
// for IO-27/28
sysctl_set_power_mode(SYSCTL_POWER_BANK4, SYSCTL_POWER_V33);
#endif #endif
#if defined(BSP_USING_UART1) || defined(BSP_USING_UART3)
// for IO-20~23 /* IO GroupB Power Supply Setting */
#if defined(BSP_GROUPB_POWER_SUPPLY_3V3)
sysctl_set_power_mode(SYSCTL_POWER_BANK3, SYSCTL_POWER_V33); sysctl_set_power_mode(SYSCTL_POWER_BANK3, SYSCTL_POWER_V33);
sysctl_set_power_mode(SYSCTL_POWER_BANK4, SYSCTL_POWER_V33);
sysctl_set_power_mode(SYSCTL_POWER_BANK5, SYSCTL_POWER_V33);
#else
sysctl_set_power_mode(SYSCTL_POWER_BANK3, SYSCTL_POWER_V18);
sysctl_set_power_mode(SYSCTL_POWER_BANK4, SYSCTL_POWER_V18);
sysctl_set_power_mode(SYSCTL_POWER_BANK5, SYSCTL_POWER_V18);
#endif
/* IO GroupC Power Supply Setting */
#if defined(BSP_GROUPC_POWER_SUPPLY_3V3)
sysctl_set_power_mode(SYSCTL_POWER_BANK6, SYSCTL_POWER_V33);
sysctl_set_power_mode(SYSCTL_POWER_BANK7, SYSCTL_POWER_V33);
#else
sysctl_set_power_mode(SYSCTL_POWER_BANK6, SYSCTL_POWER_V18);
sysctl_set_power_mode(SYSCTL_POWER_BANK7, SYSCTL_POWER_V18);
#endif #endif
for(i = 0; i < count; i++) for(i = 0; i < count; i++)
@ -120,12 +200,20 @@ int io_config_init(void)
#if defined(BSP_USING_DVP) || defined(BSP_USING_LCD) #if defined(BSP_USING_DVP) || defined(BSP_USING_LCD)
sysctl_set_spi0_dvp_data(1); sysctl_set_spi0_dvp_data(1);
sysctl_set_power_mode(SYSCTL_POWER_BANK6, SYSCTL_POWER_V18);
sysctl_set_power_mode(SYSCTL_POWER_BANK7, SYSCTL_POWER_V18);
#endif
#ifdef FACE_DETECT
sysctl_clock_enable(SYSCTL_CLOCK_AI); sysctl_clock_enable(SYSCTL_CLOCK_AI);
#endif #endif
} }
INIT_BOARD_EXPORT(io_config_init);
int io_config_used(int io_num)
{
int count = sizeof(io_config) / sizeof(io_config[0]);
int i;
for(i = 0; i < count; i++)
{
if (io_config[i].io_num == io_num)
break;
}
return (i < count);
}

View File

@ -11,10 +11,18 @@
#ifndef __DRV_IO_CONFIG_H__ #ifndef __DRV_IO_CONFIG_H__
#define __DRV_IO_CONFIG_H__ #define __DRV_IO_CONFIG_H__
#include <rtconfig.h>
enum HS_GPIO_CONFIG enum HS_GPIO_CONFIG
{ {
#ifdef BSP_USING_LCD #ifdef BSP_USING_LCD
LCD_DC_PIN = 0, /* LCD DC PIN */ LCD_DC_PIN = 0, /* LCD DC PIN */
#if BSP_LCD_RST_PIN >= 0
LCD_RST_PIN,
#endif
#if BSP_LCD_BACKLIGHT_PIN >= 0
LCD_BACKLIGHT_PIN,
#endif
#endif #endif
#ifdef BSP_SPI1_USING_SS0 #ifdef BSP_SPI1_USING_SS0
SPI1_CS0_PIN, SPI1_CS0_PIN,
@ -28,6 +36,11 @@ enum HS_GPIO_CONFIG
#ifdef BSP_SPI1_USING_SS3 #ifdef BSP_SPI1_USING_SS3
SPI1_CS3_PIN, SPI1_CS3_PIN,
#endif #endif
#ifdef BSP_USING_BRIDGE
SPI2_INT_PIN,
SPI2_READY_PIN,
#endif
GPIO_ALLOC_START /* index of gpio driver start */ GPIO_ALLOC_START /* index of gpio driver start */
}; };

View File

@ -1,16 +1,11 @@
/* Copyright 2018 Canaan Inc. /*
* Copyright (c) 2006-2018, RT-Thread Development Team
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * SPDX-License-Identifier: Apache-2.0
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * Change Logs:
* * Date Author Notes
* Unless required by applicable law or agreed to in writing, software * 2019-03-12 ZYH first version
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/ */
@ -18,314 +13,538 @@
#ifdef BSP_USING_LCD #ifdef BSP_USING_LCD
#include <drv_lcd.h> #include <drv_lcd.h>
#include <gpiohs.h>
#include <spi.h>
#include <unistd.h>
#include <string.h>
#include <fpioa.h>
#define DBG_TAG "LCD" #define DBG_TAG "LCD"
#define DBG_LVL DBG_LOG #define DBG_LVL DBG_WARNING
#include <rtdbg.h> #include <rtdbg.h>
#define NO_OPERATION 0x00
#define SOFTWARE_RESET 0x01
#define READ_ID 0x04
#define READ_STATUS 0x09
#define READ_POWER_MODE 0x0A
#define READ_MADCTL 0x0B
#define READ_PIXEL_FORMAT 0x0C
#define READ_IMAGE_FORMAT 0x0D
#define READ_SIGNAL_MODE 0x0E
#define READ_SELT_DIAG_RESULT 0x0F
#define SLEEP_ON 0x10
#define SLEEP_OFF 0x11
#define PARTIAL_DISPALY_ON 0x12
#define NORMAL_DISPALY_ON 0x13
#define INVERSION_DISPALY_OFF 0x20
#define INVERSION_DISPALY_ON 0x21
#define GAMMA_SET 0x26
#define DISPALY_OFF 0x28
#define DISPALY_ON 0x29
#define HORIZONTAL_ADDRESS_SET 0x2A
#define VERTICAL_ADDRESS_SET 0x2B
#define MEMORY_WRITE 0x2C
#define COLOR_SET 0x2D
#define MEMORY_READ 0x2E
#define PARTIAL_AREA 0x30
#define VERTICAL_SCROL_DEFINE 0x33
#define TEAR_EFFECT_LINE_OFF 0x34
#define TEAR_EFFECT_LINE_ON 0x35
#define MEMORY_ACCESS_CTL 0x36
#define VERTICAL_SCROL_S_ADD 0x37
#define IDLE_MODE_OFF 0x38
#define IDLE_MODE_ON 0x39
#define PIXEL_FORMAT_SET 0x3A
#define WRITE_MEMORY_CONTINUE 0x3C
#define READ_MEMORY_CONTINUE 0x3E
#define SET_TEAR_SCANLINE 0x44
#define GET_SCANLINE 0x45
#define WRITE_BRIGHTNESS 0x51
#define READ_BRIGHTNESS 0x52
#define WRITE_CTRL_DISPALY 0x53
#define READ_CTRL_DISPALY 0x54
#define WRITE_BRIGHTNESS_CTL 0x55
#define READ_BRIGHTNESS_CTL 0x56
#define WRITE_MIN_BRIGHTNESS 0x5E
#define READ_MIN_BRIGHTNESS 0x5F
#define READ_ID1 0xDA
#define READ_ID2 0xDB
#define READ_ID3 0xDC
#define RGB_IF_SIGNAL_CTL 0xB0
#define NORMAL_FRAME_CTL 0xB1
#define IDLE_FRAME_CTL 0xB2
#define PARTIAL_FRAME_CTL 0xB3
#define INVERSION_CTL 0xB4
#define BLANK_PORCH_CTL 0xB5
#define DISPALY_FUNCTION_CTL 0xB6
#define ENTRY_MODE_SET 0xB7
#define BACKLIGHT_CTL1 0xB8
#define BACKLIGHT_CTL2 0xB9
#define BACKLIGHT_CTL3 0xBA
#define BACKLIGHT_CTL4 0xBB
#define BACKLIGHT_CTL5 0xBC
#define BACKLIGHT_CTL7 0xBE
#define BACKLIGHT_CTL8 0xBF
#define POWER_CTL1 0xC0
#define POWER_CTL2 0xC1
#define VCOM_CTL1 0xC5
#define VCOM_CTL2 0xC7
#define NV_MEMORY_WRITE 0xD0
#define NV_MEMORY_PROTECT_KEY 0xD1
#define NV_MEMORY_STATUS_READ 0xD2
#define READ_ID4 0xD3
#define POSITIVE_GAMMA_CORRECT 0xE0
#define NEGATIVE_GAMMA_CORRECT 0xE1
#define DIGITAL_GAMMA_CTL1 0xE2
#define DIGITAL_GAMMA_CTL2 0xE3
#define INTERFACE_CTL 0xF6
#define LCD_SPI_CHANNEL SPI_DEVICE_0
#define LCD_SPI_CHIP_SELECT SPI_CHIP_SELECT_0
#if defined(BSP_BOARD_K210_OPENMV_TEST)
#define LCD_SCAN_DIR DIR_YX_LRUD
#elif defined(BSP_BOARD_KD233)
#define LCD_SCAN_DIR (DIR_YX_RLUD | 0x08)
#elif defined(BSP_BOARD_USER)
/*user define.*/
#define LCD_SCAN_DIR DIR_YX_RLDU
#endif
static lcd_ctl_t lcd_ctl;
static void init_dcx(void) static struct lcd_8080_device _lcddev;
static void drv_lcd_cmd(lcd_8080_device_t lcd, rt_uint8_t cmd)
{ {
gpiohs_set_drive_mode(DCX_GPIONUM, GPIO_DM_OUTPUT); gpiohs_set_pin(lcd->dc_pin, GPIO_PV_LOW);
gpiohs_set_pin(DCX_GPIONUM, GPIO_PV_HIGH); spi_init(lcd->spi_channel, SPI_WORK_MODE_0, SPI_FF_OCTAL, 8, 0);
spi_init_non_standard(lcd->spi_channel, 8 /*instrction length*/, 0 /*address length*/, 0 /*wait cycles*/,
SPI_AITM_AS_FRAME_FORMAT /*spi address trans mode*/);
spi_send_data_normal_dma(lcd->dma_channel, lcd->spi_channel, lcd->cs, &cmd, 1, SPI_TRANS_CHAR);
} }
static void set_dcx_control(void) static void drv_lcd_data_byte(lcd_8080_device_t lcd, rt_uint8_t *data_buf, rt_uint32_t length)
{ {
gpiohs_set_pin(DCX_GPIONUM, GPIO_PV_LOW); gpiohs_set_pin(lcd->dc_pin, GPIO_PV_HIGH);
spi_init(lcd->spi_channel, SPI_WORK_MODE_0, SPI_FF_OCTAL, 8, 0);
spi_init_non_standard(lcd->spi_channel, 8 /*instrction length*/, 0 /*address length*/, 0 /*wait cycles*/,
SPI_AITM_AS_FRAME_FORMAT /*spi address trans mode*/);
spi_send_data_normal_dma(lcd->dma_channel, lcd->spi_channel, lcd->cs, data_buf, length, SPI_TRANS_CHAR);
} }
static void set_dcx_data(void) void drv_lcd_data_half_word(lcd_8080_device_t lcd, rt_uint16_t *data_buf, rt_uint32_t length)
{ {
gpiohs_set_pin(DCX_GPIONUM, GPIO_PV_HIGH); gpiohs_set_pin(lcd->dc_pin, GPIO_PV_HIGH);
spi_init(lcd->spi_channel, SPI_WORK_MODE_0, SPI_FF_OCTAL, 16, 0);
spi_init_non_standard(lcd->spi_channel, 16 /*instrction length*/, 0 /*address length*/, 0 /*wait cycles*/,
SPI_AITM_AS_FRAME_FORMAT /*spi address trans mode*/);
spi_send_data_normal_dma(lcd->dma_channel, lcd->spi_channel, lcd->cs, data_buf, length, SPI_TRANS_SHORT);
} }
void drv_lcd_data_word(lcd_8080_device_t lcd, rt_uint32_t *data_buf, rt_uint32_t length)
static void init_rst(void)
{ {
gpiohs_set_drive_mode(RST_GPIONUM, GPIO_DM_OUTPUT); gpiohs_set_pin(lcd->dc_pin, GPIO_PV_HIGH);
gpiohs_set_pin(RST_GPIONUM, GPIO_PV_LOW); spi_init(lcd->spi_channel, SPI_WORK_MODE_0, SPI_FF_OCTAL, 32, 0);
rt_thread_mdelay(10); spi_init_non_standard(lcd->spi_channel, 0 /*instrction length*/, 32 /*address length*/, 0 /*wait cycles*/,
gpiohs_set_pin(RST_GPIONUM, GPIO_PV_HIGH); SPI_AITM_AS_FRAME_FORMAT /*spi address trans mode*/);
rt_thread_mdelay(10); spi_send_data_normal_dma(lcd->dma_channel, lcd->spi_channel, lcd->cs, data_buf, length, SPI_TRANS_INT);
} }
static void drv_lcd_hw_init(lcd_8080_device_t lcd)
void tft_hard_init(void)
{ {
init_dcx(); #if BSP_LCD_RST_PIN >= 0
spi_init(SPI_CHANNEL, SPI_WORK_MODE_0, SPI_FF_OCTAL, 8, 0); {
init_rst(); gpiohs_set_drive_mode(lcd->rst_pin, GPIO_DM_OUTPUT);
spi_set_clk_rate(SPI_CHANNEL, 20000000); gpiohs_set_pin(lcd->rst_pin, GPIO_PV_LOW);
rt_thread_mdelay(20);
gpiohs_set_pin(lcd->rst_pin, GPIO_PV_HIGH);
rt_thread_mdelay(20);
}
#endif
#if BSP_LCD_BACKLIGHT_PIN >= 0
{
gpiohs_set_drive_mode(lcd->backlight_pin, GPIO_DM_OUTPUT);
#if defined(BSP_LCD_BACKLIGHT_ACTIVE_LOW)
gpiohs_set_pin(lcd->backlight_pin, GPIO_PV_LOW);
#elif defined(BSP_LCD_BACKLIGHT_ACTIVE_HIGH)
gpiohs_set_pin(lcd->backlight_pin, GPIO_PV_HIGH);
#else
gpiohs_set_pin(lcd->backlight_pin, GPIO_PV_LOW);
#endif
}
#endif
gpiohs_set_drive_mode(lcd->dc_pin, GPIO_DM_OUTPUT);
gpiohs_set_pin(lcd->dc_pin, GPIO_PV_HIGH);
spi_init(lcd->spi_channel, SPI_WORK_MODE_0, SPI_FF_OCTAL, 8, 0);
spi_set_clk_rate(lcd->spi_channel, BSP_LCD_CLK_FREQ);
} }
void tft_write_command(uint8_t cmd) static void drv_lcd_set_direction(lcd_8080_device_t lcd, lcd_dir_t dir)
{ {
set_dcx_control();
spi_init(SPI_CHANNEL, SPI_WORK_MODE_0, SPI_FF_OCTAL, 8, 0);
spi_init_non_standard(SPI_CHANNEL, 8/*instrction length*/, 0/*address length*/, 0/*wait cycles*/,
SPI_AITM_AS_FRAME_FORMAT/*spi address trans mode*/);
spi_send_data_normal_dma(DMAC_CHANNEL0, SPI_CHANNEL, SPI_SLAVE_SELECT, (uint8_t *)(&cmd), 1,SPI_TRANS_CHAR);
}
void tft_write_byte(uint8_t *data_buf, uint32_t length)
{
set_dcx_data();
spi_init(SPI_CHANNEL, SPI_WORK_MODE_0, SPI_FF_OCTAL, 8, 0);
spi_init_non_standard(SPI_CHANNEL, 8/*instrction length*/, 0/*address length*/, 0/*wait cycles*/,
SPI_AITM_AS_FRAME_FORMAT/*spi address trans mode*/);
spi_send_data_normal_dma(DMAC_CHANNEL0, SPI_CHANNEL, SPI_SLAVE_SELECT, data_buf, length, SPI_TRANS_CHAR);
}
void tft_write_half(uint16_t *data_buf, uint32_t length)
{
set_dcx_data();
spi_init(SPI_CHANNEL, SPI_WORK_MODE_0, SPI_FF_OCTAL, 16, 0);
spi_init_non_standard(SPI_CHANNEL, 16/*instrction length*/, 0/*address length*/, 0/*wait cycles*/,
SPI_AITM_AS_FRAME_FORMAT/*spi address trans mode*/);
spi_send_data_normal_dma(DMAC_CHANNEL0, SPI_CHANNEL, SPI_SLAVE_SELECT,data_buf, length, SPI_TRANS_SHORT);
}
void tft_write_word(uint32_t *data_buf, uint32_t length, uint32_t flag)
{
set_dcx_data();
spi_init(SPI_CHANNEL, SPI_WORK_MODE_0, SPI_FF_OCTAL, 32, 0);
spi_init_non_standard(SPI_CHANNEL, 0/*instrction length*/, 32/*address length*/, 0/*wait cycles*/,
SPI_AITM_AS_FRAME_FORMAT/*spi address trans mode*/);
spi_send_data_normal_dma(DMAC_CHANNEL0, SPI_CHANNEL, SPI_SLAVE_SELECT,data_buf, length, SPI_TRANS_INT);
}
void tft_fill_data(uint32_t *data_buf, uint32_t length)
{
set_dcx_data();
spi_init(SPI_CHANNEL, SPI_WORK_MODE_0, SPI_FF_OCTAL, 32, 0);
spi_init_non_standard(SPI_CHANNEL, 0/*instrction length*/, 32/*address length*/, 0/*wait cycles*/,
SPI_AITM_AS_FRAME_FORMAT/*spi address trans mode*/);
spi_fill_data_dma(DMAC_CHANNEL0, SPI_CHANNEL, SPI_SLAVE_SELECT,data_buf, length);
}
void lcd_polling_enable(void)
{
lcd_ctl.mode = 0;
}
void lcd_interrupt_enable(void)
{
lcd_ctl.mode = 1;
}
void lcd_pre()
{
fpioa_set_function(37, FUNC_GPIOHS0 + RST_GPIONUM);
fpioa_set_function(38, FUNC_GPIOHS0 + DCX_GPIONUM);
fpioa_set_function(36, FUNC_SPI0_SS0 + LCD_SPI_SLAVE_SELECT);
fpioa_set_function(39, FUNC_SPI0_SCLK);
}
int lcd_init(void)
{
uint8_t data = 0;
lcd_pre();
tft_hard_init();
/*soft reset*/
tft_write_command(SOFTWARE_RESET);
rt_thread_mdelay(10);
/*exit sleep*/
tft_write_command(SLEEP_OFF);
rt_thread_mdelay(10);
/*pixel format*/
tft_write_command(PIXEL_FORMAT_SET);
data = 0x55;
tft_write_byte(&data, 1);
/*display on*/
tft_write_command(DISPALY_ON);
lcd_polling_enable();
lcd_clear(PINK);
lcd_set_direction(DIR_YX_RLDU);
LOG_I("LCD initialization successfully");
}
INIT_APP_EXPORT(lcd_init);
void lcd_set_direction(lcd_dir_t dir)
{
lcd_ctl.dir = dir;
if (dir & DIR_XY_MASK) if (dir & DIR_XY_MASK)
{ {
lcd_ctl.width = LCD_Y_MAX - 1; lcd->lcd_info.width = BSP_LCD_Y_MAX;
lcd_ctl.height = LCD_X_MAX - 1; lcd->lcd_info.height = BSP_LCD_X_MAX;
} }
else else
{ {
lcd_ctl.width = LCD_X_MAX - 1; lcd->lcd_info.width = BSP_LCD_X_MAX;
lcd_ctl.height = LCD_Y_MAX - 1; lcd->lcd_info.height = BSP_LCD_Y_MAX;
} }
rt_kprintf("lcd witdth %d,height %d \n",lcd->lcd_info.width,lcd->lcd_info.height);
tft_write_command(MEMORY_ACCESS_CTL); drv_lcd_cmd(lcd, MEMORY_ACCESS_CTL);
tft_write_byte((uint8_t *)&dir, 1); drv_lcd_data_byte(lcd, (rt_uint8_t *)&dir, 1);
} }
void lcd_set_area(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2) void drv_lcd_set_area(lcd_8080_device_t lcd, rt_uint16_t x1, rt_uint16_t y1, rt_uint16_t x2, rt_uint16_t y2)
{ {
uint8_t data[4] = {0}; rt_uint8_t data[4] = {0};
data[0] = (uint8_t)(x1 >> 8); data[0] = (rt_uint8_t)(x1 >> 8);
data[1] = (uint8_t)(x1); data[1] = (rt_uint8_t)(x1);
data[2] = (uint8_t)(x2 >> 8); data[2] = (rt_uint8_t)(x2 >> 8);
data[3] = (uint8_t)(x2); data[3] = (rt_uint8_t)(x2);
tft_write_command(HORIZONTAL_ADDRESS_SET); drv_lcd_cmd(lcd, HORIZONTAL_ADDRESS_SET);
tft_write_byte(data, 4); drv_lcd_data_byte(lcd, data, 4);
data[0] = (uint8_t)(y1 >> 8); data[0] = (rt_uint8_t)(y1 >> 8);
data[1] = (uint8_t)(y1); data[1] = (rt_uint8_t)(y1);
data[2] = (uint8_t)(y2 >> 8); data[2] = (rt_uint8_t)(y2 >> 8);
data[3] = (uint8_t)(y2); data[3] = (rt_uint8_t)(y2);
tft_write_command(VERTICAL_ADDRESS_SET); drv_lcd_cmd(lcd, VERTICAL_ADDRESS_SET);
tft_write_byte(data, 4); drv_lcd_data_byte(lcd, data, 4);
tft_write_command(MEMORY_WRITE); drv_lcd_cmd(lcd, MEMORY_WRITE);
} }
void lcd_draw_point(uint16_t x, uint16_t y, uint16_t color) static void drv_lcd_set_pixel(lcd_8080_device_t lcd, uint16_t x, uint16_t y, uint16_t color)
{ {
lcd_set_area(x, y, x, y); drv_lcd_set_area(lcd, x, y, x, y);
tft_write_half(&color, 1); drv_lcd_data_half_word(lcd, &color, 1);
} }
void lcd_draw_char(uint16_t x, uint16_t y, char c, uint16_t color) static void drv_lcd_clear(lcd_8080_device_t lcd, uint16_t color)
{
uint8_t i = 0;
uint8_t j = 0;
uint8_t data = 0;
for (i = 0; i < 16; i++)
{
data = ascii0816[c * 16 + i];
for (j = 0; j < 8; j++)
{
if (data & 0x80)
lcd_draw_point(x + j, y, color);
data <<= 1;
}
y++;
}
}
void lcd_draw_string(uint16_t x, uint16_t y, char *str, uint16_t color)
{
while (*str)
{
lcd_draw_char(x, y, *str, color);
str++;
x += 8;
}
}
void lcd_ram_draw_string(char *str, uint32_t *ptr, uint16_t font_color, uint16_t bg_color)
{
uint8_t i = 0;
uint8_t j = 0;
uint8_t data = 0;
uint8_t *pdata = NULL;
uint16_t width = 0;
uint32_t *pixel = NULL;
width = 4 * strlen(str);
while (*str)
{
pdata = (uint8_t *)&ascii0816[(*str) * 16];
for (i = 0; i < 16; i++)
{
data = *pdata++;
pixel = ptr + i * width;
for (j = 0; j < 4; j++)
{
switch (data >> 6)
{
case 0:
*pixel = ((uint32_t)bg_color << 16) | bg_color;
break;
case 1:
*pixel = ((uint32_t)bg_color << 16) | font_color;
break;
case 2:
*pixel = ((uint32_t)font_color << 16) | bg_color;
break;
case 3:
*pixel = ((uint32_t)font_color << 16) | font_color;
break;
default:
*pixel = 0;
break;
}
data <<= 2;
pixel++;
}
}
str++;
ptr += 4;
}
}
void lcd_clear(uint16_t color)
{ {
uint32_t data = ((uint32_t)color << 16) | (uint32_t)color; uint32_t data = ((uint32_t)color << 16) | (uint32_t)color;
lcd_set_area(0, 0, lcd_ctl.width, lcd_ctl.height); drv_lcd_set_area(lcd, 0, 0, lcd->lcd_info.width - 1, lcd->lcd_info.height - 1);
tft_fill_data(&data, LCD_X_MAX * LCD_Y_MAX / 2); gpiohs_set_pin(lcd->dc_pin, GPIO_PV_HIGH);
spi_init(lcd->spi_channel, SPI_WORK_MODE_0, SPI_FF_OCTAL, 32, 0);
spi_init_non_standard(lcd->spi_channel, 0 /*instrction length*/, 32 /*address length*/, 0 /*wait cycles*/,
SPI_AITM_AS_FRAME_FORMAT /*spi address trans mode*/);
spi_fill_data_dma(lcd->dma_channel, lcd->spi_channel, lcd->cs, (const uint32_t *)&data, lcd->lcd_info.width * lcd->lcd_info.height / 2);
} }
void lcd_draw_rectangle(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint16_t width, uint16_t color) static void rt_bitblt(rt_uint16_t * dest, int dest_segment, int dest_common, int dest_x, int dest_y, int width, int height,
rt_uint16_t *src, int src_segment, int src_common, int src_x, int src_y)
{ {
uint32_t data_buf[640] = {0}; int sx0, sx1, sy0, sy1;
uint32_t *p = data_buf; int dx0, dx1, dy0, dy1;
uint32_t data = color; rt_uint16_t *buff_src;
uint32_t index = 0; rt_uint16_t *buff_dest;
int x, y;
data = (data << 16) | data; if (width <= 0) {
for (index = 0; index < 160 * width; index++) return;
*p++ = data; }
if (height <= 0) {
return;
}
lcd_set_area(x1, y1, x2, y1 + width - 1); sx0 = src_x;
tft_write_word(data_buf, ((x2 - x1 + 1) * width + 1) / 2, 0); sy0 = src_y;
lcd_set_area(x1, y2 - width + 1, x2, y2); sx1 = sx0 + width - 1;
tft_write_word(data_buf, ((x2 - x1 + 1) * width + 1) / 2, 0); sy1 = sy0 + height - 1;
lcd_set_area(x1, y1, x1 + width - 1, y2); dx0 = dest_x;
tft_write_word(data_buf, ((y2 - y1 + 1) * width + 1) / 2, 0); dy0 = dest_y;
lcd_set_area(x2 - width + 1, y1, x2, y2); dx1 = dx0 + width - 1;
tft_write_word(data_buf, ((y2 - y1 + 1) * width + 1) / 2, 0); dy1 = dy0 + height - 1;
if (sx0 < 0) {
dx0 -= sx0;
sx0 = 0;
}
if (sy0 < 0) {
dy0 -= sy0;
sy0 = 0;
}
if (sx1 >= src_segment) {
dx1 -= (sx1 - src_segment + 1);
sx1 = src_segment - 1;
}
if (sy1 >= src_common) {
dy1 -= (sy1 - src_common + 1);
sy1 = src_common - 1;
}
if (dx0 < 0) {
sx0 -= dx0;
dx0 = 0;
}
if (dy0 < 0) {
sy0 -= dy0;
dy0 = 0;
}
if (dx1 >= dest_segment) {
sx1 -= (dx1 - dest_segment + 1);
dx1 = dest_segment - 1;
}
if (dy1 >= dest_common) {
sy1 -= (dy1 - dest_common + 1);
dy1 = dest_common - 1;
}
if (sx1 < 0 || sx0 >= src_segment) {
return;
}
if (sy1 < 0 || sy0 >= src_common) {
return;
}
if (dx1 < 0 || dx0 >= dest_segment) {
return;
}
if (dy1 < 0 || dy0 >= dest_common) {
return;
}
if ((rt_ubase_t)dest < (rt_ubase_t)src) {
buff_src = src + (sy0 * src_segment) + sx0;
buff_dest = dest + (dy0 * dest_segment) + dx0;
for (y = sy0; y <= sy1; y++) {
src = buff_src;
dest = buff_dest;
for (x = sx0; x <= sx1; x++) {
*dest++ = *src++;
}
buff_src += src_segment;
buff_dest += dest_segment;
}
} else {
buff_src = src + (sy1 * src_segment) + sx1;
buff_dest = dest + (dy1 * dest_segment) + dx1;
for (y = sy1; y >= sy0; y--) {
src = buff_src;
dest = buff_dest;
for (x = sx1; x >= sx0; x--) {
*dest-- = *src--;
}
buff_src -= src_segment;
buff_dest -= dest_segment;
}
}
} }
void lcd_draw_picture(uint16_t x1, uint16_t y1, uint16_t width, uint16_t height, uint32_t *ptr) static void drv_lcd_rect_update(lcd_8080_device_t lcd, uint16_t x1, uint16_t y1, uint16_t width, uint16_t height)
{ {
lcd_set_area(x1, y1, x1 + width - 1, y1 + height - 1); static rt_uint16_t * rect_buffer = RT_NULL;
tft_write_word(ptr, width * height / 2, lcd_ctl.mode ? 2 : 0); if(!rect_buffer)
{
rect_buffer = rt_malloc_align(lcd->lcd_info.height * lcd->lcd_info.width * (lcd->lcd_info.bits_per_pixel / 8), 64);
if(!rect_buffer)
{
return;
}
}
if(x1 == 0 && y1 == 0 && width == lcd->lcd_info.width && height == lcd->lcd_info.height)
{
drv_lcd_set_area(lcd, x1, y1, x1 + width - 1, y1 + height - 1);
drv_lcd_data_half_word(lcd, (rt_uint32_t *)lcd->lcd_info.framebuffer, width * height);
}
else
{
rt_bitblt(rect_buffer, width, height, 0, 0, width, height,(rt_uint16_t *)lcd->lcd_info.framebuffer, lcd->lcd_info.width, lcd->lcd_info.height, x1, y1);
drv_lcd_set_area(lcd, x1, y1, x1 + width - 1, y1 + height - 1);
drv_lcd_data_half_word(lcd, (rt_uint16_t *)rect_buffer, width * height);
}
} }
static rt_err_t drv_lcd_init(rt_device_t dev)
void lcd_test0()
{ {
char test[]={"xuos-intelligence framwork"}; rt_err_t ret = RT_EOK;
lcd_draw_string(0,0,test,BLUE); lcd_8080_device_t lcd = (lcd_8080_device_t)dev;
rt_uint8_t data = 0;
if(!lcd)
{
return RT_ERROR;
}
drv_lcd_hw_init(lcd);
/* reset LCD */
drv_lcd_cmd(lcd, SOFTWARE_RESET);
rt_thread_mdelay(100);
/* Enter normal status */
drv_lcd_cmd(lcd, SLEEP_OFF);
rt_thread_mdelay(100);
/* pixel format rgb565 */
drv_lcd_cmd(lcd, PIXEL_FORMAT_SET);
data = 0x55;
drv_lcd_data_byte(lcd, &data, 1);
/* set direction */
drv_lcd_set_direction(lcd, LCD_SCAN_DIR);
lcd->lcd_info.framebuffer = rt_malloc_align(lcd->lcd_info.height * lcd->lcd_info.width * (lcd->lcd_info.bits_per_pixel / 8), 64);
RT_ASSERT(lcd->lcd_info.framebuffer);
uint16_t *framebuffer = (uint16_t *)(lcd->lcd_info.framebuffer);
for(uint32_t i=0; i<(lcd->lcd_info.height * lcd->lcd_info.width * (lcd->lcd_info.bits_per_pixel / 8))/2; i++) {
framebuffer[i] = BLACK;
}
/*display on*/
drv_lcd_cmd(lcd, DISPALY_ON);
/* set to black */
drv_lcd_clear(lcd, BLACK);
return ret;
} }
MSH_CMD_EXPORT(lcd_test0,lcd show string);
void lcd_test1() static rt_err_t drv_lcd_open(rt_device_t dev, rt_uint16_t oflag)
{ {
lcd_clear(YELLOW);
/* Not need */
return RT_EOK;
} }
MSH_CMD_EXPORT(lcd_test1,lcd show string);
static rt_err_t drv_lcd_close(rt_device_t dev)
{
/* Not need */
return RT_EOK;
}
static rt_size_t drv_lcd_read(rt_device_t dev, rt_off_t pos, void *buffer, rt_size_t size)
{
/* Not need */
return 0;
}
static rt_size_t drv_lcd_write(rt_device_t dev, rt_off_t pos, const void *buffer, rt_size_t size)
{
/* Not need */
return 0;
}
static rt_err_t drv_lcd_control(rt_device_t dev, int cmd, void *args)
{
rt_err_t ret = RT_EOK;
lcd_8080_device_t lcd = (lcd_8080_device_t)dev;
rt_base_t level;
struct rt_device_rect_info* rect_info = (struct rt_device_rect_info*)args;
RT_ASSERT(dev != RT_NULL);
switch (cmd)
{
case RTGRAPHIC_CTRL_RECT_UPDATE:
if(!rect_info)
{
LOG_E("RTGRAPHIC_CTRL_RECT_UPDATE error args");
return -RT_ERROR;
}
drv_lcd_rect_update(lcd, rect_info->x, rect_info->y, rect_info->width, rect_info->height);
break;
#if BSP_LCD_BACKLIGHT_PIN >= 0
case RTGRAPHIC_CTRL_POWERON:
#if defined(BSP_LCD_BACKLIGHT_ACTIVE_LOW)
gpiohs_set_pin(lcd->backlight_pin, GPIO_PV_LOW);
#elif defined(BSP_LCD_BACKLIGHT_ACTIVE_HIGH)
gpiohs_set_pin(lcd->backlight_pin, GPIO_PV_HIGH);
#else
gpiohs_set_pin(lcd->backlight_pin, GPIO_PV_LOW);
#endif
break;
case RTGRAPHIC_CTRL_POWEROFF:
#if defined(BSP_LCD_BACKLIGHT_ACTIVE_LOW)
gpiohs_set_pin(lcd->backlight_pin, GPIO_PV_HIGH);
#elif defined(BSP_LCD_BACKLIGHT_ACTIVE_HIGH)
gpiohs_set_pin(lcd->backlight_pin, GPIO_PV_LOW);
#else
gpiohs_set_pin(lcd->backlight_pin, GPIO_PV_HIGH);
#endif
break;
#endif /* BSP_LCD_BACKLIGHT_PIN >= 0 */
case RTGRAPHIC_CTRL_GET_INFO:
*(struct rt_device_graphic_info *)args = lcd->lcd_info;
break;
case RTGRAPHIC_CTRL_SET_MODE:
ret = -RT_ENOSYS;
break;
case RTGRAPHIC_CTRL_GET_EXT:
ret = -RT_ENOSYS;
break;
default:
LOG_E("drv_lcd_control cmd: %d", cmd);
break;
}
return ret;
}
#ifdef RT_USING_DEVICE_OPS
const static struct rt_device_ops drv_lcd_ops =
{
drv_lcd_init,
drv_lcd_open,
drv_lcd_close,
drv_lcd_read,
drv_lcd_write,
drv_lcd_control
};
#endif
int rt_hw_lcd_init(void)
{
rt_err_t ret = RT_EOK;
lcd_8080_device_t lcd_dev = &_lcddev;
lcd_dev->cs = SPI_CHIP_SELECT_0;
lcd_dev->dc_pin = LCD_DC_PIN;
#if BSP_LCD_RST_PIN >= 0
lcd_dev->rst_pin = LCD_RST_PIN;
#endif
#if BSP_LCD_BACKLIGHT_PIN >= 0
lcd_dev->backlight_pin = LCD_BACKLIGHT_PIN;
#endif
dmalock_sync_take(&lcd_dev->dma_channel, RT_WAITING_FOREVER);
lcd_dev->spi_channel = SPI_DEVICE_0;
lcd_dev->lcd_info.bits_per_pixel = 16;
lcd_dev->lcd_info.pixel_format = RTGRAPHIC_PIXEL_FORMAT_RGB565;
lcd_dev->parent.type = RT_Device_Class_Graphic;
lcd_dev->parent.rx_indicate = RT_NULL;
lcd_dev->parent.tx_complete = RT_NULL;
#ifdef RT_USING_DEVICE_OPS
lcd_dev->parent.ops = &drv_lcd_ops;
#else
lcd_dev->parent.init = drv_lcd_init;
lcd_dev->parent.open = drv_lcd_open;
lcd_dev->parent.close = drv_lcd_close;
lcd_dev->parent.read = drv_lcd_read;
lcd_dev->parent.write = drv_lcd_write;
lcd_dev->parent.control = drv_lcd_control;
#endif
lcd_dev->parent.user_data = RT_NULL;
ret = rt_device_register(&lcd_dev->parent, "lcd", RT_DEVICE_FLAG_RDWR);
return ret;
}
INIT_DEVICE_EXPORT(rt_hw_lcd_init);
void lcd_set_direction(lcd_dir_t dir)
{
drv_lcd_set_direction(&_lcddev, dir);
}
#endif #endif

View File

@ -1,480 +1,43 @@
/* Copyright 2018 Canaan Inc. /*
* Copyright (c) 2006-2018, RT-Thread Development Team
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * SPDX-License-Identifier: Apache-2.0
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * Change Logs:
* * Date Author Notes
* Unless required by applicable law or agreed to in writing, software * 2019-03-07 ZYH first version
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/ */
#ifndef DRV_LCD_H__
#define DRV_LCD_H__
#include <rtdevice.h>
#include <board.h>
#include <gpiohs.h>
#include <spi.h>
#include <drv_io_config.h>
#include <rthw.h>
#include "dmalock.h"
#ifndef _DRV_LCD_H__
#define _DRV_LCD_H__
#include <stdint.h>
/* clang-format off */
#define NO_OPERATION 0x00
#define SOFTWARE_RESET 0x01
#define READ_ID 0x04
#define READ_STATUS 0x09
#define READ_POWER_MODE 0x0A
#define READ_MADCTL 0x0B
#define READ_PIXEL_FORMAT 0x0C
#define READ_IMAGE_FORMAT 0x0D
#define READ_SIGNAL_MODE 0x0E
#define READ_SELT_DIAG_RESULT 0x0F
#define SLEEP_ON 0x10
#define SLEEP_OFF 0x11
#define PARTIAL_DISPALY_ON 0x12
#define NORMAL_DISPALY_ON 0x13
#define INVERSION_DISPALY_OFF 0x20
#define INVERSION_DISPALY_ON 0x21
#define GAMMA_SET 0x26
#define DISPALY_OFF 0x28
#define DISPALY_ON 0x29
#define HORIZONTAL_ADDRESS_SET 0x2A
#define VERTICAL_ADDRESS_SET 0x2B
#define MEMORY_WRITE 0x2C
#define COLOR_SET 0x2D
#define MEMORY_READ 0x2E
#define PARTIAL_AREA 0x30
#define VERTICAL_SCROL_DEFINE 0x33
#define TEAR_EFFECT_LINE_OFF 0x34
#define TEAR_EFFECT_LINE_ON 0x35
#define MEMORY_ACCESS_CTL 0x36
#define VERTICAL_SCROL_S_ADD 0x37
#define IDLE_MODE_OFF 0x38
#define IDLE_MODE_ON 0x39
#define PIXEL_FORMAT_SET 0x3A
#define WRITE_MEMORY_CONTINUE 0x3C
#define READ_MEMORY_CONTINUE 0x3E
#define SET_TEAR_SCANLINE 0x44
#define GET_SCANLINE 0x45
#define WRITE_BRIGHTNESS 0x51
#define READ_BRIGHTNESS 0x52
#define WRITE_CTRL_DISPALY 0x53
#define READ_CTRL_DISPALY 0x54
#define WRITE_BRIGHTNESS_CTL 0x55
#define READ_BRIGHTNESS_CTL 0x56
#define WRITE_MIN_BRIGHTNESS 0x5E
#define READ_MIN_BRIGHTNESS 0x5F
#define READ_ID1 0xDA
#define READ_ID2 0xDB
#define READ_ID3 0xDC
#define RGB_IF_SIGNAL_CTL 0xB0
#define NORMAL_FRAME_CTL 0xB1
#define IDLE_FRAME_CTL 0xB2
#define PARTIAL_FRAME_CTL 0xB3
#define INVERSION_CTL 0xB4
#define BLANK_PORCH_CTL 0xB5
#define DISPALY_FUNCTION_CTL 0xB6
#define ENTRY_MODE_SET 0xB7
#define BACKLIGHT_CTL1 0xB8
#define BACKLIGHT_CTL2 0xB9
#define BACKLIGHT_CTL3 0xBA
#define BACKLIGHT_CTL4 0xBB
#define BACKLIGHT_CTL5 0xBC
#define BACKLIGHT_CTL7 0xBE
#define BACKLIGHT_CTL8 0xBF
#define POWER_CTL1 0xC0
#define POWER_CTL2 0xC1
#define VCOM_CTL1 0xC5
#define VCOM_CTL2 0xC7
#define NV_MEMORY_WRITE 0xD0
#define NV_MEMORY_PROTECT_KEY 0xD1
#define NV_MEMORY_STATUS_READ 0xD2
#define READ_ID4 0xD3
#define POSITIVE_GAMMA_CORRECT 0xE0
#define NEGATIVE_GAMMA_CORRECT 0xE1
#define DIGITAL_GAMMA_CTL1 0xE2
#define DIGITAL_GAMMA_CTL2 0xE3
#define INTERFACE_CTL 0xF6
#define DCX_GPIONUM (5)
#define RST_GPIONUM (4)
#define LCD_SPI_SLAVE_SELECT 3
#define SPI_CHANNEL 0
#define SPI_SLAVE_SELECT 3
/* clang-format off */
#define LCD_X_MAX (240)
#define LCD_Y_MAX (320)
#define BLACK 0x0000
#define NAVY 0x000F
#define DARKGREEN 0x03E0
#define DARKCYAN 0x03EF
#define MAROON 0x7800
#define PURPLE 0x780F
#define OLIVE 0x7BE0
#define LIGHTGREY 0xC618
#define DARKGREY 0x7BEF
#define BLUE 0x001F
#define GREEN 0x07E0
#define CYAN 0x07FF
#define RED 0xF800
#define MAGENTA 0xF81F
#define YELLOW 0xFFE0
#define WHITE 0xFFFF
#define ORANGE 0xFD20
#define GREENYELLOW 0xAFE5
#define PINK 0xF81F
#define USER_COLOR 0xAA55
/* clang-format on */
uint8_t const ascii0816[] =
{
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7E, 0x81, 0xA5, 0x81, 0x81, 0xBD,
0x99, 0x81, 0x81, 0x7E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7E, 0xFF,
0xDB, 0xFF, 0xFF, 0xC3, 0xE7, 0xFF, 0xFF, 0x7E, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x6C, 0xFE, 0xFE, 0xFE, 0xFE, 0x7C, 0x38, 0x10,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x38, 0x7C, 0xFE,
0x7C, 0x38, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18,
0x3C, 0x3C, 0xE7, 0xE7, 0xE7, 0x18, 0x18, 0x3C, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x18, 0x3C, 0x7E, 0xFF, 0xFF, 0x7E, 0x18, 0x18, 0x3C,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x3C,
0x3C, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xE7, 0xC3, 0xC3, 0xE7, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0x00, 0x00, 0x00, 0x00, 0x00, 0x3C, 0x66, 0x42, 0x42, 0x66, 0x3C, 0x00,
0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xC3, 0x99, 0xBD,
0xBD, 0x99, 0xC3, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x1E, 0x0E,
0x1A, 0x32, 0x78, 0xCC, 0xCC, 0xCC, 0xCC, 0x78, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x3C, 0x66, 0x66, 0x66, 0x66, 0x3C, 0x18, 0x7E, 0x18, 0x18,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3F, 0x33, 0x3F, 0x30, 0x30, 0x30,
0x30, 0x70, 0xF0, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7F, 0x63,
0x7F, 0x63, 0x63, 0x63, 0x63, 0x67, 0xE7, 0xE6, 0xC0, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x18, 0x18, 0xDB, 0x3C, 0xE7, 0x3C, 0xDB, 0x18, 0x18,
0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xC0, 0xE0, 0xF0, 0xF8, 0xFE, 0xF8,
0xF0, 0xE0, 0xC0, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x06, 0x0E,
0x1E, 0x3E, 0xFE, 0x3E, 0x1E, 0x0E, 0x06, 0x02, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x18, 0x3C, 0x7E, 0x18, 0x18, 0x18, 0x7E, 0x3C, 0x18, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66,
0x66, 0x00, 0x66, 0x66, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7F, 0xDB,
0xDB, 0xDB, 0x7B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x00, 0x00, 0x00, 0x00,
0x00, 0x7C, 0xC6, 0x60, 0x38, 0x6C, 0xC6, 0xC6, 0x6C, 0x38, 0x0C, 0xC6,
0x7C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0xFE, 0xFE, 0xFE, 0xFE, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x3C,
0x7E, 0x18, 0x18, 0x18, 0x7E, 0x3C, 0x18, 0x7E, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x18, 0x3C, 0x7E, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18,
0x18, 0x7E, 0x3C, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x18, 0x0C, 0xFE, 0x0C, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x60, 0xFE, 0x60, 0x30, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0xC0,
0xC0, 0xFE, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x28, 0x6C, 0xFE, 0x6C, 0x28, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x10, 0x38, 0x38, 0x7C, 0x7C, 0xFE, 0xFE, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFE, 0xFE, 0x7C, 0x7C,
0x38, 0x38, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x18, 0x3C, 0x3C, 0x3C, 0x18, 0x18, 0x18, 0x00, 0x18, 0x18,
0x00, 0x00, 0x00, 0x00, 0x00, 0x66, 0x66, 0x66, 0x24, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6C,
0x6C, 0xFE, 0x6C, 0x6C, 0x6C, 0xFE, 0x6C, 0x6C, 0x00, 0x00, 0x00, 0x00,
0x18, 0x18, 0x7C, 0xC6, 0xC2, 0xC0, 0x7C, 0x06, 0x06, 0x86, 0xC6, 0x7C,
0x18, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC2, 0xC6, 0x0C, 0x18,
0x30, 0x60, 0xC6, 0x86, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x6C,
0x6C, 0x38, 0x76, 0xDC, 0xCC, 0xCC, 0xCC, 0x76, 0x00, 0x00, 0x00, 0x00,
0x00, 0x30, 0x30, 0x30, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0C, 0x18, 0x30, 0x30, 0x30, 0x30,
0x30, 0x30, 0x18, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x18,
0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x18, 0x30, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x66, 0x3C, 0xFF, 0x3C, 0x66, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x7E,
0x18, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x18, 0x30, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFE, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x02, 0x06, 0x0C, 0x18, 0x30, 0x60, 0xC0, 0x80, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x38, 0x6C, 0xC6, 0xC6, 0xD6, 0xD6, 0xC6, 0xC6, 0x6C, 0x38,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x38, 0x78, 0x18, 0x18, 0x18,
0x18, 0x18, 0x18, 0x7E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7C, 0xC6,
0x06, 0x0C, 0x18, 0x30, 0x60, 0xC0, 0xC6, 0xFE, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x7C, 0xC6, 0x06, 0x06, 0x3C, 0x06, 0x06, 0x06, 0xC6, 0x7C,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0C, 0x1C, 0x3C, 0x6C, 0xCC, 0xFE,
0x0C, 0x0C, 0x0C, 0x1E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFE, 0xC0,
0xC0, 0xC0, 0xFC, 0x06, 0x06, 0x06, 0xC6, 0x7C, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x38, 0x60, 0xC0, 0xC0, 0xFC, 0xC6, 0xC6, 0xC6, 0xC6, 0x7C,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFE, 0xC6, 0x06, 0x06, 0x0C, 0x18,
0x30, 0x30, 0x30, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7C, 0xC6,
0xC6, 0xC6, 0x7C, 0xC6, 0xC6, 0xC6, 0xC6, 0x7C, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x7C, 0xC6, 0xC6, 0xC6, 0x7E, 0x06, 0x06, 0x06, 0x0C, 0x78,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00,
0x00, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x18, 0x18, 0x00, 0x00, 0x00, 0x18, 0x18, 0x30, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x06, 0x0C, 0x18, 0x30, 0x60, 0x30, 0x18, 0x0C, 0x06,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7E, 0x00, 0x00,
0x7E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x60,
0x30, 0x18, 0x0C, 0x06, 0x0C, 0x18, 0x30, 0x60, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x7C, 0xC6, 0xC6, 0x0C, 0x18, 0x18, 0x18, 0x00, 0x18, 0x18,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7C, 0xC6, 0xC6, 0xDE, 0xDE,
0xDE, 0xDC, 0xC0, 0x7C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x38,
0x6C, 0xC6, 0xC6, 0xFE, 0xC6, 0xC6, 0xC6, 0xC6, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0xFC, 0x66, 0x66, 0x66, 0x7C, 0x66, 0x66, 0x66, 0x66, 0xFC,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3C, 0x66, 0xC2, 0xC0, 0xC0, 0xC0,
0xC0, 0xC2, 0x66, 0x3C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF8, 0x6C,
0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x6C, 0xF8, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0xFE, 0x66, 0x62, 0x68, 0x78, 0x68, 0x60, 0x62, 0x66, 0xFE,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFE, 0x66, 0x62, 0x68, 0x78, 0x68,
0x60, 0x60, 0x60, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3C, 0x66,
0xC2, 0xC0, 0xC0, 0xDE, 0xC6, 0xC6, 0x66, 0x3A, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0xC6, 0xC6, 0xC6, 0xC6, 0xFE, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3C, 0x18, 0x18, 0x18, 0x18, 0x18,
0x18, 0x18, 0x18, 0x3C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1E, 0x0C,
0x0C, 0x0C, 0x0C, 0x0C, 0xCC, 0xCC, 0xCC, 0x78, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0xE6, 0x66, 0x66, 0x6C, 0x78, 0x78, 0x6C, 0x66, 0x66, 0xE6,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF0, 0x60, 0x60, 0x60, 0x60, 0x60,
0x60, 0x62, 0x66, 0xFE, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC6, 0xEE,
0xFE, 0xFE, 0xD6, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0xC6, 0xE6, 0xF6, 0xFE, 0xDE, 0xCE, 0xC6, 0xC6, 0xC6, 0xC6,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7C, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6,
0xC6, 0xC6, 0xC6, 0x7C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFC, 0x66,
0x66, 0x66, 0x7C, 0x60, 0x60, 0x60, 0x60, 0xF0, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x7C, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0xD6, 0xDE, 0x7C,
0x0C, 0x0E, 0x00, 0x00, 0x00, 0x00, 0xFC, 0x66, 0x66, 0x66, 0x7C, 0x6C,
0x66, 0x66, 0x66, 0xE6, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7C, 0xC6,
0xC6, 0x60, 0x38, 0x0C, 0x06, 0xC6, 0xC6, 0x7C, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x7E, 0x7E, 0x5A, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x3C,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6,
0xC6, 0xC6, 0xC6, 0x7C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC6, 0xC6,
0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0x6C, 0x38, 0x10, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0xC6, 0xC6, 0xC6, 0xC6, 0xD6, 0xD6, 0xD6, 0xFE, 0xEE, 0x6C,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC6, 0xC6, 0x6C, 0x7C, 0x38, 0x38,
0x7C, 0x6C, 0xC6, 0xC6, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x66, 0x66,
0x66, 0x66, 0x3C, 0x18, 0x18, 0x18, 0x18, 0x3C, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0xFE, 0xC6, 0x86, 0x0C, 0x18, 0x30, 0x60, 0xC2, 0xC6, 0xFE,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3C, 0x30, 0x30, 0x30, 0x30, 0x30,
0x30, 0x30, 0x30, 0x3C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80,
0xC0, 0xE0, 0x70, 0x38, 0x1C, 0x0E, 0x06, 0x02, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x3C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x3C,
0x00, 0x00, 0x00, 0x00, 0x10, 0x38, 0x6C, 0xC6, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00,
0x30, 0x30, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x78, 0x0C, 0x7C,
0xCC, 0xCC, 0xCC, 0x76, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE0, 0x60,
0x60, 0x78, 0x6C, 0x66, 0x66, 0x66, 0x66, 0x7C, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x7C, 0xC6, 0xC0, 0xC0, 0xC0, 0xC6, 0x7C,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1C, 0x0C, 0x0C, 0x3C, 0x6C, 0xCC,
0xCC, 0xCC, 0xCC, 0x76, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x7C, 0xC6, 0xFE, 0xC0, 0xC0, 0xC6, 0x7C, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x38, 0x6C, 0x64, 0x60, 0xF0, 0x60, 0x60, 0x60, 0x60, 0xF0,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x76, 0xCC, 0xCC,
0xCC, 0xCC, 0xCC, 0x7C, 0x0C, 0xCC, 0x78, 0x00, 0x00, 0x00, 0xE0, 0x60,
0x60, 0x6C, 0x76, 0x66, 0x66, 0x66, 0x66, 0xE6, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x18, 0x18, 0x00, 0x38, 0x18, 0x18, 0x18, 0x18, 0x18, 0x3C,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x06, 0x00, 0x0E, 0x06, 0x06,
0x06, 0x06, 0x06, 0x06, 0x66, 0x66, 0x3C, 0x00, 0x00, 0x00, 0xE0, 0x60,
0x60, 0x66, 0x6C, 0x78, 0x78, 0x6C, 0x66, 0xE6, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x38, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x3C,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xEC, 0xFE, 0xD6,
0xD6, 0xD6, 0xD6, 0xC6, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0xDC, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x7C, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0x7C,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xDC, 0x66, 0x66,
0x66, 0x66, 0x66, 0x7C, 0x60, 0x60, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x76, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0x7C, 0x0C, 0x0C, 0x1E, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0xDC, 0x76, 0x66, 0x60, 0x60, 0x60, 0xF0,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7C, 0xC6, 0x60,
0x38, 0x0C, 0xC6, 0x7C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x30,
0x30, 0xFC, 0x30, 0x30, 0x30, 0x30, 0x36, 0x1C, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0x76,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x66, 0x66, 0x66,
0x66, 0x66, 0x3C, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0xC6, 0xC6, 0xD6, 0xD6, 0xD6, 0xFE, 0x6C, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0xC6, 0x6C, 0x38, 0x38, 0x38, 0x6C, 0xC6,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC6, 0xC6, 0xC6,
0xC6, 0xC6, 0xC6, 0x7E, 0x06, 0x0C, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0xFE, 0xCC, 0x18, 0x30, 0x60, 0xC6, 0xFE, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x0E, 0x18, 0x18, 0x18, 0x70, 0x18, 0x18, 0x18, 0x18, 0x0E,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x18, 0x18, 0x00, 0x18,
0x18, 0x18, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x70, 0x18,
0x18, 0x18, 0x0E, 0x18, 0x18, 0x18, 0x18, 0x70, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x76, 0xDC, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x38, 0x6C, 0xC6,
0xC6, 0xC6, 0xFE, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3C, 0x66,
0xC2, 0xC0, 0xC0, 0xC0, 0xC2, 0x66, 0x3C, 0x0C, 0x06, 0x7C, 0x00, 0x00,
0x00, 0x00, 0xCC, 0x00, 0x00, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0x76,
0x00, 0x00, 0x00, 0x00, 0x00, 0x0C, 0x18, 0x30, 0x00, 0x7C, 0xC6, 0xFE,
0xC0, 0xC0, 0xC6, 0x7C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x38, 0x6C,
0x00, 0x78, 0x0C, 0x7C, 0xCC, 0xCC, 0xCC, 0x76, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0xCC, 0x00, 0x00, 0x78, 0x0C, 0x7C, 0xCC, 0xCC, 0xCC, 0x76,
0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0x30, 0x18, 0x00, 0x78, 0x0C, 0x7C,
0xCC, 0xCC, 0xCC, 0x76, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x6C, 0x38,
0x00, 0x78, 0x0C, 0x7C, 0xCC, 0xCC, 0xCC, 0x76, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x3C, 0x66, 0x60, 0x60, 0x66, 0x3C, 0x0C, 0x06,
0x3C, 0x00, 0x00, 0x00, 0x00, 0x10, 0x38, 0x6C, 0x00, 0x7C, 0xC6, 0xFE,
0xC0, 0xC0, 0xC6, 0x7C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC6, 0x00,
0x00, 0x7C, 0xC6, 0xFE, 0xC0, 0xC0, 0xC6, 0x7C, 0x00, 0x00, 0x00, 0x00,
0x00, 0x60, 0x30, 0x18, 0x00, 0x7C, 0xC6, 0xFE, 0xC0, 0xC0, 0xC6, 0x7C,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x66, 0x00, 0x00, 0x38, 0x18, 0x18,
0x18, 0x18, 0x18, 0x3C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x3C, 0x66,
0x00, 0x38, 0x18, 0x18, 0x18, 0x18, 0x18, 0x3C, 0x00, 0x00, 0x00, 0x00,
0x00, 0x60, 0x30, 0x18, 0x00, 0x38, 0x18, 0x18, 0x18, 0x18, 0x18, 0x3C,
0x00, 0x00, 0x00, 0x00, 0x00, 0xC6, 0x00, 0x10, 0x38, 0x6C, 0xC6, 0xC6,
0xFE, 0xC6, 0xC6, 0xC6, 0x00, 0x00, 0x00, 0x00, 0x38, 0x6C, 0x38, 0x00,
0x38, 0x6C, 0xC6, 0xC6, 0xFE, 0xC6, 0xC6, 0xC6, 0x00, 0x00, 0x00, 0x00,
0x18, 0x30, 0x60, 0x00, 0xFE, 0x66, 0x60, 0x7C, 0x60, 0x60, 0x66, 0xFE,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xCC, 0x76, 0x36,
0x7E, 0xD8, 0xD8, 0x6E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3E, 0x6C,
0xCC, 0xCC, 0xFE, 0xCC, 0xCC, 0xCC, 0xCC, 0xCE, 0x00, 0x00, 0x00, 0x00,
0x00, 0x10, 0x38, 0x6C, 0x00, 0x7C, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0x7C,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC6, 0x00, 0x00, 0x7C, 0xC6, 0xC6,
0xC6, 0xC6, 0xC6, 0x7C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0x30, 0x18,
0x00, 0x7C, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0x7C, 0x00, 0x00, 0x00, 0x00,
0x00, 0x30, 0x78, 0xCC, 0x00, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0x76,
0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0x30, 0x18, 0x00, 0xCC, 0xCC, 0xCC,
0xCC, 0xCC, 0xCC, 0x76, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC6, 0x00,
0x00, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0x7E, 0x06, 0x0C, 0x78, 0x00,
0x00, 0xC6, 0x00, 0x7C, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0x7C,
0x00, 0x00, 0x00, 0x00, 0x00, 0xC6, 0x00, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6,
0xC6, 0xC6, 0xC6, 0x7C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x3C,
0x66, 0x60, 0x60, 0x60, 0x66, 0x3C, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00,
0x00, 0x38, 0x6C, 0x64, 0x60, 0xF0, 0x60, 0x60, 0x60, 0x60, 0xE6, 0xFC,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x66, 0x66, 0x3C, 0x18, 0x7E, 0x18,
0x7E, 0x18, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF8, 0xCC, 0xCC,
0xF8, 0xC4, 0xCC, 0xDE, 0xCC, 0xCC, 0xCC, 0xC6, 0x00, 0x00, 0x00, 0x00,
0x00, 0x0E, 0x1B, 0x18, 0x18, 0x18, 0x7E, 0x18, 0x18, 0x18, 0x18, 0x18,
0xD8, 0x70, 0x00, 0x00, 0x00, 0x18, 0x30, 0x60, 0x00, 0x78, 0x0C, 0x7C,
0xCC, 0xCC, 0xCC, 0x76, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0C, 0x18, 0x30,
0x00, 0x38, 0x18, 0x18, 0x18, 0x18, 0x18, 0x3C, 0x00, 0x00, 0x00, 0x00,
0x00, 0x18, 0x30, 0x60, 0x00, 0x7C, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0x7C,
0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x30, 0x60, 0x00, 0xCC, 0xCC, 0xCC,
0xCC, 0xCC, 0xCC, 0x76, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x76, 0xDC,
0x00, 0xDC, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x00, 0x00, 0x00, 0x00,
0x76, 0xDC, 0x00, 0xC6, 0xE6, 0xF6, 0xFE, 0xDE, 0xCE, 0xC6, 0xC6, 0xC6,
0x00, 0x00, 0x00, 0x00, 0x00, 0x3C, 0x6C, 0x6C, 0x3E, 0x00, 0x7E, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x6C, 0x6C,
0x38, 0x00, 0x7C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x30, 0x30, 0x00, 0x30, 0x30, 0x60, 0xC0, 0xC6, 0xC6, 0x7C,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFE, 0xC0,
0xC0, 0xC0, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0xFE, 0x06, 0x06, 0x06, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0xC0, 0xC0, 0xC2, 0xC6, 0xCC, 0x18, 0x30, 0x60, 0xDC, 0x86, 0x0C,
0x18, 0x3E, 0x00, 0x00, 0x00, 0xC0, 0xC0, 0xC2, 0xC6, 0xCC, 0x18, 0x30,
0x66, 0xCE, 0x9E, 0x3E, 0x06, 0x06, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18,
0x00, 0x18, 0x18, 0x18, 0x3C, 0x3C, 0x3C, 0x18, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x36, 0x6C, 0xD8, 0x6C, 0x36, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xD8, 0x6C, 0x36,
0x6C, 0xD8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, 0x44, 0x11, 0x44,
0x11, 0x44, 0x11, 0x44, 0x11, 0x44, 0x11, 0x44, 0x11, 0x44, 0x11, 0x44,
0x55, 0xAA, 0x55, 0xAA, 0x55, 0xAA, 0x55, 0xAA, 0x55, 0xAA, 0x55, 0xAA,
0x55, 0xAA, 0x55, 0xAA, 0xDD, 0x77, 0xDD, 0x77, 0xDD, 0x77, 0xDD, 0x77,
0xDD, 0x77, 0xDD, 0x77, 0xDD, 0x77, 0xDD, 0x77, 0x18, 0x18, 0x18, 0x18,
0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18,
0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0xF8, 0x18, 0x18, 0x18, 0x18,
0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0xF8, 0x18, 0xF8,
0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x36, 0x36, 0x36, 0x36,
0x36, 0x36, 0x36, 0xF6, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFE, 0x36, 0x36, 0x36, 0x36,
0x36, 0x36, 0x36, 0x36, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF8, 0x18, 0xF8,
0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x36, 0x36, 0x36, 0x36,
0x36, 0xF6, 0x06, 0xF6, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36,
0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36,
0x36, 0x36, 0x36, 0x36, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFE, 0x06, 0xF6,
0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36,
0x36, 0xF6, 0x06, 0xFE, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0xFE, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x18, 0x18, 0x18, 0xF8, 0x18, 0xF8,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0xF8, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18,
0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x1F, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0xFF,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0xFF, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18,
0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x1F, 0x18, 0x18, 0x18, 0x18,
0x18, 0x18, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x18, 0x18,
0x18, 0x18, 0x18, 0xFF, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18,
0x18, 0x18, 0x18, 0x18, 0x18, 0x1F, 0x18, 0x1F, 0x18, 0x18, 0x18, 0x18,
0x18, 0x18, 0x18, 0x18, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x37,
0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36,
0x36, 0x37, 0x30, 0x3F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x3F, 0x30, 0x37, 0x36, 0x36, 0x36, 0x36,
0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0xF7, 0x00, 0xFF,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0xFF, 0x00, 0xF7, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36,
0x36, 0x36, 0x36, 0x36, 0x36, 0x37, 0x30, 0x37, 0x36, 0x36, 0x36, 0x36,
0x36, 0x36, 0x36, 0x36, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0xFF,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x36, 0x36, 0x36, 0x36,
0x36, 0xF7, 0x00, 0xF7, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36,
0x18, 0x18, 0x18, 0x18, 0x18, 0xFF, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0xFF,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0xFF, 0x00, 0xFF, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x36, 0x36, 0x36, 0x36,
0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x3F,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x18, 0x18,
0x18, 0x1F, 0x18, 0x1F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x1F, 0x18, 0x1F, 0x18, 0x18, 0x18, 0x18,
0x18, 0x18, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3F,
0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36,
0x36, 0x36, 0x36, 0xFF, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36,
0x18, 0x18, 0x18, 0x18, 0x18, 0xFF, 0x18, 0xFF, 0x18, 0x18, 0x18, 0x18,
0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0xF8,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x1F, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF0, 0xF0, 0xF0, 0xF0,
0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0,
0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F,
0x0F, 0x0F, 0x0F, 0x0F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x76, 0xDC, 0xD8, 0xD8, 0xD8, 0xDC, 0x76, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x78, 0xCC, 0xCC, 0xCC, 0xD8, 0xCC, 0xC6, 0xC6, 0xC6, 0xCC,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFE, 0xC6, 0xC6, 0xC0, 0xC0, 0xC0,
0xC0, 0xC0, 0xC0, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0xFE, 0x6C, 0x6C, 0x6C, 0x6C, 0x6C, 0x6C, 0x6C, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0xFE, 0xC6, 0x60, 0x30, 0x18, 0x30, 0x60, 0xC6, 0xFE,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7E, 0xD8, 0xD8,
0xD8, 0xD8, 0xD8, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x66, 0x66, 0x66, 0x66, 0x66, 0x7C, 0x60, 0x60, 0xC0, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x76, 0xDC, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7E, 0x18, 0x3C, 0x66, 0x66,
0x66, 0x3C, 0x18, 0x7E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38,
0x6C, 0xC6, 0xC6, 0xFE, 0xC6, 0xC6, 0x6C, 0x38, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x38, 0x6C, 0xC6, 0xC6, 0xC6, 0x6C, 0x6C, 0x6C, 0x6C, 0xEE,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1E, 0x30, 0x18, 0x0C, 0x3E, 0x66,
0x66, 0x66, 0x66, 0x3C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x7E, 0xDB, 0xDB, 0xDB, 0x7E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x03, 0x06, 0x7E, 0xDB, 0xDB, 0xF3, 0x7E, 0x60, 0xC0,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1C, 0x30, 0x60, 0x60, 0x7C, 0x60,
0x60, 0x60, 0x30, 0x1C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7C,
0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0xFE, 0x00, 0x00, 0xFE, 0x00, 0x00, 0xFE, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x7E, 0x18,
0x18, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30,
0x18, 0x0C, 0x06, 0x0C, 0x18, 0x30, 0x00, 0x7E, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x0C, 0x18, 0x30, 0x60, 0x30, 0x18, 0x0C, 0x00, 0x7E,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0E, 0x1B, 0x1B, 0x18, 0x18, 0x18,
0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18,
0x18, 0x18, 0x18, 0x18, 0xD8, 0xD8, 0xD8, 0x70, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x7E, 0x00, 0x18, 0x18, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x76, 0xDC, 0x00,
0x76, 0xDC, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x6C, 0x6C,
0x38, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0F, 0x0C, 0x0C,
0x0C, 0x0C, 0x0C, 0xEC, 0x6C, 0x6C, 0x3C, 0x1C, 0x00, 0x00, 0x00, 0x00,
0x00, 0xD8, 0x6C, 0x6C, 0x6C, 0x6C, 0x6C, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x70, 0xD8, 0x30, 0x60, 0xC8, 0xF8, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x7C, 0x7C, 0x7C, 0x7C, 0x7C, 0x7C, 0x7C, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00
};
//POINT_COLOR
#define WHITE 0xFFFF
#define BLACK 0x0000
#define BLUE 0x001F
#define BRED 0XF81F
#define GRED 0XFFE0
#define GBLUE 0X07FF
#define RED 0xF800
#define MAGENTA 0xF81F
#define GREEN 0x07E0
#define CYAN 0x7FFF
#define YELLOW 0xFFE0
#define BROWN 0XBC40
#define BRRED 0XFC07
#define GRAY 0X8430
#define GRAY175 0XAD75
#define GRAY151 0X94B2
#define GRAY187 0XBDD7
#define GRAY240 0XF79E
typedef enum _lcd_dir typedef enum _lcd_dir
{ {
@ -490,31 +53,38 @@ typedef enum _lcd_dir
DIR_MASK = 0xE0, DIR_MASK = 0xE0,
} lcd_dir_t; } lcd_dir_t;
typedef struct _lcd_ctl typedef struct lcd_8080_device
{ {
uint8_t mode; struct rt_device parent;
uint8_t dir; struct rt_device_graphic_info lcd_info;
uint16_t width; int spi_channel;
uint16_t height; int cs;
} lcd_ctl_t; int dc_pin;
#if BSP_LCD_RST_PIN >= 0
int rst_pin;
#endif
#if BSP_LCD_BACKLIGHT_PIN >= 0
int backlight_pin;
#endif
int dma_channel;
} * lcd_8080_device_t;
void tft_hard_init(void); int rt_hw_lcd_init(void);
void tft_write_command(uint8_t cmd); void drv_lcd_set_area(lcd_8080_device_t lcd, rt_uint16_t x1, rt_uint16_t y1, rt_uint16_t x2, rt_uint16_t y2);
void tft_write_byte(uint8_t *data_buf, uint32_t length); void drv_lcd_data_word(lcd_8080_device_t lcd, rt_uint32_t *data_buf, rt_uint32_t length);
void tft_write_half(uint16_t *data_buf, uint32_t length); void drv_lcd_data_half_word(lcd_8080_device_t lcd, rt_uint16_t *data_buf, rt_uint32_t length);
void tft_write_word(uint32_t *data_buf, uint32_t length, uint32_t flag);
void tft_fill_data(uint32_t *data_buf, uint32_t length);
void lcd_polling_enable(void); /* for mpy machine.lcd */
void lcd_interrupt_enable(void); void lcd_display_on(void);
int lcd_init(void); void lcd_display_off(void);
void lcd_clear(uint16_t color); void lcd_clear(int color);
void lcd_draw_point_color(int x, int y, int color);
void lcd_show_string(int x, int y, int size, const char *data);
void lcd_draw_line(int x1, int y1, int x2, int y2);
void lcd_draw_rectangle(int x1, int y1, int x2, int y2);
void lcd_draw_circle(int x1, int y1, int r);
void lcd_set_color(int back, int fore);
void lcd_show_image(int x, int y, int length, int wide, const unsigned char *buf);
void lcd_set_direction(lcd_dir_t dir); void lcd_set_direction(lcd_dir_t dir);
void lcd_set_area(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2);
void lcd_draw_point(uint16_t x, uint16_t y, uint16_t color);
void lcd_draw_string(uint16_t x, uint16_t y, char *str, uint16_t color);
void lcd_draw_picture(uint16_t x1, uint16_t y1, uint16_t width, uint16_t height, uint32_t *ptr);
void lcd_draw_rectangle(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint16_t width, uint16_t color);
void lcd_ram_draw_string(char *str, uint32_t *ptr, uint16_t font_color, uint16_t bg_color);
#endif #endif

View File

@ -18,12 +18,13 @@
#define RT_ALIGN_SIZE 8 #define RT_ALIGN_SIZE 8
#define RT_THREAD_PRIORITY_32 #define RT_THREAD_PRIORITY_32
#define RT_THREAD_PRIORITY_MAX 32 #define RT_THREAD_PRIORITY_MAX 32
#define RT_TICK_PER_SECOND 1000 #define RT_TICK_PER_SECOND 100
#define RT_USING_OVERFLOW_CHECK #define RT_USING_OVERFLOW_CHECK
#define RT_USING_HOOK #define RT_USING_HOOK
#define RT_USING_IDLE_HOOK #define RT_USING_IDLE_HOOK
#define RT_IDLE_HOOK_LIST_SIZE 4 #define RT_IDLE_HOOK_LIST_SIZE 4
#define IDLE_THREAD_STACK_SIZE 4096 #define IDLE_THREAD_STACK_SIZE 4096
#define SYSTEM_THREAD_STACK_SIZE 4096
/* kservice optimization */ /* kservice optimization */
@ -70,21 +71,22 @@
/* C++ features */ /* C++ features */
#define RT_USING_CPLUSPLUS
/* Command shell */ /* Command shell */
#define RT_USING_FINSH #define RT_USING_FINSH
#define RT_USING_MSH
#define FINSH_USING_MSH
#define FINSH_THREAD_NAME "tshell" #define FINSH_THREAD_NAME "tshell"
#define FINSH_THREAD_PRIORITY 20
#define FINSH_THREAD_STACK_SIZE 16384
#define FINSH_USING_HISTORY #define FINSH_USING_HISTORY
#define FINSH_HISTORY_LINES 5 #define FINSH_HISTORY_LINES 5
#define FINSH_USING_SYMTAB #define FINSH_USING_SYMTAB
#define FINSH_USING_DESCRIPTION
#define FINSH_THREAD_PRIORITY 20
#define FINSH_THREAD_STACK_SIZE 16384
#define FINSH_CMD_SIZE 80 #define FINSH_CMD_SIZE 80
#define FINSH_USING_MSH #define MSH_USING_BUILT_IN_COMMANDS
#define FINSH_USING_MSH_DEFAULT #define FINSH_USING_DESCRIPTION
#define FINSH_USING_MSH_ONLY
#define FINSH_ARG_MAX 10 #define FINSH_ARG_MAX 10
/* Device virtual file system */ /* Device virtual file system */
@ -108,6 +110,7 @@
#define RT_DFS_ELM_DRIVES 2 #define RT_DFS_ELM_DRIVES 2
#define RT_DFS_ELM_MAX_SECTOR_SIZE 4096 #define RT_DFS_ELM_MAX_SECTOR_SIZE 4096
#define RT_DFS_ELM_REENTRANT #define RT_DFS_ELM_REENTRANT
#define RT_DFS_ELM_MUTEX_TIMEOUT 3000
#define RT_USING_DFS_DEVFS #define RT_USING_DFS_DEVFS
/* Device Drivers */ /* Device Drivers */
@ -118,9 +121,11 @@
#define RT_SYSTEM_WORKQUEUE_STACKSIZE 2048 #define RT_SYSTEM_WORKQUEUE_STACKSIZE 2048
#define RT_SYSTEM_WORKQUEUE_PRIORITY 23 #define RT_SYSTEM_WORKQUEUE_PRIORITY 23
#define RT_USING_SERIAL #define RT_USING_SERIAL
#define RT_USING_SERIAL_V1
#define RT_SERIAL_USING_DMA #define RT_SERIAL_USING_DMA
#define RT_SERIAL_RB_BUFSZ 64 #define RT_SERIAL_RB_BUFSZ 64
#define RT_USING_PIN #define RT_USING_PIN
#define RT_USING_RTC
#define RT_USING_SPI #define RT_USING_SPI
#define RT_USING_SPI_MSD #define RT_USING_SPI_MSD
#define RT_USING_SFUD #define RT_USING_SFUD
@ -163,7 +168,8 @@
#define RT_USING_PTHREADS #define RT_USING_PTHREADS
#define PTHREAD_NUM_MAX 8 #define PTHREAD_NUM_MAX 8
#define RT_USING_POSIX #define RT_USING_POSIX
#define RT_LIBC_FIXED_TIMEZONE 8 #define RT_LIBC_USING_TIME
#define RT_LIBC_DEFAULT_TIMEZONE 8
/* Network */ /* Network */
@ -174,7 +180,7 @@
/* protocol stack implement */ /* protocol stack implement */
#define SAL_USING_LWIP #define SAL_USING_LWIP
#define SAL_SOCKETS_NUM 16 #define SAL_USING_POSIX
/* Network interface device */ /* Network interface device */
@ -245,9 +251,14 @@
/* Board Drivers Config */ /* Board Drivers Config */
#define BSP_USING_UART_HS #define BSP_USING_UART_HS
/* General Purpose UARTs */
#define BSP_USING_UART1 #define BSP_USING_UART1
#define BSP_UART1_TXD_PIN 20 #define BSP_UART1_TXD_PIN 20
#define BSP_UART1_RXD_PIN 21 #define BSP_UART1_RXD_PIN 21
#define BSP_UART1_RTS_PIN -1
#define BSP_UART1_CTS_PIN -1
#define BSP_USING_SPI1 #define BSP_USING_SPI1
#define BSP_SPI1_CLK_PIN 27 #define BSP_SPI1_CLK_PIN 27
#define BSP_SPI1_D0_PIN 28 #define BSP_SPI1_D0_PIN 28
@ -261,6 +272,10 @@
#define BSP_LCD_WR_PIN 39 #define BSP_LCD_WR_PIN 39
#define BSP_LCD_DC_PIN 38 #define BSP_LCD_DC_PIN 38
#define BSP_LCD_RST_PIN 37 #define BSP_LCD_RST_PIN 37
#define BSP_LCD_BACKLIGHT_PIN -1
#define BSP_LCD_BACKLIGHT_ACTIVE_LOW
#define BSP_LCD_CLK_FREQ 20000000
#define BSP_BOARD_USER
#define BSP_LCD_X_MAX 240 #define BSP_LCD_X_MAX 240
#define BSP_LCD_Y_MAX 320 #define BSP_LCD_Y_MAX 320
#define BSP_USING_SDCARD #define BSP_USING_SDCARD
@ -276,6 +291,9 @@
#define BSP_DVP_CMOS_XCLK_PIN 46 #define BSP_DVP_CMOS_XCLK_PIN 46
#define BSP_DVP_CMOS_PCLK_PIN 47 #define BSP_DVP_CMOS_PCLK_PIN 47
#define BSP_DVP_CMOS_HREF_PIN 45 #define BSP_DVP_CMOS_HREF_PIN 45
#define RW007_SPIDEV_NAME "spi11"
#define RW007_INT_BUSY_PIN 7
#define RW007_RST_PIN 6
/* Kendryte SDK Config */ /* Kendryte SDK Config */
@ -283,6 +301,9 @@
/* More Drivers */ /* More Drivers */
#define PKG_USING_RW007
#define RW007_NOT_USE_EXAMPLE_DRIVERS
#define RW007_SPI_MAX_HZ 20000000
#define DRV_USING_OV2640 #define DRV_USING_OV2640
/* APP_Framework */ /* APP_Framework */
@ -303,23 +324,39 @@
/* knowing app */ /* knowing app */
#define APPLICATION_KNOWING
#define APP_MNIST
#define FACE_DETECT #define FACE_DETECT
/* sensor app */ /* sensor app */
#define APPLICATION_SENSOR
#define APPLICATION_SENSOR_VOICE
#define APPLICATION_SENSOR_VOICE_D124
/* Framework */ /* Framework */
#define TRANSFORM_LAYER_ATTRIUBUTE #define TRANSFORM_LAYER_ATTRIUBUTE
#define ADD_XIUOS_FETURES #define ADD_XIUOS_FETURES
#define SUPPORT_SENSOR_FRAMEWORK #define SUPPORT_SENSOR_FRAMEWORK
#define SENSOR_VOICE
#define SENSOR_D124
#define SENSOR_DEVICE_D124 "d124_1"
#define SENSOR_QUANTITY_D124_VOICE "voice_1"
#define SENSOR_DEVICE_D124_DEV "/dev/uar2"
#define SUPPORT_KNOWING_FRAMEWORK #define SUPPORT_KNOWING_FRAMEWORK
#define USING_TENSORFLOWLITEMICRO
#define USING_TENSORFLOWLITEMICRO_NORMAL
#define USING_KPU_POSTPROCESSING #define USING_KPU_POSTPROCESSING
#define USING_YOLOV2 #define USING_YOLOV2
/* app lib */ /* Security */
/* lib */
#define APP_SELECT_NEWLIB #define APP_SELECT_NEWLIB
#define LIB_USING_CJSON
#define __STACKSIZE__ 4096 #define __STACKSIZE__ 4096
#endif #endif

View File

@ -33,8 +33,9 @@ CONFIG_RT_TIMER_THREAD_STACK_SIZE=512
# #
# CONFIG_RT_KSERVICE_USING_STDLIB is not set # CONFIG_RT_KSERVICE_USING_STDLIB is not set
# CONFIG_RT_KSERVICE_USING_TINY_SIZE is not set # CONFIG_RT_KSERVICE_USING_TINY_SIZE is not set
# CONFIG_RT_USING_ASM_MEMCPY is not set
CONFIG_RT_DEBUG=y CONFIG_RT_DEBUG=y
# CONFIG_RT_DEBUG_COLOR is not set CONFIG_RT_DEBUG_COLOR=y
# CONFIG_RT_DEBUG_INIT_CONFIG is not set # CONFIG_RT_DEBUG_INIT_CONFIG is not set
# CONFIG_RT_DEBUG_THREAD_CONFIG is not set # CONFIG_RT_DEBUG_THREAD_CONFIG is not set
# CONFIG_RT_DEBUG_SCHEDULER_CONFIG is not set # CONFIG_RT_DEBUG_SCHEDULER_CONFIG is not set
@ -60,10 +61,12 @@ CONFIG_RT_USING_MESSAGEQUEUE=y
# Memory Management # Memory Management
# #
CONFIG_RT_USING_MEMPOOL=y CONFIG_RT_USING_MEMPOOL=y
# CONFIG_RT_USING_MEMHEAP is not set CONFIG_RT_USING_MEMHEAP=y
CONFIG_RT_USING_MEMHEAP_AUTO_BINDING=y
# CONFIG_RT_USING_NOHEAP is not set # CONFIG_RT_USING_NOHEAP is not set
CONFIG_RT_USING_SMALL_MEM=y # CONFIG_RT_USING_SMALL_MEM is not set
# CONFIG_RT_USING_SLAB is not set # CONFIG_RT_USING_SLAB is not set
CONFIG_RT_USING_MEMHEAP_AS_HEAP=y
# CONFIG_RT_USING_USERHEAP is not set # CONFIG_RT_USING_USERHEAP is not set
# CONFIG_RT_USING_MEMTRACE is not set # CONFIG_RT_USING_MEMTRACE is not set
CONFIG_RT_USING_HEAP=y CONFIG_RT_USING_HEAP=y
@ -77,6 +80,7 @@ CONFIG_RT_USING_DEVICE=y
CONFIG_RT_USING_CONSOLE=y CONFIG_RT_USING_CONSOLE=y
CONFIG_RT_CONSOLEBUF_SIZE=128 CONFIG_RT_CONSOLEBUF_SIZE=128
CONFIG_RT_CONSOLE_DEVICE_NAME="uart1" CONFIG_RT_CONSOLE_DEVICE_NAME="uart1"
# CONFIG_RT_PRINTF_LONGLONG is not set
CONFIG_RT_VER_NUM=0x40004 CONFIG_RT_VER_NUM=0x40004
CONFIG_ARCH_ARM=y CONFIG_ARCH_ARM=y
CONFIG_RT_USING_CPU_FFS=y CONFIG_RT_USING_CPU_FFS=y
@ -101,19 +105,19 @@ CONFIG_RT_MAIN_THREAD_PRIORITY=10
# Command shell # Command shell
# #
CONFIG_RT_USING_FINSH=y CONFIG_RT_USING_FINSH=y
CONFIG_RT_USING_MSH=y
CONFIG_FINSH_USING_MSH=y
CONFIG_FINSH_THREAD_NAME="tshell" CONFIG_FINSH_THREAD_NAME="tshell"
CONFIG_FINSH_THREAD_PRIORITY=20
CONFIG_FINSH_THREAD_STACK_SIZE=4096
CONFIG_FINSH_USING_HISTORY=y CONFIG_FINSH_USING_HISTORY=y
CONFIG_FINSH_HISTORY_LINES=5 CONFIG_FINSH_HISTORY_LINES=5
CONFIG_FINSH_USING_SYMTAB=y CONFIG_FINSH_USING_SYMTAB=y
CONFIG_FINSH_CMD_SIZE=80
CONFIG_MSH_USING_BUILT_IN_COMMANDS=y
CONFIG_FINSH_USING_DESCRIPTION=y CONFIG_FINSH_USING_DESCRIPTION=y
# CONFIG_FINSH_ECHO_DISABLE_DEFAULT is not set # CONFIG_FINSH_ECHO_DISABLE_DEFAULT is not set
CONFIG_FINSH_THREAD_PRIORITY=20
CONFIG_FINSH_THREAD_STACK_SIZE=4096
CONFIG_FINSH_CMD_SIZE=80
# CONFIG_FINSH_USING_AUTH is not set # CONFIG_FINSH_USING_AUTH is not set
CONFIG_FINSH_USING_MSH=y
CONFIG_FINSH_USING_MSH_DEFAULT=y
# CONFIG_FINSH_USING_MSH_ONLY is not set
CONFIG_FINSH_ARG_MAX=10 CONFIG_FINSH_ARG_MAX=10
# #
@ -147,17 +151,23 @@ CONFIG_RT_DFS_ELM_DRIVES=2
CONFIG_RT_DFS_ELM_MAX_SECTOR_SIZE=512 CONFIG_RT_DFS_ELM_MAX_SECTOR_SIZE=512
# CONFIG_RT_DFS_ELM_USE_ERASE is not set # CONFIG_RT_DFS_ELM_USE_ERASE is not set
CONFIG_RT_DFS_ELM_REENTRANT=y CONFIG_RT_DFS_ELM_REENTRANT=y
CONFIG_RT_DFS_ELM_MUTEX_TIMEOUT=3000
CONFIG_RT_USING_DFS_DEVFS=y CONFIG_RT_USING_DFS_DEVFS=y
# CONFIG_RT_USING_DFS_ROMFS is not set # CONFIG_RT_USING_DFS_ROMFS is not set
# CONFIG_RT_USING_DFS_RAMFS is not set # CONFIG_RT_USING_DFS_RAMFS is not set
# CONFIG_RT_USING_DFS_NFS is not set
# #
# Device Drivers # Device Drivers
# #
CONFIG_RT_USING_DEVICE_IPC=y CONFIG_RT_USING_DEVICE_IPC=y
CONFIG_RT_PIPE_BUFSZ=512 CONFIG_RT_PIPE_BUFSZ=512
# CONFIG_RT_USING_SYSTEM_WORKQUEUE is not set CONFIG_RT_USING_SYSTEM_WORKQUEUE=y
CONFIG_RT_SYSTEM_WORKQUEUE_STACKSIZE=2048
CONFIG_RT_SYSTEM_WORKQUEUE_PRIORITY=23
CONFIG_RT_USING_SERIAL=y CONFIG_RT_USING_SERIAL=y
CONFIG_RT_USING_SERIAL_V1=y
# CONFIG_RT_USING_SERIAL_V2 is not set
CONFIG_RT_SERIAL_USING_DMA=y CONFIG_RT_SERIAL_USING_DMA=y
CONFIG_RT_SERIAL_RB_BUFSZ=64 CONFIG_RT_SERIAL_RB_BUFSZ=64
# CONFIG_RT_USING_CAN is not set # CONFIG_RT_USING_CAN is not set
@ -190,7 +200,33 @@ CONFIG_RT_USING_SPI_MSD=y
# CONFIG_RT_USING_HWCRYPTO is not set # CONFIG_RT_USING_HWCRYPTO is not set
# CONFIG_RT_USING_PULSE_ENCODER is not set # CONFIG_RT_USING_PULSE_ENCODER is not set
# CONFIG_RT_USING_INPUT_CAPTURE is not set # CONFIG_RT_USING_INPUT_CAPTURE is not set
# CONFIG_RT_USING_WIFI is not set CONFIG_RT_USING_WIFI=y
CONFIG_RT_WLAN_DEVICE_STA_NAME="wlan0"
CONFIG_RT_WLAN_DEVICE_AP_NAME="wlan1"
CONFIG_RT_WLAN_SSID_MAX_LENGTH=32
CONFIG_RT_WLAN_PASSWORD_MAX_LENGTH=32
CONFIG_RT_WLAN_DEV_EVENT_NUM=2
CONFIG_RT_WLAN_MANAGE_ENABLE=y
CONFIG_RT_WLAN_SCAN_WAIT_MS=10000
CONFIG_RT_WLAN_CONNECT_WAIT_MS=10000
CONFIG_RT_WLAN_SCAN_SORT=y
CONFIG_RT_WLAN_MSH_CMD_ENABLE=y
CONFIG_RT_WLAN_AUTO_CONNECT_ENABLE=y
CONFIG_AUTO_CONNECTION_PERIOD_MS=2000
CONFIG_RT_WLAN_CFG_ENABLE=y
CONFIG_RT_WLAN_CFG_INFO_MAX=3
CONFIG_RT_WLAN_PROT_ENABLE=y
CONFIG_RT_WLAN_PROT_NAME_LEN=8
CONFIG_RT_WLAN_PROT_MAX=2
CONFIG_RT_WLAN_DEFAULT_PROT="lwip"
CONFIG_RT_WLAN_PROT_LWIP_ENABLE=y
CONFIG_RT_WLAN_PROT_LWIP_NAME="lwip"
# CONFIG_RT_WLAN_PROT_LWIP_PBUF_FORCE is not set
CONFIG_RT_WLAN_WORK_THREAD_ENABLE=y
CONFIG_RT_WLAN_WORKQUEUE_THREAD_NAME="wlan"
CONFIG_RT_WLAN_WORKQUEUE_THREAD_SIZE=2048
CONFIG_RT_WLAN_WORKQUEUE_THREAD_PRIO=15
# CONFIG_RT_WLAN_DEBUG is not set
# #
# Using USB # Using USB
@ -202,14 +238,16 @@ CONFIG_RT_USING_SPI_MSD=y
# POSIX layer and C standard library # POSIX layer and C standard library
# #
CONFIG_RT_USING_LIBC=y CONFIG_RT_USING_LIBC=y
# CONFIG_RT_USING_PTHREADS is not set CONFIG_RT_USING_PTHREADS=y
CONFIG_PTHREAD_NUM_MAX=8
CONFIG_RT_USING_POSIX=y CONFIG_RT_USING_POSIX=y
# CONFIG_RT_USING_POSIX_MMAP is not set # CONFIG_RT_USING_POSIX_MMAP is not set
# CONFIG_RT_USING_POSIX_TERMIOS is not set # CONFIG_RT_USING_POSIX_TERMIOS is not set
# CONFIG_RT_USING_POSIX_GETLINE is not set # CONFIG_RT_USING_POSIX_GETLINE is not set
# CONFIG_RT_USING_POSIX_AIO is not set # CONFIG_RT_USING_POSIX_AIO is not set
CONFIG_RT_LIBC_USING_TIME=y
# CONFIG_RT_USING_MODULE is not set # CONFIG_RT_USING_MODULE is not set
CONFIG_RT_LIBC_FIXED_TIMEZONE=8 CONFIG_RT_LIBC_DEFAULT_TIMEZONE=8
# #
# Network # Network
@ -218,22 +256,93 @@ CONFIG_RT_LIBC_FIXED_TIMEZONE=8
# #
# Socket abstraction layer # Socket abstraction layer
# #
# CONFIG_RT_USING_SAL is not set CONFIG_RT_USING_SAL=y
CONFIG_SAL_INTERNET_CHECK=y
#
# protocol stack implement
#
CONFIG_SAL_USING_LWIP=y
# CONFIG_SAL_USING_POSIX is not set
CONFIG_SAL_SOCKETS_NUM=16
# #
# Network interface device # Network interface device
# #
# CONFIG_RT_USING_NETDEV is not set CONFIG_RT_USING_NETDEV=y
CONFIG_NETDEV_USING_IFCONFIG=y
CONFIG_NETDEV_USING_PING=y
CONFIG_NETDEV_USING_NETSTAT=y
CONFIG_NETDEV_USING_AUTO_DEFAULT=y
# CONFIG_NETDEV_USING_IPV6 is not set
CONFIG_NETDEV_IPV4=1
CONFIG_NETDEV_IPV6=0
# CONFIG_NETDEV_IPV6_SCOPES is not set
# #
# light weight TCP/IP stack # light weight TCP/IP stack
# #
# CONFIG_RT_USING_LWIP is not set CONFIG_RT_USING_LWIP=y
# CONFIG_RT_USING_LWIP141 is not set
# CONFIG_RT_USING_LWIP202 is not set
CONFIG_RT_USING_LWIP203=y
# CONFIG_RT_USING_LWIP212 is not set
# CONFIG_RT_USING_LWIP_IPV6 is not set
CONFIG_RT_LWIP_MEM_ALIGNMENT=4
CONFIG_RT_LWIP_IGMP=y
CONFIG_RT_LWIP_ICMP=y
# CONFIG_RT_LWIP_SNMP is not set
CONFIG_RT_LWIP_DNS=y
CONFIG_RT_LWIP_DHCP=y
CONFIG_IP_SOF_BROADCAST=1
CONFIG_IP_SOF_BROADCAST_RECV=1
#
# Static IPv4 Address
#
CONFIG_RT_LWIP_IPADDR="192.168.1.30"
CONFIG_RT_LWIP_GWADDR="192.168.1.1"
CONFIG_RT_LWIP_MSKADDR="255.255.255.0"
CONFIG_RT_LWIP_UDP=y
CONFIG_RT_LWIP_TCP=y
CONFIG_RT_LWIP_RAW=y
# CONFIG_RT_LWIP_PPP is not set
CONFIG_RT_MEMP_NUM_NETCONN=8
CONFIG_RT_LWIP_PBUF_NUM=16
CONFIG_RT_LWIP_RAW_PCB_NUM=4
CONFIG_RT_LWIP_UDP_PCB_NUM=4
CONFIG_RT_LWIP_TCP_PCB_NUM=4
CONFIG_RT_LWIP_TCP_SEG_NUM=40
CONFIG_RT_LWIP_TCP_SND_BUF=8196
CONFIG_RT_LWIP_TCP_WND=8196
CONFIG_RT_LWIP_TCPTHREAD_PRIORITY=10
CONFIG_RT_LWIP_TCPTHREAD_MBOX_SIZE=8
CONFIG_RT_LWIP_TCPTHREAD_STACKSIZE=1024
# CONFIG_LWIP_NO_RX_THREAD is not set
# CONFIG_LWIP_NO_TX_THREAD is not set
CONFIG_RT_LWIP_ETHTHREAD_PRIORITY=12
CONFIG_RT_LWIP_ETHTHREAD_STACKSIZE=1024
CONFIG_RT_LWIP_ETHTHREAD_MBOX_SIZE=8
# CONFIG_RT_LWIP_REASSEMBLY_FRAG is not set
CONFIG_LWIP_NETIF_STATUS_CALLBACK=1
CONFIG_LWIP_NETIF_LINK_CALLBACK=1
CONFIG_SO_REUSE=1
CONFIG_LWIP_SO_RCVTIMEO=1
CONFIG_LWIP_SO_SNDTIMEO=1
CONFIG_LWIP_SO_RCVBUF=1
CONFIG_LWIP_SO_LINGER=0
# CONFIG_RT_LWIP_NETIF_LOOPBACK is not set
CONFIG_LWIP_NETIF_LOOPBACK=0
# CONFIG_RT_LWIP_STATS is not set
# CONFIG_RT_LWIP_USING_HW_CHECKSUM is not set
CONFIG_RT_LWIP_USING_PING=y
# CONFIG_RT_LWIP_DEBUG is not set
# #
# AT commands # AT commands
# #
# CONFIG_RT_USING_AT is not set # CONFIG_RT_USING_AT is not set
# CONFIG_LWIP_USING_DHCPD is not set
# #
# VBUS(Virtual Software BUS) # VBUS(Virtual Software BUS)
@ -246,6 +355,7 @@ CONFIG_RT_LIBC_FIXED_TIMEZONE=8
# CONFIG_RT_USING_RYM is not set # CONFIG_RT_USING_RYM is not set
# CONFIG_RT_USING_ULOG is not set # CONFIG_RT_USING_ULOG is not set
# CONFIG_RT_USING_UTEST is not set # CONFIG_RT_USING_UTEST is not set
# CONFIG_RT_USING_VAR_EXPORT is not set
# CONFIG_RT_USING_RT_LINK is not set # CONFIG_RT_USING_RT_LINK is not set
# CONFIG_RT_USING_LWP is not set # CONFIG_RT_USING_LWP is not set
@ -285,7 +395,9 @@ CONFIG_BSP_USING_UART=y
CONFIG_BSP_USING_UART1=y CONFIG_BSP_USING_UART1=y
# CONFIG_BSP_UART1_RX_USING_DMA is not set # CONFIG_BSP_UART1_RX_USING_DMA is not set
# CONFIG_BSP_UART1_TX_USING_DMA is not set # CONFIG_BSP_UART1_TX_USING_DMA is not set
# CONFIG_BSP_USING_UART2 is not set CONFIG_BSP_USING_UART2=y
# CONFIG_BSP_UART2_RX_USING_DMA is not set
# CONFIG_BSP_UART2_TX_USING_DMA is not set
# CONFIG_BSP_USING_UART3 is not set # CONFIG_BSP_USING_UART3 is not set
# CONFIG_BSP_USING_UART4 is not set # CONFIG_BSP_USING_UART4 is not set
# CONFIG_BSP_USING_UART5 is not set # CONFIG_BSP_USING_UART5 is not set
@ -323,8 +435,17 @@ CONFIG_BSP_USING_FMC=y
# #
# More Drivers # More Drivers
# #
# CONFIG_PKG_USING_RW007 is not set CONFIG_PKG_USING_RW007=y
# CONFIG_DRV_USING_OV2640 is not set # CONFIG_RW007_NOT_USE_EXAMPLE_DRIVERS is not set
CONFIG_RW007_USING_STM32_DRIVERS=y
CONFIG_RW007_SPI_MAX_HZ=30000000
CONFIG_RW007_SPI_BUS_NAME="spi1"
CONFIG_RW007_CS_PIN=86
CONFIG_RW007_BOOT0_PIN=19
CONFIG_RW007_BOOT1_PIN=86
CONFIG_RW007_INT_BUSY_PIN=87
CONFIG_RW007_RST_PIN=88
CONFIG_DRV_USING_OV2640=y
# #
# APP_Framework # APP_Framework
@ -356,12 +477,18 @@ CONFIG_MAIN_KTASK_STACK_SIZE=1024
# #
# knowing app # knowing app
# #
CONFIG_IRIS_ML_DEMO=y # CONFIG_APPLICATION_KNOWING is not set
# #
# sensor app # sensor app
# #
# CONFIG_APPLICATION_SENSOR is not set CONFIG_APPLICATION_SENSOR=y
# CONFIG_APPLICATION_SENSOR_CO2 is not set
# CONFIG_APPLICATION_SENSOR_PM1_0 is not set
CONFIG_APPLICATION_SENSOR_VOICE=y
CONFIG_APPLICATION_SENSOR_VOICE_D124=y
# CONFIG_APPLICATION_SENSOR_HUMIDITY is not set
# CONFIG_APPLICATION_SENSOR_TEMPERATURE is not set
# #
# Framework # Framework
@ -373,7 +500,12 @@ CONFIG_ADD_XIUOS_FETURES=y
CONFIG_SUPPORT_SENSOR_FRAMEWORK=y CONFIG_SUPPORT_SENSOR_FRAMEWORK=y
# CONFIG_SENSOR_CO2 is not set # CONFIG_SENSOR_CO2 is not set
# CONFIG_SENSOR_PM is not set # CONFIG_SENSOR_PM is not set
# CONFIG_SENSOR_VOICE is not set CONFIG_SENSOR_VOICE=y
CONFIG_SENSOR_D124=y
CONFIG_SENSOR_DEVICE_D124="d124_1"
CONFIG_SENSOR_QUANTITY_D124_VOICE="voice_1"
# CONFIG_SENSOR_D124_DRIVER_EXTUART is not set
CONFIG_SENSOR_DEVICE_D124_DEV="/dev/uart2"
# CONFIG_SENSOR_TEMPERATURE is not set # CONFIG_SENSOR_TEMPERATURE is not set
# CONFIG_SENSOR_HUMIDITY is not set # CONFIG_SENSOR_HUMIDITY is not set
# CONFIG_SUPPORT_CONNECTION_FRAMEWORK is not set # CONFIG_SUPPORT_CONNECTION_FRAMEWORK is not set
@ -381,11 +513,19 @@ CONFIG_SUPPORT_KNOWING_FRAMEWORK=y
# CONFIG_USING_TENSORFLOWLITEMICRO is not set # CONFIG_USING_TENSORFLOWLITEMICRO is not set
CONFIG_USING_KPU_POSTPROCESSING=y CONFIG_USING_KPU_POSTPROCESSING=y
# CONFIG_USING_YOLOV2 is not set # CONFIG_USING_YOLOV2 is not set
# CONFIG_USING_KNOWING_FILTER is not set
# CONFIG_USING_OTA_MODEL is not set
# CONFIG_SUPPORT_CONTROL_FRAMEWORK is not set # CONFIG_SUPPORT_CONTROL_FRAMEWORK is not set
#
# Security
#
# CONFIG_CRYPTO is not set
# #
# lib # lib
# #
CONFIG_APP_SELECT_NEWLIB=y CONFIG_APP_SELECT_NEWLIB=y
# CONFIG_APP_SELECT_OTHER_LIB is not set # CONFIG_APP_SELECT_OTHER_LIB is not set
# CONFIG_LIB_USING_CJSON is not set # CONFIG_LIB_USING_CJSON is not set
# CONFIG_LIB_USING_QUEUE is not set

View File

@ -1,3 +1,12 @@
/*
* @Author: chunyexixiaoyu
* @Date: 2021-09-24 16:33:15
* @LastEditTime: 2021-09-24 15:48:30
* @LastEditors: Please set LastEditors
* @Description: In User Settings Edit
* @FilePath: \xiuos\Ubiquitous\RT_Thread\bsp\stm32f407-atk-coreboard\applications\main.c
*/
/* /*
* Copyright (c) 2006-2018, RT-Thread Development Team * Copyright (c) 2006-2018, RT-Thread Development Team
* *
@ -10,14 +19,27 @@
#include <rtthread.h> #include <rtthread.h>
#include <board.h> #include <board.h>
#include <stdio.h> #include <stdio.h>
#include <string.h>
#ifdef RT_USING_POSIX
#include <pthread.h>
#include <unistd.h>
#include <stdio.h>
#include <dfs_poll.h>
#include <dfs_posix.h>
#include <dfs.h>
#ifdef RT_USING_POSIX_TERMIOS
#include <posix_termios.h>
#endif
#endif
#define LED0_PIN GET_PIN(F, 9) #define LED0_PIN GET_PIN(F, 9)
extern int FrameworkInit();
int main(void) int main(void)
{ {
int count = 1; int count = 1;
rt_pin_mode(LED0_PIN, PIN_MODE_OUTPUT); rt_pin_mode(LED0_PIN, PIN_MODE_OUTPUT);
rt_thread_mdelay(100); rt_thread_mdelay(100);
FrameworkInit();
printf("XIUOS stm32f4 build %s %s\n",__DATE__,__TIME__); printf("XIUOS stm32f4 build %s %s\n",__DATE__,__TIME__);
while (count++) while (count++)
{ {

View File

@ -28,6 +28,7 @@
/* kservice optimization */ /* kservice optimization */
#define RT_DEBUG #define RT_DEBUG
#define RT_DEBUG_COLOR
/* Inter-Thread communication */ /* Inter-Thread communication */
@ -40,7 +41,9 @@
/* Memory Management */ /* Memory Management */
#define RT_USING_MEMPOOL #define RT_USING_MEMPOOL
#define RT_USING_SMALL_MEM #define RT_USING_MEMHEAP
#define RT_USING_MEMHEAP_AUTO_BINDING
#define RT_USING_MEMHEAP_AS_HEAP
#define RT_USING_HEAP #define RT_USING_HEAP
/* Kernel Device Object */ /* Kernel Device Object */
@ -68,16 +71,17 @@
/* Command shell */ /* Command shell */
#define RT_USING_FINSH #define RT_USING_FINSH
#define RT_USING_MSH
#define FINSH_USING_MSH
#define FINSH_THREAD_NAME "tshell" #define FINSH_THREAD_NAME "tshell"
#define FINSH_THREAD_PRIORITY 20
#define FINSH_THREAD_STACK_SIZE 4096
#define FINSH_USING_HISTORY #define FINSH_USING_HISTORY
#define FINSH_HISTORY_LINES 5 #define FINSH_HISTORY_LINES 5
#define FINSH_USING_SYMTAB #define FINSH_USING_SYMTAB
#define FINSH_USING_DESCRIPTION
#define FINSH_THREAD_PRIORITY 20
#define FINSH_THREAD_STACK_SIZE 4096
#define FINSH_CMD_SIZE 80 #define FINSH_CMD_SIZE 80
#define FINSH_USING_MSH #define MSH_USING_BUILT_IN_COMMANDS
#define FINSH_USING_MSH_DEFAULT #define FINSH_USING_DESCRIPTION
#define FINSH_ARG_MAX 10 #define FINSH_ARG_MAX 10
/* Device virtual file system */ /* Device virtual file system */
@ -101,13 +105,18 @@
#define RT_DFS_ELM_DRIVES 2 #define RT_DFS_ELM_DRIVES 2
#define RT_DFS_ELM_MAX_SECTOR_SIZE 512 #define RT_DFS_ELM_MAX_SECTOR_SIZE 512
#define RT_DFS_ELM_REENTRANT #define RT_DFS_ELM_REENTRANT
#define RT_DFS_ELM_MUTEX_TIMEOUT 3000
#define RT_USING_DFS_DEVFS #define RT_USING_DFS_DEVFS
/* Device Drivers */ /* Device Drivers */
#define RT_USING_DEVICE_IPC #define RT_USING_DEVICE_IPC
#define RT_PIPE_BUFSZ 512 #define RT_PIPE_BUFSZ 512
#define RT_USING_SYSTEM_WORKQUEUE
#define RT_SYSTEM_WORKQUEUE_STACKSIZE 2048
#define RT_SYSTEM_WORKQUEUE_PRIORITY 23
#define RT_USING_SERIAL #define RT_USING_SERIAL
#define RT_USING_SERIAL_V1
#define RT_SERIAL_USING_DMA #define RT_SERIAL_USING_DMA
#define RT_SERIAL_RB_BUFSZ 64 #define RT_SERIAL_RB_BUFSZ 64
#define RT_USING_I2C #define RT_USING_I2C
@ -115,6 +124,31 @@
#define RT_USING_PIN #define RT_USING_PIN
#define RT_USING_SPI #define RT_USING_SPI
#define RT_USING_SPI_MSD #define RT_USING_SPI_MSD
#define RT_USING_WIFI
#define RT_WLAN_DEVICE_STA_NAME "wlan0"
#define RT_WLAN_DEVICE_AP_NAME "wlan1"
#define RT_WLAN_SSID_MAX_LENGTH 32
#define RT_WLAN_PASSWORD_MAX_LENGTH 32
#define RT_WLAN_DEV_EVENT_NUM 2
#define RT_WLAN_MANAGE_ENABLE
#define RT_WLAN_SCAN_WAIT_MS 10000
#define RT_WLAN_CONNECT_WAIT_MS 10000
#define RT_WLAN_SCAN_SORT
#define RT_WLAN_MSH_CMD_ENABLE
#define RT_WLAN_AUTO_CONNECT_ENABLE
#define AUTO_CONNECTION_PERIOD_MS 2000
#define RT_WLAN_CFG_ENABLE
#define RT_WLAN_CFG_INFO_MAX 3
#define RT_WLAN_PROT_ENABLE
#define RT_WLAN_PROT_NAME_LEN 8
#define RT_WLAN_PROT_MAX 2
#define RT_WLAN_DEFAULT_PROT "lwip"
#define RT_WLAN_PROT_LWIP_ENABLE
#define RT_WLAN_PROT_LWIP_NAME "lwip"
#define RT_WLAN_WORK_THREAD_ENABLE
#define RT_WLAN_WORKQUEUE_THREAD_NAME "wlan"
#define RT_WLAN_WORKQUEUE_THREAD_SIZE 2048
#define RT_WLAN_WORKQUEUE_THREAD_PRIO 15
/* Using USB */ /* Using USB */
@ -122,19 +156,77 @@
/* POSIX layer and C standard library */ /* POSIX layer and C standard library */
#define RT_USING_LIBC #define RT_USING_LIBC
#define RT_USING_PTHREADS
#define PTHREAD_NUM_MAX 8
#define RT_USING_POSIX #define RT_USING_POSIX
#define RT_LIBC_FIXED_TIMEZONE 8 #define RT_LIBC_USING_TIME
#define RT_LIBC_DEFAULT_TIMEZONE 8
/* Network */ /* Network */
/* Socket abstraction layer */ /* Socket abstraction layer */
#define RT_USING_SAL
#define SAL_INTERNET_CHECK
/* protocol stack implement */
#define SAL_USING_LWIP
#define SAL_SOCKETS_NUM 16
/* Network interface device */ /* Network interface device */
#define RT_USING_NETDEV
#define NETDEV_USING_IFCONFIG
#define NETDEV_USING_PING
#define NETDEV_USING_NETSTAT
#define NETDEV_USING_AUTO_DEFAULT
#define NETDEV_IPV4 1
#define NETDEV_IPV6 0
/* light weight TCP/IP stack */ /* light weight TCP/IP stack */
#define RT_USING_LWIP
#define RT_USING_LWIP203
#define RT_LWIP_MEM_ALIGNMENT 4
#define RT_LWIP_IGMP
#define RT_LWIP_ICMP
#define RT_LWIP_DNS
#define RT_LWIP_DHCP
#define IP_SOF_BROADCAST 1
#define IP_SOF_BROADCAST_RECV 1
/* Static IPv4 Address */
#define RT_LWIP_IPADDR "192.168.1.30"
#define RT_LWIP_GWADDR "192.168.1.1"
#define RT_LWIP_MSKADDR "255.255.255.0"
#define RT_LWIP_UDP
#define RT_LWIP_TCP
#define RT_LWIP_RAW
#define RT_MEMP_NUM_NETCONN 8
#define RT_LWIP_PBUF_NUM 16
#define RT_LWIP_RAW_PCB_NUM 4
#define RT_LWIP_UDP_PCB_NUM 4
#define RT_LWIP_TCP_PCB_NUM 4
#define RT_LWIP_TCP_SEG_NUM 40
#define RT_LWIP_TCP_SND_BUF 8196
#define RT_LWIP_TCP_WND 8196
#define RT_LWIP_TCPTHREAD_PRIORITY 10
#define RT_LWIP_TCPTHREAD_MBOX_SIZE 8
#define RT_LWIP_TCPTHREAD_STACKSIZE 1024
#define RT_LWIP_ETHTHREAD_PRIORITY 12
#define RT_LWIP_ETHTHREAD_STACKSIZE 1024
#define RT_LWIP_ETHTHREAD_MBOX_SIZE 8
#define LWIP_NETIF_STATUS_CALLBACK 1
#define LWIP_NETIF_LINK_CALLBACK 1
#define SO_REUSE 1
#define LWIP_SO_RCVTIMEO 1
#define LWIP_SO_SNDTIMEO 1
#define LWIP_SO_RCVBUF 1
#define LWIP_SO_LINGER 0
#define LWIP_NETIF_LOOPBACK 0
#define RT_LWIP_USING_PING
/* AT commands */ /* AT commands */
@ -168,6 +260,7 @@
#define BSP_USING_GPIO #define BSP_USING_GPIO
#define BSP_USING_UART #define BSP_USING_UART
#define BSP_USING_UART1 #define BSP_USING_UART1
#define BSP_USING_UART2
#define BSP_USING_SPI #define BSP_USING_SPI
#define BSP_USING_SPI1 #define BSP_USING_SPI1
#define BSP_USING_SPI2 #define BSP_USING_SPI2
@ -182,6 +275,16 @@
/* More Drivers */ /* More Drivers */
#define PKG_USING_RW007
#define RW007_USING_STM32_DRIVERS
#define RW007_SPI_MAX_HZ 30000000
#define RW007_SPI_BUS_NAME "spi1"
#define RW007_CS_PIN 86
#define RW007_BOOT0_PIN 19
#define RW007_BOOT1_PIN 86
#define RW007_INT_BUSY_PIN 87
#define RW007_RST_PIN 88
#define DRV_USING_OV2640
/* APP_Framework */ /* APP_Framework */
@ -201,19 +304,29 @@
/* knowing app */ /* knowing app */
#define IRIS_ML_DEMO
/* sensor app */ /* sensor app */
#define APPLICATION_SENSOR
#define APPLICATION_SENSOR_VOICE
#define APPLICATION_SENSOR_VOICE_D124
/* Framework */ /* Framework */
#define TRANSFORM_LAYER_ATTRIUBUTE #define TRANSFORM_LAYER_ATTRIUBUTE
#define ADD_XIUOS_FETURES #define ADD_XIUOS_FETURES
#define SUPPORT_SENSOR_FRAMEWORK #define SUPPORT_SENSOR_FRAMEWORK
#define SENSOR_VOICE
#define SENSOR_D124
#define SENSOR_DEVICE_D124 "d124_1"
#define SENSOR_QUANTITY_D124_VOICE "voice_1"
#define SENSOR_DEVICE_D124_DEV "/dev/uart2"
#define SUPPORT_KNOWING_FRAMEWORK #define SUPPORT_KNOWING_FRAMEWORK
#define USING_KPU_POSTPROCESSING #define USING_KPU_POSTPROCESSING
/* Security */
/* lib */ /* lib */
#define APP_SELECT_NEWLIB #define APP_SELECT_NEWLIB

View File

@ -125,6 +125,8 @@ extern "C" {
#ifdef BOARD_K210_EVB #ifdef BOARD_K210_EVB
#define IOCTRL_CAMERA_SET_DVP_RESO (21) // set dev resolution #define IOCTRL_CAMERA_SET_DVP_RESO (21) // set dev resolution
#else
#define IOCTRL_CAMERA_SET_DVP_RESO (22) // same as IOCTRL_CAMERA_START_SHOT
#endif #endif
#define IOCTRL_CAMERA_START_SHOT (22) // start shoot #define IOCTRL_CAMERA_START_SHOT (22) // start shoot

View File

@ -5,7 +5,7 @@ MAKEFLAGS += --no-print-directory
.PHONY:COMPILE_APP COMPILE_KERNEL .PHONY:COMPILE_APP COMPILE_KERNEL
support :=kd233 stm32f407-st-discovery maix-go stm32f407zgt6 aiit-riscv64-board aiit-arm32-board hifive1-rev-B hifive1-emulator k210-emulator cortex-m3-emulator ok1052-c gapuino support :=kd233 stm32f407-st-discovery maix-go stm32f407zgt6 aiit-riscv64-board aiit-arm32-board hifive1-rev-B hifive1-emulator k210-emulator cortex-m3-emulator ok1052-c gapuino cortex-m0-emulator
SRC_DIR:= SRC_DIR:=
export BOARD ?=kd233 export BOARD ?=kd233

View File

@ -1,16 +1,28 @@
#公共部分 #公共部分
SRC_DIR := shared SRC_DIR := shared
# The following three platforms support compatiable instructions.
ifeq ($(CONFIG_BOARD_CORTEX_M3_EVB),y) ifeq ($(CONFIG_BOARD_CORTEX_M3_EVB),y)
SRC_DIR +=cortex-m3 SRC_DIR += armv7m
SRC_DIR += cortex-m3
endif endif
ifeq ($(CONFIG_BOARD_STM32F407_EVB),y) ifeq ($(CONFIG_BOARD_STM32F407_EVB),y)
SRC_DIR +=cortex-m4 SRC_DIR += armv7m
SRC_DIR += cortex-m4
endif endif
ifeq ($(CONFIG_BOARD_CORTEX_M7_EVB),y) ifeq ($(CONFIG_BOARD_CORTEX_M7_EVB),y)
SRC_DIR +=cortex-m7 SRC_DIR += armv7m
SRC_DIR += cortex-m7
endif
# cortex-m0 is ARMv6-m
ifeq ($(CONFIG_BOARD_CORTEX_M0_EVB),y)
SRC_DIR += armv6m
SRC_DIR += cortex-m0
endif endif
include $(KERNEL_ROOT)/compiler.mk include $(KERNEL_ROOT)/compiler.mk

View File

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

View File

@ -0,0 +1,241 @@
/*
* 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.
*/
#include <xs_base.h>
#include <xs_ktask.h>
#define SCB_VTOR "0xE000ED08"
#define NVIC_INT_CTRL "0xE000ED04"
#define NVIC_SYSPRI2 "0xE000ED20"
#define NVIC_PENDSV_PRI "0x00FF0000"
#define NVIC_PENDSVSET "0x10000000"
/* We replaced instructions that were not supported in thumb mode. */
void __attribute__((naked)) HwInterruptcontextSwitch(x_ubase from, x_ubase to, struct TaskDescriptor *to_task, void *context)
{
asm volatile ("PUSH {R4}");
asm volatile ("PUSH {R5}");
asm volatile ("LDR r4, =KtaskSwitchInterruptFlag");
asm volatile ("LDR r5, [r4]");
asm volatile ("CMP r5, #1");
asm volatile ("POP {R5}");
asm volatile ("POP {R4}");
asm volatile ("BEQ Arm32SwitchReswitch");
asm volatile ("PUSH {R4}");
asm volatile ("PUSH {R5}");
asm volatile ("LDR r4, =KtaskSwitchInterruptFlag");
asm volatile ("MOV r5, #1");
asm volatile ("STR r5, [r4]");
asm volatile ("LDR r4, =InterruptFromKtask");
asm volatile ("STR r0, [r4]");
asm volatile ("POP {R5}");
asm volatile ("POP {R4}");
asm volatile ("B Arm32SwitchReswitch");
}
void __attribute__((naked)) Arm32SwitchReswitch()
{
asm volatile ("PUSH {R4}");
asm volatile ("LDR r4, =InterruptToKtask");
asm volatile ("STR r1, [r4]");
asm volatile ("LDR r4, =InterruptToKtaskDescriptor");
asm volatile ("STR r2, [r4]");
asm volatile ("LDR r0, =" NVIC_INT_CTRL);
asm volatile ("LDR r1, =" NVIC_PENDSVSET);
asm volatile ("STR r1, [r0]");
asm volatile ("POP {R4}");
asm volatile ("BX LR");
}
void __attribute__((naked)) SwitchKtaskContext(x_ubase from, x_ubase to, struct TaskDescriptor *to_task)
{
asm volatile("B HwInterruptcontextSwitch");
}
void SwitchKtaskContextTo(x_ubase to, struct TaskDescriptor *to_task)
{
asm volatile ("LDR r2, =InterruptToKtask");
asm volatile ("STR r0, [r2]");
asm volatile ("LDR r2, =InterruptToKtaskDescriptor");
asm volatile ("STR r1, [r2]");
#if defined (__VFP_FP__) && !defined(__SOFTFP__)
asm volatile ("MRS r2, CONTROL");
asm volatile ("BIC r2, #0x04");
asm volatile ("MSR CONTROL, r2");
#endif
asm volatile ("LDR r1, =InterruptFromKtask");
asm volatile ("MOV r0, #0x0");
asm volatile ("STR r0, [r1]");
asm volatile ("LDR r1, =KtaskSwitchInterruptFlag");
asm volatile ("MOV r0, #1");
asm volatile ("STR r0, [r1]");
asm volatile ("LDR r0, =" NVIC_SYSPRI2);
asm volatile ("LDR r1, =" NVIC_PENDSV_PRI);
// asm volatile ("LDR.W r2, [r0,#0x00]");
asm volatile ("LDR r2, [r0,#0x00]");
asm volatile ("ORR r1,r1,r2");
asm volatile ("STR r1, [r0]");
asm volatile ("LDR r0, =" NVIC_INT_CTRL);
asm volatile ("LDR r1, =" NVIC_PENDSVSET);
asm volatile ("STR r1, [r0]");
asm volatile ("LDR r0, =" SCB_VTOR);
asm volatile ("LDR r0, [r0]");
asm volatile ("LDR r0, [r0]");
asm volatile ("NOP");
asm volatile ("MSR msp, r0");
asm volatile ("CPSIE F");
asm volatile ("CPSIE I");
asm volatile ("BX lr");
}
void __attribute__((naked)) HardFaultHandler()
{
asm volatile ("MRS r0, msp");
// asm volatile ("TST lr, #0x04");
asm volatile ("MOV r1, lr");
asm volatile ("MOV r2, #0x04");
asm volatile ("TST r1, r2");
asm volatile ("BEQ Arm32SwitchGetSpDone");
asm volatile ("MRS r0, psp");
asm volatile ("B Arm32SwitchGetSpDone");
}
void __attribute__((naked)) Arm32SwitchGetSpDone()
{
asm volatile ("MRS r3, primask");
// asm volatile ("STMFD r0!, {r3 - r11}");
asm volatile ("SUB r0, r0, #0x24");
asm volatile ("STMIA r0!, {r3 - r7}");
asm volatile ("MOV r3, r8");
asm volatile ("MOV r4, r9");
asm volatile ("MOV r5, r10");
asm volatile ("MOV r6, r11");
asm volatile ("STMIA r0!, {r3 - r6}");
asm volatile ("SUB r0, r0, #0x24");
// asm volatile ("STMFD r0!, {lr}");
asm volatile ("SUB r0, r0, #0x4");
asm volatile ("MOV r0, lr");
#if defined (__VFP_FP__) && !defined(__SOFTFP__)
asm volatile ("MOV r4, #0x00");
// asm volatile ("TST lr, #0x10");
asm volatile ("MOV r1, lr");
asm volatile ("MOV r2, #0x10");
asm volatile ("TST r1, r2");
asm volatile ("MOVEQ r4, #0x01");
asm volatile ("STMFD r0!, {r4}");
#endif
// asm volatile ("TST lr, #0x04");
asm volatile ("MOV r1, lr");
asm volatile ("MOV r2, #0x04");
asm volatile ("TST r1, r2");
asm volatile ("BEQ Arm32SwitchUpdateMsp");
asm volatile ("MSR psp, r0");
asm volatile ("B Arm32SwitchUpdateDone");
asm volatile ("B Arm32SwitchUpdateMsp");
}
void __attribute__((naked)) Arm32SwitchUpdateMsp()
{
asm volatile ("MSR msp, r0");
asm volatile ("B Arm32SwitchUpdateDone");
}
void __attribute__((naked)) Arm32SwitchUpdateDone()
{
asm volatile ("PUSH {LR}");
asm volatile ("BL HwHardFaultException");
// asm volatile ("POP {LR}");
asm volatile ("POP {R1}");
asm volatile ("MOV lr, r1");
// asm volatile ("ORR lr, lr, #0x04");
asm volatile ("MOV r1, lr");
asm volatile ("MOV r2, #0x04");
asm volatile ("ORR r1, r2");
asm volatile ("MOV lr, r1");
asm volatile ("BX lr");
}
void __attribute__((naked)) MemFaultHandler()
{
asm volatile ("MRS r0, msp");
// asm volatile ("TST lr, #0x04");
asm volatile ("MOV r1, lr");
asm volatile ("MOV r2, #0x04");
asm volatile ("TST r1, r2");
asm volatile ("BEQ Arm32Switch1");
asm volatile ("MRS r0, psp");
asm volatile ("B Arm32Switch1");
}
void __attribute__((naked)) Arm32Switch1()
{
asm volatile ("MRS r3, primask");
// asm volatile ("STMFD r0!, {r3 - r11}");
asm volatile ("SUB r0, r0, #0x24");
asm volatile ("STMIA r0!, {r3 - r7}");
asm volatile ("MOV r3, r8");
asm volatile ("MOV r4, r9");
asm volatile ("MOV r5, r10");
asm volatile ("MOV r6, r11");
asm volatile ("STMIA r0!, {r3 - r6}");
asm volatile ("SUB r0, r0, #0x24");
#if defined (__VFP_FP__) && !defined(__SOFTFP__)
asm volatile ("MOV r4, #0x00");
// asm volatile ("TST lr, #0x10");
asm volatile ("MOV r1, lr");
asm volatile ("MOV r2, #0x10");
asm volatile ("TST r1, r2");
asm volatile ("MOV lr, r1");
asm volatile ("MOVEQ r4, #0x01");
asm volatile ("STMFD r0!, {r4}");
#endif
// asm volatile ("STMFD r0!, {lr}");
asm volatile ("SUB r0, r0, #0x4");
asm volatile ("MOV r0, lr");
asm volatile ("PUSH {LR}");
asm volatile ("BL MemFaultHandle");
// asm volatile ("POP {LR}");
asm volatile ("POP {R5}");
asm volatile ("MOV lr, r5");
// asm volatile ("ORR lr, lr, #0x04");
asm volatile ("MOV r5, lr");
asm volatile ("MOV r6, #0x04");
asm volatile ("ORR r5, r6");
asm volatile ("MOV lr, r5");
asm volatile ("BX lr");
}

View File

@ -0,0 +1,159 @@
/*
* Copyright (c) 2006-2018, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2009-10-11 Bernard first version
* 2012-01-01 aozima support context switch load/store FPU register.
* 2013-06-18 aozima add restore MSP feature.
* 2013-06-23 aozima support lazy stack optimized.
* 2018-07-24 aozima enhancement hard fault exception handler.
*/
/*************************************************
File name: pendsv.S
Description: PendSV interrupt handler
Others: take RT-Thread v4.0.2/libcpu/arm/cortex-m4/context_gcc.S for references
https://github.com/RT-Thread/rt-thread/tree/v4.0.2
History:
1. Date: 2021-04-25
Author: AIIT XUOS Lab
*************************************************/
#include <xsconfig.h>
.cpu cortex-m0
.syntax unified
.thumb
.text
.equ SCB_VTOR, 0xE000ED08
.equ NVIC_INT_CTRL, 0xE000ED04
.equ NVIC_SYSPRI2, 0xE000ED20
.equ NVIC_PENDSV_PRI, 0x00FF0000
.equ NVIC_PENDSVSET, 0x10000000
.globl PendSV_Handler
.type PendSV_Handler, %function
PendSV_Handler:
MRS r3, PRIMASK
CPSID I
LDR r0, =KtaskSwitchInterruptFlag
LDR r1, [r0]
/*CBZ r1, switch_to_task*/
CMP r1, #0
BEQ pendsv_exit
MOVS r1, #0x00
STR r1, [r0]
LDR r0, =InterruptFromKtask
LDR r1, [r0]
/*CBZ r1, switch_to_task*/
CMP r1, #0
BEQ switch_to_task
MRS r1, psp
/*STMFD r1!, {r3 - r11}*/
SUBS r1, #0x24
STMIA r1!, {r3 - r7}
MOV r3, r8
MOV r4, r9
MOV r5, r10
MOV r6, r11
STMIA r1!, {r3 - r6}
SUBS r1, #0x24
#if defined (__VFP_FP__) && !defined(__SOFTFP__)
MOV r4, #0x00
TST lr, #0x10
MOVEQ r4, #0x01
/*STMFD r1!, {r4}*/
SUBS r1, #0x4
STMIA r1!, {r4}
SUBS r1, #0x4
#endif
LDR r0, [r0]
STR r1, [r0]
switch_to_task:
PUSH {lr}
BL UpdateRunningTask
POP {r0}
MOV lr, r0
#ifdef TASK_ISOLATION
PUSH {lr}
BL GetTaskPrivilege
/*POP {lr}*/
POP {r0}
MOV lr, r0
#endif
LDR r1, =InterruptToKtask
LDR r1, [r1]
LDR r1, [r1]
#if defined (__VFP_FP__) && !defined(__SOFTFP__)
LDMFD r1!, {r2}
#endif
/*LDMFD r1!, {r3 - r11}*/
ADDS r1, #0x14
LDMFD r1!, {r3 - r6}
MOV r8, r3
MOV r9, r4
MOV r10, r5
MOV r11, r6
SUBS r1, #0x24
LDMFD r1!, {r3 - r7}
ADDS r1, #0x10
MSR psp, r1
#if defined (__VFP_FP__) && !defined(__SOFTFP__)
/*ORR lr, lr, #0x10*/
MOV r2, lr
MOVS r3, #0x10
ORRS r2, r3
MOV lr, r2
CMP r2, #0
BICNE lr, lr, #0x10
#endif
MRS r2, control
#ifdef TASK_ISOLATION
CMP r0, #1
BEQ unprivilege
privilege:
BIC r2, r2, #0x01
B exit
unprivilege:
/*ORR r2, r2, #0x01*/
MOVS r1, #0x01
ORRS r2, r1
#else
/*BIC r2, r2, #0x01*/
MOVS r0, #0x01
BICS r2, r0
#endif
exit:
MSR control, r2
pendsv_exit:
/*ORR lr, lr, #0x04*/
MOV r0, lr
MOVS r1, #0x04
ORRS r0, r1
MOV lr, r0
MSR PRIMASK, r3
BX lr

View File

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

View File

@ -21,19 +21,37 @@
void __attribute__((naked)) HwInterruptcontextSwitch(x_ubase from, x_ubase to, struct TaskDescriptor *to_task, void *context) void __attribute__((naked)) HwInterruptcontextSwitch(x_ubase from, x_ubase to, struct TaskDescriptor *to_task, void *context)
{ {
asm volatile ("PUSH {R4}");
asm volatile ("PUSH {R5}");
asm volatile ("LDR r4, =KtaskSwitchInterruptFlag"); asm volatile ("LDR r4, =KtaskSwitchInterruptFlag");
asm volatile ("LDR r5, [r4]"); asm volatile ("LDR r5, [r4]");
asm volatile ("CMP r5, #1"); asm volatile ("CMP r5, #1");
asm volatile ("POP {R5}");
asm volatile ("POP {R4}");
asm volatile ("BEQ Arm32SwitchReswitch"); asm volatile ("BEQ Arm32SwitchReswitch");
asm volatile ("PUSH {R4}");
asm volatile ("PUSH {R5}");
asm volatile ("LDR r4, =KtaskSwitchInterruptFlag");
asm volatile ("MOV r5, #1"); asm volatile ("MOV r5, #1");
asm volatile ("STR r5, [r4]"); asm volatile ("STR r5, [r4]");
asm volatile ("LDR r4, =InterruptFromKtask"); asm volatile ("LDR r4, =InterruptFromKtask");
asm volatile ("STR r0, [r4]"); asm volatile ("STR r0, [r4]");
asm volatile ("POP {R5}");
asm volatile ("POP {R4}");
asm volatile ("B Arm32SwitchReswitch"); asm volatile ("B Arm32SwitchReswitch");
} }
void __attribute__((naked)) Arm32SwitchReswitch() void __attribute__((naked)) Arm32SwitchReswitch()
{ {
asm volatile ("PUSH {R4}");
asm volatile ("LDR r4, =InterruptToKtask"); asm volatile ("LDR r4, =InterruptToKtask");
asm volatile ("STR r1, [r4]"); asm volatile ("STR r1, [r4]");
asm volatile ("LDR r4, =InterruptToKtaskDescriptor"); asm volatile ("LDR r4, =InterruptToKtaskDescriptor");
@ -41,6 +59,9 @@ void __attribute__((naked)) Arm32SwitchReswitch()
asm volatile ("LDR r0, =" NVIC_INT_CTRL); asm volatile ("LDR r0, =" NVIC_INT_CTRL);
asm volatile ("LDR r1, =" NVIC_PENDSVSET); asm volatile ("LDR r1, =" NVIC_PENDSVSET);
asm volatile ("STR r1, [r0]"); asm volatile ("STR r1, [r0]");
asm volatile ("POP {R4}");
asm volatile ("BX LR"); asm volatile ("BX LR");
} }

View File

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

View File

@ -10,11 +10,19 @@
* See the Mulan PSL v2 for more details. * See the Mulan PSL v2 for more details.
*/ */
/** #ifndef ARCH_INTERRUPT_H__
* @file adapter_5G.c #define ARCH_INTERRUPT_H__
* @brief Implement the connection 5G adapter function
* @version 1.1
* @author AIIT XUOS Lab
* @date 2021.06.25
*/
#include <xs_base.h>
#define ARCH_MAX_IRQ_NUM (48)
#define ARCH_IRQ_NUM_OFFSET 0
#define SYSTICK_IRQN 15
#define UART1_IRQn 18
int32 ArchEnableHwIrq(uint32 irq_num);
int32 ArchDisableHwIrq(uint32 irq_num);
#endif

View File

@ -0,0 +1,75 @@
//*****************************************************************************
//
// startup_gcc.c - Startup code for use with GNU tools.
//
// Copyright (c) 2013 Texas Instruments Incorporated. All rights reserved.
// Software License Agreement
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
//
// Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// 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.
//
// Neither the name of Texas Instruments Incorporated 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.
//
// This is part of revision 10636 of the Stellaris Firmware Development Package.
//
//*****************************************************************************
/**
* @file boot.c
* @brief derived from Stellaris Firmware Development Package
* @version 1.0
* @author AIIT XUOS Lab
* @date 2021-05-13
*/
/*************************************************
File name: boot.c
Description: Reset and init function
Others:
History:
1. Date: 2021-05-13
Author: AIIT XUOS Lab
Modification:
1. take startup_gcc.c from revision 10636 of the Stellaris Firmware Development Package for XiUOS
*************************************************/
extern unsigned _sdata[], _edata[],
_sbss[], _ebss[], _etext[], _sidata[];
extern int entry(void);
void
Reset_Handler(void)
{
unsigned *p, *q;
p = _sdata; q = _sidata;
while (p < _edata) *p++ = *q++;
p = _sbss;
while (p < _ebss) *p++ = 0;
entry();
}

View File

@ -0,0 +1,83 @@
/*
* 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 interrupt.c
* @brief support arm cortex-m4 interrupt function
* @version 1.0
* @author AIIT XUOS Lab
* @date 2021-04-29
*/
#include <xs_base.h>
#include <xs_isr.h>
x_base __attribute__((naked)) DisableLocalInterrupt()
{
asm volatile ("MRS r0, PRIMASK");
asm volatile ("CPSID I");
asm volatile ("BX LR ");
}
void __attribute__((naked)) EnableLocalInterrupt(x_base level)
{
asm volatile ("MSR PRIMASK, r0");
asm volatile ("BX LR");
}
int32 ArchEnableHwIrq(uint32 irq_num)
{
return EOK;
}
int32 ArchDisableHwIrq(uint32 irq_num)
{
return EOK;
}
extern void KTaskOsAssignAfterIrq(void *context);
void IsrEntry()
{
uint32 ipsr;
__asm__ volatile("MRS %0, IPSR" : "=r"(ipsr));
isrManager.done->incCounter();
isrManager.done->handleIrq(ipsr);
KTaskOsAssignAfterIrq(NONE);
isrManager.done->decCounter();
}
void UsageFault_Handler(int irqn, void *arg)
{
/* Go to infinite loop when Usage Fault exception occurs */
while (1)
{
}
}
void BusFault_Handler(int irqn, void *arg)
{
/* Go to infinite loop when Bus Fault exception occurs */
while (1)
{
}
}
void NMI_Handler(int irqn, void *arg)
{
while (1)
{
}
}

View File

@ -0,0 +1,122 @@
//*****************************************************************************
//
// startup_gcc.c - Startup code for use with GNU tools.
//
// Copyright (c) 2013 Texas Instruments Incorporated. All rights reserved.
// Software License Agreement
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
//
// Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// 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.
//
// Neither the name of Texas Instruments Incorporated 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.
//
// This is part of revision 10636 of the Stellaris Firmware Development Package.
//
//*****************************************************************************
/**
* @file interrupt_vector.S
* @brief derived from Stellaris Firmware Development Package
* @version 1.0
* @author AIIT XUOS Lab
* @date 2021-05-13
*/
/*************************************************
File name: interrupt_vector.S
Description: vector table for a Cortex M3
Others:
History:
1. Date: 2021-05-13
Author: AIIT XUOS Lab
Modification:
1. take startup_gcc.c from revision 10636 of the Stellaris Firmware Development Package for XiUOS
*************************************************/
//*****************************************************************************
//
// The vector table. Note that the proper constructs must be placed on this to
// ensure that it ends up at physical address 0x0000.0000.
//
//*****************************************************************************
.globl InterruptVectors
/******************************************************************************
*******************************************************************************/
.section .isr_vector,"a",%progbits
.type InterruptVectors, %object
.size InterruptVectors, .-InterruptVectors
InterruptVectors:
.word _sp
.word Reset_Handler
.word NMI_Handler // NMI_Handler
.word HardFaultHandler
.word MemFaultHandler // MemManage_Handler
.word BusFault_Handler // BusFault_Handler
.word UsageFault_Handler // UsageFault_Handler
.word IsrEntry
.word IsrEntry
.word IsrEntry
.word IsrEntry
.word IsrEntry // SVC_Handler
.word IsrEntry // DebugMon_Handler
.word IsrEntry
.word PendSV_Handler // PendSV_Handler
.word IsrEntry // systick
.word IsrEntry
.word IsrEntry
.word IsrEntry // UART
.word IsrEntry
.word IsrEntry
.word IsrEntry
.word IsrEntry
.word IsrEntry
.word IsrEntry
.word IsrEntry
.word IsrEntry
.word IsrEntry
.word IsrEntry
.word IsrEntry
.word IsrEntry
.word IsrEntry
.word IsrEntry
.word IsrEntry
.word IsrEntry
.word IsrEntry
.word IsrEntry
.word IsrEntry
.word IsrEntry
.word IsrEntry
.word IsrEntry
.word IsrEntry
.word IsrEntry
.word IsrEntry
.word IsrEntry
.word IsrEntry
.word IsrEntry

View File

@ -1,4 +1,4 @@
SRC_FILES := pendsv.S prepare_ahwstack.c arm32_switch.c SRC_FILES := prepare_ahwstack.c
include $(KERNEL_ROOT)/compiler.mk include $(KERNEL_ROOT)/compiler.mk

View File

@ -1,31 +1,22 @@
/* /*
* Original Copyright (c) 2006-2018, RT-Thread Development Team * Copyright (c) 2020 AIIT XUOS Lab
* Modified 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.
* Licensed under the Apache License, Version 2.0 (the "License"); * You may obtain a copy of Mulan PSL v2 at:
* you may not use this file except in compliance with the License. * http://license.coscl.org.cn/MulanPSL2
* You may obtain a copy of the License at * 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.
*/
* http://www.apache.org/licenses/LICENSE-2.0 /**
* @file connect_lora_spi.c
* Unless required by applicable law or agreed to in writing, software * @brief support to register spi lora pointer and function
* distributed under the License is distributed on an "AS IS" BASIS, * @version 1.0
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * @author AIIT XUOS Lab
* See the License for the specific language governing permissions and * @date 2021-05-17
* limitations under the License. */
*
* Change Logs:
* Date Author Notes
* 2019-02-20 XiaojieFan the first version
*/
/*
* Modified by: AIIT XUOS Lab
* Modified date: 2020-09-01
* Description: replace original macro and basic date type with AIIT XUOS Lab's own defination
* start using AIIT XUOS Lab's own functional interfaces
* change some header files
*/
#include <connect_spi_lora.h> #include <connect_spi_lora.h>
@ -319,6 +310,11 @@ static uint32 SpiLoraOpen(void *dev)
KPrintf("SpiLoraOpen start\n"); KPrintf("SpiLoraOpen start\n");
x_err_t ret = EOK; x_err_t ret = EOK;
static x_bool lora_init_status = RET_FALSE;
if (RET_TRUE == lora_init_status) {
return EOK;
}
struct HardwareDev *haldev = (struct HardwareDev *)dev; struct HardwareDev *haldev = (struct HardwareDev *)dev;
@ -361,13 +357,22 @@ static uint32 SpiLoraOpen(void *dev)
KPrintf("LoRa check ok!\nNote: The length of the message that can be sent in a single time is 120 characters\n"); KPrintf("LoRa check ok!\nNote: The length of the message that can be sent in a single time is 120 characters\n");
} }
lora_init_status = RET_TRUE;
return ret; return ret;
} }
static uint32 SpiLoraClose(void *dev)
{
NULL_PARAM_CHECK(dev);
return EOK;
}
static const struct LoraDevDone lora_done = static const struct LoraDevDone lora_done =
{ {
.open = SpiLoraOpen, .open = SpiLoraOpen,
.close = NONE, .close = SpiLoraClose,
.write = SpiLoraWrite, .write = SpiLoraWrite,
.read = SpiLoraRead, .read = SpiLoraRead,
}; };
@ -475,7 +480,7 @@ int LoraSx12xxSpiDeviceInit(void)
return EOK; return EOK;
} }
#ifdef LORA_TEST
/*Just for lora test*/ /*Just for lora test*/
static struct Bus *bus; static struct Bus *bus;
static struct HardwareDev *dev; static struct HardwareDev *dev;
@ -540,4 +545,4 @@ static void LoraSend(int argc, char *argv[])
} }
SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_CMD_MAIN), SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_CMD_MAIN),
LoraSend, LoraSend, lora send message ); LoraSend, LoraSend, lora send message );
#endif

View File

@ -62,7 +62,6 @@ void SX1276Init( void )
SX1276Reset( ); SX1276Reset( );
SX1276Read(0x06, &TempReg); SX1276Read(0x06, &TempReg);
KPrintf("SX1276 Read 0x%x\n", &TempReg);
if(TempReg != 0x6C) if(TempReg != 0x6C)
{ {

View File

@ -1,31 +1,22 @@
/* /*
* Original Copyright (c) 2006-2018, RT-Thread Development Team * Copyright (c) 2020 AIIT XUOS Lab
* Modified 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.
* Licensed under the Apache License, Version 2.0 (the "License"); * You may obtain a copy of Mulan PSL v2 at:
* you may not use this file except in compliance with the License. * http://license.coscl.org.cn/MulanPSL2
* You may obtain a copy of the License at * 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.
*/
* http://www.apache.org/licenses/LICENSE-2.0 /**
* @file connect_lora_spi.c
* Unless required by applicable law or agreed to in writing, software * @brief support to register spi lora pointer and function
* distributed under the License is distributed on an "AS IS" BASIS, * @version 1.0
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * @author AIIT XUOS Lab
* See the License for the specific language governing permissions and * @date 2021-05-17
* limitations under the License. */
*
* Change Logs:
* Date Author Notes
* 2019-02-20 XiaojieFan the first version
*/
/*
* Modified by: AIIT XUOS Lab
* Modified date: 2020-09-01
* Description: replace original macro and basic date type with AIIT XUOS Lab's own defination
* start using AIIT XUOS Lab's own functional interfaces
* change some header files
*/
#include <connect_spi_lora.h> #include <connect_spi_lora.h>
@ -136,14 +127,7 @@ inline uint8_t SX1276ReadDio5(void)
inline void SX1276WriteRxTx(uint8_t txEnable) inline void SX1276WriteRxTx(uint8_t txEnable)
{ {
if (txEnable != 0) return;
{
}
else
{
}
} }
void SX1276SetReset(uint8_t state) void SX1276SetReset(uint8_t state)
@ -319,6 +303,11 @@ static uint32 SpiLoraOpen(void *dev)
KPrintf("SpiLoraOpen start\n"); KPrintf("SpiLoraOpen start\n");
x_err_t ret = EOK; x_err_t ret = EOK;
static x_bool lora_init_status = RET_FALSE;
if (RET_TRUE == lora_init_status) {
return EOK;
}
struct HardwareDev *haldev = (struct HardwareDev *)dev; struct HardwareDev *haldev = (struct HardwareDev *)dev;
@ -361,13 +350,22 @@ static uint32 SpiLoraOpen(void *dev)
KPrintf("LoRa check ok!\nNote: The length of the message that can be sent in a single time is 120 characters\n"); KPrintf("LoRa check ok!\nNote: The length of the message that can be sent in a single time is 120 characters\n");
} }
lora_init_status = RET_TRUE;
return ret; return ret;
} }
static uint32 SpiLoraClose(void *dev)
{
NULL_PARAM_CHECK(dev);
return EOK;
}
static const struct LoraDevDone lora_done = static const struct LoraDevDone lora_done =
{ {
.open = SpiLoraOpen, .open = SpiLoraOpen,
.close = NONE, .close = SpiLoraClose,
.write = SpiLoraWrite, .write = SpiLoraWrite,
.read = SpiLoraRead, .read = SpiLoraRead,
}; };
@ -467,7 +465,7 @@ int LoraSx12xxSpiDeviceInit(void)
return EOK; return EOK;
} }
#ifdef LORA_TEST
/*Just for lora test*/ /*Just for lora test*/
static struct Bus *bus; static struct Bus *bus;
static struct HardwareDev *dev; static struct HardwareDev *dev;
@ -532,4 +530,4 @@ static void LoraSend(int argc, char *argv[])
} }
SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_CMD_MAIN), SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_CMD_MAIN),
LoraSend, LoraSend, lora send message ); LoraSend, LoraSend, lora send message );
#endif

View File

@ -62,7 +62,6 @@ void SX1276Init( void )
SX1276Reset( ); SX1276Reset( );
SX1276Read(0x06, &TempReg); SX1276Read(0x06, &TempReg);
KPrintf("SX1276 Read 0x%x\n", &TempReg);
if(TempReg != 0x6C) if(TempReg != 0x6C)
{ {

View File

@ -0,0 +1,248 @@
#
# Automatically generated file; DO NOT EDIT.
# XiUOS Project Configuration
#
CONFIG_BOARD_CORTEX_M3_EVB=y
CONFIG_KERNEL_CONSOLE_DEVICE_NAME="uart0"
#CONFIG_LED0=24
#CONFIG_LED1=25
CONFIG_ARCH_RISCV=y
CONFIG_ARCH_RISCV32=y
CONFIG_ARCH_CPU_32BIT=y
#
# cortex-m3-emulator feature
#
# CONFIG_BSP_USING_AUDIO is not set
# CONFIG_BSP_USING_CAMERA is not set
# CONFIG_BSP_USING_SDIO is not set
# CONFIG_BSP_USING_DMA is not set
CONFIG_BSP_USING_GPIO=y
# CONFIG_BSP_USING_I2C is not set
# CONFIG_BSP_USING_I2S is not set
# CONFIG_BSP_USING_LCD is not set
# CONFIG_BSP_USING_RTC is not set
# CONFIG_BSP_USING_SECURITY is not set
# CONFIG_BSP_USING_SPI is not set
CONFIG_BSP_USING_UART=y
# CONFIG_BSP_USING_UART_HS is not set
# CONFIG_BSP_USING_VIDEO is not set
# CONFIG_BSP_USING_WDT is not set
#
# General Purpose UARTs
#
CONFIG___STACKSIZE__=4096
#
# Hardware feature
#
CONFIG_RESOURCES_SERIAL=y
# CONFIG_SERIAL_USING_DMA=y
CONFIG_SERIAL_RB_BUFSZ=64
CONFIG_FS_VFS=n
# CONFIG_RESOURCES_HWTIMER is not set
# CONFIG_RESOURCES_I2C is not set
# CONFIG_RESOURCES_LCD is not set
# CONFIG_RESOURCES_SDIO is not set
# CONFIG_RESOURCES_TOUCH is not set
# CONFIG_RESOURCES_PIN=y
# CONFIG_RESOURCES_RTC is not set
# CONFIG_RESOURCES_SPI is not set
#CONFIG_RESOURCES_SPI_SD is not set
#CONFIG_RESOURCES_SPI_SFUD is not set
# SFUD_USING_SFDP is not set
# SFUD_USING_FLASH_INFO_TABLE is not set
# SFUD_DEBUG_LOG is not set
# CONFIG_RESOURCES_WDT is not set
# CONFIG_RESOURCES_USB is not set
# CONFIG_RESOURCES_USB_HOST is not set
# CONFIG_UDISK_MOUNTPOINT is not set
# CONFIG_USBH_MSTORAGE is not set
# CONFIG_RESOURCES_USB_DEVICE is not set
# CONFIG_USBD_THREAD_STACK_SZ is not set
#
# Kernel feature
#
#
# Kernel Device Object
#
CONFIG_KERNEL_DEVICE=y
CONFIG_KERNEL_CONSOLE=y
CONFIG_KERNEL_CONSOLEBUF_SIZE=128
#
# Task feature
#
CONFIG_SCHED_POLICY_RR_REMAINSLICE=y
# CONFIG_SCHED_POLICY_RR is not set
# CONFIG_SCHED_POLICY_FIFO is not set
#
# Memory Management
#
# CONFIG_KERNEL_MEMBLOCK is not set
CONFIG_MEM_ALIGN_SIZE=4
CONFIG_MM_PAGE_SIZE=1024
#
# Using small memory allocator
#
CONFIG_KERNEL_SMALL_MEM_ALLOC=y
CONFIG_SMALL_NUMBER_32B=32
CONFIG_SMALL_NUMBER_64B=16
#
# Inter-Task communication
#
# CONFIG_KERNEL_SEMAPHORE=y
# CONFIG_KERNEL_MUTEX=y
CONFIG_KERNEL_EVENT=n
CONFIG_KERNEL_MESSAGEQUEUE=n
CONFIG_KTASK_PRIORITY_8=y
CONFIG_KTASK_PRIORITY_MAX=8
CONFIG_TICK_PER_SECOND=100
# CONFIG_KERNEL_STACK_OVERFLOW_CHECK=y
CONFIG_KERNEL_BANNER=y
# CONFIG_KERNEL_HOOK is not set
# CONFIG_KERNEL_SOFTTIMER=y
# CONFIG_KERNEL_IDLE_HOOK=y
# CONFIG_IDEL_HOOK_LIST_SIZE=4
CONFIG_IDLE_KTASK_STACKSIZE=512
CONFIG_ZOMBIE_KTASK_STACKSIZE=512
# CONFIG_KERNEL_TASK_ISOLATION is not set
#
# Memory Management
#
# CONFIG_KERNEL_MEMBLOCK is not set
#
# Command shell
#
CONFIG_TOOL_SHELL=y
CONFIG_SHELL_TASK_PRIORITY=4
CONFIG_SHELL_TASK_STACK_SIZE=2048
#
# User Control
#
CONFIG_SHELL_DEFAULT_USER="letter"
CONFIG_SHELL_DEFAULT_USER_PASSWORD=""
CONFIG_SHELL_LOCK_TIMEOUT=10000
CONFIG_SHELL_ENTER_CR_AND_LF=y
# CONFIG_SHELL_ENTER_CRLF is not set
CONFIG_SHELL_ENTER_CR=y
CONFIG_SHELL_ENTER_LF=y
CONFIG_SHELL_MAX_NUMBER=5
CONFIG_SHELL_PARAMETER_MAX_NUMBER=8
CONFIG_SHELL_HISTORY_MAX_NUMBER=5
CONFIG_SHELL_PRINT_BUFFER=128
CONFIG_SHELL_USING_CMD_EXPORT=y
# CONFIG_SHELL_HELP_LIST_USER is not set
CONFIG_SHELL_HELP_SHOW_PERMISSION=y
# CONFIG_SHELL_HELP_LIST_VAR is not set
# CONFIG_SHELL_HELP_LIST_KEY is not set
#CONFIG_KERNEL_QUEUEMANAGE=y
# CONFIG_KERNEL_WORKQUEUE is not set
CONFIG_WORKQUEUE_KTASK_STACKSIZE=256
CONFIG_WORKQUEUE_KTASK_PRIORITY=2
CONFIG_QUEUE_MAX=2
CONFIG_KERNEL_WAITQUEUE=y
CONFIG_KERNEL_DATAQUEUE=y
# CONFIG_KERNEL_CIRCULAR_AREA is not set
# CONFIG_KERNEL_AVL_TREE is not set
CONFIG_NAME_MAX=32
CONFIG_ALIGN_SIZE=8
CONFIG_KERNEL_COMPONENTS_INIT=n
CONFIG_KERNEL_USER_MAIN=y
CONFIG_MAIN_KTASK_STACK_SIZE=2048
CONFIG_ENV_INIT_KTASK_STACK_SIZE=2048
CONFIG_MAIN_KTASK_PRIORITY=3
# CONFIG_USER_TEST is not set
# CONFIG_TOOL_TEST_SEM is not set
# CONFIG_TOOL_TEST_MUTEX is not set
# CONFIG_TOOL_TEST_EVENT is not set
# CONFIG_TOOL_TEST_MSG is not set
# CONFIG_TOOL_TEST_AVLTREE is not set
# CONFIG_TEST_CRICULAR_AREA is not set
# CONFIG_TOOL_TEST_MEM is not set
# CONFIG_TOOL_TEST_TIMER is not set
# CONFIG_TOOL_TEST_IWG is not set
# CONFIG_TOOL_TEST_REALTIME is not set
# CONFIG_TOOL_TEST_DBG is not set
# CONFIG_TOOL_TEST_SCHED is not set
# CONFIG_KERNEL_DEBUG is not set
#CONFIG_DEBUG_INIT_CONFIG=y
#CONFIG_DBG_INIT=1
#CONFIG_ARCH_SMP=y
#CONFIG_CPUS_NR=2
#
# hash table config
#
CONFIG_ID_HTABLE_SIZE=4
CONFIG_ID_NUM_MAX=16
#
# File system
#
CONFIG_FS_DFS=n
#CONFIG_DFS_USING_WORKDIR=y
#CONFIG_FS_DFS_DEVFS=y
#
# Fat filesystem
#
#
# IOT-Device File system
#
#
# Lwext4 filesystem
#
#
# APP Framework
#
#
# Perception
#
# CONFIG_PERCEPTION_SENSORDEVICE is not set
#
# connection
#
# CONFIG_CONNECTION_AT is not set
# CONFIG_CONNECTION_MQTT is not set
#
# medium communication
#
#
# Intelligence
#
#
# Control
#
#
# Lib
#
CONFIG_LIB=y
CONFIG_LIB_POSIX=y
CONFIG_LIB_NEWLIB=y
# CONFIG_LITTLEVGL2RTT_USING_DEMO=y
#
# Security
#

View File

@ -0,0 +1,56 @@
mainmenu "XiUOS Project Configuration"
config BSP_DIR
string
option env="BSP_ROOT"
default "."
config KERNEL_DIR
string
option env="KERNEL_ROOT"
default "../.."
config BOARD_CORTEX_M0_EVB
bool
select ARCH_ARM
default y
config KERNEL_CONSOLE_DEVICE_NAME
string
default "uart0"
source "$KERNEL_DIR/arch/Kconfig"
menu "cortex-m0 emulator feature"
source "$BSP_DIR/third_party_driver/Kconfig"
menu "config default board resources"
menu "config board app name"
config BOARD_APP_NAME
string "config board app name"
default "/XiUOS_cortex-m0-emulator_app.bin"
endmenu
menu "config board service table"
config SERVICE_TABLE_ADDRESS
hex "board service table address"
default 0x2007F0000
endmenu
endmenu
config __STACKSIZE__
int "stack size for interrupt"
default 4096
endmenu
menu "Hardware feature"
source "$KERNEL_DIR/resources/Kconfig"
endmenu
source "$KERNEL_DIR/Kconfig"

View File

@ -0,0 +1,5 @@
SRC_DIR := third_party_driver
SRC_FILES := board.c connect_uart.c
include $(KERNEL_ROOT)/compiler.mk

View File

@ -0,0 +1,187 @@
# 从零开始构建矽璓工业物联操作系统使用ARM架构的cortex-m0 emulator
# cortex-m0 emulator
[XiUOS](http://xuos.io/) (X Industrial Ubiquitous Operating System) 矽璓XiUOS是一款面向智慧车间的工业物联网操作系统主要由一个极简的微型实时操作系统内核和其上的工业物联框架构成通过高效管理工业物联网设备、支撑工业物联应用在生产车间内实现智能化的“感知环境、联网传输、知悉识别、控制调整”促进以工业设备和工业控制系统为核心的人、机、物深度互联帮助提升生产线的数字化和智能化水平。
## 1. 简介
QEMU 是一个通用的开源模拟器和虚拟化工具。目前QEMU已经可以较完整的支持ARM cortex-m0架构。XiUOS同样支持运行在QEMU上
| 硬件 | 描述 |
| -- | -- |
|芯片型号| microbit nRF51 |
|架构| cortex-m0 |
|主频| 50MHz |
|片内SRAM| 64KB |
| 外设支持 | UART |
XiUOS板级当前支持使用UART。
## 2. 开发环境搭建
### 推荐使用:
**操作系统:** ubuntu18.04 [https://ubuntu.com/download/desktop](https://ubuntu.com/download/desktop)
更新`ubuntu 18.04`源的方法:(根据自身情况而定,可以不更改)
第一步:打开sources.list文件
```c
sudo vim /etc/apt/sources.list
```
第二步:将以下内容复制到sources.list文件
```c
deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
```
第三步:更新源和系统软件
```c
sudo apt-get update
sudo apt-get upgrade
```
**开发工具推荐使用 VSCode VScode下载地址为** VSCode [https://code.visualstudio.com/](https://code.visualstudio.com/),推荐下载地址为 [http://vscode.cdn.azure.cn/stable/3c4e3df9e89829dce27b7b5c24508306b151f30d/code_1.55.2-1618307277_amd64.deb](http://vscode.cdn.azure.cn/stable/3c4e3df9e89829dce27b7b5c24508306b151f30d/code_1.55.2-1618307277_amd64.deb)
### 依赖包安装:
```
$ sudo apt install build-essential pkg-config git
$ sudo apt install gcc make libncurses5-dev openssl libssl-dev bison flex libelf-dev autoconf libtool gperf libc6-dev
```
**XiUOS操作系统源码下载** XiUOS [https://forgeplus.trustie.net/projects/xuos/xiuos](https://forgeplus.trustie.net/projects/xuos/xiuos)
新建一个空文件夹并进入文件夹中,并下载源码,具体命令如下:
```c
mkdir test && cd test
git clone https://git.trustie.net/xuos/xiuos.git
```
打开源码文件包可以看到以下目录:
| 名称 | 说明 |
| -- | -- |
| application | 应用代码 |
| board | 板级支持包 |
| framework | 应用框架 |
| fs | 文件系统 |
| kernel | 内核源码 |
| resources | 驱动文件 |
| tool | 系统工具 |
使用VScode打开代码具体操作步骤为在源码文件夹下打开系统终端输入`code .`即可打开VScode开发环境如下图所示
<div align= "center">
<img src = img/vscode.jpg width =1000>
</div>
### 裁减配置工具的下载
裁减配置工具:
**工具地址:** kconfig-frontends [https://forgeplus.trustie.net/projects/xuos/kconfig-frontends](https://forgeplus.trustie.net/projects/xuos/kconfig-frontends),下载与安装的具体命令如下:
```c
mkdir kfrontends && cd kfrontends
git clone https://git.trustie.net/xuos/kconfig-frontends.git
```
下载源码后按以下步骤执行软件安装:
```c
cd kconfig-frontends
./xs_build.sh
```
### 编译工具链:
ARM arm-none-eabi(`gcc version 6.3.1`)默认安装到Ubuntu的/usr/bin/arm-none-eabi-,使用如下命令行下载和安装。
```shell
$ sudo apt install gcc-arm-none-eabi
```
## 编译说明
### 编辑环境:`Ubuntu18.04`
### 编译工具链:`arm-none-eabi-gcc`
使用`VScode`打开工程的方法有多种,本文介绍一种快捷键,在项目目录下将`code .`输入linux系统命令终端即可打开目标项目
编译步骤:
1.在VScode命令终端中执行以下命令生成配置文件
```c
make BOARD=cortex-m0-emulator menuconfig
```
2.在menuconfig界面配置需要关闭和开启的功能按回车键进入下级菜单按Y键选中需要开启的功能按N键选中需要关闭的功能配置结束后保存并退出本例旨在演示简单的输出例程所以没有需要配置的选项双击快捷键ESC退出配置
![menuconfig](img/menuconfig.png)
退出时选择`yes`保存上面所配置的内容,如下图所示:
![menuconfig1](img/menuconfig1.png)
3.继续执行以下命令,进行编译
```
make BOARD=cortex-m0-emulator
```
4.如果编译正确无误会产生XiUOS_cortex-m0-emulator.elf、XiUOS_cortex-m0-emulator.bin文件。
## 3. 运行
### 3.1 安装QEMU
```
sudo apt install qemu-system-arm
```
### 3.2 运行结果
通过以下命令启动QEMU并加载XiUOS ELF文件
```
qemu-system-arm -machine microbit -nographic -kernel build/XiUOS_cortex-m0-emulator.elf
```
QEMU运行起来后将会在终端上看到信息打印输出
![terminal](img/terminal.png)
### 3.3 调试
通过QEMU可以方便的对XiUOS进行调试首先安装gdb调试工具
```
sudo apt install gdb-multiarch
```
并通过以下命令启动QEMU
```
qemu-system-arm -machine microbit -nographic -kernel build/XiUOS_cortex-m0-emulator.elf -s -S
```
然后要重新开启另一个linux系统终端一个终端执行命令
```
gdb-multiarch build/XiUOS_cortex-m0-emulator.elf -ex "target remote localhost:1234"
```

View File

@ -0,0 +1,39 @@
/*
* 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 board.c
* @brief support cortex-m3-emulator init configure and start-up
* @version 1.0
* @author AIIT XUOS Lab
* @date 2021-05-13
*/
#include <board.h>
#include <xiuos.h>
#include <device.h>
#include <arch_interrupt.h>
void SysTick_Handler(int irqn, void *arg)
{
TickAndTaskTimesliceUpdate();
}
DECLARE_HW_IRQ(SYSTICK_IRQN, SysTick_Handler, NONE);
void InitBoardHardware()
{
extern int InitHwUart(void);
InitHwUart();
InstallConsole(SERIAL_BUS_NAME_1, SERIAL_DRV_NAME_1, SERIAL_DEVICE_NAME_1);
InitBoardMemory((void*)LM3S_SRAM_START, (void*)LM3S_SRAM_END);
}

View File

@ -0,0 +1,38 @@
/*
* 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 board.h
* @brief define cortex-m3-emulator init configure and start-up function
* @version 1.0
* @author AIIT XUOS Lab
* @date 2021-05-13
*/
#ifndef __BOARD_H__
#define __BOARD_H__
extern void *__bss_end;
extern void *_heap_end;
#define MEM_OFFSET 0x20001000
#define LM3S_SRAM_START ( ( ((unsigned long)(&__bss_end)) > MEM_OFFSET)? (unsigned long)(&__bss_end):(MEM_OFFSET) )
#define LM3S_SRAM_END ( &_heap_end )
#define BSP_USING_UART1
#define SERIAL_BUS_NAME_1 "uart0"
#define SERIAL_DRV_NAME_1 "uart0_drv"
#define SERIAL_DEVICE_NAME_1 "uart0_dev0"
#endif

View File

@ -0,0 +1,14 @@
export CROSS_COMPILE ?=/usr/bin/arm-none-eabi-
export CFLAGS := -mcpu=cortex-m0 -mthumb -ffunction-sections -fdata-sections -Dgcc -O0 -gdwarf-2 -g -fgnu89-inline -Wa,-mimplicit-it=thumb
export AFLAGS := -c -mcpu=cortex-m0 -mthumb -ffunction-sections -fdata-sections -x assembler-with-cpp -Wa,-mimplicit-it=thumb -gdwarf-2
export LFLAGS := -mcpu=cortex-m0 -mthumb -ffunction-sections -fdata-sections -Wl,--gc-sections,-Map=XiUOS_cortex-m0-emulator.map,-cref,-u,Reset_Handler -T $(BSP_ROOT)/link.lds
export CXXFLAGS := -mcpu=cortex-m0 -mthumb -ffunction-sections -fdata-sections -Dgcc -O0 -gdwarf-2 -g
export APPLFLAGS := -mcpu=cortex-m0 -mthumb -ffunction-sections -fdata-sections -Wl,--gc-sections,-Map=XiUOS_app.map,-cref,-u, -T $(BSP_ROOT)/link_userspace.lds
export DEFINES := -DHAVE_CCONFIG_H -g
export ARCH = arm
export MCU = cortex-m0

Some files were not shown because too many files have changed in this diff Show More