stm32f4xx_hal_msp.c 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218
  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. ** 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. #include <drv_common.h>
  45. /* USER CODE END Includes */
  46. /* Private typedef -----------------------------------------------------------*/
  47. /* USER CODE BEGIN TD */
  48. /* USER CODE END TD */
  49. /* Private define ------------------------------------------------------------*/
  50. /* USER CODE BEGIN Define */
  51. /* USER CODE END Define */
  52. /* Private macro -------------------------------------------------------------*/
  53. /* USER CODE BEGIN Macro */
  54. /* USER CODE END Macro */
  55. /* Private variables ---------------------------------------------------------*/
  56. /* USER CODE BEGIN PV */
  57. /* USER CODE END PV */
  58. /* Private function prototypes -----------------------------------------------*/
  59. /* USER CODE BEGIN PFP */
  60. /* USER CODE END PFP */
  61. /* External functions --------------------------------------------------------*/
  62. /* USER CODE BEGIN ExternalFunctions */
  63. /* USER CODE END ExternalFunctions */
  64. /* USER CODE BEGIN 0 */
  65. /* USER CODE END 0 */
  66. void HAL_TIM_MspPostInit(TIM_HandleTypeDef *htim);
  67. /**
  68. * Initializes the Global MSP.
  69. */
  70. void HAL_MspInit(void)
  71. {
  72. /* USER CODE BEGIN MspInit 0 */
  73. /* USER CODE END MspInit 0 */
  74. __HAL_RCC_SYSCFG_CLK_ENABLE();
  75. __HAL_RCC_PWR_CLK_ENABLE();
  76. /* System interrupt init*/
  77. /* USER CODE BEGIN MspInit 1 */
  78. /* USER CODE END MspInit 1 */
  79. }
  80. /**
  81. * @brief ADC MSP Initialization
  82. * This function configures the hardware resources used in this example
  83. * @param hadc: ADC handle pointer
  84. * @retval None
  85. */
  86. void HAL_ADC_MspInit(ADC_HandleTypeDef* hadc)
  87. {
  88. GPIO_InitTypeDef GPIO_InitStruct = {0};
  89. if(hadc->Instance==ADC1)
  90. {
  91. /* USER CODE BEGIN ADC1_MspInit 0 */
  92. /* USER CODE END ADC1_MspInit 0 */
  93. /* Peripheral clock enable */
  94. __HAL_RCC_ADC1_CLK_ENABLE();
  95. __HAL_RCC_GPIOA_CLK_ENABLE();
  96. /**ADC1 GPIO Configuration
  97. PA5 ------> ADC1_IN5
  98. */
  99. GPIO_InitStruct.Pin = GPIO_PIN_5;
  100. GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
  101. GPIO_InitStruct.Pull = GPIO_NOPULL;
  102. HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
  103. /* USER CODE BEGIN ADC1_MspInit 1 */
  104. /* USER CODE END ADC1_MspInit 1 */
  105. }
  106. }
  107. /**
  108. * @brief ADC MSP De-Initialization
  109. * This function freeze the hardware resources used in this example
  110. * @param hadc: ADC handle pointer
  111. * @retval None
  112. */
  113. void HAL_ADC_MspDeInit(ADC_HandleTypeDef* hadc)
  114. {
  115. if(hadc->Instance==ADC1)
  116. {
  117. /* USER CODE BEGIN ADC1_MspDeInit 0 */
  118. /* USER CODE END ADC1_MspDeInit 0 */
  119. /* Peripheral clock disable */
  120. __HAL_RCC_ADC1_CLK_DISABLE();
  121. /**ADC1 GPIO Configuration
  122. PA5 ------> ADC1_IN5
  123. */
  124. HAL_GPIO_DeInit(GPIOA, GPIO_PIN_5);
  125. /* USER CODE BEGIN ADC1_MspDeInit 1 */
  126. /* USER CODE END ADC1_MspDeInit 1 */
  127. }
  128. }
  129. /**
  130. * @brief ETH MSP Initialization
  131. * This function configures the hardware resources used in this example
  132. * @param heth: ETH handle pointer
  133. * @retval None
  134. */
  135. void HAL_ETH_MspInit(ETH_HandleTypeDef* heth)
  136. {
  137. GPIO_InitTypeDef GPIO_InitStruct = {0};
  138. if(heth->Instance==ETH)
  139. {
  140. /* USER CODE BEGIN ETH_MspInit 0 */
  141. /* USER CODE END ETH_MspInit 0 */
  142. /* Peripheral clock enable */
  143. __HAL_RCC_ETH_CLK_ENABLE();
  144. __HAL_RCC_GPIOC_CLK_ENABLE();
  145. __HAL_RCC_GPIOA_CLK_ENABLE();
  146. __HAL_RCC_GPIOB_CLK_ENABLE();
  147. __HAL_RCC_GPIOG_CLK_ENABLE();
  148. /**ETH GPIO Configuration
  149. PC1 ------> ETH_MDC
  150. PA1 ------> ETH_REF_CLK
  151. PA2 ------> ETH_MDIO
  152. PA7 ------> ETH_CRS_DV
  153. PC4 ------> ETH_RXD0
  154. PC5 ------> ETH_RXD1
  155. PB11 ------> ETH_TX_EN
  156. PG13 ------> ETH_TXD0
  157. PG14 ------> ETH_TXD1
  158. */
  159. GPIO_InitStruct.Pin = GPIO_PIN_1|GPIO_PIN_4|GPIO_PIN_5;
  160. GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
  161. GPIO_InitStruct.Pull = GPIO_NOPULL;
  162. GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
  163. GPIO_InitStruct.Alternate = GPIO_AF11_ETH;
  164. HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
  165. GPIO_InitStruct.Pin = GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_7;
  166. GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
  167. GPIO_InitStruct.Pull = GPIO_NOPULL;
  168. GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
  169. GPIO_InitStruct.Alternate = GPIO_AF11_ETH;
  170. HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
  171. GPIO_InitStruct.Pin = GPIO_PIN_11;
  172. GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
  173. GPIO_InitStruct.Pull = GPIO_NOPULL;
  174. GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
  175. GPIO_InitStruct.Alternate = GPIO_AF11_ETH;
  176. HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
  177. GPIO_InitStruct.Pin = GPIO_PIN_13|GPIO_PIN_14;
  178. GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
  179. GPIO_InitStruct.Pull = GPIO_NOPULL;
  180. GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
  181. GPIO_InitStruct.Alternate = GPIO_AF11_ETH;
  182. HAL_GPIO_Init(GPIOG, &GPIO_InitStruct);
  183. /* USER CODE BEGIN ETH_MspInit 1 */
  184. /* USER CODE END ETH_MspInit 1 */
  185. }
  186. }
  187. /**
  188. * @brief ETH MSP De-Initialization
  189. * This function freeze the hardware resources used in this example
  190. * @param heth: ETH handle pointer
  191. * @retval None
  192. */
  193. void HAL_ETH_MspDeInit(ETH_HandleTypeDef* heth)
  194. {
  195. if(heth->Instance==ETH)
  196. {
  197. /* USER CODE BEGIN ETH_MspDeInit 0 */
  198. /* USER CODE END ETH_MspDeInit 0 */
  199. /* Peripheral clock disable */
  200. __HAL_RCC_ETH_CLK_DISABLE();
  201. /**ETH GPIO Configuration
  202. PC1 ------> ETH_MDC
  203. PA1 ------> ETH_REF_CLK
  204. PA2 ------> ETH_MDIO
  205. PA7 ------> ETH_CRS_DV
  206. PC4 ------> ETH_RXD0
  207. PC5 ------> ETH_RXD1
  208. PB11 ------> ETH_TX_EN
  209. PG13 ------> ETH_TXD0
  210. PG14 ------> ETH_TXD1
  211. */
  212. HAL_GPIO_DeInit(GPIOC, GPIO_PIN_1|GPIO_PIN_4|GPIO_PIN_5);
  213. HAL_GPIO_DeInit(GPIOA, GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_7);
  214. HAL_GPIO_DeInit(GPIOB, GPIO_PIN_11);
  215. HAL_GPIO_DeInit(GPIOG, GPIO_PIN_13|GPIO_PIN_14);
  216. /* USER CODE BEGIN ETH_MspDeInit 1 */
  217. /* USER CODE END ETH_MspDeInit 1 */
  218. }
  219. }
  220. /**
  221. * @brief RTC MSP Initialization
  222. * This function configures the hardware resources used in this example
  223. * @param hrtc: RTC handle pointer
  224. * @retval None
  225. */
  226. void HAL_RTC_MspInit(RTC_HandleTypeDef* hrtc)
  227. {
  228. if(hrtc->Instance==RTC)
  229. {
  230. /* USER CODE BEGIN RTC_MspInit 0 */
  231. /* USER CODE END RTC_MspInit 0 */
  232. /* Peripheral clock enable */
  233. __HAL_RCC_RTC_ENABLE();
  234. /* USER CODE BEGIN RTC_MspInit 1 */
  235. /* USER CODE END RTC_MspInit 1 */
  236. }
  237. }
  238. /**
  239. * @brief RTC MSP De-Initialization
  240. * This function freeze the hardware resources used in this example
  241. * @param hrtc: RTC handle pointer
  242. * @retval None
  243. */
  244. void HAL_RTC_MspDeInit(RTC_HandleTypeDef* hrtc)
  245. {
  246. if(hrtc->Instance==RTC)
  247. {
  248. /* USER CODE BEGIN RTC_MspDeInit 0 */
  249. /* USER CODE END RTC_MspDeInit 0 */
  250. /* Peripheral clock disable */
  251. __HAL_RCC_RTC_DISABLE();
  252. /* USER CODE BEGIN RTC_MspDeInit 1 */
  253. /* USER CODE END RTC_MspDeInit 1 */
  254. }
  255. }
  256. /**
  257. * @brief SD MSP Initialization
  258. * This function configures the hardware resources used in this example
  259. * @param hsd: SD handle pointer
  260. * @retval None
  261. */
  262. void HAL_SD_MspInit(SD_HandleTypeDef* hsd)
  263. {
  264. GPIO_InitTypeDef GPIO_InitStruct = {0};
  265. if(hsd->Instance==SDIO)
  266. {
  267. /* USER CODE BEGIN SDIO_MspInit 0 */
  268. /* USER CODE END SDIO_MspInit 0 */
  269. /* Peripheral clock enable */
  270. __HAL_RCC_SDIO_CLK_ENABLE();
  271. __HAL_RCC_GPIOC_CLK_ENABLE();
  272. __HAL_RCC_GPIOD_CLK_ENABLE();
  273. /**SDIO GPIO Configuration
  274. PC8 ------> SDIO_D0
  275. PC9 ------> SDIO_D1
  276. PC10 ------> SDIO_D2
  277. PC11 ------> SDIO_D3
  278. PC12 ------> SDIO_CK
  279. PD2 ------> SDIO_CMD
  280. */
  281. GPIO_InitStruct.Pin = GPIO_PIN_8|GPIO_PIN_9|GPIO_PIN_10|GPIO_PIN_11
  282. |GPIO_PIN_12;
  283. GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
  284. GPIO_InitStruct.Pull = GPIO_NOPULL;
  285. GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
  286. GPIO_InitStruct.Alternate = GPIO_AF12_SDIO;
  287. HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
  288. GPIO_InitStruct.Pin = GPIO_PIN_2;
  289. GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
  290. GPIO_InitStruct.Pull = GPIO_NOPULL;
  291. GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
  292. GPIO_InitStruct.Alternate = GPIO_AF12_SDIO;
  293. HAL_GPIO_Init(GPIOD, &GPIO_InitStruct);
  294. /* USER CODE BEGIN SDIO_MspInit 1 */
  295. /* USER CODE END SDIO_MspInit 1 */
  296. }
  297. }
  298. /**
  299. * @brief SD MSP De-Initialization
  300. * This function freeze the hardware resources used in this example
  301. * @param hsd: SD handle pointer
  302. * @retval None
  303. */
  304. void HAL_SD_MspDeInit(SD_HandleTypeDef* hsd)
  305. {
  306. if(hsd->Instance==SDIO)
  307. {
  308. /* USER CODE BEGIN SDIO_MspDeInit 0 */
  309. /* USER CODE END SDIO_MspDeInit 0 */
  310. /* Peripheral clock disable */
  311. __HAL_RCC_SDIO_CLK_DISABLE();
  312. /**SDIO GPIO Configuration
  313. PC8 ------> SDIO_D0
  314. PC9 ------> SDIO_D1
  315. PC10 ------> SDIO_D2
  316. PC11 ------> SDIO_D3
  317. PC12 ------> SDIO_CK
  318. PD2 ------> SDIO_CMD
  319. */
  320. HAL_GPIO_DeInit(GPIOC, GPIO_PIN_8|GPIO_PIN_9|GPIO_PIN_10|GPIO_PIN_11
  321. |GPIO_PIN_12);
  322. HAL_GPIO_DeInit(GPIOD, GPIO_PIN_2);
  323. /* USER CODE BEGIN SDIO_MspDeInit 1 */
  324. /* USER CODE END SDIO_MspDeInit 1 */
  325. }
  326. }
  327. /**
  328. * @brief SPI MSP Initialization
  329. * This function configures the hardware resources used in this example
  330. * @param hspi: SPI handle pointer
  331. * @retval None
  332. */
  333. void HAL_SPI_MspInit(SPI_HandleTypeDef* hspi)
  334. {
  335. GPIO_InitTypeDef GPIO_InitStruct = {0};
  336. if(hspi->Instance==SPI1)
  337. {
  338. /* USER CODE BEGIN SPI1_MspInit 0 */
  339. /* USER CODE END SPI1_MspInit 0 */
  340. /* Peripheral clock enable */
  341. __HAL_RCC_SPI1_CLK_ENABLE();
  342. __HAL_RCC_GPIOA_CLK_ENABLE();
  343. __HAL_RCC_GPIOB_CLK_ENABLE();
  344. /**SPI1 GPIO Configuration
  345. PA6 ------> SPI1_MISO
  346. PB3 ------> SPI1_SCK
  347. PB5 ------> SPI1_MOSI
  348. */
  349. GPIO_InitStruct.Pin = GPIO_PIN_6;
  350. GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
  351. GPIO_InitStruct.Pull = GPIO_NOPULL;
  352. GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
  353. GPIO_InitStruct.Alternate = GPIO_AF5_SPI1;
  354. HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
  355. GPIO_InitStruct.Pin = GPIO_PIN_3|GPIO_PIN_5;
  356. GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
  357. GPIO_InitStruct.Pull = GPIO_NOPULL;
  358. GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
  359. GPIO_InitStruct.Alternate = GPIO_AF5_SPI1;
  360. HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
  361. /* USER CODE BEGIN SPI1_MspInit 1 */
  362. /* USER CODE END SPI1_MspInit 1 */
  363. }
  364. else if(hspi->Instance==SPI2)
  365. {
  366. /* USER CODE BEGIN SPI2_MspInit 0 */
  367. /* USER CODE END SPI2_MspInit 0 */
  368. /* Peripheral clock enable */
  369. __HAL_RCC_SPI2_CLK_ENABLE();
  370. __HAL_RCC_GPIOB_CLK_ENABLE();
  371. /**SPI2 GPIO Configuration
  372. PB13 ------> SPI2_SCK
  373. PB14 ------> SPI2_MISO
  374. PB15 ------> SPI2_MOSI
  375. */
  376. GPIO_InitStruct.Pin = GPIO_PIN_13|GPIO_PIN_14|GPIO_PIN_15;
  377. GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
  378. GPIO_InitStruct.Pull = GPIO_NOPULL;
  379. GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
  380. GPIO_InitStruct.Alternate = GPIO_AF5_SPI2;
  381. HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
  382. /* USER CODE BEGIN SPI2_MspInit 1 */
  383. /* USER CODE END SPI2_MspInit 1 */
  384. }
  385. else if(hspi->Instance==SPI5)
  386. {
  387. /* USER CODE BEGIN SPI5_MspInit 0 */
  388. /* USER CODE END SPI5_MspInit 0 */
  389. /* Peripheral clock enable */
  390. __HAL_RCC_SPI5_CLK_ENABLE();
  391. __HAL_RCC_GPIOF_CLK_ENABLE();
  392. /**SPI5 GPIO Configuration
  393. PF7 ------> SPI5_SCK
  394. PF8 ------> SPI5_MISO
  395. PF9 ------> SPI5_MOSI
  396. */
  397. GPIO_InitStruct.Pin = GPIO_PIN_7|GPIO_PIN_8|GPIO_PIN_9;
  398. GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
  399. GPIO_InitStruct.Pull = GPIO_NOPULL;
  400. GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
  401. GPIO_InitStruct.Alternate = GPIO_AF5_SPI5;
  402. HAL_GPIO_Init(GPIOF, &GPIO_InitStruct);
  403. /* USER CODE BEGIN SPI5_MspInit 1 */
  404. /* USER CODE END SPI5_MspInit 1 */
  405. }
  406. }
  407. /**
  408. * @brief SPI MSP De-Initialization
  409. * This function freeze the hardware resources used in this example
  410. * @param hspi: SPI handle pointer
  411. * @retval None
  412. */
  413. void HAL_SPI_MspDeInit(SPI_HandleTypeDef* hspi)
  414. {
  415. if(hspi->Instance==SPI1)
  416. {
  417. /* USER CODE BEGIN SPI1_MspDeInit 0 */
  418. /* USER CODE END SPI1_MspDeInit 0 */
  419. /* Peripheral clock disable */
  420. __HAL_RCC_SPI1_CLK_DISABLE();
  421. /**SPI1 GPIO Configuration
  422. PA6 ------> SPI1_MISO
  423. PB3 ------> SPI1_SCK
  424. PB5 ------> SPI1_MOSI
  425. */
  426. HAL_GPIO_DeInit(GPIOA, GPIO_PIN_6);
  427. HAL_GPIO_DeInit(GPIOB, GPIO_PIN_3|GPIO_PIN_5);
  428. /* USER CODE BEGIN SPI1_MspDeInit 1 */
  429. /* USER CODE END SPI1_MspDeInit 1 */
  430. }
  431. else if(hspi->Instance==SPI2)
  432. {
  433. /* USER CODE BEGIN SPI2_MspDeInit 0 */
  434. /* USER CODE END SPI2_MspDeInit 0 */
  435. /* Peripheral clock disable */
  436. __HAL_RCC_SPI2_CLK_DISABLE();
  437. /**SPI2 GPIO Configuration
  438. PB13 ------> SPI2_SCK
  439. PB14 ------> SPI2_MISO
  440. PB15 ------> SPI2_MOSI
  441. */
  442. HAL_GPIO_DeInit(GPIOB, GPIO_PIN_13|GPIO_PIN_14|GPIO_PIN_15);
  443. /* USER CODE BEGIN SPI2_MspDeInit 1 */
  444. /* USER CODE END SPI2_MspDeInit 1 */
  445. }
  446. else if(hspi->Instance==SPI5)
  447. {
  448. /* USER CODE BEGIN SPI5_MspDeInit 0 */
  449. /* USER CODE END SPI5_MspDeInit 0 */
  450. /* Peripheral clock disable */
  451. __HAL_RCC_SPI5_CLK_DISABLE();
  452. /**SPI5 GPIO Configuration
  453. PF7 ------> SPI5_SCK
  454. PF8 ------> SPI5_MISO
  455. PF9 ------> SPI5_MOSI
  456. */
  457. HAL_GPIO_DeInit(GPIOF, GPIO_PIN_7|GPIO_PIN_8|GPIO_PIN_9);
  458. /* USER CODE BEGIN SPI5_MspDeInit 1 */
  459. /* USER CODE END SPI5_MspDeInit 1 */
  460. }
  461. }
  462. /**
  463. * @brief TIM_Base MSP Initialization
  464. * This function configures the hardware resources used in this example
  465. * @param htim_base: TIM_Base handle pointer
  466. * @retval None
  467. */
  468. void HAL_TIM_Base_MspInit(TIM_HandleTypeDef* htim_base)
  469. {
  470. if(htim_base->Instance==TIM2)
  471. {
  472. /* USER CODE BEGIN TIM2_MspInit 0 */
  473. /* USER CODE END TIM2_MspInit 0 */
  474. /* Peripheral clock enable */
  475. __HAL_RCC_TIM2_CLK_ENABLE();
  476. /* USER CODE BEGIN TIM2_MspInit 1 */
  477. /* USER CODE END TIM2_MspInit 1 */
  478. }
  479. else if(htim_base->Instance==TIM11)
  480. {
  481. /* USER CODE BEGIN TIM11_MspInit 0 */
  482. /* USER CODE END TIM11_MspInit 0 */
  483. /* Peripheral clock enable */
  484. __HAL_RCC_TIM11_CLK_ENABLE();
  485. /* USER CODE BEGIN TIM11_MspInit 1 */
  486. /* USER CODE END TIM11_MspInit 1 */
  487. }
  488. else if(htim_base->Instance==TIM13)
  489. {
  490. /* USER CODE BEGIN TIM13_MspInit 0 */
  491. /* USER CODE END TIM13_MspInit 0 */
  492. /* Peripheral clock enable */
  493. __HAL_RCC_TIM13_CLK_ENABLE();
  494. /* USER CODE BEGIN TIM13_MspInit 1 */
  495. /* USER CODE END TIM13_MspInit 1 */
  496. }
  497. else if(htim_base->Instance==TIM14)
  498. {
  499. /* USER CODE BEGIN TIM14_MspInit 0 */
  500. /* USER CODE END TIM14_MspInit 0 */
  501. /* Peripheral clock enable */
  502. __HAL_RCC_TIM14_CLK_ENABLE();
  503. /* USER CODE BEGIN TIM14_MspInit 1 */
  504. /* USER CODE END TIM14_MspInit 1 */
  505. }
  506. }
  507. void HAL_TIM_MspPostInit(TIM_HandleTypeDef* htim)
  508. {
  509. GPIO_InitTypeDef GPIO_InitStruct = {0};
  510. if(htim->Instance==TIM2)
  511. {
  512. /* USER CODE BEGIN TIM2_MspPostInit 0 */
  513. /* USER CODE END TIM2_MspPostInit 0 */
  514. __HAL_RCC_GPIOA_CLK_ENABLE();
  515. /**TIM2 GPIO Configuration
  516. PA3 ------> TIM2_CH4
  517. */
  518. GPIO_InitStruct.Pin = GPIO_PIN_3;
  519. GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
  520. GPIO_InitStruct.Pull = GPIO_NOPULL;
  521. GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
  522. GPIO_InitStruct.Alternate = GPIO_AF1_TIM2;
  523. HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
  524. /* USER CODE BEGIN TIM2_MspPostInit 1 */
  525. /* USER CODE END TIM2_MspPostInit 1 */
  526. }
  527. }
  528. /**
  529. * @brief TIM_Base MSP De-Initialization
  530. * This function freeze the hardware resources used in this example
  531. * @param htim_base: TIM_Base handle pointer
  532. * @retval None
  533. */
  534. void HAL_TIM_Base_MspDeInit(TIM_HandleTypeDef* htim_base)
  535. {
  536. if(htim_base->Instance==TIM2)
  537. {
  538. /* USER CODE BEGIN TIM2_MspDeInit 0 */
  539. /* USER CODE END TIM2_MspDeInit 0 */
  540. /* Peripheral clock disable */
  541. __HAL_RCC_TIM2_CLK_DISABLE();
  542. /* USER CODE BEGIN TIM2_MspDeInit 1 */
  543. /* USER CODE END TIM2_MspDeInit 1 */
  544. }
  545. else if(htim_base->Instance==TIM11)
  546. {
  547. /* USER CODE BEGIN TIM11_MspDeInit 0 */
  548. /* USER CODE END TIM11_MspDeInit 0 */
  549. /* Peripheral clock disable */
  550. __HAL_RCC_TIM11_CLK_DISABLE();
  551. /* USER CODE BEGIN TIM11_MspDeInit 1 */
  552. /* USER CODE END TIM11_MspDeInit 1 */
  553. }
  554. else if(htim_base->Instance==TIM13)
  555. {
  556. /* USER CODE BEGIN TIM13_MspDeInit 0 */
  557. /* USER CODE END TIM13_MspDeInit 0 */
  558. /* Peripheral clock disable */
  559. __HAL_RCC_TIM13_CLK_DISABLE();
  560. /* USER CODE BEGIN TIM13_MspDeInit 1 */
  561. /* USER CODE END TIM13_MspDeInit 1 */
  562. }
  563. else if(htim_base->Instance==TIM14)
  564. {
  565. /* USER CODE BEGIN TIM14_MspDeInit 0 */
  566. /* USER CODE END TIM14_MspDeInit 0 */
  567. /* Peripheral clock disable */
  568. __HAL_RCC_TIM14_CLK_DISABLE();
  569. /* USER CODE BEGIN TIM14_MspDeInit 1 */
  570. /* USER CODE END TIM14_MspDeInit 1 */
  571. }
  572. }
  573. /**
  574. * @brief UART MSP Initialization
  575. * This function configures the hardware resources used in this example
  576. * @param huart: UART handle pointer
  577. * @retval None
  578. */
  579. void HAL_UART_MspInit(UART_HandleTypeDef* huart)
  580. {
  581. GPIO_InitTypeDef GPIO_InitStruct = {0};
  582. if(huart->Instance==USART1)
  583. {
  584. /* USER CODE BEGIN USART1_MspInit 0 */
  585. /* USER CODE END USART1_MspInit 0 */
  586. /* Peripheral clock enable */
  587. __HAL_RCC_USART1_CLK_ENABLE();
  588. __HAL_RCC_GPIOA_CLK_ENABLE();
  589. /**USART1 GPIO Configuration
  590. PA9 ------> USART1_TX
  591. PA10 ------> USART1_RX
  592. */
  593. GPIO_InitStruct.Pin = GPIO_PIN_9|GPIO_PIN_10;
  594. GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
  595. GPIO_InitStruct.Pull = GPIO_PULLUP;
  596. GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
  597. GPIO_InitStruct.Alternate = GPIO_AF7_USART1;
  598. HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
  599. /* USART1 interrupt Init */
  600. HAL_NVIC_SetPriority(USART1_IRQn, 0, 0);
  601. HAL_NVIC_EnableIRQ(USART1_IRQn);
  602. /* USER CODE BEGIN USART1_MspInit 1 */
  603. /* USER CODE END USART1_MspInit 1 */
  604. }
  605. else if(huart->Instance==USART2)
  606. {
  607. /* USER CODE BEGIN USART2_MspInit 0 */
  608. /* USER CODE END USART2_MspInit 0 */
  609. /* Peripheral clock enable */
  610. __HAL_RCC_USART2_CLK_ENABLE();
  611. __HAL_RCC_GPIOD_CLK_ENABLE();
  612. /**USART2 GPIO Configuration
  613. PD5 ------> USART2_TX
  614. PD6 ------> USART2_RX
  615. */
  616. GPIO_InitStruct.Pin = GPIO_PIN_5|GPIO_PIN_6;
  617. GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
  618. GPIO_InitStruct.Pull = GPIO_PULLUP;
  619. GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
  620. GPIO_InitStruct.Alternate = GPIO_AF7_USART2;
  621. HAL_GPIO_Init(GPIOD, &GPIO_InitStruct);
  622. /* USER CODE BEGIN USART2_MspInit 1 */
  623. /* USER CODE END USART2_MspInit 1 */
  624. }
  625. else if(huart->Instance==USART3)
  626. {
  627. /* USER CODE BEGIN USART3_MspInit 0 */
  628. /* USER CODE END USART3_MspInit 0 */
  629. /* Peripheral clock enable */
  630. __HAL_RCC_USART3_CLK_ENABLE();
  631. __HAL_RCC_GPIOB_CLK_ENABLE();
  632. /**USART3 GPIO Configuration
  633. PB10 ------> USART3_TX
  634. PB11 ------> USART3_RX
  635. */
  636. GPIO_InitStruct.Pin = GPIO_PIN_10|GPIO_PIN_11;
  637. GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
  638. GPIO_InitStruct.Pull = GPIO_PULLUP;
  639. GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
  640. GPIO_InitStruct.Alternate = GPIO_AF7_USART3;
  641. HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
  642. /* USER CODE BEGIN USART3_MspInit 1 */
  643. /* USER CODE END USART3_MspInit 1 */
  644. }
  645. }
  646. /**
  647. * @brief UART MSP De-Initialization
  648. * This function freeze the hardware resources used in this example
  649. * @param huart: UART handle pointer
  650. * @retval None
  651. */
  652. void HAL_UART_MspDeInit(UART_HandleTypeDef* huart)
  653. {
  654. if(huart->Instance==USART1)
  655. {
  656. /* USER CODE BEGIN USART1_MspDeInit 0 */
  657. /* USER CODE END USART1_MspDeInit 0 */
  658. /* Peripheral clock disable */
  659. __HAL_RCC_USART1_CLK_DISABLE();
  660. /**USART1 GPIO Configuration
  661. PA9 ------> USART1_TX
  662. PA10 ------> USART1_RX
  663. */
  664. HAL_GPIO_DeInit(GPIOA, GPIO_PIN_9|GPIO_PIN_10);
  665. /* USART1 interrupt DeInit */
  666. HAL_NVIC_DisableIRQ(USART1_IRQn);
  667. /* USER CODE BEGIN USART1_MspDeInit 1 */
  668. /* USER CODE END USART1_MspDeInit 1 */
  669. }
  670. else if(huart->Instance==USART2)
  671. {
  672. /* USER CODE BEGIN USART2_MspDeInit 0 */
  673. /* USER CODE END USART2_MspDeInit 0 */
  674. /* Peripheral clock disable */
  675. __HAL_RCC_USART2_CLK_DISABLE();
  676. /**USART2 GPIO Configuration
  677. PD5 ------> USART2_TX
  678. PD6 ------> USART2_RX
  679. */
  680. HAL_GPIO_DeInit(GPIOD, GPIO_PIN_5|GPIO_PIN_6);
  681. /* USER CODE BEGIN USART2_MspDeInit 1 */
  682. /* USER CODE END USART2_MspDeInit 1 */
  683. }
  684. else if(huart->Instance==USART3)
  685. {
  686. /* USER CODE BEGIN USART3_MspDeInit 0 */
  687. /* USER CODE END USART3_MspDeInit 0 */
  688. /* Peripheral clock disable */
  689. __HAL_RCC_USART3_CLK_DISABLE();
  690. /**USART3 GPIO Configuration
  691. PB10 ------> USART3_TX
  692. PB11 ------> USART3_RX
  693. */
  694. HAL_GPIO_DeInit(GPIOB, GPIO_PIN_10|GPIO_PIN_11);
  695. /* USER CODE BEGIN USART3_MspDeInit 1 */
  696. /* USER CODE END USART3_MspDeInit 1 */
  697. }
  698. }
  699. /**
  700. * @brief HCD MSP Initialization
  701. * This function configures the hardware resources used in this example
  702. * @param hhcd: HCD handle pointer
  703. * @retval None
  704. */
  705. void HAL_HCD_MspInit(HCD_HandleTypeDef* hhcd)
  706. {
  707. GPIO_InitTypeDef GPIO_InitStruct = {0};
  708. if(hhcd->Instance==USB_OTG_FS)
  709. {
  710. /* USER CODE BEGIN USB_OTG_FS_MspInit 0 */
  711. /* USER CODE END USB_OTG_FS_MspInit 0 */
  712. __HAL_RCC_GPIOA_CLK_ENABLE();
  713. /**USB_OTG_FS GPIO Configuration
  714. PA11 ------> USB_OTG_FS_DM
  715. PA12 ------> USB_OTG_FS_DP
  716. */
  717. GPIO_InitStruct.Pin = GPIO_PIN_11|GPIO_PIN_12;
  718. GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
  719. GPIO_InitStruct.Pull = GPIO_NOPULL;
  720. GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
  721. GPIO_InitStruct.Alternate = GPIO_AF10_OTG_FS;
  722. HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
  723. /* Peripheral clock enable */
  724. __HAL_RCC_USB_OTG_FS_CLK_ENABLE();
  725. /* USB_OTG_FS interrupt Init */
  726. HAL_NVIC_SetPriority(OTG_FS_IRQn, 0, 0);
  727. HAL_NVIC_EnableIRQ(OTG_FS_IRQn);
  728. /* USER CODE BEGIN USB_OTG_FS_MspInit 1 */
  729. /* USER CODE END USB_OTG_FS_MspInit 1 */
  730. }
  731. }
  732. /**
  733. * @brief HCD MSP De-Initialization
  734. * This function freeze the hardware resources used in this example
  735. * @param hhcd: HCD handle pointer
  736. * @retval None
  737. */
  738. void HAL_HCD_MspDeInit(HCD_HandleTypeDef* hhcd)
  739. {
  740. if(hhcd->Instance==USB_OTG_FS)
  741. {
  742. /* USER CODE BEGIN USB_OTG_FS_MspDeInit 0 */
  743. /* USER CODE END USB_OTG_FS_MspDeInit 0 */
  744. /* Peripheral clock disable */
  745. __HAL_RCC_USB_OTG_FS_CLK_DISABLE();
  746. /**USB_OTG_FS GPIO Configuration
  747. PA11 ------> USB_OTG_FS_DM
  748. PA12 ------> USB_OTG_FS_DP
  749. */
  750. HAL_GPIO_DeInit(GPIOA, GPIO_PIN_11|GPIO_PIN_12);
  751. /* USB_OTG_FS interrupt DeInit */
  752. HAL_NVIC_DisableIRQ(OTG_FS_IRQn);
  753. /* USER CODE BEGIN USB_OTG_FS_MspDeInit 1 */
  754. /* USER CODE END USB_OTG_FS_MspDeInit 1 */
  755. }
  756. }
  757. static uint32_t FMC_Initialized = 0;
  758. static void HAL_FMC_MspInit(void){
  759. /* USER CODE BEGIN FMC_MspInit 0 */
  760. /* USER CODE END FMC_MspInit 0 */
  761. GPIO_InitTypeDef GPIO_InitStruct ={0};
  762. if (FMC_Initialized) {
  763. return;
  764. }
  765. FMC_Initialized = 1;
  766. /* Peripheral clock enable */
  767. __HAL_RCC_FMC_CLK_ENABLE();
  768. /** FMC GPIO Configuration
  769. PF0 ------> FMC_A0
  770. PF1 ------> FMC_A1
  771. PF2 ------> FMC_A2
  772. PF3 ------> FMC_A3
  773. PF4 ------> FMC_A4
  774. PF5 ------> FMC_A5
  775. PC0 ------> FMC_SDNWE
  776. PC2 ------> FMC_SDNE0
  777. PC3 ------> FMC_SDCKE0
  778. PF11 ------> FMC_SDNRAS
  779. PF12 ------> FMC_A6
  780. PF13 ------> FMC_A7
  781. PF14 ------> FMC_A8
  782. PF15 ------> FMC_A9
  783. PG0 ------> FMC_A10
  784. PG1 ------> FMC_A11
  785. PE7 ------> FMC_D4
  786. PE8 ------> FMC_D5
  787. PE9 ------> FMC_D6
  788. PE10 ------> FMC_D7
  789. PE11 ------> FMC_D8
  790. PE12 ------> FMC_D9
  791. PE13 ------> FMC_D10
  792. PE14 ------> FMC_D11
  793. PE15 ------> FMC_D12
  794. PD8 ------> FMC_D13
  795. PD9 ------> FMC_D14
  796. PD10 ------> FMC_D15
  797. PD14 ------> FMC_D0
  798. PD15 ------> FMC_D1
  799. PG2 ------> FMC_A12
  800. PG4 ------> FMC_BA0
  801. PG5 ------> FMC_BA1
  802. PG8 ------> FMC_SDCLK
  803. PD0 ------> FMC_D2
  804. PD1 ------> FMC_D3
  805. PG15 ------> FMC_SDNCAS
  806. PE0 ------> FMC_NBL0
  807. PE1 ------> FMC_NBL1
  808. */
  809. GPIO_InitStruct.Pin = GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3
  810. |GPIO_PIN_4|GPIO_PIN_5|GPIO_PIN_11|GPIO_PIN_12
  811. |GPIO_PIN_13|GPIO_PIN_14|GPIO_PIN_15;
  812. GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
  813. GPIO_InitStruct.Pull = GPIO_NOPULL;
  814. GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
  815. GPIO_InitStruct.Alternate = GPIO_AF12_FMC;
  816. HAL_GPIO_Init(GPIOF, &GPIO_InitStruct);
  817. GPIO_InitStruct.Pin = GPIO_PIN_0|GPIO_PIN_2|GPIO_PIN_3;
  818. GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
  819. GPIO_InitStruct.Pull = GPIO_NOPULL;
  820. GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
  821. GPIO_InitStruct.Alternate = GPIO_AF12_FMC;
  822. HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
  823. GPIO_InitStruct.Pin = GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_4
  824. |GPIO_PIN_5|GPIO_PIN_8|GPIO_PIN_15;
  825. GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
  826. GPIO_InitStruct.Pull = GPIO_NOPULL;
  827. GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
  828. GPIO_InitStruct.Alternate = GPIO_AF12_FMC;
  829. HAL_GPIO_Init(GPIOG, &GPIO_InitStruct);
  830. GPIO_InitStruct.Pin = GPIO_PIN_7|GPIO_PIN_8|GPIO_PIN_9|GPIO_PIN_10
  831. |GPIO_PIN_11|GPIO_PIN_12|GPIO_PIN_13|GPIO_PIN_14
  832. |GPIO_PIN_15|GPIO_PIN_0|GPIO_PIN_1;
  833. GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
  834. GPIO_InitStruct.Pull = GPIO_NOPULL;
  835. GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
  836. GPIO_InitStruct.Alternate = GPIO_AF12_FMC;
  837. HAL_GPIO_Init(GPIOE, &GPIO_InitStruct);
  838. GPIO_InitStruct.Pin = GPIO_PIN_8|GPIO_PIN_9|GPIO_PIN_10|GPIO_PIN_14
  839. |GPIO_PIN_15|GPIO_PIN_0|GPIO_PIN_1;
  840. GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
  841. GPIO_InitStruct.Pull = GPIO_NOPULL;
  842. GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
  843. GPIO_InitStruct.Alternate = GPIO_AF12_FMC;
  844. HAL_GPIO_Init(GPIOD, &GPIO_InitStruct);
  845. /* USER CODE BEGIN FMC_MspInit 1 */
  846. /* USER CODE END FMC_MspInit 1 */
  847. }
  848. void HAL_SDRAM_MspInit(SDRAM_HandleTypeDef* hsdram){
  849. /* USER CODE BEGIN SDRAM_MspInit 0 */
  850. /* USER CODE END SDRAM_MspInit 0 */
  851. HAL_FMC_MspInit();
  852. /* USER CODE BEGIN SDRAM_MspInit 1 */
  853. /* USER CODE END SDRAM_MspInit 1 */
  854. }
  855. static uint32_t FMC_DeInitialized = 0;
  856. static void HAL_FMC_MspDeInit(void){
  857. /* USER CODE BEGIN FMC_MspDeInit 0 */
  858. /* USER CODE END FMC_MspDeInit 0 */
  859. if (FMC_DeInitialized) {
  860. return;
  861. }
  862. FMC_DeInitialized = 1;
  863. /* Peripheral clock enable */
  864. __HAL_RCC_FMC_CLK_DISABLE();
  865. /** FMC GPIO Configuration
  866. PF0 ------> FMC_A0
  867. PF1 ------> FMC_A1
  868. PF2 ------> FMC_A2
  869. PF3 ------> FMC_A3
  870. PF4 ------> FMC_A4
  871. PF5 ------> FMC_A5
  872. PC0 ------> FMC_SDNWE
  873. PC2 ------> FMC_SDNE0
  874. PC3 ------> FMC_SDCKE0
  875. PF11 ------> FMC_SDNRAS
  876. PF12 ------> FMC_A6
  877. PF13 ------> FMC_A7
  878. PF14 ------> FMC_A8
  879. PF15 ------> FMC_A9
  880. PG0 ------> FMC_A10
  881. PG1 ------> FMC_A11
  882. PE7 ------> FMC_D4
  883. PE8 ------> FMC_D5
  884. PE9 ------> FMC_D6
  885. PE10 ------> FMC_D7
  886. PE11 ------> FMC_D8
  887. PE12 ------> FMC_D9
  888. PE13 ------> FMC_D10
  889. PE14 ------> FMC_D11
  890. PE15 ------> FMC_D12
  891. PD8 ------> FMC_D13
  892. PD9 ------> FMC_D14
  893. PD10 ------> FMC_D15
  894. PD14 ------> FMC_D0
  895. PD15 ------> FMC_D1
  896. PG2 ------> FMC_A12
  897. PG4 ------> FMC_BA0
  898. PG5 ------> FMC_BA1
  899. PG8 ------> FMC_SDCLK
  900. PD0 ------> FMC_D2
  901. PD1 ------> FMC_D3
  902. PG15 ------> FMC_SDNCAS
  903. PE0 ------> FMC_NBL0
  904. PE1 ------> FMC_NBL1
  905. */
  906. HAL_GPIO_DeInit(GPIOF, GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3
  907. |GPIO_PIN_4|GPIO_PIN_5|GPIO_PIN_11|GPIO_PIN_12
  908. |GPIO_PIN_13|GPIO_PIN_14|GPIO_PIN_15);
  909. HAL_GPIO_DeInit(GPIOC, GPIO_PIN_0|GPIO_PIN_2|GPIO_PIN_3);
  910. HAL_GPIO_DeInit(GPIOG, GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_4
  911. |GPIO_PIN_5|GPIO_PIN_8|GPIO_PIN_15);
  912. HAL_GPIO_DeInit(GPIOE, GPIO_PIN_7|GPIO_PIN_8|GPIO_PIN_9|GPIO_PIN_10
  913. |GPIO_PIN_11|GPIO_PIN_12|GPIO_PIN_13|GPIO_PIN_14
  914. |GPIO_PIN_15|GPIO_PIN_0|GPIO_PIN_1);
  915. HAL_GPIO_DeInit(GPIOD, GPIO_PIN_8|GPIO_PIN_9|GPIO_PIN_10|GPIO_PIN_14
  916. |GPIO_PIN_15|GPIO_PIN_0|GPIO_PIN_1);
  917. /* USER CODE BEGIN FMC_MspDeInit 1 */
  918. /* USER CODE END FMC_MspDeInit 1 */
  919. }
  920. void HAL_SDRAM_MspDeInit(SDRAM_HandleTypeDef* hsdram){
  921. /* USER CODE BEGIN SDRAM_MspDeInit 0 */
  922. /* USER CODE END SDRAM_MspDeInit 0 */
  923. HAL_FMC_MspDeInit();
  924. /* USER CODE BEGIN SDRAM_MspDeInit 1 */
  925. /* USER CODE END SDRAM_MspDeInit 1 */
  926. }
  927. static uint32_t SAI1_client =0;
  928. void HAL_SAI_MspInit(SAI_HandleTypeDef* hsai)
  929. {
  930. GPIO_InitTypeDef GPIO_InitStruct;
  931. /* SAI1 */
  932. if(hsai->Instance==SAI1_Block_A)
  933. {
  934. /* Peripheral clock enable */
  935. if (SAI1_client == 0)
  936. {
  937. __HAL_RCC_SAI1_CLK_ENABLE();
  938. }
  939. SAI1_client ++;
  940. /**SAI1_A_Block_A GPIO Configuration
  941. PE2 ------> SAI1_MCLK_A
  942. PE4 ------> SAI1_FS_A
  943. PE5 ------> SAI1_SCK_A
  944. PE6 ------> SAI1_SD_A
  945. */
  946. GPIO_InitStruct.Pin = GPIO_PIN_2|GPIO_PIN_4|GPIO_PIN_5|GPIO_PIN_6;
  947. GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
  948. GPIO_InitStruct.Pull = GPIO_NOPULL;
  949. GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
  950. GPIO_InitStruct.Alternate = GPIO_AF6_SAI1;
  951. HAL_GPIO_Init(GPIOE, &GPIO_InitStruct);
  952. }
  953. if(hsai->Instance==SAI1_Block_B)
  954. {
  955. /* Peripheral clock enable */
  956. if (SAI1_client == 0)
  957. {
  958. __HAL_RCC_SAI1_CLK_ENABLE();
  959. }
  960. SAI1_client ++;
  961. /**SAI1_B_Block_B GPIO Configuration
  962. PE3 ------> SAI1_SD_B
  963. */
  964. GPIO_InitStruct.Pin = GPIO_PIN_3;
  965. GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
  966. GPIO_InitStruct.Pull = GPIO_NOPULL;
  967. GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
  968. GPIO_InitStruct.Alternate = GPIO_AF6_SAI1;
  969. HAL_GPIO_Init(GPIOE, &GPIO_InitStruct);
  970. }
  971. }
  972. void HAL_SAI_MspDeInit(SAI_HandleTypeDef* hsai)
  973. {
  974. /* SAI1 */
  975. if(hsai->Instance==SAI1_Block_A)
  976. {
  977. SAI1_client --;
  978. if (SAI1_client == 0)
  979. {
  980. /* Peripheral clock disable */
  981. __HAL_RCC_SAI1_CLK_DISABLE();
  982. }
  983. /**SAI1_A_Block_A GPIO Configuration
  984. PE2 ------> SAI1_MCLK_A
  985. PE4 ------> SAI1_FS_A
  986. PE5 ------> SAI1_SCK_A
  987. PE6 ------> SAI1_SD_A
  988. */
  989. HAL_GPIO_DeInit(GPIOE, GPIO_PIN_2|GPIO_PIN_4|GPIO_PIN_5|GPIO_PIN_6);
  990. }
  991. if(hsai->Instance==SAI1_Block_B)
  992. {
  993. SAI1_client --;
  994. if (SAI1_client == 0)
  995. {
  996. /* Peripheral clock disable */
  997. __HAL_RCC_SAI1_CLK_DISABLE();
  998. }
  999. /**SAI1_B_Block_B GPIO Configuration
  1000. PE3 ------> SAI1_SD_B
  1001. */
  1002. HAL_GPIO_DeInit(GPIOE, GPIO_PIN_3);
  1003. }
  1004. }
  1005. /* USER CODE BEGIN 1 */
  1006. /* USER CODE END 1 */
  1007. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/