esp_wifi/compat/
mod.rs

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
pub mod common;
pub mod malloc;
pub mod misc;
pub mod timer_compat;

#[no_mangle]
unsafe extern "C" fn _putchar(c: u8) {
    static mut BUFFER: [u8; 256] = [0u8; 256];
    static mut IDX: usize = 0;

    let buffer = core::ptr::addr_of_mut!(BUFFER);
    if c == 0 || c == b'\n' || IDX == (*buffer).len() - 1 {
        if c != 0 {
            BUFFER[IDX] = c;
        } else {
            IDX = IDX.saturating_sub(1);
        }

        info!("{}", core::str::from_utf8_unchecked(&BUFFER[..IDX]));
        IDX = 0;
    } else {
        BUFFER[IDX] = c;
        IDX += 1;
    }
}