首先我拿到了sensor_id应用程序的源码,我要在上面添加获取ov2685 的 sensor id的代码.
利用find . -name get_sensor_id找到该代码编译之后生成的a.out文件,这个a.out文件也就是get_sensor_id,它的代码如下:
./project/gplus/sampleCode/rootfs/sbin/get_sensor_id(这个是find命令找到这个a.out的路径)
从这段代码看,我们需要有ov2685的驱动作为参考,知道这个sensor的I2C的地址,然后其余的步骤配置就和其它的sensor是一样的啦!
//yangyx -------> 2016.4.20 case 6 : //ov2685 sensor { DEBUG("ov2685\n"); attr.slaveAddr = 0x78; //ov2685 sensor ID attr.clkRate = 0x64; //不用改 system("devmem 0x93007084 32 0");//scuaCsiClkCfg 不用改 usleep(1000); if(IO_Write_Value(0, reset_pin, 0) != STATUS_OK) //set_sensor_reset perror("error set_sensor_reset\n"); usleep(1000); if(IO_Write_Value(0, 12, 0) != STATUS_OK) //set_sensor_power perror("error set_sensor_power\n"); usleep(10000); //power on if(IO_Write_Value(0, 12, 1) != STATUS_OK) //set_sensor_power perror("error set_sensor_power\n"); usleep(10000); if(IO_Write_Value(0, 30, 0) != STATUS_OK) //set_sensor_standby perror("error set_sensor_standby\n"); system("devmem 0x9300703c 32 0x04003004");//scuaUsbPhyCfg system("devmem 0x93007084 32 0");//scuaCsiClkCfg system("devmem 0x93007084 32 0x00010103");//scuaCsiClkCfg usleep(2000); //------------------------------------------------- if(IO_Write_Value(0, reset_pin, 1) != STATUS_OK) //set_sensor_reset perror("error set_sensor_reset\n"); usleep(20000); //不用改 ret = ioctl(fd, I2C_BUS_ATTR_SET, &attr); if(ret < 0) { perror("ioctl set i2c arg\n"); continue; } //------------------------------------------- sensor_info.write_data[0] = 0x30; sensor_info.write_data[1] = 0x0a; sensor_info.write_size = 2; sensor_info.read_size = 2; ret = ioctl(fd, I2C_BUS_WRITE_READ, &sensor_info); if(ret < 0) { perror("ioctl set i2c arg\n"); continue; } readdevice = (sensor_info.read_data[0] << 8) + sensor_info.read_data[1]; if( readdevice == 0x2656) { DEBUG("I2C_BUS_WRITE_READ data = 0x%02x\n", readdevice); i = MAX_DEVICE + 1; deviceno = 2; } else { printf("Error I2C_BUS_WRITE_READ data = 0x%02x\n", readdevice); } break; }