STM32 OV2640 ESP8266图像传输
int main()
{
u16 temp;
u8 *p;
u32 i,k;
u32 count,spi_send_len;
delay_init(168);
uart_init(115200);
printf("usart init.\r\n");
OV2640_Init();
DCMI_Config();
user_SPI_Config();
SPI1_SetSpeed(21);
printf("ov2640 init\r\n");
OV2640_JPEG_Mode();
OV2640_OutSize_Set(1600,1200);
DCMI_DMA_Init((u32)&frame;_data,JPEG_BUFF_LEN,DMA_MemoryDataSize_Word,DMA_MemoryInc_Enable);
DMA_Cmd(DMA2_Stream1,ENABLE);
DCMI_CaptureCmd(ENABLE);
printf("init success.\r\n");
delay_ms(1000);
GPIO_SetBits(GPIOB,GPIO_Pin_12);
while(1)
{
if(jpeg_ok==1)
{
printf("send...\r\n");
count=0;
wr_rdy=1;
p = (u8*)frame_data;
spi_send_len = jpeg_len/8; //byte-->word
spi_send_len+=1;
FRAME_START();//开始传输信号
for(k=0;kDR = (u8)p[count];
count++;
}
k++;
SPI_NSS_DISABLE();
}
else //*可以添加传输失败的超时处理
{
}
}
delay_ms(1); //这里必须有延时,否则ESP8266 GPIO中断比SPI中断先到,导致接收不到最后几个字节
FRAME_END();
printf("count:%d.\r\n",count);
count= 0;
delay_ms(2); //稍作延时,更加稳定的传输
jpeg_ok = 2;
}
}
}
1