Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
stm32f4-hal
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Per Lindgren
stm32f4-hal
Commits
3462948c
Commit
3462948c
authored
Oct 15, 2018
by
Per Lindgren
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
serial-echo works
parent
5af5dcab
Pipeline
#67
failed with stages
in 57 seconds
Changes
8
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
144 additions
and
58 deletions
+144
-58
config
.cargo/config
+0
-1
.gdbinit
.gdbinit
+0
-16
launch.json
.vscode/launch.json
+105
-18
tasks.json
.vscode/tasks.json
+2
-2
Cargo.toml
Cargo.toml
+6
-6
Xargo.toml
Xargo.toml
+0
-6
serial-echo.rs
examples/serial-echo.rs
+22
-3
serial.rs
src/serial.rs
+9
-6
No files found.
.cargo/config
View file @
3462948c
...
...
@@ -4,7 +4,6 @@ rustflags = [
"-C", "link-arg=-Tlink.x",
"-C", "linker=arm-none-eabi-ld",
"-Z", "linker-flavor=ld",
"-Z", "thinlto=no",
]
[build]
...
...
.gdbinit
deleted
100644 → 0
View file @
5af5dcab
# target remote :3333
# monitor reset init
# monitor arm semihosting enable
# send captured ITM to the file /tmp/itm.log
# (the microcontroller SWO pin must be connected to the programmer SWO pin)
# 16000000 must match the core clock frequency
monitor tpiu config internal /tmp/itm.log uart off 16000000
# enable ITM port 0
monitor itm port 0 on
#load
#step
# monitor reset halt
# detach
.vscode/launch.json
View file @
3462948c
...
...
@@ -89,21 +89,9 @@
"name"
:
"c serial-dma-tx"
,
"executable"
:
"./target/thumbv7em-none-eabihf/debug/examples/serial-dma-tx"
,
"configFiles"
:
[
"interface/stlink.cfg"
,
"interface/stlink
-v2-1
.cfg"
,
"target/stm32f4x.cfg"
],
//
"swoConfig"
:
[
//
"enabled"
:
"true"
,
//
"swoFrequency"
:
"0"
,
//
"cpuFrequency"
:
"0"
,
//
"ports"
:
[
//
[
//
"number"
:
"0"
,
//
"label"
:
"0"
,
//
"format"
:
"console"
,
//
]
//
]
//
],
"cwd"
:
"${workspaceRoot}"
},
{
...
...
@@ -113,7 +101,7 @@
"name"
:
"c rtfm-serial-dma-tx"
,
"executable"
:
"./target/thumbv7em-none-eabihf/debug/examples/rtfm-serial-dma-tx"
,
"configFiles"
:
[
"interface/stlink.cfg"
,
"interface/stlink
-v2-1
.cfg"
,
"target/stm32f4x.cfg"
],
"cwd"
:
"${workspaceRoot}"
...
...
@@ -124,9 +112,8 @@
"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"
,
"interface/stlink
-2-1
.cfg"
,
"target/stm32f4x.cfg"
],
"cwd"
:
"${workspaceRoot}"
...
...
@@ -137,12 +124,112 @@
"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"
,
"interface/stlink-v2-1.cfg"
,
"target/stm32f4x.cfg"
],
"cwd"
:
"${workspaceRoot}"
},
{
"type"
:
"cortex-debug"
,
"request"
:
"launch"
,
"servertype"
:
"openocd"
,
"name"
:
"c hello (semihosting)"
,
"executable"
:
"./target/thumbv7em-none-eabihf/debug/examples/hello"
,
"postLaunchCommands"
:
[
"monitor arm semihosting enable"
],
"configFiles"
:
[
"interface/stlink-v2-1.cfg"
,
"target/stm32f4x.cfg"
],
"cwd"
:
"${workspaceRoot}"
},
{
"type"
:
"cortex-debug"
,
"request"
:
"launch"
,
"servertype"
:
"openocd"
,
"name"
:
"c hello_debug (itm)"
,
"executable"
:
"./target/thumbv7em-none-eabihf/debug/examples/hello_debug"
,
"configFiles"
:
[
"interface/stlink-v2-1.cfg"
,
"target/stm32f4x.cfg"
],
"postLaunchCommands"
:
[
"monitor arm semihosting enable"
],
"swoConfig"
:
{
"enabled"
:
true
,
"cpuFrequency"
:
16000000
,
"swoFrequency"
:
2000000
,
//
you
may
try
1000000
if
not
working
"source"
:
"probe"
,
"decoders"
:
[
{
"type"
:
"console"
,
"label"
:
"Name"
,
"port"
:
0
}
]
},
"cwd"
:
"${workspaceRoot}"
},
{
"type"
:
"cortex-debug"
,
"request"
:
"launch"
,
"servertype"
:
"openocd"
,
"name"
:
"c rtfm-blinky-systic"
,
"executable"
:
"./target/thumbv7em-none-eabihf/debug/examples/rtfm-blinky-systic"
,
"configFiles"
:
[
"interface/stlink-v2-1.cfg"
,
"target/stm32f4x.cfg"
],
"postLaunchCommands"
:
[
"monitor arm semihosting enable"
],
"swoConfig"
:
{
"enabled"
:
true
,
"cpuFrequency"
:
16000000
,
"swoFrequency"
:
2000000
,
//
you
may
try
1000000
if
not
working
"source"
:
"probe"
,
"decoders"
:
[
{
"type"
:
"console"
,
"label"
:
"Name"
,
"port"
:
0
}
]
},
"cwd"
:
"${workspaceRoot}"
},
{
"type"
:
"cortex-debug"
,
"request"
:
"launch"
,
"servertype"
:
"openocd"
,
"name"
:
"c serial-echo"
,
"executable"
:
"./target/thumbv7em-none-eabihf/debug/examples/serial-echo"
,
"configFiles"
:
[
"interface/stlink-v2-1.cfg"
,
"target/stm32f4x.cfg"
],
//
"postLaunchCommands"
:
[
//
"monitor tpiu config internal /tmp/itm.fifo uart off 16000000"
,
//
"monitor itm port 0 on"
//
"monitor arm semihosting enable"
,
//
],
"swoConfig"
:
{
"enabled"
:
true
,
"cpuFrequency"
:
16000000
,
"swoFrequency"
:
2000000
,
//
you
may
try
1000000
if
not
working
"source"
:
"probe"
,
"decoders"
:
[
{
"type"
:
"console"
,
"label"
:
"Name"
,
"port"
:
0
}
]
},
"cwd"
:
"${workspaceRoot}"
}
]
}
\ No newline at end of file
.vscode/tasks.json
View file @
3462948c
...
...
@@ -5,8 +5,8 @@
"tasks"
:
[
{
"type"
:
"shell"
,
"label"
:
"
x
argo build --examples"
,
"command"
:
"
x
argo build --examples"
,
"label"
:
"
c
argo build --examples"
,
"command"
:
"
c
argo build --examples"
,
"problemMatcher"
:
[
"$rustc"
],
...
...
Cargo.toml
View file @
3462948c
...
...
@@ -14,25 +14,25 @@ embedded-hal = "0.1.0"
nb
=
"0.1.0"
[dependencies.stm32f413]
version
=
"0.2.0"
features
=
["rt"]
#version = "0.2.0"
git
=
"https://gitlab.henriktjader.com/pln/stm32f413"
branch
=
"svd2rust0.12"
#path = "../stm32f413"
branch
=
"svd2rust0.12b"
[dependencies.cast]
default-features
=
false
version
=
"0.2.2"
[
dependencies.cortex-m-debug]
[dependencies.cortex-m-debug]
git
=
"https://gitlab.henriktjader.com/pln/cortex-m-debug.git"
version
=
"0.1.2"
branch
=
"cortex-m-4"
[dev-dependencies.stm32f413]
features
=
["rt"]
version
=
"0.2.0"
#
version = "0.2.0"
git
=
"https://gitlab.henriktjader.com/pln/stm32f413"
branch
=
"svd2rust0.12"
branch
=
"svd2rust0.12
b
"
#path = "../stm32f413"
[dev-dependencies.cortex-m-rt]
...
...
Xargo.toml
deleted
100644 → 0
View file @
5af5dcab
[dependencies.core]
stage
=
0
[dependencies.compiler_builtins]
features
=
["mem"]
stage
=
1
\ No newline at end of file
examples/serial-echo.rs
View file @
3462948c
//! 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`.
//! with serial terminal emulator like `minicom` or `moserial`.
//!
//! Serial settings:
//! Baud Rate: 115200
//!
//! Problems:
//! - Assumes processor to run at 16MHz. Beware `gdb > monitor reset init` might set
//! cpu to 64Mhz, wich gives 4 times higher Baud Rate
//! - Overflowing the serial input buffer will cause a panic.
#
!
[
deny
(
unsafe_code
)]
//#![deny(warnings)]
#
!
[
no_std
]
...
...
@@ -10,6 +19,8 @@ extern crate stm32f4x_hal as f4;
#[macro_use(block)]
extern
crate
nb
;
#[macro_use]
extern
crate
cortex_m_debug
;
use
f4
::
prelude
::
*
;
use
f4
::
serial
::
Serial
;
...
...
@@ -31,7 +42,15 @@ fn main() {
let
(
mut
tx
,
mut
rx
)
=
serial
.split
();
loop
{
let
byte
=
block!
(
rx
.read
())
.unwrap
();
block!
(
tx
.write
(
byte
))
.ok
();
ipln!
(
"wait"
);
//spln!("wait");
if
let
Ok
(
byte
)
=
block!
(
rx
.read
())
{
ipln!
(
"got {:?}"
,
byte
);
//spln!("got {:?}", byte);
block!
(
tx
.write
(
byte
))
.ok
();
}
else
{
ipln!
(
"buffer overflow"
);
//spln!("buffer overflow");
}
}
}
src/serial.rs
View file @
3462948c
...
...
@@ -5,15 +5,15 @@
//! - TX = PA2
//! - RX = PA3
//! - Interrupt = USART2
use
core
::
sync
::
atomic
::{
self
,
Ordering
};
use
core
::
ptr
;
use
core
::
marker
::{
PhantomData
,
Unsize
};
use
cast
::
u16
;
use
core
::
marker
::{
PhantomData
,
Unsize
};
use
core
::
ptr
;
use
core
::
sync
::
atomic
::{
self
,
Ordering
};
use
dma
::{
Static
,
Transfer
,
UsartRxStream
,
UsartTxStream
,
R
,
W
};
use
hal
::
serial
;
use
nb
;
use
stm32f4x
::{
USART1
,
USART2
,
USART6
};
use
dma
::{
Static
,
Transfer
,
UsartRxStream
,
UsartTxStream
,
R
,
W
};
// usart2
use
gpio
::
gpioa
::{
PA2
,
PA3
};
...
...
@@ -22,7 +22,7 @@ use gpio::gpioa::{PA2, PA3};
// use gpio::gpiod::{PD5, PD6, PD8, PD9};
// use gpio::gpioe::{PE0, PE1, PE15};
use
gpio
::
AF7
;
use
rcc
::{
APB1
,
APB2
,
Clocks
};
use
rcc
::{
Clocks
,
APB1
,
APB2
};
use
time
::
Bps
;
/// Interrupt event
...
...
@@ -44,7 +44,8 @@ pub enum Error {
Overrun
,
/// Parity check error
Parity
,
#[doc(hidden)]
_Extensible
,
#[doc(hidden)]
_Extensible
,
}
// FIXME these should be "closed" traits
...
...
@@ -216,6 +217,8 @@ macro_rules! hal {
}
else
if
isr
.nf
()
.bit_is_set
()
{
nb
::
Error
::
Other
(
Error
::
Noise
)
}
else
if
isr
.ore
()
.bit_is_set
()
{
// perhaps read the data so the error is cleared
unsafe
{
ptr
::
read_volatile
(
&
(
*
$USARTX
::
ptr
())
.dr
as
*
const
_
as
*
const
_
);}
nb
::
Error
::
Other
(
Error
::
Overrun
)
}
else
if
isr
.rxne
()
.bit_is_set
()
{
// NOTE(read_volatile) see `write_volatile` below
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment