diff options
author | Nick Pelly <npelly@google.com> | 2010-09-23 12:47:58 -0700 |
---|---|---|
committer | Nick Pelly <npelly@google.com> | 2010-09-23 13:53:18 -0700 |
commit | 5d9927ba30ba449badb9f6df0fbeb4d6aedc6e2a (patch) | |
tree | 190f9251c6db03d3550ec7f30b51a2561c01d9cf /src/phFriNfc_LlcpUtils.h | |
parent | 4ff7c86a2c706b150078274455406f1b04966e1a (diff) | |
download | external_libnfc-nxp-5d9927ba30ba449badb9f6df0fbeb4d6aedc6e2a.zip external_libnfc-nxp-5d9927ba30ba449badb9f6df0fbeb4d6aedc6e2a.tar.gz external_libnfc-nxp-5d9927ba30ba449badb9f6df0fbeb4d6aedc6e2a.tar.bz2 |
Initial libnfc checkin
Source: Trusted_NFC_Device_Host_AA03.01e02_google.zip code drop (23-Sep-2010)
Change-Id: Ie47f18423f949a8d3e0815d13f55c814312add24
Signed-off-by: Nick Pelly <npelly@google.com>
Diffstat (limited to 'src/phFriNfc_LlcpUtils.h')
-rw-r--r-- | src/phFriNfc_LlcpUtils.h | 132 |
1 files changed, 132 insertions, 0 deletions
diff --git a/src/phFriNfc_LlcpUtils.h b/src/phFriNfc_LlcpUtils.h new file mode 100644 index 0000000..7d789e5 --- /dev/null +++ b/src/phFriNfc_LlcpUtils.h @@ -0,0 +1,132 @@ +/* + * Copyright (C) 2010 NXP Semiconductors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * \file phFriNfc_LlcpUtils.h + * \brief NFC LLCP utils + * + * Project: NFC-FRI + * + */ + +#ifndef PHFRINFC_LLCPUTILS_H +#define PHFRINFC_LLCPUTILS_H + +/*include files*/ +#include <phNfcHalTypes.h> +#include <phNfcTypes.h> +#include <phNfcStatus.h> +#include <phFriNfc.h> +#include <phFriNfc_Llcp.h> + +/** + * \name NFC Forum Logical Link Control Protocol Utils + * + * File: \ref phFriNfc_LlcpUtils.h + * + */ + +/** + * UTIL_FIFO_BUFFER - A Cyclic FIFO buffer + * If pIn == pOut the buffer is empty. + */ +typedef struct UTIL_FIFO_BUFFER +{ + uint8_t *pBuffStart; /* Points to first valid location in buffer */ + uint8_t *pBuffEnd; /* Points to last valid location in buffer */ + volatile uint8_t *pIn; /* Points to 1 before where the next TU1 will enter buffer */ + volatile uint8_t *pOut; /* Points to 1 before where the next TU1 will leave buffer */ + volatile bool_t bFull; /* TRUE if buffer is full */ +}UTIL_FIFO_BUFFER, *P_UTIL_FIFO_BUFFER; + + +/** \defgroup grp_fri_nfc_llcp NFC Forum Logical Link Control Protocol Component + * + * TODO + * + */ + +NFCSTATUS phFriNfc_Llcp_DecodeTLV( phNfc_sData_t *psRawData, + uint32_t *pOffset, + uint8_t *pType, + phNfc_sData_t *psValueBuffer ); + +NFCSTATUS phFriNfc_Llcp_EncodeTLV( phNfc_sData_t *psValueBuffer, + uint32_t *pOffset, + uint8_t type, + uint8_t length, + uint8_t *pValue); + +void phFriNfc_Llcp_EncodeMIUX(uint16_t* pMiux, + uint16_t* pMiuxEncoded); + +void phFriNfc_Llcp_EncodeRW(uint8_t *pRw); + +/** + * Initializes a Fifo Cyclic Buffer to point to some allocated memory. + */ +void phFriNfc_Llcp_CyclicFifoInit(P_UTIL_FIFO_BUFFER sUtilFifo, + const uint8_t *pBuffStart, + uint32_t buffLength); + +/** + * Clears the Fifo Cyclic Buffer - loosing any data that was in it. + */ +void phFriNfc_Llcp_CyclicFifoClear(P_UTIL_FIFO_BUFFER sUtilFifo); + + +/** + * Attempts to write dataLength bytes to the specified Fifo Cyclic Buffer. + */ +uint32_t phFriNfc_Llcp_CyclicFifoWrite(P_UTIL_FIFO_BUFFER sUtilFifo, + uint8_t *pData, + uint32_t dataLength); + +/** + * Attempts to read dataLength bytes from the specified Fifo Cyclic Buffer. + */ +uint32_t phFriNfc_Llcp_CyclicFifoFifoRead(P_UTIL_FIFO_BUFFER sUtilFifo, + uint8_t *pBuffer, + uint32_t dataLength); + +/** + * Returns the number of bytes currently stored in Fifo Cyclic Buffer. + */ +uint32_t phFriNfc_Llcp_CyclicFifoUsage(P_UTIL_FIFO_BUFFER sUtilFifo); + +/** + * Returns the available room for writing in Fifo Cyclic Buffer. + */ +uint32_t phFriNfc_Llcp_CyclicFifoAvailable(P_UTIL_FIFO_BUFFER sUtilFifo); + +uint32_t phFriNfc_Llcp_Header2Buffer( phFriNfc_Llcp_sPacketHeader_t *psHeader, + uint8_t *pBuffer, + uint32_t nOffset ); + +uint32_t phFriNfc_Llcp_Sequence2Buffer( phFriNfc_Llcp_sPacketSequence_t *psSequence, + uint8_t *pBuffer, + uint32_t nOffset ); + +uint32_t phFriNfc_Llcp_Buffer2Header( uint8_t *pBuffer, + uint32_t nOffset, + phFriNfc_Llcp_sPacketHeader_t *psHeader ); + +uint32_t phFriNfc_Llcp_Buffer2Sequence( uint8_t *pBuffer, + uint32_t nOffset, + phFriNfc_Llcp_sPacketSequence_t *psSequence ); + + +#endif /* PHFRINFC_LLCPUTILS_H */ |