thomas haine
/
CIS001_v2_v2
cis001v2
stm32h7xx_hal_msp.cpp@0:e7352f4f3dcb, 2020-06-18 (annotated)
- Committer:
- thomashaine
- Date:
- Thu Jun 18 12:36:05 2020 +0000
- Revision:
- 0:e7352f4f3dcb
- Child:
- 8:66caa906d24c
rev1
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
thomashaine | 0:e7352f4f3dcb | 1 | /* USER CODE BEGIN Header */ |
thomashaine | 0:e7352f4f3dcb | 2 | /** |
thomashaine | 0:e7352f4f3dcb | 3 | ****************************************************************************** |
thomashaine | 0:e7352f4f3dcb | 4 | * File Name : stm32h7xx_hal_msp.c |
thomashaine | 0:e7352f4f3dcb | 5 | * Description : This file provides code for the MSP Initialization |
thomashaine | 0:e7352f4f3dcb | 6 | * and de-Initialization codes. |
thomashaine | 0:e7352f4f3dcb | 7 | ****************************************************************************** |
thomashaine | 0:e7352f4f3dcb | 8 | * @attention |
thomashaine | 0:e7352f4f3dcb | 9 | * |
thomashaine | 0:e7352f4f3dcb | 10 | * <h2><center>© Copyright (c) 2020 STMicroelectronics. |
thomashaine | 0:e7352f4f3dcb | 11 | * All rights reserved.</center></h2> |
thomashaine | 0:e7352f4f3dcb | 12 | * |
thomashaine | 0:e7352f4f3dcb | 13 | * This software component is licensed by ST under BSD 3-Clause license, |
thomashaine | 0:e7352f4f3dcb | 14 | * the "License"; You may not use this file except in compliance with the |
thomashaine | 0:e7352f4f3dcb | 15 | * License. You may obtain a copy of the License at: |
thomashaine | 0:e7352f4f3dcb | 16 | * opensource.org/licenses/BSD-3-Clause |
thomashaine | 0:e7352f4f3dcb | 17 | * |
thomashaine | 0:e7352f4f3dcb | 18 | ****************************************************************************** |
thomashaine | 0:e7352f4f3dcb | 19 | */ |
thomashaine | 0:e7352f4f3dcb | 20 | /* USER CODE END Header */ |
thomashaine | 0:e7352f4f3dcb | 21 | |
thomashaine | 0:e7352f4f3dcb | 22 | |
thomashaine | 0:e7352f4f3dcb | 23 | /* Includes ------------------------------------------------------------------*/ |
thomashaine | 0:e7352f4f3dcb | 24 | |
thomashaine | 0:e7352f4f3dcb | 25 | #include "stm32h7xx_hal.h" |
thomashaine | 0:e7352f4f3dcb | 26 | #include "main.h" |
thomashaine | 0:e7352f4f3dcb | 27 | |
thomashaine | 0:e7352f4f3dcb | 28 | |
thomashaine | 0:e7352f4f3dcb | 29 | |
thomashaine | 0:e7352f4f3dcb | 30 | extern DMA_HandleTypeDef hdma_dcmi; |
thomashaine | 0:e7352f4f3dcb | 31 | |
thomashaine | 0:e7352f4f3dcb | 32 | extern "C" void _Error_Handler(char *, int); |
thomashaine | 0:e7352f4f3dcb | 33 | |
thomashaine | 0:e7352f4f3dcb | 34 | |
thomashaine | 0:e7352f4f3dcb | 35 | /** |
thomashaine | 0:e7352f4f3dcb | 36 | * Initializes the Global MSP. |
thomashaine | 0:e7352f4f3dcb | 37 | */ |
thomashaine | 0:e7352f4f3dcb | 38 | void HAL_MspInit(void) |
thomashaine | 0:e7352f4f3dcb | 39 | { |
thomashaine | 0:e7352f4f3dcb | 40 | |
thomashaine | 0:e7352f4f3dcb | 41 | __HAL_RCC_SYSCFG_CLK_ENABLE(); |
thomashaine | 0:e7352f4f3dcb | 42 | |
thomashaine | 0:e7352f4f3dcb | 43 | } |
thomashaine | 0:e7352f4f3dcb | 44 | |
thomashaine | 0:e7352f4f3dcb | 45 | |
thomashaine | 0:e7352f4f3dcb | 46 | /** |
thomashaine | 0:e7352f4f3dcb | 47 | * @brief DCMI MSP Initialization |
thomashaine | 0:e7352f4f3dcb | 48 | * This function configures the hardware resources used in this example |
thomashaine | 0:e7352f4f3dcb | 49 | * @param hdcmi: DCMI handle pointer |
thomashaine | 0:e7352f4f3dcb | 50 | * @retval None |
thomashaine | 0:e7352f4f3dcb | 51 | */ |
thomashaine | 0:e7352f4f3dcb | 52 | void HAL_DCMI_MspInit(DCMI_HandleTypeDef* hdcmi) |
thomashaine | 0:e7352f4f3dcb | 53 | { |
thomashaine | 0:e7352f4f3dcb | 54 | GPIO_InitTypeDef GPIO_InitStruct = {0}; |
thomashaine | 0:e7352f4f3dcb | 55 | if(hdcmi->Instance==DCMI) |
thomashaine | 0:e7352f4f3dcb | 56 | { |
thomashaine | 0:e7352f4f3dcb | 57 | /* USER CODE BEGIN DCMI_MspInit 0 */ |
thomashaine | 0:e7352f4f3dcb | 58 | |
thomashaine | 0:e7352f4f3dcb | 59 | /* USER CODE END DCMI_MspInit 0 */ |
thomashaine | 0:e7352f4f3dcb | 60 | /* Peripheral clock enable */ |
thomashaine | 0:e7352f4f3dcb | 61 | __HAL_RCC_DCMI_CLK_ENABLE(); |
thomashaine | 0:e7352f4f3dcb | 62 | |
thomashaine | 0:e7352f4f3dcb | 63 | __HAL_RCC_GPIOE_CLK_ENABLE(); |
thomashaine | 0:e7352f4f3dcb | 64 | __HAL_RCC_GPIOA_CLK_ENABLE(); |
thomashaine | 0:e7352f4f3dcb | 65 | __HAL_RCC_GPIOB_CLK_ENABLE(); |
thomashaine | 0:e7352f4f3dcb | 66 | __HAL_RCC_GPIOC_CLK_ENABLE(); |
thomashaine | 0:e7352f4f3dcb | 67 | __HAL_RCC_GPIOD_CLK_ENABLE(); |
thomashaine | 0:e7352f4f3dcb | 68 | __HAL_RCC_GPIOG_CLK_ENABLE(); |
thomashaine | 0:e7352f4f3dcb | 69 | /**DCMI GPIO Configuration |
thomashaine | 0:e7352f4f3dcb | 70 | PE4 ------> DCMI_D4 |
thomashaine | 0:e7352f4f3dcb | 71 | PE5 ------> DCMI_D6 |
thomashaine | 0:e7352f4f3dcb | 72 | PE6 ------> DCMI_D7 |
thomashaine | 0:e7352f4f3dcb | 73 | PA4 ------> DCMI_HSYNC |
thomashaine | 0:e7352f4f3dcb | 74 | PA6 ------> DCMI_PIXCLK |
thomashaine | 0:e7352f4f3dcb | 75 | PB13 ------> DCMI_D2 |
thomashaine | 0:e7352f4f3dcb | 76 | PC6 ------> DCMI_D0 |
thomashaine | 0:e7352f4f3dcb | 77 | PC7 ------> DCMI_D1 |
thomashaine | 0:e7352f4f3dcb | 78 | PC9 ------> DCMI_D3 |
thomashaine | 0:e7352f4f3dcb | 79 | PC10 ------> DCMI_D8 |
thomashaine | 0:e7352f4f3dcb | 80 | PC12 ------> DCMI_D9 |
thomashaine | 0:e7352f4f3dcb | 81 | PD3 ------> DCMI_D5 |
thomashaine | 0:e7352f4f3dcb | 82 | PG9 ------> DCMI_VSYNC |
thomashaine | 0:e7352f4f3dcb | 83 | */ |
thomashaine | 0:e7352f4f3dcb | 84 | GPIO_InitStruct.Pin = GPIO_PIN_4|GPIO_PIN_5|GPIO_PIN_6; |
thomashaine | 0:e7352f4f3dcb | 85 | GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; |
thomashaine | 0:e7352f4f3dcb | 86 | GPIO_InitStruct.Pull = GPIO_NOPULL; |
thomashaine | 0:e7352f4f3dcb | 87 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; |
thomashaine | 0:e7352f4f3dcb | 88 | GPIO_InitStruct.Alternate = GPIO_AF13_DCMI; |
thomashaine | 0:e7352f4f3dcb | 89 | HAL_GPIO_Init(GPIOE, &GPIO_InitStruct); |
thomashaine | 0:e7352f4f3dcb | 90 | |
thomashaine | 0:e7352f4f3dcb | 91 | GPIO_InitStruct.Pin = GPIO_PIN_4|GPIO_PIN_6; |
thomashaine | 0:e7352f4f3dcb | 92 | GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; |
thomashaine | 0:e7352f4f3dcb | 93 | GPIO_InitStruct.Pull = GPIO_NOPULL; |
thomashaine | 0:e7352f4f3dcb | 94 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; |
thomashaine | 0:e7352f4f3dcb | 95 | GPIO_InitStruct.Alternate = GPIO_AF13_DCMI; |
thomashaine | 0:e7352f4f3dcb | 96 | HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); |
thomashaine | 0:e7352f4f3dcb | 97 | |
thomashaine | 0:e7352f4f3dcb | 98 | GPIO_InitStruct.Pin = GPIO_PIN_13; |
thomashaine | 0:e7352f4f3dcb | 99 | GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; |
thomashaine | 0:e7352f4f3dcb | 100 | GPIO_InitStruct.Pull = GPIO_NOPULL; |
thomashaine | 0:e7352f4f3dcb | 101 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; |
thomashaine | 0:e7352f4f3dcb | 102 | GPIO_InitStruct.Alternate = GPIO_AF13_DCMI; |
thomashaine | 0:e7352f4f3dcb | 103 | HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); |
thomashaine | 0:e7352f4f3dcb | 104 | |
thomashaine | 0:e7352f4f3dcb | 105 | GPIO_InitStruct.Pin = GPIO_PIN_6|GPIO_PIN_7|GPIO_PIN_9|GPIO_PIN_10 |
thomashaine | 0:e7352f4f3dcb | 106 | |GPIO_PIN_12; |
thomashaine | 0:e7352f4f3dcb | 107 | GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; |
thomashaine | 0:e7352f4f3dcb | 108 | GPIO_InitStruct.Pull = GPIO_NOPULL; |
thomashaine | 0:e7352f4f3dcb | 109 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; |
thomashaine | 0:e7352f4f3dcb | 110 | GPIO_InitStruct.Alternate = GPIO_AF13_DCMI; |
thomashaine | 0:e7352f4f3dcb | 111 | HAL_GPIO_Init(GPIOC, &GPIO_InitStruct); |
thomashaine | 0:e7352f4f3dcb | 112 | |
thomashaine | 0:e7352f4f3dcb | 113 | GPIO_InitStruct.Pin = GPIO_PIN_3; |
thomashaine | 0:e7352f4f3dcb | 114 | GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; |
thomashaine | 0:e7352f4f3dcb | 115 | GPIO_InitStruct.Pull = GPIO_NOPULL; |
thomashaine | 0:e7352f4f3dcb | 116 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; |
thomashaine | 0:e7352f4f3dcb | 117 | GPIO_InitStruct.Alternate = GPIO_AF13_DCMI; |
thomashaine | 0:e7352f4f3dcb | 118 | HAL_GPIO_Init(GPIOD, &GPIO_InitStruct); |
thomashaine | 0:e7352f4f3dcb | 119 | |
thomashaine | 0:e7352f4f3dcb | 120 | GPIO_InitStruct.Pin = GPIO_PIN_9; |
thomashaine | 0:e7352f4f3dcb | 121 | GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; |
thomashaine | 0:e7352f4f3dcb | 122 | GPIO_InitStruct.Pull = GPIO_NOPULL; |
thomashaine | 0:e7352f4f3dcb | 123 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; |
thomashaine | 0:e7352f4f3dcb | 124 | GPIO_InitStruct.Alternate = GPIO_AF13_DCMI; |
thomashaine | 0:e7352f4f3dcb | 125 | HAL_GPIO_Init(GPIOG, &GPIO_InitStruct); |
thomashaine | 0:e7352f4f3dcb | 126 | |
thomashaine | 0:e7352f4f3dcb | 127 | |
thomashaine | 0:e7352f4f3dcb | 128 | /* DCMI DMA Init */ |
thomashaine | 0:e7352f4f3dcb | 129 | /* DCMI_PSSI Init */ |
thomashaine | 0:e7352f4f3dcb | 130 | hdma_dcmi.Instance = DMA1_Stream0; |
thomashaine | 0:e7352f4f3dcb | 131 | //hdma_dcmi.Init.Request = DMA_REQUEST_DCMI_PSSI; |
thomashaine | 0:e7352f4f3dcb | 132 | hdma_dcmi.Init.Direction = DMA_PERIPH_TO_MEMORY; |
thomashaine | 0:e7352f4f3dcb | 133 | hdma_dcmi.Init.PeriphInc = DMA_PINC_DISABLE; |
thomashaine | 0:e7352f4f3dcb | 134 | hdma_dcmi.Init.MemInc = DMA_MINC_ENABLE; |
thomashaine | 0:e7352f4f3dcb | 135 | hdma_dcmi.Init.PeriphDataAlignment = DMA_PDATAALIGN_WORD; |
thomashaine | 0:e7352f4f3dcb | 136 | hdma_dcmi.Init.MemDataAlignment = DMA_MDATAALIGN_WORD; |
thomashaine | 0:e7352f4f3dcb | 137 | hdma_dcmi.Init.Mode = DMA_CIRCULAR; |
thomashaine | 0:e7352f4f3dcb | 138 | hdma_dcmi.Init.Priority = DMA_PRIORITY_HIGH; |
thomashaine | 0:e7352f4f3dcb | 139 | hdma_dcmi.Init.FIFOMode = DMA_FIFOMODE_ENABLE; |
thomashaine | 0:e7352f4f3dcb | 140 | hdma_dcmi.Init.FIFOThreshold = DMA_FIFO_THRESHOLD_FULL; |
thomashaine | 0:e7352f4f3dcb | 141 | hdma_dcmi.Init.MemBurst = DMA_MBURST_INC4; |
thomashaine | 0:e7352f4f3dcb | 142 | hdma_dcmi.Init.PeriphBurst = DMA_PBURST_SINGLE; |
thomashaine | 0:e7352f4f3dcb | 143 | if (HAL_DMA_Init(&hdma_dcmi) != HAL_OK) |
thomashaine | 0:e7352f4f3dcb | 144 | { |
thomashaine | 0:e7352f4f3dcb | 145 | Error_Handler(); |
thomashaine | 0:e7352f4f3dcb | 146 | } |
thomashaine | 0:e7352f4f3dcb | 147 | |
thomashaine | 0:e7352f4f3dcb | 148 | /* USER CODE BEGIN DCMI_MspInit 1 */ |
thomashaine | 0:e7352f4f3dcb | 149 | |
thomashaine | 0:e7352f4f3dcb | 150 | /* USER CODE END DCMI_MspInit 1 */ |
thomashaine | 0:e7352f4f3dcb | 151 | } |
thomashaine | 0:e7352f4f3dcb | 152 | |
thomashaine | 0:e7352f4f3dcb | 153 | } |
thomashaine | 0:e7352f4f3dcb | 154 | |
thomashaine | 0:e7352f4f3dcb | 155 | /** |
thomashaine | 0:e7352f4f3dcb | 156 | * @brief DCMI MSP De-Initialization |
thomashaine | 0:e7352f4f3dcb | 157 | * This function freeze the hardware resources used in this example |
thomashaine | 0:e7352f4f3dcb | 158 | * @param hdcmi: DCMI handle pointer |
thomashaine | 0:e7352f4f3dcb | 159 | * @retval None |
thomashaine | 0:e7352f4f3dcb | 160 | */ |
thomashaine | 0:e7352f4f3dcb | 161 | void HAL_DCMI_MspDeInit(DCMI_HandleTypeDef* hdcmi) |
thomashaine | 0:e7352f4f3dcb | 162 | { |
thomashaine | 0:e7352f4f3dcb | 163 | if(hdcmi->Instance==DCMI) |
thomashaine | 0:e7352f4f3dcb | 164 | { |
thomashaine | 0:e7352f4f3dcb | 165 | /* USER CODE BEGIN DCMI_MspDeInit 0 */ |
thomashaine | 0:e7352f4f3dcb | 166 | |
thomashaine | 0:e7352f4f3dcb | 167 | /* USER CODE END DCMI_MspDeInit 0 */ |
thomashaine | 0:e7352f4f3dcb | 168 | /* Peripheral clock disable */ |
thomashaine | 0:e7352f4f3dcb | 169 | __HAL_RCC_DCMI_CLK_DISABLE(); |
thomashaine | 0:e7352f4f3dcb | 170 | |
thomashaine | 0:e7352f4f3dcb | 171 | /**DCMI GPIO Configuration |
thomashaine | 0:e7352f4f3dcb | 172 | PE4 ------> DCMI_D4 |
thomashaine | 0:e7352f4f3dcb | 173 | PE5 ------> DCMI_D6 |
thomashaine | 0:e7352f4f3dcb | 174 | PE6 ------> DCMI_D7 |
thomashaine | 0:e7352f4f3dcb | 175 | PA4 ------> DCMI_HSYNC |
thomashaine | 0:e7352f4f3dcb | 176 | PA6 ------> DCMI_PIXCLK |
thomashaine | 0:e7352f4f3dcb | 177 | PB13 ------> DCMI_D2 |
thomashaine | 0:e7352f4f3dcb | 178 | PC6 ------> DCMI_D0 |
thomashaine | 0:e7352f4f3dcb | 179 | PC7 ------> DCMI_D1 |
thomashaine | 0:e7352f4f3dcb | 180 | PC9 ------> DCMI_D3 |
thomashaine | 0:e7352f4f3dcb | 181 | PC10 ------> DCMI_D8 |
thomashaine | 0:e7352f4f3dcb | 182 | PC12 ------> DCMI_D9 |
thomashaine | 0:e7352f4f3dcb | 183 | PD3 ------> DCMI_D5 |
thomashaine | 0:e7352f4f3dcb | 184 | PG9 ------> DCMI_VSYNC |
thomashaine | 0:e7352f4f3dcb | 185 | */ |
thomashaine | 0:e7352f4f3dcb | 186 | HAL_GPIO_DeInit(GPIOE, GPIO_PIN_4|GPIO_PIN_5|GPIO_PIN_6); |
thomashaine | 0:e7352f4f3dcb | 187 | |
thomashaine | 0:e7352f4f3dcb | 188 | HAL_GPIO_DeInit(GPIOA, GPIO_PIN_4|GPIO_PIN_6); |
thomashaine | 0:e7352f4f3dcb | 189 | |
thomashaine | 0:e7352f4f3dcb | 190 | HAL_GPIO_DeInit(GPIOB, GPIO_PIN_13); |
thomashaine | 0:e7352f4f3dcb | 191 | |
thomashaine | 0:e7352f4f3dcb | 192 | HAL_GPIO_DeInit(GPIOC, GPIO_PIN_6|GPIO_PIN_7|GPIO_PIN_9|GPIO_PIN_10 |
thomashaine | 0:e7352f4f3dcb | 193 | |GPIO_PIN_12); |
thomashaine | 0:e7352f4f3dcb | 194 | |
thomashaine | 0:e7352f4f3dcb | 195 | HAL_GPIO_DeInit(GPIOD, GPIO_PIN_3); |
thomashaine | 0:e7352f4f3dcb | 196 | |
thomashaine | 0:e7352f4f3dcb | 197 | HAL_GPIO_DeInit(GPIOG, GPIO_PIN_9); |
thomashaine | 0:e7352f4f3dcb | 198 | |
thomashaine | 0:e7352f4f3dcb | 199 | /* DCMI DMA DeInit */ |
thomashaine | 0:e7352f4f3dcb | 200 | /* USER CODE BEGIN DCMI_MspDeInit 1 */ |
thomashaine | 0:e7352f4f3dcb | 201 | |
thomashaine | 0:e7352f4f3dcb | 202 | /* USER CODE END DCMI_MspDeInit 1 */ |
thomashaine | 0:e7352f4f3dcb | 203 | } |
thomashaine | 0:e7352f4f3dcb | 204 | |
thomashaine | 0:e7352f4f3dcb | 205 | } |
thomashaine | 0:e7352f4f3dcb | 206 | |
thomashaine | 0:e7352f4f3dcb | 207 | |
thomashaine | 0:e7352f4f3dcb | 208 | /* USER CODE BEGIN 1 */ |
thomashaine | 0:e7352f4f3dcb | 209 | |
thomashaine | 0:e7352f4f3dcb | 210 | /* USER CODE END 1 */ |
thomashaine | 0:e7352f4f3dcb | 211 | |
thomashaine | 0:e7352f4f3dcb | 212 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |