1 /*******************************************************************************
\r
2 * (c) Copyright 2010-2013 Microsemi SoC Products Group. All rights reserved.
\r
4 * SmartFusion2 microcontroller subsystem (MSS) timer driver API.
\r
6 * SVN $Revision: 5111 $
\r
7 * SVN $Date: 2013-02-18 17:03:09 +0000 (Mon, 18 Feb 2013) $
\r
9 /*=========================================================================*//**
\r
10 @mainpage SmartFusion2 MSS Timer Bare Metal Driver.
\r
12 @section intro_sec Introduction
\r
13 The SmartFusion2 Microcontroller Subsystem (MSS) includes a timer hardware
\r
14 block which can be used as two independent 32-bits timers or as a single
\r
15 64-bits timer in periodic or one-shot mode.
\r
17 This driver provides a set of functions for controlling the MSS timer as part
\r
18 of a bare metal system where no operating system is available. These drivers
\r
19 can be adapted for use as part of an operating system but the implementation
\r
20 of the adaptation layer between this driver and the operating system's driver
\r
21 model is outside the scope of this driver.
\r
23 @section theory_op Theory of Operation
\r
24 The MSS Timer driver uses the SmartFusion2 "Cortex Microcontroler Software
\r
25 Interface Standard - Peripheral Access Layer" (CMSIS-PAL) to access hadware
\r
26 registers. You must ensure that the SmartFusion2 CMSIS-PAL is either included
\r
27 in the software toolchain used to build your project or is included in your
\r
28 project. The most up-to-date SmartFusion2 CMSIS-PAL files can be obtained using
\r
29 the Actel Firmware Catalog.
\r
30 The SmartFusion2 MSS Timer can be used in one of two mutually exclusive modes;
\r
31 either as a single 64-bits timer or as two independent 32-bits timers. The MSS
\r
32 Timer can be used in either periodic mode or one-shot mode. A timer configured
\r
33 for periodic mode operations will generate an interrupt and reload its
\r
34 down-counter when it reaches 0. The timer will then continue decrementing from
\r
35 its reload value without waiting for the interrupt to be cleared. A timer
\r
36 configured for one-shot mode will only generate an interrupt once when its
\r
37 down-counter reaches 0. It must be explitcitly reloaded to start decrementing
\r
40 The MSS Timer driver functions are grouped into the following categories:
\r
41 - Initialization and Configuration
\r
45 The MSS Timer driver provides three initialization functions:
\r
49 The MSS Timer driver is initialized through calls to these functions and at
\r
50 least one of them must be called before any other MSS Timer driver functions
\r
52 You should only use the MSS_TIM1_init() and MSS_TIM2_init() functions if you
\r
53 intend to use the timer in 32-bits mode. Use the MSS_TIM64_init() function is
\r
54 you intend to use the MSS Timer as a single 64-bits timer. The initialization
\r
55 functions take a single parameter specifying the operating mode of the timer
\r
58 Once initialized a timer can be controlled using the following functions:
\r
59 - MSS_TIM1_load_immediate()
\r
60 - MSS_TIM1_load_background()
\r
61 - MSS_TIM1_get_current_value()
\r
64 - MSS_TIM2_load_immediate()
\r
65 - MSS_TIM2_load_background()
\r
66 - MSS_TIM2_get_current_value()
\r
69 - MSS_TIM64_load_immediate()
\r
70 - MSS_TIM64_load_background()
\r
71 - MSS_TIM64_get_current_value()
\r
75 Timer interrupts are controlled using the following functions:
\r
76 - MSS_TIM1_enable_irq()
\r
77 - MSS_TIM1_disable_irq()
\r
78 - MSS_TIM1_clear_irq()
\r
79 - MSS_TIM2_enable_irq()
\r
80 - MSS_TIM2_disable_irq()
\r
81 - MSS_TIM2_clear_irq()
\r
82 - MSS_TIM64_enable_irq()
\r
83 - MSS_TIM64_disable_irq()
\r
84 - MSS_TIM64_clear_irq()
\r
86 The function prototypes for the timer interrupt handlers are:
\r
87 - void Timer1_IRQHandler( void )
\r
88 - void Timer2_IRQHandler( void )
\r
89 Entries for these interrupt handlers are provided in the SmartFusion2 CMSIS-PAL
\r
90 vector table. To add a Timer 1 interrupt handler, you must implement a
\r
91 Timer1_IRQHandler( ) function as part of your application code. To add a
\r
92 Timer 2 interrupt handler, you must implement a Timer2_IRQHandler( ) function
\r
93 as part of your application code. When using the MSS Timer as a 64-bit timer,
\r
94 you must implement a Timer1_IRQHandler( ) function as part of your
\r
95 application code. The Timer 2 interrupt is not used when the MSS Timer is
\r
96 configured as a 64-bit timer.
\r
98 *//*=========================================================================*/
\r
99 #ifndef MSS_TIMER_H_
\r
100 #define MSS_TIMER_H_
\r
103 #include "../../CMSIS/m2sxxx.h"
\r
109 /*-------------------------------------------------------------------------*//**
\r
110 * Timer mode selection. This enumeration is used to select between the two
\r
111 * possible timer modes of operation: periodic and one-shot mode. It is used as
\r
112 * an argument to the MSS_TIM1_init(), MSS_TIM2_init() and MSS_TIM64_init()
\r
114 * MSS_TIMER_PERIODIC_MODE:
\r
115 * In periodic mode the timer generates interrupts at constant intervals. On
\r
116 * reaching zero, the timer's counter is reloaded with a value held in a
\r
117 * register and begins counting down again.
\r
118 * MSS_TIMER_ONE_SHOT_MODE:
\r
119 * The timer generates a single interrupt in this mode. On reaching zero, the
\r
120 * timer's counter halts until reprogrammed by the user.
\r
122 typedef enum __mss_timer_mode_t
\r
124 MSS_TIMER_PERIODIC_MODE = 0,
\r
125 MSS_TIMER_ONE_SHOT_MODE = 1
\r
126 } mss_timer_mode_t;
\r
128 /*-------------------------------------------------------------------------*//**
\r
129 The MSS_TIM1_init() function initializes the SmartFusion2 MSS Timer block for
\r
130 use as a 32-bit timer and selects the operating mode for Timer 1. This function
\r
131 takes the MSS Timer block out of reset in case this hasn
\92t been done already,
\r
132 stops Timer 1, disables its interrupt and sets the Timer 1 operating mode.
\r
133 Please note that the SmartFusion2 MSS Timer block cannot be used both as a
\r
134 64-bit and 32-bit timer. Calling MSS_TIM1_init() will overwrite any previous
\r
135 configuration of the MSS Timer as a 64-bit timer.
\r
139 The mode parameter specifies whether the timer will operate in periodic or
\r
140 one-shot mode. Allowed values for this parameter are:
\r
141 - MSS_TIMER_PERIODIC_MODE
\r
142 - MSS_TIMER_ONE_SHOT_MODE
\r
144 static __INLINE void MSS_TIM1_init(mss_timer_mode_t mode)
\r
146 NVIC_DisableIRQ(Timer1_IRQn); /* Disable timer 1 irq in the Cortex-M3 NVIC */
\r
148 SYSREG->SOFT_RST_CR &= ~SYSREG_TIMER_SOFTRESET_MASK; /* Take timer block out of reset */
\r
150 TIMER->TIM64_MODE = 0u; /* switch to 32 bits mode */
\r
152 TIMER_BITBAND->TIM1ENABLE = 0u; /* disable timer */
\r
153 TIMER_BITBAND->TIM1INTEN = 0u; /* disable interrupt */
\r
154 TIMER_BITBAND->TIM1MODE = (uint32_t)mode; /* set mode (continuous/one-shot) */
\r
156 TIMER->TIM1_RIS = 1u; /* clear timer 1 interrupt */
\r
157 NVIC_ClearPendingIRQ(Timer1_IRQn); /* clear timer 1 interrupt within NVIC */
\r
160 /*-------------------------------------------------------------------------*//**
\r
161 The MSS_TIM1_start() function enables Timer 1 and starts its down-counter
\r
162 decrementing from the load_value specified in previous calls to the
\r
163 MSS_TIM1_load_immediate() or MSS_TIM1_load_background() functions.
\r
165 static __INLINE void MSS_TIM1_start(void)
\r
167 TIMER_BITBAND->TIM1ENABLE = 1u; /* enable timer */
\r
170 /*-------------------------------------------------------------------------*//**
\r
171 The MSS_TIM1_stop() function disables Timer 1 and stops its down-counter
\r
174 static __INLINE void MSS_TIM1_stop(void)
\r
176 TIMER_BITBAND->TIM1ENABLE = 0u; /* disable timer */
\r
179 /*-------------------------------------------------------------------------*//**
\r
180 The MSS_TIM1_get_current_value() returns the current value of the Timer 1
\r
184 This function returns the 32-bits current value of the Timer 1 down-counter.
\r
186 static __INLINE uint32_t MSS_TIM1_get_current_value(void)
\r
188 return TIMER->TIM1_VAL;
\r
191 /*-------------------------------------------------------------------------*//**
\r
192 The MSS_TIM1_load_immediate() function loads the value passed by the
\r
193 load_value parameter into the Timer 1 down-counter. The counter will decrement
\r
194 immediately from this value once Timer 1 is enabled. The MSS Timer will
\r
195 generate an interrupt when the counter reaches zero if Timer 1 interrupts are
\r
196 enabled. This function is intended to be used when Timer 1 is configured for
\r
197 one-shot mode to time a single delay.
\r
200 The load_value parameter specifies the value from which the Timer 1 down-counter
\r
201 will start decrementing from.
\r
203 static __INLINE void MSS_TIM1_load_immediate(uint32_t load_value)
\r
205 TIMER->TIM1_LOADVAL = load_value;
\r
208 /*-------------------------------------------------------------------------*//**
\r
209 The MSS_TIM1_load_background() function is used to specify the value that will
\r
210 be reloaded into the Timer 1 down-counter the next time the counter reaches
\r
211 zero. This function is typically used when Timer 1 is configured for periodic
\r
212 mode operation to select or change the delay period between the interrupts
\r
213 generated by Timer 1.
\r
216 The load_value parameter specifies the value that will be loaded into the
\r
217 Timer 1 down-counter the next time the down-counter reaches zero. The Timer
\r
218 1 down-counter will start decrementing from this value after the current
\r
221 static __INLINE void MSS_TIM1_load_background(uint32_t load_value)
\r
223 TIMER->TIM1_BGLOADVAL = load_value;
\r
226 /*-------------------------------------------------------------------------*//**
\r
227 The MSS_TIM1_enable_irq() function is used to enable interrupt generation for
\r
228 Timer 1. This function also enables the interrupt in the Cortex-M3 interrupt
\r
229 controller. The Timer1_IRQHandler() function will be called when a Timer 1
\r
231 Note: Note: A Timer1_IRQHandler() default implementation is defined, with
\r
232 weak linkage, in the SmartFusion2 CMSIS-PAL. You must provide your own
\r
233 implementation of the Timer1_IRQHandler() function, that will override the
\r
234 default implementation, to suit your application.
\r
237 static __INLINE void MSS_TIM1_enable_irq(void)
\r
239 TIMER_BITBAND->TIM1INTEN = 1u;
\r
240 NVIC_EnableIRQ(Timer1_IRQn);
\r
243 /*-------------------------------------------------------------------------*//**
\r
244 The MSS_TIM1_disable_irq() function is used to disable interrupt generation
\r
245 for Timer 1. This function also disables the interrupt in the Cortex-M3
\r
246 interrupt controller.
\r
248 static __INLINE void MSS_TIM1_disable_irq(void)
\r
250 TIMER_BITBAND->TIM1INTEN = 0u;
\r
251 NVIC_DisableIRQ(Timer1_IRQn);
\r
254 /*-------------------------------------------------------------------------*//**
\r
255 The MSS_TIM1_clear_irq() function is used to clear a pending interrupt from
\r
256 Timer 1. This function also clears the interrupt in the Cortex-M3 interrupt
\r
258 Note: You must call the MSS_TIM1_clear_irq() function as part of your
\r
259 implementation of the Timer1_IRQHandler() Timer 1 interrupt service routine
\r
260 (ISR) in order to prevent the same interrupt event retriggering a call to the
\r
264 static __INLINE void MSS_TIM1_clear_irq(void)
\r
266 TIMER->TIM1_RIS = 1u;
\r
269 /*-------------------------------------------------------------------------*//**
\r
270 The MSS_TIM2_init() function initializes the SmartFusion2 MSS Timer block for
\r
271 use as a 32-bit timer and selects the operating mode for Timer 2. This function
\r
272 takes the MSS Timer block out of reset in case this hasn
\92t been done already,
\r
273 stops Timer 2, disables its interrupt and sets the Timer 2 operating mode.
\r
274 Note: Please note that the SmartFusion2 MSS Timer block cannot be used both as
\r
275 a 64-bit and 32-bit timer. Calling MSS_TIM2_init() will overwrite any previous
\r
276 configuration of the MSS Timer as a 64-bit timer.
\r
279 The mode parameter specifies whether the timer will operate in periodic or
\r
280 one-shot mode. Allowed values for this parameter are:
\r
281 - MSS_TIMER_PERIODIC_MODE
\r
282 - MSS_TIMER_ONE_SHOT_MODE
\r
284 static __INLINE void MSS_TIM2_init(mss_timer_mode_t mode)
\r
286 NVIC_DisableIRQ(Timer2_IRQn); /* Disable timer 2 irq in the Cortex-M3 NVIC */
\r
288 SYSREG->SOFT_RST_CR &= ~SYSREG_TIMER_SOFTRESET_MASK; /* Take timer block out of reset */
\r
290 TIMER->TIM64_MODE = 0u; /* switch to 32 bits mode */
\r
292 TIMER_BITBAND->TIM2ENABLE = 0u; /* disable timer */
\r
293 TIMER_BITBAND->TIM2INTEN = 0u; /* disable interrupt */
\r
294 TIMER_BITBAND->TIM2MODE = (uint32_t)mode; /* set mode (continuous/one-shot) */
\r
296 TIMER->TIM2_RIS = 1u; /* clear timer 2 interrupt */
\r
297 NVIC_ClearPendingIRQ(Timer2_IRQn); /* clear timer 2 interrupt within NVIC */
\r
300 /*-------------------------------------------------------------------------*//**
\r
301 The MSS_TIM2_start() function enables Timer 2 and starts its down-counter
\r
302 decrementing from the load_value specified in previous calls to the
\r
303 MSS_TIM2_load_immediate() or MSS_TIM2_load_background() functions.
\r
305 static __INLINE void MSS_TIM2_start(void)
\r
307 TIMER_BITBAND->TIM2ENABLE = 1u; /* enable timer */
\r
310 /*-------------------------------------------------------------------------*//**
\r
311 The MSS_TIM2_stop() function disables Timer 2 and stops its down-counter
\r
314 static __INLINE void MSS_TIM2_stop(void)
\r
316 TIMER_BITBAND->TIM2ENABLE = 0u; /* disable timer */
\r
319 /*-------------------------------------------------------------------------*//**
\r
320 The MSS_TIM2_get_current_value() returns the current value of the Timer 2
\r
323 static __INLINE uint32_t MSS_TIM2_get_current_value(void)
\r
325 return TIMER->TIM2_VAL;
\r
328 /*-------------------------------------------------------------------------*//**
\r
329 The MSS_TIM2_load_immediate() function loads the value passed by the
\r
330 load_value parameter into the Timer 2 down-counter. The counter will decrement
\r
331 immediately from this value once Timer 2 is enabled. The MSS Timer will
\r
332 generate an interrupt when the counter reaches zero if Timer 2 interrupts are
\r
333 enabled. This function is intended to be used when Timer 2 is configured for
\r
334 one-shot mode to time a single delay.
\r
337 The load_value parameter specifies the value from which the Timer 2
\r
338 down-counter will start decrementing.
\r
340 static __INLINE void MSS_TIM2_load_immediate(uint32_t load_value)
\r
342 TIMER->TIM2_LOADVAL = load_value;
\r
345 /*-------------------------------------------------------------------------*//**
\r
346 The MSS_TIM2_load_background() function is used to specify the value that will
\r
347 be reloaded into the Timer 2 down-counter the next time the counter reaches
\r
348 zero. This function is typically used when Timer 2 is configured for periodic
\r
349 mode operation to select or change the delay period between the interrupts
\r
350 generated by Timer 2.
\r
353 The load_value parameter specifies the value that will be loaded into the
\r
354 Timer 2 down-counter the next time the down-counter reaches zero. The Timer
\r
355 2 down-counter will start decrementing from this value after the current
\r
358 static __INLINE void MSS_TIM2_load_background(uint32_t load_value)
\r
360 TIMER->TIM2_BGLOADVAL = load_value;
\r
363 /*-------------------------------------------------------------------------*//**
\r
364 The MSS_TIM2_enable_irq() function is used to enable interrupt generation for
\r
365 Timer 2. This function also enables the interrupt in the Cortex-M3 interrupt
\r
366 controller. The Timer2_IRQHandler() function will be called when a Timer 2
\r
368 Note: A Timer2_IRQHandler() default implementation is defined, with weak
\r
369 linkage, in the SmartFusion2 CMSIS-PAL. You must provide your own implementation
\r
370 of the Timer2_IRQHandler() function, that will override the default
\r
371 implementation, to suit your application.
\r
373 static __INLINE void MSS_TIM2_enable_irq(void)
\r
375 TIMER_BITBAND->TIM2INTEN = 1u;
\r
376 NVIC_EnableIRQ( Timer2_IRQn );
\r
379 /*-------------------------------------------------------------------------*//**
\r
380 The MSS_TIM2_disable_irq() function is used to disable interrupt generation
\r
381 for Timer 2. This function also disables the interrupt in the Cortex-M3
\r
382 interrupt controller.
\r
384 static __INLINE void MSS_TIM2_disable_irq(void)
\r
386 TIMER_BITBAND->TIM2INTEN = 0u;
\r
387 NVIC_DisableIRQ(Timer2_IRQn);
\r
390 /*-------------------------------------------------------------------------*//**
\r
391 The MSS_TIM2_clear_irq() function is used to clear a pending interrupt from
\r
392 Timer 2. This function also clears the interrupt in the Cortex-M3 interrupt
\r
394 Note: You must call the MSS_TIM2_clear_irq() function as part of your
\r
395 implementation of the Timer2_IRQHandler() Timer 2 interrupt service routine
\r
396 (ISR) in order to prevent the same interrupt event retriggering a call to the
\r
399 static __INLINE void MSS_TIM2_clear_irq(void)
\r
401 TIMER->TIM2_RIS = 1u;
\r
404 /*-------------------------------------------------------------------------*//**
\r
405 The MSS_TIM64_init() function initializes the SmartFusion2 MSS Timer block for
\r
406 use as a single 64-bit timer and selects the operating mode of the timer. This
\r
407 function takes the MSS Timer block out of reset in case this hasn
\92t been done
\r
408 already, stops the timer, disables its interrupts and sets the timer's
\r
410 Note: Please note that the SmartFusion2 MSS Timer block cannot be used both as
\r
411 a 64-bit and 32-bit timer. Calling MSS_TIM64_init() will overwrite any previous
\r
412 configuration of the MSS Timer as a 32-bit timer.
\r
415 The mode parameter specifies whether the timer will operate in periodic or
\r
416 one-shot mode. Allowed values for this parameter are:
\r
417 - MSS_TIMER_PERIODIC_MODE
\r
418 - MSS_TIMER_ONE_SHOT_MODE
\r
420 static __INLINE void MSS_TIM64_init(mss_timer_mode_t mode)
\r
422 NVIC_DisableIRQ(Timer1_IRQn); /* disable timer 1 interrupt within NVIC */
\r
423 NVIC_DisableIRQ(Timer2_IRQn); /* disable timer 2 interrupt within NVIC */
\r
425 SYSREG->SOFT_RST_CR &= ~SYSREG_TIMER_SOFTRESET_MASK; /* Take timer block out of reset */
\r
427 TIMER->TIM64_MODE = 1u; /* switch to 64 bits mode */
\r
429 TIMER_BITBAND->TIM64ENABLE = 0u; /* disable timer */
\r
430 TIMER_BITBAND->TIM64INTEN = 0u; /* disable interrupt */
\r
431 TIMER_BITBAND->TIM64MODE = (uint32_t)mode; /* set mode (continuous/one-shot) */
\r
433 TIMER->TIM1_RIS = 1u; /* clear timer 1 interrupt */
\r
434 TIMER->TIM2_RIS = 1u; /* clear timer 2 interrupt */
\r
435 NVIC_ClearPendingIRQ(Timer1_IRQn); /* clear timer 1 interrupt within NVIC */
\r
436 NVIC_ClearPendingIRQ(Timer2_IRQn); /* clear timer 2 interrupt within NVIC */
\r
439 /*-------------------------------------------------------------------------*//**
\r
440 The MSS_TIM64_start() function enables the 64-bit timer and starts its
\r
441 down-counter decrementing from the load_value specified in previous calls to
\r
442 the MSS_TIM64_load_immediate() or MSS_TIM64_load_background() functions.
\r
444 static __INLINE void MSS_TIM64_start(void)
\r
446 TIMER_BITBAND->TIM64ENABLE = 1u; /* enable timer */
\r
449 /*-------------------------------------------------------------------------*//**
\r
450 The MSS_TIM64_stop() function disables the 64-bit timer and stops its
\r
451 down-counter decrementing.
\r
453 static __INLINE void MSS_TIM64_stop(void)
\r
455 TIMER_BITBAND->TIM64ENABLE = 0u; /* disable timer */
\r
458 /*-------------------------------------------------------------------------*//**
\r
459 The MSS_TIM64_get_current_value() is used to read the current value of the
\r
460 64-bit timer down-counter.
\r
462 @param load_value_u
\r
463 The load_value_u parameter is a pointer to a 32-bit variable where the upper
\r
464 32 bits of the current value of the 64-bit timer down-counter will be copied.
\r
466 @param load_value_l
\r
467 The load_value_l parameter is a pointer to a 32-bit variable where the lower
\r
468 32 bits of the current value of the 64-bit timer down-counter will be copied.
\r
472 uint32_t current_value_u = 0;
\r
473 uint32_t current_value_l = 0;
\r
474 MSS_TIM64_get_current_value( ¤t_value_u, ¤t_value_l );
\r
477 static __INLINE void MSS_TIM64_get_current_value
\r
479 uint32_t * load_value_u,
\r
480 uint32_t * load_value_l
\r
483 *load_value_l = TIMER->TIM64_VAL_L;
\r
484 *load_value_u = TIMER->TIM64_VAL_U;
\r
487 /*-------------------------------------------------------------------------*//**
\r
488 The MSS_TIM64_load_immediate() function loads the values passed by the
\r
489 load_value_u and load_value_l parameters into the 64-bit timer down-counter.
\r
490 The counter will decrement immediately from the concatenated 64-bit value once
\r
491 the 64-bit timer is enabled. The MSS Timer will generate an interrupt when the
\r
492 counter reaches zero if 64-bit timer interrupts are enabled. This function is
\r
493 intended to be used when the 64-bit timer is configured for one-shot mode to
\r
494 time a single delay.
\r
496 @param load_value_u
\r
497 The load_value_u parameter specifies the upper 32 bits of the 64-bit timer
\r
498 load value from which the 64-bit timer down-counter will start decrementing.
\r
500 @param load_value_l
\r
501 The load_value_l parameter specifies the lower 32 bits of the 64-bit timer
\r
502 load value from which the 64-bit timer down-counter will start decrementing.
\r
504 static __INLINE void MSS_TIM64_load_immediate
\r
506 uint32_t load_value_u,
\r
507 uint32_t load_value_l
\r
510 TIMER->TIM64_LOADVAL_U = load_value_u;
\r
511 TIMER->TIM64_LOADVAL_L = load_value_l;
\r
514 /*-------------------------------------------------------------------------*//**
\r
515 The MSS_TIM64_load_background() function is used to specify the 64-bit value
\r
516 that will be reloaded into the 64-bit timer down-counter the next time the
\r
517 counter reaches zero. This function is typically used when the 64-bit timer is
\r
518 configured for periodic mode operation to select or change the delay period
\r
519 between the interrupts generated by the 64-bit timer.
\r
521 @param load_value_u
\r
522 The load_value_u parameter specifies the upper 32 bits of the 64-bit timer
\r
523 load value. The concatenated 64-bit value formed from load_value_u and
\r
524 load_value_l will be loaded into the 64-bit timer down-counter the next
\r
525 time the down-counter reaches zero. The 64-bit timer down-counter will start
\r
526 decrementing from the concatenated 64-bit value after the current count
\r
529 @param load_value_l
\r
530 The load_value_l parameter specifies the lower 32 bits of the 64-bit timer
\r
531 load value. The concatenated 64-bit value formed from load_value_u and
\r
532 load_value_l will be loaded into the 64-bit timer down-counter the next time
\r
533 the down-counter reaches zero. The 64-bit timer down-counter will start
\r
534 decrementing from the concatenated 64-bit value after the current count
\r
538 static __INLINE void MSS_TIM64_load_background
\r
540 uint32_t load_value_u,
\r
541 uint32_t load_value_l
\r
544 TIMER->TIM64_BGLOADVAL_U = load_value_u;
\r
545 TIMER->TIM64_BGLOADVAL_L = load_value_l;
\r
548 /*-------------------------------------------------------------------------*//**
\r
549 The MSS_TIM64_enable_irq() function is used to enable interrupt generation for
\r
550 the 64-bit timer. This function also enables the interrupt in the Cortex-M3
\r
551 interrupt controller. The Timer1_IRQHandler() function will be called when a
\r
552 64-bit timer interrupt occurs.
\r
553 Note: A Timer1_IRQHandler() default implementation is defined, with weak
\r
554 linkage, in the SmartFusion2 CMSIS-PAL. You must provide your own
\r
555 implementation of the Timer1_IRQHandler() function, that will override the
\r
556 default implementation, to suit your application.
\r
557 Note: The MSS_TIM64_enable_irq() function enables and uses Timer 1 interrupts
\r
558 for the 64-bit timer. Timer 2 interrupts remain disabled.
\r
560 static __INLINE void MSS_TIM64_enable_irq(void)
\r
562 TIMER_BITBAND->TIM64INTEN = 1u;
\r
563 NVIC_EnableIRQ(Timer1_IRQn);
\r
566 /*-------------------------------------------------------------------------*//**
\r
567 The MSS_TIM64_disable_irq() function is used to disable interrupt generation
\r
568 for the 64-bit timer. This function also disables the interrupt in the
\r
569 Cortex-M3 interrupt controller.
\r
571 static __INLINE void MSS_TIM64_disable_irq(void)
\r
573 TIMER_BITBAND->TIM64INTEN = 0u;
\r
574 NVIC_DisableIRQ(Timer1_IRQn);
\r
577 /*-------------------------------------------------------------------------*//**
\r
578 The MSS_TIM64_clear_irq() function is used to clear a pending interrupt from
\r
579 the 64-bit timer. This function also clears the interrupt in the Cortex-M3
\r
580 interrupt controller.
\r
581 Note: You must call the MSS_TIM64_clear_irq() function as part of your
\r
582 implementation of the Timer1_IRQHandler() 64-bit timer interrupt service
\r
583 routine (ISR) in order to prevent the same interrupt event retriggering a
\r
586 static __INLINE void MSS_TIM64_clear_irq(void)
\r
588 TIMER->TIM64_RIS = 1u;
\r
595 #endif /*MSS_TIMER_H_*/
\r