rust-embedded / cortex-m

Low level access to Cortex-M processors
Apache License 2.0
808 stars 145 forks source link

no function or associated item named `unmask` found for struct `cortex_m::peripheral::NVIC` in the current scope #221

Closed TDHolmes closed 4 years ago

TDHolmes commented 4 years ago

I'm trying to write up an example app for an interrupt based sleeping timer, but when I try to compile this app as an example for the feather_m0 board, I get:

error[E0599]: no function or associated item named `unmask` found for struct `cortex_m::peripheral::NVIC` in the current scope
  --> examples/NVIC_repro.rs:30:15
   |
30 |         NVIC::unmask(interrupt::TC4);
   |               ^^^^^^ function or associated item not found in `cortex_m::peripheral::NVIC`

Here is a minimal repro of the issue, with unnecessary bits cut out:

#![no_std]
#![no_main]

extern crate cortex_m;
extern crate feather_m0 as hal;
extern crate panic_halt;

use hal::clock::GenericClockController;
use hal::entry;
use hal::pac::{interrupt, CorePeripherals, Peripherals};
use hal::prelude::*;

use cortex_m::peripheral::NVIC;

#[entry]
fn main() -> ! {
    // Configure all of our peripherals/clocks
    let mut peripherals = Peripherals::take().unwrap();
    let mut core = CorePeripherals::take().unwrap();
    let mut clocks = GenericClockController::with_external_32kosc(
        peripherals.GCLK,
        &mut peripherals.PM,
        &mut peripherals.SYSCTRL,
        &mut peripherals.NVMCTRL,
    );

    // enable interrupts
    unsafe {
        core.NVIC.set_priority(interrupt::TC4, 2);
        NVIC::unmask(interrupt::TC4);
    };
    loop {}
}

However, when I instead put this into a standalone binary app, I do not see the issue. Any ideas as to what is going on? Here is a fork of atsamd adding what I'm trying to do. To repro, check this branch out and run cargo build --example sleeping_timer from boards/feather_m0.

It might end up being an issue on the atsamd end, but I thought since the import issues seem to be coming from cortex-m, I'd start with this crate.

TDHolmes commented 4 years ago

After some cargo clean'ing and updating my nightly compiler, this no longer occurs.