vex_sdk/serial.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 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 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100
//! USB Serial Communication
#[cfg(any(target_env = "v5", target_env = "exp", doc))]
use core::ffi::{c_char, VaList};
#[cfg(any(target_env = "v5", target_env = "exp", doc))]
use crate::map_jump_table;
#[cfg(any(target_env = "v5", target_env = "exp", doc))]
map_jump_table! {
0x898 =>
/// Writes a single byte to the serial FIFO output buffer.
///
/// # Arguments
///
/// - `channel`: The serial communications channel to write to. Use `1` for stdio.
/// - `c`: The byte to write.
///
/// # Return
///
/// The number of bytes written, or -1 if an internal error occurred.
pub fn vexSerialWriteChar(channel: u32, c: u8) -> i32,
0x89c =>
/// Writes an arbitrary buffer to the serial FIFO output buffer, returning how
/// many bytes were written. The output buffer has a maximum size of 2048 bytes,
/// meaning that a larger buffer may be truncated.
///
/// # Arguments
///
/// - `channel`: The serial communications channel to write to. Use `1` for stdio.
/// - `data`: A buffer of bytes to write.
/// - `data_len`: The length of the specified buffer.
///
/// # Return
///
/// The number of bytes written, or -1 if an internal error occurred.
pub fn vexSerialWriteBuffer(channel: u32, data: *const u8, data_len: u32) -> i32,
0x8a0 =>
/// Reads a single byte from the input buffer.
///
/// # Arguments
///
/// - `channel`: The serial communications channel to read from. Use `1` for stdio.
///
/// # Return
///
/// The next byte in the input buffer, or -1 if no character is available to be read.
pub fn vexSerialReadChar(channel: u32) -> i32,
0x8a4 =>
/// Returns the next available byte to be read in the input buffer without removing
/// it from the buffer.
///
/// # Arguments
///
/// - `channel`: The serial communications channel to read from. Use `1` for stdio.
///
/// # Return
///
/// The next byte in the input buffer, or -1 if no character is available to be read.
pub fn vexSerialPeekChar(channel: u32) -> i32,
0x8ac =>
/// Returns the number of free bytes (out of `2048`) remaining in the serial output
/// buffer.
///
/// # Arguments
///
/// - `channel`: The serial communications channel to read from. Use `1` for stdio.
///
/// # Return
///
/// The number of remaining available bytes.
pub fn vexSerialWriteFree(channel: u32) -> i32,
0x0f0 => pub fn vex_vprintf(format: *const c_char, args: VaList) -> i32,
0x0f4 => pub fn vex_vsprintf(out: *mut c_char, format: *const c_char, args: VaList) -> i32,
0x0f8 => pub fn vex_vsnprintf(out: *mut c_char, max_len: u32, format: *const c_char, args: VaList) -> i32,
}
#[cfg(any(target_env = "v5", target_env = "exp", doc))]
pub unsafe extern "C" fn vex_printf(format: *const c_char, mut args: ...) -> i32 {
unsafe { vex_vprintf(format, args.as_va_list()) }
}
#[cfg(any(target_env = "v5", target_env = "exp", doc))]
pub unsafe extern "C" fn vex_sprintf(
out: *mut c_char,
format: *const c_char,
mut args: ...
) -> i32 {
unsafe { vex_vsprintf(out, format, args.as_va_list()) }
}
#[cfg(any(target_env = "v5", target_env = "exp", doc))]
pub unsafe extern "C" fn vex_snprintf(
out: *mut c_char,
max_len: u32,
format: *const c_char,
mut args: ...
) -> i32 {
unsafe { vex_vsnprintf(out, max_len, format, args.as_va_list()) }
}