Bladeren bron

Cleanup spacing in pinsDebug.h

Scott Lahteine 8 jaren geleden
bovenliggende
commit
46b714a52f
1 gewijzigde bestanden met toevoegingen van 66 en 82 verwijderingen
  1. 66
    82
      Marlin/pinsDebug.h

+ 66
- 82
Marlin/pinsDebug.h Bestand weergeven

@@ -46,21 +46,18 @@ bool endstop_monitor_flag = false;
46 46
 
47 47
 // first pass - put the name strings into FLASH
48 48
 
49
-#define _ADD_PIN_2(PIN_NAME, ENTRY_NAME) static const unsigned char ENTRY_NAME[] PROGMEM = {PIN_NAME};
50
-#define _ADD_PIN(PIN_NAME, COUNTER)  _ADD_PIN_2(PIN_NAME, entry_NAME_##COUNTER)
51
-#define REPORT_NAME_DIGITAL(NAME, COUNTER)  _ADD_PIN(#NAME, COUNTER)
52
-#define REPORT_NAME_ANALOG(NAME, COUNTER)  _ADD_PIN(#NAME, COUNTER)
53
-
54
-#line 0   // set __LINE__ to a known value for the first pass
49
+#define _ADD_PIN_2(PIN_NAME, ENTRY_NAME) static const unsigned char ENTRY_NAME[] PROGMEM = { PIN_NAME };
50
+#define _ADD_PIN(PIN_NAME, COUNTER) _ADD_PIN_2(PIN_NAME, entry_NAME_##COUNTER)
51
+#define REPORT_NAME_DIGITAL(NAME, COUNTER) _ADD_PIN(#NAME, COUNTER)
52
+#define REPORT_NAME_ANALOG(NAME, COUNTER) _ADD_PIN(#NAME, COUNTER)
55 53
 
56 54
 #include "pinsDebug_list.h"
57
-
58
-#line 59   // set __LINE__ to the correct line number or else compiler error messages don't make sense
55
+#line 56
59 56
 
60 57
 // manually add pins that have names that are macros which don't play well with these macros
61 58
 #if SERIAL_PORT == 0 && (AVR_ATmega2560_FAMILY || AVR_ATmega1284_FAMILY)
62
-  static const char RXD_NAME[] PROGMEM = {"RXD"};
63
-  static const char TXD_NAME[] PROGMEM = {"TXD"};
59
+  static const char RXD_NAME[] PROGMEM = { "RXD" };
60
+  static const char TXD_NAME[] PROGMEM = { "TXD" };
64 61
 #endif
65 62
 
66 63
 /////////////////////////////////////////////////////////////////////////////
@@ -72,11 +69,10 @@ bool endstop_monitor_flag = false;
72 69
 #undef REPORT_NAME_DIGITAL
73 70
 #undef REPORT_NAME_ANALOG
74 71
 
75
-#define _ADD_PIN_2( ENTRY_NAME, NAME, IS_DIGITAL) {(const char*)ENTRY_NAME, (const char*)NAME, (const char*)IS_DIGITAL},
76
-#define _ADD_PIN( NAME, COUNTER, IS_DIGITAL)  _ADD_PIN_2( entry_NAME_##COUNTER, NAME, IS_DIGITAL)
77
-#define REPORT_NAME_DIGITAL(NAME, COUNTER)  _ADD_PIN( NAME, COUNTER, (uint8_t)1)
78
-#define REPORT_NAME_ANALOG(NAME, COUNTER)  _ADD_PIN( analogInputToDigitalPin(NAME), COUNTER, 0)
79
-
72
+#define _ADD_PIN_2(ENTRY_NAME, NAME, IS_DIGITAL) { (const char*)ENTRY_NAME, (const char*)NAME, (const char*)IS_DIGITAL },
73
+#define _ADD_PIN(NAME, COUNTER, IS_DIGITAL) _ADD_PIN_2(entry_NAME_##COUNTER, NAME, IS_DIGITAL)
74
+#define REPORT_NAME_DIGITAL(NAME, COUNTER) _ADD_PIN(NAME, COUNTER, (uint8_t)1)
75
+#define REPORT_NAME_ANALOG(NAME, COUNTER) _ADD_PIN(analogInputToDigitalPin(NAME), COUNTER, 0)
80 76
 
