fix hid state and video state
This commit is contained in:
@@ -235,12 +235,7 @@ static volatile uint8_t hid_state = HID_STATE_IDLE;
|
||||
/* function ------------------------------------------------------------------*/
|
||||
static void usbd_hid_int_callback(uint8_t ep, uint32_t nbytes)
|
||||
{
|
||||
/*!< endpoint call back */
|
||||
/*!< transfer successfully */
|
||||
if (hid_state == HID_STATE_BUSY) {
|
||||
/*!< update the state */
|
||||
hid_state = HID_STATE_IDLE;
|
||||
}
|
||||
hid_state = HID_STATE_IDLE;
|
||||
}
|
||||
|
||||
/*!< endpoint call back */
|
||||
@@ -341,6 +336,7 @@ void hid_mouse_test(void)
|
||||
if (ret < 0) {
|
||||
return;
|
||||
}
|
||||
hid_state = HID_STATE_BUSY;
|
||||
while (hid_state == HID_STATE_BUSY) {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -214,11 +214,12 @@ void hid_custom_keyboard_init(void)
|
||||
void hid_custom_test(void)
|
||||
{
|
||||
uint8_t sendbuffer[64] = { 0x00, 0x00, HID_KBD_USAGE_A, 0x00, 0x00, 0x00, 0x00, 0x00 };
|
||||
custom_state = HID_STATE_BUSY;
|
||||
|
||||
int ret = usbd_ep_start_write(HIDRAW_IN_EP, sendbuffer, 8);
|
||||
if (ret < 0) {
|
||||
return;
|
||||
}
|
||||
custom_state = HID_STATE_BUSY;
|
||||
while (custom_state == HID_STATE_BUSY) {
|
||||
}
|
||||
}
|
||||
@@ -205,11 +205,12 @@ void hid_keyboard_init(void)
|
||||
void hid_keyboard_test(void)
|
||||
{
|
||||
uint8_t sendbuffer[8] = { 0x00, 0x00, HID_KBD_USAGE_A, 0x00, 0x00, 0x00, 0x00, 0x00 }; //A
|
||||
hid_state = HID_STATE_BUSY;
|
||||
|
||||
int ret = usbd_ep_start_write(HID_INT_EP, sendbuffer, 8);
|
||||
if (ret < 0) {
|
||||
return;
|
||||
}
|
||||
hid_state = HID_STATE_BUSY;
|
||||
while (hid_state == HID_STATE_BUSY) {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -244,11 +244,12 @@ void hid_mouse_test(void)
|
||||
/*!< move mouse pointer */
|
||||
mouse_cfg.x += 10;
|
||||
mouse_cfg.y = 0;
|
||||
hid_state = HID_STATE_BUSY;
|
||||
|
||||
int ret = usbd_ep_start_write(HID_INT_EP, (uint8_t *)&mouse_cfg, 4);
|
||||
if (ret < 0) {
|
||||
return;
|
||||
}
|
||||
hid_state = HID_STATE_BUSY;
|
||||
while (hid_state == HID_STATE_BUSY) {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -147,20 +147,21 @@ void usbd_configure_done_callback(void)
|
||||
}
|
||||
|
||||
volatile bool tx_flag = 0;
|
||||
volatile bool iso_tx_busy = false;
|
||||
|
||||
void usbd_video_open(uint8_t intf)
|
||||
{
|
||||
tx_flag = 1;
|
||||
USB_LOG_RAW("OPEN\r\n");
|
||||
iso_tx_busy = false;
|
||||
}
|
||||
void usbd_video_close(uint8_t intf)
|
||||
{
|
||||
USB_LOG_RAW("CLOSE\r\n");
|
||||
tx_flag = 0;
|
||||
iso_tx_busy = false;
|
||||
}
|
||||
|
||||
volatile bool iso_tx_busy = false;
|
||||
|
||||
void usbd_video_iso_callback(uint8_t ep, uint32_t nbytes)
|
||||
{
|
||||
USB_LOG_RAW("actual in len:%d\r\n", nbytes);
|
||||
@@ -182,7 +183,7 @@ void video_init()
|
||||
usbd_initialize();
|
||||
}
|
||||
|
||||
USB_NOCACHE_RAM_SECTION USB_MEM_ALIGNX uint8_t packet_buffer[10 * 1024];
|
||||
USB_MEM_ALIGNX uint8_t packet_buffer[10 * 1024];
|
||||
|
||||
void video_test()
|
||||
{
|
||||
@@ -196,6 +197,9 @@ void video_test()
|
||||
iso_tx_busy = true;
|
||||
usbd_ep_start_write(VIDEO_IN_EP, packet_buffer, out_len);
|
||||
while (iso_tx_busy) {
|
||||
if (tx_flag == 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
#else
|
||||
/* dwc2 must use this method */
|
||||
@@ -204,11 +208,17 @@ void video_test()
|
||||
iso_tx_busy = true;
|
||||
usbd_ep_start_write(VIDEO_IN_EP, &packet_buffer[i * MAX_PAYLOAD_SIZE], out_len - (packets - 1) * MAX_PAYLOAD_SIZE);
|
||||
while (iso_tx_busy) {
|
||||
if (tx_flag == 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
iso_tx_busy = true;
|
||||
usbd_ep_start_write(VIDEO_IN_EP, &packet_buffer[i * MAX_PAYLOAD_SIZE], MAX_PAYLOAD_SIZE);
|
||||
while (iso_tx_busy) {
|
||||
if (tx_flag == 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user