Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
R
rtfm-app
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
Samuel Karlsson
rtfm-app
Commits
163eea59
Commit
163eea59
authored
7 years ago
by
Samuel Karlsson
Browse files
Options
Downloads
Patches
Plain Diff
bare5: task 1
parent
1d7474a3
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
examples/.bare5.rs.swp
+0
-0
0 additions, 0 deletions
examples/.bare5.rs.swp
examples/bare4.rs
+2
-2
2 additions, 2 deletions
examples/bare4.rs
examples/bare5.rs
+21
-3
21 additions, 3 deletions
examples/bare5.rs
with
23 additions
and
5 deletions
examples/.bare5.rs.swp
0 → 100644
+
0
−
0
View file @
163eea59
File added
This diff is collapsed.
Click to expand it.
examples/bare4.rs
+
2
−
2
View file @
163eea59
...
@@ -27,8 +27,8 @@ use address::*;
...
@@ -27,8 +27,8 @@ use address::*;
#[inline(always)]
#[inline(always)]
fn
read_u32
(
addr
:
u32
)
->
u32
{
fn
read_u32
(
addr
:
u32
)
->
u32
{
//
unsafe { core::ptr::read_volatile(addr as *const _) }
unsafe
{
core
::
ptr
::
read_volatile
(
addr
as
*
const
_
)
}
core
::
ptr
::
read_volatile
(
addr
as
*
const
_
)
//
core::ptr::read_volatile(addr as *const _)
}
}
#[inline(always)]
#[inline(always)]
...
...
This diff is collapsed.
Click to expand it.
examples/bare5.rs
+
21
−
3
View file @
163eea59
...
@@ -126,6 +126,7 @@ fn main() {
...
@@ -126,6 +126,7 @@ fn main() {
idle
(
rcc
,
gpioa
);
idle
(
rcc
,
gpioa
);
}
}
// user application
// user application
fn
idle
(
rcc
:
&
mut
RCC
,
gpioa
:
&
mut
GPIOA
)
{
fn
idle
(
rcc
:
&
mut
RCC
,
gpioa
:
&
mut
GPIOA
)
{
let
rcc_copy
=
&
rcc
;
let
rcc_copy
=
&
rcc
;
...
@@ -140,18 +141,35 @@ fn idle(rcc: &mut RCC, gpioa: &mut GPIOA) {
...
@@ -140,18 +141,35 @@ fn idle(rcc: &mut RCC, gpioa: &mut GPIOA) {
// and alter the data output through the BSRR register
// and alter the data output through the BSRR register
// this is more efficient as the read register is not needed.
// this is more efficient as the read register is not needed.
let
gbh
:
u32
=
0x40000000
+
0x00020000
+
0x18
;
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)
write_u32
(
gbh
,
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)
//unsafe { ptr::write_volatile(self.value.get(), value)
write_u32
(
gbh
,
1
<<
(
5
+
16
));
wait
(
10_000
);
wait
(
10_000
);
}
}
fn
write_u32
(
addr
:
u32
,
val
:
u32
)
{
unsafe
{
core
::
ptr
::
write_volatile
(
addr
as
*
mut
_
,
val
);
}
}
fn
read_u32
(
addr
:
u32
)
->
u32
{
unsafe
{
core
::
ptr
::
read_volatile
(
addr
as
*
const
_
)
}
}
}
}
//
1. C l
ike API
//ike API
// In C the .h files are used for defining interfaces, like function signatures (prototypes),
// In C the .h files are used for defining interfaces, like function signatures (prototypes),
// structs and macros (but usually not the functions themselves)
// structs and macros (but usually not the functions themselves)
// here is a peripheral abstraction quite similar to what you would find in the .h files
// here is a peripheral abstraction quite similar to what you would find in the .h files
...
...
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