Add stepper timer example implementation for avr.
[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  * \version $Id$
36  *
37  * \author Daniele Basile <asterix@develer.com>
38  *
39  */
40
41 #ifndef DRV_STEPPER_AVR_H
42 #define DRV_STEPPER_AVR_H
43
44
45 #include <cfg/compiler.h>
46 #include <cfg/macros.h>
47
48 #include <drv/stepper.h>
49
50 #warning TODO:This is an example, you must implement it!
51
52 /**
53  * IRQ callback function type definition.
54  */
55 typedef void (*irq_t)(void);
56
57 /**
58  * Timer contex structure.
59  */
60 typedef struct TimerCounter
61 {
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
66
67 } TimerCounter;
68
69 /**
70  * Enable interrupt for timer counter compare event.
71  */
72 INLINE void stepper_tc_irq_enable(struct TimerCounter *timer)
73 {
74                 /* put here code to enable timer irq */
75 }
76
77
78 /**
79  * Disable interrupt for timer counter compare event.
80  */
81 INLINE void  stepper_tc_irq_disable(struct TimerCounter *timer)
82 {
83                 /* put here code to disable timer irq */
84 }
85
86 /**
87  * Set delay for next interrupt compare event.
88  */
89 INLINE void  stepper_tc_setDelay(struct TimerCounter *timer, stepper_time_t delay)
90 {
91                 /* put here code to set the delay for next irq */
92 }
93
94
95 /**
96  * Set delay for next interrupt compare event.
97  */
98 INLINE void  stepper_tc_resetTimer(struct TimerCounter *timer)
99 {
100                 /* put here code to reset the timer */
101 }
102
103 /**
104  * Programm timer counter to generate a pulse on select TIO output.
105  */
106 INLINE void FAST_FUNC stepper_tc_doPulse(struct TimerCounter *timer)
107 {
108                 /* put here code to generate a pulse */
109 }
110
111 /**
112  * Programm timer counter to not generate a pulse on select TIO output.
113  */
114 INLINE void FAST_FUNC stepper_tc_skipPulse(struct TimerCounter *timer)
115 {
116                 /* put here code to skip a pulse */
117 }
118
119 void stepper_tc_setup(int index, stepper_isr_t callback, struct Stepper *motor);
120 void stepper_tc_init(void);
121
122 #endif /*DRV_STEPPER_AVR_H */