/** * @brief Read the OV9655 Camera identity. * @param DeviceAddr: Device address on communication Bus. * @retval the OV9655 ID */ uint16_t ov9655_ReadID(uint16_t DeviceAddr) { /* Initialize I2C */ CAMERA_IO_Init(); /* Get the camera ID */ return (CAMERA_IO_Read(DeviceAddr, OV9655_SENSOR_PIDH)); }
/** * @brief Initializes the OV9655 CAMERA component. * @param DeviceAddr: Device address on communication Bus. * @param resolution: Camera resolution * @retval None */ void ov9655_Init(uint16_t DeviceAddr, uint32_t resolution) { uint32_t index; /* Initialize I2C */ CAMERA_IO_Init(); /* Prepare the camera to be configured by resetting all its registers */ CAMERA_IO_Write(DeviceAddr, OV9655_SENSOR_COM7, 0x80); CAMERA_Delay(200); /* Initialize OV9655 */ switch (resolution) { case CAMERA_R160x120: { for(index=0; index<(sizeof(OV9655_QQVGA)/2); index++) { CAMERA_IO_Write(DeviceAddr, OV9655_QQVGA[index][0], OV9655_QQVGA[index][1]); CAMERA_Delay(2); } break; } case CAMERA_R320x240: { for(index=0; index<(sizeof(OV9655_QVGA)/2); index++) { CAMERA_IO_Write(DeviceAddr, OV9655_QVGA[index][0], OV9655_QVGA[index][1]); CAMERA_Delay(2); } break; } case CAMERA_R480x272: { /* Not supported resolution */ break; } case CAMERA_R640x480: { for(index=0; index<(sizeof(OV9655_VGA)/2); index++) { CAMERA_IO_Write(DeviceAddr, OV9655_VGA[index][0], OV9655_VGA[index][1]); CAMERA_Delay(2); } break; } default: { break; } } }
/** * @brief Read the OV2640 Camera identity. * @param DeviceAddr: Device address on communication Bus. * @retval the OV2640 ID */ uint16_t ov2640_ReadID(uint16_t DeviceAddr) { if(Is_I2C_Initialized == 0) { /* Initialize I2C */ CAMERA_IO_Init(); Is_I2C_Initialized = 1; } /* Prepare the sensor to read the Camera ID */ CAMERA_IO_Write(DeviceAddr, OV2640_DSP_RA_DLMT, 0x01); /* Get the camera ID */ return (CAMERA_IO_Read(DeviceAddr, OV2640_SENSOR_PIDH)); }
/** * @brief Initializes the OV2640 CAMERA component. * @param DeviceAddr: Device address on communication Bus. * @param resolution: the Camera resolution * @retval None */ void ov2640_Init(uint16_t DeviceAddr, uint32_t resolution) { uint32_t index; if(Is_I2C_Initialized == 0) { Is_I2C_Initialized = 1; /* Initialize I2C */ CAMERA_IO_Init(); } /* Prepare the camera to be configured */ CAMERA_IO_Write(DeviceAddr, OV2640_DSP_RA_DLMT, 0x01); CAMERA_IO_Write(DeviceAddr, OV2640_SENSOR_COM7, 0x80); CAMERA_Delay(200); /* Initialize OV2640 */ switch (resolution) { case CAMERA_R160x120: { for(index=0; index<(sizeof(OV2640_QQVGA)/2); index++) { CAMERA_IO_Write(DeviceAddr, OV2640_QQVGA[index][0], OV2640_QQVGA[index][1]); CAMERA_Delay(1); } break; } case CAMERA_R320x240: { for(index=0; index<(sizeof(OV2640_QVGA)/2); index++) { CAMERA_IO_Write(DeviceAddr, OV2640_QVGA[index][0], OV2640_QVGA[index][1]); CAMERA_Delay(1); } break; } case CAMERA_R480x272: { for(index=0; index<(sizeof(OV2640_480x272)/2); index++) { CAMERA_IO_Write(DeviceAddr, OV2640_480x272[index][0], OV2640_480x272[index][1]); CAMERA_Delay(2); } break; } case CAMERA_R640x480: { for(index=0; index<(sizeof(OV2640_VGA)/2); index++) { CAMERA_IO_Write(DeviceAddr, OV2640_VGA[index][0], OV2640_VGA[index][1]); CAMERA_Delay(2); } break; } default: { break; } } }