Reintroduce oddparity() function used by project based on libnfc but in nfc-utils.[ch] to prevent from exporting them in API.

This commit is contained in:
Romuald Conty 2010-09-06 10:02:19 +00:00
parent 190b52c4cd
commit 18d31cd672
2 changed files with 18 additions and 1 deletions

View file

@ -21,6 +21,21 @@ static const byte_t OddParity[256] = {
1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1
}; };
byte_t oddparity(const byte_t bt)
{
return OddParity[bt];
}
void oddparity_bytes_ts(const byte_t* pbtData, const size_t szLen, byte_t* pbtPar)
{
size_t szByteNr;
// Calculate the parity bits for the command
for (szByteNr=0; szByteNr<szLen; szByteNr++)
{
pbtPar[szByteNr] = OddParity[pbtData[szByteNr]];
}
}
void print_hex(const byte_t* pbtData, const size_t szBytes) void print_hex(const byte_t* pbtData, const size_t szBytes)
{ {
size_t szPos; size_t szPos;

View file

@ -18,7 +18,7 @@
* *
* *
* @file nfc-utils.h * @file nfc-utils.h
* @brief * @brief Provide some examples shared functions like print, parity calculation, options parsing.
*/ */
#ifndef _EXAMPLES_NFC_UTILS_H_ #ifndef _EXAMPLES_NFC_UTILS_H_
@ -27,6 +27,8 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
byte_t oddparity(const byte_t bt);
void oddparity_byte_ts(const byte_t* pbtData, const size_t szLen, byte_t* pbtPar);
void print_hex(const byte_t* pbtData, const size_t szLen); void print_hex(const byte_t* pbtData, const size_t szLen);
void print_hex_bits(const byte_t* pbtData, const size_t szBits); void print_hex_bits(const byte_t* pbtData, const size_t szBits);