From 31449fcc0df6cdeb54083b6ebed45bafd7a1d957 Mon Sep 17 00:00:00 2001 From: Mirna Date: Tue, 27 Oct 2020 10:06:11 +0200 Subject: [PATCH] Added setup function for driver existence checking --- third_party/libtock-drivers/src/nfc.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/third_party/libtock-drivers/src/nfc.rs b/third_party/libtock-drivers/src/nfc.rs index 06dd748..5902160 100644 --- a/third_party/libtock-drivers/src/nfc.rs +++ b/third_party/libtock-drivers/src/nfc.rs @@ -7,6 +7,7 @@ use libtock_core::{callback, syscalls}; const DRIVER_NUMBER: usize = 0x30003; mod command_nr { + pub const CHECK: usize = 0; pub const TRANSMIT: usize = 1; pub const RECEIVE: usize = 2; pub const EMULATE: usize = 3; @@ -34,6 +35,11 @@ pub struct RecvOp { pub struct NfcTag {} impl NfcTag { + /// Check the existence of an NFC driver. + pub fn setup() -> bool { + syscalls::command(DRIVER_NUMBER, command_nr::CHECK, 0, 0).is_ok() + } + pub fn enable_emulation() -> bool { NfcTag::emulate(true) }