Tool/software: Code Composer Studio
I wanted to do spi communication between Raspberry Pi and MSP432,
so I wrote the code for Raspberry Pi with reference to "http://dev.ti.com/tirex/explore/node?node=AGUJ2FnNnpbgXwL6N6ofww__z-lQYNj__LATEST".
import spidev
import RPi.GPIO as GPIO
from time import sleep
MASTER_READY_PIN = 18
SLAVE_READY_PIN = 16
# inititalize the ports / pins
GPIO.setmode(GPIO.BOARD)
GPIO.setup(SLAVE_READY_PIN, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)
GPIO.setup(MASTER_READY_PIN, GPIO.OUT)
# Handshake with the MCU
while (GPIO.input(SLAVE_READY_PIN) == GPIO.LOW):
sleep(0.1)
GPIO.output(MASTER_READY_PIN, GPIO.HIGH)
spi = spidev.SpiDev()
spi.open(0, 0)
spi.max_speed_hz = 1000
spi.bits_per_word = 8
spi.mode = 0b01
GPIO.output(MASTER_READY_PIN, GPIO.LOW)
# Begin communication
MAX_LOOP = 10;
try:
while MAX_LOOP != 0:
if (GPIO.input(SLAVE_READY_PIN) is GPIO.LOW):
read = bytes(spi.readbytes(30))
print(''.join(read.decode()))
MAX_LOOP = MAX_LOOP - 1
while (GPIO.input(SLAVE_READY_PIN)==GPIO.LOW):
sleep(0.1)
GPIO.output(MASTER_READY_PIN, GPIO.LOW)
except KeyboardInterrupt:
GPIO.output(MASTER_READY_PIN, GPIO.LOW)
But spislave.c
sem_wait (& slaveSem);
It becomes an infinite loop.
Please let me know if you know anything.
Thank you.