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
04606f40
Commit
04606f40
authored
4 years ago
by
Carl Österberg
Browse files
Options
Downloads
Patches
Plain Diff
bare7_1
parent
ceb259fa
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
examples/rtic_bare6.rs
+1
-0
1 addition, 0 deletions
examples/rtic_bare6.rs
examples/rtic_bare7.rs
+15
-7
15 additions, 7 deletions
examples/rtic_bare7.rs
with
16 additions
and
7 deletions
examples/rtic_bare6.rs
+
1
−
0
View file @
04606f40
...
@@ -203,6 +203,7 @@ fn clock_out(rcc: &RCC, gpioc: &GPIOC) {
...
@@ -203,6 +203,7 @@ fn clock_out(rcc: &RCC, gpioc: &GPIOC) {
// `rcc.cfgr.sysclk(64.mhz()).pclk1(64.mhz()).pclk2(64.mhz()).freeze()`;
// `rcc.cfgr.sysclk(64.mhz()).pclk1(64.mhz()).pclk2(64.mhz()).freeze()`;
//
//
// ** your answer here **
// ** your answer here **
// pclk1 has max frequency of 42 mhz.
//
//
// `rcc.cfgr.sysclk(84.mhz()).pclk1(42.mhz()).pclk2(64.mhz()).freeze();`
// `rcc.cfgr.sysclk(84.mhz()).pclk1(42.mhz()).pclk2(64.mhz()).freeze();`
//
//
...
...
This diff is collapsed.
Click to expand it.
examples/rtic_bare7.rs
+
15
−
7
View file @
04606f40
...
@@ -11,23 +11,25 @@
...
@@ -11,23 +11,25 @@
use
panic_rtt_target
as
_
;
use
panic_rtt_target
as
_
;
use
rtic
::
cyccnt
::{
Instant
,
U32Ext
as
_
};
use
rtic
::
cyccnt
::{
Instant
,
U32Ext
as
_
};
use
rtt_target
::{
rprintln
,
rtt_init_print
};
use
rtt_target
::{
rprintln
,
rtt_init_print
};
use
stm32f4
::
stm32f411
::
GPIOA
;
use
stm32f4xx_hal
::
stm32
;
use
stm32f4xx_hal
::
stm32
;
use
stm32f4xx_hal
::{
use
stm32f4xx_hal
::{
gpio
::{
gpioa
::
PA5
,
Output
,
PushPull
},
gpio
::{
gpioa
::
PA5
,
Output
,
PushPull
},
prelude
::
*
,
prelude
::
*
,
};
};
;
use
embedded_hal
::
digital
::
v2
::{
OutputPin
,
ToggleableOutputPin
};
use
embedded_hal
::
digital
::
v2
::{
OutputPin
,
ToggleableOutputPin
};
const
OFFSET
:
u32
=
8_000_000
;
const
OFFSET
:
u32
=
8_000_000
;
#[rtic::app(device
=
stm32f4xx_hal::stm32,
monotonic
=
rtic::cyccnt::CYCCNT,
peripherals
=
true
)]
#[rtic::app(device
=
stm32f4xx_hal::stm32,
monotonic
=
rtic::cyccnt::CYCCNT,
peripherals
=
true
)]
const
APP
:
()
=
{
const
APP
:
()
=
{
//We only need the led pin
struct
Resources
{
struct
Resources
{
// late resources
// late resources
GPIOA
:
stm32
::
GPIOA
,
//
GPIOA: stm32::GPIOA,
//
led: PA5<Output<PushPull>>,
led
:
PA5
<
Output
<
PushPull
>>
,
}
}
#[init(schedule
=
[
toggle]
)]
#[init(schedule
=
[
toggle]
)]
fn
init
(
cx
:
init
::
Context
)
->
init
::
LateResources
{
fn
init
(
cx
:
init
::
Context
)
->
init
::
LateResources
{
...
@@ -54,8 +56,10 @@ const APP: () = {
...
@@ -54,8 +56,10 @@ const APP: () = {
device
.GPIOA.moder
.modify
(|
_
,
w
|
w
.moder5
()
.bits
(
1
));
device
.GPIOA.moder
.modify
(|
_
,
w
|
w
.moder5
()
.bits
(
1
));
// pass on late resources
// pass on late resources
// Get the specific pin and make it a push pull output
init
::
LateResources
{
init
::
LateResources
{
GPIOA
:
device
.GPIOA
,
//GPIOA: device.GPIOA,
led
:
device
.GPIOA
.split
()
.pa5
.into_push_pull_output
(),
}
}
}
}
...
@@ -67,17 +71,20 @@ const APP: () = {
...
@@ -67,17 +71,20 @@ const APP: () = {
}
}
}
}
#[task(resources
=
[
GPIOA
]
,
schedule
=
[
toggle
])]
#[task(resources
=
[
led
]
,
schedule
=
[
toggle
])]
fn
toggle
(
cx
:
toggle
::
Context
)
{
fn
toggle
(
cx
:
toggle
::
Context
)
{
static
mut
TOGGLE
:
bool
=
false
;
static
mut
TOGGLE
:
bool
=
false
;
rprintln!
(
"toggle @ {:?}"
,
Instant
::
now
());
rprintln!
(
"toggle @ {:?}"
,
Instant
::
now
());
//use the set high/low for push pull output
if
*
TOGGLE
{
if
*
TOGGLE
{
cx
.resources.GPIOA.bsrr
.write
(|
w
|
w
.bs5
()
.set_bit
());
cx
.resources.led
.set_high
()
.ok
();
}
else
{
}
else
{
cx
.resources.
GPIOA.bsrr
.write
(|
w
|
w
.br5
()
.set_bit
()
);
cx
.resources.
led
.set_low
()
.ok
(
);
}
}
*
TOGGLE
=
!*
TOGGLE
;
*
TOGGLE
=
!*
TOGGLE
;
cx
.schedule
.toggle
(
cx
.scheduled
+
OFFSET
.cycles
())
.unwrap
();
cx
.schedule
.toggle
(
cx
.scheduled
+
OFFSET
.cycles
())
.unwrap
();
}
}
...
@@ -97,6 +104,7 @@ fn _toggle_generic<E>(led: &mut dyn OutputPin<Error = E>, toggle: &mut bool) {
...
@@ -97,6 +104,7 @@ fn _toggle_generic<E>(led: &mut dyn OutputPin<Error = E>, toggle: &mut bool) {
*
toggle
=
!*
toggle
;
*
toggle
=
!*
toggle
;
}
}
fn
_toggleable_generic
<
E
>
(
led
:
&
mut
dyn
ToggleableOutputPin
<
Error
=
E
>
)
{
fn
_toggleable_generic
<
E
>
(
led
:
&
mut
dyn
ToggleableOutputPin
<
Error
=
E
>
)
{
led
.toggle
()
.ok
();
led
.toggle
()
.ok
();
}
}
...
...
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