Skip to content

Commit b201cac

Browse files
authored
Merge pull request #12 from ajit1433/master
added sleep command
2 parents a06316b + e920a84 commit b201cac

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

src/SparkFun_ATECCX08a_Arduino_Library.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,25 @@ void ATECCX08A::idleMode()
111111
_i2cPort->endTransmission(); // actually send it
112112
}
113113

114+
/** \brief
115+
116+
sleep()
117+
118+
The ATECCX08A is forcefully put into sleep (LOW POWER) mode and ignores all subsequent I/O transitions
119+
until the next wake flag. The contents of TempKey and RNG Seed registers are NOT retained.
120+
Idle Power Supply Current: 150nA.
121+
This helps avoid waiting for watchdog timer and immidiately puts the device in sleep mode.
122+
With this sleep/wakeup cycle, RNG seed registers are updated from internal entropy.
123+
*/
124+
125+
void ATECCX08A::sleep()
126+
{
127+
idleMode();
128+
_i2cPort->beginTransmission(_i2caddr); // set up to write to address
129+
_i2cPort->write(WORD_ADDRESS_VALUE_SLEEP); // enter sleep command (aka word address - the first part of every communication to the IC)
130+
_i2cPort->endTransmission(); // actually send it
131+
}
132+
114133
/** \brief
115134
116135
getInfo()

src/SparkFun_ATECCX08a_Arduino_Library.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,8 @@
121121
#define WORD_ADDRESS_VALUE_COMMAND 0x03 // This is the "command" word address,
122122
//this tells the IC we are going to send a command, and is used for most communications to the IC
123123
#define WORD_ADDRESS_VALUE_IDLE 0x02 // used to enter idle mode
124+
//this tells the IC to enter sleep mode
125+
#define WORD_ADDRESS_VALUE_SLEEP 0x01 // used to enter sleep mode
124126

125127
// COMMANDS (aka "opcodes" in the datasheet)
126128
#define COMMAND_OPCODE_INFO 0x30 // Return device state information.
@@ -218,6 +220,7 @@ class ATECCX08A {
218220

219221
boolean wakeUp();
220222
void idleMode();
223+
void sleep();
221224
boolean getInfo();
222225
boolean writeConfigSparkFun();
223226
boolean lockConfig(); // note, this PERMINANTLY disables changes to config zone - including changing the I2C address!

0 commit comments

Comments
 (0)