diff options
author | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2010-12-18 03:24:13 +0000 |
---|---|---|
committer | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2010-12-18 03:24:13 +0000 |
commit | 513f435250e6a6e5d0af288358091e9aff47cdba (patch) | |
tree | c353c0d4e2ade12f6662461aa8a6f665057b91d7 /nuttx/include | |
parent | 7e3a546c5be3f8c4a5838a73d26a672fb09ea52e (diff) | |
download | px4-nuttx-513f435250e6a6e5d0af288358091e9aff47cdba.tar.gz px4-nuttx-513f435250e6a6e5d0af288358091e9aff47cdba.tar.bz2 px4-nuttx-513f435250e6a6e5d0af288358091e9aff47cdba.zip |
Working through initialization state machine
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@3194 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/include')
-rw-r--r-- | nuttx/include/nuttx/usb/usbhost.h | 128 |
1 files changed, 85 insertions, 43 deletions
diff --git a/nuttx/include/nuttx/usb/usbhost.h b/nuttx/include/nuttx/usb/usbhost.h index e72e392ce..f49db871e 100644 --- a/nuttx/include/nuttx/usb/usbhost.h +++ b/nuttx/include/nuttx/usb/usbhost.h @@ -197,24 +197,21 @@ #define DRVR_ENUMERATE(drvr) ((drvr)->enumerate(drvr)) /************************************************************************************ - * Name: DRVR_TRANSFER + * Name: DRVR_ALLOC * * Description: - * Enqueue a request to handle a transfer descriptor. This method will - * enqueue the transfer request and return immediately. The transfer will - * be performed asynchronously. When the transfer completes, the USB host - * driver will call he complete() method of the struct usbhost_class_s - * interface. Only one transfer may be queued; this function cannot be - * again until the class complete() method has been called. + * Some hardware supports special memory in which transfer descriptors can + * be accessed more efficiently. This method provides a mechanism to allocate + * the transfer descriptor memory. If the underlying hardware does not support + * such "special" memory, this functions may simply map to malloc. * * Input Parameters: * drvr - The USB host driver instance obtained as a parameter from the call to * the class create() method. - * ed - The IN or OUT endpoint descriptor for the device endpoint on which to - * perform the transfer. - * buffer - A buffer containing the data to be sent (OUT endpoint) or received - * (IN endpoint). - * buflen - The length of the data to be sent or received. + * buffer - The address of a memory location provided by the caller in which to + * return the allocated buffer memory address. + * maxlen - The address of a memory location provided by the caller in which to + * return the maximum size of the allocated buffer memory. * * Returned Values: * On success, zero (OK) is returned. On a failure, a negated errno value is @@ -225,24 +222,21 @@ * ************************************************************************************/ -#define DRVR_TRANSFER(drvr,ed,buffer,buflen) ((drvr)->transfer(drvr,ed,buffer,buflen)) +#define DRVR_ALLOC(drvr,buffer,maxlen) ((drvr)->alloc(drvr,buffer,maxlen)) /************************************************************************************ - * Name: DRVR_ALLOC + * Name: DRVR_FREE * * Description: * Some hardware supports special memory in which transfer descriptors can - * be accessed more efficiently. This method provides a mechanism to allocate - * the transfer descriptor memory. If the underlying hardware does not support - * such "special" memory, this functions may simply map to malloc. + * be accessed more efficiently. This method provides a mechanism to free that + * transfer descriptor memory. If the underlying hardware does not support + * such "special" memory, this functions may simply map to free(). * * Input Parameters: * drvr - The USB host driver instance obtained as a parameter from the call to * the class create() method. - * buffer - The address of a memory location provided by the caller in which to - * return the allocated buffer memory address. - * maxlen - The address of a memory location provided by the caller in which to - * return the maximum size of the allocated buffer memory. + * buffer - The address of the allocated buffer memory to be freed. * * Returned Values: * On success, zero (OK) is returned. On a failure, a negated errno value is @@ -253,21 +247,28 @@ * ************************************************************************************/ -#define DRVR_ALLOC(drvr,buffer,maxlen) ((drvr)->alloc(drvr,buffer,maxlen)) +#define DRVR_FREE(drvr,buffer) ((drvr)->free(drvr,buffer)) /************************************************************************************ - * Name: DRVR_FREE + * Name: DRVR_CONTROL * * Description: - * Some hardware supports special memory in which transfer descriptors can - * be accessed more efficiently. This method provides a mechanism to free that - * transfer descriptor memory. If the underlying hardware does not support - * such "special" memory, this functions may simply map to free(). + * Enqueue a request on the control endpoint. This method will enqueue + * the request and return immediately. The transfer will be performed + * asynchronously. When the transfer completes, the USB host driver will + * call the complete() method of the struct usbhost_class_s interface. + * Only one transfer may be queued; Neither this method nor the transfer() + * method can be called again until the class complete() method has been called. * * Input Parameters: * drvr - The USB host driver instance obtained as a parameter from the call to * the class create() method. - * buffer - The address of the allocated buffer memory to be freed. + * req - Describes the request to be sent. This data will be copied from the + * user provided memory. Therefore, the req buffer may be declared on the + * stack. + * buffer - A buffer used for sending the request and for returning any + * responses. This buffer must be large enough to hold the length value + * in the request description. buffer must have been allocated using DRVR_ALLOC * * Returned Values: * On success, zero (OK) is returned. On a failure, a negated errno value is @@ -278,7 +279,39 @@ * ************************************************************************************/ -#define DRVR_FREE(drvr,buffer) ((drvr)->free(drvr,buffer)) +#define DRVR_CONTROL(drvr,req,buffer) ((drvr)->control(drvr,req,buffer)) + +/************************************************************************************ + * Name: DRVR_TRANSFER + * + * Description: + * Enqueue a request to handle a transfer descriptor. This method will + * enqueue the transfer request and return immediately. The transfer will + * be performed asynchronously. When the transfer completes, the USB host + * driver will call the complete() method of the struct usbhost_class_s + * interface. Only one transfer may be queued; Neither this method nor the + * control method can be called again until the class complete() method has + * been called. + * + * Input Parameters: + * drvr - The USB host driver instance obtained as a parameter from the call to + * the class create() method. + * ed - The IN or OUT endpoint descriptor for the device endpoint on which to + * perform the transfer. + * 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. + * + * Returned Values: + * On success, zero (OK) is returned. On a failure, a negated errno value is + * returned indicating the nature of the failure + * + * Assumptions: + * This function will *not* be called from an interrupt handler. + * + ************************************************************************************/ + +#define DRVR_TRANSFER(drvr,ed,buffer,buflen) ((drvr)->transfer(drvr,ed,buffer,buflen)) /************************************************************************************ * Public Types @@ -376,18 +409,6 @@ struct usbhost_driver_s int (*enumerate)(FAR struct usbhost_driver_s *drvr); - /* Enqueue a request to handle a transfer descriptor. This method will - * enqueue the transfer request and return immediately. The transfer will - * be performed asynchronously. When the transfer completes, the USB host - * driver will call he complete() method of the struct usbhost_class_s - * interface. Only one transfer may be queued; this function cannot be - * again until the class complete() method has been called. - */ - - int (*transfer)(FAR struct usbhost_driver_s *drvr, - FAR struct usbhost_epdesc_s *ed, - FAR uint8_t *buffer, size_t buflen); - /* Some hardware supports special memory in which transfer descriptors can * be accessed more efficiently. The following methods provide a mechanism * to allocate and free the transfer descriptor memory. If the underlying @@ -399,9 +420,30 @@ struct usbhost_driver_s FAR uint8_t **buffer, FAR size_t *maxlen); int (*free)(FAR struct usbhost_driver_s *drvr, FAR uint8_t *buffer); - /* Receive control information */ + /* Enqueue a request on the control endpoint. This method will enqueue + * the request and return immediately. The transfer will be performed + * asynchronously. When the transfer completes, the USB host driver will + * call the complete() method of the struct usbhost_class_s interface. + * Only one transfer may be queued; Neither this method nor the transfer() + * method can be called again until the class complete() method has been called. + */ + + int (*control)(FAR struct usbhost_driver_s *drvr, + const struct usb_ctrlreq_s *req, + FAR uint8_t *buffer); + + /* Enqueue a request to handle a transfer descriptor. This method will + * enqueue the transfer request and return immediately. The transfer will + * be performed asynchronously. When the transfer completes, the USB host + * driver will call the complete() method of the struct usbhost_class_s + * interface. Only one transfer may be queued; Neither this method nor the + * control method can be called again until the class complete() method has + * been called. + */ - int (*rcvctrl)(FAR struct usbhost_driver_s *drvr, FAR struct usbhost_epdesc_s *ed); + int (*transfer)(FAR struct usbhost_driver_s *drvr, + FAR struct usbhost_epdesc_s *ed, + FAR uint8_t *buffer, size_t buflen); }; /* This structure describes one endpoint */ |