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

Backwards compatible eh1 SPI support #163

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

Florob
Copy link
Contributor

@Florob Florob commented Jun 8, 2024

This adds impls of eh1's SpiBus and SpiDevice traits to Lpspi in a backwards compatible manner.
At least I think it is backwards compatible. There are some added and changes trait bounds, but they ought to be equivalent to or slightly more permissive than the preexisting ones.
The DelayNs operation is not supported and documented as such, since without breaking changes we have no delay provider available to us. Users that needs it can use embedded-hal-bus in conjunction with the SpiBus impl.

This is probably not where we want to go long term. The Lpspi type needs to change to support multiple chip selects, which will probably create a more natural split between the Bus and the Device trait. However, I think it is beneficial to provide a basic impl to users in the meantime.

Caveat: I've not yet extensively tested this.

When we change the transmit / receive masks within a continuous
transaction, we might demonstrate an LPSPI hardware defect. In the
example shown here, the LPSPI SCK stalls when transmitting the final bit
of the final byte, preventing the read from executing.

Right now, I'm not sure if this is the LPSPI continuous transaction
hardware defect, or if there's an issue in this new driver. I'll shoot
for a deeper review later.
Copy link
Member

@mciantyre mciantyre left a comment

Choose a reason for hiding this comment

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

The backwards compatibility LGTM. Thanks for sharing this idea!

This looks like a good starting point for an EH1 SPI bus and device implementation. I agree that we can break / extend it later.

I pushed my first test case to this branch. All existing transactions in the loopback test are still working on my 1176 MCU. However, the SpiDevice transaction sequence

spi.transaction(&mut [
    TransferInPlace(&mut xfer),
    Read(&mut read),
]).unwrap();

isn't finishing the TransferInPlace operation. My logic analyzer output is below. It looks like SCK is stuck high, and it's not clocking out the final bit of the final byte.

SCK stuck high before end of transfer Screenshot 2024-06-10 at 12 31 31

Nothing about the continuous transactions looked obviously questionable, so I'm still digging into the issue.

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