57 lines
1.7 KiB
Rust
57 lines
1.7 KiB
Rust
/*
|
|
* any key firmware
|
|
* Copyright (C) 2020 Luca Schmid
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
* (at your option) any later version.
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
*/
|
|
|
|
#![no_std]
|
|
#![no_main]
|
|
|
|
use cortex_m_rt::entry;
|
|
use panic_halt as _;
|
|
use stm32f0xx_hal::pac::Peripherals;
|
|
use stm32f0xx_hal::prelude::*;
|
|
|
|
#[entry]
|
|
fn main() -> ! {
|
|
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();
|
|
}
|
|
}
|