Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
N
nucleo-64
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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Per Lindgren
nucleo-64
Commits
14a64be0
Commit
14a64be0
authored
Oct 19, 2017
by
Per
Browse files
Options
Downloads
Patches
Plain Diff
now using println, deny warnings
parent
7ea82ddd
No related branches found
No related tags found
No related merge requests found
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
.vscode/tasks.json
+6
-6
6 additions, 6 deletions
.vscode/tasks.json
examples/hello.rs
+3
-5
3 additions, 5 deletions
examples/hello.rs
examples/usart1.rs
+7
-35
7 additions, 35 deletions
examples/usart1.rs
src/gpio.rs
+1
-1
1 addition, 1 deletion
src/gpio.rs
src/lib.rs
+1
-1
1 addition, 1 deletion
src/lib.rs
with
18 additions
and
48 deletions
.vscode/tasks.json
+
6
−
6
View file @
14a64be0
...
@@ -25,11 +25,7 @@
...
@@ -25,11 +25,7 @@
"command"
:
"xargo build --example gpio"
,
"command"
:
"xargo build --example gpio"
,
"problemMatcher"
:
[
"problemMatcher"
:
[
"$rustc"
"$rustc"
],
]
"group"
:
{
"kind"
:
"build"
,
"isDefault"
:
true
}
},
},
{
{
"taskName"
:
"xargo build --example usart1"
,
"taskName"
:
"xargo build --example usart1"
,
...
@@ -37,7 +33,11 @@
...
@@ -37,7 +33,11 @@
"command"
:
"xargo build --example usart1"
,
"command"
:
"xargo build --example usart1"
,
"problemMatcher"
:
[
"problemMatcher"
:
[
"$rustc"
"$rustc"
]
],
"group"
:
{
"kind"
:
"build"
,
"isDefault"
:
true
}
},
},
{
{
"type"
:
"shell"
,
"type"
:
"shell"
,
...
...
This diff is collapsed.
Click to expand it.
examples/hello.rs
+
3
−
5
View file @
14a64be0
...
@@ -5,13 +5,10 @@
...
@@ -5,13 +5,10 @@
#![no_std]
#![no_std]
extern
crate
cortex_m_rtfm
as
rtfm
;
extern
crate
cortex_m_rtfm
as
rtfm
;
extern
crate
cortex_m_semihosting
as
semihosting
;
#[macro_use]
extern
crate
nucleo_64
;
extern
crate
nucleo_64
;
use
core
::
fmt
::
Write
;
use
rtfm
::
app
;
use
rtfm
::
app
;
use
semihosting
::
hio
;
app!
{
app!
{
device
:
nucleo_64
::
stm32f40x
,
device
:
nucleo_64
::
stm32f40x
,
...
@@ -20,8 +17,9 @@ app! {
...
@@ -20,8 +17,9 @@ app! {
fn
init
(
_p
:
init
::
Peripherals
)
{}
fn
init
(
_p
:
init
::
Peripherals
)
{}
fn
idle
()
->
!
{
fn
idle
()
->
!
{
w
rit
e
ln!
(
hio
::
hstdout
()
.unwrap
(),
"Hello,
S
world!"
)
.unwrap
()
;
p
ri
n
tln!
(
"Hello, world!"
);
rtfm
::
bkpt
();
loop
{
loop
{
rtfm
::
wfi
();
rtfm
::
wfi
();
}
}
...
...
This diff is collapsed.
Click to expand it.
examples/usart1.rs
+
7
−
35
View file @
14a64be0
...
@@ -4,8 +4,8 @@
...
@@ -4,8 +4,8 @@
//!
//!
//! PA2 (TX), PA3(RX) on the MCU is connected to the pin header CN3
//! PA2 (TX), PA3(RX) on the MCU is connected to the pin header CN3
//#![deny(unsafe_code)]
//#![deny(unsafe_code)]
//
#![deny(warnings)]
#![deny(warnings)]
#![allow(warnings)]
//
#![allow(warnings)]
#![feature(proc_macro)]
#![feature(proc_macro)]
#![no_std]
#![no_std]
...
@@ -13,16 +13,13 @@ extern crate cortex_m_rtfm as rtfm;
...
@@ -13,16 +13,13 @@ extern crate cortex_m_rtfm as rtfm;
extern
crate
cortex_m_semihosting
as
semihosting
;
extern
crate
cortex_m_semihosting
as
semihosting
;
#[macro_use]
#[macro_use]
extern
crate
nb
;
extern
crate
nb
;
#[macro_use]
extern
crate
nucleo_64
;
extern
crate
nucleo_64
;
extern
crate
stm32f40x
;
extern
crate
stm32f40x
;
//use nucleo_64::Serial;
use
nucleo_64
::
prelude
::
*
;
use
nucleo_64
::
time
::
Hertz
;
use
nucleo_64
::
time
::
Hertz
;
use
semihosting
::
hio
;
use
core
::
fmt
::
Write
;
use
rtfm
::
app
;
use
rtfm
::
app
;
use
core
::
ops
::
Deref
;
use
core
::
ptr
;
use
core
::
ptr
;
use
nucleo_64
::
apb1
;
use
nucleo_64
::
apb1
;
...
@@ -32,12 +29,12 @@ app! {
...
@@ -32,12 +29,12 @@ app! {
device
:
nucleo_64
::
stm32f40x
,
device
:
nucleo_64
::
stm32f40x
,
}
}
use
stm32f40x
::
{
gpioa
,
DMA1
,
USART1
,
USART2
,
USART3
,
usart6
,
GPIOA
,
GPIOB
,
RCC
}
;
use
stm32f40x
::
USART2
;
#[inline(never)]
#[inline(never)]
fn
init
(
p
:
init
::
Peripherals
)
{
fn
init
(
p
:
init
::
Peripherals
)
{
w
rit
e
ln!
(
hio
::
hstdout
()
.unwrap
(),
"Init!"
)
.unwrap
(
);
p
ri
n
tln!
(
"Init!"
);
// RM0368 6.3.9
// RM0368 6.3.9
// enable clock to GPIOA, USART2
// enable clock to GPIOA, USART2
p
.RCC.ahb1enr
.modify
(|
_
,
w
|
w
.gpioaen
()
.enable
());
p
.RCC.ahb1enr
.modify
(|
_
,
w
|
w
.gpioaen
()
.enable
());
...
@@ -59,7 +56,6 @@ fn init(p: init::Peripherals) {
...
@@ -59,7 +56,6 @@ fn init(p: init::Peripherals) {
.variant
(
stm32f40x
::
gpioa
::
moder
::
MODER15W
::
ALTERNATEMODE
)
.variant
(
stm32f40x
::
gpioa
::
moder
::
MODER15W
::
ALTERNATEMODE
)
});
});
// we don't care about the speed register atm
// we don't care about the speed register atm
// DM00102166
// DM00102166
// AF7, Table 9
// AF7, Table 9
...
@@ -106,34 +102,10 @@ fn init(p: init::Peripherals) {
...
@@ -106,34 +102,10 @@ fn init(p: init::Peripherals) {
.clear_bit
()
.clear_bit
()
});
});
// let serial = Serial(p.USART1);
// serial.init(BAUD_RATE.invert(), p.AFIO, None, p.GPIOA, p.RCC);
// echo incoming
loop
{
loop
{
let
b
=
block!
(
read
(
p
.USART2
))
.unwrap
();
let
b
=
block!
(
read
(
p
.USART2
))
.unwrap
();
write
(
p
.USART2
,
b
)
.unwrap
();
write
(
p
.USART2
,
b
)
.unwrap
();
}
}
const
BYTE
:
u8
=
b'A'
;
assert!
(
write
(
p
.USART2
,
BYTE
)
.is_ok
());
for
_
in
0
..
1_000
{
match
read
(
p
.USART2
)
{
Ok
(
byte
)
=>
{
assert_eq!
(
byte
,
BYTE
);
return
;
}
Err
(
nb
::
Error
::
Other
(
e
))
=>
panic!
(
"{:?}"
,
e
),
Err
(
nb
::
Error
::
WouldBlock
)
=>
continue
,
}
}
panic!
(
"Timeout"
)
}
}
// Specialized `Result` type
// Specialized `Result` type
...
@@ -190,7 +162,7 @@ fn read(usart2: &USART2) -> Result<u8> {
...
@@ -190,7 +162,7 @@ fn read(usart2: &USART2) -> Result<u8> {
}
}
fn
idle
()
->
!
{
fn
idle
()
->
!
{
//
OK
//
Will never be hit, as
rtfm
::
bkpt
();
rtfm
::
bkpt
();
// Sleep
// Sleep
...
...
This diff is collapsed.
Click to expand it.
src/gpio.rs
+
1
−
1
View file @
14a64be0
...
@@ -2,7 +2,7 @@
...
@@ -2,7 +2,7 @@
//!
//!
//! - PA0 - PA15
//! - PA0 - PA15
use
stm32f40x
::
{
GPIOA
,
RCC
}
;
use
stm32f40x
::
GPIOA
;
use
stm32f40x
;
use
stm32f40x
;
macro_rules!
pin
{
macro_rules!
pin
{
...
...
This diff is collapsed.
Click to expand it.
src/lib.rs
+
1
−
1
View file @
14a64be0
...
@@ -11,7 +11,7 @@
...
@@ -11,7 +11,7 @@
//! [i]: https://docs.rs/cortex-m-quickstart/0.1.8/cortex_m_quickstart/
//! [i]: https://docs.rs/cortex-m-quickstart/0.1.8/cortex_m_quickstart/
#![deny(missing_docs)]
#![deny(missing_docs)]
//
#![deny(warnings)]
#![deny(warnings)]
#![allow(warnings)]
#![allow(warnings)]
#![feature(const_cell_new)]
#![feature(const_cell_new)]
#![feature(const_fn)]
#![feature(const_fn)]
...
...
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