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
|
||||
|
||||
@@ -126,7 +126,28 @@ CONFIG_DFS_FILESYSTEMS_MAX=2
|
||||
CONFIG_DFS_FILESYSTEM_TYPES_MAX=2
|
||||
CONFIG_DFS_FD_MAX=16
|
||||
# CONFIG_RT_USING_DFS_MNTTABLE is not set
|
||||
# CONFIG_RT_USING_DFS_ELMFAT is not set
|
||||
CONFIG_RT_USING_DFS_ELMFAT=y
|
||||
|
||||
#
|
||||
# elm-chan's FatFs, Generic FAT Filesystem Module
|
||||
#
|
||||
CONFIG_RT_DFS_ELM_CODE_PAGE=437
|
||||
CONFIG_RT_DFS_ELM_WORD_ACCESS=y
|
||||
# CONFIG_RT_DFS_ELM_USE_LFN_0 is not set
|
||||
# CONFIG_RT_DFS_ELM_USE_LFN_1 is not set
|
||||
# CONFIG_RT_DFS_ELM_USE_LFN_2 is not set
|
||||
CONFIG_RT_DFS_ELM_USE_LFN_3=y
|
||||
CONFIG_RT_DFS_ELM_USE_LFN=3
|
||||
CONFIG_RT_DFS_ELM_LFN_UNICODE_0=y
|
||||
# CONFIG_RT_DFS_ELM_LFN_UNICODE_1 is not set
|
||||
# CONFIG_RT_DFS_ELM_LFN_UNICODE_2 is not set
|
||||
# CONFIG_RT_DFS_ELM_LFN_UNICODE_3 is not set
|
||||
CONFIG_RT_DFS_ELM_LFN_UNICODE=0
|
||||
CONFIG_RT_DFS_ELM_MAX_LFN=255
|
||||
CONFIG_RT_DFS_ELM_DRIVES=2
|
||||
CONFIG_RT_DFS_ELM_MAX_SECTOR_SIZE=512
|
||||
# CONFIG_RT_DFS_ELM_USE_ERASE is not set
|
||||
CONFIG_RT_DFS_ELM_REENTRANT=y
|
||||
CONFIG_RT_USING_DFS_DEVFS=y
|
||||
# CONFIG_RT_USING_DFS_ROMFS is not set
|
||||
# CONFIG_RT_USING_DFS_RAMFS is not set
|
||||
@@ -162,7 +183,7 @@ CONFIG_RT_USING_PIN=y
|
||||
# CONFIG_RT_USING_SDIO is not set
|
||||
CONFIG_RT_USING_SPI=y
|
||||
# CONFIG_RT_USING_QSPI is not set
|
||||
# CONFIG_RT_USING_SPI_MSD is not set
|
||||
CONFIG_RT_USING_SPI_MSD=y
|
||||
# CONFIG_RT_USING_SFUD is not set
|
||||
# CONFIG_RT_USING_ENC28J60 is not set
|
||||
# CONFIG_RT_USING_SPI_WIFI is not set
|
||||
@@ -348,10 +369,12 @@ CONFIG_BSP_USING_USB_TO_USART=y
|
||||
CONFIG_BSP_USING_SRAM=y
|
||||
# CONFIG_BSP_USING_SPI_FLASH is not set
|
||||
# CONFIG_BSP_USING_EEPROM is not set
|
||||
# CONFIG_BSP_USING_OV2640 is not set
|
||||
CONFIG_BSP_USING_OV2640=y
|
||||
# CONFIG_BSP_USING_ETH is not set
|
||||
# CONFIG_BSP_USING_MPU6050 is not set
|
||||
# CONFIG_BSP_USING_SDCARD is not set
|
||||
CONFIG_BSP_USING_SDCARD=y
|
||||
CONFIG_SDCARD_SPI2_CS_PIN=28
|
||||
CONFIG_SDCARD_SPI_BUS_NAME="spi2"
|
||||
|
||||
#
|
||||
# On-chip Peripheral Drivers
|
||||
@@ -373,7 +396,9 @@ CONFIG_BSP_USING_SPI=y
|
||||
CONFIG_BSP_USING_SPI1=y
|
||||
# CONFIG_BSP_SPI1_TX_USING_DMA is not set
|
||||
# CONFIG_BSP_SPI1_RX_USING_DMA is not set
|
||||
# CONFIG_BSP_USING_SPI2 is not set
|
||||
CONFIG_BSP_USING_SPI2=y
|
||||
# CONFIG_BSP_SPI2_TX_USING_DMA is not set
|
||||
# CONFIG_BSP_SPI2_RX_USING_DMA is not set
|
||||
# CONFIG_BSP_USING_ADC is not set
|
||||
CONFIG_BSP_USING_I2C1=y
|
||||
CONFIG_BSP_I2C1_SCL_PIN=54
|
||||
@@ -397,3 +422,15 @@ CONFIG_BSP_USING_FMC=y
|
||||
#
|
||||
# More Drivers
|
||||
#
|
||||
# CONFIG_PKG_USING_RW007 is not set
|
||||
# CONFIG_RW007_NOT_USE_EXAMPLE_DRIVERS is not set
|
||||
# CONFIG_RW007_USING_STM32_DRIVERS is not set
|
||||
# CONFIG_DRV_USING_OV2640 is not set
|
||||
|
||||
#
|
||||
# Applications
|
||||
#
|
||||
|
||||
#
|
||||
# Framework
|
||||
#
|
||||
|
||||
@@ -0,0 +1,97 @@
|
||||
#include <rtthread.h>
|
||||
#include <rtdevice.h>
|
||||
#include "stdio.h"
|
||||
#include "string.h"
|
||||
#ifdef DRV_USING_OV2640
|
||||
#ifdef RT_USING_POSIX
|
||||
#include <dfs_posix.h>
|
||||
#include <dfs_poll.h>
|
||||
#ifdef RT_USING_POSIX_TERMIOS
|
||||
#include <posix_termios.h>
|
||||
#endif
|
||||
#endif
|
||||
#include<drv_ov2640.h>
|
||||
#define JPEG_BUF_SIZE (1024*200)
|
||||
#define UART_NUMBER2 "uart2"
|
||||
|
||||
void ov2640_test(int argc, char **argv)
|
||||
{
|
||||
|
||||
rt_err_t ret = 0;
|
||||
int fd = 0;
|
||||
fd = open("/dev/ov2640",O_RDONLY);
|
||||
if(fd < 0)
|
||||
{
|
||||
printf("open ov2640 fail !!");
|
||||
return;
|
||||
}
|
||||
rt_uint8_t* JpegBuffer = rt_malloc(JPEG_BUF_SIZE);
|
||||
_ioctl_shoot_para shoot_para_t = {0};
|
||||
if (RT_NULL == JpegBuffer)
|
||||
{
|
||||
printf("JpegBuffer senddata buf malloc error!\n");
|
||||
return;
|
||||
}
|
||||
printf("ov2640 test by printing the image value in memory \r\n");
|
||||
shoot_para_t.pdata = (uint32_t)JpegBuffer;
|
||||
shoot_para_t.length = JPEG_BUF_SIZE;
|
||||
ret = ioctl(fd,IOCTRL_CAMERA_START_SHOT,&shoot_para_t);
|
||||
if(RT_ERROR == ret)
|
||||
{
|
||||
printf("ov2640 can't wait event flag");
|
||||
return;
|
||||
}
|
||||
printf("print the vaule:\r\n\r\n");
|
||||
ret = rt_ov2640_calculate_jpeg_len(JpegBuffer,JPEG_BUF_SIZE);
|
||||
printf("photo leghth is %d :\r\n\r\n",ret);
|
||||
#ifdef BSP_USING_UART2
|
||||
void img_output_uart2(rt_uint8_t* jpegbuf,rt_uint16_t len);
|
||||
img_output_uart2(JpegBuffer,ret);
|
||||
#endif
|
||||
for(int i =0;i<ret;i++)
|
||||
{
|
||||
printf("%x",*(JpegBuffer+i));
|
||||
}
|
||||
printf("\r\n\r\n above :\r\n\r\n");
|
||||
rt_free(JpegBuffer);
|
||||
close(fd);
|
||||
return;
|
||||
}
|
||||
MSH_CMD_EXPORT(ov2640_test,printing the image value in memory);
|
||||
|
||||
#ifdef BSP_USING_UART2
|
||||
void img_output_uart2(rt_uint8_t* jpegbuf,rt_uint16_t len)
|
||||
{
|
||||
static rt_uint8_t i =0;
|
||||
static rt_device_t serial = NULL;
|
||||
int ret = RT_EOK;
|
||||
if(i == 0)
|
||||
{
|
||||
i = 1;
|
||||
serial = rt_device_find(UART_NUMBER2);
|
||||
if (!serial)
|
||||
{
|
||||
printf("find uart2 failed!\n");
|
||||
i = 2;
|
||||
return;
|
||||
}
|
||||
ret = rt_device_open(serial, RT_DEVICE_OFLAG_RDWR | RT_DEVICE_FLAG_INT_RX);
|
||||
if(ret != RT_EOK)
|
||||
{
|
||||
printf("open uart2 failed!\n");
|
||||
i = 2;
|
||||
return ;
|
||||
}
|
||||
}
|
||||
if(i == 1)
|
||||
{
|
||||
rt_device_write(serial, 0, jpegbuf, len);
|
||||
}
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,106 @@
|
||||
#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: tcpclient URL PORT\n");
|
||||
printf("Like: tcpclient 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
|
||||
|
||||
@@ -91,6 +91,20 @@
|
||||
#define DFS_FILESYSTEMS_MAX 2
|
||||
#define DFS_FILESYSTEM_TYPES_MAX 2
|
||||
#define DFS_FD_MAX 16
|
||||
#define RT_USING_DFS_ELMFAT
|
||||
|
||||
/* elm-chan's FatFs, Generic FAT Filesystem Module */
|
||||
|
||||
#define RT_DFS_ELM_CODE_PAGE 437
|
||||
#define RT_DFS_ELM_WORD_ACCESS
|
||||
#define RT_DFS_ELM_USE_LFN_3
|
||||
#define RT_DFS_ELM_USE_LFN 3
|
||||
#define RT_DFS_ELM_LFN_UNICODE_0
|
||||
#define RT_DFS_ELM_LFN_UNICODE 0
|
||||
#define RT_DFS_ELM_MAX_LFN 255
|
||||
#define RT_DFS_ELM_DRIVES 2
|
||||
#define RT_DFS_ELM_MAX_SECTOR_SIZE 512
|
||||
#define RT_DFS_ELM_REENTRANT
|
||||
#define RT_USING_DFS_DEVFS
|
||||
|
||||
/* Device Drivers */
|
||||
@@ -107,6 +121,7 @@
|
||||
#define RT_USING_I2C_BITOPS
|
||||
#define RT_USING_PIN
|
||||
#define RT_USING_SPI
|
||||
#define RT_USING_SPI_MSD
|
||||
#define RT_USING_WIFI
|
||||
#define RT_WLAN_DEVICE_STA_NAME "wlan0"
|
||||
#define RT_WLAN_DEVICE_AP_NAME "wlan1"
|
||||
@@ -230,6 +245,10 @@
|
||||
|
||||
#define BSP_USING_USB_TO_USART
|
||||
#define BSP_USING_SRAM
|
||||
#define BSP_USING_OV2640
|
||||
#define BSP_USING_SDCARD
|
||||
#define SDCARD_SPI2_CS_PIN 28
|
||||
#define SDCARD_SPI_BUS_NAME "spi2"
|
||||
|
||||
/* On-chip Peripheral Drivers */
|
||||
|
||||
@@ -238,6 +257,7 @@
|
||||
#define BSP_USING_UART1
|
||||
#define BSP_USING_SPI
|
||||
#define BSP_USING_SPI1
|
||||
#define BSP_USING_SPI2
|
||||
#define BSP_USING_I2C1
|
||||
#define BSP_I2C1_SCL_PIN 54
|
||||
#define BSP_I2C1_SDA_PIN 55
|
||||
@@ -250,4 +270,9 @@
|
||||
/* More Drivers */
|
||||
|
||||
|
||||
/* Applications */
|
||||
|
||||
/* Framework */
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user