Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
ArduinoCore-avr
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
xpstem
ArduinoCore-avr
Commits
3b076597
Commit
3b076597
authored
Jan 04, 2017
by
Cristian Maglie
Committed by
Cristian Maglie
Mar 16, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[AVR] USB send ZLP when needed
See #5732 #4864 #4138 #3946
parent
f27e8fe1
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
4 deletions
+18
-4
cores/arduino/USBCore.cpp
cores/arduino/USBCore.cpp
+18
-4
No files found.
cores/arduino/USBCore.cpp
View file @
3b076597
...
@@ -273,7 +273,9 @@ int USB_Send(u8 ep, const void* d, int len)
...
@@ -273,7 +273,9 @@ int USB_Send(u8 ep, const void* d, int len)
int
r
=
len
;
int
r
=
len
;
const
u8
*
data
=
(
const
u8
*
)
d
;
const
u8
*
data
=
(
const
u8
*
)
d
;
u8
timeout
=
250
;
// 250ms timeout on send? TODO
u8
timeout
=
250
;
// 250ms timeout on send? TODO
while
(
len
)
bool
sendZlp
=
false
;
while
(
len
||
sendZlp
)
{
{
u8
n
=
USB_SendSpace
(
ep
);
u8
n
=
USB_SendSpace
(
ep
);
if
(
n
==
0
)
if
(
n
==
0
)
...
@@ -284,13 +286,16 @@ int USB_Send(u8 ep, const void* d, int len)
...
@@ -284,13 +286,16 @@ int USB_Send(u8 ep, const void* d, int len)
continue
;
continue
;
}
}
if
(
n
>
len
)
if
(
n
>
len
)
{
n
=
len
;
n
=
len
;
}
{
{
LockEP
lock
(
ep
);
LockEP
lock
(
ep
);
// Frame may have been released by the SOF interrupt handler
// Frame may have been released by the SOF interrupt handler
if
(
!
ReadWriteAllowed
())
if
(
!
ReadWriteAllowed
())
continue
;
continue
;
len
-=
n
;
len
-=
n
;
if
(
ep
&
TRANSFER_ZERO
)
if
(
ep
&
TRANSFER_ZERO
)
{
{
...
@@ -307,8 +312,17 @@ int USB_Send(u8 ep, const void* d, int len)
...
@@ -307,8 +312,17 @@ int USB_Send(u8 ep, const void* d, int len)
while
(
n
--
)
while
(
n
--
)
Send8
(
*
data
++
);
Send8
(
*
data
++
);
}
}
if
(
!
ReadWriteAllowed
()
||
((
len
==
0
)
&&
(
ep
&
TRANSFER_RELEASE
)))
// Release full buffer
if
(
sendZlp
)
{
ReleaseTX
();
sendZlp
=
false
;
}
else
if
(
!
ReadWriteAllowed
())
{
// ...release if buffer is full...
ReleaseTX
();
ReleaseTX
();
if
(
len
==
0
)
sendZlp
=
true
;
}
else
if
((
len
==
0
)
&&
(
ep
&
TRANSFER_RELEASE
))
{
// ...or if forced with TRANSFER_RELEASE
// XXX: TRANSFER_RELEASE is never used can be removed?
ReleaseTX
();
}
}
}
}
}
TXLED1
;
// light the TX LED
TXLED1
;
// light the TX LED
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment