]> git.sur5r.net Git - freertos/blob - FreeRTOS/Demo/CORTEX_M7_STM32F7_STM32756G-EVAL/ST_Library/stm32f7xx_hal_dcmi_ex.c
Update version number ready for V8.2.1 release.
[freertos] / FreeRTOS / Demo / CORTEX_M7_STM32F7_STM32756G-EVAL / ST_Library / stm32f7xx_hal_dcmi_ex.c
1 /**\r
2   ******************************************************************************\r
3   * @file    stm32f7xx_hal_dcmi_ex.c\r
4   * @author  MCD Application Team\r
5   * @version V0.3.0\r
6   * @date    06-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
11   *           \r
12   @verbatim      \r
13   ==============================================================================\r
14                ##### DCMI peripheral extension features  #####\r
15   ==============================================================================\r
16            \r
17   [..]  Support of Black and White cameras \r
18    \r
19                      ##### How to use this driver #####\r
20   ==============================================================================\r
21   [..] This driver provides functions to manage the Black and White feature\r
22     \r
23   @endverbatim\r
24   ******************************************************************************\r
25   * @attention\r
26   *\r
27   * <h2><center>&copy; COPYRIGHT(c) 2015 STMicroelectronics</center></h2>\r
28   *\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
39   *\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
50   *\r
51   ******************************************************************************\r
52   */ \r
53 \r
54 /* Includes ------------------------------------------------------------------*/\r
55 #include "stm32f7xx_hal.h"\r
56 \r
57 /** @addtogroup STM32F7xx_HAL_Driver\r
58   * @{\r
59   */\r
60 /** @defgroup DCMI DCMI\r
61   * @brief DCMI HAL module driver\r
62   * @{\r
63   */\r
64 \r
65 #ifdef HAL_DCMI_MODULE_ENABLED\r
66 \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
74 \r
75 /** @defgroup DCMIEx_Exported_Functions DCMI Extended Exported Functions\r
76   * @{\r
77   */\r
78 \r
79 /** @defgroup DCMIEx_Exported_Functions_Group1 Initialization and Configuration functions\r
80  *  @brief   Initialization and Configuration functions\r
81  *\r
82 @verbatim   \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
89 \r
90 @endverbatim\r
91   * @{\r
92   */\r
93   \r
94 /**\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
100   */\r
101 HAL_StatusTypeDef HAL_DCMI_Init(DCMI_HandleTypeDef *hdcmi)\r
102 {     \r
103   /* Check the DCMI peripheral state */\r
104   if(hdcmi == NULL)\r
105   {\r
106      return HAL_ERROR;\r
107   }\r
108   \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
118 \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
123                 \r
124   if(hdcmi->State == HAL_DCMI_STATE_RESET)\r
125   {\r
126     /* Init the low level hardware */\r
127     HAL_DCMI_MspInit(hdcmi);\r
128   } \r
129   \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
137 \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
144                                      \r
145   if(hdcmi->Init.SynchroMode == DCMI_SYNCHRO_EMBEDDED)\r
146   {\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
151 \r
152   }\r
153 \r
154   /* Enable the Line interrupt */\r
155   __HAL_DCMI_ENABLE_IT(hdcmi, DCMI_IT_LINE);\r
156 \r
157   /* Enable the VSYNC interrupt */\r
158   __HAL_DCMI_ENABLE_IT(hdcmi, DCMI_IT_VSYNC);\r
159 \r
160   /* Enable the Frame capture complete interrupt */\r
161   __HAL_DCMI_ENABLE_IT(hdcmi, DCMI_IT_FRAME);\r
162 \r
163   /* Enable the Synchronization error interrupt */\r
164   __HAL_DCMI_ENABLE_IT(hdcmi, DCMI_IT_ERR);\r
165 \r
166   /* Enable the Overflow interrupt */\r
167   __HAL_DCMI_ENABLE_IT(hdcmi, DCMI_IT_OVF);\r
168 \r
169   /* Enable DCMI by setting DCMIEN bit */\r
170   __HAL_DCMI_ENABLE(hdcmi);\r
171 \r
172   /* Update error code */\r
173   hdcmi->ErrorCode = HAL_DCMI_ERROR_NONE;\r
174   \r
175   /* Initialize the DCMI state*/\r
176   hdcmi->State  = HAL_DCMI_STATE_READY;\r
177 \r
178   return HAL_OK;\r
179 }\r
180 \r
181 \r
182 /**\r
183   * @}\r
184   */\r
185 \r
186 /**\r
187   * @}\r
188   */\r
189   \r
190 /**\r
191   * @}\r
192   */\r
193 #endif /* STM32F746xx || STM32F756xx */\r
194 #endif /* HAL_DCMI_MODULE_ENABLED */\r
195 /**\r
196   * @}\r
197   */\r
198 \r
199 /**\r
200   * @}\r
201   */\r
202 \r
203 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/\r