-
Notifications
You must be signed in to change notification settings - Fork 35
/
Copy pathroulette.rs
42 lines (34 loc) · 1.03 KB
/
roulette.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
//! A LED roulette!
#![deny(unsafe_code)]
#![deny(warnings)]
#![no_std]
#![no_main]
extern crate panic_semihosting;
use cortex_m_rt::entry;
use f3::{
hal::{delay::Delay, prelude::*, stm32f30x},
led::Leds,
};
#[entry]
fn main() -> ! {
let cp = cortex_m::Peripherals::take().unwrap();
let dp = stm32f30x::Peripherals::take().unwrap();
let mut flash = dp.FLASH.constrain();
let mut rcc = dp.RCC.constrain();
let gpioe = dp.GPIOE.split(&mut rcc.ahb);
// clock configuration using the default settings (all clocks run at 8 MHz)
let clocks = rcc.cfgr.freeze(&mut flash.acr);
// TRY this alternate clock configuration (all clocks run at 16 MHz)
// let clocks = rcc.cfgr.sysclk(16.mhz()).freeze(&mut flash.acr);
let mut leds = Leds::new(gpioe);
let mut delay = Delay::new(cp.SYST, clocks);
let n = leds.len();
loop {
for curr in 0..n {
let next = (curr + 1) % n;
leds[curr].off();
leds[next].on();
delay.delay_ms(100_u8);
}
}
}