Exemplo n.º 1
0
/**
  * @brief  Configures all needed resources (I2C, DCMI and DMA) to interface with
  *         the OV9655 camera module
  * @param  None
  * @retval 0x00 Camera module configured correctly 
  *         0xFF Camera module configuration failed
  */
uint8_t DCMI_OV9655Config(void)
{
    uint8_t readvalue;
    char str[8];
    uint8_t opmask=MODE|LEN|OEN_TRI_SEL_MASK;
  /* I2C1 will be used for camera configuration */
  I2C1_Config();  
//  - Read ID and check
    readvalue=DCMI_SingleRandomRead(OV9655_DEVICE_READ_ADDRESS,ID);
    sprintf(str,"ID=%x,",readvalue);
    USART_puts(USART2,str);
    
    
//- Write opform register
    //Mode=0, Len=0, rest default
    tw9910_mask_set(OV9655_DEVICE_WRITE_ADDRESS, OPFORM, opmask, 0x00|OEN_TRI_SEL_ALL_ON);
    
    
//- set resolution(vscale,hscale or vactive,hactive and vdelay hdelay)
      /* OV9655 Camera size setup */    
  DCMI_OV9655_QVGASizeSetup();
    




//- write the hsync vsync pin configuration(output control 0x05)
 DCMI_SingleRandomWrite(OV9655_DEVICE_WRITE_ADDRESS, OUTCTR1, 0x02);//**0x11,0x01,0x10?
 //- write clock
 DCMI_SingleRandomWrite(OV9655_DEVICE_WRITE_ADDRESS, OUTCTR2, 0x00);

//- write vbi control register for invalid bit settings and Hactive enable
tw9910_mask_set(OV9655_DEVICE_WRITE_ADDRESS,VBICNTL,0x18, 0x18);//Enable HA_EN**0,1? and cntl656


//- read and print status registers(Nicely! - normal status, detected format etc.)
    readvalue=DCMI_SingleRandomRead(OV9655_DEVICE_READ_ADDRESS,STATUS1);
    sprintf(str,"St1=%x,",readvalue);
    USART_puts(USART2,str);
    while((DCMI_SingleRandomRead(OV9655_DEVICE_READ_ADDRESS,STATUS1)&~0x10)!=0x68){
    
        
        Delay(10);
    }
    readvalue=DCMI_SingleRandomRead(OV9655_DEVICE_READ_ADDRESS,STATUS1);
    sprintf(str,"St1=%x,",readvalue);
//    USART_puts(USART2,str);
    readvalue=DCMI_SingleRandomRead(OV9655_DEVICE_READ_ADDRESS,STATUS2);
    sprintf(str,"St2=%x,",readvalue);
    USART_puts(USART2,str);
    readvalue=DCMI_SingleRandomRead(OV9655_DEVICE_READ_ADDRESS,SDT);
    sprintf(str,"Sdt=%x\n",readvalue);
    USART_puts(USART2,str);


  /* Configure the DCMI to interface with the OV9655 camera module */
  DCMI_Config();
  
  return (0x00);
}
Exemplo n.º 2
0
/**
  * @brief  Configures all needed resources (I2C, DCMI and DMA) to interface with
  *         the OV9655 camera module
  * @param  None
  * @retval 0x00 Camera module configured correctly 
  *         0xFF Camera module configuration failed
  */
uint8_t DCMI_OV9655Config(void)
{
  /* I2C1 will be used for OV9655 camera configuration */
  I2C1_Config();

  /* Reset and check the presence of the OV9655 camera module */
  if (DCMI_SingleRandomWrite(OV9655_DEVICE_WRITE_ADDRESS,0x12, 0x80))
  {
     return (0xFF);
  }

  /* OV9655 Camera size setup */    
  DCMI_OV9655_QVGASizeSetup();

  /* Set the RGB565 mode */
  DCMI_SingleRandomWrite(OV9655_DEVICE_WRITE_ADDRESS, OV9655_COM7, 0x63);
  DCMI_SingleRandomWrite(OV9655_DEVICE_WRITE_ADDRESS, OV9655_COM15, 0x10);

  /* Invert the HRef signal*/
  DCMI_SingleRandomWrite(OV9655_DEVICE_WRITE_ADDRESS, OV9655_COM10, 0x08);

  /* Configure the DCMI to interface with the OV9655 camera module */
  DCMI_Config();
  
  return (0x00);
}