File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 240240 }
241241
242242 // all the others
243- static uint32_t spiDelayCyclesX4 = 4 * (F_CPU) / 1000000 ; // 4µs => 125khz
243+ static uint16_t spiDelayNS = 4000 ; // 4000ns => 125khz
244244
245245 static uint8_t spiTransferX (uint8_t b) { // using Mode 0
246246 int bits = 8 ;
249249 b <<= 1 ; // little setup time
250250
251251 WRITE (SD_SCK_PIN, HIGH);
252- DELAY_CYCLES (spiDelayCyclesX4 );
252+ DELAY_NS (spiDelayNS );
253253
254254 b |= (READ (SD_MISO_PIN) != 0 );
255255
256256 WRITE (SD_SCK_PIN, LOW);
257- DELAY_CYCLES (spiDelayCyclesX4 );
257+ DELAY_NS (spiDelayNS );
258258 } while (--bits);
259259 return b;
260260 }
510510 spiRxBlock = (pfnSpiRxBlock)spiRxBlockX;
511511 break ;
512512 default :
513- spiDelayCyclesX4 = ((F_CPU) / 1000000 ) >> (6 - spiRate) << 2 ; // spiRate of 2 gives the maximum error with current CPU
513+ spiDelayNS = 4000 >> (6 - spiRate); // spiRate of 2 gives the maximum error with current CPU
514514 spiTransferTx = (pfnSpiTransfer)spiTransferX;
515515 spiTransferRx = (pfnSpiTransfer)spiTransferX;
516516 spiTxBlock = (pfnSpiTxBlock)spiTxBlockX;
You can’t perform that action at this time.
0 commit comments