reset flag in USBD_EVENT_CONFIGURED

This commit is contained in:
sakumisu
2024-03-23 17:50:49 +08:00
parent f28b1c61ba
commit 2bfb7255cd
13 changed files with 27 additions and 10 deletions

View File

@@ -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) void usbd_audio_open(uint8_t busid, uint8_t intf)
{ {
tx_flag = 1; tx_flag = 1;
ep_tx_busy_flag = false;
USB_LOG_RAW("OPEN\r\n"); USB_LOG_RAW("OPEN\r\n");
} }
void usbd_audio_close(uint8_t busid, uint8_t intf) void usbd_audio_close(uint8_t busid, uint8_t intf)
{ {
USB_LOG_RAW("CLOSE\r\n"); USB_LOG_RAW("CLOSE\r\n");
ep_tx_busy_flag = false;
tx_flag = 0; tx_flag = 0;
} }

View File

@@ -181,6 +181,7 @@ void usbd_audio_open(uint8_t busid, uint8_t intf)
printf("OPEN1\r\n"); printf("OPEN1\r\n");
} else { } else {
tx_flag = 1; tx_flag = 1;
ep_tx_busy_flag = false;
printf("OPEN2\r\n"); printf("OPEN2\r\n");
} }
} }
@@ -189,6 +190,7 @@ void usbd_audio_close(uint8_t busid, uint8_t intf)
{ {
if (intf == 1) { if (intf == 1) {
rx_flag = 1; rx_flag = 1;
ep_tx_busy_flag = false;
printf("CLOSE1\r\n"); printf("CLOSE1\r\n");
} else { } else {
tx_flag = 0; tx_flag = 0;

View File

@@ -252,6 +252,8 @@ static void usbd_event_handler(uint8_t busid, uint8_t event)
case USBD_EVENT_SUSPEND: case USBD_EVENT_SUSPEND:
break; break;
case USBD_EVENT_CONFIGURED: case USBD_EVENT_CONFIGURED:
ep_tx_busy_flag = false;
hid_state = HID_STATE_IDLE;
/* setup first out ep read transfer */ /* setup first out ep read transfer */
usbd_ep_start_read(busid, CDC_OUT_EP, read_buffer, 2048); usbd_ep_start_read(busid, CDC_OUT_EP, read_buffer, 2048);
break; break;

View File

@@ -263,6 +263,7 @@ static void usbd_event_handler(uint8_t busid, uint8_t event)
case USBD_EVENT_SUSPEND: case USBD_EVENT_SUSPEND:
break; break;
case USBD_EVENT_CONFIGURED: case USBD_EVENT_CONFIGURED:
ep_tx_busy_flag = false;
/* setup first out ep read transfer */ /* setup first out ep read transfer */
usbd_ep_start_read(busid, CDC_OUT_EP, read_buffer, 2048); usbd_ep_start_read(busid, CDC_OUT_EP, read_buffer, 2048);
break; break;

View File

@@ -139,6 +139,7 @@ static void usbd_event_handler(uint8_t busid, uint8_t event)
case USBD_EVENT_SUSPEND: case USBD_EVENT_SUSPEND:
break; break;
case USBD_EVENT_CONFIGURED: case USBD_EVENT_CONFIGURED:
ep_tx_busy_flag = false;
/* setup first out ep read transfer */ /* setup first out ep read transfer */
usbd_ep_start_read(busid, CDC_OUT_EP, read_buffer, 2048); usbd_ep_start_read(busid, CDC_OUT_EP, read_buffer, 2048);
usbd_ep_start_read(busid, CDC_OUT_EP2, read_buffer, 2048); usbd_ep_start_read(busid, CDC_OUT_EP2, read_buffer, 2048);

View File

@@ -124,6 +124,7 @@ static void usbd_event_handler(uint8_t busid, uint8_t event)
case USBD_EVENT_SUSPEND: case USBD_EVENT_SUSPEND:
break; break;
case USBD_EVENT_CONFIGURED: case USBD_EVENT_CONFIGURED:
ep_tx_busy_flag = false;
/* setup first out ep read transfer */ /* setup first out ep read transfer */
usbd_ep_start_read(busid, CDC_OUT_EP, read_buffer, 2048); usbd_ep_start_read(busid, CDC_OUT_EP, read_buffer, 2048);
break; break;

View File

@@ -167,7 +167,7 @@ USB_NOCACHE_RAM_SECTION USB_MEM_ALIGNX uint8_t send_buffer[HIDRAW_IN_EP_SIZE];
#define HID_STATE_BUSY 1 #define HID_STATE_BUSY 1
/*!< hid state ! Data can be sent only when state is idle */ /*!< 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) 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: case USBD_EVENT_SUSPEND:
break; break;
case USBD_EVENT_CONFIGURED: case USBD_EVENT_CONFIGURED:
custom_state = HID_STATE_IDLE;
/* setup first out ep read transfer */ /* setup first out ep read transfer */
usbd_ep_start_read(busid, HIDRAW_OUT_EP, read_buffer, HIDRAW_OUT_EP_SIZE); usbd_ep_start_read(busid, HIDRAW_OUT_EP, read_buffer, HIDRAW_OUT_EP_SIZE);
break; break;

View File

@@ -172,6 +172,12 @@ static const uint8_t hid_keyboard_report_desc[HID_KEYBOARD_REPORT_DESC_SIZE] = {
0xc0 // END_COLLECTION 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) static void usbd_event_handler(uint8_t busid, uint8_t event)
{ {
switch (event) { switch (event) {
@@ -186,6 +192,7 @@ static void usbd_event_handler(uint8_t busid, uint8_t event)
case USBD_EVENT_SUSPEND: case USBD_EVENT_SUSPEND:
break; break;
case USBD_EVENT_CONFIGURED: case USBD_EVENT_CONFIGURED:
hid_state = HID_STATE_IDLE;
break; break;
case USBD_EVENT_SET_REMOTE_WAKEUP: case USBD_EVENT_SET_REMOTE_WAKEUP:
break; 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) void usbd_hid_int_callback(uint8_t busid, uint8_t ep, uint32_t nbytes)
{ {
hid_state = HID_STATE_IDLE; hid_state = HID_STATE_IDLE;

View File

@@ -208,6 +208,7 @@ static void usbd_event_handler(uint8_t busid, uint8_t event)
case USBD_EVENT_SUSPEND: case USBD_EVENT_SUSPEND:
break; break;
case USBD_EVENT_CONFIGURED: case USBD_EVENT_CONFIGURED:
hid_state = HID_STATE_IDLE;
break; break;
case USBD_EVENT_SET_REMOTE_WAKEUP: case USBD_EVENT_SET_REMOTE_WAKEUP:
break; break;

View File

@@ -141,6 +141,9 @@ const uint8_t video_descriptor[] = {
0x00 0x00
}; };
volatile bool tx_flag = 0;
volatile bool iso_tx_busy = false;
static void usbd_event_handler(uint8_t busid, uint8_t event) static void usbd_event_handler(uint8_t busid, uint8_t event)
{ {
switch (event) { switch (event) {
@@ -155,6 +158,8 @@ static void usbd_event_handler(uint8_t busid, uint8_t event)
case USBD_EVENT_SUSPEND: case USBD_EVENT_SUSPEND:
break; break;
case USBD_EVENT_CONFIGURED: case USBD_EVENT_CONFIGURED:
tx_flag = 0;
iso_tx_busy = false;
break; break;
case USBD_EVENT_SET_REMOTE_WAKEUP: case USBD_EVENT_SET_REMOTE_WAKEUP:
break; 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) void usbd_video_open(uint8_t busid, uint8_t intf)
{ {
tx_flag = 1; tx_flag = 1;

View File

@@ -348,6 +348,7 @@ static void usbd_event_handler(uint8_t busid, uint8_t event)
case USBD_EVENT_SUSPEND: case USBD_EVENT_SUSPEND:
break; break;
case USBD_EVENT_CONFIGURED: case USBD_EVENT_CONFIGURED:
ep_tx_busy_flag = false;
/* setup first out ep read transfer */ /* setup first out ep read transfer */
usbd_ep_start_read(busid, WINUSB_OUT_EP, read_buffer, 2048); usbd_ep_start_read(busid, WINUSB_OUT_EP, read_buffer, 2048);
#if DOUBLE_WINUSB == 1 #if DOUBLE_WINUSB == 1

View File

@@ -240,6 +240,7 @@ static void usbd_event_handler(uint8_t busid, uint8_t event)
case USBD_EVENT_SUSPEND: case USBD_EVENT_SUSPEND:
break; break;
case USBD_EVENT_CONFIGURED: case USBD_EVENT_CONFIGURED:
ep_tx_busy_flag = false;
/* setup first out ep read transfer */ /* setup first out ep read transfer */
usbd_ep_start_read(busid, WINUSB_OUT_EP, read_buffer, 2048); usbd_ep_start_read(busid, WINUSB_OUT_EP, read_buffer, 2048);
break; break;

View File

@@ -276,6 +276,7 @@ static void usbd_event_handler(uint8_t busid, uint8_t event)
case USBD_EVENT_SUSPEND: case USBD_EVENT_SUSPEND:
break; break;
case USBD_EVENT_CONFIGURED: case USBD_EVENT_CONFIGURED:
ep_tx_busy_flag = false;
/* setup first out ep read transfer */ /* setup first out ep read transfer */
usbd_ep_start_read(busid, WINUSB_OUT_EP, read_buffer, 2048); usbd_ep_start_read(busid, WINUSB_OUT_EP, read_buffer, 2048);
break; break;