void USBWakeUp_IRQHandler(void)
{
EXTI_ClearITPendingBit(EXTI_Line18); // 清除 USB 唤醒中断挂起位
}
// USB 中断处理
void USB_LP_CAN1_RX0_IRQHandler(void)
{
USB_Istr();
}
修改 void Set_USBClock(void)
void Set_USBClock(void)
{
/* Select USBCLK source */
RCC_USBCLKConfig(RCC_USBCLKSource_PLLCLK_1Div5); // USB-48MHz
/* Enable the USB clock */
RCC_APB1PeriphClockCmd(RCC_APB1Periph_USB, ENABLE);
}
修改 void Enter_LowPowerMode(void) 函数
void Enter_LowPowerMode(void)
{
printf("u*** enter low power modern");
/* Set the device state to suspend */
bDeviceState = SUSPENDED; // bDeciceState 记录 USB 连接状态, u***_pwr.c 定义
}
printf("leave low power modern");
/* Set the device state to the correct state */
if (pInfo->Current_Configuration != 0)
{
/* Device configured */
bDeviceState = CONFIGURED;
}
else
{
bDeviceState = ATTACHED;
}
void USBWakeUp_IRQHandler(void)
{
EXTI_ClearITPendingBit(EXTI_Line18); // 清除 USB 唤醒中断挂起位
}
// USB 中断处理
void USB_LP_CAN1_RX0_IRQHandler(void)
{
USB_Istr();
}
修改 void Set_USBClock(void)
void Set_USBClock(void)
{
/* Select USBCLK source */
RCC_USBCLKConfig(RCC_USBCLKSource_PLLCLK_1Div5); // USB-48MHz
/* Enable the USB clock */
RCC_APB1PeriphClockCmd(RCC_APB1Periph_USB, ENABLE);
}
修改 void Enter_LowPowerMode(void) 函数
void Enter_LowPowerMode(void)
{
printf("u*** enter low power modern");
/* Set the device state to suspend */
bDeviceState = SUSPENDED; // bDeciceState 记录 USB 连接状态, u***_pwr.c 定义
}
printf("leave low power modern");
/* Set the device state to the correct state */
if (pInfo->Current_Configuration != 0)
{
/* Device configured */
bDeviceState = CONFIGURED;
}
else
{
bDeviceState = ATTACHED;
}