Skip to content

Commit 86854c7

Browse files
author
Daniel Campora
committed
cc3200: Adapt smoke.py for the new pin API.
1 parent e3f8777 commit 86854c7

1 file changed

Lines changed: 25 additions & 25 deletions

File tree

cc3200/tools/smoke.py

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -8,50 +8,50 @@
88
"""
99

1010
pin_map = [23, 24, 11, 12, 13, 14, 15, 16, 17, 22, 28, 10, 9, 8, 7, 6, 30, 31, 3, 0, 4, 5]
11-
test_bytes = os.urandom(2048)
11+
test_bytes = os.urandom(1024)
1212

13-
def test_pin_read (type):
13+
def test_pin_read (pull):
1414
# enable the pull resistor on all pins, then read the value
1515
for p in pin_map:
16-
pin = pyb.Pin('GP' + str(p), af= 0, mode=pyb.Pin.IN, type=type)
16+
pin = pyb.Pin('GP' + str(p), mode=pyb.Pin.IN, pull=pull)
1717
# read the pin value
18-
print (pin.value())
18+
print(pin())
1919

20-
def test_pin_shorts (type):
21-
if type == pyb.Pin.STD_PU:
22-
type_inverted = pyb.Pin.STD_PD
20+
def test_pin_shorts (pull):
21+
if pull == pyb.Pin.PULL_UP:
22+
pull_inverted = pyb.Pin.PULL_DOWN
2323
else:
24-
type_inverted = pyb.Pin.STD_PU
24+
pull_inverted = pyb.Pin.PULL_UP
2525
# enable all pulls of the specified type
2626
for p in pin_map:
27-
pin = pyb.Pin('GP' + str(p), af= 0, mode=pyb.Pin.IN, type=type_inverted)
27+
pin = pyb.Pin('GP' + str(p), mode=pyb.Pin.IN, pull=pull_inverted)
2828
# then change the pull one pin at a time and read its value
2929
i = 0
3030
while i < len(pin_map):
31-
pin = pyb.Pin('GP' + str(pin_map[i]), af= 0, mode=pyb.Pin.IN, type=type)
32-
pyb.Pin('GP' + str(pin_map[i - 1]), af= 0, mode=pyb.Pin.IN, type=type_inverted)
31+
pin = pyb.Pin('GP' + str(pin_map[i]), mode=pyb.Pin.IN, pull=pull)
32+
pyb.Pin('GP' + str(pin_map[i - 1]), mode=pyb.Pin.IN, pull=pull_inverted)
3333
i += 1
3434
# read the pin value
35-
print (pin.value())
35+
print(pin())
3636

37-
test_pin_read(pyb.Pin.STD_PU)
38-
test_pin_read(pyb.Pin.STD_PD)
39-
test_pin_shorts(pyb.Pin.STD_PU)
40-
test_pin_shorts(pyb.Pin.STD_PD)
37+
test_pin_read(pyb.Pin.PULL_UP)
38+
test_pin_read(pyb.Pin.PULL_DOWN)
39+
test_pin_shorts(pyb.Pin.PULL_UP)
40+
test_pin_shorts(pyb.Pin.PULL_DOWN)
4141

4242
# create a test directory
4343
os.mkdir('/flash/test')
4444
os.chdir('/flash/test')
4545
print(os.getcwd())
4646
# create a new file
47-
f = open ('test.txt', 'w')
48-
n_w = f.write (test_bytes)
49-
print (n_w == len(test_bytes))
47+
f = open('test.txt', 'w')
48+
n_w = f.write(test_bytes)
49+
print(n_w == len(test_bytes))
5050
f.close()
5151
f = open('test.txt', 'r')
5252
r = bytes(f.readall(), 'ascii')
5353
# check that we can write and read it correctly
54-
print (r == test_bytes)
54+
print(r == test_bytes)
5555
f.close()
5656
os.remove('test.txt')
5757
os.chdir('..')
@@ -63,12 +63,12 @@ def test_pin_shorts (type):
6363

6464
# test the real time clock
6565
rtc = pyb.RTC()
66-
while (rtc.datetime()[7] > 800):
66+
while rtc.datetime()[7] > 800:
6767
pass
6868

69-
time_1 = rtc.datetime()
69+
time1 = rtc.datetime()
7070
pyb.delay(1000)
71-
time_2 = rtc.datetime()
72-
print (time_2[6] - time_1[6] == 1)
73-
print (time_2[7] - time_1[7] < 25)
71+
time2 = rtc.datetime()
72+
print(time2[6] - time1[6] == 1)
73+
print(time2[7] - time1[7] < 50)
7474

0 commit comments

Comments
 (0)