浏览代码

Merge pull request #11542 from thinkyhead/bf2_misc_fixes_aug_6

Followup persistent store with heading, const
Scott Lahteine 6 年前
父节点
当前提交
ccf65c5397
没有帐户链接到提交者的电子邮件

+ 22
- 15
Marlin/src/HAL/HAL_AVR/persistent_store_eeprom.cpp 查看文件

1
+/**
2
+ * Marlin 3D Printer Firmware
3
+ * Copyright (C) 2016, 2017 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
4
+ *
5
+ * Based on Sprinter and grbl.
6
+ * Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
7
+ *
8
+ * This program is free software: you can redistribute it and/or modify
9
+ * it under the terms of the GNU General Public License as published by
10
+ * the Free Software Foundation, either version 3 of the License, or
11
+ * (at your option) any later version.
12
+ *
13
+ * This program is distributed in the hope that it will be useful,
14
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
+ * GNU General Public License for more details.
17
+ *
18
+ * You should have received a copy of the GNU General Public License
19
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
20
+ *
21
+ */
1
 #ifdef __AVR__
22
 #ifdef __AVR__
2
 
23
 
3
 #include "../../inc/MarlinConfig.h"
24
 #include "../../inc/MarlinConfig.h"
41
   return false;  // always assume success for AVR's
62
   return false;  // always assume success for AVR's
42
 }
63
 }
43
 
64
 
44
-bool PersistentStore::write_data(const int pos, uint8_t* value, size_t size) {
45
-  int data_pos = pos;
46
-  uint16_t crc = 0;
47
-  return write_data(data_pos, value, size, &crc);
48
-}
49
-
50
-bool PersistentStore::read_data(const int pos, uint8_t* value, size_t size) {
51
-  int data_pos = pos;
52
-  uint16_t crc = 0;
53
-  return read_data(data_pos, value, size, &crc);
54
-}
55
-
56
-const size_t PersistentStore::capacity() {
57
-  return E2END + 1;
58
-}
65
+const size_t PersistentStore::capacity() { return E2END + 1; }
59
 
66
 
60
 #endif // EEPROM_SETTINGS
67
 #endif // EEPROM_SETTINGS
61
 #endif // __AVR__
68
 #endif // __AVR__

+ 23
- 15
Marlin/src/HAL/HAL_DUE/persistent_store_eeprom.cpp 查看文件

1
+/**
2
+ * Marlin 3D Printer Firmware
3
+ *
4
+ * Copyright (C) 2016 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
5
+ * Copyright (c) 2016 Bob Cousins bobcousins42@googlemail.com
6
+ * Copyright (c) 2015-2016 Nico Tonnhofer wurstnase.reprap@gmail.com
7
+ * Copyright (c) 2016 Victor Perez victor_pv@hotmail.com
8
+ *
9
+ * This program is free software: you can redistribute it and/or modify
10
+ * it under the terms of the GNU General Public License as published by
11
+ * the Free Software Foundation, either version 3 of the License, or
12
+ * (at your option) any later version.
13
+ *
14
+ * This program is distributed in the hope that it will be useful,
15
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
16
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17
+ * GNU General Public License for more details.
18
+ *
19
+ * You should have received a copy of the GNU General Public License
20
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
21
+ *
22
+ */
1
 #ifdef ARDUINO_ARCH_SAM
23
 #ifdef ARDUINO_ARCH_SAM
2
 
24
 
3
 #include "../persistent_store_api.h"
25
 #include "../persistent_store_api.h"
49
   return false;
71
   return false;
50
 }
72
 }
51
 
73
 
52
-bool PersistentStore::write_data(const int pos, uint8_t* value, size_t size) {
53
-  int data_pos = pos;
54
-  uint16_t crc = 0;
55
-  return write_data(data_pos, value, size, &crc);
56
-}
57
-
58
-bool PersistentStore::read_data(const int pos, uint8_t* value, size_t size) {
59
-  int data_pos = pos;
60
-  uint16_t crc = 0;
61
-  return read_data(data_pos, value, size, &crc);
62
-}
63
-
64
-const size_t PersistentStore::capacity() {
65
-  return E2END + 1;
66
-}
74
+const size_t PersistentStore::capacity() { return E2END + 1; }
67
 
75
 
68
 #endif // EEPROM_SETTINGS
76
 #endif // EEPROM_SETTINGS
69
 #endif // ARDUINO_ARCH_SAM
77
 #endif // ARDUINO_ARCH_SAM

+ 25
- 30
Marlin/src/HAL/HAL_LPC1768/persistent_store_sdcard.cpp 查看文件

1
 /**
1
 /**
2
  * Marlin 3D Printer Firmware
2
  * Marlin 3D Printer Firmware
3
- * Copyright (C) 2016, 2017 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
4
  *
3
  *
5
- * Based on Sprinter and grbl.
6
- * Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
4
+ * Copyright (C) 2016 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
5
+ * Copyright (c) 2016 Bob Cousins bobcousins42@googlemail.com
6
+ * Copyright (c) 2015-2016 Nico Tonnhofer wurstnase.reprap@gmail.com
7
+ * Copyright (c) 2016 Victor Perez victor_pv@hotmail.com
7
  *
8
  *
8
  * This program is free software: you can redistribute it and/or modify
9
  * This program is free software: you can redistribute it and/or modify
9
  * it under the terms of the GNU General Public License as published by
10
  * it under the terms of the GNU General Public License as published by
98
 //    FR_INVALID_PARAMETER     /* (19) Given parameter is invalid */
