HAL function to ensure min stepper interrupt interval (#9985)
This commit is contained in:
committed by
Scott Lahteine
parent
be0e100fed
commit
a1a88ebabc
@ -137,6 +137,11 @@ uint32_t HAL_timer_get_count(const uint8_t timer_num) {
|
||||
return __HAL_TIM_GetCounter(&timerConfig[timer_num].timerdef);
|
||||
}
|
||||
|
||||
void HAL_timer_restrain(const uint8_t timer_num, const uint16_t interval_µs) {
|
||||
const hal_timer_t mincmp = HAL_timer_get_count(timer_num) + interval_µs * HAL_TICKS_PER_US;
|
||||
if (HAL_timer_get_compare(timer_num) < mincmp) HAL_timer_set_compare(timer_num, mincmp);
|
||||
}
|
||||
|
||||
void HAL_timer_isr_prologue(const uint8_t timer_num) {
|
||||
if (__HAL_TIM_GET_FLAG(&timerConfig[timer_num].timerdef, TIM_FLAG_UPDATE) == SET) {
|
||||
__HAL_TIM_CLEAR_FLAG(&timerConfig[timer_num].timerdef, TIM_FLAG_UPDATE);
|
||||
|
@ -44,7 +44,7 @@
|
||||
#define HAL_TIMER_RATE (HAL_RCC_GetSysClockFreq() / 2) // frequency of timer peripherals
|
||||
#define STEPPER_TIMER_PRESCALE 54 // was 40,prescaler for setting stepper timer, 2Mhz
|
||||
#define HAL_STEPPER_TIMER_RATE (HAL_TIMER_RATE / STEPPER_TIMER_PRESCALE) // frequency of stepper timer (HAL_TIMER_RATE / STEPPER_TIMER_PRESCALE)
|
||||
#define HAL_TICKS_PER_US ((HAL_STEPPER_TIMER_RATE) / 1000000) // stepper timer ticks per us
|
||||
#define HAL_TICKS_PER_US ((HAL_STEPPER_TIMER_RATE) / 1000000) // stepper timer ticks per µs
|
||||
|
||||
#define PULSE_TIMER_NUM STEP_TIMER_NUM
|
||||
#define PULSE_TIMER_PRESCALE STEPPER_TIMER_PRESCALE
|
||||
@ -52,6 +52,8 @@
|
||||
#define TEMP_TIMER_PRESCALE 1000 // prescaler for setting Temp timer, 72Khz
|
||||
#define TEMP_TIMER_FREQUENCY 1000 // temperature interrupt frequency
|
||||
|
||||
#define STEP_TIMER_MIN_INTERVAL 8 // minimum time in µs between stepper interrupts
|
||||
|
||||
#define ENABLE_STEPPER_DRIVER_INTERRUPT() HAL_timer_enable_interrupt(STEP_TIMER_NUM)
|
||||
#define DISABLE_STEPPER_DRIVER_INTERRUPT() HAL_timer_disable_interrupt(STEP_TIMER_NUM)
|
||||
|
||||
@ -94,6 +96,7 @@ void HAL_timer_disable_interrupt(const uint8_t timer_num);
|
||||
void HAL_timer_set_compare(const uint8_t timer_num, const uint32_t compare);
|
||||
hal_timer_t HAL_timer_get_compare(const uint8_t timer_num);
|
||||
uint32_t HAL_timer_get_count(const uint8_t timer_num);
|
||||
void HAL_timer_restrain(const uint8_t timer_num, const uint16_t interval_µs);
|
||||
|
||||
void HAL_timer_isr_prologue(const uint8_t timer_num);
|
||||
|
||||
|
@ -315,7 +315,7 @@ class TMC26XStepper {
|
||||
/*!
|
||||
* \brief readout the motor maximum current in mA (1000 is an Amp)
|
||||
* This is the maximum current. to get the current current - which may be affected by CoolStep us getCurrentCurrent()
|
||||
*\return the maximum motor current in milli amps
|
||||
* \return the maximum motor current in milli amps
|
||||
* \sa getCurrentCurrent()
|
||||
*/
|
||||
unsigned int getCurrent(void);
|
||||
|
Reference in New Issue
Block a user