From 4c193e338fbf91fd766b48f88245c91b4ab03440 Mon Sep 17 00:00:00 2001 From: Rotzbua Date: Thu, 4 Oct 2018 13:10:12 +0200 Subject: [PATCH] Revert "remove some constructors" This reverts commit f07049c24e80f69fa4c1a2a0516c1fcff92df69b. --- changes.txt | 2 -- src/MFRC522.cpp | 23 ++++++++++++++++++++++- src/MFRC522.h | 8 ++++++-- src/MFRC522Extended.h | 1 + 4 files changed, 29 insertions(+), 5 deletions(-) diff --git a/changes.txt b/changes.txt index 79f48ce..d74e7e4 100644 --- a/changes.txt +++ b/changes.txt @@ -1,7 +1,5 @@ -- Add changes to unreleased tag until we make a release. -unreleased -- unreleased, v1.4.0 - Removed: void PCD_Init(byte resetPowerDownPin); diff --git a/src/MFRC522.cpp b/src/MFRC522.cpp index f68afa5..265f25c 100644 --- a/src/MFRC522.cpp +++ b/src/MFRC522.cpp @@ -10,13 +10,26 @@ ///////////////////////////////////////////////////////////////////////////////////// // 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 constant UNUSED_PIN. 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 UINT8_MAX. In this case, only soft reset will be used in PCD_Init(). ) { _chipSelectPin = chipSelectPin; _resetPowerDownPin = resetPowerDownPin; @@ -221,6 +234,14 @@ 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 de25ece..f462d02 100644 --- a/src/MFRC522.h +++ b/src/MFRC522.h @@ -144,7 +144,7 @@ public: static constexpr 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) enum PCD_Register : byte { @@ -332,7 +332,9 @@ public: ///////////////////////////////////////////////////////////////////////////////////// // Functions for setting up the Arduino ///////////////////////////////////////////////////////////////////////////////////// - MFRC522() : MFRC522(UNUSED_PIN, UNUSED_PIN) {}; + MFRC522(); + DEPRECATED_MSG("use MFRC522(byte chipSelectPin, byte resetPowerDownPin)") + MFRC522(byte resetPowerDownPin); MFRC522(byte chipSelectPin, byte resetPowerDownPin); ///////////////////////////////////////////////////////////////////////////////////// @@ -350,6 +352,8 @@ 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 b0ce017..9fd8ff8 100644 --- a/src/MFRC522Extended.h +++ b/src/MFRC522Extended.h @@ -78,6 +78,7 @@ public: // Contructors ///////////////////////////////////////////////////////////////////////////////////// MFRC522Extended() : MFRC522() {}; + MFRC522Extended(uint8_t rst) : MFRC522(rst) {}; MFRC522Extended(uint8_t ss, uint8_t rst) : MFRC522(ss, rst) {}; /////////////////////////////////////////////////////////////////////////////////////