Skip to content

Commit fe7a64f

Browse files
committed
Updated RPi Tests
1 parent 5ac4576 commit fe7a64f

2 files changed

Lines changed: 55 additions & 22 deletions

File tree

Lines changed: 41 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -23,19 +23,21 @@
2323
#
2424
#******************************************************************************
2525
#
26-
# File: rpi_strand_test.py
26+
# File: rpi_strand_gpo_test.py
2727
# Date: Sun Aug 18 12:00:00 EDT 2019
2828
#
2929
# Functional Description:
3030
#
31-
# Raspberry Pi Based Strand Test
31+
# Raspberry Pi Strand Plus GPO Test
32+
#
33+
# Notes:
34+
#
35+
# - Raspbery Pi SPI Master Code
36+
# - RPi Board Pin 36 is used as an Active Low FPGA Logic Reset
37+
# - RPi CE0 is used for the FPGA User SPI Slave Chip Select
3238
#
3339
#******************************************************************************
3440

35-
# Raspbery Pi SPI Master Code
36-
# Board Pin 36 is used as an Active Low FPGA Logic Reset
37-
# RPi CE0 is used for the FPGA User SPI Slave Chip Select
38-
3941
import sys
4042
import time
4143
import spidev
@@ -46,6 +48,8 @@
4648
metrics['tx_sum'] = 0
4749
metrics['tx_max'] = 0
4850
metrics['tx_min'] = 10000
51+
fc_count = 0
52+
led_state = 0
4953

5054
def spi_transfer(msg, verbose):
5155
if (verbose == 1):
@@ -103,25 +107,31 @@ def reg_write(offset, wdata):
103107
print()
104108

105109
def rgb_load(rgb):
110+
global fc_count
111+
106112
msg = [0x04]
107113
msg.extend(rgb)
108114
retval = spi_transfer(msg, 0)
109115

110116
# Wait until not Almost fulll
111-
while ((retval[-1] & 0x08) == 1):
112-
print ("Flow Controlled")
117+
while ((retval[-1] & 0x08) != 0x00):
118+
# print ("Flow Controlled")
113119
msg = [0x00, 0x00, 0x00, 0x00]
114120
retval = spi_transfer(msg, 0)
121+
fc_count += 1
115122

116123
def rgb_reset_code():
124+
global fc_count
125+
117126
msg = [0x07, 0xA5]
118127
retval = spi_transfer(msg, 0)
119128

120129
# Wait until not Almost fulll
121-
while ((retval[-1] & 0x08) == 1):
122-
print ("Flow Controlled")
130+
while ((retval[-1] & 0x08) !=0x00):
131+
# print ("Flow Controlled")
123132
msg = [0x00, 0x00, 0x00, 0x00]
124133
retval = spi_transfer(msg, 0)
134+
fc_count += 1
125135

126136

127137
RESET_PIN = 36
@@ -138,7 +148,7 @@ def rgb_reset_code():
138148
spi.open(BUS_ID, DEVICE_ID)
139149

140150
# Set SPI speed and mode
141-
spi.max_speed_hz = 1953000
151+
spi.max_speed_hz = 15600000
142152
spi.mode = 0
143153

144154
print ("\nReset FPGA Fabric Logic")
@@ -154,7 +164,7 @@ def rgb_reset_code():
154164
print ("Issue Hardware Revision Command")
155165
revision_read()
156166

157-
# print ("Issue Register Write Command (Reset Code Timing")
167+
print ("Issue Register Write Command (Reset Code Timing)")
158168
reg_write(0x0C, [0xA0])
159169

160170
print ("Issue Register Reads Command (All Registers)")
@@ -164,6 +174,9 @@ def rgb_reset_code():
164174
reg_write(0xF2, [0x12, 0x34, 0x56, 0x78])
165175
reg_read(0xF2, 4)
166176

177+
print ("Enabling LEDs")
178+
reg_write(0xF1, [3])
179+
167180
print ("Issue RGB Commands")
168181
loop_count = 1
169182
while (1):
@@ -229,9 +242,24 @@ def rgb_reset_code():
229242
if (delta < metrics['tx_min']):
230243
metrics['tx_min'] = delta
231244

245+
# Set PCB LED
246+
if (led_state == 0):
247+
reg_write(0xF0, [1])
248+
led_state = 1
249+
elif (led_state == 1):
250+
reg_write(0xF0, [2])
251+
led_state = 2
252+
elif (led_state == 2):
253+
reg_write(0xF0, [3])
254+
led_state = 3
255+
else:
256+
reg_write(0xF0, [0])
257+
led_state = 0
258+
232259
# Render Average
233260
metrics['rend_avg'] = (metrics['tx_sum'] / metrics['loop_count'])
234-
print("LEDs: %1d; Current Render: %9f; TX Avg: %9f; TX Max: %9f, TX Min: %9f" % (LED_COUNT, cdelta, metrics['rend_avg'], metrics['tx_max'], metrics['tx_min']))
261+
print("LEDs: %1d; Current Render: %9f; TX Avg: %9f; TX Max: %9f, TX Min: %9f; Flow Control: %5d" % (LED_COUNT, cdelta, metrics['rend_avg'], metrics['tx_max'], metrics['tx_min'], fc_count))
262+
fc_count = 0
235263

236264
spi.close()
237265
exit()
Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,19 +23,21 @@
2323
#
2424
#******************************************************************************
2525
#
26-
# File: rpi_fpga_test.py
26+
# File: rpi_strand_walking_pixel_test.py
2727
# Date: Sun Aug 18 12:00:00 EDT 2019
2828
#
2929
# Functional Description:
3030
#
31-
# Raspberry Pi Based FPGA Test
31+
# Raspberry Pi Strand Walking Pixel Test
32+
#
33+
# Notes:
34+
#
35+
# - Raspbery Pi SPI Master Code
36+
# - RPi Board Pin 36 is used as an Active Low FPGA Logic Reset
37+
# - RPi CE0 is used for the FPGA User SPI Slave Chip Select
3238
#
3339
#******************************************************************************
3440

35-
# Raspbery Pi SPI Master Code
36-
# Board Pin 36 is used as an Active Low FPGA Logic Reset
37-
# RPi CE0 is used for the FPGA User SPI Slave Chip Select
38-
3941
import sys
4042
import time
4143
import spidev
@@ -116,7 +118,7 @@ def rgb_reset_code():
116118
RESET_PIN = 36
117119
BUS_ID = 0
118120
DEVICE_ID = 0
119-
LED_COUNT = 5
121+
LED_COUNT = 60
120122

121123
# Reset is on board pin 36
122124
GPIO.setmode(GPIO.BOARD)
@@ -127,7 +129,7 @@ def rgb_reset_code():
127129
spi.open(BUS_ID, DEVICE_ID)
128130

129131
# Set SPI speed and mode
130-
spi.max_speed_hz = 3900000
132+
spi.max_speed_hz = 1953000
131133
spi.mode = 0
132134

133135
print ("\nReset FPGA Fabric Logic")
@@ -143,7 +145,10 @@ def rgb_reset_code():
143145
print ("Issue Hardware Revision Command, 3 Bytes")
144146
revision_read()
145147

146-
print ("Issue Register Reads Command, 16 Bytes")
148+
print ("Issue Register Write Command (Reset Code Timing), 3 Bytes")
149+
reg_write(0x0C, [0xA0])
150+
151+
print ("Issue Register Reads Command (All Registers)")
147152
reg_read(0x00, 0x0D)
148153

149154
print ("Issue Register Write Command (Scratch Pad), 6 Bytes")

0 commit comments

Comments
 (0)