aboutsummaryrefslogtreecommitdiffstats
path: root/os/hal/ports/STM32/LLD/USBv1
diff options
context:
space:
mode:
authorGiovanni Di Sirio <gdisirio@gmail.com>2015-12-25 08:59:10 +0000
committerGiovanni Di Sirio <gdisirio@gmail.com>2015-12-25 08:59:10 +0000
commit4b601a5d0fd06f8e238c17fb96633100ecc59503 (patch)
tree0ed28cfc2e87f0a346850c49a9343df30604f218 /os/hal/ports/STM32/LLD/USBv1
parent6a20a7107a016a4cb43c3f98362b447f883db8c8 (diff)
downloadChibiOS-4b601a5d0fd06f8e238c17fb96633100ecc59503.tar.gz
ChibiOS-4b601a5d0fd06f8e238c17fb96633100ecc59503.tar.bz2
ChibiOS-4b601a5d0fd06f8e238c17fb96633100ecc59503.zip
USB upgrade.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@8641 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'os/hal/ports/STM32/LLD/USBv1')
-rw-r--r--os/hal/ports/STM32/LLD/USBv1/usb_lld.c133
-rw-r--r--os/hal/ports/STM32/LLD/USBv1/usb_lld.h45
2 files changed, 22 insertions, 156 deletions
diff --git a/os/hal/ports/STM32/LLD/USBv1/usb_lld.c b/os/hal/ports/STM32/LLD/USBv1/usb_lld.c
index 45450b0bb..c06b317bb 100644
--- a/os/hal/ports/STM32/LLD/USBv1/usb_lld.c
+++ b/os/hal/ports/STM32/LLD/USBv1/usb_lld.c
@@ -152,50 +152,6 @@ static void usb_packet_read_to_buffer(stm32_usb_descriptor_t *udp,
}
/**
- * @brief Reads from a dedicated packet buffer.
- *
- * @param[in] udp pointer to a @p stm32_usb_descriptor_t
- * @param[in] iqp pointer to an @p input_queue_t object
- * @param[in] n maximum number of bytes to copy. This value must
- * not exceed the maximum packet size for this endpoint.
- *
- * @notapi
- */
-static void usb_packet_read_to_queue(stm32_usb_descriptor_t *udp,
- input_queue_t *iqp, size_t n) {
- size_t nhw;
- stm32_usb_pma_t *pmap= USB_ADDR2PTR(udp->RXADDR0);
-
- nhw = n / 2;
- while (nhw > 0) {
- stm32_usb_pma_t w;
-
- w = *pmap++;
- *iqp->q_wrptr++ = (uint8_t)w;
- if (iqp->q_wrptr >= iqp->q_top)
- iqp->q_wrptr = iqp->q_buffer;
- *iqp->q_wrptr++ = (uint8_t)(w >> 8);
- if (iqp->q_wrptr >= iqp->q_top)
- iqp->q_wrptr = iqp->q_buffer;
- nhw--;
- }
- /* Last byte for odd numbers.*/
- if ((n & 1) != 0) {
- *iqp->q_wrptr++ = (uint8_t)*pmap;
- if (iqp->q_wrptr >= iqp->q_top)
- iqp->q_wrptr = iqp->q_buffer;
- }
-
- /* Updating queue.*/
- osalSysLockFromISR();
-
- iqp->q_counter += n;
- osalThreadDequeueAllI(&iqp->q_waiting, Q_OK);
-
- osalSysUnlockFromISR();
-}
-
-/**
* @brief Writes to a dedicated packet buffer.
*
* @param[in] udp pointer to a @p stm32_usb_descriptor_t
@@ -237,52 +193,6 @@ static void usb_packet_write_from_buffer(stm32_usb_descriptor_t *udp,
}
/**
- * @brief Writes to a dedicated packet buffer.
- *
- * @param[in] udp pointer to a @p stm32_usb_descriptor_t
- * @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.
- *
- * @notapi
- */
-static void usb_packet_write_from_queue(stm32_usb_descriptor_t *udp,
- output_queue_t *oqp, size_t n) {
- size_t nhw;
- syssts_t sts;
- stm32_usb_pma_t *pmap = USB_ADDR2PTR(udp->TXADDR0);
-
- nhw = n / 2;
- while (nhw > 0) {
- stm32_usb_pma_t w;
-
- w = (stm32_usb_pma_t)*oqp->q_rdptr++;
- if (oqp->q_rdptr >= oqp->q_top)
- oqp->q_rdptr = oqp->q_buffer;
- w |= (stm32_usb_pma_t)*oqp->q_rdptr++ << 8;
- if (oqp->q_rdptr >= oqp->q_top)
- oqp->q_rdptr = oqp->q_buffer;
- *pmap++ = w;
- nhw--;
- }
-
- /* Last byte for odd numbers.*/
- if ((n & 1) != 0) {
- *pmap = (stm32_usb_pma_t)*oqp->q_rdptr++;
- if (oqp->q_rdptr >= oqp->q_top)
- oqp->q_rdptr = oqp->q_buffer;
- }
-
- /* Updating queue.*/
- sts = osalSysGetStatusAndLockX();
-
- oqp->q_counter += n;
- osalThreadDequeueAllI(&oqp->q_waiting, Q_OK);
-
- osalSysRestoreStatusX(sts);
-}
-
-/**
* @brief Common ISR code, serves the EP-related interrupts.
*
* @param[in] usbp pointer to the @p USBDriver object
@@ -328,16 +238,11 @@ static void usb_serve_endpoints(USBDriver *usbp, uint32_t ep) {
if (EPR_EP_TYPE_IS_ISO(epr) && (epr & EPR_DTOG_TX))
USB_GET_DESCRIPTOR(ep)->TXCOUNT1 = (stm32_usb_pma_t)n;
- if (epcp->in_state->txqueued)
- usb_packet_write_from_queue(USB_GET_DESCRIPTOR(ep),
- epcp->in_state->mode.queue.txqueue,
- n);
- else {
- epcp->in_state->mode.linear.txbuf += transmitted;
- usb_packet_write_from_buffer(USB_GET_DESCRIPTOR(ep),
- epcp->in_state->mode.linear.txbuf,
- n);
- }
+ /* Writes the packet from the defined buffer.*/
+ epcp->in_state->txbuf += transmitted;
+ usb_packet_write_from_buffer(USB_GET_DESCRIPTOR(ep),
+ epcp->in_state->txbuf,
+ n);
osalSysLockFromISR();
usb_lld_start_in(usbp, ep);
osalSysUnlockFromISR();
@@ -370,21 +275,15 @@ static void usb_serve_endpoints(USBDriver *usbp, uint32_t ep) {
n = (size_t)udp->RXCOUNT1 & RXCOUNT_COUNT_MASK;
/* Reads the packet into the defined buffer.*/
- if (epcp->out_state->rxqueued)
- usb_packet_read_to_queue(udp,
- epcp->out_state->mode.queue.rxqueue,
- n);
- else {
- usb_packet_read_to_buffer(udp,
- epcp->out_state->mode.linear.rxbuf,
- n);
- epcp->out_state->mode.linear.rxbuf += n;
- }
+ usb_packet_read_to_buffer(udp,
+ epcp->out_state->rxbuf,
+ n);
+ epcp->out_state->rxbuf += n;
/* Transaction data updated.*/
- epcp->out_state->rxcnt += n;
- epcp->out_state->rxsize -= n;
- epcp->out_state->rxpkts -= 1;
+ epcp->out_state->rxcnt += n;
+ epcp->out_state->rxsize -= n;
+ epcp->out_state->rxpkts -= 1;
/* The transaction is completed if the specified number of packets
has been received or the current packet is a short packet.*/
@@ -828,12 +727,8 @@ void usb_lld_prepare_transmit(USBDriver *usbp, usbep_t ep) {
if (EPR_EP_TYPE_IS_ISO(epr) && (epr & EPR_DTOG_TX))
USB_GET_DESCRIPTOR(ep)->TXCOUNT1 = (stm32_usb_pma_t)n;
- if (isp->txqueued)
- usb_packet_write_from_queue(USB_GET_DESCRIPTOR(ep),
- isp->mode.queue.txqueue, n);
- else
- usb_packet_write_from_buffer(USB_GET_DESCRIPTOR(ep),
- isp->mode.linear.txbuf, n);
+ usb_packet_write_from_buffer(USB_GET_DESCRIPTOR(ep),
+ isp->txbuf, n);
}
/**
diff --git a/os/hal/ports/STM32/LLD/USBv1/usb_lld.h b/os/hal/ports/STM32/LLD/USBv1/usb_lld.h
index 065350536..7464d52da 100644
--- a/os/hal/ports/STM32/LLD/USBv1/usb_lld.h
+++ b/os/hal/ports/STM32/LLD/USBv1/usb_lld.h
@@ -140,10 +140,6 @@
*/
typedef struct {
/**
- * @brief Buffer mode, queue or linear.
- */
- bool txqueued;
- /**
* @brief Requested transmit transfer size.
*/
size_t txsize;
@@ -151,21 +147,10 @@ typedef struct {
* @brief Transmitted bytes so far.
*/
size_t txcnt;
- union {
- struct {
- /**
- * @brief Pointer to the transmission linear buffer.
- */
- const uint8_t *txbuf;
- } linear;
- struct {
- /**
- * @brief Pointer to the output queue.
- */
- output_queue_t *txqueue;
- } queue;
- /* End of the mandatory fields.*/
- } mode;
+ /**
+ * @brief Pointer to the transmission linear buffer.
+ */
+ const uint8_t *txbuf;
} USBInEndpointState;
/**
@@ -173,10 +158,6 @@ typedef struct {
*/
typedef struct {
/**
- * @brief Buffer mode, queue or linear.
- */
- bool rxqueued;
- /**
* @brief Requested receive transfer size.
*/
size_t rxsize;
@@ -184,20 +165,10 @@ typedef struct {
* @brief Received bytes so far.
*/
size_t rxcnt;
- union {
- struct {
- /**
- * @brief Pointer to the receive linear buffer.
- */
- uint8_t *rxbuf;
- } linear;
- struct {
- /**
- * @brief Pointer to the input queue.
- */
- input_queue_t *rxqueue;
- } queue;
- } mode;
+ /**
+ * @brief Pointer to the receive linear buffer.
+ */
+ uint8_t *rxbuf;
/* End of the mandatory fields.*/
/**
* @brief Number of packets to receive.