Browse Source

MKS Sbase changes

Bob-the-Kuhn 7 years ago
parent
commit
59b32c25b5
2 changed files with 46 additions and 5 deletions
  1. 37
    5
      Marlin/src/HAL/HAL_LPC1768/LPC1768_PWM.cpp
  2. 9
    0
      Marlin/src/pins/pins_MKS_SBASE.h

+ 37
- 5
Marlin/src/HAL/HAL_LPC1768/LPC1768_PWM.cpp View File

@@ -64,14 +64,29 @@
64 64
  * See the end of this file for details on the hardware/firmware interaction
65 65
  */
66 66
 
67
+/**
68
+ * Directly controlled PWM pins (
69
+ *   NA means not being used as a directly controlled PWM pin
70
+ *
71
+ *                   Re-ARM              MKS Sbase
72
+ *  PWM1.1   P1_18   SERVO3_PIN           NA(no connection)
73
+ *  PWM1.1   P2_00    NA(E0_STEP_PIN)     NA(X stepper)
74
+ *  PWM1.2   P1_20   SERVO0_PIN           NA(no connection)
75
+ *  PWM1.2   P2_01    NA(X_STEP_PIN)      NA(Y stepper)
76
+ *  PWM1.3   P1_21   SERVO1_PIN           NA(no connection)
77
+ *  PWM1.3   P2_02    NA(Y_STEP_PIN)      NA(Z stepper)
78
+ *  PWM1.4   P1_23    NA(SDSS(SSEL0))    SERVO0_PIN
79
+ *  PWM1.4   P2_03    NA(Z_STEP_PIN)      NA(E0 stepper)
80
+ *  PWM1.5   P1_24    NA(X_MIN_PIN)       NA(X_MIN_pin)
81
+ *  PWM1.5   P2_04   RAMPS_D9_PIN        FAN_PIN
82
+ *  PWM1.6   P1_26    NA(Y_MIN_PIN)       NA(Y_MIN_pin)
83
+ *  PWM1.6   P2_05   RAMPS_D10_PIN       HEATER_BED_PIN
84
+ */
85
+
67 86
 #ifdef TARGET_LPC1768
68 87
 
69 88
 #include "../../inc/MarlinConfig.h"
70 89
 
71
-// #include <math.h>
72
-// #include <stdio.h>
73
-// #include <stdlib.h>
74
-
75 90
 #include <lpc17xx_pinsel.h>
76 91
 #include "LPC1768_PWM.h"
77 92
 #include "arduino.h"
@@ -115,6 +130,7 @@ PWM_map ISR_table[NUM_PWMS] = PWM_MAP_INIT;
115 130
 #define P1_18_PWM_channel  1  // servo 3
116 131
 #define P1_20_PWM_channel  2  // servo 0
117 132
 #define P1_21_PWM_channel  3  // servo 1
133
+#define P1_23_PWM_channel  4  // servo 0 for MKS Sbase
118 134
 #define P2_04_PWM_channel  5  // D9
119 135
 #define P2_05_PWM_channel  6  // D10
120 136
 
@@ -137,7 +153,11 @@ void LPC1768_PWM_update_map_MR(void) {
137 153
   map_MR[0] = { 0, (uint8_t) (LPC_PWM1->PCR & _BV(8 + P1_18_PWM_channel) ? 1 : 0), P1_18, &LPC_PWM1->MR1, 0, 0, 0 };
138 154
   map_MR[1] = { 0, (uint8_t) (LPC_PWM1->PCR & _BV(8 + P1_20_PWM_channel) ? 1 : 0), P1_20, &LPC_PWM1->MR2, 0, 0, 0 };
139 155
   map_MR[2] = { 0, (uint8_t) (LPC_PWM1->PCR & _BV(8 + P1_21_PWM_channel) ? 1 : 0), P1_21, &LPC_PWM1->MR3, 0, 0, 0 };
140
-  map_MR[3] = { 0, 0, P_NC, &LPC_PWM1->MR4, 0, 0, 0 };
156
+  #if MOTHERBOARD == BOARD_MKS_SBASE
157
+    map_MR[3] = { 0, (uint8_t) (LPC_PWM1->PCR & _BV(8 + P1_23_PWM_channel) ? 1 : 0), P1_23, &LPC_PWM1->MR4, 0, 0, 0 };
158
+  #else
159
+    map_MR[3] = { 0, 0, P_NC, &LPC_PWM1->MR4, 0, 0, 0 };
160
+  #endif
141 161
   map_MR[4] = { 0, (uint8_t) (LPC_PWM1->PCR & _BV(8 + P2_04_PWM_channel) ? 1 : 0), P2_04, &LPC_PWM1->MR5, 0, 0, 0 };
142 162
   map_MR[5] = { 0, (uint8_t) (LPC_PWM1->PCR & _BV(8 + P2_05_PWM_channel) ? 1 : 0), P2_05, &LPC_PWM1->MR6, 0, 0, 0 };
143 163
 }
