Skip to content

Instantly share code, notes, and snippets.

@kuon
Created November 2, 2019 05:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kuon/73bd63cfca013ad3b3435e848831ad11 to your computer and use it in GitHub Desktop.
Save kuon/73bd63cfca013ad3b3435e848831ad11 to your computer and use it in GitHub Desktop.
nfc test
#![no_std]
#![no_main]
#[allow(unused_imports)]
use panic_semihosting;
use embedded_hal::blocking::delay::DelayMs;
use embedded_hal::digital::v2::OutputPin;
use nrf52840_hal as hal;
use nrf52840_hal::nrf52840_pac as pac;
use cortex_m_rt::entry;
use hal::gpio::Level;
use hal::prelude::GpioExt;
use cortex_m_semihosting::dbg;
use rtfm::app;
#[app(device = nrf52840_hal::target)]
const APP: () = {
static NFC: pac::NFCT = ();
#[init]
fn init() -> init::LateResources {
device.NFCT.tasks_activate.write(|w| w.tasks_activate().set_bit());
device.NFCT.inten.write(|w| w.fielddetected().enabled());
init::LateResources { NFC: device.NFCT }
}
#[idle]
fn idle() -> ! {
loop {}
}
#[interrupt(resources = [NFC])]
fn NFCT() {
//let p = pac::Peripherals::take().unwrap();
if (resources.NFC.events_fielddetected.read().events_fielddetected().bit_is_set()) {
dbg!("hello NFC 2");
}
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment