|
@@ -100,17 +100,23 @@ extern "C" {
|
100
|
100
|
|
101
|
101
|
|
102
|
102
|
// timers
|
103
|
|
-#define STEP_TIMER_NUM OCR1A
|
104
|
|
-#define TEMP_TIMER_NUM 0
|
105
|
|
-#define TEMP_TIMER_FREQUENCY (F_CPU / 64.0 / 256.0)
|
106
|
|
-
|
107
|
103
|
#define HAL_TIMER_RATE ((F_CPU) / 8) // i.e., 2MHz or 2.5MHz
|
|
104
|
+#define HAL_TICKS_PER_US ((HAL_STEPPER_TIMER_RATE) / 1000000) // Cannot be of type double
|
|
105
|
+
|
|
106
|
+#define TEMP_TIMER_FREQUENCY ((F_CPU) / 64.0 / 256.0)
|
|
107
|
+
|
108
|
108
|
#define HAL_STEPPER_TIMER_RATE HAL_TIMER_RATE
|
109
|
109
|
#define STEPPER_TIMER_PRESCALE 8
|
110
|
|
-#define HAL_TICKS_PER_US ((HAL_STEPPER_TIMER_RATE) / 1000000) // Cannot be of type double
|
111
|
110
|
|
112
|
|
-#define PULSE_TIMER_NUM TEMP_TIMER_NUM
|
|
111
|
+#define STEP_TIMER_NUM 1
|
|
112
|
+#define TIMER_OCR_1 OCR1A
|
|
113
|
+#define TIMER_COUNTER_1 TCNT1
|
|
114
|
+
|
|
115
|
+#define TEMP_TIMER_NUM 0
|
|
116
|
+#define TIMER_OCR_0 OCR0A
|
113
|
117
|
#define TIMER_COUNTER_0 TCNT0
|
|
118
|
+
|
|
119
|
+#define PULSE_TIMER_NUM TEMP_TIMER_NUM
|
114
|
120
|
#define PULSE_TIMER_PRESCALE 8
|
115
|
121
|
|
116
|
122
|
#define ENABLE_STEPPER_DRIVER_INTERRUPT() SBI(TIMSK1, OCIE1A)
|
|
@@ -119,17 +125,14 @@ extern "C" {
|
119
|
125
|
#define ENABLE_TEMPERATURE_INTERRUPT() SBI(TIMSK0, OCIE0B)
|
120
|
126
|
#define DISABLE_TEMPERATURE_INTERRUPT() CBI(TIMSK0, OCIE0B)
|
121
|
127
|
|
122
|
|
-//void HAL_timer_start(const uint8_t timer_num, const uint32_t frequency);
|
123
|
|
-#define HAL_timer_start(timer_num,frequency)
|
124
|
|
-
|
125
|
|
-#define HAL_timer_get_count(timer) timer
|
126
|
|
-
|
127
|
|
-//void HAL_timer_set_count(const uint8_t timer_num, const uint16_t count);
|
128
|
|
-#define HAL_timer_set_count(timer, count) timer = (count)
|
|
128
|
+#define HAL_timer_start(timer_num, frequency)
|
129
|
129
|
|
130
|
|
-#define HAL_timer_get_current_count(timer) timer
|
|
130
|
+#define _CAT(a, ...) a ## __VA_ARGS__
|
|
131
|
+#define HAL_timer_set_count(timer, count) (_CAT(TIMER_OCR_, timer) = count)
|
|
132
|
+#define HAL_timer_get_count(timer) _CAT(TIMER_OCR_, timer)
|
|
133
|
+#define HAL_timer_set_current_count(timer, count) (_CAT(TIMER_COUNTER_, timer) = count)
|
|
134
|
+#define HAL_timer_get_current_count(timer) _CAT(TIMER_COUNTER_, timer)
|
131
|
135
|
|
132
|
|
-//void HAL_timer_isr_prologue(const uint8_t timer_num);
|
133
|
136
|
#define HAL_timer_isr_prologue(timer_num)
|
134
|
137
|
|
135
|
138
|
#define HAL_STEP_TIMER_ISR ISR(TIMER1_COMPA_vect)
|