Skip to content

Commit 00c46e1

Browse files
david-sawatzketherealprof
authored andcommitted
Make examples more generic (#20)
* Make examples more generic
1 parent 0daa4df commit 00c46e1

File tree

3 files changed

+8
-12
lines changed

3 files changed

+8
-12
lines changed

Cargo.toml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,3 @@ opt-level = "s"
6666
[[example]]
6767
name = "led_hal_button_irq"
6868
required-features = ["stm32f042", "rt"]
69-
70-
[[example]]
71-
name = "spi_hal_apa102c"
72-
required-features = ["stm32f042"]

examples/led_hal_button_irq.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,15 @@ use crate::hal::prelude::*;
1212

1313
use cortex_m::interrupt::Mutex;
1414
use cortex_m::peripheral::Peripherals as c_m_Peripherals;
15-
use cortex_m_rt::{entry, interrupt};
15+
use cortex_m_rt::entry;
1616

17-
pub use crate::hal::stm32;
18-
pub use crate::hal::stm32::*;
17+
use crate::hal::stm32::{interrupt, Interrupt, Peripherals, EXTI};
1918

2019
use core::cell::RefCell;
2120
use core::ops::DerefMut;
2221

2322
// Make our LED globally available
24-
static LED: Mutex<RefCell<Option<gpiob::PB3<Output<PushPull>>>>> = Mutex::new(RefCell::new(None));
23+
static LED: Mutex<RefCell<Option<gpioa::PA1<Output<PushPull>>>>> = Mutex::new(RefCell::new(None));
2524

2625
// Make our delay provider globally available
2726
static DELAY: Mutex<RefCell<Option<Delay>>> = Mutex::new(RefCell::new(None));
@@ -32,6 +31,7 @@ static INT: Mutex<RefCell<Option<EXTI>>> = Mutex::new(RefCell::new(None));
3231
#[entry]
3332
fn main() -> ! {
3433
if let (Some(p), Some(cp)) = (Peripherals::take(), c_m_Peripherals::take()) {
34+
let gpioa = p.GPIOA.split();
3535
let gpiob = p.GPIOB.split();
3636
let syscfg = p.SYSCFG_COMP;
3737
let exti = p.EXTI;
@@ -43,8 +43,8 @@ fn main() -> ! {
4343
// Configure PB1 as input (button)
4444
let _ = gpiob.pb1.into_pull_down_input();
4545

46-
// Configure PB3 as output (LED)
47-
let mut led = gpiob.pb3.into_push_pull_output();
46+
// Configure PA1 as output (LED)
47+
let mut led = gpioa.pa1.into_push_pull_output();
4848

4949
// Turn off LED
5050
led.set_low();
@@ -107,7 +107,7 @@ fn EXTI0_1() {
107107
led.set_low();
108108

109109
// Clear interrupt
110-
exti.pr.modify(|_, w| w.pif1().set_bit());
110+
exti.pr.write(|w| w.pif1().set_bit());
111111
}
112112
});
113113
}

examples/spi_hal_apa102c.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use cortex_m_rt::entry;
1515

1616
#[entry]
1717
fn main() -> ! {
18-
pub const MODE: Mode = Mode {
18+
const MODE: Mode = Mode {
1919
polarity: Polarity::IdleHigh,
2020
phase: Phase::CaptureOnSecondTransition,
2121
};

0 commit comments

Comments
 (0)