|
|
@ -55,6 +55,7 @@ typedef uint32_t hal_timer_t; |
|
|
|
|
|
|
|
#define ENABLE_STEPPER_DRIVER_INTERRUPT() HAL_timer_enable_interrupt(STEP_TIMER_NUM) |
|
|
|
#define DISABLE_STEPPER_DRIVER_INTERRUPT() HAL_timer_disable_interrupt(STEP_TIMER_NUM) |
|
|
|
#define STEPPER_ISR_ENABLED() HAL_timer_interrupt_enabled(STEP_TIMER_NUM) |
|
|
|
|
|
|
|
#define ENABLE_TEMPERATURE_INTERRUPT() HAL_timer_enable_interrupt(TEMP_TIMER_NUM) |
|
|
|
#define DISABLE_TEMPERATURE_INTERRUPT() HAL_timer_disable_interrupt(TEMP_TIMER_NUM) |
|
|
@ -91,32 +92,33 @@ extern const tTimerConfig TimerConfig[]; |
|
|
|
void HAL_timer_start(const uint8_t timer_num, const uint32_t frequency); |
|
|
|
|
|
|
|
FORCE_INLINE static void HAL_timer_set_count(const uint8_t timer_num, const hal_timer_t count) { |
|
|
|
const tTimerConfig *pConfig = &TimerConfig[timer_num]; |
|
|
|
const tTimerConfig * const pConfig = &TimerConfig[timer_num]; |
|
|
|
pConfig->pTimerRegs->TC_CHANNEL[pConfig->channel].TC_RC = count; |
|
|
|
} |
|
|
|
|
|
|
|
FORCE_INLINE static hal_timer_t HAL_timer_get_count(const uint8_t timer_num) { |
|
|
|
const tTimerConfig *pConfig = &TimerConfig[timer_num]; |
|
|
|
const tTimerConfig * const pConfig = &TimerConfig[timer_num]; |
|
|
|
return pConfig->pTimerRegs->TC_CHANNEL[pConfig->channel].TC_RC; |
|
|
|
} |
|
|
|
|
|
|
|
FORCE_INLINE static void HAL_timer_set_current_count(const uint8_t timer_num, const hal_timer_t count) { |
|
|
|
const tTimerConfig *pConfig = &TimerConfig[timer_num]; |
|
|
|
const tTimerConfig * const pConfig = &TimerConfig[timer_num]; |
|
|
|
pConfig->pTimerRegs->TC_CHANNEL[pConfig->channel].TC_CV = count; |
|
|
|
} |
|
|
|
|
|
|
|
FORCE_INLINE static hal_timer_t HAL_timer_get_current_count(const uint8_t timer_num) { |
|
|
|
const tTimerConfig *pConfig = &TimerConfig[timer_num]; |
|
|
|
const tTimerConfig * const pConfig = &TimerConfig[timer_num]; |
|
|
|
return pConfig->pTimerRegs->TC_CHANNEL[pConfig->channel].TC_CV; |
|
|
|
} |
|
|
|
|
|
|
|
void HAL_timer_enable_interrupt(const uint8_t timer_num); |
|
|
|
void HAL_timer_disable_interrupt(const uint8_t timer_num); |
|
|
|
bool HAL_timer_interrupt_enabled(const uint8_t timer_num); |
|
|
|
|
|
|
|
//void HAL_timer_isr_prologue(const uint8_t timer_num);
|
|
|
|
|
|
|
|
FORCE_INLINE static void HAL_timer_isr_prologue(const uint8_t timer_num) { |
|
|
|
const tTimerConfig *pConfig = &TimerConfig[timer_num]; |
|
|
|
const tTimerConfig * const pConfig = &TimerConfig[timer_num]; |
|
|
|
// Reading the status register clears the interrupt flag
|
|
|
|
pConfig->pTimerRegs->TC_CHANNEL[pConfig->channel].TC_SR; |
|
|
|
} |
|
|
|