瀏覽代碼

[2.0.x] Squelch compiler warnings seen with -Wall (#11889)

Marcio Teixeira 6 年之前
父節點
當前提交
c411e7eb0d

+ 62
- 95
Marlin/src/HAL/HAL_DUE/EepromEmulation_Due.cpp 查看文件

41
 #define EEPROMSize     4096
41
 #define EEPROMSize     4096
42
 #define PagesPerGroup   128
42
 #define PagesPerGroup   128
43
 #define GroupCount        2
43
 #define GroupCount        2
44
-#define PageSize        256
44
+#define PageSize        256u
45
 
45
 
46
  /* Flash storage */
46
  /* Flash storage */
47
 typedef struct FLASH_SECTOR {
47
 typedef struct FLASH_SECTOR {
109
   return (const FLASH_SECTOR_T*)&flashStorage[page*PageSize];
109
   return (const FLASH_SECTOR_T*)&flashStorage[page*PageSize];
110
 }
110
 }
111
 
111
 
112
-static uint8_t buffer[256] = {0};   // The RAM buffer to accumulate writes
113
-static uint8_t curPage = 0;         // Current FLASH page inside the group
114
-static uint8_t curGroup = 0xFF;     // Current FLASH group
112
+static uint8_t buffer[256] = {0},   // The RAM buffer to accumulate writes
113
+               curPage = 0,         // Current FLASH page inside the group
114
+               curGroup = 0xFF;     // Current FLASH group
115
 
115
 
116
 //#define EE_EMU_DEBUG
116
 //#define EE_EMU_DEBUG
117
 #ifdef EE_EMU_DEBUG
117
 #ifdef EE_EMU_DEBUG
125
 
125
 
126
     char* p = &buffer[0];
126
     char* p = &buffer[0];
127
     for (int i = 0; i< PageSize; ++i) {
127
     for (int i = 0; i< PageSize; ++i) {
128
-      if ((i & 15) == 0) {
129
-        p += sprintf(p,"%04x] ",i);
130
-      }
128
+      if ((i & 0xF) == 0) p += sprintf(p,"%04x] ", i);
131
 
129
 
132
-      p += sprintf(p," %02x",c[i]);
133
-      if ((i & 15) == 15) {
130
+      p += sprintf(p," %02x", c[i]);
131
+      if ((i & 0xF) == 0xF) {
134
         *p++ = '\n';
132
         *p++ = '\n';
135
         *p = 0;
133
         *p = 0;
136
         SERIAL_PROTOCOL(buffer);
134
         SERIAL_PROTOCOL(buffer);
160
 __attribute__ ((long_call, section (".ramfunc")))
158
 __attribute__ ((long_call, section (".ramfunc")))
161
 static bool ee_PageWrite(uint16_t page,const void* data) {
159
 static bool ee_PageWrite(uint16_t page,const void* data) {
162
 
160
 
163
-  int i;
161
+  uint16_t i;
164
   uint32_t addrflash = ((uint32_t)getFlashStorage(page));
162
   uint32_t addrflash = ((uint32_t)getFlashStorage(page));
165
 
163
 
166
   // Read the flash contents
164
   // Read the flash contents
173
   // Programming mode works only with 128-bit (or higher) boundaries. It cannot
171
   // Programming mode works only with 128-bit (or higher) boundaries. It cannot
174
   // be used with boundaries lower than 128 bits (8, 16 or 32-bit for example)."
172
   // be used with boundaries lower than 128 bits (8, 16 or 32-bit for example)."
175
   // All bits that did not change, set them to 1.
173
   // All bits that did not change, set them to 1.
176
-  for (i = 0; i <PageSize >> 2; i++) {
174
+  for (i = 0; i <PageSize >> 2; i++)
177
     pageContents[i] = (((uint32_t*)data)[i]) | (~(pageContents[i] ^ ((uint32_t*)data)[i]));
175
     pageContents[i] = (((uint32_t*)data)[i]) | (~(pageContents[i] ^ ((uint32_t*)data)[i]));
178
-  }
179
 
176
 
180
   #ifdef EE_EMU_DEBUG
177
   #ifdef EE_EMU_DEBUG
181
     SERIAL_ECHO_START();
178
     SERIAL_ECHO_START();
182
-    SERIAL_ECHOLNPAIR("EEPROM PageWrite   ",page);
183
-    SERIAL_ECHOLNPAIR(" in FLASH address ",(uint32_t)addrflash);
184
-    SERIAL_ECHOLNPAIR(" base address     ",(uint32_t)getFlashStorage(0));
179
+    SERIAL_ECHOLNPAIR("EEPROM PageWrite   ", page);
180
+    SERIAL_ECHOLNPAIR(" in FLASH address ", (uint32_t)addrflash);
181
+    SERIAL_ECHOLNPAIR(" base address     ", (uint32_t)getFlashStorage(0));
185
     SERIAL_FLUSH();
182
     SERIAL_FLUSH();
186
   #endif
183
   #endif
187
 
184
 
207
   uint32_t orgWS = (efc->EEFC_FMR & EEFC_FMR_FWS_Msk) >> EEFC_FMR_FWS_Pos;
204
   uint32_t orgWS = (efc->EEFC_FMR & EEFC_FMR_FWS_Msk) >> EEFC_FMR_FWS_Pos;
208
 
205
 
209
   // Set wait states to 6 (SAM errata)
206
   // Set wait states to 6 (SAM errata)
210
-  efc->EEFC_FMR = efc->EEFC_FMR & (~EEFC_FMR_FWS_Msk) | EEFC_FMR_FWS(6);
207
+  efc->EEFC_FMR = (efc->EEFC_FMR & (~EEFC_FMR_FWS_Msk)) | EEFC_FMR_FWS(6);
211
 
208
 
212
   // Unlock the flash page
209
   // Unlock the flash page
213
   uint32_t status;
210
   uint32_t status;
220
   if ((status & EEFC_ERROR_FLAGS) != 0) {
217
   if ((status & EEFC_ERROR_FLAGS) != 0) {
221
 
218
 
222
     // Restore original wait states
219
     // Restore original wait states
223
-    efc->EEFC_FMR = efc->EEFC_FMR & (~EEFC_FMR_FWS_Msk) | EEFC_FMR_FWS(orgWS);
220
+    efc->EEFC_FMR = (efc->EEFC_FMR & (~EEFC_FMR_FWS_Msk)) | EEFC_FMR_FWS(orgWS);
224
 
221
 
225
     // Reenable interrupts
222
     // Reenable interrupts
226
     __enable_irq();
223
     __enable_irq();
227
 
224
 
228
     #ifdef EE_EMU_DEBUG
225
     #ifdef EE_EMU_DEBUG
229
       SERIAL_ECHO_START();
226
       SERIAL_ECHO_START();
230
-      SERIAL_ECHOLNPAIR("EEPROM Unlock failure for page ",page);
227
+      SERIAL_ECHOLNPAIR("EEPROM Unlock failure for page ", page);
231
     #endif
228
     #endif
232
     return false;
229
     return false;
233
   }
230
   }
247
   if ((status & EEFC_ERROR_FLAGS) != 0) {
244
   if ((status & EEFC_ERROR_FLAGS) != 0) {
248
 
245
 
249
     // Restore original wait states
246
     // Restore original wait states
250
-    efc->EEFC_FMR = efc->EEFC_FMR & (~EEFC_FMR_FWS_Msk) | EEFC_FMR_FWS(orgWS);
247
+    efc->EEFC_FMR = (efc->EEFC_FMR & (~EEFC_FMR_FWS_Msk)) | EEFC_FMR_FWS(orgWS);
251
 
248
 
252
     // Reenable interrupts
249
     // Reenable interrupts
253
     __enable_irq();
250
     __enable_irq();
254
 
251
 
255
     #ifdef EE_EMU_DEBUG
252
     #ifdef EE_EMU_DEBUG
256
       SERIAL_ECHO_START();
253
       SERIAL_ECHO_START();
257
-      SERIAL_ECHOLNPAIR("EEPROM Write failure for page ",page);
254
+      SERIAL_ECHOLNPAIR("EEPROM Write failure for page ", page);
258
     #endif
255
     #endif
259
     return false;
256
     return false;
260
   }
257
   }
261
 
258
 
262
   // Restore original wait states
259
   // Restore original wait states
263
-  efc->EEFC_FMR = efc->EEFC_FMR & (~EEFC_FMR_FWS_Msk) | EEFC_FMR_FWS(orgWS);
260
+  efc->EEFC_FMR = (efc->EEFC_FMR & (~EEFC_FMR_FWS_Msk)) | EEFC_FMR_FWS(orgWS);
264
 
261
 
265
   // Reenable interrupts
262
   // Reenable interrupts
266
   __enable_irq();
263
   __enable_irq();
270
 
267
 
271
     #ifdef EE_EMU_DEBUG
268
     #ifdef EE_EMU_DEBUG
272
       SERIAL_ECHO_START();
269
       SERIAL_ECHO_START();
273
-      SERIAL_ECHOLNPAIR("EEPROM Verify Write failure for page ",page);
270
+      SERIAL_ECHOLNPAIR("EEPROM Verify Write failure for page ", page);
274
 
271
 
275
       ee_Dump( page,(uint32_t *) addrflash);
272
       ee_Dump( page,(uint32_t *) addrflash);
276
       ee_Dump(-page,data);
273
       ee_Dump(-page,data);
289
           }
286
           }
290
         }
287
         }
291
       }
288
       }
292
-      SERIAL_ECHOLNPAIR("--> Differing bits: ",count);
289
+      SERIAL_ECHOLNPAIR("--> Differing bits: ", count);
293
     #endif
290
     #endif
294
 
291
 
295
     return false;
292
     return false;
305
 __attribute__ ((long_call, section (".ramfunc")))
302
 __attribute__ ((long_call, section (".ramfunc")))
306
 static bool ee_PageErase(uint16_t page) {
303
 static bool ee_PageErase(uint16_t page) {
307
 
304
 
308
-  int i;
305
+  uint16_t i;
309
   uint32_t addrflash = ((uint32_t)getFlashStorage(page));
306
   uint32_t addrflash = ((uint32_t)getFlashStorage(page));
310
 
307
 
311
   #ifdef EE_EMU_DEBUG
308
   #ifdef EE_EMU_DEBUG
338
   uint32_t orgWS = (efc->EEFC_FMR & EEFC_FMR_FWS_Msk) >> EEFC_FMR_FWS_Pos;
335
   uint32_t orgWS = (efc->EEFC_FMR & EEFC_FMR_FWS_Msk) >> EEFC_FMR_FWS_Pos;
339
 
336
 
340
   // Set wait states to 6 (SAM errata)
337
   // Set wait states to 6 (SAM errata)
341
-  efc->EEFC_FMR = efc->EEFC_FMR & (~EEFC_FMR_FWS_Msk) | EEFC_FMR_FWS(6);
338
+  efc->EEFC_FMR = (efc->EEFC_FMR & (~EEFC_FMR_FWS_Msk)) | EEFC_FMR_FWS(6);
342
 
339
 
343
   // Unlock the flash page
340
   // Unlock the flash page
344
   uint32_t status;
341
   uint32_t status;
350
   if ((status & EEFC_ERROR_FLAGS) != 0) {
347
   if ((status & EEFC_ERROR_FLAGS) != 0) {
351
 
348
 
352
     // Restore original wait states
349
     // Restore original wait states
353
-    efc->EEFC_FMR = efc->EEFC_FMR & (~EEFC_FMR_FWS_Msk) | EEFC_FMR_FWS(orgWS);
350
+    efc->EEFC_FMR = (efc->EEFC_FMR & (~EEFC_FMR_FWS_Msk)) | EEFC_FMR_FWS(orgWS);
354
 
351
 
355
     // Reenable interrupts
352
     // Reenable interrupts
356
     __enable_irq();
353
     __enable_irq();
375
   if ((status & EEFC_ERROR_FLAGS) != 0) {
372
   if ((status & EEFC_ERROR_FLAGS) != 0) {
376
 
373
 
377
     // Restore original wait states
374
     // Restore original wait states
378
-    efc->EEFC_FMR = efc->EEFC_FMR & (~EEFC_FMR_FWS_Msk) | EEFC_FMR_FWS(orgWS);
375
+    efc->EEFC_FMR = (efc->EEFC_FMR & (~EEFC_FMR_FWS_Msk)) | EEFC_FMR_FWS(orgWS);
379
 
376
 
380
     // Reenable interrupts
377
     // Reenable interrupts
381
     __enable_irq();
378
     __enable_irq();
388
   }
385
   }
389
 
386
 
390
   // Restore original wait states
387
   // Restore original wait states
391
-  efc->EEFC_FMR = efc->EEFC_FMR & (~EEFC_FMR_FWS_Msk) | EEFC_FMR_FWS(orgWS);
388
+  efc->EEFC_FMR = (efc->EEFC_FMR & (~EEFC_FMR_FWS_Msk)) | EEFC_FMR_FWS(orgWS);
392
 
389
 
393
   // Reenable interrupts
390
   // Reenable interrupts
394
   __enable_irq();
391
   __enable_irq();
421
 
418
 
422
   // Check that the value is not contained in the RAM buffer
419
   // Check that the value is not contained in the RAM buffer
423
   if (!excludeRAMBuffer) {
420
   if (!excludeRAMBuffer) {
424
-    int i = 0;
421
+    uint16_t i = 0;
425
     while (i <= (PageSize - 4)) { /* (PageSize - 4) because otherwise, there is not enough room for data and headers */
422
     while (i <= (PageSize - 4)) { /* (PageSize - 4) because otherwise, there is not enough room for data and headers */
426
 
423
 
427
       // Get the address of the block
424
       // Get the address of the block
462
     // Get a pointer to the flash page
459
     // Get a pointer to the flash page
463
     uint8_t* pflash = (uint8_t*)getFlashStorage(page + curGroup * PagesPerGroup);
460
     uint8_t* pflash = (uint8_t*)getFlashStorage(page + curGroup * PagesPerGroup);
464
 
461
 
465
-    int i = 0;
462
+    uint16_t i = 0;
466
     while (i <= (PageSize - 4)) { /* (PageSize - 4) because otherwise, there is not enough room for data and headers */
463
     while (i <= (PageSize - 4)) { /* (PageSize - 4) because otherwise, there is not enough room for data and headers */
467
 
464
 
468
       // Get the address of the block
465
       // Get the address of the block
476
         break;
473
         break;
477
 
474
 
478
       // Check if data is contained in this block
475
       // Check if data is contained in this block
479
-      if (address >= baddr &&
480
-        address < (baddr + blen)) {
481
-
482
-        // Yes, it is contained. Return it!
483
-        return pflash[i + 3 + address - baddr];
484
-      }
476
+      if (address >= baddr && address < (baddr + blen))
477
+        return pflash[i + 3 + address - baddr]; // Yes, it is contained. Return it!
485
 
478
 
486
       // As blocks are always sorted, if the starting address of this block is higher
479
       // As blocks are always sorted, if the starting address of this block is higher
487
       // than the address we are looking for, break loop now - We wont find the value
480
       // than the address we are looking for, break loop now - We wont find the value
488
       // associated to the address
481
       // associated to the address
489
-      if (baddr > address)
490
-        break;
482
+      if (baddr > address) break;
491
 
483
 
492
       // Jump to the next block
484
       // Jump to the next block
493
       i += 3 + blen;
485
       i += 3 + blen;
499
 }
491
 }
500
 
492
 
501
 static uint32_t ee_GetAddrRange(uint32_t address, bool excludeRAMBuffer = false) {
493
 static uint32_t ee_GetAddrRange(uint32_t address, bool excludeRAMBuffer = false) {
502
-  uint32_t baddr;
503
-  uint32_t blen;
504
-  uint32_t nextAddr = 0xFFFF;
505
-  uint32_t nextRange = 0;
494
+  uint32_t baddr,
495
+           blen,
496
+           nextAddr = 0xFFFF,
497
+           nextRange = 0;
506
 
498
 
507
   // Check that the value is not contained in the RAM buffer
499
   // Check that the value is not contained in the RAM buffer
508
   if (!excludeRAMBuffer) {
500
   if (!excludeRAMBuffer) {
509
-    int i = 0;
501
+    uint16_t i = 0;
510
     while (i <= (PageSize - 4)) { /* (PageSize - 4) because otherwise, there is not enough room for data and headers */
502
     while (i <= (PageSize - 4)) { /* (PageSize - 4) because otherwise, there is not enough room for data and headers */
511
 
503
 
512
       // Get the address of the block
504
       // Get the address of the block
516
       blen = buffer[i + 2];
508
       blen = buffer[i + 2];
517
 
509
 
518
       // If we reach the end of the list, break loop
510
       // If we reach the end of the list, break loop
519
-      if (blen == 0xFF)
520
-        break;
511
+      if (blen == 0xFF) break;
521
 
512
 
522
       // Check if address and address + 1 is contained in this block
513
       // Check if address and address + 1 is contained in this block
523
-      if (address >= baddr &&
524
-        address < (baddr + blen)) {
525
-
526
-        // Yes, it is contained. Return it!
527
-        return address | ((blen - address + baddr) << 16);
528
-      }
514
+      if (address >= baddr && address < (baddr + blen))
515
+        return address | ((blen - address + baddr) << 16); // Yes, it is contained. Return it!
529
 
516
 
530
       // Otherwise, check if we can use it as a limit
517
       // Otherwise, check if we can use it as a limit
531
       if (baddr > address && baddr < nextAddr) {
518
       if (baddr > address && baddr < nextAddr) {
536
       // As blocks are always sorted, if the starting address of this block is higher
523
       // As blocks are always sorted, if the starting address of this block is higher
537
       // than the address we are looking for, break loop now - We wont find the value
524
       // than the address we are looking for, break loop now - We wont find the value
538
       // associated to the address
525
       // associated to the address
539
-      if (baddr > address)
540
-        break;
526
+      if (baddr > address) break;
541
 
527
 
542
       // Jump to the next block
528
       // Jump to the next block
543
       i += 3 + blen;
529
       i += 3 + blen;
553
     // Get a pointer to the flash page
539
     // Get a pointer to the flash page
554
     uint8_t* pflash = (uint8_t*)getFlashStorage(page + curGroup * PagesPerGroup);
540
     uint8_t* pflash = (uint8_t*)getFlashStorage(page + curGroup * PagesPerGroup);
555
 
541
 
556
-    int i = 0;
542
+    uint16_t i = 0;
557
     while (i <= (PageSize - 4)) { /* (PageSize - 4) because otherwise, there is not enough room for data and headers */
543
     while (i <= (PageSize - 4)) { /* (PageSize - 4) because otherwise, there is not enough room for data and headers */
558
 
544
 
559
       // Get the address of the block
545
       // Get the address of the block
563
       blen = pflash[i + 2];
549
       blen = pflash[i + 2];
564
 
550
 
565
       // If we reach the end of the list, break loop
551
       // If we reach the end of the list, break loop
566
-      if (blen == 0xFF)
567
-        break;
552
+      if (blen == 0xFF) break;
568
 
553
 
569
       // Check if data is contained in this block
554
       // Check if data is contained in this block
570
-      if (address >= baddr &&
571
-        address < (baddr + blen)) {
572
-
573
-        // Yes, it is contained. Return it!
574
-        return address | ((blen - address + baddr) << 16);
575
-      }
555
+      if (address >= baddr && address < (baddr + blen))
556
+        return address | ((blen - address + baddr) << 16); // Yes, it is contained. Return it!
576
 
557
 
577
       // Otherwise, check if we can use it as a limit
558
       // Otherwise, check if we can use it as a limit
578
       if (baddr > address && baddr < nextAddr) {
559
       if (baddr > address && baddr < nextAddr) {
583
       // As blocks are always sorted, if the starting address of this block is higher
564
       // As blocks are always sorted, if the starting address of this block is higher
584
       // than the address we are looking for, break loop now - We wont find the value
565
       // than the address we are looking for, break loop now - We wont find the value
585
       // associated to the address
566
       // associated to the address
586
-      if (baddr > address)
587
-        break;
567
+      if (baddr > address) break;
588
 
568
 
589
       // Jump to the next block
569
       // Jump to the next block
590
       i += 3 + blen;
570
       i += 3 + blen;
596
 }
576
 }
597
 
577
 
598
 static bool ee_IsPageClean(int page) {
578
 static bool ee_IsPageClean(int page) {
599
-
600
   uint32_t* pflash = (uint32_t*) getFlashStorage(page);
579
   uint32_t* pflash = (uint32_t*) getFlashStorage(page);
601
-  for (int i = 0; i < (PageSize >> 2); ++i) {
602
-    if (*pflash++ != 0xFFFFFFFF)
603
-      return false;
604
-  }
580
+  for (uint16_t i = 0; i < (PageSize >> 2); ++i)
581
+    if (*pflash++ != 0xFFFFFFFF) return false;
605
   return true;
582
   return true;
606
 }
583
 }
607
 
584
 
610
   // Check if RAM buffer has something to be written
587
   // Check if RAM buffer has something to be written
611
   bool isEmpty = true;
588
   bool isEmpty = true;
612
   uint32_t* p = (uint32_t*) &buffer[0];
589
   uint32_t* p = (uint32_t*) &buffer[0];
613
-  for (int j = 0; j < (PageSize >> 2); j++) {
590
+  for (uint16_t j = 0; j < (PageSize >> 2); j++) {
614
     if (*p++ != 0xFFFFFFFF) {
591
     if (*p++ != 0xFFFFFFFF) {
615
       isEmpty = false;
592
       isEmpty = false;
616
       break;
593
       break;
648
   }
625
   }
649
 
626
 
650
   // We have no space left on the current group - We must compact the values
627
   // We have no space left on the current group - We must compact the values
651
-  int i = 0;
628
+  uint16_t i = 0;
652
 
629
 
653
   // Compute the next group to use
630
   // Compute the next group to use
654
-  int curwPage = 0;
655
-  int curwGroup = curGroup + 1;
656
-  if (curwGroup >= GroupCount)
657
-    curwGroup = 0;
631
+  int curwPage = 0, curwGroup = curGroup + 1;
632
+  if (curwGroup >= GroupCount) curwGroup = 0;
658
 
633
 
659
   uint32_t rdAddr = 0;
634
   uint32_t rdAddr = 0;
660
   do {
635
   do {
774
 static bool ee_Write(uint32_t address, uint8_t data) {
749
 static bool ee_Write(uint32_t address, uint8_t data) {
775
 
750
 
776
   // If we were requested an address outside of the emulated range, fail now
751
   // If we were requested an address outside of the emulated range, fail now
777
-  if (address >= EEPROMSize)
778
-    return false;
752
+  if (address >= EEPROMSize) return false;
779
 
753
 
780
   // Lets check if we have a block with that data previously defined. Block
754
   // Lets check if we have a block with that data previously defined. Block
781
   //  start addresses are always sorted in ascending order
755
   //  start addresses are always sorted in ascending order
782
-  int i = 0;
756
+  uint16_t i = 0;
783
   while (i <= (PageSize - 4)) { /* (PageSize - 4) because otherwise, there is not enough room for data and headers */
757
   while (i <= (PageSize - 4)) { /* (PageSize - 4) because otherwise, there is not enough room for data and headers */
784
 
758
 
785
     // Get the address of the block
759
     // Get the address of the block
805
 
779
 
806
     // Maybe we could add it to the front or to the back
780
     // Maybe we could add it to the front or to the back
807
     // of this block ?
781
     // of this block ?
808
-    if ((address + 1) == baddr ||
809
-      address == (baddr + blen)) {
782
+    if ((address + 1) == baddr || address == (baddr + blen)) {
810
 
783
 
811
       // Potentially, it could be done. But we must ensure there is room
784
       // Potentially, it could be done. But we must ensure there is room
812
       // so we can expand the block. Lets find how much free space remains
785
       // so we can expand the block. Lets find how much free space remains
840
 
813
 
841
           // Insert at the end - There is a very interesting thing that could happen here:
814
           // Insert at the end - There is a very interesting thing that could happen here:
842
           //  Maybe we could coalesce the next block with this block. Let's try to do it!
815
           //  Maybe we could coalesce the next block with this block. Let's try to do it!
843
-          int inext = i + 3 + blen;
816
+          uint16_t inext = i + 3 + blen;
844
           if (inext <= (PageSize - 4) &&
817
           if (inext <= (PageSize - 4) &&
845
-            (buffer[inext] | (buffer[inext + 1] << 8)) == (baddr + blen + 1)) {
818
+            (buffer[inext] | (uint16_t(buffer[inext + 1]) << 8)) == (baddr + blen + 1)) {
846
             // YES! ... we can coalesce blocks! . Do it!
819
             // YES! ... we can coalesce blocks! . Do it!
847
 
820
 
848
             // Adjust this block header to include the next one
821
             // Adjust this block header to include the next one
879
     // As blocks are always sorted, if the starting address of this block is higher
852
     // As blocks are always sorted, if the starting address of this block is higher
880
     // than the address we are looking for, break loop now - We wont find the value
853
     // than the address we are looking for, break loop now - We wont find the value
881
     // associated to the address
854
     // associated to the address
882
-    if (baddr > address)
883
-      break;
855
+    if (baddr > address) break;
884
 
856
 
885
     // Jump to the next block
857
     // Jump to the next block
886
     i += 3 + blen;
858
     i += 3 + blen;
924
 static void ee_Init() {
896
 static void ee_Init() {
925
 
897
 
926
   // Just init once!
898
   // Just init once!
927
-  if (curGroup != 0xFF)
928
-    return;
899
+  if (curGroup != 0xFF) return;
929
 
900
 
930
   // Clean up the SRAM buffer
901
   // Clean up the SRAM buffer
931
   memset(buffer, 0xFF, sizeof(buffer));
902
   memset(buffer, 0xFF, sizeof(buffer));
932
 
903
 
933
   // Now, we must find out the group where settings are stored
904
   // Now, we must find out the group where settings are stored
934
-  for (curGroup = 0; curGroup < GroupCount; curGroup++) {
935
-    if (!ee_IsPageClean(curGroup * PagesPerGroup))
936
-      break;
937
-  }
905
+  for (curGroup = 0; curGroup < GroupCount; curGroup++)
906
+    if (!ee_IsPageClean(curGroup * PagesPerGroup)) break;
938
 
907
 
939
   // If all groups seem to be used, default to first group
908
   // If all groups seem to be used, default to first group
940
-  if (curGroup >= GroupCount)
941
-    curGroup = 0;
909
+  if (curGroup >= GroupCount) curGroup = 0;
942
 
910
 
943
   #ifdef EE_EMU_DEBUG
911
   #ifdef EE_EMU_DEBUG
944
     SERIAL_ECHO_START();
912
     SERIAL_ECHO_START();
948
 
916
 
949
   // Now, validate that all the other group pages are empty
917
   // Now, validate that all the other group pages are empty
950
   for (int grp = 0; grp < GroupCount; grp++) {
918
   for (int grp = 0; grp < GroupCount; grp++) {
951
-    if (grp == curGroup)
952
-      continue;
919
+    if (grp == curGroup) continue;
953
 
920
 
954
     for (int page = 0; page < PagesPerGroup; page++) {
921
     for (int page = 0; page < PagesPerGroup; page++) {
955
       if (!ee_IsPageClean(grp * PagesPerGroup + page)) {
922
       if (!ee_IsPageClean(grp * PagesPerGroup + page)) {
1031
 }
998
 }
1032
 
999
 
1033
 #endif // ENABLED(EEPROM_SETTINGS) && DISABLED(I2C_EEPROM) && DISABLED(SPI_EEPROM)
1000
 #endif // ENABLED(EEPROM_SETTINGS) && DISABLED(I2C_EEPROM) && DISABLED(SPI_EEPROM)
1034
-#endif // ARDUINO_ARCH_AVR
1001
+#endif // ARDUINO_ARCH_AVR

+ 2
- 2
Marlin/src/gcode/feature/trinamic/M911-M915.cpp 查看文件

161
   void GcodeSuite::M913() {
161
   void GcodeSuite::M913() {
162
     #define TMC_SAY_PWMTHRS(A,Q) tmc_get_pwmthrs(stepper##Q, TMC_##Q, planner.axis_steps_per_mm[_AXIS(A)])
162
     #define TMC_SAY_PWMTHRS(A,Q) tmc_get_pwmthrs(stepper##Q, TMC_##Q, planner.axis_steps_per_mm[_AXIS(A)])
163
     #define TMC_SET_PWMTHRS(A,Q) tmc_set_pwmthrs(stepper##Q, value, planner.axis_steps_per_mm[_AXIS(A)])
163
     #define TMC_SET_PWMTHRS(A,Q) tmc_set_pwmthrs(stepper##Q, value, planner.axis_steps_per_mm[_AXIS(A)])
164
-    #define TMC_SAY_PWMTHRS_E(E) do{ const uint8_t extruder = E; tmc_get_pwmthrs(stepperE##E, TMC_E##E, planner.axis_steps_per_mm[E_AXIS_N]); }while(0)
165
-    #define TMC_SET_PWMTHRS_E(E) do{ const uint8_t extruder = E; tmc_set_pwmthrs(stepperE##E, value, planner.axis_steps_per_mm[E_AXIS_N]); }while(0)
164
+    #define TMC_SAY_PWMTHRS_E(E) do{ constexpr uint8_t extruder = E; tmc_get_pwmthrs(stepperE##E, TMC_E##E, planner.axis_steps_per_mm[E_AXIS_N]); UNUSED(extruder); }while(0)
165
+    #define TMC_SET_PWMTHRS_E(E) do{ constexpr uint8_t extruder = E; tmc_set_pwmthrs(stepperE##E, value, planner.axis_steps_per_mm[E_AXIS_N]); UNUSED(extruder); }while(0)
166
 
166
 
167
     bool report = true;
167
     bool report = true;
168
     const uint8_t index = parser.byteval('I');
168
     const uint8_t index = parser.byteval('I');

+ 10
- 4
Marlin/src/module/stepper_indirection.cpp 查看文件

258
       _TMC2130_INIT(E0, planner.axis_steps_per_mm[E_AXIS]);
258
       _TMC2130_INIT(E0, planner.axis_steps_per_mm[E_AXIS]);
259
     #endif
259
     #endif
260
     #if AXIS_DRIVER_TYPE(E1, TMC2130)
260
     #if AXIS_DRIVER_TYPE(E1, TMC2130)
261
-      { constexpr int extruder = 1; _TMC2130_INIT(E1, planner.axis_steps_per_mm[E_AXIS_N]); }
261
+      { constexpr uint8_t extruder = 1; _TMC2130_INIT(E1, planner.axis_steps_per_mm[E_AXIS_N]); UNUSED(extruder); }
262
     #endif
262
     #endif
263
     #if AXIS_DRIVER_TYPE(E2, TMC2130)
263
     #if AXIS_DRIVER_TYPE(E2, TMC2130)
264
-      { constexpr int extruder = 2; _TMC2130_INIT(E2, planner.axis_steps_per_mm[E_AXIS_N]); }
264
+      { constexpr uint8_t extruder = 2; _TMC2130_INIT(E2, planner.axis_steps_per_mm[E_AXIS_N]); UNUSED(extruder); }
265
     #endif
265
     #endif
266
     #if AXIS_DRIVER_TYPE(E3, TMC2130)
266
     #if AXIS_DRIVER_TYPE(E3, TMC2130)
267
-      { constexpr int extruder = 3; _TMC2130_INIT(E3, planner.axis_steps_per_mm[E_AXIS_N]); }
267
+      { constexpr uint8_t extruder = 3; _TMC2130_INIT(E3, planner.axis_steps_per_mm[E_AXIS_N]); UNUSED(extruder); }
268
     #endif
268
     #endif
269
     #if AXIS_DRIVER_TYPE(E4, TMC2130)
269
     #if AXIS_DRIVER_TYPE(E4, TMC2130)
270
-      { constexpr int extruder = 4; _TMC2130_INIT(E4, planner.axis_steps_per_mm[E_AXIS_N]); }
270
+      { constexpr uint8_t extruder = 4; _TMC2130_INIT(E4, planner.axis_steps_per_mm[E_AXIS_N]); UNUSED(extruder); }
271
+    #endif
272
+    #if AXIS_DRIVER_TYPE(E5, TMC2130)
273
+      { constexpr uint8_t extruder = 5; _TMC2130_INIT(E5, planner.axis_steps_per_mm[E_AXIS_N]); UNUSED(extruder); }
271
     #endif
274
     #endif
272
 
275
 
273
     #if ENABLED(SENSORLESS_HOMING)
276
     #if ENABLED(SENSORLESS_HOMING)
580
     #if AXIS_DRIVER_TYPE(E4, TMC2208)
583
     #if AXIS_DRIVER_TYPE(E4, TMC2208)
581
       { constexpr int extruder = 4; _TMC2208_INIT(E4, planner.axis_steps_per_mm[E_AXIS_N]); }
584
       { constexpr int extruder = 4; _TMC2208_INIT(E4, planner.axis_steps_per_mm[E_AXIS_N]); }
582
     #endif
585
     #endif
586
+    #if AXIS_DRIVER_TYPE(E5, TMC2208)
587
+      { constexpr int extruder = 5; _TMC2208_INIT(E5, planner.axis_steps_per_mm[E_AXIS_N]); }
588
+    #endif
583
   }
589
   }
584
 #endif // TMC2208
590
 #endif // TMC2208
585
 
591
 

Loading…
取消
儲存