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
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Tommy Andersson
e7020e_2021
Commits
0998e941
Commit
0998e941
authored
4 years ago
by
Jonas Jacobsson
Committed by
Tommy Andersson
4 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Update rtic_bare9.rs
parent
81965df7
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
examples/rtic_bare9.rs
+40
-6
40 additions, 6 deletions
examples/rtic_bare9.rs
with
40 additions
and
6 deletions
examples/rtic_bare9.rs
+
40
−
6
View file @
0998e941
...
...
@@ -13,17 +13,23 @@ use stm32f4xx_hal::{
prelude
::
*
,
serial
::{
config
::
Config
,
Event
,
Rx
,
Serial
,
Tx
},
stm32
::
USART2
,
nb
::
block
,
};
use
rtic
::
app
;
use
rtt_target
::{
rprintln
,
rtt_init_print
};
#[app(device
=
stm32f4xx_hal::stm32,
peripherals
=
true
)]
const
APP
:
()
=
{
struct
Resources
{
// Late resources
TX
:
Tx
<
USART2
>
,
RX
:
Rx
<
USART2
>
,
#[init(
0
)]
fel
:
u32
,
#[init(
0
)]
corr
:
u32
,
}
// init runs in an interrupt free section
...
...
@@ -71,23 +77,51 @@ const APP: () = {
}
// capacity sets the size of the input buffer (# outstanding messages)
#[task(resources
=
[
TX]
,
priority
=
1
,
capacity
=
128
)]
#[task(resources
=
[
TX]
,
priority
=
2
,
capacity
=
128
)]
fn
rx
(
cx
:
rx
::
Context
,
data
:
u8
)
{
let
tx
=
cx
.resources.TX
;
tx
.write
(
data
)
.unwrap
();
}
#[task(priority
=
1
,resources
=
[
fel,corr]
)]
fn
trace
(
cx
:
trace
::
Context
,
worked
:
bool
,
data
:
u8
,){
match
worked
{
true
=>
{
*
cx
.resources.corr
+=
1
;
rprintln!
(
"Ok {:?}"
,
data
);
}
false
=>
{
*
cx
.resources.fel
+=
1
;
rprintln!
(
"some error"
);
}
}
rprintln!
(
"correct {}"
,
cx
.resources.corr
);
rprintln!
(
"errors {}"
,
cx
.resources.fel
);
rprintln!
(
"data {}"
,
data
);
}
// Task bound to the USART2 interrupt.
#[task(binds
=
USART2,
priority
=
2
,
resources
=
[
RX]
,
spawn
=
[
rx
])]
#[task(binds
=
USART2,
priority
=
3
,
resources
=
[
RX]
,
spawn
=
[
rx
,
trace
])]
fn
usart2
(
cx
:
usart2
::
Context
)
{
let
rx
=
cx
.resources.RX
;
let
data
=
rx
.read
()
.unwrap
();
let
data
;
match
(
rx
.read
())
{
Ok
(
byte
)
=>
{
data
=
byte
;
let
result
=
cx
.spawn
.trace
(
true
,
byte
);
}
Err
(
err
)
=>
{
data
=
0
;
rprintln!
(
"Error {:?}"
,
err
);
cx
.spawn
.trace
(
false
,
data
)
.unwrap
();
}
}
cx
.spawn
.rx
(
data
)
.unwrap
();
}
extern
"C"
{
fn
EXTI0
();
fn
USART1
();
}
};
...
...
@@ -148,7 +182,7 @@ const APP: () = {
//
// Were you able to crash it?
//
//
** your answer here **
//
Yes
//
// 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