99
 //    FR_INVALID_PARAMETER     /* (19) Given parameter is invalid */
99
 //  } FRESULT;
100
 //  } FRESULT;
100
 
101
 
101
-bool PersistentStore::write_data(int &pos, const uint8_t *value, size_t size, uint16_t *crc) {
102
-  if(!eeprom_file_open) return true;
102
+bool PersistentStore::write_data(int &pos, const uint8_t *value, const size_t size, uint16_t *crc) {
103
+  if (!eeprom_file_open) return true;
103
   FRESULT s;
104
   FRESULT s;
104
   UINT bytes_written = 0;
105
   UINT bytes_written = 0;
105
 
106
 
113
    return s;
114
    return s;
114
   }
115
   }
115
 
116
 
116
-  s = f_write(&eeprom_file, (void *)value, size, &bytes_written);
117
+  s = f_write(&eeprom_file, (void*)value, size, &bytes_written);
117
   if (s) {
118
   if (s) {
118
    SERIAL_PROTOCOLPAIR(" write_data(", pos);         // This extra chit-chat goes away soon.  But it is helpful
119
    SERIAL_PROTOCOLPAIR(" write_data(", pos);         // This extra chit-chat goes away soon.  But it is helpful
119
    SERIAL_PROTOCOLPAIR(",", (int)value);            // right now to see errors that are happening in the
120
    SERIAL_PROTOCOLPAIR(",", (int)value);            // right now to see errors that are happening in the
129
   return (bytes_written != size);  // return true for any error
130
   return (bytes_written != size);  // return true for any error
130
 }
131
 }
131
 
132
 
132
-bool PersistentStore::read_data(int &pos, uint8_t* value, size_t size, uint16_t *crc, const bool writing/*=true*/) {
133
-  if(!eeprom_file_open) return true;
133
+bool PersistentStore::read_data(int &pos, uint8_t* value, const size_t size, uint16_t *crc, const bool writing/*=true*/) {
134
+  if (!eeprom_file_open) return true;
134
   UINT bytes_read = 0;
135
   UINT bytes_read = 0;
135
   FRESULT s;
136
   FRESULT s;
136
   s = f_lseek(&eeprom_file, pos);
137
   s = f_lseek(&eeprom_file, pos);
138
+
137
   if (s) {
139
   if (s) {
138
-   SERIAL_PROTOCOLPAIR(" read_data(", pos);          // This extra chit-chat goes away soon.  But it is helpful
139
-   SERIAL_PROTOCOLPAIR(",", (int)value);            // right now to see errors that are happening in the
140
-   SERIAL_PROTOCOLPAIR(",", size);             // read_data() and write_data() functions
140
+   SERIAL_PROTOCOLPAIR(" read_data(", pos);         // This extra chit-chat goes away soon.  But it is helpful
141
+   SERIAL_PROTOCOLCHAR(',');
142
+   SERIAL_PROTOCOL((int)value);                     // right now to see errors that are happening in the
143
+   SERIAL_PROTOCOLCHAR(',');
144
+   SERIAL_PROTOCOL(size);                           // read_data() and write_data() functions
141
    SERIAL_PROTOCOLLNPGM("...)");
145
    SERIAL_PROTOCOLLNPGM("...)");
142
    SERIAL_PROTOCOLLNPAIR(" f_lseek()=", (int)s);
146
    SERIAL_PROTOCOLLNPAIR(" f_lseek()=", (int)s);
143
    return true;
147
    return true;
144
   }
148
   }
149
+
145
   if (writing) {
150
   if (writing) {
146
-    s = f_read(&eeprom_file, (void *)value, size, &bytes_read);
151
+    s = f_read(&eeprom_file, (void*)value, size, &bytes_read);
147
     crc16(crc, value, size);
152
     crc16(crc, value, size);
148
   }
153
   }
149
   else {
154
   else {
150
     uint8_t temp[size];
155
     uint8_t temp[size];
151
-    s = f_read(&eeprom_file, (void *)temp, size, &bytes_read);
156
+    s = f_read(&eeprom_file, (void*)temp, size, &bytes_read);
152
     crc16(crc, temp, size);
157
     crc16(crc, temp, size);
153
   }
158
   }
159
+
154
   if (s) {
160
   if (s) {
155
    SERIAL_PROTOCOLPAIR(" read_data(", pos);         // This extra chit-chat goes away soon.  But it is helpful
161
    SERIAL_PROTOCOLPAIR(" read_data(", pos);         // This extra chit-chat goes away soon.  But it is helpful
156
-   SERIAL_PROTOCOLPAIR(",", (int)value);           // right now to see errors that are happening in the
157
-   SERIAL_PROTOCOLPAIR(",", size);            // read_data() and write_data() functions
162
+   SERIAL_PROTOCOLCHAR(',');
163
+   SERIAL_PROTOCOL((int)value);                     // right now to see errors that are happening in the
164
+   SERIAL_PROTOCOLCHAR(',');
165
+   SERIAL_PROTOCOL(size);                           // read_data() and write_data() functions
158
    SERIAL_PROTOCOLLNPGM("...)");
166
    SERIAL_PROTOCOLLNPGM("...)");
159
    SERIAL_PROTOCOLLNPAIR(" f_write()=", (int)s);
167
    SERIAL_PROTOCOLLNPAIR(" f_write()=", (int)s);
160
    SERIAL_PROTOCOLPAIR(" size=", size);
168
    SERIAL_PROTOCOLPAIR(" size=", size);
161
    SERIAL_PROTOCOLLNPAIR("\n bytes_read=",  bytes_read);
169
    SERIAL_PROTOCOLLNPAIR("\n bytes_read=",  bytes_read);
162
    return true;
170
    return true;
163
   }
171
   }
172
+
164
   pos = pos + size;
173
   pos = pos + size;
165
   return bytes_read != size;  // return true for any error
174
   return bytes_read != size;  // return true for any error
166
 }
175
 }
