using bitwire operators (works on all platforms)

This commit is contained in:
lathoub 2020-03-24 13:49:36 +01:00
parent 00c5cccd5d
commit 122ebe1dc3
1 changed files with 8 additions and 6 deletions

View File

@ -731,7 +731,7 @@ inline bool MidiInterface<Transport, Settings, Platform>::read(Channel inChannel
{ {
mReceiverActiveSensingActivated = false; mReceiverActiveSensingActivated = false;
bitSet(mLastError, ErrorActiveSensingTimeout); mLastError |= 1UL << ErrorActiveSensingTimeout; // set the ErrorActiveSensingTimeout bit
if (mErrorCallback) if (mErrorCallback)
mErrorCallback(mLastError); mErrorCallback(mLastError);
} }
@ -751,9 +751,10 @@ inline bool MidiInterface<Transport, Settings, Platform>::read(Channel inChannel
// When a timeout occurs, an error message is send and time keeping ends. // When a timeout occurs, an error message is send and time keeping ends.
mReceiverActiveSensingActivated = true; mReceiverActiveSensingActivated = true;
if (bitRead(mLastError, ErrorActiveSensingTimeout)) // is ErrorActiveSensingTimeout bit in mLastError on
if (mLastError & (1 << (ErrorActiveSensingTimeout - 1)))
{ {
bitClear(mLastError, ErrorActiveSensingTimeout); mLastError &= ~(1UL << ErrorActiveSensingTimeout); // clear the ErrorActiveSensingTimeout bit
if (mErrorCallback) if (mErrorCallback)
mErrorCallback(mLastError); mErrorCallback(mLastError);
} }
@ -785,7 +786,8 @@ bool MidiInterface<Transport, Settings, Platform>::parse()
if (mTransport.available() == 0) if (mTransport.available() == 0)
return false; // No data available. return false; // No data available.
bitClear(mLastError, ErrorParse); // clear the ErrorParse bit
mLastError &= ~(1UL << ErrorParse);
// Parsing algorithm: // Parsing algorithm:
// Get a byte from the serial buffer. // Get a byte from the serial buffer.
@ -883,7 +885,7 @@ bool MidiInterface<Transport, Settings, Platform>::parse()
case InvalidType: case InvalidType:
default: default:
// This is obviously wrong. Let's get the hell out'a here. // This is obviously wrong. Let's get the hell out'a here.
bitSet(mLastError, ErrorParse); mLastError |= 1UL << ErrorParse; // set the ErrorParse bit
if (mErrorCallback) if (mErrorCallback)
mErrorCallback(mLastError); mErrorCallback(mLastError);
@ -972,7 +974,7 @@ bool MidiInterface<Transport, Settings, Platform>::parse()
else else
{ {
// Well well well.. error. // Well well well.. error.
bitSet(mLastError, ErrorParse); mLastError |= 1UL << ErrorParse; // set the error bits
if (mErrorCallback) if (mErrorCallback)
mErrorCallback(mLastError); mErrorCallback(mLastError);