Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
arduino-pico
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
xpstem
arduino-pico
Commits
3ee031ab
Unverified
Commit
3ee031ab
authored
Apr 24, 2022
by
Earle F. Philhower, III
Committed by
GitHub
Apr 24, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add ::overflow() return to SerialUART/SerialPIO (#547)
Matching the Arduino SoftwareSerial API
parent
d1f9bce0
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
29 additions
and
2 deletions
+29
-2
cores/rp2040/SerialPIO.cpp
cores/rp2040/SerialPIO.cpp
+13
-1
cores/rp2040/SerialPIO.h
cores/rp2040/SerialPIO.h
+2
-0
cores/rp2040/SerialUART.cpp
cores/rp2040/SerialUART.cpp
+12
-1
cores/rp2040/SerialUART.h
cores/rp2040/SerialUART.h
+2
-0
No files found.
cores/rp2040/SerialPIO.cpp
View file @
3ee031ab
...
...
@@ -127,7 +127,7 @@ void __not_in_flash_func(SerialPIO::_handleIRQ)() {
asm
volatile
(
""
:::
"memory"
);
// Ensure the queue is written before the written count advances
_writer
=
next_writer
;
}
else
{
// TODO: Overflow
_overflow
=
true
;
}
}
}
...
...
@@ -146,6 +146,7 @@ SerialPIO::~SerialPIO() {
}
void
SerialPIO
::
begin
(
unsigned
long
baud
,
uint16_t
config
)
{
_overflow
=
false
;
_baud
=
baud
;
switch
(
config
&
SERIAL_PARITY_MASK
)
{
case
SERIAL_PARITY_EVEN
:
...
...
@@ -289,6 +290,17 @@ int SerialPIO::read() {
return
-
1
;
}
bool
SerialPIO
::
overflow
()
{
CoreMutex
m
(
&
_mutex
);
if
(
!
_running
||
!
m
||
(
_rx
==
NOPIN
))
{
return
false
;
}
bool
hold
=
_overflow
;
_overflow
=
false
;
return
hold
;
}
int
SerialPIO
::
available
()
{
CoreMutex
m
(
&
_mutex
);
if
(
!
_running
||
!
m
||
(
_rx
==
NOPIN
))
{
...
...
cores/rp2040/SerialPIO.h
View file @
3ee031ab
...
...
@@ -47,6 +47,7 @@ public:
virtual
int
availableForWrite
()
override
;
virtual
void
flush
()
override
;
virtual
size_t
write
(
uint8_t
c
)
override
;
bool
overflow
();
using
Print
::
write
;
operator
bool
()
override
;
...
...
@@ -60,6 +61,7 @@ private:
int
_bits
;
uart_parity_t
_parity
;
int
_stop
;
bool
_overflow
;
mutex_t
_mutex
;
PIOProgram
*
_txPgm
;
...
...
cores/rp2040/SerialUART.cpp
View file @
3ee031ab
...
...
@@ -131,6 +131,7 @@ void SerialUART::begin(unsigned long baud, uint16_t config) {
if
(
_running
)
{
end
();
}
_overflow
=
false
;
_queue
=
new
uint8_t
[
_fifoSize
];
_baud
=
baud
;
uart_init
(
_uart
,
baud
);
...
...
@@ -271,6 +272,16 @@ int SerialUART::read() {
return
-
1
;
}
bool
SerialUART
::
overflow
()
{
CoreMutex
m
(
&
_mutex
);
if
(
!
_running
||
!
m
)
{
return
false
;
}
bool
hold
=
_overflow
;
_overflow
=
false
;
return
hold
;
}
int
SerialUART
::
available
()
{
CoreMutex
m
(
&
_mutex
);
if
(
!
_running
||
!
m
)
{
...
...
@@ -387,7 +398,7 @@ void __not_in_flash_func(SerialUART::_handleIRQ)(bool inIRQ) {
// Avoid using division or mod because the HW divider could be in use
_writer
=
next_writer
;
}
else
{
// TODO: Overflow
_overflow
=
true
;
}
}
if
(
inIRQ
)
{
...
...
cores/rp2040/SerialUART.h
View file @
3ee031ab
...
...
@@ -60,6 +60,7 @@ public:
virtual
size_t
write
(
uint8_t
c
)
override
;
virtual
size_t
write
(
const
uint8_t
*
p
,
size_t
len
)
override
;
using
Print
::
write
;
bool
overflow
();
operator
bool
()
override
;
// Not to be called by users, only from the IRQ handler. In public so that the C-language IQR callback can access it
...
...
@@ -73,6 +74,7 @@ private:
int
_baud
;
mutex_t
_mutex
;
bool
_polling
=
false
;
bool
_overflow
;
// Lockless, IRQ-handled circular queue
uint32_t
_writer
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment