Created
June 8, 2011 14:53
-
-
Save border/1014575 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) | |
struct ov7725_reg { | |
unsigned char addr; | |
unsigned char val; | |
}; | |
/* | |
* Manual White Balance (presets) | |
*/ | |
static const struct ov7725_reg ov7725_wb_tungsten[] = { | |
// Home | |
{0x13, 0xfd}, | |
{0x01, 0x96}, | |
{0x02, 0x40}, | |
{0x0e, 0x65}, | |
{0x2d, 0x00}, | |
{0x2e, 0x00}, | |
{0x0c, 0x51}, //Horizontal mirror image ON/OFF selection And Sensor Color Bar Test Enable | |
}; | |
static const struct ov7725_reg ov7725_wb_fluorescent[] = { | |
// Office | |
{0x13, 0xfd}, | |
{0x01, 0x84}, | |
{0x02, 0x4c}, | |
{0x0e, 0x65}, | |
{0x2d, 0x00}, | |
}; | |
static const struct ov7725_reg ov7725_wb_sunny[] = { | |
// Sunny | |
{0x13, 0xfd}, | |
{0x01, 0x5a}, | |
{0x02, 0x5c}, | |
{0x0e, 0x65}, | |
{0x2d, 0x00}, | |
{0x2e, 0x00}, | |
{0x0c, 0x51}, //Horizontal mirror image ON/OFF selection And Sensor Color Bar Test Enable | |
}; | |
static const struct ov7725_reg ov7725_wb_cloudy[] = { | |
// cloudy | |
{0x13, 0xfd}, | |
{0x01, 0x58}, | |
{0x02, 0x60}, | |
{0x0e, 0x65}, | |
{0x2d, 0x00}, | |
{0x2e, 0x00}, | |
}; | |
#if 0 | |
/* Order of this array should be following the querymenu data */ | |
static const unsigned char *ov7725_regs_wb_preset[] = { | |
(unsigned char *)ov7725_wb_tungsten, | |
(unsigned char *)ov7725_wb_fluorescent, | |
(unsigned char *)ov7725_wb_sunny, | |
(unsigned char *)ov7725_wb_cloudy, | |
}; | |
#endif | |
typedef struct { | |
unsigned char * sptr; | |
unsigned int slen; | |
} structandlen; | |
/* Order of this array should be following the querymenu data */ | |
static const structandlen ov7725_regs_wb_preset[] = | |
{ | |
{(unsigned char *)ov7725_wb_tungsten , ARRAY_SIZE(ov7725_wb_tungsten)} , | |
{(unsigned char *)ov7725_wb_fluorescent, ARRAY_SIZE(ov7725_wb_fluorescent)} , | |
{(unsigned char *)ov7725_wb_sunny, ARRAY_SIZE(ov7725_wb_sunny)} , | |
{(unsigned char *)ov7725_wb_cloudy, ARRAY_SIZE(ov7725_wb_cloudy)}, | |
}; | |
int main(void) | |
{ | |
printf("ov7725_regs_wb_preset sizeof: %d\n", sizeof(ov7725_regs_wb_preset)); | |
printf("ov7725_regs_wb_preset array_size: %d\n", ARRAY_SIZE(ov7725_regs_wb_preset)); | |
int i =0, j=0; | |
for(i=0; i<ARRAY_SIZE(ov7725_regs_wb_preset); i++) { | |
unsigned char * mode = (unsigned char *)(&(ov7725_regs_wb_preset[i])); | |
printf("ov7725_regs_wb_preset[%d] sizeof: %d,\t", i, sizeof(mode)); | |
printf("ov7725_regs_wb_preset[%d] array_size: %d\n", i, ARRAY_SIZE(mode)); | |
} | |
int ic = ARRAY_SIZE(ov7725_regs_wb_preset); | |
int jc = 0; | |
struct ov7725_reg * ptr; | |
for(i=0; i<ic; i++) | |
{ | |
ptr = (struct ov7725_reg *)(ov7725_regs_wb_preset[i].sptr); | |
jc = ov7725_regs_wb_preset[i].slen; | |
printf("-----%d------\n", i); | |
for(j=0; j<jc; j++) | |
{ | |
printf("[%d]addr = 0x%02x \t" , j , ptr[j].addr); | |
printf("val = 0x%02x \n" , ptr[j].val); | |
} | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment