diff options
Diffstat (limited to 'src/log.rs')
-rw-r--r-- | src/log.rs | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/log.rs b/src/log.rs new file mode 100644 index 0000000..07525cc --- /dev/null +++ b/src/log.rs @@ -0,0 +1,16 @@ +use core::fmt::Write; + +use gd32vf103xx_hal::{ + pac::USART1, + serial::Tx, +}; + +static mut TX: Option<Tx<USART1>> = None; + +pub unsafe fn new(tx: Tx<USART1>) { + TX = Some(tx); +} + +pub unsafe fn log(str: &str) { + TX.as_mut().map(|tx| tx.write_str(str)); +} |