Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
E
e7020e_2021
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
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Carl Österberg
e7020e_2021
Commits
9e68adc9
Commit
9e68adc9
authored
4 years ago
by
Carl Österberg
Browse files
Options
Downloads
Patches
Plain Diff
bare9_2
parent
d3c039b1
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
examples/rtic_bare8.rs
+2
-0
2 additions, 0 deletions
examples/rtic_bare8.rs
examples/rtic_bare9.rs
+33
-6
33 additions, 6 deletions
examples/rtic_bare9.rs
with
35 additions
and
6 deletions
examples/rtic_bare8.rs
+
2
−
0
View file @
9e68adc9
...
...
@@ -175,6 +175,7 @@ const APP: () = {
// How did the added tracing/instrumentation affect the behavior?
//
// ** your answer here **
// More error prone
//
// Commit your answer (bare8_3)
//
...
...
@@ -187,6 +188,7 @@ const APP: () = {
// Experiment a bit, what is the max length sequence you can receive without errors?
//
// ** your answer here **
// we got 25
//
// Commit your answer (bare8_4)
//
...
...
This diff is collapsed.
Click to expand it.
examples/rtic_bare9.rs
+
33
−
6
View file @
9e68adc9
...
...
@@ -8,6 +8,7 @@
#![no_std]
use
panic_rtt_target
as
_
;
use
stm32f4xx_hal
::
nb
::
block
;
use
stm32f4xx_hal
::{
prelude
::
*
,
...
...
@@ -24,6 +25,8 @@ const APP: () = {
// Late resources
TX
:
Tx
<
USART2
>
,
RX
:
Rx
<
USART2
>
,
RECV
:
i32
,
ERR
:
i32
,
}
// init runs in an interrupt free section
...
...
@@ -44,6 +47,9 @@ const APP: () = {
let
tx
=
gpioa
.pa2
.into_alternate_af7
();
let
rx
=
gpioa
.pa3
.into_alternate_af7
();
let
mut
errors
:
i32
=
0
;
let
mut
received
:
i32
=
0
;
let
mut
serial
=
Serial
::
usart2
(
device
.USART2
,
(
tx
,
rx
),
...
...
@@ -59,7 +65,7 @@ const APP: () = {
let
(
tx
,
rx
)
=
serial
.split
();
// Late resources
init
::
LateResources
{
TX
:
tx
,
RX
:
rx
}
init
::
LateResources
{
TX
:
tx
,
RX
:
rx
,
ERR
:
errors
,
RECV
:
received
}
}
// idle may be interrupted by other interrupts/tasks in the system
...
...
@@ -74,16 +80,36 @@ const APP: () = {
#[task(resources
=
[
TX]
,
priority
=
1
,
capacity
=
128
)]
fn
rx
(
cx
:
rx
::
Context
,
data
:
u8
)
{
let
tx
=
cx
.resources.TX
;
tx
.write
(
data
)
.unwrap
();
rprintln!
(
"data {}"
,
data
);
rprintln!
(
"data {:b}"
,
data
);
match
block!
(
tx
.write
(
data
))
{
Ok
(
_val
)
=>
{
rprintln!
(
"Ok {:b}"
,
data
);
}
Err
(
err
)
=>
{
rprintln!
(
"Error {:?}"
,
err
);
}
}
}
// Task bound to the USART2 interrupt.
#[task(binds
=
USART2,
priority
=
2
,
resources
=
[
RX]
,
spawn
=
[
rx
])]
#[task(binds
=
USART2,
priority
=
2
,
resources
=
[
RX
,
ERR,
RECV
]
,
spawn
=
[
rx
])]
fn
usart2
(
cx
:
usart2
::
Context
)
{
let
rx
=
cx
.resources.RX
;
let
data
=
rx
.read
()
.unwrap
();
cx
.spawn
.rx
(
data
)
.unwrap
();
let
received
=
cx
.resources.RECV
;
let
errors
=
cx
.resources.ERR
;
match
block!
(
rx
.read
())
{
Ok
(
byte
)
=>
{
*
received
+=
1
;
rprintln!
(
"Ok {:b} Nmbr {:?}"
,
byte
,
received
);
cx
.spawn
.rx
(
byte
)
.unwrap
();
}
Err
(
err
)
=>
{
*
errors
+=
1
;
rprintln!
(
"Error {:?} Nmbr {:?}"
,
err
,
errors
);
}
}
}
extern
"C"
{
...
...
@@ -149,6 +175,7 @@ const APP: () = {
// Were you able to crash it?
//
// ** your answer here **
// yes, couldnt handle 123
//
// Notice, the input tracing in `moserial` seems broken, and may loose data.
// So don't be alarmed if data is missing, its a GUI tool after all.
...
...
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