# mios32/MIOSJUCE/c++/mios32_timer.c File Reference

`#include <mios32.h>`
`#include <JUCEtimer.h>`

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

## Function Documentation

s32 MIOS32_TIMER_Init | ( | u8 | timer,
|  | u32 | period,
|  | 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

Here is the call graph for this function: