Xbee CountUp

Dependencies:   mbed

Fork of HeptaXbee_CountUp by 智也 大野

Committer:
tomoya123
Date:
Tue Dec 13 07:55:03 2016 +0000
Revision:
1:715b80d2a02b
Parent:
0:0a7fa0911e6c
Xbee CountUp

Who changed what in which revision?

UserRevisionLine numberNew contents of line
tomoya123 0:0a7fa0911e6c 1 #define BITMAPFILE
tomoya123 0:0a7fa0911e6c 2 #undef BAYERBITMAPFILE
tomoya123 0:0a7fa0911e6c 3 #undef HEXFILE
tomoya123 0:0a7fa0911e6c 4 #undef COLORBAR
tomoya123 0:0a7fa0911e6c 5 #include <algorithm>
tomoya123 0:0a7fa0911e6c 6
tomoya123 0:0a7fa0911e6c 7 #ifndef MBED_HEPTACAMERA_H
tomoya123 0:0a7fa0911e6c 8 #define MBED_HEPTACAMERA_H
tomoya123 0:0a7fa0911e6c 9 #include "mbed.h"
tomoya123 0:0a7fa0911e6c 10
tomoya123 0:0a7fa0911e6c 11 // size register
tomoya123 0:0a7fa0911e6c 12 #define REG_COM7 0x12 /* Control 7 */
tomoya123 0:0a7fa0911e6c 13 #define REG_HSTART 0x17 /* Horiz start high bits */
tomoya123 0:0a7fa0911e6c 14 #define REG_HSTOP 0x18 /* Horiz stop high bits */
tomoya123 0:0a7fa0911e6c 15 #define REG_HREF 0x32 /* HREF pieces */
tomoya123 0:0a7fa0911e6c 16 #define REG_VSTART 0x19 /* Vert start high bits */
tomoya123 0:0a7fa0911e6c 17 #define REG_VSTOP 0x1a /* Vert stop high bits */
tomoya123 0:0a7fa0911e6c 18 #define REG_VREF 0x03 /* Pieces of GAIN, VSTART, VSTOP */
tomoya123 0:0a7fa0911e6c 19 #define REG_COM3 0x0c /* Control 3 */
tomoya123 0:0a7fa0911e6c 20 #define REG_COM14 0x3e /* Control 14 */
tomoya123 0:0a7fa0911e6c 21 #define REG_SCALING_XSC 0x70
tomoya123 0:0a7fa0911e6c 22 #define REG_SCALING_YSC 0x71
tomoya123 0:0a7fa0911e6c 23 #define REG_SCALING_DCWCTR 0x72
tomoya123 0:0a7fa0911e6c 24 #define REG_SCALING_PCLK_DIV 0x73
tomoya123 0:0a7fa0911e6c 25 #define REG_SCALING_PCLK_DELAY 0xa2
tomoya123 0:0a7fa0911e6c 26
tomoya123 0:0a7fa0911e6c 27 // VGA setting
tomoya123 0:0a7fa0911e6c 28 #define COM7_VGA 0x00
tomoya123 0:0a7fa0911e6c 29 #define HSTART_VGA 0x13
tomoya123 0:0a7fa0911e6c 30 #define HSTOP_VGA 0x01
tomoya123 0:0a7fa0911e6c 31 #define HREF_VGA 0x36 //0xb6 0x36
tomoya123 0:0a7fa0911e6c 32 #define VSTART_VGA 0x02
tomoya123 0:0a7fa0911e6c 33 #define VSTOP_VGA 0x7a
tomoya123 0:0a7fa0911e6c 34 #define VREF_VGA 0x0a
tomoya123 0:0a7fa0911e6c 35 #define COM3_VGA 0x00
tomoya123 0:0a7fa0911e6c 36 #define COM14_VGA 0x00
tomoya123 0:0a7fa0911e6c 37 #define SCALING_XSC_VGA 0x3a
tomoya123 0:0a7fa0911e6c 38 #define SCALING_YSC_VGA 0x35
tomoya123 0:0a7fa0911e6c 39 #define SCALING_DCWCTR_VGA 0x11
tomoya123 0:0a7fa0911e6c 40 #define SCALING_PCLK_DIV_VGA 0xf0
tomoya123 0:0a7fa0911e6c 41 #define SCALING_PCLK_DELAY_VGA 0x02
tomoya123 0:0a7fa0911e6c 42
tomoya123 0:0a7fa0911e6c 43 // QVGA setting
tomoya123 0:0a7fa0911e6c 44 #define COM7_QVGA 0x00
tomoya123 0:0a7fa0911e6c 45 #define HSTART_QVGA 0x16
tomoya123 0:0a7fa0911e6c 46 #define HSTOP_QVGA 0x04
tomoya123 0:0a7fa0911e6c 47 #define HREF_QVGA 0x00
tomoya123 0:0a7fa0911e6c 48 #define VSTART_QVGA 0x02
tomoya123 0:0a7fa0911e6c 49 #define VSTOP_QVGA 0x7a
tomoya123 0:0a7fa0911e6c 50 #define VREF_QVGA 0x0a
tomoya123 0:0a7fa0911e6c 51 #define COM3_QVGA 0x04
tomoya123 0:0a7fa0911e6c 52 #define COM14_QVGA 0x19
tomoya123 0:0a7fa0911e6c 53 #define SCALING_XSC_QVGA 0x3a
tomoya123 0:0a7fa0911e6c 54 #define SCALING_YSC_QVGA 0x35
tomoya123 0:0a7fa0911e6c 55 #define SCALING_DCWCTR_QVGA 0x11
tomoya123 0:0a7fa0911e6c 56 #define SCALING_PCLK_DIV_QVGA 0xf1
tomoya123 0:0a7fa0911e6c 57 #define SCALING_PCLK_DELAY_QVGA 0x02
tomoya123 0:0a7fa0911e6c 58
tomoya123 0:0a7fa0911e6c 59 // QQVGA setting
tomoya123 0:0a7fa0911e6c 60 #define COM7_QQVGA 0x00
tomoya123 0:0a7fa0911e6c 61 #define HSTART_QQVGA 0x16
tomoya123 0:0a7fa0911e6c 62 #define HSTOP_QQVGA 0x04
tomoya123 0:0a7fa0911e6c 63 #define HREF_QQVGA 0xa4 //0x24? 0xa4?
tomoya123 0:0a7fa0911e6c 64 #define VSTART_QQVGA 0x02
tomoya123 0:0a7fa0911e6c 65 #define VSTOP_QQVGA 0x7a
tomoya123 0:0a7fa0911e6c 66 #define VREF_QQVGA 0x0a
tomoya123 0:0a7fa0911e6c 67 #define COM3_QQVGA 0x04
tomoya123 0:0a7fa0911e6c 68 #define COM14_QQVGA 0x1a
tomoya123 0:0a7fa0911e6c 69 #define SCALING_XSC_QQVGA 0x3a
tomoya123 0:0a7fa0911e6c 70 #define SCALING_YSC_QQVGA 0x35
tomoya123 0:0a7fa0911e6c 71 #define SCALING_DCWCTR_QQVGA 0x22
tomoya123 0:0a7fa0911e6c 72 #define SCALING_PCLK_DIV_QQVGA 0xf2
tomoya123 0:0a7fa0911e6c 73 #define SCALING_PCLK_DELAY_QQVGA 0x02
tomoya123 0:0a7fa0911e6c 74
tomoya123 0:0a7fa0911e6c 75 // CIF setting no tested linux src 2.6.29-rc5 ov7670_soc.c
tomoya123 0:0a7fa0911e6c 76 #define COM7_CIF 0x00
tomoya123 0:0a7fa0911e6c 77 #define HSTART_CIF 0x15
tomoya123 0:0a7fa0911e6c 78 #define HSTOP_CIF 0x0b
tomoya123 0:0a7fa0911e6c 79 #define HREF_CIF 0xb6
tomoya123 0:0a7fa0911e6c 80 #define VSTART_CIF 0x03
tomoya123 0:0a7fa0911e6c 81 #define VSTOP_CIF 0x7b
tomoya123 0:0a7fa0911e6c 82 #define VREF_CIF 0x02
tomoya123 0:0a7fa0911e6c 83 #define COM3_CIF 0x08
tomoya123 0:0a7fa0911e6c 84 #define COM14_CIF 0x11
tomoya123 0:0a7fa0911e6c 85 #define SCALING_XSC_CIF 0x3a
tomoya123 0:0a7fa0911e6c 86 #define SCALING_YSC_CIF 0x35
tomoya123 0:0a7fa0911e6c 87 #define SCALING_DCWCTR_CIF 0x11
tomoya123 0:0a7fa0911e6c 88 #define SCALING_PCLK_DIV_CIF 0xf1
tomoya123 0:0a7fa0911e6c 89 #define SCALING_PCLK_DELAY_CIF 0x02
tomoya123 0:0a7fa0911e6c 90
tomoya123 0:0a7fa0911e6c 91 // QCIF setting no tested no tested linux src 2.6.29-rc5 ov7670_soc.c
tomoya123 0:0a7fa0911e6c 92 #define COM7_QCIF 0x00
tomoya123 0:0a7fa0911e6c 93 #define HSTART_QCIF 0x39
tomoya123 0:0a7fa0911e6c 94 #define HSTOP_QCIF 0x03
tomoya123 0:0a7fa0911e6c 95 #define HREF_QCIF 0x80
tomoya123 0:0a7fa0911e6c 96 #define VSTART_QCIF 0x03
tomoya123 0:0a7fa0911e6c 97 #define VSTOP_QCIF 0x7b
tomoya123 0:0a7fa0911e6c 98 #define VREF_QCIF 0x02
tomoya123 0:0a7fa0911e6c 99 #define COM3_QCIF 0x0c
tomoya123 0:0a7fa0911e6c 100 #define COM14_QCIF 0x11
tomoya123 0:0a7fa0911e6c 101 #define SCALING_XSC_QCIF 0x3a
tomoya123 0:0a7fa0911e6c 102 #define SCALING_YSC_QCIF 0x35
tomoya123 0:0a7fa0911e6c 103 #define SCALING_DCWCTR_QCIF 0x11
tomoya123 0:0a7fa0911e6c 104 #define SCALING_PCLK_DIV_QCIF 0xf1
tomoya123 0:0a7fa0911e6c 105 #define SCALING_PCLK_DELAY_QCIF 0x52
tomoya123 0:0a7fa0911e6c 106
tomoya123 0:0a7fa0911e6c 107 // YUV
tomoya123 0:0a7fa0911e6c 108 #define REG_COM13 0x3d /* Control 13 */
tomoya123 0:0a7fa0911e6c 109 #define REG_TSLB 0x3a /* lots of stuff */
tomoya123 0:0a7fa0911e6c 110
tomoya123 0:0a7fa0911e6c 111 #define COM7_YUV 0x00 /* YUV */
tomoya123 0:0a7fa0911e6c 112 #define COM13_UV 0x00 /* U before V - w/TSLB */
tomoya123 0:0a7fa0911e6c 113 #define COM13_UVSWAP 0x01 /* V before U - w/TSLB */
tomoya123 0:0a7fa0911e6c 114 #define TSLB_VLAST 0x00 /* YUYV - see com13 */
tomoya123 0:0a7fa0911e6c 115 #define TSLB_ULAST 0x00 /* YVYU - see com13 */
tomoya123 0:0a7fa0911e6c 116 #define TSLB_YLAST 0x08 /* UYVY or VYUY - see com13 */
tomoya123 0:0a7fa0911e6c 117
tomoya123 0:0a7fa0911e6c 118 // RGB
tomoya123 0:0a7fa0911e6c 119 #define COM7_RGB 0x04 /* bits 0 and 2 - RGB format */
tomoya123 0:0a7fa0911e6c 120
tomoya123 0:0a7fa0911e6c 121 // RGB444
tomoya123 0:0a7fa0911e6c 122 #define REG_RGB444 0x8c /* RGB 444 control */
tomoya123 0:0a7fa0911e6c 123 #define REG_COM15 0x40 /* Control 15 */
tomoya123 0:0a7fa0911e6c 124
tomoya123 0:0a7fa0911e6c 125 #define RGB444_ENABLE 0x02 /* Turn on RGB444, overrides 5x5 */
tomoya123 0:0a7fa0911e6c 126 #define RGB444_XBGR 0x00
tomoya123 0:0a7fa0911e6c 127 #define RGB444_BGRX 0x01 /* Empty nibble at end */
tomoya123 0:0a7fa0911e6c 128 #define COM15_RGB444 0x10 /* RGB444 output */
tomoya123 0:0a7fa0911e6c 129
tomoya123 0:0a7fa0911e6c 130 // RGB555
tomoya123 0:0a7fa0911e6c 131 #define RGB444_DISABLE 0x00 /* Turn off RGB444, overrides 5x5 */
tomoya123 0:0a7fa0911e6c 132 #define COM15_RGB555 0x30 /* RGB555 output */
tomoya123 0:0a7fa0911e6c 133
tomoya123 0:0a7fa0911e6c 134 // RGB565
tomoya123 0:0a7fa0911e6c 135 #define COM15_RGB565 0x10 /* RGB565 output */
tomoya123 0:0a7fa0911e6c 136
tomoya123 0:0a7fa0911e6c 137 // Bayer RGB
tomoya123 0:0a7fa0911e6c 138 #define COM7_BAYER 0x01 /* Bayer format */
tomoya123 0:0a7fa0911e6c 139 #define COM7_PBAYER 0x05 /* "Processed bayer" */
tomoya123 0:0a7fa0911e6c 140
tomoya123 0:0a7fa0911e6c 141
tomoya123 0:0a7fa0911e6c 142 // data format
tomoya123 0:0a7fa0911e6c 143 #define COM15_R10F0 0x00 /* Data range 10 to F0 */
tomoya123 0:0a7fa0911e6c 144 #define COM15_R01FE 0x80 /* 01 to FE */
tomoya123 0:0a7fa0911e6c 145 #define COM15_R00FF 0xc0 /* 00 to FF */
tomoya123 0:0a7fa0911e6c 146
tomoya123 0:0a7fa0911e6c 147 // Night mode, flicker, banding /
tomoya123 0:0a7fa0911e6c 148 #define REG_COM11 0x3b /* Control 11 */
tomoya123 0:0a7fa0911e6c 149 #define COM11_NIGHT 0x80 /* NIght mode enable */
tomoya123 0:0a7fa0911e6c 150 #define COM11_NIGHT_MIN_RATE_1_1 0x00 /* Normal mode same */
tomoya123 0:0a7fa0911e6c 151 #define COM11_NIGHT_MIN_RATE_1_2 0x20 /* Normal mode 1/2 */
tomoya123 0:0a7fa0911e6c 152 #define COM11_NIGHT_MIN_RATE_1_4 0x40 /* Normal mode 1/4 */
tomoya123 0:0a7fa0911e6c 153 #define COM11_NIGHT_MIN_RATE_1_8 0x60 /* Normal mode 1/5 */
tomoya123 0:0a7fa0911e6c 154 #define COM11_HZAUTO_ON 0x10 /* Auto detect 50/60 Hz on */
tomoya123 0:0a7fa0911e6c 155 #define COM11_HZAUTO_OFF 0x00 /* Auto detect 50/60 Hz off */
tomoya123 0:0a7fa0911e6c 156 #define COM11_60HZ 0x00 /* Manual 60Hz select */
tomoya123 0:0a7fa0911e6c 157 #define COM11_50HZ 0x08 /* Manual 50Hz select */
tomoya123 0:0a7fa0911e6c 158 #define COM11_EXP 0x02
tomoya123 0:0a7fa0911e6c 159
tomoya123 0:0a7fa0911e6c 160 #define REG_MTX1 0x4f
tomoya123 0:0a7fa0911e6c 161 #define REG_MTX2 0x50
tomoya123 0:0a7fa0911e6c 162 #define REG_MTX3 0x51
tomoya123 0:0a7fa0911e6c 163 #define REG_MTX4 0x52
tomoya123 0:0a7fa0911e6c 164 #define REG_MTX5 0x53
tomoya123 0:0a7fa0911e6c 165 #define REG_MTX6 0x54
tomoya123 0:0a7fa0911e6c 166 #define REG_BRIGHT 0x55 /* Brightness */
tomoya123 0:0a7fa0911e6c 167 #define REG_CONTRAS 0x56 /* Contrast control */
tomoya123 0:0a7fa0911e6c 168 #define REG_CONTRAS_CENTER 0x57
tomoya123 0:0a7fa0911e6c 169 #define REG_MTXS 0x58
tomoya123 0:0a7fa0911e6c 170 #define REG_MANU 0x67
tomoya123 0:0a7fa0911e6c 171 #define REG_MANV 0x68
tomoya123 0:0a7fa0911e6c 172 #define REG_GFIX 0x69 /* Fix gain control */
tomoya123 0:0a7fa0911e6c 173 #define REG_GGAIN 0x6a
tomoya123 0:0a7fa0911e6c 174 #define REG_DBLV 0x6b
tomoya123 0:0a7fa0911e6c 175
tomoya123 0:0a7fa0911e6c 176 #define REG_COM9 0x14 // Control 9 - gain ceiling
tomoya123 0:0a7fa0911e6c 177 #define COM9_AGC_2X 0x00
tomoya123 0:0a7fa0911e6c 178 #define COM9_AGC_4X 0x10
tomoya123 0:0a7fa0911e6c 179 #define COM9_AGC_8X 0x20
tomoya123 0:0a7fa0911e6c 180 #define COM9_AGC_16X 0x30
tomoya123 0:0a7fa0911e6c 181 #define COM9_AGC_32X 0x40
tomoya123 0:0a7fa0911e6c 182 #define COM9_AGC_64X 0x50
tomoya123 0:0a7fa0911e6c 183 #define COM9_AGC_128X 0x60
tomoya123 0:0a7fa0911e6c 184 #define COM9_AGC_MASK 0x70
tomoya123 0:0a7fa0911e6c 185 #define COM9_FREEZE 0x01
tomoya123 0:0a7fa0911e6c 186 #define COM13_GAMMA 0x80 /* Gamma enable */
tomoya123 0:0a7fa0911e6c 187 #define COM13_UVSAT 0x40 /* UV saturation auto adjustment */
tomoya123 0:0a7fa0911e6c 188 #define REG_GAIN 0x00 /* Gain lower 8 bits (rest in vref) */
tomoya123 0:0a7fa0911e6c 189 #define REG_BLUE 0x01 /* blue gain */
tomoya123 0:0a7fa0911e6c 190 #define REG_RED 0x02 /* red gain */
tomoya123 0:0a7fa0911e6c 191 #define REG_COM1 0x04 /* Control 1 */
tomoya123 0:0a7fa0911e6c 192 #define COM1_CCIR656 0x40 /* CCIR656 enable */
tomoya123 0:0a7fa0911e6c 193 #define REG_BAVE 0x05 /* U/B Average level */
tomoya123 0:0a7fa0911e6c 194 #define REG_GbAVE 0x06 /* Y/Gb Average level */
tomoya123 0:0a7fa0911e6c 195 #define REG_AECHH 0x07 /* AEC MS 5 bits */
tomoya123 0:0a7fa0911e6c 196 #define REG_RAVE 0x08 /* V/R Average level */
tomoya123 0:0a7fa0911e6c 197 #define REG_COM2 0x09 /* Control 2 */
tomoya123 0:0a7fa0911e6c 198 #define COM2_SSLEEP 0x10 /* Soft sleep mode */
tomoya123 0:0a7fa0911e6c 199 #define REG_PID 0x0a /* Product ID MSB */
tomoya123 0:0a7fa0911e6c 200 #define REG_VER 0x0b /* Product ID LSB */
tomoya123 0:0a7fa0911e6c 201 #define COM3_SWAP 0x40 /* Byte swap */
tomoya123 0:0a7fa0911e6c 202 #define COM3_SCALEEN 0x08 /* Enable scaling */
tomoya123 0:0a7fa0911e6c 203 #define COM3_DCWEN 0x04 /* Enable downsamp/crop/window */
tomoya123 0:0a7fa0911e6c 204 #define REG_COM4 0x0d /* Control 4 */
tomoya123 0:0a7fa0911e6c 205 #define REG_COM5 0x0e /* All "reserved" */
tomoya123 0:0a7fa0911e6c 206 #define REG_COM6 0x0f /* Control 6 */
tomoya123 0:0a7fa0911e6c 207 #define REG_AECH 0x10 /* More bits of AEC value */
tomoya123 0:0a7fa0911e6c 208 #define REG_CLKRC 0x11 /* Clocl control */
tomoya123 0:0a7fa0911e6c 209 #define CLK_EXT 0x40 /* Use external clock directly */
tomoya123 0:0a7fa0911e6c 210 #define CLK_SCALE 0x3f /* Mask for internal clock scale */
tomoya123 0:0a7fa0911e6c 211 #define COM7_RESET 0x80 /* Register reset */
tomoya123 0:0a7fa0911e6c 212 #define COM7_FMT_MASK 0x38
tomoya123 0:0a7fa0911e6c 213 #define COM7_FMT_VGA 0x00
tomoya123 0:0a7fa0911e6c 214 #define COM7_FMT_CIF 0x20 /* CIF format */
tomoya123 0:0a7fa0911e6c 215 #define COM7_FMT_QVGA 0x10 /* QVGA format */
tomoya123 0:0a7fa0911e6c 216 #define COM7_FMT_QCIF 0x08 /* QCIF format */
tomoya123 0:0a7fa0911e6c 217 #define REG_COM8 0x13 /* Control 8 */
tomoya123 0:0a7fa0911e6c 218 #define COM8_FASTAEC 0x80 /* Enable fast AGC/AEC */
tomoya123 0:0a7fa0911e6c 219 #define COM8_AECSTEP 0x40 /* Unlimited AEC step size */
tomoya123 0:0a7fa0911e6c 220 #define COM8_BFILT 0x20 /* Band filter enable */
tomoya123 0:0a7fa0911e6c 221 #define COM8_AGC 0x04 /* Auto gain enable */
tomoya123 0:0a7fa0911e6c 222 #define COM8_AWB 0x02 /* White balance enable */
tomoya123 0:0a7fa0911e6c 223 #define COM8_AEC 0x01 /* Auto exposure enable */
tomoya123 0:0a7fa0911e6c 224 #define REG_COM9 0x14 /* Control 9 - gain ceiling */
tomoya123 0:0a7fa0911e6c 225 #define REG_COM10 0x15 /* Control 10 */
tomoya123 0:0a7fa0911e6c 226 #define COM10_HSYNC 0x40 /* HSYNC instead of HREF */
tomoya123 0:0a7fa0911e6c 227 #define COM10_PCLK_HB 0x20 /* Suppress PCLK on horiz blank */
tomoya123 0:0a7fa0911e6c 228 #define COM10_HREF_REV 0x08 /* Reverse HREF */
tomoya123 0:0a7fa0911e6c 229 #define COM10_VS_LEAD 0x04 /* VSYNC on clock leading edge */
tomoya123 0:0a7fa0911e6c 230 #define COM10_VS_NEG 0x02 /* VSYNC negative */
tomoya123 0:0a7fa0911e6c 231 #define COM10_HS_NEG 0x01 /* HSYNC negative */
tomoya123 0:0a7fa0911e6c 232 #define REG_PSHFT 0x1b /* Pixel delay after HREF */
tomoya123 0:0a7fa0911e6c 233 #define REG_MIDH 0x1c /* Manuf. ID high */
tomoya123 0:0a7fa0911e6c 234 #define REG_MIDL 0x1d /* Manuf. ID low */
tomoya123 0:0a7fa0911e6c 235 #define REG_MVFP 0x1e /* Mirror / vflip */
tomoya123 0:0a7fa0911e6c 236 #define MVFP_MIRROR 0x20 /* Mirror image */
tomoya123 0:0a7fa0911e6c 237 #define MVFP_FLIP 0x10 /* Vertical flip */
tomoya123 0:0a7fa0911e6c 238 #define REG_AEW 0x24 /* AGC upper limit */
tomoya123 0:0a7fa0911e6c 239 #define REG_AEB 0x25 /* AGC lower limit */
tomoya123 0:0a7fa0911e6c 240 #define REG_VPT 0x26 /* AGC/AEC fast mode op region */
tomoya123 0:0a7fa0911e6c 241 #define REG_HSYST 0x30 /* HSYNC rising edge delay */
tomoya123 0:0a7fa0911e6c 242 #define REG_HSYEN 0x31 /* HSYNC falling edge delay */
tomoya123 0:0a7fa0911e6c 243 #define REG_COM12 0x3c /* Control 12 */
tomoya123 0:0a7fa0911e6c 244 #define COM12_HREF 0x80 /* HREF always */
tomoya123 0:0a7fa0911e6c 245 #define COM14_DCWEN 0x10 /* DCW/PCLK-scale enable */
tomoya123 0:0a7fa0911e6c 246 #define REG_EDGE 0x3f /* Edge enhancement factor */
tomoya123 0:0a7fa0911e6c 247 #define REG_COM16 0x41 /* Control 16 */
tomoya123 0:0a7fa0911e6c 248 #define COM16_AWBGAIN 0x08 /* AWB gain enable */
tomoya123 0:0a7fa0911e6c 249 #define REG_COM17 0x42 /* Control 17 */
tomoya123 0:0a7fa0911e6c 250 #define COM17_AECWIN 0xc0 /* AEC window - must match COM4 */
tomoya123 0:0a7fa0911e6c 251 #define COM17_CBAR 0x08 /* DSP Color bar */
tomoya123 0:0a7fa0911e6c 252 #define REG_CMATRIX_BASE 0x4f
tomoya123 0:0a7fa0911e6c 253 #define CMATRIX_LEN 6
tomoya123 0:0a7fa0911e6c 254 #define REG_REG76 0x76 /* OV's name */
tomoya123 0:0a7fa0911e6c 255 #define R76_BLKPCOR 0x80 /* Black pixel correction enable */
tomoya123 0:0a7fa0911e6c 256 #define R76_WHTPCOR 0x40 /* White pixel correction enable */
tomoya123 0:0a7fa0911e6c 257 #define REG_HAECC1 0x9f /* Hist AEC/AGC control 1 */
tomoya123 0:0a7fa0911e6c 258 #define REG_HAECC2 0xa0 /* Hist AEC/AGC control 2 */
tomoya123 0:0a7fa0911e6c 259 #define REG_BD50MAX 0xa5 /* 50hz banding step limit */
tomoya123 0:0a7fa0911e6c 260 #define REG_HAECC3 0xa6 /* Hist AEC/AGC control 3 */
tomoya123 0:0a7fa0911e6c 261 #define REG_HAECC4 0xa7 /* Hist AEC/AGC control 4 */
tomoya123 0:0a7fa0911e6c 262 #define REG_HAECC5 0xa8 /* Hist AEC/AGC control 5 */
tomoya123 0:0a7fa0911e6c 263 #define REG_HAECC6 0xa9 /* Hist AEC/AGC control 6 */
tomoya123 0:0a7fa0911e6c 264 #define REG_HAECC7 0xaa /* Hist AEC/AGC control 7 */
tomoya123 0:0a7fa0911e6c 265 #define REG_BD60MAX 0xab /* 60hz banding step limit */
tomoya123 0:0a7fa0911e6c 266
tomoya123 0:0a7fa0911e6c 267 #define OV7670_WRITE (0x42)
tomoya123 0:0a7fa0911e6c 268 #define OV7670_READ (0x43)
tomoya123 0:0a7fa0911e6c 269 #define OV7670_WRITEWAIT (20)
tomoya123 0:0a7fa0911e6c 270 #define OV7670_NOACK (0)
tomoya123 0:0a7fa0911e6c 271 #define OV7670_REGMAX (201)
tomoya123 0:0a7fa0911e6c 272 #define OV7670_I2CFREQ (50000)
tomoya123 0:0a7fa0911e6c 273
tomoya123 0:0a7fa0911e6c 274 //Camera OV7670
tomoya123 0:0a7fa0911e6c 275
tomoya123 0:0a7fa0911e6c 276 class HeptaCamera{
tomoya123 0:0a7fa0911e6c 277 public:
tomoya123 0:0a7fa0911e6c 278 I2C camera;
tomoya123 0:0a7fa0911e6c 279 InterruptIn vsync,href;
tomoya123 0:0a7fa0911e6c 280 DigitalOut wen;
tomoya123 0:0a7fa0911e6c 281 BusIn data;
tomoya123 0:0a7fa0911e6c 282 DigitalOut rrst,oe,rclk;
tomoya123 0:0a7fa0911e6c 283 volatile int LineCounter;
tomoya123 0:0a7fa0911e6c 284 volatile int LastLines;
tomoya123 0:0a7fa0911e6c 285 volatile bool CaptureReq;
tomoya123 0:0a7fa0911e6c 286 volatile bool Busy;
tomoya123 0:0a7fa0911e6c 287 volatile bool Done;
tomoya123 0:0a7fa0911e6c 288
tomoya123 0:0a7fa0911e6c 289 HeptaCamera(
tomoya123 0:0a7fa0911e6c 290 PinName sda,// Camera I2C port
tomoya123 0:0a7fa0911e6c 291 PinName scl,// Camera I2C port
tomoya123 0:0a7fa0911e6c 292 PinName vs, // VSYNC
tomoya123 0:0a7fa0911e6c 293 PinName hr, // HREF
tomoya123 0:0a7fa0911e6c 294 PinName we, // WEN
tomoya123 0:0a7fa0911e6c 295 PinName d7, // D7
tomoya123 0:0a7fa0911e6c 296 PinName d6, // D6
tomoya123 0:0a7fa0911e6c 297 PinName d5, // D5
tomoya123 0:0a7fa0911e6c 298 PinName d4, // D4
tomoya123 0:0a7fa0911e6c 299 PinName d3, // D3
tomoya123 0:0a7fa0911e6c 300 PinName d2, // D2
tomoya123 0:0a7fa0911e6c 301 PinName d1, // D1
tomoya123 0:0a7fa0911e6c 302 PinName d0, // D0
tomoya123 0:0a7fa0911e6c 303 PinName rt, // /RRST
tomoya123 0:0a7fa0911e6c 304 PinName o, // /OE
tomoya123 0:0a7fa0911e6c 305 PinName rc // RCLK
tomoya123 0:0a7fa0911e6c 306 );
tomoya123 0:0a7fa0911e6c 307 void CaptureNext(void);
tomoya123 0:0a7fa0911e6c 308 bool CaptureDone(void);
tomoya123 0:0a7fa0911e6c 309 void WriteReg(int addr,int data);
tomoya123 0:0a7fa0911e6c 310 int ReadReg(int addr);
tomoya123 0:0a7fa0911e6c 311 void PrintRegister(void);
tomoya123 0:0a7fa0911e6c 312 void Reset(void);
tomoya123 0:0a7fa0911e6c 313 void InitForFIFOWriteReset(void);
tomoya123 0:0a7fa0911e6c 314 void InitSetColorbar(void);
tomoya123 0:0a7fa0911e6c 315 void InitDefaultReg(void);
tomoya123 0:0a7fa0911e6c 316 void InitRGB444(void);
tomoya123 0:0a7fa0911e6c 317 void InitRGB555(void);
tomoya123 0:0a7fa0911e6c 318 void InitRGB565(void);
tomoya123 0:0a7fa0911e6c 319 void InitYUV(void);
tomoya123 0:0a7fa0911e6c 320 void InitBayerRGB(void);
tomoya123 0:0a7fa0911e6c 321 void InitVGA(void);
tomoya123 0:0a7fa0911e6c 322 void InitFIFO_2bytes_color_nealy_limit_size(void);
tomoya123 0:0a7fa0911e6c 323 void InitVGA_3_4(void);
tomoya123 0:0a7fa0911e6c 324 void InitQVGA(void);
tomoya123 0:0a7fa0911e6c 325 void InitQQVGA();
tomoya123 0:0a7fa0911e6c 326 void VsyncHandler(void);
tomoya123 0:0a7fa0911e6c 327 void HrefHandler(void);
tomoya123 0:0a7fa0911e6c 328 int ReadOneByte(void);
tomoya123 0:0a7fa0911e6c 329 void ReadStart(void);
tomoya123 0:0a7fa0911e6c 330 void ReadStop(void);
tomoya123 0:0a7fa0911e6c 331 void shoot();
tomoya123 0:0a7fa0911e6c 332 void shoot2();
tomoya123 0:0a7fa0911e6c 333 private:
tomoya123 0:0a7fa0911e6c 334 };
tomoya123 0:0a7fa0911e6c 335 #endif