# MIOS32_TIMER

## Defines
#define | TIM_PERIPHERAL_FRQ (MIOS32_SYS_CPU_FREQUENCY/4)
#define | NUM_TIMERS 3
#define | TIMER0_BASE LPC_TIM0
#define | TIMER0_IRQ TIMER0_IRQn
#define | TIMER0_IRQ_HANDLER void TIMER0_IRQHandler(void)
#define | TIMER1_BASE LPC_TIM1
#define | TIMER1_IRQ TIMER1_IRQn
#define | TIMER1_IRQ_HANDLER void TIMER1_IRQHandler(void)
#define | TIMER2_BASE LPC_TIM2
#define | TIMER2_IRQ TIMER2_IRQn
#define | TIMER2_IRQ_HANDLER void TIMER2_IRQHandler(void)
#define | NUM_TIMERS 3
#define | TIMER0_BASE TIM2
#define | TIMER0_RCC RCC_APB1Periph_TIM2
#define | TIMER0_IRQ TIM2_IRQn
#define | TIMER0_IRQ_HANDLER void TIM2_IRQHandler(void)
#define | TIMER1_BASE TIM3
#define | TIMER1_RCC RCC_APB1Periph_TIM3
#define | TIMER1_IRQ TIM3_IRQn
#define | TIMER1_IRQ_HANDLER void TIM3_IRQHandler(void)
#define | TIMER2_BASE TIM5
#define | TIMER2_RCC RCC_APB1Periph_TIM5
#define | TIMER2_IRQ TIM5_IRQn
#define | TIMER2_IRQ_HANDLER void TIM5_IRQHandler(void)
#define | TIM_PERIPHERAL_FRQ MIOS32_SYS_CPU_FREQUENCY
#define | NUM_TIMERS 3
#define | TIMER0_BASE TIM2
#define | TIMER0_RCC RCC_APB1Periph_TIM2
#define | TIMER0_IRQ TIM2_IRQn
#define | TIMER0_IRQ_HANDLER void TIM2_IRQHandler(void)
#define | TIMER1_BASE TIM3
#define | TIMER1_RCC RCC_APB1Periph_TIM3
#define | TIMER1_IRQ TIM3_IRQn
#define | TIMER1_IRQ_HANDLER void TIM3_IRQHandler(void)
#define | TIMER2_BASE TIM5
#define | TIMER2_RCC RCC_APB1Periph_TIM5
#define | TIMER2_IRQ TIM5_IRQn
#define | TIMER2_IRQ_HANDLER void TIM5_IRQHandler(void)
#define | TIM_PERIPHERAL_FRQ (MIOS32_SYS_CPU_FREQUENCY/2)
## Functions
s32 | MIOS32_TIMER_Init (u8 timer, u32 period, void(*_irq_handler)(void), u8 irq_priority)
s32 | MIOS32_TIMER_ReInit (u8 timer, u32 period)
s32 | MIOS32_TIMER_DeInit (u8 timer)

## Detailed Description

Timer functions for MIOS32

## Define Documentation

#define NUM_TIMERS 3

#define TIM_PERIPHERAL_FRQ (MIOS32_SYS_CPU_FREQUENCY/2)

#define TIM_PERIPHERAL_FRQ MIOS32_SYS_CPU_FREQUENCY

#define TIM_PERIPHERAL_FRQ (MIOS32_SYS_CPU_FREQUENCY/4)

#define TIMER0_BASE TIM2

#define TIMER0_BASE LPC_TIM0

#define TIMER0_IRQ TIM2_IRQn

#define TIMER0_IRQ TIMER0_IRQn

#define TIMER0_IRQ_HANDLER void TIM2_IRQHandler(void)

#define TIMER0_IRQ_HANDLER void TIMER0_IRQHandler(void)

#define TIMER0_RCC RCC_APB1Periph_TIM2

#define TIMER1_BASE TIM3

#define TIMER1_BASE LPC_TIM1

#define TIMER1_IRQ TIM3_IRQn

#define TIMER1_IRQ TIMER1_IRQn

#define TIMER1_IRQ_HANDLER void TIM3_IRQHandler(void)

#define TIMER1_IRQ_HANDLER void TIMER1_IRQHandler(void)

#define TIMER1_RCC RCC_APB1Periph_TIM3

#define TIMER2_BASE TIM5

#define TIMER2_BASE LPC_TIM2

#define TIMER2_IRQ TIM5_IRQn

#define TIMER2_IRQ TIMER2_IRQn

#define TIMER2_IRQ_HANDLER void TIM5_IRQHandler(void)

#define TIMER2_IRQ_HANDLER void TIMER2_IRQHandler(void)

#define TIMER2_RCC RCC_APB1Periph_TIM5

## Function Documentation

s32 MIOS32_TIMER_DeInit | ( | u8 | timer | ) |

De-Initialize a timer

Example:

       // disable timer
       MIOS32_TIMER_DeInit(0);

Parameters:

  `[in]` | timer | (0..2)

Returns:
  0 if timer has been disabled
  -1 if invalid timer number

s32 MIOS32_TIMER_Init | ( | u8 | timer,
|  | u32 | period,
|  | void(*)(void) | _irq_handler,
|  | u8 | irq_priority |
| ) |  |  |

Initialize a timer

Parameters:

  `[in]` | timer | (0..2) Timer allocation on STM32: 0=TIM2, 1=TIM3, 2=TIM5
  `[in]` | period | in uS accuracy (1..65536)
  `[in]` | _irq_handler | (function name)
  `[in]` | irq_priority,: | one of these values: MIOS32_IRQ_PRIO_LOW // lower than RTOS MIOS32_IRQ_PRIO_MID // higher than RTOS MIOS32_IRQ_PRIO_HIGH // same like SRIO, AIN, etc... MIOS32_IRQ_PRIO_HIGHEST // higher than SRIO, AIN, etc...

Example:

       // initialize timer for 1000 uS (= 1 mS) period
       MIOS32_TIMER_Init(0, 1000, MyTimer, MIOS32_IRQ_PRIO_MID);

this will call following function periodically:

     void MyTimer(void)
     {
        // your code
     }

Returns:
  0 if initialisation passed
  -1 if invalid timer number
  -2 if invalid period

Here is the call graph for this function:

s32 MIOS32_TIMER_ReInit | ( | u8 | timer,
|  | u32 | period |
| ) |  |  |

Re-Initialize a timer with given period

Example:

       // change timer period to 2 mS
       MIOS32_TIMER_ReInit(0, 2000);

Parameters:

  `[in]` | timer | (0..2) Timer allocation on STM32: 0=TIM2, 1=TIM3, 2=TIM5
  `[in]` | period | in uS accuracy (1..65536)

Returns:
  0 if initialisation passed
  if invalid timer number
  -2 if invalid period