From f71b49d6c0562a359df06d66669e2e0665167834 Mon Sep 17 00:00:00 2001 From: Oliver Norin Date: Thu, 28 Jan 2021 09:12:42 +0100 Subject: [PATCH 1/4] Fixed conflict issues and set I2C pins --- DFRobot_PN532.cpp | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/DFRobot_PN532.cpp b/DFRobot_PN532.cpp index c7217d9..9a60c57 100644 --- a/DFRobot_PN532.cpp +++ b/DFRobot_PN532.cpp @@ -7,6 +7,10 @@ #endif #include #define PN532_PACKBUFFSIZ 64 + +#define SDA_PIN 21 +#define SCL_PIN 22 + /*! The NTAG's EEPROM memory is organized in pages with 4 bytes per page. NTAG213 variant has 45 pages, NTAG215 variant has 135 pages and NTAG216 variant has 231 pages in total. @@ -364,6 +368,17 @@ bool DFRobot_PN532::writeData(int block, uint8_t data[]) this->readAck(16); return true; } + +const int min(const uint8_t a, const int b) +{ + return (b < a) ? b : a; +} + +const int max(const int a, const int b) +{ + return (b > a) ? b : a; +} + /*! It takes three steps to write a piece of data to a card 1.Read out all the data for one block(every block have 16 data.). @@ -639,7 +654,7 @@ bool DFRobot_PN532_IIC::begin(void) { //nfc Module initialization cmdWrite[1] = 0x01; // normal mode; cmdWrite[2] = 0x14; // timeout 50ms * 20 = 1 second cmdWrite[3] = 0x01; // use IRQ pin! - Wire.begin(); + Wire.begin(SDA_PIN, SCL_PIN); nfcEnable = true; writeCommand(cmdWrite,4); delay(10); From 0a08499b5fe39e891d3e08e8bc58e5ecd202f698 Mon Sep 17 00:00:00 2001 From: Oliver Norin Date: Thu, 11 Feb 2021 12:18:31 +0100 Subject: [PATCH 2/4] Added type cast to min and max method calls --- DFRobot_PN532.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DFRobot_PN532.cpp b/DFRobot_PN532.cpp index c7217d9..6706145 100644 --- a/DFRobot_PN532.cpp +++ b/DFRobot_PN532.cpp @@ -375,7 +375,7 @@ void DFRobot_PN532::writeData(int block, uint8_t index, uint8_t data) { if(!this->nfcEnable) return; - index = max(min(index,16),1); + index = max(min(index, (uint8_t)16), (uint8_t)1); this->readData(block); this->blockData[index - 1] = data; this->writeData(block, this->blockData); From 165e40836cd7f79a4176c3d0e7cfa30fac47fcd2 Mon Sep 17 00:00:00 2001 From: Oliver Norin Date: Thu, 11 Feb 2021 12:20:46 +0100 Subject: [PATCH 3/4] removed changes --- DFRobot_PN532.cpp | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/DFRobot_PN532.cpp b/DFRobot_PN532.cpp index b6f9767..a1be3b3 100644 --- a/DFRobot_PN532.cpp +++ b/DFRobot_PN532.cpp @@ -8,9 +8,6 @@ #include #define PN532_PACKBUFFSIZ 64 -#define SDA_PIN 21 -#define SCL_PIN 22 - /*! The NTAG's EEPROM memory is organized in pages with 4 bytes per page. NTAG213 variant has 45 pages, NTAG215 variant has 135 pages and NTAG216 variant has 231 pages in total. @@ -369,16 +366,6 @@ bool DFRobot_PN532::writeData(int block, uint8_t data[]) return true; } -const int min(const uint8_t a, const int b) -{ - return (b < a) ? b : a; -} - -const int max(const int a, const int b) -{ - return (b > a) ? b : a; -} - /*! It takes three steps to write a piece of data to a card 1.Read out all the data for one block(every block have 16 data.). @@ -654,7 +641,7 @@ bool DFRobot_PN532_IIC::begin(void) { //nfc Module initialization cmdWrite[1] = 0x01; // normal mode; cmdWrite[2] = 0x14; // timeout 50ms * 20 = 1 second cmdWrite[3] = 0x01; // use IRQ pin! - Wire.begin(SDA_PIN, SCL_PIN); + Wire.begin(); nfcEnable = true; writeCommand(cmdWrite,4); delay(10); From 07b083ed1845a450d00145016f96613aee69281d Mon Sep 17 00:00:00 2001 From: Oliver Norin Date: Thu, 11 Feb 2021 12:23:28 +0100 Subject: [PATCH 4/4] removed whitespaces --- DFRobot_PN532.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/DFRobot_PN532.cpp b/DFRobot_PN532.cpp index a1be3b3..6706145 100644 --- a/DFRobot_PN532.cpp +++ b/DFRobot_PN532.cpp @@ -7,7 +7,6 @@ #endif #include #define PN532_PACKBUFFSIZ 64 - /*! The NTAG's EEPROM memory is organized in pages with 4 bytes per page. NTAG213 variant has 45 pages, NTAG215 variant has 135 pages and NTAG216 variant has 231 pages in total. @@ -365,7 +364,6 @@ bool DFRobot_PN532::writeData(int block, uint8_t data[]) this->readAck(16); return true; } - /*! It takes three steps to write a piece of data to a card 1.Read out all the data for one block(every block have 16 data.).