1 /**
2 * @file ClockOps.h
3 *
4 * @brief Generic Clock interface header
5 *
6 *
7 */
8 /*
9 * ============================================================================
10 *
11 * Copyright (c) 2008-2012, Texas Instruments Incorporated
12 *
13 * Redistribution and use in source and binary forms, with or without
14 * modification, are permitted provided that the following conditions
15 * are met:
16 *
17 * * Redistributions of source code must retain the above copyright
18 * notice, this list of conditions and the following disclaimer.
19 *
20 * * Redistributions in binary form must reproduce the above copyright
21 * notice, this list of conditions and the following disclaimer in the
22 * documentation and/or other materials provided with the distribution.
23 *
24 * * Neither the name of Texas Instruments Incorporated nor the names of
25 * its contributors may be used to endorse or promote products derived
26 * from this software without specific prior written permission.
27 *
28 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
29 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
30 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
31 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
32 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
33 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
34 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
35 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
36 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
37 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
38 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
39 * Contact information for paper mail:
40 * Texas Instruments
41 * Post Office Box 655303
42 * Dallas, Texas 75265
43 * Contact information:
44 * http://www-k.ext.ti.com/sc/technical-support/product-information-centers.htm?
45 * DCMP=TIHomeTracking&HQS=Other+OT+home_d_contact
46 * ============================================================================
47 *
48 */
51 #ifndef ClockOps_H
52 #define ClockOps_H
54 #if defined (__cplusplus)
55 extern "C" {
56 #endif
59 /* =============================================================================
60 * All success and failure codes for the module
61 * =============================================================================
62 */
64 /*!
65 * @def ClockOps_S_ALREADYSETUP
66 * @brief The module has been already setup
67 */
68 #define ClockOps_S_ALREADYSETUP 1
70 /*!
71 * @def ClockOps_S_SUCCESS
72 * @brief Operation is successful.
73 */
74 #define ClockOps_S_SUCCESS 0
76 /*!
77 * @def ClockOps_E_FAIL
78 * @brief Generic failure.
79 */
80 #define ClockOps_E_FAIL -1
82 /*!
83 * @def ClockOps_E_INVALIDARG
84 * @brief Argument passed to function is invalid.
85 */
86 #define ClockOps_E_INVALIDARG -2
88 /*!
89 * @def ClockOps_E_MEMORY
90 * @brief Operation resulted in memory failure.
91 */
92 #define ClockOps_E_MEMORY -3
95 /*!
96 * @def ClockOps_E_INVALIDSTATE
97 * @brief Module is not initialized.
98 */
99 #define ClockOps_E_INVALIDSTATE -4
101 /*!
102 * @def ClockOps_E_OSFAILURE
103 * @brief A failure occurred in an OS-specific call
104 */
105 #define ClockOps_E_OSFAILURE -5
107 /*!
108 * @def ClockOps_E_RESOURCE
109 * @brief Specified resource is not available
110 */
111 #define ClockOps_E_RESOURCE -6
113 /*!
114 * @def ClockOps_E_HANDLE
115 * @brief Invalid object handle specified
116 */
117 #define ClockOps_E_HANDLE -7
119 /* =============================================================================
120 * Function pointer types
121 * =============================================================================
122 */
124 /* Function to get handle to the given Clock. */
125 typedef Ptr (*ClockOps_getFxn)(String clkname);
126 /* Function to release a Clock. */
127 typedef Void (*ClockOps_putFxn)(Ptr clkHandle);
128 /* Function to enable Clock. */
129 typedef Int32 (*ClockOps_enableFxn)(Ptr clkHandle);
130 /* Function to disable a Clock. */
131 typedef Void (*ClockOps_disableFxn)(Ptr clkHandle);
132 /* Function to get speed of a Clock. */
133 typedef ULong (*ClockOps_getRateFxn)(Ptr clkHandle);
134 /* Function to set the speed of a Clock. */
135 typedef Int32 (*ClockOps_setRateFxn)(Ptr clkHandle, ULong rate);
137 /* =============================================================================
138 * Function table interface
139 * =============================================================================
140 */
142 /*!
143 * @brief Function table interface for Clock.
144 */
145 typedef struct ClockOps_FxnTable_tag {
147 ClockOps_getFxn get;
148 /* Function to get handle to the given Clock. */
149 ClockOps_putFxn put;
150 /* Function to release a Clock. */
151 ClockOps_enableFxn enable;
152 /* Function to enable Clock. */
153 ClockOps_disableFxn disable;
154 /* Function to disable a Clock. */
155 ClockOps_getRateFxn getRate;
156 /* Function to get speed of a Clock. */
157 ClockOps_setRateFxn setRate;
158 /* Function to set the speed of a Clock. */
160 }ClockOps_FxnTable;
162 /*
163 * Generic ClockOps object. This object defines the handle type for all
164 * ClockOps operations.
165 */
166 struct ClockOps_Object_tag {
167 ClockOps_FxnTable clkFxnTable;
168 /*!< Interface function table to plug into the generic Clock. */
169 Ptr reserved;
170 /*!< reserved. */
171 };
173 /* ClockOps Object */
174 typedef struct ClockOps_Object_tag ClockOps_Object;
176 /*!
177 * @brief Defines ClockOps object handle
178 */
179 typedef ClockOps_Object * ClockOps_Handle;
182 /* =============================================================================
183 * APIs
184 * =============================================================================
185 */
186 /* Function to get handle to a clock given its name */
187 Ptr ClockOps_get(ClockOps_Handle handle, String clkname);
188 /* Function to release a Clock. */
189 Void ClockOps_put(ClockOps_Handle handle, Ptr clkHandle);
190 /* Function to enable a clock. */
191 Int32 ClockOps_enable(ClockOps_Handle handle, Ptr clkHandle);
192 /* Function to disable a clock */
193 Void ClockOps_disable(ClockOps_Handle handle, Ptr clkHandle);
194 /* Function to get clock speed */
195 ULong ClockOps_getRate(ClockOps_Handle handle, Ptr clkHandle);
196 /* Function to set clock speed */
197 Int32 ClockOps_setRate(ClockOps_Handle handle, Ptr clkHandle, ULong rate);
199 #if defined (__cplusplus)
200 }
201 #endif /* defined (__cplusplus) */
203 #endif /* #ifdef ClockOps_H */