Allow setting current timer counter

This commit is contained in:
Scott Lahteine
2017-12-09 19:57:25 -06:00
parent 82ef6b5242
commit 6149b82119
5 changed files with 45 additions and 17 deletions

View File

@ -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)