summaryrefslogtreecommitdiff
path: root/bsp/wch/arm/ch579m/libraries/StdPeriphDriver/inc/CH57x_pwm.h
blob: 7d524e07fe16a0e7c76628c035de0f14b17c107b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80



#ifndef __CH57x_PWM_H__
#define __CH57x_PWM_H__

#ifdef __cplusplus
 extern "C" {
#endif

#include "CH579SFR.h"
#include "core_cm0.h"

/**
  * @brief  channel of PWM define
  */

#define CH_PWM4     0x01                // PWM4 通道
#define CH_PWM5     0x02                // PWM5 通道
#define CH_PWM6     0x04                // PWM6 通道
#define CH_PWM7     0x08                // PWM7 通道
#define CH_PWM8     0x10                // PWM8 通道
#define CH_PWM9     0x20                // PWM9 通道
#define CH_PWM10    0x40                // PWM10 通道
#define CH_PWM11    0x80                // PWM11 通道



/**
  * @brief  channel of PWM define
  */
typedef enum
{
    High_Level = 0,                     // 默认低电平,高电平有效
    Low_Level,                          // 默认高电平,低电平有效
}PWMX_PolarTypeDef;


/**
  * @brief  Configuration PWM4_11 Cycle size
  */
typedef enum
{
    PWMX_Cycle_256 = 0,                 // 256 个PWMX周期
    PWMX_Cycle_255,                     // 255 个PWMX周期
    PWMX_Cycle_128,                     // 128 个PWMX周期
    PWMX_Cycle_127,                     // 127 个PWMX周期
    PWMX_Cycle_64,                      // 64 个PWMX周期
    PWMX_Cycle_63,                      // 63 个PWMX周期
    PWMX_Cycle_32,                      // 32 个PWMX周期
    PWMX_Cycle_31,                      // 31 个PWMX周期
}PWMX_CycleTypeDef;


#define PWMX_CLKCfg( d )            (R8_PWM_CLOCK_DIV=d)                /* PWM4-PWM11 通道基准时钟配置,= d*Tsys */
void PWMX_CycleCfg( PWMX_CycleTypeDef cyc );                            /* PWM4-PWM11 通道输出波形周期配置 */

#define PWM4_ActDataWidth( d )      (R8_PWM4_DATA = d)                  /* PWM4 有效数据脉宽 */
#define PWM5_ActDataWidth( d )      (R8_PWM5_DATA = d)                  /* PWM5 有效数据脉宽 */
#define PWM6_ActDataWidth( d )      (R8_PWM6_DATA = d)                  /* PWM6 有效数据脉宽 */
#define PWM7_ActDataWidth( d )      (R8_PWM7_DATA = d)                  /* PWM7 有效数据脉宽 */
#define PWM8_ActDataWidth( d )      (R8_PWM8_DATA = d)                  /* PWM8 有效数据脉宽 */
#define PWM9_ActDataWidth( d )      (R8_PWM9_DATA = d)                  /* PWM9 有效数据脉宽 */
#define PWM10_ActDataWidth( d )     (R8_PWM10_DATA = d)                 /* PWM10 有效数据脉宽 */
#define PWM11_ActDataWidth( d )     (R8_PWM11_DATA = d)                 /* PWM11 有效数据脉宽 */

// 占空比 = 数据有效脉宽/波形周期
void PWMX_ACTOUT( UINT8 ch, UINT8 da, PWMX_PolarTypeDef pr, UINT8 s);   /* PWM4-PWM11通道输出波形配置 */
void PWMX_AlterOutCfg( UINT8 ch, UINT8 s);          /* PWM 交替输出模式配置 */





#ifdef __cplusplus
}
#endif

#endif  // __CH57x_PWM_H__