Hello Carlo,
Thank you for your response.
Yes I have assigned arbitrary non connected pins of the microcontroller to variables GPO_PIN and LPD_PIN as shown in the Arduino code below :
Code: Select all
#define SerialPort Serial
// Please define the pin and wire instance used for your board
#define GPO_PIN 1
#define LPD_PIN 2
#define SDA_PIN 8
#define SCL_PIN 9
#define WireNFC Wire1
To determine the SDA_PIN and SCL_PIN variables values, I read documentation about pins for the RP2040 and the correspondence with my µC (the "WizFi-EVB-Pico") and their numbering correspondence in Arduino (using arduino-pico library). From this information, I chose the first configuration of pins for I2C comm. (there are two possible configurations) which is to connect SDA to pin 8 and SCL to pin 9 on the µC and I guess that corresponds to Wire1.
Then I tried the following setup to test the I2C comm.:
Code: Select all
void setup() {
const char uri_write_message[] = "st.com/st25"; // Uri message to write in the tag
const char uri_write_protocol[] = URI_ID_0x01_STRING; // Uri protocol to write in the tag
String uri_write = String(uri_write_protocol) + String(uri_write_message);
String uri_read;
// Initialize serial for output.
SerialPort.begin(9600);
while (!SerialPort) delay(10);
delay(5000);
int st25dv_begin = st25dv.begin(GPO_PIN, LPD_PIN, &WireNFC);
SerialPort.println(st25dv_begin);
SerialPort.println(TEST);
}
I noticed the begin function returns another value than NDEF_OK which means that the system init failed. Next I try to see why.
The code below is the begin function. Following up, we notice that begin returns what BSP_NFCTAG_Init returns.
Code: Select all
int ST25DV::begin(uint8_t gpo, uint8_t lpd, TwoWire *pwire)
{
int ret = NDEF_OK;
uint8_t test;
_pwire = pwire;
_gpo = gpo;
_lpd = lpd;
ret = BSP_NFCTAG_Init();
if (ret != NDEF_OK) {
return ret;
}
/*
BSP_NFCTAG_GetExtended_Drv()->ResetMBEN_Dyn();
if (NfcType5_NDEFDetection() != NDEF_OK) {
CCFileStruct.MagicNumber = NFCT5_MAGICNUMBER_E1_CCFILE;
CCFileStruct.Version = NFCT5_VERSION_V1_0;
CCFileStruct.MemorySize = (ST25DV_MAX_SIZE / 8) & 0xFF;
CCFileStruct.TT5Tag = 0x05;
Init of the Type Tag 5 component (M24LR)
ret = NfcType5_TT5Init();
if (ret != NDEF_OK) {
return ret;
}
}
*/
return ret;
}
So I tried analyzing BSP_NFCTAG_Init (below). Here I did two tests :
# First test :
## I did not comment anything in this function
## I defined a global variable TEST to look at nfctag_id variable in the function
## I uploaded the program on the µC and read the serial monitor : it shows 0 (=0x00) which is neither I_AM_ST25DV04 or I_AM_ST25DV64 so I guess it means the µC doesn't "see" the ST25DV that I connected via I2C (I searched the ST25DV04K datasheet and did not find information about these identifiers)
# Second test :
## I commented the last part of the function (from TEST and so on) so I actually look at the result from St25Dv_i2c_Drv.Init()
## I kept the I2C wires connected, I uploaded the program on the µC and read the serial monitor : it shows 0 (=NDEF_OK=NFCTAG_OK)
## I disconnected the I2C wires, I uploaded the program on the µC and read the serial monitor : it still shows 0 (=NDEF_OK=NFCTAG_OK)
Unfortunately, I cannot access this function St25Dv_i2c_Drv.Init() and I am not sure what it actually means but so I don't know if this second test was actually relevant or not.
Code: Select all
NFCTAG_StatusTypeDef BSP_NFCTAG_Init()
{
uint8_t nfctag_id = 0;
if (!NfctagInitialized) {
if (St25Dv_i2c_Drv.Init == NULL) {
return NFCTAG_ERROR;
}
/* ST25DV Init */
if (St25Dv_i2c_Drv.Init() != NFCTAG_OK) {
return NFCTAG_ERROR;
}
/* Check ST25DV driver ID */
St25Dv_i2c_Drv.ReadID(&nfctag_id);
TEST = nfctag_id;
if ((nfctag_id == I_AM_ST25DV04) || (nfctag_id == I_AM_ST25DV64)) {
NfctagInitialized = 1;
Nfctag_Drv = &St25Dv_i2c_Drv;
Nfctag_Drv->pData = &St25Dv_i2c_ExtDrv;
} else {
Nfctag_Drv = NULL;
NfctagInitialized = 0;
return NFCTAG_ERROR;
}
}
return NFCTAG_OK;
}
Thanks if you read until here. Please let me know if you have any idea how to solve this problem.