From 2bfb7255cd7f1c7a7d742711b8d15b073e96dfa6 Mon Sep 17 00:00:00 2001 From: sakumisu <1203593632@qq.com> Date: Sat, 23 Mar 2024 17:50:49 +0800 Subject: [PATCH] reset flag in USBD_EVENT_CONFIGURED --- demo/audio_v1_mic_multichan_template.c | 2 ++ demo/audio_v1_mic_speaker_multichan_template.c | 2 ++ demo/cdc_acm_hid_msc_template.c | 2 ++ demo/cdc_acm_msc_template.c | 1 + demo/cdc_acm_multi_template.c | 1 + demo/cdc_acm_template.c | 1 + demo/hid_custom_inout_template.c | 3 ++- demo/hid_keyboard_template.c | 13 +++++++------ demo/hid_mouse_template.c | 1 + demo/video_static_mjpeg_template.c | 8 +++++--- demo/winusb1.0_template.c | 1 + demo/winusb2.0_cdc_template.c | 1 + demo/winusb2.0_hid_template.c | 1 + 13 files changed, 27 insertions(+), 10 deletions(-) diff --git a/demo/audio_v1_mic_multichan_template.c b/demo/audio_v1_mic_multichan_template.c index 43e5f07b..779ef0d1 100644 --- a/demo/audio_v1_mic_multichan_template.c +++ b/demo/audio_v1_mic_multichan_template.c @@ -176,12 +176,14 @@ static void usbd_event_handler(uint8_t busid, uint8_t event) void usbd_audio_open(uint8_t busid, uint8_t intf) { tx_flag = 1; + ep_tx_busy_flag = false; USB_LOG_RAW("OPEN\r\n"); } void usbd_audio_close(uint8_t busid, uint8_t intf) { USB_LOG_RAW("CLOSE\r\n"); + ep_tx_busy_flag = false; tx_flag = 0; } diff --git a/demo/audio_v1_mic_speaker_multichan_template.c b/demo/audio_v1_mic_speaker_multichan_template.c index 57fdfdc0..9127e4bc 100644 --- a/demo/audio_v1_mic_speaker_multichan_template.c +++ b/demo/audio_v1_mic_speaker_multichan_template.c @@ -181,6 +181,7 @@ void usbd_audio_open(uint8_t busid, uint8_t intf) printf("OPEN1\r\n"); } else { tx_flag = 1; + ep_tx_busy_flag = false; printf("OPEN2\r\n"); } } @@ -189,6 +190,7 @@ void usbd_audio_close(uint8_t busid, uint8_t intf) { if (intf == 1) { rx_flag = 1; + ep_tx_busy_flag = false; printf("CLOSE1\r\n"); } else { tx_flag = 0; diff --git a/demo/cdc_acm_hid_msc_template.c b/demo/cdc_acm_hid_msc_template.c index f316a196..2df28b2f 100644 --- a/demo/cdc_acm_hid_msc_template.c +++ b/demo/cdc_acm_hid_msc_template.c @@ -252,6 +252,8 @@ static void usbd_event_handler(uint8_t busid, uint8_t event) case USBD_EVENT_SUSPEND: break; case USBD_EVENT_CONFIGURED: + ep_tx_busy_flag = false; + hid_state = HID_STATE_IDLE; /* setup first out ep read transfer */ usbd_ep_start_read(busid, CDC_OUT_EP, read_buffer, 2048); break; diff --git a/demo/cdc_acm_msc_template.c b/demo/cdc_acm_msc_template.c index fc5ad51c..042837de 100644 --- a/demo/cdc_acm_msc_template.c +++ b/demo/cdc_acm_msc_template.c @@ -263,6 +263,7 @@ static void usbd_event_handler(uint8_t busid, uint8_t event) case USBD_EVENT_SUSPEND: break; case USBD_EVENT_CONFIGURED: + ep_tx_busy_flag = false; /* setup first out ep read transfer */ usbd_ep_start_read(busid, CDC_OUT_EP, read_buffer, 2048); break; diff --git a/demo/cdc_acm_multi_template.c b/demo/cdc_acm_multi_template.c index a8e4709a..440720ab 100644 --- a/demo/cdc_acm_multi_template.c +++ b/demo/cdc_acm_multi_template.c @@ -139,6 +139,7 @@ static void usbd_event_handler(uint8_t busid, uint8_t event) case USBD_EVENT_SUSPEND: break; case USBD_EVENT_CONFIGURED: + ep_tx_busy_flag = false; /* setup first out ep read transfer */ usbd_ep_start_read(busid, CDC_OUT_EP, read_buffer, 2048); usbd_ep_start_read(busid, CDC_OUT_EP2, read_buffer, 2048); diff --git a/demo/cdc_acm_template.c b/demo/cdc_acm_template.c index c4896a9c..8ab296bd 100644 --- a/demo/cdc_acm_template.c +++ b/demo/cdc_acm_template.c @@ -124,6 +124,7 @@ static void usbd_event_handler(uint8_t busid, uint8_t event) case USBD_EVENT_SUSPEND: break; case USBD_EVENT_CONFIGURED: + ep_tx_busy_flag = false; /* setup first out ep read transfer */ usbd_ep_start_read(busid, CDC_OUT_EP, read_buffer, 2048); break; diff --git a/demo/hid_custom_inout_template.c b/demo/hid_custom_inout_template.c index ac3b0660..80c2f137 100644 --- a/demo/hid_custom_inout_template.c +++ b/demo/hid_custom_inout_template.c @@ -167,7 +167,7 @@ USB_NOCACHE_RAM_SECTION USB_MEM_ALIGNX uint8_t send_buffer[HIDRAW_IN_EP_SIZE]; #define HID_STATE_BUSY 1 /*!< hid state ! Data can be sent only when state is idle */ -static volatile uint8_t custom_state; +static volatile uint8_t custom_state = HID_STATE_IDLE; static void usbd_event_handler(uint8_t busid, uint8_t event) { @@ -183,6 +183,7 @@ static void usbd_event_handler(uint8_t busid, uint8_t event) case USBD_EVENT_SUSPEND: break; case USBD_EVENT_CONFIGURED: + custom_state = HID_STATE_IDLE; /* setup first out ep read transfer */ usbd_ep_start_read(busid, HIDRAW_OUT_EP, read_buffer, HIDRAW_OUT_EP_SIZE); break; diff --git a/demo/hid_keyboard_template.c b/demo/hid_keyboard_template.c index 36291a06..c6a457af 100644 --- a/demo/hid_keyboard_template.c +++ b/demo/hid_keyboard_template.c @@ -172,6 +172,12 @@ static const uint8_t hid_keyboard_report_desc[HID_KEYBOARD_REPORT_DESC_SIZE] = { 0xc0 // END_COLLECTION }; +#define HID_STATE_IDLE 0 +#define HID_STATE_BUSY 1 + +/*!< hid state ! Data can be sent only when state is idle */ +static volatile uint8_t hid_state = HID_STATE_IDLE; + static void usbd_event_handler(uint8_t busid, uint8_t event) { switch (event) { @@ -186,6 +192,7 @@ static void usbd_event_handler(uint8_t busid, uint8_t event) case USBD_EVENT_SUSPEND: break; case USBD_EVENT_CONFIGURED: + hid_state = HID_STATE_IDLE; break; case USBD_EVENT_SET_REMOTE_WAKEUP: break; @@ -197,12 +204,6 @@ static void usbd_event_handler(uint8_t busid, uint8_t event) } } -#define HID_STATE_IDLE 0 -#define HID_STATE_BUSY 1 - -/*!< hid state ! Data can be sent only when state is idle */ -static volatile uint8_t hid_state = HID_STATE_IDLE; - void usbd_hid_int_callback(uint8_t busid, uint8_t ep, uint32_t nbytes) { hid_state = HID_STATE_IDLE; diff --git a/demo/hid_mouse_template.c b/demo/hid_mouse_template.c index 9659f7d7..7421b2a1 100644 --- a/demo/hid_mouse_template.c +++ b/demo/hid_mouse_template.c @@ -208,6 +208,7 @@ static void usbd_event_handler(uint8_t busid, uint8_t event) case USBD_EVENT_SUSPEND: break; case USBD_EVENT_CONFIGURED: + hid_state = HID_STATE_IDLE; break; case USBD_EVENT_SET_REMOTE_WAKEUP: break; diff --git a/demo/video_static_mjpeg_template.c b/demo/video_static_mjpeg_template.c index 7d6b2d39..4c0c2b7b 100644 --- a/demo/video_static_mjpeg_template.c +++ b/demo/video_static_mjpeg_template.c @@ -141,6 +141,9 @@ const uint8_t video_descriptor[] = { 0x00 }; +volatile bool tx_flag = 0; +volatile bool iso_tx_busy = false; + static void usbd_event_handler(uint8_t busid, uint8_t event) { switch (event) { @@ -155,6 +158,8 @@ static void usbd_event_handler(uint8_t busid, uint8_t event) case USBD_EVENT_SUSPEND: break; case USBD_EVENT_CONFIGURED: + tx_flag = 0; + iso_tx_busy = false; break; case USBD_EVENT_SET_REMOTE_WAKEUP: break; @@ -166,9 +171,6 @@ static void usbd_event_handler(uint8_t busid, uint8_t event) } } -volatile bool tx_flag = 0; -volatile bool iso_tx_busy = false; - void usbd_video_open(uint8_t busid, uint8_t intf) { tx_flag = 1; diff --git a/demo/winusb1.0_template.c b/demo/winusb1.0_template.c index 4b8e2bb0..3d75aed9 100644 --- a/demo/winusb1.0_template.c +++ b/demo/winusb1.0_template.c @@ -348,6 +348,7 @@ static void usbd_event_handler(uint8_t busid, uint8_t event) case USBD_EVENT_SUSPEND: break; case USBD_EVENT_CONFIGURED: + ep_tx_busy_flag = false; /* setup first out ep read transfer */ usbd_ep_start_read(busid, WINUSB_OUT_EP, read_buffer, 2048); #if DOUBLE_WINUSB == 1 diff --git a/demo/winusb2.0_cdc_template.c b/demo/winusb2.0_cdc_template.c index 3a50856b..c120080a 100644 --- a/demo/winusb2.0_cdc_template.c +++ b/demo/winusb2.0_cdc_template.c @@ -240,6 +240,7 @@ static void usbd_event_handler(uint8_t busid, uint8_t event) case USBD_EVENT_SUSPEND: break; case USBD_EVENT_CONFIGURED: + ep_tx_busy_flag = false; /* setup first out ep read transfer */ usbd_ep_start_read(busid, WINUSB_OUT_EP, read_buffer, 2048); break; diff --git a/demo/winusb2.0_hid_template.c b/demo/winusb2.0_hid_template.c index 16926656..e485f904 100644 --- a/demo/winusb2.0_hid_template.c +++ b/demo/winusb2.0_hid_template.c @@ -276,6 +276,7 @@ static void usbd_event_handler(uint8_t busid, uint8_t event) case USBD_EVENT_SUSPEND: break; case USBD_EVENT_CONFIGURED: + ep_tx_busy_flag = false; /* setup first out ep read transfer */ usbd_ep_start_read(busid, WINUSB_OUT_EP, read_buffer, 2048); break;