This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

OV7670 Camera Driver

Hi, 

I'm having some trouble getting a device pointer for the OV7670 Camera. I've ported the OV7725 driver. It appears as if the program exits the driver before setting the I2C address:

drv_data->i2c = device_get_binding(DT_INST_BUS_LABEL(0));
printk("HERE!!!!!!!!!!!!!!!!!!!\n");
if (drv_data->i2c == NULL) {
LOG_ERR("Failed to get pointer to %s device!",
DT_INST_LABEL(0));
return -EINVAL;
}
printk("HERE!!!!!!!!!!!!!!!!!!!\n");
drv_data->i2c_addr = DT_INST_REG_ADDR(0);

I'm pretty sure I'm doing something but not entirely sure where.

Parents
  • I havce a very basic application where I'm trying to get a device pointer to the camera using device_get_binding() but it's not working. When I try to print out DT_INST_REG_ADDR(0) I'm getting this error missinglog_strdup(). Does that mean it isn't picking the I2C address from my board overay?

  • Yes it seems that your I2C address that you mentioned in the device tree does not seem to be visible to your project. Check if those settings in the board overlay are shielded by some other config settings that you missed to enable.

Reply Children
  • Oh I forgot I was using CONFIG_I2C=y instead of CONFIG_I2C_0=y to debug. The runtime error that the main.c is returning dev=null after  device_get_binding("ov7670")

    const struct device *dev = device_get_binding("ov7670");
    if (dev == NULL) {
    printk("Error: Could not get ov7670 device binding\n");
    return 0;
    }

    This is the camera init function

    static int ov7670_init_0(const struct device *dev)
    {
    	struct ov7670_data *drv_data = dev->data;
    
        
    	drv_data->i2c = device_get_binding(DT_INST_BUS_LABEL(0));
        printk("HERE!!!!!!! %s !!!!!!!!!!!!\n",DT_INST_REG_ADDR(0));
    	if (drv_data->i2c == NULL) {
    		LOG_ERR("Failed to get pointer to %s device!",
    			DT_INST_LABEL(0));
    		return -EINVAL;
    	}
        printk("HERE!!!!!!!!!!!!!!!!!!!\n");
        drv_data->i2c_addr = device_get_binding(DT_INST_REG_ADDR(0));
    
        
    	return ov7670_init(dev);
    	
    }

  • Can you please also attach your dts file so that i get a better picture in how your declared your instances.

  • sure

     &i2c0 {
    	compatible = "nordic,nrf-twim";
    	status = "okay";
    	ov7670@43 {
    		compatible = "ovti,ov7670";
    		label = "ov7670";
    		reg = <0x43>;
    		data-gpios = <&gpio0 0 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>,
    			  <&gpio0 1 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>,
    			  <&gpio0 5 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>,
    			  <&gpio0 6 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>,
    			  <&gpio0 7 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>,
    			  <&gpio0 8 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>,
    			  <&gpio0 9 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>,
    			  <&gpio0 10 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>;       
    
    		vsync-gpios = < &gpio0 15 (GPIO_PULL_UP | GPIO_ACTIVE_LOW) >;
    
       		hsync-gpios = < &gpio0 14 (GPIO_PULL_UP | GPIO_ACTIVE_LOW) >;
    
       		pclk-gpios = < &gpio0 13 (GPIO_PULL_UP | GPIO_ACTIVE_LOW) >;
    
       		xclk-gpios = < &gpio0 12 (GPIO_PULL_UP | GPIO_ACTIVE_LOW) >;
    	};
    };
    description: OV7670 CMOS video sensor
    
    compatible: "ovti,ov7670"
    
    properties:
        reset-gpios:
          type: phandle-array
          required: false
          description: |
            The RESETn pin is asserted to disable the sensor causing a hard
            reset.  The sensor receives this as an active-low signal.
        
        data-gpios:
          type: phandle-array
          required: false
        
        vsync-gpios:
          type: phandle-array
          required: false
        
        hsync-gpios:
          type: phandle-array
          required: false
        
        pclk-gpios:
          type: phandle-array
          required: false
        
        xclk-gpios:
          type: phandle-array
          required: false
    
    include: i2c-device.yaml

  • I am sorry, Due to start of holiday season and my travel  I could not respond to you meanwhile, I will try to respond to you by Friday.

    Thanks for your patience

Related