瀏覽代碼

Merge pull request #7471 from thinkyhead/bf1_cleanups_aug9

Miscellaneous style tweaks
Scott Lahteine 8 年之前
父節點
當前提交
6172f150c2

+ 9
- 11
Marlin/Conditionals_post.h 查看文件

681
   #endif
681
   #endif
682
   #define WRITE_FAN_N(n, v) WRITE_FAN##n(v)
682
   #define WRITE_FAN_N(n, v) WRITE_FAN##n(v)
683
 
683
 
684
-
685
-  /**
686
-   * Heater & Fan Pausing
687
-   */
688
-  #if FAN_COUNT == 0
689
-    #undef PROBING_FANS_OFF
690
-  #endif
691
-  #define QUIET_PROBING (HAS_BED_PROBE && (ENABLED(PROBING_HEATERS_OFF) || ENABLED(PROBING_FANS_OFF) || DELAY_BEFORE_PROBING > 0))
692
-  #define HEATER_IDLE_HANDLER (ENABLED(ADVANCED_PAUSE_FEATURE) || ENABLED(PROBING_HEATERS_OFF))
693
-
694
   /**
684
   /**
695
    * Servos and probes
685
    * Servos and probes
696
    */
686
    */
702
   #endif
692
   #endif
703
 
693
 
704
   #define PROBE_PIN_CONFIGURED (HAS_Z_MIN_PROBE_PIN || (HAS_Z_MIN && ENABLED(Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN)))
694
   #define PROBE_PIN_CONFIGURED (HAS_Z_MIN_PROBE_PIN || (HAS_Z_MIN && ENABLED(Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN)))
705
-
706
   #define HAS_BED_PROBE (PROBE_SELECTED && PROBE_PIN_CONFIGURED && DISABLED(PROBE_MANUALLY))
695
   #define HAS_BED_PROBE (PROBE_SELECTED && PROBE_PIN_CONFIGURED && DISABLED(PROBE_MANUALLY))
707
 
696
 
708
   #if ENABLED(Z_PROBE_ALLEN_KEY)
697
   #if ENABLED(Z_PROBE_ALLEN_KEY)
744
   #endif
733
   #endif
745
 
734
 
746
   /**
735
   /**
736
+   * Heater & Fan Pausing
737
+   */
738
+  #if FAN_COUNT == 0
739
+    #undef PROBING_FANS_OFF
740
+  #endif
741
+  #define QUIET_PROBING (HAS_BED_PROBE && (ENABLED(PROBING_HEATERS_OFF) || ENABLED(PROBING_FANS_OFF) || DELAY_BEFORE_PROBING > 0))
742
+  #define HEATER_IDLE_HANDLER (ENABLED(ADVANCED_PAUSE_FEATURE) || ENABLED(PROBING_HEATERS_OFF))
743
+
744
+  /**
747
    * Delta radius/rod trimmers/angle trimmers
745
    * Delta radius/rod trimmers/angle trimmers
748
    */
746
    */
749
   #if ENABLED(DELTA)
747
   #if ENABLED(DELTA)

+ 5
- 4
Marlin/Marlin_main.cpp 查看文件

2359
 
2359
 
2360
     const float nx = lx - (X_PROBE_OFFSET_FROM_EXTRUDER), ny = ly - (Y_PROBE_OFFSET_FROM_EXTRUDER);
2360
     const float nx = lx - (X_PROBE_OFFSET_FROM_EXTRUDER), ny = ly - (Y_PROBE_OFFSET_FROM_EXTRUDER);
2361
 
2361
 
2362
-    if (printable) {
2363
-      if (!position_is_reachable_by_probe_xy(lx, ly)) return NAN;
2364
-    }
2365
-    else if (!position_is_reachable_xy(nx, ny)) return NAN;
2362
+    if (printable
2363
+      ? !position_is_reachable_xy(nx, ny)
2364
+      : !position_is_reachable_by_probe_xy(lx, ly)
2365
+    ) return NAN;
2366
+
2366
 
2367
 
2367
     const float old_feedrate_mm_s = feedrate_mm_s;
2368
     const float old_feedrate_mm_s = feedrate_mm_s;
2368
 
2369
 

+ 52
- 52
Marlin/Sd2Card.cpp 查看文件

55
   //------------------------------------------------------------------------------
55
   //------------------------------------------------------------------------------
56
   /** SPI receive a byte */
56
   /** SPI receive a byte */
57
   static uint8_t spiRec() {
57
   static uint8_t spiRec() {
58
-    SPDR = 0XFF;
58
+    SPDR = 0xFF;
59
     while (!TEST(SPSR, SPIF)) { /* Intentionally left empty */ }
59
     while (!TEST(SPSR, SPIF)) { /* Intentionally left empty */ }
60
     return SPDR;
60
     return SPDR;
61
   }
61
   }
64
   static inline __attribute__((always_inline))
64
   static inline __attribute__((always_inline))
