capstone_finish
Dependencies: BufferedSerial motor_sn7544
main.cpp@0:f3f80a0695ff, 2012-02-17 (annotated)
- Committer:
- mio
- Date:
- Fri Feb 17 13:07:18 2012 +0000
- Revision:
- 0:f3f80a0695ff
- Child:
- 1:509676f3be32
OV7670+FIFO Cam with SPI QVGA LCD OUTPUT TEST
Who changed what in which revision?
User | Revision | Line number | New 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 "spilcd_qvga.h" |
mio | 0:f3f80a0695ff | 6 | #include "ov7670.h" |
mio | 0:f3f80a0695ff | 7 | #include <stdlib.h> |
mio | 0:f3f80a0695ff | 8 | |
mio | 0:f3f80a0695ff | 9 | // |
mio | 0:f3f80a0695ff | 10 | // SPILCD LG |
mio | 0:f3f80a0695ff | 11 | // |
mio | 0:f3f80a0695ff | 12 | SPILCD_QVGA lcd(p29, p30, p5, p6, p7) ; |
mio | 0:f3f80a0695ff | 13 | OV7670 camera( |
mio | 0:f3f80a0695ff | 14 | p28,p27, // SDA,SCL(I2C / SCCB) |
mio | 0:f3f80a0695ff | 15 | p21,p22,p20, // VSYNC,HREF,WEN(FIFO) |
mio | 0:f3f80a0695ff | 16 | //p18,p17,p16,p15,p11,p12,p14,p13, // D7-D0 |
mio | 0:f3f80a0695ff | 17 | Port0,0x07878000, |
mio | 0:f3f80a0695ff | 18 | p23,p24,p25) ; // RRST,OE,RCLK |
mio | 0:f3f80a0695ff | 19 | |
mio | 0:f3f80a0695ff | 20 | Serial pc(USBTX,USBRX) ; |
mio | 0:f3f80a0695ff | 21 | Timer t; |
mio | 0:f3f80a0695ff | 22 | |
mio | 0:f3f80a0695ff | 23 | #ifdef QQVGA |
mio | 0:f3f80a0695ff | 24 | # define SIZEX (160) |
mio | 0:f3f80a0695ff | 25 | # define SIZEY (120) |
mio | 0:f3f80a0695ff | 26 | #else |
mio | 0:f3f80a0695ff | 27 | # define SIZEX (320) |
mio | 0:f3f80a0695ff | 28 | # define SIZEY (240) |
mio | 0:f3f80a0695ff | 29 | #endif |
mio | 0:f3f80a0695ff | 30 | |
mio | 0:f3f80a0695ff | 31 | int main() { |
mio | 0:f3f80a0695ff | 32 | int last ; |
mio | 0:f3f80a0695ff | 33 | pc.baud(115200) ; |
mio | 0:f3f80a0695ff | 34 | camera.Reset() ; |
mio | 0:f3f80a0695ff | 35 | |
mio | 0:f3f80a0695ff | 36 | #ifdef QQVGA |
mio | 0:f3f80a0695ff | 37 | camera.InitQQVGA565() ; |
mio | 0:f3f80a0695ff | 38 | #else |
mio | 0:f3f80a0695ff | 39 | camera.InitQVGA565() ; |
mio | 0:f3f80a0695ff | 40 | #endif |
mio | 0:f3f80a0695ff | 41 | |
mio | 0:f3f80a0695ff | 42 | // CAPTURE and SEND LOOP |
mio | 0:f3f80a0695ff | 43 | t.start(); |
mio | 0:f3f80a0695ff | 44 | last = t.read_ms() ; |
mio | 0:f3f80a0695ff | 45 | while(1) |
mio | 0:f3f80a0695ff | 46 | { |
mio | 0:f3f80a0695ff | 47 | camera.CaptureNext() ; |
mio | 0:f3f80a0695ff | 48 | while(camera.CaptureDone() == false) ; |
mio | 0:f3f80a0695ff | 49 | printf("Caputure %d(ms)\r\n", t.read_ms() - last) ; |
mio | 0:f3f80a0695ff | 50 | last = t.read_ms() ; |
mio | 0:f3f80a0695ff | 51 | camera.ReadStart() ; |
mio | 0:f3f80a0695ff | 52 | lcd.Lcd_SetCursor(0,0); |
mio | 0:f3f80a0695ff | 53 | lcd.Lcd_WR_Start(); |
mio | 0:f3f80a0695ff | 54 | lcd.rsout(1) ; |
mio | 0:f3f80a0695ff | 55 | for (int y = 0;y < SIZEY;y++) { |
mio | 0:f3f80a0695ff | 56 | lcd.Lcd_SetCursor(y,0); |
mio | 0:f3f80a0695ff | 57 | lcd.Lcd_WR_Start(); |
mio | 0:f3f80a0695ff | 58 | for (int x = 0;x < SIZEX;x++) { |
mio | 0:f3f80a0695ff | 59 | lcd.csout(0) ; |
mio | 0:f3f80a0695ff | 60 | lcd.DataToWrite(camera.ReadOneWord()); |
mio | 0:f3f80a0695ff | 61 | lcd.csout(1) ; |
mio | 0:f3f80a0695ff | 62 | } |
mio | 0:f3f80a0695ff | 63 | } |
mio | 0:f3f80a0695ff | 64 | camera.ReadStop() ; |
mio | 0:f3f80a0695ff | 65 | lcd.rsout(0) ; |
mio | 0:f3f80a0695ff | 66 | printf("FIFO Read & Lcd Out %d(ms)\r\n", t.read_ms() - last) ; |
mio | 0:f3f80a0695ff | 67 | last = t.read_ms() ; |
mio | 0:f3f80a0695ff | 68 | } |
mio | 0:f3f80a0695ff | 69 | } |