Skip to content

How to use i2c as slave without directly control the registries #163

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

Open
eisterman opened this issue Jan 7, 2020 · 12 comments
Open

How to use i2c as slave without directly control the registries #163

eisterman opened this issue Jan 7, 2020 · 12 comments

Comments

@eisterman
Copy link

Is there an official method from this crate to use i2c without directly manipulate the bit of the i2c registries?
And if not, why?

@TeXitoi
Copy link
Contributor

TeXitoi commented Jan 7, 2020

No, because no one has done it yet.

Notably, it lacks an I2C slave embedded trait in embedded hal.

Contribution welcome!

@eisterman
Copy link
Author

If there isn't any problem with it I'm glad to implement it

@TeXitoi
Copy link
Contributor

TeXitoi commented Jan 7, 2020

Feel free to propose a first POC and ask for feedbacks. You can also chat with a lot of rust embedded developers on matrix https://github.com/rust-embedded/wg#contact

@eisterman
Copy link
Author

I ask to confirm my doubt.
Is the non-blocking master i2c interface currently lacking any method to be used, unlike its blocking counterpart, correct?

@TeXitoi
Copy link
Contributor

TeXitoi commented Jan 10, 2020

I'm not sure to understand. Doesn't the slave interface by definition different because of responding to requests?

@eisterman
Copy link
Author

Yes, however, there are two versions of the master, one blocker and one no. However, I noticed that only the blocking version is public (thanks to the embedded_hal traits). I was wondering if this was a lack of the current implementation or had a reason to reflect it in the slave implementation.

In general, I am thinking of managing the slave in a similar way to how the Arduino Wire library does, or through the assignment of two closures, one for sending data and one for receiving data.
In this area, many recommendations are accepted!

@therealprof
Copy link
Member

I think you're talking across one another.

Indeed there's no I2C slave traits to be implemented and there's also no custom I2C slave implementation implemented in this crate.

It would be great to have both.

CC rust-embedded/embedded-hal#179

@TheZoq2
Copy link
Member

TheZoq2 commented Jan 11, 2020

Yes, however, there are two versions of the master, one blocker and one no. However, I noticed that only the blocking version is public (thanks to the embedded_hal traits). I was wondering if this was a lack of the current implementation or had a reason to reflect it in the slave implementation.

Both versions are public, but only blocking i2c uses embedded hal traits, since there is no hal traits for non-blocking i2c. The same is true for slave i2c, so if you do implement it right now, users have to depend on stm32f1xx_hal directly.

The alternative is to add a slave trait to embedded_hal, and then implement it here. That would obviously be more work but is a nicer implementation.

@ost-ing
Copy link

ost-ing commented Jan 15, 2023

Wondering if there was any progress for an I2C slave feature in this crate?

Would a PR be welcome for implementing this as a device specific (ignoring the embedded-hal traits) feature for now?

@burrbull
Copy link
Member

Would a PR be welcome for implementing this as a device specific (ignoring the embedded-hal traits) feature for now?

Sure.

@surban
Copy link
Contributor

surban commented Feb 27, 2023

@ost-ing
Copy link

ost-ing commented Mar 9, 2023

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

No branches or pull requests

7 participants