stm32f7xx_hal_msp.c 35 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256
  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. static uint32_t FMC_Initialized = 0;
  875. static void HAL_FMC_MspInit(void){
  876. /* USER CODE BEGIN FMC_MspInit 0 */
  877. /* USER CODE END FMC_MspInit 0 */
  878. GPIO_InitTypeDef GPIO_InitStruct ={0};
  879. if (FMC_Initialized) {
  880. return;
  881. }
  882. FMC_Initialized = 1;
  883. /* Peripheral clock enable */
  884. __HAL_RCC_FMC_CLK_ENABLE();
  885. /** FMC GPIO Configuration
  886. PF0 ------> FMC_A0
  887. PF1 ------> FMC_A1
  888. PF2 ------> FMC_A2
  889. PF3 ------> FMC_A3
  890. PF4 ------> FMC_A4
  891. PF5 ------> FMC_A5
  892. PC0 ------> FMC_SDNWE
  893. PC2 ------> FMC_SDNE0
  894. PC3 ------> FMC_SDCKE0
  895. PF11 ------> FMC_SDNRAS
  896. PF12 ------> FMC_A6
  897. PF13 ------> FMC_A7
  898. PF14 ------> FMC_A8
  899. PF15 ------> FMC_A9
  900. PG0 ------> FMC_A10
  901. PG1 ------> FMC_A11
  902. PE7 ------> FMC_D4
  903. PE8 ------> FMC_D5
  904. PE9 ------> FMC_D6
  905. PE10 ------> FMC_D7
  906. PE11 ------> FMC_D8
  907. PE12 ------> FMC_D9
  908. PE13 ------> FMC_D10
  909. PE14 ------> FMC_D11
  910. PE15 ------> FMC_D12
  911. PD8 ------> FMC_D13
  912. PD9 ------> FMC_D14
  913. PD10 ------> FMC_D15
  914. PD14 ------> FMC_D0
  915. PD15 ------> FMC_D1
  916. PG2 ------> FMC_A12
  917. PG4 ------> FMC_BA0
  918. PG5 ------> FMC_BA1
  919. PG8 ------> FMC_SDCLK
  920. PD0 ------> FMC_D2
  921. PD1 ------> FMC_D3
  922. PG15 ------> FMC_SDNCAS
  923. */
  924. GPIO_InitStruct.Pin = GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3
  925. |GPIO_PIN_4|GPIO_PIN_5|GPIO_PIN_11|GPIO_PIN_12
  926. |GPIO_PIN_13|GPIO_PIN_14|GPIO_PIN_15;
  927. GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
  928. GPIO_InitStruct.Pull = GPIO_NOPULL;
  929. GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
  930. GPIO_InitStruct.Alternate = GPIO_AF12_FMC;
  931. HAL_GPIO_Init(GPIOF, &GPIO_InitStruct);
  932. GPIO_InitStruct.Pin = GPIO_PIN_0|GPIO_PIN_2|GPIO_PIN_3;
  933. GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
  934. GPIO_InitStruct.Pull = GPIO_NOPULL;
  935. GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
  936. GPIO_InitStruct.Alternate = GPIO_AF12_FMC;
  937. HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
  938. GPIO_InitStruct.Pin = GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_4
  939. |GPIO_PIN_5|GPIO_PIN_8|GPIO_PIN_15;
  940. GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
  941. GPIO_InitStruct.Pull = GPIO_NOPULL;
  942. GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
  943. GPIO_InitStruct.Alternate = GPIO_AF12_FMC;
  944. HAL_GPIO_Init(GPIOG, &GPIO_InitStruct);
  945. GPIO_InitStruct.Pin = GPIO_PIN_7|GPIO_PIN_8|GPIO_PIN_9|GPIO_PIN_10
  946. |GPIO_PIN_11|GPIO_PIN_12|GPIO_PIN_13|GPIO_PIN_14
  947. |GPIO_PIN_15;
  948. GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
  949. GPIO_InitStruct.Pull = GPIO_NOPULL;
  950. GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
  951. GPIO_InitStruct.Alternate = GPIO_AF12_FMC;
  952. HAL_GPIO_Init(GPIOE, &GPIO_InitStruct);
  953. GPIO_InitStruct.Pin = GPIO_PIN_8|GPIO_PIN_9|GPIO_PIN_10|GPIO_PIN_14
  954. |GPIO_PIN_15|GPIO_PIN_0|GPIO_PIN_1;
  955. GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
  956. GPIO_InitStruct.Pull = GPIO_NOPULL;
  957. GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
  958. GPIO_InitStruct.Alternate = GPIO_AF12_FMC;
  959. HAL_GPIO_Init(GPIOD, &GPIO_InitStruct);
  960. /* USER CODE BEGIN FMC_MspInit 1 */
  961. /* USER CODE END FMC_MspInit 1 */
  962. }
  963. void HAL_SDRAM_MspInit(SDRAM_HandleTypeDef* hsdram){
  964. /* USER CODE BEGIN SDRAM_MspInit 0 */
  965. /* USER CODE END SDRAM_MspInit 0 */
  966. HAL_FMC_MspInit();
  967. /* USER CODE BEGIN SDRAM_MspInit 1 */
  968. /* USER CODE END SDRAM_MspInit 1 */
  969. }
  970. static uint32_t FMC_DeInitialized = 0;
  971. static void HAL_FMC_MspDeInit(void){
  972. /* USER CODE BEGIN FMC_MspDeInit 0 */
  973. /* USER CODE END FMC_MspDeInit 0 */
  974. if (FMC_DeInitialized) {
  975. return;
  976. }
  977. FMC_DeInitialized = 1;
  978. /* Peripheral clock enable */
  979. __HAL_RCC_FMC_CLK_DISABLE();
  980. /** FMC GPIO Configuration
  981. PF0 ------> FMC_A0
  982. PF1 ------> FMC_A1
  983. PF2 ------> FMC_A2
  984. PF3 ------> FMC_A3
  985. PF4 ------> FMC_A4
  986. PF5 ------> FMC_A5
  987. PC0 ------> FMC_SDNWE
  988. PC2 ------> FMC_SDNE0
  989. PC3 ------> FMC_SDCKE0
  990. PF11 ------> FMC_SDNRAS
  991. PF12 ------> FMC_A6
  992. PF13 ------> FMC_A7
  993. PF14 ------> FMC_A8
  994. PF15 ------> FMC_A9
  995. PG0 ------> FMC_A10
  996. PG1 ------> FMC_A11
  997. PE7 ------> FMC_D4
  998. PE8 ------> FMC_D5
  999. PE9 ------> FMC_D6
  1000. PE10 ------> FMC_D7
  1001. PE11 ------> FMC_D8
  1002. PE12 ------> FMC_D9
  1003. PE13 ------> FMC_D10
  1004. PE14 ------> FMC_D11
  1005. PE15 ------> FMC_D12
  1006. PD8 ------> FMC_D13
  1007. PD9 ------> FMC_D14
  1008. PD10 ------> FMC_D15
  1009. PD14 ------> FMC_D0
  1010. PD15 ------> FMC_D1
  1011. PG2 ------> FMC_A12
  1012. PG4 ------> FMC_BA0
  1013. PG5 ------> FMC_BA1
  1014. PG8 ------> FMC_SDCLK
  1015. PD0 ------> FMC_D2
  1016. PD1 ------> FMC_D3
  1017. PG15 ------> FMC_SDNCAS
  1018. */
  1019. HAL_GPIO_DeInit(GPIOF, GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3
  1020. |GPIO_PIN_4|GPIO_PIN_5|GPIO_PIN_11|GPIO_PIN_12
  1021. |GPIO_PIN_13|GPIO_PIN_14|GPIO_PIN_15);
  1022. HAL_GPIO_DeInit(GPIOC, GPIO_PIN_0|GPIO_PIN_2|GPIO_PIN_3);
  1023. HAL_GPIO_DeInit(GPIOG, GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_4
  1024. |GPIO_PIN_5|GPIO_PIN_8|GPIO_PIN_15);
  1025. HAL_GPIO_DeInit(GPIOE, GPIO_PIN_7|GPIO_PIN_8|GPIO_PIN_9|GPIO_PIN_10
  1026. |GPIO_PIN_11|GPIO_PIN_12|GPIO_PIN_13|GPIO_PIN_14
  1027. |GPIO_PIN_15);
  1028. HAL_GPIO_DeInit(GPIOD, GPIO_PIN_8|GPIO_PIN_9|GPIO_PIN_10|GPIO_PIN_14
  1029. |GPIO_PIN_15|GPIO_PIN_0|GPIO_PIN_1);
  1030. /* USER CODE BEGIN FMC_MspDeInit 1 */
  1031. /* USER CODE END FMC_MspDeInit 1 */
  1032. }
  1033. void HAL_SDRAM_MspDeInit(SDRAM_HandleTypeDef* hsdram){
  1034. /* USER CODE BEGIN SDRAM_MspDeInit 0 */
  1035. /* USER CODE END SDRAM_MspDeInit 0 */
  1036. HAL_FMC_MspDeInit();
  1037. /* USER CODE BEGIN SDRAM_MspDeInit 1 */
  1038. /* USER CODE END SDRAM_MspDeInit 1 */
  1039. }
  1040. /* USER CODE BEGIN 1 */
  1041. /* USER CODE END 1 */
  1042. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/