Function rtt_target::set_print_channel_cs [−][src]
pub unsafe fn set_print_channel_cs(
channel: UpChannel,
cs: &'static CriticalSectionFunc
)
Sets the channel to use for rprint
and rprintln
and the critical section function used
to synchronize printing. You should only use this function if the set_print_channel
function
isn’t available on your platform.
Example
Because the function takes a static reference to a function pointer as an argument, the call
requires a manual cast. Luckily Rust will automatically promote a reference to a suitable
closure to 'static
. In this example, interrupt::free
is a function that establishes a
critical section and calls the supplied function.
use rtt_target::{rtt_init_detault, rprintln}; use platform_specific::interrupt; fn main() -> ! { let channels = rtt_init_detault!(); unsafe { rtt_target::set_print_channel_cs( channels.up.0, &((|arg, f| interrupt::free(|_| f(arg))) as rtt_target::CriticalSectionFunc), ); } loop { rprintln!("Hello, world!"); } }
Safety
This function is unsafe because the user must guarantee that the cs
function pointer passed in
adheres to the CriticalSectionFunc
specification.