Skip to content

Commit ba6fea7

Browse files
committed
Performance optimization
1 parent 2c0786c commit ba6fea7

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

src/Hardware/SPI.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,8 @@ class SPI : public ::SPI {
115115
while (--count) {
116116
value = *sp++;
117117
loop_until_bit_is_set(SPSR, SPIF);
118-
*dp++ = SPDR;
119118
SPDR = value;
119+
*dp++ = SPDR;
120120
}
121121
loop_until_bit_is_set(SPSR, SPIF);
122122
*dp = SPDR;
@@ -132,13 +132,12 @@ class SPI : public ::SPI {
132132
{
133133
if (count == 0 || buf == NULL) return;
134134
uint8_t* bp = (uint8_t*) buf;
135-
uint8_t value;
136135
SPDR = 0;
137136
while (--count) {
137+
__asm__ __volatile__("nop");
138138
loop_until_bit_is_set(SPSR, SPIF);
139-
value = SPDR;
140139
SPDR = 0;
141-
*bp++ = value;
140+
*bp++ = SPDR;
142141
}
143142
loop_until_bit_is_set(SPSR, SPIF);
144143
*bp = SPDR;

0 commit comments

Comments
 (0)