標(biāo)題:
Stm32 IO口直接驅(qū)動OV7670 V1.0(keil)源碼
[打印本頁]
作者:
白學(xué)家稽亞娜
時(shí)間:
2018-11-17 17:24
標(biāo)題:
Stm32 IO口直接驅(qū)動OV7670 V1.0(keil)源碼
ov7670的一個(gè)版本的驅(qū)動,有點(diǎn)不太好用,但大家可以拿來做一下參考。
單片機(jī)源程序如下:
/*******************************************************************************
* Copyright (C) 2012 All Rights Reserved
*
* 軟件作者: 騎飛家族
* 版權(quán)所有: 騎飛電子
* 創(chuàng)建日期: 2010年6月10日
* 軟件歷史: 2010年11月2日修改
2012年09月10日修改
* Version: 3.0
/* Includes ------------------------------------------------------------------*/
#include "stm32f10x_lib.h"
#include "ili9320.h"
#include "OV7670.h"
#include "delay.h"
#include <stdio.h>
ErrorStatus HSEStartUpStatus;
#define PIX_LONG ((u32)0x12c00)
#define GUI_CONST_STORAGE const
/* Private function prototypes -----------------------------------------------*/
void Demo_Init(void);
/* Private functions ---------------------------------------------------------*/
/*******************************************************************************
* Function Name : main
* Description : Main program
* Input : None
* Output : None
* Return : None
*******************************************************************************/
int main(void)
{
static unsigned long TimerCnt = 0;
static unsigned int temp7670 = 0;
u16 value,val,val1,val2;
Demo_Init();
ili9320_Initializtion();
ili9320_Clear(0xffff);
delay_ms(100);
ili9320_SetCursor(0,0);
LCD_WriteReg(0x0050, 0);
LCD_WriteReg(0x0052, 0);
LCD_WriteReg(0x0051, 239);
LCD_WriteReg(0x0053, 319);
LCD_WriteRAM_Prepare(); // 開顯存
//delay_ms(10);
while(1!=OV7670_init());
while(1)
{
TimerCnt = 0;
temp7670 = 0;
CLK_init_ON(); // OV7670 XCLK 開
while(value & 0x0800) value = GPIOC->IDR; // Vsync=H
while((~value) & 0x0800) value = GPIOC->IDR; // Vhync=L
CLK_init_OFF(); //OV7670 XCLK 關(guān)
while(TimerCnt < 76800)
{
XCLK_L;
XCLK_H;
value = GPIOC->IDR;
temp7670 ++;
if(value & 0x0100) // HREF = H ||(LCD_PCLK_STATE)
{
//value = GPIOC->IDR;
//display[TimerCnt]=value;
if((temp7670 == 1))// 高字節(jié)||(value & 0x0200) ||(LCD_PCLK_STATE)
{
val1=value& 0x00ff;
}
else // 低字節(jié) if((temp7670 != 1)||(LCD_PCLK_STATE))
{
val2= value<<8 ; //
val =ili9320_BGR2RGB(val1 |val2);
temp7670 = 0;
LCD_WriteRAM(val); //TFT GRAM 數(shù)據(jù)
TimerCnt ++;
}
}
}
}
}
/*******************************************************************************
* Function Name : Demo_Init
* Description : Initializes the demonstration application.
* Input : None
* Output : None
* Return : None
*******************************************************************************/
void Demo_Init(void)
{
/* SYSCLK, HCLK, PCLK2 and PCLK1 configuration -----------------------------*/
/* RCC system reset(for debug purpose) */
RCC_DeInit();
/* Enable HSE */
RCC_HSEConfig(RCC_HSE_ON);
/* Wait till HSE is ready */
HSEStartUpStatus = RCC_WaitForHSEStartUp();
if(HSEStartUpStatus == SUCCESS)
{
/* Enable Prefetch Buffer */
FLASH_PrefetchBufferCmd(FLASH_PrefetchBuffer_Enable);
/* Flash 2 wait state */
FLASH_SetLatency(FLASH_Latency_2);
/* HCLK = SYSCLK */
RCC_HCLKConfig(RCC_SYSCLK_Div1);
/* PCLK2 = HCLK */
RCC_PCLK2Config(RCC_HCLK_Div1);
/* PCLK1 = HCLK/2 */
RCC_PCLK1Config(RCC_HCLK_Div2);
/* PLLCLK = 8MHz * 9 = 72 MHz */
RCC_PLLConfig(RCC_PLLSource_HSE_Div1, RCC_PLLMul_16);
/* Enable PLL */
RCC_PLLCmd(ENABLE);
/* Wait till PLL is ready */
while(RCC_GetFlagStatus(RCC_FLAG_PLLRDY) == RESET)
{
}
/* Select PLL as system clock source */
RCC_SYSCLKConfig(RCC_SYSCLKSource_PLLCLK);
/* Wait till PLL is used as system clock source */
while(RCC_GetSYSCLKSource() != 0x08)
{
}
/* Enable USART1 and GPIOA clock */
RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART1 | RCC_APB2Periph_GPIOA, ENABLE);
}
/* Enable GPIOA, GPIOB, GPIOC, GPIOD, GPIOE, GPIOF, GPIOG and AFIO clocks */
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA | RCC_APB2Periph_GPIOB |RCC_APB2Periph_GPIOC
| RCC_APB2Periph_GPIOD | RCC_APB2Periph_GPIOE | RCC_APB2Periph_GPIOF | RCC_APB2Periph_GPIOG
| RCC_APB2Periph_AFIO, ENABLE);
/*------------------- Resources Initialization -----------------------------*/
/* ADCCLK = PCLK2/8 */
RCC_ADCCLKConfig(RCC_PCLK2_Div8);
/* Enable DMA clock */
RCC_AHBPeriphClockCmd(RCC_AHBPeriph_DMA1, ENABLE);
/* Enable ADC1 and GPIOC clock */
RCC_APB2PeriphClockCmd(RCC_APB2Periph_ALL, ENABLE);
/* If HSE is not detected at program startup */
if(HSEStartUpStatus == ERROR)
{
/* Generate NMI exception */
NVIC_SetSystemHandlerPendingBit(SystemHandler_NMI);
}
}
#ifdef DEBUG
/*******************************************************************************
* Function Name : assert_failed
* Description : Reports the name of the source file and the source line number
* where the assert_param error has occurred.
* Input : - file: pointer to the source file name
* - line: assert_param error line source number
* Output : None
* Return : None
*******************************************************************************/
void assert_failed(u8* file, u32 line)
{
/* User can add his own implementation to report the file name and line number */
}
#endif
復(fù)制代碼
所有資料51hei提供下載:
OV7670直接驅(qū)動.zip
(2.56 MB, 下載次數(shù): 20)
2018-11-17 17:23 上傳
點(diǎn)擊文件名下載附件
下載積分: 黑幣 -5
作者:
jiangkeqin_sy
時(shí)間:
2019-1-1 18:40
為什么下載了文件打不開啊
作者:
bfbd
時(shí)間:
2019-1-2 11:31
帶fifo還是不帶的呀
作者:
菜雞一只314159
時(shí)間:
2019-5-1 10:24
有沒有帶FIFO
歡迎光臨 (http://www.torrancerestoration.com/bbs/)
Powered by Discuz! X3.1