81 77
 const char* const pin_array[][3] PROGMEM = {
82 78
 
@@ -92,35 +88,32 @@ const char* const pin_array[][3] PROGMEM = {
92 88
   // manually add pins ...
93 89
   #if SERIAL_PORT == 0
94 90
     #if AVR_ATmega2560_FAMILY
95
-      {RXD_NAME, "0", "1"},
96
-      {TXD_NAME, "1", "1"},
91
+      { RXD_NAME, "0", "1" },
92
+      { TXD_NAME, "1", "1" },
97 93
     #elif AVR_ATmega1284_FAMILY
98
-      {RXD_NAME, "8", "1"},
99
-      {TXD_NAME, "9", "1"},
94
+      { RXD_NAME, "8", "1" },
95
+      { TXD_NAME, "9", "1" },
100 96
     #endif
101 97
   #endif
102 98
 
103
-  #line 0   // set __LINE__ to the SAME known value for the second pass
104 99
   #include "pinsDebug_list.h"
100
+  #line 101
105 101
 
106
-};  // done populating the array
107
-
108
-#line 109  // set __LINE__ to the correct line number or else compiler error messages don't make sense
102
+};
109 103
 
110
-#define n_array (sizeof (pin_array) / sizeof (const char *))/3
104
+#define n_array (sizeof(pin_array) / sizeof(char*)) / 3
111 105
 
112 106
 #ifndef TIMER1B
113 107
   // working with Teensyduino extension so need to re-define some things
114 108
   #include "pinsDebug_Teensyduino.h"
115 109
 #endif
116 110
 
117
-
118 111
 #define PWM_PRINT(V) do{ sprintf(buffer, "PWM:  %4d", V); SERIAL_ECHO(buffer); }while(0)
