Skip to content
This repository has been archived by the owner on Jul 6, 2019. It is now read-only.

Commit

Permalink
Panic is ISR are switched over to bootloader
Browse files Browse the repository at this point in the history
  • Loading branch information
farcaller committed Jul 2, 2015
1 parent 615fba2 commit 712ae37
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions src/hal/lpc11xx/syscon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ pub fn get_isr_location() -> ISRLocation {
/// Re-maps interrupt vectors to either RAM or Flash.
pub fn set_isr_location(loc: ISRLocation) {
regs::SYSCON().sysmemremap.ignoring_state().set_map(match loc {
ISRLocation::Bootloader => regs::SYSCON_sysmemremap_map::BOOT_LOADER_MODE_IN,
ISRLocation::RAM => regs::SYSCON_sysmemremap_map::USER_RAM_MODE_INTER,
ISRLocation::Flash => regs::SYSCON_sysmemremap_map::USER_FLASH_MODE_INT,
_ => panic!(),
});
}
Expand Down Expand Up @@ -75,6 +75,9 @@ mod test {
use volatile_cell::{VolatileCellReplayer, set_replayer};
use expectest::prelude::*;
use expectest;
use std::thread;
use std::string::String;
use std::convert::From;

#[test]
fn returns_isr_location() {
Expand All @@ -98,9 +101,18 @@ mod test {
expect_replayer_valid!();
}

set_isr_location(ISRLocation::Bootloader);

expect_replayer_valid!(replayer);
#[test]
fn fails_to_set_isr_location_to_bootloader() {
let j = thread::Builder::new()
.name(String::from("fails_to_set_isr_location_to_bootloader"))
.spawn(|| {
init_replayer!();
expect_volatile_write!(0x4004_8000, 0);
set_isr_location(ISRLocation::Bootloader);
}).unwrap();
let res = j.join();

expect!(res.is_err()).to(be_equal_to(true));
}

#[test]
Expand Down

0 comments on commit 712ae37

Please sign in to comment.