capstone_finish

Dependencies:   BufferedSerial motor_sn7544

Committer:
kangmingyo
Date:
Mon Aug 12 07:12:38 2019 +0000
Revision:
2:e98408458d2b
Parent:
1:509676f3be32
Child:
3:2a3664dc6634
al422b;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mio 0:f3f80a0695ff 1 //
mio 0:f3f80a0695ff 2 // OV7670 + FIFO AL422B camera board test
mio 0:f3f80a0695ff 3 //
mio 0:f3f80a0695ff 4 #include "mbed.h"
mio 0:f3f80a0695ff 5 #include "ov7670.h"
kangmingyo 2:e98408458d2b 6
kangmingyo 2:e98408458d2b 7
mio 0:f3f80a0695ff 8
mio 0:f3f80a0695ff 9 OV7670 camera(
kangmingyo 2:e98408458d2b 10 D14,D15, // SDA,SCL(I2C / SCCB)
kangmingyo 2:e98408458d2b 11 D9,D14,D11, // VSYNC,HREF,WEN(FIFO)
mio 0:f3f80a0695ff 12 //p18,p17,p16,p15,p11,p12,p14,p13, // D7-D0
kangmingyo 2:e98408458d2b 13 PortB,0xFF,
kangmingyo 2:e98408458d2b 14 D13,D12,D6) ; // RRST,OE,RCLK
mio 0:f3f80a0695ff 15
kangmingyo 2:e98408458d2b 16 Serial pc(USBTX,USBRX,115200) ;
mio 0:f3f80a0695ff 17 Timer t;
mio 0:f3f80a0695ff 18
kangmingyo 2:e98408458d2b 19 //#undef QQVGA
kangmingyo 2:e98408458d2b 20 #define QQVGA
mio 1:509676f3be32 21
mio 0:f3f80a0695ff 22 #ifdef QQVGA
mio 0:f3f80a0695ff 23 # define SIZEX (160)
mio 0:f3f80a0695ff 24 # define SIZEY (120)
mio 0:f3f80a0695ff 25 #else
mio 0:f3f80a0695ff 26 # define SIZEX (320)
mio 0:f3f80a0695ff 27 # define SIZEY (240)
mio 0:f3f80a0695ff 28 #endif
mio 0:f3f80a0695ff 29
kangmingyo 2:e98408458d2b 30 uint16_t fdata[SIZEX*SIZEY];
kangmingyo 2:e98408458d2b 31
mio 0:f3f80a0695ff 32 int main() {
mio 0:f3f80a0695ff 33 int last ;
mio 0:f3f80a0695ff 34 pc.baud(115200) ;
mio 0:f3f80a0695ff 35 camera.Reset() ;
mio 0:f3f80a0695ff 36
mio 0:f3f80a0695ff 37 #ifdef QQVGA
kangmingyo 2:e98408458d2b 38 // camera.InitQQVGA565(true,false) ;
kangmingyo 2:e98408458d2b 39 camera.InitQVGAYUV(true,false);
kangmingyo 2:e98408458d2b 40
kangmingyo 2:e98408458d2b 41 #else
kangmingyo 2:e98408458d2b 42 //camera.InitQVGA565(true,false) ;
mio 0:f3f80a0695ff 43 #endif
mio 0:f3f80a0695ff 44
mio 0:f3f80a0695ff 45 // CAPTURE and SEND LOOP
mio 0:f3f80a0695ff 46 t.start();
mio 0:f3f80a0695ff 47 last = t.read_ms() ;
kangmingyo 2:e98408458d2b 48 // while(1)
kangmingyo 2:e98408458d2b 49 // {
mio 0:f3f80a0695ff 50 camera.CaptureNext() ;
mio 0:f3f80a0695ff 51 while(camera.CaptureDone() == false) ;
mio 0:f3f80a0695ff 52 printf("Caputure %d(ms)\r\n", t.read_ms() - last) ;
mio 0:f3f80a0695ff 53 last = t.read_ms() ;
mio 0:f3f80a0695ff 54 camera.ReadStart() ;
kangmingyo 2:e98408458d2b 55 // lcd.Lcd_SetCursor(0,0);
kangmingyo 2:e98408458d2b 56 // lcd.Lcd_WR_Start();
kangmingyo 2:e98408458d2b 57 // lcd.rsout(1) ;
kangmingyo 2:e98408458d2b 58 for (int y = 0; y < SIZEY*SIZEX;y++) {
kangmingyo 2:e98408458d2b 59 // pc.printf("\r\n");
kangmingyo 2:e98408458d2b 60 // lcd.Lcd_SetCursor(y,0);
kangmingyo 2:e98408458d2b 61
kangmingyo 2:e98408458d2b 62 // lcd.Lcd_WR_Start();
mio 0:f3f80a0695ff 63 for (int x = 0;x < SIZEX;x++) {
kangmingyo 2:e98408458d2b 64 // pc.printf("%x ",camera.ReadOneWord());
kangmingyo 2:e98408458d2b 65 // lcd.csout(0) ;
kangmingyo 2:e98408458d2b 66 // lcd.DataToWrite(camera.ReadOneWord());
kangmingyo 2:e98408458d2b 67 // lcd.csout(1) ;
kangmingyo 2:e98408458d2b 68 fdata[SIZEX*SIZEY]=camera.ReadOneWord();
mio 0:f3f80a0695ff 69 }
mio 0:f3f80a0695ff 70 }
kangmingyo 2:e98408458d2b 71
mio 0:f3f80a0695ff 72 camera.ReadStop() ;
kangmingyo 2:e98408458d2b 73 printf("%d\n", sizeof(fdata));
mio 0:f3f80a0695ff 74 printf("FIFO Read & Lcd Out %d(ms)\r\n", t.read_ms() - last) ;
mio 0:f3f80a0695ff 75 last = t.read_ms() ;
kangmingyo 2:e98408458d2b 76 // }
mio 0:f3f80a0695ff 77 }