Skip to content
This repository was archived by the owner on Jun 8, 2022. It is now read-only.

Commit 000843a

Browse files
committed
Correction of PN5180::writeEEPROM
1 parent e5adb28 commit 000843a

File tree

3 files changed

+19
-10
lines changed

3 files changed

+19
-10
lines changed

PN5180.cpp

+10-5
Original file line numberDiff line numberDiff line change
@@ -196,9 +196,9 @@ bool PN5180::readRegister(uint8_t reg, uint32_t *value) {
196196
/*
197197
* WRITE_EEPROM - 0x06
198198
*/
199-
bool PN5180::writeEEPROM(uint8_t addr, uint8_t *buffer, int len) {
199+
bool PN5180::writeEEPROM(uint8_t addr, uint8_t *data, int len) {
200200
if ((addr > 254) || ((addr+len) > 254)) {
201-
PN5180DEBUG(F("ERROR: Reading beyond addr 254!\n"));
201+
PN5180DEBUG(F("ERROR: Writing beyond addr 254!\n"));
202202
return false;
203203
}
204204

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

211-
uint8_t cmd[2] = { PN5180_WRITE_EEPROM, addr };
211+
uint8_t buffer[len+2];
212+
buffer[0] = PN5180_WRITE_EEPROM;
213+
buffer[1] = addr;
214+
for (int i=0; i<len; i++) {
215+
buffer[2+i] = data[i];
216+
}
212217

213218
SPI.beginTransaction(PN5180_SPI_SETTINGS);
214-
bool rc = transceiveCommand(cmd, 2, buffer, len);
219+
transceiveCommand(buffer, len+2);
215220
SPI.endTransaction();
216221

217-
return rc;
222+
return true;
218223
}
219224

220225
/*

PN5180.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,8 @@ class PN5180 {
9595
bool readRegister(uint8_t reg, uint32_t *value);
9696

9797
/* cmd 0x06 */
98-
bool writeEEPROM(uint8_t addr, uint8_t *buffer, int len);
99-
98+
bool writeEEPROM(uint8_t addr, uint8_t *data, int len);
99+
100100
/* cmd 0x07 */
101101
bool readEEprom(uint8_t addr, uint8_t *buffer, int len);
102102

PN5180ISO15693.cpp

+7-3
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ ISO15693ErrorCode PN5180ISO15693::readSingleBlock(uint8_t *uid, uint8_t blockNo,
129129

130130
for (int i=0; i<blockSize; i++) {
131131
blockData[i] = resultPtr[1+i];
132-
#ifdef DEBUG
132+
#ifdef DEBUG
133133
PN5180DEBUG(formatHex(blockData[i]));
134134
PN5180DEBUG(" ");
135135
#endif
@@ -514,10 +514,14 @@ ISO15693ErrorCode PN5180ISO15693::issueISO15693Command(uint8_t *cmd, uint8_t cmd
514514

515515
sendData(cmd, cmdLen);
516516
delay(10);
517-
518-
if (0 == (getIRQStatus() & RX_SOF_DET_IRQ_STAT)) {
517+
uint32_t status = getIRQStatus();
518+
if (0 == (status & RX_SOF_DET_IRQ_STAT)) {
519519
return EC_NO_CARD;
520520
}
521+
while (0 == (status & RX_IRQ_STAT)) {
522+
delay(10);
523+
status = getIRQStatus();
524+
}
521525

522526
uint32_t rxStatus;
523527
readRegister(RX_STATUS, &rxStatus);

0 commit comments

Comments
 (0)