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
a7c33fea
Commit
a7c33fea
authored
7 years ago
by
Sandeep Mistry
Committed by
Sandeep Mistry
7 years ago
Browse files
Options
Downloads
Patches
Plain Diff
UART: manually handle IRQ if DRE + interrupts disabled or in higher priority ISR
When write is called and TX buffer is full.
parent
ee913a08
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/SERCOM.cpp
+1
-1
1 addition, 1 deletion
cores/arduino/SERCOM.cpp
cores/arduino/SERCOM.h
+2
-1
2 additions, 1 deletion
cores/arduino/SERCOM.h
cores/arduino/Uart.cpp
+21
-1
21 additions, 1 deletion
cores/arduino/Uart.cpp
with
24 additions
and
3 deletions
cores/arduino/SERCOM.cpp
+
1
−
1
View file @
a7c33fea
...
...
@@ -688,7 +688,7 @@ void SERCOM::initClockNVIC( void )
// Setting NVIC
NVIC_EnableIRQ
(
IdNvic
);
NVIC_SetPriority
(
IdNvic
,
(
1
<<
_
_NVIC_PRIO
_BITS
)
-
1
);
/* set Priority */
NVIC_SetPriority
(
IdNvic
,
SERCOM
_NVIC_PRIO
RITY
);
/* set Priority */
//Setting clock
GCLK
->
CLKCTRL
.
reg
=
GCLK_CLKCTRL_ID
(
clockId
)
|
// Generic Clock 0 (SERCOMx)
...
...
This diff is collapsed.
Click to expand it.
cores/arduino/SERCOM.h
+
2
−
1
View file @
a7c33fea
...
...
@@ -21,7 +21,8 @@
#include
"sam.h"
#define SERCOM_FREQ_REF 48000000
#define SERCOM_FREQ_REF 48000000
#define SERCOM_NVIC_PRIORITY ((1<<__NVIC_PRIO_BITS) - 1)
typedef
enum
{
...
...
This diff is collapsed.
Click to expand it.
cores/arduino/Uart.cpp
+
21
−
1
View file @
a7c33fea
...
...
@@ -154,7 +154,27 @@ size_t Uart::write(const uint8_t data)
if
(
sercom
->
isDataRegisterEmptyUART
()
&&
txBuffer
.
available
()
==
0
)
{
sercom
->
writeDataUART
(
data
);
}
else
{
while
(
txBuffer
.
isFull
());
// spin lock until a spot opens up in the buffer
// spin lock until a spot opens up in the buffer
while
(
txBuffer
.
isFull
())
{
uint8_t
interruptsEnabled
=
((
__get_PRIMASK
()
&
0x1
)
==
0
);
if
(
interruptsEnabled
)
{
uint32_t
exceptionNumber
=
(
SCB
->
ICSR
&
SCB_ICSR_VECTACTIVE_Msk
);
if
(
exceptionNumber
==
0
||
NVIC_GetPriority
((
IRQn_Type
)(
exceptionNumber
-
16
))
>
SERCOM_NVIC_PRIORITY
)
{
// no exception or called from an ISR with lower priority,
// wait for free buffer spot via IRQ
continue
;
}
}
// interrupts are disabled or called from ISR with higher or equal priority than the SERCOM IRQ
// manually call the UART IRQ handler when the data register is empty
if
(
sercom
->
isDataRegisterEmptyUART
())
{
IrqHandler
();
}
}
txBuffer
.
store_char
(
data
);
...
...
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