Explorar el Código

Cleanup spacing in pinsDebug.h

Scott Lahteine hace 8 años
padre
commit
46b714a52f
Se han modificado 1 ficheros con 66 adiciones y 82 borrados
  1. 66
    82
      Marlin/pinsDebug.h

+ 66
- 82
Marlin/pinsDebug.h Ver fichero

46
 
46
 
47
 // first pass - put the name strings into FLASH
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
 #include "pinsDebug_list.h"
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
 // manually add pins that have names that are macros which don't play well with these macros
57
 // manually add pins that have names that are macros which don't play well with these macros
61
 #if SERIAL_PORT == 0 && (AVR_ATmega2560_FAMILY || AVR_ATmega1284_FAMILY)
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
 #endif
61
 #endif
65
 
62
 
66
 /////////////////////////////////////////////////////////////////////////////
63
 /////////////////////////////////////////////////////////////////////////////
72
 #undef REPORT_NAME_DIGITAL
69
 #undef REPORT_NAME_DIGITAL
73
 #undef REPORT_NAME_ANALOG
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
 const char* const pin_array[][3] PROGMEM = {
77
 const char* const pin_array[][3] PROGMEM = {
82
 
78
 
92
   // manually add pins ...
88
   // manually add pins ...
93
   #if SERIAL_PORT == 0
89
   #if SERIAL_PORT == 0
94
     #if AVR_ATmega2560_FAMILY
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
     #elif AVR_ATmega1284_FAMILY
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
     #endif
96
     #endif
101
   #endif
97
   #endif
102
 
98
 
103
-  #line 0   // set __LINE__ to the SAME known value for the second pass
104
   #include "pinsDebug_list.h"
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
 #ifndef TIMER1B
106
 #ifndef TIMER1B
113
   // working with Teensyduino extension so need to re-define some things
107
   // working with Teensyduino extension so need to re-define some things
114
   #include "pinsDebug_Teensyduino.h"
108
   #include "pinsDebug_Teensyduino.h"
115
 #endif
109
 #endif
116
 
110
 
117
-
118
 #define PWM_PRINT(V) do{ sprintf(buffer, "PWM:  %4d", V); SERIAL_ECHO(buffer); }while(0)
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
     if (TCCR##N##A & (_BV(COM##N##Z##1) | _BV(COM##N##Z##0))) { \
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
     } else return false
117
     } else return false
125
 
118
 
126
 /**
119
 /**
130
 static bool pwm_status(uint8_t pin) {
123
 static bool pwm_status(uint8_t pin) {
131
   char buffer[20];   // for the sprintf statements
124
   char buffer[20];   // for the sprintf statements
132
 
125
 
133
-  switch(digitalPinToTimer(pin)) {
126
+  switch (digitalPinToTimer(pin)) {
134
 
127
 
135
     #if defined(TCCR0A) && defined(COM0A1)
128
     #if defined(TCCR0A) && defined(COM0A1)
136
       #ifdef TIMER0A
129
       #ifdef TIMER0A
137
-        PWM_CASE(0,A);
130
+        PWM_CASE(0, A);
138
       #endif
131
       #endif
139
-      PWM_CASE(0,B);
132
+      PWM_CASE(0, B);
140
     #endif
133
     #endif
141
 
134
 
142
     #if defined(TCCR1A) && defined(COM1A1)
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
      #if defined(COM1C1) && defined(TIMER1C)
138
      #if defined(COM1C1) && defined(TIMER1C)
146
-      PWM_CASE(1,C);
139
+      PWM_CASE(1, C);
147
      #endif
140
      #endif
148
     #endif
141
     #endif
149
 
142
 
150
     #if defined(TCCR2A) && defined(COM2A1)
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
     #endif
146
     #endif
154
 
147
 
155
     #if defined(TCCR3A) && defined(COM3A1)
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
       #ifdef COM3C1
151
       #ifdef COM3C1
159
-        PWM_CASE(3,C);
152
+        PWM_CASE(3, C);
160
       #endif
153
       #endif
161
     #endif
154
     #endif
162
 
155
 
163
     #ifdef TCCR4A
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
     #endif
160
     #endif
168
 
161
 
169
     #if defined(TCCR5A) && defined(COM5A1)
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
     #endif
166
     #endif
174
 
167
 
175
     case NOT_ON_TIMER:
168
     case NOT_ON_TIMER:
176
     default:
169
     default:
177
       return false;
170
       return false;
178
   }
171
   }
179
-  SERIAL_PROTOCOLPGM("  ");
172
+  SERIAL_PROTOCOL_SP(2);
180
 } // pwm_status
173
 } // pwm_status
181
 
174
 
182
 
175
 
183
-
184
 const volatile uint8_t* const PWM_other[][3] PROGMEM = {
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
   #if defined(TCCR2A) && defined(COM2A1)
179
   #if defined(TCCR2A) && defined(COM2A1)
188
-    {&TCCR2A, &TCCR2B, &TIMSK2},
180
+    { &TCCR2A, &TCCR2B, &TIMSK2 },
189
   #endif
181
   #endif
190
   #if defined(TCCR3A) && defined(COM3A1)
182
   #if defined(TCCR3A) && defined(COM3A1)
191
-    {&TCCR3A, &TCCR3B, &TIMSK3},
183
+    { &TCCR3A, &TCCR3B, &TIMSK3 },
192
   #endif
184
   #endif
193
   #ifdef TCCR4A
185
   #ifdef TCCR4A
194
-    {&TCCR4A, &TCCR4B, &TIMSK4},
186
+    { &TCCR4A, &TCCR4B, &TIMSK4 },
195
   #endif
187
   #endif
196
   #if defined(TCCR5A) && defined(COM5A1)
188
   #if defined(TCCR5A) && defined(COM5A1)
197
-    {&TCCR5A, &TCCR5B, &TIMSK5},
189
+    { &TCCR5A, &TCCR5B, &TIMSK5 },
198
   #endif
190
   #endif
199
 };
191
 };
200
 
192
 
202
 const volatile uint8_t* const PWM_OCR[][3] PROGMEM = {
194
 const volatile uint8_t* const PWM_OCR[][3] PROGMEM = {
203
 
195
 
204
   #ifdef TIMER0A
196
   #ifdef TIMER0A
205
-    {&OCR0A,&OCR0B,0},
197
+    { &OCR0A, &OCR0B, 0 },
206
   #else
198
   #else
207
-    {0,&OCR0B,0},
199
+    { 0, &OCR0B, 0 },
208
   #endif
200
   #endif
209
 
201
 
210
   #if defined(COM1C1) && defined(TIMER1C)
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
   #else
204
   #else
213
-   { (const uint8_t*)&OCR1A, (const uint8_t*)&OCR1B,0},
205
+   { (const uint8_t*)&OCR1A, (const uint8_t*)&OCR1B, 0 },
214
   #endif
206
   #endif
215
 
207
 
216
   #if defined(TCCR2A) && defined(COM2A1)
208
   #if defined(TCCR2A) && defined(COM2A1)
217
-    {&OCR2A,&OCR2B,0},
209
+    { &OCR2A, &OCR2B, 0 },
218
   #endif
210
   #endif
219
 
211
 
220
   #if defined(TCCR3A) && defined(COM3A1)
212
   #if defined(TCCR3A) && defined(COM3A1)
221
     #ifdef COM3C1
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
     #else
215
     #else
224
-      { (const uint8_t*)&OCR3A, (const uint8_t*)&OCR3B,0},
216
+      { (const uint8_t*)&OCR3A, (const uint8_t*)&OCR3B, 0 },
225
     #endif
217
     #endif
226
   #endif
218
   #endif
227
 
219
 
228
   #ifdef TCCR4A
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
   #endif
222
   #endif
231
 
223
 
232
   #if defined(TCCR5A) && defined(COM5A1)
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
   #endif
226
   #endif
235
 };
227
 };
236
 
228
 
247
 #define WGM_3      4
239
 #define WGM_3      4
248
 #define TOIE       0
240
 #define TOIE       0
249
 
241
 
250
-
251
 #define OCR_VAL(T, L)   pgm_read_word(&PWM_OCR[T][L])
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
 void com_print(uint8_t N, uint8_t Z) {
248
 void com_print(uint8_t N, uint8_t Z) {
265
   uint8_t *TCCRA = (uint8_t*)TCCR_A(N);
249
   uint8_t *TCCRA = (uint8_t*)TCCR_A(N);
266
   SERIAL_PROTOCOLPGM("    COM");
250
   SERIAL_PROTOCOLPGM("    COM");
267
   SERIAL_PROTOCOLCHAR(N + '0');
251
   SERIAL_PROTOCOLCHAR(N + '0');
268
-  switch(Z) {
269
-    case 'A' :
252
+  switch (Z) {
253
+    case 'A':
270
       SERIAL_PROTOCOLPAIR("A: ", ((*TCCRA & (_BV(7) | _BV(6))) >> 6));
254
       SERIAL_PROTOCOLPAIR("A: ", ((*TCCRA & (_BV(7) | _BV(6))) >> 6));
271
       break;
255
       break;
272
-    case 'B' :
256
+    case 'B':
273
       SERIAL_PROTOCOLPAIR("B: ", ((*TCCRA & (_BV(5) | _BV(4))) >> 4));
257
       SERIAL_PROTOCOLPAIR("B: ", ((*TCCRA & (_BV(5) | _BV(4))) >> 4));
274
       break;
258
       break;
275
-    case 'C' :
259
+    case 'C':
276
       SERIAL_PROTOCOLPAIR("C: ", ((*TCCRA & (_BV(3) | _BV(2))) >> 2));
260
       SERIAL_PROTOCOLPAIR("C: ", ((*TCCRA & (_BV(3) | _BV(2))) >> 2));
277
       break;
261
       break;
278
   }
262
   }
288
   SERIAL_PROTOCOLPGM("    TIMER");
272
   SERIAL_PROTOCOLPGM("    TIMER");
289
   SERIAL_PROTOCOLCHAR(T + '0');
273
   SERIAL_PROTOCOLCHAR(T + '0');
290
   SERIAL_PROTOCOLCHAR(L);
274
   SERIAL_PROTOCOLCHAR(L);
291
-  SERIAL_PROTOCOLPGM("   ");
275
+  SERIAL_PROTOCOL_SP(3);
292
 
276
 
293
   if (N == 3) {
277
   if (N == 3) {
294
     uint8_t *OCRVAL8 = (uint8_t*)OCR_VAL(T, L - 'A');
278
     uint8_t *OCRVAL8 = (uint8_t*)OCR_VAL(T, L - 'A');
316
   SERIAL_PROTOCOLPAIR(": ", *TMSK);
300
   SERIAL_PROTOCOLPAIR(": ", *TMSK);
317
 
301
 
318
   uint8_t OCIE = L - 'A' + 1;
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
   if (TEST(*TMSK, OCIE)) err_is_interrupt();
305
   if (TEST(*TMSK, OCIE)) err_is_interrupt();
322
   if (TEST(*TMSK, TOIE)) err_prob_interrupt();
306
   if (TEST(*TMSK, TOIE)) err_prob_interrupt();
323
 }
307
 }
324
 
308
 
325
 static void pwm_details(uint8_t pin) {
309
 static void pwm_details(uint8_t pin) {
326
-  switch(digitalPinToTimer(pin)) {
310
+  switch (digitalPinToTimer(pin)) {
327
 
311
 
328
     #if defined(TCCR0A) && defined(COM0A1)
312
     #if defined(TCCR0A) && defined(COM0A1)
329
       #ifdef TIMER0A
313
       #ifdef TIMER0A

Loading…
Cancelar
Guardar