Tool/software: TI-RTOS
Hi
I'm working with evmAM335x. In my code i have two tasks to implement usb Bulk device comunication
In Task1 I initialize the usb and block inside USBD_bulkRead() waiting for a msg from the host.
In Task2 I block inside a Mailbox.
Void Task1 (UArg a0, UArg a1) { usbInit(); // Function that initialize usb bulk instance. Mailbox_Handle mbx = (Mailbox_Handle)a0; while(1){ uint32_t rxBytes; if (g_ulFlags & COMMAND_STATUS_UPDATE){ g_ulFlags &= ~COMMAND_STATUS_UPDATE; if (g_bulk_state == BULK_STATE_CONNECTED){ usb_osalDelayMs(500); g_bulk_state = BULK_STATE_READY; } } if (g_bulk_state = BULK_STATE_READY){ memset(g_bulkRxBuffer, 0, MAX_TRANSFER_SIZE); USBD_bulkRead(g_usbHandle, g_bulkRxBuffer, &rxBytes); if(rxBytes > 0){ Mailbox_post(mbx, g_bulkRxBuffer, BIOS_NO_WAIT); } } } } Void Task2 (UArg a0, UArg a1) { Mailbox_Handle mbx = (Mailbox_Handle)a0; while(1){ if(Mailbox_pend (mbx, g_bulkTxBuffer, BIOS_WAIT_FOREVER)){ if (g_bulk_state == BULK_STATE_READY){ USBD_bulkWrite(g_usbHandle, g_bulkTxBuffer, 15); } } } }
I can transmit some data through USBD_bulkWrite() while another task is blocked in USBD_bulkRead(), but when I receive data from host the code jumps to syscall _exit();
I try control this behavior, meaning that in other test I make sure that USBD_bulkWrite() is not called when USBD_bulkRead() is blocked. And this works great, but I only can respond to host's messages. With this workaround I can never send unsolicited messages to the host.
Can someone help me?