Index: usbcore.c
===================================================================
--- usbcore.c (revision 353)
+++ usbcore.c (working copy)
@@ -394,32 +394,6 @@
/*
- * Add a number of bytes to a pointer's address
- * Harder than you might think. Some compilers say:
- * Expected an lvalue -- Assignment expects its first operand to be
- * an lvalue. Please note that a cast removes the lvaluedness of an
- * expression.
- *
- * vpptr = void pointer to pointer
- * n = number of bytes to add to pointer
- * Call looks like: AddPtr((void **)&myPointer, 8);
- */
-
-__inline void UsbAddPtr(void **vpptr, uint32_t n)
-{
- /* Declare a pointer to a pointer to a byte. Only a byte pointer
- * can be incremented by a number of bytes. Other pointers will
- * increment by a multiple of what they point to.
- */
- uint8_t **bpptr;
-
- /* Convert our void pointer to a pointer to a byte pointer to a pointer */
- bpptr = (uint8_t **)vpptr;
-
- /* Add 'n' bytes to our pointer value */
- (*bpptr) += n;
-}
-/*
* Set Configuration USB Request
* Parameters: None (global SetupPacket)
* Return Value: TRUE - Success, FALSE - Error
@@ -462,7 +436,10 @@
USB_DeviceStatus &= ~USB_GETSTATUS_SELF_POWERED;
}
} else {
- UsbAddPtr((void **)&pD, ((USB_CONFIGURATION_DESCRIPTOR *)pD)->wTotalLength);
+ /* increment pointer */
+ uint8_t *tmp = (void*)pD;
+ tmp += ((USB_CONFIGURATION_DESCRIPTOR *)pD)->wTotalLength;
+ pD = (void*)tmp;
continue;
}
break;
@@ -480,7 +457,10 @@
}
break;
}
- UsbAddPtr((void **)&pD, pD->bLength);
+ /* increment pointer */
+ uint8_t *tmp = (void*)pD;
+ tmp += pD->bLength;
+ pD = (void*)tmp;
}
}
else {
@@ -554,7 +534,10 @@
switch (pD->bDescriptorType) {
case USB_CONFIGURATION_DESCRIPTOR_TYPE:
if (((USB_CONFIGURATION_DESCRIPTOR *)pD)->bConfigurationValue != USB_Configuration) {
- UsbAddPtr((void **)&pD, ((USB_CONFIGURATION_DESCRIPTOR *)pD)->wTotalLength);
+ /* increment pointer */
+ uint8_t *tmp = (void*)pD;
+ tmp += ((USB_CONFIGURATION_DESCRIPTOR *)pD)->wTotalLength;
+ pD = (void*)tmp;
continue;
}
break;
@@ -588,7 +571,10 @@
}
break;
}
- UsbAddPtr((void **)&pD, pD->bLength);
+ /* increment pointer */
+ uint8_t *tmp = (void*)pD;
+ tmp += pD->bLength;
+ pD = (void*)tmp;
}
break;
default:
Index: usbhw.c
===================================================================
--- usbhw.c (revision 353)
+++ usbhw.c (working copy)
@@ -90,7 +90,7 @@
*/
void delay (uint32_t length ) {
- uint32_t i;
+ volatile uint32_t i;
for ( i = 0; i < length; i++ );
return;
|