Skip to content

Commit 0bb67ca

Browse files
committed
Add nfcaEmulationTransmit and remove redundant _u.update in emulation
1 parent 17103ef commit 0bb67ca

3 files changed

Lines changed: 14 additions & 6 deletions

File tree

src/nfc/layer/a/emulation_layer_a_ST25R3916.cpp

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -186,9 +186,9 @@ bool ListenerST25R3916ForA::stop_emulation()
186186
_u.writeModeDefinition(0x00);
187187
}
188188

189-
bool ListenerST25R3916ForA::transmit(const uint8_t* tx, const uint16_t tx_len, const uint32_t timeout_ms)
189+
bool ListenerST25R3916ForA::transmit(const uint8_t* tx, const uint16_t tx_len, const uint32_t /*timeout_ms*/)
190190
{
191-
return _u.nfcaTransmit(tx, tx_len, timeout_ms);
191+
return _u.nfcaEmulationTransmit(tx, tx_len);
192192
}
193193

194194
// ------------------------------------------------------------
@@ -273,7 +273,6 @@ EmulationLayerA::State ListenerST25R3916ForA::goto_idle()
273273

274274
_wakeup = false;
275275

276-
_u.update();
277276
return update_idle();
278277
// return EmulationLayerA::State::Idle;
279278
}
@@ -292,7 +291,6 @@ EmulationLayerA::State ListenerST25R3916ForA::goto_ready()
292291
_u.clear_bit_register8(REG_OPERATION_CONTROL, wu); // Disable wakeup mode
293292
_u.writeModeDefinition(mode_listen_nfc_a); // Disable bitrate detection and collision
294293

295-
_u.update();
296294
return update_ready();
297295
// return EmulationLayerA::State::Ready;
298296
}
@@ -305,7 +303,6 @@ EmulationLayerA::State ListenerST25R3916ForA::goto_active()
305303

306304
_u.enable_interrupts(I_rxe32);
307305

308-
_u.update();
309306
return update_active();
310307
// return EmulationLayerA::State::Active;
311308
}
@@ -326,7 +323,6 @@ EmulationLayerA::State ListenerST25R3916ForA::goto_halt()
326323
return goto_off();
327324
}
328325

329-
_u.update();
330326
return update_halt();
331327
// return EmulationLayerA::State::Halt;
332328
}

src/unit/unit_ST25R3916.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1749,6 +1749,8 @@ class UnitST25R3916 : public Component {
17491749
uint32_t nfcaTransceive(uint8_t* rx, uint16_t& rx_len, const uint8_t* tx, const uint16_t tx_len,
17501750
const uint32_t timeout_ms);
17511751
bool nfcaTransmit(const uint8_t* tx, const uint16_t tx_len, const uint32_t timeout_ms);
1752+
//! @brief Transmit in emulation (PICC) mode with minimal I2C overhead
1753+
bool nfcaEmulationTransmit(const uint8_t* tx, const uint16_t tx_len);
17521754
bool nfcaReceive(uint8_t* rx, uint16_t& rx_len, const uint32_t timeout_ms);
17531755

17541756
/*!

src/unit/unit_ST25R3916_nfca.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,16 @@ bool UnitST25R3916::nfcaTransmit(const uint8_t* tx, const uint16_t tx_len, const
205205
return true;
206206
}
207207

208+
bool UnitST25R3916::nfcaEmulationTransmit(const uint8_t* tx, const uint16_t tx_len)
209+
{
210+
if (!tx || !tx_len) {
211+
return false;
212+
}
213+
return writeDirectCommand(CMD_CLEAR_FIFO) && //
214+
writeFIFO(tx, tx_len) && //
215+
writeNumberOfTransmittedBytes(tx_len, 0) && writeDirectCommand(CMD_TRANSMIT_WITH_CRC);
216+
}
217+
208218
bool UnitST25R3916::nfcaReceive(uint8_t* rx, uint16_t& rx_len, const uint32_t timeout_ms)
209219
{
210220
CHECK_MODE();

0 commit comments

Comments
 (0)