stm32l4xx_hal_msp.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596
  1. /* USER CODE BEGIN Header */
  2. /**
  3. ******************************************************************************
  4. * File Name : stm32l4xx_hal_msp.c
  5. * Description : This file provides code for the MSP Initialization
  6. * and de-Initialization codes.
  7. ******************************************************************************
  8. * @attention
  9. *
  10. * <h2><center>&copy; Copyright (c) 2020 STMicroelectronics.
  11. * All rights reserved.</center></h2>
  12. *
  13. * This software component is licensed by ST under Ultimate Liberty license
  14. * SLA0044, the "License"; You may not use this file except in compliance with
  15. * the License. You may obtain a copy of the License at:
  16. * www.st.com/SLA0044
  17. *
  18. ******************************************************************************
  19. */
  20. /* USER CODE END Header */
  21. /* Includes ------------------------------------------------------------------*/
  22. #include "main.h"
  23. /* USER CODE BEGIN Includes */
  24. /* USER CODE END Includes */
  25. /* Private typedef -----------------------------------------------------------*/
  26. /* USER CODE BEGIN TD */
  27. /* USER CODE END TD */
  28. /* Private define ------------------------------------------------------------*/
  29. /* USER CODE BEGIN Define */
  30. /* USER CODE END Define */
  31. /* Private macro -------------------------------------------------------------*/
  32. /* USER CODE BEGIN Macro */
  33. /* USER CODE END Macro */
  34. /* Private variables ---------------------------------------------------------*/
  35. /* USER CODE BEGIN PV */
  36. /* USER CODE END PV */
  37. /* Private function prototypes -----------------------------------------------*/
  38. /* USER CODE BEGIN PFP */
  39. /* USER CODE END PFP */
  40. /* External functions --------------------------------------------------------*/
  41. /* USER CODE BEGIN ExternalFunctions */
  42. /* USER CODE END ExternalFunctions */
  43. /* USER CODE BEGIN 0 */
  44. /* USER CODE END 0 */
  45. void HAL_TIM_MspPostInit(TIM_HandleTypeDef* htim);
  46. /**
  47. * Initializes the Global MSP.
  48. */
  49. void HAL_MspInit(void) {
  50. /* USER CODE BEGIN MspInit 0 */
  51. /* USER CODE END MspInit 0 */
  52. __HAL_RCC_SYSCFG_CLK_ENABLE();
  53. __HAL_RCC_PWR_CLK_ENABLE();
  54. /* System interrupt init*/
  55. /* PendSV_IRQn interrupt configuration */
  56. HAL_NVIC_SetPriority(PendSV_IRQn, 15, 0);
  57. /* USER CODE BEGIN MspInit 1 */
  58. /* USER CODE END MspInit 1 */
  59. }
  60. /**
  61. * @brief ADC MSP Initialization
  62. * This function configures the hardware resources used in this example
  63. * @param hadc: ADC handle pointer
  64. * @retval None
  65. */
  66. void HAL_ADC_MspInit(ADC_HandleTypeDef* hadc) {
  67. GPIO_InitTypeDef GPIO_InitStruct = {0};
  68. if(hadc->Instance == ADC1) {
  69. /* USER CODE BEGIN ADC1_MspInit 0 */
  70. /* USER CODE END ADC1_MspInit 0 */
  71. /* Peripheral clock enable */
  72. __HAL_RCC_ADC_CLK_ENABLE();
  73. __HAL_RCC_GPIOC_CLK_ENABLE();
  74. __HAL_RCC_GPIOA_CLK_ENABLE();
  75. /**ADC1 GPIO Configuration
  76. PC3 ------> ADC1_IN4
  77. PA0 ------> ADC1_IN5
  78. */
  79. GPIO_InitStruct.Pin = BATT_V_Pin;
  80. GPIO_InitStruct.Mode = GPIO_MODE_ANALOG_ADC_CONTROL;
  81. GPIO_InitStruct.Pull = GPIO_NOPULL;
  82. HAL_GPIO_Init(BATT_V_GPIO_Port, &GPIO_InitStruct);
  83. GPIO_InitStruct.Pin = IR_RX_Pin;
  84. GPIO_InitStruct.Mode = GPIO_MODE_ANALOG_ADC_CONTROL;
  85. GPIO_InitStruct.Pull = GPIO_NOPULL;
  86. HAL_GPIO_Init(IR_RX_GPIO_Port, &GPIO_InitStruct);
  87. /* USER CODE BEGIN ADC1_MspInit 1 */
  88. /* USER CODE END ADC1_MspInit 1 */
  89. }
  90. }
  91. /**
  92. * @brief ADC MSP De-Initialization
  93. * This function freeze the hardware resources used in this example
  94. * @param hadc: ADC handle pointer
  95. * @retval None
  96. */
  97. void HAL_ADC_MspDeInit(ADC_HandleTypeDef* hadc) {
  98. if(hadc->Instance == ADC1) {
  99. /* USER CODE BEGIN ADC1_MspDeInit 0 */
  100. /* USER CODE END ADC1_MspDeInit 0 */
  101. /* Peripheral clock disable */
  102. __HAL_RCC_ADC_CLK_DISABLE();
  103. /**ADC1 GPIO Configuration
  104. PC3 ------> ADC1_IN4
  105. PA0 ------> ADC1_IN5
  106. */
  107. HAL_GPIO_DeInit(BATT_V_GPIO_Port, BATT_V_Pin);
  108. HAL_GPIO_DeInit(IR_RX_GPIO_Port, IR_RX_Pin);
  109. /* USER CODE BEGIN ADC1_MspDeInit 1 */
  110. /* USER CODE END ADC1_MspDeInit 1 */
  111. }
  112. }
  113. /**
  114. * @brief COMP MSP Initialization
  115. * This function configures the hardware resources used in this example
  116. * @param hcomp: COMP handle pointer
  117. * @retval None
  118. */
  119. void HAL_COMP_MspInit(COMP_HandleTypeDef* hcomp) {
  120. GPIO_InitTypeDef GPIO_InitStruct = {0};
  121. if(hcomp->Instance == COMP1) {
  122. /* USER CODE BEGIN COMP1_MspInit 0 */
  123. /* USER CODE END COMP1_MspInit 0 */
  124. __HAL_RCC_GPIOC_CLK_ENABLE();
  125. /**COMP1 GPIO Configuration
  126. PC5 ------> COMP1_INP
  127. */
  128. GPIO_InitStruct.Pin = RFID_RF_IN_Pin;
  129. GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
  130. GPIO_InitStruct.Pull = GPIO_NOPULL;
  131. HAL_GPIO_Init(RFID_RF_IN_GPIO_Port, &GPIO_InitStruct);
  132. /* USER CODE BEGIN COMP1_MspInit 1 */
  133. /* USER CODE END COMP1_MspInit 1 */
  134. }
  135. }
  136. /**
  137. * @brief COMP MSP De-Initialization
  138. * This function freeze the hardware resources used in this example
  139. * @param hcomp: COMP handle pointer
  140. * @retval None
  141. */
  142. void HAL_COMP_MspDeInit(COMP_HandleTypeDef* hcomp) {
  143. if(hcomp->Instance == COMP1) {
  144. /* USER CODE BEGIN COMP1_MspDeInit 0 */
  145. /* USER CODE END COMP1_MspDeInit 0 */
  146. /**COMP1 GPIO Configuration
  147. PC5 ------> COMP1_INP
  148. */
  149. HAL_GPIO_DeInit(RFID_RF_IN_GPIO_Port, RFID_RF_IN_Pin);
  150. /* USER CODE BEGIN COMP1_MspDeInit 1 */
  151. /* USER CODE END COMP1_MspDeInit 1 */
  152. }
  153. }
  154. /**
  155. * @brief DAC MSP Initialization
  156. * This function configures the hardware resources used in this example
  157. * @param hdac: DAC handle pointer
  158. * @retval None
  159. */
  160. void HAL_DAC_MspInit(DAC_HandleTypeDef* hdac) {
  161. GPIO_InitTypeDef GPIO_InitStruct = {0};
  162. if(hdac->Instance == DAC1) {
  163. /* USER CODE BEGIN DAC1_MspInit 0 */
  164. /* USER CODE END DAC1_MspInit 0 */
  165. /* Peripheral clock enable */
  166. __HAL_RCC_DAC1_CLK_ENABLE();
  167. __HAL_RCC_GPIOA_CLK_ENABLE();
  168. /**DAC1 GPIO Configuration
  169. PA4 ------> DAC1_OUT1
  170. */
  171. GPIO_InitStruct.Pin = RFID_REF_Pin;
  172. GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
  173. GPIO_InitStruct.Pull = GPIO_NOPULL;
  174. HAL_GPIO_Init(RFID_REF_GPIO_Port, &GPIO_InitStruct);
  175. /* USER CODE BEGIN DAC1_MspInit 1 */
  176. /* USER CODE END DAC1_MspInit 1 */
  177. }
  178. }
  179. /**
  180. * @brief DAC MSP De-Initialization
  181. * This function freeze the hardware resources used in this example
  182. * @param hdac: DAC handle pointer
  183. * @retval None
  184. */
  185. void HAL_DAC_MspDeInit(DAC_HandleTypeDef* hdac) {
  186. if(hdac->Instance == DAC1) {
  187. /* USER CODE BEGIN DAC1_MspDeInit 0 */
  188. /* USER CODE END DAC1_MspDeInit 0 */
  189. /* Peripheral clock disable */
  190. __HAL_RCC_DAC1_CLK_DISABLE();
  191. /**DAC1 GPIO Configuration
  192. PA4 ------> DAC1_OUT1
  193. */
  194. HAL_GPIO_DeInit(RFID_REF_GPIO_Port, RFID_REF_Pin);
  195. /* USER CODE BEGIN DAC1_MspDeInit 1 */
  196. /* USER CODE END DAC1_MspDeInit 1 */
  197. }
  198. }
  199. /**
  200. * @brief SPI MSP Initialization
  201. * This function configures the hardware resources used in this example
  202. * @param hspi: SPI handle pointer
  203. * @retval None
  204. */
  205. void HAL_SPI_MspInit(SPI_HandleTypeDef* hspi) {
  206. GPIO_InitTypeDef GPIO_InitStruct = {0};
  207. if(hspi->Instance == SPI1) {
  208. /* USER CODE BEGIN SPI1_MspInit 0 */
  209. /* USER CODE END SPI1_MspInit 0 */
  210. /* Peripheral clock enable */
  211. __HAL_RCC_SPI1_CLK_ENABLE();
  212. __HAL_RCC_GPIOB_CLK_ENABLE();
  213. /**SPI1 GPIO Configuration
  214. PB3 (JTDO-TRACESWO) ------> SPI1_SCK
  215. PB5 ------> SPI1_MOSI
  216. */
  217. GPIO_InitStruct.Pin = GPIO_PIN_3 | GPIO_PIN_5;
  218. GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
  219. GPIO_InitStruct.Pull = GPIO_NOPULL;
  220. GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
  221. GPIO_InitStruct.Alternate = GPIO_AF5_SPI1;
  222. HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
  223. /* USER CODE BEGIN SPI1_MspInit 1 */
  224. /* USER CODE END SPI1_MspInit 1 */
  225. } else if(hspi->Instance == SPI3) {
  226. /* USER CODE BEGIN SPI3_MspInit 0 */
  227. /* USER CODE END SPI3_MspInit 0 */
  228. /* Peripheral clock enable */
  229. __HAL_RCC_SPI3_CLK_ENABLE();
  230. __HAL_RCC_GPIOC_CLK_ENABLE();
  231. /**SPI3 GPIO Configuration
  232. PC10 ------> SPI3_SCK
  233. PC11 ------> SPI3_MISO
  234. PC12 ------> SPI3_MOSI
  235. */
  236. GPIO_InitStruct.Pin = GPIO_PIN_10 | GPIO_PIN_11 | GPIO_PIN_12;
  237. GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
  238. GPIO_InitStruct.Pull = GPIO_NOPULL;
  239. GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
  240. GPIO_InitStruct.Alternate = GPIO_AF6_SPI3;
  241. HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
  242. /* USER CODE BEGIN SPI3_MspInit 1 */
  243. /* USER CODE END SPI3_MspInit 1 */
  244. }
  245. }
  246. /**
  247. * @brief SPI MSP De-Initialization
  248. * This function freeze the hardware resources used in this example
  249. * @param hspi: SPI handle pointer
  250. * @retval None
  251. */
  252. void HAL_SPI_MspDeInit(SPI_HandleTypeDef* hspi) {
  253. if(hspi->Instance == SPI1) {
  254. /* USER CODE BEGIN SPI1_MspDeInit 0 */
  255. /* USER CODE END SPI1_MspDeInit 0 */
  256. /* Peripheral clock disable */
  257. __HAL_RCC_SPI1_CLK_DISABLE();
  258. /**SPI1 GPIO Configuration
  259. PB3 (JTDO-TRACESWO) ------> SPI1_SCK
  260. PB5 ------> SPI1_MOSI
  261. */
  262. HAL_GPIO_DeInit(GPIOB, GPIO_PIN_3 | GPIO_PIN_5);
  263. /* USER CODE BEGIN SPI1_MspDeInit 1 */
  264. /* USER CODE END SPI1_MspDeInit 1 */
  265. } else if(hspi->Instance == SPI3) {
  266. /* USER CODE BEGIN SPI3_MspDeInit 0 */
  267. /* USER CODE END SPI3_MspDeInit 0 */
  268. /* Peripheral clock disable */
  269. __HAL_RCC_SPI3_CLK_DISABLE();
  270. /**SPI3 GPIO Configuration
  271. PC10 ------> SPI3_SCK
  272. PC11 ------> SPI3_MISO
  273. PC12 ------> SPI3_MOSI
  274. */
  275. HAL_GPIO_DeInit(GPIOC, GPIO_PIN_10 | GPIO_PIN_11 | GPIO_PIN_12);
  276. /* USER CODE BEGIN SPI3_MspDeInit 1 */
  277. /* USER CODE END SPI3_MspDeInit 1 */
  278. }
  279. }
  280. /**
  281. * @brief TIM_PWM MSP Initialization
  282. * This function configures the hardware resources used in this example
  283. * @param htim_pwm: TIM_PWM handle pointer
  284. * @retval None
  285. */
  286. void HAL_TIM_PWM_MspInit(TIM_HandleTypeDef* htim_pwm) {
  287. if(htim_pwm->Instance == TIM5) {
  288. /* USER CODE BEGIN TIM5_MspInit 0 */
  289. /* USER CODE END TIM5_MspInit 0 */
  290. /* Peripheral clock enable */
  291. __HAL_RCC_TIM5_CLK_ENABLE();
  292. /* USER CODE BEGIN TIM5_MspInit 1 */
  293. /* USER CODE END TIM5_MspInit 1 */
  294. }
  295. }
  296. /**
  297. * @brief TIM_Base MSP Initialization
  298. * This function configures the hardware resources used in this example
  299. * @param htim_base: TIM_Base handle pointer
  300. * @retval None
  301. */
  302. void HAL_TIM_Base_MspInit(TIM_HandleTypeDef* htim_base) {
  303. GPIO_InitTypeDef GPIO_InitStruct = {0};
  304. if(htim_base->Instance == TIM8) {
  305. /* USER CODE BEGIN TIM8_MspInit 0 */
  306. /* USER CODE END TIM8_MspInit 0 */
  307. /* Peripheral clock enable */
  308. __HAL_RCC_TIM8_CLK_ENABLE();
  309. __HAL_RCC_GPIOC_CLK_ENABLE();
  310. /**TIM8 GPIO Configuration
  311. PC7 ------> TIM8_CH2
  312. */
  313. GPIO_InitStruct.Pin = iButton_Pin;
  314. GPIO_InitStruct.Mode = GPIO_MODE_AF_OD;
  315. GPIO_InitStruct.Pull = GPIO_NOPULL;
  316. GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_MEDIUM;
  317. GPIO_InitStruct.Alternate = GPIO_AF3_TIM8;
  318. HAL_GPIO_Init(iButton_GPIO_Port, &GPIO_InitStruct);
  319. /* TIM8 interrupt Init */
  320. HAL_NVIC_SetPriority(TIM8_CC_IRQn, 5, 0);
  321. HAL_NVIC_EnableIRQ(TIM8_CC_IRQn);
  322. /* USER CODE BEGIN TIM8_MspInit 1 */
  323. /* USER CODE END TIM8_MspInit 1 */
  324. }
  325. }
  326. /**
  327. * @brief TIM_OC MSP Initialization
  328. * This function configures the hardware resources used in this example
  329. * @param htim_oc: TIM_OC handle pointer
  330. * @retval None
  331. */
  332. void HAL_TIM_OC_MspInit(TIM_HandleTypeDef* htim_oc) {
  333. if(htim_oc->Instance == TIM15) {
  334. /* USER CODE BEGIN TIM15_MspInit 0 */
  335. /* USER CODE END TIM15_MspInit 0 */
  336. /* Peripheral clock enable */
  337. __HAL_RCC_TIM15_CLK_ENABLE();
  338. /* USER CODE BEGIN TIM15_MspInit 1 */
  339. /* USER CODE END TIM15_MspInit 1 */
  340. }
  341. }
  342. void HAL_TIM_MspPostInit(TIM_HandleTypeDef* htim) {
  343. GPIO_InitTypeDef GPIO_InitStruct = {0};
  344. if(htim->Instance == TIM5) {
  345. /* USER CODE BEGIN TIM5_MspPostInit 0 */
  346. /* USER CODE END TIM5_MspPostInit 0 */
  347. __HAL_RCC_GPIOA_CLK_ENABLE();
  348. /**TIM5 GPIO Configuration
  349. PA3 ------> TIM5_CH4
  350. */
  351. GPIO_InitStruct.Pin = SPEAKER_Pin;
  352. GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
  353. GPIO_InitStruct.Pull = GPIO_NOPULL;
  354. GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
  355. GPIO_InitStruct.Alternate = GPIO_AF2_TIM5;
  356. HAL_GPIO_Init(SPEAKER_GPIO_Port, &GPIO_InitStruct);
  357. /* USER CODE BEGIN TIM5_MspPostInit 1 */
  358. /* USER CODE END TIM5_MspPostInit 1 */
  359. } else if(htim->Instance == TIM15) {
  360. /* USER CODE BEGIN TIM15_MspPostInit 0 */
  361. /* USER CODE END TIM15_MspPostInit 0 */
  362. __HAL_RCC_GPIOB_CLK_ENABLE();
  363. /**TIM15 GPIO Configuration
  364. PB13 ------> TIM15_CH1N
  365. PB15 ------> TIM15_CH2
  366. */
  367. GPIO_InitStruct.Pin = RFID_OUT_Pin | RFID_PULL_Pin;
  368. GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
  369. GPIO_InitStruct.Pull = GPIO_NOPULL;
  370. GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
  371. GPIO_InitStruct.Alternate = GPIO_AF14_TIM15;
  372. HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
  373. /* USER CODE BEGIN TIM15_MspPostInit 1 */
  374. /* USER CODE END TIM15_MspPostInit 1 */
  375. }
  376. }
  377. /**
  378. * @brief TIM_PWM MSP De-Initialization
  379. * This function freeze the hardware resources used in this example
  380. * @param htim_pwm: TIM_PWM handle pointer
  381. * @retval None
  382. */
  383. void HAL_TIM_PWM_MspDeInit(TIM_HandleTypeDef* htim_pwm) {
  384. if(htim_pwm->Instance == TIM5) {
  385. /* USER CODE BEGIN TIM5_MspDeInit 0 */
  386. /* USER CODE END TIM5_MspDeInit 0 */
  387. /* Peripheral clock disable */
  388. __HAL_RCC_TIM5_CLK_DISABLE();
  389. /* USER CODE BEGIN TIM5_MspDeInit 1 */
  390. /* USER CODE END TIM5_MspDeInit 1 */
  391. }
  392. }
  393. /**
  394. * @brief TIM_Base MSP De-Initialization
  395. * This function freeze the hardware resources used in this example
  396. * @param htim_base: TIM_Base handle pointer
  397. * @retval None
  398. */
  399. void HAL_TIM_Base_MspDeInit(TIM_HandleTypeDef* htim_base) {
  400. if(htim_base->Instance == TIM8) {
  401. /* USER CODE BEGIN TIM8_MspDeInit 0 */
  402. /* USER CODE END TIM8_MspDeInit 0 */
  403. /* Peripheral clock disable */
  404. __HAL_RCC_TIM8_CLK_DISABLE();
  405. /**TIM8 GPIO Configuration
  406. PC7 ------> TIM8_CH2
  407. */
  408. HAL_GPIO_DeInit(iButton_GPIO_Port, iButton_Pin);
  409. /* TIM8 interrupt DeInit */
  410. HAL_NVIC_DisableIRQ(TIM8_CC_IRQn);
  411. /* USER CODE BEGIN TIM8_MspDeInit 1 */
  412. /* USER CODE END TIM8_MspDeInit 1 */
  413. }
  414. }
  415. /**
  416. * @brief TIM_OC MSP De-Initialization
  417. * This function freeze the hardware resources used in this example
  418. * @param htim_oc: TIM_OC handle pointer
  419. * @retval None
  420. */
  421. void HAL_TIM_OC_MspDeInit(TIM_HandleTypeDef* htim_oc) {
  422. if(htim_oc->Instance == TIM15) {
  423. /* USER CODE BEGIN TIM15_MspDeInit 0 */
  424. /* USER CODE END TIM15_MspDeInit 0 */
  425. /* Peripheral clock disable */
  426. __HAL_RCC_TIM15_CLK_DISABLE();
  427. /* USER CODE BEGIN TIM15_MspDeInit 1 */
  428. /* USER CODE END TIM15_MspDeInit 1 */
  429. }
  430. }
  431. /**
  432. * @brief UART MSP Initialization
  433. * This function configures the hardware resources used in this example
  434. * @param huart: UART handle pointer
  435. * @retval None
  436. */
  437. void HAL_UART_MspInit(UART_HandleTypeDef* huart) {
  438. GPIO_InitTypeDef GPIO_InitStruct = {0};
  439. if(huart->Instance == USART1) {
  440. /* USER CODE BEGIN USART1_MspInit 0 */
  441. /* USER CODE END USART1_MspInit 0 */
  442. /* Peripheral clock enable */
  443. __HAL_RCC_USART1_CLK_ENABLE();
  444. __HAL_RCC_GPIOA_CLK_ENABLE();
  445. /**USART1 GPIO Configuration
  446. PA9 ------> USART1_TX
  447. PA10 ------> USART1_RX
  448. */
  449. GPIO_InitStruct.Pin = GPIO_PIN_9 | GPIO_PIN_10;
  450. GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
  451. GPIO_InitStruct.Pull = GPIO_NOPULL;
  452. GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
  453. GPIO_InitStruct.Alternate = GPIO_AF7_USART1;
  454. HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
  455. /* USER CODE BEGIN USART1_MspInit 1 */
  456. /* USER CODE END USART1_MspInit 1 */
  457. }
  458. }
  459. /**
  460. * @brief UART MSP De-Initialization
  461. * This function freeze the hardware resources used in this example
  462. * @param huart: UART handle pointer
  463. * @retval None
  464. */
  465. void HAL_UART_MspDeInit(UART_HandleTypeDef* huart) {
  466. if(huart->Instance == USART1) {
  467. /* USER CODE BEGIN USART1_MspDeInit 0 */
  468. /* USER CODE END USART1_MspDeInit 0 */
  469. /* Peripheral clock disable */
  470. __HAL_RCC_USART1_CLK_DISABLE();
  471. /**USART1 GPIO Configuration
  472. PA9 ------> USART1_TX
  473. PA10 ------> USART1_RX
  474. */
  475. HAL_GPIO_DeInit(GPIOA, GPIO_PIN_9 | GPIO_PIN_10);
  476. /* USER CODE BEGIN USART1_MspDeInit 1 */
  477. /* USER CODE END USART1_MspDeInit 1 */
  478. }
  479. }
  480. /* USER CODE BEGIN 1 */
  481. /* USER CODE END 1 */
  482. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/