本代碼從stm32F103的OV7670例程修改而成,所以內(nèi)部文件名仍為ov7670,但實際為ov7725代碼
單片機(jī)源程序如下:
- #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(); //延時函數(shù)初始化
- NVIC_Configuration(); //設(shè)置NVIC中斷分組2:2位搶占優(yōu)先級,2位響應(yīng)優(yōu)先級
- uart_init(9600); //串口初始化為9600
- LED_Init(); //LED端口初始化
- LCD_Init();
- if(lcddev.id==0X6804||lcddev.id==0X5310||lcddev.id==0X5510) //強制設(shè)置屏幕分辨率為320*240.以支持3.5/4.3寸大屏
- {
- lcddev.width=240;
- lcddev.height=320;
- }
- KEY_Init();
- TPAD_Init(72); //觸摸按鍵初始化
- POINT_COLOR=RED;//設(shè)置字體為紅色
- 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計數(shù)頻率,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);
- //測試觸發(fā)DMA
- // if(!KEY0){
- // LED0=!LED0;
- // TIM1->EGR |=1<<6;
- // }
- //測試DMA觸發(fā)結(jié)果
- // 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++;
- // }
- }
- }
復(fù)制代碼
所有資料51hei提供下載:
Eagle7725攝像頭.rar
(369.28 KB, 下載次數(shù): 248)
2018-12-20 19:53 上傳
點擊文件名下載附件
下載積分: 黑幣 -5
|