From c34533f32addfac7071dfb99e09936d7230ae3fb Mon Sep 17 00:00:00 2001 From: chenjintao Date: Tue, 22 Sep 2026 15:58:21 +0800 Subject: [PATCH] fix(nfc): preserve target activation during ATS --- .../threadx/interface/custom_app/nfc.c | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/ql-application/threadx/interface/custom_app/nfc.c b/ql-application/threadx/interface/custom_app/nfc.c index 281c6f4..95a6308 100644 --- a/ql-application/threadx/interface/custom_app/nfc.c +++ b/ql-application/threadx/interface/custom_app/nfc.c @@ -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++) {