Samuel Pullman / Mbed 2 deprecated CameraTest

Dependencies:   FastPWM MODSERIAL mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers OV7670.h Source File

OV7670.h

00001 #include "mbed.h"
00002 #include "OV7670reg.h"
00003 #include "FastPWM.h"
00004 #include "spi_ram.h"
00005  
00006 #define OV7670_WRITE (0x42)
00007 #define OV7670_READ  (0x43)
00008 #define OV7670_WRITEWAIT (20)
00009 #define OV7670_NOACK (0)
00010 #define OV7670_REGMAX (201)
00011 #define OV7670_I2CFREQ (50000)
00012  
00013 //
00014 // OV7670 Camera board test (no FIFO)
00015 //
00016 class OV7670 {
00017 public:
00018     I2C camera;
00019     PinName xclkPin;
00020     PortIn data, inPort;
00021     SPI spi;
00022     SRAM ram;
00023     int size;
00024         
00025     OV7670(
00026         PinName sda, // Camera I2C port
00027         PinName scl, // Camera I2C port
00028         PinName xclk,// Camera XCLK
00029         PinName pclkPin,// PCLK
00030         PinName vs,  // VSYNC
00031         PinName hr,  // HREF
00032         
00033         PortName port, // 8bit bus port
00034         int mask // 0000 0111 4000 0111 1000 0000 0000 0000 = 0x07878000
00035         );
00036  
00037     void Init();
00038  
00039     // write to camera
00040     void WriteReg(int addr, int data);
00041  
00042     // read from camera
00043     int ReadReg(int addr);
00044  
00045     void Reset(void);
00046     
00047     void InitQQVGA();
00048 
00049     void scopeTest(Serial *host);
00050 
00051     // Capture image to external SRAM. Returns number of bytes received
00052     int captureImage();
00053     
00054     void sendImage(Serial *dest, int numBytes);
00055  
00056 };