From 18853dba2210eadd2d919da2f17a9b5b553245fd Mon Sep 17 00:00:00 2001
From: gdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>
Date: Sun, 6 Feb 2011 10:02:08 +0000
Subject: Removed some obsolete code from the USB driver.

git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@2715 35acf78f-673a-0410-8e92-d51de3d6d3f4
---
 os/hal/include/usb.h             |  58 ++++----------------
 os/hal/platforms/STM32/usb_lld.c | 116 +--------------------------------------
 os/hal/platforms/STM32/usb_lld.h |   5 --
 3 files changed, 13 insertions(+), 166 deletions(-)

diff --git a/os/hal/include/usb.h b/os/hal/include/usb.h
index e5f309bd3..26c701f52 100644
--- a/os/hal/include/usb.h
+++ b/os/hal/include/usb.h
@@ -222,70 +222,35 @@ typedef const USBDescriptor * (*usbgetdescriptor_t)(USBDriver *usbp,
  * @param[in] usbp      pointer to the @p USBDriver object
  * @return              The current frame number.
  *
- * @notapi
+ * @api
  */
 #define usbGetFrameNumber(usbp) usb_lld_get_frame_number(usbp)
 
 /**
- * @brief   Returns the number of bytes readable from the receive packet
- *          buffer.
- *
- * @param[in] usbp      pointer to the @p USBDriver object
- * @param[in] ep        endpoint number
- * @return              The number of bytes that are effectively available.
- * @retval 0            Data not yet available.
- *
- * @iclass
- */
-#define usbGetReadableI(usbp, ep) usb_lld_get_readable(usbp, ep)
-
-/**
- * @brief   Endpoint read.
- * @details The buffered packet is copied into the user buffer and then
- *          the endpoint is brought to the valid state in order to allow
- *          reception of more data.
+ * @brief   Returns the status of an IN endpoint.
  *
  * @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
- * @return              The number of bytes that were effectively available.
- * @retval 0            Data not yet available.
+ * @return              The operation status.
+ * @retval FALSE        Endpoint ready.
+ * @retval TRUE         Endpoint busy.
  *
  * @iclass
  */
-#define usbReadI(usbp, ep, buf, n) usb_lld_read(usbp, ep, buf, n)
+#define usbGetTransmitStatusI(usbp, ep) (usbp)->ep[ep]->transmitting
 
 /**
- * @brief   Returns the number of bytes writeable to the transmit packet
- *          buffer.
+ * @brief   Returns the status of an OUT endpoint.
  *
  * @param[in] usbp      pointer to the @p USBDriver object
  * @param[in] ep        endpoint number
- * @return              The number of bytes that can be written.
- * @retval 0            Endpoint not ready for transmission.
- *
- * @iclass
- */
-#define usbGetWriteableI(usbp, ep) usb_lld_get_readable(usbp, ep)
-
-/**
- * @brief   Endpoint write.
- * @details The user data is copied in the packer memory and then
- *          the endpoint is brought to the valid state in order to allow
- *          transmission.
- *
- * @param[in] usbp      pointer to the @p USBDriver object triggering the
- *                      callback
- * @param[in] ep        endpoint number
- * @param[in] buf       buffer where to copy the endpoint data
- * @param[in] n         maximum number of bytes to copy
- * @return              The number of bytes that were effectively written.
- * @retval 0            Endpoint not ready for transmission.
+ * @return              The operation status.
+ * @retval FALSE        Endpoint ready.
+ * @retval TRUE         Endpoint busy.
  *
  * @iclass
  */
-#define usbWriteI(usbp, ep, buf, n) usb_lld_write(usbp, ep, buf, n)
+#define usbGetReceiveStatusI(usbp, ep) (usbp)->ep[ep]->receiving
 
 /**
  * @brief   Request transfer setup.
@@ -295,7 +260,6 @@ typedef const USBDescriptor * (*usbgetdescriptor_t)(USBDriver *usbp,
  * @param[in] usbp      pointer to the @p USBDriver object
  * @param[in] buf       pointer to a buffer for the transaction data
  * @param[in] n         number of bytes to be transferred
- * @param[in] endcb     transfer complete callback
  *
  * @api
  */
diff --git a/os/hal/platforms/STM32/usb_lld.c b/os/hal/platforms/STM32/usb_lld.c
index c55251d9b..e1ba15de5 100644
--- a/os/hal/platforms/STM32/usb_lld.c
+++ b/os/hal/platforms/STM32/usb_lld.c
@@ -192,6 +192,7 @@ CH_IRQ_HANDLER(USB_LP_IRQHandler) {
       }
       else {
         /* Transfer completed, invoking the callback, if defined.*/
+        (usbp)->ep[ep]->transmitting = FALSE;
         if (epcp->in_cb)
           epcp->in_cb(usbp, ep);
       }
@@ -218,6 +219,7 @@ CH_IRQ_HANDLER(USB_LP_IRQHandler) {
         }
         else {
           /* Transfer completed, invoking the callback, if defined.*/
+          (usbp)->ep[ep]->receiving = FALSE;
           if (epcp->out_cb)
             epcp->out_cb(usbp, ep);
         }
@@ -394,120 +396,6 @@ void usb_lld_disable_endpoints(USBDriver *usbp) {
 
 }
 
-/**
- * @brief   Returns the number of bytes readable from the receive packet
- *          buffer.
- *
- * @param[in] usbp      pointer to the @p USBDriver object
- * @param[in] ep        endpoint number
- * @return              The number of bytes that are effectively available.
- * @retval 0            Data not yet available.
- *
- * @notapi
- */
-size_t usb_lld_get_readable(USBDriver *usbp, usbep_t ep) {
-
-  (void)usbp;
-  if ((STM32_USB->EPR[ep] & EPR_STAT_RX_MASK) != EPR_STAT_RX_NAK)
-    return 0;
-  return (size_t)(USB_GET_DESCRIPTOR(ep)->RXCOUNT & RXCOUNT_COUNT_MASK);
-}
-
-/**
- * @brief   Endpoint read.
- * @details The buffered packet is copied into the user buffer and then
- *          the endpoint is brought to the valid state in order to allow
- *          reception of more data.
- *
- * @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
- * @return              The number of bytes that were effectively available.
- * @retval 0            Data not yet available.
- *
- * @notapi
- */
-size_t usb_lld_read(USBDriver *usbp, usbep_t ep, uint8_t *buf, size_t n) {
-  uint32_t *pmap;
-  stm32_usb_descriptor_t *udp;
-  size_t count;
-
-  (void)usbp;
-  if ((STM32_USB->EPR[ep] & EPR_STAT_RX_MASK) != EPR_STAT_RX_NAK)
-    return 0;
-
-  udp = USB_GET_DESCRIPTOR(ep);
-  pmap = USB_ADDR2PTR(udp->RXADDR);
-  count = udp->RXCOUNT & RXCOUNT_COUNT_MASK;
-  if (n > count)
-    n = count;
-  count = (n + 1) / 2;
-  while (count) {
-    *(uint16_t *)buf = (uint16_t)*pmap++;
-    buf += 2;
-    count--;
-  }
-  EPR_SET_STAT_RX(ep, EPR_STAT_RX_VALID);
-  return n;
-}
-/**
- * @brief   Returns the number of bytes writeable to the transmit packet
- *          buffer.
- *
- * @param[in] usbp      pointer to the @p USBDriver object
- * @param[in] ep        endpoint number
- * @return              The number of bytes that can be written.
- * @retval 0            Endpoint not ready for transmission.
- *
- * @iclass
- */
-size_t usb_lld_get_writeable(USBDriver *usbp, usbep_t ep) {
-
-  if ((STM32_USB->EPR[ep] & EPR_STAT_TX_MASK) != EPR_STAT_TX_NAK)
-    return 0;
-  return (size_t)usbp->ep[ep]->config->in_maxsize;
-}
-
-/**
- * @brief   Endpoint write.
- * @details The user data is copied in the packer memory and then
- *          the endpoint is brought to the valid state in order to allow
- *          transmission.
- *
- * @param[in] usbp      pointer to the @p USBDriver object
- * @param[in] ep        endpoint number
- * @param[in] buf       buffer where to copy the endpoint data
- * @param[in] n         maximum number of bytes to copy
- * @return              The number of bytes that were effectively written.
- * @retval 0            Endpoint not ready for transmission.
- *
- * @notapi
- */
-size_t usb_lld_write(USBDriver *usbp, usbep_t ep,
-                     const uint8_t *buf,
-                     size_t n) {
-  uint32_t *pmap;
-  stm32_usb_descriptor_t *udp;
-  size_t count;
-
-  (void)usbp;
-  if ((STM32_USB->EPR[ep] & EPR_STAT_TX_MASK) != EPR_STAT_TX_NAK)
-    return 0;
-
-  udp = USB_GET_DESCRIPTOR(ep);
-  pmap = USB_ADDR2PTR(udp->TXADDR);
-  udp->TXCOUNT = n;
-  count = (n + 1) / 2;
-  while (count) {
-    *pmap++ = *(uint16_t *)buf;
-    buf += 2;
-    count--;
-  }
-  EPR_SET_STAT_TX(ep, EPR_STAT_TX_VALID);
-  return n;
-}
-
 /**
  * @brief   Returns the status of an OUT endpoint.
  *
diff --git a/os/hal/platforms/STM32/usb_lld.h b/os/hal/platforms/STM32/usb_lld.h
index 7947e22fc..d365521ee 100644
--- a/os/hal/platforms/STM32/usb_lld.h
+++ b/os/hal/platforms/STM32/usb_lld.h
@@ -310,11 +310,6 @@ extern "C" {
   void usb_lld_set_address(USBDriver *usbp);
   void usb_lld_init_endpoint(USBDriver *usbp, usbep_t ep);
   void usb_lld_disable_endpoints(USBDriver *usbp);
-  size_t usb_lld_get_readable(USBDriver *usbp, usbep_t ep);
-  size_t usb_lld_read(USBDriver *usbp, usbep_t ep,
-                      uint8_t *buf, size_t n);
-  size_t usb_lld_write(USBDriver *usbp, usbep_t ep,
-                       const uint8_t *buf, size_t n);
   usbepstatus_t usb_lld_get_status_in(USBDriver *usbp, usbep_t ep);
   usbepstatus_t usb_lld_get_status_out(USBDriver *usbp, usbep_t ep);
   void usb_lld_start_out(USBDriver *usbp, usbep_t ep,
-- 
cgit v1.2.3