forked from stm32-rs/stm32f1xx-hal
-
Notifications
You must be signed in to change notification settings - Fork 0
/
led.rs
51 lines (42 loc) · 1.26 KB
/
led.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
43
44
45
46
47
48
49
50
51
//! Turns the user LED on
//!
//! If compiled for the stm32f103, this assumes that an active low LED is connected to pc13 as
//! is the case on the blue pill board.
//!
//! If compiled for the stm32f100, this assumes that an active high LED is connected to pc9
//!
//! Note: Without additional hardware, PC13 should not be used to drive a LED, see
//! section 5.1.2 of the reference manual for an explanation.
//! This is not an issue on the blue pill.
#![deny(unsafe_code)]
#![no_main]
#![no_std]
use panic_halt as _;
use cortex_m_rt::entry;
use embedded_hal::digital::v2::OutputPin;
use stm32f1xx_hal::{pac, prelude::*};
#[entry]
fn main() -> ! {
let p = pac::Peripherals::take().unwrap();
let mut rcc = p.RCC.constrain();
let mut gpioc = p.GPIOC.split(&mut rcc.apb2);
#[cfg(feature = "stm32f100")]
gpioc
.pc9
.into_push_pull_output(&mut gpioc.crh)
.set_high()
.unwrap();
#[cfg(feature = "stm32f101")]
gpioc
.pc9
.into_push_pull_output(&mut gpioc.crh)
.set_high()
.unwrap();
#[cfg(any(feature = "stm32f103", feature = "stm32f105", feature = "stm32f107"))]
gpioc
.pc13
.into_push_pull_output(&mut gpioc.crh)
.set_low()
.unwrap();
loop {}
}