@@ -37,7 +37,7 @@ void MFRC522::PCD_ClearRegisterBitMask(PCD_Register reg, ///< The register to u
3737
3838/* *
3939 * Use the CRC coprocessor in the MFRC522 to calculate a CRC_A.
40- *
40+ *
4141 * @return StatusCode::STATUS_OK on success, StatusCode::STATUS_??? otherwise.
4242 */
4343MFRC522::StatusCode MFRC522::PCD_CalculateCRC (byte *data, // /< In: Pointer to the data to transfer to the FIFO for CRC calculation.
@@ -450,7 +450,7 @@ MFRC522::StatusCode MFRC522::PCD_CommunicateWithPICC(byte command, ///< The c
450450 if ((byte)t_delta >= software_timeout_ms) {
451451 return StatusCode::STATUS_TIMEOUT;
452452 }
453-
453+
454454 // Stop now if any errors except collisions were detected.
455455 byte errorRegValue = _driver.PCD_ReadRegister (PCD_Register::ErrorReg); // ErrorReg[7..0] bits are: WrErr TempErr reserved BufferOvfl CollErr CRCErr ParityErr ProtocolErr
456456 if (errorRegValue & 0x13 ) { // BufferOvfl ParityErr ProtocolErr
@@ -698,16 +698,16 @@ MFRC522::StatusCode MFRC522::PICC_Select(Uid *uid, ///< Pointer to Uid stru
698698 txLastBits = currentLevelKnownBits%8 ;
699699 count = currentLevelKnownBits/8 ; // Number of whole bytes in the UID part.
700700 index = 2 +count; // Number of whole bytes: SEL + NVB + UIDs
701- buffer[1 ] = (index << 4 )+txLastBits; // NVB - Number of Valid Bits
702- bufferUsed = index+(txLastBits ? 1 : 0 );
701+ buffer[1 ] = (index << 4 )+txLastBits; // NVB - Number of Valid Bits
702+ bufferUsed = index+(txLastBits ? 1 : 0 );
703703 // Store response in the unused part of buffer
704704 responseBuffer = &buffer[index];
705705 responseLength = sizeof (buffer)-index;
706706 }
707707
708708 // Set bit adjustments
709709 rxAlign = txLastBits; // Having a separate variable is overkill. But it makes the next line easier to read.
710- _driver.PCD_WriteRegister (PCD_Register::BitFramingReg, (rxAlign << 4 )+txLastBits); // RxAlign = BitFramingReg[6..4]. TxLastBits = BitFramingReg[2..0]
710+ // _driver.PCD_WriteRegister(PCD_Register::BitFramingReg, (rxAlign << 4)+txLastBits); // RxAlign = BitFramingReg[6..4]. TxLastBits = BitFramingReg[2..0]
711711
712712 // Transmit the buffer and receive the response.
713713 result = PCD_TransceiveData (buffer, bufferUsed, responseBuffer, &responseLength, &txLastBits, rxAlign);
@@ -720,11 +720,11 @@ MFRC522::StatusCode MFRC522::PICC_Select(Uid *uid, ///< Pointer to Uid stru
720720 if (collisionPos == 0 ) {
721721 collisionPos = 32 ;
722722 }
723- if (collisionPos <= currentLevelKnownBits) { // No progress - should not happen
723+ currentLevelKnownBits += collisionPos;
724+ if (currentLevelKnownBits > 32 ) {
724725 return StatusCode::STATUS_INTERNAL_ERROR;
725726 }
726727 // Choose the PICC with the bit set.
727- currentLevelKnownBits = collisionPos;
728728 count = currentLevelKnownBits%8 ; // The bit to modify
729729 checkBit = (currentLevelKnownBits-1 )%8 ;
730730 index = 1 +(currentLevelKnownBits/8 )+(count ? 1 : 0 ); // First byte is index 0.
0 commit comments