Move RTT init to constructor

This commit is contained in:
Berkus Decker 2019-03-03 10:49:29 +02:00
parent 837268a712
commit 2e4bc42cd5
1 changed files with 3 additions and 1 deletions

View File

@ -236,6 +236,9 @@ impl NonBlockingOutput {
/// Create a non-blocking output stream /// Create a non-blocking output stream
#[inline] #[inline]
pub fn new() -> Self { pub fn new() -> Self {
unsafe {
_SEGGER_RTT.init();
}
Self { blocked: false } Self { blocked: false }
} }
} }
@ -244,7 +247,6 @@ impl fmt::Write for NonBlockingOutput {
fn write_str(&mut self, s: &str) -> fmt::Result { fn write_str(&mut self, s: &str) -> fmt::Result {
if !self.blocked { if !self.blocked {
unsafe { unsafe {
_SEGGER_RTT.init();
if !_SEGGER_RTT.up.write(s.as_bytes(), false) { if !_SEGGER_RTT.up.write(s.as_bytes(), false) {
self.blocked = true; self.blocked = true;
} }