-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathSPI_16test.py
33 lines (29 loc) · 919 Bytes
/
SPI_16test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#sample program for testing SPI Driver
from spidriver import SPIDriver
port = '/dev/tty.usbserial-DO02C6P1'
s = SPIDriver(port)
# # read no write
# s.sel()
# msg = [0x40, 0x00] # val read no write
# resps = list(s.writeread(msg))
# for i in range(len(resps)):
# resps[i] = hex(resps[i])
# s.unsel()
# print(resps) # if full result should be (0b10..., 0b11..., 0b11..., 0b00...)
# write no read
# s.sel()
# msg = [0x8A, 0xAA] # val read no write
# resps = list(s.writeread(msg))
# for i in range(len(resps)):
# resps[i] = hex(resps[i])
# s.unsel()
# print(resps) # if clear, result should be three 0x4000, followed by 0x0000
# write and read
for j in range(256):
s.sel()
msg = [0xC0, j] # val read no write
resps = list(s.writeread(msg))
for i in range(len(resps)):
resps[i] = hex(resps[i])
s.unsel()
print(resps) # if clear, result should be three 0x4000, followed by 0x0000