2 * Copyright (C) 2010 NXP Semiconductors
\r
4 * Licensed under the Apache License, Version 2.0 (the "License");
\r
5 * you may not use this file except in compliance with the License.
\r
6 * You may obtain a copy of the License at
\r
8 * http://www.apache.org/licenses/LICENSE-2.0
\r
10 * Unless required by applicable law or agreed to in writing, software
\r
11 * distributed under the License is distributed on an "AS IS" BASIS,
\r
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
13 * See the License for the specific language governing permissions and
\r
14 * limitations under the License.
\r
18 * \file phFriNfc_LlcpUtils.h
\r
19 * \brief NFC LLCP utils
\r
25 #ifndef PHFRINFC_LLCPUTILS_H
\r
26 #define PHFRINFC_LLCPUTILS_H
\r
29 #include <phNfcHalTypes.h>
\r
30 #include <phNfcTypes.h>
\r
31 #include <phNfcStatus.h>
\r
32 #include <phFriNfc.h>
\r
33 #include <phFriNfc_Llcp.h>
\r
36 * \name NFC Forum Logical Link Control Protocol Utils
\r
38 * File: \ref phFriNfc_LlcpUtils.h
\r
43 * UTIL_FIFO_BUFFER - A Cyclic FIFO buffer
\r
44 * If pIn == pOut the buffer is empty.
\r
46 typedef struct UTIL_FIFO_BUFFER
\r
48 uint8_t *pBuffStart; /* Points to first valid location in buffer */
\r
49 uint8_t *pBuffEnd; /* Points to last valid location in buffer */
\r
50 volatile uint8_t *pIn; /* Points to 1 before where the next TU1 will enter buffer */
\r
51 volatile uint8_t *pOut; /* Points to 1 before where the next TU1 will leave buffer */
\r
52 volatile bool_t bFull; /* TRUE if buffer is full */
\r
53 }UTIL_FIFO_BUFFER, *P_UTIL_FIFO_BUFFER;
\r
56 /** \defgroup grp_fri_nfc_llcp NFC Forum Logical Link Control Protocol Component
\r
62 NFCSTATUS phFriNfc_Llcp_DecodeTLV( phNfc_sData_t *psRawData,
\r
65 phNfc_sData_t *psValueBuffer );
\r
67 NFCSTATUS phFriNfc_Llcp_EncodeTLV( phNfc_sData_t *psValueBuffer,
\r
73 void phFriNfc_Llcp_EncodeMIUX(uint16_t pMiux,
\r
74 uint8_t* pMiuxEncoded);
\r
76 void phFriNfc_Llcp_EncodeRW(uint8_t *pRw);
\r
79 * Initializes a Fifo Cyclic Buffer to point to some allocated memory.
\r
81 void phFriNfc_Llcp_CyclicFifoInit(P_UTIL_FIFO_BUFFER sUtilFifo,
\r
82 const uint8_t *pBuffStart,
\r
83 uint32_t buffLength);
\r
86 * Clears the Fifo Cyclic Buffer - loosing any data that was in it.
\r
88 void phFriNfc_Llcp_CyclicFifoClear(P_UTIL_FIFO_BUFFER sUtilFifo);
\r
92 * Attempts to write dataLength bytes to the specified Fifo Cyclic Buffer.
\r
94 uint32_t phFriNfc_Llcp_CyclicFifoWrite(P_UTIL_FIFO_BUFFER sUtilFifo,
\r
96 uint32_t dataLength);
\r
99 * Attempts to read dataLength bytes from the specified Fifo Cyclic Buffer.
\r
101 uint32_t phFriNfc_Llcp_CyclicFifoFifoRead(P_UTIL_FIFO_BUFFER sUtilFifo,
\r
103 uint32_t dataLength);
\r
106 * Returns the number of bytes currently stored in Fifo Cyclic Buffer.
\r
108 uint32_t phFriNfc_Llcp_CyclicFifoUsage(P_UTIL_FIFO_BUFFER sUtilFifo);
\r
111 * Returns the available room for writing in Fifo Cyclic Buffer.
\r
113 uint32_t phFriNfc_Llcp_CyclicFifoAvailable(P_UTIL_FIFO_BUFFER sUtilFifo);
\r
115 uint32_t phFriNfc_Llcp_Header2Buffer( phFriNfc_Llcp_sPacketHeader_t *psHeader,
\r
117 uint32_t nOffset );
\r
119 uint32_t phFriNfc_Llcp_Sequence2Buffer( phFriNfc_Llcp_sPacketSequence_t *psSequence,
\r
121 uint32_t nOffset );
\r
123 uint32_t phFriNfc_Llcp_Buffer2Header( uint8_t *pBuffer,
\r
125 phFriNfc_Llcp_sPacketHeader_t *psHeader );
\r
127 uint32_t phFriNfc_Llcp_Buffer2Sequence( uint8_t *pBuffer,
\r
129 phFriNfc_Llcp_sPacketSequence_t *psSequence );
\r
132 #endif /* PHFRINFC_LLCPUTILS_H */
\r