Ubiquitous/RT-Thread_Fusion_XiUOS:change name from RT_Thread to RT-Thread_Fusion_XiUOS

This commit is contained in:
chunyexixiaoyu
2022-03-30 18:18:18 +08:00
parent 658feff666
commit 5a0ffaf193
624 changed files with 13 additions and 13 deletions
@@ -0,0 +1,9 @@
from building import *
cwd = GetCurrentDir()
src = Glob('*.c') + Glob('*.cpp')
CPPPATH = [cwd]
group = DefineGroup('Applications', src, depend = [''], CPPPATH = CPPPATH)
Return('group')
@@ -0,0 +1,100 @@
#include <rtthread.h>
#include <rtdevice.h>
#include <stdint.h>
#include <stdlib.h>
#include "drv_lcd.h"
static void drawarea(rt_device_t dev, struct rt_device_graphic_info *info,
int x, int y, int w, int h, uint16_t c)
{
struct rt_device_rect_info rect;
uint16_t *fb;
int i, j;
fb = (uint16_t *)info->framebuffer;
fb += (info->width * y);
fb += x;
for (j = 0; j < h; j++)
{
for (i = 0; i < w; i++)
{
fb[i] = c;
}
fb += info->width;
}
rect.x = x;
rect.y = y;
rect.width = w;
rect.height = h;
rt_device_control(dev, RTGRAPHIC_CTRL_RECT_UPDATE, &rect);
}
#define RGB_BUF_SIZE (320*240*2)
static int showcolor(int argc, char **argv)
{
unsigned char r = 0, g = 0, b = 0;
char *devname = "lcd";
rt_device_t dev;
struct rt_device_graphic_info info;
int result;
int x = 0, y = 0;
int i;
uint16_t c;
for (i = 1; i < argc; i++)
{
switch (i)
{
case 1:
r = atoi(argv[i]);
break;
case 2:
g = atoi(argv[i]);
break;
case 3:
b = atoi(argv[i]);
break;
}
}
dev = rt_device_find(devname);
if (!dev)
{
rt_kprintf("lcd: %s not found\n", devname);
return -1;
}
if (rt_device_open(dev, 0) != 0)
{
rt_kprintf("lcd open fail\n");
return -1;
}
result = rt_device_control(dev, RTGRAPHIC_CTRL_GET_INFO, &info);
if (result != RT_EOK)
{
rt_kprintf("get device information failed\n");
return result;
}
c = (uint16_t)(((r >> 3) << 11) | ((g >> 2) << 6) | ((b >> 3)));
drawarea(dev, &info, x, y, 24, 24, c);
lcd_set_color(BLACK, BLUE);
lcd_show_string(0, 40, 16, "hello world");
lcd_show_string(0, 60, 24, "hello world");
lcd_show_string(0, 90, 32, "hello world");
lcd_draw_line(0, 200, 319, 200);
lcd_draw_circle(270, 120, 30);
lcd_set_color(BLACK, RED);
lcd_show_string(0, 130, 32, "after set color");
lcd_draw_line(0, 0, 319, 239);
lcd_draw_rectangle(50, 10, 170, 145);
lcd_draw_circle(160, 120, 50);
rt_device_close(dev);
return 0;
}
MSH_CMD_EXPORT(showcolor, showcolor R G B-- R / G / B : 0 ~255);
@@ -0,0 +1,48 @@
/*
* @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
* 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 <rtthread.h>
#include <rtdevice.h>
#include <stdio.h>
#define LED_G 12
int main(void)
{
rt_pin_mode(LED_G, PIN_MODE_OUTPUT);
rt_thread_mdelay(100);
char info1[25] ={0};
char info2[25] ={0};
sprintf(info1,"xuos-intelligence k210 ");
sprintf(info2,"build %s %s",__DATE__,__TIME__);
printf("%s %s \n",info1,info2);
#ifdef BSP_USING_LCD
#include<drv_lcd.h>
lcd_show_string(0,60,24,info1);
lcd_show_string(0,90,24,info2);
#endif
while(1)
{
rt_pin_write(LED_G, PIN_HIGH);
rt_thread_mdelay(500);
rt_pin_write(LED_G, PIN_LOW);
rt_thread_mdelay(500);
}
return 0;
}
@@ -0,0 +1,106 @@
#include <rtthread.h>
#include <rtdevice.h>
#include "stdio.h"
#include "string.h"
#include "dvp.h"
#include "fpioa.h"
#include "plic.h"
#include "sysctl.h"
#if(defined DRV_USING_OV2640 && defined BSP_USING_LCD)
#include<drv_ov2640.h>
#define RGB_BUF_SIZE (320*240*2)
#ifdef RT_USING_POSIX
#include <pthread.h>
#include <unistd.h>
#include <stdio.h>
#include <dfs_poll.h>
#ifdef RT_USING_POSIX_TERMIOS
#include <posix_termios.h>
#endif
#endif
static int g_fd = 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)
{
g_fd = open("/dev/ov2640",O_RDONLY);
if(g_fd < 0)
{
printf("open ov2640 fail !!");
return;
}
if (argc < 2)
{
printf("Usage:ov2640 display images in real time or take photos \n");
printf("Like: ov2640_test 1(take photos )\n");
printf("Like: ov2640_test 0(display images in real time )\n");
close(g_fd);
return ;
}
uint32_t* rgbbuffer = rt_malloc(RGB_BUF_SIZE);
rt_thread_t tid;
rt_err_t ret = 0;
int temf = 0;
if(NULL == rgbbuffer)
{
printf("malloc rgbbuffer failed ! \n");
close(g_fd);
return;
}
temf = strtoul(argv[1],0, 10);
printf("ov2640_test choose %d mode \n",temf);
shoot_para_t.pdata = (uint32_t)(rgbbuffer);
shoot_para_t.length = RGB_BUF_SIZE;
if(temf == 0)
{
void lcd_show_ov2640_thread(uint32_t* rgbbuffer);
tid = rt_thread_create("lcdshow", lcd_show_ov2640_thread, rgbbuffer,3000, 9, 20);
rt_thread_startup(tid);
}
else
{
memset(rgbbuffer,0,320*240*2);
ret = ioctl(g_fd,IOCTRL_CAMERA_START_SHOT,&shoot_para_t);
// ret = rt_ov2640_start_shoot((uint32_t)(rgbbuffer), RGB_BUF_SIZE);
if(RT_ERROR == ret)
{
printf("ov2640 can't wait event flag");
close(g_fd);
return;
}
lcd_show_image(0, 0, 320, 240, rgbbuffer);
rt_thread_mdelay(100);
printf("the lcd has shown the image \n");
rt_free(rgbbuffer);
close(g_fd);
}
}
MSH_CMD_EXPORT(ov2640_test,lcd show camera shot image);
void lcd_show_ov2640_thread(uint32_t* rgbbuffer)
{
rt_err_t ret = 0;
while(1)
{
ret = ioctl(g_fd,IOCTRL_CAMERA_START_SHOT,&shoot_para_t);
if(RT_ERROR == ret)
{
printf("ov2640 can't wait event flag");
rt_free(rgbbuffer);
return;
}
//lcd_show_image(0, 0, 320, 240, rgbbuffer);
lcd_draw_picture(0, 0, 320, 240, rgbbuffer);
rt_thread_mdelay(1);
}
}
#endif
@@ -0,0 +1,105 @@
#include <rtthread.h>
#ifdef PKG_USING_RW007
#include <netdb.h>
#include <string.h>
#include <finsh.h>
#include <sys/socket.h>
static const char send_data[] = "This is TCP Client from AIIT";
void rw007_test(int argc, char **argv)
{
int ret;
char *recv_data;
struct hostent *host;
int sock, bytes_received;
struct sockaddr_in server_addr;
const char *url;
int port;
extern rt_bool_t rt_wlan_is_connected(void);
if (rt_wlan_is_connected() != 1)
{
printf("Please connect a wifi firstly\n");
return;
}
if (argc < 3)
{
printf("Usage: rw007 URL PORT\n");
printf("Like: rw007 192.168.12.44 5000\n");
return ;
}
url = argv[1];
port = strtoul(argv[2], 0, 10);
host = gethostbyname(url);
recv_data = rt_malloc(1024);
if (recv_data == RT_NULL)
{
printf("No memory\n");
return;
}
if ((sock = socket(AF_INET, SOCK_STREAM, 0)) == -1)
{
printf("Socket error\n");
rt_free(recv_data);
return;
}
server_addr.sin_family = AF_INET;
server_addr.sin_port = htons(port);
server_addr.sin_addr = *((struct in_addr *)host->h_addr);
rt_memset(&(server_addr.sin_zero), 0, sizeof(server_addr.sin_zero));
if (connect(sock, (struct sockaddr *)&server_addr, sizeof(struct sockaddr)) == -1)
{
printf("Connect fail!\n");
closesocket(sock);
rt_free(recv_data);
return;
}
else
{
printf("Connect successful\n");
}
while (1)
{
bytes_received = recv(sock, recv_data, 1024 - 1, 0);
if (bytes_received < 0)
{
closesocket(sock);
printf("\nreceived error,close the socket.\r\n");
rt_free(recv_data);
break;
}
else if (bytes_received == 0)
{
closesocket(sock);
printf("\nreceived error,close the socket.\r\n");
rt_free(recv_data);
break;
}
recv_data[bytes_received] = '\0';
if (strncmp(recv_data, "q", 1) == 0 || strncmp(recv_data, "Q", 1) == 0)
{
closesocket(sock);
printf("\n got a 'q' or 'Q',close the socket.\r\n");
rt_free(recv_data);
break;
}
else
{
printf("\nReceived data = %s ", recv_data);
}
ret = send(sock, send_data, strlen(send_data), 0);
if (ret < 0)
{
closesocket(sock);
printf("\nsend error,close the socket.\r\n");
rt_free(recv_data);
break;
}
else if (ret == 0)
{
printf("\n Send warning,send function return 0.\r\n");
}
}
return;
}
MSH_CMD_EXPORT(rw007_test, a tcp client sample);
#endif