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
3cf74dd0
Commit
3cf74dd0
authored
7 years ago
by
Per Lindgren
Browse files
Options
Downloads
Patches
Plain Diff
serial works (HCI wrong value)
parent
f0036d77
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/serial-echo.rs
+14
-13
14 additions, 13 deletions
examples/serial-echo.rs
with
14 additions
and
13 deletions
examples/serial-echo.rs
+
14
−
13
View file @
3cf74dd0
...
...
@@ -16,22 +16,23 @@ use f4::serial::Serial;
use
f4
::
stm32f4x
;
fn
main
()
{
//
let p = stm32f
30
x::Peripherals::take().unwrap();
let
p
=
stm32f
4
x
::
Peripherals
::
take
()
.unwrap
();
//
let mut flash = p.FLASH.constrain();
//
let mut rcc = p.RCC.constrain();
//
let mut gpioa = p.GPIOA.split(&mut rcc.ahb);
let
mut
flash
=
p
.FLASH
.constrain
();
let
mut
rcc
=
p
.RCC
.constrain
();
let
mut
gpioa
=
p
.GPIOA
.split
(
&
mut
rcc
.ahb
1
);
//
let clocks = rcc.cfgr.freeze(&mut flash.acr);
let
clocks
=
rcc
.cfgr
.freeze
(
&
mut
flash
.acr
);
//
let tx = gpioa.pa
9
.into_af7(&mut gpioa.moder, &mut gpioa.afr
h
);
//
let rx = gpioa.pa
10
.into_af7(&mut gpioa.moder, &mut gpioa.afr
h
);
let
tx
=
gpioa
.pa
2
.into_af7
(
&
mut
gpioa
.moder
,
&
mut
gpioa
.afr
l
);
let
rx
=
gpioa
.pa
3
.into_af7
(
&
mut
gpioa
.moder
,
&
mut
gpioa
.afr
l
);
// let serial = Serial::usart1(p.USART1, (tx, rx), 115_200.bps(), clocks, &mut rcc.apb2);
// let (mut tx, mut rx) = serial.split();
//let serial = Serial::usart2(p.USART2, (tx, rx), 115_200.bps(), clocks, &mut rcc.apb1);
let
serial
=
Serial
::
usart2
(
p
.USART2
,
(
tx
,
rx
),
57_600
.bps
(),
clocks
,
&
mut
rcc
.apb1
);
let
(
mut
tx
,
mut
rx
)
=
serial
.split
();
//
loop {
//
let byte = block!(rx.read()).unwrap();
//
block!(tx.write(byte)).ok();
//
}
loop
{
let
byte
=
block!
(
rx
.read
())
.unwrap
();
block!
(
tx
.write
(
byte
))
.ok
();
}
}
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