Skip to content

Commit

Permalink
Correction of PN5180::writeEEPROM
Browse files Browse the repository at this point in the history
  • Loading branch information
ATrappmann committed Jun 23, 2021
1 parent e5adb28 commit 000843a
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 10 deletions.
15 changes: 10 additions & 5 deletions PN5180.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -196,9 +196,9 @@ bool PN5180::readRegister(uint8_t reg, uint32_t *value) {
/*
* WRITE_EEPROM - 0x06
*/
bool PN5180::writeEEPROM(uint8_t addr, uint8_t *buffer, int len) {
bool PN5180::writeEEPROM(uint8_t addr, uint8_t *data, int len) {
if ((addr > 254) || ((addr+len) > 254)) {
PN5180DEBUG(F("ERROR: Reading beyond addr 254!\n"));
PN5180DEBUG(F("ERROR: Writing beyond addr 254!\n"));
return false;
}

Expand All @@ -208,13 +208,18 @@ bool PN5180::readRegister(uint8_t reg, uint32_t *value) {
PN5180DEBUG(len);
PN5180DEBUG(F("...\n"));

uint8_t cmd[2] = { PN5180_WRITE_EEPROM, addr };
uint8_t buffer[len+2];
buffer[0] = PN5180_WRITE_EEPROM;
buffer[1] = addr;
for (int i=0; i<len; i++) {
buffer[2+i] = data[i];
}

SPI.beginTransaction(PN5180_SPI_SETTINGS);
bool rc = transceiveCommand(cmd, 2, buffer, len);
transceiveCommand(buffer, len+2);
SPI.endTransaction();

return rc;
return true;
}

/*
Expand Down
4 changes: 2 additions & 2 deletions PN5180.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,8 @@ class PN5180 {
bool readRegister(uint8_t reg, uint32_t *value);

/* cmd 0x06 */
bool writeEEPROM(uint8_t addr, uint8_t *buffer, int len);
bool writeEEPROM(uint8_t addr, uint8_t *data, int len);

/* cmd 0x07 */
bool readEEprom(uint8_t addr, uint8_t *buffer, int len);

Expand Down
10 changes: 7 additions & 3 deletions PN5180ISO15693.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ ISO15693ErrorCode PN5180ISO15693::readSingleBlock(uint8_t *uid, uint8_t blockNo,

for (int i=0; i<blockSize; i++) {
blockData[i] = resultPtr[1+i];
#ifdef DEBUG
#ifdef DEBUG
PN5180DEBUG(formatHex(blockData[i]));
PN5180DEBUG(" ");
#endif
Expand Down Expand Up @@ -514,10 +514,14 @@ ISO15693ErrorCode PN5180ISO15693::issueISO15693Command(uint8_t *cmd, uint8_t cmd

sendData(cmd, cmdLen);
delay(10);

if (0 == (getIRQStatus() & RX_SOF_DET_IRQ_STAT)) {
uint32_t status = getIRQStatus();
if (0 == (status & RX_SOF_DET_IRQ_STAT)) {
return EC_NO_CARD;
}
while (0 == (status & RX_IRQ_STAT)) {
delay(10);
status = getIRQStatus();
}

uint32_t rxStatus;
readRegister(RX_STATUS, &rxStatus);
Expand Down

0 comments on commit 000843a

Please sign in to comment.