65
   void spiRead(uint8_t* buf, uint16_t nbyte) {
65
   void spiRead(uint8_t* buf, uint16_t nbyte) {
66
     if (nbyte-- == 0) return;
66
     if (nbyte-- == 0) return;
67
-    SPDR = 0XFF;
67
+    SPDR = 0xFF;
68
     for (uint16_t i = 0; i < nbyte; i++) {
68
     for (uint16_t i = 0; i < nbyte; i++) {
69
       while (!TEST(SPSR, SPIF)) { /* Intentionally left empty */ }
69
       while (!TEST(SPSR, SPIF)) { /* Intentionally left empty */ }
70
       buf[i] = SPDR;
70
       buf[i] = SPDR;
71
-      SPDR = 0XFF;
71
+      SPDR = 0xFF;
72
     }
72
     }
73
     while (!TEST(SPSR, SPIF)) { /* Intentionally left empty */ }
73
     while (!TEST(SPSR, SPIF)) { /* Intentionally left empty */ }
74
     buf[nbyte] = SPDR;
74
     buf[nbyte] = SPDR;
103
     uint8_t data = 0;
103
     uint8_t data = 0;
104
     // no interrupts during byte receive - about 8 us
104
     // no interrupts during byte receive - about 8 us
105
     cli();
105
     cli();
106
-    // output pin high - like sending 0XFF
106
+    // output pin high - like sending 0xFF
107
     WRITE(SPI_MOSI_PIN, HIGH);
107
     WRITE(SPI_MOSI_PIN, HIGH);
108
 
108
 
109
     for (uint8_t i = 0; i < 8; i++) {
109
     for (uint8_t i = 0; i < 8; i++) {
137
     for (uint8_t i = 0; i < 8; i++) {
137
     for (uint8_t i = 0; i < 8; i++) {
138
       WRITE(SPI_SCK_PIN, LOW);
138
       WRITE(SPI_SCK_PIN, LOW);
139
 
139
 
140
-      WRITE(SPI_MOSI_PIN, data & 0X80);
140
+      WRITE(SPI_MOSI_PIN, data & 0x80);
141
 
141
 
142
       data <<= 1;
142
       data <<= 1;
143
 
143
 
177
   for (int8_t s = 24; s >= 0; s -= 8) spiSend(arg >> s);
177
   for (int8_t s = 24; s >= 0; s -= 8) spiSend(arg >> s);
178
 
178
 
179
   // send CRC
179
   // send CRC
180
-  uint8_t crc = 0XFF;
181
-  if (cmd == CMD0) crc = 0X95;  // correct crc for CMD0 with arg 0
182
-  if (cmd == CMD8) crc = 0X87;  // correct crc for CMD8 with arg 0X1AA
180
+  uint8_t crc = 0xFF;
181
+  if (cmd == CMD0) crc = 0x95;  // correct crc for CMD0 with arg 0
182
+  if (cmd == CMD8) crc = 0x87;  // correct crc for CMD8 with arg 0x1AA
183
   spiSend(crc);
183
   spiSend(crc);
184
 
184
 
185
   // skip stuff byte for stop read
185
   // skip stuff byte for stop read
186
   if (cmd == CMD12) spiRec();
186
   if (cmd == CMD12) spiRec();
187
 
187
 
188
   // wait for response
188
   // wait for response
189
-  for (uint8_t i = 0; ((status_ = spiRec()) & 0X80) && i != 0XFF; i++) { /* Intentionally left empty */ }
189
+  for (uint8_t i = 0; ((status_ = spiRec()) & 0x80) && i != 0xFF; i++) { /* Intentionally left empty */ }
190
   return status_;
190
   return status_;
191
 }
191
 }
192
 //------------------------------------------------------------------------------
192
 //------------------------------------------------------------------------------
244
  */
244
  */
245
 bool Sd2Card::erase(uint32_t firstBlock, uint32_t lastBlock) {
245
 bool Sd2Card::erase(uint32_t firstBlock, uint32_t lastBlock) {
246
   csd_t csd;
246
   csd_t csd;
247
-  if (!readCSD(&csd)) goto fail;
247
+  if (!readCSD(&csd)) goto FAIL;
248
   // check for single block erase
248
   // check for single block erase
249
   if (!csd.v1.erase_blk_en) {
249
   if (!csd.v1.erase_blk_en) {
250
     // erase size mask
250
     // erase size mask
252
     if ((firstBlock & m) != 0 || ((lastBlock + 1) & m) != 0) {
252
     if ((firstBlock & m) != 0 || ((lastBlock + 1) & m) != 0) {
253
       // error card can't erase specified area
253
       // error card can't erase specified area
254
       error(SD_CARD_ERROR_ERASE_SINGLE_BLOCK);
254
       error(SD_CARD_ERROR_ERASE_SINGLE_BLOCK);
255
-      goto fail;
255
+      goto FAIL;
256
     }
256
     }
257
   }
257
   }
258
   if (type_ != SD_CARD_TYPE_SDHC) {
258
   if (type_ != SD_CARD_TYPE_SDHC) {
263
       || cardCommand(CMD33, lastBlock)
263
       || cardCommand(CMD33, lastBlock)
264
       || cardCommand(CMD38, 0)) {
264
       || cardCommand(CMD38, 0)) {
265
     error(SD_CARD_ERROR_ERASE);
265
     error(SD_CARD_ERROR_ERASE);
266
-    goto fail;
266
+    goto FAIL;
267
   }
267
   }
268
   if (!waitNotBusy(SD_ERASE_TIMEOUT)) {
268
   if (!waitNotBusy(SD_ERASE_TIMEOUT)) {
269
     error(SD_CARD_ERROR_ERASE_TIMEOUT);
269
     error(SD_CARD_ERROR_ERASE_TIMEOUT);
270
-    goto fail;
270
+    goto FAIL;
271
   }
271
   }
272
   chipSelectHigh();
272
   chipSelectHigh();
273
   return true;
273
   return true;
274
-fail:
274
+  FAIL:
275
   chipSelectHigh();
275
   chipSelectHigh();
276
   return false;
276
   return false;
277
 }
277
 }
329
   #endif  // SOFTWARE_SPI
329
   #endif  // SOFTWARE_SPI
330
 
330
 
331
   // must supply min of 74 clock cycles with CS high.
331
   // must supply min of 74 clock cycles with CS high.
332
-  for (uint8_t i = 0; i < 10; i++) spiSend(0XFF);
332
+  for (uint8_t i = 0; i < 10; i++) spiSend(0xFF);
333
 
333
 
334
   // command to go idle in SPI mode
334
   // command to go idle in SPI mode
335
   while ((status_ = cardCommand(CMD0, 0)) != R1_IDLE_STATE) {
335
   while ((status_ = cardCommand(CMD0, 0)) != R1_IDLE_STATE) {
336
     if (((uint16_t)millis() - t0) > SD_INIT_TIMEOUT) {
336
     if (((uint16_t)millis() - t0) > SD_INIT_TIMEOUT) {
337
       error(SD_CARD_ERROR_CMD0);
337
       error(SD_CARD_ERROR_CMD0);
338
-      goto fail;
338
+      goto FAIL;
339
     }
339
     }
340
   }
340
   }
341
   // check SD version
341
   // check SD version
345
   else {
345
   else {
346
     // only need last byte of r7 response
346
     // only need last byte of r7 response
347
     for (uint8_t i = 0; i < 4; i++) status_ = spiRec();
347
     for (uint8_t i = 0; i < 4; i++) status_ = spiRec();
348
-    if (status_ != 0XAA) {
348
+    if (status_ != 0xAA) {
349
       error(SD_CARD_ERROR_CMD8);
349
       error(SD_CARD_ERROR_CMD8);
350
-      goto fail;
350
+      goto FAIL;
351
     }
351
     }
352
     type(SD_CARD_TYPE_SD2);
352
     type(SD_CARD_TYPE_SD2);
353
   }
353
   }
354
   // initialize card and send host supports SDHC if SD2
354
   // initialize card and send host supports SDHC if SD2
355
-  arg = type() == SD_CARD_TYPE_SD2 ? 0X40000000 : 0;
355
+  arg = type() == SD_CARD_TYPE_SD2 ? 0x40000000 : 0;
356
 
356
 
357
   while ((status_ = cardAcmd(ACMD41, arg)) != R1_READY_STATE) {
357
   while ((status_ = cardAcmd(ACMD41, arg)) != R1_READY_STATE) {
358
     // check for timeout
358
     // check for timeout
359
     if (((uint16_t)millis() - t0) > SD_INIT_TIMEOUT) {
359
     if (((uint16_t)millis() - t0) > SD_INIT_TIMEOUT) {
360
       error(SD_CARD_ERROR_ACMD41);
360
       error(SD_CARD_ERROR_ACMD41);
361
-      goto fail;
361
+      goto FAIL;
362
     }
362
     }
363
   }
363
   }
364
   // if SD2 read OCR register to check for SDHC card
364
   // if SD2 read OCR register to check for SDHC card
365
   if (type() == SD_CARD_TYPE_SD2) {
365
   if (type() == SD_CARD_TYPE_SD2) {
366
     if (cardCommand(CMD58, 0)) {
366
     if (cardCommand(CMD58, 0)) {
367
       error(SD_CARD_ERROR_CMD58);
367
       error(SD_CARD_ERROR_CMD58);
368
-      goto fail;
368
+      goto FAIL;
369
     }
369
     }
370
-    if ((spiRec() & 0XC0) == 0XC0) type(SD_CARD_TYPE_SDHC);
370
+    if ((spiRec() & 0xC0) == 0xC0) type(SD_CARD_TYPE_SDHC);
371
     // discard rest of ocr - contains allowed voltage range
371
     // discard rest of ocr - contains allowed voltage range
372
     for (uint8_t i = 0; i < 3; i++) spiRec();
372
     for (uint8_t i = 0; i < 3; i++) spiRec();
373
   }
373
   }
380
     return true;
380
     return true;
381
   #endif  // SOFTWARE_SPI
381
   #endif  // SOFTWARE_SPI
382
 
382
 
383
-fail:
383
+  FAIL:
384
   chipSelectHigh();
384
   chipSelectHigh();
385
   return false;
385
   return false;
386
 }
386
 }
473
 static uint16_t CRC_CCITT(const uint8_t* data, size_t n) {
473
 static uint16_t CRC_CCITT(const uint8_t* data, size_t n) {
474
   uint16_t crc = 0;
474
   uint16_t crc = 0;
475
   for (size_t i = 0; i < n; i++) {
475
   for (size_t i = 0; i < n; i++) {
476
-    crc = pgm_read_word(&crctab[(crc >> 8 ^ data[i]) & 0XFF]) ^ (crc << 8);
476
+    crc = pgm_read_word(&crctab[(crc >> 8 ^ data[i]) & 0xFF]) ^ (crc << 8);
477
   }
477
   }
478
   return crc;
478
   return crc;
479
 }
479
 }
486
   while ((status_ = spiRec()) == 0XFF) {
486
   while ((status_ = spiRec()) == 0XFF) {
487
     if (((uint16_t)millis() - t0) > SD_READ_TIMEOUT) {
487
     if (((uint16_t)millis() - t0) > SD_READ_TIMEOUT) {
488
       error(SD_CARD_ERROR_READ_TIMEOUT);
488
       error(SD_CARD_ERROR_READ_TIMEOUT);
489
-      goto fail;
489
+      goto FAIL;
490
     }
490
     }
491
   }
491
   }
492
   if (status_ != DATA_START_BLOCK) {
492
   if (status_ != DATA_START_BLOCK) {
493
     error(SD_CARD_ERROR_READ);
493
     error(SD_CARD_ERROR_READ);
494
-    goto fail;
494
+    goto FAIL;
495
   }
495
   }
496
   // transfer data
496
   // transfer data
497
   spiRead(dst, count);
497
   spiRead(dst, count);
503
     recvCrc |= spiRec();
503
     recvCrc |= spiRec();
504
     if (calcCrc != recvCrc) {
504
     if (calcCrc != recvCrc) {
505
       error(SD_CARD_ERROR_CRC);
505
       error(SD_CARD_ERROR_CRC);
506
-      goto fail;
506
+      goto FAIL;
507
     }
507
     }
508
   }
508
   }
509
 #else
509
 #else
515
   // Send an additional dummy byte, required by Toshiba Flash Air SD Card
515
   // Send an additional dummy byte, required by Toshiba Flash Air SD Card
516
   spiSend(0XFF);
516
   spiSend(0XFF);
517
   return true;
517
   return true;
518
-fail:
518
+  FAIL:
519
   chipSelectHigh();
519
   chipSelectHigh();
520
   // Send an additional dummy byte, required by Toshiba Flash Air SD Card
520
   // Send an additional dummy byte, required by Toshiba Flash Air SD Card
521
   spiSend(0XFF);
521
   spiSend(0XFF);
527
   uint8_t* dst = reinterpret_cast<uint8_t*>(buf);
527
   uint8_t* dst = reinterpret_cast<uint8_t*>(buf);
528
   if (cardCommand(cmd, 0)) {
528
   if (cardCommand(cmd, 0)) {
529
     error(SD_CARD_ERROR_READ_REG);
529
     error(SD_CARD_ERROR_READ_REG);
530
-    goto fail;
530
+    goto FAIL;
531
   }
531
   }
532
   return readData(dst, 16);
532
   return readData(dst, 16);
533
-fail:
533
+  FAIL:
534
   chipSelectHigh();
534
   chipSelectHigh();
535
   return false;
535
   return false;
536
 }
536
 }
549
   if (type() != SD_CARD_TYPE_SDHC) blockNumber <<= 9;
549
   if (type() != SD_CARD_TYPE_SDHC) blockNumber <<= 9;
550
   if (cardCommand(CMD18, blockNumber)) {
550
   if (cardCommand(CMD18, blockNumber)) {
551
     error(SD_CARD_ERROR_CMD18);
551
     error(SD_CARD_ERROR_CMD18);
552
-    goto fail;
552
+    goto FAIL;
553
   }
553
   }
554
   chipSelectHigh();
554
   chipSelectHigh();
555
   return true;
555
   return true;
556
-fail:
556
+  FAIL:
557
   chipSelectHigh();
557
   chipSelectHigh();
558
   return false;
558
   return false;
559
 }
559
 }
567
   chipSelectLow();
567
   chipSelectLow();
568
   if (cardCommand(CMD12, 0)) {
568
   if (cardCommand(CMD12, 0)) {
569
     error(SD_CARD_ERROR_CMD12);
569
     error(SD_CARD_ERROR_CMD12);
570
-    goto fail;
570
+    goto FAIL;
571
   }
571
   }
572
   chipSelectHigh();
572
   chipSelectHigh();
573
   return true;
573
   return true;
574
-fail:
574
+  FAIL:
575
   chipSelectHigh();
575
   chipSelectHigh();
576
   return false;
576
   return false;
577
 }
577
 }
601
 bool Sd2Card::waitNotBusy(uint16_t timeoutMillis) {
601
 bool Sd2Card::waitNotBusy(uint16_t timeoutMillis) {
602
   uint16_t t0 = millis();
602
   uint16_t t0 = millis();
603
   while (spiRec() != 0XFF) {
603
   while (spiRec() != 0XFF) {
604
-    if (((uint16_t)millis() - t0) >= timeoutMillis) goto fail;
604
+    if (((uint16_t)millis() - t0) >= timeoutMillis) goto FAIL;
605
   }
605
   }
606
   return true;
606
   return true;
607
-fail:
607
+  FAIL:
608
   return false;
608
   return false;
609
 }
609
 }
610
 //------------------------------------------------------------------------------