167
 
176
 
168
-bool PersistentStore::write_data(const int pos, uint8_t* value, size_t size) {
169
-  int data_pos = pos;
170
-  uint16_t crc = 0;
171
-  return write_data(data_pos, value, size, &crc);
172
-}
173
-
174
-bool PersistentStore::read_data(const int pos, uint8_t* value, size_t size) {
175
-  int data_pos = pos;
176
-  uint16_t crc = 0;
177
-  return read_data(data_pos, value, size, &crc);
178
-}
179
-
180
-const size_t PersistentStore::capacity() {
181
-  return 4096; //4KiB of Emulated EEPROM
182
-}
177
+const size_t PersistentStore::capacity() { return 4096; } // 4KiB of Emulated EEPROM
183
 
178
 
184
 #endif // EEPROM_SETTINGS
179
 #endif // EEPROM_SETTINGS
185
 #endif // TARGET_LPC1768
180
 #endif // TARGET_LPC1768

+ 3
- 18
Marlin/src/HAL/HAL_STM32F1/persistent_store_flash.cpp 查看文件

55
   return true;
55
   return true;
56
 }
56
 }
57
 
57
 
58
-bool PersistentStore::write_data(int &pos, const uint8_t *value, size_t size, uint16_t *crc) {
58
+bool PersistentStore::write_data(int &pos, const uint8_t *value, const size_t size, uint16_t *crc) {
59
   FLASH_Status status;
59
   FLASH_Status status;
60
 
60
 
61
   if (firstWrite) {
61
   if (firstWrite) {
90
   return false;
90
   return false;
91
 }
91
 }
92
 
92
 
93
-bool PersistentStore::read_data(int &pos, uint8_t* value, size_t size, uint16_t *crc, const bool writing/*=true*/) {
93
+bool PersistentStore::read_data(int &pos, uint8_t* value, const size_t size, uint16_t *crc, const bool writing/*=true*/) {
94
   for (uint16_t i = 0; i < size; i++) {
94
   for (uint16_t i = 0; i < size; i++) {
95
     byte* accessPoint = (byte*)(pageBase + pos + i);
95
     byte* accessPoint = (byte*)(pageBase + pos + i);
96
     uint8_t c = *accessPoint;
96
     uint8_t c = *accessPoint;
101
   return false;
101
   return false;
102
 }
102
 }
103
 
103
 
104
-bool PersistentStore::write_data(const int pos, uint8_t* value, size_t size) {
105
-  int data_pos = pos;
106
-  uint16_t crc = 0;
107
-  return write_data(data_pos, value, size, &crc);
108
-}
109
-
110
-bool PersistentStore::read_data(const int pos, uint8_t* value, size_t size) {
111
-  int data_pos = pos;
112
-  uint16_t crc = 0;
113
-  return read_data(data_pos, value, size, &crc);
114
-}
115
-
116
-const size_t PersistentStore::capacity() {
117
-  return E2END + 1;
118
-}
119
-
104
+const size_t PersistentStore::capacity() { return E2END + 1; }
120
 
105
 
121
 #endif // EEPROM_SETTINGS && EEPROM FLASH
106
 #endif // EEPROM_SETTINGS && EEPROM FLASH
122
 #endif // __STM32F1__
107
 #endif // __STM32F1__

+ 3
- 17
Marlin/src/HAL/HAL_STM32F1/persistent_store_sdcard.cpp 查看文件

60
   return (bytes_written == HAL_STM32F1_EEPROM_SIZE);
60
   return (bytes_written == HAL_STM32F1_EEPROM_SIZE);
61
 }
61
 }
62
 
62
 
63
-bool PersistentStore::write_data(int &pos, const uint8_t *value, size_t size, uint16_t *crc) {
63
+bool PersistentStore::write_data(int &pos, const uint8_t *value, const size_t size, uint16_t *crc) {
64
   for (int i = 0; i < size; i++)
64
   for (int i = 0; i < size; i++)
65
     HAL_STM32F1_eeprom_content[pos + i] = value[i];
65
     HAL_STM32F1_eeprom_content[pos + i] = value[i];
66
   crc16(crc, value, size);
66
   crc16(crc, value, size);
68
   return false;
68
   return false;
69
 }
69
 }
70
 
70
 
71
-bool PersistentStore::read_data(int &pos, uint8_t* value, size_t size, uint16_t *crc, const bool writing/*=true*/) {
71
+bool PersistentStore::read_data(int &pos, uint8_t* value, const size_t size, uint16_t *crc, const bool writing/*=true*/) {
72
   for (int i = 0; i < size; i++) {
72
   for (int i = 0; i < size; i++) {
73
     uint8_t c = HAL_STM32F1_eeprom_content[pos + i];
73
     uint8_t c = HAL_STM32F1_eeprom_content[pos + i];
74
     if (writing) value[i] = c;
74
     if (writing) value[i] = c;
78
   return false;
78
   return false;
79
 }
79
 }
80
 
80
 
81
-bool PersistentStore::write_data(const int pos, uint8_t* value, size_t size) {
82
-  int data_pos = pos;
83
-  uint16_t crc = 0;
84
-  return write_data(data_pos, value, size, &crc);
85
-}
86
-
87
-bool PersistentStore::read_data(const int pos, uint8_t* value, size_t size) {
88
-  int data_pos = pos;
89
-  uint16_t crc = 0;
90
-  return read_data(data_pos, value, size, &crc);
91
-}
92
-
93
-const size_t PersistentStore::capacity() {
94
-  return HAL_STM32F1_EEPROM_SIZE;
95
-}
81
+const size_t PersistentStore::capacity() { return HAL_STM32F1_EEPROM_SIZE; }
96
 
82
 
97
 #endif // EEPROM_SETTINGS
83
 #endif // EEPROM_SETTINGS
98
 
84
 

+ 1
- 15
Marlin/src/HAL/HAL_STM32F4/persistent_store_eeprom.cpp 查看文件

64
   return false;
64
   return false;
65
 }
65
 }
66
 
66
 
67
-bool PersistentStore::write_data(const int pos, uint8_t* value, size_t size) {
68
-  int data_pos = pos;
69
-  uint16_t crc = 0;
70
-  return write_data(data_pos, value, size, &crc);
71
-}
72
-
73
-bool PersistentStore::read_data(const int pos, uint8_t* value, size_t size) {
74
-  int data_pos = pos;
75
-  uint16_t crc = 0;
76
-  return read_data(data_pos, value, size, &crc);
77
-}
78
-
79
-const size_t PersistentStore::capacity() {
80
-  return E2END + 1;
81
-}
67
+const size_t PersistentStore::capacity() { return E2END + 1; }
82
 
68
 
83
 #endif // EEPROM_SETTINGS
69
 #endif // EEPROM_SETTINGS
84
 #endif // STM32F4 || STM32F4xx
70
 #endif // STM32F4 || STM32F4xx

+ 1
- 16
Marlin/src/HAL/HAL_STM32F7/persistent_store_eeprom.cpp 查看文件

21
  *
21
  *
22
  */
22
  */
23
 
23
 
24
-
25
 #ifdef STM32F7
24
 #ifdef STM32F7
26
 
25
 
27
 #include "../../inc/MarlinConfig.h"
26
 #include "../../inc/MarlinConfig.h"
65
   return false;
64
   return false;
66
 }
65
 }
