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
52237c84
Commit
52237c84
authored
10 years ago
by
Cristian Maglie
Committed by
Cristian Maglie
10 years ago
Browse files
Options
Downloads
Patches
Plain Diff
CDC-ACM bugfix
parent
d6857ed1
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
cores/arduino/USB/CDC.cpp
+13
-12
13 additions, 12 deletions
cores/arduino/USB/CDC.cpp
cores/arduino/USB/USBCore.cpp
+11
-6
11 additions, 6 deletions
cores/arduino/USB/USBCore.cpp
cores/arduino/USB/samd21_device.c
+16
-15
16 additions, 15 deletions
cores/arduino/USB/samd21_device.c
with
40 additions
and
33 deletions
cores/arduino/USB/CDC.cpp
+
13
−
12
View file @
52237c84
...
...
@@ -160,25 +160,26 @@ void Serial_::end(void)
void
Serial_
::
accept
(
void
)
{
ring_buffer
*
buffer
=
&
cdc_rx_buffer
;
uint32_t
i
=
(
uint32_t
)(
buffer
->
head
+
1
)
%
CDC_SERIAL_BUFFER_SIZE
;
uint8_t
buffer
[
CDC_SERIAL_BUFFER_SIZE
];
uint32_t
len
=
USBD_Recv
(
CDC_ENDPOINT_OUT
,
(
void
*
)
&
buffer
,
CDC_SERIAL_BUFFER_SIZE
);
noInterrupts
();
ring_buffer
*
ringBuffer
=
&
cdc_rx_buffer
;
uint32_t
i
=
ringBuffer
->
head
;
// if we should be storing the received character into the location
// just before the tail (meaning that the head would advance to the
// current location of the tail), we're about to overflow the buffer
// and so we don't write the character or advance the head.
while
(
i
!=
buffer
->
tail
)
{
uint32_t
c
;
if
(
!
USBD_Available
(
CDC_ENDPOINT_OUT
))
{
UDD_ReleaseRX
(
CDC_ENDPOINT_OUT
);
break
;
}
c
=
USBD_Recv
(
CDC_ENDPOINT_OUT
);
buffer
->
buffer
[
buffer
->
head
]
=
c
;
buffer
->
head
=
i
;
uint32_t
k
=
0
;
i
=
(
i
+
1
)
%
CDC_SERIAL_BUFFER_SIZE
;
while
(
i
!=
ringBuffer
->
tail
&&
len
>
0
)
{
len
--
;
ringBuffer
->
buffer
[
ringBuffer
->
head
]
=
buffer
[
k
++
];
ringBuffer
->
head
=
i
;
i
=
(
i
+
1
)
%
CDC_SERIAL_BUFFER_SIZE
;
}
interrupts
();
}
int
Serial_
::
available
(
void
)
...
...
This diff is collapsed.
Click to expand it.
cores/arduino/USB/USBCore.cpp
+
11
−
6
View file @
52237c84
...
...
@@ -108,12 +108,17 @@ uint32_t USBD_Recv(uint32_t ep, void* d, uint32_t len)
if
(
!
_usbConfiguration
)
return
-
1
;
uint32_t
n
=
UDD_FifoByteCount
(
ep
);
len
=
min
(
n
,
len
);
n
=
len
;
uint8_t
*
dst
=
(
uint8_t
*
)
d
;
while
(
n
--
)
*
dst
++
=
UDD_Recv_data
(
ep
,
8
);
uint8_t
*
buffer
;
uint8_t
*
data
=
(
uint8_t
*
)
d
;
len
=
min
(
UDD_FifoByteCount
(
ep
),
len
);
UDD_Recv_data
(
ep
,
len
);
UDD_Recv
(
ep
,
&
buffer
);
for
(
uint32_t
i
=
0
;
i
<
len
;
i
++
)
{
data
[
i
]
=
buffer
[
i
];
}
if
(
len
&&
!
UDD_FifoByteCount
(
ep
))
// release empty buffer
UDD_ReleaseRX
(
ep
);
...
...
This diff is collapsed.
Click to expand it.
cores/arduino/USB/samd21_device.c
+
16
−
15
View file @
52237c84
...
...
@@ -266,22 +266,23 @@ uint32_t UDD_Send(uint32_t ep, const void* data, uint32_t len)
return
len
;
}
uint8_t
UDD_Recv_data
(
uint32_t
ep
,
uint32_t
len
)
{
TRACE_DEVICE
(
printf
(
"=> UDD_Recvdata : ep=%d
\r\n
"
,
(
char
)
ep
);)
usb_endpoint_table
[
ep
].
DeviceDescBank
[
0
].
ADDR
.
reg
=
(
uint32_t
)
&
udd_ep_out_cache_buffer
[
ep
];
usb_endpoint_table
[
ep
].
DeviceDescBank
[
0
].
PCKSIZE
.
bit
.
MULTI_PACKET_SIZE
=
len
;
usb_endpoint_table
[
ep
].
DeviceDescBank
[
0
].
PCKSIZE
.
bit
.
BYTE_COUNT
=
0
;
uint8_t
UDD_Recv_data
(
uint32_t
ep
,
uint32_t
len
)
{
TRACE_DEVICE
(
printf
(
"=> UDD_Recvdata : ep=%d
\r\n
"
,
(
char
)
ep
);)
if
(
len
>
64
)
len
=
64
;
usb_endpoint_table
[
ep
].
DeviceDescBank
[
0
].
ADDR
.
reg
=
(
uint32_t
)
&
udd_ep_out_cache_buffer
[
ep
];
usb_endpoint_table
[
ep
].
DeviceDescBank
[
0
].
PCKSIZE
.
bit
.
MULTI_PACKET_SIZE
=
len
;
usb_endpoint_table
[
ep
].
DeviceDescBank
[
0
].
PCKSIZE
.
bit
.
BYTE_COUNT
=
0
;
udd_OUT_transfer_allowed
(
ep
);
TRACE_DEVICE
(
printf
(
"=> UDD_Recv_data : data=%lu
\r\n
"
,
(
unsigned
long
)
data
);)
/* Wait for transfer to complete */
while
(
!
udd_is_OUT_transf_cplt
(
ep
));
/* Clear Transfer complete 0 flag */
udd_clear_OUT_transf_cplt
(
ep
);
return
udd_ep_out_cache_buffer
[
ep
][
0
];
TRACE_DEVICE
(
printf
(
"=> UDD_Recv_data : data=%lu
\r\n
"
,
(
unsigned
long
)
data
);)
/* Wait for transfer to complete */
while
(
!
udd_is_OUT_transf_cplt
(
ep
));
/* Clear Transfer complete 0 flag */
udd_clear_OUT_transf_cplt
(
ep
);
return
udd_ep_out_cache_buffer
[
ep
][
0
];
}
void
UDD_Recv
(
uint32_t
ep
,
uint8_t
**
ppData
)
...
...
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