610
 //------------------------------------------------------------------------------
621
   if (type() != SD_CARD_TYPE_SDHC) blockNumber <<= 9;
621
   if (type() != SD_CARD_TYPE_SDHC) blockNumber <<= 9;
622
   if (cardCommand(CMD24, blockNumber)) {
622
   if (cardCommand(CMD24, blockNumber)) {
623
     error(SD_CARD_ERROR_CMD24);
623
     error(SD_CARD_ERROR_CMD24);
624
-    goto fail;
624
+    goto FAIL;
625
   }
625
   }
626
-  if (!writeData(DATA_START_BLOCK, src)) goto fail;
626
+  if (!writeData(DATA_START_BLOCK, src)) goto FAIL;
627
 
627
 
628
   // wait for flash programming to complete
628
   // wait for flash programming to complete
629
   if (!waitNotBusy(SD_WRITE_TIMEOUT)) {
629
   if (!waitNotBusy(SD_WRITE_TIMEOUT)) {
630
     error(SD_CARD_ERROR_WRITE_TIMEOUT);
630
     error(SD_CARD_ERROR_WRITE_TIMEOUT);
631
-    goto fail;
631
+    goto FAIL;
632
   }
632
   }
633
   // response is r2 so get and check two bytes for nonzero
633
   // response is r2 so get and check two bytes for nonzero
634
   if (cardCommand(CMD13, 0) || spiRec()) {
634
   if (cardCommand(CMD13, 0) || spiRec()) {
635
     error(SD_CARD_ERROR_WRITE_PROGRAMMING);
635
     error(SD_CARD_ERROR_WRITE_PROGRAMMING);
636
-    goto fail;
636
+    goto FAIL;
637
   }
637
   }
638
   chipSelectHigh();
638
   chipSelectHigh();
639
   return true;
639
   return true;
640
-fail:
640
+  FAIL:
641
   chipSelectHigh();
641
   chipSelectHigh();
642
   return false;
642
   return false;
643
 }
643
 }
650
 bool Sd2Card::writeData(const uint8_t* src) {
650
 bool Sd2Card::writeData(const uint8_t* src) {
651
   chipSelectLow();
651
   chipSelectLow();
652
   // wait for previous write to finish
652
   // wait for previous write to finish
653
-  if (!waitNotBusy(SD_WRITE_TIMEOUT)) goto fail;
654
-  if (!writeData(WRITE_MULTIPLE_TOKEN, src)) goto fail;
653
+  if (!waitNotBusy(SD_WRITE_TIMEOUT)) goto FAIL;
654
+  if (!writeData(WRITE_MULTIPLE_TOKEN, src)) goto FAIL;
655
   chipSelectHigh();
655
   chipSelectHigh();
656
   return true;
656
   return true;
657
-fail:
657
+  FAIL:
658
   error(SD_CARD_ERROR_WRITE_MULTIPLE);
658
   error(SD_CARD_ERROR_WRITE_MULTIPLE);
659
   chipSelectHigh();
659
   chipSelectHigh();
660
   return false;
660
   return false;
670
   status_ = spiRec();
670
   status_ = spiRec();
671
   if ((status_ & DATA_RES_MASK) != DATA_RES_ACCEPTED) {
671
   if ((status_ & DATA_RES_MASK) != DATA_RES_ACCEPTED) {
672
     error(SD_CARD_ERROR_WRITE);
672
     error(SD_CARD_ERROR_WRITE);
673
-    goto fail;
673
+    goto FAIL;
674
   }
674
   }
675
   return true;
675
   return true;
676
-fail:
676
+  FAIL:
677
   chipSelectHigh();
677
   chipSelectHigh();
678
   return false;
678
   return false;
679
 }
679
 }
693
   // send pre-erase count
693
   // send pre-erase count
694
   if (cardAcmd(ACMD23, eraseCount)) {
694
   if (cardAcmd(ACMD23, eraseCount)) {
695
     error(SD_CARD_ERROR_ACMD23);
695
     error(SD_CARD_ERROR_ACMD23);
696
-    goto fail;
696
+    goto FAIL;
697
   }
697
   }
698
   // use address if not SDHC card
698
   // use address if not SDHC card
699
   if (type() != SD_CARD_TYPE_SDHC) blockNumber <<= 9;
699
   if (type() != SD_CARD_TYPE_SDHC) blockNumber <<= 9;
700
   if (cardCommand(CMD25, blockNumber)) {
700
   if (cardCommand(CMD25, blockNumber)) {
701
     error(SD_CARD_ERROR_CMD25);
701
     error(SD_CARD_ERROR_CMD25);
702
-    goto fail;
702
+    goto FAIL;
703
   }
703
   }
704
   chipSelectHigh();
704
   chipSelectHigh();
705
   return true;
705
   return true;
706
-fail:
706
+  FAIL:
707
   chipSelectHigh();
707
   chipSelectHigh();
708
   return false;
708
   return false;
709
 }
709
 }
715
  */
715
  */
