fix LPC812 PWM
Fork of mbed-dev by
targets/cmsis/TARGET_STM/TARGET_STM32F7/stm32f7xx_hal_dcmi_ex.c@0:9b334a45a8ff, 2015-10-01 (annotated)
- Committer:
- bogdanm
- Date:
- Thu Oct 01 15:25:22 2015 +0300
- Revision:
- 0:9b334a45a8ff
- Child:
- 83:a036322b8637
Initial commit on mbed-dev
Replaces mbed-src (now inactive)
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
bogdanm | 0:9b334a45a8ff | 1 | /** |
bogdanm | 0:9b334a45a8ff | 2 | ****************************************************************************** |
bogdanm | 0:9b334a45a8ff | 3 | * @file stm32f7xx_hal_dcmi_ex.c |
bogdanm | 0:9b334a45a8ff | 4 | * @author MCD Application Team |
bogdanm | 0:9b334a45a8ff | 5 | * @version V1.0.1 |
bogdanm | 0:9b334a45a8ff | 6 | * @date 25-June-2015 |
bogdanm | 0:9b334a45a8ff | 7 | * @brief DCMI Extension HAL module driver. |
bogdanm | 0:9b334a45a8ff | 8 | * This file provides firmware functions to manage the following |
bogdanm | 0:9b334a45a8ff | 9 | * functionalities of DCMI extension peripheral: |
bogdanm | 0:9b334a45a8ff | 10 | * + Extension features functions |
bogdanm | 0:9b334a45a8ff | 11 | * |
bogdanm | 0:9b334a45a8ff | 12 | @verbatim |
bogdanm | 0:9b334a45a8ff | 13 | ============================================================================== |
bogdanm | 0:9b334a45a8ff | 14 | ##### DCMI peripheral extension features ##### |
bogdanm | 0:9b334a45a8ff | 15 | ============================================================================== |
bogdanm | 0:9b334a45a8ff | 16 | |
bogdanm | 0:9b334a45a8ff | 17 | [..] Support of Black and White cameras |
bogdanm | 0:9b334a45a8ff | 18 | |
bogdanm | 0:9b334a45a8ff | 19 | ##### How to use this driver ##### |
bogdanm | 0:9b334a45a8ff | 20 | ============================================================================== |
bogdanm | 0:9b334a45a8ff | 21 | [..] This driver provides functions to manage the Black and White feature |
bogdanm | 0:9b334a45a8ff | 22 | |
bogdanm | 0:9b334a45a8ff | 23 | @endverbatim |
bogdanm | 0:9b334a45a8ff | 24 | ****************************************************************************** |
bogdanm | 0:9b334a45a8ff | 25 | * @attention |
bogdanm | 0:9b334a45a8ff | 26 | * |
bogdanm | 0:9b334a45a8ff | 27 | * <h2><center>© COPYRIGHT(c) 2015 STMicroelectronics</center></h2> |
bogdanm | 0:9b334a45a8ff | 28 | * |
bogdanm | 0:9b334a45a8ff | 29 | * Redistribution and use in source and binary forms, with or without modification, |
bogdanm | 0:9b334a45a8ff | 30 | * are permitted provided that the following conditions are met: |
bogdanm | 0:9b334a45a8ff | 31 | * 1. Redistributions of source code must retain the above copyright notice, |
bogdanm | 0:9b334a45a8ff | 32 | * this list of conditions and the following disclaimer. |
bogdanm | 0:9b334a45a8ff | 33 | * 2. Redistributions in binary form must reproduce the above copyright notice, |
bogdanm | 0:9b334a45a8ff | 34 | * this list of conditions and the following disclaimer in the documentation |
bogdanm | 0:9b334a45a8ff | 35 | * and/or other materials provided with the distribution. |
bogdanm | 0:9b334a45a8ff | 36 | * 3. Neither the name of STMicroelectronics nor the names of its contributors |
bogdanm | 0:9b334a45a8ff | 37 | * may be used to endorse or promote products derived from this software |
bogdanm | 0:9b334a45a8ff | 38 | * without specific prior written permission. |
bogdanm | 0:9b334a45a8ff | 39 | * |
bogdanm | 0:9b334a45a8ff | 40 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
bogdanm | 0:9b334a45a8ff | 41 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
bogdanm | 0:9b334a45a8ff | 42 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
bogdanm | 0:9b334a45a8ff | 43 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE |
bogdanm | 0:9b334a45a8ff | 44 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
bogdanm | 0:9b334a45a8ff | 45 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
bogdanm | 0:9b334a45a8ff | 46 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
bogdanm | 0:9b334a45a8ff | 47 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
bogdanm | 0:9b334a45a8ff | 48 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
bogdanm | 0:9b334a45a8ff | 49 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
bogdanm | 0:9b334a45a8ff | 50 | * |
bogdanm | 0:9b334a45a8ff | 51 | ****************************************************************************** |
bogdanm | 0:9b334a45a8ff | 52 | */ |
bogdanm | 0:9b334a45a8ff | 53 | |
bogdanm | 0:9b334a45a8ff | 54 | /* Includes ------------------------------------------------------------------*/ |
bogdanm | 0:9b334a45a8ff | 55 | #include "stm32f7xx_hal.h" |
bogdanm | 0:9b334a45a8ff | 56 | |
bogdanm | 0:9b334a45a8ff | 57 | /** @addtogroup STM32F7xx_HAL_Driver |
bogdanm | 0:9b334a45a8ff | 58 | * @{ |
bogdanm | 0:9b334a45a8ff | 59 | */ |
bogdanm | 0:9b334a45a8ff | 60 | /** @defgroup DCMIEx DCMIEx |
bogdanm | 0:9b334a45a8ff | 61 | * @brief DCMI Extended HAL module driver |
bogdanm | 0:9b334a45a8ff | 62 | * @{ |
bogdanm | 0:9b334a45a8ff | 63 | */ |
bogdanm | 0:9b334a45a8ff | 64 | |
bogdanm | 0:9b334a45a8ff | 65 | #ifdef HAL_DCMI_MODULE_ENABLED |
bogdanm | 0:9b334a45a8ff | 66 | |
bogdanm | 0:9b334a45a8ff | 67 | /* Private typedef -----------------------------------------------------------*/ |
bogdanm | 0:9b334a45a8ff | 68 | /* Private define ------------------------------------------------------------*/ |
bogdanm | 0:9b334a45a8ff | 69 | /* Private macro -------------------------------------------------------------*/ |
bogdanm | 0:9b334a45a8ff | 70 | /* Private variables ---------------------------------------------------------*/ |
bogdanm | 0:9b334a45a8ff | 71 | /* Private function prototypes -----------------------------------------------*/ |
bogdanm | 0:9b334a45a8ff | 72 | /* Exported functions --------------------------------------------------------*/ |
bogdanm | 0:9b334a45a8ff | 73 | |
bogdanm | 0:9b334a45a8ff | 74 | /** @defgroup DCMIEx_Exported_Functions DCMIEx Exported Functions |
bogdanm | 0:9b334a45a8ff | 75 | * @{ |
bogdanm | 0:9b334a45a8ff | 76 | */ |
bogdanm | 0:9b334a45a8ff | 77 | |
bogdanm | 0:9b334a45a8ff | 78 | /** @defgroup DCMIEx_Exported_Functions_Group1 Initialization and Configuration functions |
bogdanm | 0:9b334a45a8ff | 79 | * @brief Initialization and Configuration functions |
bogdanm | 0:9b334a45a8ff | 80 | * |
bogdanm | 0:9b334a45a8ff | 81 | @verbatim |
bogdanm | 0:9b334a45a8ff | 82 | =============================================================================== |
bogdanm | 0:9b334a45a8ff | 83 | ##### Initialization and Configuration functions ##### |
bogdanm | 0:9b334a45a8ff | 84 | =============================================================================== |
bogdanm | 0:9b334a45a8ff | 85 | [..] This section provides functions allowing to: |
bogdanm | 0:9b334a45a8ff | 86 | (+) Initialize and configure the DCMI |
bogdanm | 0:9b334a45a8ff | 87 | (+) De-initialize the DCMI |
bogdanm | 0:9b334a45a8ff | 88 | |
bogdanm | 0:9b334a45a8ff | 89 | @endverbatim |
bogdanm | 0:9b334a45a8ff | 90 | * @{ |
bogdanm | 0:9b334a45a8ff | 91 | */ |
bogdanm | 0:9b334a45a8ff | 92 | |
bogdanm | 0:9b334a45a8ff | 93 | /** |
bogdanm | 0:9b334a45a8ff | 94 | * @brief Initializes the DCMI according to the specified |
bogdanm | 0:9b334a45a8ff | 95 | * parameters in the DCMI_InitTypeDef and create the associated handle. |
bogdanm | 0:9b334a45a8ff | 96 | * @param hdcmi: pointer to a DCMI_HandleTypeDef structure that contains |
bogdanm | 0:9b334a45a8ff | 97 | * the configuration information for DCMI. |
bogdanm | 0:9b334a45a8ff | 98 | * @retval HAL status |
bogdanm | 0:9b334a45a8ff | 99 | */ |
bogdanm | 0:9b334a45a8ff | 100 | HAL_StatusTypeDef HAL_DCMI_Init(DCMI_HandleTypeDef *hdcmi) |
bogdanm | 0:9b334a45a8ff | 101 | { |
bogdanm | 0:9b334a45a8ff | 102 | /* Check the DCMI peripheral state */ |
bogdanm | 0:9b334a45a8ff | 103 | if(hdcmi == NULL) |
bogdanm | 0:9b334a45a8ff | 104 | { |
bogdanm | 0:9b334a45a8ff | 105 | return HAL_ERROR; |
bogdanm | 0:9b334a45a8ff | 106 | } |
bogdanm | 0:9b334a45a8ff | 107 | |
bogdanm | 0:9b334a45a8ff | 108 | /* Check function parameters */ |
bogdanm | 0:9b334a45a8ff | 109 | assert_param(IS_DCMI_ALL_INSTANCE(hdcmi->Instance)); |
bogdanm | 0:9b334a45a8ff | 110 | assert_param(IS_DCMI_PCKPOLARITY(hdcmi->Init.PCKPolarity)); |
bogdanm | 0:9b334a45a8ff | 111 | assert_param(IS_DCMI_VSPOLARITY(hdcmi->Init.VSPolarity)); |
bogdanm | 0:9b334a45a8ff | 112 | assert_param(IS_DCMI_HSPOLARITY(hdcmi->Init.HSPolarity)); |
bogdanm | 0:9b334a45a8ff | 113 | assert_param(IS_DCMI_SYNCHRO(hdcmi->Init.SynchroMode)); |
bogdanm | 0:9b334a45a8ff | 114 | assert_param(IS_DCMI_CAPTURE_RATE(hdcmi->Init.CaptureRate)); |
bogdanm | 0:9b334a45a8ff | 115 | assert_param(IS_DCMI_EXTENDED_DATA(hdcmi->Init.ExtendedDataMode)); |
bogdanm | 0:9b334a45a8ff | 116 | assert_param(IS_DCMI_MODE_JPEG(hdcmi->Init.JPEGMode)); |
bogdanm | 0:9b334a45a8ff | 117 | |
bogdanm | 0:9b334a45a8ff | 118 | assert_param(IS_DCMI_BYTE_SELECT_MODE(hdcmi->Init.ByteSelectMode)); |
bogdanm | 0:9b334a45a8ff | 119 | assert_param(IS_DCMI_BYTE_SELECT_START(hdcmi->Init.ByteSelectStart)); |
bogdanm | 0:9b334a45a8ff | 120 | assert_param(IS_DCMI_LINE_SELECT_MODE(hdcmi->Init.LineSelectMode)); |
bogdanm | 0:9b334a45a8ff | 121 | assert_param(IS_DCMI_LINE_SELECT_START(hdcmi->Init.LineSelectStart)); |
bogdanm | 0:9b334a45a8ff | 122 | |
bogdanm | 0:9b334a45a8ff | 123 | if(hdcmi->State == HAL_DCMI_STATE_RESET) |
bogdanm | 0:9b334a45a8ff | 124 | { |
bogdanm | 0:9b334a45a8ff | 125 | /* Init the low level hardware */ |
bogdanm | 0:9b334a45a8ff | 126 | HAL_DCMI_MspInit(hdcmi); |
bogdanm | 0:9b334a45a8ff | 127 | } |
bogdanm | 0:9b334a45a8ff | 128 | |
bogdanm | 0:9b334a45a8ff | 129 | /* Change the DCMI state */ |
bogdanm | 0:9b334a45a8ff | 130 | hdcmi->State = HAL_DCMI_STATE_BUSY; |
bogdanm | 0:9b334a45a8ff | 131 | /* Configures the HS, VS, DE and PC polarity */ |
bogdanm | 0:9b334a45a8ff | 132 | hdcmi->Instance->CR &= ~(DCMI_CR_PCKPOL | DCMI_CR_HSPOL | DCMI_CR_VSPOL | DCMI_CR_EDM_0 |\ |
bogdanm | 0:9b334a45a8ff | 133 | DCMI_CR_EDM_1 | DCMI_CR_FCRC_0 | DCMI_CR_FCRC_1 | DCMI_CR_JPEG |\ |
bogdanm | 0:9b334a45a8ff | 134 | DCMI_CR_ESS | DCMI_CR_BSM_0 | DCMI_CR_BSM_1 | DCMI_CR_OEBS |\ |
bogdanm | 0:9b334a45a8ff | 135 | DCMI_CR_LSM | DCMI_CR_OELS); |
bogdanm | 0:9b334a45a8ff | 136 | |
bogdanm | 0:9b334a45a8ff | 137 | hdcmi->Instance->CR |= (uint32_t)(hdcmi->Init.SynchroMode | hdcmi->Init.CaptureRate |\ |
bogdanm | 0:9b334a45a8ff | 138 | hdcmi->Init.VSPolarity | hdcmi->Init.HSPolarity |\ |
bogdanm | 0:9b334a45a8ff | 139 | hdcmi->Init.PCKPolarity | hdcmi->Init.ExtendedDataMode |\ |
bogdanm | 0:9b334a45a8ff | 140 | hdcmi->Init.JPEGMode | hdcmi->Init.ByteSelectMode |\ |
bogdanm | 0:9b334a45a8ff | 141 | hdcmi->Init.ByteSelectStart | hdcmi->Init.LineSelectMode |\ |
bogdanm | 0:9b334a45a8ff | 142 | hdcmi->Init.LineSelectStart); |
bogdanm | 0:9b334a45a8ff | 143 | |
bogdanm | 0:9b334a45a8ff | 144 | if(hdcmi->Init.SynchroMode == DCMI_SYNCHRO_EMBEDDED) |
bogdanm | 0:9b334a45a8ff | 145 | { |
bogdanm | 0:9b334a45a8ff | 146 | DCMI->ESCR = (((uint32_t)hdcmi->Init.SyncroCode.FrameStartCode) | |
bogdanm | 0:9b334a45a8ff | 147 | ((uint32_t)hdcmi->Init.SyncroCode.LineStartCode << 8)| |
bogdanm | 0:9b334a45a8ff | 148 | ((uint32_t)hdcmi->Init.SyncroCode.LineEndCode << 16) | |
bogdanm | 0:9b334a45a8ff | 149 | ((uint32_t)hdcmi->Init.SyncroCode.FrameEndCode << 24)); |
bogdanm | 0:9b334a45a8ff | 150 | |
bogdanm | 0:9b334a45a8ff | 151 | } |
bogdanm | 0:9b334a45a8ff | 152 | |
bogdanm | 0:9b334a45a8ff | 153 | /* Enable the Line interrupt */ |
bogdanm | 0:9b334a45a8ff | 154 | __HAL_DCMI_ENABLE_IT(hdcmi, DCMI_IT_LINE); |
bogdanm | 0:9b334a45a8ff | 155 | |
bogdanm | 0:9b334a45a8ff | 156 | /* Enable the VSYNC interrupt */ |
bogdanm | 0:9b334a45a8ff | 157 | __HAL_DCMI_ENABLE_IT(hdcmi, DCMI_IT_VSYNC); |
bogdanm | 0:9b334a45a8ff | 158 | |
bogdanm | 0:9b334a45a8ff | 159 | /* Enable the Frame capture complete interrupt */ |
bogdanm | 0:9b334a45a8ff | 160 | __HAL_DCMI_ENABLE_IT(hdcmi, DCMI_IT_FRAME); |
bogdanm | 0:9b334a45a8ff | 161 | |
bogdanm | 0:9b334a45a8ff | 162 | /* Enable the Synchronization error interrupt */ |
bogdanm | 0:9b334a45a8ff | 163 | __HAL_DCMI_ENABLE_IT(hdcmi, DCMI_IT_ERR); |
bogdanm | 0:9b334a45a8ff | 164 | |
bogdanm | 0:9b334a45a8ff | 165 | /* Enable the Overflow interrupt */ |
bogdanm | 0:9b334a45a8ff | 166 | __HAL_DCMI_ENABLE_IT(hdcmi, DCMI_IT_OVF); |
bogdanm | 0:9b334a45a8ff | 167 | |
bogdanm | 0:9b334a45a8ff | 168 | /* Enable DCMI by setting DCMIEN bit */ |
bogdanm | 0:9b334a45a8ff | 169 | __HAL_DCMI_ENABLE(hdcmi); |
bogdanm | 0:9b334a45a8ff | 170 | |
bogdanm | 0:9b334a45a8ff | 171 | /* Update error code */ |
bogdanm | 0:9b334a45a8ff | 172 | hdcmi->ErrorCode = HAL_DCMI_ERROR_NONE; |
bogdanm | 0:9b334a45a8ff | 173 | |
bogdanm | 0:9b334a45a8ff | 174 | /* Initialize the DCMI state*/ |
bogdanm | 0:9b334a45a8ff | 175 | hdcmi->State = HAL_DCMI_STATE_READY; |
bogdanm | 0:9b334a45a8ff | 176 | |
bogdanm | 0:9b334a45a8ff | 177 | return HAL_OK; |
bogdanm | 0:9b334a45a8ff | 178 | } |
bogdanm | 0:9b334a45a8ff | 179 | |
bogdanm | 0:9b334a45a8ff | 180 | |
bogdanm | 0:9b334a45a8ff | 181 | /** |
bogdanm | 0:9b334a45a8ff | 182 | * @} |
bogdanm | 0:9b334a45a8ff | 183 | */ |
bogdanm | 0:9b334a45a8ff | 184 | |
bogdanm | 0:9b334a45a8ff | 185 | /** |
bogdanm | 0:9b334a45a8ff | 186 | * @} |
bogdanm | 0:9b334a45a8ff | 187 | */ |
bogdanm | 0:9b334a45a8ff | 188 | |
bogdanm | 0:9b334a45a8ff | 189 | /** |
bogdanm | 0:9b334a45a8ff | 190 | * @} |
bogdanm | 0:9b334a45a8ff | 191 | */ |
bogdanm | 0:9b334a45a8ff | 192 | #endif /* HAL_DCMI_MODULE_ENABLED */ |
bogdanm | 0:9b334a45a8ff | 193 | /** |
bogdanm | 0:9b334a45a8ff | 194 | * @} |
bogdanm | 0:9b334a45a8ff | 195 | */ |
bogdanm | 0:9b334a45a8ff | 196 | |
bogdanm | 0:9b334a45a8ff | 197 | /** |
bogdanm | 0:9b334a45a8ff | 198 | * @} |
bogdanm | 0:9b334a45a8ff | 199 | */ |
bogdanm | 0:9b334a45a8ff | 200 | |
bogdanm | 0:9b334a45a8ff | 201 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |