Remove \version svn tag.
[bertos.git] / bertos / cpu / avr / drv / stepper_avr.h
1 /**
2  * \file
3  * <!--
4  * This file is part of BeRTOS.
5  *
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.
10  *
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.
15  *
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
19  *
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.
28  *
29  * Copyright 2008 Develer S.r.l. (http://www.develer.com/)
30  *
31  * -->
32  *
33  * \brief Low-level stepper timer module for AVR (inplementation).
34  *
35  *
36  * \author Daniele Basile <asterix@develer.com>
37  *
38  */
39
40 #ifndef DRV_STEPPER_AVR_H
41 #define DRV_STEPPER_AVR_H
42
43
44 #include <cfg/compiler.h>
45 #include <cfg/macros.h>
46
47 #include <drv/stepper.h>
48
49 #warning TODO:This is an example, you must implement it!
50
51 /**
52  * IRQ callback function type definition.
53  */
54 typedef void (*irq_t)(void);
55
56 /**
57  * Timer contex structure.
58  */
59 typedef struct TimerCounter
60 {
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
65
66 } TimerCounter;
67
68 /**
69  * Enable interrupt for timer counter compare event.
70  */
71 INLINE void stepper_tc_irq_enable(struct TimerCounter *timer)
72 {
73                 /* put here code to enable timer irq */
74
75                 //Only for test remove when implement this function
76                 (void)timer;
77 }
78
79
80 /**
81  * Disable interrupt for timer counter compare event.
82  */
83 INLINE void  stepper_tc_irq_disable(struct TimerCounter *timer)
84 {
85                 /* put here code to disable timer irq */
86
87                 //Only for test remove when implement this function
88                 (void)timer;
89 }
90
91 /**
92  * Set delay for next interrupt compare event.
93  */
94 INLINE void  stepper_tc_setDelay(struct TimerCounter *timer, stepper_time_t delay)
95 {
96                 /* put here code to set the delay for next irq */
97
98                 //Only for test remove when implement this function
99                 (void)timer;
100                 (void)delay;
101 }
102
103
104 /**
105  * Set delay for next interrupt compare event.
106  */
107 INLINE void  stepper_tc_resetTimer(struct TimerCounter *timer)
108 {
109                 /* put here code to reset the timer */
110
111                 //Only for test remove when implement this function
112                 (void)timer;
113 }
114
115 /**
116  * Programm timer counter to generate a pulse on select TIO output.
117  */
118 INLINE void FAST_FUNC stepper_tc_doPulse(struct TimerCounter *timer)
119 {
120                 /* put here code to generate a pulse */
121
122                 //Only for test remove when implement this function
123                 (void)timer;
124 }
125
126 /**
127  * Programm timer counter to not generate a pulse on select TIO output.
128  */
129 INLINE void FAST_FUNC stepper_tc_skipPulse(struct TimerCounter *timer)
130 {
131                 /* put here code to skip a pulse */
132
133                 //Only for test remove when implement this function
134                 (void)timer;
135 }
136
137 void stepper_tc_setup(int index, stepper_isr_t callback, struct Stepper *motor);
138 void stepper_tc_init(void);
139
140 #endif /*DRV_STEPPER_AVR_H */