![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
ov7670 FIFO data taking program
Dependencies: OV7670 with FIFO ST7735_TFT mbed
Fork of OV7670_Testing by
Diff: ov7670.h
- Revision:
- 1:c98598814170
- Parent:
- 0:aabbf2286bf2
--- a/ov7670.h Tue Mar 27 19:10:18 2012 +0000 +++ b/ov7670.h Sat Mar 31 10:05:59 2012 +0000 @@ -17,20 +17,23 @@ I2C camera ; InterruptIn vsync,href; DigitalOut wen ; - BusIn data ; + //BusIn data ; + PortIn data; DigitalOut rrst,oe,rclk ; volatile int LineCounter ; volatile int LastLines ; volatile bool CaptureReq ; volatile bool Busy ; - volatile bool Done ; - + volatile bool Done ; + OV7670( PinName sda,// Camera I2C port PinName scl,// Camera I2C port PinName vs, // VSYNC PinName hr, // HREF PinName we, // WEN + + /* PinName d7, // D7 PinName d6, // D6 PinName d5, // D5 @@ -39,10 +42,15 @@ PinName d2, // D2 PinName d1, // D1 PinName d0, // D0 + */ + PortName port, // 8bit bus port + int mask, // 0b0000_0M65_4000_0321_L000_0000_0000_0000 = 0x07878000 + PinName rt, // /RRST PinName o, // /OE PinName rc // RCLK - ) : camera(sda,scl),vsync(vs),href(hr),wen(we),data(d0,d1,d2,d3,d4,d5,d6,d7),rrst(rt),oe(o),rclk(rc) + //) : camera(sda,scl),vsync(vs),href(hr),wen(we),data(d0,d1,d2,d3,d4,d5,d6,d7),rrst(rt),oe(o),rclk(rc) + ) : camera(sda,scl),vsync(vs),href(hr),wen(we),data(port,mask),rrst(rt),oe(o),rclk(rc) { camera.stop() ; camera.frequency(OV7670_I2CFREQ) ; @@ -125,8 +133,12 @@ WriteReg(REG_COM11,0x0A) ; WriteReg(REG_TSLB,0x04); WriteReg(REG_COM7,0x04) ; - WriteReg(REG_RGB444, 0x02); - WriteReg(REG_COM15, 0xd0); + + //WriteReg(REG_RGB444, 0x02); + //WriteReg(REG_COM15, 0xd0); + WriteReg(REG_RGB444, 0x00); // Disable RGB 444? + WriteReg(REG_COM15, 0xD0); // Set RGB 565? + WriteReg(REG_HSTART,0x16) ; WriteReg(REG_HSTOP,0x04) ; WriteReg(REG_HREF,0x24) ; @@ -136,6 +148,7 @@ WriteReg(REG_COM10,0x02) ; WriteReg(REG_COM3, 0x04); WriteReg(REG_COM14, 0x1a); + WriteReg(REG_MVFP,0x27) ; WriteReg(0x72, 0x22); WriteReg(0x73, 0xf2); @@ -197,12 +210,20 @@ // Data Read int ReadOneByte(void) { - int result ; - rclk = 1 ; -// wait_us(1) ; - result = data ; - rclk = 0 ; - return result ; + int result; + rclk = 1; + result = data; + + // Shift the bits around to form the byte + int top = result >> 19; // Isolate the top nibble + int middle = result >> 2; // Isolate bits 2 & 3 + result = result & 0x00000003; // Isolate bits 0 & 1 + + result += middle; + result += top; + + rclk = 0; + return result; } // Data Start