OV7670 without FIFO, SCCB protocol rewritten.

Dependents:   mycame wd_camera

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers ov7670s.h Source File

ov7670s.h

00001 #pragma once
00002 #include "mbed.h"
00003 #include "global.h"
00004 #include "ov7670sreg.h"
00005 #include "SDFileSystem.h"
00006 #include "SPI_TFT_ILI9341.h"
00007 #include "FastPWM.h"
00008 
00009 
00010 #define OV7670_WRITE (0x42)
00011 #define OV7670_READ  (0x43)
00012 #define OV7670_REGMAX (201)
00013 #define OV7670_I2CFREQ (100) //us half period
00014 #define CAMERA_CLK_PERIOD 0.35//micro second 0.35
00015 
00016 extern const int tmarray ;
00017 extern char desfile[25];
00018 extern Serial pc;
00019 extern Timer Time;
00020 extern bool Done;
00021 extern bool Doneaff;
00022 extern bool volatile captur;
00023 extern unsigned char bank[];
00024 extern unsigned char bankf[];
00025 extern SPI_TFT_ILI9341 TFT;
00026 extern FILE *fp;
00027 
00028 
00029 
00030 class OV7670
00031 {
00032 public:
00033 
00034     OV7670(
00035         PinName siod,    // Camera I2C port data
00036         PinName sioc,  // Camera I2C port clock
00037         PinName xclk, //  XCLK
00038         //PinName vs, // VSYNC
00039         //PinName hr, // HREF
00040         // PinName pclk,      // Pixelclock
00041         PortName port,
00042         int mask,
00043         /*
00044         VSYNC
00045         HREF
00046         Pixelclock
00047         PinName d7, // D7
00048         PinName d6, // D6
00049         PinName d5, // D5
00050         PinName d4, // D4
00051         PinName d3, // D3
00052         PinName d2, // D2
00053         PinName d1, // D1
00054         PinName d0, // D0 */
00055         PinName rst // /RESET
00056     );
00057 
00058     void InitQQVGA() ;
00059     void WriteBy(int addr);    // write to camera
00060     void WriteReg2(int data);    // write to camera
00061     void WriteReg(int subad,int data);    // write to camera
00062     int ReadReg(int subad);               // read from camera
00063     int ReadBy(void);
00064     void Reset(void);                    // reset reg camera
00065     void Start(void);
00066     void End (void);
00067     void CaptureNext(void);
00068     void capture(void);
00069     unsigned char reverse(unsigned char b);
00070     void exrgbf(int j);
00071     int ar(float a);
00072     int Init(char *format, int n);
00073     int  PixelCounter ;
00074 
00075 
00076 
00077 private:
00078     DigitalInOut _siod;
00079     DigitalOut _sioc;
00080     FastPWM _xclk;
00081     // DigitalIn _pclk;
00082     //DigitalIn _vs;
00083     //DigitalIn _hr;
00084     PortIn data;
00085     /*
00086         DigitalIn _vs;
00087         DigitalIn _hr;
00088          DigitalIn _pclk;
00089            DigitalIn d7;
00090            DigitalIn d6;
00091            DigitalIn d5;
00092            DigitalIn d4;
00093            DigitalIn d3;
00094            DigitalIn d2;
00095            DigitalIn d1;
00096            DigitalIn d0;
00097         */
00098     DigitalOut _rst;
00099 };