projects
/
pub
/
USBasp.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
a7eca42
)
Simplify the internal serial extraction routines for each architecture.
author
Dean Camera
<dean@fourwalledcubicle.com>
Sun, 13 Mar 2011 23:32:32 +0000
(23:32 +0000)
committer
Dean Camera
<dean@fourwalledcubicle.com>
Sun, 13 Mar 2011 23:32:32 +0000
(23:32 +0000)
LUFA/Drivers/USB/Core/AVR8/Device_AVR8.h
patch
|
blob
|
blame
|
history
LUFA/Drivers/USB/Core/DeviceStandardReq.c
patch
|
blob
|
blame
|
history
LUFA/Drivers/USB/Core/UC3/Device_UC3.h
patch
|
blob
|
blame
|
history
diff --git
a/LUFA/Drivers/USB/Core/AVR8/Device_AVR8.h
b/LUFA/Drivers/USB/Core/AVR8/Device_AVR8.h
index
dc86302
..
f822d0b
100644
(file)
--- a/
LUFA/Drivers/USB/Core/AVR8/Device_AVR8.h
+++ b/
LUFA/Drivers/USB/Core/AVR8/Device_AVR8.h
@@
-100,8
+100,15
@@
* number for the device.
*/
#define USE_INTERNAL_SERIAL 0xDC
* number for the device.
*/
#define USE_INTERNAL_SERIAL 0xDC
+
+ /** Length of the device's unique internal serial number, in bits, if present on the selected microcontroller
+ * model.
+ */
+ #define INTERNAL_SERIAL_LENGTH_BITS 80
#else
#define USE_INTERNAL_SERIAL NO_DESCRIPTOR
#else
#define USE_INTERNAL_SERIAL NO_DESCRIPTOR
+
+ #define INTERNAL_SERIAL_LENGTH_BITS 0
#endif
/* Function Prototypes: */
#endif
/* Function Prototypes: */
@@
-190,19
+197,14
@@
return (UDADDR & (1 << ADDEN));
}
return (UDADDR & (1 << ADDEN));
}
- static inline
uint8_t USB_Device_GetSerialString(uint16_t* UnicodeString, const uint8_t MaxLen
)
+ static inline
void USB_Device_GetSerialString(uint16_t* UnicodeString
)
{
{
- uint8_t SerialCharNum = 0;
-
ATOMIC_BLOCK(ATOMIC_RESTORESTATE)
{
uint8_t SigReadAddress = 0x0E;
ATOMIC_BLOCK(ATOMIC_RESTORESTATE)
{
uint8_t SigReadAddress = 0x0E;
- for (
SerialCharNum = 0; SerialCharNum < MIN(MaxLen, 20
); SerialCharNum++)
+ for (
uint8_t SerialCharNum = 0; SerialCharNum < (INTERNAL_SERIAL_LENGTH_BYTES * 2
); SerialCharNum++)
{
{
- if (SerialCharNum == MaxLen)
- break;
-
uint8_t SerialByte = boot_signature_byte_get(SigReadAddress);
if (SerialCharNum & 0x01)
uint8_t SerialByte = boot_signature_byte_get(SigReadAddress);
if (SerialCharNum & 0x01)
@@
-217,8
+219,6
@@
(('A' - 10) + SerialByte) : ('0' + SerialByte));
}
}
(('A' - 10) + SerialByte) : ('0' + SerialByte));
}
}
-
- return SerialCharNum;
}
#endif
}
#endif
diff --git
a/LUFA/Drivers/USB/Core/DeviceStandardReq.c
b/LUFA/Drivers/USB/Core/DeviceStandardReq.c
index
a2270f4
..
2ac6c0a
100644
(file)
--- a/
LUFA/Drivers/USB/Core/DeviceStandardReq.c
+++ b/
LUFA/Drivers/USB/Core/DeviceStandardReq.c
@@
-204,12
+204,13
@@
static void USB_Device_GetInternalSerialDescriptor(void)
struct
{
USB_Descriptor_Header_t Header;
struct
{
USB_Descriptor_Header_t Header;
- uint16_t UnicodeString[
20
];
+ uint16_t UnicodeString[
INTERNAL_SERIAL_LENGTH_BITS / 4
];
} SignatureDescriptor;
SignatureDescriptor.Header.Type = DTYPE_String;
} SignatureDescriptor;
SignatureDescriptor.Header.Type = DTYPE_String;
- SignatureDescriptor.Header.Size = USB_STRING_LEN(USB_Device_GetSerialString(SignatureDescriptor.UnicodeString,
- sizeof(SignatureDescriptor.UnicodeString) / sizeof(SignatureDescriptor.UnicodeString[0])));
+ SignatureDescriptor.Header.Size = USB_STRING_LEN(INTERNAL_SERIAL_LENGTH_BITS / 4);
+
+ USB_Device_GetSerialString(SignatureDescriptor.UnicodeString);
Endpoint_ClearSETUP();
Endpoint_ClearSETUP();
diff --git
a/LUFA/Drivers/USB/Core/UC3/Device_UC3.h
b/LUFA/Drivers/USB/Core/UC3/Device_UC3.h
index
59897a7
..
8389d62
100644
(file)
--- a/
LUFA/Drivers/USB/Core/UC3/Device_UC3.h
+++ b/
LUFA/Drivers/USB/Core/UC3/Device_UC3.h
@@
-90,9
+90,16
@@
* number for the device.
\r
*/
\r
#define USE_INTERNAL_SERIAL 0xDC
\r
* number for the device.
\r
*/
\r
#define USE_INTERNAL_SERIAL 0xDC
\r
+
\r
+ /** Length of the device's unique internal serial number, in bits, if present on the selected microcontroller
\r
+ * model.
\r
+ */
\r
+ #define INTERNAL_SERIAL_LENGTH_BITS 120
\r
#else
\r
#define USE_INTERNAL_SERIAL NO_DESCRIPTOR
\r
#else
\r
#define USE_INTERNAL_SERIAL NO_DESCRIPTOR
\r
- #endif
\r
+
\r
+ #define INTERNAL_SERIAL_LENGTH_BITS 0
\r
+ #endif
\r
\r
/* Function Prototypes: */
\r
/** Sends a Remote Wakeup request to the host. This signals to the host that the device should
\r
\r
/* Function Prototypes: */
\r
/** Sends a Remote Wakeup request to the host. This signals to the host that the device should
\r
@@
-178,19
+185,14
@@
return AVR32_USBB.UDCON.adden;
\r
}
\r
\r
return AVR32_USBB.UDCON.adden;
\r
}
\r
\r
- static inline
uint8_t USB_Device_GetSerialString(uint16_t* UnicodeString, const uint8_t MaxLen
)
\r
+ static inline
void USB_Device_GetSerialString(uint16_t* UnicodeString
)
\r
{
\r
{
\r
- uint8_t SerialCharNum = 0;
\r
-
\r
ATOMIC_BLOCK(ATOMIC_RESTORESTATE)
\r
{
\r
ATOMIC_BLOCK(ATOMIC_RESTORESTATE)
\r
{
\r
- uint
32_t* SigReadAddress =
0x80800204;
\r
+ uint
8_t* SigReadAddress = (uint8_t*)
0x80800204;
\r
\r
\r
- for (
SerialCharNum = 0; SerialCharNum < MIN(MaxLen, 30
); SerialCharNum++)
\r
+ for (
uint8_t SerialCharNum = 0; SerialCharNum < (INTERNAL_SERIAL_LENGTH_BITS / 4
); SerialCharNum++)
\r
{
\r
{
\r
- if (SerialCharNum == MaxLen)
\r
- break;
\r
-
\r
uint8_t SerialByte = *SigReadAddress;
\r
\r
if (SerialCharNum & 0x01)
\r
uint8_t SerialByte = *SigReadAddress;
\r
\r
if (SerialCharNum & 0x01)
\r
@@
-205,8
+207,6
@@
(('A' - 10) + SerialByte) : ('0' + SerialByte));
\r
}
\r
}
\r
(('A' - 10) + SerialByte) : ('0' + SerialByte));
\r
}
\r
}
\r
-
\r
- return SerialCharNum;
\r
}
\r
#endif
\r
\r
}
\r
#endif
\r
\r