kevin eccli
/
AcquisitionCamera2
Test Acquis Cam2D
main.cpp
- Committer:
- singularity
- Date:
- 2015-02-07
- Revision:
- 0:05d03cca2089
File content as of revision 0:05d03cca2089:
#include "mbed.h" #include "ov7670.h" #define I2C_D D15 #define I2C_CLK D14 #define VSYNC PTD5 #define HREF PTD6 #define WEN PTD7 #define RRST PTC6 #define OE PTC3 #define RCLK PTA4 #define D0 PTC5 #define D1 PTC10 #define D2 PTC7 #define D3 PTC9 #define D4 PTC8 #define D5 PTA12 #define D6 PTA13 #define D7 PTA5 #define SIZEX (160) #define SIZEY (120) DigitalOut led_red(LED_RED); OV7670 camera(I2C_D,I2C_CLK,VSYNC,HREF,WEN,D0,D1,D2,D3,D4,D5,D6,D7,RRST,OE,RCLK); Serial pc(USBTX,USBRX); int main() { int i ; pc.printf("Camera resetting..\r\n") ; camera.Reset() ; pc.printf("Before Init...\r\n") ; pc.printf("Lecture Registres...\r\n") ; pc.printf("AD : +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +A +B +C +D +E +F") ; for (i=0;i<OV7670_REGMAX;i++) { int data ; data = camera.ReadReg(i) ; // READ REG if ((i & 0x0F) == 0) { pc.printf("\r\n%02X : ",i) ; } pc.printf("%02X ",data) ; } pc.printf("\r\n") ; camera.InitQQVGA() ; pc.printf("After Init...\r\n") ; pc.printf("AD : +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +A +B +C +D +E +F") ; for (i=0;i<OV7670_REGMAX;i++) { int data ; data = camera.ReadReg(i) ; // READ REG if ((i & 0x0F) == 0) { pc.printf("\r\n%02X : ",i) ; } pc.printf("%02X ",data) ; } pc.printf("\r\n") ; // CAPTURE and SEND LOOP while(1) { pc.printf("Hit Any Key to send RGBx160x120 Capture Data.\r\n") ; while(!pc.readable()) ; pc.getc() ; camera.CaptureNext() ; while(camera.CaptureDone() == false) ; pc.printf("*\r\n") ; camera.ReadStart() ; i = 0 ; for (int y = 0;y < SIZEY;y++) { int r,g,b,d1,d2 ; for (int x = 0;x < SIZEX;x++) { d1 = camera.ReadOneByte() ; // upper nibble is XXX , lower nibble is B d2 = camera.ReadOneByte() ; // upper nibble is G , lower nibble is R b = (d1 & 0x0F) ; g = (d2 & 0xF0) >> 4 ; r = (d2 & 0x0F) ; pc.printf ("%1X%1X%1X",r,g,b) ; } pc.printf("\r\n") ; } camera.ReadStop() ; } }