Browse Source

[bsp/stm32] add ov5640、dcmi、i2c for openmv

Miaowulue 3 years ago
parent
commit
da0164cf8e

+ 24 - 6
bsp/stm32/stm32h743-openmv-h7plus/.config

@@ -29,7 +29,7 @@ CONFIG_IDLE_THREAD_STACK_SIZE=256
 # CONFIG_RT_KSERVICE_USING_STDLIB is not set
 # CONFIG_RT_KSERVICE_USING_TINY_SIZE is not set
 # CONFIG_RT_USING_TINY_FFS is not set
-# CONFIG_RT_PRINTF_LONGLONG is not set
+# CONFIG_RT_KPRINTF_USING_LONGLONG is not set
 CONFIG_RT_DEBUG=y
 CONFIG_RT_DEBUG_COLOR=y
 # CONFIG_RT_DEBUG_INIT_CONFIG is not set
@@ -157,7 +157,10 @@ CONFIG_RT_SERIAL_RB_BUFSZ=64
 # CONFIG_RT_USING_CAN is not set
 # CONFIG_RT_USING_HWTIMER is not set
 # CONFIG_RT_USING_CPUTIME is not set
-# CONFIG_RT_USING_I2C is not set
+CONFIG_RT_USING_I2C=y
+# CONFIG_RT_I2C_DEBUG is not set
+CONFIG_RT_USING_I2C_BITOPS=y
+# CONFIG_RT_I2C_BITOPS_DEBUG is not set
 # CONFIG_RT_USING_PHY is not set
 CONFIG_RT_USING_PIN=y
 # CONFIG_RT_USING_ADC is not set
@@ -166,7 +169,9 @@ CONFIG_RT_USING_PIN=y
 # CONFIG_RT_USING_MTD_NOR is not set
 # CONFIG_RT_USING_MTD_NAND is not set
 # CONFIG_RT_USING_PM is not set
-# CONFIG_RT_USING_RTC is not set
+CONFIG_RT_USING_RTC=y
+# CONFIG_RT_USING_ALARM is not set
+# CONFIG_RT_USING_SOFT_RTC is not set
 CONFIG_RT_USING_SDIO=y
 CONFIG_RT_SDIO_STACK_SIZE=512
 CONFIG_RT_SDIO_THREAD_PRIORITY=15
@@ -561,6 +566,7 @@ CONFIG_RT_USING_POSIX_FS=y
 # CONFIG_PKG_USING_TINYUSB is not set
 # CONFIG_PKG_USING_CHERRYUSB is not set
 # CONFIG_PKG_USING_KMULTI_RTIMER is not set
+# CONFIG_PKG_USING_TFDB is not set
 
 #
 # peripheral libraries and drivers
@@ -732,7 +738,8 @@ CONFIG_BSP_USING_UART1=y
 # CONFIG_BSP_UART1_RX_USING_DMA is not set
 # CONFIG_BSP_USING_UART2 is not set
 # CONFIG_BSP_USING_LPUART1 is not set
-# CONFIG_BSP_USING_QSPI is not set
+CONFIG_BSP_USING_QSPI=y
+# CONFIG_BSP_USING_ONCHIP_RTC is not set
 # CONFIG_BSP_USING_CRC is not set
 # CONFIG_BSP_USING_RNG is not set
 # CONFIG_BSP_USING_UDID is not set
@@ -741,6 +748,17 @@ CONFIG_BSP_USING_UART1=y
 # Onboard Peripheral Drivers
 #
 CONFIG_BSP_USING_SDRAM=y
-# CONFIG_BSP_USING_QSPI_FLASH is not set
+CONFIG_BSP_USING_QSPI_FLASH=y
 # CONFIG_BSP_USING_SDMMC is not set
-# CONFIG_BSP_USING_USBD is not set
+CONFIG_BSP_USING_USBD=y
+CONFIG_BSP_USING_OV5640=y
+CONFIG_BSP_USING_DCMI=y
+CONFIG_BSP_USING_I2C=y
+CONFIG_BSP_USING_I2C1=y
+
+#
+# Notice: PB8 --> 24; PB9 --> 25
+#
+CONFIG_BSP_I2C1_SCL_PIN=24
+CONFIG_BSP_I2C1_SDA_PIN=25
+# CONFIG_BSP_USING_I2C2 is not set

+ 7 - 8
bsp/stm32/stm32h743-openmv-h7plus/README.md

@@ -43,6 +43,10 @@ OPENMV4-H7-PLUS 是 OPENMV公司推出的一款针对 STM32H7系列设计的 Cor
 | QSPI FLASH | 支持 | W25Q256JV |
 | SDIO | 支持 | USD-1040310811 |
 | USBCDC | 支持 |  |
+| RTC | 支持 | |
+| CAMERA | 支持 | OV5640 |
+| DCMI | 支持 |  |
+| I2C | 支持 | I2C1(PB8 SCL)(PB9 SDA); I2C2 (PB10 SCL)(PB11 SDA) |
 
 ## 使用说明
 
