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_LlcpUtils.h
19 * \brief NFC LLCP utils
25 #ifndef PHFRINFC_LLCPUTILS_H
26 #define PHFRINFC_LLCPUTILS_H
29 #include <phNfcHalTypes.h>
30 #include <phNfcTypes.h>
31 #include <phNfcStatus.h>
33 #include <phFriNfc_Llcp.h>
36 * \name NFC Forum Logical Link Control Protocol Utils
38 * File: \ref phFriNfc_LlcpUtils.h
43 * UTIL_FIFO_BUFFER - A Cyclic FIFO buffer
44 * If pIn == pOut the buffer is empty.
46 typedef struct UTIL_FIFO_BUFFER
48 uint8_t *pBuffStart; /* Points to first valid location in buffer */
49 uint8_t *pBuffEnd; /* Points to last valid location in buffer */
50 volatile uint8_t *pIn; /* Points to 1 before where the next TU1 will enter buffer */
51 volatile uint8_t *pOut; /* Points to 1 before where the next TU1 will leave buffer */
52 volatile bool_t bFull; /* TRUE if buffer is full */
53 }UTIL_FIFO_BUFFER, *P_UTIL_FIFO_BUFFER;
56 /** \defgroup grp_fri_nfc_llcp NFC Forum Logical Link Control Protocol Component
62 NFCSTATUS phFriNfc_Llcp_DecodeTLV( phNfc_sData_t *psRawData,
65 phNfc_sData_t *psValueBuffer );
67 NFCSTATUS phFriNfc_Llcp_EncodeTLV( phNfc_sData_t *psValueBuffer,
73 void phFriNfc_Llcp_EncodeMIUX(uint16_t pMiux,
74 uint8_t* pMiuxEncoded);
76 void phFriNfc_Llcp_EncodeRW(uint8_t *pRw);
79 * Initializes a Fifo Cyclic Buffer to point to some allocated memory.
81 void phFriNfc_Llcp_CyclicFifoInit(P_UTIL_FIFO_BUFFER sUtilFifo,
82 const uint8_t *pBuffStart,
86 * Clears the Fifo Cyclic Buffer - loosing any data that was in it.
88 void phFriNfc_Llcp_CyclicFifoClear(P_UTIL_FIFO_BUFFER sUtilFifo);
92 * Attempts to write dataLength bytes to the specified Fifo Cyclic Buffer.
94 uint32_t phFriNfc_Llcp_CyclicFifoWrite(P_UTIL_FIFO_BUFFER sUtilFifo,
99 * Attempts to read dataLength bytes from the specified Fifo Cyclic Buffer.
101 uint32_t phFriNfc_Llcp_CyclicFifoFifoRead(P_UTIL_FIFO_BUFFER sUtilFifo,
103 uint32_t dataLength);
106 * Returns the number of bytes currently stored in Fifo Cyclic Buffer.
108 uint32_t phFriNfc_Llcp_CyclicFifoUsage(P_UTIL_FIFO_BUFFER sUtilFifo);
111 * Returns the available room for writing in Fifo Cyclic Buffer.
113 uint32_t phFriNfc_Llcp_CyclicFifoAvailable(P_UTIL_FIFO_BUFFER sUtilFifo);
115 uint32_t phFriNfc_Llcp_Header2Buffer( phFriNfc_Llcp_sPacketHeader_t *psHeader,
119 uint32_t phFriNfc_Llcp_Sequence2Buffer( phFriNfc_Llcp_sPacketSequence_t *psSequence,
123 uint32_t phFriNfc_Llcp_Buffer2Header( uint8_t *pBuffer,
125 phFriNfc_Llcp_sPacketHeader_t *psHeader );
127 uint32_t phFriNfc_Llcp_Buffer2Sequence( uint8_t *pBuffer,
129 phFriNfc_Llcp_sPacketSequence_t *psSequence );
132 #endif /* PHFRINFC_LLCPUTILS_H */