Skip to content

Commit d9b7f21

Browse files
committed
Add nfcfEmulationTransmit and remove redundant _u.update in emulation
1 parent 973976e commit d9b7f21

3 files changed

Lines changed: 14 additions & 4 deletions

File tree

src/nfc/layer/f/emulation_layer_f_ST25R3916.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -211,9 +211,9 @@ bool ListenerST25R3916ForF::stop_emulation()
211211
_u.writeModeDefinition(0x00);
212212
}
213213

214-
bool ListenerST25R3916ForF::transmit(const uint8_t* tx, const uint16_t tx_len, const uint32_t timeout_ms)
214+
bool ListenerST25R3916ForF::transmit(const uint8_t* tx, const uint16_t tx_len, const uint32_t /*timeout_ms*/)
215215
{
216-
return _u.nfcfTransmit(tx, tx_len, timeout_ms);
216+
return _u.nfcfEmulationTransmit(tx, tx_len);
217217
}
218218

219219
// ------------------------------------------------------------
@@ -284,7 +284,6 @@ EmulationLayerF::State ListenerST25R3916ForF::goto_communicated()
284284
_u.writeDirectCommand(CMD_UNMASK_RECEIVE_DATA);
285285
// rfalCheckEnableObsModeRx();
286286

287-
_u.update();
288287
return update_communicated();
289288
return EmulationLayerF::State::Communicated;
290289
}
@@ -303,7 +302,6 @@ EmulationLayerF::State ListenerST25R3916ForF::goto_selected()
303302
(void)get_irq(I_par32 | I_crc32 | I_err232 | I_err132);
304303
_u.enable_interrupts(I_rxe32);
305304

306-
_u.update();
307305
return update_selected();
308306
return EmulationLayerF::State::Selected;
309307
}

src/unit/unit_ST25R3916.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1901,6 +1901,8 @@ class UnitST25R3916 : public Component {
19011901
@return True if successful
19021902
*/
19031903
bool nfcfTransmit(const uint8_t* tx, const uint16_t tx_len, const uint32_t timeout_ms);
1904+
//! @brief Transmit in emulation (PICC) mode with minimal I2C overhead
1905+
bool nfcfEmulationTransmit(const uint8_t* tx, const uint16_t tx_len);
19041906
/*!
19051907
@brief Receive from NFC-F PICC
19061908
@param[out] rx Receive buffer

src/unit/unit_ST25R3916_nfcf.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,16 @@ bool UnitST25R3916::nfcfTransmit(const uint8_t* tx, const uint16_t tx_len, const
101101
return wait_for_interrupt(I_txe32, timeout_ms) & I_txe32;
102102
}
103103

104+
bool UnitST25R3916::nfcfEmulationTransmit(const uint8_t* tx, const uint16_t tx_len)
105+
{
106+
if (!tx || !tx_len) {
107+
return false;
108+
}
109+
return writeDirectCommand(CMD_CLEAR_FIFO) && //
110+
writeFIFO(tx, tx_len) && //
111+
writeNumberOfTransmittedBytes(tx_len, 0) && writeDirectCommand(CMD_TRANSMIT_WITH_CRC);
112+
}
113+
104114
bool UnitST25R3916::nfcfReceive(uint8_t* rx, uint16_t& rx_len, const uint32_t timeout_ms)
105115
{
106116
CHECK_MODE();

0 commit comments

Comments
 (0)