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
   tc->TC_CHANNEL[channel].TC_SR;
76
   tc->TC_CHANNEL[channel].TC_SR;
77
   if (Channel[timer] < 0)
77
   if (Channel[timer] < 0)
78
     tc->TC_CHANNEL[channel].TC_CCR |= TC_CCR_SWTRG; // channel set to -1 indicated that refresh interval completed so reset the timer
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
   Channel[timer]++;    // increment to the next channel
82
   Channel[timer]++;    // increment to the next channel
83
   if (SERVO_INDEX(timer, Channel[timer]) < ServoCount && Channel[timer] < SERVOS_PER_TIMER) {
83
   if (SERVO_INDEX(timer, Channel[timer]) < ServoCount && Channel[timer] < SERVOS_PER_TIMER) {
84
     tc->TC_CHANNEL[channel].TC_RA = tc->TC_CHANNEL[channel].TC_CV + SERVO(timer,Channel[timer]).ticks;
84
     tc->TC_CHANNEL[channel].TC_RA = tc->TC_CHANNEL[channel].TC_CV + SERVO(timer,Channel[timer]).ticks;
85
     if (SERVO(timer,Channel[timer]).Pin.isActive)    // check if activated
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
   else {
88
   else {
89
     // finished all channels so wait for the refresh period to expire before starting over
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
     ||  MB(RAMPS_14_RE_ARM_SF))
74
     ||  MB(RAMPS_14_RE_ARM_SF))
75
   #error "Re-ARM with REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER and TMC2130 require TMC_USE_SW_SPI"
75
   #error "Re-ARM with REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER and TMC2130 require TMC_USE_SW_SPI"
76
 #endif
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
   //debug_frmwrk_init();
56
   //debug_frmwrk_init();
57
   //_DBG("\n\nDebug running\n");
57
   //_DBG("\n\nDebug running\n");
58
   // Initialise the SD card chip select pins as soon as possible
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
   #endif
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
   #endif
67
   #endif
68
+
67
   USB_Init();                               // USB Initialization
69
   USB_Init();                               // USB Initialization
68
   USB_Connect(FALSE);                       // USB clear connection
70
   USB_Connect(FALSE);                       // USB clear connection
69
   delay(1000);                              // Give OS time to notice
71
   delay(1000);                              // Give OS time to notice
70
   USB_Connect(TRUE);
72
   USB_Connect(TRUE);
71
-  #ifndef USB_SD_DISABLED
73
+
74
+  #if DISABLED(USB_SD_DISABLED)
72
     MSC_SD_Init(0);                         // Enable USB SD card access
75
     MSC_SD_Init(0);                         // Enable USB SD card access
73
   #endif
76
   #endif
77
+
74
   const millis_t usb_timeout = millis() + 2000;
78
   const millis_t usb_timeout = millis() + 2000;
75
   while (!USB_Configuration && PENDING(millis(), usb_timeout)) {
79
   while (!USB_Configuration && PENDING(millis(), usb_timeout)) {
76
     delay(50);
80
     delay(50);
94
 
98
 
95
 // HAL idle task
99
 // HAL idle task
96
 void HAL_idletask(void) {
100
 void HAL_idletask(void) {
97
-  #if ENABLED(SDSUPPORT) && defined(SHARED_SD_CARD)
101
+  #if ENABLED(SDSUPPORT) && ENABLED(SHARED_SD_CARD)
98
     // If Marlin is using the SD card we need to lock it to prevent access from
102
     // If Marlin is using the SD card we need to lock it to prevent access from
99
     // a PC via USB.
103
     // a PC via USB.
100
     // Other HALs use IS_SD_PRINTING() and IS_SD_FILE_OPEN() to check for access but
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
       timerConfig[0].IRQ_Id = TIM5_IRQn;
85
       timerConfig[0].IRQ_Id = TIM5_IRQn;
86
       timerConfig[0].callback = (uint32_t)TC5_Handler;
86
       timerConfig[0].callback = (uint32_t)TC5_Handler;
87
       HAL_NVIC_SetPriority(timerConfig[0].IRQ_Id, 1, 0);
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
       break;
90
       break;
91
     case TEMP_TIMER_NUM:
91
     case TEMP_TIMER_NUM:
92
       //TEMP TIMER TIM7 // any available 16bit Timer (1 already used for PWM)
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
   pinMode(step_pin, OUTPUT);
190
   pinMode(step_pin, OUTPUT);
191
   pinMode(dir_pin, OUTPUT);
191
   pinMode(dir_pin, OUTPUT);
192
   pinMode(cs_pin, OUTPUT);
192
   pinMode(cs_pin, OUTPUT);
193
-  //pinMode(STEPPER_ENABLE_PIN, OUTPUT);
193
+  //SET_OUTPUT(STEPPER_ENABLE_PIN);
194
   digitalWrite(step_pin, LOW);
194
   digitalWrite(step_pin, LOW);
195
   digitalWrite(dir_pin, LOW);
195
   digitalWrite(dir_pin, LOW);
196
   digitalWrite(cs_pin, HIGH);
196
   digitalWrite(cs_pin, HIGH);
887
   //}
887
   //}
888
 
888
 
889
   //select the TMC driver
889
   //select the TMC driver
890
-  digitalWrite(cs_pin,LOW);
890
+  digitalWrite(cs_pin, LOW);
891
 
891
 
892
   //ensure that only valid bist are set (0-19)
892
   //ensure that only valid bist are set (0-19)
893
   //datagram &=REGISTER_BIT_PATTERN;
893
   //datagram &=REGISTER_BIT_PATTERN;
916
   #endif
916
   #endif
917
 
917
 
918
   //deselect the TMC chip
918
   //deselect the TMC chip
919
-  digitalWrite(cs_pin,HIGH);
919
+  digitalWrite(cs_pin, HIGH);
920
 
920
 
921
   //restore the previous SPI mode if neccessary
921
   //restore the previous SPI mode if neccessary
922
   //if the mode is not correct set it to mode 3
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
                               // is powered on to enable SD access.
187
                               // is powered on to enable SD access.
188
 
188
 
189
 #if ENABLED(LPC_SD_LCD)
189
 #if ENABLED(LPC_SD_LCD)
190
+
190
   #define SCK_PIN            P0_15
191
   #define SCK_PIN            P0_15
191
   #define MISO_PIN           P0_17
192
   #define MISO_PIN           P0_17
192
   #define MOSI_PIN           P0_18
193
   #define MOSI_PIN           P0_18
193
   #define SS_PIN             P1_23   // Chip select for SD card used by Marlin
194
   #define SS_PIN             P1_23   // Chip select for SD card used by Marlin
194
   #define ONBOARD_SD_CS      P0_06   // Chip select for "System" SD card
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
   #if ENABLED(USB_SD_ONBOARD)
199
   #if ENABLED(USB_SD_ONBOARD)
199
     // When sharing the SD card with a PC we want the menu options to
200
     // When sharing the SD card with a PC we want the menu options to
200
     // mount/unmount the card and refresh it. So we disable card detect.
201
     // mount/unmount the card and refresh it. So we disable card detect.
206
   #define MOSI_PIN           P0_09
207
   #define MOSI_PIN           P0_09
207
   #define SS_PIN             P0_06   // Chip select for SD card used by Marlin
208
   #define SS_PIN             P0_06   // Chip select for SD card used by Marlin
208
   #define ONBOARD_SD_CS      P0_06   // Chip select for "System" SD card
209
   #define ONBOARD_SD_CS      P0_06   // Chip select for "System" SD card
210
+
209
 #endif
211
 #endif

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

196
 
196
 
197
 /*
197
 /*
198
  * There are a number of configurations available for the SBase SD card reader.
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
 //#define LPC_SD_CUSTOM_CABLE // Use a custom cable to access the SD
204
 //#define LPC_SD_CUSTOM_CABLE // Use a custom cable to access the SD
205
 //#define LPC_SD_LCD          // Marlin uses the SD drive attached to the LCD
205
 //#define LPC_SD_LCD          // Marlin uses the SD drive attached to the LCD
206
 #define LPC_SD_ONBOARD        // Marlin uses the SD drive attached to the control board
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
    * A custom cable is needed. See the README file in the
211
    * A custom cable is needed. See the README file in the
211
    * Marlin\src\config\examples\Mks\Sbase directory
212
    * Marlin\src\config\examples\Mks\Sbase directory
218
    * If you can't find a pin to use for the LCD's SD_DETECT then comment out
219
    * If you can't find a pin to use for the LCD's SD_DETECT then comment out
219
    * SD_DETECT_PIN entirely and remove that wire from the the custom cable.
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
   #define LPC_SOFTWARE_SPI  // With a custom cable we need software SPI because the
228
   #define LPC_SOFTWARE_SPI  // With a custom cable we need software SPI because the
228
                             // selected pins are not on a hardware SPI controller
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
   // use standard cable and header, SPI and SD detect sre shared with on-board SD card
232
   // use standard cable and header, SPI and SD detect sre shared with on-board SD card
233
   // hardware SPI is used for both SD cards. The detect pin is shred between the
233
   // hardware SPI is used for both SD cards. The detect pin is shred between the
234
   // LCD and onboard SD readers so we disable it.
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
   // The external SD card is not used. Hardware SPI is used to access the card.
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
     // When sharing the SD card with a PC we want the menu options to
245
     // When sharing the SD card with a PC we want the menu options to
247
     // mount/unmount the card and refresh it. So we disable card detect.
246
     // mount/unmount the card and refresh it. So we disable card detect.
248
     #define SHARED_SD_CARD
247
     #define SHARED_SD_CARD
249
-    #undef SD_DETECT_PIN
250
   #else
248
   #else
251
-    #define SD_DETECT_PIN      P0_27
249
+    #define SD_DETECT_PIN  P0_27
252
   #endif
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
 #endif
257
 #endif
259
 
258
 
260
 /**
259
 /**
286
   #endif
285
   #endif
287
  #endif
286
  #endif
288
 #endif
287
 #endif
288
+
289
 #if HAS_DRIVER(TMC2208)
289
 #if HAS_DRIVER(TMC2208)
290
   // The shortage of pins becomes apparent.
290
   // The shortage of pins becomes apparent.
291
   // Worst case you may have to give up the LCD
291
   // Worst case you may have to give up the LCD

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

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

Loading…
Cancel
Save