Compare commits

..

2 Commits

Author SHA1 Message Date
Luca 800e73e59c Set led pins to make the leds glow blue and cyan 2020-11-03 20:57:05 +01:00
Luca eafaae8d69 Add 'stm32f0xx-hal' crate to dependencies 2020-10-31 17:17:44 +01:00
2 changed files with 31 additions and 1 deletions

View File

@ -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"] }

View File

@ -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();
}
}