Refactor to use new protocol module and sipo.
[bertos.git] / bertos / cpu / i196 / drv / timer_i196.h
1 #error This code must be revised for the new timer API
2 /**
3  * \file
4  * <!--
5  * This file is part of BeRTOS.
6  *
7  * Bertos is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 2 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
20  *
21  * As a special exception, you may use this file as part of a free software
22  * library without restriction.  Specifically, if other files instantiate
23  * templates or use macros or inline functions from this file, or you compile
24  * this file and link it with other files to produce an executable, this
25  * file does not by itself cause the resulting executable to be covered by
26  * the GNU General Public License.  This exception does not however
27  * invalidate any other reasons why the executable file might be covered by
28  * the GNU General Public License.
29  *
30  * Copyright 2003,2004 Develer S.r.l. (http://www.develer.com/)
31  * Copyright 2000 Bernie Innocenti
32  *
33  * -->
34  *
35  *
36  * \author Bernie Innocenti <bernie@codewiz.org>
37  *
38  * \brief Low-level timer module for AVR
39  */
40
41 /*#*
42  *#* $Log$
43  *#* Revision 1.7  2006/07/19 12:56:26  bernie
44  *#* Convert to new Doxygen style.
45  *#*
46  *#* Revision 1.6  2006/02/21 21:28:02  bernie
47  *#* New time handling based on TIMER_TICKS_PER_SEC to support slow timers with ticks longer than 1ms.
48  *#*
49  *#* Revision 1.5  2005/11/04 16:20:02  bernie
50  *#* Fix reference to README.devlib in header.
51  *#*
52  *#* Revision 1.4  2004/12/13 11:51:08  bernie
53  *#* DISABLE_INTS/ENABLE_INTS: Convert to IRQ_DISABLE/IRQ_ENABLE.
54  *#*
55  *#* Revision 1.3  2004/08/25 14:12:08  rasky
56  *#* Aggiornato il comment block dei log RCS
57  *#*
58  *#* Revision 1.2  2004/06/03 11:27:09  bernie
59  *#* Add dual-license information.
60  *#*
61  *#* Revision 1.1  2004/05/23 18:23:30  bernie
62  *#* Import drv/timer module.
63  *#*
64  *#*/
65
66 #ifndef TIMER_I196_H
67 #define TIMER_I196_H
68
69 /**
70  * Retrigger TIMER2, adjusting the time to account for
71  * the interrupt prologue latency.
72  */
73 #define TIMER_RETRIGGER (TIMER2 -= TICKS_RATE)
74
75 #define TIMER_INIT \
76         TIMER2 = (65535 - TICKS_RATE); \
77         INT_MASK1 |= INT1F_T2OVF; \
78         ATOMIC( \
79                 WSR = 1; \
80                 IOC3 |= IOC3F_T2_ENA; \
81                 WSR = 0; \
82         )
83
84 #define DEFINE_TIMER_ISR \
85         INTERRUPT(0x38) void TM2_OVFL_interrupt(void);  \
86         INTERRUPT(0x38) void TM2_OVFL_interrupt(void)
87
88 #endif /* DRV_TIMER_I196_H */