Browse Source

Fix name collision. timer_t => hal_timer_t

Scott Lahteine 7 years ago
parent
commit
2246316605

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

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

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

40
 
40
 
41
 #define FORCE_INLINE __attribute__((always_inline)) inline
41
 #define FORCE_INLINE __attribute__((always_inline)) inline
42
 
42
 
43
-typedef uint32_t timer_t;
43
+typedef uint32_t hal_timer_t;
44
 #define HAL_TIMER_TYPE_MAX 0xFFFFFFFF
44
 #define HAL_TIMER_TYPE_MAX 0xFFFFFFFF
45
 
45
 
46
 #define STEP_TIMER_NUM 3  // index of timer to use for stepper
46
 #define STEP_TIMER_NUM 3  // index of timer to use for stepper
92
   pConfig->pTimerRegs->TC_CHANNEL[pConfig->channel].TC_RC = count;
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
   const tTimerConfig *pConfig = &TimerConfig[timer_num];
96
   const tTimerConfig *pConfig = &TimerConfig[timer_num];
97
   return pConfig->pTimerRegs->TC_CHANNEL[pConfig->channel].TC_RC;
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
 
40
 
41
 #define FORCE_INLINE __attribute__((always_inline)) inline
41
 #define FORCE_INLINE __attribute__((always_inline)) inline
42
 
42
 
43
-typedef uint32_t timer_t;
43
+typedef uint32_t hal_timer_t;
44
 #define HAL_TIMER_TYPE_MAX 0xFFFFFFFF
44
 #define HAL_TIMER_TYPE_MAX 0xFFFFFFFF
45
 
45
 
46
 #define STEP_TIMER_NUM 0  // index of timer to use for stepper
46
 #define STEP_TIMER_NUM 0  // index of timer to use for stepper
77
 void HAL_timer_init(void);
77
 void HAL_timer_init(void);
