pub struct NfcT<'d> { /* private fields */ }
Expand description
NFC tag emulator driver.
Implementations§
Source§impl<'d> NfcT<'d>
impl<'d> NfcT<'d>
Sourcepub fn new(
_p: impl Peripheral<P = NFCT> + 'd,
_irq: impl Binding<NFCT, InterruptHandler> + 'd,
config: &Config,
) -> Self
pub fn new( _p: impl Peripheral<P = NFCT> + 'd, _irq: impl Binding<NFCT, InterruptHandler> + 'd, config: &Config, ) -> Self
Create an Nfc Tag driver
Sourcepub async fn activate(&mut self)
pub async fn activate(&mut self)
Wait for field on and select.
This waits for the field to become on, and then for a reader to select us. The ISO14443-3 sense, anticollision and select procedure is handled entirely in hardware.
When this returns, we have successfully been selected as a card. You must then
loop calling receive
and responding with transmit
.
Sourcepub async fn transmit(&mut self, buf: &[u8]) -> Result<(), Error>
pub async fn transmit(&mut self, buf: &[u8]) -> Result<(), Error>
Transmit an ISO14443-3 frame to the reader.
You must call this only after receiving a frame with receive
,
and only once. Higher-layer protocols usually define timeouts, so calling this
too late can cause things to fail.
This will fail with Error::Deactivated
if we have been deselected due to either
the field being switched off or due to the ISO14443 state machine. When this happens,
you must stop calling receive
and transmit
, reset
all protocol state, and go back to calling activate
.
Sourcepub async fn receive(&mut self, buf: &mut [u8]) -> Result<usize, Error>
pub async fn receive(&mut self, buf: &mut [u8]) -> Result<usize, Error>
Receive an ISO14443-3 frame from the reader.
After calling this, you must send back a response with transmit
,
and only once. Higher-layer protocols usually define timeouts, so calling this
too late can cause things to fail.