/**
******************************************************************************************************************************************************************************************
*@file                       user_timer.h
*@author         
*@data                       
*@version                    v1.0
*@par Copyright(c):
*
*@par History:
*     version:author,date,desc
*     v1.0   :create this file
*
*******************************************************************************************************************************************************************************************
*/
#ifndef _USER_TIMER_H_
#define _USER_TIMER_H_

#include "sdk_include.h"
typedef enum
{
    IDX_TIMER0,
	IDX_TIMER1,
	IDX_TIMER2,
	IDX_TIMER3,
	IDX_TIMER_NUM,
}timer_idx_t;

typedef struct
{
    uint32_t timer_period;
}timer_param_t;

typedef struct
{
    uint32_t timer_pwm_duty_cycle;
	uint32_t timer_pwm_hz;
}pwm_param_t;

typedef struct
{
    timer_idx_t    timer_idx;
    timer_param_t  timer_param;
    pwm_param_t    *pwm_param;
}timer_config_t;


typedef enum
{
    TIMER_START,
	TIMER_STOP,
}timer_cmd_t;



typedef  void (*timer_event_cbk_t)(timer_idx_t id);
	
void user_timer_init(void);

void timer_enable_ctrl_cmd(timer_type_def *timerx, timer_cmd_t new_state);

void timer_config(timer_type_def *timerx, timer_config_t *p_config, timer_event_cbk_t cbk);

void timer_clear_interrupt(timer_type_def *timerx);

bool timer_is_working(timer_type_def *timerx);

void timer_x_isr(timer_type_def *timerx,timer_idx_t timer_idx);

void timer_isr(void);
/*
* brief: start or stop a timer.
* param[0] : timer device index.
* param[1] : TIMER_START/TIMER_START.
*/
void timer_enable_ctrl_cmd_ex(ws_dev timer_dev, timer_cmd_t new_state);
void user_timer_set(timer_idx_t id,functional_state_t enable);

#endif
