Git Product home page Git Product logo

Comments (2)

joan2937 avatar joan2937 commented on August 26, 2024

http://abyz.co.uk/rpi/pigpio/python.html#spi_open

Firstly 3-wire operation only works on the main SPI device and works within the limits imposed by the Pi hardware.

The Pi hardware supports switching the MOSI line between MOSI and MISO after a user selected number of bytes.

The code above switches between MOSI and MISO after 0 bytes, i.e. immediately.

Contrast with the following which first does the above and secondly switches after 4 bytes.

#!/usr/bin/env python

import pigpio

W3=(1<<9) # select 3-wire operation
W3N4=(4<<10) # switch to miso after four bytes

pi = pigpio.pi() # Connect to local Pi.

spi1 = pi.spi_open(0,10000,W3)
spi2 = pi.spi_open(0,10000,W3|W3N4)

pi.spi_write(spi1,[0x01,0x02,0x03,0x04])

pi.spi_write(spi2,[0x01,0x02,0x03,0x04])

pi.spi_close(spi1)
pi.spi_close(spi2)

pi.stop()

piscope 3-wire

I presume the write is used for testing. Normally xfer would be used as you expect to write some bytes then read some back.

from pigpio.

KevinLowe360 avatar KevinLowe360 commented on August 26, 2024

It works!Seems something wrong with my comprehend to 3-wire spi. I have got the perfect output with your help,many thanks.

from pigpio.

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.