67
 
66
 
68
-bool PersistentStore::write_data(const int pos, uint8_t* value, size_t size) {
69
-  int data_pos = pos;
70
-  uint16_t crc = 0;
71
-  return write_data(data_pos, value, size, &crc);
72
-}
73
-
74
-bool PersistentStore::read_data(const int pos, uint8_t* value, size_t size) {
75
-  int data_pos = pos;
76
-  uint16_t crc = 0;
77
-  return read_data(data_pos, value, size, &crc);
78
-}
79
-
80
-const size_t PersistentStore::capacity() {
81
-  return E2END + 1;
82
-}
67
+const size_t PersistentStore::capacity() { return E2END + 1; }
83
 
68
 
84
 #endif // EEPROM_SETTINGS
69
 #endif // EEPROM_SETTINGS
85
 #endif // STM32F7
70
 #endif // STM32F7

+ 24
- 15
Marlin/src/HAL/HAL_TEENSY35_36/persistent_store_eeprom.cpp 查看文件

1
+/**
2
+ * Marlin 3D Printer Firmware
3
+ *
4
+ * Copyright (C) 2016 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
5
+ * Copyright (c) 2016 Bob Cousins bobcousins42@googlemail.com
6
+ * Copyright (c) 2015-2016 Nico Tonnhofer wurstnase.reprap@gmail.com
7
+ * Copyright (c) 2016 Victor Perez victor_pv@hotmail.com
8
+ *
9
+ * This program is free software: you can redistribute it and/or modify
10
+ * it under the terms of the GNU General Public License as published by
11
+ * the Free Software Foundation, either version 3 of the License, or
12
+ * (at your option) any later version.
13
+ *
14
+ * This program is distributed in the hope that it will be useful,
15
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
16
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17
+ * GNU General Public License for more details.
18
+ *
19
+ * You should have received a copy of the GNU General Public License
20
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
21
+ *
22
+ */
23
+
1
 #if defined(__MK64FX512__) || defined(__MK66FX1M0__)
