// Copyright 2022 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

//! Unsafe synchronous dump-string-to-uart impl and macro for debugging.

use core::fmt;
use core2::io::{Cursor, Write};

// Convenience wrapper since capsules can't use unsafe{}
pub fn send_sync(buf: &[u8], len: usize) {
    unsafe {
        crate::uart_hal::UART0.transmit_sync(&buf[..len]);
    }
}

pub fn vdprintf(args: fmt::Arguments) {
    let mut uart_buf = [0u8; 256];
    let mut cur = Cursor::new(&mut uart_buf[..]);
    if cur.write_fmt(args).is_ok() {
        let pos = cur.position();
        send_sync(&uart_buf, pos as usize);
    }
}

#[macro_export]
macro_rules! dprintf {
    ($msg:expr) => ({
        $crate::dprintf_hal::vdprintf(format_args!($msg))
    });
    ($fmt:expr, $($arg:tt)+) => ({
        $crate::dprintf_hal::vdprintf(format_args!($fmt, $($arg)+))
    });
}
