Browse Source

Merge pull request #8281 from thinkyhead/bf2_alligator_dac

[2.0] Use fastio for Alligator dac084s085, etc.
Scott Lahteine 7 years ago
parent
commit
94c7205d64
No account linked to committer's email address

+ 1
- 1
Marlin/src/HAL/HAL_AVR/HAL_AVR.h View File

@@ -66,7 +66,7 @@
66 66
 // Types
67 67
 // --------------------------------------------------------------------------
68 68
 
69
-typedef uint16_t timer_t;
69
+typedef uint16_t hal_timer_t;
70 70
 #define HAL_TIMER_TYPE_MAX 0xFFFF
71 71
 
72 72
 typedef int8_t pin_t;

+ 2
- 2
Marlin/src/HAL/HAL_DUE/HAL_timers_Due.h View File

@@ -40,7 +40,7 @@
40 40
 
41 41
 #define FORCE_INLINE __attribute__((always_inline)) inline
42 42
 
43
-typedef uint32_t timer_t;
43
+typedef uint32_t hal_timer_t;
44 44
 #define HAL_TIMER_TYPE_MAX 0xFFFFFFFF
45 45
 
46 46
 #define STEP_TIMER_NUM 3  // index of timer to use for stepper
@@ -92,7 +92,7 @@ static FORCE_INLINE void HAL_timer_set_count(const uint8_t timer_num, const uint
92 92
   pConfig->pTimerRegs->TC_CHANNEL[pConfig->channel].TC_RC = count;
93 93
 }
94 94
 
