Skip to content

Commit b7559e3

Browse files
committed
Feature: Added non-blocking serial break/unbreak functions
Current serial implementation has a send_break() command which sends a break command on the UART for a fixed amount of time. Added functions to allow users to send a break in a non-blocking fashion, as well as for a user-specified amount of time.
1 parent 96191e2 commit b7559e3

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

drivers/SerialBase.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,20 @@ int SerialBase::_base_putc(int c)
118118
return c;
119119
}
120120

121+
void SerialBase::set_break()
122+
{
123+
lock();
124+
serial_break_set(&_serial);
125+
unlock();
126+
}
127+
128+
void SerialBase::clear_break()
129+
{
130+
lock();
131+
serial_break_clear(&_serial);
132+
unlock();
133+
}
134+
121135
void SerialBase::send_break()
122136
{
123137
lock();

drivers/SerialBase.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,16 @@ class SerialBase : private NonCopyable<SerialBase> {
137137
attach(callback(obj, method), type);
138138
}
139139

140+
/** Generate a break condition on the serial line
141+
* NOTE: Clear break needs to run at least one frame after set_break is called
142+
*/
143+
void set_break();
144+
145+
/** Clear a break condition on the serial line
146+
* NOTE: Should be run at least one frame after set_break is called
147+
*/
148+
void clear_break();
149+
140150
/** Generate a break condition on the serial line
141151
*/
142152
void send_break();

0 commit comments

Comments
 (0)