This application provides a set of demos with X-NUCLEO-NFC01A1 expansion board.
Dependencies: NDefLib X_NUCLEO_NFC01A1 mbed
Fork of X-MBED-NFC1 by
This application provides a set of demos with X-NUCLEO-NFC01A1 expansion board.
The available demos are:
- SAMPLE_WRITE_URL: write a tag with the ST home page URL
- SAMPLE_COUNT_CLICK: create a custom tag to count and report the user button clicks.
- SAMPLE_WRITE_AND_CHANGE_ALL: write a tag with all the supported records and update the tag contents when the user button is pressed.
- SAMPLE_LOCK_TAG_CONTENT: use the M24SR component API to set the NFC tag as read-only.
To enable the different demos comment/uncomment the SAMPLE_* macros provided in main.cpp .
Diff: m24sr/m24sr_class.cpp
- Revision:
- 2:0648c1561eb2
- Parent:
- 1:6d202b62ed68
--- a/m24sr/m24sr_class.cpp Fri Nov 27 15:10:25 2015 +0000
+++ b/m24sr/m24sr_class.cpp Tue Dec 01 08:30:54 2015 +0000
@@ -36,20 +36,15 @@
******************************************************************************
*/
-/* Generated with Stm32CubeTOO -----------------------------------------------*/
-/* Revision ------------------------------------------------------------------*/
-/*
- Repository: http://svn.x-nucleodev.codex.cro.st.com/svnroot/X-NucleoDev
- Branch/Trunk/Tag: trunk
- Based on: X-CUBE-MEMS1/trunk/Drivers/BSP/Components/m24sr/m24sr.c
- Revision: :410
- */
/* Includes ------------------------------------------------------------------*/
#include "m24sr_class.h"
#include "m24sr.h"
+/**
+ * default password, it is used also for reach the super user mode throught the i2c channel
+ */
const uint8_t M24SR::DEFAULT_PASSWORD[16] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
@@ -64,7 +59,12 @@
*/
#ifndef errchk
+
+/** value return by the NFC chip when a command is successfully done */
#define NFC_COMMAND_SUCCESS 0x9000
+
+/** call the fCall funtion and check that the return status is NFC_COMMAND_SUCCESS,
+ * otherwise return the error status*/
#define errchk(fCall) {\
const NFC_StatusTypeDef status = (fCall); \
if((status!=NFC_SUCCESS)) \
@@ -108,7 +108,7 @@
/**
* @brief This function computes the CRC16 residue as defined by CRC ISO/IEC 13239
* @param DataIn : input to data
- * @param Length : Number of bits of DataIn
+ * @param Length : Number of bits of DataIn
* @retval Status (SW1&SW2) : CRC16 residue is correct
* @retval M24SR_ERROR_CRC : CRC16 residue is false
*/
@@ -266,7 +266,7 @@
* @brief This function sends the FWT extension command (S-Block format)
* @param FWTbyte : FWT value
* @retval Status (SW1&SW2) : Status of the operation to complete.
- * @retval M24SR_ERROR_I2CTIMEOUT : The I2C timeout occured.
+ * @retval M24SR_ERROR_I2CTIMEOUT : The I2C timeout occurred.
*/
NFC_StatusTypeDef M24SR::M24SR_FWTExtension(uint8_t FWTbyte) {
uint8_t pBuffer[M24SR_STATUSRESPONSE_NBBYTE];
@@ -301,8 +301,8 @@
/**
* @brief This function sends the KillSession command to the M24SR device
* @param None
- * @retval NFC_OK : the function is succesful.
- * @retval M24SR_ERROR_I2CTIMEOUT : The I2C timeout occured.
+ * @retval NFC_SUCCESS : the function is successful.
+ * @retval M24SR_ERROR_I2CTIMEOUT : The I2C timeout occurred.
*/
NFC_StatusTypeDef M24SR::M24SR_KillSession(void) {
uint8_t commandBuffer[] = M24SR_KILLSESSION_COMMAND;
@@ -319,8 +319,8 @@
/**
* @brief This function sends the Deselect command (S-Block format)
- * @retval NFC_OK : the function is succesful.
- * @retval M24SR_ERROR_I2CTIMEOUT : The I2C timeout occured.
+ * @retval NFC_SUCCESS : the function is successful.
+ * @retval M24SR_ERROR_I2CTIMEOUT : The I2C timeout occurred.
*/
NFC_StatusTypeDef M24SR::M24SR_Deselect(void) {
uint8_t pBuffer[] = M24SR_DESELECTREQUEST_COMMAND;
@@ -337,8 +337,8 @@
/**
* @brief This function sends the SelectApplication command
- * @retval NFC_OK : the function is succesful.
- * @retval M24SR_ERROR_I2CTIMEOUT : The I2C timeout occured.
+ * @retval NFC_SUCCESS : the function is successful.
+ * @retval M24SR_ERROR_I2CTIMEOUT : The I2C timeout occurred.
*/
NFC_StatusTypeDef M24SR::M24SR_SelectApplication(void) {
@@ -408,7 +408,7 @@
/**
* @brief This function sends the GetSession command to the M24SR device
- * @retval NFC_OK : the function is succesful.
+ * @retval NFC_SUCCESS : the function is successful.
* @retval Status (SW1&SW2) : if operation does not complete.
*/
NFC_StatusTypeDef M24SR::M24SR_GetSession(void) {
@@ -427,8 +427,8 @@
/**
* @brief This function sends the SelectCCFile command
- * @retval NFC_OK : the function is succesful.
- * @retval M24SR_ERROR_I2CTIMEOUT : The I2C timeout occured.
+ * @retval NFC_SUCCESS : the function is successful.
+ * @retval M24SR_ERROR_I2CTIMEOUT : The I2C timeout occurred.
* @retval Status (SW1&SW2) : if operation does not complete for another reason.
*/
NFC_StatusTypeDef M24SR::M24SR_SelectCCfile(void) {
@@ -471,7 +471,7 @@
/**
* @brief This function sends the SelectSystemFile command
* @retval Status (SW1&SW2) : Status of the operation to complete.
- * @retval M24SR_ERROR_I2CTIMEOUT : The I2C timeout occured.
+ * @retval M24SR_ERROR_I2CTIMEOUT : The I2C timeout occurred.
*/
NFC_StatusTypeDef M24SR::M24SR_SelectSystemfile(void) {
C_APDU command;
@@ -513,7 +513,7 @@
/**
* @brief This function sends the SelectNDEFfile command
* @retval Status (SW1&SW2) : Status of the operation to complete.
- * @retval M24SR_ERROR_I2CTIMEOUT : The I2C timeout occured.
+ * @retval M24SR_ERROR_I2CTIMEOUT : The I2C timeout occurred.
*/
NFC_StatusTypeDef M24SR::M24SR_SelectNDEFfile(uint16_t NDEFfileId) {
C_APDU command;
@@ -557,7 +557,7 @@
* @param NbByteToRead : number of byte to read
* @param pBufferRead : pointer of the buffer read from the M24SR device
* @retval Status (SW1&SW2) : Status of the operation to complete.
- * @retval M24SR_ERROR_I2CTIMEOUT : The I2C timeout occured.
+ * @retval M24SR_ERROR_I2CTIMEOUT : The I2C timeout occurred.
*/
NFC_StatusTypeDef M24SR::M24SR_ReadBinary(uint16_t Offset, uint8_t NbByteToRead,
uint8_t *pBufferRead) {
@@ -599,7 +599,7 @@
* @param NbByteToRead : number of byte to read
* @param pBufferRead : pointer of the buffer read from the M24SR device
* @retval Status (SW1&SW2) : Status of the operation to complete.
- * @retval M24SR_ERROR_I2CTIMEOUT : The I2C timeout occured.
+ * @retval M24SR_ERROR_I2CTIMEOUT : The I2C timeout occurred.
*/
NFC_StatusTypeDef M24SR::M24SR_STReadBinary(uint16_t Offset,
uint8_t NbByteToRead, uint8_t *pBufferRead) {
@@ -641,7 +641,7 @@
* @param NbByteToWrite : number of byte to write
* @param pBufferRead : pointer of the buffer read from the M24SR device
* @retval Status (SW1&SW2) : Status of the operation to complete.
- * @retval M24SR_ERROR_I2CTIMEOUT : The I2C timeout occured.
+ * @retval M24SR_ERROR_I2CTIMEOUT : The I2C timeout occurred.
*/
NFC_StatusTypeDef M24SR::M24SR_UpdateBinary(uint16_t Offset,
uint8_t NbByteToWrite, uint8_t *pDataToWrite) {
@@ -699,7 +699,7 @@
* @param NbPwdByte : Number of byte ( 0x00 or 0x10)
* @param pPwd : pointer on the passwaord
* @retval Status (SW1&SW2) : Status of the operation to complete.
- * @retval M24SR_ERROR_I2CTIMEOUT : The I2C timeout occured.
+ * @retval M24SR_ERROR_I2CTIMEOUT : The I2C timeout occurred.
*/
NFC_StatusTypeDef M24SR::M24SR_Verify(uint16_t uPwdId, uint8_t NbPwdByte,
const uint8_t *pPwd) {
@@ -760,7 +760,7 @@
* @param uPwdId : PasswordId ( 0x0001 : Read NDEF pwd or 0x0002 : Write NDEF pwd or 0x0003 : I2C pwd)
* @param pPwd : pointer on the passwaord
* @retval Status (SW1&SW2) : Status of the operation to complete.
- * @retval M24SR_ERROR_I2CTIMEOUT : The I2C timeout occured.
+ * @retval M24SR_ERROR_I2CTIMEOUT : The I2C timeout occurred.
*/
NFC_StatusTypeDef M24SR::M24SR_ChangeReferenceData(uint16_t uPwdId,
uint8_t *pPwd) {
@@ -807,7 +807,7 @@
* @brief This function sends the EnableVerificationRequirement command
* @param uReadOrWrite : enable the read or write protection ( 0x0001 : Read or 0x0002 : Write )
* @retval Status (SW1&SW2) : Status of the operation to complete.
- * @retval M24SR_ERROR_I2CTIMEOUT : The I2C timeout occured.
+ * @retval M24SR_ERROR_I2CTIMEOUT : The I2C timeout occurred.
*/
NFC_StatusTypeDef M24SR::M24SR_EnableVerificationRequirement(
uint16_t uReadOrWrite) {
@@ -850,7 +850,7 @@
* @brief This function sends the DisableVerificationRequirement command
* @param uReadOrWrite : enable the read or write protection ( 0x0001 : Read or 0x0002 : Write )
* @retval Status (SW1&SW2) : Status of the operation to complete.
- * @retval M24SR_ERROR_I2CTIMEOUT : The I2C timeout occured.
+ * @retval M24SR_ERROR_I2CTIMEOUT : The I2C timeout occurred.
*/
NFC_StatusTypeDef M24SR::M24SR_DisableVerificationRequirement(
uint16_t uReadOrWrite) {
@@ -895,7 +895,7 @@
* @brief This function sends the EnablePermananentState command
* @param uReadOrWrite : enable the read or write protection ( 0x0001 : Read or 0x0002 : Write )
* @retval Status (SW1&SW2) : Status of the operation to complete.
- * @retval M24SR_ERROR_I2CTIMEOUT : The I2C timeout occured.
+ * @retval M24SR_ERROR_I2CTIMEOUT : The I2C timeout occurred.
*/
NFC_StatusTypeDef M24SR::M24SR_EnablePermanentState(uint16_t uReadOrWrite) {
C_APDU command;
@@ -937,7 +937,7 @@
* @brief This function sends the DisablePermanentState command
* @param uReadOrWrite : enable the read or write protection ( 0x0001 : Read or 0x0002 : Write )
* @retval Status (SW1&SW2) : Status of the operation to complete.
- * @retval M24SR_ERROR_I2CTIMEOUT : The I2C timeout occured.
+ * @retval M24SR_ERROR_I2CTIMEOUT : The I2C timeout occurred.
*/
NFC_StatusTypeDef M24SR::M24SR_DisablePermanentState(uint16_t uReadOrWrite) {
C_APDU command;
@@ -980,7 +980,7 @@
* @brief This function generates a interrupt on GPO pin
* @param None
* @retval Status (SW1&SW2) : Status of the operation to complete.
- * @retval M24SR_ERROR_I2CTIMEOUT : The I2C timeout occured.
+ * @retval M24SR_ERROR_I2CTIMEOUT : The I2C timeout occurred.
*/
NFC_StatusTypeDef M24SR::M24SR_SendInterrupt(void) {
C_APDU command;
@@ -1023,7 +1023,7 @@
* @brief This function force GPO pin to low state or high Z
* @param uSetOrReset : select if GPO must be low (reset) or HiZ
* @retval Status (SW1&SW2) : Status of the operation to complete.
- * @retval M24SR_ERROR_I2CTIMEOUT : The I2C timeout occured.
+ * @retval M24SR_ERROR_I2CTIMEOUT : The I2C timeout occurred.
*/
NFC_StatusTypeDef M24SR::M24SR_StateControl(uint8_t uSetOrReset) {
C_APDU command;
