stm32l4xx_hal_msp.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635
  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 BSD 3-Clause license,
  14. * the "License"; You may not use this file except in compliance with the
  15. * License. You may obtain a copy of the License at:
  16. * opensource.org/licenses/BSD-3-Clause
  17. *
  18. ******************************************************************************
  19. */
  20. /* USER CODE END Header */
  21. /* Includes ------------------------------------------------------------------*/
  22. #include "main.h"
  23. /* USER CODE BEGIN Includes */
  24. #include <drv_common.h>
  25. /* USER CODE END Includes */
  26. /* Private typedef -----------------------------------------------------------*/
  27. /* USER CODE BEGIN TD */
  28. /* USER CODE END TD */
  29. /* Private define ------------------------------------------------------------*/
  30. /* USER CODE BEGIN Define */
  31. /* USER CODE END Define */
  32. /* Private macro -------------------------------------------------------------*/
  33. /* USER CODE BEGIN Macro */
  34. /* USER CODE END Macro */
  35. /* Private variables ---------------------------------------------------------*/
  36. /* USER CODE BEGIN PV */
  37. /* USER CODE END PV */
  38. /* Private function prototypes -----------------------------------------------*/
  39. /* USER CODE BEGIN PFP */
  40. /* USER CODE END PFP */
  41. /* External functions --------------------------------------------------------*/
  42. /* USER CODE BEGIN ExternalFunctions */
  43. /* USER CODE END ExternalFunctions */
  44. /* USER CODE BEGIN 0 */
  45. /* USER CODE END 0 */
  46. void HAL_TIM_MspPostInit(TIM_HandleTypeDef *htim);
  47. /**
  48. * Initializes the Global MSP.
  49. */
  50. void HAL_MspInit(void)
  51. {
  52. /* USER CODE BEGIN MspInit 0 */
  53. /* USER CODE END MspInit 0 */
  54. __HAL_RCC_SYSCFG_CLK_ENABLE();
  55. __HAL_RCC_PWR_CLK_ENABLE();
  56. /* System interrupt init*/
  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. {
  68. GPIO_InitTypeDef GPIO_InitStruct = {0};
  69. RCC_PeriphCLKInitTypeDef PeriphClkInit = {0};
  70. if(hadc->Instance==ADC1)
  71. {
  72. /* USER CODE BEGIN ADC1_MspInit 0 */
  73. /* USER CODE END ADC1_MspInit 0 */
  74. /** Initializes the peripherals clock
  75. */
  76. PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_ADC;
  77. PeriphClkInit.AdcClockSelection = RCC_ADCCLKSOURCE_PLLSAI1;
  78. PeriphClkInit.PLLSAI1.PLLSAI1Source = RCC_PLLSOURCE_MSI;
  79. PeriphClkInit.PLLSAI1.PLLSAI1M = 1;
  80. PeriphClkInit.PLLSAI1.PLLSAI1N = 16;
  81. PeriphClkInit.PLLSAI1.PLLSAI1P = RCC_PLLP_DIV7;
  82. PeriphClkInit.PLLSAI1.PLLSAI1Q = RCC_PLLQ_DIV2;
  83. PeriphClkInit.PLLSAI1.PLLSAI1R = RCC_PLLR_DIV2;
  84. PeriphClkInit.PLLSAI1.PLLSAI1ClockOut = RCC_PLLSAI1_ADC1CLK;
  85. if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInit) != HAL_OK)
  86. {
  87. Error_Handler();
  88. }
  89. /* Peripheral clock enable */
  90. __HAL_RCC_ADC_CLK_ENABLE();
  91. __HAL_RCC_GPIOC_CLK_ENABLE();
  92. /**ADC1 GPIO Configuration
  93. PC2 ------> ADC1_IN3
  94. */
  95. GPIO_InitStruct.Pin = GPIO_PIN_2;
  96. GPIO_InitStruct.Mode = GPIO_MODE_ANALOG_ADC_CONTROL;
  97. GPIO_InitStruct.Pull = GPIO_NOPULL;
  98. HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
  99. /* USER CODE BEGIN ADC1_MspInit 1 */
  100. /* USER CODE END ADC1_MspInit 1 */
  101. }
  102. }
  103. /**
  104. * @brief ADC MSP De-Initialization
  105. * This function freeze the hardware resources used in this example
  106. * @param hadc: ADC handle pointer
  107. * @retval None
  108. */
  109. void HAL_ADC_MspDeInit(ADC_HandleTypeDef* hadc)
  110. {
  111. if(hadc->Instance==ADC1)
  112. {
  113. /* USER CODE BEGIN ADC1_MspDeInit 0 */
  114. /* USER CODE END ADC1_MspDeInit 0 */
  115. /* Peripheral clock disable */
  116. __HAL_RCC_ADC_CLK_DISABLE();
  117. /**ADC1 GPIO Configuration
  118. PC2 ------> ADC1_IN3
  119. */
  120. HAL_GPIO_DeInit(GPIOC, GPIO_PIN_2);
  121. /* USER CODE BEGIN ADC1_MspDeInit 1 */
  122. /* USER CODE END ADC1_MspDeInit 1 */
  123. }
  124. }
  125. /**
  126. * @brief DAC MSP Initialization
  127. * This function configures the hardware resources used in this example
  128. * @param hdac: DAC handle pointer
  129. * @retval None
  130. */
  131. void HAL_DAC_MspInit(DAC_HandleTypeDef* hdac)
  132. {
  133. GPIO_InitTypeDef GPIO_InitStruct = {0};
  134. if(hdac->Instance==DAC1)
  135. {
  136. /* USER CODE BEGIN DAC1_MspInit 0 */
  137. /* USER CODE END DAC1_MspInit 0 */
  138. /* Peripheral clock enable */
  139. __HAL_RCC_DAC1_CLK_ENABLE();
  140. __HAL_RCC_GPIOA_CLK_ENABLE();
  141. /**DAC1 GPIO Configuration
  142. PA5 ------> DAC1_OUT2
  143. */
  144. GPIO_InitStruct.Pin = GPIO_PIN_5;
  145. GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
  146. GPIO_InitStruct.Pull = GPIO_NOPULL;
  147. HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
  148. /* USER CODE BEGIN DAC1_MspInit 1 */
  149. /* USER CODE END DAC1_MspInit 1 */
  150. }
  151. }
  152. /**
  153. * @brief DAC MSP De-Initialization
  154. * This function freeze the hardware resources used in this example
  155. * @param hdac: DAC handle pointer
  156. * @retval None
  157. */
  158. void HAL_DAC_MspDeInit(DAC_HandleTypeDef* hdac)
  159. {
  160. if(hdac->Instance==DAC1)
  161. {
  162. /* USER CODE BEGIN DAC1_MspDeInit 0 */
  163. /* USER CODE END DAC1_MspDeInit 0 */
  164. /* Peripheral clock disable */
  165. __HAL_RCC_DAC1_CLK_DISABLE();
  166. /**DAC1 GPIO Configuration
  167. PA5 ------> DAC1_OUT2
  168. */
  169. HAL_GPIO_DeInit(GPIOA, GPIO_PIN_5);
  170. /* USER CODE BEGIN DAC1_MspDeInit 1 */
  171. /* USER CODE END DAC1_MspDeInit 1 */
  172. }
  173. }
  174. /**
  175. * @brief UART MSP Initialization
  176. * This function configures the hardware resources used in this example
  177. * @param huart: UART handle pointer
  178. * @retval None
  179. */
  180. void HAL_UART_MspInit(UART_HandleTypeDef* huart)
  181. {
  182. GPIO_InitTypeDef GPIO_InitStruct = {0};
  183. RCC_PeriphCLKInitTypeDef PeriphClkInit = {0};
  184. if(huart->Instance==LPUART1)
  185. {
  186. /* USER CODE BEGIN LPUART1_MspInit 0 */
  187. /* USER CODE END LPUART1_MspInit 0 */
  188. /** Initializes the peripherals clock
  189. */
  190. PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_LPUART1;
  191. PeriphClkInit.Lpuart1ClockSelection = RCC_LPUART1CLKSOURCE_PCLK1;
  192. if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInit) != HAL_OK)
  193. {
  194. Error_Handler();
  195. }
  196. /* Peripheral clock enable */
  197. __HAL_RCC_LPUART1_CLK_ENABLE();
  198. __HAL_RCC_GPIOC_CLK_ENABLE();
  199. /**LPUART1 GPIO Configuration
  200. PC0 ------> LPUART1_RX
  201. PC1 ------> LPUART1_TX
  202. */
  203. GPIO_InitStruct.Pin = GPIO_PIN_0|GPIO_PIN_1;
  204. GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
  205. GPIO_InitStruct.Pull = GPIO_NOPULL;
  206. GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
  207. GPIO_InitStruct.Alternate = GPIO_AF8_LPUART1;
  208. HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
  209. /* USER CODE BEGIN LPUART1_MspInit 1 */
  210. /* USER CODE END LPUART1_MspInit 1 */
  211. }
  212. else if(huart->Instance==USART1)
  213. {
  214. /* USER CODE BEGIN USART1_MspInit 0 */
  215. /* USER CODE END USART1_MspInit 0 */
  216. /** Initializes the peripherals clock
  217. */
  218. PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_USART1;
  219. PeriphClkInit.Usart1ClockSelection = RCC_USART1CLKSOURCE_PCLK2;
  220. if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInit) != HAL_OK)
  221. {
  222. Error_Handler();
  223. }
  224. /* Peripheral clock enable */
  225. __HAL_RCC_USART1_CLK_ENABLE();
  226. __HAL_RCC_GPIOA_CLK_ENABLE();
  227. /**USART1 GPIO Configuration
  228. PA9 ------> USART1_TX
  229. PA10 ------> USART1_RX
  230. */
  231. GPIO_InitStruct.Pin = GPIO_PIN_9|GPIO_PIN_10;
  232. GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
  233. GPIO_InitStruct.Pull = GPIO_PULLUP;
  234. GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
  235. GPIO_InitStruct.Alternate = GPIO_AF7_USART1;
  236. HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
  237. /* USER CODE BEGIN USART1_MspInit 1 */
  238. /* USER CODE END USART1_MspInit 1 */
  239. }
  240. else if(huart->Instance==USART3)
  241. {
  242. /* USER CODE BEGIN USART3_MspInit 0 */
  243. /* USER CODE END USART3_MspInit 0 */
  244. /** Initializes the peripherals clock
  245. */
  246. PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_USART3;
  247. PeriphClkInit.Usart3ClockSelection = RCC_USART3CLKSOURCE_PCLK1;
  248. if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInit) != HAL_OK)
  249. {
  250. Error_Handler();
  251. }
  252. /* Peripheral clock enable */
  253. __HAL_RCC_USART3_CLK_ENABLE();
  254. __HAL_RCC_GPIOC_CLK_ENABLE();
  255. /**USART3 GPIO Configuration
  256. PC4 ------> USART3_TX
  257. PC5 ------> USART3_RX
  258. */
  259. GPIO_InitStruct.Pin = GPIO_PIN_4|GPIO_PIN_5;
  260. GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
  261. GPIO_InitStruct.Pull = GPIO_NOPULL;
  262. GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
  263. GPIO_InitStruct.Alternate = GPIO_AF7_USART3;
  264. HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
  265. /* USER CODE BEGIN USART3_MspInit 1 */
  266. /* USER CODE END USART3_MspInit 1 */
  267. }
  268. }
  269. /**
  270. * @brief UART MSP De-Initialization
  271. * This function freeze the hardware resources used in this example
  272. * @param huart: UART handle pointer
  273. * @retval None
  274. */
  275. void HAL_UART_MspDeInit(UART_HandleTypeDef* huart)
  276. {
  277. if(huart->Instance==LPUART1)
  278. {
  279. /* USER CODE BEGIN LPUART1_MspDeInit 0 */
  280. /* USER CODE END LPUART1_MspDeInit 0 */
  281. /* Peripheral clock disable */
  282. __HAL_RCC_LPUART1_CLK_DISABLE();
  283. /**LPUART1 GPIO Configuration
  284. PC0 ------> LPUART1_RX
  285. PC1 ------> LPUART1_TX
  286. */
  287. HAL_GPIO_DeInit(GPIOC, GPIO_PIN_0|GPIO_PIN_1);
  288. /* USER CODE BEGIN LPUART1_MspDeInit 1 */
  289. /* USER CODE END LPUART1_MspDeInit 1 */
  290. }
  291. else if(huart->Instance==USART1)
  292. {
  293. /* USER CODE BEGIN USART1_MspDeInit 0 */
  294. /* USER CODE END USART1_MspDeInit 0 */
  295. /* Peripheral clock disable */
  296. __HAL_RCC_USART1_CLK_DISABLE();
  297. /**USART1 GPIO Configuration
  298. PA9 ------> USART1_TX
  299. PA10 ------> USART1_RX
  300. */
  301. HAL_GPIO_DeInit(GPIOA, GPIO_PIN_9|GPIO_PIN_10);
  302. /* USER CODE BEGIN USART1_MspDeInit 1 */
  303. /* USER CODE END USART1_MspDeInit 1 */
  304. }
  305. else if(huart->Instance==USART3)
  306. {
  307. /* USER CODE BEGIN USART3_MspDeInit 0 */
  308. /* USER CODE END USART3_MspDeInit 0 */
  309. /* Peripheral clock disable */
  310. __HAL_RCC_USART3_CLK_DISABLE();
  311. /**USART3 GPIO Configuration
  312. PC4 ------> USART3_TX
  313. PC5 ------> USART3_RX
  314. */
  315. HAL_GPIO_DeInit(GPIOC, GPIO_PIN_4|GPIO_PIN_5);
  316. /* USER CODE BEGIN USART3_MspDeInit 1 */
  317. /* USER CODE END USART3_MspDeInit 1 */
  318. }
  319. }
  320. /**
  321. * @brief SPI MSP Initialization
  322. * This function configures the hardware resources used in this example
  323. * @param hspi: SPI handle pointer
  324. * @retval None
  325. */
  326. void HAL_SPI_MspInit(SPI_HandleTypeDef* hspi)
  327. {
  328. GPIO_InitTypeDef GPIO_InitStruct = {0};
  329. if(hspi->Instance==SPI1)
  330. {
  331. /* USER CODE BEGIN SPI1_MspInit 0 */
  332. /* USER CODE END SPI1_MspInit 0 */
  333. /* Peripheral clock enable */
  334. __HAL_RCC_SPI1_CLK_ENABLE();
  335. __HAL_RCC_GPIOA_CLK_ENABLE();
  336. /**SPI1 GPIO Configuration
  337. PA1 ------> SPI1_SCK
  338. PA6 ------> SPI1_MISO
  339. PA12 ------> SPI1_MOSI
  340. */
  341. GPIO_InitStruct.Pin = GPIO_PIN_1|GPIO_PIN_6|GPIO_PIN_12;
  342. GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
  343. GPIO_InitStruct.Pull = GPIO_NOPULL;
  344. GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
  345. GPIO_InitStruct.Alternate = GPIO_AF5_SPI1;
  346. HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
  347. /* USER CODE BEGIN SPI1_MspInit 1 */
  348. /* USER CODE END SPI1_MspInit 1 */
  349. }
  350. else if(hspi->Instance==SPI2)
  351. {
  352. /* USER CODE BEGIN SPI2_MspInit 0 */
  353. /* USER CODE END SPI2_MspInit 0 */
  354. /* Peripheral clock enable */
  355. __HAL_RCC_SPI2_CLK_ENABLE();
  356. __HAL_RCC_GPIOC_CLK_ENABLE();
  357. __HAL_RCC_GPIOB_CLK_ENABLE();
  358. /**SPI2 GPIO Configuration
  359. PC3 ------> SPI2_MOSI
  360. PB13 ------> SPI2_SCK
  361. */
  362. GPIO_InitStruct.Pin = GPIO_PIN_3;
  363. GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
  364. GPIO_InitStruct.Pull = GPIO_NOPULL;
  365. GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
  366. GPIO_InitStruct.Alternate = GPIO_AF5_SPI2;
  367. HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
  368. GPIO_InitStruct.Pin = GPIO_PIN_13;
  369. GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
  370. GPIO_InitStruct.Pull = GPIO_NOPULL;
  371. GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
  372. GPIO_InitStruct.Alternate = GPIO_AF5_SPI2;
  373. HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
  374. /* USER CODE BEGIN SPI2_MspInit 1 */
  375. /* USER CODE END SPI2_MspInit 1 */
  376. }
  377. }
  378. /**
  379. * @brief SPI MSP De-Initialization
  380. * This function freeze the hardware resources used in this example
  381. * @param hspi: SPI handle pointer
  382. * @retval None
  383. */
  384. void HAL_SPI_MspDeInit(SPI_HandleTypeDef* hspi)
  385. {
  386. if(hspi->Instance==SPI1)
  387. {
  388. /* USER CODE BEGIN SPI1_MspDeInit 0 */
  389. /* USER CODE END SPI1_MspDeInit 0 */
  390. /* Peripheral clock disable */
  391. __HAL_RCC_SPI1_CLK_DISABLE();
  392. /**SPI1 GPIO Configuration
  393. PA1 ------> SPI1_SCK
  394. PA6 ------> SPI1_MISO
  395. PA12 ------> SPI1_MOSI
  396. */
  397. HAL_GPIO_DeInit(GPIOA, GPIO_PIN_1|GPIO_PIN_6|GPIO_PIN_12);
  398. /* USER CODE BEGIN SPI1_MspDeInit 1 */
  399. /* USER CODE END SPI1_MspDeInit 1 */
  400. }
  401. else if(hspi->Instance==SPI2)
  402. {
  403. /* USER CODE BEGIN SPI2_MspDeInit 0 */
  404. /* USER CODE END SPI2_MspDeInit 0 */
  405. /* Peripheral clock disable */
  406. __HAL_RCC_SPI2_CLK_DISABLE();
  407. /**SPI2 GPIO Configuration
  408. PC3 ------> SPI2_MOSI
  409. PB13 ------> SPI2_SCK
  410. */
  411. HAL_GPIO_DeInit(GPIOC, GPIO_PIN_3);
  412. HAL_GPIO_DeInit(GPIOB, GPIO_PIN_13);
  413. /* USER CODE BEGIN SPI2_MspDeInit 1 */
  414. /* USER CODE END SPI2_MspDeInit 1 */
  415. }
  416. }
  417. /**
  418. * @brief TIM_Base MSP Initialization
  419. * This function configures the hardware resources used in this example
  420. * @param htim_base: TIM_Base handle pointer
  421. * @retval None
  422. */
  423. void HAL_TIM_Base_MspInit(TIM_HandleTypeDef* htim_base)
  424. {
  425. if(htim_base->Instance==TIM1)
  426. {
  427. /* USER CODE BEGIN TIM1_MspInit 0 */
  428. /* USER CODE END TIM1_MspInit 0 */
  429. /* Peripheral clock enable */
  430. __HAL_RCC_TIM1_CLK_ENABLE();
  431. /* USER CODE BEGIN TIM1_MspInit 1 */
  432. /* USER CODE END TIM1_MspInit 1 */
  433. }
  434. else if(htim_base->Instance==TIM16)
  435. {
  436. /* USER CODE BEGIN TIM16_MspInit 0 */
  437. /* USER CODE END TIM16_MspInit 0 */
  438. /* Peripheral clock enable */
  439. __HAL_RCC_TIM16_CLK_ENABLE();
  440. /* USER CODE BEGIN TIM16_MspInit 1 */
  441. /* USER CODE END TIM16_MspInit 1 */
  442. }
  443. }
  444. void HAL_TIM_MspPostInit(TIM_HandleTypeDef* htim)
  445. {
  446. GPIO_InitTypeDef GPIO_InitStruct = {0};
  447. if(htim->Instance==TIM1)
  448. {
  449. /* USER CODE BEGIN TIM1_MspPostInit 0 */
  450. /* USER CODE END TIM1_MspPostInit 0 */
  451. __HAL_RCC_GPIOA_CLK_ENABLE();
  452. /**TIM1 GPIO Configuration
  453. PA8 ------> TIM1_CH1
  454. */
  455. GPIO_InitStruct.Pin = GPIO_PIN_8;
  456. GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
  457. GPIO_InitStruct.Pull = GPIO_NOPULL;
  458. GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
  459. GPIO_InitStruct.Alternate = GPIO_AF1_TIM1;
  460. HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
  461. /* USER CODE BEGIN TIM1_MspPostInit 1 */
  462. /* USER CODE END TIM1_MspPostInit 1 */
  463. }
  464. else if(htim->Instance==TIM16)
  465. {
  466. /* USER CODE BEGIN TIM16_MspPostInit 0 */
  467. /* USER CODE END TIM16_MspPostInit 0 */
  468. __HAL_RCC_GPIOB_CLK_ENABLE();
  469. /**TIM16 GPIO Configuration
  470. PB8 ------> TIM16_CH1
  471. */
  472. GPIO_InitStruct.Pin = GPIO_PIN_8;
  473. GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
  474. GPIO_InitStruct.Pull = GPIO_NOPULL;
  475. GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
  476. GPIO_InitStruct.Alternate = GPIO_AF14_TIM16;
  477. HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
  478. /* USER CODE BEGIN TIM16_MspPostInit 1 */
  479. /* USER CODE END TIM16_MspPostInit 1 */
  480. }
  481. }
  482. /**
  483. * @brief TIM_Base MSP De-Initialization
  484. * This function freeze the hardware resources used in this example
  485. * @param htim_base: TIM_Base handle pointer
  486. * @retval None
  487. */
  488. void HAL_TIM_Base_MspDeInit(TIM_HandleTypeDef* htim_base)
  489. {
  490. if(htim_base->Instance==TIM1)
  491. {
  492. /* USER CODE BEGIN TIM1_MspDeInit 0 */
  493. /* USER CODE END TIM1_MspDeInit 0 */
  494. /* Peripheral clock disable */
  495. __HAL_RCC_TIM1_CLK_DISABLE();
  496. /* USER CODE BEGIN TIM1_MspDeInit 1 */
  497. /* USER CODE END TIM1_MspDeInit 1 */
  498. }
  499. else if(htim_base->Instance==TIM16)
  500. {
  501. /* USER CODE BEGIN TIM16_MspDeInit 0 */
  502. /* USER CODE END TIM16_MspDeInit 0 */
  503. /* Peripheral clock disable */
  504. __HAL_RCC_TIM16_CLK_DISABLE();
  505. /* USER CODE BEGIN TIM16_MspDeInit 1 */
  506. /* USER CODE END TIM16_MspDeInit 1 */
  507. }
  508. }
  509. /* USER CODE BEGIN 1 */
  510. /* USER CODE END 1 */