Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
micropython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
xpstem
micropython
Commits
ef5f2669
Commit
ef5f2669
authored
Jan 30, 2016
by
Damien George
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tests: For pyboard, add test for I2C error handling and recovery.
parent
db573082
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
54 additions
and
0 deletions
+54
-0
tests/pyb/i2c_error.py
tests/pyb/i2c_error.py
+50
-0
tests/pyb/i2c_error.py.exp
tests/pyb/i2c_error.py.exp
+4
-0
No files found.
tests/pyb/i2c_error.py
0 → 100644
View file @
ef5f2669
# test I2C errors, with polling (disabled irqs) and DMA
import
pyb
from
pyb
import
I2C
# init accelerometer
pyb
.
Accel
()
# get I2C bus
i2c
=
I2C
(
1
,
I2C
.
MASTER
)
# test polling mem_read
pyb
.
disable_irq
()
i2c
.
mem_read
(
1
,
76
,
0x0a
)
# should succeed
pyb
.
enable_irq
()
try
:
pyb
.
disable_irq
()
i2c
.
mem_read
(
1
,
77
,
0x0a
)
# should fail
except
OSError
as
e
:
pyb
.
enable_irq
()
print
(
repr
(
e
))
i2c
.
mem_read
(
1
,
76
,
0x0a
)
# should succeed
# test polling mem_write
pyb
.
disable_irq
()
i2c
.
mem_write
(
1
,
76
,
0x0a
)
# should succeed
pyb
.
enable_irq
()
try
:
pyb
.
disable_irq
()
i2c
.
mem_write
(
1
,
77
,
0x0a
)
# should fail
except
OSError
as
e
:
pyb
.
enable_irq
()
print
(
repr
(
e
))
i2c
.
mem_write
(
1
,
76
,
0x0a
)
# should succeed
# test DMA mem_read
i2c
.
mem_read
(
1
,
76
,
0x0a
)
# should succeed
try
:
i2c
.
mem_read
(
1
,
77
,
0x0a
)
# should fail
except
OSError
as
e
:
print
(
repr
(
e
))
i2c
.
mem_read
(
1
,
76
,
0x0a
)
# should succeed
# test DMA mem_write
i2c
.
mem_write
(
1
,
76
,
0x0a
)
# should succeed
try
:
i2c
.
mem_write
(
1
,
77
,
0x0a
)
# should fail
except
OSError
as
e
:
print
(
repr
(
e
))
i2c
.
mem_write
(
1
,
76
,
0x0a
)
# should succeed
tests/pyb/i2c_error.py.exp
0 → 100644
View file @
ef5f2669
OSError(5,)
OSError(5,)
OSError(5,)
OSError(5,)
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