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
Tommy Andersson
e7020e_2021
Commits
fed46a06
Commit
fed46a06
authored
Mar 19, 2021
by
Tommy Andersson
Browse files
Options
Downloads
Patches
Plain Diff
getting pers example
parent
560e9492
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
+12
-6
12 additions, 6 deletions
examples/rtic_bare5.rs
with
12 additions
and
6 deletions
examples/rtic_bare5.rs
+
12
−
6
View file @
fed46a06
...
@@ -11,6 +11,7 @@
...
@@ -11,6 +11,7 @@
extern
crate
cortex_m
;
extern
crate
cortex_m
;
extern
crate
panic_semihosting
;
extern
crate
panic_semihosting
;
//use bitvec::prelude::*; <-- Might wont to look in to this.
// C like API...
// C like API...
mod
stm32f40x
{
mod
stm32f40x
{
...
@@ -58,7 +59,9 @@ mod stm32f40x {
...
@@ -58,7 +59,9 @@ mod stm32f40x {
impl
VolatileCell
<
u32
>
{
impl
VolatileCell
<
u32
>
{
#[inline(always)]
#[inline(always)]
pub
fn
modify
(
&
self
,
offset
:
u8
,
width
:
u8
,
value
:
u32
)
{
pub
fn
modify
(
&
self
,
offset
:
u8
,
width
:
u8
,
value
:
u32
)
{
// your code here
let
mut
value_mut
=
value
<<
32
-
width
;
value_mut
=
value_mut
>>
32
-
width
;
self
.write
(
value_mut
<<
offset
);
}
}
}
}
...
@@ -179,22 +182,25 @@ const APP: () = {
...
@@ -179,22 +182,25 @@ const APP: () = {
// test_modify();
// test_modify();
test_modify
();
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)
// alternatively to set the bit high we can
// alternatively to set the bit high we can
// read the value, or with PA5 (bit 5) and write back
// read the value, or with PA5 (bit 5) and write back
//
gpioa.ODR.write(gpioa.ODR.read() | (1 << 5));
gpioa
.ODR
.write
(
gpioa
.ODR
.read
()
|
(
1
<<
5
));
wait
(
10_000
);
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)
// alternatively to clear the bit we can
// alternatively to clear the bit we can
// read the value, mask out PA5 (bit 5) and write back
// read the value, mask out PA5 (bit 5) and write back
//
gpioa.ODR.write(gpioa.ODR.read() & !(1 << 5));
gpioa
.ODR
.write
(
gpioa
.ODR
.read
()
&
!
(
1
<<
5
));
wait
(
10_000
);
wait
(
10_000
);
}
}
}
}
...
@@ -241,6 +247,6 @@ const APP: () = {
...
@@ -241,6 +247,6 @@ const APP: () = {
// What if we could automatically generate that from Vendors specifications (SVD files)?
// What if we could automatically generate that from Vendors specifications (SVD files)?
// Wouldn't that be great?
// Wouldn't that be great?
//
//
//
** your answer here **
//
I got the first assert to work. But I don't understand the second. What are we supposed to do?
//
//
// Commit your answers (bare5_2)
// 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