USBv1 performance improvements.

git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@8643 35acf78f-673a-0410-8e92-d51de3d6d3f4
master
Giovanni Di Sirio 2015-12-25 10:13:26 +00:00
parent a4272b606f
commit 6857f4ff33
2 changed files with 18 additions and 40 deletions

View File

@ -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;
int i = (int)n;
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++;
}
/* 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;
}
}

View File

@ -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