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

#ifdef __cplusplus
 extern "C" {
#endif

/* Includes ------------------------------------------------------------------*/
#include "cpu.h"

typedef enum
{
    PWM_0,
    PWM_1,
}PWM_x;

typedef struct
{
	uint32_t timer_period;
	functional_state_t TIMER_PWMCmd;
	uint32_t TIMER_PWM_duty_cycle;
	uint32_t TIMER_PWM_Hz;
	
} timer_init_type_def;       

void timer_init(timer_type_def* timerx, timer_init_type_def* timer_init_struct);
void timer_pwm_init(uint8_t pwmx, timer_init_type_def* timer_init_struct);
void timer_cmd(timer_type_def* timerx, functional_state_t new_state);
void timer_it_config(timer_type_def* timerx,functional_state_t new_state);
void timer_clear_it_pending_bit(timer_type_def* timerx);
itstatus timer_get_it_status(timer_type_def* timerx);

flag_status timer_get_flag_status(timer_type_def* timerx);
void timer_clear_flag(timer_type_def* timerx);

void timer_set_period(timer_type_def* timerx,uint32_t Period);
void timer_set_pwm_period(timer_type_def* timerx,uint32_t pwm_period);

void mdelay(uint32_t delay);
uint32_t get_tick(void);

uint32_t timer_get_current_count(timer_type_def * timerx);
void pwm_start(uint8_t pwmx, timer_init_type_def* timer_init_struct);
void pwm_stop(uint8_t PWMx);

#ifdef __cplusplus
}
#endif

#endif

