Compare commits
2 Commits
02f4cd0de1
...
800e73e59c
Author | SHA1 | Date |
---|---|---|
Luca | 800e73e59c | |
Luca | eafaae8d69 |
|
@ -6,5 +6,7 @@ edition = "2018"
|
|||
readme = "README.md"
|
||||
|
||||
[dependencies]
|
||||
cortex-m = "0.6.4"
|
||||
cortex-m-rt = "0.6.13"
|
||||
panic-halt = "0.2.0"
|
||||
stm32f0xx-hal = { version = "0.17.1", features = ["rt", "stm32f072"] }
|
||||
|
|
30
src/main.rs
30
src/main.rs
|
@ -21,8 +21,36 @@
|
|||
|
||||
use cortex_m_rt::entry;
|
||||
use panic_halt as _;
|
||||
use stm32f0xx_hal::pac::Peripherals;
|
||||
use stm32f0xx_hal::prelude::*;
|
||||
|
||||
#[entry]
|
||||
fn main() -> ! {
|
||||
loop {}
|
||||
let mut p = Peripherals::take().unwrap();
|
||||
|
||||
let mut rcc = p.RCC.configure().freeze(&mut p.FLASH);
|
||||
|
||||
let gpioa = p.GPIOA.split(&mut rcc);
|
||||
let gpiob = p.GPIOB.split(&mut rcc);
|
||||
|
||||
let (mut led1_b, mut led1_g, mut led1_r, mut led2_g, mut led2_r, mut led2_b) = cortex_m::interrupt::free(|cs| (
|
||||
gpioa.pa0.into_push_pull_output(cs),
|
||||
gpioa.pa1.into_push_pull_output(cs),
|
||||
gpioa.pa2.into_push_pull_output(cs),
|
||||
gpiob.pb0.into_push_pull_output(cs),
|
||||
gpiob.pb1.into_push_pull_output(cs),
|
||||
gpiob.pb5.into_push_pull_output(cs),
|
||||
));
|
||||
led1_r.set_high().ok(); // 0
|
||||
led1_g.set_high().ok(); // 0
|
||||
led1_b.set_low().ok(); // 255
|
||||
// ^ blue
|
||||
led2_r.set_high().ok(); // 0
|
||||
led2_g.set_low().ok(); // 255
|
||||
led2_b.set_low().ok(); // 255
|
||||
// ^ cyan
|
||||
|
||||
loop {
|
||||
cortex_m::asm::nop();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue