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
Carl Österberg
e7020e_2021
Commits
222c5b4a
Commit
222c5b4a
authored
4 years ago
by
Carl Österberg
Browse files
Options
Downloads
Patches
Plain Diff
bare9_2
parent
9e68adc9
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
+27
-18
27 additions, 18 deletions
examples/rtic_bare9.rs
with
27 additions
and
18 deletions
examples/rtic_bare9.rs
+
27
−
18
View file @
222c5b4a
...
...
@@ -10,6 +10,7 @@
use
panic_rtt_target
as
_
;
use
stm32f4xx_hal
::
nb
::
block
;
use
stm32f4xx_hal
::{
prelude
::
*
,
serial
::{
config
::
Config
,
Event
,
Rx
,
Serial
,
Tx
},
...
...
@@ -77,36 +78,43 @@ 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
;
rprintln!
(
"data {:b}"
,
data
);
match
block!
(
tx
.write
(
data
))
{
Ok
(
_val
)
=>
{
rprintln!
(
"Ok {:b}"
,
data
);
}
Err
(
err
)
=>
{
rprintln!
(
"Error {:?}"
,
err
);
}
}
block!
(
tx
.write
(
data
))
.unwrap
();
//rprintln!("data {:b}", data);
}
// Task bound to the USART2 interrupt.
#[task(binds
=
USART2,
priority
=
2
,
resources
=
[
RX
,
ERR,
RECV
]
,
spawn
=
[
rx
])]
#[task(binds
=
USART2,
priority
=
3
,
resources
=
[
RX]
,
spawn
=
[
rx
,
traceing
])]
fn
usart2
(
cx
:
usart2
::
Context
)
{
let
rx
=
cx
.resources.RX
;
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
();
let
_res
=
cx
.spawn
.traceing
(
true
);
}
Err
(
_err
)
=>
{
let
_res
=
cx
.spawn
.traceing
(
false
);
}
}
}
// Handles prints
#[task(priority
=
1
,
resources
=
[
ERR,
RECV]
)]
fn
traceing
(
cx
:
traceing
::
Context
,
state
:
bool
)
{
let
received
=
cx
.resources.RECV
;
let
errors
=
cx
.resources.ERR
;
match
state
{
true
=>
{
*
received
+=
1
;
rprintln!
(
"Ok:s {:?}"
,
received
);
}
Err
(
err
)
=>
{
false
=>
{
*
errors
+=
1
;
rprintln!
(
"Error
{:?} Nmbr
{:?}"
,
err
,
errors
);
rprintln!
(
"Error
s
{:?}"
,
errors
);
}
}
...
...
@@ -114,6 +122,7 @@ const APP: () = {
extern
"C"
{
fn
EXTI0
();
fn
USART1
();
}
};
...
...
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