nanohub: initalize local interrupt state
Change-Id: Id7e3e75fffd5af9e892105c5554becda39e56d88
diff --git a/firmware/os/core/nanohubCommand.c b/firmware/os/core/nanohubCommand.c
index 1c96225..095cd5a 100644
--- a/firmware/os/core/nanohubCommand.c
+++ b/firmware/os/core/nanohubCommand.c
@@ -734,7 +734,8 @@
packet->firstSample.interrupt = NANOHUB_INT_WAKEUP;
}
- if ((!totLength || (isSensorEvent(firstPacket->evtType) && isSensorEvent(packet->evtType))) && totLength + length <= sizeof(struct HostIntfDataBuffer)) {
+ if ((!totLength || (isSensorEvent(firstPacket->evtType) && isSensorEvent(packet->evtType))) &&
+ totLength + length <= sizeof(struct HostIntfDataBuffer)) {
memcpy(buf + totLength, &mTxNext, length);
totLength += length;
if (isSensorEvent(packet->evtType) && packet->firstSample.interrupt == NANOHUB_INT_WAKEUP)
@@ -868,10 +869,11 @@
return totLength;
}
+ wakeup = atomicRead32bits(&mTxWakeCnt[0]);
+ nonwakeup = atomicRead32bits(&mTxWakeCnt[1]);
+
if (mTxNextLength > 0) {
length = mTxNextLength;
- wakeup = atomicRead32bits(&mTxWakeCnt[0]);
- nonwakeup = atomicRead32bits(&mTxWakeCnt[1]);
memcpy(buf, &mTxNext, length);
totLength = length;
mTxNextLength = 0;