找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
查看: 3284|回复: 0
打印 上一主题 下一主题
收起左侧

STM32F4XX OV9655摄像头驱动程序

[复制链接]
跳转到指定楼层
楼主
使用ov9655摄像头,拍摄图象。


全部源码下载:
STM32F4XX OV9655摄像头程序.zip (540.44 KB, 下载次数: 20)




部分源码预览:
  1. /**
  2.   ******************************************************************************
  3.   * @file    main.c
  4.   * @author  MCD Application Team
  5.   * @version V1.0.0
  6.   * @brief   Main program body
  7.   ******************************************************************************
  8.   * @attention
  9.   *
  10.   * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
  11.   * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
  12.   * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
  13.   * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
  14.   * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
  15.   * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
  16.   *
  17.   ******************************************************************************  
  18.   */

  19. /* Includes ------------------------------------------------------------------*/
  20. #include "stm32f4xx.h"
  21. #include "usart.h"
  22. #include "LCD/LCD.h"
  23. #include "camera/dcmi_OV9655.h"

  24. /** @addtogroup STM32F2xx_StdPeriph_Examples
  25.   * @{
  26.   */

  27. /** @addtogroup IOToggle
  28.   * @{
  29.   */
  30. void LCD_CS_ResetBits(void);
  31. void Delay(__IO uint32_t nTime);
  32. void TimingDelay_Decrement(void);
  33. static __IO uint32_t TimingDelay;

  34. uint32_t        fps=0;
  35. uint32_t        disfps=0;
  36. uint32_t        fpsbuff[5];
  37. /**
  38.   * @brief  Main program
  39.   * @param  None
  40.   * @retval None
  41.   */
  42. int main(void)
  43. {       
  44.         OV9655_IDTypeDef OV9655ID;
  45.   /*!< At this stage the microcontroller clock setting is already configured,
  46.        this is done through SystemInit() function which is called from startup
  47.        file (startup_stm32f2xx.s) before to branch to application main.
  48.        To reconfigure the default setting of SystemInit() function, refer to
  49.         system_stm32f2xx.c file
  50.      */

  51.         USART_Configuration();
  52.         //USART_NVIC_Config();

  53.         LCD_Initializtion();
  54.         LCD_Clear(Red);
  55.         GUI_Text(50,70,"Camera Init..",White,Red);

  56.         printf("\r\n\r\nWelcome to WaveShare STM32F2 series MCU Board Open207I\r\n");
  57.         printf("OV9655 Init..\r\n");
  58.         if(DCMI_OV9655Config()==0){
  59.                 printf("Camera Have Init..\r\n");
  60.                 GUI_Text(50,90,"Camera Have Init..",White,Red);
  61.                 }
  62.         else {
  63.                 printf("OV9655 Init fails!!\r\n");
  64.                 GUI_Text(50,90,"OV9655 Init fails!!",White,Red);
  65.                 }

  66.         DCMI_OV9655_ReadID(&OV9655ID);
  67.         printf("OV9655 ID:0x%x 0x%x 0x%x 0x%x\r\n",OV9655ID.Manufacturer_ID1, OV9655ID.Manufacturer_ID2, OV9655ID.PID, OV9655ID.Version);
  68.        
  69.                        
  70.         LCD_WriteReg(0x0011,0x6068);
  71.         LCD_SetCursor(0,0);
  72.         Prepare_Write_RAM();

  73.         /* Start Image capture and Display on the LCD *****************************/
  74.     /* Enable DMA transfer */
  75.     DMA_Cmd(DMA2_Stream1, ENABLE);

  76.     /* Enable DCMI interface */
  77.     DCMI_Cmd(ENABLE);

  78.     /* Start Image capture */
  79.     DCMI_CaptureCmd(ENABLE);
  80.           
  81.         //DCMI_SingleRandomWrite(OV9655_DEVICE_WRITE_ADDRESS,0x8d, 0x10); //color test        on
  82.         //DCMI_SingleRandomWrite(OV9655_DEVICE_WRITE_ADDRESS,0x0c, 0x80); //color test        on
  83.         //uint32_t i=0x1fffff;
  84. //        while(i--);
  85.         //DCMI_SingleRandomWrite(OV9655_DEVICE_WRITE_ADDRESS,0x8d, 0x00); //color test off
  86.         //DCMI_SingleRandomWrite(OV9655_DEVICE_WRITE_ADDRESS,0x0c, 0x00); //color test off                                       
  87.         while (1)
  88.         {
  89.         }
  90. }

  91. void Delay(__IO uint32_t nTime)
  92. {
  93.   TimingDelay = nTime;

  94.   while(TimingDelay != 0)
  95.   {}
  96. }

  97. void TimingDelay_Decrement(void)
  98. {
  99.   if (TimingDelay != 0x00)
  100.   {
  101.     TimingDelay--;
  102.   }
  103. }

  104. void LCD_CS_ResetBits(void)
  105. {
  106.         GPIO_InitTypeDef  GPIO_InitStructure;
  107.     RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOD, ENABLE);

  108.         //LCD_CS PD7

  109.     GPIO_InitStructure.GPIO_Pin = GPIO_Pin_7;
  110.         GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
  111.         GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
  112.         GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;
  113.         GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
  114.         GPIO_Init(GPIOD, &GPIO_InitStructure);       


  115.         GPIO_ResetBits(GPIOD , GPIO_Pin_7);                 //CS=0;
  116. }


  117. #ifdef  USE_FULL_ASSERT

  118. /**
  119.   * @brief  Reports the name of the source file and the source line number
  120.   *         where the assert_param error has occurred.
  121.   * @param  file: pointer to the source file name
  122.   * @param  line: assert_param error line source number
  123.   * @retval None
  124.   */
  125. void assert_failed(uint8_t* file, uint32_t line)
  126. {
  127.   /* User can add his own implementation to report the file name and line number,
  128.      ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */

  129.   /* Infinite loop */
  130.   while (1)
  131.   {

  132.   }
  133. }
  134. #endif

  135. /**
  136.   * @}
  137.   */

  138. /**
  139.   * @}
  140.   */

  141. /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/
复制代码




评分

参与人数 1黑币 +50 收起 理由
admin + 50 共享资料的黑币奖励!

查看全部评分

分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖 顶 踩
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手机版|小黑屋|51黑电子论坛 |51黑电子论坛6群 QQ 管理员QQ:125739409;技术交流QQ群281945664

Powered by 单片机教程网

快速回复 返回顶部 返回列表