int8_t OV2640_Init(uint16_t img_w, uint16_t img_h)
{
uint16_t ov_pid, ov_mid;
OV2640_IDTypeDef OV2640_Camera_ID;
img_width = img_w;
img_height = img_h;
OV2640_GPIO_Init();
OV2640_Reset();
OV2640_ReadID(&OV2640_Camera_ID);
ov_mid = OV2640_Camera_ID.MIDH << 8 | OV2640_Camera_ID.MIDL;
ov_pid = OV2640_Camera_ID.PIDH << 8 | OV2640_Camera_ID.PIDL;
DBG_RAW("MID: %x", ov_mid);
DBG_RAW("PID: %x", ov_pid);
if (ov_mid != OV2640_MID) return -1;
else if (ov_pid != OV2640_PID) return -2;
OV2640_DMA_Init((uint32_t)dvp_buf0, FSMC_LCD_DATA_ADDR, lcd.width);
OV2640_DVP_Init((uint32_t*)dvp_buf0, (uint32_t*)dvp_buf1, RGB565_COL_NUM, RGB565_ROW_NUM);
return 0;
}
|