tests/pyb: Adjust tests so they can run on PYB and PYBLITE.
A few tests still fail on PYBLITE, and that's due to differences in the available peripheral block numbers on the different MCUs (eg I2C(2) exists on one, but it's I2C(3) on the other).pull/1/head
parent
27c149efe0
commit
d3bb3e38df
|
@ -9,9 +9,12 @@ print(adc)
|
||||||
val = adc.read()
|
val = adc.read()
|
||||||
assert val < 500
|
assert val < 500
|
||||||
|
|
||||||
|
# timer for read_timed
|
||||||
|
tim = pyb.Timer(5, freq=500)
|
||||||
|
|
||||||
# read into bytearray
|
# read into bytearray
|
||||||
buf = bytearray(50)
|
buf = bytearray(50)
|
||||||
adc.read_timed(buf, 500)
|
adc.read_timed(buf, tim)
|
||||||
print(len(buf))
|
print(len(buf))
|
||||||
for i in buf:
|
for i in buf:
|
||||||
assert i < 500
|
assert i < 500
|
||||||
|
@ -19,12 +22,12 @@ for i in buf:
|
||||||
# read into arrays with different element sizes
|
# read into arrays with different element sizes
|
||||||
import array
|
import array
|
||||||
ar = array.array('h', 25 * [0])
|
ar = array.array('h', 25 * [0])
|
||||||
adc.read_timed(ar, 500)
|
adc.read_timed(ar, tim)
|
||||||
print(len(ar))
|
print(len(ar))
|
||||||
for i in buf:
|
for i in buf:
|
||||||
assert i < 500
|
assert i < 500
|
||||||
ar = array.array('i', 30 * [0])
|
ar = array.array('i', 30 * [0])
|
||||||
adc.read_timed(ar, 500)
|
adc.read_timed(ar, tim)
|
||||||
print(len(ar))
|
print(len(ar))
|
||||||
for i in buf:
|
for i in buf:
|
||||||
assert i < 500
|
assert i < 500
|
||||||
|
|
|
@ -1,4 +1,10 @@
|
||||||
from pyb import CAN
|
try:
|
||||||
|
from pyb import CAN
|
||||||
|
except ImportError:
|
||||||
|
print('SKIP')
|
||||||
|
import sys
|
||||||
|
sys.exit()
|
||||||
|
|
||||||
import pyb
|
import pyb
|
||||||
|
|
||||||
# test we can correctly create by id or name
|
# test we can correctly create by id or name
|
||||||
|
|
|
@ -1,5 +1,10 @@
|
||||||
import pyb
|
import pyb
|
||||||
|
|
||||||
|
if not hasattr(pyb, 'DAC'):
|
||||||
|
print('SKIP')
|
||||||
|
import sys
|
||||||
|
sys.exit()
|
||||||
|
|
||||||
dac = pyb.DAC(1)
|
dac = pyb.DAC(1)
|
||||||
print(dac)
|
print(dac)
|
||||||
dac.noise(100)
|
dac.noise(100)
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import pyb
|
import pyb
|
||||||
|
|
||||||
# test basic functionality
|
# test basic functionality
|
||||||
ext = pyb.ExtInt('X1', pyb.ExtInt.IRQ_RISING, pyb.Pin.PULL_DOWN, lambda l:print('line:', l))
|
ext = pyb.ExtInt('Y1', pyb.ExtInt.IRQ_RISING, pyb.Pin.PULL_DOWN, lambda l:print('line:', l))
|
||||||
ext.disable()
|
ext.disable()
|
||||||
ext.enable()
|
ext.enable()
|
||||||
print(ext.line())
|
print(ext.line())
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
0
|
6
|
||||||
line: 0
|
line: 6
|
||||||
line: 0
|
line: 6
|
||||||
|
|
|
@ -1,14 +1,14 @@
|
||||||
from pyb import Pin
|
from pyb import Pin
|
||||||
|
|
||||||
p = Pin('X1', Pin.IN)
|
p = Pin('Y1', Pin.IN)
|
||||||
print(p)
|
print(p)
|
||||||
print(p.name())
|
print(p.name())
|
||||||
print(p.pin())
|
print(p.pin())
|
||||||
print(p.port())
|
print(p.port())
|
||||||
|
|
||||||
p = Pin('X1', Pin.IN, Pin.PULL_UP)
|
p = Pin('Y1', Pin.IN, Pin.PULL_UP)
|
||||||
p = Pin('X1', Pin.IN, pull=Pin.PULL_UP)
|
p = Pin('Y1', Pin.IN, pull=Pin.PULL_UP)
|
||||||
p = Pin('X1', mode=Pin.IN, pull=Pin.PULL_UP)
|
p = Pin('Y1', mode=Pin.IN, pull=Pin.PULL_UP)
|
||||||
print(p)
|
print(p)
|
||||||
print(p.value())
|
print(p.value())
|
||||||
|
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
Pin(Pin.cpu.A0, mode=Pin.IN)
|
Pin(Pin.cpu.C6, mode=Pin.IN)
|
||||||
A0
|
C6
|
||||||
0
|
6
|
||||||
0
|
2
|
||||||
Pin(Pin.cpu.A0, mode=Pin.IN, pull=Pin.PULL_UP)
|
Pin(Pin.cpu.C6, mode=Pin.IN, pull=Pin.PULL_UP)
|
||||||
1
|
1
|
||||||
Pin(Pin.cpu.A0, mode=Pin.IN, pull=Pin.PULL_DOWN)
|
Pin(Pin.cpu.C6, mode=Pin.IN, pull=Pin.PULL_DOWN)
|
||||||
0
|
0
|
||||||
0
|
0
|
||||||
1
|
1
|
||||||
|
|
|
@ -27,14 +27,10 @@ print((pyb.millis() - start) // 5) # should print 3
|
||||||
pyb.disable_irq()
|
pyb.disable_irq()
|
||||||
pyb.enable_irq()
|
pyb.enable_irq()
|
||||||
|
|
||||||
print(pyb.freq())
|
|
||||||
|
|
||||||
print(pyb.have_cdc())
|
print(pyb.have_cdc())
|
||||||
|
|
||||||
pyb.hid((0, 0, 0, 0)) # won't do anything
|
pyb.hid((0, 0, 0, 0)) # won't do anything
|
||||||
|
|
||||||
pyb.rng()
|
|
||||||
|
|
||||||
pyb.sync()
|
pyb.sync()
|
||||||
|
|
||||||
print(len(pyb.unique_id()))
|
print(len(pyb.unique_id()))
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
3
|
3
|
||||||
3
|
3
|
||||||
(168000000, 168000000, 42000000, 84000000)
|
|
||||||
True
|
True
|
||||||
12
|
12
|
||||||
|
|
|
@ -0,0 +1,11 @@
|
||||||
|
# test pyb module on F405 MCUs
|
||||||
|
|
||||||
|
import os, pyb
|
||||||
|
|
||||||
|
if not 'STM32F405' in os.uname().machine:
|
||||||
|
print('SKIP')
|
||||||
|
import sys
|
||||||
|
sys.exit()
|
||||||
|
|
||||||
|
print(pyb.freq())
|
||||||
|
print(type(pyb.rng()))
|
|
@ -0,0 +1,2 @@
|
||||||
|
(168000000, 168000000, 42000000, 84000000)
|
||||||
|
<class 'int'>
|
|
@ -0,0 +1,10 @@
|
||||||
|
# test pyb module on F411 MCUs
|
||||||
|
|
||||||
|
import os, pyb
|
||||||
|
|
||||||
|
if not 'STM32F411' in os.uname().machine:
|
||||||
|
print('SKIP')
|
||||||
|
import sys
|
||||||
|
sys.exit()
|
||||||
|
|
||||||
|
print(pyb.freq())
|
|
@ -0,0 +1 @@
|
||||||
|
(96000000, 96000000, 24000000, 48000000)
|
|
@ -7,7 +7,7 @@ print(rtc)
|
||||||
|
|
||||||
# make sure that 1 second passes correctly
|
# make sure that 1 second passes correctly
|
||||||
rtc.datetime((2014, 1, 1, 1, 0, 0, 0, 0))
|
rtc.datetime((2014, 1, 1, 1, 0, 0, 0, 0))
|
||||||
pyb.delay(1001)
|
pyb.delay(1002)
|
||||||
print(rtc.datetime()[:7])
|
print(rtc.datetime()[:7])
|
||||||
|
|
||||||
def set_and_print(datetime):
|
def set_and_print(datetime):
|
||||||
|
|
Loading…
Reference in New Issue