stm32f7xx_hal_msp.c 36 KB

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