STM32F439xx HAL User Manual
stm32f4xx_hal_dcmi_ex.c
Go to the documentation of this file.
00001 /**
00002   ******************************************************************************
00003   * @file    stm32f4xx_hal_dcmi_ex.c
00004   * @author  MCD Application Team
00005   * @brief   DCMI Extension HAL module driver
00006   *          This file provides firmware functions to manage the following
00007   *          functionalities of DCMI extension peripheral:
00008   *           + Extension features functions
00009   *
00010   @verbatim
00011   ==============================================================================
00012                ##### DCMI peripheral extension features  #####
00013   ==============================================================================
00014 
00015   [..] Comparing to other previous devices, the DCMI interface for STM32F446xx 
00016        devices contains the following additional features :
00017 
00018        (+) Support of Black and White cameras 
00019 
00020                      ##### How to use this driver #####
00021   ==============================================================================
00022   [..] This driver provides functions to manage the Black and White feature
00023 
00024   @endverbatim
00025   ******************************************************************************
00026   * @attention
00027   *
00028   * <h2><center>&copy; COPYRIGHT(c) 2017 STMicroelectronics</center></h2>
00029   *
00030   * Redistribution and use in source and binary forms, with or without modification,
00031   * are permitted provided that the following conditions are met:
00032   *   1. Redistributions of source code must retain the above copyright notice,
00033   *      this list of conditions and the following disclaimer.
00034   *   2. Redistributions in binary form must reproduce the above copyright notice,
00035   *      this list of conditions and the following disclaimer in the documentation
00036   *      and/or other materials provided with the distribution.
00037   *   3. Neither the name of STMicroelectronics nor the names of its contributors
00038   *      may be used to endorse or promote products derived from this software
00039   *      without specific prior written permission.
00040   *
00041   * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
00042   * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00043   * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
00044   * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
00045   * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
00046   * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
00047   * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00048   * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
00049   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
00050   * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00051   *
00052   ******************************************************************************
00053   */
00054 
00055 /* Includes ------------------------------------------------------------------*/
00056 #include "stm32f4xx_hal.h"
00057 
00058 /** @addtogroup STM32F4xx_HAL_Driver
00059   * @{
00060   */
00061 /** @defgroup DCMIEx DCMIEx
00062   * @brief DCMI Extended HAL module driver
00063   * @{
00064   */
00065 
00066 #ifdef HAL_DCMI_MODULE_ENABLED
00067 
00068 #if defined(STM32F407xx) || defined(STM32F417xx) || defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) ||\
00069     defined(STM32F439xx) || defined(STM32F446xx) || defined(STM32F469xx) || defined(STM32F479xx)
00070 /* Private typedef -----------------------------------------------------------*/
00071 /* Private define ------------------------------------------------------------*/
00072 /* Private macro -------------------------------------------------------------*/
00073 /* Private variables ---------------------------------------------------------*/
00074 /* Private function prototypes -----------------------------------------------*/
00075 /* Exported functions --------------------------------------------------------*/
00076 
00077 /** @defgroup DCMIEx_Exported_Functions DCMI Extended Exported Functions
00078   * @{
00079   */
00080 
00081 /**
00082   * @}
00083   */
00084 
00085 /** @addtogroup DCMI_Exported_Functions_Group1 Initialization and Configuration functions
00086   * @{
00087   */
00088 
00089 /**
00090   * @brief  Initializes the DCMI according to the specified
00091   *         parameters in the DCMI_InitTypeDef and create the associated handle.
00092   * @param  hdcmi pointer to a DCMI_HandleTypeDef structure that contains
00093   *                the configuration information for DCMI.
00094   * @retval HAL status
00095   */
00096 HAL_StatusTypeDef HAL_DCMI_Init(DCMI_HandleTypeDef *hdcmi)
00097 {
00098   /* Check the DCMI peripheral state */
00099   if(hdcmi == NULL)
00100   {
00101      return HAL_ERROR;
00102   }
00103 
00104   /* Check function parameters */
00105   assert_param(IS_DCMI_ALL_INSTANCE(hdcmi->Instance));
00106   assert_param(IS_DCMI_PCKPOLARITY(hdcmi->Init.PCKPolarity));
00107   assert_param(IS_DCMI_VSPOLARITY(hdcmi->Init.VSPolarity));
00108   assert_param(IS_DCMI_HSPOLARITY(hdcmi->Init.HSPolarity));
00109   assert_param(IS_DCMI_SYNCHRO(hdcmi->Init.SynchroMode));
00110   assert_param(IS_DCMI_CAPTURE_RATE(hdcmi->Init.CaptureRate));
00111   assert_param(IS_DCMI_EXTENDED_DATA(hdcmi->Init.ExtendedDataMode));
00112   assert_param(IS_DCMI_MODE_JPEG(hdcmi->Init.JPEGMode));
00113 #if defined(STM32F446xx) || defined(STM32F469xx) || defined(STM32F479xx)
00114   assert_param(IS_DCMI_BYTE_SELECT_MODE(hdcmi->Init.ByteSelectMode));
00115   assert_param(IS_DCMI_BYTE_SELECT_START(hdcmi->Init.ByteSelectStart));
00116   assert_param(IS_DCMI_LINE_SELECT_MODE(hdcmi->Init.LineSelectMode));
00117   assert_param(IS_DCMI_LINE_SELECT_START(hdcmi->Init.LineSelectStart));
00118 #endif /* STM32F446xx || STM32F469xx || STM32F479xx */
00119   if(hdcmi->State == HAL_DCMI_STATE_RESET)
00120   {
00121     /* Init the low level hardware */
00122     HAL_DCMI_MspInit(hdcmi);
00123   }
00124 
00125   /* Change the DCMI state */
00126   hdcmi->State = HAL_DCMI_STATE_BUSY;
00127                           /* Configures the HS, VS, DE and PC polarity */
00128   hdcmi->Instance->CR &= ~(DCMI_CR_PCKPOL | DCMI_CR_HSPOL  | DCMI_CR_VSPOL  | DCMI_CR_EDM_0 |\
00129                            DCMI_CR_EDM_1  | DCMI_CR_FCRC_0 | DCMI_CR_FCRC_1 | DCMI_CR_JPEG  |\
00130                            DCMI_CR_ESS
00131 #if defined(STM32F446xx) || defined(STM32F469xx) || defined(STM32F479xx)
00132                            | DCMI_CR_BSM_0 | DCMI_CR_BSM_1 | DCMI_CR_OEBS |\
00133                            DCMI_CR_LSM | DCMI_CR_OELS
00134 #endif /* STM32F446xx || STM32F469xx || STM32F479xx */
00135                            );
00136   hdcmi->Instance->CR |=  (uint32_t)(hdcmi->Init.SynchroMode | hdcmi->Init.CaptureRate |\
00137                                      hdcmi->Init.VSPolarity  | hdcmi->Init.HSPolarity  |\
00138                                      hdcmi->Init.PCKPolarity | hdcmi->Init.ExtendedDataMode |\
00139                                      hdcmi->Init.JPEGMode 
00140 #if defined(STM32F446xx) || defined(STM32F469xx) || defined(STM32F479xx)
00141                                      | hdcmi->Init.ByteSelectMode |\
00142                                      hdcmi->Init.ByteSelectStart | hdcmi->Init.LineSelectMode |\
00143                                      hdcmi->Init.LineSelectStart
00144 #endif /* STM32F446xx || STM32F469xx || STM32F479xx */
00145                                      );
00146   if(hdcmi->Init.SynchroMode == DCMI_SYNCHRO_EMBEDDED)
00147   {
00148     hdcmi->Instance->ESCR = (((uint32_t)hdcmi->Init.SyncroCode.FrameStartCode)    |
00149                              ((uint32_t)hdcmi->Init.SyncroCode.LineStartCode << DCMI_POSITION_ESCR_LSC)|
00150                              ((uint32_t)hdcmi->Init.SyncroCode.LineEndCode << DCMI_POSITION_ESCR_LEC) |
00151                              ((uint32_t)hdcmi->Init.SyncroCode.FrameEndCode << DCMI_POSITION_ESCR_FEC));
00152 
00153   }
00154 
00155   /* Enable the Line, Vsync, Error and Overrun interrupts */
00156   __HAL_DCMI_ENABLE_IT(hdcmi, DCMI_IT_LINE | DCMI_IT_VSYNC | DCMI_IT_ERR | DCMI_IT_OVR);
00157 
00158   /* Update error code */
00159   hdcmi->ErrorCode = HAL_DCMI_ERROR_NONE;
00160 
00161   /* Initialize the DCMI state*/
00162   hdcmi->State  = HAL_DCMI_STATE_READY;
00163 
00164   return HAL_OK;
00165 }
00166   
00167 /**
00168   * @}
00169   */
00170 #endif /* STM32F407xx || STM32F417xx || STM32F427xx || STM32F437xx || STM32F429xx ||\
00171           STM32F439xx || STM32F446xx || STM32F469xx || STM32F479xx */
00172 #endif /* HAL_DCMI_MODULE_ENABLED */
00173 /**
00174   * @}
00175   */
00176 
00177 /**
00178   * @}
00179   */
00180 
00181 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/