1 /*******************************************************************************
\r
2 * (c) Copyright 2009 Actel Corporation. All rights reserved.
\r
4 * SmartFusion microcontroller subsystem (MSS) timer driver API.
\r
6 * SVN $Revision: 2661 $
\r
7 * SVN $Date: 2010-04-19 17:14:26 +0100 (Mon, 19 Apr 2010) $
\r
9 /*=========================================================================*//**
\r
10 @mainpage SmartFusion MSS Timer Bare Metal Driver.
\r
12 @section intro_sec Introduction
\r
13 The SmartFusion 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 SmartFusion "Cortex Microcontroler Software
\r
25 Interface Standard - Peripheral Access Layer" (CMSIS-PAL) to access hadware
\r
26 registers. You must ensure that the SmartFusion 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 SmartFusion CMSIS-PAL files can be obtained using
\r
29 the Actel Firmware Catalog.
\r
30 The SmartFusion 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 SmartFusion 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/a2fxxxm3.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 SmartFusion 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 SmartFusion 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 SmartFusion 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
267 NVIC_ClearPendingIRQ( Timer1_IRQn );
\r
270 /*-------------------------------------------------------------------------*//**
\r
271 The MSS_TIM2_init() function initializes the SmartFusion MSS Timer block for
\r
272 use as a 32-bit timer and selects the operating mode for Timer 2. This function
\r
273 takes the MSS Timer block out of reset in case this hasn
\92t been done already,
\r
274 stops Timer 2, disables its interrupt and sets the Timer 2 operating mode.
\r
275 Note: Please note that the SmartFusion MSS Timer block cannot be used both as
\r
276 a 64-bit and 32-bit timer. Calling MSS_TIM2_init() will overwrite any previous
\r
277 configuration of the MSS Timer as a 64-bit timer.
\r
280 The mode parameter specifies whether the timer will operate in periodic or
\r
281 one-shot mode. Allowed values for this parameter are:
\r
282 - MSS_TIMER_PERIODIC_MODE
\r
283 - MSS_TIMER_ONE_SHOT_MODE
\r
285 static __INLINE void MSS_TIM2_init( mss_timer_mode_t mode )
\r
287 NVIC_DisableIRQ( Timer2_IRQn ); /* Disable timer 2 irq in the Cortex-M3 NVIC */
\r
289 SYSREG->SOFT_RST_CR &= ~SYSREG_TIMER_SOFTRESET_MASK; /* Take timer block out of reset */
\r
291 TIMER->TIM64_MODE = 0U; /* switch to 32 bits mode */
\r
293 TIMER_BITBAND->TIM2ENABLE = 0U; /* disable timer */
\r
294 TIMER_BITBAND->TIM2INTEN = 0U; /* disable interrupt */
\r
295 TIMER_BITBAND->TIM2MODE = (uint32_t)mode; /* set mode (continuous/one-shot) */
\r
297 TIMER->TIM2_RIS = 1U; /* clear timer 2 interrupt */
\r
298 NVIC_ClearPendingIRQ( Timer2_IRQn ); /* clear timer 2 interrupt within NVIC */
\r
301 /*-------------------------------------------------------------------------*//**
\r
302 The MSS_TIM2_start() function enables Timer 2 and starts its down-counter
\r
303 decrementing from the load_value specified in previous calls to the
\r
304 MSS_TIM2_load_immediate() or MSS_TIM2_load_background() functions.
\r
306 static __INLINE void MSS_TIM2_start( void )
\r
308 TIMER_BITBAND->TIM2ENABLE = 1U; /* enable timer */
\r
311 /*-------------------------------------------------------------------------*//**
\r
312 The MSS_TIM2_stop() function disables Timer 2 and stops its down-counter
\r
315 static __INLINE void MSS_TIM2_stop( void )
\r
317 TIMER_BITBAND->TIM2ENABLE = 0U; /* disable timer */
\r
320 /*-------------------------------------------------------------------------*//**
\r
321 The MSS_TIM2_get_current_value() returns the current value of the Timer 2
\r
324 static __INLINE uint32_t MSS_TIM2_get_current_value( void )
\r
326 return TIMER->TIM2_VAL;
\r
329 /*-------------------------------------------------------------------------*//**
\r
330 The MSS_TIM2_load_immediate() function loads the value passed by the
\r
331 load_value parameter into the Timer 2 down-counter. The counter will decrement
\r
332 immediately from this value once Timer 2 is enabled. The MSS Timer will
\r
333 generate an interrupt when the counter reaches zero if Timer 2 interrupts are
\r
334 enabled. This function is intended to be used when Timer 2 is configured for
\r
335 one-shot mode to time a single delay.
\r
338 The load_value parameter specifies the value from which the Timer 2
\r
339 down-counter will start decrementing.
\r
341 static __INLINE void MSS_TIM2_load_immediate( uint32_t load_value )
\r
343 TIMER->TIM2_LOADVAL = load_value;
\r
346 /*-------------------------------------------------------------------------*//**
\r
347 The MSS_TIM2_load_background() function is used to specify the value that will
\r
348 be reloaded into the Timer 2 down-counter the next time the counter reaches
\r
349 zero. This function is typically used when Timer 2 is configured for periodic
\r
350 mode operation to select or change the delay period between the interrupts
\r
351 generated by Timer 2.
\r
354 The load_value parameter specifies the value that will be loaded into the
\r
355 Timer 2 down-counter the next time the down-counter reaches zero. The Timer
\r
356 2 down-counter will start decrementing from this value after the current
\r
359 static __INLINE void MSS_TIM2_load_background( uint32_t load_value )
\r
361 TIMER->TIM2_BGLOADVAL = load_value;
\r
364 /*-------------------------------------------------------------------------*//**
\r
365 The MSS_TIM2_enable_irq() function is used to enable interrupt generation for
\r
366 Timer 2. This function also enables the interrupt in the Cortex-M3 interrupt
\r
367 controller. The Timer2_IRQHandler() function will be called when a Timer 2
\r
369 Note: A Timer2_IRQHandler() default implementation is defined, with weak
\r
370 linkage, in the SmartFusion CMSIS-PAL. You must provide your own implementation
\r
371 of the Timer2_IRQHandler() function, that will override the default
\r
372 implementation, to suit your application.
\r
374 static __INLINE void MSS_TIM2_enable_irq( void )
\r
376 TIMER_BITBAND->TIM2INTEN = 1U;
\r
377 NVIC_EnableIRQ( Timer2_IRQn );
\r
380 /*-------------------------------------------------------------------------*//**
\r
381 The MSS_TIM2_disable_irq() function is used to disable interrupt generation
\r
382 for Timer 2. This function also disables the interrupt in the Cortex-M3
\r
383 interrupt controller.
\r
385 static __INLINE void MSS_TIM2_disable_irq( void )
\r
387 TIMER_BITBAND->TIM2INTEN = 0U;
\r
388 NVIC_DisableIRQ( Timer2_IRQn );
\r
391 /*-------------------------------------------------------------------------*//**
\r
392 The MSS_TIM2_clear_irq() function is used to clear a pending interrupt from
\r
393 Timer 2. This function also clears the interrupt in the Cortex-M3 interrupt
\r
395 Note: You must call the MSS_TIM2_clear_irq() function as part of your
\r
396 implementation of the Timer2_IRQHandler() Timer 2 interrupt service routine
\r
397 (ISR) in order to prevent the same interrupt event retriggering a call to the
\r
400 static __INLINE void MSS_TIM2_clear_irq( void )
\r
402 TIMER->TIM2_RIS = 1U;
\r
403 NVIC_ClearPendingIRQ( Timer2_IRQn );
\r
406 /*-------------------------------------------------------------------------*//**
\r
407 The MSS_TIM64_init() function initializes the SmartFusion MSS Timer block for
\r
408 use as a single 64-bit timer and selects the operating mode of the timer. This
\r
409 function takes the MSS Timer block out of reset in case this hasn
\92t been done
\r
410 already, stops the timer, disables its interrupts and sets the timer's
\r
412 Note: Please note that the SmartFusion MSS Timer block cannot be used both as
\r
413 a 64-bit and 32-bit timer. Calling MSS_TIM64_init() will overwrite any previous
\r
414 configuration of the MSS Timer as a 32-bit timer.
\r
417 The mode parameter specifies whether the timer will operate in periodic or
\r
418 one-shot mode. Allowed values for this parameter are:
\r
419 - MSS_TIMER_PERIODIC_MODE
\r
420 - MSS_TIMER_ONE_SHOT_MODE
\r
422 static __INLINE void MSS_TIM64_init( mss_timer_mode_t mode )
\r
424 NVIC_DisableIRQ( Timer1_IRQn ); /* disable timer 1 interrupt within NVIC */
\r
425 NVIC_DisableIRQ( Timer2_IRQn ); /* disable timer 2 interrupt within NVIC */
\r
427 SYSREG->SOFT_RST_CR &= ~SYSREG_TIMER_SOFTRESET_MASK; /* Take timer block out of reset */
\r
429 TIMER->TIM64_MODE = 1U; /* switch to 64 bits mode */
\r
431 TIMER_BITBAND->TIM64ENABLE = 0U; /* disable timer */
\r
432 TIMER_BITBAND->TIM64INTEN = 0U; /* disable interrupt */
\r
433 TIMER_BITBAND->TIM64MODE = (uint32_t)mode; /* set mode (continuous/one-shot) */
\r
435 TIMER->TIM1_RIS = 1U; /* clear timer 1 interrupt */
\r
436 TIMER->TIM2_RIS = 1U; /* clear timer 2 interrupt */
\r
437 NVIC_ClearPendingIRQ( Timer1_IRQn ); /* clear timer 1 interrupt within NVIC */
\r
438 NVIC_ClearPendingIRQ( Timer2_IRQn ); /* clear timer 2 interrupt within NVIC */
\r
441 /*-------------------------------------------------------------------------*//**
\r
442 The MSS_TIM64_start() function enables the 64-bit timer and starts its
\r
443 down-counter decrementing from the load_value specified in previous calls to
\r
444 the MSS_TIM64_load_immediate() or MSS_TIM64_load_background() functions.
\r
446 static __INLINE void MSS_TIM64_start( void )
\r
448 TIMER_BITBAND->TIM64ENABLE = 1U; /* enable timer */
\r
451 /*-------------------------------------------------------------------------*//**
\r
452 The MSS_TIM64_stop() function disables the 64-bit timer and stops its
\r
453 down-counter decrementing.
\r
455 static __INLINE void MSS_TIM64_stop( void )
\r
457 TIMER_BITBAND->TIM64ENABLE = 0U; /* disable timer */
\r
460 /*-------------------------------------------------------------------------*//**
\r
461 The MSS_TIM64_get_current_value() is used to read the current value of the
\r
462 64-bit timer down-counter.
\r
464 @param load_value_u
\r
465 The load_value_u parameter is a pointer to a 32-bit variable where the upper
\r
466 32 bits of the current value of the 64-bit timer down-counter will be copied.
\r
468 @param load_value_l
\r
469 The load_value_l parameter is a pointer to a 32-bit variable where the lower
\r
470 32 bits of the current value of the 64-bit timer down-counter will be copied.
\r
474 uint32_t current_value_u = 0;
\r
475 uint32_t current_value_l = 0;
\r
476 MSS_TIM64_get_current_value( ¤t_value_u, ¤t_value_l );
\r
479 static __INLINE void MSS_TIM64_get_current_value
\r
481 uint32_t * load_value_u,
\r
482 uint32_t * load_value_l
\r
485 *load_value_l = TIMER->TIM64_VAL_L;
\r
486 *load_value_u = TIMER->TIM64_VAL_U;
\r
489 /*-------------------------------------------------------------------------*//**
\r
490 The MSS_TIM64_load_immediate() function loads the values passed by the
\r
491 load_value_u and load_value_l parameters into the 64-bit timer down-counter.
\r
492 The counter will decrement immediately from the concatenated 64-bit value once
\r
493 the 64-bit timer is enabled. The MSS Timer will generate an interrupt when the
\r
494 counter reaches zero if 64-bit timer interrupts are enabled. This function is
\r
495 intended to be used when the 64-bit timer is configured for one-shot mode to
\r
496 time a single delay.
\r
498 @param load_value_u
\r
499 The load_value_u parameter specifies the upper 32 bits of the 64-bit timer
\r
500 load value from which the 64-bit timer down-counter will start decrementing.
\r
502 @param load_value_l
\r
503 The load_value_l parameter specifies the lower 32 bits of the 64-bit timer
\r
504 load value from which the 64-bit timer down-counter will start decrementing.
\r
506 static __INLINE void MSS_TIM64_load_immediate
\r
508 uint32_t load_value_u,
\r
509 uint32_t load_value_l
\r
512 TIMER->TIM64_LOADVAL_U = load_value_u;
\r
513 TIMER->TIM64_LOADVAL_L = load_value_l;
\r
516 /*-------------------------------------------------------------------------*//**
\r
517 The MSS_TIM64_load_background() function is used to specify the 64-bit value
\r
518 that will be reloaded into the 64-bit timer down-counter the next time the
\r
519 counter reaches zero. This function is typically used when the 64-bit timer is
\r
520 configured for periodic mode operation to select or change the delay period
\r
521 between the interrupts generated by the 64-bit timer.
\r
523 @param load_value_u
\r
524 The load_value_u parameter specifies the upper 32 bits of the 64-bit timer
\r
525 load value. The concatenated 64-bit value formed from load_value_u and
\r
526 load_value_l will be loaded into the 64-bit timer down-counter the next
\r
527 time the down-counter reaches zero. The 64-bit timer down-counter will start
\r
528 decrementing from the concatenated 64-bit value after the current count
\r
531 @param load_value_l
\r
532 The load_value_l parameter specifies the lower 32 bits of the 64-bit timer
\r
533 load value. The concatenated 64-bit value formed from load_value_u and
\r
534 load_value_l will be loaded into the 64-bit timer down-counter the next time
\r
535 the down-counter reaches zero. The 64-bit timer down-counter will start
\r
536 decrementing from the concatenated 64-bit value after the current count
\r
540 static __INLINE void MSS_TIM64_load_background
\r
542 uint32_t load_value_u,
\r
543 uint32_t load_value_l
\r
546 TIMER->TIM64_BGLOADVAL_U = load_value_u;
\r
547 TIMER->TIM64_BGLOADVAL_L = load_value_l;
\r
550 /*-------------------------------------------------------------------------*//**
\r
551 The MSS_TIM64_enable_irq() function is used to enable interrupt generation for
\r
552 the 64-bit timer. This function also enables the interrupt in the Cortex-M3
\r
553 interrupt controller. The Timer1_IRQHandler() function will be called when a
\r
554 64-bit timer interrupt occurs.
\r
555 Note: A Timer1_IRQHandler() default implementation is defined, with weak
\r
556 linkage, in the SmartFusion CMSIS-PAL. You must provide your own
\r
557 implementation of the Timer1_IRQHandler() function, that will override the
\r
558 default implementation, to suit your application.
\r
559 Note: The MSS_TIM64_enable_irq() function enables and uses Timer 1 interrupts
\r
560 for the 64-bit timer. Timer 2 interrupts remain disabled.
\r
562 static __INLINE void MSS_TIM64_enable_irq( void )
\r
564 TIMER_BITBAND->TIM64INTEN = 1U;
\r
565 NVIC_EnableIRQ( Timer1_IRQn );
\r
568 /*-------------------------------------------------------------------------*//**
\r
569 The MSS_TIM64_disable_irq() function is used to disable interrupt generation
\r
570 for the 64-bit timer. This function also disables the interrupt in the
\r
571 Cortex-M3 interrupt controller.
\r
573 static __INLINE void MSS_TIM64_disable_irq( void )
\r
575 TIMER_BITBAND->TIM64INTEN = 0U;
\r
576 NVIC_DisableIRQ( Timer1_IRQn );
\r
579 /*-------------------------------------------------------------------------*//**
\r
580 The MSS_TIM64_clear_irq() function is used to clear a pending interrupt from
\r
581 the 64-bit timer. This function also clears the interrupt in the Cortex-M3
\r
582 interrupt controller.
\r
583 Note: You must call the MSS_TIM64_clear_irq() function as part of your
\r
584 implementation of the Timer1_IRQHandler() 64-bit timer interrupt service
\r
585 routine (ISR) in order to prevent the same interrupt event retriggering a
\r
588 static __INLINE void MSS_TIM64_clear_irq( void )
\r
590 TIMER->TIM64_RIS = 1U;
\r
591 NVIC_ClearPendingIRQ( Timer1_IRQn );
\r
598 #endif /*MSS_TIMER_H_*/
\r