yarf 0.1
Yet Another RepRap Firmware
|
The real-time timer is a high resolution, high priority timer which is used for controlling the rate at which the stepper motors are stepped. More...
#include "realtime_timer.h"
#include "hardware/fastio.h"
#include "yarf.h"
#include "util/math.h"
#include <stdint.h>
#include <stdlib.h>
#include <avr/interrupt.h>
#include <util/atomic.h>
Go to the source code of this file.
Defines | |
#define | RTTIMER_TICKS_PER_US (((float)F_CPU)/8/1000000) |
The number of ticks the real-time timer takes in one microsecond. | |
Functions | |
static void | timer2_set (long ticks) |
Sets the hardware timer 2 to raise an interrupt after a specified number of timer ticks. | |
ISR (TIMER2_COMPA_vect, ISR_BLOCK) | |
Interrupt service routine for the hardware timer. | |
void | rttimer_init (void) |
Initializes the real-time timer component. | |
int | rttimer_schedule_ticks (realtime_task_t *t, uint16_t ticks) |
Schedules a task to be executed after a specified number of ticks. | |
int | rttimer_cancel (void) |
Cancels the currently scheduled task. | |
Variables | |
static volatile realtime_task_t * | pending_task |
A pointer to a realtime_task_t structure indicating the task to be executed when the timer rings. |
The real-time timer is a high resolution, high priority timer which is used for controlling the rate at which the stepper motors are stepped.
Definition in file realtime_timer.c.
ISR | ( | TIMER2_COMPA_vect | , |
ISR_BLOCK | |||
) |
Interrupt service routine for the hardware timer.
This routine executes the scheduled task if the specified number of ticks have passed, or reschedules the timer if more ticks must elapse before the task must be executed.
Definition at line 97 of file realtime_timer.c.
int rttimer_cancel | ( | void | ) |
Cancels the currently scheduled task.
Definition at line 153 of file realtime_timer.c.
void rttimer_init | ( | void | ) |
Initializes the real-time timer component.
This should only be called once on boot.
Definition at line 121 of file realtime_timer.c.
int rttimer_schedule_ticks | ( | realtime_task_t * | t, |
uint16_t | ticks | ||
) |
Schedules a task to be executed after a specified number of ticks.
t | pointer to the task to be executed |
ticks | the number of ticks to wait before executing the task |
Definition at line 138 of file realtime_timer.c.
static void timer2_set | ( | long | ticks | ) | [inline, static] |
Sets the hardware timer 2 to raise an interrupt after a specified number of timer ticks.
ticks | the number of timer ticks after which the interrupt should be raised. |
If ticks is greater than the maximum possible hardware time interval, an interrupt will be raised after the maximum possible hardware time interval.
Definition at line 74 of file realtime_timer.c.