#****************************************
# Raspberry Pi 5 SPI Example
# Written for Design News
# Written by: Fred Eady
# Last Update: 08-22-2024
# Notes:
#****************************************
# MOSI = GPIO 10
# MISO = GPIO 9
# SCLK = GPIO 11
# CE0  = GPIO 8
#****************************************
# This code will send 0xAA and capture 
# the incoming byte (0x55). The incoming
# byte is printed to the console.
#****************************************

import spidev
import time

spibus0 = spidev.SpiDev()

# open (bus,device) spi0 and use CE0
spibus0.open(0,0)
spibus0.max_speed_hz = 5000

# mode bits CPOL|CPHA
spibus0.mode = 0b00

while True:
# xfer2 = hold CS0 active between blocks of data
# send data and receive slave response
    slaveResponse = spibus0.xfer2([0xAA])
    time.sleep(.5)    
    print(slaveResponse)
    