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
Anton Johansson
e7020e_2021
Commits
772e94c5
Commit
772e94c5
authored
4 years ago
by
Anton
Browse files
Options
Downloads
Patches
Plain Diff
bare5_2
parent
9817a47a
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/rtic_bare5.rs
+20
-6
20 additions, 6 deletions
examples/rtic_bare5.rs
with
20 additions
and
6 deletions
examples/rtic_bare5.rs
+
20
−
6
View file @
772e94c5
...
...
@@ -59,6 +59,16 @@ mod stm32f40x {
#[inline(always)]
pub
fn
modify
(
&
self
,
offset
:
u8
,
width
:
u8
,
value
:
u32
)
{
// your code here
let
current
=
self
.read
();
let
mut
mask
=
0
;
for
_
in
0
..
width
{
mask
=
(
mask
<<
1
|
1
);
}
//mask = mask << offset;
let
test
=
(
current
&
!
(
mask
<<
offset
));
let
test2
=
((
value
&
(
mask
))
<<
offset
);
let
modified
=
(
current
&
!
(
mask
<<
offset
))
|
((
value
&
(
mask
))
<<
offset
);
self
.write
(
modified
);
}
}
...
...
@@ -170,12 +180,16 @@ const APP: () = {
let
gpioa
=
unsafe
{
&
mut
*
GPIOA
::
get
()
};
// get the reference to GPIOA in memory
// power on GPIOA
let
r
=
rcc
.AHB1ENR
.read
();
// read
rcc
.AHB1ENR
.write
(
r
|
1
<<
(
0
));
// set enable
// let r = rcc.AHB1ENR.read(); // read
// rcc.AHB1ENR.write(r | 1 << (0)); // set enable
rcc
.AHB1ENR
.modify
(
0
,
1
,
1
);
// configure PA5 as output
let
r
=
gpioa
.MODER
.read
()
&
!
(
0b11
<<
(
5
*
2
));
// read and mask
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
gpioa
.MODER
.modify
(
5
*
2
,
2
,
0b01
);
//test_modify();
...
...
@@ -241,6 +255,6 @@ const APP: () = {
// What if we could automatically generate that from Vendors specifications (SVD files)?
// Wouldn't that be great?
//
//
** your answer here **
//
Yes.
//
// Commit your answers (bare5_2)
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