ov7670 library

Dependents:   Project_test Capture_bw_portin Capture_bw_v3 Project_190659132

Committer:
edodm85
Date:
Sun Mar 10 13:01:45 2013 +0000
Revision:
0:810d59d0b843
Child:
1:d82dbad9c06b
First Version

Who changed what in which revision?

UserRevisionLine numberNew contents of line
edodm85 0:810d59d0b843 1 //
edodm85 0:810d59d0b843 2 // OV7670 library
edodm85 0:810d59d0b843 3 //
edodm85 0:810d59d0b843 4
edodm85 0:810d59d0b843 5 #pragma once
edodm85 0:810d59d0b843 6 #include "mbed.h"
edodm85 0:810d59d0b843 7 #include "ov7670reg.h"
edodm85 0:810d59d0b843 8
edodm85 0:810d59d0b843 9 #define OV7670_WRITE (0x42)
edodm85 0:810d59d0b843 10 #define OV7670_READ (0x43)
edodm85 0:810d59d0b843 11 #define OV7670_WRITEWAIT (20)
edodm85 0:810d59d0b843 12 #define OV7670_NOACK (0)
edodm85 0:810d59d0b843 13 #define OV7670_REGMAX (201)
edodm85 0:810d59d0b843 14 #define OV7670_I2CFREQ (100000)
edodm85 0:810d59d0b843 15
edodm85 0:810d59d0b843 16
edodm85 0:810d59d0b843 17 class OV7670
edodm85 0:810d59d0b843 18 {
edodm85 0:810d59d0b843 19 public:
edodm85 0:810d59d0b843 20
edodm85 0:810d59d0b843 21 OV7670(
edodm85 0:810d59d0b843 22 PinName sda, // Camera I2C port
edodm85 0:810d59d0b843 23 PinName scl, // Camera I2C port
edodm85 0:810d59d0b843 24 PinName vs, // VSYNC
edodm85 0:810d59d0b843 25 PinName hr, // HREF
edodm85 0:810d59d0b843 26 PinName we, // WEN
edodm85 0:810d59d0b843 27
edodm85 0:810d59d0b843 28 PortName port, // 8bit bus port
edodm85 0:810d59d0b843 29 int mask, // 0b0000_0M65_4000_0321_L000_0000_0000_0000 = 0x07878000
edodm85 0:810d59d0b843 30
edodm85 0:810d59d0b843 31 PinName rt, // /RRST
edodm85 0:810d59d0b843 32 PinName o, // /OE
edodm85 0:810d59d0b843 33 PinName rc // RCLK
edodm85 0:810d59d0b843 34 );
edodm85 0:810d59d0b843 35
edodm85 0:810d59d0b843 36 ~OV7670();
edodm85 0:810d59d0b843 37
edodm85 0:810d59d0b843 38 void CaptureNext(void); // capture request
edodm85 0:810d59d0b843 39 bool CaptureDone(void); // capture done? (with clear)
edodm85 0:810d59d0b843 40 void WriteReg(int addr,int data); // write to camera
edodm85 0:810d59d0b843 41 int ReadReg(int addr); // read from camera
edodm85 0:810d59d0b843 42 void Reset(void); // reset reg camera
edodm85 0:810d59d0b843 43 int Init(char c); // init reg
edodm85 0:810d59d0b843 44 void VsyncHandler(void); // vsync handler
edodm85 0:810d59d0b843 45 void HrefHandler(void); // href handler
edodm85 0:810d59d0b843 46 int ReadOnebyte(void); // Data Read
edodm85 0:810d59d0b843 47 void ReadStart(void); // Data Start
edodm85 0:810d59d0b843 48 void ReadStop(void); // Data Stop
edodm85 0:810d59d0b843 49
edodm85 0:810d59d0b843 50
edodm85 0:810d59d0b843 51 private:
edodm85 0:810d59d0b843 52 I2C _i2c;
edodm85 0:810d59d0b843 53 InterruptIn vsync,href;
edodm85 0:810d59d0b843 54
edodm85 0:810d59d0b843 55 DigitalOut wen;
edodm85 0:810d59d0b843 56 PortIn data;
edodm85 0:810d59d0b843 57 DigitalOut rrst,oe,rclk;
edodm85 0:810d59d0b843 58 volatile int LineCounter;
edodm85 0:810d59d0b843 59 volatile int LastLines;
edodm85 0:810d59d0b843 60 volatile bool CaptureReq;
edodm85 0:810d59d0b843 61 volatile bool Busy;
edodm85 0:810d59d0b843 62 volatile bool Done;
edodm85 0:810d59d0b843 63 };