USB HCDs: Add hooks for the async method

This commit is contained in:
Gregory Nutt 2015-04-21 15:43:12 -06:00
parent 28647cf705
commit 5189dd7074
3 changed files with 80 additions and 3 deletions

View File

@ -326,6 +326,12 @@ static int lpc17_ctrlout(struct usbhost_driver_s *drvr, usbhost_ep_t ep0,
const uint8_t *buffer);
static int lpc17_transfer(struct usbhost_driver_s *drvr, usbhost_ep_t ep,
uint8_t *buffer, size_t buflen);
#ifdef CONFIG_USBHOST_ASYNCH
static int lpc17_asynch(FAR struct usbhost_driver_s *drvr, usbhost_ep_t ep,
FAR uint8_t *buffer, size_t buflen,
usbhost_asynch_t callback, FAR void *arg);
#endif
static void lpc17_disconnect(struct usbhost_driver_s *drvr);
/* Initialization **************************************************************/
@ -2190,7 +2196,7 @@ static int lpc17_ctrlout(struct usbhost_driver_s *drvr, usbhost_ep_t ep0,
}
/*******************************************************************************
* Name: lpc17_transfer
* Name: lpc17_transfer and lcp17_async
*
* Description:
* Process a request to handle a transfer descriptor. This method will
@ -2201,6 +2207,13 @@ static int lpc17_ctrlout(struct usbhost_driver_s *drvr, usbhost_ep_t ep0,
* This is a blocking method; this functions will not return until the
* transfer has completed.
*
* - 'transfer' is a blocking method; this method will not return until the
* transfer has completed.
* - 'asynch' will return immediately. When the transfer completes, the
* the callback will be invoked with the provided transfer. This method
* is useful for receiving interrupt transfers which may come
* infrequently.
*
* Input Parameters:
* drvr - The USB host driver instance obtained as a parameter from the call to
* the class create() method.
@ -2209,6 +2222,10 @@ static int lpc17_ctrlout(struct usbhost_driver_s *drvr, usbhost_ep_t ep0,
* buffer - A buffer containing the data to be sent (OUT endpoint) or received
* (IN endpoint). buffer must have been allocated using DRVR_ALLOC
* buflen - The length of the data to be sent or received.
* callback - This function will be called when the transfer completes ('asynch'
* only).
* arg - The arbitrary parameter that will be passed to the callback function
* when the transfer completes ('asynch' only).
*
* Returned Values:
* On success, zero (OK) is returned. On a failure, a negated errno value is
@ -2380,6 +2397,16 @@ errout:
return ret;
}
#ifdef CONFIG_USBHOST_ASYNCH
static int lpc17_asynch(FAR struct usbhost_driver_s *drvr, usbhost_ep_t ep,
FAR uint8_t *buffer, size_t buflen,
usbhost_asynch_t callback, FAR void *arg)
{
# error Not implemented
return -ENOSYS;
}
#endif
/*******************************************************************************
* Name: lpc17_disconnect
*
@ -2526,6 +2553,9 @@ struct usbhost_connection_s *lpc17_usbhost_initialize(int controller)
drvr->ctrlin = lpc17_ctrlin;
drvr->ctrlout = lpc17_ctrlout;
drvr->transfer = lpc17_transfer;
#ifdef CONFIG_USBHOST_ASYNCH
drvr->asynch = lpc17_asynch;
#endif
drvr->disconnect = lpc17_disconnect;
/* Initialize the public port representation */

View File

