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:
804e80a
)
Optimize Endpoint_Discard_Stream() and Endpoint_Null_Stream().
author
Dean Camera
<dean@fourwalledcubicle.com>
Sat, 8 Dec 2018 00:10:28 +0000
(11:10 +1100)
committer
Dean Camera
<dean@fourwalledcubicle.com>
Sat, 8 Dec 2018 00:10:28 +0000
(11:10 +1100)
LUFA/Drivers/USB/Core/AVR8/EndpointStream_AVR8.c
patch
|
blob
|
blame
|
history
LUFA/Drivers/USB/Core/UC3/EndpointStream_UC3.c
patch
|
blob
|
blame
|
history
LUFA/Drivers/USB/Core/XMEGA/EndpointStream_XMEGA.c
patch
|
blob
|
blame
|
history
diff --git
a/LUFA/Drivers/USB/Core/AVR8/EndpointStream_AVR8.c
b/LUFA/Drivers/USB/Core/AVR8/EndpointStream_AVR8.c
index
0364c60
..
bf6fee4
100644
(file)
--- a/
LUFA/Drivers/USB/Core/AVR8/EndpointStream_AVR8.c
+++ b/
LUFA/Drivers/USB/Core/AVR8/EndpointStream_AVR8.c
@@
-43,15
+43,12
@@
uint8_t Endpoint_Discard_Stream(uint16_t Length,
uint16_t* const BytesProcessed)
{
uint8_t ErrorCode;
uint16_t* const BytesProcessed)
{
uint8_t ErrorCode;
- uint16_t BytesInTransfer = 0;
+ uint16_t BytesInTransfer =
BytesProcessed ? *BytesProcessed :
0;
if ((ErrorCode = Endpoint_WaitUntilReady()))
return ErrorCode;
if ((ErrorCode = Endpoint_WaitUntilReady()))
return ErrorCode;
- if (BytesProcessed != NULL)
- Length -= *BytesProcessed;
-
- while (Length)
+ while (BytesInTransfer < Length)
{
if (!(Endpoint_IsReadWriteAllowed()))
{
{
if (!(Endpoint_IsReadWriteAllowed()))
{
@@
-59,7
+56,7
@@
uint8_t Endpoint_Discard_Stream(uint16_t Length,
if (BytesProcessed != NULL)
{
if (BytesProcessed != NULL)
{
- *BytesProcessed
+
= BytesInTransfer;
+ *BytesProcessed = BytesInTransfer;
return ENDPOINT_RWSTREAM_IncompleteTransfer;
}
return ENDPOINT_RWSTREAM_IncompleteTransfer;
}
@@
-69,8
+66,6
@@
uint8_t Endpoint_Discard_Stream(uint16_t Length,
else
{
Endpoint_Discard_8();
else
{
Endpoint_Discard_8();
-
- Length--;
BytesInTransfer++;
}
}
BytesInTransfer++;
}
}
@@
-82,15
+77,12
@@
uint8_t Endpoint_Null_Stream(uint16_t Length,
uint16_t* const BytesProcessed)
{
uint8_t ErrorCode;
uint16_t* const BytesProcessed)
{
uint8_t ErrorCode;
- uint16_t BytesInTransfer = 0;
+ uint16_t BytesInTransfer =
BytesProcessed ? *BytesProcessed :
0;
if ((ErrorCode = Endpoint_WaitUntilReady()))
return ErrorCode;
if ((ErrorCode = Endpoint_WaitUntilReady()))
return ErrorCode;
- if (BytesProcessed != NULL)
- Length -= *BytesProcessed;
-
- while (Length)
+ while (BytesInTransfer < Length)
{
if (!(Endpoint_IsReadWriteAllowed()))
{
{
if (!(Endpoint_IsReadWriteAllowed()))
{
@@
-98,7
+90,7
@@
uint8_t Endpoint_Null_Stream(uint16_t Length,
if (BytesProcessed != NULL)
{
if (BytesProcessed != NULL)
{
- *BytesProcessed
+
= BytesInTransfer;
+ *BytesProcessed = BytesInTransfer;
return ENDPOINT_RWSTREAM_IncompleteTransfer;
}
return ENDPOINT_RWSTREAM_IncompleteTransfer;
}
@@
-108,8
+100,6
@@
uint8_t Endpoint_Null_Stream(uint16_t Length,
else
{
Endpoint_Write_8(0);
else
{
Endpoint_Write_8(0);
-
- Length--;
BytesInTransfer++;
}
}
BytesInTransfer++;
}
}
diff --git
a/LUFA/Drivers/USB/Core/UC3/EndpointStream_UC3.c
b/LUFA/Drivers/USB/Core/UC3/EndpointStream_UC3.c
index
214edd7
..
5a6131f
100644
(file)
--- a/
LUFA/Drivers/USB/Core/UC3/EndpointStream_UC3.c
+++ b/
LUFA/Drivers/USB/Core/UC3/EndpointStream_UC3.c
@@
-43,15
+43,12
@@
uint8_t Endpoint_Discard_Stream(uint16_t Length,
uint16_t* const BytesProcessed)
{
uint8_t ErrorCode;
uint16_t* const BytesProcessed)
{
uint8_t ErrorCode;
- uint16_t BytesInTransfer = 0;
+ uint16_t BytesInTransfer =
BytesProcessed ? *BytesProcessed :
0;
if ((ErrorCode = Endpoint_WaitUntilReady()))
return ErrorCode;
if ((ErrorCode = Endpoint_WaitUntilReady()))
return ErrorCode;
- if (BytesProcessed != NULL)
- Length -= *BytesProcessed;
-
- while (Length)
+ while (BytesInTransfer < Length)
{
if (!(Endpoint_IsReadWriteAllowed()))
{
{
if (!(Endpoint_IsReadWriteAllowed()))
{
@@
-59,7
+56,7
@@
uint8_t Endpoint_Discard_Stream(uint16_t Length,
if (BytesProcessed != NULL)
{
if (BytesProcessed != NULL)
{
- *BytesProcessed
+
= BytesInTransfer;
+ *BytesProcessed = BytesInTransfer;
return ENDPOINT_RWSTREAM_IncompleteTransfer;
}
return ENDPOINT_RWSTREAM_IncompleteTransfer;
}
@@
-69,8
+66,6
@@
uint8_t Endpoint_Discard_Stream(uint16_t Length,
else
{
Endpoint_Discard_8();
else
{
Endpoint_Discard_8();
-
- Length--;
BytesInTransfer++;
}
}
BytesInTransfer++;
}
}
@@
-82,15
+77,12
@@
uint8_t Endpoint_Null_Stream(uint16_t Length,
uint16_t* const BytesProcessed)
{
uint8_t ErrorCode;
uint16_t* const BytesProcessed)
{
uint8_t ErrorCode;
- uint16_t BytesInTransfer = 0;
+ uint16_t BytesInTransfer =
BytesProcessed ? *BytesProcessed :
0;
if ((ErrorCode = Endpoint_WaitUntilReady()))
return ErrorCode;
if ((ErrorCode = Endpoint_WaitUntilReady()))
return ErrorCode;
- if (BytesProcessed != NULL)
- Length -= *BytesProcessed;
-
- while (Length)
+ while (BytesInTransfer < Length)
{
if (!(Endpoint_IsReadWriteAllowed()))
{
{
if (!(Endpoint_IsReadWriteAllowed()))
{
@@
-98,7
+90,7
@@
uint8_t Endpoint_Null_Stream(uint16_t Length,
if (BytesProcessed != NULL)
{
if (BytesProcessed != NULL)
{
- *BytesProcessed
+
= BytesInTransfer;
+ *BytesProcessed = BytesInTransfer;
return ENDPOINT_RWSTREAM_IncompleteTransfer;
}
return ENDPOINT_RWSTREAM_IncompleteTransfer;
}
@@
-108,8
+100,6
@@
uint8_t Endpoint_Null_Stream(uint16_t Length,
else
{
Endpoint_Write_8(0);
else
{
Endpoint_Write_8(0);
-
- Length--;
BytesInTransfer++;
}
}
BytesInTransfer++;
}
}
diff --git
a/LUFA/Drivers/USB/Core/XMEGA/EndpointStream_XMEGA.c
b/LUFA/Drivers/USB/Core/XMEGA/EndpointStream_XMEGA.c
index
a24f624
..
e8ee7e6
100644
(file)
--- a/
LUFA/Drivers/USB/Core/XMEGA/EndpointStream_XMEGA.c
+++ b/
LUFA/Drivers/USB/Core/XMEGA/EndpointStream_XMEGA.c
@@
-43,15
+43,12
@@
uint8_t Endpoint_Discard_Stream(uint16_t Length,
uint16_t* const BytesProcessed)
{
uint8_t ErrorCode;
uint16_t* const BytesProcessed)
{
uint8_t ErrorCode;
- uint16_t BytesInTransfer = 0;
+ uint16_t BytesInTransfer =
BytesProcessed ? *BytesProcessed :
0;
if ((ErrorCode = Endpoint_WaitUntilReady()))
return ErrorCode;
if ((ErrorCode = Endpoint_WaitUntilReady()))
return ErrorCode;
- if (BytesProcessed != NULL)
- Length -= *BytesProcessed;
-
- while (Length)
+ while (BytesInTransfer < Length)
{
if (!(Endpoint_IsReadWriteAllowed()))
{
{
if (!(Endpoint_IsReadWriteAllowed()))
{
@@
-59,7
+56,7
@@
uint8_t Endpoint_Discard_Stream(uint16_t Length,
if (BytesProcessed != NULL)
{
if (BytesProcessed != NULL)
{
- *BytesProcessed
+
= BytesInTransfer;
+ *BytesProcessed = BytesInTransfer;
return ENDPOINT_RWSTREAM_IncompleteTransfer;
}
return ENDPOINT_RWSTREAM_IncompleteTransfer;
}
@@
-69,8
+66,6
@@
uint8_t Endpoint_Discard_Stream(uint16_t Length,
else
{
Endpoint_Discard_8();
else
{
Endpoint_Discard_8();
-
- Length--;
BytesInTransfer++;
}
}
BytesInTransfer++;
}
}
@@
-82,15
+77,12
@@
uint8_t Endpoint_Null_Stream(uint16_t Length,
uint16_t* const BytesProcessed)
{
uint8_t ErrorCode;
uint16_t* const BytesProcessed)
{
uint8_t ErrorCode;
- uint16_t BytesInTransfer = 0;
+ uint16_t BytesInTransfer =
BytesProcessed ? *BytesProcessed :
0;
if ((ErrorCode = Endpoint_WaitUntilReady()))
return ErrorCode;
if ((ErrorCode = Endpoint_WaitUntilReady()))
return ErrorCode;
- if (BytesProcessed != NULL)
- Length -= *BytesProcessed;
-
- while (Length)
+ while (BytesInTransfer < Length)
{
if (!(Endpoint_IsReadWriteAllowed()))
{
{
if (!(Endpoint_IsReadWriteAllowed()))
{
@@
-98,7
+90,7
@@
uint8_t Endpoint_Null_Stream(uint16_t Length,
if (BytesProcessed != NULL)
{
if (BytesProcessed != NULL)
{
- *BytesProcessed
+
= BytesInTransfer;
+ *BytesProcessed = BytesInTransfer;
return ENDPOINT_RWSTREAM_IncompleteTransfer;
}
return ENDPOINT_RWSTREAM_IncompleteTransfer;
}
@@
-108,8
+100,6
@@
uint8_t Endpoint_Null_Stream(uint16_t Length,
else
{
Endpoint_Write_8(0);
else
{
Endpoint_Write_8(0);
-
- Length--;
BytesInTransfer++;
}
}
BytesInTransfer++;
}
}