Giter VIP home page Giter VIP logo

Comments (4)

Vollbrecht avatar Vollbrecht commented on July 18, 2024

Welcome and thanks for reporting.

I think there might be a bug inside the read path of the transfer, when used in half3wire mode , but have to investigate a bit further.

from esp-idf-hal.

Dominaezzz avatar Dominaezzz commented on July 18, 2024
        .duplex(esp_idf_hal::spi::config::Duplex::Half3Wire)

and

    spi_dev.transfer(&mut read_buf, &[0x80 | 0x01, 0x00])?;

are incompatible.
You can't do a transfer with only one wire, you need one wire for reading and one wire for writing.

What you probably want to do there is this.

    spi_dev.transaction(&mut [Operation::Read(&mut read_buf), Operation::Write(&[0x80 | 0x01, 0x00]))?;

EDIT:

Actually, thinking about it a bit more, you're probably wanting to write first. Up to you to decide 😄

    spi_dev.transaction(&mut [Operation::Write(&[0x80 | 0x01, 0x00]), Operation::Read(&mut read_buf))?;

from esp-idf-hal.

Dessera avatar Dessera commented on July 18, 2024
        .duplex(esp_idf_hal::spi::config::Duplex::Half3Wire)

and

    spi_dev.transfer(&mut read_buf, &[0x80 | 0x01, 0x00])?;

are incompatible. You can't do a transfer with only one wire, you need one wire for reading and one wire for writing.

What you probably want to do there is this.

    spi_dev.transaction(&mut [Operation::Read(&mut read_buf), Operation::Write(&[0x80 | 0x01, 0x00]))?;

EDIT:

Actually, thinking about it a bit more, you're probably wanting to write first. Up to you to decide 😄

    spi_dev.transaction(&mut [Operation::Write(&[0x80 | 0x01, 0x00]), Operation::Read(&mut read_buf))?;

I tried to solve the problem with your code, but it returned the same error. When I did not select any Duplex (which should be Full-Duplex at this time), the final read_buf only has 0xF.

from esp-idf-hal.

Dominaezzz avatar Dominaezzz commented on July 18, 2024

I see. Looks like @Vollbrecht discovered this as well.

From a quick glance it appears we should be setting this to zero in half duplex mode.

This comment should've been taken care of when half duplex was added in this PR. Though I'm a little surprised no one has encountered this issue yet.

from esp-idf-hal.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.