119
-#define PWM_CASE(N,Z) \
120
-  case TIMER##N##Z: \
112
+#define PWM_CASE(N,Z)                                           \
113
+  case TIMER##N##Z:                                             \
121 114
     if (TCCR##N##A & (_BV(COM##N##Z##1) | _BV(COM##N##Z##0))) { \
122
-      PWM_PRINT(OCR##N##Z); \
123
-      return true; \
115
+      PWM_PRINT(OCR##N##Z);                                     \
116
+      return true;                                              \
124 117
     } else return false
125 118
 
126 119
 /**
@@ -130,71 +123,70 @@ const char* const pin_array[][3] PROGMEM = {
130 123
 static bool pwm_status(uint8_t pin) {
131 124
   char buffer[20];   // for the sprintf statements
132 125
 
133
-  switch(digitalPinToTimer(pin)) {
126
+  switch (digitalPinToTimer(pin)) {
134 127
 
135 128
     #if defined(TCCR0A) && defined(COM0A1)
136 129
       #ifdef TIMER0A
137
-        PWM_CASE(0,A);
130
+        PWM_CASE(0, A);
138 131
       #endif
139
-      PWM_CASE(0,B);
132
+      PWM_CASE(0, B);
140 133
     #endif
141 134
 
142 135
     #if defined(TCCR1A) && defined(COM1A1)
143
-      PWM_CASE(1,A);
144
-      PWM_CASE(1,B);
136
+      PWM_CASE(1, A);
137
+      PWM_CASE(1, B);
145 138
      #if defined(COM1C1) && defined(TIMER1C)
146
-      PWM_CASE(1,C);
139
+      PWM_CASE(1, C);
147 140
      #endif
148 141
     #endif
149 142
 
150 143
     #if defined(TCCR2A) && defined(COM2A1)
151
-      PWM_CASE(2,A);
152
-      PWM_CASE(2,B);
144
+      PWM_CASE(2, A);
145
+      PWM_CASE(2, B);
153 146
     #endif
154 147
 
155 148
     #if defined(TCCR3A) && defined(COM3A1)
156
-      PWM_CASE(3,A);
157
-      PWM_CASE(3,B);
149
+      PWM_CASE(3, A);
150
+      PWM_CASE(3, B);
158 151
       #ifdef COM3C1
159
-        PWM_CASE(3,C);
152
+        PWM_CASE(3, C);
160 153
       #endif
161 154
     #endif
162 155
 
163 156
     #ifdef TCCR4A
164
-      PWM_CASE(4,A);
165
-      PWM_CASE(4,B);
166
-      PWM_CASE(4,C);
157
+      PWM_CASE(4, A);
158
+      PWM_CASE(4, B);
159
+      PWM_CASE(4, C);
167 160
     #endif
168 161
 
169 162
     #if defined(TCCR5A) && defined(COM5A1)
170
-      PWM_CASE(5,A);
171
-      PWM_CASE(5,B);
172
-      PWM_CASE(5,C);
163
+      PWM_CASE(5, A);
164
+      PWM_CASE(5, B);
165
+      PWM_CASE(5, C);
173 166
     #endif
174 167
 
175 168
     case NOT_ON_TIMER:
176 169
     default:
177 170
       return false;
178 171
   }
179
-  SERIAL_PROTOCOLPGM("  ");
172
+  SERIAL_PROTOCOL_SP(2);
180 173
 } // pwm_status
181 174
 
182 175
 
183
-
184 176
 const volatile uint8_t* const PWM_other[][3] PROGMEM = {
185
-    {&TCCR0A, &TCCR0B, &TIMSK0},
186
-    {&TCCR1A, &TCCR1B, &TIMSK1},
177
+    { &TCCR0A, &TCCR0B, &TIMSK0 },
178
+    { &TCCR1A, &TCCR1B, &TIMSK1 },
187 179
   #if defined(TCCR2A) && defined(COM2A1)
188
-    {&TCCR2A, &TCCR2B, &TIMSK2},
180
+    { &TCCR2A, &TCCR2B, &TIMSK2 },
189 181
   #endif
190 182
   #if defined(TCCR3A) && defined(COM3A1)
191
-    {&TCCR3A, &TCCR3B, &TIMSK3},
183
+    { &TCCR3A, &TCCR3B, &TIMSK3 },
192 184
   #endif
193 185
   #ifdef TCCR4A
194
-    {&TCCR4A, &TCCR4B, &TIMSK4},
186
+    { &TCCR4A, &TCCR4B, &TIMSK4 },
195 187
   #endif
196 188
   #if defined(TCCR5A) && defined(COM5A1)
197
-    {&TCCR5A, &TCCR5B, &TIMSK5},
189
+    { &TCCR5A, &TCCR5B, &TIMSK5 },
198 190
   #endif
199 191
 };
200 192
 
@@ -202,35 +194,35 @@ const volatile uint8_t* const PWM_other[][3] PROGMEM = {
202 194
 const volatile uint8_t* const PWM_OCR[][3] PROGMEM = {
203 195
 
204 196
   #ifdef TIMER0A
205
-    {&OCR0A,&OCR0B,0},
197
+    { &OCR0A, &OCR0B, 0 },
206 198
   #else
207
-    {0,&OCR0B,0},
199
+    { 0, &OCR0B, 0 },
208 200
   #endif
209 201
 
210 202
   #if defined(COM1C1) && defined(TIMER1C)
211
-   { (const uint8_t*)&OCR1A, (const uint8_t*)&OCR1B, (const uint8_t*)&OCR1C},
203
+   { (const uint8_t*)&OCR1A, (const uint8_t*)&OCR1B, (const uint8_t*)&OCR1C },
212 204
   #else
213
-   { (const uint8_t*)&OCR1A, (const uint8_t*)&OCR1B,0},
205
+   { (const uint8_t*)&OCR1A, (const uint8_t*)&OCR1B, 0 },
214 206
   #endif
215 207
 
216 208
   #if defined(TCCR2A) && defined(COM2A1)
217
-    {&OCR2A,&OCR2B,0},
209
+    { &OCR2A, &OCR2B, 0 },
218 210
   #endif
219 211
 
220 212
   #if defined(TCCR3A) && defined(COM3A1)
221 213
     #ifdef COM3C1
222
-      { (const uint8_t*)&OCR3A, (const uint8_t*)&OCR3B, (const uint8_t*)&OCR3C},
214
+      { (const uint8_t*)&OCR3A, (const uint8_t*)&OCR3B, (const uint8_t*)&OCR3C },
223 215
     #else
224
-      { (const uint8_t*)&OCR3A, (const uint8_t*)&OCR3B,0},
216
+      { (const uint8_t*)&OCR3A, (const uint8_t*)&OCR3B, 0 },
225 217
     #endif
226 218
   #endif
227 219
 
228 220
   #ifdef TCCR4A
229
-    { (const uint8_t*)&OCR4A, (const uint8_t*)&OCR4B, (const uint8_t*)&OCR4C},
221
+    { (const uint8_t*)&OCR4A, (const uint8_t*)&OCR4B, (const uint8_t*)&OCR4C },
230 222
   #endif
231 223
 
232 224
   #if defined(TCCR5A) && defined(COM5A1)
233
-    { (const uint8_t*)&OCR5A, (const uint8_t*)&OCR5B, (const uint8_t*)&OCR5C},
225
+    { (const uint8_t*)&OCR5A, (const uint8_t*)&OCR5B, (const uint8_t*)&OCR5C },
234 226
   #endif
235 227
 };
236 228
 
@@ -247,32 +239,24 @@ const volatile uint8_t* const PWM_OCR[][3] PROGMEM = {
247 239
 #define WGM_3      4
248 240
 #define TOIE       0
249 241
 
250
-
251 242
 #define OCR_VAL(T, L)   pgm_read_word(&PWM_OCR[T][L])
252 243
 
253
-
254
-static void err_is_counter() {
255
-  SERIAL_PROTOCOLPGM("   non-standard PWM mode");
256
-}
257
-static void err_is_interrupt() {
258
-  SERIAL_PROTOCOLPGM("   compare interrupt enabled");
259
-}
260
-static void err_prob_interrupt() {
261
-  SERIAL_PROTOCOLPGM("   overflow interrupt enabled");
262
-}
244
+static void err_is_counter()     { SERIAL_PROTOCOLPGM("   non-standard PWM mode"); }
245
+static void err_is_interrupt()   { SERIAL_PROTOCOLPGM("   compare interrupt enabled"); }
246
+static void err_prob_interrupt() { SERIAL_PROTOCOLPGM("   overflow interrupt enabled"); }
263 247
 
264 248
 void com_print(uint8_t N, uint8_t Z) {
265 249
   uint8_t *TCCRA = (uint8_t*)TCCR_A(N);
266 250
   SERIAL_PROTOCOLPGM("    COM");
267 251
   SERIAL_PROTOCOLCHAR(N + '0');
268
-  switch(Z) {
269
-    case 'A' :
252
+  switch (Z) {
253
+    case 'A':
270 254
       SERIAL_PROTOCOLPAIR("A: ", ((*TCCRA & (_BV(7) | _BV(6))) >> 6));
271 255
       break;
272
-    case 'B' :
256
+    case 'B':
273 257
       SERIAL_PROTOCOLPAIR("B: ", ((*TCCRA & (_BV(5) | _BV(4))) >> 4));
274 258
       break;
275
-    case 'C' :
259
+    case 'C':
276 260
       SERIAL_PROTOCOLPAIR("C: ", ((*TCCRA & (_BV(3) | _BV(2))) >> 2));
277 261
       break;
278 262
   }
@@ -288,7 +272,7 @@ void timer_prefix(uint8_t T, char L, uint8_t N) {  // T - timer    L - pwm  N -
288 272
   SERIAL_PROTOCOLPGM("    TIMER");
289 273
   SERIAL_PROTOCOLCHAR(T + '0');
290 274
   SERIAL_PROTOCOLCHAR(L);
291
-  SERIAL_PROTOCOLPGM("   ");
275
+  SERIAL_PROTOCOL_SP(3);
292 276
 
293 277
   if (N == 3) {
294 278
     uint8_t *OCRVAL8 = (uint8_t*)OCR_VAL(T, L - 'A');
@@ -316,14 +300,14 @@ void timer_prefix(uint8_t T, char L, uint8_t N) {  // T - timer    L - pwm  N -
316 300
   SERIAL_PROTOCOLPAIR(": ", *TMSK);
317 301
 
318 302
   uint8_t OCIE = L - 'A' + 1;
319
-  if (N == 3) {if (WGM == 0 || WGM == 2 || WGM ==  4 || WGM ==  6) err_is_counter();}
320
-  else        {if (WGM == 0 || WGM == 4 || WGM == 12 || WGM == 13) err_is_counter();}
303
+  if (N == 3) { if (WGM == 0 || WGM == 2 || WGM ==  4 || WGM ==  6) err_is_counter(); }
304
+  else        { if (WGM == 0 || WGM == 4 || WGM == 12 || WGM == 13) err_is_counter(); }
321 305
   if (TEST(*TMSK, OCIE)) err_is_interrupt();
322 306
   if (TEST(*TMSK, TOIE)) err_prob_interrupt();
323 307
 }
324 308
 
325 309
 static void pwm_details(uint8_t pin) {
326
-  switch(digitalPinToTimer(pin)) {
310
+  switch (digitalPinToTimer(pin)) {
327 311
 
328 312
     #if defined(TCCR0A) && defined(COM0A1)
329 313
       #ifdef TIMER0A

Laden…
Annuleren
Opslaan