1 //*****************************************************************************
2 //
3 //! @file am_hal_timer.h
4 //!
5 //! @brief Functions for interfacing with the timer (TIMER).
6 //!
7 //! @addtogroup timer_4p Timer Functionality
8 //! @ingroup apollo4p_hal
9 //! @{
10 //
11 //*****************************************************************************
12 
13 //*****************************************************************************
14 //
15 // Copyright (c) 2023, Ambiq Micro, Inc.
16 // All rights reserved.
17 //
18 // Redistribution and use in source and binary forms, with or without
19 // modification, are permitted provided that the following conditions are met:
20 //
21 // 1. Redistributions of source code must retain the above copyright notice,
22 // this list of conditions and the following disclaimer.
23 //
24 // 2. Redistributions in binary form must reproduce the above copyright
25 // notice, this list of conditions and the following disclaimer in the
26 // documentation and/or other materials provided with the distribution.
27 //
28 // 3. Neither the name of the copyright holder nor the names of its
29 // contributors may be used to endorse or promote products derived from this
30 // software without specific prior written permission.
31 //
32 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
33 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
34 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
35 // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
36 // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
37 // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
38 // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
39 // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
40 // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
41 // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
42 // POSSIBILITY OF SUCH DAMAGE.
43 //
44 // This is part of revision release_sdk_4_4_0-3c5977e664 of the AmbiqSuite Development Package.
45 //
46 //*****************************************************************************
47 #ifndef AM_HAL_TIMER_H
48 #define AM_HAL_TIMER_H
49 
50 #ifdef __cplusplus
51 extern "C"
52 {
53 #endif
54 
55 #undef AM_REG_NUM_TIMERS
56 #define AM_REG_NUM_TIMERS       16
57 
58 //*****************************************************************************
59 //
60 // CMSIS-style macro for handling a variable TIMER module number.
61 //
62 //*****************************************************************************
63 #define AM_HAL_TIMER_OFFSET (&TIMER->CTRL1 - &TIMER->CTRL0)
64 #define TIMERn(n)   ((TIMER_Type*)(TIMER_BASE + (n * 4 * AM_HAL_TIMER_OFFSET)))
65 #define AM_HAL_TIMER_GLOBEN_DEFAULT     0x0000FFFF
66 #define AM_HAL_TIMER_MASK(timer, compare) (compare << (2 * timer))
67 
68 //*****************************************************************************
69 //
70 //! Timer selection enum
71 //
72 //*****************************************************************************
73 typedef enum
74 {
75     AM_HAL_TIMER_TMR0  = TIMER_GLOBEN_ENB0_Msk,
76     AM_HAL_TIMER_TMR1  = TIMER_GLOBEN_ENB1_Msk,
77     AM_HAL_TIMER_TMR2  = TIMER_GLOBEN_ENB2_Msk,
78     AM_HAL_TIMER_TMR3  = TIMER_GLOBEN_ENB3_Msk,
79     AM_HAL_TIMER_TMR4  = TIMER_GLOBEN_ENB4_Msk,
80     AM_HAL_TIMER_TMR5  = TIMER_GLOBEN_ENB5_Msk,
81     AM_HAL_TIMER_TMR6  = TIMER_GLOBEN_ENB6_Msk,
82     AM_HAL_TIMER_TMR7  = TIMER_GLOBEN_ENB7_Msk,
83     AM_HAL_TIMER_TMR8  = TIMER_GLOBEN_ENB8_Msk,
84     AM_HAL_TIMER_TMR9  = TIMER_GLOBEN_ENB9_Msk,
85     AM_HAL_TIMER_TMR10 = TIMER_GLOBEN_ENB10_Msk,
86     AM_HAL_TIMER_TMR11 = TIMER_GLOBEN_ENB11_Msk,
87     AM_HAL_TIMER_TMR12 = TIMER_GLOBEN_ENB12_Msk,
88     AM_HAL_TIMER_TMR13 = TIMER_GLOBEN_ENB13_Msk,
89     AM_HAL_TIMER_TMR14 = TIMER_GLOBEN_ENB14_Msk,
90     AM_HAL_TIMER_TMR15 = TIMER_GLOBEN_ENB15_Msk,
91 }
92 am_hal_timer_select_e;
93 
94 //*****************************************************************************
95 //
96 //! TIMER configuration enum
97 //
98 //*****************************************************************************
99 typedef enum
100 {
101     AM_HAL_TIMER_CLOCK_HFRC_DIV4    = TIMER_CTRL0_TMR0CLK_HFRC_DIV4,
102     AM_HAL_TIMER_CLOCK_HFRC_DIV16   = TIMER_CTRL0_TMR0CLK_HFRC_DIV16,
103     AM_HAL_TIMER_CLOCK_HFRC_DIV64   = TIMER_CTRL0_TMR0CLK_HFRC_DIV64,
104     AM_HAL_TIMER_CLOCK_HFRC_DIV256  = TIMER_CTRL0_TMR0CLK_HFRC_DIV256,
105     AM_HAL_TIMER_CLOCK_HFRC_DIV1024 = TIMER_CTRL0_TMR0CLK_HFRC_DIV1024,
106     AM_HAL_TIMER_CLOCK_HFRC_DIV4K   = TIMER_CTRL0_TMR0CLK_HFRC_DIV4K,
107     AM_HAL_TIMER_CLOCK_LFRC         = TIMER_CTRL0_TMR0CLK_LFRC,
108     AM_HAL_TIMER_CLOCK_LFRC_DIV2    = TIMER_CTRL0_TMR0CLK_LFRC_DIV2,
109     AM_HAL_TIMER_CLOCK_LFRC_DIV32   = TIMER_CTRL0_TMR0CLK_LFRC_DIV32,
110     AM_HAL_TIMER_CLOCK_LFRC_DIV1K   = TIMER_CTRL0_TMR0CLK_LFRC_DIV1K,
111     AM_HAL_TIMER_CLOCK_XT           = TIMER_CTRL0_TMR0CLK_XT,
112     AM_HAL_TIMER_CLOCK_XT_DIV2      = TIMER_CTRL0_TMR0CLK_XT_DIV2,
113     AM_HAL_TIMER_CLOCK_XT_DIV4      = TIMER_CTRL0_TMR0CLK_XT_DIV4,
114     AM_HAL_TIMER_CLOCK_XT_DIV8      = TIMER_CTRL0_TMR0CLK_XT_DIV8,
115     AM_HAL_TIMER_CLOCK_XT_DIV16     = TIMER_CTRL0_TMR0CLK_XT_DIV16,
116     AM_HAL_TIMER_CLOCK_XT_DIV32     = TIMER_CTRL0_TMR0CLK_XT_DIV32,
117     AM_HAL_TIMER_CLOCK_XT_DIV128    = TIMER_CTRL0_TMR0CLK_XT_DIV128,
118     AM_HAL_TIMER_CLOCK_RTC_100HZ    = TIMER_CTRL0_TMR0CLK_RTC_100HZ,
119     AM_HAL_TIMER_CLOCK_BUCKC        = TIMER_CTRL0_TMR0CLK_BUCKC,
120     AM_HAL_TIMER_CLOCK_BUCKF        = TIMER_CTRL0_TMR0CLK_BUCKF,
121     AM_HAL_TIMER_CLOCK_BUCKS        = TIMER_CTRL0_TMR0CLK_BUCKS,
122     AM_HAL_TIMER_CLOCK_BUCKC_LV     = TIMER_CTRL0_TMR0CLK_BUCKC_LV,
123     AM_HAL_TIMER_CLOCK_TMR0_OUT0    = TIMER_CTRL0_TMR0CLK_TMR00,
124     AM_HAL_TIMER_CLOCK_TMR0_OUT1    = TIMER_CTRL0_TMR0CLK_TMR01,
125     AM_HAL_TIMER_CLOCK_TMR1_OUT0    = TIMER_CTRL0_TMR0CLK_TMR10,
126     AM_HAL_TIMER_CLOCK_TMR1_OUT1    = TIMER_CTRL0_TMR0CLK_TMR11,
127     AM_HAL_TIMER_CLOCK_TMR2_OUT0    = TIMER_CTRL0_TMR0CLK_TMR20,
128     AM_HAL_TIMER_CLOCK_TMR2_OUT1    = TIMER_CTRL0_TMR0CLK_TMR21,
129     AM_HAL_TIMER_CLOCK_TMR3_OUT0    = TIMER_CTRL0_TMR0CLK_TMR30,
130     AM_HAL_TIMER_CLOCK_TMR3_OUT1    = TIMER_CTRL0_TMR0CLK_TMR31,
131     AM_HAL_TIMER_CLOCK_TMR4_OUT0    = TIMER_CTRL0_TMR0CLK_TMR40,
132     AM_HAL_TIMER_CLOCK_TMR4_OUT1    = TIMER_CTRL0_TMR0CLK_TMR41,
133     AM_HAL_TIMER_CLOCK_TMR5_OUT0    = TIMER_CTRL0_TMR0CLK_TMR50,
134     AM_HAL_TIMER_CLOCK_TMR5_OUT1    = TIMER_CTRL0_TMR0CLK_TMR51,
135     AM_HAL_TIMER_CLOCK_TMR6_OUT0    = TIMER_CTRL0_TMR0CLK_TMR60,
136     AM_HAL_TIMER_CLOCK_TMR6_OUT1    = TIMER_CTRL0_TMR0CLK_TMR61,
137     AM_HAL_TIMER_CLOCK_TMR7_OUT0    = TIMER_CTRL0_TMR0CLK_TMR70,
138     AM_HAL_TIMER_CLOCK_TMR7_OUT1    = TIMER_CTRL0_TMR0CLK_TMR71,
139     AM_HAL_TIMER_CLOCK_TMR8_OUT0    = TIMER_CTRL0_TMR0CLK_TMR80,
140     AM_HAL_TIMER_CLOCK_TMR8_OUT1    = TIMER_CTRL0_TMR0CLK_TMR81,
141     AM_HAL_TIMER_CLOCK_TMR9_OUT0    = TIMER_CTRL0_TMR0CLK_TMR90,
142     AM_HAL_TIMER_CLOCK_TMR9_OUT1    = TIMER_CTRL0_TMR0CLK_TMR91,
143     AM_HAL_TIMER_CLOCK_TMR10_OUT0   = TIMER_CTRL0_TMR0CLK_TMR100,
144     AM_HAL_TIMER_CLOCK_TMR10_OUT1   = TIMER_CTRL0_TMR0CLK_TMR101,
145     AM_HAL_TIMER_CLOCK_TMR11_OUT0   = TIMER_CTRL0_TMR0CLK_TMR110,
146     AM_HAL_TIMER_CLOCK_TMR11_OUT1   = TIMER_CTRL0_TMR0CLK_TMR111,
147     AM_HAL_TIMER_CLOCK_TMR12_OUT0   = TIMER_CTRL0_TMR0CLK_TMR120,
148     AM_HAL_TIMER_CLOCK_TMR12_OUT1   = TIMER_CTRL0_TMR0CLK_TMR121,
149     AM_HAL_TIMER_CLOCK_TMR13_OUT0   = TIMER_CTRL0_TMR0CLK_TMR130,
150     AM_HAL_TIMER_CLOCK_TMR13_OUT1   = TIMER_CTRL0_TMR0CLK_TMR131,
151     AM_HAL_TIMER_CLOCK_TMR14_OUT0   = TIMER_CTRL0_TMR0CLK_TMR140,
152     AM_HAL_TIMER_CLOCK_TMR14_OUT1   = TIMER_CTRL0_TMR0CLK_TMR140,
153     AM_HAL_TIMER_CLOCK_TMR15_OUT0   = TIMER_CTRL0_TMR0CLK_TMR150,
154     AM_HAL_TIMER_CLOCK_TMR15_OUT1   = TIMER_CTRL0_TMR0CLK_TMR151,
155     AM_HAL_TIMER_CLOCK_GPIO0        = TIMER_CTRL0_TMR0CLK_GPIO0,
156     AM_HAL_TIMER_CLOCK_GPIO1,
157     AM_HAL_TIMER_CLOCK_GPIO2,
158     AM_HAL_TIMER_CLOCK_GPIO3,
159     AM_HAL_TIMER_CLOCK_GPIO4,
160     AM_HAL_TIMER_CLOCK_GPIO5,
161     AM_HAL_TIMER_CLOCK_GPIO6,
162     AM_HAL_TIMER_CLOCK_GPIO7,
163     AM_HAL_TIMER_CLOCK_GPIO8,
164     AM_HAL_TIMER_CLOCK_GPIO9,
165     AM_HAL_TIMER_CLOCK_GPIO10,
166     AM_HAL_TIMER_CLOCK_GPIO11,
167     AM_HAL_TIMER_CLOCK_GPIO12,
168     AM_HAL_TIMER_CLOCK_GPIO13,
169     AM_HAL_TIMER_CLOCK_GPIO14,
170     AM_HAL_TIMER_CLOCK_GPIO15,
171     AM_HAL_TIMER_CLOCK_GPIO16,
172     AM_HAL_TIMER_CLOCK_GPIO17,
173     AM_HAL_TIMER_CLOCK_GPIO18,
174     AM_HAL_TIMER_CLOCK_GPIO19,
175     AM_HAL_TIMER_CLOCK_GPIO20,
176     AM_HAL_TIMER_CLOCK_GPIO21,
177     AM_HAL_TIMER_CLOCK_GPIO22,
178     AM_HAL_TIMER_CLOCK_GPIO23,
179     AM_HAL_TIMER_CLOCK_GPIO24,
180     AM_HAL_TIMER_CLOCK_GPIO25,
181     AM_HAL_TIMER_CLOCK_GPIO26,
182     AM_HAL_TIMER_CLOCK_GPIO27,
183     AM_HAL_TIMER_CLOCK_GPIO28,
184     AM_HAL_TIMER_CLOCK_GPIO29,
185     AM_HAL_TIMER_CLOCK_GPIO30,
186     AM_HAL_TIMER_CLOCK_GPIO31,
187     AM_HAL_TIMER_CLOCK_GPIO32,
188     AM_HAL_TIMER_CLOCK_GPIO33,
189     AM_HAL_TIMER_CLOCK_GPIO34,
190     AM_HAL_TIMER_CLOCK_GPIO35,
191     AM_HAL_TIMER_CLOCK_GPIO36,
192     AM_HAL_TIMER_CLOCK_GPIO37,
193     AM_HAL_TIMER_CLOCK_GPIO38,
194     AM_HAL_TIMER_CLOCK_GPIO39,
195     AM_HAL_TIMER_CLOCK_GPIO40,
196     AM_HAL_TIMER_CLOCK_GPIO41,
197     AM_HAL_TIMER_CLOCK_GPIO42,
198     AM_HAL_TIMER_CLOCK_GPIO43,
199     AM_HAL_TIMER_CLOCK_GPIO44,
200     AM_HAL_TIMER_CLOCK_GPIO45,
201     AM_HAL_TIMER_CLOCK_GPIO46,
202     AM_HAL_TIMER_CLOCK_GPIO47,
203     AM_HAL_TIMER_CLOCK_GPIO48,
204     AM_HAL_TIMER_CLOCK_GPIO49,
205     AM_HAL_TIMER_CLOCK_GPIO50,
206     AM_HAL_TIMER_CLOCK_GPIO51,
207     AM_HAL_TIMER_CLOCK_GPIO52,
208     AM_HAL_TIMER_CLOCK_GPIO53,
209     AM_HAL_TIMER_CLOCK_GPIO54,
210     AM_HAL_TIMER_CLOCK_GPIO55,
211     AM_HAL_TIMER_CLOCK_GPIO56,
212     AM_HAL_TIMER_CLOCK_GPIO57,
213     AM_HAL_TIMER_CLOCK_GPIO58,
214     AM_HAL_TIMER_CLOCK_GPIO59,
215     AM_HAL_TIMER_CLOCK_GPIO60,
216     AM_HAL_TIMER_CLOCK_GPIO61,
217     AM_HAL_TIMER_CLOCK_GPIO62,
218     AM_HAL_TIMER_CLOCK_GPIO63,
219     AM_HAL_TIMER_CLOCK_GPIO64,
220     AM_HAL_TIMER_CLOCK_GPIO65,
221     AM_HAL_TIMER_CLOCK_GPIO66,
222     AM_HAL_TIMER_CLOCK_GPIO67,
223     AM_HAL_TIMER_CLOCK_GPIO68,
224     AM_HAL_TIMER_CLOCK_GPIO69,
225     AM_HAL_TIMER_CLOCK_GPIO70,
226     AM_HAL_TIMER_CLOCK_GPIO71,
227     AM_HAL_TIMER_CLOCK_GPIO72,
228     AM_HAL_TIMER_CLOCK_GPIO73,
229     AM_HAL_TIMER_CLOCK_GPIO74,
230     AM_HAL_TIMER_CLOCK_GPIO75,
231     AM_HAL_TIMER_CLOCK_GPIO76,
232     AM_HAL_TIMER_CLOCK_GPIO77,
233     AM_HAL_TIMER_CLOCK_GPIO78,
234     AM_HAL_TIMER_CLOCK_GPIO79,
235     AM_HAL_TIMER_CLOCK_GPIO80,
236     AM_HAL_TIMER_CLOCK_GPIO81,
237     AM_HAL_TIMER_CLOCK_GPIO82,
238     AM_HAL_TIMER_CLOCK_GPIO83,
239     AM_HAL_TIMER_CLOCK_GPIO84,
240     AM_HAL_TIMER_CLOCK_GPIO85,
241     AM_HAL_TIMER_CLOCK_GPIO86,
242     AM_HAL_TIMER_CLOCK_GPIO87,
243     AM_HAL_TIMER_CLOCK_GPIO88,
244     AM_HAL_TIMER_CLOCK_GPIO89,
245     AM_HAL_TIMER_CLOCK_GPIO90,
246     AM_HAL_TIMER_CLOCK_GPIO91,
247     AM_HAL_TIMER_CLOCK_GPIO92,
248     AM_HAL_TIMER_CLOCK_GPIO93,
249     AM_HAL_TIMER_CLOCK_GPIO94,
250     AM_HAL_TIMER_CLOCK_GPIO95,
251     AM_HAL_TIMER_CLOCK_GPIO96,
252     AM_HAL_TIMER_CLOCK_GPIO97,
253     AM_HAL_TIMER_CLOCK_GPIO98,
254     AM_HAL_TIMER_CLOCK_GPIO99,
255     AM_HAL_TIMER_CLOCK_GPIO100,
256     AM_HAL_TIMER_CLOCK_GPIO101,
257     AM_HAL_TIMER_CLOCK_GPIO102,
258     AM_HAL_TIMER_CLOCK_GPIO103,
259     AM_HAL_TIMER_CLOCK_GPIO104,
260     AM_HAL_TIMER_CLOCK_GPIO105,
261     AM_HAL_TIMER_CLOCK_GPIO106,
262     AM_HAL_TIMER_CLOCK_GPIO107,
263     AM_HAL_TIMER_CLOCK_GPIO108,
264     AM_HAL_TIMER_CLOCK_GPIO109,
265     AM_HAL_TIMER_CLOCK_GPIO110,
266     AM_HAL_TIMER_CLOCK_GPIO111,
267     AM_HAL_TIMER_CLOCK_GPIO112,
268     AM_HAL_TIMER_CLOCK_GPIO113,
269     AM_HAL_TIMER_CLOCK_GPIO114,
270     AM_HAL_TIMER_CLOCK_GPIO115,
271     AM_HAL_TIMER_CLOCK_GPIO116,
272     AM_HAL_TIMER_CLOCK_GPIO117,
273     AM_HAL_TIMER_CLOCK_GPIO118,
274     AM_HAL_TIMER_CLOCK_GPIO119,
275     AM_HAL_TIMER_CLOCK_GPIO120,
276     AM_HAL_TIMER_CLOCK_GPIO121,
277     AM_HAL_TIMER_CLOCK_GPIO122,
278     AM_HAL_TIMER_CLOCK_GPIO123,
279     AM_HAL_TIMER_CLOCK_GPIO124,
280     AM_HAL_TIMER_CLOCK_GPIO125,
281     AM_HAL_TIMER_CLOCK_GPIO126,
282     AM_HAL_TIMER_CLOCK_GPIO127     = TIMER_CTRL0_TMR0CLK_GPIO127,
283 
284 }
285 am_hal_timer_clock_e;
286 
287 //*****************************************************************************
288 //
289 //! TIMER Function
290 //
291 //*****************************************************************************
292 typedef enum
293 {
294     AM_HAL_TIMER_FN_EDGE            = TIMER_CTRL0_TMR0FN_EDGE,
295     AM_HAL_TIMER_FN_UPCOUNT         = TIMER_CTRL0_TMR0FN_UPCOUNT,
296     AM_HAL_TIMER_FN_PWM             = TIMER_CTRL0_TMR0FN_PWM,
297     AM_HAL_TIMER_FN_SINGLEPATTERN   = TIMER_CTRL0_TMR0FN_SINGLEPATTERN,
298     AM_HAL_TIMER_FN_REPEATPATTERN   = TIMER_CTRL0_TMR0FN_REPEATPATTERN,
299 }
300 am_hal_timer_function_e;
301 
302 //*****************************************************************************
303 //
304 //! TIMER Compare Selection
305 //
306 //*****************************************************************************
307 typedef enum
308 {
309     AM_HAL_TIMER_COMPARE0 = 1,
310     AM_HAL_TIMER_COMPARE1 = 2,
311     AM_HAL_TIMER_COMPARE_BOTH = 3
312 }
313 am_hal_timer_compare_e;
314 
315 //*****************************************************************************
316 //
317 //! TIMER Trigger Type
318 //
319 //*****************************************************************************
320 typedef enum
321 {
322     AM_HAL_TIMER_TRIGGER_DIS  = TIMER_CTRL0_TMR0TMODE_DIS,
323     AM_HAL_TIMER_TRIGGER_RISE = TIMER_CTRL0_TMR0TMODE_RISE,
324     AM_HAL_TIMER_TRIGGER_FALL = TIMER_CTRL0_TMR0TMODE_FALL,
325     AM_HAL_TIMER_TRIGGER_BOTH = TIMER_CTRL0_TMR0TMODE_BOTH,
326 }
327 am_hal_timer_trigger_type_e;
328 
329 //*****************************************************************************
330 //
331 //! TIMER Trigger pins
332 //
333 //*****************************************************************************
334 typedef enum
335 {
336     AM_HAL_TIMER_TRIGGER_TMR0_OUT0  = TIMER_MODE0_TMR0TRIGSEL_TMR00,
337     AM_HAL_TIMER_TRIGGER_TMR0_OUT1  = TIMER_MODE0_TMR0TRIGSEL_TMR01,
338     AM_HAL_TIMER_TRIGGER_TMR1_OUT0  = TIMER_MODE0_TMR0TRIGSEL_TMR10,
339     AM_HAL_TIMER_TRIGGER_TMR1_OUT1  = TIMER_MODE0_TMR0TRIGSEL_TMR11,
340     AM_HAL_TIMER_TRIGGER_TMR2_OUT0  = TIMER_MODE0_TMR0TRIGSEL_TMR20,
341     AM_HAL_TIMER_TRIGGER_TMR2_OUT1  = TIMER_MODE0_TMR0TRIGSEL_TMR21,
342     AM_HAL_TIMER_TRIGGER_TMR3_OUT0  = TIMER_MODE0_TMR0TRIGSEL_TMR30,
343     AM_HAL_TIMER_TRIGGER_TMR3_OUT1  = TIMER_MODE0_TMR0TRIGSEL_TMR31,
344     AM_HAL_TIMER_TRIGGER_TMR4_OUT0  = TIMER_MODE0_TMR0TRIGSEL_TMR40,
345     AM_HAL_TIMER_TRIGGER_TMR4_OUT1  = TIMER_MODE0_TMR0TRIGSEL_TMR41,
346     AM_HAL_TIMER_TRIGGER_TMR5_OUT0  = TIMER_MODE0_TMR0TRIGSEL_TMR50,
347     AM_HAL_TIMER_TRIGGER_TMR5_OUT1  = TIMER_MODE0_TMR0TRIGSEL_TMR51,
348     AM_HAL_TIMER_TRIGGER_TMR6_OUT0  = TIMER_MODE0_TMR0TRIGSEL_TMR60,
349     AM_HAL_TIMER_TRIGGER_TMR6_OUT1  = TIMER_MODE0_TMR0TRIGSEL_TMR61,
350     AM_HAL_TIMER_TRIGGER_TMR7_OUT0  = TIMER_MODE0_TMR0TRIGSEL_TMR70,
351     AM_HAL_TIMER_TRIGGER_TMR7_OUT1  = TIMER_MODE0_TMR0TRIGSEL_TMR71,
352     AM_HAL_TIMER_TRIGGER_TMR8_OUT0  = TIMER_MODE0_TMR0TRIGSEL_TMR80,
353     AM_HAL_TIMER_TRIGGER_TMR8_OUT1  = TIMER_MODE0_TMR0TRIGSEL_TMR81,
354     AM_HAL_TIMER_TRIGGER_TMR9_OUT0  = TIMER_MODE0_TMR0TRIGSEL_TMR90,
355     AM_HAL_TIMER_TRIGGER_TMR9_OUT1  = TIMER_MODE0_TMR0TRIGSEL_TMR91,
356     AM_HAL_TIMER_TRIGGER_TMR10_OUT0 = TIMER_MODE0_TMR0TRIGSEL_TMR100,
357     AM_HAL_TIMER_TRIGGER_TMR10_OUT1 = TIMER_MODE0_TMR0TRIGSEL_TMR101,
358     AM_HAL_TIMER_TRIGGER_TMR11_OUT0 = TIMER_MODE0_TMR0TRIGSEL_TMR110,
359     AM_HAL_TIMER_TRIGGER_TMR11_OUT1 = TIMER_MODE0_TMR0TRIGSEL_TMR111,
360     AM_HAL_TIMER_TRIGGER_TMR12_OUT0 = TIMER_MODE0_TMR0TRIGSEL_TMR120,
361     AM_HAL_TIMER_TRIGGER_TMR12_OUT1 = TIMER_MODE0_TMR0TRIGSEL_TMR121,
362     AM_HAL_TIMER_TRIGGER_TMR13_OUT0 = TIMER_MODE0_TMR0TRIGSEL_TMR130,
363     AM_HAL_TIMER_TRIGGER_TMR13_OUT1 = TIMER_MODE0_TMR0TRIGSEL_TMR131,
364     AM_HAL_TIMER_TRIGGER_TMR14_OUT0 = TIMER_MODE0_TMR0TRIGSEL_TMR140,
365     AM_HAL_TIMER_TRIGGER_TMR14_OUT1 = TIMER_MODE0_TMR0TRIGSEL_TMR141,
366     AM_HAL_TIMER_TRIGGER_TMR15_OUT0 = TIMER_MODE0_TMR0TRIGSEL_TMR150,
367     AM_HAL_TIMER_TRIGGER_TMR15_OUT1 = TIMER_MODE0_TMR0TRIGSEL_TMR151,
368 
369     AM_HAL_TIMER_TRIGGER_GPIO0      = TIMER_MODE0_TMR0TRIGSEL_GPIO0,
370     AM_HAL_TIMER_TRIGGER_GPIO1,
371     AM_HAL_TIMER_TRIGGER_GPIO2,
372     AM_HAL_TIMER_TRIGGER_GPIO3,
373     AM_HAL_TIMER_TRIGGER_GPIO4,
374     AM_HAL_TIMER_TRIGGER_GPIO5,
375     AM_HAL_TIMER_TRIGGER_GPIO6,
376     AM_HAL_TIMER_TRIGGER_GPIO7,
377     AM_HAL_TIMER_TRIGGER_GPIO8,
378     AM_HAL_TIMER_TRIGGER_GPIO9,
379     AM_HAL_TIMER_TRIGGER_GPIO10,
380     AM_HAL_TIMER_TRIGGER_GPIO11,
381     AM_HAL_TIMER_TRIGGER_GPIO12,
382     AM_HAL_TIMER_TRIGGER_GPIO13,
383     AM_HAL_TIMER_TRIGGER_GPIO14,
384     AM_HAL_TIMER_TRIGGER_GPIO15,
385     AM_HAL_TIMER_TRIGGER_GPIO16,
386     AM_HAL_TIMER_TRIGGER_GPIO17,
387     AM_HAL_TIMER_TRIGGER_GPIO18,
388     AM_HAL_TIMER_TRIGGER_GPIO19,
389     AM_HAL_TIMER_TRIGGER_GPIO20,
390     AM_HAL_TIMER_TRIGGER_GPIO21,
391     AM_HAL_TIMER_TRIGGER_GPIO22,
392     AM_HAL_TIMER_TRIGGER_GPIO23,
393     AM_HAL_TIMER_TRIGGER_GPIO24,
394     AM_HAL_TIMER_TRIGGER_GPIO25,
395     AM_HAL_TIMER_TRIGGER_GPIO26,
396     AM_HAL_TIMER_TRIGGER_GPIO27,
397     AM_HAL_TIMER_TRIGGER_GPIO28,
398     AM_HAL_TIMER_TRIGGER_GPIO29,
399     AM_HAL_TIMER_TRIGGER_GPIO30,
400     AM_HAL_TIMER_TRIGGER_GPIO31,
401     AM_HAL_TIMER_TRIGGER_GPIO32,
402     AM_HAL_TIMER_TRIGGER_GPIO33,
403     AM_HAL_TIMER_TRIGGER_GPIO34,
404     AM_HAL_TIMER_TRIGGER_GPIO35,
405     AM_HAL_TIMER_TRIGGER_GPIO36,
406     AM_HAL_TIMER_TRIGGER_GPIO37,
407     AM_HAL_TIMER_TRIGGER_GPIO38,
408     AM_HAL_TIMER_TRIGGER_GPIO39,
409     AM_HAL_TIMER_TRIGGER_GPIO40,
410     AM_HAL_TIMER_TRIGGER_GPIO41,
411     AM_HAL_TIMER_TRIGGER_GPIO42,
412     AM_HAL_TIMER_TRIGGER_GPIO43,
413     AM_HAL_TIMER_TRIGGER_GPIO44,
414     AM_HAL_TIMER_TRIGGER_GPIO45,
415     AM_HAL_TIMER_TRIGGER_GPIO46,
416     AM_HAL_TIMER_TRIGGER_GPIO47,
417     AM_HAL_TIMER_TRIGGER_GPIO48,
418     AM_HAL_TIMER_TRIGGER_GPIO49,
419     AM_HAL_TIMER_TRIGGER_GPIO50,
420     AM_HAL_TIMER_TRIGGER_GPIO51,
421     AM_HAL_TIMER_TRIGGER_GPIO52,
422     AM_HAL_TIMER_TRIGGER_GPIO53,
423     AM_HAL_TIMER_TRIGGER_GPIO54,
424     AM_HAL_TIMER_TRIGGER_GPIO55,
425     AM_HAL_TIMER_TRIGGER_GPIO56,
426     AM_HAL_TIMER_TRIGGER_GPIO57,
427     AM_HAL_TIMER_TRIGGER_GPIO58,
428     AM_HAL_TIMER_TRIGGER_GPIO59,
429     AM_HAL_TIMER_TRIGGER_GPIO60,
430     AM_HAL_TIMER_TRIGGER_GPIO61,
431     AM_HAL_TIMER_TRIGGER_GPIO62,
432     AM_HAL_TIMER_TRIGGER_GPIO63,
433     AM_HAL_TIMER_TRIGGER_GPIO64,
434     AM_HAL_TIMER_TRIGGER_GPIO65,
435     AM_HAL_TIMER_TRIGGER_GPIO66,
436     AM_HAL_TIMER_TRIGGER_GPIO67,
437     AM_HAL_TIMER_TRIGGER_GPIO68,
438     AM_HAL_TIMER_TRIGGER_GPIO69,
439     AM_HAL_TIMER_TRIGGER_GPIO70,
440     AM_HAL_TIMER_TRIGGER_GPIO71,
441     AM_HAL_TIMER_TRIGGER_GPIO72,
442     AM_HAL_TIMER_TRIGGER_GPIO73,
443     AM_HAL_TIMER_TRIGGER_GPIO74,
444     AM_HAL_TIMER_TRIGGER_GPIO75,
445     AM_HAL_TIMER_TRIGGER_GPIO76,
446     AM_HAL_TIMER_TRIGGER_GPIO77,
447     AM_HAL_TIMER_TRIGGER_GPIO78,
448     AM_HAL_TIMER_TRIGGER_GPIO79,
449     AM_HAL_TIMER_TRIGGER_GPIO80,
450     AM_HAL_TIMER_TRIGGER_GPIO81,
451     AM_HAL_TIMER_TRIGGER_GPIO82,
452     AM_HAL_TIMER_TRIGGER_GPIO83,
453     AM_HAL_TIMER_TRIGGER_GPIO84,
454     AM_HAL_TIMER_TRIGGER_GPIO85,
455     AM_HAL_TIMER_TRIGGER_GPIO86,
456     AM_HAL_TIMER_TRIGGER_GPIO87,
457     AM_HAL_TIMER_TRIGGER_GPIO88,
458     AM_HAL_TIMER_TRIGGER_GPIO89,
459     AM_HAL_TIMER_TRIGGER_GPIO90,
460     AM_HAL_TIMER_TRIGGER_GPIO91,
461     AM_HAL_TIMER_TRIGGER_GPIO92,
462     AM_HAL_TIMER_TRIGGER_GPIO93,
463     AM_HAL_TIMER_TRIGGER_GPIO94,
464     AM_HAL_TIMER_TRIGGER_GPIO95,
465     AM_HAL_TIMER_TRIGGER_GPIO96,
466     AM_HAL_TIMER_TRIGGER_GPIO97,
467     AM_HAL_TIMER_TRIGGER_GPIO98,
468     AM_HAL_TIMER_TRIGGER_GPIO99,
469     AM_HAL_TIMER_TRIGGER_GPIO100,
470     AM_HAL_TIMER_TRIGGER_GPIO101,
471     AM_HAL_TIMER_TRIGGER_GPIO102,
472     AM_HAL_TIMER_TRIGGER_GPIO103,
473     AM_HAL_TIMER_TRIGGER_GPIO104,
474     AM_HAL_TIMER_TRIGGER_GPIO105,
475     AM_HAL_TIMER_TRIGGER_GPIO106,
476     AM_HAL_TIMER_TRIGGER_GPIO107,
477     AM_HAL_TIMER_TRIGGER_GPIO108,
478     AM_HAL_TIMER_TRIGGER_GPIO109,
479     AM_HAL_TIMER_TRIGGER_GPIO110,
480     AM_HAL_TIMER_TRIGGER_GPIO111,
481     AM_HAL_TIMER_TRIGGER_GPIO112,
482     AM_HAL_TIMER_TRIGGER_GPIO113,
483     AM_HAL_TIMER_TRIGGER_GPIO114,
484     AM_HAL_TIMER_TRIGGER_GPIO115,
485     AM_HAL_TIMER_TRIGGER_GPIO116,
486     AM_HAL_TIMER_TRIGGER_GPIO117,
487     AM_HAL_TIMER_TRIGGER_GPIO118,
488     AM_HAL_TIMER_TRIGGER_GPIO119,
489     AM_HAL_TIMER_TRIGGER_GPIO120,
490     AM_HAL_TIMER_TRIGGER_GPIO121,
491     AM_HAL_TIMER_TRIGGER_GPIO122,
492     AM_HAL_TIMER_TRIGGER_GPIO123,
493     AM_HAL_TIMER_TRIGGER_GPIO124,
494     AM_HAL_TIMER_TRIGGER_GPIO125,
495     AM_HAL_TIMER_TRIGGER_GPIO126,
496     AM_HAL_TIMER_TRIGGER_GPIO127     = TIMER_MODE0_TMR0TRIGSEL_GPIO127,
497 }
498 am_hal_timer_trigger_source_e;
499 
500 //*****************************************************************************
501 //
502 //! TIMER Output
503 //
504 //*****************************************************************************
505 typedef enum
506 {
507     AM_HAL_TIMER_OUTPUT_TMR0_OUT0   =   TIMER_OUTCFG0_OUTCFG0_TIMER00,
508     AM_HAL_TIMER_OUTPUT_TMR0_OUT1   =   TIMER_OUTCFG0_OUTCFG0_TIMER01,
509     AM_HAL_TIMER_OUTPUT_TMR1_OUT0   =   TIMER_OUTCFG0_OUTCFG0_TIMER10,
510     AM_HAL_TIMER_OUTPUT_TMR1_OUT1   =   TIMER_OUTCFG0_OUTCFG0_TIMER11,
511     AM_HAL_TIMER_OUTPUT_TMR2_OUT0   =   TIMER_OUTCFG0_OUTCFG0_TIMER20,
512     AM_HAL_TIMER_OUTPUT_TMR2_OUT1   =   TIMER_OUTCFG0_OUTCFG0_TIMER21,
513     AM_HAL_TIMER_OUTPUT_TMR3_OUT0   =   TIMER_OUTCFG0_OUTCFG0_TIMER30,
514     AM_HAL_TIMER_OUTPUT_TMR3_OUT1   =   TIMER_OUTCFG0_OUTCFG0_TIMER31,
515     AM_HAL_TIMER_OUTPUT_TMR4_OUT0   =   TIMER_OUTCFG0_OUTCFG0_TIMER40,
516     AM_HAL_TIMER_OUTPUT_TMR4_OUT1   =   TIMER_OUTCFG0_OUTCFG0_TIMER41,
517     AM_HAL_TIMER_OUTPUT_TMR5_OUT0   =   TIMER_OUTCFG0_OUTCFG0_TIMER50,
518     AM_HAL_TIMER_OUTPUT_TMR5_OUT1   =   TIMER_OUTCFG0_OUTCFG0_TIMER51,
519     AM_HAL_TIMER_OUTPUT_TMR6_OUT0   =   TIMER_OUTCFG0_OUTCFG0_TIMER60,
520     AM_HAL_TIMER_OUTPUT_TMR6_OUT1   =   TIMER_OUTCFG0_OUTCFG0_TIMER61,
521     AM_HAL_TIMER_OUTPUT_TMR7_OUT0   =   TIMER_OUTCFG0_OUTCFG0_TIMER70,
522     AM_HAL_TIMER_OUTPUT_TMR7_OUT1   =   TIMER_OUTCFG0_OUTCFG0_TIMER71,
523     AM_HAL_TIMER_OUTPUT_TMR8_OUT0   =   TIMER_OUTCFG0_OUTCFG0_TIMER80,
524     AM_HAL_TIMER_OUTPUT_TMR8_OUT1   =   TIMER_OUTCFG0_OUTCFG0_TIMER81,
525     AM_HAL_TIMER_OUTPUT_TMR9_OUT0   =   TIMER_OUTCFG0_OUTCFG0_TIMER90,
526     AM_HAL_TIMER_OUTPUT_TMR9_OUT1   =   TIMER_OUTCFG0_OUTCFG0_TIMER91,
527     AM_HAL_TIMER_OUTPUT_TMR10_OUT0  =   TIMER_OUTCFG0_OUTCFG0_TIMER100,
528     AM_HAL_TIMER_OUTPUT_TMR10_OUT1  =   TIMER_OUTCFG0_OUTCFG0_TIMER101,
529     AM_HAL_TIMER_OUTPUT_TMR11_OUT0  =   TIMER_OUTCFG0_OUTCFG0_TIMER110,
530     AM_HAL_TIMER_OUTPUT_TMR11_OUT1  =   TIMER_OUTCFG0_OUTCFG0_TIMER111,
531     AM_HAL_TIMER_OUTPUT_TMR12_OUT0  =   TIMER_OUTCFG0_OUTCFG0_TIMER120,
532     AM_HAL_TIMER_OUTPUT_TMR12_OUT1  =   TIMER_OUTCFG0_OUTCFG0_TIMER121,
533     AM_HAL_TIMER_OUTPUT_TMR13_OUT0  =   TIMER_OUTCFG0_OUTCFG0_TIMER130,
534     AM_HAL_TIMER_OUTPUT_TMR13_OUT1  =   TIMER_OUTCFG0_OUTCFG0_TIMER131,
535     AM_HAL_TIMER_OUTPUT_TMR14_OUT0  =   TIMER_OUTCFG0_OUTCFG0_TIMER140,
536     AM_HAL_TIMER_OUTPUT_TMR14_OUT1  =   TIMER_OUTCFG0_OUTCFG0_TIMER141,
537     AM_HAL_TIMER_OUTPUT_TMR15_OUT0  =   TIMER_OUTCFG0_OUTCFG0_TIMER150,
538     AM_HAL_TIMER_OUTPUT_TMR15_OUT1  =   TIMER_OUTCFG0_OUTCFG0_TIMER151,
539     AM_HAL_TIMER_OUTPUT_STIMER0     =   TIMER_OUTCFG0_OUTCFG0_STIMER0,
540     AM_HAL_TIMER_OUTPUT_STIMER1     =   TIMER_OUTCFG0_OUTCFG0_STIMER1,
541     AM_HAL_TIMER_OUTPUT_STIMER2     =   TIMER_OUTCFG0_OUTCFG0_STIMER2,
542     AM_HAL_TIMER_OUTPUT_STIMER3     =   TIMER_OUTCFG0_OUTCFG0_STIMER3,
543     AM_HAL_TIMER_OUTPUT_STIMER4     =   TIMER_OUTCFG0_OUTCFG0_STIMER4,
544     AM_HAL_TIMER_OUTPUT_STIMER5     =   TIMER_OUTCFG0_OUTCFG0_STIMER5,
545     AM_HAL_TIMER_OUTPUT_STIMER6     =   TIMER_OUTCFG0_OUTCFG0_STIMER6,
546     AM_HAL_TIMER_OUTPUT_STIMER7     =   TIMER_OUTCFG0_OUTCFG0_STIMER7,
547 }
548 am_hal_timer_output_e;
549 
550 //*****************************************************************************
551 //
552 //! TIMER configuration structure.
553 //
554 //*****************************************************************************
555 typedef struct
556 {
557     am_hal_timer_clock_e                eInputClock;            // Input Clock
558     am_hal_timer_function_e             eFunction;              // Function
559     bool                                bInvertOutput0;         // Output0 polarity.
560     bool                                bInvertOutput1;         // Output1 polarity.
561     am_hal_timer_trigger_type_e         eTriggerType;           // Rising, Falling, Both, None.
562     am_hal_timer_trigger_source_e       eTriggerSource;         // Input Trigger Source.
563     bool                                bLowJitter;             // Asynch to bus to provide low-jitter clock.
564 
565     //
566     // Note: Setting ui32PatternLimit for SINGLEPATTERN and REPEATPATTERN Modes
567     // will produce a pattern that is N+1 bits long. For example,
568     // ui32PatternLimit of 24 will produce a pattern that is 25 bits long, and
569     // ui32PatternLimit of 0 will produce a pattern that is 1 bit long.
570     //
571     uint32_t                            ui32PatternLimit;       // End of pattern count. Max value 63.
572     // Function dependent comparator values.  See register definitions and datasheet.
573     uint32_t                            ui32Compare0;           // Primary comparator value.
574     uint32_t                            ui32Compare1;           // Secondary comparator value.
575 }
576 am_hal_timer_config_t;
577 
578 //*****************************************************************************
579 //
580 //! TIMER interrupt macros
581 //! @name timer_interrupt_macros
582 //! @{
583 //
584 //*****************************************************************************
585 #define AM_HAL_TIMER_INT_TMR0_CMP0    TIMER_INTSTAT_TMR00INT_Msk
586 #define AM_HAL_TIMER_INT_TMR0_CMP1    TIMER_INTSTAT_TMR01INT_Msk
587 #define AM_HAL_TIMER_INT_TMR1_CMP0    TIMER_INTSTAT_TMR10INT_Msk
588 #define AM_HAL_TIMER_INT_TMR1_CMP1    TIMER_INTSTAT_TMR11INT_Msk
589 #define AM_HAL_TIMER_INT_TMR2_CMP0    TIMER_INTSTAT_TMR20INT_Msk
590 #define AM_HAL_TIMER_INT_TMR2_CMP1    TIMER_INTSTAT_TMR21INT_Msk
591 #define AM_HAL_TIMER_INT_TMR3_CMP0    TIMER_INTSTAT_TMR30INT_Msk
592 #define AM_HAL_TIMER_INT_TMR3_CMP1    TIMER_INTSTAT_TMR31INT_Msk
593 #define AM_HAL_TIMER_INT_TMR4_CMP0    TIMER_INTSTAT_TMR40INT_Msk
594 #define AM_HAL_TIMER_INT_TMR4_CMP1    TIMER_INTSTAT_TMR41INT_Msk
595 #define AM_HAL_TIMER_INT_TMR5_CMP0    TIMER_INTSTAT_TMR50INT_Msk
596 #define AM_HAL_TIMER_INT_TMR5_CMP1    TIMER_INTSTAT_TMR51INT_Msk
597 #define AM_HAL_TIMER_INT_TMR6_CMP0    TIMER_INTSTAT_TMR60INT_Msk
598 #define AM_HAL_TIMER_INT_TMR6_CMP1    TIMER_INTSTAT_TMR61INT_Msk
599 #define AM_HAL_TIMER_INT_TMR7_CMP0    TIMER_INTSTAT_TMR70INT_Msk
600 #define AM_HAL_TIMER_INT_TMR7_CMP1    TIMER_INTSTAT_TMR71INT_Msk
601 #define AM_HAL_TIMER_INT_TMR8_CMP0    TIMER_INTSTAT_TMR80INT_Msk
602 #define AM_HAL_TIMER_INT_TMR8_CMP1    TIMER_INTSTAT_TMR81INT_Msk
603 #define AM_HAL_TIMER_INT_TMR9_CMP0    TIMER_INTSTAT_TMR90INT_Msk
604 #define AM_HAL_TIMER_INT_TMR9_CMP1    TIMER_INTSTAT_TMR91INT_Msk
605 #define AM_HAL_TIMER_INT_TMR10_CMP0   TIMER_INTSTAT_TMR100INT_Msk
606 #define AM_HAL_TIMER_INT_TMR10_CMP1   TIMER_INTSTAT_TMR101INT_Msk
607 #define AM_HAL_TIMER_INT_TMR11_CMP0   TIMER_INTSTAT_TMR110INT_Msk
608 #define AM_HAL_TIMER_INT_TMR11_CMP1   TIMER_INTSTAT_TMR111INT_Msk
609 #define AM_HAL_TIMER_INT_TMR12_CMP0   TIMER_INTSTAT_TMR120INT_Msk
610 #define AM_HAL_TIMER_INT_TMR12_CMP1   TIMER_INTSTAT_TMR121INT_Msk
611 #define AM_HAL_TIMER_INT_TMR13_CMP0   TIMER_INTSTAT_TMR130INT_Msk
612 #define AM_HAL_TIMER_INT_TMR13_CMP1   TIMER_INTSTAT_TMR131INT_Msk
613 #define AM_HAL_TIMER_INT_TMR14_CMP0   TIMER_INTSTAT_TMR140INT_Msk
614 #define AM_HAL_TIMER_INT_TMR14_CMP1   TIMER_INTSTAT_TMR141INT_Msk
615 #define AM_HAL_TIMER_INT_TMR15_CMP0   TIMER_INTSTAT_TMR150INT_Msk
616 #define AM_HAL_TIMER_INT_TMR15_CMP1   TIMER_INTSTAT_TMR151INT_Msk
617 //! @}
618 
619 //*****************************************************************************
620 //
621 //! @brief Configure a TIMER
622 //!
623 //! @param ui32TimerNumber refers to one of the numbered TIMERs in the module.
624 //! @param psTimerConfig is a structure describing a timer configuration.
625 //!
626 //! Use this function to set important qualities about a TIMER, such as its
627 //! clock, compare values, and output pin configuration.
628 //!
629 //! @return Standard HAL status code.
630 //
631 //*****************************************************************************
632 extern uint32_t am_hal_timer_config(uint32_t ui32TimerNumber,
633                                     am_hal_timer_config_t *psTimerConfig);
634 
635 //*****************************************************************************
636 //
637 //! @brief Initialize a timer configuration structure with default values.
638 //!
639 //! @param psTimerConfig is a structure describing a timer configuration.
640 //!
641 //! This function will set the members of a timer config structure to default
642 //! values as follows:
643 //!    psTimerConfig->eInputClock = AM_HAL_TIMER_CLOCK_HFRC_DIV4;
644 //!    psTimerConfig->eFunction = AM_HAL_TIMER_FN_EDGE;
645 //!    psTimerConfig->ui32Compare0 = 0xFFFFFFFF;
646 //!    psTimerConfig->ui32Compare1 = 0xFFFFFFFF;
647 //!    psTimerConfig->bInvertOutput0 = false;
648 //!    psTimerConfig->bInvertOutput1 = false;
649 //!    psTimerConfig->eTriggerType = AM_HAL_TIMER_TRIGGER_DIS;
650 //!    psTimerConfig->eTriggerSource = AM_HAL_TIMER_TRIGGER_TMR0_CMP0;
651 //!    psTimerConfig->ui32PatternLimit = 0;
652 
653 //! @return Standard HAL status code.
654 //
655 //*****************************************************************************
656 extern uint32_t am_hal_timer_default_config_set(am_hal_timer_config_t *psTimerConfig);
657 
658 //*****************************************************************************
659 //
660 //! @brief Reset a timer configuration to the power up state.
661 //!
662 //! @param ui32TimerNumber is the number of the TIMER to enable.
663 //!
664 //! This function will reset the given timer to the power up configuration.
665 //!
666 //! @return Standard HAL status code.
667 //
668 //*****************************************************************************
669 extern uint32_t am_hal_timer_reset_config(uint32_t ui32TimerNumber);
670 
671 //*****************************************************************************
672 //
673 //! @brief Enable a single TIMER
674 //!
675 //! @param ui32TimerNumber is the number of the TIMER to enable.
676 //!
677 //! @return Standard HAL status code.
678 //
679 //*****************************************************************************
680 extern uint32_t am_hal_timer_enable(uint32_t ui32TimerNumber);
681 
682 //*****************************************************************************
683 //
684 //! @brief Disable a single TIMER
685 //!
686 //! @param ui32TimerNumber is the number of the TIMER to disable.
687 //!
688 //! @return Standard HAL status code.
689 //
690 //*****************************************************************************
691 extern uint32_t am_hal_timer_disable(uint32_t ui32TimerNumber);
692 
693 //*****************************************************************************
694 //
695 //! @brief Enable a group of TIMERS all at once
696 //!
697 //! @param ui32TimerMask is a set of TIMERs to enable.
698 //!
699 //! @return Standard HAL status code.
700 //
701 //*****************************************************************************
702 extern uint32_t am_hal_timer_enable_sync(uint32_t ui32TimerMask);
703 
704 //*****************************************************************************
705 //
706 //! @brief Enable a group of TIMERS all at once
707 //!
708 //! @param ui32TimerMask is a set of TIMERs to enable.
709 //!
710 //! @return Standard HAL status code.
711 //
712 //*****************************************************************************
713 extern uint32_t am_hal_timer_disable_sync(uint32_t ui32TimerMask);
714 
715 //*****************************************************************************
716 //
717 //! @brief Start a single TIMER
718 //!
719 //! @param ui32TimerNumber is the number of the timer to use.
720 //!
721 //! Call this definition to start the timer.
722 //!
723 //
724 //*****************************************************************************
725 #define am_hal_timer_start(ui32TimerNumber)   am_hal_timer_enable(ui32TimerNumber)
726 
727 //*****************************************************************************
728 //
729 //! @brief Disable a single TIMER
730 //!
731 //! @param ui32TimerNumber is the number of the timer to use.
732 //!
733 //! This definition will stop the timer.
734 //
735 //*****************************************************************************
736 #define am_hal_timer_stop(ui32TimerNumber)    am_hal_timer_disable(ui32TimerNumber)
737 
738 //*****************************************************************************
739 //
740 //! @brief Clear a single TIMER and start the timer.
741 //!
742 //! @param ui32TimerNumber is the number of the timer to use.
743 //!
744 //! This function will reset a timer to its "start" value. For count-up timers
745 //! this will be zero, and for count-down timers this will be the value
746 //! COMPARE0.
747 //!
748 //! After clearing the timer, the timer is started in this function.
749 //!
750 //! @return Standard HAL status code.
751 //
752 //*****************************************************************************
753 extern uint32_t am_hal_timer_clear(uint32_t ui32TimerNumber);
754 
755 //*****************************************************************************
756 //
757 //! @brief Clear a single TIMER, but don't start it.
758 //!
759 //! @param ui32TimerNumber is the number of the timer to use.
760 //!
761 //! This function will reset a timer to its "start" value. For count-up timers
762 //! this will be zero, and for count-down timers this will be the value
763 //! COMPARE0.
764 //!
765 //! @return Standard HAL status code.
766 //
767 //*****************************************************************************
768 extern uint32_t am_hal_timer_clear_stop(uint32_t ui32TimerNumber);
769 
770 //*****************************************************************************
771 //
772 //! @brief Read the current value of a timer.
773 //!
774 //! @param ui32TimerNumber is the number of the timer to use.
775 //!
776 //! This function returns the 32-bit count value of a timer.
777 //!
778 //! @return Current value of the timer.
779 //
780 //*****************************************************************************
781 extern uint32_t am_hal_timer_read(uint32_t ui32TimerNumber);
782 
783 //*****************************************************************************
784 //
785 //! @brief Configure timer pin output.
786 //!
787 //! @param ui32PadNum is the gpio number to output pattern.
788 //! @param eOutputType specifies which source to use.
789 //!
790 //! This function will configure the output pin for the selected timer.
791 //!
792 //! ui32PadNum
793 //!     Pad number to be used for the output signal.
794 //! eOutputType
795 //!     AM_HAL_TIMER_OUTPUT_TMR0_OUT0
796 //!     AM_HAL_TIMER_OUTPUT_TMR0_OUT1
797 //!     ......
798 //!     AM_HAL_TIMER_OUTPUT_STIMER6
799 //!     AM_HAL_TIMER_OUTPUT_STIMER7
800 //!
801 //! @return result.
802 //
803 //*****************************************************************************
804 extern uint32_t am_hal_timer_output_config(uint32_t ui32PadNum, uint32_t eOutputType);
805 
806 //*****************************************************************************
807 //
808 //! @brief Set the COMPARE0 value for a single timer.
809 //!
810 //! @param ui32TimerNumber is the number of the timer to use.
811 //! @param ui32CompareValue is the value to use for COMPARE0
812 //!
813 //! This function will set COMPARE0 for the selected timer. COMPARE0 controls
814 //! the roll-over value for the selcted timer (or the stop value for
815 //! single-shot timers). This change is done "on the fly" without disabling
816 //! the timer for use with the DOWNCOUNT function.
817 //!
818 //! @return Standard HAL status code.
819 //
820 //*****************************************************************************
821 extern uint32_t am_hal_timer_compare0_set(uint32_t ui32TimerNumber,
822                                           uint32_t ui32CompareValue);
823 
824 //*****************************************************************************
825 //
826 //! @brief Set the COMPARE1 value for a single timer.
827 //!
828 //! @param ui32TimerNumber is the number of the timer to use.
829 //! @param ui32CompareValue is the value to use for COMPARE1
830 //!
831 //! This function will set COMPARE1 for the selected timer. COMPARE1 is used to
832 //! generate interrupts and output level shifts for a timer values between zero
833 //! and COMPARE0. Check the description of your selected TIMER mode for a
834 //! precise description of the function of COMPARE1.  This change is done
835 //! "on the fly" without disabling the timer for use with the DOWNCOUNT function.
836 //!
837 //! @return Standard HAL status code.
838 //
839 //*****************************************************************************
840 extern uint32_t am_hal_timer_compare1_set(uint32_t ui32TimerNumber,
841                                           uint32_t ui32CompareValue);
842 
843 //*****************************************************************************
844 //
845 //! @brief TIMER enable interrupts function
846 //!
847 //! @param ui32InterruptMask  - interface specific interrupt mask.
848 //!
849 //! This function enables the specific indicated interrupts (see above).
850 //!
851 //! @return status      - generic or interface specific status.
852 //
853 //*****************************************************************************
854 extern uint32_t am_hal_timer_interrupt_enable(uint32_t ui32InterruptMask);
855 
856 //*****************************************************************************
857 //
858 //! @brief TIMER disable interrupts function
859 //!
860 //! @param ui32InterruptMask  - interface specific interrupt mask.
861 //!
862 //! This function disables the specified interrupts.
863 //!
864 //! @return status      - generic or interface specific status.
865 //!
866 //*****************************************************************************
867 extern uint32_t am_hal_timer_interrupt_disable(uint32_t ui32InterruptMask);
868 
869 //*****************************************************************************
870 //
871 //! @brief TIMER get interrupt status
872 //!
873 //! @param bEnabledOnly   - If interrupt is enabled
874 //! @param pui32IntStatus - pointer to a uint32_t to return the interrupt status
875 //!
876 //! @return status      - generic or interface specific status.
877 //
878 //*****************************************************************************
879 extern uint32_t am_hal_timer_interrupt_status_get(bool bEnabledOnly, uint32_t *pui32IntStatus);
880 
881 //*****************************************************************************
882 //
883 //! @brief TIMER interrupt clear
884 //!
885 //! @param ui32InterruptMask  - interface specific interrupt mask.
886 //!
887 //! This function clears the interrupts for the given peripheral.
888 //!
889 //! @return status      - generic or interface specific status.
890 //
891 //*****************************************************************************
892 extern uint32_t am_hal_timer_interrupt_clear(uint32_t ui32InterruptMask);
893 
894 #ifdef __cplusplus
895 }
896 #endif
897 
898 #endif // AM_HAL_TIMER_H
899 
900 //*****************************************************************************
901 //
902 // End Doxygen group.
903 //! @}
904 //
905 //*****************************************************************************
906 
907