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
ba02d346
Commit
ba02d346
authored
9 years ago
by
Sandeep Mistry
Browse files
Options
Downloads
Patches
Plain Diff
Add USB transfer RX/TX LED blinking
Only enabled if PIN_LED_TXL or PIN_LED_RXL is defined
parent
dd6890a3
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
cores/arduino/USB/USBCore.cpp
+41
-0
41 additions, 0 deletions
cores/arduino/USB/USBCore.cpp
with
41 additions
and
0 deletions
cores/arduino/USB/USBCore.cpp
+
41
−
0
View file @
ba02d346
...
@@ -28,6 +28,14 @@
...
@@ -28,6 +28,14 @@
USBDevice_SAMD21G18x
usbd
;
USBDevice_SAMD21G18x
usbd
;
/** Pulse generation counters to keep track of the number of milliseconds remaining for each pulse type */
#define TX_RX_LED_PULSE_MS 100
#ifdef PIN_LED_TXL
static
volatile
uint8_t
txLEDPulse
;
/**< Milliseconds remaining for data Tx LED pulse */
#endif
#ifdef PIN_LED_RXL
static
volatile
uint8_t
rxLEDPulse
;
/**< Milliseconds remaining for data Rx LED pulse */
#endif
static
char
isRemoteWakeUpEnabled
=
0
;
static
char
isRemoteWakeUpEnabled
=
0
;
static
char
isEndpointHalt
=
0
;
static
char
isEndpointHalt
=
0
;
...
@@ -273,6 +281,18 @@ void USBDeviceClass::handleEndpoint(uint8_t ep)
...
@@ -273,6 +281,18 @@ void USBDeviceClass::handleEndpoint(uint8_t ep)
void
USBDeviceClass
::
init
()
void
USBDeviceClass
::
init
()
{
{
#ifdef PIN_LED_TXL
txLEDPulse
=
0
;
pinMode
(
PIN_LED_TXL
,
OUTPUT
);
digitalWrite
(
PIN_LED_TXL
,
HIGH
);
#endif
#ifdef PIN_LED_RXL
rxLEDPulse
=
0
;
pinMode
(
PIN_LED_RXL
,
OUTPUT
);
digitalWrite
(
PIN_LED_RXL
,
HIGH
);
#endif
// Enable USB clock
// Enable USB clock
PM
->
APBBMASK
.
reg
|=
PM_APBBMASK_USB
;
PM
->
APBBMASK
.
reg
|=
PM_APBBMASK_USB
;
...
@@ -522,6 +542,11 @@ uint32_t USBDeviceClass::recv(uint32_t ep, void *_data, uint32_t len)
...
@@ -522,6 +542,11 @@ uint32_t USBDeviceClass::recv(uint32_t ep, void *_data, uint32_t len)
if
(
available
(
ep
)
<
len
)
if
(
available
(
ep
)
<
len
)
len
=
available
(
ep
);
len
=
available
(
ep
);
#ifdef PIN_LED_RXL
digitalWrite
(
PIN_LED_RXL
,
LOW
);
rxLEDPulse
=
TX_RX_LED_PULSE_MS
;
#endif
armRecv
(
ep
);
armRecv
(
ep
);
usbd
.
epBank0DisableTransferComplete
(
ep
);
usbd
.
epBank0DisableTransferComplete
(
ep
);
...
@@ -620,6 +645,11 @@ uint32_t USBDeviceClass::send(uint32_t ep, const void *data, uint32_t len)
...
@@ -620,6 +645,11 @@ uint32_t USBDeviceClass::send(uint32_t ep, const void *data, uint32_t len)
}
}
#endif
#endif
#ifdef PIN_LED_TXL
digitalWrite
(
PIN_LED_TXL
,
LOW
);
txLEDPulse
=
TX_RX_LED_PULSE_MS
;
#endif
// Flash area
// Flash area
while
(
len
!=
0
)
while
(
len
!=
0
)
{
{
...
@@ -826,6 +856,17 @@ void USBDeviceClass::ISRHandler()
...
@@ -826,6 +856,17 @@ void USBDeviceClass::ISRHandler()
if
(
usbd
.
isStartOfFrameInterrupt
())
if
(
usbd
.
isStartOfFrameInterrupt
())
{
{
usbd
.
ackStartOfFrameInterrupt
();
usbd
.
ackStartOfFrameInterrupt
();
// check whether the one-shot period has elapsed. if so, turn off the LED
#ifdef PIN_LED_TXL
if
(
txLEDPulse
&&
!
(
--
txLEDPulse
))
digitalWrite
(
PIN_LED_TXL
,
HIGH
);
#endif
#ifdef PIN_LED_RXL
if
(
rxLEDPulse
&&
!
(
--
rxLEDPulse
))
digitalWrite
(
PIN_LED_RXL
,
HIGH
);
#endif
}
}
// Endpoint 0 Received Setup interrupt
// Endpoint 0 Received Setup interrupt
...
...
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