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

Upgrading spi to embedded_hal 1.0 #517

Merged
merged 8 commits into from
Mar 12, 2024
Merged

Upgrading spi to embedded_hal 1.0 #517

merged 8 commits into from
Mar 12, 2024

Conversation

rubend056
Copy link
Contributor

@rubend056 rubend056 commented Mar 8, 2024

This is my follow up to #503, with your suggestions, since I needed the new Trait for a library I'm using. Perhaps we can continue to refine the implementation.

This might be good progress towards #468.

Copy link
Owner

@Rahix Rahix left a comment

Choose a reason for hiding this comment

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

Thanks a lot for picking up the changeset from the other PR. How much did you test this on real hardware so far?

Regarding the code, I only have one topic left to discuss, see below.

avr-hal-generic/src/spi.rs Outdated Show resolved Hide resolved
@rubend056
Copy link
Contributor Author

rubend056 commented Mar 10, 2024

I implemented the change by using SpiBus::flush(self)?; sice the Result is already infallible.

Now that I re-read the code, these function names are confusing raw_read and raw_read_buf, their name implies the only difference is one is a single byte read, and the other is multiple bytes read. But functionally one just reads spdr and the other makes a transaction on the bus by exchanging 0x00 with slave, reading incoming, repeating for every byte.

I understand this doesn't concern the end user of the library but it makes it confusing to understand by the maintainers.

I'll give this some rework and update accordingly.

@rubend056
Copy link
Contributor Author

rubend056 commented Mar 10, 2024

Ok, I've reworked the code, it should be functionally the same just slightly more clear.

I also moved the comments to the SpiOps definition so they would show up when hovering over the functions.

@rubend056
Copy link
Contributor Author

The code was tested/re-tested with an Uno sending/receiving packets using the nrf24l01 module, register readings and transmission were successful. The functions directly used were transfer and transfer_in_place.

Copy link
Owner

@Rahix Rahix left a comment

Choose a reason for hiding this comment

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

Looking very good, thanks a lot!

@Rahix Rahix merged commit 47cbf96 into Rahix:main Mar 12, 2024
23 checks passed
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.

2 participants