[posix] use OT_MAX to simplify SPI code (#7124)

This commit is contained in:
Li Cao
2021-11-01 09:26:02 -07:00
committed by GitHub
parent 60aa8b4fb9
commit 5e8265f455
+3 -12
View File
@@ -445,29 +445,20 @@ otError SpiInterface::PushPullSpi(void)
// Go ahead and try to immediately send a frame if we have it queued up.
txFrame.SetHeaderDataLen(mSpiTxPayloadSize);
if (mSpiTxPayloadSize > spiTransferBytes)
{
spiTransferBytes = mSpiTxPayloadSize;
}
spiTransferBytes = OT_MAX(spiTransferBytes, mSpiTxPayloadSize);
}
if (mSpiSlaveDataLen != 0)
{
// In a previous transaction the slave indicated it had something to send us. Make sure our transaction
// is large enough to handle it.
if (mSpiSlaveDataLen > spiTransferBytes)
{
spiTransferBytes = mSpiSlaveDataLen;
}
spiTransferBytes = OT_MAX(spiTransferBytes, mSpiSlaveDataLen);
}
else
{
// Set up a minimum transfer size to allow small frames the slave wants to send us to be handled in a
// single transaction.
if (spiTransferBytes < mSpiSmallPacketSize)
{
spiTransferBytes = mSpiSmallPacketSize;
}
spiTransferBytes = OT_MAX(spiTransferBytes, mSpiSmallPacketSize);
}
txFrame.SetHeaderAcceptLen(spiTransferBytes);