24
 #if defined(__MK64FX512__) || defined(__MK66FX1M0__)
2
 
25
 
3
 #include "../../inc/MarlinConfig.h"
26
 #include "../../inc/MarlinConfig.h"
42
   return false;
65
   return false;
43
 }
66
 }
44
 
67
 
45
-bool PersistentStore::write_data(const int pos, uint8_t* value, size_t size) {
46
-  int data_pos = pos;
47
-  uint16_t crc = 0;
48
-  return write_data(data_pos, value, size, &crc);
49
-}
50
-
51
-bool PersistentStore::read_data(const int pos, uint8_t* value, size_t size) {
52
-  int data_pos = pos;
53
-  uint16_t crc = 0;
54
-  return read_data(data_pos, value, size, &crc);
55
-}
56
-
57
-const size_t PersistentStore::capacity() {
58
-  return E2END + 1;
59
-}
68
+const size_t PersistentStore::capacity() { return E2END + 1; }
60
 
69
 
61
 #endif // EEPROM_SETTINGS
70
 #endif // EEPROM_SETTINGS
62
 #endif // __MK64FX512__ || __MK66FX1M0__
71
 #endif // __MK64FX512__ || __MK66FX1M0__

+ 4
- 3
Marlin/src/HAL/persistent_store_api.cpp 查看文件

1
 /**
1
 /**
2
  * Marlin 3D Printer Firmware
2
  * Marlin 3D Printer Firmware
3
- * Copyright (C) 2016 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
4
  *
3
  *
5
- * Based on Sprinter and grbl.
6
- * Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
4
+ * Copyright (C) 2016 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
5
+ * Copyright (c) 2016 Bob Cousins bobcousins42@googlemail.com
6
+ * Copyright (c) 2015-2016 Nico Tonnhofer wurstnase.reprap@gmail.com
7
+ * Copyright (c) 2016 Victor Perez victor_pv@hotmail.com
7
  *
8
  *
8
  * This program is free software: you can redistribute it and/or modify
9
  * This program is free software: you can redistribute it and/or modify
9
  * it under the terms of the GNU General Public License as published by
10
  * it under the terms of the GNU General Public License as published by

+ 16
- 5
Marlin/src/HAL/persistent_store_api.h 查看文件

1
 /**
1
 /**
2
  * Marlin 3D Printer Firmware
2
  * Marlin 3D Printer Firmware
3
- * Copyright (C) 2016 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
4
  *
3
  *
5
- * Based on Sprinter and grbl.
6
- * Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
4
+ * Copyright (C) 2016 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
5
+ * Copyright (c) 2016 Bob Cousins bobcousins42@googlemail.com
6
+ * Copyright (c) 2015-2016 Nico Tonnhofer wurstnase.reprap@gmail.com
7
+ * Copyright (c) 2016 Victor Perez victor_pv@hotmail.com
7
  *
8
  *
8
  * This program is free software: you can redistribute it and/or modify
9
  * This program is free software: you can redistribute it and/or modify
9
  * it under the terms of the GNU General Public License as published by
10
  * it under the terms of the GNU General Public License as published by
30
   static bool access_finish();
31
   static bool access_finish();
31
   static bool write_data(int &pos, const uint8_t *value, size_t size, uint16_t *crc);
32
   static bool write_data(int &pos, const uint8_t *value, size_t size, uint16_t *crc);
32
   static bool read_data(int &pos, uint8_t* value, size_t size, uint16_t *crc, const bool writing=true);
33
   static bool read_data(int &pos, uint8_t* value, size_t size, uint16_t *crc, const bool writing=true);
33
-  static bool write_data(const int pos, uint8_t* value, size_t size);
34
-  static bool read_data(const int pos, uint8_t* value, size_t size);
35
   static const size_t capacity();
34
   static const size_t capacity();
35
+
36
+  static inline bool write_data(const int pos, uint8_t* value, const size_t size) {
37
+    int data_pos = pos;
38
+    uint16_t crc = 0;
39
+    return write_data(data_pos, value, size, &crc);
40
+  }
41
+
42
+  static inline bool read_data(const int pos, uint8_t* value, const size_t size) {
43
+    int data_pos = pos;
44
+    uint16_t crc = 0;
45
+    return read_data(data_pos, value, size, &crc);
46
+  }
36
 };
47
 };
37
 
48
 
38
 extern PersistentStore persistentStore;
49
 extern PersistentStore persistentStore;

+ 3
- 3
Marlin/src/feature/bedlevel/ubl/ubl.h 查看文件

215
      * z_correction_for_x_on_horizontal_mesh_line is an optimization for
215
      * z_correction_for_x_on_horizontal_mesh_line is an optimization for
216
      * the case where the printer is making a vertical line that only crosses horizontal mesh lines.
216
      * the case where the printer is making a vertical line that only crosses horizontal mesh lines.
217
      */
