소스 검색

We only need to test 50 and 25 as the rest are just divided and rounded to full and half.

Eric Helgeson 3 년 전
부모
커밋
1cfaf00594
1개의 변경된 파일12개의 추가작업 그리고 13개의 파일을 삭제
  1. 12 13
      src/BlueSCSI.cpp

+ 12 - 13
src/BlueSCSI.cpp

@@ -371,21 +371,20 @@ void setup()
   //Occurs when the RST pin state changes from HIGH to LOW
   //attachInterrupt(RST, onBusReset, FALLING);
 
-  // Try different clock speeds till we find one that is stable.
+  // Try Full and half clock speeds.
   LED_ON();
-  int mhz = 50;
-  bool sd_ready = false;
-  while (mhz >= 32 && !sd_ready) {
-    if(SD.begin(SdSpiConfig(PA4, DEDICATED_SPI, SD_SCK_MHZ(mhz), &SPI))) {
-      sd_ready = true;
-    }
-    else {
-      mhz--;
-    }
+  int mhz = 0;
+  if (SD.begin(SdSpiConfig(PA4, DEDICATED_SPI, SD_SCK_MHZ(50), &SPI)))
+  {
+    mhz = 50;
+  }
+  else if (SD.begin(SdSpiConfig(PA4, DEDICATED_SPI, SD_SCK_MHZ(25), &SPI)))
+  {
+    mhz = 25;
   }
   LED_OFF();
 
-  if(!sd_ready) {
+  if(mhz == 0) {
 #if DEBUG > 0
     Serial.println("SD initialization failed!");
 #endif
@@ -594,8 +593,8 @@ void initFileLog(int success_mhz) {
   LOG_FILE.print("SPI speed: ");
   LOG_FILE.print(success_mhz);
   LOG_FILE.println("Mhz");
-  if(success_mhz < 40) {
-    LOG_FILE.println("SPI under 40Mhz - read https://github.com/erichelgeson/BlueSCSI/wiki/Slow-SPI");
+  if(success_mhz == 25) {
+    LOG_FILE.println("SPI running at half speed - read https://github.com/erichelgeson/BlueSCSI/wiki/Slow-SPI");
   }
   LOG_FILE.print("SdFat Max FileName Length: ");
   LOG_FILE.println(MAX_FILE_PATH);