From 4b601a5d0fd06f8e238c17fb96633100ecc59503 Mon Sep 17 00:00:00 2001 From: Giovanni Di Sirio Date: Fri, 25 Dec 2015 08:59:10 +0000 Subject: USB upgrade. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@8641 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/hal/ports/STM32/LLD/OTGv1/usb_lld.c | 119 +++------------------------------ os/hal/ports/STM32/LLD/OTGv1/usb_lld.h | 44 +++--------- 2 files changed, 18 insertions(+), 145 deletions(-) (limited to 'os/hal/ports/STM32/LLD/OTGv1') diff --git a/os/hal/ports/STM32/LLD/OTGv1/usb_lld.c b/os/hal/ports/STM32/LLD/OTGv1/usb_lld.c index e20622424..4ec8fd976 100644 --- a/os/hal/ports/STM32/LLD/OTGv1/usb_lld.c +++ b/os/hal/ports/STM32/LLD/OTGv1/usb_lld.c @@ -233,50 +233,6 @@ static void otg_fifo_write_from_buffer(volatile uint32_t *fifop, } } -/** - * @brief Writes to a TX FIFO fetching data from a queue. - * - * @param[in] fifop pointer to the FIFO register - * @param[in] oqp pointer to an @p output_queue_t object - * @param[in] n maximum number of bytes to copy - * - * @notapi - */ -static void otg_fifo_write_from_queue(volatile uint32_t *fifop, - output_queue_t *oqp, - size_t n) { - uint32_t w; - size_t i; - - /* Pushing all complete words.*/ - i = 0; - w = 0; - while (i < n) { - w |= (uint32_t)*oqp->q_rdptr << ((i & 3) * 8); - oqp->q_rdptr++; - if (oqp->q_rdptr >= oqp->q_top) { - oqp->q_rdptr = oqp->q_buffer; - } - i++; - if ((i & 3) == 0) { - *fifop = w; - w = 0; - } - } - - /* Remaining bytes.*/ - if ((i & 3) != 0) { - *fifop = w; - } - - /* Updating queue.*/ - osalSysLock(); - oqp->q_counter += n; - osalThreadDequeueAllI(&oqp->q_waiting, Q_OK); - osalOsRescheduleS(); - osalSysUnlock(); -} - /** * @brief Reads a packet from the RXFIFO. * @@ -306,43 +262,6 @@ static void otg_fifo_read_to_buffer(volatile uint32_t *fifop, } } -/** - * @brief Reads a packet from the RXFIFO. - * - * @param[in] fifop pointer to the FIFO register - * @param[in] iqp pointer to an @p input_queue_t object - * @param[in] n number of bytes to pull from the FIFO - * - * @notapi - */ -static void otg_fifo_read_to_queue(volatile uint32_t *fifop, - input_queue_t *iqp, - size_t n) { - uint32_t w = 0; - size_t i; - - i = 0; - while (i < n) { - if ((i & 3) == 0){ - w = *fifop; - } - *iqp->q_wrptr = (uint8_t)w; - iqp->q_wrptr++; - if (iqp->q_wrptr >= iqp->q_top) { - iqp->q_wrptr = iqp->q_buffer; - } - w >>= 8; - i++; - } - - /* Updating queue.*/ - osalSysLock(); - iqp->q_counter += n; - osalThreadDequeueAllI(&iqp->q_waiting, Q_OK); - osalOsRescheduleS(); - osalSysUnlock(); -} - /** * @brief Incoming packets handler. * @@ -366,20 +285,12 @@ static void otg_rxfifo_handler(USBDriver *usbp) { case GRXSTSP_OUT_DATA: cnt = (sts & GRXSTSP_BCNT_MASK) >> GRXSTSP_BCNT_OFF; ep = (sts & GRXSTSP_EPNUM_MASK) >> GRXSTSP_EPNUM_OFF; - if (usbp->epc[ep]->out_state->rxqueued) { - /* Queue associated.*/ - otg_fifo_read_to_queue(usbp->otg->FIFO[0], - usbp->epc[ep]->out_state->mode.queue.rxqueue, - cnt); - } - else { - otg_fifo_read_to_buffer(usbp->otg->FIFO[0], - usbp->epc[ep]->out_state->mode.linear.rxbuf, - cnt, - usbp->epc[ep]->out_state->rxsize - - usbp->epc[ep]->out_state->rxcnt); - usbp->epc[ep]->out_state->mode.linear.rxbuf += cnt; - } + otg_fifo_read_to_buffer(usbp->otg->FIFO[0], + usbp->epc[ep]->out_state->rxbuf, + cnt, + usbp->epc[ep]->out_state->rxsize - + usbp->epc[ep]->out_state->rxcnt); + usbp->epc[ep]->out_state->rxbuf += cnt; usbp->epc[ep]->out_state->rxcnt += cnt; break; case GRXSTSP_OUT_GLOBAL_NAK: @@ -420,20 +331,10 @@ static bool otg_txfifo_handler(USBDriver *usbp, usbep_t ep) { #if STM32_USB_OTGFIFO_FILL_BASEPRI __set_BASEPRI(CORTEX_PRIO_MASK(STM32_USB_OTGFIFO_FILL_BASEPRI)); #endif - /* Handles the two cases: linear buffer or queue.*/ - if (usbp->epc[ep]->in_state->txqueued) { - /* Queue associated.*/ - otg_fifo_write_from_queue(usbp->otg->FIFO[ep], - usbp->epc[ep]->in_state->mode.queue.txqueue, - n); - } - else { - /* Linear buffer associated.*/ - otg_fifo_write_from_buffer(usbp->otg->FIFO[ep], - usbp->epc[ep]->in_state->mode.linear.txbuf, - n); - usbp->epc[ep]->in_state->mode.linear.txbuf += n; - } + otg_fifo_write_from_buffer(usbp->otg->FIFO[ep], + usbp->epc[ep]->in_state->txbuf, + n); + usbp->epc[ep]->in_state->txbuf += n; #if STM32_USB_OTGFIFO_FILL_BASEPRI __set_BASEPRI(0); #endif diff --git a/os/hal/ports/STM32/LLD/OTGv1/usb_lld.h b/os/hal/ports/STM32/LLD/OTGv1/usb_lld.h index 78acf00c8..a8c3bd4d9 100644 --- a/os/hal/ports/STM32/LLD/OTGv1/usb_lld.h +++ b/os/hal/ports/STM32/LLD/OTGv1/usb_lld.h @@ -214,10 +214,6 @@ typedef struct { * @brief Type of an IN endpoint state structure. */ typedef struct { - /** - * @brief Buffer mode, queue or linear. - */ - bool txqueued; /** * @brief Requested transmit transfer size. */ @@ -226,20 +222,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; - } mode; + /** + * @brief Pointer to the transmission linear buffer. + */ + const uint8_t *txbuf; /** * @brief Total transmit transfer size. */ @@ -250,10 +236,6 @@ typedef struct { * @brief Type of an OUT endpoint state structure. */ typedef struct { - /** - * @brief Buffer mode, queue or linear. - */ - bool rxqueued; /** * @brief Requested receive transfer size. */ @@ -262,20 +244,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; /** * @brief Total transmit transfer size. */ -- cgit v1.2.3