Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
M
micropython
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
card10
micropython
Commits
ef5f2669
Commit
ef5f2669
authored
9 years ago
by
Damien George
Browse files
Options
Downloads
Patches
Plain Diff
tests: For pyboard, add test for I2C error handling and recovery.
parent
db573082
Branches
master
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
tests/pyb/i2c_error.py
+50
-0
50 additions, 0 deletions
tests/pyb/i2c_error.py
tests/pyb/i2c_error.py.exp
+4
-0
4 additions, 0 deletions
tests/pyb/i2c_error.py.exp
with
54 additions
and
0 deletions
tests/pyb/i2c_error.py
0 → 100644
+
50
−
0
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
This diff is collapsed.
Click to expand it.
tests/pyb/i2c_error.py.exp
0 → 100644
+
4
−
0
View file @
ef5f2669
OSError(5,)
OSError(5,)
OSError(5,)
OSError(5,)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment