aboutsummaryrefslogtreecommitdiffstats
path: root/LUFA/Drivers/USB/Core/XMEGA/EndpointStream_XMEGA.c
diff options
context:
space:
mode:
authorDrashna Jaelre <drashna@live.com>2019-07-03 07:54:39 -0700
committerDrashna Jaelre <drashna@live.com>2019-07-03 07:54:49 -0700
commit110622eaa2787cc54818083d4243653b088e5b5a (patch)
treeb1637e4dc8d8aa13e9face4998cf25ae620361e5 /LUFA/Drivers/USB/Core/XMEGA/EndpointStream_XMEGA.c
parentd0fd80affba97b37eb00c650e87cb5982a4f260e (diff)
parent5ba628d10b54d58d445896290ba9799bd76a73b3 (diff)
downloadlufa-110622eaa2787cc54818083d4243653b088e5b5a.tar.gz
lufa-110622eaa2787cc54818083d4243653b088e5b5a.tar.bz2
lufa-110622eaa2787cc54818083d4243653b088e5b5a.zip
Merge remote-tracking branch 'abcminiuser/master'
Diffstat (limited to 'LUFA/Drivers/USB/Core/XMEGA/EndpointStream_XMEGA.c')
-rw-r--r--LUFA/Drivers/USB/Core/XMEGA/EndpointStream_XMEGA.c26
1 files changed, 8 insertions, 18 deletions
diff --git a/LUFA/Drivers/USB/Core/XMEGA/EndpointStream_XMEGA.c b/LUFA/Drivers/USB/Core/XMEGA/EndpointStream_XMEGA.c
index 641328170..f5e8f4179 100644
--- a/LUFA/Drivers/USB/Core/XMEGA/EndpointStream_XMEGA.c
+++ b/LUFA/Drivers/USB/Core/XMEGA/EndpointStream_XMEGA.c
@@ -1,13 +1,13 @@
/*
LUFA Library
- Copyright (C) Dean Camera, 2017.
+ Copyright (C) Dean Camera, 2019.
dean [at] fourwalledcubicle [dot] com
www.lufa-lib.org
*/
/*
- Copyright 2017 Dean Camera (dean [at] fourwalledcubicle [dot] com)
+ Copyright 2019 Dean Camera (dean [at] fourwalledcubicle [dot] com)
Permission to use, copy, modify, distribute, and sell this
software and its documentation for any purpose is hereby granted
@@ -43,15 +43,12 @@ uint8_t Endpoint_Discard_Stream(uint16_t Length,
uint16_t* const BytesProcessed)
{
uint8_t ErrorCode;
- uint16_t BytesInTransfer = 0;
+ uint16_t BytesInTransfer = BytesProcessed ? *BytesProcessed : 0;
if ((ErrorCode = Endpoint_WaitUntilReady()))
return ErrorCode;
- if (BytesProcessed != NULL)
- Length -= *BytesProcessed;
-
- while (Length)
+ while (BytesInTransfer < Length)
{
if (!(Endpoint_IsReadWriteAllowed()))
{
@@ -59,7 +56,7 @@ uint8_t Endpoint_Discard_Stream(uint16_t Length,
if (BytesProcessed != NULL)
{
- *BytesProcessed += BytesInTransfer;
+ *BytesProcessed = BytesInTransfer;
return ENDPOINT_RWSTREAM_IncompleteTransfer;
}
@@ -69,8 +66,6 @@ uint8_t Endpoint_Discard_Stream(uint16_t Length,
else
{
Endpoint_Discard_8();
-
- Length--;
BytesInTransfer++;
}
}
@@ -82,15 +77,12 @@ uint8_t Endpoint_Null_Stream(uint16_t Length,
uint16_t* const BytesProcessed)
{
uint8_t ErrorCode;
- uint16_t BytesInTransfer = 0;
+ uint16_t BytesInTransfer = BytesProcessed ? *BytesProcessed : 0;
if ((ErrorCode = Endpoint_WaitUntilReady()))
return ErrorCode;
- if (BytesProcessed != NULL)
- Length -= *BytesProcessed;
-
- while (Length)
+ while (BytesInTransfer < Length)
{
if (!(Endpoint_IsReadWriteAllowed()))
{
@@ -98,7 +90,7 @@ uint8_t Endpoint_Null_Stream(uint16_t Length,
if (BytesProcessed != NULL)
{
- *BytesProcessed += BytesInTransfer;
+ *BytesProcessed = BytesInTransfer;
return ENDPOINT_RWSTREAM_IncompleteTransfer;
}
@@ -108,8 +100,6 @@ uint8_t Endpoint_Null_Stream(uint16_t Length,
else
{
Endpoint_Write_8(0);
-
- Length--;
BytesInTransfer++;
}
}