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
Johannes Sjölund
stm32f4-hal
Commits
5af5dcab
Commit
5af5dcab
authored
7 years ago
by
Per Lindgren
Browse files
Options
Downloads
Patches
Plain Diff
rtfm examples
parent
32347613
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
.vscode/launch.json
+14
-0
14 additions, 0 deletions
.vscode/launch.json
examples/rtfm-serial-dma-rx.rs
+88
-0
88 additions, 0 deletions
examples/rtfm-serial-dma-rx.rs
examples/serial-dma-rx.rs
+5
-0
5 additions, 0 deletions
examples/serial-dma-rx.rs
with
107 additions
and
0 deletions
.vscode/launch.json
+
14
−
0
View file @
5af5dcab
...
...
@@ -124,6 +124,20 @@
"servertype"
:
"openocd"
,
"name"
:
"c serial-dma-rx"
,
"executable"
:
"./target/thumbv7em-none-eabihf/debug/examples/serial-dma-rx"
,
//
"debugger_args"
:
"so .gdbint"
,
"configFiles"
:
[
"interface/stlink.cfg"
,
"target/stm32f4x.cfg"
],
"cwd"
:
"${workspaceRoot}"
},
{
"type"
:
"cortex-debug"
,
"request"
:
"launch"
,
"servertype"
:
"openocd"
,
"name"
:
"c rtfm-serial-dma-rx"
,
"executable"
:
"./target/thumbv7em-none-eabihf/debug/examples/rtfm-serial-dma-rx"
,
//
"debugger_args"
:
"so .gdbint"
,
"configFiles"
:
[
"interface/stlink.cfg"
,
"target/stm32f4x.cfg"
...
...
This diff is collapsed.
Click to expand it.
examples/rtfm-serial-dma-rx.rs
0 → 100644
+
88
−
0
View file @
5af5dcab
//! Serial interface echo server
//!
//! In this example every received byte will be sent back to the sender. You can test this example
//! with serial terminal emulator like `minicom`.
//!
//!
#![deny(unsafe_code)]
//#![deny(warnings)]
#![feature(proc_macro)]
#![no_std]
#[macro_use(singleton)]
extern
crate
cortex_m
;
extern
crate
cortex_m_rtfm
as
rtfm
;
extern
crate
stm32f4x_hal
as
hal
;
use
hal
::
prelude
::
*
;
use
hal
::
serial
::{
Rx
,
Serial
,
Tx
};
use
hal
::
dma
::
Event
;
use
hal
::
stm32f4x
;
use
rtfm
::{
app
,
Threshold
};
use
cortex_m
::
asm
;
app!
{
device
:
stm32f4x
,
resources
:
{
static
X
:
u32
;
// static CB: CircBuffer<[u8; 8], dma1::S6<C5>>;
},
tasks
:
{
DMA1_STREAM6
:
{
path
:
tx
,
resources
:
[
X
]
},
DMA1_STREAM5
:
{
path
:
rx
,
resources
:
[
X
]
}
}
}
fn
init
(
p
:
init
::
Peripherals
)
->
init
::
LateResources
{
let
mut
flash
=
p
.device.FLASH
.constrain
();
let
mut
rcc
=
p
.device.RCC
.constrain
();
let
mut
gpioa
=
p
.device.GPIOA
.split
(
&
mut
rcc
.ahb1
);
let
streams
=
p
.device.DMA1
.split
(
&
mut
rcc
.ahb1
);
let
mut
tx_stream
=
streams
.1
.into_channel4
();
// S6<C4>
let
mut
rx_stream
=
streams
.0
.into_channel4
();
// S5<C4>
let
clocks
=
rcc
.cfgr
.freeze
(
&
mut
flash
.acr
);
let
tx
=
gpioa
.pa2
.into_af7
(
&
mut
gpioa
.moder
,
&
mut
gpioa
.afrl
);
let
rx
=
gpioa
.pa3
.into_af7
(
&
mut
gpioa
.moder
,
&
mut
gpioa
.afrl
);
let
mut
serial
=
Serial
::
usart2
(
p
.device.USART2
,
(
tx
,
rx
),
115_200
.bps
(),
clocks
,
&
mut
rcc
.apb1
,
);
let
(
tx
,
rx
)
=
serial
.split
();
//tx_stream.listen(Event::TransferComplete);
rx_stream
.listen
(
Event
::
TransferComplete
);
let
buf
=
singleton!
(:
[
u8
;
8
]
=
[
0
;
8
])
.unwrap
();
let
_
=
tx
.write_all
(
tx_stream
,
b"The quick brown fox"
);
init
::
LateResources
{
X
:
0
}
}
fn
idle
()
->
!
{
// sleep
loop
{
// rtfm::wfi();
}
}
fn
tx
(
_
:
&
mut
Threshold
,
mut
r
:
DMA1_STREAM6
::
Resources
)
{
asm
::
bkpt
();
}
fn
rx
(
_
:
&
mut
Threshold
,
mut
r
:
DMA1_STREAM5
::
Resources
)
{
asm
::
bkpt
();
}
This diff is collapsed.
Click to expand it.
examples/serial-dma-rx.rs
+
5
−
0
View file @
5af5dcab
...
...
@@ -8,6 +8,8 @@
#[macro_use(singleton)]
extern
crate
cortex_m
;
#[macro_use]
extern
crate
cortex_m_debug
;
extern
crate
stm32f4x_hal
as
f4
;
use
cortex_m
::
asm
;
...
...
@@ -16,6 +18,8 @@ use f4::serial::Serial;
use
f4
::
stm32f4x
;
fn
main
()
{
ipln!
(
"serial-dma-rx"
);
let
p
=
stm32f4x
::
Peripherals
::
take
()
.unwrap
();
let
mut
flash
=
p
.FLASH
.constrain
();
...
...
@@ -35,6 +39,7 @@ fn main() {
let
buf
=
singleton!
(:
[
u8
;
8
]
=
[
0
;
8
])
.unwrap
();
let
(
_buf
,
_c
,
_rx
)
=
rx
.read_exact
(
rx_stream
,
buf
)
.wait
();
ipln!
(
"{:?}"
,
_buf
);
asm
::
bkpt
();
}
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