From f07049c24e80f69fa4c1a2a0516c1fcff92df69b Mon Sep 17 00:00:00 2001 From: Rotzbua Date: Thu, 11 May 2017 17:36:43 +0200 Subject: [PATCH] remove some constructors Optional soft reset was added before, this can confuse ppl by default set ss and not set rst pin. To clearify this change is made. Maybe brakes some implmentations. --- changes.txt | 6 +++++- src/MFRC522.cpp | 25 ++----------------------- src/MFRC522.h | 8 +++----- src/MFRC522Extended.h | 1 - 4 files changed, 10 insertions(+), 30 deletions(-) diff --git a/changes.txt b/changes.txt index f3f866a..60bf872 100644 --- a/changes.txt +++ b/changes.txt @@ -1,7 +1,11 @@ -- Add changes to unreleased tag until we make a release. unreleased -- +- Removed: void PCD_Init(byte resetPowerDownPin); +- Removed: MFRC522(byte resetPowerDownPin); +- Changed default initialisation of SS pin with constants of arduino.h are not done anymore +- Replaced UINT8_MAX by UNUSED_PIN +- 22 Mar 2017, v1.3.6 - Added deprecate and compiler warnings @Rotzbua diff --git a/src/MFRC522.cpp b/src/MFRC522.cpp index 7800e24..e610250 100644 --- a/src/MFRC522.cpp +++ b/src/MFRC522.cpp @@ -10,26 +10,13 @@ ///////////////////////////////////////////////////////////////////////////////////// // Functions for setting up the Arduino ///////////////////////////////////////////////////////////////////////////////////// -/** - * Constructor. - */ -MFRC522::MFRC522(): MFRC522(SS, UINT8_MAX) { // SS is defined in pins_arduino.h, UINT8_MAX means there is no connection from Arduino to MFRC522's reset and power down input -} // End constructor - -/** - * Constructor. - * Prepares the output pins. - */ -MFRC522::MFRC522( byte resetPowerDownPin ///< Arduino pin connected to MFRC522's reset and power down input (Pin 6, NRSTPD, active low). If there is no connection from the CPU to NRSTPD, set this to UINT8_MAX. In this case, only soft reset will be used in PCD_Init(). - ): MFRC522(SS, resetPowerDownPin) { // SS is defined in pins_arduino.h -} // End constructor /** * Constructor. * Prepares the output pins. */ MFRC522::MFRC522( byte chipSelectPin, ///< Arduino pin connected to MFRC522's SPI slave select input (Pin 24, NSS, active low) - byte resetPowerDownPin ///< Arduino pin connected to MFRC522's reset and power down input (Pin 6, NRSTPD, active low). If there is no connection from the CPU to NRSTPD, set this to UINT8_MAX. In this case, only soft reset will be used in PCD_Init(). + byte resetPowerDownPin ///< Arduino pin connected to MFRC522's reset and power down input (Pin 6, NRSTPD, active low). If there is no connection from the CPU to NRSTPD, set this to constant UNUSED_PIN. In this case, only soft reset will be used in PCD_Init(). ) { _chipSelectPin = chipSelectPin; _resetPowerDownPin = resetPowerDownPin; @@ -198,7 +185,7 @@ void MFRC522::PCD_Init() { digitalWrite(_chipSelectPin, HIGH); // If a valid pin number has been set, pull device out of power down / reset state. - if (_resetPowerDownPin != UINT8_MAX) { + if (_resetPowerDownPin != UNUSED_PIN) { // Set the resetPowerDownPin as digital output, do not reset or power down. pinMode(_resetPowerDownPin, OUTPUT); @@ -233,14 +220,6 @@ void MFRC522::PCD_Init() { PCD_AntennaOn(); // Enable the antenna driver pins TX1 and TX2 (they were disabled by the reset) } // End PCD_Init() -/** - * Initializes the MFRC522 chip. - */ -void MFRC522::PCD_Init( byte resetPowerDownPin ///< Arduino pin connected to MFRC522's reset and power down input (Pin 6, NRSTPD, active low) - ) { - PCD_Init(SS, resetPowerDownPin); // SS is defined in pins_arduino.h -} // End PCD_Init() - /** * Initializes the MFRC522 chip. */ diff --git a/src/MFRC522.h b/src/MFRC522.h index 7fa6288..609e9b4 100644 --- a/src/MFRC522.h +++ b/src/MFRC522.h @@ -142,6 +142,8 @@ class MFRC522 { public: // Size of the MFRC522 FIFO static const byte FIFO_SIZE = 64; // The FIFO is 64 bytes. + // Default value for unused pin + static constexpr uint8_t UNUSED_PIN = UINT8_MAX; // MFRC522 registers. Described in chapter 9 of the datasheet. // When using SPI all addresses are shifted one bit left in the "SPI address byte" (section 8.1.2.3) @@ -330,9 +332,7 @@ public: ///////////////////////////////////////////////////////////////////////////////////// // Functions for setting up the Arduino ///////////////////////////////////////////////////////////////////////////////////// - MFRC522(); - DEPRECATED_MSG("use MFRC522(byte chipSelectPin, byte resetPowerDownPin)") - MFRC522(byte resetPowerDownPin); + MFRC522() : MFRC522(UNUSED_PIN, UNUSED_PIN) {}; MFRC522(byte chipSelectPin, byte resetPowerDownPin); ///////////////////////////////////////////////////////////////////////////////////// @@ -350,8 +350,6 @@ public: // Functions for manipulating the MFRC522 ///////////////////////////////////////////////////////////////////////////////////// void PCD_Init(); - DEPRECATED_MSG("use PCD_Init(byte chipSelectPin, byte resetPowerDownPin)") - void PCD_Init(byte resetPowerDownPin); void PCD_Init(byte chipSelectPin, byte resetPowerDownPin); void PCD_Reset(); void PCD_AntennaOn(); diff --git a/src/MFRC522Extended.h b/src/MFRC522Extended.h index 9fd8ff8..b0ce017 100644 --- a/src/MFRC522Extended.h +++ b/src/MFRC522Extended.h @@ -78,7 +78,6 @@ public: // Contructors ///////////////////////////////////////////////////////////////////////////////////// MFRC522Extended() : MFRC522() {}; - MFRC522Extended(uint8_t rst) : MFRC522(rst) {}; MFRC522Extended(uint8_t ss, uint8_t rst) : MFRC522(ss, rst) {}; /////////////////////////////////////////////////////////////////////////////////////