Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
E
e7020e_2019
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
Anton
e7020e_2019
Commits
903f20ef
Commit
903f20ef
authored
6 years ago
by
anttib-5
Browse files
Options
Downloads
Patches
Plain Diff
bare5_2
parent
73257721
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/bare5.rs
+19
-13
19 additions, 13 deletions
examples/bare5.rs
with
19 additions
and
13 deletions
examples/bare5.rs
+
19
−
13
View file @
903f20ef
...
@@ -174,7 +174,7 @@ fn main() -> ! {
...
@@ -174,7 +174,7 @@ fn main() -> ! {
let
rcc
=
unsafe
{
&
mut
*
RCC
::
get
()
};
// get the reference to RCC in memory
let
rcc
=
unsafe
{
&
mut
*
RCC
::
get
()
};
// get the reference to RCC in memory
let
gpioa
=
unsafe
{
&
mut
*
GPIOA
::
get
()
};
// get the reference to GPIOA in memory
let
gpioa
=
unsafe
{
&
mut
*
GPIOA
::
get
()
};
// get the reference to GPIOA in memory
//
test(); // uncomment to run test
test
();
// uncomment to run test
idle
(
rcc
,
gpioa
);
idle
(
rcc
,
gpioa
);
loop
{}
loop
{}
}
}
...
@@ -182,27 +182,33 @@ fn main() -> ! {
...
@@ -182,27 +182,33 @@ fn main() -> ! {
// user application
// user application
fn
idle
(
rcc
:
&
mut
RCC
,
gpioa
:
&
mut
GPIOA
)
{
fn
idle
(
rcc
:
&
mut
RCC
,
gpioa
:
&
mut
GPIOA
)
{
// power on GPIOA
// power on GPIOA
let
r
=
rcc
.AHB1ENR
.read
();
// read
// let r = rcc.AHB1ENR.read(); // read
rcc
.AHB1ENR
.write
(
r
|
1
<<
(
0
));
// set enable
// rcc.AHB1ENR.write(r | 1 << (0)); // set enable
rcc
.AHB1ENR
.modify
(
0
,
1
,
0b1
);
// configure PA5 as output
// configure PA5 as output
let
r
=
gpioa
.MODER
.read
()
&
!
(
0b11
<<
(
5
*
2
));
// read and mask
gpioa
.MODER
.modify
(
5
*
2
,
2
,
0b01
);
gpioa
.MODER
.write
(
r
|
0b01
<<
(
5
*
2
));
// set output mode
// let r = gpioa.MODER.read() & !(0b11 << (5 * 2)); // read and mask
// gpioa.MODER.write(r | 0b01 << (5 * 2)); // set output mode
loop
{
loop
{
// set PA5 high
// set PA5 high
// gpioa.BSRRH.write(1 << 5); // set bit, output hight (turn on led)
// gpioa.BSRRH.write(1 << 5); // set bit, output hight (turn on led)
gpioa
.ODR
.write
(
gpioa
.ODR
.read
()
|
(
1
<<
5
));
// gpioa.ODR.write(gpioa.ODR.read() | (1 << 5));
gpioa
.ODR
.modify
(
5
,
1
,
0b1
);
wait
(
10_000
);
wait
(
1_119_982
);
// wait(10_000);
// set PA5 low
// set PA5 low
// gpioa.BSRRL.write(1 << 5); // clear bit, output low (turn off led)
// gpioa.BSRRL.write(1 << 5); // clear bit, output low (turn off led)
gpioa
.ODR
.write
(
gpioa
.ODR
.read
()
&
!
(
1
<<
5
));
// gpioa.ODR.write(gpioa.ODR.read() & !(1 << 5));
wait
(
10_000
);
gpioa
.ODR
.modify
(
5
,
1
,
0b0
);
// wait(10_000);
wait
(
1_119_982
);
}
}
}
}
// 0. Build and run the application.
// 0. Build and run the application.
//
//
// > cargo build --example bare5
// > cargo build --example bare5
...
...
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