Created
December 21, 2018 15:23
-
-
Save bofh/833e9b9e34692acd8bec00b4e68bcb4f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#![deny(warnings)] | |
#![no_main] | |
#![no_std] | |
extern crate panic_semihosting; | |
use rtfm::app; | |
#[app(device = stm32f30x)] | |
const APP: () = { | |
static DEVICE: stm32f30x::Peripherals = (); | |
#[init] | |
fn init() { | |
let mut _core: rtfm::Peripherals = core; | |
let device: stm32f30x::Peripherals = device; | |
device.RCC.ahbenr.modify(|_, w| w.iopaen().set_bit()); | |
device.GPIOA.moder.modify( | |
|_, w| w.moder5().output() | |
); | |
device.RCC.ahbenr.modify(|_, w| w.iopcen().set_bit()); | |
device.GPIOC.moder.modify( | |
|_, w| w.moder13().input() | |
); | |
device.GPIOC.pupdr.modify(|_, w| unsafe { | |
w.pupdr13().bits(0b01) | |
}); | |
device.SYSCFG.exticr4.modify(|_, w| unsafe { | |
w.exti13().bits(0b010) | |
}); | |
device.EXTI.imr1.modify(|_, w| w.mr13().set_bit()); | |
device.EXTI.emr1.modify(|_, w| w.mr13().set_bit()); | |
device.EXTI.rtsr1.modify(|_, w| w.tr13().set_bit()); | |
DEVICE = device; | |
} | |
#[interrupt(resources = [DEVICE])] | |
fn EXTI15_10() { | |
resources.DEVICE.GPIOA.bsrr.write(|w| w.bs5().set_bit()); | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment