8051-ELL库  beta 1.1.6
8051-ELL library API Document Center
STC8x_MPWM.h
浏览该文件的文档.
1 /*-----------------------------------------------------------------------
2 | FILE DESCRIPTION |
3 -----------------------------------------------------------------------*/
4 /*----------------------------------------------------------------------
5  - File name : STC8x_MPWM.h
6  - Author : slipperstree
7  - Update date : 2020.07.25
8  - Copyright(C) : 2020-2021 zeweni. All rights reserved.
9 -----------------------------------------------------------------------*/
10 /*------------------------------------------------------------------------
11 | COPYRIGHT NOTICE |
12 ------------------------------------------------------------------------*/
13 /*
14  * Copyright (C) 2021, zeweni (slipperstree@gmail.com)
15 
16  * This file is part of 8051 ELL low-layer libraries.
17 
18  * 8051 ELL low-layer libraries is free software: you can redistribute
19  * it and/or modify it under the terms of the Apache-2.0 License.
20 
21  * 8051 ELL low-layer libraries is distributed in the hope that it will
22  * be useful,but WITHOUT ANY WARRANTY; without even the implied warranty
23  * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24  * Apache-2.0 License License for more details.
25 
26  * You should have received a copy of the Apache-2.0 License.8051 ELL
27  * low-layer libraries. If not, see <http://www.apache.org/licenses/>.
28 **/
29 /*-----------------------------------------------------------------------
30 | INCLUDES |
31 -----------------------------------------------------------------------*/
32 #ifndef __STC8x_MPWM_H_
33 #define __STC8x_MPWM_H_
34 
35 /*--------------------------------------------------------
36 | @Description: STC8x core |
37 --------------------------------------------------------*/
38 #include "ELL_CORE.h"
39 
40 /*--------------------------------------------------------
41 | @Description: STC8x MCU Register |
42 --------------------------------------------------------*/
43 
44 #if (PER_LIB_MCU_MUODEL == STC8Gx)
45 
46  #include "STC8Gx_REG.h"
47 
48 #endif
49 
50 /*-----------------------------------------------------------------------
51 | DATA |
52 -----------------------------------------------------------------------*/
53 
54 #ifndef PER_LIB_MCU_MUODEL
57  #define PER_LIB_MCU_MUODEL STC8Gx
58 #endif
59 
60 
61 #ifndef PER_LIB_MPWM_CTRL
64  #define PER_LIB_MPWM_CTRL 1
65 #endif
66 
67 
68 #ifndef PER_LIB_MPWM_INIT_CTRL
71  #define PER_LIB_MPWM_INIT_CTRL 1
72 #endif
73 
74 
75 #ifndef PER_LIB_MPWM_NVIC_CTRL
78  #define PER_LIB_MPWM_NVIC_CTRL 1
79 #endif
80 
81 
82 #ifndef PER_LIB_MPWM_WORK_CTRL
85  #define PER_LIB_MPWM_WORK_CTRL 1
86 #endif
87 
88 
89 #if (PER_LIB_MCU_MUODEL == STC8Gx)
90 
91 
92  /*--------------------------------------------------------
93  | @Description: PWM clock source enum |
94  --------------------------------------------------------*/
95 
100  typedef enum
101  {
118  MPWM_TIMER2_PULSE = 0x1F
120 
121  /*--------------------------------------------------------
122  | @Description: PWM road start level configure enum |
123  --------------------------------------------------------*/
124 
125  typedef enum
126  {
128  MPWM_Start_High_Level = 0x01
130 
131  /*--------------------------------------------------------
132  | @Description: PWM port enum |
133  --------------------------------------------------------*/
134  typedef enum
135  {
136  MPWM_Port_0 = 0x00 ,
137  MPWM_Port_1 = 0x01 ,
138  MPWM_Port_2 = 0x02 ,
139  MPWM_Port_3 = 0x03 ,
140  MPWM_Port_4 = 0x04 ,
141  MPWM_Port_5 = 0x05
143 
144  /*--------------------------------------------------------
145  | @Description: PWM channel enum |
146  --------------------------------------------------------*/
147 
148  typedef enum
149  {
150  MPWM_Channel_0 = 0x00 ,
151  MPWM_Channel_1 = 0x01 ,
152  MPWM_Channel_2 = 0x02 ,
153  MPWM_Channel_3 = 0x03 ,
154  MPWM_Channel_4 = 0x04 ,
155  MPWM_Channel_5 = 0x05 ,
156  MPWM_Channel_6 = 0x06 ,
157  MPWM_Channel_7 = 0x07
159 
160 
161  /*-----------------------------------------------------------------------
162  | API FUNCTION |
163  -----------------------------------------------------------------------*/
164 
175 
189 
198 
207 
208 #endif
209 
210 /*-----------------------------------------------------------------------
211 | END OF FLIE. (C) COPYRIGHT zeweni |
212 -----------------------------------------------------------------------*/
213 #endif
BOOL
Definition: ELL_CORE.h:50
FSCSTATE
Definition: ELL_CORE.h:65
unsigned int uint16_t
Definition: ELL_TYPE.h:73
MPWMStartLevel_Type
Definition: STC8x_MPWM.h:126
@ MPWM_Start_High_Level
Definition: STC8x_MPWM.h:128
@ MPWM_Start_Low_Level
Definition: STC8x_MPWM.h:127
FSCSTATE MPWMn_Port_Init(MPWMPort_Type port, MPWMCLKSrc_Type clkSrc, uint16_t period)
PWM端口初始化函数。Init PWM port function.
Definition: STC8x_MPWM.c:208
FSCSTATE MPWMn_Stop(MPWMPort_Type port)
指定PWM端口停止工作。Stop specified PWM port working.
Definition: STC8x_MPWM.c:288
MPWMChannel_Type
Definition: STC8x_MPWM.h:149
@ MPWM_Channel_1
Definition: STC8x_MPWM.h:151
@ MPWM_Channel_0
Definition: STC8x_MPWM.h:150
@ MPWM_Channel_7
Definition: STC8x_MPWM.h:157
@ MPWM_Channel_2
Definition: STC8x_MPWM.h:152
@ MPWM_Channel_5
Definition: STC8x_MPWM.h:155
@ MPWM_Channel_3
Definition: STC8x_MPWM.h:153
@ MPWM_Channel_6
Definition: STC8x_MPWM.h:156
@ MPWM_Channel_4
Definition: STC8x_MPWM.h:154
FSCSTATE MPWMn_Channel_Init(MPWMPort_Type port, MPWMChannel_Type ch, MPWMStartLevel_Type level, uint16_t fValue, uint16_t sValue, BOOL run)
PWM通道初始化函数。Init PWM channel function.
Definition: STC8x_MPWM.c:234
MPWMPort_Type
Definition: STC8x_MPWM.h:135
@ MPWM_Port_5
Definition: STC8x_MPWM.h:141
@ MPWM_Port_0
Definition: STC8x_MPWM.h:136
@ MPWM_Port_2
Definition: STC8x_MPWM.h:138
@ MPWM_Port_1
Definition: STC8x_MPWM.h:137
@ MPWM_Port_4
Definition: STC8x_MPWM.h:140
@ MPWM_Port_3
Definition: STC8x_MPWM.h:139
MPWMCLKSrc_Type
MPWM系统时钟选择枚举体。
Definition: STC8x_MPWM.h:101
@ MPWM_SCLK_DIV_14
Definition: STC8x_MPWM.h:115
@ MPWM_SCLK_DIV_16
Definition: STC8x_MPWM.h:117
@ MPWM_SCLK_DIV_4
Definition: STC8x_MPWM.h:105
@ MPWM_SCLK_DIV_7
Definition: STC8x_MPWM.h:108
@ MPWM_TIMER2_PULSE
Definition: STC8x_MPWM.h:118
@ MPWM_SCLK_DIV_6
Definition: STC8x_MPWM.h:107
@ MPWM_SCLK_DIV_9
Definition: STC8x_MPWM.h:110
@ MPWM_SCLK_DIV_3
Definition: STC8x_MPWM.h:104
@ MPWM_SCLK_DIV_13
Definition: STC8x_MPWM.h:114
@ MPWM_SCLK_DIV_1
Definition: STC8x_MPWM.h:102
@ MPWM_SCLK_DIV_10
Definition: STC8x_MPWM.h:111
@ MPWM_SCLK_DIV_15
Definition: STC8x_MPWM.h:116
@ MPWM_SCLK_DIV_8
Definition: STC8x_MPWM.h:109
@ MPWM_SCLK_DIV_2
Definition: STC8x_MPWM.h:103
@ MPWM_SCLK_DIV_12
Definition: STC8x_MPWM.h:113
@ MPWM_SCLK_DIV_5
Definition: STC8x_MPWM.h:106
@ MPWM_SCLK_DIV_11
Definition: STC8x_MPWM.h:112
FSCSTATE MPWMn_Run(MPWMPort_Type port)
指定PWM端口开始工作。Run specified PWM port.
Definition: STC8x_MPWM.c:273