Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
Arduino Core for SAMD21 CPU
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
josc941e
Arduino Core for SAMD21 CPU
Commits
ffd05f25
Commit
ffd05f25
authored
9 years ago
by
Jean-Christophe BUDA
Committed by
Cristian Maglie
9 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Fix to USBDevice blocking-send
parent
9d0d5d61
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
cores/arduino/USB/CDC.cpp
+2
-2
2 additions, 2 deletions
cores/arduino/USB/CDC.cpp
cores/arduino/USB/USBCore.cpp
+49
-12
49 additions, 12 deletions
cores/arduino/USB/USBCore.cpp
with
51 additions
and
14 deletions
cores/arduino/USB/CDC.cpp
+
2
−
2
View file @
ffd05f25
...
...
@@ -242,11 +242,11 @@ size_t Serial_::write(const uint8_t *buffer, size_t size)
// TODO - ZE - check behavior on different OSes and test what happens if an
// open connection isn't broken cleanly (cable is yanked out, host dies
// or locks up, or host virtual serial port hangs)
//
if (_usbLineInfo.lineState > 0) // Problem with Windows(R)
if
(
_usbLineInfo
.
lineState
>
0
)
// Problem with Windows(R)
{
uint32_t
r
=
usb
.
send
(
CDC_ENDPOINT_IN
,
buffer
,
size
);
if
(
r
>
0
)
{
if
(
r
==
0
)
{
return
r
;
}
else
{
setWriteError
();
...
...
This diff is collapsed.
Click to expand it.
cores/arduino/USB/USBCore.cpp
+
49
−
12
View file @
ffd05f25
...
...
@@ -579,27 +579,64 @@ uint8_t USBDeviceClass::armRecv(uint32_t ep, uint32_t len)
// Blocking Send of data to an endpoint
uint32_t
USBDeviceClass
::
send
(
uint32_t
ep
,
const
void
*
data
,
uint32_t
len
)
{
uint32_t
length
=
0
;
if
(
!
_usbConfiguration
)
return
-
1
;
if
(
len
>
16384
)
return
-
1
;
//armSend(ep, data, len);
if
((
unsigned
int
)
data
>
0x20000000
)
{
// Buffer in RAM
usbd
.
epBank1SetAddress
(
ep
,
(
void
*
)
data
);
usbd
.
epBank1SetMultiPacketSize
(
ep
,
0
);
/* memcopy could be safer in multithreaded environment */
memcpy
(
&
udd_ep_in_cache_buffer
[
ep
],
data
,
len
);
usbd
.
epBank1SetByteCount
(
ep
,
len
);
usbd
.
epBank1SetAddress
(
ep
,
&
udd_ep_in_cache_buffer
[
ep
]);
usbd
.
epBank1
SetByteCount
(
ep
,
len
);
// Clear the transfer complete flag
usbd
.
epBank1
AckTransferComplete
(
ep
);
//
Clear the transfer complete flag
usbd
.
epBank1
AckTransferComplete
(
ep
);
//
RAM buffer is full, we can send data (IN)
usbd
.
epBank1
SetReady
(
ep
);
// RAM buffer is full, we can send data (IN)
usbd
.
epBank1SetReady
(
ep
);
// Wait for transfer to complete
while
(
!
usbd
.
epBank1IsTransferComplete
(
ep
))
{
;
// need fire exit.
}
len
=
0
;
}
else
{
// Flash area
while
(
len
!=
0
)
{
if
(
len
>=
64
)
{
length
=
64
;
}
else
{
length
=
len
;
}
// Wait for transfer to complete
while
(
!
usbd
.
epBank1IsTransferComplete
(
ep
))
{
;
// need fire exit.
/* memcopy could be safer in multi threaded environment */
memcpy
(
&
udd_ep_in_cache_buffer
[
ep
],
data
,
length
);
usbd
.
epBank1SetAddress
(
ep
,
&
udd_ep_in_cache_buffer
[
ep
]);
usbd
.
epBank1SetByteCount
(
ep
,
length
);
// Clear the transfer complete flag
usbd
.
epBank1AckTransferComplete
(
ep
);
// RAM buffer is full, we can send data (IN)
usbd
.
epBank1SetReady
(
ep
);
// Wait for transfer to complete
while
(
!
usbd
.
epBank1IsTransferComplete
(
ep
))
{
;
// need fire exit.
}
len
-=
length
;
}
}
return
len
;
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment