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