annotate packages/kernel/current/include/clock.inl @ 3177:58eda6fed5a5

New files -- Kinetis variant documentation. [Bug 1001580]
author vae
date Fri, 18 May 2012 21:27:23 +0000
parents 74dbf4c3f2e1
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_INL
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
2 #define CYGONCE_KERNEL_CLOCK_INL
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.inl
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 inlines
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: 66
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: 66
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: 66
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: 66
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: 66
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-30
443894e2e912 Block commit of eCos version 1.2.1
jlarmour
parents: 0
diff changeset
48 // Purpose: Define Clock and Alarm class inlines
443894e2e912 Block commit of eCos version 1.2.1
jlarmour
parents: 0
diff changeset
49 // Description: Define inline functions for counter, clock and alarm
0
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
50 // classes.
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
51 // Usage: #include <cyg/kernel/clock.hxx>
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
52 // #include <cyg/kernel/clock.inl>
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/clock.hxx>
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
59
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
60 // -------------------------------------------------------------------------
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
61 // -------------------------------------------------------------------------
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
62 // Counter class inlines
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
63
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
64 // Return current value of counter
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
65 inline cyg_tick_count Cyg_Counter::current_value()
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
66 {
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
67 return counter;
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
68 }
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
69
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
70 inline cyg_uint32 Cyg_Counter::current_value_lo()
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
71 {
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
72 return counter&0xFFFFFFFF;
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
73 }
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 inline cyg_uint32 Cyg_Counter::current_value_hi()
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 return (counter>>32)&0xFFFFFFFF;
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
78 }
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 // Set the counter's current value
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
81 inline void Cyg_Counter::set_value( cyg_tick_count new_value)
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
82 {
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
83 counter = new_value;
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
84 }
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
85
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
86 // -------------------------------------------------------------------------
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 // Clock class inlines
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
89
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
90 // Return current resolution
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
91 inline Cyg_Clock::cyg_resolution Cyg_Clock::get_resolution()
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
92 {
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
93 return resolution;
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
94 }
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
95
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
96 // Set new resolution
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
97 inline void Cyg_Clock::set_resolution(
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
98 Cyg_Clock::cyg_resolution new_resolution
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 {
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
101 resolution = new_resolution;
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
102 }
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
103
64
c38311975d4f Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents: 2
diff changeset
104 inline cyg_tick_count Cyg_Clock::convert(
c38311975d4f Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents: 2
diff changeset
105 cyg_tick_count value,
c38311975d4f Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents: 2
diff changeset
106 struct converter *pcc )
c38311975d4f Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents: 2
diff changeset
107 {
c38311975d4f Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents: 2
diff changeset
108 cyg_uint64 t = (cyg_uint64)value;
c38311975d4f Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents: 2
diff changeset
109 // Do this in an order to prevent overflow at the expense of
c38311975d4f Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents: 2
diff changeset
110 // accuracy:
c38311975d4f Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents: 2
diff changeset
111 t *= pcc->mul1;
c38311975d4f Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents: 2
diff changeset
112 t += pcc->div1 / 2;
c38311975d4f Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents: 2
diff changeset
113 t /= pcc->div1;
c38311975d4f Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents: 2
diff changeset
114 t *= pcc->mul2;
c38311975d4f Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents: 2
diff changeset
115 t += pcc->div2 / 2;
c38311975d4f Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents: 2
diff changeset
116 t /= pcc->div2;
c38311975d4f Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents: 2
diff changeset
117 // The alternative would be to do the 2 multiplies first
c38311975d4f Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents: 2
diff changeset
118 // for smaller arguments.
c38311975d4f Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents: 2
diff changeset
119 return (cyg_tick_count)t;
c38311975d4f Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents: 2
diff changeset
120 }
c38311975d4f Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents: 2
diff changeset
121
0
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
122 // -------------------------------------------------------------------------
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
123 #endif // ifndef CYGONCE_KERNEL_CLOCK_INL
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
124 // EOF clock.inl