fix(nfc): preserve target activation during ATS

This commit is contained in:
chenjintao
2026-09-22 15:58:21 +08:00
parent 14c0065bb1
commit c34533f32a
@@ -107,15 +107,14 @@ static u8 nfc_card_emulation_send_frame(const u8 *frame, u8 length)
u16 poll_count;
u8 irq;
/* Stop the AutoColl-created Transceive before starting a clean TX. */
DP1312EA_WriteRawRC(CommandReg, DP1312EA_IDLE);
/* AutoColl has activated target mode and changed to Transceive. Keep it
* active: writing Idle here clears TargetActivated in Status2Reg. */
DP1312EA_WriteRawRC(ComIrqReg, 0x7F);
DP1312EA_SetBitMask(FIFOLevelReg, 0x80);
DP1312EA_SetBitMask(TxModeReg, 0x80);
DP1312EA_SetBitMask(RxModeReg, 0x80);
DP1312EA_WriteRawRC(BitFramingReg, 0x00);
DP1312EA_WriteFIFO((u8 *)frame, length);
DP1312EA_WriteRawRC(CommandReg, DP1312EA_TRANSMIT);
DP1312EA_SetBitMask(BitFramingReg, 0x80);
for (poll_count = 0; poll_count < NFC_CARD_TX_POLLS; poll_count++) {
@@ -135,15 +134,6 @@ static u8 nfc_card_emulation_send_frame(const u8 *frame, u8 length)
return 0;
}
static void nfc_card_emulation_start_receive(void)
{
DP1312EA_WriteRawRC(CommandReg, DP1312EA_IDLE);
DP1312EA_WriteRawRC(ComIrqReg, 0x7F);
DP1312EA_SetBitMask(FIFOLevelReg, 0x80);
DP1312EA_WriteRawRC(BitFramingReg, 0x00);
DP1312EA_WriteRawRC(CommandReg, DP1312EA_RECEIVE);
}
static void nfc_card_emulation_configure_iso_dep(void)
{
static const u8 card_config[] = {
@@ -214,7 +204,10 @@ static void nfc_card_emulation_task(void)
nfc_card_emulation_log_frame("ATS TX complete", ats,
sizeof(ats));
nfc_card_emulation_start_receive();
/* Transceive automatically switches from transmit to receive.
* Only clear the completed TX interrupt; do not stop command. */
DP1312EA_WriteRawRC(ComIrqReg, NFC_IRQ_TX);
for (poll_count = 0;
poll_count < NFC_CARD_RX_POLLS;
poll_count++) {