Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Add mutex-traits-based implementations of SpiDevice and I2c#683

Open
JalonWong wants to merge 1 commit into
rust-embedded:master from
JalonWong:mutex_trait
Open

Add mutex-traits-based implementations of SpiDevice and I2c #683
JalonWong wants to merge 1 commit into
rust-embedded:master from
JalonWong:mutex_trait

Conversation

@JalonWong

@JalonWong JalonWong commented Aug 18, 2025

Copy link
Copy Markdown

Fix #119

@JalonWong JalonWong requested a review from a team as a code owner August 18, 2025 15:29
@JalonWong JalonWong changed the title (削除) Add mutex-trait-based implementations of SpiDevice and I2c (削除ここまで) (追記) Add mutex-traits-based implementations of SpiDevice and I2c (追記ここまで) Aug 18, 2025

Copy link
Copy Markdown

What exactly are the mutex/mutex-trait crates? I took a quick peek at them and they don't really seem to be used by anything in the ecosystem and are maintained under the tosc-rs GitHub organization (which I have never heard of before), rather than rust-embedded.

JalonWong commented Aug 21, 2025
edited
Loading

Copy link
Copy Markdown
Author

@FeldrinH
There is a mutex-trait under rust-embedded, but it's archived. It recommends the mutex-traits. I found it decent, so I suggest that you consider bringing it into the ecosystem.

critical-section = { version = "1.0" }
defmt-03 = { package = "defmt", version = "0.3", optional = true }
portable-atomic = {version = "1.3", default-features = false, optional = true, features = ["require-cas"]}
mutex = "1.0"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I'm a bit confused:

The mutex crate itself contains the following explanation of the relationship between mutex and mutex-traits:

The mutex-traits crate should be used by library crates that want to be generic over different ways of exclusive access.

The mutex crate should be used by applications that need to select which implementation is appropriate for their use case.

As embedded-hal-bus is a library, shouldn't it depend on mutex-traits?

But then, I don't get how code like MutexTraitsDevice implementations should be written without using the mutex crate. So this is more likely a documentation issue in mutex and mutex-traits (or just me being particularly slow today) than an actual issue with this pull request.

@JalonWong JalonWong Aug 25, 2025

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

The mutex-traits is used in the library that wants to provide a mutex implementation. For example a RTOS library. embedded-hal-bus should use mutex crate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@jannic jannic jannic left review comments

At least 1 approving review is required to merge this pull request.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Generic Mutex Trait

AltStyle によって変換されたページ (->オリジナル) /