Merge pull request #108 from anistor/t_fixes_for_STM32F103
Some fixes for STM32F1 platform
This commit is contained in:
26
MFRC522.cpp
26
MFRC522.cpp
@@ -18,18 +18,8 @@
|
||||
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)
|
||||
) {
|
||||
// Set the chipSelectPin as digital output, do not select the slave yet
|
||||
_chipSelectPin = chipSelectPin;
|
||||
pinMode(_chipSelectPin, OUTPUT);
|
||||
digitalWrite(_chipSelectPin, HIGH);
|
||||
|
||||
// Set the resetPowerDownPin as digital output, do not reset or power down.
|
||||
_resetPowerDownPin = resetPowerDownPin;
|
||||
pinMode(_resetPowerDownPin, OUTPUT);
|
||||
digitalWrite(_resetPowerDownPin, LOW);
|
||||
|
||||
// Set SPI bus to work with MFRC522 chip.
|
||||
setSPIConfig();
|
||||
} // End constructor
|
||||
|
||||
/**
|
||||
@@ -194,6 +184,16 @@ byte MFRC522::PCD_CalculateCRC( byte *data, ///< In: Pointer to the data to tra
|
||||
* Initializes the MFRC522 chip.
|
||||
*/
|
||||
void MFRC522::PCD_Init() {
|
||||
// Set the chipSelectPin as digital output, do not select the slave yet
|
||||
pinMode(_chipSelectPin, OUTPUT);
|
||||
digitalWrite(_chipSelectPin, HIGH);
|
||||
|
||||
// Set the resetPowerDownPin as digital output, do not reset or power down.
|
||||
pinMode(_resetPowerDownPin, OUTPUT);
|
||||
|
||||
// Set SPI bus to work with MFRC522 chip.
|
||||
setSPIConfig();
|
||||
|
||||
if (digitalRead(_resetPowerDownPin) == LOW) { //The MFRC522 chip is in power down mode.
|
||||
digitalWrite(_resetPowerDownPin, HIGH); // Exit power down mode. This triggers a hard reset.
|
||||
// Section 8.8.2 in the datasheet says the oscillator start-up time is the start up time of the crystal + 37,74<37>s. Let us be generous: 50ms.
|
||||
@@ -548,7 +548,7 @@ byte MFRC522::PICC_Select( Uid *uid, ///< Pointer to Uid struct. Normally outp
|
||||
byte count;
|
||||
byte index;
|
||||
byte uidIndex; // The first index in uid->uidByte[] that is used in the current Cascade Level.
|
||||
char currentLevelKnownBits; // The number of known UID bits in the current Cascade Level.
|
||||
int8_t currentLevelKnownBits; // The number of known UID bits in the current Cascade Level.
|
||||
byte buffer[9]; // The SELECT/ANTICOLLISION commands uses a 7 byte standard frame + 2 bytes CRC_A
|
||||
byte bufferUsed; // The number of bytes used in the buffer, ie the number of bytes to transfer to the FIFO.
|
||||
byte rxAlign; // Used in BitFramingReg. Defines the bit position for the first bit received.
|
||||
@@ -1307,7 +1307,7 @@ void MFRC522::PICC_DumpMifareClassicToSerial( Uid *uid, ///< Pointer to Uid str
|
||||
// Dump sectors, highest address first.
|
||||
if (no_of_sectors) {
|
||||
Serial.println(F("Sector Block 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 AccessBits"));
|
||||
for (char i = no_of_sectors - 1; i >= 0; i--) {
|
||||
for (int8_t i = no_of_sectors - 1; i >= 0; i--) {
|
||||
PICC_DumpMifareClassicSectorToSerial(uid, key, i);
|
||||
}
|
||||
}
|
||||
@@ -1362,7 +1362,7 @@ void MFRC522::PICC_DumpMifareClassicSectorToSerial(Uid *uid, ///< Pointer to U
|
||||
byte buffer[18];
|
||||
byte blockAddr;
|
||||
isSectorTrailer = true;
|
||||
for (char blockOffset = no_of_blocks - 1; blockOffset >= 0; blockOffset--) {
|
||||
for (int8_t blockOffset = no_of_blocks - 1; blockOffset >= 0; blockOffset--) {
|
||||
blockAddr = firstBlock + blockOffset;
|
||||
// Sector number - only on first line
|
||||
if (isSectorTrailer) {
|
||||
|
||||
@@ -58,13 +58,13 @@
|
||||
* MIFARE Ultralight (MF0ICU1):
|
||||
* Has 16 pages of 4 bytes = 64 bytes.
|
||||
* Pages 0 + 1 is used for the 7-byte UID.
|
||||
* Page 2 contains the last chech digit for the UID, one byte manufacturer internal data, and the lock bytes (see http://www.nxp.com/documents/data_sheet/MF0ICU1.pdf section 8.5.2)
|
||||
* Page 2 contains the last check digit for the UID, one byte manufacturer internal data, and the lock bytes (see http://www.nxp.com/documents/data_sheet/MF0ICU1.pdf section 8.5.2)
|
||||
* Page 3 is OTP, One Time Programmable bits. Once set to 1 they cannot revert to 0.
|
||||
* Pages 4-15 are read/write unless blocked by the lock bytes in page 2.
|
||||
* MIFARE Ultralight C (MF0ICU2):
|
||||
* Has 48 pages of 4 bytes = 64 bytes.
|
||||
* Has 48 pages of 4 bytes = 192 bytes.
|
||||
* Pages 0 + 1 is used for the 7-byte UID.
|
||||
* Page 2 contains the last chech digit for the UID, one byte manufacturer internal data, and the lock bytes (see http://www.nxp.com/documents/data_sheet/MF0ICU1.pdf section 8.5.2)
|
||||
* Page 2 contains the last check digit for the UID, one byte manufacturer internal data, and the lock bytes (see http://www.nxp.com/documents/data_sheet/MF0ICU1.pdf section 8.5.2)
|
||||
* Page 3 is OTP, One Time Programmable bits. Once set to 1 they cannot revert to 0.
|
||||
* Pages 4-39 are read/write unless blocked by the lock bytes in page 2.
|
||||
* Page 40 Lock bytes
|
||||
|
||||
@@ -64,7 +64,7 @@ void loop() {
|
||||
// Ask personal data: Family name
|
||||
Serial.println(F("Type Family name, ending with #"));
|
||||
len=Serial.readBytesUntil('#', (char *) buffer, 30) ; // read family name from serial
|
||||
for (byte i = len; i < 30; i++) buffer[i] = '\s'; // pad with spaces
|
||||
for (byte i = len; i < 30; i++) buffer[i] = ' '; // pad with spaces
|
||||
|
||||
block = 1;
|
||||
//Serial.println(F("Authenticating using key A..."));
|
||||
@@ -106,7 +106,7 @@ void loop() {
|
||||
// Ask personal data: First name
|
||||
Serial.println(F("Type First name, ending with #"));
|
||||
len=Serial.readBytesUntil('#', (char *) buffer, 20) ; // read first name from serial
|
||||
for (byte i = len; i < 20; i++) buffer[i] = '\s'; // pad with spaces
|
||||
for (byte i = len; i < 20; i++) buffer[i] = ' '; // pad with spaces
|
||||
|
||||
block = 4;
|
||||
//Serial.println(F("Authenticating using key A..."));
|
||||
|
||||
@@ -9,5 +9,5 @@
|
||||
},
|
||||
"exclude": "doc",
|
||||
"frameworks": "arduino",
|
||||
"platforms": "atmelavr"
|
||||
"platforms": ["atmelavr", "ststm32"]
|
||||
}
|
||||
|
||||
@@ -7,4 +7,4 @@ sentence=Arduino RFID Library for MFRC522 (SPI)
|
||||
paragraph=Read/Write a RFID Card or Tag using the ISO/IEC 14443A/MIFARE interface.
|
||||
category=Communication
|
||||
url=https://github.com/miguelbalboa/rfid
|
||||
architectures=avr
|
||||
architectures=avr,STM32F1
|
||||
|
||||
Reference in New Issue
Block a user