Просмотр исходного кода

reset flag in USBD_EVENT_CONFIGURED

sakumisu 1 год назад
Родитель
Сommit
2bfb7255cd

+ 2 - 0
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;
 }
 

+ 2 - 0
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;

+ 2 - 0
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;

+ 1 - 0
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;

+ 1 - 0
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);

+ 1 - 0
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;

+ 2 - 1
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;

+ 7 - 6
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;

+ 1 - 0
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;

+ 5 - 3
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;

+ 1 - 0
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

+ 1 - 0
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;

+ 1 - 0
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;