60 lines
1.4 KiB
C
60 lines
1.4 KiB
C
/*
|
|
******************************************************************************
|
|
*
|
|
* @file pwm.h
|
|
* @brief pwm module
|
|
* @ic sy8835
|
|
*
|
|
* @version 1.0
|
|
* @date 2024/11/01 09:59:40
|
|
* @author Alex Xu
|
|
*
|
|
* Copyright (c) 2013-2099,Tkplusemi Technology Co.,Ltd.
|
|
* All Rights Reserved
|
|
*
|
|
* History:
|
|
* Revision Date Author Desc
|
|
* 1.0.0 2024/11/01 Alex build this file
|
|
******************************************************************************
|
|
*/
|
|
|
|
#ifndef __PWM_H__
|
|
#define __PWM_H__
|
|
|
|
#include "define.h"
|
|
|
|
#ifdef PWM_ENABLE
|
|
/* PWM Channels */
|
|
typedef enum {
|
|
|
|
PWM_CH0 = 0x00,
|
|
PWM_CH1,
|
|
PWM_CH2,
|
|
PWM_CH3,
|
|
PWM_ALL
|
|
}Pwm_Channels_e;
|
|
|
|
/* PWM Parameters Config */
|
|
|
|
typedef struct {
|
|
|
|
uint8_t nPWM_PRE; //PWM Clock Precale Set --- clock divide 2^n(n:0-7)
|
|
uint8_t nPWM_REL; //PWM counter reload value --- Fre(0-255)
|
|
uint8_t nPWM_CMP; //PWM compare value --- duty (0-255)
|
|
|
|
}s_gPWM_Para_Cfg;
|
|
|
|
#define PWM_REL_VALUE 105 //Feq:KK ,PWM_REL = 255 - 1.5M / 6K = 255-250 = 5£¬nPWM_CMP = 5 + 250 * (1-50%) = 130¡£
|
|
#define PWM_REL_FULL 254
|
|
|
|
extern void PWM_Enable(void);
|
|
extern void PWM_Disable(Pwm_Channels_e nPWM_Ch);
|
|
extern void PWM_Init_Set(uint8_t nPWM_PRE,uint8_t nPWM_REL);
|
|
extern void PWM_Duty_Set(Pwm_Channels_e nPWM_Ch,uint8_t nPWM_CMP);
|
|
extern void HuXi_Led(Pwm_Channels_e nPWM_Ch, uint8_t Delay_Timer);
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|