完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
|
你好开发者,
我们目前正在开发一种产品,我们希望将 PN7160 NFC 阅读器与 STM32WL 微控制器连接起来,以与 ST25DV04KC 动态标签通信,以便使用 ST25DV 的邮箱功能在 NFC 阅读器和 ST25DV 标签之间发送和接收数据。 为此,我使用带有 ISO15693 协议和 nfc_example_RW函数的 SW6705 示例进行读写。 从这个例子中,我能够连接NxpNci_Connect、NxpNci_ConfigureSettings,在 NxpNci_ConfigureMode中,我使用的是 NXPNCI_MODE_RW。 之后可以完成 NxpNci_StartDiscovery, 我正在等待NxpNci_WaitForDiscoveryNotification,但我没有收到通知,我的代码将在 while 循环中停止, 我的代码片段如下, bool NxpNci_WaitForDiscoveryNotification(NxpNci_RfIntf_t *pRfIntf) { uint8_t NCIRfDiscoverSelect[] = {0x21, 0x04, 0x03, 0x01, PROT_ISODEP, INTF_ISODEP}; uint8_t Answer[MAX_NCI_FRAME_SIZE]; uint16_t AnswerSize; #ifndef REMOVE_P2P_SUPPORT uint8_t NCIStopDiscovery[] = {0x21, 0x06, 0x01, 0x00}; uint8_t NCIRestartDiscovery[] = {0x21, 0x06, 0x01, 0x03}; uint8_t saved_NTF[7]; wait: #endif //#ifndef REMOVE_P2P_SUPPORT do { if(NxpNci_WaitForReception(Answer, sizeof(Answer), &AnswerSize, TIMEOUT_INFINITE) == NXPNCI_ERROR) return NXPNCI_ERROR; }while ((Answer[0] != 0x61) || ((Answer[1] != 0x05) && (Answer[1] != 0x03))); gNextTag_Protocol = PROT_UNDETERMINED; /* Is RF_INTF_ACTIVATED_NTF ? */ if (Answer[1] == 0x05) { pRfIntf->Interface = Answer[4]; pRfIntf->Protocol = Answer[5]; pRfIntf->ModeTech = Answer[6]; pRfIntf->MoreTags = false; NxpNci_FillInterfaceInfo(pRfIntf, &Answer[10]); #ifndef REMOVE_P2P_SUPPORT /* Verifying if not a P2P device also presenting T4T emulation */ if ((pRfIntf->Interface == INTF_ISODEP) && (pRfIntf->Protocol == PROT_ISODEP) && ((pRfIntf->ModeTech & MODE_LISTEN) != MODE_LISTEN)) { memcpy(saved_NTF, Answer, sizeof(saved_NTF)); while(1) { /* Restart the discovery loop */ NxpNci_HostTransceive(NCIRestartDiscovery, sizeof(NCIRestartDiscovery), Answer, sizeof(Answer), &AnswerSize); NxpNci_WaitForReception(Answer, sizeof(Answer), &AnswerSize, TIMEOUT_100MS); /* Wait for discovery */ do NxpNci_WaitForReception(Answer, sizeof(Answer), &AnswerSize, TIMEOUT_1S); while ((AnswerSize == 4) && (Answer[0] == 0x60) && (Answer[1] == 0x07)); if ((AnswerSize != 0) && (Answer[0] == 0x61) && (Answer[1] == 0x05)) { /* Is same device detected ? */ if (memcmp(saved_NTF, Answer, sizeof(saved_NTF)) == 0) break; /* Is P2P detected ? */ if (Answer[5] == PROT_NFCDEP) { pRfIntf->Interface = Answer[4]; pRfIntf->Protocol = Answer[5]; pRfIntf->ModeTech = Answer[6]; pRfIntf->MoreTags = false; NxpNci_FillInterfaceInfo(pRfIntf, &Answer[10]); break; } } else { if (AnswerSize != 0) { /* Flush any other notification */ while(Answer != 0) NxpNci_WaitForReception(Answer, sizeof(Answer), &AnswerSize, TIMEOUT_100MS); /* Restart the discovery loop */ NxpNci_HostTransceive(NCIRestartDiscovery, sizeof(NCIRestartDiscovery), Answer, sizeof(Answer), &AnswerSize); NxpNci_WaitForReception(Answer, sizeof(Answer), &AnswerSize, TIMEOUT_100MS); } goto wait; } } } #endif //#ifndef REMOVE_P2P_SUPPORT } else /* RF_DISCOVER_NTF */ { pRfIntf->Interface = INTF_UNDETERMINED; pRfIntf->Protocol = Answer[4]; pRfIntf->ModeTech = Answer[5]; pRfIntf->MoreTags = true; /* Get next NTF for further activation */ do { if(NxpNci_WaitForReception(Answer, sizeof(Answer), &AnswerSize, TIMEOUT_100MS) == NXPNCI_ERROR) return NXPNCI_ERROR; } while ((Answer[0] != 0x61) || (Answer[1] != 0x03)); gNextTag_Protocol = Answer[4]; /* Remaining NTF ? */ while(Answer[AnswerSize-1] == 0x02) NxpNci_WaitForReception(Answer, sizeof(Answer), &AnswerSize, TIMEOUT_100MS); /* In case of multiple cards, select the first one */ NCIRfDiscoverSelect[4] = pRfIntf->Protocol; if (pRfIntf->Protocol == PROT_ISODEP) NCIRfDiscoverSelect[5] = INTF_ISODEP; else if (pRfIntf->Protocol == PROT_NFCDEP) NCIRfDiscoverSelect[5] = INTF_NFCDEP; else if (pRfIntf->Protocol == PROT_MIFARE) NCIRfDiscoverSelect[5] = INTF_TAGCMD; else NCIRfDiscoverSelect[5] = INTF_FRAME; NxpNci_HostTransceive(NCIRfDiscoverSelect, sizeof(NCIRfDiscoverSelect), Answer, sizeof(Answer), &AnswerSize); if ((Answer[0] == 0x41) || (Answer[1] == 0x04) || (Answer[3] == 0x00)) { NxpNci_WaitForReception(Answer, sizeof(Answer), &AnswerSize, TIMEOUT_100MS); if ((Answer[0] == 0x61) || (Answer[1] == 0x05)) { pRfIntf->Interface = Answer[4]; pRfIntf->Protocol = Answer[5]; pRfIntf->ModeTech = Answer[6]; NxpNci_FillInterfaceInfo(pRfIntf, &Answer[10]); } #ifndef REMOVE_P2P_SUPPORT /* In case of P2P target detected but lost, inform application to restart discovery */ else if (pRfIntf->Protocol == PROT_NFCDEP) { /* Restart the discovery loop */ NxpNci_HostTransceive(NCIStopDiscovery, sizeof(NCIStopDiscovery), Answer, sizeof(Answer), &AnswerSize); NxpNci_WaitForReception(Answer, sizeof(Answer), &AnswerSize, TIMEOUT_100MS); NxpNci_HostTransceive(NCIStartDiscovery, NCIStartDiscovery_length, Answer, sizeof(Answer), &AnswerSize); goto wait; } #endif //#ifndef REMOVE_P2P_SUPPORT } } /* In case of unknown target align protocol information */ if (pRfIntf->Interface == INTF_UNDETERMINED) pRfIntf->Protocol = PROT_UNDETERMINED; return NXPNCI_SUCCESS; } 在这一行,我的代码停止连续轮询发现通知 do { if(NxpNci_WaitForReception(Answer, sizeof(Answer), &AnswerSize, TIMEOUT_INFINITE) == NXPNCI_ERROR) return NXPNCI_ERROR; }while ((Answer[0] != 0x61) || ((Answer[1] != 0x05) && (Answer[1] != 0x03))); 收到的答复是, 答案[0] = 0x61, 答案[1]=0x23, 实际上 Answer[1] 收到 0x05 或 0x03 但我得到 ox23, 所以请建议我是否在做正确或错误的配置。 |
|
相关推荐
|
|
只有小组成员才能发言,加入小组>>
2135个成员聚集在这个小组
加入小组我的项目我做主,使用GN+Ninja来完成构建系统(VSCode开发RT106X)
37376 浏览 0 评论
NXP IMX8应用处理器快速入门必备:技巧、使用、设计指南
6775 浏览 1 评论
7793 浏览 1 评论
7642 浏览 0 评论
NXP i.MX6UL开发板(linux系统烧录+规格+硬件+模块移植)使用手册
5071 浏览 0 评论
1556浏览 2评论
关于NINA-W132 Wi-Fi模块SPI通信遇到的疑问求解
1208浏览 2评论
如何在MPC PowerPC MCU上首次刷写后禁用BDM?
749浏览 1评论
将HFREFR和LFREFR寄存器值设置为错误的值来将故障注入CMU,但CMU_ISR值始终为零,为什么?
735浏览 1评论
将SPSDK for FRDM-MCX-W71 SDK与VS一起安装时出现hidapi构建错误怎么解决?
678浏览 1评论
/9
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2025-12-2 04:19 , Processed in 1.999404 second(s), Total 70, Slave 53 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191

淘帖
5064