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
b2ddb226
Commit
b2ddb226
authored
8 years ago
by
Cristian Maglie
Browse files
Options
Downloads
Patches
Plain Diff
USB: Added interface to possibly setup dynamic USB EP Handler
parent
34bf5421
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
cores/arduino/USB/USBCore.cpp
+22
-2
22 additions, 2 deletions
cores/arduino/USB/USBCore.cpp
with
22 additions
and
2 deletions
cores/arduino/USB/USBCore.cpp
+
22
−
2
View file @
b2ddb226
...
...
@@ -46,6 +46,12 @@ extern "C" void UDD_Handler(void) {
USBDevice
.
ISRHandler
();
}
class
EPHandler
{
public:
virtual
void
handleEndpoint
()
=
0
;
virtual
uint32_t
recv
(
void
*
_data
,
uint32_t
len
)
=
0
;
virtual
uint32_t
available
()
const
=
0
;
};
const
uint16_t
STRING_LANGUAGE
[
2
]
=
{
...
...
@@ -88,6 +94,8 @@ uint8_t udd_ep_out_cache_buffer[7][64];
static
__attribute__
((
__aligned__
(
4
)))
//__attribute__((__section__(".bss_hram0")))
uint8_t
udd_ep_in_cache_buffer
[
7
][
64
];
static
EPHandler
*
epHandlers
[
7
];
//==================================================================
// Send a USB descriptor string. The string is stored as a
...
...
@@ -532,7 +540,11 @@ uint32_t USBDeviceClass::recvControl(void *_data, uint32_t len)
// Number of bytes, assumes a rx endpoint
uint32_t
USBDeviceClass
::
available
(
uint32_t
ep
)
{
return
usbd
.
epBank0ByteCount
(
ep
);
if
(
epHandlers
[
ep
])
{
return
epHandlers
[
ep
]
->
available
();
}
else
{
return
usbd
.
epBank0ByteCount
(
ep
);
}
}
// Non Blocking receive
...
...
@@ -542,6 +554,10 @@ uint32_t USBDeviceClass::recv(uint32_t ep, void *_data, uint32_t len)
if
(
!
_usbConfiguration
)
return
-
1
;
if
(
epHandlers
[
ep
])
{
return
epHandlers
[
ep
]
->
recv
(
_data
,
len
);
}
if
(
available
(
ep
)
<
len
)
len
=
available
(
ep
);
...
...
@@ -891,7 +907,11 @@ void USBDeviceClass::ISRHandler()
if
(
usbd
.
epBank0IsTransferComplete
(
i
)
||
usbd
.
epBank1IsTransferComplete
(
i
))
{
handleEndpoint
(
i
);
if
(
epHandlers
[
i
])
{
epHandlers
[
i
]
->
handleEndpoint
();
}
else
{
handleEndpoint
(
i
);
}
}
ept_int
&=
~
(
1
<<
i
);
}
...
...
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