Skip to content

Commit

Permalink
usb: device: Add usb_transfer_is_busy() function
Browse files Browse the repository at this point in the history
Add usb_transfer_is_busy() function to check if there is ongoing
transfer.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
  • Loading branch information
finikorg authored and nashif committed May 8, 2019
1 parent cc1b2c7 commit 2c672b9
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
10 changes: 10 additions & 0 deletions include/usb/usb_device.h
Expand Up @@ -418,6 +418,16 @@ int usb_transfer_sync(u8_t ep, u8_t *data, size_t dlen, unsigned int flags);
*/ */
void usb_cancel_transfer(u8_t ep); void usb_cancel_transfer(u8_t ep);


/**
* @brief Check that transfer is ongoing for the endpoint
*
* @param[in] ep Endpoint address corresponding to the one
* listed in the device configuration table
*
* @return true if transfer is ongoing, false otherwise.
*/
bool usb_transfer_is_busy(u8_t ep);

/** /**
* @brief Start the USB remote wakeup procedure * @brief Start the USB remote wakeup procedure
* *
Expand Down
11 changes: 11 additions & 0 deletions subsys/usb/usb_device.c
Expand Up @@ -1194,6 +1194,17 @@ static struct usb_transfer_data *usb_ep_get_transfer(u8_t ep)
return NULL; return NULL;
} }


bool usb_transfer_is_busy(u8_t ep)
{
struct usb_transfer_data *trans = usb_ep_get_transfer(ep);

if (trans && trans->status == -EBUSY) {
return true;
}

return false;
}

static void usb_transfer_work(struct k_work *item) static void usb_transfer_work(struct k_work *item)
{ {
struct usb_transfer_data *trans; struct usb_transfer_data *trans;
Expand Down

0 comments on commit 2c672b9

Please sign in to comment.