@@ -84,24 +88,19 @@ OPENMV4-H7-PLUS 是 OPENMV公司推出的一款针对 STM32H7系列设计的 Cor
  2006 - 2019 Copyright by rt-thread team
 msh >
 ```
+注意:由于BSP默认开启USBCDC,与shell的交互需通过虚拟串口。
+
 ### 进阶使用
 
-此 BSP 默认只开启了 GPIO 和 LPUART1 的功能,如果需使用更多高级功能,需要利用 ENV 工具对BSP 进行配置,步骤如下:
+此 BSP 默认开启了 GPIO 、 USART1、QSPI FLASH、USBCDC和CAMERA的功能,如果需使用更多高级功能,需要利用 ENV 工具对BSP 进行配置,步骤如下:
 
 1. 在 bsp 下打开 env 工具。
-
 2. 输入`menuconfig`命令配置工程,配置好之后保存退出。
-
 3. 输入`pkgs --update`命令更新软件包。
-
 4. 输入`scons --target=mdk4/mdk5/iar` 命令重新生成工程。
 
 本章节更多详细的介绍请参考 [STM32 系列 BSP 外设驱动使用教程](../docs/STM32系列BSP外设驱动使用教程.md)。
 
-
-
-5. USBD CDC使用,参考文章[STM32L496 USB CDC适配](https://club.rt-thread.org/ask/article/2959.html)(bsp已配置引脚和修改Kconfig)
-
 ## 注意事项
 
 - 开机时如果不能打印 RT-Thread 版本信息,请重新选择 PC 端串口调试软件的串口号或将 BSP 中串口的 GPIO 速率调低

+ 3 - 1
bsp/stm32/stm32h743-openmv-h7plus/applications/main.c

@@ -18,7 +18,9 @@ int main(void)
 {
     /* set LED2 pin mode to output */
     rt_pin_mode(LED1_PIN, PIN_MODE_OUTPUT);
-
+    #ifdef BSP_USING_USBD
+        rt_console_set_device("vcom");
+    #endif
     while (1)
     {
         rt_pin_write(LED1_PIN, PIN_HIGH);

+ 2 - 0
bsp/stm32/stm32h743-openmv-h7plus/board/CubeMX_Config/Core/Inc/main.h

@@ -49,6 +49,8 @@ extern "C" {
 
 /* USER CODE END EM */
 
+void HAL_TIM_MspPostInit(TIM_HandleTypeDef *htim);
+
 /* Exported functions prototypes ---------------------------------------------*/
 void Error_Handler(void);
 

+ 3 - 3
bsp/stm32/stm32h743-openmv-h7plus/board/CubeMX_Config/Core/Inc/stm32h7xx_hal_conf.h

@@ -43,7 +43,7 @@
 /* #define HAL_CRC_MODULE_ENABLED   */
 /* #define HAL_CRYP_MODULE_ENABLED   */
 /* #define HAL_DAC_MODULE_ENABLED   */
-/* #define HAL_DCMI_MODULE_ENABLED   */
+#define HAL_DCMI_MODULE_ENABLED
 /* #define HAL_DMA2D_MODULE_ENABLED   */
 /* #define HAL_ETH_MODULE_ENABLED   */
 /* #define HAL_NAND_MODULE_ENABLED   */
@@ -74,7 +74,7 @@
 /* #define HAL_SPDIFRX_MODULE_ENABLED   */
 /* #define HAL_SPI_MODULE_ENABLED   */
 /* #define HAL_SWPMI_MODULE_ENABLED   */
-/* #define HAL_TIM_MODULE_ENABLED   */
+#define HAL_TIM_MODULE_ENABLED
 #define HAL_UART_MODULE_ENABLED
 /* #define HAL_USART_MODULE_ENABLED   */
 /* #define HAL_IRDA_MODULE_ENABLED   */
@@ -168,7 +168,7 @@
 #define  TICK_INT_PRIORITY            (15UL) /*!< tick interrupt priority */
 #define  USE_RTOS                     0
 #define  USE_SD_TRANSCEIVER           0U               /*!< use uSD Transceiver */
-#define  USE_SPI_CRC	              0U               /*!< use CRC in SPI */
+#define  USE_SPI_CRC                  0U               /*!< use CRC in SPI */
 
 #define  USE_HAL_ADC_REGISTER_CALLBACKS     0U /* ADC register callback disabled     */
 #define  USE_HAL_CEC_REGISTER_CALLBACKS     0U /* CEC register callback disabled     */

+ 2 - 0
bsp/stm32/stm32h743-openmv-h7plus/board/CubeMX_Config/Core/Inc/stm32h7xx_it.h

@@ -55,7 +55,9 @@ void SVC_Handler(void);
 void DebugMon_Handler(void);
 void PendSV_Handler(void);
 void SysTick_Handler(void);
+void DMA1_Stream3_IRQHandler(void);
 void SDMMC1_IRQHandler(void);
+void DCMI_IRQHandler(void);
 void OTG_FS_EP1_OUT_IRQHandler(void);
 void OTG_FS_EP1_IN_IRQHandler(void);
 /* USER CODE BEGIN EFP */

+ 137 - 3
bsp/stm32/stm32h743-openmv-h7plus/board/CubeMX_Config/Core/Src/main.c

@@ -40,12 +40,17 @@
 
 /* Private variables ---------------------------------------------------------*/
 
+DCMI_HandleTypeDef hdcmi;
+DMA_HandleTypeDef hdma_dcmi;
+
 QSPI_HandleTypeDef hqspi;
 
 RTC_HandleTypeDef hrtc;
 
 SD_HandleTypeDef hsd1;
 
+TIM_HandleTypeDef htim1;
+
 UART_HandleTypeDef huart1;
 
 PCD_HandleTypeDef hpcd_USB_OTG_FS;
@@ -63,8 +68,11 @@ static void MX_USART1_UART_Init(void);
 static void MX_FMC_Init(void);
 static void MX_QUADSPI_Init(void);
 static void MX_SDMMC1_SD_Init(void);
-static void MX_USB_OTG_FS_PCD_Init(void);
+static void MX_DMA_Init(void);
 static void MX_RTC_Init(void);
+static void MX_DCMI_Init(void);
+static void MX_USB_OTG_FS_PCD_Init(void);
+static void MX_TIM1_Init(void);
 /* USER CODE BEGIN PFP */
 
 /* USER CODE END PFP */
@@ -112,8 +120,11 @@ int main(void)
   MX_FMC_Init();
   MX_QUADSPI_Init();
   MX_SDMMC1_SD_Init();
-  MX_USB_OTG_FS_PCD_Init();
+  MX_DMA_Init();
   MX_RTC_Init();
+  MX_DCMI_Init();
+  MX_USB_OTG_FS_PCD_Init();
+  MX_TIM1_Init();
   /* USER CODE BEGIN 2 */
 
   /* USER CODE END 2 */
@@ -187,6 +198,43 @@ void SystemClock_Config(void)
   }
 }
 
+/**
+  * @brief DCMI Initialization Function
+  * @param None
+  * @retval None
+  */
+static void MX_DCMI_Init(void)
+{
+
+  /* USER CODE BEGIN DCMI_Init 0 */
+
+  /* USER CODE END DCMI_Init 0 */
+
+  /* USER CODE BEGIN DCMI_Init 1 */
+
+  /* USER CODE END DCMI_Init 1 */
+  hdcmi.Instance = DCMI;
+  hdcmi.Init.SynchroMode = DCMI_SYNCHRO_HARDWARE;
+  hdcmi.Init.PCKPolarity = DCMI_PCKPOLARITY_FALLING;
+  hdcmi.Init.VSPolarity = DCMI_VSPOLARITY_LOW;
+  hdcmi.Init.HSPolarity = DCMI_HSPOLARITY_LOW;
+  hdcmi.Init.CaptureRate = DCMI_CR_ALL_FRAME;
+  hdcmi.Init.ExtendedDataMode = DCMI_EXTEND_DATA_8B;
+  hdcmi.Init.JPEGMode = DCMI_JPEG_ENABLE;
+  hdcmi.Init.ByteSelectMode = DCMI_BSM_ALL;
+  hdcmi.Init.ByteSelectStart = DCMI_OEBS_ODD;
+  hdcmi.Init.LineSelectMode = DCMI_LSM_ALL;
+  hdcmi.Init.LineSelectStart = DCMI_OELS_ODD;
+  if (HAL_DCMI_Init(&hdcmi) != HAL_OK)
+  {
+    Error_Handler();
+  }
+  /* USER CODE BEGIN DCMI_Init 2 */
+
+  /* USER CODE END DCMI_Init 2 */
+
+}
+
 /**
   * @brief QUADSPI Initialization Function
   * @param None
@@ -316,6 +364,76 @@ static void MX_SDMMC1_SD_Init(void)
 
 }
 
+/**
+  * @brief TIM1 Initialization Function
+  * @param None
+  * @retval None
+  */
+static void MX_TIM1_Init(void)
+{
+
+  /* USER CODE BEGIN TIM1_Init 0 */
+
+  /* USER CODE END TIM1_Init 0 */
+
+  TIM_MasterConfigTypeDef sMasterConfig = {0};
+  TIM_OC_InitTypeDef sConfigOC = {0};
+  TIM_BreakDeadTimeConfigTypeDef sBreakDeadTimeConfig = {0};
+
+  /* USER CODE BEGIN TIM1_Init 1 */
+
+  /* USER CODE END TIM1_Init 1 */
+  htim1.Instance = TIM1;
+  htim1.Init.Prescaler = 0;
+  htim1.Init.CounterMode = TIM_COUNTERMODE_UP;
+  htim1.Init.Period = 7;
+  htim1.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;
+  htim1.Init.RepetitionCounter = 0;
+  htim1.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_ENABLE;
+  if (HAL_TIM_PWM_Init(&htim1) != HAL_OK)
+  {
+    Error_Handler();
+  }
+  sMasterConfig.MasterOutputTrigger = TIM_TRGO_RESET;
+  sMasterConfig.MasterOutputTrigger2 = TIM_TRGO2_RESET;
+  sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE;
+  if (HAL_TIMEx_MasterConfigSynchronization(&htim1, &sMasterConfig) != HAL_OK)
+  {
+    Error_Handler();
+  }
+  sConfigOC.OCMode = TIM_OCMODE_PWM1;
+  sConfigOC.Pulse = 3;
+  sConfigOC.OCPolarity = TIM_OCPOLARITY_HIGH;
+  sConfigOC.OCNPolarity = TIM_OCNPOLARITY_HIGH;
+  sConfigOC.OCFastMode = TIM_OCFAST_DISABLE;
+  sConfigOC.OCIdleState = TIM_OCIDLESTATE_RESET;
+  sConfigOC.OCNIdleState = TIM_OCNIDLESTATE_RESET;
+  if (HAL_TIM_PWM_ConfigChannel(&htim1, &sConfigOC, TIM_CHANNEL_1) != HAL_OK)
+  {
+    Error_Handler();
+  }
+  sBreakDeadTimeConfig.OffStateRunMode = TIM_OSSR_DISABLE;
+  sBreakDeadTimeConfig.OffStateIDLEMode = TIM_OSSI_DISABLE;
+  sBreakDeadTimeConfig.LockLevel = TIM_LOCKLEVEL_OFF;
+  sBreakDeadTimeConfig.DeadTime = 0;
+  sBreakDeadTimeConfig.BreakState = TIM_BREAK_DISABLE;
+  sBreakDeadTimeConfig.BreakPolarity = TIM_BREAKPOLARITY_HIGH;
+  sBreakDeadTimeConfig.BreakFilter = 0;
+  sBreakDeadTimeConfig.Break2State = TIM_BREAK2_DISABLE;
+  sBreakDeadTimeConfig.Break2Polarity = TIM_BREAK2POLARITY_HIGH;
+  sBreakDeadTimeConfig.Break2Filter = 0;
+  sBreakDeadTimeConfig.AutomaticOutput = TIM_AUTOMATICOUTPUT_DISABLE;
+  if (HAL_TIMEx_ConfigBreakDeadTime(&htim1, &sBreakDeadTimeConfig) != HAL_OK)
+  {
+    Error_Handler();
+  }
+  /* USER CODE BEGIN TIM1_Init 2 */
+
+  /* USER CODE END TIM1_Init 2 */
+  HAL_TIM_MspPostInit(&htim1);
+
+}
+
 /**
   * @brief USART1 Initialization Function
   * @param None
@@ -400,6 +518,22 @@ static void MX_USB_OTG_FS_PCD_Init(void)
 
 }
 
+/**
+  * Enable DMA controller clock
+  */
+static void MX_DMA_Init(void)
+{
+
+  /* DMA controller clock enable */
+  __HAL_RCC_DMA1_CLK_ENABLE();
+
+  /* DMA interrupt init */
+  /* DMA1_Stream3_IRQn interrupt configuration */
+  HAL_NVIC_SetPriority(DMA1_Stream3_IRQn, 0, 0);
+  HAL_NVIC_EnableIRQ(DMA1_Stream3_IRQn);
+
+}
+
 /* FMC initialization function */
 static void MX_FMC_Init(void)
 {
@@ -459,13 +593,13 @@ static void MX_GPIO_Init(void)
   /* GPIO Ports Clock Enable */
   __HAL_RCC_GPIOE_CLK_ENABLE();
   __HAL_RCC_GPIOC_CLK_ENABLE();
+  __HAL_RCC_GPIOB_CLK_ENABLE();
   __HAL_RCC_GPIOG_CLK_ENABLE();
   __HAL_RCC_GPIOD_CLK_ENABLE();
   __HAL_RCC_GPIOA_CLK_ENABLE();
   __HAL_RCC_GPIOI_CLK_ENABLE();
   __HAL_RCC_GPIOH_CLK_ENABLE();
   __HAL_RCC_GPIOF_CLK_ENABLE();
-  __HAL_RCC_GPIOB_CLK_ENABLE();
 
   /*Configure GPIO pin Output Level */
   HAL_GPIO_WritePin(LED_RED_GPIO_Port, LED_RED_Pin, GPIO_PIN_RESET);

+ 227 - 1
bsp/stm32/stm32h743-openmv-h7plus/board/CubeMX_Config/Core/Src/stm32h7xx_hal_msp.c

@@ -25,6 +25,7 @@
 #include "drv_common.h"
 #endif
 /* USER CODE END Includes */
+extern DMA_HandleTypeDef hdma_dcmi;
 
 /* Private typedef -----------------------------------------------------------*/
 /* USER CODE BEGIN TD */
@@ -59,7 +60,9 @@
 /* USER CODE BEGIN 0 */
 
 /* USER CODE END 0 */
-/**
+
+void HAL_TIM_MspPostInit(TIM_HandleTypeDef *htim);
+                    /**
   * Initializes the Global MSP.
   */
 void HAL_MspInit(void)
@@ -77,6 +80,159 @@ void HAL_MspInit(void)
   /* USER CODE END MspInit 1 */
 }
 
+/**
+* @brief DCMI MSP Initialization
+* This function configures the hardware resources used in this example
+* @param hdcmi: DCMI handle pointer
+* @retval None
+*/
+void HAL_DCMI_MspInit(DCMI_HandleTypeDef* hdcmi)
+{
+  GPIO_InitTypeDef GPIO_InitStruct = {0};
+  if(hdcmi->Instance==DCMI)
+  {
+  /* USER CODE BEGIN DCMI_MspInit 0 */
+
+  /* USER CODE END DCMI_MspInit 0 */
+    /* Peripheral clock enable */
+    __HAL_RCC_DCMI_CLK_ENABLE();
+
+    __HAL_RCC_GPIOE_CLK_ENABLE();
+    __HAL_RCC_GPIOB_CLK_ENABLE();
+    __HAL_RCC_GPIOG_CLK_ENABLE();
+    __HAL_RCC_GPIOC_CLK_ENABLE();
+    __HAL_RCC_GPIOA_CLK_ENABLE();
+    /**DCMI GPIO Configuration
+    PE4     ------> DCMI_D4
+    PE5     ------> DCMI_D6
+    PE6     ------> DCMI_D7
+    PB7     ------> DCMI_VSYNC
+    PB6     ------> DCMI_D5
+    PG11     ------> DCMI_D3
+    PG10     ------> DCMI_D2
+    PC7     ------> DCMI_D1
+    PC6     ------> DCMI_D0
+    PA4     ------> DCMI_HSYNC
+    PA6     ------> DCMI_PIXCLK
+    */
+    GPIO_InitStruct.Pin = GPIO_PIN_4|GPIO_PIN_5|GPIO_PIN_6;
+    GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
+    GPIO_InitStruct.Pull = GPIO_PULLUP;
+    GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
+    GPIO_InitStruct.Alternate = GPIO_AF13_DCMI;
+    HAL_GPIO_Init(GPIOE, &GPIO_InitStruct);
+
+    GPIO_InitStruct.Pin = GPIO_PIN_7|GPIO_PIN_6;
+    GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
+    GPIO_InitStruct.Pull = GPIO_PULLUP;
+    GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
+    GPIO_InitStruct.Alternate = GPIO_AF13_DCMI;
+    HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
+
+    GPIO_InitStruct.Pin = GPIO_PIN_11|GPIO_PIN_10;
+    GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
+    GPIO_InitStruct.Pull = GPIO_PULLUP;
+    GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
+    GPIO_InitStruct.Alternate = GPIO_AF13_DCMI;
+    HAL_GPIO_Init(GPIOG, &GPIO_InitStruct);
+
+    GPIO_InitStruct.Pin = GPIO_PIN_7|GPIO_PIN_6;
+    GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
+    GPIO_InitStruct.Pull = GPIO_PULLUP;
+    GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
+    GPIO_InitStruct.Alternate = GPIO_AF13_DCMI;
+    HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
+
+    GPIO_InitStruct.Pin = GPIO_PIN_4|GPIO_PIN_6;
+    GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
+    GPIO_InitStruct.Pull = GPIO_PULLUP;
+    GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
+    GPIO_InitStruct.Alternate = GPIO_AF13_DCMI;
+    HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
+
+    /* DCMI DMA Init */
+    /* DCMI Init */
+    hdma_dcmi.Instance = DMA1_Stream3;
+    hdma_dcmi.Init.Request = DMA_REQUEST_DCMI;
+    hdma_dcmi.Init.Direction = DMA_PERIPH_TO_MEMORY;
+    hdma_dcmi.Init.PeriphInc = DMA_PINC_DISABLE;
+    hdma_dcmi.Init.MemInc = DMA_MINC_ENABLE;
+    hdma_dcmi.Init.PeriphDataAlignment = DMA_PDATAALIGN_WORD;
+    hdma_dcmi.Init.MemDataAlignment = DMA_MDATAALIGN_WORD;
+    hdma_dcmi.Init.Mode = DMA_CIRCULAR;
+    hdma_dcmi.Init.Priority = DMA_PRIORITY_HIGH;
+    hdma_dcmi.Init.FIFOMode = DMA_FIFOMODE_ENABLE;
+    hdma_dcmi.Init.FIFOThreshold = DMA_FIFO_THRESHOLD_FULL;
+    hdma_dcmi.Init.MemBurst = DMA_MBURST_SINGLE;
+    hdma_dcmi.Init.PeriphBurst = DMA_PBURST_SINGLE;
+    if (HAL_DMA_Init(&hdma_dcmi) != HAL_OK)
+    {
+      Error_Handler();
+    }
+
+    __HAL_LINKDMA(hdcmi,DMA_Handle,hdma_dcmi);
+
+    /* DCMI interrupt Init */
+    HAL_NVIC_SetPriority(DCMI_IRQn, 0, 0);
+    HAL_NVIC_EnableIRQ(DCMI_IRQn);
+  /* USER CODE BEGIN DCMI_MspInit 1 */
+
+  /* USER CODE END DCMI_MspInit 1 */
+  }
+
+}
+
+/**
+* @brief DCMI MSP De-Initialization
+* This function freeze the hardware resources used in this example
+* @param hdcmi: DCMI handle pointer
+* @retval None
+*/
+void HAL_DCMI_MspDeInit(DCMI_HandleTypeDef* hdcmi)
+{
+  if(hdcmi->Instance==DCMI)
+  {
+  /* USER CODE BEGIN DCMI_MspDeInit 0 */
+
+  /* USER CODE END DCMI_MspDeInit 0 */
+    /* Peripheral clock disable */
+    __HAL_RCC_DCMI_CLK_DISABLE();
+
+    /**DCMI GPIO Configuration
+    PE4     ------> DCMI_D4
+    PE5     ------> DCMI_D6
+    PE6     ------> DCMI_D7
+    PB7     ------> DCMI_VSYNC
+    PB6     ------> DCMI_D5
+    PG11     ------> DCMI_D3
+    PG10     ------> DCMI_D2
+    PC7     ------> DCMI_D1
+    PC6     ------> DCMI_D0
+    PA4     ------> DCMI_HSYNC
+    PA6     ------> DCMI_PIXCLK
+    */
+    HAL_GPIO_DeInit(GPIOE, GPIO_PIN_4|GPIO_PIN_5|GPIO_PIN_6);
+
+    HAL_GPIO_DeInit(GPIOB, GPIO_PIN_7|GPIO_PIN_6);
+
+    HAL_GPIO_DeInit(GPIOG, GPIO_PIN_11|GPIO_PIN_10);
+
+    HAL_GPIO_DeInit(GPIOC, GPIO_PIN_7|GPIO_PIN_6);
+
+    HAL_GPIO_DeInit(GPIOA, GPIO_PIN_4|GPIO_PIN_6);
+
+    /* DCMI DMA DeInit */
+    HAL_DMA_DeInit(hdcmi->DMA_Handle);
+
+    /* DCMI interrupt DeInit */
+    HAL_NVIC_DisableIRQ(DCMI_IRQn);
+  /* USER CODE BEGIN DCMI_MspDeInit 1 */
+
+  /* USER CODE END DCMI_MspDeInit 1 */
+  }
+
+}
+
 /**
 * @brief QSPI MSP Initialization
 * This function configures the hardware resources used in this example
@@ -332,6 +488,76 @@ void HAL_SD_MspDeInit(SD_HandleTypeDef* hsd)
 
 }
 
+/**
+* @brief TIM_PWM MSP Initialization
+* This function configures the hardware resources used in this example
+* @param htim_pwm: TIM_PWM handle pointer
+* @retval None
+*/
+void HAL_TIM_PWM_MspInit(TIM_HandleTypeDef* htim_pwm)
+{
+  if(htim_pwm->Instance==TIM1)
+  {
+  /* USER CODE BEGIN TIM1_MspInit 0 */
+
+  /* USER CODE END TIM1_MspInit 0 */
+    /* Peripheral clock enable */
+    __HAL_RCC_TIM1_CLK_ENABLE();
+  /* USER CODE BEGIN TIM1_MspInit 1 */
+
+  /* USER CODE END TIM1_MspInit 1 */
+  }
+
+}
+
+void HAL_TIM_MspPostInit(TIM_HandleTypeDef* htim)
+{
+  GPIO_InitTypeDef GPIO_InitStruct = {0};
+  if(htim->Instance==TIM1)
+  {
+  /* USER CODE BEGIN TIM1_MspPostInit 0 */
+
+  /* USER CODE END TIM1_MspPostInit 0 */
+
+    __HAL_RCC_GPIOA_CLK_ENABLE();
+    /**TIM1 GPIO Configuration
+    PA8     ------> TIM1_CH1
+    */
+    GPIO_InitStruct.Pin = GPIO_PIN_8;
+    GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
+    GPIO_InitStruct.Pull = GPIO_PULLUP;
+    GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
+    GPIO_InitStruct.Alternate = GPIO_AF1_TIM1;
+    HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
+
+  /* USER CODE BEGIN TIM1_MspPostInit 1 */
+
+  /* USER CODE END TIM1_MspPostInit 1 */
+  }
+
+}
+/**
+* @brief TIM_PWM MSP De-Initialization
+* This function freeze the hardware resources used in this example
+* @param htim_pwm: TIM_PWM handle pointer
+* @retval None
+*/
+void HAL_TIM_PWM_MspDeInit(TIM_HandleTypeDef* htim_pwm)
+{
+  if(htim_pwm->Instance==TIM1)
+  {
+  /* USER CODE BEGIN TIM1_MspDeInit 0 */
+
+  /* USER CODE END TIM1_MspDeInit 0 */
+    /* Peripheral clock disable */
+    __HAL_RCC_TIM1_CLK_DISABLE();
+  /* USER CODE BEGIN TIM1_MspDeInit 1 */
+
+  /* USER CODE END TIM1_MspDeInit 1 */
+  }
+
+}
+
 /**
 * @brief UART MSP Initialization
 * This function configures the hardware resources used in this example

+ 210 - 84
bsp/stm32/stm32h743-openmv-h7plus/board/CubeMX_Config/CubeMX_Config.ioc

@@ -2,6 +2,31 @@
 CORTEX_M7.CPU_DCache=Enabled
 CORTEX_M7.CPU_ICache=Enabled
 CORTEX_M7.IPParameters=CPU_ICache,CPU_DCache
+DCMI.IPParameters=JPEGMode
+DCMI.JPEGMode=DCMI_JPEG_ENABLE
+Dma.DCMI.0.Direction=DMA_PERIPH_TO_MEMORY
+Dma.DCMI.0.EventEnable=DISABLE
+Dma.DCMI.0.FIFOMode=DMA_FIFOMODE_ENABLE
+Dma.DCMI.0.FIFOThreshold=DMA_FIFO_THRESHOLD_FULL
+Dma.DCMI.0.Instance=DMA1_Stream3
+Dma.DCMI.0.MemBurst=DMA_MBURST_SINGLE
+Dma.DCMI.0.MemDataAlignment=DMA_MDATAALIGN_WORD
+Dma.DCMI.0.MemInc=DMA_MINC_ENABLE
+Dma.DCMI.0.Mode=DMA_CIRCULAR
+Dma.DCMI.0.PeriphBurst=DMA_PBURST_SINGLE
+Dma.DCMI.0.PeriphDataAlignment=DMA_PDATAALIGN_WORD
+Dma.DCMI.0.PeriphInc=DMA_PINC_DISABLE
+Dma.DCMI.0.Polarity=HAL_DMAMUX_REQ_GEN_RISING
+Dma.DCMI.0.Priority=DMA_PRIORITY_HIGH
+Dma.DCMI.0.RequestNumber=1
+Dma.DCMI.0.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,FIFOMode,FIFOThreshold,MemBurst,PeriphBurst,SignalID,Polarity,RequestNumber,SyncSignalID,SyncPolarity,SyncEnable,EventEnable,SyncRequestNumber
+Dma.DCMI.0.SignalID=NONE
+Dma.DCMI.0.SyncEnable=DISABLE
+Dma.DCMI.0.SyncPolarity=HAL_DMAMUX_SYNC_NO_EVENT
+Dma.DCMI.0.SyncRequestNumber=1
+Dma.DCMI.0.SyncSignalID=NONE
+Dma.Request0=DCMI
+Dma.RequestsNb=1
 FMC.BankMapConfig=FMC_SWAPBMAP_DISABLE
 FMC.CASLatency1=FMC_SDRAM_CAS_LATENCY_2
 FMC.ColumnBitsNumber1=FMC_SDRAM_COLUMN_BITS_NUM_9
@@ -21,100 +46,120 @@ KeepUserPlacement=false
 Mcu.CPN=STM32H743IIK6
 Mcu.Family=STM32H7
 Mcu.IP0=CORTEX_M7
-Mcu.IP1=FMC
-Mcu.IP2=NVIC
-Mcu.IP3=QUADSPI
-Mcu.IP4=RCC
-Mcu.IP5=SDMMC1
-Mcu.IP6=SYS
-Mcu.IP7=USART1
-Mcu.IP8=USB_OTG_FS
-Mcu.IPNb=9
+Mcu.IP1=DCMI
+Mcu.IP10=TIM1
+Mcu.IP11=USART1
+Mcu.IP12=USB_OTG_FS
+Mcu.IP2=DMA
+Mcu.IP3=FMC
+Mcu.IP4=NVIC
+Mcu.IP5=QUADSPI
+Mcu.IP6=RCC
+Mcu.IP7=RTC
+Mcu.IP8=SDMMC1
+Mcu.IP9=SYS
+Mcu.IPNb=13
 Mcu.Name=STM32H743IIKx
 Mcu.Package=UFBGA176
 Mcu.Pin0=PE1
 Mcu.Pin1=PE0
-Mcu.Pin10=PI5
-Mcu.Pin11=PD1
-Mcu.Pin12=PI3
-Mcu.Pin13=PI2
-Mcu.Pin14=PA11
-Mcu.Pin15=PI9
-Mcu.Pin16=PI4
-Mcu.Pin17=PD2
-Mcu.Pin18=PH15
-Mcu.Pin19=PI1
+Mcu.Pin10=PG10
+Mcu.Pin11=PD0
+Mcu.Pin12=PC11
+Mcu.Pin13=PC10
+Mcu.Pin14=PA12
+Mcu.Pin15=PI7
+Mcu.Pin16=PI6
+Mcu.Pin17=PI5
+Mcu.Pin18=PD1
+Mcu.Pin19=PI3
 Mcu.Pin2=PC12
-Mcu.Pin20=PF0
-Mcu.Pin21=PI10
-Mcu.Pin22=PH13
-Mcu.Pin23=PH14
-Mcu.Pin24=PI0
-Mcu.Pin25=PC9
-Mcu.Pin26=PH0-OSC_IN (PH0)
-Mcu.Pin27=PC8
-Mcu.Pin28=PH1-OSC_OUT (PH1)
-Mcu.Pin29=PF2
-Mcu.Pin3=PG15
-Mcu.Pin30=PF1
-Mcu.Pin31=PG8
-Mcu.Pin32=PF3
-Mcu.Pin33=PF4
-Mcu.Pin34=PG6
-Mcu.Pin35=PF7
-Mcu.Pin36=PF6
-Mcu.Pin37=PF5
-Mcu.Pin38=PH12
-Mcu.Pin39=PG5
-Mcu.Pin4=PD0
-Mcu.Pin40=PG4
-Mcu.Pin41=PF10
-Mcu.Pin42=PF9
-Mcu.Pin43=PF8
-Mcu.Pin44=PH11
-Mcu.Pin45=PH10
-Mcu.Pin46=PD15
-Mcu.Pin47=PC0
-Mcu.Pin48=PG1
-Mcu.Pin49=PH8
-Mcu.Pin5=PC11
-Mcu.Pin50=PH9
-Mcu.Pin51=PD14
-Mcu.Pin52=PC4
-Mcu.Pin53=PF13
-Mcu.Pin54=PG0
-Mcu.Pin55=PE13
-Mcu.Pin56=PD10
-Mcu.Pin57=PC5
-Mcu.Pin58=PF12
-Mcu.Pin59=PF15
-Mcu.Pin6=PC10
-Mcu.Pin60=PE8
-Mcu.Pin61=PE9
-Mcu.Pin62=PE11
-Mcu.Pin63=PE14
-Mcu.Pin64=PD9
-Mcu.Pin65=PD8
-Mcu.Pin66=PA7
-Mcu.Pin67=PF11
-Mcu.Pin68=PF14
-Mcu.Pin69=PE7
-Mcu.Pin7=PA12
-Mcu.Pin70=PE10
-Mcu.Pin71=PE12
-Mcu.Pin72=PE15
-Mcu.Pin73=PB14
-Mcu.Pin74=PB15
-Mcu.Pin75=VP_SYS_VS_Systick
-Mcu.Pin8=PI7
-Mcu.Pin9=PI6
-Mcu.PinsNb=76
+Mcu.Pin20=PI2
+Mcu.Pin21=PA11
+Mcu.Pin22=PI9
+Mcu.Pin23=PI4
+Mcu.Pin24=PD2
+Mcu.Pin25=PH15
+Mcu.Pin26=PI1
+Mcu.Pin27=PF0
+Mcu.Pin28=PI10
+Mcu.Pin29=PH13
+Mcu.Pin3=PE4
+Mcu.Pin30=PH14
+Mcu.Pin31=PI0
+Mcu.Pin32=PC9
+Mcu.Pin33=PA8
+Mcu.Pin34=PH0-OSC_IN (PH0)
+Mcu.Pin35=PC8
+Mcu.Pin36=PC7
+Mcu.Pin37=PH1-OSC_OUT (PH1)
+Mcu.Pin38=PF2
+Mcu.Pin39=PF1
+Mcu.Pin4=PE5
+Mcu.Pin40=PG8
+Mcu.Pin41=PC6
+Mcu.Pin42=PF3
+Mcu.Pin43=PF4
+Mcu.Pin44=PG6
+Mcu.Pin45=PF7
+Mcu.Pin46=PF6
+Mcu.Pin47=PF5
+Mcu.Pin48=PH12
+Mcu.Pin49=PG5
+Mcu.Pin5=PE6
+Mcu.Pin50=PG4
+Mcu.Pin51=PF10
+Mcu.Pin52=PF9
+Mcu.Pin53=PF8
+Mcu.Pin54=PH11
+Mcu.Pin55=PH10
+Mcu.Pin56=PD15
+Mcu.Pin57=PC0
+Mcu.Pin58=PG1
+Mcu.Pin59=PH8
+Mcu.Pin6=PB7
+Mcu.Pin60=PH9
+Mcu.Pin61=PD14
+Mcu.Pin62=PA4
+Mcu.Pin63=PC4
+Mcu.Pin64=PF13
+Mcu.Pin65=PG0
+Mcu.Pin66=PE13
+Mcu.Pin67=PD10
+Mcu.Pin68=PA6
+Mcu.Pin69=PC5
+Mcu.Pin7=PB6
+Mcu.Pin70=PF12
+Mcu.Pin71=PF15
+Mcu.Pin72=PE8
+Mcu.Pin73=PE9
+Mcu.Pin74=PE11
+Mcu.Pin75=PE14
+Mcu.Pin76=PD9
+Mcu.Pin77=PD8
+Mcu.Pin78=PA7
+Mcu.Pin79=PF11
+Mcu.Pin8=PG15
+Mcu.Pin80=PF14
+Mcu.Pin81=PE7
+Mcu.Pin82=PE10
+Mcu.Pin83=PE12
+Mcu.Pin84=PE15
+Mcu.Pin85=PB14
+Mcu.Pin86=PB15
+Mcu.Pin87=VP_RTC_VS_RTC_Activate
+Mcu.Pin88=VP_RTC_VS_RTC_Calendar
+Mcu.Pin89=VP_SYS_VS_Systick
+Mcu.Pin9=PG11
+Mcu.PinsNb=90
 Mcu.ThirdPartyNb=0
 Mcu.UserConstants=
 Mcu.UserName=STM32H743IIKx
 MxCube.Version=6.4.0
 MxDb.Version=DB.6.0.40
 NVIC.BusFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:true
+NVIC.DCMI_IRQn=true\:0\:0\:false\:false\:true\:true\:true\:true
+NVIC.DMA1_Stream3_IRQn=true\:0\:0\:false\:false\:true\:false\:true\:true
 NVIC.DebugMonitor_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:true
 NVIC.ForceEnableDMAVector=true
 NVIC.HardFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:true
@@ -136,16 +181,44 @@ PA12.GPIOParameters=GPIO_Speed
 PA12.GPIO_Speed=GPIO_SPEED_FREQ_HIGH
 PA12.Mode=Device_Only
 PA12.Signal=USB_OTG_FS_DP
+PA4.GPIOParameters=GPIO_Speed,GPIO_PuPd
+PA4.GPIO_PuPd=GPIO_PULLUP
+PA4.GPIO_Speed=GPIO_SPEED_FREQ_HIGH
+PA4.Locked=true
+PA4.Mode=Slave_8_bits_External_Synchro
+PA4.Signal=DCMI_HSYNC
+PA6.GPIOParameters=GPIO_Speed,GPIO_PuPd
+PA6.GPIO_PuPd=GPIO_PULLUP
+PA6.GPIO_Speed=GPIO_SPEED_FREQ_HIGH
+PA6.Locked=true
+PA6.Mode=Slave_8_bits_External_Synchro
+PA6.Signal=DCMI_PIXCLK
 PA7.GPIOParameters=GPIO_PuPd
 PA7.GPIO_PuPd=GPIO_PULLUP
 PA7.Locked=true
 PA7.Signal=FMC_SDNWE
+PA8.GPIOParameters=GPIO_Speed,GPIO_PuPd
+PA8.GPIO_PuPd=GPIO_PULLUP
+PA8.GPIO_Speed=GPIO_SPEED_FREQ_HIGH
+PA8.Signal=S_TIM1_CH1
 PB14.Locked=true
 PB14.Mode=Asynchronous
 PB14.Signal=USART1_TX
 PB15.Locked=true
 PB15.Mode=Asynchronous
 PB15.Signal=USART1_RX
+PB6.GPIOParameters=GPIO_Speed,GPIO_PuPd
+PB6.GPIO_PuPd=GPIO_PULLUP
+PB6.GPIO_Speed=GPIO_SPEED_FREQ_HIGH
+PB6.Locked=true
+PB6.Mode=Slave_8_bits_External_Synchro
+PB6.Signal=DCMI_D5
+PB7.GPIOParameters=GPIO_Speed,GPIO_PuPd
+PB7.GPIO_PuPd=GPIO_PULLUP
+PB7.GPIO_Speed=GPIO_SPEED_FREQ_HIGH
+PB7.Locked=true
+PB7.Mode=Slave_8_bits_External_Synchro
+PB7.Signal=DCMI_VSYNC
 PC0.GPIOParameters=GPIO_Label
 PC0.GPIO_Label=LED_RED
 PC0.Locked=true
@@ -166,6 +239,18 @@ PC5.GPIO_PuPd=GPIO_PULLUP
 PC5.Locked=true
 PC5.Mode=SdramChipSelect1_1
 PC5.Signal=FMC_SDCKE0
+PC6.GPIOParameters=GPIO_Speed,GPIO_PuPd
+PC6.GPIO_PuPd=GPIO_PULLUP
+PC6.GPIO_Speed=GPIO_SPEED_FREQ_HIGH
+PC6.Locked=true
+PC6.Mode=Slave_8_bits_External_Synchro
+PC6.Signal=DCMI_D0
+PC7.GPIOParameters=GPIO_Speed,GPIO_PuPd
+PC7.GPIO_PuPd=GPIO_PULLUP
+PC7.GPIO_Speed=GPIO_SPEED_FREQ_HIGH
+PC7.Locked=true
+PC7.Mode=Slave_8_bits_External_Synchro
+PC7.Signal=DCMI_D1
 PC8.Mode=SD_4_bits_Wide_bus
 PC8.Signal=SDMMC1_D0
 PC9.Mode=SD_4_bits_Wide_bus
@@ -217,6 +302,24 @@ PE14.Signal=FMC_D11_DA11
 PE15.GPIOParameters=GPIO_PuPd
 PE15.GPIO_PuPd=GPIO_PULLUP
 PE15.Signal=FMC_D12_DA12
+PE4.GPIOParameters=GPIO_Speed,GPIO_PuPd
+PE4.GPIO_PuPd=GPIO_PULLUP
+PE4.GPIO_Speed=GPIO_SPEED_FREQ_HIGH
+PE4.Locked=true
+PE4.Mode=Slave_8_bits_External_Synchro
+PE4.Signal=DCMI_D4
+PE5.GPIOParameters=GPIO_Speed,GPIO_PuPd
+PE5.GPIO_PuPd=GPIO_PULLUP
+PE5.GPIO_Speed=GPIO_SPEED_FREQ_HIGH
+PE5.Locked=true
+PE5.Mode=Slave_8_bits_External_Synchro
+PE5.Signal=DCMI_D6
+PE6.GPIOParameters=GPIO_Speed,GPIO_PuPd
+PE6.GPIO_PuPd=GPIO_PULLUP
+PE6.GPIO_Speed=GPIO_SPEED_FREQ_HIGH
+PE6.Locked=true
+PE6.Mode=Slave_8_bits_External_Synchro
+PE6.Signal=DCMI_D7
 PE7.GPIOParameters=GPIO_PuPd
 PE7.GPIO_PuPd=GPIO_PULLUP
 PE7.Signal=FMC_D4_DA4
@@ -290,6 +393,18 @@ PG0.Signal=FMC_A10
 PG1.GPIOParameters=GPIO_PuPd
 PG1.GPIO_PuPd=GPIO_PULLUP
 PG1.Signal=FMC_A11
+PG10.GPIOParameters=GPIO_Speed,GPIO_PuPd
+PG10.GPIO_PuPd=GPIO_PULLUP
+PG10.GPIO_Speed=GPIO_SPEED_FREQ_HIGH
+PG10.Locked=true
+PG10.Mode=Slave_8_bits_External_Synchro
+PG10.Signal=DCMI_D2
+PG11.GPIOParameters=GPIO_Speed,GPIO_PuPd
+PG11.GPIO_PuPd=GPIO_PULLUP
+PG11.GPIO_Speed=GPIO_SPEED_FREQ_HIGH
+PG11.Locked=true
+PG11.Mode=Slave_8_bits_External_Synchro
+PG11.Signal=DCMI_D3
 PG15.GPIOParameters=GPIO_PuPd
 PG15.GPIO_PuPd=GPIO_PULLUP
 PG15.Signal=FMC_SDNCAS
@@ -394,7 +509,7 @@ ProjectManager.StackSize=0x400
 ProjectManager.TargetToolchain=MDK-ARM V5.32
 ProjectManager.ToolChainLocation=
 ProjectManager.UnderRoot=false
-ProjectManager.functionlistsort=1-MX_GPIO_Init-GPIO-false-HAL-true,2-SystemClock_Config-RCC-false-HAL-false,3-MX_USART1_UART_Init-USART1-false-HAL-true,4-MX_FMC_Init-FMC-false-HAL-true,5-MX_QUADSPI_Init-QUADSPI-false-HAL-true,6-MX_SDMMC1_SD_Init-SDMMC1-false-HAL-true,0-MX_CORTEX_M7_Init-CORTEX_M7-false-HAL-true
+ProjectManager.functionlistsort=1-MX_GPIO_Init-GPIO-false-HAL-true,2-SystemClock_Config-RCC-false-HAL-false,3-MX_USART1_UART_Init-USART1-false-HAL-true,4-MX_FMC_Init-FMC-false-HAL-true,5-MX_QUADSPI_Init-QUADSPI-false-HAL-true,6-MX_SDMMC1_SD_Init-SDMMC1-false-HAL-true,7-MX_DMA_Init-DMA-false-HAL-true,8-MX_RTC_Init-RTC-false-HAL-true,9-MX_DCMI_Init-DCMI-false-HAL-true,10-MX_USB_OTG_FS_PCD_Init-USB_OTG_FS-false-HAL-true,0-MX_CORTEX_M7_Init-CORTEX_M7-false-HAL-true
 QUADSPI.ChipSelectHighTime=QSPI_CS_HIGH_TIME_2_CYCLE
 QUADSPI.ClockPrescaler=1
 QUADSPI.FifoThreshold=3
@@ -592,10 +707,21 @@ SH.FMC_SDNRAS.0=FMC_SDNRAS,12b-sda1
 SH.FMC_SDNRAS.ConfNb=1
 SH.FMC_SDNWE.0=FMC_SDNWE,12b-sda1
 SH.FMC_SDNWE.ConfNb=1
+SH.S_TIM1_CH1.0=TIM1_CH1,PWM Generation1 CH1
+SH.S_TIM1_CH1.ConfNb=1
+TIM1.AutoReloadPreload=TIM_AUTORELOAD_PRELOAD_ENABLE
+TIM1.Channel-PWM\ Generation1\ CH1=TIM_CHANNEL_1
+TIM1.IPParameters=Channel-PWM Generation1 CH1,Period,AutoReloadPreload,Pulse-PWM Generation1 CH1
+TIM1.Period=7
+TIM1.Pulse-PWM\ Generation1\ CH1=3
 USART1.IPParameters=VirtualMode-Asynchronous
 USART1.VirtualMode-Asynchronous=VM_ASYNC
 USB_OTG_FS.IPParameters=VirtualMode
 USB_OTG_FS.VirtualMode=Device_Only
+VP_RTC_VS_RTC_Activate.Mode=RTC_Enabled
+VP_RTC_VS_RTC_Activate.Signal=RTC_VS_RTC_Activate
+VP_RTC_VS_RTC_Calendar.Mode=RTC_Calendar
+VP_RTC_VS_RTC_Calendar.Signal=RTC_VS_RTC_Calendar
 VP_SYS_VS_Systick.Mode=SysTick
 VP_SYS_VS_Systick.Signal=SYS_VS_Systick
 board=custom

+ 50 - 1
bsp/stm32/stm32h743-openmv-h7plus/board/Kconfig

@@ -53,7 +53,7 @@ menu "Hardware Drivers Config"
                 select RT_USING_QSPI
                 select RT_USING_SPI
                 default n
-                
+
             config BSP_USING_ONCHIP_RTC
                 bool "Enable RTC"
                 select RT_USING_RTC
@@ -88,6 +88,55 @@ menu "Hardware Drivers Config"
             select RT_USING_USB_DEVICE
             default n 
 
+        config BSP_USING_OV5640
+            bool "Enable camera (ov5640)"
+            select BSP_USING_DCMI
+            select BSP_USING_I2C
+            select BSP_USING_I2C1
+            default n
+
+        config BSP_USING_DCMI
+            bool "Enable DCMI"
+            default n
+        
+        menuconfig BSP_USING_I2C
+            bool "Enable I2C BUS (software simulation)"
+            select RT_USING_I2C
+            select RT_USING_I2C_BITOPS
+            select RT_USING_PIN
+            default n
+            if BSP_USING_I2C
+                menuconfig BSP_USING_I2C1
+                    bool "Enable I2C1 BUS (software simulation)"
+                    default n
+                    if BSP_USING_I2C1
+                        comment "Notice: PB8 --> 24; PB9 --> 25"
+                        config BSP_I2C1_SCL_PIN
+                            int "i2c1 scl pin number"
+                            range 1 176
+                            default 24
+                        config BSP_I2C1_SDA_PIN
+                            int "I2C1 sda pin number"
+                            range 1 176
+                            default 25
+                    endif
+
+                menuconfig BSP_USING_I2C2
+                    bool "Enable I2C2 BUS (software simulation)"
+                    default n
+                    if BSP_USING_I2C2
+                        comment "Notice: PB10 --> 26; PB11 --> 27"
+                        config BSP_I2C2_SCL_PIN
+                            int "i2c2 scl pin number"
+                            range 1 176
+                            default 26
+                        config BSP_I2C2_SDA_PIN
+                            int "I2C2 sda pin number"
+                            range 1 176
+                            default 27
+                    endif
+            endif
+
     endmenu
 
 endmenu

+ 7 - 2
bsp/stm32/stm32h743-openmv-h7plus/board/SConscript

@@ -4,6 +4,7 @@ from building import *
 
 Import('SDK_LIB')
 
+startup_path_prefix = SDK_LIB
 cwd = GetCurrentDir()
 
 # add general drivers
@@ -20,8 +21,12 @@ if GetDepend(['BSP_USING_QSPI_FLASH']):
     src += Glob('ports/drv_qspi_flash.c')
 if GetDepend(['BSP_USING_SDMMC']):
     src += Glob('ports/drv_sdio.c')
-
-startup_path_prefix = SDK_LIB
+if GetDepend(['BSP_USING_OV5640']):
+    src += Glob('ports/drv_ov5640.c')
+    src += [startup_path_prefix + '/STM32H7xx_HAL/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_tim.c']
+if GetDepend(['BSP_USING_DCMI']):
+    src += Glob('ports/drv_dcmi.c')
+    src += [startup_path_prefix + '/STM32H7xx_HAL/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_dcmi.c']
 
 if rtconfig.CROSS_TOOL == 'gcc':
     src += [startup_path_prefix + '/STM32H7xx_HAL/CMSIS/Device/ST/STM32H7xx/Source/Templates/gcc/startup_stm32h743xx.s']

+ 210 - 0
bsp/stm32/stm32h743-openmv-h7plus/board/ports/drv_dcmi.c

@@ -0,0 +1,210 @@
+/*
+ * Copyright (c) 2006-2022, RT-Thread Development Team
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Change Logs:
+ * Date           Author            Notes
+ * 2020-07-27     thread-liu        the first version
+ * 2022-04-13     Miaowulue         fit openmv-h7plus
+ */
+#include "board.h"
+
+#ifdef BSP_USING_DCMI
+
+#define DRV_DEBUG
+#define LOG_TAG             "drv.dcmi"
+#include <drv_log.h>
+
+struct stm32_dcmi
+{
+    struct rt_device dev;
+};
+static struct stm32_dcmi rt_dcmi = {0};
+DCMI_HandleTypeDef dcmi    = {0};
+DMA_HandleTypeDef hdma_dcmi = {0};
+
+extern void jpeg_data_process(void);
+
+static void rt_hw_dmci_dma_init(void)
+{
+    __HAL_RCC_DMA1_CLK_ENABLE();
+
+    hdma_dcmi.Instance = DMA1_Stream3;
+    hdma_dcmi.Init.Request = DMA_REQUEST_DCMI;
+    hdma_dcmi.Init.Direction = DMA_PERIPH_TO_MEMORY;
+    hdma_dcmi.Init.PeriphInc = DMA_PINC_DISABLE;
+    hdma_dcmi.Init.MemInc = DMA_MINC_ENABLE;
+    hdma_dcmi.Init.PeriphDataAlignment = DMA_PDATAALIGN_WORD;
+    hdma_dcmi.Init.MemDataAlignment = DMA_MDATAALIGN_WORD;
+    hdma_dcmi.Init.Mode = DMA_CIRCULAR;
+    hdma_dcmi.Init.Priority = DMA_PRIORITY_HIGH;
+    hdma_dcmi.Init.FIFOMode = DMA_FIFOMODE_ENABLE;
+    hdma_dcmi.Init.FIFOThreshold = DMA_FIFO_THRESHOLD_FULL;
+    hdma_dcmi.Init.MemBurst = DMA_MBURST_SINGLE;
+    hdma_dcmi.Init.PeriphBurst = DMA_PBURST_SINGLE;
+    if (HAL_DMA_Init(&hdma_dcmi) != HAL_OK)
+    {
+      Error_Handler();
+    }
+
+    __HAL_LINKDMA(&dcmi, DMA_Handle, hdma_dcmi);
+
+    HAL_NVIC_SetPriority(DMA1_Stream3_IRQn, 0x00, 0);
+    HAL_NVIC_EnableIRQ(DMA1_Stream3_IRQn);
+}
+
+void rt_hw_dcmi_dma_config(rt_uint32_t dst_addr1, rt_uint32_t dst_addr2, rt_uint16_t len)
+{
+    HAL_DMAEx_MultiBufferStart(&hdma_dcmi, (rt_uint32_t)&DCMI->DR, dst_addr1, dst_addr2, len);
+    __HAL_DMA_ENABLE_IT(&hdma_dcmi, DMA_IT_TC);
+}
+
+static rt_err_t rt_hw_dcmi_init(DCMI_HandleTypeDef *device)
+{
+    RT_ASSERT(device != RT_NULL);
+
+    dcmi.Instance = DCMI;
+    dcmi.Init.SynchroMode = DCMI_SYNCHRO_HARDWARE;
+    dcmi.Init.PCKPolarity = DCMI_PCKPOLARITY_RISING;
+    dcmi.Init.VSPolarity = DCMI_VSPOLARITY_LOW;
+    dcmi.Init.HSPolarity = DCMI_HSPOLARITY_LOW;
+    dcmi.Init.CaptureRate = DCMI_CR_ALL_FRAME;
+    dcmi.Init.ExtendedDataMode = DCMI_EXTEND_DATA_8B;
+    dcmi.Init.JPEGMode = DCMI_JPEG_ENABLE;
+    dcmi.Init.ByteSelectMode = DCMI_BSM_ALL;
+    dcmi.Init.ByteSelectStart = DCMI_OEBS_ODD;
+    dcmi.Init.LineSelectMode = DCMI_LSM_ALL;
+    dcmi.Init.LineSelectStart = DCMI_OELS_ODD;
+    if (HAL_DCMI_Init(device) != HAL_OK)
+    {
+        LOG_E("dcmi init error!");
+        return RT_ERROR;
+    }
+
+    DCMI->IER = 0x0;
+
+    __HAL_DCMI_ENABLE_IT(device, DCMI_IT_FRAME);
+    __HAL_DCMI_ENABLE(device);
+
+    rt_hw_dmci_dma_init();
+
+    return RT_EOK;
+}
+
+void DCMI_IRQHandler(void)
+{
+    /* enter interrupt */
+    rt_interrupt_enter();
+
+    HAL_DCMI_IRQHandler(&dcmi);
+
+    /* leave interrupt */
+    rt_interrupt_leave();
+}
+
+/* Capture a frame of the image */
+void HAL_DCMI_FrameEventCallback(DCMI_HandleTypeDef *hdcmi)
+{
+    /* enter interrupt */
+    rt_interrupt_enter();
+
+    jpeg_data_process();
+    __HAL_DCMI_ENABLE_IT(&dcmi,DCMI_IT_FRAME);
+    /* leave interrupt */
+    rt_interrupt_leave();
+}
+
+void DMA1_Stream3_IRQHandler(void)
+{
+    extern void rt_hw_camera_rx_callback(void);
+    /* enter interrupt */
+    rt_interrupt_enter();
+
+    if(__HAL_DMA_GET_FLAG(&hdma_dcmi, DMA_FLAG_TCIF3_7)!=RESET)
+    {
+        __HAL_DMA_CLEAR_FLAG(&hdma_dcmi, DMA_FLAG_TCIF3_7);
+        rt_hw_camera_rx_callback();
+    }
+
+    /* leave interrupt */
+    rt_interrupt_leave();
+}
+
+static rt_err_t rt_dcmi_init(rt_device_t dev)
+{
+    RT_ASSERT(dev != RT_NULL);
+    rt_err_t result = RT_EOK;
+
+    result = rt_hw_dcmi_init(&dcmi);
+    if (result != RT_EOK)
+    {
+        return result;
+    }
+
+    return result;
+}
+
+static rt_err_t rt_dcmi_open(rt_device_t dev, rt_uint16_t oflag)
+{
+    RT_ASSERT(dev != RT_NULL);
+
+    return RT_EOK;
+}
+
+static rt_err_t rt_dcmi_close(rt_device_t dev)
+{
+    RT_ASSERT(dev != RT_NULL);
+
+    return RT_EOK;
+}
+
+static rt_err_t rt_dcmi_control(rt_device_t dev, int cmd, void *args)
+{
+    RT_ASSERT(dev != RT_NULL);
+
+    return RT_EOK;
+}
+
+static rt_size_t rt_dcmi_read(rt_device_t dev, rt_off_t pos, void *buffer, rt_size_t size)
+{
+    RT_ASSERT(dev != RT_NULL);
+
+    return RT_EOK;
+}
+
+static rt_size_t rt_dcmi_write(rt_device_t dev, rt_off_t pos, const void *buffer, rt_size_t size)
+{
+    RT_ASSERT(dev != RT_NULL);
+
+    return RT_EOK;
+}
+
+int dcmi_init(void)
+{
+    int ret = 0;
+    rt_device_t dcmi_dev = RT_NULL;
+
+    rt_dcmi.dev.type      = RT_Device_Class_Miscellaneous;
+    rt_dcmi.dev.init      = rt_dcmi_init;
+    rt_dcmi.dev.open      = rt_dcmi_open;
+    rt_dcmi.dev.close     = rt_dcmi_close;
+    rt_dcmi.dev.read      = rt_dcmi_read;
+    rt_dcmi.dev.write     = rt_dcmi_write;
+    rt_dcmi.dev.control   = rt_dcmi_control;
+    rt_dcmi.dev.user_data = RT_NULL;
+
+    ret = rt_device_register(&rt_dcmi.dev, "dcmi", RT_DEVICE_FLAG_RDWR | RT_DEVICE_FLAG_REMOVABLE | RT_DEVICE_FLAG_STANDALONE);
+    if(ret != RT_EOK)
+    {
+        LOG_E("dcmi registered fail!\n\r");
+        return -RT_ERROR;
+    }
+
+    LOG_I("dcmi init success!");
+
+    return RT_EOK;
+}
+INIT_BOARD_EXPORT(dcmi_init);
+
+#endif

+ 694 - 0
bsp/stm32/stm32h743-openmv-h7plus/board/ports/drv_ov5640.c

@@ -0,0 +1,694 @@
+/*
+ * Copyright (c) 2006-2022, RT-Thread Development Team
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Change Logs:
+ * Date           Author            Notes
+ * 2020-08-03     thread-liu        the first version
+ * 2022-04-13     Miaowulue         fit openmv-h7plus
+ */
+
+#include "board.h"
+
+#ifdef BSP_USING_OV5640
+
+#include <dfs_file.h>
+#include <unistd.h>
+#include <stdio.h>
+#include <sys/stat.h>
+#include <sys/statfs.h>
+#include "drv_ov5640.h"
+
+//#define DRV_DEBUG
+//#define CAMERA_DUMP
+#define LOG_TAG     "drv.ov5640"
+#include <drv_log.h>
+
+#define CHIP_ADDRESS    0x3C /* OV5640 address */
+#define I2C_NAME        "i2c1"
+#define RST_PIN    GET_PIN(A, 10)
+#define PWDN_PIN    GET_PIN(D, 7)
+
+#define JPEG_BUF_SIZE   8 * 1024
+#define JPEG_LINE_SIZE  1 * 1024
+
+static rt_int32_t JPEG_DATA_BUF[JPEG_BUF_SIZE];
+static rt_int32_t JPEG_LINE_BUF[2][JPEG_LINE_SIZE];
+
+volatile rt_uint32_t jpeg_data_len = 0;
+volatile rt_uint8_t  jpeg_data_ok  = 0;
+struct rt_i2c_bus_device *i2c_bus  = RT_NULL;
+extern DCMI_HandleTypeDef dcmi;
+extern DMA_HandleTypeDef hdma_dcmi;
+
+#if defined(CAMERA_DUMP)
+#define __is_print(ch) ((unsigned int)((ch) - ' ') < 127u - ' ')
+static void dump_hex(const rt_uint8_t *ptr, rt_size_t buflen)
+{
+    unsigned char *buf = (unsigned char *)ptr;
+    int i, j;
+
+    for (i = 0; i < buflen; i += 16)
+    {
+        rt_kprintf("%08x:", i);
+
+        for (j = 0; j < 16; j++)
+        {
+            if (i + j < buflen)
+            {
+                rt_kprintf("%02x", buf[i + j]);
+            }
+            else
+            {
+                rt_kprintf(" ");
+            }
+        }
+        rt_kprintf(" ");
+
+        for (j = 0; j < 16; j++)
+        {
+            if (i + j < buflen)
+            {
+                rt_kprintf("%c", __is_print(buf[i + j]) ? buf[i + j] : '.');
+            }
+        }
+        rt_kprintf("\n");
+    }
+}
+#endif
+
+/* i2c read reg */
+static rt_err_t read_reg(struct rt_i2c_bus_device *bus, rt_uint16_t reg, rt_uint8_t len, rt_uint8_t *buf)
+{
+    struct rt_i2c_msg msg[2] = {0, 0};
+    static rt_uint8_t i2c_reg[2] = {0, 0};
+
+    RT_ASSERT(bus != RT_NULL);
+
+    i2c_reg[0] = ((uint16_t)(reg >> 8) & 0xFF);
+    i2c_reg[1] = ((uint16_t)(reg & 0xFF));
+
+    msg[0].addr  = CHIP_ADDRESS;
+    msg[0].flags = RT_I2C_WR;
+    msg[0].buf   = i2c_reg;
+    msg[0].len   = 2;
+
+    msg[1].addr  = CHIP_ADDRESS;
+    msg[1].flags = RT_I2C_RD;
+    msg[1].len   = len;
+    msg[1].buf   = buf;
+
+    if (rt_i2c_transfer(bus, msg, 2) == 2)
+    {
+        return RT_EOK;
+    }
+
+    return RT_ERROR;
+}
+
+/* i2c write reg */
+static rt_err_t write_reg(struct rt_i2c_bus_device *bus, rt_uint16_t reg, rt_uint8_t data)
+{
+    rt_uint8_t buf[3];
+    struct rt_i2c_msg msgs;
+
+    RT_ASSERT(bus != RT_NULL);
+
+    buf[0] = ((uint16_t)(reg >> 8) & 0xFF);
+    buf[1] = ((uint16_t)(reg)&0xFF);
+
+    buf[2] = data;
+
+    msgs.addr = CHIP_ADDRESS;
+    msgs.flags = RT_I2C_WR;
+    msgs.buf = buf;
+    msgs.len = 3;
+
+    if (rt_i2c_transfer(bus, &msgs, 1) == 1)
+    {
+        return RT_EOK;
+    }
+
+    return RT_ERROR;
+}
+
+static rt_err_t ov5640_read_id(struct rt_i2c_bus_device *bus, rt_uint16_t *id)
+{
+    rt_uint8_t read_value[2];
+
+    read_reg(bus, 0x300A, 1, &read_value[0]);
+    read_reg(bus, 0x300B, 1, &read_value[1]);
+    *id = ((uint16_t)(read_value[0] << 8) & 0xFF00);
+    *id |= ((uint16_t)(read_value[1]) & 0x00FF);
+
+    if (*id != OV5640_ID)
+    {
+        LOG_E("ov5640 init error, id: 0x%04x", *id);
+        return RT_ERROR;
+    }
+
+    LOG_I("ov5640 init success, id: 0x%04x", *id);
+
+    return RT_EOK;
+}
+
+static rt_err_t ov5640_hard_reset(void)
+{
+    rt_pin_mode(RST_PIN, PIN_MODE_OUTPUT);
+    rt_pin_mode(PWDN_PIN, PIN_MODE_OUTPUT);
+
+    rt_pin_write(RST_PIN, PIN_LOW);
+    rt_thread_mdelay(20);
+    rt_pin_write(PWDN_PIN, PIN_LOW);
+    rt_thread_mdelay(5);
+    rt_pin_write(RST_PIN, PIN_HIGH);
+    rt_thread_mdelay(20);
+
+    return RT_EOK;
+}
+
+void OV5640_Flash_Ctrl(struct rt_i2c_bus_device *bus, rt_uint8_t sw)
+{
+    write_reg(bus, 0x3016, 0X02);
+    write_reg(bus, 0x301C, 0X02);
+    if (sw)
+    {
+        write_reg(bus, 0X3019, 0X02);
+    }
+    else
+    {
+        write_reg(bus, 0X3019, 0X00);
+    }
+}
+
+static rt_err_t ov5640_config(struct rt_i2c_bus_device *bus)
+{
+    rt_uint32_t i = 0;
+    rt_uint8_t value = 0;
+
+    write_reg(bus, 0x3103, 0X11); /* system clock from pad, bit[1] */
+    write_reg(bus, 0X3008, 0X82); /* soft reset */
+
+    rt_thread_delay(10);
+
+    for (i = 0; i < (sizeof(RGB565_Init) / 4); i++)
+    {
+        write_reg(bus, RGB565_Init[i][0], RGB565_Init[i][1]);
+        rt_thread_delay(10);
+        read_reg(bus, RGB565_Init[i][0], 1, &value);
+
+        if (RGB565_Init[i][1] != value)
+        {
+            LOG_D("error reg value[0x%x]:0x%02x - 0x%02x", RGB565_Init[i][0], RGB565_Init[i][1], value);
+        }
+    }
+
+    OV5640_Flash_Ctrl(bus, 1); /* open camera flash*/
+    rt_thread_delay(3);
+    OV5640_Flash_Ctrl(bus, 0); /* close camera flash*/
+
+    return RT_EOK;
+}
+
+/* JPEG */
+void ov5640_jpeg_mode(struct rt_i2c_bus_device *bus)
+{
+    rt_uint16_t i = 0;
+    for (i = 0; i < (sizeof(OV5640_jpeg_reg_tbl) / 4); i++)
+    {
+        write_reg(bus, OV5640_jpeg_reg_tbl[i][0], OV5640_jpeg_reg_tbl[i][1]);
+    }
+}
+
+/* RGB565 */
+void ov5640_rgb565_mode(struct rt_i2c_bus_device *bus)
+{
+    rt_uint16_t i = 0;
+    for (i = 0; i < (sizeof(ov5640_rgb565_reg_tbl) / 4); i++)
+    {
+        write_reg(bus, ov5640_rgb565_reg_tbl[i][0], ov5640_rgb565_reg_tbl[i][1]);
+    }
+
+    write_reg(bus, 0x3821, 0x06);
+}
+
+rt_uint8_t ov5640_focus_init(struct rt_i2c_bus_device *bus)
+{
+    rt_uint16_t tickstart = 0 ,i = 0;
+    rt_uint16_t addr = 0x8000;
+    rt_uint8_t state = 0x8F;
+
+    write_reg(bus, 0x3000, 0x20); //reset MCU
+    for (i = 0; i < sizeof(OV5640_AF_Config); i++)
+    {
+        write_reg(bus, addr, OV5640_AF_Config[i]);
+        addr++;
+    }
+    write_reg(bus, 0x3022, 0x00);
+    write_reg(bus, 0x3023, 0x00);
+    write_reg(bus, 0x3024, 0x00);
+    write_reg(bus, 0x3025, 0x00);
+    write_reg(bus, 0x3026, 0x00);
+    write_reg(bus, 0x3027, 0x00);
+    write_reg(bus, 0x3028, 0x00);
+    write_reg(bus, 0x3029, 0x7f);
+    write_reg(bus, 0x3000, 0x00);
+    i = 0;
+
+    tickstart = rt_tick_get();
+    do
+    {
+        read_reg(bus, 0x3029, 1, &state);
+        if (rt_tick_get() - tickstart > 1000)
+        {
+            return RT_ERROR;
+        }
+    } while (state != 0x70);
+
+    return RT_EOK;
+}
+
+void ov5640_set_light(struct rt_i2c_bus_device *bus, rt_uint8_t mode)
+{
+    rt_uint8_t i = 0;
+    write_reg(bus, 0x3212, 0x03); //start group 3
+
+    for (i = 0; i < 7; i++)
+    {
+        write_reg(bus, 0x3400 + i, OV5640_LIGHTMODE_TBL[mode][i]);
+    }
+
+    write_reg(bus, 0x3212, 0x13); //end group 3
+    write_reg(bus, 0x3212, 0xa3); //launch group 3
+}
+
+/* sat:0~6 */
+void ov5640_color_saturation(struct rt_i2c_bus_device *bus, rt_uint8_t sat)
+{
+    rt_uint8_t i = 0;
+    write_reg(bus, 0x3212, 0x03); //start group 3
+    write_reg(bus, 0x5381, 0x1c);
+    write_reg(bus, 0x5382, 0x5a);
+    write_reg(bus, 0x5383, 0x06);
+    for (i = 0; i < 6; i++)
+    {
+        write_reg(bus, 0x5384 + i, OV5640_SATURATION_TBL[sat][i]);
+    }
+    write_reg(bus, 0x538b, 0x98);
+    write_reg(bus, 0x538a, 0x01);
+    write_reg(bus, 0x3212, 0x13); //end group 3
+    write_reg(bus, 0x3212, 0xa3); //launch group 3
+}
+
+/* bright:0~8 */
+void ov5640_set_brightness(struct rt_i2c_bus_device *bus, rt_uint8_t bright)
+{
+    rt_uint8_t brtval;
+    if (bright < 4)
+    {
+        brtval = 4 - bright;
+    }
+    else
+    {
+        brtval = bright - 4;
+    }
+    write_reg(bus, 0x3212, 0x03); //start group 3
+    write_reg(bus, 0x5587, brtval << 4);
+    if (bright < 4)
+    {
+        write_reg(bus, 0x5588, 0x09);
+    }
+    else
+    {
+        write_reg(bus, 0x5588, 0x01);
+    }
+    write_reg(bus, 0x3212, 0x13); //end group 3
+    write_reg(bus, 0x3212, 0xa3); //launch group 3
+}
+
+/* contrast:0~6 */
+void ov5640_contrast(struct rt_i2c_bus_device *bus, rt_uint8_t contrast)
+{
+    rt_uint8_t reg0val = 0x00;
+    rt_uint8_t reg1val = 0x20;
+    switch (contrast)
+    {
+    case 0:
+        reg1val = reg0val = 0X14;
+        break;
+
+    case 1:
+        reg1val = reg0val = 0X18;
+        break;
+
+    case 2:
+        reg1val = reg0val = 0X1C;
+        break;
+
+    case 4:
+        reg0val = 0X10;
+        reg1val = 0X24;
+        break;
+
+    case 5:
+        reg0val = 0X18;
+        reg1val = 0X28;
+        break;
+
+    case 6:
+        reg0val = 0X1C;
+        reg1val = 0X2C;
+
+        break;
+    }
+    write_reg(bus, 0x3212, 0x03); //start group 3
+    write_reg(bus, 0x5585, reg0val);
+    write_reg(bus, 0x5586, reg1val);
+    write_reg(bus, 0x3212, 0x13); //end group 3
+    write_reg(bus, 0x3212, 0xa3); //launch group 3
+}
+
+/* sharp:0~33 */
+void ov5640_set_sharpness(struct rt_i2c_bus_device *bus, rt_uint8_t sharp)
+{
+    if (sharp < 33)
+    {
+        write_reg(bus, 0x5308, 0x65);
+        write_reg(bus, 0x5302, sharp);
+    }
+    else
+    {
+        write_reg(bus, 0x5308, 0x25);
+        write_reg(bus, 0x5300, 0x08);
+        write_reg(bus, 0x5301, 0x30);
+        write_reg(bus, 0x5302, 0x10);
+        write_reg(bus, 0x5303, 0x00);
+        write_reg(bus, 0x5309, 0x08);
+        write_reg(bus, 0x530a, 0x30);
+        write_reg(bus, 0x530b, 0x04);
+        write_reg(bus, 0x530c, 0x06);
+    }
+}
+
+rt_uint8_t ov5640_focus_constant(struct rt_i2c_bus_device *bus)
+{
+    rt_uint8_t temp = 0;
+    rt_uint16_t tickstrat = 0;
+
+    write_reg(bus, 0x3023, 0x01);
+    write_reg(bus, 0x3022, 0x08);
+    do
+    {
+        tickstrat = rt_tick_get();
+        read_reg(bus, 0x3023, 1, &temp);
+        if (rt_tick_get() - tickstrat > 1000)
+        {
+            return RT_ERROR;
+        }
+    } while (temp != 0x00);
+
+    write_reg(bus, 0x3023, 0x01);
+    write_reg(bus, 0x3022, 0x04);
+
+    do
+    {
+        tickstrat = rt_tick_get();
+        read_reg(bus, 0x3023, 1, &temp);
+        if (rt_tick_get() - tickstrat > 1000)
+        {
+            return RT_ERROR;
+        }
+    } while (temp != 0x00);
+
+    return 0;
+}
+
+rt_uint8_t ov5640_set_outsize(struct rt_i2c_bus_device *bus, rt_uint16_t offx, rt_uint16_t offy, rt_uint16_t width, rt_uint16_t height)
+{
+    write_reg(bus, 0X3212, 0X03);
+
+    write_reg(bus, 0x3808, width >> 8);
+    write_reg(bus, 0x3809, width & 0xff);
+    write_reg(bus, 0x380a, height >> 8);
+    write_reg(bus, 0x380b, height & 0xff);
+
+    write_reg(bus, 0x3810, offx >> 8);
+    write_reg(bus, 0x3811, offx & 0xff);
+
+    write_reg(bus, 0x3812, offy >> 8);
+    write_reg(bus, 0x3813, offy & 0xff);
+
+    write_reg(bus, 0X3212, 0X13);
+    write_reg(bus, 0X3212, 0Xa3);
+
+    return RT_EOK;
+}
+
+void rt_hw_camera_rx_callback(void)
+{
+    rt_uint16_t i;
+    rt_int32_t *pbuf = RT_NULL;
+    pbuf = JPEG_DATA_BUF + jpeg_data_len;
+
+    if (((DMA_Stream_TypeDef *)hdma_dcmi.Instance)->CR & (1 << 19))
+    {
+        for (i = 0; i < JPEG_LINE_SIZE; i++)
+        {
+            pbuf[i] = JPEG_LINE_BUF[0][i];
+        }
+        jpeg_data_len += JPEG_LINE_SIZE;
+
+    }
+    else
+    {
+        for (i = 0; i < JPEG_LINE_SIZE; i++)
+        {
+            pbuf[i] = JPEG_LINE_BUF[1][i];
+        }
+        jpeg_data_len += JPEG_LINE_SIZE;
+    }
+}
+
+/* After a frame of JPEG data has been collected. */
+void jpeg_data_process(void)
+{
+    rt_uint16_t i, rlen;
+    int *pbuf = RT_NULL;
+
+    if (!jpeg_data_ok)
+    {
+        __HAL_DMA_DISABLE(&hdma_dcmi);
+        rlen = JPEG_LINE_SIZE - __HAL_DMA_GET_COUNTER(&hdma_dcmi);
+        pbuf = JPEG_DATA_BUF + jpeg_data_len;
+
+        if (((DMA_Stream_TypeDef *)hdma_dcmi.Instance)->CR & (1 << 19))
+        {
+            for (i = 0; i < rlen; i++)
+            {
+                pbuf[i] = JPEG_LINE_BUF[1][i];
+            }
+        }
+        else
+        {
+            for (i = 0; i < rlen; i++)
+            {
+                pbuf[i] = JPEG_LINE_BUF[0][i];
+            }
+        }
+        jpeg_data_len += rlen;
+        jpeg_data_ok   = 1;
+    }
+
+    if (jpeg_data_ok == 2)
+    {
+        __HAL_DMA_SET_COUNTER(&hdma_dcmi, JPEG_LINE_SIZE);
+        __HAL_DMA_ENABLE(&hdma_dcmi);
+
+        jpeg_data_ok  = 0;
+        jpeg_data_len = 0;
+    }
+}
+
+int ov5640_set_xclk_frequency(uint32_t frequency)
+{
+    extern void HAL_TIM_MspPostInit(TIM_HandleTypeDef *htim);
+    int tclk = HAL_RCC_GetPCLK2Freq() * 2;
+    int period = (tclk / frequency) - 1;
+    int pulse = period / 2;
+
+    TIM_HandleTypeDef  TIMHandle  = {.Instance = TIM1};
+
+    if (TIMHandle.Init.Period && (TIMHandle.Init.Period != period)) {
+        __HAL_TIM_SET_AUTORELOAD(&TIMHandle, period);
+        __HAL_TIM_SET_COMPARE(&TIMHandle, TIM_CHANNEL_1, pulse);
+        return 0;
+    }
+
+    TIMHandle.Init.Period            = period;
+    TIMHandle.Init.Prescaler         = 0;
+    TIMHandle.Init.CounterMode       = TIM_COUNTERMODE_UP;
+    TIMHandle.Init.ClockDivision     = TIM_CLOCKDIVISION_DIV1;
+    TIMHandle.Init.RepetitionCounter = 0;
+    TIMHandle.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_ENABLE;
+
+    TIM_OC_InitTypeDef TIMOCHandle;
+    TIMOCHandle.Pulse           = pulse;
+    TIMOCHandle.OCMode          = TIM_OCMODE_PWM1;
+    TIMOCHandle.OCPolarity      = TIM_OCPOLARITY_HIGH;
+    TIMOCHandle.OCNPolarity     = TIM_OCNPOLARITY_HIGH;
+    TIMOCHandle.OCFastMode      = TIM_OCFAST_DISABLE;
+    TIMOCHandle.OCIdleState     = TIM_OCIDLESTATE_RESET;
+    TIMOCHandle.OCNIdleState    = TIM_OCNIDLESTATE_RESET;
+
+    HAL_TIM_MspPostInit(&TIMHandle);
+
+    if ((HAL_TIM_PWM_Init(&TIMHandle) != HAL_OK)
+    || (HAL_TIM_PWM_ConfigChannel(&TIMHandle, &TIMOCHandle, TIM_CHANNEL_1) != HAL_OK)
+    || (HAL_TIM_PWM_Start(&TIMHandle, TIM_CHANNEL_1) != HAL_OK))
+    {
+        rt_kprintf("config fail!\n");
+        return -1;
+    }
+
+    return 0;
+}
+
+int rt_hw_ov5640_init(void)
+{
+    ov5640_set_xclk_frequency(24000000);
+    extern void rt_hw_dcmi_dma_config(rt_uint32_t dst_addr1, rt_uint32_t dst_addr2, rt_uint16_t len);
+
+    static rt_uint16_t id = 0;
+    rt_device_t dcmi_dev = RT_NULL;
+
+    i2c_bus = rt_i2c_bus_device_find(I2C_NAME);
+    if (i2c_bus == RT_NULL)
+    {
+        LOG_E("can't find %c deivce", I2C_NAME);
+        return RT_ERROR;
+    }
+
+    ov5640_hard_reset();
+    ov5640_read_id(i2c_bus, &id);
+    ov5640_config(i2c_bus);
+    ov5640_rgb565_mode(i2c_bus);        /* rgb565 mode */
+    ov5640_focus_init(i2c_bus);
+    ov5640_jpeg_mode(i2c_bus);          /* jpeg mode */
+    ov5640_set_light(i2c_bus, 0);       /* auto mode  */
+    ov5640_color_saturation(i2c_bus, 3);
+    ov5640_set_brightness(i2c_bus, 4);  /* brigetness 0 */
+    ov5640_contrast(i2c_bus, 3);
+    ov5640_set_sharpness(i2c_bus, 33);
+    ov5640_focus_constant(i2c_bus);
+
+    /* dcmi init */
+    dcmi_dev = rt_device_find("dcmi");
+    if (dcmi_dev == RT_NULL)
+    {
+        LOG_E("can't find dcmi device!");
+        return RT_ERROR;
+    }
+    rt_device_open(dcmi_dev, RT_DEVICE_FLAG_RDWR);
+
+    rt_hw_dcmi_dma_config((rt_uint32_t)&JPEG_LINE_BUF[0], (rt_uint32_t)&JPEG_LINE_BUF[1], JPEG_LINE_SIZE);
+    ov5640_set_outsize(i2c_bus, 4, 0, jpeg_picture_size[1][0], jpeg_picture_size[1][1]);
+
+    return RT_EOK;
+}
+INIT_APP_EXPORT(rt_hw_ov5640_init);
+
+int camera_sample(int argc, char **argv)
+{
+
+    int fd = -1;
+    rt_uint32_t i, jpg_start, jpg_len;
+    rt_uint16_t tickstart = 0;
+    rt_uint8_t jpg_head = 0;
+    rt_uint8_t *p = RT_NULL;
+
+    if (argc != 2)
+    {
+        rt_kprintf("Usage:\n");
+        rt_kprintf("camera_sample file.jpg\n");
+        return -1;
+    }
+
+    /* start dcmi capture */
+    __HAL_DMA_ENABLE(&hdma_dcmi);
+    dcmi.Instance->CR |= DCMI_CR_CAPTURE;
+
+    tickstart = rt_tick_get();
+    while (1)
+    {
+        if (rt_tick_get() - tickstart > 1000)
+        {
+            LOG_E("picture capture overtime!");
+            break;
+        }
+
+        if (jpeg_data_ok == 1)
+        {
+            dcmi.Instance->CR &= ~(DCMI_CR_CAPTURE);
+            tickstart = rt_tick_get();
+            while(dcmi.Instance->CR & 0x01)
+            {
+                if (rt_tick_get() - tickstart > 0x1000)
+                {
+                    rt_kprintf("dcmi close failed!\n");
+                    jpeg_data_ok = 2;
+                    break;
+                }
+            }
+            __HAL_DMA_DISABLE(&hdma_dcmi);
+
+            p = (rt_uint8_t *)JPEG_DATA_BUF;
+            jpg_len  = 0;
+            jpg_head = 0;
+            for (i = 0; i < jpeg_data_len * 4; i++)
+            {
+                /* jpg head */
+                if ((p[i] == 0xFF) && (p[i + 1] == 0xD8))
+                {
+                    jpg_start = i;
+                    jpg_head = 1;
+                }
+                /* jpg end */
+                if ((p[i] == 0xFF) && (p[i + 1] == 0xD9) && jpg_head)
+                {
+                    jpg_len = i - jpg_start + 2; /* a picture len */
+                    break;
+                }
+            }
+
+            if (jpg_len)
+            {
+                p += jpg_start;
+
+                fd = open(argv[1], O_WRONLY | O_CREAT);
+                if (fd < 0)
+                {
+                    rt_kprintf("open file for recording failed!\n");
+                    return -RT_ERROR;
+                }
+                else
+                {
+                    write(fd, p, jpg_len);
+                    close(fd);
+                    rt_kprintf("picture capture complate!\n");
+                    memset(JPEG_DATA_BUF,0,jpeg_data_len);
+                    jpeg_data_len = 0;
+                    jpeg_data_ok = 0;
+                    break;
+                }
+            }
+
+            jpeg_data_ok = 2;
+        }
+    }
+
+    return RT_EOK;
+}
+MSH_CMD_EXPORT(camera_sample, record picture to a jpg file);
+
+#endif

+ 653 - 0
bsp/stm32/stm32h743-openmv-h7plus/board/ports/drv_ov5640.h

@@ -0,0 +1,653 @@
+
+/*
+ * Copyright (c) 2006-2022, RT-Thread Development Team
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Change Logs:
+ * Date           Author       Notes
+ * 2020-07-27     thread-liu   first version
+ */
+
+#ifndef __DRV_OV5640_H__
+#define __DRV_OV5640_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+  * @brief  OV5640 ID
+  */
+#define  OV5640_ID                                 0x5640U
+
+/* JPEG picture size table */
+static const unsigned short jpeg_picture_size[][2] =
+{
+        160, 120,   /* QQVGA */
+        320, 240,   /* QVGA */
+        640, 480,   /* VGA */
+        800, 600,   /* SVGA */
+        1024, 768,  /* XGA */
+        1280, 800,  /* WXGA */
+        1440, 900,  /* WXGA+ */
+        1280, 1024, /* SXGA */
+        1600, 1200, /* UXGA */
+        1920, 1080, /* 1080P */
+        2048, 1536, /* QXGA */
+        2592, 1944, /* 500W */
+};
+
+/* camera light mode */
+static const unsigned char OV5640_LIGHTMODE_TBL[5][7]=
+{
+    0x04,0X00,0X04,0X00,0X04,0X00,0X00,     /* Auto */
+    0x06,0X1C,0X04,0X00,0X04,0XF3,0X01,     /* Sunny */
+    0x05,0X48,0X04,0X00,0X07,0XCF,0X01,     /* Office */
+    0x06,0X48,0X04,0X00,0X04,0XD3,0X01,     /* Cloudy */
+    0x04,0X10,0X04,0X00,0X08,0X40,0X01,     /* Home */
+};
+
+/* Table of color saturation setting parameters */
+static const unsigned char OV5640_SATURATION_TBL[7][6]=
+{
+    0X0C,0x30,0X3D,0X3E,0X3D,0X01,      /* -3 */
+    0X10,0x3D,0X4D,0X4E,0X4D,0X01,      /* -2 */
+    0X15,0x52,0X66,0X68,0X66,0X02,      /* -1 */
+    0X1A,0x66,0X80,0X82,0X80,0X02,      /* 0 */
+    0X1F,0x7A,0X9A,0X9C,0X9A,0X02,      /* 1 */
+    0X24,0x8F,0XB3,0XB6,0XB3,0X03,      /* 2 */
+    0X2B,0xAB,0XD6,0XDA,0XD6,0X04,      /* 3 */
+};
+
+static const unsigned short OV5640_jpeg_reg_tbl[][2]=
+{
+    0x4300, 0x30, // YUV 422, YUYV
+    0x501f, 0x00, // YUV 422
+    // Input clock = 24Mhz
+    0x3035, 0x21, // PLL
+    0x3036, 0x69, // PLL
+    0x3c07, 0x07, // lightmeter 1 threshold[7:0]
+    0x3820, 0x46, // flip
+    0x3821, 0x20, // mirror
+    0x3814, 0x11, // timing X inc
+    0x3815, 0x11, // timing Y inc
+    0x3800, 0x00, // HS
+    0x3801, 0x00, // HS
+    0x3802, 0x00, // VS
+    0x3803, 0x00, // VS
+    0x3804, 0x0a, // HW (HE)
+    0x3805, 0x3f, // HW (HE)
+    0x3806, 0x07, // VH (VE)
+    0x3807, 0x9f, // VH (VE)
+
+    0x3808, 0x02, // DVPHO
+    0x3809, 0x80, // DVPHO
+    0x380a, 0x01, // DVPVO
+    0x380b, 0xe0, // DVPVO
+
+    0x380c, 0x0b, // HTS        //
+    0x380d, 0x1c, // HTS
+    0x380e, 0x07, // VTS        //
+    0x380f, 0xb0, // VTS
+    0x3813, 0x04, // timing V offset   04
+    0x3618, 0x04,
+    0x3612, 0x2b,
+    0x3709, 0x12,
+    0x370c, 0x00,
+
+    0x4004, 0x06, // BLC line number
+    0x3002, 0x00, // enable JFIFO, SFIFO, JPG
+    0x3006, 0xff, // enable clock of JPEG2x, JPEG
+    0x4713, 0x03, // JPEG mode 3
+    0x4407, 0x01, // Quantization sacle
+    0x460b, 0x35,
+    0x460c, 0x22,
+    0x4837, 0x16, // MIPI global timing
+    0x3824, 0x02, // PCLK manual divider
+    0x5001, 0xA3, // SDE on, Scaling on, CMX on, AWB on
+    0x3503, 0x00, // AEC/AGC on
+};
+
+/* RGB565 configuration, 15 frames */
+static const unsigned short ov5640_rgb565_reg_tbl[][2]=
+{
+    0x4300, 0X6F,
+    0X501F, 0x01,
+    // 1280x800, 15fps
+    // input clock 24Mhz, PCLK 42Mhz
+    0x3035, 0x41, // PLL
+    0x3036, 0x69, // PLL
+    0x3c07, 0x07, // lightmeter 1 threshold[7:0]
+    0x3820, 0x46, // flip
+    0x3821, 0x00, // mirror
+    0x3814, 0x31, // timing X inc
+    0x3815, 0x31, // timing Y inc
+    0x3800, 0x00, // HS
+    0x3801, 0x00, // HS
+    0x3802, 0x00, // VS
+    0x3803, 0x00, // VS
+    0x3804, 0x0a, // HW (HE)
+    0x3805, 0x3f, // HW (HE)
+    0x3806, 0x06, // VH (VE)
+    0x3807, 0xa9, // VH (VE)
+    0x3808, 0x05, // DVPHO
+    0x3809, 0x00, // DVPHO
+    0x380a, 0x02, // DVPVO
+    0x380b, 0xd0, // DVPVO
+    0x380c, 0x05, // HTS
+    0x380d, 0xF8, // HTS
+    0x380e, 0x03, // VTS
+    0x380f, 0x84, // VTS
+    0x3813, 0x04, // timing V offset
+    0x3618, 0x00,
+    0x3612, 0x29,
+    0x3709, 0x52,
+    0x370c, 0x03,
+    0x3a02, 0x02, // 60Hz max exposure
+    0x3a03, 0xe0, // 60Hz max exposure
+
+    0x3a14, 0x02, // 50Hz max exposure
+    0x3a15, 0xe0, // 50Hz max exposure
+    0x4004, 0x02, // BLC line number
+    0x3002, 0x1c, // reset JFIFO, SFIFO, JPG
+    0x3006, 0xc3, // disable clock of JPEG2x, JPEG
+    0x4713, 0x03, // JPEG mode 3
+    0x4407, 0x04, // Quantization scale
+    0x460b, 0x37,
+    0x460c, 0x20,
+    0x4837, 0x16, // MIPI global timing
+    0x3824, 0x04, // PCLK manual divider
+    0x5001, 0xA3, // SDE on, scale on, UV average off, color matrix on, AWB on
+    0x3503, 0x00, // AEC/AGC on
+};
+
+static const unsigned short RGB565_Init[][2]=
+{
+    /* 24MHz input clock, 24MHz PCLK */
+    0x3008, 0x42, // software power down, bit[6]
+    0x3103, 0x03, // system clock from PLL, bit[1]
+    0x3017, 0xff, // FREX, Vsync, HREF, PCLK, D[9:6] output enable
+    0x3018, 0xff, // D[5:0], GPIO[1:0] output enable
+    0x3034, 0x1a, // MIPI 10-bit
+    0x3037, 0x13, // PLL root divider, bit[4], PLL pre-divider, bit[3:0]
+    0x3108, 0x01, // PCLK root divider, bit[5:4], SCLK2x root divider, bit[3:2]
+
+    // SCLK root divider, bit[1:0]
+    0x3630, 0x36,
+    0x3631, 0x0e,
+    0x3632, 0xe2,
+    0x3633, 0x12,
+    0x3621, 0xe0,
+    0x3704, 0xa0,
+    0x3703, 0x5a,
+    0x3715, 0x78,
+    0x3717, 0x01,
+    0x370b, 0x60,
+    0x3705, 0x1a,
+    0x3905, 0x02,
+    0x3906, 0x10,
+    0x3901, 0x0a,
+    0x3731, 0x12,
+    0x3600, 0x08, // VCM control
+    0x3601, 0x33, // VCM control
+    0x302d, 0x60, // system control
+    0x3620, 0x52,
+    0x371b, 0x20,
+    0x471c, 0x50,
+    0x3a13, 0x43, // pre-gain = 1.047x
+    0x3a18, 0x00, // gain ceiling
+    0x3a19, 0xf8, // gain ceiling = 15.5x
+    0x3635, 0x13,
+    0x3636, 0x03,
+    0x3634, 0x40,
+    0x3622, 0x01,
+    // 50/60Hz detection 50/60Hz
+    0x3c01, 0x34, // Band auto, bit[7]
+    0x3c04, 0x28, // threshold low sum
+    0x3c05, 0x98, // threshold high sum
+    0x3c06, 0x00, // light meter 1 threshold[15:8]
+    0x3c07, 0x08, // light meter 1 threshold[7:0]
+    0x3c08, 0x00, // light meter 2 threshold[15:8]
+    0x3c09, 0x1c, // light meter 2 threshold[7:0]
+    0x3c0a, 0x9c, // sample number[15:8]
+    0x3c0b, 0x40, // sample number[7:0]
+    0x3810, 0x00, // Timing Hoffset[11:8]
+    0x3811, 0x10, // Timing Hoffset[7:0]
+    0x3812, 0x00, // Timing Voffset[10:8]
+    0x3708, 0x64,
+    0x4001, 0x02, // BLC start from line 2
+    0x4005, 0x1a, // BLC always update
+    0x3000, 0x00, // enable blocks
+    0x3004, 0xff, // enable clocks
+    0x300e, 0x58, // MIPI power down, DVP enable
+    0x302e, 0x00,
+    0x4300, 0x30, // YUV 422, YUYV
+    0x501f, 0x00, // YUV 422
+    0x440e, 0x00,
+    0x5000, 0xa7, // Lenc on, raw gamma on, BPC on, WPC on, CIP on
+    // AEC target
+    0x3a0f, 0x30, // stable range in high
+    0x3a10, 0x28, // stable range in low
+    0x3a1b, 0x30, // stable range out high
+    0x3a1e, 0x26, // stable range out low
+    0x3a11, 0x60, // fast zone high
+    0x3a1f, 0x14, // fast zone low
+    // Lens correction
+    0x5800, 0x23,
+    0x5801, 0x14,
+    0x5802, 0x0f,
+    0x5803, 0x0f,
+    0x5804, 0x12,
+    0x5805, 0x26,
+    0x5806, 0x0c,
+    0x5807, 0x08,
+    0x5808, 0x05,
+    0x5809, 0x05,
+    0x580a, 0x08,
+
+    0x580b, 0x0d,
+    0x580c, 0x08,
+    0x580d, 0x03,
+    0x580e, 0x00,
+    0x580f, 0x00,
+    0x5810, 0x03,
+    0x5811, 0x09,
+    0x5812, 0x07,
+    0x5813, 0x03,
+    0x5814, 0x00,
+    0x5815, 0x01,
+    0x5816, 0x03,
+    0x5817, 0x08,
+    0x5818, 0x0d,
+    0x5819, 0x08,
+    0x581a, 0x05,
+    0x581b, 0x06,
+    0x581c, 0x08,
+    0x581d, 0x0e,
+    0x581e, 0x29,
+    0x581f, 0x17,
+    0x5820, 0x11,
+    0x5821, 0x11,
+    0x5822, 0x15,
+    0x5823, 0x28,
+    0x5824, 0x46,
+    0x5825, 0x26,
+    0x5826, 0x08,
+    0x5827, 0x26,
+    0x5828, 0x64,
+    0x5829, 0x26,
+    0x582a, 0x24,
+    0x582b, 0x22,
+    0x582c, 0x24,
+    0x582d, 0x24,
+    0x582e, 0x06,
+    0x582f, 0x22,
+    0x5830, 0x40,
+    0x5831, 0x42,
+    0x5832, 0x24,
+    0x5833, 0x26,
+    0x5834, 0x24,
+    0x5835, 0x22,
+    0x5836, 0x22,
+    0x5837, 0x26,
+    0x5838, 0x44,
+    0x5839, 0x24,
+    0x583a, 0x26,
+    0x583b, 0x28,
+    0x583c, 0x42,
+    0x583d, 0xce, // lenc BR offset
+    // AWB
+    0x5180, 0xff, // AWB B block
+    0x5181, 0xf2, // AWB control
+    0x5182, 0x00, // [7:4] max local counter, [3:0] max fast counter
+    0x5183, 0x14, // AWB advanced
+    0x5184, 0x25,
+    0x5185, 0x24,
+    0x5186, 0x09,
+    0x5187, 0x09,
+    0x5188, 0x09,
+    0x5189, 0x75,
+    0x518a, 0x54,
+    0x518b, 0xe0,
+    0x518c, 0xb2,
+    0x518d, 0x42,
+    0x518e, 0x3d,
+    0x518f, 0x56,
+    0x5190, 0x46,
+    0x5191, 0xf8, // AWB top limit
+    0x5192, 0x04, // AWB bottom limit
+    0x5193, 0x70, // red limit
+    0x5194, 0xf0, // green limit
+    0x5195, 0xf0, // blue limit
+    0x5196, 0x03, // AWB control
+    0x5197, 0x01, // local limit
+    0x5198, 0x04,
+    0x5199, 0x12,
+    0x519a, 0x04,
+    0x519b, 0x00,
+    0x519c, 0x06,
+    0x519d, 0x82,
+    0x519e, 0x38, // AWB control
+    // Gamma
+    0x5480, 0x01, // Gamma bias plus on, bit[0]
+    0x5481, 0x08,
+    0x5482, 0x14,
+    0x5483, 0x28,
+    0x5484, 0x51,
+    0x5485, 0x65,
+    0x5486, 0x71,
+    0x5487, 0x7d,
+    0x5488, 0x87,
+    0x5489, 0x91,
+    0x548a, 0x9a,
+    0x548b, 0xaa,
+    0x548c, 0xb8,
+    0x548d, 0xcd,
+    0x548e, 0xdd,
+    0x548f, 0xea,
+    0x5490, 0x1d,
+    // color matrix
+    0x5381, 0x1e, // CMX1 for Y
+    0x5382, 0x5b, // CMX2 for Y
+    0x5383, 0x08, // CMX3 for Y
+    0x5384, 0x0a, // CMX4 for U
+    0x5385, 0x7e, // CMX5 for U
+    0x5386, 0x88, // CMX6 for U
+    0x5387, 0x7c, // CMX7 for V
+    0x5388, 0x6c, // CMX8 for V
+    0x5389, 0x10, // CMX9 for V
+    0x538a, 0x01, // sign[9]
+    0x538b, 0x98, // sign[8:1]
+    // UV adjust UV
+    0x5580, 0x06, // saturation on, bit[1]
+    0x5583, 0x40,
+    0x5584, 0x10,
+    0x5589, 0x10,
+    0x558a, 0x00,
+    0x558b, 0xf8,
+    0x501d, 0x40, // enable manual offset of contrast
+    // CIP
+    0x5300, 0x08, // CIP sharpen MT threshold 1
+    0x5301, 0x30, // CIP sharpen MT threshold 2
+    0x5302, 0x10, // CIP sharpen MT offset 1
+    0x5303, 0x00, // CIP sharpen MT offset 2
+    0x5304, 0x08, // CIP DNS threshold 1
+    0x5305, 0x30, // CIP DNS threshold 2
+    0x5306, 0x08, // CIP DNS offset 1
+    0x5307, 0x16, // CIP DNS offset 2
+    0x5309, 0x08, // CIP sharpen TH threshold 1
+    0x530a, 0x30, // CIP sharpen TH threshold 2
+    0x530b, 0x04, // CIP sharpen TH offset 1
+    0x530c, 0x06, // CIP sharpen TH offset 2
+    0x5025, 0x00,
+    0x3008, 0x02, // wake up from standby, bit[6]
+
+    0x4740, 0X21, //VSYNC
+};
+
+/* Autofocus initialization configuration  */
+const unsigned char OV5640_AF_Config[] =
+{
+    0x02, 0x0f, 0xd6, 0x02, 0x0a, 0x39, 0xc2, 0x01, 0x22, 0x22, 0x00, 0x02, 0x0f, 0xb2, 0xe5, 0x1f, //0x8000,
+    0x70, 0x72, 0xf5, 0x1e, 0xd2, 0x35, 0xff, 0xef, 0x25, 0xe0, 0x24, 0x4e, 0xf8, 0xe4, 0xf6, 0x08, //0x8010,
+    0xf6, 0x0f, 0xbf, 0x34, 0xf2, 0x90, 0x0e, 0x93, 0xe4, 0x93, 0xff, 0xe5, 0x4b, 0xc3, 0x9f, 0x50, //0x8020,
+    0x04, 0x7f, 0x05, 0x80, 0x02, 0x7f, 0xfb, 0x78, 0xbd, 0xa6, 0x07, 0x12, 0x0f, 0x04, 0x40, 0x04, //0x8030,
+    0x7f, 0x03, 0x80, 0x02, 0x7f, 0x30, 0x78, 0xbc, 0xa6, 0x07, 0xe6, 0x18, 0xf6, 0x08, 0xe6, 0x78, //0x8040,
+    0xb9, 0xf6, 0x78, 0xbc, 0xe6, 0x78, 0xba, 0xf6, 0x78, 0xbf, 0x76, 0x33, 0xe4, 0x08, 0xf6, 0x78, //0x8050,
+    0xb8, 0x76, 0x01, 0x75, 0x4a, 0x02, 0x78, 0xb6, 0xf6, 0x08, 0xf6, 0x74, 0xff, 0x78, 0xc1, 0xf6, //0x8060,
+    0x08, 0xf6, 0x75, 0x1f, 0x01, 0x78, 0xbc, 0xe6, 0x75, 0xf0, 0x05, 0xa4, 0xf5, 0x4b, 0x12, 0x0a, //0x8070,
+    0xff, 0xc2, 0x37, 0x22, 0x78, 0xb8, 0xe6, 0xd3, 0x94, 0x00, 0x40, 0x02, 0x16, 0x22, 0xe5, 0x1f, //0x8080,
+    0xb4, 0x05, 0x23, 0xe4, 0xf5, 0x1f, 0xc2, 0x01, 0x78, 0xb6, 0xe6, 0xfe, 0x08, 0xe6, 0xff, 0x78, //0x8090,
+    0x4e, 0xa6, 0x06, 0x08, 0xa6, 0x07, 0xa2, 0x37, 0xe4, 0x33, 0xf5, 0x3c, 0x90, 0x30, 0x28, 0xf0, //0x80a0,
+    0x75, 0x1e, 0x10, 0xd2, 0x35, 0x22, 0xe5, 0x4b, 0x75, 0xf0, 0x05, 0x84, 0x78, 0xbc, 0xf6, 0x90, //0x80b0,
+    0x0e, 0x8c, 0xe4, 0x93, 0xff, 0x25, 0xe0, 0x24, 0x0a, 0xf8, 0xe6, 0xfc, 0x08, 0xe6, 0xfd, 0x78, //0x80c0,
+    0xbc, 0xe6, 0x25, 0xe0, 0x24, 0x4e, 0xf8, 0xa6, 0x04, 0x08, 0xa6, 0x05, 0xef, 0x12, 0x0f, 0x0b, //0x80d0,
+    0xd3, 0x78, 0xb7, 0x96, 0xee, 0x18, 0x96, 0x40, 0x0d, 0x78, 0xbc, 0xe6, 0x78, 0xb9, 0xf6, 0x78, //0x80e0,
+    0xb6, 0xa6, 0x06, 0x08, 0xa6, 0x07, 0x90, 0x0e, 0x8c, 0xe4, 0x93, 0x12, 0x0f, 0x0b, 0xc3, 0x78, //0x80f0,
+    0xc2, 0x96, 0xee, 0x18, 0x96, 0x50, 0x0d, 0x78, 0xbc, 0xe6, 0x78, 0xba, 0xf6, 0x78, 0xc1, 0xa6, //0x8100,
+    0x06, 0x08, 0xa6, 0x07, 0x78, 0xb6, 0xe6, 0xfe, 0x08, 0xe6, 0xc3, 0x78, 0xc2, 0x96, 0xff, 0xee, //0x8110,
+    0x18, 0x96, 0x78, 0xc3, 0xf6, 0x08, 0xa6, 0x07, 0x90, 0x0e, 0x95, 0xe4, 0x18, 0x12, 0x0e, 0xe9, //0x8120,
+    0x40, 0x02, 0xd2, 0x37, 0x78, 0xbc, 0xe6, 0x08, 0x26, 0x08, 0xf6, 0xe5, 0x1f, 0x64, 0x01, 0x70, //0x8130,
+    0x4a, 0xe6, 0xc3, 0x78, 0xc0, 0x12, 0x0e, 0xdf, 0x40, 0x05, 0x12, 0x0e, 0xda, 0x40, 0x39, 0x12, //0x8140,
+    0x0f, 0x02, 0x40, 0x04, 0x7f, 0xfe, 0x80, 0x02, 0x7f, 0x02, 0x78, 0xbd, 0xa6, 0x07, 0x78, 0xb9, //0x8150,
+    0xe6, 0x24, 0x03, 0x78, 0xbf, 0xf6, 0x78, 0xb9, 0xe6, 0x24, 0xfd, 0x78, 0xc0, 0xf6, 0x12, 0x0f, //0x8160,
+    0x02, 0x40, 0x06, 0x78, 0xc0, 0xe6, 0xff, 0x80, 0x04, 0x78, 0xbf, 0xe6, 0xff, 0x78, 0xbe, 0xa6, //0x8170,
+    0x07, 0x75, 0x1f, 0x02, 0x78, 0xb8, 0x76, 0x01, 0x02, 0x02, 0x4a, 0xe5, 0x1f, 0x64, 0x02, 0x60, //0x8180,
+    0x03, 0x02, 0x02, 0x2a, 0x78, 0xbe, 0xe6, 0xff, 0xc3, 0x78, 0xc0, 0x12, 0x0e, 0xe0, 0x40, 0x08, //0x8190,
+    0x12, 0x0e, 0xda, 0x50, 0x03, 0x02, 0x02, 0x28, 0x12, 0x0f, 0x02, 0x40, 0x04, 0x7f, 0xff, 0x80, //0x81a0,
+    0x02, 0x7f, 0x01, 0x78, 0xbd, 0xa6, 0x07, 0x78, 0xb9, 0xe6, 0x04, 0x78, 0xbf, 0xf6, 0x78, 0xb9, //0x81b0,
+    0xe6, 0x14, 0x78, 0xc0, 0xf6, 0x18, 0x12, 0x0f, 0x04, 0x40, 0x04, 0xe6, 0xff, 0x80, 0x02, 0x7f, //0x81c0,
+    0x00, 0x78, 0xbf, 0xa6, 0x07, 0xd3, 0x08, 0xe6, 0x64, 0x80, 0x94, 0x80, 0x40, 0x04, 0xe6, 0xff, //0x81d0,
+    0x80, 0x02, 0x7f, 0x00, 0x78, 0xc0, 0xa6, 0x07, 0xc3, 0x18, 0xe6, 0x64, 0x80, 0x94, 0xb3, 0x50, //0x81e0,
+    0x04, 0xe6, 0xff, 0x80, 0x02, 0x7f, 0x33, 0x78, 0xbf, 0xa6, 0x07, 0xc3, 0x08, 0xe6, 0x64, 0x80, //0x81f0,
+    0x94, 0xb3, 0x50, 0x04, 0xe6, 0xff, 0x80, 0x02, 0x7f, 0x33, 0x78, 0xc0, 0xa6, 0x07, 0x12, 0x0f, //0x8200,
+    0x02, 0x40, 0x06, 0x78, 0xc0, 0xe6, 0xff, 0x80, 0x04, 0x78, 0xbf, 0xe6, 0xff, 0x78, 0xbe, 0xa6, //0x8210,
+    0x07, 0x75, 0x1f, 0x03, 0x78, 0xb8, 0x76, 0x01, 0x80, 0x20, 0xe5, 0x1f, 0x64, 0x03, 0x70, 0x26, //0x8220,
+    0x78, 0xbe, 0xe6, 0xff, 0xc3, 0x78, 0xc0, 0x12, 0x0e, 0xe0, 0x40, 0x05, 0x12, 0x0e, 0xda, 0x40, //0x8230,
+    0x09, 0x78, 0xb9, 0xe6, 0x78, 0xbe, 0xf6, 0x75, 0x1f, 0x04, 0x78, 0xbe, 0xe6, 0x75, 0xf0, 0x05, //0x8240,
+    0xa4, 0xf5, 0x4b, 0x02, 0x0a, 0xff, 0xe5, 0x1f, 0xb4, 0x04, 0x10, 0x90, 0x0e, 0x94, 0xe4, 0x78, //0x8250,
+    0xc3, 0x12, 0x0e, 0xe9, 0x40, 0x02, 0xd2, 0x37, 0x75, 0x1f, 0x05, 0x22, 0x30, 0x01, 0x03, 0x02, //0x8260,
+    0x04, 0xc0, 0x30, 0x02, 0x03, 0x02, 0x04, 0xc0, 0x90, 0x51, 0xa5, 0xe0, 0x78, 0x93, 0xf6, 0xa3, //0x8270,
+    0xe0, 0x08, 0xf6, 0xa3, 0xe0, 0x08, 0xf6, 0xe5, 0x1f, 0x70, 0x3c, 0x75, 0x1e, 0x20, 0xd2, 0x35, //0x8280,
+    0x12, 0x0c, 0x7a, 0x78, 0x7e, 0xa6, 0x06, 0x08, 0xa6, 0x07, 0x78, 0x8b, 0xa6, 0x09, 0x18, 0x76, //0x8290,
+    0x01, 0x12, 0x0c, 0x5b, 0x78, 0x4e, 0xa6, 0x06, 0x08, 0xa6, 0x07, 0x78, 0x8b, 0xe6, 0x78, 0x6e, //0x82a0,
+    0xf6, 0x75, 0x1f, 0x01, 0x78, 0x93, 0xe6, 0x78, 0x90, 0xf6, 0x78, 0x94, 0xe6, 0x78, 0x91, 0xf6, //0x82b0,
+    0x78, 0x95, 0xe6, 0x78, 0x92, 0xf6, 0x22, 0x79, 0x90, 0xe7, 0xd3, 0x78, 0x93, 0x96, 0x40, 0x05, //0x82c0,
+    0xe7, 0x96, 0xff, 0x80, 0x08, 0xc3, 0x79, 0x93, 0xe7, 0x78, 0x90, 0x96, 0xff, 0x78, 0x88, 0x76, //0x82d0,
+    0x00, 0x08, 0xa6, 0x07, 0x79, 0x91, 0xe7, 0xd3, 0x78, 0x94, 0x96, 0x40, 0x05, 0xe7, 0x96, 0xff, //0x82e0,
+    0x80, 0x08, 0xc3, 0x79, 0x94, 0xe7, 0x78, 0x91, 0x96, 0xff, 0x12, 0x0c, 0x8e, 0x79, 0x92, 0xe7, //0x82f0,
+    0xd3, 0x78, 0x95, 0x96, 0x40, 0x05, 0xe7, 0x96, 0xff, 0x80, 0x08, 0xc3, 0x79, 0x95, 0xe7, 0x78, //0x8300,
+    0x92, 0x96, 0xff, 0x12, 0x0c, 0x8e, 0x12, 0x0c, 0x5b, 0x78, 0x8a, 0xe6, 0x25, 0xe0, 0x24, 0x4e, //0x8310,
+    0xf8, 0xa6, 0x06, 0x08, 0xa6, 0x07, 0x78, 0x8a, 0xe6, 0x24, 0x6e, 0xf8, 0xa6, 0x09, 0x78, 0x8a, //0x8320,
+    0xe6, 0x24, 0x01, 0xff, 0xe4, 0x33, 0xfe, 0xd3, 0xef, 0x94, 0x0f, 0xee, 0x64, 0x80, 0x94, 0x80, //0x8330,
+    0x40, 0x04, 0x7f, 0x00, 0x80, 0x05, 0x78, 0x8a, 0xe6, 0x04, 0xff, 0x78, 0x8a, 0xa6, 0x07, 0xe5, //0x8340,
+    0x1f, 0xb4, 0x01, 0x0a, 0xe6, 0x60, 0x03, 0x02, 0x04, 0xc0, 0x75, 0x1f, 0x02, 0x22, 0x12, 0x0c, //0x8350,
+    0x7a, 0x78, 0x80, 0xa6, 0x06, 0x08, 0xa6, 0x07, 0x12, 0x0c, 0x7a, 0x78, 0x82, 0xa6, 0x06, 0x08, //0x8360,
+    0xa6, 0x07, 0x78, 0x6e, 0xe6, 0x78, 0x8c, 0xf6, 0x78, 0x6e, 0xe6, 0x78, 0x8d, 0xf6, 0x7f, 0x01, //0x8370,
+    0xef, 0x25, 0xe0, 0x24, 0x4f, 0xf9, 0xc3, 0x78, 0x81, 0xe6, 0x97, 0x18, 0xe6, 0x19, 0x97, 0x50, //0x8380,
+    0x0a, 0x12, 0x0c, 0x82, 0x78, 0x80, 0xa6, 0x04, 0x08, 0xa6, 0x05, 0x74, 0x6e, 0x2f, 0xf9, 0x78, //0x8390,
+    0x8c, 0xe6, 0xc3, 0x97, 0x50, 0x08, 0x74, 0x6e, 0x2f, 0xf8, 0xe6, 0x78, 0x8c, 0xf6, 0xef, 0x25, //0x83a0,
+    0xe0, 0x24, 0x4f, 0xf9, 0xd3, 0x78, 0x83, 0xe6, 0x97, 0x18, 0xe6, 0x19, 0x97, 0x40, 0x0a, 0x12, //0x83b0,
+    0x0c, 0x82, 0x78, 0x82, 0xa6, 0x04, 0x08, 0xa6, 0x05, 0x74, 0x6e, 0x2f, 0xf9, 0x78, 0x8d, 0xe6, //0x83c0,
+    0xd3, 0x97, 0x40, 0x08, 0x74, 0x6e, 0x2f, 0xf8, 0xe6, 0x78, 0x8d, 0xf6, 0x0f, 0xef, 0x64, 0x10, //0x83d0,
+    0x70, 0x9e, 0xc3, 0x79, 0x81, 0xe7, 0x78, 0x83, 0x96, 0xff, 0x19, 0xe7, 0x18, 0x96, 0x78, 0x84, //0x83e0,
+    0xf6, 0x08, 0xa6, 0x07, 0xc3, 0x79, 0x8c, 0xe7, 0x78, 0x8d, 0x96, 0x08, 0xf6, 0xd3, 0x79, 0x81, //0x83f0,
+    0xe7, 0x78, 0x7f, 0x96, 0x19, 0xe7, 0x18, 0x96, 0x40, 0x05, 0x09, 0xe7, 0x08, 0x80, 0x06, 0xc3, //0x8400,
+    0x79, 0x7f, 0xe7, 0x78, 0x81, 0x96, 0xff, 0x19, 0xe7, 0x18, 0x96, 0xfe, 0x78, 0x86, 0xa6, 0x06, //0x8410,
+    0x08, 0xa6, 0x07, 0x79, 0x8c, 0xe7, 0xd3, 0x78, 0x8b, 0x96, 0x40, 0x05, 0xe7, 0x96, 0xff, 0x80, //0x8420,
+    0x08, 0xc3, 0x79, 0x8b, 0xe7, 0x78, 0x8c, 0x96, 0xff, 0x78, 0x8f, 0xa6, 0x07, 0xe5, 0x1f, 0x64, //0x8430,
+    0x02, 0x70, 0x69, 0x90, 0x0e, 0x91, 0x93, 0xff, 0x18, 0xe6, 0xc3, 0x9f, 0x50, 0x72, 0x12, 0x0c, //0x8440,
+    0x4a, 0x12, 0x0c, 0x2f, 0x90, 0x0e, 0x8e, 0x12, 0x0c, 0x38, 0x78, 0x80, 0x12, 0x0c, 0x6b, 0x7b, //0x8450,
+    0x04, 0x12, 0x0c, 0x1d, 0xc3, 0x12, 0x06, 0x45, 0x50, 0x56, 0x90, 0x0e, 0x92, 0xe4, 0x93, 0xff, //0x8460,
+    0x78, 0x8f, 0xe6, 0x9f, 0x40, 0x02, 0x80, 0x11, 0x90, 0x0e, 0x90, 0xe4, 0x93, 0xff, 0xd3, 0x78, //0x8470,
+    0x89, 0xe6, 0x9f, 0x18, 0xe6, 0x94, 0x00, 0x40, 0x03, 0x75, 0x1f, 0x05, 0x12, 0x0c, 0x4a, 0x12, //0x8480,
+    0x0c, 0x2f, 0x90, 0x0e, 0x8f, 0x12, 0x0c, 0x38, 0x78, 0x7e, 0x12, 0x0c, 0x6b, 0x7b, 0x40, 0x12, //0x8490,
+    0x0c, 0x1d, 0xd3, 0x12, 0x06, 0x45, 0x40, 0x18, 0x75, 0x1f, 0x05, 0x22, 0xe5, 0x1f, 0xb4, 0x05, //0x84a0,
+    0x0f, 0xd2, 0x01, 0xc2, 0x02, 0xe4, 0xf5, 0x1f, 0xf5, 0x1e, 0xd2, 0x35, 0xd2, 0x33, 0xd2, 0x36, //0x84b0,
+    0x22, 0xef, 0x8d, 0xf0, 0xa4, 0xa8, 0xf0, 0xcf, 0x8c, 0xf0, 0xa4, 0x28, 0xce, 0x8d, 0xf0, 0xa4, //0x84c0,
+    0x2e, 0xfe, 0x22, 0xbc, 0x00, 0x0b, 0xbe, 0x00, 0x29, 0xef, 0x8d, 0xf0, 0x84, 0xff, 0xad, 0xf0, //0x84d0,
+    0x22, 0xe4, 0xcc, 0xf8, 0x75, 0xf0, 0x08, 0xef, 0x2f, 0xff, 0xee, 0x33, 0xfe, 0xec, 0x33, 0xfc, //0x84e0,
+    0xee, 0x9d, 0xec, 0x98, 0x40, 0x05, 0xfc, 0xee, 0x9d, 0xfe, 0x0f, 0xd5, 0xf0, 0xe9, 0xe4, 0xce, //0x84f0,
+    0xfd, 0x22, 0xed, 0xf8, 0xf5, 0xf0, 0xee, 0x84, 0x20, 0xd2, 0x1c, 0xfe, 0xad, 0xf0, 0x75, 0xf0, //0x8500,
+    0x08, 0xef, 0x2f, 0xff, 0xed, 0x33, 0xfd, 0x40, 0x07, 0x98, 0x50, 0x06, 0xd5, 0xf0, 0xf2, 0x22, //0x8510,
+    0xc3, 0x98, 0xfd, 0x0f, 0xd5, 0xf0, 0xea, 0x22, 0xe8, 0x8f, 0xf0, 0xa4, 0xcc, 0x8b, 0xf0, 0xa4, //0x8520,
+    0x2c, 0xfc, 0xe9, 0x8e, 0xf0, 0xa4, 0x2c, 0xfc, 0x8a, 0xf0, 0xed, 0xa4, 0x2c, 0xfc, 0xea, 0x8e, //0x8530,
+    0xf0, 0xa4, 0xcd, 0xa8, 0xf0, 0x8b, 0xf0, 0xa4, 0x2d, 0xcc, 0x38, 0x25, 0xf0, 0xfd, 0xe9, 0x8f, //0x8540,
+    0xf0, 0xa4, 0x2c, 0xcd, 0x35, 0xf0, 0xfc, 0xeb, 0x8e, 0xf0, 0xa4, 0xfe, 0xa9, 0xf0, 0xeb, 0x8f, //0x8550,
+    0xf0, 0xa4, 0xcf, 0xc5, 0xf0, 0x2e, 0xcd, 0x39, 0xfe, 0xe4, 0x3c, 0xfc, 0xea, 0xa4, 0x2d, 0xce, //0x8560,
+    0x35, 0xf0, 0xfd, 0xe4, 0x3c, 0xfc, 0x22, 0x75, 0xf0, 0x08, 0x75, 0x82, 0x00, 0xef, 0x2f, 0xff, //0x8570,
+    0xee, 0x33, 0xfe, 0xcd, 0x33, 0xcd, 0xcc, 0x33, 0xcc, 0xc5, 0x82, 0x33, 0xc5, 0x82, 0x9b, 0xed, //0x8580,
+    0x9a, 0xec, 0x99, 0xe5, 0x82, 0x98, 0x40, 0x0c, 0xf5, 0x82, 0xee, 0x9b, 0xfe, 0xed, 0x9a, 0xfd, //0x8590,
+    0xec, 0x99, 0xfc, 0x0f, 0xd5, 0xf0, 0xd6, 0xe4, 0xce, 0xfb, 0xe4, 0xcd, 0xfa, 0xe4, 0xcc, 0xf9, //0x85a0,
+    0xa8, 0x82, 0x22, 0xb8, 0x00, 0xc1, 0xb9, 0x00, 0x59, 0xba, 0x00, 0x2d, 0xec, 0x8b, 0xf0, 0x84, //0x85b0,
+    0xcf, 0xce, 0xcd, 0xfc, 0xe5, 0xf0, 0xcb, 0xf9, 0x78, 0x18, 0xef, 0x2f, 0xff, 0xee, 0x33, 0xfe, //0x85c0,
+    0xed, 0x33, 0xfd, 0xec, 0x33, 0xfc, 0xeb, 0x33, 0xfb, 0x10, 0xd7, 0x03, 0x99, 0x40, 0x04, 0xeb, //0x85d0,
+    0x99, 0xfb, 0x0f, 0xd8, 0xe5, 0xe4, 0xf9, 0xfa, 0x22, 0x78, 0x18, 0xef, 0x2f, 0xff, 0xee, 0x33, //0x85e0,
+    0xfe, 0xed, 0x33, 0xfd, 0xec, 0x33, 0xfc, 0xc9, 0x33, 0xc9, 0x10, 0xd7, 0x05, 0x9b, 0xe9, 0x9a, //0x85f0,
+    0x40, 0x07, 0xec, 0x9b, 0xfc, 0xe9, 0x9a, 0xf9, 0x0f, 0xd8, 0xe0, 0xe4, 0xc9, 0xfa, 0xe4, 0xcc, //0x8600,
+    0xfb, 0x22, 0x75, 0xf0, 0x10, 0xef, 0x2f, 0xff, 0xee, 0x33, 0xfe, 0xed, 0x33, 0xfd, 0xcc, 0x33, //0x8610,
+    0xcc, 0xc8, 0x33, 0xc8, 0x10, 0xd7, 0x07, 0x9b, 0xec, 0x9a, 0xe8, 0x99, 0x40, 0x0a, 0xed, 0x9b, //0x8620,
+    0xfd, 0xec, 0x9a, 0xfc, 0xe8, 0x99, 0xf8, 0x0f, 0xd5, 0xf0, 0xda, 0xe4, 0xcd, 0xfb, 0xe4, 0xcc, //0x8630,
+    0xfa, 0xe4, 0xc8, 0xf9, 0x22, 0xeb, 0x9f, 0xf5, 0xf0, 0xea, 0x9e, 0x42, 0xf0, 0xe9, 0x9d, 0x42, //0x8640,
+    0xf0, 0xe8, 0x9c, 0x45, 0xf0, 0x22, 0xe8, 0x60, 0x0f, 0xec, 0xc3, 0x13, 0xfc, 0xed, 0x13, 0xfd, //0x8650,
+    0xee, 0x13, 0xfe, 0xef, 0x13, 0xff, 0xd8, 0xf1, 0x22, 0xe8, 0x60, 0x0f, 0xef, 0xc3, 0x33, 0xff, //0x8660,
+    0xee, 0x33, 0xfe, 0xed, 0x33, 0xfd, 0xec, 0x33, 0xfc, 0xd8, 0xf1, 0x22, 0xe4, 0x93, 0xfc, 0x74, //0x8670,
+    0x01, 0x93, 0xfd, 0x74, 0x02, 0x93, 0xfe, 0x74, 0x03, 0x93, 0xff, 0x22, 0xe6, 0xfb, 0x08, 0xe6, //0x8680,
+    0xf9, 0x08, 0xe6, 0xfa, 0x08, 0xe6, 0xcb, 0xf8, 0x22, 0xec, 0xf6, 0x08, 0xed, 0xf6, 0x08, 0xee, //0x8690,
+    0xf6, 0x08, 0xef, 0xf6, 0x22, 0xa4, 0x25, 0x82, 0xf5, 0x82, 0xe5, 0xf0, 0x35, 0x83, 0xf5, 0x83, //0x86a0,
+    0x22, 0xd0, 0x83, 0xd0, 0x82, 0xf8, 0xe4, 0x93, 0x70, 0x12, 0x74, 0x01, 0x93, 0x70, 0x0d, 0xa3, //0x86b0,
+    0xa3, 0x93, 0xf8, 0x74, 0x01, 0x93, 0xf5, 0x82, 0x88, 0x83, 0xe4, 0x73, 0x74, 0x02, 0x93, 0x68, //0x86c0,
+    0x60, 0xef, 0xa3, 0xa3, 0xa3, 0x80, 0xdf, 0x90, 0x38, 0x04, 0x78, 0x52, 0x12, 0x0b, 0xfd, 0x90, //0x86d0,
+    0x38, 0x00, 0xe0, 0xfe, 0xa3, 0xe0, 0xfd, 0xed, 0xff, 0xc3, 0x12, 0x0b, 0x9e, 0x90, 0x38, 0x10, //0x86e0,
+    0x12, 0x0b, 0x92, 0x90, 0x38, 0x06, 0x78, 0x54, 0x12, 0x0b, 0xfd, 0x90, 0x38, 0x02, 0xe0, 0xfe, //0x86f0,
+    0xa3, 0xe0, 0xfd, 0xed, 0xff, 0xc3, 0x12, 0x0b, 0x9e, 0x90, 0x38, 0x12, 0x12, 0x0b, 0x92, 0xa3, //0x8700,
+    0xe0, 0xb4, 0x31, 0x07, 0x78, 0x52, 0x79, 0x52, 0x12, 0x0c, 0x13, 0x90, 0x38, 0x14, 0xe0, 0xb4, //0x8710,
+    0x71, 0x15, 0x78, 0x52, 0xe6, 0xfe, 0x08, 0xe6, 0x78, 0x02, 0xce, 0xc3, 0x13, 0xce, 0x13, 0xd8, //0x8720,
+    0xf9, 0x79, 0x53, 0xf7, 0xee, 0x19, 0xf7, 0x90, 0x38, 0x15, 0xe0, 0xb4, 0x31, 0x07, 0x78, 0x54, //0x8730,
+    0x79, 0x54, 0x12, 0x0c, 0x13, 0x90, 0x38, 0x15, 0xe0, 0xb4, 0x71, 0x15, 0x78, 0x54, 0xe6, 0xfe, //0x8740,
+    0x08, 0xe6, 0x78, 0x02, 0xce, 0xc3, 0x13, 0xce, 0x13, 0xd8, 0xf9, 0x79, 0x55, 0xf7, 0xee, 0x19, //0x8750,
+    0xf7, 0x79, 0x52, 0x12, 0x0b, 0xd9, 0x09, 0x12, 0x0b, 0xd9, 0xaf, 0x47, 0x12, 0x0b, 0xb2, 0xe5, //0x8760,
+    0x44, 0xfb, 0x7a, 0x00, 0xfd, 0x7c, 0x00, 0x12, 0x04, 0xd3, 0x78, 0x5a, 0xa6, 0x06, 0x08, 0xa6, //0x8770,
+    0x07, 0xaf, 0x45, 0x12, 0x0b, 0xb2, 0xad, 0x03, 0x7c, 0x00, 0x12, 0x04, 0xd3, 0x78, 0x56, 0xa6, //0x8780,
+    0x06, 0x08, 0xa6, 0x07, 0xaf, 0x48, 0x78, 0x54, 0x12, 0x0b, 0xb4, 0xe5, 0x43, 0xfb, 0xfd, 0x7c, //0x8790,
+    0x00, 0x12, 0x04, 0xd3, 0x78, 0x5c, 0xa6, 0x06, 0x08, 0xa6, 0x07, 0xaf, 0x46, 0x7e, 0x00, 0x78, //0x87a0,
+    0x54, 0x12, 0x0b, 0xb6, 0xad, 0x03, 0x7c, 0x00, 0x12, 0x04, 0xd3, 0x78, 0x58, 0xa6, 0x06, 0x08, //0x87b0,
+    0xa6, 0x07, 0xc3, 0x78, 0x5b, 0xe6, 0x94, 0x08, 0x18, 0xe6, 0x94, 0x00, 0x50, 0x05, 0x76, 0x00, //0x87c0,
+    0x08, 0x76, 0x08, 0xc3, 0x78, 0x5d, 0xe6, 0x94, 0x08, 0x18, 0xe6, 0x94, 0x00, 0x50, 0x05, 0x76, //0x87d0,
+    0x00, 0x08, 0x76, 0x08, 0x78, 0x5a, 0x12, 0x0b, 0xc6, 0xff, 0xd3, 0x78, 0x57, 0xe6, 0x9f, 0x18, //0x87e0,
+    0xe6, 0x9e, 0x40, 0x0e, 0x78, 0x5a, 0xe6, 0x13, 0xfe, 0x08, 0xe6, 0x78, 0x57, 0x12, 0x0c, 0x08, //0x87f0,
+    0x80, 0x04, 0x7e, 0x00, 0x7f, 0x00, 0x78, 0x5e, 0x12, 0x0b, 0xbe, 0xff, 0xd3, 0x78, 0x59, 0xe6, //0x8800,
+    0x9f, 0x18, 0xe6, 0x9e, 0x40, 0x0e, 0x78, 0x5c, 0xe6, 0x13, 0xfe, 0x08, 0xe6, 0x78, 0x59, 0x12, //0x8810,
+    0x0c, 0x08, 0x80, 0x04, 0x7e, 0x00, 0x7f, 0x00, 0xe4, 0xfc, 0xfd, 0x78, 0x62, 0x12, 0x06, 0x99, //0x8820,
+    0x78, 0x5a, 0x12, 0x0b, 0xc6, 0x78, 0x57, 0x26, 0xff, 0xee, 0x18, 0x36, 0xfe, 0x78, 0x66, 0x12, //0x8830,
+    0x0b, 0xbe, 0x78, 0x59, 0x26, 0xff, 0xee, 0x18, 0x36, 0xfe, 0xe4, 0xfc, 0xfd, 0x78, 0x6a, 0x12, //0x8840,
+    0x06, 0x99, 0x12, 0x0b, 0xce, 0x78, 0x66, 0x12, 0x06, 0x8c, 0xd3, 0x12, 0x06, 0x45, 0x40, 0x08, //0x8850,
+    0x12, 0x0b, 0xce, 0x78, 0x66, 0x12, 0x06, 0x99, 0x78, 0x54, 0x12, 0x0b, 0xd0, 0x78, 0x6a, 0x12, //0x8860,
+    0x06, 0x8c, 0xd3, 0x12, 0x06, 0x45, 0x40, 0x0a, 0x78, 0x54, 0x12, 0x0b, 0xd0, 0x78, 0x6a, 0x12, //0x8870,
+    0x06, 0x99, 0x78, 0x61, 0xe6, 0x90, 0x60, 0x01, 0xf0, 0x78, 0x65, 0xe6, 0xa3, 0xf0, 0x78, 0x69, //0x8880,
+    0xe6, 0xa3, 0xf0, 0x78, 0x55, 0xe6, 0xa3, 0xf0, 0x7d, 0x01, 0x78, 0x61, 0x12, 0x0b, 0xe9, 0x24, //0x8890,
+    0x01, 0x12, 0x0b, 0xa6, 0x78, 0x65, 0x12, 0x0b, 0xe9, 0x24, 0x02, 0x12, 0x0b, 0xa6, 0x78, 0x69, //0x88a0,
+    0x12, 0x0b, 0xe9, 0x24, 0x03, 0x12, 0x0b, 0xa6, 0x78, 0x6d, 0x12, 0x0b, 0xe9, 0x24, 0x04, 0x12, //0x88b0,
+    0x0b, 0xa6, 0x0d, 0xbd, 0x05, 0xd4, 0xc2, 0x0e, 0xc2, 0x06, 0x22, 0x85, 0x08, 0x41, 0x90, 0x30, //0x88c0,
+    0x24, 0xe0, 0xf5, 0x3d, 0xa3, 0xe0, 0xf5, 0x3e, 0xa3, 0xe0, 0xf5, 0x3f, 0xa3, 0xe0, 0xf5, 0x40, //0x88d0,
+    0xa3, 0xe0, 0xf5, 0x3c, 0xd2, 0x34, 0xe5, 0x41, 0x12, 0x06, 0xb1, 0x09, 0x31, 0x03, 0x09, 0x35, //0x88e0,
+    0x04, 0x09, 0x3b, 0x05, 0x09, 0x3e, 0x06, 0x09, 0x41, 0x07, 0x09, 0x4a, 0x08, 0x09, 0x5b, 0x12, //0x88f0,
+    0x09, 0x73, 0x18, 0x09, 0x89, 0x19, 0x09, 0x5e, 0x1a, 0x09, 0x6a, 0x1b, 0x09, 0xad, 0x80, 0x09, //0x8900,
+    0xb2, 0x81, 0x0a, 0x1d, 0x8f, 0x0a, 0x09, 0x90, 0x0a, 0x1d, 0x91, 0x0a, 0x1d, 0x92, 0x0a, 0x1d, //0x8910,
+    0x93, 0x0a, 0x1d, 0x94, 0x0a, 0x1d, 0x98, 0x0a, 0x17, 0x9f, 0x0a, 0x1a, 0xec, 0x00, 0x00, 0x0a, //0x8920,
+    0x38, 0x12, 0x0f, 0x74, 0x22, 0x12, 0x0f, 0x74, 0xd2, 0x03, 0x22, 0xd2, 0x03, 0x22, 0xc2, 0x03, //0x8930,
+    0x22, 0xa2, 0x37, 0xe4, 0x33, 0xf5, 0x3c, 0x02, 0x0a, 0x1d, 0xc2, 0x01, 0xc2, 0x02, 0xc2, 0x03, //0x8940,
+    0x12, 0x0d, 0x0d, 0x75, 0x1e, 0x70, 0xd2, 0x35, 0x02, 0x0a, 0x1d, 0x02, 0x0a, 0x04, 0x85, 0x40, //0x8950,
+    0x4a, 0x85, 0x3c, 0x4b, 0x12, 0x0a, 0xff, 0x02, 0x0a, 0x1d, 0x85, 0x4a, 0x40, 0x85, 0x4b, 0x3c, //0x8960,
+    0x02, 0x0a, 0x1d, 0xe4, 0xf5, 0x22, 0xf5, 0x23, 0x85, 0x40, 0x31, 0x85, 0x3f, 0x30, 0x85, 0x3e, //0x8970,
+    0x2f, 0x85, 0x3d, 0x2e, 0x12, 0x0f, 0x46, 0x80, 0x1f, 0x75, 0x22, 0x00, 0x75, 0x23, 0x01, 0x74, //0x8980,
+    0xff, 0xf5, 0x2d, 0xf5, 0x2c, 0xf5, 0x2b, 0xf5, 0x2a, 0x12, 0x0f, 0x46, 0x85, 0x2d, 0x40, 0x85, //0x8990,
+    0x2c, 0x3f, 0x85, 0x2b, 0x3e, 0x85, 0x2a, 0x3d, 0xe4, 0xf5, 0x3c, 0x80, 0x70, 0x12, 0x0f, 0x16, //0x89a0,
+    0x80, 0x6b, 0x85, 0x3d, 0x45, 0x85, 0x3e, 0x46, 0xe5, 0x47, 0xc3, 0x13, 0xff, 0xe5, 0x45, 0xc3, //0x89b0,
+    0x9f, 0x50, 0x02, 0x8f, 0x45, 0xe5, 0x48, 0xc3, 0x13, 0xff, 0xe5, 0x46, 0xc3, 0x9f, 0x50, 0x02, //0x89c0,
+    0x8f, 0x46, 0xe5, 0x47, 0xc3, 0x13, 0xff, 0xfd, 0xe5, 0x45, 0x2d, 0xfd, 0xe4, 0x33, 0xfc, 0xe5, //0x89d0,
+    0x44, 0x12, 0x0f, 0x90, 0x40, 0x05, 0xe5, 0x44, 0x9f, 0xf5, 0x45, 0xe5, 0x48, 0xc3, 0x13, 0xff, //0x89e0,
+    0xfd, 0xe5, 0x46, 0x2d, 0xfd, 0xe4, 0x33, 0xfc, 0xe5, 0x43, 0x12, 0x0f, 0x90, 0x40, 0x05, 0xe5, //0x89f0,
+    0x43, 0x9f, 0xf5, 0x46, 0x12, 0x06, 0xd7, 0x80, 0x14, 0x85, 0x40, 0x48, 0x85, 0x3f, 0x47, 0x85, //0x8a00,
+    0x3e, 0x46, 0x85, 0x3d, 0x45, 0x80, 0x06, 0x02, 0x06, 0xd7, 0x12, 0x0d, 0x7e, 0x90, 0x30, 0x24, //0x8a10,
+    0xe5, 0x3d, 0xf0, 0xa3, 0xe5, 0x3e, 0xf0, 0xa3, 0xe5, 0x3f, 0xf0, 0xa3, 0xe5, 0x40, 0xf0, 0xa3, //0x8a20,
+    0xe5, 0x3c, 0xf0, 0x90, 0x30, 0x23, 0xe4, 0xf0, 0x22, 0xc0, 0xe0, 0xc0, 0x83, 0xc0, 0x82, 0xc0, //0x8a30,
+    0xd0, 0x90, 0x3f, 0x0c, 0xe0, 0xf5, 0x32, 0xe5, 0x32, 0x30, 0xe3, 0x74, 0x30, 0x36, 0x66, 0x90, //0x8a40,
+    0x60, 0x19, 0xe0, 0xf5, 0x0a, 0xa3, 0xe0, 0xf5, 0x0b, 0x90, 0x60, 0x1d, 0xe0, 0xf5, 0x14, 0xa3, //0x8a50,
+    0xe0, 0xf5, 0x15, 0x90, 0x60, 0x21, 0xe0, 0xf5, 0x0c, 0xa3, 0xe0, 0xf5, 0x0d, 0x90, 0x60, 0x29, //0x8a60,
+    0xe0, 0xf5, 0x0e, 0xa3, 0xe0, 0xf5, 0x0f, 0x90, 0x60, 0x31, 0xe0, 0xf5, 0x10, 0xa3, 0xe0, 0xf5, //0x8a70,
+    0x11, 0x90, 0x60, 0x39, 0xe0, 0xf5, 0x12, 0xa3, 0xe0, 0xf5, 0x13, 0x30, 0x01, 0x06, 0x30, 0x33, //0x8a80,
+    0x03, 0xd3, 0x80, 0x01, 0xc3, 0x92, 0x09, 0x30, 0x02, 0x06, 0x30, 0x33, 0x03, 0xd3, 0x80, 0x01, //0x8a90,
+    0xc3, 0x92, 0x0a, 0x30, 0x33, 0x0c, 0x30, 0x03, 0x09, 0x20, 0x02, 0x06, 0x20, 0x01, 0x03, 0xd3, //0x8aa0,
+    0x80, 0x01, 0xc3, 0x92, 0x0b, 0x90, 0x30, 0x01, 0xe0, 0x44, 0x40, 0xf0, 0xe0, 0x54, 0xbf, 0xf0, //0x8ab0,
+    0xe5, 0x32, 0x30, 0xe1, 0x14, 0x30, 0x34, 0x11, 0x90, 0x30, 0x22, 0xe0, 0xf5, 0x08, 0xe4, 0xf0, //0x8ac0,
+    0x30, 0x00, 0x03, 0xd3, 0x80, 0x01, 0xc3, 0x92, 0x08, 0xe5, 0x32, 0x30, 0xe5, 0x12, 0x90, 0x56, //0x8ad0,
+    0xa1, 0xe0, 0xf5, 0x09, 0x30, 0x31, 0x09, 0x30, 0x05, 0x03, 0xd3, 0x80, 0x01, 0xc3, 0x92, 0x0d, //0x8ae0,
+    0x90, 0x3f, 0x0c, 0xe5, 0x32, 0xf0, 0xd0, 0xd0, 0xd0, 0x82, 0xd0, 0x83, 0xd0, 0xe0, 0x32, 0x90, //0x8af0,
+    0x0e, 0x7e, 0xe4, 0x93, 0xfe, 0x74, 0x01, 0x93, 0xff, 0xc3, 0x90, 0x0e, 0x7c, 0x74, 0x01, 0x93, //0x8b00,
+    0x9f, 0xff, 0xe4, 0x93, 0x9e, 0xfe, 0xe4, 0x8f, 0x3b, 0x8e, 0x3a, 0xf5, 0x39, 0xf5, 0x38, 0xab, //0x8b10,
+    0x3b, 0xaa, 0x3a, 0xa9, 0x39, 0xa8, 0x38, 0xaf, 0x4b, 0xfc, 0xfd, 0xfe, 0x12, 0x05, 0x28, 0x12, //0x8b20,
+    0x0d, 0xe1, 0xe4, 0x7b, 0xff, 0xfa, 0xf9, 0xf8, 0x12, 0x05, 0xb3, 0x12, 0x0d, 0xe1, 0x90, 0x0e, //0x8b30,
+    0x69, 0xe4, 0x12, 0x0d, 0xf6, 0x12, 0x0d, 0xe1, 0xe4, 0x85, 0x4a, 0x37, 0xf5, 0x36, 0xf5, 0x35, //0x8b40,
+    0xf5, 0x34, 0xaf, 0x37, 0xae, 0x36, 0xad, 0x35, 0xac, 0x34, 0xa3, 0x12, 0x0d, 0xf6, 0x8f, 0x37, //0x8b50,
+    0x8e, 0x36, 0x8d, 0x35, 0x8c, 0x34, 0xe5, 0x3b, 0x45, 0x37, 0xf5, 0x3b, 0xe5, 0x3a, 0x45, 0x36, //0x8b60,
+    0xf5, 0x3a, 0xe5, 0x39, 0x45, 0x35, 0xf5, 0x39, 0xe5, 0x38, 0x45, 0x34, 0xf5, 0x38, 0xe4, 0xf5, //0x8b70,
+    0x22, 0xf5, 0x23, 0x85, 0x3b, 0x31, 0x85, 0x3a, 0x30, 0x85, 0x39, 0x2f, 0x85, 0x38, 0x2e, 0x02, //0x8b80,
+    0x0f, 0x46, 0xe0, 0xa3, 0xe0, 0x75, 0xf0, 0x02, 0xa4, 0xff, 0xae, 0xf0, 0xc3, 0x08, 0xe6, 0x9f, //0x8b90,
+    0xf6, 0x18, 0xe6, 0x9e, 0xf6, 0x22, 0xff, 0xe5, 0xf0, 0x34, 0x60, 0x8f, 0x82, 0xf5, 0x83, 0xec, //0x8ba0,
+    0xf0, 0x22, 0x78, 0x52, 0x7e, 0x00, 0xe6, 0xfc, 0x08, 0xe6, 0xfd, 0x02, 0x04, 0xc1, 0xe4, 0xfc, //0x8bb0,
+    0xfd, 0x12, 0x06, 0x99, 0x78, 0x5c, 0xe6, 0xc3, 0x13, 0xfe, 0x08, 0xe6, 0x13, 0x22, 0x78, 0x52, //0x8bc0,
+    0xe6, 0xfe, 0x08, 0xe6, 0xff, 0xe4, 0xfc, 0xfd, 0x22, 0xe7, 0xc4, 0xf8, 0x54, 0xf0, 0xc8, 0x68, //0x8bd0,
+    0xf7, 0x09, 0xe7, 0xc4, 0x54, 0x0f, 0x48, 0xf7, 0x22, 0xe6, 0xfc, 0xed, 0x75, 0xf0, 0x04, 0xa4, //0x8be0,
+    0x22, 0x12, 0x06, 0x7c, 0x8f, 0x48, 0x8e, 0x47, 0x8d, 0x46, 0x8c, 0x45, 0x22, 0xe0, 0xfe, 0xa3, //0x8bf0,
+    0xe0, 0xfd, 0xee, 0xf6, 0xed, 0x08, 0xf6, 0x22, 0x13, 0xff, 0xc3, 0xe6, 0x9f, 0xff, 0x18, 0xe6, //0x8c00,
+    0x9e, 0xfe, 0x22, 0xe6, 0xc3, 0x13, 0xf7, 0x08, 0xe6, 0x13, 0x09, 0xf7, 0x22, 0xad, 0x39, 0xac, //0x8c10,
+    0x38, 0xfa, 0xf9, 0xf8, 0x12, 0x05, 0x28, 0x8f, 0x3b, 0x8e, 0x3a, 0x8d, 0x39, 0x8c, 0x38, 0xab, //0x8c20,
+    0x37, 0xaa, 0x36, 0xa9, 0x35, 0xa8, 0x34, 0x22, 0x93, 0xff, 0xe4, 0xfc, 0xfd, 0xfe, 0x12, 0x05, //0x8c30,
+    0x28, 0x8f, 0x37, 0x8e, 0x36, 0x8d, 0x35, 0x8c, 0x34, 0x22, 0x78, 0x84, 0xe6, 0xfe, 0x08, 0xe6, //0x8c40,
+    0xff, 0xe4, 0x8f, 0x37, 0x8e, 0x36, 0xf5, 0x35, 0xf5, 0x34, 0x22, 0x90, 0x0e, 0x8c, 0xe4, 0x93, //0x8c50,
+    0x25, 0xe0, 0x24, 0x0a, 0xf8, 0xe6, 0xfe, 0x08, 0xe6, 0xff, 0x22, 0xe6, 0xfe, 0x08, 0xe6, 0xff, //0x8c60,
+    0xe4, 0x8f, 0x3b, 0x8e, 0x3a, 0xf5, 0x39, 0xf5, 0x38, 0x22, 0x78, 0x4e, 0xe6, 0xfe, 0x08, 0xe6, //0x8c70,
+    0xff, 0x22, 0xef, 0x25, 0xe0, 0x24, 0x4e, 0xf8, 0xe6, 0xfc, 0x08, 0xe6, 0xfd, 0x22, 0x78, 0x89, //0x8c80,
+    0xef, 0x26, 0xf6, 0x18, 0xe4, 0x36, 0xf6, 0x22, 0x75, 0x89, 0x03, 0x75, 0xa8, 0x01, 0x75, 0xb8, //0x8c90,
+    0x04, 0x75, 0x34, 0xff, 0x75, 0x35, 0x0e, 0x75, 0x36, 0x15, 0x75, 0x37, 0x0d, 0x12, 0x0e, 0x9a, //0x8ca0,
+    0x12, 0x00, 0x09, 0x12, 0x0f, 0x16, 0x12, 0x00, 0x06, 0xd2, 0x00, 0xd2, 0x34, 0xd2, 0xaf, 0x75, //0x8cb0,
+    0x34, 0xff, 0x75, 0x35, 0x0e, 0x75, 0x36, 0x49, 0x75, 0x37, 0x03, 0x12, 0x0e, 0x9a, 0x30, 0x08, //0x8cc0,
+    0x09, 0xc2, 0x34, 0x12, 0x08, 0xcb, 0xc2, 0x08, 0xd2, 0x34, 0x30, 0x0b, 0x09, 0xc2, 0x36, 0x12, //0x8cd0,
+    0x02, 0x6c, 0xc2, 0x0b, 0xd2, 0x36, 0x30, 0x09, 0x09, 0xc2, 0x36, 0x12, 0x00, 0x0e, 0xc2, 0x09, //0x8ce0,
+    0xd2, 0x36, 0x30, 0x0e, 0x03, 0x12, 0x06, 0xd7, 0x30, 0x35, 0xd3, 0x90, 0x30, 0x29, 0xe5, 0x1e, //0x8cf0,
+    0xf0, 0xb4, 0x10, 0x05, 0x90, 0x30, 0x23, 0xe4, 0xf0, 0xc2, 0x35, 0x80, 0xc1, 0xe4, 0xf5, 0x4b, //0x8d00,
+    0x90, 0x0e, 0x7a, 0x93, 0xff, 0xe4, 0x8f, 0x37, 0xf5, 0x36, 0xf5, 0x35, 0xf5, 0x34, 0xaf, 0x37, //0x8d10,
+    0xae, 0x36, 0xad, 0x35, 0xac, 0x34, 0x90, 0x0e, 0x6a, 0x12, 0x0d, 0xf6, 0x8f, 0x37, 0x8e, 0x36, //0x8d20,
+    0x8d, 0x35, 0x8c, 0x34, 0x90, 0x0e, 0x72, 0x12, 0x06, 0x7c, 0xef, 0x45, 0x37, 0xf5, 0x37, 0xee, //0x8d30,
+    0x45, 0x36, 0xf5, 0x36, 0xed, 0x45, 0x35, 0xf5, 0x35, 0xec, 0x45, 0x34, 0xf5, 0x34, 0xe4, 0xf5, //0x8d40,
+    0x22, 0xf5, 0x23, 0x85, 0x37, 0x31, 0x85, 0x36, 0x30, 0x85, 0x35, 0x2f, 0x85, 0x34, 0x2e, 0x12, //0x8d50,
+    0x0f, 0x46, 0xe4, 0xf5, 0x22, 0xf5, 0x23, 0x90, 0x0e, 0x72, 0x12, 0x0d, 0xea, 0x12, 0x0f, 0x46, //0x8d60,
+    0xe4, 0xf5, 0x22, 0xf5, 0x23, 0x90, 0x0e, 0x6e, 0x12, 0x0d, 0xea, 0x02, 0x0f, 0x46, 0xe5, 0x40, //0x8d70,
+    0x24, 0xf2, 0xf5, 0x37, 0xe5, 0x3f, 0x34, 0x43, 0xf5, 0x36, 0xe5, 0x3e, 0x34, 0xa2, 0xf5, 0x35, //0x8d80,
+    0xe5, 0x3d, 0x34, 0x28, 0xf5, 0x34, 0xe5, 0x37, 0xff, 0xe4, 0xfe, 0xfd, 0xfc, 0x78, 0x18, 0x12, //0x8d90,
+    0x06, 0x69, 0x8f, 0x40, 0x8e, 0x3f, 0x8d, 0x3e, 0x8c, 0x3d, 0xe5, 0x37, 0x54, 0xa0, 0xff, 0xe5, //0x8da0,
+    0x36, 0xfe, 0xe4, 0xfd, 0xfc, 0x78, 0x07, 0x12, 0x06, 0x56, 0x78, 0x10, 0x12, 0x0f, 0x9a, 0xe4, //0x8db0,
+    0xff, 0xfe, 0xe5, 0x35, 0xfd, 0xe4, 0xfc, 0x78, 0x0e, 0x12, 0x06, 0x56, 0x12, 0x0f, 0x9d, 0xe4, //0x8dc0,
+    0xff, 0xfe, 0xfd, 0xe5, 0x34, 0xfc, 0x78, 0x18, 0x12, 0x06, 0x56, 0x78, 0x08, 0x12, 0x0f, 0x9a, //0x8dd0,
+    0x22, 0x8f, 0x3b, 0x8e, 0x3a, 0x8d, 0x39, 0x8c, 0x38, 0x22, 0x12, 0x06, 0x7c, 0x8f, 0x31, 0x8e, //0x8de0,
+    0x30, 0x8d, 0x2f, 0x8c, 0x2e, 0x22, 0x93, 0xf9, 0xf8, 0x02, 0x06, 0x69, 0x00, 0x00, 0x00, 0x00, //0x8df0,
+    0x12, 0x01, 0x17, 0x08, 0x31, 0x15, 0x53, 0x54, 0x44, 0x20, 0x20, 0x20, 0x20, 0x20, 0x13, 0x01, //0x8e00,
+    0x10, 0x01, 0x56, 0x40, 0x1a, 0x30, 0x29, 0x7e, 0x00, 0x30, 0x04, 0x20, 0xdf, 0x30, 0x05, 0x40, //0x8e10,
+    0xbf, 0x50, 0x03, 0x00, 0xfd, 0x50, 0x27, 0x01, 0xfe, 0x60, 0x00, 0x11, 0x00, 0x3f, 0x05, 0x30, //0x8e20,
+    0x00, 0x3f, 0x06, 0x22, 0x00, 0x3f, 0x01, 0x2a, 0x00, 0x3f, 0x02, 0x00, 0x00, 0x36, 0x06, 0x07, //0x8e30,
+    0x00, 0x3f, 0x0b, 0x0f, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x30, 0x01, 0x40, 0xbf, 0x30, 0x01, 0x00, //0x8e40,
+    0xbf, 0x30, 0x29, 0x70, 0x00, 0x3a, 0x00, 0x00, 0xff, 0x3a, 0x00, 0x00, 0xff, 0x36, 0x03, 0x36, //0x8e50,
+    0x02, 0x41, 0x44, 0x58, 0x20, 0x18, 0x10, 0x0a, 0x04, 0x04, 0x00, 0x03, 0xff, 0x64, 0x00, 0x00, //0x8e60,
+    0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x04, 0x06, 0x06, 0x00, 0x03, 0x51, 0x00, 0x7a, //0x8e70,
+    0x50, 0x3c, 0x28, 0x1e, 0x10, 0x10, 0x50, 0x2d, 0x28, 0x16, 0x10, 0x10, 0x02, 0x00, 0x10, 0x0c, //0x8e80,
+    0x10, 0x04, 0x0c, 0x6e, 0x06, 0x05, 0x00, 0xa5, 0x5a, 0x00, 0xae, 0x35, 0xaf, 0x36, 0xe4, 0xfd, //0x8e90,
+    0xed, 0xc3, 0x95, 0x37, 0x50, 0x33, 0x12, 0x0f, 0xe2, 0xe4, 0x93, 0xf5, 0x38, 0x74, 0x01, 0x93, //0x8ea0,
+    0xf5, 0x39, 0x45, 0x38, 0x60, 0x23, 0x85, 0x39, 0x82, 0x85, 0x38, 0x83, 0xe0, 0xfc, 0x12, 0x0f, //0x8eb0,
+    0xe2, 0x74, 0x03, 0x93, 0x52, 0x04, 0x12, 0x0f, 0xe2, 0x74, 0x02, 0x93, 0x42, 0x04, 0x85, 0x39, //0x8ec0,
+    0x82, 0x85, 0x38, 0x83, 0xec, 0xf0, 0x0d, 0x80, 0xc7, 0x22, 0x78, 0xbe, 0xe6, 0xd3, 0x08, 0xff, //0x8ed0,
+    0xe6, 0x64, 0x80, 0xf8, 0xef, 0x64, 0x80, 0x98, 0x22, 0x93, 0xff, 0x7e, 0x00, 0xe6, 0xfc, 0x08, //0x8ee0,
+    0xe6, 0xfd, 0x12, 0x04, 0xc1, 0x78, 0xc1, 0xe6, 0xfc, 0x08, 0xe6, 0xfd, 0xd3, 0xef, 0x9d, 0xee, //0x8ef0,
+    0x9c, 0x22, 0x78, 0xbd, 0xd3, 0xe6, 0x64, 0x80, 0x94, 0x80, 0x22, 0x25, 0xe0, 0x24, 0x0a, 0xf8, //0x8f00,
+    0xe6, 0xfe, 0x08, 0xe6, 0xff, 0x22, 0xe5, 0x3c, 0xd3, 0x94, 0x00, 0x40, 0x0b, 0x90, 0x0e, 0x88, //0x8f10,
+    0x12, 0x0b, 0xf1, 0x90, 0x0e, 0x86, 0x80, 0x09, 0x90, 0x0e, 0x82, 0x12, 0x0b, 0xf1, 0x90, 0x0e, //0x8f20,
+    0x80, 0xe4, 0x93, 0xf5, 0x44, 0xa3, 0xe4, 0x93, 0xf5, 0x43, 0xd2, 0x06, 0x30, 0x06, 0x03, 0xd3, //0x8f30,
+    0x80, 0x01, 0xc3, 0x92, 0x0e, 0x22, 0xa2, 0xaf, 0x92, 0x32, 0xc2, 0xaf, 0xe5, 0x23, 0x45, 0x22, //0x8f40,
+    0x90, 0x0e, 0x5d, 0x60, 0x0e, 0x12, 0x0f, 0xcb, 0xe0, 0xf5, 0x2c, 0x12, 0x0f, 0xc8, 0xe0, 0xf5, //0x8f50,
+    0x2d, 0x80, 0x0c, 0x12, 0x0f, 0xcb, 0xe5, 0x30, 0xf0, 0x12, 0x0f, 0xc8, 0xe5, 0x31, 0xf0, 0xa2, //0x8f60,
+    0x32, 0x92, 0xaf, 0x22, 0xd2, 0x01, 0xc2, 0x02, 0xe4, 0xf5, 0x1f, 0xf5, 0x1e, 0xd2, 0x35, 0xd2, //0x8f70,
+    0x33, 0xd2, 0x36, 0xd2, 0x01, 0xc2, 0x02, 0xf5, 0x1f, 0xf5, 0x1e, 0xd2, 0x35, 0xd2, 0x33, 0x22, //0x8f80,
+    0xfb, 0xd3, 0xed, 0x9b, 0x74, 0x80, 0xf8, 0x6c, 0x98, 0x22, 0x12, 0x06, 0x69, 0xe5, 0x40, 0x2f, //0x8f90,
+    0xf5, 0x40, 0xe5, 0x3f, 0x3e, 0xf5, 0x3f, 0xe5, 0x3e, 0x3d, 0xf5, 0x3e, 0xe5, 0x3d, 0x3c, 0xf5, //0x8fa0,
+    0x3d, 0x22, 0xc0, 0xe0, 0xc0, 0x83, 0xc0, 0x82, 0x90, 0x3f, 0x0d, 0xe0, 0xf5, 0x33, 0xe5, 0x33, //0x8fb0,
+    0xf0, 0xd0, 0x82, 0xd0, 0x83, 0xd0, 0xe0, 0x32, 0x90, 0x0e, 0x5f, 0xe4, 0x93, 0xfe, 0x74, 0x01, //0x8fc0,
+    0x93, 0xf5, 0x82, 0x8e, 0x83, 0x22, 0x78, 0x7f, 0xe4, 0xf6, 0xd8, 0xfd, 0x75, 0x81, 0xcd, 0x02, //0x8fd0,
+    0x0c, 0x98, 0x8f, 0x82, 0x8e, 0x83, 0x75, 0xf0, 0x04, 0xed, 0x02, 0x06, 0xa5,                   //0x8fe0
+};
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif

+ 15 - 0
bsp/stm32/stm32h743-openmv-h7plus/rtconfig.h

@@ -98,7 +98,10 @@
 #define RT_USING_SERIAL_V1
 #define RT_SERIAL_USING_DMA
 #define RT_SERIAL_RB_BUFSZ 64
+#define RT_USING_I2C
+#define RT_USING_I2C_BITOPS
 #define RT_USING_PIN
+#define RT_USING_RTC
 #define RT_USING_SDIO
 #define RT_SDIO_STACK_SIZE 512
 #define RT_SDIO_THREAD_PRIORITY 15
@@ -236,9 +239,21 @@
 #define BSP_USING_GPIO
 #define BSP_USING_UART
 #define BSP_USING_UART1
+#define BSP_USING_QSPI
 
 /* Onboard Peripheral Drivers */
 
 #define BSP_USING_SDRAM
+#define BSP_USING_QSPI_FLASH
+#define BSP_USING_USBD
+#define BSP_USING_OV5640
+#define BSP_USING_DCMI
+#define BSP_USING_I2C
+#define BSP_USING_I2C1
+
+/* Notice: PB8 --> 24; PB9 --> 25 */
+
+#define BSP_I2C1_SCL_PIN 24
+#define BSP_I2C1_SDA_PIN 25
 
 #endif