--- /dev/null
+/*******************************************************************************\r
+ * (c) Copyright 2009 Actel Corporation. All rights reserved.\r
+ * \r
+ * SmartFusion microcontroller subsystem (MSS) timer driver API.\r
+ *\r
+ * SVN $Revision: 2661 $\r
+ * SVN $Date: 2010-04-19 17:14:26 +0100 (Mon, 19 Apr 2010) $\r
+ */\r
+/*=========================================================================*//**\r
+ @mainpage SmartFusion MSS Timer Bare Metal Driver.\r
+\r
+ @section intro_sec Introduction\r
+ The SmartFusion Microcontroller Subsystem (MSS) includes a timer hardware\r
+ block which can be used as two independent 32-bits timers or as a single\r
+ 64-bits timer in periodic or one-shot mode. \r
+\r
+ This driver provides a set of functions for controlling the MSS timer as part\r
+ of a bare metal system where no operating system is available. These drivers\r
+ can be adapted for use as part of an operating system but the implementation\r
+ of the adaptation layer between this driver and the operating system's driver\r
+ model is outside the scope of this driver.\r
+ \r
+ @section theory_op Theory of Operation\r
+ The MSS Timer driver uses the SmartFusion "Cortex Microcontroler Software\r
+ Interface Standard - Peripheral Access Layer" (CMSIS-PAL) to access hadware\r
+ registers. You must ensure that the SmartFusion CMSIS-PAL is either included\r
+ in the software toolchain used to build your project or is included in your\r
+ project. The most up-to-date SmartFusion CMSIS-PAL files can be obtained using\r
+ the Actel Firmware Catalog.\r
+ The SmartFusion MSS Timer can be used in one of two mutually exclusive modes;\r
+ either as a single 64-bits timer or as two independent 32-bits timers. The MSS\r
+ Timer can be used in either periodic mode or one-shot mode. A timer configured\r
+ for periodic mode operations will generate an interrupt and reload its\r
+ down-counter when it reaches 0. The timer will then continue decrementing from\r
+ its reload value without waiting for the interrupt to be cleared. A timer\r
+ configured for one-shot mode will only generate an interrupt once when its\r
+ down-counter reaches 0. It must be explitcitly reloaded to start decrementing\r
+ again.\r
+ \r
+ The MSS Timer driver functions are grouped into the following categories:\r
+ - Initialization and Configuration\r
+ - Timer control\r
+ - Interrupt control\r
+ \r
+ The MSS Timer driver provides three initialization functions:\r
+ - MSS_TIM1_init()\r
+ - MSS_TIM2_init()\r
+ - MSS_TIM64_init()\r
+ The MSS Timer driver is initialized through calls to these functions and at\r
+ least one of them must be called before any other MSS Timer driver functions\r
+ can be called.\r
+ You should only use the MSS_TIM1_init() and MSS_TIM2_init() functions if you\r
+ intend to use the timer in 32-bits mode. Use the MSS_TIM64_init() function is\r
+ you intend to use the MSS Timer as a single 64-bits timer. The initialization\r
+ functions take a single parameter specifying the operating mode of the timer\r
+ being initialized.\r
+ \r
+ Once initialized a timer can be controlled using the following functions:\r
+ - MSS_TIM1_load_immediate()\r
+ - MSS_TIM1_load_background()\r
+ - MSS_TIM1_get_current_value()\r
+ - MSS_TIM1_start()\r
+ - MSS_TIM1_stop()\r
+ - MSS_TIM2_load_immediate()\r
+ - MSS_TIM2_load_background()\r
+ - MSS_TIM2_get_current_value()\r
+ - MSS_TIM2_start()\r
+ - MSS_TIM2_stop()\r
+ - MSS_TIM64_load_immediate()\r
+ - MSS_TIM64_load_background()\r
+ - MSS_TIM64_get_current_value()\r
+ - MSS_TIM64_start()\r
+ - MSS_TIM64_stop()\r
+ \r
+ Timer interrupts are controlled using the following functions:\r
+ - MSS_TIM1_enable_irq()\r
+ - MSS_TIM1_disable_irq()\r
+ - MSS_TIM1_clear_irq()\r
+ - MSS_TIM2_enable_irq()\r
+ - MSS_TIM2_disable_irq()\r
+ - MSS_TIM2_clear_irq()\r
+ - MSS_TIM64_enable_irq()\r
+ - MSS_TIM64_disable_irq()\r
+ - MSS_TIM64_clear_irq()\r
+ \r
+ The function prototypes for the timer interrupt handlers are:\r
+ - void Timer1_IRQHandler( void )\r
+ - void Timer2_IRQHandler( void )\r
+ Entries for these interrupt handlers are provided in the SmartFusion CMSIS-PAL\r
+ vector table. To add a Timer 1 interrupt handler, you must implement a\r
+ Timer1_IRQHandler( ) function as part of your application code. To add a\r
+ Timer 2 interrupt handler, you must implement a Timer2_IRQHandler( ) function\r
+ as part of your application code. When using the MSS Timer as a 64-bit timer,\r
+ you must implement a Timer1_IRQHandler( ) function as part of your\r
+ application code. The Timer 2 interrupt is not used when the MSS Timer is\r
+ configured as a 64-bit timer.\r
+ \r
+ *//*=========================================================================*/\r
+#ifndef MSS_TIMER_H_\r
+#define MSS_TIMER_H_\r
+\r
+\r
+#include "../../CMSIS/a2fxxxm3.h"\r
+\r
+#ifdef __cplusplus\r
+extern "C" {\r
+#endif \r
+\r
+/*-------------------------------------------------------------------------*//**\r
+ * Timer mode selection. This enumeration is used to select between the two\r
+ * possible timer modes of operation: periodic and one-shot mode. It is used as\r
+ * an argument to the MSS_TIM1_init(), MSS_TIM2_init() and MSS_TIM64_init()\r
+ * functions.\r
+ * MSS_TIMER_PERIODIC_MODE:\r
+ * In periodic mode the timer generates interrupts at constant intervals. On \r
+ * reaching zero, the timer's counter is reloaded with a value held in a\r
+ * register and begins counting down again.\r
+ * MSS_TIMER_ONE_SHOT_MODE:\r
+ * The timer generates a single interrupt in this mode. On reaching zero, the\r
+ * timer's counter halts until reprogrammed by the user.\r
+ */\r
+typedef enum __mss_timer_mode_t\r
+{\r
+ MSS_TIMER_PERIODIC_MODE = 0,\r
+ MSS_TIMER_ONE_SHOT_MODE = 1\r
+} mss_timer_mode_t;\r
+\r
+/*-------------------------------------------------------------------------*//**\r
+ The MSS_TIM1_init() function initializes the SmartFusion MSS Timer block for\r
+ use as a 32-bit timer and selects the operating mode for Timer 1. This function\r
+ takes the MSS Timer block out of reset in case this hasn\92t been done already,\r
+ stops Timer 1, disables its interrupt and sets the Timer 1 operating mode.\r
+ Please note that the SmartFusion MSS Timer block cannot be used both as a\r
+ 64-bit and 32-bit timer. Calling MSS_TIM1_init() will overwrite any previous\r
+ configuration of the MSS Timer as a 64-bit timer.\r
+\r
+ \r
+ @param mode\r
+ The mode parameter specifies whether the timer will operate in periodic or\r
+ one-shot mode. Allowed values for this parameter are:\r
+ - MSS_TIMER_PERIODIC_MODE\r
+ - MSS_TIMER_ONE_SHOT_MODE\r
+ */\r
+static __INLINE void MSS_TIM1_init( mss_timer_mode_t mode )\r
+{\r
+ NVIC_DisableIRQ( Timer1_IRQn ); /* Disable timer 1 irq in the Cortex-M3 NVIC */ \r
+ \r
+ SYSREG->SOFT_RST_CR &= ~SYSREG_TIMER_SOFTRESET_MASK; /* Take timer block out of reset */\r
+ \r
+ TIMER->TIM64_MODE = 0U; /* switch to 32 bits mode */\r
+ \r
+ TIMER_BITBAND->TIM1ENABLE = 0U; /* disable timer */\r
+ TIMER_BITBAND->TIM1INTEN = 0U; /* disable interrupt */\r
+ TIMER_BITBAND->TIM1MODE = (uint32_t)mode; /* set mode (continuous/one-shot) */\r
+ \r
+ TIMER->TIM1_RIS = 1U; /* clear timer 1 interrupt */\r
+ NVIC_ClearPendingIRQ( Timer1_IRQn ); /* clear timer 1 interrupt within NVIC */\r
+}\r
+\r
+/*-------------------------------------------------------------------------*//**\r
+ The MSS_TIM1_start() function enables Timer 1 and starts its down-counter\r
+ decrementing from the load_value specified in previous calls to the\r
+ MSS_TIM1_load_immediate() or MSS_TIM1_load_background() functions.\r
+ */\r
+static __INLINE void MSS_TIM1_start( void )\r
+{\r
+ TIMER_BITBAND->TIM1ENABLE = 1U; /* enable timer */\r
+}\r
+\r
+/*-------------------------------------------------------------------------*//**\r
+ The MSS_TIM1_stop() function disables Timer 1 and stops its down-counter\r
+ decrementing.\r
+ */\r
+static __INLINE void MSS_TIM1_stop( void )\r
+{\r
+ TIMER_BITBAND->TIM1ENABLE = 0U; /* disable timer */\r
+}\r
+\r
+/*-------------------------------------------------------------------------*//**\r
+ The MSS_TIM1_get_current_value() returns the current value of the Timer 1\r
+ down-counter.\r
+ \r
+ @return\r
+ This function returns the 32-bits current value of the Timer 1 down-counter.\r
+ */\r
+static __INLINE uint32_t MSS_TIM1_get_current_value( void )\r
+{\r
+ return TIMER->TIM1_VAL;\r
+}\r
+\r
+/*-------------------------------------------------------------------------*//**\r
+ The MSS_TIM1_load_immediate() function loads the value passed by the\r
+ load_value parameter into the Timer 1 down-counter. The counter will decrement\r
+ immediately from this value once Timer 1 is enabled. The MSS Timer will\r
+ generate an interrupt when the counter reaches zero if Timer 1 interrupts are\r
+ enabled. This function is intended to be used when Timer 1 is configured for\r
+ one-shot mode to time a single delay.\r
+ \r
+ @param load_value\r
+ The load_value parameter specifies the value from which the Timer 1 down-counter\r
+ will start decrementing from.\r
+ */\r
+static __INLINE void MSS_TIM1_load_immediate( uint32_t load_value )\r
+{\r
+ TIMER->TIM1_LOADVAL = load_value;\r
+}\r
+\r
+/*-------------------------------------------------------------------------*//**\r
+ The MSS_TIM1_load_background() function is used to specify the value that will\r
+ be reloaded into the Timer 1 down-counter the next time the counter reaches\r
+ zero. This function is typically used when Timer 1 is configured for periodic\r
+ mode operation to select or change the delay period between the interrupts\r
+ generated by Timer 1.\r
+ \r
+ @param load_value\r
+ The load_value parameter specifies the value that will be loaded into the\r
+ Timer 1 down-counter the next time the down-counter reaches zero. The Timer\r
+ 1 down-counter will start decrementing from this value after the current\r
+ count expires.\r
+ */\r
+static __INLINE void MSS_TIM1_load_background( uint32_t load_value )\r
+{\r
+ TIMER->TIM1_BGLOADVAL = load_value;\r
+}\r
+\r
+/*-------------------------------------------------------------------------*//**\r
+ The MSS_TIM1_enable_irq() function is used to enable interrupt generation for\r
+ Timer 1. This function also enables the interrupt in the Cortex-M3 interrupt\r
+ controller. The Timer1_IRQHandler() function will be called when a Timer 1\r
+ interrupt occurs.\r
+ Note: Note: A Timer1_IRQHandler() default implementation is defined, with\r
+ weak linkage, in the SmartFusion CMSIS-PAL. You must provide your own\r
+ implementation of the Timer1_IRQHandler() function, that will override the\r
+ default implementation, to suit your application.\r
+\r
+ */\r
+static __INLINE void MSS_TIM1_enable_irq( void )\r
+{\r
+ TIMER_BITBAND->TIM1INTEN = 1U;\r
+ NVIC_EnableIRQ( Timer1_IRQn );\r
+}\r
+\r
+/*-------------------------------------------------------------------------*//**\r
+ The MSS_TIM1_disable_irq() function is used to disable interrupt generation\r
+ for Timer 1. This function also disables the interrupt in the Cortex-M3\r
+ interrupt controller.\r
+ */\r
+static __INLINE void MSS_TIM1_disable_irq( void )\r
+{\r
+ TIMER_BITBAND->TIM1INTEN = 0U;\r
+ NVIC_DisableIRQ( Timer1_IRQn );\r
+}\r
+\r
+/*-------------------------------------------------------------------------*//**\r
+ The MSS_TIM1_clear_irq() function is used to clear a pending interrupt from\r
+ Timer 1. This function also clears the interrupt in the Cortex-M3 interrupt\r
+ controller.\r
+ Note: You must call the MSS_TIM1_clear_irq() function as part of your\r
+ implementation of the Timer1_IRQHandler() Timer 1 interrupt service routine\r
+ (ISR) in order to prevent the same interrupt event retriggering a call to the\r
+ ISR.\r
+\r
+ */\r
+static __INLINE void MSS_TIM1_clear_irq( void )\r
+{\r
+ TIMER->TIM1_RIS = 1U;\r
+ NVIC_ClearPendingIRQ( Timer1_IRQn );\r
+}\r
+\r
+/*-------------------------------------------------------------------------*//**\r
+ The MSS_TIM2_init() function initializes the SmartFusion MSS Timer block for\r
+ use as a 32-bit timer and selects the operating mode for Timer 2. This function\r
+ takes the MSS Timer block out of reset in case this hasn\92t been done already,\r
+ stops Timer 2, disables its interrupt and sets the Timer 2 operating mode.\r
+ Note: Please note that the SmartFusion MSS Timer block cannot be used both as\r
+ a 64-bit and 32-bit timer. Calling MSS_TIM2_init() will overwrite any previous\r
+ configuration of the MSS Timer as a 64-bit timer.\r
+ \r
+ @param mode\r
+ The mode parameter specifies whether the timer will operate in periodic or\r
+ one-shot mode. Allowed values for this parameter are:\r
+ - MSS_TIMER_PERIODIC_MODE\r
+ - MSS_TIMER_ONE_SHOT_MODE \r
+ */\r
+static __INLINE void MSS_TIM2_init( mss_timer_mode_t mode )\r
+{\r
+ NVIC_DisableIRQ( Timer2_IRQn ); /* Disable timer 2 irq in the Cortex-M3 NVIC */ \r
+ \r
+ SYSREG->SOFT_RST_CR &= ~SYSREG_TIMER_SOFTRESET_MASK; /* Take timer block out of reset */\r
+ \r
+ TIMER->TIM64_MODE = 0U; /* switch to 32 bits mode */\r
+ \r
+ TIMER_BITBAND->TIM2ENABLE = 0U; /* disable timer */\r
+ TIMER_BITBAND->TIM2INTEN = 0U; /* disable interrupt */\r
+ TIMER_BITBAND->TIM2MODE = (uint32_t)mode; /* set mode (continuous/one-shot) */\r
+ \r
+ TIMER->TIM2_RIS = 1U; /* clear timer 2 interrupt */\r
+ NVIC_ClearPendingIRQ( Timer2_IRQn ); /* clear timer 2 interrupt within NVIC */\r
+}\r
+\r
+/*-------------------------------------------------------------------------*//**\r
+ The MSS_TIM2_start() function enables Timer 2 and starts its down-counter\r
+ decrementing from the load_value specified in previous calls to the\r
+ MSS_TIM2_load_immediate() or MSS_TIM2_load_background() functions.\r
+ */\r
+static __INLINE void MSS_TIM2_start( void )\r
+{\r
+ TIMER_BITBAND->TIM2ENABLE = 1U; /* enable timer */\r
+}\r
+\r
+/*-------------------------------------------------------------------------*//**\r
+ The MSS_TIM2_stop() function disables Timer 2 and stops its down-counter\r
+ decrementing.\r
+ */\r
+static __INLINE void MSS_TIM2_stop( void )\r
+{\r
+ TIMER_BITBAND->TIM2ENABLE = 0U; /* disable timer */\r
+}\r
+\r
+/*-------------------------------------------------------------------------*//**\r
+ The MSS_TIM2_get_current_value() returns the current value of the Timer 2\r
+ down-counter.\r
+ */\r
+static __INLINE uint32_t MSS_TIM2_get_current_value( void )\r
+{\r
+ return TIMER->TIM2_VAL;\r
+}\r
+\r
+/*-------------------------------------------------------------------------*//**\r
+ The MSS_TIM2_load_immediate() function loads the value passed by the\r
+ load_value parameter into the Timer 2 down-counter. The counter will decrement\r
+ immediately from this value once Timer 2 is enabled. The MSS Timer will\r
+ generate an interrupt when the counter reaches zero if Timer 2 interrupts are\r
+ enabled. This function is intended to be used when Timer 2 is configured for\r
+ one-shot mode to time a single delay.\r
+ \r
+ @param load_value\r
+ The load_value parameter specifies the value from which the Timer 2\r
+ down-counter will start decrementing. \r
+ */\r
+static __INLINE void MSS_TIM2_load_immediate( uint32_t load_value )\r
+{\r
+ TIMER->TIM2_LOADVAL = load_value;\r
+}\r
+\r
+/*-------------------------------------------------------------------------*//**\r
+ The MSS_TIM2_load_background() function is used to specify the value that will\r
+ be reloaded into the Timer 2 down-counter the next time the counter reaches\r
+ zero. This function is typically used when Timer 2 is configured for periodic\r
+ mode operation to select or change the delay period between the interrupts\r
+ generated by Timer 2.\r
+ \r
+ @param load_value\r
+ The load_value parameter specifies the value that will be loaded into the\r
+ Timer 2 down-counter the next time the down-counter reaches zero. The Timer\r
+ 2 down-counter will start decrementing from this value after the current\r
+ count expires.\r
+ */\r
+static __INLINE void MSS_TIM2_load_background( uint32_t load_value )\r
+{\r
+ TIMER->TIM2_BGLOADVAL = load_value;\r
+}\r
+\r
+/*-------------------------------------------------------------------------*//**\r
+ The MSS_TIM2_enable_irq() function is used to enable interrupt generation for\r
+ Timer 2. This function also enables the interrupt in the Cortex-M3 interrupt\r
+ controller. The Timer2_IRQHandler() function will be called when a Timer 2\r
+ interrupt occurs.\r
+ Note: A Timer2_IRQHandler() default implementation is defined, with weak\r
+ linkage, in the SmartFusion CMSIS-PAL. You must provide your own implementation\r
+ of the Timer2_IRQHandler() function, that will override the default\r
+ implementation, to suit your application.\r
+ */\r
+static __INLINE void MSS_TIM2_enable_irq( void )\r
+{\r
+ TIMER_BITBAND->TIM2INTEN = 1U;\r
+ NVIC_EnableIRQ( Timer2_IRQn );\r
+}\r
+\r
+/*-------------------------------------------------------------------------*//**\r
+ The MSS_TIM2_disable_irq() function is used to disable interrupt generation\r
+ for Timer 2. This function also disables the interrupt in the Cortex-M3\r
+ interrupt controller.\r
+ */\r
+static __INLINE void MSS_TIM2_disable_irq( void )\r
+{\r
+ TIMER_BITBAND->TIM2INTEN = 0U;\r
+ NVIC_DisableIRQ( Timer2_IRQn );\r
+}\r
+\r
+/*-------------------------------------------------------------------------*//**\r
+ The MSS_TIM2_clear_irq() function is used to clear a pending interrupt from\r
+ Timer 2. This function also clears the interrupt in the Cortex-M3 interrupt\r
+ controller.\r
+ Note: You must call the MSS_TIM2_clear_irq() function as part of your\r
+ implementation of the Timer2_IRQHandler() Timer 2 interrupt service routine\r
+ (ISR) in order to prevent the same interrupt event retriggering a call to the\r
+ ISR.\r
+ */\r
+static __INLINE void MSS_TIM2_clear_irq( void )\r
+{\r
+ TIMER->TIM2_RIS = 1U;\r
+ NVIC_ClearPendingIRQ( Timer2_IRQn );\r
+}\r
+\r
+/*-------------------------------------------------------------------------*//**\r
+ The MSS_TIM64_init() function initializes the SmartFusion MSS Timer block for\r
+ use as a single 64-bit timer and selects the operating mode of the timer. This\r
+ function takes the MSS Timer block out of reset in case this hasn\92t been done\r
+ already, stops the timer, disables its interrupts and sets the timer's\r
+ operating mode.\r
+ Note: Please note that the SmartFusion MSS Timer block cannot be used both as\r
+ a 64-bit and 32-bit timer. Calling MSS_TIM64_init() will overwrite any previous\r
+ configuration of the MSS Timer as a 32-bit timer.\r
+\r
+ @param mode\r
+ The mode parameter specifies whether the timer will operate in periodic or\r
+ one-shot mode. Allowed values for this parameter are:\r
+ - MSS_TIMER_PERIODIC_MODE\r
+ - MSS_TIMER_ONE_SHOT_MODE \r
+ */\r
+static __INLINE void MSS_TIM64_init( mss_timer_mode_t mode )\r
+{\r
+ NVIC_DisableIRQ( Timer1_IRQn ); /* disable timer 1 interrupt within NVIC */\r
+ NVIC_DisableIRQ( Timer2_IRQn ); /* disable timer 2 interrupt within NVIC */\r
+ \r
+ SYSREG->SOFT_RST_CR &= ~SYSREG_TIMER_SOFTRESET_MASK; /* Take timer block out of reset */\r
+ \r
+ TIMER->TIM64_MODE = 1U; /* switch to 64 bits mode */\r
+ \r
+ TIMER_BITBAND->TIM64ENABLE = 0U; /* disable timer */\r
+ TIMER_BITBAND->TIM64INTEN = 0U; /* disable interrupt */\r
+ TIMER_BITBAND->TIM64MODE = (uint32_t)mode; /* set mode (continuous/one-shot) */\r
+ \r
+ TIMER->TIM1_RIS = 1U; /* clear timer 1 interrupt */\r
+ TIMER->TIM2_RIS = 1U; /* clear timer 2 interrupt */\r
+ NVIC_ClearPendingIRQ( Timer1_IRQn ); /* clear timer 1 interrupt within NVIC */\r
+ NVIC_ClearPendingIRQ( Timer2_IRQn ); /* clear timer 2 interrupt within NVIC */\r
+}\r
+\r
+/*-------------------------------------------------------------------------*//**\r
+ The MSS_TIM64_start() function enables the 64-bit timer and starts its\r
+ down-counter decrementing from the load_value specified in previous calls to\r
+ the MSS_TIM64_load_immediate() or MSS_TIM64_load_background() functions.\r
+ */\r
+static __INLINE void MSS_TIM64_start( void )\r
+{\r
+ TIMER_BITBAND->TIM64ENABLE = 1U; /* enable timer */\r
+}\r
+\r
+/*-------------------------------------------------------------------------*//**\r
+ The MSS_TIM64_stop() function disables the 64-bit timer and stops its\r
+ down-counter decrementing.\r
+ */\r
+static __INLINE void MSS_TIM64_stop( void )\r
+{\r
+ TIMER_BITBAND->TIM64ENABLE = 0U; /* disable timer */\r
+}\r
+\r
+/*-------------------------------------------------------------------------*//**\r
+ The MSS_TIM64_get_current_value() is used to read the current value of the\r
+ 64-bit timer down-counter. \r
+ \r
+ @param load_value_u\r
+ The load_value_u parameter is a pointer to a 32-bit variable where the upper\r
+ 32 bits of the current value of the 64-bit timer down-counter will be copied.\r
+ \r
+ @param load_value_l\r
+ The load_value_l parameter is a pointer to a 32-bit variable where the lower\r
+ 32 bits of the current value of the 64-bit timer down-counter will be copied.\r
+ \r
+ Example:\r
+ @code\r
+ uint32_t current_value_u = 0;\r
+ uint32_t current_value_l = 0;\r
+ MSS_TIM64_get_current_value( ¤t_value_u, ¤t_value_l );\r
+ @endcode\r
+ */\r
+static __INLINE void MSS_TIM64_get_current_value\r
+(\r
+ uint32_t * load_value_u,\r
+ uint32_t * load_value_l\r
+)\r
+{\r
+ *load_value_l = TIMER->TIM64_VAL_L;\r
+ *load_value_u = TIMER->TIM64_VAL_U;\r
+}\r
+\r
+/*-------------------------------------------------------------------------*//**\r
+ The MSS_TIM64_load_immediate() function loads the values passed by the\r
+ load_value_u and load_value_l parameters into the 64-bit timer down-counter.\r
+ The counter will decrement immediately from the concatenated 64-bit value once\r
+ the 64-bit timer is enabled. The MSS Timer will generate an interrupt when the\r
+ counter reaches zero if 64-bit timer interrupts are enabled. This function is\r
+ intended to be used when the 64-bit timer is configured for one-shot mode to\r
+ time a single delay.\r
+ \r
+ @param load_value_u\r
+ The load_value_u parameter specifies the upper 32 bits of the 64-bit timer\r
+ load value from which the 64-bit timer down-counter will start decrementing.\r
+ \r
+ @param load_value_l\r
+ The load_value_l parameter specifies the lower 32 bits of the 64-bit timer\r
+ load value from which the 64-bit timer down-counter will start decrementing.\r
+ */\r
+static __INLINE void MSS_TIM64_load_immediate\r
+(\r
+ uint32_t load_value_u,\r
+ uint32_t load_value_l\r
+)\r
+{\r
+ TIMER->TIM64_LOADVAL_U = load_value_u;\r
+ TIMER->TIM64_LOADVAL_L = load_value_l;\r
+}\r
+\r
+/*-------------------------------------------------------------------------*//**\r
+ The MSS_TIM64_load_background() function is used to specify the 64-bit value\r
+ that will be reloaded into the 64-bit timer down-counter the next time the\r
+ counter reaches zero. This function is typically used when the 64-bit timer is\r
+ configured for periodic mode operation to select or change the delay period\r
+ between the interrupts generated by the 64-bit timer.\r
+ \r
+ @param load_value_u\r
+ The load_value_u parameter specifies the upper 32 bits of the 64-bit timer\r
+ load value. The concatenated 64-bit value formed from load_value_u and\r
+ load_value_l will be loaded into the 64-bit timer down-counter the next\r
+ time the down-counter reaches zero. The 64-bit timer down-counter will start\r
+ decrementing from the concatenated 64-bit value after the current count\r
+ expires.\r
+ \r
+ @param load_value_l\r
+ The load_value_l parameter specifies the lower 32 bits of the 64-bit timer\r
+ load value. The concatenated 64-bit value formed from load_value_u and\r
+ load_value_l will be loaded into the 64-bit timer down-counter the next time\r
+ the down-counter reaches zero. The 64-bit timer down-counter will start\r
+ decrementing from the concatenated 64-bit value after the current count\r
+ expires.\r
+ \r
+ */\r
+static __INLINE void MSS_TIM64_load_background\r
+(\r
+ uint32_t load_value_u,\r
+ uint32_t load_value_l\r
+)\r
+{\r
+ TIMER->TIM64_BGLOADVAL_U = load_value_u;\r
+ TIMER->TIM64_BGLOADVAL_L = load_value_l;\r
+}\r
+\r
+/*-------------------------------------------------------------------------*//**\r
+ The MSS_TIM64_enable_irq() function is used to enable interrupt generation for\r
+ the 64-bit timer. This function also enables the interrupt in the Cortex-M3\r
+ interrupt controller. The Timer1_IRQHandler() function will be called when a\r
+ 64-bit timer interrupt occurs.\r
+ Note: A Timer1_IRQHandler() default implementation is defined, with weak\r
+ linkage, in the SmartFusion CMSIS-PAL. You must provide your own\r
+ implementation of the Timer1_IRQHandler() function, that will override the\r
+ default implementation, to suit your application.\r
+ Note: The MSS_TIM64_enable_irq() function enables and uses Timer 1 interrupts\r
+ for the 64-bit timer. Timer 2 interrupts remain disabled.\r
+ */\r
+static __INLINE void MSS_TIM64_enable_irq( void )\r
+{\r
+ TIMER_BITBAND->TIM64INTEN = 1U;\r
+ NVIC_EnableIRQ( Timer1_IRQn );\r
+}\r
+\r
+/*-------------------------------------------------------------------------*//**\r
+ The MSS_TIM64_disable_irq() function is used to disable interrupt generation\r
+ for the 64-bit timer. This function also disables the interrupt in the\r
+ Cortex-M3 interrupt controller.\r
+ */\r
+static __INLINE void MSS_TIM64_disable_irq( void )\r
+{\r
+ TIMER_BITBAND->TIM64INTEN = 0U;\r
+ NVIC_DisableIRQ( Timer1_IRQn );\r
+}\r
+\r
+/*-------------------------------------------------------------------------*//**\r
+ The MSS_TIM64_clear_irq() function is used to clear a pending interrupt from\r
+ the 64-bit timer. This function also clears the interrupt in the Cortex-M3\r
+ interrupt controller.\r
+ Note: You must call the MSS_TIM64_clear_irq() function as part of your\r
+ implementation of the Timer1_IRQHandler() 64-bit timer interrupt service\r
+ routine (ISR) in order to prevent the same interrupt event retriggering a\r
+ call to the ISR.\r
+ */\r
+static __INLINE void MSS_TIM64_clear_irq( void )\r
+{\r
+ TIMER->TIM64_RIS = 1U;\r
+ NVIC_ClearPendingIRQ( Timer1_IRQn );\r
+}\r
+\r
+#ifdef __cplusplus\r
+}\r
+#endif\r
+\r
+#endif /*MSS_TIMER_H_*/\r