Clone
Dependents: SignalProcessLab DigitalSignalAlgorithm_Lab DigitalSignal_Lab
Drivers/BSP/Components/ov9655/ov9655.c@0:fc80425b677a, 2019-08-26 (annotated)
- Committer:
- ngtkien
- Date:
- Mon Aug 26 16:33:09 2019 +0000
- Revision:
- 0:fc80425b677a
Library
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
ngtkien | 0:fc80425b677a | 1 | /** |
ngtkien | 0:fc80425b677a | 2 | ****************************************************************************** |
ngtkien | 0:fc80425b677a | 3 | * @file ov9655.c |
ngtkien | 0:fc80425b677a | 4 | * @author MCD Application Team |
ngtkien | 0:fc80425b677a | 5 | * @version V1.0.0 |
ngtkien | 0:fc80425b677a | 6 | * @date 25-June-2015 |
ngtkien | 0:fc80425b677a | 7 | * @brief This file provides the OV9655 camera driver |
ngtkien | 0:fc80425b677a | 8 | ****************************************************************************** |
ngtkien | 0:fc80425b677a | 9 | * @attention |
ngtkien | 0:fc80425b677a | 10 | * |
ngtkien | 0:fc80425b677a | 11 | * <h2><center>© COPYRIGHT(c) 2015 STMicroelectronics</center></h2> |
ngtkien | 0:fc80425b677a | 12 | * |
ngtkien | 0:fc80425b677a | 13 | * Redistribution and use in source and binary forms, with or without modification, |
ngtkien | 0:fc80425b677a | 14 | * are permitted provided that the following conditions are met: |
ngtkien | 0:fc80425b677a | 15 | * 1. Redistributions of source code must retain the above copyright notice, |
ngtkien | 0:fc80425b677a | 16 | * this list of conditions and the following disclaimer. |
ngtkien | 0:fc80425b677a | 17 | * 2. Redistributions in binary form must reproduce the above copyright notice, |
ngtkien | 0:fc80425b677a | 18 | * this list of conditions and the following disclaimer in the documentation |
ngtkien | 0:fc80425b677a | 19 | * and/or other materials provided with the distribution. |
ngtkien | 0:fc80425b677a | 20 | * 3. Neither the name of STMicroelectronics nor the names of its contributors |
ngtkien | 0:fc80425b677a | 21 | * may be used to endorse or promote products derived from this software |
ngtkien | 0:fc80425b677a | 22 | * without specific prior written permission. |
ngtkien | 0:fc80425b677a | 23 | * |
ngtkien | 0:fc80425b677a | 24 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
ngtkien | 0:fc80425b677a | 25 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
ngtkien | 0:fc80425b677a | 26 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
ngtkien | 0:fc80425b677a | 27 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE |
ngtkien | 0:fc80425b677a | 28 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
ngtkien | 0:fc80425b677a | 29 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
ngtkien | 0:fc80425b677a | 30 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
ngtkien | 0:fc80425b677a | 31 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
ngtkien | 0:fc80425b677a | 32 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
ngtkien | 0:fc80425b677a | 33 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
ngtkien | 0:fc80425b677a | 34 | * |
ngtkien | 0:fc80425b677a | 35 | ****************************************************************************** |
ngtkien | 0:fc80425b677a | 36 | */ |
ngtkien | 0:fc80425b677a | 37 | |
ngtkien | 0:fc80425b677a | 38 | /* Includes ------------------------------------------------------------------*/ |
ngtkien | 0:fc80425b677a | 39 | #include "ov9655.h" |
ngtkien | 0:fc80425b677a | 40 | |
ngtkien | 0:fc80425b677a | 41 | /** @addtogroup BSP |
ngtkien | 0:fc80425b677a | 42 | * @{ |
ngtkien | 0:fc80425b677a | 43 | */ |
ngtkien | 0:fc80425b677a | 44 | |
ngtkien | 0:fc80425b677a | 45 | /** @addtogroup Components |
ngtkien | 0:fc80425b677a | 46 | * @{ |
ngtkien | 0:fc80425b677a | 47 | */ |
ngtkien | 0:fc80425b677a | 48 | |
ngtkien | 0:fc80425b677a | 49 | /** @addtogroup OV9655 |
ngtkien | 0:fc80425b677a | 50 | * @brief This file provides a set of functions needed to drive the |
ngtkien | 0:fc80425b677a | 51 | * OV9655 Camera module. |
ngtkien | 0:fc80425b677a | 52 | * @{ |
ngtkien | 0:fc80425b677a | 53 | */ |
ngtkien | 0:fc80425b677a | 54 | |
ngtkien | 0:fc80425b677a | 55 | /** @defgroup OV9655_Private_TypesDefinitions |
ngtkien | 0:fc80425b677a | 56 | * @{ |
ngtkien | 0:fc80425b677a | 57 | */ |
ngtkien | 0:fc80425b677a | 58 | |
ngtkien | 0:fc80425b677a | 59 | /** |
ngtkien | 0:fc80425b677a | 60 | * @} |
ngtkien | 0:fc80425b677a | 61 | */ |
ngtkien | 0:fc80425b677a | 62 | |
ngtkien | 0:fc80425b677a | 63 | /** @defgroup OV9655_Private_Defines |
ngtkien | 0:fc80425b677a | 64 | * @{ |
ngtkien | 0:fc80425b677a | 65 | */ |
ngtkien | 0:fc80425b677a | 66 | |
ngtkien | 0:fc80425b677a | 67 | /** |
ngtkien | 0:fc80425b677a | 68 | * @} |
ngtkien | 0:fc80425b677a | 69 | */ |
ngtkien | 0:fc80425b677a | 70 | |
ngtkien | 0:fc80425b677a | 71 | /** @defgroup OV9655_Private_Macros |
ngtkien | 0:fc80425b677a | 72 | * @{ |
ngtkien | 0:fc80425b677a | 73 | */ |
ngtkien | 0:fc80425b677a | 74 | |
ngtkien | 0:fc80425b677a | 75 | /** |
ngtkien | 0:fc80425b677a | 76 | * @} |
ngtkien | 0:fc80425b677a | 77 | */ |
ngtkien | 0:fc80425b677a | 78 | |
ngtkien | 0:fc80425b677a | 79 | /** @defgroup OV9655_Private_FunctionPrototypes |
ngtkien | 0:fc80425b677a | 80 | * @{ |
ngtkien | 0:fc80425b677a | 81 | */ |
ngtkien | 0:fc80425b677a | 82 | static uint64_t ov9655_ConvertValue(uint32_t feature, uint32_t value); |
ngtkien | 0:fc80425b677a | 83 | /** |
ngtkien | 0:fc80425b677a | 84 | * @} |
ngtkien | 0:fc80425b677a | 85 | */ |
ngtkien | 0:fc80425b677a | 86 | |
ngtkien | 0:fc80425b677a | 87 | /** @defgroup OV9655_Private_Variables |
ngtkien | 0:fc80425b677a | 88 | * @{ |
ngtkien | 0:fc80425b677a | 89 | */ |
ngtkien | 0:fc80425b677a | 90 | |
ngtkien | 0:fc80425b677a | 91 | CAMERA_DrvTypeDef ov9655_drv = |
ngtkien | 0:fc80425b677a | 92 | { |
ngtkien | 0:fc80425b677a | 93 | ov9655_Init, |
ngtkien | 0:fc80425b677a | 94 | ov9655_ReadID, |
ngtkien | 0:fc80425b677a | 95 | ov9655_Config, |
ngtkien | 0:fc80425b677a | 96 | }; |
ngtkien | 0:fc80425b677a | 97 | |
ngtkien | 0:fc80425b677a | 98 | /* Initialization sequence for VGA resolution (640x480)*/ |
ngtkien | 0:fc80425b677a | 99 | const unsigned char OV9655_VGA[][2]= |
ngtkien | 0:fc80425b677a | 100 | { |
ngtkien | 0:fc80425b677a | 101 | {0x00, 0x00}, |
ngtkien | 0:fc80425b677a | 102 | {0x01, 0x80}, |
ngtkien | 0:fc80425b677a | 103 | {0x02, 0x80}, |
ngtkien | 0:fc80425b677a | 104 | {0xb5, 0x00}, |
ngtkien | 0:fc80425b677a | 105 | {0x35, 0x00}, |
ngtkien | 0:fc80425b677a | 106 | {0xa8, 0xc1}, |
ngtkien | 0:fc80425b677a | 107 | {0x3a, 0xcc}, |
ngtkien | 0:fc80425b677a | 108 | {0x3d, 0x99}, |
ngtkien | 0:fc80425b677a | 109 | {0x77, 0x02}, |
ngtkien | 0:fc80425b677a | 110 | {0x13, 0xe7}, |
ngtkien | 0:fc80425b677a | 111 | {0x26, 0x72}, |
ngtkien | 0:fc80425b677a | 112 | {0x27, 0x08}, |
ngtkien | 0:fc80425b677a | 113 | {0x28, 0x08}, |
ngtkien | 0:fc80425b677a | 114 | {0x2c, 0x08}, |
ngtkien | 0:fc80425b677a | 115 | {0xab, 0x04}, |
ngtkien | 0:fc80425b677a | 116 | {0x6e, 0x00}, |
ngtkien | 0:fc80425b677a | 117 | {0x6d, 0x55}, |
ngtkien | 0:fc80425b677a | 118 | {0x00, 0x11}, |
ngtkien | 0:fc80425b677a | 119 | {0x10, 0x7b}, |
ngtkien | 0:fc80425b677a | 120 | {0xbb, 0xae}, |
ngtkien | 0:fc80425b677a | 121 | {0x11, 0x03}, |
ngtkien | 0:fc80425b677a | 122 | {0x72, 0x00}, |
ngtkien | 0:fc80425b677a | 123 | {0x3e, 0x0c}, |
ngtkien | 0:fc80425b677a | 124 | {0x74, 0x3a}, |
ngtkien | 0:fc80425b677a | 125 | {0x76, 0x01}, |
ngtkien | 0:fc80425b677a | 126 | {0x75, 0x35}, |
ngtkien | 0:fc80425b677a | 127 | {0x73, 0x00}, |
ngtkien | 0:fc80425b677a | 128 | {0xc7, 0x80}, |
ngtkien | 0:fc80425b677a | 129 | {0x62, 0x00}, |
ngtkien | 0:fc80425b677a | 130 | {0x63, 0x00}, |
ngtkien | 0:fc80425b677a | 131 | {0x64, 0x02}, |
ngtkien | 0:fc80425b677a | 132 | {0x65, 0x20}, |
ngtkien | 0:fc80425b677a | 133 | {0x66, 0x01}, |
ngtkien | 0:fc80425b677a | 134 | {0xc3, 0x4e}, |
ngtkien | 0:fc80425b677a | 135 | {0x33, 0x00}, |
ngtkien | 0:fc80425b677a | 136 | {0xa4, 0x50}, |
ngtkien | 0:fc80425b677a | 137 | {0xaa, 0x92}, |
ngtkien | 0:fc80425b677a | 138 | {0xc2, 0x01}, |
ngtkien | 0:fc80425b677a | 139 | {0xc1, 0xc8}, |
ngtkien | 0:fc80425b677a | 140 | {0x1e, 0x04}, |
ngtkien | 0:fc80425b677a | 141 | {0xa9, 0xef}, |
ngtkien | 0:fc80425b677a | 142 | {0x0e, 0x61}, |
ngtkien | 0:fc80425b677a | 143 | {0x39, 0x57}, |
ngtkien | 0:fc80425b677a | 144 | {0x0f, 0x48}, |
ngtkien | 0:fc80425b677a | 145 | {0x24, 0x3c}, |
ngtkien | 0:fc80425b677a | 146 | {0x25, 0x36}, |
ngtkien | 0:fc80425b677a | 147 | {0x12, 0x63}, |
ngtkien | 0:fc80425b677a | 148 | {0x03, 0x12}, |
ngtkien | 0:fc80425b677a | 149 | {0x32, 0xff}, |
ngtkien | 0:fc80425b677a | 150 | {0x17, 0x16}, |
ngtkien | 0:fc80425b677a | 151 | {0x18, 0x02}, |
ngtkien | 0:fc80425b677a | 152 | {0x19, 0x01}, |
ngtkien | 0:fc80425b677a | 153 | {0x1a, 0x3d}, |
ngtkien | 0:fc80425b677a | 154 | {0x36, 0xfa}, |
ngtkien | 0:fc80425b677a | 155 | {0x69, 0x0a}, |
ngtkien | 0:fc80425b677a | 156 | {0x8c, 0x8d}, |
ngtkien | 0:fc80425b677a | 157 | {0xc0, 0xaa}, |
ngtkien | 0:fc80425b677a | 158 | {0x40, 0xd0}, |
ngtkien | 0:fc80425b677a | 159 | {0x43, 0x14}, |
ngtkien | 0:fc80425b677a | 160 | {0x44, 0xf0}, |
ngtkien | 0:fc80425b677a | 161 | {0x45, 0x46}, |
ngtkien | 0:fc80425b677a | 162 | {0x46, 0x62}, |
ngtkien | 0:fc80425b677a | 163 | {0x47, 0x2a}, |
ngtkien | 0:fc80425b677a | 164 | {0x48, 0x3c}, |
ngtkien | 0:fc80425b677a | 165 | {0x59, 0x85}, |
ngtkien | 0:fc80425b677a | 166 | {0x5a, 0xa9}, |
ngtkien | 0:fc80425b677a | 167 | {0x5b, 0x64}, |
ngtkien | 0:fc80425b677a | 168 | {0x5c, 0x84}, |
ngtkien | 0:fc80425b677a | 169 | {0x5d, 0x53}, |
ngtkien | 0:fc80425b677a | 170 | {0x5e, 0x0e}, |
ngtkien | 0:fc80425b677a | 171 | {0x6c, 0x0c}, |
ngtkien | 0:fc80425b677a | 172 | {0xc6, 0x85}, |
ngtkien | 0:fc80425b677a | 173 | {0xcb, 0xf0}, |
ngtkien | 0:fc80425b677a | 174 | {0xcc, 0xd8}, |
ngtkien | 0:fc80425b677a | 175 | {0x71, 0x78}, |
ngtkien | 0:fc80425b677a | 176 | {0xa5, 0x68}, |
ngtkien | 0:fc80425b677a | 177 | {0x6f, 0x9e}, |
ngtkien | 0:fc80425b677a | 178 | {0x42, 0xc0}, |
ngtkien | 0:fc80425b677a | 179 | {0x3f, 0x82}, |
ngtkien | 0:fc80425b677a | 180 | {0x8a, 0x23}, |
ngtkien | 0:fc80425b677a | 181 | {0x14, 0x3a}, |
ngtkien | 0:fc80425b677a | 182 | {0x3b, 0xcc}, |
ngtkien | 0:fc80425b677a | 183 | {0x34, 0x3d}, |
ngtkien | 0:fc80425b677a | 184 | {0x41, 0x40}, |
ngtkien | 0:fc80425b677a | 185 | {0xc9, 0xe0}, |
ngtkien | 0:fc80425b677a | 186 | {0xca, 0xe8}, |
ngtkien | 0:fc80425b677a | 187 | {0xcd, 0x93}, |
ngtkien | 0:fc80425b677a | 188 | {0x7a, 0x20}, |
ngtkien | 0:fc80425b677a | 189 | {0x7b, 0x1c}, |
ngtkien | 0:fc80425b677a | 190 | {0x7c, 0x28}, |
ngtkien | 0:fc80425b677a | 191 | {0x7d, 0x3c}, |
ngtkien | 0:fc80425b677a | 192 | {0x7e, 0x5a}, |
ngtkien | 0:fc80425b677a | 193 | {0x7f, 0x68}, |
ngtkien | 0:fc80425b677a | 194 | {0x80, 0x76}, |
ngtkien | 0:fc80425b677a | 195 | {0x81, 0x80}, |
ngtkien | 0:fc80425b677a | 196 | {0x82, 0x88}, |
ngtkien | 0:fc80425b677a | 197 | {0x83, 0x8f}, |
ngtkien | 0:fc80425b677a | 198 | {0x84, 0x96}, |
ngtkien | 0:fc80425b677a | 199 | {0x85, 0xa3}, |
ngtkien | 0:fc80425b677a | 200 | {0x86, 0xaf}, |
ngtkien | 0:fc80425b677a | 201 | {0x87, 0xc4}, |
ngtkien | 0:fc80425b677a | 202 | {0x88, 0xd7}, |
ngtkien | 0:fc80425b677a | 203 | {0x89, 0xe8}, |
ngtkien | 0:fc80425b677a | 204 | {0x4f, 0x98}, |
ngtkien | 0:fc80425b677a | 205 | {0x50, 0x98}, |
ngtkien | 0:fc80425b677a | 206 | {0x51, 0x00}, |
ngtkien | 0:fc80425b677a | 207 | {0x52, 0x28}, |
ngtkien | 0:fc80425b677a | 208 | {0x53, 0x70}, |
ngtkien | 0:fc80425b677a | 209 | {0x54, 0x98}, |
ngtkien | 0:fc80425b677a | 210 | {0x58, 0x1a}, |
ngtkien | 0:fc80425b677a | 211 | {0x6b, 0x5a}, |
ngtkien | 0:fc80425b677a | 212 | {0x90, 0x92}, |
ngtkien | 0:fc80425b677a | 213 | {0x91, 0x92}, |
ngtkien | 0:fc80425b677a | 214 | {0x9f, 0x90}, |
ngtkien | 0:fc80425b677a | 215 | {0xa0, 0x90}, |
ngtkien | 0:fc80425b677a | 216 | {0x16, 0x24}, |
ngtkien | 0:fc80425b677a | 217 | {0x2a, 0x00}, |
ngtkien | 0:fc80425b677a | 218 | {0x2b, 0x00}, |
ngtkien | 0:fc80425b677a | 219 | {0xac, 0x80}, |
ngtkien | 0:fc80425b677a | 220 | {0xad, 0x80}, |
ngtkien | 0:fc80425b677a | 221 | {0xae, 0x80}, |
ngtkien | 0:fc80425b677a | 222 | {0xaf, 0x80}, |
ngtkien | 0:fc80425b677a | 223 | {0xb2, 0xf2}, |
ngtkien | 0:fc80425b677a | 224 | {0xb3, 0x20}, |
ngtkien | 0:fc80425b677a | 225 | {0xb4, 0x20}, |
ngtkien | 0:fc80425b677a | 226 | {0xb6, 0xaf}, |
ngtkien | 0:fc80425b677a | 227 | {0x29, 0x15}, |
ngtkien | 0:fc80425b677a | 228 | {0x9d, 0x02}, |
ngtkien | 0:fc80425b677a | 229 | {0x9e, 0x02}, |
ngtkien | 0:fc80425b677a | 230 | {0x9e, 0x02}, |
ngtkien | 0:fc80425b677a | 231 | {0x04, 0x03}, |
ngtkien | 0:fc80425b677a | 232 | {0x05, 0x2e}, |
ngtkien | 0:fc80425b677a | 233 | {0x06, 0x2e}, |
ngtkien | 0:fc80425b677a | 234 | {0x07, 0x2e}, |
ngtkien | 0:fc80425b677a | 235 | {0x08, 0x2e}, |
ngtkien | 0:fc80425b677a | 236 | {0x2f, 0x2e}, |
ngtkien | 0:fc80425b677a | 237 | {0x4a, 0xe9}, |
ngtkien | 0:fc80425b677a | 238 | {0x4b, 0xdd}, |
ngtkien | 0:fc80425b677a | 239 | {0x4c, 0xdd}, |
ngtkien | 0:fc80425b677a | 240 | {0x4d, 0xdd}, |
ngtkien | 0:fc80425b677a | 241 | {0x4e, 0xdd}, |
ngtkien | 0:fc80425b677a | 242 | {0x70, 0x06}, |
ngtkien | 0:fc80425b677a | 243 | {0xa6, 0x40}, |
ngtkien | 0:fc80425b677a | 244 | {0xbc, 0x02}, |
ngtkien | 0:fc80425b677a | 245 | {0xbd, 0x01}, |
ngtkien | 0:fc80425b677a | 246 | {0xbe, 0x02}, |
ngtkien | 0:fc80425b677a | 247 | {0xbf, 0x01}, |
ngtkien | 0:fc80425b677a | 248 | }; |
ngtkien | 0:fc80425b677a | 249 | |
ngtkien | 0:fc80425b677a | 250 | /* Initialization sequence for QVGA resolution (320x240) */ |
ngtkien | 0:fc80425b677a | 251 | const unsigned char OV9655_QVGA[][2]= |
ngtkien | 0:fc80425b677a | 252 | { |
ngtkien | 0:fc80425b677a | 253 | {0x00, 0x00}, |
ngtkien | 0:fc80425b677a | 254 | {0x01, 0x80}, |
ngtkien | 0:fc80425b677a | 255 | {0x02, 0x80}, |
ngtkien | 0:fc80425b677a | 256 | {0x03, 0x02}, |
ngtkien | 0:fc80425b677a | 257 | {0x04, 0x03}, |
ngtkien | 0:fc80425b677a | 258 | {0x09, 0x01}, |
ngtkien | 0:fc80425b677a | 259 | {0x0b, 0x57}, |
ngtkien | 0:fc80425b677a | 260 | {0x0e, 0x61}, |
ngtkien | 0:fc80425b677a | 261 | {0x0f, 0x40}, |
ngtkien | 0:fc80425b677a | 262 | {0x11, 0x01}, |
ngtkien | 0:fc80425b677a | 263 | {0x12, 0x62}, |
ngtkien | 0:fc80425b677a | 264 | {0x13, 0xc7}, |
ngtkien | 0:fc80425b677a | 265 | {0x14, 0x3a}, |
ngtkien | 0:fc80425b677a | 266 | {0x16, 0x24}, |
ngtkien | 0:fc80425b677a | 267 | {0x17, 0x18}, |
ngtkien | 0:fc80425b677a | 268 | {0x18, 0x04}, |
ngtkien | 0:fc80425b677a | 269 | {0x19, 0x01}, |
ngtkien | 0:fc80425b677a | 270 | {0x1a, 0x81}, |
ngtkien | 0:fc80425b677a | 271 | {0x1e, 0x00}, |
ngtkien | 0:fc80425b677a | 272 | {0x24, 0x3c}, |
ngtkien | 0:fc80425b677a | 273 | {0x25, 0x36}, |
ngtkien | 0:fc80425b677a | 274 | {0x26, 0x72}, |
ngtkien | 0:fc80425b677a | 275 | {0x27, 0x08}, |
ngtkien | 0:fc80425b677a | 276 | {0x28, 0x08}, |
ngtkien | 0:fc80425b677a | 277 | {0x29, 0x15}, |
ngtkien | 0:fc80425b677a | 278 | {0x2a, 0x00}, |
ngtkien | 0:fc80425b677a | 279 | {0x2b, 0x00}, |
ngtkien | 0:fc80425b677a | 280 | {0x2c, 0x08}, |
ngtkien | 0:fc80425b677a | 281 | {0x32, 0x12}, |
ngtkien | 0:fc80425b677a | 282 | {0x33, 0x00}, |
ngtkien | 0:fc80425b677a | 283 | {0x34, 0x3f}, |
ngtkien | 0:fc80425b677a | 284 | {0x35, 0x00}, |
ngtkien | 0:fc80425b677a | 285 | {0x36, 0x3a}, |
ngtkien | 0:fc80425b677a | 286 | {0x38, 0x72}, |
ngtkien | 0:fc80425b677a | 287 | {0x39, 0x57}, |
ngtkien | 0:fc80425b677a | 288 | {0x3a, 0xcc}, |
ngtkien | 0:fc80425b677a | 289 | {0x3b, 0x04}, |
ngtkien | 0:fc80425b677a | 290 | {0x3d, 0x99}, |
ngtkien | 0:fc80425b677a | 291 | {0x3e, 0x02}, |
ngtkien | 0:fc80425b677a | 292 | {0x3f, 0xc1}, |
ngtkien | 0:fc80425b677a | 293 | {0x40, 0xc0}, |
ngtkien | 0:fc80425b677a | 294 | {0x41, 0x41}, |
ngtkien | 0:fc80425b677a | 295 | {0x42, 0xc0}, |
ngtkien | 0:fc80425b677a | 296 | {0x43, 0x0a}, |
ngtkien | 0:fc80425b677a | 297 | {0x44, 0xf0}, |
ngtkien | 0:fc80425b677a | 298 | {0x45, 0x46}, |
ngtkien | 0:fc80425b677a | 299 | {0x46, 0x62}, |
ngtkien | 0:fc80425b677a | 300 | {0x47, 0x2a}, |
ngtkien | 0:fc80425b677a | 301 | {0x48, 0x3c}, |
ngtkien | 0:fc80425b677a | 302 | {0x4a, 0xfc}, |
ngtkien | 0:fc80425b677a | 303 | {0x4b, 0xfc}, |
ngtkien | 0:fc80425b677a | 304 | {0x4c, 0x7f}, |
ngtkien | 0:fc80425b677a | 305 | {0x4d, 0x7f}, |
ngtkien | 0:fc80425b677a | 306 | {0x4e, 0x7f}, |
ngtkien | 0:fc80425b677a | 307 | {0x4f, 0x98}, |
ngtkien | 0:fc80425b677a | 308 | {0x50, 0x98}, |
ngtkien | 0:fc80425b677a | 309 | {0x51, 0x00}, |
ngtkien | 0:fc80425b677a | 310 | {0x52, 0x28}, |
ngtkien | 0:fc80425b677a | 311 | {0x53, 0x70}, |
ngtkien | 0:fc80425b677a | 312 | {0x54, 0x98}, |
ngtkien | 0:fc80425b677a | 313 | {0x58, 0x1a}, |
ngtkien | 0:fc80425b677a | 314 | {0x59, 0x85}, |
ngtkien | 0:fc80425b677a | 315 | {0x5a, 0xa9}, |
ngtkien | 0:fc80425b677a | 316 | {0x5b, 0x64}, |
ngtkien | 0:fc80425b677a | 317 | {0x5c, 0x84}, |
ngtkien | 0:fc80425b677a | 318 | {0x5d, 0x53}, |
ngtkien | 0:fc80425b677a | 319 | {0x5e, 0x0e}, |
ngtkien | 0:fc80425b677a | 320 | {0x5f, 0xf0}, |
ngtkien | 0:fc80425b677a | 321 | {0x60, 0xf0}, |
ngtkien | 0:fc80425b677a | 322 | {0x61, 0xf0}, |
ngtkien | 0:fc80425b677a | 323 | {0x62, 0x00}, |
ngtkien | 0:fc80425b677a | 324 | {0x63, 0x00}, |
ngtkien | 0:fc80425b677a | 325 | {0x64, 0x02}, |
ngtkien | 0:fc80425b677a | 326 | {0x65, 0x20}, |
ngtkien | 0:fc80425b677a | 327 | {0x66, 0x00}, |
ngtkien | 0:fc80425b677a | 328 | {0x69, 0x0a}, |
ngtkien | 0:fc80425b677a | 329 | {0x6b, 0x5a}, |
ngtkien | 0:fc80425b677a | 330 | {0x6c, 0x04}, |
ngtkien | 0:fc80425b677a | 331 | {0x6d, 0x55}, |
ngtkien | 0:fc80425b677a | 332 | {0x6e, 0x00}, |
ngtkien | 0:fc80425b677a | 333 | {0x6f, 0x9d}, |
ngtkien | 0:fc80425b677a | 334 | {0x70, 0x21}, |
ngtkien | 0:fc80425b677a | 335 | {0x71, 0x78}, |
ngtkien | 0:fc80425b677a | 336 | {0x72, 0x11}, |
ngtkien | 0:fc80425b677a | 337 | {0x73, 0x01}, |
ngtkien | 0:fc80425b677a | 338 | {0x74, 0x10}, |
ngtkien | 0:fc80425b677a | 339 | {0x75, 0x10}, |
ngtkien | 0:fc80425b677a | 340 | {0x76, 0x01}, |
ngtkien | 0:fc80425b677a | 341 | {0x77, 0x02}, |
ngtkien | 0:fc80425b677a | 342 | {0x7A, 0x12}, |
ngtkien | 0:fc80425b677a | 343 | {0x7B, 0x08}, |
ngtkien | 0:fc80425b677a | 344 | {0x7C, 0x16}, |
ngtkien | 0:fc80425b677a | 345 | {0x7D, 0x30}, |
ngtkien | 0:fc80425b677a | 346 | {0x7E, 0x5e}, |
ngtkien | 0:fc80425b677a | 347 | {0x7F, 0x72}, |
ngtkien | 0:fc80425b677a | 348 | {0x80, 0x82}, |
ngtkien | 0:fc80425b677a | 349 | {0x81, 0x8e}, |
ngtkien | 0:fc80425b677a | 350 | {0x82, 0x9a}, |
ngtkien | 0:fc80425b677a | 351 | {0x83, 0xa4}, |
ngtkien | 0:fc80425b677a | 352 | {0x84, 0xac}, |
ngtkien | 0:fc80425b677a | 353 | {0x85, 0xb8}, |
ngtkien | 0:fc80425b677a | 354 | {0x86, 0xc3}, |
ngtkien | 0:fc80425b677a | 355 | {0x87, 0xd6}, |
ngtkien | 0:fc80425b677a | 356 | {0x88, 0xe6}, |
ngtkien | 0:fc80425b677a | 357 | {0x89, 0xf2}, |
ngtkien | 0:fc80425b677a | 358 | {0x8a, 0x24}, |
ngtkien | 0:fc80425b677a | 359 | {0x8c, 0x80}, |
ngtkien | 0:fc80425b677a | 360 | {0x90, 0x7d}, |
ngtkien | 0:fc80425b677a | 361 | {0x91, 0x7b}, |
ngtkien | 0:fc80425b677a | 362 | {0x9d, 0x02}, |
ngtkien | 0:fc80425b677a | 363 | {0x9e, 0x02}, |
ngtkien | 0:fc80425b677a | 364 | {0x9f, 0x7a}, |
ngtkien | 0:fc80425b677a | 365 | {0xa0, 0x79}, |
ngtkien | 0:fc80425b677a | 366 | {0xa1, 0x40}, |
ngtkien | 0:fc80425b677a | 367 | {0xa4, 0x50}, |
ngtkien | 0:fc80425b677a | 368 | {0xa5, 0x68}, |
ngtkien | 0:fc80425b677a | 369 | {0xa6, 0x4a}, |
ngtkien | 0:fc80425b677a | 370 | {0xa8, 0xc1}, |
ngtkien | 0:fc80425b677a | 371 | {0xa9, 0xef}, |
ngtkien | 0:fc80425b677a | 372 | {0xaa, 0x92}, |
ngtkien | 0:fc80425b677a | 373 | {0xab, 0x04}, |
ngtkien | 0:fc80425b677a | 374 | {0xac, 0x80}, |
ngtkien | 0:fc80425b677a | 375 | {0xad, 0x80}, |
ngtkien | 0:fc80425b677a | 376 | {0xae, 0x80}, |
ngtkien | 0:fc80425b677a | 377 | {0xaf, 0x80}, |
ngtkien | 0:fc80425b677a | 378 | {0xb2, 0xf2}, |
ngtkien | 0:fc80425b677a | 379 | {0xb3, 0x20}, |
ngtkien | 0:fc80425b677a | 380 | {0xb4, 0x20}, |
ngtkien | 0:fc80425b677a | 381 | {0xb5, 0x00}, |
ngtkien | 0:fc80425b677a | 382 | {0xb6, 0xaf}, |
ngtkien | 0:fc80425b677a | 383 | {0xb6, 0xaf}, |
ngtkien | 0:fc80425b677a | 384 | {0xbb, 0xae}, |
ngtkien | 0:fc80425b677a | 385 | {0xbc, 0x7f}, |
ngtkien | 0:fc80425b677a | 386 | {0xbd, 0x7f}, |
ngtkien | 0:fc80425b677a | 387 | {0xbe, 0x7f}, |
ngtkien | 0:fc80425b677a | 388 | {0xbf, 0x7f}, |
ngtkien | 0:fc80425b677a | 389 | {0xbf, 0x7f}, |
ngtkien | 0:fc80425b677a | 390 | {0xc0, 0xaa}, |
ngtkien | 0:fc80425b677a | 391 | {0xc1, 0xc0}, |
ngtkien | 0:fc80425b677a | 392 | {0xc2, 0x01}, |
ngtkien | 0:fc80425b677a | 393 | {0xc3, 0x4e}, |
ngtkien | 0:fc80425b677a | 394 | {0xc6, 0x05}, |
ngtkien | 0:fc80425b677a | 395 | {0xc7, 0x81}, |
ngtkien | 0:fc80425b677a | 396 | {0xc9, 0xe0}, |
ngtkien | 0:fc80425b677a | 397 | {0xca, 0xe8}, |
ngtkien | 0:fc80425b677a | 398 | {0xcb, 0xf0}, |
ngtkien | 0:fc80425b677a | 399 | {0xcc, 0xd8}, |
ngtkien | 0:fc80425b677a | 400 | {0xcd, 0x93}, |
ngtkien | 0:fc80425b677a | 401 | {0x12, 0x63}, |
ngtkien | 0:fc80425b677a | 402 | {0x40, 0x10}, |
ngtkien | 0:fc80425b677a | 403 | }; |
ngtkien | 0:fc80425b677a | 404 | |
ngtkien | 0:fc80425b677a | 405 | /* Initialization sequence for QQVGA resolution (160x120) */ |
ngtkien | 0:fc80425b677a | 406 | const char OV9655_QQVGA[][2]= |
ngtkien | 0:fc80425b677a | 407 | { |
ngtkien | 0:fc80425b677a | 408 | {0x00, 0x00}, |
ngtkien | 0:fc80425b677a | 409 | {0x01, 0x80}, |
ngtkien | 0:fc80425b677a | 410 | {0x02, 0x80}, |
ngtkien | 0:fc80425b677a | 411 | {0x03, 0x02}, |
ngtkien | 0:fc80425b677a | 412 | {0x04, 0x03}, |
ngtkien | 0:fc80425b677a | 413 | {0x09, 0x01}, |
ngtkien | 0:fc80425b677a | 414 | {0x0b, 0x57}, |
ngtkien | 0:fc80425b677a | 415 | {0x0e, 0x61}, |
ngtkien | 0:fc80425b677a | 416 | {0x0f, 0x40}, |
ngtkien | 0:fc80425b677a | 417 | {0x11, 0x01}, |
ngtkien | 0:fc80425b677a | 418 | {0x12, 0x62}, |
ngtkien | 0:fc80425b677a | 419 | {0x13, 0xc7}, |
ngtkien | 0:fc80425b677a | 420 | {0x14, 0x3a}, |
ngtkien | 0:fc80425b677a | 421 | {0x16, 0x24}, |
ngtkien | 0:fc80425b677a | 422 | {0x17, 0x18}, |
ngtkien | 0:fc80425b677a | 423 | {0x18, 0x04}, |
ngtkien | 0:fc80425b677a | 424 | {0x19, 0x01}, |
ngtkien | 0:fc80425b677a | 425 | {0x1a, 0x81}, |
ngtkien | 0:fc80425b677a | 426 | {0x1e, 0x00}, |
ngtkien | 0:fc80425b677a | 427 | {0x24, 0x3c}, |
ngtkien | 0:fc80425b677a | 428 | {0x25, 0x36}, |
ngtkien | 0:fc80425b677a | 429 | {0x26, 0x72}, |
ngtkien | 0:fc80425b677a | 430 | {0x27, 0x08}, |
ngtkien | 0:fc80425b677a | 431 | {0x28, 0x08}, |
ngtkien | 0:fc80425b677a | 432 | {0x29, 0x15}, |
ngtkien | 0:fc80425b677a | 433 | {0x2a, 0x00}, |
ngtkien | 0:fc80425b677a | 434 | {0x2b, 0x00}, |
ngtkien | 0:fc80425b677a | 435 | {0x2c, 0x08}, |
ngtkien | 0:fc80425b677a | 436 | {0x32, 0xa4}, |
ngtkien | 0:fc80425b677a | 437 | {0x33, 0x00}, |
ngtkien | 0:fc80425b677a | 438 | {0x34, 0x3f}, |
ngtkien | 0:fc80425b677a | 439 | {0x35, 0x00}, |
ngtkien | 0:fc80425b677a | 440 | {0x36, 0x3a}, |
ngtkien | 0:fc80425b677a | 441 | {0x38, 0x72}, |
ngtkien | 0:fc80425b677a | 442 | {0x39, 0x57}, |
ngtkien | 0:fc80425b677a | 443 | {0x3a, 0xcc}, |
ngtkien | 0:fc80425b677a | 444 | {0x3b, 0x04}, |
ngtkien | 0:fc80425b677a | 445 | {0x3d, 0x99}, |
ngtkien | 0:fc80425b677a | 446 | {0x3e, 0x0e}, |
ngtkien | 0:fc80425b677a | 447 | {0x3f, 0xc1}, |
ngtkien | 0:fc80425b677a | 448 | {0x40, 0xc0}, |
ngtkien | 0:fc80425b677a | 449 | {0x41, 0x41}, |
ngtkien | 0:fc80425b677a | 450 | {0x42, 0xc0}, |
ngtkien | 0:fc80425b677a | 451 | {0x43, 0x0a}, |
ngtkien | 0:fc80425b677a | 452 | {0x44, 0xf0}, |
ngtkien | 0:fc80425b677a | 453 | {0x45, 0x46}, |
ngtkien | 0:fc80425b677a | 454 | {0x46, 0x62}, |
ngtkien | 0:fc80425b677a | 455 | {0x47, 0x2a}, |
ngtkien | 0:fc80425b677a | 456 | {0x48, 0x3c}, |
ngtkien | 0:fc80425b677a | 457 | {0x4a, 0xfc}, |
ngtkien | 0:fc80425b677a | 458 | {0x4b, 0xfc}, |
ngtkien | 0:fc80425b677a | 459 | {0x4c, 0x7f}, |
ngtkien | 0:fc80425b677a | 460 | {0x4d, 0x7f}, |
ngtkien | 0:fc80425b677a | 461 | {0x4e, 0x7f}, |
ngtkien | 0:fc80425b677a | 462 | {0x4f, 0x98}, |
ngtkien | 0:fc80425b677a | 463 | {0x50, 0x98}, |
ngtkien | 0:fc80425b677a | 464 | {0x51, 0x00}, |
ngtkien | 0:fc80425b677a | 465 | {0x52, 0x28}, |
ngtkien | 0:fc80425b677a | 466 | {0x53, 0x70}, |
ngtkien | 0:fc80425b677a | 467 | {0x54, 0x98}, |
ngtkien | 0:fc80425b677a | 468 | {0x58, 0x1a}, |
ngtkien | 0:fc80425b677a | 469 | {0x59, 0x85}, |
ngtkien | 0:fc80425b677a | 470 | {0x5a, 0xa9}, |
ngtkien | 0:fc80425b677a | 471 | {0x5b, 0x64}, |
ngtkien | 0:fc80425b677a | 472 | {0x5c, 0x84}, |
ngtkien | 0:fc80425b677a | 473 | {0x5d, 0x53}, |
ngtkien | 0:fc80425b677a | 474 | {0x5e, 0x0e}, |
ngtkien | 0:fc80425b677a | 475 | {0x5f, 0xf0}, |
ngtkien | 0:fc80425b677a | 476 | {0x60, 0xf0}, |
ngtkien | 0:fc80425b677a | 477 | {0x61, 0xf0}, |
ngtkien | 0:fc80425b677a | 478 | {0x62, 0x00}, |
ngtkien | 0:fc80425b677a | 479 | {0x63, 0x00}, |
ngtkien | 0:fc80425b677a | 480 | {0x64, 0x02}, |
ngtkien | 0:fc80425b677a | 481 | {0x65, 0x20}, |
ngtkien | 0:fc80425b677a | 482 | {0x66, 0x00}, |
ngtkien | 0:fc80425b677a | 483 | {0x69, 0x0a}, |
ngtkien | 0:fc80425b677a | 484 | {0x6b, 0x5a}, |
ngtkien | 0:fc80425b677a | 485 | {0x6c, 0x04}, |
ngtkien | 0:fc80425b677a | 486 | {0x6d, 0x55}, |
ngtkien | 0:fc80425b677a | 487 | {0x6e, 0x00}, |
ngtkien | 0:fc80425b677a | 488 | {0x6f, 0x9d}, |
ngtkien | 0:fc80425b677a | 489 | {0x70, 0x21}, |
ngtkien | 0:fc80425b677a | 490 | {0x71, 0x78}, |
ngtkien | 0:fc80425b677a | 491 | {0x72, 0x22}, |
ngtkien | 0:fc80425b677a | 492 | {0x73, 0x02}, |
ngtkien | 0:fc80425b677a | 493 | {0x74, 0x10}, |
ngtkien | 0:fc80425b677a | 494 | {0x75, 0x10}, |
ngtkien | 0:fc80425b677a | 495 | {0x76, 0x01}, |
ngtkien | 0:fc80425b677a | 496 | {0x77, 0x02}, |
ngtkien | 0:fc80425b677a | 497 | {0x7A, 0x12}, |
ngtkien | 0:fc80425b677a | 498 | {0x7B, 0x08}, |
ngtkien | 0:fc80425b677a | 499 | {0x7C, 0x16}, |
ngtkien | 0:fc80425b677a | 500 | {0x7D, 0x30}, |
ngtkien | 0:fc80425b677a | 501 | {0x7E, 0x5e}, |
ngtkien | 0:fc80425b677a | 502 | {0x7F, 0x72}, |
ngtkien | 0:fc80425b677a | 503 | {0x80, 0x82}, |
ngtkien | 0:fc80425b677a | 504 | {0x81, 0x8e}, |
ngtkien | 0:fc80425b677a | 505 | {0x82, 0x9a}, |
ngtkien | 0:fc80425b677a | 506 | {0x83, 0xa4}, |
ngtkien | 0:fc80425b677a | 507 | {0x84, 0xac}, |
ngtkien | 0:fc80425b677a | 508 | {0x85, 0xb8}, |
ngtkien | 0:fc80425b677a | 509 | {0x86, 0xc3}, |
ngtkien | 0:fc80425b677a | 510 | {0x87, 0xd6}, |
ngtkien | 0:fc80425b677a | 511 | {0x88, 0xe6}, |
ngtkien | 0:fc80425b677a | 512 | {0x89, 0xf2}, |
ngtkien | 0:fc80425b677a | 513 | {0x8a, 0x24}, |
ngtkien | 0:fc80425b677a | 514 | {0x8c, 0x80}, |
ngtkien | 0:fc80425b677a | 515 | {0x90, 0x7d}, |
ngtkien | 0:fc80425b677a | 516 | {0x91, 0x7b}, |
ngtkien | 0:fc80425b677a | 517 | {0x9d, 0x02}, |
ngtkien | 0:fc80425b677a | 518 | {0x9e, 0x02}, |
ngtkien | 0:fc80425b677a | 519 | {0x9f, 0x7a}, |
ngtkien | 0:fc80425b677a | 520 | {0xa0, 0x79}, |
ngtkien | 0:fc80425b677a | 521 | {0xa1, 0x40}, |
ngtkien | 0:fc80425b677a | 522 | {0xa4, 0x50}, |
ngtkien | 0:fc80425b677a | 523 | {0xa5, 0x68}, |
ngtkien | 0:fc80425b677a | 524 | {0xa6, 0x4a}, |
ngtkien | 0:fc80425b677a | 525 | {0xa8, 0xc1}, |
ngtkien | 0:fc80425b677a | 526 | {0xa9, 0xef}, |
ngtkien | 0:fc80425b677a | 527 | {0xaa, 0x92}, |
ngtkien | 0:fc80425b677a | 528 | {0xab, 0x04}, |
ngtkien | 0:fc80425b677a | 529 | {0xac, 0x80}, |
ngtkien | 0:fc80425b677a | 530 | {0xad, 0x80}, |
ngtkien | 0:fc80425b677a | 531 | {0xae, 0x80}, |
ngtkien | 0:fc80425b677a | 532 | {0xaf, 0x80}, |
ngtkien | 0:fc80425b677a | 533 | {0xb2, 0xf2}, |
ngtkien | 0:fc80425b677a | 534 | {0xb3, 0x20}, |
ngtkien | 0:fc80425b677a | 535 | {0xb4, 0x20}, |
ngtkien | 0:fc80425b677a | 536 | {0xb5, 0x00}, |
ngtkien | 0:fc80425b677a | 537 | {0xb6, 0xaf}, |
ngtkien | 0:fc80425b677a | 538 | {0xb6, 0xaf}, |
ngtkien | 0:fc80425b677a | 539 | {0xbb, 0xae}, |
ngtkien | 0:fc80425b677a | 540 | {0xbc, 0x7f}, |
ngtkien | 0:fc80425b677a | 541 | {0xbd, 0x7f}, |
ngtkien | 0:fc80425b677a | 542 | {0xbe, 0x7f}, |
ngtkien | 0:fc80425b677a | 543 | {0xbf, 0x7f}, |
ngtkien | 0:fc80425b677a | 544 | {0xbf, 0x7f}, |
ngtkien | 0:fc80425b677a | 545 | {0xc0, 0xaa}, |
ngtkien | 0:fc80425b677a | 546 | {0xc1, 0xc0}, |
ngtkien | 0:fc80425b677a | 547 | {0xc2, 0x01}, |
ngtkien | 0:fc80425b677a | 548 | {0xc3, 0x4e}, |
ngtkien | 0:fc80425b677a | 549 | {0xc6, 0x05}, |
ngtkien | 0:fc80425b677a | 550 | {0xc7, 0x82}, |
ngtkien | 0:fc80425b677a | 551 | {0xc9, 0xe0}, |
ngtkien | 0:fc80425b677a | 552 | {0xca, 0xe8}, |
ngtkien | 0:fc80425b677a | 553 | {0xcb, 0xf0}, |
ngtkien | 0:fc80425b677a | 554 | {0xcc, 0xd8}, |
ngtkien | 0:fc80425b677a | 555 | {0xcd, 0x93}, |
ngtkien | 0:fc80425b677a | 556 | {0x12, 0x63}, |
ngtkien | 0:fc80425b677a | 557 | {0x40, 0x10}, |
ngtkien | 0:fc80425b677a | 558 | }; |
ngtkien | 0:fc80425b677a | 559 | |
ngtkien | 0:fc80425b677a | 560 | /** |
ngtkien | 0:fc80425b677a | 561 | * @} |
ngtkien | 0:fc80425b677a | 562 | */ |
ngtkien | 0:fc80425b677a | 563 | |
ngtkien | 0:fc80425b677a | 564 | /** @defgroup OV9655_Private_Functions |
ngtkien | 0:fc80425b677a | 565 | * @{ |
ngtkien | 0:fc80425b677a | 566 | */ |
ngtkien | 0:fc80425b677a | 567 | |
ngtkien | 0:fc80425b677a | 568 | /** |
ngtkien | 0:fc80425b677a | 569 | * @brief Initializes the OV9655 CAMERA component. |
ngtkien | 0:fc80425b677a | 570 | * @param DeviceAddr: Device address on communication Bus. |
ngtkien | 0:fc80425b677a | 571 | * @param resolution: Camera resolution |
ngtkien | 0:fc80425b677a | 572 | * @retval None |
ngtkien | 0:fc80425b677a | 573 | */ |
ngtkien | 0:fc80425b677a | 574 | void ov9655_Init(uint16_t DeviceAddr, uint32_t resolution) |
ngtkien | 0:fc80425b677a | 575 | { |
ngtkien | 0:fc80425b677a | 576 | uint32_t index; |
ngtkien | 0:fc80425b677a | 577 | |
ngtkien | 0:fc80425b677a | 578 | /* Initialize I2C */ |
ngtkien | 0:fc80425b677a | 579 | CAMERA_IO_Init(); |
ngtkien | 0:fc80425b677a | 580 | |
ngtkien | 0:fc80425b677a | 581 | /* Prepare the camera to be configured by resetting all its registers */ |
ngtkien | 0:fc80425b677a | 582 | CAMERA_IO_Write(DeviceAddr, OV9655_SENSOR_COM7, 0x80); |
ngtkien | 0:fc80425b677a | 583 | CAMERA_Delay(200); |
ngtkien | 0:fc80425b677a | 584 | |
ngtkien | 0:fc80425b677a | 585 | /* Initialize OV9655 */ |
ngtkien | 0:fc80425b677a | 586 | switch (resolution) |
ngtkien | 0:fc80425b677a | 587 | { |
ngtkien | 0:fc80425b677a | 588 | case CAMERA_R160x120: |
ngtkien | 0:fc80425b677a | 589 | { |
ngtkien | 0:fc80425b677a | 590 | for(index=0; index<(sizeof(OV9655_QQVGA)/2); index++) |
ngtkien | 0:fc80425b677a | 591 | { |
ngtkien | 0:fc80425b677a | 592 | CAMERA_IO_Write(DeviceAddr, OV9655_QQVGA[index][0], OV9655_QQVGA[index][1]); |
ngtkien | 0:fc80425b677a | 593 | CAMERA_Delay(2); |
ngtkien | 0:fc80425b677a | 594 | } |
ngtkien | 0:fc80425b677a | 595 | break; |
ngtkien | 0:fc80425b677a | 596 | } |
ngtkien | 0:fc80425b677a | 597 | case CAMERA_R320x240: |
ngtkien | 0:fc80425b677a | 598 | { |
ngtkien | 0:fc80425b677a | 599 | for(index=0; index<(sizeof(OV9655_QVGA)/2); index++) |
ngtkien | 0:fc80425b677a | 600 | { |
ngtkien | 0:fc80425b677a | 601 | CAMERA_IO_Write(DeviceAddr, OV9655_QVGA[index][0], OV9655_QVGA[index][1]); |
ngtkien | 0:fc80425b677a | 602 | CAMERA_Delay(2); |
ngtkien | 0:fc80425b677a | 603 | } |
ngtkien | 0:fc80425b677a | 604 | break; |
ngtkien | 0:fc80425b677a | 605 | } |
ngtkien | 0:fc80425b677a | 606 | case CAMERA_R480x272: |
ngtkien | 0:fc80425b677a | 607 | { |
ngtkien | 0:fc80425b677a | 608 | /* Not supported resolution */ |
ngtkien | 0:fc80425b677a | 609 | break; |
ngtkien | 0:fc80425b677a | 610 | } |
ngtkien | 0:fc80425b677a | 611 | case CAMERA_R640x480: |
ngtkien | 0:fc80425b677a | 612 | { |
ngtkien | 0:fc80425b677a | 613 | for(index=0; index<(sizeof(OV9655_VGA)/2); index++) |
ngtkien | 0:fc80425b677a | 614 | { |
ngtkien | 0:fc80425b677a | 615 | CAMERA_IO_Write(DeviceAddr, OV9655_VGA[index][0], OV9655_VGA[index][1]); |
ngtkien | 0:fc80425b677a | 616 | CAMERA_Delay(2); |
ngtkien | 0:fc80425b677a | 617 | } |
ngtkien | 0:fc80425b677a | 618 | break; |
ngtkien | 0:fc80425b677a | 619 | } |
ngtkien | 0:fc80425b677a | 620 | default: |
ngtkien | 0:fc80425b677a | 621 | { |
ngtkien | 0:fc80425b677a | 622 | break; |
ngtkien | 0:fc80425b677a | 623 | } |
ngtkien | 0:fc80425b677a | 624 | } |
ngtkien | 0:fc80425b677a | 625 | } |
ngtkien | 0:fc80425b677a | 626 | |
ngtkien | 0:fc80425b677a | 627 | /** |
ngtkien | 0:fc80425b677a | 628 | * @brief Configures the OV9655 camera feature. |
ngtkien | 0:fc80425b677a | 629 | * @param DeviceAddr: Device address on communication Bus. |
ngtkien | 0:fc80425b677a | 630 | * @param feature: Camera feature to be configured |
ngtkien | 0:fc80425b677a | 631 | * @param value: Value to be configured |
ngtkien | 0:fc80425b677a | 632 | * @param brightness_value: Brightness value to be configured |
ngtkien | 0:fc80425b677a | 633 | * @retval None |
ngtkien | 0:fc80425b677a | 634 | */ |
ngtkien | 0:fc80425b677a | 635 | void ov9655_Config(uint16_t DeviceAddr, uint32_t feature, uint32_t value, uint32_t brightness_value) |
ngtkien | 0:fc80425b677a | 636 | { |
ngtkien | 0:fc80425b677a | 637 | uint8_t tslb, mtx1, mtx2, mtx3, mtx4, mtx5, mtx6; |
ngtkien | 0:fc80425b677a | 638 | uint64_t value_tmp; |
ngtkien | 0:fc80425b677a | 639 | uint32_t br_value; |
ngtkien | 0:fc80425b677a | 640 | |
ngtkien | 0:fc80425b677a | 641 | /* Convert the input value into ov9655 parameters */ |
ngtkien | 0:fc80425b677a | 642 | value_tmp = ov9655_ConvertValue(feature, value); |
ngtkien | 0:fc80425b677a | 643 | br_value = (uint32_t)ov9655_ConvertValue(CAMERA_CONTRAST_BRIGHTNESS, brightness_value); |
ngtkien | 0:fc80425b677a | 644 | |
ngtkien | 0:fc80425b677a | 645 | switch(feature) |
ngtkien | 0:fc80425b677a | 646 | { |
ngtkien | 0:fc80425b677a | 647 | case CAMERA_CONTRAST_BRIGHTNESS: |
ngtkien | 0:fc80425b677a | 648 | { |
ngtkien | 0:fc80425b677a | 649 | CAMERA_IO_Write(DeviceAddr, OV9655_SENSOR_BRTN, br_value); |
ngtkien | 0:fc80425b677a | 650 | CAMERA_IO_Write(DeviceAddr, OV9655_SENSOR_CNST1, value_tmp); |
ngtkien | 0:fc80425b677a | 651 | break; |
ngtkien | 0:fc80425b677a | 652 | } |
ngtkien | 0:fc80425b677a | 653 | case CAMERA_BLACK_WHITE: |
ngtkien | 0:fc80425b677a | 654 | case CAMERA_COLOR_EFFECT: |
ngtkien | 0:fc80425b677a | 655 | { |
ngtkien | 0:fc80425b677a | 656 | tslb = (uint8_t)(value_tmp >> 48); |
ngtkien | 0:fc80425b677a | 657 | mtx1 = (uint8_t)(value_tmp >> 40); |
ngtkien | 0:fc80425b677a | 658 | mtx2 = (uint8_t)(value_tmp >> 32); |
ngtkien | 0:fc80425b677a | 659 | mtx3 = (uint8_t)(value_tmp >> 24); |
ngtkien | 0:fc80425b677a | 660 | mtx4 = (uint8_t)(value_tmp >> 16); |
ngtkien | 0:fc80425b677a | 661 | mtx5 = (uint8_t)(value_tmp >> 8); |
ngtkien | 0:fc80425b677a | 662 | mtx6 = (uint8_t)(value_tmp); |
ngtkien | 0:fc80425b677a | 663 | CAMERA_IO_Write(DeviceAddr, OV9655_SENSOR_TSLB, tslb); |
ngtkien | 0:fc80425b677a | 664 | CAMERA_IO_Write(DeviceAddr, OV9655_SENSOR_MTX1, mtx1); |
ngtkien | 0:fc80425b677a | 665 | CAMERA_IO_Write(DeviceAddr, OV9655_SENSOR_MTX2, mtx2); |
ngtkien | 0:fc80425b677a | 666 | CAMERA_IO_Write(DeviceAddr, OV9655_SENSOR_MTX3, mtx3); |
ngtkien | 0:fc80425b677a | 667 | CAMERA_IO_Write(DeviceAddr, OV9655_SENSOR_MTX4, mtx4); |
ngtkien | 0:fc80425b677a | 668 | CAMERA_IO_Write(DeviceAddr, OV9655_SENSOR_MTX5, mtx5); |
ngtkien | 0:fc80425b677a | 669 | CAMERA_IO_Write(DeviceAddr, OV9655_SENSOR_MTX6, mtx6); |
ngtkien | 0:fc80425b677a | 670 | break; |
ngtkien | 0:fc80425b677a | 671 | } |
ngtkien | 0:fc80425b677a | 672 | default: |
ngtkien | 0:fc80425b677a | 673 | { |
ngtkien | 0:fc80425b677a | 674 | break; |
ngtkien | 0:fc80425b677a | 675 | } |
ngtkien | 0:fc80425b677a | 676 | } |
ngtkien | 0:fc80425b677a | 677 | } |
ngtkien | 0:fc80425b677a | 678 | |
ngtkien | 0:fc80425b677a | 679 | /** |
ngtkien | 0:fc80425b677a | 680 | * @brief Read the OV9655 Camera identity. |
ngtkien | 0:fc80425b677a | 681 | * @param DeviceAddr: Device address on communication Bus. |
ngtkien | 0:fc80425b677a | 682 | * @retval the OV9655 ID |
ngtkien | 0:fc80425b677a | 683 | */ |
ngtkien | 0:fc80425b677a | 684 | uint16_t ov9655_ReadID(uint16_t DeviceAddr) |
ngtkien | 0:fc80425b677a | 685 | { |
ngtkien | 0:fc80425b677a | 686 | /* Initialize I2C */ |
ngtkien | 0:fc80425b677a | 687 | CAMERA_IO_Init(); |
ngtkien | 0:fc80425b677a | 688 | |
ngtkien | 0:fc80425b677a | 689 | /* Get the camera ID */ |
ngtkien | 0:fc80425b677a | 690 | return (CAMERA_IO_Read(DeviceAddr, OV9655_SENSOR_PIDH)); |
ngtkien | 0:fc80425b677a | 691 | } |
ngtkien | 0:fc80425b677a | 692 | |
ngtkien | 0:fc80425b677a | 693 | /****************************************************************************** |
ngtkien | 0:fc80425b677a | 694 | Static Functions |
ngtkien | 0:fc80425b677a | 695 | *******************************************************************************/ |
ngtkien | 0:fc80425b677a | 696 | /** |
ngtkien | 0:fc80425b677a | 697 | * @brief Convert input values into ov9655 parameters. |
ngtkien | 0:fc80425b677a | 698 | * @param feature: Camera feature to be configured |
ngtkien | 0:fc80425b677a | 699 | * @param value: Value to be configured |
ngtkien | 0:fc80425b677a | 700 | * @retval The converted value |
ngtkien | 0:fc80425b677a | 701 | */ |
ngtkien | 0:fc80425b677a | 702 | static uint64_t ov9655_ConvertValue(uint32_t feature, uint32_t value) |
ngtkien | 0:fc80425b677a | 703 | { |
ngtkien | 0:fc80425b677a | 704 | uint64_t ret = 0; |
ngtkien | 0:fc80425b677a | 705 | |
ngtkien | 0:fc80425b677a | 706 | switch(feature) |
ngtkien | 0:fc80425b677a | 707 | { |
ngtkien | 0:fc80425b677a | 708 | case CAMERA_BLACK_WHITE: |
ngtkien | 0:fc80425b677a | 709 | { |
ngtkien | 0:fc80425b677a | 710 | switch(value) |
ngtkien | 0:fc80425b677a | 711 | { |
ngtkien | 0:fc80425b677a | 712 | case CAMERA_BLACK_WHITE_BW: |
ngtkien | 0:fc80425b677a | 713 | { |
ngtkien | 0:fc80425b677a | 714 | ret = OV9655_BLACK_WHITE_BW; |
ngtkien | 0:fc80425b677a | 715 | break; |
ngtkien | 0:fc80425b677a | 716 | } |
ngtkien | 0:fc80425b677a | 717 | case CAMERA_BLACK_WHITE_NEGATIVE: |
ngtkien | 0:fc80425b677a | 718 | { |
ngtkien | 0:fc80425b677a | 719 | ret = OV9655_BLACK_WHITE_NEGATIVE; |
ngtkien | 0:fc80425b677a | 720 | break; |
ngtkien | 0:fc80425b677a | 721 | } |
ngtkien | 0:fc80425b677a | 722 | case CAMERA_BLACK_WHITE_BW_NEGATIVE: |
ngtkien | 0:fc80425b677a | 723 | { |
ngtkien | 0:fc80425b677a | 724 | ret = OV9655_BLACK_WHITE_BW_NEGATIVE; |
ngtkien | 0:fc80425b677a | 725 | break; |
ngtkien | 0:fc80425b677a | 726 | } |
ngtkien | 0:fc80425b677a | 727 | case CAMERA_BLACK_WHITE_NORMAL: |
ngtkien | 0:fc80425b677a | 728 | { |
ngtkien | 0:fc80425b677a | 729 | ret = OV9655_BLACK_WHITE_NORMAL; |
ngtkien | 0:fc80425b677a | 730 | break; |
ngtkien | 0:fc80425b677a | 731 | } |
ngtkien | 0:fc80425b677a | 732 | default: |
ngtkien | 0:fc80425b677a | 733 | { |
ngtkien | 0:fc80425b677a | 734 | ret = OV9655_BLACK_WHITE_NORMAL; |
ngtkien | 0:fc80425b677a | 735 | break; |
ngtkien | 0:fc80425b677a | 736 | } |
ngtkien | 0:fc80425b677a | 737 | } |
ngtkien | 0:fc80425b677a | 738 | break; |
ngtkien | 0:fc80425b677a | 739 | } |
ngtkien | 0:fc80425b677a | 740 | case CAMERA_CONTRAST_BRIGHTNESS: |
ngtkien | 0:fc80425b677a | 741 | { |
ngtkien | 0:fc80425b677a | 742 | switch(value) |
ngtkien | 0:fc80425b677a | 743 | { |
ngtkien | 0:fc80425b677a | 744 | case CAMERA_BRIGHTNESS_LEVEL0: |
ngtkien | 0:fc80425b677a | 745 | { |
ngtkien | 0:fc80425b677a | 746 | ret = OV9655_BRIGHTNESS_LEVEL0; |
ngtkien | 0:fc80425b677a | 747 | break; |
ngtkien | 0:fc80425b677a | 748 | } |
ngtkien | 0:fc80425b677a | 749 | case CAMERA_BRIGHTNESS_LEVEL1: |
ngtkien | 0:fc80425b677a | 750 | { |
ngtkien | 0:fc80425b677a | 751 | ret = OV9655_BRIGHTNESS_LEVEL1; |
ngtkien | 0:fc80425b677a | 752 | break; |
ngtkien | 0:fc80425b677a | 753 | } |
ngtkien | 0:fc80425b677a | 754 | case CAMERA_BRIGHTNESS_LEVEL2: |
ngtkien | 0:fc80425b677a | 755 | { |
ngtkien | 0:fc80425b677a | 756 | ret = OV9655_BRIGHTNESS_LEVEL2; |
ngtkien | 0:fc80425b677a | 757 | break; |
ngtkien | 0:fc80425b677a | 758 | } |
ngtkien | 0:fc80425b677a | 759 | case CAMERA_BRIGHTNESS_LEVEL3: |
ngtkien | 0:fc80425b677a | 760 | { |
ngtkien | 0:fc80425b677a | 761 | ret = OV9655_BRIGHTNESS_LEVEL3; |
ngtkien | 0:fc80425b677a | 762 | break; |
ngtkien | 0:fc80425b677a | 763 | } |
ngtkien | 0:fc80425b677a | 764 | case CAMERA_BRIGHTNESS_LEVEL4: |
ngtkien | 0:fc80425b677a | 765 | { |
ngtkien | 0:fc80425b677a | 766 | ret = OV9655_BRIGHTNESS_LEVEL4; |
ngtkien | 0:fc80425b677a | 767 | break; |
ngtkien | 0:fc80425b677a | 768 | } |
ngtkien | 0:fc80425b677a | 769 | case CAMERA_CONTRAST_LEVEL0: |
ngtkien | 0:fc80425b677a | 770 | { |
ngtkien | 0:fc80425b677a | 771 | ret = OV9655_CONTRAST_LEVEL0; |
ngtkien | 0:fc80425b677a | 772 | break; |
ngtkien | 0:fc80425b677a | 773 | } |
ngtkien | 0:fc80425b677a | 774 | case CAMERA_CONTRAST_LEVEL1: |
ngtkien | 0:fc80425b677a | 775 | { |
ngtkien | 0:fc80425b677a | 776 | ret = OV9655_CONTRAST_LEVEL1; |
ngtkien | 0:fc80425b677a | 777 | break; |
ngtkien | 0:fc80425b677a | 778 | } |
ngtkien | 0:fc80425b677a | 779 | case CAMERA_CONTRAST_LEVEL2: |
ngtkien | 0:fc80425b677a | 780 | { |
ngtkien | 0:fc80425b677a | 781 | ret = OV9655_CONTRAST_LEVEL2; |
ngtkien | 0:fc80425b677a | 782 | break; |
ngtkien | 0:fc80425b677a | 783 | } |
ngtkien | 0:fc80425b677a | 784 | case CAMERA_CONTRAST_LEVEL3: |
ngtkien | 0:fc80425b677a | 785 | { |
ngtkien | 0:fc80425b677a | 786 | ret = OV9655_CONTRAST_LEVEL3; |
ngtkien | 0:fc80425b677a | 787 | break; |
ngtkien | 0:fc80425b677a | 788 | } |
ngtkien | 0:fc80425b677a | 789 | case CAMERA_CONTRAST_LEVEL4: |
ngtkien | 0:fc80425b677a | 790 | { |
ngtkien | 0:fc80425b677a | 791 | ret = OV9655_CONTRAST_LEVEL4; |
ngtkien | 0:fc80425b677a | 792 | break; |
ngtkien | 0:fc80425b677a | 793 | } |
ngtkien | 0:fc80425b677a | 794 | default: |
ngtkien | 0:fc80425b677a | 795 | { |
ngtkien | 0:fc80425b677a | 796 | ret = OV9655_CONTRAST_LEVEL0; |
ngtkien | 0:fc80425b677a | 797 | break; |
ngtkien | 0:fc80425b677a | 798 | } |
ngtkien | 0:fc80425b677a | 799 | } |
ngtkien | 0:fc80425b677a | 800 | break; |
ngtkien | 0:fc80425b677a | 801 | } |
ngtkien | 0:fc80425b677a | 802 | case CAMERA_COLOR_EFFECT: |
ngtkien | 0:fc80425b677a | 803 | { |
ngtkien | 0:fc80425b677a | 804 | switch(value) |
ngtkien | 0:fc80425b677a | 805 | { |
ngtkien | 0:fc80425b677a | 806 | case CAMERA_COLOR_EFFECT_ANTIQUE: |
ngtkien | 0:fc80425b677a | 807 | { |
ngtkien | 0:fc80425b677a | 808 | ret = OV9655_COLOR_EFFECT_ANTIQUE; |
ngtkien | 0:fc80425b677a | 809 | break; |
ngtkien | 0:fc80425b677a | 810 | } |
ngtkien | 0:fc80425b677a | 811 | case CAMERA_COLOR_EFFECT_BLUE: |
ngtkien | 0:fc80425b677a | 812 | { |
ngtkien | 0:fc80425b677a | 813 | ret = OV9655_COLOR_EFFECT_BLUE; |
ngtkien | 0:fc80425b677a | 814 | break; |
ngtkien | 0:fc80425b677a | 815 | } |
ngtkien | 0:fc80425b677a | 816 | case CAMERA_COLOR_EFFECT_GREEN: |
ngtkien | 0:fc80425b677a | 817 | { |
ngtkien | 0:fc80425b677a | 818 | ret = OV9655_COLOR_EFFECT_GREEN; |
ngtkien | 0:fc80425b677a | 819 | break; |
ngtkien | 0:fc80425b677a | 820 | } |
ngtkien | 0:fc80425b677a | 821 | case CAMERA_COLOR_EFFECT_RED: |
ngtkien | 0:fc80425b677a | 822 | { |
ngtkien | 0:fc80425b677a | 823 | ret = OV9655_COLOR_EFFECT_RED; |
ngtkien | 0:fc80425b677a | 824 | break; |
ngtkien | 0:fc80425b677a | 825 | } |
ngtkien | 0:fc80425b677a | 826 | case CAMERA_COLOR_EFFECT_NONE: |
ngtkien | 0:fc80425b677a | 827 | default: |
ngtkien | 0:fc80425b677a | 828 | { |
ngtkien | 0:fc80425b677a | 829 | ret = OV9655_COLOR_EFFECT_NONE; |
ngtkien | 0:fc80425b677a | 830 | break; |
ngtkien | 0:fc80425b677a | 831 | } |
ngtkien | 0:fc80425b677a | 832 | } |
ngtkien | 0:fc80425b677a | 833 | break; |
ngtkien | 0:fc80425b677a | 834 | default: |
ngtkien | 0:fc80425b677a | 835 | { |
ngtkien | 0:fc80425b677a | 836 | ret = 0; |
ngtkien | 0:fc80425b677a | 837 | break; |
ngtkien | 0:fc80425b677a | 838 | } |
ngtkien | 0:fc80425b677a | 839 | } |
ngtkien | 0:fc80425b677a | 840 | } |
ngtkien | 0:fc80425b677a | 841 | |
ngtkien | 0:fc80425b677a | 842 | return ret; |
ngtkien | 0:fc80425b677a | 843 | } |
ngtkien | 0:fc80425b677a | 844 | |
ngtkien | 0:fc80425b677a | 845 | /** |
ngtkien | 0:fc80425b677a | 846 | * @} |
ngtkien | 0:fc80425b677a | 847 | */ |
ngtkien | 0:fc80425b677a | 848 | |
ngtkien | 0:fc80425b677a | 849 | /** |
ngtkien | 0:fc80425b677a | 850 | * @} |
ngtkien | 0:fc80425b677a | 851 | */ |
ngtkien | 0:fc80425b677a | 852 | |
ngtkien | 0:fc80425b677a | 853 | /** |
ngtkien | 0:fc80425b677a | 854 | * @} |
ngtkien | 0:fc80425b677a | 855 | */ |
ngtkien | 0:fc80425b677a | 856 | |
ngtkien | 0:fc80425b677a | 857 | /** |
ngtkien | 0:fc80425b677a | 858 | * @} |
ngtkien | 0:fc80425b677a | 859 | */ |
ngtkien | 0:fc80425b677a | 860 | |
ngtkien | 0:fc80425b677a | 861 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |