Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Single spi #4

Closed
wants to merge 26 commits into from
Closed
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
ddbf7e3
glitches
mattvenn Nov 15, 2018
4734746
savefile
mattvenn Nov 16, 2018
05b7d34
savefile
mattvenn Nov 16, 2018
e1f09eb
looking at null bytes
mattvenn Nov 16, 2018
067cc73
move gtkwave filters
Nov 18, 2018
f21638c
working with regular clock
Nov 18, 2018
9760a04
tidy up sspi dir
Nov 18, 2018
5a43d03
formal
Nov 18, 2018
696e225
formally verified with CDC
mattvenn Nov 19, 2018
e006d8e
assign spi_rdy and err high
mattvenn Nov 19, 2018
e229432
added more testbench support files
mattvenn Nov 20, 2018
a25d0c4
no_glitch localparam to turn on clock glitching
mattvenn Nov 20, 2018
ed19d85
testing spi comms and camera
mattvenn Nov 21, 2018
07048df
wait for acks properly by controlling cs pin manually
mattvenn Nov 21, 2018
332e583
add length and position to read and write routines
mattvenn Nov 21, 2018
a9efb1b
random write/read test
mattvenn Nov 21, 2018
1ae583a
kernel upload, run and readout works, but only with 128byte reads
mattvenn Nov 21, 2018
b67c8d5
fixed ACK: working with 1024 byte write/reads
mattvenn Nov 21, 2018
4575fe0
nicer formatting
mattvenn Nov 21, 2018
02e10bd
include spi client verilog
mattvenn Nov 26, 2018
1bbcbb3
pcf for lattice up5k dev board
mattvenn Nov 26, 2018
5a1619e
gtkwave config
mattvenn Nov 26, 2018
931fafa
Merge branch 'single_spi_reg_clock' of mattvenn.net:~/symbiotic_eda/m…
mattvenn Nov 26, 2018
443d1e4
change print for python2
mattvenn Nov 26, 2018
9f1006e
Merge branch 'single_spi_reg_clock' of mattvenn.net:~/symbiotic_eda/m…
mattvenn Nov 26, 2018
ed52c10
pinout
mattvenn Nov 26, 2018
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

testing spi comms and camera

  • Loading branch information
mattvenn committed Nov 21, 2018
commit ed19d85a4db2dce5d554f265e0d7c1365dccd0ab
@@ -0,0 +1,57 @@
# import the necessary packages
from picamera.array import PiRGBArray
from picamera import PiCamera
import spidev
import time
import cv2

# initialize the camera and grab a reference to the raw camera capture
camera = PiCamera()

export_resolution = (16, 16)
camera_res = (32, 32)

camera.resolution = camera_res
camera.framerate = 32
rawCapture = PiRGBArray(camera, size=camera_res)

# allow the camera to warmup
time.sleep(0.1)


import spidev
spi = spidev.SpiDev()
spi.open(0, 0)
spi.max_speed_hz = 8000000

# capture frames from the camera
time_start = time.time()
frames = 0
for frame in camera.capture_continuous(rawCapture, format="bgr", use_video_port=True):
# grab the raw NumPy array representing the image, then initialize the timestamp
# and occupied/unoccupied text
image = frame.array

#grey scale
image = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)

# resize
if export_resolution != camera_res:
image = cv2.resize(image, dsize=export_resolution, interpolation=cv2.INTER_CUBIC)

#cv2.imshow("Frame", image)
key = cv2.waitKey(1) & 0xFF

#print(image[0])
for row in image:
spi.xfer(row.tolist())
# clear the stream in preparation for the next frame
rawCapture.truncate(0)

# if the `q` key was pressed, break from the loop
if key == ord("q"):
break
frames += 1
if frames % 100 == 0:
print(time.time() - time_start)
time_start = time.time()
@@ -0,0 +1,31 @@
import spidev


import spidev
spi = spidev.SpiDev()
spi.open(0, 0)
spi.max_speed_hz = 8000000
spi.mode = 0b11


def send_data(cursor):
# send the data
spi.xfer([0x21, cursor])
# 2 bytes word len
spi.xfer([0x23, cursor, 0x00, 0x01, 0,0, 0])


def get_data(cursor):
spi.xfer([0x24, cursor, 0x00, 0x01, 0x00, 0x00, 0])
data = spi.xfer([0x22, 0x00, 0])
print(data)
return data[2]

for cursor in range(100):
send_data(cursor)
data = get_data(cursor)
assert(data == cursor)

#print(spi.readbytes(1))
#spi.xfer([0x20, 0, 0, 0])
#print(spi.readbytes(8))
ProTip! Use n and p to navigate between commits in a pull request.