Skip to content

Commit

Permalink
Performance optimization
Browse files Browse the repository at this point in the history
  • Loading branch information
mikaelpatel committed Sep 25, 2017
1 parent 2c0786c commit ba6fea7
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/Hardware/SPI.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,8 @@ class SPI : public ::SPI {
while (--count) {
value = *sp++;
loop_until_bit_is_set(SPSR, SPIF);
*dp++ = SPDR;
SPDR = value;
*dp++ = SPDR;
}
loop_until_bit_is_set(SPSR, SPIF);
*dp = SPDR;
Expand All @@ -132,13 +132,12 @@ class SPI : public ::SPI {
{
if (count == 0 || buf == NULL) return;
uint8_t* bp = (uint8_t*) buf;
uint8_t value;
SPDR = 0;
while (--count) {
__asm__ __volatile__("nop");
loop_until_bit_is_set(SPSR, SPIF);
value = SPDR;
SPDR = 0;
*bp++ = value;
*bp++ = SPDR;
}
loop_until_bit_is_set(SPSR, SPIF);
*bp = SPDR;
Expand Down

0 comments on commit ba6fea7

Please sign in to comment.