求助求助,一个月了还没能解决掉,来帮帮我,具体情况是用的微雪电子的ov2640和正点原子的2.8寸屏抓照片1600*1200分辨率,抓完图之后再显示视频,主要代码是正点原子探索者F407上例程抠下来的,目前有个问题,抓图后再显示会出现屏幕偏移,就是本来的屏幕边缘跑到中间去了,不一定跑到什么位置有时左边有时右边,再次抓图就会恢复,偶尔也不能恢复,要再抓一次才能恢复,
[mw_shl_code=c,true]void photo_task(void *pdata)
{
OS_CPU_SR cpu_sr;
u8 res;
u32 tol_len,bwr;
u16 i;
u8 *pbuf,*pbuff;
err_t err; //′íÎó±êÖ¾
u8 err2;
u8 *pptr[2];
u32 jpgdata_len,jpgdata_len1;
//static u8 cnt_buf[100];
///////////////////////////////DT¸ÄÄú′æéêÇë꧰üoó′|àí1y3ì////////////////////////////
while(1)
{
LCD_WR_REG_cnt=0;
LCD_WR_DATA_cnt=0;
LCD_RD_DATA_cnt=0;
LCD_WriteReg_cnt=0;
LCD_ReadReg_cnt=0;
LCD_WriteRAM_Prepare_cnt=0;
LCD_WriteRAM_cnt=0;
//delay_ms(100);
if(1)
{
OSSemPend(tkpic_flag,0,&err2);
DCMI_Stop();
jpeg_size=12; //JPEGÅÄÕÕ,ĬèÏéèÖÃÎa1600*1200·Ö±æÂê(UXGA)
send_picture_t *send_pic;
do{
u8 i=0;
//OSSchedLock();
jpeg_buf0=gui_memex_malloc(jpeg_dma_bufsize*4); //
jpeg_buf1=gui_memex_malloc(jpeg_dma_bufsize*4); //
jpeg_data_buf=gui_memex_malloc(210*1024); //
jpeg_pack_buf=gui_memex_malloc(215*1024);
send_pic = gui_memin_malloc(sizeof(send_picture_t));
if(!jpeg_buf0||!jpeg_buf1||!jpeg_data_buf||!send_pic||!jpeg_pack_buf)//
{
gui_memin_free(jpeg_pack_buf);
gui_memin_free(send_pic);
gui_memin_free(jpeg_buf0);
gui_memin_free(jpeg_buf1);
gui_memex_free(jpeg_data_buf);
if(i>2){
DCMI_Start();
beep_beep(6, "Photo memory error
");
OSSemPost(command_finished);
}
i++;
}
}while(!jpeg_buf0||!jpeg_buf1||!jpeg_data_buf||!send_pic||!jpeg_pack_buf);
if(jpeg_buf0 && jpeg_buf1 && jpeg_data_buf && send_pic && jpeg_pack_buf )
{
ov2640_mode=OV2640_JPEG_MODE; //
dcmi_rx_callback=jpeg_dcmi_rx_callback;//
DCMI_DMA_Init((u32)jpeg_buf0,(u32)jpeg_buf1,jpeg_dma_bufsize,DMA_MemoryDataSize_Word,DMA_MemoryInc_Enable);//
OV2640_JPEG_Mode(); //
OV2640_ImageWin_Set(0,0,1600,1200);
OV2640_OutSize_Set(camera_jpeg_img_size_tbl[jpeg_size][0],camera_jpeg_img_size_tbl[jpeg_size][1]);//
DCMI_Start(); //
while(jpeg_data_ok!=1); //
jpeg_data_ok=2; //
while(jpeg_data_ok!=1); //
jpeg_data_ok=2; //
while(jpeg_data_ok!=1); //
DCMI_Stop(); //í£Ö1DMA°áÔË
pbuf=(u8*)jpeg_data_buf;
for(i=0;i<jpeg_data_len*4;i++)//0XFF,0XD8
{
if((pbuf
==0XFF)&&(pbuf[i+1]==0XD8))break;
}
if(i==jpeg_data_len*4)res=0XFD;//ûÕòμ½0XFF,0XD8
else//Õòμ½áË
{
//u32 j,j2;
pbuf+=i;//Æ«òÆμ½0XFF,0XD8′|
pbuff = (u8 *)send_pic;
send_pic->len=jpeg_data_len*4+16;
send_pic->protocType = 0x54;
send_pic->send_type = *(u32 *)&pic_flag_buf;
send_pic->pic_size=jpeg_data_len*4;
k[0]=XOR(0,pbuff,16);
k[0]=XOR(k[0],pbuf,jpeg_data_len*4);
Pic_pack_work((u8 *)test_head,4,pbuff,16,pbuf,jpeg_data_len*4,&k[0],4);
counter=5;
beep_beep(0, "Send Photo OK
");
if(bwr!=(jpeg_data_len*4-i)){res=0;
}
}
jpeg_data_len=0;
ov2640_mode=OV2640_RGB565_MODE;//
OV2640_RGB565_Mode(); //
// My_DCMI_Init(); //DCMIÅäÖÃ
//// {
////
//// sprintf(cnt_buf,"%d,%d,%d,%d,%d,%d,%d",
//// LCD_WR_REG_cnt, LCD_WR_DATA_cnt,
//// LCD_RD_DATA_cnt, LCD_WriteReg_cnt,
//// LCD_WriteRAM_Prepare_cnt,
//// LCD_WriteRAM_Prepare_cnt,
//// LCD_WriteRAM_cnt);
////
//// OSMboxPost(UDP_BOX,(void *)cnt_buf);
//// }
OS_ENTER_CRITICAL();
LCD_Init2(); //!!!!!!!!!!!!!!!!抓完图之后在这里把LCD再初始化一下并且放在临界区内
DCMI_DMA_Init((u32)&LCD->LCD_RAM,0,1,DMA_MemoryDataSize_HalfWord,DMA_MemoryInc_Disable);//
OV2640_OutSize_Set(lcddev.width,lcddev.height);//
OS_EXIT_CRITICAL();
DCMI_Start();
gui_memin_free(send_pic);
gui_memex_free(jpeg_data_buf);
gui_memex_free(jpeg_pack_buf);
gui_memex_free(jpeg_buf0);
gui_memex_free(jpeg_buf1);
OSSemPost(command_finished); //±ØDëμèí¼Æ¬ÅÄíê2ÅÄüêí·ÅDÅoÅá¿
}
}
}
}[/mw_shl_code]
一周热门 更多>