Skip to content

Commit

Permalink
lattice: spi_put: avoid loop when tx == NULL
Browse files Browse the repository at this point in the history
  • Loading branch information
trabucayre committed Sep 6, 2023
1 parent 61b59ce commit c417ce6
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/lattice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1361,10 +1361,13 @@ int Lattice::spi_put(const uint8_t *tx, uint8_t *rx, uint32_t len)
uint8_t jtx[len];
uint8_t jrx[len];

for (uint32_t i = 0; i < len; ++i) {
jtx[i] = (tx) ? LatticeBitParser::reverseByte(tx[i]) : 0;
jrx[i] = 0;
}
memset(jrx, 0, len);

if (tx)
for (uint32_t i = 0; i < len; ++i)
jtx[i] = LatticeBitParser::reverseByte(tx[i]);
else
memset(jtx, 0, len);

/* send first already stored cmd,
* in the same time store each byte
Expand Down

0 comments on commit c417ce6

Please sign in to comment.