@ -393,6 +393,11 @@ static int sam_ctrlout(FAR struct usbhost_driver_s *drvr, usbhost_ep_t ep0,
FAR const uint8_t *buffer);
static int sam_transfer(FAR struct usbhost_driver_s *drvr, usbhost_ep_t ep,
FAR uint8_t *buffer, size_t buflen);
#ifdef CONFIG_USBHOST_ASYNCH
static int sam_asynch(FAR struct usbhost_driver_s *drvr, usbhost_ep_t ep,
FAR uint8_t *buffer, size_t buflen,
usbhost_asynch_t callback, FAR void *arg);
#endif
static void sam_disconnect(FAR struct usbhost_driver_s *drvr);
/* Initialization **************************************************************/
@ -3706,7 +3711,7 @@ static int sam_ctrlout(FAR struct usbhost_driver_s *drvr, usbhost_ep_t ep0,
}
/*******************************************************************************
* Name: sam_transfer
* Name: sam_transfer and sam_asynch
*
* Description:
* Process a request to handle a transfer descriptor. This method will
@ -3716,6 +3721,13 @@ static int sam_ctrlout(FAR struct usbhost_driver_s *drvr, usbhost_ep_t ep0,
* This is a blocking method; this functions will not return until the
* transfer has completed.
*
* - 'transfer' is a blocking method; this method will not return until the
* transfer has completed.
* - 'asynch' will return immediately. When the transfer completes, the
* the callback will be invoked with the provided transfer. This method
* is useful for receiving interrupt transfers which may come
* infrequently.
*
* Input Parameters:
* drvr - The USB host driver instance obtained as a parameter from the call to
* the class create() method.
@ -3724,6 +3736,10 @@ static int sam_ctrlout(FAR struct usbhost_driver_s *drvr, usbhost_ep_t ep0,
* buffer - A buffer containing the data to be sent (OUT endpoint) or received
* (IN endpoint). buffer must have been allocated using DRVR_ALLOC
* buflen - The length of the data to be sent or received.
* callback - This function will be called when the transfer completes ('asynch'
* only).
* arg - The arbitrary parameter that will be passed to the callback function
* when the transfer completes ('asynch' only).
*
* Returned Values:
* On success, zero (OK) is returned. On a failure, a negated errno value is
@ -3784,6 +3800,16 @@ static int sam_transfer(FAR struct usbhost_driver_s *drvr, usbhost_ep_t ep,
return nbytes >=0 ? OK : (int)nbytes;
}
#ifdef CONFIG_USBHOST_ASYNCH
static int sam_asynch(FAR struct usbhost_driver_s *drvr, usbhost_ep_t ep,
FAR uint8_t *buffer, size_t buflen,
usbhost_asynch_t callback, FAR void *arg)
{
# error Not implemented
return -ENOSYS;
}
#endif
/*******************************************************************************
* Name: sam_disconnect
*
@ -4083,6 +4109,9 @@ FAR struct usbhost_connection_s *sam_ehci_initialize(int controller)
rhport->drvr.ctrlin = sam_ctrlin;
rhport->drvr.ctrlout = sam_ctrlout;
rhport->drvr.transfer = sam_transfer;
#ifdef CONFIG_USBHOST_ASYNCH
rhport->drvr.asynch = sam_asynch;
#endif
rhport->drvr.disconnect = sam_disconnect;
/* Initialize EP0 */

View File

@ -410,6 +410,11 @@ static int sam_ctrlout(FAR struct usbhost_driver_s *drvr, usbhost_ep_t ep0,
FAR const uint8_t *buffer);
static int sam_transfer(FAR struct usbhost_driver_s *drvr, usbhost_ep_t ep,
FAR uint8_t *buffer, size_t buflen);
#ifdef CONFIG_USBHOST_ASYNCH
static int sam_asynch(FAR struct usbhost_driver_s *drvr, usbhost_ep_t ep,
FAR uint8_t *buffer, size_t buflen,
usbhost_asynch_t callback, FAR void *arg);
#endif
static void sam_disconnect(FAR struct usbhost_driver_s *drvr);
/*******************************************************************************
@ -2855,7 +2860,7 @@ static int sam_ctrlout(FAR struct usbhost_driver_s *drvr, usbhost_ep_t ep0,
}
/*******************************************************************************
* Name: sam_transfer
* Name: sam_transfer and sam_asynch
*
* Description:
* Process a request to handle a transfer descriptor. This method will
@ -3032,6 +3037,16 @@ errout:
return ret;
}
#ifdef CONFIG_USBHOST_ASYNCH
static int sam_asynch(FAR struct usbhost_driver_s *drvr, usbhost_ep_t ep,
FAR uint8_t *buffer, size_t buflen,
usbhost_asynch_t callback, FAR void *arg)
{
# error Not implemented
return -ENOSYS;
}
#endif
/*******************************************************************************
* Name: sam_disconnect
*
@ -3237,6 +3252,9 @@ FAR struct usbhost_connection_s *sam_ohci_initialize(int controller)
rhport->drvr.ctrlin = sam_ctrlin;
rhport->drvr.ctrlout = sam_ctrlout;
rhport->drvr.transfer = sam_transfer;
#ifdef CONFIG_USBHOST_ASYNCH
rhport->drvr.asynch = sam_asynch;
#endif
rhport->drvr.disconnect = sam_disconnect;
/* Initialize the public port representation */