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

Improving the SPI-M #91

Open
hegza opened this issue Nov 5, 2024 · 3 comments
Open

Improving the SPI-M #91

hegza opened this issue Nov 5, 2024 · 3 comments

Comments

@hegza
Copy link
Contributor

hegza commented Nov 5, 2024

@Aisha-KM @RHamalainen

Some questions based on the current implementation

Writing on RX (SOLVED)

Does it ever make sense to write on the RX line? I.e., is this method redundant?

Solved: I was misinterpreting the source code.

Reading from the RX

How would one read from the RX. Looking at the UART RX code, something like this might work:

// Block until SPI-M reports data is available
while !spim.read_ready() {}

// SPI-Ms RX channel
let rx = spim.rx();

// Block until device reports ability to enqueue
while !rx.can_enqueue() {}

// Read the buffer from device
unsafe { rx.enqueue(buf) }

// Block again until the transfer is complete
while rx.saddr().read().bits() != 0 {}

Now the main question is, how to determine when data is ready to be read (read_ready).

@Aisha-KM
Copy link
Contributor

Aisha-KM commented Nov 5, 2024

we can't implement the same functionality as read_ready() for SPIM since it does not have a VALID register to check for the data validity, however we can rely on can_enqueue() to some degree as it reads the transfer "pending" status in a channel.

@Aisha-KM
Copy link
Contributor

Aisha-KM commented Nov 6, 2024

The changes are already done by @hegza , they are essentially similar to mine.

I added the check for enqueue here. please check it and let me know if there is issues with it.

@hegza
Copy link
Contributor Author

hegza commented Nov 6, 2024

It looks like the current version at main might work. I added deprecation warning to the method, imploring that it should be tested.

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

2 participants