|
圖像采集程序
- #include "stm32f10x.h"
- #include<stdio.h>
- //應(yīng)用層函數(shù)頭文件
- #include"Application.h"
- /*與板子相關(guān)的頭文件*/
- #include"LED.h"
- #include"KEY.h"
- #include"EXIT.h"
- #include"USART.h"
- #include"delay.h"
- #include"I2C.h"
- #include"OV7670.h"
- uint8_t PIC[R][C];
- //當(dāng)前的狀態(tài)
- //下一步的狀態(tài)
- OV7670_State OV_State=Wait_Vsync1;
- u16 TrueLine;
- u8 datareadyflag=0;
- /*
- 攝像頭模塊初始化
- */
- void Data_Bus_Config(void)
- {
-
- /*通用GPIO結(jié)構(gòu)體聲明*/
- GPIO_InitTypeDef GPIO_InitStructure;
- GPIO_InitStructure.GPIO_Mode=GPIO_Mode_IPU;
- /*開啟時(shí)鐘*/
- RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA,ENABLE);
- RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB,ENABLE);
- RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOC,ENABLE);
- GPIO_InitStructure.GPIO_Pin=D0_Pin;
- GPIO_Init(D0_Port,&GPIO_InitStructure);
- GPIO_InitStructure.GPIO_Pin=D1_Pin;
- GPIO_Init(D1_Port,&GPIO_InitStructure);
- GPIO_InitStructure.GPIO_Pin=D2_Pin;
- GPIO_Init(D2_Port,&GPIO_InitStructure);
- GPIO_InitStructure.GPIO_Pin=D3_Pin;
- GPIO_Init(D3_Port,&GPIO_InitStructure);
- GPIO_InitStructure.GPIO_Pin=D4_Pin;
- GPIO_Init(D4_Port,&GPIO_InitStructure);
- GPIO_InitStructure.GPIO_Pin=D5_Pin;
- GPIO_Init(D5_Port,&GPIO_InitStructure);
- GPIO_InitStructure.GPIO_Pin=D6_Pin;
- GPIO_Init(D6_Port,&GPIO_InitStructure);
- GPIO_InitStructure.GPIO_Pin=D7_Pin;
- GPIO_Init(D7_Port,&GPIO_InitStructure);
- GPIO_InitStructure.GPIO_Speed=GPIO_Speed_50MHz;
- GPIO_InitStructure.GPIO_Mode=GPIO_Mode_Out_PP;
- //PWDN
- GPIO_InitStructure.GPIO_Pin=PWDN_Pin;
- GPIO_Init(PWDN_Port,&GPIO_InitStructure);
- //RESET
- GPIO_InitStructure.GPIO_Pin=RESET_Pin;
- GPIO_Init(RESET_Port,&GPIO_InitStructure);
- //FIFO_RCK
- GPIO_InitStructure.GPIO_Pin=FIFO_RCK_Pin;
- GPIO_Init(FIFO_RCK_Port,&GPIO_InitStructure);
- //FIFO_EO
- GPIO_InitStructure.GPIO_Pin=FIFO_OE_Pin;
- GPIO_Init(FIFO_OE_Port,&GPIO_InitStructure);
- //FIFO_RRST
- GPIO_InitStructure.GPIO_Pin=FIFO_RRST_Pin;
- GPIO_Init(FIFO_RRST_Port,&GPIO_InitStructure);
- //FIFO_WR
- GPIO_InitStructure.GPIO_Pin=FIFO_WR_Pin;
- GPIO_Init(FIFO_WR_Port,&GPIO_InitStructure);
- //FIFO_WRST
- GPIO_InitStructure.GPIO_Pin=FIFO_WRST_Pin;
- GPIO_Init(FIFO_WRST_Port,&GPIO_InitStructure);
- //STORBE
- GPIO_InitStructure.GPIO_Pin=STORBE_Pin;
- GPIO_Init(STORBE_Port,&GPIO_InitStructure);
- }
- void OV7670_Init(void)
- {
- /*I2C控制引腳初始化*/
- I2C_Configuration();
- /*數(shù)據(jù)總線與控制總線初始化*/
- Data_Bus_Config();
- OV7670_Register_Init();
- /*以上初始化結(jié)束之后才可以初始化下面的*/
- EXTI_ClearITPendingBit(EXTI_Line0);
- EXTI_Config(EN);
-
- }
- void OV7670_Register_Init(void)
- {
- PWDN_L;/*電源工作方式*/
- RESET_L;//寄存器復(fù)位
- delay_ms(20);
- RESET_H;
- //YUV格式
- I2C_WriteByte(0x12,0x80);
- I2C_WriteByte(0x3a, 0x04);
- I2C_WriteByte(0x40, 0xd0);
- I2C_WriteByte(0x12, 0x14);
- I2C_WriteByte(0x32, 0x80);
- I2C_WriteByte(0x17, 0x16);
- I2C_WriteByte(0x18, 0x04);
- I2C_WriteByte(0x19, 0x02);
- I2C_WriteByte(0x1a, 0x7b);
- I2C_WriteByte(0x03, 0x06);
- I2C_WriteByte(0x0c, 0x00);
- I2C_WriteByte(0x3e, 0x00);
- I2C_WriteByte(0x70, 0x3a);
- I2C_WriteByte(0x71, 0x35);
- I2C_WriteByte(0x72, 0x11);
- I2C_WriteByte(0x73, 0x00);
- I2C_WriteByte(0xa2, 0x02);
- I2C_WriteByte(0x11, 0x81);
- I2C_WriteByte(0x7a, 0x20);
- I2C_WriteByte(0x7b, 0x1c);
- I2C_WriteByte(0x7c, 0x28);
- I2C_WriteByte(0x7d, 0x3c);
- I2C_WriteByte(0x7e, 0x55);
- I2C_WriteByte(0x7f, 0x68);
- I2C_WriteByte(0x80, 0x76);
- I2C_WriteByte(0x81, 0x80);
- I2C_WriteByte(0x82, 0x88);
- I2C_WriteByte(0x83, 0x8f);
- I2C_WriteByte(0x84, 0x96);
- I2C_WriteByte(0x85, 0xa3);
- I2C_WriteByte(0x86, 0xaf);
- I2C_WriteByte(0x87, 0xc4);
- I2C_WriteByte(0x88, 0xd7);
- I2C_WriteByte(0x89, 0xe8);
- I2C_WriteByte(0x13, 0xe0);
- I2C_WriteByte(0x00, 0x00);
- I2C_WriteByte(0x10, 0x00);
- I2C_WriteByte(0x0d, 0x00);
- I2C_WriteByte(0x14, 0x28);
- I2C_WriteByte(0xa5, 0x05);
- I2C_WriteByte(0xab, 0x07);
- I2C_WriteByte(0x24, 0x75);
- I2C_WriteByte(0x25, 0x63);
- I2C_WriteByte(0x26, 0xA5);
- I2C_WriteByte(0x9f, 0x78);
- I2C_WriteByte(0xa0, 0x68);
- I2C_WriteByte(0xa1, 0x03);
- I2C_WriteByte(0xa6, 0xdf);
- I2C_WriteByte(0xa7, 0xdf);
- I2C_WriteByte(0xa8, 0xf0);
- I2C_WriteByte(0xa9, 0x90);
- I2C_WriteByte(0xaa, 0x94);
- I2C_WriteByte(0x13, 0xe5);
- I2C_WriteByte(0x0e, 0x61);
- I2C_WriteByte(0x0f, 0x4b);
- I2C_WriteByte(0x16, 0x02);
- I2C_WriteByte(0x1e, 0x37);
- I2C_WriteByte(0x21, 0x02);
- I2C_WriteByte(0x22, 0x91);
- I2C_WriteByte(0x29, 0x07);
- I2C_WriteByte(0x33, 0x0b);
- I2C_WriteByte(0x35, 0x0b);
- I2C_WriteByte(0x37, 0x1d);
- I2C_WriteByte(0x38, 0x71);
- I2C_WriteByte(0x39, 0x2a);
- I2C_WriteByte(0x3c, 0x78);
- I2C_WriteByte(0x4d, 0x40);
- I2C_WriteByte(0x4e, 0x20);
- I2C_WriteByte(0x69, 0x00);
- I2C_WriteByte(0x6b, 0x60);
- I2C_WriteByte(0x74, 0x19);
- I2C_WriteByte(0x8d, 0x4f);
- I2C_WriteByte(0x8e, 0x00);
- I2C_WriteByte(0x8f, 0x00);
- I2C_WriteByte(0x90, 0x00);
- I2C_WriteByte(0x91, 0x00);
- I2C_WriteByte(0x92, 0x00);
- I2C_WriteByte(0x96, 0x00);
- I2C_WriteByte(0x9a, 0x80);
- I2C_WriteByte(0xb0, 0x84);
- I2C_WriteByte(0xb1, 0x0c);
- I2C_WriteByte(0xb2, 0x0e);
- I2C_WriteByte(0xb3, 0x82);
- I2C_WriteByte(0xb8, 0x0a);
- I2C_WriteByte(0x43, 0x14);
- I2C_WriteByte(0x44, 0xf0);
- I2C_WriteByte(0x45, 0x34);
- I2C_WriteByte(0x46, 0x58);
- I2C_WriteByte(0x47, 0x28);
- I2C_WriteByte(0x48, 0x3a);
- I2C_WriteByte(0x59, 0x88);
- I2C_WriteByte(0x5a, 0x88);
- I2C_WriteByte(0x5b, 0x44);
- I2C_WriteByte(0x5c, 0x67);
- I2C_WriteByte(0x5d, 0x49);
- I2C_WriteByte(0x5e, 0x0e);
- I2C_WriteByte(0x64, 0x04);
- I2C_WriteByte(0x65, 0x20);
- I2C_WriteByte(0x66, 0x05);
- I2C_WriteByte(0x94, 0x04);
- I2C_WriteByte(0x95, 0x08);
- I2C_WriteByte(0x6c, 0x0a);
- I2C_WriteByte(0x6d, 0x55);
- I2C_WriteByte(0x6e, 0x11);
- I2C_WriteByte(0x6f, 0x9f);
- I2C_WriteByte(0x6a, 0x40);
- I2C_WriteByte(0x01, 0x40);
- I2C_WriteByte(0x02, 0x40);
- I2C_WriteByte(0x13, 0xe7);
- I2C_WriteByte(0x15, 0x00);
- I2C_WriteByte(0x4f, 0x80);
- I2C_WriteByte(0x50, 0x80);
- I2C_WriteByte(0x51, 0x00);
- I2C_WriteByte(0x52, 0x22);
- I2C_WriteByte(0x53, 0x5e);
- I2C_WriteByte(0x54, 0x80);
- I2C_WriteByte(0x58, 0x9e);
- I2C_WriteByte(0x41, 0x08);
- I2C_WriteByte(0x3f, 0x00);
- I2C_WriteByte(0x75, 0x05);
- I2C_WriteByte(0x76, 0xe1);
- I2C_WriteByte(0x4c, 0x00);
- I2C_WriteByte(0x77, 0x01);
- I2C_WriteByte(0x3d, 0xc2);
- I2C_WriteByte(0x4b, 0x09);
- I2C_WriteByte(0xc9, 0x60);
- I2C_WriteByte(0x41, 0x38);
- I2C_WriteByte(0x56, 0x40);
- I2C_WriteByte(0x34, 0x11);
- I2C_WriteByte(0x3b, 0x02);
- I2C_WriteByte(0xa4, 0x89);
- I2C_WriteByte(0x96, 0x00);
- I2C_WriteByte(0x97, 0x30);
- I2C_WriteByte(0x98, 0x20);
- I2C_WriteByte(0x99, 0x30);
- I2C_WriteByte(0x9a, 0x84);
- I2C_WriteByte(0x9b, 0x29);
- I2C_WriteByte(0x9c, 0x03);
- I2C_WriteByte(0x9d, 0x4c);
- I2C_WriteByte(0x9e, 0x3f);
- I2C_WriteByte(0x78, 0x04);
- I2C_WriteByte(0x79, 0x01);
- I2C_WriteByte(0xc8, 0xf0);
- I2C_WriteByte(0x79, 0x0f);
- I2C_WriteByte(0xc8, 0x00);
- I2C_WriteByte(0x79, 0x10);
- I2C_WriteByte(0xc8, 0x7e);
- I2C_WriteByte(0x79, 0x0a);
- I2C_WriteByte(0xc8, 0x80);
- I2C_WriteByte(0x79, 0x0b);
- I2C_WriteByte(0xc8, 0x01);
- I2C_WriteByte(0x79, 0x0c);
- I2C_WriteByte(0xc8, 0x0f);
- I2C_WriteByte(0x79, 0x0d);
- I2C_WriteByte(0xc8, 0x20);
- I2C_WriteByte(0x79, 0x09);
- I2C_WriteByte(0xc8, 0x80);
- I2C_WriteByte(0x79, 0x02);
- I2C_WriteByte(0xc8, 0xc0);
- I2C_WriteByte(0x79, 0x03);
- I2C_WriteByte(0xc8, 0x40);
- I2C_WriteByte(0x79, 0x05);
- I2C_WriteByte(0xc8, 0x30);
- I2C_WriteByte(0x79, 0x26);
- I2C_WriteByte(0x09, 0x00);
- /*
-
- // {0x3a, 0x04},//RGB
- {0x12, 0x10},//QVGA YUV
- {0x3a, 0x14},//使用固定UV輸出
- {0x3d, 0x80},//使用固定UV輸出
- //0 0 : Y U Y V (3a:14 3d:80)
- //0 1 : Y V Y U (3a:14 3d:81)
- //1 0 : U Y V Y (3a:18 3d:80)
- //1 1 : V Y U Y (3a:18 3d:81)
- {0x67, 0x11},//固定U值,0x11,方便測試
- {0x68, 0xFF},//固定V值,0xFF,方便測試
- // {0x40, 0x10},//RGB565
- {0x40, 0xC0},//初始配置,YUV模式,這個(gè)寄存器必須設(shè)置,否則不好使
- // {0x12, 0x14},//QVGA RGB,
- I2C_WriteByte(0x12, 0x10);
- I2C_WriteByte (0x3a, 0x14);
- I2C_WriteByte (0x3d, 0x80);
- I2C_WriteByte(0x67, 0x11);
- I2C_WriteByte(0x68, 0xFF);
- I2C_WriteByte(0x40, 0xC0);
-
- */
- I2C_WriteByte(0x12, 0x10);
- I2C_WriteByte (0x3a, 0x14);
- I2C_WriteByte (0x3d, 0x80);
- I2C_WriteByte(0x67, 0x11);
- I2C_WriteByte(0x68, 0xFF);
- I2C_WriteByte(0x40, 0xC0);
- LED_1(ON);
- LED_2(ON);
- }
- void Read_Pic(void)
- {
- u16 i,j;
- u16 t1,t2;
- //以下代碼完成,圖像的采集,并顯示在tft上
- for(i = 0; i < 240; i ++)
- {
- if(i%6==1)
- {
- for(j = 0; j < 320; j ++)
- {
- if (j<160)
- {
- //獲得一個(gè)Y分量的過程
- FIFO_RCK_L;
- FIFO_RCK_H;
- t1=(0x00ff&GPIOC->IDR);
- FIFO_RCK_L;
- FIFO_RCK_H;
- t2=(0x00ff&GPIOC->IDR);
-
- //跳過一個(gè)點(diǎn),隔開取點(diǎn)
- FIFO_RCK_L;
- FIFO_RCK_H;
- t2=(0x00ff&GPIOC->IDR);
- FIFO_RCK_L;
- FIFO_RCK_H;
- t2=(0x00ff&GPIOC->IDR);
- PIC[TrueLine][j]=t1;
- }
- }
- TrueLine++;
- }
- else
- { //否則跳過這些像素點(diǎn)
- for(j = 0; j < 320; j ++)
- {
- FIFO_RCK_L;
- FIFO_RCK_H;
- t2=(0x00ff&GPIOC->IDR);
- FIFO_RCK_L;
- FIFO_RCK_H;
- t2=(0x00ff&GPIOC->IDR);
- }
- }
- }
- FIFO_OE_H; //禁止FIFO輸出
- }
- void Send_Pic(void)
- {
- u8 i;
- u8 j;
- USART_ClearFlag(USART1, USART_FLAG_TC);
- USART_SendData(USART1,0xff);
- while (USART_GetFlagStatus(USART1, USART_FLAG_TC) == RESET);
- for(i=0;i<40;i++)
- {
- for(j=0;j<160;j++)
- {
- USART_ClearFlag(USART1, USART_FLAG_TC);
- USART_SendData(USART1,PIC[i][j]);
- while (USART_GetFlagStatus(USART1, USART_FLAG_TC) == RESET);
- }
- }
- }
- void I2C_Configuration(void)
- {
- GPIO_InitTypeDef I2C;
- /*開漏輸出,速度50MHZ*/
- I2C.GPIO_Speed=GPIO_Speed_50MHz;
- /*必須設(shè)置成開漏模式*/
- I2C.GPIO_Mode=GPIO_Mode_Out_OD;
- //I2C SDA
- RCC_APB2PeriphClockCmd(SDA_Clock,ENABLE);
- I2C.GPIO_Pin=SDA_Pin;
- GPIO_Init(SDA_Port,&I2C);
- //I2C SCL
- RCC_APB2PeriphClockCmd(SCL_Clock,ENABLE);
- I2C.GPIO_Pin=SCL_Pin;
- GPIO_Init(SCL_Port,&I2C);
- SCL_H;
- SDA_H;
- }
- /*
- *********************************************************************************************************
- * 函數(shù)名稱:I2C_Start()
- * 函數(shù)功能:I2C開始序列
- * 輸入形參:
- * 返回值:
- * 函數(shù)說明:當(dāng)SCL高電平時(shí),SDA出現(xiàn)一個(gè)下跳沿表示I2C總線啟動信號
- *********************************************************************************************************
- */
- void I2C_Start(void)
- {
- SDA_H;
- delay_us(100);
- SCL_H;//延時(shí)5us 等待電平穩(wěn)定
- delay_us(100);
- SDA_L;
- delay_us(100);
- SCL_L;
- delay_us(100);
-
- }
- /*
- *********************************************************************************************************
- * 函數(shù)名稱:I2C_Stop(void)
- * 函數(shù)功能:發(fā)送I2C總線停止信號
- * 輸入形參:無
- * 返回值: 無
- * 函數(shù)說明:當(dāng)SCL高電平時(shí),SDA出現(xiàn)一個(gè)上跳沿表示I2C總線停止信號
- *********************************************************************************************************
- */
- void I2C_Stop(void)
- {
- SDA_L;
- delay_us(100);
- SCL_H;
- delay_us(100);
- SDA_H;
- delay_us(100);
- }
- /*
- *********************************************************************************************************
- * 函 數(shù) 名: i2c_SendByte
- * 功能說明: CPU向I2C總線設(shè)備發(fā)送8bit數(shù)據(jù)
- * 形 參:_ucByte : 等待發(fā)送的字節(jié)
- * 返 回 值: 無
- *********************************************************************************************************
- */
- void I2C_SendByte(uint8_t _ucByte)
- {
- uint8_t i;
- SCL_L;//發(fā)送之前先拉低
- for (i = 0; i < 8; i++)
- {
- if (_ucByte & 0x80)
- {
- SDA_H;
- }
- else
- {
- SDA_L;
- }
- _ucByte <<= 1; /* 左移一個(gè)bit */
- delay_us(100);
- SCL_H;//高電平采集數(shù)據(jù)
- delay_us(100);
- SCL_L;
- delay_us(100);
- if (i == 7)
- {
- SDA_H; // 釋放總線
- }
- }
- }
- /*
- *********************************************************************************************************
- * 函 數(shù) 名: i2c_ReadByte
- * 功能說明: CPU從I2C總線設(shè)備讀取8bit數(shù)據(jù)
- * 形 參:無
- * 返 回 值: 讀到的數(shù)據(jù)
- *********************************************************************************************************
- */
- uint8_t I2C_ReadByte(void)
- {
- uint8_t i;
- uint8_t value;
- /* 讀到第1個(gè)bit為數(shù)據(jù)的bit7 */
- value = 0;
- SCL_L;
- for (i = 0; i < 8; i++)
- {
- value <<= 1;
- SCL_H;
- delay_us(100);
- if (I2C_SDA_READ())
- {
- value++;
- }
- else
- {
-
- }
- SCL_L;
- delay_us(100);
- }
- return value;
- }
- /*
- *********************************************************************************************************
- * 函 數(shù) 名: i2c_WaitAck
- * 功能說明: CPU產(chǎn)生一個(gè)時(shí)鐘,并讀取器件的ACK應(yīng)答信號
- * 形 參:無
- * 返 回 值: 返回0表示正確應(yīng)答,1表示無器件響應(yīng)
- *********************************************************************************************************
- */
- uint8_t I2C_WaitAck(void)
- {
- uint8_t re=0;
- SCL_L;
- SDA_H; /* CPU釋放SDA總線 */
- SCL_H; /* CPU驅(qū)動SCL = 1, 此時(shí)器件會返回ACK應(yīng)答 */
- delay_us(100);
- if(I2C_SDA_READ())
- {
- re=1;
- }
- else
- {
- re=0;
- }
- SCL_L;
- delay_us(100);
- return re;
- }
- /*
- *********************************************************************************************************
- * 函 數(shù) 名: i2c_Ack
- * 功能說明: CPU產(chǎn)生一個(gè)ACK信號
- * 形 參:無
- * 返 回 值: 無
- *********************************************************************************************************
- */
- void I2C_Ack(void)
- {
- /* CPU驅(qū)動SDA = 0 */
- SCL_L;
- delay_us(10);
- SDA_L;
- delay_us(10);
- /* CPU產(chǎn)生1個(gè)時(shí)鐘 */
- SCL_H;
- delay_us(10);
- SCL_L;
- delay_us(10);
- }
- /*
- *********************************************************************************************************
- * 函 數(shù) 名: i2c_NAck
- * 功能說明: CPU產(chǎn)生1個(gè)NACK信號
- * 形 參:無
- * 返 回 值: 無
- *********************************************************************************************************
- */
- void I2C_NAck(void)
- {
- /* CPU驅(qū)動SDA = 1 */
- SDA_H;
- delay_us(100);
- /* CPU產(chǎn)生1個(gè)時(shí)鐘 */
- SCL_H;
- delay_us(100);
- SCL_L;
- delay_us(100);
- SDA_H;
- delay_us(100);
- }
- /*******************************************************************************
- * Function Name : I2C_WriteByte
- * Description : 寫一字節(jié)數(shù)據(jù)
- * Input : - WriteAddress: 待寫入地址
- * - SendByte: 待寫入數(shù)據(jù)
- * - DeviceAddress: 器件類型
- * Output : None
- * Return : 返回為:=1成功寫入,=0失敗
- * Attention : None
- *******************************************************************************/
- int I2C_WriteByte( uint16_t WriteAddress , uint8_t SendByte )
- {
- I2C_Start();
- delay_us(100);
- //發(fā)送器件地址
- I2C_SendByte(ADDR_OV7670);
- //如果器件沒有應(yīng)答,那么就發(fā)送停止信號
- if(I2C_WaitAck()==1)
- {
- I2C_Stop();
- printf("器件沒有應(yīng)答\n"); //調(diào)試使用
- return 0;
- }
- delay_us(5);
- I2C_SendByte((uint8_t)(WriteAddress & 0x00FF)); /* 設(shè)置低起始地址 */
- //如果器件沒有應(yīng)答,那么就發(fā)送停止信號
- if(I2C_WaitAck()==1)
- {
- I2C_Stop();
- printf("寫寄存器地址失敗\n"); //調(diào)試使用
- return 0;
- }
- I2C_SendByte(SendByte); /* 設(shè)置低起始地址寫寄存器數(shù)據(jù) */
- //如果器件沒有應(yīng)答,那么就發(fā)送停止信號
- if(I2C_WaitAck()==1)
- {
- I2C_Stop();
- printf("寫寄存器內(nèi)容失敗\n"); //調(diào)試使用
- return 0;
- }
- I2C_Stop();
- return 1;
- }
- //讀書菊
- uint8_t I2C_ReadOneByte(uint8_t Address)
- {
- uint8_t temp;
- I2C_Start();
- delay_us(100);
- // 寫器件地址
- I2C_SendByte(ADDR_OV7670);
- //如果器件沒有應(yīng)答,那么就發(fā)送停止信號
- if(I2C_WaitAck()==1)
- {
- I2C_Stop();
- printf("器件沒有應(yīng)答\n"); //調(diào)試使用
- return 0;
- }
- delay_us(5);
- I2C_SendByte(Address);
- //如果器件沒有應(yīng)答,那么就發(fā)送停止信號
- if(I2C_WaitAck()==1)
- {
- I2C_Stop();
- printf("寫寄存器地址失敗\n"); //調(diào)試使用
- return 0;
- }
- I2C_Stop();
- delay_us(500);
- //開始讀
- I2C_Start();
- //發(fā)送讀命令
- I2C_SendByte(ADDR_OV7670|0x01);
- if(I2C_WaitAck()==1)
- {
- I2C_Stop();
- printf("讀失敗\n"); //調(diào)試使用
- return 0;
- }
- delay_us(100);
- temp=I2C_ReadByte();
- I2C_NAck();
- I2C_Stop();
- return temp;
- }
- int main(void)
- {
- /*硬件初始化*/
- Board_Init();
- /*應(yīng)用函數(shù)*/
- Application();
- /*正常情況下不會執(zhí)行到這一步*/
- return 0;
- }
復(fù)制代碼 |
-
-
AL422b.pdf
2019-6-21 18:09 上傳
點(diǎn)擊文件名下載附件
下載積分: 黑幣 -5
254.28 KB, 下載次數(shù): 4, 下載積分: 黑幣 -5
-
-
CMOS_FIFO電路.pdf
2019-6-21 18:09 上傳
點(diǎn)擊文件名下載附件
下載積分: 黑幣 -5
55.08 KB, 下載次數(shù): 8, 下載積分: 黑幣 -5
-
-
FIFO尺寸圖.pdf
2019-6-21 18:09 上傳
點(diǎn)擊文件名下載附件
下載積分: 黑幣 -5
163.14 KB, 下載次數(shù): 6, 下載積分: 黑幣 -5
-
-
OmniVision_ProductGuide[1].pdf
2019-6-21 18:09 上傳
點(diǎn)擊文件名下載附件
下載積分: 黑幣 -5
674.09 KB, 下載次數(shù): 4, 下載積分: 黑幣 -5
-
-
OV7670_DS_(1_4).pdf
2019-6-21 18:09 上傳
點(diǎn)擊文件名下載附件
下載積分: 黑幣 -5
738.26 KB, 下載次數(shù): 4, 下載積分: 黑幣 -5
-
-
OV7670帶FIFO的CMOS攝像頭使用說明.pdf
2019-6-21 18:09 上傳
點(diǎn)擊文件名下載附件
下載積分: 黑幣 -5
2.75 MB, 下載次數(shù): 8, 下載積分: 黑幣 -5
-
-
OV7670照相模組硬件應(yīng)用指南1.01 OVT.pdf
2019-6-21 18:10 上傳
點(diǎn)擊文件名下載附件
下載積分: 黑幣 -5
892.67 KB, 下載次數(shù): 9, 下載積分: 黑幣 -5
|