diff --git a/configure.ac b/configure.ac
index da0d2df..47e3279 100644
--- a/configure.ac
+++ b/configure.ac
@@ -13,7 +13,7 @@ AC_PATH_PROG(PKG_CONFIG, pkg-config)
# Checks for header files.
AC_HEADER_STDC
-AC_CHECK_HEADERS([stdlib.h])
+AC_CHECK_HEADERS([stdlib.h stdint.h])
# libusb
@@ -40,10 +40,11 @@ AC_MSG_RESULT($enable_debug)
if test "x$enable_debug" = "xyes"
then
- CFLAGS="$CFLAGS -g -Wall -DDEBUG"
+ CFLAGS="$CFLAGS -g -Wall -DDEBUG -pedantic"
fi
AC_SUBST([DEBUG_CFLAGS])
+CFLAGS="$CFLAGS -std=c99"
AC_CONFIG_FILES([
Makefile
diff --git a/src/anticol.c b/src/anticol.c
index e4e4e34..f05908f 100644
--- a/src/anticol.c
+++ b/src/anticol.c
@@ -20,16 +20,18 @@ along with this program. If not, see .
#include
#include
+#include
#include
+
#include "libnfc.h"
#define SAK_FLAG_ATS_SUPPORTED 0x20
static byte abtRx[MAX_FRAME_LEN];
-static ui32 uiRxBits;
-static ui32 uiRxLen;
+static uint32_t uiRxBits;
+static uint32_t uiRxLen;
static byte abtUid[10];
-static ui32 uiUidLen = 4;
+static uint32_t uiUidLen = 4;
static dev_info* pdi;
// ISO14443A Anti-Collision Commands
@@ -39,7 +41,7 @@ byte abtSelectTag [9] = { 0x93,0x70,0x00,0x00,0x00,0x00,0x00,0x00,0x00 };
byte abtRats [4] = { 0xe0,0x50,0xbc,0xa5 };
byte abtHalt [4] = { 0x50,0x00,0x57,0xcd };
-bool transmit_bits(const byte* pbtTx, const ui32 uiTxBits)
+bool transmit_bits(const byte* pbtTx, const uint32_t uiTxBits)
{
// Show transmitted command
printf("R: "); print_hex_bits(pbtTx,uiTxBits);
@@ -55,7 +57,7 @@ bool transmit_bits(const byte* pbtTx, const ui32 uiTxBits)
}
-bool transmit_bytes(const byte* pbtTx, const ui32 uiTxLen)
+bool transmit_bytes(const byte* pbtTx, const uint32_t uiTxLen)
{
// Show transmitted command
printf("R: "); print_hex(pbtTx,uiTxLen);
diff --git a/src/bitutils.c b/src/bitutils.c
index 5fda4b1..6ce6e19 100644
--- a/src/bitutils.c
+++ b/src/bitutils.c
@@ -19,6 +19,7 @@ along with this program. If not, see .
*/
#include
+
#include "bitutils.h"
const static byte OddParity[256] = {
@@ -68,9 +69,9 @@ byte oddparity(const byte bt)
return OddParity[bt];
}
-void oddparity_bytes(const byte* pbtData, const ui32 uiLen, byte* pbtPar)
+void oddparity_bytes(const byte* pbtData, const uint32_t uiLen, byte* pbtPar)
{
- ui32 uiByteNr;
+ uint32_t uiByteNr;
// Calculate the parity bits for the command
for (uiByteNr=0; uiByteNr>8)+((ui32N&0xFF000000)>>24));
}
-ui64 swap_endian64(const void* pui64)
+uint64_t swap_endian64(const void* pui64)
{
- ui64 ui64N = *((ui64*)pui64);
+ uint64_t ui64N = *((uint64_t *)pui64);
return (((ui64N&0xFF)<<56)+((ui64N&0xFF00)<<40)+((ui64N&0xFF0000)<<24)+((ui64N&0xFF000000)<<8)+((ui64N&0xFF00000000ull)>>8)+((ui64N&0xFF0000000000ull)>>24)+((ui64N&0xFF000000000000ull)>>40)+((ui64N&0xFF00000000000000ull)>>56));
}
-void append_iso14443a_crc(byte* pbtData, ui32 uiLen)
+void append_iso14443a_crc(byte* pbtData, uint32_t uiLen)
{
byte bt;
- ui32 wCrc = 0x6363;
+ uint32_t wCrc = 0x6363;
do {
bt = *pbtData++;
bt = (bt^(byte)(wCrc & 0x00FF));
bt = (bt^(bt<<4));
- wCrc = (wCrc >> 8)^((ui32)bt << 8)^((ui32)bt<<3)^((ui32)bt>>4);
+ wCrc = (wCrc >> 8)^((uint32_t)bt << 8)^((uint32_t)bt<<3)^((uint32_t)bt>>4);
} while (--uiLen);
*pbtData++ = (byte) (wCrc & 0xFF);
*pbtData = (byte) ((wCrc >> 8) & 0xFF);
}
-void print_hex(const byte* pbtData, const ui32 uiBytes)
+void print_hex(const byte* pbtData, const uint32_t uiBytes)
{
- ui32 uiPos;
+ uint32_t uiPos;
for (uiPos=0; uiPos < uiBytes; uiPos++)
{
@@ -146,10 +147,10 @@ void print_hex(const byte* pbtData, const ui32 uiBytes)
printf("\n");
}
-void print_hex_bits(const byte* pbtData, const ui32 uiBits)
+void print_hex_bits(const byte* pbtData, const uint32_t uiBits)
{
- ui32 uiPos;
- ui32 uiBytes = uiBits/8;
+ uint32_t uiPos;
+ uint32_t uiBytes = uiBits/8;
for (uiPos=0; uiPos < uiBytes; uiPos++)
{
@@ -162,10 +163,10 @@ void print_hex_bits(const byte* pbtData, const ui32 uiBits)
printf("\n");
}
-void print_hex_par(const byte* pbtData, const ui32 uiBits, const byte* pbtDataPar)
+void print_hex_par(const byte* pbtData, const uint32_t uiBits, const byte* pbtDataPar)
{
- ui32 uiPos;
- ui32 uiBytes = uiBits/8;
+ uint32_t uiPos;
+ uint32_t uiBytes = uiBits/8;
for (uiPos=0; uiPos < uiBytes; uiPos++)
{
diff --git a/src/bitutils.h b/src/bitutils.h
index 312c968..8cd6d97 100644
--- a/src/bitutils.h
+++ b/src/bitutils.h
@@ -21,24 +21,26 @@ along with this program. If not, see .
#ifndef _LIBNFC_BITUTILS_H_
#define _LIBNFC_BITUTILS_H_
+#include
+
#include "defines.h"
byte oddparity(const byte bt);
-void oddparity_bytes(const byte* pbtData, const ui32 uiLen, byte* pbtPar);
+void oddparity_bytes(const byte* pbtData, const uint32_t uiLen, byte* pbtPar);
byte mirror(byte bt);
-ui32 mirror32(ui32 ui32Bits);
-ui64 mirror64(ui64 ui64Bits);
-void mirror_bytes(byte *pbts, ui32 uiLen);
+uint32_t mirror32(uint32_t ui32Bits);
+uint64_t mirror64(uint64_t ui64Bits);
+void mirror_bytes(byte *pbts, uint32_t uiLen);
-ui32 swap_endian32(const void* pui32);
-ui64 swap_endian64(const void* pui64);
+uint32_t swap_endian32(const void* pui32);
+uint64_t swap_endian64(const void* pui64);
-void append_iso14443a_crc(byte* pbtData, ui32 uiLen);
+void append_iso14443a_crc(byte* pbtData, uint32_t uiLen);
-void print_hex(const byte* pbtData, const ui32 uiLen);
-void print_hex_bits(const byte* pbtData, const ui32 uiBits);
-void print_hex_par(const byte* pbtData, const ui32 uiBits, const byte* pbtDataPar);
+void print_hex(const byte* pbtData, const uint32_t uiLen);
+void print_hex_bits(const byte* pbtData, const uint32_t uiBits);
+void print_hex_par(const byte* pbtData, const uint32_t uiBits, const byte* pbtDataPar);
#endif // _LIBNFC_BITUTILS_H_
diff --git a/src/defines.h b/src/defines.h
index 2c63865..cddea0e 100644
--- a/src/defines.h
+++ b/src/defines.h
@@ -24,14 +24,7 @@ along with this program. If not, see .
// #define DEBUG
typedef unsigned char byte;
-typedef unsigned char ui8;
-typedef unsigned short ui16;
-typedef unsigned int ui32;
-typedef unsigned long long ui64;
typedef unsigned long ulong;
-typedef char i8;
-typedef short i16;
-typedef int i32;
#define null 0
diff --git a/src/dev_acr122.c b/src/dev_acr122.c
index cb2495a..18e6181 100644
--- a/src/dev_acr122.c
+++ b/src/dev_acr122.c
@@ -57,15 +57,15 @@ static ulong ulRxBufLen;
static byte abtGetFw[5] = { 0xFF,0x00,0x48,0x00,0x00 };
static byte abtLed[9] = { 0xFF,0x00,0x40,0x05,0x04,0x00,0x00,0x00,0x00 };
-dev_info* dev_acr122_connect(const ui32 uiIndex)
+dev_info* dev_acr122_connect(const uint32_t uiIndex)
{
char* pacReaders[MAX_READERS];
char acList[256+64*MAX_READERS];
ulong ulListLen = sizeof(acList);
- ui32 uiPos;
- ui32 uiReaderCount;
- ui32 uiReader;
- ui32 uiDevIndex;
+ uint32_t uiPos;
+ uint32_t uiReaderCount;
+ uint32_t uiReader;
+ uint32_t uiDevIndex;
dev_info* pdi;
dev_spec_acr122* pdsa;
dev_spec_acr122 dsa;
@@ -172,7 +172,7 @@ void dev_acr122_disconnect(dev_info* pdi)
free(pdi);
}
-bool dev_acr122_transceive(const dev_spec ds, const byte* pbtTx, const ui32 uiTxLen, byte* pbtRx, ui32* puiRxLen)
+bool dev_acr122_transceive(const dev_spec ds, const byte* pbtTx, const uint32_t uiTxLen, byte* pbtRx, uint32_t* puiRxLen)
{
dev_spec_acr122* pdsa = (dev_spec_acr122*)ds;
@@ -231,7 +231,7 @@ bool dev_acr122_transceive(const dev_spec ds, const byte* pbtTx, const ui32 uiTx
char* dev_acr122_firmware(const dev_spec ds)
{
- ui32 uiResult;
+ uint32_t uiResult;
dev_spec_acr122* pdsa = (dev_spec_acr122*)ds;
static char abtFw[11];
diff --git a/src/dev_acr122.h b/src/dev_acr122.h
index 95c763d..02e1b50 100644
--- a/src/dev_acr122.h
+++ b/src/dev_acr122.h
@@ -21,15 +21,17 @@ along with this program. If not, see .
#ifndef _LIBNFC_DEV_ACR122_H_
#define _LIBNFC_DEV_ACR122_H_
+#include
+
#include "defines.h"
#include "types.h"
// Functions used by developer to handle connection to this device
-dev_info* dev_acr122_connect(const ui32 uiIndex);
+dev_info* dev_acr122_connect(const uint32_t uiIndex);
void dev_acr122_disconnect(dev_info* pdi);
// Callback function used by libnfc to transmit commands to the PN53X chip
-bool dev_acr122_transceive(const dev_spec ds, const byte* pbtTx, const ui32 uiTxLen, byte* pbtRx, ui32* puiRxLen);
+bool dev_acr122_transceive(const dev_spec ds, const byte* pbtTx, const uint32_t uiTxLen, byte* pbtRx, uint32_t* puiRxLen);
// Various additional features this device supports
char* dev_acr122_firmware(const dev_spec ds);
diff --git a/src/dev_pn531.c b/src/dev_pn531.c
index a6d3bd0..67791e9 100644
--- a/src/dev_pn531.c
+++ b/src/dev_pn531.c
@@ -34,15 +34,15 @@ static char buffer[BUFFER_LENGTH] = { 0x00, 0x00, 0xff }; // Every packet must s
typedef struct {
usb_dev_handle* pudh;
- ui32 uiEndPointIn;
- ui32 uiEndPointOut;
+ uint32_t uiEndPointIn;
+ uint32_t uiEndPointOut;
} dev_spec_pn531;
// Find transfer endpoints for bulk transfers
void get_end_points(struct usb_device *dev, dev_spec_pn531* pdsp)
{
- ui32 uiIndex;
- ui32 uiEndPoint;
+ uint32_t uiIndex;
+ uint32_t uiEndPoint;
struct usb_interface_descriptor* puid = dev->config->interface->altsetting;
// 3 Endpoints maximum: Interrupt In, Bulk In, Bulk Out
@@ -74,7 +74,7 @@ void get_end_points(struct usb_device *dev, dev_spec_pn531* pdsp)
}
}
-dev_info* dev_pn531_connect(const ui32 uiIndex)
+dev_info* dev_pn531_connect(const uint32_t uiIndex)
{
int idvendor = 0x04CC;
int idproduct = 0x0531;
@@ -83,7 +83,7 @@ dev_info* dev_pn531_connect(const ui32 uiIndex)
dev_info* pdi = INVALID_DEVICE_INFO;
dev_spec_pn531* pdsp;
dev_spec_pn531 dsp;
- ui32 uiDevIndex;
+ uint32_t uiDevIndex;
dsp.uiEndPointIn = 0;
dsp.uiEndPointOut = 0;
@@ -164,9 +164,9 @@ void dev_pn531_disconnect(dev_info* pdi)
free(pdi);
}
-bool dev_pn531_transceive(const dev_spec ds, const byte* pbtTx, const ui32 uiTxLen, byte* pbtRx, ui32* puiRxLen)
+bool dev_pn531_transceive(const dev_spec ds, const byte* pbtTx, const uint32_t uiTxLen, byte* pbtRx, uint32_t* puiRxLen)
{
- ui32 uiPos = 0;
+ uint32_t uiPos = 0;
int ret = 0;
char buf[BUFFER_LENGTH];
dev_spec_pn531* pdsp = (dev_spec_pn531*)ds;
diff --git a/src/dev_pn531.h b/src/dev_pn531.h
index 65419c4..33ab49e 100644
--- a/src/dev_pn531.h
+++ b/src/dev_pn531.h
@@ -21,15 +21,17 @@ along with this program. If not, see .
#ifndef _LIBNFC_DEV_PN531_H_
#define _LIBNFC_DEV_PN531_H_
+#include
+
#include "defines.h"
#include "types.h"
// Functions used by developer to handle connection to this device
-dev_info* dev_pn531_connect(const ui32 uiIndex);
+dev_info* dev_pn531_connect(const uint32_t uiIndex);
void dev_pn531_disconnect(dev_info* pdi);
// Callback function used by libnfc to transmit commands to the PN53X chip
-bool dev_pn531_transceive(const dev_spec ds, const byte* pbtTx, const ui32 uiTxLen, byte* pbtRx, ui32* puiRxLen);
+bool dev_pn531_transceive(const dev_spec ds, const byte* pbtTx, const uint32_t uiTxLen, byte* pbtRx, uint32_t* puiRxLen);
#endif // _LIBNFC_DEV_PN531_H_
diff --git a/src/emulate.c b/src/emulate.c
index 5153ba9..134912a 100644
--- a/src/emulate.c
+++ b/src/emulate.c
@@ -20,11 +20,13 @@ along with this program. If not, see .
#include
#include
+#include
#include
+
#include "libnfc.h"
static byte abtRecv[MAX_FRAME_LEN];
-static ui32 uiRecvBits;
+static uint32_t uiRecvBits;
static dev_info* pdi;
// ISO14443A Anti-Collision response
@@ -35,7 +37,7 @@ byte abtSak [9] = { 0x08,0xb6,0xdd };
int main(int argc, const char* argv[])
{
byte* pbtTx = null;
- ui32 uiTxBits;
+ uint32_t uiTxBits;
// Try to open the NFC reader
pdi = nfc_connect();
diff --git a/src/libnfc.c b/src/libnfc.c
index 8d87140..f83dcd6 100644
--- a/src/libnfc.c
+++ b/src/libnfc.c
@@ -88,9 +88,9 @@ byte pncmd_exchange_raw_data [266] = { 0xD4,0x42 };
// Global buffers used for communication with the PN53X chip
#define MAX_FRAME_LEN 264
static byte abtRx[MAX_FRAME_LEN];
-static ui32 uiRxLen;
+static uint32_t uiRxLen;
-bool pn53x_transceive(const dev_info* pdi, const byte* pbtTx, const ui32 uiTxLen)
+bool pn53x_transceive(const dev_info* pdi, const byte* pbtTx, const uint32_t uiTxLen)
{
// Reset the receiving buffer
uiRxLen = MAX_FRAME_LEN;
@@ -105,17 +105,17 @@ bool pn53x_transceive(const dev_info* pdi, const byte* pbtTx, const ui32 uiTxLen
return true;
}
-byte pn53x_get_reg(const dev_info* pdi, ui16 ui16Reg)
+byte pn53x_get_reg(const dev_info* pdi, uint16_t ui16Reg)
{
- ui8 ui8Value;
- ui32 uiValueLen = 1;
+ uint8_t ui8Value;
+ uint32_t uiValueLen = 1;
pncmd_get_register[2] = ui16Reg >> 8;
pncmd_get_register[3] = ui16Reg & 0xff;
pdi->pdc->transceive(pdi->ds,pncmd_get_register,4,&ui8Value,&uiValueLen);
return ui8Value;
}
-bool pn53x_set_reg(const dev_info* pdi, ui16 ui16Reg, ui8 ui8SybmolMask, ui8 ui8Value)
+bool pn53x_set_reg(const dev_info* pdi, uint16_t ui16Reg, uint8_t ui8SybmolMask, uint8_t ui8Value)
{
pncmd_set_register[2] = ui16Reg >> 8;
pncmd_set_register[3] = ui16Reg & 0xff;
@@ -123,13 +123,13 @@ bool pn53x_set_reg(const dev_info* pdi, ui16 ui16Reg, ui8 ui8SybmolMask, ui8 ui8
return pdi->pdc->transceive(pdi->ds,pncmd_set_register,5,null,null);
}
-bool pn53x_set_parameters(const dev_info* pdi, ui8 ui8Value)
+bool pn53x_set_parameters(const dev_info* pdi, uint8_t ui8Value)
{
pncmd_set_parameters[2] = ui8Value;
return pdi->pdc->transceive(pdi->ds,pncmd_set_parameters,3,null,null);
}
-bool pn53x_set_tx_bits(const dev_info* pdi, ui8 ui8Bits)
+bool pn53x_set_tx_bits(const dev_info* pdi, uint8_t ui8Bits)
{
// Test if we need to update the transmission bits register setting
if (pdi->ui8TxBits != ui8Bits)
@@ -143,13 +143,13 @@ bool pn53x_set_tx_bits(const dev_info* pdi, ui8 ui8Bits)
return true;
}
-bool pn53x_wrap_frame(const byte* pbtTx, const ui32 uiTxBits, const byte* pbtTxPar, byte* pbtFrame, ui32* puiFrameBits)
+bool pn53x_wrap_frame(const byte* pbtTx, const uint32_t uiTxBits, const byte* pbtTxPar, byte* pbtFrame, uint32_t* puiFrameBits)
{
byte btFrame;
byte btData;
- ui32 uiBitPos;
- ui32 uiDataPos = 0;
- ui32 uiBitsLeft = uiTxBits;
+ uint32_t uiBitPos;
+ uint32_t uiDataPos = 0;
+ uint32_t uiBitsLeft = uiTxBits;
// Make sure we should frame at least something
if (uiBitsLeft == 0) return false;
@@ -199,14 +199,14 @@ bool pn53x_wrap_frame(const byte* pbtTx, const ui32 uiTxBits, const byte* pbtTxP
}
}
-bool pn53x_unwrap_frame(const byte* pbtFrame, const ui32 uiFrameBits, byte* pbtRx, ui32* puiRxBits, byte* pbtRxPar)
+bool pn53x_unwrap_frame(const byte* pbtFrame, const uint32_t uiFrameBits, byte* pbtRx, uint32_t* puiRxBits, byte* pbtRxPar)
{
byte btFrame;
byte btData;
- ui8 uiBitPos;
- ui32 uiDataPos = 0;
+ uint8_t uiBitPos;
+ uint32_t uiDataPos = 0;
byte* pbtFramePos = (byte*) pbtFrame;
- ui32 uiBitsLeft = uiFrameBits;
+ uint32_t uiBitsLeft = uiFrameBits;
// Make sure we should frame at least something
if (uiBitsLeft == 0) return false;
@@ -248,9 +248,9 @@ bool pn53x_unwrap_frame(const byte* pbtFrame, const ui32 uiFrameBits, byte* pbtR
dev_info* nfc_connect()
{
dev_info* pdi;
- ui32 uiDev;
+ uint32_t uiDev;
byte abtFw[4];
- ui32 uiFwLen = sizeof(abtFw);
+ uint32_t uiFwLen = sizeof(abtFw);
// Search through the device list for an available device
for (uiDev=0; uiDevbActive) return false;
@@ -480,11 +480,11 @@ bool nfc_reader_deselect(const dev_info* pdi)
return (pdi->pdc->transceive(pdi->ds,pncmd_reader_deselect,3,null,null));
}
-bool nfc_reader_transceive_bits(const dev_info* pdi, const byte* pbtTx, const ui32 uiTxBits, const byte* pbtTxPar, byte* pbtRx, ui32* puiRxBits, byte* pbtRxPar)
+bool nfc_reader_transceive_bits(const dev_info* pdi, const byte* pbtTx, const uint32_t uiTxBits, const byte* pbtTxPar, byte* pbtRx, uint32_t* puiRxBits, byte* pbtRxPar)
{
- ui32 uiFrameBits = 0;
- ui32 uiFrameBytes = 0;
- ui8 ui8Bits = 0;
+ uint32_t uiFrameBits = 0;
+ uint32_t uiFrameBytes = 0;
+ uint8_t ui8Bits = 0;
// Check if we should prepare the parity bits ourself
if (!pdi->bPar)
@@ -534,7 +534,7 @@ bool nfc_reader_transceive_bits(const dev_info* pdi, const byte* pbtTx, const ui
return true;
}
-bool nfc_reader_transceive_bytes(const dev_info* pdi, const byte* pbtTx, const ui32 uiTxLen, byte* pbtRx, ui32* puiRxLen)
+bool nfc_reader_transceive_bytes(const dev_info* pdi, const byte* pbtTx, const uint32_t uiTxLen, byte* pbtRx, uint32_t* puiRxLen)
{
// We can not just send bytes without parity if while the PN53X expects we handled them
if (!pdi->bPar) return false;
@@ -559,9 +559,9 @@ bool nfc_reader_transceive_bytes(const dev_info* pdi, const byte* pbtTx, const u
return true;
}
-bool nfc_reader_mifare_cmd(const dev_info* pdi, const mifare_cmd mc, const ui8 ui8Block, mifare_param* pmp)
+bool nfc_reader_mifare_cmd(const dev_info* pdi, const mifare_cmd mc, const uint8_t ui8Block, mifare_param* pmp)
{
- ui32 uiParamLen;
+ uint32_t uiParamLen;
// Make sure we are dealing with a active device
if (!pdi->bActive) return false;
@@ -615,9 +615,9 @@ bool nfc_reader_mifare_cmd(const dev_info* pdi, const mifare_cmd mc, const ui8 u
return true;
}
-bool nfc_target_init(const dev_info* pdi, byte* pbtRx, ui32* puiRxBits)
+bool nfc_target_init(const dev_info* pdi, byte* pbtRx, uint32_t* puiRxBits)
{
- ui8 ui8Bits;
+ uint8_t ui8Bits;
// Save the current configuration settings
bool bCrc = pdi->bCrc;
@@ -665,10 +665,10 @@ bool nfc_target_init(const dev_info* pdi, byte* pbtRx, ui32* puiRxBits)
return true;
}
-bool nfc_target_receive_bits(const dev_info* pdi, byte* pbtRx, ui32* puiRxBits, byte* pbtRxPar)
+bool nfc_target_receive_bits(const dev_info* pdi, byte* pbtRx, uint32_t* puiRxBits, byte* pbtRxPar)
{
- ui32 uiFrameBits;
- ui8 ui8Bits;
+ uint32_t uiFrameBits;
+ uint8_t ui8Bits;
// Try to gather a received frame from the reader
if (!pn53x_transceive(pdi,pncmd_target_receive,2)) return false;
@@ -695,7 +695,7 @@ bool nfc_target_receive_bits(const dev_info* pdi, byte* pbtRx, ui32* puiRxBits,
return true;
}
-bool nfc_target_receive_bytes(const dev_info* pdi, byte* pbtRx, ui32* puiRxLen)
+bool nfc_target_receive_bytes(const dev_info* pdi, byte* pbtRx, uint32_t* puiRxLen)
{
// Try to gather a received frame from the reader
if (!pn53x_transceive(pdi,pncmd_target_receive,2)) return false;
@@ -710,11 +710,11 @@ bool nfc_target_receive_bytes(const dev_info* pdi, byte* pbtRx, ui32* puiRxLen)
return true;
}
-bool nfc_target_send_bits(const dev_info* pdi, const byte* pbtTx, const ui32 uiTxBits, const byte* pbtTxPar)
+bool nfc_target_send_bits(const dev_info* pdi, const byte* pbtTx, const uint32_t uiTxBits, const byte* pbtTxPar)
{
- ui32 uiFrameBits = 0;
- ui32 uiFrameBytes = 0;
- ui8 ui8Bits = 0;
+ uint32_t uiFrameBits = 0;
+ uint32_t uiFrameBytes = 0;
+ uint8_t ui8Bits = 0;
// Check if we should prepare the parity bits ourself
if (!pdi->bPar)
@@ -745,7 +745,7 @@ bool nfc_target_send_bits(const dev_info* pdi, const byte* pbtTx, const ui32 uiT
}
-bool nfc_target_send_bytes(const dev_info* pdi, const byte* pbtTx, const ui32 uiTxLen)
+bool nfc_target_send_bytes(const dev_info* pdi, const byte* pbtTx, const uint32_t uiTxLen)
{
// We can not just send bytes without parity if while the PN53X expects we handled them
if (!pdi->bPar) return false;
diff --git a/src/libnfc.h b/src/libnfc.h
index f122137..04a50e9 100644
--- a/src/libnfc.h
+++ b/src/libnfc.h
@@ -21,6 +21,8 @@ along with this program. If not, see .
#ifndef _LIBNFC_H_
#define _LIBNFC_H_
+#include
+
#include "defines.h"
#include "types.h"
#include "bitutils.h"
@@ -31,17 +33,17 @@ void nfc_disconnect(dev_info* pdi);
bool nfc_configure(dev_info* pdi, const dev_config_option dco, const bool bEnable);
bool nfc_reader_init(const dev_info* pdi);
-bool nfc_reader_select(const dev_info* pdi, const init_modulation im, const byte* pbtInitData, const ui32 uiInitDataLen, tag_info* pti);
+bool nfc_reader_select(const dev_info* pdi, const init_modulation im, const byte* pbtInitData, const uint32_t uiInitDataLen, tag_info* pti);
bool nfc_reader_deselect(const dev_info* pdi);
-bool nfc_reader_transceive_bits(const dev_info* pdi, const byte* pbtTx, const ui32 uiTxBits, const byte* pbtTxPar, byte* pbtRx, ui32* puiRxBits, byte* pbtRxPar);
-bool nfc_reader_transceive_bytes(const dev_info* pdi, const byte* pbtTx, const ui32 uiTxLen, byte* pbtRx, ui32* puiRxLen);
-bool nfc_reader_mifare_cmd(const dev_info* pdi, const mifare_cmd mc, const ui8 ui8Block, mifare_param* pmp);
+bool nfc_reader_transceive_bits(const dev_info* pdi, const byte* pbtTx, const uint32_t uiTxBits, const byte* pbtTxPar, byte* pbtRx, uint32_t* puiRxBits, byte* pbtRxPar);
+bool nfc_reader_transceive_bytes(const dev_info* pdi, const byte* pbtTx, const uint32_t uiTxLen, byte* pbtRx, uint32_t* puiRxLen);
+bool nfc_reader_mifare_cmd(const dev_info* pdi, const mifare_cmd mc, const uint8_t ui8Block, mifare_param* pmp);
-bool nfc_target_init(const dev_info* pdi, byte* pbtRx, ui32* puiRxBits);
-bool nfc_target_receive_bits(const dev_info* pdi, byte* pbtRx, ui32* puiRxBits, byte* pbtRxPar);
-bool nfc_target_receive_bytes(const dev_info* pdi, byte* pbtRx, ui32* puiRxLen);
-bool nfc_target_send_bits(const dev_info* pdi, const byte* pbtTx, const ui32 uiTxBits, const byte* pbtTxPar);
-bool nfc_target_send_bytes(const dev_info* pdi, const byte* pbtTx, const ui32 uiTxLen);
+bool nfc_target_init(const dev_info* pdi, byte* pbtRx, uint32_t* puiRxBits);
+bool nfc_target_receive_bits(const dev_info* pdi, byte* pbtRx, uint32_t* puiRxBits, byte* pbtRxPar);
+bool nfc_target_receive_bytes(const dev_info* pdi, byte* pbtRx, uint32_t* puiRxLen);
+bool nfc_target_send_bits(const dev_info* pdi, const byte* pbtTx, const uint32_t uiTxBits, const byte* pbtTxPar);
+bool nfc_target_send_bytes(const dev_info* pdi, const byte* pbtTx, const uint32_t uiTxLen);
#endif // _LIBNFC_H_
diff --git a/src/mftool.c b/src/mftool.c
index fb390d2..39c2229 100644
--- a/src/mftool.c
+++ b/src/mftool.c
@@ -20,6 +20,7 @@ along with this program. If not, see .
#include
#include
+#include
#include
#include
@@ -32,21 +33,21 @@ static mifare_param mp;
static mifare_tag mtKeys;
static mifare_tag mtDump;
static bool bUseKeyA;
-static ui32 uiBlocks;
+static uint32_t uiBlocks;
-bool is_first_block(ui32 uiBlock)
+bool is_first_block(uint32_t uiBlock)
{
// Test if we are in the small or big sectors
if (uiBlock < 128) return ((uiBlock)%4 == 0); else return ((uiBlock)%16 == 0);
}
-bool is_trailer_block(ui32 uiBlock)
+bool is_trailer_block(uint32_t uiBlock)
{
// Test if we are in the small or big sectors
if (uiBlock < 128) return ((uiBlock+1)%4 == 0); else return ((uiBlock+1)%16 == 0);
}
-ui32 get_trailer_block(ui32 uiFirstBlock)
+uint32_t get_trailer_block(uint32_t uiFirstBlock)
{
// Test if we are in the small or big sectors
if (uiFirstBlock<128) return uiFirstBlock+3; else return uiFirstBlock+15;
@@ -54,7 +55,7 @@ ui32 get_trailer_block(ui32 uiFirstBlock)
bool read_card()
{
- i32 iBlock;
+ int32_t iBlock;
mifare_cmd mc;
bool bFailure = false;
@@ -136,8 +137,8 @@ bool read_card()
bool write_card()
{
- ui32 uiBlock;
- ui32 uiTrailerBlock;
+ uint32_t uiBlock;
+ uint32_t uiTrailerBlock;
bool bFailure = false;
mifare_cmd mc;
diff --git a/src/relay.c b/src/relay.c
index 65c1566..a942cc7 100644
--- a/src/relay.c
+++ b/src/relay.c
@@ -20,15 +20,17 @@ along with this program. If not, see .
#include
#include
+#include
#include
+
#include "libnfc.h"
static byte abtReaderRx[MAX_FRAME_LEN];
static byte abtReaderRxPar[MAX_FRAME_LEN];
-static ui32 uiReaderRxBits;
+static uint32_t uiReaderRxBits;
static byte abtTagRx[MAX_FRAME_LEN];
static byte abtTagRxPar[MAX_FRAME_LEN];
-static ui32 uiTagRxBits;
+static uint32_t uiTagRxBits;
static dev_info* pdiReader;
static dev_info* pdiTag;
diff --git a/src/types.h b/src/types.h
index ab3c02d..e0b1b28 100644
--- a/src/types.h
+++ b/src/types.h
@@ -21,6 +21,8 @@ along with this program. If not, see .
#ifndef _LIBNFC_TYPES_H_
#define _LIBNFC_TYPES_H_
+#include
+
#include "defines.h"
// Compiler directive, set struct alignment to 1 byte for compatibility
@@ -47,13 +49,13 @@ typedef struct {
bool bActive; // This represents if the PN53X device was initialized succesful
bool bCrc; // Is the crc automaticly added, checked and removed from the frames
bool bPar; // Does the PN53x chip handles parity bits, all parities are handled as data
- ui8 ui8TxBits; // The last tx bits setting, we need to reset this if it does not apply anymore
+ uint8_t ui8TxBits; // The last tx bits setting, we need to reset this if it does not apply anymore
} dev_info;
struct dev_callbacks {
const char* acDriver; // Driver description
- dev_info* (*connect)(const ui32 uiIndex);
- bool (*transceive)(const dev_spec ds, const byte* pbtTx, const ui32 uiTxLen, byte* pbtRx, ui32* puiRxLen);
+ dev_info* (*connect)(const uint32_t uiIndex);
+ bool (*transceive)(const dev_spec ds, const byte* pbtTx, const uint32_t uiTxLen, byte* pbtRx, uint32_t* puiRxLen);
void (*disconnect)(dev_info* pdi);
};
@@ -81,14 +83,14 @@ typedef enum {
typedef struct {
byte abtAtqa[2];
byte btSak;
- ui32 uiUidLen;
+ uint32_t uiUidLen;
byte abtUid[10];
- ui32 uiAtsLen;
+ uint32_t uiAtsLen;
byte abtAts[36];
}tag_info_iso14443a;
typedef struct {
- ui32 uiLen;
+ uint32_t uiLen;
byte btResCode;
byte abtId[8];
byte abtPad[8];
@@ -103,7 +105,7 @@ typedef struct {
byte btParam3;
byte btParam4;
byte btCid;
- ui32 uiInfLen;
+ uint32_t uiInfLen;
byte abtInf[64];
}tag_info_iso14443b;