annotate packages/kernel/current/include/clock.hxx @ 2729:74dbf4c3f2e1 after-copyright-change-20090129

Update all copyright banners to reflect FSF ownership; fix and improve licence text.
author jlarmour
date Thu, 29 Jan 2009 17:47:46 +0000
parents 4c13726203c5
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
1 #ifndef CYGONCE_KERNEL_CLOCK_HXX
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
2 #define CYGONCE_KERNEL_CLOCK_HXX
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
3
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
4 //==========================================================================
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
5 //
2
443894e2e912 Block commit of eCos version 1.2.1
jlarmour
parents: 0
diff changeset
6 // clock.hxx
0
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
7 //
2
443894e2e912 Block commit of eCos version 1.2.1
jlarmour
parents: 0
diff changeset
8 // Clock and Alarm class declaration(s)
0
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
9 //
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
10 //==========================================================================
2729
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 1088
diff changeset
11 // ####ECOSGPLCOPYRIGHTBEGIN####
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 1088
diff changeset
12 // -------------------------------------------
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 1088
diff changeset
13 // This file is part of eCos, the Embedded Configurable Operating System.
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 1088
diff changeset
14 // Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
208
e0c0827131d1 Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents: 148
diff changeset
15 //
2729
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 1088
diff changeset
16 // eCos is free software; you can redistribute it and/or modify it under
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 1088
diff changeset
17 // the terms of the GNU General Public License as published by the Free
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 1088
diff changeset
18 // Software Foundation; either version 2 or (at your option) any later
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 1088
diff changeset
19 // version.
208
e0c0827131d1 Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents: 148
diff changeset
20 //
2729
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 1088
diff changeset
21 // eCos is distributed in the hope that it will be useful, but WITHOUT
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 1088
diff changeset
22 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 1088
diff changeset
23 // FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 1088
diff changeset
24 // for more details.
208
e0c0827131d1 Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents: 148
diff changeset
25 //
2729
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 1088
diff changeset
26 // You should have received a copy of the GNU General Public License
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 1088
diff changeset
27 // along with eCos; if not, write to the Free Software Foundation, Inc.,
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 1088
diff changeset
28 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
208
e0c0827131d1 Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents: 148
diff changeset
29 //
2729
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 1088
diff changeset
30 // As a special exception, if other files instantiate templates or use
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 1088
diff changeset
31 // macros or inline functions from this file, or you compile this file
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 1088
diff changeset
32 // and link it with other works to produce a work based on this file,
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 1088
diff changeset
33 // this file does not by itself cause the resulting work to be covered by
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 1088
diff changeset
34 // the GNU General Public License. However the source code for this file
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 1088
diff changeset
35 // must still be made available in accordance with section (3) of the GNU
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 1088
diff changeset
36 // General Public License v2.
208
e0c0827131d1 Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents: 148
diff changeset
37 //
2729
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 1088
diff changeset
38 // This exception does not invalidate any other reasons why a work based
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 1088
diff changeset
39 // on this file might be covered by the GNU General Public License.
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 1088
diff changeset
40 // -------------------------------------------
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 1088
diff changeset
41 // ####ECOSGPLCOPYRIGHTEND####
0
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
42 //==========================================================================
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
43 //#####DESCRIPTIONBEGIN####
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
44 //
2
443894e2e912 Block commit of eCos version 1.2.1
jlarmour
parents: 0
diff changeset
45 // Author(s): nickg
443894e2e912 Block commit of eCos version 1.2.1
jlarmour
parents: 0
diff changeset
46 // Contributors: nickg
443894e2e912 Block commit of eCos version 1.2.1
jlarmour
parents: 0
diff changeset
47 // Date: 1997-09-09
443894e2e912 Block commit of eCos version 1.2.1
jlarmour
parents: 0
diff changeset
48 // Purpose: Define Clock and Alarm class interfaces
443894e2e912 Block commit of eCos version 1.2.1
jlarmour
parents: 0
diff changeset
49 // Description: The classes defined here collectively implement the
0
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
50 // internal API used to create, configure and manage Counters,
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
51 // Clocks and Alarms.
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
52 // Usage: #include <cyg/kernel/clock.hxx>
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
53 //
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
54 //####DESCRIPTIONEND####
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
55 //
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
56 //==========================================================================
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
57
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
58 #include <cyg/kernel/ktypes.h>
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
59 #include <cyg/infra/cyg_ass.h> // assertion macros
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
60
148
8f2f7615e727 Merge from eCos master repository on 2001-01-12-06:43:03-GMT
jlarmour
parents: 115
diff changeset
61 #include <cyg/infra/clist.hxx>
8f2f7615e727 Merge from eCos master repository on 2001-01-12-06:43:03-GMT
jlarmour
parents: 115
diff changeset
62
0
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
63 // -------------------------------------------------------------------------
148
8f2f7615e727 Merge from eCos master repository on 2001-01-12-06:43:03-GMT
jlarmour
parents: 115
diff changeset
64 // Forward definitions and typedefs.
0
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
65
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
66 class Cyg_Alarm;
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
67
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
68 typedef void cyg_alarm_fn(Cyg_Alarm *alarm, CYG_ADDRWORD data);
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
69
148
8f2f7615e727 Merge from eCos master repository on 2001-01-12-06:43:03-GMT
jlarmour
parents: 115
diff changeset
70 typedef Cyg_CList_T<Cyg_Alarm> Cyg_Alarm_List;
8f2f7615e727 Merge from eCos master repository on 2001-01-12-06:43:03-GMT
jlarmour
parents: 115
diff changeset
71
0
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
72 // -------------------------------------------------------------------------
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
73 // Counter object.
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
74
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
75 class Cyg_Counter
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
76 {
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
77
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
78 friend class Cyg_Alarm;
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
79
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
80 #if defined(CYGIMP_KERNEL_COUNTERS_SINGLE_LIST)
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
81
148
8f2f7615e727 Merge from eCos master repository on 2001-01-12-06:43:03-GMT
jlarmour
parents: 115
diff changeset
82 Cyg_Alarm_List alarm_list; // Linear list of Alarms
0
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
83
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
84 #elif defined(CYGIMP_KERNEL_COUNTERS_MULTI_LIST)
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
85
148
8f2f7615e727 Merge from eCos master repository on 2001-01-12-06:43:03-GMT
jlarmour
parents: 115
diff changeset
86 Cyg_Alarm_List alarm_list[CYGNUM_KERNEL_COUNTERS_MULTI_LIST_SIZE];
0
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
87
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
88 #endif
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
89
62
7a6ac9edc838 Merge from eCos master repository on 2000-01-24-19:43:49-GMT
jlarmour
parents: 2
diff changeset
90 volatile cyg_tick_count counter; // counter value
0
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
91
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
92 cyg_uint32 increment; // increment per tick
1088
4c13726203c5 * include/clock.hxx: Made Cyg_Counter::add_alarm() and
nickg
parents: 210
diff changeset
93
4c13726203c5 * include/clock.hxx: Made Cyg_Counter::add_alarm() and
nickg
parents: 210
diff changeset
94 // Add an alarm to this counter
4c13726203c5 * include/clock.hxx: Made Cyg_Counter::add_alarm() and
nickg
parents: 210
diff changeset
95 void add_alarm( Cyg_Alarm *alarm );
4c13726203c5 * include/clock.hxx: Made Cyg_Counter::add_alarm() and
nickg
parents: 210
diff changeset
96
4c13726203c5 * include/clock.hxx: Made Cyg_Counter::add_alarm() and
nickg
parents: 210
diff changeset
97 // Remove an alarm from this counter
4c13726203c5 * include/clock.hxx: Made Cyg_Counter::add_alarm() and
nickg
parents: 210
diff changeset
98 void rem_alarm( Cyg_Alarm *alarm );
0
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
99
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
100 public:
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
101
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
102 CYGDBG_DEFINE_CHECK_THIS
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
103
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
104 Cyg_Counter(
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
105 cyg_uint32 increment = 1
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
106 );
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
107
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
108 ~Cyg_Counter();
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
109
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
110 // Return current value of counter
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
111 cyg_tick_count current_value();
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
112
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
113 // Return low and high halves of the
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
114 // counter value.
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
115 cyg_uint32 current_value_lo();
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
116 cyg_uint32 current_value_hi();
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
117
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
118 // Set the counter's current value
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
119 void set_value( cyg_tick_count new_value);
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
120
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
121 // Advance counter by some number of ticks
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
122 void tick( cyg_uint32 ticks = 1);
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
123
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
124 };
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
125
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
126 // -------------------------------------------------------------------------
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
127 // Clock class. This is derived from a Counter and defines extra
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
128 // features to support clock-like behaviour.
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
129
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
130 class Cyg_Clock
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
131 : public Cyg_Counter
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
132 {
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
133
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
134 public:
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
135
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
136 CYGDBG_DEFINE_CHECK_THIS
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
137
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
138 // This structure allows a more accurate representation
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
139 // of the resolution than a single integer would allow.
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
140 // The resolution is defined as dividend/divisor nanoseconds
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
141 // per tick.
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
142 struct cyg_resolution {
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
143 cyg_uint32 dividend;
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
144 cyg_uint32 divisor;
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
145 };
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
146
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
147 private:
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
148
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
149 cyg_resolution resolution; // Current clock resolution
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
150
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
151 public:
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
152
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
153 Cyg_Clock( // Create clock with given resolution
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
154 cyg_resolution resolution
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
155 );
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
156
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
157 ~Cyg_Clock(); // Destructor
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
158
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
159 cyg_resolution get_resolution(); // Return current resolution
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
160
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
161 void set_resolution( // Set new resolution
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
162 cyg_resolution resolution
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
163 );
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
164
64
c38311975d4f Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents: 62
diff changeset
165 // There is a need for converting from "other" ticks to clock ticks.
c38311975d4f Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents: 62
diff changeset
166 // We will construct 4 numbers to do the conversion as:
c38311975d4f Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents: 62
diff changeset
167 // clock_ticks = (((otherticks*mul1)/div1)*mul2/div2)
c38311975d4f Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents: 62
diff changeset
168 // with the values chosen to minimize the possibility of overflow.
c38311975d4f Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents: 62
diff changeset
169 // Do the arithmetic in cyg_uint64s throughout.
c38311975d4f Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents: 62
diff changeset
170 struct converter {
c38311975d4f Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents: 62
diff changeset
171 cyg_uint64 mul1, div1, mul2, div2;
c38311975d4f Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents: 62
diff changeset
172 };
c38311975d4f Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents: 62
diff changeset
173
c38311975d4f Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents: 62
diff changeset
174 // There are two of these because the 4 numbers are different depending
c38311975d4f Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents: 62
diff changeset
175 // on the direction of the conversion, to prevent loss of significance.
c38311975d4f Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents: 62
diff changeset
176 // NB these relate to the resolution of the clock object they are
c38311975d4f Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents: 62
diff changeset
177 // called against, not necessarily "the" system real time clock.
c38311975d4f Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents: 62
diff changeset
178 void get_other_to_clock_converter( cyg_uint64 ns_per_other_tick,
c38311975d4f Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents: 62
diff changeset
179 struct converter *pcc );
c38311975d4f Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents: 62
diff changeset
180
c38311975d4f Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents: 62
diff changeset
181 void get_clock_to_other_converter( cyg_uint64 ns_per_other_tick,
c38311975d4f Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents: 62
diff changeset
182 struct converter *pcc );
c38311975d4f Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents: 62
diff changeset
183
c38311975d4f Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents: 62
diff changeset
184 // A utility to perform the conversion in the obvious way, with
c38311975d4f Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents: 62
diff changeset
185 // rounding to nearest at each stage. Static because it uses a
c38311975d4f Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents: 62
diff changeset
186 // previously acquired converter.
c38311975d4f Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents: 62
diff changeset
187 static cyg_tick_count convert( cyg_tick_count value,
c38311975d4f Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents: 62
diff changeset
188 struct converter *pcc );
c38311975d4f Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents: 62
diff changeset
189
0
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
190 #ifdef CYGVAR_KERNEL_COUNTERS_CLOCK
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
191
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
192 // There is a system supplied real time clock...
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
193
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
194 static Cyg_Clock *real_time_clock;
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
195
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
196 #endif
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
197
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
198 };
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
199
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
200 // -------------------------------------------------------------------------
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
201 // Alarm class. An alarm may be attached to a counter (or a clock) to be
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
202 // called when the trigger value is reached.
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
203
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
204 class Cyg_Alarm
148
8f2f7615e727 Merge from eCos master repository on 2001-01-12-06:43:03-GMT
jlarmour
parents: 115
diff changeset
205 #if defined(CYGIMP_KERNEL_COUNTERS_SINGLE_LIST) || defined(CYGIMP_KERNEL_COUNTERS_MULTI_LIST)
8f2f7615e727 Merge from eCos master repository on 2001-01-12-06:43:03-GMT
jlarmour
parents: 115
diff changeset
206 : public Cyg_DNode_T<Cyg_Alarm>
8f2f7615e727 Merge from eCos master repository on 2001-01-12-06:43:03-GMT
jlarmour
parents: 115
diff changeset
207 #endif
0
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
208 {
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
209 friend class Cyg_Counter;
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
210
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
211 protected:
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
212 Cyg_Counter *counter; // Attached to this counter/clock
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
213
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
214 cyg_alarm_fn *alarm; // Call-back function
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
215
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
216 CYG_ADDRWORD data; // Call-back data
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
217
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
218 cyg_tick_count trigger; // Absolute trigger time
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
219
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
220 cyg_tick_count interval; // Retrigger interval
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
221
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
222 cyg_bool enabled; // True if enabled
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
223
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
224 Cyg_Alarm();
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
225
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
226 void synchronize( void ); // deal with times in the past,
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
227 // make next alarm in synch.
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
228
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
229 public:
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
230
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
231 CYGDBG_DEFINE_CHECK_THIS
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
232
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
233 Cyg_Alarm // Constructor
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
234 (
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
235 Cyg_Counter *counter, // Attached to this counter
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
236 cyg_alarm_fn *alarm, // Call-back function
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
237 CYG_ADDRWORD data // Call-back data
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
238 );
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
239
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
240 ~Cyg_Alarm(); // Destructor
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
241
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
242 void initialize( // Initialize Alarm
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
243 cyg_tick_count trigger, // Absolute trigger time
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
244 cyg_tick_count interval = 0 // Relative retrigger interval
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
245 );
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
246
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
247 void enable(); // Ensure alarm enabled
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
248
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
249 void disable(); // Ensure alarm disabled
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
250
115
6ed91473a1cd Merge from eCos master repository on 2000-08-21-22:40:54-BST
jlarmour
parents: 66
diff changeset
251 void get_times(
6ed91473a1cd Merge from eCos master repository on 2000-08-21-22:40:54-BST
jlarmour
parents: 66
diff changeset
252 cyg_tick_count *trigger, // Next trigger time
6ed91473a1cd Merge from eCos master repository on 2000-08-21-22:40:54-BST
jlarmour
parents: 66
diff changeset
253 cyg_tick_count *interval // Current interval
6ed91473a1cd Merge from eCos master repository on 2000-08-21-22:40:54-BST
jlarmour
parents: 66
diff changeset
254 );
0
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
255 };
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
256
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
257 // -------------------------------------------------------------------------
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
258
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
259 #endif // ifndef CYGONCE_KERNEL_CLOCK_HXX
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
260 // EOF clock.hxx