stm32f4xx_hal_msp.c 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011
  1. /* USER CODE BEGIN Header */
  2. /**
  3. ******************************************************************************
  4. * File Name : stm32f4xx_hal_msp.c
  5. * Description : This file provides code for the MSP Initialization
  6. * and de-Initialization codes.
  7. ******************************************************************************
  8. * @attention
  9. *
  10. * <h2><center>&copy; Copyright (c) 2019 STMicroelectronics.
  11. * All rights reserved.</center></h2>
  12. *
  13. * This software component is licensed by ST under BSD 3-Clause license,
  14. * the "License"; You may not use this file except in compliance with the
  15. * License. You may obtain a copy of the License at:
  16. * opensource.org/licenses/BSD-3-Clause
  17. *
  18. ******************************************************************************
  19. */
  20. /* USER CODE END Header */
  21. /* Includes ------------------------------------------------------------------*/
  22. #include "main.h"
  23. /* USER CODE BEGIN Includes */
  24. /* USER CODE END Includes */
  25. /* Private typedef -----------------------------------------------------------*/
  26. /* USER CODE BEGIN TD */
  27. /* USER CODE END TD */
  28. /* Private define ------------------------------------------------------------*/
  29. /* USER CODE BEGIN Define */
  30. /* USER CODE END Define */
  31. /* Private macro -------------------------------------------------------------*/
  32. /* USER CODE BEGIN Macro */
  33. /* USER CODE END Macro */
  34. /* Private variables ---------------------------------------------------------*/
  35. /* USER CODE BEGIN PV */
  36. /* USER CODE END PV */
  37. /* Private function prototypes -----------------------------------------------*/
  38. /* USER CODE BEGIN PFP */
  39. /* USER CODE END PFP */
  40. /* External functions --------------------------------------------------------*/
  41. /* USER CODE BEGIN ExternalFunctions */
  42. /* USER CODE END ExternalFunctions */
  43. /* USER CODE BEGIN 0 */
  44. /* USER CODE END 0 */
  45. void HAL_TIM_MspPostInit(TIM_HandleTypeDef *htim);
  46. /**
  47. * Initializes the Global MSP.
  48. */
  49. void HAL_MspInit(void)
  50. {
  51. /* USER CODE BEGIN MspInit 0 */
  52. /* USER CODE END MspInit 0 */
  53. __HAL_RCC_SYSCFG_CLK_ENABLE();
  54. __HAL_RCC_PWR_CLK_ENABLE();
  55. /* System interrupt init*/
  56. /* USER CODE BEGIN MspInit 1 */
  57. /* USER CODE END MspInit 1 */
  58. }
  59. /**
  60. * @brief CRC MSP Initialization
  61. * This function configures the hardware resources used in this example
  62. * @param hcrc: CRC handle pointer
  63. * @retval None
  64. */
  65. void HAL_CRC_MspInit(CRC_HandleTypeDef* hcrc)
  66. {
  67. if(hcrc->Instance==CRC)
  68. {
  69. /* USER CODE BEGIN CRC_MspInit 0 */
  70. /* USER CODE END CRC_MspInit 0 */
  71. /* Peripheral clock enable */
  72. __HAL_RCC_CRC_CLK_ENABLE();
  73. /* USER CODE BEGIN CRC_MspInit 1 */
  74. /* USER CODE END CRC_MspInit 1 */
  75. }
  76. }
  77. /**
  78. * @brief CRC MSP De-Initialization
  79. * This function freeze the hardware resources used in this example
  80. * @param hcrc: CRC handle pointer
  81. * @retval None
  82. */
  83. void HAL_CRC_MspDeInit(CRC_HandleTypeDef* hcrc)
  84. {
  85. if(hcrc->Instance==CRC)
  86. {
  87. /* USER CODE BEGIN CRC_MspDeInit 0 */
  88. /* USER CODE END CRC_MspDeInit 0 */
  89. /* Peripheral clock disable */
  90. __HAL_RCC_CRC_CLK_DISABLE();
  91. /* USER CODE BEGIN CRC_MspDeInit 1 */
  92. /* USER CODE END CRC_MspDeInit 1 */
  93. }
  94. }
  95. /**
  96. * @brief DMA2D MSP Initialization
  97. * This function configures the hardware resources used in this example
  98. * @param hdma2d: DMA2D handle pointer
  99. * @retval None
  100. */
  101. void HAL_DMA2D_MspInit(DMA2D_HandleTypeDef* hdma2d)
  102. {
  103. if(hdma2d->Instance==DMA2D)
  104. {
  105. /* USER CODE BEGIN DMA2D_MspInit 0 */
  106. /* USER CODE END DMA2D_MspInit 0 */
  107. /* Peripheral clock enable */
  108. __HAL_RCC_DMA2D_CLK_ENABLE();
  109. /* USER CODE BEGIN DMA2D_MspInit 1 */
  110. /* USER CODE END DMA2D_MspInit 1 */
  111. }
  112. }
  113. /**
  114. * @brief DMA2D MSP De-Initialization
  115. * This function freeze the hardware resources used in this example
  116. * @param hdma2d: DMA2D handle pointer
  117. * @retval None
  118. */
  119. void HAL_DMA2D_MspDeInit(DMA2D_HandleTypeDef* hdma2d)
  120. {
  121. if(hdma2d->Instance==DMA2D)
  122. {
  123. /* USER CODE BEGIN DMA2D_MspDeInit 0 */
  124. /* USER CODE END DMA2D_MspDeInit 0 */
  125. /* Peripheral clock disable */
  126. __HAL_RCC_DMA2D_CLK_DISABLE();
  127. /* USER CODE BEGIN DMA2D_MspDeInit 1 */
  128. /* USER CODE END DMA2D_MspDeInit 1 */
  129. }
  130. }
  131. /**
  132. * @brief DSI MSP Initialization
  133. * This function configures the hardware resources used in this example
  134. * @param hdsi: DSI handle pointer
  135. * @retval None
  136. */
  137. void HAL_DSI_MspInit(DSI_HandleTypeDef* hdsi)
  138. {
  139. if(hdsi->Instance==DSI)
  140. {
  141. /* USER CODE BEGIN DSI_MspInit 0 */
  142. /* USER CODE END DSI_MspInit 0 */
  143. /* Peripheral clock enable */
  144. __HAL_RCC_DSI_CLK_ENABLE();
  145. /* USER CODE BEGIN DSI_MspInit 1 */
  146. /* USER CODE END DSI_MspInit 1 */
  147. }
  148. }
  149. /**
  150. * @brief DSI MSP De-Initialization
  151. * This function freeze the hardware resources used in this example
  152. * @param hdsi: DSI handle pointer
  153. * @retval None
  154. */
  155. void HAL_DSI_MspDeInit(DSI_HandleTypeDef* hdsi)
  156. {
  157. if(hdsi->Instance==DSI)
  158. {
  159. /* USER CODE BEGIN DSI_MspDeInit 0 */
  160. /* USER CODE END DSI_MspDeInit 0 */
  161. /* Peripheral clock disable */
  162. __HAL_RCC_DSI_CLK_DISABLE();
  163. /* USER CODE BEGIN DSI_MspDeInit 1 */
  164. /* USER CODE END DSI_MspDeInit 1 */
  165. }
  166. }
  167. /**
  168. * @brief I2S MSP Initialization
  169. * This function configures the hardware resources used in this example
  170. * @param hi2s: I2S handle pointer
  171. * @retval None
  172. */
  173. void HAL_I2S_MspInit(I2S_HandleTypeDef* hi2s)
  174. {
  175. GPIO_InitTypeDef GPIO_InitStruct = {0};
  176. if(hi2s->Instance==SPI3)
  177. {
  178. /* USER CODE BEGIN SPI3_MspInit 0 */
  179. /* USER CODE END SPI3_MspInit 0 */
  180. /* Peripheral clock enable */
  181. __HAL_RCC_SPI3_CLK_ENABLE();
  182. __HAL_RCC_GPIOB_CLK_ENABLE();
  183. __HAL_RCC_GPIOA_CLK_ENABLE();
  184. __HAL_RCC_GPIOD_CLK_ENABLE();
  185. /**I2S3 GPIO Configuration
  186. PB3 ------> I2S3_CK
  187. PA15 ------> I2S3_WS
  188. PD6 ------> I2S3_SD
  189. */
  190. GPIO_InitStruct.Pin = GPIO_PIN_3;
  191. GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
  192. GPIO_InitStruct.Pull = GPIO_NOPULL;
  193. GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
  194. GPIO_InitStruct.Alternate = GPIO_AF6_SPI3;
  195. HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
  196. GPIO_InitStruct.Pin = GPIO_PIN_15;
  197. GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
  198. GPIO_InitStruct.Pull = GPIO_NOPULL;
  199. GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
  200. GPIO_InitStruct.Alternate = GPIO_AF6_SPI3;
  201. HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
  202. GPIO_InitStruct.Pin = GPIO_PIN_6;
  203. GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
  204. GPIO_InitStruct.Pull = GPIO_NOPULL;
  205. GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
  206. GPIO_InitStruct.Alternate = GPIO_AF5_I2S3ext;
  207. HAL_GPIO_Init(GPIOD, &GPIO_InitStruct);
  208. /* I2S3 interrupt Init */
  209. HAL_NVIC_SetPriority(SPI3_IRQn, 0, 0);
  210. HAL_NVIC_EnableIRQ(SPI3_IRQn);
  211. /* USER CODE BEGIN SPI3_MspInit 1 */
  212. /* USER CODE END SPI3_MspInit 1 */
  213. }
  214. }
  215. /**
  216. * @brief I2S MSP De-Initialization
  217. * This function freeze the hardware resources used in this example
  218. * @param hi2s: I2S handle pointer
  219. * @retval None
  220. */
  221. void HAL_I2S_MspDeInit(I2S_HandleTypeDef* hi2s)
  222. {
  223. if(hi2s->Instance==SPI3)
  224. {
  225. /* USER CODE BEGIN SPI3_MspDeInit 0 */
  226. /* USER CODE END SPI3_MspDeInit 0 */
  227. /* Peripheral clock disable */
  228. __HAL_RCC_SPI3_CLK_DISABLE();
  229. /**I2S3 GPIO Configuration
  230. PB3 ------> I2S3_CK
  231. PA15 ------> I2S3_WS
  232. PD6 ------> I2S3_SD
  233. */
  234. HAL_GPIO_DeInit(GPIOB, GPIO_PIN_3);
  235. HAL_GPIO_DeInit(GPIOA, GPIO_PIN_15);
  236. HAL_GPIO_DeInit(GPIOD, GPIO_PIN_6);
  237. /* I2S3 interrupt DeInit */
  238. HAL_NVIC_DisableIRQ(SPI3_IRQn);
  239. /* USER CODE BEGIN SPI3_MspDeInit 1 */
  240. /* USER CODE END SPI3_MspDeInit 1 */
  241. }
  242. }
  243. /**
  244. * @brief LTDC MSP Initialization
  245. * This function configures the hardware resources used in this example
  246. * @param hltdc: LTDC handle pointer
  247. * @retval None
  248. */
  249. void HAL_LTDC_MspInit(LTDC_HandleTypeDef* hltdc)
  250. {
  251. if(hltdc->Instance==LTDC)
  252. {
  253. /* USER CODE BEGIN LTDC_MspInit 0 */
  254. /* USER CODE END LTDC_MspInit 0 */
  255. /* Peripheral clock enable */
  256. __HAL_RCC_LTDC_CLK_ENABLE();
  257. /* USER CODE BEGIN LTDC_MspInit 1 */
  258. /* USER CODE END LTDC_MspInit 1 */
  259. }
  260. }
  261. /**
  262. * @brief LTDC MSP De-Initialization
  263. * This function freeze the hardware resources used in this example
  264. * @param hltdc: LTDC handle pointer
  265. * @retval None
  266. */
  267. void HAL_LTDC_MspDeInit(LTDC_HandleTypeDef* hltdc)
  268. {
  269. if(hltdc->Instance==LTDC)
  270. {
  271. /* USER CODE BEGIN LTDC_MspDeInit 0 */
  272. /* USER CODE END LTDC_MspDeInit 0 */
  273. /* Peripheral clock disable */
  274. __HAL_RCC_LTDC_CLK_DISABLE();
  275. /* USER CODE BEGIN LTDC_MspDeInit 1 */
  276. /* USER CODE END LTDC_MspDeInit 1 */
  277. }
  278. }
  279. /**
  280. * @brief QSPI MSP Initialization
  281. * This function configures the hardware resources used in this example
  282. * @param hqspi: QSPI handle pointer
  283. * @retval None
  284. */
  285. void HAL_QSPI_MspInit(QSPI_HandleTypeDef* hqspi)
  286. {
  287. GPIO_InitTypeDef GPIO_InitStruct = {0};
  288. if(hqspi->Instance==QUADSPI)
  289. {
  290. /* USER CODE BEGIN QUADSPI_MspInit 0 */
  291. /* USER CODE END QUADSPI_MspInit 0 */
  292. /* Peripheral clock enable */
  293. __HAL_RCC_QSPI_CLK_ENABLE();
  294. __HAL_RCC_GPIOB_CLK_ENABLE();
  295. __HAL_RCC_GPIOF_CLK_ENABLE();
  296. /**QUADSPI GPIO Configuration
  297. PB6 ------> QUADSPI_BK1_NCS
  298. PF7 ------> QUADSPI_BK1_IO2
  299. PF6 ------> QUADSPI_BK1_IO3
  300. PF10 ------> QUADSPI_CLK
  301. PF9 ------> QUADSPI_BK1_IO1
  302. PF8 ------> QUADSPI_BK1_IO0
  303. */
  304. GPIO_InitStruct.Pin = GPIO_PIN_6;
  305. GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
  306. GPIO_InitStruct.Pull = GPIO_NOPULL;
  307. GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
  308. GPIO_InitStruct.Alternate = GPIO_AF10_QSPI;
  309. HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
  310. GPIO_InitStruct.Pin = GPIO_PIN_7|GPIO_PIN_6|GPIO_PIN_10;
  311. GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
  312. GPIO_InitStruct.Pull = GPIO_NOPULL;
  313. GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
  314. GPIO_InitStruct.Alternate = GPIO_AF9_QSPI;
  315. HAL_GPIO_Init(GPIOF, &GPIO_InitStruct);
  316. GPIO_InitStruct.Pin = GPIO_PIN_9|GPIO_PIN_8;
  317. GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
  318. GPIO_InitStruct.Pull = GPIO_NOPULL;
  319. GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
  320. GPIO_InitStruct.Alternate = GPIO_AF10_QSPI;
  321. HAL_GPIO_Init(GPIOF, &GPIO_InitStruct);
  322. /* USER CODE BEGIN QUADSPI_MspInit 1 */
  323. /* USER CODE END QUADSPI_MspInit 1 */
  324. }
  325. }
  326. /**
  327. * @brief QSPI MSP De-Initialization
  328. * This function freeze the hardware resources used in this example
  329. * @param hqspi: QSPI handle pointer
  330. * @retval None
  331. */
  332. void HAL_QSPI_MspDeInit(QSPI_HandleTypeDef* hqspi)
  333. {
  334. if(hqspi->Instance==QUADSPI)
  335. {
  336. /* USER CODE BEGIN QUADSPI_MspDeInit 0 */
  337. /* USER CODE END QUADSPI_MspDeInit 0 */
  338. /* Peripheral clock disable */
  339. __HAL_RCC_QSPI_CLK_DISABLE();
  340. /**QUADSPI GPIO Configuration
  341. PB6 ------> QUADSPI_BK1_NCS
  342. PF7 ------> QUADSPI_BK1_IO2
  343. PF6 ------> QUADSPI_BK1_IO3
  344. PF10 ------> QUADSPI_CLK
  345. PF9 ------> QUADSPI_BK1_IO1
  346. PF8 ------> QUADSPI_BK1_IO0
  347. */
  348. HAL_GPIO_DeInit(GPIOB, GPIO_PIN_6);
  349. HAL_GPIO_DeInit(GPIOF, GPIO_PIN_7|GPIO_PIN_6|GPIO_PIN_10|GPIO_PIN_9
  350. |GPIO_PIN_8);
  351. /* USER CODE BEGIN QUADSPI_MspDeInit 1 */
  352. /* USER CODE END QUADSPI_MspDeInit 1 */
  353. }
  354. }
  355. /**
  356. * @brief SD MSP Initialization
  357. * This function configures the hardware resources used in this example
  358. * @param hsd: SD handle pointer
  359. * @retval None
  360. */
  361. void HAL_SD_MspInit(SD_HandleTypeDef* hsd)
  362. {
  363. GPIO_InitTypeDef GPIO_InitStruct = {0};
  364. if(hsd->Instance==SDIO)
  365. {
  366. /* USER CODE BEGIN SDIO_MspInit 0 */
  367. /* USER CODE END SDIO_MspInit 0 */
  368. /* Peripheral clock enable */
  369. __HAL_RCC_SDIO_CLK_ENABLE();
  370. __HAL_RCC_GPIOC_CLK_ENABLE();
  371. __HAL_RCC_GPIOD_CLK_ENABLE();
  372. /**SDIO GPIO Configuration
  373. PC12 ------> SDIO_CK
  374. PC11 ------> SDIO_D3
  375. PC10 ------> SDIO_D2
  376. PD2 ------> SDIO_CMD
  377. PC9 ------> SDIO_D1
  378. PC8 ------> SDIO_D0
  379. */
  380. GPIO_InitStruct.Pin = GPIO_PIN_12|GPIO_PIN_11|GPIO_PIN_10|GPIO_PIN_9
  381. |GPIO_PIN_8;
  382. GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
  383. GPIO_InitStruct.Pull = GPIO_NOPULL;
  384. GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
  385. GPIO_InitStruct.Alternate = GPIO_AF12_SDIO;
  386. HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
  387. GPIO_InitStruct.Pin = GPIO_PIN_2;
  388. GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
  389. GPIO_InitStruct.Pull = GPIO_NOPULL;
  390. GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
  391. GPIO_InitStruct.Alternate = GPIO_AF12_SDIO;
  392. HAL_GPIO_Init(GPIOD, &GPIO_InitStruct);
  393. /* USER CODE BEGIN SDIO_MspInit 1 */
  394. /* USER CODE END SDIO_MspInit 1 */
  395. }
  396. }
  397. /**
  398. * @brief SD MSP De-Initialization
  399. * This function freeze the hardware resources used in this example
  400. * @param hsd: SD handle pointer
  401. * @retval None
  402. */
  403. void HAL_SD_MspDeInit(SD_HandleTypeDef* hsd)
  404. {
  405. if(hsd->Instance==SDIO)
  406. {
  407. /* USER CODE BEGIN SDIO_MspDeInit 0 */
  408. /* USER CODE END SDIO_MspDeInit 0 */
  409. /* Peripheral clock disable */
  410. __HAL_RCC_SDIO_CLK_DISABLE();
  411. /**SDIO GPIO Configuration
  412. PC12 ------> SDIO_CK
  413. PC11 ------> SDIO_D3
  414. PC10 ------> SDIO_D2
  415. PD2 ------> SDIO_CMD
  416. PC9 ------> SDIO_D1
  417. PC8 ------> SDIO_D0
  418. */
  419. HAL_GPIO_DeInit(GPIOC, GPIO_PIN_12|GPIO_PIN_11|GPIO_PIN_10|GPIO_PIN_9
  420. |GPIO_PIN_8);
  421. HAL_GPIO_DeInit(GPIOD, GPIO_PIN_2);
  422. /* USER CODE BEGIN SDIO_MspDeInit 1 */
  423. /* USER CODE END SDIO_MspDeInit 1 */
  424. }
  425. }
  426. /**
  427. * @brief TIM_Base MSP Initialization
  428. * This function configures the hardware resources used in this example
  429. * @param htim_base: TIM_Base handle pointer
  430. * @retval None
  431. */
  432. void HAL_TIM_Base_MspInit(TIM_HandleTypeDef* htim_base)
  433. {
  434. GPIO_InitTypeDef GPIO_InitStruct = {0};
  435. if(htim_base->Instance==TIM4)
  436. {
  437. /* USER CODE BEGIN TIM4_MspInit 0 */
  438. /* USER CODE END TIM4_MspInit 0 */
  439. /* Peripheral clock enable */
  440. __HAL_RCC_TIM4_CLK_ENABLE();
  441. __HAL_RCC_GPIOD_CLK_ENABLE();
  442. /**TIM4 GPIO Configuration
  443. PD12 ------> TIM4_CH1
  444. */
  445. GPIO_InitStruct.Pin = GPIO_PIN_12;
  446. GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
  447. GPIO_InitStruct.Pull = GPIO_NOPULL;
  448. GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
  449. GPIO_InitStruct.Alternate = GPIO_AF2_TIM4;
  450. HAL_GPIO_Init(GPIOD, &GPIO_InitStruct);
  451. /* USER CODE BEGIN TIM4_MspInit 1 */
  452. /* USER CODE END TIM4_MspInit 1 */
  453. }
  454. }
  455. void HAL_TIM_MspPostInit(TIM_HandleTypeDef* htim)
  456. {
  457. GPIO_InitTypeDef GPIO_InitStruct = {0};
  458. if(htim->Instance==TIM4)
  459. {
  460. /* USER CODE BEGIN TIM4_MspPostInit 0 */
  461. /* USER CODE END TIM4_MspPostInit 0 */
  462. __HAL_RCC_GPIOD_CLK_ENABLE();
  463. /**TIM4 GPIO Configuration
  464. PD13 ------> TIM4_CH2
  465. */
  466. GPIO_InitStruct.Pin = GPIO_PIN_13;
  467. GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
  468. GPIO_InitStruct.Pull = GPIO_NOPULL;
  469. GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
  470. GPIO_InitStruct.Alternate = GPIO_AF2_TIM4;
  471. HAL_GPIO_Init(GPIOD, &GPIO_InitStruct);
  472. /* USER CODE BEGIN TIM4_MspPostInit 1 */
  473. /* USER CODE END TIM4_MspPostInit 1 */
  474. }
  475. }
  476. /**
  477. * @brief TIM_Base MSP De-Initialization
  478. * This function freeze the hardware resources used in this example
  479. * @param htim_base: TIM_Base handle pointer
  480. * @retval None
  481. */
  482. void HAL_TIM_Base_MspDeInit(TIM_HandleTypeDef* htim_base)
  483. {
  484. if(htim_base->Instance==TIM4)
  485. {
  486. /* USER CODE BEGIN TIM4_MspDeInit 0 */
  487. /* USER CODE END TIM4_MspDeInit 0 */
  488. /* Peripheral clock disable */
  489. __HAL_RCC_TIM4_CLK_DISABLE();
  490. /**TIM4 GPIO Configuration
  491. PD12 ------> TIM4_CH1
  492. PD13 ------> TIM4_CH2
  493. */
  494. HAL_GPIO_DeInit(GPIOD, GPIO_PIN_12|GPIO_PIN_13);
  495. /* USER CODE BEGIN TIM4_MspDeInit 1 */
  496. /* USER CODE END TIM4_MspDeInit 1 */
  497. }
  498. }
  499. /**
  500. * @brief UART MSP Initialization
  501. * This function configures the hardware resources used in this example
  502. * @param huart: UART handle pointer
  503. * @retval None
  504. */
  505. void HAL_UART_MspInit(UART_HandleTypeDef* huart)
  506. {
  507. GPIO_InitTypeDef GPIO_InitStruct = {0};
  508. if(huart->Instance==USART3)
  509. {
  510. /* USER CODE BEGIN USART3_MspInit 0 */
  511. /* USER CODE END USART3_MspInit 0 */
  512. /* Peripheral clock enable */
  513. __HAL_RCC_USART3_CLK_ENABLE();
  514. __HAL_RCC_GPIOB_CLK_ENABLE();
  515. /**USART3 GPIO Configuration
  516. PB10 ------> USART3_TX
  517. PB11 ------> USART3_RX
  518. */
  519. GPIO_InitStruct.Pin = GPIO_PIN_10|GPIO_PIN_11;
  520. GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
  521. GPIO_InitStruct.Pull = GPIO_PULLUP;
  522. GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
  523. GPIO_InitStruct.Alternate = GPIO_AF7_USART3;
  524. HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
  525. /* USER CODE BEGIN USART3_MspInit 1 */
  526. /* USER CODE END USART3_MspInit 1 */
  527. }
  528. }
  529. /**
  530. * @brief UART MSP De-Initialization
  531. * This function freeze the hardware resources used in this example
  532. * @param huart: UART handle pointer
  533. * @retval None
  534. */
  535. void HAL_UART_MspDeInit(UART_HandleTypeDef* huart)
  536. {
  537. if(huart->Instance==USART3)
  538. {
  539. /* USER CODE BEGIN USART3_MspDeInit 0 */
  540. /* USER CODE END USART3_MspDeInit 0 */
  541. /* Peripheral clock disable */
  542. __HAL_RCC_USART3_CLK_DISABLE();
  543. /**USART3 GPIO Configuration
  544. PB10 ------> USART3_TX
  545. PB11 ------> USART3_RX
  546. */
  547. HAL_GPIO_DeInit(GPIOB, GPIO_PIN_10|GPIO_PIN_11);
  548. /* USER CODE BEGIN USART3_MspDeInit 1 */
  549. /* USER CODE END USART3_MspDeInit 1 */
  550. }
  551. }
  552. /**
  553. * @brief PCD MSP Initialization
  554. * This function configures the hardware resources used in this example
  555. * @param hpcd: PCD handle pointer
  556. * @retval None
  557. */
  558. void HAL_PCD_MspInit(PCD_HandleTypeDef* hpcd)
  559. {
  560. GPIO_InitTypeDef GPIO_InitStruct = {0};
  561. if(hpcd->Instance==USB_OTG_FS)
  562. {
  563. /* USER CODE BEGIN USB_OTG_FS_MspInit 0 */
  564. /* USER CODE END USB_OTG_FS_MspInit 0 */
  565. __HAL_RCC_GPIOA_CLK_ENABLE();
  566. /**USB_OTG_FS GPIO Configuration
  567. PA12 ------> USB_OTG_FS_DP
  568. PA11 ------> USB_OTG_FS_DM
  569. */
  570. GPIO_InitStruct.Pin = GPIO_PIN_12|GPIO_PIN_11;
  571. GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
  572. GPIO_InitStruct.Pull = GPIO_NOPULL;
  573. GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
  574. GPIO_InitStruct.Alternate = GPIO_AF10_OTG_FS;
  575. HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
  576. /* Peripheral clock enable */
  577. __HAL_RCC_USB_OTG_FS_CLK_ENABLE();
  578. /* USB_OTG_FS interrupt Init */
  579. HAL_NVIC_SetPriority(OTG_FS_IRQn, 0, 0);
  580. HAL_NVIC_EnableIRQ(OTG_FS_IRQn);
  581. /* USER CODE BEGIN USB_OTG_FS_MspInit 1 */
  582. /* USER CODE END USB_OTG_FS_MspInit 1 */
  583. }
  584. }
  585. /**
  586. * @brief PCD MSP De-Initialization
  587. * This function freeze the hardware resources used in this example
  588. * @param hpcd: PCD handle pointer
  589. * @retval None
  590. */
  591. void HAL_PCD_MspDeInit(PCD_HandleTypeDef* hpcd)
  592. {
  593. if(hpcd->Instance==USB_OTG_FS)
  594. {
  595. /* USER CODE BEGIN USB_OTG_FS_MspDeInit 0 */
  596. /* USER CODE END USB_OTG_FS_MspDeInit 0 */
  597. /* Peripheral clock disable */
  598. __HAL_RCC_USB_OTG_FS_CLK_DISABLE();
  599. /**USB_OTG_FS GPIO Configuration
  600. PA12 ------> USB_OTG_FS_DP
  601. PA11 ------> USB_OTG_FS_DM
  602. */
  603. HAL_GPIO_DeInit(GPIOA, GPIO_PIN_12|GPIO_PIN_11);
  604. /* USB_OTG_FS interrupt DeInit */
  605. HAL_NVIC_DisableIRQ(OTG_FS_IRQn);
  606. /* USER CODE BEGIN USB_OTG_FS_MspDeInit 1 */
  607. /* USER CODE END USB_OTG_FS_MspDeInit 1 */
  608. }
  609. }
  610. static uint32_t FMC_Initialized = 0;
  611. static void HAL_FMC_MspInit(void){
  612. /* USER CODE BEGIN FMC_MspInit 0 */
  613. /* USER CODE END FMC_MspInit 0 */
  614. GPIO_InitTypeDef GPIO_InitStruct;
  615. if (FMC_Initialized) {
  616. return;
  617. }
  618. FMC_Initialized = 1;
  619. /* Peripheral clock enable */
  620. __HAL_RCC_FMC_CLK_ENABLE();
  621. /** FMC GPIO Configuration
  622. PE1 ------> FMC_NBL1
  623. PE0 ------> FMC_NBL0
  624. PG15 ------> FMC_SDNCAS
  625. PD0 ------> FMC_D2
  626. PI4 ------> FMC_NBL2
  627. PD1 ------> FMC_D3
  628. PI3 ------> FMC_D27
  629. PI2 ------> FMC_D26
  630. PF0 ------> FMC_A0
  631. PI5 ------> FMC_NBL3
  632. PI7 ------> FMC_D29
  633. PI10 ------> FMC_D31
  634. PI6 ------> FMC_D28
  635. PH15 ------> FMC_D23
  636. PI1 ------> FMC_D25
  637. PF1 ------> FMC_A1
  638. PI9 ------> FMC_D30
  639. PH13 ------> FMC_D21
  640. PH14 ------> FMC_D22
  641. PI0 ------> FMC_D24
  642. PF2 ------> FMC_A2
  643. PF3 ------> FMC_A3
  644. PG8 ------> FMC_SDCLK
  645. PF4 ------> FMC_A4
  646. PH3 ------> FMC_SDNE0
  647. PF5 ------> FMC_A5
  648. PH2 ------> FMC_SDCKE0
  649. PD15 ------> FMC_D1
  650. PD10 ------> FMC_D15
  651. PD14 ------> FMC_D0
  652. PD9 ------> FMC_D14
  653. PD8 ------> FMC_D13
  654. PC0 ------> FMC_SDNWE
  655. PF12 ------> FMC_A6
  656. PG1 ------> FMC_A11
  657. PF15 ------> FMC_A9
  658. PH12 ------> FMC_D20
  659. PF13 ------> FMC_A7
  660. PG0 ------> FMC_A10
  661. PE8 ------> FMC_D5
  662. PG5 ------> FMC_BA1
  663. PG4 ------> FMC_BA0
  664. PH9 ------> FMC_D17
  665. PH11 ------> FMC_D19
  666. PF14 ------> FMC_A8
  667. PF11 ------> FMC_SDNRAS
  668. PE9 ------> FMC_D6
  669. PE11 ------> FMC_D8
  670. PE14 ------> FMC_D11
  671. PH8 ------> FMC_D16
  672. PH10 ------> FMC_D18
  673. PE7 ------> FMC_D4
  674. PE10 ------> FMC_D7
  675. PE12 ------> FMC_D9
  676. PE15 ------> FMC_D12
  677. PE13 ------> FMC_D10
  678. */
  679. GPIO_InitStruct.Pin = GPIO_PIN_1|GPIO_PIN_0|GPIO_PIN_8|GPIO_PIN_9
  680. |GPIO_PIN_11|GPIO_PIN_14|GPIO_PIN_7|GPIO_PIN_10
  681. |GPIO_PIN_12|GPIO_PIN_15|GPIO_PIN_13;
  682. GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
  683. GPIO_InitStruct.Pull = GPIO_NOPULL;
  684. GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
  685. GPIO_InitStruct.Alternate = GPIO_AF12_FMC;
  686. HAL_GPIO_Init(GPIOE, &GPIO_InitStruct);
  687. GPIO_InitStruct.Pin = GPIO_PIN_15|GPIO_PIN_8|GPIO_PIN_1|GPIO_PIN_0
  688. |GPIO_PIN_5|GPIO_PIN_4;
  689. GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
  690. GPIO_InitStruct.Pull = GPIO_NOPULL;
  691. GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
  692. GPIO_InitStruct.Alternate = GPIO_AF12_FMC;
  693. HAL_GPIO_Init(GPIOG, &GPIO_InitStruct);
  694. GPIO_InitStruct.Pin = GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_15|GPIO_PIN_10
  695. |GPIO_PIN_14|GPIO_PIN_9|GPIO_PIN_8;
  696. GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
  697. GPIO_InitStruct.Pull = GPIO_NOPULL;
  698. GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
  699. GPIO_InitStruct.Alternate = GPIO_AF12_FMC;
  700. HAL_GPIO_Init(GPIOD, &GPIO_InitStruct);
  701. GPIO_InitStruct.Pin = GPIO_PIN_4|GPIO_PIN_3|GPIO_PIN_2|GPIO_PIN_5
  702. |GPIO_PIN_7|GPIO_PIN_10|GPIO_PIN_6|GPIO_PIN_1
  703. |GPIO_PIN_9|GPIO_PIN_0;
  704. GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
  705. GPIO_InitStruct.Pull = GPIO_NOPULL;
  706. GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
  707. GPIO_InitStruct.Alternate = GPIO_AF12_FMC;
  708. HAL_GPIO_Init(GPIOI, &GPIO_InitStruct);
  709. GPIO_InitStruct.Pin = GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3
  710. |GPIO_PIN_4|GPIO_PIN_5|GPIO_PIN_12|GPIO_PIN_15
  711. |GPIO_PIN_13|GPIO_PIN_14|GPIO_PIN_11;
  712. GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
  713. GPIO_InitStruct.Pull = GPIO_NOPULL;
  714. GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
  715. GPIO_InitStruct.Alternate = GPIO_AF12_FMC;
  716. HAL_GPIO_Init(GPIOF, &GPIO_InitStruct);
  717. GPIO_InitStruct.Pin = GPIO_PIN_15|GPIO_PIN_13|GPIO_PIN_14|GPIO_PIN_3
  718. |GPIO_PIN_2|GPIO_PIN_12|GPIO_PIN_9|GPIO_PIN_11
  719. |GPIO_PIN_8|GPIO_PIN_10;
  720. GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
  721. GPIO_InitStruct.Pull = GPIO_NOPULL;
  722. GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
  723. GPIO_InitStruct.Alternate = GPIO_AF12_FMC;
  724. HAL_GPIO_Init(GPIOH, &GPIO_InitStruct);
  725. GPIO_InitStruct.Pin = GPIO_PIN_0;
  726. GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
  727. GPIO_InitStruct.Pull = GPIO_NOPULL;
  728. GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
  729. GPIO_InitStruct.Alternate = GPIO_AF12_FMC;
  730. HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
  731. /* USER CODE BEGIN FMC_MspInit 1 */
  732. /* USER CODE END FMC_MspInit 1 */
  733. }
  734. void HAL_SDRAM_MspInit(SDRAM_HandleTypeDef* hsdram){
  735. /* USER CODE BEGIN SDRAM_MspInit 0 */
  736. /* USER CODE END SDRAM_MspInit 0 */
  737. HAL_FMC_MspInit();
  738. /* USER CODE BEGIN SDRAM_MspInit 1 */
  739. /* USER CODE END SDRAM_MspInit 1 */
  740. }
  741. static uint32_t FMC_DeInitialized = 0;
  742. static void HAL_FMC_MspDeInit(void){
  743. /* USER CODE BEGIN FMC_MspDeInit 0 */
  744. /* USER CODE END FMC_MspDeInit 0 */
  745. if (FMC_DeInitialized) {
  746. return;
  747. }
  748. FMC_DeInitialized = 1;
  749. /* Peripheral clock enable */
  750. __HAL_RCC_FMC_CLK_DISABLE();
  751. /** FMC GPIO Configuration
  752. PE1 ------> FMC_NBL1
  753. PE0 ------> FMC_NBL0
  754. PG15 ------> FMC_SDNCAS
  755. PD0 ------> FMC_D2
  756. PI4 ------> FMC_NBL2
  757. PD1 ------> FMC_D3
  758. PI3 ------> FMC_D27
  759. PI2 ------> FMC_D26
  760. PF0 ------> FMC_A0
  761. PI5 ------> FMC_NBL3
  762. PI7 ------> FMC_D29
  763. PI10 ------> FMC_D31
  764. PI6 ------> FMC_D28
  765. PH15 ------> FMC_D23
  766. PI1 ------> FMC_D25
  767. PF1 ------> FMC_A1
  768. PI9 ------> FMC_D30
  769. PH13 ------> FMC_D21
  770. PH14 ------> FMC_D22
  771. PI0 ------> FMC_D24
  772. PF2 ------> FMC_A2
  773. PF3 ------> FMC_A3
  774. PG8 ------> FMC_SDCLK
  775. PF4 ------> FMC_A4
  776. PH3 ------> FMC_SDNE0
  777. PF5 ------> FMC_A5
  778. PH2 ------> FMC_SDCKE0
  779. PD15 ------> FMC_D1
  780. PD10 ------> FMC_D15
  781. PD14 ------> FMC_D0
  782. PD9 ------> FMC_D14
  783. PD8 ------> FMC_D13
  784. PC0 ------> FMC_SDNWE
  785. PF12 ------> FMC_A6
  786. PG1 ------> FMC_A11
  787. PF15 ------> FMC_A9
  788. PH12 ------> FMC_D20
  789. PF13 ------> FMC_A7
  790. PG0 ------> FMC_A10
  791. PE8 ------> FMC_D5
  792. PG5 ------> FMC_BA1
  793. PG4 ------> FMC_BA0
  794. PH9 ------> FMC_D17
  795. PH11 ------> FMC_D19
  796. PF14 ------> FMC_A8
  797. PF11 ------> FMC_SDNRAS
  798. PE9 ------> FMC_D6
  799. PE11 ------> FMC_D8
  800. PE14 ------> FMC_D11
  801. PH8 ------> FMC_D16
  802. PH10 ------> FMC_D18
  803. PE7 ------> FMC_D4
  804. PE10 ------> FMC_D7
  805. PE12 ------> FMC_D9
  806. PE15 ------> FMC_D12
  807. PE13 ------> FMC_D10
  808. */
  809. HAL_GPIO_DeInit(GPIOE, GPIO_PIN_1|GPIO_PIN_0|GPIO_PIN_8|GPIO_PIN_9
  810. |GPIO_PIN_11|GPIO_PIN_14|GPIO_PIN_7|GPIO_PIN_10
  811. |GPIO_PIN_12|GPIO_PIN_15|GPIO_PIN_13);
  812. HAL_GPIO_DeInit(GPIOG, GPIO_PIN_15|GPIO_PIN_8|GPIO_PIN_1|GPIO_PIN_0
  813. |GPIO_PIN_5|GPIO_PIN_4);
  814. HAL_GPIO_DeInit(GPIOD, GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_15|GPIO_PIN_10
  815. |GPIO_PIN_14|GPIO_PIN_9|GPIO_PIN_8);
  816. HAL_GPIO_DeInit(GPIOI, GPIO_PIN_4|GPIO_PIN_3|GPIO_PIN_2|GPIO_PIN_5
  817. |GPIO_PIN_7|GPIO_PIN_10|GPIO_PIN_6|GPIO_PIN_1
  818. |GPIO_PIN_9|GPIO_PIN_0);
  819. HAL_GPIO_DeInit(GPIOF, GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3
  820. |GPIO_PIN_4|GPIO_PIN_5|GPIO_PIN_12|GPIO_PIN_15
  821. |GPIO_PIN_13|GPIO_PIN_14|GPIO_PIN_11);
  822. HAL_GPIO_DeInit(GPIOH, GPIO_PIN_15|GPIO_PIN_13|GPIO_PIN_14|GPIO_PIN_3
  823. |GPIO_PIN_2|GPIO_PIN_12|GPIO_PIN_9|GPIO_PIN_11
  824. |GPIO_PIN_8|GPIO_PIN_10);
  825. HAL_GPIO_DeInit(GPIOC, GPIO_PIN_0);
  826. /* USER CODE BEGIN FMC_MspDeInit 1 */
  827. /* USER CODE END FMC_MspDeInit 1 */
  828. }
  829. void HAL_SDRAM_MspDeInit(SDRAM_HandleTypeDef* hsdram){
  830. /* USER CODE BEGIN SDRAM_MspDeInit 0 */
  831. /* USER CODE END SDRAM_MspDeInit 0 */
  832. HAL_FMC_MspDeInit();
  833. /* USER CODE BEGIN SDRAM_MspDeInit 1 */
  834. /* USER CODE END SDRAM_MspDeInit 1 */
  835. }
  836. /* USER CODE BEGIN 1 */
  837. /* USER CODE END 1 */
  838. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/