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

Reduce vertical space slightly in UART examples #2407

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 1 addition & 3 deletions src/bare-metal/aps/examples/src/main_improved.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,7 @@ extern "C" fn main(x0: u64, x1: u64, x2: u64, x3: u64) {
if let Some(byte) = uart.read_byte() {
uart.write_byte(byte);
match byte {
b'\r' => {
uart.write_byte(b'\n');
}
b'\r' => uart.write_byte(b'\n'),
b'q' => break,
_ => {}
}
Expand Down
5 changes: 1 addition & 4 deletions src/bare-metal/aps/examples/src/pl011.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,10 +122,7 @@ impl Uart {

// SAFETY: We know that self.registers points to the control registers
// of a PL011 device which is appropriately mapped.
unsafe {
// Write to the TX buffer.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd like to keep this comment, as it's not immediately obvious what this line does. How about moving it up above the safety comment?

addr_of_mut!((*self.registers).dr).write_volatile(byte.into());
}
unsafe { addr_of_mut!((*self.registers).dr).write_volatile(byte.into()) };

// Wait until the UART is no longer busy.
while self.read_flag_register().contains(Flags::BUSY) {}
Expand Down
5 changes: 1 addition & 4 deletions src/bare-metal/aps/examples/src/pl011_minimal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,7 @@ impl Uart {

// SAFETY: We know that the base address points to the control
// registers of a PL011 device which is appropriately mapped.
unsafe {
// Write to the TX buffer.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto.

self.base_address.write_volatile(byte);
}
unsafe { self.base_address.write_volatile(byte) };

// Wait until the UART is no longer busy.
while self.read_flag_register() & FR_BUSY != 0 {}
Expand Down