bx-cam

Dependencies:   mbed-rtos mbed

Fork of rtos_basic by mbed official

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             
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                       
00028            PinName d7, // D7
00029         PinName d6, // D6
00030         PinName d5, // D5
00031         PinName d4, // D4
00032         PinName d3, // D3
00033         PinName d2, // D2
00034         PinName d1, // D1
00035         PinName d0, // D0     // 0b0000_0M65_4000_0321_L000_0000_0000_0000 = 0x07878000
00036             
00037             PinName rt,     // /RRST
00038             PinName o,      // /OE
00039             PinName rc      // RCLK      
00040             );
00041         
00042         ~OV7670();
00043         
00044         void CaptureNext(void);              // capture request
00045         bool CaptureDone(void);              // capture done? (with clear)
00046         void WriteReg(int addr,int data);    // write to camera
00047         int ReadReg(int addr);               // read from camera
00048         void Reset(void);                    // reset reg camera
00049         int Init(char c, int n);             // Old init reg
00050         int Init(char *format, int n);       // init reg    
00051         void VsyncHandler(void);             // New vsync handler
00052         void HrefHandler(void);              // href handler
00053         int ReadOnebyte(void);               // Data Read
00054         void ReadStart(void);                // Data Start
00055         void ReadStop(void);                 // Data Stop
00056        
00057         void InitQQVGA(void);
00058     private:
00059         I2C _i2c;
00060         InterruptIn vsync,href;
00061         
00062         DigitalOut wen;
00063          BusIn data ;
00064         DigitalOut rrst,oe,rclk;
00065         volatile int LineCounter;
00066         volatile int LastLines;
00067         volatile bool CaptureReq;
00068         volatile bool Busy;
00069         volatile bool Done; 
00070         char *format_temp;
00071 };