comparison Common/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_dcmi_ex.c @ 128:c78bcbd5deda FlipDisplay

Added current STM32 standandard libraries in version independend folder structure
author Ideenmodellierer
date Sun, 17 Feb 2019 21:12:22 +0100
parents
children
comparison
equal deleted inserted replaced
127:1369f8660eaa 128:c78bcbd5deda
1 /**
2 ******************************************************************************
3 * @file stm32f4xx_hal_dcmi_ex.c
4 * @author MCD Application Team
5 * @brief DCMI Extension HAL module driver
6 * This file provides firmware functions to manage the following
7 * functionalities of DCMI extension peripheral:
8 * + Extension features functions
9 *
10 @verbatim
11 ==============================================================================
12 ##### DCMI peripheral extension features #####
13 ==============================================================================
14
15 [..] Comparing to other previous devices, the DCMI interface for STM32F446xx
16 devices contains the following additional features :
17
18 (+) Support of Black and White cameras
19
20 ##### How to use this driver #####
21 ==============================================================================
22 [..] This driver provides functions to manage the Black and White feature
23
24 @endverbatim
25 ******************************************************************************
26 * @attention
27 *
28 * <h2><center>&copy; COPYRIGHT(c) 2017 STMicroelectronics</center></h2>
29 *
30 * Redistribution and use in source and binary forms, with or without modification,
31 * are permitted provided that the following conditions are met:
32 * 1. Redistributions of source code must retain the above copyright notice,
33 * this list of conditions and the following disclaimer.
34 * 2. Redistributions in binary form must reproduce the above copyright notice,
35 * this list of conditions and the following disclaimer in the documentation
36 * and/or other materials provided with the distribution.
37 * 3. Neither the name of STMicroelectronics nor the names of its contributors
38 * may be used to endorse or promote products derived from this software
39 * without specific prior written permission.
40 *
41 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
42 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
44 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
47 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
48 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
49 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
50 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
51 *
52 ******************************************************************************
53 */
54
55 /* Includes ------------------------------------------------------------------*/
56 #include "stm32f4xx_hal.h"
57
58 /** @addtogroup STM32F4xx_HAL_Driver
59 * @{
60 */
61 /** @defgroup DCMIEx DCMIEx
62 * @brief DCMI Extended HAL module driver
63 * @{
64 */
65
66 #ifdef HAL_DCMI_MODULE_ENABLED
67
68 #if defined(STM32F407xx) || defined(STM32F417xx) || defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) ||\
69 defined(STM32F439xx) || defined(STM32F446xx) || defined(STM32F469xx) || defined(STM32F479xx)
70 /* Private typedef -----------------------------------------------------------*/
71 /* Private define ------------------------------------------------------------*/
72 /* Private macro -------------------------------------------------------------*/
73 /* Private variables ---------------------------------------------------------*/
74 /* Private function prototypes -----------------------------------------------*/
75 /* Exported functions --------------------------------------------------------*/
76
77 /** @defgroup DCMIEx_Exported_Functions DCMI Extended Exported Functions
78 * @{
79 */
80
81 /**
82 * @}
83 */
84
85 /** @addtogroup DCMI_Exported_Functions_Group1 Initialization and Configuration functions
86 * @{
87 */
88
89 /**
90 * @brief Initializes the DCMI according to the specified
91 * parameters in the DCMI_InitTypeDef and create the associated handle.
92 * @param hdcmi pointer to a DCMI_HandleTypeDef structure that contains
93 * the configuration information for DCMI.
94 * @retval HAL status
95 */
96 HAL_StatusTypeDef HAL_DCMI_Init(DCMI_HandleTypeDef *hdcmi)
97 {
98 /* Check the DCMI peripheral state */
99 if(hdcmi == NULL)
100 {
101 return HAL_ERROR;
102 }
103
104 /* Check function parameters */
105 assert_param(IS_DCMI_ALL_INSTANCE(hdcmi->Instance));
106 assert_param(IS_DCMI_PCKPOLARITY(hdcmi->Init.PCKPolarity));
107 assert_param(IS_DCMI_VSPOLARITY(hdcmi->Init.VSPolarity));
108 assert_param(IS_DCMI_HSPOLARITY(hdcmi->Init.HSPolarity));
109 assert_param(IS_DCMI_SYNCHRO(hdcmi->Init.SynchroMode));
110 assert_param(IS_DCMI_CAPTURE_RATE(hdcmi->Init.CaptureRate));
111 assert_param(IS_DCMI_EXTENDED_DATA(hdcmi->Init.ExtendedDataMode));
112 assert_param(IS_DCMI_MODE_JPEG(hdcmi->Init.JPEGMode));
113 #if defined(STM32F446xx) || defined(STM32F469xx) || defined(STM32F479xx)
114 assert_param(IS_DCMI_BYTE_SELECT_MODE(hdcmi->Init.ByteSelectMode));
115 assert_param(IS_DCMI_BYTE_SELECT_START(hdcmi->Init.ByteSelectStart));
116 assert_param(IS_DCMI_LINE_SELECT_MODE(hdcmi->Init.LineSelectMode));
117 assert_param(IS_DCMI_LINE_SELECT_START(hdcmi->Init.LineSelectStart));
118 #endif /* STM32F446xx || STM32F469xx || STM32F479xx */
119 if(hdcmi->State == HAL_DCMI_STATE_RESET)
120 {
121 /* Init the low level hardware */
122 HAL_DCMI_MspInit(hdcmi);
123 }
124
125 /* Change the DCMI state */
126 hdcmi->State = HAL_DCMI_STATE_BUSY;
127 /* Configures the HS, VS, DE and PC polarity */
128 hdcmi->Instance->CR &= ~(DCMI_CR_PCKPOL | DCMI_CR_HSPOL | DCMI_CR_VSPOL | DCMI_CR_EDM_0 |\
129 DCMI_CR_EDM_1 | DCMI_CR_FCRC_0 | DCMI_CR_FCRC_1 | DCMI_CR_JPEG |\
130 DCMI_CR_ESS
131 #if defined(STM32F446xx) || defined(STM32F469xx) || defined(STM32F479xx)
132 | DCMI_CR_BSM_0 | DCMI_CR_BSM_1 | DCMI_CR_OEBS |\
133 DCMI_CR_LSM | DCMI_CR_OELS
134 #endif /* STM32F446xx || STM32F469xx || STM32F479xx */
135 );
136 hdcmi->Instance->CR |= (uint32_t)(hdcmi->Init.SynchroMode | hdcmi->Init.CaptureRate |\
137 hdcmi->Init.VSPolarity | hdcmi->Init.HSPolarity |\
138 hdcmi->Init.PCKPolarity | hdcmi->Init.ExtendedDataMode |\
139 hdcmi->Init.JPEGMode
140 #if defined(STM32F446xx) || defined(STM32F469xx) || defined(STM32F479xx)
141 | hdcmi->Init.ByteSelectMode |\
142 hdcmi->Init.ByteSelectStart | hdcmi->Init.LineSelectMode |\
143 hdcmi->Init.LineSelectStart
144 #endif /* STM32F446xx || STM32F469xx || STM32F479xx */
145 );
146 if(hdcmi->Init.SynchroMode == DCMI_SYNCHRO_EMBEDDED)
147 {
148 hdcmi->Instance->ESCR = (((uint32_t)hdcmi->Init.SyncroCode.FrameStartCode) |
149 ((uint32_t)hdcmi->Init.SyncroCode.LineStartCode << DCMI_POSITION_ESCR_LSC)|
150 ((uint32_t)hdcmi->Init.SyncroCode.LineEndCode << DCMI_POSITION_ESCR_LEC) |
151 ((uint32_t)hdcmi->Init.SyncroCode.FrameEndCode << DCMI_POSITION_ESCR_FEC));
152
153 }
154
155 /* Enable the Line, Vsync, Error and Overrun interrupts */
156 __HAL_DCMI_ENABLE_IT(hdcmi, DCMI_IT_LINE | DCMI_IT_VSYNC | DCMI_IT_ERR | DCMI_IT_OVR);
157
158 /* Update error code */
159 hdcmi->ErrorCode = HAL_DCMI_ERROR_NONE;
160
161 /* Initialize the DCMI state*/
162 hdcmi->State = HAL_DCMI_STATE_READY;
163
164 return HAL_OK;
165 }
166
167 /**
168 * @}
169 */
170 #endif /* STM32F407xx || STM32F417xx || STM32F427xx || STM32F437xx || STM32F429xx ||\
171 STM32F439xx || STM32F446xx || STM32F469xx || STM32F479xx */
172 #endif /* HAL_DCMI_MODULE_ENABLED */
173 /**
174 * @}
175 */
176
177 /**
178 * @}
179 */
180
181 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/