716
 bool Sd2Card::writeStop() {
716
 bool Sd2Card::writeStop() {
717
   chipSelectLow();
717
   chipSelectLow();
718
-  if (!waitNotBusy(SD_WRITE_TIMEOUT)) goto fail;
718
+  if (!waitNotBusy(SD_WRITE_TIMEOUT)) goto FAIL;
719
   spiSend(STOP_TRAN_TOKEN);
719
   spiSend(STOP_TRAN_TOKEN);
720
-  if (!waitNotBusy(SD_WRITE_TIMEOUT)) goto fail;
720
+  if (!waitNotBusy(SD_WRITE_TIMEOUT)) goto FAIL;
721
   chipSelectHigh();
721
   chipSelectHigh();
722
   return true;
722
   return true;
723
-fail:
723
+  FAIL:
724
   error(SD_CARD_ERROR_STOP_TRAN);
724
   error(SD_CARD_ERROR_STOP_TRAN);
725
   chipSelectHigh();
725
   chipSelectHigh();
726
   return false;
726
   return false;

+ 11
- 11
Marlin/Sd2Card.h 查看文件

92
 /** card returned an error token instead of read data */
92
 /** card returned an error token instead of read data */
93
 uint8_t const SD_CARD_ERROR_READ = 0XF;
93
 uint8_t const SD_CARD_ERROR_READ = 0XF;
94
 /** read CID or CSD failed */
94
 /** read CID or CSD failed */
95
-uint8_t const SD_CARD_ERROR_READ_REG = 0X10;
95
+uint8_t const SD_CARD_ERROR_READ_REG = 0x10;
96
 /** timeout while waiting for start of read data */
96
 /** timeout while waiting for start of read data */
97
-uint8_t const SD_CARD_ERROR_READ_TIMEOUT = 0X11;
97
+uint8_t const SD_CARD_ERROR_READ_TIMEOUT = 0x11;
98
 /** card did not accept STOP_TRAN_TOKEN */
98
 /** card did not accept STOP_TRAN_TOKEN */
99
-uint8_t const SD_CARD_ERROR_STOP_TRAN = 0X12;
99
+uint8_t const SD_CARD_ERROR_STOP_TRAN = 0x12;
100
 /** card returned an error token as a response to a write operation */
100
 /** card returned an error token as a response to a write operation */
101
-uint8_t const SD_CARD_ERROR_WRITE = 0X13;
101
+uint8_t const SD_CARD_ERROR_WRITE = 0x13;
102
 /** attempt to write protected block zero */
102
 /** attempt to write protected block zero */
103
-uint8_t const SD_CARD_ERROR_WRITE_BLOCK_ZERO = 0X14;  // REMOVE - not used
103
+uint8_t const SD_CARD_ERROR_WRITE_BLOCK_ZERO = 0x14;  // REMOVE - not used
104
 /** card did not go ready for a multiple block write */
104
 /** card did not go ready for a multiple block write */
105
-uint8_t const SD_CARD_ERROR_WRITE_MULTIPLE = 0X15;
105
+uint8_t const SD_CARD_ERROR_WRITE_MULTIPLE = 0x15;
106
 /** card returned an error to a CMD13 status check after a write */
106
 /** card returned an error to a CMD13 status check after a write */
107
-uint8_t const SD_CARD_ERROR_WRITE_PROGRAMMING = 0X16;
107
+uint8_t const SD_CARD_ERROR_WRITE_PROGRAMMING = 0x16;
108
 /** timeout occurred during write programming */
108
 /** timeout occurred during write programming */
109
-uint8_t const SD_CARD_ERROR_WRITE_TIMEOUT = 0X17;
109
+uint8_t const SD_CARD_ERROR_WRITE_TIMEOUT = 0x17;
110
 /** incorrect rate selected */
110
 /** incorrect rate selected */
111
-uint8_t const SD_CARD_ERROR_SCK_RATE = 0X18;
111
+uint8_t const SD_CARD_ERROR_SCK_RATE = 0x18;
112
 /** init() not called */
112
 /** init() not called */
113
-uint8_t const SD_CARD_ERROR_INIT_NOT_CALLED = 0X19;
113
+uint8_t const SD_CARD_ERROR_INIT_NOT_CALLED = 0x19;
114
 /** crc check error */
114
 /** crc check error */
115
-uint8_t const SD_CARD_ERROR_CRC = 0X20;
115
+uint8_t const SD_CARD_ERROR_CRC = 0x20;
116
 //------------------------------------------------------------------------------
116
 //------------------------------------------------------------------------------
117
 // card types
117
 // card types
118
 /** Standard capacity V1 SD card */
118
 /** Standard capacity V1 SD card */

+ 150
- 150
Marlin/SdBaseFile.cpp
文件差異過大導致無法顯示
查看文件


+ 13
- 13
Marlin/SdBaseFile.h 查看文件

54
 
54
 
55
 // use the gnu style oflag in open()
55
 // use the gnu style oflag in open()
56
 /** open() oflag for reading */
56
 /** open() oflag for reading */
57
-uint8_t const O_READ = 0X01;
57
+uint8_t const O_READ = 0x01;
58
 /** open() oflag - same as O_IN */
58
 /** open() oflag - same as O_IN */
59
 uint8_t const O_RDONLY = O_READ;
59
 uint8_t const O_RDONLY = O_READ;
60
 /** open() oflag for write */
60
 /** open() oflag for write */
61
-uint8_t const O_WRITE = 0X02;
61
+uint8_t const O_WRITE = 0x02;
62
 /** open() oflag - same as O_WRITE */
62
 /** open() oflag - same as O_WRITE */
63
 uint8_t const O_WRONLY = O_WRITE;
63
 uint8_t const O_WRONLY = O_WRITE;
64
 /** open() oflag for reading and writing */
64
 /** open() oflag for reading and writing */
66
 /** open() oflag mask for access modes */
66
 /** open() oflag mask for access modes */
67
 uint8_t const O_ACCMODE = (O_READ | O_WRITE);
67
 uint8_t const O_ACCMODE = (O_READ | O_WRITE);
68
 /** The file offset shall be set to the end of the file prior to each write. */
68
 /** The file offset shall be set to the end of the file prior to each write. */
69
-uint8_t const O_APPEND = 0X04;
69
+uint8_t const O_APPEND = 0x04;
70
 /** synchronous writes - call sync() after each write */
70
 /** synchronous writes - call sync() after each write */
71
-uint8_t const O_SYNC = 0X08;
71
+uint8_t const O_SYNC = 0x08;
72
 /** truncate the file to zero length */
72
 /** truncate the file to zero length */
73
-uint8_t const O_TRUNC = 0X10;
73
+uint8_t const O_TRUNC = 0x10;
74
 /** set the initial position at the end of the file */
74
 /** set the initial position at the end of the file */
75
-uint8_t const O_AT_END = 0X20;
75
+uint8_t const O_AT_END = 0x20;
76
 /** create the file if nonexistent */
76
 /** create the file if nonexistent */
77
-uint8_t const O_CREAT = 0X40;
77
+uint8_t const O_CREAT = 0x40;
78
 /** If O_CREAT and O_EXCL are set, open() shall fail if the file exists */
78
 /** If O_CREAT and O_EXCL are set, open() shall fail if the file exists */
79
-uint8_t const O_EXCL = 0X80;
79
+uint8_t const O_EXCL = 0x80;
80
 
80
 
81
 // SdBaseFile class static and const definitions
81
 // SdBaseFile class static and const definitions
82
 // flags for ls()
82
 // flags for ls()
141
  * \return Extracted day [1,31]
141
  * \return Extracted day [1,31]
142
  */
142
  */
143
 static inline uint8_t FAT_DAY(uint16_t fatDate) {
143
 static inline uint8_t FAT_DAY(uint16_t fatDate) {
144
-  return fatDate & 0X1F;
144
+  return fatDate & 0x1F;
145
 }
145
 }
146
 /** time field for FAT directory entry
146
 /** time field for FAT directory entry
147
  * \param[in] hour [0,23]
147
  * \param[in] hour [0,23]
167
  * \return Extracted minute [0,59]
167
  * \return Extracted minute [0,59]
168
  */
168
  */
169
 static inline uint8_t FAT_MINUTE(uint16_t fatTime) {
169
 static inline uint8_t FAT_MINUTE(uint16_t fatTime) {
170
-  return (fatTime >> 5) & 0X3F;
170
+  return (fatTime >> 5) & 0x3F;
171
 }
171
 }
172
 /** second part of FAT directory time field
172
 /** second part of FAT directory time field
173
  * Note second/2 is stored in packed time.
173
  * Note second/2 is stored in packed time.
177
  * \return Extracted second [0,58]
177
  * \return Extracted second [0,58]
178
  */
178
  */
179
 static inline uint8_t FAT_SECOND(uint16_t fatTime) {
179
 static inline uint8_t FAT_SECOND(uint16_t fatTime) {
180
-  return 2 * (fatTime & 0X1F);
180
+  return 2 * (fatTime & 0x1F);
181
 }
181
 }
182
 /** Default date for file timestamps is 1 Jan 2000 */
182
 /** Default date for file timestamps is 1 Jan 2000 */
183
 uint16_t const FAT_DEFAULT_DATE = ((2000 - 1980) << 9) | (1 << 5) | 1;
183
 uint16_t const FAT_DEFAULT_DATE = ((2000 - 1980) << 9) | (1 << 5) | 1;
338
   // data time callback function
338
   // data time callback function
339
   static void (*dateTime_)(uint16_t* date, uint16_t* time);
339
   static void (*dateTime_)(uint16_t* date, uint16_t* time);
340
   // bits defined in flags_
340
   // bits defined in flags_
341
-  // should be 0X0F
341
+  // should be 0x0F
342
   static uint8_t const F_OFLAG = (O_ACCMODE | O_APPEND | O_SYNC);
342
   static uint8_t const F_OFLAG = (O_ACCMODE | O_APPEND | O_SYNC);
343
   // sync of directory entry required
343
   // sync of directory entry required
344
-  static uint8_t const F_FILE_DIR_DIRTY = 0X80;
344
+  static uint8_t const F_FILE_DIR_DIRTY = 0x80;
345
 
345
 
346
   // private data
346
   // private data
347
   uint8_t   flags_;         // See above for definition of flags_ bits
347
   uint8_t   flags_;         // See above for definition of flags_ bits

+ 36
- 36
Marlin/SdFatStructs.h 查看文件

43
  */
43
  */
44
 //------------------------------------------------------------------------------
44
 //------------------------------------------------------------------------------
45
 /** Value for byte 510 of boot block or MBR */
45
 /** Value for byte 510 of boot block or MBR */
46
-uint8_t const BOOTSIG0 = 0X55;
46
+uint8_t const BOOTSIG0 = 0x55;
47
 /** Value for byte 511 of boot block or MBR */
47
 /** Value for byte 511 of boot block or MBR */
48
-uint8_t const BOOTSIG1 = 0XAA;
48
+uint8_t const BOOTSIG1 = 0xAA;
49
 /** Value for bootSignature field int FAT/FAT32 boot sector */
49
 /** Value for bootSignature field int FAT/FAT32 boot sector */
50
-uint8_t const EXTENDED_BOOT_SIG = 0X29;
50
+uint8_t const EXTENDED_BOOT_SIG = 0x29;
51
 //------------------------------------------------------------------------------
51
 //------------------------------------------------------------------------------
52
 /**
52
 /**
53
  * \struct partitionTable
53
  * \struct partitionTable
59
 struct partitionTable {
59
 struct partitionTable {
60
           /**
60
           /**
61
            * Boot Indicator . Indicates whether the volume is the active
61
            * Boot Indicator . Indicates whether the volume is the active
62
-           * partition.  Legal values include: 0X00. Do not use for booting.
63
-           * 0X80 Active partition.
62
+           * partition.  Legal values include: 0x00. Do not use for booting.
63
+           * 0x80 Active partition.
64
            */
64
            */
65
   uint8_t  boot;
65
   uint8_t  boot;
66
           /**
66
           /**
126
   uint16_t usuallyZero;
126
   uint16_t usuallyZero;
127
            /** Partition tables. */
127
            /** Partition tables. */
128
   part_t   part[4];
128
   part_t   part[4];
129
-           /** First MBR signature byte. Must be 0X55 */
129
+           /** First MBR signature byte. Must be 0x55 */
130
   uint8_t  mbrSig0;
130
   uint8_t  mbrSig0;
131
-           /** Second MBR signature byte. Must be 0XAA */
131
+           /** Second MBR signature byte. Must be 0xAA */
132
   uint8_t  mbrSig1;
132
   uint8_t  mbrSig1;
133
 } PACKED;
133
 } PACKED;
134
 /** Type name for masterBootRecord */
134
 /** Type name for masterBootRecord */
234
   uint8_t  driveNumber;
234
   uint8_t  driveNumber;
235
            /** used by Windows NT - should be zero for FAT */
235
            /** used by Windows NT - should be zero for FAT */
236
   uint8_t  reserved1;
236
   uint8_t  reserved1;
237
-           /** 0X29 if next three fields are valid */
237
+           /** 0x29 if next three fields are valid */
238
   uint8_t  bootSignature;
238
   uint8_t  bootSignature;
239
            /**
239
            /**
240
             * A random serial number created when formatting a disk,
240
             * A random serial number created when formatting a disk,
254
   char     fileSystemType[8];
254
   char     fileSystemType[8];
255
            /** X86 boot code */
255
            /** X86 boot code */
256
   uint8_t  bootCode[448];
256
   uint8_t  bootCode[448];
257
-           /** must be 0X55 */
257
+           /** must be 0x55 */
258
   uint8_t  bootSectorSig0;
258
   uint8_t  bootSectorSig0;
259
-           /** must be 0XAA */
259
+           /** must be 0xAA */
260
   uint8_t  bootSectorSig1;
260
   uint8_t  bootSectorSig1;
261
 } PACKED;
261
 } PACKED;
262
 /** Type name for FAT Boot Sector */
262
 /** Type name for FAT Boot Sector */
389
   uint8_t  driveNumber;
389
   uint8_t  driveNumber;
390
            /** used by Windows NT - should be zero for FAT */
390
            /** used by Windows NT - should be zero for FAT */
391
   uint8_t  reserved1;
391
   uint8_t  reserved1;
392
-           /** 0X29 if next three fields are valid */
392
+           /** 0x29 if next three fields are valid */
393
   uint8_t  bootSignature;
393
   uint8_t  bootSignature;
394
            /**
394
            /**
395
             * A random serial number created when formatting a disk,
395
             * A random serial number created when formatting a disk,
408
   char     fileSystemType[8];
408
   char     fileSystemType[8];
409
            /** X86 boot code */
409
            /** X86 boot code */
410
   uint8_t  bootCode[420];
410
   uint8_t  bootCode[420];
411
-           /** must be 0X55 */
411
+           /** must be 0x55 */
412
   uint8_t  bootSectorSig0;
412
   uint8_t  bootSectorSig0;
413
-           /** must be 0XAA */
413
+           /** must be 0xAA */
414
   uint8_t  bootSectorSig1;
414
   uint8_t  bootSectorSig1;
415
 } PACKED;
415
 } PACKED;
416
 /** Type name for FAT32 Boot Sector */
416
 /** Type name for FAT32 Boot Sector */
427
  *
427
  *
428
  */
428
  */