78
 void HAL_timer_start(const uint8_t timer_num, const uint32_t frequency);
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
   switch (timer_num) {
81
   switch (timer_num) {
82
     case 0:
82
     case 0:
83
       LPC_TIM0->MR0 = count;
83
       LPC_TIM0->MR0 = count;
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
   switch (timer_num) {
96
   switch (timer_num) {
97
     case 0: return LPC_TIM0->MR0;
97
     case 0: return LPC_TIM0->MR0;
98
     case 1: return LPC_TIM1->MR0;
98
     case 1: return LPC_TIM1->MR0;
100
   return 0;
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
   switch (timer_num) {
104
   switch (timer_num) {
105
     case 0: return LPC_TIM0->TC;
105
     case 0: return LPC_TIM0->TC;
106
     case 1: return LPC_TIM1->TC;
106
     case 1: return LPC_TIM1->TC;

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

43
  */
43
  */
44
 #define FORCE_INLINE __attribute__((always_inline)) inline
44
 #define FORCE_INLINE __attribute__((always_inline)) inline
45
 
45
 
46
-typedef uint16_t timer_t;
46
+typedef uint16_t hal_timer_t;
47
 #define HAL_TIMER_TYPE_MAX 0xFFFF
47
 #define HAL_TIMER_TYPE_MAX 0xFFFF
48
 
48
 
49
 #define STEP_TIMER_NUM 5  // index of timer to use for stepper
49
 #define STEP_TIMER_NUM 5  // index of timer to use for stepper
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
   switch (timer_num) {
131
   switch (timer_num) {
132
   case STEP_TIMER_NUM:
132
   case STEP_TIMER_NUM:
133
     temp = StepperTimer.getCompare(STEP_TIMER_CHAN);
133
     temp = StepperTimer.getCompare(STEP_TIMER_CHAN);
142
   return temp;
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
   switch (timer_num) {
147
   switch (timer_num) {
148
   case STEP_TIMER_NUM:
148
   case STEP_TIMER_NUM:
149
     temp = StepperTimer.getCount();
149
     temp = StepperTimer.getCount();

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

40
 
40
 
41
 #define FORCE_INLINE __attribute__((always_inline)) inline
41
 #define FORCE_INLINE __attribute__((always_inline)) inline
42
 
42
 
43
-typedef uint32_t timer_t;
43
+typedef uint32_t hal_timer_t;
44
 #define HAL_TIMER_TYPE_MAX 0xFFFFFFFF
44
 #define HAL_TIMER_TYPE_MAX 0xFFFFFFFF
45
 
45
 
46
 #define STEP_TIMER_NUM 0
46
 #define STEP_TIMER_NUM 0
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
   switch(timer_num) {
86
   switch(timer_num) {
87
     case 0: return FTM0_C0V;
87
     case 0: return FTM0_C0V;
88
     case 1: return FTM1_C0V;
88
     case 1: return FTM1_C0V;

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

120
 
120
 
121
 #if ENABLED(LIN_ADVANCE)
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
          Stepper::nextAdvanceISR = ADV_NEVER,
126
          Stepper::nextAdvanceISR = ADV_NEVER,
127
          Stepper::eISR_Rate = ADV_NEVER;
127
          Stepper::eISR_Rate = ADV_NEVER;
128
 
128
 
137
    * This fix isn't perfect and may lose steps - but better than locking up completely
137
    * This fix isn't perfect and may lose steps - but better than locking up completely
138
    * in future the planner should slow down if advance stepping rate would be too high
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
     if (steps) {
141
     if (steps) {
142
-      const timer_t rate = (timer * loops) / abs(steps);
142
+      const hal_timer_t rate = (timer * loops) / abs(steps);
143
       //return constrain(rate, 1, ADV_NEVER - 1)
143
       //return constrain(rate, 1, ADV_NEVER - 1)
144
       return rate ? rate : 1;
144
       return rate ? rate : 1;
145
     }
145
     }
157
   long Stepper::counter_m[MIXING_STEPPERS];
157
   long Stepper::counter_m[MIXING_STEPPERS];
158
 #endif
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
 uint8_t Stepper::step_loops, Stepper::step_loops_nominal;
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
 volatile long Stepper::endstops_trigsteps[XYZ];
164
 volatile long Stepper::endstops_trigsteps[XYZ];
165
 
165
 
341
 
341
 
342
 void Stepper::isr() {
342
 void Stepper::isr() {
343
 
343
 
344
-  timer_t ocr_val;
344
+  hal_timer_t ocr_val;
345
 
345
 
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
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
   #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
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
     NOMORE(acc_step_rate, current_block->nominal_rate);
677
     NOMORE(acc_step_rate, current_block->nominal_rate);
678
 
678
 
679
     // step_rate to timer interval
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
     SPLIT(timer);  // split step into multiple ISRs if larger than  ENDSTOP_NOMINAL_OCR_VAL
682
     SPLIT(timer);  // split step into multiple ISRs if larger than  ENDSTOP_NOMINAL_OCR_VAL
683
     _NEXT_ISR(ocr_val);
683
     _NEXT_ISR(ocr_val);
699
     #endif // LIN_ADVANCE
699
     #endif // LIN_ADVANCE
700
   }
700
   }
701
   else if (step_events_completed > (uint32_t)current_block->decelerate_after) {
701
   else if (step_events_completed > (uint32_t)current_block->decelerate_after) {
702
-    timer_t step_rate;
702
+    hal_timer_t step_rate;
703
     #ifdef CPU_32_BIT
703
     #ifdef CPU_32_BIT
704
       MultiU32X24toH32(step_rate, deceleration_time, current_block->acceleration_rate);
704
       MultiU32X24toH32(step_rate, deceleration_time, current_block->acceleration_rate);
705
     #else
705
     #else
714
       step_rate = current_block->final_rate;
714
       step_rate = current_block->final_rate;
715
 
715
 
716
     // step_rate to timer interval
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
     SPLIT(timer);  // split step into multiple ISRs if larger than  ENDSTOP_NOMINAL_OCR_VAL
719
     SPLIT(timer);  // split step into multiple ISRs if larger than  ENDSTOP_NOMINAL_OCR_VAL
720
     _NEXT_ISR(ocr_val);
720
     _NEXT_ISR(ocr_val);
754
   #if DISABLED(LIN_ADVANCE)
754
   #if DISABLED(LIN_ADVANCE)
755
     #ifdef CPU_32_BIT
755
     #ifdef CPU_32_BIT
756
       // Make sure stepper interrupt does not monopolise CPU by adjusting count to give about 8 us room
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
                      stepper_timer_current_count = HAL_timer_get_current_count(STEP_TIMER_NUM) + 8 * HAL_TICKS_PER_US;
758
                      stepper_timer_current_count = HAL_timer_get_current_count(STEP_TIMER_NUM) + 8 * HAL_TICKS_PER_US;
759
       HAL_timer_set_count(STEP_TIMER_NUM, max(stepper_timer_count, stepper_timer_current_count));
759
       HAL_timer_set_count(STEP_TIMER_NUM, max(stepper_timer_count, stepper_timer_current_count));
760
     #else
760
     #else

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

97
     static volatile uint32_t step_events_completed; // The number of step events executed in the current block
97
     static volatile uint32_t step_events_completed; // The number of step events executed in the current block
98
 
98
 
99
     #if ENABLED(LIN_ADVANCE)
99
     #if ENABLED(LIN_ADVANCE)
100
-      static timer_t nextMainISR, nextAdvanceISR, eISR_Rate;
100
+      static hal_timer_t nextMainISR, nextAdvanceISR, eISR_Rate;
101
       #define _NEXT_ISR(T) nextMainISR = T
101
       #define _NEXT_ISR(T) nextMainISR = T
102
 
102
 
103
       static volatile int e_steps[E_STEPPERS];
103
       static volatile int e_steps[E_STEPPERS];
112
 
112
 
113
     static long acceleration_time, deceleration_time;
113
     static long acceleration_time, deceleration_time;
114
     //unsigned long accelerate_until, decelerate_after, acceleration_rate, initial_rate, final_rate, nominal_rate;
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
     static uint8_t step_loops, step_loops_nominal;
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
     static volatile long endstops_trigsteps[XYZ];
119
     static volatile long endstops_trigsteps[XYZ];
120
     static volatile long endstops_stepsTotal, endstops_stepsDone;
120
     static volatile long endstops_stepsTotal, endstops_stepsDone;
277
 
277
 
278
   private:
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
       NOMORE(step_rate, MAX_STEP_FREQUENCY);
283
       NOMORE(step_rate, MAX_STEP_FREQUENCY);
284
 
284
 

Loading…
Cancel
Save