implement resume command (0xA5)
This commit is contained in:
parent
5621c45c02
commit
a31256f60d
@ -46,6 +46,7 @@ byte OneWireSlave::receivingByte_;
|
||||
byte OneWireSlave::searchRomBytePos_;
|
||||
byte OneWireSlave::searchRomBitPos_;
|
||||
bool OneWireSlave::searchRomInverse_;
|
||||
bool OneWireSlave::resumeCommandFlag_;
|
||||
|
||||
const byte* OneWireSlave::sendBuffer_;
|
||||
byte* OneWireSlave::recvBuffer_;
|
||||
@ -77,6 +78,8 @@ void OneWireSlave::begin(const byte* rom, byte pinNumber)
|
||||
memcpy(rom_, rom, 7);
|
||||
rom_[7] = crc8(rom_, 7);
|
||||
|
||||
resumeCommandFlag_ = false;
|
||||
|
||||
clientReceiveBitCallback_ = 0;
|
||||
|
||||
// log("Enabling 1-wire library")
|
||||
@ -416,9 +419,18 @@ void OneWireSlave::onBitReceived_(bool bit, bool error)
|
||||
beginReceiveBytes_(scratchpad_, 8, &OneWireSlave::matchRomBytesReceived_);
|
||||
return;
|
||||
case 0xCC: // SKIP ROM
|
||||
// emulate a match rom operation
|
||||
memcpy(scratchpad_, rom_, 8);
|
||||
matchRomBytesReceived_(false);
|
||||
resumeCommandFlag_ = false;
|
||||
beginReceiveBytes_(scratchpad_, 1, &OneWireSlave::notifyClientByteReceived_);
|
||||
return;
|
||||
case 0xA5: // RESUME
|
||||
if (resumeCommandFlag_)
|
||||
{
|
||||
beginReceiveBytes_(scratchpad_, 1, &OneWireSlave::notifyClientByteReceived_);
|
||||
}
|
||||
else
|
||||
{
|
||||
beginWaitReset_();
|
||||
}
|
||||
return;
|
||||
default:
|
||||
ERROR("Unknown command");
|
||||
@ -582,6 +594,7 @@ void OneWireSlave::matchRomBytesReceived_(bool error)
|
||||
{
|
||||
if (error)
|
||||
{
|
||||
resumeCommandFlag_ = false;
|
||||
ERROR("error receiving match rom bytes");
|
||||
return;
|
||||
}
|
||||
@ -589,13 +602,13 @@ void OneWireSlave::matchRomBytesReceived_(bool error)
|
||||
if (memcmp(rom_, scratchpad_, 8) == 0)
|
||||
{
|
||||
// log("ROM matched");
|
||||
|
||||
resumeCommandFlag_ = true;
|
||||
beginReceiveBytes_(scratchpad_, 1, &OneWireSlave::notifyClientByteReceived_);
|
||||
}
|
||||
else
|
||||
{
|
||||
// log("ROM not matched");
|
||||
|
||||
resumeCommandFlag_ = false;
|
||||
beginWaitReset_();
|
||||
}
|
||||
}
|
||||
|
@ -102,6 +102,7 @@ private:
|
||||
static byte searchRomBytePos_;
|
||||
static byte searchRomBitPos_;
|
||||
static bool searchRomInverse_;
|
||||
static bool resumeCommandFlag_;
|
||||
|
||||
static const byte* sendBuffer_;
|
||||
static byte* recvBuffer_;
|
||||
|
Loading…
Reference in New Issue
Block a user