429
 struct fat32_fsinfo {
429
 struct fat32_fsinfo {
430
-           /** must be 0X52, 0X52, 0X61, 0X41 */
430
+           /** must be 0x52, 0x52, 0x61, 0x41 */
431
   uint32_t  leadSignature;
431
   uint32_t  leadSignature;
432
            /** must be zero */
432
            /** must be zero */
433
   uint8_t  reserved1[480];
433
   uint8_t  reserved1[480];
434
-           /** must be 0X72, 0X72, 0X41, 0X61 */
434
+           /** must be 0x72, 0x72, 0x41, 0x61 */
435
   uint32_t  structSignature;
435
   uint32_t  structSignature;
436
           /**
436
           /**
437
            * Contains the last known free cluster count on the volume.
437
            * Contains the last known free cluster count on the volume.
450
   uint32_t nextFree;
450
   uint32_t nextFree;
451
            /** must be zero */
451
            /** must be zero */
452
   uint8_t  reserved2[12];
452
   uint8_t  reserved2[12];
453
-           /** must be 0X00, 0X00, 0X55, 0XAA */
453
+           /** must be 0x00, 0x00, 0x55, 0xAA */
454
   uint8_t  tailSignature[4];
454
   uint8_t  tailSignature[4];
455
 } PACKED;
455
 } PACKED;
456
 /** Type name for FAT32 FSINFO Sector */
456
 /** Type name for FAT32 FSINFO Sector */
458
 //------------------------------------------------------------------------------
458
 //------------------------------------------------------------------------------
459
 // End Of Chain values for FAT entries
459
 // End Of Chain values for FAT entries
460
 /** FAT12 end of chain value used by Microsoft. */
460
 /** FAT12 end of chain value used by Microsoft. */
461
-uint16_t const FAT12EOC = 0XFFF;
461
+uint16_t const FAT12EOC = 0xFFF;
462
 /** Minimum value for FAT12 EOC.  Use to test for EOC. */
462
 /** Minimum value for FAT12 EOC.  Use to test for EOC. */
463
-uint16_t const FAT12EOC_MIN = 0XFF8;
463
+uint16_t const FAT12EOC_MIN = 0xFF8;
464
 /** FAT16 end of chain value used by Microsoft. */
464
 /** FAT16 end of chain value used by Microsoft. */
465
-uint16_t const FAT16EOC = 0XFFFF;
465
+uint16_t const FAT16EOC = 0xFFFF;
466
 /** Minimum value for FAT16 EOC.  Use to test for EOC. */
466
 /** Minimum value for FAT16 EOC.  Use to test for EOC. */
467
-uint16_t const FAT16EOC_MIN = 0XFFF8;
467
+uint16_t const FAT16EOC_MIN = 0xFFF8;
468
 /** FAT32 end of chain value used by Microsoft. */
468
 /** FAT32 end of chain value used by Microsoft. */
469
-uint32_t const FAT32EOC = 0X0FFFFFFF;
469
+uint32_t const FAT32EOC = 0x0FFFFFFF;
470
 /** Minimum value for FAT32 EOC.  Use to test for EOC. */
470
 /** Minimum value for FAT32 EOC.  Use to test for EOC. */
471
-uint32_t const FAT32EOC_MIN = 0X0FFFFFF8;
471
+uint32_t const FAT32EOC_MIN = 0x0FFFFFF8;
472
 /** Mask a for FAT32 entry. Entries are 28 bits. */
472
 /** Mask a for FAT32 entry. Entries are 28 bits. */
473
-uint32_t const FAT32MASK = 0X0FFFFFFF;
473
+uint32_t const FAT32MASK = 0x0FFFFFFF;
474
 //------------------------------------------------------------------------------
474
 //------------------------------------------------------------------------------
475
 /**
475
 /**
476
  * \struct directoryEntry
476
  * \struct directoryEntry
590
 typedef struct directoryEntry dir_t;
590
 typedef struct directoryEntry dir_t;
591
 /** Type name for directoryVFATEntry */
591
 /** Type name for directoryVFATEntry */
592
 typedef struct directoryVFATEntry vfat_t;
592
 typedef struct directoryVFATEntry vfat_t;
593
-/** escape for name[0] = 0XE5 */
594
-uint8_t const DIR_NAME_0XE5 = 0X05;
593
+/** escape for name[0] = 0xE5 */
594
+uint8_t const DIR_NAME_0xE5 = 0x05;
595
 /** name[0] value for entry that is free after being "deleted" */
595
 /** name[0] value for entry that is free after being "deleted" */
596
-uint8_t const DIR_NAME_DELETED = 0XE5;
596
+uint8_t const DIR_NAME_DELETED = 0xE5;
597
 /** name[0] value for entry that is free and no allocated entries follow */
597
 /** name[0] value for entry that is free and no allocated entries follow */
598
-uint8_t const DIR_NAME_FREE = 0X00;
598
+uint8_t const DIR_NAME_FREE = 0x00;
599
 /** file is read-only */
599
 /** file is read-only */
600
-uint8_t const DIR_ATT_READ_ONLY = 0X01;
600
+uint8_t const DIR_ATT_READ_ONLY = 0x01;
601
 /** File should hidden in directory listings */
601
 /** File should hidden in directory listings */
602
-uint8_t const DIR_ATT_HIDDEN = 0X02;
602
+uint8_t const DIR_ATT_HIDDEN = 0x02;
603
 /** Entry is for a system file */
603
 /** Entry is for a system file */
604
-uint8_t const DIR_ATT_SYSTEM = 0X04;
604
+uint8_t const DIR_ATT_SYSTEM = 0x04;
605
 /** Directory entry contains the volume label */
605
 /** Directory entry contains the volume label */
606
-uint8_t const DIR_ATT_VOLUME_ID = 0X08;
606
+uint8_t const DIR_ATT_VOLUME_ID = 0x08;
607
 /** Entry is for a directory */
607
 /** Entry is for a directory */
608
-uint8_t const DIR_ATT_DIRECTORY = 0X10;
608
+uint8_t const DIR_ATT_DIRECTORY = 0x10;
609
 /** Old DOS archive bit for backup support */
609
 /** Old DOS archive bit for backup support */
610
-uint8_t const DIR_ATT_ARCHIVE = 0X20;
610
+uint8_t const DIR_ATT_ARCHIVE = 0x20;
611
 /** Test value for long name entry.  Test is
611
 /** Test value for long name entry.  Test is
612
   (d->attributes & DIR_ATT_LONG_NAME_MASK) == DIR_ATT_LONG_NAME. */
612
   (d->attributes & DIR_ATT_LONG_NAME_MASK) == DIR_ATT_LONG_NAME. */
613
-uint8_t const DIR_ATT_LONG_NAME = 0X0F;
613
+uint8_t const DIR_ATT_LONG_NAME = 0x0F;
614
 /** Test mask for long name entry */
614
 /** Test mask for long name entry */
615
-uint8_t const DIR_ATT_LONG_NAME_MASK = 0X3F;
615
+uint8_t const DIR_ATT_LONG_NAME_MASK = 0x3F;
616
 /** defined attribute bits */
616
 /** defined attribute bits */
617
-uint8_t const DIR_ATT_DEFINED_BITS = 0X3F;
617
+uint8_t const DIR_ATT_DEFINED_BITS = 0x3F;
618
 /** Directory entry is part of a long name
618
 /** Directory entry is part of a long name
619
  * \param[in] dir Pointer to a directory entry.
619
  * \param[in] dir Pointer to a directory entry.
620
  *
620
  *

+ 26
- 26
Marlin/SdInfo.h 查看文件

45
 //------------------------------------------------------------------------------
45
 //------------------------------------------------------------------------------
46
 // SD card commands
46
 // SD card commands
47
 /** GO_IDLE_STATE - init card in spi mode if CS low */
47
 /** GO_IDLE_STATE - init card in spi mode if CS low */
48
-uint8_t const CMD0 = 0X00;
48
+uint8_t const CMD0 = 0x00;
49
 /** SEND_IF_COND - verify SD Memory Card interface operating condition.*/
49
 /** SEND_IF_COND - verify SD Memory Card interface operating condition.*/
50
-uint8_t const CMD8 = 0X08;
50
+uint8_t const CMD8 = 0x08;
51
 /** SEND_CSD - read the Card Specific Data (CSD register) */
51
 /** SEND_CSD - read the Card Specific Data (CSD register) */
52
-uint8_t const CMD9 = 0X09;
52
+uint8_t const CMD9 = 0x09;
53
 /** SEND_CID - read the card identification information (CID register) */
53
 /** SEND_CID - read the card identification information (CID register) */
54
-uint8_t const CMD10 = 0X0A;
54
+uint8_t const CMD10 = 0x0A;
55
 /** STOP_TRANSMISSION - end multiple block read sequence */
55
 /** STOP_TRANSMISSION - end multiple block read sequence */
56
-uint8_t const CMD12 = 0X0C;
56
+uint8_t const CMD12 = 0x0C;
57
 /** SEND_STATUS - read the card status register */
57
 /** SEND_STATUS - read the card status register */
58
-uint8_t const CMD13 = 0X0D;
58
+uint8_t const CMD13 = 0x0D;
59
 /** READ_SINGLE_BLOCK - read a single data block from the card */
59
 /** READ_SINGLE_BLOCK - read a single data block from the card */
60
-uint8_t const CMD17 = 0X11;
60
+uint8_t const CMD17 = 0x11;
61
 /** READ_MULTIPLE_BLOCK - read a multiple data blocks from the card */
61
 /** READ_MULTIPLE_BLOCK - read a multiple data blocks from the card */
62
-uint8_t const CMD18 = 0X12;
62
+uint8_t const CMD18 = 0x12;
63
 /** WRITE_BLOCK - write a single data block to the card */
63
 /** WRITE_BLOCK - write a single data block to the card */
64
-uint8_t const CMD24 = 0X18;
64
+uint8_t const CMD24 = 0x18;
65
 /** WRITE_MULTIPLE_BLOCK - write blocks of data until a STOP_TRANSMISSION */
65
 /** WRITE_MULTIPLE_BLOCK - write blocks of data until a STOP_TRANSMISSION */
66
-uint8_t const CMD25 = 0X19;
66
+uint8_t const CMD25 = 0x19;
67
 /** ERASE_WR_BLK_START - sets the address of the first block to be erased */
67
 /** ERASE_WR_BLK_START - sets the address of the first block to be erased */
