blob: 0bbd09f5e036ce4f4361ae2641840204eb1b804d (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
//! IMPLEMENTATION DETAILS USED BY MACROS
use core::fmt::{self, Write};
use cortex_m::interrupt;
use crate::hio::{self, HostStream};
static mut HSTDOUT: Option<HostStream> = None;
pub fn hstdout_str(s: &str) {
let _result = interrupt::free(|_| unsafe {
if HSTDOUT.is_none() {
HSTDOUT = Some(hio::hstdout()?);
}
HSTDOUT.as_mut().unwrap().write_str(s).map_err(drop)
});
}
pub fn hstdout_fmt(args: fmt::Arguments) {
let _result = interrupt::free(|_| unsafe {
if HSTDOUT.is_none() {
HSTDOUT = Some(hio::hstdout()?);
}
HSTDOUT.as_mut().unwrap().write_fmt(args).map_err(drop)
});
}
static mut HSTDERR: Option<HostStream> = None;
pub fn hstderr_str(s: &str) {
let _result = interrupt::free(|_| unsafe {
if HSTDERR.is_none() {
HSTDERR = Some(hio::hstderr()?);
}
HSTDERR.as_mut().unwrap().write_str(s).map_err(drop)
});
}
pub fn hstderr_fmt(args: fmt::Arguments) {
let _result = interrupt::free(|_| unsafe {
if HSTDERR.is_none() {
HSTDERR = Some(hio::hstderr()?);
}
HSTDERR.as_mut().unwrap().write_fmt(args).map_err(drop)
});
}
|