diff --git a/.cargo/config.toml b/.cargo/config.toml index 00158d2..ef1fea6 100755 --- a/.cargo/config.toml +++ b/.cargo/config.toml @@ -3,6 +3,7 @@ target = "thumbv6m-none-eabi" [target.thumbv6m-none-eabi] runner = 'probe-rs run --chip STM32L053R8' +rustflags = ["-Clink-args=-Tlink.x"] [alias] cflash = "flash --chip STM32L053R8" diff --git a/build.rs b/build.rs deleted file mode 100755 index 9ed9568..0000000 --- a/build.rs +++ /dev/null @@ -1,3 +0,0 @@ -fn main() { - println!("cargo:rustc-link-arg-bins=-Tlink.x"); -} diff --git a/examples/blinky.rs b/examples/blinky.rs new file mode 100755 index 0000000..054a19b --- /dev/null +++ b/examples/blinky.rs @@ -0,0 +1,34 @@ +#![no_main] +#![no_std] + +extern crate panic_halt; + +use cortex_m_rt::entry; +use hal::{pac, prelude::*, rcc::Config}; + +#[entry] +fn main() -> ! { + let dp = pac::Peripherals::take().unwrap(); + let cp = cortex_m::Peripherals::take().unwrap(); + + // Configure the clock. + let mut rcc = dp.RCC.freeze(Config::hsi16()); + + // Acquire the GPIOA peripheral. This also enables the clock for GPIOA in + // the RCC register. + let gpioa = dp.GPIOA.split(&mut rcc); + + // Configure PA1 as output. + let mut led = gpioa.pa5.into_push_pull_output(); + + // Get the delay provider. + let mut delay = cp.SYST.delay(rcc.clocks); + + loop { + led.set_high().unwrap(); + delay.delay_ms(500_u16); + + led.set_low().unwrap(); + delay.delay_ms(500_u16); + } +} diff --git a/src/main.rs b/src/main.rs index 054a19b..1af1ed3 100755 --- a/src/main.rs +++ b/src/main.rs @@ -8,27 +8,5 @@ use hal::{pac, prelude::*, rcc::Config}; #[entry] fn main() -> ! { - let dp = pac::Peripherals::take().unwrap(); - let cp = cortex_m::Peripherals::take().unwrap(); - - // Configure the clock. - let mut rcc = dp.RCC.freeze(Config::hsi16()); - - // Acquire the GPIOA peripheral. This also enables the clock for GPIOA in - // the RCC register. - let gpioa = dp.GPIOA.split(&mut rcc); - - // Configure PA1 as output. - let mut led = gpioa.pa5.into_push_pull_output(); - - // Get the delay provider. - let mut delay = cp.SYST.delay(rcc.clocks); - - loop { - led.set_high().unwrap(); - delay.delay_ms(500_u16); - - led.set_low().unwrap(); - delay.delay_ms(500_u16); - } + compile_error!("Use blinky example") }