3 * Copyright (C) 2010 NXP Semiconductors
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
19 * \file phFriNfc_ISO15693Map.h
20 * \brief NFC Ndef Mapping For ISO-15693 Smart Card.
31 #ifndef PHFRINFC_ISO15693MAP_H
32 #define PHFRINFC_ISO15693MAP_H
34 /************************** START MACROS definition *********************/
35 /* BYTES in a BLOCK */
36 #define ISO15693_BYTES_PER_BLOCK 0x04U
38 #define ISO15693_BLOCKS_PER_PAGE 0x04U
39 /* 3 BYTE value identifier for NDEF TLV */
40 #define ISO15693_THREE_BYTE_LENGTH_ID 0xFFU
42 /* Get the NDEF TLV VALUE field block and byte address */
43 #define ISO15693_GET_VALUE_FIELD_BLOCK_NO(blk, byte_addr, ndef_size) \
44 (((byte_addr + 1 + ((ndef_size >= ISO15693_THREE_BYTE_LENGTH_ID) ? 3 : 1)) > \
45 (ISO15693_BYTES_PER_BLOCK - 1)) ? (blk + 1) : blk)
47 #define ISO15693_GET_VALUE_FIELD_BYTE_NO(blk, byte_addr, ndef_size) \
48 (((byte_addr + 1 + ((ndef_size >= ISO15693_THREE_BYTE_LENGTH_ID) ? 3 : 1)) % \
49 ISO15693_BYTES_PER_BLOCK))
51 /************************** END MACROS definition *********************/
53 /************************** START Functions declaration *********************/
55 * \brief \copydoc page_ovr Initiates Reading of NDEF information from the Remote Device.
57 * The function initiates the reading of NDEF information from a Remote Device.
58 * It performs a reset of the state and starts the action (state machine).
59 * A periodic call of the \ref phFriNfc_NdefMap_Process has to be done once the action
62 * \param[in] NdefMap Pointer to a valid instance of the \ref phFriNfc_NdefMap_t structure describing
63 * the component context.
65 * \param[in] PacketData Pointer to a location that receives the NDEF Packet.
67 * \param[in,out] PacketDataLength Pointer to a variable receiving the length of the NDEF packet.
69 * \param[in] Offset Indicates whether the read operation shall start from the begining of the
70 * file/card storage \b or continue from the last offset. The last Offset set is stored
71 * within a context variable (must not be modified by the integration).
72 * If the caller sets the value to \ref PH_FRINFC_NDEFMAP_SEEK_CUR, the component shall
73 * start reading from the last offset set (continue where it has stopped before).
74 * If set to \ref PH_FRINFC_NDEFMAP_SEEK_BEGIN, the component shall start reading
75 * from the begining of the card (restarted)
77 * \retval NFCSTATUS_PENDING The action has been successfully triggered.
78 * \retval NFCSTATUS_INVALID_DEVICE_REQUEST If Previous Operation is Write Ndef and Offset
79 * is Current then this error is displayed.
80 * \retval NFCSTATUS_EOF_NDEF_CONTAINER_REACHED No Space in the File to read.
81 * \retval NFCSTATUS_MORE_INFORMATION There are more bytes to read in the card.
82 * \retval NFCSTATUS_SUCCESS Last Byte of the card read.
83 * \retval NFCSTATUS_INVALID_DEVICE The device has not been opened or has been disconnected
85 * \retval NFCSTATUS_CMD_ABORTED The caller/driver has aborted the request.
86 * \retval NFCSTATUS_BUFFER_TOO_SMALL The buffer provided by the caller is too small.
87 * \retval NFCSTATUS_RF_TIMEOUT No data has been received within the TIMEOUT period.
92 phFriNfc_ISO15693_RdNdef (
93 phFriNfc_NdefMap_t *psNdefMap,
95 uint32_t *pPacketDataLength,
99 * \brief \copydoc page_ovr Initiates Writing of NDEF information to the Remote Device.
101 * The function initiates the writing of NDEF information to a Remote Device.
102 * It performs a reset of the state and starts the action (state machine).
103 * A periodic call of the \ref phFriNfc_NdefMap_Process has to be done once the action
104 * has been triggered.
106 * \param[in] NdefMap Pointer to a valid instance of the \ref phFriNfc_NdefMap_t structure describing
107 * the component context.
109 * \param[in] PacketData Pointer to a location that holds the prepared NDEF Packet.
111 * \param[in,out] PacketDataLength Variable specifying the length of the prepared NDEF packet.
113 * \param[in] Offset Indicates whether the write operation shall start from the begining of the
114 * file/card storage \b or continue from the last offset. The last Offset set is stored
115 * within a context variable (must not be modified by the integration).
116 * If the caller sets the value to \ref PH_FRINFC_NDEFMAP_SEEK_CUR, the component shall
117 * start writing from the last offset set (continue where it has stopped before).
118 * If set to \ref PH_FRINFC_NDEFMAP_SEEK_BEGIN, the component shall start writing
119 * from the begining of the card (restarted)
121 * \retval NFCSTATUS_PENDING The action has been successfully triggered.
122 * \retval NFCSTATUS_INVALID_DEVICE_REQUEST If Previous Operation is Write Ndef and Offset
123 * is Current then this error is displayed.
124 * \retval NFCSTATUS_EOF_NDEF_CONTAINER_REACHED Last byte is written to the card after this
125 * no further writing is possible.
126 * \retval NFCSTATUS_SUCCESS Buffer provided by the user is completely written
128 * \retval NFCSTATUS_INVALID_DEVICE The device has not been opened or has been disconnected
130 * \retval NFCSTATUS_CMD_ABORTED The caller/driver has aborted the request.
131 * \retval NFCSTATUS_BUFFER_TOO_SMALL The buffer provided by the caller is too small.
132 * \retval NFCSTATUS_RF_TIMEOUT No data has been received within the TIMEOUT period.
137 phFriNfc_ISO15693_WrNdef (
138 phFriNfc_NdefMap_t *psNdefMap,
139 uint8_t *pPacketData,
140 uint32_t *pPacketDataLength,
144 * \brief \copydoc page_ovr Check whether a particulat Remote Device is NDEF compliant.
146 * The function checks whether the peer device is NDEF compliant.
148 * \param[in] NdefMap Pointer to a valid instance of the \ref phFriNfc_NdefMap_t structure describing
149 * the component context.
151 * \retval NFCSTATUS_PENDING The action has been successfully triggered.
152 * \retval NFCSTATUS_INVALID_PARAMETER At least one parameter of the function is invalid.
153 * \retval NFCSTATUS_INVALID_DEVICE The device has not been opened or has been disconnected
155 * \retval NFCSTATUS_CMD_ABORTED The caller/driver has aborted the request.
156 * \retval NFCSTATUS_BUFFER_TOO_SMALL The buffer provided by the caller is too small.
157 * \retval NFCSTATUS_RF_TIMEOUT No data has been received within the TIMEOUT period.
162 phFriNfc_ISO15693_ChkNdef (
163 phFriNfc_NdefMap_t *psNdefMap);
166 * \brief \copydoc page_cb Completion Routine, Processing function, needed to avoid long blocking.
168 * The function call scheme is according to \ref grp_interact. No State reset is performed during operation.
170 * \copydoc pphFriNfc_Cr_t
172 * \note The lower (Overlapped HAL) layer must register a pointer to this function as a Completion
173 * Routine in order to be able to notify the component that an I/O has finished and data are
174 * ready to be processed.
179 phFriNfc_ISO15693_Process (
183 #ifdef FRINFC_READONLY_NDEF
186 * \brief \copydoc page_ovr Initiates Writing of NDEF information to the Remote Device.
188 * The function initiates the writing of NDEF information to a Remote Device.
189 * It performs a reset of the state and starts the action (state machine).
190 * A periodic call of the \ref phFriNfc_NdefMap_Process has to be done once the action
191 * has been triggered.
193 * \param[in] psNdefMap Pointer to a valid instance of the \ref phFriNfc_NdefMap_t structure describing
194 * the component context.
197 * \retval NFCSTATUS_PENDING The action has been successfully triggered.
198 * \retval NFCSTATUS_INVALID_DEVICE_REQUEST If Previous Operation is Write Ndef and Offset
199 * is Current then this error is displayed.
200 * \retval NFCSTATUS_EOF_NDEF_CONTAINER_REACHED Last byte is written to the card after this
201 * no further writing is possible.
202 * \retval NFCSTATUS_SUCCESS Buffer provided by the user is completely written
204 * \retval NFCSTATUS_INVALID_DEVICE The device has not been opened or has been disconnected
206 * \retval NFCSTATUS_CMD_ABORTED The caller/driver has aborted the request.
207 * \retval NFCSTATUS_BUFFER_TOO_SMALL The buffer provided by the caller is too small.
208 * \retval NFCSTATUS_RF_TIMEOUT No data has been received within the TIMEOUT period.
212 phFriNfc_ISO15693_ConvertToReadOnly (
213 phFriNfc_NdefMap_t *psNdefMap);
215 #endif /* #ifdef FRINFC_READONLY_NDEF */
217 /************************** END Functions declaration *********************/
219 #endif /* #ifndef PHFRINFC_ISO15693MAP_H */