68
-uint8_t const CMD32 = 0X20;
68
+uint8_t const CMD32 = 0x20;
69
 /** ERASE_WR_BLK_END - sets the address of the last block of the continuous
69
 /** ERASE_WR_BLK_END - sets the address of the last block of the continuous
70
     range to be erased*/
70
     range to be erased*/
71
-uint8_t const CMD33 = 0X21;
71
+uint8_t const CMD33 = 0x21;
72
 /** ERASE - erase all previously selected blocks */
72
 /** ERASE - erase all previously selected blocks */
73
-uint8_t const CMD38 = 0X26;
73
+uint8_t const CMD38 = 0x26;
74
 /** APP_CMD - escape for application specific command */
74
 /** APP_CMD - escape for application specific command */
75
-uint8_t const CMD55 = 0X37;
75
+uint8_t const CMD55 = 0x37;
76
 /** READ_OCR - read the OCR register of a card */
76
 /** READ_OCR - read the OCR register of a card */
77
-uint8_t const CMD58 = 0X3A;
77
+uint8_t const CMD58 = 0x3A;
78
 /** SET_WR_BLK_ERASE_COUNT - Set the number of write blocks to be
78
 /** SET_WR_BLK_ERASE_COUNT - Set the number of write blocks to be
79
      pre-erased before writing */
79
      pre-erased before writing */
80
-uint8_t const ACMD23 = 0X17;
80
+uint8_t const ACMD23 = 0x17;
81
 /** SD_SEND_OP_COMD - Sends host capacity support information and
81
 /** SD_SEND_OP_COMD - Sends host capacity support information and
82
     activates the card's initialization process */
82
     activates the card's initialization process */
83
-uint8_t const ACMD41 = 0X29;
83
+uint8_t const ACMD41 = 0x29;
84
 //------------------------------------------------------------------------------
84
 //------------------------------------------------------------------------------
85
 /** status for card in the ready state */
85
 /** status for card in the ready state */
86
-uint8_t const R1_READY_STATE = 0X00;
86
+uint8_t const R1_READY_STATE = 0x00;
87
 /** status for card in the idle state */
87
 /** status for card in the idle state */
88
-uint8_t const R1_IDLE_STATE = 0X01;
88
+uint8_t const R1_IDLE_STATE = 0x01;
89
 /** status bit for illegal command */
89
 /** status bit for illegal command */
90
-uint8_t const R1_ILLEGAL_COMMAND = 0X04;
90
+uint8_t const R1_ILLEGAL_COMMAND = 0x04;
91
 /** start data token for read or write single block*/
91
 /** start data token for read or write single block*/
92
-uint8_t const DATA_START_BLOCK = 0XFE;
92
+uint8_t const DATA_START_BLOCK = 0xFE;
93
 /** stop token for write multiple blocks*/
93
 /** stop token for write multiple blocks*/
94
-uint8_t const STOP_TRAN_TOKEN = 0XFD;
94
+uint8_t const STOP_TRAN_TOKEN = 0xFD;
95
 /** start data token for write multiple blocks*/
95
 /** start data token for write multiple blocks*/
96
-uint8_t const WRITE_MULTIPLE_TOKEN = 0XFC;
96
+uint8_t const WRITE_MULTIPLE_TOKEN = 0xFC;
97
 /** mask for data response tokens after a write block operation */
97
 /** mask for data response tokens after a write block operation */
98
-uint8_t const DATA_RES_MASK = 0X1F;
98
+uint8_t const DATA_RES_MASK = 0x1F;
99
 /** write data accepted token */
99
 /** write data accepted token */
100
-uint8_t const DATA_RES_ACCEPTED = 0X05;
100
+uint8_t const DATA_RES_ACCEPTED = 0x05;
101
 //------------------------------------------------------------------------------
101
 //------------------------------------------------------------------------------
102
 /** Card IDentification (CID) register */
102
 /** Card IDentification (CID) register */
103
 typedef struct CID {
103
 typedef struct CID {
203
   unsigned char reserved1 : 6;
203
   unsigned char reserved1 : 6;
204
   unsigned char csd_ver : 2;
204
   unsigned char csd_ver : 2;
205
   // byte 1
205
   // byte 1
206
-  /** fixed to 0X0E */
206
+  /** fixed to 0x0E */
207
   unsigned char taac;
207
   unsigned char taac;
208
   // byte 2
208
   // byte 2
209
   /** fixed to 0 */
209
   /** fixed to 0 */

+ 48
- 48
Marlin/SdVolume.cpp 查看文件

73
   // search the FAT for free clusters
73
   // search the FAT for free clusters
74
   for (uint32_t n = 0;; n++, endCluster++) {
74
   for (uint32_t n = 0;; n++, endCluster++) {
75
     // can't find space checked all clusters
75
     // can't find space checked all clusters
76
-    if (n >= clusterCount_) goto fail;
76
+    if (n >= clusterCount_) goto FAIL;
77
 
77
 
78
     // past end - start from beginning of FAT
78
     // past end - start from beginning of FAT
79
     if (endCluster > fatEnd) {
79
     if (endCluster > fatEnd) {
80
       bgnCluster = endCluster = 2;
80
       bgnCluster = endCluster = 2;
81
     }
81
     }
82
     uint32_t f;
82
     uint32_t f;
83
-    if (!fatGet(endCluster, &f)) goto fail;
83
+    if (!fatGet(endCluster, &f)) goto FAIL;
84
 
84
 
85
     if (f != 0) {
85
     if (f != 0) {
86
       // cluster in use try next cluster as bgnCluster
86
       // cluster in use try next cluster as bgnCluster
92
     }
92
     }
93
   }
93
   }
94
   // mark end of chain
94
   // mark end of chain
95
-  if (!fatPutEOC(endCluster)) goto fail;
95
+  if (!fatPutEOC(endCluster)) goto FAIL;
96
 
96
 
97
   // link clusters
97
   // link clusters
98
   while (endCluster > bgnCluster) {
98
   while (endCluster > bgnCluster) {
99
-    if (!fatPut(endCluster - 1, endCluster)) goto fail;
99
+    if (!fatPut(endCluster - 1, endCluster)) goto FAIL;
100
     endCluster--;
100
     endCluster--;
101
   }
101
   }
102
   if (*curCluster != 0) {
102
   if (*curCluster != 0) {
103
     // connect chains
103
     // connect chains
104
-    if (!fatPut(*curCluster, bgnCluster)) goto fail;
104
+    if (!fatPut(*curCluster, bgnCluster)) goto FAIL;
105
   }
105
   }
106
   // return first cluster number to caller
106
   // return first cluster number to caller
107
   *curCluster = bgnCluster;
107
   *curCluster = bgnCluster;
110
   if (setStart) allocSearchStart_ = bgnCluster + 1;
110
   if (setStart) allocSearchStart_ = bgnCluster + 1;
111
 
111
 
112
   return true;
112
   return true;
113
-fail:
113
+  FAIL:
114
   return false;
114
   return false;
115
 }
115
 }
116
 //------------------------------------------------------------------------------
116
 //------------------------------------------------------------------------------
117
 bool SdVolume::cacheFlush() {
117
 bool SdVolume::cacheFlush() {
118
   if (cacheDirty_) {
118
   if (cacheDirty_) {
119
     if (!sdCard_->writeBlock(cacheBlockNumber_, cacheBuffer_.data)) {
119
     if (!sdCard_->writeBlock(cacheBlockNumber_, cacheBuffer_.data)) {
120
-      goto fail;
120
+      goto FAIL;
121
     }
121
     }
122
     // mirror FAT tables
122
     // mirror FAT tables
123
     if (cacheMirrorBlock_) {
123
     if (cacheMirrorBlock_) {
124
       if (!sdCard_->writeBlock(cacheMirrorBlock_, cacheBuffer_.data)) {
124
       if (!sdCard_->writeBlock(cacheMirrorBlock_, cacheBuffer_.data)) {
125
-        goto fail;
125
+        goto FAIL;
126
       }
126
       }
127
       cacheMirrorBlock_ = 0;
127
       cacheMirrorBlock_ = 0;
128
     }
128
     }
129
     cacheDirty_ = 0;
129
     cacheDirty_ = 0;
130
   }
130
   }
131
   return true;
131
   return true;
132
-fail:
132
+  FAIL:
133
   return false;
133
   return false;
134
 }
134
 }
135
 //------------------------------------------------------------------------------
135
 //------------------------------------------------------------------------------
136
 bool SdVolume::cacheRawBlock(uint32_t blockNumber, bool dirty) {
136
 bool SdVolume::cacheRawBlock(uint32_t blockNumber, bool dirty) {
137
   if (cacheBlockNumber_ != blockNumber) {
137
   if (cacheBlockNumber_ != blockNumber) {
138
-    if (!cacheFlush()) goto fail;
139
-    if (!sdCard_->readBlock(blockNumber, cacheBuffer_.data)) goto fail;
138
+    if (!cacheFlush()) goto FAIL;
139
+    if (!sdCard_->readBlock(blockNumber, cacheBuffer_.data)) goto FAIL;
140
     cacheBlockNumber_ = blockNumber;
140
     cacheBlockNumber_ = blockNumber;
141
   }
141
   }
142
   if (dirty) cacheDirty_ = true;
142
   if (dirty) cacheDirty_ = true;
143
   return true;
143
   return true;
144
-fail:
144
+  FAIL:
145
   return false;
145
   return false;
146
 }
146
 }
147
 //------------------------------------------------------------------------------
147
 //------------------------------------------------------------------------------
149
 bool SdVolume::chainSize(uint32_t cluster, uint32_t* size) {
149
 bool SdVolume::chainSize(uint32_t cluster, uint32_t* size) {
150
   uint32_t s = 0;
150
   uint32_t s = 0;
151
   do {
151
   do {
152
-    if (!fatGet(cluster, &cluster)) goto fail;
152
+    if (!fatGet(cluster, &cluster)) goto FAIL;
153
     s += 512UL << clusterSizeShift_;
153
     s += 512UL << clusterSizeShift_;
154
   } while (!isEOC(cluster));
154
   } while (!isEOC(cluster));
155
   *size = s;
155
   *size = s;
156
   return true;
156
   return true;
157
-fail:
157
+  FAIL:
158
   return false;
158
   return false;
159
 }
159
 }
160
 //------------------------------------------------------------------------------
160
 //------------------------------------------------------------------------------
161
 // Fetch a FAT entry
