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