arduino / arduino/ArduinoCore-mbed

Nano 33 BLE NFC driver - trying to set one up

Open
#440 14 comments 0 reactions 0 assignees View on GitHub
Dominant language
C
Stars
411
Forks
225
PR merge metrics
No merged PRs in 30d

Description

I spotted an article showing how to link precompiled libraries inside Arduino. So I thought to try this out with my Arduino Nano 33 BLE board as the Nordic Semiconductor's nRF52 SDK for the nRF52840 SoC uses two precompiled libraries to handle part of the NFC tag functionality (namely nfc_t2t_lib_#### and nfc_t4t_lib_####).

So I created a new library folder inside my Arduino libraries folder and gave it a name (e.g. nRF52_NFC). Inside this folder I then created a folder called _cortex-m4_ and inside this another one called _fpv4-sp-d16-softfp_.

I then went to the _./components/nfc/t2t_lib_ folder (for t2t_lib) within my Nordic Semiconductor nRF52 SDK folder and copied nfc_t2t_lib.h and nfc_t2t_lib_gcc.a. The nfc_t2t_lib.h file went inside the library folder (e.g. nRF52_NFC) and the nfc_t2t_lib_gcc.a file went inside _fpv4-sp-d16-softfp_. Then nfc_t2t_lib_gcc needed to be renamed to **libnfc_t2t_lib.a**. The "lib" prefix is required.

I then created my library.properties file within the library folder and added the following, in addition the standard requirements:
```
architectures=mbed_nano
precompiled=true
includes=nfc_t2t_lib.h
ldflags=-lnfc_t2t_lib
```

This all worked, as in, I could get Arduino to accept the .a file as a precompiled library... but that is only 1% of the solution.

As soon as I add the function `nfc_t2t_setup(nfc_callback, NULL);` or `nfc_t4t_setup(nfc_callback, NULL);` inside my Arduino code (setup routine) all the interface issues/errors start.

Note that for the nfc_callback I simply added this function inside my Arduino code.

```
/**
* @brief Callback function for handling NFC events.
*/
static void nfc_callback(void * p_context, nfc_t2t_event_t event, const uint8_t * p_data, size_t data_length)
{
(void)p_context;

switch (event)
{
case NFC_T2T_EVENT_FIELD_ON:
Serial.println("\r\nNFC_T2T_EVENT_FIELD_ON");
break;
case NFC_T2T_EVENT_FIELD_OFF:
Serial.println("\r\nNFC_T2T_EVENT_FIELD_OFF");
break;
default:
break;
}
}
```

This is where I need help. For example, if I add in the functions from nfc_platform.h, for example, it then bumps into clock related issues. **So I am not sure where mbedOS clock drivers can be used versus relying on nRF drivers for clocks etc.**

Before I try take this further, has anyone looked at adding NFC as part of making compatible ArduinoCore-mbed library.

Any guidance appreciated in tackling this issue.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with the library.properties setup and the nfc_t2t_setup/nfc_t4t_setup calls, then read nfc_platform.h and trace the reported clock-related interfaces between mbedOS and the nRF drivers. The issue does not define a concrete completion criterion; done would need an agreed NFC integration scope and a working Nano 33 BLE example.

Written by the indexing model from the issue text.

Assessment

Tech stack
c
Domain
embedded-iot
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.