161
 // Fetch a FAT entry
162
 bool SdVolume::fatGet(uint32_t cluster, uint32_t* value) {
162
 bool SdVolume::fatGet(uint32_t cluster, uint32_t* value) {
163
   uint32_t lba;
163
   uint32_t lba;
164
-  if (cluster > (clusterCount_ + 1)) goto fail;
164
+  if (cluster > (clusterCount_ + 1)) goto FAIL;
165
   if (FAT12_SUPPORT && fatType_ == 12) {
165
   if (FAT12_SUPPORT && fatType_ == 12) {
166
     uint16_t index = cluster;
166
     uint16_t index = cluster;
167
     index += index >> 1;
167
     index += index >> 1;
168
     lba = fatStartBlock_ + (index >> 9);
168
     lba = fatStartBlock_ + (index >> 9);
169
-    if (!cacheRawBlock(lba, CACHE_FOR_READ)) goto fail;
170
-    index &= 0X1FF;
169
+    if (!cacheRawBlock(lba, CACHE_FOR_READ)) goto FAIL;
170
+    index &= 0x1FF;
171
     uint16_t tmp = cacheBuffer_.data[index];
171
     uint16_t tmp = cacheBuffer_.data[index];
172
     index++;
172
     index++;
173
     if (index == 512) {
173
     if (index == 512) {
174
-      if (!cacheRawBlock(lba + 1, CACHE_FOR_READ)) goto fail;
174
+      if (!cacheRawBlock(lba + 1, CACHE_FOR_READ)) goto FAIL;
175
       index = 0;
175
       index = 0;
176
     }
176
     }
177
     tmp |= cacheBuffer_.data[index] << 8;
177
     tmp |= cacheBuffer_.data[index] << 8;
178
-    *value = cluster & 1 ? tmp >> 4 : tmp & 0XFFF;
178
+    *value = cluster & 1 ? tmp >> 4 : tmp & 0xFFF;
179
     return true;
179
     return true;
180
   }
180
   }
181
   if (fatType_ == 16) {
181
   if (fatType_ == 16) {
185
     lba = fatStartBlock_ + (cluster >> 7);
185
     lba = fatStartBlock_ + (cluster >> 7);
186
   }
186
   }
187
   else {
187
   else {
188
-    goto fail;
188
+    goto FAIL;
189
   }
189
   }
190
   if (lba != cacheBlockNumber_) {
190
   if (lba != cacheBlockNumber_) {
191
-    if (!cacheRawBlock(lba, CACHE_FOR_READ)) goto fail;
191
+    if (!cacheRawBlock(lba, CACHE_FOR_READ)) goto FAIL;
192
   }
192
   }
193
   if (fatType_ == 16) {
193
   if (fatType_ == 16) {
194
-    *value = cacheBuffer_.fat16[cluster & 0XFF];
194
+    *value = cacheBuffer_.fat16[cluster & 0xFF];
195
   }
195
   }
196
   else {
196
   else {
197
-    *value = cacheBuffer_.fat32[cluster & 0X7F] & FAT32MASK;
197
+    *value = cacheBuffer_.fat32[cluster & 0x7F] & FAT32MASK;
198
   }
198
   }
199
   return true;
199
   return true;
200
-fail:
200
+  FAIL:
201
   return false;
201
   return false;
202
 }
202
 }
203
 //------------------------------------------------------------------------------
203
 //------------------------------------------------------------------------------
205
 bool SdVolume::fatPut(uint32_t cluster, uint32_t value) {
205
 bool SdVolume::fatPut(uint32_t cluster, uint32_t value) {
206
   uint32_t lba;
206
   uint32_t lba;
207
   // error if reserved cluster
207
   // error if reserved cluster
208
-  if (cluster < 2) goto fail;
208
+  if (cluster < 2) goto FAIL;
209
 
209
 
210
   // error if not in FAT
210
   // error if not in FAT
211
-  if (cluster > (clusterCount_ + 1)) goto fail;
211
+  if (cluster > (clusterCount_ + 1)) goto FAIL;
212
 
212
 
213
   if (FAT12_SUPPORT && fatType_ == 12) {
213
   if (FAT12_SUPPORT && fatType_ == 12) {
214
     uint16_t index = cluster;
214
     uint16_t index = cluster;
215
     index += index >> 1;
215
     index += index >> 1;
216
     lba = fatStartBlock_ + (index >> 9);
216
     lba = fatStartBlock_ + (index >> 9);
217
-    if (!cacheRawBlock(lba, CACHE_FOR_WRITE)) goto fail;
217
+    if (!cacheRawBlock(lba, CACHE_FOR_WRITE)) goto FAIL;
218
     // mirror second FAT
218
     // mirror second FAT
219
     if (fatCount_ > 1) cacheMirrorBlock_ = lba + blocksPerFat_;
219
     if (fatCount_ > 1) cacheMirrorBlock_ = lba + blocksPerFat_;
220
-    index &= 0X1FF;
220
+    index &= 0x1FF;
221
     uint8_t tmp = value;
221
     uint8_t tmp = value;
222
     if (cluster & 1) {
222
     if (cluster & 1) {
223
       tmp = (cacheBuffer_.data[index] & 0XF) | tmp << 4;
223
       tmp = (cacheBuffer_.data[index] & 0XF) | tmp << 4;
227
     if (index == 512) {
227
     if (index == 512) {
228
       lba++;
228
       lba++;
229
       index = 0;
229
       index = 0;
230
-      if (!cacheRawBlock(lba, CACHE_FOR_WRITE)) goto fail;
230
+      if (!cacheRawBlock(lba, CACHE_FOR_WRITE)) goto FAIL;
231
       // mirror second FAT
231
       // mirror second FAT
232
       if (fatCount_ > 1) cacheMirrorBlock_ = lba + blocksPerFat_;
232
       if (fatCount_ > 1) cacheMirrorBlock_ = lba + blocksPerFat_;
233
     }
233
     }
234
     tmp = value >> 4;
234
     tmp = value >> 4;
235
     if (!(cluster & 1)) {
235
     if (!(cluster & 1)) {
236
-      tmp = ((cacheBuffer_.data[index] & 0XF0)) | tmp >> 4;
236
+      tmp = ((cacheBuffer_.data[index] & 0xF0)) | tmp >> 4;
237
     }
237
     }
238
     cacheBuffer_.data[index] = tmp;
238
     cacheBuffer_.data[index] = tmp;
239
     return true;
239
     return true;
245
     lba = fatStartBlock_ + (cluster >> 7);
245
     lba = fatStartBlock_ + (cluster >> 7);
246
   }
246
   }
247
   else {
247
   else {
248
-    goto fail;
248
+    goto FAIL;
249
   }
249
   }
250
-  if (!cacheRawBlock(lba, CACHE_FOR_WRITE)) goto fail;
250
+  if (!cacheRawBlock(lba, CACHE_FOR_WRITE)) goto FAIL;
251
   // store entry
251
   // store entry
252
   if (fatType_ == 16) {
252
   if (fatType_ == 16) {
253
-    cacheBuffer_.fat16[cluster & 0XFF] = value;
253
+    cacheBuffer_.fat16[cluster & 0xFF] = value;
254
   }
254
   }
255
   else {
255
   else {
256
-    cacheBuffer_.fat32[cluster & 0X7F] = value;
256
+    cacheBuffer_.fat32[cluster & 0x7F] = value;
257
   }
257
   }
258
   // mirror second FAT
258
   // mirror second FAT
259
   if (fatCount_ > 1) cacheMirrorBlock_ = lba + blocksPerFat_;
259
   if (fatCount_ > 1) cacheMirrorBlock_ = lba + blocksPerFat_;
260
   return true;
260
   return true;
261
-fail:
261
+  FAIL:
262
   return false;
262
   return false;
263
 }
263
 }
264
 //------------------------------------------------------------------------------
264
 //------------------------------------------------------------------------------
270
   allocSearchStart_ = 2;
270
   allocSearchStart_ = 2;
271
 
271
 
272
   do {
272
   do {
273
-    if (!fatGet(cluster, &next)) goto fail;
273
+    if (!fatGet(cluster, &next)) goto FAIL;
274
 
274
 
275
     // free cluster
275
     // free cluster
276
-    if (!fatPut(cluster, 0)) goto fail;
276
+    if (!fatPut(cluster, 0)) goto FAIL;
277
 
277
 
278
     cluster = next;
278
     cluster = next;
279
   } while (!isEOC(cluster));
279
   } while (!isEOC(cluster));
280
 
280
 
281
   return true;
281
   return true;
282
-fail:
282
+  FAIL:
283
   return false;
283
   return false;
284
 }
284
 }
285
 //------------------------------------------------------------------------------
285
 //------------------------------------------------------------------------------
344
   allocSearchStart_ = 2;
344
   allocSearchStart_ = 2;
345
   cacheDirty_ = 0;  // cacheFlush() will write block if true
345
   cacheDirty_ = 0;  // cacheFlush() will write block if true
346
   cacheMirrorBlock_ = 0;
346
   cacheMirrorBlock_ = 0;
347
-  cacheBlockNumber_ = 0XFFFFFFFF;
347
+  cacheBlockNumber_ = 0xFFFFFFFF;
348
 
348
 
349
   // if part == 0 assume super floppy with FAT boot sector in block zero
349
   // if part == 0 assume super floppy with FAT boot sector in block zero
350
   // if part > 0 assume mbr volume with partition table
350
   // if part > 0 assume mbr volume with partition table
351
   if (part) {
351
   if (part) {
352
-    if (part > 4)goto fail;
353
-    if (!cacheRawBlock(volumeStartBlock, CACHE_FOR_READ)) goto fail;
352
+    if (part > 4)goto FAIL;
353
+    if (!cacheRawBlock(volumeStartBlock, CACHE_FOR_READ)) goto FAIL;
354
     part_t* p = &cacheBuffer_.mbr.part[part - 1];
354
     part_t* p = &cacheBuffer_.mbr.part[part - 1];
355
-    if ((p->boot & 0X7F) != 0  ||
355
+    if ((p->boot & 0x7F) != 0  ||
356
         p->totalSectors < 100 ||
356
         p->totalSectors < 100 ||
357
         p->firstSector == 0) {
357
         p->firstSector == 0) {
358
       // not a valid partition
358
       // not a valid partition
359
-      goto fail;
359
+      goto FAIL;
360
     }
360
     }
361
     volumeStartBlock = p->firstSector;
361
     volumeStartBlock = p->firstSector;
362
   }
362
   }
