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

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

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

772 Views
QuarterOpposite
Contributor II

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 Kudos
Reply
5 Replies

750 Views
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 Kudos
Reply

734 Views
QuarterOpposite
Contributor II

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 Kudos
Reply

724 Views
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 Kudos
Reply

711 Views
QuarterOpposite
Contributor II

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 Kudos
Reply

701 Views
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 Kudos
Reply