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

07-uart code refactor #583

Merged

Conversation

A-Young-Git
Copy link
Contributor

Context: With recent updates to Rust’s embedded libraries, compatibility issues arose due to older versions of embedded-hal and associated dependencies. This refactor updates the project to utilize the latest libraries, ensuring both compatibility and enhanced functionality.

Key Refactoring Points:

  1. Updated Serial Communication:
  • Replaced the existing embedded-hal serial interfaces with the updated embedded-hal-nb::nb and embedded-hal-nb::serial modules, as well as embedded-io.

This update aligns the project with the latest embedded-hal standards, enhancing future compatibility and maintaining consistency with the broader embedded Rust ecosystem.

use embedded_hal_nb::nb;
use embedded_hal_nb::serial::{Error as SerialError, ErrorType, Read, Write};
use embedded_io::{Read as EmbeddedIoRead, Write as EmbeddedIoWrite};

  1. Refactored Static Buffers:
  • Updated tx and rx buffer static constants to utilize core::ptr::addr_of_mut, a safer and more flexible way to handle mutable pointers in Rust’s core library.

This change improves the handling of memory addresses, ensuring a more robust and maintainable codebase, especially in the context of embedded programming where direct memory manipulation is common.

  1. Dependency Version Updates:
  • Updated all dependencies in Cargo.toml to the latest compatible versions. This includes major updates like embedded-hal moving from version 0.2.6 to 1.0.0 and other libraries such as microbit-v2 and cortex-m.

These updates ensure compatibility with recent Rust releases and align with the latest improvements in the ecosystem.

@A-Young-Git A-Young-Git requested a review from a team as a code owner October 27, 2024 22:31
@humb1t
Copy link
Contributor

humb1t commented Jan 5, 2025

This PR helped me to overcome compilation errors from the book. I think it is nice to merge it sooner then later.

Copy link
Member

@jamesmunns jamesmunns left a comment

Choose a reason for hiding this comment

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

Looks reasonable, thanks for the update!

@jamesmunns jamesmunns enabled auto-merge January 6, 2025 15:16
@jamesmunns jamesmunns added this pull request to the merge queue Jan 6, 2025
Merged via the queue into rust-embedded:master with commit dd23318 Jan 6, 2025
17 checks passed
@eldruin
Copy link
Member

eldruin commented Jan 6, 2025

cc @BartMassey in case some of this needs to be incorporated into the mb2 version.

@BartMassey
Copy link
Member

@jamesmunns Thanks! I've been following this, but haven't got around to responding yet. I already rewrote the serial stuff for Discovery MB2, but I'll look at these commits and see what I can figure out.

@humb1t Thanks much for the PR!

@humb1t
Copy link
Contributor

humb1t commented Jan 7, 2025

Thanks @BartMassey - the author is @A-Young-Git, so I will forward your thanks to him)

@BartMassey
Copy link
Member

Oops. Thanks for the correction.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants