1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351 |
- /**
- ******************************************************************************
- * @file ov2640.c
- * @author MCD Application Team
- * @version V1.0.2
- * @date 02-December-2014
- * @brief This file provides the OV2640 camera driver
- ******************************************************************************
- * @attention
- *
- * <h2><center>© COPYRIGHT(c) 2014 STMicroelectronics</center></h2>
- *
- * Redistribution and use in source and binary forms, with or without modification,
- * are permitted provided that the following conditions are met:
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- * 3. Neither the name of STMicroelectronics nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
- * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- ******************************************************************************
- */
- /* Includes ------------------------------------------------------------------*/
- #include "ov2640.h"
- /** @addtogroup BSP
- * @{
- */
- /** @addtogroup Components
- * @{
- */
-
- /** @addtogroup OV2640
- * @brief This file provides a set of functions needed to drive the
- * OV2640 Camera module.
- * @{
- */
- /** @defgroup OV2640_Private_TypesDefinitions
- * @{
- */
- /**
- * @}
- */
- /** @defgroup OV2640_Private_Defines
- * @{
- */
- /**
- * @}
- */
-
- /** @defgroup OV2640_Private_Macros
- * @{
- */
-
- /**
- * @}
- */
-
- /** @defgroup OV2640_Private_FunctionPrototypes
- * @{
- */
- static uint32_t ov2640_ConvertValue(uint32_t feature, uint32_t value);
- /**
- * @}
- */
-
- /** @defgroup OV2640_Private_Variables
- * @{
- */
- CAMERA_DrvTypeDef ov2640_drv =
- {
- ov2640_Init,
- ov2640_ReadID,
- ov2640_Config,
- };
- /* Initialization sequence for 480x272 resolution */
- const unsigned char OV2640_480x272[][2]=
- {
- {0xff, 0x00}, /* Device control register list Table 12 */
- {0x2c, 0xff}, /* Reserved */
- {0x2e, 0xdf}, /* Reserved */
- {0xff, 0x01}, /* Device control register list Table 13 */
- {0x3c, 0x32}, /* Reserved */
- {0x11, 0x00}, /* Clock Rate Control */
- {0x09, 0x02}, /* Common control 2 */
- {0x04, 0xA8}, /* Mirror */
- {0x13, 0xe5}, /* Common control 8 */
- {0x14, 0x48}, /* Common control 9 */
- {0x2c, 0x0c}, /* Reserved */
- {0x33, 0x78}, /* Reserved */
- {0x3a, 0x33}, /* Reserved */
- {0x3b, 0xfB}, /* Reserved */
- {0x3e, 0x00}, /* Reserved */
- {0x43, 0x11}, /* Reserved */
- {0x16, 0x10}, /* Reserved */
- {0x4a, 0x81}, /* Reserved */
- {0x21, 0x99}, /* Reserved */
- {0x24, 0x40}, /* Luminance signal High range */
- {0x25, 0x38}, /* Luminance signal low range */
- {0x26, 0x82}, /* */
- {0x5c, 0x00}, /* Reserved */
- {0x63, 0x00}, /* Reserved */
- {0x46, 0x3f}, /* Frame length adjustment */
- {0x0c, 0x3c}, /* Common control 3 */
- {0x61, 0x70}, /* Histogram algo low level */
- {0x62, 0x80}, /* Histogram algo high level */
- {0x7c, 0x05}, /* Reserved */
- {0x20, 0x80}, /* Reserved */
- {0x28, 0x30}, /* Reserved */
- {0x6c, 0x00}, /* Reserved */
- {0x6d, 0x80}, /* Reserved */
- {0x6e, 0x00}, /* Reserved */
- {0x70, 0x02}, /* Reserved */
- {0x71, 0x94}, /* Reserved */
- {0x73, 0xc1}, /* Reserved */
- {0x3d, 0x34}, /* Reserved */
- {0x5a, 0x57}, /* Reserved */
- {0x12, 0x00}, /* Common control 7 */
- {0x11, 0x00}, /* Clock Rate Control 2*/
- {0x17, 0x11}, /* Horiz window start MSB 8bits */
- {0x18, 0x75}, /* Horiz window end MSB 8bits */
- {0x19, 0x01}, /* Vert window line start MSB 8bits */
- {0x1a, 0x97}, /* Vert window line end MSB 8bits */
- {0x32, 0x36},
- {0x03, 0x0f},
- {0x37, 0x40},
- {0x4f, 0xbb},
- {0x50, 0x9c},
- {0x5a, 0x57},
- {0x6d, 0x80},
- {0x6d, 0x38},
- {0x39, 0x02},
- {0x35, 0x88},
- {0x22, 0x0a},
- {0x37, 0x40},
- {0x23, 0x00},
- {0x34, 0xa0},
- {0x36, 0x1a},
- {0x06, 0x02},
- {0x07, 0xc0},
- {0x0d, 0xb7},
- {0x0e, 0x01},
- {0x4c, 0x00},
- {0xff, 0x00},
- {0xe5, 0x7f},
- {0xf9, 0xc0},
- {0x41, 0x24},
- {0xe0, 0x14},
- {0x76, 0xff},
- {0x33, 0xa0},
- {0x42, 0x20},
- {0x43, 0x18},
- {0x4c, 0x00},
- {0x87, 0xd0},
- {0x88, 0x3f},
- {0xd7, 0x03},
- {0xd9, 0x10},
- {0xd3, 0x82},
- {0xc8, 0x08},
- {0xc9, 0x80},
- {0x7d, 0x00},
- {0x7c, 0x03},
- {0x7d, 0x48},
- {0x7c, 0x08},
- {0x7d, 0x20},
- {0x7d, 0x10},
- {0x7d, 0x0e},
- {0x90, 0x00},
- {0x91, 0x0e},
- {0x91, 0x1a},
- {0x91, 0x31},
- {0x91, 0x5a},
- {0x91, 0x69},
- {0x91, 0x75},
- {0x91, 0x7e},
- {0x91, 0x88},
- {0x91, 0x8f},
- {0x91, 0x96},
- {0x91, 0xa3},
- {0x91, 0xaf},
- {0x91, 0xc4},
- {0x91, 0xd7},
- {0x91, 0xe8},
- {0x91, 0x20},
- {0x92, 0x00},
- {0x93, 0x06},
- {0x93, 0xe3},
- {0x93, 0x02},
- {0x93, 0x02},
- {0x93, 0x00},
- {0x93, 0x04},
- {0x93, 0x00},
- {0x93, 0x03},
- {0x93, 0x00},
- {0x93, 0x00},
- {0x93, 0x00},
- {0x93, 0x00},
- {0x93, 0x00},
- {0x93, 0x00},
- {0x93, 0x00},
- {0x96, 0x00},
- {0x97, 0x08},
- {0x97, 0x19},
- {0x97, 0x02},
- {0x97, 0x0c},
- {0x97, 0x24},
- {0x97, 0x30},
- {0x97, 0x28},
- {0x97, 0x26},
- {0x97, 0x02},
- {0x97, 0x98},
- {0x97, 0x80},
- {0x97, 0x00},
- {0x97, 0x00},
- {0xc3, 0xef},
- {0xff, 0x00},
- {0xba, 0xdc},
- {0xbb, 0x08},
- {0xb6, 0x24},
- {0xb8, 0x33},
- {0xb7, 0x20},
- {0xb9, 0x30},
- {0xb3, 0xb4},
- {0xb4, 0xca},
- {0xb5, 0x43},
- {0xb0, 0x5c},
- {0xb1, 0x4f},
- {0xb2, 0x06},
- {0xc7, 0x00},
- {0xc6, 0x51},
- {0xc5, 0x11},
- {0xc4, 0x9c},
- {0xbf, 0x00},
- {0xbc, 0x64},
- {0xa6, 0x00},
- {0xa7, 0x1e},
- {0xa7, 0x6b},
- {0xa7, 0x47},
- {0xa7, 0x33},
- {0xa7, 0x00},
- {0xa7, 0x23},
- {0xa7, 0x2e},
- {0xa7, 0x85},
- {0xa7, 0x42},
- {0xa7, 0x33},
- {0xa7, 0x00},
- {0xa7, 0x23},
- {0xa7, 0x1b},
- {0xa7, 0x74},
- {0xa7, 0x42},
- {0xa7, 0x33},
- {0xa7, 0x00},
- {0xa7, 0x23},
- {0xc0, 0xc8},
- {0xc1, 0x96},
- {0x8c, 0x00},
- {0x86, 0x3d},
- {0x50, 0x92},
- {0x51, 0x90},
- {0x52, 0x2c},
- {0x53, 0x00},
- {0x54, 0x00},
- {0x55, 0x88},
- {0x5a, 0x50},
- {0x5b, 0x3c},
- {0x5c, 0x00},
- {0xd3, 0x04},
- {0x7f, 0x00},
- {0xda, 0x00},
- {0xe5, 0x1f},
- {0xe1, 0x67},
- {0xe0, 0x00},
- {0xdd, 0x7f},
- {0x05, 0x00},
- {0xff, 0x00},
- {0xe0, 0x04},
- {0xc0, 0xc8},
- {0xc1, 0x96},
- {0x86, 0x3d},
- {0x50, 0x92},
- {0x51, 0x90},
- {0x52, 0x2c},
- {0x53, 0x00},
- {0x54, 0x00},
- {0x55, 0x88},
- {0x57, 0x00},
- {0x5a, 0x50},
- {0x5b, 0x3c},
- {0x5c, 0x00},
- {0xd3, 0x04},
- {0xe0, 0x00},
- {0xFF, 0x00},
- {0x05, 0x00},
- {0xDA, 0x08},
- {0xda, 0x09},
- {0x98, 0x00},
- {0x99, 0x00},
- {0x00, 0x00},
- {0xff, 0x00},
- {0xe0, 0x04},
- {0xc0, 0xc8},
- {0xc1, 0x96},
- {0x86, 0x35},
- {0x50, 0x80},
- {0x51, 0x90},
- {0x52, 0x2c},
- {0x53, 0x00},
- {0x54, 0x00},
- {0x55, 0x88},
- {0x57, 0x00},
- {0x5a, 0x78},
- {0x5b, 0x44},
- {0x5c, 0x00},
- {0xd3, 0x04},
- {0xe0, 0x00},
- };
- /* Initialization sequence for VGA resolution (640x480)*/
- const unsigned char OV2640_VGA[][2]=
- {
- {0xff, 0x00}, /* Device control register list Table 12 */
- {0x2c, 0xff}, /* Reserved */
- {0x2e, 0xdf}, /* Reserved */
- {0xff, 0x01}, /* Device control register list Table 13 */
- {0x3c, 0x32}, /* Reserved */
- {0x11, 0x00}, /* Clock Rate Control */
- {0x09, 0x02}, /* Common control 2 */
- {0x04, 0xA8}, /* Mirror */
- {0x13, 0xe5}, /* Common control 8 */
- {0x14, 0x48}, /* Common control 9 */
- {0x2c, 0x0c}, /* Reserved */
- {0x33, 0x78}, /* Reserved */
- {0x3a, 0x33}, /* Reserved */
- {0x3b, 0xfB}, /* Reserved */
- {0x3e, 0x00}, /* Reserved */
- {0x43, 0x11}, /* Reserved */
- {0x16, 0x10}, /* Reserved */
- {0x4a, 0x81}, /* Reserved */
- {0x21, 0x99}, /* Reserved */
- {0x24, 0x40}, /* Luminance signal High range */
- {0x25, 0x38}, /* Luminance signal low range */
- {0x26, 0x82}, /* */
- {0x5c, 0x00}, /* Reserved */
- {0x63, 0x00}, /* Reserved */
- {0x46, 0x3f}, /* Frame length adjustment */
- {0x0c, 0x3c}, /* Common control 3 */
- {0x61, 0x70}, /* Histogram algo low level */
- {0x62, 0x80}, /* Histogram algo high level */
- {0x7c, 0x05}, /* Reserved */
- {0x20, 0x80}, /* Reserved */
- {0x28, 0x30}, /* Reserved */
- {0x6c, 0x00}, /* Reserved */
- {0x6d, 0x80}, /* Reserved */
- {0x6e, 0x00}, /* Reserved */
- {0x70, 0x02}, /* Reserved */
- {0x71, 0x94}, /* Reserved */
- {0x73, 0xc1}, /* Reserved */
- {0x3d, 0x34}, /* Reserved */
- {0x5a, 0x57}, /* Reserved */
- {0x12, 0x00}, /* Common control 7 */
- {0x11, 0x00}, /* Clock Rate Control 2*/
- {0x17, 0x11}, /* Horiz window start MSB 8bits */
- {0x18, 0x75}, /* Horiz window end MSB 8bits */
- {0x19, 0x01}, /* Vert window line start MSB 8bits */
- {0x1a, 0x97}, /* Vert window line end MSB 8bits */
- {0x32, 0x36},
- {0x03, 0x0f},
- {0x37, 0x40},
- {0x4f, 0xbb},
- {0x50, 0x9c},
- {0x5a, 0x57},
- {0x6d, 0x80},
- {0x6d, 0x38},
- {0x39, 0x02},
- {0x35, 0x88},
- {0x22, 0x0a},
- {0x37, 0x40},
- {0x23, 0x00},
- {0x34, 0xa0},
- {0x36, 0x1a},
- {0x06, 0x02},
- {0x07, 0xc0},
- {0x0d, 0xb7},
- {0x0e, 0x01},
- {0x4c, 0x00},
- {0xff, 0x00},
- {0xe5, 0x7f},
- {0xf9, 0xc0},
- {0x41, 0x24},
- {0xe0, 0x14},
- {0x76, 0xff},
- {0x33, 0xa0},
- {0x42, 0x20},
- {0x43, 0x18},
- {0x4c, 0x00},
- {0x87, 0xd0},
- {0x88, 0x3f},
- {0xd7, 0x03},
- {0xd9, 0x10},
- {0xd3, 0x82},
- {0xc8, 0x08},
- {0xc9, 0x80},
- {0x7d, 0x00},
- {0x7c, 0x03},
- {0x7d, 0x48},
- {0x7c, 0x08},
- {0x7d, 0x20},
- {0x7d, 0x10},
- {0x7d, 0x0e},
- {0x90, 0x00},
- {0x91, 0x0e},
- {0x91, 0x1a},
- {0x91, 0x31},
- {0x91, 0x5a},
- {0x91, 0x69},
- {0x91, 0x75},
- {0x91, 0x7e},
- {0x91, 0x88},
- {0x91, 0x8f},
- {0x91, 0x96},
- {0x91, 0xa3},
- {0x91, 0xaf},
- {0x91, 0xc4},
- {0x91, 0xd7},
- {0x91, 0xe8},
- {0x91, 0x20},
- {0x92, 0x00},
- {0x93, 0x06},
- {0x93, 0xe3},
- {0x93, 0x02},
- {0x93, 0x02},
- {0x93, 0x00},
- {0x93, 0x04},
- {0x93, 0x00},
- {0x93, 0x03},
- {0x93, 0x00},
- {0x93, 0x00},
- {0x93, 0x00},
- {0x93, 0x00},
- {0x93, 0x00},
- {0x93, 0x00},
- {0x93, 0x00},
- {0x96, 0x00},
- {0x97, 0x08},
- {0x97, 0x19},
- {0x97, 0x02},
- {0x97, 0x0c},
- {0x97, 0x24},
- {0x97, 0x30},
- {0x97, 0x28},
- {0x97, 0x26},
- {0x97, 0x02},
- {0x97, 0x98},
- {0x97, 0x80},
- {0x97, 0x00},
- {0x97, 0x00},
- {0xc3, 0xef},
- {0xff, 0x00},
- {0xba, 0xdc},
- {0xbb, 0x08},
- {0xb6, 0x24},
- {0xb8, 0x33},
- {0xb7, 0x20},
- {0xb9, 0x30},
- {0xb3, 0xb4},
- {0xb4, 0xca},
- {0xb5, 0x43},
- {0xb0, 0x5c},
- {0xb1, 0x4f},
- {0xb2, 0x06},
- {0xc7, 0x00},
- {0xc6, 0x51},
- {0xc5, 0x11},
- {0xc4, 0x9c},
- {0xbf, 0x00},
- {0xbc, 0x64},
- {0xa6, 0x00},
- {0xa7, 0x1e},
- {0xa7, 0x6b},
- {0xa7, 0x47},
- {0xa7, 0x33},
- {0xa7, 0x00},
- {0xa7, 0x23},
- {0xa7, 0x2e},
- {0xa7, 0x85},
- {0xa7, 0x42},
- {0xa7, 0x33},
- {0xa7, 0x00},
- {0xa7, 0x23},
- {0xa7, 0x1b},
- {0xa7, 0x74},
- {0xa7, 0x42},
- {0xa7, 0x33},
- {0xa7, 0x00},
- {0xa7, 0x23},
- {0xc0, 0xc8},
- {0xc1, 0x96},
- {0x8c, 0x00},
- {0x86, 0x3d},
- {0x50, 0x92},
- {0x51, 0x90},
- {0x52, 0x2c},
- {0x53, 0x00},
- {0x54, 0x00},
- {0x55, 0x88},
- {0x5a, 0x50},
- {0x5b, 0x3c},
- {0x5c, 0x00},
- {0xd3, 0x04},
- {0x7f, 0x00},
- {0xda, 0x00},
- {0xe5, 0x1f},
- {0xe1, 0x67},
- {0xe0, 0x00},
- {0xdd, 0x7f},
- {0x05, 0x00},
- {0xff, 0x00},
- {0xe0, 0x04},
- {0xc0, 0xc8},
- {0xc1, 0x96},
- {0x86, 0x3d},
- {0x50, 0x92},
- {0x51, 0x90},
- {0x52, 0x2c},
- {0x53, 0x00},
- {0x54, 0x00},
- {0x55, 0x88},
- {0x57, 0x00},
- {0x5a, 0x50},
- {0x5b, 0x3c},
- {0x5c, 0x00},
- {0xd3, 0x04},
- {0xe0, 0x00},
- {0xFF, 0x00},
- {0x05, 0x00},
- {0xDA, 0x08},
- {0xda, 0x09},
- {0x98, 0x00},
- {0x99, 0x00},
- {0x00, 0x00},
- {0xff, 0x00},
- {0xe0, 0x04},
- {0xc0, 0xc8},
- {0xc1, 0x96},
- {0x86, 0x3d},
- {0x50, 0x89},
- {0x51, 0x90},
- {0x52, 0x2c},
- {0x53, 0x00},
- {0x54, 0x00},
- {0x55, 0x88},
- {0x57, 0x00},
- {0x5a, 0xA0},
- {0x5b, 0x78},
- {0x5c, 0x00},
- {0xd3, 0x02},
- {0xe0, 0x00},
- };
- /* Initialization sequence for QVGA resolution (320x240) */
- const unsigned char OV2640_QVGA[][2]=
- {
- {0xff, 0x00},
- {0x2c, 0xff},
- {0x2e, 0xdf},
- {0xff, 0x01},
- {0x3c, 0x32},
- {0x11, 0x00},
- {0x09, 0x02},
- {0x04, 0xA8},
- {0x13, 0xe5},
- {0x14, 0x48},
- {0x2c, 0x0c},
- {0x33, 0x78},
- {0x3a, 0x33},
- {0x3b, 0xfB},
- {0x3e, 0x00},
- {0x43, 0x11},
- {0x16, 0x10},
- {0x4a, 0x81},
- {0x21, 0x99},
- {0x24, 0x40},
- {0x25, 0x38},
- {0x26, 0x82},
- {0x5c, 0x00},
- {0x63, 0x00},
- {0x46, 0x3f},
- {0x0c, 0x3c},
- {0x61, 0x70},
- {0x62, 0x80},
- {0x7c, 0x05},
- {0x20, 0x80},
- {0x28, 0x30},
- {0x6c, 0x00},
- {0x6d, 0x80},
- {0x6e, 0x00},
- {0x70, 0x02},
- {0x71, 0x94},
- {0x73, 0xc1},
- {0x3d, 0x34},
- {0x5a, 0x57},
- {0x12, 0x00},
- {0x11, 0x00},
- {0x17, 0x11},
- {0x18, 0x75},
- {0x19, 0x01},
- {0x1a, 0x97},
- {0x32, 0x36},
- {0x03, 0x0f},
- {0x37, 0x40},
- {0x4f, 0xbb},
- {0x50, 0x9c},
- {0x5a, 0x57},
- {0x6d, 0x80},
- {0x6d, 0x38},
- {0x39, 0x02},
- {0x35, 0x88},
- {0x22, 0x0a},
- {0x37, 0x40},
- {0x23, 0x00},
- {0x34, 0xa0},
- {0x36, 0x1a},
- {0x06, 0x02},
- {0x07, 0xc0},
- {0x0d, 0xb7},
- {0x0e, 0x01},
- {0x4c, 0x00},
- {0xff, 0x00},
- {0xe5, 0x7f},
- {0xf9, 0xc0},
- {0x41, 0x24},
- {0xe0, 0x14},
- {0x76, 0xff},
- {0x33, 0xa0},
- {0x42, 0x20},
- {0x43, 0x18},
- {0x4c, 0x00},
- {0x87, 0xd0},
- {0x88, 0x3f},
- {0xd7, 0x03},
- {0xd9, 0x10},
- {0xd3, 0x82},
- {0xc8, 0x08},
- {0xc9, 0x80},
- {0x7d, 0x00},
- {0x7c, 0x03},
- {0x7d, 0x48},
- {0x7c, 0x08},
- {0x7d, 0x20},
- {0x7d, 0x10},
- {0x7d, 0x0e},
- {0x90, 0x00},
- {0x91, 0x0e},
- {0x91, 0x1a},
- {0x91, 0x31},
- {0x91, 0x5a},
- {0x91, 0x69},
- {0x91, 0x75},
- {0x91, 0x7e},
- {0x91, 0x88},
- {0x91, 0x8f},
- {0x91, 0x96},
- {0x91, 0xa3},
- {0x91, 0xaf},
- {0x91, 0xc4},
- {0x91, 0xd7},
- {0x91, 0xe8},
- {0x91, 0x20},
- {0x92, 0x00},
- {0x93, 0x06},
- {0x93, 0xe3},
- {0x93, 0x02},
- {0x93, 0x02},
- {0x93, 0x00},
- {0x93, 0x04},
- {0x93, 0x00},
- {0x93, 0x03},
- {0x93, 0x00},
- {0x93, 0x00},
- {0x93, 0x00},
- {0x93, 0x00},
- {0x93, 0x00},
- {0x93, 0x00},
- {0x93, 0x00},
- {0x96, 0x00},
- {0x97, 0x08},
- {0x97, 0x19},
- {0x97, 0x02},
- {0x97, 0x0c},
- {0x97, 0x24},
- {0x97, 0x30},
- {0x97, 0x28},
- {0x97, 0x26},
- {0x97, 0x02},
- {0x97, 0x98},
- {0x97, 0x80},
- {0x97, 0x00},
- {0x97, 0x00},
- {0xc3, 0xef},
- {0xff, 0x00},
- {0xba, 0xdc},
- {0xbb, 0x08},
- {0xb6, 0x24},
- {0xb8, 0x33},
- {0xb7, 0x20},
- {0xb9, 0x30},
- {0xb3, 0xb4},
- {0xb4, 0xca},
- {0xb5, 0x43},
- {0xb0, 0x5c},
- {0xb1, 0x4f},
- {0xb2, 0x06},
- {0xc7, 0x00},
- {0xc6, 0x51},
- {0xc5, 0x11},
- {0xc4, 0x9c},
- {0xbf, 0x00},
- {0xbc, 0x64},
- {0xa6, 0x00},
- {0xa7, 0x1e},
- {0xa7, 0x6b},
- {0xa7, 0x47},
- {0xa7, 0x33},
- {0xa7, 0x00},
- {0xa7, 0x23},
- {0xa7, 0x2e},
- {0xa7, 0x85},
- {0xa7, 0x42},
- {0xa7, 0x33},
- {0xa7, 0x00},
- {0xa7, 0x23},
- {0xa7, 0x1b},
- {0xa7, 0x74},
- {0xa7, 0x42},
- {0xa7, 0x33},
- {0xa7, 0x00},
- {0xa7, 0x23},
- {0xc0, 0xc8},
- {0xc1, 0x96},
- {0x8c, 0x00},
- {0x86, 0x3d},
- {0x50, 0x92},
- {0x51, 0x90},
- {0x52, 0x2c},
- {0x53, 0x00},
- {0x54, 0x00},
- {0x55, 0x88},
- {0x5a, 0x50},
- {0x5b, 0x3c},
- {0x5c, 0x00},
- {0xd3, 0x04},
- {0x7f, 0x00},
- {0xda, 0x00},
- {0xe5, 0x1f},
- {0xe1, 0x67},
- {0xe0, 0x00},
- {0xdd, 0x7f},
- {0x05, 0x00},
- {0xff, 0x00},
- {0xe0, 0x04},
- {0xc0, 0xc8},
- {0xc1, 0x96},
- {0x86, 0x3d},
- {0x50, 0x92},
- {0x51, 0x90},
- {0x52, 0x2c},
- {0x53, 0x00},
- {0x54, 0x00},
- {0x55, 0x88},
- {0x57, 0x00},
- {0x5a, 0x50},
- {0x5b, 0x3C},
- {0x5c, 0x00},
- {0xd3, 0x08},
- {0xe0, 0x00},
- {0xFF, 0x00},
- {0x05, 0x00},
- {0xDA, 0x08},
- {0xda, 0x09},
- {0x98, 0x00},
- {0x99, 0x00},
- {0x00, 0x00},
- };
- /* Initialization sequence for QQVGA resolution (160x120) */
- const char OV2640_QQVGA[][2]=
- {
- {0xff, 0x00},
- {0x2c, 0xff},
- {0x2e, 0xdf},
- {0xff, 0x01},
- {0x3c, 0x32},
- {0x11, 0x00},
- {0x09, 0x02},
- {0x04, 0xA8},
- {0x13, 0xe5},
- {0x14, 0x48},
- {0x2c, 0x0c},
- {0x33, 0x78},
- {0x3a, 0x33},
- {0x3b, 0xfB},
- {0x3e, 0x00},
- {0x43, 0x11},
- {0x16, 0x10},
- {0x4a, 0x81},
- {0x21, 0x99},
- {0x24, 0x40},
- {0x25, 0x38},
- {0x26, 0x82},
- {0x5c, 0x00},
- {0x63, 0x00},
- {0x46, 0x3f},
- {0x0c, 0x3c},
- {0x61, 0x70},
- {0x62, 0x80},
- {0x7c, 0x05},
- {0x20, 0x80},
- {0x28, 0x30},
- {0x6c, 0x00},
- {0x6d, 0x80},
- {0x6e, 0x00},
- {0x70, 0x02},
- {0x71, 0x94},
- {0x73, 0xc1},
- {0x3d, 0x34},
- {0x5a, 0x57},
- {0x12, 0x00},
- {0x11, 0x00},
- {0x17, 0x11},
- {0x18, 0x75},
- {0x19, 0x01},
- {0x1a, 0x97},
- {0x32, 0x36},
- {0x03, 0x0f},
- {0x37, 0x40},
- {0x4f, 0xbb},
- {0x50, 0x9c},
- {0x5a, 0x57},
- {0x6d, 0x80},
- {0x6d, 0x38},
- {0x39, 0x02},
- {0x35, 0x88},
- {0x22, 0x0a},
- {0x37, 0x40},
- {0x23, 0x00},
- {0x34, 0xa0},
- {0x36, 0x1a},
- {0x06, 0x02},
- {0x07, 0xc0},
- {0x0d, 0xb7},
- {0x0e, 0x01},
- {0x4c, 0x00},
- {0xff, 0x00},
- {0xe5, 0x7f},
- {0xf9, 0xc0},
- {0x41, 0x24},
- {0xe0, 0x14},
- {0x76, 0xff},
- {0x33, 0xa0},
- {0x42, 0x20},
- {0x43, 0x18},
- {0x4c, 0x00},
- {0x87, 0xd0},
- {0x88, 0x3f},
- {0xd7, 0x03},
- {0xd9, 0x10},
- {0xd3, 0x82},
- {0xc8, 0x08},
- {0xc9, 0x80},
- {0x7d, 0x00},
- {0x7c, 0x03},
- {0x7d, 0x48},
- {0x7c, 0x08},
- {0x7d, 0x20},
- {0x7d, 0x10},
- {0x7d, 0x0e},
- {0x90, 0x00},
- {0x91, 0x0e},
- {0x91, 0x1a},
- {0x91, 0x31},
- {0x91, 0x5a},
- {0x91, 0x69},
- {0x91, 0x75},
- {0x91, 0x7e},
- {0x91, 0x88},
- {0x91, 0x8f},
- {0x91, 0x96},
- {0x91, 0xa3},
- {0x91, 0xaf},
- {0x91, 0xc4},
- {0x91, 0xd7},
- {0x91, 0xe8},
- {0x91, 0x20},
- {0x92, 0x00},
- {0x93, 0x06},
- {0x93, 0xe3},
- {0x93, 0x02},
- {0x93, 0x02},
- {0x93, 0x00},
- {0x93, 0x04},
- {0x93, 0x00},
- {0x93, 0x03},
- {0x93, 0x00},
- {0x93, 0x00},
- {0x93, 0x00},
- {0x93, 0x00},
- {0x93, 0x00},
- {0x93, 0x00},
- {0x93, 0x00},
- {0x96, 0x00},
- {0x97, 0x08},
- {0x97, 0x19},
- {0x97, 0x02},
- {0x97, 0x0c},
- {0x97, 0x24},
- {0x97, 0x30},
- {0x97, 0x28},
- {0x97, 0x26},
- {0x97, 0x02},
- {0x97, 0x98},
- {0x97, 0x80},
- {0x97, 0x00},
- {0x97, 0x00},
- {0xc3, 0xef},
- {0xff, 0x00},
- {0xba, 0xdc},
- {0xbb, 0x08},
- {0xb6, 0x24},
- {0xb8, 0x33},
- {0xb7, 0x20},
- {0xb9, 0x30},
- {0xb3, 0xb4},
- {0xb4, 0xca},
- {0xb5, 0x43},
- {0xb0, 0x5c},
- {0xb1, 0x4f},
- {0xb2, 0x06},
- {0xc7, 0x00},
- {0xc6, 0x51},
- {0xc5, 0x11},
- {0xc4, 0x9c},
- {0xbf, 0x00},
- {0xbc, 0x64},
- {0xa6, 0x00},
- {0xa7, 0x1e},
- {0xa7, 0x6b},
- {0xa7, 0x47},
- {0xa7, 0x33},
- {0xa7, 0x00},
- {0xa7, 0x23},
- {0xa7, 0x2e},
- {0xa7, 0x85},
- {0xa7, 0x42},
- {0xa7, 0x33},
- {0xa7, 0x00},
- {0xa7, 0x23},
- {0xa7, 0x1b},
- {0xa7, 0x74},
- {0xa7, 0x42},
- {0xa7, 0x33},
- {0xa7, 0x00},
- {0xa7, 0x23},
- {0xc0, 0xc8},
- {0xc1, 0x96},
- {0x8c, 0x00},
- {0x86, 0x3d},
- {0x50, 0x92},
- {0x51, 0x90},
- {0x52, 0x2c},
- {0x53, 0x00},
- {0x54, 0x00},
- {0x55, 0x88},
- {0x5a, 0x50},
- {0x5b, 0x3c},
- {0x5c, 0x00},
- {0xd3, 0x04},
- {0x7f, 0x00},
- {0xda, 0x00},
- {0xe5, 0x1f},
- {0xe1, 0x67},
- {0xe0, 0x00},
- {0xdd, 0x7f},
- {0x05, 0x00},
- {0xff, 0x00},
- {0xe0, 0x04},
- {0xc0, 0xc8},
- {0xc1, 0x96},
- {0x86, 0x3d},
- {0x50, 0x92},
- {0x51, 0x90},
- {0x52, 0x2c},
- {0x53, 0x00},
- {0x54, 0x00},
- {0x55, 0x88},
- {0x57, 0x00},
- {0x5a, 0x28},
- {0x5b, 0x1E},
- {0x5c, 0x00},
- {0xd3, 0x08},
- {0xe0, 0x00},
- {0xFF, 0x00},
- {0x05, 0x00},
- {0xDA, 0x08},
- {0xda, 0x09},
- {0x98, 0x00},
- {0x99, 0x00},
- {0x00, 0x00},
- };
- /**
- * @}
- */
-
- /** @defgroup OV2640_Private_Functions
- * @{
- */
-
- /**
- * @brief Initializes the OV2640 CAMERA component.
- * @param DeviceAddr: Device address on communication Bus.
- * @param resolution: Camera resolution
- * @retval None
- */
- void ov2640_Init(uint16_t DeviceAddr, uint32_t resolution)
- {
- uint32_t index;
-
- /* Initialize I2C */
- CAMERA_IO_Init();
-
- /* Prepare the camera to be configured */
- CAMERA_IO_Write(DeviceAddr, OV2640_DSP_RA_DLMT, 0x01);
- CAMERA_IO_Write(DeviceAddr, OV2640_SENSOR_COM7, 0x80);
- CAMERA_Delay(200);
-
- /* Initialize OV2640 */
- switch (resolution)
- {
- case CAMERA_R160x120:
- {
- for(index=0; index<(sizeof(OV2640_QQVGA)/2); index++)
- {
- CAMERA_IO_Write(DeviceAddr, OV2640_QQVGA[index][0], OV2640_QQVGA[index][1]);
- CAMERA_Delay(1);
- }
- break;
- }
- case CAMERA_R320x240:
- {
- for(index=0; index<(sizeof(OV2640_QVGA)/2); index++)
- {
- CAMERA_IO_Write(DeviceAddr, OV2640_QVGA[index][0], OV2640_QVGA[index][1]);
- CAMERA_Delay(1);
- }
- break;
- }
- case CAMERA_R480x272:
- {
- for(index=0; index<(sizeof(OV2640_480x272)/2); index++)
- {
- CAMERA_IO_Write(DeviceAddr, OV2640_480x272[index][0], OV2640_480x272[index][1]);
- CAMERA_Delay(2);
- }
- break;
- }
- case CAMERA_R640x480:
- {
- for(index=0; index<(sizeof(OV2640_VGA)/2); index++)
- {
- CAMERA_IO_Write(DeviceAddr, OV2640_VGA[index][0], OV2640_VGA[index][1]);
- CAMERA_Delay(2);
- }
- break;
- }
- default:
- {
- break;
- }
- }
- }
- /**
- * @brief Configures the OV2640 camera feature.
- * @param DeviceAddr: Device address on communication Bus.
- * @param feature: Camera feature to be configured
- * @param value: Value to be configured
- * @param brightness_value: Brightness value to be configured
- * @retval None
- */
- void ov2640_Config(uint16_t DeviceAddr, uint32_t feature, uint32_t value, uint32_t brightness_value)
- {
- uint8_t value1, value2;
- uint32_t value_tmp;
- uint32_t br_value;
-
- /* Convert the input value into ov2640 parameters */
- value_tmp = ov2640_ConvertValue(feature, value);
- br_value = ov2640_ConvertValue(CAMERA_CONTRAST_BRIGHTNESS, brightness_value);
-
- switch(feature)
- {
- case CAMERA_BLACK_WHITE:
- {
- CAMERA_IO_Write(DeviceAddr, 0xff, 0x00);
- CAMERA_IO_Write(DeviceAddr, 0x7c, 0x00);
- CAMERA_IO_Write(DeviceAddr, 0x7d, value_tmp);
- CAMERA_IO_Write(DeviceAddr, 0x7c, 0x05);
- CAMERA_IO_Write(DeviceAddr, 0x7d, 0x80);
- CAMERA_IO_Write(DeviceAddr, 0x7d, 0x80);
- break;
- }
- case CAMERA_CONTRAST_BRIGHTNESS:
- {
- value1 = (uint8_t)(value_tmp);
- value2 = (uint8_t)(value_tmp >> 8);
- CAMERA_IO_Write(DeviceAddr, 0xff, 0x00);
- CAMERA_IO_Write(DeviceAddr, 0x7c, 0x00);
- CAMERA_IO_Write(DeviceAddr, 0x7d, 0x04);
- CAMERA_IO_Write(DeviceAddr, 0x7c, 0x07);
- CAMERA_IO_Write(DeviceAddr, 0x7d, br_value);
- CAMERA_IO_Write(DeviceAddr, 0x7d, value1);
- CAMERA_IO_Write(DeviceAddr, 0x7d, value2);
- CAMERA_IO_Write(DeviceAddr, 0x7d, 0x06);
- break;
- }
- case CAMERA_COLOR_EFFECT:
- {
- value1 = (uint8_t)(value_tmp);
- value2 = (uint8_t)(value_tmp >> 8);
- CAMERA_IO_Write(DeviceAddr, 0xff, 0x00);
- CAMERA_IO_Write(DeviceAddr, 0x7c, 0x00);
- CAMERA_IO_Write(DeviceAddr, 0x7d, 0x18);
- CAMERA_IO_Write(DeviceAddr, 0x7c, 0x05);
- CAMERA_IO_Write(DeviceAddr, 0x7d, value1);
- CAMERA_IO_Write(DeviceAddr, 0x7d, value2);
- break;
- }
- default:
- {
- break;
- }
- }
- }
- /**
- * @brief Read the OV2640 Camera identity.
- * @param DeviceAddr: Device address on communication Bus.
- * @retval the OV2640 ID
- */
- uint16_t ov2640_ReadID(uint16_t DeviceAddr)
- {
- /* Initialize I2C */
- CAMERA_IO_Init();
-
- /* Prepare the sensor to read the Camera ID */
- CAMERA_IO_Write(DeviceAddr, OV2640_DSP_RA_DLMT, 0x01);
-
- /* Get the camera ID */
- return (CAMERA_IO_Read(DeviceAddr, OV2640_SENSOR_PIDH));
- }
- /******************************************************************************
- Static Functions
- *******************************************************************************/
- /**
- * @brief Convert input values into ov2640 parameters.
- * @param feature: Camera feature to be configured
- * @param value: Value to be configured
- * @retval The converted value
- */
- static uint32_t ov2640_ConvertValue(uint32_t feature, uint32_t value)
- {
- uint32_t ret = 0;
-
- switch(feature)
- {
- case CAMERA_BLACK_WHITE:
- {
- switch(value)
- {
- case CAMERA_BLACK_WHITE_BW:
- {
- ret = OV2640_BLACK_WHITE_BW;
- break;
- }
- case CAMERA_BLACK_WHITE_NEGATIVE:
- {
- ret = OV2640_BLACK_WHITE_NEGATIVE;
- break;
- }
- case CAMERA_BLACK_WHITE_BW_NEGATIVE:
- {
- ret = OV2640_BLACK_WHITE_BW_NEGATIVE;
- break;
- }
- case CAMERA_BLACK_WHITE_NORMAL:
- {
- ret = OV2640_BLACK_WHITE_NORMAL;
- break;
- }
- default:
- {
- ret = OV2640_BLACK_WHITE_NORMAL;
- break;
- }
- }
- break;
- }
- case CAMERA_CONTRAST_BRIGHTNESS:
- {
- switch(value)
- {
- case CAMERA_BRIGHTNESS_LEVEL0:
- {
- ret = OV2640_BRIGHTNESS_LEVEL0;
- break;
- }
- case CAMERA_BRIGHTNESS_LEVEL1:
- {
- ret = OV2640_BRIGHTNESS_LEVEL1;
- break;
- }
- case CAMERA_BRIGHTNESS_LEVEL2:
- {
- ret = OV2640_BRIGHTNESS_LEVEL2;
- break;
- }
- case CAMERA_BRIGHTNESS_LEVEL3:
- {
- ret = OV2640_BRIGHTNESS_LEVEL3;
- break;
- }
- case CAMERA_BRIGHTNESS_LEVEL4:
- {
- ret = OV2640_BRIGHTNESS_LEVEL4;
- break;
- }
- case CAMERA_CONTRAST_LEVEL0:
- {
- ret = OV2640_CONTRAST_LEVEL0;
- break;
- }
- case CAMERA_CONTRAST_LEVEL1:
- {
- ret = OV2640_CONTRAST_LEVEL1;
- break;
- }
- case CAMERA_CONTRAST_LEVEL2:
- {
- ret = OV2640_CONTRAST_LEVEL2;
- break;
- }
- case CAMERA_CONTRAST_LEVEL3:
- {
- ret = OV2640_CONTRAST_LEVEL3;
- break;
- }
- case CAMERA_CONTRAST_LEVEL4:
- {
- ret = OV2640_CONTRAST_LEVEL4;
- break;
- }
- default:
- {
- ret = OV2640_CONTRAST_LEVEL0;
- break;
- }
- }
- break;
- }
- case CAMERA_COLOR_EFFECT:
- {
- switch(value)
- {
- case CAMERA_COLOR_EFFECT_ANTIQUE:
- {
- ret = OV2640_COLOR_EFFECT_ANTIQUE;
- break;
- }
- case CAMERA_COLOR_EFFECT_BLUE:
- {
- ret = OV2640_COLOR_EFFECT_BLUE;
- break;
- }
- case CAMERA_COLOR_EFFECT_GREEN:
- {
- ret = OV2640_COLOR_EFFECT_GREEN;
- break;
- }
- case CAMERA_COLOR_EFFECT_RED:
- {
- ret = OV2640_COLOR_EFFECT_RED;
- break;
- }
- default:
- {
- ret = OV2640_COLOR_EFFECT_RED;
- break;
- }
- }
- break;
- default:
- {
- ret = 0;
- break;
- }
- }
- }
-
- return ret;
- }
-
- /**
- * @}
- */
-
- /**
- * @}
- */
- /**
- * @}
- */
-
- /**
- * @}
- */
- /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|