cancel
Showing results for 
Search instead for 
Did you mean: 

X-NUCLEO-NFC06A1 over i2c

KVoul.1
Associate III

Hello,

I want to use X-NUCLEO-NFC06A1 with an esp32 pico kit over i2c. I have the read/write functions from esp and I can read a register from the module. I want to use the code you provide to read an nxp ntag (ndef_t2t.c in x-cube examples has some functions) . I studied the linux demo with SPI and read the cube-x code and rfal.chm.

  1. I understand that if I provide some functions in a platform.h and with a custom analog config, then I can use the whole linux example to the esp oer i2c, is that correct? How do I use the NDEFs in the cube example? The linux demo does not use them.
  2. has someone done something similar? I could use some guidance for the analog_config
1 ACCEPTED SOLUTION

Accepted Solutions
Brian TIDAL
ST Employee

Hi Katerina,

I suggest to follow §3.5.1 of UM2616 for the  X-NUCLEO-NFC06A1 expansion board setup modification for the proper i2c hardware setup.

Then, add RFAL_USE_I2C preprocessor compilation flag in your project.

Than you have to replace pltf_spi.c/.h by your I2C wrapper functions and update platform.h:

#define platformI2CTx(txBuf, len, last, txOnly)       i2c_tx(txBuf, len, last, txOnly)                         /*!< I2C Transmit                                */
#define platformI2CRx(rxBuf, len)                     i2c_rx(rxBuf, len)                                       /*!< I2C Receive                                 */
#define platformI2CStart()                            i2c_start()                                              /*!< I2C Start condition                         */

(assuming i2c_tx, i2x_rx and i2c_start are your i2c wrapper fonctions)

As far as I know, the analog config does not need modification when moving from spi to i2c.

if you want to use NDEF, you just need to add the various ndef_*.c/.h from cube package to your project and use the ndef_demo.c instead of the Linux demo. As the underlaying RFAL version is different, you may need to do some light adaptation.

Rgds

BT

In order to give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

View solution in original post

7 REPLIES 7
Brian TIDAL
ST Employee

Hi Katerina,

I suggest to follow §3.5.1 of UM2616 for the  X-NUCLEO-NFC06A1 expansion board setup modification for the proper i2c hardware setup.

Then, add RFAL_USE_I2C preprocessor compilation flag in your project.

Than you have to replace pltf_spi.c/.h by your I2C wrapper functions and update platform.h:

#define platformI2CTx(txBuf, len, last, txOnly)       i2c_tx(txBuf, len, last, txOnly)                         /*!< I2C Transmit                                */
#define platformI2CRx(rxBuf, len)                     i2c_rx(rxBuf, len)                                       /*!< I2C Receive                                 */
#define platformI2CStart()                            i2c_start()                                              /*!< I2C Start condition                         */

(assuming i2c_tx, i2x_rx and i2c_start are your i2c wrapper fonctions)

As far as I know, the analog config does not need modification when moving from spi to i2c.

if you want to use NDEF, you just need to add the various ndef_*.c/.h from cube package to your project and use the ndef_demo.c instead of the Linux demo. As the underlaying RFAL version is different, you may need to do some light adaptation.

Rgds

BT

In order to give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
KVoul.1
Associate III

Hello, can you explain the "sequential i2c read/write" I see in cube-x example? It does not read any specific register, is it an i2c dump? How does the interrupt work? (functions BSP_I2C1_SequencialRecv, HAL_I2C_Master_Seq_Receive_IT etc)

Brian TIDAL
ST Employee

Hi,

do you plan to use a Linux based implementation or a bare metal implementation?

Rgds

BT

In order to give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
KVoul.1
Associate III

Hi,

I want to use the nfc0a61 to pair wih a tag with an espressif esp32 and it runs freeRTOS. I don't know if it couns as bare metal.

I can keep the posix mutexes implementation from linux_demo (pltf_protect_com, pltf_protect_worker etc) because espressif gives pthread functions implemented from freeRTOS xMutexes. I can create a task to read the IRQ pin.

I have not yet created timers to replace plfTimerCreate(t) and plfTimerIsExpired(t).

Is there another way, than to modify the linux example?

Brian TIDAL
ST Employee

Hi,

our ST25 Embedded NFC library includes a polling loop example with FreeRTOS for X-NUCLEO-NFC06A1 + STM32 MCU. This is a full functional example (over SPI communication). The ST25R3916 interrupt is managed through a dedicated ISR task. I would suggest to base your development on this example and then migrate from SPI to I2C.

By the way, why do you prefer to use I2C rather than SPI?

Rgds

BT

In order to give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
KVoul.1
Associate III

Hello,

in order to use the hal code I need to write a sequential read from i2c for esp32, as these:

BSP_I2C1_SequencialSend((uint16_t)0xA0, (uint8_t *)(txBuf), (len), last, txOnly )
BSP_I2C1_SequencialRecv((uint16_t)0xA0, rxBuf, len ) 

st25r3916 datasheet describes a FIFO read and write, is that the sequential send/recv?

I found an I2C_TransferConfig function in the cube-x example code, can you explain more about the registers it writes/reads so I can implement it for my board or do I just follow the datasheet?

Brian TIDAL
ST Employee

Hi,

those 2 BSP functions basically implements the I2C communication as described in §4.3.4 of the ST25R3916 datasheet on top of STM32 HAL I2C API.

Depending on your esp32 i2c api, you may need to implement as well other macros from platform.h such as platformI2CStart()

See attached picture for a example of Reading a single byte from a register over i2c.

Rgds

BT

In order to give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.