95
-static FORCE_INLINE timer_t HAL_timer_get_count(const uint8_t timer_num) {
95
+static FORCE_INLINE hal_timer_t HAL_timer_get_count(const uint8_t timer_num) {
96 96
   const tTimerConfig *pConfig = &TimerConfig[timer_num];
97 97
   return pConfig->pTimerRegs->TC_CHANNEL[pConfig->channel].TC_RC;
98 98
 }

+ 4
- 4
Marlin/src/HAL/HAL_LPC1768/HAL_timers.h View File

@@ -40,7 +40,7 @@
40 40
 
41 41
 #define FORCE_INLINE __attribute__((always_inline)) inline
42 42
 
43
-typedef uint32_t timer_t;
43
+typedef uint32_t hal_timer_t;
44 44
 #define HAL_TIMER_TYPE_MAX 0xFFFFFFFF
45 45
 
46 46
 #define STEP_TIMER_NUM 0  // index of timer to use for stepper
@@ -77,7 +77,7 @@ typedef uint32_t timer_t;
77 77
 void HAL_timer_init(void);
78 78
 void HAL_timer_start(const uint8_t timer_num, const uint32_t frequency);
79 79
 
80
-static FORCE_INLINE void HAL_timer_set_count(const uint8_t timer_num, const timer_t count) {
80
+static FORCE_INLINE void HAL_timer_set_count(const uint8_t timer_num, const hal_timer_t count) {
81 81
   switch (timer_num) {
82 82
     case 0:
83 83
       LPC_TIM0->MR0 = count;
@@ -92,7 +92,7 @@ static FORCE_INLINE void HAL_timer_set_count(const uint8_t timer_num, const time
92 92
   }
93 93
 }
94 94
 
95
-static FORCE_INLINE timer_t HAL_timer_get_count(const uint8_t timer_num) {
95
+static FORCE_INLINE hal_timer_t HAL_timer_get_count(const uint8_t timer_num) {
96 96
   switch (timer_num) {
97 97
     case 0: return LPC_TIM0->MR0;
98 98
     case 1: return LPC_TIM1->MR0;
@@ -100,7 +100,7 @@ static FORCE_INLINE timer_t HAL_timer_get_count(const uint8_t timer_num) {
100 100
   return 0;
101 101
 }
102 102
 
103
-static FORCE_INLINE timer_t HAL_timer_get_current_count(const uint8_t timer_num) {
103
+static FORCE_INLINE hal_timer_t HAL_timer_get_current_count(const uint8_t timer_num) {
104 104
   switch (timer_num) {
105 105
     case 0: return LPC_TIM0->TC;
106 106
     case 1: return LPC_TIM1->TC;

+ 5
- 5
Marlin/src/HAL/HAL_STM32F1/HAL_timers_Stm32f1.h View File

@@ -43,7 +43,7 @@
43 43
  */
44 44
 #define FORCE_INLINE __attribute__((always_inline)) inline
45 45
 
46
-typedef uint16_t timer_t;
46
+typedef uint16_t hal_timer_t;
47 47
 #define HAL_TIMER_TYPE_MAX 0xFFFF
48 48
 
49 49
 #define STEP_TIMER_NUM 5  // index of timer to use for stepper
@@ -126,8 +126,8 @@ static FORCE_INLINE void HAL_timer_set_count (uint8_t timer_num, uint32_t count)
126 126
   }
127 127
 }
128 128
 
129
-static FORCE_INLINE timer_t HAL_timer_get_count (uint8_t timer_num) {
130
-  timer_t temp;
129
+static FORCE_INLINE hal_timer_t HAL_timer_get_count (uint8_t timer_num) {
130
+  hal_timer_t temp;
131 131
   switch (timer_num) {
132 132
   case STEP_TIMER_NUM:
133 133
     temp = StepperTimer.getCompare(STEP_TIMER_CHAN);
@@ -142,8 +142,8 @@ static FORCE_INLINE timer_t HAL_timer_get_count (uint8_t timer_num) {
142 142
   return temp;
143 143
 }
144 144
 
145
-static FORCE_INLINE timer_t HAL_timer_get_current_count(uint8_t timer_num) {
146
-  timer_t temp;
145
+static FORCE_INLINE hal_timer_t HAL_timer_get_current_count(uint8_t timer_num) {
146
+  hal_timer_t temp;
147 147
   switch (timer_num) {
148 148
   case STEP_TIMER_NUM:
149 149
     temp = StepperTimer.getCount();

+ 9
- 9
Marlin/src/HAL/HAL_STM32F1/endstop_interrupts.h View File

@@ -51,39 +51,39 @@
51 51
 
52 52
 void setup_endstop_interrupts(void) {
53 53
   #if HAS_X_MAX
54
-    pinMode(X_MAX_PIN, INPUT);
54
+    SET_INPUT(X_MAX_PIN);
55 55
     attachInterrupt(X_MAX_PIN, endstop_ISR, CHANGE); // assign it
56 56
   #endif
57 57
   #if HAS_X_MIN
58
-    pinMode(X_MIN_PIN, INPUT);
58
+    SET_INPUT(X_MIN_PIN);
59 59
     attachInterrupt(X_MIN_PIN, endstop_ISR, CHANGE);
60 60
   #endif
61 61
   #if HAS_Y_MAX
62
-    pinMode(Y_MAX_PIN, INPUT);
62
+    SET_INPUT(Y_MAX_PIN);
63 63
     attachInterrupt(Y_MAX_PIN, endstop_ISR, CHANGE);
64 64
   #endif
65 65
   #if HAS_Y_MIN
66
-    pinMode(Y_MIN_PIN, INPUT);
66
+    SET_INPUT(Y_MIN_PIN);
67 67
     attachInterrupt(Y_MIN_PIN, endstop_ISR, CHANGE);
68 68
   #endif
69 69
   #if HAS_Z_MAX
70
-    pinMode(Z_MAX_PIN, INPUT);
70
+    SET_INPUT(Z_MAX_PIN);
71 71
     attachInterrupt(Z_MAX_PIN, endstop_ISR, CHANGE);
72 72
   #endif
73 73
   #if HAS_Z_MIN
74
-    pinMode(Z_MIN_PIN, INPUT);
74
+    SET_INPUT(Z_MIN_PIN);
75 75
     attachInterrupt(Z_MIN_PIN, endstop_ISR, CHANGE);
76 76
   #endif
77 77
   #if HAS_Z2_MAX
78
-    pinMode(Z2_MAX_PIN, INPUT);
78
+    SET_INPUT(Z2_MAX_PIN);
79 79
     attachInterrupt(Z2_MAX_PIN, endstop_ISR, CHANGE);
80 80
   #endif
81 81
   #if HAS_Z2_MIN
82
-    pinMode(Z2_MIN_PIN, INPUT);
82
+    SET_INPUT(Z2_MIN_PIN);
83 83
     attachInterrupt(Z2_MIN_PIN, endstop_ISR, CHANGE);
84 84
   #endif
85 85
   #if HAS_Z_MIN_PROBE_PIN
86
-    pinMode(Z_MIN_PROBE_PIN, INPUT);
86
+    SET_INPUT(Z_MIN_PROBE_PIN);
87 87
     attachInterrupt(Z_MIN_PROBE_PIN, endstop_ISR, CHANGE);
88 88
   #endif
89 89
 }

+ 2
- 2
Marlin/src/HAL/HAL_TEENSY35_36/HAL_timers_Teensy.h View File

@@ -40,7 +40,7 @@
40 40
 
41 41
 #define FORCE_INLINE __attribute__((always_inline)) inline
42 42
 
43
-typedef uint32_t timer_t;
43
+typedef uint32_t hal_timer_t;
44 44
 #define HAL_TIMER_TYPE_MAX 0xFFFFFFFF
45 45
 
46 46
 #define STEP_TIMER_NUM 0
@@ -82,7 +82,7 @@ static FORCE_INLINE void HAL_timer_set_count(const uint8_t timer_num, const uint
82 82
   }
83 83
 }
84 84
 
85
-static FORCE_INLINE timer_t HAL_timer_get_count(const uint8_t timer_num) {
85
+static FORCE_INLINE hal_timer_t HAL_timer_get_count(const uint8_t timer_num) {
86 86
   switch(timer_num) {
87 87
     case 0: return FTM0_C0V;
88 88
     case 1: return FTM1_C0V;

+ 14
- 14
Marlin/src/HAL/SpiEeprom.cpp View File

@@ -44,12 +44,12 @@ uint8_t eeprom_read_byte(uint8_t* pos) {
44 44
   eeprom_temp[0] = CMD_READ;
45 45
   eeprom_temp[1] = ((unsigned)pos>>8) & 0xFF; // addr High
46 46
   eeprom_temp[2] = (unsigned)pos& 0xFF;       // addr Low
47
-  digitalWrite(SPI_EEPROM1_CS, HIGH);
48
-  digitalWrite(SPI_EEPROM1_CS, LOW);
47
+  WRITE(SPI_EEPROM1_CS, HIGH);
48
+  WRITE(SPI_EEPROM1_CS, LOW);
49 49
   spiSend(SPI_CHAN_EEPROM1, eeprom_temp, 3);
50 50
 
51 51
   v = spiRec(SPI_CHAN_EEPROM1);
52
-  digitalWrite(SPI_EEPROM1_CS, HIGH);
52
+  WRITE(SPI_EEPROM1_CS, HIGH);
53 53
   return v;
54 54
 }
55 55
 
@@ -62,14 +62,14 @@ void eeprom_read_block(void* dest, const void* eeprom_address, size_t n) {
62 62
   eeprom_temp[0] = CMD_READ;
63 63
   eeprom_temp[1] = ((unsigned)eeprom_address>>8) & 0xFF; // addr High
64 64
   eeprom_temp[2] = (unsigned)eeprom_address& 0xFF;       // addr Low
65
-  digitalWrite(SPI_EEPROM1_CS, HIGH);
66
-  digitalWrite(SPI_EEPROM1_CS, LOW);
65
+  WRITE(SPI_EEPROM1_CS, HIGH);
66
+  WRITE(SPI_EEPROM1_CS, LOW);
67 67
   spiSend(SPI_CHAN_EEPROM1, eeprom_temp, 3);
68 68
 
69 69
   uint8_t *p_dest = (uint8_t *)dest;
70 70
   while (n--)
71 71
     *p_dest++ = spiRec(SPI_CHAN_EEPROM1);
72
-  digitalWrite(SPI_EEPROM1_CS, HIGH);
72
+  WRITE(SPI_EEPROM1_CS, HIGH);
73 73
 }
74 74
 
75 75
 void eeprom_write_byte(uint8_t* pos, uint8_t value) {
@@ -77,20 +77,20 @@ void eeprom_write_byte(uint8_t* pos, uint8_t value) {
77 77
 
78 78
   /*write enable*/
79 79
   eeprom_temp[0] = CMD_WREN;
80
-  digitalWrite(SPI_EEPROM1_CS, LOW);
80
+  WRITE(SPI_EEPROM1_CS, LOW);
81 81
   spiSend(SPI_CHAN_EEPROM1, eeprom_temp, 1);
82
-  digitalWrite(SPI_EEPROM1_CS, HIGH);
82
+  WRITE(SPI_EEPROM1_CS, HIGH);
83 83
   delay(1);
84 84
 
85 85
   /*write addr*/
86 86
   eeprom_temp[0] = CMD_WRITE;
87 87
   eeprom_temp[1] = ((unsigned)pos>>8) & 0xFF;  //addr High
88 88
   eeprom_temp[2] = (unsigned)pos & 0xFF;       //addr Low
89
-  digitalWrite(SPI_EEPROM1_CS, LOW);
89
+  WRITE(SPI_EEPROM1_CS, LOW);
90 90
   spiSend(SPI_CHAN_EEPROM1, eeprom_temp, 3);
91 91
 
92 92
   spiSend(SPI_CHAN_EEPROM1, value);
93
-  digitalWrite(SPI_EEPROM1_CS, HIGH);
93
+  WRITE(SPI_EEPROM1_CS, HIGH);
94 94
   delay(7);   // wait for page write to complete
95 95
 }
96 96
 
@@ -99,20 +99,20 @@ void eeprom_update_block(const void* src, void* eeprom_address, size_t n) {
99 99
 
100 100
   /*write enable*/
101 101
   eeprom_temp[0] = CMD_WREN;
102
-  digitalWrite(SPI_EEPROM1_CS, LOW);
102
+  WRITE(SPI_EEPROM1_CS, LOW);
103 103
   spiSend(SPI_CHAN_EEPROM1, eeprom_temp, 1);
104
-  digitalWrite(SPI_EEPROM1_CS, HIGH);
104
+  WRITE(SPI_EEPROM1_CS, HIGH);
105 105
   delay(1);
106 106
 
107 107
   /*write addr*/
108 108
   eeprom_temp[0] = CMD_WRITE;
109 109
   eeprom_temp[1] = ((unsigned)eeprom_address>>8) & 0xFF;  //addr High
110 110
   eeprom_temp[2] = (unsigned)eeprom_address & 0xFF;       //addr Low
111
-  digitalWrite(SPI_EEPROM1_CS, LOW);
111
+  WRITE(SPI_EEPROM1_CS, LOW);
112 112
   spiSend(SPI_CHAN_EEPROM1, eeprom_temp, 3);
113 113
 
114 114
   spiSend(SPI_CHAN_EEPROM1, (const uint8_t*)src, n);
115
-  digitalWrite(SPI_EEPROM1_CS, HIGH);
115
+  WRITE(SPI_EEPROM1_CS, HIGH);
116 116
   delay(7);   // wait for page write to complete
117 117
 }
118 118
 

+ 41
- 56
Marlin/src/feature/dac/dac_dac084s085.cpp View File

@@ -13,100 +13,85 @@
13 13
 #include "../../Marlin.h"
14 14
 #include "../../module/stepper.h"
15 15
 
16
-dac084s085::dac084s085() {
17
-  return ;
18
-}
16
+dac084s085::dac084s085() { }
19 17
 
20 18
 void dac084s085::begin() {
21
-  uint8_t externalDac_buf[2] = {0x20,0x00};//all off
19
+  uint8_t externalDac_buf[] = { 0x20, 0x00 }; // all off
22 20
 
23 21
   // All SPI chip-select HIGH
24
-  pinMode(DAC0_SYNC, OUTPUT);
25
-  digitalWrite( DAC0_SYNC , HIGH );
22
+  SET_OUTPUT(DAC0_SYNC);
26 23
   #if EXTRUDERS > 1
27
-    pinMode(DAC1_SYNC, OUTPUT);
28
-    digitalWrite( DAC1_SYNC , HIGH );
24
+    SET_OUTPUT(DAC1_SYNC);
29 25
   #endif
30
-  digitalWrite( SPI_EEPROM1_CS , HIGH );
31
-  digitalWrite( SPI_EEPROM2_CS , HIGH );
32
-  digitalWrite( SPI_FLASH_CS , HIGH );
33
-  digitalWrite( SS_PIN , HIGH );
26
+  cshigh();
34 27
   spiBegin();
35 28
 
36 29
   //init onboard DAC
37 30
   delayMicroseconds(2U);
38
-  digitalWrite( DAC0_SYNC , LOW );
31
+  WRITE(DAC0_SYNC, LOW);
39 32
   delayMicroseconds(2U);
40
-  digitalWrite( DAC0_SYNC , HIGH );
33
+  WRITE(DAC0_SYNC, HIGH);
41 34
   delayMicroseconds(2U);
42
-  digitalWrite( DAC0_SYNC , LOW );
35
+  WRITE(DAC0_SYNC, LOW);
43 36
 
44
-  spiSend(SPI_CHAN_DAC,externalDac_buf , 2);
45
-  digitalWrite( DAC0_SYNC , HIGH );
37
+  spiSend(SPI_CHAN_DAC, externalDac_buf, COUNT(externalDac_buf));
38
+  WRITE(DAC0_SYNC, HIGH);
46 39
 
47 40
   #if EXTRUDERS > 1
48 41
     //init Piggy DAC
49 42
     delayMicroseconds(2U);
50
-    digitalWrite( DAC1_SYNC , LOW );
43
+    WRITE(DAC1_SYNC, LOW);
51 44
     delayMicroseconds(2U);
52
-    digitalWrite( DAC1_SYNC , HIGH );
45
+    WRITE(DAC1_SYNC, HIGH);
53 46
     delayMicroseconds(2U);
54
-    digitalWrite( DAC1_SYNC , LOW );
47
+    WRITE(DAC1_SYNC, LOW);
55 48
 
56
-    spiSend(SPI_CHAN_DAC,externalDac_buf , 2);
57
-    digitalWrite( DAC1_SYNC , HIGH );
49
+    spiSend(SPI_CHAN_DAC, externalDac_buf, COUNT(externalDac_buf));
50
+    WRITE(DAC1_SYNC, HIGH);
58 51
   #endif
59 52
 
60 53
   return;
61 54
 }
62 55
 
63
-void dac084s085::setValue(uint8_t channel, uint8_t value) {
64
-  if(channel >= 7) // max channel (X,Y,Z,E0,E1,E2,E3)
65
-    return;
66
-  if(value > 255) value = 255;
67
-
68
-  uint8_t externalDac_buf[2] = {0x10,0x00};
69
-
70
-  if(channel > 3)
71
-    externalDac_buf[0] |= (7 - channel << 6);
72
-  else
73
-    externalDac_buf[0] |= (3 - channel << 6);
56
+void dac084s085::setValue(const uint8_t channel, const uint8_t value) {
57
+  if (channel >= 7) return; // max channel (X,Y,Z,E0,E1,E2,E3)
74 58
 
75
-  externalDac_buf[0] |= (value >> 4);
76
-  externalDac_buf[1] |= (value << 4);
59
+  const uint8_t externalDac_buf[] = {
60
+    0x10 | ((channel > 3 ? 7 : 3) - channel << 6) | (value >> 4),
61
+    0x00 | (value << 4)
62
+  };
77 63
 
78 64
   // All SPI chip-select HIGH
79
-  digitalWrite( DAC0_SYNC , HIGH );
80
-  #if EXTRUDERS > 1
81
-    digitalWrite( DAC1_SYNC , HIGH );
82
-  #endif
83
-  digitalWrite( SPI_EEPROM1_CS , HIGH );
84
-  digitalWrite( SPI_EEPROM2_CS , HIGH );
85
-  digitalWrite( SPI_FLASH_CS , HIGH );
86
-  digitalWrite( SS_PIN , HIGH );
87
-
88
-  if(channel > 3) { // DAC Piggy E1,E2,E3
65
+  cshigh();
89 66
 
90
-    digitalWrite(DAC1_SYNC , LOW);
67
+  if (channel > 3) {        // DAC Piggy E1,E2,E3
68
+    WRITE(DAC1_SYNC, LOW);
91 69
     delayMicroseconds(2U);
92
-    digitalWrite(DAC1_SYNC , HIGH);
70
+    WRITE(DAC1_SYNC, HIGH);
93 71
     delayMicroseconds(2U);
94
-    digitalWrite(DAC1_SYNC , LOW);
72
+    WRITE(DAC1_SYNC, LOW);
95 73
   }
96
-
97
-  else { // DAC onboard X,Y,Z,E0
98
-
99
-    digitalWrite(DAC0_SYNC , LOW);
74
+  else {                    // DAC onboard X,Y,Z,E0
75
+    WRITE(DAC0_SYNC, LOW);
100 76
     delayMicroseconds(2U);
101
-    digitalWrite(DAC0_SYNC , HIGH);
77
+    WRITE(DAC0_SYNC, HIGH);
102 78
     delayMicroseconds(2U);
103
-    digitalWrite(DAC0_SYNC , LOW);
79
+    WRITE(DAC0_SYNC, LOW);
104 80
   }
105 81
 
106 82
   delayMicroseconds(2U);
107
-  spiSend(SPI_CHAN_DAC,externalDac_buf , 2);
83
+  spiSend(SPI_CHAN_DAC, externalDac_buf, COUNT(externalDac_buf));
84
+}
108 85
 
109
-  return;
86
+void dac084s085::cshigh() {
87
+  WRITE(DAC0_SYNC, HIGH);
88
+  #if EXTRUDERS > 1
89
+    WRITE(DAC1_SYNC, HIGH);
90
+  #endif
91
+  WRITE(SPI_EEPROM1_CS, HIGH);
92
+  WRITE(SPI_EEPROM2_CS, HIGH);
93
+  WRITE(SPI_FLASH_CS, HIGH);
94
+  WRITE(SS_PIN, HIGH);
110 95
 }
111 96
 
112 97
 #endif // MB(ALLIGATOR)

+ 3
- 1
Marlin/src/feature/dac/dac_dac084s085.h View File

@@ -5,7 +5,9 @@ class dac084s085 {
5 5
   public:
6 6
     dac084s085();
7 7
     static void begin(void);
8
-    static void setValue(uint8_t channel, uint8_t value);
8
+    static void setValue(const uint8_t channel, const uint8_t value);
9
+  private:
10
+    static void cshigh();
9 11
 };
10 12
 
11 13
 #endif // DAC084S085_H

+ 11
- 11
Marlin/src/module/stepper.cpp View File

@@ -120,9 +120,9 @@ volatile uint32_t Stepper::step_events_completed = 0; // The number of step even
120 120
 
121 121
 #if ENABLED(LIN_ADVANCE)
122 122
 
123
-  constexpr timer_t ADV_NEVER = HAL_TIMER_TYPE_MAX;
123
+  constexpr hal_timer_t ADV_NEVER = HAL_TIMER_TYPE_MAX;
124 124
 
125
-  timer_t Stepper::nextMainISR = 0,
125
+  hal_timer_t Stepper::nextMainISR = 0,
126 126
          Stepper::nextAdvanceISR = ADV_NEVER,
127 127
          Stepper::eISR_Rate = ADV_NEVER;
128 128
 
@@ -137,9 +137,9 @@ volatile uint32_t Stepper::step_events_completed = 0; // The number of step even
137 137
    * This fix isn't perfect and may lose steps - but better than locking up completely
138 138
    * in future the planner should slow down if advance stepping rate would be too high
139 139
    */
140
-  FORCE_INLINE timer_t adv_rate(const int steps, const timer_t timer, const uint8_t loops) {
140
+  FORCE_INLINE hal_timer_t adv_rate(const int steps, const hal_timer_t timer, const uint8_t loops) {
141 141
     if (steps) {
142
-      const timer_t rate = (timer * loops) / abs(steps);
142
+      const hal_timer_t rate = (timer * loops) / abs(steps);
143 143
       //return constrain(rate, 1, ADV_NEVER - 1)
144 144
       return rate ? rate : 1;
145 145
     }
@@ -157,9 +157,9 @@ volatile signed char Stepper::count_direction[NUM_AXIS] = { 1, 1, 1, 1 };
157 157
   long Stepper::counter_m[MIXING_STEPPERS];
158 158
 #endif
159 159
 
160
-timer_t Stepper::acc_step_rate; // needed for deceleration start point
160
+hal_timer_t Stepper::acc_step_rate; // needed for deceleration start point
161 161
 uint8_t Stepper::step_loops, Stepper::step_loops_nominal;
162
-timer_t Stepper::OCR1A_nominal;
162
+hal_timer_t Stepper::OCR1A_nominal;
163 163
 
164 164
 volatile long Stepper::endstops_trigsteps[XYZ];
165 165
 
@@ -341,7 +341,7 @@ HAL_STEP_TIMER_ISR {
341 341
 
342 342
 void Stepper::isr() {
343 343
 
344
-  timer_t ocr_val;
344
+  hal_timer_t ocr_val;
345 345
 
346 346
   #define ENDSTOP_NOMINAL_OCR_VAL 1500 * HAL_TICKS_PER_US    // check endstops every 1.5ms to guarantee two stepper ISRs within 5ms for BLTouch
347 347
   #define OCR_VAL_TOLERANCE 500 * HAL_TICKS_PER_US           // First max delay is 2.0ms, last min delay is 0.5ms, all others 1.5ms
@@ -677,7 +677,7 @@ void Stepper::isr() {
677 677
     NOMORE(acc_step_rate, current_block->nominal_rate);
678 678
 
679 679
     // step_rate to timer interval
680
-    const timer_t timer = calc_timer(acc_step_rate);
680
+    const hal_timer_t timer = calc_timer(acc_step_rate);
681 681
 
682 682
     SPLIT(timer);  // split step into multiple ISRs if larger than  ENDSTOP_NOMINAL_OCR_VAL
683 683
     _NEXT_ISR(ocr_val);
@@ -699,7 +699,7 @@ void Stepper::isr() {
699 699
     #endif // LIN_ADVANCE
700 700
   }
701 701
   else if (step_events_completed > (uint32_t)current_block->decelerate_after) {
702
-    timer_t step_rate;
702
+    hal_timer_t step_rate;
703 703
     #ifdef CPU_32_BIT
704 704
       MultiU32X24toH32(step_rate, deceleration_time, current_block->acceleration_rate);
705 705
     #else
@@ -714,7 +714,7 @@ void Stepper::isr() {
714 714
       step_rate = current_block->final_rate;
715 715
 
716 716
     // step_rate to timer interval
717
-    const timer_t timer = calc_timer(step_rate);
717
+    const hal_timer_t timer = calc_timer(step_rate);
718 718
 
719 719
     SPLIT(timer);  // split step into multiple ISRs if larger than  ENDSTOP_NOMINAL_OCR_VAL
720 720
     _NEXT_ISR(ocr_val);
@@ -754,7 +754,7 @@ void Stepper::isr() {
754 754
   #if DISABLED(LIN_ADVANCE)
755 755
     #ifdef CPU_32_BIT
756 756
       // Make sure stepper interrupt does not monopolise CPU by adjusting count to give about 8 us room
757
-      timer_t stepper_timer_count = HAL_timer_get_count(STEP_TIMER_NUM),
757
+      hal_timer_t stepper_timer_count = HAL_timer_get_count(STEP_TIMER_NUM),
758 758
                      stepper_timer_current_count = HAL_timer_get_current_count(STEP_TIMER_NUM) + 8 * HAL_TICKS_PER_US;
759 759
       HAL_timer_set_count(STEP_TIMER_NUM, max(stepper_timer_count, stepper_timer_current_count));
760 760
     #else

+ 5
- 5
Marlin/src/module/stepper.h View File

@@ -97,7 +97,7 @@ class Stepper {
97 97
     static volatile uint32_t step_events_completed; // The number of step events executed in the current block
98 98
 
99 99
     #if ENABLED(LIN_ADVANCE)
100
-      static timer_t nextMainISR, nextAdvanceISR, eISR_Rate;
100
+      static hal_timer_t nextMainISR, nextAdvanceISR, eISR_Rate;
101 101
       #define _NEXT_ISR(T) nextMainISR = T
102 102
 
103 103
       static volatile int e_steps[E_STEPPERS];
@@ -112,9 +112,9 @@ class Stepper {
112 112
 
113 113
     static long acceleration_time, deceleration_time;
114 114
     //unsigned long accelerate_until, decelerate_after, acceleration_rate, initial_rate, final_rate, nominal_rate;
115
-    static timer_t acc_step_rate; // needed for deceleration start point
115
+    static hal_timer_t acc_step_rate; // needed for deceleration start point
116 116
     static uint8_t step_loops, step_loops_nominal;
117
-    static timer_t OCR1A_nominal;
117
+    static hal_timer_t OCR1A_nominal;
118 118
 
119 119
     static volatile long endstops_trigsteps[XYZ];
120 120
     static volatile long endstops_stepsTotal, endstops_stepsDone;
@@ -277,8 +277,8 @@ class Stepper {
277 277
 
278 278
   private:
279 279
 
280
-    static FORCE_INLINE timer_t calc_timer(timer_t step_rate) {
281
-      timer_t timer;
280
+    static FORCE_INLINE hal_timer_t calc_timer(hal_timer_t step_rate) {
281
+      hal_timer_t timer;
282 282
 
283 283
       NOMORE(step_rate, MAX_STEP_FREQUENCY);
284 284
 

Loading…
Cancel
Save