aboutsummaryrefslogtreecommitdiffstats
path: root/os/hal/ports/STM32/LLD/OTGv1
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/OTGv1
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/OTGv1')
-rw-r--r--os/hal/ports/STM32/LLD/OTGv1/usb_lld.c119
-rw-r--r--os/hal/ports/STM32/LLD/OTGv1/usb_lld.h44
2 files changed, 18 insertions, 145 deletions
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
@@ -234,50 +234,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.
*
* @param[in] fifop pointer to the FIFO register
@@ -307,43 +263,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.
*
* @param[in] usbp pointer to the @p USBDriver object
@@ -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
@@ -215,10 +215,6 @@ typedef struct {
*/
typedef struct {
/**
- * @brief Buffer mode, queue or linear.
- */
- bool txqueued;
- /**
* @brief Requested transmit transfer size.
*/
size_t txsize;
@@ -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.
*/
@@ -251,10 +237,6 @@ typedef struct {
*/
typedef struct {
/**
- * @brief Buffer mode, queue or linear.
- */
- bool rxqueued;
- /**
* @brief Requested receive transfer size.
*/
size_t rxsize;
@@ -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.
*/