高级会员
- 积分
- 613
- 金钱
- 613
- 注册时间
- 2014-10-26
- 在线时间
- 32 小时
|
5金钱
最近在研究OV7670+24L01的图像传输,搞了好多天了,现在分模块一步步来<br />
现在单独调24l01发现 数据发不出去,返回max 大神们帮看看代码<br />
板子是 mini32 v3.0<br />
备注的请跳过是OV7670的,已经屏蔽掉他们了 但24L01还是不正常~
<div style="background-color:#E8E8E8;">
[mw_shl_code=c,true]#include "sys.h"
#include "usart.h"
#include "delay.h"
#include "led.h"
#include "lcd.h"
#include "ov7670.h"
#include "exti.h"
#include "timer.h"
#include "24l01.h"
#include "spi.h"
//ALIENTEK Mini STM32??·?°??©?????é9
//?????·???é
//?????§????www.openedv.com
//?????????í??×?????????????
extern u8 ov_sta; //??exit.c?????¨??
extern u8 ov_frame; //??timer.c?????¨??
//?ü??LCD????
void camera_refresh(void)
{
u16 j , i;
u16 color;
u8 h_txbuf[31],l_txbuf[31];
u8 color_l,color_h;
if(ov_sta==2)
{
LCD_Scan_Dir(U2D_L2R); //????????,??×ó????
LCD_SetCursor(0x00,0x0000); //?è????±ê????
LCD_WriteRAM_Prepare(); //????????GRAM
OV7670_CS=0;
OV7670_RRST=0; //??????????????
OV7670_RCK=0;
OV7670_RCK=1;
OV7670_RCK=0;
OV7670_RRST=1; //???????????á??
OV7670_RCK=1;
for(j=0;j<2400;j++)//????????
{
for(i=0;i<32;i++)
{
GPIOB->CRL=0X88888888;
OV7670_RCK=0;
color_h=GPIOB->IDR&0Xff; //????×???????
h_txbuf=color_h;
OV7670_RCK=1;
OV7670_RCK=0;
color_l=GPIOB->IDR&0Xff; //????×???????
l_txbuf=color_l;
OV7670_RCK=1;
color=color_h&0xff;
color<<=8; //????
color|=color_l&0xff;
GPIOB->CRL=0X33333333;
LCD_WR_DATA(color); //????
}
while(NRF24L01_TxPacket(h_txbuf)!=TX_OK);
while(NRF24L01_TxPacket(l_txbuf)!=TX_OK); ///????·????ê????
}
OV7670_CS=1;
OV7670_RCK=0;
OV7670_RCK=1;
EXTI->R=1<<15; //????LINE8????????±ê????
ov_sta=0; //??????????????
ov_frame++;
LCD_Scan_Dir(DFT_SCAN_DIR); //?????????¨?è·??ò
}
//
// GPIOB->CRL=0X88888888;
// OV7670_RCK=0;
// color=OV7670_DATA; //?????? #define OV7670_DATA GPIOB->IDR&0x00FF
// h_txbuf[31]=i;
// printf("\r\n %d\r\n",h_txbuf);
//
// OV7670_RCK=1;
// color<<=8;
//
// OV7670_RCK=0;
// color|=OV7670_DATA; //??????
// // l_txbuf[31]=(u8)(color >>8);
// OV7670_RCK=1;
// GPIOB->CRL=0X33333333;
// LCD_WR_DATA(color);
// }
//
// while(NRF24L01_TxPacket(h_txbuf)!=TX_OK);
//// while(NRF24L01_TxPacket(l_txbuf)!=TX_OK); ///????·????ê????
// }
//
//
//
// OV7670_CS=1;
// OV7670_RCK=0;
// OV7670_RCK=1;
// EXTI->R=1<<15; //????LINE8????????±ê????
// ov_sta=0; //??????????????
// ov_frame++;
// LCD_Scan_Dir(DFT_SCAN_DIR); //?????????¨?è·??ò
// }
}
int main(void)
{
u8 key,mode;
u16 t=0;
u8 tmp_buf[32];
u8 i;
Stm32_Clock_Init(9); //?????±???è??
uart_init(9600); //?®??????????9600
delay_init(); //???±??????
NRF24L01_Init(); //??????NRF24L01
//OV7670_Init();
LED_Init(); //????????LED??????????????
LCD_Init(); //??????LCD
if(lcddev.id==0X6804||lcddev.id==0X5310||lcddev.id==0X5510) //?????è??????·?±?????320*240.???§??3.5???ó??
{
lcddev.width=240;
lcddev.height=320;
}
POINT_COLOR=RED;//?è??×??????ì??
LCD_ShowString(60,50,200,200,16,"Mini STM32");
LCD_ShowString(60,70,200,200,16,"OV7670 TEST");
LCD_ShowString(60,90,200,200,16,"ATOM@ALIENTEK");
LCD_ShowString(60,110,200,200,16,"2014/3/27");
LCD_ShowString(60,130,200,200,16,"Use USMART To Set!");
LCD_ShowString(60,150,200,200,16,"OV7670 Init...");
// while(OV7670_Init())//??????OV7670
// {
// LCD_ShowString(60,150,200,200,16,"OV7670 Error!!");
// delay_ms(200);
// LCD_Fill(60,150,239,166,WHITE);
// delay_ms(200);
// }
// LCD_ShowString(60,150,200,200,16,"OV7670 Init OK");
LCD_ShowString(60,180,200,200,16,"nrf24l01 Init...");
while(NRF24L01_Check()) //?ì?éNRF24L01??·?????.
{
LCD_ShowString(60,180,200,16,16,"NRF24L01 Error");
delay_ms(200);
LCD_Fill(60,180,239,130+16,WHITE);
delay_ms(200);
}
LCD_ShowString(60,180,200,16,16,"NRF24L01 OK ");
delay_ms(1500);
//TIM3_Int_Init(10000,7199); //TIM3,10Khz????????,1????????
//EXTI15_Init(); //?????¨?±?÷????
// OV7670_Window_Set(10,174,240,320); //?è???°??
// OV7670_CS=0;
NRF24L01_TX_Mode();//·???????
LCD_ShowString(60,180,200,16,16,"WAIT TX... ");
while(1)
{
if(NRF24L01_TxPacket(tmp_buf)==TX_OK)
{
LCD_ShowString(60,170,239,32,16,"Sended DATA:");
LCD_ShowString(0,190,239,32,16,tmp_buf);
key=mode;
for(t=0;t<32;t++)
{
key++;
if(key>('~'))key=' ';
tmp_buf[t]=key;
}
mode++;
if(mode>'~')mode=' ';
tmp_buf[31]=0;//?????á??·?
LED0=~LED0;
delay_ms(500);
}
if(NRF24L01_TxPacket(tmp_buf)==MAX_TX)
{
LCD_ShowString(60,170,239,32,16,"MAX :");
}
else if(NRF24L01_TxPacket(tmp_buf)==MAX_TX)
{
LCD_ShowString(60,170,239,32,16,"MAX :");
}
else
{
LCD_ShowString(60,170,239,32,16,"FAIL :");
}
// camera_refresh(); //?ü??????
// if(i!=ov_frame) //DS0????.
// {
// i=ov_frame;
// LED0=!LED0;
// }
//
LED1=~LED1;
delay_ms(1000);
}
}
[/mw_shl_code]
</div>
<br /> |
|