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
Interfaces/Nfc_class.h@7:19fc04b8fec6, 2016-01-11 (annotated)
- Committer:
- giovannivisentini
- Date:
- Mon Jan 11 12:37:28 2016 +0000
- Revision:
- 7:19fc04b8fec6
- Parent:
- 6:96389fb79676
- Child:
- 8:5e637c71cbb3
update docs
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| giovannivisentini | 0:969a2be49f41 | 1 | /** |
| giovannivisentini | 0:969a2be49f41 | 2 | ****************************************************************************** |
| giovannivisentini | 0:969a2be49f41 | 3 | * @file Nfc_class.h |
| giovannivisentini | 6:96389fb79676 | 4 | * @author ST Central Labs |
| giovannivisentini | 0:969a2be49f41 | 5 | * @version V0.0.1 |
| giovannivisentini | 0:969a2be49f41 | 6 | * @date 13-April-2015 |
| giovannivisentini | 0:969a2be49f41 | 7 | * @brief This file contains the abstract class describing the interface of a |
| giovannivisentini | 0:969a2be49f41 | 8 | * nfc component. |
| giovannivisentini | 0:969a2be49f41 | 9 | ****************************************************************************** |
| giovannivisentini | 0:969a2be49f41 | 10 | * @attention |
| giovannivisentini | 0:969a2be49f41 | 11 | * |
| giovannivisentini | 0:969a2be49f41 | 12 | * <h2><center>© COPYRIGHT(c) 2015 STMicroelectronics</center></h2> |
| giovannivisentini | 0:969a2be49f41 | 13 | * |
| giovannivisentini | 0:969a2be49f41 | 14 | * Redistribution and use in source and binary forms, with or without modification, |
| giovannivisentini | 0:969a2be49f41 | 15 | * are permitted provided that the following conditions are met: |
| giovannivisentini | 0:969a2be49f41 | 16 | * 1. Redistributions of source code must retain the above copyright notice, |
| giovannivisentini | 0:969a2be49f41 | 17 | * this list of conditions and the following disclaimer. |
| giovannivisentini | 0:969a2be49f41 | 18 | * 2. Redistributions in binary form must reproduce the above copyright notice, |
| giovannivisentini | 0:969a2be49f41 | 19 | * this list of conditions and the following disclaimer in the documentation |
| giovannivisentini | 0:969a2be49f41 | 20 | * and/or other materials provided with the distribution. |
| giovannivisentini | 0:969a2be49f41 | 21 | * 3. Neither the name of STMicroelectronics nor the names of its contributors |
| giovannivisentini | 0:969a2be49f41 | 22 | * may be used to endorse or promote products derived from this software |
| giovannivisentini | 0:969a2be49f41 | 23 | * without specific prior written permission. |
| giovannivisentini | 0:969a2be49f41 | 24 | * |
| giovannivisentini | 0:969a2be49f41 | 25 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
| giovannivisentini | 0:969a2be49f41 | 26 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| giovannivisentini | 0:969a2be49f41 | 27 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
| giovannivisentini | 0:969a2be49f41 | 28 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE |
| giovannivisentini | 0:969a2be49f41 | 29 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
| giovannivisentini | 0:969a2be49f41 | 30 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
| giovannivisentini | 0:969a2be49f41 | 31 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
| giovannivisentini | 0:969a2be49f41 | 32 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
| giovannivisentini | 0:969a2be49f41 | 33 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| giovannivisentini | 0:969a2be49f41 | 34 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| giovannivisentini | 0:969a2be49f41 | 35 | * |
| giovannivisentini | 0:969a2be49f41 | 36 | ****************************************************************************** |
| giovannivisentini | 0:969a2be49f41 | 37 | */ |
| giovannivisentini | 0:969a2be49f41 | 38 | |
| giovannivisentini | 0:969a2be49f41 | 39 | |
| giovannivisentini | 0:969a2be49f41 | 40 | /* Generated with Stm32CubeTOO -----------------------------------------------*/ |
| giovannivisentini | 0:969a2be49f41 | 41 | |
| giovannivisentini | 0:969a2be49f41 | 42 | /* Define to prevent from recursive inclusion --------------------------------*/ |
| giovannivisentini | 0:969a2be49f41 | 43 | |
| giovannivisentini | 0:969a2be49f41 | 44 | #ifndef __NFC_CLASS_H |
| giovannivisentini | 0:969a2be49f41 | 45 | #define __NFC_CLASS_H |
| giovannivisentini | 0:969a2be49f41 | 46 | |
| giovannivisentini | 0:969a2be49f41 | 47 | |
| giovannivisentini | 0:969a2be49f41 | 48 | /* Includes ------------------------------------------------------------------*/ |
| giovannivisentini | 0:969a2be49f41 | 49 | |
| giovannivisentini | 0:969a2be49f41 | 50 | #include "Component_class.h" |
| giovannivisentini | 0:969a2be49f41 | 51 | |
| giovannivisentini | 0:969a2be49f41 | 52 | |
| giovannivisentini | 0:969a2be49f41 | 53 | /* Classes ------------------------------------------------------------------*/ |
| giovannivisentini | 0:969a2be49f41 | 54 | |
| giovannivisentini | 0:969a2be49f41 | 55 | /** An abstract class for Nfc components. |
| giovannivisentini | 0:969a2be49f41 | 56 | */ |
| giovannivisentini | 0:969a2be49f41 | 57 | class Nfc : public Component |
| giovannivisentini | 0:969a2be49f41 | 58 | { |
| giovannivisentini | 0:969a2be49f41 | 59 | public: |
| giovannivisentini | 0:969a2be49f41 | 60 | |
| giovannivisentini | 0:969a2be49f41 | 61 | /** |
| giovannivisentini | 0:969a2be49f41 | 62 | * possible password to set |
| giovannivisentini | 0:969a2be49f41 | 63 | */ |
| giovannivisentini | 0:969a2be49f41 | 64 | typedef enum{ |
| giovannivisentini | 0:969a2be49f41 | 65 | ReadPwd=READ_PWD, //!< password to use before read the tag |
| giovannivisentini | 0:969a2be49f41 | 66 | WritePwd=WRITE_PWD,//!< password to use before write the tag |
| giovannivisentini | 0:969a2be49f41 | 67 | I2CPwd=I2C_PWD, //!< root password, used only thought nfc |
| giovannivisentini | 0:969a2be49f41 | 68 | }PasswordType_t; |
| giovannivisentini | 0:969a2be49f41 | 69 | |
| giovannivisentini | 0:969a2be49f41 | 70 | |
| giovannivisentini | 0:969a2be49f41 | 71 | /** |
| giovannivisentini | 0:969a2be49f41 | 72 | * open a i2c connection with the tag if an RF connection isn't already open |
| giovannivisentini | 0:969a2be49f41 | 73 | * @return operation status |
| giovannivisentini | 0:969a2be49f41 | 74 | */ |
| giovannivisentini | 0:969a2be49f41 | 75 | virtual NFC_StatusTypeDef GetSession(void) = 0; |
| giovannivisentini | 0:969a2be49f41 | 76 | /** |
| giovannivisentini | 0:969a2be49f41 | 77 | * force to open an i2c connection , abort the RF connection |
| giovannivisentini | 7:19fc04b8fec6 | 78 | * @return NFC_SUCCESS if the session is acquired |
| giovannivisentini | 0:969a2be49f41 | 79 | */ |
| giovannivisentini | 0:969a2be49f41 | 80 | virtual NFC_StatusTypeDef KillSession(void) = 0; |
| giovannivisentini | 0:969a2be49f41 | 81 | |
| giovannivisentini | 0:969a2be49f41 | 82 | /** |
| giovannivisentini | 0:969a2be49f41 | 83 | * close an i2c connection |
| giovannivisentini | 7:19fc04b8fec6 | 84 | * @return NFC_SUCCESS if the session is release |
| giovannivisentini | 0:969a2be49f41 | 85 | */ |
| giovannivisentini | 0:969a2be49f41 | 86 | virtual NFC_StatusTypeDef Deselect(void) = 0; |
| giovannivisentini | 0:969a2be49f41 | 87 | |
| giovannivisentini | 0:969a2be49f41 | 88 | /** |
| giovannivisentini | 0:969a2be49f41 | 89 | * Select the application file |
| giovannivisentini | 7:19fc04b8fec6 | 90 | * @return NFC_SUCCESS if the application is selected |
| giovannivisentini | 0:969a2be49f41 | 91 | */ |
| giovannivisentini | 0:969a2be49f41 | 92 | virtual NFC_StatusTypeDef SelectApplication(void) = 0; |
| giovannivisentini | 0:969a2be49f41 | 93 | |
| giovannivisentini | 0:969a2be49f41 | 94 | /** |
| giovannivisentini | 0:969a2be49f41 | 95 | * select the CC file |
| giovannivisentini | 7:19fc04b8fec6 | 96 | * @return NFC_SUCCESS if the cc file is selected |
| giovannivisentini | 0:969a2be49f41 | 97 | */ |
| giovannivisentini | 0:969a2be49f41 | 98 | virtual NFC_StatusTypeDef SelectCCfile(void) = 0; |
| giovannivisentini | 0:969a2be49f41 | 99 | |
| giovannivisentini | 0:969a2be49f41 | 100 | /** |
| giovannivisentini | 0:969a2be49f41 | 101 | * select the ndef file |
| giovannivisentini | 0:969a2be49f41 | 102 | * @param NDEFfileId file id to open |
| giovannivisentini | 7:19fc04b8fec6 | 103 | * @return NFC_SUCCESS if the file is selected |
| giovannivisentini | 0:969a2be49f41 | 104 | */ |
| giovannivisentini | 0:969a2be49f41 | 105 | virtual NFC_StatusTypeDef SelectNDEFfile(uint16_t NDEFfileId) = 0; |
| giovannivisentini | 0:969a2be49f41 | 106 | |
| giovannivisentini | 0:969a2be49f41 | 107 | /** |
| giovannivisentini | 0:969a2be49f41 | 108 | * select the system file |
| giovannivisentini | 7:19fc04b8fec6 | 109 | * @return NFC_SUCCESS if the system file is selected |
| giovannivisentini | 0:969a2be49f41 | 110 | */ |
| giovannivisentini | 0:969a2be49f41 | 111 | virtual NFC_StatusTypeDef SelectSystemfile(void) = 0; |
| giovannivisentini | 0:969a2be49f41 | 112 | |
| giovannivisentini | 0:969a2be49f41 | 113 | /** |
| giovannivisentini | 0:969a2be49f41 | 114 | * read data from the tag |
| giovannivisentini | 0:969a2be49f41 | 115 | * @param Offset offset where start to read |
| giovannivisentini | 0:969a2be49f41 | 116 | * @param NbByteToRead number of byte to read |
| giovannivisentini | 0:969a2be49f41 | 117 | * @param[out] pBufferRead buffer where store the read data |
| giovannivisentini | 7:19fc04b8fec6 | 118 | * @return NFC_SUCCESS if no error happen |
| giovannivisentini | 0:969a2be49f41 | 119 | */ |
| giovannivisentini | 0:969a2be49f41 | 120 | virtual NFC_StatusTypeDef ReadBinary(uint16_t Offset, uint8_t NbByteToRead, uint8_t *pBufferRead) = 0; |
| giovannivisentini | 0:969a2be49f41 | 121 | |
| giovannivisentini | 0:969a2be49f41 | 122 | /** |
| giovannivisentini | 0:969a2be49f41 | 123 | * write data to the tag |
| giovannivisentini | 0:969a2be49f41 | 124 | * @param Offset offset where start to write |
| giovannivisentini | 0:969a2be49f41 | 125 | * @param NbByteToWrite number of byte to write |
| giovannivisentini | 0:969a2be49f41 | 126 | * @param pDataToWrite buffer to write |
| giovannivisentini | 7:19fc04b8fec6 | 127 | * @return NFC_SUCCESS if no error happen |
| giovannivisentini | 0:969a2be49f41 | 128 | */ |
| giovannivisentini | 0:969a2be49f41 | 129 | virtual NFC_StatusTypeDef UpdateBinary(uint16_t Offset, uint8_t NbByteToWrite, uint8_t *pDataToWrite) = 0; |
| giovannivisentini | 0:969a2be49f41 | 130 | |
| giovannivisentini | 0:969a2be49f41 | 131 | /** |
| giovannivisentini | 0:969a2be49f41 | 132 | * check that the password is correct |
| giovannivisentini | 0:969a2be49f41 | 133 | * @param uPwdId password type |
| giovannivisentini | 0:969a2be49f41 | 134 | * @param NbPwdByte password size ( must be 0x10) |
| giovannivisentini | 0:969a2be49f41 | 135 | * @param pPwd password buffer |
| giovannivisentini | 7:19fc04b8fec6 | 136 | * @return NFC_SUCCESS if no error happen, and you have the permission to write/read |
| giovannivisentini | 0:969a2be49f41 | 137 | */ |
| giovannivisentini | 0:969a2be49f41 | 138 | virtual NFC_StatusTypeDef Verify(PasswordType_t uPwdId, uint8_t NbPwdByte,const uint8_t *pPwd) = 0; |
| giovannivisentini | 0:969a2be49f41 | 139 | |
| giovannivisentini | 0:969a2be49f41 | 140 | /** |
| giovannivisentini | 0:969a2be49f41 | 141 | * change the pa |
| giovannivisentini | 0:969a2be49f41 | 142 | * @param uPwdId |
| giovannivisentini | 0:969a2be49f41 | 143 | * @param pPwd |
| giovannivisentini | 0:969a2be49f41 | 144 | * @return |
| giovannivisentini | 0:969a2be49f41 | 145 | */ |
| giovannivisentini | 0:969a2be49f41 | 146 | virtual NFC_StatusTypeDef ChangeReferenceData(PasswordType_t uPwdId,const uint8_t *pPwd) = 0; |
| giovannivisentini | 0:969a2be49f41 | 147 | virtual NFC_StatusTypeDef EnableVerificationRequirement(PasswordType_t uReadOrWrite) = 0; |
| giovannivisentini | 0:969a2be49f41 | 148 | virtual NFC_StatusTypeDef DisableVerificationRequirement(PasswordType_t uReadOrWrite) = 0; |
| giovannivisentini | 7:19fc04b8fec6 | 149 | |
| giovannivisentini | 7:19fc04b8fec6 | 150 | /** |
| giovannivisentini | 7:19fc04b8fec6 | 151 | * as {@link Nfc#ReadBinary} but it doesn't give error if you read more byte than the ones |
| giovannivisentini | 7:19fc04b8fec6 | 152 | * that are available |
| giovannivisentini | 7:19fc04b8fec6 | 153 | * @param Offset offset where start to read |
| giovannivisentini | 7:19fc04b8fec6 | 154 | * @param NbByteToRead number of byte to read |
| giovannivisentini | 7:19fc04b8fec6 | 155 | * @param[out] pBufferRead buffer where store the read data |
| giovannivisentini | 7:19fc04b8fec6 | 156 | * @return NFC_SUCCESS if no error happen |
| giovannivisentini | 7:19fc04b8fec6 | 157 | */ |
| giovannivisentini | 0:969a2be49f41 | 158 | virtual NFC_StatusTypeDef STReadBinary(uint16_t Offset, uint8_t NbByteToRead, uint8_t *pBufferRead) = 0; |
| giovannivisentini | 7:19fc04b8fec6 | 159 | |
| giovannivisentini | 7:19fc04b8fec6 | 160 | /** |
| giovannivisentini | 7:19fc04b8fec6 | 161 | * set the tag as read/write only and write it in the eeprom |
| giovannivisentini | 7:19fc04b8fec6 | 162 | * @param uReadOrWrite ReadPwd if you need a write only, WritePwd if you need a read only |
| giovannivisentini | 7:19fc04b8fec6 | 163 | * @return NFC_SUCCESS if no error happen |
| giovannivisentini | 7:19fc04b8fec6 | 164 | */ |
| giovannivisentini | 0:969a2be49f41 | 165 | virtual NFC_StatusTypeDef EnablePermanentState(PasswordType_t uReadOrWrite) = 0; |
| giovannivisentini | 7:19fc04b8fec6 | 166 | /** |
| giovannivisentini | 7:19fc04b8fec6 | 167 | * unset the tag as read/write only and write it in the eeprom |
| giovannivisentini | 7:19fc04b8fec6 | 168 | * @param uReadOrWrite ReadPwd if you need a write only, WritePwd if you need a read only |
| giovannivisentini | 7:19fc04b8fec6 | 169 | * @return NFC_SUCCESS if no error happen |
| giovannivisentini | 7:19fc04b8fec6 | 170 | * @par you must be in i2csuper user state for call this function |
| giovannivisentini | 7:19fc04b8fec6 | 171 | */ |
| giovannivisentini | 0:969a2be49f41 | 172 | virtual NFC_StatusTypeDef DisablePermanentState(PasswordType_t uReadOrWrite) = 0; |
| giovannivisentini | 7:19fc04b8fec6 | 173 | |
| giovannivisentini | 7:19fc04b8fec6 | 174 | /** |
| giovannivisentini | 7:19fc04b8fec6 | 175 | * set the gpo output pin |
| giovannivisentini | 7:19fc04b8fec6 | 176 | * @param uSetOrReset new pin status |
| giovannivisentini | 7:19fc04b8fec6 | 177 | * @return NFC_SUCCESS if no error happen |
| giovannivisentini | 7:19fc04b8fec6 | 178 | */ |
| giovannivisentini | 0:969a2be49f41 | 179 | virtual NFC_StatusTypeDef StateControl(uint8_t uSetOrReset) = 0; |
| giovannivisentini | 7:19fc04b8fec6 | 180 | |
| giovannivisentini | 7:19fc04b8fec6 | 181 | /** |
| giovannivisentini | 7:19fc04b8fec6 | 182 | * @brief This function configure GPO purpose for I2C session |
| giovannivisentini | 7:19fc04b8fec6 | 183 | * @param GPO_I2Cconfig: GPO configuration to set |
| giovannivisentini | 7:19fc04b8fec6 | 184 | * @return NFC_SUCCESS if no error happen |
| giovannivisentini | 7:19fc04b8fec6 | 185 | */ |
| giovannivisentini | 0:969a2be49f41 | 186 | virtual NFC_StatusTypeDef ManageI2CGPO(uint8_t GPO_I2Cconfig) = 0; |
| giovannivisentini | 7:19fc04b8fec6 | 187 | |
| giovannivisentini | 7:19fc04b8fec6 | 188 | /** |
| giovannivisentini | 7:19fc04b8fec6 | 189 | * @brief This function configure GPO purpose for RF session |
| giovannivisentini | 7:19fc04b8fec6 | 190 | * @param GPO_RFconfig: GPO configuration to set |
| giovannivisentini | 7:19fc04b8fec6 | 191 | * @return NFC_SUCCESS if no error happen |
| giovannivisentini | 7:19fc04b8fec6 | 192 | */ |
| giovannivisentini | 0:969a2be49f41 | 193 | virtual NFC_StatusTypeDef ManageRFGPO(uint8_t GPO_RFconfig) = 0; |
| giovannivisentini | 7:19fc04b8fec6 | 194 | |
| giovannivisentini | 7:19fc04b8fec6 | 195 | /** |
| giovannivisentini | 7:19fc04b8fec6 | 196 | * @brief This function enable or disable RF communication |
| giovannivisentini | 7:19fc04b8fec6 | 197 | * @param OnOffChoice: GPO configuration to set |
| giovannivisentini | 7:19fc04b8fec6 | 198 | * @return NFC_SUCCESS if no error happen |
| giovannivisentini | 7:19fc04b8fec6 | 199 | */ |
| giovannivisentini | 0:969a2be49f41 | 200 | virtual NFC_StatusTypeDef RFConfig(uint8_t OnOffChoice) = 0; |
| giovannivisentini | 0:969a2be49f41 | 201 | |
| giovannivisentini | 0:969a2be49f41 | 202 | virtual ~Nfc(){}; |
| giovannivisentini | 0:969a2be49f41 | 203 | }; |
| giovannivisentini | 0:969a2be49f41 | 204 | |
| giovannivisentini | 0:969a2be49f41 | 205 | #endif /* __NFC_CLASS_H */ |
| giovannivisentini | 0:969a2be49f41 | 206 | |
| giovannivisentini | 0:969a2be49f41 | 207 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |

X-NUCLEO-NFC01A1 Dynamic NFC Tag