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