Skip to content
Snippets Groups Projects
Unverified Commit 10f5ceb2 authored by lucazulian's avatar lucazulian
Browse files

Add examples folder and update dependecies

parent e8bba282
No related branches found
No related tags found
No related merge requests found
......@@ -6,17 +6,17 @@ readme = "README.md"
authors = ["Luca Zulian <lucagiuggia@gmail.com>"]
[dependencies]
cortex-m = "0.7"
cortex-m-rt = "0.6.5"
cortex-m = "0.7.5"
cortex-m-rt = "0.7.1"
panic-halt = "0.2.0"
panic-semihosting = "0.6.0"
cortex-m-semihosting = "0.5.0"
stm32l4xx-hal = { version = "0.6.0", features = ["rt", "stm32l4x2"] }
stm32l4xx-hal = { version = "0.7.1", features = ["rt", "stm32l432"] }
nb = "1.0.0"
[[bin]]
name = "stm"
path = "src/blink.rs"
path = "examples/blink.rs"
test = false
bench = false
......
......@@ -10,7 +10,7 @@ BINARY=stm
TARGET=thumbv7em-none-eabihf
TARGET_FOLDER=target
LEVEL=release
STM_PATH=/run/media/luca/NODE_L432KC
STM_PATH=/media/luca/NODE_L432KC
EL=arm-none-eabi-readelf
CP=arm-none-eabi-objcopy
......
//! Blinks an LED
#![no_std]
#![no_main]
extern crate cortex_m;
#[macro_use]
extern crate cortex_m_rt as rt;
extern crate cortex_m_semihosting as sh;
extern crate panic_semihosting;
extern crate stm32l4xx_hal as hal;
use crate::hal::delay::Delay;
use crate::hal::prelude::*;
use crate::rt::entry;
use crate::rt::ExceptionFrame;
#[entry]
fn main() -> ! {
let cp = cortex_m::Peripherals::take().unwrap();
let dp = hal::stm32::Peripherals::take().unwrap();
let mut flash = dp.FLASH.constrain();
let mut rcc = dp.RCC.constrain();
let mut pwr = dp.PWR.constrain(&mut rcc.apb1r1);
// Try a different clock configuration
let clocks = rcc.cfgr.hclk(4.MHz()).freeze(&mut flash.acr, &mut pwr);
let mut gpiob = dp.GPIOB.split(&mut rcc.ahb2);
let mut led = gpiob
.pb3
.into_push_pull_output(&mut gpiob.moder, &mut gpiob.otyper);
let mut timer = Delay::new(cp.SYST, clocks);
loop {
timer.delay_ms(1000_u32);
led.set_high();
timer.delay_ms(1000_u32);
led.set_low();
}
}
#[exception]
unsafe fn HardFault(ef: &ExceptionFrame) -> ! {
panic!("{:#?}", ef);
}
#![allow(non_camel_case_types)]
#![no_std]
#![no_main]
// Halt when the program panics.
extern crate panic_halt;
// Includes.
use cortex_m::peripheral::syst::SystClkSource;
use cortex_m_rt::entry;
use stm32l4xx_hal as hal;
use hal::prelude::*;
// use cortex_m_semihosting::{hprintln};
#[entry]
fn main() -> ! {
// Set up SysTick peripheral.
let cmp = cortex_m::Peripherals::take().unwrap();
let mut syst = cmp.SYST;
syst.set_clock_source( SystClkSource::Core );
// ~1ms period; STM32F3 resets to 8MHz internal oscillator.
syst.set_reload( 4_000_000 );
syst.enable_counter();
let p = stm32l4xx_hal::pac::Peripherals::take().unwrap();
let mut rcc = p.RCC.constrain();
let mut gpioe = p.GPIOB.split( &mut rcc.ahb2 );
let mut ld4 = gpioe.pb3.into_push_pull_output( &mut gpioe.moder, &mut gpioe.otyper );
loop {
while !syst.has_wrapped() {};
let _ = ld4.set_high();
// hprintln!("Hello, world!").unwrap();
while !syst.has_wrapped() {};
let _ = ld4.set_low();
}
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment