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.
ov9655.c
00001 /** 00002 ****************************************************************************** 00003 * @file ov9655.c 00004 * @author MCD Application Team 00005 * @brief This file provides the OV9655 camera driver 00006 ****************************************************************************** 00007 * @attention 00008 * 00009 * <h2><center>© COPYRIGHT(c) 2015 STMicroelectronics</center></h2> 00010 * 00011 * Redistribution and use in source and binary forms, with or without modification, 00012 * are permitted provided that the following conditions are met: 00013 * 1. Redistributions of source code must retain the above copyright notice, 00014 * this list of conditions and the following disclaimer. 00015 * 2. Redistributions in binary form must reproduce the above copyright notice, 00016 * this list of conditions and the following disclaimer in the documentation 00017 * and/or other materials provided with the distribution. 00018 * 3. Neither the name of STMicroelectronics nor the names of its contributors 00019 * may be used to endorse or promote products derived from this software 00020 * without specific prior written permission. 00021 * 00022 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 00023 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00024 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 00025 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 00026 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 00027 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 00028 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 00029 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 00030 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 00031 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00032 * 00033 ****************************************************************************** 00034 */ 00035 00036 /* Includes ------------------------------------------------------------------*/ 00037 #include "ov9655.h" 00038 00039 /** @addtogroup BSP 00040 * @{ 00041 */ 00042 00043 /** @addtogroup Components 00044 * @{ 00045 */ 00046 00047 /** @addtogroup OV9655 00048 * @brief This file provides a set of functions needed to drive the 00049 * OV9655 Camera module. 00050 * @{ 00051 */ 00052 00053 /** @defgroup OV9655_Private_TypesDefinitions 00054 * @{ 00055 */ 00056 00057 /** 00058 * @} 00059 */ 00060 00061 /** @defgroup OV9655_Private_Defines 00062 * @{ 00063 */ 00064 00065 /** 00066 * @} 00067 */ 00068 00069 /** @defgroup OV9655_Private_Macros 00070 * @{ 00071 */ 00072 00073 /** 00074 * @} 00075 */ 00076 00077 /** @defgroup OV9655_Private_FunctionPrototypes 00078 * @{ 00079 */ 00080 static uint64_t ov9655_ConvertValue(uint32_t feature, uint32_t value); 00081 /** 00082 * @} 00083 */ 00084 00085 /** @defgroup OV9655_Private_Variables 00086 * @{ 00087 */ 00088 00089 CAMERA_DrvTypeDef ov9655_drv = 00090 { 00091 ov9655_Init, 00092 ov9655_ReadID, 00093 ov9655_Config, 00094 }; 00095 00096 /* Initialization sequence for VGA resolution (640x480)*/ 00097 const unsigned char OV9655_VGA[][2]= 00098 { 00099 {0x00, 0x00}, 00100 {0x01, 0x80}, 00101 {0x02, 0x80}, 00102 {0xb5, 0x00}, 00103 {0x35, 0x00}, 00104 {0xa8, 0xc1}, 00105 {0x3a, 0xcc}, 00106 {0x3d, 0x99}, 00107 {0x77, 0x02}, 00108 {0x13, 0xe7}, 00109 {0x26, 0x72}, 00110 {0x27, 0x08}, 00111 {0x28, 0x08}, 00112 {0x2c, 0x08}, 00113 {0xab, 0x04}, 00114 {0x6e, 0x00}, 00115 {0x6d, 0x55}, 00116 {0x00, 0x11}, 00117 {0x10, 0x7b}, 00118 {0xbb, 0xae}, 00119 {0x11, 0x03}, 00120 {0x72, 0x00}, 00121 {0x3e, 0x0c}, 00122 {0x74, 0x3a}, 00123 {0x76, 0x01}, 00124 {0x75, 0x35}, 00125 {0x73, 0x00}, 00126 {0xc7, 0x80}, 00127 {0x62, 0x00}, 00128 {0x63, 0x00}, 00129 {0x64, 0x02}, 00130 {0x65, 0x20}, 00131 {0x66, 0x01}, 00132 {0xc3, 0x4e}, 00133 {0x33, 0x00}, 00134 {0xa4, 0x50}, 00135 {0xaa, 0x92}, 00136 {0xc2, 0x01}, 00137 {0xc1, 0xc8}, 00138 {0x1e, 0x04}, 00139 {0xa9, 0xef}, 00140 {0x0e, 0x61}, 00141 {0x39, 0x57}, 00142 {0x0f, 0x48}, 00143 {0x24, 0x3c}, 00144 {0x25, 0x36}, 00145 {0x12, 0x63}, 00146 {0x03, 0x12}, 00147 {0x32, 0xff}, 00148 {0x17, 0x16}, 00149 {0x18, 0x02}, 00150 {0x19, 0x01}, 00151 {0x1a, 0x3d}, 00152 {0x36, 0xfa}, 00153 {0x69, 0x0a}, 00154 {0x8c, 0x8d}, 00155 {0xc0, 0xaa}, 00156 {0x40, 0xd0}, 00157 {0x43, 0x14}, 00158 {0x44, 0xf0}, 00159 {0x45, 0x46}, 00160 {0x46, 0x62}, 00161 {0x47, 0x2a}, 00162 {0x48, 0x3c}, 00163 {0x59, 0x85}, 00164 {0x5a, 0xa9}, 00165 {0x5b, 0x64}, 00166 {0x5c, 0x84}, 00167 {0x5d, 0x53}, 00168 {0x5e, 0x0e}, 00169 {0x6c, 0x0c}, 00170 {0xc6, 0x85}, 00171 {0xcb, 0xf0}, 00172 {0xcc, 0xd8}, 00173 {0x71, 0x78}, 00174 {0xa5, 0x68}, 00175 {0x6f, 0x9e}, 00176 {0x42, 0xc0}, 00177 {0x3f, 0x82}, 00178 {0x8a, 0x23}, 00179 {0x14, 0x3a}, 00180 {0x3b, 0xcc}, 00181 {0x34, 0x3d}, 00182 {0x41, 0x40}, 00183 {0xc9, 0xe0}, 00184 {0xca, 0xe8}, 00185 {0xcd, 0x93}, 00186 {0x7a, 0x20}, 00187 {0x7b, 0x1c}, 00188 {0x7c, 0x28}, 00189 {0x7d, 0x3c}, 00190 {0x7e, 0x5a}, 00191 {0x7f, 0x68}, 00192 {0x80, 0x76}, 00193 {0x81, 0x80}, 00194 {0x82, 0x88}, 00195 {0x83, 0x8f}, 00196 {0x84, 0x96}, 00197 {0x85, 0xa3}, 00198 {0x86, 0xaf}, 00199 {0x87, 0xc4}, 00200 {0x88, 0xd7}, 00201 {0x89, 0xe8}, 00202 {0x4f, 0x98}, 00203 {0x50, 0x98}, 00204 {0x51, 0x00}, 00205 {0x52, 0x28}, 00206 {0x53, 0x70}, 00207 {0x54, 0x98}, 00208 {0x58, 0x1a}, 00209 {0x6b, 0x5a}, 00210 {0x90, 0x92}, 00211 {0x91, 0x92}, 00212 {0x9f, 0x90}, 00213 {0xa0, 0x90}, 00214 {0x16, 0x24}, 00215 {0x2a, 0x00}, 00216 {0x2b, 0x00}, 00217 {0xac, 0x80}, 00218 {0xad, 0x80}, 00219 {0xae, 0x80}, 00220 {0xaf, 0x80}, 00221 {0xb2, 0xf2}, 00222 {0xb3, 0x20}, 00223 {0xb4, 0x20}, 00224 {0xb6, 0xaf}, 00225 {0x29, 0x15}, 00226 {0x9d, 0x02}, 00227 {0x9e, 0x02}, 00228 {0x9e, 0x02}, 00229 {0x04, 0x03}, 00230 {0x05, 0x2e}, 00231 {0x06, 0x2e}, 00232 {0x07, 0x2e}, 00233 {0x08, 0x2e}, 00234 {0x2f, 0x2e}, 00235 {0x4a, 0xe9}, 00236 {0x4b, 0xdd}, 00237 {0x4c, 0xdd}, 00238 {0x4d, 0xdd}, 00239 {0x4e, 0xdd}, 00240 {0x70, 0x06}, 00241 {0xa6, 0x40}, 00242 {0xbc, 0x02}, 00243 {0xbd, 0x01}, 00244 {0xbe, 0x02}, 00245 {0xbf, 0x01}, 00246 }; 00247 00248 /* Initialization sequence for QVGA resolution (320x240) */ 00249 const unsigned char OV9655_QVGA[][2]= 00250 { 00251 {0x00, 0x00}, 00252 {0x01, 0x80}, 00253 {0x02, 0x80}, 00254 {0x03, 0x02}, 00255 {0x04, 0x03}, 00256 {0x09, 0x01}, 00257 {0x0b, 0x57}, 00258 {0x0e, 0x61}, 00259 {0x0f, 0x40}, 00260 {0x11, 0x01}, 00261 {0x12, 0x62}, 00262 {0x13, 0xc7}, 00263 {0x14, 0x3a}, 00264 {0x16, 0x24}, 00265 {0x17, 0x18}, 00266 {0x18, 0x04}, 00267 {0x19, 0x01}, 00268 {0x1a, 0x81}, 00269 {0x1e, 0x00}, 00270 {0x24, 0x3c}, 00271 {0x25, 0x36}, 00272 {0x26, 0x72}, 00273 {0x27, 0x08}, 00274 {0x28, 0x08}, 00275 {0x29, 0x15}, 00276 {0x2a, 0x00}, 00277 {0x2b, 0x00}, 00278 {0x2c, 0x08}, 00279 {0x32, 0x12}, 00280 {0x33, 0x00}, 00281 {0x34, 0x3f}, 00282 {0x35, 0x00}, 00283 {0x36, 0x3a}, 00284 {0x38, 0x72}, 00285 {0x39, 0x57}, 00286 {0x3a, 0xcc}, 00287 {0x3b, 0x04}, 00288 {0x3d, 0x99}, 00289 {0x3e, 0x02}, 00290 {0x3f, 0xc1}, 00291 {0x40, 0xc0}, 00292 {0x41, 0x41}, 00293 {0x42, 0xc0}, 00294 {0x43, 0x0a}, 00295 {0x44, 0xf0}, 00296 {0x45, 0x46}, 00297 {0x46, 0x62}, 00298 {0x47, 0x2a}, 00299 {0x48, 0x3c}, 00300 {0x4a, 0xfc}, 00301 {0x4b, 0xfc}, 00302 {0x4c, 0x7f}, 00303 {0x4d, 0x7f}, 00304 {0x4e, 0x7f}, 00305 {0x4f, 0x98}, 00306 {0x50, 0x98}, 00307 {0x51, 0x00}, 00308 {0x52, 0x28}, 00309 {0x53, 0x70}, 00310 {0x54, 0x98}, 00311 {0x58, 0x1a}, 00312 {0x59, 0x85}, 00313 {0x5a, 0xa9}, 00314 {0x5b, 0x64}, 00315 {0x5c, 0x84}, 00316 {0x5d, 0x53}, 00317 {0x5e, 0x0e}, 00318 {0x5f, 0xf0}, 00319 {0x60, 0xf0}, 00320 {0x61, 0xf0}, 00321 {0x62, 0x00}, 00322 {0x63, 0x00}, 00323 {0x64, 0x02}, 00324 {0x65, 0x20}, 00325 {0x66, 0x00}, 00326 {0x69, 0x0a}, 00327 {0x6b, 0x5a}, 00328 {0x6c, 0x04}, 00329 {0x6d, 0x55}, 00330 {0x6e, 0x00}, 00331 {0x6f, 0x9d}, 00332 {0x70, 0x21}, 00333 {0x71, 0x78}, 00334 {0x72, 0x11}, 00335 {0x73, 0x01}, 00336 {0x74, 0x10}, 00337 {0x75, 0x10}, 00338 {0x76, 0x01}, 00339 {0x77, 0x02}, 00340 {0x7A, 0x12}, 00341 {0x7B, 0x08}, 00342 {0x7C, 0x16}, 00343 {0x7D, 0x30}, 00344 {0x7E, 0x5e}, 00345 {0x7F, 0x72}, 00346 {0x80, 0x82}, 00347 {0x81, 0x8e}, 00348 {0x82, 0x9a}, 00349 {0x83, 0xa4}, 00350 {0x84, 0xac}, 00351 {0x85, 0xb8}, 00352 {0x86, 0xc3}, 00353 {0x87, 0xd6}, 00354 {0x88, 0xe6}, 00355 {0x89, 0xf2}, 00356 {0x8a, 0x24}, 00357 {0x8c, 0x80}, 00358 {0x90, 0x7d}, 00359 {0x91, 0x7b}, 00360 {0x9d, 0x02}, 00361 {0x9e, 0x02}, 00362 {0x9f, 0x7a}, 00363 {0xa0, 0x79}, 00364 {0xa1, 0x40}, 00365 {0xa4, 0x50}, 00366 {0xa5, 0x68}, 00367 {0xa6, 0x4a}, 00368 {0xa8, 0xc1}, 00369 {0xa9, 0xef}, 00370 {0xaa, 0x92}, 00371 {0xab, 0x04}, 00372 {0xac, 0x80}, 00373 {0xad, 0x80}, 00374 {0xae, 0x80}, 00375 {0xaf, 0x80}, 00376 {0xb2, 0xf2}, 00377 {0xb3, 0x20}, 00378 {0xb4, 0x20}, 00379 {0xb5, 0x00}, 00380 {0xb6, 0xaf}, 00381 {0xb6, 0xaf}, 00382 {0xbb, 0xae}, 00383 {0xbc, 0x7f}, 00384 {0xbd, 0x7f}, 00385 {0xbe, 0x7f}, 00386 {0xbf, 0x7f}, 00387 {0xbf, 0x7f}, 00388 {0xc0, 0xaa}, 00389 {0xc1, 0xc0}, 00390 {0xc2, 0x01}, 00391 {0xc3, 0x4e}, 00392 {0xc6, 0x05}, 00393 {0xc7, 0x81}, 00394 {0xc9, 0xe0}, 00395 {0xca, 0xe8}, 00396 {0xcb, 0xf0}, 00397 {0xcc, 0xd8}, 00398 {0xcd, 0x93}, 00399 {0x12, 0x63}, 00400 {0x40, 0x10}, 00401 }; 00402 00403 /* Initialization sequence for QQVGA resolution (160x120) */ 00404 const char OV9655_QQVGA[][2]= 00405 { 00406 {0x00, 0x00}, 00407 {0x01, 0x80}, 00408 {0x02, 0x80}, 00409 {0x03, 0x02}, 00410 {0x04, 0x03}, 00411 {0x09, 0x01}, 00412 {0x0b, 0x57}, 00413 {0x0e, 0x61}, 00414 {0x0f, 0x40}, 00415 {0x11, 0x01}, 00416 {0x12, 0x62}, 00417 {0x13, 0xc7}, 00418 {0x14, 0x3a}, 00419 {0x16, 0x24}, 00420 {0x17, 0x18}, 00421 {0x18, 0x04}, 00422 {0x19, 0x01}, 00423 {0x1a, 0x81}, 00424 {0x1e, 0x00}, 00425 {0x24, 0x3c}, 00426 {0x25, 0x36}, 00427 {0x26, 0x72}, 00428 {0x27, 0x08}, 00429 {0x28, 0x08}, 00430 {0x29, 0x15}, 00431 {0x2a, 0x00}, 00432 {0x2b, 0x00}, 00433 {0x2c, 0x08}, 00434 {0x32, 0xa4}, 00435 {0x33, 0x00}, 00436 {0x34, 0x3f}, 00437 {0x35, 0x00}, 00438 {0x36, 0x3a}, 00439 {0x38, 0x72}, 00440 {0x39, 0x57}, 00441 {0x3a, 0xcc}, 00442 {0x3b, 0x04}, 00443 {0x3d, 0x99}, 00444 {0x3e, 0x0e}, 00445 {0x3f, 0xc1}, 00446 {0x40, 0xc0}, 00447 {0x41, 0x41}, 00448 {0x42, 0xc0}, 00449 {0x43, 0x0a}, 00450 {0x44, 0xf0}, 00451 {0x45, 0x46}, 00452 {0x46, 0x62}, 00453 {0x47, 0x2a}, 00454 {0x48, 0x3c}, 00455 {0x4a, 0xfc}, 00456 {0x4b, 0xfc}, 00457 {0x4c, 0x7f}, 00458 {0x4d, 0x7f}, 00459 {0x4e, 0x7f}, 00460 {0x4f, 0x98}, 00461 {0x50, 0x98}, 00462 {0x51, 0x00}, 00463 {0x52, 0x28}, 00464 {0x53, 0x70}, 00465 {0x54, 0x98}, 00466 {0x58, 0x1a}, 00467 {0x59, 0x85}, 00468 {0x5a, 0xa9}, 00469 {0x5b, 0x64}, 00470 {0x5c, 0x84}, 00471 {0x5d, 0x53}, 00472 {0x5e, 0x0e}, 00473 {0x5f, 0xf0}, 00474 {0x60, 0xf0}, 00475 {0x61, 0xf0}, 00476 {0x62, 0x00}, 00477 {0x63, 0x00}, 00478 {0x64, 0x02}, 00479 {0x65, 0x20}, 00480 {0x66, 0x00}, 00481 {0x69, 0x0a}, 00482 {0x6b, 0x5a}, 00483 {0x6c, 0x04}, 00484 {0x6d, 0x55}, 00485 {0x6e, 0x00}, 00486 {0x6f, 0x9d}, 00487 {0x70, 0x21}, 00488 {0x71, 0x78}, 00489 {0x72, 0x22}, 00490 {0x73, 0x02}, 00491 {0x74, 0x10}, 00492 {0x75, 0x10}, 00493 {0x76, 0x01}, 00494 {0x77, 0x02}, 00495 {0x7A, 0x12}, 00496 {0x7B, 0x08}, 00497 {0x7C, 0x16}, 00498 {0x7D, 0x30}, 00499 {0x7E, 0x5e}, 00500 {0x7F, 0x72}, 00501 {0x80, 0x82}, 00502 {0x81, 0x8e}, 00503 {0x82, 0x9a}, 00504 {0x83, 0xa4}, 00505 {0x84, 0xac}, 00506 {0x85, 0xb8}, 00507 {0x86, 0xc3}, 00508 {0x87, 0xd6}, 00509 {0x88, 0xe6}, 00510 {0x89, 0xf2}, 00511 {0x8a, 0x24}, 00512 {0x8c, 0x80}, 00513 {0x90, 0x7d}, 00514 {0x91, 0x7b}, 00515 {0x9d, 0x02}, 00516 {0x9e, 0x02}, 00517 {0x9f, 0x7a}, 00518 {0xa0, 0x79}, 00519 {0xa1, 0x40}, 00520 {0xa4, 0x50}, 00521 {0xa5, 0x68}, 00522 {0xa6, 0x4a}, 00523 {0xa8, 0xc1}, 00524 {0xa9, 0xef}, 00525 {0xaa, 0x92}, 00526 {0xab, 0x04}, 00527 {0xac, 0x80}, 00528 {0xad, 0x80}, 00529 {0xae, 0x80}, 00530 {0xaf, 0x80}, 00531 {0xb2, 0xf2}, 00532 {0xb3, 0x20}, 00533 {0xb4, 0x20}, 00534 {0xb5, 0x00}, 00535 {0xb6, 0xaf}, 00536 {0xb6, 0xaf}, 00537 {0xbb, 0xae}, 00538 {0xbc, 0x7f}, 00539 {0xbd, 0x7f}, 00540 {0xbe, 0x7f}, 00541 {0xbf, 0x7f}, 00542 {0xbf, 0x7f}, 00543 {0xc0, 0xaa}, 00544 {0xc1, 0xc0}, 00545 {0xc2, 0x01}, 00546 {0xc3, 0x4e}, 00547 {0xc6, 0x05}, 00548 {0xc7, 0x82}, 00549 {0xc9, 0xe0}, 00550 {0xca, 0xe8}, 00551 {0xcb, 0xf0}, 00552 {0xcc, 0xd8}, 00553 {0xcd, 0x93}, 00554 {0x12, 0x63}, 00555 {0x40, 0x10}, 00556 }; 00557 00558 /** 00559 * @} 00560 */ 00561 00562 /** @defgroup OV9655_Private_Functions 00563 * @{ 00564 */ 00565 00566 /** 00567 * @brief Initializes the OV9655 CAMERA component. 00568 * @param DeviceAddr: Device address on communication Bus. 00569 * @param resolution: Camera resolution 00570 * @retval None 00571 */ 00572 void ov9655_Init(uint16_t DeviceAddr, uint32_t resolution) 00573 { 00574 uint32_t index; 00575 00576 /* Initialize I2C */ 00577 CAMERA_IO_Init(); 00578 00579 /* Prepare the camera to be configured by resetting all its registers */ 00580 CAMERA_IO_Write(DeviceAddr, OV9655_SENSOR_COM7, 0x80); 00581 CAMERA_Delay(200); 00582 00583 /* Initialize OV9655 */ 00584 switch (resolution) 00585 { 00586 case CAMERA_R160x120: 00587 { 00588 for(index=0; index<(sizeof(OV9655_QQVGA)/2); index++) 00589 { 00590 CAMERA_IO_Write(DeviceAddr, OV9655_QQVGA[index][0], OV9655_QQVGA[index][1]); 00591 CAMERA_Delay(2); 00592 } 00593 break; 00594 } 00595 case CAMERA_R320x240: 00596 { 00597 for(index=0; index<(sizeof(OV9655_QVGA)/2); index++) 00598 { 00599 CAMERA_IO_Write(DeviceAddr, OV9655_QVGA[index][0], OV9655_QVGA[index][1]); 00600 CAMERA_Delay(2); 00601 } 00602 break; 00603 } 00604 case CAMERA_R480x272: 00605 { 00606 /* Not supported resolution */ 00607 break; 00608 } 00609 case CAMERA_R640x480: 00610 { 00611 for(index=0; index<(sizeof(OV9655_VGA)/2); index++) 00612 { 00613 CAMERA_IO_Write(DeviceAddr, OV9655_VGA[index][0], OV9655_VGA[index][1]); 00614 CAMERA_Delay(2); 00615 } 00616 break; 00617 } 00618 default: 00619 { 00620 break; 00621 } 00622 } 00623 } 00624 00625 /** 00626 * @brief Configures the OV9655 camera feature. 00627 * @param DeviceAddr: Device address on communication Bus. 00628 * @param feature: Camera feature to be configured 00629 * @param value: Value to be configured 00630 * @param brightness_value: Brightness value to be configured 00631 * @retval None 00632 */ 00633 void ov9655_Config(uint16_t DeviceAddr, uint32_t feature, uint32_t value, uint32_t brightness_value) 00634 { 00635 uint8_t tslb, mtx1, mtx2, mtx3, mtx4, mtx5, mtx6; 00636 uint64_t value_tmp; 00637 uint32_t br_value; 00638 00639 /* Convert the input value into ov9655 parameters */ 00640 value_tmp = ov9655_ConvertValue(feature, value); 00641 br_value = (uint32_t)ov9655_ConvertValue(CAMERA_CONTRAST_BRIGHTNESS, brightness_value); 00642 00643 switch(feature) 00644 { 00645 case CAMERA_CONTRAST_BRIGHTNESS: 00646 { 00647 CAMERA_IO_Write(DeviceAddr, OV9655_SENSOR_BRTN, br_value); 00648 CAMERA_IO_Write(DeviceAddr, OV9655_SENSOR_CNST1, value_tmp); 00649 break; 00650 } 00651 case CAMERA_BLACK_WHITE: 00652 case CAMERA_COLOR_EFFECT: 00653 { 00654 tslb = (uint8_t)(value_tmp >> 48); 00655 mtx1 = (uint8_t)(value_tmp >> 40); 00656 mtx2 = (uint8_t)(value_tmp >> 32); 00657 mtx3 = (uint8_t)(value_tmp >> 24); 00658 mtx4 = (uint8_t)(value_tmp >> 16); 00659 mtx5 = (uint8_t)(value_tmp >> 8); 00660 mtx6 = (uint8_t)(value_tmp); 00661 CAMERA_IO_Write(DeviceAddr, OV9655_SENSOR_TSLB, tslb); 00662 CAMERA_IO_Write(DeviceAddr, OV9655_SENSOR_MTX1, mtx1); 00663 CAMERA_IO_Write(DeviceAddr, OV9655_SENSOR_MTX2, mtx2); 00664 CAMERA_IO_Write(DeviceAddr, OV9655_SENSOR_MTX3, mtx3); 00665 CAMERA_IO_Write(DeviceAddr, OV9655_SENSOR_MTX4, mtx4); 00666 CAMERA_IO_Write(DeviceAddr, OV9655_SENSOR_MTX5, mtx5); 00667 CAMERA_IO_Write(DeviceAddr, OV9655_SENSOR_MTX6, mtx6); 00668 break; 00669 } 00670 default: 00671 { 00672 break; 00673 } 00674 } 00675 } 00676 00677 /** 00678 * @brief Read the OV9655 Camera identity. 00679 * @param DeviceAddr: Device address on communication Bus. 00680 * @retval the OV9655 ID 00681 */ 00682 uint16_t ov9655_ReadID(uint16_t DeviceAddr) 00683 { 00684 /* Initialize I2C */ 00685 CAMERA_IO_Init(); 00686 00687 /* Get the camera ID */ 00688 return (CAMERA_IO_Read(DeviceAddr, OV9655_SENSOR_PIDH)); 00689 } 00690 00691 /****************************************************************************** 00692 Static Functions 00693 *******************************************************************************/ 00694 /** 00695 * @brief Convert input values into ov9655 parameters. 00696 * @param feature: Camera feature to be configured 00697 * @param value: Value to be configured 00698 * @retval The converted value 00699 */ 00700 static uint64_t ov9655_ConvertValue(uint32_t feature, uint32_t value) 00701 { 00702 uint64_t ret = 0; 00703 00704 switch(feature) 00705 { 00706 case CAMERA_BLACK_WHITE: 00707 { 00708 switch(value) 00709 { 00710 case CAMERA_BLACK_WHITE_BW: 00711 { 00712 ret = OV9655_BLACK_WHITE_BW; 00713 break; 00714 } 00715 case CAMERA_BLACK_WHITE_NEGATIVE: 00716 { 00717 ret = OV9655_BLACK_WHITE_NEGATIVE; 00718 break; 00719 } 00720 case CAMERA_BLACK_WHITE_BW_NEGATIVE: 00721 { 00722 ret = OV9655_BLACK_WHITE_BW_NEGATIVE; 00723 break; 00724 } 00725 case CAMERA_BLACK_WHITE_NORMAL: 00726 { 00727 ret = OV9655_BLACK_WHITE_NORMAL; 00728 break; 00729 } 00730 default: 00731 { 00732 ret = OV9655_BLACK_WHITE_NORMAL; 00733 break; 00734 } 00735 } 00736 break; 00737 } 00738 case CAMERA_CONTRAST_BRIGHTNESS: 00739 { 00740 switch(value) 00741 { 00742 case CAMERA_BRIGHTNESS_LEVEL0: 00743 { 00744 ret = OV9655_BRIGHTNESS_LEVEL0; 00745 break; 00746 } 00747 case CAMERA_BRIGHTNESS_LEVEL1: 00748 { 00749 ret = OV9655_BRIGHTNESS_LEVEL1; 00750 break; 00751 } 00752 case CAMERA_BRIGHTNESS_LEVEL2: 00753 { 00754 ret = OV9655_BRIGHTNESS_LEVEL2; 00755 break; 00756 } 00757 case CAMERA_BRIGHTNESS_LEVEL3: 00758 { 00759 ret = OV9655_BRIGHTNESS_LEVEL3; 00760 break; 00761 } 00762 case CAMERA_BRIGHTNESS_LEVEL4: 00763 { 00764 ret = OV9655_BRIGHTNESS_LEVEL4; 00765 break; 00766 } 00767 case CAMERA_CONTRAST_LEVEL0: 00768 { 00769 ret = OV9655_CONTRAST_LEVEL0; 00770 break; 00771 } 00772 case CAMERA_CONTRAST_LEVEL1: 00773 { 00774 ret = OV9655_CONTRAST_LEVEL1; 00775 break; 00776 } 00777 case CAMERA_CONTRAST_LEVEL2: 00778 { 00779 ret = OV9655_CONTRAST_LEVEL2; 00780 break; 00781 } 00782 case CAMERA_CONTRAST_LEVEL3: 00783 { 00784 ret = OV9655_CONTRAST_LEVEL3; 00785 break; 00786 } 00787 case CAMERA_CONTRAST_LEVEL4: 00788 { 00789 ret = OV9655_CONTRAST_LEVEL4; 00790 break; 00791 } 00792 default: 00793 { 00794 ret = OV9655_CONTRAST_LEVEL0; 00795 break; 00796 } 00797 } 00798 break; 00799 } 00800 case CAMERA_COLOR_EFFECT: 00801 { 00802 switch(value) 00803 { 00804 case CAMERA_COLOR_EFFECT_ANTIQUE: 00805 { 00806 ret = OV9655_COLOR_EFFECT_ANTIQUE; 00807 break; 00808 } 00809 case CAMERA_COLOR_EFFECT_BLUE: 00810 { 00811 ret = OV9655_COLOR_EFFECT_BLUE; 00812 break; 00813 } 00814 case CAMERA_COLOR_EFFECT_GREEN: 00815 { 00816 ret = OV9655_COLOR_EFFECT_GREEN; 00817 break; 00818 } 00819 case CAMERA_COLOR_EFFECT_RED: 00820 { 00821 ret = OV9655_COLOR_EFFECT_RED; 00822 break; 00823 } 00824 case CAMERA_COLOR_EFFECT_NONE: 00825 default: 00826 { 00827 ret = OV9655_COLOR_EFFECT_NONE; 00828 break; 00829 } 00830 } 00831 break; 00832 default: 00833 { 00834 ret = 0; 00835 break; 00836 } 00837 } 00838 } 00839 00840 return ret; 00841 } 00842 00843 /** 00844 * @} 00845 */ 00846 00847 /** 00848 * @} 00849 */ 00850 00851 /** 00852 * @} 00853 */ 00854 00855 /** 00856 * @} 00857 */ 00858 00859 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
Generated on Tue Jul 12 2022 19:38:24 by
