]> git.sur5r.net Git - freertos/blob - FreeRTOS-Plus/Demo/FreeRTOS_Plus_UDP_and_CLI_LPC1830_GCC/ThirdParty/CMSISv2p10_LPC18xx_DriverLib/src/lpc18xx_mcpwm.c
Slight modification to license blub text in header comments.
[freertos] / FreeRTOS-Plus / Demo / FreeRTOS_Plus_UDP_and_CLI_LPC1830_GCC / ThirdParty / CMSISv2p10_LPC18xx_DriverLib / src / lpc18xx_mcpwm.c
1 /**********************************************************************\r
2 * $Id$          lpc18xx_mcpwm.c         2011-06-02\r
3 *//**\r
4 * @file         lpc18xx_mcpwm.c\r
5 * @brief        Contains all functions support for Motor Control PWM firmware\r
6 *                       library on LPC18XX\r
7 * @version      1.0\r
8 * @date         02. June. 2011\r
9 * @author       NXP MCU SW Application Team\r
10 *\r
11 * Copyright(C) 2011, NXP Semiconductor\r
12 * All rights reserved.\r
13 *\r
14 ***********************************************************************\r
15 * Software that is described herein is for illustrative purposes only\r
16 * which provides customers with programming information regarding the\r
17 * products. This software is supplied "AS IS" without any warranties.\r
18 * NXP Semiconductors assumes no responsibility or liability for the\r
19 * use of the software, conveys no license or title under any patent,\r
20 * copyright, or mask work right to the product. NXP Semiconductors\r
21 * reserves the right to make changes in the software without\r
22 * notification. NXP Semiconductors also make no representation or\r
23 * warranty that such application will be suitable for the specified\r
24 * use without further testing or modification.\r
25 **********************************************************************/\r
26 \r
27 /* Peripheral group ----------------------------------------------------------- */\r
28 /** @addtogroup MCPWM\r
29  * @{\r
30  */\r
31 \r
32 /* Includes ------------------------------------------------------------------- */\r
33 #include "lpc18xx_mcpwm.h"\r
34 #include "lpc18xx_cgu.h"\r
35 \r
36 /* If this source file built with example, the LPC18xx FW library configuration\r
37  * file in each example directory ("lpc18xx_libcfg.h") must be included,\r
38  * otherwise the default FW library configuration file must be included instead\r
39  */\r
40 #ifdef __BUILD_WITH_EXAMPLE__\r
41 #include "lpc18xx_libcfg.h"\r
42 #else\r
43 #include "lpc18xx_libcfg_default.h"\r
44 #endif /* __BUILD_WITH_EXAMPLE__ */\r
45 \r
46 #ifdef _MCPWM\r
47 \r
48 /* Public Functions ----------------------------------------------------------- */\r
49 /** @addtogroup MCPWM_Public_Functions\r
50  * @{\r
51  */\r
52 \r
53 /*********************************************************************//**\r
54  * @brief               Initializes the MCPWM peripheral\r
55  * @param[in]   MCPWMx  Motor Control PWM peripheral selected, should be: LPC_MCPWM\r
56  * @return              None\r
57  **********************************************************************/\r
58 void MCPWM_Init(LPC_MCPWM_Type *MCPWMx)\r
59 {\r
60         /* Turn On MCPWM PCLK */\r
61         //LPC_CGU->BASE_VPB1_CLK = (SRC_PL160M_0<<24) | (1<<11);\r
62         CGU_EntityConnect(CGU_CLKSRC_PLL1, CGU_BASE_APB1);\r
63 \r
64         MCPWMx->CAP_CLR = MCPWM_CAPCLR_CAP(0) | MCPWM_CAPCLR_CAP(1) | MCPWM_CAPCLR_CAP(2);\r
65 \r
66         MCPWMx->INTF_CLR = MCPWM_INT_ILIM(0) | MCPWM_INT_ILIM(1) | MCPWM_INT_ILIM(2) \\r
67                                                                 | MCPWM_INT_IMAT(0) | MCPWM_INT_IMAT(1) | MCPWM_INT_IMAT(2) \\r
68                                                                 | MCPWM_INT_ICAP(0) | MCPWM_INT_ICAP(1) | MCPWM_INT_ICAP(2);\r
69 \r
70         MCPWMx->INTEN_CLR = MCPWM_INT_ILIM(0) | MCPWM_INT_ILIM(1) | MCPWM_INT_ILIM(2) \\r
71                                                                 | MCPWM_INT_IMAT(0) | MCPWM_INT_IMAT(1) | MCPWM_INT_IMAT(2) \\r
72                                                                 | MCPWM_INT_ICAP(0) | MCPWM_INT_ICAP(1) | MCPWM_INT_ICAP(2);\r
73 }\r
74 \r
75 \r
76 /*********************************************************************//**\r
77  * @brief               Configures each channel in MCPWM peripheral according to the\r
78  *                              specified parameters in the MCPWM_CHANNEL_CFG_Type.\r
79  * @param[in]   MCPWMx  Motor Control PWM peripheral selected, should be: LPC_MCPWM\r
80  * @param[in]   channelNum      Channel number, should be: 0..2.\r
81  * @param[in]   channelSetup Pointer to a MCPWM_CHANNEL_CFG_Type structure\r
82  *                              that contains the configuration information for the specified\r
83  *                              MCPWM channel.\r
84  * @return              None\r
85  **********************************************************************/\r
86 void MCPWM_ConfigChannel(LPC_MCPWM_Type *MCPWMx, uint32_t channelNum,\r
87                                                 MCPWM_CHANNEL_CFG_Type * channelSetup)\r
88 {\r
89         if (channelNum <= 2)\r
90         {\r
91                 if (channelNum == MCPWM_CHANNEL_0)\r
92                 {\r
93                         MCPWMx->TC[0] = channelSetup->channelTimercounterValue;\r
94                         MCPWMx->LIM[0] = channelSetup->channelPeriodValue;\r
95                         MCPWMx->MAT[0] = channelSetup->channelPulsewidthValue;\r
96                 }\r
97                 else if (channelNum == MCPWM_CHANNEL_1)\r
98                 {\r
99                         MCPWMx->TC[1] = channelSetup->channelTimercounterValue;\r
100                         MCPWMx->LIM[1] = channelSetup->channelPeriodValue;\r
101                         MCPWMx->MAT[1] = channelSetup->channelPulsewidthValue;\r
102                 }\r
103                 else if (channelNum == MCPWM_CHANNEL_2)\r
104                 {\r
105                         MCPWMx->TC[2] = channelSetup->channelTimercounterValue;\r
106                         MCPWMx->LIM[2] = channelSetup->channelPeriodValue;\r
107                         MCPWMx->MAT[2] = channelSetup->channelPulsewidthValue;\r
108                 }\r
109                 else\r
110                 {\r
111                         return;\r
112                 }\r
113 \r
114                 if (channelSetup->channelType == MCPWM_CHANNEL_CENTER_MODE)\r
115                 {\r
116                         MCPWMx->CON_SET = MCPWM_CON_CENTER(channelNum);\r
117                 }\r
118                 else\r
119                 {\r
120                         MCPWMx->CON_CLR = MCPWM_CON_CENTER(channelNum);\r
121                 }\r
122 \r
123                 if (channelSetup->channelPolarity == MCPWM_CHANNEL_PASSIVE_HI)\r
124                 {\r
125                         MCPWMx->CON_SET = MCPWM_CON_POLAR(channelNum);\r
126                 }\r
127                 else\r
128                 {\r
129                         MCPWMx->CON_CLR = MCPWM_CON_POLAR(channelNum);\r
130                 }\r
131 \r
132                 if (channelSetup->channelDeadtimeEnable == ENABLE)\r
133                 {\r
134                         MCPWMx->CON_SET = MCPWM_CON_DTE(channelNum);\r
135 \r
136                         MCPWMx->DT &= ~(MCPWM_DT(channelNum, 0x3FF));\r
137 \r
138                         MCPWMx->DT |= MCPWM_DT(channelNum, channelSetup->channelDeadtimeValue);\r
139                 }\r
140                 else\r
141                 {\r
142                         MCPWMx->CON_CLR = MCPWM_CON_DTE(channelNum);\r
143                 }\r
144 \r
145                 if (channelSetup->channelUpdateEnable == ENABLE)\r
146                 {\r
147                         MCPWMx->CON_CLR = MCPWM_CON_DISUP(channelNum);\r
148                 }\r
149                 else\r
150                 {\r
151                         MCPWMx->CON_SET = MCPWM_CON_DISUP(channelNum);\r
152                 }\r
153         }\r
154 }\r
155 \r
156 \r
157 /*********************************************************************//**\r
158  * @brief               Write to MCPWM shadow registers - Update the value for period\r
159  *                              and pulse width in MCPWM peripheral.\r
160  * @param[in]   MCPWMx  Motor Control PWM peripheral selected, should be: LPC_MCPWM\r
161  * @param[in]   channelNum      Channel Number, should be: 0..2.\r
162  * @param[in]   channelSetup Pointer to a MCPWM_CHANNEL_CFG_Type structure\r
163  *                              that contains the configuration information for the specified\r
164  *                              MCPWM channel.\r
165  * @return              None\r
166  **********************************************************************/\r
167 void MCPWM_WriteToShadow(LPC_MCPWM_Type *MCPWMx, uint32_t channelNum,\r
168                                                                                                         MCPWM_CHANNEL_CFG_Type *channelSetup)\r
169 {\r
170         if (channelNum == MCPWM_CHANNEL_0)\r
171         {\r
172                 MCPWMx->LIM[0] = channelSetup->channelPeriodValue;\r
173                 MCPWMx->MAT[0] = channelSetup->channelPulsewidthValue;\r
174         }\r
175         else if (channelNum == MCPWM_CHANNEL_1)\r
176         {\r
177                 MCPWMx->LIM[1] = channelSetup->channelPeriodValue;\r
178                 MCPWMx->MAT[1] = channelSetup->channelPulsewidthValue;\r
179         }\r
180         else if (channelNum == MCPWM_CHANNEL_2)\r
181         {\r
182                 MCPWMx->LIM[2] = channelSetup->channelPeriodValue;\r
183                 MCPWMx->MAT[2] = channelSetup->channelPulsewidthValue;\r
184         }\r
185 }\r
186 \r
187 \r
188 \r
189 /*********************************************************************//**\r
190  * @brief               Configures capture function in MCPWM peripheral\r
191  * @param[in]   MCPWMx  Motor Control PWM peripheral selected, should be: LPC_MCPWM\r
192  * @param[in]   channelNum      MCI (Motor Control Input pin) number, should be: 0..2\r
193  * @param[in]   captureConfig   Pointer to a MCPWM_CAPTURE_CFG_Type structure\r
194  *                              that contains the configuration information for the\r
195  *                              specified MCPWM capture.\r
196  * @return\r
197  **********************************************************************/\r
198 void MCPWM_ConfigCapture(LPC_MCPWM_Type *MCPWMx, uint32_t channelNum,\r
199                                                                                                 MCPWM_CAPTURE_CFG_Type *captureConfig)\r
200 {\r
201         if ((channelNum <= MCPWM_CHANNEL_2))\r
202         {\r
203 \r
204                 if (captureConfig->captureFalling == ENABLE)\r
205                 {\r
206                         MCPWMx->CAPCON_SET = MCPWM_CAPCON_CAPMCI_FE(captureConfig->captureChannel, channelNum);\r
207                 }\r
208                 else\r
209                 {\r
210                         MCPWMx->CAPCON_CLR = MCPWM_CAPCON_CAPMCI_FE(captureConfig->captureChannel, channelNum);\r
211                 }\r
212 \r
213                 if (captureConfig->captureRising == ENABLE)\r
214                 {\r
215                         MCPWMx->CAPCON_SET = MCPWM_CAPCON_CAPMCI_RE(captureConfig->captureChannel, channelNum);\r
216                 }\r
217                 else\r
218                 {\r
219                         MCPWMx->CAPCON_CLR = MCPWM_CAPCON_CAPMCI_RE(captureConfig->captureChannel, channelNum);\r
220                 }\r
221 \r
222                 if (captureConfig->timerReset == ENABLE)\r
223                 {\r
224                         MCPWMx->CAPCON_SET = MCPWM_CAPCON_RT(captureConfig->captureChannel);\r
225                 }\r
226                 else\r
227                 {\r
228                         MCPWMx->CAPCON_CLR = MCPWM_CAPCON_RT(captureConfig->captureChannel);\r
229                 }\r
230 \r
231                 if (captureConfig->hnfEnable == ENABLE)\r
232                 {\r
233                         MCPWMx->CAPCON_SET = MCPWM_CAPCON_HNFCAP(channelNum);\r
234                 }\r
235                 else\r
236                 {\r
237                         MCPWMx->CAPCON_CLR = MCPWM_CAPCON_HNFCAP(channelNum);\r
238                 }\r
239         }\r
240 }\r
241 \r
242 \r
243 /*********************************************************************//**\r
244  * @brief               Clears current captured value in specified capture channel\r
245  * @param[in]   MCPWMx  Motor Control PWM peripheral selected, should be: LPC_MCPWM\r
246  * @param[in]   captureChannel  Capture channel number, should be: 0..2\r
247  * @return              None\r
248  **********************************************************************/\r
249 void MCPWM_ClearCapture(LPC_MCPWM_Type *MCPWMx, uint32_t captureChannel)\r
250 {\r
251         MCPWMx->CAP_CLR = MCPWM_CAPCLR_CAP(captureChannel);\r
252 }\r
253 \r
254 /*********************************************************************//**\r
255  * @brief               Get current captured value in specified capture channel\r
256  * @param[in]   MCPWMx  Motor Control PWM peripheral selected, should be: LPC_MCPWM\r
257  * @param[in]   captureChannel  Capture channel number, should be: 0..2\r
258  * @return              None\r
259  **********************************************************************/\r
260 uint32_t MCPWM_GetCapture(LPC_MCPWM_Type *MCPWMx, uint32_t captureChannel)\r
261 {\r
262         if (captureChannel == MCPWM_CHANNEL_0)\r
263         {\r
264                 return (MCPWMx->CAP[0]);\r
265         }\r
266         else if (captureChannel == MCPWM_CHANNEL_1)\r
267         {\r
268                 return (MCPWMx->CAP[1]);\r
269         }\r
270         else if (captureChannel == MCPWM_CHANNEL_2)\r
271         {\r
272                 return (MCPWMx->CAP[2]);\r
273         }\r
274         return (0);\r
275 }\r
276 \r
277 \r
278 /*********************************************************************//**\r
279  * @brief               Configures Count control in MCPWM peripheral\r
280  * @param[in]   MCPWMx  Motor Control PWM peripheral selected, should be: LPC_MCPWM\r
281  * @param[in]   channelNum      Channel number, should be: 0..2\r
282  * @param[in]   countMode       Count mode, should be:\r
283  *                                      - ENABLE: Enables count mode.\r
284  *                                      - DISABLE: Disable count mode, the channel is in timer mode.\r
285  * @param[in]   countConfig     Pointer to a MCPWM_COUNT_CFG_Type structure\r
286  *                              that contains the configuration information for the\r
287  *                              specified MCPWM count control.\r
288  * @return              None\r
289  **********************************************************************/\r
290 void MCPWM_CountConfig(LPC_MCPWM_Type *MCPWMx, uint32_t channelNum,\r
291                                                                         uint32_t countMode, MCPWM_COUNT_CFG_Type *countConfig)\r
292 {\r
293         if ((channelNum <= 2))\r
294         {\r
295                 if (countMode == ENABLE)\r
296                 {\r
297                         MCPWMx->CNTCON_SET = MCPWM_CNTCON_CNTR(channelNum);\r
298 \r
299                         if (countConfig->countFalling == ENABLE)\r
300                         {\r
301                                 MCPWMx->CNTCON_SET = MCPWM_CNTCON_TCMCI_FE(countConfig->counterChannel,channelNum);\r
302                         }\r
303                         else\r
304                         {\r
305                                 MCPWMx->CNTCON_CLR = MCPWM_CNTCON_TCMCI_FE(countConfig->counterChannel,channelNum);\r
306                         }\r
307 \r
308                         if (countConfig->countRising == ENABLE)\r
309                         {\r
310                                 MCPWMx->CNTCON_SET = MCPWM_CNTCON_TCMCI_RE(countConfig->counterChannel,channelNum);\r
311                         }\r
312                         else\r
313                         {\r
314                                 MCPWMx->CNTCON_CLR = MCPWM_CNTCON_TCMCI_RE(countConfig->counterChannel,channelNum);\r
315                         }\r
316                 }\r
317                 else\r
318                 {\r
319                         MCPWMx->CNTCON_CLR = MCPWM_CNTCON_CNTR(channelNum);\r
320                 }\r
321         }\r
322 }\r
323 \r
324 \r
325 /*********************************************************************//**\r
326  * @brief               Start MCPWM activity for each MCPWM channel\r
327  * @param[in]   MCPWMx  Motor Control PWM peripheral selected, should be: LPC_MCPWM\r
328  * @param[in]   channel0 State of this command on channel 0:\r
329  *                                      - ENABLE: 'Start' command will effect on channel 0\r
330  *                                      - DISABLE: 'Start' command will not effect on channel 0\r
331  * @param[in]   channel1 State of this command on channel 1:\r
332  *                                      - ENABLE: 'Start' command will effect on channel 1\r
333  *                                      - DISABLE: 'Start' command will not effect on channel 1\r
334  * @param[in]   channel2 State of this command on channel 2:\r
335  *                                      - ENABLE: 'Start' command will effect on channel 2\r
336  *                                      - DISABLE: 'Start' command will not effect on channel 2\r
337  * @return              None\r
338  **********************************************************************/\r
339 void MCPWM_Start(LPC_MCPWM_Type *MCPWMx, uint32_t channel0,\r
340                                                                         uint32_t channel1, uint32_t channel2)\r
341 {\r
342         uint32_t regVal = 0;\r
343 \r
344         regVal = (channel0 ? MCPWM_CON_RUN(0) : 0) | (channel1 ? MCPWM_CON_RUN(1) : 0) \\r
345                                 | (channel2 ? MCPWM_CON_RUN(2) : 0);\r
346 \r
347         MCPWMx->CON_SET = regVal;\r
348 }\r
349 \r
350 \r
351 /*********************************************************************//**\r
352  * @brief               Stop MCPWM activity for each MCPWM channel\r
353  * @param[in]   MCPWMx  Motor Control PWM peripheral selected, should be: LPC_MCPWM\r
354  * @param[in]   channel0 State of this command on channel 0:\r
355  *                                      - ENABLE: 'Stop' command will effect on channel 0\r
356  *                                      - DISABLE: 'Stop' command will not effect on channel 0\r
357  * @param[in]   channel1 State of this command on channel 1:\r
358  *                                      - ENABLE: 'Stop' command will effect on channel 1\r
359  *                                      - DISABLE: 'Stop' command will not effect on channel 1\r
360  * @param[in]   channel2 State of this command on channel 2:\r
361  *                                      - ENABLE: 'Stop' command will effect on channel 2\r
362  *                                      - DISABLE: 'Stop' command will not effect on channel 2\r
363  * @return              None\r
364  **********************************************************************/\r
365 void MCPWM_Stop(LPC_MCPWM_Type *MCPWMx, uint32_t channel0,\r
366                 uint32_t channel1, uint32_t channel2)\r
367 {\r
368         uint32_t regVal = 0;\r
369 \r
370         regVal = (channel0 ? MCPWM_CON_RUN(0) : 0) | (channel1 ? MCPWM_CON_RUN(1) : 0) \\r
371                                 | (channel2 ? MCPWM_CON_RUN(2) : 0);\r
372 \r
373         MCPWMx->CON_CLR = regVal;\r
374 }\r
375 \r
376 \r
377 /*********************************************************************//**\r
378  * @brief               Enables/Disables 3-phase AC motor mode on MCPWM peripheral\r
379  * @param[in]   MCPWMx  Motor Control PWM peripheral selected, should be: LPC_MCPWM\r
380  * @param[in]   acMode  State of this command, should be:\r
381  *                                      - ENABLE.\r
382  *                                      - DISABLE.\r
383  * @return              None\r
384  **********************************************************************/\r
385 void MCPWM_ACMode(LPC_MCPWM_Type *MCPWMx, uint32_t acMode)\r
386 {\r
387         if (acMode)\r
388         {\r
389                 MCPWMx->CON_SET = MCPWM_CON_ACMODE;\r
390         }\r
391         else\r
392         {\r
393                 MCPWMx->CON_CLR = MCPWM_CON_ACMODE;\r
394         }\r
395 }\r
396 \r
397 \r
398 /*********************************************************************//**\r
399  * @brief               Enables/Disables 3-phase DC motor mode on MCPWM peripheral\r
400  * @param[in]   MCPWMx  Motor Control PWM peripheral selected, should be: LPC_MCPWM\r
401  * @param[in]   dcMode  State of this command, should be:\r
402  *                                      - ENABLE.\r
403  *                                      - DISABLE.\r
404  * @param[in]   outputInvered   Polarity of the MCOB outputs for all 3 channels,\r
405  *                              should be:\r
406  *                                      - ENABLE        :The MCOB outputs have opposite polarity from the MCOA outputs.\r
407  *                                      - DISABLE       :The MCOB outputs have the same basic polarity as the MCOA outputs.\r
408  * @param[in]   outputPattern   A value contains bits that enables/disables the specified\r
409  *                              output pins route to the internal MCOA0 signal, should be:\r
410  *                                      - MCPWM_PATENT_A0       :MCOA0 tracks internal MCOA0\r
411  *                                      - MCPWM_PATENT_B0       :MCOB0 tracks internal MCOA0\r
412  *                                      - MCPWM_PATENT_A1       :MCOA1 tracks internal MCOA0\r
413  *                                      - MCPWM_PATENT_B1       :MCOB1 tracks internal MCOA0\r
414  *                                      - MCPWM_PATENT_A2       :MCOA2 tracks internal MCOA0\r
415  *                                      - MCPWM_PATENT_B2       :MCOB2 tracks internal MCOA0\r
416  * @return              None\r
417  *\r
418  * Note: all these outputPatent values above can be ORed together for using as input parameter.\r
419  **********************************************************************/\r
420 void MCPWM_DCMode(LPC_MCPWM_Type *MCPWMx, uint32_t dcMode,\r
421                                         uint32_t outputInvered, uint32_t outputPattern)\r
422 {\r
423         if (dcMode)\r
424         {\r
425                 MCPWMx->CON_SET = MCPWM_CON_DCMODE;\r
426         }\r
427         else\r
428         {\r
429                 MCPWMx->CON_CLR = MCPWM_CON_DCMODE;\r
430         }\r
431 \r
432         if (outputInvered)\r
433         {\r
434                 MCPWMx->CON_SET = MCPWM_CON_INVBDC;\r
435         }\r
436         else\r
437         {\r
438                 MCPWMx->CON_CLR = MCPWM_CON_INVBDC;\r
439         }\r
440 \r
441         MCPWMx->CCP = outputPattern;\r
442 }\r
443 \r
444 \r
445 /*********************************************************************//**\r
446  * @brief               Configures the specified interrupt in MCPWM peripheral\r
447  * @param[in]   MCPWMx  Motor Control PWM peripheral selected, should be: LPC_MCPWM\r
448  * @param[in]   ulIntType       Interrupt type, should be:\r
449  *                                      - MCPWM_INTFLAG_LIM0    :Limit interrupt for channel (0)\r
450  *                                      - MCPWM_INTFLAG_MAT0    :Match interrupt for channel (0)\r
451  *                                      - MCPWM_INTFLAG_CAP0    :Capture interrupt for channel (0)\r
452  *                                      - MCPWM_INTFLAG_LIM1    :Limit interrupt for channel (1)\r
453  *                                      - MCPWM_INTFLAG_MAT1    :Match interrupt for channel (1)\r
454  *                                      - MCPWM_INTFLAG_CAP1    :Capture interrupt for channel (1)\r
455  *                                      - MCPWM_INTFLAG_LIM2    :Limit interrupt for channel (2)\r
456  *                                      - MCPWM_INTFLAG_MAT2    :Match interrupt for channel (2)\r
457  *                                      - MCPWM_INTFLAG_CAP2    :Capture interrupt for channel (2)\r
458  *                                      - MCPWM_INTFLAG_ABORT   :Fast abort interrupt\r
459  * @param[in]   NewState        New State of this command, should be:\r
460  *                                      - ENABLE.\r
461  *                                      - DISABLE.\r
462  * @return              None\r
463  *\r
464  * Note: all these ulIntType values above can be ORed together for using as input parameter.\r
465  **********************************************************************/\r
466 void MCPWM_IntConfig(LPC_MCPWM_Type *MCPWMx, uint32_t ulIntType, FunctionalState NewState)\r
467 {\r
468         if (NewState)\r
469         {\r
470                 MCPWMx->INTEN_SET = ulIntType;\r
471         }\r
472         else\r
473         {\r
474                 MCPWMx->INTEN_CLR = ulIntType;\r
475         }\r
476 }\r
477 \r
478 \r
479 /*********************************************************************//**\r
480  * @brief               Sets/Forces the specified interrupt for MCPWM peripheral\r
481  * @param[in]   MCPWMx  Motor Control PWM peripheral selected, should be: LPC_MCPWM\r
482  * @param[in]   ulIntType       Interrupt type, should be:\r
483  *                                      - MCPWM_INTFLAG_LIM0    :Limit interrupt for channel (0)\r
484  *                                      - MCPWM_INTFLAG_MAT0    :Match interrupt for channel (0)\r
485  *                                      - MCPWM_INTFLAG_CAP0    :Capture interrupt for channel (0)\r
486  *                                      - MCPWM_INTFLAG_LIM1    :Limit interrupt for channel (1)\r
487  *                                      - MCPWM_INTFLAG_MAT1    :Match interrupt for channel (1)\r
488  *                                      - MCPWM_INTFLAG_CAP1    :Capture interrupt for channel (1)\r
489  *                                      - MCPWM_INTFLAG_LIM2    :Limit interrupt for channel (2)\r
490  *                                      - MCPWM_INTFLAG_MAT2    :Match interrupt for channel (2)\r
491  *                                      - MCPWM_INTFLAG_CAP2    :Capture interrupt for channel (2)\r
492  *                                      - MCPWM_INTFLAG_ABORT   :Fast abort interrupt\r
493  * @return              None\r
494  * Note: all these ulIntType values above can be ORed together for using as input parameter.\r
495  **********************************************************************/\r
496 void MCPWM_IntSet(LPC_MCPWM_Type *MCPWMx, uint32_t ulIntType)\r
497 {\r
498         MCPWMx->INTF_SET = ulIntType;\r
499 }\r
500 \r
501 \r
502 /*********************************************************************//**\r
503  * @brief               Clear the specified interrupt pending for MCPWM peripheral\r
504  * @param[in]   MCPWMx  Motor Control PWM peripheral selected, should be: LPC_MCPWM\r
505  * @param[in]   ulIntType       Interrupt type, should be:\r
506  *                                      - MCPWM_INTFLAG_LIM0    :Limit interrupt for channel (0)\r
507  *                                      - MCPWM_INTFLAG_MAT0    :Match interrupt for channel (0)\r
508  *                                      - MCPWM_INTFLAG_CAP0    :Capture interrupt for channel (0)\r
509  *                                      - MCPWM_INTFLAG_LIM1    :Limit interrupt for channel (1)\r
510  *                                      - MCPWM_INTFLAG_MAT1    :Match interrupt for channel (1)\r
511  *                                      - MCPWM_INTFLAG_CAP1    :Capture interrupt for channel (1)\r
512  *                                      - MCPWM_INTFLAG_LIM2    :Limit interrupt for channel (2)\r
513  *                                      - MCPWM_INTFLAG_MAT2    :Match interrupt for channel (2)\r
514  *                                      - MCPWM_INTFLAG_CAP2    :Capture interrupt for channel (2)\r
515  *                                      - MCPWM_INTFLAG_ABORT   :Fast abort interrupt\r
516  * @return              None\r
517  * Note: all these ulIntType values above can be ORed together for using as input parameter.\r
518  **********************************************************************/\r
519 void MCPWM_IntClear(LPC_MCPWM_Type *MCPWMx, uint32_t ulIntType)\r
520 {\r
521         MCPWMx->INTF_CLR = ulIntType;\r
522 }\r
523 \r
524 \r
525 /*********************************************************************//**\r
526  * @brief               Check whether if the specified interrupt in MCPWM is set or not\r
527  * @param[in]   MCPWMx  Motor Control PWM peripheral selected, should be: LPC_MCPWM\r
528  * @param[in]   ulIntType       Interrupt type, should be:\r
529  *                                      - MCPWM_INTFLAG_LIM0    :Limit interrupt for channel (0)\r
530  *                                      - MCPWM_INTFLAG_MAT0    :Match interrupt for channel (0)\r
531  *                                      - MCPWM_INTFLAG_CAP0    :Capture interrupt for channel (0)\r
532  *                                      - MCPWM_INTFLAG_LIM1    :Limit interrupt for channel (1)\r
533  *                                      - MCPWM_INTFLAG_MAT1    :Match interrupt for channel (1)\r
534  *                                      - MCPWM_INTFLAG_CAP1    :Capture interrupt for channel (1)\r
535  *                                      - MCPWM_INTFLAG_LIM2    :Limit interrupt for channel (2)\r
536  *                                      - MCPWM_INTFLAG_MAT2    :Match interrupt for channel (2)\r
537  *                                      - MCPWM_INTFLAG_CAP2    :Capture interrupt for channel (2)\r
538  *                                      - MCPWM_INTFLAG_ABORT   :Fast abort interrupt\r
539  * @return              None\r
540  **********************************************************************/\r
541 FlagStatus MCPWM_GetIntStatus(LPC_MCPWM_Type *MCPWMx, uint32_t ulIntType)\r
542 {\r
543         return ((MCPWMx->INTF & ulIntType) ? SET : RESET);\r
544 }\r
545 \r
546 /**\r
547  * @}\r
548  */\r
549 \r
550 #endif /* _MCPWM */\r
551 /**\r
552  * @}\r
553  */\r
554 \r
555 /* --------------------------------- End Of File ------------------------------ */\r