@@ -259,6 +279,13 @@ bool LPC1768_PWM_detach_pin(pin_t pin) {
259 279
 
260 280
   // OK to make these changes before the MR0 interrupt
261 281
   switch(pin) {
282
+    case P1_23:                        // MKS Sbase Servo 0, PWM1 channel 4  (J3-8 PWM1.4)
283
+      LPC_PWM1->PCR &= ~(_BV(8 + P1_23_PWM_channel));                 // disable PWM1 module control of this pin
284
+      map_MR[P1_23_PWM_channel - 1].PCR_bit = 0;
285
+      LPC_PINCON->PINSEL3 &= ~(0x3 <<  14);    // return pin to general purpose I/O
286
+      map_MR[P1_23_PWM_channel - 1].PINSEL_bits = 0;
287
+      map_MR[P1_23_PWM_channel - 1].map_PWM_INT = 0;               // 0 - available for interrupts, 1 - in use by PWM
288
+      break;
262 289
     case P1_20:                        // Servo 0, PWM1 channel 2  (Pin 11  P1.20 PWM1.2)
263 290
       LPC_PWM1->PCR &= ~(_BV(8 + P1_20_PWM_channel));                 // disable PWM1 module control of this pin
264 291
       map_MR[P1_20_PWM_channel - 1].PCR_bit = 0;
@@ -324,6 +351,11 @@ bool LPC1768_PWM_write(pin_t pin, uint32_t value) {
324 351
   LPC1768_PWM_update_map_MR();
325 352
 
326 353
   switch(pin) {
354
+    case P1_23:                        // MKS Sbase Servo 0, PWM1 channel 4  (J3-8 PWM1.4)
355
+      map_MR[P1_23_PWM_channel - 1].PCR_bit = _BV(8 + P1_23_PWM_channel);  // enable PWM1 module control of this pin
356
+      map_MR[P1_23_PWM_channel - 1].PINSEL_reg = &LPC_PINCON->PINSEL3;
357
+      map_MR[P1_23_PWM_channel - 1].PINSEL_bits = 0x2 <<  14;      // ISR must do this AFTER setting PCR
358
+      break;
327 359
     case P1_20:                        // Servo 0, PWM1 channel 2 (Pin 11  P1.20 PWM1.2)
328 360
       map_MR[P1_20_PWM_channel - 1].PCR_bit = _BV(8 + P1_20_PWM_channel);  // enable PWM1 module control of this pin
329 361
       map_MR[P1_20_PWM_channel - 1].PINSEL_reg = &LPC_PINCON->PINSEL3;

+ 9
- 0
Marlin/src/pins/pins_MKS_SBASE.h View File

@@ -40,6 +40,15 @@
40 40
 #define PIN_P0_28         P0_28
41 41
 */
42 42
 
43
+
44
+//
45
+// Servo pin
46
+//
47
+#define SERVO0_PIN         P1_23  // J8-3 (low jitter)
48
+#define SERVO1_PIN         P2_12  // J8-4
49
+#define SERVO2_PIN         P2_11  // J8-5
50
+#define SERVO3_PIN         P4_28  // J8-6
51
+
43 52
 //
44 53
 // Limit Switches
45 54
 //

Loading…
Cancel
Save