🎨 Rename HAL timer elements
This commit is contained in:
@@ -110,7 +110,7 @@ HardwareTimer *timer_instance[NUM_HARDWARE_TIMERS] = { nullptr };
|
||||
uint32_t GetStepperTimerClkFreq() {
|
||||
// Timer input clocks vary between devices, and in some cases between timers on the same device.
|
||||
// Retrieve at runtime to ensure device compatibility. Cache result to avoid repeated overhead.
|
||||
static uint32_t clkfreq = timer_instance[STEP_TIMER_NUM]->getTimerClkFreq();
|
||||
static uint32_t clkfreq = timer_instance[MF_TIMER_STEP]->getTimerClkFreq();
|
||||
return clkfreq;
|
||||
}
|
||||
|
||||
@@ -118,7 +118,7 @@ uint32_t GetStepperTimerClkFreq() {
|
||||
void HAL_timer_start(const uint8_t timer_num, const uint32_t frequency) {
|
||||
if (!HAL_timer_initialized(timer_num)) {
|
||||
switch (timer_num) {
|
||||
case STEP_TIMER_NUM: // STEPPER TIMER - use a 32bit timer if possible
|
||||
case MF_TIMER_STEP: // STEPPER TIMER - use a 32bit timer if possible
|
||||
timer_instance[timer_num] = new HardwareTimer(STEP_TIMER_DEV);
|
||||
/* Set the prescaler to the final desired value.
|
||||
* This will change the effective ISR callback frequency but when
|
||||
@@ -137,7 +137,7 @@ void HAL_timer_start(const uint8_t timer_num, const uint32_t frequency) {
|
||||
timer_instance[timer_num]->setPrescaleFactor(STEPPER_TIMER_PRESCALE); //the -1 is done internally
|
||||
timer_instance[timer_num]->setOverflow(_MIN(hal_timer_t(HAL_TIMER_TYPE_MAX), (HAL_TIMER_RATE) / (STEPPER_TIMER_PRESCALE) /* /frequency */), TICK_FORMAT);
|
||||
break;
|
||||
case TEMP_TIMER_NUM: // TEMP TIMER - any available 16bit timer
|
||||
case MF_TIMER_TEMP: // TEMP TIMER - any available 16bit timer
|
||||
timer_instance[timer_num] = new HardwareTimer(TEMP_TIMER_DEV);
|
||||
// The prescale factor is computed automatically for HERTZ_FORMAT
|
||||
timer_instance[timer_num]->setOverflow(frequency, HERTZ_FORMAT);
|
||||
@@ -157,10 +157,10 @@ void HAL_timer_start(const uint8_t timer_num, const uint32_t frequency) {
|
||||
// These calls can be removed and replaced with
|
||||
// timer_instance[timer_num]->setInterruptPriority
|
||||
switch (timer_num) {
|
||||
case STEP_TIMER_NUM:
|
||||
case MF_TIMER_STEP:
|
||||
timer_instance[timer_num]->setInterruptPriority(STEP_TIMER_IRQ_PRIO, 0);
|
||||
break;
|
||||
case TEMP_TIMER_NUM:
|
||||
case MF_TIMER_TEMP:
|
||||
timer_instance[timer_num]->setInterruptPriority(TEMP_TIMER_IRQ_PRIO, 0);
|
||||
break;
|
||||
}
|
||||
@@ -170,10 +170,10 @@ void HAL_timer_start(const uint8_t timer_num, const uint32_t frequency) {
|
||||
void HAL_timer_enable_interrupt(const uint8_t timer_num) {
|
||||
if (HAL_timer_initialized(timer_num) && !timer_instance[timer_num]->hasInterrupt()) {
|
||||
switch (timer_num) {
|
||||
case STEP_TIMER_NUM:
|
||||
case MF_TIMER_STEP:
|
||||
timer_instance[timer_num]->attachInterrupt(Step_Handler);
|
||||
break;
|
||||
case TEMP_TIMER_NUM:
|
||||
case MF_TIMER_TEMP:
|
||||
timer_instance[timer_num]->attachInterrupt(Temp_Handler);
|
||||
break;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user