/* Initializes the timer device, include timer registers and interrupt.  */
void gtimer_init(gtimer_t *obj, uint32_t tid)
/* Initializes the timer device, include timer registers and interrupt.  */
void gtimer_init(gtimer_t *obj, uint32_t tid)
{
	RTIM_TimeBaseInitTypeDef TIM_InitStruct;
	assert_param(tid < GTIMER_MAX);
	obj->timer_id = tid;
	RTIM_TimeBaseStructInit(&TIM_InitStruct);
	TIM_InitStruct.TIM_Idx = (u8)tid;
	TIM_InitStruct.TIM_UpdateEvent = ENABLE;
	TIM_InitStruct.TIM_UpdateSource = TIM_UpdateSource_Overflow;
	TIM_InitStruct.TIM_ARRProtection = ENABLE;
	RTIM_TimeBaseInit(TIMx[tid], &TIM_InitStruct, TIMx_irq[tid], (IRQ_FUN) gtimer_timeout_handler, (u32)obj);
}