Updated to newest embedded hal version
This commit is contained in:
parent
9f55b6dc08
commit
b2f80a8da2
|
@ -1,33 +1,9 @@
|
|||
[target.thumbv7m-none-eabi]
|
||||
# uncomment this to make `cargo run` execute programs on QEMU
|
||||
# runner = "qemu-system-arm -cpu cortex-m3 -machine lm3s6965evb -nographic -semihosting-config enable=on,target=native -kernel"
|
||||
|
||||
[target.'cfg(all(target_arch = "arm", target_os = "none"))']
|
||||
# uncomment ONE of these three option to make `cargo run` start a GDB session
|
||||
# which option to pick depends on your system
|
||||
# runner = "arm-none-eabi-gdb -q -x openocd.gdb"
|
||||
# runner = "gdb-multiarch -q -x openocd.gdb"
|
||||
# runner = "gdb -q -x openocd.gdb"
|
||||
|
||||
runner = "arm-none-eabi-gdb -q -x openocd.gdb"
|
||||
rustflags = [
|
||||
# LLD (shipped with the Rust toolchain) is used as the default linker
|
||||
"-C", "linker=rust-lld",
|
||||
"-C", "link-arg=-Tlink.x",
|
||||
|
||||
# if you run into problems with LLD switch to the GNU linker by commenting out
|
||||
# this line
|
||||
# "-C", "linker=arm-none-eabi-ld",
|
||||
|
||||
# if you need to link to pre-compiled C libraries provided by a C toolchain
|
||||
# use GCC as the linker by commenting out both lines above and then
|
||||
# uncommenting the three lines below
|
||||
# "-C", "linker=arm-none-eabi-gcc",
|
||||
# "-C", "link-arg=-Wl,-Tlink.x",
|
||||
# "-C", "link-arg=-nostartfiles",
|
||||
]
|
||||
|
||||
[build]
|
||||
# Pick ONE of these compilation targets
|
||||
# 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)
|
||||
target = "thumbv7m-none-eabi"
|
||||
|
|
26
Cargo.toml
26
Cargo.toml
|
@ -2,32 +2,20 @@
|
|||
authors = ["sebastian"]
|
||||
edition = "2018"
|
||||
readme = "README.md"
|
||||
name = "STM32F1Test"
|
||||
name = "stm32_f1_blinky"
|
||||
version = "0.1.0"
|
||||
|
||||
[dependencies]
|
||||
cortex-m = "0.6.0"
|
||||
cortex-m-rt = "0.6.8"
|
||||
cortex-m-semihosting = "0.3.2"
|
||||
panic-halt = "0.2.0"
|
||||
nb = "0.1.2"
|
||||
|
||||
[dependencies.stm32f1]
|
||||
version = "0.8.0"
|
||||
features = ["stm32f103"]
|
||||
|
||||
[dependencies.stm32f1xx-hal]
|
||||
version = "0.4.0"
|
||||
features = ["stm32f103", "rt"]
|
||||
|
||||
[dependencies.embedded-hal]
|
||||
version = "0.2.3"
|
||||
features = ["unproven"]
|
||||
cortex-m = "0.6"
|
||||
cortex-m-rt = "0.6"
|
||||
stm32f1xx-hal = { version = "0.5.3", features = ["stm32f103", "stm32-usbd", "rt"] }
|
||||
panic-semihosting = "0.5"
|
||||
embedded-hal = "0.2.3"
|
||||
|
||||
|
||||
# this lets you use `cargo fix`!
|
||||
[[bin]]
|
||||
name = "STM32F1Test"
|
||||
name = "stm32_f1_blinky"
|
||||
test = false
|
||||
bench = false
|
||||
|
||||
|
|
11
build.rs
11
build.rs
|
@ -1,18 +1,15 @@
|
|||
use std::env;
|
||||
use std::fs::File;
|
||||
use std::fs;
|
||||
use std::io::Write;
|
||||
use std::path::PathBuf;
|
||||
|
||||
fn main() {
|
||||
// Put the linker script somewhere the linker can find it
|
||||
let out = &PathBuf::from(env::var_os("OUT_DIR").unwrap());
|
||||
File::create(out.join("memory.x"))
|
||||
let out_dir = PathBuf::from(env::var("OUT_DIR").unwrap());
|
||||
fs::File::create(out_dir.join("memory.x"))
|
||||
.unwrap()
|
||||
.write_all(include_bytes!("memory.x"))
|
||||
.unwrap();
|
||||
println!("cargo:rustc-link-search={}", out.display());
|
||||
|
||||
// Only re-run the build script when memory.x is changed,
|
||||
// instead of when any part of the source code changes.
|
||||
println!("cargo:rustc-link-search={}", out_dir.display());
|
||||
println!("cargo:rerun-if-changed=memory.x");
|
||||
}
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
set history save on
|
||||
set confirm off
|
||||
target extended-remote :3333
|
||||
set print asm-demangle on
|
||||
monitor arm semihosting enable
|
||||
monitor reset halt
|
||||
load
|
||||
# monitor verify
|
||||
# monitor reset
|
||||
# quit
|
||||
continue
|
3
run.sh
3
run.sh
|
@ -1,3 +0,0 @@
|
|||
#!/bin/bash
|
||||
cargo build || exit -1
|
||||
arm-none-eabi-gdb target/thumbv7m-none-eabi/debug/STM32F1Test
|
22
src/main.rs
22
src/main.rs
|
@ -1,22 +1,15 @@
|
|||
//! Blinks an LED
|
||||
//!
|
||||
//! This assumes that a LED is connected to pc13 as is the case on the blue pill board.
|
||||
//!
|
||||
//! Note: Without additional hardware, PC13 should not be used to drive an LED, see page 5.1.2 of
|
||||
//! the reference manaual for an explanation. This is not an issue on the blue pill.
|
||||
|
||||
#![deny(unsafe_code)]
|
||||
#![no_std]
|
||||
#![no_main]
|
||||
|
||||
use panic_halt as _;
|
||||
|
||||
use nb::block;
|
||||
extern crate panic_semihosting;
|
||||
|
||||
|
||||
use stm32f1xx_hal::{
|
||||
prelude::*,
|
||||
pac,
|
||||
timer::Timer,
|
||||
delay::Delay,
|
||||
};
|
||||
use cortex_m_rt::entry;
|
||||
use embedded_hal::digital::v2::OutputPin;
|
||||
|
@ -43,14 +36,15 @@ fn main() -> ! {
|
|||
// Configure gpio C pin 13 as a push-pull output. The `crh` register is passed to the function
|
||||
// in order to configure the port. For pins 0-7, crl should be passed instead.
|
||||
let mut led = gpioc.pc13.into_push_pull_output(&mut gpioc.crh);
|
||||
// Configure the syst timer to trigger an update every second
|
||||
let mut timer = Timer::syst(cp.SYST, 1.hz(), clocks);
|
||||
|
||||
|
||||
let mut delay = Delay::new(cp.SYST, clocks);
|
||||
|
||||
// Wait for the timer to trigger an update and change the state of the LED
|
||||
loop {
|
||||
block!(timer.wait()).unwrap();
|
||||
led.set_high().unwrap();
|
||||
block!(timer.wait()).unwrap();
|
||||
delay.delay_ms(1000u16);
|
||||
led.set_low().unwrap();
|
||||
delay.delay_ms(1000u16);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue