diff options
author | Giovanni Di Sirio <gdisirio@gmail.com> | 2015-12-25 10:13:26 +0000 |
---|---|---|
committer | Giovanni Di Sirio <gdisirio@gmail.com> | 2015-12-25 10:13:26 +0000 |
commit | 6857f4ff339826e7c5b2f26cf19d6275208631e6 (patch) | |
tree | b74c367dbe261dea36de4021ed391adeed59ed45 | |
parent | a4272b606f1a92b9c47d57c918f4296f58f0b2cc (diff) | |
download | ChibiOS-6857f4ff339826e7c5b2f26cf19d6275208631e6.tar.gz ChibiOS-6857f4ff339826e7c5b2f26cf19d6275208631e6.tar.bz2 ChibiOS-6857f4ff339826e7c5b2f26cf19d6275208631e6.zip |
USBv1 performance improvements.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@8643 35acf78f-673a-0410-8e92-d51de3d6d3f4
-rw-r--r-- | os/hal/ports/STM32/LLD/USBv1/usb_lld.c | 56 | ||||
-rw-r--r-- | readme.txt | 2 |
2 files changed, 18 insertions, 40 deletions
diff --git a/os/hal/ports/STM32/LLD/USBv1/usb_lld.c b/os/hal/ports/STM32/LLD/USBv1/usb_lld.c index c06b317bb..05d03f524 100644 --- a/os/hal/ports/STM32/LLD/USBv1/usb_lld.c +++ b/os/hal/ports/STM32/LLD/USBv1/usb_lld.c @@ -129,25 +129,17 @@ static uint32_t usb_pm_alloc(USBDriver *usbp, size_t size) { */
static void usb_packet_read_to_buffer(stm32_usb_descriptor_t *udp,
uint8_t *buf, size_t n) {
- stm32_usb_pma_t *pmap;
- uint32_t w;
- size_t i;
+ stm32_usb_pma_t *pmap = USB_ADDR2PTR(udp->RXADDR0);
- pmap = USB_ADDR2PTR(udp->RXADDR0);
+ while (n > 1) {
+ uint32_t w = *pmap++;
+ *buf++ = (uint8_t)w;
+ *buf++ = (uint8_t)(w >> 8);
+ n -= 2;
+ }
- i = 0;
- w = 0; /* Useless but silences a warning.*/
- while (i < n) {
- if ((i & 1) == 0){
- w = *pmap;
- *buf = (uint8_t)w;
- pmap++;
- }
- else {
- *buf = (uint8_t)(w >> 8);
- }
- i++;
- buf++;
+ if (n > 0) {
+ *buf = (uint8_t)*pmap;
}
}
@@ -164,31 +156,15 @@ static void usb_packet_read_to_buffer(stm32_usb_descriptor_t *udp, static void usb_packet_write_from_buffer(stm32_usb_descriptor_t *udp,
const uint8_t *buf,
size_t n) {
+ stm32_usb_pma_t *pmap = USB_ADDR2PTR(udp->TXADDR0);
uint32_t w;
- size_t i;
- stm32_usb_pma_t *pmap;
-
- pmap = USB_ADDR2PTR(udp->TXADDR0);
-
- /* Pushing all complete words.*/
- i = 0;
- w = 0; /* Useless but silences a warning.*/
- while (i < n) {
- if ((i & 1) == 0) {
- w = (uint32_t)*buf;
- }
- else {
- w |= (uint32_t)*buf << 8;
- *pmap = (stm32_usb_pma_t)w;
- pmap++;
- }
- i++;
- buf++;
- }
+ int i = (int)n;
- /* Remaining byte.*/
- if ((i & 1) != 0) {
- *pmap = (stm32_usb_pma_t)w;
+ while (i > 0) {
+ w = *buf++;
+ w |= *buf++ << 8;
+ *pmap++ = (stm32_usb_pma_t)w;
+ i -= 2;
}
}
diff --git a/readme.txt b/readme.txt index 8f977d245..e7e1d7152 100644 --- a/readme.txt +++ b/readme.txt @@ -77,6 +77,8 @@ - HAL: Introduced preliminary support for STM32F7xx devices.
- HAL: Introduced preliminary support for STM32L4xx devices.
- HAL: Introduced preliminary support for STM32L0xx devices.
+- HAL: Increased performance of USBv1 and OTGv1 driver thanks to better
+ data copying code.
- HAL: Enhanced Serial-USB driver using the new buffers queues object.
- HAL: Simplified USB driver, queued API has been removed.
- HAL: Enhanced the CAN driver with I-class functions. Now it is possible
|