-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
43b9f45
commit 04e3ca9
Showing
6 changed files
with
107 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
[build] | ||
target = "thumbv7em-none-eabihf" | ||
|
||
[target.thumbv7em-none-eabihf] | ||
runner = "probe-rs run --chip nRF52833_xxAA" | ||
rustflags = [ | ||
"-C", "linker=rust-lld", | ||
] |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
[package] | ||
name = "interrupts" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
[dependencies] | ||
microbit-v2 = "0.15" | ||
cortex-m-rt = "0.7" | ||
rtt-target = "0.5" | ||
panic-rtt-target = "0.1" | ||
heapless = "0.8" | ||
tiny-led-matrix = "1.0" | ||
embedded-hal = "1.0" | ||
|
||
[dependencies.cortex-m] | ||
version = "0.7" | ||
features = ["critical-section-single-core"] |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
[default.general] | ||
chip = "nrf52833_xxAA" # micro:bit V2 | ||
|
||
[default.reset] | ||
halt_afterwards = false | ||
|
||
[default.rtt] | ||
enabled = true | ||
|
||
[default.gdb] | ||
enabled = false |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#![no_main] | ||
#![no_std] | ||
|
||
use cortex_m::asm; | ||
use cortex_m_rt::entry; | ||
use panic_rtt_target as _; | ||
use rtt_target::{rprintln, rtt_init_print}; | ||
|
||
use microbit::{ | ||
Board, | ||
hal::{ | ||
gpiote, | ||
pac::{self, interrupt}, | ||
}, | ||
}; | ||
|
||
#[interrupt] | ||
fn GPIOTE() { | ||
rprintln!("ouch"); | ||
asm::bkpt(); | ||
} | ||
|
||
#[entry] | ||
fn main() -> ! { | ||
rtt_init_print!(); | ||
let board = Board::take().unwrap(); | ||
let button_a = board.buttons.button_a.into_floating_input(); | ||
let gpiote = gpiote::Gpiote::new(board.GPIOTE); | ||
let channel = gpiote.channel0(); | ||
channel | ||
.input_pin(&button_a.degrade()) | ||
.lo_to_hi() | ||
.enable_interrupt(); | ||
channel.reset_events(); | ||
unsafe { pac::NVIC::unmask(pac::Interrupt::GPIOTE) }; | ||
pac::NVIC::unpend(pac::Interrupt::GPIOTE); | ||
loop { | ||
asm::wfe(); | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#![no_main] | ||
#![no_std] | ||
|
||
use cortex_m::asm; | ||
use cortex_m_rt::entry; | ||
use panic_rtt_target as _; | ||
use rtt_target::{rprintln, rtt_init_print}; | ||
|
||
use microbit::hal::{ | ||
gpio, | ||
gpiote, | ||
pac::{self, interrupt}, | ||
timer, | ||
}; | ||
|
||
struct Blinker { | ||
period: u32, | ||
timer: timer::Timer<> | ||
|
||
static BLINKER: Option<Mutex<RefCell | ||
|
||
#[interrupt] | ||
fn TIMER0() { | ||
rprintln!("tick"); | ||
} | ||
|
||
#[entry] | ||
fn main() -> ! { | ||
|
||
} |