From 6a20a7107a016a4cb43c3f98362b447f883db8c8 Mon Sep 17 00:00:00 2001 From: Giovanni Di Sirio Date: Thu, 24 Dec 2015 13:04:12 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@8640 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/hal/ports/STM32/LLD/OTGv1/usb_lld.c | 31 +++++++++++-------------------- os/hal/ports/STM32/LLD/OTGv1/usb_lld.h | 2 +- 2 files changed, 12 insertions(+), 21 deletions(-) diff --git a/os/hal/ports/STM32/LLD/OTGv1/usb_lld.c b/os/hal/ports/STM32/LLD/OTGv1/usb_lld.c index 58ea74870..e20622424 100644 --- a/os/hal/ports/STM32/LLD/OTGv1/usb_lld.c +++ b/os/hal/ports/STM32/LLD/OTGv1/usb_lld.c @@ -220,24 +220,16 @@ static uint32_t otg_ram_alloc(USBDriver *usbp, size_t size) { static void otg_fifo_write_from_buffer(volatile uint32_t *fifop, const uint8_t *buf, size_t n) { - uint32_t w; - size_t i; - /* Pushing all complete words.*/ - i = 0; - w = 0; - while (i < n) { - w |= (uint32_t)*buf++ << ((i & 3) * 8); - i++; - if ((i & 3) == 0) { - *fifop = w; - w = 0; - } - } + osalDbgAssert(n > 0, "is zero"); - /* Remaining bytes.*/ - if ((i & 3) != 0) { - *fifop = w; + while (true) { + *fifop = *((uint32_t *)buf); + if (n <= 4) { + break; + } + n -= 4; + buf += 4; } } @@ -300,9 +292,8 @@ static void otg_fifo_read_to_buffer(volatile uint32_t *fifop, size_t n, size_t max) { uint32_t w = 0; - size_t i; + size_t i = 0; - i = 0; while (i < n) { if ((i & 3) == 0){ w = *fifop; @@ -414,7 +405,7 @@ static bool otg_txfifo_handler(USBDriver *usbp, usbep_t ep) { /* Transaction end condition.*/ if (usbp->epc[ep]->in_state->txcnt >= usbp->epc[ep]->in_state->txsize) - return TRUE; + return true; /* Number of bytes remaining in current transaction.*/ n = usbp->epc[ep]->in_state->txsize - usbp->epc[ep]->in_state->txcnt; @@ -424,7 +415,7 @@ static bool otg_txfifo_handler(USBDriver *usbp, usbep_t ep) { /* Checks if in the TXFIFO there is enough space to accommodate the next packet.*/ if (((usbp->otg->ie[ep].DTXFSTS & DTXFSTS_INEPTFSAV_MASK) * 4) < n) - return FALSE; + return false; #if STM32_USB_OTGFIFO_FILL_BASEPRI __set_BASEPRI(CORTEX_PRIO_MASK(STM32_USB_OTGFIFO_FILL_BASEPRI)); diff --git a/os/hal/ports/STM32/LLD/OTGv1/usb_lld.h b/os/hal/ports/STM32/LLD/OTGv1/usb_lld.h index 4ded14b85..78acf00c8 100644 --- a/os/hal/ports/STM32/LLD/OTGv1/usb_lld.h +++ b/os/hal/ports/STM32/LLD/OTGv1/usb_lld.h @@ -273,7 +273,7 @@ typedef struct { /** * @brief Pointer to the input queue. */ - input_queue_t *rxqueue; + input_queue_t *rxqueue; } queue; } mode; /** -- cgit v1.2.3