Skip to content

Commit 6a86ff4

Browse files
committed
rnfc: move PICC bytes to enum
Signed-off-by: Krzysztof Królczyk <[email protected]>
1 parent c7e7d7b commit 6a86ff4

File tree

3 files changed

+53
-1
lines changed

3 files changed

+53
-1
lines changed

rnfc-fm175xx/src/iso14443a.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ use embassy_futures::yield_now;
22
use embassy_time::{Duration, Instant, Timer};
33
use embedded_hal::digital::{InputPin, OutputPin};
44
use embedded_hal_async::digital::Wait;
5+
use rnfc::picc_cmds;
56
use rnfc_traits::iso14443a_ll as ll;
67

78
use crate::fmt::Bytes;
@@ -105,7 +106,7 @@ where
105106

106107
let (tx, crc, timeout_1fc, lastbits, rxalign) = match opts {
107108
ll::Frame::Anticoll { bits } => (&tx[..(bits + 7) / 8], false, 65536, (bits % 8) as u8, (bits % 8) as u8),
108-
ll::Frame::ReqA => (&[0x26][..], false, 16384, 7, 0),
109+
ll::Frame::ReqA => (&[picc_cmds::REQA][..], false, 16384, 7, 0),
109110
ll::Frame::WupA => (&[0x52][..], false, 16384, 7, 0),
110111
ll::Frame::Standard { timeout_1fc } => (tx, true, timeout_1fc, 0, 0),
111112
};

rnfc/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@ pub use rnfc_traits as traits;
88

99
pub mod iso14443a;
1010
pub mod iso_dep;
11+
pub mod picc_cmds;

rnfc/src/picc_cmds.rs

+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
/// Both NFC (ISO/IEC 18092) and RFID (ISO/IEC 14443) codes/types collected here
2+
#[derive(Debug, Clone, Copy, PartialEq)]
3+
pub enum PiccCodes {
4+
/// REQuest command, Type A, moves PICC from IDLE to READY state
5+
REQA = 0x26,
6+
/// Wake-UP command, Type A, moves PICC from IDLE or HALT to READY
7+
WUPA = 0x52,
8+
/// REQuest command, Type B, (Requested/slot-maker) ready
9+
REQB = 0x05,
10+
/// Wake-UP command, Type B
11+
WUPB = 0x08,
12+
/// With matching PUPI moves PICC to ACTIVE
13+
ATTRIB = 0x1D,
14+
/// Cascade Tag, UID not complete, used during anti-collision
15+
CT = 0x88,
16+
/// Anti collision/Select, Cascade Level 1
17+
SelCl1 = 0x93,
18+
/// Anti collision/Select, Cascade Level 2
19+
SelCl2 = 0x95,
20+
/// Anti collision/Select, Cascade Level 3
21+
SelCl3 = 0x97,
22+
/// HaLT command, Type A == Type B, move PICC state to HALT
23+
HLT = 0x50,
24+
/// Request command for Answer To Select
25+
RATS = 0xE0,
26+
/// Select, Type B
27+
SEL = 0x0E,
28+
/// Perform authentication with Key A
29+
MfAuthKeyA = 0x60,
30+
/// Perform authentication with Key B
31+
MfAuthKeyB = 0x61,
32+
/// Reads one 16 byte block from the authenticated sector of the PICC.\
33+
/// Also used for MIFARE Ultralight.
34+
MfRead = 0x30,
35+
/// Writes one 16 byte block to the authenticated sector of the PICC.\
36+
/// Called "COMPATIBILITY WRITE" for MIFARE Ultralight.
37+
MfWrite = 0xA0,
38+
/// Decrements the contents of a block and stores the result in the internal data register.
39+
MfDecrement = 0xC0,
40+
/// Increments the contents of a block and stores the result in the internal data register.
41+
MfIncrement = 0xC1,
42+
/// Reads the contents of a block into the internal data register.
43+
MfRestore = 0xC2,
44+
/// Writes the contents of the internal data register to a block.
45+
MfTransfer = 0xB0,
46+
/// Writes one 4 byte page to the PICC.
47+
UlWrite = 0xA2,
48+
/// TODO
49+
RFU = 0xF8,
50+
}

0 commit comments

Comments
 (0)