diff options
author | Josh Rahm <joshuarahm@gmail.com> | 2022-12-13 16:45:49 -0700 |
---|---|---|
committer | Josh Rahm <joshuarahm@gmail.com> | 2022-12-13 16:45:49 -0700 |
commit | 540e0316aa425a8fbd126d31350dbe51fca92791 (patch) | |
tree | abc938b9b9f21b7d2357a18272d84c263d767142 /src/main.rs | |
parent | 8bb2d168044213ce9bd31a19efb6bab90f5c9722 (diff) | |
download | stm32l4-rust-master.tar.gz stm32l4-rust-master.tar.bz2 stm32l4-rust-master.zip |
This rapidly blinks the sysled on the stm32.
This shows the ability to manipulate memory mapped registers.
Diffstat (limited to 'src/main.rs')
-rw-r--r-- | src/main.rs | 29 |
1 files changed, 26 insertions, 3 deletions
diff --git a/src/main.rs b/src/main.rs index 146f601..997e532 100644 --- a/src/main.rs +++ b/src/main.rs @@ -2,14 +2,37 @@ #![no_std] use core::panic::PanicInfo; +use hal::gpio::get_gpio_port_b; +use crate::hal::gpio; + +mod hal; mod init; #[link_section = ".inits.999"] #[no_mangle] -pub static __MAIN: fn() -> () = main; -pub fn main() -> () { - loop {}; +pub static __MAIN: unsafe fn() -> () = main; +pub unsafe fn main() -> () { + let mut pin = get_gpio_port_b().pin(3); + pin.set_mode(gpio::GpioMode::Output); + pin.set_output_type(gpio::GpioOutputType::PushPull); + pin.set_output_speed(gpio::GpioSpeed::Medium); + pin.set_pull_dir(gpio::GpioPullDir::Down); + + pin.set_high(); + loop { + delay(); + pin.set_low(); + delay(); + pin.set_high(); + } +} + +fn delay() { + let mut cnt = 0; + while cnt < 10000 { + cnt += 1; + } } #[panic_handler] |