4 * This file is part of BeRTOS.
6 * Bertos is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20 * As a special exception, you may use this file as part of a free software
21 * library without restriction. Specifically, if other files instantiate
22 * templates or use macros or inline functions from this file, or you compile
23 * this file and link it with other files to produce an executable, this
24 * file does not by itself cause the resulting executable to be covered by
25 * the GNU General Public License. This exception does not however
26 * invalidate any other reasons why the executable file might be covered by
27 * the GNU General Public License.
29 * Copyright 2008 Develer S.r.l. (http://www.develer.com/)
33 * \brief Low-level stepper timer module for AVR (inplementation).
37 * \author Daniele Basile <asterix@develer.com>
41 #ifndef DRV_STEPPER_AVR_H
42 #define DRV_STEPPER_AVR_H
45 #include <cfg/compiler.h>
46 #include <cfg/macros.h>
48 #include <drv/stepper.h>
50 #warning TODO:This is an example, you must implement it!
53 * IRQ callback function type definition.
55 typedef void (*irq_t)(void);
58 * Timer contex structure.
60 typedef struct TimerCounter
62 int timer_id; ///< Timer counter ID
63 irq_t isr; ///< IRQ handler
64 stepper_isr_t callback; ///< Interrupt callback pointer
65 struct Stepper *motor; ///< Stepper context structure
70 * Enable interrupt for timer counter compare event.
72 INLINE void stepper_tc_irq_enable(struct TimerCounter *timer)
74 /* put here code to enable timer irq */
76 //Only for test remove when implement this function
82 * Disable interrupt for timer counter compare event.
84 INLINE void stepper_tc_irq_disable(struct TimerCounter *timer)
86 /* put here code to disable timer irq */
88 //Only for test remove when implement this function
93 * Set delay for next interrupt compare event.
95 INLINE void stepper_tc_setDelay(struct TimerCounter *timer, stepper_time_t delay)
97 /* put here code to set the delay for next irq */
99 //Only for test remove when implement this function
106 * Set delay for next interrupt compare event.
108 INLINE void stepper_tc_resetTimer(struct TimerCounter *timer)
110 /* put here code to reset the timer */
112 //Only for test remove when implement this function
117 * Programm timer counter to generate a pulse on select TIO output.
119 INLINE void FAST_FUNC stepper_tc_doPulse(struct TimerCounter *timer)
121 /* put here code to generate a pulse */
123 //Only for test remove when implement this function
128 * Programm timer counter to not generate a pulse on select TIO output.
130 INLINE void FAST_FUNC stepper_tc_skipPulse(struct TimerCounter *timer)
132 /* put here code to skip a pulse */
134 //Only for test remove when implement this function
138 void stepper_tc_setup(int index, stepper_isr_t callback, struct Stepper *motor);
139 void stepper_tc_init(void);
141 #endif /*DRV_STEPPER_AVR_H */