2 ******************************************************************************
\r
3 * @file stm32f7xx_hal_dcmi_ex.c
\r
4 * @author MCD Application Team
\r
6 * @date 24-March-2015
\r
7 * @brief DCMI Extension HAL module driver.
\r
8 * This file provides firmware functions to manage the following
\r
9 * functionalities of DCMI extension peripheral:
\r
10 * + Extension features functions
\r
13 ==============================================================================
\r
14 ##### DCMI peripheral extension features #####
\r
15 ==============================================================================
\r
17 [..] Support of Black and White cameras
\r
19 ##### How to use this driver #####
\r
20 ==============================================================================
\r
21 [..] This driver provides functions to manage the Black and White feature
\r
24 ******************************************************************************
\r
27 * <h2><center>© COPYRIGHT(c) 2015 STMicroelectronics</center></h2>
\r
29 * Redistribution and use in source and binary forms, with or without modification,
\r
30 * are permitted provided that the following conditions are met:
\r
31 * 1. Redistributions of source code must retain the above copyright notice,
\r
32 * this list of conditions and the following disclaimer.
\r
33 * 2. Redistributions in binary form must reproduce the above copyright notice,
\r
34 * this list of conditions and the following disclaimer in the documentation
\r
35 * and/or other materials provided with the distribution.
\r
36 * 3. Neither the name of STMicroelectronics nor the names of its contributors
\r
37 * may be used to endorse or promote products derived from this software
\r
38 * without specific prior written permission.
\r
40 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
\r
41 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
\r
42 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
\r
43 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
\r
44 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
\r
45 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
\r
46 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
\r
47 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
\r
48 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
\r
49 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
\r
51 ******************************************************************************
\r
54 /* Includes ------------------------------------------------------------------*/
\r
55 #include "stm32f7xx_hal.h"
\r
57 /** @addtogroup STM32F7xx_HAL_Driver
\r
60 /** @defgroup DCMI DCMI
\r
61 * @brief DCMI HAL module driver
\r
65 #ifdef HAL_DCMI_MODULE_ENABLED
\r
67 #if defined(STM32F746xx) || defined(STM32F756xx)
\r
68 /* Private typedef -----------------------------------------------------------*/
\r
69 /* Private define ------------------------------------------------------------*/
\r
70 /* Private macro -------------------------------------------------------------*/
\r
71 /* Private variables ---------------------------------------------------------*/
\r
72 /* Private function prototypes -----------------------------------------------*/
\r
73 /* Exported functions --------------------------------------------------------*/
\r
75 /** @defgroup DCMIEx_Exported_Functions DCMI Extended Exported Functions
\r
79 /** @defgroup DCMIEx_Exported_Functions_Group1 Initialization and Configuration functions
\r
80 * @brief Initialization and Configuration functions
\r
83 ===============================================================================
\r
84 ##### Initialization and Configuration functions #####
\r
85 ===============================================================================
\r
86 [..] This section provides functions allowing to:
\r
87 (+) Initialize and configure the DCMI
\r
88 (+) De-initialize the DCMI
\r
95 * @brief Initializes the DCMI according to the specified
\r
96 * parameters in the DCMI_InitTypeDef and create the associated handle.
\r
97 * @param hdcmi: pointer to a DCMI_HandleTypeDef structure that contains
\r
98 * the configuration information for DCMI.
\r
99 * @retval HAL status
\r
101 HAL_StatusTypeDef HAL_DCMI_Init(DCMI_HandleTypeDef *hdcmi)
\r
103 /* Check the DCMI peripheral state */
\r
109 /* Check function parameters */
\r
110 assert_param(IS_DCMI_ALL_INSTANCE(hdcmi->Instance));
\r
111 assert_param(IS_DCMI_PCKPOLARITY(hdcmi->Init.PCKPolarity));
\r
112 assert_param(IS_DCMI_VSPOLARITY(hdcmi->Init.VSPolarity));
\r
113 assert_param(IS_DCMI_HSPOLARITY(hdcmi->Init.HSPolarity));
\r
114 assert_param(IS_DCMI_SYNCHRO(hdcmi->Init.SynchroMode));
\r
115 assert_param(IS_DCMI_CAPTURE_RATE(hdcmi->Init.CaptureRate));
\r
116 assert_param(IS_DCMI_EXTENDED_DATA(hdcmi->Init.ExtendedDataMode));
\r
117 assert_param(IS_DCMI_MODE_JPEG(hdcmi->Init.JPEGMode));
\r
119 assert_param(IS_DCMI_BYTE_SELECT_MODE(hdcmi->Init.ByteSelectMode));
\r
120 assert_param(IS_DCMI_BYTE_SELECT_START(hdcmi->Init.ByteSelectStart));
\r
121 assert_param(IS_DCMI_LINE_SELECT_MODE(hdcmi->Init.LineSelectMode));
\r
122 assert_param(IS_DCMI_LINE_SELECT_START(hdcmi->Init.LineSelectStart));
\r
124 if(hdcmi->State == HAL_DCMI_STATE_RESET)
\r
126 /* Init the low level hardware */
\r
127 HAL_DCMI_MspInit(hdcmi);
\r
130 /* Change the DCMI state */
\r
131 hdcmi->State = HAL_DCMI_STATE_BUSY;
\r
132 /* Configures the HS, VS, DE and PC polarity */
\r
133 hdcmi->Instance->CR &= ~(DCMI_CR_PCKPOL | DCMI_CR_HSPOL | DCMI_CR_VSPOL | DCMI_CR_EDM_0 |\
\r
134 DCMI_CR_EDM_1 | DCMI_CR_FCRC_0 | DCMI_CR_FCRC_1 | DCMI_CR_JPEG |\
\r
135 DCMI_CR_ESS | DCMI_CR_BSM_0 | DCMI_CR_BSM_1 | DCMI_CR_OEBS |\
\r
136 DCMI_CR_LSM | DCMI_CR_OELS);
\r
138 hdcmi->Instance->CR |= (uint32_t)(hdcmi->Init.SynchroMode | hdcmi->Init.CaptureRate |\
\r
139 hdcmi->Init.VSPolarity | hdcmi->Init.HSPolarity |\
\r
140 hdcmi->Init.PCKPolarity | hdcmi->Init.ExtendedDataMode |\
\r
141 hdcmi->Init.JPEGMode | hdcmi->Init.ByteSelectMode |\
\r
142 hdcmi->Init.ByteSelectStart | hdcmi->Init.LineSelectMode |\
\r
143 hdcmi->Init.LineSelectStart);
\r
145 if(hdcmi->Init.SynchroMode == DCMI_SYNCHRO_EMBEDDED)
\r
147 DCMI->ESCR = (((uint32_t)hdcmi->Init.SyncroCode.FrameStartCode) |
\r
148 ((uint32_t)hdcmi->Init.SyncroCode.LineStartCode << 8)|
\r
149 ((uint32_t)hdcmi->Init.SyncroCode.LineEndCode << 16) |
\r
150 ((uint32_t)hdcmi->Init.SyncroCode.FrameEndCode << 24));
\r
154 /* Enable the Line interrupt */
\r
155 __HAL_DCMI_ENABLE_IT(hdcmi, DCMI_IT_LINE);
\r
157 /* Enable the VSYNC interrupt */
\r
158 __HAL_DCMI_ENABLE_IT(hdcmi, DCMI_IT_VSYNC);
\r
160 /* Enable the Frame capture complete interrupt */
\r
161 __HAL_DCMI_ENABLE_IT(hdcmi, DCMI_IT_FRAME);
\r
163 /* Enable the Synchronization error interrupt */
\r
164 __HAL_DCMI_ENABLE_IT(hdcmi, DCMI_IT_ERR);
\r
166 /* Enable the Overflow interrupt */
\r
167 __HAL_DCMI_ENABLE_IT(hdcmi, DCMI_IT_OVF);
\r
169 /* Enable DCMI by setting DCMIEN bit */
\r
170 __HAL_DCMI_ENABLE(hdcmi);
\r
172 /* Update error code */
\r
173 hdcmi->ErrorCode = HAL_DCMI_ERROR_NONE;
\r
175 /* Initialize the DCMI state*/
\r
176 hdcmi->State = HAL_DCMI_STATE_READY;
\r
193 #endif /* STM32F746xx || STM32F756xx */
\r
194 #endif /* HAL_DCMI_MODULE_ENABLED */
\r
203 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
\r