[C]
纯文本查看 复制代码
#include "sys.h"#include "usart.h"#include "delay.h"#include "led.h" #include "beep.h" #include "key.h" #include "ex
ti.h" #include "wdg.h" #include "timer.h" #include "tpad.h"#include "oled.h" #include "lcd.h"#include "usmart.h"#include "rtc.h" #include "wkup.h"#include "adc.h" #include "dac.h" #include "dma.h" #include "24cxx.h" #include "flash.h" #include "rs485.h" #include "can.h" #include "touch.h" #include "remote.h" #include "joypad.h"#include "adxl345.h"#include "ds18b20.h"#include "dht11.h"#include "24l01.h"#include "mouse.h"#include "stmflash.h"#include "rda5820.h"#include "audiosel.h"#include "ov7670.h"const u8*LMODE_TBL[5]={"Auto","Sunny","Cloudy","Office","Home"};//5种光照模式 const u8*EFFECTS_TBL[7]={"Normal","Negative","B&W","Redish","Greenish","Bluish","Antique"};//7种特效 extern u8 ov_sta;//在exit.c里面定义 //更新LCD显示void camera_refresh(void){u32 j; u16 color;u32 sendCount=0; u8 tmp_buf[32];NRF24L01_TX_Mode();if(ov_sta==2){LCD_Scan_Dir(U2D_L2R);//从上到下,从左到右 LCD_SetCursor(0x00,0x0000);//设置光标位置 LCD_WriteRAM_Prepare(); //开始写入GRAMOV7670_RRST=0;//开始复位读指针 OV7670_RCK=0;OV7670_RCK=1;OV7670_RCK=0;OV7670_RRST=1;//复位读指针结束 OV7670_RCK=1; for(j=0;j<76800;j++){OV7670_RCK=0;color=GPIOC->IDR&0XFF;//读数据tmp_buf[sendCount++]=GPIOC->IDR&0XFF;OV7670_RCK=1; color<<=8; OV7670_RCK=0;color|=GPIOC->IDR&0XFF;//读数据tmp_buf[sendCount++]=GPIOC->IDR&0XFF;OV7670_RCK=1; LCD->LCD_RAM=color; if(sendCount>=32){sendCount=0;while(NRF24L01_TxPacket(tmp_buf)!=TX_OK);//等待数据发送完毕} } EXTI->PR=1<<8; //清除LINE8上的中断标志位 ov_sta=0;//开始下一次采集NRF24L01_RX_Mode();//配置为接收模式while(NRF24L01_RxPacket(tmp_buf)!=0);//等待同步信号 }} int main(void){u32 count;u8 SendCount=0;u8 tmp_buf[32];
STM32_Clock_Init(9);//系统时钟设置uart_init(72,9600); //串口初始化为9600delay_init(72); //延时初始化 usmart_dev.init(72);//初始化USLCD_Init(); //初始化LCDNRF24L01_Init(); //初始化NRF24L01OV7670_Init(); POINT_COLOR=RED;//设置字体为红色 LCD_ShowString(60,50,200,16,16,"WarShip STM32");LCD_ShowString(60,70,200,16,16,"OV7670 TEST");LCD_ShowString(60,90,200,16,16,"ATOM@ALIENTEK");LCD_ShowString(60,110,200,16,16,"2012/9/14"); LCD_ShowString(60,130,200,16,16,"KEY0:Light Mode");LCD_ShowString(60,150,200,16,16,"KEY1:Saturation");LCD_ShowString(60,170,200,16,16,"KEY2:Brightness");LCD_ShowString(60,190,200,16,16,"KEY_UP:Contrast");LCD_ShowString(60,210,200,16,16,"TPAD:Effects"); LCD_ShowString(60,230,200,16,16,"OV7670 Init..."); while(OV7670_Init())//初始化OV7670{LCD_ShowString(60,230,200,16,16,"OV7670 Error!!");delay_ms(200); LCD_Fill(60,230,239,246,WHITE);delay_ms(200);} LCD_ShowString(60,230,200,16,16,"OV7670 Init OK");delay_ms(1500); LCD_Clear(WHITE);while(NRF24L01_Check())//检查NRF24L01是否在位.{LCD_ShowString(60,130,200,16,16,"NRF24L01 Error");delay_ms(200);LCD_Fill(60,130,239,130+16,WHITE); delay_ms(200);} LCD_ShowString(60,130,200,16,16,"NRF24L01 OK"); EXTI8_Init();//使能定时器捕获帧同步信号OV7670_Window_Set(10,174,240,320);//设置窗口 OV7670_CS=0;NRF24L01_RX_Mode();//配置为接收模式while(NRF24L01_RxPacket(tmp_buf)!=0);//等待同步信号 while(1){camera_refresh();//更新显示} }