|
34 | 34 | #include "hw_config.h" |
35 | 35 | #include "usb_pwr.h" |
36 | 36 |
|
37 | | - |
| 37 | +#define USB_IRQ_PRIORITY 7 |
38 | 38 | /* Private typedef -----------------------------------------------------------*/ |
39 | 39 | /* Private define ------------------------------------------------------------*/ |
40 | 40 | /* Private macro -------------------------------------------------------------*/ |
@@ -118,13 +118,6 @@ void Set_System(void) |
118 | 118 | GPIO_PinAFConfig(GPIOA, GPIO_PinSource11, GPIO_AF_14); |
119 | 119 | GPIO_PinAFConfig(GPIOA, GPIO_PinSource12, GPIO_AF_14); |
120 | 120 |
|
121 | | - /* USB_DISCONNECT used as USB pull-up */ |
122 | | - GPIO_InitStructure.GPIO_Pin = USB_DISCONNECT_PIN; |
123 | | - GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz; |
124 | | - GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT; |
125 | | - GPIO_InitStructure.GPIO_OType = GPIO_OType_OD; |
126 | | - GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL; |
127 | | - GPIO_Init(USB_DISCONNECT, &GPIO_InitStructure); |
128 | 121 | #endif /* STM32F37X && STM32F30X */ |
129 | 122 |
|
130 | 123 | /* Configure the EXTI line 18 connected internally to the USB IP */ |
@@ -202,48 +195,19 @@ void USB_Interrupts_Config(void) |
202 | 195 | { |
203 | 196 | NVIC_InitTypeDef NVIC_InitStructure; |
204 | 197 |
|
205 | | - /* 2 bit for pre-emption priority, 2 bits for subpriority */ |
| 198 | + /* We use no bits for nested sub priority */ |
206 | 199 | NVIC_PriorityGroupConfig(NVIC_PriorityGroup_4); |
207 | 200 |
|
208 | | -#if defined(STM32L1XX_MD) || defined(STM32L1XX_HD)|| defined(STM32L1XX_MD_PLUS) |
209 | | - NVIC_InitStructure.NVIC_IRQChannel = USB_LP_IRQn; |
210 | | - NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 2; |
211 | | - NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0; |
212 | | - NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; |
213 | | - NVIC_Init(&NVIC_InitStructure); |
214 | | - |
215 | | - /* Enable the USB Wake-up interrupt */ |
216 | | - NVIC_InitStructure.NVIC_IRQChannel = USB_FS_WKUP_IRQn; |
217 | | - NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0; |
218 | | - NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; |
219 | | - NVIC_Init(&NVIC_InitStructure); |
220 | | - |
221 | | -#elif defined(STM32F37X) |
222 | | - /* Enable the USB interrupt */ |
223 | | - NVIC_InitStructure.NVIC_IRQChannel = USB_LP_IRQn; |
224 | | - NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 2; |
225 | | - NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0; |
226 | | - NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; |
227 | | - NVIC_Init(&NVIC_InitStructure); |
228 | | - |
229 | | - /* Enable the USB Wake-up interrupt */ |
230 | | - NVIC_InitStructure.NVIC_IRQChannel = USBWakeUp_IRQn; |
231 | | - NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0; |
232 | | - NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; |
233 | | - NVIC_Init(&NVIC_InitStructure); |
234 | | - |
235 | | -#else |
236 | 201 | NVIC_InitStructure.NVIC_IRQChannel = USB_LP_CAN1_RX0_IRQn; |
237 | | - NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 2; |
| 202 | + NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = USB_IRQ_PRIORITY; |
238 | 203 | NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0; |
239 | 204 | NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; |
240 | 205 | NVIC_Init(&NVIC_InitStructure); |
241 | 206 |
|
242 | 207 | /* Enable the USB Wake-up interrupt */ |
243 | 208 | NVIC_InitStructure.NVIC_IRQChannel = USBWakeUp_IRQn; |
244 | | - NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0; |
| 209 | + NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = USB_IRQ_PRIORITY; |
245 | 210 | NVIC_Init(&NVIC_InitStructure); |
246 | | -#endif /* STM32L1XX_XD */ |
247 | 211 |
|
248 | 212 | /* Enable USART Interrupt */ |
249 | 213 | /* We don't need to do this since we're intercepting traffic directly */ |
|
0 commit comments