Revision 0:8e1d760507b5, committed 2019-11-14
- Comitter:
- DiegoOstuni
- Date:
- Thu Nov 14 14:34:17 2019 +0000
- Commit message:
- Add files
Changed in this revision
diff -r 000000000000 -r 8e1d760507b5 .gitignore
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/.gitignore Thu Nov 14 14:34:17 2019 +0000
@@ -0,0 +1,32 @@
+# Prerequisites
+*.d
+
+# Compiled Object files
+*.slo
+*.lo
+*.o
+*.obj
+
+# Precompiled Headers
+*.gch
+*.pch
+
+# Compiled Dynamic libraries
+*.so
+*.dylib
+*.dll
+
+# Fortran module files
+*.mod
+*.smod
+
+# Compiled Static libraries
+*.lai
+*.la
+*.a
+*.lib
+
+# Executables
+*.exe
+*.out
+*.app
diff -r 000000000000 -r 8e1d760507b5 LICENSE
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/LICENSE Thu Nov 14 14:34:17 2019 +0000
@@ -0,0 +1,201 @@
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
diff -r 000000000000 -r 8e1d760507b5 README.md
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/README.md Thu Nov 14 14:34:17 2019 +0000
@@ -0,0 +1,4 @@
+# BSP05
+BSP05 is the library for STMicroelectronics X-NUCLEO-NFC05A1 expansion board.
+# OVERVIEW
+It contains the functions for the Demo functionalities. It enables the configuration of the RFAL to a chosen protocol and when the device is found It would start the communication.
diff -r 000000000000 -r 8e1d760507b5 x_nucleo_nfc05a1.cpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/x_nucleo_nfc05a1.cpp Thu Nov 14 14:34:17 2019 +0000
@@ -0,0 +1,919 @@
+/**
+ ******************************************************************************
+ * @file x_nucleo_nfc04a1.c
+ * @author MMY Application Team
+ * @version $Revision: 3351 $
+ * @date $Date: 2017-01-25 17:28:08 +0100 (Wed, 25 Jan 2017) $
+ * @brief This file provides nfc05a1 specific functions
+ ******************************************************************************
+ * @attention
+ *
+ * <h2><center>© COPYRIGHT 2017 STMicroelectronics</center></h2>
+ *
+ * Licensed under ST MYLIBERTY SOFTWARE LICENSE AGREEMENT (the "License");
+ * You may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.st.com/myliberty
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied,
+ * AND SPECIFICALLY DISCLAIMING THE IMPLIED WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ ******************************************************************************
+ */
+
+/*
+ ******************************************************************************
+ * INCLUDES
+ ******************************************************************************
+ */
+
+#include "utils.h"
+#include "rfal_rf.h"
+#include "rfal_nfca.h"
+#include "rfal_nfcb.h"
+#include "rfal_nfcf.h"
+#include "rfal_nfcv.h"
+#include "rfal_st25tb.h"
+#include "rfal_nfcDep.h"
+#include "rfal_isoDep.h"
+#include "DigitalOut.h"
+#include "st25r3911_interrupt.h"
+
+
+/*
+******************************************************************************
+* GLOBAL DEFINES
+******************************************************************************
+*/
+
+/* Definition of possible states the demo state machine could have */
+#define DEMO_ST_FIELD_OFF 0
+#define DEMO_ST_POLL_ACTIVE_TECH 1
+#define DEMO_ST_POLL_PASSIV_TECH 2
+#define DEMO_ST_WAIT_WAKEUP 3
+
+#define DEMO_BUF_LEN 255
+
+/* macro to cycle through states */
+#define NEXT_STATE() {state++; state %= sizeof(stateArray);}
+
+
+
+
+/*
+ ******************************************************************************
+ * LOCAL VARIABLES
+ ******************************************************************************
+ */
+
+/* State array of all possible states to be executed one after each other */
+static uint8_t stateArray[] = { DEMO_ST_FIELD_OFF,
+ DEMO_ST_POLL_ACTIVE_TECH,
+ DEMO_ST_POLL_PASSIV_TECH,
+ DEMO_ST_WAIT_WAKEUP
+ };
+
+/* P2P communication data */
+static uint8_t NFCID3[] = {0x01, 0xFE, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A};
+static uint8_t GB[] = {0x46, 0x66, 0x6d, 0x01, 0x01, 0x11, 0x02, 0x02, 0x07, 0x80, 0x03, 0x02, 0x00, 0x03, 0x04, 0x01, 0x32, 0x07, 0x01, 0x03};
+
+/* APDUs communication data */
+static uint8_t ndefSelectApp[] = { 0x00, 0xA4, 0x04, 0x00, 0x07, 0xD2, 0x76, 0x00, 0x00, 0x85, 0x01, 0x01, 0x00 };
+static uint8_t ccSelectFile[] = { 0x00, 0xA4, 0x00, 0x0C, 0x02, 0xE1, 0x03};
+static uint8_t readBynary[] = { 0x00, 0xB0, 0x00, 0x00, 0x0F };
+/*static uint8_t ppseSelectApp[] = { 0x00, 0xA4, 0x04, 0x00, 0x0E, 0x32, 0x50, 0x41, 0x59, 0x2E, 0x53, 0x59, 0x53, 0x2E, 0x44, 0x44, 0x46, 0x30, 0x31, 0x00 };*/
+
+/* P2P communication data */
+static uint8_t ndefPing[] = {0x00, 0x00};
+static uint8_t ndefInit[] = {0x05, 0x20, 0x06, 0x0F, 0x75, 0x72, 0x6E, 0x3A, 0x6E, 0x66, 0x63, 0x3A, 0x73, 0x6E, 0x3A, 0x73, 0x6E, 0x65, 0x70, 0x02, 0x02, 0x07, 0x80, 0x05, 0x01, 0x02};
+static uint8_t ndefUriSTcom[] = {0x13, 0x20, 0x00, 0x10, 0x02, 0x00, 0x00, 0x00, 0x19, 0xc1, 0x01, 0x00, 0x00, 0x00, 0x12, 0x55, 0x00, 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77, 0x2e, 0x73, 0x74, 0x2e, 0x63, 0x6f, 0x6d};
+
+
+/*
+ ******************************************************************************
+ * LOCAL VARIABLES
+ ******************************************************************************
+ */
+
+/*! Transmit buffers union, only one interface is used at a time */
+static union{
+ rfalIsoDepApduBufFormat isoDepTxBuf; /* ISO-DEP Tx buffer format (with header/prologue) */
+ rfalNfcDepBufFormat nfcDepTxBuf; /* NFC-DEP Rx buffer format (with header/prologue) */
+ uint8_t txBuf[DEMO_BUF_LEN]; /* Generic buffer abstraction */
+}gTxBuf;
+
+
+/*! Receive buffers union, only one interface is used at a time */
+static union {
+ rfalIsoDepApduBufFormat isoDepRxBuf; /* ISO-DEP Rx buffer format (with header/prologue) */
+ rfalNfcDepBufFormat nfcDepRxBuf; /* NFC-DEP Rx buffer format (with header/prologue) */
+ uint8_t rxBuf[DEMO_BUF_LEN]; /* Generic buffer abstraction */
+}gRxBuf;
+
+static rfalIsoDepBufFormat tmpBuf; /* tmp buffer required for ISO-DEP APDU interface, I-Block interface does not */
+
+/*! Receive buffers union, only one interface is used at a time */
+static union {
+ rfalIsoDepDevice isoDepDev; /* ISO-DEP Device details */
+ rfalNfcDepDevice nfcDepDev; /* NFC-DEP Device details */
+}gDevProto;
+
+static bool doWakeUp = false; /*!< by default do not perform Wake-Up */
+static uint8_t state = DEMO_ST_FIELD_OFF; /*!< Actual state, starting with RF field turned off */
+
+
+
+extern volatile bool wakeupFlag;
+
+
+
+
+/*
+******************************************************************************
+* LOCAL FUNCTION PROTOTYPES
+******************************************************************************
+*/
+
+static bool demoPollAP2P( SPI* mspiChannel, ST25R3911* mST25, DigitalOut* gpio_cs, InterruptIn* IRQ, DigitalOut* fieldLED_01, DigitalOut* fieldLED_02, DigitalOut* fieldLED_03, DigitalOut* fieldLED_04, DigitalOut* fieldLED_05, DigitalOut* fieldLED_06 );
+static bool demoPollNFCA( SPI* mspiChannel, ST25R3911* mST25, DigitalOut* gpio_cs, InterruptIn* IRQ, DigitalOut* fieldLED_01, DigitalOut* fieldLED_02, DigitalOut* fieldLED_03, DigitalOut* fieldLED_04, DigitalOut* fieldLED_05, DigitalOut* fieldLED_06 );
+static bool demoPollNFCB( SPI* mspiChannel, ST25R3911* mST25, DigitalOut* gpio_cs, InterruptIn* IRQ, DigitalOut* fieldLED_01, DigitalOut* fieldLED_02, DigitalOut* fieldLED_03, DigitalOut* fieldLED_04, DigitalOut* fieldLED_05, DigitalOut* fieldLED_06 );
+static bool demoPollST25TB( SPI* mspiChannel, ST25R3911* mST25, DigitalOut* gpio_cs, InterruptIn* IRQ, DigitalOut* fieldLED_01, DigitalOut* fieldLED_02, DigitalOut* fieldLED_03, DigitalOut* fieldLED_04, DigitalOut* fieldLED_05, DigitalOut* fieldLED_06 );
+static bool demoPollNFCF( SPI* mspiChannel, ST25R3911* mST25, DigitalOut* gpio_cs, InterruptIn* IRQ, DigitalOut* fieldLED_01, DigitalOut* fieldLED_02, DigitalOut* fieldLED_03, DigitalOut* fieldLED_04, DigitalOut* fieldLED_05, DigitalOut* fieldLED_06 );
+static bool demoPollNFCV( SPI* mspiChannel, ST25R3911* mST25, DigitalOut* gpio_cs, InterruptIn* IRQ, DigitalOut* fieldLED_01, DigitalOut* fieldLED_02, DigitalOut* fieldLED_03, DigitalOut* fieldLED_04, DigitalOut* fieldLED_05, DigitalOut* fieldLED_06 );
+static ReturnCode demoActivateP2P( uint8_t* nfcid, uint8_t nfidLen, bool isActive, rfalNfcDepDevice *nfcDepDev, SPI* mspiChannel, ST25R3911* mST25, DigitalOut* gpio_cs, InterruptIn* IRQ, DigitalOut* fieldLED_01, DigitalOut* fieldLED_02, DigitalOut* fieldLED_03, DigitalOut* fieldLED_04, DigitalOut* fieldLED_05, DigitalOut* fieldLED_06 );
+static ReturnCode demoNfcDepBlockingTxRx( rfalNfcDepDevice *nfcDepDev, const uint8_t *txBuf, uint16_t txBufSize, uint8_t *rxBuf, uint16_t rxBufSize, uint16_t *rxActLen, SPI* mspiChannel, ST25R3911* mST25, DigitalOut* gpio_cs, InterruptIn* IRQ, DigitalOut* fieldLED_01, DigitalOut* fieldLED_02, DigitalOut* fieldLED_03, DigitalOut* fieldLED_04, DigitalOut* fieldLED_05, DigitalOut* fieldLED_06 );
+static ReturnCode demoIsoDepBlockingTxRx( rfalIsoDepDevice *isoDepDev, const uint8_t *txBuf, uint16_t txBufSize, uint8_t *rxBuf, uint16_t rxBufSize, uint16_t *rxActLen, SPI* mspiChannel, ST25R3911* mST25, DigitalOut* gpio_cs, InterruptIn* IRQ, DigitalOut* fieldLED_01, DigitalOut* fieldLED_02, DigitalOut* fieldLED_03, DigitalOut* fieldLED_04, DigitalOut* fieldLED_05, DigitalOut* fieldLED_06 );
+static void demoSendNdefUri( SPI* mspiChannel, ST25R3911* mST25, DigitalOut* gpio_cs, InterruptIn* IRQ, DigitalOut* fieldLED_01, DigitalOut* fieldLED_02, DigitalOut* fieldLED_03, DigitalOut* fieldLED_04, DigitalOut* fieldLED_05, DigitalOut* fieldLED_06 );
+static void demoSendAPDUs( SPI* mspiChannel, ST25R3911* mST25, DigitalOut* gpio_cs, InterruptIn* IRQ, DigitalOut* fieldLED_01, DigitalOut* fieldLED_02, DigitalOut* fieldLED_03, DigitalOut* fieldLED_04, DigitalOut* fieldLED_05, DigitalOut* fieldLED_06 );
+
+
+/*!
+ *****************************************************************************
+ * \brief Demo Cycle
+ *
+ * This function executes the actual state of the demo state machine.
+ * Must be called cyclically
+ *****************************************************************************
+ */
+
+
+
+void demoCycle(SPI* mspiChannel, ST25R3911* mST25, DigitalIn * uButton, DigitalOut* gpio_cs, InterruptIn* IRQ, DigitalOut* fieldLED_01, DigitalOut* fieldLED_02, DigitalOut* fieldLED_03, DigitalOut* fieldLED_04, DigitalOut* fieldLED_05, DigitalOut* fieldLED_06 )
+{
+ bool found = false;
+
+ /* Code below is commented since not implemented. It may be of interest to uncommented if going through the wake up mode */
+
+ /* Check if USER button is pressed */
+// if( uButton -> read() == 1 )
+ //{
+
+ //doWakeUp = 1;
+ //!doWakeUp; /* enable/disable wakeup */
+ // state = DEMO_ST_FIELD_OFF; /* restart loop */
+
+ /* Debounce button */
+ // while( uButton -> read() == 0 );
+// }
+
+ switch( stateArray[state] )
+ {
+ //
+ case DEMO_ST_FIELD_OFF:
+
+ fieldLED_01 -> write(0);
+ fieldLED_02 -> write(0);
+ fieldLED_03 -> write(0);
+ fieldLED_04 -> write(0);
+ fieldLED_05 -> write(0);
+ fieldLED_06 -> write(0);
+
+
+ rfalFieldOff( mspiChannel, mST25, gpio_cs, IRQ, fieldLED_01, fieldLED_02, fieldLED_03, fieldLED_04, fieldLED_05, fieldLED_06 ) ;
+ rfalWakeUpModeStop( mspiChannel, mST25, gpio_cs, IRQ, fieldLED_01, fieldLED_02, fieldLED_03, fieldLED_04, fieldLED_05, fieldLED_06 ) ;
+ platformDelay(300);
+
+ /* If WakeUp is to be executed, enable Wake-Up mode */
+ if( doWakeUp )
+ {
+ //"Going to Wakeup mode.\r\n");
+
+ rfalWakeUpModeStart( NULL, mST25, mspiChannel, gpio_cs, IRQ, fieldLED_01, fieldLED_02, fieldLED_03, fieldLED_04, fieldLED_05, fieldLED_06 ) ;
+ state = DEMO_ST_WAIT_WAKEUP;
+ break;
+ }
+
+ NEXT_STATE();
+ break;
+
+ //
+ case DEMO_ST_POLL_ACTIVE_TECH:
+ demoPollAP2P( mspiChannel, mST25, gpio_cs, IRQ, fieldLED_01, fieldLED_02, fieldLED_03, fieldLED_04, fieldLED_05, fieldLED_06 ) ;
+ platformDelay(40);
+ NEXT_STATE();
+ break;
+
+ //
+ case DEMO_ST_POLL_PASSIV_TECH:
+ found |= demoPollNFCA( mspiChannel, mST25, gpio_cs, IRQ, fieldLED_01, fieldLED_02, fieldLED_03, fieldLED_04, fieldLED_05, fieldLED_06 ) ;
+ found |= demoPollNFCB( mspiChannel, mST25, gpio_cs, IRQ, fieldLED_01, fieldLED_02, fieldLED_03, fieldLED_04, fieldLED_05, fieldLED_06 ) ;
+ found |= demoPollST25TB( mspiChannel, mST25, gpio_cs, IRQ, fieldLED_01, fieldLED_02, fieldLED_03, fieldLED_04, fieldLED_05, fieldLED_06 ) ;
+ found |= demoPollNFCF( mspiChannel, mST25, gpio_cs, IRQ, fieldLED_01, fieldLED_02, fieldLED_03, fieldLED_04, fieldLED_05, fieldLED_06 ) ;
+ found |= demoPollNFCV( mspiChannel, mST25, gpio_cs, IRQ, fieldLED_01, fieldLED_02, fieldLED_03, fieldLED_04, fieldLED_05, fieldLED_06 ) ;
+
+ platformDelay(300);
+ state = DEMO_ST_FIELD_OFF;
+ break;
+
+ //
+ case DEMO_ST_WAIT_WAKEUP:
+
+
+
+
+ st25r3911Isr(mspiChannel, mST25, gpio_cs, IRQ, fieldLED_01, fieldLED_02, fieldLED_03, fieldLED_04, fieldLED_05, fieldLED_06 ) ;
+
+
+ if( st25r3911ChipHasWoke() )
+ {
+ rfalSetWumState();
+ }
+
+
+ /* Check if Wake-Up Mode has been awaked */
+ if( rfalWakeUpModeHasWoke(mST25, mspiChannel, gpio_cs, IRQ, fieldLED_01, fieldLED_02, fieldLED_03, fieldLED_04, fieldLED_05, fieldLED_06 ) )
+ {
+ /* If awake, go directly to Poll */
+ rfalWakeUpModeStop( mspiChannel, mST25, gpio_cs, IRQ, fieldLED_01, fieldLED_02, fieldLED_03, fieldLED_04, fieldLED_05, fieldLED_06 ) ;
+ state = DEMO_ST_POLL_ACTIVE_TECH;
+ }
+ break;
+
+ default:
+ break;
+ }
+
+}
+
+
+/*!
+ *****************************************************************************
+ * \brief Poll NFC-AP2P
+ *
+ * Configures the RFAL to AP2P communication and polls for a nearby
+ * device. If a device is found turns On a LED and logs its UID.
+ * If the Device supports NFC-DEP protocol (P2P) it will activate
+ * the device and try to send an URI record.
+ *
+ * This methid first tries to establish communication at 424kb/s and if
+ * failed, tries also at 106kb/s
+ *
+ *
+ * \return true : AP2P device found
+ * \return false : No device found
+ *
+ *****************************************************************************
+ */
+bool demoPollAP2P( SPI* mspiChannel, ST25R3911* mST25, DigitalOut* gpio_cs, InterruptIn* IRQ, DigitalOut* fieldLED_01, DigitalOut* fieldLED_02, DigitalOut* fieldLED_03, DigitalOut* fieldLED_04, DigitalOut* fieldLED_05, DigitalOut* fieldLED_06 )
+{
+ ReturnCode err;
+ bool try106 = false;
+
+
+ while (!try106)
+ {
+ /*******************************************************************************/
+ /* NFC_ACTIVE_POLL_MODE */
+ /*******************************************************************************/
+ /* Initialize RFAL as AP2P Initiator NFC BR 424 */
+ err = rfalSetMode(RFAL_MODE_POLL_ACTIVE_P2P, ((try106) ? RFAL_BR_106 : RFAL_BR_424), ((try106) ? RFAL_BR_106 : RFAL_BR_424), mspiChannel, mST25, gpio_cs, IRQ, fieldLED_01, fieldLED_02, fieldLED_03, fieldLED_04, fieldLED_05, fieldLED_06 ) ;
+
+ rfalSetErrorHandling(RFAL_ERRORHANDLING_NFC);
+ rfalSetFDTListen(RFAL_FDT_LISTEN_AP2P_POLLER);
+ rfalSetFDTPoll(RFAL_TIMING_NONE);
+
+ rfalSetGT( RFAL_GT_AP2P_ADJUSTED );
+ err = rfalFieldOnAndStartGT( mspiChannel, mST25, gpio_cs, IRQ, fieldLED_01, fieldLED_02, fieldLED_03, fieldLED_04, fieldLED_05, fieldLED_06 ) ;
+
+
+ err = demoActivateP2P( NFCID3, RFAL_NFCDEP_NFCID3_LEN, true, &gDevProto.nfcDepDev, mspiChannel, mST25, gpio_cs, IRQ, fieldLED_01, fieldLED_02, fieldLED_03, fieldLED_04, fieldLED_05, fieldLED_06 ) ;
+ if (err == ERR_NONE)
+ {
+ /****************************************************************************/
+ /* Active P2P device activated */
+ /* NFCID / UID is contained in : nfcDepDev.activation.Target.ATR_RES.NFCID3 */
+ // //("NFC Active P2P device found. NFCID3: %s\r\n", hex2Str(gDevProto.nfcDepDev.activation.Target.ATR_RES.NFCID3, RFAL_NFCDEP_NFCID3_LEN));
+ fieldLED_05 -> write(1);
+ /* Send an URI record */
+ demoSendNdefUri( mspiChannel, mST25, gpio_cs, IRQ, fieldLED_01, fieldLED_02, fieldLED_03, fieldLED_04, fieldLED_05, fieldLED_06 ) ;
+ return true;
+ }
+
+ /* AP2P at 424kb/s didn't found any device, try at 106kb/s */
+ try106 = true;
+ rfalFieldOff( mspiChannel, mST25, gpio_cs, IRQ, fieldLED_01, fieldLED_02, fieldLED_03, fieldLED_04, fieldLED_05, fieldLED_06 ) ;
+ }
+
+ return false;
+}
+
+/*!
+ *****************************************************************************
+ * \brief Poll NFC-A
+ *
+ * Configures the RFAL to NFC-A (ISO14443A) communication and polls for a nearby
+ * NFC-A device.
+ * If a device is found turns On a LED and logs its UID.
+ *
+ * Additionally, if the Device supports NFC-DEP protocol (P2P) it will activate
+ * the device and try to send an URI record.
+ * If the device supports ISO-DEP protocol (ISO144443-4) it will
+ * activate the device and try exchange some APDUs with PICC.
+ *
+ *
+ * \return true : NFC-A device found
+ * \return false : No device found
+ *
+ *****************************************************************************
+ */
+bool demoPollNFCA( SPI* mspiChannel, ST25R3911* mST25, DigitalOut* gpio_cs, InterruptIn* IRQ, DigitalOut* fieldLED_01, DigitalOut* fieldLED_02, DigitalOut* fieldLED_03, DigitalOut* fieldLED_04, DigitalOut* fieldLED_05, DigitalOut* fieldLED_06 )
+{
+ ReturnCode err;
+ bool found = false;
+ uint8_t devIt = 0;
+ rfalNfcaSensRes sensRes;
+
+ rfalNfcaPollerInitialize( mspiChannel, mST25, gpio_cs, IRQ, fieldLED_01, fieldLED_02, fieldLED_03, fieldLED_04, fieldLED_05, fieldLED_06 ) ; /* Initialize for NFC-A */
+ rfalFieldOnAndStartGT( mspiChannel, mST25, gpio_cs, IRQ, fieldLED_01, fieldLED_02, fieldLED_03, fieldLED_04, fieldLED_05, fieldLED_06 ) ; /* Turns the Field On if not already and start GT timer */
+
+ err = rfalNfcaPollerTechnologyDetection( RFAL_COMPLIANCE_MODE_NFC, &sensRes, mspiChannel, mST25, gpio_cs, IRQ, fieldLED_01, fieldLED_02, fieldLED_03, fieldLED_04, fieldLED_05, fieldLED_06 ) ;
+ if(err == ERR_NONE)
+ {
+ rfalNfcaListenDevice nfcaDevList[1];
+ uint8_t devCnt;
+
+ err = rfalNfcaPollerFullCollisionResolution( RFAL_COMPLIANCE_MODE_NFC, 1, nfcaDevList, &devCnt, mspiChannel, mST25, gpio_cs, IRQ, fieldLED_01, fieldLED_02, fieldLED_03, fieldLED_04, fieldLED_05, fieldLED_06 ) ;
+
+ if ( (err == ERR_NONE) && (devCnt > 0) )
+ {
+ found = true;
+ devIt = 0;
+
+ fieldLED_03 -> write(1);
+
+ /* Check if it is Topaz aka T1T */
+ if( nfcaDevList[devIt].type == RFAL_NFCA_T1T )
+ {
+ /********************************************/
+ /* NFC-A T1T card found */
+ /* NFCID/UID is contained in: t1tRidRes.uid */
+ // //("ISO14443A/Topaz (NFC-A T1T) TAG found. UID: %s\r\n", hex2Str(nfcaDevList[devIt].ridRes.uid, RFAL_T1T_UID_LEN));
+ }
+ else
+ {
+ /*********************************************/
+ /* NFC-A device found */
+ /* NFCID/UID is contained in: nfcaDev.nfcId1 */
+ // //("ISO14443A/NFC-A card found. UID: %s\r\n", hex2Str(nfcaDevList[0].nfcId1, nfcaDevList[0].nfcId1Len));
+ }
+
+
+ /* Check if device supports P2P/NFC-DEP */
+ if( (nfcaDevList[devIt].type == RFAL_NFCA_NFCDEP) || (nfcaDevList[devIt].type == RFAL_NFCA_T4T_NFCDEP))
+ {
+ /* Continue with P2P Activation .... */
+
+ err = demoActivateP2P( NFCID3, RFAL_NFCDEP_NFCID3_LEN, false, &gDevProto.nfcDepDev, mspiChannel, mST25, gpio_cs, IRQ, fieldLED_01, fieldLED_02, fieldLED_03, fieldLED_04, fieldLED_05, fieldLED_06 ) ;
+ if (err == ERR_NONE)
+ {
+ /*********************************************/
+ /* Passive P2P device activated */
+ // //("NFCA Passive P2P device found. NFCID: %s\r\n", hex2Str(gDevProto.nfcDepDev.activation.Target.ATR_RES.NFCID3, RFAL_NFCDEP_NFCID3_LEN));
+
+ /* Send an URI record */
+ demoSendNdefUri( mspiChannel, mST25, gpio_cs, IRQ, fieldLED_01, fieldLED_02, fieldLED_03, fieldLED_04, fieldLED_05, fieldLED_06 ) ;
+ }
+ }
+ /* Check if device supports ISO14443-4/ISO-DEP */
+ else if (nfcaDevList[devIt].type == RFAL_NFCA_T4T)
+ {
+ /* Activate the ISO14443-4 / ISO-DEP layer */
+
+ rfalIsoDepInitialize();
+ err = rfalIsoDepPollAHandleActivation((rfalIsoDepFSxI)RFAL_ISODEP_FSDI_DEFAULT, RFAL_ISODEP_NO_DID, RFAL_BR_424, &gDevProto.isoDepDev, mspiChannel, mST25, gpio_cs, IRQ, fieldLED_01, fieldLED_02, fieldLED_03, fieldLED_04, fieldLED_05, fieldLED_06 ) ;
+ if( err == ERR_NONE )
+ {
+ // //("ISO14443-4/ISO-DEP layer activated. \r\n");
+
+ /* Exchange APDUs */
+ demoSendAPDUs( mspiChannel, mST25, gpio_cs, IRQ, fieldLED_01, fieldLED_02, fieldLED_03, fieldLED_04, fieldLED_05, fieldLED_06 ) ;
+ }
+ }
+ }
+ }
+ return found;
+}
+
+/*!
+ *****************************************************************************
+ * \brief Poll NFC-B
+ *
+ * Configures the RFAL to NFC-B (ISO14443B) communication and polls for a nearby
+ * NFC-B device.
+ * If a device is found turns On a LED and logs its UID.
+ * Additionally, if the Device supports ISO-DEP protocol (ISO144443-4) it will
+ * activate the device and try exchange some APDUs with PICC
+ *
+ * \return true : NFC-B device found
+ * \return false : No device found
+ *
+ *****************************************************************************
+ */
+bool demoPollNFCB( SPI* mspiChannel, ST25R3911* mST25, DigitalOut* gpio_cs, InterruptIn* IRQ, DigitalOut* fieldLED_01, DigitalOut* fieldLED_02, DigitalOut* fieldLED_03, DigitalOut* fieldLED_04, DigitalOut* fieldLED_05, DigitalOut* fieldLED_06 )
+{
+ ReturnCode err;
+ rfalNfcbListenDevice nfcbDev;
+ bool found = false;
+ uint8_t devCnt = 0;
+
+ /*******************************************************************************/
+ /* ISO14443B/NFC_B_PASSIVE_POLL_MODE */
+ /*******************************************************************************/
+
+ rfalNfcbPollerInitialize( mspiChannel, mST25, gpio_cs, IRQ, fieldLED_01, fieldLED_02, fieldLED_03, fieldLED_04, fieldLED_05, fieldLED_06 ) ; /* Initialize for NFC-B */
+ rfalFieldOnAndStartGT( mspiChannel, mST25, gpio_cs, IRQ, fieldLED_01, fieldLED_02, fieldLED_03, fieldLED_04, fieldLED_05, fieldLED_06 ) ; /* Turns the Field On if not already and start GT timer */
+
+
+ err = rfalNfcbPollerCollisionResolution( RFAL_COMPLIANCE_MODE_NFC, 1, &nfcbDev, &devCnt, mspiChannel, mST25, gpio_cs, IRQ, fieldLED_01, fieldLED_02, fieldLED_03, fieldLED_04, fieldLED_05, fieldLED_06 ) ;
+ if( (err == ERR_NONE) && (devCnt > 0) )
+ {
+ /**********************************************/
+ /* NFC-B card found */
+ /* NFCID/UID is contained in: sensbRes.nfcid0 */
+ found = true;
+
+ fieldLED_02 -> write(1);
+ // //("ISO14443B/NFC-B card found. UID: %s\r\n", hex2Str(nfcbDev.sensbRes.nfcid0, RFAL_NFCB_NFCID0_LEN));
+
+ }
+
+ /* Check if device supports ISO14443-4/ISO-DEP */
+ if( nfcbDev.sensbRes.protInfo.FsciProType & RFAL_NFCB_SENSB_RES_PROTO_ISO_MASK )
+ {
+
+ /* Activate the ISO14443-4 / ISO-DEP layer */
+ rfalIsoDepInitialize();
+ err = rfalIsoDepPollBHandleActivation((rfalIsoDepFSxI)RFAL_ISODEP_FSDI_DEFAULT, RFAL_ISODEP_NO_DID, RFAL_BR_424, RFAL_ISODEP_ATTRIB_REQ_PARAM1_DEFAULT, &nfcbDev, NULL, 0, &gDevProto.isoDepDev, mspiChannel, mST25, gpio_cs, IRQ, fieldLED_01, fieldLED_02, fieldLED_03, fieldLED_04, fieldLED_05, fieldLED_06 ) ;
+
+ if( err == ERR_NONE )
+ {
+ //("ISO14443-4/ISO-DEP layer activated. \r\n");
+
+ /* Exchange APDUs */
+ demoSendAPDUs( mspiChannel, mST25, gpio_cs, IRQ, fieldLED_01, fieldLED_02, fieldLED_03, fieldLED_04, fieldLED_05, fieldLED_06 ) ;
+ }
+ }
+ return found;
+}
+
+/*!
+ *****************************************************************************
+ * \brief Poll ST25TB
+ *
+ * Configures the RFAL and polls for a nearby ST25TB device.
+ * If a device is found turns On a LED and logs its UID.
+ *
+ * \return true : ST25TB device found
+ * \return false : No device found
+ *
+ *****************************************************************************
+ */
+bool demoPollST25TB( SPI* mspiChannel, ST25R3911* mST25, DigitalOut* gpio_cs, InterruptIn* IRQ, DigitalOut* fieldLED_01, DigitalOut* fieldLED_02, DigitalOut* fieldLED_03, DigitalOut* fieldLED_04, DigitalOut* fieldLED_05, DigitalOut* fieldLED_06 )
+{
+ ReturnCode err;
+ bool found = false;
+ uint8_t devCnt = 0;
+ rfalSt25tbListenDevice st25tbDev;
+
+ /*******************************************************************************/
+ /* ST25TB_PASSIVE_POLL_MODE */
+ /*******************************************************************************/
+
+ rfalSt25tbPollerInitialize( mspiChannel, mST25, gpio_cs, IRQ, fieldLED_01, fieldLED_02, fieldLED_03, fieldLED_04, fieldLED_05, fieldLED_06 ) ;
+ rfalFieldOnAndStartGT( mspiChannel, mST25, gpio_cs, IRQ, fieldLED_01, fieldLED_02, fieldLED_03, fieldLED_04, fieldLED_05, fieldLED_06 ) ;
+
+ err = rfalSt25tbPollerCheckPresence(NULL, mspiChannel, mST25, gpio_cs, IRQ, fieldLED_01, fieldLED_02, fieldLED_03, fieldLED_04, fieldLED_05, fieldLED_06 ) ;
+ if( err == ERR_NONE )
+ {
+ err = rfalSt25tbPollerCollisionResolution(1, &st25tbDev, &devCnt, mspiChannel, mST25, gpio_cs, IRQ, fieldLED_01, fieldLED_02, fieldLED_03, fieldLED_04, fieldLED_05, fieldLED_06 ) ;
+
+ if ((err == ERR_NONE) && (devCnt > 0))
+ {
+ /******************************************************/
+ /* ST25TB card found */
+ /* NFCID/UID is contained in: st25tbDev.UID */
+ found = true;
+ fieldLED_02 -> write(1);
+ //// //("ST25TB card found. UID: %s\r\n", hex2Str(st25tbDev.UID, RFAL_ST25TB_UID_LEN));
+
+ }
+ }
+ return found;
+}
+
+
+/*!
+ *****************************************************************************
+ * \brief Poll NFC-F
+ *
+ * Configures the RFAL to NFC-F (FeliCa) communication and polls for a nearby
+ * NFC-F device.
+ * If a device is found turns On a LED and logs its UID.
+ * Additionally, if the Device supports NFC-DEP protocol (P2P) it will
+ * activate the device and try to send an URI record
+ *
+ * \return true : NFC-F device found
+ * \return false : No device found
+ *
+ *****************************************************************************
+ */
+bool demoPollNFCF( SPI* mspiChannel, ST25R3911* mST25, DigitalOut* gpio_cs, InterruptIn* IRQ, DigitalOut* fieldLED_01, DigitalOut* fieldLED_02, DigitalOut* fieldLED_03, DigitalOut* fieldLED_04, DigitalOut* fieldLED_05, DigitalOut* fieldLED_06 )
+{
+ ReturnCode err;
+ rfalNfcfListenDevice nfcfDev;
+ uint8_t devCnt = 0;
+ bool found = false;
+
+ /*******************************************************************************/
+ /* Felica/NFC_F_PASSIVE_POLL_MODE */
+ /*******************************************************************************/
+
+ rfalNfcfPollerInitialize( RFAL_BR_212, mspiChannel, mST25, gpio_cs, IRQ, fieldLED_01, fieldLED_02, fieldLED_03, fieldLED_04, fieldLED_05, fieldLED_06 ) ; /* Initialize for NFC-F */
+ rfalFieldOnAndStartGT( mspiChannel, mST25, gpio_cs, IRQ, fieldLED_01, fieldLED_02, fieldLED_03, fieldLED_04, fieldLED_05, fieldLED_06 ) ; /* Turns the Field On if not already and start GT timer */
+
+ err = rfalNfcfPollerCheckPresence( mspiChannel, mST25, gpio_cs, IRQ, fieldLED_01, fieldLED_02, fieldLED_03, fieldLED_04, fieldLED_05, fieldLED_06 ) ;
+ if( err == ERR_NONE )
+ {
+ err = rfalNfcfPollerCollisionResolution( RFAL_COMPLIANCE_MODE_NFC, 1, &nfcfDev, &devCnt, mspiChannel, mST25, gpio_cs, IRQ, fieldLED_01, fieldLED_02, fieldLED_03, fieldLED_04, fieldLED_05, fieldLED_06 ) ;
+
+ if( (err == ERR_NONE) && (devCnt > 0) )
+ {
+ /******************************************************/
+ /* NFC-F card found */
+ /* NFCID/UID is contained in: nfcfDev.sensfRes.NFCID2 */
+ found = true;
+ fieldLED_01 -> write(1);
+ //("Felica/NFC-F card found. UID: %s\r\n", hex2Str(nfcfDev.sensfRes.NFCID2, RFAL_NFCF_NFCID2_LEN));
+
+
+
+ /* Check if device supports P2P/NFC-DEP */
+ if( rfalNfcfIsNfcDepSupported( &nfcfDev ) )
+ {
+ /* Continue with P2P (NFC-DEP) activation */
+ err = demoActivateP2P( nfcfDev.sensfRes.NFCID2, RFAL_NFCDEP_NFCID3_LEN, false, &gDevProto.nfcDepDev, mspiChannel, mST25, gpio_cs, IRQ, fieldLED_01, fieldLED_02, fieldLED_03, fieldLED_04, fieldLED_05, fieldLED_06 ) ;
+ if (err == ERR_NONE)
+ {
+ /*********************************************/
+ /* Passive P2P device activated */
+ //("NFCF Passive P2P device found. NFCID: %s\r\n", hex2Str(gDevProto.nfcDepDev.activation.Target.ATR_RES.NFCID3, RFAL_NFCDEP_NFCID3_LEN));
+
+ /* Send an URI record */
+ demoSendNdefUri( mspiChannel, mST25, gpio_cs, IRQ, fieldLED_01, fieldLED_02, fieldLED_03, fieldLED_04, fieldLED_05, fieldLED_06 ) ;
+ }
+ }
+ }
+ }
+ return found;
+}
+
+
+/*!
+ *****************************************************************************
+ * \brief Poll NFC-V
+ *
+ * Configures the RFAL to NFC-V (ISO15693) communication, polls for a nearby
+ * NFC-V device. If a device is found turns On a LED and logs its UID
+ *
+ *
+ * \return true : NFC-V device found
+ * \return false : No device found
+ *
+ *****************************************************************************
+ */
+bool demoPollNFCV( SPI* mspiChannel, ST25R3911* mST25, DigitalOut* gpio_cs, InterruptIn* IRQ, DigitalOut* fieldLED_01, DigitalOut* fieldLED_02, DigitalOut* fieldLED_03, DigitalOut* fieldLED_04, DigitalOut* fieldLED_05, DigitalOut* fieldLED_06 )
+{
+ ReturnCode err;
+ rfalNfcvListenDevice nfcvDev;
+ bool found = false;
+ uint8_t devCnt = 0;
+
+ /*******************************************************************************/
+ /* ISO15693/NFC_V_PASSIVE_POLL_MODE */
+ /*******************************************************************************/
+
+ rfalNfcvPollerInitialize( mspiChannel, mST25, gpio_cs, IRQ, fieldLED_01, fieldLED_02, fieldLED_03, fieldLED_04, fieldLED_05, fieldLED_06 ) ; /* Initialize for NFC-F */
+ rfalFieldOnAndStartGT( mspiChannel, mST25, gpio_cs, IRQ, fieldLED_01, fieldLED_02, fieldLED_03, fieldLED_04, fieldLED_05, fieldLED_06 ) ; /* Turns the Field On if not already and start GT timer */
+
+ err = rfalNfcvPollerCollisionResolution(1, &nfcvDev, &devCnt, mspiChannel, mST25, gpio_cs, IRQ, fieldLED_01, fieldLED_02, fieldLED_03, fieldLED_04, fieldLED_05, fieldLED_06 ) ;
+ if( (err == ERR_NONE) && (devCnt > 0) )
+ {
+ /******************************************************/
+ /* NFC-V card found */
+ /* NFCID/UID is contained in: invRes.UID */
+ REVERSE_BYTES(nfcvDev.InvRes.UID, RFAL_NFCV_UID_LEN);
+
+ found = true;
+ fieldLED_04 -> write(1);
+ //("ISO15693/NFC-V card found. UID: %s\r\n", hex2Str(nfcvDev.InvRes.UID, RFAL_NFCV_UID_LEN));
+
+ }
+
+ return found;
+}
+
+/*!
+ *****************************************************************************
+ * \brief Activate P2P
+ *
+ * Configures NFC-DEP layer and executes the NFC-DEP/P2P activation (ATR_REQ
+ * and PSL_REQ if applicable)
+ *
+ * \param[in] nfcid : nfcid to be used
+ * \param[in] nfcidLen : length of nfcid
+ * \param[in] isActive : Active or Passive communication
+ * \param[out] nfcDepDev : If activation successful, device's Info
+ *
+ * \return ERR_PARAM : Invalid parameters
+ * \return ERR_TIMEOUT : Timeout error
+ * \return ERR_FRAMING : Framing error detected
+ * \return ERR_PROTO : Protocol error detected
+ * \return ERR_NONE : No error, activation successful
+ *
+ *****************************************************************************
+ */
+ReturnCode demoActivateP2P( uint8_t* nfcid, uint8_t nfidLen, bool isActive, rfalNfcDepDevice *nfcDepDev, SPI* mspiChannel, ST25R3911* mST25, DigitalOut* gpio_cs, InterruptIn* IRQ, DigitalOut* fieldLED_01, DigitalOut* fieldLED_02, DigitalOut* fieldLED_03, DigitalOut* fieldLED_04, DigitalOut* fieldLED_05, DigitalOut* fieldLED_06 )
+{
+ rfalNfcDepAtrParam nfcDepParams;
+
+ nfcDepParams.nfcid = nfcid;
+ nfcDepParams.nfcidLen = nfidLen;
+ nfcDepParams.BS = RFAL_NFCDEP_Bx_NO_HIGH_BR;
+ nfcDepParams.BR = RFAL_NFCDEP_Bx_NO_HIGH_BR;
+ nfcDepParams.LR = RFAL_NFCDEP_LR_254;
+ nfcDepParams.DID = RFAL_NFCDEP_DID_NO;
+ nfcDepParams.NAD = RFAL_NFCDEP_NAD_NO;
+ nfcDepParams.GBLen = sizeof(GB);
+ nfcDepParams.GB = GB;
+ nfcDepParams.commMode = ((isActive) ? RFAL_NFCDEP_COMM_ACTIVE : RFAL_NFCDEP_COMM_PASSIVE);
+ nfcDepParams.operParam = (RFAL_NFCDEP_OPER_FULL_MI_EN | RFAL_NFCDEP_OPER_EMPTY_DEP_DIS | RFAL_NFCDEP_OPER_ATN_EN | RFAL_NFCDEP_OPER_RTOX_REQ_EN);
+
+ /* Initialize NFC-DEP protocol layer */
+ rfalNfcDepInitialize();
+
+ /* Handle NFC-DEP Activation (ATR_REQ and PSL_REQ if applicable) */
+ return rfalNfcDepInitiatorHandleActivation( &nfcDepParams, RFAL_BR_424, nfcDepDev, mspiChannel, mST25, gpio_cs, IRQ, fieldLED_01, fieldLED_02, fieldLED_03, fieldLED_04, fieldLED_05, fieldLED_06 ) ;
+}
+
+
+/*!
+ *****************************************************************************
+ * \brief Send URI
+ *
+ * Sends a NDEF URI record 'http://www.ST.com' via NFC-DEP (P2P) protocol.
+ *
+ * This method sends a set of static predefined frames which tries to establish
+ * a LLCP connection, followed by the NDEF record, and then keeps sending
+ * LLCP SYMM packets to maintain the connection.
+ *
+ *
+ * \return true : NDEF URI was sent
+ * \return false : Exchange failed
+ *
+ *****************************************************************************
+ */
+void demoSendNdefUri( SPI* mspiChannel, ST25R3911* mST25, DigitalOut* gpio_cs, InterruptIn* IRQ, DigitalOut* fieldLED_01, DigitalOut* fieldLED_02, DigitalOut* fieldLED_03, DigitalOut* fieldLED_04, DigitalOut* fieldLED_05, DigitalOut* fieldLED_06 )
+{
+ uint16_t actLen = 0;
+ ReturnCode err = ERR_NONE;
+
+ //(" Initalize device .. ");
+ if(ERR_NONE != demoNfcDepBlockingTxRx( &gDevProto.nfcDepDev, ndefInit, sizeof(ndefInit), gRxBuf.rxBuf, sizeof(gRxBuf.rxBuf), &actLen , mspiChannel, mST25, gpio_cs, IRQ, fieldLED_01, fieldLED_02, fieldLED_03, fieldLED_04, fieldLED_05, fieldLED_06 ) )
+ {
+ //("failed.");
+ return;
+ }
+ //("succeeded.\r\n");
+
+ actLen = 0;
+ //(" Push NDEF Uri: www.ST.com .. ");
+ if(ERR_NONE != demoNfcDepBlockingTxRx( &gDevProto.nfcDepDev, ndefUriSTcom, sizeof(ndefUriSTcom), gRxBuf.rxBuf, sizeof(gRxBuf.rxBuf), &actLen, mspiChannel, mST25, gpio_cs, IRQ, fieldLED_01, fieldLED_02, fieldLED_03, fieldLED_04, fieldLED_05, fieldLED_06 ) )
+ {
+ //("failed.");
+ return;
+ }
+ //("succeeded.\r\n");
+
+
+ //(" Device present, maintaining connection ");
+ while(err == ERR_NONE)
+ {
+ err = demoNfcDepBlockingTxRx( &gDevProto.nfcDepDev, ndefPing, sizeof(ndefPing), gRxBuf.rxBuf, sizeof(gRxBuf.rxBuf), &actLen, mspiChannel, mST25, gpio_cs, IRQ, fieldLED_01, fieldLED_02, fieldLED_03, fieldLED_04, fieldLED_05, fieldLED_06 ) ;
+ //(".");
+ platformDelay(50);
+ }
+ //("\r\n Device removed.\r\n");
+
+}
+
+
+/*!
+ *****************************************************************************
+ * \brief Exchange APDUs
+ *
+ * Example how to exchange a set of predefined APDUs with PICC. The NDEF
+ * application will be selected and then CC will be selected and read.
+ *
+ *****************************************************************************
+ */
+void demoSendAPDUs( SPI* mspiChannel, ST25R3911* mST25, DigitalOut* gpio_cs, InterruptIn* IRQ, DigitalOut* fieldLED_01, DigitalOut* fieldLED_02, DigitalOut* fieldLED_03, DigitalOut* fieldLED_04, DigitalOut* fieldLED_05, DigitalOut* fieldLED_06 )
+{
+ uint16_t rxLen;
+ ReturnCode err;
+
+ /* Exchange APDU: NDEF Tag Application Select command */
+ err = demoIsoDepBlockingTxRx(&gDevProto.isoDepDev, ndefSelectApp, sizeof(ndefSelectApp), gRxBuf.rxBuf, sizeof(gRxBuf.rxBuf), &rxLen, mspiChannel, mST25, gpio_cs, IRQ, fieldLED_01, fieldLED_02, fieldLED_03, fieldLED_04, fieldLED_05, fieldLED_06 ) ;
+
+ if( (err == ERR_NONE) && gRxBuf.rxBuf[0] == 0x90 && gRxBuf.rxBuf[1] == 0x00)
+ {
+ //(" Select NDEF App successfully \r\n");
+
+ /* Exchange APDU: Select Capability Container File */
+ err = demoIsoDepBlockingTxRx(&gDevProto.isoDepDev, ccSelectFile, sizeof(ccSelectFile), gRxBuf.rxBuf, sizeof(gRxBuf.rxBuf), &rxLen, mspiChannel, mST25, gpio_cs, IRQ, fieldLED_01, fieldLED_02, fieldLED_03, fieldLED_04, fieldLED_05, fieldLED_06 ) ;
+
+ /* Exchange APDU: Read Capability Container File */
+ err = demoIsoDepBlockingTxRx(&gDevProto.isoDepDev, readBynary, sizeof(readBynary), gRxBuf.rxBuf, sizeof(gRxBuf.rxBuf), &rxLen, mspiChannel, mST25, gpio_cs, IRQ, fieldLED_01, fieldLED_02, fieldLED_03, fieldLED_04, fieldLED_05, fieldLED_06 ) ;
+ }
+}
+
+/*!
+ *****************************************************************************
+ * \brief ISO-DEP Blocking Transceive
+ *
+ * Helper function to send data in a blocking manner via the rfalIsoDep module
+ *
+ * \warning A protocol transceive handles long timeouts (several seconds),
+ * transmission errors and retransmissions which may lead to a long period of
+ * time where the MCU/CPU is blocked in this method.
+ * This is a demo implementation, for a non-blocking usage example please
+ * refer to the Examples available with RFAL
+ *
+ *
+ * \param[in] isoDepDev : device details retrived during activation
+ * \param[in] txBuf : data to be transmitted
+ * \param[in] txBufSize : size of the data to be transmited
+ * \param[out] rxBuf : buffer to place receive data
+ * \param[in] rxBufSize : size of the reception buffer
+ * \param[out] rxActLen : number of data bytes received
+
+ *
+ * \return ERR_PARAM : Invalid parameters
+ * \return ERR_TIMEOUT : Timeout error
+ * \return ERR_FRAMING : Framing error detected
+ * \return ERR_PROTO : Protocol error detected
+ * \return ERR_NONE : No error, activation successful
+ *
+ *****************************************************************************
+ */
+ReturnCode demoIsoDepBlockingTxRx( rfalIsoDepDevice *isoDepDev, const uint8_t *txBuf, uint16_t txBufSize, uint8_t *rxBuf, uint16_t rxBufSize, uint16_t *rxActLen, SPI* mspiChannel, ST25R3911* mST25, DigitalOut* gpio_cs, InterruptIn* IRQ, DigitalOut* fieldLED_01, DigitalOut* fieldLED_02, DigitalOut* fieldLED_03, DigitalOut* fieldLED_04, DigitalOut* fieldLED_05, DigitalOut* fieldLED_06 )
+{
+ ReturnCode err;
+ rfalIsoDepApduTxRxParam isoDepTxRx;
+
+ /* Initialize the ISO-DEP protocol transceive context */
+ isoDepTxRx.txBuf = &gTxBuf.isoDepTxBuf;
+ isoDepTxRx.txBufLen = txBufSize;
+ isoDepTxRx.DID = isoDepDev->info.DID;
+ isoDepTxRx.FWT = isoDepDev->info.FWT;
+ isoDepTxRx.dFWT = isoDepDev->info.dFWT;
+ isoDepTxRx.FSx = isoDepDev->info.FSx;
+ isoDepTxRx.ourFSx = RFAL_ISODEP_FSX_KEEP;
+ isoDepTxRx.rxBuf = &gRxBuf.isoDepRxBuf;
+ isoDepTxRx.rxLen = rxActLen;
+ isoDepTxRx.tmpBuf = &tmpBuf;
+
+
+ /* Copy data to send */
+ ST_MEMMOVE( gTxBuf.isoDepTxBuf.apdu, txBuf, MIN( txBufSize, RFAL_ISODEP_DEFAULT_FSC ) );
+
+ /* Perform the ISO-DEP Transceive in a blocking way */
+ rfalIsoDepStartApduTransceive( isoDepTxRx );
+ do {
+ rfalWorker( mspiChannel, mST25, gpio_cs, IRQ, fieldLED_01, fieldLED_02, fieldLED_03, fieldLED_04, fieldLED_05, fieldLED_06 ) ;
+ err = rfalIsoDepGetApduTransceiveStatus( mspiChannel, mST25, gpio_cs, IRQ, fieldLED_01, fieldLED_02, fieldLED_03, fieldLED_04, fieldLED_05, fieldLED_06 ) ;
+ } while(err == ERR_BUSY);
+
+ //(" ISO-DEP TxRx %s: - Tx: %s Rx: %s \r\n", (err != ERR_NONE) ? "FAIL": "OK", hex2Str((uint8_t*)txBuf, txBufSize), (err != ERR_NONE) ? "": hex2Str( isoDepTxRx.rxBuf->apdu, *rxActLen));
+
+ if( err != ERR_NONE )
+ {
+ return err;
+ }
+
+ /* Copy received data */
+ ST_MEMMOVE( rxBuf, isoDepTxRx.rxBuf->apdu, MIN(*rxActLen, rxBufSize) );
+ return ERR_NONE;
+}
+
+
+/*!
+ *****************************************************************************
+ * \brief NFC-DEP Blocking Transceive
+ *
+ * Helper function to send data in a blocking manner via the rfalNfcDep module
+ *
+ * \warning A protocol transceive handles long timeouts (several seconds),
+ * transmission errors and retransmissions which may lead to a long period of
+ * time where the MCU/CPU is blocked in this method.
+ * This is a demo implementation, for a non-blocking usage example please
+ * refer to the Examples available with RFAL
+ *
+ * \param[in] nfcDepDev : device details retrived during activation
+ * \param[in] txBuf : data to be transmitted
+ * \param[in] txBufSize : size of the data to be transmited
+ * \param[out] rxBuf : buffer to place receive data
+ * \param[in] rxBufSize : size of the reception buffer
+ * \param[out] rxActLen : number of data bytes received
+
+ *
+ * \return ERR_PARAM : Invalid parameters
+ * \return ERR_TIMEOUT : Timeout error
+ * \return ERR_FRAMING : Framing error detected
+ * \return ERR_PROTO : Protocol error detected
+ * \return ERR_NONE : No error, activation successful
+ *
+ *****************************************************************************
+ */
+ReturnCode demoNfcDepBlockingTxRx( rfalNfcDepDevice *nfcDepDev, const uint8_t *txBuf, uint16_t txBufSize, uint8_t *rxBuf, uint16_t rxBufSize, uint16_t *rxActLen, SPI* mspiChannel, ST25R3911* mST25, DigitalOut* gpio_cs, InterruptIn* IRQ, DigitalOut* fieldLED_01, DigitalOut* fieldLED_02, DigitalOut* fieldLED_03, DigitalOut* fieldLED_04, DigitalOut* fieldLED_05, DigitalOut* fieldLED_06 )
+{
+ ReturnCode err;
+ bool isChaining;
+ rfalNfcDepTxRxParam rfalNfcDepTxRx;
+
+
+ /* Initialize the NFC-DEP protocol transceive context */
+ rfalNfcDepTxRx.txBuf = &gTxBuf.nfcDepTxBuf;
+ rfalNfcDepTxRx.txBufLen = txBufSize;
+ rfalNfcDepTxRx.rxBuf = &gRxBuf.nfcDepRxBuf;
+ rfalNfcDepTxRx.rxLen = rxActLen;
+ rfalNfcDepTxRx.DID = RFAL_NFCDEP_DID_NO;
+ rfalNfcDepTxRx.FSx = rfalNfcDepLR2FS( rfalNfcDepPP2LR( nfcDepDev->activation.Target.ATR_RES.PPt ) );
+ rfalNfcDepTxRx.FWT = nfcDepDev->info.FWT;
+ rfalNfcDepTxRx.dFWT = nfcDepDev->info.dFWT;
+ rfalNfcDepTxRx.isRxChaining = &isChaining;
+ rfalNfcDepTxRx.isTxChaining = false;
+
+ /* Copy data to send */
+ ST_MEMMOVE( gTxBuf.nfcDepTxBuf.inf, txBuf, MIN( txBufSize, RFAL_NFCDEP_FRAME_SIZE_MAX_LEN ) );
+
+ /* Perform the NFC-DEP Transceive in a blocking way */
+ rfalNfcDepStartTransceive( &rfalNfcDepTxRx );
+ do {
+ rfalWorker( mspiChannel, mST25, gpio_cs, IRQ, fieldLED_01, fieldLED_02, fieldLED_03, fieldLED_04, fieldLED_05, fieldLED_06 ) ;
+ err = rfalNfcDepGetTransceiveStatus( mspiChannel, mST25, gpio_cs, IRQ, fieldLED_01, fieldLED_02, fieldLED_03, fieldLED_04, fieldLED_05, fieldLED_06 ) ;
+ } while(err == ERR_BUSY);
+
+ /* //(" NFC-DEP TxRx %s: - Tx: %s Rx: %s \r\n", (err != ERR_NONE) ? "FAIL": "OK", hex2Str( (uint8_t*)rfalNfcDepTxRx.txBuf, txBufSize), (err != ERR_NONE) ? "": hex2Str( rfalNfcDepTxRx.rxBuf->inf, *rxActLen)); */
+
+ if( err != ERR_NONE )
+ {
+ return err;
+ }
+
+ /* Copy received data */
+ ST_MEMMOVE( rxBuf, gRxBuf.nfcDepRxBuf.inf, MIN(*rxActLen, rxBufSize) );
+ return ERR_NONE;
+}
+
+
+
+
+/**
+ * @}
+ */
+
+/**
+ * @}
+ */
+
+/**
+ * @}
+ */
+
+/******************* (C) COPYRIGHT 2017 STMicroelectronics *****END OF FILE****/
diff -r 000000000000 -r 8e1d760507b5 x_nucleo_nfc05a1.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/x_nucleo_nfc05a1.h Thu Nov 14 14:34:17 2019 +0000
@@ -0,0 +1,55 @@
+/**
+ ******************************************************************************
+ *
+ * COPYRIGHT(c) 2017 STMicroelectronics
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * 3. Neither the name of STMicroelectronics nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ ******************************************************************************
+ */
+/*! \file
+ *
+ * \author
+ *
+ * \brief Demo functionality header file
+ *
+ */
+/* Define to prevent recursive inclusion -------------------------------------*/
+
+
+
+/* Includes ------------------------------------------------------------------*/
+#include "platform1.h"
+#include "st_errno.h"
+#include "ST25R3911.h"
+
+
+
+
+/* Exported functions ------------------------------------------------------- */
+extern void demoCycle(SPI* mspiChannel, ST25R3911* mST25, DigitalIn * uButton, DigitalOut* gpio_cs, InterruptIn* IRQ,
+ DigitalOut* fieldLED_01, DigitalOut* fieldLED_02, DigitalOut* fieldLED_03, DigitalOut* fieldLED_04, DigitalOut* fieldLED_05, DigitalOut* fieldLED_06 );
+
+
+
+/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/