Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: Project_test Capture_bw_portin Capture_bw_v3 Project_190659132
Revision 4:119b4c04a4ed, committed 2014-04-05
- Comitter:
- edodm85
- Date:
- Sat Apr 05 14:01:37 2014 +0000
- Parent:
- 3:b40a945dd672
- Commit message:
- Updated Init function
Changed in this revision
| ov7670.cpp | Show annotated file Show diff for this revision Revisions of this file |
| ov7670.h | Show annotated file Show diff for this revision Revisions of this file |
--- a/ov7670.cpp Sat Feb 15 15:00:37 2014 +0000
+++ b/ov7670.cpp Sat Apr 05 14:01:37 2014 +0000
@@ -19,6 +19,7 @@
OV7670::~OV7670()
{
+
}
@@ -110,6 +111,21 @@
int OV7670::Init(char c, int n)
{
+ if(c == 'b' || c == 'y') // YUV
+ {
+ format_temp = "BAW";
+ }
+ else
+ if(c == 'r') // RGB565
+ {
+ format_temp = "RGB";
+ }
+ return Init(format_temp, n);
+}
+
+
+int OV7670::Init(char *format, int n)
+{
if (ReadReg(REG_PID) != 0x76) // check id camera
{
@@ -120,7 +136,7 @@
Reset(); // Resets all registers to default values
WriteReg(REG_RGB444, 0x00); // Disable RGB444
- WriteReg(REG_COM10, 0x02); // 0x02 VSYNC negative (http://thinksmallthings.wordpress.com/2012/03/10/cf7670c-vs-cf7670c-v2/)
+ WriteReg(REG_COM10, 0x02); // 0x02 VSYNC negative (http://nasulica.homelinux.org/?p=959)
WriteReg(REG_MVFP, 0x27); // mirror image
WriteReg(REG_CLKRC, 0x80); // prescaler x1
@@ -131,7 +147,7 @@
WriteReg(REG_COM13, 0x88); // connect to REG_TSLB
- if(c == 'b' || c == 'y') // YUV
+ if((strcmp("BAW", format) == 0) || (strcmp("YUV", format) == 0)|| (strcmp("RAW", format) == 0)) // YUV
{
WriteReg(REG_COM7, 0x00); // YUV
WriteReg(REG_COM17, 0x00); // color bar disable
@@ -139,7 +155,7 @@
WriteReg(REG_COM15, 0xC0); // Set normal rgb with Full range
}else
- if(c == 'r') // RGB565
+ if((strcmp("RGB", format) == 0)) // RGB565
{
WriteReg(REG_COM7, 0x04); // RGB + color bar disable
WriteReg(REG_RGB444, 0x00); // Disable RGB444
@@ -260,7 +276,7 @@
WriteReg(0x01, 0x40);
WriteReg(0x02, 0x40);
WriteReg(0x13, 0xe7);
- //WriteReg(0x15, 0x02);
+ WriteReg(0x15, 0x02);
WriteReg(0x4f, 0x80);
WriteReg(0x50, 0x80);
@@ -429,7 +445,7 @@
WriteReg(0x01, 0x40);
WriteReg(0x02, 0x40);
WriteReg(0x13, 0xe7);
- //WriteReg(0x15, 0x02);
+ WriteReg(0x15, 0x02);
WriteReg(0x4f, 0x80);
WriteReg(0x50, 0x80);
WriteReg(0x51, 0x00);
--- a/ov7670.h Sat Feb 15 15:00:37 2014 +0000
+++ b/ov7670.h Sat Apr 05 14:01:37 2014 +0000
@@ -40,8 +40,9 @@
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); // init reg
- void VsyncHandler(void); // vsync handler
+ 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
@@ -60,4 +61,5 @@
volatile bool CaptureReq;
volatile bool Busy;
volatile bool Done;
+ char *format_temp;
};