Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
B
bare-boyes
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
Fredrik Pettersson
bare-boyes
Commits
140426a5
There was an error fetching the commit references. Please try again later.
Commit
140426a5
authored
7 years ago
by
DevDoggo
Browse files
Options
Downloads
Patches
Plain Diff
Created write/read while using registry directly
parent
329c5022
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
compile.sh
+2
-1
2 additions, 1 deletion
compile.sh
examples/bare5.rs
+39
-5
39 additions, 5 deletions
examples/bare5.rs
gdb.sh
+2
-1
2 additions, 1 deletion
gdb.sh
with
43 additions
and
7 deletions
compile.sh
+
2
−
1
View file @
140426a5
...
...
@@ -6,4 +6,5 @@
#cargo build --target thumbv7em-none-eabihf --example bare2
#cargo build --target thumbv7em-none-eabihf --release --example bare2
#cargo build --target thumbv7em-none-eabihf --example bare3
cargo build
--target
thumbv7em-none-eabihf
--example
bare4
#cargo build --target thumbv7em-none-eabihf --example bare4
cargo build
--target
thumbv7em-none-eabihf
--example
bare5
This diff is collapsed.
Click to expand it.
examples/bare5.rs
+
39
−
5
View file @
140426a5
...
...
@@ -7,6 +7,8 @@
extern
crate
cortex_m
;
extern
crate
cortex_m_rt
;
extern
crate
cortex_m_debug
;
// C like API...
mod
stm32f40x
{
...
...
@@ -126,6 +128,27 @@ fn main() {
idle
(
rcc
,
gpioa
);
}
////////////////////// Fun API starts here
pub
const
G_BASE
:
u32
=
0x40000000
+
0x00020000
;
pub
const
GPIOA_MODER
:
u32
=
G_BASE
;
pub
const
GPIOA_BSRR
:
u32
=
G_BASE
+
0x18
;
fn
w_rite
(
addr
:
u32
,
val
:
u32
)
{
unsafe
{
core
::
ptr
::
write_volatile
(
addr
as
*
mut
_
,
val
);
}
}
fn
r_ead
(
addr
:
u32
)
->
u32
{
unsafe
{
core
::
ptr
::
read_volatile
(
addr
as
*
const
_
)
}
}
// user application
fn
idle
(
rcc
:
&
mut
RCC
,
gpioa
:
&
mut
GPIOA
)
{
let
rcc_copy
=
&
rcc
;
...
...
@@ -141,13 +164,24 @@ fn idle(rcc: &mut RCC, gpioa: &mut GPIOA) {
// this is more efficient as the read register is not needed.
loop
{
// set PA5 high
gpioa
.BSRRH
.write
(
1
<<
5
);
// set bit, output hight (turn on led)
w_rite
(
GPIOA_BSRR
,
1
<<
5
);
wait
(
10_000
);
// sprintln!("BOYE");
// ipln!("Boye!");
// set PA5 low
gpioa
.BSRRL
.write
(
1
<<
5
);
// clear bit, output low (turn off led)
w_rite
(
GPIOA_BSRR
,
1
<<
(
5
+
16
));
wait
(
10_000
);
// // set PA5 high
// gpioa.BSRRH.write(1 << 5); // set bit, output hight (turn on led)
// wait(10_000);
// // set PA5 low
// gpioa.BSRRL.write(1 << 5); // clear bit, output low (turn off led)
// wait(10_000);
}
}
...
...
This diff is collapsed.
Click to expand it.
gdb.sh
+
2
−
1
View file @
140426a5
...
...
@@ -7,4 +7,5 @@ TARGET=thumbv7em-none-eabihf
#arm-none-eabi-gdb target/$TARGET/debug/examples/bare2
#arm-none-eabi-gdb target/$TARGET/release/examples/bare2
#arm-none-eabi-gdb target/$TARGET/debug/examples/bare3
arm-none-eabi-gdb target/
$TARGET
/debug/examples/bare4
#arm-none-eabi-gdb target/$TARGET/debug/examples/bare4
arm-none-eabi-gdb target/
$TARGET
/debug/examples/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