Sebastian Barrera / ov7670_lib

Dependents:   Project_test Capture_bw_portin Capture_bw_v3 Project_190659132

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers ov7670.h Source File

ov7670.h

00001 //
00002 // OV7670 library
00003 //
00004 
00005 #pragma once 
00006 #include "mbed.h"
00007 #include "ov7670reg.h"
00008 
00009 #define OV7670_WRITE (0x42)
00010 #define OV7670_READ  (0x43)
00011 #define OV7670_WRITEWAIT (20)
00012 #define OV7670_NOACK (0)
00013 #define OV7670_REGMAX (201)
00014 #define OV7670_I2CFREQ (100000) 
00015 
00016 
00017 class OV7670
00018 {
00019     public:
00020         PortIn data;
00021         OV7670(
00022             PinName sda,    // Camera I2C port
00023             PinName scl,    // Camera I2C port
00024             PinName vs,     // VSYNC
00025             PinName hr,     // HREF
00026             PinName we,     // WEN
00027             PortName port,
00028             int mask,
00029             PinName rt,     // /RRST
00030             PinName o,      // /OE
00031             PinName rc      // RCLK      
00032             );
00033         
00034         ~OV7670();
00035         
00036         void CaptureNext(void);              // capture request
00037         bool CaptureDone(void);              // capture done? (with clear)
00038         void WriteReg(int addr,int data);    // write to camera
00039         int ReadReg(int addr);               // read from camera
00040         void Reset(void);                    // reset reg camera
00041         int Init(char c, int n);             // init reg    
00042         void VsyncHandler(void);             // vsync handler
00043         void HrefHandler(void);              // href handler
00044         int ReadOnebyte(void);               // Data Read
00045         void ReadStart(void);                // Data Start
00046         void ReadStop(void);                 // Data Stop
00047        
00048         
00049     private:
00050         I2C _i2c;
00051         InterruptIn vsync,href;
00052         //BusIn data;
00053         
00054         DigitalOut wen;
00055         DigitalOut rrst,oe,rclk;
00056         volatile int LineCounter;
00057         volatile int LastLines;
00058         volatile bool CaptureReq;
00059         volatile bool Busy;
00060         volatile bool Done; 
00061 };