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