Browse Source

Use FastIO, sanity-check LPC SD options, apply formatting (#12231)

Scott Lahteine 5 years ago
parent
commit
5580773191
No account linked to committer's email address

+ 3
- 3
Marlin/src/HAL/HAL_DUE/Servo_Due.cpp View File

@@ -76,14 +76,14 @@ void Servo_Handler(timer16_Sequence_t timer, Tc *tc, uint8_t channel) {
76 76
   tc->TC_CHANNEL[channel].TC_SR;
77 77
   if (Channel[timer] < 0)
78 78
     tc->TC_CHANNEL[channel].TC_CCR |= TC_CCR_SWTRG; // channel set to -1 indicated that refresh interval completed so reset the timer
79
-  else if (SERVO_INDEX(timer,Channel[timer]) < ServoCount && SERVO(timer,Channel[timer]).Pin.isActive)
80
-    digitalWrite(SERVO(timer,Channel[timer]).Pin.nbr, LOW); // pulse this channel low if activated
79
+  else if (SERVO_INDEX(timer, Channel[timer]) < ServoCount && SERVO(timer, Channel[timer]).Pin.isActive)
80
+    digitalWrite(SERVO(timer, Channel[timer]).Pin.nbr, LOW); // pulse this channel low if activated
81 81
 
82 82
   Channel[timer]++;    // increment to the next channel
83 83
   if (SERVO_INDEX(timer, Channel[timer]) < ServoCount && Channel[timer] < SERVOS_PER_TIMER) {
84 84
     tc->TC_CHANNEL[channel].TC_RA = tc->TC_CHANNEL[channel].TC_CV + SERVO(timer,Channel[timer]).ticks;
85 85
     if (SERVO(timer,Channel[timer]).Pin.isActive)    // check if activated
86
-      digitalWrite( SERVO(timer,Channel[timer]).Pin.nbr,HIGH); // its an active channel so pulse it high
86
+      digitalWrite(SERVO(timer, Channel[timer]).Pin.nbr, HIGH); // its an active channel so pulse it high
87 87
   }
88 88
   else {
89 89
     // finished all channels so wait for the refresh period to expire before starting over

+ 8
- 0
Marlin/src/HAL/HAL_LPC1768/SanityCheck.h View File

@@ -74,3 +74,11 @@
74 74
     ||  MB(RAMPS_14_RE_ARM_SF))
75 75
   #error "Re-ARM with REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER and TMC2130 require TMC_USE_SW_SPI"
76 76
 #endif
77
+
78
+#if 1 < (ENABLED(LPC_SD_CUSTOM_CABLE) + ENABLED(LPC_SD_LCD) + ENABLED(LPC_SD_ONBOARD))
79
+  #error "Enable only one of LPC_SD_CUSTOM_CABLE, LPC_SD_LCD, or LPC_SD_ONBOARD."
80
+#endif
81
+
82
+#if 1 < (ENABLED(USB_SD_DISABLED) + ENABLED(USB_SD_ONBOARD))
83
+  #error "Enable only one of USB_SD_DISABLED or USB_SD_ONBOARD."
84
+#endif

+ 12
- 8
Marlin/src/HAL/HAL_LPC1768/main.cpp View File

@@ -56,21 +56,25 @@ void HAL_init() {
56 56
   //debug_frmwrk_init();
57 57
   //_DBG("\n\nDebug running\n");
58 58
   // Initialise the SD card chip select pins as soon as possible
59
-  #ifdef SS_PIN
60
-    digitalWrite(SS_PIN, HIGH);
61
-    pinMode(SS_PIN, OUTPUT);
59
+  #if PIN_EXISTS(SS)
60
+    WRITE(SS_PIN, HIGH);
61
+    SET_OUTPUT(SS_PIN);
62 62
   #endif
63
-  #ifdef ONBOARD_SD_CS
64
-    digitalWrite(ONBOARD_SD_CS, HIGH);
65
-    pinMode(ONBOARD_SD_CS, OUTPUT);
63
+
64
+  #if defined(ONBOARD_SD_CS) && ONBOARD_SD_CS > -1
65
+    WRITE(ONBOARD_SD_CS, HIGH);
66
+    SET_OUTPUT(ONBOARD_SD_CS);
66 67
   #endif
68
+
67 69
   USB_Init();                               // USB Initialization
68 70
   USB_Connect(FALSE);                       // USB clear connection
69 71
   delay(1000);                              // Give OS time to notice
70 72
   USB_Connect(TRUE);
71
-  #ifndef USB_SD_DISABLED
73
+
74
+  #if DISABLED(USB_SD_DISABLED)
72 75
     MSC_SD_Init(0);                         // Enable USB SD card access
73 76
   #endif
77
+
74 78
   const millis_t usb_timeout = millis() + 2000;
75 79
   while (!USB_Configuration && PENDING(millis(), usb_timeout)) {
76 80
     delay(50);
@@ -94,7 +98,7 @@ void HAL_init() {
94 98
 
95 99
 // HAL idle task
96 100
 void HAL_idletask(void) {
97
-  #if ENABLED(SDSUPPORT) && defined(SHARED_SD_CARD)
101
+  #if ENABLED(SDSUPPORT) && ENABLED(SHARED_SD_CARD)
98 102
     // If Marlin is using the SD card we need to lock it to prevent access from
99 103
     // a PC via USB.
100 104
     // Other HALs use IS_SD_PRINTING() and IS_SD_FILE_OPEN() to check for access but

+ 2
- 2
Marlin/src/HAL/HAL_STM32F7/HAL_timers_STM32F7.cpp View File

@@ -85,8 +85,8 @@ void HAL_timer_start(const uint8_t timer_num, const uint32_t frequency) {
85 85
       timerConfig[0].IRQ_Id = TIM5_IRQn;
86 86
       timerConfig[0].callback = (uint32_t)TC5_Handler;
87 87
       HAL_NVIC_SetPriority(timerConfig[0].IRQ_Id, 1, 0);
88
-      pinMode(STEPPER_ENABLE_PIN,OUTPUT);
89
-      digitalWrite(STEPPER_ENABLE_PIN,LOW);
88
+      SET_OUTPUT(STEPPER_ENABLE_PIN);
89
+      WRITE(STEPPER_ENABLE_PIN);
90 90
       break;
91 91
     case TEMP_TIMER_NUM:
92 92
       //TEMP TIMER TIM7 // any available 16bit Timer (1 already used for PWM)

+ 3
- 3
Marlin/src/HAL/HAL_STM32F7/TMC2660.cpp View File

@@ -190,7 +190,7 @@ void TMC26XStepper::start() {
190 190
   pinMode(step_pin, OUTPUT);
191 191
   pinMode(dir_pin, OUTPUT);
192 192
   pinMode(cs_pin, OUTPUT);
193
-  //pinMode(STEPPER_ENABLE_PIN, OUTPUT);
193
+  //SET_OUTPUT(STEPPER_ENABLE_PIN);
194 194
   digitalWrite(step_pin, LOW);
195 195
   digitalWrite(dir_pin, LOW);
196 196
   digitalWrite(cs_pin, HIGH);
@@ -887,7 +887,7 @@ inline void TMC26XStepper::send262(uint32_t datagram) {
887 887
   //}
888 888
 
889 889
   //select the TMC driver
890
-  digitalWrite(cs_pin,LOW);
890
+  digitalWrite(cs_pin, LOW);
891 891
 
892 892
   //ensure that only valid bist are set (0-19)
893 893
   //datagram &=REGISTER_BIT_PATTERN;
@@ -916,7 +916,7 @@ inline void TMC26XStepper::send262(uint32_t datagram) {
916 916
   #endif
917 917
 
918 918
   //deselect the TMC chip
919
-  digitalWrite(cs_pin,HIGH);
919
+  digitalWrite(cs_pin, HIGH);
920 920
 
921 921
   //restore the previous SPI mode if neccessary
922 922
   //if the mode is not correct set it to mode 3

+ 4
- 2
Marlin/src/pins/pins_AZTEEG_X5_MINI_WIFI.h View File

@@ -187,14 +187,15 @@
187 187
                               // is powered on to enable SD access.
188 188
 
189 189
 #if ENABLED(LPC_SD_LCD)
190
+
190 191
   #define SCK_PIN            P0_15
191 192
   #define MISO_PIN           P0_17
192 193
   #define MOSI_PIN           P0_18
193 194
   #define SS_PIN             P1_23   // Chip select for SD card used by Marlin
194 195
   #define ONBOARD_SD_CS      P0_06   // Chip select for "System" SD card
195
-#endif
196 196
 
197
-#if ENABLED(LPC_SD_ONBOARD)
197
+#elif ENABLED(LPC_SD_ONBOARD)
198
+
198 199
   #if ENABLED(USB_SD_ONBOARD)
199 200
     // When sharing the SD card with a PC we want the menu options to
200 201
     // mount/unmount the card and refresh it. So we disable card detect.
@@ -206,4 +207,5 @@
206 207
   #define MOSI_PIN           P0_09
207 208
   #define SS_PIN             P0_06   // Chip select for SD card used by Marlin
208 209
   #define ONBOARD_SD_CS      P0_06   // Chip select for "System" SD card
210
+
209 211
 #endif

+ 28
- 28
Marlin/src/pins/pins_MKS_SBASE.h View File

@@ -196,16 +196,17 @@
196 196
 
197 197
 /*
198 198
  * There are a number of configurations available for the SBase SD card reader.
199
- * A custom cable can be used to allow access to the LCD based SD card.
200
- * A standard cable can be used for access to the LCD SD card (but no SD detect).
201
- * The onboard SD card can be used and optionally shared with a PC via USB.
199
+ * - A custom cable can be used to allow access to the LCD based SD card.
200
+ * - A standard cable can be used for access to the LCD SD card (but no SD detect).
201
+ * - The onboard SD card can be used and optionally shared with a PC via USB.
202 202
  */
203 203
 
204 204
 //#define LPC_SD_CUSTOM_CABLE // Use a custom cable to access the SD
205 205
 //#define LPC_SD_LCD          // Marlin uses the SD drive attached to the LCD
206 206
 #define LPC_SD_ONBOARD        // Marlin uses the SD drive attached to the control board
207 207
 
208
-#ifdef LPC_SD_CUSTOM_CABLE
208
+#if ENABLED(LPC_SD_CUSTOM_CABLE)
209
+
209 210
   /**
210 211
    * A custom cable is needed. See the README file in the
211 212
    * Marlin\src\config\examples\Mks\Sbase directory
@@ -218,43 +219,41 @@
218 219
    * If you can't find a pin to use for the LCD's SD_DETECT then comment out
219 220
    * SD_DETECT_PIN entirely and remove that wire from the the custom cable.
220 221
    */
221
-  #define SD_DETECT_PIN      P2_11   // J8-5 (moved from EXP2 P0.27)
222
-  #define SCK_PIN            P1_22   // J8-2 (moved from EXP2 P0.7)
223
-  #define MISO_PIN           P1_23   // J8-3 (moved from EXP2 P0.8)
224
-  #define MOSI_PIN           P2_12   // J8-4 (moved from EXP2 P0.9)
225
-  #define SS_PIN             P0_28   // Chip select for SD card used by Marlin
226
-  #define ONBOARD_SD_CS      P0_06   // Chip select for "System" SD card
222
+  #define SD_DETECT_PIN    P2_11   // J8-5 (moved from EXP2 P0.27)
223
+  #define SCK_PIN          P1_22   // J8-2 (moved from EXP2 P0.7)
224
+  #define MISO_PIN         P1_23   // J8-3 (moved from EXP2 P0.8)
225
+  #define MOSI_PIN         P2_12   // J8-4 (moved from EXP2 P0.9)
226
+  #define SS_PIN           P0_28   // Chip select for SD card used by Marlin
227
+  #define ONBOARD_SD_CS    P0_06   // Chip select for "System" SD card
227 228
   #define LPC_SOFTWARE_SPI  // With a custom cable we need software SPI because the
228 229
                             // selected pins are not on a hardware SPI controller
229
-#endif
230
+#elif ENABLED(LPC_SD_LCD)
230 231
 
231
-#ifdef LPC_SD_LCD
232 232
   // use standard cable and header, SPI and SD detect sre shared with on-board SD card
233 233
   // hardware SPI is used for both SD cards. The detect pin is shred between the
234 234
   // LCD and onboard SD readers so we disable it.
235
-  #undef SD_DETECT_PIN
236
-  #define SCK_PIN            P0_07
237
-  #define MISO_PIN           P0_08
238
-  #define MOSI_PIN           P0_09
239
-  #define SS_PIN             P0_28   // Chip select for SD card used by Marlin
240
-  #define ONBOARD_SD_CS      P0_06   // Chip select for "System" SD card
241
-#endif
235
+  #define SCK_PIN          P0_07
236
+  #define MISO_PIN         P0_08
237
+  #define MOSI_PIN         P0_09
238
+  #define SS_PIN           P0_28   // Chip select for SD card used by Marlin
239
+  #define ONBOARD_SD_CS    P0_06   // Chip select for "System" SD card
240
+
241
+#elif ENABLED(LPC_SD_ONBOARD)
242 242
 
243
-#ifdef LPC_SD_ONBOARD
244 243
   // The external SD card is not used. Hardware SPI is used to access the card.
245
-  #ifdef USB_SD_ONBOARD
244
+  #if ENABLED(USB_SD_ONBOARD)
246 245
     // When sharing the SD card with a PC we want the menu options to
247 246
     // mount/unmount the card and refresh it. So we disable card detect.
248 247
     #define SHARED_SD_CARD
249
-    #undef SD_DETECT_PIN
250 248
   #else
251
-    #define SD_DETECT_PIN      P0_27
249
+    #define SD_DETECT_PIN  P0_27
252 250
   #endif
253
-  #define SCK_PIN            P0_07
254
-  #define MISO_PIN           P0_08
255
-  #define MOSI_PIN           P0_09
256
-  #define SS_PIN             P0_06   // Chip select for SD card used by Marlin
257
-  #define ONBOARD_SD_CS      P0_06   // Chip select for "System" SD card
251
+  #define SCK_PIN          P0_07
252
+  #define MISO_PIN         P0_08
253
+  #define MOSI_PIN         P0_09
254
+  #define SS_PIN           P0_06   // Chip select for SD card used by Marlin
255
+  #define ONBOARD_SD_CS    P0_06   // Chip select for "System" SD card
256
+
258 257
 #endif
259 258
 
260 259
 /**
@@ -286,6 +285,7 @@
286 285
   #endif
287 286
  #endif
288 287
 #endif
288
+
289 289
 #if HAS_DRIVER(TMC2208)
290 290
   // The shortage of pins becomes apparent.
291 291
   // Worst case you may have to give up the LCD

+ 8
- 7
Marlin/src/pins/pins_RAMPS_RE_ARM.h View File

@@ -363,23 +363,23 @@
363 363
 #define ENET_TXD0     P1_00   // (78)  J12-11
364 364
 #define ENET_TXD1     P1_01   // (79)  J12-12
365 365
 
366
-
367 366
 //#define USB_SD_DISABLED
368 367
 #define USB_SD_ONBOARD        // Provide the onboard SD card to the host as a USB mass storage device
369 368
 
370 369
 //#define LPC_SD_LCD          // Marlin uses the SD drive attached to the LCD
371 370
 #define LPC_SD_ONBOARD        // Marlin uses the SD drive on the control board
372 371
 
373
-#ifdef LPC_SD_LCD
372
+#if ENABLED(LPC_SD_LCD)
373
+
374 374
   #define SCK_PIN            P0_15
375 375
   #define MISO_PIN           P0_17
376 376
   #define MOSI_PIN           P0_18
377 377
   #define SS_PIN             P1_23   // Chip select for SD card used by Marlin
378 378
   #define ONBOARD_SD_CS      P0_06   // Chip select for "System" SD card
379
-#endif
380 379
 
381
-#ifdef LPC_SD_ONBOARD
382
-  #ifdef USB_SD_ONBOARD
380
+#elif ENABLED(LPC_SD_ONBOARD)
381
+
382
+  #if ENABLED(USB_SD_ONBOARD)
383 383
     // When sharing the SD card with a PC we want the menu options to
384 384
     // mount/unmount the card and refresh it. So we disable card detect.
385 385
     #define SHARED_SD_CARD
@@ -390,10 +390,11 @@
390 390
   #define MOSI_PIN           P0_09
391 391
   #define SS_PIN             P0_06   // Chip select for SD card used by Marlin
392 392
   #define ONBOARD_SD_CS      P0_06   // Chip select for "System" SD card
393
+
393 394
 #endif
394 395
 
395 396
 /**
396
- *  Fast PWMS
397
+ *  Fast PWMs
397 398
  *
398 399
  *  The LPC1768's hardware PWM controller has 6 channels.  Each channel
399 400
  *  can be setup to either control a dedicated pin directly or to generate
@@ -418,7 +419,7 @@
418 419
  */
419 420
 
420 421
  /**
421
-  * special pins
422
+  * Special pins
422 423
   *   P1_30  (37) - not 5V tolerant
423 424
   *   P1_31  (49) - not 5V tolerant
424 425
   *   P0_27  (57) - open collector

Loading…
Cancel
Save