217
      */
218
-    inline static float z_correction_for_x_on_horizontal_mesh_line(const float &rx0, const int x1_i, const int yi) {
218
+    static inline float z_correction_for_x_on_horizontal_mesh_line(const float &rx0, const int x1_i, const int yi) {
219
       if (!WITHIN(x1_i, 0, GRID_MAX_POINTS_X - 1) || !WITHIN(yi, 0, GRID_MAX_POINTS_Y - 1)) {
219
       if (!WITHIN(x1_i, 0, GRID_MAX_POINTS_X - 1) || !WITHIN(yi, 0, GRID_MAX_POINTS_Y - 1)) {
220
         #if ENABLED(DEBUG_LEVELING_FEATURE)
220
         #if ENABLED(DEBUG_LEVELING_FEATURE)
221
           if (DEBUGGING(LEVELING)) {
221
           if (DEBUGGING(LEVELING)) {
249
     //
249
     //
250
     // See comments above for z_correction_for_x_on_horizontal_mesh_line
250
     // See comments above for z_correction_for_x_on_horizontal_mesh_line
251
     //
251
     //
252
-    inline static float z_correction_for_y_on_vertical_mesh_line(const float &ry0, const int xi, const int y1_i) {
252
+    static inline float z_correction_for_y_on_vertical_mesh_line(const float &ry0, const int xi, const int y1_i) {
253
       if (!WITHIN(xi, 0, GRID_MAX_POINTS_X - 1) || !WITHIN(y1_i, 0, GRID_MAX_POINTS_Y - 1)) {
253
       if (!WITHIN(xi, 0, GRID_MAX_POINTS_X - 1) || !WITHIN(y1_i, 0, GRID_MAX_POINTS_Y - 1)) {
254
         #if ENABLED(DEBUG_LEVELING_FEATURE)
254
         #if ENABLED(DEBUG_LEVELING_FEATURE)
255
           if (DEBUGGING(LEVELING)) {
255
           if (DEBUGGING(LEVELING)) {
362
       static void line_to_destination_cartesian(const float &fr, const uint8_t e);
362
       static void line_to_destination_cartesian(const float &fr, const uint8_t e);
363
     #endif
363
     #endif
364
 
364
 
365
-    inline static bool mesh_is_valid() {
365
+    static inline bool mesh_is_valid() {
366
       for (uint8_t x = 0; x < GRID_MAX_POINTS_X; x++)
366
       for (uint8_t x = 0; x < GRID_MAX_POINTS_X; x++)
367
         for (uint8_t y = 0; y < GRID_MAX_POINTS_Y; y++)
367
         for (uint8_t y = 0; y < GRID_MAX_POINTS_Y; y++)
368
           if (isnan(z_values[x][y])) return false;
368
           if (isnan(z_values[x][y])) return false;

+ 15
- 15
Marlin/src/gcode/parser.h 查看文件

175
   FORCE_INLINE static bool has_value() { return value_ptr != NULL; }
175
   FORCE_INLINE static bool has_value() { return value_ptr != NULL; }
176
 
176
 
177
   // Seen a parameter with a value
177
   // Seen a parameter with a value
178
-  inline static bool seenval(const char c) { return seen(c) && has_value(); }
178
+  static inline bool seenval(const char c) { return seen(c) && has_value(); }
179
 
179
 
180
   // Float removes 'E' to prevent scientific notation interpretation
180
   // Float removes 'E' to prevent scientific notation interpretation
181
-  inline static float value_float() {
181
+  static inline float value_float() {
182
     if (value_ptr) {
182
     if (value_ptr) {
183
       char *e = value_ptr;
183
       char *e = value_ptr;
184
       for (;;) {
184
       for (;;) {
198
   }
198
   }
199
 
199
 
200
   // Code value as a long or ulong
200
   // Code value as a long or ulong
201
-  inline static int32_t value_long() { return value_ptr ? strtol(value_ptr, NULL, 10) : 0L; }
202
-  inline static uint32_t value_ulong() { return value_ptr ? strtoul(value_ptr, NULL, 10) : 0UL; }
201
+  static inline int32_t value_long() { return value_ptr ? strtol(value_ptr, NULL, 10) : 0L; }
202
+  static inline uint32_t value_ulong() { return value_ptr ? strtoul(value_ptr, NULL, 10) : 0UL; }
203
 
203
 
204
   // Code value for use as time
204
   // Code value for use as time
205
   FORCE_INLINE static millis_t value_millis() { return value_ulong(); }
205
   FORCE_INLINE static millis_t value_millis() { return value_ulong(); }
208
   // Reduce to fewer bits
208
   // Reduce to fewer bits
209
   FORCE_INLINE static int16_t value_int() { return (int16_t)value_long(); }
209
   FORCE_INLINE static int16_t value_int() { return (int16_t)value_long(); }
210
   FORCE_INLINE static uint16_t value_ushort() { return (uint16_t)value_long(); }
210
   FORCE_INLINE static uint16_t value_ushort() { return (uint16_t)value_long(); }
211
-  inline static uint8_t value_byte() { return (uint8_t)constrain(value_long(), 0, 255); }
211
+  static inline uint8_t value_byte() { return (uint8_t)constrain(value_long(), 0, 255); }
212
 
212
 
213
   // Bool is true with no value or non-zero
213
   // Bool is true with no value or non-zero
214
-  inline static bool value_bool() { return !has_value() || !!value_byte(); }
214
+  static inline bool value_bool() { return !has_value() || !!value_byte(); }
215
 
215
 
216
   // Units modes: Inches, Fahrenheit, Kelvin
216
   // Units modes: Inches, Fahrenheit, Kelvin
217
 
217
 
220
     // Init linear units by constructor
220
     // Init linear units by constructor
221
     GCodeParser() { set_input_linear_units(LINEARUNIT_MM); }
221
     GCodeParser() { set_input_linear_units(LINEARUNIT_MM); }
222
 
222
 
223
-    inline static void set_input_linear_units(const LinearUnit units) {
223
+    static inline void set_input_linear_units(const LinearUnit units) {
224
       switch (units) {
224
       switch (units) {
225
         case LINEARUNIT_INCH:
225
         case LINEARUNIT_INCH:
226
           linear_unit_factor = 25.4f;
226
           linear_unit_factor = 25.4f;
233
       volumetric_unit_factor = POW(linear_unit_factor, 3);
233
       volumetric_unit_factor = POW(linear_unit_factor, 3);
234
     }
234
     }
235
 
235
 
236
-    inline static float axis_unit_factor(const AxisEnum axis) {
236
+    static inline float axis_unit_factor(const AxisEnum axis) {
237
       return (axis >= E_AXIS && volumetric_enabled ? volumetric_unit_factor : linear_unit_factor);
237
       return (axis >= E_AXIS && volumetric_enabled ? volumetric_unit_factor : linear_unit_factor);
238
     }
238
     }
239
 
239
 
240
-    inline static float value_linear_units()                     { return value_float() * linear_unit_factor; }
241
-    inline static float value_axis_units(const AxisEnum axis)    { return value_float() * axis_unit_factor(axis); }
242
-    inline static float value_per_axis_unit(const AxisEnum axis) { return value_float() / axis_unit_factor(axis); }
240
+    static inline float value_linear_units()                     { return value_float() * linear_unit_factor; }
241
+    static inline float value_axis_units(const AxisEnum axis)    { return value_float() * axis_unit_factor(axis); }
242
+    static inline float value_per_axis_unit(const AxisEnum axis) { return value_float() / axis_unit_factor(axis); }
243
 
243
 
244
   #else
244
   #else
245
 
245
 
251
 
251
 
252
   #if ENABLED(TEMPERATURE_UNITS_SUPPORT)
252
   #if ENABLED(TEMPERATURE_UNITS_SUPPORT)
253
 
253
 
254
-    inline static void set_input_temp_units(TempUnit units) { input_temp_units = units; }
254
+    static inline void set_input_temp_units(TempUnit units) { input_temp_units = units; }
255
 
255
 
256
     #if ENABLED(ULTIPANEL) && DISABLED(DISABLE_M503)
256
     #if ENABLED(ULTIPANEL) && DISABLED(DISABLE_M503)
257
 
257
 
261
       FORCE_INLINE static const char* temp_units_name() {
261
       FORCE_INLINE static const char* temp_units_name() {
262
         return input_temp_units == TEMPUNIT_K ? PSTR("Kelvin") : input_temp_units == TEMPUNIT_F ? PSTR("Fahrenheit") : PSTR("Celsius");
262
         return input_temp_units == TEMPUNIT_K ? PSTR("Kelvin") : input_temp_units == TEMPUNIT_F ? PSTR("Fahrenheit") : PSTR("Celsius");
263
       }
263
       }
264
-      inline static float to_temp_units(const float &f) {
264
+      static inline float to_temp_units(const float &f) {
265
         switch (input_temp_units) {
265
         switch (input_temp_units) {
266
           case TEMPUNIT_F:
266
           case TEMPUNIT_F:
267
             return f * 0.5555555556f + 32;
267
             return f * 0.5555555556f + 32;
275
 
275
 
276
     #endif // ULTIPANEL && !DISABLE_M503
276
     #endif // ULTIPANEL && !DISABLE_M503
277
 
277
 
278
-    inline static float value_celsius() {
278
+    static inline float value_celsius() {
279
       const float f = value_float();
279
       const float f = value_float();
280
       switch (input_temp_units) {
280
       switch (input_temp_units) {
281
         case TEMPUNIT_F:
281
         case TEMPUNIT_F:
288
       }
288
       }
289
     }
289
     }
290
 
290
 
291
-    inline static float value_celsius_diff() {
291
+    static inline float value_celsius_diff() {
292
       switch (input_temp_units) {
292
       switch (input_temp_units) {
293
         case TEMPUNIT_F:
293
         case TEMPUNIT_F:
294
           return value_float() * 0.5555555556f;
294
           return value_float() * 0.5555555556f;

+ 1
- 1
Marlin/src/libs/buzzer.h 查看文件

82
      * @brief Resets the state of the class
82
      * @brief Resets the state of the class
83
      * @details Brings the class state to a known one.
83
      * @details Brings the class state to a known one.
84
      */
84
      */
85
-    inline static void reset() {
85
+    static inline void reset() {
86
       off();
86
       off();
87
       state.endtime = 0;
87
       state.endtime = 0;
88
     }
88
     }

+ 1
- 1
Marlin/src/module/planner.h 查看文件

361
        *  Returns 1.0 if planner.z_fade_height is 0.0.
361
        *  Returns 1.0 if planner.z_fade_height is 0.0.
362
        *  Returns 0.0 if Z is past the specified 'Fade Height'.
362
        *  Returns 0.0 if Z is past the specified 'Fade Height'.
363
        */
363
        */
364
-      inline static float fade_scaling_factor_for_z(const float &rz) {
364
+      static inline float fade_scaling_factor_for_z(const float &rz) {
365
         static float z_fade_factor = 1;
365
         static float z_fade_factor = 1;
366
         if (z_fade_height) {
366
         if (z_fade_height) {
367
           if (rz >= z_fade_height) return 0;
367
           if (rz >= z_fade_height) return 0;

+ 9
- 10
Marlin/src/module/planner_bezier.cpp 查看文件

45
 #define SIGMA 0.1f
45
 #define SIGMA 0.1f
46
 
46
 
47
 // Compute the linear interpolation between two real numbers.
47
 // Compute the linear interpolation between two real numbers.
48
-inline static float interp(float a, float b, float t) { return (1 - t) * a + t * b; }
48
+static inline float interp(const float &a, const float &b, const float &t) { return (1 - t) * a + t * b; }
49
 
49
 
50
 /**
50
 /**
51
  * Compute a Bézier curve using the De Casteljau's algorithm (see
51
  * Compute a Bézier curve using the De Casteljau's algorithm (see
53
  * easy to code and has good numerical stability (very important,
53
  * easy to code and has good numerical stability (very important,
54
  * since Arudino works with limited precision real numbers).
54
  * since Arudino works with limited precision real numbers).
55
  */
55
  */
56
-inline static float eval_bezier(float a, float b, float c, float d, float t) {
57
-  float iab = interp(a, b, t);
58
-  float ibc = interp(b, c, t);
59
-  float icd = interp(c, d, t);
60
-  float iabc = interp(iab, ibc, t);
61
-  float ibcd = interp(ibc, icd, t);
62
-  float iabcd = interp(iabc, ibcd, t);
63
-  return iabcd;
56
+static inline float eval_bezier(const float &a, const float &b, const float &c, const float &d, const float &t) {
57
+  const float iab = interp(a, b, t),
58
+              ibc = interp(b, c, t),
59
+              icd = interp(c, d, t),
60
+              iabc = interp(iab, ibc, t),
61
+              ibcd = interp(ibc, icd, t);
62
+  return interp(iabc, ibcd, t);
64
 }
63
 }
65
 
64
 
66
 /**
65
 /**
67
  * We approximate Euclidean distance with the sum of the coordinates
66
  * We approximate Euclidean distance with the sum of the coordinates
68
  * offset (so-called "norm 1"), which is quicker to compute.
67
  * offset (so-called "norm 1"), which is quicker to compute.
69
  */
68
  */
70
-inline static float dist1(float x1, float y1, float x2, float y2) { return ABS(x1 - x2) + ABS(y1 - y2); }
69
+static inline float dist1(const float &x1, const float &y1, const float &x2, const float &y2) { return ABS(x1 - x2) + ABS(y1 - y2); }
71
 
70
 
72
 /**
71
 /**
73
  * The algorithm for computing the step is loosely based on the one in Kig
72
  * The algorithm for computing the step is loosely based on the one in Kig

+ 2
- 2
Marlin/src/module/stepper.h 查看文件

435
     #endif
435
     #endif
436
 
436
 
437
     // Set the current position in steps
437
     // Set the current position in steps
438
-    inline static void set_position(const int32_t &a, const int32_t &b, const int32_t &c, const int32_t &e) {
438
+    static inline void set_position(const int32_t &a, const int32_t &b, const int32_t &c, const int32_t &e) {
439
       planner.synchronize();
439
       planner.synchronize();
440
       const bool was_enabled = STEPPER_ISR_ENABLED();
440
       const bool was_enabled = STEPPER_ISR_ENABLED();
441
       if (was_enabled) DISABLE_STEPPER_DRIVER_INTERRUPT();
441
       if (was_enabled) DISABLE_STEPPER_DRIVER_INTERRUPT();
443
       if (was_enabled) ENABLE_STEPPER_DRIVER_INTERRUPT();
443
       if (was_enabled) ENABLE_STEPPER_DRIVER_INTERRUPT();
444
     }
444
     }
445
 
445
 
446
-    inline static void set_position(const AxisEnum a, const int32_t &v) {
446
+    static inline void set_position(const AxisEnum a, const int32_t &v) {
447
       planner.synchronize();
447
       planner.synchronize();
448
 
448
 
449
       #ifdef __AVR__
449
       #ifdef __AVR__

正在加载...
取消
保存