Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
V
vSPI
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
rasky
vSPI
Commits
beb5a7fe
Commit
beb5a7fe
authored
Feb 24, 2012
by
Mike Lyons
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of github.com:mjlyons/vSPI
parents
fb592855
5e3a2e6b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
15 deletions
+17
-15
spitest.py
scripts/master/spitest.py
+17
-15
No files found.
scripts/master/spitest.py
View file @
beb5a7fe
...
@@ -12,9 +12,9 @@ if (len(sys.argv) < 2):
...
@@ -12,9 +12,9 @@ if (len(sys.argv) < 2):
sys
.
exit
(
1
)
sys
.
exit
(
1
)
port
=
int
(
sys
.
argv
[
1
])
port
=
int
(
sys
.
argv
[
1
])
mode
=
2
mode
=
3
bitrate
=
4
0000
# kbps
bitrate
=
3
0000
# kbps
byteCount
=
11
# bytes
byteCount
=
4096
# bytes
# Open the device
# Open the device
handle
=
ch_open
(
port
)
handle
=
ch_open
(
port
)
...
@@ -44,10 +44,10 @@ sys.stdout.flush()
...
@@ -44,10 +44,10 @@ sys.stdout.flush()
# Create 4KB of fake data so we can exchange it for real data
# Create 4KB of fake data so we can exchange it for real data
data_in
=
array
(
'B'
,
[
0
for
i
in
range
(
byteCount
)])
data_in
=
array
(
'B'
,
[
0
for
i
in
range
(
byteCount
)])
ch_spi_queue_clear
(
handle
)
ch_spi_queue_clear
(
handle
)
ch_spi_queue_oe
(
handle
,
1
)
ch_spi_queue_oe
(
handle
,
1
)
ch_spi_queue_ss
(
handle
,
0x1
)
ch_spi_queue_ss
(
handle
,
0x1
)
ch_spi_queue_byte
(
handle
,
1
,
1
)
# Sending data to FPGA
ch_spi_queue_byte
(
handle
,
1
,
1
)
# Sending data to FPGA
ch_spi_queue_byte
(
handle
,
1
,
0xFF
)
# Sending bytes
ch_spi_queue_byte
(
handle
,
1
,
0xFF
)
# Sending bytes
ch_spi_queue_byte
(
handle
,
1
,
0xF0
)
# Sending bytes
ch_spi_queue_byte
(
handle
,
1
,
0xF0
)
# Sending bytes
...
@@ -58,23 +58,25 @@ ch_spi_queue_byte(handle, 1, 0x34) # Sending bytes
...
@@ -58,23 +58,25 @@ ch_spi_queue_byte(handle, 1, 0x34) # Sending bytes
ch_spi_queue_byte
(
handle
,
1
,
0x56
)
# Sending bytes
ch_spi_queue_byte
(
handle
,
1
,
0x56
)
# Sending bytes
ch_spi_queue_byte
(
handle
,
1
,
0x78
)
# Sending bytes
ch_spi_queue_byte
(
handle
,
1
,
0x78
)
# Sending bytes
ch_spi_queue_byte
(
handle
,
1
,
0x9A
)
# Sending bytes
ch_spi_queue_byte
(
handle
,
1
,
0x9A
)
# Sending bytes
ch_spi_queue_ss
(
handle
,
0
)
ch_spi_queue_ss
(
handle
,
0
)
#ch_spi_queue_byte(handle, 1, 0x00) # Send an empty byte, SS high
(
actualByteCount
,
data_in
)
=
ch_spi_batch_shift
(
handle
,
byteCount
)
(
actualByteCount
,
data_in
)
=
ch_spi_batch_shift
(
handle
,
byteCount
)
for
i
in
range
(
actualByteCount
):
sys
.
stdout
.
write
(
"
%
x "
%
data_in
[
i
])
sys
.
stdout
.
write
(
"
\n
"
)
#if (actualByteCount < 0):
ch_spi_queue_clear
(
handle
)
# print "error: %s" % ch_status_string(count)
ch_spi_queue_oe
(
handle
,
1
)
#elif (actualByteCount != byteCount):
ch_spi_queue_ss
(
handle
,
0x1
)
# print "error: read %d bytes (expected %d)" % (actualByteCount, byteCount)
ch_spi_queue_byte
(
handle
,
1
,
3
)
# Receiving data from FPGA
#else:
for
i
in
range
(
1024
):
ch_spi_queue_byte
(
handle
,
1
,
0x00
)
# Sending bytes (1024 bytes of gibberish)
ch_spi_queue_ss
(
handle
,
0
)
(
actualByteCount
,
data_in
)
=
ch_spi_batch_shift
(
handle
,
byteCount
)
for
i
in
range
(
actualByteCount
):
for
i
in
range
(
actualByteCount
):
sys
.
stdout
.
write
(
"
%
d
"
%
data_in
[
i
])
sys
.
stdout
.
write
(
"
%
x
"
%
data_in
[
i
])
sys
.
stdout
.
write
(
"
\n
"
)
sys
.
stdout
.
write
(
"
\n
"
)
# Close and exit
# Close and exit
ch_close
(
handle
)
ch_close
(
handle
)
sys
.
exit
(
0
)
sys
.
exit
(
0
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment