/**
* @file:	 pwm_manage_cfg.h
* @brief:
* @author:	mingyea
* @version: V1.0.0
* @date:	 2016-03-22
* @history:
*	   1.
*  author:
*  version:
*  date:
*/
#ifndef _PWM_MANAGE_CFG_H_
#define _PWM_MANAGE_CFG_H_

#include "common_types.h"
#include "common_cfg.h"
#include "tim.h"
#include "system_config.h"
//#include "pwm.h"

typedef u16 pwm_duty_t;

typedef struct
{
	u8 base;
	u8 channel;
}pwm_cfg_tab_s;

extern const pwm_cfg_tab_s g_pwm_array_channel_tab[PWM_PYH_TOTAL_CHANNEL] ;

//真正
#define PHY_PWM_CHANNEL_ATM_CH1_EN		1u
#define PHY_PWM_CHANNEL_ATM_CH2_EN		1u
#define PHY_PWM_CHANNEL_ATM_CH3_EN		1u 
#define PHY_PWM_CHANNEL_ATM_CH4_EN		1u
#define PHY_PWM_CHANNEL_GPTM0_CH1_EN	1u
#define PHY_PWM_CHANNEL_GPTM0_CH2_EN	0u
#define PHY_PWM_CHANNEL_GPTM0_CH3_EN	0u
#define PHY_PWM_CHANNEL_GPTM0_CH4_EN	0u
#define PHY_PWM_CHANNEL_GPTM1_CH1_EN	1u
#define PHY_PWM_CHANNEL_GPTM1_CH2_EN	1u
#define PHY_PWM_CHANNEL_GPTM1_CH3_EN	1u
#define PHY_PWM_CHANNEL_GPTM1_CH4_EN	0u



//定义各pwm对应的应用通道

#define PWM_LOGIC_CHANNEL_LED_ILL PHY_PWM_CHANNEL_GPTM1_CH3

//#define PWM_LOGIC_CHANNEL_LED_IND PHY_PWM_CHANNEL_GPTM0_CH2

//#define PWM_LOGIC_CHANNEL_LED_L1 PHY_PWM_CHANNEL_ATM_CH1
#define PWM_LOGIC_CHANNEL_LED_L2 PHY_PWM_CHANNEL_ATM_CH2
#define PWM_LOGIC_CHANNEL_LED_R2 PHY_PWM_CHANNEL_ATM_CH3
//#define PWM_LOGIC_CHANNEL_LED_R1 PHY_PWM_CHANNEL_ATM_CH4
#define PWM_LOGIC_CHANNEL_LED_LH PHY_PWM_CHANNEL_GPTM1_CH1
#define PWM_LOGIC_CHANNEL_LED_RH PHY_PWM_CHANNEL_GPTM1_CH2

#define PWM_LOGIC_CHANNEL_HS PHY_PWM_CHANNEL_GPTM0_CH1

#define SET_ATM1_PWM_DUTY_PERCENT(percent)		(u16)(percent*FL_ATIM_PWM_FREQ/1000)
#define SET_GPTIM0_PWM_DUTY_PERCENT(percent)	(u16)(percent*FL_GPTIM_PWM_FREQ/1000)
#define SET_GPTIM1_PWM_DUTY_PERCENT(percent)	(u16)(percent*FL_GPTIM1_PWM_FREQ/1000)
#define SET_GPTIM2_PWM_DUTY_PERCENT(percent)	(u16)(percent*FL_GPTIM2_PWM_FREQ/1000)
#define SET_LPT32_PWM_DUTY_PERCENT(percent)		(u16)(percent*FL_LPT32_PWM_FREQ/1000)
//测试上电就输出
#define PWM_LOGIC_CHANNEL_LED_DEBUG

#endif

