Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
E
e7020e_2020
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
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Mark Hakansson
e7020e_2020
Commits
a9158563
Commit
a9158563
authored
5 years ago
by
Per Lindgren
Browse files
Options
Downloads
Patches
Plain Diff
polish
parent
811cb636
No related branches found
No related tags found
No related merge requests found
Changes
4
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
Cargo.toml
+8
-0
8 additions, 0 deletions
Cargo.toml
README.md
+156
-71
156 additions, 71 deletions
README.md
examples/rtfm_blinky.rs
+14
-30
14 additions, 30 deletions
examples/rtfm_blinky.rs
examples/rtfm_blinky_msg.rs
+0
-65
0 additions, 65 deletions
examples/rtfm_blinky_msg.rs
with
178 additions
and
166 deletions
Cargo.toml
+
8
−
0
View file @
a9158563
...
@@ -62,6 +62,14 @@ required-features = ["rtfm"]
...
@@ -62,6 +62,14 @@ required-features = ["rtfm"]
name
=
"rtfm_itm_spawn"
name
=
"rtfm_itm_spawn"
required-features
=
[
"rtfm"
]
required-features
=
[
"rtfm"
]
[[example]]
name
=
"rtfm_schedule"
required-features
=
[
"rtfm"
]
[[example]]
name
=
"rtfm_blinky"
required-features
=
[
"rtfm"
]
[[example]]
[[example]]
name
=
"rtfm_blinky_msg1"
name
=
"rtfm_blinky_msg1"
required-features
=
[
"rtfm"
]
required-features
=
[
"rtfm"
]
...
...
This diff is collapsed.
Click to expand it.
README.md
+
156
−
71
View file @
a9158563
This diff is collapsed.
Click to expand it.
examples/rtfm_blinky.rs
+
14
−
30
View file @
a9158563
#![deny(unsafe_code)]
#![deny(unsafe_code)]
//
#![deny(warnings)]
#![deny(warnings)]
#![no_main]
#![no_main]
#![no_std]
#![no_std]
use
cortex_m
::
peripheral
::
DWT
;
use
cortex_m
::
peripheral
::
syst
::
SystClkSource
;
use
cortex_m_semihosting
::
hprintln
;
use
cortex_m_semihosting
::
hprintln
;
use
panic_halt
as
_
;
use
panic_halt
as
_
;
use
rtfm
::
cyccnt
::{
Instant
,
U32Ext
as
_
};
use
stm32f4xx_hal
::
stm32
;
use
stm32f4xx_hal
::
stm32
;
#[rtfm::app(device
=
stm32f4xx_hal::stm32,
monotonic
=
rtfm::cyccnt::CYCCNT,
peripherals
=
true
)]
#[rtfm::app(device
=
stm32f4xx_hal::stm32,
peripherals
=
true
)]
const
APP
:
()
=
{
const
APP
:
()
=
{
struct
Resources
{
struct
Resources
{
// late resources
// late resources
GPIOA
:
stm32
::
GPIOA
,
GPIOA
:
stm32
::
GPIOA
,
}
}
#[init
(schedule
=
[
toggle]
)
]
#[init]
fn
init
(
mut
cx
:
init
::
Context
)
->
init
::
LateResources
{
fn
init
(
cx
:
init
::
Context
)
->
init
::
LateResources
{
let
mut
core
=
cx
.core
;
let
mut
syst
=
cx
.core
.SYST
;
let
mut
device
=
cx
.device
;
let
device
=
cx
.device
;
// Initialize (enable) the monotonic timer (CYCCNT)
// configures the system timer to trigger a SysTick exception every second
core
.DCB
.enable_trace
();
syst
.set_clock_source
(
SystClkSource
::
Core
);
// required on Cortex-M7 devices that software lock the DWT (e.g. STM32F7)
syst
.set_reload
(
16_000_000
);
// period = 1s
DWT
::
unlock
();
syst
.enable_counter
();
core
.DWT
.enable_cycle_counter
();
syst
.enable_interrupt
();
// semantically, the monotonic timer is frozen at time "zero" during `init`
// NOTE do *not* call `Instant::now` in this context; it will return a nonsense value
let
now
=
cx
.start
;
// the start time of the system
// Schedule `toggle` to run 8e6 cycles (clock cycles) in the future
cx
.schedule
.toggle
(
now
+
8_000_000
.cycles
())
.unwrap
();
// power on GPIOA, RM0368 6.3.11
// power on GPIOA, RM0368 6.3.11
device
.RCC.ahb1enr
.modify
(|
_
,
w
|
w
.gpioaen
()
.set_bit
());
device
.RCC.ahb1enr
.modify
(|
_
,
w
|
w
.gpioaen
()
.set_bit
());
...
@@ -44,24 +36,16 @@ const APP: () = {
...
@@ -44,24 +36,16 @@ const APP: () = {
}
}
}
}
#[task(resources
=
[
GPIOA]
,
schedule
=
[
toggle
]
)]
#[task(
binds
=
SysTick,
resources
=
[
GPIOA]
)]
fn
toggle
(
cx
:
toggle
::
Context
)
{
fn
toggle
(
cx
:
toggle
::
Context
)
{
static
mut
TOGGLE
:
bool
=
false
;
static
mut
TOGGLE
:
bool
=
false
;
hprintln!
(
"
foo @
{:?}"
,
Instant
::
now
()
)
.unwrap
();
hprintln!
(
"
toggle
{:?}"
,
TOGGLE
)
.unwrap
();
if
*
TOGGLE
{
if
*
TOGGLE
{
cx
.resources.GPIOA.bsrr
.write
(|
w
|
w
.bs5
()
.set_bit
());
cx
.resources.GPIOA.bsrr
.write
(|
w
|
w
.bs5
()
.set_bit
());
}
else
{
}
else
{
cx
.resources.GPIOA.bsrr
.write
(|
w
|
w
.br5
()
.set_bit
());
cx
.resources.GPIOA.bsrr
.write
(|
w
|
w
.br5
()
.set_bit
());
}
}
*
TOGGLE
=
!*
TOGGLE
;
*
TOGGLE
=
!*
TOGGLE
;
cx
.schedule
.toggle
(
cx
.scheduled
+
8_000_000
.cycles
())
.unwrap
();
}
extern
"C"
{
fn
EXTI0
();
}
}
};
};
This diff is collapsed.
Click to expand it.
examples/rtfm_blinky_msg.rs
deleted
100644 → 0
+
0
−
65
View file @
811cb636
#![deny(unsafe_code)]
// #![deny(warnings)]
#![no_main]
#![no_std]
use
cortex_m
::
peripheral
::
DWT
;
use
cortex_m_semihosting
::
hprintln
;
use
panic_halt
as
_
;
use
rtfm
::
cyccnt
::{
Instant
,
U32Ext
as
_
};
use
stm32f4xx_hal
::
stm32
;
#[rtfm::app(device
=
stm32f4xx_hal::stm32,
monotonic
=
rtfm::cyccnt::CYCCNT,
peripherals
=
true
)]
const
APP
:
()
=
{
struct
Resources
{
// late resources
GPIOA
:
stm32
::
GPIOA
,
}
#[init(schedule
=
[
toggle]
)]
fn
init
(
mut
cx
:
init
::
Context
)
->
init
::
LateResources
{
let
mut
core
=
cx
.core
;
let
mut
device
=
cx
.device
;
// Initialize (enable) the monotonic timer (CYCCNT)
core
.DCB
.enable_trace
();
// required on Cortex-M7 devices that software lock the DWT (e.g. STM32F7)
DWT
::
unlock
();
core
.DWT
.enable_cycle_counter
();
// semantically, the monotonic timer is frozen at time "zero" during `init`
// NOTE do *not* call `Instant::now` in this context; it will return a nonsense value
let
now
=
cx
.start
;
// the start time of the system
// Schedule `toggle` to run 8e6 cycles (clock cycles) in the future
cx
.schedule
.toggle
(
now
+
8_000_000
.cycles
(),
true
)
.unwrap
();
// power on GPIOA, RM0368 6.3.11
device
.RCC.ahb1enr
.modify
(|
_
,
w
|
w
.gpioaen
()
.set_bit
());
// configure PA5 as output, RM0368 8.4.1
device
.GPIOA.moder
.modify
(|
_
,
w
|
w
.moder5
()
.bits
(
1
));
// pass on late resources
init
::
LateResources
{
GPIOA
:
device
.GPIOA
,
}
}
#[task(resources
=
[
GPIOA]
,
schedule
=
[
toggle
])]
fn
toggle
(
cx
:
toggle
::
Context
,
toggle
:
bool
)
{
hprintln!
(
"foo @ {:?}"
,
Instant
::
now
())
.unwrap
();
if
toggle
{
cx
.resources.GPIOA.bsrr
.write
(|
w
|
w
.bs5
()
.set_bit
());
}
else
{
cx
.resources.GPIOA.bsrr
.write
(|
w
|
w
.br5
()
.set_bit
());
}
cx
.schedule
.toggle
(
cx
.scheduled
+
8_000_000
.cycles
(),
!
toggle
)
.unwrap
();
}
extern
"C"
{
fn
EXTI0
();
}
};
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