NxpNci: PN7150 non-blocking card discovery on bare-metal

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

NxpNci: PN7150 non-blocking card discovery on bare-metal

346 次查看
QuarterOpposite
Contributor I

We're using the PN7150 in a product that needs to do both NFC communication and UART at the same time on bare metal (so no RTOS). The problem is that the library call for card discovery is blocking until a card is discovered, but we need to execute other code while no card is detected. Is there a non-blocking, poll based alternative to NxpNci_WaitForDiscoveryNotification that we can call in a while-loop?

 

This code is based on https://www.nxp.com/docs/en/application-note/AN11990.pdf, which says it should be possible to use on bare metal (they call it NullOS).

 

if (initializeReaderLibraryModules() != NFC_SUCCESS) {
        PRINTF("Error: cannot initialize Reader library modules\n");
        return;
    }

    /* Open connection to NXPNCI device */
    if (NxpNci_Connect() == NFC_ERROR) {
        PRINTF("Error: cannot connect to NXPNCI device\n");
        return;
    }

    if (NxpNci_ConfigureSettings() == NFC_ERROR) {
        PRINTF("Error: cannot configure NXPNCI settings\n");
        return;
    }

    if (NxpNci_ConfigureMode(NXPNCI_MODE_RW) == NFC_ERROR)
    {
        PRINTF("Error: cannot configure NXPNCI\n");
        return;
    }

    /* Start Discovery */
    if (NxpNci_StartDiscovery(DiscoveryTechnologies,sizeof(DiscoveryTechnologies)) != NFC_SUCCESS)
    {
        PRINTF("Error: cannot start discovery\n");
        return;
    }

    while(1)
    {
        PRINTF("\nWAITING FOR DEVICE DISCOVERY\n");

        /* Wait until a peer is discovered */
        NxpNci_WaitForDiscoveryNotification(&gRfInterface);

 

0 项奖励
5 回复数

324 次查看
KellyLi
NXP TechSupport
NXP TechSupport

Hello @QuarterOpposite 

It is recommended that you wait for two events in a while loop to switch NFC and UART tasks. These two events can be obtained through interrupts. One is NFC trigger and the other is UART trigger.

0 项奖励

308 次查看
QuarterOpposite
Contributor I

That sounds like what I want to do. Is there a way to do this with the NxpNci library? The NxpNci_WaitForDiscoveryNotification function is blocking, is there another function I can use to poll?

0 项奖励

298 次查看
KellyLi
NXP TechSupport
NXP TechSupport

Hello @QuarterOpposite 

Without an OS, the simplest implementation interrupts the flag bit to switch between the two tasks. For example, wait for two interrupt flags in the While(1) loop, when its related interrupt is set and execute the corresponding task.

BR

kelly

0 项奖励

285 次查看
QuarterOpposite
Contributor I

Is there a way to do that with the library from sw375625 as-is?

It appears that I would have to modify that library to get polling working.

0 项奖励

275 次查看
KellyLi
NXP TechSupport
NXP TechSupport

Hello @QuarterOpposite

This needs to be your own implementation, our routines are single thread and based on RTOS, your system is not with OS, so you need to follow the previously mentioned logic to implement your own.

0 项奖励