Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
L
low-power-stm32f103c8
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
Per Lindgren
low-power-stm32f103c8
Commits
0941f758
Commit
0941f758
authored
6 years ago
by
Per
Browse files
Options
Downloads
Patches
Plain Diff
sleep with wakeup from true sleep mode
parent
0db730af
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
examples/sleep.rs
+11
-11
11 additions, 11 deletions
examples/sleep.rs
with
11 additions
and
11 deletions
examples/sleep.rs
+
11
−
11
View file @
0941f758
...
...
@@ -81,6 +81,9 @@ fn main() -> ! {
p
.NVIC
.enable
(
Interrupt
::
EXTI1
);
// enable gpioa (input mode on reset)
r
.RCC.ahb1enr
.modify
(|
_
,
w
|
w
.gpioaen
()
.set_bit
());
r
.GPIOA.pupdr
.modify
(|
_
,
w
|
w
.pupdr1
()
.pull_up
());
// SYSCFG.exti1 is PAx (0000) by reset
// enbable masking of EXTI line 1
r
.EXTI.imr
.modify
(|
_
,
w
|
w
.mr1
()
.set_bit
());
// trigger on falling edge
...
...
@@ -91,9 +94,12 @@ fn main() -> ! {
// p.NVIC.set_pending(Interrupt::EXTI1);
dbg_disable
();
asm
::
wfi
();
dbg_enable
();
loop
{
dbg_disable
();
asm
::
wfi
();
dbg_enable
();
asm
::
bkpt
();
}
// asm::bkpt();
loop
{}
}
...
...
@@ -122,7 +128,7 @@ use cortex_m::interrupt::Nr;
fn
exti1
()
{
// dbg_enable();
// asm::bkpt();
blink2
();
blink2
();
// it will take some time so bounces are likely gone
// // let's try to "fake" access to GPIOA
// // let g = stm32f40x::GPIOA {
...
...
@@ -132,13 +138,7 @@ fn exti1() {
// clear pending state
let
exti
=
unsafe
{
&*
stm32f40x
::
EXTI
::
ptr
()
};
exti
.imr
.modify
(|
_
,
w
|
w
.mr1
()
.clear_bit
());
exti
.pr
.reset
();
let
nvic
=
unsafe
{
&*
cortex_m
::
peripheral
::
NVIC
::
ptr
()
};
let
nr
=
Interrupt
::
EXTI1
.nr
();
unsafe
{
nvic
.icpr
[
usize
::
from
(
nr
/
32
)]
.write
(
1
<<
(
nr
%
32
))
};
unsafe
{
nvic
.icer
[
usize
::
from
(
nr
/
32
)]
.write
(
1
<<
(
nr
%
32
))
};
exti
.pr
.write
(|
w
|
w
.pr1
()
.set_bit
());
}
// define the hard fault handler
...
...
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