forked from xuos/xiuos
Ubiquitous/RT_Thread/:add rw007 driver and ov2640 driver
This commit is contained in:
@@ -368,22 +368,20 @@ CONFIG_BSP_UART1_RXD_PIN=21
|
||||
# CONFIG_BSP_USING_UART2 is not set
|
||||
# CONFIG_BSP_USING_UART3 is not set
|
||||
# CONFIG_BSP_USING_I2C1 is not set
|
||||
# CONFIG_BSP_USING_SPI1 is not set
|
||||
CONFIG_BSP_USING_SPI1=y
|
||||
# CONFIG_BSP_USING_SPI1_AS_QSPI is not set
|
||||
CONFIG_BSP_SPI1_CLK_PIN=27
|
||||
CONFIG_BSP_SPI1_D0_PIN=28
|
||||
CONFIG_BSP_SPI1_D1_PIN=26
|
||||
CONFIG_BSP_SPI1_USING_SS0=y
|
||||
CONFIG_BSP_SPI1_SS0_PIN=29
|
||||
CONFIG_BSP_SPI1_USING_SS1=y
|
||||
CONFIG_BSP_SPI1_SS1_PIN=8
|
||||
# CONFIG_BSP_SPI1_USING_SS2 is not set
|
||||
# CONFIG_BSP_SPI1_USING_SS3 is not set
|
||||
# CONFIG_BSP_USING_LCD is not set
|
||||
# CONFIG_BSP_USING_SDCARD is not set
|
||||
CONFIG_BSP_USING_DVP=y
|
||||
|
||||
#
|
||||
# The default pin assignment is based on the Maix Duino K210 development board
|
||||
#
|
||||
CONFIG_BSP_DVP_SCCB_SDA_PIN=40
|
||||
CONFIG_BSP_DVP_SCCB_SCLK_PIN=41
|
||||
CONFIG_BSP_DVP_CMOS_RST_PIN=42
|
||||
CONFIG_BSP_DVP_CMOS_VSYNC_PIN=43
|
||||
CONFIG_BSP_DVP_CMOS_PWDN_PIN=44
|
||||
CONFIG_BSP_DVP_CMOS_XCLK_PIN=46
|
||||
CONFIG_BSP_DVP_CMOS_PCLK_PIN=47
|
||||
CONFIG_BSP_DVP_CMOS_HREF_PIN=45
|
||||
CONFIG_BSP_USING_SDCARD=y
|
||||
# CONFIG_BSP_USING_DVP is not set
|
||||
|
||||
#
|
||||
# Kendryte SDK Config
|
||||
@@ -393,4 +391,14 @@ CONFIG_PKG_KENDRYTE_SDK_VERNUM=0x0055
|
||||
#
|
||||
# More Drivers
|
||||
#
|
||||
# CONFIG_PKG_USING_RW007 is not set
|
||||
# CONFIG_DRV_USING_OV2640 is not set
|
||||
|
||||
#
|
||||
# Applications
|
||||
#
|
||||
|
||||
#
|
||||
# Framework
|
||||
#
|
||||
CONFIG___STACKSIZE__=4096
|
||||
|
||||
@@ -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};
|
||||
|
||||
|
||||
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);
|
||||
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_draw_picture(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)
|
||||
{
|
||||
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;
|
||||
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_draw_picture(0, 0, 320, 240, rgbbuffer);
|
||||
rt_thread_mdelay(2);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
#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
|
||||
@@ -246,18 +246,15 @@
|
||||
#define BSP_USING_UART1
|
||||
#define BSP_UART1_TXD_PIN 20
|
||||
#define BSP_UART1_RXD_PIN 21
|
||||
#define BSP_USING_DVP
|
||||
|
||||
/* The default pin assignment is based on the Maix Duino K210 development board */
|
||||
|
||||
#define BSP_DVP_SCCB_SDA_PIN 40
|
||||
#define BSP_DVP_SCCB_SCLK_PIN 41
|
||||
#define BSP_DVP_CMOS_RST_PIN 42
|
||||
#define BSP_DVP_CMOS_VSYNC_PIN 43
|
||||
#define BSP_DVP_CMOS_PWDN_PIN 44
|
||||
#define BSP_DVP_CMOS_XCLK_PIN 46
|
||||
#define BSP_DVP_CMOS_PCLK_PIN 47
|
||||
#define BSP_DVP_CMOS_HREF_PIN 45
|
||||
#define BSP_USING_SPI1
|
||||
#define BSP_SPI1_CLK_PIN 27
|
||||
#define BSP_SPI1_D0_PIN 28
|
||||
#define BSP_SPI1_D1_PIN 26
|
||||
#define BSP_SPI1_USING_SS0
|
||||
#define BSP_SPI1_SS0_PIN 29
|
||||
#define BSP_SPI1_USING_SS1
|
||||
#define BSP_SPI1_SS1_PIN 8
|
||||
#define BSP_USING_SDCARD
|
||||
|
||||
/* Kendryte SDK Config */
|
||||
|
||||
@@ -265,6 +262,11 @@
|
||||
|
||||
/* More Drivers */
|
||||
|
||||
|
||||
/* Applications */
|
||||
|
||||
/* Framework */
|
||||
|
||||
#define __STACKSIZE__ 4096
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user