完善资料让更多小伙伴认识你,还能领取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, 所以请建议我是否在做正确或错误的配置。 |
|
相关推荐
|
|
只有小组成员才能发言,加入小组>>
1907个成员聚集在这个小组
加入小组我的项目我做主,使用GN+Ninja来完成构建系统(VSCode开发RT106X)
36358 浏览 0 评论
NXP IMX8应用处理器快速入门必备:技巧、使用、设计指南
4396 浏览 0 评论
6050 浏览 1 评论
6763 浏览 0 评论
NXP i.MX6UL开发板(linux系统烧录+规格+硬件+模块移植)使用手册
4213 浏览 0 评论
619浏览 2评论
求助,S32G上Core M启动后如何让Core A在Flash指定位置加载uboot?
615浏览 2评论
ESP32-WROVER-IE + LAN8720以太网,GPIO0电压只有1.6v,无法正常进入spi flash boot模式如何解决?
606浏览 2评论
求分享适用于PN7160 Android的NFC工厂测试应用程序
694浏览 2评论
798浏览 2评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-11-23 17:26 , Processed in 1.103249 second(s), Total 76, Slave 60 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号