2 * Copyright (C) 2010 NXP Semiconductors
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 * \file phFriNfc_FelicaMap.h
19 * \brief NFC Ndef Mapping For Felica Smart Card.
23 * $Date: Wed Apr 8 14:37:05 2009 $
26 * $Aliases: NFC_FRI1.1_WK914_R22_1,NFC_FRI1.1_WK914_R22_2,NFC_FRI1.1_WK916_R23_1,NFC_FRI1.1_WK918_R24_1,NFC_FRI1.1_WK920_PREP1,NFC_FRI1.1_WK920_R25_1,NFC_FRI1.1_WK922_PREP1,NFC_FRI1.1_WK922_R26_1,NFC_FRI1.1_WK924_PREP1,NFC_FRI1.1_WK924_R27_1,NFC_FRI1.1_WK926_R28_1,NFC_FRI1.1_WK928_R29_1,NFC_FRI1.1_WK930_R30_1,NFC_FRI1.1_WK934_PREP_1,NFC_FRI1.1_WK934_R31_1,NFC_FRI1.1_WK941_PREP1,NFC_FRI1.1_WK941_PREP2,NFC_FRI1.1_WK941_1,NFC_FRI1.1_WK943_R32_1,NFC_FRI1.1_WK949_PREP1,NFC_FRI1.1_WK943_R32_10,NFC_FRI1.1_WK943_R32_13,NFC_FRI1.1_WK943_R32_14,NFC_FRI1.1_WK1007_R33_1,NFC_FRI1.1_WK1007_R33_4,NFC_FRI1.1_WK1017_PREP1,NFC_FRI1.1_WK1017_R34_1,NFC_FRI1.1_WK1017_R34_2,NFC_FRI1.1_WK1023_R35_1 $
30 #ifndef PHFRINFC_FELICAMAP_H
31 #define PHFRINFC_FELICAMAP_H
34 #if !defined PH_HAL4_ENABLE
37 #include <phNfcStatus.h>
38 #include <phNfcTypes.h>
39 #include <phFriNfc_NdefMap.h>
42 #ifndef PH_FRINFC_EXCLUDE_FROM_TESTFW /* */
44 #define PH_FRINFC_NDEFMAP_FELICAMAP_FILEREVISION "$Revision: 1.4 $"
45 #define PH_FRINFC_NDEFMAP_FELLICAMAP_FILEALIASES "$Aliases: NFC_FRI1.1_WK914_R22_1,NFC_FRI1.1_WK914_R22_2,NFC_FRI1.1_WK916_R23_1,NFC_FRI1.1_WK918_R24_1,NFC_FRI1.1_WK920_PREP1,NFC_FRI1.1_WK920_R25_1,NFC_FRI1.1_WK922_PREP1,NFC_FRI1.1_WK922_R26_1,NFC_FRI1.1_WK924_PREP1,NFC_FRI1.1_WK924_R27_1,NFC_FRI1.1_WK926_R28_1,NFC_FRI1.1_WK928_R29_1,NFC_FRI1.1_WK930_R30_1,NFC_FRI1.1_WK934_PREP_1,NFC_FRI1.1_WK934_R31_1,NFC_FRI1.1_WK941_PREP1,NFC_FRI1.1_WK941_PREP2,NFC_FRI1.1_WK941_1,NFC_FRI1.1_WK943_R32_1,NFC_FRI1.1_WK949_PREP1,NFC_FRI1.1_WK943_R32_10,NFC_FRI1.1_WK943_R32_13,NFC_FRI1.1_WK943_R32_14,NFC_FRI1.1_WK1007_R33_1,NFC_FRI1.1_WK1007_R33_4,NFC_FRI1.1_WK1017_PREP1,NFC_FRI1.1_WK1017_R34_1,NFC_FRI1.1_WK1017_R34_2,NFC_FRI1.1_WK1023_R35_1 $"
47 /* NDEF Mapping - states of the Finite State machine */
48 #define PH_NFCFRI_NDEFMAP_FELI_STATE_SELECT_WILD_CARD 1 /* Select Wild Card State*/
49 #define PH_NFCFRI_NDEFMAP_FELI_STATE_SELECT_NDEF_APP 2 /* Select NFC Forum Application State*/
50 #define PH_FRINFC_NDEFMAP_FELI_STATE_CHK_NDEF 3 /* Ndef Complient State*/
51 #define PH_NFCFRI_NDEFMAP_FELI_STATE_RD_ATTR 4 /* Read Attribute Information State*/
52 #define PH_NFCFRI_NDEFMAP_FELI_STATE_RD_BLOCK 5 /* Read Data state*/
53 #define PH_NFCFRI_NDEFMAP_FELI_STATE_WR_BLOCK 6 /* Write Data State*/
54 #define PH_NFCFRI_NDEFMAP_FELI_STATE_ATTR_BLK_WR_BEGIN 7 /* Write Attrib Blk for write Begin*/
55 #define PH_NFCFRI_NDEFMAP_FELI_STATE_ATTR_BLK_WR_END 8 /* Write Attrib Blk for write End*/
56 #define PH_NFCFRI_NDEFMAP_FELI_STATE_WR_EMPTY_MSG 9 /* write Empty Ndef Msg*/
59 #define PH_NFCFRI_NDEFMAP_FELI_WR_RESP_BYTE 0x09 /* Write Cmd Response Byte*/
60 #define PH_NFCFRI_NDEFMAP_FELI_RD_RESP_BYTE 0x07 /* Read Cmd Response Byte*/
62 #define PH_NFCFRI_NDEFMAP_FELI_NMAXB 13 /* Nmaxb Identifier*/
63 #define PH_NFCFRI_NDEFMAP_FELI_NBC 14 /* Nbc Identifier*/
65 #define PH_FRINFC_NDEFMAP_FELI_OP_NONE 15 /* To Read the attribute information*/
66 #define PH_FRINFC_NDEFMAP_FELI_WR_ATTR_RD_OP 16 /* To Read the attribute info. while a WR Operationg*/
67 #define PH_FRINFC_NDEFMAP_FELI_RD_ATTR_RD_OP 17 /* To Read the attribute info. while a RD Operationg*/
68 #define PH_FRINFC_NDEFMAP_FELI_CHK_NDEF_OP 18 /* To Process the read attribute info. while a ChkNdef Operation*/
69 #define PH_FRINFC_NDEFMAP_FELI_WR_EMPTY_MSG_OP 19 /* To Process the Empty NDEF Msg while erasing the NDEF data*/
71 #define PH_FRINFC_NDEFMAP_FELI_NUM_DEVICE_TO_DETECT 1
73 #define PH_NFCFRI_NDEFMAP_FELI_RESP_HEADER_LEN 13 /* To skip response code, IDm, status flgas and Nb*/
74 #define PH_NFCFRI_NDEFMAP_FELI_VERSION_INDEX 13 /* Specifies Index of the version in Attribute Resp Buffer*/
75 #define PH_NFCFRI_NDEFMAP_FELI_PKT_LEN_INDEX 0 /* Specifies Index of the Packet Length*/
78 /* To Handle the EOF staus*/
81 #endif /* #ifndef TRUE */
85 #endif /* #ifndef FALSE */
88 /* NFC Device Major and Minor Version numbers*/
89 /* !!CAUTION!! these needs to be updated periodically.Major and Minor version numbers
90 should be compatible to the version number of currently implemented mapping document.
91 Example : NFC Device version Number : 1.0 , specifies
94 #define PH_NFCFRI_NDEFMAP_FELI_NFCDEV_MAJOR_VER_NUM 0x01
95 #define PH_NFCFRI_NDEFMAP_FELI_NFCDEV_MINOR_VER_NUM 0x00
97 /* Macros to find major and minor T3T version numbers*/
98 #define PH_NFCFRI_NDEFMAP_FELI_GET_MAJOR_T3T_VERNO(a)\
101 (((a) & (0xf0))>>(4))\
104 #define PH_NFCFRI_NDEFMAP_FELI_GET_MINOR_T3T_VERNO(a)\
111 /* Macro for LEN Byte Calculation*/
112 #define PH_NFCFRI_NDEFMAP_FELI_CAL_LEN_BYTES(Byte1,Byte2,Byte3,DataLen)\
115 (DataLen) = (Byte1); \
116 (DataLen) = (DataLen) << (16);\
117 (DataLen) += (Byte2);\
118 (DataLen) = (DataLen) << (8);\
119 (DataLen) += (Byte3);\
125 /* Enum for the data write operations*/
128 FELICA_WRITE_STARTED,
130 FELICA_EOF_REACHED_WR_WITH_BEGIN_OFFSET,
131 FELICA_EOF_REACHED_WR_WITH_CURR_OFFSET,
132 FELICA_RD_WR_EOF_CARD_REACHED,
133 FELICA_WRITE_EMPTY_MSG
135 }phFriNfc_FelicaError_t;
140 * \brief \copydoc page_ovr Initiates Reading of NDEF information from the Remote Device.
142 * The function initiates the reading of NDEF information from a Remote Device.
143 * It performs a reset of the state and starts the action (state machine).
144 * A periodic call of the \ref phFriNfc_NdefMap_Process has to be done once the action
145 * has been triggered.
147 * \param[in] NdefMap Pointer to a valid instance of the \ref phFriNfc_NdefMap_t structure describing
148 * the component context.
150 * \param[in] PacketData Pointer to a location that receives the NDEF Packet.
152 * \param[in,out] PacketDataLength Pointer to a variable receiving the length of the NDEF packet.
154 * \param[in] Offset Indicates whether the read operation shall start from the begining of the
155 * file/card storage \b or continue from the last offset. The last Offset set is stored
156 * within a context variable (must not be modified by the integration).
157 * If the caller sets the value to \ref PH_FRINFC_NDEFMAP_SEEK_CUR, the component shall
158 * start reading from the last offset set (continue where it has stopped before).
159 * If set to \ref PH_FRINFC_NDEFMAP_SEEK_BEGIN, the component shall start reading
160 * from the begining of the card (restarted)
162 * \retval NFCSTATUS_PENDING The action has been successfully triggered.
163 * \retval NFCSTATUS_INVALID_DEVICE_REQUEST If Previous Operation is Write Ndef and Offset
164 * is Current then this error is displayed.
165 * \retval NFCSTATUS_EOF_NDEF_CONTAINER_REACHED No Space in the File to read.
166 * \retval NFCSTATUS_SUCCESS Last Byte of the card read.
167 * \retval NFCSTATUS_INVALID_DEVICE The device has not been opened or has been disconnected
169 * \retval NFCSTATUS_CMD_ABORTED The caller/driver has aborted the request.
170 * \retval NFCSTATUS_RF_TIMEOUT No data has been received within the TIMEOUT period.
174 NFCSTATUS phFriNfc_Felica_RdNdef( phFriNfc_NdefMap_t *NdefMap,
176 uint32_t *PacketDataLength,
180 * \brief \copydoc page_ovr Initiates Writing of NDEF information to the Remote Device.
182 * The function initiates the writing of NDEF information to a Remote Device.
183 * It performs a reset of the state and starts the action (state machine).
184 * A periodic call of the \ref phFriNfc_NdefMap_Process has to be done once the action
185 * has been triggered.
187 * \param[in] NdefMap Pointer to a valid instance of the \ref phFriNfc_NdefMap_t structure describing
188 * the component context.
190 * \param[in] PacketData Pointer to a location that holds the prepared NDEF Packet.
192 * \param[in,out] PacketDataLength Variable specifying the length of the prepared NDEF packet.
194 * \param[in] Offset Indicates whether the write operation shall start from the begining of the
195 * file/card storage \b or continue from the last offset. The last Offset set is stored
196 * within a context variable (must not be modified by the integration).
197 * If the caller sets the value to \ref PH_FRINFC_NDEFMAP_SEEK_CUR, the component shall
198 * start writing from the last offset set (continue where it has stopped before).
199 * If set to \ref PH_FRINFC_NDEFMAP_SEEK_BEGIN, the component shall start writing
200 * from the begining of the card (restarted)
202 * \retval NFCSTATUS_PENDING The action has been successfully triggered.
203 * \retval NFCSTATUS_INVALID_DEVICE_REQUEST If Previous Operation is Write Ndef and Offset
204 * is Current then this error is displayed.
205 * \retval NFCSTATUS_EOF_NDEF_CONTAINER_REACHED Last byte is written to the card after this
206 * no further writing is possible.
207 * \retval NFCSTATUS_SUCCESS Buffer provided by the user is completely written
209 * \retval NFCSTATUS_INVALID_DEVICE The device has not been opened or has been disconnected
211 * \retval NFCSTATUS_CMD_ABORTED The caller/driver has aborted the request.
212 * \retval NFCSTATUS_RF_TIMEOUT No data has been received within the TIMEOUT period.
216 NFCSTATUS phFriNfc_Felica_WrNdef( phFriNfc_NdefMap_t *NdefMap,
218 uint32_t *PacketDataLength,
222 * \brief \copydoc page_ovr Initiates Writing of Empty NDEF information to the Remote Device.
224 * The function initiates the erasing of NDEF information to a Remote Device.
225 * It performs a reset of the state and starts the action (state machine).
226 * A periodic call of the \ref phFriNfc_NdefMap_Process has to be done once the action
227 * has been triggered.
229 * \param[in] NdefMap Pointer to a valid instance of the \ref phFriNfc_NdefMap_t structure describing
230 * the component context.
232 * \retval NFCSTATUS_PENDING The action has been successfully triggered.
233 * \retval NFCSTATUS_SUCCESS Empty msessage is completely written
235 * \retval NFCSTATUS_INVALID_DEVICE The device has not been opened or has been disconnected
237 * \retval NFCSTATUS_CMD_ABORTED The caller/driver has aborted the request.
238 * \retval NFCSTATUS_RF_TIMEOUT No data has been received within the TIMEOUT period.
242 NFCSTATUS phFriNfc_Felica_EraseNdef( phFriNfc_NdefMap_t *NdefMap);
246 * \brief \copydoc page_ovr Check whether a particulat Remote Device is NDEF compliant.
248 * The function checks whether the peer device is NDEF compliant.
250 * \param[in] NdefMap Pointer to a valid instance of the \ref phFriNfc_NdefMap_t structure describing
251 * the component context.
253 * \retval NFCSTATUS_PENDING The action has been successfully triggered.
254 * \retval NFCSTATUS_INVALID_PARAMETER At least one parameter of the function is invalid.
255 * \retval NFCSTATUS_INVALID_DEVICE The device has not been opened or has been disconnected
257 * \retval NFCSTATUS_CMD_ABORTED The caller/driver has aborted the request.
258 * \retval NFCSTATUS_RF_TIMEOUT No data has been received within the TIMEOUT period.
262 NFCSTATUS phFriNfc_Felica_ChkNdef( phFriNfc_NdefMap_t *NdefMap);
265 * \brief \copydoc page_cb Completion Routine, Processing function, needed to avoid long blocking.
267 * The function call scheme is according to \ref grp_interact. No State reset is performed during operation.
269 * \copydoc pphFriNfc_Cr_t
271 * \note The lower (Overlapped HAL) layer must register a pointer to this function as a Completion
272 * Routine in order to be able to notify the component that an I/O has finished and data are
273 * ready to be processed.
277 void phFriNfc_Felica_Process(void *Context,
281 #endif /* PH_FRINFC_EXCLUDE_FROM_TESTFW */
284 #endif /* PHFRINFC_FELICAMAP_H */