2 ******************************************************************************
3 * File Name : stm32f1xx_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.
13 * COPYRIGHT(c) 2018 STMicroelectronics
15 * Redistribution and use in source and binary forms, with or without modification,
16 * are permitted provided that the following conditions are met:
17 * 1. Redistributions of source code must retain the above copyright notice,
18 * this list of conditions and the following disclaimer.
19 * 2. Redistributions in binary form must reproduce the above copyright notice,
20 * this list of conditions and the following disclaimer in the documentation
21 * and/or other materials provided with the distribution.
22 * 3. Neither the name of STMicroelectronics nor the names of its contributors
23 * may be used to endorse or promote products derived from this software
24 * without specific prior written permission.
26 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
27 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
29 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
30 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
31 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
32 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
33 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
34 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
35 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37 ******************************************************************************
39 /* Includes ------------------------------------------------------------------*/
40 #include "stm32f1xx_hal.h"
42 extern void _Error_Handler(char *, int);
43 /* USER CODE BEGIN 0 */
47 * Initializes the Global MSP.
49 void HAL_MspInit(void)
51 /* USER CODE BEGIN MspInit 0 */
53 /* USER CODE END MspInit 0 */
55 __HAL_RCC_AFIO_CLK_ENABLE();
57 HAL_NVIC_SetPriorityGrouping(NVIC_PRIORITYGROUP_4);
59 /* System interrupt init*/
60 /* MemoryManagement_IRQn interrupt configuration */
61 HAL_NVIC_SetPriority(MemoryManagement_IRQn, 0, 0);
62 /* BusFault_IRQn interrupt configuration */
63 HAL_NVIC_SetPriority(BusFault_IRQn, 0, 0);
64 /* UsageFault_IRQn interrupt configuration */
65 HAL_NVIC_SetPriority(UsageFault_IRQn, 0, 0);
66 /* SVCall_IRQn interrupt configuration */
67 HAL_NVIC_SetPriority(SVCall_IRQn, 0, 0);
68 /* DebugMonitor_IRQn interrupt configuration */
69 HAL_NVIC_SetPriority(DebugMonitor_IRQn, 0, 0);
70 /* PendSV_IRQn interrupt configuration */
71 HAL_NVIC_SetPriority(PendSV_IRQn, 0, 0);
72 /* SysTick_IRQn interrupt configuration */
73 HAL_NVIC_SetPriority(SysTick_IRQn, 0, 0);
75 /**NOJTAG: JTAG-DP Disabled and SW-DP Enabled
77 __HAL_AFIO_REMAP_SWJ_NOJTAG();
79 /* USER CODE BEGIN MspInit 1 */
81 /* USER CODE END MspInit 1 */
84 void HAL_PCD_MspInit(PCD_HandleTypeDef* hpcd)
87 if(hpcd->Instance==USB)
89 /* USER CODE BEGIN USB_MspInit 0 */
91 /* USER CODE END USB_MspInit 0 */
92 /* Peripheral clock enable */
93 __HAL_RCC_USB_CLK_ENABLE();
94 /* USB interrupt Init */
95 HAL_NVIC_SetPriority(USB_HP_CAN1_TX_IRQn, 15, 0);
96 HAL_NVIC_EnableIRQ(USB_HP_CAN1_TX_IRQn);
97 HAL_NVIC_SetPriority(USB_LP_CAN1_RX0_IRQn, 15, 0);
98 HAL_NVIC_EnableIRQ(USB_LP_CAN1_RX0_IRQn);
99 /* USER CODE BEGIN USB_MspInit 1 */
101 /* USER CODE END USB_MspInit 1 */
106 void HAL_PCD_MspDeInit(PCD_HandleTypeDef* hpcd)
109 if(hpcd->Instance==USB)
111 /* USER CODE BEGIN USB_MspDeInit 0 */
113 /* USER CODE END USB_MspDeInit 0 */
114 /* Peripheral clock disable */
115 __HAL_RCC_USB_CLK_DISABLE();
117 /* USB interrupt DeInit */
118 HAL_NVIC_DisableIRQ(USB_HP_CAN1_TX_IRQn);
119 HAL_NVIC_DisableIRQ(USB_LP_CAN1_RX0_IRQn);
120 /* USER CODE BEGIN USB_MspDeInit 1 */
122 /* USER CODE END USB_MspDeInit 1 */
127 /* USER CODE BEGIN 1 */
129 /* USER CODE END 1 */
139 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/