|
|
@ -53,14 +53,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
#define TEMP_TIMER_FREQUENCY 1000 // temperature interrupt frequency
|
|
|
|
#define TEMP_TIMER_FREQUENCY 1000 // temperature interrupt frequency
|
|
|
|
|
|
|
|
|
|
|
|
#define ENABLE_STEPPER_DRIVER_INTERRUPT() HAL_timer_enable_interrupt (STEP_TIMER_NUM)
|
|
|
|
#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 DISABLE_STEPPER_DRIVER_INTERRUPT() HAL_timer_disable_interrupt(STEP_TIMER_NUM)
|
|
|
|
|
|
|
|
|
|
|
|
#define ENABLE_TEMPERATURE_INTERRUPT() HAL_timer_enable_interrupt (TEMP_TIMER_NUM)
|
|
|
|
#define ENABLE_TEMPERATURE_INTERRUPT() HAL_timer_enable_interrupt(TEMP_TIMER_NUM)
|
|
|
|
#define DISABLE_TEMPERATURE_INTERRUPT() HAL_timer_disable_interrupt (TEMP_TIMER_NUM)
|
|
|
|
#define DISABLE_TEMPERATURE_INTERRUPT() HAL_timer_disable_interrupt(TEMP_TIMER_NUM)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#define HAL_ENABLE_ISRs() do { if (thermalManager.in_temp_isr) DISABLE_TEMPERATURE_INTERRUPT(); else ENABLE_TEMPERATURE_INTERRUPT(); ENABLE_STEPPER_DRIVER_INTERRUPT(); } while(0)
|
|
|
|
|
|
|
|
|
|
|
|
#define HAL_ENABLE_ISRs() do { if (thermalManager.in_temp_isr)DISABLE_TEMPERATURE_INTERRUPT(); else ENABLE_TEMPERATURE_INTERRUPT(); ENABLE_STEPPER_DRIVER_INTERRUPT(); } while(0)
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
#define HAL_STEP_TIMER_ISR void TC3_Handler()
|
|
|
|
#define HAL_STEP_TIMER_ISR void TC3_Handler()
|
|
|
|
#define HAL_TEMP_TIMER_ISR void TC4_Handler()
|
|
|
|
#define HAL_TEMP_TIMER_ISR void TC4_Handler()
|
|
|
|
|
|
|
|
|
|
|
@ -85,29 +85,29 @@ extern const tTimerConfig TimerConfig[];
|
|
|
|
// Public functions
|
|
|
|
// Public functions
|
|
|
|
// --------------------------------------------------------------------------
|
|
|
|
// --------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
|
|
void HAL_timer_start (uint8_t timer_num, uint32_t frequency);
|
|
|
|
void HAL_timer_start(const uint8_t timer_num, const uint32_t frequency);
|
|
|
|
|
|
|
|
|
|
|
|
static FORCE_INLINE void HAL_timer_set_count (uint8_t timer_num, uint32_t count) {
|
|
|
|
static FORCE_INLINE void HAL_timer_set_count(const uint8_t timer_num, const uint32_t count) {
|
|
|
|
const tTimerConfig *pConfig = &TimerConfig[timer_num];
|
|
|
|
const tTimerConfig *pConfig = &TimerConfig[timer_num];
|
|
|
|
pConfig->pTimerRegs->TC_CHANNEL[pConfig->channel].TC_RC = count;
|
|
|
|
pConfig->pTimerRegs->TC_CHANNEL[pConfig->channel].TC_RC = count;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static FORCE_INLINE HAL_TIMER_TYPE HAL_timer_get_count (uint8_t timer_num) {
|
|
|
|
static FORCE_INLINE HAL_TIMER_TYPE HAL_timer_get_count(const uint8_t timer_num) {
|
|
|
|
const tTimerConfig *pConfig = &TimerConfig[timer_num];
|
|
|
|
const tTimerConfig *pConfig = &TimerConfig[timer_num];
|
|
|
|
return pConfig->pTimerRegs->TC_CHANNEL[pConfig->channel].TC_RC;
|
|
|
|
return pConfig->pTimerRegs->TC_CHANNEL[pConfig->channel].TC_RC;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static FORCE_INLINE uint32_t HAL_timer_get_current_count(uint8_t timer_num) {
|
|
|
|
static FORCE_INLINE uint32_t HAL_timer_get_current_count(const uint8_t timer_num) {
|
|
|
|
const tTimerConfig *pConfig = &TimerConfig[timer_num];
|
|
|
|
const tTimerConfig *pConfig = &TimerConfig[timer_num];
|
|
|
|
return pConfig->pTimerRegs->TC_CHANNEL[pConfig->channel].TC_CV;
|
|
|
|
return pConfig->pTimerRegs->TC_CHANNEL[pConfig->channel].TC_CV;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void HAL_timer_enable_interrupt(uint8_t timer_num);
|
|
|
|
void HAL_timer_enable_interrupt(const uint8_t timer_num);
|
|
|
|
void HAL_timer_disable_interrupt(uint8_t timer_num);
|
|
|
|
void HAL_timer_disable_interrupt(const uint8_t timer_num);
|
|
|
|
|
|
|
|
|
|
|
|
//void HAL_timer_isr_prologue (uint8_t timer_num);
|
|
|
|
//void HAL_timer_isr_prologue(const uint8_t timer_num);
|
|
|
|
|
|
|
|
|
|
|
|
static FORCE_INLINE void HAL_timer_isr_prologue(uint8_t timer_num) {
|
|
|
|
static FORCE_INLINE void HAL_timer_isr_prologue(const uint8_t timer_num) {
|
|
|
|
const tTimerConfig *pConfig = &TimerConfig[timer_num];
|
|
|
|
const tTimerConfig *pConfig = &TimerConfig[timer_num];
|
|
|
|
// Reading the status register clears the interrupt flag
|
|
|
|
// Reading the status register clears the interrupt flag
|
|
|
|
pConfig->pTimerRegs->TC_CHANNEL[pConfig->channel].TC_SR;
|
|
|
|
pConfig->pTimerRegs->TC_CHANNEL[pConfig->channel].TC_SR;
|
|
|
|