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

How to read incoming data from SPI MOSI Lane? (not MISO) #624

Open
Syphixs opened this issue Aug 17, 2024 · 1 comment
Open

How to read incoming data from SPI MOSI Lane? (not MISO) #624

Syphixs opened this issue Aug 17, 2024 · 1 comment

Comments

@Syphixs
Copy link

Syphixs commented Aug 17, 2024

I am working on a specific epd which requires to read data from the MOSI line after sending a command but switching the CS pin between each byte. It's unclear to me if this is even achievable with the SPI Bus implementation. If so some guidance would be appreciated.
Some relevant parts from the documentation:
appnote1

Here it also states that a CS pulse is necessary between each read.
appnote2

I thought something like this would be working:

    pub fn read_otp(&mut self, buffer: &mut [u8]) -> Result<(), E> {
        self.bus.lock(|bus| {
            let mut bus = bus.borrow_mut();

            self.cs.set_low().ok();
            // Command mode
            self.dc.set_low().ok();

            // Send read command
            bus.write(&[0xA2])?;

            self.dc.set_high().ok(); // Data mode

            // Read data
            for byte in buffer.iter_mut() {
                self.cs.set_high().ok();
                self.cs.set_low().ok();

                // Send dummy byte and read the result
                let mut read_buf = [0u8];
                bus.transfer(&mut read_buf, &[0x00])?;
                *byte = read_buf[0];
            }

            self.cs.set_high().ok();
            Ok(())
        })
    }

but then i found out that the transfer also wants to read on the MISO line.

@jannic
Copy link
Member

jannic commented Sep 17, 2024

This looks like a non-standard variation of SPI.

While it may (or may not) be supported by the SPI hardware of your microcontroller, it's not something supported by the abstraction layer provided by embedded-hal.

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