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