Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
S
stm32f4-hal
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
Per Lindgren
stm32f4-hal
Commits
7e3b05d5
Commit
7e3b05d5
authored
7 years ago
by
Per Lindgren
Browse files
Options
Downloads
Patches
Plain Diff
blinky using systic delay
parent
0ba359bb
No related branches found
No related tags found
No related merge requests found
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
examples/blinky.rs
+6
-12
6 additions, 12 deletions
examples/blinky.rs
src/delay.rs
+1
-0
1 addition, 0 deletions
src/delay.rs
src/lib.rs
+1
-1
1 addition, 1 deletion
src/lib.rs
src/prelude.rs
+3
-3
3 additions, 3 deletions
src/prelude.rs
with
11 additions
and
16 deletions
examples/blinky.rs
+
6
−
12
View file @
7e3b05d5
...
@@ -8,14 +8,10 @@ extern crate cortex_m;
...
@@ -8,14 +8,10 @@ extern crate cortex_m;
extern
crate
stm32f4x_hal
as
f4
;
extern
crate
stm32f4x_hal
as
f4
;
use
f4
::
stm32f4x
;
use
f4
::
stm32f4x
;
//
use f
3::hal
::delay::Delay;
use
f
4
::
delay
::
Delay
;
use
f4
::
prelude
::
*
;
use
f4
::
prelude
::
*
;
use
f4
::
led
::
Led
;
use
f4
::
led
::
Led
;
fn
wait
(
v
:
u32
)
{
for
_
in
0
..
v
{}
}
fn
main
()
{
fn
main
()
{
let
cp
=
cortex_m
::
Peripherals
::
take
()
.unwrap
();
let
cp
=
cortex_m
::
Peripherals
::
take
()
.unwrap
();
let
dp
=
stm32f4x
::
Peripherals
::
take
()
.unwrap
();
let
dp
=
stm32f4x
::
Peripherals
::
take
()
.unwrap
();
...
@@ -27,19 +23,17 @@ fn main() {
...
@@ -27,19 +23,17 @@ fn main() {
// // clock configuration using the default settings (all clocks run at 8 MHz)
// // clock configuration using the default settings (all clocks run at 8 MHz)
//let clocks = rcc.cfgr.freeze(&mut flash.acr);
//let clocks = rcc.cfgr.freeze(&mut flash.acr);
// // TRY this alternate clock configuration (all clocks run at 16 MHz)
// // TRY this alternate clock configuration (all clocks run at 16 MHz)
// //
let clocks = rcc.cfgr.sysclk(16.mhz()).freeze(&mut flash.acr);
let
clocks
=
rcc
.cfgr
.sysclk
(
16
.mhz
())
.freeze
(
&
mut
flash
.acr
);
let
mut
led
:
Led
=
gpioa
let
mut
led
:
Led
=
gpioa
.pa5
.pa5
.into_push_pull_output
(
&
mut
gpioa
.moder
,
&
mut
gpioa
.otyper
)
.into_push_pull_output
(
&
mut
gpioa
.moder
,
&
mut
gpioa
.otyper
)
.into
();
.into
();
//
let mut delay = Delay::new(cp.SYST, clocks);
let
mut
delay
=
Delay
::
new
(
cp
.SYST
,
clocks
);
loop
{
loop
{
led
.on
();
led
.on
();
wait
(
10000
);
delay
.delay_ms
(
1_000_u16
);
// delay.delay_ms(1_000_u16);
led
.off
();
led
.off
();
wait
(
10000
);
delay
.delay_ms
(
1_000_u16
);
// delay.delay_ms(1_000_u16);
}
}
}
}
This diff is collapsed.
Click to expand it.
src/delay.rs
+
1
−
0
View file @
7e3b05d5
...
@@ -15,6 +15,7 @@ pub struct Delay {
...
@@ -15,6 +15,7 @@ pub struct Delay {
impl
Delay
{
impl
Delay
{
/// Configures the system timer (SysTick) as a delay provider
/// Configures the system timer (SysTick) as a delay provider
/// Uses the Core clock
pub
fn
new
(
mut
syst
:
SYST
,
clocks
:
Clocks
)
->
Self
{
pub
fn
new
(
mut
syst
:
SYST
,
clocks
:
Clocks
)
->
Self
{
syst
.set_clock_source
(
SystClkSource
::
Core
);
syst
.set_clock_source
(
SystClkSource
::
Core
);
...
...
This diff is collapsed.
Click to expand it.
src/lib.rs
+
1
−
1
View file @
7e3b05d5
...
@@ -28,7 +28,7 @@ extern crate embedded_hal as hal;
...
@@ -28,7 +28,7 @@ extern crate embedded_hal as hal;
extern
crate
nb
;
extern
crate
nb
;
pub
extern
crate
stm32f413
as
stm32f4x
;
pub
extern
crate
stm32f413
as
stm32f4x
;
//
pub mod delay;
pub
mod
delay
;
pub
mod
flash
;
pub
mod
flash
;
pub
mod
gpio
;
pub
mod
gpio
;
// pub mod i2c;
// pub mod i2c;
...
...
This diff is collapsed.
Click to expand it.
src/prelude.rs
+
3
−
3
View file @
7e3b05d5
//! Prelude
//! Prelude
pub
use
gpio
::
GpioExt
as
_stm32f
30
x_hal_gpio_GpioExt
;
pub
use
gpio
::
GpioExt
as
_stm32f
4
x_hal_gpio_GpioExt
;
pub
use
hal
::
prelude
::
*
;
pub
use
hal
::
prelude
::
*
;
pub
use
rcc
::
RccExt
as
_stm32f4x_hal_rcc_RccExt
;
pub
use
rcc
::
RccExt
as
_stm32f4x_hal_rcc_RccExt
;
//
pub use time::U32Ext as _stm32f
30
x_hal_time_U32Ext;
pub
use
time
::
U32Ext
as
_stm32f
4
x_hal_time_U32Ext
;
pub
use
flash
::
FlashExt
as
_stm32f
30
x_hal_flash_FlashExt
;
pub
use
flash
::
FlashExt
as
_stm32f
4
x_hal_flash_FlashExt
;
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