ov7670 FIFO
OV7670.h@0:101fbacf126f, 2016-11-16 (annotated)
- Committer:
- rulla
- Date:
- Wed Nov 16 10:37:49 2016 +0000
- Revision:
- 0:101fbacf126f
11/2016
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
rulla | 0:101fbacf126f | 1 | #include "mbed.h" |
rulla | 0:101fbacf126f | 2 | #include "ov7670reg.h" |
rulla | 0:101fbacf126f | 3 | |
rulla | 0:101fbacf126f | 4 | #define OV7670_WRITE (0x42) |
rulla | 0:101fbacf126f | 5 | #define OV7670_READ (0x43) |
rulla | 0:101fbacf126f | 6 | #define OV7670_WRITEWAIT (20) |
rulla | 0:101fbacf126f | 7 | #define OV7670_NOACK (0) |
rulla | 0:101fbacf126f | 8 | #define OV7670_REGMAX (201) |
rulla | 0:101fbacf126f | 9 | #define OV7670_I2CFREQ (50000) |
rulla | 0:101fbacf126f | 10 | |
rulla | 0:101fbacf126f | 11 | |
rulla | 0:101fbacf126f | 12 | // |
rulla | 0:101fbacf126f | 13 | // OV7670 + FIFO AL422B camera board test |
rulla | 0:101fbacf126f | 14 | // |
rulla | 0:101fbacf126f | 15 | class OV7670 |
rulla | 0:101fbacf126f | 16 | { |
rulla | 0:101fbacf126f | 17 | |
rulla | 0:101fbacf126f | 18 | public: |
rulla | 0:101fbacf126f | 19 | volatile int LineCounter ; |
rulla | 0:101fbacf126f | 20 | volatile int LastLines ; |
rulla | 0:101fbacf126f | 21 | volatile bool CaptureReq ; |
rulla | 0:101fbacf126f | 22 | volatile bool Busy ; |
rulla | 0:101fbacf126f | 23 | volatile bool Done ; |
rulla | 0:101fbacf126f | 24 | void CaptureNext(void); |
rulla | 0:101fbacf126f | 25 | bool CaptureDone(void); |
rulla | 0:101fbacf126f | 26 | void WriteReg(int addr,char data); |
rulla | 0:101fbacf126f | 27 | void Reset(void); |
rulla | 0:101fbacf126f | 28 | void test(void); |
rulla | 0:101fbacf126f | 29 | void InitQQVGA(void); |
rulla | 0:101fbacf126f | 30 | char ReadReg(int addr); |
rulla | 0:101fbacf126f | 31 | int ReadOneByte(void); |
rulla | 0:101fbacf126f | 32 | void ReadStart(void); |
rulla | 0:101fbacf126f | 33 | void ReadStop(void); |
rulla | 0:101fbacf126f | 34 | void VsyncHandler(void); |
rulla | 0:101fbacf126f | 35 | InterruptIn vsync; |
rulla | 0:101fbacf126f | 36 | |
rulla | 0:101fbacf126f | 37 | OV7670( |
rulla | 0:101fbacf126f | 38 | PinName sda,// Camera I2C port |
rulla | 0:101fbacf126f | 39 | PinName scl,// Camera I2C port |
rulla | 0:101fbacf126f | 40 | PinName vs, // VSYNC |
rulla | 0:101fbacf126f | 41 | PinName hr, // HREF |
rulla | 0:101fbacf126f | 42 | PinName we, // WEN |
rulla | 0:101fbacf126f | 43 | PortName port, // 8bit bus port |
rulla | 0:101fbacf126f | 44 | int mask, // 0b0000_0M65_4000_0321_L000_0000_0000_0000 = 0x07878000 |
rulla | 0:101fbacf126f | 45 | PinName rt, // /RRST |
rulla | 0:101fbacf126f | 46 | PinName o, // /OE |
rulla | 0:101fbacf126f | 47 | PinName rc // RCLK |
rulla | 0:101fbacf126f | 48 | ) : camera(sda,scl),vsync(vs),href(hr),wen(we),dataP(port,mask),rrst(rt),oe(o),rclk(rc) |
rulla | 0:101fbacf126f | 49 | { |
rulla | 0:101fbacf126f | 50 | //camera.stop() ; |
rulla | 0:101fbacf126f | 51 | camera.frequency(OV7670_I2CFREQ) ; |
rulla | 0:101fbacf126f | 52 | // camera.start() ; |
rulla | 0:101fbacf126f | 53 | |
rulla | 0:101fbacf126f | 54 | CaptureReq = false ; |
rulla | 0:101fbacf126f | 55 | Busy = false ; |
rulla | 0:101fbacf126f | 56 | Done = false ; |
rulla | 0:101fbacf126f | 57 | LineCounter = 0 ; |
rulla | 0:101fbacf126f | 58 | rrst = 1 ; |
rulla | 0:101fbacf126f | 59 | oe = 1 ; |
rulla | 0:101fbacf126f | 60 | rclk = 1 ; |
rulla | 0:101fbacf126f | 61 | wen = 0 ; |
rulla | 0:101fbacf126f | 62 | vsync.rise(this,&OV7670::VsyncHandler) ; |
rulla | 0:101fbacf126f | 63 | } |
rulla | 0:101fbacf126f | 64 | protected: |
rulla | 0:101fbacf126f | 65 | I2C camera ; |
rulla | 0:101fbacf126f | 66 | DigitalIn href; |
rulla | 0:101fbacf126f | 67 | DigitalOut wen ; |
rulla | 0:101fbacf126f | 68 | PortIn dataP; |
rulla | 0:101fbacf126f | 69 | DigitalOut rrst,oe,rclk ; |
rulla | 0:101fbacf126f | 70 | }; |