Skip to content

Commit 75e617c

Browse files
authored
Merge pull request #15 from sparkfun/release_candidate
Better error reporting
2 parents 5986d82 + 49a6252 commit 75e617c

File tree

5 files changed

+183
-60
lines changed

5 files changed

+183
-60
lines changed

docs/api_SFE_ST25DV64KC.md

+12-7
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ When set, the memory area is only readable if a security session is open.
209209
Area 1 is _always_ readable. Calling ```programEEPROMReadProtectionBit(1, true)``` has no effect.
210210
211211
```c++
212-
void programEEPROMReadProtectionBit(uint8_t memoryArea, bool readSecured)
212+
bool programEEPROMReadProtectionBit(uint8_t memoryArea, bool readSecured)
213213
```
214214

215215
| Parameter | Type | Description |
@@ -225,7 +225,7 @@ This method sets/clears the I2C write protection bit for the specified memory ar
225225
When set, the memory area is only writeable if a security session is open.
226226

227227
```c++
228-
void programEEPROMWriteProtectionBit(uint8_t memoryArea, bool writeSecured)
228+
bool programEEPROMWriteProtectionBit(uint8_t memoryArea, bool writeSecured)
229229
```
230230
231231
| Parameter | Type | Description |
@@ -412,7 +412,7 @@ This method sets or clears the selected bit(s) in the GPO1 register.
412412
Multiple bits can be set or cleared with a single call.
413413

414414
```c++
415-
void setGPO1Bit(uint8_t bitMask, bool enabled)
415+
bool setGPO1Bit(uint8_t bitMask, bool enabled)
416416
```
417417
418418
The GPO1 bit definitions are:
@@ -432,6 +432,7 @@ The GPO1 bit definitions are:
432432
| :-------- | :--- | :---------- |
433433
| `bitMask` | `uint8_t` | The bit(s) to be set or cleared |
434434
| `enabled` | `bool` | If ```true```, the bit(s) set in `bitMask` are set. If ```false```, the bit(s) set in `bitMask` are cleared.
435+
| return value | `bool` | ```true``` if the write is successful, otherwise ```false``` |
435436

436437
### getGPO1Bit()
437438

@@ -453,7 +454,7 @@ This method sets or clears the selected bit(s) in the GPO2 register.
453454
Multiple bits can be set or cleared with a single call.
454455
455456
```c++
456-
void setGPO2Bit(uint8_t bitMask, bool enabled)
457+
bool setGPO2Bit(uint8_t bitMask, bool enabled)
457458
```
458459

459460
The GPO2 bit defintions are:
@@ -467,6 +468,7 @@ The GPO2 bit defintions are:
467468
| :-------- | :--- | :---------- |
468469
| `bitMask` | `uint8_t` | The bit(s) to be set or cleared |
469470
| `enabled` | `bool` | If ```true```, the bit(s) set in `bitMask` are set. If ```false```, the bit(s) set in `bitMask` are cleared.
471+
| return value | `bool` | ```true``` if the write is successful, otherwise ```false``` |
470472
471473
### getGPO2Bit()
472474
@@ -487,12 +489,13 @@ This method sets or clears the GPO_EN bit in the GPO_CTRL_Dyn (Dynamic) register
487489
This allows the GPO pin to be enabled or disabled without making non-volatile changes to the GPO1 register GPO_EN bit.
488490

489491
```c++
490-
void setGPO_CTRL_DynBit(bool enabled)
492+
bool setGPO_CTRL_DynBit(bool enabled)
491493
```
492494
493495
| Parameter | Type | Description |
494496
| :-------- | :--- | :---------- |
495497
| `enabled` | `bool` | If ```true```, the GPO_EN bit is set, otherwise it is cleared |
498+
| return value | `bool` | ```true``` if the write is successful, otherwise ```false``` |
496499
497500
### getGPO_CTRL_DynBit()
498501
@@ -545,12 +548,13 @@ The bit definitions of the IT_SYS_Dyn register are:
545548
This method sets or clears the Energy Harvesting EH_MODE bit in the EH_MODE register.
546549
547550
```c++
548-
void setEH_MODEBit(bool value)
551+
bool setEH_MODEBit(bool value)
549552
```
550553

551554
| Parameter | Type | Description |
552555
| :-------- | :--- | :---------- |
553556
| `value` | `bool` | If ```true```, Energy Harvesting is on demand only (default). If ```false```, EH is forced after boot |
557+
| return value | `bool` | ```true``` if the write is successful, otherwise ```false``` |
554558

555559
### getEH_MODEBit()
556560

@@ -570,13 +574,14 @@ This method will set or clear bit(s) in the dynamic EH_CTRL_Dyn register.
570574
This allows energy harvesting to be enabled or disabled without making non-volatile changes to the EH_MODE register.
571575

572576
```c++
573-
void setEH_CTRL_DYNBit(uint8_t bitMask, bool value)
577+
bool setEH_CTRL_DYNBit(uint8_t bitMask, bool value)
574578
```
575579
576580
| Parameter | Type | Description |
577581
| :-------- | :--- | :---------- |
578582
| `bitMask` | `uint8_t` | The bit(s) to be set or cleared |
579583
| `value` | `bool` | If ```true```, the bit(s) set in `bitMask` are set. If ```false```, the bit(s) set in `bitMask` are cleared |
584+
| return value | `bool` | ```true``` if the write is successful, otherwise ```false``` |
580585
581586
### getEH_CTRL_DYNBit()
582587

examples/Example13-Check_For_NDEF_Write/Example13-Check_For_NDEF_Write.ino

+3-1
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@
3535

3636
SFE_ST25DV64KC_NDEF tag;
3737

38+
// Error handler: print the error code as readable text
39+
// An I2C_TRANSMISSION_ERROR probably indicates that the tag is busy servicing an RF transaction
3840
void errorHandler(SF_ST25DV64KC_ERROR errorCode)
3941
{
4042
Serial.print(F("Error Callback: "));
@@ -50,7 +52,7 @@ void setup()
5052

5153
Serial.println(F("ST25DV64KC example."));
5254

53-
tag.setErrorCallback(&errorHandler); // Set up the error callback
55+
//tag.setErrorCallback(&errorHandler); // Uncomment this line to enable the error callback
5456

5557
if (!tag.begin(Wire))
5658
{

examples/Example14-Wait_For_NDEF_Write/Example14-Wait_For_NDEF_Write.ino

+3-1
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ SFE_ST25DV64KC_NDEF tag;
4141
const uint8_t GPO_PIN = 2; // Change this to match the digital pin you have linked GPO to
4242
#endif
4343

44+
// Error handler: print the error code as readable text
45+
// An I2C_TRANSMISSION_ERROR probably indicates that the tag is busy servicing an RF transaction
4446
void errorHandler(SF_ST25DV64KC_ERROR errorCode)
4547
{
4648
Serial.print(F("Error Callback: "));
@@ -60,7 +62,7 @@ void setup()
6062

6163
Serial.println(F("ST25DV64KC example."));
6264

63-
tag.setErrorCallback(&errorHandler); // Set up the error callback
65+
//tag.setErrorCallback(&errorHandler); // Uncomment this line to enable the error callback
6466

6567
if (!tag.begin(Wire))
6668
{

0 commit comments

Comments
 (0)