Commit 86854c70 authored by Daniel Campora's avatar Daniel Campora
Browse files

cc3200: Adapt smoke.py for the new pin API.

parent e3f8777e
...@@ -8,50 +8,50 @@ python3 run-tests --target wipy --device 192.168.1.1 ../cc3200/tools/smoke.py ...@@ -8,50 +8,50 @@ python3 run-tests --target wipy --device 192.168.1.1 ../cc3200/tools/smoke.py
""" """
pin_map = [23, 24, 11, 12, 13, 14, 15, 16, 17, 22, 28, 10, 9, 8, 7, 6, 30, 31, 3, 0, 4, 5] pin_map = [23, 24, 11, 12, 13, 14, 15, 16, 17, 22, 28, 10, 9, 8, 7, 6, 30, 31, 3, 0, 4, 5]
test_bytes = os.urandom(2048) test_bytes = os.urandom(1024)
def test_pin_read (type): def test_pin_read (pull):
# enable the pull resistor on all pins, then read the value # enable the pull resistor on all pins, then read the value
for p in pin_map: for p in pin_map:
pin = pyb.Pin('GP' + str(p), af= 0, mode=pyb.Pin.IN, type=type) pin = pyb.Pin('GP' + str(p), mode=pyb.Pin.IN, pull=pull)
# read the pin value # read the pin value
print (pin.value()) print(pin())
def test_pin_shorts (type): def test_pin_shorts (pull):
if type == pyb.Pin.STD_PU: if pull == pyb.Pin.PULL_UP:
type_inverted = pyb.Pin.STD_PD pull_inverted = pyb.Pin.PULL_DOWN
else: else:
type_inverted = pyb.Pin.STD_PU pull_inverted = pyb.Pin.PULL_UP
# enable all pulls of the specified type # enable all pulls of the specified type
for p in pin_map: for p in pin_map:
pin = pyb.Pin('GP' + str(p), af= 0, mode=pyb.Pin.IN, type=type_inverted) pin = pyb.Pin('GP' + str(p), mode=pyb.Pin.IN, pull=pull_inverted)
# then change the pull one pin at a time and read its value # then change the pull one pin at a time and read its value
i = 0 i = 0
while i < len(pin_map): while i < len(pin_map):
pin = pyb.Pin('GP' + str(pin_map[i]), af= 0, mode=pyb.Pin.IN, type=type) pin = pyb.Pin('GP' + str(pin_map[i]), mode=pyb.Pin.IN, pull=pull)
pyb.Pin('GP' + str(pin_map[i - 1]), af= 0, mode=pyb.Pin.IN, type=type_inverted) pyb.Pin('GP' + str(pin_map[i - 1]), mode=pyb.Pin.IN, pull=pull_inverted)
i += 1 i += 1
# read the pin value # read the pin value
print (pin.value()) print(pin())
test_pin_read(pyb.Pin.STD_PU) test_pin_read(pyb.Pin.PULL_UP)
test_pin_read(pyb.Pin.STD_PD) test_pin_read(pyb.Pin.PULL_DOWN)
test_pin_shorts(pyb.Pin.STD_PU) test_pin_shorts(pyb.Pin.PULL_UP)
test_pin_shorts(pyb.Pin.STD_PD) test_pin_shorts(pyb.Pin.PULL_DOWN)
# create a test directory # create a test directory
os.mkdir('/flash/test') os.mkdir('/flash/test')
os.chdir('/flash/test') os.chdir('/flash/test')
print(os.getcwd()) print(os.getcwd())
# create a new file # create a new file
f = open ('test.txt', 'w') f = open('test.txt', 'w')
n_w = f.write (test_bytes) n_w = f.write(test_bytes)
print (n_w == len(test_bytes)) print(n_w == len(test_bytes))
f.close() f.close()
f = open('test.txt', 'r') f = open('test.txt', 'r')
r = bytes(f.readall(), 'ascii') r = bytes(f.readall(), 'ascii')
# check that we can write and read it correctly # check that we can write and read it correctly
print (r == test_bytes) print(r == test_bytes)
f.close() f.close()
os.remove('test.txt') os.remove('test.txt')
os.chdir('..') os.chdir('..')
...@@ -63,12 +63,12 @@ print(ls) ...@@ -63,12 +63,12 @@ print(ls)
# test the real time clock # test the real time clock
rtc = pyb.RTC() rtc = pyb.RTC()
while (rtc.datetime()[7] > 800): while rtc.datetime()[7] > 800:
pass pass
time_1 = rtc.datetime() time1 = rtc.datetime()
pyb.delay(1000) pyb.delay(1000)
time_2 = rtc.datetime() time2 = rtc.datetime()
print (time_2[6] - time_1[6] == 1) print(time2[6] - time1[6] == 1)
print (time_2[7] - time_1[7] < 25) print(time2[7] - time1[7] < 50)
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment