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
230758b1
Unverified
Commit
230758b1
authored
Apr 28, 2022
by
Earle F. Philhower, III
Committed by
GitHub
Apr 28, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add invert option to SWSerial (#563)
Thanks to @StefanKellerAC !
parent
d7e02c6f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
3 deletions
+25
-3
cores/rp2040/SerialPIO.h
cores/rp2040/SerialPIO.h
+1
-1
cores/rp2040/SoftwareSerial.h
cores/rp2040/SoftwareSerial.h
+24
-2
No files found.
cores/rp2040/SerialPIO.h
View file @
230758b1
...
...
@@ -54,7 +54,7 @@ public:
// Not to be called by users, only from the IRQ handler. In public so that the C-language IQR callback can access it
void
_handleIRQ
();
pr
ivate
:
pr
otected
:
bool
_running
=
false
;
pin_size_t
_tx
,
_rx
;
int
_baud
;
...
...
cores/rp2040/SoftwareSerial.h
View file @
230758b1
...
...
@@ -26,12 +26,34 @@ class SoftwareSerial : public SerialPIO {
public:
// Note the rx/tx pins are swapped in PIO vs SWSerial
SoftwareSerial
(
pin_size_t
rx
,
pin_size_t
tx
,
bool
invert
=
false
)
:
SerialPIO
(
tx
,
rx
)
{
if
(
invert
)
{
panic
(
"SoftwareSerial inverted operation not supported
\n
"
);
_invert
=
invert
;
}
~
SoftwareSerial
()
{
if
(
_invert
)
{
gpio_set_outover
(
_tx
,
0
);
gpio_set_outover
(
_rx
,
0
);
}
}
virtual
void
begin
(
unsigned
long
baud
=
115200
)
override
{
begin
(
baud
,
SERIAL_8N1
);
};
void
begin
(
unsigned
long
baud
,
uint16_t
config
)
override
{
SerialPIO
::
begin
(
baud
,
config
);
if
(
_invert
)
{
gpio_set_outover
(
_tx
,
GPIO_OVERRIDE_INVERT
);
gpio_set_inover
(
_rx
,
GPIO_OVERRIDE_INVERT
);
}
}
void
listen
()
{
/* noop */
}
bool
isListening
()
{
return
true
;
}
private:
bool
_invert
;
};
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