CC3200 Peripheral Driver Library User's Guide  1.2.0
timer.h
1 //*****************************************************************************
2 //
3 // timer.h
4 //
5 // Prototypes for the timer module
6 //
7 // Copyright (C) 2014 Texas Instruments Incorporated - https://www.ti.com/
8 //
9 //
10 // Redistribution and use in source and binary forms, with or without
11 // modification, are permitted provided that the following conditions
12 // are met:
13 //
14 // Redistributions of source code must retain the above copyright
15 // notice, this list of conditions and the following disclaimer.
16 //
17 // Redistributions in binary form must reproduce the above copyright
18 // notice, this list of conditions and the following disclaimer in the
19 // documentation and/or other materials provided with the
20 // distribution.
21 //
22 // Neither the name of Texas Instruments Incorporated nor the names of
23 // its contributors may be used to endorse or promote products derived
24 // from this software without specific prior written permission.
25 //
26 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
27 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
28 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
29 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
30 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
31 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
32 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
33 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
34 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
35 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
36 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37 //
38 //*****************************************************************************
39 
40 #ifndef __TIMER_H__
41 #define __TIMER_H__
42 
43 //*****************************************************************************
44 //
45 // If building with a C++ compiler, make all of the definitions in this header
46 // have a C binding.
47 //
48 //*****************************************************************************
49 #ifdef __cplusplus
50 extern "C"
51 {
52 #endif
53 
54 //*****************************************************************************
55 //
56 // Values that can be passed to TimerConfigure as the ulConfig parameter.
57 //
58 //*****************************************************************************
59 
60 #define TIMER_CFG_ONE_SHOT 0x00000021 // Full-width one-shot timer
61 #define TIMER_CFG_ONE_SHOT_UP 0x00000031 // Full-width one-shot up-count
62  // timer
63 #define TIMER_CFG_PERIODIC 0x00000022 // Full-width periodic timer
64 #define TIMER_CFG_PERIODIC_UP 0x00000032 // Full-width periodic up-count
65  // timer
66 #define TIMER_CFG_SPLIT_PAIR 0x04000000 // Two half-width timers
67 
68 #define TIMER_CFG_A_ONE_SHOT 0x00000021 // Timer A one-shot timer
69 #define TIMER_CFG_A_ONE_SHOT_UP 0x00000031 // Timer A one-shot up-count timer
70 #define TIMER_CFG_A_PERIODIC 0x00000022 // Timer A periodic timer
71 #define TIMER_CFG_A_PERIODIC_UP 0x00000032 // Timer A periodic up-count timer
72 #define TIMER_CFG_A_CAP_COUNT 0x00000003 // Timer A event counter
73 #define TIMER_CFG_A_CAP_COUNT_UP 0x00000013 // Timer A event up-counter
74 #define TIMER_CFG_A_CAP_TIME 0x00000007 // Timer A event timer
75 #define TIMER_CFG_A_CAP_TIME_UP 0x00000017 // Timer A event up-count timer
76 #define TIMER_CFG_A_PWM 0x0000000A // Timer A PWM output
77 #define TIMER_CFG_B_ONE_SHOT 0x00002100 // Timer B one-shot timer
78 #define TIMER_CFG_B_ONE_SHOT_UP 0x00003100 // Timer B one-shot up-count timer
79 #define TIMER_CFG_B_PERIODIC 0x00002200 // Timer B periodic timer
80 #define TIMER_CFG_B_PERIODIC_UP 0x00003200 // Timer B periodic up-count timer
81 #define TIMER_CFG_B_CAP_COUNT 0x00000300 // Timer B event counter
82 #define TIMER_CFG_B_CAP_COUNT_UP 0x00001300 // Timer B event up-counter
83 #define TIMER_CFG_B_CAP_TIME 0x00000700 // Timer B event timer
84 #define TIMER_CFG_B_CAP_TIME_UP 0x00001700 // Timer B event up-count timer
85 #define TIMER_CFG_B_PWM 0x00000A00 // Timer B PWM output
86 
87 //*****************************************************************************
88 //
89 // Values that can be passed to TimerIntEnable, TimerIntDisable, and
90 // TimerIntClear as the ulIntFlags parameter, and returned from TimerIntStatus.
91 //
92 //*****************************************************************************
93 
94 #define TIMER_TIMB_DMA 0x00002000 // TimerB DMA Done interrupt
95 #define TIMER_TIMB_MATCH 0x00000800 // TimerB match interrupt
96 #define TIMER_CAPB_EVENT 0x00000400 // CaptureB event interrupt
97 #define TIMER_CAPB_MATCH 0x00000200 // CaptureB match interrupt
98 #define TIMER_TIMB_TIMEOUT 0x00000100 // TimerB time out interrupt
99 #define TIMER_TIMA_DMA 0x00000020 // TimerA DMA Done interrupt
100 #define TIMER_TIMA_MATCH 0x00000010 // TimerA match interrupt
101 #define TIMER_CAPA_EVENT 0x00000004 // CaptureA event interrupt
102 #define TIMER_CAPA_MATCH 0x00000002 // CaptureA match interrupt
103 #define TIMER_TIMA_TIMEOUT 0x00000001 // TimerA time out interrupt
104 
105 //*****************************************************************************
106 //
107 // Values that can be passed to TimerControlEvent as the ulEvent parameter.
108 //
109 //*****************************************************************************
110 #define TIMER_EVENT_POS_EDGE 0x00000000 // Count positive edges
111 #define TIMER_EVENT_NEG_EDGE 0x00000404 // Count negative edges
112 #define TIMER_EVENT_BOTH_EDGES 0x00000C0C // Count both edges
113 
114 //*****************************************************************************
115 //
116 // Values that can be passed to most of the timer APIs as the ulTimer
117 // parameter.
118 //
119 //*****************************************************************************
120 #define TIMER_A 0x000000ff // Timer A
121 #define TIMER_B 0x0000ff00 // Timer B
122 #define TIMER_BOTH 0x0000ffff // Timer Both
123 
124 
125 //*****************************************************************************
126 //
127 // Values that can be passed to TimerSynchronize as the ulTimers parameter.
128 //
129 //*****************************************************************************
130 #define TIMER_0A_SYNC 0x00000001 // Synchronize Timer 0A
131 #define TIMER_0B_SYNC 0x00000002 // Synchronize Timer 0B
132 #define TIMER_1A_SYNC 0x00000004 // Synchronize Timer 1A
133 #define TIMER_1B_SYNC 0x00000008 // Synchronize Timer 1B
134 #define TIMER_2A_SYNC 0x00000010 // Synchronize Timer 2A
135 #define TIMER_2B_SYNC 0x00000020 // Synchronize Timer 2B
136 #define TIMER_3A_SYNC 0x00000040 // Synchronize Timer 3A
137 #define TIMER_3B_SYNC 0x00000080 // Synchronize Timer 3B
138 
139 //*****************************************************************************
140 //
141 // Values that can be passed to TimerDMAEventSet() or returned from
142 // TimerDMAEventGet().
143 //
144 //*****************************************************************************
145 #define TIMER_DMA_MODEMATCH_B 0x00000800
146 #define TIMER_DMA_CAPEVENT_B 0x00000400
147 #define TIMER_DMA_CAPMATCH_B 0x00000200
148 #define TIMER_DMA_TIMEOUT_B 0x00000100
149 #define TIMER_DMA_MODEMATCH_A 0x00000010
150 #define TIMER_DMA_CAPEVENT_A 0x00000004
151 #define TIMER_DMA_CAPMATCH_A 0x00000002
152 #define TIMER_DMA_TIMEOUT_A 0x00000001
153 
154 
155 //*****************************************************************************
156 //
157 // Prototypes for the APIs.
158 //
159 //*****************************************************************************
160 extern void TimerEnable(unsigned long ulBase, unsigned long ulTimer);
161 extern void TimerDisable(unsigned long ulBase, unsigned long ulTimer);
162 extern void TimerConfigure(unsigned long ulBase, unsigned long ulConfig);
163 extern void TimerControlLevel(unsigned long ulBase, unsigned long ulTimer,
164  tBoolean bInvert);
165 extern void TimerControlEvent(unsigned long ulBase, unsigned long ulTimer,
166  unsigned long ulEvent);
167 extern void TimerControlStall(unsigned long ulBase, unsigned long ulTimer,
168  tBoolean bStall);
169 extern void TimerPrescaleSet(unsigned long ulBase, unsigned long ulTimer,
170  unsigned long ulValue);
171 extern unsigned long TimerPrescaleGet(unsigned long ulBase,
172  unsigned long ulTimer);
173 extern void TimerPrescaleMatchSet(unsigned long ulBase, unsigned long ulTimer,
174  unsigned long ulValue);
175 extern unsigned long TimerPrescaleMatchGet(unsigned long ulBase,
176  unsigned long ulTimer);
177 extern void TimerLoadSet(unsigned long ulBase, unsigned long ulTimer,
178  unsigned long ulValue);
179 extern unsigned long TimerLoadGet(unsigned long ulBase, unsigned long ulTimer);
180 
181 extern unsigned long TimerValueGet(unsigned long ulBase,
182  unsigned long ulTimer);
183 extern void TimerValueSet(unsigned long ulBase, unsigned long ulTimer,
184  unsigned long ulValue);
185 
186 extern void TimerMatchSet(unsigned long ulBase, unsigned long ulTimer,
187  unsigned long ulValue);
188 extern unsigned long TimerMatchGet(unsigned long ulBase,
189  unsigned long ulTimer);
190 extern void TimerIntRegister(unsigned long ulBase, unsigned long ulTimer,
191  void (*pfnHandler)(void));
192 extern void TimerIntUnregister(unsigned long ulBase, unsigned long ulTimer);
193 extern void TimerIntEnable(unsigned long ulBase, unsigned long ulIntFlags);
194 extern void TimerIntDisable(unsigned long ulBase, unsigned long ulIntFlags);
195 extern unsigned long TimerIntStatus(unsigned long ulBase, tBoolean bMasked);
196 extern void TimerIntClear(unsigned long ulBase, unsigned long ulIntFlags);
197 extern void TimerDMAEventSet(unsigned long ulBase, unsigned long ulDMAEvent);
198 extern unsigned long TimerDMAEventGet(unsigned long ulBase);
199 
200 
201 //*****************************************************************************
202 //
203 // Mark the end of the C bindings section for C++ compilers.
204 //
205 //*****************************************************************************
206 #ifdef __cplusplus
207 }
208 #endif
209 
210 #endif // __TIMER_H__
unsigned long TimerMatchGet(unsigned long ulBase, unsigned long ulTimer)
Definition: timer.c:716
unsigned long TimerPrescaleMatchGet(unsigned long ulBase, unsigned long ulTimer)
Definition: timer.c:490
void TimerIntClear(unsigned long ulBase, unsigned long ulIntFlags)
Definition: timer.c:1001
void TimerDisable(unsigned long ulBase, unsigned long ulTimer)
Definition: timer.c:122
void TimerControlEvent(unsigned long ulBase, unsigned long ulTimer, unsigned long ulEvent)
Definition: timer.c:284
void TimerPrescaleSet(unsigned long ulBase, unsigned long ulTimer, unsigned long ulValue)
Definition: timer.c:358
void TimerConfigure(unsigned long ulBase, unsigned long ulConfig)
Definition: timer.c:184
void TimerIntEnable(unsigned long ulBase, unsigned long ulIntFlags)
Definition: timer.c:898
void TimerIntUnregister(unsigned long ulBase, unsigned long ulTimer)
Definition: timer.c:821
void TimerIntDisable(unsigned long ulBase, unsigned long ulIntFlags)
Definition: timer.c:929
void TimerLoadSet(unsigned long ulBase, unsigned long ulTimer, unsigned long ulValue)
Definition: timer.c:526
void TimerControlLevel(unsigned long ulBase, unsigned long ulTimer, tBoolean bInvert)
Definition: timer.c:247
void TimerPrescaleMatchSet(unsigned long ulBase, unsigned long ulTimer, unsigned long ulValue)
Definition: timer.c:442
void TimerControlStall(unsigned long ulBase, unsigned long ulTimer, tBoolean bStall)
Definition: timer.c:321
unsigned long TimerIntStatus(unsigned long ulBase, tBoolean bMasked)
Definition: timer.c:959
unsigned long TimerLoadGet(unsigned long ulBase, unsigned long ulTimer)
Definition: timer.c:572
unsigned long TimerValueGet(unsigned long ulBase, unsigned long ulTimer)
Definition: timer.c:602
void TimerDMAEventSet(unsigned long ulBase, unsigned long ulDMAEvent)
Definition: timer.c:1044
unsigned long TimerPrescaleGet(unsigned long ulBase, unsigned long ulTimer)
Definition: timer.c:404
void TimerMatchSet(unsigned long ulBase, unsigned long ulTimer, unsigned long ulValue)
Definition: timer.c:674
void TimerEnable(unsigned long ulBase, unsigned long ulTimer)
Definition: timer.c:93
void TimerIntRegister(unsigned long ulBase, unsigned long ulTimer, void(*pfnHandler)(void))
Definition: timer.c:755
unsigned long TimerDMAEventGet(unsigned long ulBase)
Definition: timer.c:1086
void TimerValueSet(unsigned long ulBase, unsigned long ulTimer, unsigned long ulValue)
Definition: timer.c:633