+++ /dev/null
-/**\r
- ******************************************************************************\r
- * @file stm32f7xx_hal_dcmi.c\r
- * @author MCD Application Team\r
- * @version V0.3.0\r
- * @date 06-March-2015\r
- * @brief DCMI HAL module driver\r
- * This file provides firmware functions to manage the following \r
- * functionalities of the Digital Camera Interface (DCMI) peripheral:\r
- * + Initialization and de-initialization functions\r
- * + IO operation functions\r
- * + Peripheral Control functions \r
- * + Peripheral State and Error functions \r
- * \r
- @verbatim\r
- ==============================================================================\r
- ##### How to use this driver #####\r
- ==============================================================================\r
- [..]\r
- The sequence below describes how to use this driver to capture image\r
- from a camera module connected to the DCMI Interface.\r
- This sequence does not take into account the configuration of the\r
- camera module, which should be made before to configure and enable\r
- the DCMI to capture images.\r
-\r
- (#) Program the required configuration through following parameters:\r
- horizontal and vertical polarity, pixel clock polarity, Capture Rate,\r
- Synchronization Mode, code of the frame delimiter and data width \r
- using HAL_DCMI_Init() function.\r
-\r
- (#) Configure the DMA2_Stream1 channel1 to transfer Data from DCMI DR\r
- register to the destination memory buffer.\r
-\r
- (#) Program the required configuration through following parameters:\r
- DCMI mode, destination memory Buffer address and the data length \r
- and enable capture using HAL_DCMI_Start_DMA() function.\r
-\r
- (#) Optionally, configure and Enable the CROP feature to select a rectangular\r
- window from the received image using HAL_DCMI_ConfigCrop() \r
- and HAL_DCMI_EnableCROP() functions\r
-\r
- (#) The capture can be stopped using HAL_DCMI_Stop() function.\r
-\r
- (#) To control DCMI state you can use the function HAL_DCMI_GetState().\r
-\r
- *** DCMI HAL driver macros list ***\r
- ============================================= \r
- [..]\r
- Below the list of most used macros in DCMI HAL driver.\r
- \r
- (+) __HAL_DCMI_ENABLE: Enable the DCMI peripheral.\r
- (+) __HAL_DCMI_DISABLE: Disable the DCMI peripheral.\r
- (+) __HAL_DCMI_GET_FLAG: Get the DCMI pending flags.\r
- (+) __HAL_DCMI_CLEAR_FLAG: Clear the DCMI pending flags.\r
- (+) __HAL_DCMI_ENABLE_IT: Enable the specified DCMI interrupts.\r
- (+) __HAL_DCMI_DISABLE_IT: Disable the specified DCMI interrupts.\r
- (+) __HAL_DCMI_GET_IT_SOURCE: Check whether the specified DCMI interrupt has occurred or not.\r
- \r
- [..] \r
- (@) You can refer to the DCMI HAL driver header file for more useful macros\r
- \r
- @endverbatim\r
- ******************************************************************************\r
- * @attention\r
- *\r
- * <h2><center>© COPYRIGHT(c) 2015 STMicroelectronics</center></h2>\r
- *\r
- * Redistribution and use in source and binary forms, with or without modification,\r
- * are permitted provided that the following conditions are met:\r
- * 1. Redistributions of source code must retain the above copyright notice,\r
- * this list of conditions and the following disclaimer.\r
- * 2. Redistributions in binary form must reproduce the above copyright notice,\r
- * this list of conditions and the following disclaimer in the documentation\r
- * and/or other materials provided with the distribution.\r
- * 3. Neither the name of STMicroelectronics nor the names of its contributors\r
- * may be used to endorse or promote products derived from this software\r
- * without specific prior written permission.\r
- *\r
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"\r
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\r
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\r
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE\r
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\r
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR\r
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER\r
- * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,\r
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\r
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
- *\r
- ******************************************************************************\r
- */ \r
-\r
-/* Includes ------------------------------------------------------------------*/\r
-#include "stm32f7xx_hal.h"\r
-\r
-/** @addtogroup STM32F7xx_HAL_Driver\r
- * @{\r
- */\r
-/** @defgroup DCMI DCMI\r
- * @brief DCMI HAL module driver\r
- * @{\r
- */\r
-\r
-#ifdef HAL_DCMI_MODULE_ENABLED\r
-\r
-/* Private typedef -----------------------------------------------------------*/\r
-/* Private define ------------------------------------------------------------*/\r
-#define HAL_TIMEOUT_DCMI_STOP ((uint32_t)1000) /* 1s */\r
-/* Private macro -------------------------------------------------------------*/\r
-/* Private variables ---------------------------------------------------------*/\r
-/* Private function prototypes -----------------------------------------------*/\r
-static void DCMI_DMAConvCplt(DMA_HandleTypeDef *hdma);\r
-static void DCMI_DMAError(DMA_HandleTypeDef *hdma);\r
-\r
-/* Exported functions --------------------------------------------------------*/\r
-\r
-/** @defgroup DCMI_Exported_Functions DCMI Exported Functions\r
- * @{\r
- */\r
-\r
-/** @defgroup DCMI_Exported_Functions_Group1 Initialization and Configuration functions\r
- * @brief Initialization and Configuration functions\r
- *\r
-@verbatim \r
- ===============================================================================\r
- ##### Initialization and Configuration functions #####\r
- =============================================================================== \r
- [..] This section provides functions allowing to:\r
- (+) Initialize and configure the DCMI\r
- (+) De-initialize the DCMI \r
-\r
-@endverbatim\r
- * @{\r
- */\r
- \r
-/**\r
- * @brief Initializes the DCMI according to the specified\r
- * parameters in the DCMI_InitTypeDef and create the associated handle.\r
- * @param hdcmi: pointer to a DCMI_HandleTypeDef structure that contains\r
- * the configuration information for DCMI.\r
- * @retval HAL status\r
- */\r
-__weak HAL_StatusTypeDef HAL_DCMI_Init(DCMI_HandleTypeDef *hdcmi)\r
-{ \r
- /* Check the DCMI peripheral state */\r
- if(hdcmi == NULL)\r
- {\r
- return HAL_ERROR;\r
- }\r
- \r
- /* Check function parameters */\r
- assert_param(IS_DCMI_ALL_INSTANCE(hdcmi->Instance));\r
- assert_param(IS_DCMI_SYNCHRO(hdcmi->Init.SynchroMode)); \r
- assert_param(IS_DCMI_PCKPOLARITY(hdcmi->Init.PCKPolarity));\r
- assert_param(IS_DCMI_VSPOLARITY(hdcmi->Init.VSPolarity));\r
- assert_param(IS_DCMI_HSPOLARITY(hdcmi->Init.HSPolarity));\r
- assert_param(IS_DCMI_CAPTURE_RATE(hdcmi->Init.CaptureRate));\r
- assert_param(IS_DCMI_EXTENDED_DATA(hdcmi->Init.ExtendedDataMode));\r
- assert_param(IS_DCMI_MODE_JPEG(hdcmi->Init.JPEGMode));\r
-\r
- if(hdcmi->State == HAL_DCMI_STATE_RESET)\r
- {\r
- /* Init the low level hardware */\r
- HAL_DCMI_MspInit(hdcmi);\r
- } \r
- \r
- /* Change the DCMI state */\r
- hdcmi->State = HAL_DCMI_STATE_BUSY; \r
-\r
- /* Set DCMI parameters */\r
- /* Configures the HS, VS, DE and PC polarity */\r
- hdcmi->Instance->CR &= ~(DCMI_CR_PCKPOL | DCMI_CR_HSPOL | DCMI_CR_VSPOL | DCMI_CR_EDM_0 |\r
- DCMI_CR_EDM_1 | DCMI_CR_FCRC_0 | DCMI_CR_FCRC_1 | DCMI_CR_JPEG |\r
- DCMI_CR_ESS);\r
- hdcmi->Instance->CR |= (uint32_t)(hdcmi->Init.SynchroMode | hdcmi->Init.CaptureRate | \\r
- hdcmi->Init.VSPolarity | hdcmi->Init.HSPolarity | \\r
- hdcmi->Init.PCKPolarity | hdcmi->Init.ExtendedDataMode | \\r
- hdcmi->Init.JPEGMode);\r
-\r
- if(hdcmi->Init.SynchroMode == DCMI_SYNCHRO_EMBEDDED)\r
- {\r
- DCMI->ESCR = (((uint32_t)hdcmi->Init.SyncroCode.FrameStartCode) |\r
- ((uint32_t)hdcmi->Init.SyncroCode.LineStartCode << 8)|\r
- ((uint32_t)hdcmi->Init.SyncroCode.LineEndCode << 16) |\r
- ((uint32_t)hdcmi->Init.SyncroCode.FrameEndCode << 24));\r
- }\r
-\r
- /* Enable the Line interrupt */\r
- __HAL_DCMI_ENABLE_IT(hdcmi, DCMI_IT_LINE);\r
-\r
- /* Enable the VSYNC interrupt */\r
- __HAL_DCMI_ENABLE_IT(hdcmi, DCMI_IT_VSYNC);\r
-\r
- /* Enable the Frame capture complete interrupt */\r
- __HAL_DCMI_ENABLE_IT(hdcmi, DCMI_IT_FRAME);\r
-\r
- /* Enable the Synchronization error interrupt */\r
- __HAL_DCMI_ENABLE_IT(hdcmi, DCMI_IT_ERR);\r
-\r
- /* Enable the Overflow interrupt */\r
- __HAL_DCMI_ENABLE_IT(hdcmi, DCMI_IT_OVF);\r
-\r
- /* Enable DCMI by setting DCMIEN bit */\r
- __HAL_DCMI_ENABLE(hdcmi);\r
-\r
- /* Update error code */\r
- hdcmi->ErrorCode = HAL_DCMI_ERROR_NONE;\r
- \r
- /* Initialize the DCMI state*/\r
- hdcmi->State = HAL_DCMI_STATE_READY;\r
-\r
- return HAL_OK;\r
-}\r
-\r
-/**\r
- * @brief Deinitializes the DCMI peripheral registers to their default reset\r
- * values.\r
- * @param hdcmi: pointer to a DCMI_HandleTypeDef structure that contains\r
- * the configuration information for DCMI.\r
- * @retval HAL status\r
- */\r
-\r
-HAL_StatusTypeDef HAL_DCMI_DeInit(DCMI_HandleTypeDef *hdcmi)\r
-{\r
- /* DeInit the low level hardware */\r
- HAL_DCMI_MspDeInit(hdcmi);\r
-\r
- /* Update error code */\r
- hdcmi->ErrorCode = HAL_DCMI_ERROR_NONE;\r
-\r
- /* Initialize the DCMI state*/\r
- hdcmi->State = HAL_DCMI_STATE_RESET;\r
-\r
- /* Release Lock */\r
- __HAL_UNLOCK(hdcmi);\r
-\r
- return HAL_OK;\r
-}\r
-\r
-/**\r
- * @brief Initializes the DCMI MSP.\r
- * @param hdcmi: pointer to a DCMI_HandleTypeDef structure that contains\r
- * the configuration information for DCMI.\r
- * @retval None\r
- */\r
-__weak void HAL_DCMI_MspInit(DCMI_HandleTypeDef* hdcmi)\r
-{\r
- /* NOTE : This function Should not be modified, when the callback is needed,\r
- the HAL_DCMI_MspInit could be implemented in the user file\r
- */ \r
-}\r
-\r
-/**\r
- * @brief DeInitializes the DCMI MSP.\r
- * @param hdcmi: pointer to a DCMI_HandleTypeDef structure that contains\r
- * the configuration information for DCMI.\r
- * @retval None\r
- */\r
-__weak void HAL_DCMI_MspDeInit(DCMI_HandleTypeDef* hdcmi)\r
-{\r
- /* NOTE : This function Should not be modified, when the callback is needed,\r
- the HAL_DCMI_MspDeInit could be implemented in the user file\r
- */\r
-}\r
-\r
-/**\r
- * @}\r
- */\r
-/** @defgroup DCMI_Exported_Functions_Group2 IO operation functions \r
- * @brief IO operation functions \r
- *\r
-@verbatim \r
- ===============================================================================\r
- ##### IO operation functions #####\r
- =============================================================================== \r
- [..] This section provides functions allowing to:\r
- (+) Configure destination address and data length and \r
- Enables DCMI DMA request and enables DCMI capture\r
- (+) Stop the DCMI capture.\r
- (+) Handles DCMI interrupt request.\r
-\r
-@endverbatim\r
- * @{\r
- */\r
-\r
-/**\r
- * @brief Enables DCMI DMA request and enables DCMI capture \r
- * @param hdcmi: pointer to a DCMI_HandleTypeDef structure that contains\r
- * the configuration information for DCMI.\r
- * @param DCMI_Mode: DCMI capture mode snapshot or continuous grab.\r
- * @param pData: The destination memory Buffer address (LCD Frame buffer).\r
- * @param Length: The length of capture to be transferred.\r
- * @retval HAL status\r
- */\r
-HAL_StatusTypeDef HAL_DCMI_Start_DMA(DCMI_HandleTypeDef* hdcmi, uint32_t DCMI_Mode, uint32_t pData, uint32_t Length)\r
-{ \r
- /* Initialize the second memory address */\r
- uint32_t SecondMemAddress = 0;\r
-\r
- /* Check function parameters */\r
- assert_param(IS_DCMI_CAPTURE_MODE(DCMI_Mode));\r
-\r
- /* Process Locked */\r
- __HAL_LOCK(hdcmi);\r
-\r
- /* Lock the DCMI peripheral state */\r
- hdcmi->State = HAL_DCMI_STATE_BUSY;\r
-\r
- /* Check the parameters */\r
- assert_param(IS_DCMI_CAPTURE_MODE(DCMI_Mode));\r
-\r
- /* Configure the DCMI Mode */\r
- hdcmi->Instance->CR &= ~(DCMI_CR_CM);\r
- hdcmi->Instance->CR |= (uint32_t)(DCMI_Mode);\r
-\r
- /* Set the DMA memory0 conversion complete callback */\r
- hdcmi->DMA_Handle->XferCpltCallback = DCMI_DMAConvCplt;\r
-\r
- /* Set the DMA error callback */\r
- hdcmi->DMA_Handle->XferErrorCallback = DCMI_DMAError;\r
-\r
- if(Length <= 0xFFFF)\r
- {\r
- /* Enable the DMA Stream */\r
- HAL_DMA_Start_IT(hdcmi->DMA_Handle, (uint32_t)&hdcmi->Instance->DR, (uint32_t)pData, Length);\r
- }\r
- else /* DCMI_DOUBLE_BUFFER Mode */\r
- {\r
- /* Set the DMA memory1 conversion complete callback */\r
- hdcmi->DMA_Handle->XferM1CpltCallback = DCMI_DMAConvCplt; \r
-\r
- /* Initialize transfer parameters */\r
- hdcmi->XferCount = 1;\r
- hdcmi->XferSize = Length;\r
- hdcmi->pBuffPtr = pData;\r
- \r
- /* Get the number of buffer */\r
- while(hdcmi->XferSize > 0xFFFF)\r
- {\r
- hdcmi->XferSize = (hdcmi->XferSize/2);\r
- hdcmi->XferCount = hdcmi->XferCount*2;\r
- }\r
-\r
- /* Update DCMI counter and transfer number*/\r
- hdcmi->XferCount = (hdcmi->XferCount - 2);\r
- hdcmi->XferTransferNumber = hdcmi->XferCount;\r
-\r
- /* Update second memory address */\r
- SecondMemAddress = (uint32_t)(pData + (4*hdcmi->XferSize));\r
-\r
- /* Start DMA multi buffer transfer */\r
- HAL_DMAEx_MultiBufferStart_IT(hdcmi->DMA_Handle, (uint32_t)&hdcmi->Instance->DR, (uint32_t)pData, SecondMemAddress, hdcmi->XferSize);\r
- }\r
-\r
- /* Enable Capture */\r
- DCMI->CR |= DCMI_CR_CAPTURE;\r
-\r
- /* Return function status */\r
- return HAL_OK;\r
-}\r
-\r
-/**\r
- * @brief Disable DCMI DMA request and Disable DCMI capture \r
- * @param hdcmi: pointer to a DCMI_HandleTypeDef structure that contains\r
- * the configuration information for DCMI. \r
- * @retval HAL status \r
- */\r
-HAL_StatusTypeDef HAL_DCMI_Stop(DCMI_HandleTypeDef* hdcmi)\r
-{\r
- uint32_t tickstart = 0;\r
-\r
- /* Lock the DCMI peripheral state */\r
- hdcmi->State = HAL_DCMI_STATE_BUSY;\r
-\r
- __HAL_DCMI_DISABLE(hdcmi);\r
-\r
- /* Disable Capture */\r
- DCMI->CR &= ~(DCMI_CR_CAPTURE);\r
-\r
- /* Get tick */\r
- tickstart = HAL_GetTick();\r
-\r
- /* Check if the DCMI capture effectively disabled */\r
- while((hdcmi->Instance->CR & DCMI_CR_CAPTURE) != 0)\r
- {\r
- if((HAL_GetTick() - tickstart ) > HAL_TIMEOUT_DCMI_STOP)\r
- {\r
- /* Process Unlocked */\r
- __HAL_UNLOCK(hdcmi);\r
- \r
- /* Update error code */\r
- hdcmi->ErrorCode |= HAL_DCMI_ERROR_TIMEOUT;\r
- \r
- /* Change DCMI state */\r
- hdcmi->State = HAL_DCMI_STATE_TIMEOUT;\r
- \r
- return HAL_TIMEOUT;\r
- }\r
- }\r
-\r
- /* Disable the DMA */\r
- HAL_DMA_Abort(hdcmi->DMA_Handle);\r
-\r
- /* Update error code */\r
- hdcmi->ErrorCode |= HAL_DCMI_ERROR_NONE;\r
-\r
- /* Change DCMI state */\r
- hdcmi->State = HAL_DCMI_STATE_READY;\r
-\r
- /* Process Unlocked */\r
- __HAL_UNLOCK(hdcmi);\r
-\r
- /* Return function status */\r
- return HAL_OK;\r
-}\r
-\r
-/**\r
- * @brief Handles DCMI interrupt request.\r
- * @param hdcmi: pointer to a DCMI_HandleTypeDef structure that contains\r
- * the configuration information for the DCMI.\r
- * @retval None\r
- */\r
-void HAL_DCMI_IRQHandler(DCMI_HandleTypeDef *hdcmi)\r
-{ \r
- /* Synchronization error interrupt management *******************************/\r
- if(__HAL_DCMI_GET_FLAG(hdcmi, DCMI_FLAG_ERRRI) != RESET)\r
- {\r
- if(__HAL_DCMI_GET_IT_SOURCE(hdcmi, DCMI_IT_ERR) != RESET)\r
- {\r
- /* Disable the Synchronization error interrupt */\r
- __HAL_DCMI_DISABLE_IT(hdcmi, DCMI_IT_ERR); \r
-\r
- /* Clear the Synchronization error flag */\r
- __HAL_DCMI_CLEAR_FLAG(hdcmi, DCMI_FLAG_ERRRI);\r
-\r
- /* Update error code */\r
- hdcmi->ErrorCode |= HAL_DCMI_ERROR_SYNC;\r
-\r
- /* Change DCMI state */\r
- hdcmi->State = HAL_DCMI_STATE_ERROR;\r
-\r
- /* Process Unlocked */\r
- __HAL_UNLOCK(hdcmi);\r
-\r
- /* Abort the DMA Transfer */\r
- HAL_DMA_Abort(hdcmi->DMA_Handle);\r
- \r
- /* Synchronization error Callback */\r
- HAL_DCMI_ErrorCallback(hdcmi);\r
- }\r
- }\r
- /* Overflow interrupt management ********************************************/\r
- if(__HAL_DCMI_GET_FLAG(hdcmi, DCMI_FLAG_OVFRI) != RESET) \r
- {\r
- if(__HAL_DCMI_GET_IT_SOURCE(hdcmi, DCMI_IT_OVF) != RESET)\r
- {\r
- /* Disable the Overflow interrupt */\r
- __HAL_DCMI_DISABLE_IT(hdcmi, DCMI_IT_OVF);\r
-\r
- /* Clear the Overflow flag */\r
- __HAL_DCMI_CLEAR_FLAG(hdcmi, DCMI_FLAG_OVFRI);\r
-\r
- /* Update error code */\r
- hdcmi->ErrorCode |= HAL_DCMI_ERROR_OVF;\r
-\r
- /* Change DCMI state */\r
- hdcmi->State = HAL_DCMI_STATE_ERROR;\r
-\r
- /* Process Unlocked */\r
- __HAL_UNLOCK(hdcmi);\r
-\r
- /* Abort the DMA Transfer */\r
- HAL_DMA_Abort(hdcmi->DMA_Handle);\r
-\r
- /* Overflow Callback */\r
- HAL_DCMI_ErrorCallback(hdcmi);\r
- }\r
- }\r
- /* Line Interrupt management ************************************************/\r
- if(__HAL_DCMI_GET_FLAG(hdcmi, DCMI_FLAG_LINERI) != RESET)\r
- {\r
- if(__HAL_DCMI_GET_IT_SOURCE(hdcmi, DCMI_IT_LINE) != RESET)\r
- {\r
- /* Clear the Line interrupt flag */ \r
- __HAL_DCMI_CLEAR_FLAG(hdcmi, DCMI_FLAG_LINERI);\r
-\r
- /* Process Unlocked */\r
- __HAL_UNLOCK(hdcmi);\r
-\r
- /* Line interrupt Callback */\r
- HAL_DCMI_LineEventCallback(hdcmi);\r
- }\r
- }\r
- /* VSYNC interrupt management ***********************************************/\r
- if(__HAL_DCMI_GET_FLAG(hdcmi, DCMI_FLAG_VSYNCRI) != RESET)\r
- {\r
- if(__HAL_DCMI_GET_IT_SOURCE(hdcmi, DCMI_IT_VSYNC) != RESET)\r
- {\r
- /* Disable the VSYNC interrupt */\r
- __HAL_DCMI_DISABLE_IT(hdcmi, DCMI_IT_VSYNC); \r
-\r
- /* Clear the VSYNC flag */\r
- __HAL_DCMI_CLEAR_FLAG(hdcmi, DCMI_FLAG_VSYNCRI);\r
-\r
- /* Process Unlocked */\r
- __HAL_UNLOCK(hdcmi);\r
-\r
- /* VSYNC Callback */\r
- HAL_DCMI_VsyncEventCallback(hdcmi);\r
- }\r
- }\r
- /* End of Frame interrupt management ****************************************/\r
- if(__HAL_DCMI_GET_FLAG(hdcmi, DCMI_FLAG_FRAMERI) != RESET)\r
- {\r
- if(__HAL_DCMI_GET_IT_SOURCE(hdcmi, DCMI_IT_FRAME) != RESET)\r
- {\r
- /* Disable the End of Frame interrupt */\r
- __HAL_DCMI_DISABLE_IT(hdcmi, DCMI_IT_FRAME);\r
-\r
- /* Clear the End of Frame flag */\r
- __HAL_DCMI_CLEAR_FLAG(hdcmi, DCMI_FLAG_FRAMERI);\r
-\r
- /* Process Unlocked */\r
- __HAL_UNLOCK(hdcmi);\r
-\r
- /* End of Frame Callback */\r
- HAL_DCMI_FrameEventCallback(hdcmi);\r
- }\r
- }\r
-}\r
-\r
-/**\r
- * @brief Error DCMI callback.\r
- * @param hdcmi: pointer to a DCMI_HandleTypeDef structure that contains\r
- * the configuration information for DCMI.\r
- * @retval None\r
- */\r
-__weak void HAL_DCMI_ErrorCallback(DCMI_HandleTypeDef *hdcmi)\r
-{\r
- /* NOTE : This function Should not be modified, when the callback is needed,\r
- the HAL_DCMI_ErrorCallback could be implemented in the user file\r
- */\r
-}\r
-\r
-/**\r
- * @brief Line Event callback.\r
- * @param hdcmi: pointer to a DCMI_HandleTypeDef structure that contains\r
- * the configuration information for DCMI.\r
- * @retval None\r
- */\r
-__weak void HAL_DCMI_LineEventCallback(DCMI_HandleTypeDef *hdcmi)\r
-{\r
- /* NOTE : This function Should not be modified, when the callback is needed,\r
- the HAL_DCMI_LineEventCallback could be implemented in the user file\r
- */\r
-}\r
-\r
-/**\r
- * @brief VSYNC Event callback.\r
- * @param hdcmi: pointer to a DCMI_HandleTypeDef structure that contains\r
- * the configuration information for DCMI.\r
- * @retval None\r
- */\r
-__weak void HAL_DCMI_VsyncEventCallback(DCMI_HandleTypeDef *hdcmi)\r
-{\r
- /* NOTE : This function Should not be modified, when the callback is needed,\r
- the HAL_DCMI_VsyncEventCallback could be implemented in the user file\r
- */\r
-}\r
-\r
-/**\r
- * @brief Frame Event callback.\r
- * @param hdcmi: pointer to a DCMI_HandleTypeDef structure that contains\r
- * the configuration information for DCMI.\r
- * @retval None\r
- */\r
-__weak void HAL_DCMI_FrameEventCallback(DCMI_HandleTypeDef *hdcmi)\r
-{\r
- /* NOTE : This function Should not be modified, when the callback is needed,\r
- the HAL_DCMI_FrameEventCallback could be implemented in the user file\r
- */\r
-}\r
-\r
-/**\r
- * @}\r
- */\r
-\r
-/** @defgroup DCMI_Exported_Functions_Group3 Peripheral Control functions\r
- * @brief Peripheral Control functions \r
- *\r
-@verbatim \r
- ===============================================================================\r
- ##### Peripheral Control functions #####\r
- =============================================================================== \r
-[..] This section provides functions allowing to:\r
- (+) Configure the CROP feature.\r
- (+) Enable/Disable the CROP feature.\r
- (+) Enable/Disable the JPEG feature.\r
-\r
-@endverbatim\r
- * @{\r
- */\r
-\r
-/**\r
- * @brief Configure the DCMI CROP coordinate.\r
- * @param hdcmi: pointer to a DCMI_HandleTypeDef structure that contains\r
- * the configuration information for DCMI.\r
- * @param YSize: DCMI Line number\r
- * @param XSize: DCMI Pixel per line\r
- * @param X0: DCMI window X offset\r
- * @param Y0: DCMI window Y offset\r
- * @retval HAL status\r
- */\r
-HAL_StatusTypeDef HAL_DCMI_ConfigCROP(DCMI_HandleTypeDef *hdcmi, uint32_t X0, uint32_t Y0, uint32_t XSize, uint32_t YSize)\r
-{\r
- /* Process Locked */\r
- __HAL_LOCK(hdcmi);\r
-\r
- /* Lock the DCMI peripheral state */\r
- hdcmi->State = HAL_DCMI_STATE_BUSY;\r
-\r
- /* Check the parameters */\r
- assert_param(IS_DCMI_WINDOW_COORDINATE(X0));\r
- assert_param(IS_DCMI_WINDOW_HEIGHT(Y0));\r
- assert_param(IS_DCMI_WINDOW_COORDINATE(XSize));\r
- assert_param(IS_DCMI_WINDOW_COORDINATE(YSize));\r
- \r
- /* Configure CROP */\r
- DCMI->CWSIZER = (XSize | (YSize << 16));\r
- DCMI->CWSTRTR = (X0 | (Y0 << 16));\r
-\r
- /* Initialize the DCMI state*/\r
- hdcmi->State = HAL_DCMI_STATE_READY;\r
-\r
- /* Process Unlocked */\r
- __HAL_UNLOCK(hdcmi);\r
-\r
- return HAL_OK;\r
-}\r
-\r
-/**\r
- * @brief Disable the Crop feature.\r
- * @param hdcmi: pointer to a DCMI_HandleTypeDef structure that contains\r
- * the configuration information for DCMI.\r
- * @retval HAL status\r
- */\r
-HAL_StatusTypeDef HAL_DCMI_DisableCROP(DCMI_HandleTypeDef *hdcmi)\r
-{\r
- /* Process Locked */\r
- __HAL_LOCK(hdcmi);\r
-\r
- /* Lock the DCMI peripheral state */\r
- hdcmi->State = HAL_DCMI_STATE_BUSY;\r
-\r
- /* Disable DCMI Crop feature */\r
- DCMI->CR &= ~(uint32_t)DCMI_CR_CROP; \r
-\r
- /* Change the DCMI state*/\r
- hdcmi->State = HAL_DCMI_STATE_READY; \r
-\r
- /* Process Unlocked */\r
- __HAL_UNLOCK(hdcmi);\r
-\r
- return HAL_OK; \r
-}\r
-\r
-/**\r
- * @brief Enable the Crop feature.\r
- * @param hdcmi: pointer to a DCMI_HandleTypeDef structure that contains\r
- * the configuration information for DCMI.\r
- * @retval HAL status\r
- */\r
-HAL_StatusTypeDef HAL_DCMI_EnableCROP(DCMI_HandleTypeDef *hdcmi)\r
-{\r
- /* Process Locked */\r
- __HAL_LOCK(hdcmi);\r
-\r
- /* Lock the DCMI peripheral state */\r
- hdcmi->State = HAL_DCMI_STATE_BUSY;\r
-\r
- /* Enable DCMI Crop feature */\r
- DCMI->CR |= (uint32_t)DCMI_CR_CROP;\r
-\r
- /* Change the DCMI state*/\r
- hdcmi->State = HAL_DCMI_STATE_READY;\r
-\r
- /* Process Unlocked */\r
- __HAL_UNLOCK(hdcmi);\r
-\r
- return HAL_OK; \r
-}\r
-\r
-/**\r
- * @}\r
- */\r
-\r
-/** @defgroup DCMI_Exported_Functions_Group4 Peripheral State functions\r
- * @brief Peripheral State functions \r
- *\r
-@verbatim \r
- ===============================================================================\r
- ##### Peripheral State and Errors functions #####\r
- =============================================================================== \r
- [..]\r
- This subsection provides functions allowing to\r
- (+) Check the DCMI state.\r
- (+) Get the specific DCMI error flag. \r
-\r
-@endverbatim\r
- * @{\r
- */ \r
-\r
-/**\r
- * @brief Return the DCMI state\r
- * @param hdcmi: pointer to a DCMI_HandleTypeDef structure that contains\r
- * the configuration information for DCMI.\r
- * @retval HAL state\r
- */\r
-HAL_DCMI_StateTypeDef HAL_DCMI_GetState(DCMI_HandleTypeDef *hdcmi) \r
-{\r
- return hdcmi->State;\r
-}\r
-\r
-/**\r
-* @brief Return the DCMI error code\r
-* @param hdcmi : pointer to a DCMI_HandleTypeDef structure that contains\r
- * the configuration information for DCMI.\r
-* @retval DCMI Error Code\r
-*/\r
-uint32_t HAL_DCMI_GetError(DCMI_HandleTypeDef *hdcmi)\r
-{\r
- return hdcmi->ErrorCode;\r
-}\r
-\r
-/**\r
- * @}\r
- */\r
-/* Private functions ---------------------------------------------------------*/\r
-/** @defgroup DCMI_Private_Functions DCMI Private Functions\r
- * @{\r
- */\r
- /**\r
- * @brief DMA conversion complete callback. \r
- * @param hdma: pointer to a DMA_HandleTypeDef structure that contains\r
- * the configuration information for the specified DMA module.\r
- * @retval None\r
- */\r
-static void DCMI_DMAConvCplt(DMA_HandleTypeDef *hdma)\r
-{\r
- uint32_t tmp = 0;\r
- \r
- DCMI_HandleTypeDef* hdcmi = ( DCMI_HandleTypeDef* )((DMA_HandleTypeDef* )hdma)->Parent;\r
- hdcmi->State= HAL_DCMI_STATE_READY;\r
-\r
- if(hdcmi->XferCount != 0)\r
- {\r
- /* Update memory 0 address location */\r
- tmp = ((hdcmi->DMA_Handle->Instance->CR) & DMA_SxCR_CT);\r
- if(((hdcmi->XferCount % 2) == 0) && (tmp != 0))\r
- {\r
- tmp = hdcmi->DMA_Handle->Instance->M0AR;\r
- HAL_DMAEx_ChangeMemory(hdcmi->DMA_Handle, (tmp + (8*hdcmi->XferSize)), MEMORY0);\r
- hdcmi->XferCount--;\r
- }\r
- /* Update memory 1 address location */\r
- else if((hdcmi->DMA_Handle->Instance->CR & DMA_SxCR_CT) == 0)\r
- {\r
- tmp = hdcmi->DMA_Handle->Instance->M1AR;\r
- HAL_DMAEx_ChangeMemory(hdcmi->DMA_Handle, (tmp + (8*hdcmi->XferSize)), MEMORY1);\r
- hdcmi->XferCount--;\r
- }\r
- }\r
- /* Update memory 0 address location */\r
- else if((hdcmi->DMA_Handle->Instance->CR & DMA_SxCR_CT) != 0)\r
- {\r
- hdcmi->DMA_Handle->Instance->M0AR = hdcmi->pBuffPtr;\r
- }\r
- /* Update memory 1 address location */\r
- else if((hdcmi->DMA_Handle->Instance->CR & DMA_SxCR_CT) == 0)\r
- {\r
- tmp = hdcmi->pBuffPtr;\r
- hdcmi->DMA_Handle->Instance->M1AR = (tmp + (4*hdcmi->XferSize));\r
- hdcmi->XferCount = hdcmi->XferTransferNumber;\r
- }\r
-\r
- if(__HAL_DCMI_GET_FLAG(hdcmi, DCMI_FLAG_FRAMERI) != RESET)\r
- {\r
- /* Process Unlocked */\r
- __HAL_UNLOCK(hdcmi);\r
-\r
- /* FRAME Callback */\r
- HAL_DCMI_FrameEventCallback(hdcmi);\r
- }\r
-}\r
-\r
-/**\r
- * @brief DMA error callback \r
- * @param hdma: pointer to a DMA_HandleTypeDef structure that contains\r
- * the configuration information for the specified DMA module.\r
- * @retval None\r
- */\r
-static void DCMI_DMAError(DMA_HandleTypeDef *hdma)\r
-{\r
- DCMI_HandleTypeDef* hdcmi = ( DCMI_HandleTypeDef* )((DMA_HandleTypeDef* )hdma)->Parent; \r
- hdcmi->State= HAL_DCMI_STATE_READY;\r
- HAL_DCMI_ErrorCallback(hdcmi);\r
-}\r
-\r
-/**\r
- * @}\r
- */\r
- \r
-/**\r
- * @}\r
- */\r
-#endif /* HAL_DCMI_MODULE_ENABLED */\r
-/**\r
- * @}\r
- */\r
-\r
-/**\r
- * @}\r
- */\r
-\r
-/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/\r