I am currently attempting to send and receive data from SPI0 to SPI1 on a singular raspberry pi.
My Current code is as follows;
from multiprocessing import Process
import spidev
import time
import sys
import RPi.GPIO as GPIO
import pigpio
GPIO.setwarnings(False)
GPIO.setmode(GPIO.BCM)
GPIO.setup(27, GPIO.OUT)
GPIO.setup(22, GPIO.OUT)
GPIO.output(27, GPIO.LOW)
GPIO.output(22, GPIO.HIGH)
master_spi = spidev.SpiDev()
slave_spi = spidev.SpiDev()
def master():
master_spi = spi.SpiDev()
master_spi.open(0, 0)
while True:
master_spi.max_speed_hz = 900000
def slave():
slave_spi = spidev.SpiDev()
slave_spi.open(1, 0)
while True:
resp = slave_spi.xfer([255])
print(resp[0])
time.sleep(1)
if __name__ == "__main__":
p1 = Process(target = master)
p2 = Process(target = slave)
p1.start()
p2.start()
At the moment, although both the slave and master can run at the same time, being able to send and recieve data between the two cannot happen.
Currently, the pins are connected as follows:
SPI0 MOSI (GPIO10) - SPI1 MOSI (GPIO20)
SPI0 MISO (GPIO9) - SPI1 MISO (GPIO19)
SPI0 SCLK (GPIO11) - SPI1 SCLK (GPIO21)
SPI0 CS0 (GPIO8) - SPI1 CS0 (GPIO16)
Any pointers, suggestions, or help would be great. Thank you.