Skip to content

Commit c7e7d7b

Browse files
committed
review: changes part 1
- remove stubs - compact Commands together, cfg's when diffrences - update ci (no chip selection is a compile error) - update st25r39-disco to use feature Signed-off-by: Krzysztof Królczyk <[email protected]>
1 parent 5d09698 commit c7e7d7b

File tree

12 files changed

+109
-565
lines changed

12 files changed

+109
-565
lines changed

ci.sh

-4
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,8 @@ cargo build --release --manifest-path rnfc-fm175xx/Cargo.toml --features ''
1717
cargo build --release --manifest-path rnfc-fm175xx/Cargo.toml --features 'defmt'
1818
cargo build --release --manifest-path rnfc-fm175xx/Cargo.toml --features 'log'
1919

20-
echo "no-features"
21-
cargo build --release --manifest-path rnfc-st25r39/Cargo.toml --features ''
22-
echo "st25r3916"
2320
cargo build --release --manifest-path rnfc-st25r39/Cargo.toml --features 'st25r3916, defmt'
2421
cargo build --release --manifest-path rnfc-st25r39/Cargo.toml --features 'st25r3916, log'
25-
echo "st25r3911b"
2622
cargo build --release --manifest-path rnfc-st25r39/Cargo.toml --features 'st25r3911b, defmt'
2723
cargo build --release --manifest-path rnfc-st25r39/Cargo.toml --features 'st25r3911b, log'
2824

examples/st25r39-disco/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ default = [
1111
]
1212

1313
[dependencies]
14-
rnfc-st25r39 = { path = "../../rnfc-st25r39", features = [ "defmt" ] }
14+
rnfc-st25r39 = { path = "../../rnfc-st25r39", features = [ "defmt", "st25r3916" ] }
1515
rnfc = { path = "../../rnfc", features = [ "defmt" ] }
1616

1717
embassy-executor = { version = "0.7", features = ["defmt", "nightly", "arch-cortex-m", "executor-thread"] }

rnfc-st25r39/src/commands/cmds_st25r3911b.rs

-68
This file was deleted.

rnfc-st25r39/src/commands/cmds_st25r3916.rs

-70
This file was deleted.

rnfc-st25r39/src/commands/mod.rs

