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).
36 * \author Daniele Basile <asterix@develer.com>
40 #ifndef DRV_STEPPER_AVR_H
41 #define DRV_STEPPER_AVR_H
44 #include <cfg/compiler.h>
45 #include <cfg/macros.h>
47 #include <drv/stepper.h>
49 #warning TODO:This is an example, you must implement it!
52 * IRQ callback function type definition.
54 typedef void (*irq_t)(void);
57 * Timer contex structure.
59 typedef struct TimerCounter
61 int timer_id; ///< Timer counter ID
62 irq_t isr; ///< IRQ handler
63 stepper_isr_t callback; ///< Interrupt callback pointer
64 struct Stepper *motor; ///< Stepper context structure
69 * Enable interrupt for timer counter compare event.
71 INLINE void stepper_tc_irq_enable(struct TimerCounter *timer)
73 /* put here code to enable timer irq */
75 //Only for test remove when implement this function
81 * Disable interrupt for timer counter compare event.
83 INLINE void stepper_tc_irq_disable(struct TimerCounter *timer)
85 /* put here code to disable timer irq */
87 //Only for test remove when implement this function
92 * Set delay for next interrupt compare event.
94 INLINE void stepper_tc_setDelay(struct TimerCounter *timer, stepper_time_t delay)
96 /* put here code to set the delay for next irq */
98 //Only for test remove when implement this function
105 * Set delay for next interrupt compare event.
107 INLINE void stepper_tc_resetTimer(struct TimerCounter *timer)
109 /* put here code to reset the timer */
111 //Only for test remove when implement this function
116 * Programm timer counter to generate a pulse on select TIO output.
118 INLINE void FAST_FUNC stepper_tc_doPulse(struct TimerCounter *timer)
120 /* put here code to generate a pulse */
122 //Only for test remove when implement this function
127 * Programm timer counter to not generate a pulse on select TIO output.
129 INLINE void FAST_FUNC stepper_tc_skipPulse(struct TimerCounter *timer)
131 /* put here code to skip a pulse */
133 //Only for test remove when implement this function
137 void stepper_tc_setup(int index, stepper_isr_t callback, struct Stepper *motor);
138 void stepper_tc_init(void);
140 #endif /*DRV_STEPPER_AVR_H */