diff --git a/stm32f072_usb_custom_hid/User/Src/usbd_custom_hid.c b/stm32f072_usb_custom_hid/User/Src/usbd_custom_hid.c index b2ba692..36b2e9e 100644 --- a/stm32f072_usb_custom_hid/User/Src/usbd_custom_hid.c +++ b/stm32f072_usb_custom_hid/User/Src/usbd_custom_hid.c @@ -203,7 +203,11 @@ static void usbd_event_handler(uint8_t busid, uint8_t event) static void usbd_hid_custom_in_callback(uint8_t busid, uint8_t ep, uint32_t nbytes) { - xTaskNotifyGive(sender_task_handle); + BaseType_t higher_task_woken = pdFALSE; + + vTaskNotifyGiveFromISR(sender_task_handle, &higher_task_woken); + + portYIELD_FROM_ISR(higher_task_woken); } static void usbd_hid_custom_out_callback(uint8_t busid, uint8_t ep, uint32_t nbytes) @@ -221,7 +225,7 @@ static void fill_usb_descriptor_serial_number(void) sprintf(uid_string, "%08X%08X%08X", HAL_GetUIDw0(), HAL_GetUIDw1(), HAL_GetUIDw2()); uint16_t serial_number_offset = 0; - + for (uint16_t i = 0; i < sizeof(usb_descriptor) - 3; i ++) { //查找USB描述符中序列号字符描述符的偏移 if (usb_descriptor[i + 0] == '0' && usb_descriptor[i + 1] == 0x00 && usb_descriptor[i + 2] == '0' && usb_descriptor[i + 3] == 0x00) { @@ -229,7 +233,7 @@ static void fill_usb_descriptor_serial_number(void) break; } } - + if (serial_number_offset == 0) { //未找到 return; }