edited
This commit is contained in:
parent
aa5fc09ca0
commit
d7e225f6e5
1 changed files with 7 additions and 7 deletions
14
src/main.rs
14
src/main.rs
|
|
@ -4,12 +4,12 @@
|
||||||
extern crate panic_halt;
|
extern crate panic_halt;
|
||||||
use cortex_m_rt::entry;
|
use cortex_m_rt::entry;
|
||||||
use hal::prelude::*;
|
use hal::prelude::*;
|
||||||
use stm32f3xx_hal as hal;
|
use stm32f3xx_hal::{self as hal, pac::CorePeripherals, pac::Peripherals};
|
||||||
|
|
||||||
#[entry]
|
#[entry]
|
||||||
fn main() -> ! {
|
fn main() -> ! {
|
||||||
let sp = hal::pac::Peripherals::take().unwrap();
|
let sp = Peripherals::take().unwrap();
|
||||||
let mut core_periphrals = hal::pac::CorePeripherals::take().unwrap();
|
let mut core_periphrals = CorePeripherals::take().unwrap();
|
||||||
|
|
||||||
let mut rcc = sp.RCC.constrain();
|
let mut rcc = sp.RCC.constrain();
|
||||||
let mut flash = sp.FLASH.constrain();
|
let mut flash = sp.FLASH.constrain();
|
||||||
|
|
@ -25,9 +25,9 @@ fn main() -> ! {
|
||||||
|
|
||||||
let reload = clocks.sysclk().0 / 8;
|
let reload = clocks.sysclk().0 / 8;
|
||||||
|
|
||||||
hal::pac::SYST::set_reload(&mut core_periphrals.SYST, reload - 1);
|
core_periphrals.SYST.set_reload(reload - 1);
|
||||||
hal::pac::SYST::clear_current(&mut core_periphrals.SYST);
|
core_periphrals.SYST.clear_current();
|
||||||
hal::pac::SYST::enable_counter(&mut core_periphrals.SYST);
|
core_periphrals.SYST.enable_counter();
|
||||||
|
|
||||||
let mut last_led_state = false;
|
let mut last_led_state = false;
|
||||||
let mut last_button_state = false;
|
let mut last_button_state = false;
|
||||||
|
|
@ -45,7 +45,7 @@ fn main() -> ! {
|
||||||
false
|
false
|
||||||
};
|
};
|
||||||
|
|
||||||
if hal::pac::SYST::has_wrapped(&mut core_periphrals.SYST) {
|
if core_periphrals.SYST.has_wrapped() {
|
||||||
led_state = !last_led_state;
|
led_state = !last_led_state;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue