Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

porting the crate to the knurling app template #7

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions .cargo/config

This file was deleted.

22 changes: 22 additions & 0 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
[target.'cfg(all(target_arch = "arm", target_os = "none"))']
runner = "probe-run --chip STM32F429ZITx"
rustflags = [
"-C", "linker=flip-link",
"-C", "link-arg=-Tlink.x",
"-C", "link-arg=-Tdefmt.x",
# This is needed if your flash or ram addresses are not aligned to 0x10000 in memory.x
# See https://github.com/rust-embedded/cortex-m-quickstart/pull/95
"-C", "link-arg=--nmagic",
]

[build]
# (`thumbv6m-*` is compatible with all ARM Cortex-M chips but using the right
# target improves performance)
# target = "thumbv6m-none-eabi" # Cortex-M0 and Cortex-M0+
# target = "thumbv7m-none-eabi" # Cortex-M3
# target = "thumbv7em-none-eabi" # Cortex-M4 and Cortex-M7 (no FPU)
target = "thumbv7em-none-eabihf" # Cortex-M4F and Cortex-M7F (with FPU)

[alias]
rb = "run --bin"
rrb = "run --release --bin"
86 changes: 68 additions & 18 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,29 +21,79 @@ repository = "https://github.com/stm32-rs/stm32f429i-disc"
version = "0.3.0"
readme = "README.md"

[dependencies]
cortex-m = "0.6.2"
cortex-m-rt = "0.6.12"
[workspace]
members = ["testsuite"]

[dependencies.embedded-hal]
features = ["unproven"]
version = "0.2.3"
[dependencies]
cortex-m = "0.7.1"
cortex-m-rt = "0.6.13"
defmt = "0.2.0"
defmt-rtt = "0.2.0"
nb = "1.0.0"
panic-probe = { version = "0.2.0", features = ["print-defmt"] }
ssd1306 = "0.5.2"

[dependencies.stm32f4xx-hal]
default-features = false
features = ["rt", "stm32f429"]
version = "0.8.0"
version = "0.9"
features = ["rt", "stm32f429"]

[features]
# set logging levels here
default = [
"defmt-default",
# "dependency-a/defmt-trace",
]

[dev-dependencies]
ssd1306 = "0.4"
nb = "1.0"
panic-halt = "0.2.0"
l3gd20 = "0.2.0"
# do NOT modify these features
defmt-default = []
defmt-trace = []
defmt-debug = []
defmt-info = []
defmt-warn = []
defmt-error = []

# cargo build/run
[profile.dev]
debug = true
codegen-units = 1
debug = 2
debug-assertions = true # <-
incremental = false
opt-level = 3 # <-
overflow-checks = true # <-

# cargo test
[profile.test]
codegen-units = 1
debug = 2
debug-assertions = true # <-
incremental = false
opt-level = 3 # <-
overflow-checks = true # <-

# cargo build/run --release
[profile.release]
debug = true
lto = true
opt-level = "s"
codegen-units = 1
debug = 2
debug-assertions = false # <-
incremental = false
lto = 'fat'
opt-level = 3 # <-
overflow-checks = false # <-

# cargo test --release
[profile.bench]
codegen-units = 1
debug = 2
debug-assertions = false # <-
incremental = false
lto = 'fat'
opt-level = 3 # <-
overflow-checks = false # <-

# uncomment this to switch from the crates.io version of defmt to its git version
# check app-template's README for instructions
# [patch.crates-io]
# defmt = { git = "https://github.com/knurling-rs/defmt", rev = "use defmt version reported by `probe-run --version`" }
# defmt-rtt = { git = "https://github.com/knurling-rs/defmt", rev = "use defmt version reported by `probe-run --version`" }
# defmt-test = { git = "https://github.com/knurling-rs/defmt", rev = "use defmt version reported by `probe-run --version`" }
# panic-probe = { git = "https://github.com/knurling-rs/defmt", rev = "use defmt version reported by `probe-run --version`" }
1 change: 0 additions & 1 deletion examples/button_read.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#![no_main]
#![no_std]

use panic_halt as _;

use stm32f429i_disc as board;

Expand Down
2 changes: 0 additions & 2 deletions examples/gpio_hal_blinky.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
#![no_main]
#![no_std]

use panic_halt as _;

use stm32f429i_disc as board;

use cortex_m_rt::entry;
Expand Down
6 changes: 2 additions & 4 deletions examples/i2c_hal_ssd1306alphabeter.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
#![no_main]
#![no_std]

use panic_halt as _;

use stm32f429i_disc as board;

use ssd1306::displayrotation::DisplayRotation;
Expand Down Expand Up @@ -41,11 +39,11 @@ fn main() -> ! {
.set_open_drain();

// Setup I2C1 using the above defined pins at 400kHz bitrate (fast mode)
let i2c = I2c::i2c1(p.I2C1, (scl, sda), 400.khz(), clocks);
let i2c = I2c::new(p.I2C1, (scl, sda), 400.khz(), clocks);

// Set up the SSD1306 display at I2C address 0x3c
let interface = I2CDIBuilder::new().init(i2c);
let mut disp: TerminalMode<_> = Builder::new().connect(interface).into();
let mut disp: TerminalMode<_,_> = Builder::new().connect(interface).into();

// Set display rotation to 180 degrees
let _ = disp.set_rotation(DisplayRotation::Rotate180);
Expand Down
6 changes: 2 additions & 4 deletions examples/i2c_hal_ssd1306helloworld.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
#![no_main]
#![no_std]

use panic_halt as _;

use stm32f429i_disc as board;

use ssd1306::displayrotation::DisplayRotation;
Expand Down Expand Up @@ -41,11 +39,11 @@ fn main() -> ! {
.set_open_drain();

// Setup I2C1 using the above defined pins at 400kHz bitrate (fast mode)
let i2c = I2c::i2c1(p.I2C1, (scl, sda), 400.khz(), clocks);
let i2c = I2c::new(p.I2C1, (scl, sda), 400.khz(), clocks);

// Set up the SSD1306 display at I2C address 0x3c
let interface = I2CDIBuilder::new().init(i2c);
let mut disp: TerminalMode<_> = Builder::new().connect(interface).into();
let mut disp: TerminalMode<_,_> = Builder::new().connect(interface).into();

// Set display rotation to 180 degrees
let _ = disp.set_rotation(DisplayRotation::Rotate180);
Expand Down
2 changes: 0 additions & 2 deletions examples/leds.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
#![no_main]
#![no_std]

use panic_halt as _;

use stm32f429i_disc as board;

use cortex_m::peripheral::Peripherals;
Expand Down
2 changes: 0 additions & 2 deletions examples/serial_echo.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
#![no_main]
#![no_std]

use panic_halt as _;

use stm32f429i_disc as board;

use nb::block;
Expand Down
6 changes: 0 additions & 6 deletions openocd.cfg

This file was deleted.

27 changes: 0 additions & 27 deletions openocd.gdb

This file was deleted.

8 changes: 0 additions & 8 deletions openocd_program.sh

This file was deleted.

13 changes: 13 additions & 0 deletions src/bin/bitfield.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#![no_main]
#![no_std]

use stm32f429i_disc as _; // global logger + panicking-behavior + memory layout

#[cortex_m_rt::entry]
fn main() -> ! {
// value of the FREQUENCY register (nRF52840 device; RADIO peripheral)
let frequency: u32 = 276;
defmt::debug!("FREQUENCY: {0=0..7}, MAP: {0=8..9}", frequency);

stm32f429i_disc::exit()
}
29 changes: 29 additions & 0 deletions src/bin/format.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#![no_main]
#![no_std]

use defmt::Format;
use stm32f429i_disc as _; // global logger + panicking-behavior + memory layout // <- derive attribute

#[derive(Format)]
struct S1<T> {
x: u8,
y: T,
}

#[derive(Format)]
struct S2 {
z: u8,
}

#[cortex_m_rt::entry]
fn main() -> ! {
let s = S1 {
x: 42,
y: S2 { z: 43 },
};
defmt::info!("s={:?}", s);
let x = 42;
defmt::info!("x={=u8}", x);

stm32f429i_disc::exit()
}
11 changes: 11 additions & 0 deletions src/bin/hello.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#![no_main]
#![no_std]

use stm32f429i_disc as _; // global logger + panicking-behavior + memory layout

#[cortex_m_rt::entry]
fn main() -> ! {
defmt::info!("Hello, world!");

stm32f429i_disc::exit()
}
15 changes: 15 additions & 0 deletions src/bin/levels.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#![no_main]
#![no_std]

use stm32f429i_disc as _; // global logger + panicking-behavior + memory layout

#[cortex_m_rt::entry]
fn main() -> ! {
defmt::info!("info");
defmt::trace!("trace");
defmt::warn!("warn");
defmt::debug!("debug");
defmt::error!("error");

stm32f429i_disc::exit()
}
25 changes: 25 additions & 0 deletions src/bin/overflow.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#![no_main]
#![no_std]

use stm32f429i_disc as _; // global logger + panicking-behavior + memory layout

#[cortex_m_rt::entry]
fn main() -> ! {
ack(10, 10);
stm32f429i_disc::exit()
}

fn ack(m: u32, n: u32) -> u32 {
defmt::info!("ack(m={=u32}, n={=u32})", m, n);
let mut big = [2; 512];
if m == 0 {
n + 1
} else {
big[100] += 1;
if n == 0 {
ack(m - 1, 1)
} else {
ack(m - 1, ack(m, n - 1))
}
}
}
11 changes: 11 additions & 0 deletions src/bin/panic.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#![no_main]
#![no_std]

use stm32f429i_disc as _; // global logger + panicking-behavior + memory layout

#[cortex_m_rt::entry]
fn main() -> ! {
defmt::info!("main");

defmt::panic!()
}
2 changes: 2 additions & 0 deletions src/led.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
//! On-board user LEDs

use stm32f4xx_hal as hal; // memory layout

use hal::prelude::*;

use hal::gpio::gpiog::{self, PG, PG13, PG14};
Expand Down
Loading