Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
N
nucleo-64-rtfm
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
Model registry
Operate
Environments
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
Per Lindgren
nucleo-64-rtfm
Commits
5ff57e48
Commit
5ff57e48
authored
7 years ago
by
Per Lindgren
Browse files
Options
Downloads
Patches
Plain Diff
nested examples
parent
bed76109
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/nested_new.rs
+108
-0
108 additions, 0 deletions
examples/nested_new.rs
with
108 additions
and
0 deletions
examples/nested_new.rs
0 → 100644
+
108
−
0
View file @
5ff57e48
//! Nesting claims and how the preemption threshold works
//!
//! If you run this program you'll hit the breakpoints as indicated by the
//! letters in the comments: A, then B, then C, etc.
#![deny(unsafe_code)]
#![feature(proc_macro)]
#![no_std]
extern
crate
cortex_m_rtfm
as
rtfm
;
extern
crate
stm32f40x
;
use
stm32f40x
::
Interrupt
;
use
rtfm
::{
app
,
Resource
,
Threshold
};
app!
{
device
:
stm32f40x
,
resources
:
{
static
LOW
:
u64
=
0
;
static
HIGH
:
u64
=
0
;
},
tasks
:
{
EXTI0
:
{
path
:
exti0
,
priority
:
1
,
resources
:
[
LOW
,
HIGH
],
},
EXTI1
:
{
path
:
exti1
,
priority
:
2
,
resources
:
[
LOW
],
},
EXTI2
:
{
path
:
exti2
,
priority
:
3
,
resources
:
[
HIGH
],
},
EXTI3
:
{
path
:
exti0_new_stub
,
priority
:
1
,
resources
:
[
LOW
,
HIGH
],
},
},
}
fn
init
(
_p
:
init
::
Peripherals
,
_r
:
init
::
Resources
)
{}
#[inline(never)]
fn
idle
()
->
!
{
// A
rtfm
::
bkpt
();
// Sets task `exti0` as pending
//
// Because `exti0` has higher priority than `idle` it will be executed
// immediately
rtfm
::
set_pending
(
Interrupt
::
EXTI0
);
// ~> exti0
rtfm
::
set_pending
(
Interrupt
::
EXTI3
);
// ~> exti0
loop
{
rtfm
::
wfi
();
}
}
#[allow(non_snake_case)]
fn
exti0_new_stub
(
t
:
&
mut
Threshold
,
r
:
EXTI3
::
Resources
)
{
let
mut
b
=
false
;
// first claim
rtfm
::
bkpt
();
exti0_new
(
&
mut
b
,
t
,
r
)
}
#[allow(non_snake_case)]
fn
exti0_new
(
b
:
&
mut
bool
,
// shulde be a newtype later
t
:
&
mut
Threshold
,
EXTI3
::
Resources
{
mut
LOW
,
mut
HIGH
}:
EXTI3
::
Resources
,
)
{
LOW
.claim_mut_new
(
b
,
t
,
|
_low
,
b
,
t
|
{
rtfm
::
bkpt
();
HIGH
.claim_mut_new
(
b
,
t
,
|
_high
,
_
,
_
|
{
rtfm
::
bkpt
();
});
});
}
#[allow(non_snake_case)]
fn
exti0
(
t
:
&
mut
Threshold
,
EXTI0
::
Resources
{
mut
LOW
,
mut
HIGH
}:
EXTI0
::
Resources
)
{
rtfm
::
bkpt
();
LOW
.claim_mut
(
t
,
|
_low
,
t
|
{
rtfm
::
bkpt
();
HIGH
.claim_mut
(
t
,
|
_high
,
_
|
{
rtfm
::
bkpt
();
});
});
}
fn
exti1
(
_t
:
&
mut
Threshold
,
_r
:
EXTI1
::
Resources
)
{
rtfm
::
bkpt
();
}
fn
exti2
(
_t
:
&
mut
Threshold
,
_r
:
EXTI2
::
Resources
)
{
rtfm
::
bkpt
();
}
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