diff options
author | gdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4> | 2011-02-09 16:36:49 +0000 |
---|---|---|
committer | gdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4> | 2011-02-09 16:36:49 +0000 |
commit | 77934792d53efe99678286bab123c42c546478a7 (patch) | |
tree | 19ff302d365627261bf60802d78669e31bda1b76 /os/hal/src/usb.c | |
parent | 9ab9d1b44b1dfc11094faf3da939d35061b53bed (diff) | |
download | ChibiOS-77934792d53efe99678286bab123c42c546478a7.tar.gz ChibiOS-77934792d53efe99678286bab123c42c546478a7.tar.bz2 ChibiOS-77934792d53efe99678286bab123c42c546478a7.zip |
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@2722 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'os/hal/src/usb.c')
-rw-r--r-- | os/hal/src/usb.c | 76 |
1 files changed, 69 insertions, 7 deletions
diff --git a/os/hal/src/usb.c b/os/hal/src/usb.c index d0db0ed5c..afec3c645 100644 --- a/os/hal/src/usb.c +++ b/os/hal/src/usb.c @@ -338,15 +338,73 @@ void usbDisableEndpointsI(USBDriver *usbp) { }
/**
+ * @brief Reads a packet from the dedicated packet buffer.
+ * @pre In order to use this function he endpoint must have been
+ * initialized in packet mode.
+ * @post The endpoint is ready to accept another packet.
+ *
+ * @param[in] usbp pointer to the @p USBDriver object
+ * @param[in] ep endpoint number
+ * @param[out] buf buffer where to copy the packet data
+ * @param[in] n maximum number of bytes to copy. This value must
+ * not exceed the maximum packet size for this endpoint.
+ * @return The received packet size regardless the specified
+ * @p n parameter.
+ * @retval USB_ENDPOINT_BUSY Endpoint busy receiving.
+ * @retval 0 Zero size packet received.
+ *
+ * @iclass
+ */
+size_t usbReadPacketI(USBDriver *usbp, usbep_t ep,
+ uint8_t *buf, size_t n) {
+
+ if (usbp->ep[ep]->receiving)
+ return USB_ENDPOINT_BUSY;
+
+ return usb_lld_read_packet(usbp, ep, buf, n);;
+}
+
+/**
+ * @brief Writes a packet to the dedicated packet buffer.
+ * @pre In order to use this function he endpoint must have been
+ * initialized in packet mode.
+ * @post The endpoint is ready to transmit the packet.
+ *
+ * @param[in] usbp pointer to the @p USBDriver object
+ * @param[in] ep endpoint number
+ * @param[in] buf buffer where to fetch the packet data
+ * @param[in] n maximum number of bytes to copy. This value must
+ * not exceed the maximum packet size for this endpoint.
+ * @return The operation status.
+ * @retval USB_ENDPOINT_BUSY Endpoint busy transmitting.
+ * @retval 0 Operation complete.
+ *
+ * @iclass
+ */
+size_t usbWritePacketI(USBDriver *usbp, usbep_t ep,
+ const uint8_t *buf, size_t n) {
+
+ if (usbp->ep[ep]->transmitting)
+ return USB_ENDPOINT_BUSY;
+
+ usb_lld_write_packet(usbp, ep, buf, n);
+ return 0;
+}
+
+/**
* @brief Starts a receive operation on an OUT endpoint.
+ * @pre In order to use this function he endpoint must have been
+ * initialized in transaction mode.
+ * @post The endpoint callback is invoked when the transfer has been
+ * completed.
*
* @param[in] usbp pointer to the @p USBDriver object
* @param[in] ep endpoint number
- * @param[out] buf buffer where to copy the endpoint data
- * @param[in] n maximum number of bytes to copy in the buffer
+ * @param[out] buf buffer where to copy the received data
+ * @param[in] n maximum number of bytes to copy
* @return The operation status.
- * @retval FALSE Receive operation started.
- * @retval TRUE Endpoint already receiving.
+ * @retval FALSE Operation complete.
+ * @retval TRUE Endpoint busy receiving.
*
* @iclass
*/
@@ -362,14 +420,18 @@ bool_t usbStartReceiveI(USBDriver *usbp, usbep_t ep, /**
* @brief Starts a transmit operation on an IN endpoint.
+ * @pre In order to use this function he endpoint must have been
+ * initialized in transaction mode.
+ * @post The endpoint callback is invoked when the transfer has been
+ * completed.
*
* @param[in] usbp pointer to the @p USBDriver object
* @param[in] ep endpoint number
- * @param[in] buf buffer where to fetch the endpoint data
+ * @param[in] buf buffer where to fetch the data to be transmitted
* @param[in] n maximum number of bytes to copy
* @return The operation status.
- * @retval FALSE Transmit operation started.
- * @retval TRUE Endpoint already transmitting.
+ * @retval FALSE Operation complete.
+ * @retval TRUE Endpoint busy transmitting.
*
* @iclass
*/
|