/*! * @brief 鹰眼ov7725寄存器 初始化 * @return 初始化结果(0表示失败,1表示成功) * @since v5.0 */ uint8 ov7725_eagle_reg_init(void) { uint16 i = 0; uint8 Sensor_IDCode = 0; SCCB_GPIO_init(); //OV7725_Delay_ms(50); if( 0 == SCCB_WriteByte ( OV7725_COM7, 0x80 ) ) /*复位sensor */ { DEBUG_PRINTF("\n警告:SCCB写数据错误"); return 0 ; } OV7725_EAGLE_Delay_ms(50); if( 0 == SCCB_ReadByte( &Sensor_IDCode, 1, OV7725_VER ) ) /* 读取sensor ID号*/ { DEBUG_PRINTF("\n警告:读取ID失败"); return 0; } DEBUG_PRINTF("\nGet ID success,SENSOR ID is 0x%x", Sensor_IDCode); DEBUG_PRINTF("\nConfig Register Number is %d ", ov7725_eagle_cfgnum); if(Sensor_IDCode == OV7725_ID) { for( i = 0 ; i < ov7725_eagle_cfgnum ; i++ ) { if( 0 == SCCB_WriteByte(ov7725_eagle_reg[i].addr, ov7725_eagle_reg[i].val) ) { DEBUG_PRINTF("\n警告:写寄存器0x%x失败", ov7725_eagle_reg[i].addr); return 0; } if(ov7725_eagle_reg[i].addr == OV7725_BRIGHT) { if( 0 == SCCB_WriteByte(ov7725_eagle_reg[i].addr, BaiPingHeng) ) { DEBUG_PRINTF("\n警告:写寄存器0x%x失败", ov7725_eagle_reg[i].addr); return 0; } } if(ov7725_eagle_reg[i].addr == OV7725_CNST) { if( 0 == SCCB_WriteByte(ov7725_eagle_reg[i].addr, DuiBiDu) ) { DEBUG_PRINTF("\n警告:写寄存器0x%x失败", ov7725_eagle_reg[i].addr); return 0; } extern uint16 DuiBiDu; } } } else { return 0; } DEBUG_PRINTF("\nOV7725 Register Config Success!"); return 1; }
/************************************************ * 函数名:Ov7725_Init * 描述 :Sensor初始化 * 输入 :无 * 输出 :返回1成功,返回0失败 * 注意 :无 ************************************************/ u8 Ov7725_Init(void) { u16 i = 0; u8 Sensor_IDCode = 0; SCCB_GPIO_init(); DEBUG_OUT("\r\n>>>>>>Kinetis OV7725 Demo<<<<<<\r\n"); DEBUG_OUT("OV7725 Register Config Start!"); OV7725_Delay_ms(50); while( 0 == SCCB_WriteByte ( 0x12, 0x80 ) ) /*复位sensor */ { i++; if(i == 20) { DEBUG_OUT("警告:SCCB写数据错误"); //OV7725_Delay_ms(50); return 0 ; } } OV7725_Delay_ms(50); if( 0 == SCCB_ReadByte( &Sensor_IDCode, 1, 0x0b ) ) /* 读取sensor ID号*/ { DEBUG_OUT("警告:读取ID失败"); return 0; } DEBUG_OUT("Get ID success,SENSOR ID is 0x%x", Sensor_IDCode); DEBUG_OUT("Config Register Number is %d ", OV7725_REG_NUM); if(Sensor_IDCode == OV7725_ID) { for( i = 0 ; i < OV7725_REG_NUM ; i++ ) { if( 0 == SCCB_WriteByte(Sensor_Config[i].Address, Sensor_Config[i].Value) ) { DEBUG_OUT("警告:写寄存器0x%x失败", Sensor_Config[i].Address); return 0; } } } else { return 0; } DEBUG_OUT("OV7725 Register Config Success!"); return 1; }
/** * @name Ov7670_Init * @brief 初始化OV7670 * @param None * @return None * @notice */ ErrStatus Ov7670_Init(void) { uint16_t i = 0; uint8_t Sensor_IDCode = 0; /*结构体数组成员数目*/ uint8_t OV7670_REG_NUM = sizeof(Sensor_Config)/sizeof(Sensor_Config[0]); OV7670_DEBUG("ov7670 Register Config Start......\r\n"); if( 0 == SCCB_WriteByte ( 0x12, 0x80 ) ) /*复位sensor */ { OV7670_DEBUG("sccb write data error\r\n"); return ERROR ; } if( 0 == SCCB_ReadByte( &Sensor_IDCode, 1, 0x0b ) ) /* 读取sensor ID号*/ { OV7670_DEBUG("read id faild\r\n"); return ERROR; } OV7670_DEBUG("Sensor ID is 0x%x\r\n", Sensor_IDCode); if(Sensor_IDCode == OV7670_ID) { for( i = 0 ; i < OV7670_REG_NUM ; i++ ) { if( 0 == SCCB_WriteByte(Sensor_Config[i].Address, Sensor_Config[i].Value) ) { OV7670_DEBUG("write reg %x faild\r\n", Sensor_Config[i].Address); return ERROR; } } } else { return ERROR; } OV7670_DEBUG("ov7670 Register Config Success\r\n"); return SUCCESS; }
/************************************************ * 函数名:Sensor_Init * 描述 :Sensor初始化 * 输入 :无 * 输出 :返回1成功,返回0失败 * 注意 :无 ************************************************/ ErrorStatus Ov7725_Init(void) { uint16_t i = 0; uint8_t Sensor_IDCode = 0; //DEBUG("ov7725 Register Config Start......"); if( 0 == SCCB_WriteByte ( 0x12, 0x80 ) ) /*复位sensor */ { //DEBUG("sccb write data error"); return ERROR ; } if( 0 == SCCB_ReadByte( &Sensor_IDCode, 1, 0x0b ) ) /* 读取sensor ID号*/ { //DEBUG("read id faild"); return ERROR; } //DEBUG("Sensor ID is 0x%x", Sensor_IDCode); if(Sensor_IDCode == OV7725_ID) { for( i = 0 ; i < OV7725_REG_NUM ; i++ ) { if( 0 == SCCB_WriteByte(Sensor_Config[i].Address, Sensor_Config[i].Value) ) { //DEBUG("write reg faild", Sensor_Config[i].Address); return ERROR; } } } else { return ERROR; } //DEBUG("ov7725 Register Config Success"); return SUCCESS; }