Skip to content

Commit

Permalink
Small cleanup to SPI write16 and write32 for big-endian
Browse files Browse the repository at this point in the history
Merge a common line.
  • Loading branch information
rsaxvc authored and igrr committed Jun 7, 2017
1 parent 5b5ba1a commit c07c8dc
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions libraries/SPI/SPI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -343,12 +343,11 @@ void SPIClass::write16(uint16_t data, bool msb) {
if(msb) {
// MSBFIRST Byte first
SPI1W0 = (data >> 8) | (data << 8);
SPI1CMD |= SPIBUSY;
} else {
// LSBFIRST Byte first
SPI1W0 = data;
SPI1CMD |= SPIBUSY;
}
SPI1CMD |= SPIBUSY;
while(SPI1CMD & SPIBUSY) {}
}

Expand All @@ -367,14 +366,11 @@ void SPIClass::write32(uint32_t data, bool msb) {
} data_;
data_.l = data;
// MSBFIRST Byte first
SPI1W0 = (data_.b[3] | (data_.b[2] << 8) | (data_.b[1] << 16) | (data_.b[0] << 24));
SPI1CMD |= SPIBUSY;
} else {
// LSBFIRST Byte first
SPI1W0 = data;
SPI1CMD |= SPIBUSY;
data = (data_.b[3] | (data_.b[2] << 8) | (data_.b[1] << 16) | (data_.b[0] << 24));
}
while(SPI1CMD & SPIBUSY) {}
SPI1W0 = data;
SPI1CMD |= SPIBUSY;
while(SPI1CMD & SPIBUSY) {}
}

/**
Expand Down

0 comments on commit c07c8dc

Please sign in to comment.