本代码从stm32F103的OV7670例程修改而成,所以内部文件名仍为ov7670,但实际为ov7725代码
单片机源程序如下:
- #include "led.h"
- #include "delay.h"
- #include "key.h"
- #include "sys.h"
- #include "lcd.h"
- #include "usart.h"
- #include "string.h"
- #include "ov7670.h"
- #include "tpad.h"
- #include "timer.h"
- #include "exti.h"
- #include "dma.h"
- #include "stm32f10x_dma.h"
- extern u8 ov_frame; //在timer.c里面定义
- extern u8 finfish; //在it.c里面定义
- u8 Row[40];
- //u16 Row_color[320];
- int main(void)
- {
- // u32 *p;
- delay_init(); //延时函数初始化
- NVIC_Configuration(); //设置NVIC中断分组2:2位抢占优先级,2位响应优先级
- uart_init(9600); //串口初始化为9600
- LED_Init(); //LED端口初始化
- LCD_Init();
- if(lcddev.id==0X6804||lcddev.id==0X5310||lcddev.id==0X5510) //强制设置屏幕分辨率为320*240.以支持3.5/4.3寸大屏
- {
- lcddev.width=240;
- lcddev.height=320;
- }
- KEY_Init();
- TPAD_Init(72); //触摸按键初始化
- POINT_COLOR=RED;//设置字体为红色
- LCD_ShowString(60,40,200,16,16,"WarShip STM32");
- LCD_ShowString(60,60,200,16,16,"OV7670 TEST");
- LCD_ShowString(60,80,200,16,16,"ATOM@ALIENTEK");
- LCD_ShowString(60,100,200,16,16,"2012/9/14");
- LCD_ShowString(60,120,200,16,16,"KEY0:Light Mode");
- LCD_ShowString(60,140,200,16,16,"KEY1:Saturation");
- LCD_ShowString(60,160,200,16,16,"KEY2:Brightness");
- LCD_ShowString(60,180,200,16,16,"KEY_UP:Contrast");
- LCD_ShowString(60,200,200,16,16,"TPAD:Effects");
- LCD_ShowString(60,220,200,16,16,"OV7670 Init...");
-
- while(OV7670_Init())//初始化OV7670
- {
- LCD_ShowString(60,220,200,16,16,"OV7670 Error!!");
- delay_ms(200);
- LCD_Fill(60,220,239,246,WHITE);
- delay_ms(200);
- }
- LCD_ShowString(60,220,200,16,16,"OV7670 Init OK");
- delay_ms(1500);
- TIM6_Int_Init(10000,7199); //10Khz计数频率,1秒钟中断
-
- // LCD_Put16REG(0,0,"Row[0]:",Row[0]);
- // LCD_Put16REG(0,300,"Row[1]:",Row[1]);
- // //LCD_Put16REG(0,0,"LCD_RAM:",LCD->LCD_RAM);
- // LCD_Put16REG(0,20,"TIM1->SR:",TIM1->SR);
- // LCD_Put16REG(0,280,"DMA->ISR:",DMA1->ISR);
-
- TIM1_ETR_Init();
- MYDMA_Config(DMA1_Channel4,(u32)Row); //初始化DMA1通道
- EXTI4_Init();
- EXTI3_Init();
- while(1)
- {
- // LCD_Put16REG(120,0,"Row[0]:",Row[0]);
- // LCD_Put16REG(120,300,"Row[1]:",Row[1]);
- // //LCD_Put16REG(120,0,"LCD_RAM:",LCD->LCD_RAM);
- // LCD_Put16REG(120,20,"TIM1->SR:",TIM1->SR);
- // LCD_Put16REG(0,240,"TIM1->SMCR:",TIM1->SMCR);
- // LCD_Put16REG(120,240,"TIM1->DIER:",TIM1->DIER);
- // LCD_Put16REG(120,260,"TIM1->CNT:",TIM1->CNT);
- // LCD_Put16REG(120,280,"DMA->ISR:",DMA1->ISR);
- // LCD_Put16REG(0,260,"DMA->CNDTR:",DMA1_Channel4->CNDTR);
- //测试触发DMA
- // if(!KEY0){
- // LED0=!LED0;
- // TIM1->EGR |=1<<6;
- // }
- //测试DMA触发结果
- // if(!KEY1){
- // LED0=!LED0;
- // if(TIM1->SR) TIM1->SR=0x0000;
- // Row[0]=0;
- // MYDMA_Enable(DMA1_Channel4);
- // }
- //测试位带操作
- // if(!KEY2){
- // Row[0]=0XA5;
- // p=(u32 *)Row;
- // LCD_Put32REG(0,0,"Row0:",Row[0]);
- // LCD_Put32REG(120,0,"ARow:",(u32)p);
- // p=(u32 *)(0x22000000+(((u32)Row &0xFFFFF)<<5)+0*4);
- // LCD_Put32REG(0,240,"ARow:",(u32)p);
- // LCD_Put32REG(120,240,"Row00:",*p);
- // p++;
- // LCD_Put32REG(0,260,"ARow:",(u32)p);
- // LCD_Put32REG(120,260,"Row01:",*p);
- // p++;
- // LCD_Put32REG(0,280,"ARow:",(u32)p);
- // LCD_Put32REG(120,280,"Row02:",*p);
- // p++;
- // LCD_Put32REG(0,300,"ARow:",(u32)p);
- // LCD_Put32REG(120,300,"Row03:",*p);
- // p++;
- // }
- }
- }
复制代码
所有资料51hei提供下载:
Eagle7725摄像头.rar
(369.28 KB, 下载次数: 248)
|