初级会员
- 积分
- 90
- 金钱
- 90
- 注册时间
- 2014-3-12
- 在线时间
- 8 小时
|
楼主 |
发表于 2014-5-13 12:31:15
|
显示全部楼层
这是发送端程序:<br />
#include "sys.h"<br />
#include "usart.h" <br />
#include "delay.h" <br />
#include "led.h" <br />
#include "key.h"<br />
#include "exti.h"<br />
#include "timer.h"<br />
#include "lcd.h" <br />
#include "ov7670.h"<br />
#include "usmart.h" <br />
#include "24l01.h" <br />
<br />
extern u8 ov_sta; //在exit.c里面定义<br />
extern u8 ov_frame; //在timer.c里面定义 <br />
<br />
int main(void)<br />
{<br />
<br />
u32 j;<br />
u16 color;<br />
u8 t=0; <br />
u8 tmp_buf[33];<br />
<br />
Stm32_Clock_Init(9); //系统时钟设置<br />
uart_init(72,9600); //串口初始化为9600<br />
delay_init(72); //延时初始化 <br />
LED_Init(); //初始化与LED连接的硬件接口<br />
<br />
OV7670_Init(); <br />
LCD_Init(); <br />
NRF24L01_Init();<br />
<br />
if(lcddev.id==0X6804) //强制设置屏幕分辨率为320*240.以支持3.5寸大屏<br />
{<br />
lcddev.width=240;<br />
lcddev.height=320; <br />
}<br />
usmart_dev.init(72); //初始化USMART? <br />
POINT_COLOR=RED;//设置字体为红色<br />
while(NRF24L01_Check())//检测不到24L01 return:1 ,检测到24L01 return:0<br />
{<br />
LCD_ShowString(60,70,200,200,16,"24L01 Error!!!");<br />
delay_ms(500);<br />
LCD_ShowString(60,70,200,200,16,"lease Check!!!");<br />
delay_ms(500);<br />
LED0=!LED0;//DS0闪烁<br />
}<br />
LCD_ShowString(60,70,200,200,16,"24L01 TX_Mode OK!");<br />
<br />
while(OV7670_Init())//初始化OV7670<br />
{<br />
LCD_ShowString(60,90,200,200,16,"OV7670 Error!!!");<br />
delay_ms(500);<br />
LCD_ShowString(60,90,200,200,16,"lease Check!!!");<br />
delay_ms(500);<br />
LED0=!LED0;//DS0闪烁<br />
}<br />
LCD_ShowString(60,90,200,200,16,"OV7670 Init OK!");<br />
<br />
Timerx_Init(10000,7199); //TIM3,10Khz计数频率,1秒钟中断 <br />
EXTI15_Init(); //使能定时器捕获<br />
OV7670_Window_Set(10,174,240,320); //设置窗口<br />
<br />
while(1)<br />
{ <br />
if(ov_sta==2) //写入FIFO <br />
{<br />
LED0=0; <br />
LCD_Scan_Dir(U2D_L2R); //从上到下,从左到右<br />
LCD_SetCursor(0x00,0x0000); //设置光标位置 <br />
LCD_WriteRAM_Prepare(); //开始写入GRAM<br />
<br />
OV7670_CS=0; <br />
OV7670_RRST=0; //开始复位读指针 <br />
OV7670_RCK=0;<br />
OV7670_RCK=1;<br />
OV7670_RCK=0;<br />
OV7670_RRST=1; //复位读指针结束 <br />
OV7670_RCK=1;<br />
<br />
TX_Mode();<br />
while(NRF24L01_TxPacket(tmp_buf)!=TX_OK);<br />
for(j=0;j<76800;j++) //320*240=76800个像素点 ,每个像素点16位数据<br />
{<br />
LED1=0; <br />
GPIOB->CRL=0X88888888; <br />
OV7670_RCK=0; <br />
color=OV7670_DATA; //读数据 <br />
OV7670_RCK=1;<br />
tmp_buf[t]=color;<br />
t++;<br />
color<<=8; <br />
OV7670_RCK=0;<br />
color|=OV7670_DATA; //读数据 <br />
OV7670_RCK=1;<br />
tmp_buf[t]=color; <br />
t++;<br />
GPIOB->CRL=0X33333333; <br />
LCD_WR_DATA(color); //显示一个像素点的颜色<br />
<br />
if(t==32)//达到32Byte=32*8 bite,最大发送量<br />
{<br />
t=0;<br />
while(NRF24L01_TxPacket(tmp_buf)!=TX_OK) ;<br />
}; <br />
<br />
OV7670_CS=1; <br />
OV7670_RCK=0; <br />
OV7670_RCK=1; <br />
EXTI->R=1<<15; //清除LINE8上的中断标志位<br />
ov_sta=0; //开始下一次采集<br />
ov_frame++;<br />
} <br />
}<br />
}<br />
}<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br /> |
|