Initialize Tizen 2.3
[adaptation/devices/nfc-plugin-nxp.git] / src / phFriNfc_ISO15693Map.h
1 /*
2  *
3  * Copyright (C) 2010 NXP Semiconductors
4  *
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
8  *
9  *      http://www.apache.org/licenses/LICENSE-2.0
10  *
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.
16  */
17
18 /*
19  * \file  phFriNfc_ISO15693Map.h
20  * \brief NFC Ndef Mapping For ISO-15693 Smart Card.
21  *
22  * Project: NFC-FRI
23  *
24  * $Date:  $
25  * $Author: ing02260 $
26  * $Revision:  $
27  * $Aliases:  $
28  *
29  */
30
31 #ifndef PHFRINFC_ISO15693MAP_H
32 #define PHFRINFC_ISO15693MAP_H
33
34 /************************** START MACROS definition *********************/
35 /* BYTES in a BLOCK */
36 #define ISO15693_BYTES_PER_BLOCK            0x04U
37 /* BLOCKS per page */
38 #define ISO15693_BLOCKS_PER_PAGE            0x04U
39 /* 3 BYTE value identifier for NDEF TLV */
40 #define ISO15693_THREE_BYTE_LENGTH_ID       0xFFU
41
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)
46
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))
50
51 /************************** END MACROS definition *********************/
52
53 /************************** START Functions declaration *********************/
54 /*!
55  * \brief \copydoc page_ovr Initiates Reading of NDEF information from the Remote Device.
56  *
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
60  * has been triggered.
61  *
62  * \param[in] NdefMap Pointer to a valid instance of the \ref phFriNfc_NdefMap_t structure describing
63  *                    the component context.
64  *
65  * \param[in] PacketData  Pointer to a location that receives the NDEF Packet.
66  *
67  * \param[in,out] PacketDataLength Pointer to a variable receiving the length of the NDEF packet.
68  *
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) 
76  *
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
84  *                                                 meanwhile.
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.
88  *
89  */
90
91 NFCSTATUS 
92 phFriNfc_ISO15693_RdNdef (
93     phFriNfc_NdefMap_t  *psNdefMap,
94     uint8_t             *pPacketData,
95     uint32_t            *pPacketDataLength,
96     uint8_t             Offset);
97
98 /*!
99  * \brief \copydoc page_ovr Initiates Writing of NDEF information to the Remote Device.
100  *
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.
105  *
106  * \param[in] NdefMap Pointer to a valid instance of the \ref phFriNfc_NdefMap_t structure describing
107  *                    the component context.
108  *
109  * \param[in] PacketData  Pointer to a location that holds the prepared NDEF Packet.
110  *
111  * \param[in,out] PacketDataLength Variable specifying the length of the prepared NDEF packet.
112  *
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) 
120  *
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
127  *                                                  into the card.
128  * \retval NFCSTATUS_INVALID_DEVICE                 The device has not been opened or has been disconnected
129  *                                                  meanwhile.
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.
133  *
134  */
135
136 NFCSTATUS 
137 phFriNfc_ISO15693_WrNdef (
138     phFriNfc_NdefMap_t  *psNdefMap,
139     uint8_t             *pPacketData,
140     uint32_t            *pPacketDataLength,
141     uint8_t             Offset);
142
143 /*!
144  * \brief \copydoc page_ovr Check whether a particulat Remote Device is NDEF compliant.
145  *
146  * The function checks whether the peer device is NDEF compliant.
147  *
148  * \param[in] NdefMap Pointer to a valid instance of the \ref phFriNfc_NdefMap_t structure describing
149  *                    the component context.
150  *
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
154  *                                          meanwhile.
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.
158  *
159  */
160
161 NFCSTATUS 
162 phFriNfc_ISO15693_ChkNdef (
163     phFriNfc_NdefMap_t  *psNdefMap);
164
165 /*!
166  * \brief \copydoc page_cb Completion Routine, Processing function, needed to avoid long blocking.
167  *
168  * The function call scheme is according to \ref grp_interact. No State reset is performed during operation.
169  *
170  * \copydoc pphFriNfc_Cr_t
171  *
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.
175  *
176  */
177                                     
178 void 
179 phFriNfc_ISO15693_Process (
180     void        *pContext,
181     NFCSTATUS   Status);
182
183 #ifdef FRINFC_READONLY_NDEF
184
185 /*!
186  * \brief \copydoc page_ovr Initiates Writing of NDEF information to the Remote Device.
187  *
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.
192  *
193  * \param[in] psNdefMap Pointer to a valid instance of the \ref phFriNfc_NdefMap_t structure describing
194  *                    the component context.
195  *
196  *
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
203  *                                                  into the card.
204  * \retval NFCSTATUS_INVALID_DEVICE                 The device has not been opened or has been disconnected
205  *                                                  meanwhile.
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.
209  *
210  */
211 NFCSTATUS 
212 phFriNfc_ISO15693_ConvertToReadOnly (
213     phFriNfc_NdefMap_t  *psNdefMap);
214
215 #endif /* #ifdef FRINFC_READONLY_NDEF */
216
217 /************************** END Functions declaration *********************/
218
219 #endif /* #ifndef PHFRINFC_ISO15693MAP_H */