-
Notifications
You must be signed in to change notification settings - Fork 1.2k
MSPM0: add i2c target implementation #4605
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
base: main
Are you sure you want to change the base?
Conversation
Done, | ||
/// Transaction Incomplete, controller trying to read more bytes than were provided | ||
NeedMoreBytes, | ||
/// Transaction Complere, but controller stopped reading bytes before we ran out |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/// Transaction Complere, but controller stopped reading bytes before we ran out | |
/// Transaction complete, but controller stopped reading bytes before we ran out |
/// Transaction completed successfully. The controller either NACKed the last byte | ||
/// or sent a STOP condition. | ||
Done, | ||
/// Transaction Incomplete, controller trying to read more bytes than were provided |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/// Transaction Incomplete, controller trying to read more bytes than were provided | |
/// Transaction incomplete, controller trying to read more bytes than were provided |
pub bus_speed: BusSpeed, | ||
|
||
/// 7-bit Target Address | ||
pub target_addr: u8, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do the other hals add target_addr
as a field for target mode? Or do the other hals make a new config type?
impl From<ClockDiv> for vals::Ratio { | ||
fn from(value: ClockDiv) -> Self { | ||
match value { | ||
ClockDiv::DivBy1 => Self::DIV_BY_1, | ||
ClockDiv::DivBy2 => Self::DIV_BY_2, | ||
ClockDiv::DivBy3 => Self::DIV_BY_3, | ||
ClockDiv::DivBy4 => Self::DIV_BY_4, | ||
ClockDiv::DivBy5 => Self::DIV_BY_5, | ||
ClockDiv::DivBy6 => Self::DIV_BY_6, | ||
ClockDiv::DivBy7 => Self::DIV_BY_7, | ||
ClockDiv::DivBy8 => Self::DIV_BY_8, | ||
} | ||
} | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we did this as an associated function rather than a trait impl to avoid making From<ClockDiv> for vals::Ratio
public API. Probably should revert this part.
let sda = p.PB3; | ||
|
||
let mut config = i2c::Config::default(); | ||
config.general_call = true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should explicitly set the target address here, even if redundant for the sake of making the examples helpful.
Just dropping in to say thanks for writing this; since there was a comment about not yet testing on MSPM0L1306, which I'm using, I tried it out on an LP-MSPM0L1306 and it worked after making basic pin-revisions:
|
Implement the i2c target interface from https://github.com/embassy-rs/embassy/tree/main/embassy-rp for mspm0.
In the interface we define a listen function that is used to receive the commands from the i2c controller asynchronously so that the user can handle them accordingly.
Currently the implementation heavily favors async because of the easier implementation with interrupts.
The example was tested on the dev. board: MSPM0G3507
Sadly my MSPM0L1306 board is broken at the moment, but the example should work exactly the same. So if needed I can add the example to the L1306 , but someone else would need to test it.