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