stm32f7xx_hal_msp.c 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672
  1. /* USER CODE BEGIN Header */
  2. /**
  3. ******************************************************************************
  4. * File Name : stm32f7xx_hal_msp.c
  5. * Description : This file provides code for the MSP Initialization
  6. * and de-Initialization codes.
  7. ******************************************************************************
  8. ** This notice applies to any and all portions of this file
  9. * that are not between comment pairs USER CODE BEGIN and
  10. * USER CODE END. Other portions of this file, whether
  11. * inserted by the user or by software development tools
  12. * are owned by their respective copyright owners.
  13. *
  14. * COPYRIGHT(c) 2018 STMicroelectronics
  15. *
  16. * Redistribution and use in source and binary forms, with or without modification,
  17. * are permitted provided that the following conditions are met:
  18. * 1. Redistributions of source code must retain the above copyright notice,
  19. * this list of conditions and the following disclaimer.
  20. * 2. Redistributions in binary form must reproduce the above copyright notice,
  21. * this list of conditions and the following disclaimer in the documentation
  22. * and/or other materials provided with the distribution.
  23. * 3. Neither the name of STMicroelectronics nor the names of its contributors
  24. * may be used to endorse or promote products derived from this software
  25. * without specific prior written permission.
  26. *
  27. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  28. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  29. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  30. * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
  31. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  32. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  33. * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  34. * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  35. * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  36. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  37. *
  38. ******************************************************************************
  39. */
  40. /* USER CODE END Header */
  41. /* Includes ------------------------------------------------------------------*/
  42. #include "main.h"
  43. /* USER CODE BEGIN Includes */
  44. /* USER CODE END Includes */
  45. /* Private typedef -----------------------------------------------------------*/
  46. /* USER CODE BEGIN TD */
  47. /* USER CODE END TD */
  48. /* Private define ------------------------------------------------------------*/
  49. /* USER CODE BEGIN Define */
  50. /* USER CODE END Define */
  51. /* Private macro -------------------------------------------------------------*/
  52. /* USER CODE BEGIN Macro */
  53. /* USER CODE END Macro */
  54. /* Private variables ---------------------------------------------------------*/
  55. /* USER CODE BEGIN PV */
  56. /* USER CODE END PV */
  57. /* Private function prototypes -----------------------------------------------*/
  58. /* USER CODE BEGIN PFP */
  59. /* USER CODE END PFP */
  60. /* External functions --------------------------------------------------------*/
  61. /* USER CODE BEGIN ExternalFunctions */
  62. /* USER CODE END ExternalFunctions */
  63. /* USER CODE BEGIN 0 */
  64. /* USER CODE END 0 */
  65. /**
  66. * Initializes the Global MSP.
  67. */
  68. void HAL_MspInit(void)
  69. {
  70. /* USER CODE BEGIN MspInit 0 */
  71. /* USER CODE END MspInit 0 */
  72. __HAL_RCC_PWR_CLK_ENABLE();
  73. __HAL_RCC_SYSCFG_CLK_ENABLE();
  74. /* System interrupt init*/
  75. /* USER CODE BEGIN MspInit 1 */
  76. /* USER CODE END MspInit 1 */
  77. }
  78. /**
  79. * @brief ETH MSP Initialization
  80. * This function configures the hardware resources used in this example
  81. * @param heth: ETH handle pointer
  82. * @retval None
  83. */
  84. void HAL_ETH_MspInit(ETH_HandleTypeDef* heth)
  85. {
  86. GPIO_InitTypeDef GPIO_InitStruct = {0};
  87. if(heth->Instance==ETH)
  88. {
  89. /* USER CODE BEGIN ETH_MspInit 0 */
  90. /* USER CODE END ETH_MspInit 0 */
  91. /* Peripheral clock enable */
  92. __HAL_RCC_ETH_CLK_ENABLE();
  93. __HAL_RCC_GPIOG_CLK_ENABLE();
  94. __HAL_RCC_GPIOC_CLK_ENABLE();
  95. __HAL_RCC_GPIOA_CLK_ENABLE();
  96. /**ETH GPIO Configuration
  97. PG14 ------> ETH_TXD1
  98. PG13 ------> ETH_TXD0
  99. PG11 ------> ETH_TX_EN
  100. PC1 ------> ETH_MDC
  101. PA1 ------> ETH_REF_CLK
  102. PC4 ------> ETH_RXD0
  103. PA2 ------> ETH_MDIO
  104. PC5 ------> ETH_RXD1
  105. PA7 ------> ETH_CRS_DV
  106. */
  107. GPIO_InitStruct.Pin = GPIO_PIN_14|GPIO_PIN_13|GPIO_PIN_11;
  108. GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
  109. GPIO_InitStruct.Pull = GPIO_NOPULL;
  110. GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
  111. GPIO_InitStruct.Alternate = GPIO_AF11_ETH;
  112. HAL_GPIO_Init(GPIOG, &GPIO_InitStruct);
  113. GPIO_InitStruct.Pin = GPIO_PIN_1|GPIO_PIN_4|GPIO_PIN_5;
  114. GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
  115. GPIO_InitStruct.Pull = GPIO_NOPULL;
  116. GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
  117. GPIO_InitStruct.Alternate = GPIO_AF11_ETH;
  118. HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
  119. GPIO_InitStruct.Pin = GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_7;
  120. GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
  121. GPIO_InitStruct.Pull = GPIO_NOPULL;
  122. GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
  123. GPIO_InitStruct.Alternate = GPIO_AF11_ETH;
  124. HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
  125. /* USER CODE BEGIN ETH_MspInit 1 */
  126. /* USER CODE END ETH_MspInit 1 */
  127. }
  128. }
  129. /**
  130. * @brief ETH MSP De-Initialization
  131. * This function freeze the hardware resources used in this example
  132. * @param heth: ETH handle pointer
  133. * @retval None
  134. */
  135. void HAL_ETH_MspDeInit(ETH_HandleTypeDef* heth)
  136. {
  137. if(heth->Instance==ETH)
  138. {
  139. /* USER CODE BEGIN ETH_MspDeInit 0 */
  140. /* USER CODE END ETH_MspDeInit 0 */
  141. /* Peripheral clock disable */
  142. __HAL_RCC_ETH_CLK_DISABLE();
  143. /**ETH GPIO Configuration
  144. PG14 ------> ETH_TXD1
  145. PG13 ------> ETH_TXD0
  146. PG11 ------> ETH_TX_EN
  147. PC1 ------> ETH_MDC
  148. PA1 ------> ETH_REF_CLK
  149. PC4 ------> ETH_RXD0
  150. PA2 ------> ETH_MDIO
  151. PC5 ------> ETH_RXD1
  152. PA7 ------> ETH_CRS_DV
  153. */
  154. HAL_GPIO_DeInit(GPIOG, GPIO_PIN_14|GPIO_PIN_13|GPIO_PIN_11);
  155. HAL_GPIO_DeInit(GPIOC, GPIO_PIN_1|GPIO_PIN_4|GPIO_PIN_5);
  156. HAL_GPIO_DeInit(GPIOA, GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_7);
  157. /* USER CODE BEGIN ETH_MspDeInit 1 */
  158. /* USER CODE END ETH_MspDeInit 1 */
  159. }
  160. }
  161. /**
  162. * @brief QSPI MSP Initialization
  163. * This function configures the hardware resources used in this example
  164. * @param hqspi: QSPI handle pointer
  165. * @retval None
  166. */
  167. void HAL_QSPI_MspInit(QSPI_HandleTypeDef* hqspi)
  168. {
  169. GPIO_InitTypeDef GPIO_InitStruct = {0};
  170. if(hqspi->Instance==QUADSPI)
  171. {
  172. /* USER CODE BEGIN QUADSPI_MspInit 0 */
  173. /* USER CODE END QUADSPI_MspInit 0 */
  174. /* Peripheral clock enable */
  175. __HAL_RCC_QSPI_CLK_ENABLE();
  176. __HAL_RCC_GPIOE_CLK_ENABLE();
  177. __HAL_RCC_GPIOB_CLK_ENABLE();
  178. __HAL_RCC_GPIOD_CLK_ENABLE();
  179. /**QUADSPI GPIO Configuration
  180. PE2 ------> QUADSPI_BK1_IO2
  181. PB6 ------> QUADSPI_BK1_NCS
  182. PB2 ------> QUADSPI_CLK
  183. PD12 ------> QUADSPI_BK1_IO1
  184. PD13 ------> QUADSPI_BK1_IO3
  185. PD11 ------> QUADSPI_BK1_IO0
  186. */
  187. GPIO_InitStruct.Pin = GPIO_PIN_2;
  188. GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
  189. GPIO_InitStruct.Pull = GPIO_NOPULL;
  190. GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
  191. GPIO_InitStruct.Alternate = GPIO_AF9_QUADSPI;
  192. HAL_GPIO_Init(GPIOE, &GPIO_InitStruct);
  193. GPIO_InitStruct.Pin = GPIO_PIN_6;
  194. GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
  195. GPIO_InitStruct.Pull = GPIO_NOPULL;
  196. GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
  197. GPIO_InitStruct.Alternate = GPIO_AF10_QUADSPI;
  198. HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
  199. GPIO_InitStruct.Pin = GPIO_PIN_2;
  200. GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
  201. GPIO_InitStruct.Pull = GPIO_NOPULL;
  202. GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
  203. GPIO_InitStruct.Alternate = GPIO_AF9_QUADSPI;
  204. HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
  205. GPIO_InitStruct.Pin = GPIO_PIN_12|GPIO_PIN_13|GPIO_PIN_11;
  206. GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
  207. GPIO_InitStruct.Pull = GPIO_NOPULL;
  208. GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
  209. GPIO_InitStruct.Alternate = GPIO_AF9_QUADSPI;
  210. HAL_GPIO_Init(GPIOD, &GPIO_InitStruct);
  211. /* USER CODE BEGIN QUADSPI_MspInit 1 */
  212. /* USER CODE END QUADSPI_MspInit 1 */
  213. }
  214. }
  215. /**
  216. * @brief QSPI MSP De-Initialization
  217. * This function freeze the hardware resources used in this example
  218. * @param hqspi: QSPI handle pointer
  219. * @retval None
  220. */
  221. void HAL_QSPI_MspDeInit(QSPI_HandleTypeDef* hqspi)
  222. {
  223. if(hqspi->Instance==QUADSPI)
  224. {
  225. /* USER CODE BEGIN QUADSPI_MspDeInit 0 */
  226. /* USER CODE END QUADSPI_MspDeInit 0 */
  227. /* Peripheral clock disable */
  228. __HAL_RCC_QSPI_CLK_DISABLE();
  229. /**QUADSPI GPIO Configuration
  230. PE2 ------> QUADSPI_BK1_IO2
  231. PB6 ------> QUADSPI_BK1_NCS
  232. PB2 ------> QUADSPI_CLK
  233. PD12 ------> QUADSPI_BK1_IO1
  234. PD13 ------> QUADSPI_BK1_IO3
  235. PD11 ------> QUADSPI_BK1_IO0
  236. */
  237. HAL_GPIO_DeInit(GPIOE, GPIO_PIN_2);
  238. HAL_GPIO_DeInit(GPIOB, GPIO_PIN_6|GPIO_PIN_2);
  239. HAL_GPIO_DeInit(GPIOD, GPIO_PIN_12|GPIO_PIN_13|GPIO_PIN_11);
  240. /* USER CODE BEGIN QUADSPI_MspDeInit 1 */
  241. /* USER CODE END QUADSPI_MspDeInit 1 */
  242. }
  243. }
  244. /**
  245. * @brief SD MSP Initialization
  246. * This function configures the hardware resources used in this example
  247. * @param hsd: SD handle pointer
  248. * @retval None
  249. */
  250. void HAL_SD_MspInit(SD_HandleTypeDef* hsd)
  251. {
  252. GPIO_InitTypeDef GPIO_InitStruct = {0};
  253. if(hsd->Instance==SDMMC1)
  254. {
  255. /* USER CODE BEGIN SDMMC1_MspInit 0 */
  256. /* USER CODE END SDMMC1_MspInit 0 */
  257. /* Peripheral clock enable */
  258. __HAL_RCC_SDMMC1_CLK_ENABLE();
  259. __HAL_RCC_GPIOC_CLK_ENABLE();
  260. __HAL_RCC_GPIOD_CLK_ENABLE();
  261. /**SDMMC1 GPIO Configuration
  262. PC12 ------> SDMMC1_CK
  263. PC11 ------> SDMMC1_D3
  264. PC10 ------> SDMMC1_D2
  265. PD2 ------> SDMMC1_CMD
  266. PC9 ------> SDMMC1_D1
  267. PC8 ------> SDMMC1_D0
  268. */
  269. GPIO_InitStruct.Pin = GPIO_PIN_12|GPIO_PIN_11|GPIO_PIN_10|GPIO_PIN_9
  270. |GPIO_PIN_8;
  271. GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
  272. GPIO_InitStruct.Pull = GPIO_NOPULL;
  273. GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
  274. GPIO_InitStruct.Alternate = GPIO_AF12_SDMMC1;
  275. HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
  276. GPIO_InitStruct.Pin = GPIO_PIN_2;
  277. GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
  278. GPIO_InitStruct.Pull = GPIO_NOPULL;
  279. GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
  280. GPIO_InitStruct.Alternate = GPIO_AF12_SDMMC1;
  281. HAL_GPIO_Init(GPIOD, &GPIO_InitStruct);
  282. /* USER CODE BEGIN SDMMC1_MspInit 1 */
  283. /* USER CODE END SDMMC1_MspInit 1 */
  284. }
  285. }
  286. /**
  287. * @brief SD MSP De-Initialization
  288. * This function freeze the hardware resources used in this example
  289. * @param hsd: SD handle pointer
  290. * @retval None
  291. */
  292. void HAL_SD_MspDeInit(SD_HandleTypeDef* hsd)
  293. {
  294. if(hsd->Instance==SDMMC1)
  295. {
  296. /* USER CODE BEGIN SDMMC1_MspDeInit 0 */
  297. /* USER CODE END SDMMC1_MspDeInit 0 */
  298. /* Peripheral clock disable */
  299. __HAL_RCC_SDMMC1_CLK_DISABLE();
  300. /**SDMMC1 GPIO Configuration
  301. PC12 ------> SDMMC1_CK
  302. PC11 ------> SDMMC1_D3
  303. PC10 ------> SDMMC1_D2
  304. PD2 ------> SDMMC1_CMD
  305. PC9 ------> SDMMC1_D1
  306. PC8 ------> SDMMC1_D0
  307. */
  308. HAL_GPIO_DeInit(GPIOC, GPIO_PIN_12|GPIO_PIN_11|GPIO_PIN_10|GPIO_PIN_9
  309. |GPIO_PIN_8);
  310. HAL_GPIO_DeInit(GPIOD, GPIO_PIN_2);
  311. /* USER CODE BEGIN SDMMC1_MspDeInit 1 */
  312. /* USER CODE END SDMMC1_MspDeInit 1 */
  313. }
  314. }
  315. /**
  316. * @brief UART MSP Initialization
  317. * This function configures the hardware resources used in this example
  318. * @param huart: UART handle pointer
  319. * @retval None
  320. */
  321. void HAL_UART_MspInit(UART_HandleTypeDef* huart)
  322. {
  323. GPIO_InitTypeDef GPIO_InitStruct = {0};
  324. if(huart->Instance==USART1)
  325. {
  326. /* USER CODE BEGIN USART1_MspInit 0 */
  327. /* USER CODE END USART1_MspInit 0 */
  328. /* Peripheral clock enable */
  329. __HAL_RCC_USART1_CLK_ENABLE();
  330. __HAL_RCC_GPIOB_CLK_ENABLE();
  331. __HAL_RCC_GPIOA_CLK_ENABLE();
  332. /**USART1 GPIO Configuration
  333. PB7 ------> USART1_RX
  334. PA9 ------> USART1_TX
  335. */
  336. GPIO_InitStruct.Pin = GPIO_PIN_7;
  337. GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
  338. GPIO_InitStruct.Pull = GPIO_NOPULL;
  339. GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
  340. GPIO_InitStruct.Alternate = GPIO_AF7_USART1;
  341. HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
  342. GPIO_InitStruct.Pin = GPIO_PIN_9;
  343. GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
  344. GPIO_InitStruct.Pull = GPIO_NOPULL;
  345. GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
  346. GPIO_InitStruct.Alternate = GPIO_AF7_USART1;
  347. HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
  348. /* USER CODE BEGIN USART1_MspInit 1 */
  349. /* USER CODE END USART1_MspInit 1 */
  350. }
  351. }
  352. /**
  353. * @brief UART MSP De-Initialization
  354. * This function freeze the hardware resources used in this example
  355. * @param huart: UART handle pointer
  356. * @retval None
  357. */
  358. void HAL_UART_MspDeInit(UART_HandleTypeDef* huart)
  359. {
  360. if(huart->Instance==USART1)
  361. {
  362. /* USER CODE BEGIN USART1_MspDeInit 0 */
  363. /* USER CODE END USART1_MspDeInit 0 */
  364. /* Peripheral clock disable */
  365. __HAL_RCC_USART1_CLK_DISABLE();
  366. /**USART1 GPIO Configuration
  367. PB7 ------> USART1_RX
  368. PA9 ------> USART1_TX
  369. */
  370. HAL_GPIO_DeInit(GPIOB, GPIO_PIN_7);
  371. HAL_GPIO_DeInit(GPIOA, GPIO_PIN_9);
  372. /* USER CODE BEGIN USART1_MspDeInit 1 */
  373. /* USER CODE END USART1_MspDeInit 1 */
  374. }
  375. }
  376. static uint32_t FMC_Initialized = 0;
  377. static void HAL_FMC_MspInit(void){
  378. /* USER CODE BEGIN FMC_MspInit 0 */
  379. /* USER CODE END FMC_MspInit 0 */
  380. GPIO_InitTypeDef GPIO_InitStruct;
  381. if (FMC_Initialized) {
  382. return;
  383. }
  384. FMC_Initialized = 1;
  385. /* Peripheral clock enable */
  386. __HAL_RCC_FMC_CLK_ENABLE();
  387. /** FMC GPIO Configuration
  388. PG15 ------> FMC_SDNCAS
  389. PD0 ------> FMC_D2
  390. PD1 ------> FMC_D3
  391. PF0 ------> FMC_A0
  392. PF1 ------> FMC_A1
  393. PF2 ------> FMC_A2
  394. PF3 ------> FMC_A3
  395. PG8 ------> FMC_SDCLK
  396. PF4 ------> FMC_A4
  397. PH5 ------> FMC_SDNWE
  398. PH3 ------> FMC_SDNE0
  399. PF5 ------> FMC_A5
  400. PD15 ------> FMC_D1
  401. PD10 ------> FMC_D15
  402. PC3 ------> FMC_SDCKE0
  403. PD14 ------> FMC_D0
  404. PD9 ------> FMC_D14
  405. PD8 ------> FMC_D13
  406. PF12 ------> FMC_A6
  407. PF15 ------> FMC_A9
  408. PF13 ------> FMC_A7
  409. PG0 ------> FMC_A10
  410. PE8 ------> FMC_D5
  411. PG5 ------> FMC_BA1
  412. PG4 ------> FMC_BA0
  413. PF14 ------> FMC_A8
  414. PF11 ------> FMC_SDNRAS
  415. PE9 ------> FMC_D6
  416. PE11 ------> FMC_D8
  417. PE14 ------> FMC_D11
  418. PE7 ------> FMC_D4
  419. PE10 ------> FMC_D7
  420. PE12 ------> FMC_D9
  421. PE15 ------> FMC_D12
  422. PE13 ------> FMC_D10
  423. */
  424. GPIO_InitStruct.Pin = GPIO_PIN_15|GPIO_PIN_8|GPIO_PIN_0|GPIO_PIN_5
  425. |GPIO_PIN_4;
  426. GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
  427. GPIO_InitStruct.Pull = GPIO_NOPULL;
  428. GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
  429. GPIO_InitStruct.Alternate = GPIO_AF12_FMC;
  430. HAL_GPIO_Init(GPIOG, &GPIO_InitStruct);
  431. GPIO_InitStruct.Pin = GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_15|GPIO_PIN_10
  432. |GPIO_PIN_14|GPIO_PIN_9|GPIO_PIN_8;
  433. GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
  434. GPIO_InitStruct.Pull = GPIO_NOPULL;
  435. GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
  436. GPIO_InitStruct.Alternate = GPIO_AF12_FMC;
  437. HAL_GPIO_Init(GPIOD, &GPIO_InitStruct);
  438. GPIO_InitStruct.Pin = GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3
  439. |GPIO_PIN_4|GPIO_PIN_5|GPIO_PIN_12|GPIO_PIN_15
  440. |GPIO_PIN_13|GPIO_PIN_14|GPIO_PIN_11;
  441. GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
  442. GPIO_InitStruct.Pull = GPIO_NOPULL;
  443. GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
  444. GPIO_InitStruct.Alternate = GPIO_AF12_FMC;
  445. HAL_GPIO_Init(GPIOF, &GPIO_InitStruct);
  446. GPIO_InitStruct.Pin = GPIO_PIN_5|GPIO_PIN_3;
  447. GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
  448. GPIO_InitStruct.Pull = GPIO_NOPULL;
  449. GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
  450. GPIO_InitStruct.Alternate = GPIO_AF12_FMC;
  451. HAL_GPIO_Init(GPIOH, &GPIO_InitStruct);
  452. GPIO_InitStruct.Pin = GPIO_PIN_3;
  453. GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
  454. GPIO_InitStruct.Pull = GPIO_NOPULL;
  455. GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
  456. GPIO_InitStruct.Alternate = GPIO_AF12_FMC;
  457. HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
  458. GPIO_InitStruct.Pin = GPIO_PIN_8|GPIO_PIN_9|GPIO_PIN_11|GPIO_PIN_14
  459. |GPIO_PIN_7|GPIO_PIN_10|GPIO_PIN_12|GPIO_PIN_15
  460. |GPIO_PIN_13;
  461. GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
  462. GPIO_InitStruct.Pull = GPIO_NOPULL;
  463. GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
  464. GPIO_InitStruct.Alternate = GPIO_AF12_FMC;
  465. HAL_GPIO_Init(GPIOE, &GPIO_InitStruct);
  466. /* USER CODE BEGIN FMC_MspInit 1 */
  467. /* USER CODE END FMC_MspInit 1 */
  468. }
  469. void HAL_SDRAM_MspInit(SDRAM_HandleTypeDef* hsdram){
  470. /* USER CODE BEGIN SDRAM_MspInit 0 */
  471. /* USER CODE END SDRAM_MspInit 0 */
  472. HAL_FMC_MspInit();
  473. /* USER CODE BEGIN SDRAM_MspInit 1 */
  474. /* USER CODE END SDRAM_MspInit 1 */
  475. }
  476. static uint32_t FMC_DeInitialized = 0;
  477. static void HAL_FMC_MspDeInit(void){
  478. /* USER CODE BEGIN FMC_MspDeInit 0 */
  479. /* USER CODE END FMC_MspDeInit 0 */
  480. if (FMC_DeInitialized) {
  481. return;
  482. }
  483. FMC_DeInitialized = 1;
  484. /* Peripheral clock enable */
  485. __HAL_RCC_FMC_CLK_DISABLE();
  486. /** FMC GPIO Configuration
  487. PG15 ------> FMC_SDNCAS
  488. PD0 ------> FMC_D2
  489. PD1 ------> FMC_D3
  490. PF0 ------> FMC_A0
  491. PF1 ------> FMC_A1
  492. PF2 ------> FMC_A2
  493. PF3 ------> FMC_A3
  494. PG8 ------> FMC_SDCLK
  495. PF4 ------> FMC_A4
  496. PH5 ------> FMC_SDNWE
  497. PH3 ------> FMC_SDNE0
  498. PF5 ------> FMC_A5
  499. PD15 ------> FMC_D1
  500. PD10 ------> FMC_D15
  501. PC3 ------> FMC_SDCKE0
  502. PD14 ------> FMC_D0
  503. PD9 ------> FMC_D14
  504. PD8 ------> FMC_D13
  505. PF12 ------> FMC_A6
  506. PF15 ------> FMC_A9
  507. PF13 ------> FMC_A7
  508. PG0 ------> FMC_A10
  509. PE8 ------> FMC_D5
  510. PG5 ------> FMC_BA1
  511. PG4 ------> FMC_BA0
  512. PF14 ------> FMC_A8
  513. PF11 ------> FMC_SDNRAS
  514. PE9 ------> FMC_D6
  515. PE11 ------> FMC_D8
  516. PE14 ------> FMC_D11
  517. PE7 ------> FMC_D4
  518. PE10 ------> FMC_D7
  519. PE12 ------> FMC_D9
  520. PE15 ------> FMC_D12
  521. PE13 ------> FMC_D10
  522. */
  523. HAL_GPIO_DeInit(GPIOG, GPIO_PIN_15|GPIO_PIN_8|GPIO_PIN_0|GPIO_PIN_5
  524. |GPIO_PIN_4);
  525. HAL_GPIO_DeInit(GPIOD, GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_15|GPIO_PIN_10
  526. |GPIO_PIN_14|GPIO_PIN_9|GPIO_PIN_8);
  527. HAL_GPIO_DeInit(GPIOF, GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3
  528. |GPIO_PIN_4|GPIO_PIN_5|GPIO_PIN_12|GPIO_PIN_15
  529. |GPIO_PIN_13|GPIO_PIN_14|GPIO_PIN_11);
  530. HAL_GPIO_DeInit(GPIOH, GPIO_PIN_5|GPIO_PIN_3);
  531. HAL_GPIO_DeInit(GPIOC, GPIO_PIN_3);
  532. HAL_GPIO_DeInit(GPIOE, GPIO_PIN_8|GPIO_PIN_9|GPIO_PIN_11|GPIO_PIN_14
  533. |GPIO_PIN_7|GPIO_PIN_10|GPIO_PIN_12|GPIO_PIN_15
  534. |GPIO_PIN_13);
  535. /* USER CODE BEGIN FMC_MspDeInit 1 */
  536. /* USER CODE END FMC_MspDeInit 1 */
  537. }
  538. void HAL_SDRAM_MspDeInit(SDRAM_HandleTypeDef* hsdram){
  539. /* USER CODE BEGIN SDRAM_MspDeInit 0 */
  540. /* USER CODE END SDRAM_MspDeInit 0 */
  541. HAL_FMC_MspDeInit();
  542. /* USER CODE BEGIN SDRAM_MspDeInit 1 */
  543. /* USER CODE END SDRAM_MspDeInit 1 */
  544. }
  545. /* USER CODE BEGIN 1 */
  546. /* USER CODE END 1 */
  547. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/