新手上路
- 积分
- 38
- 金钱
- 38
- 注册时间
- 2015-5-10
- 在线时间
- 0 小时
|
楼主 |
发表于 2015-5-22 10:35:16
|
显示全部楼层
回复【13楼】正点原子:
--------------------------------
我现在又改了一次,在板子跑步起来。麻烦帮我看看。
#include "sys.h"
#include "delay.h"
#include "usart.h"
#include "led.h"
#include "key.h"
#include "lwip_comm.h"
#include "LAN8720.h"
#include "usmart.h"
#include "timer.h"
#include "lcd.h"
#include "adc.h"
#include "rtc.h"
#include "sram.h"
#include "malloc.h"
#include "beep.h"
#include "lwip_comm.h"
#include "tcp_client_demo.h"
#include "tcp_server_demo.h"
#include "udp_demo.h"
#include "httpd.h"
#include "led.h"
#include "key.h"
#include "usart2.h"
#include "ov2640.h"
#include "dcmi.h"
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
u8 ov2640_mode=0; //????:0,RGB565??;1,JPEG??
#define jpeg_buf_size 31*1024 //??JPEG????jpeg_buf???(*4??)
//__align(4) u32 jpeg_buf[jpeg_buf_size]; //JPEG????buf
u32 *jpeg_buf;
volatile u32 jpeg_data_len=0; //buf??JPEG??????
volatile u8 jpeg_data_ok=0; //JPEG????????
//0,???????;
//1,??????,??????;
//2,?????????,?????????
//JPEG??????
const u16 jpeg_img_size_tbl[][2]=
{
160,120, //QQVGA
176,144, //QCIF
320,240, //QVGA
400,240, //WQVGA
352,288, //CIF
640,480, //VGA
800,600, //SVGA
1024,768, //XGA
1280,800, //WXGA
1280,960, //XVGA
1440,900, //WXGA+
1280,1024, //SXGA
1600,1200, //UXGA
};
const u8*EFFECTS_TBL[7]={"Normal","Negative","B&W","Redish","Greenish","Bluish","Antique"}; //7???
const u8*JPEG_SIZE_TBL[13]={"QQVGA","QCIF","QVGA","WQVGA","CIF","VGA","SVGA","XGA","WXGA","XVGA","WXGA+","SXGA","UXGA"};//JPEG?? 13???
//处理JPEG数据
//当采集完一帧JPEG数据后,调用此函数,切换JPEG BUF.开始下一帧采集.
void jpeg_data_process(void)
{
if(ov2640_mode)//只有在JPEG格式下,才需要做处理
{
if(jpeg_data_ok==0) //jpeg数据还未采集完?
{
DMA2_Stream1->CR&=~(1<<0); //停止当前传输
while(DMA2_Stream1->CR&0X01); //等待DMA2_Stream1可配置
jpeg_data_len=jpeg_buf_size-DMA2_Stream1->NDTR;//得到此次数据传输的长度
jpeg_data_ok=1; //标记JPEG数据采集完按成,等待其他函数处理
}
if(jpeg_data_ok==2) //上一次的jpeg数据已经被处理
{
DMA2_Stream1->NDTR=jpeg_buf_size; //传输长度为jpeg_buf_size*4字节
DMA2_Stream1->CR|=1<<0; //重新传输
jpeg_data_ok=0; //?标记数据未采集
}
}
}
//JPEG??
//JPEG??,????2?????.
void jpeg_init(void)
{
u8 size=2; //???QVGA 320*240??
OV2640_JPEG_Mode(); //JPEG??
DCMI_Init(); //DCMI??
DCMI_DMA_Init((u32)&jpeg_buf,jpeg_buf_size,2,1);//DCMI DMA??
OV2640_OutSize_Set(jpeg_img_size_tbl[size][0],jpeg_img_size_tbl[size][1]);//??????
DCMI_Start(); //????
}
//加载UI
//mode:
//bit0:0,不加载;1,加载前半部分UI
//bit1:0,不加载;1,加载后半部分UI
void lwip_test_ui(u8 mode)
{
u8 speed;
u8 buf[30];
POINT_COLOR=RED;
if(mode&1<<0)
{
LCD_Fill(30,30,lcddev.width,110,WHITE); //清除显示
LCD_ShowString(30,30,200,16,16,"Explorer STM32F4");
LCD_ShowString(30,50,200,16,16,"Ethernet lwIP Test");
LCD_ShowString(30,70,200,16,16,"ATOM@ALIENTEK");
LCD_ShowString(30,90,200,16,16,"2014/8/15");
}
if(mode&1<<1)
{
LCD_Fill(30,110,lcddev.width,lcddev.height,WHITE); //清除显示
LCD_ShowString(30,110,200,16,16,"lwIP Init Successed");
if(lwipdev.dhcpstatus==2)sprintf((char*)buf,"DHCP IP:%d.%d.%d.%d",lwipdev.ip[0],lwipdev.ip[1],lwipdev.ip[2],lwipdev.ip[3]);//打印动态IP地址
else sprintf((char*)buf,"Static IP:%d.%d.%d.%d",lwipdev.ip[0],lwipdev.ip[1],lwipdev.ip[2],lwipdev.ip[3]);//打印静态IP地址
LCD_ShowString(30,130,210,16,16,buf);
speed=LAN8720_Get_Speed();//得到网速
if(speed&1<<1)LCD_ShowString(30,150,200,16,16,"Ethernet Speed:100M");
else LCD_ShowString(30,150,200,16,16,"Ethernet Speed:10M");
LCD_ShowString(30,170,200,16,16,"KEY0:TCP Server Test");
LCD_ShowString(30,190,200,16,16,"KEY1:TCP Client Test");
LCD_ShowString(30,210,200,16,16,"KEY2:UDP Test");
}
}
int main(void)
{
// u8 t;
// u8 key;
Stm32_Clock_Init(336,8,2,7);//设置时钟,168Mhz
delay_init(168); //延时初始化
uart_init(84,115200); //初始化串口波特率为115200
usart2_init(42,115200); //初始化串口2波特率为115200
usmart_dev.init(84); //初始化USMART
LED_Init(); //LED初始化
KEY_Init(); //按键初始化
LCD_Init(); //LCD初始化
// BEEP_Init(); //蜂鸣器初始化
// RTC_Init(); //RTC初始化
// Adc_Init(); //ADC初始化
TIM3_Int_Init(100-1,8400-1);//10khz的频率,计数100为10ms
FSMC_SRAM_Init(); //初始化外部SRAM.
my_mem_init(SRAMIN); //初始化内部内存池
my_mem_init(SRAMEX); //初始化外部内存池
my_mem_init(SRAMCCM); //初始化CCM内存池
jpeg_buf=mymalloc(SRAMEX,jpeg_buf_size); //图片存取分配内存
while(OV2640_Init())//初始化OV2640
{
LED0=!LED0;
}
//POINT_COLOR=RED; //红色字体
//lwip_test_ui(1); //加载前半部分UI
//先初始化lwIP(包括LAN8720初始化),此时必须插上网线,否则初始化会失败!!
//LCD_ShowString(30,110,200,16,16,"lwIP Initing...");
while(lwip_comm_init()!=0);//lwip初始化
//等待DHCP获取
while((lwipdev.dhcpstatus!=2)&&(lwipdev.dhcpstatus!=0XFF))//等待DHCP获取成功/超时溢出
{
lwip_periodic_handle();//这里在获取IP地址
}
jpeg_init();//现在这个函数仅仅是用来初始化摄像头
while(1)
{
tcp_server_test();
lwip_periodic_handle();
}
}
编译都是对的 |
|