aboutsummaryrefslogtreecommitdiffstats
path: root/os/hal/include/usb.h
diff options
context:
space:
mode:
authorgdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2011-02-14 19:37:40 +0000
committergdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2011-02-14 19:37:40 +0000
commit2c15c4864f33c3c71c58e54494561eff1b291a0f (patch)
tree0fe85fb7e1825b67d78cadab18901bc7e6068e1b /os/hal/include/usb.h
parentdd6a0b3ccdd62873e1cb874969741e3fb683db4b (diff)
downloadChibiOS-2c15c4864f33c3c71c58e54494561eff1b291a0f.tar.gz
ChibiOS-2c15c4864f33c3c71c58e54494561eff1b291a0f.tar.bz2
ChibiOS-2c15c4864f33c3c71c58e54494561eff1b291a0f.zip
More improvements in the USB driver model.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@2738 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'os/hal/include/usb.h')
-rw-r--r--os/hal/include/usb.h39
1 files changed, 36 insertions, 3 deletions
diff --git a/os/hal/include/usb.h b/os/hal/include/usb.h
index 82ff59d03..a7b183fe4 100644
--- a/os/hal/include/usb.h
+++ b/os/hal/include/usb.h
@@ -139,7 +139,8 @@ typedef enum {
USB_EP0_TX, /**< Trasmitting. */
USB_EP0_WAITING_STS, /**< Waiting status. */
USB_EP0_RX, /**< Receiving. */
- USB_EP0_SENDING_STS /**< Sending status. */
+ USB_EP0_SENDING_STS, /**< Sending status. */
+ USB_EP0_ERROR /**< Error, EP0 stalled. */
} usbep0state_t;
/**
@@ -256,6 +257,37 @@ typedef const USBDescriptor * (*usbgetdescriptor_t)(USBDriver *usbp,
#define usbGetReceiveStatusI(usbp, ep) ((usbp)->receiving & (1 << (ep)))
/**
+ * @brief Returns the exact size of a receive transaction.
+ * @details The received size can be different from the size specified in
+ * @p usbStartReceiveI() because the last packet could have a size
+ * different from the expected one.
+ * @pre The OUT endpoint must have been configured in transaction mode
+ * in order to use this function.
+ *
+ * @param[in] usbp pointer to the @p USBDriver object
+ * @param[in] ep endpoint number
+ * @return Received data size.
+ *
+ * @iclass
+ */
+#define usbGetReceiveTransactionSizeI(usbp, ep) \
+ usb_lld_get_transaction_size(usbp, ep)
+
+/**
+ * @brief Returns the exact size of a received packet.
+ * @pre The OUT endpoint must have been configured in packet mode
+ * in order to use this function.
+ *
+ * @param[in] usbp pointer to the @p USBDriver object
+ * @param[in] ep endpoint number
+ * @return Received data size.
+ *
+ * @iclass
+ */
+#define usbGetReceivePacketSizeI(usbp, ep) \
+ usb_lld_get_packet_size(usbp, ep)
+
+/**
* @brief Request transfer setup.
* @details This macro is used by the request handling callbacks in order to
* prepare a transaction over the endpoint zero.
@@ -266,9 +298,10 @@ typedef const USBDescriptor * (*usbgetdescriptor_t)(USBDriver *usbp,
*
* @api
*/
-#define usbSetupTransfer(usbp, buf, n) { \
+#define usbSetupTransfer(usbp, buf, n, endcb) { \
(usbp)->ep0next = (buf); \
(usbp)->ep0n = (n); \
+ (usbp)->ep0endcb = (endcb); \
}
/*===========================================================================*/
@@ -282,7 +315,7 @@ extern "C" {
void usbObjectInit(USBDriver *usbp);
void usbStart(USBDriver *usbp, const USBConfig *config);
void usbStop(USBDriver *usbp);
- void usbInitEndpointI(USBDriver *usbp, usbep_t ep, USBEndpointState *epp,
+ void usbInitEndpointI(USBDriver *usbp, usbep_t ep,
const USBEndpointConfig *epcp);
void usbDisableEndpointsI(USBDriver *usbp);
size_t usbReadPacketI(USBDriver *usbp, usbep_t ep,