363
-  if (!cacheRawBlock(volumeStartBlock, CACHE_FOR_READ)) goto fail;
363
+  if (!cacheRawBlock(volumeStartBlock, CACHE_FOR_READ)) goto FAIL;
364
   fbs = &cacheBuffer_.fbs32;
364
   fbs = &cacheBuffer_.fbs32;
365
   if (fbs->bytesPerSector != 512 ||
365
   if (fbs->bytesPerSector != 512 ||
366
       fbs->fatCount == 0 ||
366
       fbs->fatCount == 0 ||
367
       fbs->reservedSectorCount == 0 ||
367
       fbs->reservedSectorCount == 0 ||
368
       fbs->sectorsPerCluster == 0) {
368
       fbs->sectorsPerCluster == 0) {
369
     // not valid FAT volume
369
     // not valid FAT volume
370
-    goto fail;
370
+    goto FAIL;
371
   }
371
   }
372
   fatCount_ = fbs->fatCount;
372
   fatCount_ = fbs->fatCount;
373
   blocksPerCluster_ = fbs->sectorsPerCluster;
373
   blocksPerCluster_ = fbs->sectorsPerCluster;
375
   clusterSizeShift_ = 0;
375
   clusterSizeShift_ = 0;
376
   while (blocksPerCluster_ != _BV(clusterSizeShift_)) {
376
   while (blocksPerCluster_ != _BV(clusterSizeShift_)) {
377
     // error if not power of 2
377
     // error if not power of 2
378
-    if (clusterSizeShift_++ > 7) goto fail;
378
+    if (clusterSizeShift_++ > 7) goto FAIL;
379
   }
379
   }
380
   blocksPerFat_ = fbs->sectorsPerFat16 ?
380
   blocksPerFat_ = fbs->sectorsPerFat16 ?
381
                   fbs->sectorsPerFat16 : fbs->sectorsPerFat32;
381
                   fbs->sectorsPerFat16 : fbs->sectorsPerFat32;
404
   // FAT type is determined by cluster count
404
   // FAT type is determined by cluster count
405
   if (clusterCount_ < 4085) {
405
   if (clusterCount_ < 4085) {
406
     fatType_ = 12;
406
     fatType_ = 12;
407
-    if (!FAT12_SUPPORT) goto fail;
407
+    if (!FAT12_SUPPORT) goto FAIL;
408
   }
408
   }
409
   else if (clusterCount_ < 65525) {
409
   else if (clusterCount_ < 65525) {
410
     fatType_ = 16;
410
     fatType_ = 16;
414
     fatType_ = 32;
414
     fatType_ = 32;
415
   }
415
   }
416
   return true;
416
   return true;
417
-fail:
417
+  FAIL:
418
   return false;
418
   return false;
419
 }
419
 }
420
 #endif
420
 #endif

+ 1
- 1
Marlin/SdVolume.h 查看文件

76
    */
76
    */
77
   cache_t* cacheClear() {
77
   cache_t* cacheClear() {
78
     if (!cacheFlush()) return 0;
78
     if (!cacheFlush()) return 0;
79
-    cacheBlockNumber_ = 0XFFFFFFFF;
79
+    cacheBlockNumber_ = 0xFFFFFFFF;
80
     return &cacheBuffer_;
80
     return &cacheBuffer_;
81
   }
81
   }
82
   /** Initialize a FAT volume.  Try partition one first then try super
82
   /** Initialize a FAT volume.  Try partition one first then try super

+ 1
- 1
Marlin/example_configurations/Creality/CR-10/Configuration.h 查看文件

74
 // User-specified version info of this build to display in [Pronterface, etc] terminal window during
74
 // User-specified version info of this build to display in [Pronterface, etc] terminal window during
75
 // startup. Implementation of an idea by Prof Braino to inform user that any changes made to this
75
 // startup. Implementation of an idea by Prof Braino to inform user that any changes made to this
76
 // build by the user have been successfully uploaded into firmware.
76
 // build by the user have been successfully uploaded into firmware.
77
-#define STRING_CONFIG_H_AUTHOR "(none, default config)" // Who made the changes.
77
+#define STRING_CONFIG_H_AUTHOR "(Creality CR-10)" // Who made the changes.
78
 #define SHOW_BOOTSCREEN
78
 #define SHOW_BOOTSCREEN
79
 #define STRING_SPLASH_LINE1 SHORT_BUILD_VERSION // will be shown during bootup in line 1
79
 #define STRING_SPLASH_LINE1 SHORT_BUILD_VERSION // will be shown during bootup in line 1
80
 //#define STRING_SPLASH_LINE2 WEBSITE_URL         // will be shown during bootup in line 2
80
 //#define STRING_SPLASH_LINE2 WEBSITE_URL         // will be shown during bootup in line 2

+ 1
- 1
Marlin/pca9632.cpp 查看文件

45
 #define PCA9632_PWM3        0x05
45
 #define PCA9632_PWM3        0x05
46
 #define PCA9632_GRPPWM      0x06
46
 #define PCA9632_GRPPWM      0x06
47
 #define PCA9632_GRPFREQ     0x07
47
 #define PCA9632_GRPFREQ     0x07
48
-#define PCA9632_LEDOUT      0X08
48
+#define PCA9632_LEDOUT      0x08
49
 #define PCA9632_SUBADR1     0x09
49
 #define PCA9632_SUBADR1     0x09
50
 #define PCA9632_SUBADR2     0x0A
50
 #define PCA9632_SUBADR2     0x0A
51
 #define PCA9632_SUBADR3     0x0B
51
 #define PCA9632_SUBADR3     0x0B

+ 1
- 1
Marlin/pins_MELZI_CREALITY.h 查看文件

24
  * Melzi (Creality) pin assignments
24
  * Melzi (Creality) pin assignments
25
  */
25
  */
26
 
26
 
27
-#define BOARD_NAME "Melzi Creality"
27
+#define BOARD_NAME "Melzi (Creality)"
28
 
28
 
29
 #ifdef __AVR_ATmega1284P__
29
 #ifdef __AVR_ATmega1284P__
30
   #define LARGE_FLASH true
30
   #define LARGE_FLASH true

+ 1
- 1
Marlin/pins_MELZI_MAKR3D.h 查看文件

24
  * Melzi with ATmega1284 (MaKr3d version) pin assignments
24
  * Melzi with ATmega1284 (MaKr3d version) pin assignments
25
  */
25
  */
26
 
26
 
27
-#define BOARD_NAME "Melzi ATmega1284"
27
+#define BOARD_NAME "Melzi (ATmega1284)"
28
 
28
 
29
 #ifdef __AVR_ATmega1284P__
29
 #ifdef __AVR_ATmega1284P__
30
   #define LARGE_FLASH true
30
   #define LARGE_FLASH true

+ 3
- 3
Marlin/softspi.h 查看文件

455
 static inline __attribute__((always_inline))
455
 static inline __attribute__((always_inline))
456
 void fastBitWriteSafe(volatile uint8_t* address, uint8_t bit, bool level) {
456
 void fastBitWriteSafe(volatile uint8_t* address, uint8_t bit, bool level) {
457
   uint8_t oldSREG;
457
   uint8_t oldSREG;
458
-  if (address > (uint8_t*)0X5F) {
458
+  if (address > (uint8_t*)0x5F) {
459
     oldSREG = SREG;
459
     oldSREG = SREG;
460
     cli();
460
     cli();
461
   }
461
   }
464
   } else {
464
   } else {
465
     *address &= ~(1 << bit);
465
     *address &= ~(1 << bit);
466
   }
466
   }
467
-  if (address > (uint8_t*)0X5F) {
467
+  if (address > (uint8_t*)0x5F) {
468
     SREG = oldSREG;
468
     SREG = oldSREG;
469
   }
469
   }
470
 }
470
 }
488
 static inline __attribute__((always_inline))
488
 static inline __attribute__((always_inline))
489
 void fastDigitalToggle(uint8_t pin) {
489
 void fastDigitalToggle(uint8_t pin) {
490
   badPinCheck(pin);
490
   badPinCheck(pin);
491
-    if (pinMap[pin].pin > (uint8_t*)0X5F) {
491
+    if (pinMap[pin].pin > (uint8_t*)0x5F) {
492
       // must write bit to high address port
492
       // must write bit to high address port
493
       *pinMap[pin].pin = 1 << pinMap[pin].bit;
493
       *pinMap[pin].pin = 1 << pinMap[pin].bit;
494
     } else {
494
     } else {

+ 9
- 4
Marlin/ultralcd.cpp 查看文件

2720
 
2720
 
2721
   screenFunc_t _manual_move_func_ptr;
2721
   screenFunc_t _manual_move_func_ptr;
2722
 
2722
 
2723
-  void lcd_move_menu_10mm() { move_menu_scale = 10.0; lcd_goto_screen(_manual_move_func_ptr); }
2724
-  void lcd_move_menu_1mm()  { move_menu_scale =  1.0; lcd_goto_screen(_manual_move_func_ptr); }
2725
-  void lcd_move_menu_01mm() { move_menu_scale =  0.1; lcd_goto_screen(_manual_move_func_ptr); }
2723
+  void _goto_manual_move(const float scale) {
2724
+    defer_return_to_status = true;
2725
+    move_menu_scale = scale;
2726
+    lcd_goto_screen(_manual_move_func_ptr);
2727
+  }
2728
+  void lcd_move_menu_10mm() { _goto_manual_move(10.0); }
2729
+  void lcd_move_menu_1mm()  { _goto_manual_move( 1.0); }
2730
+  void lcd_move_menu_01mm() { _goto_manual_move( 0.1); }
2726
 
2731
 
2727
-  void _lcd_move_distance_menu(AxisEnum axis, screenFunc_t func) {
2732
+  void _lcd_move_distance_menu(const AxisEnum axis, const screenFunc_t func) {
2728
     _manual_move_func_ptr = func;
2733
     _manual_move_func_ptr = func;
2729
     START_MENU();
2734
     START_MENU();
2730
     if (LCD_HEIGHT >= 4) {
2735
     if (LCD_HEIGHT >= 4) {

Loading…
取消
儲存