1 //*****************************************************************************
2 //
3 // timer.h - Prototypes for the timer module
4 //
5 // Copyright (c) 2005-2011 Texas Instruments Incorporated.  All rights reserved.
6 // Software License Agreement
7 //
8 // Texas Instruments (TI) is supplying this software for use solely and
9 // exclusively on TI's microcontroller products. The software is owned by
10 // TI and/or its suppliers, and is protected under applicable copyright
11 // laws. You may not combine this software with "viral" open-source
12 // software in order to form a larger program.
13 //
14 // THIS SOFTWARE IS PROVIDED "AS IS" AND WITH ALL FAULTS.
15 // NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT
16 // NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
17 // A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. TI SHALL NOT, UNDER ANY
18 // CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR CONSEQUENTIAL
19 // DAMAGES, FOR ANY REASON WHATSOEVER.
20 //
21 // This is part of revision 8264 of the Stellaris Peripheral Driver Library.
22 //
23 //*****************************************************************************
24 
25 #ifndef __TIMER_H__
26 #define __TIMER_H__
27 
28 //*****************************************************************************
29 //
30 // If building with a C++ compiler, make all of the definitions in this header
31 // have a C binding.
32 //
33 //*****************************************************************************
34 #ifdef __cplusplus
35 extern "C"
36 {
37 #endif
38 
39 //*****************************************************************************
40 //
41 // Values that can be passed to TimerConfigure as the ulConfig parameter.
42 //
43 //*****************************************************************************
44 #define TIMER_CFG_ONE_SHOT       0x00000021  // Full-width one-shot timer
45 #define TIMER_CFG_ONE_SHOT_UP    0x00000031  // Full-width one-shot up-count
46                                             // timer
47 #define TIMER_CFG_PERIODIC       0x00000022  // Full-width periodic timer
48 #define TIMER_CFG_PERIODIC_UP    0x00000032  // Full-width periodic up-count
49                                             // timer
50 #define TIMER_CFG_RTC            0x01000000  // Full-width RTC timer
51 #define TIMER_CFG_SPLIT_PAIR     0x04000000  // Two half-width timers
52 #define TIMER_CFG_A_ONE_SHOT     0x00000021  // Timer A one-shot timer
53 #define TIMER_CFG_A_ONE_SHOT_UP  0x00000031  // Timer A one-shot up-count timer
54 #define TIMER_CFG_A_PERIODIC     0x00000022  // Timer A periodic timer
55 #define TIMER_CFG_A_PERIODIC_UP  0x00000032  // Timer A periodic up-count timer
56 #define TIMER_CFG_A_CAP_COUNT    0x00000003  // Timer A event counter
57 #define TIMER_CFG_A_CAP_COUNT_UP 0x00000013  // Timer A event up-counter
58 #define TIMER_CFG_A_CAP_TIME     0x00000007  // Timer A event timer
59 #define TIMER_CFG_A_CAP_TIME_UP  0x00000017  // Timer A event up-count timer
60 #define TIMER_CFG_A_PWM          0x0000000A  // Timer A PWM output
61 #define TIMER_CFG_B_ONE_SHOT     0x00002100  // Timer B one-shot timer
62 #define TIMER_CFG_B_ONE_SHOT_UP  0x00003100  // Timer B one-shot up-count timer
63 #define TIMER_CFG_B_PERIODIC     0x00002200  // Timer B periodic timer
64 #define TIMER_CFG_B_PERIODIC_UP  0x00003200  // Timer B periodic up-count timer
65 #define TIMER_CFG_B_CAP_COUNT    0x00000300  // Timer B event counter
66 #define TIMER_CFG_B_CAP_COUNT_UP 0x00001300  // Timer B event up-counter
67 #define TIMER_CFG_B_CAP_TIME     0x00000700  // Timer B event timer
68 #define TIMER_CFG_B_CAP_TIME_UP  0x00001700  // Timer B event up-count timer
69 #define TIMER_CFG_B_PWM          0x00000A00  // Timer B PWM output
70 
71 //*****************************************************************************
72 //
73 // Values that can be passed to TimerIntEnable, TimerIntDisable, and
74 // TimerIntClear as the ulIntFlags parameter, and returned from TimerIntStatus.
75 //
76 //*****************************************************************************
77 #define TIMER_TIMB_MATCH        0x00000800  // TimerB match interrupt
78 #define TIMER_CAPB_EVENT        0x00000400  // CaptureB event interrupt
79 #define TIMER_CAPB_MATCH        0x00000200  // CaptureB match interrupt
80 #define TIMER_TIMB_TIMEOUT      0x00000100  // TimerB time out interrupt
81 #define TIMER_TIMA_MATCH        0x00000010  // TimerA match interrupt
82 #define TIMER_RTC_MATCH         0x00000008  // RTC interrupt mask
83 #define TIMER_CAPA_EVENT        0x00000004  // CaptureA event interrupt
84 #define TIMER_CAPA_MATCH        0x00000002  // CaptureA match interrupt
85 #define TIMER_TIMA_TIMEOUT      0x00000001  // TimerA time out interrupt
86 
87 //*****************************************************************************
88 //
89 // Values that can be passed to TimerControlEvent as the ulEvent parameter.
90 //
91 //*****************************************************************************
92 #define TIMER_EVENT_POS_EDGE    0x00000000  // Count positive edges
93 #define TIMER_EVENT_NEG_EDGE    0x00000404  // Count negative edges
94 #define TIMER_EVENT_BOTH_EDGES  0x00000C0C  // Count both edges
95 
96 //*****************************************************************************
97 //
98 // Values that can be passed to most of the timer APIs as the ulTimer
99 // parameter.
100 //
101 //*****************************************************************************
102 #define TIMER_A                 0x000000ff  // Timer A
103 #define TIMER_B                 0x0000ff00  // Timer B
104 #define TIMER_BOTH              0x0000ffff  // Timer Both
105 
106 //*****************************************************************************
107 //
108 // Values that can be passed to TimerSynchronize as the ulTimers parameter.
109 //
110 //*****************************************************************************
111 #define TIMER_0A_SYNC           0x00000001  // Synchronize Timer 0A
112 #define TIMER_0B_SYNC           0x00000002  // Synchronize Timer 0B
113 #define TIMER_1A_SYNC           0x00000004  // Synchronize Timer 1A
114 #define TIMER_1B_SYNC           0x00000008  // Synchronize Timer 1B
115 #define TIMER_2A_SYNC           0x00000010  // Synchronize Timer 2A
116 #define TIMER_2B_SYNC           0x00000020  // Synchronize Timer 2B
117 #define TIMER_3A_SYNC           0x00000040  // Synchronize Timer 3A
118 #define TIMER_3B_SYNC           0x00000080  // Synchronize Timer 3B
119 #define TIMER_4A_SYNC           0x00000100  // Synchronize Timer 4A
120 #define TIMER_4B_SYNC           0x00000200  // Synchronize Timer 4B
121 #define TIMER_5A_SYNC           0x00000400  // Synchronize Timer 5A
122 #define TIMER_5B_SYNC           0x00000800  // Synchronize Timer 5B
123 #define WTIMER_0A_SYNC          0x00001000  // Synchronize Wide Timer 0A
124 #define WTIMER_0B_SYNC          0x00002000  // Synchronize Wide Timer 0B
125 #define WTIMER_1A_SYNC          0x00004000  // Synchronize Wide Timer 1A
126 #define WTIMER_1B_SYNC          0x00008000  // Synchronize Wide Timer 1B
127 #define WTIMER_2A_SYNC          0x00010000  // Synchronize Wide Timer 2A
128 #define WTIMER_2B_SYNC          0x00020000  // Synchronize Wide Timer 2B
129 #define WTIMER_3A_SYNC          0x00040000  // Synchronize Wide Timer 3A
130 #define WTIMER_3B_SYNC          0x00080000  // Synchronize Wide Timer 3B
131 #define WTIMER_4A_SYNC          0x00100000  // Synchronize Wide Timer 4A
132 #define WTIMER_4B_SYNC          0x00200000  // Synchronize Wide Timer 4B
133 #define WTIMER_5A_SYNC          0x00400000  // Synchronize Wide Timer 5A
134 #define WTIMER_5B_SYNC          0x00800000  // Synchronize Wide Timer 5B
135 
136 //*****************************************************************************
137 //
138 // Prototypes for the APIs.
139 //
140 //*****************************************************************************
141 extern void TimerEnable(unsigned long ulBase, unsigned long ulTimer);
142 extern void TimerDisable(unsigned long ulBase, unsigned long ulTimer);
143 extern void TimerConfigure(unsigned long ulBase, unsigned long ulConfig);
144 extern void TimerControlLevel(unsigned long ulBase, unsigned long ulTimer,
145                               tBoolean bInvert);
146 extern void TimerControlTrigger(unsigned long ulBase, unsigned long ulTimer,
147                                 tBoolean bEnable);
148 extern void TimerControlEvent(unsigned long ulBase, unsigned long ulTimer,
149                               unsigned long ulEvent);
150 extern void TimerControlStall(unsigned long ulBase, unsigned long ulTimer,
151                               tBoolean bStall);
152 extern void TimerControlWaitOnTrigger(unsigned long ulBase,
153                                       unsigned long ulTimer,
154                                       tBoolean bWait);
155 extern void TimerRTCEnable(unsigned long ulBase);
156 extern void TimerRTCDisable(unsigned long ulBase);
157 extern void TimerPrescaleSet(unsigned long ulBase, unsigned long ulTimer,
158                              unsigned long ulValue);
159 extern unsigned long TimerPrescaleGet(unsigned long ulBase,
160                                       unsigned long ulTimer);
161 extern void TimerPrescaleMatchSet(unsigned long ulBase, unsigned long ulTimer,
162                                   unsigned long ulValue);
163 extern unsigned long TimerPrescaleMatchGet(unsigned long ulBase,
164                                            unsigned long ulTimer);
165 extern void TimerLoadSet(unsigned long ulBase, unsigned long ulTimer,
166                          unsigned long ulValue);
167 extern unsigned long TimerLoadGet(unsigned long ulBase, unsigned long ulTimer);
168 extern void TimerLoadSet64(unsigned long ulBase, unsigned long long ullValue);
169 extern unsigned long long TimerLoadGet64(unsigned long ulBase);
170 extern unsigned long TimerValueGet(unsigned long ulBase,
171                                    unsigned long ulTimer);
172 extern unsigned long long TimerValueGet64(unsigned long ulBase);
173 extern void TimerMatchSet(unsigned long ulBase, unsigned long ulTimer,
174                           unsigned long ulValue);
175 extern unsigned long TimerMatchGet(unsigned long ulBase,
176                                    unsigned long ulTimer);
177 extern void TimerMatchSet64(unsigned long ulBase, unsigned long long ullValue);
178 extern unsigned long long TimerMatchGet64(unsigned long ulBase);
179 extern void TimerIntRegister(unsigned long ulBase, unsigned long ulTimer,
180                              void (*pfnHandler)(void));
181 extern void TimerIntUnregister(unsigned long ulBase, unsigned long ulTimer);
182 extern void TimerIntEnable(unsigned long ulBase, unsigned long ulIntFlags);
183 extern void TimerIntDisable(unsigned long ulBase, unsigned long ulIntFlags);
184 extern unsigned long TimerIntStatus(unsigned long ulBase, tBoolean bMasked);
185 extern void TimerIntClear(unsigned long ulBase, unsigned long ulIntFlags);
186 extern void TimerSynchronize(unsigned long ulBase, unsigned long ulTimers);
187 
188 //*****************************************************************************
189 //
190 // TimerQuiesce() has been deprecated.  SysCtlPeripheralReset() should be used
191 // instead to return the timer to its reset state.
192 //
193 //*****************************************************************************
194 #ifndef DEPRECATED
195 extern void TimerQuiesce(unsigned long ulBase);
196 #endif
197 
198 //*****************************************************************************
199 //
200 // These values for TimerConfigure have been deprecated.
201 //
202 //*****************************************************************************
203 #ifndef DEPRECATED
204 #define TIMER_CFG_32_BIT_OS      0x00000021  // 32-bit one-shot timer
205 #define TIMER_CFG_32_BIT_OS_UP   0x00000031  // 32-bit one-shot up-count timer
206 #define TIMER_CFG_32_BIT_PER     0x00000022  // 32-bit periodic timer
207 #define TIMER_CFG_32_BIT_PER_UP  0x00000032  // 32-bit periodic up-count timer
208 #define TIMER_CFG_32_RTC         0x01000000  // 32-bit RTC timer
209 #define TIMER_CFG_16_BIT_PAIR    0x04000000  // Two 16-bit timers
210 #endif
211 
212 //*****************************************************************************
213 //
214 // Mark the end of the C bindings section for C++ compilers.
215 //
216 //*****************************************************************************
217 #ifdef __cplusplus
218 }
219 #endif
220 
221 #endif // __TIMER_H__
222