Firmware library for the X-NUCLEO-NFC01A1 Dynamic NFC Tag board.
Dependencies: M24SR
Dependents: NFC M2M_2016_STM32 MyongjiElec_capstone1 IDW01M1_Cloud_IBM ... more
Fork of X_NUCLEO_NFC01A1 by
X-NUCLEO-NFC01A1 Dynamic NFC Tag Expansion Board Firmware Package
Introduction
This firmware package includes Components Device Drivers, Board Support Package and example applications for STMicroelectronics X-NUCLEO-NFC01A1 Dynamic NFC Tag Expansion Board based on M24SR.
Firmware Library
Class X_NUCLEO_NFC01A1 is intended to represent the Dynamic NFC Tag Expansion Board with the same name.
It provides an API to access to the M24SR component and to the three onboard LEDs.
It is intentionally implemented as a singleton because only one X_NUCLEO_NFC01A1 at a time might be deployed in a HW component stack.
The library also provides an implementation of the NDEF library API for M24SR, providing an simple way to read/write NDEF formatted messages from/to the M24SR dynamic NFC tag.
Example applications
1. Hello World
2. Asynchronous Hello World
Revision 16:b0d62f4b185a, committed 2016-01-19
- Comitter:
- giovannivisentini
- Date:
- Tue Jan 19 08:08:00 2016 +0000
- Parent:
- 15:67e136b6921d
- Child:
- 17:c750fff4a096
- Commit message:
- more roubust interrupt handle
Changed in this revision
--- a/m24sr/NDefNfcTagM24SR.cpp Fri Jan 15 11:02:30 2016 +0000
+++ b/m24sr/NDefNfcTagM24SR.cpp Tue Jan 19 08:08:00 2016 +0000
@@ -34,6 +34,7 @@
*
******************************************************************************
*/
+#include "mbed.h"
#include "NDefNfcTagM24SR.h"
@@ -64,11 +65,13 @@
} //else
//Select the NFC type 4 application
- if (mDevice.SelectApplication() != NFC_SUCCESS)
+ if (mDevice.SelectApplication() != NFC_SUCCESS){
return false;
+ }
- if (mDevice.SelectCCfile() != NFC_SUCCESS)
+ if (mDevice.SelectCCfile() != NFC_SUCCESS){
return false;
+ }
uint8_t CCFile[CC_FILE_LENGTH_BYTE];
/* read the first 15 bytes of the CC file */
--- a/m24sr/m24sr_class.cpp Fri Jan 15 11:02:30 2016 +0000
+++ b/m24sr/m24sr_class.cpp Tue Jan 19 08:08:00 2016 +0000
@@ -41,8 +41,14 @@
/* Includes ------------------------------------------------------------------*/
#include "m24sr_class.h"
#include "m24sr.h"
+#ifdef GPIO_PIN_RESET
+ #undef GPIO_PIN_RESET
+#endif
+#define GPIO_PIN_RESET (0)
-#define GPIO_PIN_RESET (0)
+#ifdef GPIO_PIN_SET
+ #undef GPIO_PIN_SET
+#endif
#define GPIO_PIN_SET (1)
/**
@@ -68,6 +74,7 @@
/** call the fCall funtion and check that the return status is NFC_SUCCESS,
* otherwise return the error status*/
+ //printf("call status: %x\n\r",status);
#define errchk(fCall) {\
const NFC_StatusTypeDef status = (fCall); \
if((status!=NFC_SUCCESS)) \
@@ -330,8 +337,9 @@
errchk(M24SR_IO_IsAnswerReady());
/* read the response */
errchk(M24SR_IO_ReceiveI2Cresponse(sizeof(pDataIn), pDataIn));
-
+
status= M24SR_IsCorrectCRC16Residue(pDataIn, sizeof(pDataIn));
+ //printf("M24SR_IsCorrectCRC16Residue %x\r\n",status);
if(status == NFC_COMMAND_SUCCESS)
return NFC_SUCCESS;
@@ -1108,7 +1116,7 @@
#define M24SR_POLL_DELAY 10
/* In case M24SR will reply ACK failed allow to perform retry before returning error (HAL option not used) */
-#define M24SR_I2C_POLLING 200
+#define M24SR_I2C_POLLING 2000
NFC_StatusTypeDef M24SR::M24SR_IO_PollI2C(void) {
@@ -1132,7 +1140,7 @@
uint32_t retry = 0xFFFFF;
int8_t stable = 0;
uint8_t PinState;
-
+
switch (syncMode) {
case M24SR_WAITINGTIME_POLLING:
return M24SR_IO_PollI2C();
@@ -1159,14 +1167,21 @@
/* Check if the GPIO is not already low before calling this function */
M24SR_IO_GPO_ReadPin(&PinState);
- answerReadyInterrupt.enable_irq();
+
if (PinState == GPIO_PIN_SET) {
- while (!interruptIsFired)
+ //prepare and set the inpterrupt
+ interruptIsFired = false;
+ answerReadyInterrupt.enable_irq();
+ while (PinState == GPIO_PIN_SET ){
__WFE();
- }
- //the interrupt is disable insde the interrupt callback
- //answerReadyInterrupt.disable_irq();
- interruptIsFired = false;
+ //if we weake up for our interrupt, update the gpo state
+ if(interruptIsFired)
+ M24SR_IO_GPO_ReadPin(&PinState);
+ }//while
+ //disable the interrupt
+ answerReadyInterrupt.disable_irq();
+ }//if
+
return NFC_SUCCESS;
default:
--- a/m24sr/m24sr_class.h Fri Jan 15 11:02:30 2016 +0000
+++ b/m24sr/m24sr_class.h Tue Jan 19 08:08:00 2016 +0000
@@ -94,7 +94,6 @@
answerReadyInterrupt.fall(this,
&M24SR::M24SR_AnswerReadyInterruptCallback);
answerReadyInterrupt.mode(PullUp);
-
}
/**
@@ -415,7 +414,6 @@
*/
void M24SR_AnswerReadyInterruptCallback() {
interruptIsFired = true;
- answerReadyInterrupt.disable_irq();
}
/*** Component's Instance Variables ***/

X-NUCLEO-NFC01A1 Dynamic NFC Tag