Allow setting current timer counter
This commit is contained in:
parent
82ef6b5242
commit
6149b82119
@ -100,17 +100,23 @@ extern "C" {
|
||||
|
||||
|
||||
// timers
|
||||
#define STEP_TIMER_NUM OCR1A
|
||||
#define TEMP_TIMER_NUM 0
|
||||
#define TEMP_TIMER_FREQUENCY (F_CPU / 64.0 / 256.0)
|
||||
|
||||
#define HAL_TIMER_RATE ((F_CPU) / 8) // i.e., 2MHz or 2.5MHz
|
||||
#define HAL_STEPPER_TIMER_RATE HAL_TIMER_RATE
|
||||
#define STEPPER_TIMER_PRESCALE 8
|
||||
#define HAL_TICKS_PER_US ((HAL_STEPPER_TIMER_RATE) / 1000000) // Cannot be of type double
|
||||
|
||||
#define PULSE_TIMER_NUM TEMP_TIMER_NUM
|
||||
#define TEMP_TIMER_FREQUENCY ((F_CPU) / 64.0 / 256.0)
|
||||
|
||||
#define HAL_STEPPER_TIMER_RATE HAL_TIMER_RATE
|
||||
#define STEPPER_TIMER_PRESCALE 8
|
||||
|
||||
#define STEP_TIMER_NUM 1
|
||||
#define TIMER_OCR_1 OCR1A
|
||||
#define TIMER_COUNTER_1 TCNT1
|
||||
|
||||
#define TEMP_TIMER_NUM 0
|
||||
#define TIMER_OCR_0 OCR0A
|
||||
#define TIMER_COUNTER_0 TCNT0
|
||||
|
||||
#define PULSE_TIMER_NUM TEMP_TIMER_NUM
|
||||
#define PULSE_TIMER_PRESCALE 8
|
||||
|
||||
#define ENABLE_STEPPER_DRIVER_INTERRUPT() SBI(TIMSK1, OCIE1A)
|
||||
@ -119,17 +125,14 @@ extern "C" {
|
||||
#define ENABLE_TEMPERATURE_INTERRUPT() SBI(TIMSK0, OCIE0B)
|
||||
#define DISABLE_TEMPERATURE_INTERRUPT() CBI(TIMSK0, OCIE0B)
|
||||
|
||||
//void HAL_timer_start(const uint8_t timer_num, const uint32_t frequency);
|
||||
#define HAL_timer_start(timer_num,frequency)
|
||||
#define HAL_timer_start(timer_num, frequency)
|
||||
|
||||
#define HAL_timer_get_count(timer) timer
|
||||
#define _CAT(a, ...) a ## __VA_ARGS__
|
||||
#define HAL_timer_set_count(timer, count) (_CAT(TIMER_OCR_, timer) = count)
|
||||
#define HAL_timer_get_count(timer) _CAT(TIMER_OCR_, timer)
|
||||
#define HAL_timer_set_current_count(timer, count) (_CAT(TIMER_COUNTER_, timer) = count)
|
||||
#define HAL_timer_get_current_count(timer) _CAT(TIMER_COUNTER_, timer)
|
||||
|
||||
//void HAL_timer_set_count(const uint8_t timer_num, const uint16_t count);
|
||||
#define HAL_timer_set_count(timer, count) timer = (count)
|
||||
|
||||
#define HAL_timer_get_current_count(timer) timer
|
||||
|
||||
//void HAL_timer_isr_prologue(const uint8_t timer_num);
|
||||
#define HAL_timer_isr_prologue(timer_num)
|
||||
|
||||
#define HAL_STEP_TIMER_ISR ISR(TIMER1_COMPA_vect)
|
||||
|
@ -100,6 +100,11 @@ FORCE_INLINE static hal_timer_t HAL_timer_get_count(const uint8_t 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];
|
||||
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];
|
||||
return pConfig->pTimerRegs->TC_CHANNEL[pConfig->channel].TC_CV;
|
||||
|
@ -103,6 +103,13 @@ FORCE_INLINE static hal_timer_t HAL_timer_get_count(const uint8_t timer_num) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
FORCE_INLINE static void HAL_timer_set_current_count(const uint8_t timer_num, const hal_timer_t count) {
|
||||
switch (timer_num) {
|
||||
case 0: LPC_TIM0->TC = count; break;
|
||||
case 1: LPC_TIM1->TC = count; break;
|
||||
}
|
||||
}
|
||||
|
||||
FORCE_INLINE static hal_timer_t HAL_timer_get_current_count(const uint8_t timer_num) {
|
||||
switch (timer_num) {
|
||||
case 0: return LPC_TIM0->TC;
|
||||
|
@ -144,6 +144,13 @@ FORCE_INLINE static hal_timer_t HAL_timer_get_count(const uint8_t timer_num) {
|
||||
return temp;
|
||||
}
|
||||
|
||||
FORCE_INLINE static void HAL_timer_set_current_count(const uint8_t timer_num, const hal_timer_t count) {
|
||||
switch (timer_num) {
|
||||
case STEP_TIMER_NUM: StepperTimer.setCount(count); break;
|
||||
case TEMP_TIMER_NUM: TempTimer.setCount(count); break;
|
||||
}
|
||||
}
|
||||
|
||||
FORCE_INLINE static hal_timer_t HAL_timer_get_current_count(const uint8_t timer_num) {
|
||||
hal_timer_t temp;
|
||||
switch (timer_num) {
|
||||
@ -160,7 +167,6 @@ FORCE_INLINE static hal_timer_t HAL_timer_get_current_count(const uint8_t timer_
|
||||
return temp;
|
||||
}
|
||||
|
||||
|
||||
//void HAL_timer_isr_prologue (const uint8_t timer_num);
|
||||
|
||||
FORCE_INLINE static void HAL_timer_isr_prologue(const uint8_t timer_num) {
|
||||
|
@ -93,6 +93,13 @@ FORCE_INLINE static hal_timer_t HAL_timer_get_count(const uint8_t timer_num) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
FORCE_INLINE static void HAL_timer_set_current_count(const uint8_t timer_num, const hal_timer_t count) {
|
||||
switch (timer_num) {
|
||||
case 0: FTM0_CNT = count;
|
||||
case 1: FTM1_CNT = count;
|
||||
}
|
||||
}
|
||||
|
||||
FORCE_INLINE static hal_timer_t HAL_timer_get_current_count(const uint8_t timer_num) {
|
||||
switch (timer_num) {
|
||||
case 0: return FTM0_CNT;
|
||||
|
Loading…
Reference in New Issue
Block a user