OV7670 Library
Dependents: OV7670_Test_Code OV7670_Test_Code_with_ethernet Practica4_Camara
You can find the original files here: http://mbed.org/users/mio/notebook/ov7670_with_al422b_qqvga_test/
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 |
diff -r b40a945dd672 -r 119b4c04a4ed ov7670.cpp --- 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);
diff -r b40a945dd672 -r 119b4c04a4ed ov7670.h --- 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; };