Skip to content

Commit

Permalink
Fix #335: [un]signed cleanup Catena_Mx25v8035f::begin()
Browse files Browse the repository at this point in the history
  • Loading branch information
terrillmoore committed Jun 12, 2022
1 parent a39ee4b commit 6ff9a53
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/lib/stm32/Catena_Mx25v8035f.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,9 @@ bool Catena_Mx25v8035f::begin(
return false;
}

if (ChipSelectPin == -1 && this->m_CS == -1)
if (ChipSelectPin == -1 && this->m_CS == UINT8_MAX)
{
// [1] prevent us from proceeding if both ChipSelectPin and m_CS are "not specified"
gLog.printf(cLog::kError, "flash pin not set\n");
return false;
}
Expand All @@ -129,8 +130,12 @@ bool Catena_Mx25v8035f::begin(

this->m_pSpi = pSpi;
if (ChipSelectPin != -1)
// [2] make sure m_CS has a value.
this->m_CS = ChipSelectPin;

// at this point, m_CS is valid by [1] and [2] above.

// start the operation.
pSpi->beginTransaction(this->m_CS, SpiSettings);

/* force to put stand-by mode, just in case */
Expand Down

0 comments on commit 6ff9a53

Please sign in to comment.