//////////////////////////// //╣д─▄Б║Х┴OV7660╝─┤Ткэ //их╗пБ║1-│╔╣д 0-╩Д░▄ //guanfu_wang unsigned char rd_Sensor_Reg(unsigned char regID, unsigned char *regDat) { //═е╣§л┤▓┘Оэ╔Уо├╝─┤Ткэхпои startSCCB(); if(0==SCCBwriteByte(0x42))//л┤хпои { stopSCCB();//иб╦═SCCB О▄¤▀═Бо╣┤Ф╩С├Ч┴Ь return(0);//┤ь╬зих╗п } delay_us(100); if(0==SCCBwriteByte(regID))//╗§┤ТкэID { stopSCCB();//иб╦═SCCB О▄¤▀═Бо╣┤Ф╩С├Ч┴Ь return(0);//┤ь╬зих╗п } stopSCCB();//иб╦═SCCB О▄¤▀═Бо╣┤Ф╩С├Ч┴Ь delay_us(100); //╔Уо├╝─┤Ткэхпои║зБг▓┼╩КХ┴ startSCCB(); if(0==SCCBwriteByte(0x43))//Х┴хпои { stopSCCB();//иб╦═SCCB О▄¤▀═Бо╣┤Ф╩С├Ч┴Ь return(0);//┤ь╬зих╗п } delay_us(100); *regDat=SCCBreadByte();//их╗пХ┴хйх─ох noAck();//иб╦═NACK├Ч┴Ь stopSCCB();//иб╦═SCCB О▄¤▀═Бо╣┤Ф╩С├Ч┴Ь return(1);//│╔╣дих╗п }
//////////////////////////// //¹¦ÄÜ£º¶ÁOV7660¼Ä´æÆ÷ //·µ»Ø£º1-³É¹¦ 0-ʧ°Ü uchar rdOV7670Reg(uchar regID, uchar *regDat) { //ͨ¹ýд²Ù×÷ÉèÖüĴæÆ÷µØÖ· startSCCB(); if(0==SCCBwriteByte(0x60)) { stopSCCB(); return(0); } //Delay_nUS(100); if(0==SCCBwriteByte(regID)) { stopSCCB(); return(0); } stopSCCB(); //Delay_nUS(100); //ÉèÖüĴæÆ÷µØÖ·ºó£¬²ÅÊǶÁ startSCCB(); if(0==SCCBwriteByte(0x61)) { stopSCCB(); return(0); } //Delay_nUS(100); *regDat=SCCBreadByte(); noAck(); stopSCCB(); return(1); }
//////////////////////////// //¹¦ÄÜ£ºÐ´OV7660¼Ä´æÆ÷ //·µ»Ø£º1-³É¹¦ 0-ʧ°Ü uchar wrOV7670Reg(uchar regID, uchar regDat) { startSCCB(); if(0==SCCBwriteByte(0x60)) { stopSCCB(); return(0); } //Delay_nUS(100); if(0==SCCBwriteByte(regID)) { stopSCCB(); return(0); } //Delay_nUS(100); if(0==SCCBwriteByte(regDat)) { stopSCCB(); return(0); } stopSCCB(); return(1); }
/////////////////////////////////////////////////////////////////////////// //╣д─▄Б║л┤OV7660╝─┤Ткэ //их╗пБ║1-│╔╣д 0-╩Д░▄ //guanfu_wang unsigned char wr_Sensor_Reg(unsigned char regID, unsigned char regDat) { startSCCB();//иб╦═SCCB О▄¤▀┐ф╩╝┤Ф╩С├Ч┴Ь if(0==SCCBwriteByte(0x42))//л┤хпои { stopSCCB();//иб╦═SCCB О▄¤▀═Бо╣┤Ф╩С├Ч┴Ь return(0);//┤ь╬зих╗п } delay_us(100); if(0==SCCBwriteByte(regID))//╗§┤ТкэID { stopSCCB();//иб╦═SCCB О▄¤▀═Бо╣┤Ф╩С├Ч┴Ь return(0);//┤ь╬зих╗п } delay_us(100); if(0==SCCBwriteByte(regDat))//л┤╩§ЙПхй╗§┤Ткэ { stopSCCB();//иб╦═SCCB О▄¤▀═Бо╣┤Ф╩С├Ч┴Ь return(0);//┤ь╬зих╗п } stopSCCB();//иб╦═SCCB О▄¤▀═Бо╣┤Ф╩С├Ч┴Ь return(1);//│╔╣дих╗п }
//////////////////////////// //¹¦ÄÜ£ºÐ´OV7660¼Ä´æÆ÷ //·µ»Ø£º1-³É¹¦ 0-ʧ°Ü uchar wrOV7670Reg(uchar regID, uchar regDat) { startSCCB(); if(0==SCCBwriteByte(0x42)) { stopSCCB(); return(0); } delay_us(100); if(0==SCCBwriteByte(regID)) { stopSCCB(); return(0); } delay_us(100); if(0==SCCBwriteByte(regDat)) { stopSCCB(); return(0); } stopSCCB(); return(1); }
//////////////////////////// //Function:read MTpM031 reg //return: 0=success; 1=fail uchar rdMT9M031Reg(uchar regID_h, uchar regID_l, uchar length, uchar *regDat_h, uchar *regDat_l) { //ͨ¹ýд²Ù×÷ÉèÖüĴæÆ÷µØÖ· startSCCB(); if(SCCBwriteByte(0x20)) { stopSCCB(); return(1); } usleep(DELAY_TIME); if(SCCBwriteByte(regID_h)) { stopSCCB(); return(1); } usleep(DELAY_TIME); if(SCCBwriteByte(regID_l)) { stopSCCB(); return(1); } stopSCCB(); usleep(DELAY_TIME); //ÉèÖüĴæÆ÷µØÖ·ºó£¬²ÅÊǶÁ startSCCB(); if(SCCBwriteByte(0x21)) { stopSCCB(); return(1); } usleep(DELAY_TIME); *regDat_h=SCCBreadByte(); if(length == 2){ usleep(DELAY_TIME); SCCB_Ack(); *regDat_l=SCCBreadByte(); } noAck(); stopSCCB(); return(0); }
//////////////////////////// //Function:write MTpM031 reg //return: 0=success; 1=fail uchar wrMT9M031Reg(uchar regID_h, uchar regID_l, uchar length, uchar regDat_h, uchar regDat_l) { startSCCB(); if(SCCBwriteByte(0x20)) { stopSCCB(); return(1); } usleep(DELAY_TIME); if(SCCBwriteByte(regID_h)) { stopSCCB(); return(1); } usleep(DELAY_TIME); if(SCCBwriteByte(regID_l)) { stopSCCB(); return(1); } usleep(DELAY_TIME); if(SCCBwriteByte(regDat_h)) { stopSCCB(); return(1); } if(length == 2){ usleep(DELAY_TIME); if(SCCBwriteByte(regDat_l)) { stopSCCB(); return(1); } } stopSCCB(); return(0); }