stm32l1xx_hal_msp.c 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  1. /**
  2. ******************************************************************************
  3. * File Name : stm32l1xx_hal_msp.c
  4. * Date : 03/01/2015 16:46:03
  5. * Description : This file provides code for the MSP Initialization
  6. * and de-Initialization codes.
  7. ******************************************************************************
  8. *
  9. * COPYRIGHT(c) 2015 STMicroelectronics
  10. *
  11. * Redistribution and use in source and binary forms, with or without modification,
  12. * are permitted provided that the following conditions are met:
  13. * 1. Redistributions of source code must retain the above copyright notice,
  14. * this list of conditions and the following disclaimer.
  15. * 2. Redistributions in binary form must reproduce the above copyright notice,
  16. * this list of conditions and the following disclaimer in the documentation
  17. * and/or other materials provided with the distribution.
  18. * 3. Neither the name of STMicroelectronics nor the names of its contributors
  19. * may be used to endorse or promote products derived from this software
  20. * without specific prior written permission.
  21. *
  22. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  23. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  24. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  25. * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
  26. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  27. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  28. * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  29. * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  30. * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  31. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  32. *
  33. ******************************************************************************
  34. */
  35. /* Includes ------------------------------------------------------------------*/
  36. #include "stm32l1xx_hal.h"
  37. /* USER CODE BEGIN 0 */
  38. /* USER CODE END 0 */
  39. /**
  40. * Initializes the Global MSP.
  41. */
  42. void HAL_MspInit(void)
  43. {
  44. /* USER CODE BEGIN MspInit 0 */
  45. /* USER CODE END MspInit 0 */
  46. __COMP_CLK_ENABLE();
  47. HAL_NVIC_SetPriorityGrouping(NVIC_PRIORITYGROUP_4);
  48. /* System interrupt init*/
  49. /* SysTick_IRQn interrupt configuration */
  50. HAL_NVIC_SetPriority(SysTick_IRQn, 2, 0);
  51. /* USER CODE BEGIN MspInit 1 */
  52. /* USER CODE END MspInit 1 */
  53. }
  54. void HAL_TIM_Base_MspInit(TIM_HandleTypeDef* htim_base)
  55. {
  56. if(htim_base->Instance==TIM2)
  57. {
  58. /* USER CODE BEGIN TIM2_MspInit 0 */
  59. /* USER CODE END TIM2_MspInit 0 */
  60. /* Peripheral clock enable */
  61. __TIM2_CLK_ENABLE();
  62. /* System interrupt init*/
  63. HAL_NVIC_SetPriority(TIM2_IRQn, 0, 0);
  64. HAL_NVIC_EnableIRQ(TIM2_IRQn);
  65. /* USER CODE BEGIN TIM2_MspInit 1 */
  66. /* USER CODE END TIM2_MspInit 1 */
  67. }
  68. else if(htim_base->Instance==TIM3)
  69. {
  70. /* USER CODE BEGIN TIM3_MspInit 0 */
  71. /* USER CODE END TIM3_MspInit 0 */
  72. /* Peripheral clock enable */
  73. __TIM3_CLK_ENABLE();
  74. /* System interrupt init*/
  75. HAL_NVIC_SetPriority(TIM3_IRQn, 1, 0);
  76. HAL_NVIC_EnableIRQ(TIM3_IRQn);
  77. /* USER CODE BEGIN TIM3_MspInit 1 */
  78. /* USER CODE END TIM3_MspInit 1 */
  79. }
  80. }
  81. void HAL_TIM_Base_MspDeInit(TIM_HandleTypeDef* htim_base)
  82. {
  83. if(htim_base->Instance==TIM2)
  84. {
  85. /* USER CODE BEGIN TIM2_MspDeInit 0 */
  86. /* USER CODE END TIM2_MspDeInit 0 */
  87. /* Peripheral clock disable */
  88. __TIM2_CLK_DISABLE();
  89. /* Peripheral interrupt DeInit*/
  90. HAL_NVIC_DisableIRQ(TIM2_IRQn);
  91. /* USER CODE BEGIN TIM2_MspDeInit 1 */
  92. /* USER CODE END TIM2_MspDeInit 1 */
  93. }
  94. else if(htim_base->Instance==TIM3)
  95. {
  96. /* USER CODE BEGIN TIM3_MspDeInit 0 */
  97. /* USER CODE END TIM3_MspDeInit 0 */
  98. /* Peripheral clock disable */
  99. __TIM3_CLK_DISABLE();
  100. /* Peripheral interrupt DeInit*/
  101. HAL_NVIC_DisableIRQ(TIM3_IRQn);
  102. /* USER CODE BEGIN TIM3_MspDeInit 1 */
  103. /* USER CODE END TIM3_MspDeInit 1 */
  104. }
  105. }
  106. void HAL_UART_MspInit(UART_HandleTypeDef* huart)
  107. {
  108. GPIO_InitTypeDef GPIO_InitStruct;
  109. if(huart->Instance==USART1)
  110. {
  111. /* USER CODE BEGIN USART1_MspInit 0 */
  112. /* USER CODE END USART1_MspInit 0 */
  113. /* Peripheral clock enable */
  114. __USART1_CLK_ENABLE();
  115. /**USART1 GPIO Configuration
  116. PA9 ------> USART1_TX
  117. PA10 ------> USART1_RX
  118. */
  119. GPIO_InitStruct.Pin = GPIO_PIN_9|GPIO_PIN_10;
  120. GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
  121. GPIO_InitStruct.Pull = GPIO_PULLUP;
  122. GPIO_InitStruct.Speed = GPIO_SPEED_VERY_LOW;
  123. GPIO_InitStruct.Alternate = GPIO_AF7_USART1;
  124. HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
  125. /* System interrupt init*/
  126. HAL_NVIC_SetPriority(USART1_IRQn, 5, 0);
  127. HAL_NVIC_EnableIRQ(USART1_IRQn);
  128. /* USER CODE BEGIN USART1_MspInit 1 */
  129. /* USER CODE END USART1_MspInit 1 */
  130. }
  131. }
  132. void HAL_UART_MspDeInit(UART_HandleTypeDef* huart)
  133. {
  134. if(huart->Instance==USART1)
  135. {
  136. /* USER CODE BEGIN USART1_MspDeInit 0 */
  137. /* USER CODE END USART1_MspDeInit 0 */
  138. /* Peripheral clock disable */
  139. __USART1_CLK_DISABLE();
  140. /**USART1 GPIO Configuration
  141. PA9 ------> USART1_TX
  142. PA10 ------> USART1_RX
  143. */
  144. HAL_GPIO_DeInit(GPIOA, GPIO_PIN_9|GPIO_PIN_10);
  145. /* Peripheral interrupt DeInit*/
  146. HAL_NVIC_DisableIRQ(USART1_IRQn);
  147. /* USER CODE BEGIN USART1_MspDeInit 1 */
  148. /* USER CODE END USART1_MspDeInit 1 */
  149. }
  150. }
  151. /* USER CODE BEGIN 1 */
  152. /* USER CODE END 1 */
  153. /**
  154. * @}
  155. */
  156. /**
  157. * @}
  158. */
  159. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/