Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UART EasyDMA example #272

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
use rprint instead of rprintln
  • Loading branch information
Jesse committed Dec 1, 2020
commit 51f25b8d45ae4aa2126ebd931e0c68af3be7eaaf
2 changes: 1 addition & 1 deletion examples/uarte-demo/Embed.toml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ channels = [
# The duration in ms for which the logger should retry to attach to RTT.
timeout = 3000
# Whether timestamps in the RTTUI are enabled
show_timestamps = true
show_timestamps = false
# Whether to save rtt history buffer on exit.
log_enabled = false
# Where to save rtt history buffer relative to manifest path.
Expand Down
11 changes: 4 additions & 7 deletions examples/uarte-demo/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,14 @@ use {
cortex_m_rt::entry,
hal::gpio::Level,
nrf52840_hal as hal,
rtt_target::{rprintln, rtt_init_print},
rtt_target::{rprintln, rprint, rtt_init_print},
};

#[inline(never)]
#[panic_handler]
fn panic(_info: &PanicInfo) -> ! {
fn panic(info: &PanicInfo) -> ! {
cortex_m::interrupt::disable();
rprintln!("{}", info);
loop {
compiler_fence(Ordering::SeqCst);
}
Expand Down Expand Up @@ -68,12 +69,8 @@ fn main() -> ! {
// write buffer back
serial.write(&rx_buffer).unwrap();

// strip the new line since rprintln automatically adds one
if rx_buffer[index - 1] == '\n' as u8 {
rx_buffer[index - 1] = 0;
}
// duplicating messages over rtt to compare results
rprintln!("{}", str::from_utf8(&rx_buffer).unwrap());
rprint!(str::from_utf8(&rx_buffer).unwrap());

// reset the buffer so we don't have stale data
rx_buffer.iter_mut().for_each(|m| *m = 0);
Expand Down