+94-14
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,94 @@
1-
#[cfg(feature = "st25r3916")]
2-
pub mod cmds_st25r3916;
3-
#[cfg(feature = "st25r3916")]
4-
pub use cmds_st25r3916::Command;
5-
6-
#[cfg(feature = "st25r3911b")]
7-
pub mod cmds_st25r3911b;
8-
#[cfg(feature = "st25r3911b")]
9-
pub use cmds_st25r3911b::Command;
10-
11-
#[cfg(all(not(feature = "st25r3911b"), not(feature = "st25r3916")))]
12-
mod stub;
13-
#[cfg(all(not(feature = "st25r3911b"), not(feature = "st25r3916")))]
14-
pub use stub::Command;
1+
/// Direct commands
2+
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
3+
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
4+
#[allow(unused)]
5+
pub enum Command {
6+
/// Puts the chip in default state (same as after power-up)
7+
SetDefault = 0xC1,
8+
/// Stops all activities and clears FIFO same as C3
9+
Stop = 0xC2,
10+
/// Stops all activities and clears FIFO same as C2
11+
Clear = 0xC3,
12+
/// Transmit with CRC
13+
TransmitWithCrc = 0xC4,
14+
/// Transmit without CRC
15+
TransmitWithoutCrc = 0xC5,
16+
/// Transmit REQA
17+
TransmitReqa = 0xC6,
18+
/// Transmit WUPA
19+
TransmitWupa = 0xC7,
20+
/// NFC transmit with Initial RF Collision Avoidance
21+
InitialRfCollision = 0xC8,
22+
/// NFC transmit with Response RF Collision Avoidance
23+
ResponseRfCollisionN = 0xC9,
24+
#[cfg(feature = "st25r3911b")]
25+
/// NFC transmit with Response RF Collision Avoidance with n=0
26+
ResponseRfCollisionNzero = 0xCA,
27+
#[cfg(feature = "st25r3911b")]
28+
/// Accepted in NFCIP-1 active communication bitrate detection mode
29+
GotoNormalNFCMode = 0xCB,
30+
#[cfg(feature = "st25r3911b")]
31+
/// Presets Rx and Tx configuration based on state of Mode definition register and Bit rate definition register
32+
PresetAnalog = 0xCC,
33+
#[cfg(feature = "st25r3916")]
34+
/// Passive target logic to Sense/Idle state
35+
GotoSense = 0xCD,
36+
#[cfg(feature = "st25r3916")]
37+
/// Passive target logic to Sleep/Halt state
38+
GotoSleep = 0xCE,
39+
/// Mask receive data
40+
MaskReceiveData = 0xD0,
41+
/// Unmask receive data
42+
UnmaskReceiveData = 0xD1,
43+
#[cfg(feature = "st25r3916")]
44+
/// AM Modulation state change
45+
AmModStateChange = 0xD2,
46+
/// Measure singal amplitude on RFI inputs
47+
MeasureAmplitude = 0xD3,
48+
#[cfg(feature = "st25r3911b")]
49+
/// Performs gain reduction based on the current noise level
50+
Squelch = 0xD4,
51+
/// Reset RX Gain
52+
ResetRxgain = 0xD5,
53+
/// Adjust regulators
54+
AdjustRegulators = 0xD6,
55+
#[cfg(feature = "st25r3911b")]
56+
/// Starts sequence that activates the Tx, measures the modulation depth, and adapts it to comply with the specified modulation depth
57+
CalibrateModDepth = 0xD7,
58+
/// Starts the sequence to adjust the driver timing. Called CalibrateAntenna in st25r3911b
59+
CalibrateDriverTiming = 0xD8,
60+
/// Measure phase between RFO and RFI signal
61+
MeasurePhase = 0xD9,
62+
/// Clear RSSI bits and restart the measurement
63+
ClearRssi = 0xDA,
64+
#[cfg(feature = "st25r3916")]
65+
/// Clears FIFO, Collision and IRQ status
66+
ClearFifo = 0xDB,
67+
/// Transparent mode - amplitude of signal present on RFI inputs is measured, result is stored in A/D converter output register
68+
TransparentMode = 0xDC,
69+
/// Calibrate the capacitive sensor
70+
CalibrateCSensor = 0xDD,
71+
/// Measure capacitance sensor
72+
MeasureCapacitance = 0xDE,
73+
/// Measure power supply voltage
74+
MeasureVdd = 0xDF,
75+
/// Start the general purpose timer
76+
StartGpTimer = 0xE0,
77+
/// Start the wake-up timer
78+
StartWupTimer = 0xE1,
79+
/// Start the mask-receive timer
80+
StartMaskReceiveTimer = 0xE2,
81+
/// Start the no-response timer
82+
StartNoResponseTimer = 0xE3,
83+
#[cfg(feature = "st25r3916")]
84+
/// Start PPon2 timer
85+
StartPpon2Timer = 0xE4,
86+
#[cfg(feature = "st25r3916")]
87+
/// Stop No Response Timer
88+
StopNrt = 0xE8,
89+
#[cfg(feature = "st25r3916")]
90+
/// Enable R/W access to the test registers
91+
SpaceBAccess = 0xFB,
92+
/// Enable R/W access to the test registers
93+
TestAccess = 0xFC,
94+
}

rnfc-st25r39/src/commands/stub.rs

-15
This file was deleted.

rnfc-st25r39/src/impls/mod.rs

-5
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,6 @@ pub mod lib_st25r3911b;
88
#[cfg(feature = "st25r3911b")]
99
pub use lib_st25r3911b::*;
1010

11-
#[cfg(all(not(feature = "st25r3911b"), not(feature = "st25r3916")))]
12-
mod stub;
13-
#[cfg(all(not(feature = "st25r3911b"), not(feature = "st25r3916")))]
14-
pub use stub::*;
15-
1611
// TODO: check wup and other wake-up registers in st25r3911b
1712
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
1813
#[cfg_attr(feature = "defmt", derive(defmt::Format))]

rnfc-st25r39/src/impls/stub.rs

-59
This file was deleted.

rnfc-st25r39/src/lib.rs

+6-3
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
// This must go FIRST so that other mods see its macros.
66
mod fmt;
77

8-
// no-chip-specified, maybe it'd be useful to have common api
9-
// or support a mock, in case some tests to validate calculations?
10-
#[cfg(any(feature = "st25r3911b", feature = "st25r3916"))]
8+
#[cfg(all(not(feature = "st25r3911b"), not(feature = "st25r3916")))]
9+
compile_error!("A chip/feature has to be selected in Cargo.toml");
10+
1111
mod aat;
1212
pub mod commands;
1313
pub mod impls;
@@ -28,8 +28,11 @@ pub enum Error<T> {
2828

2929
#[derive(PartialEq, Eq, Clone, Copy)]
3030
enum Mode {
31+
/// SPI running, AFE static power consumpton mnimized
3132
Off,
33+
/// Ready mode
3234
On,
35+
/// Low power mode, card presence detection
3336
Wakeup,
3437
}
3538

0 commit comments

Comments
 (0)