1 /**
2   ******************************************************************************
3   * File Name          : stm32l4xx_hal_msp.c
4   * Description        : This file provides code for the MSP Initialization
5   *                      and de-Initialization codes.
6   ******************************************************************************
7   * This notice applies to any and all portions of this file
8   * that are not between comment pairs USER CODE BEGIN and
9   * USER CODE END. Other portions of this file, whether
10   * inserted by the user or by software development tools
11   * are owned by their respective copyright owners.
12   *
13   * Copyright (c) 2018 STMicroelectronics International N.V.
14   * All rights reserved.
15   *
16   * Redistribution and use in source and binary forms, with or without
17   * modification, are permitted, provided that the following conditions are met:
18   *
19   * 1. Redistribution of source code must retain the above copyright notice,
20   *    this list of conditions and the following disclaimer.
21   * 2. Redistributions in binary form must reproduce the above copyright notice,
22   *    this list of conditions and the following disclaimer in the documentation
23   *    and/or other materials provided with the distribution.
24   * 3. Neither the name of STMicroelectronics nor the names of other
25   *    contributors to this software may be used to endorse or promote products
26   *    derived from this software without specific written permission.
27   * 4. This software, including modifications and/or derivative works of this
28   *    software, must execute solely and exclusively on microcontroller or
29   *    microprocessor devices manufactured by or for STMicroelectronics.
30   * 5. Redistribution and use of this software other than as permitted under
31   *    this license is void and will automatically terminate your rights under
32   *    this license.
33   *
34   * THIS SOFTWARE IS PROVIDED BY STMICROELECTRONICS AND CONTRIBUTORS "AS IS"
35   * AND ANY EXPRESS, IMPLIED OR STATUTORY WARRANTIES, INCLUDING, BUT NOT
36   * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
37   * PARTICULAR PURPOSE AND NON-INFRINGEMENT OF THIRD PARTY INTELLECTUAL PROPERTY
38   * RIGHTS ARE DISCLAIMED TO THE FULLEST EXTENT PERMITTED BY LAW. IN NO EVENT
39   * SHALL STMICROELECTRONICS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
40   * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
41   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
42   * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
43   * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
44   * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
45   * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
46   *
47   ******************************************************************************
48   */
49 /* Includes ------------------------------------------------------------------*/
50 #include "stm32l4xx_hal.h"
51 
52 extern void _Error_Handler(char *, int);
53 /* USER CODE BEGIN 0 */
54 
55 /* USER CODE END 0 */
56 /**
57   * Initializes the Global MSP.
58   */
HAL_MspInit(void)59 void HAL_MspInit(void)
60 {
61   /* USER CODE BEGIN MspInit 0 */
62 
63   /* USER CODE END MspInit 0 */
64 
65   __HAL_RCC_SYSCFG_CLK_ENABLE();
66   __HAL_RCC_PWR_CLK_ENABLE();
67 
68   HAL_NVIC_SetPriorityGrouping(NVIC_PRIORITYGROUP_4);
69 
70   /* System interrupt init*/
71   /* MemoryManagement_IRQn interrupt configuration */
72   HAL_NVIC_SetPriority(MemoryManagement_IRQn, 0, 0);
73   /* BusFault_IRQn interrupt configuration */
74   HAL_NVIC_SetPriority(BusFault_IRQn, 0, 0);
75   /* UsageFault_IRQn interrupt configuration */
76   HAL_NVIC_SetPriority(UsageFault_IRQn, 0, 0);
77   /* SVCall_IRQn interrupt configuration */
78   HAL_NVIC_SetPriority(SVCall_IRQn, 0, 0);
79   /* DebugMonitor_IRQn interrupt configuration */
80   HAL_NVIC_SetPriority(DebugMonitor_IRQn, 0, 0);
81   /* PendSV_IRQn interrupt configuration */
82   HAL_NVIC_SetPriority(PendSV_IRQn, 0, 0);
83   /* SysTick_IRQn interrupt configuration */
84   HAL_NVIC_SetPriority(SysTick_IRQn, 0, 0);
85 
86   /* USER CODE BEGIN MspInit 1 */
87 
88   /* USER CODE END MspInit 1 */
89 }
90 
HAL_RNG_MspInit(RNG_HandleTypeDef * hrng)91 void HAL_RNG_MspInit(RNG_HandleTypeDef* hrng)
92 {
93 
94   if(hrng->Instance==RNG)
95   {
96   /* USER CODE BEGIN RNG_MspInit 0 */
97 
98   /* USER CODE END RNG_MspInit 0 */
99     /* Peripheral clock enable */
100     __HAL_RCC_RNG_CLK_ENABLE();
101   /* USER CODE BEGIN RNG_MspInit 1 */
102 
103   /* USER CODE END RNG_MspInit 1 */
104   }
105 
106 }
107 
HAL_RNG_MspDeInit(RNG_HandleTypeDef * hrng)108 void HAL_RNG_MspDeInit(RNG_HandleTypeDef* hrng)
109 {
110 
111   if(hrng->Instance==RNG)
112   {
113   /* USER CODE BEGIN RNG_MspDeInit 0 */
114 
115   /* USER CODE END RNG_MspDeInit 0 */
116     /* Peripheral clock disable */
117     __HAL_RCC_RNG_CLK_DISABLE();
118   /* USER CODE BEGIN RNG_MspDeInit 1 */
119 
120   /* USER CODE END RNG_MspDeInit 1 */
121   }
122 
123 }
124 
HAL_RTC_MspInit(RTC_HandleTypeDef * hrtc)125 void HAL_RTC_MspInit(RTC_HandleTypeDef* hrtc)
126 {
127 
128   if(hrtc->Instance==RTC)
129   {
130   /* USER CODE BEGIN RTC_MspInit 0 */
131 
132   /* USER CODE END RTC_MspInit 0 */
133     /* Peripheral clock enable */
134     __HAL_RCC_RTC_ENABLE();
135   /* USER CODE BEGIN RTC_MspInit 1 */
136 
137   /* USER CODE END RTC_MspInit 1 */
138   }
139 
140 }
141 
HAL_RTC_MspDeInit(RTC_HandleTypeDef * hrtc)142 void HAL_RTC_MspDeInit(RTC_HandleTypeDef* hrtc)
143 {
144 
145   if(hrtc->Instance==RTC)
146   {
147   /* USER CODE BEGIN RTC_MspDeInit 0 */
148 
149   /* USER CODE END RTC_MspDeInit 0 */
150     /* Peripheral clock disable */
151     __HAL_RCC_RTC_DISABLE();
152   /* USER CODE BEGIN RTC_MspDeInit 1 */
153 
154   /* USER CODE END RTC_MspDeInit 1 */
155   }
156 
157 }
158 
HAL_UART_MspInit(UART_HandleTypeDef * huart)159 void HAL_UART_MspInit(UART_HandleTypeDef* huart)
160 {
161 
162   GPIO_InitTypeDef GPIO_InitStruct;
163   if(huart->Instance==USART2)
164   {
165   /* USER CODE BEGIN USART2_MspInit 0 */
166 
167   /* USER CODE END USART2_MspInit 0 */
168     /* Peripheral clock enable */
169     __HAL_RCC_USART2_CLK_ENABLE();
170 
171     /**USART2 GPIO Configuration
172     PA2     ------> USART2_TX
173     PA3     ------> USART2_RX
174     */
175     GPIO_InitStruct.Pin = GPIO_PIN_2|GPIO_PIN_3;
176     GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
177     GPIO_InitStruct.Pull = GPIO_NOPULL;
178     GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
179     GPIO_InitStruct.Alternate = GPIO_AF7_USART2;
180     HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
181 
182   /* USER CODE BEGIN USART2_MspInit 1 */
183 
184   /* USER CODE END USART2_MspInit 1 */
185   }
186 
187 }
188 
HAL_UART_MspDeInit(UART_HandleTypeDef * huart)189 void HAL_UART_MspDeInit(UART_HandleTypeDef* huart)
190 {
191 
192   if(huart->Instance==USART2)
193   {
194   /* USER CODE BEGIN USART2_MspDeInit 0 */
195 
196   /* USER CODE END USART2_MspDeInit 0 */
197     /* Peripheral clock disable */
198     __HAL_RCC_USART2_CLK_DISABLE();
199 
200     /**USART2 GPIO Configuration
201     PA2     ------> USART2_TX
202     PA3     ------> USART2_RX
203     */
204     HAL_GPIO_DeInit(GPIOA, GPIO_PIN_2|GPIO_PIN_3);
205 
206   /* USER CODE BEGIN USART2_MspDeInit 1 */
207 
208   /* USER CODE END USART2_MspDeInit 1 */
209   }
210 
211 }
212 
213 /* USER CODE BEGIN 1 */
214 
215 /* USER CODE END 1 */
216 
217 /**
218   * @}
219   */
220 
221 /**
222   * @}
223   */
224 
225 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
226